diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..62dc6b584b2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,96 @@ +--- +Language: Cpp +BasedOnStyle: LLVM +AlignConsecutiveAssignments: true +#llvm11: AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true +#llvm10-11: AlignOperands: true - Align +#llvm11: AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +AlwaysBreakAfterReturnType: AllDefinitions +# Can enable the following section when llvm 12.x is out +#AttributeMacros: +# - H5_ATTR_FORMAT +# - H5_ATTR_UNUSED +# - H5_ATTR_DEPRECATED_USED +# - H5_ATTR_NDEBUG_UNUSED +# - H5_ATTR_DEBUG_API_USED +# - H5_ATTR_PARALLEL_UNUSED +# - H5_ATTR_PARALLEL_USED +# - H5_ATTR_NORETURN +# - 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)/' + Priority: 3 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 4 + SortPriority: 0 + - Regex: '.*' + Priority: 0 + SortPriority: 0 + - Regex: '^H5*.*' + Priority: 1 + SortPriority: 0 + - Regex: 'private.*' + Priority: 2 + SortPriority: 0 +IncludeIsMainRegex: '(public)?$' +IndentCaseLabels: true +#llvm11: IndentCaseBlocks: false +IndentGotoLabels: false +#llvm11: IndentExternBlock: AfterExternBlock +IndentWidth: 4 +#llvm11: InsertTrailingCommas: None +MacroBlockBegin: "^BEGIN_FUNC" +MacroBlockEnd: "^END_FUNC" +ObjCBlockIndentWidth: 4 +#llvm11: ObjCBreakBeforeNestedBlockParam: true +ReflowComments: true +SortIncludes: false +StatementMacros: + - FUNC_ENTER_API + - FUNC_LEAVE_API + - FUNC_ENTER_NOAPI_NOINIT_NOERR + - FUNC_LEAVE_NOAPI + - H5_BEGIN_TAG + - HGOTO_DONE_TAG + - H5_END_TAG + - HSYS_DONE_ERROR + - HSYS_GOTO_ERROR + - HDONE_ERROR + - HERROR + - H5_LEAVE + - H5E_PRINTF + - H5E_THROW + - HGOTO_DONE + - HGOTO_ERROR + - HMPI_ERROR + - HMPI_DONE_ERROR + - HMPI_GOTO_ERROR + - H5_GCC_DIAG_OFF + - H5_GCC_DIAG_ON + - CATCH +#llvm10: TypenameMacros: +#llvm10: - STACK_OF +#llvm10: - LIST +#llvm11: WhitespaceSensitiveMacros: +#llvm11: - STRINGIZE +#llvm11: - PP_STRINGIZE +... + diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 270654207d6..d5f801e2895 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -5,13 +5,15 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # option (USE_LIBAEC "Use AEC library as SZip Filter" OFF) include (ExternalProject) +include (FetchContent) + #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) @@ -30,7 +32,9 @@ if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MAT set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME}) if (NOT EXISTS "${ZLIB_URL}") set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) - message (STATUS "Filter ZLIB file ${ZLIB_URL} not found") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB file ${ZLIB_URL} not found") + endif () endif () set (SZIP_URL ${TGZPATH}/${SZIP_TGZ_NAME}) if (USE_LIBAEC) @@ -38,7 +42,9 @@ if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MAT endif () if (NOT EXISTS "${SZIP_URL}") set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) - message (STATUS "Filter SZIP file ${SZIP_URL} not found") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP file ${SZIP_URL} not found") + endif () endif () else () set (ZLIB_USE_EXTERNAL 0) @@ -74,7 +80,9 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) set (H5_HAVE_FILTER_DEFLATE 1) set (H5_HAVE_ZLIB_H 1) set (H5_HAVE_LIBZ 1) - message (STATUS "Filter ZLIB is built") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB is built") + endif () else () message (FATAL_ERROR " ZLib is Required for ZLib support in HDF5") endif () @@ -90,7 +98,9 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) endif () set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS}) - message (STATUS "Filter ZLIB is ON") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB is ON") + endif () endif () #----------------------------------------------------------------------------- @@ -120,9 +130,13 @@ if (HDF5_ENABLE_SZIP_SUPPORT) set (H5_HAVE_FILTER_SZIP 1) set (H5_HAVE_SZLIB_H 1) set (H5_HAVE_LIBSZ 1) - message (STATUS "Filter SZIP is built") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP is built") + endif () if (USE_LIBAEC) - message (STATUS "... with library AEC") + 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}) @@ -133,7 +147,9 @@ if (HDF5_ENABLE_SZIP_SUPPORT) endif () set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) - message (STATUS "Filter SZIP is ON") + 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 () diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index c9eb229207b..65be97154f3 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -53,7 +53,7 @@ endif () #----------------------------------------------------------------------------- set (HDF5_INCLUDES_BUILD_TIME ${HDF5_SRC_DIR} ${HDF5_CPP_SRC_DIR} ${HDF5_HL_SRC_DIR} - ${HDF5_TOOLS_SRC_DIR} ${HDF5_BINARY_DIR} + ${HDF5_TOOLS_SRC_DIR} ${HDF5_SRC_BINARY_DIR} ) #----------------------------------------------------------------------------- @@ -124,10 +124,10 @@ else () endif () configure_file ( ${HDF_RESOURCES_DIR}/libhdf5.settings.cmake.in - ${HDF5_BINARY_DIR}/libhdf5.settings ESCAPE_QUOTES @ONLY + ${HDF5_SRC_BINARY_DIR}/libhdf5.settings ESCAPE_QUOTES @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/libhdf5.settings + FILES ${HDF5_SRC_BINARY_DIR}/libhdf5.settings DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries ) @@ -185,7 +185,7 @@ HDF_README_PROPERTIES(HDF5_BUILD_FORTRAN) #----------------------------------------------------------------------------- # Configure the COPYING.txt file for the windows binary package #----------------------------------------------------------------------------- -if (WIN32 OR MINGW) +if (WIN32) configure_file (${HDF5_SOURCE_DIR}/COPYING ${HDF5_BINARY_DIR}/COPYING.txt @ONLY) endif () @@ -201,10 +201,9 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) if (EXISTS "${HDF5_SOURCE_DIR}/release_docs" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/release_docs") set (release_files ${HDF5_SOURCE_DIR}/release_docs/USING_HDF5_CMake.txt - ${HDF5_SOURCE_DIR}/release_docs/COPYING ${HDF5_SOURCE_DIR}/release_docs/RELEASE.txt ) - if (WIN32 OR MINGW) + if (WIN32) set (release_files ${release_files} ${HDF5_SOURCE_DIR}/release_docs/USING_HDF5_VS.txt @@ -218,7 +217,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) ${HDF5_SOURCE_DIR}/release_docs/HISTORY-1_8.txt ${HDF5_SOURCE_DIR}/release_docs/INSTALL ) - if (WIN32 OR MINGW) + if (WIN32) set (release_files ${release_files} ${HDF5_SOURCE_DIR}/release_docs/INSTALL_Windows.txt @@ -245,19 +244,6 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) endif () endif () -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - if (CMAKE_HOST_UNIX) - set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/HDF_Group/${HDF5_PACKAGE_NAME}/${HDF5_PACKAGE_VERSION}" - CACHE PATH "Install path prefix, prepended onto install directories." FORCE) - else () - GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) - set (CMAKE_INSTALL_PREFIX - "${CMAKE_GENERIC_PROGRAM_FILES}/HDF_Group/${HDF5_PACKAGE_NAME}/${HDF5_PACKAGE_VERSION}" - CACHE PATH "Install path prefix, prepended onto install directories." FORCE) - set (CMAKE_GENERIC_PROGRAM_FILES) - endif () -endif () - #----------------------------------------------------------------------------- # Set the cpack variables #----------------------------------------------------------------------------- @@ -272,9 +258,9 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGE_VERSION_MAJOR "${HDF5_PACKAGE_VERSION_MAJOR}") set (CPACK_PACKAGE_VERSION_MINOR "${HDF5_PACKAGE_VERSION_MINOR}") set (CPACK_PACKAGE_VERSION_PATCH "") + set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") if (EXISTS "${HDF5_SOURCE_DIR}/release_docs") set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/release_docs/RELEASE.txt") - set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/release_docs/RELEASE.txt") endif () set (CPACK_PACKAGE_RELOCATABLE TRUE) @@ -286,7 +272,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.bmp") set (CPACK_GENERATOR "TGZ") - if (WIN32 OR MINGW) + if (WIN32) set (CPACK_GENERATOR "ZIP") if (NSIS_EXECUTABLE) @@ -451,7 +437,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut if (HDF5_PACKAGE_EXTLIBS) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) - if (WIN32 OR MINGW) + if (WIN32) set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;ALL;/") else () set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;libraries;/") @@ -460,7 +446,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut endif () endif () if (SZIP_FOUND AND SZIP_USE_EXTERNAL) - if (WIN32 OR MINGW) + if (WIN32) set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;ALL;/") else () set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;libraries;/") @@ -468,6 +454,13 @@ The HDF5 data model, file format, API, library, and tools are open and distribut set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${SZIP_INCLUDE_DIR_GEN};SZIP;configinstall;/") endif () endif () + if (PLUGIN_FOUND AND PLUGIN_USE_EXTERNAL) + if (WIN32) + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;ALL;/") + else () + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;libraries;/") + endif () + endif () endif () endif () @@ -550,6 +543,13 @@ The HDF5 data model, file format, API, library, and tools are open and distribut ) endif () + cpack_add_component (utilsapplications + DISPLAY_NAME "HDF5 Utility Applications" + DEPENDS libraries + GROUP Applications + INSTALL_TYPES Full Developer User + ) + if (HDF5_BUILD_TOOLS) cpack_add_component (toolsapplications DISPLAY_NAME "HDF5 Tools Applications" diff --git a/CMakeLists.txt b/CMakeLists.txt index 029449d07c0..b75fdd2ce3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,9 +42,8 @@ set (CMAKE_IGNORE_EOL "--ignore-eol") if (CMAKE_VERSION VERSION_LESS "3.14.0") set (CMAKE_IGNORE_EOL "") if (WIN32) - message (FATAL_ERROR "Windows builds requires a minimum of CMake 3.14") + message (FATAL_ERROR "Windows builds require a minimum of CMake 3.14") endif() -else () endif () #----------------------------------------------------------------------------- @@ -72,6 +71,13 @@ mark_as_advanced (HDF5_EXTERNAL_LIB_PREFIX) # If the parent project needs to install hdf libraries, but avoid # name conflicts with system versions, then a prefix may be added # to ensure that the correct versions configured are used. +set (HDF5_LIB_INFIX "" CACHE STRING "Use infix for custom library naming.") +mark_as_advanced (HDF5_LIB_INFIX) +# HDF5_LIB_INFIX : +# This infix is added to all library names after 'hdf5'. +# e.g. the infix '_openmpi' results in the library name 'libhdf5_openmpi.so' +# This name is used in packages on debian based systems. +# (see https://packages.debian.org/jessie/amd64/libhdf5-openmpi-8/filelist) # # HDF5_INSTALL_BIN_DIR, HDF5_INSTALL_LIB_DIR, HDF5_INSTALL_INCLUDE_DIR, HDF5_INSTALL_DATA_DIR : # Customize the 'bin', 'lib', 'include', and 'share' installation directories. @@ -131,20 +137,20 @@ mark_as_advanced (ALLOW_UNSUPPORTED) #----------------------------------------------------------------------------- # Set the core names of all the libraries #----------------------------------------------------------------------------- -set (HDF5_LIB_CORENAME "hdf5") -set (HDF5_TEST_LIB_CORENAME "hdf5_test") -set (HDF5_CPP_LIB_CORENAME "hdf5_cpp") -set (HDF5_HL_LIB_CORENAME "hdf5_hl") -set (HDF5_HL_CPP_LIB_CORENAME "hdf5_hl_cpp") -set (HDF5_TOOLS_LIB_CORENAME "hdf5_tools") -set (HDF5_UTILS_LIB_CORENAME "hdf5_utils") -set (HDF5_F90_LIB_CORENAME "hdf5_fortran") -set (HDF5_F90_C_LIB_CORENAME "hdf5_f90cstub") -set (HDF5_F90_TEST_LIB_CORENAME "hdf5_test_fortran") -set (HDF5_F90_C_TEST_LIB_CORENAME "hdf5_test_f90cstub") -set (HDF5_HL_F90_LIB_CORENAME "hdf5_hl_fortran") -set (HDF5_HL_F90_C_LIB_CORENAME "hdf5_hl_f90cstub") -set (HDF5_JAVA_JNI_LIB_CORENAME "hdf5_java") +set (HDF5_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}") +set (HDF5_TEST_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_test") +set (HDF5_CPP_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_cpp") +set (HDF5_HL_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_hl") +set (HDF5_HL_CPP_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_hl_cpp") +set (HDF5_TOOLS_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_tools") +set (HDF5_UTILS_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_utils") +set (HDF5_F90_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_fortran") +set (HDF5_F90_C_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_f90cstub") +set (HDF5_F90_TEST_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_test_fortran") +set (HDF5_F90_C_TEST_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_test_f90cstub") +set (HDF5_HL_F90_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_hl_fortran") +set (HDF5_HL_F90_C_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_hl_f90cstub") +set (HDF5_JAVA_JNI_LIB_CORENAME "hdf5${HDF5_LIB_INFIX}_java") set (HDF5_JAVA_HDF5_LIB_CORENAME "jarhdf5") set (HDF5_JAVA_TEST_LIB_CORENAME "jartest5") @@ -204,6 +210,7 @@ set (HDF5_HL_F90_C_LIBSH_TARGET "${HDF5_HL_F90_C_LIB_CORENAME}-shared") #----------------------------------------------------------------------------- # Define some CMake variables for use later in the project #----------------------------------------------------------------------------- +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) @@ -225,6 +232,7 @@ 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_DOXYGEN_DIR ${HDF5_SOURCE_DIR}/doxygen) #----------------------------------------------------------------------------- # parse the full version number from H5public.h and include in H5_VERS_INFO @@ -236,9 +244,11 @@ string (REGEX REPLACE ".*#define[ \t]+H5_VERS_MINOR[ \t]+([0-9]*).*$" "\\1" H5_VERS_MINOR ${_h5public_h_contents}) string (REGEX REPLACE ".*#define[ \t]+H5_VERS_RELEASE[ \t]+([0-9]*).*$" "\\1" H5_VERS_RELEASE ${_h5public_h_contents}) -string (REGEX REPLACE ".*#define[ \t]+H5_VERS_SUBRELEASE[ \t]+\"([0-9A-Za-z._\-]*)\".*$" +string (REGEX REPLACE ".*#define[ \t]+H5_VERS_SUBRELEASE[ \t]+\"([0-9A-Za-z._-]*)\".*$" "\\1" H5_VERS_SUBRELEASE ${_h5public_h_contents}) -#message (STATUS "VERSION: ${H5_VERS_MAJOR}.${H5_VERS_MINOR}.${H5_VERS_RELEASE}-${H5_VERS_SUBRELEASE}") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "VERSION: ${H5_VERS_MAJOR}.${H5_VERS_MINOR}.${H5_VERS_RELEASE}-${H5_VERS_SUBRELEASE}") +endif () #----------------------------------------------------------------------------- # parse the full soversion number from config/lt_vers.am and include in H5_SOVERS_INFO @@ -251,7 +261,9 @@ string (REGEX REPLACE ".*LT_VERS_REVISION[ \t]+=[ \t]+([0-9]*).*$" string (REGEX REPLACE ".*LT_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_LIB_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_LIB_SOVERS_MAJOR ${H5_LIB_SOVERS_INTERFACE}-${H5_LIB_SOVERS_RELEASE}) -message (STATUS "SOVERSION: ${H5_LIB_SOVERS_MAJOR}.${H5_LIB_SOVERS_RELEASE}.${H5_LIB_SOVERS_MINOR}") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION: ${H5_LIB_SOVERS_MAJOR}.${H5_LIB_SOVERS_RELEASE}.${H5_LIB_SOVERS_MINOR}") +endif () string (REGEX MATCH ".*LT_TOOLS_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_TOOLS_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_TOOLS_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_TOOLS_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" @@ -261,7 +273,9 @@ if (H5_TOOLS_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_TOOLS_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_TOOLS_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_TOOLS_SOVERS_MAJOR ${H5_TOOLS_SOVERS_INTERFACE}-${H5_TOOLS_SOVERS_RELEASE}) - message (STATUS "SOVERSION_TOOLS: ${H5_TOOLS_SOVERS_MAJOR}.${H5_TOOLS_SOVERS_RELEASE}.${H5_TOOLS_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_TOOLS: ${H5_TOOLS_SOVERS_MAJOR}.${H5_TOOLS_SOVERS_RELEASE}.${H5_TOOLS_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_CXX_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_CXX_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_CXX_SOVERS_EXISTS) @@ -272,7 +286,9 @@ if (H5_CXX_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_CXX_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_CXX_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_CXX_SOVERS_MAJOR ${H5_CXX_SOVERS_INTERFACE}-${H5_CXX_SOVERS_RELEASE}) - message (STATUS "SOVERSION_CXX: ${H5_CXX_SOVERS_MAJOR}.${H5_CXX_SOVERS_RELEASE}.${H5_CXX_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_CXX: ${H5_CXX_SOVERS_MAJOR}.${H5_CXX_SOVERS_RELEASE}.${H5_CXX_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_F_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_F_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_F_SOVERS_EXISTS) @@ -283,7 +299,9 @@ if (H5_F_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_F_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_F_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_F_SOVERS_MAJOR ${H5_F_SOVERS_INTERFACE}-${H5_F_SOVERS_RELEASE}) - message (STATUS "SOVERSION_F: ${H5_F_SOVERS_MAJOR}.${H5_F_SOVERS_RELEASE}.${H5_F_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_F: ${H5_F_SOVERS_MAJOR}.${H5_F_SOVERS_RELEASE}.${H5_F_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_HL_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_HL_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_HL_SOVERS_EXISTS) @@ -294,7 +312,9 @@ if (H5_HL_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_HL_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_HL_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_HL_SOVERS_MAJOR ${H5_HL_SOVERS_INTERFACE}-${H5_HL_SOVERS_RELEASE}) - message (STATUS "SOVERSION_HL: ${H5_HL_SOVERS_MAJOR}.${H5_HL_SOVERS_RELEASE}.${H5_HL_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_HL: ${H5_HL_SOVERS_MAJOR}.${H5_HL_SOVERS_RELEASE}.${H5_HL_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_HL_CXX_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_HL_CXX_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_HL_CXX_SOVERS_EXISTS) @@ -305,7 +325,9 @@ if (H5_HL_CXX_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_HL_CXX_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_HL_CXX_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_HL_CXX_SOVERS_MAJOR ${H5_HL_CXX_SOVERS_INTERFACE}-${H5_HL_CXX_SOVERS_RELEASE}) - message (STATUS "SOVERSION_HL_CXX: ${H5_HL_CXX_SOVERS_MAJOR}.${H5_HL_CXX_SOVERS_RELEASE}.${H5_HL_CXX_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_HL_CXX: ${H5_HL_CXX_SOVERS_MAJOR}.${H5_HL_CXX_SOVERS_RELEASE}.${H5_HL_CXX_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_HL_F_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_HL_F_SOVERS_EXISTS ${_lt_vers_am_contents}) if (H5_HL_F_SOVERS_EXISTS) @@ -316,7 +338,9 @@ if (H5_HL_F_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_HL_F_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_HL_F_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_HL_F_SOVERS_MAJOR ${H5_HL_F_SOVERS_INTERFACE}-${H5_HL_F_SOVERS_RELEASE}) - message (STATUS "SOVERSION_HL_F: ${H5_HL_F_SOVERS_MAJOR}.${H5_HL_F_SOVERS_RELEASE}.${H5_HL_F_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_HL_F: ${H5_HL_F_SOVERS_MAJOR}.${H5_HL_F_SOVERS_RELEASE}.${H5_HL_F_SOVERS_MINOR}") + endif () endif () string (REGEX MATCH ".*LT_JAVA_VERS_INTERFACE[ \t]+=[ \t]+([0-9]*).*$" H5_JAVA_SOVERS_EXISTS ${_lt_vers_am_contents}) if(H5_JAVA_SOVERS_EXISTS) @@ -327,7 +351,9 @@ if(H5_JAVA_SOVERS_EXISTS) string (REGEX REPLACE ".*LT_JAVA_VERS_AGE[ \t]+=[ \t]+([0-9]*).*$" "\\1" H5_JAVA_SOVERS_RELEASE ${_lt_vers_am_contents}) math (EXPR H5_JAVA_SOVERS_MAJOR ${H5_JAVA_SOVERS_INTERFACE}-${H5_JAVA_SOVERS_RELEASE}) - message (STATUS "SOVERSION_JAVA: ${H5_JAVA_SOVERS_MAJOR}.${H5_JAVA_SOVERS_RELEASE}.${H5_JAVA_SOVERS_MINOR}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SOVERSION_JAVA: ${H5_JAVA_SOVERS_MAJOR}.${H5_JAVA_SOVERS_RELEASE}.${H5_JAVA_SOVERS_MINOR}") + endif () endif () #----------------------------------------------------------------------------- @@ -409,6 +435,7 @@ include (${HDF_RESOURCES_EXT_DIR}/HDFMacros.cmake) HDF_DIR_PATHS(${HDF5_PACKAGE_NAME}) include (${HDF_RESOURCES_EXT_DIR}/HDFLibMacros.cmake) +include (${HDF_RESOURCES_DIR}/HDF5PluginMacros.cmake) include (${HDF_RESOURCES_DIR}/HDF5Macros.cmake) #----------------------------------------------------------------------------- @@ -480,6 +507,14 @@ else () set (tgt_file_ext "-shared") endif () +#----------------------------------------------------------------------------- +# perl is used in some optional src and tests, check availability +find_package (Perl) +if (PERL_FOUND) + set (H5_PERL_FOUND YES) +endif () +#----------------------------------------------------------------------------- + #----------------------------------------------------------------------------- # Option to Build Static executables #----------------------------------------------------------------------------- @@ -491,12 +526,21 @@ if (BUILD_STATIC_EXECS) endif () endif () +option (HDF5_ENABLE_ANALYZER_TOOLS "enable the use of Clang tools" OFF) +mark_as_advanced (HDF5_ENABLE_ANALYZER_TOOLS) if (HDF5_ENABLE_ANALYZER_TOOLS) include (${HDF5_SOURCE_DIR}/config/sanitizer/tools.cmake) endif () +option (HDF5_ENABLE_SANITIZERS "execute the Clang sanitizer" OFF) +mark_as_advanced (HDF5_ENABLE_SANITIZERS) if (HDF5_ENABLE_SANITIZERS) include (${HDF5_SOURCE_DIR}/config/sanitizer/sanitizers.cmake) endif () +option (HDF5_ENABLE_FORMATTERS "format source files" OFF) +mark_as_advanced (HDF5_ENABLE_FORMATTERS) +if (HDF5_ENABLE_FORMATTERS) + include (${HDF5_SOURCE_DIR}/config/sanitizer/formatting.cmake) +endif () #----------------------------------------------------------------------------- # Option to use code coverage @@ -527,6 +571,20 @@ endif () # 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 #----------------------------------------------------------------------------- @@ -568,12 +626,15 @@ endif () # Certain systems may add /Debug or /Release to output paths # and we need to call the executable from inside the CMake configuration #----------------------------------------------------------------------------- -set (EXE_EXT "") -if (WIN32 OR MINGW) - set (EXE_EXT ".exe") - add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1 _CRT_SECURE_NO_WARNINGS _CONSOLE) +if (WIN32) + add_compile_definitions (_CRT_SECURE_NO_WARNINGS) + if (MSVC) + add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1 _CONSOLE) + endif () endif () +option (HDF5_MINGW_STATIC_GCC_LIBS "Statically link libgcc/libstdc++" OFF) + if (MSVC) set (CMAKE_MFC_FLAG 0) set (WIN_COMPILE_FLAGS "") @@ -581,7 +642,7 @@ if (MSVC) endif () set (MAKE_SYSTEM) -if (CMAKE_BUILD_TOOL MATCHES "make") +if (CMAKE_MAKE_PROGRAM MATCHES "make") set (MAKE_SYSTEM 1) endif () @@ -691,9 +752,9 @@ if (H5_HAVE_PARALLEL) endif () endif () -#option (DEFAULT_API_VERSION "Enable v1.10 API (v16, v18, v110)" "v110") -set (DEFAULT_API_VERSION "v110" CACHE STRING "Enable v1.10 API (v16, v18, v110)") -set_property (CACHE DEFAULT_API_VERSION PROPERTY STRINGS v16 v18 v110) +#option (DEFAULT_API_VERSION "Enable v1.12 API (v16, v18, v110, v112)" "v112") +set (DEFAULT_API_VERSION "v112" CACHE STRING "Enable v1.12 API (v16, v18, v110, v112)") +set_property (CACHE DEFAULT_API_VERSION PROPERTY STRINGS v16 v18 v110 v112) #----------------------------------------------------------------------------- # Option to use 1.6.x API #----------------------------------------------------------------------------- @@ -713,14 +774,22 @@ endif () #----------------------------------------------------------------------------- # Option to use 1.10.x API #----------------------------------------------------------------------------- -if (NOT DEFAULT_API_VERSION) - set (DEFAULT_API_VERSION "v110") -endif () set (H5_USE_110_API_DEFAULT 0) if (DEFAULT_API_VERSION MATCHES "v110") set (H5_USE_110_API_DEFAULT 1) endif () +#----------------------------------------------------------------------------- +# Option to use 1.12.x API +#----------------------------------------------------------------------------- +if (NOT DEFAULT_API_VERSION) + set (DEFAULT_API_VERSION "v112") +endif () +set (H5_USE_112_API_DEFAULT 0) +if (DEFAULT_API_VERSION MATCHES "v112") + set (H5_USE_112_API_DEFAULT 1) +endif () + #----------------------------------------------------------------------------- # Include user macros #----------------------------------------------------------------------------- @@ -754,40 +823,52 @@ endif () option (HDF5_ENABLE_THREADSAFE "Enable thread-safety" OFF) if (HDF5_ENABLE_THREADSAFE) # check for unsupported options - if (WIN32 OR MINGW) - message (STATUS " **** thread-safety option not supported with static library **** ") - message (STATUS " **** thread-safety option will not be used building static library **** ") + 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 **** ") + endif () endif () if (HDF5_ENABLE_PARALLEL) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** parallel and thread-safety options are not supported, override with ALLOW_UNSUPPORTED option **** ") else () - message (STATUS " **** Allowing unsupported parallel and thread-safety options **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Allowing unsupported parallel and thread-safety options **** ") + endif () endif () endif () if (HDF5_BUILD_FORTRAN) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** Fortran and thread-safety options are not supported, override with ALLOW_UNSUPPORTED option **** ") else () - message (STATUS " **** Allowing unsupported Fortran and thread-safety options **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Allowing unsupported Fortran and thread-safety options **** ") + endif () endif () endif () if (HDF5_BUILD_CPP_LIB) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** C++ and thread-safety options are not supported, override with ALLOW_UNSUPPORTED option **** ") else () - message (STATUS " **** Allowing unsupported C++ and thread-safety options **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Allowing unsupported C++ and thread-safety options **** ") + endif () endif () endif () if (HDF5_BUILD_HL_LIB) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** HL and thread-safety options are not supported, override with ALLOW_UNSUPPORTED option **** ") else () - message (STATUS " **** Allowing unsupported HL and thread-safety options **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Allowing unsupported HL and thread-safety options **** ") + endif () endif () endif () if (H5_HAVE_IOEO) - message (STATUS " **** Win32 threads requires WINVER>=0x600 (Windows Vista/7/8) **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Win32 threads requires WINVER>=0x600 (Windows Vista/7/8) **** ") + endif () set (H5_HAVE_WIN_THREADS 1) else () if (NOT H5_HAVE_PTHREAD_H) @@ -801,6 +882,14 @@ if (HDF5_ENABLE_THREADSAFE) endif () endif () +#----------------------------------------------------------------------------- +# Option to build the map API +#----------------------------------------------------------------------------- +option (HDF5_ENABLE_MAP_API "Build the map API" OFF) +if (HDF5_ENABLE_MAP_API) + set (H5_HAVE_MAP_API 1) +endif () + #----------------------------------------------------------------------------- # Add the HDF5 Library Target to the build #----------------------------------------------------------------------------- @@ -847,6 +936,13 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_FHEAP_VFD) endif () + option (HDF5_TEST_PASSTHROUGH_VOL "Execute tests with different passthrough VOL connectors" OFF) + mark_as_advanced (HDF5_TEST_PASSTHROUGH_VOL) + if (HDF5_TEST_PASSTHROUGH_VOL) + option (HDF5_TEST_FHEAP_PASSTHROUGH_VOL "Execute fheap test with different passthrough VOL connectors" ON) + mark_as_advanced (HDF5_TEST_FHEAP_PASSTHROUGH VOL) + endif () + option (HDF_TEST_EXPRESS "Control testing framework (0-3)" "0") mark_as_advanced (HDF_TEST_EXPRESS) @@ -912,6 +1008,21 @@ if (EXISTS "${HDF5_SOURCE_DIR}/tools" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/tools endif () endif () +#----------------------------------------------------------------------------- +# Include filter plugins +#----------------------------------------------------------------------------- +include (CMakePlugins.cmake) + +if (HDF5_PACKAGE_EXTLIBS AND NOT HDF5_NO_PACKAGES) + if (HDF5_ENABLE_PLUGIN_SUPPORT AND PLUGIN_FOUND) + PACKAGE_PLUGIN_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) +# option (HDF5_TEST_PLUGIN "Execute plugin tests" ON) +# mark_as_advanced (HDF5_TEST_PLUGIN) + +# TEST_PLUGIN_LIBRARY () + endif () +endif () + #----------------------------------------------------------------------------- # Option to build examples #----------------------------------------------------------------------------- @@ -946,7 +1057,9 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for if (HDF5_BUILD_FORTRAN) include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) - message (STATUS "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") + endif () include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) set (LINK_Fortran_LIBS ${LINK_LIBS}) @@ -988,23 +1101,22 @@ endif () # Option to build HDF5 C++ Library #----------------------------------------------------------------------------- if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") - option (HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" ON) + option (HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" OFF) if (HDF5_BUILD_CPP_LIB) # check for unsupported options if (HDF5_ENABLE_PARALLEL) if (NOT ALLOW_UNSUPPORTED) message (FATAL_ERROR " **** Parallel and C++ options are mutually exclusive, override with ALLOW_UNSUPPORTED option **** ") else () - message (STATUS " **** Allowing unsupported Parallel and C++ options **** ") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE " **** Allowing unsupported Parallel and C++ options **** ") + endif () endif () endif () include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake) include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake) - if (CMAKE_NO_STD_NAMESPACE) - set (H5_NO_STD 1) - endif () add_subdirectory (c++) if (HDF5_BUILD_HL_LIB) if (EXISTS "${HDF5_SOURCE_DIR}/hl/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/hl/c++") @@ -1038,7 +1150,7 @@ endif () #----------------------------------------------------------------------------- # Generate the H5pubconf.h file containing user settings needed by compilation #----------------------------------------------------------------------------- -configure_file (${HDF_RESOURCES_DIR}/H5pubconf.h.in ${HDF5_BINARY_DIR}/H5pubconf.h @ONLY) +configure_file (${HDF_RESOURCES_DIR}/H5pubconf.h.in ${HDF5_SRC_BINARY_DIR}/H5pubconf.h @ONLY) #----------------------------------------------------------------------------- # Options for use by cross compiling and toolchains diff --git a/COPYING b/COPYING index da64ef8db8b..9d32232bdf2 100644 --- a/COPYING +++ b/COPYING @@ -67,6 +67,12 @@ under Prime Contract No. DE-AC02-05CH11231. ----------------------------------------------------------------------------- +Portions of HDF5 were developed with support from Lawrence Livermore +National Laboratory and the United States Department of Energy under +Prime Contract No. DE-AC52-07NA27344. + +----------------------------------------------------------------------------- + Portions of HDF5 were developed with support from the University of California, Lawrence Livermore National Laboratory (UC LLNL). The following statement applies to those portions of the product and must diff --git a/CTestConfig.cmake b/CTestConfig.cmake index fbc073eff1f..7066376715d 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -18,7 +18,7 @@ set (CTEST_PROJECT_NAME "HDF5") set (CTEST_NIGHTLY_START_TIME "18:00:00 CST") -set (CTEST_DROP_METHOD "http") +set (CTEST_DROP_METHOD "https") if (CTEST_DROP_SITE_INIT) set (CTEST_DROP_SITE "${CTEST_DROP_SITE_INIT}") else () @@ -32,7 +32,7 @@ if (CTEST_DROP_LOCATION_INIT) set (CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION_INIT}") else () if (CDASH_LOCAL) - set (CTEST_DROP_LOCATION "/submit.php?project=HDF5110") + set (CTEST_DROP_LOCATION "/submit.php?project=HDF5112") else () set (CTEST_DROP_LOCATION "/submit.php?project=HDF5") endif () diff --git a/README.txt b/README.txt index 42bb993315c..1162b5fd802 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.10.7 released on 2020-09-11 +HDF5 version 1.12.1 released on 2021-07-01 ------------------------------------------------------------------------------ Please refer to the release_docs/INSTALL file for installation instructions. @@ -75,9 +75,6 @@ Periodically development code snapshots are provided at the following URL: Source packages for current and previous releases are located at: https://portal.hdfgroup.org/display/support/Downloads -Source packages and binaries for current and previous releases are located at: - https://support.hdfgroup.org/ftp/HDF5/releases/ - -Development code is available at our BitBucket Server: - https://bitbucket.hdfgroup.org/projects/HDFFV/repos/hdf5/browse +Development code is available at our Github location: + https://github.com/HDFGroup/hdf5.git diff --git a/UserMacros.cmake b/UserMacros.cmake index c578c91cb0c..c9162236a8a 100644 --- a/UserMacros.cmake +++ b/UserMacros.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/c++/COPYING b/c++/COPYING deleted file mode 100644 index 6497ace3da0..00000000000 --- a/c++/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 058f457c942..835d422c71e 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -5,7 +5,7 @@ project (HDF5_CPP_SRC CXX) # Generate configure file #----------------------------------------------------------------------------- configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in - ${HDF5_BINARY_DIR}/H5cxx_pubconf.h + ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h ) #----------------------------------------------------------------------------- @@ -87,7 +87,7 @@ set (CPP_HDRS if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_CPP_LIB_TARGET} STATIC ${CPP_SOURCES} ${CPP_HDRS}) target_include_directories (${HDF5_CPP_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -105,7 +105,7 @@ 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_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -117,7 +117,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${HDF5_CPP_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET} ) - if (MINGW) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) target_link_options (${HDF5_CPP_LIBSH_TARGET} PRIVATE -static-libgcc -static-libstdc++ ) @@ -128,6 +128,17 @@ if (BUILD_SHARED_LIBS) set (install_targets ${install_targets} ${HDF5_CPP_LIBSH_TARGET}) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIB_TARGET}) + else () + clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIBSH_TARGET}) + endif () +endif () + #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- @@ -183,22 +194,26 @@ if (BUILD_SHARED_LIBS) set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_CPP_LIB_CORENAME}") endif () -set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}") -set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.pc.in - ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}.pc @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}.pc DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig COMPONENT cpplibraries ) if (NOT WIN32 AND NOT MINGW) - set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND) + set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER}) + else () + set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + endif () configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in ${HDF5_BINARY_DIR}/CMakeFiles/h5c++ diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index d59a3cbc37f..eeb015584b1 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -38,7 +38,9 @@ namespace H5 { ///\brief Default constructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::AbstractDs(){} +AbstractDs::AbstractDs() +{ +} //-------------------------------------------------------------------------- // Function: AbstractDs default constructor @@ -61,19 +63,20 @@ AbstractDs::AbstractDs(){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t AbstractDs::getTypeClass() const +H5T_class_t +AbstractDs::getTypeClass() const { // Gets the datatype used by this dataset or attribute. // p_get_type calls either H5Dget_type or H5Aget_type depending on // which object invokes getTypeClass hid_t datatype_id; try { - datatype_id = p_get_type(); // returned value is already validated + datatype_id = p_get_type(); // returned value is already validated } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); } @@ -82,8 +85,7 @@ H5T_class_t AbstractDs::getTypeClass() const // Close temporary datatype_id herr_t ret_value = H5Tclose(datatype_id); - if (ret_value < 0) - { + if (ret_value < 0) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed"); else if (fromClass() == "Attribute") @@ -91,14 +93,13 @@ H5T_class_t AbstractDs::getTypeClass() const } // Check on the returned type_class - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { if (fromClass() == "DataSet") throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); else if (fromClass() == "Attribute") throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -109,7 +110,8 @@ H5T_class_t AbstractDs::getTypeClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType AbstractDs::getDataType() const +DataType +AbstractDs::getDataType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -118,12 +120,12 @@ DataType AbstractDs::getDataType() const try { DataType datatype; f_DataType_setId(&datatype, p_get_type()); - return(datatype); + return (datatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); } } @@ -136,7 +138,8 @@ DataType AbstractDs::getDataType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType AbstractDs::getArrayType() const +ArrayType +AbstractDs::getArrayType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -147,12 +150,12 @@ ArrayType AbstractDs::getArrayType() const // problem described in the JIRA issue HDFFV-7947 ArrayType arraytype; f_DataType_setId(&arraytype, p_get_type()); - return(arraytype); + return (arraytype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); } } @@ -165,7 +168,8 @@ ArrayType AbstractDs::getArrayType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType AbstractDs::getCompType() const +CompType +AbstractDs::getCompType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -174,12 +178,12 @@ CompType AbstractDs::getCompType() const try { CompType comptype; f_DataType_setId(&comptype, p_get_type()); - return(comptype); + return (comptype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); } } @@ -192,7 +196,8 @@ CompType AbstractDs::getCompType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType AbstractDs::getEnumType() const +EnumType +AbstractDs::getEnumType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -201,12 +206,12 @@ EnumType AbstractDs::getEnumType() const try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_type()); - return(enumtype); + return (enumtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); } } @@ -219,7 +224,8 @@ EnumType AbstractDs::getEnumType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType AbstractDs::getIntType() const +IntType +AbstractDs::getIntType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -228,12 +234,12 @@ IntType AbstractDs::getIntType() const try { IntType inttype; f_DataType_setId(&inttype, p_get_type()); - return(inttype); + return (inttype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); } } @@ -246,7 +252,8 @@ IntType AbstractDs::getIntType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType AbstractDs::getFloatType() const +FloatType +AbstractDs::getFloatType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -255,12 +262,12 @@ FloatType AbstractDs::getFloatType() const try { FloatType floatype; f_DataType_setId(&floatype, p_get_type()); - return(floatype); + return (floatype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); } } @@ -273,7 +280,8 @@ FloatType AbstractDs::getFloatType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType AbstractDs::getStrType() const +StrType +AbstractDs::getStrType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -282,12 +290,12 @@ StrType AbstractDs::getStrType() const try { StrType strtype; f_DataType_setId(&strtype, p_get_type()); - return(strtype); + return (strtype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } } @@ -300,7 +308,8 @@ StrType AbstractDs::getStrType() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType AbstractDs::getVarLenType() const +VarLenType +AbstractDs::getVarLenType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type @@ -309,12 +318,12 @@ VarLenType AbstractDs::getVarLenType() const try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_type()); - return(varlentype); + return (varlentype); } - catch (DataSetIException& E) { + catch (DataSetIException &E) { throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); } - catch (AttributeIException& E) { + catch (AttributeIException &E) { throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); } } @@ -324,6 +333,8 @@ VarLenType AbstractDs::getVarLenType() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AbstractDs::~AbstractDs() {} +AbstractDs::~AbstractDs() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 399e0335f72..b84867b2cb9 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __AbstractDs_H -#define __AbstractDs_H +#ifndef H5AbstractDs_H +#define H5AbstractDs_H namespace H5 { @@ -34,51 +34,51 @@ class DataSpace; and DataSet. */ class H5_DLLCPP AbstractDs { - public: - // Gets a copy the datatype of that this abstract dataset uses. - // Note that this datatype is a generic one and can only be accessed - // via generic member functions, i.e., member functions belong - // to DataType. To get specific datatype, i.e. EnumType, FloatType, - // etc..., use the specific functions, that follow, instead. - DataType getDataType() const; - - // Gets a copy of the specific datatype of this abstract dataset. - ArrayType getArrayType() const; - CompType getCompType() const; - EnumType getEnumType() const; - IntType getIntType() const; - FloatType getFloatType() const; - StrType getStrType() const; - VarLenType getVarLenType() const; - - ///\brief Gets the size in memory of this abstract dataset. - virtual size_t getInMemDataSize() const = 0; - - ///\brief Gets the dataspace of this abstract dataset - pure virtual. - virtual DataSpace getSpace() const = 0; - - // Gets the class of the datatype that is used by this abstract - // dataset. - H5T_class_t getTypeClass() const; - - ///\brief Returns the amount of storage size required - pure virtual. - virtual hsize_t getStorageSize() const = 0; - - // Returns this class name - pure virtual. - virtual H5std_string fromClass() const = 0; - - // Destructor - virtual ~AbstractDs(); - - protected: - // Default constructor - AbstractDs(); - - private: - // This member function is implemented by DataSet and Attribute - pure virtual. - virtual hid_t p_get_type() const = 0; + public: + // Gets a copy the datatype of that this abstract dataset uses. + // Note that this datatype is a generic one and can only be accessed + // via generic member functions, i.e., member functions belong + // to DataType. To get specific datatype, i.e. EnumType, FloatType, + // etc..., use the specific functions, that follow, instead. + DataType getDataType() const; + + // Gets a copy of the specific datatype of this abstract dataset. + ArrayType getArrayType() const; + CompType getCompType() const; + EnumType getEnumType() const; + IntType getIntType() const; + FloatType getFloatType() const; + StrType getStrType() const; + VarLenType getVarLenType() const; + + ///\brief Gets the size in memory of this abstract dataset. + virtual size_t getInMemDataSize() const = 0; + + ///\brief Gets the dataspace of this abstract dataset - pure virtual. + virtual DataSpace getSpace() const = 0; + + // Gets the class of the datatype that is used by this abstract + // dataset. + H5T_class_t getTypeClass() const; + + ///\brief Returns the amount of storage size required - pure virtual. + virtual hsize_t getStorageSize() const = 0; + + // Returns this class name - pure virtual. + virtual H5std_string fromClass() const = 0; + + // Destructor + virtual ~AbstractDs(); + + protected: + // Default constructor + AbstractDs(); + + private: + // This member function is implemented by DataSet and Attribute - pure virtual. + virtual hid_t p_get_type() const = 0; }; // end of AbstractDs } // namespace H5 -#endif // __AbstractDs_H +#endif // H5AbstractDs_H diff --git a/c++/src/H5Alltypes.h b/c++/src/H5Alltypes.h index d67f3fe2ab2..7a14774f8ff 100644 --- a/c++/src/H5Alltypes.h +++ b/c++/src/H5Alltypes.h @@ -7,7 +7,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 0dab8ef12c3..6999f1bf70e 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -34,7 +34,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub ArrayType // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType() : DataType() {} +ArrayType::ArrayType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -43,14 +45,18 @@ ArrayType::ArrayType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) {} +ArrayType::ArrayType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} +ArrayType::ArrayType(const ArrayType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -62,7 +68,7 @@ ArrayType::ArrayType(const ArrayType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() +ArrayType::ArrayType(const DataType &base_type, int ndims, const hsize_t *dims) : DataType() { // Call C API to create an array data type hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); @@ -87,7 +93,7 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -106,7 +112,7 @@ ArrayType::ArrayType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +ArrayType::ArrayType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -122,21 +128,21 @@ ArrayType::ArrayType(const H5Location& loc, const H5std_string& dtype_name) : Da // each data member from the rhs object. (Issue HDFFV-9562) // Programmer Binh-Minh Ribler - Mar 2016 //-------------------------------------------------------------------------- -ArrayType& ArrayType::operator=(const ArrayType& rhs) +ArrayType & +ArrayType::operator=(const ArrayType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.id); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); } } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -147,7 +153,8 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* ArrayType::decode() const +DataType * +ArrayType::decode() const { hid_t encoded_arrtype_id = H5I_INVALID_HID; try { @@ -158,7 +165,7 @@ DataType* ArrayType::decode() const } ArrayType *encoded_arrtype = new ArrayType; encoded_arrtype->p_setId(encoded_arrtype_id); - return(encoded_arrtype); + return (encoded_arrtype); } //-------------------------------------------------------------------------- @@ -168,16 +175,16 @@ DataType* ArrayType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayNDims() const +int +ArrayType::getArrayNDims() const { // Get the rank of the array type specified by id from the C API int ndims = H5Tget_array_ndims(id); - if (ndims < 0) - { + if (ndims < 0) { throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -188,7 +195,8 @@ int ArrayType::getArrayNDims() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -int ArrayType::getArrayDims(hsize_t* dims) const +int +ArrayType::getArrayDims(hsize_t *dims) const { // Get the dimensions int ndims = H5Tget_array_dims2(id, dims); @@ -196,7 +204,7 @@ int ArrayType::getArrayDims(hsize_t* dims) const throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); // Return the number of dimensions - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -204,6 +212,8 @@ int ArrayType::getArrayDims(hsize_t* dims) const ///\brief Properly terminates access to this array datatype. // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::~ArrayType() {} +ArrayType::~ArrayType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index d99b936aa4a..4302352c851 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5ArrayType_H -#define __H5ArrayType_H +#ifndef H5ArrayType_H +#define H5ArrayType_H namespace H5 { @@ -23,46 +23,50 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP ArrayType : public DataType { - public: - // Constructor that creates a new array data type based on the - // specified base type. - ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); + public: + // Constructor that creates a new array data type based on the + // specified base type. + ArrayType(const DataType &base_type, int ndims, const hsize_t *dims); - // Assignment operator - ArrayType& operator=(const ArrayType& rhs); + // Assignment operator + ArrayType &operator=(const ArrayType &rhs); - // Constructors that open an array datatype, given a location. - ArrayType(const H5Location& loc, const char* name); - ArrayType(const H5Location& loc, const H5std_string& name); + // Constructors that open an array datatype, given a location. + ArrayType(const H5Location &loc, const char *name); + ArrayType(const H5Location &loc, const H5std_string &name); - // Returns an ArrayType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an ArrayType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of dimensions of this array datatype. - int getArrayNDims() const; - //int getArrayNDims(); // removed 1.8.18 and 1.10.1 + // Returns the number of dimensions of this array datatype. + int getArrayNDims() const; + // int getArrayNDims(); // removed 1.8.18 and 1.10.1 - // Returns the sizes of dimensions of this array datatype. - int getArrayDims(hsize_t* dims) const; - //int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 + // Returns the sizes of dimensions of this array datatype. + int getArrayDims(hsize_t *dims) const; + // int getArrayDims(hsize_t* dims); // removed 1.8.18 and 1.10.1 - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ArrayType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ArrayType"); + } - // Copy constructor: same as the original ArrayType. - ArrayType(const ArrayType& original); + // Copy constructor: same as the original ArrayType. + ArrayType(const ArrayType &original); - // Constructor that takes an existing id - ArrayType(const hid_t existing_id); + // Constructor that takes an existing id + ArrayType(const hid_t existing_id); - // Noop destructor - virtual ~ArrayType(); + // Noop destructor + virtual ~ArrayType(); - // Default constructor - ArrayType(); + // Default constructor + ArrayType(); }; // end of ArrayType } // namespace H5 -#endif // __H5ArrayType_H +#endif // H5ArrayType_H diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 94084529116..0b480464c96 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -35,7 +35,9 @@ namespace H5 { // Purpose Default constructor: creates a stub atomic datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType() : DataType() {} +AtomType::AtomType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: AtomType overloaded constructor [protected] @@ -44,14 +46,18 @@ AtomType::AtomType() : DataType() {} // Exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) {} +AtomType::AtomType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: AtomType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::AtomType(const AtomType& original) : DataType(original) {} +AtomType::AtomType(const AtomType &original) : DataType(original) +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -61,12 +67,12 @@ AtomType::AtomType(const AtomType& original) : DataType(original) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setSize(size_t size) const +void +AtomType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); } } @@ -81,18 +87,17 @@ void AtomType::setSize(size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder() const +H5T_order_t +AtomType::getOrder() const { // Call C routine to get the byte ordering H5T_order_t type_order = H5Tget_order(id); // return a byte order constant if successful - if (type_order == H5T_ORDER_ERROR) - { - throw DataTypeIException(inMemFunc("getOrder"), - "H5Tget_order returns H5T_ORDER_ERROR"); + if (type_order == H5T_ORDER_ERROR) { + throw DataTypeIException(inMemFunc("getOrder"), "H5Tget_order returns H5T_ORDER_ERROR"); } - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -112,7 +117,8 @@ H5T_order_t AtomType::getOrder() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder(H5std_string& order_string) const +H5T_order_t +AtomType::getOrder(H5std_string &order_string) const { // Call the overloaded to get the type order without text H5T_order_t type_order = getOrder(); @@ -124,7 +130,7 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const order_string = "Big endian byte ordering (1)"; else if (type_order == H5T_ORDER_VAX) order_string = "VAX mixed byte ordering (2)"; - return(type_order); + return (type_order); } //-------------------------------------------------------------------------- @@ -137,12 +143,12 @@ H5T_order_t AtomType::getOrder(H5std_string& order_string) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOrder(H5T_order_t order) const +void +AtomType::setOrder(H5T_order_t order) const { // Call C routine to set the byte ordering herr_t ret_value = H5Tset_order(id, order); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); } } @@ -158,17 +164,17 @@ void AtomType::setOrder(H5T_order_t order) const /// value returned by \c DataType::getSize(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t AtomType::getPrecision() const +size_t +AtomType::getPrecision() const { - size_t num_signi_bits = H5Tget_precision(id); // C routine + size_t num_signi_bits = H5Tget_precision(id); // C routine // returns number of significant bits if successful - if (num_signi_bits == 0) - { + if (num_signi_bits == 0) { throw DataTypeIException(inMemFunc("getPrecision"), - "H5Tget_precision returns invalid number of significant bits"); + "H5Tget_precision returns invalid number of significant bits"); } - return(num_signi_bits); + return (num_signi_bits); } //-------------------------------------------------------------------------- @@ -181,12 +187,12 @@ size_t AtomType::getPrecision() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPrecision(size_t precision) const +void +AtomType::setPrecision(size_t precision) const { // Call C routine to set the datatype precision herr_t ret_value = H5Tset_precision(id, precision); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); } } @@ -205,17 +211,16 @@ void AtomType::setPrecision(size_t precision) const // - return type changed from size_t to int // - offset = -1 when failure occurs vs. 0 //-------------------------------------------------------------------------- -int AtomType::getOffset() const +int +AtomType::getOffset() const { - int offset = H5Tget_offset(id); // C routine + int offset = H5Tget_offset(id); // C routine // returns a non-negative offset value if successful - if (offset == -1) - { - throw DataTypeIException(inMemFunc("getOffset"), - "H5Tget_offset returns a negative offset value"); + if (offset == -1) { + throw DataTypeIException(inMemFunc("getOffset"), "H5Tget_offset returns a negative offset value"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -228,12 +233,12 @@ int AtomType::getOffset() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setOffset(size_t offset) const +void +AtomType::setOffset(size_t offset) const { // Call C routine to set the bit offset herr_t ret_value = H5Tset_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); } } @@ -252,12 +257,12 @@ void AtomType::setOffset(size_t offset) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const +void +AtomType::getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const { // Call C routine to get the padding type herr_t ret_value = H5Tget_pad(id, &lsb, &msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); } } @@ -275,12 +280,12 @@ void AtomType::getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const +void +AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const { // Call C routine to set the padding type herr_t ret_value = H5Tset_pad(id, lsb, msb); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); } } @@ -291,7 +296,9 @@ void AtomType::setPad(H5T_pad_t lsb, H5T_pad_t msb) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -AtomType::~AtomType() {} +AtomType::~AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 80271aca1b9..84da5e98ff0 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5AtomType_H -#define __H5AtomType_H +#ifndef H5AtomType_H +#define H5AtomType_H namespace H5 { @@ -26,57 +26,61 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP AtomType : public DataType { - public: - // Returns the byte order of an atomic datatype. - H5T_order_t getOrder() const; - H5T_order_t getOrder(H5std_string& order_string) const; + public: + // Returns the byte order of an atomic datatype. + H5T_order_t getOrder() const; + H5T_order_t getOrder(H5std_string &order_string) const; - // Sets the byte ordering of an atomic datatype. - void setOrder(H5T_order_t order) const; + // Sets the byte ordering of an atomic datatype. + void setOrder(H5T_order_t order) const; - // Retrieves the bit offset of the first significant bit. - // 12/05/00 - changed return type to int from size_t - C API - int getOffset() const; + // Retrieves the bit offset of the first significant bit. + // 12/05/00 - changed return type to int from size_t - C API + int getOffset() const; - // Sets the bit offset of the first significant bit. - void setOffset(size_t offset) const; + // Sets the bit offset of the first significant bit. + void setOffset(size_t offset) const; - // Retrieves the padding type of the least and most-significant bit padding. - void getPad(H5T_pad_t& lsb, H5T_pad_t& msb) const; + // Retrieves the padding type of the least and most-significant bit padding. + void getPad(H5T_pad_t &lsb, H5T_pad_t &msb) const; - // Sets the least and most-significant bits padding types - void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; + // Sets the least and most-significant bits padding types + void setPad(H5T_pad_t lsb, H5T_pad_t msb) const; - // Returns the precision of an atomic datatype. - size_t getPrecision() const; + // Returns the precision of an atomic datatype. + size_t getPrecision() const; - // Sets the precision of an atomic datatype. - void setPrecision(size_t precision) const; + // Sets the precision of an atomic datatype. + void setPrecision(size_t precision) const; - // Sets the total size for an atomic datatype. - void setSize(size_t size) const; + // Sets the total size for an atomic datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("AtomType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("AtomType"); + } #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Copy constructor: same as the original AtomType. - AtomType(const AtomType& original); + // Copy constructor: same as the original AtomType. + AtomType(const AtomType &original); - // Noop destructor - virtual ~AtomType(); + // Noop destructor + virtual ~AtomType(); #endif // DOXYGEN_SHOULD_SKIP_THIS - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Default constructor - AtomType(); + // Default constructor + AtomType(); - // Constructor that takes an existing id - AtomType(const hid_t existing_id); + // Constructor that takes an existing id + AtomType(const hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of AtomType } // namespace H5 -#endif // __H5AtomType_H +#endif // H5AtomType_H diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 33f992a0b16..0e37c2b3247 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -6,19 +6,15 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,14 +37,16 @@ namespace H5 { using std::cerr; using std::endl; -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate +class H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor ///\brief Default constructor: Creates a stub attribute // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} +Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Attribute copy constructor @@ -56,7 +54,7 @@ Attribute::Attribute() : AbstractDs(), H5Location(), id(H5I_INVALID_HID) {} ///\param original - IN: Original Attribute object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute::Attribute(const Attribute& original) : AbstractDs(), H5Location(), id(original.id) +Attribute::Attribute(const Attribute &original) : AbstractDs(), H5Location(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -82,11 +80,11 @@ Attribute::Attribute(const hid_t existing_id) : AbstractDs(), H5Location(), id(e ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const void *buf) const +void +Attribute::write(const DataType &mem_type, const void *buf) const { - herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Awrite(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -100,32 +98,29 @@ void Attribute::write(const DataType& mem_type, const void *buf) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr, 2003 //-------------------------------------------------------------------------- -void Attribute::write(const DataType& mem_type, const H5std_string& strg) const +void +Attribute::write(const DataType &mem_type, const H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); } // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Awrite(id, mem_type.getId(), strg_C); } - else - { + else { // passing third argument by address ret_value = H5Awrite(id, mem_type.getId(), &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::write", "H5Awrite failed"); } } @@ -138,11 +133,11 @@ void Attribute::write(const DataType& mem_type, const H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, void *buf) const +void +Attribute::read(const DataType &mem_type, void *buf) const { - herr_t ret_value = H5Aread(id, mem_type.getId(), buf); - if (ret_value < 0) - { + herr_t ret_value = H5Aread(id, mem_type.getId(), buf); + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } } @@ -167,22 +162,21 @@ void Attribute::read(const DataType& mem_type, void *buf) const // variable-len string data: p_read_fixed_len and // p_read_variable_len. This should improve readability. -BMR //-------------------------------------------------------------------------- -void Attribute::read(const DataType& mem_type, H5std_string& strg) const +void +Attribute::read(const DataType &mem_type, H5std_string &strg) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw AttributeIException("Attribute::read", "H5Tis_variable_str failed"); } - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type, strg); } - else - { + else { p_read_variable_len(mem_type, strg); } } @@ -194,62 +188,55 @@ void Attribute::read(const DataType& mem_type, H5std_string& strg) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t Attribute::getInMemDataSize() const +size_t +Attribute::getInMemDataSize() const { const char *func = "Attribute::getInMemDataSize"; // Get the data type of this attribute hid_t mem_type_id = H5Aget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw AttributeIException(func, "H5Aget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw AttributeIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw AttributeIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this attribute. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the attribute by first getting its dataspace // then getting the number of elements in the dataspace hid_t space_id = H5Aget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw AttributeIException(func, "H5Aget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw AttributeIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -259,20 +246,19 @@ size_t Attribute::getInMemDataSize() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace Attribute::getSpace() const +DataSpace +Attribute::getSpace() const { - // Calls C function H5Aget_space to get the id of the dataspace - hid_t dataspace_id = H5Aget_space(id); + // Calls C function H5Aget_space to get the id of the dataspace + hid_t dataspace_id = H5Aget_space(id); - // If the dataspace id is valid, create and return the DataSpace object - if (dataspace_id > 0) - { + // If the dataspace id is valid, create and return the DataSpace object + if (dataspace_id > 0) { DataSpace dataspace; f_DataSpace_setId(&dataspace, dataspace_id); - return(dataspace); + return (dataspace); } - else - { + else { throw AttributeIException("Attribute::getSpace", "H5Aget_space failed"); } } @@ -294,22 +280,21 @@ DataSpace Attribute::getSpace() const /// first argument and ignore the second argument. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t Attribute::getName(char* attr_name, size_t buf_size) const +ssize_t +Attribute::getName(char *attr_name, size_t buf_size) const { // H5Aget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Aget_name(id, buf_size, attr_name); // If H5Aget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -322,40 +307,37 @@ ssize_t Attribute::getName(char* attr_name, size_t buf_size) const // Mar 2014 - BMR // Revised to use the modified getName() above //-------------------------------------------------------------------------- -H5std_string Attribute::getName() const +H5std_string +Attribute::getName() const { - H5std_string attr_name(""); // attribute name to return + 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); // If H5Aget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw AttributeIException("Attribute::getName", "H5Aget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw AttributeIException("Attribute::getName", "Attribute must have a name, name length is 0"); } // 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 + 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 // Use overloaded function - name_size = getName(name_C, name_size+1); + name_size = getName(name_C, name_size + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; - + delete[] name_C; } // Return attribute's name - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -371,14 +353,15 @@ H5std_string Attribute::getName() const // Mar 2014 - BMR // Revised to use the new getName() below //-------------------------------------------------------------------------- -H5std_string Attribute::getName(size_t len) const +H5std_string +Attribute::getName(size_t len) const { H5std_string attr_name; - ssize_t name_size = getName(attr_name, len); + ssize_t name_size = getName(attr_name, len); if (name_size < 0) - return(""); + return (""); else - return(attr_name); + return (attr_name); } //-------------------------------------------------------------------------- @@ -398,35 +381,34 @@ H5std_string Attribute::getName(size_t len) const // Added to replace getName(size_t, H5std_string&) so that it'll // allow the argument "len" to be skipped. //-------------------------------------------------------------------------- -ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const +ssize_t +Attribute::getName(H5std_string &attr_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire attribute name - if (len == 0) - { + if (len == 0) { attr_name = getName(); name_size = attr_name.length(); } // 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 + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getName(name_C, len+1); + name_size = getName(name_C, len + 1); // Convert the C attribute name to return attr_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep attr_name intact // Return name size - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -444,7 +426,7 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const +// ssize_t Attribute::getName(size_t len, H5std_string& attr_name) const //{ // return (getName(attr_name, len)); //} @@ -458,10 +440,11 @@ ssize_t Attribute::getName(H5std_string& attr_name, size_t len) const // function should have no failure. (from SLU) // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t Attribute::getStorageSize() const +hsize_t +Attribute::getStorageSize() const { - hsize_t storage_size = H5Aget_storage_size(id); - return (storage_size); + hsize_t storage_size = H5Aget_storage_size(id); + return (storage_size); } //-------------------------------------------------------------------------- @@ -480,9 +463,10 @@ hsize_t Attribute::getStorageSize() const // an attribute id can be used to specify a location in HDF5 // library. //-------------------------------------------------------------------------- -hid_t Attribute::getId() const +hid_t +Attribute::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- @@ -494,13 +478,13 @@ hid_t Attribute::getId() const // This private function is used in AbstractDs. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hid_t Attribute::p_get_type() const +hid_t +Attribute::p_get_type() const { hid_t type_id = H5Aget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw AttributeIException("", "H5Aget_type failed"); } } @@ -517,7 +501,8 @@ hid_t Attribute::p_get_type() const // Separated the fixed length case from the original // Attribute::read //-------------------------------------------------------------------------- -void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const { // Only allocate for fixed-len string. @@ -525,19 +510,17 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c size_t attr_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (attr_size > 0) - { - char *strg_C = new char[attr_size+1]; + if (attr_size > 0) { + 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 + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw AttributeIException("Attribute::read", "H5Aread failed"); } // Get string from the C char* and release resource allocated locally strg_C[attr_size] = '\0'; - strg = strg_C; - delete []strg_C; + strg = strg_C; + delete[] strg_C; } } @@ -553,7 +536,8 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // Separated the variable length case from the original // Attribute::read. -BMR //-------------------------------------------------------------------------- -void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg) const +void +Attribute::p_read_variable_len(const DataType &mem_type, H5std_string &strg) const { // Prepare and call C API to read attribute. char *strg_C; @@ -561,8 +545,7 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Read attribute, no allocation for variable-len string; C library will herr_t ret_value = H5Aread(id, mem_type.getId(), &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::read", "H5Aread failed"); } @@ -584,13 +567,14 @@ void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Attribute::p_setId(const hid_t new_id) +void +Attribute::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -605,13 +589,12 @@ void Attribute::p_setId(const hid_t new_id) ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Attribute::close() +void +Attribute::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Aclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw AttributeIException("Attribute::close", "H5Aclose failed"); } // reset the id @@ -634,9 +617,9 @@ Attribute::~Attribute() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index c6fdaec07b7..41e5a313a3f 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Attribute_H -#define __H5Attribute_H +#ifndef H5Attribute_H +#define H5Attribute_H namespace H5 { @@ -27,78 +27,81 @@ namespace H5 { */ // Inheritance: multiple H5Location/AbstractDs -> IdComponent class H5_DLLCPP Attribute : public AbstractDs, public H5Location { - public: + public: + // Copy constructor: same as the original Attribute. + Attribute(const Attribute &original); - // Copy constructor: same as the original Attribute. - Attribute(const Attribute& original); + // Default constructor + Attribute(); - // Default constructor - Attribute(); + // Creates a copy of an existing attribute using the attribute id + Attribute(const hid_t attr_id); - // Creates a copy of an existing attribute using the attribute id - Attribute(const hid_t attr_id); + // Closes this attribute. + virtual void close(); - // Closes this attribute. - virtual void close(); + // Gets the name of this attribute. + ssize_t getName(char *attr_name, size_t buf_size = 0) const; + H5std_string getName(size_t len) const; + H5std_string getName() const; + ssize_t getName(H5std_string &attr_name, size_t len = 0) const; + // The overloaded function below is replaced by the one above and it + // is kept for backward compatibility purpose. + ssize_t getName(size_t buf_size, H5std_string &attr_name) const; - // Gets the name of this attribute. - ssize_t getName(char* attr_name, size_t buf_size = 0) const; - H5std_string getName(size_t len) const; - H5std_string getName() const; - ssize_t getName(H5std_string& attr_name, size_t len = 0) const; - // The overloaded function below is replaced by the one above and it - // is kept for backward compatibility purpose. - 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; - // Gets a copy of the dataspace for this attribute. - virtual DataSpace getSpace() const; + // Returns the amount of storage size required for this attribute. + virtual hsize_t getStorageSize() const; - // Returns the amount of storage size required for this attribute. - virtual hsize_t getStorageSize() const; + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + // Reads data from this attribute. + void read(const DataType &mem_type, void *buf) const; + void read(const DataType &mem_type, H5std_string &strg) const; - // Reads data from this attribute. - void read(const DataType& mem_type, void *buf) const; - void read(const DataType& mem_type, H5std_string& strg) const; + // Writes data to this attribute. + void write(const DataType &mem_type, const void *buf) const; + void write(const DataType &mem_type, const H5std_string &strg) const; - // Writes data to this attribute. - void write(const DataType& mem_type, const void *buf) const; - void write(const DataType& mem_type, const H5std_string& strg) const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("Attribute"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Attribute"); } + // Gets the attribute id. + virtual hid_t getId() const; - // Gets the attribute id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this attribute. - virtual ~Attribute(); + // Destructor: properly terminates access to this attribute. + virtual ~Attribute(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the attribute id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the attribute id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 attribute id + private: + hid_t id; // HDF5 attribute id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // Reads variable or fixed len strings from this attribute. - void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const; - void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const; + // Reads variable or fixed len strings from this attribute. + void p_read_variable_len(const DataType &mem_type, H5std_string &strg) const; + void p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const; - // Friend function to set Attribute id. For library use only. - friend void f_Attribute_setId(Attribute* attr, hid_t new_id); + // Friend function to set Attribute id. For library use only. + friend void f_Attribute_setId(Attribute *attr, hid_t new_id); }; // end of Attribute } // namespace H5 -#endif // __H5Attribute_H +#endif // H5Attribute_H diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 8b1e6edb00c..7820ce2564e 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -7,40 +7,40 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Classes_H -#define __H5Classes_H +#ifndef H5Classes_H +#define H5Classes_H namespace H5 { - class Exception; - class IdComponent; - class H5Location; - class H5Object; - class PropList; - class FileCreatPropList; - class FileAccPropList; - class LinkAccPropList; - class DSetCreatPropList; - class DSetMemXferPropList; - class DTypePropList; - class DataType; - class DataSpace; - class AtomType; - class PredType; - class IntType; - class FloatType; - class StrType; - class EnumType; - class CompType; - class AbstractDs; - class DataSet; - class Group; - class H5File; - class Attribute; - class H5Library; -} -#endif // __H5Classes_H +class Exception; +class IdComponent; +class H5Location; +class H5Object; +class PropList; +class FileCreatPropList; +class FileAccPropList; +class LinkAccPropList; +class DSetCreatPropList; +class DSetMemXferPropList; +class DTypePropList; +class DataType; +class DataSpace; +class AtomType; +class PredType; +class IntType; +class FloatType; +class StrType; +class EnumType; +class CompType; +class AbstractDs; +class DataSet; +class Group; +class H5File; +class Attribute; +class H5Library; +} // namespace H5 +#endif // H5Classes_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 6c5fdca9470..fb602d93319 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -6,14 +6,14 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include "H5private.h" // for HDstrcpy +#include "H5private.h" // for HDstrcpy #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -55,7 +55,8 @@ namespace H5 { ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const char* name) const +DataType +CommonFG::openDataType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -68,7 +69,7 @@ DataType CommonFG::openDataType(const char* name) const // No failure, create and return the DataType object DataType data_type; f_DataType_setId(&data_type, type_id); - return(data_type); + return (data_type); } //-------------------------------------------------------------------------- @@ -78,9 +79,10 @@ DataType CommonFG::openDataType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CommonFG::openDataType(const H5std_string& name) const +DataType +CommonFG::openDataType(const H5std_string &name) const { - return(openDataType(name.c_str())); + return (openDataType(name.c_str())); } //-------------------------------------------------------------------------- @@ -91,7 +93,8 @@ DataType CommonFG::openDataType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const char* name) const +ArrayType +CommonFG::openArrayType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -104,7 +107,7 @@ ArrayType CommonFG::openArrayType(const char* name) const // No failure, create and return the ArrayType object ArrayType array_type; f_DataType_setId(&array_type, type_id); - return(array_type); + return (array_type); } //-------------------------------------------------------------------------- @@ -114,9 +117,10 @@ ArrayType CommonFG::openArrayType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CommonFG::openArrayType(const H5std_string& name) const +ArrayType +CommonFG::openArrayType(const H5std_string &name) const { - return(openArrayType(name.c_str())); + return (openArrayType(name.c_str())); } //-------------------------------------------------------------------------- @@ -127,7 +131,8 @@ ArrayType CommonFG::openArrayType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const char* name) const +CompType +CommonFG::openCompType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -140,7 +145,7 @@ CompType CommonFG::openCompType(const char* name) const // No failure, create and return the CompType object CompType comp_type; f_DataType_setId(&comp_type, type_id); - return(comp_type); + return (comp_type); } //-------------------------------------------------------------------------- @@ -150,9 +155,10 @@ CompType CommonFG::openCompType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CommonFG::openCompType(const H5std_string& name) const +CompType +CommonFG::openCompType(const H5std_string &name) const { - return(openCompType(name.c_str())); + return (openCompType(name.c_str())); } //-------------------------------------------------------------------------- @@ -163,7 +169,8 @@ CompType CommonFG::openCompType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const char* name) const +EnumType +CommonFG::openEnumType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -176,7 +183,7 @@ EnumType CommonFG::openEnumType(const char* name) const // No failure, create and return the EnumType object EnumType enum_type; f_DataType_setId(&enum_type, type_id); - return(enum_type); + return (enum_type); } //-------------------------------------------------------------------------- @@ -186,9 +193,10 @@ EnumType CommonFG::openEnumType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CommonFG::openEnumType(const H5std_string& name) const +EnumType +CommonFG::openEnumType(const H5std_string &name) const { - return(openEnumType(name.c_str())); + return (openEnumType(name.c_str())); } //-------------------------------------------------------------------------- @@ -199,7 +207,8 @@ EnumType CommonFG::openEnumType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const char* name) const +IntType +CommonFG::openIntType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -212,7 +221,7 @@ IntType CommonFG::openIntType(const char* name) const // No failure, create and return the IntType object IntType int_type; f_DataType_setId(&int_type, type_id); - return(int_type); + return (int_type); } //-------------------------------------------------------------------------- @@ -222,9 +231,10 @@ IntType CommonFG::openIntType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CommonFG::openIntType(const H5std_string& name) const +IntType +CommonFG::openIntType(const H5std_string &name) const { - return(openIntType(name.c_str())); + return (openIntType(name.c_str())); } //-------------------------------------------------------------------------- @@ -235,7 +245,8 @@ IntType CommonFG::openIntType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const char* name) const +FloatType +CommonFG::openFloatType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -248,7 +259,7 @@ FloatType CommonFG::openFloatType(const char* name) const // No failure, create and return the FloatType object FloatType float_type; f_DataType_setId(&float_type, type_id); - return(float_type); + return (float_type); } //-------------------------------------------------------------------------- @@ -258,9 +269,10 @@ FloatType CommonFG::openFloatType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CommonFG::openFloatType(const H5std_string& name) const +FloatType +CommonFG::openFloatType(const H5std_string &name) const { - return(openFloatType(name.c_str())); + return (openFloatType(name.c_str())); } //-------------------------------------------------------------------------- @@ -271,7 +283,8 @@ FloatType CommonFG::openFloatType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const char* name) const +StrType +CommonFG::openStrType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -284,7 +297,7 @@ StrType CommonFG::openStrType(const char* name) const // No failure, create and return the StrType object StrType str_type; f_DataType_setId(&str_type, type_id); - return(str_type); + return (str_type); } //-------------------------------------------------------------------------- @@ -294,9 +307,10 @@ StrType CommonFG::openStrType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CommonFG::openStrType(const H5std_string& name) const +StrType +CommonFG::openStrType(const H5std_string &name) const { - return(openStrType(name.c_str())); + return (openStrType(name.c_str())); } //-------------------------------------------------------------------------- @@ -307,7 +321,8 @@ StrType CommonFG::openStrType(const H5std_string& name) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const char* name) const +VarLenType +CommonFG::openVarLenType(const char *name) const { // Call C function H5Topen2 to open the named datatype in this group, // given either the file or group id @@ -320,7 +335,7 @@ VarLenType CommonFG::openVarLenType(const char* name) const // No failure, create and return the VarLenType object VarLenType varlen_type; f_DataType_setId(&varlen_type, type_id); - return(varlen_type); + return (varlen_type); } //-------------------------------------------------------------------------- @@ -330,9 +345,10 @@ VarLenType CommonFG::openVarLenType(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CommonFG::openVarLenType(const H5std_string& name) const +VarLenType +CommonFG::openVarLenType(const H5std_string &name) const { - return(openVarLenType(name.c_str())); + return (openVarLenType(name.c_str())); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -341,14 +357,18 @@ VarLenType CommonFG::openVarLenType(const H5std_string& name) const ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::CommonFG() {} +CommonFG::CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: CommonFG destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CommonFG::~CommonFG() {} +CommonFG::~CommonFG() +{ +} //-------------------------------------------------------------------------- // Function: f_DataType_setId - friend @@ -360,7 +380,8 @@ CommonFG::~CommonFG() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataType_setId(DataType* dtype, hid_t new_id) +void +f_DataType_setId(DataType *dtype, hid_t new_id) { dtype->p_setId(new_id); } @@ -375,11 +396,12 @@ void f_DataType_setId(DataType* dtype, hid_t new_id) // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSet_setId(DataSet* dset, hid_t new_id) +void +f_DataSet_setId(DataSet *dset, hid_t new_id) { dset->p_setId(new_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 68e3f193035..d87f9ca1348 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __CommonFG_H -#define __CommonFG_H +#ifndef H5CommonFG_H +#define H5CommonFG_H namespace H5 { @@ -28,63 +28,62 @@ class VarLenType; */ /* Note: This class is being deprecated gradually. */ class H5_DLLCPP CommonFG { - public: - // Opens a generic named datatype in this location. - DataType openDataType(const char* name) const; - DataType openDataType(const H5std_string& name) const; + public: + // Opens a generic named datatype in this location. + DataType openDataType(const char *name) const; + DataType openDataType(const H5std_string &name) const; - // Opens a named array datatype in this location. - ArrayType openArrayType(const char* name) const; - ArrayType openArrayType(const H5std_string& name) const; + // Opens a named array datatype in this location. + ArrayType openArrayType(const char *name) const; + ArrayType openArrayType(const H5std_string &name) const; - // Opens a named compound datatype in this location. - CompType openCompType(const char* name) const; - CompType openCompType(const H5std_string& name) const; + // Opens a named compound datatype in this location. + CompType openCompType(const char *name) const; + CompType openCompType(const H5std_string &name) const; - // Opens a named enumeration datatype in this location. - EnumType openEnumType(const char* name) const; - EnumType openEnumType(const H5std_string& name) const; + // Opens a named enumeration datatype in this location. + EnumType openEnumType(const char *name) const; + EnumType openEnumType(const H5std_string &name) const; - // Opens a named integer datatype in this location. - IntType openIntType(const char* name) const; - IntType openIntType(const H5std_string& name) const; + // Opens a named integer datatype in this location. + IntType openIntType(const char *name) const; + IntType openIntType(const H5std_string &name) const; - // Opens a named floating-point datatype in this location. - FloatType openFloatType(const char* name) const; - FloatType openFloatType(const H5std_string& name) const; + // Opens a named floating-point datatype in this location. + FloatType openFloatType(const char *name) const; + FloatType openFloatType(const H5std_string &name) const; - // Opens a named string datatype in this location. - StrType openStrType(const char* name) const; - StrType openStrType(const H5std_string& name) const; + // Opens a named string datatype in this location. + StrType openStrType(const char *name) const; + StrType openStrType(const H5std_string &name) const; - // Opens a named variable length datatype in this location. - VarLenType openVarLenType(const char* name) const; - VarLenType openVarLenType(const H5std_string& name) const; + // Opens a named variable length datatype in this location. + VarLenType openVarLenType(const char *name) const; + VarLenType openVarLenType(const H5std_string &name) const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - /// For subclasses, H5File and Group, to return the correct - /// object id, i.e. file or group id. - virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to return the correct + /// object id, i.e. file or group id. + virtual hid_t getLocId() const = 0; + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const = 0; - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; + // Default constructor. + CommonFG(); - // Default constructor. - CommonFG(); + // Noop destructor. + virtual ~CommonFG(); - // Noop destructor. - virtual ~CommonFG(); - - protected: - virtual void p_setId(const hid_t new_id) = 0; + protected: + virtual void p_setId(const hid_t new_id) = 0; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of CommonFG } // namespace H5 -#endif // __CommonFG_H +#endif // H5CommonFG_H /*************************************************************************** Design Note diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index fe96bb07641..3b38c6d81cd 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -37,7 +37,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType() : DataType() {} +CompType::CompType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: CompType copy constructor @@ -45,7 +47,9 @@ CompType::CompType() : DataType() {} ///\param original - IN: Original CompType instance // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const CompType& original) : DataType(original) {} +CompType::CompType(const CompType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -53,7 +57,9 @@ CompType::CompType(const CompType& original) : DataType(original) {} ///\param existing_id - IN: Id of an existing compound datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} +CompType::CompType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -65,7 +71,9 @@ CompType::CompType(const hid_t existing_id) : DataType(existing_id) {} // the compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} +CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) +{ +} //-------------------------------------------------------------------------- // Function: CompType overloaded constructor @@ -75,14 +83,13 @@ CompType::CompType(size_t size) : DataType(H5T_COMPOUND, size) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::CompType(const DataSet& dataset) : DataType() +CompType::CompType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is invalid, throw exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("CompType constructor", "H5Dget_type failed"); } } @@ -101,7 +108,7 @@ CompType::CompType(const DataSet& dataset) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -120,7 +127,7 @@ CompType::CompType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +CompType::CompType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -133,7 +140,8 @@ CompType::CompType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* CompType::decode() const +DataType * +CompType::decode() const { hid_t encoded_cmptype_id = H5I_INVALID_HID; try { @@ -144,7 +152,7 @@ DataType* CompType::decode() const } CompType *encoded_cmptype = new CompType; encoded_cmptype->p_setId(encoded_cmptype_id); - return(encoded_cmptype); + return (encoded_cmptype); } //-------------------------------------------------------------------------- @@ -154,15 +162,15 @@ DataType* CompType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int CompType::getNmembers() const +int +CompType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("CompType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -173,17 +181,18 @@ int CompType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string CompType::getMemberName(unsigned member_num) const +H5std_string +CompType::getMemberName(unsigned member_num) const { - char* member_name_C = H5Tget_member_name(id, member_num); - if (member_name_C == NULL) // NULL means failure + char *member_name_C = H5Tget_member_name(id, member_num); + if (member_name_C == NULL) // NULL means failure { throw DataTypeIException("CompType::getMemberName", - "H5Tget_member_name returns NULL for member name"); + "H5Tget_member_name returns NULL for member name"); } H5std_string member_name = H5std_string(member_name_C); // convert C string to string - H5free_memory(member_name_C); // free the C string - return(member_name); // return the member name string + H5free_memory(member_name_C); // free the C string + return (member_name); // return the member name string } //-------------------------------------------------------------------------- @@ -198,19 +207,19 @@ H5std_string CompType::getMemberName(unsigned member_num) const /// function \c CompType::getNmembers. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int CompType::getMemberIndex(const char* name) const +int +CompType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("CompType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("CompType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } -int CompType::getMemberIndex(const H5std_string& name) const +int +CompType::getMemberIndex(const H5std_string &name) const { - return(getMemberIndex(name.c_str())); + return (getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -228,10 +237,11 @@ int CompType::getMemberIndex(const H5std_string& name) const // Note that byte offset being returned as 0 doesn't indicate // a failure. (According to Quincey) //-------------------------------------------------------------------------- -size_t CompType::getMemberOffset(unsigned member_num) const +size_t +CompType::getMemberOffset(unsigned member_num) const { size_t offset = H5Tget_member_offset(id, member_num); - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -244,29 +254,28 @@ size_t CompType::getMemberOffset(unsigned member_num) const // Modification // Modified to use H5Tget_member_class instead. - Jul, 2005 //-------------------------------------------------------------------------- -H5T_class_t CompType::getMemberClass(unsigned member_num) const +H5T_class_t +CompType::getMemberClass(unsigned member_num) const { H5T_class_t member_class = H5Tget_member_class(id, member_num); - if (member_class == H5T_NO_CLASS) - { - throw DataTypeIException("CompType::getMemberClass", - "H5Tget_member_class returns H5T_NO_CLASS"); + if (member_class == H5T_NO_CLASS) { + throw DataTypeIException("CompType::getMemberClass", "H5Tget_member_class returns H5T_NO_CLASS"); } - return(member_class); + return (member_class); } // This private member function calls the C API to get the identifier // of the specified member. It provides the id to construct appropriate // sub-types in the functions getMemberXxxType below, where Xxx indicates // the sub-types. -hid_t CompType::p_get_member_type(unsigned member_num) const +hid_t +CompType::p_get_member_type(unsigned member_num) const { // get the id of the specified member first hid_t member_type_id = H5Tget_member_type(id, member_num); if (member_type_id > 0) - return(member_type_id); - else - { + return (member_type_id); + else { // p_get_member_type is private, caller will catch this exception // then throw another with appropriate API name throw DataTypeIException("", "H5Tget_member_type failed"); @@ -282,14 +291,15 @@ hid_t CompType::p_get_member_type(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType CompType::getMemberDataType(unsigned member_num) const +DataType +CompType::getMemberDataType(unsigned member_num) const { try { DataType datatype; f_DataType_setId(&datatype, p_get_member_type(member_num)); - return(datatype); + return (datatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -303,14 +313,15 @@ DataType CompType::getMemberDataType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -ArrayType CompType::getMemberArrayType(unsigned member_num) const +ArrayType +CompType::getMemberArrayType(unsigned member_num) const { try { ArrayType arraytype; f_DataType_setId(&arraytype, p_get_member_type(member_num)); - return(arraytype); + return (arraytype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); } } @@ -324,14 +335,15 @@ ArrayType CompType::getMemberArrayType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType CompType::getMemberCompType(unsigned member_num) const +CompType +CompType::getMemberCompType(unsigned member_num) const { try { CompType comptype; f_DataType_setId(&comptype, p_get_member_type(member_num)); - return(comptype); + return (comptype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); } } @@ -345,14 +357,15 @@ CompType CompType::getMemberCompType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType CompType::getMemberEnumType(unsigned member_num) const +EnumType +CompType::getMemberEnumType(unsigned member_num) const { try { EnumType enumtype; f_DataType_setId(&enumtype, p_get_member_type(member_num)); - return(enumtype); + return (enumtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); } } @@ -366,14 +379,15 @@ EnumType CompType::getMemberEnumType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType CompType::getMemberIntType(unsigned member_num) const +IntType +CompType::getMemberIntType(unsigned member_num) const { try { IntType inttype; f_DataType_setId(&inttype, p_get_member_type(member_num)); - return(inttype); + return (inttype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); } } @@ -387,14 +401,15 @@ IntType CompType::getMemberIntType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType CompType::getMemberFloatType(unsigned member_num) const +FloatType +CompType::getMemberFloatType(unsigned member_num) const { try { FloatType floatype; f_DataType_setId(&floatype, p_get_member_type(member_num)); - return(floatype); + return (floatype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); } } @@ -408,14 +423,15 @@ FloatType CompType::getMemberFloatType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType CompType::getMemberStrType(unsigned member_num) const +StrType +CompType::getMemberStrType(unsigned member_num) const { try { StrType strtype; f_DataType_setId(&strtype, p_get_member_type(member_num)); - return(strtype); + return (strtype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } } @@ -429,14 +445,15 @@ StrType CompType::getMemberStrType(unsigned member_num) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -VarLenType CompType::getMemberVarLenType(unsigned member_num) const +VarLenType +CompType::getMemberVarLenType(unsigned member_num) const { try { VarLenType varlentype; f_DataType_setId(&varlentype, p_get_member_type(member_num)); - return(varlentype); + return (varlentype); } - catch (DataTypeIException& E) { + catch (DataTypeIException &E) { throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); } } @@ -483,18 +500,18 @@ void CompType::getMemberType(unsigned member_num, StrType& strtype) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const +void +CompType::insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const { // Convert string to C-string - const char* name_C; - name_C = name.c_str(); // name_C refers to the contents of name as a C-str + const char *name_C; + name_C = name.c_str(); // name_C refers to the contents of name as a C-str - hid_t new_member_id = new_member.getId(); // get new_member id for C API + hid_t new_member_id = new_member.getId(); // get new_member id for C API // Call C routine H5Tinsert to add the new member herr_t ret_value = H5Tinsert(id, name_C, offset, new_member_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::insertMember", "H5Tinsert failed"); } } @@ -506,12 +523,12 @@ void CompType::insertMember(const H5std_string& name, size_t offset, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void CompType::pack() const +void +CompType::pack() const { // Calls C routine H5Tpack to remove padding herr_t ret_value = H5Tpack(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::pack", "H5Tpack failed"); } } @@ -525,12 +542,12 @@ void CompType::pack() const // H5Tset_size works on atom datatypes and compound datatypes only // Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void CompType::setSize(size_t size) const +void +CompType::setSize(size_t size) const { // Call C routine H5Tset_size to set the total size herr_t ret_value = H5Tset_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("CompType::setSize", "H5Tset_size failed"); } } @@ -540,6 +557,8 @@ void CompType::setSize(size_t size) const ///\brief Properly terminates access to this compound datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -CompType::~CompType() {} +CompType::~CompType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index d85e2ed39c2..6a4c093decc 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5CompType_H -#define __H5CompType_H +#ifndef H5CompType_H +#define H5CompType_H namespace H5 { @@ -23,101 +23,105 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP CompType : public DataType { - public: - // Default constructor - CompType(); + public: + // Default constructor + CompType(); - // Creates a compound datatype using an existing id - CompType(const hid_t existing_id); + // Creates a compound datatype using an existing id + CompType(const hid_t existing_id); - // Creates a new compound datatype, given the type's size - CompType(size_t size); // H5Tcreate + // Creates a new compound datatype, given the type's size + CompType(size_t size); // H5Tcreate - // Gets the compound datatype of the specified dataset - CompType(const DataSet& dataset); // H5Dget_type + // Gets the compound datatype of the specified dataset + CompType(const DataSet &dataset); // H5Dget_type - // Copy constructor - same as the original CompType. - CompType(const CompType& original); + // Copy constructor - same as the original CompType. + CompType(const CompType &original); - // Constructors that open a compound datatype, given a location. - CompType(const H5Location& loc, const char* name); - CompType(const H5Location& loc, const H5std_string& name); + // Constructors that open a compound datatype, given a location. + CompType(const H5Location &loc, const char *name); + CompType(const H5Location &loc, const H5std_string &name); - // Returns a CompType object via DataType* by decoding the binary - // object description of this type. - virtual DataType* decode() const; + // Returns a CompType object via DataType* by decoding the binary + // object description of this type. + virtual DataType *decode() const; - // Returns the type class of the specified member of this compound - // datatype. It provides to the user a way of knowing what type - // to create another datatype of the same class - H5T_class_t getMemberClass(unsigned member_num) const; + // Returns the type class of the specified member of this compound + // datatype. It provides to the user a way of knowing what type + // to create another datatype of the same class + H5T_class_t getMemberClass(unsigned member_num) const; - // Returns the index of a member in this compound data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this compound data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the offset of a member of this compound datatype. - size_t getMemberOffset(unsigned memb_no) const; + // Returns the offset of a member of this compound datatype. + size_t getMemberOffset(unsigned memb_no) const; - // Returns the name of a member of this compound datatype. - H5std_string getMemberName(unsigned member_num) const; + // Returns the name of a member of this compound datatype. + H5std_string getMemberName(unsigned member_num) const; - // Returns the generic datatype of the specified member in - // this compound datatype. - DataType getMemberDataType(unsigned member_num) const; + // Returns the generic datatype of the specified member in + // this compound datatype. + DataType getMemberDataType(unsigned member_num) const; - // Returns the array datatype of the specified member in - // this compound datatype. - ArrayType getMemberArrayType(unsigned member_num) const; + // Returns the array datatype of the specified member in + // this compound datatype. + ArrayType getMemberArrayType(unsigned member_num) const; - // Returns the compound datatype of the specified member in - // this compound datatype. - CompType getMemberCompType(unsigned member_num) const; + // Returns the compound datatype of the specified member in + // this compound datatype. + CompType getMemberCompType(unsigned member_num) const; - // Returns the enumeration datatype of the specified member in - // this compound datatype. - EnumType getMemberEnumType(unsigned member_num) const; + // Returns the enumeration datatype of the specified member in + // this compound datatype. + EnumType getMemberEnumType(unsigned member_num) const; - // Returns the integer datatype of the specified member in - // this compound datatype. - IntType getMemberIntType(unsigned member_num) const; + // Returns the integer datatype of the specified member in + // this compound datatype. + IntType getMemberIntType(unsigned member_num) const; - // Returns the floating-point datatype of the specified member in - // this compound datatype. - FloatType getMemberFloatType(unsigned member_num) const; + // Returns the floating-point datatype of the specified member in + // this compound datatype. + FloatType getMemberFloatType(unsigned member_num) const; - // Returns the string datatype of the specified member in - // this compound datatype. - StrType getMemberStrType(unsigned member_num) const; + // Returns the string datatype of the specified member in + // this compound datatype. + StrType getMemberStrType(unsigned member_num) const; - // Returns the variable length datatype of the specified member in - // this compound datatype. - VarLenType getMemberVarLenType(unsigned member_num) const; + // Returns the variable length datatype of the specified member in + // this compound datatype. + VarLenType getMemberVarLenType(unsigned member_num) const; - // Returns the number of members in this compound datatype. - int getNmembers() const; + // Returns the number of members in this compound datatype. + int getNmembers() const; - // Adds a new member to this compound datatype. - void insertMember(const H5std_string& name, size_t offset, const DataType& new_member) const; + // Adds a new member to this compound datatype. + void insertMember(const H5std_string &name, size_t offset, const DataType &new_member) const; - // Recursively removes padding from within this compound datatype. - void pack() const; + // Recursively removes padding from within this compound datatype. + void pack() const; - // Sets the total size for this compound datatype. - void setSize(size_t size) const; + // Sets the total size for this compound datatype. + void setSize(size_t size) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("CompType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("CompType"); + } - // Noop destructor. - virtual ~CompType(); + // Noop destructor. + virtual ~CompType(); - private: - // Contains common code that is used by the member functions - // getMemberXxxType - hid_t p_get_member_type(unsigned member_num) const; + private: + // Contains common code that is used by the member functions + // getMemberXxxType + hid_t p_get_member_type(unsigned member_num) const; }; // end of CompType } // namespace H5 -#endif // __H5CompType_H +#endif // H5CompType_H diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 01fae453045..9272bdb1f5a 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Cpp_H -#define __H5Cpp_H +#ifndef H5Cpp_H +#define H5Cpp_H #include "H5Include.h" #include "H5Exception.h" @@ -53,9 +53,9 @@ */ #ifndef H5_CXX_HAVE_OFFSETOF #ifdef HOFFSET - #undef HOFFSET +#undef HOFFSET #endif -#define HOFFSET(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) #endif -#endif // __H5Cpp_H +#endif // H5Cpp_H diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index 11081814684..4337a6fe911 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5CppDoc_H -#define __H5CppDoc_H +#ifndef H5CppDoc_H +#define H5CppDoc_H //------------------------------------------------------------------------- // The following section will be used to generate the 'Mainpage' @@ -92,4 +92,4 @@ /// This example shows how to work with groups. ///\example h5group.cpp -#endif // __H5CppDoc_H +#endif // H5CppDoc_H diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp index c6ff705f873..35c071ac7c8 100644 --- a/c++/src/H5DaccProp.cpp +++ b/c++/src/H5DaccProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,7 +29,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; +DSetAccPropList *DSetAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetAccPropList::getConstant @@ -43,13 +43,13 @@ DSetAccPropList* DSetAccPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetAccPropList* DSetAccPropList::getConstant() +DSetAccPropList * +DSetAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -58,8 +58,9 @@ DSetAccPropList* DSetAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetAccPropList(H5P_DATASET_ACCESS); else - throw PropListIException("DSetAccPropList::getConstant", "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetAccPropList::getConstant", + "DSetAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -68,7 +69,8 @@ DSetAccPropList* DSetAccPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetAccPropList::deleteConstants() +void +DSetAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -77,7 +79,7 @@ void DSetAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); +const DSetAccPropList &DSetAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +88,9 @@ const DSetAccPropList& DSetAccPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} +DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList copy constructor @@ -94,7 +98,9 @@ DSetAccPropList::DSetAccPropList() : LinkAccPropList(H5P_DATASET_ACCESS) {} /// DSetAccPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList(orig) {} +DSetAccPropList::DSetAccPropList(const DSetAccPropList &orig) : LinkAccPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList overloaded constructor @@ -102,7 +108,9 @@ DSetAccPropList::DSetAccPropList(const DSetAccPropList& orig) : LinkAccPropList( /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) {} +DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetAccPropList::setChunkCache @@ -122,11 +130,11 @@ DSetAccPropList::DSetAccPropList(const hid_t plist_id) : LinkAccPropList(plist_i /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const +void +DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_chunk_cache(id, rdcc_nslots, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::setChunkCache", "H5Pset_chunk_cache failed"); } } @@ -143,11 +151,11 @@ void DSetAccPropList::setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, doub /// the HDF5 C Reference Manual. // July 2018 //-------------------------------------------------------------------------- -void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const +void +DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_chunk_cache(id, &rdcc_nslots, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetAccPropList::getChunkCache", "H5Pget_chunk_cache failed"); } } @@ -157,6 +165,8 @@ void DSetAccPropList::getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, d ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetAccPropList::~DSetAccPropList() {} +DSetAccPropList::~DSetAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h index 111b4f5c20a..7d6b25051c1 100644 --- a/c++/src/H5DaccProp.h +++ b/c++/src/H5DaccProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DSetAccPropList_H -#define __H5DSetAccPropList_H +#ifndef H5DSetAccPropList_H +#define H5DSetAccPropList_H namespace H5 { @@ -23,46 +23,50 @@ namespace H5 { */ // Inheritance: LinkAccPropList -> PropList -> IdComponent class H5_DLLCPP DSetAccPropList : public LinkAccPropList { - public: - ///\brief Default dataset creation property list. - static const DSetAccPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetAccPropList &DEFAULT; - // Creates a dataset creation property list. - DSetAccPropList(); + // Creates a dataset creation property list. + DSetAccPropList(); - // Sets the raw data chunk cache parameters. - void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the raw data chunk cache parameters. + void setChunkCache(size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) const; - // Retrieves the raw data chunk cache parameters. - void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; + // Retrieves the raw data chunk cache parameters. + void getChunkCache(size_t &rdcc_nslots, size_t &rdcc_nbytes, double &rdcc_w0) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetAccPropList"); + } - // Copy constructor - same as the original DSetAccPropList. - DSetAccPropList(const DSetAccPropList& orig); + // Copy constructor - same as the original DSetAccPropList. + DSetAccPropList(const DSetAccPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetAccPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetAccPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetAccPropList(); + // Noop destructor. + virtual ~DSetAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetAccPropList* DEFAULT_; + private: + static DSetAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetAccPropList } // namespace H5 -#endif // __H5DSetAccPropList_H +#endif // H5DSetAccPropList_H diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index db145774def..47031dbfaec 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -6,19 +6,15 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include -#include "H5private.h" // for HDfree +#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -46,15 +42,15 @@ using std::endl; //-------------------------------------------------------------------------- // Function: DataSet default constructor ///\brief Default constructor: creates a stub DataSet. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} +DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: DataSet overloaded constructor ///\brief Creates an DataSet object using the id of an existing dataset. ///\param existing_id - IN: Id of an existing dataset -// Programmer Binh-Minh Ribler - 2000 // Description // incRefCount() is needed here to prevent the id from being closed // prematurely. That is, when application uses the id of an @@ -71,13 +67,26 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existin // Function: DataSet copy constructor ///\brief Copy constructor: same HDF5 object as \a original ///\param original - IN: DataSet instance to copy -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id) +DataSet::DataSet(const DataSet &original) : H5Object(), AbstractDs(), id(original.id) { incRefCount(); // increment number of references to this id } +//-------------------------------------------------------------------------- +// Function: DataSet assignment operator +///\brief Assignment operator: same HDF5 object as \a original +///\param original - IN: DataSet instance to copy +//-------------------------------------------------------------------------- +DataSet & +DataSet::operator=(const DataSet &original) +{ + if (this != &original) { + setId(original.id); + } + return (*this); +} + //-------------------------------------------------------------------------- // Function: DataSet overload constructor - dereference ///\brief Given a reference, ref, to an hdf5 location, creates a @@ -91,9 +100,9 @@ DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(origina ///\par Description /// \c loc can be DataSet, Group, H5File, or named DataType, that /// is a datatype that has been named by DataType::commit. -// Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereferenced"); } @@ -107,9 +116,9 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co ///\param ref_type - IN: Reference type - default to H5R_OBJECT ///\param plist - IN: Property list - default to PropList::DEFAULT ///\exception H5::ReferenceException -// Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), AbstractDs(), id(H5I_INVALID_HID) +DataSet::DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), AbstractDs(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -119,34 +128,33 @@ DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, co ///\brief Gets a copy of the dataspace of this dataset. ///\return DataSpace instance ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace DataSet::getSpace() const +DataSpace +DataSet::getSpace() const { // Calls C function H5Dget_space to get the id of the dataspace hid_t dataspace_id = H5Dget_space(id); // If the dataspace id is invalid, throw an exception - if (dataspace_id < 0) - { + if (dataspace_id < 0) { throw DataSetIException("DataSet::getSpace", "H5Dget_space failed"); } - //create dataspace object using the existing id then return the object + // create dataspace object using the existing id then return the object DataSpace data_space; f_DataSpace_setId(&data_space, dataspace_id); - return(data_space); + return (data_space); } // This private member function calls the C API to get the identifier // of the datatype that is used by this dataset. It is used // by the various AbstractDs functions to get the specific datatype. -hid_t DataSet::p_get_type() const +hid_t +DataSet::p_get_type() const { hid_t type_id = H5Dget_type(id); if (type_id > 0) - return(type_id); - else - { + return (type_id); + else { throw DataSetIException("", "H5Dget_type failed"); } } @@ -156,20 +164,19 @@ hid_t DataSet::p_get_type() const ///\brief Gets the dataset creation property list. ///\return DSetCreatPropList instance ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList DataSet::getCreatePlist() const +DSetCreatPropList +DataSet::getCreatePlist() const { hid_t create_plist_id = H5Dget_create_plist(id); - if (create_plist_id < 0) - { + if (create_plist_id < 0) { throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); } // create and return the DSetCreatPropList object DSetCreatPropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -179,18 +186,18 @@ DSetCreatPropList DataSet::getCreatePlist() const ///\exception H5::DataSetIException // July 2018 //-------------------------------------------------------------------------- -DSetAccPropList DataSet::getAccessPlist() const +DSetAccPropList +DataSet::getAccessPlist() const { hid_t access_plist_id = H5Dget_access_plist(id); - if (access_plist_id < 0) - { + if (access_plist_id < 0) { throw DataSetIException("DataSet::getAccessPlist", "H5Dget_access_plist failed"); } // create and return the DSetCreatPropList object DSetAccPropList access_plist; f_PropList_setId(&access_plist, access_plist_id); - return(access_plist); + return (access_plist); } //-------------------------------------------------------------------------- @@ -200,12 +207,12 @@ DSetAccPropList DataSet::getAccessPlist() const ///\exception H5::DataSetIException // Note: H5Dget_storage_size returns 0 when there is no data. This // function should have no failure. (from SLU) -// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -hsize_t DataSet::getStorageSize() const +hsize_t +DataSet::getStorageSize() const { hsize_t storage_size = H5Dget_storage_size(id); - return(storage_size); + return (storage_size); } //-------------------------------------------------------------------------- @@ -213,64 +220,56 @@ hsize_t DataSet::getStorageSize() const ///\brief Gets the size in memory of the dataset's data. ///\return Size of data (in memory) ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Apr 2009 //-------------------------------------------------------------------------- -size_t DataSet::getInMemDataSize() const +size_t +DataSet::getInMemDataSize() const { const char *func = "DataSet::getInMemDataSize"; // Get the data type of this dataset hid_t mem_type_id = H5Dget_type(id); - if (mem_type_id < 0) - { + if (mem_type_id < 0) { throw DataSetIException(func, "H5Dget_type failed"); } // Get the data type's size by first getting its native type then getting // the native type's size. hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); - if (native_type < 0) - { + if (native_type < 0) { throw DataSetIException(func, "H5Tget_native_type failed"); } size_t type_size = H5Tget_size(native_type); - if (type_size == 0) - { + if (type_size == 0) { throw DataSetIException(func, "H5Tget_size failed"); } // Close the native type and the datatype of this dataset. - if (H5Tclose(native_type) < 0) - { + if (H5Tclose(native_type) < 0) { throw DataSetIException(func, "H5Tclose(native_type) failed"); } - if (H5Tclose(mem_type_id) < 0) - { + if (H5Tclose(mem_type_id) < 0) { throw DataSetIException(func, "H5Tclose(mem_type_id) failed"); } // Get number of elements of the dataset by first getting its dataspace, // then getting the number of elements in the dataspace hid_t space_id = H5Dget_space(id); - if (space_id < 0) - { + if (space_id < 0) { throw DataSetIException(func, "H5Dget_space failed"); } hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); - if (num_elements < 0) - { + if (num_elements < 0) { throw DataSetIException(func, "H5Sget_simple_extent_npoints failed"); } // Close the dataspace - if (H5Sclose(space_id) < 0) - { + if (H5Sclose(space_id) < 0) { throw DataSetIException(func, "H5Sclose failed"); } // Calculate and return the size of the data size_t data_size = type_size * num_elements; - return(data_size); + return (data_size); } //-------------------------------------------------------------------------- @@ -278,18 +277,17 @@ size_t DataSet::getInMemDataSize() const ///\brief Returns the address of this dataset in the file. ///\return Address of dataset ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -haddr_t DataSet::getOffset() const +haddr_t +DataSet::getOffset() const { haddr_t ds_addr; // for address of dataset ds_addr = H5Dget_offset(id); - if (ds_addr == HADDR_UNDEF) - { + if (ds_addr == HADDR_UNDEF) { throw DataSetIException("DataSet::getOffset", "H5Dget_offset returned HADDR_UNDEF"); } - return(ds_addr); + return (ds_addr); } //-------------------------------------------------------------------------- @@ -297,13 +295,12 @@ haddr_t DataSet::getOffset() const ///\brief Determines whether space has been allocated for a dataset. ///\param status - OUT: Space allocation status ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::getSpaceStatus(H5D_space_status_t& status) const +void +DataSet::getSpaceStatus(H5D_space_status_t &status) const { herr_t ret_value = H5Dget_space_status(id, &status); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getSpaceStatus", "H5Dget_space_status failed"); } } @@ -315,22 +312,21 @@ void DataSet::getSpaceStatus(H5D_space_status_t& status) const ///\param space - IN: Selection for the memory buffer ///\return Amount of storage ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) const +hsize_t +DataSet::getVlenBufSize(const DataType &type, const DataSpace &space) const { // Obtain identifiers for C API - hid_t type_id = type.getId(); + hid_t type_id = type.getId(); hid_t space_id = space.getId(); hsize_t size; // for amount of storage herr_t ret_value = H5Dvlen_get_buf_size(id, type_id, space_id, &size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::getVlenBufSize", "H5Dvlen_get_buf_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -340,13 +336,12 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co // misses const's. This wrapper will be removed in future release. // Return Amount of storage // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const +// hsize_t DataSet::getVlenBufSize(DataType& type, DataSpace& space) const //{ // return(getVlenBufSize(type, space)); //} @@ -360,19 +355,19 @@ hsize_t DataSet::getVlenBufSize(const DataType& type, const DataSpace& space) co ///\param xfer_plist - IN: Property list used to create the buffer ///\param buf - IN: Pointer to the buffer to be reclaimed ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf) +void +DataSet::vlenReclaim(const DataType &type, const DataSpace &space, const DSetMemXferPropList &xfer_plist, + void *buf) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); - herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { - throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); + herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf); + if (ret_value < 0) { + throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -385,22 +380,22 @@ void DataSet::vlenReclaim(const DataType& type, const DataSpace& space, const DS ///\param xfer_plist - IN: Property list used to create the buffer ///\param buf - IN: Pointer to the buffer to be reclaimed ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //\parDescription // This function has better prototype for the users than the // other, which might be removed at some point. BMR - 2006/12/20 //-------------------------------------------------------------------------- -void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist) +void +DataSet::vlenReclaim(void *buf, const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); - herr_t ret_value = H5Dvlen_reclaim(type_id, space_id, xfer_plist_id, buf); - if (ret_value < 0) - { - throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed"); + herr_t ret_value = H5Treclaim(type_id, space_id, xfer_plist_id, buf); + if (ret_value < 0) { + throw DataSetIException("DataSet::vlenReclaim", "H5Treclaim failed"); } } @@ -417,19 +412,19 @@ void DataSet::vlenReclaim(void* buf, const DataType& type, const DataSpace& spac /// This function reads raw data from this dataset into the /// buffer \a buf, converting from file datatype and dataspace /// to memory datatype \a mem_type and dataspace \a mem_space. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(void *buf, const DataType &mem_type, const DataSpace &mem_space, const DataSpace &file_space, + const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed"); } } @@ -444,7 +439,6 @@ void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_spa ///\param file_space - IN: Dataset's dataspace in the file ///\param xfer_plist - IN: Transfer property list for this I/O operation ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Jul 2009 // Follow the change to Attribute::read and use the following @@ -453,28 +447,28 @@ void DataSet::read(void* buf, const DataType& mem_type, const DataSpace& mem_spa // DataSet::p_read_fixed_len and // DataSet::p_read_variable_len //-------------------------------------------------------------------------- -void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::read(H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this dataset has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::read", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); - if (!is_variable_len) // only allocate for fixed-len string + if (!is_variable_len) // only allocate for fixed-len string { p_read_fixed_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } - else - { + else { p_read_variable_len(mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg); } } @@ -493,19 +487,19 @@ void DataSet::read(H5std_string& strg, const DataType& mem_type, const DataSpace /// \a buf to a dataset, converting from memory datatype /// \a mem_type and dataspace \a mem_space to file datatype /// and dataspace. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const void *buf, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); herr_t ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -514,45 +508,42 @@ void DataSet::write(const void* buf, const DataType& mem_type, const DataSpace& // Function: DataSet::write ///\brief This is an overloaded member function, provided for convenience. /// It takes a reference to a \c H5std_string for the buffer. -// Programmer Binh-Minh Ribler - 2000 // Modification // Jul 2009 // Modified to pass the buffer into H5Dwrite properly depending // whether the dataset has variable- or fixed-length string. //-------------------------------------------------------------------------- -void DataSet::write(const H5std_string& strg, const DataType& mem_type, const DataSpace& mem_space, const DataSpace& file_space, const DSetMemXferPropList& xfer_plist) const +void +DataSet::write(const H5std_string &strg, const DataType &mem_type, const DataSpace &mem_space, + const DataSpace &file_space, const DSetMemXferPropList &xfer_plist) const { // Check if this attribute has variable-len string or fixed-len string and // proceed appropriately. htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); - if (is_variable_len < 0) - { + if (is_variable_len < 0) { throw DataSetIException("DataSet::write", "H5Tis_variable_str failed"); } // Obtain identifiers for C API - hid_t mem_type_id = mem_type.getId(); - hid_t mem_space_id = mem_space.getId(); + hid_t mem_type_id = mem_type.getId(); + hid_t mem_space_id = mem_space.getId(); hid_t file_space_id = file_space.getId(); hid_t xfer_plist_id = xfer_plist.getId(); // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + const char *strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str herr_t ret_value = 0; // Pass string in differently depends on variable or fixed length - if (!is_variable_len) - { + if (!is_variable_len) { ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); } - else - { + else { // passing string argument by address ret_value = H5Dwrite(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); } - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::write", "H5Dwrite failed"); } } @@ -572,17 +563,18 @@ void DataSet::write(const H5std_string& strg, const DataType& mem_type, const Da ///\exception H5::DataSetIException ///\note This function may not work correctly yet - it's still /// under development. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data) +int +DataSet::iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, + void *op_data) { // Obtain identifiers for C API - hid_t type_id = type.getId(); - hid_t space_id = space.getId(); + hid_t type_id = type.getId(); + hid_t space_id = space.getId(); herr_t ret_value = H5Diterate(buf, type_id, space_id, op, op_data); if (ret_value >= 0) - return(ret_value); - else // raise exception when H5Diterate returns a negative value + return (ret_value); + else // raise exception when H5Diterate returns a negative value { throw DataSetIException("DataSet::iterateElems", "H5Diterate failed"); } @@ -596,12 +588,12 @@ int DataSet::iterateElems(void* buf, const DataType& type, const DataSpace& spac ///\par Description /// For information, please refer to the H5Dset_extent API in /// the HDF5 C Reference Manual. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::extend(const hsize_t* size) const +void +DataSet::extend(const hsize_t *size) const { herr_t ret_value = H5Dset_extent(id, size); - if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value + if (ret_value < 0) // raise exception when H5Dset_extent returns a neg value throw DataSetIException("DataSet::extend", "H5Dset_extent failed"); } @@ -614,16 +606,16 @@ void DataSet::extend(const hsize_t* size) const ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2014 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const { - hid_t fill_type_id = fill_type.getId(); - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t fill_type_id = fill_type.getId(); + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(fill, fill_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -639,13 +631,13 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, // Param buf_type - IN: Datatype of the elements in buffer // Param space - IN: Dataspace describing memory buffer & containing selection to use // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& +// space) //{ // fillMemBuf(fill, (const DataType)fill_type, buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -657,15 +649,14 @@ void DataSet::fillMemBuf(const void *fill, const DataType& fill_type, void *buf, ///\param buf_type - IN: Datatype of the elements in buffer ///\param space - IN: Dataspace describing memory buffer & containing selection to use ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const +void +DataSet::fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const { - hid_t buf_type_id = buf_type.getId(); - hid_t space_id = space.getId(); - herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); - if (ret_value < 0) - { + hid_t buf_type_id = buf_type.getId(); + hid_t space_id = space.getId(); + herr_t ret_value = H5Dfill(NULL, buf_type_id, buf, buf_type_id, space_id); + if (ret_value < 0) { throw DataSetIException("DataSet::fillMemBuf", "H5Dfill failed"); } } @@ -679,13 +670,12 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // Param buf_type - IN: Datatype of the elements in buffer // Param space - IN: Dataspace describing memory buffer & containing selection to use // Exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 // Modification // Modified to call its replacement. -BMR, 2014/04/16 // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) +// void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) //{ // fillMemBuf(buf, (const DataType)buf_type, (const DataSpace)space); //} @@ -699,25 +689,26 @@ void DataSet::fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& s // AbstractDs and Attribute are moved out of H5Object. In // addition, member IdComponent::id is moved into subclasses, and // IdComponent::getId now becomes pure virtual function. -// Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSet::getId() const +hid_t +DataSet::getId() const { - return(id); + return (id); } //-------------------------------------------------------------------------- // Function: DataSet::p_read_fixed_len (private) -// brief Reads a fixed length \a H5std_string from a dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// brief Reads a fixed length \a H5std_string from a dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exceptio n H5::DataSetIException // Modification // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const +void +DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const { // Only allocate for fixed-len string. @@ -725,37 +716,36 @@ void DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id size_t data_size = getInMemDataSize(); // If there is data, allocate buffer and read it. - if (data_size > 0) - { - char *strg_C = new char [data_size+1]; - HDmemset(strg_C, 0, data_size+1); // clear buffer + if (data_size > 0) { + char *strg_C = new char[data_size + 1]; + HDmemset(strg_C, 0, data_size + 1); // clear buffer herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); - if (ret_value < 0) - { - delete []strg_C; // de-allocate for fixed-len string + if (ret_value < 0) { + delete[] strg_C; // de-allocate for fixed-len string throw DataSetIException("DataSet::read", "H5Dread failed for fixed length string"); } // Get string from the C char* and release resource allocated locally strg = strg_C; - delete []strg_C; + delete[] strg_C; } } //-------------------------------------------------------------------------- // Function: DataSet::p_read_variable_len (private) -// brief Reads a variable length \a H5std_string from an dataset. -// param mem_type - IN: DataSet datatype (in memory) -// param strg - IN: Buffer for read string -// exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Jul, 2009 +// brief Reads a variable length \a H5std_string from an dataset. +// param mem_type - IN: DataSet datatype (in memory) +// param strg - IN: Buffer for read string +// exception H5::DataSetIException // Modification // Jul 2009 // Added in follow to the change in Attribute::read //-------------------------------------------------------------------------- -void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const +void +DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const { // Prepare and call C API to read dataset. char *strg_C; @@ -763,8 +753,7 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // Read dataset, no allocation for variable-len string; C library will herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, &strg_C); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::read", "H5Dread failed for variable length string"); } @@ -784,19 +773,19 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space // The underlaying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. -// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSet::p_setId(const hid_t new_id) +void +DataSet::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } //-------------------------------------------------------------------------- @@ -807,9 +796,9 @@ void DataSet::p_setId(const hid_t new_id) // Applications shouldn't need to use it. // param dset - IN/OUT: DataSet object to be changed // param new_id - IN: New id to set -// Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_PropList_setId(PropList* plist, hid_t new_id) +void +f_PropList_setId(PropList *plist, hid_t new_id) { plist->p_setId(new_id); } @@ -821,15 +810,13 @@ void f_PropList_setId(PropList* plist, hid_t new_id) ///\brief Closes this dataset. /// ///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSet::close() +void +DataSet::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Dclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSetIException("DataSet::close", "H5Dclose failed"); } // reset the id @@ -840,7 +827,6 @@ void DataSet::close() //-------------------------------------------------------------------------- // Function: DataSet destructor ///\brief Properly terminates access to this dataset. -// Programmer Binh-Minh Ribler - 2000 // Modification // - Replaced resetIdComponent() with decRefCount() to use C // library ID reference counting mechanism - BMR, Jun 1, 2004 @@ -852,9 +838,9 @@ DataSet::~DataSet() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index a0a962e4319..333ed7a999f 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DataSet_H -#define __H5DataSet_H +#ifndef H5DataSet_H +#define H5DataSet_H namespace H5 { @@ -26,111 +26,134 @@ namespace H5 { */ // Inheritance: multiple H5Object/AbstractDs -> H5Location -> IdComponent class H5_DLLCPP DataSet : public H5Object, public AbstractDs { - public: - - // Close this dataset. - virtual void close(); - - // Extends the dataset with unlimited dimension. - void extend(const hsize_t* size) const; - - // Fills a selection in memory with a value - void fillMemBuf(const void *fill, const DataType& fill_type, void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Fills a selection in memory with zero - void fillMemBuf(void *buf, const DataType& buf_type, const DataSpace& space) const; - //void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 - - // Gets the creation property list of this dataset. - DSetCreatPropList getCreatePlist() const; - - // Gets the access property list of this dataset. - DSetAccPropList getAccessPlist() const; - - // Returns the address of this dataset in the file. - haddr_t getOffset() const; - - // Gets the dataspace of this dataset. - virtual DataSpace getSpace() const; - - // 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; - - // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; - - // Returns the number of bytes required to store VL data. - hsize_t getVlenBufSize(const DataType& type, const DataSpace& space) const; - //hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 - - // Reclaims VL datatype memory buffers. - static void vlenReclaim(const DataType& type, const DataSpace& space, const DSetMemXferPropList& xfer_plist, void* buf); - static void vlenReclaim(void *buf, const DataType& type, const DataSpace& space = DataSpace::ALL, const DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT); - - // Reads the data of this dataset and stores it in the provided buffer. - // 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 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 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 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 DSetMemXferPropList& xfer_plist = DSetMemXferPropList::DEFAULT) const; - - // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet - int iterateElems(void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL); - - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSet"); } - - // Creates a dataset by way of dereference. - DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - - // Default constructor. - DataSet(); - - // Copy constructor - same as the original DataSet. - DataSet(const DataSet& original); - - // Creates a copy of an existing DataSet using its id. - DataSet(const hid_t existing_id); - - // Gets the dataset id. - virtual hid_t getId() const; - - // Destructor: properly terminates access to this dataset. - virtual ~DataSet(); - - protected: + public: + // Close this dataset. + virtual void close(); + + // Extends the dataset with unlimited dimension. + void extend(const hsize_t *size) const; + + // Fills a selection in memory with a value + void fillMemBuf(const void *fill, const DataType &fill_type, void *buf, const DataType &buf_type, + const DataSpace &space) const; + // void fillMemBuf(const void *fill, DataType& fill_type, void *buf, DataType& buf_type, DataSpace& + // space); // removed from 1.8.18 and 1.10.1 + + // Fills a selection in memory with zero + void fillMemBuf(void *buf, const DataType &buf_type, const DataSpace &space) const; + // void fillMemBuf(void *buf, DataType& buf_type, DataSpace& space); // removed from 1.8.18 and 1.10.1 + + // Gets the creation property list of this dataset. + DSetCreatPropList getCreatePlist() const; + + // Gets the access property list of this dataset. + DSetAccPropList getAccessPlist() const; + + // Returns the address of this dataset in the file. + haddr_t getOffset() const; + + // Gets the dataspace of this dataset. + virtual DataSpace getSpace() const; + + // 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; + + // Returns the in memory size of this attribute's data. + virtual size_t getInMemDataSize() const; + + // Returns the number of bytes required to store VL data. + hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const; + // hsize_t getVlenBufSize(DataType& type, DataSpace& space) const; // removed from 1.8.18 and 1.10.1 + + // Reclaims VL datatype memory buffers. + static void vlenReclaim(const DataType &type, const DataSpace &space, + const DSetMemXferPropList &xfer_plist, void *buf); + static void vlenReclaim(void *buf, const DataType &type, const DataSpace &space = DataSpace::ALL, + const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT); + + // Reads the data of this dataset and stores it in the provided buffer. + // 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 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 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 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 DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; + + // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet + int iterateElems(void *buf, const DataType &type, const DataSpace &space, H5D_operator_t op, + void *op_data = NULL); + + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataSet"); + } + + // Creates a dataset by way of dereference. + DataSet(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + DataSet(const Attribute &attr, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + + // Default constructor. + DataSet(); + + // Copy constructor - same as the original DataSet. + DataSet(const DataSet &original); + + // Assignment operator + DataSet &operator=(const DataSet &original); + + // Creates a copy of an existing DataSet using its id. + DataSet(const hid_t existing_id); + + // Gets the dataset id. + virtual hid_t getId() const; + + // Destructor: properly terminates access to this dataset. + virtual ~DataSet(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the dataset id. - virtual void p_setId(const hid_t new_id); + // Sets the dataset id. + virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataset id + private: + hid_t id; // HDF5 dataset id - // This function contains the common code that is used by - // getTypeClass and various API functions getXxxType - // defined in AbstractDs for generic datatype and specific - // sub-types - virtual hid_t p_get_type() const; + // This function contains the common code that is used by + // getTypeClass and various API functions getXxxType + // defined in AbstractDs for generic datatype and specific + // sub-types + virtual hid_t p_get_type() const; - // 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, const hid_t xfer_plist_id, H5std_string& strg) const; - void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; + // 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, + const hid_t xfer_plist_id, H5std_string &strg) const; + void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, + const hid_t xfer_plist_id, H5std_string &strg) const; - // Friend function to set DataSet id. For library use only. - friend void f_DataSet_setId(DataSet* dset, hid_t new_id); + // Friend function to set DataSet id. For library use only. + friend void f_DataSet_setId(DataSet *dset, hid_t new_id); }; // end of DataSet } // namespace H5 -#endif // __H5DataSet_H +#endif // H5DataSet_H diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index e8e5712cfce..0485530d785 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -6,16 +6,12 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include #include "H5Include.h" @@ -33,7 +29,7 @@ using std::endl; // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DataSpace* DataSpace::ALL_ = 0; +DataSpace *DataSpace::ALL_ = 0; //-------------------------------------------------------------------------- // Function: DataSpace::getConstant @@ -45,13 +41,13 @@ DataSpace* DataSpace::ALL_ = 0; // a DataSpaceIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DataSpace* DataSpace::getConstant() +DataSpace * +DataSpace::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -60,8 +56,9 @@ DataSpace* DataSpace::getConstant() if (ALL_ == 0) ALL_ = new DataSpace(H5S_ALL); else - throw DataSpaceIException("DataSpace::getConstant", "DataSpace::getConstant is being invoked on an allocated ALL_"); - return(ALL_); + throw DataSpaceIException("DataSpace::getConstant", + "DataSpace::getConstant is being invoked on an allocated ALL_"); + return (ALL_); } //-------------------------------------------------------------------------- @@ -69,7 +66,8 @@ DataSpace* DataSpace::getConstant() // Purpose: Deletes the constant object that DataSpace::ALL_ points to // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DataSpace::deleteConstants() +void +DataSpace::deleteConstants() { if (ALL_ != 0) delete ALL_; @@ -78,7 +76,7 @@ void DataSpace::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataspace. //-------------------------------------------------------------------------- -const DataSpace& DataSpace::ALL = *getConstant(); +const DataSpace &DataSpace::ALL = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,8 +92,7 @@ const DataSpace& DataSpace::ALL = *getConstant(); DataSpace::DataSpace(H5S_class_t type) : IdComponent() { id = H5Screate(type); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); } } @@ -109,11 +106,10 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent() ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent() { id = H5Screate_simple(rank, dims, maxdims); - if (id < 0) - { + if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); } } @@ -137,7 +133,7 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id) ///\param original - IN: DataSpace object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) +DataSpace::DataSpace(const DataSpace &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -154,17 +150,18 @@ DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id) // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataSpace::copy(const DataSpace& like_space) +void +DataSpace::copy(const DataSpace &like_space) { // If this object has an hdf5 valid id, close it if (id != H5S_ALL) { try { close(); } - catch (Exception& close_error) { - throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + catch (Exception &close_error) { + throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); } - } // end if + } // end if // call C routine to copy the dataspace id = H5Scopy(like_space.getId()); @@ -184,11 +181,12 @@ void DataSpace::copy(const DataSpace& like_space) // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace& DataSpace::operator=(const DataSpace& rhs) +DataSpace & +DataSpace::operator=(const DataSpace &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -199,17 +197,16 @@ DataSpace& DataSpace::operator=(const DataSpace& rhs) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::isSimple () const +bool +DataSpace::isSimple() const { htri_t simple = H5Sis_simple(id); if (simple > 0) return true; else if (simple == 0) return false; - else - { - throw DataSpaceIException("DataSpace::isSimple", - "H5Sis_simple returns negative value"); + else { + throw DataSpaceIException("DataSpace::isSimple", "H5Sis_simple returns negative value"); } } @@ -225,11 +222,11 @@ bool DataSpace::isSimple () const /// it to be re-defined. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::offsetSimple (const hssize_t* offset) const +void +DataSpace::offsetSimple(const hssize_t *offset) const { herr_t ret_value = H5Soffset_simple(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed"); } } @@ -244,15 +241,15 @@ void DataSpace::offsetSimple (const hssize_t* offset) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const +int +DataSpace::getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims) const { int ndims = H5Sget_simple_extent_dims(id, dims, maxdims); - if (ndims < 0) - { + if (ndims < 0) { throw DataSpaceIException("DataSpace::getSimpleExtentDims", - "H5Sget_simple_extent_dims returns negative number of dimensions"); + "H5Sget_simple_extent_dims returns negative number of dimensions"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -262,15 +259,16 @@ int DataSpace::getSimpleExtentDims (hsize_t *dims, hsize_t *maxdims) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DataSpace::getSimpleExtentNdims () const +int +DataSpace::getSimpleExtentNdims() const { int ndims = H5Sget_simple_extent_ndims(id); - if (ndims < 0) - { - throw DataSpaceIException("DataSpace::getSimpleExtentNdims", + if (ndims < 0) { + throw DataSpaceIException( + "DataSpace::getSimpleExtentNdims", "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace"); } - return(ndims); + return (ndims); } //-------------------------------------------------------------------------- @@ -284,15 +282,16 @@ int DataSpace::getSimpleExtentNdims () const // num_elements = -1 when failure occurs vs. 0 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSimpleExtentNpoints () const +hssize_t +DataSpace::getSimpleExtentNpoints() const { hssize_t num_elements = H5Sget_simple_extent_npoints(id); if (num_elements > -1) - return(num_elements); - else - { + return (num_elements); + else { throw DataSpaceIException("DataSpace::getSimpleExtentNpoints", - "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace"); + "H5Sget_simple_extent_npoints returns negative value for the number of " + "elements in the dataspace"); } } @@ -303,15 +302,15 @@ hssize_t DataSpace::getSimpleExtentNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5S_class_t DataSpace::getSimpleExtentType () const +H5S_class_t +DataSpace::getSimpleExtentType() const { H5S_class_t class_name = H5Sget_simple_extent_type(id); - if (class_name == H5S_NO_CLASS) - { + if (class_name == H5S_NO_CLASS) { throw DataSpaceIException("DataSpace::getSimpleExtentType", - "H5Sget_simple_extent_type returns H5S_NO_CLASS"); + "H5Sget_simple_extent_type returns H5S_NO_CLASS"); } - return(class_name); + return (class_name); } //-------------------------------------------------------------------------- @@ -321,12 +320,12 @@ H5S_class_t DataSpace::getSimpleExtentType () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::extentCopy (const DataSpace& dest_space) const +void +DataSpace::extentCopy(const DataSpace &dest_space) const { - hid_t dest_space_id = dest_space.getId(); - herr_t ret_value = H5Sextent_copy(dest_space_id, id); - if (ret_value < 0) - { + hid_t dest_space_id = dest_space.getId(); + herr_t ret_value = H5Sextent_copy(dest_space_id, id); + if (ret_value < 0) { throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed"); } } @@ -344,7 +343,7 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataSpace::extentCopy(DataSpace& dest_space) const +// void DataSpace::extentCopy(DataSpace& dest_space) const //{ // extentCopy(dest_space); //} @@ -358,12 +357,12 @@ void DataSpace::extentCopy (const DataSpace& dest_space) const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const +void +DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size) const { herr_t ret_value; ret_value = H5Sset_extent_simple(id, rank, current_size, maximum_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed"); } } @@ -375,11 +374,11 @@ void DataSpace::setExtentSimple(int rank, const hsize_t *current_size, const hsi ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::setExtentNone () const +void +DataSpace::setExtentNone() const { herr_t ret_value = H5Sset_extent_none(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed"); } } @@ -391,15 +390,16 @@ void DataSpace::setExtentNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectNpoints () const +hssize_t +DataSpace::getSelectNpoints() const { hssize_t num_elements = H5Sget_select_npoints(id); - if (num_elements < 0) - { - throw DataSpaceIException("DataSpace::getSelectNpoints", + if (num_elements < 0) { + throw DataSpaceIException( + "DataSpace::getSelectNpoints", "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection"); } - return(num_elements); + return (num_elements); } //-------------------------------------------------------------------------- @@ -409,15 +409,16 @@ hssize_t DataSpace::getSelectNpoints () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectHyperNblocks () const +hssize_t +DataSpace::getSelectHyperNblocks() const { hssize_t num_blocks = H5Sget_select_hyper_nblocks(id); - if (num_blocks < 0) - { - throw DataSpaceIException("DataSpace::getSelectHyperNblocks", + if (num_blocks < 0) { + throw DataSpaceIException( + "DataSpace::getSelectHyperNblocks", "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks"); } - return(num_blocks); + return (num_blocks); } //-------------------------------------------------------------------------- @@ -429,14 +430,14 @@ hssize_t DataSpace::getSelectHyperNblocks () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const +void +DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_hyper_blocklist(id, startblock, numblocks, buf); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::getSelectHyperBlocklist", - "H5Sget_select_hyper_blocklist failed"); + "H5Sget_select_hyper_blocklist failed"); } } @@ -447,15 +448,14 @@ void DataSpace::getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, h ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hssize_t DataSpace::getSelectElemNpoints () const +hssize_t +DataSpace::getSelectElemNpoints() const { hssize_t num_points = H5Sget_select_elem_npoints(id); - if (num_points < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemNpoints", - "H5Sget_select_elem_npoints failed"); + if (num_points < 0) { + throw DataSpaceIException("DataSpace::getSelectElemNpoints", "H5Sget_select_elem_npoints failed"); } - return(num_points); + return (num_points); } //-------------------------------------------------------------------------- @@ -470,14 +470,13 @@ hssize_t DataSpace::getSelectElemNpoints () const /// H5Sget_select_elem_pointlist in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const +void +DataSpace::getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const { herr_t ret_value; ret_value = H5Sget_select_elem_pointlist(id, startpoint, numpoints, buf); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectElemPointlist", - "H5Sget_select_elem_pointlist failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectElemPointlist", "H5Sget_select_elem_pointlist failed"); } } @@ -493,13 +492,12 @@ void DataSpace::getSelectElemPointlist (hsize_t startpoint, hsize_t numpoints, h /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const +void +DataSpace::getSelectBounds(hsize_t *start, hsize_t *end) const { herr_t ret_value = H5Sget_select_bounds(id, start, end); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::getSelectBounds", - "H5Sget_select_bounds failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::getSelectBounds", "H5Sget_select_bounds failed"); } } @@ -518,14 +516,13 @@ void DataSpace::getSelectBounds (hsize_t* start, hsize_t* end) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const +void +DataSpace::selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const { herr_t ret_value; ret_value = H5Sselect_elements(id, op, num_elements, coord); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectElements", - "H5Sselect_elements failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectElements", "H5Sselect_elements failed"); } } @@ -536,11 +533,11 @@ void DataSpace::selectElements (H5S_seloper_t op, const size_t num_elements, con ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectAll () const +void +DataSpace::selectAll() const { herr_t ret_value = H5Sselect_all(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed"); } } @@ -552,13 +549,12 @@ void DataSpace::selectAll () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectNone () const +void +DataSpace::selectNone() const { herr_t ret_value = H5Sselect_none(id); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectNone", - "H5Sselect_none failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectNone", "H5Sselect_none failed"); } } @@ -571,17 +567,16 @@ void DataSpace::selectNone () const ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataSpace::selectValid () const +bool +DataSpace::selectValid() const { htri_t ret_value = H5Sselect_valid(id); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataSpaceIException("DataSpace::selectValid", - "H5Sselect_valid returns negative value"); + else { + throw DataSpaceIException("DataSpace::selectValid", "H5Sselect_valid returns negative value"); } } @@ -599,14 +594,14 @@ bool DataSpace::selectValid () const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride, const hsize_t *block) const +void +DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride, const hsize_t *block) const { herr_t ret_value; ret_value = H5Sselect_hyperslab(id, op, start, stride, count, block); - if (ret_value < 0) - { - throw DataSpaceIException("DataSpace::selectHyperslab", - "H5Sselect_hyperslab failed"); + if (ret_value < 0) { + throw DataSpaceIException("DataSpace::selectHyperslab", "H5Sselect_hyperslab failed"); } } @@ -622,9 +617,10 @@ void DataSpace::selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hs // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataSpace::getId() const +hid_t +DataSpace::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -640,13 +636,14 @@ hid_t DataSpace::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataSpace::p_setId(const hid_t new_id) +void +DataSpace::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -661,14 +658,13 @@ void DataSpace::p_setId(const hid_t new_id) ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSpace::close() +void +DataSpace::close() { // check if id is a valid hdf5 object id before trying to close it - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Sclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); } // reset the id @@ -690,9 +686,10 @@ DataSpace::~DataSpace() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 54c68acb701..470de74cc7c 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DataSpace_H -#define __H5DataSpace_H +#ifndef H5DataSpace_H +#define H5DataSpace_H namespace H5 { @@ -23,131 +23,136 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP DataSpace : public IdComponent { - public: - ///\brief Default DataSpace objects - static const DataSpace& ALL; + public: + ///\brief Default DataSpace objects + static const DataSpace &ALL; - // Creates a dataspace object given the space type - DataSpace(H5S_class_t type = H5S_SCALAR); + // Creates a dataspace object given the space type + DataSpace(H5S_class_t type = H5S_SCALAR); - // Creates a simple dataspace - DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); + // Creates a simple dataspace + DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims = NULL); - // Creates a DataSpace object using an existing dataspace id. - DataSpace(const hid_t space_id); + // Creates a DataSpace object using an existing dataspace id. + DataSpace(const hid_t space_id); - // Copy constructor - same as the original DataSpace. - DataSpace(const DataSpace& original); + // Copy constructor - same as the original DataSpace. + DataSpace(const DataSpace &original); - // Assignment operator - DataSpace& operator=(const DataSpace& rhs); + // Assignment operator + DataSpace &operator=(const DataSpace &rhs); - // Closes this dataspace. - virtual void close(); + // Closes this dataspace. + virtual void close() H5_OVERRIDE; - // Makes copy of an existing dataspace. - void copy(const DataSpace& like_space); + // Makes copy of an existing dataspace. + void copy(const DataSpace &like_space); - // Copies the extent of this dataspace. - void extentCopy(const DataSpace& dest_space) const; - // removed from 1.8.18 and 1.10.1 - //void extentCopy(DataSpace& dest_space) const; + // Copies the extent of this dataspace. + void extentCopy(const DataSpace &dest_space) const; + // removed from 1.8.18 and 1.10.1 + // void extentCopy(DataSpace& dest_space) const; - // Gets the bounding box containing the current selection. - void getSelectBounds(hsize_t* start, hsize_t* end) const; + // Gets the bounding box containing the current selection. + void getSelectBounds(hsize_t *start, hsize_t *end) const; - // Gets the number of element points in the current selection. - hssize_t getSelectElemNpoints() const; + // Gets the number of element points in the current selection. + hssize_t getSelectElemNpoints() const; - // Retrieves the list of element points currently selected. - void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; + // Retrieves the list of element points currently selected. + void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const; - // Gets the list of hyperslab blocks currently selected. - void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; + // Gets the list of hyperslab blocks currently selected. + void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const; - // Get number of hyperslab blocks. - hssize_t getSelectHyperNblocks() const; + // Get number of hyperslab blocks. + hssize_t getSelectHyperNblocks() const; - // Gets the number of elements in this dataspace selection. - hssize_t getSelectNpoints() const; + // Gets the number of elements in this dataspace selection. + hssize_t getSelectNpoints() const; - // Retrieves dataspace dimension size and maximum size. - int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; + // Retrieves dataspace dimension size and maximum size. + int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const; - // Gets the dimensionality of this dataspace. - int getSimpleExtentNdims() const; + // Gets the dimensionality of this dataspace. + int getSimpleExtentNdims() const; - // Gets the number of elements in this dataspace. - // 12/05/00 - changed return type to hssize_t from hsize_t - C API - hssize_t getSimpleExtentNpoints() const; + // Gets the number of elements in this dataspace. + // 12/05/00 - changed return type to hssize_t from hsize_t - C API + hssize_t getSimpleExtentNpoints() const; - // Gets the current class of this dataspace. - H5S_class_t getSimpleExtentType() const; + // Gets the current class of this dataspace. + H5S_class_t getSimpleExtentType() const; - // Determines if this dataspace is a simple one. - bool isSimple() const; + // Determines if this dataspace is a simple one. + bool isSimple() const; - // Sets the offset of this simple dataspace. - void offsetSimple(const hssize_t* offset) const; + // Sets the offset of this simple dataspace. + void offsetSimple(const hssize_t *offset) const; - // Selects the entire dataspace. - void selectAll() const; + // Selects the entire dataspace. + void selectAll() const; - // Selects array elements to be included in the selection for - // this dataspace. - void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; + // Selects array elements to be included in the selection for + // this dataspace. + void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const; - // Selects a hyperslab region to add to the current selected region. - void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, const hsize_t *stride = NULL, const hsize_t *block = NULL) const; + // Selects a hyperslab region to add to the current selected region. + void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start, + const hsize_t *stride = NULL, const hsize_t *block = NULL) const; - // Resets the selection region to include no elements. - void selectNone() const; + // Resets the selection region to include no elements. + void selectNone() const; - // Verifies that the selection is within the extent of the dataspace. - bool selectValid() const; + // Verifies that the selection is within the extent of the dataspace. + bool selectValid() const; - // Removes the extent from this dataspace. - void setExtentNone() const; + // Removes the extent from this dataspace. + void setExtentNone() const; - // Sets or resets the size of this dataspace. - void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; + // Sets or resets the size of this dataspace. + void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataSpace"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("DataSpace"); + } - // Gets the dataspace id. - virtual hid_t getId() const; + // Gets the dataspace id. + virtual hid_t getId() const H5_OVERRIDE; - // Deletes the global constant - static void deleteConstants(); + // Deletes the global constant + static void deleteConstants(); - // Destructor: properly terminates access to this dataspace. - virtual ~DataSpace(); + // Destructor: properly terminates access to this dataspace. + virtual ~DataSpace(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Sets the dataspace id. - virtual void p_setId(const hid_t new_id); + protected: + // Sets the dataspace id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 dataspace id + private: + hid_t id; // HDF5 dataspace id #ifndef DOXYGEN_SHOULD_SKIP_THIS - static DataSpace* ALL_; + static DataSpace *ALL_; - // Creates the global constant - static DataSpace* getConstant(); + // Creates the global constant + static DataSpace *getConstant(); - // Friend function to set DataSpace id. For library use only. - friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); + // Friend function to set DataSpace id. For library use only. + friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DataSpace } // namespace H5 -#endif // __H5DataSpace_H +#endif // H5DataSpace_H diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 0472975295a..3228dcbf175 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -6,16 +6,12 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include #include "H5Include.h" @@ -50,7 +46,9 @@ using std::endl; ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) {} +DataType::DataType() : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +{ +} //-------------------------------------------------------------------------- // Function: DataType overloaded constructor @@ -82,8 +80,7 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco { // Call C routine to create the new datatype id = H5Tcreate(type_class, size); - if (id < 0) - { + if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); } } @@ -99,7 +96,8 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -118,18 +116,19 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- - /* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) +/* DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : +H5Object(), id(H5I_INVALID_HID), encoded_buf(NULL), buf_size(0) { - id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); + id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } - */ +*/ //-------------------------------------------------------------------------- // Function: DataType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType(const DataType& original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) +DataType::DataType(const DataType &original) : H5Object(), id(original.id), encoded_buf(NULL), buf_size(0) { incRefCount(); // increment number of references to this id } @@ -147,7 +146,7 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id), enco // unnecessarily and will produce undefined behavior. // -BMR, Apr 2015 //-------------------------------------------------------------------------- -DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) +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()); @@ -169,7 +168,7 @@ DataType::DataType(const PredType& pred_type) : H5Object(), encoded_buf(NULL), b // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name); } @@ -188,7 +187,8 @@ DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object(), // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const H5std_string &dtype_name) + : H5Object(), encoded_buf(NULL), buf_size(0) { id = p_opentype(loc, dtype_name.c_str()); } @@ -205,13 +205,14 @@ DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Ob // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataType::copy(const DataType& like_type) +void +DataType::copy(const DataType &like_type) { // close the current data type before copying like_type to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -230,13 +231,14 @@ void DataType::copy(const DataType& like_type) ///\par Description /// The resulted dataset will be transient and modifiable. //-------------------------------------------------------------------------- -void DataType::copy(const DataSet& dset) +void +DataType::copy(const DataSet &dset) { // close the current data type before copying dset's datatype to this object try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -254,11 +256,11 @@ void DataType::copy(const DataSet& dset) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -hid_t DataType::p_decode() const +hid_t +DataType::p_decode() const { // Make sure that the buffer can be decoded - if (encoded_buf == NULL) - { + if (encoded_buf == NULL) { throw DataTypeIException("DataType::p_decode", "No encoded buffer"); } @@ -266,13 +268,11 @@ hid_t DataType::p_decode() const hid_t encoded_dtype_id = H5Tdecode(encoded_buf); // If H5Tdecode fails, raise exception - if (encoded_dtype_id < 0) - { + if (encoded_dtype_id < 0) { throw DataTypeIException("DataType::p_decode", "H5Tdecode failed"); } - else - { - return(encoded_dtype_id); + else { + return (encoded_dtype_id); } } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -285,7 +285,8 @@ hid_t DataType::p_decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* DataType::decode() const +DataType * +DataType::decode() const { hid_t encoded_dtype_id = H5I_INVALID_HID; try { @@ -296,7 +297,7 @@ DataType* DataType::decode() const } DataType *encoded_dtype = new DataType; encoded_dtype->p_setId(encoded_dtype_id); - return(encoded_dtype); + return (encoded_dtype); } //-------------------------------------------------------------------------- @@ -306,27 +307,24 @@ DataType* DataType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -void DataType::encode() +void +DataType::encode() { // Call H5Tencode passing in null to determine the size of the buffer herr_t ret_value = H5Tencode(id, NULL, &buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "Failed to get buf_size"); } // Allocate buffer and call C function again to encode - if (buf_size > 0) - { + if (buf_size > 0) { encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); - ret_value = H5Tencode(id, encoded_buf, &buf_size); - if (ret_value < 0) - { + ret_value = H5Tencode(id, encoded_buf, &buf_size); + if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); } } - else - { + else { throw DataTypeIException("DataType::encode", "Failed to allocate buffer for encoding"); } } @@ -339,7 +337,8 @@ void DataType::encode() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -bool DataType::hasBinaryDesc() const +bool +DataType::hasBinaryDesc() const { if (encoded_buf != NULL) return true; @@ -366,13 +365,13 @@ bool DataType::hasBinaryDesc() const // transient datatype. // BMR - Mar, 2015 //-------------------------------------------------------------------------- -DataType& DataType::operator=(const DataType& rhs) +DataType & +DataType::operator=(const DataType &rhs) { - if (this != &rhs) - { + if (this != &rhs) { setId(rhs.id); } - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -384,7 +383,8 @@ DataType& DataType::operator=(const DataType& rhs) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::operator==(const DataType& compared_type) const +bool +DataType::operator==(const DataType &compared_type) const { // Call C routine H5Tequal to determines whether two datatype // identifiers refer to the same datatype @@ -393,8 +393,7 @@ bool DataType::operator==(const DataType& compared_type) const return true; else if (ret_value == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); } } @@ -408,7 +407,8 @@ bool DataType::operator==(const DataType& compared_type) const ///\exception H5::DataTypeIException // July, 2018 //-------------------------------------------------------------------------- -bool DataType::operator!=(const DataType& compared_type) const +bool +DataType::operator!=(const DataType &compared_type) const { return !operator==(compared_type); } @@ -427,7 +427,8 @@ bool DataType::operator!=(const DataType& compared_type) const // to be commonly used by several overloads of DataType::commit. // BMR - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::p_commit(hid_t loc_id, const char* name) +void +DataType::p_commit(hid_t loc_id, const char *name) { // Call C routine to commit the transient datatype herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -444,7 +445,8 @@ void DataType::p_commit(hid_t loc_id, const char* name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const char* name) +void +DataType::commit(const H5Location &loc, const char *name) { p_commit(loc.getId(), name); } @@ -463,7 +465,7 @@ void DataType::commit(const H5Location& loc, const char* name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const char* name) +// void DataType::commit(H5Location& loc, const char* name) //{ // p_commit(loc.getId(), name); //} @@ -475,7 +477,8 @@ void DataType::commit(const H5Location& loc, const char* name) /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::commit(const H5Location& loc, const H5std_string& name) +void +DataType::commit(const H5Location &loc, const H5std_string &name) { p_commit(loc.getId(), name.c_str()); } @@ -494,7 +497,7 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void DataType::commit(H5Location& loc, const H5std_string& name) +// void DataType::commit(H5Location& loc, const H5std_string& name) //{ // p_commit(loc.getId(), name.c_str()); //} @@ -508,7 +511,8 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::committed() const +bool +DataType::committed() const { // Call C function to determine if a datatype is a named one htri_t is_committed = H5Tcommitted(id); @@ -516,8 +520,7 @@ bool DataType::committed() const return true; else if (is_committed == 0) return false; - else - { + else { throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); } } @@ -532,15 +535,15 @@ bool DataType::committed() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const +H5T_conv_t +DataType::find(const DataType &dest, H5T_cdata_t **pcdata) const { // Call C routine to find the conversion function H5T_conv_t func = H5Tfind(id, dest.getId(), pcdata); - if (func == NULL) - { + if (func == NULL) { throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); } - return(func); + return (func); } //-------------------------------------------------------------------------- @@ -556,17 +559,18 @@ H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist) const +void +DataType::convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist) const { // Get identifiers for C API - hid_t dest_id = dest.getId(); + hid_t dest_id = dest.getId(); hid_t plist_id = plist.getId(); // Call C routine H5Tconvert to convert the data herr_t ret_value; ret_value = H5Tconvert(id, dest_id, nelmts, buf, background, plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); } } @@ -585,12 +589,12 @@ void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *bac /// the entire library is closed. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::lock() const +void +DataType::lock() const { // Call C routine to lock the datatype herr_t ret_value = H5Tlock(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); } } @@ -602,16 +606,16 @@ void DataType::lock() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_class_t DataType::getClass() const +H5T_class_t +DataType::getClass() const { H5T_class_t type_class = H5Tget_class(id); // Return datatype class identifier if successful - if (type_class == H5T_NO_CLASS) - { + if (type_class == H5T_NO_CLASS) { throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); } - return(type_class); + return (type_class); } //-------------------------------------------------------------------------- @@ -621,15 +625,16 @@ H5T_class_t DataType::getClass() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DataType::getSize() const +size_t +DataType::getSize() const { // Call C routine to get the datatype size size_t type_size = H5Tget_size(id); - if (type_size <= 0) // valid data types are never zero size + if (type_size <= 0) // valid data types are never zero size { throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); } - return(type_size); + return (type_size); } //-------------------------------------------------------------------------- @@ -639,7 +644,8 @@ size_t DataType::getSize() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType DataType::getSuper() const +DataType +DataType::getSuper() const { // Call C routine to get the base datatype from which the specified // datatype is derived. @@ -647,14 +653,12 @@ DataType DataType::getSuper() const // If H5Tget_super returns a valid datatype id, create and return // the base type, otherwise, raise exception - if (base_type_id > 0) - { + if (base_type_id > 0) { DataType base_type; base_type.p_setId(base_type_id); - return(base_type); + return (base_type); } - else - { + else { throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); } } @@ -675,14 +679,14 @@ DataType DataType::getSuper() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the destination datatype + hid_t dest_id = dest.getId(); // get id of the destination datatype // Call C routine H5Tregister to register the conversion function herr_t ret_value = H5Tregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); } } @@ -694,7 +698,8 @@ void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& d /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { registerFunc(pers, name.c_str(), dest, func); } @@ -712,14 +717,14 @@ void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const Dat ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the dest datatype for C API + hid_t dest_id = dest.getId(); // get id of the dest datatype for C API // Call C routine H5Tunregister to remove the conversion function herr_t ret_value = H5Tunregister(pers, name, id, dest_id, func); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); } } @@ -731,7 +736,8 @@ void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& des /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const +void +DataType::unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const { unregister(pers, name.c_str(), dest, func); } @@ -744,12 +750,12 @@ void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataT ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const char* tag) const +void +DataType::setTag(const char *tag) const { // Call C routine H5Tset_tag to tag an opaque datatype. herr_t ret_value = H5Tset_tag(id, tag); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); } } @@ -761,7 +767,8 @@ void DataType::setTag(const char* tag) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag(const H5std_string& tag) const +void +DataType::setTag(const H5std_string &tag) const { setTag(tag.c_str()); } @@ -773,20 +780,19 @@ void DataType::setTag(const H5std_string& tag) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string DataType::getTag() const +H5std_string +DataType::getTag() const { - char* tag_Cstr = H5Tget_tag(id); + char *tag_Cstr = H5Tget_tag(id); // if the tag C-string returned is not NULL, convert it to C++ string // and return it, otherwise, raise an exception - if (tag_Cstr != NULL) - { + if (tag_Cstr != NULL) { H5std_string tag = H5std_string(tag_Cstr); // C string to string object - H5free_memory(tag_Cstr); // free the C string - return (tag); // return the tag + H5free_memory(tag_Cstr); // free the C string + return (tag); // return the tag } - else - { + else { throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); } } @@ -800,17 +806,16 @@ H5std_string DataType::getTag() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::detectClass(H5T_class_t cls) const +bool +DataType::detectClass(H5T_class_t cls) const { htri_t ret_value = H5Tdetect_class(id, cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException(inMemFunc("detectClass"), - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException(inMemFunc("detectClass"), "H5Tdetect_class returns negative value"); } } @@ -822,17 +827,16 @@ bool DataType::detectClass(H5T_class_t cls) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - August, 2017 //-------------------------------------------------------------------------- -bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) +bool +DataType::detectClass(const PredType &pred_type, H5T_class_t cls) { htri_t ret_value = H5Tdetect_class(pred_type.getId(), cls); if (ret_value > 0) return true; else if (ret_value == 0) return false; - else - { - throw DataTypeIException("detectClass on PredType", - "H5Tdetect_class returns negative value"); + else { + throw DataTypeIException("detectClass on PredType", "H5Tdetect_class returns negative value"); } } @@ -844,17 +848,16 @@ bool DataType::detectClass(const PredType& pred_type, H5T_class_t cls) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -bool DataType::isVariableStr() const +bool +DataType::isVariableStr() const { htri_t is_varlen_str = H5Tis_variable_str(id); if (is_varlen_str == 1) return true; else if (is_varlen_str == 0) return false; - else - { - throw DataTypeIException(inMemFunc("isVariableStr"), - "H5Tis_variable_str returns negative value"); + else { + throw DataTypeIException(inMemFunc("isVariableStr"), "H5Tis_variable_str returns negative value"); } } @@ -869,18 +872,17 @@ bool DataType::isVariableStr() const // Currently, there is no datatype creation property list class // in the C++ API because there is no associated functionality. //-------------------------------------------------------------------------- -PropList DataType::getCreatePlist() const +PropList +DataType::getCreatePlist() const { hid_t create_plist_id = H5Tget_create_plist(id); - if (create_plist_id < 0) - { - throw DataTypeIException(inMemFunc("getCreatePlist"), - "H5Tget_create_plist returns negative value"); + if (create_plist_id < 0) { + throw DataTypeIException(inMemFunc("getCreatePlist"), "H5Tget_create_plist returns negative value"); } // create and return the DSetCreatPropList object PropList create_plist; f_PropList_setId(&create_plist, create_plist_id); - return(create_plist); + return (create_plist); } //-------------------------------------------------------------------------- @@ -895,9 +897,10 @@ PropList DataType::getCreatePlist() const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t DataType::getId() const +hid_t +DataType::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -912,13 +915,14 @@ hid_t DataType::getId() const // This function was introduced in 1.10.1 to be used by the new // XxxType constructors that open a datatype. -BMR, Dec 2016 //-------------------------------------------------------------------------- -hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const +hid_t +DataType::p_opentype(const H5Location &loc, const char *dtype_name) const { // Call C function to open the named datatype at this location hid_t ret_value = H5Topen2(loc.getId(), dtype_name, H5P_DEFAULT); if (ret_value < 0) throw DataTypeIException(inMemFunc("constructor"), "H5Topen2 failed"); - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -933,13 +937,14 @@ hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::p_setId(const hid_t new_id) +void +DataType::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -954,21 +959,19 @@ void DataType::p_setId(const hid_t new_id) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataType::close() +void +DataType::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Tclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } // Reset the id id = H5I_INVALID_HID; // Free and reset buffer of encoded object description if it's been used - if (encoded_buf != NULL) - { + if (encoded_buf != NULL) { HDfree(encoded_buf); buf_size = 0; } @@ -995,13 +998,12 @@ void DataType::close() //-------------------------------------------------------------------------- DataType::~DataType() { - try - { + try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index e4d9e4b3a15..49f534859fa 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DataType_H -#define __H5DataType_H +#ifndef H5DataType_H +#define H5DataType_H namespace H5 { @@ -26,154 +26,161 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP DataType : public H5Object { - public: - // Creates a datatype given its class and size - DataType(const H5T_class_t type_class, size_t size); + public: + // Creates a datatype given its class and size + DataType(const H5T_class_t type_class, size_t size); - // Copy constructor - same as the original DataType. - DataType(const DataType& original); + // Copy constructor - same as the original DataType. + DataType(const DataType &original); - // Creates a copy of a predefined type - DataType(const PredType& pred_type); + // Creates a copy of a predefined type + DataType(const PredType &pred_type); - // Constructors to open a generic named datatype at a given location. - DataType(const H5Location& loc, const char* name); - DataType(const H5Location& loc, const H5std_string& name); + // Constructors to open a generic named datatype at a given location. + DataType(const H5Location &loc, const char *name); + DataType(const H5Location &loc, const H5std_string &name); - // Creates a datatype by way of dereference. - DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); -// DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a datatype by way of dereference. + DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const + // PropList& plist = PropList::DEFAULT); - // Closes this datatype. - virtual void close(); + // Closes this datatype. + virtual void close(); - // Copies an existing datatype to this datatype object. - void copy(const DataType& like_type); + // Copies an existing datatype to this datatype object. + void copy(const DataType &like_type); - // Copies the datatype of dset to this datatype object. - void copy(const DataSet& dset); + // Copies the datatype of dset to this datatype object. + void copy(const DataSet &dset); - // Returns a DataType instance by decoding the binary object - // description of this datatype. - virtual DataType* decode() const; + // Returns a DataType instance by decoding the binary object + // description of this datatype. + virtual DataType *decode() const; - // Creates a binary object description of this datatype. - void encode(); + // Creates a binary object description of this datatype. + void encode(); - // Returns the datatype class identifier. - H5T_class_t getClass() const; + // Returns the datatype class identifier. + H5T_class_t getClass() const; - // Commits a transient datatype to a file; this datatype becomes - // a named datatype which can be accessed from the location. - void commit(const H5Location& loc, const char* name); - void commit(const H5Location& loc, const H5std_string& name); + // Commits a transient datatype to a file; this datatype becomes + // a named datatype which can be accessed from the location. + void commit(const H5Location &loc, const char *name); + void commit(const H5Location &loc, const H5std_string &name); - // These two overloaded functions are kept for backward compatibility - // only; they missed the const - removed from 1.8.18 and 1.10.1 - //void commit(H5Location& loc, const char* name); - //void commit(H5Location& loc, const H5std_string& name); + // These two overloaded functions are kept for backward compatibility + // only; they missed the const - removed from 1.8.18 and 1.10.1 + // void commit(H5Location& loc, const char* name); + // void commit(H5Location& loc, const H5std_string& name); - // Determines whether this datatype is a named datatype or - // a transient datatype. - bool committed() const; + // Determines whether this datatype is a named datatype or + // a transient datatype. + bool committed() const; - // Finds a conversion function that can handle the conversion - // this datatype to the given datatype, dest. - H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const; + // Finds a conversion function that can handle the conversion + // this datatype to the given datatype, dest. + H5T_conv_t find(const DataType &dest, H5T_cdata_t **pcdata) const; - // Converts data from between specified datatypes. - void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const; + // Converts data from between specified datatypes. + void convert(const DataType &dest, size_t nelmts, void *buf, void *background, + const PropList &plist = PropList::DEFAULT) const; - // Assignment operator - DataType& operator=(const DataType& rhs); + // Assignment operator + DataType &operator=(const DataType &rhs); - // Determines whether two datatypes are the same. - bool operator==(const DataType& compared_type) const; + // Determines whether two datatypes are the same. + bool operator==(const DataType &compared_type) const; - // Determines whether two datatypes are not the same. - bool operator!=(const DataType& compared_type) const; + // Determines whether two datatypes are not the same. + bool operator!=(const DataType &compared_type) const; - // Locks a datatype. - void lock() const; + // Locks a datatype. + void lock() const; - // Returns the size of a datatype. - size_t getSize() const; + // Returns the size of a datatype. + size_t getSize() const; - // Returns the base datatype from which a datatype is derived. - // Note: not quite right for specific types yet??? - DataType getSuper() const; + // Returns the base datatype from which a datatype is derived. + // Note: not quite right for specific types yet??? + DataType getSuper() const; - // Registers a conversion function. - void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Registers a conversion function. + void registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Removes a conversion function from all conversion paths. - void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const; - void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const; + // Removes a conversion function from all conversion paths. + void unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const; + void unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const; - // Tags an opaque datatype. - void setTag(const char* tag) const; - void setTag(const H5std_string& tag) const; + // Tags an opaque datatype. + void setTag(const char *tag) const; + void setTag(const H5std_string &tag) const; - // Gets the tag associated with an opaque datatype. - H5std_string getTag() const; + // Gets the tag associated with an opaque datatype. + H5std_string getTag() const; - // Checks whether this datatype contains (or is) a certain type class. - bool detectClass(H5T_class_t cls) const; - static bool detectClass(const PredType& pred_type, H5T_class_t cls); + // Checks whether this datatype contains (or is) a certain type class. + bool detectClass(H5T_class_t cls) const; + static bool detectClass(const PredType &pred_type, H5T_class_t cls); - // Checks whether this datatype is a variable-length string. - bool isVariableStr() const; + // Checks whether this datatype is a variable-length string. + bool isVariableStr() const; - // Returns a copy of the creation property list of a datatype. - PropList getCreatePlist() const; + // Returns a copy of the creation property list of a datatype. + PropList getCreatePlist() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DataType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DataType"); + } - // Creates a copy of an existing DataType using its id - DataType(const hid_t type_id); + // Creates a copy of an existing DataType using its id + DataType(const hid_t type_id); - // Default constructor - DataType(); + // Default constructor + DataType(); - // Determines whether this datatype has a binary object description. - bool hasBinaryDesc() const; + // Determines whether this datatype has a binary object description. + bool hasBinaryDesc() const; - // Gets the datatype id. - virtual hid_t getId() const; + // Gets the datatype id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this datatype. - virtual ~DataType(); + // Destructor: properly terminates access to this datatype. + virtual ~DataType(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - hid_t id; // HDF5 datatype id + hid_t id; // HDF5 datatype id - // Returns an id of a type by decoding the binary object - // description of this datatype. - hid_t p_decode() const; + // Returns an id of a type by decoding the binary object + // description of this datatype. + hid_t p_decode() const; - // Sets the datatype id. - virtual void p_setId(const hid_t new_id); + // Sets the datatype id. + virtual void p_setId(const hid_t new_id); - // Opens a datatype and returns the id. - hid_t p_opentype(const H5Location& loc, const char* dtype_name) const; + // Opens a datatype and returns the id. + hid_t p_opentype(const H5Location &loc, const char *dtype_name) const; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - // Buffer for binary object description of this datatype, allocated - // in DataType::encode and used in DataType::decode - unsigned char *encoded_buf; - size_t buf_size; + private: + // Buffer for binary object description of this datatype, allocated + // in DataType::encode and used in DataType::decode + unsigned char *encoded_buf; + size_t buf_size; - // Friend function to set DataType id. For library use only. - friend void f_DataType_setId(DataType* dtype, hid_t new_id); + // Friend function to set DataType id. For library use only. + friend void f_DataType_setId(DataType *dtype, hid_t new_id); - void p_commit(hid_t loc_id, const char* name); + void p_commit(hid_t loc_id, const char *name); }; // end of DataType } // namespace H5 -#endif // __H5DataType_H +#endif // H5DataType_H diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 79ff1006ef0..4c71d5ece90 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -35,7 +35,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; +DSetCreatPropList *DSetCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetCreatPropList::getConstant @@ -49,13 +49,13 @@ DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0; // not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetCreatPropList* DSetCreatPropList::getConstant() +DSetCreatPropList * +DSetCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -64,8 +64,9 @@ DSetCreatPropList* DSetCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetCreatPropList(H5P_DATASET_CREATE); else - throw PropListIException("DSetCreatPropList::getConstant", "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("DSetCreatPropList::getConstant", + "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -74,7 +75,8 @@ DSetCreatPropList* DSetCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetCreatPropList::deleteConstants() +void +DSetCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -83,7 +85,7 @@ void DSetCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for dataset creation default property //-------------------------------------------------------------------------- -const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); +const DSetCreatPropList &DSetCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -92,7 +94,9 @@ const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} +DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList copy constructor @@ -100,7 +104,9 @@ DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} /// DSetCreatPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPropList(orig) {} +DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList &orig) : ObjCreatPropList(orig) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList overloaded constructor @@ -108,7 +114,9 @@ DSetCreatPropList::DSetCreatPropList(const DSetCreatPropList& orig) : ObjCreatPr /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) {} +DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetCreatPropList::setChunk @@ -125,11 +133,11 @@ DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(pl /// changed to \c H5D_CHUNKED, if it is not so already. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const +void +DSetCreatPropList::setChunk(int ndims, const hsize_t *dim) const { herr_t ret_value = H5Pset_chunk(id, ndims, dim); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed"); } } @@ -143,15 +151,14 @@ void DSetCreatPropList::setChunk(int ndims, const hsize_t* dim) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const +int +DSetCreatPropList::getChunk(int max_ndims, hsize_t *dim) const { int chunk_size = H5Pget_chunk(id, max_ndims, dim); - if (chunk_size < 0) - { - throw PropListIException("DSetCreatPropList::getChunk", - "H5Pget_chunk returns negative chunk size"); + if (chunk_size < 0) { + throw PropListIException("DSetCreatPropList::getChunk", "H5Pget_chunk returns negative chunk size"); } - return(chunk_size); + return (chunk_size); } //-------------------------------------------------------------------------- @@ -164,13 +171,12 @@ int DSetCreatPropList::getChunk(int max_ndims, hsize_t* dim) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setLayout(H5D_layout_t layout) const +void +DSetCreatPropList::setLayout(H5D_layout_t layout) const { herr_t ret_value = H5Pset_layout(id, layout); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setLayout", - "H5Pset_layout failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setLayout", "H5Pset_layout failed"); } } @@ -190,15 +196,14 @@ void DSetCreatPropList::setLayout(H5D_layout_t layout) const ///\par Description // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_layout_t DSetCreatPropList::getLayout() const +H5D_layout_t +DSetCreatPropList::getLayout() const { H5D_layout_t layout = H5Pget_layout(id); - if (layout == H5D_LAYOUT_ERROR) - { - throw PropListIException("DSetCreatPropList::getLayout", - "H5Pget_layout returns H5D_LAYOUT_ERROR"); + if (layout == H5D_LAYOUT_ERROR) { + throw PropListIException("DSetCreatPropList::getLayout", "H5Pget_layout returns H5D_LAYOUT_ERROR"); } - return(layout); + return (layout); } //-------------------------------------------------------------------------- @@ -213,13 +218,12 @@ H5D_layout_t DSetCreatPropList::getLayout() const /// less compression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setDeflate(int level) const +void +DSetCreatPropList::setDeflate(int level) const { herr_t ret_value = H5Pset_deflate(id, level); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setDeflate", - "H5Pset_deflate failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setDeflate", "H5Pset_deflate failed"); } } @@ -239,13 +243,12 @@ void DSetCreatPropList::setDeflate(int level) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Jan, 2007 //-------------------------------------------------------------------------- -void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const +void +DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_per_block) const { herr_t ret_value = H5Pset_szip(id, options_mask, pixels_per_block); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setSzip", - "H5Pset_szip failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setSzip", "H5Pset_szip failed"); } } @@ -261,13 +264,12 @@ void DSetCreatPropList::setSzip(unsigned int options_mask, unsigned int pixels_p /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Apr, 2016 //-------------------------------------------------------------------------- -void DSetCreatPropList::setNbit() const +void +DSetCreatPropList::setNbit() const { herr_t ret_value = H5Pset_nbit(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setNbit", - "H5Pset_nbit failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setNbit", "H5Pset_nbit failed"); } } @@ -288,13 +290,12 @@ void DSetCreatPropList::setNbit() const /// H5Pset_fill_value API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* value) const +void +DSetCreatPropList::setFillValue(const DataType &fvalue_type, const void *value) const { herr_t ret_value = H5Pset_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillValue", - "H5Pset_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillValue", "H5Pset_fill_value failed"); } } @@ -311,13 +312,12 @@ void DSetCreatPropList::setFillValue(const DataType& fvalue_type, const void* va /// specified by \a fvalue_type. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) const +void +DSetCreatPropList::getFillValue(const DataType &fvalue_type, void *value) const { herr_t ret_value = H5Pget_fill_value(id, fvalue_type.getId(), value); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillValue", - "H5Pget_fill_value failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillValue", "H5Pget_fill_value failed"); } } @@ -331,14 +331,14 @@ void DSetCreatPropList::getFillValue(const DataType& fvalue_type, void* value) c ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const +H5D_fill_value_t +DSetCreatPropList::isFillValueDefined() const { H5D_fill_value_t status; - herr_t ret_value = H5Pfill_value_defined(id, &status); - if (ret_value < 0) - { + herr_t ret_value = H5Pfill_value_defined(id, &status); + if (ret_value < 0) { throw PropListIException("DSetCreatPropList::isFillValueDefined", - "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); + "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); } else return (status); @@ -364,14 +364,13 @@ H5D_fill_value_t DSetCreatPropList::isFillValueDefined() const /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pset_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFilter", - "H5Pset_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFilter", "H5Pset_filter failed"); } } @@ -385,13 +384,12 @@ void DSetCreatPropList::setFilter(H5Z_filter_t filter_id, unsigned int flags, /// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const +void +DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const { herr_t ret_value = H5Premove_filter(id, filter_id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::removeFilter", - "H5Premove_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::removeFilter", "H5Premove_filter failed"); } } @@ -402,16 +400,16 @@ void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getNfilters() const +int +DSetCreatPropList::getNfilters() const { int num_filters = H5Pget_nfilters(id); - if (num_filters < 0) - { + if (num_filters < 0) { throw PropListIException("DSetCreatPropList::getNfilters", - "H5Pget_nfilters returned negative number of filters"); + "H5Pget_nfilters returned negative number of filters"); } else - return(num_filters); + return (num_filters); } //-------------------------------------------------------------------------- @@ -434,18 +432,18 @@ int DSetCreatPropList::getNfilters() const // of unsigned int, but for backward compatibility, it cannot be // changed. -BMR (2014/04/15) //-------------------------------------------------------------------------- -H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int& filter_config) const +H5Z_filter_t +DSetCreatPropList::getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { H5Z_filter_t filter_id; - filter_id = H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + filter_id = + H5Pget_filter2(id, filter_number, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (filter_id == H5Z_FILTER_ERROR) - throw PropListIException("DSetCreatPropList::getFilter", - "H5Pget_filter2 returned H5Z_FILTER_ERROR"); + throw PropListIException("DSetCreatPropList::getFilter", "H5Pget_filter2 returned H5Z_FILTER_ERROR"); else - return(filter_id); + return (filter_id); } //-------------------------------------------------------------------------- @@ -463,15 +461,15 @@ H5Z_filter_t DSetCreatPropList::getFilter(int filter_number, ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, - unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, - size_t namelen, char name[], unsigned int &filter_config) const +void +DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const { - herr_t ret_value = H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, - cd_values, namelen, name, &filter_config); + herr_t ret_value = + H5Pget_filter_by_id2(id, filter_id, &flags, &cd_nelmts, cd_values, namelen, name, &filter_config); if (ret_value < 0) - throw PropListIException("DSetCreatPropList::getFilterById", - "H5Pget_filter_by_id2 failed"); + throw PropListIException("DSetCreatPropList::getFilterById", "H5Pget_filter_by_id2 failed"); } //-------------------------------------------------------------------------- @@ -495,14 +493,13 @@ void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, /// and the filter fails then the entire I/O operation fails. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int - flags, size_t cd_nelmts, const unsigned int cd_values[]) const +void +DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const { herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::modifyFilter", - "H5Pmodify_filter failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::modifyFilter", "H5Pmodify_filter failed"); } } @@ -515,7 +512,8 @@ void DSetCreatPropList::modifyFilter(H5Z_filter_t filter_id, unsigned int ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetCreatPropList::allFiltersAvail() const +bool +DSetCreatPropList::allFiltersAvail() const { htri_t ret_value = H5Pall_filters_avail(id); if (ret_value > 0) @@ -524,7 +522,8 @@ bool DSetCreatPropList::allFiltersAvail() const return false; else // Raise exception when H5Pall_filters_avail returns a negative value { - throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); + throw PropListIException("DSetCreatPropList::allFiltersAvail", + "H5Pall_filters_avail returned negative value"); } } @@ -538,13 +537,12 @@ bool DSetCreatPropList::allFiltersAvail() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setShuffle() const +void +DSetCreatPropList::setShuffle() const { herr_t ret_value = H5Pset_shuffle(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setShuffle", - "H5Pset_shuffle failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setShuffle", "H5Pset_shuffle failed"); } } @@ -562,14 +560,13 @@ void DSetCreatPropList::setShuffle() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_alloc_time_t DSetCreatPropList::getAllocTime() const +H5D_alloc_time_t +DSetCreatPropList::getAllocTime() const { H5D_alloc_time_t alloc_time; - herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getAllocTime", - "H5Pget_alloc_time failed"); + herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getAllocTime", "H5Pget_alloc_time failed"); } else return (alloc_time); @@ -586,14 +583,13 @@ H5D_alloc_time_t DSetCreatPropList::getAllocTime() const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5D_fill_time_t DSetCreatPropList::getFillTime() const +H5D_fill_time_t +DSetCreatPropList::getFillTime() const { H5D_fill_time_t fill_time; - herr_t ret_value = H5Pget_fill_time(id, &fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getFillTime", - "H5Pget_fill_time failed"); + herr_t ret_value = H5Pget_fill_time(id, &fill_time); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getFillTime", "H5Pget_fill_time failed"); } else return (fill_time); @@ -612,13 +608,12 @@ H5D_fill_time_t DSetCreatPropList::getFillTime() const /// \li \c H5D_ALLOC_TIME_INCR // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const +void +DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const { herr_t ret_value = H5Pset_alloc_time(id, alloc_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setAllocTime", - "H5Pset_alloc_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setAllocTime", "H5Pset_alloc_time failed"); } } @@ -633,13 +628,12 @@ void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) const /// \li \c H5D_FILL_TIME_ALLOC. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const +void +DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const { herr_t ret_value = H5Pset_fill_time(id, fill_time); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFillTime", - "H5Pset_fill_time failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFillTime", "H5Pset_fill_time failed"); } } @@ -650,13 +644,12 @@ void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setFletcher32() const +void +DSetCreatPropList::setFletcher32() const { herr_t ret_value = H5Pset_fletcher32(id); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setFletcher32", - "H5Pset_fletcher32 failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setFletcher32", "H5Pset_fletcher32 failed"); } } @@ -676,13 +669,12 @@ void DSetCreatPropList::setFletcher32() const /// the extending). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size) const +void +DSetCreatPropList::setExternal(const char *name, off_t offset, hsize_t size) const { herr_t ret_value = H5Pset_external(id, name, offset, size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setExternal", - "H5Pset_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setExternal", "H5Pset_external failed"); } } @@ -693,16 +685,16 @@ void DSetCreatPropList::setExternal(const char* name, off_t offset, hsize_t size ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int DSetCreatPropList::getExternalCount() const +int +DSetCreatPropList::getExternalCount() const { int num_ext_files = H5Pget_external_count(id); - if (num_ext_files < 0) - { + if (num_ext_files < 0) { throw PropListIException("DSetCreatPropList::getExternalCount", - "H5Pget_external_count returns negative number of external files"); + "H5Pget_external_count returns negative number of external files"); } else - return(num_ext_files); + return (num_ext_files); } //-------------------------------------------------------------------------- @@ -727,13 +719,12 @@ int DSetCreatPropList::getExternalCount() const /// will not be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const +void +DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const { herr_t ret_value = H5Pget_external(id, idx, name_size, name, &offset, &size); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::getExternal", - "H5Pget_external failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::getExternal", "H5Pget_external failed"); } } @@ -755,13 +746,13 @@ void DSetCreatPropList::getExternal(unsigned idx, size_t name_size, char* name, /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const { herr_t ret_value = H5Pset_virtual(id, vspace.getId(), src_fname, src_dsname, sspace.getId()); - if (ret_value < 0) - { - throw PropListIException("DSetCreatPropList::setVirtual", - "H5Pset_virtual failed"); + if (ret_value < 0) { + throw PropListIException("DSetCreatPropList::setVirtual", "H5Pset_virtual failed"); } } @@ -783,7 +774,9 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const char *src_fnam /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Mar, 2017 //-------------------------------------------------------------------------- -void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const +void +DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string src_fname, + const H5std_string src_dsname, const DataSpace &sspace) const { setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace); } @@ -793,6 +786,8 @@ void DSetCreatPropList::setVirtual(const DataSpace& vspace, const H5std_string s ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::~DSetCreatPropList() {} +DSetCreatPropList::~DSetCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 9f54e8dc10a..3c032ee5c6d 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DSCreatPropList_H -#define __H5DSCreatPropList_H +#ifndef H5DSCreatPropList_H +#define H5DSCreatPropList_H namespace H5 { @@ -27,125 +27,136 @@ class DataSpace; */ // Inheritance: ObjCreatPropList -> PropList -> IdComponent class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { - public: - ///\brief Default dataset creation property list. - static const DSetCreatPropList& DEFAULT; + public: + ///\brief Default dataset creation property list. + static const DSetCreatPropList &DEFAULT; - // Creates a dataset creation property list. - DSetCreatPropList(); + // Creates a dataset creation property list. + DSetCreatPropList(); - // Queries whether all the filters set in this property list are - // available currently. - bool allFiltersAvail() const; + // Queries whether all the filters set in this property list are + // available currently. + bool allFiltersAvail() const; - // Get space allocation time for this property. - H5D_alloc_time_t getAllocTime() const; + // Get space allocation time for this property. + H5D_alloc_time_t getAllocTime() const; - // Set space allocation time for dataset during creation. - void setAllocTime(H5D_alloc_time_t alloc_time) const; + // Set space allocation time for dataset during creation. + void setAllocTime(H5D_alloc_time_t alloc_time) const; - // Retrieves the size of the chunks used to store a chunked layout dataset. - int getChunk(int max_ndims, hsize_t* dim) const; + // Retrieves the size of the chunks used to store a chunked layout dataset. + int getChunk(int max_ndims, hsize_t *dim) const; - // Sets the size of the chunks used to store a chunked layout dataset. - void setChunk(int ndims, const hsize_t* dim) const; + // Sets the size of the chunks used to store a chunked layout dataset. + void setChunk(int ndims, const hsize_t *dim) const; - // Returns information about an external file. - void getExternal(unsigned idx, size_t name_size, char* name, off_t& offset, hsize_t& size) const; + // Returns information about an external file. + void getExternal(unsigned idx, size_t name_size, char *name, off_t &offset, hsize_t &size) const; - // Returns the number of external files for a dataset. - int getExternalCount() const; + // Returns the number of external files for a dataset. + int getExternalCount() const; - // Gets fill value writing time. - H5D_fill_time_t getFillTime() const; + // Gets fill value writing time. + H5D_fill_time_t getFillTime() const; - // Sets fill value writing time for dataset. - void setFillTime(H5D_fill_time_t fill_time) const; + // Sets fill value writing time for dataset. + void setFillTime(H5D_fill_time_t fill_time) const; - // Retrieves a dataset fill value. - void getFillValue(const DataType& fvalue_type, void* value) const; + // Retrieves a dataset fill value. + void getFillValue(const DataType &fvalue_type, void *value) const; - // Sets a dataset fill value. - void setFillValue(const DataType& fvalue_type, const void* value) const; + // Sets a dataset fill value. + void setFillValue(const DataType &fvalue_type, const void *value) const; - // Returns information about a filter in a pipeline. - H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline. + H5Z_filter_t getFilter(int filter_number, unsigned int &flags, size_t &cd_nelmts, unsigned int *cd_values, + size_t namelen, char name[], unsigned int &filter_config) const; - // Returns information about a filter in a pipeline given the filter id. - void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[], unsigned int &filter_config) const; + // Returns information about a filter in a pipeline given the filter id. + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, + unsigned int *cd_values, size_t namelen, char name[], + unsigned int &filter_config) const; - // Gets the layout of the raw data storage of the data that uses this - // property list. - H5D_layout_t getLayout() const; + // Gets the layout of the raw data storage of the data that uses this + // property list. + H5D_layout_t getLayout() const; - // Sets the type of storage used to store the raw data for the - // dataset that uses this property list. - void setLayout(H5D_layout_t layout) const; + // Sets the type of storage used to store the raw data for the + // dataset that uses this property list. + void setLayout(H5D_layout_t layout) const; - // Returns the number of filters in the pipeline. - int getNfilters() const; + // Returns the number of filters in the pipeline. + int getNfilters() const; - // Checks if fill value has been defined for this property. - H5D_fill_value_t isFillValueDefined() const; + // Checks if fill value has been defined for this property. + H5D_fill_value_t isFillValueDefined() const; - // Modifies the specified filter. - void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[]) const; + // Modifies the specified filter. + void modifyFilter(H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[]) const; - // Remove one or all filters from the filter pipeline. - void removeFilter(H5Z_filter_t filter_id) const; + // Remove one or all filters from the filter pipeline. + void removeFilter(H5Z_filter_t filter_id) const; - // Sets compression method and compression level. - void setDeflate(int level) const; + // Sets compression method and compression level. + void setDeflate(int level) const; - // Adds an external file to the list of external files. - void setExternal(const char* name, off_t offset, hsize_t size) const; + // Adds an external file to the list of external files. + void setExternal(const char *name, off_t offset, hsize_t size) const; - // Adds a filter to the filter pipeline. - void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, const unsigned int cd_values[] = NULL) const; + // Adds a filter to the filter pipeline. + void setFilter(H5Z_filter_t filter, unsigned int flags = 0, size_t cd_nelmts = 0, + const unsigned int cd_values[] = NULL) const; - // Sets Fletcher32 checksum of EDC for this property list. - void setFletcher32() const; + // Sets Fletcher32 checksum of EDC for this property list. + void setFletcher32() const; - // Sets method of the shuffle filter. - void setShuffle() const; + // Sets method of the shuffle filter. + void setShuffle() const; - // Sets SZIP compression method. - void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; + // Sets SZIP compression method. + void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; - // Sets N-bit compression method. - void setNbit() const; + // Sets N-bit compression method. + void setNbit() const; - // Maps elements of a virtual dataset to elements of the source dataset. - void setVirtual(const DataSpace& vspace, const char *src_fname, const char *src_dsname, const DataSpace& sspace) const; - void setVirtual(const DataSpace& vspace, const H5std_string src_fname, const H5std_string src_dsname, const DataSpace& sspace) const; + // Maps elements of a virtual dataset to elements of the source dataset. + void setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname, + const DataSpace &sspace) const; + void setVirtual(const DataSpace &vspace, const H5std_string src_fname, const H5std_string src_dsname, + const DataSpace &sspace) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetCreatPropList"); + } - // Copy constructor - same as the original DSetCreatPropList. - DSetCreatPropList(const DSetCreatPropList& orig); + // Copy constructor - same as the original DSetCreatPropList. + DSetCreatPropList(const DSetCreatPropList &orig); - // Creates a copy of an existing dataset creation property list - // using the property list id. - DSetCreatPropList(const hid_t plist_id); + // Creates a copy of an existing dataset creation property list + // using the property list id. + DSetCreatPropList(const hid_t plist_id); - // Noop destructor. - virtual ~DSetCreatPropList(); + // Noop destructor. + virtual ~DSetCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetCreatPropList* DEFAULT_; + private: + static DSetCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetCreatPropList } // namespace H5 -#endif // __H5DSCreatPropList_H +#endif // H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 9cc6961de33..2b50de42333 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -6,14 +6,14 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -28,7 +28,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; +DSetMemXferPropList *DSetMemXferPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::getConstant @@ -42,13 +42,13 @@ DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -DSetMemXferPropList* DSetMemXferPropList::getConstant() +DSetMemXferPropList * +DSetMemXferPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -57,8 +57,10 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new DSetMemXferPropList(H5P_DATASET_XFER); else - throw PropListIException("DSetMemXferPropList::getConstant", "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException( + "DSetMemXferPropList::getConstant", + "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -67,7 +69,8 @@ DSetMemXferPropList* DSetMemXferPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void DSetMemXferPropList::deleteConstants() +void +DSetMemXferPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -76,7 +79,7 @@ void DSetMemXferPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default dataset memory and transfer property list. //-------------------------------------------------------------------------- -const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); +const DSetMemXferPropList &DSetMemXferPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -86,7 +89,9 @@ const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant(); /// transfer property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} +DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList constructor @@ -94,7 +99,7 @@ DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} /// expression. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET_XFER) +DSetMemXferPropList::DSetMemXferPropList(const char *exp) : PropList(H5P_DATASET_XFER) { setDataTransform(exp); } @@ -107,7 +112,9 @@ DSetMemXferPropList::DSetMemXferPropList(const char* exp) : PropList(H5P_DATASET /// list object to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : PropList(original ) {} +DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function DSetMemXferPropList overloaded constructor @@ -117,7 +124,9 @@ DSetMemXferPropList::DSetMemXferPropList(const DSetMemXferPropList& original) : /// property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) {} +DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: DSetMemXferPropList::setBuffer @@ -128,13 +137,12 @@ DSetMemXferPropList::DSetMemXferPropList(const hid_t plist_id) : PropList(plist_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const +void +DSetMemXferPropList::setBuffer(size_t size, void *tconv, void *bkg) const { herr_t ret_value = H5Pset_buffer(id, size, tconv, bkg); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBuffer", - "H5Pset_buffer failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBuffer", "H5Pset_buffer failed"); } } @@ -147,15 +155,15 @@ void DSetMemXferPropList::setBuffer(size_t size, void* tconv, void* bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const +size_t +DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const { size_t buffer_size = H5Pget_buffer(id, tconv, bkg); - if(buffer_size == 0) - { + if (buffer_size == 0) { throw PropListIException("DSetMemXferPropList::getBuffer", - "H5Pget_buffer returned 0 for buffer size - failure"); + "H5Pget_buffer returned 0 for buffer size - failure"); } - return(buffer_size); + return (buffer_size); } //-------------------------------------------------------------------------- @@ -165,13 +173,12 @@ size_t DSetMemXferPropList::getBuffer(void** tconv, void** bkg) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setPreserve(bool status) const +void +DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t) status); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setPreserve", - "H5Pset_preserve failed"); + herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } } @@ -182,17 +189,17 @@ void DSetMemXferPropList::setPreserve(bool status) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DSetMemXferPropList::getPreserve() const +bool +DSetMemXferPropList::getPreserve() const { int ret_value = H5Pget_preserve(id); - if(ret_value > 0) + if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; - else - { + else { throw PropListIException("DSetMemXferPropList::getPreserve", - "H5Pget_preserve returned negative value for status"); + "H5Pget_preserve returned negative value for status"); } } @@ -205,13 +212,12 @@ bool DSetMemXferPropList::getPreserve() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const +void +DSetMemXferPropList::setBtreeRatios(double left, double middle, double right) const { herr_t ret_value = H5Pset_btree_ratios(id, left, middle, right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setBtreeRatios", - "H5Pset_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setBtreeRatios", "H5Pset_btree_ratios failed"); } } @@ -224,13 +230,12 @@ void DSetMemXferPropList::setBtreeRatios(double left, double middle, double righ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& right) const +void +DSetMemXferPropList::getBtreeRatios(double &left, double &middle, double &right) const { herr_t ret_value = H5Pget_btree_ratios(id, &left, &middle, &right); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getBtreeRatios", - "H5Pget_btree_ratios failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getBtreeRatios", "H5Pget_btree_ratios failed"); } } @@ -241,13 +246,12 @@ void DSetMemXferPropList::getBtreeRatios(double& left, double& middle, double& r ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const char* expression) const +void +DSetMemXferPropList::setDataTransform(const char *expression) const { herr_t ret_value = H5Pset_data_transform(id, expression); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setDataTransform", - "H5Pset_data_transform failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setDataTransform", "H5Pset_data_transform failed"); } } @@ -259,7 +263,8 @@ void DSetMemXferPropList::setDataTransform(const char* expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const +void +DSetMemXferPropList::setDataTransform(const H5std_string &expression) const { setDataTransform(expression.c_str()); } @@ -273,7 +278,8 @@ void DSetMemXferPropList::setDataTransform(const H5std_string& expression) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const +ssize_t +DSetMemXferPropList::getDataTransform(char *exp, size_t buf_size) const { // H5Pget_data_transform will get buf_size characters of the expression // including the null terminator @@ -281,10 +287,8 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const exp_len = H5Pget_data_transform(id, exp, buf_size); // H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { - throw PropListIException("DSetMemXferPropList::getDataTransform", - "H5Pget_data_transform failed"); + if (exp_len < 0) { + throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // H5Pget_data_transform will put a null terminator at the end of the @@ -292,7 +296,7 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const // of the buffer. // Return the expression length, which might be different from buf_size - return(exp_len); + return (exp_len); } //-------------------------------------------------------------------------- @@ -303,39 +307,38 @@ ssize_t DSetMemXferPropList::getDataTransform(char* exp, size_t buf_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string DSetMemXferPropList::getDataTransform() const +H5std_string +DSetMemXferPropList::getDataTransform() const { // Initialize string to "", so that if there is no expression, the returned // string will be empty - H5std_string expression(""); + H5std_string expression; // Preliminary call to get the expression's length ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); // If H5Pget_data_transform returns a negative value, raise an exception - if (exp_len < 0) - { + if (exp_len < 0) { throw PropListIException("DSetMemXferPropList::getDataTransform", "H5Pget_data_transform failed"); } // If expression exists, calls C routine again to get it - else if (exp_len > 0) - { + 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 + char *exp_C = new char[exp_len + 1]; + HDmemset(exp_C, 0, exp_len + 1); // clear buffer // Used overloaded function - exp_len = getDataTransform(exp_C, exp_len+1); + exp_len = getDataTransform(exp_C, exp_len + 1); // Convert the C expression to return expression = exp_C; // Clean up resource - delete []exp_C; + delete[] exp_C; } // Return the string expression - return(expression); + return (expression); } //-------------------------------------------------------------------------- @@ -347,13 +350,12 @@ H5std_string DSetMemXferPropList::getDataTransform() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const +void +DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const { herr_t ret_value = H5Pset_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setTypeConvCB", - "H5Pset_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setTypeConvCB", "H5Pset_type_conv_cb failed"); } } @@ -365,13 +367,12 @@ void DSetMemXferPropList::setTypeConvCB(H5T_conv_except_func_t op, void *user_da ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const +void +DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const { herr_t ret_value = H5Pget_type_conv_cb(id, op, user_data); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getTypeConvCB", - "H5Pget_type_conv_cb failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getTypeConvCB", "H5Pget_type_conv_cb failed"); } } @@ -385,14 +386,13 @@ void DSetMemXferPropList::getTypeConvCB(H5T_conv_except_func_t *op, void **user_ ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info) const +void +DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info) const { - herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, - free_func, free_info); - if(ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setVlenMemManager", - "H5Pset_vlen_mem_manager failed"); + herr_t ret_value = H5Pset_vlen_mem_manager(id, alloc_func, alloc_info, free_func, free_info); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setVlenMemManager", "H5Pset_vlen_mem_manager failed"); } } @@ -404,9 +404,10 @@ void DSetMemXferPropList::setVlenMemManager(H5MM_allocate_t alloc_func, void* al ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setVlenMemManager() const +void +DSetMemXferPropList::setVlenMemManager() const { - setVlenMemManager(NULL, NULL, NULL, NULL); + setVlenMemManager(NULL, NULL, NULL, NULL); } //-------------------------------------------------------------------------- @@ -419,13 +420,13 @@ void DSetMemXferPropList::setVlenMemManager() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info) const +void +DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t &alloc_func, void **alloc_info, H5MM_free_t &free_func, + void **free_info) const { herr_t ret_value = H5Pget_vlen_mem_manager(id, &alloc_func, alloc_info, &free_func, free_info); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::getVlenMemManager", - "H5Pget_vlen_mem_manager failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::getVlenMemManager", "H5Pget_vlen_mem_manager failed"); } } @@ -439,13 +440,13 @@ void DSetMemXferPropList::getVlenMemManager(H5MM_allocate_t& alloc_func, void** /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const +void +DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const { herr_t ret_value = H5Pset_small_data_block_size(id, size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", - "H5Pset_small_data_block_size failed"); + "H5Pset_small_data_block_size failed"); } } @@ -456,16 +457,16 @@ void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t DSetMemXferPropList::getSmallDataBlockSize() const +hsize_t +DSetMemXferPropList::getSmallDataBlockSize() const { hsize_t size; - herr_t ret_value = H5Pget_small_data_block_size(id, &size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_small_data_block_size(id, &size); + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", - "H5Pget_small_data_block_size failed"); + "H5Pget_small_data_block_size failed"); } - return(size); + return (size); } //-------------------------------------------------------------------------- @@ -478,13 +479,13 @@ hsize_t DSetMemXferPropList::getSmallDataBlockSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const +void +DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const { herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setHyperVectorSize", - "H5Pset_hyper_vector_size failed"); + "H5Pset_hyper_vector_size failed"); } } @@ -496,16 +497,16 @@ void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t DSetMemXferPropList::getHyperVectorSize() const +size_t +DSetMemXferPropList::getHyperVectorSize() const { size_t vector_size; herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::getHyperVectorSize", - "H5Pget_hyper_vector_size failed"); + "H5Pget_hyper_vector_size failed"); } - return(vector_size); + return (vector_size); } //-------------------------------------------------------------------------- @@ -526,13 +527,12 @@ size_t DSetMemXferPropList::getHyperVectorSize() const /// \li \c H5Z_DISABLE_EDC // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const +void +DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const { herr_t ret_value = H5Pset_edc_check(id, check); - if (ret_value < 0) - { - throw PropListIException("DSetMemXferPropList::setEDCCheck", - "H5Pset_edc_check failed"); + if (ret_value < 0) { + throw PropListIException("DSetMemXferPropList::setEDCCheck", "H5Pset_edc_check failed"); } } @@ -543,15 +543,14 @@ void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const +H5Z_EDC_t +DSetMemXferPropList::getEDCCheck() const { H5Z_EDC_t check = H5Pget_edc_check(id); - if (check < 0) - { - throw PropListIException("DSetMemXferPropList::getEDCCheck", - "H5Pget_edc_check failed"); + if (check < 0) { + throw PropListIException("DSetMemXferPropList::getEDCCheck", "H5Pget_edc_check failed"); } - return(check); + return (check); } //-------------------------------------------------------------------------- @@ -559,7 +558,8 @@ H5Z_EDC_t DSetMemXferPropList::getEDCCheck() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetMemXferPropList::~DSetMemXferPropList() {} - -} // end namespace +DSetMemXferPropList::~DSetMemXferPropList() +{ +} +} // namespace H5 diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 69557788cfa..1e4d66824f8 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5DSetMemXferPropList_H -#define __H5DSetMemXferPropList_H +#ifndef H5DSetMemXferPropList_H +#define H5DSetMemXferPropList_H namespace H5 { @@ -23,109 +23,112 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP DSetMemXferPropList : public PropList { - public: - ///\brief Default dataset memory and transfer property list. - static const DSetMemXferPropList& DEFAULT; + public: + ///\brief Default dataset memory and transfer property list. + static const DSetMemXferPropList &DEFAULT; - // Creates a dataset memory and transfer property list. - DSetMemXferPropList(); + // Creates a dataset memory and transfer property list. + DSetMemXferPropList(); - // Creates a dataset transform property list. - DSetMemXferPropList(const char* expression); + // Creates a dataset transform property list. + DSetMemXferPropList(const char *expression); - // Sets type conversion and background buffers. - void setBuffer(size_t size, void* tconv, void* bkg) const; + // Sets type conversion and background buffers. + void setBuffer(size_t size, void *tconv, void *bkg) const; - // Reads buffer settings. - size_t getBuffer(void** tconv, void** bkg) const; + // Reads buffer settings. + size_t getBuffer(void **tconv, void **bkg) const; - // Sets B-tree split ratios for a dataset transfer property list. - void setBtreeRatios(double left, double middle, double right) const; + // Sets B-tree split ratios for a dataset transfer property list. + void setBtreeRatios(double left, double middle, double right) const; - // Gets B-tree split ratios for a dataset transfer property list. - void getBtreeRatios(double& left, double& middle, double& right) const; + // Gets B-tree split ratios for a dataset transfer property list. + void getBtreeRatios(double &left, double &middle, double &right) const; - // Sets data transform expression. - void setDataTransform(const char* expression) const; - void setDataTransform(const H5std_string& expression) const; + // Sets data transform expression. + void setDataTransform(const char *expression) const; + void setDataTransform(const H5std_string &expression) const; - // Gets data transform expression. - ssize_t getDataTransform(char* exp, size_t buf_size=0) const; - H5std_string getDataTransform() const; + // Gets data transform expression. + ssize_t getDataTransform(char *exp, size_t buf_size = 0) const; + H5std_string getDataTransform() const; - // Sets the dataset transfer property list status to TRUE or FALSE. - void setPreserve(bool status) const; + // Sets the dataset transfer property list status to TRUE or FALSE. + void setPreserve(bool status) const; - // Checks status of the dataset transfer property list. - bool getPreserve() const; + // Checks status of the dataset transfer property list. + bool getPreserve() const; - // Sets an exception handling callback for datatype conversion. - void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; + // Sets an exception handling callback for datatype conversion. + void setTypeConvCB(H5T_conv_except_func_t op, void *user_data) const; - // Gets the exception handling callback for datatype conversion. - void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; + // Gets the exception handling callback for datatype conversion. + void getTypeConvCB(H5T_conv_except_func_t *op, void **user_data) const; - // Sets the memory manager for variable-length datatype - // allocation in H5Dread and H5Dvlen_reclaim. - void setVlenMemManager(H5MM_allocate_t alloc, void* alloc_info, - H5MM_free_t free, void* free_info) const; + // Sets the memory manager for variable-length datatype + // allocation in H5Dread and H5Treclaim. + void setVlenMemManager(H5MM_allocate_t alloc, void *alloc_info, H5MM_free_t free, void *free_info) const; - // alloc and free are set to NULL, indicating that system - // malloc and free are to be used. - void setVlenMemManager() const; + // alloc and free are set to NULL, indicating that system + // malloc and free are to be used. + void setVlenMemManager() const; - // Gets the memory manager for variable-length datatype - // allocation in H5Dread and H5Tvlen_reclaim. - void getVlenMemManager(H5MM_allocate_t& alloc, void** alloc_info, - H5MM_free_t& free, void** free_info) const; + // Gets the memory manager for variable-length datatype + // allocation in H5Dread and H5Treclaim. + void getVlenMemManager(H5MM_allocate_t &alloc, void **alloc_info, H5MM_free_t &free, + void **free_info) const; - // Sets the size of a contiguous block reserved for small data. - void setSmallDataBlockSize(hsize_t size) const; + // Sets the size of a contiguous block reserved for small data. + void setSmallDataBlockSize(hsize_t size) const; - // Returns the current small data block size setting. - hsize_t getSmallDataBlockSize() const; + // Returns the current small data block size setting. + hsize_t getSmallDataBlockSize() const; - // Sets number of I/O vectors to be read/written in hyperslab I/O. - void setHyperVectorSize(size_t vector_size) const; + // Sets number of I/O vectors to be read/written in hyperslab I/O. + void setHyperVectorSize(size_t vector_size) const; - // Returns the number of I/O vectors to be read/written in - // hyperslab I/O. - size_t getHyperVectorSize() const; + // Returns the number of I/O vectors to be read/written in + // hyperslab I/O. + size_t getHyperVectorSize() const; - // Enables or disables error-detecting for a dataset reading - // process. - void setEDCCheck(H5Z_EDC_t check) const; + // Enables or disables error-detecting for a dataset reading + // process. + void setEDCCheck(H5Z_EDC_t check) const; - // Determines whether error-detection is enabled for dataset reads. - H5Z_EDC_t getEDCCheck() const; + // Determines whether error-detection is enabled for dataset reads. + H5Z_EDC_t getEDCCheck() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("DSetMemXferPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("DSetMemXferPropList"); + } - // Copy constructor - same as the original DSetMemXferPropList. - DSetMemXferPropList(const DSetMemXferPropList& orig); + // Copy constructor - same as the original DSetMemXferPropList. + DSetMemXferPropList(const DSetMemXferPropList &orig); - // Creates a copy of an existing dataset memory and transfer - // property list using the property list id. - DSetMemXferPropList(const hid_t plist_id); + // Creates a copy of an existing dataset memory and transfer + // property list using the property list id. + DSetMemXferPropList(const hid_t plist_id); - // Noop destructor - virtual ~DSetMemXferPropList(); + // Noop destructor + virtual ~DSetMemXferPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static DSetMemXferPropList* DEFAULT_; + private: + static DSetMemXferPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static DSetMemXferPropList* getConstant(); + // Creates the global constant, should only be used by the library + static DSetMemXferPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of DSetMemXferPropList } // namespace H5 -#endif // __H5DSetMemXferPropList_H +#endif // H5DSetMemXferPropList_H diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index f9adc47f774..6c7b53384f5 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -6,14 +6,14 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -41,7 +41,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType() : DataType() {} +EnumType::EnumType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -50,14 +52,18 @@ EnumType::EnumType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const hid_t existing_id) : DataType( existing_id ) {} +EnumType::EnumType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: EnumType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const EnumType& original) : DataType( original ) {} +EnumType::EnumType(const EnumType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -69,7 +75,9 @@ EnumType::EnumType(const EnumType& original) : DataType( original ) {} // the enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} +EnumType::EnumType(size_t size) : DataType(H5T_ENUM, size) +{ +} //-------------------------------------------------------------------------- // Function: EnumType overloaded constructor @@ -78,14 +86,13 @@ EnumType::EnumType(size_t size) : DataType( H5T_ENUM, size ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const DataSet& dataset) : DataType() +EnumType::EnumType(const DataSet &dataset) : DataType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Dget_type failed"); } } @@ -97,14 +104,13 @@ EnumType::EnumType(const DataSet& dataset) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::EnumType(const IntType& data_type) : DataType() +EnumType::EnumType(const IntType &data_type) : DataType() { // Calls C function H5Tenum_create to get the id of the datatype id = H5Tenum_create(data_type.getId()); // If the datatype id is not valid, throw an exception - if (id < 0) - { + if (id < 0) { throw DataSetIException("EnumType constructor", "H5Tenum_create failed"); } } @@ -123,7 +129,7 @@ EnumType::EnumType(const IntType& data_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -142,7 +148,7 @@ EnumType::EnumType(const H5Location& loc, const char *dtype_name) : DataType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +EnumType::EnumType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -155,7 +161,8 @@ EnumType::EnumType(const H5Location& loc, const H5std_string& dtype_name) : Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* EnumType::decode() const +DataType * +EnumType::decode() const { hid_t encoded_enumtype_id = H5I_INVALID_HID; try { @@ -166,7 +173,7 @@ DataType* EnumType::decode() const } EnumType *encoded_enumtype = new EnumType; encoded_enumtype->p_setId(encoded_enumtype_id); - return(encoded_enumtype); + return (encoded_enumtype); } //-------------------------------------------------------------------------- @@ -177,12 +184,12 @@ DataType* EnumType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const char* name, void *value) const +void +EnumType::insert(const char *name, void *value) const { // Calls C routine H5Tenum_insert to insert the new enum datatype member. herr_t ret_value = H5Tenum_insert(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed"); } } @@ -194,7 +201,8 @@ void EnumType::insert(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::insert(const H5std_string& name, void *value) const +void +EnumType::insert(const H5std_string &name, void *value) const { insert(name.c_str(), value); } @@ -208,24 +216,24 @@ void EnumType::insert(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string EnumType::nameOf(void *value, size_t size) const +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 + char *name_C = new char[size + 1]; // temporary C-string for C API + HDmemset(name_C, 0, size + 1); // clear buffer // 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); // If H5Tenum_nameof returns a negative value, raise an exception, - if (ret_value < 0) - { - delete []name_C; + if (ret_value < 0) { + delete[] name_C; throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); } // otherwise, create the string to hold the datatype name and return it H5std_string name(name_C); - delete []name_C; - return(name); + delete[] name_C; + return (name); } //-------------------------------------------------------------------------- @@ -237,12 +245,12 @@ H5std_string EnumType::nameOf(void *value, size_t size) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const char* name, void *value) const +void +EnumType::valueOf(const char *name, void *value) const { // Calls C routine H5Tenum_valueof to get the enum datatype value herr_t ret_value = H5Tenum_valueof(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed"); } } @@ -254,7 +262,8 @@ void EnumType::valueOf(const char* name, void *value) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::valueOf(const H5std_string& name, void *value) const +void +EnumType::valueOf(const H5std_string &name, void *value) const { valueOf(name.c_str(), value); } @@ -269,15 +278,14 @@ void EnumType::valueOf(const H5std_string& name, void *value) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const char *name) const +int +EnumType::getMemberIndex(const char *name) const { int member_index = H5Tget_member_index(id, name); - if (member_index < 0) - { - throw DataTypeIException("EnumType::getMemberIndex", - "H5Tget_member_index returns negative value"); + if (member_index < 0) { + throw DataTypeIException("EnumType::getMemberIndex", "H5Tget_member_index returns negative value"); } - return(member_index); + return (member_index); } //-------------------------------------------------------------------------- @@ -287,9 +295,10 @@ int EnumType::getMemberIndex(const char *name) const /// argument \a name. // Programmer Binh-Minh Ribler - May 16, 2002 //-------------------------------------------------------------------------- -int EnumType::getMemberIndex(const H5std_string& name) const +int +EnumType::getMemberIndex(const H5std_string &name) const { - return(EnumType::getMemberIndex(name.c_str())); + return (EnumType::getMemberIndex(name.c_str())); } //-------------------------------------------------------------------------- @@ -299,15 +308,15 @@ int EnumType::getMemberIndex(const H5std_string& name) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -int EnumType::getNmembers() const +int +EnumType::getNmembers() const { int num_members = H5Tget_nmembers(id); - if (num_members < 0) - { + if (num_members < 0) { throw DataTypeIException("EnumType::getNmembers", - "H5Tget_nmembers returns negative number of members"); + "H5Tget_nmembers returns negative number of members"); } - return(num_members); + return (num_members); } //-------------------------------------------------------------------------- @@ -319,12 +328,12 @@ int EnumType::getNmembers() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void EnumType::getMemberValue(unsigned memb_no, void *value) const +void +EnumType::getMemberValue(unsigned memb_no, void *value) const { // Call C routine H5Tget_member_value to get the datatype member's value hid_t ret_value = H5Tget_member_value(id, memb_no, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed"); } } @@ -334,6 +343,8 @@ void EnumType::getMemberValue(unsigned memb_no, void *value) const ///\brief Properly terminates access to this enum datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -EnumType::~EnumType() {} +EnumType::~EnumType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 4797ee7742b..484405a0b76 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5EnumType_H -#define __H5EnumType_H +#ifndef H5EnumType_H +#define H5EnumType_H namespace H5 { @@ -24,63 +24,67 @@ namespace H5 { // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP EnumType : public DataType { - public: - // Creates an empty enumeration datatype based on a native signed - // integer type, whose size is given by size. - EnumType(size_t size); + public: + // Creates an empty enumeration datatype based on a native signed + // integer type, whose size is given by size. + EnumType(size_t size); - // Gets the enum datatype of the specified dataset - EnumType(const DataSet& dataset); // H5Dget_type + // Gets the enum datatype of the specified dataset + EnumType(const DataSet &dataset); // H5Dget_type - // Creates a new enum datatype based on an integer datatype - EnumType(const IntType& data_type); // H5Tenum_create + // Creates a new enum datatype based on an integer datatype + EnumType(const IntType &data_type); // H5Tenum_create - // Constructors that open an enum datatype, given a location. - EnumType(const H5Location& loc, const char* name); - EnumType(const H5Location& loc, const H5std_string& name); + // Constructors that open an enum datatype, given a location. + EnumType(const H5Location &loc, const char *name); + EnumType(const H5Location &loc, const H5std_string &name); - // Returns an EnumType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an EnumType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Returns the number of members in this enumeration datatype. - int getNmembers () const; + // Returns the number of members in this enumeration datatype. + int getNmembers() const; - // Returns the index of a member in this enumeration data type. - int getMemberIndex(const char* name) const; - int getMemberIndex(const H5std_string& name) const; + // Returns the index of a member in this enumeration data type. + int getMemberIndex(const char *name) const; + int getMemberIndex(const H5std_string &name) const; - // Returns the value of an enumeration datatype member - void getMemberValue(unsigned memb_no, void *value) const; + // Returns the value of an enumeration datatype member + void getMemberValue(unsigned memb_no, void *value) const; - // Inserts a new member to this enumeration type. - void insert(const char* name, void *value) const; - void insert(const H5std_string& name, void *value) const; + // Inserts a new member to this enumeration type. + void insert(const char *name, void *value) const; + void insert(const H5std_string &name, void *value) const; - // Returns the symbol name corresponding to a specified member - // of this enumeration datatype. - H5std_string nameOf(void *value, size_t size) const; + // Returns the symbol name corresponding to a specified member + // of this enumeration datatype. + H5std_string nameOf(void *value, size_t size) const; - // Returns the value corresponding to a specified member of this - // enumeration datatype. - void valueOf(const char* name, void *value) const; - void valueOf(const H5std_string& name, void *value) const; + // Returns the value corresponding to a specified member of this + // enumeration datatype. + void valueOf(const char *name, void *value) const; + void valueOf(const H5std_string &name, void *value) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("EnumType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("EnumType"); + } - // Default constructor - EnumType(); + // Default constructor + EnumType(); - // Creates an enumeration datatype using an existing id - EnumType(const hid_t existing_id); + // Creates an enumeration datatype using an existing id + EnumType(const hid_t existing_id); - // Copy constructor: same as the original EnumType. - EnumType(const EnumType& original); + // Copy constructor: same as the original EnumType. + EnumType(const EnumType &original); - virtual ~EnumType(); + virtual ~EnumType(); }; // end of EnumType } // namespace H5 -#endif // __H5EnumType_H +#endif // H5EnumType_H diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7431e6cd9ee..67694390f11 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,7 +25,9 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided"; ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() : detail_message(""), func_name("") {} +Exception::Exception() +{ +} //-------------------------------------------------------------------------- // Function: Exception overloaded constructor @@ -35,7 +37,10 @@ Exception::Exception() : detail_message(""), func_name("") {} ///\param message - IN: Message on the failure // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const H5std_string& func, const H5std_string& message) : detail_message(message), func_name(func) {} +Exception::Exception(const H5std_string &func, const H5std_string &message) + : detail_message(message), func_name(func) +{ +} //-------------------------------------------------------------------------- // Function: Exception copy constructor @@ -43,7 +48,9 @@ Exception::Exception(const H5std_string& func, const H5std_string& message) : de ///\param orig - IN: Exception instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception(const Exception& orig) : detail_message(orig.detail_message), func_name(orig.func_name) {} +Exception::Exception(const Exception &orig) : detail_message(orig.detail_message), func_name(orig.func_name) +{ +} //-------------------------------------------------------------------------- // Function: Exception::getMajorString @@ -56,32 +63,30 @@ Exception::Exception(const Exception& orig) : detail_message(orig.detail_message /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMajorString(hid_t err_major) const +H5std_string +Exception::getMajorString(hid_t err_major) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_major, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_major, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMajorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string major_str(mesg_C); - delete []mesg_C; - return(major_str); + delete[] mesg_C; + return (major_str); } //-------------------------------------------------------------------------- @@ -95,32 +100,30 @@ H5std_string Exception::getMajorString(hid_t err_major) const /// will be returned. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getMinorString(hid_t err_minor) const +H5std_string +Exception::getMinorString(hid_t err_minor) const { // Preliminary call to H5Eget_msg() to get the length of the message ssize_t mesg_size = H5Eget_msg(err_minor, NULL, NULL, 0); // If H5Eget_msg() returns a negative value, raise an exception, if (mesg_size < 0) - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); // Call H5Eget_msg again to get the actual message - char* mesg_C = new char[mesg_size+1]; // temporary C-string for C API - mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size+1); + char *mesg_C = new char[mesg_size + 1]; // temporary C-string for C API + mesg_size = H5Eget_msg(err_minor, NULL, mesg_C, mesg_size + 1); // Check for failure again - if (mesg_size < 0) - { - delete []mesg_C; - throw IdComponentException("Exception::getMinorString", - "H5Eget_msg failed"); + if (mesg_size < 0) { + delete[] mesg_C; + throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); } // Convert the C error description and return H5std_string minor_str(mesg_C); - delete []mesg_C; - return(minor_str); + delete[] mesg_C; + return (minor_str); } //-------------------------------------------------------------------------- @@ -139,7 +142,8 @@ H5std_string Exception::getMinorString(hid_t err_minor) const /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) +void +Exception::setAutoPrint(H5E_auto2_t &func, void *client_data) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. @@ -153,7 +157,8 @@ void Exception::setAutoPrint(H5E_auto2_t& func, void* client_data) ///\brief Turns off the automatic error printing from the C library. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::dontPrint() +void +Exception::dontPrint() { // calls the C API routine H5Eset_auto with NULL parameters to turn // off the automatic error printing. @@ -172,7 +177,8 @@ void Exception::dontPrint() /// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) +void +Exception::getAutoPrint(H5E_auto2_t &func, void **client_data) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing @@ -189,7 +195,8 @@ void Exception::getAutoPrint(H5E_auto2_t& func, void** client_data) /// called, with certain exceptions (for instance, \c H5Eprint). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::clearErrorStack() +void +Exception::clearErrorStack() { // calls the C API routine H5Eclear to clear the error stack herr_t ret_value = H5Eclear2(H5E_DEFAULT); @@ -238,7 +245,8 @@ void Exception::clearErrorStack() ///\endcode // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void* client_data) +void +Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data) { // calls the C API routine H5Ewalk to walk the error stack herr_t ret_value = H5Ewalk2(H5E_DEFAULT, direction, func, client_data); @@ -253,9 +261,10 @@ void Exception::walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getDetailMsg() const +H5std_string +Exception::getDetailMsg() const { - return(detail_message); + return (detail_message); } //-------------------------------------------------------------------------- @@ -265,9 +274,10 @@ H5std_string Exception::getDetailMsg() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCDetailMsg() const +const char * +Exception::getCDetailMsg() const { - return(detail_message.c_str()); + return (detail_message.c_str()); } //-------------------------------------------------------------------------- @@ -276,9 +286,10 @@ const char* Exception::getCDetailMsg() const ///\return Text message - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string Exception::getFuncName() const +H5std_string +Exception::getFuncName() const { - return(func_name); + return (func_name); } //-------------------------------------------------------------------------- @@ -287,9 +298,10 @@ H5std_string Exception::getFuncName() const ///\return Text message - \c char pointer // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -const char* Exception::getCFuncName() const +const char * +Exception::getCFuncName() const { - return(func_name.c_str()); + return (func_name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +311,8 @@ const char* Exception::getCFuncName() const ///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::printErrorStack(FILE* stream, hid_t err_stack) +void +Exception::printErrorStack(FILE *stream, hid_t err_stack) { herr_t ret_value = H5Eprint2(err_stack, stream); if (ret_value < 0) @@ -319,7 +332,7 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) // Removed from documentation. -BMR, 2016/03/23 // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 //-------------------------------------------------------------------------- -//void Exception::printError(FILE* stream) const +// void Exception::printError(FILE* stream) const //{ // Exception::printErrorStack(stream, H5E_DEFAULT); //} @@ -329,7 +342,9 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::~Exception() throw() {} +Exception::~Exception() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: FileIException @@ -339,7 +354,9 @@ Exception::~Exception() throw() {} // Function: FileIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -FileIException::FileIException():Exception(){} +FileIException::FileIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: FileIException overloaded constructor ///\brief Creates a FileIException with the name of the function, @@ -347,12 +364,17 @@ FileIException::FileIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -FileIException::FileIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +FileIException::FileIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: FileIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -FileIException::~FileIException() throw() {} +FileIException::~FileIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: GroupIException @@ -362,7 +384,9 @@ FileIException::~FileIException() throw() {} // Function: GroupIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -GroupIException::GroupIException():Exception(){} +GroupIException::GroupIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: GroupIException overloaded constructor ///\brief Creates a GroupIException with the name of the function, @@ -370,12 +394,17 @@ GroupIException::GroupIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -GroupIException::GroupIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +GroupIException::GroupIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: GroupIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -GroupIException::~GroupIException() throw() {} +GroupIException::~GroupIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSpaceIException @@ -385,7 +414,9 @@ GroupIException::~GroupIException() throw() {} // Function: DataSpaceIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException():Exception(){} +DataSpaceIException::DataSpaceIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException overloaded constructor ///\brief Creates a DataSpaceIException with the name of the function, @@ -393,12 +424,17 @@ DataSpaceIException::DataSpaceIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSpaceIException::DataSpaceIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSpaceIException::DataSpaceIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSpaceIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSpaceIException::~DataSpaceIException() throw() {} +DataSpaceIException::~DataSpaceIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataTypeIException @@ -408,7 +444,9 @@ DataSpaceIException::~DataSpaceIException() throw() {} // Function: DataTypeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException():Exception(){} +DataTypeIException::DataTypeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException overloaded constructor ///\brief Creates a DataTypeIException with the name of the function, @@ -416,12 +454,17 @@ DataTypeIException::DataTypeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataTypeIException::DataTypeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataTypeIException::DataTypeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataTypeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataTypeIException::~DataTypeIException() throw() {} +DataTypeIException::~DataTypeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ObjHeaderIException @@ -431,7 +474,9 @@ DataTypeIException::~DataTypeIException() throw() {} // Function: ObjHeaderIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException():Exception(){} +ObjHeaderIException::ObjHeaderIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException overloaded constructor ///\brief Creates an ObjHeaderIException with the name of the function, @@ -439,12 +484,17 @@ ObjHeaderIException::ObjHeaderIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ObjHeaderIException::ObjHeaderIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ObjHeaderIException::ObjHeaderIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ObjHeaderIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ObjHeaderIException::~ObjHeaderIException() throw() {} +ObjHeaderIException::~ObjHeaderIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: PropListIException @@ -454,7 +504,9 @@ ObjHeaderIException::~ObjHeaderIException() throw() {} // Function: PropListIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -PropListIException::PropListIException():Exception(){} +PropListIException::PropListIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: PropListIException overloaded constructor ///\brief Creates a PropListIException with the name of the function, @@ -462,12 +514,17 @@ PropListIException::PropListIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -PropListIException::PropListIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +PropListIException::PropListIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: PropListIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -PropListIException::~PropListIException() throw() {} +PropListIException::~PropListIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: DataSetIException @@ -477,7 +534,9 @@ PropListIException::~PropListIException() throw() {} // Function: DataSetIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -DataSetIException::DataSetIException():Exception(){} +DataSetIException::DataSetIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException overloaded constructor ///\brief Creates a DataSetIException with the name of the function, @@ -485,12 +544,17 @@ DataSetIException::DataSetIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -DataSetIException::DataSetIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +DataSetIException::DataSetIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: DataSetIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -DataSetIException::~DataSetIException() throw() {} +DataSetIException::~DataSetIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: AttributeIException @@ -500,7 +564,9 @@ DataSetIException::~DataSetIException() throw() {} // Function: AttributeIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -AttributeIException::AttributeIException():Exception(){} +AttributeIException::AttributeIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException overloaded constructor ///\brief Creates an AttributeIException with the name of the function, @@ -508,12 +574,17 @@ AttributeIException::AttributeIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -AttributeIException::AttributeIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +AttributeIException::AttributeIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: AttributeIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -AttributeIException::~AttributeIException() throw() {} +AttributeIException::~AttributeIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: ReferenceException @@ -523,7 +594,9 @@ AttributeIException::~AttributeIException() throw() {} // Function: ReferenceException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -ReferenceException::ReferenceException():Exception(){} +ReferenceException::ReferenceException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException overloaded constructor ///\brief Creates a ReferenceException with the name of the function, @@ -531,12 +604,17 @@ ReferenceException::ReferenceException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -ReferenceException::ReferenceException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +ReferenceException::ReferenceException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: ReferenceException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -ReferenceException::~ReferenceException() throw() {} +ReferenceException::~ReferenceException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LibraryIException @@ -546,7 +624,9 @@ ReferenceException::~ReferenceException() throw() {} // Function: LibraryIException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LibraryIException::LibraryIException():Exception(){} +LibraryIException::LibraryIException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException overloaded constructor ///\brief Creates a LibraryIException with the name of the function, @@ -554,12 +634,17 @@ LibraryIException::LibraryIException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LibraryIException::LibraryIException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LibraryIException::LibraryIException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LibraryIException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LibraryIException::~LibraryIException() throw() {} +LibraryIException::~LibraryIException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: LocationException @@ -569,7 +654,9 @@ LibraryIException::~LibraryIException() throw() {} // Function: LocationException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -LocationException::LocationException():Exception(){} +LocationException::LocationException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: LocationException overloaded constructor ///\brief Creates a LocationException with the name of the function, @@ -577,12 +664,17 @@ LocationException::LocationException():Exception(){} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -LocationException::LocationException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +LocationException::LocationException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: LocationException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -LocationException::~LocationException() throw() {} +LocationException::~LocationException() throw() +{ +} //-------------------------------------------------------------------------- // Subclass: IdComponentException @@ -592,7 +684,9 @@ LocationException::~LocationException() throw() {} // Function: IdComponentException default constructor ///\brief Default constructor. //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(): Exception() {} +IdComponentException::IdComponentException() : Exception() +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException overloaded constructor ///\brief Creates a IdComponentException with the name of the function, @@ -600,11 +694,16 @@ IdComponentException::IdComponentException(): Exception() {} ///\param func - IN: Name of the function where failure occurs ///\param message - IN: Message on the failure //-------------------------------------------------------------------------- -IdComponentException::IdComponentException(const H5std_string& func, const H5std_string& message) : Exception(func, message) {} +IdComponentException::IdComponentException(const H5std_string &func, const H5std_string &message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: IdComponentException destructor ///\brief Noop destructor. //-------------------------------------------------------------------------- -IdComponentException::~IdComponentException() throw() {} +IdComponentException::~IdComponentException() throw() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index cb14a4c9c26..9970d2229b0 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -7,22 +7,18 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Exception_H -#define __H5Exception_H +#ifndef H5Exception_H +#define H5Exception_H #include namespace H5 { -#ifdef H5_NO_STD - #define H5std_string ::string -#else - #define H5std_string std::string -#endif +#define H5std_string std::string /*! \class Exception \brief Exception provides wrappers of HDF5 error handling functions. @@ -30,152 +26,150 @@ namespace H5 { Many classes are derived from Exception for specific HDF5 C interfaces. */ class H5_DLLCPP Exception { - public: - // Creates an exception with a function name where the failure occurs - // and an optional detailed message - Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - - // Returns a character string that describes the error specified by - // a major error number. - H5std_string getMajorString(hid_t err_major_id) const; - - // Returns a character string that describes the error specified by - // a minor error number. - H5std_string getMinorString(hid_t err_minor_id) const; - - // 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 - H5std_string getFuncName() const; // function name as a string object - 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); - - // Turns off the automatic error printing. - static void dontPrint(); - - // Retrieves the current settings for the automatic error stack - // traversal function and its data. - static void getAutoPrint(H5E_auto2_t& func, void** client_data); - - // Clears the error stack for the current thread. - static void clearErrorStack(); - - // Walks the error stack for the current thread, calling the - // specified function. - static void walkErrorStack(H5E_direction_t direction, - H5E_walk2_t func, void* client_data); - - // Prints the error stack in a default manner. - static void printErrorStack(FILE* stream = stderr, - hid_t err_stack = H5E_DEFAULT); - // Deprecated in favor of printErrorStack. - // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 - // virtual void printError(FILE* stream = NULL) const; - - // Default constructor - Exception(); - - // copy constructor - Exception(const Exception& orig); - - // virtual Destructor - virtual ~Exception() throw(); - - protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; - - private: - H5std_string detail_message; - H5std_string func_name; + public: + // Creates an exception with a function name where the failure occurs + // and an optional detailed message + Exception(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + + // Returns a character string that describes the error specified by + // a major error number. + H5std_string getMajorString(hid_t err_major_id) const; + + // Returns a character string that describes the error specified by + // a minor error number. + H5std_string getMinorString(hid_t err_minor_id) const; + + // 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 + H5std_string getFuncName() const; // function name as a string object + 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); + + // Turns off the automatic error printing. + static void dontPrint(); + + // Retrieves the current settings for the automatic error stack + // traversal function and its data. + static void getAutoPrint(H5E_auto2_t &func, void **client_data); + + // Clears the error stack for the current thread. + static void clearErrorStack(); + + // Walks the error stack for the current thread, calling the + // specified function. + static void walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data); + + // Prints the error stack in a default manner. + static void printErrorStack(FILE *stream = stderr, hid_t err_stack = H5E_DEFAULT); + // Deprecated in favor of printErrorStack. + // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2 + // virtual void printError(FILE* stream = NULL) const; + + // Default constructor + Exception(); + + // copy constructor + Exception(const Exception &orig); + + // virtual Destructor + virtual ~Exception() throw(); + + protected: + // Default value for detail_message + static const char DEFAULT_MSG[]; + + private: + H5std_string detail_message; + H5std_string func_name; }; class H5_DLLCPP FileIException : public Exception { - public: - FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - FileIException(); - virtual ~FileIException() throw(); + public: + FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + FileIException(); + virtual ~FileIException() throw() H5_OVERRIDE; }; class H5_DLLCPP GroupIException : public Exception { - public: - GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - GroupIException(); - virtual ~GroupIException() throw(); + public: + GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + GroupIException(); + virtual ~GroupIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataSpaceIException : public Exception { - public: - DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSpaceIException(); - virtual ~DataSpaceIException() throw(); + public: + DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSpaceIException(); + virtual ~DataSpaceIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataTypeIException : public Exception { - public: - DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataTypeIException(); - virtual ~DataTypeIException() throw(); + public: + DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataTypeIException(); + virtual ~DataTypeIException() throw() H5_OVERRIDE; }; class H5_DLLCPP ObjHeaderIException : public Exception { - public: - ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ObjHeaderIException(); - virtual ~ObjHeaderIException() throw(); + public: + ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ObjHeaderIException(); + virtual ~ObjHeaderIException() throw() H5_OVERRIDE; }; class H5_DLLCPP PropListIException : public Exception { - public: - PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - PropListIException(); - virtual ~PropListIException() throw(); + public: + PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + PropListIException(); + virtual ~PropListIException() throw() H5_OVERRIDE; }; class H5_DLLCPP DataSetIException : public Exception { - public: - DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - DataSetIException(); - virtual ~DataSetIException() throw(); + public: + DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + DataSetIException(); + virtual ~DataSetIException() throw() H5_OVERRIDE; }; class H5_DLLCPP AttributeIException : public Exception { - public: - AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - AttributeIException(); - virtual ~AttributeIException() throw(); + public: + AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + AttributeIException(); + virtual ~AttributeIException() throw() H5_OVERRIDE; }; class H5_DLLCPP ReferenceException : public Exception { - public: - ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - ReferenceException(); - virtual ~ReferenceException() throw(); + public: + ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + ReferenceException(); + virtual ~ReferenceException() throw() H5_OVERRIDE; }; class H5_DLLCPP LibraryIException : public Exception { - public: - LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LibraryIException(); - virtual ~LibraryIException() throw(); + public: + LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LibraryIException(); + virtual ~LibraryIException() throw() H5_OVERRIDE; }; class H5_DLLCPP LocationException : public Exception { - public: - LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - LocationException(); - virtual ~LocationException() throw(); + public: + LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + LocationException(); + virtual ~LocationException() throw() H5_OVERRIDE; }; class H5_DLLCPP IdComponentException : public Exception { - public: - IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); - IdComponentException(); - virtual ~IdComponentException() throw(); + public: + IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG); + IdComponentException(); + virtual ~IdComponentException() throw() H5_OVERRIDE; }; // end of IdComponentException } // namespace H5 -#endif // __H5Exception_H +#endif // H5Exception_H diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 6128d6583bf..005e5997c01 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -6,16 +6,12 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include using std::cerr; @@ -37,7 +33,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileAccPropList* FileAccPropList::DEFAULT_ = 0; +FileAccPropList *FileAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileAccPropList::getConstant @@ -50,13 +46,13 @@ FileAccPropList* FileAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileAccPropList* FileAccPropList::getConstant() +FileAccPropList * +FileAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -65,8 +61,9 @@ FileAccPropList* FileAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileAccPropList(H5P_FILE_ACCESS); else - throw PropListIException("FileAccPropList::getConstant", "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileAccPropList::getConstant", + "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -76,7 +73,8 @@ FileAccPropList* FileAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileAccPropList::deleteConstants() +void +FileAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -85,7 +83,7 @@ void FileAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); +const FileAccPropList &FileAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -94,7 +92,9 @@ const FileAccPropList& FileAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} +FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList copy constructor @@ -102,7 +102,9 @@ FileAccPropList::FileAccPropList() : PropList(H5P_FILE_ACCESS) {} ///\param original - IN: FileAccPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(original) {} +FileAccPropList::FileAccPropList(const FileAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList overloaded constructor @@ -110,7 +112,9 @@ FileAccPropList::FileAccPropList(const FileAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} +FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: FileAccPropList::setStdio @@ -119,11 +123,11 @@ FileAccPropList::FileAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setStdio() const +void +FileAccPropList::setStdio() const { herr_t ret_value = H5Pset_fapl_stdio(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); } } @@ -139,14 +143,14 @@ void FileAccPropList::setStdio() const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t FileAccPropList::getDriver() const +hid_t +FileAccPropList::getDriver() const { hid_t driver = H5Pget_driver(id); - if (driver < 0) - { + if (driver < 0) { throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); } - return(driver); + return (driver); } //-------------------------------------------------------------------------- @@ -160,11 +164,11 @@ hid_t FileAccPropList::getDriver() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const +void +FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const { herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); } } @@ -176,11 +180,11 @@ void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamilyOffset(hsize_t offset) const +void +FileAccPropList::setFamilyOffset(hsize_t offset) const { herr_t ret_value = H5Pset_family_offset(id, offset); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); } } @@ -192,15 +196,15 @@ void FileAccPropList::setFamilyOffset(hsize_t offset) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getFamilyOffset() const +hsize_t +FileAccPropList::getFamilyOffset() const { hsize_t offset; - herr_t ret_value = H5Pget_family_offset(id, &offset); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_family_offset(id, &offset); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); } - return(offset); + return (offset); } //-------------------------------------------------------------------------- @@ -217,12 +221,12 @@ hsize_t FileAccPropList::getFamilyOffset() const /// refer to the H5Pset_fapl_core API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const +void +FileAccPropList::setCore(size_t increment, hbool_t backing_store) const { - herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); - if (ret_value < 0) - { - throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); + herr_t ret_value = H5Pset_fapl_core(id, increment, backing_store); + if (ret_value < 0) { + throw PropListIException("FileAccPropList::setCore", "H5Pset_fapl_core failed"); } } @@ -235,11 +239,11 @@ void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const +void +FileAccPropList::getCore(size_t &increment, hbool_t &backing_store) const { herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); } } @@ -255,11 +259,11 @@ void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const /// Note that \a memb_size is used only when creating a new file. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const +void +FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const { - herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId()); - if (ret_value < 0) - { + herr_t ret_value = H5Pset_fapl_family(id, memb_size, memb_plist.getId()); + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); } } @@ -274,12 +278,12 @@ void FileAccPropList::setFamily(hsize_t memb_size, const FileAccPropList& memb_p ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const +void +FileAccPropList::getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } memb_plist.p_setId(memb_plist_id); @@ -295,16 +299,16 @@ void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const +FileAccPropList +FileAccPropList::getFamily(hsize_t &memb_size) const { - hid_t memb_plist_id; + hid_t memb_plist_id; herr_t ret_value = H5Pget_fapl_family(id, &memb_size, &memb_plist_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } FileAccPropList memb_plist(memb_plist_id); - return(memb_plist); + return (memb_plist); } //-------------------------------------------------------------------------- @@ -321,13 +325,14 @@ FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext, const char *raw_ext) const { - hid_t meta_pid = meta_plist.getId(); - hid_t raw_pid = raw_plist.getId(); + hid_t meta_pid = meta_plist.getId(); + hid_t raw_pid = raw_plist.getId(); herr_t ret_value = H5Pset_fapl_split(id, meta_ext, meta_pid, raw_ext, raw_pid); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); } } @@ -343,7 +348,9 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccPropList& raw_plist, const H5std_string& meta_ext, const H5std_string& raw_ext) const +void +FileAccPropList::setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext, const H5std_string &raw_ext) const { setSplit(meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str()); } @@ -360,15 +367,15 @@ void FileAccPropList::setSplit(const FileAccPropList& meta_plist, const FileAccP ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t FileAccPropList::getSieveBufSize() const +size_t +FileAccPropList::getSieveBufSize() const { size_t bufsize; herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } - return(bufsize); + return (bufsize); } //-------------------------------------------------------------------------- @@ -381,11 +388,11 @@ size_t FileAccPropList::getSieveBufSize() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSieveBufSize(size_t bufsize) const +void +FileAccPropList::setSieveBufSize(size_t bufsize) const { herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); } } @@ -401,11 +408,11 @@ void FileAccPropList::setSieveBufSize(size_t bufsize) const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const +void +FileAccPropList::setMetaBlockSize(hsize_t &block_size) const { herr_t ret_value = H5Pset_meta_block_size(id, block_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); } } @@ -417,15 +424,15 @@ void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hsize_t FileAccPropList::getMetaBlockSize() const +hsize_t +FileAccPropList::getMetaBlockSize() const { hsize_t block_size; - herr_t ret_value = H5Pget_meta_block_size(id, &block_size); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_meta_block_size(id, &block_size); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); } - return(block_size); + return (block_size); } //-------------------------------------------------------------------------- @@ -441,11 +448,11 @@ hsize_t FileAccPropList::getMetaBlockSize() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const { herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); } } @@ -460,7 +467,8 @@ void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_siz ///\param buf_size - IN: Size of the logging buffer // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const +void +FileAccPropList::setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const { setLog(logfile.c_str(), flags, buf_size); } @@ -473,11 +481,11 @@ void FileAccPropList::setLog(const H5std_string& logfile, unsigned flags, size_t ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setSec2() const +void +FileAccPropList::setSec2() const { herr_t ret_value = H5Pset_fapl_sec2(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); } } @@ -498,11 +506,11 @@ void FileAccPropList::setSec2() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const +void +FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const { herr_t ret_value = H5Pset_alignment(id, threshold, alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed"); } } @@ -516,11 +524,11 @@ void FileAccPropList::setAlignment(hsize_t threshold, hsize_t alignment) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const +void +FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const { herr_t ret_value = H5Pget_alignment(id, &threshold, &alignment); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed"); } } @@ -535,11 +543,11 @@ void FileAccPropList::getAlignment(hsize_t &threshold, hsize_t &alignment) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setMultiType(H5FD_mem_t dtype) const +void +FileAccPropList::setMultiType(H5FD_mem_t dtype) const { herr_t ret_value = H5Pset_multi_type(id, dtype); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); } } @@ -554,15 +562,15 @@ void FileAccPropList::setMultiType(H5FD_mem_t dtype) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5FD_mem_t FileAccPropList::getMultiType() const +H5FD_mem_t +FileAccPropList::getMultiType() const { H5FD_mem_t dtype; - herr_t ret_value = H5Pget_multi_type(id, &dtype); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_multi_type(id, &dtype); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); } - return(dtype); + return (dtype); } //-------------------------------------------------------------------------- @@ -582,11 +590,11 @@ H5FD_mem_t FileAccPropList::getMultiType() const /// means fully read chunks are always preempted before other chunks. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const +void +FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const { herr_t ret_value = H5Pset_cache(id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed"); } } @@ -601,11 +609,11 @@ void FileAccPropList::setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_n ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const +void +FileAccPropList::getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const { herr_t ret_value = H5Pget_cache(id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed"); } } @@ -617,11 +625,11 @@ void FileAccPropList::getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdc ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const +void +FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const { herr_t ret_value = H5Pset_fclose_degree(id, degree); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); } } @@ -633,15 +641,15 @@ void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5F_close_degree_t FileAccPropList::getFcloseDegree() const +H5F_close_degree_t +FileAccPropList::getFcloseDegree() const { H5F_close_degree_t degree; - herr_t ret_value = H5Pget_fclose_degree(id, °ree); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_fclose_degree(id, °ree); + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); } - return(degree); + return (degree); } //-------------------------------------------------------------------------- @@ -655,11 +663,11 @@ H5F_close_degree_t FileAccPropList::getFcloseDegree() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileAccPropList::setGcReferences(unsigned gc_ref) const +void +FileAccPropList::setGcReferences(unsigned gc_ref) const { herr_t ret_value = H5Pset_gc_references(id, gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed"); } } @@ -671,17 +679,17 @@ void FileAccPropList::setGcReferences(unsigned gc_ref) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileAccPropList::getGcReferences() const +unsigned +FileAccPropList::getGcReferences() const { unsigned gc_ref; // the name of this routine will be changed to H5Pget_gc_references??? herr_t ret_value = H5Pget_gc_references(id, &gc_ref); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed"); } - return(gc_ref); + return (gc_ref); } //-------------------------------------------------------------------------- @@ -697,12 +705,12 @@ unsigned FileAccPropList::getGcReferences() const /// the HDF5 C Reference Manual. // Programmer Dana Robinson - 2020 //-------------------------------------------------------------------------- -void FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const +void +FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const { herr_t ret_value = H5Pset_file_locking(id, use_file_locking, ignore_when_disabled); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setFileLocking", "H5Pset_file_locking failed"); } } @@ -720,17 +728,16 @@ void FileAccPropList::setFileLocking(hbool_t use_file_locking, hbool_t ignore_wh /// the HDF5 C Reference Manual. // Programmer Dana Robinson - 2020 //-------------------------------------------------------------------------- -void FileAccPropList::getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_when_disabled) const +void +FileAccPropList::getFileLocking(hbool_t &use_file_locking, hbool_t &ignore_when_disabled) const { herr_t ret_value = H5Pget_file_locking(id, &use_file_locking, &ignore_when_disabled); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getFileLocking", "H5Pget_file_locking failed"); } } - //-------------------------------------------------------------------------- // Function: FileAccPropList::setLibverBounds ///\brief Sets bounds on versions of library format to be used when creating @@ -743,21 +750,25 @@ void FileAccPropList::getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_ /// Valid values of \a libver_low are as follows: /// \li \c H5F_LIBVER_EARLIEST (Default) /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 /// \li \c H5F_LIBVER_LATEST /// /// Valid values of \a libver_high are as follows: /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 /// \li \c H5F_LIBVER_LATEST (Default) /// /// For more detail, please refer to the H5Pset_libver_bounds API in /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const +void +FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const { herr_t ret_value = H5Pset_libver_bounds(id, libver_low, libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::setLibverBounds", "H5Pset_libver_bounds failed"); } } @@ -776,18 +787,22 @@ void FileAccPropList::setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libv /// values: /// \li \c H5F_LIBVER_EARLIEST /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 /// \li \c H5F_LIBVER_LATEST /// /// and \a libver_high: /// \li \c H5F_LIBVER_18 +/// \li \c H5F_LIBVER_110 +/// \li \c H5F_LIBVER_112 /// \li \c H5F_LIBVER_LATEST // Programmer Binh-Minh Ribler - March, 2015 //-------------------------------------------------------------------------- -void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const +void +FileAccPropList::getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const { herr_t ret_value = H5Pget_libver_bounds(id, &libver_low, &libver_high); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileAccPropList::getLibverBounds", "H5Pget_libver_bounds failed"); } } @@ -797,6 +812,8 @@ void FileAccPropList::getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& li ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileAccPropList::~FileAccPropList() {} +FileAccPropList::~FileAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index ee90fa430ae..998f870bea1 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5FileAccPropList_H -#define __H5FileAccPropList_H +#ifndef H5FileAccPropList_H +#define H5FileAccPropList_H namespace H5 { @@ -23,149 +23,149 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileAccPropList : public PropList { - public: - ///\brief Default file access property list. - static const FileAccPropList& DEFAULT; + public: + ///\brief Default file access property list. + static const FileAccPropList &DEFAULT; - // Creates a file access property list. - FileAccPropList(); + // Creates a file access property list. + FileAccPropList(); - // Modifies this property list to use the H5FD_STDIO driver - void setStdio() const; + // Modifies this property list to use the H5FD_STDIO driver + void setStdio() const; - // Set file driver for this property list - void setDriver(hid_t new_driver_id, const void *new_driver_info) const; + // Set file driver for this property list + void setDriver(hid_t new_driver_id, const void *new_driver_info) const; - // Returns a low-level file driver identifier. - hid_t getDriver() const; + // Returns a low-level file driver identifier. + hid_t getDriver() const; - // Sets offset for family driver. - void setFamilyOffset(hsize_t offset) const; + // Sets offset for family driver. + void setFamilyOffset(hsize_t offset) const; - // Gets offset for family driver. - hsize_t getFamilyOffset() const; + // Gets offset for family driver. + hsize_t getFamilyOffset() const; - // Modifies this file access property list to use the sec2 driver. - void setSec2() const; + // Modifies this file access property list to use the sec2 driver. + void setSec2() const; - // Modifies this file access property list to use the H5FD_CORE - // driver. - void setCore (size_t increment, hbool_t backing_store) const; + // Modifies this file access property list to use the H5FD_CORE + // driver. + void setCore(size_t increment, hbool_t backing_store) const; - // Queries H5FD_CORE driver properties. - void getCore (size_t& increment, hbool_t& backing_store) const; + // Queries H5FD_CORE driver properties. + void getCore(size_t &increment, hbool_t &backing_store) const; - // Sets this file access properties list to the family driver. - void setFamily(hsize_t memb_size, const FileAccPropList& memb_plist) const; + // Sets this file access properties list to the family driver. + void setFamily(hsize_t memb_size, const FileAccPropList &memb_plist) const; - // Returns information about the family file access property list. - void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; - FileAccPropList getFamily(hsize_t& memb_size) const; + // Returns information about the family file access property list. + void getFamily(hsize_t &memb_size, FileAccPropList &memb_plist) const; + FileAccPropList getFamily(hsize_t &memb_size) const; - // Emulates the old split file driver, - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const char* meta_ext = ".meta", - const char* raw_ext = ".raw") const; - void setSplit(const FileAccPropList& meta_plist, - const FileAccPropList& raw_plist, - const H5std_string& meta_ext = ".meta", - const H5std_string& raw_ext = ".raw") const; + // Emulates the old split file driver, + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const char *meta_ext = ".meta", const char *raw_ext = ".raw") const; + void setSplit(const FileAccPropList &meta_plist, const FileAccPropList &raw_plist, + const H5std_string &meta_ext = ".meta", const H5std_string &raw_ext = ".raw") const; - // Sets the maximum size of the data sieve buffer. - void setSieveBufSize(size_t bufsize) const; + // Sets the maximum size of the data sieve buffer. + void setSieveBufSize(size_t bufsize) const; - // Returns the current settings for the data sieve buffer size - // property - size_t getSieveBufSize() const; + // Returns the current settings for the data sieve buffer size + // property + size_t getSieveBufSize() const; - // Sets the minimum size of metadata block allocations. - void setMetaBlockSize(hsize_t &block_size) const; + // Sets the minimum size of metadata block allocations. + void setMetaBlockSize(hsize_t &block_size) const; - // Returns the current metadata block size setting. - hsize_t getMetaBlockSize() const; + // Returns the current metadata block size setting. + hsize_t getMetaBlockSize() const; - // Modifies this file access property list to use the logging driver. - void setLog(const char *logfile, unsigned flags, size_t buf_size) const; - void setLog(const H5std_string& logfile, unsigned flags, size_t buf_size) const; + // Modifies this file access property list to use the logging driver. + void setLog(const char *logfile, unsigned flags, size_t buf_size) const; + void setLog(const H5std_string &logfile, unsigned flags, size_t buf_size) const; - // Sets alignment properties of this file access property list - void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; + // Sets alignment properties of this file access property list + void setAlignment(hsize_t threshold = 1, hsize_t alignment = 1) const; - // Retrieves the current settings for alignment properties from - // this property list. - void getAlignment(hsize_t& threshold, hsize_t& alignment) const; + // Retrieves the current settings for alignment properties from + // this property list. + void getAlignment(hsize_t &threshold, hsize_t &alignment) const; - // Sets data type for multi driver. - void setMultiType(H5FD_mem_t dtype) const; + // Sets data type for multi driver. + void setMultiType(H5FD_mem_t dtype) const; - // Returns the data type property for MULTI driver. - H5FD_mem_t getMultiType() const; + // Returns the data type property for MULTI driver. + H5FD_mem_t getMultiType() const; - // Sets the meta data cache and raw data chunk cache parameters. - void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; + // Sets the meta data cache and raw data chunk cache parameters. + void setCache(int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) const; - // Queries the meta data cache and raw data chunk cache parameters. - void getCache(int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0) const; + // Queries the meta data cache and raw data chunk cache parameters. + void getCache(int &mdc_nelmts, size_t &rdcc_nelmts, size_t &rdcc_nbytes, double &rdcc_w0) const; - // Sets the degree for the file close behavior. - void setFcloseDegree(H5F_close_degree_t degree) const; + // Sets the degree for the file close behavior. + void setFcloseDegree(H5F_close_degree_t degree) const; - // Returns the degree for the file close behavior. - H5F_close_degree_t getFcloseDegree() const; + // Returns the degree for the file close behavior. + H5F_close_degree_t getFcloseDegree() const; - // Sets file access property list to use the H5FD_DIRECT driver. - void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; + // Sets file access property list to use the H5FD_DIRECT driver. + void setFileAccDirect(size_t boundary, size_t block_size, size_t cbuf_size) const; - // Retrieves information about the direct file access property list. - void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; + // Retrieves information about the direct file access property list. + void getFileAccDirect(size_t &boundary, size_t &block_size, size_t &cbuf_size) const; - // Sets garbage collecting references flag. - void setGcReferences(unsigned gc_ref = 0) const; + // Sets garbage collecting references flag. + void setGcReferences(unsigned gc_ref = 0) const; - // Returns garbage collecting references setting. - unsigned getGcReferences() const; + // Returns garbage collecting references setting. + unsigned getGcReferences() const; - // Sets file locking parameters. - void setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const; + // Sets file locking parameters. + void setFileLocking(hbool_t use_file_locking, hbool_t ignore_when_disabled) const; - // Gets file locking parameters. - void getFileLocking(hbool_t& use_file_locking, hbool_t& ignore_when_disabled) const; + // Gets file locking parameters. + void getFileLocking(hbool_t &use_file_locking, hbool_t &ignore_when_disabled) const; - // Sets bounds on versions of library format to be used when creating - // or writing objects. - void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; + // Sets bounds on versions of library format to be used when creating + // or writing objects. + void setLibverBounds(H5F_libver_t libver_low, H5F_libver_t libver_high) const; - // Gets the current settings for the library version format bounds. - void getLibverBounds(H5F_libver_t& libver_low, H5F_libver_t& libver_high) const; + // Gets the current settings for the library version format bounds. + void getLibverBounds(H5F_libver_t &libver_low, H5F_libver_t &libver_high) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FileAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileAccPropList"); + } - // Copy constructor: same as the original FileAccPropList. - FileAccPropList(const FileAccPropList& original); + // Copy constructor: same as the original FileAccPropList. + FileAccPropList(const FileAccPropList &original); - // Creates a copy of an existing file access property list - // using the property list id. - FileAccPropList (const hid_t plist_id); + // Creates a copy of an existing file access property list + // using the property list id. + FileAccPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileAccPropList(); + // Noop destructor + virtual ~FileAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileAccPropList* DEFAULT_; + private: + static FileAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of FileAccPropList } // namespace H5 -#endif // __H5FileAccPropList_H +#endif // H5FileAccPropList_H diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 9b0fecc9778..b9be5634f27 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; +FileCreatPropList *FileCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: FileCreatPropList::getConstant @@ -39,13 +39,13 @@ FileCreatPropList* FileCreatPropList::DEFAULT_ = 0; // object, throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -FileCreatPropList* FileCreatPropList::getConstant() +FileCreatPropList * +FileCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -54,8 +54,9 @@ FileCreatPropList* FileCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new FileCreatPropList(H5P_FILE_CREATE); else - throw PropListIException("FileCreatPropList::getConstant", "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("FileCreatPropList::getConstant", + "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -64,7 +65,8 @@ FileCreatPropList* FileCreatPropList::getConstant() // points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void FileCreatPropList::deleteConstants() +void +FileCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -73,7 +75,7 @@ void FileCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property //-------------------------------------------------------------------------- -const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); +const FileCreatPropList &FileCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -82,7 +84,9 @@ const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: Creates a file create property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} +FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList copy constructor @@ -91,7 +95,9 @@ FileCreatPropList::FileCreatPropList() : PropList(H5P_FILE_CREATE) {} ///\param original - IN: FileCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropList( original ) {} +FileCreatPropList::FileCreatPropList(const FileCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: FileCreatPropList overloaded constructor @@ -100,7 +106,9 @@ FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropLi ///\param plist_id - IN: FileCreatPropList id to use // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -115,13 +123,12 @@ FileCreatPropList::FileCreatPropList(const hid_t plist_id) : PropList(plist_id) /// Any (or even all) of the output arguments can be null pointers. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const +void +FileCreatPropList::getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const { herr_t ret_value = H5Pget_version(id, &super, &freelist, &stab, &shhdr); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getVersion", - "H5Pget_version failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getVersion", "H5Pget_version failed"); } } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -136,13 +143,12 @@ void FileCreatPropList::getVersion(unsigned& super, unsigned& freelist, unsigned /// of 2 equal to 512 or greater (512, 1024, 2048, etc.) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setUserblock(hsize_t size) const +void +FileCreatPropList::setUserblock(hsize_t size) const { herr_t ret_value = H5Pset_userblock(id, size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setUserblock", - "H5Pset_userblock failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setUserblock", "H5Pset_userblock failed"); } } @@ -153,16 +159,15 @@ void FileCreatPropList::setUserblock(hsize_t size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getUserblock() const +hsize_t +FileCreatPropList::getUserblock() const { hsize_t userblock_size; - herr_t ret_value = H5Pget_userblock(id, &userblock_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getUserblock", - "H5Pget_userblock failed"); + herr_t ret_value = H5Pget_userblock(id, &userblock_size); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getUserblock", "H5Pget_userblock failed"); } - return(userblock_size); + return (userblock_size); } //-------------------------------------------------------------------------- @@ -177,13 +182,12 @@ hsize_t FileCreatPropList::getUserblock() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const +void +FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const { herr_t ret_value = H5Pset_sizes(id, sizeof_addr, sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSizes", - "H5Pset_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSizes", "H5Pset_sizes failed"); } } @@ -195,13 +199,12 @@ void FileCreatPropList::setSizes(size_t sizeof_addr, size_t sizeof_size) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const +void +FileCreatPropList::getSizes(size_t &sizeof_addr, size_t &sizeof_size) const { herr_t ret_value = H5Pget_sizes(id, &sizeof_addr, &sizeof_size); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSizes", - "H5Pget_sizes failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSizes", "H5Pget_sizes failed"); } } @@ -217,13 +220,12 @@ void FileCreatPropList::getSizes(size_t& sizeof_addr, size_t& sizeof_size) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const +void +FileCreatPropList::setSymk(unsigned ik, unsigned lk) const { herr_t ret_value = H5Pset_sym_k(id, ik, lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setSymk", - "H5Pset_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setSymk", "H5Pset_sym_k failed"); } } @@ -238,13 +240,12 @@ void FileCreatPropList::setSymk(unsigned ik, unsigned lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const +void +FileCreatPropList::getSymk(unsigned &ik, unsigned &lk) const { herr_t ret_value = H5Pget_sym_k(id, &ik, &lk); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getSymk", - "H5Pget_sym_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getSymk", "H5Pget_sym_k failed"); } } @@ -259,13 +260,12 @@ void FileCreatPropList::getSymk(unsigned& ik, unsigned& lk) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FileCreatPropList::setIstorek(unsigned ik) const +void +FileCreatPropList::setIstorek(unsigned ik) const { herr_t ret_value = H5Pset_istore_k(id, ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::setIstorek", - "H5Pset_istore_k failed"); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::setIstorek", "H5Pset_istore_k failed"); } } @@ -279,16 +279,15 @@ void FileCreatPropList::setIstorek(unsigned ik) const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -unsigned FileCreatPropList::getIstorek() const +unsigned +FileCreatPropList::getIstorek() const { unsigned ik; - herr_t ret_value = H5Pget_istore_k(id, &ik); - if (ret_value < 0) - { - throw PropListIException("FileCreatPropList::getIstorek", - "H5Pget_istore_k failed"); + herr_t ret_value = H5Pget_istore_k(id, &ik); + if (ret_value < 0) { + throw PropListIException("FileCreatPropList::getIstorek", "H5Pget_istore_k failed"); } - return(ik); + return (ik); } //-------------------------------------------------------------------------- @@ -309,13 +308,14 @@ unsigned FileCreatPropList::getIstorek() const /// API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const +void +FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, + hsize_t threshold) const { herr_t ret_value = H5Pset_file_space_strategy(id, strategy, persist, threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpaceStrategy", - "H5Pset_file_space_strategy failed"); + "H5Pset_file_space_strategy failed"); } } @@ -329,13 +329,14 @@ void FileCreatPropList::setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbo ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const +void +FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, + hsize_t &threshold) const { herr_t ret_value = H5Pget_file_space_strategy(id, &strategy, &persist, &threshold); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpaceStrategy", - "H5Pget_file_space_strategy failed"); + "H5Pget_file_space_strategy failed"); } } @@ -346,13 +347,13 @@ void FileCreatPropList::getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hb ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const +void +FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const { herr_t ret_value = H5Pset_file_space_page_size(id, fsp_psize); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("FileCreatPropList::setFileSpacePagesize", - "H5Pset_file_space_page_size failed"); + "H5Pset_file_space_page_size failed"); } } @@ -364,16 +365,16 @@ void FileCreatPropList::setFileSpacePagesize(hsize_t fsp_psize) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t FileCreatPropList::getFileSpacePagesize() const +hsize_t +FileCreatPropList::getFileSpacePagesize() const { hsize_t fsp_psize = 0; - herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_file_space_page_size(id, &fsp_psize); + if (ret_value < 0) { throw PropListIException("FileCreatPropList::getFileSpacePagesize", - "H5Pget_file_space_page_size failed"); + "H5Pget_file_space_page_size failed"); } - return(fsp_psize); + return (fsp_psize); } //-------------------------------------------------------------------------- @@ -381,6 +382,8 @@ hsize_t FileCreatPropList::getFileSpacePagesize() const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FileCreatPropList::~FileCreatPropList() {} +FileCreatPropList::~FileCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index cc28920a995..00ae0b1500b 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5FileCreatPropList_H -#define __H5FileCreatPropList_H +#ifndef H5FileCreatPropList_H +#define H5FileCreatPropList_H namespace H5 { @@ -23,86 +23,90 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP FileCreatPropList : public PropList { - public: - ///\brief Default file creation property list. - static const FileCreatPropList& DEFAULT; + public: + ///\brief Default file creation property list. + static const FileCreatPropList &DEFAULT; - // Creates a file create property list. - FileCreatPropList(); + // Creates a file create property list. + FileCreatPropList(); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves version information for various parts of a file. - void getVersion(unsigned& super, unsigned& freelist, unsigned& stab, unsigned& shhdr) const; + // Retrieves version information for various parts of a file. + void getVersion(unsigned &super, unsigned &freelist, unsigned &stab, unsigned &shhdr) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Sets the userblock size field of a file creation property list. - void setUserblock(hsize_t size) const; + // Sets the userblock size field of a file creation property list. + void setUserblock(hsize_t size) const; - // Gets the size of a user block in this file creation property list. - hsize_t getUserblock() const; + // Gets the size of a user block in this file creation property list. + hsize_t getUserblock() const; - // Retrieves the size-of address and size quantities stored in a - // file according to this file creation property list. - void getSizes(size_t& sizeof_addr, size_t& sizeof_size) const; + // Retrieves the size-of address and size quantities stored in a + // file according to this file creation property list. + void getSizes(size_t &sizeof_addr, size_t &sizeof_size) const; - // Sets file size-of addresses and sizes. - void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; + // Sets file size-of addresses and sizes. + void setSizes(size_t sizeof_addr = 4, size_t sizeof_size = 4) const; - // Retrieves the size of the symbol table B-tree 1/2 rank and the - // symbol table leaf node 1/2 size. - void getSymk(unsigned& int_nodes_k, unsigned& leaf_nodes_k) const; + // Retrieves the size of the symbol table B-tree 1/2 rank and the + // symbol table leaf node 1/2 size. + void getSymk(unsigned &int_nodes_k, unsigned &leaf_nodes_k) const; - // Sets the size of parameters used to control the symbol table nodes. - void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; + // Sets the size of parameters used to control the symbol table nodes. + void setSymk(unsigned int_nodes_k, unsigned leaf_nodes_k) const; - // Returns the 1/2 rank of an indexed storage B-tree. - unsigned getIstorek() const; + // Returns the 1/2 rank of an indexed storage B-tree. + unsigned getIstorek() const; - // Sets the size of parameter used to control the B-trees for - // indexing chunked datasets. - void setIstorek(unsigned ik) const; + // Sets the size of parameter used to control the B-trees for + // indexing chunked datasets. + void setIstorek(unsigned ik) const; - // Sets the strategy and the threshold value that the library will - // will employ in managing file space. - void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; + // Sets the strategy and the threshold value that the library will + // will employ in managing file space. + void setFileSpaceStrategy(H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) const; - // Returns the strategy that the library uses in managing file space. - void getFileSpaceStrategy(H5F_fspace_strategy_t& strategy, hbool_t& persist, hsize_t& threshold) const; + // Returns the strategy that the library uses in managing file space. + void getFileSpaceStrategy(H5F_fspace_strategy_t &strategy, hbool_t &persist, hsize_t &threshold) const; - // Sets the file space page size for paged aggregation. - void setFileSpacePagesize(hsize_t fsp_psize) const; + // Sets the file space page size for paged aggregation. + void setFileSpacePagesize(hsize_t fsp_psize) const; - // Returns the threshold value that the library uses in tracking free - // space sections. - hsize_t getFileSpacePagesize() const; + // Returns the threshold value that the library uses in tracking free + // space sections. + hsize_t getFileSpacePagesize() const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("FileCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FileCreatPropList"); + } - // Copy constructor: same as the original FileCreatPropList. - FileCreatPropList(const FileCreatPropList& orig); + // Copy constructor: same as the original FileCreatPropList. + FileCreatPropList(const FileCreatPropList &orig); - // Creates a copy of an existing file create property list - // using the property list id. - FileCreatPropList(const hid_t plist_id); + // Creates a copy of an existing file create property list + // using the property list id. + FileCreatPropList(const hid_t plist_id); - // Noop destructor - virtual ~FileCreatPropList(); + // Noop destructor + virtual ~FileCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static FileCreatPropList* DEFAULT_; + private: + static FileCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static FileCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static FileCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of FileCreatPropList } // namespace H5 -#endif // __H5FileCreatPropList_H +#endif // H5FileCreatPropList_H diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 07d7e847f39..9a6f191f70f 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -6,16 +6,12 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include #include "H5Include.h" @@ -41,15 +37,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function H5File default constructor ///\brief Default constructor: creates a stub H5File object. // December 2000 //-------------------------------------------------------------------------- -H5File::H5File() : Group(), id(H5I_INVALID_HID) {} +H5File::H5File() : Group(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: H5File overloaded constructor @@ -81,11 +79,14 @@ H5File::H5File() : Group(), id(H5I_INVALID_HID) {} // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name, flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -106,11 +107,14 @@ H5File::H5File(const char* name, unsigned int flags, const FileCreatPropList& cr // block here to catch then re-throw it. -BMR 2013/03/21 // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) : Group(), id(H5I_INVALID_HID) +H5File::H5File(const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); - } catch (FileIException& open_file) { + } + catch (FileIException &open_file) { throw open_file; } } @@ -123,26 +127,26 @@ H5File::H5File(const H5std_string& name, unsigned int flags, const FileCreatProp // - removed H5F_ACC_CREAT because H5Fcreate will fail with // H5F_ACC_CREAT. - BMR, Sep 17, 2014 //-------------------------------------------------------------------------- -void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist) +void +H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist) { // These bits only set for creation, so if any of them are set, // create the file. - if (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) - { + if (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC)) { hid_t create_plist_id = create_plist.getId(); hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate(name, flags, create_plist_id, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fcreate(name, flags, create_plist_id, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fcreate failed"); } } // Open the file if none of the bits above are set. - else - { + else { hid_t access_plist_id = access_plist.getId(); - id = H5Fopen(name, flags, access_plist_id); - if (id < 0) // throw an exception when open/create fail + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open/create fail { throw FileIException("H5File constructor", "H5Fopen failed"); } @@ -176,7 +180,7 @@ H5File::H5File(hid_t existing_id) : Group() ///\param original - IN: H5File instance to copy // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5File& original) : Group() +H5File::H5File(const H5File &original) : Group(original) { id = original.getId(); incRefCount(); // increment number of references to this id @@ -190,18 +194,20 @@ H5File::H5File(const H5File& original) : Group() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const char* name) +bool +H5File::isHdf5(const char *name) { - // Calls C routine H5Fis_hdf5 to determine whether the file is in + // Calls C routine H5Fis_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value - htri_t ret_value = H5Fis_hdf5(name); + htri_t ret_value = H5Fis_accessible(name, H5P_DEFAULT); + if (ret_value > 0) return true; else if (ret_value == 0) return false; - else // Raise exception when H5Fis_hdf5 returns a negative value + else // Raise exception when H5Fis_accessible returns a negative value { - throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value"); + throw FileIException("H5File::isHdf5", "H5Fis_accessible returned negative value"); } } @@ -212,9 +218,52 @@ bool H5File::isHdf5(const char* name) ///\param name - IN: Name of the file - \c H5std_string // December 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const H5std_string& name) +bool +H5File::isHdf5(const H5std_string &name) +{ + return (isHdf5(name.c_str())); +} + +//-------------------------------------------------------------------------- +// Function: H5File::isAccessible (static) +///\brief Determines whether a file can be accessed as HDF5. (Static) +///\param name - IN: Name of the file +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT +///\return true if the file can be accessed as HDF5, and false, otherwise +///\exception H5::FileIException +// September 2018 +//-------------------------------------------------------------------------- +bool +H5File::isAccessible(const char *name, const FileAccPropList &access_plist) +{ + // Calls C routine H5Fis_accessible to determine whether the file is in + // HDF5 format. It returns positive value, 0, or negative value + hid_t access_plist_id = access_plist.getId(); + htri_t ret_value = H5Fis_accessible(name, access_plist_id); + if (ret_value > 0) + return true; + else if (ret_value == 0) + return false; + else // Raise exception when H5Fis_accessible returns a negative value + { + throw FileIException("H5File::isAccessible", "H5Fis_accessible returned negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: H5File::isAccessible (static) +///\brief This is an overloaded member function, provided for convenience. +/// It takes an \c H5std_string for \a name. (Static) +///\param name - IN: Name of the file - \c H5std_string +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT +// September 2018 +//-------------------------------------------------------------------------- +bool +H5File::isAccessible(const H5std_string &name, const FileAccPropList &access_plist) { - return(isHdf5( name.c_str())); + return (isAccessible(name.c_str(), access_plist)); } //-------------------------------------------------------------------------- @@ -235,18 +284,19 @@ bool H5File::isHdf5(const H5std_string& name) /// // October 2005 //-------------------------------------------------------------------------- -void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const char *name, unsigned int flags, const FileAccPropList &access_plist) { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::openFile", close_error.getDetailMsg()); } hid_t access_plist_id = access_plist.getId(); - id = H5Fopen (name, flags, access_plist_id); - if (id < 0) // throw an exception when open fails + id = H5Fopen(name, flags, access_plist_id); + if (id < 0) // throw an exception when open fails { throw FileIException("H5File::openFile", "H5Fopen failed"); } @@ -262,7 +312,8 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis /// FileAccPropList::DEFAULT // December 2000 //-------------------------------------------------------------------------- -void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAccPropList& access_plist) +void +H5File::openFile(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist) { openFile(name.c_str(), flags, access_plist); } @@ -283,12 +334,13 @@ void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAc // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void H5File::reOpen() +void +H5File::reOpen() { try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } @@ -306,19 +358,18 @@ void H5File::reOpen() ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileCreatPropList H5File::getCreatePlist() const +FileCreatPropList +H5File::getCreatePlist() const { hid_t create_plist_id = H5Fget_create_plist(id); // if H5Fget_create_plist returns a valid id, create and return // the FileCreatPropList object for this property list - if (create_plist_id > 0) - { - FileCreatPropList create_plist(create_plist_id); - return(create_plist); + if (create_plist_id > 0) { + FileCreatPropList create_plist(create_plist_id); + return (create_plist); } - else - { + else { throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed"); } } @@ -330,16 +381,16 @@ FileCreatPropList H5File::getCreatePlist() const ///\exception H5::FileIException // December 2000 //-------------------------------------------------------------------------- -FileAccPropList H5File::getAccessPlist() const +FileAccPropList +H5File::getAccessPlist() const { hid_t access_plist_id = H5Fget_access_plist(id); // if H5Fget_access_plist returns a valid id, create and return // the FileAccPropList object for this property list - if (access_plist_id > 0) - { - FileAccPropList access_plist(access_plist_id); - return access_plist; + if (access_plist_id > 0) { + FileAccPropList access_plist(access_plist_id); + return access_plist; } else // Raise an exception { @@ -357,11 +408,11 @@ FileAccPropList H5File::getAccessPlist() const /// superblock extension, free space management, and shared object // February 2017 //-------------------------------------------------------------------------- -void H5File::getFileInfo(H5F_info2_t& file_info) const +void +H5File::getFileInfo(H5F_info2_t &file_info) const { herr_t ret_value = H5Fget_info2(id, &file_info); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed"); } } @@ -373,17 +424,16 @@ void H5File::getFileInfo(H5F_info2_t& file_info) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -hssize_t H5File::getFreeSpace() const +hssize_t +H5File::getFreeSpace() const { hssize_t free_space = H5Fget_freespace(id); - if (free_space < 0) - { + if (free_space < 0) { throw FileIException("H5File::getFreeSpace", "H5Fget_freespace failed"); } return (free_space); } - //-------------------------------------------------------------------------- // Function: H5File::getObjCount ///\brief Returns the number of opened object IDs (files, datasets, @@ -405,11 +455,11 @@ hssize_t H5File::getFreeSpace() const /// Multiple object types can be combined with the logical OR operator (|). // May 2004 //-------------------------------------------------------------------------- -ssize_t H5File::getObjCount(unsigned types) const +ssize_t +H5File::getObjCount(unsigned types) const { ssize_t num_objs = H5Fget_obj_count(id, types); - if (num_objs < 0) - { + if (num_objs < 0) { throw FileIException("H5File::getObjCount", "H5Fget_obj_count failed"); } return (num_objs); @@ -440,11 +490,11 @@ ssize_t H5File::getObjCount(unsigned types) const // Notes: will do the overload for this one after hearing from Quincey??? // May 2004 //-------------------------------------------------------------------------- -void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const +void +H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const { ssize_t ret_value = H5Fget_obj_ids(id, types, max_objs, oid_list); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getObjIDs", "H5Fget_obj_ids failed"); } } @@ -468,12 +518,12 @@ void H5File::getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const /// closed and reopened or opened during a subsequent session. // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const +void +H5File::getVFDHandle(const FileAccPropList &fapl, void **file_handle) const { - hid_t fapl_id = fapl.getId(); + hid_t fapl_id = fapl.getId(); herr_t ret_value = H5Fget_vfd_handle(id, fapl_id, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -493,7 +543,7 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const +// void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) const //{ // getVFDHandle((const FileAccPropList)fapl, file_handle); //} @@ -508,11 +558,11 @@ void H5File::getVFDHandle(const FileAccPropList& fapl, void **file_handle) const ///\exception H5::FileIException // May 2004 //-------------------------------------------------------------------------- -void H5File::getVFDHandle(void **file_handle) const +void +H5File::getVFDHandle(void **file_handle) const { herr_t ret_value = H5Fget_vfd_handle(id, H5P_DEFAULT, file_handle); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::getVFDHandle", "H5Fget_vfd_handle failed"); } } @@ -527,17 +577,38 @@ void H5File::getVFDHandle(void **file_handle) const /// order to learn the true size of the underlying file. // Programmer Raymond Lu - June 24, 2004 //-------------------------------------------------------------------------- -hsize_t H5File::getFileSize() const +hsize_t +H5File::getFileSize() const { hsize_t file_size; - herr_t ret_value = H5Fget_filesize(id, &file_size); - if (ret_value < 0) - { + herr_t ret_value = H5Fget_filesize(id, &file_size); + if (ret_value < 0) { throw FileIException("H5File::getFileSize", "H5Fget_filesize failed"); } return (file_size); } +//-------------------------------------------------------------------------- +// Function: H5File::getFileNum +///\brief Returns the file number of the HDF5 file. +///\return File number +///\exception H5::FileIException +///\par Description +/// This function is called after an existing file is opened in +/// order to retrieve the unique 'file number' for the file. +// Programmer Quincey Koziol - April 13, 2019 +//-------------------------------------------------------------------------- +unsigned long +H5File::getFileNum() const +{ + unsigned long fileno = 0; + herr_t ret_value = H5Fget_fileno(id, &fileno); + if (ret_value < 0) { + throw FileIException("H5File::getFileNum", "H5Fget_fileno failed"); + } + return (fileno); +} + //-------------------------------------------------------------------------- // Function: H5File::getId ///\brief Get the id of this file @@ -550,9 +621,10 @@ hsize_t H5File::getFileSize() const // IdComponent::getId now becomes pure virtual function. // May, 2008 //-------------------------------------------------------------------------- -hid_t H5File::getId() const +hid_t +H5File::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -564,7 +636,8 @@ hid_t H5File::getId() const // This function is replaced by the above function reOpen. // December 2000 //-------------------------------------------------------------------------- -void H5File::reopen() +void +H5File::reopen() { H5File::reOpen(); } @@ -581,9 +654,10 @@ void H5File::reopen() // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t H5File::getLocId() const +hid_t +H5File::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -598,13 +672,14 @@ hid_t H5File::getLocId() const // Then the object's id is reset to the new id. // December 2000 //-------------------------------------------------------------------------- -void H5File::p_setId(const hid_t new_id) +void +H5File::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& E) { + catch (Exception &E) { throw FileIException("H5File::p_setId", E.getDetailMsg()); } // reset object's id to the given id @@ -619,13 +694,12 @@ void H5File::p_setId(const hid_t new_id) ///\exception H5::FileIException // March 2005 //-------------------------------------------------------------------------- -void H5File::close() +void +H5File::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Fclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw FileIException("H5File::close", "H5Fclose failed"); } // reset the id @@ -646,7 +720,8 @@ void H5File::close() // an implementation of H5File. // December 2000 //-------------------------------------------------------------------------- -void H5File::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5File::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "H5File::"); @@ -667,9 +742,10 @@ H5File::~H5File() { try { close(); - } catch (Exception& close_error) { + } + catch (Exception &close_error) { cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 473428a27d5..6126eec455c 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5File_H -#define __H5File_H +#ifndef H5File_H +#define H5File_H namespace H5 { @@ -23,104 +23,117 @@ namespace H5 { */ // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP H5File : public Group { - public: - // 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); - H5File(const H5std_string& name, unsigned int flags, - const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + public: + // 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); + H5File(const H5std_string &name, unsigned int flags, + const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, + const FileAccPropList & access_plist = FileAccPropList::DEFAULT); - // Open the file - void openFile(const H5std_string& name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); - void openFile(const char* name, unsigned int flags, - const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + // Open the file + void openFile(const H5std_string &name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + void openFile(const char *name, unsigned int flags, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - // Close this file. - virtual void close(); + // Close this file. + virtual void close() H5_OVERRIDE; - // Gets a copy of the access property list of this file. - FileAccPropList getAccessPlist() const; + // Gets a copy of the access property list of this file. + FileAccPropList getAccessPlist() const; - // Gets a copy of the creation property list of this file. - FileCreatPropList getCreatePlist() const; + // Gets a copy of the creation property list of this file. + FileCreatPropList getCreatePlist() const; - // Gets general information about this file. - void getFileInfo(H5F_info2_t& file_info) const; + // Gets general information about this file. + void getFileInfo(H5F_info2_t &file_info) const; - // Returns the amount of free space in the file. - hssize_t getFreeSpace() const; + // Returns the amount of free space in the file. + hssize_t getFreeSpace() const; - // Returns the number of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; + // Returns the number of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const; - // Retrieves a list of opened object IDs (files, datasets, groups - // and datatypes) in the same file. - void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; + // Retrieves a list of opened object IDs (files, datasets, groups + // and datatypes) in the same file. + void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const; - // Returns the pointer to the file handle of the low-level file driver. - void getVFDHandle(void **file_handle) const; - void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; - //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 + // Returns the pointer to the file handle of the low-level file driver. + void getVFDHandle(void **file_handle) const; + void getVFDHandle(const FileAccPropList &fapl, void **file_handle) const; + // void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1 - // Returns the file size of the HDF5 file. - hsize_t getFileSize() const; + // Returns the file size of the HDF5 file. + hsize_t getFileSize() const; - // Determines if a file, specified by its name, is in HDF5 format - static bool isHdf5(const char* name); - static bool isHdf5(const H5std_string& name); + // Returns the 'file number' of the HDF5 file. + unsigned long getFileNum() const; - // Reopens this file. - void reOpen(); // added for better name + // Determines if a file, specified by its name, is in HDF5 format + static bool isHdf5(const char *name); + 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, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + static bool isAccessible(const H5std_string & name, + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + + // Reopens this file. + void reOpen(); // added for better name #ifndef DOXYGEN_SHOULD_SKIP_THIS - void reopen(); // obsolete in favor of reOpen() + void reopen(); // obsolete in favor of reOpen() - // Creates an H5File using an existing file id. Not recommended - // in applications. - H5File(hid_t existing_id); + // Creates an H5File using an existing file id. Not recommended + // in applications. + H5File(hid_t existing_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("H5File"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("H5File"); + } - // Throw file exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw file exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE; - // For CommonFG to get the file id. - virtual hid_t getLocId() const; + // For CommonFG to get the file id. + virtual hid_t getLocId() const H5_OVERRIDE; - // Default constructor - H5File(); + // Default constructor + H5File(); - // Copy constructor: same as the original H5File. - H5File(const H5File& original); + // Copy constructor: same as the original H5File. + H5File(const H5File &original); - // Gets the HDF5 file id. - virtual hid_t getId() const; + // Gets the HDF5 file id. + virtual hid_t getId() const H5_OVERRIDE; - // H5File destructor. - virtual ~H5File(); + // H5File destructor. + virtual ~H5File(); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the HDF5 file id. - virtual void p_setId(const hid_t new_id); + // Sets the HDF5 file id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 file id + private: + hid_t id; // HDF5 file id - // This function is private and contains common code between the - // constructors taking a string or a char* - void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist); + // This function is private and contains common code between the + // constructors taking a string or a char* + void p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist, + const FileAccPropList &access_plist); }; // end of H5File } // namespace H5 -#endif // __H5File_H - +#endif // H5File_H diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index aba826e4d98..33f83770844 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -40,7 +40,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub floating-point datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType() {} +FloatType::FloatType() +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -49,7 +51,7 @@ FloatType::FloatType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const PredType& pred_type) : AtomType() +FloatType::FloatType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -63,14 +65,18 @@ FloatType::FloatType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const hid_t existing_id) : AtomType( existing_id ) {} +FloatType::FloatType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: FloatType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const FloatType& original) : AtomType( original ){} +FloatType::FloatType(const FloatType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: FloatType overloaded constructor @@ -80,13 +86,12 @@ FloatType::FloatType(const FloatType& original) : AtomType( original ){} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::FloatType(const DataSet& dataset) : AtomType() +FloatType::FloatType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("FloatType constructor", "H5Dget_type failed"); } } @@ -105,7 +110,7 @@ FloatType::FloatType(const DataSet& dataset) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +129,7 @@ FloatType::FloatType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +FloatType::FloatType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +142,8 @@ FloatType::FloatType(const H5Location& loc, const H5std_string& dtype_name) : At ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* FloatType::decode() const +DataType * +FloatType::decode() const { hid_t encoded_flttype_id = H5I_INVALID_HID; try { @@ -148,7 +154,7 @@ DataType* FloatType::decode() const } FloatType *encoded_flttype = new FloatType; encoded_flttype->p_setId(encoded_flttype_id); - return(encoded_flttype); + return (encoded_flttype); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ DataType* FloatType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const +void +FloatType::getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const { herr_t ret_value = H5Tget_fields(id, &spos, &epos, &esize, &mpos, &msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed"); } } @@ -183,11 +189,11 @@ void FloatType::getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpo ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const +void +FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const { herr_t ret_value = H5Tset_fields(id, spos, epos, esize, mpos, msize); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed"); } } @@ -199,15 +205,15 @@ void FloatType::setFields(size_t spos, size_t epos, size_t esize, size_t mpos, s ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -size_t FloatType::getEbias() const +size_t +FloatType::getEbias() const { size_t ebias = H5Tget_ebias(id); // Returns the bias if successful - if (ebias == 0) - { + if (ebias == 0) { throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0"); } - return(ebias); + return (ebias); } //-------------------------------------------------------------------------- @@ -217,11 +223,11 @@ size_t FloatType::getEbias() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setEbias(size_t ebias) const +void +FloatType::setEbias(size_t ebias) const { herr_t ret_value = H5Tset_ebias(id, ebias); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed"); } } @@ -241,12 +247,12 @@ void FloatType::setEbias(size_t ebias) const /// \a norm_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const +H5T_norm_t +FloatType::getNorm(H5std_string &norm_string) const { - H5T_norm_t norm = H5Tget_norm(id); // C routine + H5T_norm_t norm = H5Tget_norm(id); // C routine // Returns a valid normalization type if successful - if (norm == H5T_NORM_ERROR) - { + if (norm == H5T_NORM_ERROR) { throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR"); } if (norm == H5T_NORM_IMPLIED) @@ -255,7 +261,7 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const norm_string = "H5T_NORM_MSBSET (1)"; else if (norm == H5T_NORM_NONE) norm_string = "H5T_NORM_NONE (2)"; - return(norm); + return (norm); } //-------------------------------------------------------------------------- @@ -270,11 +276,11 @@ H5T_norm_t FloatType::getNorm(H5std_string& norm_string) const /// \li \c H5T_NORM_NONE (2) - Mantissa is not normalized // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setNorm(H5T_norm_t norm) const +void +FloatType::setNorm(H5T_norm_t norm) const { herr_t ret_value = H5Tset_norm(id, norm); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed"); } } @@ -294,12 +300,12 @@ void FloatType::setNorm(H5T_norm_t norm) const /// \a pad_string. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const +H5T_pad_t +FloatType::getInpad(H5std_string &pad_string) const { H5T_pad_t pad_type = H5Tget_inpad(id); // Returns a valid padding type if successful - if (pad_type == H5T_PAD_ERROR) - { + if (pad_type == H5T_PAD_ERROR) { throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR"); } if (pad_type == H5T_PAD_ZERO) @@ -308,7 +314,7 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const pad_string = "H5T_PAD_ONE (1)"; else if (pad_type == H5T_PAD_BACKGROUND) pad_string = "H5T_PAD_BACKGROUD (2)"; - return(pad_type); + return (pad_type); } //-------------------------------------------------------------------------- @@ -328,11 +334,11 @@ H5T_pad_t FloatType::getInpad(H5std_string& pad_string) const /// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void FloatType::setInpad(H5T_pad_t inpad) const +void +FloatType::setInpad(H5T_pad_t inpad) const { herr_t ret_value = H5Tset_inpad(id, inpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed"); } } @@ -342,6 +348,8 @@ void FloatType::setInpad(H5T_pad_t inpad) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -FloatType::~FloatType() {} +FloatType::~FloatType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index f74a9ae623b..c76be955a68 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5FloatType_H -#define __H5FloatType_H +#ifndef H5FloatType_H +#define H5FloatType_H namespace H5 { @@ -23,61 +23,65 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP FloatType : public AtomType { - public: - // Creates a floating-point type using a predefined type. - FloatType(const PredType& pred_type); + public: + // Creates a floating-point type using a predefined type. + FloatType(const PredType &pred_type); - // Gets the floating-point datatype of the specified dataset. - FloatType(const DataSet& dataset); + // Gets the floating-point datatype of the specified dataset. + FloatType(const DataSet &dataset); - // Constructors that open an HDF5 float datatype, given a location. - FloatType(const H5Location& loc, const char* name); - FloatType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 float datatype, given a location. + FloatType(const H5Location &loc, const char *name); + FloatType(const H5Location &loc, const H5std_string &name); - // Returns an FloatType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an FloatType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the exponent bias of a floating-point type. - size_t getEbias() const; + // Retrieves the exponent bias of a floating-point type. + size_t getEbias() const; - // Sets the exponent bias of a floating-point type. - void setEbias(size_t ebias) const; + // Sets the exponent bias of a floating-point type. + void setEbias(size_t ebias) const; - // Retrieves floating point datatype bit field information. - void getFields(size_t& spos, size_t& epos, size_t& esize, size_t& mpos, size_t& msize) const; + // Retrieves floating point datatype bit field information. + void getFields(size_t &spos, size_t &epos, size_t &esize, size_t &mpos, size_t &msize) const; - // Sets locations and sizes of floating point bit fields. - void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; + // Sets locations and sizes of floating point bit fields. + void setFields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) const; - // Retrieves the internal padding type for unused bits in floating-point datatypes. - H5T_pad_t getInpad(H5std_string& pad_string) const; + // Retrieves the internal padding type for unused bits in floating-point datatypes. + H5T_pad_t getInpad(H5std_string &pad_string) const; - // Fills unused internal floating point bits. - void setInpad(H5T_pad_t inpad) const; + // Fills unused internal floating point bits. + void setInpad(H5T_pad_t inpad) const; - // Retrieves mantissa normalization of a floating-point datatype. - H5T_norm_t getNorm(H5std_string& norm_string) const; + // Retrieves mantissa normalization of a floating-point datatype. + H5T_norm_t getNorm(H5std_string &norm_string) const; - // Sets the mantissa normalization of a floating-point datatype. - void setNorm(H5T_norm_t norm) const; + // Sets the mantissa normalization of a floating-point datatype. + void setNorm(H5T_norm_t norm) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("FloatType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("FloatType"); + } - // Default constructor - FloatType(); + // Default constructor + FloatType(); - // Creates a floating-point datatype using an existing id. - FloatType(const hid_t existing_id); + // Creates a floating-point datatype using an existing id. + FloatType(const hid_t existing_id); - // Copy constructor: same as the original FloatType. - FloatType(const FloatType& original); + // Copy constructor: same as the original FloatType. + FloatType(const FloatType &original); - // Noop destructor. - virtual ~FloatType(); + // Noop destructor. + virtual ~FloatType(); }; // end of FloatType } // namespace H5 -#endif // __H5FloatType_H +#endif // H5FloatType_H diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 7132bdf6ab2..fe791dae9df 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -6,16 +6,12 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include #include "H5Include.h" @@ -42,15 +38,17 @@ #include "H5Alltypes.h" namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; //-------------------------------------------------------------------------- // Function: Group default constructor ///\brief Default constructor: creates a stub Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} +Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) +{ +} //-------------------------------------------------------------------------- // Function: Group copy constructor @@ -58,7 +56,7 @@ Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {} ///\param original - IN: Original group to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) +Group::Group(const Group &original) : H5Object(), CommonFG(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -70,11 +68,11 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -void Group::closeObjId(hid_t obj_id) const +void +Group::closeObjId(hid_t obj_id) const { herr_t ret_value = H5Oclose(obj_id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::closeObjId", "H5Oclose failed"); } } @@ -91,9 +89,10 @@ void Group::closeObjId(hid_t obj_id) const // After HDFFV-9920, the Group's methods can use getId() and // getLocId() is kept for backward compatibility. //-------------------------------------------------------------------------- -hid_t Group::getLocId() const +hid_t +Group::getLocId() const { - return(getId()); + return (getId()); } //-------------------------------------------------------------------------- @@ -120,7 +119,8 @@ Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id) /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), CommonFG(), id(H5I_INVALID_HID) +Group::Group(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) + : H5Object(), CommonFG(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -132,12 +132,13 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t Group::getNumObjs() const +hsize_t +Group::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -155,14 +156,14 @@ hsize_t Group::getNumObjs() const /// the object's type. // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const char* obj_name, const PropList& plist) const +hid_t +Group::getObjId(const char *obj_name, const PropList &plist) const { hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::getObjId", "H5Oopen failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -175,9 +176,10 @@ hid_t Group::getObjId(const char* obj_name, const PropList& plist) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - March, 2017 //-------------------------------------------------------------------------- -hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const +hid_t +Group::getObjId(const H5std_string &obj_name, const PropList &plist) const { - return(getObjId(obj_name.c_str(), plist)); + return (getObjId(obj_name.c_str(), plist)); } //-------------------------------------------------------------------------- @@ -192,9 +194,10 @@ hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t Group::getId() const +hid_t +Group::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -210,13 +213,14 @@ hid_t Group::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::p_setId(const hid_t new_id) +void +Group::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throwException("Group::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -231,13 +235,12 @@ void Group::p_setId(const hid_t new_id) ///\exception H5::GroupIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Group::close() +void +Group::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Gclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("Group::close", "H5Gclose failed"); } // reset the id @@ -258,7 +261,8 @@ void Group::close() // an implementation of Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Group::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +Group::throwException(const H5std_string &func_name, const H5std_string &msg) const { H5std_string full_name = func_name; full_name.insert(0, "Group::"); @@ -280,9 +284,9 @@ Group::~Group() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 70b6bfffeff..b5f7e51110d 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __Group_H -#define __Group_H +#ifndef H5Group_H +#define H5Group_H namespace H5 { @@ -22,59 +22,65 @@ namespace H5 { */ // Inheritance: CommonFG/H5Object -> H5Location -> IdComponent class H5_DLLCPP Group : public H5Object, public CommonFG { - public: - // Close this group. - virtual void close(); + public: + // Close this group. + virtual void close() H5_OVERRIDE; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("Group"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const H5_OVERRIDE + { + return ("Group"); + } - // Throw group exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; + // Throw group exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE; - // for CommonFG to get the file id. - virtual hid_t getLocId() const; + // for CommonFG to get the file id. + virtual hid_t getLocId() const H5_OVERRIDE; - // Creates a group by way of dereference. - Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass -// Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Creates a group by way of dereference. + Group(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& + // plist = PropList::DEFAULT); - // Returns the number of objects in this group. - hsize_t getNumObjs() const; + // Returns the number of objects in this group. + hsize_t getNumObjs() const; - // Opens an object within a group or a file, i.e., root group. - hid_t getObjId(const char* name, const PropList& plist = PropList::DEFAULT) const; - hid_t getObjId(const H5std_string& name, const PropList& plist = PropList::DEFAULT) const; + // Opens an object within a group or a file, i.e., root group. + hid_t getObjId(const char *name, const PropList &plist = PropList::DEFAULT) const; + hid_t getObjId(const H5std_string &name, const PropList &plist = PropList::DEFAULT) const; - // Closes an object opened by getObjId(). - void closeObjId(hid_t obj_id) const; + // Closes an object opened by getObjId(). + void closeObjId(hid_t obj_id) const; - // default constructor - Group(); + // default constructor + Group(); - // Copy constructor: same as the original Group. - Group(const Group& original); + // Copy constructor: same as the original Group. + Group(const Group &original); - // Gets the group id. - virtual hid_t getId() const; + // Gets the group id. + virtual hid_t getId() const H5_OVERRIDE; - // Destructor - virtual ~Group(); + // Destructor + virtual ~Group() H5_OVERRIDE; - // Creates a copy of an existing group using its id. - Group(const hid_t group_id); + // Creates a copy of an existing group using its id. + Group(const hid_t group_id); - protected: + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Sets the group id. - virtual void p_setId(const hid_t new_id); + // Sets the group id. + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS - private: - hid_t id; // HDF5 group id + private: + hid_t id; // HDF5 group id }; // end of Group } // namespace H5 -#endif // __Group_H +#endif // H5Group_H diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index a0412737580..18bcbd3c870 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -6,14 +6,14 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5Library.h" @@ -38,7 +38,8 @@ bool IdComponent::H5dontAtexit_called = false; ///\brief Increment reference counter for a given id. // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -void IdComponent::incRefCount(const hid_t obj_id) const +void +IdComponent::incRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) if (H5Iinc_ref(obj_id) < 0) @@ -50,7 +51,8 @@ void IdComponent::incRefCount(const hid_t obj_id) const ///\brief Increment reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::incRefCount() const +void +IdComponent::incRefCount() const { incRefCount(getId()); } @@ -63,17 +65,15 @@ void IdComponent::incRefCount() const // Added the check for ref counter to give a little more info // on why H5Idec_ref fails in some cases - BMR 5/19/2005 //-------------------------------------------------------------------------- -void IdComponent::decRefCount(const hid_t obj_id) const +void +IdComponent::decRefCount(const hid_t obj_id) const { if (p_valid_id(obj_id)) - if (H5Idec_ref(obj_id) < 0) - { + if (H5Idec_ref(obj_id) < 0) { if (H5Iget_ref(obj_id) <= 0) - throw IdComponentException(inMemFunc("decRefCount"), - "object ref count is 0 or negative"); + throw IdComponentException(inMemFunc("decRefCount"), "object ref count is 0 or negative"); else - throw IdComponentException(inMemFunc("decRefCount"), - "decrementing object ref count failed"); + throw IdComponentException(inMemFunc("decRefCount"), "decrementing object ref count failed"); } } @@ -82,7 +82,8 @@ void IdComponent::decRefCount(const hid_t obj_id) const ///\brief Decrement reference counter for the id of this object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IdComponent::decRefCount() const +void +IdComponent::decRefCount() const { decRefCount(getId()); } @@ -93,14 +94,15 @@ void IdComponent::decRefCount() const ///\return Reference count // Programmer Binh-Minh Ribler - May 2005 //-------------------------------------------------------------------------- -int IdComponent::getCounter(const hid_t obj_id) const +int +IdComponent::getCounter(const hid_t obj_id) const { int counter = 0; - if (p_valid_id(obj_id)) - { + if (p_valid_id(obj_id)) { counter = H5Iget_ref(obj_id); if (counter < 0) - throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative"); + throw IdComponentException(inMemFunc("incRefCount"), + "getting object ref count failed - negative"); } return (counter); } @@ -111,7 +113,8 @@ int IdComponent::getCounter(const hid_t obj_id) const ///\return Reference count // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int IdComponent::getCounter() const +int +IdComponent::getCounter() const { return (getCounter(getId())); } @@ -130,7 +133,8 @@ int IdComponent::getCounter() const /// input object id is invalid. // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) +H5I_type_t +IdComponent::getHDFObjType(const hid_t obj_id) { if (obj_id <= 0) return H5I_BADID; // invalid @@ -156,9 +160,10 @@ H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) /// input object id is invalid. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5I_type_t IdComponent::getHDFObjType() const +H5I_type_t +IdComponent::getHDFObjType() const { - return(getHDFObjType(getId())); + return (getHDFObjType(getId())); } //-------------------------------------------------------------------------- @@ -174,8 +179,8 @@ H5I_type_t IdComponent::getHDFObjType() const /// \li \c H5I_DATASPACE /// \li \c H5I_DATASET /// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE (DEPRECATED) /// \li \c H5I_VFL +/// \li \c H5I_VOL /// \li \c H5I_GENPROP_CLS /// \li \c H5I_GENPROP_LST /// \li \c H5I_ERROR_CLASS @@ -183,14 +188,15 @@ H5I_type_t IdComponent::getHDFObjType() const /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -hsize_t IdComponent::getNumMembers(H5I_type_t type) +hsize_t +IdComponent::getNumMembers(H5I_type_t type) { - hsize_t nmembers = 0; - herr_t ret_value = H5Inmembers(type, &nmembers); + hsize_t nmembers = 0; + herr_t ret_value = H5Inmembers(type, &nmembers); if (ret_value < 0) throw IdComponentException("getNumMembers", "H5Inmembers failed"); else - return(nmembers); + return (nmembers); } //-------------------------------------------------------------------------- @@ -202,7 +208,8 @@ hsize_t IdComponent::getNumMembers(H5I_type_t type) /// reference count of at least 1. // Programmer Binh-Minh Ribler - Mar 1, 2017 //-------------------------------------------------------------------------- -bool IdComponent::isValid(hid_t an_id) +bool +IdComponent::isValid(hid_t an_id) { // Call C function htri_t ret_value = H5Iis_valid(an_id); @@ -227,8 +234,8 @@ bool IdComponent::isValid(hid_t an_id) /// \li \c H5I_DATASPACE /// \li \c H5I_DATASET /// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE (DEPRECATED) /// \li \c H5I_VFL +/// \li \c H5I_VOL /// \li \c H5I_GENPROP_CLS /// \li \c H5I_GENPROP_LST /// \li \c H5I_ERROR_CLASS @@ -236,7 +243,8 @@ bool IdComponent::isValid(hid_t an_id) /// \li \c H5I_ERROR_STACK // Programmer Binh-Minh Ribler - Feb, 2017 //-------------------------------------------------------------------------- -bool IdComponent::typeExists(H5I_type_t type) +bool +IdComponent::typeExists(H5I_type_t type) { // Call C function htri_t ret_value = H5Itype_exists(type); @@ -266,17 +274,17 @@ bool IdComponent::typeExists(H5I_type_t type) // care of close() and setId takes care incRefCount(). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent& IdComponent::operator=(const IdComponent& rhs) +IdComponent & +IdComponent::operator=(const IdComponent &rhs) { - if (this != &rhs) - { + if (this != &rhs) { // handling references to this id try { setId(rhs.getId()); // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception& close_error) { + catch (Exception &close_error) { throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); } } @@ -304,7 +312,8 @@ IdComponent& IdComponent::operator=(const IdComponent& rhs) // the id passed to setId is that of another C++ API object, so // setId must call incRefCount. //-------------------------------------------------------------------------- -void IdComponent::setId(const hid_t new_id) +void +IdComponent::setId(const hid_t new_id) { // set to new_id p_setId(new_id); @@ -318,7 +327,9 @@ void IdComponent::setId(const hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IdComponent::~IdComponent() {} +IdComponent::~IdComponent() +{ +} // // Implementation of protected functions for HDF5 Reference Interface @@ -338,7 +349,8 @@ IdComponent::~IdComponent() {} /// an exception is thrown. // Programmer Binh-Minh Ribler - Aug 6, 2005 //-------------------------------------------------------------------------- -H5std_string IdComponent::inMemFunc(const char* func_name) const +H5std_string +IdComponent::inMemFunc(const char *func_name) const { H5std_string full_name = func_name; full_name.insert(0, "::"); @@ -355,8 +367,7 @@ IdComponent::IdComponent() { // initH5cpp will register the terminating functions with atexit(). // This should only be done once. - if (!H5cppinit) - { + if (!H5cppinit) { H5Library::initH5cpp(); H5cppinit = true; } @@ -374,7 +385,8 @@ IdComponent::IdComponent() // inherits from H5Location. // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string IdComponent::p_get_file_name() const +H5std_string +IdComponent::p_get_file_name() const { hid_t temp_id = getId(); @@ -382,28 +394,26 @@ H5std_string IdComponent::p_get_file_name() const ssize_t name_size = H5Fget_name(temp_id, NULL, 0); // If H5Aget_name returns a negative value, raise an exception, - if (name_size < 0) - { + if (name_size < 0) { throw IdComponentException("", "H5Fget_name failed"); } // 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]; // temporary C-string for C API + HDmemset(name_C, 0, name_size + 1); // clear buffer - name_size = H5Fget_name(temp_id, name_C, name_size+1); + name_size = H5Fget_name(temp_id, name_C, name_size + 1); // Check for failure again - if (name_size < 0) - { - delete []name_C; + if (name_size < 0) { + delete[] name_C; throw IdComponentException("", "H5Fget_name failed"); } // Convert the C file name and return H5std_string file_name(name_C); - delete []name_C; - return(file_name); + delete[] name_C; + return (file_name); } // @@ -417,7 +427,8 @@ H5std_string IdComponent::p_get_file_name() const // Return true if id is valid, false, otherwise // Programmer Binh-Minh Ribler - May, 2005 //-------------------------------------------------------------------------- -bool IdComponent::p_valid_id(const hid_t obj_id) +bool +IdComponent::p_valid_id(const hid_t obj_id) { if (obj_id <= 0) return false; @@ -439,4 +450,4 @@ bool IdComponent::p_valid_id(const hid_t obj_id) #endif // DOXYGEN_SHOULD_SKIP_THIS -} +} // namespace H5 diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index b4070b05ac8..383d42d333f 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __IdComponent_H -#define __IdComponent_H +#ifndef H5IdComponent_H +#define H5IdComponent_H namespace H5 { @@ -25,89 +25,92 @@ namespace H5 { rarely needs them. */ class H5_DLLCPP IdComponent { - public: + public: + // Increment reference counter. + void incRefCount(const hid_t obj_id) const; + void incRefCount() const; - // Increment reference counter. - void incRefCount(const hid_t obj_id) const; - void incRefCount() const; + // Decrement reference counter. + void decRefCount(const hid_t obj_id) const; + void decRefCount() const; - // Decrement reference counter. - void decRefCount(const hid_t obj_id) const; - void decRefCount() const; + // Get the reference counter to this identifier. + int getCounter(const hid_t obj_id) const; + int getCounter() const; - // Get the reference counter to this identifier. - int getCounter(const hid_t obj_id) const; - int getCounter() const; + // Returns an HDF5 object type, given the object id. + static H5I_type_t getHDFObjType(const hid_t obj_id); - // Returns an HDF5 object type, given the object id. - static H5I_type_t getHDFObjType(const hid_t obj_id); + // Returns an HDF5 object type of this object. + H5I_type_t getHDFObjType() const; - // Returns an HDF5 object type of this object. - H5I_type_t getHDFObjType() const; + // Returns the number of members in a type. + static hsize_t getNumMembers(H5I_type_t type); - // Returns the number of members in a type. - static hsize_t getNumMembers(H5I_type_t type); + // Checks if the given ID is valid. + static bool isValid(hid_t an_id); - // Checks if the given ID is valid. - static bool isValid(hid_t an_id); + // Determines if an type exists. + static bool typeExists(H5I_type_t type); - // Determines if an type exists. - static bool typeExists(H5I_type_t type); + // Assignment operator. + IdComponent &operator=(const IdComponent &rhs); - // Assignment operator. - IdComponent& operator=(const IdComponent& rhs); - - // Sets the identifier of this object to a new value. - void setId(const hid_t new_id); + // Sets the identifier of this object to a new value. + void setId(const hid_t new_id); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Gets the identifier of this object. - virtual hid_t getId () const = 0; + // Gets the identifier of this object. + virtual hid_t getId() const = 0; - // Pure virtual function for there are various H5*close for the - // subclasses. - virtual void close() = 0; + // Pure virtual function for there are various H5*close for the + // subclasses. + virtual void close() = 0; - // Makes and returns the string "::"; - // is returned by fromClass(). - H5std_string inMemFunc(const char* func_name) const; + // Makes and returns the string "::"; + // is returned by fromClass(). + H5std_string inMemFunc(const char *func_name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass() const { return("IdComponent");} + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IdComponent"); + } #endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor - virtual ~IdComponent(); + // Destructor + virtual ~IdComponent(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor. - IdComponent(); + protected: + // Default constructor. + IdComponent(); - // Gets the name of the file, in which an HDF5 object belongs. - H5std_string p_get_file_name() const; + // Gets the name of the file, in which an HDF5 object belongs. + H5std_string p_get_file_name() const; - // Verifies that the given id is valid. - static bool p_valid_id(const hid_t obj_id); + // Verifies that the given id is valid. + static bool p_valid_id(const hid_t obj_id); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) = 0; - // This flag is used to decide whether H5dont_atexit should be called - static bool H5dontAtexit_called; + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; - private: - // This flag indicates whether H5Library::initH5cpp has been called - // to register various terminating functions with atexit() - static bool H5cppinit; + private: + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() + static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end class IdComponent } // namespace H5 -#endif // __IdComponent_H +#endif // H5IdComponent_H diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index a18043033f4..0dc930dbef5 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -7,34 +7,27 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -// Define bool type for platforms that don't support bool yet -#ifdef BOOL_NOTDEFINED -#ifdef false -#undef false -#endif -#ifdef true -#undef true -#endif -typedef int bool; -const bool false = 0; -const bool true = 1; -#endif - // These are defined in H5Opkg.h, which should not be included in the C++ API, // so re-define them here for now. /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 +#define H5O_VERSION_2 2 +// Define H5_OVERRIDE to override for C++11. +#if defined(__cplusplus) && (201103L <= __cplusplus) +#define H5_OVERRIDE override +#else +#define H5_OVERRIDE +#endif diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 01c20e940d9..27c449165bb 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -40,14 +40,18 @@ namespace H5 { ///\brief Default constructor: Creates a stub integer datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType() {} +IntType::IntType() +{ +} //-------------------------------------------------------------------------- // Function: IntType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const IntType& original) : AtomType( original ) {} +IntType::IntType(const IntType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -56,7 +60,7 @@ IntType::IntType(const IntType& original) : AtomType( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const PredType& pred_type) : AtomType() +IntType::IntType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -70,7 +74,9 @@ IntType::IntType(const PredType& pred_type) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} +IntType::IntType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: IntType overloaded constructor @@ -79,13 +85,12 @@ IntType::IntType(const hid_t existing_id) : AtomType( existing_id ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::IntType(const DataSet& dataset) : AtomType() +IntType::IntType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("IntType constructor", "H5Dget_type failed"); } } @@ -104,7 +109,7 @@ IntType::IntType(const DataSet& dataset) : AtomType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -123,7 +128,7 @@ IntType::IntType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +IntType::IntType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -136,7 +141,8 @@ IntType::IntType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* IntType::decode() const +DataType * +IntType::decode() const { hid_t encoded_inttype_id = H5I_INVALID_HID; try { @@ -147,7 +153,7 @@ DataType* IntType::decode() const } IntType *encoded_inttype = new IntType; encoded_inttype->p_setId(encoded_inttype_id); - return(encoded_inttype); + return (encoded_inttype); } //-------------------------------------------------------------------------- @@ -157,17 +163,17 @@ DataType* IntType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_sign_t IntType::getSign() const +H5T_sign_t +IntType::getSign() const { - H5T_sign_t type_sign = H5Tget_sign(id); // C routine + H5T_sign_t type_sign = H5Tget_sign(id); // C routine // Returns a valid sign type if no errors - if (type_sign == H5T_SGN_ERROR) - { + if (type_sign == H5T_SGN_ERROR) { throw DataTypeIException("IntType::getSign", - "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); + "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type"); } - return(type_sign); + return (type_sign); } //-------------------------------------------------------------------------- @@ -177,12 +183,12 @@ H5T_sign_t IntType::getSign() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void IntType::setSign(H5T_sign_t sign) const +void +IntType::setSign(H5T_sign_t sign) const { // Call C routine to set the sign property herr_t ret_value = H5Tset_sign(id, sign); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("IntType::setSign", "H5Tset_sign failed"); } } @@ -192,6 +198,8 @@ void IntType::setSign(H5T_sign_t sign) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -IntType::~IntType() {} +IntType::~IntType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 496872b2fbe..185c8f0da50 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5IntType_H -#define __H5IntType_H +#ifndef H5IntType_H +#define H5IntType_H namespace H5 { @@ -23,43 +23,47 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP IntType : public AtomType { - public: - // Creates an integer type using a predefined type - IntType(const PredType& pred_type); + public: + // Creates an integer type using a predefined type + IntType(const PredType &pred_type); - // Gets the integer datatype of the specified dataset - IntType(const DataSet& dataset); + // Gets the integer datatype of the specified dataset + IntType(const DataSet &dataset); - // Constructors that open an HDF5 integer datatype, given a location. - IntType(const H5Location& loc, const char* name); - IntType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 integer datatype, given a location. + IntType(const H5Location &loc, const char *name); + IntType(const H5Location &loc, const H5std_string &name); - // Returns an IntType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an IntType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the sign type for an integer type - H5T_sign_t getSign() const; + // Retrieves the sign type for an integer type + H5T_sign_t getSign() const; - // Sets the sign proprety for an integer type. - void setSign(H5T_sign_t sign) const; + // Sets the sign proprety for an integer type. + void setSign(H5T_sign_t sign) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("IntType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("IntType"); + } - // Default constructor - IntType(); + // Default constructor + IntType(); - // Creates a integer datatype using an existing id - IntType(const hid_t existing_id); + // Creates a integer datatype using an existing id + IntType(const hid_t existing_id); - // Copy constructor: same as the original IntType. - IntType(const IntType& original); + // Copy constructor: same as the original IntType. + IntType(const IntType &original); - // Noop destructor. - virtual ~IntType(); + // Noop destructor. + virtual ~IntType(); }; // end of IntType } // namespace H5 -#endif // __H5IntType_H +#endif // H5IntType_H diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index 1905cce362c..feaa555255b 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; +LinkAccPropList *LinkAccPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkAccPropList::getConstant @@ -40,13 +40,13 @@ LinkAccPropList* LinkAccPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList* LinkAccPropList::getConstant() +LinkAccPropList * +LinkAccPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkAccPropList* LinkAccPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkAccPropList(H5P_LINK_ACCESS); else - throw PropListIException("LinkAccPropList::getConstant", "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkAccPropList::getConstant", + "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkAccPropList* LinkAccPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -void LinkAccPropList::deleteConstants() +void +LinkAccPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkAccPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); +const LinkAccPropList &LinkAccPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} +LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList copy constructor @@ -92,7 +96,9 @@ LinkAccPropList::LinkAccPropList() : PropList(H5P_LINK_ACCESS) {} ///\param original - IN: LinkAccPropList instance to copy // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {} +LinkAccPropList::LinkAccPropList(const LinkAccPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList overloaded constructor @@ -100,7 +106,9 @@ LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(ori /// existing one. // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkAccPropList::setNumLinks @@ -111,12 +119,12 @@ LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {} ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -void LinkAccPropList::setNumLinks(size_t nlinks) const +void +LinkAccPropList::setNumLinks(size_t nlinks) const { herr_t ret_value = H5Pset_nlinks(id, nlinks); // Throw exception if H5Pset_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setNumLinks", "H5Pset_nlinks failed"); } } @@ -129,16 +137,16 @@ void LinkAccPropList::setNumLinks(size_t nlinks) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - March 1, 2017 //-------------------------------------------------------------------------- -size_t LinkAccPropList::getNumLinks() const +size_t +LinkAccPropList::getNumLinks() const { - size_t nlinks = 0; + size_t nlinks = 0; herr_t ret_value = H5Pget_nlinks(id, &nlinks); // Throw exception if H5Pget_nlinks returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getNumLinks", "H5Pget_nlinks failed"); } - return(nlinks); + return (nlinks); } //-------------------------------------------------------------------------- @@ -146,6 +154,8 @@ size_t LinkAccPropList::getNumLinks() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -LinkAccPropList::~LinkAccPropList() {} +LinkAccPropList::~LinkAccPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index ec5e54f6a38..4fa516ca60a 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5LinkAccPropList_H -#define __H5LinkAccPropList_H +#ifndef H5LinkAccPropList_H +#define H5LinkAccPropList_H namespace H5 { @@ -23,47 +23,51 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkAccPropList : public PropList { - public: - ///\brief Default link access property list. - static const LinkAccPropList& DEFAULT; + public: + ///\brief Default link access property list. + static const LinkAccPropList &DEFAULT; - // Creates a link access property list. - LinkAccPropList(); + // Creates a link access property list. + LinkAccPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkAccPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkAccPropList"); + } - // Copy constructor: same as the original LinkAccPropList. - LinkAccPropList(const LinkAccPropList& original); + // Copy constructor: same as the original LinkAccPropList. + LinkAccPropList(const LinkAccPropList &original); - // Creates a copy of an existing link access property list - // using the property list id. - LinkAccPropList (const hid_t plist_id); + // Creates a copy of an existing link access property list + // using the property list id. + LinkAccPropList(const hid_t plist_id); - // Sets the number of soft or user-defined links that can be - // traversed before a failure occurs. - void setNumLinks(size_t nlinks) const; + // Sets the number of soft or user-defined links that can be + // traversed before a failure occurs. + void setNumLinks(size_t nlinks) const; - // Gets the number of soft or user-defined link traversals allowed - size_t getNumLinks() const; + // Gets the number of soft or user-defined link traversals allowed + size_t getNumLinks() const; - // Noop destructor - virtual ~LinkAccPropList(); + // Noop destructor + virtual ~LinkAccPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkAccPropList* DEFAULT_; + private: + static LinkAccPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkAccPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkAccPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of LinkAccPropList } // namespace H5 -#endif // __H5LinkAccPropList_H +#endif // H5LinkAccPropList_H diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index bde93391040..29721c18090 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; +LinkCreatPropList *LinkCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: LinkCreatPropList::getConstant @@ -40,13 +40,13 @@ LinkCreatPropList* LinkCreatPropList::DEFAULT_ = 0; // happen. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList* LinkCreatPropList::getConstant() +LinkCreatPropList * +LinkCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ LinkCreatPropList* LinkCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new LinkCreatPropList(H5P_LINK_CREATE); else - throw PropListIException("LinkCreatPropList::getConstant", "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("LinkCreatPropList::getConstant", + "LinkCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ LinkCreatPropList* LinkCreatPropList::getConstant() // exception H5::PropListIException // December, 2016 //-------------------------------------------------------------------------- -void LinkCreatPropList::deleteConstants() +void +LinkCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void LinkCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); +const LinkCreatPropList &LinkCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const LinkCreatPropList& LinkCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} +LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList copy constructor @@ -92,7 +96,9 @@ LinkCreatPropList::LinkCreatPropList() : PropList(H5P_LINK_CREATE) {} ///\param original - IN: LinkCreatPropList instance to copy // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropList(original) {} +LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList overloaded constructor @@ -100,7 +106,9 @@ LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropLi /// existing one. // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: LinkCreatPropList::setCreateIntermediateGroup @@ -111,12 +119,12 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const +void +LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); // Throw exception if H5Pset_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); } } @@ -129,17 +137,17 @@ void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const ///\exception H5::PropListIException // April, 2019 //-------------------------------------------------------------------------- -bool LinkCreatPropList::getCreateIntermediateGroup() const +bool +LinkCreatPropList::getCreateIntermediateGroup() const { unsigned crt_intmd_group; - herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); + herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group); // Throw exception if H5Pget_create_intermediate_group returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return((bool)crt_intmd_group); + return ((bool)crt_intmd_group); } //-------------------------------------------------------------------------- @@ -149,12 +157,12 @@ bool LinkCreatPropList::getCreateIntermediateGroup() const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const +void +LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const { herr_t ret_value = H5Pset_char_encoding(id, encoding); // Throw exception if H5Pset_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("setCharEncoding", "H5Pset_char_encoding failed"); } } @@ -166,16 +174,16 @@ void LinkCreatPropList::setCharEncoding(H5T_cset_t encoding) const ///\exception H5::PropListIException // March, 2018 //-------------------------------------------------------------------------- -H5T_cset_t LinkCreatPropList::getCharEncoding() const +H5T_cset_t +LinkCreatPropList::getCharEncoding() const { H5T_cset_t encoding; - herr_t ret_value = H5Pget_char_encoding(id, &encoding); + herr_t ret_value = H5Pget_char_encoding(id, &encoding); // Throw exception if H5Pget_char_encoding returns failure - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("getCharEncoding", "H5Pget_char_encoding failed"); } - return(encoding); + return (encoding); } //-------------------------------------------------------------------------- @@ -183,6 +191,8 @@ H5T_cset_t LinkCreatPropList::getCharEncoding() const ///\brief Noop destructor // December, 2016 //-------------------------------------------------------------------------- -LinkCreatPropList::~LinkCreatPropList() {} +LinkCreatPropList::~LinkCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5LcreatProp.h b/c++/src/H5LcreatProp.h index 908ef634017..aea38e76b88 100644 --- a/c++/src/H5LcreatProp.h +++ b/c++/src/H5LcreatProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5LinkCreatPropList_H -#define __H5LinkCreatPropList_H +#ifndef H5LinkCreatPropList_H +#define H5LinkCreatPropList_H namespace H5 { @@ -23,54 +23,58 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP LinkCreatPropList : public PropList { - public: - ///\brief Default link creation property list. - static const LinkCreatPropList& DEFAULT; + public: + ///\brief Default link creation property list. + static const LinkCreatPropList &DEFAULT; - // Creates a link creation property list. - LinkCreatPropList(); + // Creates a link creation property list. + LinkCreatPropList(); - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("LinkCreatPropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("LinkCreatPropList"); + } - // Copy constructor: same as the original LinkCreatPropList. - LinkCreatPropList(const LinkCreatPropList& original); + // Copy constructor: same as the original LinkCreatPropList. + LinkCreatPropList(const LinkCreatPropList &original); - // Creates a copy of an existing link creation property list - // using the property list id. - LinkCreatPropList (const hid_t plist_id); + // Creates a copy of an existing link creation property list + // using the property list id. + LinkCreatPropList(const hid_t plist_id); - // Specifies in property list whether to create missing - // intermediate groups - void setCreateIntermediateGroup(bool crt_intmd_group) const; + // Specifies in property list whether to create missing + // intermediate groups + void setCreateIntermediateGroup(bool crt_intmd_group) const; - // Determines whether property is set to enable creating missing - // intermediate groups - bool getCreateIntermediateGroup() const; + // Determines whether property is set to enable creating missing + // intermediate groups + bool getCreateIntermediateGroup() const; - // Sets the character encoding of the string. - void setCharEncoding(H5T_cset_t encoding) const; + // Sets the character encoding of the string. + void setCharEncoding(H5T_cset_t encoding) const; - // Gets the character encoding of the string. - H5T_cset_t getCharEncoding() const; + // Gets the character encoding of the string. + H5T_cset_t getCharEncoding() const; - // Noop destructor - virtual ~LinkCreatPropList(); + // Noop destructor + virtual ~LinkCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static LinkCreatPropList* DEFAULT_; + private: + static LinkCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static LinkCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static LinkCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of LinkCreatPropList } // namespace H5 -#endif // __H5LinkCreatPropList_H +#endif // H5LinkCreatPropList_H diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index fde559958c4..37516be9f43 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,7 +14,7 @@ #include #include -#include "H5CppDoc.h" // included only for Doxygen to generate part of RM +#include "H5CppDoc.h" // included only for Doxygen to generate part of RM #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -44,11 +44,11 @@ namespace H5 { ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::open() +void +H5Library::open() { herr_t ret_value = H5open(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::open", "H5open failed"); } } @@ -60,11 +60,11 @@ void H5Library::open() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::close() +void +H5Library::close() { herr_t ret_value = H5close(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::close", "H5close failed"); } } @@ -79,9 +79,10 @@ void H5Library::close() // Removed the check for failure returned from H5dont_atexit. // will be fixed to not fail (HDFFV-9540) //-------------------------------------------------------------------------- -void H5Library::dontAtExit() +void +H5Library::dontAtExit() { - (void)H5dont_atexit(); + (void)H5dont_atexit(); } //-------------------------------------------------------------------------- @@ -93,11 +94,11 @@ void H5Library::dontAtExit() ///\exception H5::LibraryIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum) +void +H5Library::getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum) { herr_t ret_value = H5get_libversion(&majnum, &minnum, &relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed"); } } @@ -115,11 +116,11 @@ void H5Library::getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& reln /// the H5check_version API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) +void +H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) { herr_t ret_value = H5check_version(majnum, minnum, relnum); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::checkVersion", "H5check_version failed"); } } @@ -144,11 +145,11 @@ void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) /// lists when the application ends. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::garbageCollect() +void +H5Library::garbageCollect() { herr_t ret_value = H5garbage_collect(); - if (ret_value < 0) - { + if (ret_value < 0) { throw LibraryIException("H5Library::garbageCollect", "H5garbage_collect failed"); } } @@ -168,12 +169,13 @@ void H5Library::garbageCollect() // // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::initH5cpp() +void +H5Library::initH5cpp() { // Register terminating functions with atexit(); they will be invoked in // the reversed order int ret_value = 0; - ret_value = std::atexit(termH5cpp); + ret_value = std::atexit(termH5cpp); if (ret_value != 0) throw LibraryIException("H5Library::initH5cpp", "Registering termH5cpp failed"); @@ -187,35 +189,43 @@ void H5Library::initH5cpp() ret_value = std::atexit(DSetAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkAccPropList::deleteConstants failed"); ret_value = std::atexit(LinkCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering LinkCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering LinkCreatPropList::deleteConstants failed"); ret_value = std::atexit(FileAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileAccPropList::deleteConstants failed"); ret_value = std::atexit(FileCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering FileCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering FileCreatPropList::deleteConstants failed"); ret_value = std::atexit(DSetMemXferPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetMemXferPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetMemXferPropList::deleteConstants failed"); ret_value = std::atexit(DSetCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering DSetCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering DSetCreatPropList::deleteConstants failed"); ret_value = std::atexit(ObjCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registering ObjCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", + "Registering ObjCreatPropList::deleteConstants failed"); ret_value = std::atexit(DataSpace::deleteConstants); if (ret_value != 0) @@ -229,7 +239,8 @@ void H5Library::initH5cpp() /// If the C library fails to terminate, exit with a failure. // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- -void H5Library::termH5cpp() +void +H5Library::termH5cpp() { // Close the C library herr_t ret_value = H5close(); @@ -253,13 +264,13 @@ void H5Library::termH5cpp() /// the H5set_free_list_limits API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim) +void +H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim) { - herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, blk_list_lim); - if (ret_value < 0) - { + herr_t ret_value = H5set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, + blk_global_lim, blk_list_lim); + if (ret_value < 0) { throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed"); } } @@ -270,14 +281,18 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, ///\brief Default constructor: Creates a stub H5Library object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::H5Library(){} +H5Library::H5Library() +{ +} //-------------------------------------------------------------------------- // Function: H5Library destructor ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Library::~H5Library(){} +H5Library::~H5Library() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index b9be3d0a0f2..3df8d56d9b3 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Library_H -#define __H5Library_H +#ifndef H5Library_H +#define H5Library_H namespace H5 { @@ -24,50 +24,49 @@ namespace H5 { methods. */ class H5_DLLCPP H5Library { - public: - // Initializes the HDF5 library. - static void open(); + public: + // Initializes the HDF5 library. + static void open(); - // Flushes all data to disk, closes files, and cleans up memory. - static void close(); + // Flushes all data to disk, closes files, and cleans up memory. + static void close(); - // Instructs library not to install atexit cleanup routine - static void dontAtExit(); + // Instructs library not to install atexit cleanup routine + static void dontAtExit(); - // Returns the HDF library release number. - static void getLibVersion(unsigned& majnum, unsigned& minnum, unsigned& relnum); + // Returns the HDF library release number. + static void getLibVersion(unsigned &majnum, unsigned &minnum, unsigned &relnum); - // Verifies that the arguments match the version numbers compiled - // into the library - static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); + // Verifies that the arguments match the version numbers compiled + // into the library + static void checkVersion(unsigned majnum, unsigned minnum, unsigned relnum); - // Walks through all the garbage collection routines for the library, - // which are supposed to free any unused memory they have allocated. - static void garbageCollect(); + // Walks through all the garbage collection routines for the library, + // which are supposed to free any unused memory they have allocated. + static void garbageCollect(); - // Sets limits on the different kinds of free lists. - static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int - arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); + // Sets limits on the different kinds of free lists. + static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim); - // Initializes C++ library and registers terminating functions at exit. - // Only for the library functions, not for user-defined functions. - static void initH5cpp(void); + // Initializes C++ library and registers terminating functions at exit. + // Only for the library functions, not for user-defined functions. + static void initH5cpp(void); - // Sends request for terminating the HDF5 library. - static void termH5cpp(void); + // Sends request for terminating the HDF5 library. + static void termH5cpp(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS - private: + private: + // Default constructor - no instance ever created from outsiders + H5Library(); - // Default constructor - no instance ever created from outsiders - H5Library(); - - // Destructor - ~H5Library(); + // Destructor + ~H5Library(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of H5Library } // namespace H5 -#endif // __H5Library_H +#endif // H5Library_H diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 100c0b990e3..065de0c09bc 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,7 +15,7 @@ #include using namespace std; -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -45,7 +45,9 @@ namespace H5 { // Function: H5Location default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::H5Location() : IdComponent() {} +H5Location::H5Location() : IdComponent() +{ +} //-------------------------------------------------------------------------- // Function: H5Location overloaded constructor (protected) @@ -88,7 +90,8 @@ H5Location::H5Location() : IdComponent() {} // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const char *name, const LinkAccPropList &lapl) const { htri_t ret_value = H5Lexists(getId(), name, lapl.getId()); if (ret_value > 0) @@ -110,9 +113,10 @@ bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed from exists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::nameExists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -126,9 +130,10 @@ bool H5Location::nameExists(const H5std_string& name, const LinkAccPropList& lap // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const char *name, const LinkAccPropList &lapl) const { - return(nameExists(name, lapl)); + return (nameExists(name, lapl)); } //-------------------------------------------------------------------------- @@ -142,9 +147,10 @@ bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const // Modification // Renamed to nameExists() in 1.10.2 -BMR //-------------------------------------------------------------------------- -bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) const +bool +H5Location::exists(const H5std_string &name, const LinkAccPropList &lapl) const { - return(nameExists(name.c_str(), lapl)); + return (nameExists(name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -162,11 +168,11 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c // Sep 2012 - BMR // Moved from H5File/H5Object //-------------------------------------------------------------------------- -void H5Location::flush(H5F_scope_t scope) const +void +H5Location::flush(H5F_scope_t scope) const { herr_t ret_value = H5Fflush(getId(), scope); - if (ret_value < 0) - { + if (ret_value < 0) { throw LocationException(inMemFunc("flush"), "H5Fflush failed"); } } @@ -179,12 +185,13 @@ void H5Location::flush(H5F_scope_t scope) const ///\exception H5::LocationException // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- -H5std_string H5Location::getFileName() const +H5std_string +H5Location::getFileName() const { try { - return(p_get_file_name()); + return (p_get_file_name()); } - catch (IdComponentException& E) { + catch (IdComponentException &E) { throw LocationException(inMemFunc("getFileName"), E.getDetailMsg()); } } @@ -209,7 +216,8 @@ H5std_string H5Location::getFileName() const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::setComment(const char* name, const char* comment) const +void +H5Location::setComment(const char *name, const char *comment) const { herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT); if (ret_value < 0) @@ -223,7 +231,8 @@ void H5Location::setComment(const char* name, const char* comment) const /// \c H5std_string for \a name and \a comment. // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -void H5Location::setComment(const H5std_string& name, const H5std_string& comment) const +void +H5Location::setComment(const H5std_string &name, const H5std_string &comment) const { setComment(name.c_str(), comment.c_str()); } @@ -235,7 +244,8 @@ void H5Location::setComment(const H5std_string& name, const H5std_string& commen /// an object name. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const char* comment) const +void +H5Location::setComment(const char *comment) const { herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); if (ret_value < 0) @@ -249,7 +259,8 @@ void H5Location::setComment(const char* comment) const /// \c H5std_string for \a comment. // Programmer Binh-Minh Ribler - Sep 2013 //-------------------------------------------------------------------------- -void H5Location::setComment(const H5std_string& comment) const +void +H5Location::setComment(const H5std_string &comment) const { setComment(comment.c_str()); } @@ -265,7 +276,8 @@ void H5Location::setComment(const H5std_string& comment) const // to another class to accommodate attribute, dataset, and named // datatype. - BMR //-------------------------------------------------------------------------- -void H5Location::removeComment(const char* name) const +void +H5Location::removeComment(const char *name) const { herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); if (ret_value < 0) @@ -279,9 +291,10 @@ void H5Location::removeComment(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -void H5Location::removeComment(const H5std_string& name) const +void +H5Location::removeComment(const H5std_string &name) const { - removeComment (name.c_str()); + removeComment(name.c_str()); } //-------------------------------------------------------------------------- @@ -299,7 +312,8 @@ void H5Location::removeComment(const H5std_string& name) const /// will be truncated to accommodate the null terminator. // Programmer Binh-Minh Ribler - Mar 2014 //-------------------------------------------------------------------------- -ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) const +ssize_t +H5Location::getComment(const char *name, size_t buf_size, char *comment) const { // H5Oget_comment_by_name will get buf_size chars of the comment including // the null terminator @@ -307,17 +321,16 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) comment_len = H5Oget_comment_by_name(getId(), name, comment, buf_size, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If the comment is longer than the provided buffer size, the C library // will not null terminate it if (static_cast(comment_len) >= buf_size) - comment[buf_size-1] = '\0'; + comment[buf_size - 1] = '\0'; // Return the actual comment length, which might be different from buf_size - return(comment_len); + return (comment_len); } //-------------------------------------------------------------------------- @@ -330,24 +343,23 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment) ///\exception H5::LocationException // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -H5std_string H5Location::getComment(const char* name, size_t buf_size) const +H5std_string +H5Location::getComment(const char *name, size_t buf_size) const { // Initialize string to "", so that if there is no comment, the returned // string will be empty - H5std_string comment(""); + 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); // If H5Oget_comment_by_name returns a negative value, raise an exception - if (comment_len < 0) - { + if (comment_len < 0) { throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } // If comment exists, calls C routine again to get it - else if (comment_len > 0) - { + else if (comment_len > 0) { size_t tmp_len = buf_size; // If buffer size is not provided, use comment length @@ -355,14 +367,13 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const tmp_len = comment_len; // Temporary buffer for char* comment - char* comment_C = new char[tmp_len+1]; - HDmemset(comment_C, 0, tmp_len+1); // clear buffer + char *comment_C = new char[tmp_len + 1]; + HDmemset(comment_C, 0, tmp_len + 1); // clear buffer // Used overloaded function - ssize_t temp_len = getComment(name, tmp_len+1, comment_C); - if (temp_len < 0) - { - delete []comment_C; + ssize_t temp_len = getComment(name, tmp_len + 1, comment_C); + if (temp_len < 0) { + delete[] comment_C; throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } @@ -370,11 +381,11 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const comment = comment_C; // Clean up resource - delete []comment_C; + delete[] comment_C; } // Return the string comment - return(comment); + return (comment); } //-------------------------------------------------------------------------- @@ -384,10 +395,12 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) //-------------------------------------------------------------------------- -H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) const +H5std_string +H5Location::getComment(const H5std_string &name, size_t buf_size) const { - return(getComment(name.c_str(), buf_size)); + return (getComment(name.c_str(), buf_size)); } + #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -400,11 +413,11 @@ H5std_string H5Location::getComment(const H5std_string& name, size_t buf_size) c // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const +void +H5Location::p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const { herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id); - if (ret_value < 0) - { + if (ret_value < 0) { throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); } } @@ -425,12 +438,13 @@ void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_ty ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type) const { try { p_reference(ref, name, dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -451,12 +465,14 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, const DataSpace &dataspace, + H5R_type_t ref_type) const { try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -475,12 +491,13 @@ void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const char *name, H5R_type_t ref_type) const { try { p_reference(ref, name, -1, ref_type); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -498,9 +515,10 @@ void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) con ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const +void +H5Location::reference(void *ref, const H5std_string &name, H5R_type_t ref_type) const { - reference(ref, name.c_str(), ref_type); + reference(ref, name.c_str(), ref_type); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -517,7 +535,9 @@ void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_t // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func) +hid_t +H5Location::p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, + const char *from_func) { hid_t plist_id; if (p_valid_id(plist.getId())) @@ -526,12 +546,11 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty plist_id = H5P_DEFAULT; hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); - if (temp_id < 0) - { + if (temp_id < 0) { throw ReferenceException(inMemFunc(from_func), "H5Rdereference2 failed"); } - return(temp_id); + return (temp_id); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -545,7 +564,8 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) +void +H5Location::dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) { p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference")); } @@ -564,11 +584,12 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Removed in 1.10.1 because H5Location is Attribute's baseclass // now. -BMR //-------------------------------------------------------------------------- - /* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) +/* void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& +plist) { - p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); + p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); } - */ +*/ #ifndef H5_NO_DEPRECATED_SYMBOLS //-------------------------------------------------------------------------- @@ -590,12 +611,13 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t // Modification // Sep 2012: Moved up from H5File, Group, DataSet, and DataType //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const +H5G_obj_t +H5Location::getObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_obj_type(ref, ref_type)); + return (p_get_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); } } @@ -617,16 +639,17 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const +H5G_obj_t +H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const { - H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); - if (obj_type == H5G_UNKNOWN) - { + H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); + if (obj_type == H5G_UNKNOWN) { throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); } - return(obj_type); + return (obj_type); } #endif // DOXYGEN_SHOULD_SKIP_THIS + #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- @@ -645,12 +668,13 @@ H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const +H5O_type_t +H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const { try { - return(p_get_ref_obj_type(ref, ref_type)); + return (p_get_ref_obj_type(ref, ref_type)); } - catch (ReferenceException& E) { + catch (ReferenceException &E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } } @@ -671,21 +695,20 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const +H5O_type_t +H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const { - H5O_type_t obj_type = H5O_TYPE_UNKNOWN; - herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); - if (ret_value < 0) - { + H5O_type_t obj_type = H5O_TYPE_UNKNOWN; + herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); + if (ret_value < 0) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); } - if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) - { + if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); } - return(obj_type); + return (obj_type); } - +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5Location::getRegion @@ -703,24 +726,23 @@ H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const // ref count, as a work-around for a problem described in the JIRA // issue HDFFV-7947. -BMR //-------------------------------------------------------------------------- -DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const +DataSpace +H5Location::getRegion(void *ref, H5R_type_t ref_type) const { hid_t space_id = H5Rget_region(getId(), ref_type, ref); - if (space_id < 0) - { + if (space_id < 0) { throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); } try { DataSpace dataspace; f_DataSpace_setId(&dataspace, space_id); - return(dataspace); + return (dataspace); } - catch (DataSpaceIException& E) { + catch (DataSpaceIException &E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } } - // From H5CommonFG.cpp // Notes with "***Updated" are new and for Group.cpp // Original notes are from December 2000 @@ -768,7 +790,8 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const char *name, const LinkCreatPropList &lcpl) const { // Call C routine H5Gcreate2 to create the named group, giving the // location id which can be a file id or a group id @@ -779,10 +802,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -792,9 +815,10 @@ Group H5Location::createGroup(const char* name, const LinkCreatPropList& lcpl) c /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const +Group +H5Location::createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const { - return(createGroup( name.c_str(), lcpl)); + return (createGroup(name.c_str(), lcpl)); } //-------------------------------------------------------------------------- @@ -813,22 +837,22 @@ Group H5Location::createGroup(const H5std_string& name, const LinkCreatPropList& /// then a default size is chosen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const char* name, size_t size_hint) const +Group +H5Location::createGroup(const char *name, size_t size_hint) const { // Group creation property list for size hint hid_t gcpl_id = 0; // Set the local heap size hint - if (size_hint > 0) - { - // If the creation of the property list failed, throw an exception - if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - throwException("createGroup", "H5Pcreate failed"); - - if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { - H5Pclose(gcpl_id); - throwException("createGroup", "H5Pset_local_heap_size_hint failed"); - } + if (size_hint > 0) { + // If the creation of the property list failed, throw an exception + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + throwException("createGroup", "H5Pcreate failed"); + + if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) { + H5Pclose(gcpl_id); + throwException("createGroup", "H5Pset_local_heap_size_hint failed"); + } } // Call C routine H5Gcreate2 to create the named group, giving the @@ -836,18 +860,18 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const hid_t group_id = H5Gcreate2(getId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT); // Close the group creation property list, if necessary - if(gcpl_id > 0) - H5Pclose(gcpl_id); + if (gcpl_id > 0) + H5Pclose(gcpl_id); // If the creation of the group failed, throw an exception if (group_id < 0) throwException("createGroup", "H5Gcreate2 failed"); // No failure, create and return the Group object - Group group; + Group group; H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -857,9 +881,10 @@ Group H5Location::createGroup(const char* name, size_t size_hint) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const +Group +H5Location::createGroup(const H5std_string &name, size_t size_hint) const { - return(createGroup( name.c_str(), size_hint)); + return (createGroup(name.c_str(), size_hint)); } //-------------------------------------------------------------------------- @@ -871,7 +896,8 @@ Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const char* name) const +Group +H5Location::openGroup(const char *name) const { // Call C routine H5Gopen2 to open the named group, giving the // location id which can be a file id or a group id @@ -883,10 +909,10 @@ Group H5Location::openGroup(const char* name) const // No failure, create and return the Group object Group group; - //group.p_setId(group_id); + // group.p_setId(group_id); H5Location *ptr = &group; ptr->p_setId(group_id); - return(group); + return (group); } //-------------------------------------------------------------------------- @@ -896,9 +922,10 @@ Group H5Location::openGroup(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group H5Location::openGroup(const H5std_string& name) const +Group +H5Location::openGroup(const H5std_string &name) const { - return(openGroup( name.c_str())); + return (openGroup(name.c_str())); } //-------------------------------------------------------------------------- @@ -919,14 +946,17 @@ Group H5Location::openGroup(const H5std_string& name) const // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - // Obtain identifiers for C API - hid_t type_id = data_type.getId(); + // Obtain identifiers for C API + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); - hid_t dcpl_id = dcpl.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t dapl_id = dapl.getId(); + hid_t dcpl_id = dcpl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t dapl_id = dapl.getId(); // Call C routine H5Dcreate2 to create the named dataset hid_t dataset_id = H5Dcreate2(getId(), name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); @@ -938,7 +968,7 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -953,9 +983,12 @@ DataSet H5Location::createDataSet(const char* name, const DataType& data_type, c // follow the order in the C function: lcpl, dcpl, dapl, to // accommodate the existing createDataSet calls. //-------------------------------------------------------------------------- -DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& dcpl, const DSetAccPropList& dapl, const LinkCreatPropList& lcpl) const +DataSet +H5Location::createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const DSetCreatPropList &dcpl, const DSetAccPropList &dapl, + const LinkCreatPropList &lcpl) const { - return(createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); + return (createDataSet(name.c_str(), data_type, data_space, dcpl, dapl, lcpl)); } //-------------------------------------------------------------------------- @@ -969,21 +1002,22 @@ DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const char *name, const DSetAccPropList &dapl) const { // Call C function H5Dopen2 to open the specified dataset, giving // the location id and the dataset's name - hid_t dapl_id = dapl.getId(); + hid_t dapl_id = dapl.getId(); hid_t dataset_id = H5Dopen2(getId(), name, dapl_id); // If the dataset's opening failed, throw an exception - if(dataset_id < 0) + if (dataset_id < 0) throwException("openDataSet", "H5Dopen2 failed"); // No failure, create and return the DataSet object DataSet dataset; f_DataSet_setId(&dataset, dataset_id); - return(dataset); + return (dataset); } //-------------------------------------------------------------------------- @@ -996,9 +1030,10 @@ DataSet H5Location::openDataSet(const char* name, const DSetAccPropList& dapl) c // Jul 2018 // Added DSetAccPropList argument //-------------------------------------------------------------------------- -DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& dapl) const +DataSet +H5Location::openDataSet(const H5std_string &name, const DSetAccPropList &dapl) const { - return(openDataSet(name.c_str(), dapl)); + return (openDataSet(name.c_str(), dapl)); } //-------------------------------------------------------------------------- @@ -1016,12 +1051,13 @@ DataSet H5Location::openDataSet(const H5std_string& name, const DSetAccPropList& /// H5Lcreate_soft APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *target_name, const char *link_name, - const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *target_name, const char *link_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_soft(target_name, getId(), link_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1036,8 +1072,9 @@ void H5Location::link(const char *target_name, const char *link_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& target_name, const H5std_string& - link_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(target_name.c_str(), link_name.c_str(), lcpl, lapl); } @@ -1058,16 +1095,17 @@ void H5Location::link(const H5std_string& target_name, const H5std_string& /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const Group& new_loc, - const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const Group &new_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { - herr_t ret_value = -1; - hid_t new_loc_id = new_loc.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + herr_t ret_value = -1; + hid_t new_loc_id = new_loc.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, new_loc_id, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1079,8 +1117,9 @@ void H5Location::link(const char *curr_name, const Group& new_loc, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const Group& new_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), new_loc, new_name.c_str(), lcpl, lapl); } @@ -1102,15 +1141,17 @@ void H5Location::link(const H5std_string& curr_name, const Group& new_loc, /// H5Lcreate_hard APIs in the HDF5 C Reference Manual. // March 2018 //-------------------------------------------------------------------------- -void H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value = -1; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, lcpl_id, lapl_id); - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1122,8 +1163,9 @@ void H5Location::link(const char *curr_name, const hid_t same_loc, const char *n ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, - const H5std_string& new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { link(curr_name.c_str(), same_loc, new_name.c_str(), lcpl, lapl); } @@ -1152,17 +1194,18 @@ void H5Location::link(const H5std_string& curr_name, const hid_t same_loc, // H5L_SAME_LOC. This function will be retired in favor of // its replacement. - BMR //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* new_name) const +void +H5Location::link(H5L_type_t link_type, const char *curr_name, const char *new_name) const { herr_t ret_value = -1; - switch(link_type) { + switch (link_type) { case H5L_TYPE_HARD: ret_value = H5Lcreate_hard(getId(), curr_name, H5L_SAME_LOC, new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_SOFT: - ret_value = H5Lcreate_soft(curr_name,getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); + ret_value = H5Lcreate_soft(curr_name, getId(), new_name, H5P_DEFAULT, H5P_DEFAULT); break; case H5L_TYPE_ERROR: @@ -1173,7 +1216,7 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n break; } /* end switch */ - if (ret_value < 0) + if (ret_value < 0) throwException("link", "creating link failed"); } @@ -1184,7 +1227,8 @@ void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* n /// \c H5std_string for \a curr_name and \a new_name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const +void +H5Location::link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const { link(link_type, curr_name.c_str(), new_name.c_str()); } @@ -1200,17 +1244,17 @@ void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const Group& dst, const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy failed"); } @@ -1222,9 +1266,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1239,16 +1283,16 @@ void H5Location::copyLink(const H5std_string& src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const char *src_name, - const char *dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lcopy(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); - if(ret_value < 0) + if (ret_value < 0) throwException("copyLink", "H5Lcopy H5L_SAME_LOC failed"); } @@ -1260,9 +1304,9 @@ void H5Location::copyLink(const char *src_name, ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::copyLink(const H5std_string& src_name, - const H5std_string& dst_name, const LinkCreatPropList& lcpl, - const LinkAccPropList& lapl) const +void +H5Location::copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { copyLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1282,12 +1326,14 @@ void H5Location::copyLink(const H5std_string& src_name, /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const Group& dst, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const Group &dst, const char *dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t dst_id = dst.getId(); - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t dst_id = dst.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1302,7 +1348,9 @@ void H5Location::moveLink(const char* src_name, const Group& dst, const char* ds ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl); } @@ -1321,11 +1369,13 @@ void H5Location::moveLink(const H5std_string& src_name, const Group& dst, const /// to the Group Interface in the HDF5 User's Guide for details. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const char* src_name, const char* dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl, + const LinkAccPropList &lapl) const { herr_t ret_value; - hid_t lcpl_id = lcpl.getId(); - hid_t lapl_id = lapl.getId(); + hid_t lcpl_id = lcpl.getId(); + hid_t lapl_id = lapl.getId(); ret_value = H5Lmove(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id); if (ret_value < 0) @@ -1340,7 +1390,9 @@ void H5Location::moveLink(const char* src_name, const char* dst_name, const Link ///\exception H5::FileIException or H5::GroupIException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const +void +H5Location::moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl, const LinkAccPropList &lapl) const { moveLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl); } @@ -1359,7 +1411,8 @@ void H5Location::moveLink(const H5std_string& src_name, const H5std_string& dst_ // 2007: QAK modified to use H5L APIs - BMR // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const char* src, const char* dst) const +void +H5Location::move(const char *src, const char *dst) const { moveLink(src, dst, LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1372,7 +1425,8 @@ void H5Location::move(const char* src, const char* dst) const // Modification // 2018: Will be replaced by H5Location::moveLink() -BMR //-------------------------------------------------------------------------- -void H5Location::move(const H5std_string& src, const H5std_string& dst) const +void +H5Location::move(const H5std_string &src, const H5std_string &dst) const { moveLink(src.c_str(), dst.c_str(), LinkCreatPropList::DEFAULT, LinkAccPropList::DEFAULT); } @@ -1384,7 +1438,8 @@ void H5Location::move(const H5std_string& src, const H5std_string& dst) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const char *name, const LinkAccPropList &lapl) const { herr_t ret_value = H5Ldelete(getId(), name, lapl.getId()); if (ret_value < 0) @@ -1398,11 +1453,133 @@ void H5Location::unlink(const char* name, const LinkAccPropList& lapl) const /// \c H5std_string for \a name. // March, 2018 //-------------------------------------------------------------------------- -void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) const +void +H5Location::unlink(const H5std_string &name, const LinkAccPropList &lapl) const { unlink(name.c_str(), lapl); } +//-------------------------------------------------------------------------- +// Function: H5Location::getNativeObjinfo +///\brief Retrieves native information about an HDF5 object. +///\param objinfo - OUT: Struct containing the native object info +///\param fields - IN: Indicates the group of information to be retrieved +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_HDR (default) +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void +H5Location::getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields) const +{ + + // Use C API to get information of the object + herr_t ret_value = H5Oget_native_info(getId(), &objinfo, fields); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getNativeObjinfo"), "H5Oget_native_info failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getNativeObjinfo +///\brief Retrieves native information about an HDF5 object given its name. +///\param name - IN: Name of the object to be queried - \c char * +///\param objinfo - OUT: Struct containing the native object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_HDR +///\param lapl - IN: Link access property list +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_HDR (default) +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void +H5Location::getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const +{ + // Use C API to get information of the object + herr_t ret_value = H5Oget_native_info_by_name(getId(), name, &objinfo, fields, lapl.getId()); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getNativeObjinfo"), "H5Oget_native_info_by_name failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getNativeObjinfo +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +///\param name - IN: Name of the object to be queried - \c H5std_string +///\param objinfo - OUT: Struct containing the native object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_HDR +///\param lapl - IN: Link access property list +// July, 2018 +//-------------------------------------------------------------------------- +void +H5Location::getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const +{ + getNativeObjinfo(name.c_str(), objinfo, fields, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getNativeObjinfo +///\brief Retrieves native information about an HDF5 object given its index. +///\param grp_name - IN: Group name where the object belongs - \c char * +///\param idx_type - IN: Type of index +///\param order - IN: Order to traverse +///\param idx - IN: Object position +///\param objinfo - OUT: Struct containing the native object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_HDR +///\param lapl - IN: Link access property list +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_HDR (default) +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void +H5Location::getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const +{ + // Use C API to get information of the object + herr_t ret_value = + H5Oget_native_info_by_idx(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getNativeObjinfo"), "H5Oget_native_info_by_idx failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getObjinfo +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes +/// a reference to an \c H5std_string for \a name. +///\param name - IN: Name of the object to be queried - \c H5std_string +///\param objinfo - OUT: Struct containing the native object info +///\param fields - IN: Indicates a group of information to be retrieved +/// - default to H5O_INFO_HDR +///\param lapl - IN: Link access property list +// July, 2018 +//-------------------------------------------------------------------------- +void +H5Location::getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const +{ + getNativeObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); +} + //-------------------------------------------------------------------------- // Function: H5Location::getObjinfo ///\brief Retrieves information about an HDF5 object. @@ -1418,15 +1595,16 @@ void H5Location::unlink(const H5std_string& name, const LinkAccPropList& lapl) c /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(H5O_info_t& objinfo, unsigned fields) const +void +H5Location::getObjinfo(H5O_info2_t &objinfo, unsigned fields) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info2(getId(), &objinfo, fields); + herr_t ret_value = H5Oget_info3(getId(), &objinfo, fields); // Throw exception if C API returns failure if (ret_value < 0) - throwException(inMemFunc("getObjinfo"), "H5Oget_info2 failed"); + throwException(inMemFunc("getObjinfo"), "H5Oget_info3 failed"); } //-------------------------------------------------------------------------- @@ -1447,10 +1625,12 @@ void H5Location::getObjinfo(H5O_info_t& objinfo, unsigned fields) const /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_name2(getId(), name, &objinfo, fields, lapl.getId()); + herr_t ret_value = H5Oget_info_by_name3(getId(), name, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1469,7 +1649,9 @@ void H5Location::getObjinfo(const char* name, H5O_info_t& objinfo, unsigned fiel ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields, + const LinkAccPropList &lapl) const { getObjinfo(name.c_str(), objinfo, fields, lapl); } @@ -1495,13 +1677,13 @@ void H5Location::getObjinfo(const H5std_string& name, H5O_info_t& objinfo, unsig /// \li \c H5O_INFO_ALL // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_idx2(getId(), grp_name, idx_type, order, - idx, &objinfo, fields, lapl.getId()); + herr_t ret_value = + H5Oget_info_by_idx3(getId(), grp_name, idx_type, order, idx, &objinfo, fields, lapl.getId()); // Throw exception if C API returns failure if (ret_value < 0) @@ -1520,9 +1702,9 @@ void H5Location::getObjinfo(const char* grp_name, H5_index_t idx_type, ///\param lapl - IN: Link access property list // July, 2018 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, - const LinkAccPropList& lapl) const +void +H5Location::getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields, const LinkAccPropList &lapl) const { getObjinfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); } @@ -1540,7 +1722,8 @@ void H5Location::getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, /// the HDF5 C Reference Manual. // 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, follow_link, &statbuf); if (ret_value < 0) @@ -1554,7 +1737,8 @@ void H5Location::getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& s /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), follow_link, statbuf); } @@ -1566,7 +1750,8 @@ void H5Location::getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_s /// the paramemter \a follow_link. // Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const char *name, H5G_stat_t &statbuf) const { herr_t ret_value = H5Gget_objinfo(getId(), name, 0, &statbuf); if (ret_value < 0) @@ -1580,7 +1765,8 @@ void H5Location::getObjinfo(const char* name, H5G_stat_t& statbuf) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - Nov, 2005 //-------------------------------------------------------------------------- -void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const +void +H5Location::getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const { getObjinfo(name.c_str(), statbuf); } @@ -1596,15 +1782,16 @@ void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& lapl) const +H5L_info2_t +H5Location::getLinkInfo(const char *link_name, const LinkAccPropList &lapl) const { - H5L_info_t linkinfo; // link info structure + H5L_info2_t linkinfo; // link info structure - herr_t ret_value = H5Lget_info(getId(), link_name, &linkinfo, lapl.getId()); + herr_t ret_value = H5Lget_info2(getId(), link_name, &linkinfo, lapl.getId()); if (ret_value < 0) throwException("getLinkInfo", "H5Lget_info to find buffer size failed"); - return(linkinfo); + return (linkinfo); } //-------------------------------------------------------------------------- @@ -1613,9 +1800,10 @@ H5L_info_t H5Location::getLinkInfo(const char* link_name, const LinkAccPropList& /// It differs from the above function in that it takes an /// \c H5std_string for \a link_name. //-------------------------------------------------------------------------- -H5L_info_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl) const +H5L_info2_t +H5Location::getLinkInfo(const H5std_string &link_name, const LinkAccPropList &lapl) const { - return(getLinkInfo(link_name.c_str(), lapl)); + return (getLinkInfo(link_name.c_str(), lapl)); } //-------------------------------------------------------------------------- @@ -1627,18 +1815,18 @@ H5L_info_t H5Location::getLinkInfo(const H5std_string& link_name, const LinkAccP ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const char* name, size_t size) const +H5std_string +H5Location::getLinkval(const char *name, size_t size) const { - H5L_info_t linkinfo; - char *value_C; // value in C string - size_t val_size = size; - H5std_string value = ""; - herr_t ret_value; + H5L_info2_t linkinfo; + char * value_C; // value in C string + size_t val_size = size; + H5std_string value; + herr_t ret_value; // if user doesn't provide buffer size, determine it - if (size == 0) - { - ret_value = H5Lget_info(getId(), name, &linkinfo, H5P_DEFAULT); + if (size == 0) { + ret_value = H5Lget_info2(getId(), name, &linkinfo, H5P_DEFAULT); if (ret_value < 0) throwException("getLinkval", "H5Lget_info to find buffer size failed"); @@ -1646,22 +1834,20 @@ H5std_string 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 + 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 ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); - if (ret_value < 0) - { - delete []value_C; + if (ret_value < 0) { + delete[] value_C; throwException("getLinkval", "H5Lget_val failed"); } value = H5std_string(value_C); - delete []value_C; + delete[] value_C; } - return(value); + return (value); } //-------------------------------------------------------------------------- @@ -1671,9 +1857,10 @@ H5std_string H5Location::getLinkval(const char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const +H5std_string +H5Location::getLinkval(const H5std_string &name, size_t size) const { - return(getLinkval( name.c_str(), size)); + return (getLinkval(name.c_str(), size)); } //-------------------------------------------------------------------------- @@ -1685,7 +1872,8 @@ H5std_string H5Location::getLinkval(const H5std_string& name, size_t size) const ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2014 (original 2000) //-------------------------------------------------------------------------- -void H5Location::mount(const char* name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const char *name, const H5File &child, const PropList &plist) const { // Obtain identifiers for C API hid_t plist_id = plist.getId(); @@ -1714,7 +1902,7 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const char* name, H5File& child, PropList& plist) const +// void H5Location::mount(const char* name, H5File& child, PropList& plist) const //{ // mount(name, child, plist); //} @@ -1725,7 +1913,8 @@ void H5Location::mount(const char* name, const H5File& child, const PropList& pl /// It takes an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::mount(const H5std_string& name, const H5File& child, const PropList& plist) const +void +H5Location::mount(const H5std_string &name, const H5File &child, const PropList &plist) const { mount(name.c_str(), child, plist); } @@ -1741,7 +1930,7 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop // Removed from documentation. -BMR, 2016/03/07 1.8.17 and 1.10.0 // Removed from code. -BMR, 2016/08/11 1.8.18 and 1.10.1 //-------------------------------------------------------------------------- -//void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const +// void H5Location::mount(const H5std_string& name, H5File& child, PropList& plist) const //{ // mount(name.c_str(), child, plist); //} @@ -1753,7 +1942,8 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const char* name) const +void +H5Location::unmount(const char *name) const { // Call C routine H5Fmount to do the mouting herr_t ret_value = H5Funmount(getId(), name); @@ -1770,7 +1960,8 @@ void H5Location::unmount(const char* name) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Location::unmount(const H5std_string& name) const +void +H5Location::unmount(const H5std_string &name) const { unmount(name.c_str()); } @@ -1789,14 +1980,14 @@ void H5Location::unmount(const H5std_string& name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data) { int ret_value = H5Giterate(getId(), name, idx, op, op_data); - if (ret_value < 0) - { + if (ret_value < 0) { throwException("iterateElems", "H5Giterate failed"); } - return(ret_value); + return (ret_value); } //-------------------------------------------------------------------------- @@ -1806,9 +1997,10 @@ int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op , void* op_data) +int +H5Location::iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data) { - return(iterateElems( name.c_str(), idx, op, op_data)); + return (iterateElems(name.c_str(), idx, op, op_data)); } #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1819,12 +2011,13 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o ///\exception Deprecated // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -hsize_t H5Location::getNumObjs() const +hsize_t +H5Location::getNumObjs() const { - H5G_info_t ginfo; // Group information + H5G_info_t ginfo; // Group information herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) + if (ret_value < 0) throwException("getNumObjs", "H5Gget_info failed"); return (ginfo.nlinks); } @@ -1844,28 +2037,30 @@ hsize_t H5Location::getNumObjs() const /// each time the group is opened. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5std_string H5Location::getObjnameByIdx(hsize_t idx) const +H5std_string +H5Location::getObjnameByIdx(hsize_t idx) const { // call H5Lget_name_by_idx with name as NULL to get its length - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, NULL, 0, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); // now, allocate C buffer to get the name - char* name_C = new char[name_len+1]; - HDmemset(name_C, 0, name_len+1); // clear buffer + char *name_C = new char[name_len + 1]; + HDmemset(name_C, 0, name_len + 1); // clear buffer - name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len+1, H5P_DEFAULT); + name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len + 1, H5P_DEFAULT); - if (name_len < 0) - { - delete []name_C; + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string H5std_string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name); } @@ -1886,10 +2081,12 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const /// each time the group is opened. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const +ssize_t +H5Location::getObjnameByIdx(hsize_t idx, char *name, size_t size) const { - ssize_t name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); - if(name_len < 0) + ssize_t name_len = + H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5P_DEFAULT); + if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); return (name_len); @@ -1902,22 +2099,22 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, char* name, size_t size) const /// \c H5std_string for \a name. // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& 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 + char *name_C = new char[size + 1]; // temporary C-string for object name + HDmemset(name_C, 0, size + 1); // clear buffer // call overloaded function to get the name - ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); - if(name_len < 0) - { - delete []name_C; + ssize_t name_len = getObjnameByIdx(idx, name_C, size + 1); + if (name_len < 0) { + delete[] name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); } // clean up and return the string name = H5std_string(name_C); - delete []name_C; + delete[] name_C; return (name_len); } @@ -1939,32 +2136,33 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size /// - object type is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const char* objname) const +H5O_type_t +H5Location::childObjType(const char *objname) const { - H5O_info_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + H5O_info2_t objinfo; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_name2(getId(), objname, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); + herr_t ret_value = H5Oget_info_by_name3(getId(), objname, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjType", "H5Oget_info_by_name failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + case H5O_TYPE_MAP: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -1977,11 +2175,12 @@ H5O_type_t H5Location::childObjType(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(const H5std_string& objname) const +H5O_type_t +H5Location::childObjType(const H5std_string &objname) const { // Use overloaded function H5O_type_t objtype = childObjType(objname.c_str()); - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2013,33 +2212,36 @@ H5O_type_t H5Location::childObjType(const H5std_string& objname) const // can be added later when needed. // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, const char* objname) const +H5O_type_t +H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t order, + const char *objname) const { - herr_t ret_value; - H5O_info_t objinfo; - H5O_type_t objtype = H5O_TYPE_UNKNOWN; + herr_t ret_value; + H5O_info2_t objinfo; + H5O_type_t objtype = H5O_TYPE_UNKNOWN; // Use C API to get information of the object - ret_value = H5Oget_info_by_idx2(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, H5P_DEFAULT); + ret_value = H5Oget_info_by_idx3(getId(), objname, index_type, order, index, &objinfo, H5O_INFO_BASIC, + H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjType", "H5Oget_info_by_idx failed"); // Return a valid type or throw an exception for unknown type else - switch (objinfo.type) - { - case H5O_TYPE_GROUP: - case H5O_TYPE_DATASET: - case H5O_TYPE_NAMED_DATATYPE: - objtype = objinfo.type; - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - throwException("childObjType", "Unknown type of object"); + switch (objinfo.type) { + case H5O_TYPE_GROUP: + case H5O_TYPE_DATASET: + case H5O_TYPE_NAMED_DATATYPE: + objtype = objinfo.type; + break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + case H5O_TYPE_MAP: + default: + throwException("childObjType", "Unknown type of object"); } - return(objtype); + return (objtype); } //-------------------------------------------------------------------------- @@ -2056,25 +2258,26 @@ H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_ite /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const char* objname) const +unsigned +H5Location::childObjVersion(const char *objname) const { - H5O_info_t objinfo; - unsigned version = 0; + H5O_native_info_t objinfo; + unsigned version = 0; // Use C API to get information of the object - herr_t ret_value = H5Oget_info_by_name2(getId(), objname, &objinfo, H5O_INFO_HDR, H5P_DEFAULT); + herr_t ret_value = + H5Oget_native_info_by_name(getId(), objname, &objinfo, H5O_NATIVE_INFO_HDR, H5P_DEFAULT); // Throw exception if C API returns failure if (ret_value < 0) throwException("childObjVersion", "H5Oget_info_by_name failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throwException("childObjVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -2087,15 +2290,15 @@ unsigned H5Location::childObjVersion(const char* objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - April, 2014 //-------------------------------------------------------------------------- -unsigned H5Location::childObjVersion(const H5std_string& objname) const +unsigned +H5Location::childObjVersion(const H5std_string &objname) const { // Use overloaded function unsigned version = childObjVersion(objname.c_str()); - return(version); + return (version); } #ifndef H5_NO_DEPRECATED_SYMBOLS -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5Location::getObjTypeByIdx ///\brief Returns the type of an object in this group, given the @@ -2105,13 +2308,14 @@ unsigned H5Location::childObjVersion(const H5std_string& objname) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx) const { - H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - if (obj_type == H5G_UNKNOWN) + H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); + if (obj_type == H5G_UNKNOWN) throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); - return (obj_type); + return (obj_type); } //-------------------------------------------------------------------------- @@ -2127,10 +2331,11 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const // Modification // Modified to use the other function. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, char *type_name) const { H5std_string stype_name(type_name); - return(getObjTypeByIdx(idx, stype_name)); + return (getObjTypeByIdx(idx, stype_name)); } //-------------------------------------------------------------------------- // Function: H5Location::getObjTypeByIdx @@ -2143,27 +2348,34 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const ///\exception H5::FileIException/H5::GroupIException/H5::LocationException // Programmer Binh-Minh Ribler - January, 2003 //-------------------------------------------------------------------------- -H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const +H5G_obj_t +H5Location::getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const { H5G_obj_t obj_type = H5Gget_objtype_by_idx(getId(), idx); - switch (obj_type) - { - case H5G_LINK: type_name = H5std_string("symbolic link"); break; - case H5G_GROUP: type_name = H5std_string("group"); break; - case H5G_DATASET: type_name = H5std_string("dataset"); break; - case H5G_TYPE: type_name = H5std_string("datatype"); break; - case H5G_UNKNOWN: - case H5G_UDLINK: - case H5G_RESERVED_5: - case H5G_RESERVED_6: - case H5G_RESERVED_7: - default: - throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); + switch (obj_type) { + case H5G_LINK: + type_name = H5std_string("symbolic link"); + break; + case H5G_GROUP: + type_name = H5std_string("group"); + break; + case H5G_DATASET: + type_name = H5std_string("dataset"); + break; + case H5G_TYPE: + type_name = H5std_string("datatype"); + break; + case H5G_UNKNOWN: + case H5G_UDLINK: + case H5G_RESERVED_5: + case H5G_RESERVED_6: + case H5G_RESERVED_7: + default: + throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed"); } return (obj_type); } -#endif // DOXYGEN_SHOULD_SKIP_THIS #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- @@ -2179,7 +2391,8 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) cons // maintain backward compatibility. For other subclasses, throw // LocationException. //-------------------------------------------------------------------------- -void H5Location::throwException(const H5std_string& func_name, const H5std_string& msg) const +void +H5Location::throwException(const H5std_string &func_name, const H5std_string &msg) const { throw LocationException(inMemFunc(func_name.c_str()), msg); } @@ -2210,7 +2423,8 @@ void H5Location::throwException(const H5std_string& func_name, const H5std_strin // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) +void +f_DataSpace_setId(DataSpace *dspace, hid_t new_id) { dspace->p_setId(new_id); } @@ -2220,8 +2434,8 @@ void f_DataSpace_setId(DataSpace* dspace, hid_t new_id) ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Location::~H5Location() {} - -#endif // DOXYGEN_SHOULD_SKIP_THIS +H5Location::~H5Location() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index c21cf060926..740d0ce57ea 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -7,15 +7,15 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Location_H -#define __H5Location_H +#ifndef H5Location_H +#define H5Location_H -#include "H5Classes.h" // constains forward class declarations +#include "H5Classes.h" // constains forward class declarations namespace H5 { @@ -29,300 +29,314 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP H5Location : public IdComponent { - public: - // Checks if a link of a given name exists in a location - bool nameExists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool nameExists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + public: + // Checks if a link of a given name exists in a location + bool nameExists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool nameExists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Checks if a link of a given name exists in a location - // Deprecated in favor of nameExists for better name. - bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Checks if a link of a given name exists in a location + // Deprecated in favor of nameExists for better name. + bool exists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + bool exists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - // Flushes all buffers associated with this location to disk. - void flush(H5F_scope_t scope) const; + // Flushes all buffers associated with this location to disk. + void flush(H5F_scope_t scope) const; - // Gets the name of the file, specified by this location. - H5std_string getFileName() const; + // Gets the name of the file, specified by this location. + H5std_string getFileName() const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; - // Note: getRefObjType deprecates getObjType, but getObjType's name is - // misleading, so getRefObjType is used in the new function instead. - - // Sets the comment for an HDF5 object specified by its name. - void setComment(const char* name, const char* comment) const; - void setComment(const H5std_string& name, const H5std_string& comment) const; - void setComment(const char* comment) const; - void setComment(const H5std_string& comment) const; - - // Retrieves comment for the HDF5 object specified by its name. - ssize_t getComment(const char* name, size_t buf_size, char* comment) const; - H5std_string getComment(const char* name, size_t buf_size=0) const; - H5std_string getComment(const H5std_string& name, size_t buf_size=0) const; - - // Removes the comment for the HDF5 object specified by its name. - void removeComment(const char* name) const; - void removeComment(const H5std_string& name) const; - - // Creates a reference to a named object or to a dataset region - // in this object. - void reference(void* ref, const char* name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const H5std_string& name, - H5R_type_t ref_type = H5R_OBJECT) const; - void reference(void* ref, const char* name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - void reference(void* ref, const H5std_string& name, const DataSpace& dataspace, - H5R_type_t ref_type = H5R_DATASET_REGION) const; - - // Open a referenced object whose location is specified by either - // a file, an HDF5 object, or an attribute. - void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - // Removed in 1.10.1, because H5Location is baseclass - //void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); - - // Retrieves a dataspace with the region pointed to selected. - DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; - - // Create a new group with using link create property list. - Group createGroup(const char* name, const LinkCreatPropList& lcpl) const; - Group createGroup(const H5std_string& name, const LinkCreatPropList& lcpl) const; - -// From CommonFG - // Creates a new group at this location which can be a file - // or another group. - Group createGroup(const char* name, size_t size_hint = 0) const; - Group createGroup(const H5std_string& name, size_t size_hint = 0) const; - - // Opens an existing group in a location which can be a file - // or another group. - Group openGroup(const char* name) const; - Group openGroup(const H5std_string& name) const; - - // 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 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 LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const; - - // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 - // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - // DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; - - // 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, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const; - - H5L_info_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - H5L_info_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Returns the value of a symbolic link. - H5std_string getLinkval(const char* link_name, size_t size=0) const; - H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; - - // Returns the number of objects in this group. - // Deprecated - moved to H5::Group in 1.10.2. - hsize_t getNumObjs() const; - - // Retrieves the name of an object in this group, given the - // object's index. - H5std_string getObjnameByIdx(hsize_t idx) const; - ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const; - ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const; - - // Retrieves the type of an object in this file or group, given the - // object's name - H5O_type_t childObjType(const H5std_string& objname) const; - H5O_type_t childObjType(const char* objname) const; - H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const; - - // Returns the object header version of an object in this file or group, - // given the object's name. - unsigned childObjVersion(const char* objname) const; - unsigned childObjVersion(const H5std_string& objname) const; - - // Retrieves information about an HDF5 object. - void getObjinfo(H5O_info_t& objinfo, unsigned fields = H5O_INFO_BASIC) const; - - // Retrieves information about an HDF5 object, given its name. - void getObjinfo(const char* name, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& name, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Retrieves information about an HDF5 object, given its index. - void getObjinfo(const char* grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void getObjinfo(const H5std_string& grp_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, - unsigned fields = H5O_INFO_BASIC, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; + // Note: getRefObjType deprecates getObjType, but getObjType's name is + // misleading, so getRefObjType is used in the new function instead. + + // Sets the comment for an HDF5 object specified by its name. + void setComment(const char *name, const char *comment) const; + void setComment(const H5std_string &name, const H5std_string &comment) const; + void setComment(const char *comment) const; + void setComment(const H5std_string &comment) const; + + // Retrieves comment for the HDF5 object specified by its name. + ssize_t getComment(const char *name, size_t buf_size, char *comment) const; + H5std_string getComment(const char *name, size_t buf_size = 0) const; + H5std_string getComment(const H5std_string &name, size_t buf_size = 0) const; + + // Removes the comment for the HDF5 object specified by its name. + void removeComment(const char *name) const; + void removeComment(const H5std_string &name) const; + + // Creates a reference to a named object or to a dataset region + // in this object. + void reference(void *ref, const char *name, H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void *ref, const H5std_string &name, H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void *ref, const char *name, const DataSpace &dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + void reference(void *ref, const H5std_string &name, const DataSpace &dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Open a referenced object whose location is specified by either + // a file, an HDF5 object, or an attribute. + void dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT, + const PropList &plist = PropList::DEFAULT); + // Removed in 1.10.1, because H5Location is baseclass + // void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const + // PropList& plist = PropList::DEFAULT); + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Create a new group with using link create property list. + Group createGroup(const char *name, const LinkCreatPropList &lcpl) const; + Group createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const; + + // From CommonFG + // Creates a new group at this location which can be a file + // or another group. + Group createGroup(const char *name, size_t size_hint = 0) const; + Group createGroup(const H5std_string &name, size_t size_hint = 0) const; + + // Opens an existing group in a location which can be a file + // or another group. + Group openGroup(const char *name) const; + Group openGroup(const H5std_string &name) const; + + // 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 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 LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; + + // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 + // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const + // DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; DataSet createDataSet(const + // H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& + // create_plist = DSetCreatPropList::DEFAULT) const; + + // 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, + const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; + + H5L_info2_t getLinkInfo(const char * link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + H5L_info2_t getLinkInfo(const H5std_string & link_name, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Returns the value of a symbolic link. + H5std_string getLinkval(const char *link_name, size_t size = 0) const; + H5std_string getLinkval(const H5std_string &link_name, size_t size = 0) const; + + // Returns the number of objects in this group. + // Deprecated - moved to H5::Group in 1.10.2. + hsize_t getNumObjs() const; + + // Retrieves the name of an object in this group, given the + // object's index. + H5std_string getObjnameByIdx(hsize_t idx) const; + ssize_t getObjnameByIdx(hsize_t idx, char *name, size_t size) const; + ssize_t getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const; + + // Retrieves the type of an object in this file or group, given the + // object's name + H5O_type_t childObjType(const H5std_string &objname) const; + H5O_type_t childObjType(const char *objname) const; + H5O_type_t childObjType(hsize_t index, H5_index_t index_type = H5_INDEX_NAME, + H5_iter_order_t order = H5_ITER_INC, const char *objname = ".") const; + + // Returns the object header version of an object in this file or group, + // given the object's name. + unsigned childObjVersion(const char *objname) const; + unsigned childObjVersion(const H5std_string &objname) const; + + // Retrieves information about an HDF5 object. + void getObjinfo(H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC) const; + + // Retrieves information about an HDF5 object, given its name. + void getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves information about an HDF5 object, given its index. + void getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native native information about an HDF5 object. + void getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const; + + // Retrieves native information about an HDF5 object, given its name. + void getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo, + unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves native information about an HDF5 object, given its index. + void getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t idx, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR, + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Returns the type of an object in this group, given the - // object's index. - H5G_obj_t getObjTypeByIdx(hsize_t idx) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const; - H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const; - - // Returns information about an HDF5 object, given by its name, - // at this location. - Deprecated - void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const; - void getObjinfo(const char* name, H5G_stat_t& statbuf) const; - void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const; - - // Iterates over the elements of this group - not implemented in - // C++ style yet. - int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data); - int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data); + // Returns the type of an object in this group, given the + // object's index. + H5G_obj_t getObjTypeByIdx(hsize_t idx) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, char *type_name) const; + H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const; + + // Returns information about an HDF5 object, given by its name, + // at this location. - Deprecated + void getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const; + void getObjinfo(const char *name, H5G_stat_t &statbuf) const; + void getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const; + + // Iterates over the elements of this group - not implemented in + // C++ style yet. + int iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data); + int iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // 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; - void link(const H5std_string& target_name, - const H5std_string& link_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - 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; - 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; - - // 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; - 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; - - // Creates a link of the specified type from new_name to current_name; - // both names are interpreted relative to the specified location id. - // Deprecated due to inadequate functionality. - void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const; - void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const; - - // Removes the specified link from this location. - void unlink(const char *link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - void unlink(const H5std_string& link_name, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Mounts the file 'child' onto this location. - void mount(const char* name, const H5File& child, const PropList& plist) const; - void mount(const H5std_string& name, const H5File& child, const PropList& plist) const; - - // Unmounts the file named 'name' from this parent location. - void unmount(const char* name) const; - void unmount(const H5std_string& name) const; - - // 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; - 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; - - // 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; - void copyLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - 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; - 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; - - // 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; - void moveLink(const H5std_string& src_name, - const H5std_string& dst_name, - const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - - // Renames an object at this location. - // Deprecated due to inadequate functionality. - void move(const char* src, const char* dst) const; - void move(const H5std_string& src, const H5std_string& dst) const; - -// end From CommonFG - - /// For subclasses, H5File and Group, to throw appropriate exception. - virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - - // Default constructor - H5Location(); - - protected: + // 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; + void link(const H5std_string &target_name, const H5std_string &link_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + 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; + 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; + + // 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; + 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; + + // Creates a link of the specified type from new_name to current_name; + // both names are interpreted relative to the specified location id. + // Deprecated due to inadequate functionality. + void link(H5L_type_t link_type, const char *curr_name, const char *new_name) const; + void link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const; + + // Removes the specified link from this location. + void unlink(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + void unlink(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; + + // Mounts the file 'child' onto this location. + void mount(const char *name, const H5File &child, const PropList &plist) const; + void mount(const H5std_string &name, const H5File &child, const PropList &plist) const; + + // Unmounts the file named 'name' from this parent location. + void unmount(const char *name) const; + void unmount(const H5std_string &name) const; + + // 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; + 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; + + // 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; + void copyLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + 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; + 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; + + // 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; + void moveLink(const H5std_string &src_name, const H5std_string &dst_name, + const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, + const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + + // Renames an object at this location. + // Deprecated due to inadequate functionality. + void move(const char *src, const char *dst) const; + void move(const H5std_string &src, const H5std_string &dst) const; + + // end From CommonFG + + /// For subclasses, H5File and Group, to throw appropriate exception. + virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const; + + // Default constructor + H5Location(); + + protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS - // *** Deprecation warning *** - // The following two constructors are no longer appropriate after the - // data member "id" had been moved to the sub-classes. - // The copy constructor is a noop and is removed in 1.8.15 and the - // other will be removed from 1.10 release, and then from 1.8 if its - // removal does not raise any problems in two 1.10 releases. + // *** Deprecation warning *** + // The following two constructors are no longer appropriate after the + // data member "id" had been moved to the sub-classes. + // The copy constructor is a noop and is removed in 1.8.15 and the + // other will be removed from 1.10 release, and then from 1.8 if its + // removal does not raise any problems in two 1.10 releases. - // Creates a copy of an existing object giving the location id. - // H5Location(const hid_t loc_id); + // Creates a copy of an existing object giving the location id. + // H5Location(const hid_t loc_id); - // Creates a reference to an HDF5 object or a dataset region. - void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; + // Creates a reference to an HDF5 object or a dataset region. + void p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const; - // Dereferences a ref into an HDF5 id. - hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func); + // Dereferences a ref into an HDF5 id. + hid_t p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, + const char *from_func); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Retrieves the type of object that an object reference points to. - H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const; - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - //virtual void p_setId(const hid_t new_id); + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + // virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS - // Noop destructor. - virtual ~H5Location(); + // Noop destructor. + virtual ~H5Location(); }; // end of H5Location } // namespace H5 -#endif // __H5Location_H +#endif // H5Location_H diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 8d3334b44fd..71109d3db1f 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -6,14 +6,14 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -42,31 +42,39 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS // userAttrOpWrpr interfaces between the user's function and the // C library function H5Aiterate2 -extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, - const H5A_info_t *ainfo, void *op_data) +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) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Aiterate* myData = reinterpret_cast (op_data); + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Aiterate *myData = reinterpret_cast(op_data); myData->op(*myData->location, s_attr_name, myData->opData); return 0; } // userVisitOpWrpr interfaces between the user's function and the -// C library function H5Ovisit2 -extern "C" herr_t userVisitOpWrpr(hid_t obj_id, const char *attr_name, - const H5O_info_t *obj_info, void *op_data) +// 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) { - 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); + 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); return status; } +} // extern "C" + //-------------------------------------------------------------------------- // Function: H5Object default constructor (protected) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::H5Object() : H5Location() {} +H5Object::H5Object() : H5Location() +{ +} //-------------------------------------------------------------------------- // Function: f_Attribute_setId - friend @@ -78,7 +86,8 @@ H5Object::H5Object() : H5Location() {} // param new_id - IN: New id to set // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void f_Attribute_setId(Attribute* attr, hid_t new_id) +void +f_Attribute_setId(Attribute *attr, hid_t new_id) { attr->p_setId(new_id); } @@ -105,19 +114,20 @@ void f_Attribute_setId(Attribute* attr, hid_t new_id) /// recreate it with this function. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const char *name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - hid_t type_id = data_type.getId(); + hid_t type_id = data_type.getId(); hid_t space_id = data_space.getId(); hid_t plist_id = create_plist.getId(); - hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); + hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT); // If the attribute id is valid, create and return the Attribute object - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } else throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed"); @@ -130,9 +140,11 @@ Attribute H5Object::createAttribute(const char* name, const DataType& data_type, /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::createAttribute(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const +Attribute +H5Object::createAttribute(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, + const PropList &create_plist) const { - return(createAttribute(name.c_str(), data_type, data_space, create_plist)); + return (createAttribute(name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- @@ -143,17 +155,16 @@ Attribute H5Object::createAttribute(const H5std_string& name, const DataType& da ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const char* name) const +Attribute +H5Object::openAttribute(const char *name) const { hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT); - if (attr_id > 0) - { + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed"); } } @@ -165,9 +176,10 @@ Attribute H5Object::openAttribute(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const H5std_string& name) const +Attribute +H5Object::openAttribute(const H5std_string &name) const { - return(openAttribute(name.c_str())); + return (openAttribute(name.c_str())); } //-------------------------------------------------------------------------- @@ -178,18 +190,17 @@ Attribute H5Object::openAttribute(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Attribute H5Object::openAttribute(const unsigned int idx) const +Attribute +H5Object::openAttribute(const unsigned int idx) const { - hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, - H5_ITER_INC, static_cast(idx), H5P_DEFAULT, H5P_DEFAULT); - if (attr_id > 0) - { + hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, static_cast(idx), + H5P_DEFAULT, H5P_DEFAULT); + if (attr_id > 0) { Attribute attr; f_Attribute_setId(&attr, attr_id); - return(attr); + return (attr); } - else - { + else { throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed"); } } @@ -209,18 +220,19 @@ Attribute H5Object::openAttribute(const unsigned int idx) const /// void (*)(H5::H5Location&, H5std_string, void*). // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) +int +H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_data) { // store the user's function and data - UserData4Aiterate* userData = new UserData4Aiterate; - userData->opData = op_data; - userData->op = user_op; - userData->location = this; + UserData4Aiterate *userData = new UserData4Aiterate; + userData->opData = op_data; + userData->op = user_op; + userData->location = this; // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = _idx ? static_cast(*_idx) : 0; - int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, static_cast(userData)); + int ret_value = + H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, static_cast(userData)); // release memory delete userData; @@ -229,9 +241,9 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /* Pass back update index value to calling code */ if (_idx) *_idx = static_cast(idx); - return(ret_value); + return (ret_value); } - else // raise exception when H5Aiterate returns a negative value + else // raise exception when H5Aiterate returns a negative value throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed"); } @@ -250,13 +262,11 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat ///\param *op_data - IN: User-defined pointer to data required by the /// application for its processing of the object ///\param fields - IN: Flags specifying the fields to be retrieved -/// to the callback op via the H5O_info_t argument. +/// to the callback op via the H5O_info2_t argument. /// \li \c H5O_INFO_BASIC fileno, addr, type, and rc fields /// \li \c H5O_INFO_TIME atime, mtime, ctime, and btime fields /// \li \c H5O_INFO_NUM_ATTRS num_attrs field -/// \li \c H5O_INFO_HDR hdr field -/// \li \c H5O_INFO_META_SIZE meta_size field -/// \li \c H5O_INFO_ALL H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS ///\return /// \li On success: /// \li the return value of the first operator that returns a positive value @@ -266,28 +276,31 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat /// wrong within the library or the operator failed ///\exception H5::Exception ///\par Description -/// For information, please refer to the H5Ovisit2 API in the HDF5 +/// For information, please refer to the H5Ovisit3 API in the HDF5 /// C Reference Manual. // Programmer Binh-Minh Ribler - Feb, 2019 //-------------------------------------------------------------------------- -void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields) +void +H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields) { // Store the user's function and data - UserData4Visit* userData = new UserData4Visit; - userData->opData = op_data; - userData->op = user_op; - userData->obj = this; + UserData4Visit *userData = new UserData4Visit; + userData->opData = op_data; + userData->op = user_op; + userData->obj = this; // Call the C API passing in op wrapper and info - herr_t ret_value = H5Ovisit2(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); + herr_t ret_value = + H5Ovisit3(getId(), idx_type, order, userVisitOpWrpr, static_cast(userData), fields); // Release memory delete userData; - // Throw exception if H5Ovisit2 failed, which could be a failure in + // Throw exception if H5Ovisit3 failed, which could be a failure in // the library or in the call back operator if (ret_value < 0) - throw Exception(inMemFunc("visit"), "H5Ovisit2 failed"); + throw Exception(inMemFunc("visit"), "H5Ovisit3 failed"); } //-------------------------------------------------------------------------- @@ -302,25 +315,25 @@ void H5Object::visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_ /// - version number is not one of the valid values above // Programmer Binh-Minh Ribler - December, 2016 //-------------------------------------------------------------------------- -unsigned H5Object::objVersion() const +unsigned +H5Object::objVersion() const { - H5O_info_t objinfo; - unsigned version = 0; + H5O_native_info_t objinfo; + unsigned version = 0; // Use C API to get information of the object - herr_t ret_value = H5Oget_info2(getId(), &objinfo, H5O_INFO_HDR); + herr_t ret_value = H5Oget_native_info(getId(), &objinfo, H5O_NATIVE_INFO_HDR); // Throw exception if C API returns failure if (ret_value < 0) - throw Exception(inMemFunc("objVersion"), "H5Oget_info failed"); + throw Exception(inMemFunc("objVersion"), "H5Oget_native_info failed"); // Return a valid version or throw an exception for invalid value - else - { + else { version = objinfo.hdr.version; if (version != H5O_VERSION_1 && version != H5O_VERSION_2) throw ObjHeaderIException("objVersion", "Invalid version for object"); } - return(version); + return (version); } //-------------------------------------------------------------------------- @@ -330,14 +343,15 @@ unsigned H5Object::objVersion() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -int H5Object::getNumAttrs() const +int +H5Object::getNumAttrs() const { - H5O_info_t oinfo; /* Object info */ + H5O_info2_t oinfo; /* Object info */ - if(H5Oget_info2(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) + if (H5Oget_info3(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0) throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); else - return(static_cast(oinfo.num_attrs)); + return (static_cast(oinfo.num_attrs)); } //-------------------------------------------------------------------------- @@ -347,7 +361,8 @@ int H5Object::getNumAttrs() const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2013 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const char* name) const +bool +H5Object::attrExists(const char *name) const { // Call C routine H5Aexists to determine whether an attribute exists // at this location, which could be specified by a file, group, dataset, @@ -355,7 +370,7 @@ bool H5Object::attrExists(const char* name) const herr_t ret_value = H5Aexists(getId(), name); if (ret_value > 0) return true; - else if(ret_value == 0) + else if (ret_value == 0) return false; else // Raise exception when H5Aexists returns a negative value throw AttributeIException(inMemFunc("attrExists"), "H5Aexists failed"); @@ -368,9 +383,10 @@ bool H5Object::attrExists(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5Object::attrExists(const H5std_string& name) const +bool +H5Object::attrExists(const H5std_string &name) const { - return(attrExists(name.c_str())); + return (attrExists(name.c_str())); } //-------------------------------------------------------------------------- @@ -380,7 +396,8 @@ bool H5Object::attrExists(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const char* name) const +void +H5Object::removeAttr(const char *name) const { herr_t ret_value = H5Adelete(getId(), name); if (ret_value < 0) @@ -394,7 +411,8 @@ void H5Object::removeAttr(const char* name) const /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5Object::removeAttr(const H5std_string& name) const +void +H5Object::removeAttr(const H5std_string &name) const { removeAttr(name.c_str()); } @@ -407,7 +425,8 @@ void H5Object::removeAttr(const H5std_string& name) const ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const char* oldname, const char* newname) const +void +H5Object::renameAttr(const char *oldname, const char *newname) const { herr_t ret_value = H5Arename(getId(), oldname, newname); if (ret_value < 0) @@ -421,9 +440,10 @@ void H5Object::renameAttr(const char* oldname, const char* newname) const /// a reference to an \c H5std_string for the names. // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newname) const +void +H5Object::renameAttr(const H5std_string &oldname, const H5std_string &newname) const { - renameAttr (oldname.c_str(), newname.c_str()); + renameAttr(oldname.c_str(), newname.c_str()); } //-------------------------------------------------------------------------- @@ -432,22 +452,21 @@ void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newna ///\return The name of the object // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const +ssize_t +H5Object::getObjName(char *obj_name, size_t buf_size) const { // H5Iget_name will get buf_size-1 chars of the name to null terminate it ssize_t name_size = H5Iget_name(getId(), obj_name, buf_size); // If H5Iget_name returns a negative value, raise an exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // Return length of the name - return(name_size); + return (name_size); } //-------------------------------------------------------------------------- @@ -457,39 +476,37 @@ ssize_t H5Object::getObjName(char *obj_name, size_t buf_size) const ///\exception H5::Exception // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -H5std_string H5Object::getObjName() const +H5std_string +H5Object::getObjName() const { - H5std_string obj_name(""); // object name to return + 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)); // If H5Iget_name failed, throw exception - if (name_size < 0) - { + if (name_size < 0) { throw Exception(inMemFunc("getObjName"), "H5Iget_name failed"); } - else if (name_size == 0) - { + else if (name_size == 0) { throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0"); } // 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 + 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 // Use overloaded function - name_size = getObjName(name_C, name_size+1); + name_size = getObjName(name_C, name_size + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Return object's name - return(obj_name); + return (obj_name); } //-------------------------------------------------------------------------- @@ -505,35 +522,34 @@ H5std_string H5Object::getObjName() const /// which case the entire name will be retrieved. // Programmer Binh-Minh Ribler - Mar, 2014 //-------------------------------------------------------------------------- -ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const +ssize_t +H5Object::getObjName(H5std_string &obj_name, size_t len) const { ssize_t name_size = 0; // If no length is provided, get the entire object name - if (len == 0) - { - obj_name = getObjName(); + if (len == 0) { + obj_name = getObjName(); name_size = obj_name.length(); } // 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 + else { + char *name_C = new char[len + 1]; // temporary C-string + HDmemset(name_C, 0, len + 1); // clear buffer // Use overloaded function - name_size = getObjName(name_C, len+1); + name_size = getObjName(name_C, len + 1); // Convert the C object name to return obj_name = name_C; // Clean up resource - delete []name_C; + delete[] name_C; } // Otherwise, keep obj_name intact // Return name size - return(name_size); + return (name_size); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -542,7 +558,9 @@ ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::~H5Object() {} +H5Object::~H5Object() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index d7b2b0b2805..bc2f14a1860 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5Object_H -#define __H5Object_H +#ifndef H5Object_H +#define H5Object_H namespace H5 { @@ -40,98 +40,96 @@ namespace H5 { // Inheritance: H5Location -> IdComponent // Define the operator function pointer for H5Aiterate(). -typedef void (*attr_operator_t)(H5Object& loc, - const H5std_string attr_name, - void *operator_data); +typedef void (*attr_operator_t)(H5Object &loc, const H5std_string attr_name, void *operator_data); -// Define the operator function pointer for H5Ovisit2(). -typedef int (*visit_operator_t)(H5Object& obj, - const H5std_string attr_name, - const H5O_info_t *oinfo, - void *operator_data); +// Define the operator function pointer for H5Ovisit3(). +typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, const H5O_info2_t *oinfo, + void *operator_data); // User data for attribute iteration class UserData4Aiterate { - public: - attr_operator_t op; - void* opData; - H5Object* location; // Consider changing to H5Location + public: + attr_operator_t op; + void * opData; + H5Object * location; // Consider changing to H5Location }; // User data for visit iteration class UserData4Visit { - public: - visit_operator_t op; - void* opData; - H5Object* obj; + public: + visit_operator_t op; + void * opData; + H5Object * obj; }; class H5_DLLCPP H5Object : public H5Location { - public: - // Creates an attribute for the specified object - // PropList is currently not used, so always be default. - Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; - Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const; + public: + // Creates an attribute for the specified object + // PropList is currently not used, so always be default. + Attribute createAttribute(const char *name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; + Attribute createAttribute(const H5std_string &name, const DataType &type, const DataSpace &space, + const PropList &create_plist = PropList::DEFAULT) const; - // Given its name, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const char* name) const; - Attribute openAttribute(const H5std_string& name) const; + // Given its name, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const char *name) const; + Attribute openAttribute(const H5std_string &name) const; - // Given its index, opens the attribute that belongs to an object at - // this location. - Attribute openAttribute(const unsigned int idx) const; + // Given its index, opens the attribute that belongs to an object at + // this location. + Attribute openAttribute(const unsigned int idx) const; - // Iterate user's function over the attributes of this object. - int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL); + // Iterate user's function over the attributes of this object. + int iterateAttrs(attr_operator_t user_op, unsigned *idx = NULL, void *op_data = NULL); - // Recursively visit elements reachable from this object. - void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields); + // Recursively visit elements reachable from this object. + void visit(H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, + unsigned int fields); - // Returns the object header version of an object - unsigned objVersion() const; + // Returns the object header version of an object + unsigned objVersion() const; - // Determines the number of attributes belong to this object. - int getNumAttrs() const; + // Determines the number of attributes belong to this object. + int getNumAttrs() const; - // Checks whether the named attribute exists for this object. - bool attrExists(const char* name) const; - bool attrExists(const H5std_string& name) const; + // Checks whether the named attribute exists for this object. + bool attrExists(const char *name) const; + bool attrExists(const H5std_string &name) const; - // Renames the named attribute to a new name. - void renameAttr(const char* oldname, const char* newname) const; - void renameAttr(const H5std_string& oldname, const H5std_string& newname) const; + // Renames the named attribute to a new name. + void renameAttr(const char *oldname, const char *newname) const; + void renameAttr(const H5std_string &oldname, const H5std_string &newname) const; - // Removes the named attribute from this object. - void removeAttr(const char* name) const; - void removeAttr(const H5std_string& name) const; + // Removes the named attribute from this object. + void removeAttr(const char *name) const; + void removeAttr(const H5std_string &name) const; - // Returns an identifier. - virtual hid_t getId() const = 0; - - // Gets the name of this HDF5 object, i.e., Group, DataSet, or - // DataType. - ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; - ssize_t getObjName(H5std_string& obj_name, size_t len = 0) const; - H5std_string getObjName() const; + // Returns an identifier. + virtual hid_t getId() const H5_OVERRIDE = 0; + // Gets the name of this HDF5 object, i.e., Group, DataSet, or + // DataType. + ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; + ssize_t getObjName(H5std_string &obj_name, size_t len = 0) const; + H5std_string getObjName() const; #ifndef DOXYGEN_SHOULD_SKIP_THIS - protected: - // Default constructor - H5Object(); + protected: + // Default constructor + H5Object(); - // Sets the identifier of this object to a new value. - this one - // doesn't increment reference count - virtual void p_setId(const hid_t new_id) = 0; + // Sets the identifier of this object to a new value. - this one + // doesn't increment reference count + virtual void p_setId(const hid_t new_id) H5_OVERRIDE = 0; - // Noop destructor. - virtual ~H5Object(); + // Noop destructor. + virtual ~H5Object() H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of H5Object } // namespace H5 -#endif // __H5Object_H +#endif // H5Object_H diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 0542d5ed7e7..81dae313ada 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; +ObjCreatPropList *ObjCreatPropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: ObjCreatPropList::getConstant @@ -40,13 +40,13 @@ ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; // happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -ObjCreatPropList* ObjCreatPropList::getConstant() +ObjCreatPropList * +ObjCreatPropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -55,8 +55,9 @@ ObjCreatPropList* ObjCreatPropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new ObjCreatPropList(H5P_OBJECT_CREATE); else - throw PropListIException("ObjCreatPropList::getConstant", "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("ObjCreatPropList::getConstant", + "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -66,7 +67,8 @@ ObjCreatPropList* ObjCreatPropList::getConstant() // exception H5::PropListIException // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::deleteConstants() +void +ObjCreatPropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -75,7 +77,7 @@ void ObjCreatPropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose: Constant for default property //-------------------------------------------------------------------------- -const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); +const ObjCreatPropList &ObjCreatPropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -84,7 +86,9 @@ const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); ///\brief Creates a file access property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} +ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList copy constructor @@ -92,7 +96,9 @@ ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} ///\param original - IN: ObjCreatPropList instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {} +ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList &original) : PropList(original) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList overloaded constructor @@ -100,7 +106,9 @@ ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList( /// existing one. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) +{ +} //-------------------------------------------------------------------------- // Function: ObjCreatPropList::setAttrPhaseChange @@ -116,11 +124,11 @@ ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} /// H5Pset_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const +void +ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const { herr_t ret_value = H5Pset_attr_phase_change(id, max_compact, min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrPhaseChange", "H5Pset_attr_phase_change failed"); } } @@ -139,12 +147,12 @@ void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_den /// H5Pget_attr_phase_change API in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const +void +ObjCreatPropList::getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const { herr_t ret_value; ret_value = H5Pget_attr_phase_change(id, &max_compact, &min_dense); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrPhaseChange", "H5Pget_attr_phase_change failed"); } } @@ -168,11 +176,11 @@ void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_d /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const +void +ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const { herr_t ret_value = H5Pset_attr_creation_order(id, crt_order_flags); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::setAttrCrtOrder", "H5Pset_attr_creation_order failed"); } } @@ -190,16 +198,16 @@ void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const /// in the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -unsigned ObjCreatPropList::getAttrCrtOrder() const +unsigned +ObjCreatPropList::getAttrCrtOrder() const { - herr_t ret_value; + herr_t ret_value; unsigned crt_order_flags = 0; - ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); - if (ret_value < 0) - { + ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); + if (ret_value < 0) { throw PropListIException("ObjCreatPropList::getAttrCrtOrder", "H5Pget_attr_creation_order failed"); } - return(crt_order_flags); + return (crt_order_flags); } //-------------------------------------------------------------------------- @@ -207,6 +215,8 @@ unsigned ObjCreatPropList::getAttrCrtOrder() const ///\brief Noop destructor // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -ObjCreatPropList::~ObjCreatPropList() {} +ObjCreatPropList::~ObjCreatPropList() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 1d5dd55c449..7f6d411064e 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5ObjCreatPropList_H -#define __H5ObjCreatPropList_H +#ifndef H5ObjCreatPropList_H +#define H5ObjCreatPropList_H namespace H5 { @@ -23,53 +23,56 @@ namespace H5 { */ // Inheritance: PropList -> IdComponent class H5_DLLCPP ObjCreatPropList : public PropList { - public: - ///\brief Default object creation property list. - static const ObjCreatPropList& DEFAULT; + public: + ///\brief Default object creation property list. + static const ObjCreatPropList &DEFAULT; - // Creates a object creation property list. - ObjCreatPropList(); + // Creates a object creation property list. + ObjCreatPropList(); - // Sets attribute storage phase change thresholds. - void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; + // Sets attribute storage phase change thresholds. + void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; - // Gets attribute storage phase change thresholds. - void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; + // Gets attribute storage phase change thresholds. + void getAttrPhaseChange(unsigned &max_compact, unsigned &min_dense) const; - // Sets tracking and indexing of attribute creation order. - void setAttrCrtOrder(unsigned crt_order_flags) const; + // Sets tracking and indexing of attribute creation order. + void setAttrCrtOrder(unsigned crt_order_flags) const; - // Gets tracking and indexing settings for attribute creation order. - unsigned getAttrCrtOrder() const; + // Gets tracking and indexing settings for attribute creation order. + unsigned getAttrCrtOrder() const; + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("ObjCreatPropList"); + } - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("ObjCreatPropList"); } + // Copy constructor: same as the original ObjCreatPropList. + ObjCreatPropList(const ObjCreatPropList &original); - // Copy constructor: same as the original ObjCreatPropList. - ObjCreatPropList(const ObjCreatPropList& original); + // Creates a copy of an existing object creation property list + // using the property list id. + ObjCreatPropList(const hid_t plist_id); - // Creates a copy of an existing object creation property list - // using the property list id. - ObjCreatPropList (const hid_t plist_id); - - // Noop destructor - virtual ~ObjCreatPropList(); + // Noop destructor + virtual ~ObjCreatPropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the global constant, should only be used by the library - static void deleteConstants(); + // Deletes the global constant, should only be used by the library + static void deleteConstants(); - private: - static ObjCreatPropList* DEFAULT_; + private: + static ObjCreatPropList *DEFAULT_; - // Creates the global constant, should only be used by the library - static ObjCreatPropList* getConstant(); + // Creates the global constant, should only be used by the library + static ObjCreatPropList *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of ObjCreatPropList } // namespace H5 -#endif // __H5ObjCreatPropList_H +#endif // H5ObjCreatPropList_H diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 57ba5e5974d..9e67968bfc6 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,6 +27,7 @@ #include "H5DataType.h" #include "H5AtomType.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -51,7 +52,9 @@ PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id) ///\brief Default constructor: Creates a stub predefined datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType() : AtomType() {} +PredType::PredType() : AtomType() +{ +} #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- @@ -60,7 +63,9 @@ PredType::PredType() : AtomType() {} ///\param original - IN: PredType instance to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::PredType(const PredType& original) : AtomType(original) {} +PredType::PredType(const PredType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: PredType::operator= @@ -73,29 +78,35 @@ PredType::PredType(const PredType& original) : AtomType(original) {} // the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType& PredType::operator=(const PredType& rhs) +PredType & +PredType::operator=(const PredType &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } #ifndef DOXYGEN_SHOULD_SKIP_THIS // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. -void PredType::commit(H5Location& loc, const char* name) +void +PredType::commit(H5_ATTR_UNUSED H5Location &loc, H5_ATTR_UNUSED const char *name) { - throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); + throw DataTypeIException("PredType::commit", + "Error: Attempted to commit a predefined datatype. Invalid operation!"); } -void PredType::commit(H5Location& loc, const H5std_string& name) +void +PredType::commit(H5Location &loc, const H5std_string &name) { commit(loc, name.c_str()); } -bool PredType::committed() +bool +PredType::committed() { - throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype."); + throw DataTypeIException("PredType::committed", + "Error: Attempting to check for commit status on a predefined datatype."); } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -105,7 +116,9 @@ bool PredType::committed() ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PredType::~PredType() {} +PredType::~PredType() +{ +} /***************************************************************************** The following section is regarding the global constants PredType, @@ -115,180 +128,180 @@ PredType::~PredType() {} #ifndef DOXYGEN_SHOULD_SKIP_THIS // Definition pointers for the constants -PredType* PredType::PREDTYPE_CONST_ = 0; //dummy -PredType* PredType::STD_I8BE_; -PredType* PredType::STD_I8LE_; -PredType* PredType::STD_I16BE_; -PredType* PredType::STD_I16LE_; -PredType* PredType::STD_I32BE_; -PredType* PredType::STD_I32LE_; -PredType* PredType::STD_I64BE_; -PredType* PredType::STD_I64LE_; -PredType* PredType::STD_U8BE_; -PredType* PredType::STD_U8LE_; -PredType* PredType::STD_U16BE_; -PredType* PredType::STD_U16LE_; -PredType* PredType::STD_U32BE_; -PredType* PredType::STD_U32LE_; -PredType* PredType::STD_U64BE_; -PredType* PredType::STD_U64LE_; -PredType* PredType::STD_B8BE_; -PredType* PredType::STD_B8LE_; -PredType* PredType::STD_B16BE_; -PredType* PredType::STD_B16LE_; -PredType* PredType::STD_B32BE_; -PredType* PredType::STD_B32LE_; -PredType* PredType::STD_B64BE_; -PredType* PredType::STD_B64LE_; -PredType* PredType::STD_REF_OBJ_; -PredType* PredType::STD_REF_DSETREG_; - -PredType* PredType::C_S1_; -PredType* PredType::FORTRAN_S1_; - -PredType* PredType::IEEE_F32BE_; -PredType* PredType::IEEE_F32LE_; -PredType* PredType::IEEE_F64BE_; -PredType* PredType::IEEE_F64LE_; - -PredType* PredType::UNIX_D32BE_; -PredType* PredType::UNIX_D32LE_; -PredType* PredType::UNIX_D64BE_; -PredType* PredType::UNIX_D64LE_; - -PredType* PredType::INTEL_I8_; -PredType* PredType::INTEL_I16_; -PredType* PredType::INTEL_I32_; -PredType* PredType::INTEL_I64_; -PredType* PredType::INTEL_U8_; -PredType* PredType::INTEL_U16_; -PredType* PredType::INTEL_U32_; -PredType* PredType::INTEL_U64_; -PredType* PredType::INTEL_B8_; -PredType* PredType::INTEL_B16_; -PredType* PredType::INTEL_B32_; -PredType* PredType::INTEL_B64_; -PredType* PredType::INTEL_F32_; -PredType* PredType::INTEL_F64_; - -PredType* PredType::ALPHA_I8_; -PredType* PredType::ALPHA_I16_; -PredType* PredType::ALPHA_I32_; -PredType* PredType::ALPHA_I64_; -PredType* PredType::ALPHA_U8_; -PredType* PredType::ALPHA_U16_; -PredType* PredType::ALPHA_U32_; -PredType* PredType::ALPHA_U64_; -PredType* PredType::ALPHA_B8_; -PredType* PredType::ALPHA_B16_; -PredType* PredType::ALPHA_B32_; -PredType* PredType::ALPHA_B64_; -PredType* PredType::ALPHA_F32_; -PredType* PredType::ALPHA_F64_; - -PredType* PredType::MIPS_I8_; -PredType* PredType::MIPS_I16_; -PredType* PredType::MIPS_I32_; -PredType* PredType::MIPS_I64_; -PredType* PredType::MIPS_U8_; -PredType* PredType::MIPS_U16_; -PredType* PredType::MIPS_U32_; -PredType* PredType::MIPS_U64_; -PredType* PredType::MIPS_B8_; -PredType* PredType::MIPS_B16_; -PredType* PredType::MIPS_B32_; -PredType* PredType::MIPS_B64_; -PredType* PredType::MIPS_F32_; -PredType* PredType::MIPS_F64_; - -PredType* PredType::NATIVE_CHAR_; -PredType* PredType::NATIVE_SCHAR_; -PredType* PredType::NATIVE_UCHAR_; -PredType* PredType::NATIVE_SHORT_; -PredType* PredType::NATIVE_USHORT_; -PredType* PredType::NATIVE_INT_; -PredType* PredType::NATIVE_UINT_; -PredType* PredType::NATIVE_LONG_; -PredType* PredType::NATIVE_ULONG_; -PredType* PredType::NATIVE_LLONG_; -PredType* PredType::NATIVE_ULLONG_; -PredType* PredType::NATIVE_FLOAT_; -PredType* PredType::NATIVE_DOUBLE_; -PredType* PredType::NATIVE_LDOUBLE_; -PredType* PredType::NATIVE_B8_; -PredType* PredType::NATIVE_B16_; -PredType* PredType::NATIVE_B32_; -PredType* PredType::NATIVE_B64_; -PredType* PredType::NATIVE_OPAQUE_; -PredType* PredType::NATIVE_HSIZE_; -PredType* PredType::NATIVE_HSSIZE_; -PredType* PredType::NATIVE_HERR_; -PredType* PredType::NATIVE_HBOOL_; - -PredType* PredType::NATIVE_INT8_; -PredType* PredType::NATIVE_UINT8_; -PredType* PredType::NATIVE_INT16_; -PredType* PredType::NATIVE_UINT16_; -PredType* PredType::NATIVE_INT32_; -PredType* PredType::NATIVE_UINT32_; -PredType* PredType::NATIVE_INT64_; -PredType* PredType::NATIVE_UINT64_; +PredType *PredType::PREDTYPE_CONST_ = 0; // dummy +PredType *PredType::STD_I8BE_; +PredType *PredType::STD_I8LE_; +PredType *PredType::STD_I16BE_; +PredType *PredType::STD_I16LE_; +PredType *PredType::STD_I32BE_; +PredType *PredType::STD_I32LE_; +PredType *PredType::STD_I64BE_; +PredType *PredType::STD_I64LE_; +PredType *PredType::STD_U8BE_; +PredType *PredType::STD_U8LE_; +PredType *PredType::STD_U16BE_; +PredType *PredType::STD_U16LE_; +PredType *PredType::STD_U32BE_; +PredType *PredType::STD_U32LE_; +PredType *PredType::STD_U64BE_; +PredType *PredType::STD_U64LE_; +PredType *PredType::STD_B8BE_; +PredType *PredType::STD_B8LE_; +PredType *PredType::STD_B16BE_; +PredType *PredType::STD_B16LE_; +PredType *PredType::STD_B32BE_; +PredType *PredType::STD_B32LE_; +PredType *PredType::STD_B64BE_; +PredType *PredType::STD_B64LE_; +PredType *PredType::STD_REF_OBJ_; +PredType *PredType::STD_REF_DSETREG_; + +PredType *PredType::C_S1_; +PredType *PredType::FORTRAN_S1_; + +PredType *PredType::IEEE_F32BE_; +PredType *PredType::IEEE_F32LE_; +PredType *PredType::IEEE_F64BE_; +PredType *PredType::IEEE_F64LE_; + +PredType *PredType::UNIX_D32BE_; +PredType *PredType::UNIX_D32LE_; +PredType *PredType::UNIX_D64BE_; +PredType *PredType::UNIX_D64LE_; + +PredType *PredType::INTEL_I8_; +PredType *PredType::INTEL_I16_; +PredType *PredType::INTEL_I32_; +PredType *PredType::INTEL_I64_; +PredType *PredType::INTEL_U8_; +PredType *PredType::INTEL_U16_; +PredType *PredType::INTEL_U32_; +PredType *PredType::INTEL_U64_; +PredType *PredType::INTEL_B8_; +PredType *PredType::INTEL_B16_; +PredType *PredType::INTEL_B32_; +PredType *PredType::INTEL_B64_; +PredType *PredType::INTEL_F32_; +PredType *PredType::INTEL_F64_; + +PredType *PredType::ALPHA_I8_; +PredType *PredType::ALPHA_I16_; +PredType *PredType::ALPHA_I32_; +PredType *PredType::ALPHA_I64_; +PredType *PredType::ALPHA_U8_; +PredType *PredType::ALPHA_U16_; +PredType *PredType::ALPHA_U32_; +PredType *PredType::ALPHA_U64_; +PredType *PredType::ALPHA_B8_; +PredType *PredType::ALPHA_B16_; +PredType *PredType::ALPHA_B32_; +PredType *PredType::ALPHA_B64_; +PredType *PredType::ALPHA_F32_; +PredType *PredType::ALPHA_F64_; + +PredType *PredType::MIPS_I8_; +PredType *PredType::MIPS_I16_; +PredType *PredType::MIPS_I32_; +PredType *PredType::MIPS_I64_; +PredType *PredType::MIPS_U8_; +PredType *PredType::MIPS_U16_; +PredType *PredType::MIPS_U32_; +PredType *PredType::MIPS_U64_; +PredType *PredType::MIPS_B8_; +PredType *PredType::MIPS_B16_; +PredType *PredType::MIPS_B32_; +PredType *PredType::MIPS_B64_; +PredType *PredType::MIPS_F32_; +PredType *PredType::MIPS_F64_; + +PredType *PredType::NATIVE_CHAR_; +PredType *PredType::NATIVE_SCHAR_; +PredType *PredType::NATIVE_UCHAR_; +PredType *PredType::NATIVE_SHORT_; +PredType *PredType::NATIVE_USHORT_; +PredType *PredType::NATIVE_INT_; +PredType *PredType::NATIVE_UINT_; +PredType *PredType::NATIVE_LONG_; +PredType *PredType::NATIVE_ULONG_; +PredType *PredType::NATIVE_LLONG_; +PredType *PredType::NATIVE_ULLONG_; +PredType *PredType::NATIVE_FLOAT_; +PredType *PredType::NATIVE_DOUBLE_; +PredType *PredType::NATIVE_LDOUBLE_; +PredType *PredType::NATIVE_B8_; +PredType *PredType::NATIVE_B16_; +PredType *PredType::NATIVE_B32_; +PredType *PredType::NATIVE_B64_; +PredType *PredType::NATIVE_OPAQUE_; +PredType *PredType::NATIVE_HSIZE_; +PredType *PredType::NATIVE_HSSIZE_; +PredType *PredType::NATIVE_HERR_; +PredType *PredType::NATIVE_HBOOL_; + +PredType *PredType::NATIVE_INT8_; +PredType *PredType::NATIVE_UINT8_; +PredType *PredType::NATIVE_INT16_; +PredType *PredType::NATIVE_UINT16_; +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_; +PredType *PredType::NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 -PredType* PredType::NATIVE_UINT_LEAST8_; +PredType *PredType::NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 -PredType* PredType::NATIVE_INT_LEAST16_; +PredType *PredType::NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 -PredType* PredType::NATIVE_UINT_LEAST16_; +PredType *PredType::NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 -PredType* PredType::NATIVE_INT_LEAST32_; +PredType *PredType::NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 -PredType* PredType::NATIVE_UINT_LEAST32_; +PredType *PredType::NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 -PredType* PredType::NATIVE_INT_LEAST64_; +PredType *PredType::NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 -PredType* PredType::NATIVE_UINT_LEAST64_; +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_; +PredType *PredType::NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 -PredType* PredType::NATIVE_UINT_FAST8_; +PredType *PredType::NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 -PredType* PredType::NATIVE_INT_FAST16_; +PredType *PredType::NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 -PredType* PredType::NATIVE_UINT_FAST16_; +PredType *PredType::NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 -PredType* PredType::NATIVE_INT_FAST32_; +PredType *PredType::NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 -PredType* PredType::NATIVE_UINT_FAST32_; +PredType *PredType::NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 -PredType* PredType::NATIVE_INT_FAST64_; +PredType *PredType::NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 -PredType* PredType::NATIVE_UINT_FAST64_; +PredType *PredType::NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ //-------------------------------------------------------------------------- @@ -305,13 +318,13 @@ PredType* PredType::NATIVE_UINT_FAST64_; // // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -PredType* PredType::getPredTypes() +PredType * +PredType::getPredTypes() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -320,7 +333,9 @@ PredType* PredType::getPredTypes() if (PREDTYPE_CONST_ == 0) makePredTypes(); else - throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); + throw H5::DataTypeIException( + "PredType::getPredTypes", + "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_"); return PREDTYPE_CONST_; } @@ -329,38 +344,39 @@ PredType* PredType::getPredTypes() // Purpose Allocate all PredType constants. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::makePredTypes() +void +PredType::makePredTypes() { PREDTYPE_CONST_ = new PredType; - C_S1_ = new PredType(H5T_C_S1); - FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); + C_S1_ = new PredType(H5T_C_S1); + FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1); - STD_I8BE_ = new PredType(H5T_STD_I8BE); - STD_I8LE_ = new PredType(H5T_STD_I8LE); + STD_I8BE_ = new PredType(H5T_STD_I8BE); + STD_I8LE_ = new PredType(H5T_STD_I8LE); STD_I16BE_ = new PredType(H5T_STD_I16BE); STD_I16LE_ = new PredType(H5T_STD_I16LE); STD_I32BE_ = new PredType(H5T_STD_I32BE); STD_I32LE_ = new PredType(H5T_STD_I32LE); STD_I64BE_ = new PredType(H5T_STD_I64BE); STD_I64LE_ = new PredType(H5T_STD_I64LE); - STD_U8BE_ = new PredType(H5T_STD_U8BE); - STD_U8LE_ = new PredType(H5T_STD_U8LE); + STD_U8BE_ = new PredType(H5T_STD_U8BE); + STD_U8LE_ = new PredType(H5T_STD_U8LE); STD_U16BE_ = new PredType(H5T_STD_U16BE); STD_U16LE_ = new PredType(H5T_STD_U16LE); STD_U32BE_ = new PredType(H5T_STD_U32BE); STD_U32LE_ = new PredType(H5T_STD_U32LE); STD_U64BE_ = new PredType(H5T_STD_U64BE); STD_U64LE_ = new PredType(H5T_STD_U64LE); - STD_B8BE_ = new PredType(H5T_STD_B8BE); - STD_B8LE_ = new PredType(H5T_STD_B8LE); - - STD_B16BE_ = new PredType(H5T_STD_B16BE); - STD_B16LE_ = new PredType(H5T_STD_B16LE); - STD_B32BE_ = new PredType(H5T_STD_B32BE); - STD_B32LE_ = new PredType(H5T_STD_B32LE); - STD_B64BE_ = new PredType(H5T_STD_B64BE); - STD_B64LE_ = new PredType(H5T_STD_B64LE); - STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); + STD_B8BE_ = new PredType(H5T_STD_B8BE); + STD_B8LE_ = new PredType(H5T_STD_B8LE); + + STD_B16BE_ = new PredType(H5T_STD_B16BE); + STD_B16LE_ = new PredType(H5T_STD_B16LE); + STD_B32BE_ = new PredType(H5T_STD_B32BE); + STD_B32LE_ = new PredType(H5T_STD_B32LE); + STD_B64BE_ = new PredType(H5T_STD_B64BE); + STD_B64LE_ = new PredType(H5T_STD_B64LE); + STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ); STD_REF_DSETREG_ = new PredType(H5T_STD_REF_DSETREG); IEEE_F32BE_ = new PredType(H5T_IEEE_F32BE); @@ -373,84 +389,84 @@ void PredType::makePredTypes() UNIX_D64BE_ = new PredType(H5T_UNIX_D64BE); UNIX_D64LE_ = new PredType(H5T_UNIX_D64LE); - INTEL_I8_ = new PredType(H5T_INTEL_I8); + INTEL_I8_ = new PredType(H5T_INTEL_I8); INTEL_I16_ = new PredType(H5T_INTEL_I16); INTEL_I32_ = new PredType(H5T_INTEL_I32); INTEL_I64_ = new PredType(H5T_INTEL_I64); - INTEL_U8_ = new PredType(H5T_INTEL_U8); + INTEL_U8_ = new PredType(H5T_INTEL_U8); INTEL_U16_ = new PredType(H5T_INTEL_U16); INTEL_U32_ = new PredType(H5T_INTEL_U32); INTEL_U64_ = new PredType(H5T_INTEL_U64); - INTEL_B8_ = new PredType(H5T_INTEL_B8); + INTEL_B8_ = new PredType(H5T_INTEL_B8); INTEL_B16_ = new PredType(H5T_INTEL_B16); INTEL_B32_ = new PredType(H5T_INTEL_B32); INTEL_B64_ = new PredType(H5T_INTEL_B64); INTEL_F32_ = new PredType(H5T_INTEL_F32); INTEL_F64_ = new PredType(H5T_INTEL_F64); - ALPHA_I8_ = new PredType(H5T_ALPHA_I8); + ALPHA_I8_ = new PredType(H5T_ALPHA_I8); ALPHA_I16_ = new PredType(H5T_ALPHA_I16); ALPHA_I32_ = new PredType(H5T_ALPHA_I32); ALPHA_I64_ = new PredType(H5T_ALPHA_I64); - ALPHA_U8_ = new PredType(H5T_ALPHA_U8); + ALPHA_U8_ = new PredType(H5T_ALPHA_U8); ALPHA_U16_ = new PredType(H5T_ALPHA_U16); ALPHA_U32_ = new PredType(H5T_ALPHA_U32); ALPHA_U64_ = new PredType(H5T_ALPHA_U64); - ALPHA_B8_ = new PredType(H5T_ALPHA_B8); + ALPHA_B8_ = new PredType(H5T_ALPHA_B8); ALPHA_B16_ = new PredType(H5T_ALPHA_B16); ALPHA_B32_ = new PredType(H5T_ALPHA_B32); ALPHA_B64_ = new PredType(H5T_ALPHA_B64); ALPHA_F32_ = new PredType(H5T_ALPHA_F32); ALPHA_F64_ = new PredType(H5T_ALPHA_F64); - MIPS_I8_ = new PredType(H5T_MIPS_I8); + MIPS_I8_ = new PredType(H5T_MIPS_I8); MIPS_I16_ = new PredType(H5T_MIPS_I16); MIPS_I32_ = new PredType(H5T_MIPS_I32); MIPS_I64_ = new PredType(H5T_MIPS_I64); - MIPS_U8_ = new PredType(H5T_MIPS_U8); + MIPS_U8_ = new PredType(H5T_MIPS_U8); MIPS_U16_ = new PredType(H5T_MIPS_U16); MIPS_U32_ = new PredType(H5T_MIPS_U32); MIPS_U64_ = new PredType(H5T_MIPS_U64); - MIPS_B8_ = new PredType(H5T_MIPS_B8); + MIPS_B8_ = new PredType(H5T_MIPS_B8); MIPS_B16_ = new PredType(H5T_MIPS_B16); MIPS_B32_ = new PredType(H5T_MIPS_B32); MIPS_B64_ = new PredType(H5T_MIPS_B64); 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_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_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 +#if H5_SIZEOF_LONG_DOUBLE != 0 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_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_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_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); - NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); + NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); + NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); + NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16); NATIVE_UINT16_ = new PredType(H5T_NATIVE_UINT16); - NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); + NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32); NATIVE_UINT32_ = new PredType(H5T_NATIVE_UINT32); - NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); + NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); NATIVE_UINT64_ = new PredType(H5T_NATIVE_UINT64); // LEAST types @@ -513,13 +529,13 @@ void PredType::makePredTypes() } // makePredTypes - //-------------------------------------------------------------------------- // Function: PredType::deleteConstants // Purpose Deletes all PredType constant pointers. // Programmer Binh-Minh Ribler - September 2015 //-------------------------------------------------------------------------- -void PredType::deleteConstants() +void +PredType::deleteConstants() { delete STD_I8BE_; delete STD_I8LE_; @@ -709,186 +725,186 @@ void PredType::deleteConstants() // PredType constants. Note that, there is a similar function to getPredTypes() // in other classes, that have global constants, is called getConstant(). -const PredType& PredType::PREDTYPE_CONST = *PredType::getPredTypes(); -const PredType& PredType::STD_I8BE = *STD_I8BE_; -const PredType& PredType::STD_I8LE = *STD_I8LE_; -const PredType& PredType::STD_I16BE = *STD_I16BE_; -const PredType& PredType::STD_I16LE = *STD_I16LE_; -const PredType& PredType::STD_I32BE = *STD_I32BE_; -const PredType& PredType::STD_I32LE = *STD_I32LE_; -const PredType& PredType::STD_I64BE = *STD_I64BE_; -const PredType& PredType::STD_I64LE = *STD_I64LE_; -const PredType& PredType::STD_U8BE = *STD_U8BE_; -const PredType& PredType::STD_U8LE = *STD_U8LE_; -const PredType& PredType::STD_U16BE = *STD_U16BE_; -const PredType& PredType::STD_U16LE = *STD_U16LE_; -const PredType& PredType::STD_U32BE = *STD_U32BE_; -const PredType& PredType::STD_U32LE = *STD_U32LE_; -const PredType& PredType::STD_U64BE = *STD_U64BE_; -const PredType& PredType::STD_U64LE = *STD_U64LE_; -const PredType& PredType::STD_B8BE = *STD_B8BE_; -const PredType& PredType::STD_B8LE = *STD_B8LE_; -const PredType& PredType::STD_B16BE = *STD_B16BE_; -const PredType& PredType::STD_B16LE = *STD_B16LE_; -const PredType& PredType::STD_B32BE = *STD_B32BE_; -const PredType& PredType::STD_B32LE = *STD_B32LE_; -const PredType& PredType::STD_B64BE = *STD_B64BE_; -const PredType& PredType::STD_B64LE = *STD_B64LE_; -const PredType& PredType::STD_REF_OBJ = *STD_REF_OBJ_; -const PredType& PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; - -const PredType& PredType::C_S1 = *C_S1_; -const PredType& PredType::FORTRAN_S1 = *FORTRAN_S1_; - -const PredType& PredType::IEEE_F32BE = *IEEE_F32BE_; -const PredType& PredType::IEEE_F32LE = *IEEE_F32LE_; -const PredType& PredType::IEEE_F64BE = *IEEE_F64BE_; -const PredType& PredType::IEEE_F64LE = *IEEE_F64LE_; - -const PredType& PredType::UNIX_D32BE = *UNIX_D32BE_; -const PredType& PredType::UNIX_D32LE = *UNIX_D32LE_; -const PredType& PredType::UNIX_D64BE = *UNIX_D64BE_; -const PredType& PredType::UNIX_D64LE = *UNIX_D64LE_; - -const PredType& PredType::INTEL_I8 = *INTEL_I8_; -const PredType& PredType::INTEL_I16 = *INTEL_I16_; -const PredType& PredType::INTEL_I32 = *INTEL_I32_; -const PredType& PredType::INTEL_I64 = *INTEL_I64_; -const PredType& PredType::INTEL_U8 = *INTEL_U8_; -const PredType& PredType::INTEL_U16 = *INTEL_U16_; -const PredType& PredType::INTEL_U32 = *INTEL_U32_; -const PredType& PredType::INTEL_U64 = *INTEL_U64_; -const PredType& PredType::INTEL_B8 = *INTEL_B8_; -const PredType& PredType::INTEL_B16 = *INTEL_B16_; -const PredType& PredType::INTEL_B32 = *INTEL_B32_; -const PredType& PredType::INTEL_B64 = *INTEL_B64_; -const PredType& PredType::INTEL_F32 = *INTEL_F32_; -const PredType& PredType::INTEL_F64 = *INTEL_F64_; - -const PredType& PredType::ALPHA_I8 = *ALPHA_I8_; -const PredType& PredType::ALPHA_I16 = *ALPHA_I16_; -const PredType& PredType::ALPHA_I32 = *ALPHA_I32_; -const PredType& PredType::ALPHA_I64 = *ALPHA_I64_; -const PredType& PredType::ALPHA_U8 = *ALPHA_U8_; -const PredType& PredType::ALPHA_U16 = *ALPHA_U16_; -const PredType& PredType::ALPHA_U32 = *ALPHA_U32_; -const PredType& PredType::ALPHA_U64 = *ALPHA_U64_; -const PredType& PredType::ALPHA_B8 = *ALPHA_B8_; -const PredType& PredType::ALPHA_B16 = *ALPHA_B16_; -const PredType& PredType::ALPHA_B32 = *ALPHA_B32_; -const PredType& PredType::ALPHA_B64 = *ALPHA_B64_; -const PredType& PredType::ALPHA_F32 = *ALPHA_F32_; -const PredType& PredType::ALPHA_F64 = *ALPHA_F64_; - -const PredType& PredType::MIPS_I8 = *MIPS_I8_; -const PredType& PredType::MIPS_I16 = *MIPS_I16_; -const PredType& PredType::MIPS_I32 = *MIPS_I32_; -const PredType& PredType::MIPS_I64 = *MIPS_I64_; -const PredType& PredType::MIPS_U8 = *MIPS_U8_; -const PredType& PredType::MIPS_U16 = *MIPS_U16_; -const PredType& PredType::MIPS_U32 = *MIPS_U32_; -const PredType& PredType::MIPS_U64 = *MIPS_U64_; -const PredType& PredType::MIPS_B8 = *MIPS_B8_; -const PredType& PredType::MIPS_B16 = *MIPS_B16_; -const PredType& PredType::MIPS_B32 = *MIPS_B32_; -const PredType& PredType::MIPS_B64 = *MIPS_B64_; -const PredType& PredType::MIPS_F32 = *MIPS_F32_; -const PredType& PredType::MIPS_F64 = *MIPS_F64_; - -const PredType& PredType::NATIVE_CHAR = *NATIVE_CHAR_; -const PredType& PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; -const PredType& PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; -const PredType& PredType::NATIVE_SHORT = *NATIVE_SHORT_; -const PredType& PredType::NATIVE_USHORT = *NATIVE_USHORT_; -const PredType& PredType::NATIVE_INT = *NATIVE_INT_; -const PredType& PredType::NATIVE_UINT = *NATIVE_UINT_; -const PredType& PredType::NATIVE_LONG = *NATIVE_LONG_; -const PredType& PredType::NATIVE_ULONG = *NATIVE_ULONG_; -const PredType& PredType::NATIVE_LLONG = *NATIVE_LLONG_; -const PredType& PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; -const PredType& PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; -const PredType& PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; -const PredType& PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; -const PredType& PredType::NATIVE_B8 = *NATIVE_B8_; -const PredType& PredType::NATIVE_B16 = *NATIVE_B16_; -const PredType& PredType::NATIVE_B32 = *NATIVE_B32_; -const PredType& PredType::NATIVE_B64 = *NATIVE_B64_; -const PredType& PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; -const PredType& PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; -const PredType& PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; -const PredType& PredType::NATIVE_HERR = *NATIVE_HERR_; -const PredType& PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; - -const PredType& PredType::NATIVE_INT8 = *NATIVE_INT8_; -const PredType& PredType::NATIVE_UINT8 = *NATIVE_UINT8_; -const PredType& PredType::NATIVE_INT16 = *NATIVE_INT16_; -const PredType& PredType::NATIVE_UINT16 = *NATIVE_UINT16_; -const PredType& PredType::NATIVE_INT32 = *NATIVE_INT32_; -const PredType& PredType::NATIVE_UINT32 = *NATIVE_UINT32_; -const PredType& PredType::NATIVE_INT64 = *NATIVE_INT64_; -const PredType& PredType::NATIVE_UINT64 = *NATIVE_UINT64_; +const PredType &PredType::PREDTYPE_CONST = *PredType::getPredTypes(); +const PredType &PredType::STD_I8BE = *STD_I8BE_; +const PredType &PredType::STD_I8LE = *STD_I8LE_; +const PredType &PredType::STD_I16BE = *STD_I16BE_; +const PredType &PredType::STD_I16LE = *STD_I16LE_; +const PredType &PredType::STD_I32BE = *STD_I32BE_; +const PredType &PredType::STD_I32LE = *STD_I32LE_; +const PredType &PredType::STD_I64BE = *STD_I64BE_; +const PredType &PredType::STD_I64LE = *STD_I64LE_; +const PredType &PredType::STD_U8BE = *STD_U8BE_; +const PredType &PredType::STD_U8LE = *STD_U8LE_; +const PredType &PredType::STD_U16BE = *STD_U16BE_; +const PredType &PredType::STD_U16LE = *STD_U16LE_; +const PredType &PredType::STD_U32BE = *STD_U32BE_; +const PredType &PredType::STD_U32LE = *STD_U32LE_; +const PredType &PredType::STD_U64BE = *STD_U64BE_; +const PredType &PredType::STD_U64LE = *STD_U64LE_; +const PredType &PredType::STD_B8BE = *STD_B8BE_; +const PredType &PredType::STD_B8LE = *STD_B8LE_; +const PredType &PredType::STD_B16BE = *STD_B16BE_; +const PredType &PredType::STD_B16LE = *STD_B16LE_; +const PredType &PredType::STD_B32BE = *STD_B32BE_; +const PredType &PredType::STD_B32LE = *STD_B32LE_; +const PredType &PredType::STD_B64BE = *STD_B64BE_; +const PredType &PredType::STD_B64LE = *STD_B64LE_; +const PredType &PredType::STD_REF_OBJ = *STD_REF_OBJ_; +const PredType &PredType::STD_REF_DSETREG = *STD_REF_DSETREG_; + +const PredType &PredType::C_S1 = *C_S1_; +const PredType &PredType::FORTRAN_S1 = *FORTRAN_S1_; + +const PredType &PredType::IEEE_F32BE = *IEEE_F32BE_; +const PredType &PredType::IEEE_F32LE = *IEEE_F32LE_; +const PredType &PredType::IEEE_F64BE = *IEEE_F64BE_; +const PredType &PredType::IEEE_F64LE = *IEEE_F64LE_; + +const PredType &PredType::UNIX_D32BE = *UNIX_D32BE_; +const PredType &PredType::UNIX_D32LE = *UNIX_D32LE_; +const PredType &PredType::UNIX_D64BE = *UNIX_D64BE_; +const PredType &PredType::UNIX_D64LE = *UNIX_D64LE_; + +const PredType &PredType::INTEL_I8 = *INTEL_I8_; +const PredType &PredType::INTEL_I16 = *INTEL_I16_; +const PredType &PredType::INTEL_I32 = *INTEL_I32_; +const PredType &PredType::INTEL_I64 = *INTEL_I64_; +const PredType &PredType::INTEL_U8 = *INTEL_U8_; +const PredType &PredType::INTEL_U16 = *INTEL_U16_; +const PredType &PredType::INTEL_U32 = *INTEL_U32_; +const PredType &PredType::INTEL_U64 = *INTEL_U64_; +const PredType &PredType::INTEL_B8 = *INTEL_B8_; +const PredType &PredType::INTEL_B16 = *INTEL_B16_; +const PredType &PredType::INTEL_B32 = *INTEL_B32_; +const PredType &PredType::INTEL_B64 = *INTEL_B64_; +const PredType &PredType::INTEL_F32 = *INTEL_F32_; +const PredType &PredType::INTEL_F64 = *INTEL_F64_; + +const PredType &PredType::ALPHA_I8 = *ALPHA_I8_; +const PredType &PredType::ALPHA_I16 = *ALPHA_I16_; +const PredType &PredType::ALPHA_I32 = *ALPHA_I32_; +const PredType &PredType::ALPHA_I64 = *ALPHA_I64_; +const PredType &PredType::ALPHA_U8 = *ALPHA_U8_; +const PredType &PredType::ALPHA_U16 = *ALPHA_U16_; +const PredType &PredType::ALPHA_U32 = *ALPHA_U32_; +const PredType &PredType::ALPHA_U64 = *ALPHA_U64_; +const PredType &PredType::ALPHA_B8 = *ALPHA_B8_; +const PredType &PredType::ALPHA_B16 = *ALPHA_B16_; +const PredType &PredType::ALPHA_B32 = *ALPHA_B32_; +const PredType &PredType::ALPHA_B64 = *ALPHA_B64_; +const PredType &PredType::ALPHA_F32 = *ALPHA_F32_; +const PredType &PredType::ALPHA_F64 = *ALPHA_F64_; + +const PredType &PredType::MIPS_I8 = *MIPS_I8_; +const PredType &PredType::MIPS_I16 = *MIPS_I16_; +const PredType &PredType::MIPS_I32 = *MIPS_I32_; +const PredType &PredType::MIPS_I64 = *MIPS_I64_; +const PredType &PredType::MIPS_U8 = *MIPS_U8_; +const PredType &PredType::MIPS_U16 = *MIPS_U16_; +const PredType &PredType::MIPS_U32 = *MIPS_U32_; +const PredType &PredType::MIPS_U64 = *MIPS_U64_; +const PredType &PredType::MIPS_B8 = *MIPS_B8_; +const PredType &PredType::MIPS_B16 = *MIPS_B16_; +const PredType &PredType::MIPS_B32 = *MIPS_B32_; +const PredType &PredType::MIPS_B64 = *MIPS_B64_; +const PredType &PredType::MIPS_F32 = *MIPS_F32_; +const PredType &PredType::MIPS_F64 = *MIPS_F64_; + +const PredType &PredType::NATIVE_CHAR = *NATIVE_CHAR_; +const PredType &PredType::NATIVE_SCHAR = *NATIVE_SCHAR_; +const PredType &PredType::NATIVE_UCHAR = *NATIVE_UCHAR_; +const PredType &PredType::NATIVE_SHORT = *NATIVE_SHORT_; +const PredType &PredType::NATIVE_USHORT = *NATIVE_USHORT_; +const PredType &PredType::NATIVE_INT = *NATIVE_INT_; +const PredType &PredType::NATIVE_UINT = *NATIVE_UINT_; +const PredType &PredType::NATIVE_LONG = *NATIVE_LONG_; +const PredType &PredType::NATIVE_ULONG = *NATIVE_ULONG_; +const PredType &PredType::NATIVE_LLONG = *NATIVE_LLONG_; +const PredType &PredType::NATIVE_ULLONG = *NATIVE_ULLONG_; +const PredType &PredType::NATIVE_FLOAT = *NATIVE_FLOAT_; +const PredType &PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_; +const PredType &PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_; +const PredType &PredType::NATIVE_B8 = *NATIVE_B8_; +const PredType &PredType::NATIVE_B16 = *NATIVE_B16_; +const PredType &PredType::NATIVE_B32 = *NATIVE_B32_; +const PredType &PredType::NATIVE_B64 = *NATIVE_B64_; +const PredType &PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_; +const PredType &PredType::NATIVE_HSIZE = *NATIVE_HSIZE_; +const PredType &PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_; +const PredType &PredType::NATIVE_HERR = *NATIVE_HERR_; +const PredType &PredType::NATIVE_HBOOL = *NATIVE_HBOOL_; + +const PredType &PredType::NATIVE_INT8 = *NATIVE_INT8_; +const PredType &PredType::NATIVE_UINT8 = *NATIVE_UINT8_; +const PredType &PredType::NATIVE_INT16 = *NATIVE_INT16_; +const PredType &PredType::NATIVE_UINT16 = *NATIVE_UINT16_; +const PredType &PredType::NATIVE_INT32 = *NATIVE_INT32_; +const PredType &PredType::NATIVE_UINT32 = *NATIVE_UINT32_; +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_; +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_UINT_LEAST8 = *NATIVE_UINT_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_; +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_UINT_LEAST16 = *NATIVE_UINT_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_; +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_UINT_LEAST32 = *NATIVE_UINT_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_; +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_UINT_LEAST64 = *NATIVE_UINT_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_; +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_UINT_FAST8 = *NATIVE_UINT_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_; +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_UINT_FAST16 = *NATIVE_UINT_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_; +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_UINT_FAST32 = *NATIVE_UINT_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_; +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_UINT_FAST64 = *NATIVE_UINT_FAST64_; +const PredType &PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ #endif // DOXYGEN_SHOULD_SKIP_THIS -} // end namespace +} // namespace H5 /*************************************************************************** Design Note @@ -1102,4 +1118,3 @@ September 2015: using PropList's because of the class types and in favor of clarity. ****************************************************************************/ - diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 097838418b6..b40d2b3782d 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5PredType_H -#define __H5PredType_H +#ifndef H5PredType_H +#define H5PredType_H namespace H5 { @@ -26,416 +26,420 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP PredType : public AtomType { - public: - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PredType"); } - - // Makes a copy of the predefined type and stores the new - // id in the left hand side object. - PredType& operator=(const PredType& rhs); - - // Copy constructor: same as the original PredType. - PredType(const PredType& original); - - // Noop destructor - virtual ~PredType(); - - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const H5std_string& name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - void commit(H5Location& loc, const char* name); - /*! \brief This dummy function do not inherit from DataType - it will - throw a DataTypeIException if invoked. - */ - bool committed(); - - ///\brief PredType constants - static const PredType& STD_I8BE; - static const PredType& STD_I8LE; - static const PredType& STD_I16BE; - static const PredType& STD_I16LE; - static const PredType& STD_I32BE; - static const PredType& STD_I32LE; - static const PredType& STD_I64BE; - static const PredType& STD_I64LE; - static const PredType& STD_U8BE; - static const PredType& STD_U8LE; - static const PredType& STD_U16BE; - static const PredType& STD_U16LE; - static const PredType& STD_U32BE; - static const PredType& STD_U32LE; - static const PredType& STD_U64BE; - static const PredType& STD_U64LE; - static const PredType& STD_B8BE; - static const PredType& STD_B8LE; - static const PredType& STD_B16BE; - static const PredType& STD_B16LE; - static const PredType& STD_B32BE; - static const PredType& STD_B32LE; - static const PredType& STD_B64BE; - static const PredType& STD_B64LE; - static const PredType& STD_REF_OBJ; - static const PredType& STD_REF_DSETREG; - - static const PredType& C_S1; - static const PredType& FORTRAN_S1; - - static const PredType& IEEE_F32BE; - static const PredType& IEEE_F32LE; - static const PredType& IEEE_F64BE; - static const PredType& IEEE_F64LE; - - static const PredType& UNIX_D32BE; - static const PredType& UNIX_D32LE; - static const PredType& UNIX_D64BE; - static const PredType& UNIX_D64LE; - - static const PredType& INTEL_I8; - static const PredType& INTEL_I16; - static const PredType& INTEL_I32; - static const PredType& INTEL_I64; - static const PredType& INTEL_U8; - static const PredType& INTEL_U16; - static const PredType& INTEL_U32; - static const PredType& INTEL_U64; - static const PredType& INTEL_B8; - static const PredType& INTEL_B16; - static const PredType& INTEL_B32; - static const PredType& INTEL_B64; - static const PredType& INTEL_F32; - static const PredType& INTEL_F64; - - static const PredType& ALPHA_I8; - static const PredType& ALPHA_I16; - static const PredType& ALPHA_I32; - static const PredType& ALPHA_I64; - static const PredType& ALPHA_U8; - static const PredType& ALPHA_U16; - static const PredType& ALPHA_U32; - static const PredType& ALPHA_U64; - static const PredType& ALPHA_B8; - static const PredType& ALPHA_B16; - static const PredType& ALPHA_B32; - static const PredType& ALPHA_B64; - static const PredType& ALPHA_F32; - static const PredType& ALPHA_F64; - - static const PredType& MIPS_I8; - static const PredType& MIPS_I16; - static const PredType& MIPS_I32; - static const PredType& MIPS_I64; - static const PredType& MIPS_U8; - static const PredType& MIPS_U16; - static const PredType& MIPS_U32; - static const PredType& MIPS_U64; - static const PredType& MIPS_B8; - static const PredType& MIPS_B16; - static const PredType& MIPS_B32; - static const PredType& MIPS_B64; - static const PredType& MIPS_F32; - static const PredType& MIPS_F64; - - static const PredType& NATIVE_CHAR; - static const PredType& NATIVE_SCHAR; - static const PredType& NATIVE_UCHAR; - static const PredType& NATIVE_SHORT; - static const PredType& NATIVE_USHORT; - static const PredType& NATIVE_INT; - static const PredType& NATIVE_UINT; - static const PredType& NATIVE_LONG; - static const PredType& NATIVE_ULONG; - static const PredType& NATIVE_LLONG; - static const PredType& NATIVE_ULLONG; - static const PredType& NATIVE_FLOAT; - static const PredType& NATIVE_DOUBLE; - static const PredType& NATIVE_LDOUBLE; - static const PredType& NATIVE_B8; - static const PredType& NATIVE_B16; - static const PredType& NATIVE_B32; - static const PredType& NATIVE_B64; - static const PredType& NATIVE_OPAQUE; - static const PredType& NATIVE_HSIZE; - static const PredType& NATIVE_HSSIZE; - static const PredType& NATIVE_HERR; - static const PredType& NATIVE_HBOOL; - - static const PredType& NATIVE_INT8; - static const PredType& NATIVE_UINT8; - static const PredType& NATIVE_INT16; - static const PredType& NATIVE_UINT16; - static const PredType& NATIVE_INT32; - static const PredType& NATIVE_UINT32; - static const PredType& NATIVE_INT64; - static const PredType& NATIVE_UINT64; + public: + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PredType"); + } + + // Makes a copy of the predefined type and stores the new + // id in the left hand side object. + PredType &operator=(const PredType &rhs); + + // Copy constructor: same as the original PredType. + PredType(const PredType &original); + + // Noop destructor + virtual ~PredType(); + + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const H5std_string &name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + void commit(H5Location &loc, const char *name); + /*! \brief This dummy function do not inherit from DataType - it will + throw a DataTypeIException if invoked. + */ + bool committed(); + + ///\brief PredType constants + static const PredType &STD_I8BE; + static const PredType &STD_I8LE; + static const PredType &STD_I16BE; + static const PredType &STD_I16LE; + static const PredType &STD_I32BE; + static const PredType &STD_I32LE; + static const PredType &STD_I64BE; + static const PredType &STD_I64LE; + static const PredType &STD_U8BE; + static const PredType &STD_U8LE; + static const PredType &STD_U16BE; + static const PredType &STD_U16LE; + static const PredType &STD_U32BE; + static const PredType &STD_U32LE; + static const PredType &STD_U64BE; + static const PredType &STD_U64LE; + static const PredType &STD_B8BE; + static const PredType &STD_B8LE; + static const PredType &STD_B16BE; + static const PredType &STD_B16LE; + static const PredType &STD_B32BE; + static const PredType &STD_B32LE; + static const PredType &STD_B64BE; + static const PredType &STD_B64LE; + static const PredType &STD_REF_OBJ; + static const PredType &STD_REF_DSETREG; + + static const PredType &C_S1; + static const PredType &FORTRAN_S1; + + static const PredType &IEEE_F32BE; + static const PredType &IEEE_F32LE; + static const PredType &IEEE_F64BE; + static const PredType &IEEE_F64LE; + + static const PredType &UNIX_D32BE; + static const PredType &UNIX_D32LE; + static const PredType &UNIX_D64BE; + static const PredType &UNIX_D64LE; + + static const PredType &INTEL_I8; + static const PredType &INTEL_I16; + static const PredType &INTEL_I32; + static const PredType &INTEL_I64; + static const PredType &INTEL_U8; + static const PredType &INTEL_U16; + static const PredType &INTEL_U32; + static const PredType &INTEL_U64; + static const PredType &INTEL_B8; + static const PredType &INTEL_B16; + static const PredType &INTEL_B32; + static const PredType &INTEL_B64; + static const PredType &INTEL_F32; + static const PredType &INTEL_F64; + + static const PredType &ALPHA_I8; + static const PredType &ALPHA_I16; + static const PredType &ALPHA_I32; + static const PredType &ALPHA_I64; + static const PredType &ALPHA_U8; + static const PredType &ALPHA_U16; + static const PredType &ALPHA_U32; + static const PredType &ALPHA_U64; + static const PredType &ALPHA_B8; + static const PredType &ALPHA_B16; + static const PredType &ALPHA_B32; + static const PredType &ALPHA_B64; + static const PredType &ALPHA_F32; + static const PredType &ALPHA_F64; + + static const PredType &MIPS_I8; + static const PredType &MIPS_I16; + static const PredType &MIPS_I32; + static const PredType &MIPS_I64; + static const PredType &MIPS_U8; + static const PredType &MIPS_U16; + static const PredType &MIPS_U32; + static const PredType &MIPS_U64; + static const PredType &MIPS_B8; + static const PredType &MIPS_B16; + static const PredType &MIPS_B32; + static const PredType &MIPS_B64; + static const PredType &MIPS_F32; + static const PredType &MIPS_F64; + + static const PredType &NATIVE_CHAR; + static const PredType &NATIVE_SCHAR; + static const PredType &NATIVE_UCHAR; + static const PredType &NATIVE_SHORT; + static const PredType &NATIVE_USHORT; + static const PredType &NATIVE_INT; + static const PredType &NATIVE_UINT; + static const PredType &NATIVE_LONG; + static const PredType &NATIVE_ULONG; + static const PredType &NATIVE_LLONG; + static const PredType &NATIVE_ULLONG; + static const PredType &NATIVE_FLOAT; + static const PredType &NATIVE_DOUBLE; + static const PredType &NATIVE_LDOUBLE; + static const PredType &NATIVE_B8; + static const PredType &NATIVE_B16; + static const PredType &NATIVE_B32; + static const PredType &NATIVE_B64; + static const PredType &NATIVE_OPAQUE; + static const PredType &NATIVE_HSIZE; + static const PredType &NATIVE_HSSIZE; + static const PredType &NATIVE_HERR; + static const PredType &NATIVE_HBOOL; + + static const PredType &NATIVE_INT8; + static const PredType &NATIVE_UINT8; + static const PredType &NATIVE_INT16; + static const PredType &NATIVE_UINT16; + static const PredType &NATIVE_INT32; + static const PredType &NATIVE_UINT32; + static const PredType &NATIVE_INT64; + static const PredType &NATIVE_UINT64; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static const PredType& NATIVE_INT_LEAST8; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + static const PredType &NATIVE_UINT_LEAST64; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static const PredType& NATIVE_INT_FAST8; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + static const PredType &NATIVE_UINT_FAST64; #endif /* H5_SIZEOF_UINT_FAST64_T */ #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PredType global constants - static void deleteConstants(); - - // Dummy constant - static const PredType& PREDTYPE_CONST; // dummy constant - - protected: - // Default constructor - PredType(); - - // Creates a pre-defined type using an HDF5 pre-defined constant - PredType(const hid_t predtype_id); // used by the library only - - private: - // Activates the creation of the PredType global constants - static PredType* getPredTypes(); - - // Dynamically allocates PredType global constants - static void makePredTypes(); - - // Dummy constant - static PredType* PREDTYPE_CONST_; - - // Declaration of pointers to constants - static PredType* STD_I8BE_; - static PredType* STD_I8LE_; - static PredType* STD_I16BE_; - static PredType* STD_I16LE_; - static PredType* STD_I32BE_; - static PredType* STD_I32LE_; - static PredType* STD_I64BE_; - static PredType* STD_I64LE_; - static PredType* STD_U8BE_; - static PredType* STD_U8LE_; - static PredType* STD_U16BE_; - static PredType* STD_U16LE_; - static PredType* STD_U32BE_; - static PredType* STD_U32LE_; - static PredType* STD_U64BE_; - static PredType* STD_U64LE_; - static PredType* STD_B8BE_; - static PredType* STD_B8LE_; - static PredType* STD_B16BE_; - static PredType* STD_B16LE_; - static PredType* STD_B32BE_; - static PredType* STD_B32LE_; - static PredType* STD_B64BE_; - static PredType* STD_B64LE_; - static PredType* STD_REF_OBJ_; - static PredType* STD_REF_DSETREG_; - - static PredType* C_S1_; - static PredType* FORTRAN_S1_; - - static PredType* IEEE_F32BE_; - static PredType* IEEE_F32LE_; - static PredType* IEEE_F64BE_; - static PredType* IEEE_F64LE_; - - static PredType* UNIX_D32BE_; - static PredType* UNIX_D32LE_; - static PredType* UNIX_D64BE_; - static PredType* UNIX_D64LE_; - - static PredType* INTEL_I8_; - static PredType* INTEL_I16_; - static PredType* INTEL_I32_; - static PredType* INTEL_I64_; - static PredType* INTEL_U8_; - static PredType* INTEL_U16_; - static PredType* INTEL_U32_; - static PredType* INTEL_U64_; - static PredType* INTEL_B8_; - static PredType* INTEL_B16_; - static PredType* INTEL_B32_; - static PredType* INTEL_B64_; - static PredType* INTEL_F32_; - static PredType* INTEL_F64_; - - static PredType* ALPHA_I8_; - static PredType* ALPHA_I16_; - static PredType* ALPHA_I32_; - static PredType* ALPHA_I64_; - static PredType* ALPHA_U8_; - static PredType* ALPHA_U16_; - static PredType* ALPHA_U32_; - static PredType* ALPHA_U64_; - static PredType* ALPHA_B8_; - static PredType* ALPHA_B16_; - static PredType* ALPHA_B32_; - static PredType* ALPHA_B64_; - static PredType* ALPHA_F32_; - static PredType* ALPHA_F64_; - - static PredType* MIPS_I8_; - static PredType* MIPS_I16_; - static PredType* MIPS_I32_; - static PredType* MIPS_I64_; - static PredType* MIPS_U8_; - static PredType* MIPS_U16_; - static PredType* MIPS_U32_; - static PredType* MIPS_U64_; - static PredType* MIPS_B8_; - static PredType* MIPS_B16_; - static PredType* MIPS_B32_; - static PredType* MIPS_B64_; - static PredType* MIPS_F32_; - static PredType* MIPS_F64_; - - static PredType* NATIVE_CHAR_; - static PredType* NATIVE_SCHAR_; - static PredType* NATIVE_UCHAR_; - static PredType* NATIVE_SHORT_; - static PredType* NATIVE_USHORT_; - static PredType* NATIVE_INT_; - static PredType* NATIVE_UINT_; - static PredType* NATIVE_LONG_; - static PredType* NATIVE_ULONG_; - static PredType* NATIVE_LLONG_; - static PredType* NATIVE_ULLONG_; - static PredType* NATIVE_FLOAT_; - static PredType* NATIVE_DOUBLE_; - static PredType* NATIVE_LDOUBLE_; - static PredType* NATIVE_B8_; - static PredType* NATIVE_B16_; - static PredType* NATIVE_B32_; - static PredType* NATIVE_B64_; - static PredType* NATIVE_OPAQUE_; - static PredType* NATIVE_HSIZE_; - static PredType* NATIVE_HSSIZE_; - static PredType* NATIVE_HERR_; - static PredType* NATIVE_HBOOL_; - - static PredType* NATIVE_INT8_; - static PredType* NATIVE_UINT8_; - static PredType* NATIVE_INT16_; - static PredType* NATIVE_UINT16_; - static PredType* NATIVE_INT32_; - static PredType* NATIVE_UINT32_; - static PredType* NATIVE_INT64_; - static PredType* NATIVE_UINT64_; + // Deletes the PredType global constants + static void deleteConstants(); + + // Dummy constant + static const PredType &PREDTYPE_CONST; // dummy constant + + protected: + // Default constructor + PredType(); + + // Creates a pre-defined type using an HDF5 pre-defined constant + PredType(const hid_t predtype_id); // used by the library only + + private: + // Activates the creation of the PredType global constants + static PredType *getPredTypes(); + + // Dynamically allocates PredType global constants + static void makePredTypes(); + + // Dummy constant + static PredType *PREDTYPE_CONST_; + + // Declaration of pointers to constants + static PredType *STD_I8BE_; + static PredType *STD_I8LE_; + static PredType *STD_I16BE_; + static PredType *STD_I16LE_; + static PredType *STD_I32BE_; + static PredType *STD_I32LE_; + static PredType *STD_I64BE_; + static PredType *STD_I64LE_; + static PredType *STD_U8BE_; + static PredType *STD_U8LE_; + static PredType *STD_U16BE_; + static PredType *STD_U16LE_; + static PredType *STD_U32BE_; + static PredType *STD_U32LE_; + static PredType *STD_U64BE_; + static PredType *STD_U64LE_; + static PredType *STD_B8BE_; + static PredType *STD_B8LE_; + static PredType *STD_B16BE_; + static PredType *STD_B16LE_; + static PredType *STD_B32BE_; + static PredType *STD_B32LE_; + static PredType *STD_B64BE_; + static PredType *STD_B64LE_; + static PredType *STD_REF_OBJ_; + static PredType *STD_REF_DSETREG_; + + static PredType *C_S1_; + static PredType *FORTRAN_S1_; + + static PredType *IEEE_F32BE_; + static PredType *IEEE_F32LE_; + static PredType *IEEE_F64BE_; + static PredType *IEEE_F64LE_; + + static PredType *UNIX_D32BE_; + static PredType *UNIX_D32LE_; + static PredType *UNIX_D64BE_; + static PredType *UNIX_D64LE_; + + static PredType *INTEL_I8_; + static PredType *INTEL_I16_; + static PredType *INTEL_I32_; + static PredType *INTEL_I64_; + static PredType *INTEL_U8_; + static PredType *INTEL_U16_; + static PredType *INTEL_U32_; + static PredType *INTEL_U64_; + static PredType *INTEL_B8_; + static PredType *INTEL_B16_; + static PredType *INTEL_B32_; + static PredType *INTEL_B64_; + static PredType *INTEL_F32_; + static PredType *INTEL_F64_; + + static PredType *ALPHA_I8_; + static PredType *ALPHA_I16_; + static PredType *ALPHA_I32_; + static PredType *ALPHA_I64_; + static PredType *ALPHA_U8_; + static PredType *ALPHA_U16_; + static PredType *ALPHA_U32_; + static PredType *ALPHA_U64_; + static PredType *ALPHA_B8_; + static PredType *ALPHA_B16_; + static PredType *ALPHA_B32_; + static PredType *ALPHA_B64_; + static PredType *ALPHA_F32_; + static PredType *ALPHA_F64_; + + static PredType *MIPS_I8_; + static PredType *MIPS_I16_; + static PredType *MIPS_I32_; + static PredType *MIPS_I64_; + static PredType *MIPS_U8_; + static PredType *MIPS_U16_; + static PredType *MIPS_U32_; + static PredType *MIPS_U64_; + static PredType *MIPS_B8_; + static PredType *MIPS_B16_; + static PredType *MIPS_B32_; + static PredType *MIPS_B64_; + static PredType *MIPS_F32_; + static PredType *MIPS_F64_; + + static PredType *NATIVE_CHAR_; + static PredType *NATIVE_SCHAR_; + static PredType *NATIVE_UCHAR_; + static PredType *NATIVE_SHORT_; + static PredType *NATIVE_USHORT_; + static PredType *NATIVE_INT_; + static PredType *NATIVE_UINT_; + static PredType *NATIVE_LONG_; + static PredType *NATIVE_ULONG_; + static PredType *NATIVE_LLONG_; + static PredType *NATIVE_ULLONG_; + static PredType *NATIVE_FLOAT_; + static PredType *NATIVE_DOUBLE_; + static PredType *NATIVE_LDOUBLE_; + static PredType *NATIVE_B8_; + static PredType *NATIVE_B16_; + static PredType *NATIVE_B32_; + static PredType *NATIVE_B64_; + static PredType *NATIVE_OPAQUE_; + static PredType *NATIVE_HSIZE_; + static PredType *NATIVE_HSSIZE_; + static PredType *NATIVE_HERR_; + static PredType *NATIVE_HBOOL_; + + static PredType *NATIVE_INT8_; + static PredType *NATIVE_UINT8_; + static PredType *NATIVE_INT16_; + static PredType *NATIVE_UINT16_; + static PredType *NATIVE_INT32_; + static PredType *NATIVE_UINT32_; + static PredType *NATIVE_INT64_; + static PredType *NATIVE_UINT64_; // LEAST types #if H5_SIZEOF_INT_LEAST8_T != 0 - static PredType* NATIVE_INT_LEAST8_; + static PredType *NATIVE_INT_LEAST8_; #endif /* H5_SIZEOF_INT_LEAST8_T */ #if H5_SIZEOF_UINT_LEAST8_T != 0 - static PredType* NATIVE_UINT_LEAST8_; + static PredType *NATIVE_UINT_LEAST8_; #endif /* H5_SIZEOF_UINT_LEAST8_T */ #if H5_SIZEOF_INT_LEAST16_T != 0 - static PredType* NATIVE_INT_LEAST16_; + static PredType *NATIVE_INT_LEAST16_; #endif /* H5_SIZEOF_INT_LEAST16_T */ #if H5_SIZEOF_UINT_LEAST16_T != 0 - static PredType* NATIVE_UINT_LEAST16_; + static PredType *NATIVE_UINT_LEAST16_; #endif /* H5_SIZEOF_UINT_LEAST16_T */ #if H5_SIZEOF_INT_LEAST32_T != 0 - static PredType* NATIVE_INT_LEAST32_; + static PredType *NATIVE_INT_LEAST32_; #endif /* H5_SIZEOF_INT_LEAST32_T */ #if H5_SIZEOF_UINT_LEAST32_T != 0 - static PredType* NATIVE_UINT_LEAST32_; + static PredType *NATIVE_UINT_LEAST32_; #endif /* H5_SIZEOF_UINT_LEAST32_T */ #if H5_SIZEOF_INT_LEAST64_T != 0 - static PredType* NATIVE_INT_LEAST64_; + static PredType *NATIVE_INT_LEAST64_; #endif /* H5_SIZEOF_INT_LEAST64_T */ #if H5_SIZEOF_UINT_LEAST64_T != 0 - static PredType* NATIVE_UINT_LEAST64_; + static PredType *NATIVE_UINT_LEAST64_; #endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types #if H5_SIZEOF_INT_FAST8_T != 0 - static PredType* NATIVE_INT_FAST8_; + static PredType *NATIVE_INT_FAST8_; #endif /* H5_SIZEOF_INT_FAST8_T */ #if H5_SIZEOF_UINT_FAST8_T != 0 - static PredType* NATIVE_UINT_FAST8_; + static PredType *NATIVE_UINT_FAST8_; #endif /* H5_SIZEOF_UINT_FAST8_T */ #if H5_SIZEOF_INT_FAST16_T != 0 - static PredType* NATIVE_INT_FAST16_; + static PredType *NATIVE_INT_FAST16_; #endif /* H5_SIZEOF_INT_FAST16_T */ #if H5_SIZEOF_UINT_FAST16_T != 0 - static PredType* NATIVE_UINT_FAST16_; + static PredType *NATIVE_UINT_FAST16_; #endif /* H5_SIZEOF_UINT_FAST16_T */ #if H5_SIZEOF_INT_FAST32_T != 0 - static PredType* NATIVE_INT_FAST32_; + static PredType *NATIVE_INT_FAST32_; #endif /* H5_SIZEOF_INT_FAST32_T */ #if H5_SIZEOF_UINT_FAST32_T != 0 - static PredType* NATIVE_UINT_FAST32_; + static PredType *NATIVE_UINT_FAST32_; #endif /* H5_SIZEOF_UINT_FAST32_T */ #if H5_SIZEOF_INT_FAST64_T != 0 - static PredType* NATIVE_INT_FAST64_; + static PredType *NATIVE_INT_FAST64_; #endif /* H5_SIZEOF_INT_FAST64_T */ #if H5_SIZEOF_UINT_FAST64_T != 0 - static PredType* NATIVE_UINT_FAST64_; + static PredType *NATIVE_UINT_FAST64_; #endif /* H5_SIZEOF_UINT_FAST64_T */ - // End of Declaration of pointers + // End of Declaration of pointers #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of PredType } // namespace H5 -#endif // __H5PredType_H +#endif // H5PredType_H diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 1918d27fd03..fda41148e7e 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -6,29 +6,24 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME -#include -#else #include -#endif #include -#include "H5private.h" // for HDmemset +#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" - namespace H5 { - using std::cerr; - using std::endl; +using std::cerr; +using std::endl; #ifndef DOXYGEN_SHOULD_SKIP_THIS // This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control @@ -36,7 +31,7 @@ namespace H5 { // in "H5PredType.cpp" for information. // Initialize a pointer for the constant -PropList* PropList::DEFAULT_ = 0; +PropList *PropList::DEFAULT_ = 0; //-------------------------------------------------------------------------- // Function: PropList::getConstant @@ -48,13 +43,13 @@ PropList* PropList::DEFAULT_ = 0; // throw a PropListIException. This scenario should not happen. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -PropList* PropList::getConstant() +PropList * +PropList::getConstant() { // Tell the C library not to clean up, H5Library::termH5cpp will call // H5close - more dependency if use H5Library::dontAtExit() - if (!IdComponent::H5dontAtexit_called) - { - (void) H5dont_atexit(); + if (!IdComponent::H5dontAtexit_called) { + (void)H5dont_atexit(); IdComponent::H5dontAtexit_called = true; } @@ -63,8 +58,9 @@ PropList* PropList::getConstant() if (DEFAULT_ == 0) DEFAULT_ = new PropList(H5P_DEFAULT); else - throw PropListIException("PropList::getConstant", "PropList::getConstant is being invoked on an allocated DEFAULT_"); - return(DEFAULT_); + throw PropListIException("PropList::getConstant", + "PropList::getConstant is being invoked on an allocated DEFAULT_"); + return (DEFAULT_); } //-------------------------------------------------------------------------- @@ -72,7 +68,8 @@ PropList* PropList::getConstant() // Purpose Deletes the constant object that PropList::DEFAULT_ points to. // Programmer Binh-Minh Ribler - 2015 //-------------------------------------------------------------------------- -void PropList::deleteConstants() +void +PropList::deleteConstants() { if (DEFAULT_ != 0) delete DEFAULT_; @@ -81,7 +78,7 @@ void PropList::deleteConstants() //-------------------------------------------------------------------------- // Purpose Constant for default property. //-------------------------------------------------------------------------- -const PropList& PropList::DEFAULT = *getConstant(); +const PropList &PropList::DEFAULT = *getConstant(); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -90,7 +87,9 @@ const PropList& PropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} +PropList::PropList() : IdComponent(), id(H5P_DEFAULT) +{ +} //-------------------------------------------------------------------------- // Function: PropList copy constructor @@ -98,7 +97,7 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} ///\param original - IN: The original property list to copy // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList(const PropList& original) : IdComponent(), id(original.id) +PropList::PropList(const PropList &original) : IdComponent(), id(original.id) { incRefCount(); // increment number of references to this id } @@ -123,21 +122,19 @@ PropList::PropList(const hid_t plist_id) : IdComponent() H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: - // call C routine to create a new property from the given prop class - id = H5Pcreate(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcreate failed"); - } - break; + // call C routine to create a new property from the given prop class + id = H5Pcreate(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcreate failed"); + } + break; case H5I_GENPROP_LST: - // call C routine to make a copy of the given property list - id = H5Pcopy(plist_id); - if (id < 0) - { - throw PropListIException("PropList constructor", "H5Pcopy failed"); - } - break; + // call C routine to make a copy of the given property list + id = H5Pcopy(plist_id); + if (id < 0) { + throw PropListIException("PropList constructor", "H5Pcopy failed"); + } + break; /* These should really be error cases, but changing that breaks * the stated behavior and causes test failures. * (DER, July 2017) @@ -149,16 +146,18 @@ PropList::PropList(const hid_t plist_id) : IdComponent() case H5I_DATASPACE: case H5I_DATASET: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_ERROR_CLASS: case H5I_ERROR_MSG: case H5I_ERROR_STACK: case H5I_NTYPES: case H5I_UNINIT: + case H5I_MAP: + case H5I_SPACE_SEL_ITER: default: - id = H5P_DEFAULT; - break; + id = H5P_DEFAULT; + break; } } @@ -174,14 +173,15 @@ PropList::PropList(const hid_t plist_id) : IdComponent() // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void PropList::copy(const PropList& like_plist) +void +PropList::copy(const PropList &like_plist) { // If this object is representing an hdf5 object, close it before // copying like_plist to it try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -202,11 +202,12 @@ void PropList::copy(const PropList& like_plist) // and stores the new id in the left hand side object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList& PropList::operator=(const PropList& rhs) +PropList & +PropList::operator=(const PropList &rhs) { if (this != &rhs) copy(rhs); - return(*this); + return (*this); } //-------------------------------------------------------------------------- @@ -217,12 +218,12 @@ PropList& PropList::operator=(const PropList& rhs) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const char *name) const +void +PropList::copyProp(PropList &dest, const char *name) const { - hid_t dst_id = dest.getId(); + hid_t dst_id = dest.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } } @@ -236,7 +237,8 @@ void PropList::copyProp(PropList& dest, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - Jul, 2005 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, const H5std_string &name) const { copyProp(dest, name.c_str()); } @@ -251,16 +253,15 @@ void PropList::copyProp(PropList& dest, const H5std_string& name) const ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const char *name) const +void +PropList::copyProp(PropList &dest, PropList &src, const char *name) const { - hid_t dst_id = dest.getId(); - hid_t src_id = src.getId(); + hid_t dst_id = dest.getId(); + hid_t src_id = src.getId(); herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } - } //-------------------------------------------------------------------------- @@ -273,7 +274,8 @@ void PropList::copyProp(PropList& dest, PropList& src, const char *name) const ///\param name - IN: Name of the property to copy - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) const +void +PropList::copyProp(PropList &dest, PropList &src, const H5std_string &name) const { copyProp(dest, src, name.c_str()); } @@ -289,9 +291,10 @@ void PropList::copyProp(PropList& dest, PropList& src, const H5std_string& name) // IdComponent::getId now becomes pure virtual function. // Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- -hid_t PropList::getId() const +hid_t +PropList::getId() const { - return(id); + return (id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -307,17 +310,18 @@ hid_t PropList::getId() const // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void PropList::p_setId(const hid_t new_id) +void +PropList::p_setId(const hid_t new_id) { // handling references to this old id try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -329,13 +333,12 @@ void PropList::p_setId(const hid_t new_id) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void PropList::close() +void +PropList::close() { - if (p_valid_id(id)) - { + if (p_valid_id(id)) { herr_t ret_value = H5Pclose(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("close"), "H5Pclose failed"); } // reset the id @@ -350,15 +353,14 @@ void PropList::close() ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -hid_t PropList::getClass() const +hid_t +PropList::getClass() const { hid_t plist_class = H5Pget_class(id); - if (plist_class == H5P_ROOT) - { - throw PropListIException(inMemFunc("getClass"), - "H5Pget_class failed - returned H5P_ROOT"); + if (plist_class == H5P_ROOT) { + throw PropListIException(inMemFunc("getClass"), "H5Pget_class failed - returned H5P_ROOT"); } - return(plist_class); + return (plist_class); } //-------------------------------------------------------------------------- @@ -373,7 +375,8 @@ hid_t PropList::getClass() const /// list or class. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const char* name) const +bool +PropList::propExist(const char *name) const { // Calls C routine H5Pexist to determine whether a property exists // within a property list or class. It returns a positive value, 0, @@ -396,9 +399,10 @@ bool PropList::propExist(const char* name) const ///\param name - IN: Name of property to check for - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::propExist(const H5std_string& name) const +bool +PropList::propExist(const H5std_string &name) const { - return(propExist( name.c_str())); + return (propExist(name.c_str())); } //-------------------------------------------------------------------------- @@ -411,11 +415,11 @@ bool PropList::propExist(const H5std_string& name) const /// list class hierarchy. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::closeClass() const +void +PropList::closeClass() const { herr_t ret_value = H5Pclose_class(id); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); } } @@ -432,11 +436,11 @@ void PropList::closeClass() const /// throw an exception. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const char* name, void* value) const +void +PropList::getProperty(const char *name, void *value) const { herr_t ret_value = H5Pget(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } } @@ -450,27 +454,27 @@ void PropList::getProperty(const char* name, void* value) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const char* name) const +H5std_string +PropList::getProperty(const char *name) const { // Get property size first 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]; // temporary C-string for C API + HDmemset(prop_strg_C, 0, size + 1); // clear buffer herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API // Throw exception if H5Pget returns failure - if (ret_value < 0) - { - delete []prop_strg_C; + if (ret_value < 0) { + delete[] prop_strg_C; throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } // Return property value as a string after deleting temp C-string H5std_string prop_strg(prop_strg_C); - delete []prop_strg_C; + delete[] prop_strg_C; return (prop_strg); } //-------------------------------------------------------------------------- @@ -482,7 +486,8 @@ H5std_string PropList::getProperty(const char* name) const ///\param value - OUT: Pointer to the buffer for the property value // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::getProperty(const H5std_string& name, void* value) const +void +PropList::getProperty(const H5std_string &name, void *value) const { getProperty(name.c_str(), value); } @@ -495,7 +500,8 @@ void PropList::getProperty(const H5std_string& name, void* value) const ///\return The property that is a \c H5std_string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getProperty(const H5std_string& name) const +H5std_string +PropList::getProperty(const H5std_string &name) const { return (getProperty(name.c_str())); } @@ -513,15 +519,15 @@ H5std_string PropList::getProperty(const H5std_string& name) const /// lists and classes. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const char *name) const +size_t +PropList::getPropSize(const char *name) const { size_t prop_size; herr_t ret_value = H5Pget_size(id, name, &prop_size); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); } - return(prop_size); + return (prop_size); } //-------------------------------------------------------------------------- // Function: PropList::getPropSize @@ -532,7 +538,8 @@ size_t PropList::getPropSize(const char *name) const /// // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getPropSize(const H5std_string& name) const +size_t +PropList::getPropSize(const H5std_string &name) const { return (getPropSize(name.c_str())); } @@ -544,15 +551,15 @@ size_t PropList::getPropSize(const H5std_string& name) const /// a NULL string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -H5std_string PropList::getClassName() const +H5std_string +PropList::getClassName() const { - char* temp_str; + char *temp_str; temp_str = H5Pget_class_name(id); - if (temp_str != NULL) - { + if (temp_str != NULL) { H5std_string class_name(temp_str); H5free_memory(temp_str); - return(class_name); + return (class_name); } else return 0; @@ -564,12 +571,12 @@ H5std_string PropList::getClassName() const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -size_t PropList::getNumProps() const +size_t +PropList::getNumProps() const { size_t nprops; - herr_t ret_value = H5Pget_nprops (id, &nprops); - if (ret_value < 0) - { + herr_t ret_value = H5Pget_nprops(id, &nprops); + if (ret_value < 0) { throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); } return (nprops); @@ -586,11 +593,11 @@ size_t PropList::getNumProps() const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const void* value) const +void +PropList::setProperty(const char *name, const void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -602,11 +609,11 @@ void PropList::setProperty(const char* name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, void* value) const +void +PropList::setProperty(const char *name, void *value) const { herr_t ret_value = H5Pset(id, name, value); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -623,11 +630,11 @@ void PropList::setProperty(const char* name, void* value) const // the non-const setProperty. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const char* charptr) const +void +PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void*)charptr); - if (ret_value < 0) - { + herr_t ret_value = H5Pset(id, name, (const void *)charptr); + if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } @@ -640,7 +647,8 @@ void PropList::setProperty(const char* name, const char* charptr) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, const H5std_string& strg) const +void +PropList::setProperty(const char *name, const H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -652,7 +660,8 @@ void PropList::setProperty(const char* name, const H5std_string& strg) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const char* name, H5std_string& strg) const +void +PropList::setProperty(const char *name, H5std_string &strg) const { setProperty(name, strg.c_str()); } @@ -666,7 +675,8 @@ void PropList::setProperty(const char* name, H5std_string& strg) const ///\param value - IN: Void pointer to the value for the property // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const void* value) const +void +PropList::setProperty(const H5std_string &name, const void *value) const { setProperty(name.c_str(), value); } @@ -678,7 +688,8 @@ void PropList::setProperty(const H5std_string& name, const void* value) const // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, void* value) const +void +PropList::setProperty(const H5std_string &name, void *value) const { setProperty(name.c_str(), value); } @@ -692,7 +703,8 @@ void PropList::setProperty(const H5std_string& name, void* value) const ///\param strg - IN: Value for the property is a \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, const H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, const H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -704,7 +716,8 @@ void PropList::setProperty(const H5std_string& name, const H5std_string& strg) c // Modification // Planned for removal. -BMR, 2017/03/17 1.10.1 //-------------------------------------------------------------------------- -void PropList::setProperty(const H5std_string& name, H5std_string& strg) const +void +PropList::setProperty(const H5std_string &name, H5std_string &strg) const { setProperty(name.c_str(), strg.c_str()); } @@ -718,7 +731,8 @@ void PropList::setProperty(const H5std_string& name, H5std_string& strg) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::isAClass(const PropList& prop_class) const +bool +PropList::isAClass(const PropList &prop_class) const { htri_t ret_value = H5Pisa_class(id, prop_class.getId()); if (ret_value > 0) @@ -738,11 +752,11 @@ bool PropList::isAClass(const PropList& prop_class) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const char *name) const +void +PropList::removeProp(const char *name) const { herr_t ret_value = H5Premove(id, name); - if (ret_value < 0) - { + if (ret_value < 0) { throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); } } @@ -755,7 +769,8 @@ void PropList::removeProp(const char *name) const ///\param name - IN: Name of property to remove - \c H5std_string // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -void PropList::removeProp(const H5std_string& name) const +void +PropList::removeProp(const H5std_string &name) const { removeProp(name.c_str()); } @@ -769,7 +784,8 @@ void PropList::removeProp(const H5std_string& name) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -bool PropList::operator==(const PropList& rhs) const +bool +PropList::operator==(const PropList &rhs) const { htri_t ret_value = H5Pequal(id, rhs.getId()); if (ret_value > 0) @@ -789,15 +805,15 @@ bool PropList::operator==(const PropList& rhs) const ///\exception H5::PropListIException // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- -PropList PropList::getClassParent() const +PropList +PropList::getClassParent() const { hid_t class_id = H5Pget_class_parent(id); - if (class_id < 0) - { + if (class_id < 0) { throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); } PropList pclass(class_id); - return(pclass); + return (pclass); } //-------------------------------------------------------------------------- @@ -815,9 +831,9 @@ PropList::~PropList() try { close(); } - catch (Exception& close_error) { + catch (Exception &close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } -} // end namespace +} // namespace H5 diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index d7047758413..12c8b4b058c 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5PropList_H -#define __H5PropList_H +#ifndef H5PropList_H +#define H5PropList_H namespace H5 { @@ -23,121 +23,125 @@ namespace H5 { */ // Inheritance: IdComponent class H5_DLLCPP PropList : public IdComponent { - public: - ///\brief Default property list - static const PropList& DEFAULT; + public: + ///\brief Default property list + static const PropList &DEFAULT; - // Creates a property list of a given type or creates a copy of an - // existing property list giving the property list id. - PropList(const hid_t plist_id); + // Creates a property list of a given type or creates a copy of an + // existing property list giving the property list id. + PropList(const hid_t plist_id); - // Make a copy of the given property list using assignment statement - PropList& operator=(const PropList& rhs); + // Make a copy of the given property list using assignment statement + PropList &operator=(const PropList &rhs); - // Compares this property list or class against the given list or class. - bool operator==(const PropList& rhs) const; + // Compares this property list or class against the given list or class. + bool operator==(const PropList &rhs) const; - // Close this property list. - virtual void close(); + // Close this property list. + virtual void close(); - // Close a property list class. - void closeClass() const; + // Close a property list class. + void closeClass() const; - // Makes a copy of the given property list. - void copy(const PropList& like_plist); + // Makes a copy of the given property list. + void copy(const PropList &like_plist); - // Copies a property from this property list or class to another - void copyProp(PropList& dest, const char* name) const; - void copyProp(PropList& dest, const H5std_string& name) const; + // Copies a property from this property list or class to another + void copyProp(PropList &dest, const char *name) const; + void copyProp(PropList &dest, const H5std_string &name) const; - // Copies a property from one property list or property class to another - void copyProp(PropList& dest, PropList& src, const char* name) const; - void copyProp(PropList& dest, PropList& src, const H5std_string& name) const; + // Copies a property from one property list or property class to another + void copyProp(PropList &dest, PropList &src, const char *name) const; + void copyProp(PropList &dest, PropList &src, const H5std_string &name) const; - // Gets the class of this property list, i.e. H5P_FILE_CREATE, - // H5P_FILE_ACCESS, ... - hid_t getClass() const; + // Gets the class of this property list, i.e. H5P_FILE_CREATE, + // H5P_FILE_ACCESS, ... + hid_t getClass() const; - // Return the name of a generic property list class. - H5std_string getClassName() const; + // Return the name of a generic property list class. + H5std_string getClassName() const; - // Returns the parent class of a generic property class. - PropList getClassParent() const; + // Returns the parent class of a generic property class. + PropList getClassParent() const; - // Returns the number of properties in this property list or class. - size_t getNumProps() const; + // Returns the number of properties in this property list or class. + size_t getNumProps() const; - // Query the value of a property in a property list. - void getProperty(const char* name, void* value) const; - void getProperty(const H5std_string& name, void* value) const; - H5std_string getProperty(const char* name) const; - H5std_string getProperty(const H5std_string& name) const; + // Query the value of a property in a property list. + void getProperty(const char *name, void *value) const; + void getProperty(const H5std_string &name, void *value) const; + H5std_string getProperty(const char *name) const; + H5std_string getProperty(const H5std_string &name) const; - // Set a property's value in a property list. - void setProperty(const char* name, const char* charptr) const; - void setProperty(const char* name, const void* value) const; - void setProperty(const char* name, const H5std_string& strg) const; - void setProperty(const H5std_string& name, const void* value) const; - void setProperty(const H5std_string& name, const H5std_string& strg) const; - // Deprecated after 1.10.1, missing const - void setProperty(const char* name, void* value) const; - void setProperty(const char* name, H5std_string& strg) const; - void setProperty(const H5std_string& name, void* value) const; - void setProperty(const H5std_string& name, H5std_string& strg) const; + // Set a property's value in a property list. + void setProperty(const char *name, const char *charptr) const; + void setProperty(const char *name, const void *value) const; + void setProperty(const char *name, const H5std_string &strg) const; + void setProperty(const H5std_string &name, const void *value) const; + void setProperty(const H5std_string &name, const H5std_string &strg) const; + // Deprecated after 1.10.1, missing const + void setProperty(const char *name, void *value) const; + void setProperty(const char *name, H5std_string &strg) const; + void setProperty(const H5std_string &name, void *value) const; + void setProperty(const H5std_string &name, H5std_string &strg) const; - // Query the size of a property in a property list or class. - size_t getPropSize(const char *name) const; - size_t getPropSize(const H5std_string& name) const; + // Query the size of a property in a property list or class. + size_t getPropSize(const char *name) const; + size_t getPropSize(const H5std_string &name) const; - // Determines whether a property list is a certain class. - bool isAClass(const PropList& prop_class) const; + // Determines whether a property list is a certain class. + bool isAClass(const PropList &prop_class) const; - /// Query the existence of a property in a property object. - bool propExist(const char* name) const; - bool propExist(const H5std_string& name) const; + /// Query the existence of a property in a property object. + bool propExist(const char *name) const; + bool propExist(const H5std_string &name) const; - // Removes a property from a property list. - void removeProp(const char *name) const; - void removeProp(const H5std_string& name) const; + // Removes a property from a property list. + void removeProp(const char *name) const; + void removeProp(const H5std_string &name) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("PropList"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("PropList"); + } - // Default constructor: creates a stub PropList object. - PropList(); + // Default constructor: creates a stub PropList object. + PropList(); - // Copy constructor: same as the original PropList. - PropList(const PropList& original); + // Copy constructor: same as the original PropList. + PropList(const PropList &original); - // Gets the property list id. - virtual hid_t getId() const; + // Gets the property list id. + virtual hid_t getId() const; - // Destructor: properly terminates access to this property list. - virtual ~PropList(); + // Destructor: properly terminates access to this property list. + virtual ~PropList(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - // Deletes the PropList global constant - static void deleteConstants(); + // Deletes the PropList global constant + static void deleteConstants(); - protected: - hid_t id; // HDF5 property list id + protected: + hid_t id; // HDF5 property list id - // Sets the property list id. - virtual void p_setId(const hid_t new_id); + // Sets the property list id. + virtual void p_setId(const hid_t new_id); - private: - static PropList* DEFAULT_; + private: + static PropList *DEFAULT_; - // Dynamically allocates the PropList global constant - static PropList* getConstant(); + // Dynamically allocates the PropList global constant + static PropList *getConstant(); - // Friend function to set PropList id. For library use only. - friend void f_PropList_setId(PropList* plist, hid_t new_id); + // Friend function to set PropList id. For library use only. + friend void f_PropList_setId(PropList *plist, hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of PropList } // namespace H5 -#endif // __H5PropList_H +#endif // H5PropList_H diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index f5b65e4d85f..5df48f38660 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -32,6 +32,7 @@ #include "H5StrType.h" #include "H5DataSet.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -40,7 +41,9 @@ namespace H5 { ///\brief Default constructor: Creates a stub string datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType() : AtomType() {} +StrType::StrType() : AtomType() +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -49,7 +52,7 @@ StrType::StrType() : AtomType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type) : AtomType() +StrType::StrType(const PredType &pred_type) : AtomType() { // use DataType::copy to make a copy of this predefined type copy(pred_type); @@ -78,7 +81,7 @@ StrType::StrType(const PredType& pred_type) : AtomType() // Planned for removal. -BMR, 2005/12/02 // Removed from documentation. -BMR, 2016/03/07 //-------------------------------------------------------------------------- -StrType::StrType(const PredType& pred_type, const size_t& size) : AtomType() +StrType::StrType(const PredType &pred_type, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -102,7 +105,7 @@ 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(const int dummy, const size_t& size) : AtomType() +StrType::StrType(H5_ATTR_UNUSED const int dummy, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length @@ -117,14 +120,18 @@ StrType::StrType(const int dummy, const size_t& size) : AtomType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const hid_t existing_id) : AtomType( existing_id ) {} +StrType::StrType(const hid_t existing_id) : AtomType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: StrType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const StrType& original) : AtomType ( original ) {} +StrType::StrType(const StrType &original) : AtomType(original) +{ +} //-------------------------------------------------------------------------- // Function: StrType overloaded constructor @@ -133,13 +140,12 @@ StrType::StrType(const StrType& original) : AtomType ( original ) {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::StrType(const DataSet& dataset) : AtomType () +StrType::StrType(const DataSet &dataset) : AtomType() { // Calls C function H5Dget_type to get the id of the datatype id = H5Dget_type(dataset.getId()); - if (id < 0) - { + if (id < 0) { throw DataSetIException("StrType constructor", "H5Dget_type failed"); } } @@ -158,7 +164,7 @@ StrType::StrType(const DataSet& dataset) : AtomType () // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const char *dtype_name) : AtomType() { id = p_opentype(loc, dtype_name); } @@ -177,7 +183,7 @@ StrType::StrType(const H5Location& loc, const char *dtype_name) : AtomType() // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomType() +StrType::StrType(const H5Location &loc, const H5std_string &dtype_name) : AtomType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -190,7 +196,8 @@ StrType::StrType(const H5Location& loc, const H5std_string& dtype_name) : AtomTy ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* StrType::decode() const +DataType * +StrType::decode() const { hid_t encoded_strtype_id = H5I_INVALID_HID; try { @@ -201,7 +208,7 @@ DataType* StrType::decode() const } StrType *encoded_strtype = new StrType; encoded_strtype->p_setId(encoded_strtype_id); - return(encoded_strtype); + return (encoded_strtype); } //-------------------------------------------------------------------------- @@ -219,16 +226,16 @@ DataType* StrType::decode() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_cset_t StrType::getCset() const +H5T_cset_t +StrType::getCset() const { H5T_cset_t cset = H5Tget_cset(id); // Returns a valid character set type if successful - if (cset == H5T_CSET_ERROR) - { + if (cset == H5T_CSET_ERROR) { throw DataTypeIException("StrType::getCset", "H5Tget_cset failed"); } - return(cset); + return (cset); } //-------------------------------------------------------------------------- @@ -246,11 +253,11 @@ H5T_cset_t StrType::getCset() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setCset(H5T_cset_t cset) const +void +StrType::setCset(H5T_cset_t cset) const { herr_t ret_value = H5Tset_cset(id, cset); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setCset", "H5Tset_cset failed"); } } @@ -265,17 +272,16 @@ void StrType::setCset(H5T_cset_t cset) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_str_t StrType::getStrpad() const +H5T_str_t +StrType::getStrpad() const { H5T_str_t strpad = H5Tget_strpad(id); // Returns a valid string padding type if successful - if (strpad == H5T_STR_ERROR) - { - throw DataTypeIException("StrType::getStrpad", - "H5Tget_strpad failed - returned H5T_STR_ERROR"); + if (strpad == H5T_STR_ERROR) { + throw DataTypeIException("StrType::getStrpad", "H5Tget_strpad failed - returned H5T_STR_ERROR"); } - return(strpad); + return (strpad); } //-------------------------------------------------------------------------- @@ -288,11 +294,11 @@ H5T_str_t StrType::getStrpad() const /// the HDF5 C Reference Manual. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void StrType::setStrpad(H5T_str_t strpad) const +void +StrType::setStrpad(H5T_str_t strpad) const { herr_t ret_value = H5Tset_strpad(id, strpad); - if (ret_value < 0) - { + if (ret_value < 0) { throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed"); } } @@ -302,6 +308,8 @@ void StrType::setStrpad(H5T_str_t strpad) const ///\brief Properly terminates access to this string datatype. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -StrType::~StrType() {} +StrType::~StrType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index 38974da49ad..d272c535bcf 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5StrType_H -#define __H5StrType_H +#ifndef H5StrType_H +#define H5StrType_H namespace H5 { @@ -23,55 +23,59 @@ namespace H5 { */ // Inheritance: AtomType -> DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP StrType : public AtomType { - public: - // Creates a string type using a predefined type - StrType(const PredType& pred_type); + public: + // Creates a string type using a predefined type + StrType(const PredType &pred_type); - // Creates a string type with specified length - may be obsolete - StrType(const PredType& pred_type, const size_t& size); + // Creates a string type with specified length - may be obsolete + StrType(const PredType &pred_type, const size_t &size); - // Creates a string type with specified length - StrType(const int dummy, const size_t& size); + // Creates a string type with specified length + StrType(const int dummy, const size_t &size); - // Gets the string datatype of the specified dataset - StrType(const DataSet& dataset); + // Gets the string datatype of the specified dataset + StrType(const DataSet &dataset); - // Constructors that open an HDF5 string datatype, given a location. - StrType(const H5Location& loc, const char* name); - StrType(const H5Location& loc, const H5std_string& name); + // Constructors that open an HDF5 string datatype, given a location. + StrType(const H5Location &loc, const char *name); + StrType(const H5Location &loc, const H5std_string &name); - // Returns an StrType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an StrType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - // Retrieves the character set type of this string datatype. - H5T_cset_t getCset() const; + // Retrieves the character set type of this string datatype. + H5T_cset_t getCset() const; - // Sets character set to be used. - void setCset(H5T_cset_t cset) const; + // Sets character set to be used. + void setCset(H5T_cset_t cset) const; - // Retrieves the string padding method for this string datatype. - H5T_str_t getStrpad() const; + // Retrieves the string padding method for this string datatype. + H5T_str_t getStrpad() const; - // Defines the storage mechanism for character strings. - void setStrpad(H5T_str_t strpad) const; + // Defines the storage mechanism for character strings. + void setStrpad(H5T_str_t strpad) const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("StrType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("StrType"); + } - // default constructor - StrType(); + // default constructor + StrType(); - // Creates a string datatype using an existing id - StrType(const hid_t existing_id); + // Creates a string datatype using an existing id + StrType(const hid_t existing_id); - // Copy constructor: same as the original StrType. - StrType(const StrType& original); + // Copy constructor: same as the original StrType. + StrType(const StrType &original); - // Noop destructor. - virtual ~StrType(); + // Noop destructor. + virtual ~StrType(); }; // end of StrType } // namespace H5 -#endif // __H5StrType_H +#endif // H5StrType_H diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 094af6181c9..0270febfe59 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -33,7 +33,9 @@ namespace H5 { // Function: VarLenType default constructor ///\brief Default constructor: Creates a stub variable-length datatype. //-------------------------------------------------------------------------- -VarLenType::VarLenType() : DataType() {} +VarLenType::VarLenType() : DataType() +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -42,14 +44,18 @@ VarLenType::VarLenType() : DataType() {} ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) {} +VarLenType::VarLenType(const hid_t existing_id) : DataType(existing_id) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType copy constructor ///\brief Copy constructor: same HDF5 object as \a original // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} +VarLenType::VarLenType(const VarLenType &original) : DataType(original) +{ +} //-------------------------------------------------------------------------- // Function: VarLenType overloaded constructor @@ -63,13 +69,11 @@ VarLenType::VarLenType(const VarLenType& original) : DataType(original) {} // -BMR, Sep, 2017 // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType* base_type) : DataType() +VarLenType::VarLenType(const DataType *base_type) : DataType() { id = H5Tvlen_create(base_type->getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -81,13 +85,11 @@ VarLenType::VarLenType(const DataType* base_type) : DataType() ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const DataType& base_type) : DataType() +VarLenType::VarLenType(const DataType &base_type) : DataType() { id = H5Tvlen_create(base_type.getId()); - if (id < 0) - { - throw DataTypeIException("VarLenType constructor", - "H5Tvlen_create returns negative value"); + if (id < 0) { + throw DataTypeIException("VarLenType constructor", "H5Tvlen_create returns negative value"); } } @@ -105,7 +107,7 @@ VarLenType::VarLenType(const DataType& base_type) : DataType() // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const char *dtype_name) : DataType() { id = p_opentype(loc, dtype_name); } @@ -124,7 +126,7 @@ VarLenType::VarLenType(const H5Location& loc, const char *dtype_name) : DataType // to improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : DataType() +VarLenType::VarLenType(const H5Location &loc, const H5std_string &dtype_name) : DataType() { id = p_opentype(loc, dtype_name.c_str()); } @@ -137,7 +139,8 @@ VarLenType::VarLenType(const H5Location& loc, const H5std_string& dtype_name) : ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- -DataType* VarLenType::decode() const +DataType * +VarLenType::decode() const { hid_t encoded_vltype_id = H5I_INVALID_HID; try { @@ -148,7 +151,7 @@ DataType* VarLenType::decode() const } VarLenType *encoded_vltype = new VarLenType; encoded_vltype->p_setId(encoded_vltype_id); - return(encoded_vltype); + return (encoded_vltype); } //-------------------------------------------------------------------------- @@ -156,6 +159,8 @@ DataType* VarLenType::decode() const ///\brief Properly terminates access to this datatype. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -VarLenType::~VarLenType() {} +VarLenType::~VarLenType() +{ +} -} // end namespace +} // namespace H5 diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index ab3c14cd927..f767e0ebd2f 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -7,13 +7,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef __H5VarLenType_H -#define __H5VarLenType_H +#ifndef H5VarLenType_H +#define H5VarLenType_H namespace H5 { @@ -23,38 +23,42 @@ namespace H5 { */ // Inheritance: DataType -> H5Object -> H5Location -> IdComponent class H5_DLLCPP VarLenType : public DataType { - public: - // Constructor that creates a variable-length datatype based - // on the specified base type. - VarLenType(const DataType& base_type); + public: + // Constructor that creates a variable-length datatype based + // on the specified base type. + VarLenType(const DataType &base_type); - // Deprecated - will be removed after 1.10.2 - VarLenType(const DataType* base_type); + // Deprecated - will be removed after 1.10.2 + VarLenType(const DataType *base_type); - // Returns an VarLenType object via DataType* by decoding the - // binary object description of this type. - virtual DataType* decode() const; + // Returns an VarLenType object via DataType* by decoding the + // binary object description of this type. + virtual DataType *decode() const; - ///\brief Returns this class name. - virtual H5std_string fromClass () const { return("VarLenType"); } + ///\brief Returns this class name. + virtual H5std_string + fromClass() const + { + return ("VarLenType"); + } - // Copy constructor: same as the original VarLenType. - VarLenType(const VarLenType& original); + // Copy constructor: same as the original VarLenType. + VarLenType(const VarLenType &original); - // Constructor that takes an existing id - VarLenType(const hid_t existing_id); + // Constructor that takes an existing id + VarLenType(const hid_t existing_id); - // Constructors that open a variable-length datatype, given a location. - VarLenType(const H5Location& loc, const char* name); - VarLenType(const H5Location& loc, const H5std_string& name); + // Constructors that open a variable-length datatype, given a location. + VarLenType(const H5Location &loc, const char *name); + VarLenType(const H5Location &loc, const H5std_string &name); - // Noop destructor - virtual ~VarLenType(); + // Noop destructor + virtual ~VarLenType(); - // Default constructor - VarLenType(); + // Default constructor + VarLenType(); }; // end of VarLenType } // namespace H5 -#endif // __H5VarLenType_H +#endif // H5VarLenType_H diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 8397a2fbaf9..f17652eee6b 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.10.7" +PROJECT_NUMBER = "1.12.1" # 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/h5c++.in b/c++/src/h5c++.in index 16e73b0b6c8..bcc835ebe38 100755 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -7,7 +7,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/c++/src/header.html b/c++/src/header.html index cb42565e37d..5b92416dbb1 100644 --- a/c++/src/header.html +++ b/c++/src/header.html @@ -13,7 +13,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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/config/clang-warnings/noerror-general b/config/clang-warnings/noerror-general new file mode 100644 index 00000000000..4690ebd56f6 --- /dev/null +++ b/config/clang-warnings/noerror-general @@ -0,0 +1,82 @@ +# +# These warnings will be treated as errors, using the error-general file, +# when HDF5_ENABLE_WARNINGS_AS_ERRORS is set to true for CMake or +# the --enable-warnings-as-errors option is specified for configure. +# Otherwise this file will be used to treat them as warnings. +# +-Wbad-function-cast +-Wimplicit-function-declaration +-Wincompatible-pointer-types +-Wmissing-declarations +-Wpacked +-Wshadow +-Wswitch +# +# NOTE: Following files are not compatible with incompatible-pointer-types as errors +# src/H5Dchunk.c,src/H5Dint.c,src/H5Gint.c,src/H5HFcache.c,src/H5I.c,src/H5T.c +-Wno-error=incompatible-pointer-types-discards-qualifiers +# +# +# NOTE: File Driver files are not compatible with these warnings as errors +# H5FDdirect.c,H5FDmpio.c,H5FDros3.c, +# -Werror=unused-function +# +-Wunused-function +# +# H5FDdrvr_module.h +# -Werror=unused-variable +# +-Wunused-variable +# +# H5VLpassthru.c +# -Werror=unused-parameter +# +-Wunused-parameter +# +# +# +# NOTE: Tools files are not compatible with these warnings as errors +# lib/h5tools.c +# -Werror=cast-align +# +-Wcast-align +# +# lib/h5tools_utils.c +# -Werror=unused-parameter +# +# +# NOTE: JNI files are not compatible with these warnings as errors +# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c +# jni/h5sImp.c,jni/h5tImp.c +# -Werror=cast-align +# jni/h5util.c +# -Werror=format(-overflow) +# +-Wformat +# +# +#Examples and tests do not use the same set of extensive warning flags as libraries +# Here is a list of tests and examples that have issues with the stricter warnings as error +# +# NOTE: Test files are not compatible with these warnings as errors +# thread_id.c, +# -Werror=unused-function +# dsets.c +# -Werror=unused-parameter +# +# +# NOTE: Examples files are not compatible with these warnings as errors +# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c +# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c +# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c +# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c +# h5_reference_deprec.c +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=strict-prototypes +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=old-style-definition +# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c, +# -Werror=unused-variable +# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c +# -Werror=unused-parameter + diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 534f139096c..f9588041450 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -27,7 +27,7 @@ set (CTEST_CUSTOM_WARNING_EXCEPTION "config.cmake.xlatefile.c" "warning.*unknown pragma" "warning.*unrecognized .pragma" - "note: expanded from macro" +# "note: expanded from macro" # HDDFFV-11074 "This directive is not standard" ) @@ -130,7 +130,9 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE H5REPACK-szip_individual-clear-objects H5REPACK-szip_remove-clear-objects H5REPACK-upgrade_layout-clear-objects + H5REPACK_DMP-attrregion-clear-objects H5REPACK_DMP-crtorder-clear-objects + H5REPACK_DMP-dataregion-clear-objects H5REPACK_DMP-deflate_limit-clear-objects H5REPACK-bug1814-clear-objects H5REPACK-HDFFV-5932-clear-objects diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake index 5478862b9be..0ed90635087 100644 --- a/config/cmake/CTestScript.cmake +++ b/config/cmake/CTestScript.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index ab121e9c581..902ddd3d3ec 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -28,6 +28,18 @@ if (HDF5_STRICT_FORMAT_CHECKS) endif () MARK_AS_ADVANCED (HDF5_STRICT_FORMAT_CHECKS) +#----------------------------------------------------------------------------- +# Option for --enable-threadsafe +#----------------------------------------------------------------------------- +# Recursive RW locks are not supported on Windows (yet) +if (NOT WINDOWS) + option (HDF5_USE_RECURSIVE_RW_LOCKS "Whether to use recursive RW locks for thread-safety" OFF) + if (HDF5_USE_RECURSIVE_RW_LOCKS) + set (${HDF_PREFIX}_USE_RECURSIVE_RW_LOCKS 1) + endif () + MARK_AS_ADVANCED (HDF5_USE_RECURSIVE_RW_LOCKS) +endif () + # ---------------------------------------------------------------------- # Decide whether the data accuracy has higher priority during data # conversions. If not, some hard conversions will still be prefered even @@ -165,14 +177,18 @@ if (NOT WINDOWS) add_definitions ("-D_GNU_SOURCE") else () set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Test TEST_DIRECT_VFD_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n" ) endif () else () set (TEST_DIRECT_VFD_WORKS "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Test TEST_DIRECT_VFD_WORKS Compile failed with the following output:\n ${OUTPUT}\n" ) @@ -192,7 +208,7 @@ option (HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF) list (APPEND LINK_LIBS ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) INCLUDE_DIRECTORIES (${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) else () - message (STATUS "The Read-Only S3 VFD was requested but cannot be built.\nPlease check that openssl and cURL are available on your\nsystem, and/or re-configure without option HDF5_ENABLE_ROS3_VFD.") + message (WARNING "The Read-Only S3 VFD was requested but cannot be built.\nPlease check that openssl and cURL are available on your\nsystem, and/or re-configure without option HDF5_ENABLE_ROS3_VFD.") endif () endif () @@ -209,7 +225,7 @@ if (H5FD_ENABLE_MIRROR_VFD) ${HDF_PREFIX}_HAVE_FORK) set (${HDF_PREFIX}_HAVE_MIRROR_VFD 1) else() - message(STATUS "The socket-based Mirror VFD was requested but cannot be built. System prerequisites are not met.") + message(WARNING "The socket-based Mirror VFD was requested but cannot be built. System prerequisites are not met.") endif() endif() @@ -217,25 +233,132 @@ endif() # Check if C has __float128 extension #----------------------------------------------------------------------------- -CHECK_TYPE_SIZE("__float128" ${HDF_PREFIX}_SIZEOF___FLOAT128) -if (${${HDF_PREFIX}_SIZEOF___FLOAT128}) +HDF_CHECK_TYPE_SIZE(__float128 _SIZEOF___FLOAT128) +if (${_SIZEOF___FLOAT128}) set (${HDF_PREFIX}_HAVE_FLOAT128 1) + set (${HDF_PREFIX}_SIZEOF___FLOAT128 ${_SIZEOF___FLOAT128}) else () set (${HDF_PREFIX}_HAVE_FLOAT128 0) set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) endif () -CHECK_TYPE_SIZE("_Quad" ${HDF_PREFIX}_SIZEOF__QUAD) -if (NOT ${${HDF_PREFIX}_SIZEOF__QUAD}) +HDF_CHECK_TYPE_SIZE(_Quad _SIZEOF__QUAD) +if (NOT ${_SIZEOF__QUAD}) set (${HDF_PREFIX}_SIZEOF__QUAD 0) +else () + set (${HDF_PREFIX}_SIZEOF__QUAD ${_SIZEOF__QUAD}) endif () +#----------------------------------------------------------------------------- +# The provided CMake C macros don't provide a general compile/run function +# so this one is used. +#----------------------------------------------------------------------------- +set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) +macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Detecting C ${FUNCTION_NAME}") + endif () + file (WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + ${SOURCE_CODE} + ) + TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + COMPILE_DEFINITIONS "-D_SIZEOF___FLOAT128=${H5_SIZEOF___FLOAT128};-D_HAVE_QUADMATH_H=${H5_HAVE_QUADMATH_H}" + COMPILE_OUTPUT_VARIABLE COMPILEOUT + RUN_OUTPUT_VARIABLE OUTPUT_VAR + ) + + set (${RETURN_VAR} ${OUTPUT_VAR}) + + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + message (VERBOSE "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") + message (VERBOSE "Test COMPILE_OUTPUT ${COMPILEOUT} ") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + message (VERBOSE "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") + message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + endif () + + if (${COMPILE_RESULT_VAR}) + if (${RUN_RESULT_VAR} MATCHES 0) + set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing C ${FUNCTION_NAME} - OK") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" + "${OUTPUT_VAR}\n\n" + ) + else () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing C ${FUNCTION_NAME} - Fail") + endif () + set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" + "${OUTPUT_VAR}\n\n") + endif () + else () + message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") + endif () +endmacro () + +set (PROG_SRC + " +#include \n\ +#include \n\ +#define CHECK_FLOAT128 _SIZEOF___FLOAT128\n\ +#if CHECK_FLOAT128!=0\n\ +#if _HAVE_QUADMATH_H!=0\n\ +#include \n\ +#endif\n\ +#ifdef FLT128_DIG\n\ +#define C_FLT128_DIG FLT128_DIG\n\ +#else\n\ +#define C_FLT128_DIG 0\n\ +#endif\n\ +#else\n\ +#define C_FLT128_DIG 0\n\ +#endif\n\ +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\ +#define C_LDBL_DIG DECIMAL_DIG\n\ +#else\n\ +#define C_LDBL_DIG LDBL_DIG\n\ +#endif\n\nint main() {\nFILE *pFile = fopen(\"pac_Cconftest.out\",\"w\")\\\;\nfprintf(pFile, \"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n + " +) + +C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES) +file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_Cconftest.out" PROG_OUTPUT4) +message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}") + +# dnl The output from the above program will be: +# dnl -- long double decimal precision -- __float128 decimal precision + +list (GET PROG_OUTPUT4 0 H5_LDBL_DIG) +list (GET PROG_OUTPUT4 1 H5_FLT128_DIG) + +if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0) + set (${HDF_PREFIX}_HAVE_FLOAT128 0) + set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) + set (_PAC_C_MAX_REAL_PRECISION ${H5_LDBL_DIG}) +else () + set (_PAC_C_MAX_REAL_PRECISION ${H5_FLT128_DIG}) +endif () +if (NOT ${_PAC_C_MAX_REAL_PRECISION}) + set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION 0) +else () + set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${_PAC_C_MAX_REAL_PRECISION}) +endif () +message (STATUS "maximum decimal precision for C var - ${${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION}") + #----------------------------------------------------------------------------- # Macro to determine the various conversion capabilities #----------------------------------------------------------------------------- macro (H5ConversionTests TEST msg) if (NOT DEFINED ${TEST}) - # message (STATUS "===> ${TEST}") TRY_RUN (${TEST}_RUN ${TEST}_COMPILE ${CMAKE_BINARY_DIR} ${HDF_RESOURCES_DIR}/ConversionTests.c @@ -245,17 +368,23 @@ macro (H5ConversionTests TEST msg) if (${TEST}_COMPILE) if (${TEST}_RUN MATCHES 0) set (${TEST} 1 CACHE INTERNAL ${msg}) - message (STATUS "${msg}... yes") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... yes") + endif () else () set (${TEST} "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Test ${TEST} Run failed with the following output and exit code:\n ${OUTPUT}\n" ) endif () else () set (${TEST} "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Test ${TEST} Compile failed with the following output:\n ${OUTPUT}\n" ) diff --git a/config/cmake/ConversionTests.c b/config/cmake/ConversionTests.c index 6d597a0dfe2..f80959fdc79 100644 --- a/config/cmake/ConversionTests.c +++ b/config/cmake/ConversionTests.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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/config/cmake/H5cxx_config.h.in b/config/cmake/H5cxx_config.h.in index d1dd42bb998..b5ae8cea435 100644 --- a/config/cmake/H5cxx_config.h.in +++ b/config/cmake/H5cxx_config.h.in @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index f66f5294221..e163d3a50c5 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,16 +26,13 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Define if building universal (internal helper macro) */ -#cmakedefine H5_AC_APPLE_UNIVERSAL_BUILD @H5_AC_APPLE_UNIVERSAL_BUILD@ - /* Define if C++ compiler recognizes offsetof */ #cmakedefine H5_CXX_HAVE_OFFSETOF @CXX_HAVE_OFFSETOF@ /* Define the default plugins path to compile */ #cmakedefine H5_DEFAULT_PLUGINDIR "@H5_DEFAULT_PLUGINDIR@" -/* Define if `dev_t' is a scalar */ +/* Define if dev_t is a scalar */ #cmakedefine H5_DEV_T_IS_SCALAR @H5_DEV_T_IS_SCALAR@ /* Define to dummy `main' function (if any) required to link to the Fortran @@ -91,6 +88,9 @@ /* Define to 1 if you have the `alarm' function. */ #cmakedefine H5_HAVE_ALARM @H5_HAVE_ALARM@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_ARPA_INET_H @H5_HAVE_ARPA_INET_H@ + /* Define to 1 if you have the `asprintf' function. */ #cmakedefine H5_HAVE_ASPRINTF @H5_HAVE_ASPRINTF@ @@ -104,9 +104,6 @@ /* Define if the compiler understands the __func__ keyword */ #cmakedefine H5_HAVE_C99_FUNC @H5_HAVE_C99_FUNC@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_ARPA_INET_H @H5_HAVE_ARPA_INET_H@ - /* Define to 1 if you have the `clock_gettime' function. */ #cmakedefine H5_HAVE_CLOCK_GETTIME @H5_HAVE_CLOCK_GETTIME@ @@ -267,10 +264,13 @@ /* Define to 1 if you have the `lstat' function. */ #cmakedefine H5_HAVE_LSTAT @H5_HAVE_LSTAT@ +/* Define if the map API (H5M) should be compiled */ +#cmakedefine H5_HAVE_MAP_API @H5_HAVE_MAP_API@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MEMORY_H @H5_HAVE_MEMORY_H@ -/* Define if we can build the Mirror VFD */ +/* Define whether the Mirror virtual file driver (VFD) will be compiled */ #cmakedefine H5_HAVE_MIRROR_VFD @H5_HAVE_MIRROR_VFD@ /* Define if we have MPE support */ @@ -279,10 +279,10 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MPE_H @H5_HAVE_MPE_H@ -/* Define if MPI_Comm_c2f and MPI_Comm_f2c exists */ +/* Define if MPI_Comm_c2f and MPI_Comm_f2c exist */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Comm @H5_HAVE_MPI_MULTI_LANG_Comm@ -/* Define if MPI_Info_c2f and MPI_Info_f2c exists */ +/* Define if MPI_Info_c2f and MPI_Info_f2c exist */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Info @H5_HAVE_MPI_MULTI_LANG_Info@ /* Define to 1 if you have the header file. */ @@ -486,7 +486,7 @@ /* Define if the compiler understands __inline__ */ #cmakedefine H5_HAVE___INLINE__ @H5_HAVE___INLINE__@ -/* Define if the library will ignore file locks when disabled */ +/* Define if the library will ignore file locks when disabled */ #cmakedefine H5_IGNORE_DISABLED_FILE_LOCKS @H5_IGNORE_DISABLED_FILE_LOCKS@ /* Define if the high-level library headers should be included in hdf5.h */ @@ -515,7 +515,7 @@ #cmakedefine H5_LT_OBJDIR @H5_LT_OBJDIR@ /* Define to enable internal memory allocation sanity checking. */ -/* #cmakedefine H5_MEMORY_ALLOC_SANITY_CHECK @H5_MEMORY_ALLOC_SANITY_CHECK@ ** Define in CMakeLists.txt */ +#cmakedefine H5_MEMORY_ALLOC_SANITY_CHECK @H5_MEMORY_ALLOC_SANITY_CHECK@ /* Define if we can violate pointer alignment restrictions */ #cmakedefine H5_NO_ALIGNMENT_RESTRICTIONS @H5_NO_ALIGNMENT_RESTRICTIONS@ @@ -545,10 +545,10 @@ #define H5_PACKAGE_VERSION "@HDF5_PACKAGE_VERSION_STRING@" /* Determine the maximum decimal precision in C */ -#cmakedefine H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ +#define H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ /* Define Fortran Maximum Real Decimal Precision */ -#cmakedefine H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ +#define H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ /* Width for printf() for type `long long' or `__int64', use `ll' */ #cmakedefine H5_PRINTF_LL_WIDTH @H5_PRINTF_LL_WIDTH@ @@ -605,6 +605,7 @@ #cmakedefine H5_SIZEOF_INT_LEAST8_T @H5_SIZEOF_INT_LEAST8_T@ #if !defined(__APPLE__) + /* The size of `size_t', as computed by sizeof. */ #cmakedefine H5_SIZEOF_SIZE_T @H5_SIZEOF_SIZE_T@ @@ -614,8 +615,17 @@ /* The size of `long', as computed by sizeof. */ #cmakedefine H5_SIZEOF_LONG @H5_SIZEOF_LONG@ +/* The size of `long double', as computed by sizeof. */ +#cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@ + #else - # if defined(__LP64__) && __LP64__ + + /* On Apple, to support Universal Binaries (where multiple CPU + architectures exist in one library/executable), we can't assume + the machine doing the compiling has the same endianness or type + sizes as all the various architectures (PowerPC, Intel, ARM). */ + + # if defined(__LP64__) && __LP64__ #define H5_SIZEOF_LONG 8 #define H5_SIZEOF_SIZE_T 8 #define H5_SIZEOF_SSIZE_T 8 @@ -625,10 +635,15 @@ #define H5_SIZEOF_SSIZE_T 4 # endif -#endif + # if defined(__i386__) || defined(__x86_64__) + #define H5_SIZEOF_LONG_DOUBLE 16 + # elif defined(__aarch64__) + #define H5_SIZEOF_LONG_DOUBLE 8 + # else + #cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@ + # endif -/* The size of `long double', as computed by sizeof. */ -#cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@ +#endif /* Define size of long long and/or __int64 bit integer type only if the type exists. */ @@ -723,9 +738,15 @@ /* Define using v1.10 public API symbols by default */ #cmakedefine H5_USE_110_API_DEFAULT @H5_USE_110_API_DEFAULT@ +/* Define using v1.12 public API symbols by default */ +#cmakedefine H5_USE_112_API_DEFAULT @H5_USE_112_API_DEFAULT@ + /* Define if the library will use file locking */ #cmakedefine H5_USE_FILE_LOCKING @H5_USE_FILE_LOCKING@ +/* Define if the library will use recursive RW locks for thread safety */ +#cmakedefine H5_USE_RECURSIVE_RW_LOCKS @H5_USE_RECURSIVE_RW_LOCKS@ + /* Define if a memory checking tool will be used on the library, to cause library to be very picky about memory operations and also disable the internal free list manager code. */ diff --git a/config/cmake/HDF5Macros.cmake b/config/cmake/HDF5Macros.cmake index 007bc2988e8..090524a1406 100644 --- a/config/cmake/HDF5Macros.cmake +++ b/config/cmake/HDF5Macros.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/HDF5PluginCache.cmake b/config/cmake/HDF5PluginCache.cmake new file mode 100644 index 00000000000..3b085ddf54b --- /dev/null +++ b/config/cmake/HDF5PluginCache.cmake @@ -0,0 +1,29 @@ +# This is the CMakeCache file. + +######################## +# EXTERNAL cache entries +######################## + +# examples are the tests for plugins +set (H5PL_BUILD_TESTING ON CACHE BOOL "Enable h5pl testing" FORCE) +set (BUILD_EXAMPLES ON CACHE BOOL "Build h5pl Examples" FORCE) + +set (HDF5_HDF5_HEADER "h5pubconf.h" CACHE STRING "Name of HDF5 header" FORCE) +set (HDF5_LINK_LIBS ${HDF5_LIBSH_TARGET} CACHE STRING "hdf5 target" FORCE) +#set (HDF5_INCLUDE_DIR $ CACHE PATH "hdf5 include dirs" FORCE) +set (HDF5_INCLUDE_DIR "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}" CACHE PATH "hdf5 include dirs" FORCE) +set (HDF5_INCLUDE_DIRS "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}" CACHE PATH "hdf5 include dirs" FORCE) +set (HDF5_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "hdf5 build folder" FORCE) + +set (HDF5_DUMP_EXECUTABLE $ CACHE STRING "hdf5 h5dump target" FORCE) +set (HDF5_REPACK_EXECUTABLE $ CACHE STRING "hdf5 h5repack target" FORCE) + +set (H5PL_ALLOW_EXTERNAL_SUPPORT "${HDF5_ALLOW_EXTERNAL_SUPPORT}" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE) + +set (H5PL_GIT_URL "https://github.com/HDFGroup/hdf5_plugins.git" CACHE STRING "Use plugins from HDF repository" FORCE) +set (H5PL_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (H5PL_TGZ_NAME "${PLUGIN_TGZ_NAME}" CACHE STRING "Use plugins from compressed file" FORCE) + +set (PL_PACKAGE_NAME "${PLUGIN_PACKAGE_NAME}" CACHE STRING "Name of plugins package" FORCE) +set (H5PL_CPACK_ENABLE OFF CACHE BOOL "Enable the CPACK include and components" FORCE) diff --git a/config/cmake/HDF5PluginMacros.cmake b/config/cmake/HDF5PluginMacros.cmake new file mode 100644 index 00000000000..4e05399becb --- /dev/null +++ b/config/cmake/HDF5PluginMacros.cmake @@ -0,0 +1,108 @@ +#------------------------------------------------------------------------------- +# Plugins must be built SHARED +#------------------------------------------------------------------------------- +macro (EXTERNAL_PLUGIN_LIBRARY compress_type) + if (${compress_type} MATCHES "GIT") + FetchContent_Declare (PLUGIN + GIT_REPOSITORY ${PLUGIN_URL} + GIT_TAG ${PLUGIN_BRANCH} + ) + elseif (${compress_type} MATCHES "TGZ") + FetchContent_Declare (PLUGIN + URL ${PLUGIN_URL} + URL_HASH "" + ) + endif () + FetchContent_GetProperties(PLUGIN) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}") + endif () + if(NOT PLUGIN_POPULATED) + FetchContent_Populate(PLUGIN) + include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake) + set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + add_subdirectory(${plugin_SOURCE_DIR} ${plugin_BINARY_DIR}) + if (ENABLE_BLOSC) + add_dependencies (h5blosc ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_blosc ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_blosc PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_BSHUF) + add_dependencies (h5bshuf ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_bshuf ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_bshuf PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_BZIP2) + add_dependencies (h5bz2 ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_bzip2 ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_bzip2 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_JPEG) + add_dependencies (h5jpeg ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_jpeg ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_jpeg PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_LZ4) + add_dependencies (h5lz4 ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_lz4 ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_lz4 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_LZF) + add_dependencies (h5lzf ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_lzf ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_lzf PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_MAFISC) + add_dependencies (h5mafisc ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_mafisc ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_mafisc PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_SZF) + add_dependencies (h5szf ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_sz ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_sz PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + if (ENABLE_ZFP) + add_dependencies (h5zfp ${HDF5_LIBSH_TARGET}) + add_dependencies (h5ex_d_zfp ${HDF5_LIBSH_TARGET}) + target_include_directories (h5ex_d_zfp PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR}") + endif () + endif () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}") + endif () + set (PLUGIN_BINARY_DIR "${plugin_BINARY_DIR}") + set (PLUGIN_SOURCE_DIR "${plugin_SOURCE_DIR}") + set (PLUGIN_LIBRARY "PLUGIN") + set (PLUGIN_FOUND 1) +endmacro () + +#------------------------------------------------------------------------------- +macro (FILTER_OPTION plname) + string(TOLOWER ${plname} PLUGIN_NAME) + option (ENABLE_${plname} "Enable Library Building for ${plname} plugin" ON) + if (ENABLE_${plname}) + option (HDF_${plname}_USE_EXTERNAL "Use External Library Building for ${PLUGIN_NAME} plugin" 0) + if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") + set (HDF_${plname}_USE_EXTERNAL 1 CACHE BOOL "Use External Library Building for ${PLUGIN_NAME} plugin" FORCE) + if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT") + set (HDF_${plname}_URL ${HDF_${plname}_GIT_URL}) + set (HDF_${plname}_BRANCH ${HDF_${plname}_GIT_BRANCH}) + elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") + if (NOT TGZPATH) + set (TGZPATH ${H5PL_SOURCE_DIR}) + endif () + set (HDF_${plname}_URL ${TGZPATH}/${HDF_${plname}_TGZ_NAME}) + endif () + endif () + add_subdirectory (${plname}) + set_global_variable (H5PL_LIBRARIES_TO_EXPORT "${H5PL_LIBRARIES_TO_EXPORT};${H5${plname}_LIBRARIES_TO_EXPORT}") + endif () +endmacro () + +#------------------------------------------------------------------------------- +macro (PACKAGE_PLUGIN_LIBRARY compress_type) + if (${compress_type} MATCHES "GIT" OR ${compress_type} MATCHES "TGZ") + message (STATUS "Filter PLUGIN is to be packaged") + endif () +endmacro () diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 4350b7afa2d..e192ec4dd65 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -41,7 +41,9 @@ else () # so this one is used. #----------------------------------------------------------------------------- macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 RETURN_VAR) - message (STATUS "Detecting Fortran ${FUNCTION_NAME}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Detecting Fortran ${FUNCTION_NAME}") + endif () file (WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 "${SOURCE_CODE}" @@ -55,18 +57,24 @@ macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 if (${COMPILE_RESULT_VAR}) set(${RETURN_VAR} ${RUN_RESULT_VAR}) if (${RUN_RESULT_VAR} MATCHES 0) - message (STATUS "Testing Fortran ${FUNCTION_NAME} - OK") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing Fortran ${FUNCTION_NAME} - OK") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran ${FUNCTION_NAME} exists passed\n" ) else () - message (STATUS "Testing Fortran ${FUNCTION_NAME} - Fail") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing Fortran ${FUNCTION_NAME} - Fail") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran ${FUNCTION_NAME} exists failed: ${RUN_RESULT_VAR}\n" ) endif () else () - message (STATUS "Compiling Fortran ${FUNCTION_NAME} - Fail") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Compiling Fortran ${FUNCTION_NAME} - Fail") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the Fortran ${FUNCTION_NAME} compiles failed: ${COMPILE_RESULT_VAR}\n" ) @@ -121,74 +129,12 @@ endif () # Determine the available KINDs for REALs and INTEGERs #----------------------------------------------------------------------------- -#READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) -set (PROG_SRC_CODE - " - PROGRAM FC_AVAIL_KINDS - IMPLICIT NONE - INTEGER :: ik, jk, k, max_decimal_prec - INTEGER :: num_rkinds = 1, num_ikinds = 1 - INTEGER, DIMENSION(1:10) :: list_ikinds = -1 - INTEGER, DIMENSION(1:10) :: list_rkinds = -1 - - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - - ! Find integer KINDs - list_ikinds(num_ikinds)=SELECTED_INT_KIND(1) - DO ik = 2, 36 - k = SELECTED_INT_KIND(ik) - IF(k.LT.0) EXIT - IF(k.GT.list_ikinds(num_ikinds))THEN - num_ikinds = num_ikinds + 1 - list_ikinds(num_ikinds) = k - ENDIF - ENDDO - - DO k = 1, num_ikinds - WRITE(8,'(I0)', ADVANCE='NO') list_ikinds(k) - IF(k.NE.num_ikinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - ! Find real KINDs - list_rkinds(num_rkinds)=SELECTED_REAL_KIND(1) - max_decimal_prec = 1 - - prec: DO ik = 2, 36 - exp: DO jk = 1, 17000 - k = SELECTED_REAL_KIND(ik,jk) - IF(k.LT.0) EXIT exp - IF(k.GT.list_rkinds(num_rkinds))THEN - num_rkinds = num_rkinds + 1 - list_rkinds(num_rkinds) = k - ENDIF - max_decimal_prec = ik - ENDDO exp - ENDDO prec - - DO k = 1, num_rkinds - WRITE(8,'(I0)', ADVANCE='NO') list_rkinds(k) - IF(k.NE.num_rkinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' - ELSE - WRITE(8,'()') - ENDIF - ENDDO - - WRITE(8,'(I0)') max_decimal_prec - WRITE(8,'(I0)') num_ikinds - WRITE(8,'(I0)') num_rkinds - END PROGRAM FC_AVAIL_KINDS - " -) +READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) + check_fortran_source_runs (${SOURCE_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) else () FORTRAN_RUN ("REAL and INTEGER KINDs" - "${PROG_SRC_CODE}" + "${SOURCE_CODE}" XX YY FC_AVAIL_KINDS_RESULT @@ -252,7 +198,7 @@ foreach (KIND ${VAR}) USE ISO_C_BINDING IMPLICIT NONE INTEGER (KIND=${KIND}) a - OPEN(8,FILE='pac_validIntKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validIntKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -263,7 +209,7 @@ foreach (KIND ${VAR}) else () FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC_${KIND}} XX YY VALIDINTKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -281,7 +227,9 @@ string (REGEX REPLACE " " "" pack_int_sizeof "${pack_int_sizeof}") set (PAC_FC_ALL_INTEGER_KINDS_SIZEOF "\{${pack_int_sizeof}\}") -message (STATUS "....FOUND SIZEOF for INTEGER KINDs ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF}") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "....FOUND SIZEOF for INTEGER KINDs ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF}") +endif () # ********** # REALS # ********** @@ -299,7 +247,7 @@ foreach (KIND ${VAR} ) USE ISO_C_BINDING IMPLICIT NONE REAL (KIND=${KIND}) a - OPEN(8,FILE='pac_validRealKinds.out',FORM='formatted') + OPEN(8,FILE='pac_validRealKinds.${KIND}.out',FORM='formatted') WRITE(8,'(I0)') ${FC_SIZEOF_A} CLOSE(8) END @@ -310,7 +258,7 @@ foreach (KIND ${VAR} ) else () FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC2_${KIND}} XX YY VALIDREALKINDS_RESULT_${KIND}) endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.out" PROG_OUTPUT1) + file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.${KIND}.out" PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -365,7 +313,7 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") else () FORTRAN_RUN ("SIZEOF NATIVE KINDs" ${PROG_SRC3} XX YY PAC_SIZEOF_NATIVE_KINDS_RESULT) endif () -file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT) +file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT3) # dnl The output from the above program will be: # dnl -- LINE 1 -- sizeof INTEGER # dnl -- LINE 2 -- kind of INTEGER @@ -375,14 +323,14 @@ file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT) # dnl -- LINE 6 -- kind of DOUBLE PRECISION # Convert the string to a list of strings by replacing the carriage return with a semicolon -string (REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") +string (REGEX REPLACE "\n" ";" PROG_OUTPUT3 "${PROG_OUTPUT3}") -list (GET PROG_OUTPUT 0 PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) -list (GET PROG_OUTPUT 1 PAC_FORTRAN_NATIVE_INTEGER_KIND) -list (GET PROG_OUTPUT 2 PAC_FORTRAN_NATIVE_REAL_SIZEOF) -list (GET PROG_OUTPUT 3 PAC_FORTRAN_NATIVE_REAL_KIND) -list (GET PROG_OUTPUT 4 PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF) -list (GET PROG_OUTPUT 5 PAC_FORTRAN_NATIVE_DOUBLE_KIND) +list (GET PROG_OUTPUT3 0 PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) +list (GET PROG_OUTPUT3 1 PAC_FORTRAN_NATIVE_INTEGER_KIND) +list (GET PROG_OUTPUT3 2 PAC_FORTRAN_NATIVE_REAL_SIZEOF) +list (GET PROG_OUTPUT3 3 PAC_FORTRAN_NATIVE_REAL_KIND) +list (GET PROG_OUTPUT3 4 PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF) +list (GET PROG_OUTPUT3 5 PAC_FORTRAN_NATIVE_DOUBLE_KIND) if (NOT PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) message (FATAL_ERROR "Failed to find SIZEOF NATIVE INTEGER KINDs for Fortran") @@ -424,124 +372,13 @@ endif () set (${HDF_PREFIX}_H5CONFIG_F_NUM_RKIND "INTEGER, PARAMETER :: num_rkinds = ${NUM_RKIND}") -string (REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS}) -string (REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) -set (${HDF_PREFIX}_H5CONFIG_F_RKIND "INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/${OUT_VAR}/)") - -string (REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) -string (REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) -set (${HDF_PREFIX}_H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${OUT_VAR}/)") - -ENABLE_LANGUAGE (C) - -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - include (CheckCSourceRuns) -else () -#----------------------------------------------------------------------------- -# The provided CMake C macros don't provide a general compile/run function -# so this one is used. -#----------------------------------------------------------------------------- -macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) - message (STATUS "Detecting C ${FUNCTION_NAME}") - if (HDF5_REQUIRED_LIBRARIES) - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") - else () - set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) - endif () - file (WRITE - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c - ${SOURCE_CODE} - ) - TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c - CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" - RUN_OUTPUT_VARIABLE OUTPUT_VAR - ) - - set (${RETURN_VAR} ${OUTPUT_VAR}) - - #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message (STATUS "Test COMPILE_RESULT_VAR ${COMPILE_RESULT_VAR} ") - #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - #message (STATUS "Test RUN_RESULT_VAR ${RUN_RESULT_VAR} ") - #message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - - if (${COMPILE_RESULT_VAR}) - if (${RUN_RESULT_VAR} MATCHES 1) - set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") - message (STATUS "Testing C ${FUNCTION_NAME} - OK") - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C ${FUNCTION_NAME} exists passed with the following output:\n" - "${OUTPUT_VAR}\n\n" - ) - else () - message (STATUS "Testing C ${FUNCTION_NAME} - Fail") - set (${RUN_RESULT_VAR} 0 CACHE INTERNAL "Have C function ${FUNCTION_NAME}") - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the C ${FUNCTION_NAME} exists failed with the following output:\n" - "${OUTPUT_VAR}\n\n") - endif () - else () - message (FATAL_ERROR "Compilation of C ${FUNCTION_NAME} - Failed") - endif () -endmacro () -endif () - -set (PROG_SRC - " -#include -#include -#define CHECK_FLOAT128 ${${HDF_PREFIX}_SIZEOF___FLOAT128} -#if CHECK_FLOAT128!=0 -# if ${${HDF_PREFIX}_HAVE_QUADMATH_H}!=0 -#include -# endif -# ifdef FLT128_DIG -#define C_FLT128_DIG FLT128_DIG -# else -#define C_FLT128_DIG 0 -# endif -#else -#define C_FLT128_DIG 0 -#endif -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define C_LDBL_DIG DECIMAL_DIG -#else -#define C_LDBL_DIG LDBL_DIG -#endif - int main() { - printf(\"%d\\\\n%d\\\\n\", C_LDBL_DIG, C_FLT128_DIG)\\\; - return 1\\\; - } - " -) - -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_c_source_runs (${PROG_SRC} PROG_OUTPUT) -else () - C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_OUTPUT) -endif () - -# dnl The output from the above program will be: -# dnl -- LINE 1 -- long double decimal precision -# dnl -- LINE 2 -- __float128 decimal precision - -# Convert the string to a list of strings by replacing the carriage return with a semicolon -string (REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") - -list (GET PROG_OUTPUT 0 LDBL_DIG) -list (GET PROG_OUTPUT 1 FLT128_DIG) - -if (${HDF_PREFIX}_SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0) - set (${HDF_PREFIX}_HAVE_FLOAT128 0) - set (${HDF_PREFIX}_SIZEOF___FLOAT128 0) - set (${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${LDBL_DIG}) -else () - set(${HDF_PREFIX}_PAC_C_MAX_REAL_PRECISION ${FLT128_DIG}) -endif () +string (REGEX REPLACE "{" "" OUT_VAR1 ${PAC_FC_ALL_REAL_KINDS}) +string (REGEX REPLACE "}" "" OUT_VAR1 ${OUT_VAR1}) +set (${HDF_PREFIX}_H5CONFIG_F_RKIND "INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/${OUT_VAR1}/)") +string (REGEX REPLACE "{" "" OUT_VAR2 ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) +string (REGEX REPLACE "}" "" OUT_VAR2 ${OUT_VAR2}) +set (${HDF_PREFIX}_H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${OUT_VAR2}/)") # Setting definition if there is a 16 byte fortran integer string (FIND ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF} "16" pos) diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in index 5abb59fab8a..c04bb5b39d4 100644 --- a/config/cmake/HDF5_Examples.cmake.in +++ b/config/cmake/HDF5_Examples.cmake.in @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -77,7 +77,7 @@ set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDN #TAR_SOURCE - name of tarfile #if(NOT DEFINED TAR_SOURCE) -# set(CTEST_USE_TAR_SOURCE "HDF5Examples-1.10.15-Source") +# set(CTEST_USE_TAR_SOURCE "HDF5Examples-1.12.7-Source") #endif() ############################################################################################################### diff --git a/config/cmake/HDF5_Examples_options.cmake b/config/cmake/HDF5_Examples_options.cmake index 386e99c4ce9..236a814cfa6 100644 --- a/config/cmake/HDF5_Examples_options.cmake +++ b/config/cmake/HDF5_Examples_options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -18,6 +18,7 @@ #### HDF_BUILD_CXX:BOOL=OFF ### #### HDF_BUILD_FORTRAN:BOOL=OFF ### #### HDF_BUILD_JAVA:BOOL=OFF ### +#### HDF_BUILD_FILTERS:BOOL=OFF ### #### BUILD_TESTING:BOOL=OFF ### #### HDF_ENABLE_PARALLEL:BOOL=OFF ### #### HDF_ENABLE_THREADSAFE:BOOL=OFF ### @@ -41,6 +42,12 @@ ### enable JAVA builds #set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_JAVA:BOOL=ON") +############################################################################################# +### enable FILTERS builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_FILTERS:BOOL=ON") +### default HDF5_PLUGIN_PATH to where the filter libraries are located +#set(ENV{HDF5_PLUGIN_PATH} "${INSTALLDIR}/lib/plugin") + ############################################################################################# ### enable parallel program builds #set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_ENABLE_PARALLEL:BOOL=ON") diff --git a/config/cmake/HDF5_Process_Flex_Files.cmake b/config/cmake/HDF5_Process_Flex_Files.cmake deleted file mode 100644 index 2595c396ab3..00000000000 --- a/config/cmake/HDF5_Process_Flex_Files.cmake +++ /dev/null @@ -1,95 +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://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# post process flex/bison files - -message (STATUS "File: ${GEN_DIR} ${FILE_PARSE} ${FILE_ANALYZE}") - -if (FILE_PARSE) - # fix H5LTparse.c to declare H5LTyyparse return type as an hid_t - # instead of int. Currently the generated function H5LTyyparse is - # generated with a return value of type int, which is a mapping to the - # flex yyparse function. The return value in the HL library should be - # an hid_t. - # I propose to not use flex to generate this function, but for now I am - # adding a perl command to find and replace this function declaration in - # H5LTparse.c. - file (READ ${GEN_DIR}/${FILE_PARSE}.c TEST_STREAM) - string (REGEX REPLACE "int yyparse" "hid_t yyparse" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "int\nyyparse" "hid_t\nyyparse" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "int H5LTyyparse" "hid_t H5LTyyparse" TEST_STREAM "${TEST_STREAM}") - file (WRITE ${FILE_PARSE}.c "${TEST_STREAM}") - message (STATUS "replacing signature in H5LTparse.c") - - # Add code that disables warnings in the flex/bison-generated code. - # - # Note that the GCC pragmas did not exist until gcc 4.2. Earlier versions - # will simply ignore them, but we want to avoid those warnings. - file (READ ${FILE_PARSE}.c TEST_STREAM) - file (WRITE ${FILE_PARSE}.c " -#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n -#pragma GCC diagnostic ignored \"-Wconversion\"\n -#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n -#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n -#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n -#pragma GCC diagnostic ignored \"-Wnested-externs\"\n -#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n -#pragma GCC diagnostic ignored \"-Wsign-compare\"\n -#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n -#pragma GCC diagnostic ignored \"-Wswitch-default\"\n -#pragma GCC diagnostic ignored \"-Wunused-function\"\n -#pragma GCC diagnostic ignored \"-Wunused-macros\"\n -#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n -#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n -#elif defined __SUNPRO_CC\n -#pragma disable_warn\n -#elif defined _MSC_VER\n -#pragma warning(push, 1)\n -#endif\n - ") - file (APPEND ${FILE_PARSE}.c "${TEST_STREAM}") - message (STATUS "processed pragma in ${FILE_PARSE}") - file (READ ${GEN_DIR}/${FILE_PARSE}.h TEST_STREAM) - file (WRITE ${FILE_PARSE}.h "${TEST_STREAM}") -endif () - -if (FILE_ANALYZE) - # Add code that disables warnings in the flex/bison-generated code. - # - # Note that the GCC pragmas did not exist until gcc 4.2. Earlier versions - # will simply ignore them, but we want to avoid those warnings. - file (READ ${GEN_DIR}/${FILE_ANALYZE} TEST_STREAM) - file (WRITE ${FILE_ANALYZE} " -#if __GNUC__ >= 4 && __GNUC_MINOR__ >=2\n -#pragma GCC diagnostic ignored \"-Wconversion\"\n -#pragma GCC diagnostic ignored \"-Wimplicit-function-declaration\"\n -#pragma GCC diagnostic ignored \"-Wlarger-than=\"\n -#pragma GCC diagnostic ignored \"-Wmissing-prototypes\"\n -#pragma GCC diagnostic ignored \"-Wnested-externs\"\n -#pragma GCC diagnostic ignored \"-Wold-style-definition\"\n -#pragma GCC diagnostic ignored \"-Wsign-compare\"\n -#pragma GCC diagnostic ignored \"-Wsign-conversion\"\n -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"\n -#pragma GCC diagnostic ignored \"-Wswitch-default\"\n -#pragma GCC diagnostic ignored \"-Wunused-function\"\n -#pragma GCC diagnostic ignored \"-Wunused-macros\"\n -#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n -#pragma GCC diagnostic ignored \"-Wredundant-decls\"\n -#elif defined __SUNPRO_CC\n -#pragma disable_warn\n -#elif defined _MSC_VER\n -#pragma warning(push, 1)\n -#endif\n - ") - file (APPEND ${FILE_ANALYZE} "${TEST_STREAM}") - message (STATUS "processed pragma in ${FILE_ANALYZE}") -endif () diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 7bbebbc9160..64ec0107d2c 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -14,7 +14,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") -message (STATUS "Warnings Configuration: CXX default: ${CMAKE_CXX_FLAGS}") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Warnings Configuration: CXX default: ${CMAKE_CXX_FLAGS}") +endif () #----------------------------------------------------------------------------- # Compiler specific flags : Shouldn't there be compiler tests for these #----------------------------------------------------------------------------- @@ -28,6 +30,14 @@ if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstdarg-opt") endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + if (HDF5_ENABLE_BUILD_DIAGS) + message (STATUS "... default color and URL extended diagnostic messages enabled") + else () + message (STATUS "... disable color and URL extended diagnostic messages") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-urls=never -fno-diagnostics-color") + endif () + endif () endif () endif () @@ -61,10 +71,6 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") @@ -80,23 +86,31 @@ if (NOT MSVC AND NOT MINGW) # warnings that are emitted. If you need it, add it at configure time. if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/15") + endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CXXFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CXXFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/18") endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) # add the general CXX flags for g++ compiler versions 4.8 and above. ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") - ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-general") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-general") + else () + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-noerror-general") + endif () endif () elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") list (APPEND HDF5_CMAKE_CXX_FLAGS "-Minform=inform") endif () - message (STATUS "CMAKE_CXX_FLAGS_GENERAL=${HDF5_CMAKE_CXX_FLAGS}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "CMAKE_CXX_FLAGS_GENERAL=${HDF5_CMAKE_CXX_FLAGS}") + endif () endif () #----------------------------------------------------------------------------- @@ -105,21 +119,20 @@ if (NOT MSVC AND NOT MINGW) #----------------------------------------------------------------------------- if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") - # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # list (APPEND H5_CXXFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") endif () else () if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") - # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") endif () endif () @@ -127,76 +140,96 @@ if (NOT MSVC AND NOT MINGW) # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... Only needed for gcc 4.X if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.8") if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") else () - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.9") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.9") endif () - # Append more extra warning flags that only gcc 5.1+ know about + # Append more extra warning flags that only gcc 5.1+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-5") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-5") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-error-5") + else () + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-noerror-5") + endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) - # autotools always add the C flags with the CXX flags + # Use the C warnings as CXX warnings are the same ADD_H5_FLAGS (H5_CXxFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") #else () - # ADD_H5_FLAGS (H5_CXXFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") + # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") - #ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") + else () + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/noerror-8") + endif () if (HDF5_ENABLE_DEV_WARNINGS) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") else () # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) - # autotools always add the C flags with the CXX flags - ADD_H5_FLAGS (H5_CXXFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-9") endif () - endif () -else () - if (NOT MINGW) - list (APPEND HDF5_CMAKE_CXX_FLAGS "/EHsc") + + # Append more extra warning flags that only gcc 9.3+ knows about + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.3) + # do not use C warnings, gnu-warnings 9.3, no cxx warniings + # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") endif () + + # Append more extra warning flags that only gcc 10.x+ knows about + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + if (HDF5_ENABLE_DEV_WARNINGS) + # Use the C warnings as CXX warnings are the same + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") + #else () + # ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-10") + endif () + endif () + endif () endif () #----------------------------------------------------------------------------- @@ -208,97 +241,17 @@ if (HDF5_ENABLE_ALL_WARNINGS) if (HDF5_ENABLE_DEV_WARNINGS) if (CMAKE_CXX_COMPILER_LOADED) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall" "/wd4668") endif () else () if (CMAKE_CXX_COMPILER_LOADED) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3" "/wd4100" "/wd4706" "/wd4127") endif () endif () else () if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0} ${H5_CXXFLAGS1} ${H5_CXXFLAGS2} ${H5_CXXFLAGS3} ${H5_CXXFLAGS4}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_GROUPZERO_WARNINGS) - message (STATUS "....Group Zero warnings are enabled") - if (MSVC) - if (CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W1") - endif () - else () - if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_GROUPONE_WARNINGS) - message (STATUS "....Group One warnings are enabled") - if (MSVC) - if (CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2") - endif () - else () - if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS1}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_GROUPTWO_WARNINGS) - message (STATUS "....Group Two warnings are enabled") - if (MSVC) - if (CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") - endif () - else () - if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS2}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_GROUPTHREE_WARNINGS) - message (STATUS "....Group Three warnings are enabled") - if (MSVC) - if (CMAKE_CXX_COMPILER_LOADED) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") - list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4") - endif () - else () - if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS3}) - endif () - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_GROUPFOUR_WARNINGS) - message (STATUS "....Group Four warnings are enabled") - if (NOT MSVC) - if (CMAKE_CXX_COMPILER_LOADED) - list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS4}) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS}) endif () endif () endif () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 31af2f8c4b2..e38a92b76b1 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -15,7 +15,10 @@ set(CMAKE_C_STANDARD_REQUIRED TRUE) set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") -message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") + +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}") +endif () #----------------------------------------------------------------------------- # Compiler specific flags : Shouldn't there be compiler tests for these #----------------------------------------------------------------------------- @@ -29,6 +32,20 @@ if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstdarg-opt") endif () + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) + #----------------------------------------------------------------------------- + # Option to allow the user to enable build extended diagnostics + # + # This should NOT be on by default as it can cause process issues. + #----------------------------------------------------------------------------- + option (HDF5_ENABLE_BUILD_DIAGS "Enable color and URL extended diagnostic messages" OFF) + if (HDF5_ENABLE_BUILD_DIAGS) + message (STATUS "... default color and URL extended diagnostic messages enabled") + else () + message (STATUS "... disable color and URL extended diagnostic messages") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-urls=never -fno-diagnostics-color") + endif () + endif () endif () endif () @@ -64,11 +81,19 @@ endif () # HDF5 library compile options #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# CDash is configured to only allow 3000 warnings, so -# break into groups (from the config/gnu-flags file) -#----------------------------------------------------------------------------- if (NOT MSVC AND NOT MINGW) + #----------------------------------------------------------------------------- + # Option to allow the user to interpret certain warnings as errors + # + # This should NOT be on by default as it can cause a lot of conflicts with + # new operating systems and compiler versions. Header files that are out of + # our control (MPI, HDFS, etc.) can also raise warnings. + #----------------------------------------------------------------------------- + option (HDF5_ENABLE_WARNINGS_AS_ERRORS "Interpret some warnings as errors" OFF) + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + message (STATUS "...some warnings will be interpreted as errors") + endif () + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP") else () @@ -83,31 +108,40 @@ if (NOT MSVC AND NOT MINGW) # warnings that are emitted. If you need it, add it at configure time. if (CMAKE_C_COMPILER_ID STREQUAL "Intel") ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") - list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith") - list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized") - list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable") + if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/15") + endif() # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") + list (APPEND H5_CFLAGS "-finline-functions") if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0) - list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") - list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/18") endif() elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") # Add general CFlags for GCC versions 4.8 and above if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general") + else () + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/noerror-general") + endif () endif () # gcc automatically inlines based on the optimization level # this is just a failsafe - list (APPEND H5_CFLAGS0 "-finline-functions") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") + list (APPEND H5_CFLAGS "-finline-functions") + elseif (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang") ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general") + else () + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/noerror-general") + endif () elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI") list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform") endif () - message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") + endif () endif () #----------------------------------------------------------------------------- @@ -118,78 +152,97 @@ if (NOT MSVC AND NOT MINGW) if (HDF5_ENABLE_DEV_WARNINGS) message (STATUS "....HDF5 developer group warnings are enabled") if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/developer-general") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + elseif (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") endif () else () if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") - elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + elseif (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") endif () endif () - if (CMAKE_C_COMPILER_ID STREQUAL "GNU") # Technically, variable-length arrays are part of the C99 standard, but # we should approach them a bit cautiously... Only needed for gcc 4.X if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4.8) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8-4.last") endif () - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8") if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") else () - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") endif () endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9") endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/5") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + else () + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5") + endif () endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0) - ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/7") if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7") #else () - # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") + # ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7") endif () endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/8") + if (HDF5_ENABLE_WARNINGS_AS_ERRORS) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-8") + endif () if (HDF5_ENABLE_DEV_WARNINGS) - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8") else () - ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8") endif () endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) - ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9") + endif () + + # Append more extra warning flags that only gcc 9.3+ knows about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/9.3") + endif () + + # Append more extra warning flags that only gcc 10.x+ knows about + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-10") + #else () + # ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-10") + endif () endif () endif () endif () @@ -197,86 +250,19 @@ endif () #----------------------------------------------------------------------------- # Option to allow the user to enable all warnings #----------------------------------------------------------------------------- -option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF) +option (HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" ON) if (HDF5_ENABLE_ALL_WARNINGS) message (STATUS "....All Warnings are enabled") if (MSVC) if (HDF5_ENABLE_DEV_WARNINGS) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") + list (APPEND HDF5_CMAKE_C_FLAGS "/Wall" "/wd4668") else () string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3" "/wd4100" "/wd4706" "/wd4127") endif () else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4}) - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF) -if (HDF5_ENABLE_GROUPZERO_WARNINGS) - message (STATUS "....Group Zero warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W1") - else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0}) - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF) -if (HDF5_ENABLE_GROUPONE_WARNINGS) - message (STATUS "....Group One warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W2") - else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF) -if (HDF5_ENABLE_GROUPTWO_WARNINGS) - message (STATUS "....Group Two warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W3") - else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF) -if (HDF5_ENABLE_GROUPTHREE_WARNINGS) - message (STATUS "....Group Three warnings are enabled") - if (MSVC) - string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") - list (APPEND HDF5_CMAKE_C_FLAGS "/W4") - else () - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) - endif () -endif () - -#----------------------------------------------------------------------------- -# Option to allow the user to enable warnings by groups -#----------------------------------------------------------------------------- -option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF) -if (HDF5_ENABLE_GROUPFOUR_WARNINGS) - message (STATUS "....Group Four warnings are enabled") - if (NOT MSVC) - list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS}) endif () endif () diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 2bbb35d8d82..18ab62186de 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -5,12 +5,14 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # -message (STATUS "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") +endif () #----------------------------------------------------------------------------- # Option to allow the user to disable compiler warnings @@ -43,6 +45,14 @@ endif () #----------------------------------------------------------------------------- # HDF5 library compile options #----------------------------------------------------------------------------- +if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0) + if (HDF5_ENABLE_BUILD_DIAGS) + message (STATUS "... default color and URL extended diagnostic messages enabled") + else () + message (STATUS "... disable color and URL extended diagnostic messages") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdiagnostics-urls=never -fno-diagnostics-color") + endif () +endif () #----------------------------------------------------------------------------- # CDash is configured to only allow 3000 warnings, so @@ -64,41 +74,43 @@ if (NOT MSVC AND NOT MINGW) elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") endif () - message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") + endif () if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append more extra warning flags that only gcc 4.8+ know about + # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") endif () - # Append more extra warning flags that only gcc 4.9+ know about + # Append more extra warning flags that only gcc 4.9+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") #endif () - # Append more extra warning flags that only gcc 5.x+ know about + # Append more extra warning flags that only gcc 5.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") endif () - # Append more extra warning flags that only gcc 6.x+ know about + # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") endif () - # Append more extra warning flags that only gcc 7.x+ know about + # Append more extra warning flags that only gcc 7.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") #endif () - # Append more extra warning flags that only gcc 8.x+ know about + # Append more extra warning flags that only gcc 8.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") endif () - # Append more extra warning flags that only gcc 9.x+ know about + # Append more extra warning flags that only gcc 9.x+ knows about #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") #endif () diff --git a/config/cmake/README.txt.cmake.in b/config/cmake/README.txt.cmake.in index f621515412f..bc14e995ed3 100644 --- a/config/cmake/README.txt.cmake.in +++ b/config/cmake/README.txt.cmake.in @@ -26,7 +26,7 @@ The official ZLIB and SZIP/Libaec pages are at: ZLIB: https://git.savannah.gnu.org/cgit/gzip.git/ https://git.savannah.gnu.org/cgit/gzip.git/tree/COPYING SZIP/Libaec: https://gitlab.dkrz.de/k202009/libaec - https://gitlab.dkrz.de/k202009/libaec/-/blob/master/Copyright.txt + https://gitlab.dkrz.de/k202009/libaec/-/blob/master/LICENSE.txt Installation diff --git a/config/cmake/UserMacros/Windows_MT.cmake b/config/cmake/UserMacros/Windows_MT.cmake index 78d8277789c..15cffbaae99 100644 --- a/config/cmake/UserMacros/Windows_MT.cmake +++ b/config/cmake/UserMacros/Windows_MT.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 64e8dccf018..e423debdaa7 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -21,6 +21,8 @@ set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE) set (HDF_PACKAGE_NAMESPACE "hdf5::" CACHE STRING "Name for HDF package namespace (can be empty)" FORCE) +set (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build C++ support" FORCE) + set (HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE) set (HDF5_INSTALL_MOD_FORTRAN "NO" CACHE STRING "Copy FORTRAN mod files to include directory (NO SHARED STATIC)" FORCE) @@ -40,11 +42,12 @@ set (HDF5_ENABLE_ALL_WARNINGS ON CACHE BOOL "Enable all warnings" FORCE) set (HDF_TEST_EXPRESS "2" CACHE STRING "Control testing framework (0-3)" FORCE) +set (HDF5_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" FORCE) + set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE) set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ) set (ZLIB_TGZ_NAME "ZLib.tar.gz" CACHE STRING "Use ZLib from compressed file" FORCE) - set (SZIP_TGZ_NAME "SZip.tar.gz" CACHE STRING "Use SZip from compressed file" FORCE) set (SZAEC_TGZ_NAME "LIBAEC.tar.gz" CACHE STRING "Use SZip AEC from compressed file" FORCE) set (USE_LIBAEC ON CACHE BOOL "Use libaec szip replacement" FORCE) @@ -52,3 +55,128 @@ set (USE_LIBAEC ON CACHE BOOL "Use libaec szip replacement" FORCE) set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE) set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package" FORCE) set (SZIP_PACKAGE_NAME "szip" CACHE STRING "Name of SZIP package" FORCE) + +####################### +# filter plugin options +####################### +set (PLUGIN_TGZ_NAME "hdf5_plugins.tar.gz" CACHE STRING "Use PLUGINS from compressed file" FORCE) + +set (PLUGIN_PACKAGE_NAME "pl" CACHE STRING "Name of PLUGIN package" FORCE) + +############ +# bitshuffle +########### + +set (BSHUF_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/bitshuffle.git" CACHE STRING "Use BSHUF from HDF repository" FORCE) +set (BSHUF_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (BSHUF_TGZ_NAME "bitshuffle.tar.gz" CACHE STRING "Use BSHUF from compressed file" FORCE) + +set (BSHUF_PACKAGE_NAME "bshuf" CACHE STRING "Name of BSHUF package" FORCE) + +####### +# blosc +####### + +set (BLOSC_GIT_URL "https://github.com/Blosc/c-blosc.git" CACHE STRING "Use BLOSC from Github" FORCE) +set (BLOSC_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (BLOSC_TGZ_NAME "c-blosc.tar.gz" CACHE STRING "Use BLOSC from compressed file" FORCE) + +set (BLOSC_PACKAGE_NAME "blosc" CACHE STRING "Name of BLOSC package" FORCE) + +set (ZLIB_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/zlib.git" CACHE STRING "Use ZLIB from HDF repo" FORCE) +set (ZLIB_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (ZLIB_TGZ_NAME "ZLib.tar.gz" CACHE STRING "Use ZLib from compressed file" FORCE) + +set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE) + +####### +# bzip2 +###### +# +set (BZ2_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/bzip2.git" CACHE STRING "Use BZ2 from HDF repository" FORCE) +set (BZ2_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (BZ2_TGZ_NAME "BZ2.tar.gz" CACHE STRING "Use BZ2 from compressed file" FORCE) + +set (BZ2_PACKAGE_NAME "bz2" CACHE STRING "Name of BZ2 package" FORCE) + +####### +# fpzip +####### + +set (FPZIP_GIT_URL "https://https://github.com/LLNL/fpzip" CACHE STRING "Use FPZIP from github repository" FORCE) +set (FPZIP_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (FPZIP_TGZ_NAME "fpzip.tar.gz" CACHE STRING "Use FPZIP from compressed file" FORCE) + +set (FPZIP_PACKAGE_NAME "fpzip" CACHE STRING "Name of FPZIP package" FORCE) + +###### +# jpeg +###### + +set (JPEG_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/jpeg.git" CACHE STRING "Use JPEG from HDF repository" FORCE) +set (JPEG_GIT_BRANCH "jpeg9c" CACHE STRING "" FORCE) + +#set (JPEG_TGZ_NAME "JPEG9c.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE) +set (JPEG_TGZ_NAME "JPEG.tar.gz" CACHE STRING "Use JPEG from compressed file" FORCE) + +set (JPEG_PACKAGE_NAME "jpeg" CACHE STRING "Name of JPEG package" FORCE) + +###### +# lz4 +###### + +set (BUILD_LZ4_LIBRARY_SOURCE ON CACHE BOOL "build the lz4 library within the plugin" FORCE) + +set (LZ4_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/lz4.git" CACHE STRING "Use LZ4 from HDF repository" FORCE) +set (LZ4_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (LZ4_TGZ_NAME "lz4.tar.gz" CACHE STRING "Use LZ4 from compressed file" FORCE) + +set (LZ4_PACKAGE_NAME "lz4" CACHE STRING "Name of LZ4 package" FORCE) + +###### +# lzf +###### + +set (LZF_GIT_URL "https://git@bitbucket.hdfgroup.org/scm/test/lzf.git" CACHE STRING "Use LZF from HDF repository" FORCE) +set (LZF_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (LZF_TGZ_NAME "lzf.tar.gz" CACHE STRING "Use LZF from compressed file" FORCE) + +set (LZF_PACKAGE_NAME "lzf" CACHE STRING "Name of LZF package" FORCE) + +######## +# mafisc +######## + +#set (BUILD_MAFISC_LIBRARY_SOURCE OFF CACHE BOOL "build the mafisc library within the plugin" FORCE) + +#set (MAFISC_PACKAGE_NAME "mafisc" CACHE STRING "Name of MAFISC package" FORCE) + +###### +# szf +###### + +set (SZF_GIT_URL "https://github.com/disheng222/SZ" CACHE STRING "Use SZ from github repository" FORCE) +set (SZF_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (SZF_TGZ_NAME "szf.tar.gz" CACHE STRING "Use SZ from compressed file" FORCE) + +set (SZF_PACKAGE_NAME "szf" CACHE STRING "Name of SZ package" FORCE) + +###### +# zfp +###### + +set (ZFP_GIT_URL "https://github.com/LLNL/zfp.git" CACHE STRING "Use ZFP from Github" FORCE) +set (ZFP_GIT_BRANCH "master" CACHE STRING "" FORCE) + +set (ZFP_TGZ_NAME "zfp.tar.gz" CACHE STRING "Use ZFP from compressed file" FORCE) + +set (ZFP_PACKAGE_NAME "zfp" CACHE STRING "Name of ZFP package" FORCE) + diff --git a/config/cmake/fileCompareTest.cmake b/config/cmake/fileCompareTest.cmake index d913da02973..4a8dc099618 100644 --- a/config/cmake/fileCompareTest.cmake +++ b/config/cmake/fileCompareTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -24,9 +24,6 @@ endif () if (NOT TEST_FUNCTION) message (FATAL_ERROR "Require TEST_FUNCTION (LT,LTEQ,EQ,GTEQ,GT) to be defined") endif () -#if (NOT TEST_EXPECT) -# message (STATUS "Require TEST_EXPECT to be defined") -#endif () set (TEST_ONE_SIZE 0) set (TEST_TWO_SIZE 0) @@ -53,7 +50,9 @@ if (TEST_STRINGS STREQUAL "YES") RESULT_VARIABLE TEST_RESULT ) - message (STATUS "COMPARE Result: ${TEST_RESULT}: ${TEST_STRING_SIZE}=${TEST_U_STRING_LEN}-${TEST_O_STRING_LEN}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "COMPARE Result: ${TEST_RESULT}: ${TEST_STRING_SIZE}=${TEST_U_STRING_LEN}-${TEST_O_STRING_LEN}") + endif () # if the return value is !=${TEST_EXPECT} bail out if (NOT TEST_RESULT EQUAL TEST_EXPECT) message (FATAL_ERROR "Failed: The output of ${TEST_FOLDER}/${TEST_ONEFILE} did not match ${TEST_FOLDER}/${TEST_TWOFILE}.\n${TEST_ERROR}") @@ -66,31 +65,41 @@ else () file (SIZE ${TEST_FOLDER}/${TEST_TWOFILE} TEST_TWO_SIZE) if (TEST_FUNCTION MATCHES "LT") if (TEST_ONE_SIZE LESS TEST_TWO_SIZE) - message (STATUS "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was less ${TEST_FOLDER}/${TEST_TWOFILE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was less ${TEST_FOLDER}/${TEST_TWOFILE}") + endif () else () message (FATAL_ERROR "The size of ${TEST_FOLDER}/${TEST_ONEFILE} was NOT less ${TEST_FOLDER}/${TEST_TWOFILE}") endif () elseif (TEST_FUNCTION MATCHES "LTEQ") if (TEST_ONE_SIZE LESS_EQUAL TEST_TWO_SIZE) - message (STATUS "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was less or equal ${TEST_FOLDER}/${TEST_TWOFILE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSES "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was less or equal ${TEST_FOLDER}/${TEST_TWOFILE}") + endif () else () message (FATAL_ERROR "The size of ${TEST_FOLDER}/${TEST_ONEFILE} was NOT less or equal ${TEST_FOLDER}/${TEST_TWOFILE}") endif () elseif (TEST_FUNCTION MATCHES "EQ") if (TEST_ONE_SIZE LESS_EQUAL TEST_TWO_SIZE) - message (STATUS "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was equal ${TEST_FOLDER}/${TEST_TWOFILE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was equal ${TEST_FOLDER}/${TEST_TWOFILE}") + endif () else () message (FATAL_ERROR "The size of ${TEST_FOLDER}/${TEST_ONEFILE} was NOT equal ${TEST_FOLDER}/${TEST_TWOFILE}") endif () elseif (TEST_FUNCTION MATCHES "GTEQ") if (TEST_ONE_SIZE LESS_EQUAL TEST_TWO_SIZE) - message (STATUS "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was greater or equal ${TEST_FOLDER}/${TEST_TWOFILE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was greater or equal ${TEST_FOLDER}/${TEST_TWOFILE}") + endif () else () message (FATAL_ERROR "The size of ${TEST_FOLDER}/${TEST_ONEFILE} was NOT greater or equal ${TEST_FOLDER}/${TEST_TWOFILE}") endif () elseif (TEST_FUNCTION MATCHES "GT") if (TEST_ONE_SIZE LESS_EQUAL TEST_TWO_SIZE) - message (STATUS "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was greater ${TEST_FOLDER}/${TEST_TWOFILE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Passed: The size of ${TEST_FOLDER}/${TEST_ONEFILE} was greater ${TEST_FOLDER}/${TEST_TWOFILE}") + endif () else () message (FATAL_ERROR "The size of ${TEST_FOLDER}/${TEST_ONEFILE} was NOT greater ${TEST_FOLDER}/${TEST_TWOFILE}") endif () diff --git a/config/cmake/hdf5-config-version.cmake.in b/config/cmake/hdf5-config-version.cmake.in index 575c1ab8818..20ce630351a 100644 --- a/config/cmake/hdf5-config-version.cmake.in +++ b/config/cmake/hdf5-config-version.cmake.in @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -33,7 +33,7 @@ else() endif() if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND - (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR)) + (PACKAGE_FIND_VERSION_MINOR STRLESS_EQUAL CVF_VERSION_MINOR)) set(PACKAGE_VERSION_COMPATIBLE TRUE) else() set(PACKAGE_VERSION_COMPATIBLE FALSE) diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index a0e93df6b2a..4d02c9c5ff2 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -39,6 +39,7 @@ set (${HDF5_PACKAGE_NAME}_BUILD_JAVA @HDF5_BUILD_JAVA@) set (${HDF5_PACKAGE_NAME}_BUILD_TOOLS @HDF5_BUILD_TOOLS@) set (${HDF5_PACKAGE_NAME}_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) set (${HDF5_PACKAGE_NAME}_ENABLE_THREADSAFE @HDF5_ENABLE_THREADSAFE@) +set (${HDF5_PACKAGE_NAME}_ENABLE_PLUGIN_SUPPORT @HDF5_ENABLE_PLUGIN_SUPPORT@) set (${HDF5_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT @HDF5_ENABLE_Z_LIB_SUPPORT@) set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT @HDF5_ENABLE_SZIP_SUPPORT@) set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_ENCODING @HDF5_ENABLE_SZIP_ENCODING@) diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake index 41570ebc899..2ca1b755aae 100644 --- a/config/cmake/jrunTest.cmake +++ b/config/cmake/jrunTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -49,7 +49,7 @@ endif () message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") -if (WIN32 OR MINGW) +if (WIN32) set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -131,7 +131,7 @@ if (NOT TEST_SKIP_COMPARE) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) list (LENGTH TEST_STREAM test_len) if (test_len GREATER 0) - if (WIN32 OR MINGW) + if (WIN32) configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp") file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) @@ -202,7 +202,7 @@ if (NOT TEST_SKIP_COMPARE) file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) list (LENGTH TEST_STREAM test_len) if (test_len GREATER 0) - if (WIN32 OR MINGW) + if (WIN32) configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) if (EXISTS "${TEST_FOLDER}/${TEST_ERRREF}.tmp") file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) diff --git a/config/cmake/jvolTest.cmake b/config/cmake/jvolTest.cmake new file mode 100644 index 00000000000..b12c358cb5b --- /dev/null +++ b/config/cmake/jvolTest.cmake @@ -0,0 +1,301 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# jrunTest.cmake executes a command and captures the output in a file. File is then compared +# against a reference file. Exit status of command can also be compared. +cmake_policy(SET CMP0007 NEW) + +# arguments checking +if (NOT TEST_TESTER) + message (FATAL_ERROR "Require TEST_TESTER to be defined") +endif () +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif () +if (NOT TEST_LIBRARY_DIRECTORY) + message (STATUS "Require TEST_LIBRARY_DIRECTORY to be defined") +endif () +if (NOT TEST_FOLDER) + message (FATAL_ERROR "Require TEST_FOLDER to be defined") +endif () +if (NOT TEST_OUTPUT) + message (FATAL_ERROR "Require TEST_OUTPUT to be defined") +endif () +if (NOT TEST_CLASSPATH) + message (STATUS "Require TEST_CLASSPATH to be defined") +endif () +if (NOT TEST_VOL) + message (FATAL_ERROR "Require TEST_VOL to be defined") +endif () + +if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}") + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) +endif () + +if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) +endif () + +if (NOT TEST_LOG_LEVEL) + set (LOG_LEVEL "info") +else () + set (LOG_LEVEL "${TEST_LOG_LEVEL}") +endif () + +message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") + +set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") + +if (WIN32) + set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}") +else () + set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") +endif () + +# run the test program, capture the stdout/stderr and the result var +execute_process ( + COMMAND ${TEST_TESTER} -Xmx1024M + -Dorg.slf4j.simpleLogger.defaultLogLevel=${LOG_LEVEL} + -Djava.library.path=${TEST_LIBRARY_DIRECTORY} + -cp "${TEST_CLASSPATH}" ${TEST_ARGS} ${TEST_PROGRAM} + ${ARGN} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_OUT + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +# if the .err file exists and ERRROR_APPEND is enabled +if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + list(LENGTH TEST_STREAM test_len) + if (test_len GREATER 0) + if (TEST_MASK_FILE) + STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}") + endif () + + if (NOT ERROR_APPEND) + # write back to original .err file + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") + else () + # append error output to the stdout output file + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + endif () + endif () +endif () + +# if the output file or the .err file needs to mask out error stack info +if (TEST_MASK_ERROR) + if (NOT TEST_ERRREF) + # the error stack has been appended to the output file + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + else () + # the error stack remains in the .err file + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + endif () + string (REGEX REPLACE "Time:[^\n]+\n" "Time: XXXX\n" TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}") + #string (REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE "HDF5 .[1-9]*[.][0-9]*[.][0-9]*[^)]*" "HDF5 (version (number)" TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + string (REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + # write back the changes to the original files + if (NOT TEST_ERRREF) + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + else () + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") + endif () +endif () + +# if the return value is !=expected bail out +if (NOT TEST_RESULT EQUAL TEST_EXPECT) + message (STATUS "ERROR OUTPUT: ${TEST_STREAM}") + message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != 0.\n${TEST_ERROR}") +endif () + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +# compare output files to references unless this must be skipped +set (TEST_COMPARE_RESULT 0) +if (NOT TEST_SKIP_COMPARE) + if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}") + file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + list(LENGTH TEST_STREAM test_len) + if (test_len GREATER 0) + if (WIN32) + configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) + if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp") + file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) + endif () + #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + endif () + + if (NOT TEST_SORT_COMPARE) + # now compare the output with the reference + execute_process ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} + RESULT_VARIABLE TEST_COMPARE_RESULT + ) + else () + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2) + list (SORT v1) + list (SORT v2) + if (NOT v1 STREQUAL v2) + set(TEST_COMPARE_RESULT 1) + endif () + endif () + + if (TEST_COMPARE_RESULT) + set (TEST_COMPARE_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) + list (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) + list (LENGTH test_ref len_ref) + if (len_act GREATER 0 AND len_ref GREATER 0) + math (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET test_act ${line} str_act) + list (GET test_ref ${line} str_ref) + if (NOT str_act STREQUAL str_ref) + if (str_act) + set (TEST_COMPARE_RESULT 1) + message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif () + endif () + endforeach () + else () + if (len_act EQUAL 0) + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") + endif () + if (len_ref EQUAL 0) + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") + endif () + endif () + if (NOT len_act EQUAL len_ref) + set (TEST_COMPARE_RESULT 1) + endif () + endif () + endif () + + message (STATUS "COMPARE Result: ${TEST_COMPARE_RESULT}") + + # again, if return value is !=0 scream and shout + if (TEST_COMPARE_RESULT) + message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + endif () + endif () + + # now compare the .err file with the error reference, if supplied + set (TEST_ERRREF_RESULT 0) + if (TEST_ERRREF) + file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) + list(LENGTH TEST_STREAM test_len) + if (test_len GREATER 0) + if (WIN32) + configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) + if (EXISTS "${TEST_FOLDER}/${TEST_ERRREF}.tmp") + file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) + endif () + #file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) + #file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") + endif () + + # now compare the error output with the error reference + execute_process ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF} + RESULT_VARIABLE TEST_ERRREF_RESULT + ) + if (TEST_ERRREF_RESULT) + set (TEST_ERRREF_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act) + list (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref) + list (LENGTH test_ref len_ref) + math (EXPR _FP_LEN "${len_ref} - 1") + if (len_act GREATER 0 AND len_ref GREATER 0) + math (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET test_act ${line} str_act) + list (GET test_ref ${line} str_ref) + if (NOT str_act STREQUAL str_ref) + if (str_act) + set (TEST_ERRREF_RESULT 1) + message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif () + endif () + endforeach () + else () + if (len_act EQUAL 0) + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT}.err is empty") + endif () + if (len_ref EQUAL 0) + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_ERRREF} is empty") + endif () + endif () + if (NOT len_act EQUAL len_ref) + set (TEST_ERRREF_RESULT 1) + endif () + endif () + endif () + + message (STATUS "COMPARE Result: ${TEST_ERRREF_RESULT}") + + # again, if return value is !=0 scream and shout + if (TEST_ERRREF_RESULT) + message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}") + endif () + endif () +endif () + +set (TEST_GREP_RESULT 0) +if (TEST_GREP_COMPARE) + # now grep the output with the reference + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + list(LENGTH TEST_STREAM test_len) + if (test_len GREATER 0) + # TEST_REFERENCE should always be matched + string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM}) + string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_GREP_RESULT) + if (NOT TEST_GREP_RESULT) + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}") + endif () + + string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM}) + if (TEST_EXPECT) + # TEST_EXPECT (1) interprets TEST_FILTER as; NOT to match + string (LENGTH "${TEST_MATCH}" TEST_GREP_RESULT) + if (TEST_GREP_RESULT) + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}") + endif () + endif () + endif () +endif () + +# dump the output unless nodisplay option is set +if (TEST_SKIP_COMPARE AND NOT TEST_NO_DISPLAY) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + execute_process ( + COMMAND ${CMAKE_COMMAND} -E echo ${TEST_STREAM} + RESULT_VARIABLE TEST_RESULT + ) +endif () + +# everything went fine... +message (STATUS "${TEST_PROGRAM} program used vol ${TEST_VOL} Passed") + diff --git a/config/cmake/libh5cc.in b/config/cmake/libh5cc.in index 3b44b211613..c98d9ca23ba 100755 --- a/config/cmake/libh5cc.in +++ b/config/cmake/libh5cc.in @@ -1,4 +1,4 @@ -#!/bin/sh +#! /bin/sh ## # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -7,7 +7,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. ## @@ -29,4 +29,4 @@ printf 'dir is %s\n' "$dir" export PKG_CONFIG_PATH=$dir/lib/pkgconfig -@_PKG_CONFIG_COMPILER@ `pkg-config --define-variable=prefix=$dir --cflags --libs @_PKG_CONFIG_LIBNAME@-@_PKG_CONFIG_VERSION@` $@ +@_PKG_CONFIG_COMPILER@ `pkg-config --define-variable=prefix=$dir --cflags --libs @_PKG_CONFIG_LIBNAME@` $@ diff --git a/config/cmake/libhdf5.pc.in b/config/cmake/libhdf5.pc.in deleted file mode 100644 index 4a2ebaab474..00000000000 --- a/config/cmake/libhdf5.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@_PKG_CONFIG_PREFIX@ -exec_prefix=@_PKG_CONFIG_EXEC_PREFIX@ -libdir=@_PKG_CONFIG_LIBDIR@ -includedir=@_PKG_CONFIG_INCLUDEDIR@ - -Name: @_PKG_CONFIG_LIBNAME@ -Description: HDF5 (Hierarchical Data Format 5) Software Library -Version: @_PKG_CONFIG_VERSION@ - -Cflags: -I${includedir} -Libs: -L${libdir} @_PKG_CONFIG_SH_LIBS@ -Requires: @_PKG_CONFIG_REQUIRES@ -Libs.private: @_PKG_CONFIG_LIBS_PRIVATE@ @_PKG_CONFIG_LIBS@ -Requires.private: @_PKG_CONFIG_REQUIRES_PRIVATE@ diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index ebcbd61ae11..dd345b4cd5c 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -70,7 +70,7 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ High-level library: @HDF5_BUILD_HL_LIB@ Build HDF5 Tests: @BUILD_TESTING@ Build HDF5 Tools: @HDF5_BUILD_TOOLS@ - Threadsafety: @HDF5_ENABLE_THREADSAFE@ + Threadsafety: @HDF5_ENABLE_THREADSAFE@ (recursive RW locks: @HDF5_USE_RECURSIVE_RW_LOCKS@) Default API mapping: @DEFAULT_API_VERSION@ With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@ I/O filters (external): @EXTERNAL_FILTERS@ diff --git a/config/cmake/mccacheinit.cmake b/config/cmake/mccacheinit.cmake index af078941a29..dd0c9ece455 100644 --- a/config/cmake/mccacheinit.cmake +++ b/config/cmake/mccacheinit.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index e3659f6c130..b142ade8b4e 100644 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index 0bbd3b95549..50709ec12b9 100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -5,13 +5,13 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # ############################################################################################# ### ${CTEST_SCRIPT_ARG} is of the form OPTION=VALUE ### -### BUILD_GENERATOR required [Unix, VS2017, VS201764, VS2015, VS201564, VS2013, VS201364] ### +### BUILD_GENERATOR required [Unix, VS2019, VS201964, VS2017, VS201764, VS2015, VS201564] ### ### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ### ############################################################################################# @@ -37,15 +37,15 @@ cmake_minimum_required (VERSION 3.12) # CTEST_SOURCE_NAME - source folder ############################################################################## -set (CTEST_SOURCE_VERSION "1.10.7") +set (CTEST_SOURCE_VERSION "1.12.1") set (CTEST_SOURCE_VERSEXT "") ############################################################################## # handle input parameters to script. #BUILD_GENERATOR - which CMake generator to use, required -#INSTALLDIR - HDF5-1.10.x root folder +#INSTALLDIR - HDF5-1.12.x root folder #CTEST_CONFIGURATION_TYPE - Release, Debug, RelWithDebInfo -#CTEST_SOURCE_NAME - name of source folder; HDF5-1.10.x +#CTEST_SOURCE_NAME - name of source folder; HDF5-1.12.x #MODEL - CDash group name #HPC - run alternate configurations for HPC machines; sbatch, bsub, raybsub, qsub #MPI - enable MPI @@ -68,7 +68,7 @@ endif () # build generator must be defined if (NOT DEFINED BUILD_GENERATOR) - message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") + message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2019, VS201964, VS2017, or VS201764, VS2015, VS201564") endif () ################################################################### @@ -105,7 +105,7 @@ endif () ######### Following describes compiler ############ if (NOT DEFINED HPC) if (NOT DEFINED BUILD_GENERATOR) - message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") + message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2019, VS201964, VS2017, or VS201764, VS2015, VS201564") endif () if (WIN32 AND NOT MINGW) set (SITE_OS_NAME "Windows") @@ -163,7 +163,7 @@ if (NOT DEFINED HPC) set (SITE_COMPILER_NAME "vs2012") set (SITE_COMPILER_VERSION "11") else () - message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") + message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2019, VS201964, VS2017, or VS201764, VS2015, VS201564") endif () ## Set the following to unique id your computer ## set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") @@ -204,8 +204,8 @@ endif () #set (LOCAL_NO_PACKAGE "TRUE") ##### Following controls source update ##### #set (LOCAL_UPDATE "TRUE") -set (REPOSITORY_URL "https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5.git") -set (REPOSITORY_BRANCH "hdf5_1_10") +set (REPOSITORY_URL "https://github.com/HDFGroup/hdf5.git") +set (REPOSITORY_BRANCH "hdf5_1_12") #uncomment to use a compressed source file: *.tar on linux or mac *.zip on windows #set(CTEST_USE_TAR_SOURCE "${CTEST_SOURCE_VERSION}") diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake index bd186040296..532cf6accf2 100644 --- a/config/cmake/scripts/HDF5options.cmake +++ b/config/cmake/scripts/HDF5options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -57,7 +57,9 @@ set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRIN #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=GIT") ### ext libs on system #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=NO") +#set(ENV{ZLIB_ROOT} "some_location") #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") +#set(ENV{SZIP_ROOT} "some_location") #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSZIP_LIBRARY:FILEPATH=some_location/lib/szlib.lib -DSZIP_INCLUDE_DIR:PATH=some_location/include") ### disable using ext zlib @@ -67,7 +69,7 @@ set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRIN #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF") #### package examples #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACK_EXAMPLES:BOOL=ON -DHDF5_EXAMPLES_COMPRESSED:STRING=HDF5Examples-1.10.15-Source.tar.gz -DHDF5_EXAMPLES_COMPRESSED_DIR:PATH=${CTEST_SCRIPT_DIRECTORY}") +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACK_EXAMPLES:BOOL=ON -DHDF5_EXAMPLES_COMPRESSED:STRING=HDF5Examples-1.12.7-Source.tar.gz -DHDF5_EXAMPLES_COMPRESSED_DIR:PATH=${CTEST_SCRIPT_DIRECTORY}") ############################################################################################# ### enable parallel builds diff --git a/config/cmake/scripts/HPC/bsub-HDF5options.cmake b/config/cmake/scripts/HPC/bsub-HDF5options.cmake index 7473e8aee12..37fdb8b66d2 100644 --- a/config/cmake/scripts/HPC/bsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/bsub-HDF5options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/scripts/HPC/qsub-HDF5options.cmake b/config/cmake/scripts/HPC/qsub-HDF5options.cmake index 34eba1b2459..fe335467c61 100644 --- a/config/cmake/scripts/HPC/qsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/qsub-HDF5options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/scripts/HPC/raybsub-HDF5options.cmake b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake index fa1ec4a20de..89ce4f06b5d 100644 --- a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/scripts/HPC/sbatch-HDF5options.cmake b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake index 3205a1cabee..ddf4858170a 100644 --- a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake +++ b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/userblockTest.cmake b/config/cmake/userblockTest.cmake index c02669de57b..e6a278c563b 100644 --- a/config/cmake/userblockTest.cmake +++ b/config/cmake/userblockTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/vfdTest.cmake b/config/cmake/vfdTest.cmake index c07d0058ecd..f5a4e3e9351 100644 --- a/config/cmake/vfdTest.cmake +++ b/config/cmake/vfdTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake/volTest.cmake b/config/cmake/volTest.cmake new file mode 100644 index 00000000000..27ef8a2e113 --- /dev/null +++ b/config/cmake/volTest.cmake @@ -0,0 +1,76 @@ +# +# 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. +# +# volTest.cmake executes a command and captures the output in a file. Command uses specified VOL. +# Exit status of command can also be compared. + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif () +if (NOT TEST_FOLDER) + message (FATAL_ERROR "Require TEST_FOLDER to be defined") +endif () +if (NOT TEST_VOL) + message (FATAL_ERROR "Require TEST_VOL to be defined") +endif () + +if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}") + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) +endif () + +if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) +endif () + +# if there is not an error reference file add the error output to the stdout file +#if (NOT TEST_ERRREF) +# set (ERROR_APPEND 1) +#endif () + +message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") + +set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") + +# run the test program, capture the stdout/stderr and the result var +execute_process ( + COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT}.out + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_OUT + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +# if the .err file exists and ERRROR_APPEND is enabled +if (ERROR_APPEND AND EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}.out "${TEST_STREAM}") +endif () + +# if the return value is !=${TEST_EXPECT} bail out +if (NOT TEST_RESULT EQUAL TEST_EXPECT) + if (NOT TEST_NOERRDISPLAY) + if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.out") + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.out TEST_STREAM) + message (STATUS "Output USING ${TEST_VOL}:\n${TEST_STREAM}") + endif () + endif () + message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}") +endif () + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +# everything went fine... +message (STATUS "Passed: The ${TEST_PROGRAM} program used vol ${TEST_VOL}") diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 0ddb6d08822..004adede5c7 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -22,21 +22,6 @@ include (CheckVariableExists) include (TestBigEndian) include (CheckStructHasMember) -#----------------------------------------------------------------------------- -# APPLE/Darwin setup -#----------------------------------------------------------------------------- -if (APPLE) - list (LENGTH CMAKE_OSX_ARCHITECTURES ARCH_LENGTH) - if (ARCH_LENGTH GREATER 1) - set (CMAKE_OSX_ARCHITECTURES "" CACHE STRING "" FORCE) - message (FATAL_ERROR "Building Universal Binaries on OS X is NOT supported by the HDF5 project. This is" - "due to technical reasons. The best approach would be build each architecture in separate directories" - "and use the 'lipo' tool to combine them into a single executable or library. The 'CMAKE_OSX_ARCHITECTURES'" - "variable has been set to a blank value which will build the default architecture for this system.") - endif () - set (${HDF_PREFIX}_AC_APPLE_UNIVERSAL_BUILD 0) -endif () - # Check for Darwin (not just Apple - we also want to catch OpenDarwin) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set (${HDF_PREFIX}_HAVE_DARWIN 1) @@ -69,6 +54,7 @@ if (MINGW) set (WINDOWS 1) # MinGW tries to imitate Windows set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") set (${HDF_PREFIX}_HAVE_WINSOCK2_H 1) + set (__USE_MINGW_ANSI_STDIO 1) endif () if (WIN32 AND NOT MINGW) @@ -223,7 +209,9 @@ macro (HDF_FUNCTION_TEST OTHER_TEST) ) endif () - #message (STATUS "Performing ${OTHER_TEST}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "Performing ${OTHER_TEST}") + endif () try_compile (${OTHER_TEST} ${CMAKE_BINARY_DIR} ${HDF_RESOURCES_EXT_DIR}/HDFTests.c @@ -233,9 +221,13 @@ macro (HDF_FUNCTION_TEST OTHER_TEST) ) if (${OTHER_TEST}) set (${HDF_PREFIX}_${OTHER_TEST} 1 CACHE INTERNAL "Other test ${FUNCTION}") - message (STATUS "Performing Other Test ${OTHER_TEST} - Success") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing Other Test ${OTHER_TEST} - Success") + endif () else () - message (STATUS "Performing Other Test ${OTHER_TEST} - Failed") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing Other Test ${OTHER_TEST} - Failed") + endif () set (${HDF_PREFIX}_${OTHER_TEST} "" CACHE INTERNAL "Other test ${FUNCTION}") file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Other Test ${OTHER_TEST} failed with the following output:\n" @@ -296,17 +288,23 @@ if (MINGW OR NOT WINDOWS) set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) set (LARGEFILE 1) set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) - message (STATUS "${msg}... yes") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... yes") + endif () else () set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n" ) endif () else () set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - message (STATUS "${msg}... no") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Test TEST_LFS_WORKS Compile failed\n" ) @@ -339,11 +337,15 @@ endif () macro (HDF_CHECK_TYPE_SIZE type var) set (aType ${type}) set (aVar ${var}) -# message (STATUS "Checking size of ${aType} and storing into ${aVar}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "Checking size of ${aType} and storing into ${aVar}") + endif () CHECK_TYPE_SIZE (${aType} ${aVar}) if (NOT ${aVar}) set (${aVar} 0 CACHE INTERNAL "SizeOf for ${aType}") -# message (STATUS "Size of ${aType} was NOT Found") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "Size of ${aType} was NOT Found") + endif () endif () endmacro () @@ -573,7 +575,9 @@ endif () #----------------------------------------------------------------------------- if (WINDOWS) if (NOT HDF_NO_IOEO_TEST) - message (STATUS "Checking for InitOnceExecuteOnce:") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Checking for InitOnceExecuteOnce:") + endif () if (NOT DEFINED ${HDF_PREFIX}_HAVE_IOEO) if (LARGEFILE) set (CMAKE_REQUIRED_DEFINITIONS @@ -602,7 +606,9 @@ if (WINDOWS) # if the return value was 0 then it worked if ("${HAVE_IOEO_EXITCODE}" EQUAL 0) set (${HDF_PREFIX}_HAVE_IOEO 1 CACHE INTERNAL "Test InitOnceExecuteOnce") - message (STATUS "Performing Test InitOnceExecuteOnce - Success") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing Test InitOnceExecuteOnce - Success") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test InitOnceExecuteOnce succeded with the following output:\n" "${OUTPUT}\n" @@ -614,7 +620,9 @@ if (WINDOWS) set (${HDF_PREFIX}_HAVE_IOEO "" CACHE INTERNAL "Test InitOnceExecuteOnce") endif () - message (STATUS "Performing Test InitOnceExecuteOnce - Failed") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing Test InitOnceExecuteOnce - Failed") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing InitOnceExecuteOnce Test failed with the following output:\n" "${OUTPUT}\n" @@ -637,7 +645,9 @@ endforeach () #----------------------------------------------------------------------------- if (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES "unknown") set (PRINT_LL_FOUND 0) - message (STATUS "Checking for appropriate format for 64 bit long:") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Checking for appropriate format for 64 bit long:") + endif () set (CURRENT_TEST_DEFINITIONS "-DPRINTF_LL_WIDTH") if (${HDF_PREFIX}_SIZEOF_LONG_LONG) set (CURRENT_TEST_DEFINITIONS "${CURRENT_TEST_DEFINITIONS} -DHAVE_LONG_LONG") @@ -654,7 +664,9 @@ if (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES " set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"${${HDF_PREFIX}_PRINTF_LL}\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll") set (PRINT_LL_FOUND 1) else () - message (STATUS "Width test failed with result: ${${HDF_PREFIX}_PRINTF_LL_TEST_RUN}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Width test failed with result: ${${HDF_PREFIX}_PRINTF_LL_TEST_RUN}") + endif () endif () else () file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log @@ -663,9 +675,13 @@ if (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES " endif () if (PRINT_LL_FOUND) - message (STATUS "Checking for appropriate format for 64 bit long: found ${${HDF_PREFIX}_PRINTF_LL_WIDTH}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Checking for appropriate format for 64 bit long: found ${${HDF_PREFIX}_PRINTF_LL_WIDTH}") + endif () else () - message (STATUS "Checking for appropriate format for 64 bit long: not found") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Checking for appropriate format for 64 bit long: not found") + endif () set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"unknown\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll" ) diff --git a/config/cmake_ext_mod/FindSZIP.cmake b/config/cmake_ext_mod/FindSZIP.cmake index 8f882b4a5fa..846a3d11e63 100644 --- a/config/cmake_ext_mod/FindSZIP.cmake +++ b/config/cmake_ext_mod/FindSZIP.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -118,7 +118,9 @@ if (NOT SZIP_FOUND) "SZip was not found. Make sure SZIP_LIBRARY and SZIP_INCLUDE_DIR are set or set the SZIP_INSTALL environment variable." ) if (NOT SZIP_FIND_QUIETLY) - message (STATUS "${SZIP_DIR_MESSAGE}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${SZIP_DIR_MESSAGE}") + endif () else () if (SZIP_FIND_REQUIRED) message (FATAL_ERROR "SZip was NOT found and is Required by this project") diff --git a/config/cmake_ext_mod/GetTimeOfDayTest.cpp b/config/cmake_ext_mod/GetTimeOfDayTest.cpp index 5fd7c04c6b8..b35efa5c39a 100644 --- a/config/cmake_ext_mod/GetTimeOfDayTest.cpp +++ b/config/cmake_ext_mod/GetTimeOfDayTest.cpp @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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/config/cmake_ext_mod/HDFCXXTests.cpp b/config/cmake_ext_mod/HDFCXXTests.cpp index 1b98092aa0c..08ccb34f672 100644 --- a/config/cmake_ext_mod/HDFCXXTests.cpp +++ b/config/cmake_ext_mod/HDFCXXTests.cpp @@ -5,67 +5,11 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifdef OLD_HEADER_FILENAME - -#include - -int main(void) { return 0; } - -#endif - - -#ifdef HDF_NO_NAMESPACE - -namespace HDF { -int fnord; -} - -int main(void) { - using namespace HDF; - fnord = 37; - return 0; -} - -#endif - -#ifdef HDF_NO_STD - -#include - -using namespace std; - -int main(void) { - string myString("testing namespace std"); - return 0; -} - -#endif - -#ifdef BOOL_NOTDEFINED -int main(void) { - bool flag; - return 0; -} - -#endif - -#ifdef NO_STATIC_CAST - -int main(void) { - float test_float; - int test_int; - test_float = 37.0; - test_int = static_cast (test_float); - return 0; -} - -#endif - #ifdef CXX_HAVE_OFFSETOF #include diff --git a/config/cmake_ext_mod/HDFLibMacros.cmake b/config/cmake_ext_mod/HDFLibMacros.cmake index fe633bf0505..821ac2d75cd 100644 --- a/config/cmake_ext_mod/HDFLibMacros.cmake +++ b/config/cmake_ext_mod/HDFLibMacros.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index 5740740f515..ae0ebca83d9 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -28,7 +28,9 @@ macro (SET_HDF_BUILD_TYPE) endif() endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message (STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Setting build type to 'RelWithDebInfo' as none was specified.") + endif() set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" @@ -126,10 +128,6 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) OUTPUT_NAME_MINSIZEREL ${LIB_RELEASE_NAME} OUTPUT_NAME_RELWITHDEBINFO ${LIB_RELEASE_NAME} ) - #get_property (target_name TARGET ${libtarget} PROPERTY OUTPUT_NAME) - #get_property (target_name_debug TARGET ${libtarget} PROPERTY OUTPUT_NAME_DEBUG) - #get_property (target_name_rwdi TARGET ${libtarget} PROPERTY OUTPUT_NAME_RELWITHDEBINFO) - #message (STATUS "${target_name} : ${target_name_debug} : ${target_name_rwdi}") if (${libtype} MATCHES "STATIC") if (WIN32) @@ -143,8 +141,8 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) endif () endif () - #----- Use MSVC Naming conventions for Shared Libraries - if (MINGW AND ${libtype} MATCHES "SHARED") + option (HDF5_MSVC_NAMING_CONVENTION "Use MSVC Naming conventions for Shared Libraries" OFF) + if (HDF5_MSVC_NAMING_CONVENTION AND MINGW AND ${libtype} MATCHES "SHARED") set_target_properties (${libtarget} PROPERTIES IMPORT_SUFFIX ".lib" IMPORT_PREFIX "" @@ -343,7 +341,7 @@ macro (HDF_DIR_PATHS package_prefix) set (${package_prefix}_INSTALL_INCLUDE_DIR include) endif () if (NOT ${package_prefix}_INSTALL_DATA_DIR) - if (NOT WIN32) + if (NOT MSVC) if (APPLE) if (${package_prefix}_BUILD_FRAMEWORKS) set (${package_prefix}_INSTALL_EXTRA_DIR ../SharedSupport) @@ -353,12 +351,13 @@ macro (HDF_DIR_PATHS package_prefix) set (${package_prefix}_INSTALL_FWRK_DIR ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) endif () set (${package_prefix}_INSTALL_DATA_DIR share) - set (${package_prefix}_INSTALL_CMAKE_DIR share/cmake) else () set (${package_prefix}_INSTALL_DATA_DIR ".") - set (${package_prefix}_INSTALL_CMAKE_DIR cmake) endif () endif () + if (NOT ${package_prefix}_INSTALL_CMAKE_DIR) + set (${package_prefix}_INSTALL_CMAKE_DIR share/cmake) + endif () # Always use full RPATH, i.e. don't skip the full RPATH for the build tree set (CMAKE_SKIP_BUILD_RPATH FALSE) @@ -427,23 +426,49 @@ macro (HDF_DIR_PATHS package_prefix) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) endif () endif () + + if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if (CMAKE_HOST_UNIX) + set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/HDF_Group/${HDF5_PACKAGE_NAME}/${HDF5_PACKAGE_VERSION}" + CACHE PATH "Install path prefix, prepended onto install directories." FORCE) + else () + GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) + set (CMAKE_INSTALL_PREFIX + "${CMAKE_GENERIC_PROGRAM_FILES}/HDF_Group/${HDF5_PACKAGE_NAME}/${HDF5_PACKAGE_VERSION}" + CACHE PATH "Install path prefix, prepended onto install directories." FORCE) + set (CMAKE_GENERIC_PROGRAM_FILES) + endif () + endif () + +#----------------------------------------------------------------------------- +# Setup pre-3.14 FetchContent +#----------------------------------------------------------------------------- + if(${CMAKE_VERSION} VERSION_LESS 3.14) + macro(FetchContent_MakeAvailable NAME) + FetchContent_GetProperties(${NAME}) + if(NOT ${NAME}_POPULATED) + FetchContent_Populate(${NAME}) + add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR}) + endif() + endmacro() + endif() endmacro () macro (ADD_H5_FLAGS h5_flag_var infile) file (STRINGS ${infile} TEST_FLAG_STREAM) - #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + #message (TRACE "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") list (LENGTH TEST_FLAG_STREAM len_flag) if (len_flag GREATER 0) math (EXPR _FP_LEN "${len_flag} - 1") foreach (line RANGE 0 ${_FP_LEN}) list (GET TEST_FLAG_STREAM ${line} str_flag) string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") - #message (STATUS "str_flag=${str_flag}") + #message (TRACE "str_flag=${str_flag}") if (str_flag) list (APPEND ${h5_flag_var} "${str_flag}") endif () endforeach () endif () - #message (STATUS "h5_flag_var=${${h5_flag_var}}") + #message (TRACE "h5_flag_var=${${h5_flag_var}}") endmacro () diff --git a/config/cmake_ext_mod/HDFTests.c b/config/cmake_ext_mod/HDFTests.c index 31a568aef5f..2d7e1b468b1 100644 --- a/config/cmake_ext_mod/HDFTests.c +++ b/config/cmake_ext_mod/HDFTests.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -178,7 +178,7 @@ int DebugReport(int reportType, char* message, int* returnValue) int main(void) { - char *llwidthArgs[] = { "I64", "l64", "l", "L", "q", "ll", NULL }; + char *llwidthArgs[] = { "I64", "l64", "ll", "l", "L", "q", NULL }; char *s = malloc(128); char **currentArg = NULL; LL_TYPE x = (LL_TYPE)1048576 * (LL_TYPE)1048576; diff --git a/config/cmake_ext_mod/HDFUseCXX.cmake b/config/cmake_ext_mod/HDFUseCXX.cmake index 8d981479912..580c4092bc8 100644 --- a/config/cmake_ext_mod/HDFUseCXX.cmake +++ b/config/cmake_ext_mod/HDFUseCXX.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -70,7 +70,9 @@ macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) ) endif () - #message (STATUS "Performing ${OTHER_TEST}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "Performing ${OTHER_TEST}") + endif () TRY_COMPILE (${OTHER_TEST} ${CMAKE_BINARY_DIR} ${HDF_RESOURCES_EXT_DIR}/HDFCXXTests.cpp @@ -80,9 +82,13 @@ macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) ) if (${OTHER_TEST} EQUAL 0) set (${OTHER_TEST} 1 CACHE INTERNAL "CXX test ${FUNCTION}") - message (STATUS "Performing CXX Test ${OTHER_TEST} - Success") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Success") + endif () else () - message (STATUS "Performing CXX Test ${OTHER_TEST} - Failed") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Performing CXX Test ${OTHER_TEST} - Failed") + endif () set (${OTHER_TEST} "" CACHE INTERNAL "CXX test ${FUNCTION}") file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Performing CXX Test ${OTHER_TEST} failed with the following output:\n" @@ -97,11 +103,6 @@ endmacro () #----------------------------------------------------------------------------- if (CMAKE_CXX_COMPILER_LOADED) foreach (cxx_test - OLD_HEADER_FILENAME - HDF_NO_NAMESPACE - HDF_NO_STD - BOOL_NOTDEFINED - NO_STATIC_CAST CXX_HAVE_OFFSETOF ) HDF_CXX_FUNCTION_TEST (${cxx_test}) diff --git a/config/cmake_ext_mod/HDFUseFortran.cmake b/config/cmake_ext_mod/HDFUseFortran.cmake index 0a6a0926ddb..9cbcd76fec6 100644 --- a/config/cmake_ext_mod/HDFUseFortran.cmake +++ b/config/cmake_ext_mod/HDFUseFortran.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -135,7 +135,9 @@ else () # so this one is used for a sizeof test. #----------------------------------------------------------------------------- macro (CHECK_FORTRAN_FEATURE FUNCTION CODE VARIABLE) - message (STATUS "Testing Fortran ${FUNCTION}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing Fortran ${FUNCTION}") + endif () if (HDF5_REQUIRED_LIBRARIES) set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") @@ -153,13 +155,17 @@ else () OUTPUT_VARIABLE OUTPUT ) - # message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") - # message (STATUS "Test result ${OUTPUT}") - # message (STATUS "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + # if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + # message (TRACE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + # message (TRACE "Test result ${OUTPUT}") + # message (TRACE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + # endif () if (${RESULT_VAR}) set (${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") - message (STATUS "Testing Fortran ${FUNCTION} - OK") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Testing Fortran ${FUNCTION} - OK") + endif () file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n" diff --git a/config/cmake_ext_mod/grepTest.cmake b/config/cmake_ext_mod/grepTest.cmake index b011ae80a98..631fca6fdfc 100644 --- a/config/cmake_ext_mod/grepTest.cmake +++ b/config/cmake_ext_mod/grepTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -16,18 +16,12 @@ if (NOT TEST_PROGRAM) message (FATAL_ERROR "Require TEST_PROGRAM to be defined") endif () -#if (NOT TEST_ARGS) -# message (STATUS "Require TEST_ARGS to be defined") -#endif () if (NOT TEST_FOLDER) message (FATAL_ERROR "Require TEST_FOLDER to be defined") endif () if (NOT TEST_OUTPUT) message (FATAL_ERROR "Require TEST_OUTPUT to be defined") endif () -#if (NOT TEST_EXPECT) -# message (STATUS "Require TEST_EXPECT to be defined") -#endif () if (NOT TEST_FILTER) message (STATUS "Optional TEST_FILTER to be defined") endif () @@ -46,7 +40,7 @@ endif () message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) - if (WIN32 OR MINGW) + if (WIN32) set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -55,7 +49,9 @@ endif () if (TEST_ENV_VAR) set (ENV{${TEST_ENV_VAR}} "${TEST_ENV_VALUE}") - #message (STATUS "ENV:${TEST_ENV_VAR}=$ENV{${TEST_ENV_VAR}}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (TRACE "ENV:${TEST_ENV_VAR}=$ENV{${TEST_ENV_VAR}}") + endif () endif () # run the test program, capture the stdout/stderr and the result var @@ -105,7 +101,7 @@ if (TEST_ERRREF) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) list (LENGTH TEST_STREAM test_len) if (test_len GREATER 0) - if (WIN32 OR MINGW) + if (WIN32) configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp") file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 2b8b6b09539..f552dcdf968 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -38,7 +38,7 @@ endif () message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) - if (WIN32 OR MINGW) + if (WIN32) set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}") else () set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") @@ -212,7 +212,7 @@ if (NOT TEST_SKIP_COMPARE) file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) list (LENGTH TEST_STREAM test_len) if (test_len GREATER 0) - if (WIN32 OR MINGW) + if (WIN32) configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp") file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) @@ -283,7 +283,7 @@ if (NOT TEST_SKIP_COMPARE) file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) list (LENGTH TEST_STREAM test_len) if (test_len GREATER 0) - if (WIN32 OR MINGW) + if (WIN32) configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) if (EXISTS "${TEST_FOLDER}/${TEST_ERRREF}.tmp") file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) diff --git a/config/gnu-warnings/4.8 b/config/gnu-warnings/4.8 index 05f4d92fa8f..fa678ff6ecc 100644 --- a/config/gnu-warnings/4.8 +++ b/config/gnu-warnings/4.8 @@ -9,6 +9,7 @@ # warning flag added for GCC >= 4.5 -Wstrict-overflow=5 + # This warning can only be truly addressed using the gcc extension of # using D to indicate doubles (e.g., 1.23D). -Wno-unsuffixed-float-constants diff --git a/config/gnu-warnings/7 b/config/gnu-warnings/7 index 266f5c17b82..9d5b44d18b8 100644 --- a/config/gnu-warnings/7 +++ b/config/gnu-warnings/7 @@ -3,5 +3,4 @@ -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 --Wimplicit-fallthrough=5 -Wrestrict diff --git a/config/gnu-warnings/9.3 b/config/gnu-warnings/9.3 new file mode 100644 index 00000000000..f37fdd69b99 --- /dev/null +++ b/config/gnu-warnings/9.3 @@ -0,0 +1 @@ +-Wc11-c2x-compat diff --git a/config/gnu-warnings/cxx-4.8 b/config/gnu-warnings/cxx-4.8 new file mode 100644 index 00000000000..744ebdc611c --- /dev/null +++ b/config/gnu-warnings/cxx-4.8 @@ -0,0 +1,26 @@ +# warning flags added for GCC >= 4.3 +-Wlarger-than=2560 +-Wlogical-op + +# warning flags added for GCC >= 4.4 +-Wframe-larger-than=16384 +-Wpacked-bitfield-compat +-Wsync-nand + +# warning flag added for GCC >= 4.5 +-Wstrict-overflow=5 + +# warning flags added for GCC >= 4.6 +-Wdouble-promotion +-Wtrampolines + +# warning flag added for GCC >= 4.7 +# +# -Wstack-usage=8192 warnings need to be swept up on a branch so +# that we can stop burdening the whole development team. +# +-Wstack-usage=8192 + +# warning flag added for GCC >= 4.8 +-Wmaybe-uninitialized + diff --git a/config/gnu-warnings/cxx-4.9 b/config/gnu-warnings/cxx-4.9 index 046d6dbdc08..30553bdab79 100644 --- a/config/gnu-warnings/cxx-4.9 +++ b/config/gnu-warnings/cxx-4.9 @@ -1 +1,2 @@ +-Wdate-time -Wopenmp-simd diff --git a/config/gnu-warnings/cxx-9 b/config/gnu-warnings/cxx-9 new file mode 100644 index 00000000000..8f843a46c23 --- /dev/null +++ b/config/gnu-warnings/cxx-9 @@ -0,0 +1,4 @@ +-Wattribute-alias=2 +-Wmissing-profile +# Turn this on when the C++ wrappers obey the Rule of Five +-Wno-deprecated-copy diff --git a/config/gnu-warnings/cxx-noerror-5 b/config/gnu-warnings/cxx-noerror-5 new file mode 100644 index 00000000000..7bce3e8ba72 --- /dev/null +++ b/config/gnu-warnings/cxx-noerror-5 @@ -0,0 +1,11 @@ +# +# In GCC 4.4.7, the compiler gripes about shadowed global +# declarations when a local variable uses the name of a +# function that's in a system header file. For some reason, +# later versions of GCC (e.g., 5.2.0) don't complain about +# the shadowed globals. Maybe later versions are less fussy? +# Anyway, the shadowing seems to be harmless, and GCC 4.4.7 +# is not a supported compiler, so let us promote shadowed globals +# warnings to errors only for GCC 5 and later. +# +-Wshadow diff --git a/config/gnu-warnings/cxx-noerror-general b/config/gnu-warnings/cxx-noerror-general new file mode 100644 index 00000000000..8cc1d949bad --- /dev/null +++ b/config/gnu-warnings/cxx-noerror-general @@ -0,0 +1,32 @@ +# +# HDF5 code should not trigger the following warnings under any +# circumstances, so ask the compiler to treat them as errors: +# +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/tcompound.cpp +# -Werror=cast-align +-Wcast-align +# NOTE: c++/src files are not compatible with these warnings as errors +# c++/src/H5Object.cpp +# -Werror=missing-declarations +-Wmissing-declarations +-Wpacked +-Wredundant-decls +-Wswitch +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/tattr.cpp +# -Werror=unused-but-set-variable +-Wunused-but-set-variable +-Wunused-function +-Wunused-variable +# NOTE: c++/src files are not compatible with these warnings as errors +# c++/src/H5Object.cpp,c++/src/H5StrType.cpp,c++/src/H5PredType.cpp +# -Werror=unused-parameter +-Wunused-parameter +# +# Other files not compatible +# NOTE: c++/test files are not compatible with these warnings as errors +# c++/test/titerate.cpp,c++/test/tarray.cpp +# -Werror=missing-declarations +# c++/test/titerate.cpp,c++/test/tarray.cpp,c++/test/tlinks.cpp,c++/test/ttypes.cpp,c++/test/dsets.cpp +# -Werror=unused-parameter diff --git a/config/gnu-warnings/developer-10 b/config/gnu-warnings/developer-10 new file mode 100644 index 00000000000..022c97f9666 --- /dev/null +++ b/config/gnu-warnings/developer-10 @@ -0,0 +1,2 @@ +# New warning +-Warith-conversion diff --git a/config/gnu-warnings/error-general b/config/gnu-warnings/error-general index f0e61f88bbf..8405c401103 100644 --- a/config/gnu-warnings/error-general +++ b/config/gnu-warnings/error-general @@ -3,7 +3,6 @@ # circumstances, so ask the compiler to treat them as errors: # -Werror=bad-function-cast --Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=missing-prototypes @@ -59,7 +58,7 @@ # jni/h5util.c # -Werror=format(-overflow) # --Wformat +-Werror=format # # #Examples and tests do not use the same set of extensive warning flags as libraries diff --git a/config/gnu-warnings/noerror-5 b/config/gnu-warnings/noerror-5 new file mode 100644 index 00000000000..a7d40dd841c --- /dev/null +++ b/config/gnu-warnings/noerror-5 @@ -0,0 +1,12 @@ +-Wincompatible-pointer-types +# +# In GCC 4.4.7, the compiler gripes about shadowed global +# declarations when a local variable uses the name of a +# function that's in a system header file. For some reason, +# later versions of GCC (e.g., 5.2.0) don't complain about +# the shadowed globals. Maybe later versions are less fussy? +# Anyway, the shadowing seems to be harmless, and GCC 4.4.7 +# is not a supported compiler, so let us promote shadowed globals +# warnings to errors only for GCC 5 and later. +# +-Wshadow diff --git a/config/gnu-warnings/noerror-8 b/config/gnu-warnings/noerror-8 new file mode 100644 index 00000000000..2f54a4d24eb --- /dev/null +++ b/config/gnu-warnings/noerror-8 @@ -0,0 +1,25 @@ +# NOTE: src/ files are not compatible with these warnings as errors +# src/H5Dchunk.c +# -Werror=cast-function-type +-Wcast-function-type +# +# For GCC 8, promote maybe-initialized warnings to an error. GCC 8 +# reports 0 maybe-uninitialized warnings where earlier versions +# make many false reports. GCC 8 seems to analyze calls to static +# in order to detect initializations that occur there. It's possible +# that GCC 8 only performs that analysis at -O3, though. +# +# +# NOTE: File Driver files are not compatible with these warnings as errors +# H5FDlog.c, +# -Werror=maybe-uninitialized +-Wmaybe-uninitialized +# NOTE: src/ files are not compatible with these warnings as errors +# src/H5Shyper.c,src/H5SL.c,src/H5Shyper.c +# -Werror=maybe-uninitialized +# NOTE: Test files are not compatible with these warnings as errors +# test/cache_common.c, +# -Werror=maybe-uninitialized +# NOTE: hl/src/ files are not compatible with these warnings as errors +# hl/src/H5DS.c, +# -Werror=maybe-uninitialized diff --git a/config/gnu-warnings/noerror-general b/config/gnu-warnings/noerror-general new file mode 100644 index 00000000000..f49d89a3a5a --- /dev/null +++ b/config/gnu-warnings/noerror-general @@ -0,0 +1,92 @@ +# +# These warnings will be treated as errors, using the error-general file, +# when HDF5_ENABLE_WARNINGS_AS_ERRORS is set to true for CMake or +# the --enable-warnings-as-errors option is specified for configure. +# Otherwise this file will be used to treat them as warnings. +# +-Wbad-function-cast +-Wimplicit-function-declaration +-Wmissing-declarations +-Wmissing-prototypes +-Wnested-externs +-Wold-style-definition +-Wpacked +-Wpointer-sign +-Wpointer-to-int-cast +-Wredundant-decls +-Wstrict-prototypes +-Wswitch +# +#-Werror=discarded-qualifiers +# +# +# NOTE: File Driver files are not compatible with these warnings as errors +# H5FDdirect.c,H5FDmpio.c,H5FDros3.c, +# -Werror=unused-function +# +-Wunused-function +# +# H5FDdrvr_module.h +# -Werror=unused-variable +# +-Wunused-variable +# +# H5VLpassthru.c +# -Werror=unused-parameter +# +-Wunused-parameter +# +# +# +# NOTE: Tools files are not compatible with these warnings as errors +# lib/h5tools.c +# -Werror=cast-align +# +-Wcast-align +# +# lib/h5diff_array.c +# -Werror=unused-but-set-variable +# +-Wunused-but-set-variable +# +# lib/h5tools_utils.c +# -Werror=unused-parameter +# +# +# NOTE: JNI files are not compatible with these warnings as errors +# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c +# jni/h5sImp.c,jni/h5tImp.c +# -Werror=cast-align +# jni/h5util.c +# -Werror=format(-overflow) +# +-Wformat +# +# +#Examples and tests do not use the same set of extensive warning flags as libraries +# Here is a list of tests and examples that have issues with the stricter warnings as error +# +# NOTE: Test files are not compatible with these warnings as errors +# thread_id.c, +# -Werror=unused-function +# dsets.c +# -Werror=unused-parameter +# external.c,perform/sio_engine.c +# -Werror=format(-truncation) +# +# +# NOTE: Examples files are not compatible with these warnings as errors +# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c +# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c +# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c +# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c +# h5_reference_deprec.c +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=strict-prototypes +# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c +# -Werror=old-style-definition +# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c, +# -Werror=unused-variable +# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c +# -Werror=unused-parameter + diff --git a/config/intel-warnings/15 b/config/intel-warnings/15 new file mode 100644 index 00000000000..6746f975736 --- /dev/null +++ b/config/intel-warnings/15 @@ -0,0 +1,19 @@ +-Wcomment +-Wdeprecated +-Wextra-tokens +-Wformat +-Wformat-security +-Wmain +-Wmissing-declarations +-Wmissing-prototypes +-Wp64 +-Wpointer-arith +-Wreturn-type +-Wshadow +-Wstrict-prototypes +-Wtrigraphs +-Wuninitialized +-Wunknown-pragmas +-Wunused-function +-Wunused-variable +-Wwrite-strings diff --git a/config/intel-warnings/18 b/config/intel-warnings/18 new file mode 100644 index 00000000000..565b47a4d85 --- /dev/null +++ b/config/intel-warnings/18 @@ -0,0 +1,8 @@ +-Wextra-tokens +-Wformat +-Wformat-security +-Wic-pointer +-Wshadow +-Wsign-compare +-Wtrigraphs +-Wwrite-strings diff --git a/config/intel-warnings/developer-general b/config/intel-warnings/developer-general new file mode 100644 index 00000000000..fae56f0acc8 --- /dev/null +++ b/config/intel-warnings/developer-general @@ -0,0 +1,4 @@ +-Winline +-Wreorder +-Wport +-Wstrict-aliasing diff --git a/config/intel-warnings/general b/config/intel-warnings/general index d0b2e25e997..bd866b6966d 100644 --- a/config/intel-warnings/general +++ b/config/intel-warnings/general @@ -1,2 +1 @@ -Wall --Wcheck \ No newline at end of file diff --git a/config/intel-warnings/general-19 b/config/intel-warnings/general-19 new file mode 100644 index 00000000000..e35af30213c --- /dev/null +++ b/config/intel-warnings/general-19 @@ -0,0 +1,2 @@ +# this is only available before oneapi versions +-Wcheck diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt index 70c458dc2f5..083c60eb39e 100644 --- a/hl/CMakeLists.txt +++ b/hl/CMakeLists.txt @@ -18,8 +18,6 @@ if (HDF5_BUILD_EXAMPLES) endif () #-- Build the Unit testing if requested -if (NOT HDF5_EXTERNALLY_CONFIGURED) - if (BUILD_TESTING AND HDF5_TEST_SERIAL) - add_subdirectory (test) - endif () +if (BUILD_TESTING AND HDF5_TEST_SERIAL) + add_subdirectory (test) endif () diff --git a/hl/COPYING b/hl/COPYING deleted file mode 100644 index 6497ace3da0..00000000000 --- a/hl/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/hl/c++/COPYING b/hl/c++/COPYING deleted file mode 100644 index 6497ace3da0..00000000000 --- a/hl/c++/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index fbabc863bcf..c516df15e7e 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -9,9 +9,9 @@ set (HDF5_HL_CPP_SOURCES ${HDF5_HL_CPP_SRC_SOURCE_DIR}/H5PacketTable.cpp) set (HDF5_HL_CPP_HDRS ${HDF5_HL_CPP_SRC_SOURCE_DIR}/H5PacketTable.h) if (NOT ONLY_SHARED_LIBS) - add_library (${HDF5_HL_CPP_LIB_TARGET} STATIC ${HDF5_HL_CPP_SOURCES}) + add_library (${HDF5_HL_CPP_LIB_TARGET} STATIC ${HDF5_HL_CPP_SOURCES} ${HDF5_HL_CPP_HDRS}) target_include_directories (${HDF5_HL_CPP_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_HL_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -26,7 +26,7 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_CPP_LIBSH_TARGET} SHARED ${HDF5_HL_CPP_SOURCES}) target_include_directories (${HDF5_HL_CPP_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_HL_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") @@ -39,6 +39,17 @@ if (BUILD_SHARED_LIBS) set (install_targets ${install_targets} ${HDF5_HL_CPP_LIBSH_TARGET}) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_HL_CPP_SRC_FORMAT ${HDF5_HL_CPP_LIB_TARGET}) + else () + clang_format (HDF5_HL_CPP_SRC_FORMAT ${HDF5_HL_CPP_LIBSH_TARGET}) + endif () +endif () + #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- @@ -94,22 +105,26 @@ if (BUILD_SHARED_LIBS) set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_HL_CPP_LIB_CORENAME}") endif () -set (_PKG_CONFIG_REQUIRES "${HDF5_HL_LIB_CORENAME}") -set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_HL_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES "${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.pc.in - ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}.pc @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}.pc DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig COMPONENT hlcpplibraries ) if (NOT WIN32 AND NOT MINGW) - set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND) + set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER}) + else () + set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + endif () configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in ${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++ @@ -122,4 +137,3 @@ if (NOT WIN32 AND NOT MINGW) COMPONENT hlcpplibraries ) endif () - diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp index 544df0bcf97..0f47b0d7aea 100644 --- a/hl/c++/src/H5PacketTable.cpp +++ b/hl/c++/src/H5PacketTable.cpp @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,257 +24,278 @@ #include "H5PacketTable.h" - /********************************/ - /* PacketTable superclass */ - /********************************/ - - /* "Open" Constructor - * Opens an existing packet table, which can contain either fixed-length or - * variable-length packets. - */ - PacketTable::PacketTable(hid_t fileID, const char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable::PacketTable(hid_t fileID, char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* Destructor - * Cleans up the packet table - */ - PacketTable::~PacketTable() - { - H5PTclose( table_id); - } - - /* IsValid - * Returns true if this packet table is valid, false otherwise. - * Use this after the constructor to ensure HDF did not have - * any trouble making or opening the packet table. - */ - bool PacketTable::IsValid() - { - if (H5PTis_valid(table_id) == 0) - return true; - else - return false; - } - - /* IsVariableLength - * Return 1 if this packet table uses variable-length datatype, - * and 0, otherwise. Returns -1 if the table is invalid (not open). - */ - int PacketTable::IsVariableLength() - { - return H5PTis_varlen(table_id); - } - - /* ResetIndex - * Sets the index to point to the first packet in the packet table - */ - void PacketTable::ResetIndex() - { - H5PTcreate_index(table_id); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - int PacketTable::SetIndex(hsize_t index) - { - return H5PTset_index(table_id, index); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - hsize_t PacketTable::GetIndex(int &error) - { - hsize_t index; - - error = H5PTget_index(table_id, &index); - if(error < 0) - return 0; - else - return index; - } - - /* GetPacketCount - * Returns the number of packets in the packet table. Error - * is set to 0 on success. On failure, returns 0 and - * error is set to negative. - */ - hsize_t PacketTable::GetPacketCount(int& error) - { - hsize_t npackets; - - error = H5PTget_num_packets(table_id, &npackets); - return npackets; - } - - /* GetTableId - * Returns the identifier of the packet table - */ - hid_t PacketTable::GetTableId() - { - return table_id; - } - - /* GetDatatype - * Returns the datatype identifier used by the packet table, on success, - * or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDatatype() - { - return H5PTget_type(table_id); - } - - /* GetDataset - * Returns the dataset identifier associated with the packet table, on - * success, or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDataset() - { - return H5PTget_dataset(table_id); - } - - /* FreeBuff - * Frees the buffers created when variable-length packets are read. - * Takes the number of hvl_t structs to be freed and a pointer to their - * location in memory. - * Returns 0 on success, negative on error. - */ - int PacketTable::FreeBuff(size_t numStructs, hvl_t * buffer) - { - return H5PTfree_vlen_buff( table_id, numStructs, buffer); - } - - - /********************************/ - /* Fixed-Length Packet Table */ - /********************************/ - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize, hid_t plistID) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - deprecated - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - * Note: The above constructor has a better prototype, which allows default - * values to be used. This constructor was only released in 1.10.0. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char* name, hid_t dtypeID, hsize_t chunkSize) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the name of - * the packet table, the ID of the datatype of the set, and the size - * of a memory chunk used in chunking. - * Note: this overload will be deprecated in favor of the constructor above. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression) - { - table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); - } - - /* "Open" Constructor - * Opens an existing fixed-length packet table. - * Fails if the packet table specified is variable-length. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : PacketTable(fileID, name) {} - - /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name) {} - - /* AppendPacket - * Adds a single packet to the packet table. Takes a pointer - * to the location of the data in memory. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::AppendPacket(void * data) - { - return H5PTappend(table_id, 1, data); - } - - /* AppendPackets (multiple packets) - * Adds multiple packets to the packet table. Takes the number of packets - * to be added and a pointer to their location in memory. - * Returns 0 on success, -1 on failure. - */ - int FL_PacketTable::AppendPackets(size_t numPackets, void * data) - { - return H5PTappend(table_id, numPackets, data); - } - - /* GetPacket (indexed) - * Gets a single packet from the packet table. Takes the index - * of the packet (with 0 being the first packet) and a pointer - * to memory where the data should be stored. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::GetPacket(hsize_t index, void * data) - { - return H5PTread_packets(table_id, index, 1, data); - } - - /* GetPackets (multiple packets) - * Gets multiple packets at once, all packets between - * startIndex and endIndex inclusive. Also takes a pointer to - * the memory where these packets should be stored. - * Returns 0 on success, negative on failure. - */ - int FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void * data) - { - // Make sure the range of indexes is valid - if (startIndex > endIndex) - return -1; - - return H5PTread_packets(table_id, startIndex, (size_t)(endIndex-startIndex+1), data); - } - - /* GetNextPacket (single packet) - * Gets the next packet in the packet table. Takes a pointer to - * memory where the packet should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced to the next packet on failure. - */ - int FL_PacketTable::GetNextPacket(void * data) - { - return H5PTget_next(table_id, 1, data); - } - - /* GetNextPackets (multiple packets) - * Gets the next numPackets packets in the packet table. Takes a - * pointer to memory where these packets should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced on failure. - */ - int FL_PacketTable::GetNextPackets(size_t numPackets, void * data) - { - return H5PTget_next(table_id, numPackets, data); - } +/********************************/ +/* PacketTable superclass */ +/********************************/ + +/* "Open" Constructor + * Opens an existing packet table, which can contain either fixed-length or + * variable-length packets. + */ +PacketTable::PacketTable(hid_t fileID, const char *name) +{ + table_id = H5PTopen(fileID, name); +} + +/* "Open" Constructor - will be deprecated because of char* name */ +PacketTable::PacketTable(hid_t fileID, char *name) +{ + table_id = H5PTopen(fileID, name); +} + +/* Destructor + * Cleans up the packet table + */ +PacketTable::~PacketTable() +{ + H5PTclose(table_id); +} + +/* IsValid + * Returns true if this packet table is valid, false otherwise. + * Use this after the constructor to ensure HDF did not have + * any trouble making or opening the packet table. + */ +bool +PacketTable::IsValid() +{ + if (H5PTis_valid(table_id) == 0) + return true; + else + return false; +} + +/* IsVariableLength + * Return 1 if this packet table uses variable-length datatype, + * and 0, otherwise. Returns -1 if the table is invalid (not open). + */ +int +PacketTable::IsVariableLength() +{ + return H5PTis_varlen(table_id); +} + +/* ResetIndex + * Sets the index to point to the first packet in the packet table + */ +void +PacketTable::ResetIndex() +{ + H5PTcreate_index(table_id); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +int +PacketTable::SetIndex(hsize_t index) +{ + return H5PTset_index(table_id, index); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +hsize_t +PacketTable::GetIndex(int &error) +{ + hsize_t index; + + error = H5PTget_index(table_id, &index); + if (error < 0) + return 0; + else + return index; +} + +/* GetPacketCount + * Returns the number of packets in the packet table. Error + * is set to 0 on success. On failure, returns 0 and + * error is set to negative. + */ +hsize_t +PacketTable::GetPacketCount(int &error) +{ + hsize_t npackets; + + error = H5PTget_num_packets(table_id, &npackets); + return npackets; +} + +/* GetTableId + * Returns the identifier of the packet table + */ +hid_t +PacketTable::GetTableId() +{ + return table_id; +} + +/* GetDatatype + * Returns the datatype identifier used by the packet table, on success, + * or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDatatype() +{ + return H5PTget_type(table_id); +} + +/* GetDataset + * Returns the dataset identifier associated with the packet table, on + * success, or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDataset() +{ + return H5PTget_dataset(table_id); +} + +/* FreeBuff + * Frees the buffers created when variable-length packets are read. + * Takes the number of hvl_t structs to be freed and a pointer to their + * location in memory. + * Returns 0 on success, negative on error. + */ +int +PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) +{ + return H5PTfree_vlen_buff(table_id, numStructs, buffer); +} + +/********************************/ +/* Fixed-Length Packet Table */ +/********************************/ + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize, + hid_t plistID) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor - deprecated + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + * Note: The above constructor has a better prototype, which allows default + * values to be used. This constructor was only released in 1.10.0. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char *name, hid_t dtypeID, + hsize_t chunkSize) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the name of + * the packet table, the ID of the datatype of the set, and the size + * of a memory chunk used in chunking. + * Note: this overload will be deprecated in favor of the constructor above. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression) +{ + table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); +} + +/* "Open" Constructor + * Opens an existing fixed-length packet table. + * Fails if the packet table specified is variable-length. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name) : PacketTable(fileID, name) +{ +} + +/* "Open" Constructor - will be deprecated because of char* name */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name) : PacketTable(fileID, name) +{ +} + +/* AppendPacket + * Adds a single packet to the packet table. Takes a pointer + * to the location of the data in memory. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::AppendPacket(void *data) +{ + return H5PTappend(table_id, 1, data); +} + +/* AppendPackets (multiple packets) + * Adds multiple packets to the packet table. Takes the number of packets + * to be added and a pointer to their location in memory. + * Returns 0 on success, -1 on failure. + */ +int +FL_PacketTable::AppendPackets(size_t numPackets, void *data) +{ + return H5PTappend(table_id, numPackets, data); +} + +/* GetPacket (indexed) + * Gets a single packet from the packet table. Takes the index + * of the packet (with 0 being the first packet) and a pointer + * to memory where the data should be stored. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::GetPacket(hsize_t index, void *data) +{ + return H5PTread_packets(table_id, index, 1, data); +} + +/* GetPackets (multiple packets) + * Gets multiple packets at once, all packets between + * startIndex and endIndex inclusive. Also takes a pointer to + * the memory where these packets should be stored. + * Returns 0 on success, negative on failure. + */ +int +FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data) +{ + // Make sure the range of indexes is valid + if (startIndex > endIndex) + return -1; + + return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data); +} + +/* GetNextPacket (single packet) + * Gets the next packet in the packet table. Takes a pointer to + * memory where the packet should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced to the next packet on failure. + */ +int +FL_PacketTable::GetNextPacket(void *data) +{ + return H5PTget_next(table_id, 1, data); +} + +/* GetNextPackets (multiple packets) + * Gets the next numPackets packets in the packet table. Takes a + * pointer to memory where these packets should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced on failure. + */ +int +FL_PacketTable::GetNextPackets(size_t numPackets, void *data) +{ + return H5PTget_next(table_id, numPackets, data); +} /* Removed "ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index 26659844b7a..acd0ccfb68d 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,22 +28,24 @@ #include "H5PTpublic.h" #include "H5api_adpt.h" -class H5_HLCPPDLL PacketTable -{ -public: +class H5_HLCPPDLL PacketTable { + public: /* Null constructor * Sets table_id to "invalid" */ - PacketTable() {table_id = H5I_BADID;} + PacketTable() + { + table_id = H5I_INVALID_HID; + } /* "Open" Constructor * Opens an existing packet table, which can contain either fixed-length or * variable-length packets. */ - PacketTable(hid_t fileID, const char* name); + PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable(hid_t fileID, char* name); + PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table @@ -80,16 +82,17 @@ class H5_HLCPPDLL PacketTable * Returns the position of the current packet. * On failure, returns 0 and error is set to negative. */ - hsize_t GetIndex(int& error); + hsize_t GetIndex(int &error); /* GetPacketCount * Returns the number of packets in the packet table. Error * is set to 0 on success. On failure, returns 0 and * error is set to negative. */ - hsize_t GetPacketCount(int& error); + hsize_t GetPacketCount(int &error); - hsize_t GetPacketCount() + hsize_t + GetPacketCount() { int ignoreError; return GetPacketCount(ignoreError); @@ -122,22 +125,22 @@ class H5_HLCPPDLL PacketTable * location in memory. * Returns 0 on success, negative on error. */ - int FreeBuff(size_t numStructs, hvl_t * buffer); + int FreeBuff(size_t numStructs, hvl_t *buffer); -protected: + protected: hid_t table_id; }; -class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable -{ -public: +class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable { + public: /* Constructor * Creates a packet table to store either fixed- or variable-length packets. * Takes the ID of the file the packet table will be created in, the ID of * the property list to specify compression, the name of the packet table, * the ID of the datatype, and the size of a memory chunk used in chunking. */ - FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize = 0, hid_t plistID = H5P_DEFAULT); + FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize = 0, + hid_t plistID = H5P_DEFAULT); /* Constructors - deprecated * Creates a packet table in which to store fixed length packets. @@ -148,36 +151,38 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable * Note: these overloaded constructors will be deprecated in favor of the * constructor above. */ - FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize); - FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); + FL_PacketTable(hid_t fileID, hid_t plist_id, const char *name, hid_t dtypeID, hsize_t chunkSize); + FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); /* "Open" Constructor * Opens an existing fixed-length packet table. * Fails if the packet table specified is variable-length. */ - FL_PacketTable(hid_t fileID, const char* name); + FL_PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable(hid_t fileID, char* name); + FL_PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table */ - virtual ~FL_PacketTable() {}; + virtual ~FL_PacketTable() + { + } /* AppendPacket * Adds a single packet to the packet table. Takes a pointer * to the location of the data in memory. * Returns 0 on success, negative on failure */ - int AppendPacket(void * data); + int AppendPacket(void *data); /* AppendPackets (multiple packets) * Adds multiple packets to the packet table. Takes the number of packets * to be added and a pointer to their location in memory. * Returns 0 on success, -1 on failure. */ - int AppendPackets(size_t numPackets, void * data); + int AppendPackets(size_t numPackets, void *data); /* GetPacket (indexed) * Gets a single packet from the packet table. Takes the index @@ -185,7 +190,7 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable * to memory where the data should be stored. * Returns 0 on success, negative on failure */ - int GetPacket(hsize_t index, void * data); + int GetPacket(hsize_t index, void *data); /* GetPackets (multiple packets) * Gets multiple packets at once, all packets between @@ -193,7 +198,7 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable * the memory where these packets should be stored. * Returns 0 on success, negative on failure. */ - int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data); + int GetPackets(hsize_t startIndex, hsize_t endIndex, void *data); /* GetNextPacket (single packet) * Gets the next packet in the packet table. Takes a pointer to @@ -201,7 +206,7 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable * Returns 0 on success, negative on failure. Index * is not advanced to the next packet on failure. */ - int GetNextPacket(void * data); + int GetNextPacket(void *data); /* GetNextPackets (multiple packets) * Gets the next numPackets packets in the packet table. Takes a @@ -209,7 +214,7 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable * Returns 0 on success, negative on failure. Index * is not advanced on failure. */ - int GetNextPackets(size_t numPackets, void * data); + int GetNextPackets(size_t numPackets, void *data); }; /* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index c4ddf199049..7678de84001 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -30,12 +30,20 @@ set (HL_HEADERS set (HL_PRIVATE_HEADERS ${HDF5_HL_SRC_SOURCE_DIR}/H5LTparse.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5DSprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5IMprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5PTprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5HLprivate2.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5LTprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5PTprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5TBprivate.h + ${HDF5_HL_SRC_SOURCE_DIR}/H5LDprivate.h ) if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_HL_LIB_TARGET} STATIC ${HL_SOURCES} ${HL_HEADERS} ${HL_PRIVATE_HEADERS}) target_include_directories (${HDF5_HL_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_HL_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") @@ -50,7 +58,7 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_LIBSH_TARGET} SHARED ${HL_SOURCES} ${HL_HEADERS} ${HL_PRIVATE_HEADERS}) target_include_directories (${HDF5_HL_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_HL_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") @@ -63,6 +71,17 @@ if (BUILD_SHARED_LIBS) set (install_targets ${install_targets} ${HDF5_HL_LIBSH_TARGET}) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_HL_SRC_FORMAT ${HDF5_HL_LIB_TARGET}) + else () + clang_format (HDF5_HL_SRC_FORMAT ${HDF5_HL_LIBSH_TARGET}) + endif () +endif () + #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- @@ -118,22 +137,26 @@ if (BUILD_SHARED_LIBS) set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_HL_LIB_CORENAME}") endif () -set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}") -set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.pc.in - ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}.pc @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}.pc DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig COMPONENT hllibraries ) if (NOT WIN32 AND NOT MINGW) - set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND) + set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER}) + else () + set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + endif () configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in ${HDF5_BINARY_DIR}/CMakeFiles/h5hlcc diff --git a/hl/src/COPYING b/hl/src/COPYING deleted file mode 100644 index 6497ace3da0..00000000000 --- a/hl/src/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c index 66997cb4d67..3bdb4e22d24 100644 --- a/hl/src/H5DO.c +++ b/hl/src/H5DO.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by 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 * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -18,7 +18,7 @@ #include "H5DOpublic.h" #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5DOwrite_chunk * @@ -33,8 +33,8 @@ *------------------------------------------------------------------------- */ herr_t -H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, - size_t data_size, const void *buf) +H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, + const void *buf) { /* Call underlying H5D function */ if (H5Dwrite_chunk(dset_id, dxpl_id, filters, offset, data_size, buf) < 0) @@ -44,7 +44,6 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o } /* end H5DOwrite_chunk() */ - /*------------------------------------------------------------------------- * Function: H5DOread_chunk * @@ -59,19 +58,17 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o *--------------------------------------------------------------------------- */ herr_t -H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, - void *buf) +H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) { /* Call underlying H5D function */ if (H5Dread_chunk(dset_id, dxpl_id, offset, filters, buf) < 0) return FAIL; else return SUCCEED; - } /* end H5DOread_chunk() */ +} /* end H5DOread_chunk() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5DOappend() * @@ -103,57 +100,56 @@ H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fi *------------------------------------------------------------------------- */ herr_t -H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, - hid_t memtype, const void *buf) +H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, const void *buf) { - hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */ - hsize_t old_size = 0; /* The size of the dimension to be extended */ - int sndims; /* Number of dimensions in dataspace (signed) */ - unsigned ndims; /* Number of dimensions in dataspace */ - hid_t space_id = FAIL; /* Old file space */ - hid_t new_space_id = FAIL; /* New file space (after extension) */ - hid_t mem_space_id = FAIL; /* Memory space for data buffer */ - hssize_t snelmts; /* Number of elements in selection (signed) */ - hsize_t nelmts; /* Number of elements in selection */ - hid_t dapl = FAIL; /* Dataset access property list */ - - hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */ - hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */ - hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */ - hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */ - - hsize_t *boundary = NULL; /* Boundary set in append flush property */ - H5D_append_cb_t append_cb; /* Callback function set in append flush property */ - void *udata; /* User data set in append flush property */ - hbool_t hit = FALSE; /* Boundary is hit or not */ - hsize_t k; /* Local index variable */ - unsigned u; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hsize_t size[H5S_MAX_RANK]; /* The new size (after extension */ + hsize_t old_size = 0; /* The size of the dimension to be extended */ + int sndims; /* Number of dimensions in dataspace (signed) */ + unsigned ndims; /* Number of dimensions in dataspace */ + hid_t space_id = FAIL; /* Old file space */ + hid_t new_space_id = FAIL; /* New file space (after extension) */ + hid_t mem_space_id = FAIL; /* Memory space for data buffer */ + hssize_t snelmts; /* Number of elements in selection (signed) */ + hsize_t nelmts; /* Number of elements in selection */ + hid_t dapl = FAIL; /* Dataset access property list */ + + hsize_t start[H5S_MAX_RANK]; /* H5Sselect_Hyperslab: starting offset */ + hsize_t count[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of blocks to select */ + hsize_t stride[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements to move when selecting */ + hsize_t block[H5S_MAX_RANK]; /* H5Sselect_hyperslab: # of elements in a block */ + + hsize_t * boundary = NULL; /* Boundary set in append flush property */ + H5D_append_cb_t append_cb; /* Callback function set in append flush property */ + void * udata; /* User data set in append flush property */ + hbool_t hit = FALSE; /* Boundary is hit or not */ + hsize_t k; /* Local index variable */ + unsigned u; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* check arguments */ - if(H5I_DATASET != H5Iget_type(dset_id)) + if (H5I_DATASET != H5Iget_type(dset_id)) goto done; /* If the user passed in a default DXPL, sanity check it */ - if(H5P_DEFAULT != dxpl_id) - if(TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) + if (H5P_DEFAULT != dxpl_id) + if (TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) goto done; /* Get the dataspace of the dataset */ - if(FAIL == (space_id = H5Dget_space(dset_id))) + if (FAIL == (space_id = H5Dget_space(dset_id))) goto done; /* Get the rank of this dataspace */ - if((sndims = H5Sget_simple_extent_ndims(space_id)) < 0) + if ((sndims = H5Sget_simple_extent_ndims(space_id)) < 0) goto done; ndims = (unsigned)sndims; /* Verify correct axis */ - if(axis >= ndims) + if (axis >= ndims) goto done; /* Get the dimensions sizes of the dataspace */ - if(H5Sget_simple_extent_dims(space_id, size, NULL) < 0) + if (H5Sget_simple_extent_dims(space_id, size, NULL) < 0) goto done; /* Adjust the dimension size of the requested dimension, @@ -161,99 +157,98 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, */ old_size = size[axis]; size[axis] += extension; - if(size[axis] < old_size) + if (size[axis] < old_size) goto done; /* Set the extent of the dataset to the new dimension */ - if(H5Dset_extent(dset_id, size) < 0) + if (H5Dset_extent(dset_id, size) < 0) goto done; /* Get the new dataspace of the dataset */ - if(FAIL == (new_space_id = H5Dget_space(dset_id))) + if (FAIL == (new_space_id = H5Dget_space(dset_id))) goto done; /* Select a hyperslab corresponding to the append operation */ - for(u = 0 ; u < ndims ; u++) { - start[u] = 0; + for (u = 0; u < ndims; u++) { + start[u] = 0; stride[u] = 1; - count[u] = size[u]; - block[u] = 1; - if(u == axis) { + count[u] = size[u]; + block[u] = 1; + if (u == axis) { count[u] = extension; start[u] = old_size; } /* end if */ - } /* end for */ - if(FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block)) + } /* end for */ + if (FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block)) goto done; /* The # of elemnts in the new extended dataspace */ - if((snelmts = H5Sget_select_npoints(new_space_id)) < 0) + if ((snelmts = H5Sget_select_npoints(new_space_id)) < 0) goto done; nelmts = (hsize_t)snelmts; /* create a memory space */ - if(FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL))) + if (FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL))) goto done; /* Write the data */ - if(H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0) + if (H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0) goto done; /* Obtain the dataset's access property list */ - if((dapl = H5Dget_access_plist(dset_id)) < 0) + if ((dapl = H5Dget_access_plist(dset_id)) < 0) goto done; /* Allocate the boundary array */ boundary = (hsize_t *)HDmalloc(ndims * sizeof(hsize_t)); /* Retrieve the append flush property */ - if(H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0) + if (H5Pget_append_flush(dapl, ndims, boundary, &append_cb, &udata) < 0) goto done; /* No boundary for this axis */ - if(boundary[axis] != 0) { + if (boundary[axis] != 0) { /* Determine whether a boundary is hit or not */ - for(k = start[axis]; k < size[axis]; k++) - if(!((k + 1) % boundary[axis])) { + for (k = start[axis]; k < size[axis]; k++) + if (!((k + 1) % boundary[axis])) { hit = TRUE; break; } - if(hit) { /* Hit the boundary */ + if (hit) { /* Hit the boundary */ /* Invoke callback if there is one */ - if(append_cb && append_cb(dset_id, size, udata) < 0) + if (append_cb && append_cb(dset_id, size, udata) < 0) goto done; - /* Do a dataset flush */ - if(H5Dflush(dset_id) < 0) + /* Do a dataset flush */ + if (H5Dflush(dset_id) < 0) goto done; } /* end if */ - } /* end if */ + } /* end if */ /* Indicate success */ ret_value = SUCCEED; done: /* Close old dataspace */ - if(space_id != FAIL && H5Sclose(space_id) < 0) + if (space_id != FAIL && H5Sclose(space_id) < 0) ret_value = FAIL; /* Close new dataspace */ - if(new_space_id != FAIL && H5Sclose(new_space_id) < 0) + if (new_space_id != FAIL && H5Sclose(new_space_id) < 0) ret_value = FAIL; /* Close memory dataspace */ - if(mem_space_id != FAIL && H5Sclose(mem_space_id) < 0) + if (mem_space_id != FAIL && H5Sclose(mem_space_id) < 0) ret_value = FAIL; /* Close the dataset access property list */ - if(dapl != FAIL && H5Pclose(dapl) < 0) + if (dapl != FAIL && H5Pclose(dapl) < 0) ret_value = FAIL; - if(boundary) + if (boundary) HDfree(boundary); return ret_value; } /* H5DOappend() */ - diff --git a/hl/src/H5DOpublic.h b/hl/src/H5DOpublic.h index e09ebcaaf9a..88616a3738e 100644 --- a/hl/src/H5DOpublic.h +++ b/hl/src/H5DOpublic.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DOpublic_H -#define _H5DOpublic_H +#ifndef H5DOpublic_H +#define H5DOpublic_H #ifdef __cplusplus extern "C" { @@ -25,8 +25,8 @@ extern "C" { *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, - size_t extension, hid_t memtype, const void *buf); +H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t memtype, + const void *buf); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -35,10 +35,10 @@ H5_HLDLL herr_t H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Compatibility wrappers for functionality moved to H5D */ -H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, - const hsize_t *offset, size_t data_size, const void *buf); -H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, - uint32_t *filters /*out*/, void *buf /*out*/); +H5_HLDLL herr_t H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, + size_t data_size, const void *buf); +H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters /*out*/, + void *buf /*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -47,4 +47,3 @@ H5_HLDLL herr_t H5DOread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offs #endif #endif - diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index eac4d2380c9..2bd40469c8b 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1,25 +1,24 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by 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 * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5DSprivate.h" #include "H5LTprivate.h" #include "H5IMprivate.h" #include "H5TBprivate.h" - /* Local routines */ static herr_t H5DS_is_reserved(hid_t did); -static hid_t H5DS_get_REFLIST_type(void); +static hid_t H5DS_get_REFLIST_type(void); /*------------------------------------------------------------------------- * Function: H5DSset_scale @@ -41,51 +40,48 @@ static hid_t H5DS_get_REFLIST_type(void); herr_t H5DSset_scale(hid_t dsid, const char *dimname) { - int has_dimlist; + int has_dimlist; H5I_type_t it; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(dsid)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; /*------------------------------------------------------------------------- - * check if the dataset is a dataset wich has references to dimension scales - *------------------------------------------------------------------------- - */ + * check if the dataset is a dataset wich has references to dimension scales + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LIST" */ - if ((has_dimlist = H5LT_find_attribute(dsid,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(dsid, DIMENSION_LIST)) < 0) return FAIL; if (has_dimlist == 1) return FAIL; /*------------------------------------------------------------------------- - * write the standard attributes for a Dimension Scale dataset - *------------------------------------------------------------------------- - */ + * write the standard attributes for a Dimension Scale dataset + *------------------------------------------------------------------------- + */ - if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0) + if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0) return FAIL; - if (dimname!=NULL) - { - if (H5LT_set_attribute_string(dsid,"NAME",dimname) < 0) + if (dimname != NULL) { + if (H5LT_set_attribute_string(dsid, "NAME", dimname) < 0) return FAIL; } return SUCCEED; } - - /*------------------------------------------------------------------------- * Function: H5DSattach_scale * @@ -110,33 +106,33 @@ H5DSset_scale(hid_t dsid, const char *dimname) herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - int is_ds; - hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref_to_ds; /* reference to the DS */ - hobj_ref_t ref_j; /* iterator reference */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - H5O_info_t oi1, oi2; - H5I_type_t it1, it2; - int i; - size_t len; - int found_ds=0; - htri_t is_scale; + int has_dimlist; + int has_reflist; + int is_ds; + hssize_t nelmts; + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hobj_ref_t ref_to_ds; /* reference to the DS */ + hobj_ref_t ref_j; /* iterator reference */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + H5O_info2_t oi1, oi2; + H5I_type_t it1, it2; + int i; + size_t len; + int found_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; @@ -146,16 +142,22 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info2(did, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info2(dsid, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) - return FAIL; + if (oi1.fileno == oi2.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + return FAIL; + if (!token_cmp) + return FAIL; + } /* end if */ /* get ID type */ if ((it1 = H5Iget_type(did)) < 0) @@ -167,21 +169,20 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* the DS dataset cannot have dimension scales */ - if (H5LT_find_attribute(dsid,DIMENSION_LIST)==1) + if (H5LT_find_attribute(dsid, DIMENSION_LIST) == 1) return FAIL; /* check if the dataset is a "reserved" dataset (image, table) */ - if (H5DS_is_reserved(did)==1) + if (H5DS_is_reserved(did) == 1) return FAIL; - /*------------------------------------------------------------------------- - * The dataset may or may not have the associated DS attribute - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new DS - *------------------------------------------------------------------------- - */ + * The dataset may or may not have the associated DS attribute + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new DS + *------------------------------------------------------------------------- + */ /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) @@ -200,14 +201,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* parameter range checking */ - if (idx > (unsigned)rank-1) + if (idx > (unsigned)rank - 1) return FAIL; /*------------------------------------------------------------------------- - * two references are created: one to the DS, saved in "DIMENSION_LIST" - * and one to the dataset, saved in "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * two references are created: one to the DS, saved in "DIMENSION_LIST" + * and one to the dataset, saved in "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ /* create a reference for the >>DS<< dataset */ if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0) return FAIL; @@ -217,57 +218,56 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if ((has_dimlist = H5LT_find_attribute(did,DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /*------------------------------------------------------------------------- - * it does not exist. we create the attribute and its reference data - *------------------------------------------------------------------------- - */ - if (has_dimlist == 0) - { + * it does not exist. we create the attribute and its reference data + *------------------------------------------------------------------------- + */ + if (has_dimlist == 0) { dims[0] = (hsize_t)rank; /* space for the attribute */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) return FAIL; /* create the type for the attribute "DIMENSION_LIST" */ - if((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) + if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) goto out; /* create the attribute */ - if((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { buf[i].len = 0; - buf[i].p = NULL; + buf[i].p = NULL; } /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc( 1 * sizeof(hobj_ref_t)); + buf[idx].len = 1; + buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; /* write the attribute with the reference */ - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; /* close */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); @@ -275,212 +275,217 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) } /*------------------------------------------------------------------------- - * the attribute already exists, open it, extend the buffer, - * and insert the new reference - *------------------------------------------------------------------------- - */ - else if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + * the attribute already exists, open it, extend the buffer, + * and insert the new reference + *------------------------------------------------------------------------- + */ + else if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* check to avoid inserting duplicates. it is not FAIL, just do nothing */ /* iterate all the REFs in this dimension IDX */ - for(i = 0; i < (int)buf[idx].len; i++) { + for (i = 0; i < (int)buf[idx].len; i++) { /* get the reference */ ref_j = ((hobj_ref_t *)buf[idx].p)[i]; /* get the scale id for this REF */ - if((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) goto out; /* get info for DS in the parameter list */ - if(H5Oget_info2(dsid, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) goto out; /* get info for this DS */ - if(H5Oget_info2(dsid_j, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) goto out; /* same object, so this DS scale is already in this DIM IDX */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) - found_ds = 1; + if (oi1.fileno == oi2.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + goto out; + if (!token_cmp) + found_ds = 1; + } /* end if */ /* close the dereferenced dataset */ - if(H5Dclose(dsid_j) < 0) + if (H5Dclose(dsid_j) < 0) goto out; } /* end for */ - if(found_ds == 0) { + if (found_ds == 0) { /* we are adding one more DS to this dimension */ - if(buf[idx].len > 0) { + if (buf[idx].len > 0) { buf[idx].len++; - len = buf[idx].len; - buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); + len = buf[idx].len; + buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds; } /* end if */ else { /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); + buf[idx].len = 1; + buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; } /* end else */ - } /* end if */ + } /* end if */ /* write the attribute with the new references */ - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; /* close */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; } /* has_dimlist */ /*------------------------------------------------------------------------- - * save DS info on the >>DS<< dataset - *------------------------------------------------------------------------- - */ + * save DS info on the >>DS<< dataset + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) goto out; /*------------------------------------------------------------------------- - * it does not exist. we create the attribute and its reference data - *------------------------------------------------------------------------- - */ - if(has_reflist == 0) { + * it does not exist. we create the attribute and its reference data + *------------------------------------------------------------------------- + */ + if (has_reflist == 0) { dims[0] = 1; /* space for the attribute */ - if((sid = H5Screate_simple(1,dims,NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the compound datatype for the attribute "REFERENCE_LIST" */ - if((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) goto out; /* insert reference field */ - if(H5Tinsert(tid, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0) + if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) goto out; /* insert dimension idx of the dataset field */ - if(H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) + if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) goto out; /* create the attribute */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* store the IDX information */ dsl.dim_idx = idx; /* write the attribute with the reference */ - if(H5Awrite(aid, tid, &dsl) < 0) + if (H5Awrite(aid, tid, &dsl) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* end if */ /*------------------------------------------------------------------------- - * the "REFERENCE_LIST" array already exists, open it and extend it - *------------------------------------------------------------------------- - */ - else if(has_reflist == 1) { - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + * the "REFERENCE_LIST" array already exists, open it and extend it + *------------------------------------------------------------------------- + */ + else if (has_reflist == 1) { + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read attribute REFERENCE_LIST */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; nelmts++; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if(dsbuf == NULL) + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) goto out; - if(H5Aread(aid, ntid, dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; /*------------------------------------------------------------------------- - * create a new attribute - *------------------------------------------------------------------------- - */ + * create a new attribute + *------------------------------------------------------------------------- + */ /* the attribute must be deleted, in order to the new one can reflect the changes*/ - if(H5Adelete(dsid, REFERENCE_LIST) < 0) + if (H5Adelete(dsid, REFERENCE_LIST) < 0) goto out; /* store the IDX information (index of the dataset that has the DS) */ - dsl.dim_idx = idx; + dsl.dim_idx = idx; dsbuf[nelmts - 1] = dsl; /* create a new data space for the new references array */ dims[0] = (hsize_t)nelmts; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the attribute with the new references */ - if(H5Awrite(aid, ntid, dsbuf) < 0) + if (H5Awrite(aid, ntid, dsbuf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; if (H5Tclose(ntid) < 0) goto out; @@ -490,15 +495,15 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) } /* has_reflist */ /*------------------------------------------------------------------------- - * write the standard attributes for a Dimension Scale dataset - *------------------------------------------------------------------------- - */ + * write the standard attributes for a Dimension Scale dataset + *------------------------------------------------------------------------- + */ - if((is_ds = H5DSis_scale(dsid)) < 0) + if ((is_ds = H5DSis_scale(dsid)) < 0) return FAIL; - if(is_ds == 0) { - if (H5LT_set_attribute_string(dsid,"CLASS",DIMENSION_SCALE_CLASS) < 0) + if (is_ds == 0) { + if (H5LT_set_attribute_string(dsid, "CLASS", DIMENSION_SCALE_CLASS) < 0) return FAIL; } @@ -506,17 +511,19 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) /* error zone */ out: - if(buf) + if (buf) HDfree(buf); - if(dsbuf) + if (dsbuf) HDfree(dsbuf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(ntid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -547,62 +554,67 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - hssize_t nelmts; - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - int i; - size_t j; - hssize_t ii; - H5O_info_t did_oi, dsid_oi, tmp_oi; - int found_dset = 0, found_ds = 0; - int have_ds = 0; - htri_t is_scale; + int has_dimlist; + int has_reflist; + hssize_t nelmts; + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + int i; + size_t j; + hssize_t ii; + H5O_info2_t did_oi, dsid_oi, tmp_oi; + int found_dset = 0, found_ds = 0; + int have_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* check for valid types of identifiers */ - if(H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) + if (H5I_DATASET != H5Iget_type(did) || H5I_DATASET != H5Iget_type(dsid)) return FAIL; - if((is_scale = H5DSis_scale(did)) < 0) + if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; /* the dataset cannot be a DS dataset */ - if( is_scale == 1) + if (is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info2(did, &did_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &did_oi, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info2(dsid, &dsid_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &dsid_oi, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(did_oi.fileno == dsid_oi.fileno && did_oi.addr == dsid_oi.addr) - return FAIL; + if (did_oi.fileno == dsid_oi.fileno) { + int token_cmp; + if (H5Otoken_cmp(did, &did_oi.token, &dsid_oi.token, &token_cmp) < 0) + return FAIL; + if (!token_cmp) + return FAIL; + } /* end if */ /*------------------------------------------------------------------------- - * Find "DIMENSION_LIST" - *------------------------------------------------------------------------- - */ + * Find "DIMENSION_LIST" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; @@ -623,58 +635,56 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* parameter range checking */ - if (idx > (unsigned)rank-1) + if (idx > (unsigned)rank - 1) return FAIL; /*------------------------------------------------------------------------- - * find "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * find "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) return FAIL; - if(has_reflist == 0) + if (has_reflist == 0) return FAIL; /*------------------------------------------------------------------------- - * open "DIMENSION_LIST", and delete the reference - *------------------------------------------------------------------------- - */ + * open "DIMENSION_LIST", and delete the reference + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) return FAIL; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* reset */ - if ( buf[idx].len > 0 ) - { - for (j=0; j 0) { + for (j = 0; j < buf[idx].len; j++) { /* get the reference */ ref = ((hobj_ref_t *)buf[idx].p)[j]; /* get the DS id */ - if ((dsid_j = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for this DS */ - if(H5Oget_info2(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0) goto out; /* Close the dereferenced dataset */ @@ -682,124 +692,135 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; /* same object, reset */ - if(dsid_oi.fileno == tmp_oi.fileno && dsid_oi.addr == tmp_oi.addr) { - /* If there are more than one reference in the VL element - and the reference we found is not the last one, - copy the last one to replace the found one since the order - of the references doesn't matter according to the spec; - reduce the size of the VL element by 1; - if the length of the element becomes 0, free the pointer - and reset to NULL */ - - size_t len = buf[idx].len; - - if(j < len - 1) - ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len-1]; - len = --buf[idx].len; - if(len == 0) { - HDfree(buf[idx].p); - buf[idx].p = NULL; - } - /* Since a reference to a dim. scale can be inserted only once, - we do not need to continue the search if it is found */ - found_ds = 1; - break; - } /* end if */ - } /* j */ - } /* if */ + if (dsid_oi.fileno == tmp_oi.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &dsid_oi.token, &tmp_oi.token, &token_cmp) < 0) + goto out; + if (!token_cmp) { + /* If there are more than one reference in the VL element + and the reference we found is not the last one, + copy the last one to replace the found one since the order + of the references doesn't matter according to the spec; + reduce the size of the VL element by 1; + if the length of the element becomes 0, free the pointer + and reset to NULL */ + + size_t len = buf[idx].len; + + if (j < len - 1) + ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1]; + len = --buf[idx].len; + if (len == 0) { + HDfree(buf[idx].p); + buf[idx].p = NULL; + } + /* Since a reference to a dim. scale can be inserted only once, + we do not need to continue the search if it is found */ + found_ds = 1; + break; + } /* end if */ + } /* end if */ + } /* j */ + } /* if */ /* the scale must be present to continue */ - if(found_ds == 0) + if (found_ds == 0) goto out; /* Write the attribute, but check first, if we have any scales left, because if not, we should delete the attribute according to the spec */ - for(i = 0; i < rank; i++) { - if(buf[i].len > 0) { + for (i = 0; i < rank; i++) { + if (buf[i].len > 0) { have_ds = 1; break; } } - if(have_ds) { - if(H5Awrite(aid, tid, buf) < 0) + if (have_ds) { + if (H5Awrite(aid, tid, buf) < 0) goto out; } else { - if(H5Adelete(did, DIMENSION_LIST) < 0) + if (H5Adelete(did, DIMENSION_LIST) < 0) goto out; } /* close */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; - /*------------------------------------------------------------------------- - * the "REFERENCE_LIST" array exists, update - *------------------------------------------------------------------------- - */ + * the "REFERENCE_LIST" array exists, update + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read attribute REFERENCE_LIST */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if(dsbuf == NULL) + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) goto out; - if(H5Aread(aid, ntid, dsbuf) < 0) + if (H5Aread(aid, ntid, dsbuf) < 0) goto out; - for(ii = 0; ii < nelmts; ii++) { + for (ii = 0; ii < nelmts; ii++) { /* First check if we have the same dimension index */ - if(idx == dsbuf[ii].dim_idx) { + if (idx == dsbuf[ii].dim_idx) { /* get the reference to the dataset */ ref = dsbuf[ii].ref; /* get the dataset id */ - if ((did_i = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for this dataset */ - if(H5Oget_info2(did_i, &tmp_oi, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0) goto out; /* close the dereferenced dataset */ - if(H5Dclose(did_i) < 0) + if (H5Dclose(did_i) < 0) goto out; /* same object, reset. we want to detach only for this DIM */ - if(did_oi.fileno == tmp_oi.fileno && did_oi.addr == tmp_oi.addr) { - /* copy the last one to replace the one which is found */ - dsbuf[ii] = dsbuf[nelmts-1]; - nelmts--; - found_dset=1; - break; - } /* end if */ - } /* if we have the same dimension index */ - } /* ii */ + if (did_oi.fileno == tmp_oi.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &did_oi.token, &tmp_oi.token, &token_cmp) < 0) + goto out; + if (!token_cmp) { + /* copy the last one to replace the one which is found */ + dsbuf[ii] = dsbuf[nelmts - 1]; + nelmts--; + found_dset = 1; + break; + } /* end if */ + } /* end if */ + } /* if we have the same dimension index */ + } /* ii */ /* close space and attribute */ if (H5Sclose(sid) < 0) @@ -808,44 +829,43 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; /*------------------------------------------------------------------------- - * check if we found the pointed dataset - *------------------------------------------------------------------------- - */ + * check if we found the pointed dataset + *------------------------------------------------------------------------- + */ /* the pointed dataset must exist */ if (found_dset == 0) goto out; /*------------------------------------------------------------------------- - * create a new attribute - *------------------------------------------------------------------------- - */ + * create a new attribute + *------------------------------------------------------------------------- + */ /* the attribute must be deleted, in order to the new one can reflect the changes*/ if (H5Adelete(dsid, REFERENCE_LIST) < 0) goto out; /* don't do anything for an empty array */ - if(nelmts) - { + if (nelmts) { /* create a new data space for the new references array */ - dims[0] = (hsize_t)nelmts; + dims[0] = (hsize_t)nelmts; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the new attribute with the new references */ - if(H5Awrite(aid, ntid, dsbuf) < 0) + if (H5Awrite(aid, ntid, dsbuf) < 0) goto out; /* close space and attribute */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* nelmts */ @@ -862,29 +882,30 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(ntid); H5Tclose(tid); - if(dsbuf) { + if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; } - if(buf) { - /* Failure occured before H5Dvlen_reclaim was called; + if (buf) { + /* Failure occured before H5Treclaim was called; free the pointers allocated when we read data in */ - for(i = 0; i < rank; i++) { - if(buf[i].p) + for (i = 0; i < rank; i++) { + if (buf[i].p) HDfree(buf[i].p); } HDfree(buf); buf = NULL; } - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; - } /*------------------------------------------------------------------------- @@ -912,48 +933,54 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) htri_t H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ - H5O_info_t oi1, oi2, oi3, oi4; - H5I_type_t it1, it2; - int i; - int found_dset=0, found_ds=0; - htri_t is_scale; + int has_dimlist; + int has_reflist; + hssize_t nelmts; + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t ntid = -1; /* attribute native type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ + H5O_info2_t oi1, oi2, oi3, oi4; + H5I_type_t it1, it2; + int i; + int found_dset = 0, found_ds = 0; + htri_t is_scale; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ if ((is_scale = H5DSis_scale(did)) < 0) return FAIL; /* the dataset cannot be a DS dataset */ - if ( is_scale == 1) + if (is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info2(did, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi1, H5O_INFO_BASIC) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info2(dsid, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi2, H5O_INFO_BASIC) < 0) return FAIL; /* same object, not valid */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) - return FAIL; + if (oi1.fileno == oi2.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + return FAIL; + if (!token_cmp) + return FAIL; + } /* end if */ /* get ID type */ if ((it1 = H5Iget_type(did)) < 0) @@ -965,16 +992,16 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /*------------------------------------------------------------------------- - * get space - *------------------------------------------------------------------------- - */ + * get space + *------------------------------------------------------------------------- + */ /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ @@ -982,32 +1009,31 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) goto out; /* parameter range checking */ - if(idx > ((unsigned)rank - 1)) + if (idx > ((unsigned)rank - 1)) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /*------------------------------------------------------------------------- - * open "DIMENSION_LIST" - *------------------------------------------------------------------------- - */ + * open "DIMENSION_LIST" + *------------------------------------------------------------------------- + */ - if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); + if (buf == NULL) goto out; /* read */ @@ -1015,8 +1041,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) goto out; /* iterate all the REFs in this dimension IDX */ - for (i=0; i<(int)buf[idx].len; i++) - { + for (i = 0; i < (int)buf[idx].len; i++) { /* get the reference */ ref = ((hobj_ref_t *)buf[idx].p)[i]; @@ -1025,26 +1050,30 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) goto out; /* get info for DS in the parameter list */ - if(H5Oget_info2(dsid, &oi1, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) goto out; /* get info for this DS */ - if(H5Oget_info2(dsid_j, &oi2, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(dsid_j, &oi2, H5O_INFO_BASIC) < 0) goto out; /* same object */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) - found_ds = 1; + if (oi1.fileno == oi2.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &oi1.token, &oi2.token, &token_cmp) < 0) + goto out; + if (!token_cmp) + found_ds = 1; + } /* end if */ /* close the dereferenced dataset */ if (H5Dclose(dsid_j) < 0) goto out; - } - /* close */ - if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; if (H5Sclose(sid) < 0) goto out; @@ -1057,39 +1086,38 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) } /* has_dimlist */ /*------------------------------------------------------------------------- - * info on the >>DS<< dataset - *------------------------------------------------------------------------- - */ + * info on the >>DS<< dataset + *------------------------------------------------------------------------- + */ /* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */ - if((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) + if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0) goto out; /*------------------------------------------------------------------------- - * open "REFERENCE_LIST" - *------------------------------------------------------------------------- - */ + * open "REFERENCE_LIST" + *------------------------------------------------------------------------- + */ - if(has_reflist == 1) - { - if((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) + if (has_reflist == 1) { + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get native type to read REFERENCE_LIST attribute */ - if((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5DS_get_REFLIST_type()) < 0) goto out; /* get and save the old reference(s) */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; - if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) + if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); if (dsbuf == NULL) goto out; @@ -1098,40 +1126,43 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) goto out; /*------------------------------------------------------------------------- - * iterate - *------------------------------------------------------------------------- - */ + * iterate + *------------------------------------------------------------------------- + */ - for(i = 0; i < nelmts; i++) - { + for (i = 0; i < nelmts; i++) { /* get the reference */ ref = dsbuf[i].ref; /* the reference was not deleted */ - if (ref) - { + if (ref) { /* get the dataset id */ - if ((did_i = H5Rdereference2(did,H5P_DEFAULT,H5R_OBJECT,&ref)) < 0) + if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; /* get info for dataset in the parameter list */ - if(H5Oget_info2(did, &oi3, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0) goto out; /* get info for this dataset */ - if(H5Oget_info2(did_i, &oi4, H5O_INFO_BASIC) < 0) + if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0) goto out; /* same object */ - if(oi3.fileno == oi4.fileno && oi3.addr == oi4.addr && idx==dsbuf[i].dim_idx) - found_dset=1; + if (oi3.fileno == oi4.fileno) { + int token_cmp; + + if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0) + goto out; + if (!token_cmp && (idx == dsbuf[i].dim_idx)) + found_dset = 1; + } /* end if */ /* close the dereferenced dataset */ if (H5Dclose(did_i) < 0) goto out; } /* if */ - } /* i */ - + } /* i */ /* close */ if (H5Sclose(sid) < 0) @@ -1154,18 +1185,20 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); H5Tclose(ntid); - } H5E_END_TRY; + } + H5E_END_TRY; if (buf) { HDfree(buf); buf = NULL; } - if(dsbuf) { + if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; } @@ -1212,42 +1245,40 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) *------------------------------------------------------------------------- */ herr_t -H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, - H5DS_iterate_t visitor, void *visitor_data ) +H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visitor, void *visitor_data) { - hid_t scale_id; - int rank; - hobj_ref_t ref; /* reference to the DS */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - herr_t ret_value=0; - int j_idx; - int nscales; - int has_dimlist; - int i; + hid_t scale_id; + int rank; + hobj_ref_t ref; /* reference to the DS */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + herr_t ret_value = 0; + int j_idx; + int nscales; + int has_dimlist; + int i; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; /* get the number of scales assotiated with this DIM */ - if ((nscales = H5DSget_num_scales(did,dim)) < 0) + if ((nscales = H5DSget_num_scales(did, dim)) < 0) return FAIL; /* parameter range checking */ - if (ds_idx!=NULL) - { - if (*ds_idx>=nscales) + if (ds_idx != NULL) { + if (*ds_idx >= nscales) return FAIL; } @@ -1256,70 +1287,67 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, return FAIL; /* get rank */ - if ((rank=H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if ( dim >= (unsigned)rank ) + if (dim >= (unsigned)rank) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; - if(has_dimlist == 0) + if (has_dimlist == 0) return SUCCEED; - else if(has_dimlist == 1) - { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + else if (has_dimlist == 1) { + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; - if ( buf[dim].len > 0 ) - { - if (ds_idx!=NULL) + if (buf[dim].len > 0) { + if (ds_idx != NULL) j_idx = *ds_idx; else - j_idx=0; + j_idx = 0; /* iterate */ - for(i=j_idx; i= (unsigned)rank ) + if (idx >= (unsigned)rank) return FAIL; /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) return FAIL; /*------------------------------------------------------------------------- - * make the attribute and insert label - *------------------------------------------------------------------------- - */ + * make the attribute and insert label + *------------------------------------------------------------------------- + */ - if (has_labels == 0) - { + if (has_labels == 0) { dims[0] = (hsize_t)rank; /* space for the attribute */ @@ -1459,12 +1488,12 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - u.const_buf = (char const **) HDmalloc((size_t) rank * sizeof(char *)); + u.const_buf = (char const **)HDmalloc((size_t)rank * sizeof(char *)); if (u.const_buf == NULL) goto out; - for (i = 0; i < (unsigned int) rank; i++) + for (i = 0; i < (unsigned int)rank; i++) u.const_buf[i] = NULL; /* store the label information in the required index */ @@ -1481,20 +1510,18 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (u.const_buf) - { + if (u.const_buf) { HDfree(u.const_buf); u.const_buf = NULL; } } /*------------------------------------------------------------------------- - * just insert label - *------------------------------------------------------------------------- - */ + * just insert label + *------------------------------------------------------------------------- + */ - else - { + else { if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; @@ -1503,7 +1530,7 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - u.buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); + u.buf = (char **)HDmalloc((size_t)rank * sizeof(char *)); if (u.buf == NULL) goto out; @@ -1527,8 +1554,7 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) u.buf[idx] = NULL; /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) - { + for (i = 0; i < (unsigned int)rank; i++) { if (u.buf[i]) HDfree(u.buf[i]); } @@ -1538,8 +1564,7 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (H5Aclose(aid) < 0) goto out; - if (u.buf) - { + if (u.buf) { HDfree(u.buf); u.buf = NULL; } @@ -1550,13 +1575,11 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) /* error zone */ out: - if (u.buf) - { - if (u.buf[idx]) /* check if we errored during H5Awrite */ + if (u.buf) { + if (u.buf[idx]) /* check if we errored during H5Awrite */ u.buf[idx] = NULL; /* don't free label */ /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) - { + for (i = 0; i < (unsigned int)rank; i++) { if (u.buf[i]) HDfree(u.buf[i]); } @@ -1567,7 +1590,8 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label) H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - }H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -1592,20 +1616,20 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { int has_labels; - hid_t sid = -1; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + char ** buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ size_t nbytes = 0; size_t copy_len; int i; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; @@ -1613,7 +1637,7 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) if (H5I_DATASET != it) return FAIL; - /* get dataset space */ + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1625,41 +1649,39 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) if (H5Sclose(sid) < 0) goto out; - if ( idx >= (unsigned)rank ) + if (idx >= (unsigned)rank) return FAIL; /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) return FAIL; /* return 0 and NULL for label if no label found */ - if (has_labels == 0) - { + if (has_labels == 0) { if (label) label[0] = 0; return 0; } /*------------------------------------------------------------------------- - * open the attribute and read label - *------------------------------------------------------------------------- - */ + * open the attribute and read label + *------------------------------------------------------------------------- + */ - assert (has_labels == 1); + assert(has_labels == 1); if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; - if ((tid = H5Aget_type(aid)) < 0) goto out; /* allocate and initialize */ - buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); + buf = (char **)HDmalloc((size_t)rank * sizeof(char *)); if (buf == NULL) goto out; @@ -1669,27 +1691,23 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; /* do only if the label name exists for the dimension */ - if (buf[idx] != NULL) - { + if (buf[idx] != NULL) { /* get the real string length */ nbytes = HDstrlen(buf[idx]); /* compute the string length which will fit into the user's buffer */ - copy_len = MIN(size-1, nbytes); + copy_len = MIN(size - 1, nbytes); /* copy all/some of the name */ - if (label) - { + if (label) { HDmemcpy(label, buf[idx], copy_len); /* terminate the string */ label[copy_len] = '\0'; } - } /* free all the ptr's from the H5Aread() */ - for (i = 0; i < rank; i++) - { + for (i = 0; i < rank; i++) { if (buf[i]) HDfree(buf[i]); } @@ -1699,21 +1717,18 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; if (H5Aclose(aid) < 0) goto out; - if (buf) - { + if (buf) { HDfree(buf); buf = NULL; } - return (ssize_t) nbytes; + return (ssize_t)nbytes; /* error zone */ out: - if (buf) - { + if (buf) { /* free all the ptr's from the H5Aread() */ - for (i = 0; i < rank; i++) - { + for (i = 0; i < rank; i++) { if (buf[i]) HDfree(buf[i]); } @@ -1724,7 +1739,8 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - }H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -1755,26 +1771,26 @@ H5DSget_scale_name(hid_t did, char *name, size_t size) size_t nbytes; size_t copy_len; int has_name; - char *buf=NULL; + char * buf = NULL; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) return FAIL; - if (H5I_DATASET!=it) + if (H5I_DATASET != it) return FAIL; - if ((H5DSis_scale(did))<=0) + if ((H5DSis_scale(did)) <= 0) return FAIL; /*------------------------------------------------------------------------- - * check if the DS has a name - *------------------------------------------------------------------------- - */ + * check if the DS has a name + *------------------------------------------------------------------------- + */ /* try to find the attribute "NAME" on the >>DS<< dataset */ if ((has_name = H5LT_find_attribute(did, "NAME")) < 0) @@ -1784,43 +1800,43 @@ H5DSget_scale_name(hid_t did, char *name, size_t size) return 0; /*------------------------------------------------------------------------- - * open the attribute - *------------------------------------------------------------------------- - */ + * open the attribute + *------------------------------------------------------------------------- + */ - if((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "NAME", H5P_DEFAULT)) < 0) return FAIL; /* get space */ - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* get type */ - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* get the size */ - if((nbytes = H5Tget_size(tid)) == 0) + if ((nbytes = H5Tget_size(tid)) == 0) goto out; /* allocate a temporary buffer */ - buf = (char*)HDmalloc(nbytes * sizeof(char)); + buf = (char *)HDmalloc(nbytes * sizeof(char)); if (buf == NULL) goto out; /* read */ - if (H5Aread(aid,tid,buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* compute the string length which will fit into the user's buffer */ - copy_len = MIN(size-1, nbytes); + copy_len = MIN(size - 1, nbytes); /* copy all/some of the name */ if (name) { HDmemcpy(name, buf, copy_len); /* terminate the string */ - name[copy_len]='\0'; + name[copy_len] = '\0'; } /* close */ @@ -1837,11 +1853,13 @@ H5DSget_scale_name(hid_t did, char *name, size_t size) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; if (buf) HDfree(buf); return FAIL; @@ -1860,99 +1878,100 @@ H5DSget_scale_name(hid_t did, char *name, size_t size) * *------------------------------------------------------------------------- */ -htri_t H5DSis_scale(hid_t did) +htri_t +H5DSis_scale(hid_t did) { - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - herr_t attr_class; /* has the "CLASS" attribute */ - htri_t is_ds = -1; /* set to "not a dimension scale" */ - H5I_type_t it; /* type of identifier */ - char *buf = NULL; /* buffer to read name of attribute */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + herr_t attr_class; /* has the "CLASS" attribute */ + htri_t is_ds = -1; /* set to "not a dimension scale" */ + H5I_type_t it; /* type of identifier */ + char * buf = NULL; /* buffer to read name of attribute */ size_t string_size; /* size of storage for the attribute */ H5T_class_t type_class; H5T_str_t strpad; /*------------------------------------------------------------------------ - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ if ((it = H5Iget_type(did)) < 0) goto out; - if(H5I_DATASET != it) + if (H5I_DATASET != it) goto out; /* try to find the attribute "CLASS" on the dataset */ - if((attr_class = H5LT_find_attribute(did, "CLASS")) < 0) + if ((attr_class = H5LT_find_attribute(did, "CLASS")) < 0) goto out; - if(attr_class == 0) { + if (attr_class == 0) { is_ds = 0; goto out; } - else - { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + else { + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - /* check to make sure attribute is a string; + /* check to make sure attribute is a string; if not, then it is not dimension scale */ - if((type_class = H5Tget_class(tid)) < 0) + if ((type_class = H5Tget_class(tid)) < 0) goto out; - if(H5T_STRING != type_class) { + if (H5T_STRING != type_class) { is_ds = 0; goto out; } - /* check to make sure string is null-terminated; + /* check to make sure string is null-terminated; if not, then it is not dimension scale */ - if((strpad = H5Tget_strpad(tid)) < 0 ) + if ((strpad = H5Tget_strpad(tid)) < 0) goto out; - if(H5T_STR_NULLTERM != strpad) { + if (H5T_STR_NULLTERM != strpad) { is_ds = 0; goto out; } - /* According to Spec string is ASCII and its size should be 16 to hold + /* According to Spec string is ASCII and its size should be 16 to hold "DIMENSION_SCALE" string */ - if((string_size = H5Tget_size(tid)) == 0) - goto out; - if(string_size != 16) { - is_ds = 0; + if ((string_size = H5Tget_size(tid)) == 0) + goto out; + if (string_size != 16) { + is_ds = 0; goto out; } - buf = (char*)HDmalloc((size_t)string_size * sizeof(char)); - if(buf == NULL) + buf = (char *)HDmalloc((size_t)string_size * sizeof(char)); + if (buf == NULL) goto out; /* Read the attribute */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; /* compare strings */ - if(HDstrncmp(buf, DIMENSION_SCALE_CLASS, - MIN(HDstrlen(DIMENSION_SCALE_CLASS),HDstrlen(buf)))==0) + if (HDstrncmp(buf, DIMENSION_SCALE_CLASS, MIN(HDstrlen(DIMENSION_SCALE_CLASS), HDstrlen(buf))) == 0) is_ds = 1; HDfree(buf); - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; if (H5Aclose(aid) < 0) goto out; } out: - if(is_ds < 0) { + if (is_ds < 0) { HDfree(buf); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; } return is_ds; } @@ -1976,84 +1995,84 @@ int H5DSget_num_scales(hid_t did, unsigned int idx) { int has_dimlist; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + hid_t sid; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ int nscales; /*------------------------------------------------------------------------- - * parameter checking - *------------------------------------------------------------------------- - */ + * parameter checking + *------------------------------------------------------------------------- + */ /* get ID type */ - if((it = H5Iget_type(did)) < 0) + if ((it = H5Iget_type(did)) < 0) return FAIL; - if(H5I_DATASET != it) + if (H5I_DATASET != it) return FAIL; /*------------------------------------------------------------------------- - * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist - *------------------------------------------------------------------------- - */ + * the attribute "DIMENSION_LIST" on the >>data<< dataset must exist + *------------------------------------------------------------------------- + */ /* get dataset space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) return FAIL; /* get rank */ - if((rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* close dataset space */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* dimemsion index IDX range checking */ - if(idx >= (unsigned int )rank) + if (idx >= (unsigned int)rank) return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ - if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) + if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; /* it does not exist */ - if(has_dimlist == 0) + if (has_dimlist == 0) return 0; /*------------------------------------------------------------------------- - * the attribute exists, open it - *------------------------------------------------------------------------- - */ + * the attribute exists, open it + *------------------------------------------------------------------------- + */ else { - if((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; - if((sid = H5Aget_space(aid)) < 0) + if ((sid = H5Aget_space(aid)) < 0) goto out; /* allocate and initialize the VL */ buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); - if(buf == NULL) + if (buf == NULL) goto out; /* read */ - if(H5Aread(aid, tid, buf) < 0) + if (H5Aread(aid, tid, buf) < 0) goto out; nscales = (int)buf[idx].len; /* close */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) + if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; HDfree(buf); buf = NULL; @@ -2063,13 +2082,15 @@ H5DSget_num_scales(hid_t did, unsigned int idx) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; - if(buf) + if (buf) HDfree(buf); return FAIL; @@ -2091,51 +2112,50 @@ H5DSget_num_scales(hid_t did, unsigned int idx) static herr_t H5DS_is_reserved(hid_t did) { - int has_class; - hid_t tid = -1; - hid_t aid = -1; - char *buf; /* Name of attribute */ + int has_class; + hid_t tid = -1; + hid_t aid = -1; + char * buf; /* Name of attribute */ hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + herr_t ret; /* try to find the attribute "CLASS" on the dataset */ - if((has_class = H5LT_find_attribute(did, "CLASS")) < 0) + if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0) return -1; - if(has_class == 0) + if (has_class == 0) return 0; - assert(has_class == 1); - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + assert(has_class == 1); + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((tid = H5Aget_type(aid)) < 0) + if ((tid = H5Aget_type(aid)) < 0) goto out; /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(tid)) - goto out; + if (H5T_STRING != H5Tget_class(tid)) + goto out; /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(tid)) - goto out; + if (H5T_STR_NULLTERM != H5Tget_strpad(tid)) + goto out; /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - buf = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(buf == NULL) - goto out; + buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (buf == NULL) + goto out; /* Read the attribute */ - if(H5Aread(aid, tid, buf) < 0) - goto out; - + if (H5Aread(aid, tid, buf) < 0) + goto out; - if(HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(buf))) == 0 || - HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(buf))) == 0 || - HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS),HDstrlen(buf))) == 0 ) + if (HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(buf))) == 0 || + HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(buf))) == 0 || + HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS), HDstrlen(buf))) == 0) ret = 1; else ret = 0; @@ -2148,7 +2168,6 @@ H5DS_is_reserved(hid_t did) if (H5Aclose(aid) < 0) goto out; - return ret; /* error zone */ @@ -2157,7 +2176,8 @@ H5DS_is_reserved(hid_t did) { H5Tclose(tid); H5Aclose(aid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } @@ -2184,20 +2204,21 @@ H5DS_get_REFLIST_type(void) used to store ds_list_t structure in the REFERENCE_LIST attribute */ - if((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) + if ((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) goto out; - if(H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t,ref), H5T_STD_REF_OBJ) < 0) + if (H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) goto out; - if(H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) + if (H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) goto out; return ntid_t; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(ntid_t); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; } - diff --git a/hl/src/H5DSprivate.h b/hl/src/H5DSprivate.h index 9d20d4837c0..0403a4cbe30 100644 --- a/hl/src/H5DSprivate.h +++ b/hl/src/H5DSprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DSprivate_H -#define _H5DSprivate_H +#ifndef H5DSprivate_H +#define H5DSprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -20,21 +20,15 @@ /* public LT prototypes */ #include "H5DSpublic.h" - - - /* attribute type of a DS dataset */ typedef struct ds_list_t { - hobj_ref_t ref; /* object reference */ - unsigned int dim_idx; /* dimension index of the dataset */ + hobj_ref_t ref; /* object reference */ + unsigned int dim_idx; /* dimension index of the dataset */ } ds_list_t; - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ - #endif - diff --git a/hl/src/H5DSpublic.h b/hl/src/H5DSpublic.h index 615122cb7c1..7306cbc85ea 100644 --- a/hl/src/H5DSpublic.h +++ b/hl/src/H5DSpublic.h @@ -6,69 +6,45 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DSpublic_H -#define _H5DSpublic_H - - +#ifndef H5DSpublic_H +#define H5DSpublic_H #define DIMENSION_SCALE_CLASS "DIMENSION_SCALE" #define DIMENSION_LIST "DIMENSION_LIST" #define REFERENCE_LIST "REFERENCE_LIST" #define DIMENSION_LABELS "DIMENSION_LABELS" - -typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); - +typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); #ifdef __cplusplus extern "C" { #endif -H5_HLDLL herr_t H5DSattach_scale( hid_t did, - hid_t dsid, - unsigned int idx); - -H5_HLDLL herr_t H5DSdetach_scale( hid_t did, - hid_t dsid, - unsigned int idx); - -H5_HLDLL herr_t H5DSset_scale( hid_t dsid, - const char *dimname); +H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx); -H5_HLDLL int H5DSget_num_scales( hid_t did, - unsigned int dim); +H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx); -H5_HLDLL herr_t H5DSset_label( hid_t did, - unsigned int idx, - const char *label); +H5_HLDLL herr_t H5DSset_scale(hid_t dsid, const char *dimname); -H5_HLDLL ssize_t H5DSget_label( hid_t did, - unsigned int idx, - char *label, - size_t size); +H5_HLDLL int H5DSget_num_scales(hid_t did, unsigned int dim); -H5_HLDLL ssize_t H5DSget_scale_name( hid_t did, - char *name, - size_t size); +H5_HLDLL herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label); -H5_HLDLL htri_t H5DSis_scale( hid_t did); +H5_HLDLL ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size); -H5_HLDLL herr_t H5DSiterate_scales( hid_t did, - unsigned int dim, - int *idx, - H5DS_iterate_t visitor, - void *visitor_data); +H5_HLDLL ssize_t H5DSget_scale_name(hid_t did, char *name, size_t size); -H5_HLDLL htri_t H5DSis_attached( hid_t did, - hid_t dsid, - unsigned int idx); +H5_HLDLL htri_t H5DSis_scale(hid_t did); +H5_HLDLL herr_t H5DSiterate_scales(hid_t did, unsigned int dim, int *idx, H5DS_iterate_t visitor, + void *visitor_data); +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 45591e8c3d3..c696b773260 100644 --- a/hl/src/H5HLprivate2.h +++ b/hl/src/H5HLprivate2.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5HLprivate2_H -#define _H5HLprivate2_H +#ifndef H5HLprivate2_H +#define H5HLprivate2_H /* Public HDF5 header */ #include "hdf5.h" @@ -23,5 +23,4 @@ /* HDF5 private functions */ #include "H5private.h" -#endif /* _H5HLprivate2_H */ - +#endif /* H5HLprivate2_H */ diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 2b292dc8879..ff10d573c7c 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -1,45 +1,43 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5IMprivate.h" #include "H5LTprivate.h" /*------------------------------------------------------------------------- -* Function: H5IMmake_image_8bit -* -* Purpose: Creates and writes an image an 8 bit image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_image_8bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const unsigned char *buf ) + * Function: H5IMmake_image_8bit + * + * Purpose: Creates and writes an image an 8 bit image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const unsigned char *buf) { - hsize_t dims[IMAGE8_RANK]; + hsize_t dims[IMAGE8_RANK]; /* check the arguments */ if (dset_name == NULL) @@ -50,56 +48,53 @@ herr_t H5IMmake_image_8bit( hid_t loc_id, dims[1] = width; /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) + if (H5LTmake_dataset(loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf) < 0) return -1; /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) return -1; /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) return -1; /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5IMmake_image_24bit -* -* Purpose: -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Interlace Mode Dimensions in the Dataspace -* INTERLACE_PIXEL [height][width][pixel components] -* INTERLACE_PLANE [pixel components][height][width] -* -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_image_24bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - const unsigned char *buf ) + * Function: H5IMmake_image_24bit + * + * Purpose: + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Interlace Mode Dimensions in the Dataspace + * INTERLACE_PIXEL [height][width][pixel components] + * INTERLACE_PLANE [pixel components][height][width] + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_image_24bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, + const char *interlace, const unsigned char *buf) { - hsize_t dims[IMAGE24_RANK]; + hsize_t dims[IMAGE24_RANK]; /* check the arguments */ if (interlace == NULL) @@ -107,73 +102,66 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, if (dset_name == NULL) return -1; - /* Initialize the image dimensions */ - if ( HDstrncmp( interlace, "INTERLACE_PIXEL",15 ) == 0 ) - { + if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) { /* Number of color planes is defined as the third dimension */ dims[0] = height; dims[1] = width; dims[2] = IMAGE24_RANK; } + else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) { + /* Number of color planes is defined as the first dimension */ + dims[0] = IMAGE24_RANK; + dims[1] = height; + dims[2] = width; + } else - if ( HDstrncmp( interlace, "INTERLACE_PLANE",15 ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - dims[0] = IMAGE24_RANK; - dims[1] = height; - dims[2] = width; - } - else return -1; - - /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) - return -1; + return -1; - /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) - return -1; + /* Make the dataset */ + if (H5LTmake_dataset(loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf) < 0) + return -1; - /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) - return -1; + /* Attach the CLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) + return -1; - /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0) - return -1; + /* Attach the VERSION attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) + return -1; - /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0) - return -1; + /* Attach the IMAGE_SUBCLASS attribute */ + if (H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0) + return -1; - return 0; + /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ + if (H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0) + return -1; + return 0; } - - /*------------------------------------------------------------------------- -* Function: find_palette -* -* Purpose: operator function used by H5LT_find_palette -* -* Return: -* -* Programmer: Pedro Vicente Nunes -* -* Date: May 28, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static herr_t find_palette(hid_t loc_id, - const char *name, - const H5A_info_t *ainfo, - void *op_data) + * Function: find_palette + * + * Purpose: operator function used by H5LT_find_palette + * + * Return: + * + * Programmer: Pedro Vicente Nunes + * + * Date: May 28, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +find_palette(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo, + H5_ATTR_UNUSED void *op_data) { int ret = H5_ITER_CONT; @@ -182,93 +170,90 @@ static herr_t find_palette(hid_t loc_id, return -1; /* Shut compiler up */ - loc_id = loc_id; ainfo = ainfo; op_data = op_data; + (void)loc_id; + (void)ainfo; + (void)op_data; /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - if(HDstrncmp(name, "PALETTE",7) == 0) + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ + if (HDstrncmp(name, "PALETTE", 7) == 0) ret = H5_ITER_STOP; return ret; } - /*------------------------------------------------------------------------- -* Function: H5IM_find_palette -* -* Purpose: Private function. Find the attribute "PALETTE" in the image dataset -* -* Return: Success: 1, Failure: 0 -* -* Programmer: Pedro Vicente Nunes -* -* Date: May 11, 2001 -* -* Comments: -* The function uses H5Aiterate2 with the operator function find_palette -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IM_find_palette( hid_t loc_id ) + * Function: H5IM_find_palette + * + * Purpose: Private function. Find the attribute "PALETTE" in the image dataset + * + * Return: Success: 1, Failure: 0 + * + * Programmer: Pedro Vicente Nunes + * + * Date: May 11, 2001 + * + * Comments: + * The function uses H5Aiterate2 with the operator function find_palette + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IM_find_palette(hid_t loc_id) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_palette, NULL); } - /*------------------------------------------------------------------------- -* Function: H5IMget_image_info -* -* Purpose: Gets information about an image dataset (dimensions, interlace mode -* and number of associated palettes). -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: July 25, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_image_info( hid_t loc_id, - const char *dset_name, - hsize_t *width, - hsize_t *height, - hsize_t *planes, - char *interlace, - hssize_t *npals ) + * Function: H5IMget_image_info + * + * Purpose: Gets information about an image dataset (dimensions, interlace mode + * and number of associated palettes). + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: July 25, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_image_info(hid_t loc_id, const char *dset_name, hsize_t *width, hsize_t *height, hsize_t *planes, + char *interlace, hssize_t *npals) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t sid = -1; hsize_t dims[IMAGE24_RANK]; - hid_t aid = -1; - hid_t asid = -1; - hid_t atid = -1; + hid_t aid = -1; + hid_t asid = -1; + hid_t atid = -1; H5T_class_t aclass; int has_pal; int has_attr; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; if (interlace == NULL) - return -1; + return -1; /*assume initially we have no palettes attached*/ *npals = 0; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */ @@ -276,58 +261,55 @@ herr_t H5IMget_image_info( hid_t loc_id, goto out; /* It exists, get it */ - if(has_attr == 1) - { + if (has_attr == 1) { - if((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Aread(aid, atid, interlace) < 0) + if (H5Aread(aid, atid, interlace) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* Get the dataspace handle */ - if ( (sid = H5Dget_space( did )) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* Initialize the image dimensions */ - if ( has_attr == 1 ) - /* This is a 24 bit image */ + if (has_attr == 1) + /* This is a 24 bit image */ { - if ( HDstrncmp( interlace, "INTERLACE_PIXEL", 15 ) == 0 ) - { + if (HDstrncmp(interlace, "INTERLACE_PIXEL", 15) == 0) { /* Number of color planes is defined as the third dimension */ *height = dims[0]; *width = dims[1]; *planes = dims[2]; } + else if (HDstrncmp(interlace, "INTERLACE_PLANE", 15) == 0) { + /* Number of color planes is defined as the first dimension */ + *planes = dims[0]; + *height = dims[1]; + *width = dims[2]; + } else - if ( HDstrncmp( interlace, "INTERLACE_PLANE", 15 ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - *planes = dims[0]; - *height = dims[1]; - *width = dims[2]; - } - else return -1; + return -1; } else - /* This is a 8 bit image */ + /* This is a 8 bit image */ { *height = dims[0]; *width = dims[1]; @@ -335,147 +317,135 @@ herr_t H5IMget_image_info( hid_t loc_id, } /* Close */ - if ( H5Sclose( sid ) < 0) + if (H5Sclose(sid) < 0) goto out; - /* Get number of palettes */ - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { + if (has_pal == 1) { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { + if (aclass == H5T_REFERENCE) { /* Get the reference(s) */ - if ( (asid = H5Aget_space( aid )) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; - *npals = H5Sget_simple_extent_npoints( asid ); + *npals = H5Sget_simple_extent_npoints(asid); - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - if(did > 0) - H5Dclose( did ); - if(aid > 0) - H5Aclose( aid ); - if(asid > 0) - H5Sclose( asid ); - if(atid > 0) - H5Tclose( atid ); + if (did > 0) + H5Dclose(did); + if (aid > 0) + H5Aclose(aid); + if (asid > 0) + H5Sclose(asid); + if (atid > 0) + H5Tclose(atid); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMread_image -* -* Purpose: Reads image data from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: June 13, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMread_image( hid_t loc_id, - const char *dset_name, - unsigned char *buf ) + * Function: H5IMread_image + * + * Purpose: Reads image data from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: June 13, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buf) { - hid_t did; + hid_t did; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Read */ - if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0) + if (H5Dread(did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) ) + if (H5Dclose(did)) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMmake_palette -* -* Purpose: Creates and writes a palette. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: May 01, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMmake_palette( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - const unsigned char *pal_data ) + * Function: H5IMmake_palette + * + * Purpose: Creates and writes a palette. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: May 01, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, const unsigned char *pal_data) { @@ -483,231 +453,221 @@ herr_t H5IMmake_palette( hid_t loc_id, /* check the arguments */ if (pal_name == NULL) - return -1; + return -1; /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + has_pal = H5LTfind_dataset(loc_id, pal_name); /* It exists. Return */ - if ( has_pal == 1 ) + if (has_pal == 1) return 0; /* Make the palette dataset. */ - if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 ) + if (H5LTmake_dataset(loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data) < 0) return -1; /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0) + if (H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0) return -1; /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0) + if (H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5IMlink_palette -* -* Purpose: This function attaches a palette to an existing image dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: May 01, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* An image (dataset) within an HDF5 file may optionally specify an array of -* palettes to be viewed with. The dataset will have an attribute -* which contains an array of object reference pointers which refer to palettes in the file. -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ) + * Function: H5IMlink_palette + * + * Purpose: This function attaches a palette to an existing image dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: May 01, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * An image (dataset) within an HDF5 file may optionally specify an array of + * palettes to be viewed with. The dataset will have an attribute + * which contains an array of object reference pointers which refer to palettes in the file. + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name) { hid_t did; - hid_t atid=-1; - hid_t aid=-1; - hid_t asid=-1; - hobj_ref_t ref; /* write a new reference */ - hobj_ref_t *refbuf; /* buffer to read references */ + hid_t atid = -1; + hid_t aid = -1; + hid_t asid = -1; + hobj_ref_t ref; /* write a new reference */ + hobj_ref_t *refbuf; /* buffer to read references */ hssize_t n_refs; hsize_t dim_ref; int ok_pal; - /* check the arguments */ if (image_name == NULL) - return -1; + return -1; if (pal_name == NULL) - return -1; + return -1; /* The image dataset may or may not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ /* First we get the image id */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - ok_pal = H5LT_find_attribute( did, "PALETTE" ); + ok_pal = H5LT_find_attribute(did, "PALETTE"); /*------------------------------------------------------------------------- - * It does not exist. We create the attribute and one reference - *------------------------------------------------------------------------- - */ - if(ok_pal == 0 ) - { - if((asid = H5Screate(H5S_SCALAR)) < 0) + * It does not exist. We create the attribute and one reference + *------------------------------------------------------------------------- + */ + if (ok_pal == 0) { + if ((asid = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the attribute type for the reference */ - if((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0) + if ((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0) goto out; /* Create the attribute "PALETTE" to be attached to the image*/ - if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Create a reference. The reference is created on the local id. */ - if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) + if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; /* Write the attribute with the reference */ - if(H5Awrite(aid, atid, &ref) < 0) + if (H5Awrite(aid, atid, &ref) < 0) goto out; /* close */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - } /*------------------------------------------------------------------------- - * The attribute already exists, open it - *------------------------------------------------------------------------- - */ - else if(ok_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + * The attribute already exists, open it + *------------------------------------------------------------------------- + */ + else if (ok_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get and save the old reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs + 1; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* The attribute must be deleted, in order to the new one can reflect the changes*/ - if(H5Adelete(did, "PALETTE") < 0) + if (H5Adelete(did, "PALETTE") < 0) goto out; /* Create a new reference for this palette. */ - if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1 ) < 0) + if (H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; refbuf[n_refs] = ref; /* Create the data space for the new references */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0) + if ((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0) goto out; /* Create the attribute again with the changes of space */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute with the new references */ - if(H5Awrite(aid, atid, refbuf) < 0) + if (H5Awrite(aid, atid, refbuf) < 0) goto out; /* close */ - if(H5Sclose(asid) < 0) + if (H5Sclose(asid) < 0) goto out; - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); + HDfree(refbuf); } /* ok_pal == 1 */ /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; } - - /*------------------------------------------------------------------------- -* Function: H5IMunlink_palette -* -* Purpose: This function dettaches a palette from an existing image dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: September 10, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMunlink_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 + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: September 10, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name) { hid_t did; hid_t atid; @@ -716,98 +676,94 @@ herr_t H5IMunlink_palette( hid_t loc_id, int ok_pal, has_pal; /* check the arguments */ - if(image_name == NULL) - return -1; - if(pal_name == NULL) - return -1; + if (image_name == NULL) + return -1; + if (pal_name == NULL) + return -1; /* Try to find the palette dataset */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + has_pal = H5LTfind_dataset(loc_id, pal_name); /* It does not exist. Return */ - if ( has_pal == 0 ) + if (has_pal == 0) return -1; /* The image dataset may or not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ /* First we get the image id */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ ok_pal = H5LT_find_attribute(did, "PALETTE"); /* It does not exist. Nothing to do */ - if(ok_pal == 0) + if (ok_pal == 0) return -1; /* The attribute exists, open it */ - else if(ok_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + else if (ok_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { + if (aclass == H5T_REFERENCE) { /* Delete the attribute */ - if(H5Adelete(did, "PALETTE") < 0) + if (H5Adelete(did, "PALETTE") < 0) goto out; - } /* H5T_REFERENCE */ + } /* H5T_REFERENCE */ - if(H5Tclose(atid) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; } /* ok_pal */ /* Close the image dataset. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; } - /*------------------------------------------------------------------------- -* Function: H5IMget_npalettes -* -* Purpose: Gets the number of palettes associated to an image -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: July 22, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_npalettes( hid_t loc_id, - const char *image_name, - hssize_t *npals ) + * Function: H5IMget_npalettes + * + * Purpose: Gets the number of palettes associated to an image + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: July 22, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals) { hid_t did; hid_t atid; @@ -817,495 +773,469 @@ herr_t H5IMget_npalettes( hid_t loc_id, int has_pal; /* check the arguments */ - if(image_name == NULL) - return -1; + if (image_name == NULL) + return -1; /*assume initially we have no palettes attached*/ *npals = 0; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { + if (has_pal == 1) { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if((aclass = H5Tget_class(atid)) < 0) + if ((aclass = H5Tget_class(atid)) < 0) goto out; /* Check if it is really a reference */ - if(aclass == H5T_REFERENCE) - { - if((asid = H5Aget_space(aid)) < 0) + if (aclass == H5T_REFERENCE) { + if ((asid = H5Aget_space(aid)) < 0) goto out; - *npals = H5Sget_simple_extent_npoints( asid ); + *npals = H5Sget_simple_extent_npoints(asid); - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMget_palette_info -* -* Purpose: Get palette information -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: July 22, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_palette_info( hid_t loc_id, - const char *image_name, - int pal_number, - hsize_t *pal_dims ) + * Function: H5IMget_palette_info + * + * Purpose: Get palette information + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: July 22, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims) { - hid_t did; - int has_pal; - hid_t atid=-1; - hid_t aid; - hid_t asid=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; - hid_t pal_space_id; - hsize_t pal_maxdims[2]; + hid_t did; + int has_pal; + hid_t atid = -1; + hid_t aid; + hid_t asid = -1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; + hid_t pal_space_id; + hsize_t pal_maxdims[2]; /* check the arguments */ if (image_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if (has_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get the reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* Get the actual palette */ - if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) + if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) goto out; - if ( (pal_space_id = H5Dget_space( pal_id )) < 0) + if ((pal_space_id = H5Dget_space(pal_id)) < 0) goto out; - if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0) + if (H5Sget_simple_extent_ndims(pal_space_id) < 0) goto out; - if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0) + if (H5Sget_simple_extent_dims(pal_space_id, pal_dims, pal_maxdims) < 0) goto out; /* close */ - if (H5Dclose(pal_id)<0) + if (H5Dclose(pal_id) < 0) goto out; - if ( H5Sclose( pal_space_id ) < 0) + if (H5Sclose(pal_space_id) < 0) goto out; - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); - - + HDfree(refbuf); } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5IMget_palette -* -* Purpose: Read palette -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente Nunes -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMget_palette( hid_t loc_id, - const char *image_name, - int pal_number, - unsigned char *pal_data ) + * Function: H5IMget_palette + * + * Purpose: Read palette + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente Nunes + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, unsigned char *pal_data) { - hid_t did; - int has_pal; - hid_t atid=-1; - hid_t aid; - hid_t asid=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; + hid_t did; + int has_pal; + hid_t atid = -1; + hid_t aid; + hid_t asid = -1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; /* check the arguments */ if (image_name == NULL) - return -1; + return -1; if (pal_data == NULL) - return -1; - + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { - if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + if (has_pal == 1) { + if ((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - if(H5Tget_class(atid) < 0) + if (H5Tget_class(atid) < 0) goto out; /* Get the reference(s) */ - if((asid = H5Aget_space(aid)) < 0) + if ((asid = H5Aget_space(aid)) < 0) goto out; n_refs = H5Sget_simple_extent_npoints(asid); dim_ref = (hsize_t)n_refs; - refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (size_t)dim_ref ); + refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * (size_t)dim_ref); - if ( H5Aread( aid, atid, refbuf ) < 0) + if (H5Aread(aid, atid, refbuf) < 0) goto out; /* Get the palette id */ - if ( (pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) + if ((pal_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0) goto out; /* Read the palette dataset */ - if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0) + if (H5Dread(pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) goto out; /* close */ - if (H5Dclose(pal_id)<0) + if (H5Dclose(pal_id) < 0) goto out; - if ( H5Sclose( asid ) < 0) + if (H5Sclose(asid) < 0) goto out; - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - HDfree( refbuf ); + HDfree(refbuf); } /* Close the image dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return 0; out: - H5Dclose( did ); - H5Sclose( asid ); - H5Tclose( atid ); - H5Aclose( aid ); + H5Dclose(did); + H5Sclose(asid); + H5Tclose(atid); + H5Aclose(aid); return -1; - } /*------------------------------------------------------------------------- -* Function: H5IMis_image -* -* Purpose: -* -* Return: true, false, fail -* -* Programmer: Pedro Vicente Nunes -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMis_image( hid_t loc_id, - const char *dset_name ) + * Function: H5IMis_image + * + * Purpose: + * + * Return: true, false, fail + * + * Programmer: Pedro Vicente Nunes + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMis_image(hid_t loc_id, const char *dset_name) { - hid_t did; - int has_class; - hid_t atid; - hid_t aid = -1; - char* attr_data; /* Name of attribute */ - hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid = -1; + char * attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ + herr_t ret; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Assume initially fail condition */ ret = -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { + if (has_class == 0) { H5Dclose(did); return 0; } - else if(has_class == 1) - { + else if (has_class == 1) { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(atid)) - goto out; + /* check to make sure attribute is a string */ + if (H5T_STRING != H5Tget_class(atid)) + goto out; - /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) - goto out; + /* check to make sure string is null-terminated */ + if (H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; - /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + /* allocate buffer large enough to hold string */ + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(attr_data == NULL) - goto out; + attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (attr_data == NULL) + goto out; - if(H5Aread(aid, atid, attr_data) < 0) + if (H5Aread(aid, atid, attr_data) < 0) goto out; - if(HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS),HDstrlen(attr_data))) == 0) + if (HDstrncmp(attr_data, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; - HDfree(attr_data); + HDfree(attr_data); - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return ret; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } /*------------------------------------------------------------------------- -* Function: H5IMis_palette -* -* Purpose: -* -* Return: true, false, fail -* -* Programmer: Pedro Vicente Nunes -* -* Date: August 30, 2001 -* -* Comments: -* based on HDF5 Image and Palette Specification -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - -herr_t H5IMis_palette( hid_t loc_id, - const char *dset_name ) + * Function: H5IMis_palette + * + * Purpose: + * + * Return: true, false, fail + * + * Programmer: Pedro Vicente Nunes + * + * Date: August 30, 2001 + * + * Comments: + * based on HDF5 Image and Palette Specification + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5IMis_palette(hid_t loc_id, const char *dset_name) { - hid_t did; - int has_class; - hid_t atid; - hid_t aid = -1; - char* attr_data; /* Name of attribute */ - hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid = -1; + char * attr_data; /* Name of attribute */ + hsize_t storage_size; /* Size of storage for attribute */ + herr_t ret; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Assume initially fail condition */ ret = -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { - H5Dclose( did ); + if (has_class == 0) { + H5Dclose(did); return 0; } - else if(has_class == 1) - { + else if (has_class == 1) { - if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) goto out; - if((atid = H5Aget_type(aid)) < 0) + if ((atid = H5Aget_type(aid)) < 0) goto out; - /* check to make sure attribute is a string */ - if(H5T_STRING != H5Tget_class(atid)) - goto out; + /* check to make sure attribute is a string */ + if (H5T_STRING != H5Tget_class(atid)) + goto out; - /* check to make sure string is null-terminated */ - if(H5T_STR_NULLTERM != H5Tget_strpad(atid)) - goto out; + /* check to make sure string is null-terminated */ + if (H5T_STR_NULLTERM != H5Tget_strpad(atid)) + goto out; - /* allocate buffer large enough to hold string */ - if((storage_size = H5Aget_storage_size(aid)) == 0) - goto out; + /* allocate buffer large enough to hold string */ + if ((storage_size = H5Aget_storage_size(aid)) == 0) + goto out; - attr_data = (char*)HDmalloc( (size_t)storage_size * sizeof(char) + 1); - if(attr_data == NULL) - goto out; + attr_data = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + if (attr_data == NULL) + goto out; - if(H5Aread(aid, atid, attr_data) < 0) + if (H5Aread(aid, atid, attr_data) < 0) goto out; - if(HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS),HDstrlen(attr_data))) == 0) + if (HDstrncmp(attr_data, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(attr_data))) == 0) ret = 1; else ret = 0; - HDfree(attr_data); + HDfree(attr_data); - if ( H5Tclose( atid ) < 0) + if (H5Tclose(atid) < 0) goto out; - if ( H5Aclose( aid ) < 0) + if (H5Aclose(aid) < 0) goto out; - } /* Close the dataset. */ - if ( H5Dclose( did ) < 0) + if (H5Dclose(did) < 0) return -1; return ret; out: - H5Dclose( did ); + H5Dclose(did); return -1; - } - diff --git a/hl/src/H5IMprivate.h b/hl/src/H5IMprivate.h index 6776c9d562d..3570ea3352e 100644 --- a/hl/src/H5IMprivate.h +++ b/hl/src/H5IMprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5IMprivate_H -#define _H5IMprivate_H +#ifndef H5IMprivate_H +#define H5IMprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -20,20 +20,16 @@ /* public IM prototypes */ #include "H5IMpublic.h" - #define IMAGE_CLASS "IMAGE" #define PALETTE_CLASS "PALETTE" #define IMAGE_VERSION "1.2" -#define IMAGE8_RANK 2 -#define IMAGE24_RANK 3 - +#define IMAGE8_RANK 2 +#define IMAGE24_RANK 3 /*------------------------------------------------------------------------- * Private functions *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id ); - +H5_HLDLL herr_t H5IM_find_palette(hid_t loc_id); #endif - diff --git a/hl/src/H5IMpublic.h b/hl/src/H5IMpublic.h index a95e4398555..2843942e13d 100644 --- a/hl/src/H5IMpublic.h +++ b/hl/src/H5IMpublic.h @@ -6,77 +6,46 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5IMpublic_H -#define _H5IMpublic_H - +#ifndef H5IMpublic_H +#define H5IMpublic_H #ifdef __cplusplus extern "C" { #endif +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); + +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); + +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); + +H5_HLDLL herr_t H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buffer); + +H5_HLDLL herr_t H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, + const unsigned char *pal_data); + +H5_HLDLL herr_t H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); + +H5_HLDLL herr_t H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); + +H5_HLDLL herr_t H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals); + +H5_HLDLL herr_t H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims); + +H5_HLDLL herr_t H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, + unsigned char *pal_data); + +H5_HLDLL herr_t H5IMis_image(hid_t loc_id, const char *dset_name); -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 ); - -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 ); - -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 ); - -H5_HLDLL herr_t H5IMread_image( hid_t loc_id, - const char *dset_name, - unsigned char *buffer ); - -H5_HLDLL herr_t H5IMmake_palette( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - const unsigned char *pal_data ); - -H5_HLDLL herr_t H5IMlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ); - -H5_HLDLL herr_t H5IMunlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ); - -H5_HLDLL herr_t H5IMget_npalettes( hid_t loc_id, - const char *image_name, - hssize_t *npals ); - -H5_HLDLL herr_t H5IMget_palette_info( hid_t loc_id, - const char *image_name, - int pal_number, - hsize_t *pal_dims ); - -H5_HLDLL herr_t H5IMget_palette( hid_t loc_id, - const char *image_name, - int pal_number, - unsigned char *pal_data ); - -H5_HLDLL herr_t H5IMis_image( hid_t loc_id, - const char *dset_name ); - -H5_HLDLL herr_t H5IMis_palette( hid_t loc_id, - const char *dset_name ); +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 21975d17390..8bfd0d682f4 100644 --- a/hl/src/H5LD.c +++ b/hl/src/H5LD.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by 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 * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5LDprivate.h" @@ -22,10 +22,9 @@ static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid); static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims); static size_t H5LD_get_dset_type_size(hid_t did, const char *fields); -static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, - const hsize_t *cur_dims, const char *fields, void *buf); +static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, + const char *fields, void *buf); - /*------------------------------------------------------------------------- * Function: H5LD_clean_vector * @@ -43,30 +42,29 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, void H5LD_clean_vector(H5LD_memb_t *listv[]) { - unsigned n; /* Local index variable */ + unsigned n; /* Local index variable */ HDassert(listv); /* Go through info for each field stored in listv[] */ - for(n = 0; listv[n] != NULL; n++) { - if(listv[n]->names) { - HDfree(listv[n]->names); - listv[n]->names = NULL; - } /* end if */ - - /* Close the type id of the last member in the field */ - if(!(listv[n]->last_tid < 0)) { - H5Tclose(listv[n]->last_tid); - listv[n]->last_tid = -1; - } /* end if */ - - /* Free the H5LD_memb_t structure for the field */ - HDfree(listv[n]); - listv[n] = NULL; + for (n = 0; listv[n] != NULL; n++) { + if (listv[n]->names) { + HDfree(listv[n]->names); + listv[n]->names = NULL; + } /* end if */ + + /* Close the type id of the last member in the field */ + if (!(listv[n]->last_tid < 0)) { + H5Tclose(listv[n]->last_tid); + listv[n]->last_tid = -1; + } /* end if */ + + /* Free the H5LD_memb_t structure for the field */ + HDfree(listv[n]); + listv[n] = NULL; } /* end for */ } /* H5LD_clean_vector() */ - /*------------------------------------------------------------------------- * Function: H5LD_construct_info() * @@ -85,27 +83,27 @@ H5LD_clean_vector(H5LD_memb_t *listv[]) static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) { - hid_t tmp_tid = -1; /* Dataset type id */ - unsigned i; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hid_t tmp_tid = -1; /* Dataset type id */ + unsigned i; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* Make a copy of the incoming datatype */ tmp_tid = H5Tcopy(par_tid); /* Validate all the members in a field */ - for(i = 0; memb->names[i] != NULL; i++) { - hid_t memb_tid; /* Type id for a member in a field */ - int idx; /* Index # of a member in a compound datatype */ + for (i = 0; memb->names[i] != NULL; i++) { + hid_t memb_tid; /* Type id for a member in a field */ + int idx; /* Index # of a member in a compound datatype */ /* Get the member index and member type id */ - if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0) + if ((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0) goto done; - if((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) + if ((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) goto done; - /* Sum up the offset of all the members in the field */ + /* Sum up the offset of all the members in the field */ memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx); - if(H5Tclose(tmp_tid) < 0) + if (H5Tclose(tmp_tid) < 0) goto done; tmp_tid = memb_tid; } /* end for */ @@ -121,13 +119,12 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) done: H5E_BEGIN_TRY - H5Tclose(tmp_tid); + H5Tclose(tmp_tid); H5E_END_TRY - return(ret_value); + return (ret_value); } /* H5LD_construct_info() */ - /*------------------------------------------------------------------------- * Function: H5LD_construct_vector * @@ -153,84 +150,87 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) * * Programmer: Vailin Choi; Aug 2010 * -*------------------------------------------------------------------------- -*/ + *------------------------------------------------------------------------- + */ int -H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) +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" */ - int ret_value = FAIL; /* Return value */ + int nfields; /* The # of comma-separated fields in "fields" */ + hbool_t end_of_fields = FALSE; /* end of "fields" */ + char * fields_ptr; /* Pointer to "fields" */ + int ret_value = FAIL; /* Return value */ HDassert(listv); HDassert(fields); fields_ptr = fields; - nfields = 0; + nfields = 0; /* 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 */ - 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 */ - hbool_t valid = TRUE; /* Whether a field being processed is valid or not */ - int j = 0; /* The # of members in a field */ - - len = (HDstrlen(fields_ptr) / 2) + 2; - - /* Allocate memory for an H5LD_memb_t for storing a field's info */ - if(NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t)))) - goto done; - - /* Allocate memory for an array of pointers to member names */ - if(NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *)))) - goto done; - - memb->names[j] = fields_ptr; - memb->last_tid = -1; - cur = fields_ptr; - - /* Continue processing till: not valid or comma encountered or "fields" ended */ - while(valid && !gotcomma && !end_of_fields) { - switch(*fields_ptr) { - case '\0': /* end of list */ - if(gotmember) { /* getting something and end of "fields" */ - *cur++ = '\0';; + 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 */ + 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 */ + hbool_t valid = TRUE; /* Whether a field being processed is valid or not */ + int j = 0; /* The # of members in a field */ + + len = (HDstrlen(fields_ptr) / 2) + 2; + + /* Allocate memory for an H5LD_memb_t for storing a field's info */ + if (NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t)))) + goto done; + + /* Allocate memory for an array of pointers to member names */ + if (NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *)))) + goto done; + + memb->names[j] = fields_ptr; + memb->last_tid = -1; + cur = fields_ptr; + + /* Continue processing till: not valid or comma encountered or "fields" ended */ + while (valid && !gotcomma && !end_of_fields) { + switch (*fields_ptr) { + case '\0': /* end of list */ + if (gotmember) { /* getting something and end of "fields" */ + *cur++ = '\0'; + ; memb->names[++j] = NULL; - } /* end if */ + } /* end if */ else /* getting nothing but end of list */ valid = FALSE; end_of_fields = TRUE; break; - case '\\': /* escape character */ + case '\\': /* escape character */ ++fields_ptr; /* skip it */ - if(*fields_ptr == '\0') + if (*fields_ptr == '\0') valid = FALSE; else { - *cur++ = *fields_ptr++; + *cur++ = *fields_ptr++; gotmember = TRUE; } /* end else */ break; case '.': /* nested field separator */ - *fields_ptr++ = *cur++ = '\0';; - if(gotmember) { + *fields_ptr++ = *cur++ = '\0'; + ; + if (gotmember) { memb->names[++j] = cur; - gotmember = FALSE; + gotmember = FALSE; } /* end if */ else valid = FALSE; break; case ',': /* field separator */ - *fields_ptr++ = *cur++ = '\0';; - if(gotmember) { + *fields_ptr++ = *cur++ = '\0'; + ; + if (gotmember) { memb->names[++j] = NULL; - gotmember = FALSE; + gotmember = FALSE; } /* end if */ else valid = FALSE; @@ -238,37 +238,36 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) break; default: - *cur++ = *fields_ptr++; + *cur++ = *fields_ptr++; gotmember = TRUE; break; - } /* end switch */ - } /* while (valid && !gotcomma && !end_of_fields) */ - - /* If valid, put into listv and continue processing further info */ - if(valid) { - listv[nfields++] = memb; - if(H5LD_construct_info(memb, par_tid) < 0) - goto done; - } /* end if */ + } /* end switch */ + } /* while (valid && !gotcomma && !end_of_fields) */ + + /* If valid, put into listv and continue processing further info */ + if (valid) { + listv[nfields++] = memb; + if (H5LD_construct_info(memb, par_tid) < 0) + goto done; + } /* end if */ else { - if(memb) + if (memb) HDfree(memb); - goto done; - } /* end else */ - } /* while !end_of_fields */ + goto done; + } /* end else */ + } /* while !end_of_fields */ /* Indicate success */ ret_value = nfields; done: listv[nfields] = NULL; - if(ret_value == FAIL) - H5LD_clean_vector(listv); + if (ret_value == FAIL) + H5LD_clean_vector(listv); - return(ret_value); -} /* H5LD_construct_vector() */ + return (ret_value); +} /* H5LD_construct_vector() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_dims * @@ -280,38 +279,39 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid) * * Programmer: Vailin Choi; March 2010 * -*------------------------------------------------------------------------- -*/ + *------------------------------------------------------------------------- + */ static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims) { - hid_t sid = -1; /* Dataspace ID */ - herr_t ret_value = FAIL; /* Return Value */ + hid_t sid = -1; /* Dataspace ID */ + herr_t ret_value = FAIL; /* Return Value */ /* Verify parameter */ - if(cur_dims == NULL) + if (cur_dims == NULL) goto done; /* Get the dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto done; /* Get the current dimension size */ - if(H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0) goto done; /* Indicate success */ ret_value = SUCCEED; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; - return(ret_value); + return (ret_value); } /* H5LD_get_dset_dims() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_type_size * @@ -330,73 +330,72 @@ H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims) static size_t 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" */ - size_t ret_value = 0; /* Return value */ + 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" */ + size_t ret_value = 0; /* Return value */ /* Get the datatype of the dataset */ - if((dset_tid = H5Dget_type(did)) < 0) + if ((dset_tid = H5Dget_type(did)) < 0) goto done; - if((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0) + if ((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0) goto done; - if(fields == NULL) /* If no "fields" is specified */ + if (fields == NULL) /* If no "fields" is specified */ ret_value = H5Tget_size(tid); - else { /* "fields" are specified */ - size_t len; /* Estimate the number of comma-separated fields in "fields" */ - size_t tot = 0; /* Data type size of all the fields in "fields" */ - int n = 0, num = 0; /* Local index variables */ + else { /* "fields" are specified */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + size_t tot = 0; /* Data type size of all the fields in "fields" */ + int n = 0, num = 0; /* Local index variables */ HDassert(fields && *fields); /* Should be a compound datatype if "fields" exists */ - if(H5Tget_class(dset_tid) != H5T_COMPOUND) + if (H5Tget_class(dset_tid) != H5T_COMPOUND) goto done; - /* Get a copy of "fields" */ - if(NULL == (dup_fields = HDstrdup(fields))) + /* Get a copy of "fields" */ + if (NULL == (dup_fields = HDstrdup(fields))) goto done; - /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */ - len = (HDstrlen(fields) / 2) + 2; - if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) + /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */ + len = (HDstrlen(fields) / 2) + 2; + if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) goto done; - /* Process and store info for "fields" */ - if((num = H5LD_construct_vector(dup_fields, listv/*OUT*/, tid)) < 0) + /* Process and store info for "fields" */ + if ((num = H5LD_construct_vector(dup_fields, listv /*OUT*/, tid)) < 0) goto done; - /* Sum up the size of all the datatypes in "fields" */ - for(n = 0; n < num; n++) - tot += listv[n]->last_tsize; + /* Sum up the size of all the datatypes in "fields" */ + for (n = 0; n < num; n++) + tot += listv[n]->last_tsize; - /* Clean up the vector of H5LD_memb_t structures */ - H5LD_clean_vector(listv); + /* Clean up the vector of H5LD_memb_t structures */ + H5LD_clean_vector(listv); - /* Return the total size */ - ret_value = tot; + /* Return the total size */ + ret_value = tot; } /* end else */ done: H5E_BEGIN_TRY - H5Tclose(tid); - H5Tclose(dset_tid); + H5Tclose(tid); + H5Tclose(dset_tid); H5E_END_TRY /* Free the array of H5LD_memb_t pointers */ - if(listv) + if (listv) HDfree(listv); /* Free memory */ - if(dup_fields) + if (dup_fields) HDfree(dup_fields); - return(ret_value); + return (ret_value); } /* H5LD_get_dset_type_size() */ - /*------------------------------------------------------------------------- * Function: H5LD_get_dset_elmts * @@ -410,136 +409,136 @@ H5LD_get_dset_type_size(hid_t did, const char *fields) *------------------------------------------------------------------------- */ static herr_t -H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, - const char *fields, void *buf) +H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, + void *buf) { - hid_t dtid = -1, tid = -1; /* Dataset type id */ - hid_t sid = -1, mid = -1; /* Dataspace and memory space id */ - hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */ - hsize_t num_elmts; /* Number of dataset elements in the selection */ - 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 */ - unsigned ctr; /* Counter for # of curr_dims > prev_dims */ - int ndims; /* Number of dimensions for the dataset */ - int i; /* Local index variable */ - herr_t ret_value = FAIL; /* Return value */ + hid_t dtid = -1, tid = -1; /* Dataset type id */ + hid_t sid = -1, mid = -1; /* Dataspace and memory space id */ + hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */ + hsize_t num_elmts; /* Number of dataset elements in the selection */ + 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 */ + unsigned ctr; /* Counter for # of curr_dims > prev_dims */ + int ndims; /* Number of dimensions for the dataset */ + int i; /* Local index variable */ + herr_t ret_value = FAIL; /* Return value */ /* Verify parameters */ - if(prev_dims == NULL || cur_dims == NULL || buf == NULL) - goto done; + if (prev_dims == NULL || cur_dims == NULL || buf == NULL) + goto done; /* Get dataset's dataspace */ - if((sid = H5Dget_space(did)) < 0) - goto done; + if ((sid = H5Dget_space(did)) < 0) + goto done; /* Get the number of dimensions */ - if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) - goto done; + if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + goto done; /* Verify that cur_dims must have one dimension whose size is greater than prev_dims */ HDmemset(start, 0, sizeof start); HDmemset(count, 0, sizeof count); ctr = 0; - for(i = 0; i < ndims; i++) - if(cur_dims[i] > prev_dims[i]) { - ++ctr; - count[i] = cur_dims[i] - prev_dims[i]; - start[i] = prev_dims[i]; - } /* end if */ + for (i = 0; i < ndims; i++) + if (cur_dims[i] > prev_dims[i]) { + ++ctr; + count[i] = cur_dims[i] - prev_dims[i]; + start[i] = prev_dims[i]; + } /* end if */ else { /* < or = */ - start[i] = 0; - count[i] = MIN(prev_dims[i], cur_dims[i]); - } /* end else */ - if(!ctr) - goto done; - - if(ctr == 1) { /* changes for only one dimension */ - /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - goto done; - } /* end if */ + start[i] = 0; + count[i] = MIN(prev_dims[i], cur_dims[i]); + } /* end else */ + if (!ctr) + goto done; + + if (ctr == 1) { /* changes for only one dimension */ + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + goto done; + } /* end if */ else { /* changes for more than one dimensions */ - HDmemset(start, 0, sizeof start); + HDmemset(start, 0, sizeof start); - /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0) - goto done; - if(H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0) - goto done; + /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */ + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0) + goto done; + if (H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0) + goto done; } /* end else */ /* Get the number of elements in the selection */ - if(0 == (snum_elmts = H5Sget_select_npoints(sid))) + if (0 == (snum_elmts = H5Sget_select_npoints(sid))) goto done; num_elmts = (hsize_t)snum_elmts; /* Create the memory space for the selection */ - if((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0) - goto done; + if ((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0) + goto done; /* Get the native datatype size */ - if((dtid = H5Dget_type(did)) < 0) + if ((dtid = H5Dget_type(did)) < 0) goto done; - if((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) + if ((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) goto done; - if(fields == NULL) { /* nothing in "fields" */ - /* Read and store all the elements in "buf" */ - if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0) - goto done; - } /* 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 */ - size_t tot_tsize; /* Total datatype size */ - size_t len; /* Estimate the number of comma-separated fields in "fields" */ - - /* should be a compound datatype if "fields" exists */ - if(H5Tget_class(tid) != H5T_COMPOUND) - goto done; - - /* Get the total size of the dataset's datatypes */ - if(0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL))) - goto done; - - /* Allocate memory for reading in the elements in the dataset selection */ - if(NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize))) - goto done; - - /* Read the dataset elements in the selection */ - if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0) - goto done; - - /* Make a copy of "fields" */ - if(NULL == (dup_fields = HDstrdup(fields))) - goto done; - - /* Allocate memory for the vector of H5LD_memb_t pointers */ - len = (HDstrlen(fields) / 2) + 2; - if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) - goto done; - - /* Process and store information for "fields" */ - if(H5LD_construct_vector(dup_fields, listv, tid) < 0) + if (fields == NULL) { /* nothing in "fields" */ + /* Read and store all the elements in "buf" */ + if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0) + goto done; + } /* 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 */ + size_t tot_tsize; /* Total datatype size */ + size_t len; /* Estimate the number of comma-separated fields in "fields" */ + + /* should be a compound datatype if "fields" exists */ + if (H5Tget_class(tid) != H5T_COMPOUND) goto done; - /* Copy data for each dataset element in the selection */ - for(i = 0; i < (int)num_elmts; i++) { - int j; /* Local index variable */ + /* Get the total size of the dataset's datatypes */ + if (0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL))) + goto done; - /* Copy data for "fields" to the input buffer */ - for(j = 0; listv[j] != NULL; j++) { - HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize); - buf_p += listv[j]->last_tsize; - } /* end for */ - tmp_buf += tot_tsize; - } /* end for */ + /* Allocate memory for reading in the elements in the dataset selection */ + if (NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize))) + goto done; + + /* Read the dataset elements in the selection */ + if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0) + goto done; + + /* Make a copy of "fields" */ + if (NULL == (dup_fields = HDstrdup(fields))) + goto done; - /* Clean up the vector of H5LD_memb_t structures */ - H5LD_clean_vector(listv); + /* Allocate memory for the vector of H5LD_memb_t pointers */ + len = (HDstrlen(fields) / 2) + 2; + if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *)))) + goto done; + + /* Process and store information for "fields" */ + if (H5LD_construct_vector(dup_fields, listv, tid) < 0) + goto done; + + /* Copy data for each dataset element in the selection */ + for (i = 0; i < (int)num_elmts; i++) { + int j; /* Local index variable */ + + /* Copy data for "fields" to the input buffer */ + for (j = 0; listv[j] != NULL; j++) { + HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize); + buf_p += listv[j]->last_tsize; + } /* end for */ + tmp_buf += tot_tsize; + } /* end for */ + + /* Clean up the vector of H5LD_memb_t structures */ + H5LD_clean_vector(listv); } /* end else */ /* Indicate success */ @@ -547,23 +546,23 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims done: H5E_BEGIN_TRY - H5Tclose(dtid); - H5Tclose(tid); - H5Sclose(sid); - H5Sclose(mid); + H5Tclose(dtid); + H5Tclose(tid); + H5Sclose(sid); + H5Sclose(mid); H5E_END_TRY /* Free the array of H5LD_memb_t pointers */ - if(listv) + if (listv) HDfree(listv); /* Free memory */ - if(dup_fields) + if (dup_fields) HDfree(dup_fields); - if(sav_buf) + if (sav_buf) HDfree(sav_buf); - return(ret_value); + return (ret_value); } /* H5LD_get_dset_elmts() */ /*------------------------------------------------------------------------- @@ -573,7 +572,6 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5LDget_dset_dims * @@ -589,11 +587,9 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) { - return(H5LD_get_dset_dims(did, cur_dims)); + return (H5LD_get_dset_dims(did, cur_dims)); } /* H5LDget_dset_dims() */ - - /*------------------------------------------------------------------------- * Function: H5LDget_dset_type_size * @@ -609,10 +605,9 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) size_t H5LDget_dset_type_size(hid_t did, const char *fields) { - return(H5LD_get_dset_type_size(did, fields)); + return (H5LD_get_dset_type_size(did, fields)); } /* H5LDget_dset_type_size() */ - /*------------------------------------------------------------------------- * Function: H5LDget_dset_elmts * @@ -626,8 +621,8 @@ H5LDget_dset_type_size(hid_t did, const char *fields) *------------------------------------------------------------------------- */ herr_t -H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf) +H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, + void *buf) { - return(H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf) ); + return (H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf)); } /* H5LDget_dset_elmts() */ - diff --git a/hl/src/H5LDprivate.h b/hl/src/H5LDprivate.h index 203bceab8c9..862e5b7d98c 100644 --- a/hl/src/H5LDprivate.h +++ b/hl/src/H5LDprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5LDprivate_H -#define _H5LDprivate_H +#ifndef H5LDprivate_H +#define H5LDprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -26,7 +26,7 @@ typedef struct H5LD_memb_t { size_t tot_offset; size_t last_tsize; - hid_t last_tid; + hid_t last_tid; char **names; } H5LD_memb_t; @@ -44,11 +44,10 @@ extern "C" { * Decide to do #3 at this point of time after some discussion. */ H5_HLDLL void H5LD_clean_vector(H5LD_memb_t *listv[]); -H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid); +H5_HLDLL int H5LD_construct_vector(char *fields, H5LD_memb_t *listv[], hid_t par_tid); #ifdef __cplusplus } #endif -#endif /* end _H5LDprivate_H */ - +#endif /* end H5LDprivate_H */ diff --git a/hl/src/H5LDpublic.h b/hl/src/H5LDpublic.h index e2bb74573ea..011b208e4cb 100644 --- a/hl/src/H5LDpublic.h +++ b/hl/src/H5LDpublic.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5LDpublic_H -#define _H5LDpublic_H +#ifndef H5LDpublic_H +#define H5LDpublic_H #ifdef __cplusplus extern "C" { @@ -20,12 +20,11 @@ extern "C" { H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims); H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields); -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); +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); #ifdef __cplusplus } #endif -#endif /* _H5LDpublic_H */ - +#endif /* H5LDpublic_H */ diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 55b1b9e462e..fb507e7d792 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1,28 +1,27 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by 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 * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5LTprivate.h" /* For Lex and Yacc */ -#define COL 3 -#define LIMIT 512 -#define INCREMENT 1024 -#define TMP_LEN 256 -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -size_t input_len; -char *myinput; -size_t indent = 0; - +#define COL 3 +#define LIMIT 512 +#define INCREMENT 1024 +#define TMP_LEN 256 +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +size_t input_len; +char * myinput; +size_t indent = 0; /* File Image operations @@ -58,58 +57,58 @@ size_t indent = 0; /* Data structure to pass application data to callbacks. */ typedef struct { - 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 */ - 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 */ - 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 */ - /* be open */ - int ref_count; /* Reference counter on udata struct */ + 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 */ + 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 */ + 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 */ + /* be open */ + int ref_count; /* Reference counter on udata 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, void *udata); -static void *image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); +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 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. */ - -/*------------------------------------------------------------------------- -* Function: image_malloc -* -* Purpose: Simulates malloc() function to avoid copying file images. -* The application buffer is set to the buffer on only one FAPL. -* Then the FAPL buffer can be copied to other FAPL buffers or -* to only one VFD buffer. -* -* Return: Address of "allocated" buffer, if successful. Otherwise, it returns -* NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_malloc + * + * Purpose: Simulates malloc() function to avoid copying file images. + * The application buffer is set to the buffer on only one FAPL. + * Then the FAPL buffer can be copied to other FAPL buffers or + * to only one VFD buffer. + * + * Return: Address of "allocated" buffer, if successful. Otherwise, it returns + * NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ 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; + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch ( file_image_op ) { + switch (file_image_op) { /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (udata->app_image_ptr == NULL) @@ -123,13 +122,13 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) if (udata->fapl_ref_count != 0) goto out; - udata->fapl_image_ptr = udata->app_image_ptr; + udata->fapl_image_ptr = udata->app_image_ptr; udata->fapl_image_size = udata->app_image_size; - return_value = udata->fapl_image_ptr; + return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; - break; + break; - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: if (udata->fapl_image_ptr == NULL) goto out; if (udata->fapl_image_size != size) @@ -139,7 +138,7 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) return_value = udata->fapl_image_ptr; udata->fapl_ref_count++; - break; + break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: goto out; @@ -159,48 +158,46 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) if (udata->fapl_ref_count == 0) goto out; - udata->vfd_image_ptr = udata->fapl_image_ptr; - udata->vfd_image_size = size; + udata->vfd_image_ptr = udata->fapl_image_ptr; + udata->vfd_image_size = size; udata->vfd_ref_count++; return_value = udata->vfd_image_ptr; break; - /* added unused labels to shut the compiler up */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ - return(return_value); + return (return_value); out: return NULL; } /* end image_malloc() */ - -/*------------------------------------------------------------------------- -* Function: image_memcpy -* -* Purpose: Simulates memcpy() function to avoid copying file images. -* The image buffer can be set to only one FAPL buffer, and -* "copied" to only one VFD buffer. The FAPL buffer can be -* "copied" to other FAPLs buffers. -* -* Return: The address of the destination buffer, if successful. Otherwise, it -* returns NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_memcpy + * + * Purpose: Simulates memcpy() function to avoid copying file images. + * The image buffer can be set to only one FAPL buffer, and + * "copied" to only one VFD buffer. The FAPL buffer can be + * "copied" to other FAPLs buffers. + * + * Return: The address of the destination buffer, if successful. Otherwise, it + * returns NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * -image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, - void *_udata) +image_memcpy(void *dest, const void *src, 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; @@ -208,7 +205,7 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch(file_image_op) { + switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: if (dest != udata->fapl_image_ptr) goto out; @@ -251,42 +248,41 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file goto out; break; - /* added unused labels to shut the compiler up */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - case H5FD_FILE_IMAGE_OP_FILE_CLOSE: + /* added unused labels to shut the compiler up */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + case H5FD_FILE_IMAGE_OP_FILE_CLOSE: default: goto out; } /* end switch */ - return(dest); + return (dest); out: return NULL; } /* end image_memcpy() */ - -/*------------------------------------------------------------------------- -* Function: image_realloc -* -* Purpose: Reallocates the shared application image buffer and updates data -* structures that manage buffer "copying". -* -* Return: Address of reallocated buffer, if successful. Otherwise, it returns -* NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: image_realloc + * + * Purpose: Reallocates the shared application image buffer and updates data + * structures that manage buffer "copying". + * + * Return: Address of reallocated buffer, if successful. Otherwise, it returns + * NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ 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; + H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; + void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) @@ -313,33 +309,32 @@ image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void * goto out; udata->vfd_image_size = size; - return_value = udata->vfd_image_ptr; + return_value = udata->vfd_image_ptr; } /* end if */ else goto out; - return(return_value); + return (return_value); out: return NULL; } /* end image_realloc() */ - /*------------------------------------------------------------------------- -* Function: image_free -* -* Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing -* reference counters. Shared application buffer is actually -* deallocated if there are no outstanding references. -* -* Return: SUCCEED or FAIL -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ + * Function: image_free + * + * Purpose: Simulates deallocation of FAPL and VFD buffers by decreasing + * reference counters. Shared application buffer is actually + * deallocated if there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) { @@ -349,22 +344,23 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - switch(file_image_op) { + switch (file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - if (udata->fapl_image_ptr != ptr) + if (udata->fapl_image_ptr != ptr) goto out; if (udata->fapl_ref_count == 0) goto out; udata->fapl_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && - !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->fapl_image_ptr); - udata->app_image_ptr = NULL; + udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; - udata->vfd_image_ptr = NULL; + udata->vfd_image_ptr = NULL; } /* end if */ break; @@ -376,49 +372,49 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) udata->vfd_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding + * references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && - !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { + !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->vfd_image_ptr); - udata->app_image_ptr = NULL; + udata->app_image_ptr = NULL; udata->fapl_image_ptr = NULL; - udata->vfd_image_ptr = NULL; + udata->vfd_image_ptr = NULL; } /* end if */ break; - /* added unused labels to keep the compiler quite */ - case H5FD_FILE_IMAGE_OP_NO_OP: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: - case H5FD_FILE_IMAGE_OP_FILE_OPEN: - case H5FD_FILE_IMAGE_OP_FILE_RESIZE: - default: + /* added unused labels to keep the compiler quite */ + case H5FD_FILE_IMAGE_OP_NO_OP: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: + case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET: + case H5FD_FILE_IMAGE_OP_FILE_OPEN: + case H5FD_FILE_IMAGE_OP_FILE_RESIZE: + default: goto out; } /* end switch */ - return(SUCCEED); + return (SUCCEED); out: - return(FAIL); + return (FAIL); } /* end image_free() */ - -/*------------------------------------------------------------------------- -* Function: udata_copy -* -* Purpose: Simulates the copying of the user data structure utilized in the -* management of the "copying" of file images. -* -* Return: Address of "newly allocated" structure, if successful. Otherwise, it -* returns NULL. -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ +/*------------------------------------------------------------------------- + * Function: udata_copy + * + * Purpose: Simulates the copying of the user data structure utilized in the + * management of the "copying" of file images. + * + * Return: Address of "newly allocated" structure, if successful. Otherwise, it + * returns NULL. + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static void * udata_copy(void *_udata) { @@ -432,28 +428,27 @@ udata_copy(void *_udata) udata->ref_count++; - return(udata); + return (udata); out: return NULL; } /* end udata_copy */ - /*------------------------------------------------------------------------- -* Function: udata_free -* -* Purpose: Simulates deallocation of the user data structure utilized in the -* management of the "copying" of file images. The data structure is -* actually deallocated when there are no outstanding references. -* -* Return: SUCCEED or FAIL -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ + * Function: udata_free + * + * Purpose: Simulates deallocation of the user data structure utilized in the + * management of the "copying" of file images. The data structure is + * actually deallocated when there are no outstanding references. + * + * Return: SUCCEED or FAIL + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ static herr_t udata_free(void *_udata) { @@ -468,409 +463,370 @@ udata_free(void *_udata) udata->ref_count--; /* checks that there are no references outstanding before deallocating udata */ - if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && - udata->vfd_ref_count == 0) + if (udata->ref_count == 0 && udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0) HDfree(udata); - return(SUCCEED); + return (SUCCEED); out: - return(FAIL); + return (FAIL); } /* end udata_free */ /* End of callbacks definitions for file image operations */ /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ -static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data); - -/*------------------------------------------------------------------------- -* Function: H5LT_make_dataset -* -* Purpose: Creates and writes a dataset of a type tid -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Quincey Koziol -* -* Date: October 10, 2007 -* -*------------------------------------------------------------------------- -*/ + * + * internal functions + * + *------------------------------------------------------------------------- + */ +static herr_t H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, + hid_t mem_type_id, void *data); + +/*------------------------------------------------------------------------- + * Function: H5LT_make_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Quincey Koziol + * + * Date: October 10, 2007 + * + *------------------------------------------------------------------------- + */ static herr_t -H5LT_make_dataset_numerical( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) +H5LT_make_dataset_numerical(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) { - hid_t did = -1, sid = -1; + hid_t did = -1, sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Create the data space for the dataset. */ - if((sid = H5Screate_simple(rank, dims, NULL)) < 0) + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; /* Create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ - if(data) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (data) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; /* Terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- -* -* Public functions -* -*------------------------------------------------------------------------- -*/ + * + * Public functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset -* -* Purpose: Creates and writes a dataset of a type tid -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 19, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset + * + * Purpose: Creates and writes a dataset of a type tid + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 19, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) +herr_t +H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t tid, + const void *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_char -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTmake_dataset_char + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_char( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const char *data ) +herr_t +H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_short -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_short + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_short( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const short *data ) +herr_t +H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_int -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_INT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_int + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_int( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const int *data ) +herr_t +H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); } - - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_long -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_long + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_long( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const long *data ) +herr_t +H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_float -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_float + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_float( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const float *data ) +herr_t +H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); } - - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_double -* -* Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 14, 2001 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_double + * + * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 14, 2001 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_double( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const double *data ) +herr_t +H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const double *data) { - return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); + return (H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTmake_dataset_string -* -* Purpose: Creates and writes a dataset of H5T_C_S1 type -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: October 05, 2004 -* -* Comments: -* -* Modifications: -* -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTmake_dataset_string + * + * Purpose: Creates and writes a dataset of H5T_C_S1 type + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: October 05, 2004 + * + * Comments: + * + * Modifications: + * + * + *------------------------------------------------------------------------- + */ -herr_t H5LTmake_dataset_string(hid_t loc_id, - const char *dset_name, - const char *buf ) +herr_t +H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf) { - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - size_t size; + hid_t did = -1; + hid_t sid = -1; + hid_t tid = -1; + size_t size; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* create a string data type */ - if((tid = H5Tcopy(H5T_C_S1)) < 0 ) + if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; size = HDstrlen(buf) + 1; /* extra null term */ - if(H5Tset_size(tid, size) < 0) + if (H5Tset_size(tid, size) < 0) goto out; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; /* Create the data space for the dataset. */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the dataset only if there is data to write */ - if(buf) - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close*/ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - -/*------------------------------------------------------------------------- -* Function: H5LTopen_file_image -* -* Purpose: Open a user supplied file image using the core file driver. -* -* Return: File identifier, Failure: -1 -* -* Programmer: Christian Chilan -* -* Date: October 3, 2011 -* -*------------------------------------------------------------------------- -*/ -hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) -{ - hid_t fapl=-1, file_id=-1; /* HDF5 identifiers */ - unsigned file_open_flags; /* Flags for image open */ - char file_name[64]; /* Filename buffer */ - size_t alloc_incr; /* Buffer allocation increment */ - size_t min_incr = 65536; /* Minimum buffer increment */ - double buf_prcnt = 0.1f; /* Percentage of buffer size to set - as increment */ - static long file_name_counter; - H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, - &image_realloc, &image_free, - &udata_copy, &udata_free, - (void *)NULL}; +/*------------------------------------------------------------------------- + * Function: H5LTopen_file_image + * + * Purpose: Open a user supplied file image using the core file driver. + * + * Return: File identifier, Failure: -1 + * + * Programmer: Christian Chilan + * + * Date: October 3, 2011 + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) +{ + hid_t fapl = -1, file_id = -1; /* HDF5 identifiers */ + unsigned file_open_flags; /* Flags for image open */ + char file_name[64]; /* Filename buffer */ + size_t alloc_incr; /* Buffer allocation increment */ + size_t min_incr = 65536; /* Minimum buffer increment */ + double buf_prcnt = 0.1; /* Percentage of buffer size to set + as increment */ + static long file_name_counter; + H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, &image_realloc, &image_free, + &udata_copy, &udata_free, (void *)NULL}; /* check arguments */ if (buf_ptr == NULL) @@ -898,33 +854,33 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) /* Set callbacks for file image ops ONLY if the file image is NOT copied */ if (flags & H5LT_FILE_IMAGE_DONT_COPY) { - H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ + H5LT_file_image_ud_t *udata; /* Pointer to udata structure */ /* Allocate buffer to communicate user data to callbacks */ if (NULL == (udata = (H5LT_file_image_ud_t *)HDmalloc(sizeof(H5LT_file_image_ud_t)))) goto out; /* Initialize udata with info about app buffer containing file image and flags */ - udata->app_image_ptr = buf_ptr; - udata->app_image_size = buf_size; - udata->fapl_image_ptr = NULL; + udata->app_image_ptr = buf_ptr; + udata->app_image_size = buf_size; + udata->fapl_image_ptr = NULL; udata->fapl_image_size = 0; - udata->fapl_ref_count = 0; - udata->vfd_image_ptr = NULL; - udata->vfd_image_size = 0; - udata->vfd_ref_count = 0; - udata->flags = flags; - udata->ref_count = 1; /* corresponding to the first FAPL */ + udata->fapl_ref_count = 0; + udata->vfd_image_ptr = NULL; + udata->vfd_image_size = 0; + udata->vfd_ref_count = 0; + udata->flags = flags; + udata->ref_count = 1; /* corresponding to the first FAPL */ /* copy address of udata into callbacks */ callbacks.udata = (void *)udata; /* Set file image callbacks */ - if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { + if (H5Pset_file_image_callbacks(fapl, &callbacks) < 0) { HDfree(udata); goto out; } /* end if */ - } /* end if */ + } /* end if */ /* Assign file image in user buffer to FAPL */ if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) @@ -951,46 +907,47 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) return file_id; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end H5LTopen_file_image() */ - /*------------------------------------------------------------------------- -* Function: H5LT_read_dataset -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Quincey Koziol -* -* Date: October 8, 2007 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_read_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Quincey Koziol + * + * Date: October 8, 2007 + * + *------------------------------------------------------------------------- + */ static herr_t H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { - hid_t did; + hid_t did; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Read */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto out; /* End access to the dataset and release resources used by it. */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; @@ -1001,513 +958,498 @@ H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: June 13, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: June 13, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset(hid_t loc_id, - const char *dset_name, - hid_t tid, - void *data) +herr_t +H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t tid, void *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, tid, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_char -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_char + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_char( hid_t loc_id, - const char *dset_name, - char *data ) +herr_t +H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_short -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_short + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_short( hid_t loc_id, - const char *dset_name, - short *data ) +herr_t +H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_int -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_int + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_int( hid_t loc_id, - const char *dset_name, - int *data ) +herr_t +H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_long -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_long + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_long( hid_t loc_id, - const char *dset_name, - long *data ) +herr_t +H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_float -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_float + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_float( hid_t loc_id, - const char *dset_name, - float *data ) +herr_t +H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_double -* -* Purpose: Reads a dataset from disk. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 5, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_double + * + * Purpose: Reads a dataset from disk. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 5, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_double( hid_t loc_id, - const char *dset_name, - double *data ) +herr_t +H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *data) { - return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); + return (H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); } - /*------------------------------------------------------------------------- -* Function: H5LTread_dataset_string -* -* Purpose: Reads a dataset -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: October 05, 2004 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTread_dataset_string + * + * Purpose: Reads a dataset + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: October 05, 2004 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTread_dataset_string( hid_t loc_id, - const char *dset_name, - char *buf ) +herr_t +H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf) { - hid_t did = -1; - hid_t tid = -1; + hid_t did = -1; + hid_t tid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* Read */ - if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Dclose(did)) + if (H5Dclose(did)) goto out; - if(H5Tclose(tid)) + if (H5Tclose(tid)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTget_dataset_ndims -* -* Purpose: Gets the dimensionality of a dataset. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_dataset_ndims + * + * Purpose: Gets the dimensionality of a dataset. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_dataset_ndims( hid_t loc_id, - const char *dset_name, - int *rank ) +herr_t +H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* Get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* Get rank */ - if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* End access to the dataset */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTget_dataset_info -* -* Purpose: Gets information about a dataset. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 4, 2001 -* Modified: February 28, 2006: checked for NULL parameters -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_dataset_info + * + * Purpose: Gets information about a dataset. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * Modified: February 28, 2006: checked for NULL parameters + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_dataset_info( hid_t loc_id, - const char *dset_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) +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) { - hid_t did = -1; - hid_t tid = -1; - hid_t sid = -1; + hid_t did = -1; + hid_t tid = -1; + hid_t sid = -1; /* check the arguments */ if (dset_name == NULL) - return -1; + return -1; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; /* get an identifier for the datatype. */ tid = H5Dget_type(did); /* get the class. */ - if(type_class != NULL) + if (type_class != NULL) *type_class = H5Tget_class(tid); /* get the size. */ - if(type_size!=NULL) + if (type_size != NULL) *type_size = H5Tget_size(tid); - if(dims != NULL) { + if (dims != NULL) { /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; } /* end if */ /* release the datatype. */ - if(H5Tclose(tid)) + if (H5Tclose(tid)) return -1; /* end access to the dataset */ - if(H5Dclose(did)) + if (H5Dclose(did)) return -1; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: find_dataset -* -* Purpose: operator function used by H5LTfind_dataset -* -* Programmer: Pedro Vicente -* -* Date: June 21, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: find_dataset + * + * Purpose: operator function used by H5LTfind_dataset + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ static herr_t -find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_data) +find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5L_info2_t *linfo, + void *op_data) { /* Define a default zero value for return. This will cause the iterator to continue if - * the dataset is not found yet. - */ + * the dataset is not found yet. + */ int ret = 0; /* check the arguments */ if (name == NULL) - return ret; + return ret; /* Shut the compiler up */ - loc_id = loc_id; - linfo = linfo; + (void)loc_id; + (void)linfo; /* Define a positive value for return value if the dataset was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - if(HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ + if (HDstrncmp(name, (char *)op_data, HDstrlen((char *)op_data)) == 0) ret = 1; return ret; } - /*------------------------------------------------------------------------- -* Function: H5LTfind_dataset -* -* Purpose: Inquires if a dataset named dset_name exists attached -* to the object loc_id. -* -* Programmer: Pedro Vicente -* -* Date: July 15, 2001 -* -* Return: -* Success: The return value of the first operator that -* returns non-zero, or zero if all members were -* processed with no operator returning non-zero. -* -* Failure: Negative if something goes wrong within the -* library, or the negative value returned by one -* of the operators. -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTfind_dataset + * + * Purpose: Inquires if a dataset named dset_name exists attached + * to the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: July 15, 2001 + * + * Return: + * Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ /* H5Literate 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.: dset_name) during the traversal, and the * library never modifies that buffer. */ -H5_GCC_DIAG_OFF(cast-qual) +H5_GCC_DIAG_OFF("cast-qual") herr_t -H5LTfind_dataset( hid_t loc_id, const char *dset_name ) +H5LTfind_dataset(hid_t loc_id, const char *dset_name) { - return H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); + return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } -H5_GCC_DIAG_ON(cast-qual) +H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- -* -* Set attribute functions -* -*------------------------------------------------------------------------- -*/ - + * + * Set attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_string -* -* Purpose: Creates and writes a string attribute named attr_name and attaches -* it to the object specified by the name obj_name. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: July 23, 2001 -* -* Comments: If the attribute already exists, it is overwritten -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_string + * + * Purpose: Creates and writes a string attribute named attr_name and attaches + * it to the object specified by the name obj_name. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: July 23, 2001 + * + * Comments: If the attribute already exists, it is overwritten + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *attr_data ) +herr_t +H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data) { - hid_t attr_type; - hid_t attr_space_id; - hid_t attr_id; - hid_t obj_id; - int has_attr; - size_t attr_size; + hid_t attr_type; + hid_t attr_space_id; + hid_t attr_id; + hid_t obj_id; + int has_attr; + size_t attr_size; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; if (attr_data == NULL) - return -1; + return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the attribute */ - if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 ) + if ((attr_type = H5Tcopy(H5T_C_S1)) < 0) goto out; - attr_size = HDstrlen( attr_data ) + 1; /* extra null term */ + attr_size = HDstrlen(attr_data) + 1; /* extra null term */ - if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 ) + if (H5Tset_size(attr_type, (size_t)attr_size) < 0) goto out; - if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 ) + if (H5Tset_strpad(attr_type, H5T_STR_NULLTERM) < 0) goto out; - if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 ) + if ((attr_space_id = H5Screate(H5S_SCALAR)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) + if (has_attr == 1) + if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create and write the attribute */ - if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, attr_type, attr_data) < 0) + if (H5Awrite(attr_id, attr_type, attr_data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - if(H5Sclose(attr_space_id) < 0) + if (H5Sclose(attr_space_id) < 0) goto out; - if(H5Tclose(attr_type) < 0) + if (H5Tclose(attr_type) < 0) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -1518,79 +1460,71 @@ herr_t H5LTset_attribute_string( hid_t loc_id, return -1; } - - - - /*------------------------------------------------------------------------- -* Function: H5LT_set_attribute_numerical -* -* Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: July 25, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LT_set_attribute_numerical + * + * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: July 25, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LT_set_attribute_numerical( hid_t loc_id, - const char *obj_name, - const char *attr_name, - size_t size, - hid_t tid, - const void *data ) +herr_t +H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, size_t size, + hid_t tid, const void *data) { - hid_t obj_id, sid, attr_id; - hsize_t dim_size=size; - int has_attr; + hid_t obj_id, sid, attr_id; + hsize_t dim_size = size; + int has_attr; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Create the data space for the attribute. */ - if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 ) + if ((sid = H5Screate_simple(1, &dim_size, NULL)) < 0) goto out; /* Verify if the attribute already exists */ has_attr = H5LT_find_attribute(obj_id, attr_name); /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) + if (has_attr == 1) + if (H5Adelete(obj_id, attr_name) < 0) goto out; /* Create the attribute. */ - if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute data. */ - if(H5Awrite(attr_id, tid, data) < 0) + if (H5Awrite(attr_id, tid, data) < 0) goto out; /* Close the attribute. */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; /* Close the dataspace. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -1600,562 +1534,500 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, return -1; } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_char -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_char + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *data, - size_t size ) +herr_t +H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, const char *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_CHAR, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_uchar -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_uchar + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned char *data, - size_t size ) +herr_t +H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UCHAR, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_short -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_short + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const short *data, - size_t size ) +herr_t +H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, const short *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_SHORT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_ushort -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_ushort + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned short *data, - size_t size ) +herr_t +H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned short *data, size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_USHORT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_int -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_int + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const int *data, - size_t size ) +herr_t +H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, const int *data, size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_INT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_INT, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_uint -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_uint + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned int *data, - size_t size ) +herr_t +H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UINT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_UINT, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_long -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long *data, - size_t size ) +herr_t +H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LONG, data) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_long_long -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Elena Pourmal -* -* Date: June 17, 2005 -* -* Comments: This function was added to support attributes of type long long -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_long_long + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Elena Pourmal + * + * Date: June 17, 2005 + * + * Comments: This function was added to support attributes of type long long + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long long *data, - size_t size ) +herr_t +H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LLONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_ulong -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_ulong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned long *data, - size_t size ) +herr_t +H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_ULONG, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_float -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: July 25, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTset_attribute_float + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: July 25, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const float *data, - size_t size ) +herr_t +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_FLOAT, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; - } - /*------------------------------------------------------------------------- -* Function: H5LTset_attribute_double -* -* Purpose: Create and write an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 7, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTset_attribute_double + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 7, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTset_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const double *data, - size_t size ) +herr_t +H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, + size_t size) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_DOUBLE, data ) < 0 ) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; - } - - /*------------------------------------------------------------------------- -* Function: find_attr -* -* Purpose: operator function used by H5LT_find_attribute -* -* Programmer: Pedro Vicente -* -* Date: June 21, 2001 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: find_attr + * + * Purpose: operator function used by H5LT_find_attribute + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ static herr_t -find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, +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; + return H5_ITER_CONT; /* Shut compiler up */ - loc_id = loc_id; ainfo = ainfo; + (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 - */ + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ - if(HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data),HDstrlen(name))) == 0) + if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0) ret = H5_ITER_STOP; return ret; } - /*------------------------------------------------------------------------- -* Function: H5LTfind_attribute -* -* Purpose: Inquires if an attribute named attr_name exists attached to -* the object loc_id. -* -* Programmer: Pedro Vicente -* -* Date: May 17, 2006 -* -* Comments: -* Calls the private version of the function -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTfind_attribute + * + * Purpose: Inquires if an attribute named attr_name exists attached to + * the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: May 17, 2006 + * + * Comments: + * Calls the private version of the function + * + *------------------------------------------------------------------------- + */ -herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) +herr_t +H5LTfind_attribute(hid_t loc_id, const char *attr_name) { - return H5LT_find_attribute(loc_id,attr_name); + return H5LT_find_attribute(loc_id, attr_name); } - - /*------------------------------------------------------------------------- -* Function: H5LT_find_attribute -* -* Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. -* -* Programmer: Pedro Vicente -* -* Date: June 21, 2001 -* -* Comments: -* The function uses H5Aiterate2 with the operator function find_attr -* -* Return: -* Success: The return value of the first operator that -* returns non-zero, or zero if all members were -* processed with no operator returning non-zero. -* -* Failure: Negative if something goes wrong within the -* library, or the negative value returned by one -* of the operators. -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_find_attribute + * + * Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. + * + * Programmer: Pedro Vicente + * + * Date: June 21, 2001 + * + * Comments: + * The function uses H5Aiterate2 with the operator function find_attr + * + * Return: + * Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ /* 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) +H5_GCC_DIAG_OFF("cast-qual") herr_t -H5LT_find_attribute( hid_t loc_id, const char* attr_name ) +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); } -H5_GCC_DIAG_ON(cast-qual) - - -/*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ndims -* -* Purpose: Gets the dimensionality of an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ +H5_GCC_DIAG_ON("cast-qual") + +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ndims + * + * Purpose: Gets the dimensionality of an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_ndims( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *rank ) +herr_t +H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank) { - hid_t attr_id; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t sid; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } /* Get the dataspace handle */ - if((sid = H5Aget_space(attr_id)) < 0) + if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get rank */ - if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + if ((*rank = H5Sget_simple_extent_ndims(sid)) < 0) goto out; /* Terminate access to the attribute */ - if ( H5Sclose( sid ) < 0 ) + if (H5Sclose(sid) < 0) goto out; /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) - goto out;; + if (H5Aclose(attr_id)) + goto out; + ; /* Close the object */ - if(H5Oclose(obj_id) < 0 ) + if (H5Oclose(obj_id) < 0) return -1; return 0; out: - H5Aclose( attr_id ); + H5Aclose(attr_id); H5Oclose(obj_id); return -1; - } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_info -* -* Purpose: Gets information about an attribute. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 4, 2001 -* -*------------------------------------------------------------------------- -*/ + * Function: H5LTget_attribute_info + * + * Purpose: Gets information about an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 4, 2001 + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_info( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) +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) { - hid_t attr_id; - hid_t tid; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t tid; + hid_t sid; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) { H5Oclose(obj_id); return -1; } @@ -2167,30 +2039,30 @@ herr_t H5LTget_attribute_info( hid_t loc_id, *type_class = H5Tget_class(tid); /* Get the size. */ - *type_size = H5Tget_size( tid ); + *type_size = H5Tget_size(tid); /* Get the dataspace handle */ - if ( (sid = H5Aget_space( attr_id )) < 0 ) + if ((sid = H5Aget_space(attr_id)) < 0) goto out; /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* Terminate access to the dataspace */ - if ( H5Sclose( sid ) < 0 ) + if (H5Sclose(sid) < 0) goto out; /* Release the datatype. */ - if ( H5Tclose( tid ) ) + if (H5Tclose(tid)) goto out; /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) + if (H5Aclose(attr_id)) goto out; /* Close the object */ - if(H5Oclose(obj_id) < 0 ) + if (H5Oclose(obj_id) < 0) return -1; return 0; @@ -2200,46 +2072,46 @@ herr_t H5LTget_attribute_info( hid_t loc_id, H5Aclose(attr_id); H5Oclose(obj_id); return -1; - } /*------------------------------------------------------------------------- -* Function: H5LTtext_to_dtype -* -* Purpose: Convert DDL description to HDF5 data type. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu -* -* Date: October 6, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) + * Function: H5LTtext_to_dtype + * + * Purpose: Convert DDL description to HDF5 data type. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: October 6, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) { - hid_t type_id; + hid_t type_id; /* check the arguments */ if (text == NULL) - return -1; + return -1; - if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; - if(lang_type != H5LT_DDL) { + if (lang_type != H5LT_DDL) { HDfprintf(stderr, "only DDL is supported for now.\n"); goto out; } input_len = HDstrlen(text); - myinput = HDstrdup(text); + myinput = HDstrdup(text); - if((type_id = H5LTyyparse()) < 0) { + if ((type_id = H5LTyyparse()) < 0) { HDfree(myinput); goto out; } @@ -2254,57 +2126,60 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) } /*------------------------------------------------------------------------- -* Function: realloc_and_append -* -* Purpose: Expand the buffer and append a string to it. -* -* Return: void -* -* Programmer: Raymond Lu -* -* Date: 29 September 2011 -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static char* + * Function: realloc_and_append + * + * Purpose: Expand the buffer and append a string to it. + * + * Return: void + * + * Programmer: Raymond Lu + * + * Date: 29 September 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static char * realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add) { size_t size_str_to_add, size_str; - if(_no_user_buf) { + if (_no_user_buf) { /* 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)) { + 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)) { + buf = (char *)HDrealloc(buf, *len); + } + else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; - buf = (char*)HDrealloc(buf, *len); + buf = (char *)HDrealloc(buf, *len); } } - if(!buf) - goto out; - - if(str_to_add) { - /* find the size of the buffer to add */ - size_str_to_add = HDstrlen(str_to_add); - /* find the size of the current buffer */ - size_str = HDstrlen(buf); - - /* Check to make sure the appended string does not - * extend past the allocated buffer; if it does then truncate the string - */ - if(size_str < *len - 1) { - if( size_str + size_str_to_add < *len - 1) { - HDstrncat(buf, str_to_add, size_str_to_add); - } else { - HDstrncat(buf, str_to_add, (*len - 1) - size_str); - } - } else { - buf[*len-1] = '\0'; /* buffer is full, null terminate */ - } + if (!buf) + goto out; + + if (str_to_add) { + /* find the size of the buffer to add */ + size_str_to_add = HDstrlen(str_to_add); + /* find the size of the current buffer */ + size_str = HDstrlen(buf); + + /* Check to make sure the appended string does not + * extend past the allocated buffer; if it does then truncate the string + */ + if (size_str < *len - 1) { + if (size_str + size_str_to_add < *len - 1) { + HDstrncat(buf, str_to_add, size_str_to_add); + } + else { + HDstrncat(buf, str_to_add, (*len - 1) - size_str); + } + } + else { + buf[*len - 1] = '\0'; /* buffer is full, null terminate */ + } } return buf; @@ -2314,32 +2189,33 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str } /*------------------------------------------------------------------------- -* Function: indentation -* -* Purpose: Print spaces for indentation -* -* Return: void -* -* Programmer: Raymond Lu -* -* Date: December 6, 2005 -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -static char* -indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len) + * Function: indentation + * + * Purpose: Print spaces for indentation + * + * Return: void + * + * Programmer: Raymond Lu + * + * Date: December 6, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static char * +indentation(size_t x, char *str, hbool_t no_u_buf, size_t *s_len) { - char tmp_str[TMP_LEN]; + char tmp_str[TMP_LEN]; if (x < 80) { HDmemset(tmp_str, ' ', x); - tmp_str[x]='\0'; - } else + tmp_str[x] = '\0'; + } + else HDsnprintf(tmp_str, TMP_LEN, "error: the indentation exceeds the number of cols."); - if(!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) + if (!(str = realloc_and_append(no_u_buf, s_len, str, tmp_str))) goto out; return str; @@ -2349,98 +2225,99 @@ indentation(size_t x, char* str, hbool_t no_u_buf, size_t *s_len) } /*------------------------------------------------------------------------- -* Function: print_enum -* -* Purpose: prints the enum data -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu -* -* Modifications: -* -*-----------------------------------------------------------------------*/ -static char* -print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) + * Function: print_enum + * + * Purpose: prints the enum data + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Modifications: + * + *-----------------------------------------------------------------------*/ +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 */ - unsigned char *value = NULL; /*value array */ - int nmembs; /*number of members */ - char tmp_str[TMP_LEN]; - int nchars; /*number of output characters */ - hid_t super = -1; /*enum base integer type */ - hid_t native = -1; /*native integer data type */ - size_t super_size; /*enum base type size */ - size_t dst_size; /*destination value type size */ - int i; + char ** name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + int nmembs; /*number of members */ + char tmp_str[TMP_LEN]; + int nchars; /*number of output characters */ + hid_t super = -1; /*enum base integer type */ + hid_t native = -1; /*native integer data type */ + size_t super_size; /*enum base type size */ + size_t dst_size; /*destination value type size */ + int i; - if((nmembs = H5Tget_nmembers(type))<=0) + if ((nmembs = H5Tget_nmembers(type)) <= 0) goto out; - if((super = H5Tget_super(type)) < 0) + if ((super = H5Tget_super(type)) < 0) goto out; /* Use buffer of INT or UNSIGNED INT to print enum values because - * we don't expect these values to be so big that INT or UNSIGNED - * INT can't hold. - */ + * we don't expect these values to be so big that INT or UNSIGNED + * INT can't hold. + */ if (H5T_SGN_NONE == H5Tget_sign(super)) { native = H5T_NATIVE_UINT; - } else { + } + else { native = H5T_NATIVE_INT; } super_size = H5Tget_size(super); - dst_size = H5Tget_size(native); + dst_size = H5Tget_size(native); /* Get the names and raw values of all members */ - name = (char**)HDcalloc((size_t)nmembs, sizeof(char *)); - value = (unsigned char*)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); + name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); + value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { - if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL) + if ((name[i] = H5Tget_member_name(type, (unsigned)i)) == NULL) goto out; - if(H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) + if (H5Tget_member_value(type, (unsigned)i, value + (size_t)i * super_size) < 0) goto out; } /* Convert values to native data type */ if (native > 0) { - if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) + if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) goto out; } /* - * Sort members by increasing value - * ***not implemented yet*** - */ + * Sort members by increasing value + * ***not implemented yet*** + */ /* Print members */ for (i = 0; i < nmembs; i++) { - if(!(str = indentation(indt + COL, str, no_ubuf, str_len))) + if (!(str = indentation(indt + COL, str, no_ubuf, str_len))) goto out; nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); tmp_str[MAX(3, 19 - nchars)] = '\0'; - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; if (H5T_SGN_NONE == H5Tget_sign(native)) HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); else HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; HDsnprintf(tmp_str, TMP_LEN, ";\n"); - if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) + if (!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; } /* Release resources */ - for(i = 0; i < nmembs; i++) + for (i = 0; i < nmembs; i++) H5free_memory(name[i]); HDfree(name); @@ -2451,71 +2328,73 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) out: - if(0 == nmembs) { + if (0 == nmembs) { str = realloc_and_append(no_ubuf, str_len, str, "\n"); HDassert((indt + 4) < TMP_LEN); HDmemset(tmp_str, ' ', (indt + 4) + 1); tmp_str[(indt + 4)] = '\0'; - str = realloc_and_append(no_ubuf, str_len, str, tmp_str); - str = realloc_and_append(no_ubuf, str_len, str, " "); + str = realloc_and_append(no_ubuf, str_len, str, tmp_str); + str = realloc_and_append(no_ubuf, str_len, str, " "); } /* end if */ /* Release resources */ - if(name) { - for(i = 0; i < nmembs; i++) - if(name[i]) + if (name) { + for (i = 0; i < nmembs; i++) + if (name[i]) HDfree(name[i]); HDfree(name); } /* end if */ - if(value) + if (value) HDfree(value); - if(super >= 0) + if (super >= 0) H5Tclose(super); return NULL; } /*------------------------------------------------------------------------- -* Function: H5LTdtype_to_text -* -* Purpose: Convert HDF5 data type to DDL description. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu -* -* Date: December 6, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) + * Function: H5LTdtype_to_text + * + * Purpose: Convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: December 6, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { - size_t str_len = INCREMENT; - char *text_str; - herr_t ret = SUCCEED; + size_t str_len = INCREMENT; + char * text_str; + herr_t ret = SUCCEED; - if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; - if(len && !str) { - text_str = (char*)HDcalloc(str_len, sizeof(char)); - text_str[0]='\0'; - if(!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) + if (len && !str) { + text_str = (char *)HDcalloc(str_len, sizeof(char)); + text_str[0] = '\0'; + if (!(text_str = H5LT_dtype_to_text(dtype, text_str, lang_type, &str_len, 1))) goto out; *len = HDstrlen(text_str) + 1; - if(text_str) + if (text_str) HDfree(text_str); text_str = NULL; - } else if(len && str) { - if(!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) + } + else if (len && str) { + if (!(H5LT_dtype_to_text(dtype, str, lang_type, len, 0))) goto out; - str[*len-1] = '\0'; + str[*len - 1] = '\0'; } return ret; @@ -2525,38 +2404,38 @@ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t * } /*------------------------------------------------------------------------- -* Function: H5LT_dtype_to_text -* -* Purpose: Private function to convert HDF5 data type to DDL description. -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Raymond Lu -* -* Date: December 20, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, - hbool_t no_user_buf) + * Function: H5LT_dtype_to_text + * + * Purpose: Private function to convert HDF5 data type to DDL description. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Raymond Lu + * + * Date: December 20, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +char * +H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hbool_t no_user_buf) { H5T_class_t tcls; char tmp_str[TMP_LEN]; int i; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) goto out; - if(lang != H5LT_DDL) { + if (lang != H5LT_DDL) { HDsnprintf(dt_str, *slen, "only DDL is supported for now"); goto out; } - if((tcls = H5Tget_class(dtype)) < 0) + if ((tcls = H5Tget_class(dtype)) < 0) goto out; switch (tcls) { @@ -2564,57 +2443,83 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl case H5T_BITFIELD: if (H5Tequal(dtype, H5T_STD_I8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8BE"); - } else if (H5Tequal(dtype, H5T_STD_I8LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I8LE"); - } else if (H5Tequal(dtype, H5T_STD_I16BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16BE"); - } else if (H5Tequal(dtype, H5T_STD_I16LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I16LE"); - } else if (H5Tequal(dtype, H5T_STD_I32BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32BE"); - } else if (H5Tequal(dtype, H5T_STD_I32LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I32LE"); - } else if (H5Tequal(dtype, H5T_STD_I64BE)) { + } + else if (H5Tequal(dtype, H5T_STD_I64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64BE"); - } else if (H5Tequal(dtype, H5T_STD_I64LE)) { + } + else if (H5Tequal(dtype, H5T_STD_I64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_I64LE"); - } else if (H5Tequal(dtype, H5T_STD_U8BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U8BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8BE"); - } else if (H5Tequal(dtype, H5T_STD_U8LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U8LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U8LE"); - } else if (H5Tequal(dtype, H5T_STD_U16BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U16BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16BE"); - } else if (H5Tequal(dtype, H5T_STD_U16LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U16LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U16LE"); - } else if (H5Tequal(dtype, H5T_STD_U32BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U32BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32BE"); - } else if (H5Tequal(dtype, H5T_STD_U32LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U32LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U32LE"); - } else if (H5Tequal(dtype, H5T_STD_U64BE)) { + } + else if (H5Tequal(dtype, H5T_STD_U64BE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64BE"); - } else if (H5Tequal(dtype, H5T_STD_U64LE)) { + } + else if (H5Tequal(dtype, H5T_STD_U64LE)) { HDsnprintf(dt_str, *slen, "H5T_STD_U64LE"); - } else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_SCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SCHAR"); - } else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_UCHAR)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UCHAR"); - } else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_SHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_SHORT"); - } else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_USHORT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_USHORT"); - } else if (H5Tequal(dtype, H5T_NATIVE_INT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_INT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_INT"); - } else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_UINT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_UINT"); - } else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_LONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_ULONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_LLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LLONG"); - } else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_ULLONG)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_ULLONG"); - } else { + } + else { HDsnprintf(dt_str, *slen, "undefined integer"); } @@ -2622,439 +2527,445 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl case H5T_FLOAT: if (H5Tequal(dtype, H5T_IEEE_F32BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32BE"); - } else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F32LE"); - } else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F64BE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64BE"); - } else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { + } + else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { HDsnprintf(dt_str, *slen, "H5T_IEEE_F64LE"); - } else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { + } + else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_FLOAT"); - } else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { + } + 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)) { +#if H5_SIZEOF_LONG_DOUBLE != 0 + } + else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE"); #endif - } else { + } + else { HDsnprintf(dt_str, *slen, "undefined float"); } break; - case H5T_STRING: - { - /* Make a copy of type in memory in case when DTYPE is on disk, the size - * will be bigger than in memory. This makes it easier to compare - * types in memory. */ - hid_t str_type; - H5T_order_t order; - hid_t tmp_type; - size_t size; - H5T_str_t str_pad; - H5T_cset_t cset; - htri_t is_vlstr; - - if((tmp_type = H5Tcopy(dtype)) < 0) - goto out; - if((size = H5Tget_size(tmp_type))==0) - goto out; - if((str_pad = H5Tget_strpad(tmp_type)) < 0) - goto out; - if((cset = H5Tget_cset(tmp_type)) < 0) - goto out; - if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) - goto out; + case H5T_STRING: { + /* Make a copy of type in memory in case when DTYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + hid_t str_type; + H5T_order_t order; + hid_t tmp_type; + size_t size; + H5T_str_t str_pad; + H5T_cset_t cset; + htri_t is_vlstr; + + if ((tmp_type = H5Tcopy(dtype)) < 0) + goto out; + if ((size = H5Tget_size(tmp_type)) == 0) + goto out; + if ((str_pad = H5Tget_strpad(tmp_type)) < 0) + goto out; + if ((cset = H5Tget_cset(tmp_type)) < 0) + goto out; + if ((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) + goto out; - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_STRING {\n"); - indent += COL; + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_STRING {\n"); + indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if(is_vlstr) - HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); + if (is_vlstr) + HDsnprintf(tmp_str, TMP_LEN, "STRSIZE H5T_VARIABLE;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "STRSIZE %d;\n", (int)size); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if (str_pad == H5T_STR_NULLTERM) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); - else if (str_pad == H5T_STR_NULLPAD) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); - else if (str_pad == H5T_STR_SPACEPAD) - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); + if (str_pad == H5T_STR_NULLTERM) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_SPACEPAD;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "STRPAD H5T_STR_ERROR;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if (cset == H5T_CSET_ASCII) - HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); - else if (cset == H5T_CSET_UTF8) - HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); - else - HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); + if (cset == H5T_CSET_ASCII) + HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_ASCII;\n"); + else if (cset == H5T_CSET_UTF8) + HDsnprintf(tmp_str, TMP_LEN, "CSET H5T_CSET_UTF8;\n"); + else + HDsnprintf(tmp_str, TMP_LEN, "CSET unknown;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - /* Reproduce a C type string */ - if((str_type = H5Tcopy(H5T_C_S1)) < 0) - goto out; - if(is_vlstr) { - if(H5Tset_size(str_type, H5T_VARIABLE) < 0) - goto out; - } else { - if(H5Tset_size(str_type, size) < 0) - goto out; - } - if(H5Tset_cset(str_type, cset) < 0) + /* Reproduce a C type string */ + if ((str_type = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (is_vlstr) { + if (H5Tset_size(str_type, H5T_VARIABLE) < 0) goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) + } + else { + if (H5Tset_size(str_type, size) < 0) goto out; + } + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - /* Check C variable-length string first. Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + goto next; + } - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - goto out; - } - - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* If not equal to C variable-length string, check Fortran type. - * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - if(H5Tclose(str_type) < 0) + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; - if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) + } + + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_C_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(H5Tset_cset(str_type, cset) < 0) + goto next; + } + + /* If not equal to C variable-length string, check Fortran type. + * Actually H5Tequal can't tell difference between H5T_C_S1 and + * H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + if (H5Tclose(str_type) < 0) + goto out; + if ((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) + goto out; + if (H5Tset_cset(str_type, cset) < 0) + goto out; + if (H5Tset_size(str_type, size) < 0) + goto out; + if (H5Tset_strpad(str_type, str_pad) < 0) + goto out; + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(H5Tset_size(str_type, size) < 0) + goto next; + } + + /* Change the endianness and see if they're equal. */ + if ((order = H5Tget_order(tmp_type)) < 0) + goto out; + if (order == H5T_ORDER_LE) { + if (H5Tset_order(str_type, H5T_ORDER_LE) < 0) goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) + } + else if (order == H5T_ORDER_BE) { + if (H5Tset_order(str_type, H5T_ORDER_BE) < 0) goto out; + } - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) - goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - goto out; - } - - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - goto next; - } - - /* Type doesn't match any of above. */ - HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + HDsnprintf(tmp_str, TMP_LEN, "CTYPE H5T_FORTRAN_S1;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; + goto next; + } + + /* Type doesn't match any of above. */ + HDsnprintf(tmp_str, TMP_LEN, "CTYPE unknown_one_character_type;\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; next: - H5Tclose(str_type); - H5Tclose(tmp_type); + H5Tclose(str_type); + H5Tclose(tmp_type); - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - break; - } - case H5T_OPAQUE: - { + break; + } + case H5T_OPAQUE: { char *tag = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_OPAQUE {\n"); indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "OPQ_SIZE %lu;\n", (unsigned long)H5Tget_size(dtype)); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; tag = H5Tget_tag(dtype); - if(tag) { + if (tag) { HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag); - if(tag) + if (tag) H5free_memory(tag); tag = NULL; - } else + } + else HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; /* Print closing */ indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; break; - } - case H5T_ENUM: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + } + case H5T_ENUM: { + hid_t super; + size_t super_len; + char * stmp = NULL; - if((super = H5Tget_super(dtype)) < 0) - goto out; - 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) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - if(stmp) - HDfree(stmp); - stmp = NULL; + if ((super = H5Tget_super(dtype)) < 0) + goto out; + 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) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; - HDsnprintf(tmp_str, TMP_LEN, ";\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); + if (stmp) + HDfree(stmp); + stmp = NULL; - if(!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) - goto out; + HDsnprintf(tmp_str, TMP_LEN, ";\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (!(dt_str = print_enum(dtype, dt_str, slen, no_user_buf, indent))) + goto out; - break; - } - case H5T_VLEN: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - if((super = H5Tget_super(dtype)) < 0) - goto out; - 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) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; + break; + } + case H5T_VLEN: { + hid_t super; + size_t super_len; + char * stmp = NULL; - if(stmp) - HDfree(stmp); - stmp = NULL; - HDsnprintf(tmp_str, TMP_LEN, "\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if ((super = H5Tget_super(dtype)) < 0) + goto out; + 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) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; - break; - } - case H5T_ARRAY: - { - hid_t super; - size_t super_len; - char* stmp = NULL; - hsize_t dims[H5S_MAX_RANK]; - int ndims; - - /* Print lead-in */ - HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n"); - indent += COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (stmp) + HDfree(stmp); + stmp = NULL; + HDsnprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } + case H5T_ARRAY: { + hid_t super; + size_t super_len; + char * stmp = NULL; + hsize_t dims[H5S_MAX_RANK]; + int ndims; + + /* Print lead-in */ + HDsnprintf(dt_str, *slen, "H5T_ARRAY {\n"); + indent += COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + + /* Get array information */ + if ((ndims = H5Tget_array_ndims(dtype)) < 0) + goto out; + if (H5Tget_array_dims2(dtype, dims) < 0) + goto out; + + /* Print array dimensions */ + for (i = 0; i < ndims; i++) { + HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int)dims[i]); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; + } + HDsnprintf(tmp_str, TMP_LEN, " "); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + if ((super = H5Tget_super(dtype)) < 0) + goto out; + 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) + goto out; + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + goto out; + if (stmp) + HDfree(stmp); + stmp = NULL; + HDsnprintf(tmp_str, TMP_LEN, "\n"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + H5Tclose(super); + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; - /* Get array information */ - if((ndims = H5Tget_array_ndims(dtype)) < 0) + break; + } + case H5T_COMPOUND: { + char * mname = NULL; + hid_t mtype; + size_t moffset; + H5T_class_t mclass; + size_t mlen; + char * mtmp = NULL; + int nmembs; + + if ((nmembs = H5Tget_nmembers(dtype)) < 0) + goto out; + + HDsnprintf(dt_str, *slen, "H5T_COMPOUND {\n"); + indent += COL; + + for (i = 0; i < nmembs; i++) { + if ((mname = H5Tget_member_name(dtype, (unsigned)i)) == NULL) goto out; - if(H5Tget_array_dims2(dtype, dims) < 0) + if ((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) + goto out; + moffset = H5Tget_member_offset(dtype, (unsigned)i); + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) goto out; - /* Print array dimensions */ - for (i = 0; i < ndims; i++) { - HDsnprintf(tmp_str, TMP_LEN, "[%d]", (int) dims[i]); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - } - HDsnprintf(tmp_str, TMP_LEN, " "); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - - if((super = H5Tget_super(dtype)) < 0) + if ((mclass = H5Tget_class(mtype)) < 0) goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + if (H5T_COMPOUND == mclass) + indent += COL; + + if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; - stmp = (char*)HDcalloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + mtmp = (char *)HDcalloc(mlen, sizeof(char)); + if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) - goto out; - if(stmp) - HDfree(stmp); - stmp = NULL; - HDsnprintf(tmp_str, TMP_LEN, "\n"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - H5Tclose(super); - - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (mtmp) + HDfree(mtmp); + mtmp = NULL; - break; - } - case H5T_COMPOUND: - { - char *mname = NULL; - hid_t mtype; - size_t moffset; - H5T_class_t mclass; - size_t mlen; - char* mtmp = NULL; - int nmembs; - - if((nmembs = H5Tget_nmembers(dtype)) < 0) - goto out; + if (H5T_COMPOUND == mclass) + indent -= COL; - HDsnprintf(dt_str, *slen, "H5T_COMPOUND {\n"); - indent += COL; - - for (i = 0; i < nmembs; i++) { - if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL) - goto out; - if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) - goto out; - moffset = H5Tget_member_offset(dtype, (unsigned)i); - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) - goto out; - - if((mclass = H5Tget_class(mtype)) < 0) - goto out; - if (H5T_COMPOUND == mclass) - indent += COL; - - if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) - goto out; - mtmp = (char*)HDcalloc(mlen, sizeof(char)); - if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) - goto out; - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) - goto out; - if(mtmp) - HDfree(mtmp); - mtmp = NULL; - - if (H5T_COMPOUND == mclass) - indent -= COL; - - HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - if(mname) - H5free_memory(mname); - mname = NULL; - - HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; - } - - /* Print closing */ - indent -= COL; - if(!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + HDsnprintf(tmp_str, TMP_LEN, " \"%s\"", mname); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "}"); - if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) - goto out; + if (mname) + H5free_memory(mname); + mname = NULL; - break; + HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; } + + /* Print closing */ + indent -= COL; + if (!(dt_str = indentation(indent + COL, dt_str, no_user_buf, slen))) + goto out; + HDsnprintf(tmp_str, TMP_LEN, "}"); + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str))) + goto out; + + break; + } case H5T_TIME: HDsnprintf(dt_str, *slen, "H5T_TIME: not yet implemented"); break; @@ -3062,15 +2973,15 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl HDsnprintf(dt_str, *slen, "H5T_NO_CLASS"); break; case H5T_REFERENCE: - if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) { - HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); - } - else { - HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); - } - break; + if (H5Tequal(dtype, H5T_STD_REF_DSETREG) == TRUE) { + HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_DSETREG }"); + } + else { + HDsnprintf(dt_str, *slen, " H5T_REFERENCE { H5T_STD_REF_OBJECT }"); + } + break; case H5T_NCLASSES: - break; + break; default: HDsnprintf(dt_str, *slen, "unknown data type"); } @@ -3082,747 +2993,701 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl } /*------------------------------------------------------------------------- -* -* Get attribute functions -* -*------------------------------------------------------------------------- -*/ - + * + * Get attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_string -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_string + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) +herr_t +H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* identifiers */ - hid_t obj_id; + hid_t obj_id; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - { - H5Oclose(obj_id); - return -1; + if (H5LT_get_attribute_disk(obj_id, attr_name, data) < 0) { + H5Oclose(obj_id); + return -1; } /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) return -1; return 0; - } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_char -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) + * Function: H5LTget_attribute_char + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_uchar -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned char *data ) + * Function: H5LTget_attribute_uchar + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_short -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - short *data ) + * Function: H5LTget_attribute_short + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, short *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ushort -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned short *data ) + * Function: H5LTget_attribute_ushort + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_USHORT, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_int -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *data ) + * Function: H5LTget_attribute_int + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_uint -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned int *data ) + * Function: H5LTget_attribute_uint + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UINT, data) < 0) return -1; return 0; } - - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_long -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long *data ) + * Function: H5LTget_attribute_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_long_long -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Elena Pourmal -* -* Date: June 17, 2005 -* -* Comments: This function was added to support INTEGER*8 Fortran types -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long long *data ) + * Function: H5LTget_attribute_long_long + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Elena Pourmal + * + * Date: June 17, 2005 + * + * Comments: This function was added to support INTEGER*8 Fortran types + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, long long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_ulong -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 8, 2004 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LTget_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned long *data ) + * Function: H5LTget_attribute_ulong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 8, 2004 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_float -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_float + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - float *data ) +herr_t +H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute_double -* -* Purpose: Reads an attribute named attr_name -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute_double + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - double *data ) +herr_t +H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, double *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* Function: H5LTget_attribute -* -* Purpose: Reads an attribute named attr_name with the memory type mem_type_id -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: Private function -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LTget_attribute + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: Private function + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LTget_attribute( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data ) +herr_t +H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data) { /* Get the attribute */ - if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) return -1; return 0; } - /*------------------------------------------------------------------------- -* private functions -*------------------------------------------------------------------------- -*/ - + * private functions + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5LT_get_attribute_mem -* -* Purpose: Reads an attribute named attr_name with the memory type mem_type_id -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: Private function -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ - + * Function: H5LT_get_attribute_mem + * + * Purpose: Reads an attribute named attr_name with the memory type mem_type_id + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: Private function + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data) +static herr_t +H5LT_get_attribute_mem(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, + void *data) { /* identifiers */ - hid_t obj_id = -1; + hid_t obj_id = -1; hid_t attr_id = -1; /* check the arguments */ if (obj_name == NULL) - return -1; + return -1; if (attr_name == NULL) - return -1; + return -1; /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) goto out; - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) goto out; - if(H5Aread(attr_id, mem_type_id, data) < 0) + if (H5Aread(attr_id, mem_type_id, data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; attr_id = -1; /* Close the object */ - if(H5Oclose(obj_id) < 0) + if (H5Oclose(obj_id) < 0) goto out; obj_id = -1; return 0; out: - if(obj_id > 0) + if (obj_id > 0) H5Oclose(obj_id); - if(attr_id > 0) + if (attr_id > 0) H5Aclose(attr_id); return -1; } /*------------------------------------------------------------------------- -* Function: H5LT_get_attribute_disk -* -* Purpose: Reads an attribute named attr_name with the datatype stored on disk -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: September 19, 2002 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ + * Function: H5LT_get_attribute_disk + * + * Purpose: Reads an attribute named attr_name with the datatype stored on disk + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: September 19, 2002 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ -herr_t H5LT_get_attribute_disk( hid_t loc_id, - const char *attr_name, - void *attr_out ) +herr_t +H5LT_get_attribute_disk(hid_t loc_id, const char *attr_name, void *attr_out) { /* identifiers */ hid_t attr_id; hid_t attr_type; - if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) + if ((attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) return -1; - if((attr_type = H5Aget_type(attr_id)) < 0) + if ((attr_type = H5Aget_type(attr_id)) < 0) goto out; - if(H5Aread(attr_id, attr_type, attr_out) < 0) + if (H5Aread(attr_id, attr_type, attr_out) < 0) goto out; - if(H5Tclose(attr_type) < 0) + if (H5Tclose(attr_type) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) - return -1;; + if (H5Aclose(attr_id) < 0) + return -1; + ; return 0; out: - H5Tclose( attr_type ); - H5Aclose( attr_id ); + H5Tclose(attr_type); + H5Aclose(attr_id); return -1; } - -/*------------------------------------------------------------------------- -* Function: H5LT_set_attribute_string -* -* Purpose: creates and writes an attribute named NAME to the dataset DSET_ID -* -* Return: FAIL on error, SUCCESS on success -* -* Programmer: Pedro Vicente -* -* Date: January 04, 2005 -* -* Comments: -* -* Modifications: -* -*------------------------------------------------------------------------- -*/ -herr_t H5LT_set_attribute_string(hid_t dset_id, - const char *name, - const char *buf ) +/*------------------------------------------------------------------------- + * Function: H5LT_set_attribute_string + * + * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID + * + * Return: FAIL on error, SUCCESS on success + * + * Programmer: Pedro Vicente + * + * Date: January 04, 2005 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf) { - hid_t tid; - hid_t sid = -1; - hid_t aid = -1; - int has_attr; - size_t size; + hid_t tid; + hid_t sid = -1; + hid_t aid = -1; + int has_attr; + size_t size; /* verify if the attribute already exists */ - has_attr = H5LT_find_attribute(dset_id,name); + has_attr = H5LT_find_attribute(dset_id, name); /* the attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(dset_id, name) < 0) + if (has_attr == 1) + if (H5Adelete(dset_id, name) < 0) return FAIL; /*------------------------------------------------------------------------- - * create the attribute type - *------------------------------------------------------------------------- - */ - if((tid = H5Tcopy(H5T_C_S1)) < 0) + * create the attribute type + *------------------------------------------------------------------------- + */ + if ((tid = H5Tcopy(H5T_C_S1)) < 0) return FAIL; size = HDstrlen(buf) + 1; /* extra null term */ - if(H5Tset_size(tid,(size_t)size) < 0) + if (H5Tset_size(tid, (size_t)size) < 0) goto out; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + if (H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) goto out; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - /*------------------------------------------------------------------------- - * create and write the attribute - *------------------------------------------------------------------------- - */ - if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * create and write the attribute + *------------------------------------------------------------------------- + */ + if ((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(aid, tid, buf) < 0) + if (H5Awrite(aid, tid, buf) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; return SUCCEED; /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Tclose(tid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return FAIL; - } 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 */ - H5I_type_t obj_type; - htri_t link_exists, obj_exists; - size_t path_length; - htri_t ret_value; - - /* Initialize */ - ret_value = FALSE; - - /* check the arguments */ - if (path == NULL) { - ret_value = FAIL; - goto done; - } - - /* Find the type of loc_id */ - if((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { - ret_value = FAIL; - goto done; - } - - /* Find the length of the path */ - path_length = HDstrlen(path); - - /* Check if the identifier is the object itself, i.e. path is '.' */ - if(HDstrncmp(path, ".", path_length) == 0) { - if(check_object_valid) { - obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); - ret_value = obj_exists; - goto done; - } else { - ret_value = TRUE; /* Since the object is the identifier itself, - * we can only check if loc_id is a valid type */ - goto done; - } - } - - /* Duplicate the path to use */ - if(NULL == (tmp_path = HDstrdup(path))) { - ret_value = FAIL; - goto done; - } - - curr_name = tmp_path; - - /* check if absolute pathname */ - if(HDstrncmp(path, "/", 1) == 0) curr_name++; - - /* check if relative path name starts with "./" */ - if(HDstrncmp(path, "./", 2) == 0) curr_name += 2; - - while((delimit=HDstrchr(curr_name,'/'))!=NULL) { - /* Change the delimiter to terminate the string */ - *delimit='\0'; - - obj_exists = FALSE; - if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - goto done; - } - - /* If target link does not exist then no reason to - * continue checking the path */ - if(link_exists != TRUE) { - ret_value = FALSE; - goto done; - } - - /* Determine if link resolves to an actual object */ - if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - goto done; - } - - if(obj_exists != TRUE) - break; - - /* Change the delimiter back to '/' */ - *delimit='/'; - - /* Advance the pointer in the path to the start of the next component */ - curr_name = delimit + 1; - - } /* end while */ - - /* Should be pointing to the last component in the path name now... */ - - /* Check if link does not exist */ - if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - } else { - ret_value = link_exists; - /* Determine if link resolves to an actual object for check_object_valid TRUE */ - if(check_object_valid == TRUE && link_exists == TRUE) { - if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { - ret_value = FAIL; - } else { - ret_value = obj_exists; - } - } - } +{ + 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; + htri_t ret_value; + + /* Initialize */ + ret_value = FALSE; + + /* check the arguments */ + if (path == NULL) { + ret_value = FAIL; + goto done; + } + + /* Find the type of loc_id */ + if ((obj_type = H5Iget_type(loc_id)) == H5I_BADID) { + ret_value = FAIL; + goto done; + } + + /* Find the length of the path */ + path_length = HDstrlen(path); + + /* Check if the identifier is the object itself, i.e. path is '.' */ + if (HDstrncmp(path, ".", path_length) == 0) { + if (check_object_valid) { + obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT); + ret_value = obj_exists; + goto done; + } + else { + ret_value = TRUE; /* Since the object is the identifier itself, + * we can only check if loc_id is a valid type */ + goto done; + } + } + + /* Duplicate the path to use */ + if (NULL == (tmp_path = HDstrdup(path))) { + ret_value = FAIL; + goto done; + } + + curr_name = tmp_path; + + /* check if absolute pathname */ + if (HDstrncmp(path, "/", 1) == 0) + curr_name++; + + /* check if relative path name starts with "./" */ + if (HDstrncmp(path, "./", 2) == 0) + curr_name += 2; + + while ((delimit = HDstrchr(curr_name, '/')) != NULL) { + /* Change the delimiter to terminate the string */ + *delimit = '\0'; + + obj_exists = FALSE; + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + /* If target link does not exist then no reason to + * continue checking the path */ + if (link_exists != TRUE) { + ret_value = FALSE; + goto done; + } + + /* Determine if link resolves to an actual object */ + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if (obj_exists != TRUE) + break; + + /* Change the delimiter back to '/' */ + *delimit = '/'; + + /* Advance the pointer in the path to the start of the next component */ + curr_name = delimit + 1; + + } /* end while */ + + /* Should be pointing to the last component in the path name now... */ + + /* Check if link does not exist */ + if ((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = link_exists; + /* Determine if link resolves to an actual object for check_object_valid TRUE */ + if (check_object_valid == TRUE && link_exists == TRUE) { + if ((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { + ret_value = FAIL; + } + else { + ret_value = obj_exists; + } + } + } done: - if(tmp_path != NULL) - HDfree(tmp_path); + if (tmp_path != NULL) + HDfree(tmp_path); - return ret_value; - } + return ret_value; +} diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c index e5f0bea3758..875a37a9eed 100644 --- a/hl/src/H5LTanalyze.c +++ b/hl/src/H5LTanalyze.c @@ -1,7 +1,7 @@ -#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined (__GNUC__) +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wimplicit-function-declaration" -#pragma GCC diagnostic ignored "-Wlarger-than=" #pragma GCC diagnostic ignored "-Wmissing-prototypes" #pragma GCC diagnostic ignored "-Wnested-externs" #pragma GCC diagnostic ignored "-Wold-style-definition" @@ -10,19 +10,27 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wstrict-overflow" #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wlarger-than=" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif #pragma GCC diagnostic ignored "-Wswitch-default" #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-macros" #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600 +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif #elif defined __SUNPRO_CC #pragma disable_warn #elif defined _MSC_VER #pragma warning(push, 1) #endif -#line 2 "hl/src/H5LTanalyze.c" +#line 1 "hl/src/H5LTanalyze.c" -#line 4 "hl/src/H5LTanalyze.c" +#line 3 "hl/src/H5LTanalyze.c" #define YY_INT_ALIGNED short int @@ -633,8 +641,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 66 -#define YY_END_OF_BUFFER 67 +#define YY_NUM_RULES 64 +#define YY_END_OF_BUFFER 65 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -642,138 +650,56 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_acclist[437] = +static const flex_int16_t yy_accept[275] = { 0, - 64, 64, 64, 64, 67, 66, 64, 66, 64, 65, - 66, 56, 66, 55, 66, 62, 66, 63, 66, 66, - 66, 66, 66, 60, 66, 61, 66, 58, 66, 59, - 66, 57, 66, 57, 64, 66, 57, 64, 65, 66, - 55, 57, 66, 57, 62, 66, 57, 63, 66, 57, - 66, 57, 66, 57, 66, 57, 66, 57, 60, 66, - 57, 61, 66, 57, 58, 66, 57, 59, 66, 64, - 55, 57, 57, 64, 55, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 38, 38, 57, 57, - 57, 57, 57, 57, 39, 39, 57, 57, 57, 57, - - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 37, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 37, 57, 57, 54, 36, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 54, 57, 36, 57, 45, 49, - 51, 53, 57, 57, 57, 45, 57, 49, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 51, 57, 53, - 57, 50, 50, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 52, 35, 57, 57, - 57, 57, 57, 57, 52, 57, 57, 57, 57, 57, - - 57, 57, 57, 57, 35, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 48, - 1, 2, 9, 10, 47, 48, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 1, 57, 2, 57, 57, - 57, 57, 57, 57, 57, 9, 57, 10, 57, 57, - 57, 47, 57, 44, 3, 4, 5, 6, 7, 8, - 11, 12, 13, 14, 15, 16, 57, 44, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - - 57, 57, 57, 57, 57, 57, 57, 3, 57, 4, - 57, 5, 57, 6, 57, 7, 57, 8, 57, 11, - 57, 12, 57, 13, 57, 14, 57, 15, 57, 16, - 57, 57, 57, 57, 43, 46, 28, 29, 30, 31, - 22, 43, 57, 46, 57, 28, 57, 29, 57, 30, - 57, 31, 57, 57, 57, 57, 22, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 17, 24, 23, 41, 17, 57, 57, 57, 57, - 57, 24, 57, 57, 57, 57, 23, 57, 57, 57, - 57, 41, 57, 57, 57, 32, 26, 18, 20, 19, - - 25, 40, 42, 57, 32, 57, 57, 26, 57, 18, - 57, 20, 57, 19, 57, 57, 25, 57, 57, 40, - 57, 42, 57, 33, 27, 21, 33, 57, 57, 27, - 57, 21, 57, 34, 34, 57 - } ; - -static const flex_int16_t yy_accept[546] = - { 0, - 1, 2, 3, 4, 5, 6, 7, 9, 12, 14, - 16, 18, 20, 21, 22, 23, 24, 26, 28, 30, - 32, 34, 37, 41, 44, 47, 50, 52, 54, 56, - 58, 61, 64, 67, 70, 71, 72, 72, 72, 72, - 72, 72, 73, 75, 77, 78, 79, 80, 81, 82, - 82, 82, 82, 82, 82, 83, 84, 85, 86, 87, - 88, 88, 88, 88, 88, 88, 90, 91, 92, 93, - 94, 95, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - - 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 112, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, - 129, 129, 129, 129, 129, 129, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 147, 149, 149, 149, 149, 150, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 152, 153, 154, - 155, 156, 158, 160, 161, 162, 163, 164, 165, 166, - 167, 168, 170, 172, 173, 173, 173, 173, 173, 173, - - 173, 173, 173, 173, 173, 173, 173, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, - 187, 187, 187, 187, 187, 187, 188, 188, 188, 188, - 188, 188, 188, 188, 188, 189, 189, 189, 189, 190, - 191, 192, 193, 194, 195, 197, 198, 199, 200, 201, - 202, 203, 204, 205, 207, 208, 209, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 211, 212, - 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, 231, 231, - - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 232, 233, 233, - 233, 233, 233, 233, 233, 234, 235, 235, 235, 236, - 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255, 256, 258, - 260, 261, 262, 263, 264, 265, 266, 268, 270, 271, - 272, 274, 274, 275, 275, 275, 275, 275, 275, 275, - 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - 275, 275, 276, 277, 278, 279, 280, 281, 282, 283, - 284, 285, 286, 287, 287, 287, 287, 288, 290, 291, - - 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, - 302, 303, 304, 305, 306, 307, 308, 310, 312, 314, - 316, 318, 320, 322, 324, 326, 328, 330, 332, 333, - 334, 335, 336, 337, 338, 339, 340, 341, 341, 341, - 341, 342, 342, 342, 342, 342, 342, 342, 342, 342, - 342, 342, 342, 342, 342, 344, 346, 348, 350, 352, - 354, 355, 356, 357, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 373, - 373, 373, 373, 374, 374, 374, 374, 375, 375, 375, - 375, 376, 376, 376, 378, 379, 380, 381, 382, 384, - - 385, 386, 387, 389, 390, 391, 392, 394, 395, 396, - 396, 397, 397, 398, 399, 400, 401, 401, 402, 402, - 403, 404, 405, 407, 408, 410, 412, 414, 416, 417, - 419, 420, 422, 424, 425, 425, 426, 427, 429, 430, - 432, 434, 435, 437, 437 + 63, 63, 65, 64, 63, 64, 55, 61, 62, 64, + 64, 64, 64, 59, 60, 57, 58, 63, 0, 55, + 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, + 0, 38, 0, 0, 0, 0, 0, 39, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 54, 36, 0, 0, 0, 45, 49, 0, 0, + 0, 0, 0, 0, 0, 0, 51, 53, 50, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 2, 0, 0, 0, 0, 0, 0, 9, 10, 0, + 0, 47, 0, 44, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 3, 4, 5, 6, 7, 8, 11, 12, + 13, 14, 15, 16, 0, 0, 0, 43, 46, 28, + 29, 30, 31, 0, 0, 0, 22, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 24, 0, 0, 0, 23, + 0, 0, 0, 41, 0, 0, 0, 32, 0, 26, + 18, 20, 19, 0, 25, 0, 40, 42, 33, 0, + 27, 21, 34, 0 } ; static const YY_CHAR yy_ec[256] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 5, 6, 7, - 8, 9, 10, 11, 5, 12, 5, 13, 14, 1, - 1, 1, 1, 1, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 1, 1, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 1, 1, 35, 36, - 37, 1, 38, 1, 39, 1, 1, 1, 1, 1, + 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 4, 5, 6, + 7, 8, 9, 10, 4, 11, 4, 12, 13, 1, + 1, 1, 1, 1, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 1, 1, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 1, 1, 34, 35, + 36, 1, 37, 1, 38, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 40, 1, 41, 1, 1, 1, 1, 1, + 1, 1, 39, 1, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -790,309 +716,174 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[42] = +static const YY_CHAR yy_meta[41] = { 0, - 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static const flex_int16_t yy_base[547] = +static const flex_int16_t yy_base[277] = { 0, - 0, 0, 41, 0, 610, 611, 81, 83, 611, 0, - 611, 611, 56, 599, 580, 575, 611, 611, 611, 611, - 0, 87, 89, 88, 0, 0, 70, 596, 577, 572, - 0, 0, 0, 0, 101, 0, 584, 567, 569, 571, - 569, 0, 103, 0, 579, 562, 564, 566, 564, 561, - 564, 552, 551, 79, 557, 560, 548, 547, 80, 611, - 566, 97, 87, 569, 560, 0, 563, 117, 90, 566, - 557, 611, 549, 99, 552, 550, 557, 560, 546, 541, - 118, 549, 556, 552, 533, 0, 538, 108, 541, 539, - 546, 549, 535, 530, 126, 538, 545, 541, 522, 527, - - 531, 536, 523, 520, 522, 532, 518, 534, 95, 518, - 528, 510, 524, 611, 525, 513, 517, 522, 509, 506, - 508, 518, 504, 520, 97, 504, 514, 496, 510, 0, - 511, 514, 500, 495, 520, 500, 492, 504, 499, 492, - 481, 106, 496, 492, 498, 611, 611, 501, 487, 482, - 507, 487, 479, 491, 486, 479, 468, 123, 483, 479, - 485, 0, 0, 468, 475, 462, 611, 611, 470, 460, - 464, 464, 126, 470, 126, 480, 611, 611, 459, 466, - 453, 0, 0, 461, 451, 455, 455, 130, 461, 129, - 471, 0, 0, 611, 452, 139, 469, 463, 463, 462, - - 158, 165, 459, 446, 450, 461, 0, 443, 141, 460, - 454, 454, 453, 172, 179, 450, 437, 441, 452, 441, - 435, 433, 438, 150, 424, 611, 451, 454, 451, 151, - 448, 451, 448, 165, 611, 432, 440, 430, 427, 421, - 419, 424, 157, 410, 0, 437, 440, 437, 170, 434, - 437, 434, 172, 0, 418, 426, 416, 421, 421, 417, - 397, 428, 425, 180, 177, 183, 186, 414, 413, 190, - 192, 193, 412, 411, 405, 411, 408, 408, 408, 404, - 384, 415, 412, 201, 196, 199, 206, 401, 400, 211, - 212, 213, 399, 398, 392, 398, 395, 611, 390, 400, - - 380, 215, 217, 388, 382, 384, 381, 220, 223, 225, - 387, 386, 385, 384, 383, 382, 611, 611, 381, 380, - 379, 378, 377, 376, 611, 611, 218, 375, 611, 0, - 370, 380, 360, 227, 236, 368, 362, 364, 361, 235, - 241, 244, 367, 366, 365, 364, 363, 362, 0, 0, - 361, 360, 359, 358, 357, 356, 0, 0, 237, 355, - 0, 350, 611, 366, 352, 351, 350, 349, 352, 333, - 338, 332, 336, 335, 335, 338, 332, 336, 331, 155, - 334, 611, 611, 611, 611, 611, 611, 611, 611, 611, - 611, 611, 611, 340, 335, 325, 329, 0, 345, 331, - - 330, 329, 328, 331, 312, 317, 311, 315, 314, 314, - 317, 311, 315, 310, 168, 313, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 319, 314, - 304, 611, 611, 611, 611, 611, 611, 301, 314, 314, - 611, 295, 301, 305, 310, 294, 308, 290, 294, 294, - 292, 300, 287, 301, 0, 0, 0, 0, 0, 0, - 285, 298, 298, 0, 279, 285, 289, 294, 278, 292, - 274, 278, 278, 276, 284, 271, 285, 611, 275, 266, - 281, 275, 611, 265, 262, 263, 611, 266, 270, 260, - 611, 264, 270, 0, 263, 254, 269, 263, 0, 253, - - 250, 251, 0, 254, 258, 247, 0, 249, 255, 253, - 611, 247, 611, 611, 611, 611, 249, 611, 234, 611, - 611, 245, 0, 233, 0, 0, 0, 0, 234, 0, - 222, 0, 0, 611, 207, 611, 611, 0, 186, 0, - 0, 611, 0, 611, 106, 275 + 0, 0, 299, 300, 296, 0, 0, 300, 300, 11, + 288, 269, 264, 300, 300, 300, 300, 292, 290, 0, + 274, 257, 259, 261, 259, 300, 256, 259, 247, 246, + 16, 300, 265, 33, 14, 268, 259, 300, 251, 24, + 254, 252, 259, 262, 248, 243, 34, 251, 258, 254, + 235, 240, 244, 249, 236, 233, 235, 245, 231, 247, + 36, 231, 241, 223, 237, 300, 238, 241, 227, 222, + 247, 227, 219, 231, 226, 219, 208, 34, 223, 219, + 225, 300, 300, 208, 215, 202, 300, 300, 210, 200, + 204, 204, 38, 210, 39, 220, 300, 300, 300, 201, + + 47, 218, 212, 212, 211, 66, 73, 208, 195, 199, + 210, 199, 193, 191, 196, 75, 182, 300, 209, 212, + 209, 52, 206, 209, 206, 66, 300, 190, 198, 188, + 193, 193, 189, 169, 200, 197, 74, 71, 72, 77, + 186, 185, 84, 86, 87, 184, 183, 177, 183, 180, + 300, 175, 185, 165, 88, 90, 173, 167, 169, 166, + 91, 99, 96, 172, 171, 170, 169, 168, 167, 300, + 300, 166, 165, 164, 163, 162, 161, 300, 300, 94, + 160, 300, 155, 300, 171, 157, 156, 155, 154, 157, + 138, 143, 137, 141, 140, 140, 143, 137, 141, 136, + + 101, 139, 300, 300, 300, 300, 300, 300, 300, 300, + 300, 300, 300, 300, 145, 140, 130, 300, 300, 300, + 300, 300, 300, 127, 140, 140, 300, 121, 127, 131, + 136, 120, 134, 116, 120, 120, 118, 126, 113, 127, + 300, 117, 108, 123, 117, 300, 107, 104, 105, 300, + 108, 112, 102, 300, 105, 106, 104, 300, 93, 300, + 300, 300, 300, 78, 300, 57, 300, 300, 300, 56, + 300, 300, 300, 300, 127, 65 } ; -static const flex_int16_t yy_def[547] = +static const flex_int16_t yy_def[277] = { 0, - 544, 1, 544, 3, 544, 544, 544, 544, 544, 545, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 544, 545, 544, 544, 544, 544, - 544, 546, 546, 24, 546, 546, 546, 546, 546, 544, - 544, 544, 544, 544, 546, 546, 546, 546, 546, 544, - 544, 544, 544, 544, 544, 546, 546, 546, 546, 546, - 546, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 544, - - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 544, 544, 544, 544, 544, 544, 544, - - 544, 544, 544, 544, 544, 544, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 544, 544, 544, - - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 546, 546, 546, 546, - - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 546, 546, 546, 546, 546, 546, 546, - - 546, 546, 546, 546, 546, 546, 546, 546, 546, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 544, 544, 544, 544, 546, 546, 546, - 546, 544, 546, 0, 544, 544 + 274, 1, 274, 274, 274, 275, 276, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 275, 276, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 0, 274, 274 } ; -static const flex_int16_t yy_nxt[653] = +static const flex_int16_t yy_nxt[341] = { 0, - 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 12, 6, 6, 13, 6, 6, 6, - 6, 14, 6, 6, 6, 6, 15, 6, 6, 6, - 16, 6, 6, 6, 6, 6, 17, 18, 6, 19, - 20, 21, 22, 23, 9, 24, 24, 24, 24, 24, - 24, 24, 24, 25, 26, 21, 21, 27, 21, 21, - 21, 21, 28, 21, 21, 21, 21, 29, 21, 21, - 21, 30, 21, 21, 21, 21, 21, 31, 32, 21, - 33, 34, 35, 35, 35, 35, 37, 38, 43, 43, - 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, - - 45, 46, 35, 35, 43, 43, 64, 70, 36, 65, - 71, 73, 141, 74, 157, 75, 76, 82, 83, 77, - 96, 97, 78, 79, 142, 101, 158, 80, 174, 102, - 81, 87, 110, 88, 117, 89, 90, 103, 118, 91, - 126, 111, 92, 93, 175, 189, 119, 94, 201, 127, - 95, 204, 214, 221, 217, 240, 205, 262, 202, 218, - 263, 190, 215, 227, 282, 228, 268, 283, 229, 230, - 231, 222, 232, 241, 269, 233, 234, 246, 449, 247, - 273, 450, 248, 249, 250, 288, 251, 293, 274, 252, - 253, 472, 311, 289, 473, 294, 304, 305, 313, 306, - - 312, 315, 307, 308, 543, 319, 314, 321, 323, 316, - 309, 343, 310, 320, 345, 322, 324, 336, 337, 344, - 338, 347, 346, 339, 340, 542, 351, 353, 355, 348, - 365, 341, 367, 342, 352, 354, 356, 373, 366, 376, - 368, 378, 400, 374, 377, 394, 375, 379, 380, 395, - 401, 402, 408, 541, 540, 381, 539, 411, 409, 403, - 413, 410, 412, 538, 429, 537, 414, 415, 430, 536, - 535, 534, 533, 532, 416, 42, 531, 42, 530, 529, - 528, 527, 526, 525, 524, 523, 522, 521, 520, 519, - 518, 517, 516, 515, 514, 513, 512, 511, 510, 509, - - 508, 507, 506, 505, 504, 503, 502, 501, 500, 499, - 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, - 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, - 478, 477, 476, 475, 474, 471, 470, 469, 468, 467, - 466, 465, 464, 463, 462, 461, 460, 459, 458, 457, - 456, 455, 454, 453, 452, 451, 448, 447, 446, 445, - 444, 443, 442, 441, 440, 439, 438, 437, 436, 435, - 434, 433, 432, 431, 428, 427, 426, 425, 424, 423, - 422, 421, 420, 419, 418, 417, 407, 406, 405, 404, - 399, 398, 397, 396, 393, 392, 391, 390, 389, 388, - - 387, 386, 385, 384, 383, 382, 372, 371, 370, 369, - 364, 363, 362, 361, 360, 359, 358, 357, 350, 349, - 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, - 325, 318, 317, 303, 302, 301, 300, 299, 298, 297, - 296, 295, 292, 291, 290, 287, 286, 285, 284, 281, - 280, 279, 278, 277, 276, 275, 272, 271, 270, 267, - 266, 265, 264, 261, 260, 259, 258, 257, 256, 255, - 254, 245, 244, 243, 242, 239, 238, 237, 236, 235, - 226, 225, 224, 223, 220, 219, 216, 213, 212, 211, - 210, 209, 208, 207, 206, 203, 200, 199, 198, 197, - - 196, 195, 194, 193, 192, 191, 188, 187, 186, 185, - 184, 183, 182, 181, 180, 179, 178, 177, 176, 173, - 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, - 162, 161, 160, 159, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 147, 146, 145, 144, 143, 140, 139, - 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, - 128, 125, 124, 123, 122, 121, 120, 116, 115, 114, - 113, 112, 109, 108, 107, 106, 105, 104, 100, 99, - 98, 86, 85, 84, 72, 69, 68, 67, 66, 63, - 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, - - 52, 51, 50, 49, 48, 47, 41, 40, 39, 544, - 5, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544 + 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, + 7, 8, 9, 4, 4, 10, 4, 4, 4, 4, + 11, 4, 4, 4, 4, 12, 4, 4, 4, 13, + 4, 4, 4, 4, 4, 14, 15, 4, 16, 17, + 21, 22, 36, 48, 49, 37, 39, 62, 40, 53, + 41, 42, 77, 54, 43, 94, 63, 44, 45, 106, + 113, 55, 46, 109, 78, 47, 141, 20, 110, 107, + 119, 95, 120, 273, 142, 121, 122, 123, 114, 124, + 146, 135, 125, 126, 136, 164, 166, 272, 147, 157, + 158, 168, 159, 165, 167, 160, 161, 271, 172, 169, + + 174, 176, 186, 162, 188, 163, 173, 194, 175, 177, + 187, 199, 189, 195, 197, 270, 196, 200, 201, 198, + 215, 269, 268, 235, 216, 202, 236, 19, 267, 19, + 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, + 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, + 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, + 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, + 224, 223, 222, 221, 220, 219, 218, 217, 214, 213, + 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, + 193, 192, 191, 190, 185, 184, 183, 182, 181, 180, + + 179, 178, 171, 170, 156, 155, 154, 153, 152, 151, + 150, 149, 148, 145, 144, 143, 140, 139, 138, 137, + 134, 133, 132, 131, 130, 129, 128, 127, 118, 117, + 116, 115, 112, 111, 108, 105, 104, 103, 102, 101, + 100, 99, 98, 97, 96, 93, 92, 91, 90, 89, + 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, + 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, + 66, 65, 64, 61, 60, 59, 58, 57, 56, 52, + 51, 50, 38, 35, 34, 33, 32, 31, 30, 29, + 28, 27, 26, 18, 25, 24, 23, 18, 274, 3, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 } ; -static const flex_int16_t yy_chk[653] = +static const flex_int16_t yy_chk[341] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 7, 7, 8, 8, 13, 13, 22, 22, - 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, - - 27, 27, 35, 35, 43, 43, 54, 59, 545, 54, - 59, 62, 109, 62, 125, 62, 62, 63, 63, 62, - 69, 69, 62, 62, 109, 74, 125, 62, 142, 74, - 62, 68, 81, 68, 88, 68, 68, 74, 88, 68, - 95, 81, 68, 68, 142, 158, 88, 68, 173, 95, - 68, 175, 188, 196, 190, 209, 175, 224, 173, 190, - 224, 158, 188, 201, 243, 201, 230, 243, 201, 201, - 202, 196, 202, 209, 230, 202, 202, 214, 380, 214, - 234, 380, 214, 214, 215, 249, 215, 253, 234, 215, - 215, 415, 265, 249, 415, 253, 264, 264, 266, 264, - - 265, 267, 264, 264, 539, 270, 266, 271, 272, 267, - 264, 285, 264, 270, 286, 271, 272, 284, 284, 285, - 284, 287, 286, 284, 284, 535, 290, 291, 292, 287, - 302, 284, 303, 284, 290, 291, 292, 308, 302, 309, - 303, 310, 334, 308, 309, 327, 308, 310, 310, 327, - 334, 335, 340, 531, 529, 310, 524, 341, 340, 335, - 342, 340, 341, 522, 359, 519, 342, 342, 359, 517, - 512, 510, 509, 508, 342, 546, 506, 546, 505, 504, - 502, 501, 500, 498, 497, 496, 495, 493, 492, 490, - 489, 488, 486, 485, 484, 482, 481, 480, 479, 477, - - 476, 475, 474, 473, 472, 471, 470, 469, 468, 467, - 466, 465, 463, 462, 461, 454, 453, 452, 451, 450, - 449, 448, 447, 446, 445, 444, 443, 442, 440, 439, - 438, 431, 430, 429, 416, 414, 413, 412, 411, 410, - 409, 408, 407, 406, 405, 404, 403, 402, 401, 400, - 399, 397, 396, 395, 394, 381, 379, 378, 377, 376, - 375, 374, 373, 372, 371, 370, 369, 368, 367, 366, - 365, 364, 362, 360, 356, 355, 354, 353, 352, 351, - 348, 347, 346, 345, 344, 343, 339, 338, 337, 336, - 333, 332, 331, 328, 324, 323, 322, 321, 320, 319, - - 316, 315, 314, 313, 312, 311, 307, 306, 305, 304, - 301, 300, 299, 297, 296, 295, 294, 293, 289, 288, - 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, - 273, 269, 268, 263, 262, 261, 260, 259, 258, 257, - 256, 255, 252, 251, 250, 248, 247, 246, 244, 242, - 241, 240, 239, 238, 237, 236, 233, 232, 231, 229, - 228, 227, 225, 223, 222, 221, 220, 219, 218, 217, - 216, 213, 212, 211, 210, 208, 206, 205, 204, 203, - 200, 199, 198, 197, 195, 191, 189, 187, 186, 185, - 184, 181, 180, 179, 176, 174, 172, 171, 170, 169, - - 166, 165, 164, 161, 160, 159, 157, 156, 155, 154, - 153, 152, 151, 150, 149, 148, 145, 144, 143, 141, - 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, - 129, 128, 127, 126, 124, 123, 122, 121, 120, 119, - 118, 117, 116, 115, 113, 112, 111, 110, 108, 107, - 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, - 96, 94, 93, 92, 91, 90, 89, 87, 85, 84, - 83, 82, 80, 79, 78, 77, 76, 75, 73, 71, - 70, 67, 65, 64, 61, 58, 57, 56, 55, 53, - 52, 51, 50, 49, 48, 47, 46, 45, 41, 40, - - 39, 38, 37, 30, 29, 28, 16, 15, 14, 5, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, - 544, 544 + 10, 10, 31, 35, 35, 31, 34, 47, 34, 40, + 34, 34, 61, 40, 34, 78, 47, 34, 34, 93, + 101, 40, 34, 95, 61, 34, 122, 276, 95, 93, + 106, 78, 106, 270, 122, 106, 106, 107, 101, 107, + 126, 116, 107, 107, 116, 138, 139, 266, 126, 137, + 137, 140, 137, 138, 139, 137, 137, 264, 143, 140, + + 144, 145, 155, 137, 156, 137, 143, 161, 144, 145, + 155, 163, 156, 161, 162, 259, 161, 163, 163, 162, + 180, 257, 256, 201, 180, 163, 201, 275, 255, 275, + 253, 252, 251, 249, 248, 247, 245, 244, 243, 242, + 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, + 230, 229, 228, 226, 225, 224, 217, 216, 215, 202, + 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, + 190, 189, 188, 187, 186, 185, 183, 181, 177, 176, + 175, 174, 173, 172, 169, 168, 167, 166, 165, 164, + 160, 159, 158, 157, 154, 153, 152, 150, 149, 148, + + 147, 146, 142, 141, 136, 135, 134, 133, 132, 131, + 130, 129, 128, 125, 124, 123, 121, 120, 119, 117, + 115, 114, 113, 112, 111, 110, 109, 108, 105, 104, + 103, 102, 100, 96, 94, 92, 91, 90, 89, 86, + 85, 84, 81, 80, 79, 77, 76, 75, 74, 73, + 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, + 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, + 50, 49, 48, 46, 45, 44, 43, 42, 41, 39, + 37, 36, 33, 30, 29, 28, 27, 25, 24, 23, + 22, 21, 19, 18, 13, 12, 11, 5, 3, 274, + + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, + 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 } ; +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + extern int yy_flex_debug; int yy_flex_debug = 0; -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -#define REJECT \ -{ \ -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ -yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ -++(yy_lp); \ -goto find_rule; \ -} - +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET @@ -1106,7 +897,7 @@ char *yytext; * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -1116,24 +907,16 @@ char *yytext; * recreate the output files. */ #line 21 "hl/src/H5LTanalyze.l" +#include #include #include #include -#include "H5LTparse.h" -/* Turn off suggest const & malloc attribute warnings in gcc */ -#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ -#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" -#endif - -/* Turn off null dereference warnings in gcc. - * We have no control over this generated code. - */ -#if defined __GNUC__ && 600 <= __GNUC__ * 100 -#pragma GCC diagnostic ignored "-Wnull-dereference" -#endif +#include "H5private.h" +#include "H5LTparse.h" -int my_yyinput(char *, int); +static char *trim_quotes(const char *); +static int my_yyinput(char *, int); #undef YY_INPUT #define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms)) #define token(x) (int)x @@ -1147,45 +930,10 @@ int my_yyinput(char *, int); extern char *myinput; extern size_t input_len; -#define STACK_SIZE 16 - -/*variables for compound type*/ -struct cmpd_info { - hid_t id; - hbool_t is_field; - hbool_t first_memb; -}; -extern struct cmpd_info cmpd_stack[STACK_SIZE]; -extern int csindex; - -/*variables for array type*/ -struct arr_info { - hsize_t dims[H5S_MAX_RANK]; - int ndim; - hbool_t is_dim; -}; -extern struct arr_info arr_stack[STACK_SIZE]; -extern int asindex; - -/*variables for enumerate type*/ -extern hbool_t is_enum; -extern hbool_t is_enum_memb; - -/*variables for string type*/ -extern hbool_t is_str_size; - -/*variables for opaque type*/ -extern hbool_t is_opq_size; -extern hbool_t is_opq_tag; - -hbool_t first_quote = 1; - -#line 1162 "hl/src/H5LTanalyze.c" - -#line 1164 "hl/src/H5LTanalyze.c" +#line 903 "hl/src/H5LTanalyze.c" +#line 904 "hl/src/H5LTanalyze.c" #define INITIAL 0 -#define TAG_STRING 1 #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * @@ -1373,12 +1121,6 @@ YY_DECL YY_USER_INIT; #endif - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! (yy_state_buf) ) - (yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE ); - if ( ! (yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in yylex()" ); - if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ @@ -1398,10 +1140,10 @@ YY_DECL } { -#line 89 "hl/src/H5LTanalyze.l" +#line 46 "hl/src/H5LTanalyze.l" -#line 1383 "hl/src/H5LTanalyze.c" +#line 1116 "hl/src/H5LTanalyze.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1416,45 +1158,33 @@ YY_DECL yy_bp = yy_cp; yy_current_state = (yy_start); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - yy_match: do { YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 545 ) + if ( yy_current_state >= 275 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - *(yy_state_ptr)++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 611 ); + while ( yy_base[yy_current_state] != 300 ); yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - -find_rule: /* we branch to this label when backing up */ - - for ( ; ; ) /* until we find what rule we matched */ - { - if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[(yy_lp)]; - { - (yy_full_match) = yy_cp; - break; - } - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; @@ -1463,368 +1193,344 @@ YY_DECL switch ( yy_act ) { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + case 1: YY_RULE_SETUP -#line 91 "hl/src/H5LTanalyze.l" +#line 48 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I8BE_TOKEN);} YY_BREAK case 2: YY_RULE_SETUP -#line 92 "hl/src/H5LTanalyze.l" +#line 49 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I8LE_TOKEN);} YY_BREAK case 3: YY_RULE_SETUP -#line 93 "hl/src/H5LTanalyze.l" +#line 50 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I16BE_TOKEN);} YY_BREAK case 4: YY_RULE_SETUP -#line 94 "hl/src/H5LTanalyze.l" +#line 51 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I16LE_TOKEN);} YY_BREAK case 5: YY_RULE_SETUP -#line 95 "hl/src/H5LTanalyze.l" +#line 52 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I32BE_TOKEN);} YY_BREAK case 6: YY_RULE_SETUP -#line 96 "hl/src/H5LTanalyze.l" +#line 53 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I32LE_TOKEN);} YY_BREAK case 7: YY_RULE_SETUP -#line 97 "hl/src/H5LTanalyze.l" +#line 54 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I64BE_TOKEN);} YY_BREAK case 8: YY_RULE_SETUP -#line 98 "hl/src/H5LTanalyze.l" +#line 55 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_I64LE_TOKEN);} YY_BREAK case 9: YY_RULE_SETUP -#line 100 "hl/src/H5LTanalyze.l" +#line 57 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U8BE_TOKEN);} YY_BREAK case 10: YY_RULE_SETUP -#line 101 "hl/src/H5LTanalyze.l" +#line 58 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U8LE_TOKEN);} YY_BREAK case 11: YY_RULE_SETUP -#line 102 "hl/src/H5LTanalyze.l" +#line 59 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U16BE_TOKEN);} YY_BREAK case 12: YY_RULE_SETUP -#line 103 "hl/src/H5LTanalyze.l" +#line 60 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U16LE_TOKEN);} YY_BREAK case 13: YY_RULE_SETUP -#line 104 "hl/src/H5LTanalyze.l" +#line 61 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U32BE_TOKEN);} YY_BREAK case 14: YY_RULE_SETUP -#line 105 "hl/src/H5LTanalyze.l" +#line 62 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U32LE_TOKEN);} YY_BREAK case 15: YY_RULE_SETUP -#line 106 "hl/src/H5LTanalyze.l" +#line 63 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U64BE_TOKEN);} YY_BREAK case 16: YY_RULE_SETUP -#line 107 "hl/src/H5LTanalyze.l" +#line 64 "hl/src/H5LTanalyze.l" {return hid(H5T_STD_U64LE_TOKEN);} YY_BREAK case 17: YY_RULE_SETUP -#line 109 "hl/src/H5LTanalyze.l" +#line 66 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_CHAR_TOKEN);} YY_BREAK case 18: YY_RULE_SETUP -#line 110 "hl/src/H5LTanalyze.l" +#line 67 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_SCHAR_TOKEN);} YY_BREAK case 19: YY_RULE_SETUP -#line 111 "hl/src/H5LTanalyze.l" +#line 68 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_UCHAR_TOKEN);} YY_BREAK case 20: YY_RULE_SETUP -#line 112 "hl/src/H5LTanalyze.l" +#line 69 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_SHORT_TOKEN);} YY_BREAK case 21: YY_RULE_SETUP -#line 113 "hl/src/H5LTanalyze.l" +#line 70 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_USHORT_TOKEN);} YY_BREAK case 22: YY_RULE_SETUP -#line 114 "hl/src/H5LTanalyze.l" +#line 71 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_INT_TOKEN);} YY_BREAK case 23: YY_RULE_SETUP -#line 115 "hl/src/H5LTanalyze.l" +#line 72 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_UINT_TOKEN);} YY_BREAK case 24: YY_RULE_SETUP -#line 116 "hl/src/H5LTanalyze.l" +#line 73 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_LONG_TOKEN);} YY_BREAK case 25: YY_RULE_SETUP -#line 117 "hl/src/H5LTanalyze.l" +#line 74 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_ULONG_TOKEN);} YY_BREAK case 26: YY_RULE_SETUP -#line 118 "hl/src/H5LTanalyze.l" +#line 75 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_LLONG_TOKEN);} YY_BREAK case 27: YY_RULE_SETUP -#line 119 "hl/src/H5LTanalyze.l" +#line 76 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_ULLONG_TOKEN);} YY_BREAK case 28: YY_RULE_SETUP -#line 121 "hl/src/H5LTanalyze.l" +#line 78 "hl/src/H5LTanalyze.l" {return hid(H5T_IEEE_F32BE_TOKEN);} YY_BREAK case 29: YY_RULE_SETUP -#line 122 "hl/src/H5LTanalyze.l" +#line 79 "hl/src/H5LTanalyze.l" {return hid(H5T_IEEE_F32LE_TOKEN);} YY_BREAK case 30: YY_RULE_SETUP -#line 123 "hl/src/H5LTanalyze.l" +#line 80 "hl/src/H5LTanalyze.l" {return hid(H5T_IEEE_F64BE_TOKEN);} YY_BREAK case 31: YY_RULE_SETUP -#line 124 "hl/src/H5LTanalyze.l" +#line 81 "hl/src/H5LTanalyze.l" {return hid(H5T_IEEE_F64LE_TOKEN);} YY_BREAK case 32: YY_RULE_SETUP -#line 125 "hl/src/H5LTanalyze.l" +#line 82 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_FLOAT_TOKEN);} YY_BREAK case 33: YY_RULE_SETUP -#line 126 "hl/src/H5LTanalyze.l" +#line 83 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_DOUBLE_TOKEN);} YY_BREAK case 34: YY_RULE_SETUP -#line 127 "hl/src/H5LTanalyze.l" +#line 84 "hl/src/H5LTanalyze.l" {return hid(H5T_NATIVE_LDOUBLE_TOKEN);} YY_BREAK case 35: YY_RULE_SETUP -#line 129 "hl/src/H5LTanalyze.l" +#line 86 "hl/src/H5LTanalyze.l" {return token(H5T_STRING_TOKEN);} YY_BREAK case 36: YY_RULE_SETUP -#line 130 "hl/src/H5LTanalyze.l" +#line 87 "hl/src/H5LTanalyze.l" {return token(STRSIZE_TOKEN);} YY_BREAK case 37: YY_RULE_SETUP -#line 131 "hl/src/H5LTanalyze.l" +#line 88 "hl/src/H5LTanalyze.l" {return token(STRPAD_TOKEN);} YY_BREAK case 38: YY_RULE_SETUP -#line 132 "hl/src/H5LTanalyze.l" +#line 89 "hl/src/H5LTanalyze.l" {return token(CSET_TOKEN);} YY_BREAK case 39: YY_RULE_SETUP -#line 133 "hl/src/H5LTanalyze.l" +#line 90 "hl/src/H5LTanalyze.l" {return token(CTYPE_TOKEN);} YY_BREAK case 40: YY_RULE_SETUP -#line 134 "hl/src/H5LTanalyze.l" -{return token(H5T_STR_NULLTERM_TOKEN);} +#line 91 "hl/src/H5LTanalyze.l" +{return token(H5T_STR_NULLTERM_TOKEN);} YY_BREAK case 41: YY_RULE_SETUP -#line 135 "hl/src/H5LTanalyze.l" -{return token(H5T_STR_NULLPAD_TOKEN);} +#line 92 "hl/src/H5LTanalyze.l" +{return token(H5T_STR_NULLPAD_TOKEN);} YY_BREAK case 42: YY_RULE_SETUP -#line 136 "hl/src/H5LTanalyze.l" -{return token(H5T_STR_SPACEPAD_TOKEN);} +#line 93 "hl/src/H5LTanalyze.l" +{return token(H5T_STR_SPACEPAD_TOKEN);} YY_BREAK case 43: YY_RULE_SETUP -#line 137 "hl/src/H5LTanalyze.l" +#line 94 "hl/src/H5LTanalyze.l" {return token(H5T_CSET_ASCII_TOKEN);} YY_BREAK case 44: YY_RULE_SETUP -#line 138 "hl/src/H5LTanalyze.l" +#line 95 "hl/src/H5LTanalyze.l" {return token(H5T_CSET_UTF8_TOKEN);} YY_BREAK case 45: YY_RULE_SETUP -#line 139 "hl/src/H5LTanalyze.l" +#line 96 "hl/src/H5LTanalyze.l" {return token(H5T_C_S1_TOKEN);} YY_BREAK case 46: YY_RULE_SETUP -#line 140 "hl/src/H5LTanalyze.l" +#line 97 "hl/src/H5LTanalyze.l" {return token(H5T_FORTRAN_S1_TOKEN);} YY_BREAK case 47: YY_RULE_SETUP -#line 141 "hl/src/H5LTanalyze.l" +#line 98 "hl/src/H5LTanalyze.l" {return token(H5T_VARIABLE_TOKEN);} YY_BREAK case 48: YY_RULE_SETUP -#line 143 "hl/src/H5LTanalyze.l" +#line 100 "hl/src/H5LTanalyze.l" {return token(H5T_COMPOUND_TOKEN);} YY_BREAK case 49: YY_RULE_SETUP -#line 144 "hl/src/H5LTanalyze.l" +#line 101 "hl/src/H5LTanalyze.l" {return token(H5T_ENUM_TOKEN);} YY_BREAK case 50: YY_RULE_SETUP -#line 145 "hl/src/H5LTanalyze.l" +#line 102 "hl/src/H5LTanalyze.l" {return token(H5T_ARRAY_TOKEN);} YY_BREAK case 51: YY_RULE_SETUP -#line 146 "hl/src/H5LTanalyze.l" +#line 103 "hl/src/H5LTanalyze.l" {return token(H5T_VLEN_TOKEN);} YY_BREAK case 52: YY_RULE_SETUP -#line 148 "hl/src/H5LTanalyze.l" +#line 105 "hl/src/H5LTanalyze.l" {return token(H5T_OPAQUE_TOKEN);} YY_BREAK case 53: YY_RULE_SETUP -#line 149 "hl/src/H5LTanalyze.l" +#line 106 "hl/src/H5LTanalyze.l" {return token(OPQ_SIZE_TOKEN);} YY_BREAK case 54: YY_RULE_SETUP -#line 150 "hl/src/H5LTanalyze.l" +#line 107 "hl/src/H5LTanalyze.l" {return token(OPQ_TAG_TOKEN);} YY_BREAK case 55: YY_RULE_SETUP -#line 152 "hl/src/H5LTanalyze.l" -{ - if( is_str_size || (is_enum && is_enum_memb) || - is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) || - (csindex>-1 && cmpd_stack[csindex].is_field) ) { - H5LTyylval.ival = atoi(yytext); - return NUMBER; - } else - REJECT; - } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 162 "hl/src/H5LTanalyze.l" +#line 109 "hl/src/H5LTanalyze.l" { - /*if it's first quote, and is a compound field name or an enum symbol*/ - if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field)) - && first_quote) { - first_quote = 0; - BEGIN TAG_STRING; - } else /*if it's second quote*/ - first_quote = 1; - return token('"'); + H5LTyylval.ival = HDatoi(yytext); + return NUMBER; } YY_BREAK -case 57: -/* rule 57 can match eol */ +case 56: +/* rule 56 can match eol */ YY_RULE_SETUP -#line 172 "hl/src/H5LTanalyze.l" +#line 114 "hl/src/H5LTanalyze.l" { -#ifdef H5_HAVE_WIN32_API - H5LTyylval.sval = _strdup(yytext); -#else /* H5_HAVE_WIN32_API */ - H5LTyylval.sval = strdup(yytext); -#endif /* H5_HAVE_WIN32_API */ - BEGIN INITIAL; + H5LTyylval.sval = trim_quotes(yytext); return STRING; } YY_BREAK -case 58: +case 57: YY_RULE_SETUP -#line 182 "hl/src/H5LTanalyze.l" +#line 119 "hl/src/H5LTanalyze.l" {return token('{');} YY_BREAK -case 59: +case 58: YY_RULE_SETUP -#line 183 "hl/src/H5LTanalyze.l" +#line 120 "hl/src/H5LTanalyze.l" {return token('}');} YY_BREAK -case 60: +case 59: YY_RULE_SETUP -#line 184 "hl/src/H5LTanalyze.l" +#line 121 "hl/src/H5LTanalyze.l" {return token('[');} YY_BREAK -case 61: +case 60: YY_RULE_SETUP -#line 185 "hl/src/H5LTanalyze.l" +#line 122 "hl/src/H5LTanalyze.l" {return token(']');} YY_BREAK -case 62: +case 61: YY_RULE_SETUP -#line 186 "hl/src/H5LTanalyze.l" +#line 123 "hl/src/H5LTanalyze.l" {return token(':');} YY_BREAK -case 63: +case 62: YY_RULE_SETUP -#line 187 "hl/src/H5LTanalyze.l" +#line 124 "hl/src/H5LTanalyze.l" {return token(';');} YY_BREAK -case 64: -/* rule 64 can match eol */ +case 63: +/* rule 63 can match eol */ YY_RULE_SETUP -#line 188 "hl/src/H5LTanalyze.l" +#line 125 "hl/src/H5LTanalyze.l" ; YY_BREAK -case 65: -/* rule 65 can match eol */ -YY_RULE_SETUP -#line 189 "hl/src/H5LTanalyze.l" -{ return 0; } - YY_BREAK -case 66: +case 64: YY_RULE_SETUP -#line 191 "hl/src/H5LTanalyze.l" +#line 127 "hl/src/H5LTanalyze.l" ECHO; YY_BREAK -#line 1803 "hl/src/H5LTanalyze.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(TAG_STRING): - yyterminate(); +#line 1501 "hl/src/H5LTanalyze.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); case YY_END_OF_BUFFER: { @@ -2015,8 +1721,38 @@ static int yy_get_next_buffer (void) while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; } @@ -2078,20 +1814,21 @@ static int yy_get_next_buffer (void) yy_current_state = (yy_start); - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 545 ) + if ( yy_current_state >= 275 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - *(yy_state_ptr)++ = yy_current_state; } return yy_current_state; @@ -2105,18 +1842,22 @@ static int yy_get_next_buffer (void) static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { int yy_is_jam; - + char *yy_cp = (yy_c_buf_p); + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 545 ) + if ( yy_current_state >= 275 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 544); - if ( ! yy_is_jam ) - *(yy_state_ptr)++ = yy_current_state; + yy_is_jam = (yy_current_state == 274); return yy_is_jam ? 0 : yy_current_state; } @@ -2705,11 +2446,6 @@ static int yy_init_globals (void) (yy_init) = 0; (yy_start) = 0; - (yy_state_buf) = 0; - (yy_state_ptr) = 0; - (yy_full_match) = 0; - (yy_lp) = 0; - /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; @@ -2740,9 +2476,6 @@ int yylex_destroy (void) yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; - yyfree ( (yy_state_buf) ); - (yy_state_buf) = NULL; - /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( ); @@ -2800,20 +2533,39 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 191 "hl/src/H5LTanalyze.l" +#line 127 "hl/src/H5LTanalyze.l" + -int my_yyinput(char *buf, int max_size) +/* Allocate a copy of `quoted` with the double quote character at + * the beginning and the one at the end both removed. The caller is + * responsible for free()ing the copy. + */ +static char * +trim_quotes(const char *quoted) +{ + size_t len = HDstrlen(quoted); + char *trimmed; + + HDassert(quoted[0] == '"' && quoted[len - 1] == '"'); + + trimmed = HDstrdup(quoted + 1); + trimmed[len - 2] = '\0'; + + return trimmed; +} + +static int my_yyinput(char *buf, int max_size) { int ret; - - memcpy(buf, myinput, input_len); + + HDmemcpy(buf, myinput, input_len); ret = (int)input_len; return ret; } int H5LTyyerror(const char *msg) { - printf("ERROR: %s before \"%s\".\n", msg, yytext); + HDprintf("ERROR: %s before \"%s\".\n", msg, yytext); return 0; } diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index cdd5b0dc530..50066126fbf 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,24 +18,16 @@ */ %{ +#include #include #include #include -#include "H5LTparse.h" - -/* Turn off suggest const & malloc attribute warnings in gcc */ -#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ -#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" -#endif -/* Turn off null dereference warnings in gcc. - * We have no control over this generated code. - */ -#if defined __GNUC__ && 600 <= __GNUC__ * 100 -#pragma GCC diagnostic ignored "-Wnull-dereference" -#endif +#include "H5private.h" +#include "H5LTparse.h" -int my_yyinput(char *, int); +static char *trim_quotes(const char *); +static int my_yyinput(char *, int); #undef YY_INPUT #define YY_INPUT(b, r, ms) (r=my_yyinput(b, ms)) #define token(x) (int)x @@ -49,43 +41,8 @@ int my_yyinput(char *, int); extern char *myinput; extern size_t input_len; -#define STACK_SIZE 16 - -/*variables for compound type*/ -struct cmpd_info { - hid_t id; - hbool_t is_field; - hbool_t first_memb; -}; -extern struct cmpd_info cmpd_stack[STACK_SIZE]; -extern int csindex; - -/*variables for array type*/ -struct arr_info { - hsize_t dims[H5S_MAX_RANK]; - int ndim; - hbool_t is_dim; -}; -extern struct arr_info arr_stack[STACK_SIZE]; -extern int asindex; - -/*variables for enumerate type*/ -extern hbool_t is_enum; -extern hbool_t is_enum_memb; - -/*variables for string type*/ -extern hbool_t is_str_size; - -/*variables for opaque type*/ -extern hbool_t is_opq_size; -extern hbool_t is_opq_tag; - -hbool_t first_quote = 1; - %} -%s TAG_STRING - %% H5T_STD_I8BE {return hid(H5T_STD_I8BE_TOKEN);} @@ -131,9 +88,9 @@ STRSIZE {return token(STRSIZE_TOKEN);} STRPAD {return token(STRPAD_TOKEN);} CSET {return token(CSET_TOKEN);} CTYPE {return token(CTYPE_TOKEN);} -H5T_STR_NULLTERM {return token(H5T_STR_NULLTERM_TOKEN);} -H5T_STR_NULLPAD {return token(H5T_STR_NULLPAD_TOKEN);} -H5T_STR_SPACEPAD {return token(H5T_STR_SPACEPAD_TOKEN);} +H5T_STR_NULLTERM {return token(H5T_STR_NULLTERM_TOKEN);} +H5T_STR_NULLPAD {return token(H5T_STR_NULLPAD_TOKEN);} +H5T_STR_SPACEPAD {return token(H5T_STR_SPACEPAD_TOKEN);} H5T_CSET_ASCII {return token(H5T_CSET_ASCII_TOKEN);} H5T_CSET_UTF8 {return token(H5T_CSET_UTF8_TOKEN);} H5T_C_S1 {return token(H5T_C_S1_TOKEN);} @@ -149,36 +106,16 @@ H5T_OPAQUE {return token(H5T_OPAQUE_TOKEN);} OPQ_SIZE {return token(OPQ_SIZE_TOKEN);} OPQ_TAG {return token(OPQ_TAG_TOKEN);} -[0-9]+ { - if( is_str_size || (is_enum && is_enum_memb) || - is_opq_size || (asindex>-1 && arr_stack[asindex].is_dim) || - (csindex>-1 && cmpd_stack[csindex].is_field) ) { - H5LTyylval.ival = atoi(yytext); - return NUMBER; - } else - REJECT; +[0-9]+ { + H5LTyylval.ival = HDatoi(yytext); + return NUMBER; } -"\"" { - /*if it's first quote, and is a compound field name or an enum symbol*/ - if((is_opq_tag || is_enum || (csindex>-1 && cmpd_stack[csindex].is_field)) - && first_quote) { - first_quote = 0; - BEGIN TAG_STRING; - } else /*if it's second quote*/ - first_quote = 1; - return token('"'); - } -[^\"]+ { -#ifdef H5_HAVE_WIN32_API - H5LTyylval.sval = _strdup(yytext); -#else /* H5_HAVE_WIN32_API */ - H5LTyylval.sval = strdup(yytext); -#endif /* H5_HAVE_WIN32_API */ - BEGIN INITIAL; +["][^\"]+["] { + H5LTyylval.sval = trim_quotes(yytext); return STRING; } - + "{" {return token('{');} "}" {return token('}');} "[" {return token('[');} @@ -186,21 +123,39 @@ OPQ_TAG {return token(OPQ_TAG_TOKEN);} ":" {return token(':');} ";" {return token(';');} [ \t\n]* ; -"\n" { return 0; } %% -int my_yyinput(char *buf, int max_size) + +/* Allocate a copy of `quoted` with the double quote character at + * the beginning and the one at the end both removed. The caller is + * responsible for free()ing the copy. + */ +static char * +trim_quotes(const char *quoted) +{ + size_t len = HDstrlen(quoted); + char *trimmed; + + HDassert(quoted[0] == '"' && quoted[len - 1] == '"'); + + trimmed = HDstrdup(quoted + 1); + trimmed[len - 2] = '\0'; + + return trimmed; +} + +static int my_yyinput(char *buf, int max_size) { int ret; - - memcpy(buf, myinput, input_len); + + HDmemcpy(buf, myinput, input_len); ret = (int)input_len; return ret; } int H5LTyyerror(const char *msg) { - printf("ERROR: %s before \"%s\".\n", msg, yytext); + HDprintf("ERROR: %s before \"%s\".\n", msg, yytext); return 0; } diff --git a/hl/src/H5LTparse.c b/hl/src/H5LTparse.c index a9b3dc38802..7f552d8cb00 100644 --- a/hl/src/H5LTparse.c +++ b/hl/src/H5LTparse.c @@ -1,7 +1,7 @@ -#if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined (__GNUC__) +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wimplicit-function-declaration" -#pragma GCC diagnostic ignored "-Wlarger-than=" #pragma GCC diagnostic ignored "-Wmissing-prototypes" #pragma GCC diagnostic ignored "-Wnested-externs" #pragma GCC diagnostic ignored "-Wold-style-definition" @@ -10,11 +10,19 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wstrict-overflow" #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wlarger-than=" +#pragma GCC diagnostic ignored "-Wsuggest-attribute=const" #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" +#endif #pragma GCC diagnostic ignored "-Wswitch-default" #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-macros" #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif +#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 600 +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif #elif defined __SUNPRO_CC #pragma disable_warn #elif defined _MSC_VER @@ -98,7 +106,9 @@ #include #include -extern int yylex(); +#include "H5private.h" + +extern int yylex(void); extern int yyerror(const char *); #define STACK_SIZE 16 @@ -111,13 +121,13 @@ struct cmpd_info { }; /*stack for nested compound type*/ -struct cmpd_info cmpd_stack[STACK_SIZE] = { +static struct cmpd_info cmpd_stack[STACK_SIZE] = { {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1} }; -int csindex = -1; /*pointer to the top of compound stack*/ +static int csindex = -1; /*pointer to the top of compound stack*/ /*structure for array type information*/ struct arr_info { @@ -126,26 +136,21 @@ struct arr_info { hbool_t is_dim; /*flag to lexer for dimension*/ }; /*stack for nested array type*/ -struct arr_info arr_stack[STACK_SIZE]; -int asindex = -1; /*pointer to the top of array stack*/ - -hbool_t is_str_size = 0; /*flag to lexer for string size*/ -hbool_t is_str_pad = 0; /*flag to lexer for string padding*/ -H5T_str_t str_pad; /*variable for string padding*/ -H5T_cset_t str_cset; /*variable for string character set*/ -hbool_t is_variable = 0; /*variable for variable-length string*/ -size_t str_size; /*variable for string size*/ - -hid_t enum_id; /*type ID*/ -hbool_t is_enum = 0; /*flag to lexer for enum type*/ -hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/ -char* enum_memb_symbol; /*enum member symbol string*/ +static struct arr_info arr_stack[STACK_SIZE]; +static int asindex = -1; /*pointer to the top of array stack*/ -hbool_t is_opq_size = 0; /*flag to lexer for opaque type size*/ -hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/ +static H5T_str_t str_pad; /*variable for string padding*/ +static H5T_cset_t str_cset; /*variable for string character set*/ +static hbool_t is_variable = 0; /*variable for variable-length string*/ +static size_t str_size; /*variable for string size*/ + +static hid_t enum_id; /*type ID*/ +static hbool_t is_enum = 0; /*flag to lexer for enum type*/ +static hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/ +static char* enum_memb_symbol; /*enum member symbol string*/ -#line 127 "hl/src/H5LTparse.c" /* yacc.c:339 */ +#line 124 "hl/src/H5LTparse.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -244,13 +249,13 @@ extern int H5LTyydebug; union YYSTYPE { -#line 72 "hl/src/H5LTparse.y" /* yacc.c:355 */ +#line 69 "hl/src/H5LTparse.y" /* yacc.c:355 */ int ival; /*for integer token*/ char *sval; /*for name string*/ hid_t hid; /*for hid_t token*/ -#line 232 "hl/src/H5LTparse.c" /* yacc.c:355 */ +#line 229 "hl/src/H5LTparse.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -267,7 +272,7 @@ hid_t H5LTyyparse (void); /* Copy the second part of user declarations. */ -#line 249 "hl/src/H5LTparse.c" /* yacc.c:358 */ +#line 246 "hl/src/H5LTparse.c" /* yacc.c:358 */ #ifdef short # undef short @@ -509,16 +514,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 58 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 203 +#define YYLAST 197 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 66 +#define YYNTOKENS 65 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 46 +#define YYNNTS 43 /* YYNRULES -- Number of rules. */ -#define YYNRULES 95 +#define YYNRULES 92 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 143 +#define YYNSTATES 134 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ @@ -535,9 +540,9 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 63, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 64, 65, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 63, 64, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -570,16 +575,16 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 105, 105, 106, 108, 109, 110, 111, 113, 114, - 115, 116, 117, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, - 149, 150, 151, 152, 153, 154, 155, 159, 158, 167, - 168, 170, 170, 207, 215, 216, 219, 221, 221, 230, - 231, 233, 234, 233, 241, 244, 250, 251, 256, 257, - 248, 265, 267, 271, 272, 280, 289, 296, 269, 320, - 321, 323, 324, 325, 327, 328, 330, 331, 335, 334, - 339, 340, 342, 342, 396, 398 + 0, 102, 102, 103, 105, 106, 107, 108, 110, 111, + 112, 113, 114, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 146, 147, 148, 149, 150, 151, 152, 156, 155, 164, + 165, 167, 167, 204, 212, 213, 216, 218, 218, 227, + 228, 230, 231, 230, 238, 241, 248, 253, 245, 260, + 262, 267, 274, 283, 290, 264, 314, 315, 317, 318, + 319, 321, 322, 324, 325, 329, 328, 333, 334, 336, + 336, 386, 388 }; #endif @@ -609,14 +614,14 @@ static const char *const yytname[] = "H5T_C_S1_TOKEN", "H5T_FORTRAN_S1_TOKEN", "H5T_OPAQUE_TOKEN", "OPQ_SIZE_TOKEN", "OPQ_TAG_TOKEN", "H5T_COMPOUND_TOKEN", "H5T_ENUM_TOKEN", "H5T_ARRAY_TOKEN", "H5T_VLEN_TOKEN", "STRING", - "NUMBER", "'{'", "'}'", "'['", "']'", "'\"'", "':'", "';'", "$accept", - "start", "ddl_type", "atomic_type", "integer_type", "fp_type", - "compound_type", "$@1", "memb_list", "memb_def", "$@2", "field_name", - "field_offset", "offset", "array_type", "$@3", "dim_list", "dim", "$@4", - "$@5", "dimsize", "vlen_type", "opaque_type", "$@6", "@7", "$@8", "$@9", - "opaque_size", "opaque_tag", "string_type", "$@10", "$@11", "$@12", - "$@13", "@14", "strsize", "strpad", "cset", "ctype", "enum_type", "$@15", - "enum_list", "enum_def", "$@16", "enum_symbol", "enum_val", YY_NULLPTR + "NUMBER", "'{'", "'}'", "'['", "']'", "':'", "';'", "$accept", "start", + "ddl_type", "atomic_type", "integer_type", "fp_type", "compound_type", + "$@1", "memb_list", "memb_def", "$@2", "field_name", "field_offset", + "offset", "array_type", "$@3", "dim_list", "dim", "$@4", "$@5", + "dimsize", "vlen_type", "opaque_type", "@6", "$@7", "opaque_size", + "opaque_tag", "string_type", "$@8", "$@9", "$@10", "@11", "strsize", + "strpad", "cset", "ctype", "enum_type", "$@12", "enum_list", "enum_def", + "$@13", "enum_symbol", "enum_val", YY_NULLPTR }; #endif @@ -631,7 +636,7 @@ static const yytype_uint16 yytoknum[] = 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 123, - 125, 91, 93, 34, 58, 59 + 125, 91, 93, 58, 59 }; # endif @@ -652,18 +657,17 @@ static const yytype_int16 yypact[] = 114, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -24, -20, -25, -15, -25, - -14, 49, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, 19, 45, 38, 168, 39, 114, -25, -25, - -25, -25, 34, -25, 40, -4, 43, 56, -25, -3, - -25, -25, -25, 37, -25, 42, -25, -25, -25, -25, - -25, 44, -25, -25, -25, 50, -23, 47, -25, 64, - 62, 51, -25, 58, -25, -25, -25, -2, -25, -25, - 89, -25, 90, 92, -25, -25, -25, 91, 94, 95, - -25, -25, -25, 98, 100, 96, 102, 122, -25, 103, - -25, -25, -25, -25, 133, 9, 134, -25, -25, -25, - 135, -25, -25, 105, 160, -25, 46, -25, -25, 137, - -25, 143, -25 + -25, -25, -25, -25, -25, -24, -22, -25, -13, -25, + -11, 49, -25, -25, -25, -25, -25, -25, -25, -25, + -25, -25, 18, 45, 38, 168, 39, 114, -25, -4, + 41, -25, 36, -25, 42, -25, -25, 37, -25, 40, + 56, -25, -3, -25, -25, -25, -25, -25, -25, -25, + -25, 43, -25, 66, 55, 51, -21, 57, -25, 0, + 95, -25, 50, -25, -25, -25, -25, -25, -25, -25, + -25, -25, 89, -25, 90, 97, 92, 99, 52, -25, + -25, -25, -25, -25, -25, 94, -25, 119, 100, -25, + -6, -25, -25, -25, 98, -25, 120, 46, -25, -25, + 101, -25, 103, -25 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -676,36 +680,35 @@ static const yytype_uint8 yydefact[] = 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 0, 0, 47, 0, 57, 0, 0, 3, 4, 8, 9, 5, 6, 7, 12, - 10, 11, 0, 0, 0, 0, 0, 0, 1, 73, - 66, 49, 0, 59, 0, 0, 0, 0, 88, 0, - 65, 79, 80, 0, 71, 0, 48, 51, 50, 90, - 61, 0, 60, 74, 67, 0, 0, 0, 58, 0, - 0, 0, 89, 0, 91, 64, 62, 0, 68, 53, - 0, 94, 0, 0, 81, 82, 83, 0, 0, 54, - 92, 63, 75, 0, 0, 0, 0, 0, 72, 0, - 56, 55, 52, 95, 0, 0, 0, 93, 84, 85, - 0, 69, 76, 0, 0, 70, 0, 86, 87, 0, - 77, 0, 78 + 10, 11, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 49, 0, 59, 0, 76, 77, 0, 69, 0, + 0, 85, 0, 65, 71, 66, 48, 51, 50, 87, + 61, 0, 60, 0, 0, 0, 0, 0, 58, 0, + 0, 53, 54, 91, 86, 88, 89, 64, 62, 78, + 79, 80, 0, 70, 0, 0, 0, 0, 0, 72, + 67, 56, 55, 52, 92, 0, 63, 0, 0, 90, + 0, 68, 81, 82, 0, 73, 0, 0, 83, 84, + 0, 74, 0, 75 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -25, -25, -21, -25, 108, -25, -25, -25, -25, -25, + -25, -25, -15, -25, 111, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -25 + -25, -25, -25 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 41, 42, 43, 44, 45, 46, 54, 67, 78, - 85, 100, 115, 121, 47, 56, 69, 82, 87, 103, - 96, 48, 49, 66, 90, 108, 133, 75, 119, 50, - 65, 89, 117, 134, 141, 73, 107, 130, 139, 51, - 79, 86, 94, 116, 102, 124 + -1, 41, 42, 43, 44, 45, 46, 54, 70, 78, + 85, 92, 106, 112, 47, 56, 72, 82, 87, 108, + 98, 48, 49, 84, 118, 69, 104, 50, 83, 117, + 126, 132, 67, 102, 124, 130, 51, 79, 86, 95, + 107, 96, 115 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -716,24 +719,23 @@ static const yytype_uint8 yytable[] = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 52, 64, 92, 71, 53, - 93, 104, 105, 106, 55, 57, 77, 36, 81, 58, - 37, 38, 39, 40, 72, 128, 129, 59, 80, 1, + 31, 32, 33, 34, 35, 52, 93, 53, 65, 94, + 122, 123, 64, 99, 100, 101, 55, 36, 57, 58, + 37, 38, 39, 40, 66, 77, 59, 81, 80, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 137, 138, 60, 61, 63, 68, - 70, 74, 83, 97, 88, 95, 36, 84, 99, 37, - 38, 39, 40, 91, 98, 101, 76, 1, 2, 3, + 32, 33, 34, 35, 128, 129, 60, 61, 63, 68, + 71, 74, 73, 88, 75, 89, 36, 90, 91, 37, + 38, 39, 40, 105, 116, 97, 76, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 109, 110, 111, 118, 112, 113, 120, 114, - 123, 122, 125, 62, 36, 135, 126, 37, 38, 39, + 34, 35, 103, 109, 110, 111, 113, 114, 119, 120, + 121, 127, 125, 133, 36, 131, 62, 37, 38, 39, 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 127, 131, - 132, 136, 140, 142 + 20, 21, 22, 23, 24, 25, 26, 27 }; static const yytype_uint8 yycheck[] = @@ -741,24 +743,23 @@ static const yytype_uint8 yycheck[] = 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 59, 57, 60, 42, 59, - 63, 43, 44, 45, 59, 59, 67, 50, 69, 0, - 53, 54, 55, 56, 58, 46, 47, 38, 61, 3, + 33, 34, 35, 36, 37, 59, 57, 59, 42, 60, + 46, 47, 57, 43, 44, 45, 59, 50, 59, 0, + 53, 54, 55, 56, 58, 70, 38, 72, 61, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 48, 49, 51, 59, 59, 65, - 60, 58, 65, 39, 60, 58, 50, 65, 57, 53, - 54, 55, 56, 63, 52, 57, 60, 3, 4, 5, + 34, 35, 36, 37, 48, 49, 51, 59, 59, 58, + 64, 64, 60, 60, 64, 39, 50, 52, 57, 53, + 54, 55, 56, 63, 62, 58, 60, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 63, 63, 62, 57, 65, 63, 58, 64, - 58, 65, 40, 55, 50, 60, 63, 53, 54, 55, + 36, 37, 57, 64, 64, 58, 64, 58, 64, 40, + 60, 41, 64, 60, 50, 64, 55, 53, 54, 55, 56, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 65, 65, - 65, 41, 65, 60 + 22, 23, 24, 25, 26, 27, 28, 29 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -769,32 +770,31 @@ static const yytype_uint8 yystos[] = 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 50, 53, 54, 55, - 56, 67, 68, 69, 70, 71, 72, 80, 87, 88, - 95, 105, 59, 59, 73, 59, 81, 59, 0, 38, - 51, 59, 70, 59, 68, 96, 89, 74, 65, 82, - 60, 42, 58, 101, 58, 93, 60, 68, 75, 106, - 61, 68, 83, 65, 65, 76, 107, 84, 60, 97, - 90, 63, 60, 63, 108, 58, 86, 39, 52, 57, - 77, 57, 110, 85, 43, 44, 45, 102, 91, 63, - 63, 62, 65, 63, 64, 78, 109, 98, 57, 94, - 58, 79, 65, 58, 111, 40, 63, 65, 46, 47, - 103, 65, 65, 92, 99, 60, 41, 48, 49, 104, - 65, 100, 60 + 56, 66, 67, 68, 69, 70, 71, 79, 86, 87, + 92, 101, 59, 59, 72, 59, 80, 59, 0, 38, + 51, 59, 69, 59, 67, 42, 58, 97, 58, 90, + 73, 64, 81, 60, 64, 64, 60, 67, 74, 102, + 61, 67, 82, 93, 88, 75, 103, 83, 60, 39, + 52, 57, 76, 57, 60, 104, 106, 58, 85, 43, + 44, 45, 98, 57, 91, 63, 77, 105, 84, 64, + 64, 58, 78, 64, 58, 107, 62, 94, 89, 64, + 40, 60, 46, 47, 99, 64, 95, 41, 48, 49, + 100, 64, 96, 60 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 66, 67, 67, 68, 68, 68, 68, 69, 69, - 69, 69, 69, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 71, 71, 71, 71, 71, 71, 71, 73, 72, 74, - 74, 76, 75, 77, 78, 78, 79, 81, 80, 82, - 82, 84, 85, 83, 86, 87, 89, 90, 91, 92, - 88, 93, 94, 96, 97, 98, 99, 100, 95, 101, - 101, 102, 102, 102, 103, 103, 104, 104, 106, 105, - 107, 107, 109, 108, 110, 111 + 0, 65, 66, 66, 67, 67, 67, 67, 68, 68, + 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 70, 70, 70, 70, 70, 70, 70, 72, 71, 73, + 73, 75, 74, 76, 77, 77, 78, 80, 79, 81, + 81, 83, 84, 82, 85, 86, 88, 89, 87, 90, + 91, 93, 94, 95, 96, 92, 97, 97, 98, 98, + 98, 99, 99, 100, 100, 102, 101, 103, 103, 105, + 104, 106, 107 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -805,11 +805,11 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 5, 0, - 2, 0, 7, 1, 0, 2, 1, 0, 6, 0, - 2, 0, 0, 5, 1, 4, 0, 0, 0, 0, - 15, 1, 1, 0, 0, 0, 0, 0, 20, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 7, - 0, 2, 0, 6, 1, 1 + 2, 0, 5, 1, 0, 2, 1, 0, 6, 0, + 2, 0, 0, 5, 1, 4, 0, 0, 11, 1, + 1, 0, 0, 0, 0, 19, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 7, 0, 2, 0, + 4, 1, 1 }; @@ -1486,402 +1486,381 @@ yyparse (void) switch (yyn) { case 2: -#line 105 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 102 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ } -#line 1470 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1462 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 3: -#line 106 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 103 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { return (yyval.hid);} -#line 1476 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1468 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 13: -#line 120 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 117 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I8BE); } -#line 1482 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1474 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 14: -#line 121 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 118 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I8LE); } -#line 1488 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1480 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 15: -#line 122 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 119 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I16BE); } -#line 1494 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1486 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 16: -#line 123 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 120 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I16LE); } -#line 1500 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1492 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 17: -#line 124 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 121 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I32BE); } -#line 1506 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1498 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 18: -#line 125 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 122 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I32LE); } -#line 1512 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1504 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 19: -#line 126 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 123 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I64BE); } -#line 1518 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1510 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 20: -#line 127 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 124 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_I64LE); } -#line 1524 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1516 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 21: -#line 128 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 125 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U8BE); } -#line 1530 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1522 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 22: -#line 129 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 126 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U8LE); } -#line 1536 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1528 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 23: -#line 130 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 127 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U16BE); } -#line 1542 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1534 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 24: -#line 131 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 128 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U16LE); } -#line 1548 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1540 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 25: -#line 132 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 129 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U32BE); } -#line 1554 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1546 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 26: -#line 133 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 130 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U32LE); } -#line 1560 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1552 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 27: -#line 134 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 131 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U64BE); } -#line 1566 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1558 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 28: -#line 135 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 132 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_STD_U64LE); } -#line 1572 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1564 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 29: -#line 136 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 133 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_CHAR); } -#line 1578 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1570 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 30: -#line 137 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 134 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_SCHAR); } -#line 1584 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1576 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 31: -#line 138 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 135 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_UCHAR); } -#line 1590 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1582 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 32: -#line 139 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 136 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_SHORT); } -#line 1596 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1588 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 33: -#line 140 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 137 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_USHORT); } -#line 1602 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1594 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 34: -#line 141 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 138 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_INT); } -#line 1608 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1600 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 35: -#line 142 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 139 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_UINT); } -#line 1614 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1606 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 36: -#line 143 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 140 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_LONG); } -#line 1620 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1612 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 37: -#line 144 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 141 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULONG); } -#line 1626 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1618 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 38: -#line 145 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 142 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_LLONG); } -#line 1632 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1624 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 39: -#line 146 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 143 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULLONG); } -#line 1638 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1630 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 40: -#line 149 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 146 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_IEEE_F32BE); } -#line 1644 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1636 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 41: -#line 150 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 147 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_IEEE_F32LE); } -#line 1650 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1642 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 42: -#line 151 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 148 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_IEEE_F64BE); } -#line 1656 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1648 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 43: -#line 152 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 149 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_IEEE_F64LE); } -#line 1662 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1654 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 44: -#line 153 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 150 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_FLOAT); } -#line 1668 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1660 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 45: -#line 154 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 151 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_DOUBLE); } -#line 1674 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1666 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 46: -#line 155 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 152 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tcopy(H5T_NATIVE_LDOUBLE); } -#line 1680 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1672 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 47: -#line 159 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 156 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { csindex++; cmpd_stack[csindex].id = H5Tcreate(H5T_COMPOUND, 1); /*temporarily set size to 1*/ } -#line 1686 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1678 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 48: -#line 161 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 158 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = cmpd_stack[csindex].id; cmpd_stack[csindex].id = 0; cmpd_stack[csindex].first_memb = 1; csindex--; } -#line 1696 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1688 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 51: -#line 170 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 167 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ } -#line 1702 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1694 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 52: -#line 172 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 169 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { size_t origin_size, new_size; hid_t dtype_id = cmpd_stack[csindex].id; /*Adjust size and insert member, consider both member size and offset.*/ if(cmpd_stack[csindex].first_memb) { /*reclaim the size 1 temporarily set*/ - new_size = H5Tget_size((yyvsp[-6].hid)) + (yyvsp[-1].ival); + new_size = H5Tget_size((yyvsp[-4].hid)) + (yyvsp[-1].ival); H5Tset_size(dtype_id, new_size); /*member name is saved in yylval.sval by lexer*/ - H5Tinsert(dtype_id, (yyvsp[-3].sval), (yyvsp[-1].ival), (yyvsp[-6].hid)); + H5Tinsert(dtype_id, (yyvsp[-2].sval), (yyvsp[-1].ival), (yyvsp[-4].hid)); cmpd_stack[csindex].first_memb = 0; } else { origin_size = H5Tget_size(dtype_id); if((yyvsp[-1].ival) == 0) { - new_size = origin_size + H5Tget_size((yyvsp[-6].hid)); + new_size = origin_size + H5Tget_size((yyvsp[-4].hid)); H5Tset_size(dtype_id, new_size); - H5Tinsert(dtype_id, (yyvsp[-3].sval), origin_size, (yyvsp[-6].hid)); + H5Tinsert(dtype_id, (yyvsp[-2].sval), origin_size, (yyvsp[-4].hid)); } else { - new_size = (yyvsp[-1].ival) + H5Tget_size((yyvsp[-6].hid)); + new_size = (yyvsp[-1].ival) + H5Tget_size((yyvsp[-4].hid)); H5Tset_size(dtype_id, new_size); - H5Tinsert(dtype_id, (yyvsp[-3].sval), (yyvsp[-1].ival), (yyvsp[-6].hid)); + H5Tinsert(dtype_id, (yyvsp[-2].sval), (yyvsp[-1].ival), (yyvsp[-4].hid)); } } - if((yyvsp[-3].sval)) { - free((yyvsp[-3].sval)); - (yyvsp[-3].sval) = NULL; + if((yyvsp[-2].sval)) { + HDfree((yyvsp[-2].sval)); + (yyvsp[-2].sval) = NULL; } cmpd_stack[csindex].is_field = 0; - H5Tclose((yyvsp[-6].hid)); + H5Tclose((yyvsp[-4].hid)); new_size = H5Tget_size(dtype_id); } -#line 1741 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1733 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 53: -#line 208 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 205 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { - (yyval.sval) = strdup(yylval.sval); - free(yylval.sval); + (yyval.sval) = HDstrdup(yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; } -#line 1751 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1743 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 54: -#line 215 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 212 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.ival) = 0; } -#line 1757 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1749 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 55: -#line 217 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 214 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.ival) = yylval.ival; } -#line 1763 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1755 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 57: -#line 221 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 218 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { asindex++; /*pushd onto the stack*/ } -#line 1769 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1761 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 58: -#line 223 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 220 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tarray_create2((yyvsp[-1].hid), arr_stack[asindex].ndims, arr_stack[asindex].dims); arr_stack[asindex].ndims = 0; asindex--; H5Tclose((yyvsp[-1].hid)); } -#line 1780 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1772 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 61: -#line 233 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 230 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { arr_stack[asindex].is_dim = 1; /*notice lexer of dimension size*/ } -#line 1786 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1778 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 62: -#line 234 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 231 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { unsigned ndims = arr_stack[asindex].ndims; arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival; arr_stack[asindex].ndims++; arr_stack[asindex].is_dim = 0; } -#line 1796 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1788 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 65: -#line 245 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 242 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { (yyval.hid) = H5Tvlen_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } -#line 1802 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1794 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; case 66: -#line 250 "hl/src/H5LTparse.y" /* yacc.c:1646 */ - { is_opq_size = 1; } -#line 1808 "hl/src/H5LTparse.c" /* yacc.c:1646 */ - break; - - case 67: -#line 251 "hl/src/H5LTparse.y" /* yacc.c:1646 */ +#line 248 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { size_t size = (size_t)yylval.ival; (yyval.hid) = H5Tcreate(H5T_OPAQUE, size); - is_opq_size = 0; } -#line 1818 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1803 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 68: -#line 256 "hl/src/H5LTparse.y" /* yacc.c:1646 */ - { is_opq_tag = 1; } -#line 1824 "hl/src/H5LTparse.c" /* yacc.c:1646 */ - break; - - case 69: -#line 257 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 67: +#line 253 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { - H5Tset_tag((yyvsp[-6].hid), yylval.sval); - free(yylval.sval); + H5Tset_tag((yyvsp[-3].hid), yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; - is_opq_tag = 0; } -#line 1835 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1813 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 70: -#line 263 "hl/src/H5LTparse.y" /* yacc.c:1646 */ - { (yyval.hid) = (yyvsp[-8].hid); } -#line 1841 "hl/src/H5LTparse.c" /* yacc.c:1646 */ - break; - - case 73: -#line 271 "hl/src/H5LTparse.y" /* yacc.c:1646 */ - { is_str_size = 1; } -#line 1847 "hl/src/H5LTparse.c" /* yacc.c:1646 */ + case 68: +#line 258 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + { (yyval.hid) = (yyvsp[-5].hid); } +#line 1819 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 74: -#line 272 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 71: +#line 267 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { if((yyvsp[-1].ival) == H5T_VARIABLE_TOKEN) is_variable = 1; else str_size = yylval.ival; - is_str_size = 0; } -#line 1859 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1830 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 75: -#line 280 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 72: +#line 274 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { if((yyvsp[-1].ival) == H5T_STR_NULLTERM_TOKEN) str_pad = H5T_STR_NULLTERM; @@ -1890,33 +1869,33 @@ yyparse (void) else if((yyvsp[-1].ival) == H5T_STR_SPACEPAD_TOKEN) str_pad = H5T_STR_SPACEPAD; } -#line 1872 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1843 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 76: -#line 289 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 73: +#line 283 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { if((yyvsp[-1].ival) == H5T_CSET_ASCII_TOKEN) str_cset = H5T_CSET_ASCII; else if((yyvsp[-1].ival) == H5T_CSET_UTF8_TOKEN) str_cset = H5T_CSET_UTF8; } -#line 1883 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1854 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 77: -#line 296 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 74: +#line 290 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { if((yyvsp[-1].hid) == H5T_C_S1_TOKEN) (yyval.hid) = H5Tcopy(H5T_C_S1); else if((yyvsp[-1].hid) == H5T_FORTRAN_S1_TOKEN) (yyval.hid) = H5Tcopy(H5T_FORTRAN_S1); } -#line 1894 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1865 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 78: -#line 303 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 75: +#line 297 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { hid_t str_id = (yyvsp[-1].hid); @@ -1933,86 +1912,82 @@ yyparse (void) (yyval.hid) = str_id; } -#line 1915 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1886 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 79: -#line 320 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 76: +#line 314 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_VARIABLE_TOKEN;} -#line 1921 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1892 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 81: -#line 323 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 78: +#line 317 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_STR_NULLTERM_TOKEN;} -#line 1927 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1898 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 82: -#line 324 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 79: +#line 318 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_STR_NULLPAD_TOKEN;} -#line 1933 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1904 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 83: -#line 325 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 80: +#line 319 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_STR_SPACEPAD_TOKEN;} -#line 1939 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1910 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 84: -#line 327 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 81: +#line 321 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_CSET_ASCII_TOKEN;} -#line 1945 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1916 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 85: -#line 328 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 82: +#line 322 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.ival) = H5T_CSET_UTF8_TOKEN;} -#line 1951 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1922 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 86: -#line 330 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 83: +#line 324 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.hid) = H5T_C_S1_TOKEN;} -#line 1957 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1928 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 87: -#line 331 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 84: +#line 325 "hl/src/H5LTparse.y" /* yacc.c:1646 */ {(yyval.hid) = H5T_FORTRAN_S1_TOKEN;} -#line 1963 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1934 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 88: -#line 335 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 85: +#line 329 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { is_enum = 1; enum_id = H5Tenum_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } -#line 1969 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1940 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 89: -#line 337 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 86: +#line 331 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { is_enum = 0; /*reset*/ (yyval.hid) = enum_id; } -#line 1975 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1946 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 92: -#line 342 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 89: +#line 336 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { is_enum_memb = 1; /*indicate member of enum*/ -#ifdef H5_HAVE_WIN32_API - enum_memb_symbol = _strdup(yylval.sval); -#else /* H5_HAVE_WIN32_API */ - enum_memb_symbol = strdup(yylval.sval); -#endif /* H5_HAVE_WIN32_API */ - free(yylval.sval); + enum_memb_symbol = HDstrdup(yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; } -#line 1990 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 1957 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; - case 93: -#line 353 "hl/src/H5LTparse.y" /* yacc.c:1646 */ + case 90: +#line 343 "hl/src/H5LTparse.y" /* yacc.c:1646 */ { char char_val=(char)yylval.ival; short short_val=(short)yylval.ival; @@ -2049,17 +2024,17 @@ yyparse (void) } is_enum_memb = 0; - if(enum_memb_symbol) free(enum_memb_symbol); + if(enum_memb_symbol) HDfree(enum_memb_symbol); } H5Tclose(super); H5Tclose(native); } -#line 2037 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 2004 "hl/src/H5LTparse.c" /* yacc.c:1646 */ break; -#line 2041 "hl/src/H5LTparse.c" /* yacc.c:1646 */ +#line 2008 "hl/src/H5LTparse.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/hl/src/H5LTparse.h b/hl/src/H5LTparse.h index e38116aa0ac..9dd2fba7b11 100644 --- a/hl/src/H5LTparse.h +++ b/hl/src/H5LTparse.h @@ -109,7 +109,7 @@ extern int H5LTyydebug; union YYSTYPE { -#line 72 "hl/src/H5LTparse.y" /* yacc.c:1909 */ +#line 69 "hl/src/H5LTparse.y" /* yacc.c:1909 */ int ival; /*for integer token*/ char *sval; /*for name string*/ @@ -126,6 +126,6 @@ typedef union YYSTYPE YYSTYPE; extern YYSTYPE H5LTyylval; -int H5LTyyparse (void); +hid_t H5LTyyparse (void); #endif /* !YY_H5LTYY_HL_SRC_H5LTPARSE_H_INCLUDED */ diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 66a85568555..01f6ded1f61 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,7 +22,9 @@ #include #include -extern int yylex(); +#include "H5private.h" + +extern int yylex(void); extern int yyerror(const char *); #define STACK_SIZE 16 @@ -35,13 +37,13 @@ struct cmpd_info { }; /*stack for nested compound type*/ -struct cmpd_info cmpd_stack[STACK_SIZE] = { +static struct cmpd_info cmpd_stack[STACK_SIZE] = { {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1} }; -int csindex = -1; /*pointer to the top of compound stack*/ +static int csindex = -1; /*pointer to the top of compound stack*/ /*structure for array type information*/ struct arr_info { @@ -50,23 +52,18 @@ struct arr_info { hbool_t is_dim; /*flag to lexer for dimension*/ }; /*stack for nested array type*/ -struct arr_info arr_stack[STACK_SIZE]; -int asindex = -1; /*pointer to the top of array stack*/ +static struct arr_info arr_stack[STACK_SIZE]; +static int asindex = -1; /*pointer to the top of array stack*/ -hbool_t is_str_size = 0; /*flag to lexer for string size*/ -hbool_t is_str_pad = 0; /*flag to lexer for string padding*/ -H5T_str_t str_pad; /*variable for string padding*/ -H5T_cset_t str_cset; /*variable for string character set*/ -hbool_t is_variable = 0; /*variable for variable-length string*/ -size_t str_size; /*variable for string size*/ +static H5T_str_t str_pad; /*variable for string padding*/ +static H5T_cset_t str_cset; /*variable for string character set*/ +static hbool_t is_variable = 0; /*variable for variable-length string*/ +static size_t str_size; /*variable for string size*/ -hid_t enum_id; /*type ID*/ -hbool_t is_enum = 0; /*flag to lexer for enum type*/ -hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/ -char* enum_memb_symbol; /*enum member symbol string*/ - -hbool_t is_opq_size = 0; /*flag to lexer for opaque type size*/ -hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/ +static hid_t enum_id; /*type ID*/ +static hbool_t is_enum = 0; /*flag to lexer for enum type*/ +static hbool_t is_enum_memb = 0; /*flag to lexer for enum member*/ +static char* enum_memb_symbol; /*enum member symbol string*/ %} %union { @@ -99,7 +96,7 @@ hbool_t is_opq_tag = 0; /*flag to lexer for opaque type tag*/ %token STRING %token NUMBER -%token '{' '}' '[' ']' '"' ':' ';' +%token '{' '}' '[' ']' ':' ';' %% start : { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ } @@ -168,35 +165,35 @@ memb_list : | memb_list memb_def ; memb_def : ddl_type { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ } - '"' field_name '"' field_offset ';' + field_name field_offset ';' { size_t origin_size, new_size; hid_t dtype_id = cmpd_stack[csindex].id; /*Adjust size and insert member, consider both member size and offset.*/ if(cmpd_stack[csindex].first_memb) { /*reclaim the size 1 temporarily set*/ - new_size = H5Tget_size($1) + $6; + new_size = H5Tget_size($1) + $4; H5Tset_size(dtype_id, new_size); /*member name is saved in yylval.sval by lexer*/ - H5Tinsert(dtype_id, $4, $6, $1); + H5Tinsert(dtype_id, $3, $4, $1); cmpd_stack[csindex].first_memb = 0; } else { origin_size = H5Tget_size(dtype_id); - if($6 == 0) { + if($4 == 0) { new_size = origin_size + H5Tget_size($1); H5Tset_size(dtype_id, new_size); - H5Tinsert(dtype_id, $4, origin_size, $1); + H5Tinsert(dtype_id, $3, origin_size, $1); } else { - new_size = $6 + H5Tget_size($1); + new_size = $4 + H5Tget_size($1); H5Tset_size(dtype_id, new_size); - H5Tinsert(dtype_id, $4, $6, $1); + H5Tinsert(dtype_id, $3, $4, $1); } } - if($4) { - free($4); - $4 = NULL; + if($3) { + HDfree($3); + $3 = NULL; } cmpd_stack[csindex].is_field = 0; H5Tclose($1); @@ -206,8 +203,8 @@ memb_def : ddl_type { cmpd_stack[csindex].is_field = 1; /*notify le ; field_name : STRING { - $$ = strdup(yylval.sval); - free(yylval.sval); + $$ = HDstrdup(yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; } ; @@ -247,20 +244,18 @@ vlen_type : H5T_VLEN_TOKEN '{' ddl_type '}' opaque_type : H5T_OPAQUE_TOKEN '{' - OPQ_SIZE_TOKEN { is_opq_size = 1; } opaque_size ';' + OPQ_SIZE_TOKEN opaque_size ';' { size_t size = (size_t)yylval.ival; $$ = H5Tcreate(H5T_OPAQUE, size); - is_opq_size = 0; } - OPQ_TAG_TOKEN { is_opq_tag = 1; } '"' opaque_tag '"' ';' + OPQ_TAG_TOKEN opaque_tag ';' { - H5Tset_tag($7, yylval.sval); - free(yylval.sval); + H5Tset_tag($6, yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; - is_opq_tag = 0; } - '}' { $$ = $7; } + '}' { $$ = $6; } ; opaque_size : NUMBER ; @@ -268,40 +263,39 @@ opaque_tag : STRING ; string_type : H5T_STRING_TOKEN '{' - STRSIZE_TOKEN { is_str_size = 1; } strsize ';' + STRSIZE_TOKEN strsize ';' { - if($5 == H5T_VARIABLE_TOKEN) + if($4 == H5T_VARIABLE_TOKEN) is_variable = 1; else str_size = yylval.ival; - is_str_size = 0; } STRPAD_TOKEN strpad ';' { - if($9 == H5T_STR_NULLTERM_TOKEN) + if($8 == H5T_STR_NULLTERM_TOKEN) str_pad = H5T_STR_NULLTERM; - else if($9 == H5T_STR_NULLPAD_TOKEN) + else if($8 == H5T_STR_NULLPAD_TOKEN) str_pad = H5T_STR_NULLPAD; - else if($9 == H5T_STR_SPACEPAD_TOKEN) + else if($8 == H5T_STR_SPACEPAD_TOKEN) str_pad = H5T_STR_SPACEPAD; } CSET_TOKEN cset ';' { - if($13 == H5T_CSET_ASCII_TOKEN) + if($12 == H5T_CSET_ASCII_TOKEN) str_cset = H5T_CSET_ASCII; - else if($13 == H5T_CSET_UTF8_TOKEN) + else if($12 == H5T_CSET_UTF8_TOKEN) str_cset = H5T_CSET_UTF8; } CTYPE_TOKEN ctype ';' { - if($17 == H5T_C_S1_TOKEN) + if($16 == H5T_C_S1_TOKEN) $$ = H5Tcopy(H5T_C_S1); - else if($17 == H5T_FORTRAN_S1_TOKEN) + else if($16 == H5T_FORTRAN_S1_TOKEN) $$ = H5Tcopy(H5T_FORTRAN_S1); } '}' { - hid_t str_id = $19; + hid_t str_id = $18; /*set string size*/ if(is_variable) { @@ -339,14 +333,10 @@ enum_type : H5T_ENUM_TOKEN '{' integer_type ';' enum_list : | enum_list enum_def ; -enum_def : '"' enum_symbol '"' { +enum_def : enum_symbol { is_enum_memb = 1; /*indicate member of enum*/ -#ifdef H5_HAVE_WIN32_API - enum_memb_symbol = _strdup(yylval.sval); -#else /* H5_HAVE_WIN32_API */ - enum_memb_symbol = strdup(yylval.sval); -#endif /* H5_HAVE_WIN32_API */ - free(yylval.sval); + enum_memb_symbol = HDstrdup(yylval.sval); + HDfree(yylval.sval); yylval.sval = NULL; } enum_val ';' @@ -386,7 +376,7 @@ enum_def : '"' enum_symbol '"' { } is_enum_memb = 0; - if(enum_memb_symbol) free(enum_memb_symbol); + if(enum_memb_symbol) HDfree(enum_memb_symbol); } H5Tclose(super); diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h index 01c5ee69d93..5a97d9c22f6 100644 --- a/hl/src/H5LTprivate.h +++ b/hl/src/H5LTprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5LTprivate_H -#define _H5LTprivate_H +#ifndef H5LTprivate_H +#define H5LTprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -25,26 +25,17 @@ *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LT_get_attribute_disk( hid_t obj_id, - const char *attr_name, - void *data ); +H5_HLDLL herr_t H5LT_get_attribute_disk(hid_t obj_id, const char *attr_name, void *data); -H5_HLDLL herr_t H5LT_set_attribute_numerical( hid_t loc_id, - const char *obj_name, - const char *attr_name, - size_t size, - hid_t type_id, - const void *data ); +H5_HLDLL herr_t H5LT_set_attribute_numerical(hid_t loc_id, const char *obj_name, const char *attr_name, + size_t size, hid_t type_id, const void *data); -H5_HLDLL herr_t H5LT_set_attribute_string( hid_t dset_id, - const char *name, - const char *buf ); +H5_HLDLL herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf); -H5_HLDLL herr_t H5LT_find_attribute( hid_t loc_id, const char *name ); +H5_HLDLL herr_t H5LT_find_attribute(hid_t loc_id, const char *name); - -H5_HLDLL char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, - size_t *slen, hbool_t no_user_buf); +H5_HLDLL char *H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, + hbool_t no_user_buf); H5_HLDLL hid_t H5LTyyparse(void); diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 6df7c4b8e2d..2af9b07a0ff 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -6,22 +6,22 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5LTpublic_H -#define _H5LTpublic_H +#ifndef H5LTpublic_H +#define H5LTpublic_H /* Flag definitions for H5LTopen_file_image() */ -#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */ -#define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */ +#define H5LT_FILE_IMAGE_OPEN_RW 0x0001 /* Open image for read-write */ +#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 */ /* for doing so. */ -#define H5LT_FILE_IMAGE_ALL 0x0007 +#define H5LT_FILE_IMAGE_ALL 0x0007 typedef enum H5LT_lang_t { H5LT_LANG_ERR = -1, /*this is the first*/ @@ -42,53 +42,28 @@ extern "C" { *------------------------------------------------------------------------- */ -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 ); - -H5_HLDLL herr_t H5LTmake_dataset_char( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const char *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_short( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const short *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_int( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const int *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_long( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const long *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_float( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const float *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_double( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const double *buffer ); - -H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, - const char *dset_name, - const char *buf ); +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); +H5_HLDLL herr_t H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const char *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const short *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const int *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const long *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const float *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, + const double *buffer); + +H5_HLDLL herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf); /*------------------------------------------------------------------------- * @@ -97,38 +72,21 @@ H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTread_dataset( hid_t loc_id, - const char *dset_name, - hid_t type_id, - void *buffer ); +H5_HLDLL herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t type_id, void *buffer); -H5_HLDLL herr_t H5LTread_dataset_char( hid_t loc_id, - const char *dset_name, - char *buffer ); +H5_HLDLL herr_t H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *buffer); -H5_HLDLL herr_t H5LTread_dataset_short( hid_t loc_id, - const char *dset_name, - short *buffer ); +H5_HLDLL herr_t H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *buffer); -H5_HLDLL herr_t H5LTread_dataset_int( hid_t loc_id, - const char *dset_name, - int *buffer ); +H5_HLDLL herr_t H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *buffer); -H5_HLDLL herr_t H5LTread_dataset_long( hid_t loc_id, - const char *dset_name, - long *buffer ); +H5_HLDLL herr_t H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *buffer); -H5_HLDLL herr_t H5LTread_dataset_float( hid_t loc_id, - const char *dset_name, - float *buffer ); +H5_HLDLL herr_t H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *buffer); -H5_HLDLL herr_t H5LTread_dataset_double( hid_t loc_id, - const char *dset_name, - double *buffer ); +H5_HLDLL herr_t H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *buffer); -H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, - const char *dset_name, - char *buf ); +H5_HLDLL herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf); /*------------------------------------------------------------------------- * @@ -137,20 +95,12 @@ H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank); -H5_HLDLL herr_t H5LTget_dataset_ndims( hid_t loc_id, - const char *dset_name, - int *rank ); - -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 ); - -H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name ); - +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); +H5_HLDLL herr_t H5LTfind_dataset(hid_t loc_id, const char *name); /*------------------------------------------------------------------------- * @@ -159,77 +109,41 @@ H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name ); *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, + const char *attr_data); + +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); + +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); + +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); + +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); + +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); + +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); + +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); + +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); + +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); + +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); -H5_HLDLL herr_t H5LTset_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *attr_data ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); - -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 ); +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); /*------------------------------------------------------------------------- * @@ -238,72 +152,41 @@ H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_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 ); - -H5_HLDLL herr_t H5LTget_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ); - -H5_HLDLL herr_t H5LTget_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ); - -H5_HLDLL herr_t H5LTget_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned char *data ); - -H5_HLDLL herr_t H5LTget_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - short *data ); - -H5_HLDLL herr_t H5LTget_attribute_ushort( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned short *data ); - -H5_HLDLL herr_t H5LTget_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *data ); - -H5_HLDLL herr_t H5LTget_attribute_uint( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned int *data ); - -H5_HLDLL herr_t H5LTget_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long *data ); - -H5_HLDLL herr_t H5LTget_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long long *data ); - -H5_HLDLL herr_t H5LTget_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned long *data ); - -H5_HLDLL herr_t H5LTget_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - float *data ); - -H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - double *data ); +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); +H5_HLDLL herr_t H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, + char *data); + +H5_HLDLL herr_t H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data); + +H5_HLDLL herr_t H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned char *data); + +H5_HLDLL herr_t H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, + short *data); + +H5_HLDLL herr_t H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned short *data); + +H5_HLDLL herr_t H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data); + +H5_HLDLL herr_t H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned int *data); + +H5_HLDLL herr_t H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data); + +H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, + long long *data); + +H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned long *data); + +H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, + float *data); + +H5_HLDLL herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, + double *data); /*------------------------------------------------------------------------- * @@ -312,22 +195,10 @@ H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank); -H5_HLDLL herr_t H5LTget_attribute_ndims( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *rank ); - -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 ); - - - - +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); /*------------------------------------------------------------------------- * @@ -336,10 +207,9 @@ H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); +H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len); - /*------------------------------------------------------------------------- * * Utility functions @@ -347,7 +217,7 @@ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name ); +H5_HLDLL herr_t H5LTfind_attribute(hid_t loc_id, const char *name); H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid); @@ -365,4 +235,3 @@ H5_HLDLL hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flag #endif #endif - diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index fa140bc983b..f5fb99f84b8 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,22 +16,21 @@ /* Packet Table private data */ -typedef struct -{ - hid_t dset_id; /* The ID of the dataset containing this table */ - hid_t type_id; /* The ID of the packet table's native datatype */ - hsize_t current_index; /* The index of the packet that get_next_packet will read next */ - hsize_t size; /* The number of packets currently contained in this table */ +typedef struct { + hid_t dset_id; /* The ID of the dataset containing this table */ + hid_t type_id; /* The ID of the packet table's native datatype */ + hsize_t current_index; /* The index of the packet that get_next_packet will read next */ + hsize_t size; /* The number of packets currently contained in this table */ } htbl_t; -static hsize_t H5PT_ptable_count = 0; +static hsize_t H5PT_ptable_count = 0; 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); -static herr_t H5PT_close( htbl_t* table ); +static herr_t H5PT_free_id(void *id, void **_ctx); +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); static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index); @@ -69,109 +68,105 @@ static herr_t H5PT_get_index(htbl_t *table_id, hsize_t *pt_index); * *------------------------------------------------------------------------- */ -hid_t H5PTcreate(hid_t loc_id, - const char *dset_name, - hid_t dtype_id, - hsize_t chunk_size, - hid_t plist_id) +hid_t +H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, hid_t plist_id) { - htbl_t * table = NULL; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t plistcopy_id = H5I_INVALID_HID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* 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) - goto error; - - /* Get memory for the table identifier */ - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Create a simple data space with unlimited size */ - dims[0] = 0; - dims_chunk[0] = chunk_size; - maxdims[0] = H5S_UNLIMITED; - if((space_id = H5Screate_simple(1, dims, maxdims)) < 0) - goto error; - - /* Modify dataset creation properties to enable chunking */ - if (plist_id == H5P_DEFAULT) { - plistcopy_id = H5Pcreate(H5P_DATASET_CREATE); - } - else { - plistcopy_id = H5Pcopy(plist_id); - } - if (chunk_size > 0) - { - if(H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0) - goto error; - } - - /* Create the dataset. */ - if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0) - goto error; - - /* Create the table identifier */ - table->dset_id = dset_id; - - /* Terminate access to the data space. */ - if(H5Sclose(space_id) < 0) - goto error; - - /* End access to the property list */ - if(H5Pclose(plistcopy_id) < 0) - goto error; - - /* Make a copy of caller's datatype and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(dtype_id)) < 0) - goto error; - - H5PT_create_index(table); - table->size = 0; - - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); - - return ret_value; + htbl_t *table = NULL; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t plistcopy_id = H5I_INVALID_HID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { + goto error; + } + + /* 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) + goto error; + + /* Get memory for the table identifier */ + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Create a simple data space with unlimited size */ + dims[0] = 0; + dims_chunk[0] = chunk_size; + maxdims[0] = H5S_UNLIMITED; + if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0) + goto error; + + /* Modify dataset creation properties to enable chunking */ + if (plist_id == H5P_DEFAULT) { + plistcopy_id = H5Pcreate(H5P_DATASET_CREATE); + } + else { + plistcopy_id = H5Pcopy(plist_id); + } + if (chunk_size > 0) { + if (H5Pset_chunk(plistcopy_id, 1, dims_chunk) < 0) + goto error; + } + + /* Create the dataset. */ + if ((dset_id = + H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plistcopy_id, H5P_DEFAULT)) < 0) + goto error; + + /* Create the table identifier */ + table->dset_id = dset_id; + + /* Terminate access to the data space. */ + if (H5Sclose(space_id) < 0) + goto error; + + /* End access to the property list */ + if (H5Pclose(plistcopy_id) < 0) + goto error; + + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(dtype_id)) < 0) + goto error; + + H5PT_create_index(table); + table->size = 0; + + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); + + return ret_value; error: if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); + H5Sclose(space_id); if (plistcopy_id != H5I_INVALID_HID) - H5Pclose(plistcopy_id); + H5Pclose(plistcopy_id); if (dset_id != H5I_INVALID_HID) - H5Dclose(dset_id); - if (table) - { + H5Dclose(dset_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - HDfree(table); + H5Tclose(table->type_id); + HDfree(table); } return ret_value; } /* H5PTcreate */ - /*------------------------------------------------------------------------- * Function: H5PTcreate_fl * @@ -194,98 +189,95 @@ hid_t H5PTcreate(hid_t loc_id, *------------------------------------------------------------------------- */ -hid_t H5PTcreate_fl ( hid_t loc_id, - const char *dset_name, - hid_t dtype_id, - hsize_t chunk_size, - int compression ) +hid_t +H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, int compression) { - htbl_t * table = NULL; - hid_t dset_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t plist_id = H5I_INVALID_HID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* 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) - goto error; - - /* Get memory for the table identifier */ - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Create a simple data space with unlimited size */ - dims[0] = 0; - dims_chunk[0] = chunk_size; - maxdims[0] = H5S_UNLIMITED; - if((space_id = H5Screate_simple(1, dims, maxdims)) < 0) - goto error; - - /* Modify dataset creation properties to enable chunking */ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) - goto error; - if(compression >= 0 && compression <= 9) - if(H5Pset_deflate(plist_id, (unsigned)compression) < 0) + htbl_t *table = NULL; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t plist_id = H5I_INVALID_HID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { goto error; + } - /* Create the dataset. */ - if((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) - goto error; + /* 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) + goto error; - /* Create the table identifier */ - table->dset_id = dset_id; + /* Get memory for the table identifier */ + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Create a simple data space with unlimited size */ + dims[0] = 0; + dims_chunk[0] = chunk_size; + maxdims[0] = H5S_UNLIMITED; + if ((space_id = H5Screate_simple(1, dims, maxdims)) < 0) + goto error; - /* Terminate access to the data space. */ - if(H5Sclose(space_id) < 0) - goto error; + /* Modify dataset creation properties to enable chunking */ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0) + goto error; + if (compression >= 0 && compression <= 9) + if (H5Pset_deflate(plist_id, (unsigned)compression) < 0) + goto error; - /* End access to the property list */ - if(H5Pclose(plist_id) < 0) - goto error; + /* Create the dataset. */ + if ((dset_id = H5Dcreate2(loc_id, dset_name, dtype_id, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) + goto error; - /* Make a copy of caller's datatype and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(dtype_id)) < 0) - goto error; + /* Create the table identifier */ + table->dset_id = dset_id; - H5PT_create_index(table); - table->size = 0; + /* Terminate access to the data space. */ + if (H5Sclose(space_id) < 0) + goto error; + + /* End access to the property list */ + if (H5Pclose(plist_id) < 0) + goto error; + + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(dtype_id)) < 0) + goto error; + + H5PT_create_index(table); + table->size = 0; - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); - return ret_value; + return ret_value; error: if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); + H5Sclose(space_id); if (plist_id != H5I_INVALID_HID) - H5Pclose(plist_id); + H5Pclose(plist_id); if (dset_id != H5I_INVALID_HID) - H5Dclose(dset_id); - if (table) - { + H5Dclose(dset_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - HDfree(table); + H5Tclose(table->type_id); + HDfree(table); } return ret_value; @@ -315,87 +307,87 @@ hid_t H5PTcreate_fl ( hid_t loc_id, * *------------------------------------------------------------------------- */ -hid_t H5PTopen( hid_t loc_id, - const char *dset_name ) +hid_t +H5PTopen(hid_t loc_id, const char *dset_name) { - hid_t type_id=H5I_INVALID_HID; - hid_t space_id=H5I_INVALID_HID; - htbl_t * table = NULL; - hsize_t dims[1]; - hid_t ret_value = H5I_INVALID_HID; - - /* check the arguments */ - if (dset_name == NULL) { - goto error; - } - - /* 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) - goto error; - - table = (htbl_t *)HDmalloc(sizeof(htbl_t)); - if ( table == NULL ) { - goto error; - } - table->dset_id = H5I_INVALID_HID; - table->type_id = H5I_INVALID_HID; - - /* Open the dataset */ - if((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - goto error; - - /* Get the dataset's disk datatype */ - if((type_id = H5Dget_type(table->dset_id)) < 0) - goto error; - - /* Make a copy of the datatype obtained and save it in the table structure. - It will be closed when the table is closed */ - if((table->type_id = H5Tcopy(type_id)) < 0) - goto error; - - /* Close the disk datatype */ - if(H5Tclose(type_id) < 0) - goto error; - type_id = H5I_INVALID_HID; - - /* Initialize the current record pointer */ - if((H5PT_create_index(table)) < 0) - goto error; - - /* Get number of records in table */ - if((space_id=H5Dget_space(table->dset_id)) < 0) - goto error; - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - goto error; - if(H5Sclose(space_id) < 0) - goto error; - space_id = H5I_INVALID_HID; - - table->size = dims[0]; - - /* Get an ID for this table */ - ret_value = H5Iregister(H5PT_ptable_id_type, table); - - if(ret_value != H5I_INVALID_HID) - H5PT_ptable_count++; - else - H5PT_close(table); - - return ret_value; + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + htbl_t *table = NULL; + hsize_t dims[1]; + hid_t ret_value = H5I_INVALID_HID; + + /* check the arguments */ + if (dset_name == NULL) { + goto error; + } + + /* 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) + goto error; + + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); + if (table == NULL) { + goto error; + } + table->dset_id = H5I_INVALID_HID; + table->type_id = H5I_INVALID_HID; + + /* Open the dataset */ + if ((table->dset_id = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + goto error; + + /* Get the dataset's disk datatype */ + if ((type_id = H5Dget_type(table->dset_id)) < 0) + goto error; + + /* Make a copy of the datatype obtained and save it in the table structure. + It will be closed when the table is closed */ + if ((table->type_id = H5Tcopy(type_id)) < 0) + goto error; + + /* Close the disk datatype */ + if (H5Tclose(type_id) < 0) + goto error; + type_id = H5I_INVALID_HID; + + /* Initialize the current record pointer */ + if ((H5PT_create_index(table)) < 0) + goto error; + + /* Get number of records in table */ + if ((space_id = H5Dget_space(table->dset_id)) < 0) + goto error; + if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + goto error; + if (H5Sclose(space_id) < 0) + goto error; + space_id = H5I_INVALID_HID; + + table->size = dims[0]; + + /* Get an ID for this table */ + ret_value = H5Iregister(H5PT_ptable_id_type, table); + + if (ret_value != H5I_INVALID_HID) + H5PT_ptable_count++; + else + H5PT_close(table); + + return ret_value; error: if (type_id != H5I_INVALID_HID) - H5Dclose(type_id); + H5Dclose(type_id); if (space_id != H5I_INVALID_HID) - H5Sclose(space_id); - if(table) - { + H5Sclose(space_id); + if (table) { if (table->type_id != H5I_INVALID_HID) - H5Tclose(table->type_id); - if (table->dset_id != H5I_INVALID_HID) - H5Dclose(table->dset_id); - HDfree(table); + H5Tclose(table->type_id); + if (table->dset_id != H5I_INVALID_HID) + H5Dclose(table->dset_id); + HDfree(table); } return ret_value; @@ -410,7 +402,7 @@ hid_t H5PTopen( hid_t loc_id, *------------------------------------------------------------------------- */ static herr_t -H5PT_free_id(void *id) +H5PT_free_id(void *id, void H5_ATTR_UNUSED **_ctx) { HDfree(id); return SUCCEED; @@ -436,33 +428,32 @@ H5PT_free_id(void *id) *------------------------------------------------------------------------- */ static herr_t -H5PT_close( htbl_t* table) +H5PT_close(htbl_t *table) { - if(table == NULL) - goto error; + if (table == NULL) + goto error; - /* Close the dataset */ - if(H5Dclose(table->dset_id) < 0) - goto error; + /* Close the dataset */ + if (H5Dclose(table->dset_id) < 0) + goto error; - /* Close the memory datatype */ - if(H5Tclose(table->type_id) < 0) - goto error; + /* Close the memory datatype */ + if (H5Tclose(table->type_id) < 0) + goto error; - HDfree(table); + HDfree(table); - return SUCCEED; + return SUCCEED; error: - if(table) - { - H5E_BEGIN_TRY - H5Dclose(table->dset_id); - H5Tclose(table->type_id); - H5E_END_TRY - HDfree(table); - } - return FAIL; + if (table) { + H5E_BEGIN_TRY + H5Dclose(table->dset_id); + H5Tclose(table->type_id); + H5E_END_TRY + HDfree(table); + } + return FAIL; } /*------------------------------------------------------------------------- @@ -484,36 +475,35 @@ H5PT_close( htbl_t* table) * *------------------------------------------------------------------------- */ -herr_t H5PTclose( hid_t table_id ) +herr_t +H5PTclose(hid_t table_id) { - htbl_t * table; + htbl_t *table; - /* Remove the ID from the library */ - if((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) ==NULL) - goto error; + /* Remove the ID from the library */ + if ((table = (htbl_t *)H5Iremove_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If the library found the table, remove it */ - if( H5PT_close(table) < 0) - goto error; + /* If the library found the table, remove it */ + if (H5PT_close(table) < 0) + goto error; - /* One less packet table open */ - H5PT_ptable_count--; + /* One less packet table open */ + H5PT_ptable_count--; - /* Remove the packet table type ID if no more packet */ - /* tables are open */ - if(H5PT_ptable_count == 0) - { - H5Idestroy_type(H5PT_ptable_id_type); - H5PT_ptable_id_type = H5I_UNINIT; - } + /* Remove the packet table type ID if no more packet */ + /* tables are open */ + if (H5PT_ptable_count == 0) { + H5Idestroy_type(H5PT_ptable_id_type); + H5PT_ptable_id_type = H5I_UNINIT; + } - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } - /*------------------------------------------------------------------------- * * Write functions @@ -539,30 +529,28 @@ herr_t H5PTclose( hid_t table_id ) * *------------------------------------------------------------------------- */ -herr_t H5PTappend( hid_t table_id, - size_t nrecords, - const void * data ) +herr_t +H5PTappend(hid_t table_id, size_t nrecords, const void *data) { - 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) - goto error; + /* Find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If we are asked to write 0 records, just do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If we are asked to write 0 records, just do nothing */ + if (nrecords == 0) + return SUCCEED; - if((H5TB_common_append_records(table->dset_id, table->type_id, - nrecords, table->size, data)) < 0) - goto error; + if ((H5TB_common_append_records(table->dset_id, table->type_id, nrecords, table->size, data)) < 0) + goto error; - /* Update table size */ - table->size += nrecords; - return SUCCEED; + /* Update table size */ + table->size += nrecords; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -572,7 +560,6 @@ herr_t H5PTappend( hid_t table_id, *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5PTget_next * @@ -593,30 +580,29 @@ herr_t H5PTappend( hid_t table_id, * *------------------------------------------------------------------------- */ -herr_t H5PTget_next( hid_t table_id, - size_t nrecords, - void * data) +herr_t +H5PTget_next(hid_t table_id, size_t nrecords, void *data) { - 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) - goto error; + /* Find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - /* If nrecords == 0, do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If nrecords == 0, do nothing */ + if (nrecords == 0) + return SUCCEED; - if((H5TB_common_read_records(table->dset_id, table->type_id, - table->current_index, nrecords, table->size, data)) < 0) - goto error; + if ((H5TB_common_read_records(table->dset_id, table->type_id, table->current_index, nrecords, table->size, + data)) < 0) + goto error; - /* Update the current index */ - table->current_index += nrecords; - return SUCCEED; + /* Update the current index */ + table->current_index += nrecords; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -638,30 +624,27 @@ herr_t H5PTget_next( hid_t table_id, * *------------------------------------------------------------------------- */ -herr_t H5PTread_packets( hid_t table_id, - hsize_t start, - size_t nrecords, - void *data) +herr_t +H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type); - if(table == NULL) - goto error; + /* find the table struct from its ID */ + table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type); + if (table == NULL) + goto error; - /* If nrecords == 0, do nothing */ - if(nrecords == 0) - return SUCCEED; + /* If nrecords == 0, do nothing */ + if (nrecords == 0) + return SUCCEED; - if( H5TB_common_read_records(table->dset_id, table->type_id, - start, nrecords, table->size, data) < 0) - goto error; + if (H5TB_common_read_records(table->dset_id, table->type_id, start, nrecords, table->size, data) < 0) + goto error; - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -692,40 +675,36 @@ herr_t H5PTread_packets( hid_t table_id, static herr_t H5PT_create_index(htbl_t *table) { - if( table != NULL) - { - table->current_index = 0; - return SUCCEED; - } - return FAIL; + if (table != NULL) { + table->current_index = 0; + return SUCCEED; + } + return FAIL; } static herr_t H5PT_set_index(htbl_t *table, hsize_t pt_index) { - /* Ensure index is valid */ - if( table != NULL ) - { - if( pt_index < table->size ) - { - table->current_index = pt_index; - return SUCCEED; + /* Ensure index is valid */ + if (table != NULL) { + if (pt_index < table->size) { + table->current_index = pt_index; + return SUCCEED; + } } - } - return FAIL; + return FAIL; } static herr_t H5PT_get_index(htbl_t *table, hsize_t *pt_index) { - /* Ensure index is valid */ - if( table != NULL ) - { - if(pt_index) - *pt_index = table->current_index; - return SUCCEED; - } - return FAIL; + /* Ensure index is valid */ + if (table != NULL) { + if (pt_index) + *pt_index = table->current_index; + return SUCCEED; + } + return FAIL; } /*------------------------------------------------------------------------- @@ -746,37 +725,40 @@ H5PT_get_index(htbl_t *table, hsize_t *pt_index) * *------------------------------------------------------------------------- */ -herr_t H5PTcreate_index(hid_t table_id) +herr_t +H5PTcreate_index(hid_t table_id) { - htbl_t * table; + htbl_t *table; - /* find the table struct from its ID */ - if((table = (htbl_t *) (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)(htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_create_index(table); + return H5PT_create_index(table); } -herr_t H5PTset_index(hid_t table_id, hsize_t pt_index) +herr_t +H5PTset_index(hid_t table_id, hsize_t pt_index) { - 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) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_set_index(table, pt_index); + return H5PT_set_index(table, pt_index); } -herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index) +herr_t +H5PTget_index(hid_t table_id, hsize_t *pt_index) { - 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) - return FAIL; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + return FAIL; - return H5PT_get_index(table, pt_index); + return H5PT_get_index(table, pt_index); } /*------------------------------------------------------------------------- @@ -805,24 +787,24 @@ herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index) * *------------------------------------------------------------------------- */ -herr_t H5PTget_num_packets( hid_t table_id, hsize_t *nrecords) +herr_t +H5PTget_num_packets(hid_t table_id, hsize_t *nrecords) { - 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) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if(nrecords) - *nrecords = table->size; + if (nrecords) + *nrecords = table->size; - return SUCCEED; + return SUCCEED; error: - return FAIL; + return FAIL; } - /*------------------------------------------------------------------------- * Function: H5PTis_valid * @@ -842,13 +824,14 @@ herr_t H5PTget_num_packets( hid_t table_id, hsize_t *nrecords) * *------------------------------------------------------------------------- */ -herr_t H5PTis_valid(hid_t table_id) +herr_t +H5PTis_valid(hid_t table_id) { - /* find the table struct from its ID */ - if(H5Iobject_verify(table_id, H5PT_ptable_id_type) ==NULL) - return FAIL; + /* find the table struct from its ID */ + if (H5Iobject_verify(table_id, H5PT_ptable_id_type) == NULL) + return FAIL; - return SUCCEED; + return SUCCEED; } /*------------------------------------------------------------------------- @@ -871,25 +854,26 @@ herr_t H5PTis_valid(hid_t table_id) * *------------------------------------------------------------------------- */ -herr_t H5PTis_varlen(hid_t table_id) +herr_t +H5PTis_varlen(hid_t table_id) { - H5T_class_t type; - htbl_t * table; + H5T_class_t type; + htbl_t * table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if((type = H5Tget_class( table->type_id )) == H5T_NO_CLASS) - goto error; + if ((type = H5Tget_class(table->type_id)) == H5T_NO_CLASS) + goto error; - if( type == H5T_VLEN ) - return 1; - else - return 0; + if (type == H5T_VLEN) + return 1; + else + return 0; error: - return FAIL; + return FAIL; } /*------------------------------------------------------------------------- @@ -921,38 +905,37 @@ herr_t H5PTis_varlen(hid_t table_id) *------------------------------------------------------------------------- */ -herr_t H5PTfree_vlen_buff( hid_t table_id, - size_t _bufflen, - void * buff ) +herr_t +H5PTfree_vlen_buff(hid_t table_id, size_t _bufflen, void *buff) { - hid_t space_id = H5I_INVALID_HID; - htbl_t * table; - hsize_t bufflen = _bufflen; - herr_t ret_value; + hid_t space_id = H5I_INVALID_HID; + htbl_t *table; + hsize_t bufflen = _bufflen; + herr_t ret_value; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - if((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) - goto error; + if ((space_id = H5Screate_simple(1, &bufflen, NULL)) < 0) + goto error; - /* Free the memory. If this succeeds, ret_value should be 0. */ - if((ret_value = H5Dvlen_reclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0) - goto error; + /* Free the memory. If this succeeds, ret_value should be 0. */ + if ((ret_value = H5Treclaim(table->type_id, space_id, H5P_DEFAULT, buff)) < 0) + goto error; - /* If the dataspace cannot be closed, return -2 to indicate that memory */ - /* was freed successfully but an error still occurred. */ - if(H5Sclose(space_id) < 0) - return -2; + /* If the dataspace cannot be closed, return -2 to indicate that memory */ + /* was freed successfully but an error still occurred. */ + if (H5Sclose(space_id) < 0) + return -2; - return ret_value; + return ret_value; error: - H5E_BEGIN_TRY + H5E_BEGIN_TRY H5Sclose(space_id); - H5E_END_TRY - return FAIL; + H5E_END_TRY + return FAIL; } /* H5PTfree_vlen_buff */ /*------------------------------------------------------------------------- @@ -979,20 +962,21 @@ herr_t H5PTfree_vlen_buff( hid_t table_id, * *------------------------------------------------------------------------- */ -hid_t H5PTget_dataset(hid_t table_id) +hid_t +H5PTget_dataset(hid_t table_id) { - htbl_t * table; - hid_t ret_value = H5I_INVALID_HID; + htbl_t *table; + hid_t ret_value = H5I_INVALID_HID; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - ret_value = table->dset_id; + ret_value = table->dset_id; error: - return ret_value; + return ret_value; } /*------------------------------------------------------------------------- @@ -1013,18 +997,19 @@ hid_t H5PTget_dataset(hid_t table_id) * *------------------------------------------------------------------------- */ -hid_t H5PTget_type( hid_t table_id) +hid_t +H5PTget_type(hid_t table_id) { - htbl_t * table; - hid_t ret_value = H5I_INVALID_HID; + htbl_t *table; + hid_t ret_value = H5I_INVALID_HID; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) - goto error; + /* find the table struct from its ID */ + if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) + goto error; - ret_value = table->type_id; + ret_value = table->type_id; error: - return ret_value; + return ret_value; } diff --git a/hl/src/H5PTprivate.h b/hl/src/H5PTprivate.h index eec9df7662c..9ca7676852a 100644 --- a/hl/src/H5PTprivate.h +++ b/hl/src/H5PTprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5PTprivate_H -#define _H5PTprivate_H +#ifndef H5PTprivate_H +#define H5PTprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -21,4 +21,3 @@ #include "H5PTpublic.h" #endif - diff --git a/hl/src/H5PTpublic.h b/hl/src/H5PTpublic.h index 8a12c8cad21..d74baa513ed 100644 --- a/hl/src/H5PTpublic.h +++ b/hl/src/H5PTpublic.h @@ -6,14 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5PTpublic_H -#define _H5PTpublic_H - +#ifndef H5PTpublic_H +#define H5PTpublic_H #ifdef __cplusplus extern "C" { @@ -25,17 +24,16 @@ extern "C" { */ /* 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. */ -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); +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); H5_HLDLL hid_t H5PTopen(hid_t loc_id, const char *dset_name); H5_HLDLL herr_t H5PTclose(hid_t table_id); /* 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); - +H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, + int compression); /*------------------------------------------------------------------------- * Write functions @@ -47,10 +45,9 @@ H5_HLDLL herr_t H5PTappend(hid_t table_id, size_t nrecords, const void *data); * Read functions *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void * data); +H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void *data); -H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, - size_t nrecords, void *data); +H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data); /*------------------------------------------------------------------------- * Inquiry functions @@ -80,13 +77,11 @@ H5_HLDLL hid_t H5PTget_type(hid_t table_id); *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTcreate_index( hid_t table_id ); +H5_HLDLL herr_t H5PTcreate_index(hid_t table_id); -H5_HLDLL herr_t H5PTset_index( hid_t table_id, - hsize_t pt_index ); +H5_HLDLL herr_t H5PTset_index(hid_t table_id, hsize_t pt_index); -H5_HLDLL herr_t H5PTget_index( hid_t table_id, - hsize_t *pt_index ); +H5_HLDLL herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index); /*------------------------------------------------------------------------- * @@ -95,13 +90,10 @@ H5_HLDLL herr_t H5PTget_index( hid_t table_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5PTfree_vlen_buff( hid_t table_id, - size_t bufflen, - void * buff ); +H5_HLDLL herr_t H5PTfree_vlen_buff(hid_t table_id, size_t bufflen, void *buff); #ifdef __cplusplus } #endif #endif - diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 79d5cef2fc5..efa61a32eb1 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1,191 +1,173 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by 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 * + * Copyright by The HDF Group. * + * Copyright by 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5LTprivate.h" #include "H5TBprivate.h" - /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ - -static hbool_t H5TB_find_field(const char *field, - const char *field_list); - -static herr_t H5TB_attach_attributes(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hid_t tid); - -static hid_t H5TB_create_type(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - hid_t ftype_id); + * + * internal functions + * + *------------------------------------------------------------------------- + */ + +static hbool_t H5TB_find_field(const char *field, const char *field_list); + +static herr_t H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name, + hsize_t nfields, hid_t tid); + +static hid_t H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, hid_t ftype_id); /*------------------------------------------------------------------------- -* -* Create functions -* -*------------------------------------------------------------------------- -*/ + * + * Create functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBmake_table -* -* Purpose: Make a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* Quincey Koziol -* -* Date: January 17, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBmake_table(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hsize_t nrecords, - size_t type_size, - const char *field_names[], - const size_t *field_offset, - const hid_t *field_types, - hsize_t chunk_size, - void *fill_data, - int compress, - const void *buf) + * Function: H5TBmake_table + * + * Purpose: Make a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * Quincey Koziol + * + * Date: January 17, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, + hsize_t nrecords, size_t type_size, const char *field_names[], const size_t *field_offset, + const hid_t *field_types, hsize_t chunk_size, void *fill_data, int compress, const void *buf) { - hid_t did = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t plist_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - hsize_t dims[1]; - hsize_t dims_chunk[1]; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - char attr_name[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; - hsize_t i; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t plist_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + hsize_t dims[1]; + hsize_t dims_chunk[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + char attr_name[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; + hsize_t i; + herr_t ret_val = -1; /* check the arguments */ if (table_title == NULL) { - goto out; + goto out; } if (dset_name == NULL) { - goto out; + goto out; } if (field_names == NULL) { - goto out; + goto out; } dims[0] = nrecords; dims_chunk[0] = chunk_size; /* create the memory data type. */ - if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* insert fields. */ - for(i = 0; i < nfields; i++) - if(H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i] ) < 0) + for (i = 0; i < nfields; i++) + if (H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i]) < 0) goto out; /* create a simple data space with unlimited size */ - if((sid = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ - if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(plist_id, 1, dims_chunk) < 0) + if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0) goto out; /* set the fill value using a struct as the data type. */ - if(fill_data) - if(H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) + if (fill_data) + if (H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) goto out; /* dataset creation property list is modified to use GZIP compression with the compression effort set to 6. */ - if(compress) - if(H5Pset_deflate(plist_id, 6) < 0) + if (compress) + if (H5Pset_deflate(plist_id, 6) < 0) goto out; /* create the dataset. */ - if((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) goto out; /* only write if there is something to write */ - if(buf) - if(H5Dwrite(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) + if (H5Dwrite(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /* end access to the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - did = H5I_BADID; + did = H5I_INVALID_HID; /* end access to the property list */ - if(H5Pclose(plist_id) < 0) + if (H5Pclose(plist_id) < 0) goto out; - plist_id = H5I_BADID; + plist_id = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * set the conforming table attributes - *------------------------------------------------------------------------- - */ + * set the conforming table attributes + *------------------------------------------------------------------------- + */ /* attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) goto out; /* attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) goto out; /* attach the TITLE attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) goto out; /* attach the FIELD_ name attribute */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(mem_type_id, (unsigned)i))) goto out; HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i); /* attach the attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) goto out; H5free_memory(member_name); @@ -193,283 +175,269 @@ herr_t H5TBmake_table(const char *table_title, } /* end for */ /* attach the FIELD_ fill value attribute */ - if(fill_data) { + if (fill_data) { tmp_buf = (unsigned char *)fill_data; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, field_types[i], tmp_buf + field_offset[i]) < 0) + if (H5Awrite(attr_id, field_types[i], tmp_buf + field_offset[i]) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; } /* end for */ /* terminate access to the data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /* end access to the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; - did = H5I_BADID; + did = H5I_INVALID_HID; } /* end if */ /* release the datatype. */ - if(H5Tclose(mem_type_id) < 0) + if (H5Tclose(mem_type_id) < 0) goto out; - mem_type_id = H5I_BADID; + mem_type_id = H5I_INVALID_HID; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(plist_id > 0) - if(H5Pclose(plist_id) < 0) + if (plist_id > 0) + if (H5Pclose(plist_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; return ret_val; } /* end H5TBmake_table() */ /*------------------------------------------------------------------------- -* -* Write functions -* -*------------------------------------------------------------------------- -*/ + * + * Write functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBappend_records -* -* Purpose: Appends records to a table -* -* Return: Success: 0, Failure: -1 -* -* Programmers: -* Pedro Vicente -* Quincey Koziol -* -* Date: November 19, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBappend_records(hid_t loc_id, - const char *dset_name, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBappend_records + * + * Purpose: Appends records to a table + * + * Return: Success: 0, Failure: -1 + * + * Programmers: + * Pedro Vicente + * Quincey Koziol + * + * Date: November 19, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nrecords_orig; - hsize_t nfields; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hsize_t nrecords_orig; + hsize_t nfields; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the original number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatypes */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; /* append the records */ - if((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0) + if ((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; ret_val = 0; out: - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBappend_records() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_records -* -* Purpose: Writes records -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_records(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_records + * + * Purpose: Writes records + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t dims[1]; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t dims[1]; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get records */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; - if(start + nrecords > dims[0]) + if (start + nrecords > dims[0]) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_records() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_fields_name -* -* Purpose: Writes fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 21, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_fields_name(hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_fields_name + * + * Purpose: Writes fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 21, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, + hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t file_space_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; hssize_t nfields; 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; @@ -480,72 +448,72 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the number of fields */ - if((nfields = H5Tget_nmembers(tid)) < 0) + if ((nfields = H5Tget_nmembers(tid)) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; j = 0; /* iterate though the members */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; - if(H5TB_find_field(member_name, field_names)) { + if (H5TB_find_field(member_name, field_names)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid, (unsigned)i)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; /* adjust, if necessary */ - if(field_sizes[j] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[j]) < 0) + if (field_sizes[j] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(write_type_id, member_name, field_offset[j], nmtype_id) < 0) goto out; } /* end if */ /* only one field */ else { - if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ j++; /* close */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + member_type_id = H5I_INVALID_HID; + if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; } /* end if */ H5free_memory(member_name); @@ -553,408 +521,388 @@ herr_t H5TBwrite_fields_name(hid_t loc_id, } /* end for */ /* get the dataspace handle */ - if((file_space_id = H5Dget_space(did)) < 0) + if ((file_space_id = H5Dget_space(did)) < 0) goto out; - if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write */ - if(H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) + if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(file_space_id > 0) - if(H5Sclose(file_space_id) < 0) + if (file_space_id > 0) + if (H5Sclose(file_space_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_fields_name() */ /*------------------------------------------------------------------------- -* Function: H5TBwrite_fields_index -* -* Purpose: Writes fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 21, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBwrite_fields_index(hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf) + * Function: H5TBwrite_fields_index + * + * Purpose: Writes fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 21, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, + hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t i; - size_t size_native; - char *member_name = NULL; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t file_space_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t i; + size_t size_native; + char * member_name = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { - unsigned j; + for (i = 0; i < nfields; i++) { + unsigned j; /* Range check value */ - if(field_index[i] < 0) + if (field_index[i] < 0) goto out; j = (unsigned)field_index[i]; /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, j))) + if (NULL == (member_name = H5Tget_member_name(tid, j))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, j)) < 0) + if ((member_type_id = H5Tget_member_type(tid, j)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(write_type_id, member_name, field_offset[i], nmtype_id) < 0) goto out; } /* end if */ /* only one field */ else { - if(H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + member_type_id = H5I_INVALID_HID; + if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; } /* end for */ /* get the dataspace handles */ - if((file_space_id = H5Dget_space(did)) < 0) + if ((file_space_id = H5Dget_space(did)) < 0) goto out; - if((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write */ - if(H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) + if (H5Dwrite(did, write_type_id, m_sid, file_space_id, preserve_id, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(file_space_id > 0) - if(H5Sclose(file_space_id) < 0) + if (file_space_id > 0) + if (H5Sclose(file_space_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBwrite_fields_index() */ - /*------------------------------------------------------------------------- -* -* Read functions -* -*------------------------------------------------------------------------- -*/ - + * + * Read functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBread_table -* -* Purpose: Reads a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 20, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_table(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *dst_buf) + * Function: H5TBread_table + * + * Purpose: Reads a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 20, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_table(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *dst_buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; - hsize_t dims[1]; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1]; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimensions */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* get the datatypes */ - if((ftype_id = H5Dget_type (did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < + 0) goto out; /* read */ - if(H5Dread(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0) + if (H5Dread(did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0) goto out; ret_val = 0; out: - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_table() */ /*------------------------------------------------------------------------- -* Function: H5TBread_records -* -* Purpose: Reads records -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_records(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_records + * + * Purpose: Reads records + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nrecords_orig; - hsize_t nfields; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hsize_t nrecords_orig; + hsize_t nfields; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0) goto out; /* open the dataset */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatypes */ - if((ftype_id = H5Dget_type(did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, ftype_id)) < + 0) goto out; /* read the records */ - if((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0) + if ((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; ret_val = 0; out: - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_records() */ /*------------------------------------------------------------------------- -* Function: H5TBread_fields_name -* -* Purpose: Reads fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_fields_name(hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_fields_name + * + * Purpose: Reads fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, + hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t mtype_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hssize_t nfields; hsize_t count[1]; 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; - /* check the arguments */ if (dset_name == NULL) goto out; @@ -962,60 +910,60 @@ herr_t H5TBread_fields_name(hid_t loc_id, goto out; /* open the dataset */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((ftype_id = H5Dget_type(did)) < 0) + if ((ftype_id = H5Dget_type(did)) < 0) goto out; /* get the number of fields */ - if((nfields = H5Tget_nmembers(ftype_id)) < 0) + if ((nfields = H5Tget_nmembers(ftype_id)) < 0) goto out; /* create a memory read id */ - if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate through the members */ - for(i = 0, j = 0; i < nfields; i++) { + for (i = 0, j = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i))) goto out; - if(H5TB_find_field(member_name, field_names)) { + if (H5TB_find_field(member_name, field_names)) { /* get the member type */ - if((mtype_id = H5Tget_member_type(ftype_id, (unsigned)i)) < 0) + if ((mtype_id = H5Tget_member_type(ftype_id, (unsigned)i)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[j] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[j]) < 0) + if (field_sizes[j] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(mem_type_id, member_name, field_offset[j], nmtype_id) < 0) goto out; } /* end if */ else { - if(H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(mem_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close */ - if(H5Tclose(mtype_id) < 0) + if (H5Tclose(mtype_id) < 0) goto out; - mtype_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + mtype_id = H5I_INVALID_HID; + if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; j++; } /* end if */ @@ -1024,844 +972,826 @@ herr_t H5TBread_fields_name(hid_t loc_id, } /* end for */ /* check to make sure field was found, no reason to continue if it does not exist */ - if(j == 0) - goto out; + if (j == 0) + goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* read */ - if(H5Dread(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(mtype_id > 0) - if(H5Tclose(mtype_id) < 0) + if (mtype_id > 0) + if (H5Tclose(mtype_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(ftype_id > 0) - if(H5Tclose(ftype_id) < 0) + if (ftype_id > 0) + if (H5Tclose(ftype_id) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_fields_name() */ /*------------------------------------------------------------------------- -* Function: H5TBread_fields_index -* -* Purpose: Reads fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBread_fields_index(hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBread_fields_index + * + * Purpose: Reads fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, + hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t i; - size_t size_native; - char *member_name = NULL; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t read_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t i; + size_t size_native; + char * member_name = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create a read id */ - if((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) + if ((read_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { - unsigned j; + for (i = 0; i < nfields; i++) { + unsigned j; /* Range check */ - if(field_index[i] < 0) + if (field_index[i] < 0) goto out; j = (unsigned)field_index[i]; /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)j))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)j))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid, (unsigned)j)) < 0) + if ((member_type_id = H5Tget_member_type(tid, (unsigned)j)) < 0) goto out; /* convert to native type */ - if((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(member_type_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; /* the field in the file is found by its name */ - if(field_offset) { - if(H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0) + if (field_offset) { + if (H5Tinsert(read_type_id, member_name, field_offset[i], nmtype_id) < 0) goto out; } /* end if */ else { - if(H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0) + if (H5Tinsert(read_type_id, member_name, (size_t)0, nmtype_id) < 0) goto out; } /* end else */ /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + member_type_id = H5I_INVALID_HID; + if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; } /* end for */ /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* read */ - if(H5Dread( did, read_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dread(did, read_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(read_type_id > 0) - if(H5Tclose(read_type_id) < 0) + if (read_type_id > 0) + if (H5Tclose(read_type_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBread_fields_index() */ - /*------------------------------------------------------------------------- -* -* Manipulation functions -* -*------------------------------------------------------------------------- -*/ + * + * Manipulation functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBdelete_record -* -* Purpose: Delete records from middle of table ("pulling up" all the records after it) -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 26, 2001 -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBdelete_record(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords) + * Function: H5TBdelete_record + * + * Purpose: Delete records from middle of table ("pulling up" all the records after it) + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 26, 2001 + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hsize_t nfields; - hsize_t ntotal_records; - hsize_t read_start; - hsize_t read_nrecords; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t dims[1]; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; - + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hsize_t nfields; + hsize_t ntotal_records; + hsize_t read_start; + hsize_t read_nrecords; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t dims[1]; + size_t src_size; + size_t * src_offset = NULL; + size_t * src_sizes = NULL; + unsigned char *tmp_buf = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id, dset_name, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * read the records after the deleted one(s) - *------------------------------------------------------------------------- - */ + * read the records after the deleted one(s) + *------------------------------------------------------------------------- + */ - read_start = start + nrecords; + read_start = start + nrecords; read_nrecords = ntotal_records - read_start; - if(read_nrecords) { - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size))) + if (read_nrecords) { + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, src_size))) goto out; /* read the records after the deleted one(s) */ - if(H5TBread_records(loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBread_records(loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, + tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * write the records in another position - *------------------------------------------------------------------------- - */ + * write the records in another position + *------------------------------------------------------------------------- + */ /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; - /* create the memory data type. */ - if((mem_type_id = H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) - goto out; + /* create the memory data type. */ + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) + goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; /* close */ - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) + goto out; + m_sid = H5I_INVALID_HID; + if (H5Tclose(mem_type_id) < 0) goto out; - m_sid = H5I_BADID; - if(H5Tclose(mem_type_id) < 0) - goto out; - mem_type_id = H5I_BADID; - if(H5Sclose(sid) < 0) + mem_type_id = H5I_INVALID_HID; + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; - if(H5Tclose(tid) < 0) + sid = H5I_INVALID_HID; + if (H5Tclose(tid) < 0) goto out; - tid = H5I_BADID; + tid = H5I_INVALID_HID; } /* read_nrecords */ /*------------------------------------------------------------------------- - * change the dataset dimension - *------------------------------------------------------------------------- - */ + * change the dataset dimension + *------------------------------------------------------------------------- + */ dims[0] = ntotal_records - nrecords; - if(H5Dset_extent(did, dims) < 0) + if (H5Dset_extent(did, dims) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBdelete_record() */ /*------------------------------------------------------------------------- -* Function: H5TBinsert_record -* -* Purpose: Inserts records into middle of table ("pushing down" all the records after it) -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 26, 2001 -* -* Comments: Uses memory offsets -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBinsert_record(hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf) + * Function: H5TBinsert_record + * + * Purpose: Inserts records into middle of table ("pushing down" all the records after it) + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 26, 2001 + * + * Comments: Uses memory offsets + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, + const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t nfields; - hsize_t ntotal_records; - hsize_t read_nrecords; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t dims[1]; - hsize_t mem_dims[1]; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hsize_t nfields; + hsize_t ntotal_records; + hsize_t read_nrecords; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t dims[1]; + hsize_t mem_dims[1]; unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /*------------------------------------------------------------------------- - * read the records after the inserted one(s) - *------------------------------------------------------------------------- - */ + * read the records after the inserted one(s) + *------------------------------------------------------------------------- + */ /* get the dimensions */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &ntotal_records) < 0) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* create the memory data type. */ - if((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) + if ((mem_type_id = H5TB_create_type(loc_id, dset_name, type_size, field_offset, field_sizes, tid)) < 0) goto out; read_nrecords = ntotal_records - start; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t) read_nrecords, type_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)read_nrecords, type_size))) goto out; /* read the records after the inserted one(s) */ - if(H5TBread_records(loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, tmp_buf) < 0) + if (H5TBread_records(loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, + tmp_buf) < 0) goto out; /* extend the dataset */ dims[0] = ntotal_records + nrecords; - if(H5Dset_extent(did, dims) < 0) + if (H5Dset_extent(did, dims) < 0) goto out; /*------------------------------------------------------------------------- - * write the inserted records - *------------------------------------------------------------------------- - */ + * write the inserted records + *------------------------------------------------------------------------- + */ /* create a simple memory data space */ mem_dims[0] = nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get the file data space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset to write the new data */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) goto out; - m_sid = H5I_BADID; - if(H5Sclose(sid) < 0) + m_sid = H5I_INVALID_HID; + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * write the "pushed down" records - *------------------------------------------------------------------------- - */ + * write the "pushed down" records + *------------------------------------------------------------------------- + */ /* create a simple memory data space */ mem_dims[0] = read_nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get the file data space */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* define a hyperslab in the dataset to write the new data */ offset[0] = start + nrecords; count[0] = read_nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - if(H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(mem_type_id > 0) - if(H5Tclose(mem_type_id) < 0) + if (mem_type_id > 0) + if (H5Tclose(mem_type_id) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBinsert_record() */ /*------------------------------------------------------------------------- -* Function: H5TBadd_records_from -* -* Purpose: Add records from first table to second table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: December 5, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -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) + * Function: H5TBadd_records_from + * + * Purpose: Add records from first table to second table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: December 5, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +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) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t nfields; - hsize_t ntotal_records; - size_t type_size1; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - unsigned char *tmp_buf = NULL; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t nfields; + hsize_t ntotal_records; + size_t type_size1; + size_t src_size; + size_t * src_offset = NULL; + size_t * src_sizes = NULL; + unsigned char *tmp_buf = NULL; + herr_t ret_val = -1; /* check the arguments */ if (dset_name1 == NULL) - goto out; + goto out; if (dset_name2 == NULL) - goto out; + goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name1, &nfields, &ntotal_records) < 0) + if (H5TBget_table_info(loc_id, dset_name1, &nfields, &ntotal_records) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /*------------------------------------------------------------------------- - * Get information about the first table and read it - *------------------------------------------------------------------------- - */ + * Get information about the first table and read it + *------------------------------------------------------------------------- + */ /* open the 1st dataset. */ - if((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get the size of the datatype */ - if(0 == (type_size1 = H5Tget_size(tid))) + if (0 == (type_size1 = H5Tget_size(tid))) goto out; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start1; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * add to the second table - *------------------------------------------------------------------------- - */ - if(H5TBinsert_record(loc_id, dset_name2, start2, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + * add to the second table + *------------------------------------------------------------------------- + */ + if (H5TBinsert_record(loc_id, dset_name2, start2, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBadd_records_from() */ /*------------------------------------------------------------------------- -* Function: H5TBcombine_tables -* -* Purpose: Combine records from two tables into a third -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: December 10, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBcombine_tables(hid_t loc_id1, - const char *dset_name1, - hid_t loc_id2, - const char *dset_name2, - const char *dset_name3) + * Function: H5TBcombine_tables + * + * Purpose: Combine records from two tables into a third + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: December 10, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const char *dset_name2, + const char *dset_name3) { /* identifiers for the 1st dataset. */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; /* identifiers for the 2nd dataset. */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; /* identifiers for the 3rd dataset. */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t pid_3 = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims[1]; - hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t i; - size_t type_size; - size_t member_offset; - size_t src_size; - size_t *src_offset = NULL; - size_t *src_sizes = NULL; - char attr_name[255]; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t sid_3 = H5I_INVALID_HID; + hid_t pid_3 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t i; + size_t type_size; + size_t member_offset; + size_t src_size; + 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; - htri_t has_fill; - herr_t ret_val = -1; + htri_t has_fill; + herr_t ret_val = -1; /* check the arguments */ if (dset_name1 == NULL) - goto out; + goto out; if (dset_name2 == NULL) - goto out; + goto out; if (dset_name3 == NULL) - goto out; + goto out; /*------------------------------------------------------------------------- - * first we get information about type size and offsets on disk - *------------------------------------------------------------------------- - */ + * first we get information about type size and offsets on disk + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) + if (H5TBget_field_info(loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size) < 0) goto out; /*------------------------------------------------------------------------- - * get information about the first table - *------------------------------------------------------------------------- - */ + * get information about the first table + *------------------------------------------------------------------------- + */ /* open the 1st dataset. */ - if((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the dimensions */ - if(H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id1, dset_name1, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * make the merged table with no data originally - *------------------------------------------------------------------------- - */ + * make the merged table with no data originally + *------------------------------------------------------------------------- + */ /* clone the property list */ - if((pid_3 = H5Pcopy(pid_1)) < 0) + if ((pid_3 = H5Pcopy(pid_1)) < 0) goto out; /* clone the type id */ - if((tid_3 = H5Tcopy(tid_1)) < 0) + if ((tid_3 = H5Tcopy(tid_1)) < 0) goto out; /*------------------------------------------------------------------------- - * here we do not clone the file space from the 1st dataset, because we want to create - * an empty table. Instead we create a new dataspace with zero records and expandable. - *------------------------------------------------------------------------- - */ + * here we do not clone the file space from the 1st dataset, because we want to create + * an empty table. Instead we create a new dataspace with zero records and expandable. + *------------------------------------------------------------------------- + */ dims[0] = 0; /* create a simple data space with unlimited size */ - if((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* create the dataset */ - if((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * attach the conforming table attributes - *------------------------------------------------------------------------- - */ - if(H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0) + * attach the conforming table attributes + *------------------------------------------------------------------------- + */ + if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- - * get attributes - *------------------------------------------------------------------------- - */ - if(0 == (type_size = H5Tget_size(tid_3))) + * get attributes + *------------------------------------------------------------------------- + */ + if (0 == (type_size = H5Tget_size(tid_3))) goto out; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(type_size))) goto out; /* get the fill value attributes */ - if((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0) + if ((has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf)) < 0) goto out; /*------------------------------------------------------------------------- - * attach the fill attributes from previous table - *------------------------------------------------------------------------- - */ - if(has_fill) { - if((sid = H5Screate(H5S_SCALAR)) < 0) + * attach the fill attributes from previous table + *------------------------------------------------------------------------- + */ + if (has_fill) { + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -1869,249 +1799,245 @@ herr_t H5TBcombine_tables(hid_t loc_id1, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /* close data space. */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; } /* end if */ /*------------------------------------------------------------------------- - * read data from 1st table - *------------------------------------------------------------------------- - */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) + * read data from 1st table + *------------------------------------------------------------------------- + */ + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * save data from 1st table into new table - *------------------------------------------------------------------------- - */ + * save data from 1st table into new table + *------------------------------------------------------------------------- + */ /* append the records to the new table */ - if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * release temporary resources - *------------------------------------------------------------------------- - */ - if(H5Sclose(m_sid) < 0) + * release temporary resources + *------------------------------------------------------------------------- + */ + if (H5Sclose(m_sid) < 0) goto out; - m_sid = H5I_BADID; + m_sid = H5I_INVALID_HID; HDfree(tmp_buf); tmp_buf = NULL; /*------------------------------------------------------------------------- - * get information about the 2nd table - *------------------------------------------------------------------------- - */ + * get information about the 2nd table + *------------------------------------------------------------------------- + */ /* open the dataset. */ - if((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_2 = H5Dget_type(did_2)) < 0) + if ((tid_2 = H5Dget_type(did_2)) < 0) goto out; /* get the dataspace handle */ - if((sid_2 = H5Dget_space(did_2)) < 0) + if ((sid_2 = H5Dget_space(did_2)) < 0) goto out; /* get the property list handle */ - if((pid_2 = H5Dget_create_plist(did_2)) < 0) + if ((pid_2 = H5Dget_create_plist(did_2)) < 0) goto out; /* get the dimensions */ - if(H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id2, dset_name2, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * read data from 2nd table - *------------------------------------------------------------------------- - */ + * read data from 2nd table + *------------------------------------------------------------------------- + */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- - * save data from 2nd table into new table - *------------------------------------------------------------------------- - */ + * save data from 2nd table into new table + *------------------------------------------------------------------------- + */ /* append the records to the new table */ - if(H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) + if (H5TBappend_records(loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf) < 0) goto out; ret_val = 0; out: - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(src_offset) + if (src_offset) HDfree(src_offset); - if(src_sizes) + if (src_sizes) HDfree(src_sizes); - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(sid_3 > 0) - if(H5Sclose(sid_3) < 0) + if (sid_3 > 0) + if (H5Sclose(sid_3) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(pid_3 > 0) - if(H5Pclose(pid_3) < 0) + if (pid_3 > 0) + if (H5Pclose(pid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBcombine_tables() */ /*------------------------------------------------------------------------- -* Function: H5TBinsert_field -* -* Purpose: Inserts a field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -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) + * Function: H5TBinsert_field + * + * Purpose: Inserts a field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +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) { /* identifiers for the 1st, original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; - hid_t msid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; + hid_t msid_1 = H5I_INVALID_HID; /* identifiers for the 2nd, new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; - hid_t msid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; + hid_t msid_2 = H5I_INVALID_HID; /* identifiers for the 3rd, final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - size_t member_size; - size_t new_member_size = 0; - size_t total_size; - size_t curr_offset; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims_chunk[1]; - hsize_t dims[1]; - hsize_t maxdims[1] = { H5S_UNLIMITED }; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - hsize_t i; - char table_title[255]; - char attr_name[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t sid_3 = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + size_t member_size; + size_t new_member_size = 0; + size_t total_size; + size_t curr_offset; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims_chunk[1]; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + hsize_t i; + char table_title[255]; + char attr_name[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; - hbool_t inserted; - herr_t ret_val = -1; + hbool_t inserted; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) @@ -2120,7 +2046,7 @@ herr_t H5TBinsert_field(hid_t loc_id, goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- @@ -2129,27 +2055,27 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* open the dataset. */ - if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the size of the datatype */ - if(0 == (total_size = H5Tget_size(tid_1))) + if (0 == (total_size = H5Tget_size(tid_1))) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) goto out; /*------------------------------------------------------------------------- @@ -2158,15 +2084,15 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the table title */ - if((H5TBAget_title(did_1, table_title)) < 0) + if ((H5TBAget_title(did_1, table_title)) < 0) goto out; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc(total_size))) goto out; /* get the fill value attributes */ - if((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0) + if ((H5TBAget_fill(loc_id, dset_name, did_1, tmp_fill_buf)) < 0) goto out; /*------------------------------------------------------------------------- @@ -2175,31 +2101,31 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the new member size */ - if(0 == (member_size = H5Tget_size(field_type))) + if (0 == (member_size = H5Tget_size(field_type))) goto out; /* create the data type. */ - if((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0) + if ((tid_2 = H5Tcreate(H5T_COMPOUND, (size_t)(total_size + member_size))) < 0) goto out; curr_offset = 0; inserted = FALSE; /* insert the old fields, counting with the new one */ - for(i = 0; i < nfields + 1; i++) { - hsize_t idx; + for (i = 0; i < nfields + 1; i++) { + hsize_t idx; idx = i; - if(inserted) + if (inserted) idx = i - 1; - if(i == position) { + if (i == position) { /* get the new member size */ - if(0 == (new_member_size = H5Tget_size(field_type))) + if (0 == (new_member_size = H5Tget_size(field_type))) goto out; /* insert the new field type */ - if(H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0) + if (H5Tinsert(tid_2, field_name, curr_offset, field_type) < 0) goto out; curr_offset += new_member_size; @@ -2208,19 +2134,19 @@ herr_t H5TBinsert_field(hid_t loc_id, } /* end if */ else { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)idx))) goto out; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)idx)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* insert it into the new type */ - if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) + if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) goto out; curr_offset += member_size; @@ -2229,11 +2155,11 @@ herr_t H5TBinsert_field(hid_t loc_id, member_name = NULL; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end else */ - } /* end for */ + } /* end for */ /*------------------------------------------------------------------------- * create a new temporary dataset @@ -2241,21 +2167,21 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* retrieve the size of chunk */ - if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0) + if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; /* create a new simple data space with unlimited size, using the dimension */ - if((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ - if((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((pid_2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0) + if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) goto out; /* create the dataset. */ - if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- @@ -2263,21 +2189,21 @@ herr_t H5TBinsert_field(hid_t loc_id, *------------------------------------------------------------------------- */ - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size))) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; - if(H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if(H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- @@ -2286,7 +2212,7 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* write */ - if(H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dwrite(did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /*------------------------------------------------------------------------- @@ -2295,27 +2221,27 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, (size_t)new_member_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, (size_t)new_member_size)) < 0) goto out; /* the field in the file is found by its name */ - if(H5Tinsert(write_type_id, field_name, (size_t)0, field_type) < 0) + if (H5Tinsert(write_type_id, field_name, (size_t)0, field_type) < 0) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* only write if there is something to write */ - if(buf) { + if (buf) { /* create a memory dataspace handle */ - if((msid_2 = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((msid_2 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; /* write */ - if(H5Dwrite(did_2, write_type_id, msid_2, sid_2, preserve_id, buf) < 0) + if (H5Dwrite(did_2, write_type_id, msid_2, sid_2, preserve_id, buf) < 0) goto out; } /* end if */ @@ -2323,14 +2249,14 @@ herr_t H5TBinsert_field(hid_t loc_id, * delete 1st table *------------------------------------------------------------------------- */ - if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) + if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- * rename 2nd table *------------------------------------------------------------------------- */ - if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- @@ -2339,33 +2265,33 @@ herr_t H5TBinsert_field(hid_t loc_id, */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /* open the dataset. */ - if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_3 = H5Dget_type(did_3)) < 0) + if ((tid_3 = H5Dget_type(did_3)) < 0) goto out; /* set the attributes */ - if(H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0) + if (H5TB_attach_attributes(table_title, loc_id, dset_name, (hsize_t)nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- * attach the fill attributes from previous table *------------------------------------------------------------------------- */ - if((sid_3 = H5Screate(H5S_SCALAR)) < 0) + if ((sid_3 = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < (nfields - 1); i++) { - size_t member_offset; + for (i = 0; i < (nfields - 1); i++) { + size_t member_offset; /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -2373,160 +2299,158 @@ herr_t H5TBinsert_field(hid_t loc_id, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /*------------------------------------------------------------------------- * attach the fill attribute from the new field, if present *------------------------------------------------------------------------- */ - if(fill_data) { + if (fill_data) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)(nfields - 1)); /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)nfields - 1)) < 0) goto out; - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, fill_data) < 0) + if (H5Awrite(attr_id, member_type_id, fill_data) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end fill_data */ ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(msid_1 > 0) - if(H5Sclose(msid_1) < 0) + if (msid_1 > 0) + if (H5Sclose(msid_1) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(msid_2 > 0) - if(H5Sclose(msid_2) < 0) + if (msid_2 > 0) + if (H5Sclose(msid_2) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(sid_3 > 0) - if(H5Sclose(sid_3) < 0) + if (sid_3 > 0) + if (H5Sclose(sid_3) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBinsert_field() */ /*------------------------------------------------------------------------- -* Function: H5TBdelete_field -* -* Purpose: Deletes a field -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBdelete_field(hid_t loc_id, - const char *dset_name, - const char *field_name) + * Function: H5TBdelete_field + * + * Purpose: Deletes a field + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) { /* identifiers for the 1st original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; /* identifiers for the 2nd new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; /* identifiers for the 3rd final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; - size_t member_size; - size_t type_size1; - size_t type_size2; - size_t curr_offset; - size_t delete_member_size = 0; - size_t member_offset; - hsize_t nfields; - hsize_t nrecords; - hsize_t dims_chunk[1]; - hsize_t dims[1]; - hsize_t maxdims[1] = { H5S_UNLIMITED }; - hsize_t i; - char attr_name[255]; - char table_title[255]; - char *member_name = NULL; - unsigned char *tmp_buf = NULL; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; + hid_t read_type_id = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; + size_t member_size; + size_t type_size1; + size_t type_size2; + size_t curr_offset; + size_t delete_member_size = 0; + size_t member_offset; + hsize_t nfields; + hsize_t nrecords; + hsize_t dims_chunk[1]; + hsize_t dims[1]; + hsize_t maxdims[1] = {H5S_UNLIMITED}; + hsize_t i; + char attr_name[255]; + char table_title[255]; + char * member_name = NULL; + unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; - htri_t has_fill = FALSE; - herr_t ret_val = -1; - + htri_t has_fill = FALSE; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) @@ -2535,63 +2459,63 @@ herr_t H5TBdelete_field(hid_t loc_id, goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /*------------------------------------------------------------------------- - * get information about the old data type - *------------------------------------------------------------------------- - */ + * get information about the old data type + *------------------------------------------------------------------------- + */ /* open the dataset. */ - if((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get creation properties list */ - if((pid_1 = H5Dget_create_plist(did_1)) < 0) + if ((pid_1 = H5Dget_create_plist(did_1)) < 0) goto out; /* get the datatype */ - if((tid_1 = H5Dget_type(did_1)) < 0) + if ((tid_1 = H5Dget_type(did_1)) < 0) goto out; /* get the size of the datatype */ - if(0 == (type_size1 = H5Tget_size(tid_1))) + if (0 == (type_size1 = H5Tget_size(tid_1))) goto out; /* get the dataspace handle */ - if((sid_1 = H5Dget_space(did_1)) < 0) + if ((sid_1 = H5Dget_space(did_1)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid_1, dims, NULL) < 0) goto out; /*------------------------------------------------------------------------- - * create a new data type; first we find the size of the datatype to delete - *------------------------------------------------------------------------- - */ + * create a new data type; first we find the size of the datatype to delete + *------------------------------------------------------------------------- + */ /* check out the field */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* we want to find the field to delete */ - if(H5TB_find_field(member_name, field_name)) { + if (H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (delete_member_size = H5Tget_size(member_type_id))) + if (0 == (delete_member_size = H5Tget_size(member_type_id))) goto out; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; @@ -2604,77 +2528,77 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /* no field to delete was found */ - if(delete_member_size == 0) + if (delete_member_size == 0) goto out; /*------------------------------------------------------------------------- - * create a new data type; we now insert all the fields into the new type - *------------------------------------------------------------------------- - */ + * create a new data type; we now insert all the fields into the new type + *------------------------------------------------------------------------- + */ type_size2 = type_size1 - delete_member_size; /* create the data type. */ - if((tid_2 = H5Tcreate (H5T_COMPOUND, type_size2)) < 0) + if ((tid_2 = H5Tcreate(H5T_COMPOUND, type_size2)) < 0) goto out; curr_offset = 0; /* alloc fill value attribute buffer */ - if(NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2))) + if (NULL == (tmp_fill_buf = (unsigned char *)HDmalloc((size_t)type_size2))) goto out; /*------------------------------------------------------------------------- - * get attributes from previous table in the process - *------------------------------------------------------------------------- - */ + * get attributes from previous table in the process + *------------------------------------------------------------------------- + */ /* get the table title */ - if((H5TBAget_title(did_1, table_title)) < 0) + if ((H5TBAget_title(did_1, table_title)) < 0) goto out; /* insert the old fields except the one to delete */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* we want to skip the field to delete */ - if(!H5TB_find_field(member_name, field_name)) { + if (!H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* insert it into the new type */ - if(H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) + if (H5Tinsert(tid_2, member_name, curr_offset, member_type_id) < 0) goto out; /*------------------------------------------------------------------------- - * get the fill value information - *------------------------------------------------------------------------- - */ + * get the fill value information + *------------------------------------------------------------------------- + */ HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); /* check if we have the _FILL attribute */ - if((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0) + if ((has_fill = H5LT_find_attribute(did_1, attr_name)) < 0) goto out; /* get it */ - if(has_fill) - if(H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0) + if (has_fill) + if (H5LT_get_attribute_disk(did_1, attr_name, tmp_fill_buf + curr_offset) < 0) goto out; curr_offset += member_size; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end if */ H5free_memory(member_name); @@ -2682,98 +2606,98 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /*------------------------------------------------------------------------- - * create a new temporary dataset - *------------------------------------------------------------------------- - */ + * create a new temporary dataset + *------------------------------------------------------------------------- + */ /* retrieve the size of chunk */ - if(H5Pget_chunk(pid_1, 1, dims_chunk) < 0) + if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; /* create a new simple data space with unlimited size, using the dimension */ - if((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) + if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) goto out; /* modify dataset creation properties, i.e. enable chunking */ pid_2 = H5Pcreate(H5P_DATASET_CREATE); - if(H5Pset_chunk(pid_2, 1, dims_chunk) < 0) + if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) goto out; /* create the dataset. */ - if((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) + if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * we have to read field by field of the old dataset and save it into the new one - *------------------------------------------------------------------------- - */ - for(i = 0; i < nfields; i++) { + * we have to read field by field of the old dataset and save it into the new one + *------------------------------------------------------------------------- + */ + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid_1, (unsigned)i))) goto out; /* skip the field to delete */ - if(!H5TB_find_field(member_name, field_name)) { + if (!H5TB_find_field(member_name, field_name)) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; /* get the member size */ - if(0 == (member_size = H5Tget_size(member_type_id))) + if (0 == (member_size = H5Tget_size(member_type_id))) goto out; /* create a read id */ - if((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) + if ((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; /* insert it into the new type */ - if(H5Tinsert(read_type_id, member_name, (size_t)0, member_type_id) < 0) + if (H5Tinsert(read_type_id, member_name, (size_t)0, member_type_id) < 0) goto out; - if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size))) + if (NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, member_size))) goto out; /* read */ - if(H5Dread(did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) + if (H5Dread(did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; /* create a write id */ - if((write_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) + if ((write_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; /* the field in the file is found by its name */ - if(H5Tinsert(write_type_id, member_name, (size_t)0, member_type_id) < 0) + if (H5Tinsert(write_type_id, member_name, (size_t)0, member_type_id) < 0) goto out; /* create xfer properties to preserve initialized data */ - if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + if ((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto out; - if(H5Pset_preserve(preserve_id, 1) < 0) + if (H5Pset_preserve(preserve_id, 1) < 0) goto out; /* write */ - if(H5Dwrite(did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf) < 0) + if (H5Dwrite(did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf) < 0) goto out; /* end access to the property list */ - if(H5Pclose(preserve_id) < 0) + if (H5Pclose(preserve_id) < 0) goto out; - preserve_id = H5I_BADID; + preserve_id = H5I_INVALID_HID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; /* close the read type */ - if(H5Tclose(read_type_id) < 0) + if (H5Tclose(read_type_id) < 0) goto out; - read_type_id = H5I_BADID; + read_type_id = H5I_INVALID_HID; /* close the write type */ - if(H5Tclose(write_type_id) < 0) + if (H5Tclose(write_type_id) < 0) goto out; - write_type_id = H5I_BADID; + write_type_id = H5I_INVALID_HID; HDfree(tmp_buf); tmp_buf = NULL; @@ -2785,51 +2709,51 @@ herr_t H5TBdelete_field(hid_t loc_id, } /* end for */ /*------------------------------------------------------------------------- - * delete 1st table - *------------------------------------------------------------------------- - */ - if(H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) + * delete 1st table + *------------------------------------------------------------------------- + */ + if (H5Ldelete(loc_id, dset_name, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * rename 2nd table - *------------------------------------------------------------------------- - */ - if(H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + * rename 2nd table + *------------------------------------------------------------------------- + */ + if (H5Lmove(loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * attach the conforming table attributes - *------------------------------------------------------------------------- - */ + * attach the conforming table attributes + *------------------------------------------------------------------------- + */ /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; /* open the dataset. */ - if((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did_3 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid_3 = H5Dget_type(did_3)) < 0) + if ((tid_3 = H5Dget_type(did_3)) < 0) goto out; /* set the attributes */ - if(H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0) + if (H5TB_attach_attributes(table_title, loc_id, dset_name, nfields, tid_3) < 0) goto out; /*------------------------------------------------------------------------- - * attach the fill attributes from previous table - *------------------------------------------------------------------------- - */ - if(has_fill) { - if((sid_1 = H5Screate(H5S_SCALAR)) < 0) + * attach the fill attributes from previous table + *------------------------------------------------------------------------- + */ + if (has_fill) { + if ((sid_1 = H5Screate(H5S_SCALAR)) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member type */ - if((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) + if ((member_type_id = H5Tget_member_type(tid_3, (unsigned)i)) < 0) goto out; /* get the member offset */ @@ -2837,259 +2761,254 @@ herr_t H5TBdelete_field(hid_t loc_id, HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); - if((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf + member_offset) < 0) goto out; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; /* close the member type */ - if(H5Tclose(member_type_id) < 0) + if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /* close data space. */ - if(H5Sclose(sid_1) < 0) + if (H5Sclose(sid_1) < 0) goto out; - sid_1 = H5I_BADID; + sid_1 = H5I_INVALID_HID; } /* end if */ ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); - if(tmp_fill_buf) + if (tmp_fill_buf) HDfree(tmp_fill_buf); - if(tmp_buf) + if (tmp_buf) HDfree(tmp_buf); - if(attr_id > 0) - if(H5Aclose(attr_id) < 0) + if (attr_id > 0) + if (H5Aclose(attr_id) < 0) ret_val = -1; - if(preserve_id > 0) - if(H5Pclose(preserve_id) < 0) + if (preserve_id > 0) + if (H5Pclose(preserve_id) < 0) ret_val = -1; - if(member_type_id > 0) - if(H5Tclose(member_type_id) < 0) + if (member_type_id > 0) + if (H5Tclose(member_type_id) < 0) ret_val = -1; - if(read_type_id > 0) - if(H5Tclose(read_type_id) < 0) + if (read_type_id > 0) + if (H5Tclose(read_type_id) < 0) ret_val = -1; - if(write_type_id > 0) - if(H5Tclose(write_type_id) < 0) + if (write_type_id > 0) + if (H5Tclose(write_type_id) < 0) ret_val = -1; - if(tid_1 > 0) - if(H5Tclose(tid_1) < 0) + if (tid_1 > 0) + if (H5Tclose(tid_1) < 0) ret_val = -1; - if(pid_1 > 0) - if(H5Pclose(pid_1) < 0) + if (pid_1 > 0) + if (H5Pclose(pid_1) < 0) ret_val = -1; - if(sid_1 > 0) - if(H5Sclose(sid_1) < 0) + if (sid_1 > 0) + if (H5Sclose(sid_1) < 0) ret_val = -1; - if(did_1 > 0) - if(H5Dclose(did_1) < 0) + if (did_1 > 0) + if (H5Dclose(did_1) < 0) ret_val = -1; - if(sid_2 > 0) - if(H5Sclose(sid_2) < 0) + if (sid_2 > 0) + if (H5Sclose(sid_2) < 0) ret_val = -1; - if(tid_2 > 0) - if(H5Tclose(tid_2) < 0) + if (tid_2 > 0) + if (H5Tclose(tid_2) < 0) ret_val = -1; - if(pid_2 > 0) - if(H5Pclose(pid_2) < 0) + if (pid_2 > 0) + if (H5Pclose(pid_2) < 0) ret_val = -1; - if(did_2 > 0) - if(H5Dclose(did_2) < 0) + if (did_2 > 0) + if (H5Dclose(did_2) < 0) ret_val = -1; - if(tid_3 > 0) - if(H5Tclose(tid_3) < 0) + if (tid_3 > 0) + if (H5Tclose(tid_3) < 0) ret_val = -1; - if(did_3 > 0) - if(H5Dclose(did_3) < 0) + if (did_3 > 0) + if (H5Dclose(did_3) < 0) ret_val = -1; return ret_val; } /* end H5TBdelete_field() */ /*------------------------------------------------------------------------- -* -* Table attribute functions -* -*------------------------------------------------------------------------- -*/ + * + * Table attribute functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBAget_title -* -* Purpose: Read the table title -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: January 30, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBAget_title(hid_t loc_id, - char *table_title) + * Function: H5TBAget_title + * + * Purpose: Read the table title + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: January 30, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBAget_title(hid_t loc_id, char *table_title) { /* Get the TITLE attribute */ - if(H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0) + if (H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0) return -1; return 0; } /*------------------------------------------------------------------------- -* Function: H5TBAget_fill -* -* Purpose: Read the table attribute fill values -* -* Return: Success: TRUE/FALSE, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: January 30, 2002 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -htri_t H5TBAget_fill(hid_t loc_id, - const char *dset_name, - hid_t dset_id, - unsigned char *dst_buf) + * Function: H5TBAget_fill + * + * Purpose: Read the table attribute fill values + * + * Return: Success: TRUE/FALSE, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: January 30, 2002 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +htri_t +H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf) { - hsize_t nfields; - hsize_t nrecords; - hsize_t i; - size_t *src_offset = NULL; - char attr_name[255]; - htri_t has_fill = FALSE; - htri_t ret_val = -1; + hsize_t nfields; + hsize_t nrecords; + hsize_t i; + size_t *src_offset = NULL; + char attr_name[255]; + htri_t has_fill = FALSE; + htri_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* get the number of records and fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0) goto out; - if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) + if (NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0) + if (H5TBget_field_info(loc_id, dset_name, NULL, NULL, src_offset, NULL) < 0) goto out; - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_FILL", (int)i); /* check if we have the _FILL attribute */ - if((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0) + if ((has_fill = H5LT_find_attribute(dset_id, attr_name)) < 0) goto out; /* get it */ - if(has_fill) - if(H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0) + if (has_fill) + if (H5LT_get_attribute_disk(dset_id, attr_name, dst_buf + src_offset[i]) < 0) goto out; } /* end for */ ret_val = has_fill; out: - if(src_offset) + if (src_offset) HDfree(src_offset); return ret_val; } /* end H5TBAget_fill() */ - /*------------------------------------------------------------------------- -* -* Inquiry functions -* -*------------------------------------------------------------------------- -*/ + * + * Inquiry functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TBget_table_info -* -* Purpose: Gets the number of records and fields of a table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -herr_t H5TBget_table_info(hid_t loc_id, - const char *dset_name, - hsize_t *nfields, - hsize_t *nrecords) + * Function: H5TBget_table_info + * + * Purpose: Gets the number of records and fields of a table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords) { - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t did = H5I_BADID; - hsize_t dims[1]; - int num_members; - herr_t ret_val = -1; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hsize_t dims[1]; + int num_members; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; /* get the number of members */ - if((num_members = H5Tget_nmembers(tid)) < 0) + if ((num_members = H5Tget_nmembers(tid)) < 0) goto out; /*------------------------------------------------------------------------- - * get number of nfields - *------------------------------------------------------------------------- - */ - if(nfields) + * get number of nfields + *------------------------------------------------------------------------- + */ + if (nfields) *nfields = (hsize_t)num_members; /*------------------------------------------------------------------------- - * get number of records - *------------------------------------------------------------------------- - */ - if(nrecords) { + * get number of records + *------------------------------------------------------------------------- + */ + if (nrecords) { /* get the dataspace handle */ - if((sid = H5Dget_space(did)) < 0) + if ((sid = H5Dget_space(did)) < 0) goto out; /* get dimension */ - if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) goto out; /* terminate access to the dataspace */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; *nrecords = dims[0]; } /* end if */ @@ -3097,229 +3016,223 @@ herr_t H5TBget_table_info(hid_t loc_id, ret_val = 0; out: - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBget_table_info() */ /*------------------------------------------------------------------------- -* Function: H5TBget_field_info -* -* Purpose: Get information about fields -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -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) + * Function: H5TBget_field_info + * + * Purpose: Get information about fields + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +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) { - hid_t did = H5I_BADID; /* dataset ID */ - hid_t tid = H5I_BADID; /* file type ID */ - hid_t n_tid = H5I_BADID; /* native type ID */ - hid_t m_tid = H5I_BADID; /* member type ID */ - hid_t nm_tid = H5I_BADID; /* native member ID */ - hssize_t nfields; - hssize_t i; - herr_t ret_val = -1; + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t tid = H5I_INVALID_HID; /* file type ID */ + hid_t n_tid = H5I_INVALID_HID; /* native type ID */ + hid_t m_tid = H5I_INVALID_HID; /* member type ID */ + hid_t nm_tid = H5I_INVALID_HID; /* native member ID */ + hssize_t nfields; + hssize_t i; + herr_t ret_val = -1; /* check the arguments */ if (dset_name == NULL) goto out; /* open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; /* get the datatype */ - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) + if ((n_tid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the type size */ - if(type_size) - if(0 == (*type_size = H5Tget_size(n_tid))) + if (type_size) + if (0 == (*type_size = H5Tget_size(n_tid))) goto out; /* get the number of members */ - if((nfields = H5Tget_nmembers(tid)) < 0) + if ((nfields = H5Tget_nmembers(tid)) < 0) goto out; /* iterate tru the members */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(field_names) { - char *member_name; + if (field_names) { + char *member_name; - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; strcpy(field_names[i], member_name); H5free_memory(member_name); } /* end if */ /* get the member type */ - if((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0) + if ((m_tid = H5Tget_member_type(tid, (unsigned)i)) < 0) goto out; - if((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0) + if ((nm_tid = H5Tget_native_type(m_tid, H5T_DIR_DEFAULT)) < 0) goto out; /* get the member size */ - if(field_sizes) - if(0 == (field_sizes[i] = H5Tget_size(nm_tid))) + if (field_sizes) + if (0 == (field_sizes[i] = H5Tget_size(nm_tid))) goto out; /* get the member offset */ - if(field_offsets) - field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned) i); + if (field_offsets) + field_offsets[i] = H5Tget_member_offset(n_tid, (unsigned)i); /* close the member types */ - if(H5Tclose(m_tid) < 0) + if (H5Tclose(m_tid) < 0) goto out; - m_tid = H5I_BADID; - if(H5Tclose(nm_tid) < 0) + m_tid = H5I_INVALID_HID; + if (H5Tclose(nm_tid) < 0) goto out; - nm_tid = H5I_BADID; + nm_tid = H5I_INVALID_HID; } /* end for */ ret_val = 0; out: - if(tid > 0) - if(H5Tclose(tid) < 0) + if (tid > 0) + if (H5Tclose(tid) < 0) ret_val = -1; - if(n_tid > 0) - if(H5Tclose(n_tid) < 0) + if (n_tid > 0) + if (H5Tclose(n_tid) < 0) ret_val = -1; - if(m_tid > 0) - if(H5Tclose(m_tid) < 0) + if (m_tid > 0) + if (H5Tclose(m_tid) < 0) ret_val = -1; - if(nm_tid > 0) - if(H5Tclose(nm_tid) < 0) + if (nm_tid > 0) + if (H5Tclose(nm_tid) < 0) ret_val = -1; - if(did > 0) - if(H5Dclose(did) < 0) + if (did > 0) + if (H5Dclose(did) < 0) ret_val = -1; return ret_val; } /* end H5TBget_field_info() */ /*------------------------------------------------------------------------- -* -* internal functions -* -*------------------------------------------------------------------------- -*/ + * + * internal functions + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TB_find_field -* -* Purpose: Find a string field -* -* Return: Success: TRUE/FALSE, Failure: N/A -* -* Programmer: Pedro Vicente -* -* Date: November 19, 2001 -* -*------------------------------------------------------------------------- -*/ -H5_ATTR_PURE static -hbool_t H5TB_find_field(const char *field, const char *field_list) + * Function: H5TB_find_field + * + * Purpose: Find a string field + * + * Return: Success: TRUE/FALSE, Failure: N/A + * + * Programmer: Pedro Vicente + * + * Date: November 19, 2001 + * + *------------------------------------------------------------------------- + */ +H5_ATTR_PURE static hbool_t +H5TB_find_field(const char *field, const char *field_list) { const char *start = field_list; const char *end; /* check the arguments */ if (field == NULL) - return FALSE; + return FALSE; if (field_list == NULL) - return FALSE; + return FALSE; - while((end = HDstrstr(start, ",")) != 0) { + while ((end = HDstrstr(start, ",")) != 0) { ptrdiff_t count = end - start; - if(HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field)) + if (HDstrncmp(start, field, (size_t)count) == 0 && (size_t)count == HDstrlen(field)) return TRUE; start = end + 1; } /* end while */ - if(HDstrncmp(start, field, HDstrlen(field)) == 0) + if (HDstrncmp(start, field, HDstrlen(field)) == 0) return TRUE; return FALSE; } /* end H5TB_find_field() */ /*------------------------------------------------------------------------- -* Function: H5TB_attach_attributes -* -* Purpose: Private function that creates the conforming table attributes; -* Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read -* the fill value attributes from an existing table -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: December 6, 2001 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -static -herr_t H5TB_attach_attributes(const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hid_t tid) + * Function: H5TB_attach_attributes + * + * Purpose: Private function that creates the conforming table attributes; + * Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read + * the fill value attributes from an existing table + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: December 6, 2001 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, + hid_t tid) { - char attr_name[255]; - char *member_name = NULL; - hsize_t i; - herr_t ret_val = -1; + char attr_name[255]; + char * member_name = NULL; + hsize_t i; + herr_t ret_val = -1; /* attach the CLASS attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "CLASS", TABLE_CLASS) < 0) goto out; /* attach the VERSION attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "VERSION", TABLE_VERSION) < 0) goto out; /* attach the TITLE attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, "TITLE", table_title) < 0) goto out; /* attach the FIELD_ name attribute */ - for(i = 0; i < nfields; i++) { + for (i = 0; i < nfields; i++) { /* get the member name */ - if(NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) + if (NULL == (member_name = H5Tget_member_name(tid, (unsigned)i))) goto out; HDsnprintf(attr_name, sizeof(attr_name), "FIELD_%d_NAME", (int)i); /* attach the attribute */ - if(H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) + if (H5LTset_attribute_string(loc_id, dset_name, attr_name, member_name) < 0) goto out; H5free_memory(member_name); @@ -3329,57 +3242,53 @@ herr_t H5TB_attach_attributes(const char *table_title, ret_val = 0; out: - if(member_name) + if (member_name) H5free_memory(member_name); return ret_val; } /* end H5TB_attach_attributes() */ /*------------------------------------------------------------------------- -* Function: H5TB_create_type -* -* Purpose: Private function that creates a memory type ID -* -* Return: Success: the memory type ID, Failure: -1 -* -* Programmer: Pedro Vicente -* -* Date: March 31, 2004 -* -* Comments: -* -*------------------------------------------------------------------------- -*/ -static -hid_t H5TB_create_type(hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - hid_t ftype_id) + * Function: H5TB_create_type + * + * Purpose: Private function that creates a memory type ID + * + * Return: Success: the memory type ID, Failure: -1 + * + * Programmer: Pedro Vicente + * + * Date: March 31, 2004 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +static hid_t +H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, + const size_t *field_sizes, hid_t ftype_id) { - hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t mtype_id = H5I_INVALID_HID; + 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; + hid_t ret_val = -1; /* get the number of fields */ - if(H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0) + if (H5TBget_table_info(loc_id, dset_name, &nfields, NULL) < 0) goto out; - if(NULL == (fnames = (char**)HDcalloc(sizeof(char*), (size_t)nfields))) + if (NULL == (fnames = (char **)HDcalloc(sizeof(char *), (size_t)nfields))) goto out; - for(i = 0; i < nfields; i++) - if(NULL == (fnames[i] = (char*)HDmalloc(HLTB_MAX_FIELD_LEN))) + for (i = 0; i < nfields; i++) + if (NULL == (fnames[i] = (char *)HDmalloc(HLTB_MAX_FIELD_LEN))) goto out; /* get field info */ - if(H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0) + if (H5TBget_field_info(loc_id, dset_name, fnames, NULL, NULL, NULL) < 0) goto out; /* create the memory data type */ @@ -3387,182 +3296,176 @@ hid_t H5TB_create_type(hid_t loc_id, goto out; /* get each field ID and adjust its size, if necessary */ - for(i = 0; i < nfields; i++) { - if((mtype_id = H5Tget_member_type(ftype_id, i)) < 0) + for (i = 0; i < nfields; i++) { + if ((mtype_id = H5Tget_member_type(ftype_id, i)) < 0) goto out; - if((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) + if ((nmtype_id = H5Tget_native_type(mtype_id, H5T_DIR_DEFAULT)) < 0) goto out; - if(0 == (size_native = H5Tget_size(nmtype_id))) + if (0 == (size_native = H5Tget_size(nmtype_id))) goto out; - if(field_sizes[i] != size_native) - if(H5Tset_size(nmtype_id, field_sizes[i]) < 0) + if (field_sizes[i] != size_native) + if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; - if(H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0) + if (H5Tinsert(mem_type_id, fnames[i], field_offset[i], nmtype_id) < 0) goto out; - if(H5Tclose(mtype_id) < 0) + if (H5Tclose(mtype_id) < 0) goto out; - mtype_id = H5I_BADID; - if(H5Tclose(nmtype_id) < 0) + mtype_id = H5I_INVALID_HID; + if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; } /* end for */ ret_val = mem_type_id; out: - if(fnames) { - for(i = 0; i < nfields; i++) - if(fnames[i]) + if (fnames) { + for (i = 0; i < nfields; i++) + if (fnames[i]) HDfree(fnames[i]); HDfree(fnames); } /* end if */ - if(mtype_id > 0) - if(H5Tclose(mtype_id) < 0) + if (mtype_id > 0) + if (H5Tclose(mtype_id) < 0) ret_val = -1; - if(nmtype_id > 0) - if(H5Tclose(nmtype_id) < 0) + if (nmtype_id > 0) + if (H5Tclose(nmtype_id) < 0) ret_val = -1; - if(ret_val < 0 && mem_type_id > 0) + if (ret_val < 0 && mem_type_id > 0) H5Tclose(mem_type_id); return ret_val; } /* end H5TB_create_type() */ /*------------------------------------------------------------------------- -* -* Functions shared between H5TB and H5PT -* -*------------------------------------------------------------------------- -*/ + * + * Functions shared between H5TB and H5PT + * + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- -* Function: H5TB_common_append_records -* -* Purpose: Common code for reading records shared between H5PT and H5TB -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Nat Furrer -* James Laird -* -* Date: March 8, 2004 -* -* Comments: Called by H5TBappend_records and H5PTappend_records -* -*------------------------------------------------------------------------- -*/ -herr_t H5TB_common_append_records(hid_t dataset_id, - hid_t mem_type_id, - size_t nrecords, - hsize_t orig_table_size, - const void *buf) + * Function: H5TB_common_append_records + * + * Purpose: Common code for reading records shared between H5PT and H5TB + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Nat Furrer + * James Laird + * + * Date: March 8, 2004 + * + * Comments: Called by H5TBappend_records and H5PTappend_records + * + *------------------------------------------------------------------------- + */ +herr_t +H5TB_common_append_records(hid_t dataset_id, hid_t mem_type_id, size_t nrecords, hsize_t orig_table_size, + const void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t dims[1]; - hsize_t mem_dims[1]; - herr_t ret_val = -1; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t dims[1]; + hsize_t mem_dims[1]; + herr_t ret_val = -1; /* extend the dataset */ dims[0] = nrecords + orig_table_size; - if(H5Dset_extent(dataset_id, dims) < 0) + if (H5Dset_extent(dataset_id, dims) < 0) goto out; /* create a simple memory data space */ mem_dims[0] = nrecords; - if((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) goto out; /* get a copy of the new file data space for writing */ - if((sid = H5Dget_space(dataset_id)) < 0) + if ((sid = H5Dget_space(dataset_id)) < 0) goto out; /* define a hyperslab in the dataset */ offset[0] = orig_table_size; - count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + count[0] = nrecords; + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* write the records */ - if(H5Dwrite(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; return ret_val; } /* end H5TB_common_append_records() */ /*------------------------------------------------------------------------- -* Function: H5TB_common_read_records -* -* Purpose: Common code for reading records shared between H5PT and H5TB -* -* Return: Success: 0, Failure: -1 -* -* Programmer: Nat Furrer -* James Laird -* -* Date: March 8, 2004 -* -* Comments: Called by H5TBread_records and H5PTread_records -* -*------------------------------------------------------------------------- -*/ -herr_t H5TB_common_read_records(hid_t dataset_id, - hid_t mem_type_id, - hsize_t start, - size_t nrecords, - hsize_t table_size, - void *buf) + * Function: H5TB_common_read_records + * + * Purpose: Common code for reading records shared between H5PT and H5TB + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Nat Furrer + * James Laird + * + * Date: March 8, 2004 + * + * Comments: Called by H5TBread_records and H5PTread_records + * + *------------------------------------------------------------------------- + */ +herr_t +H5TB_common_read_records(hid_t dataset_id, hid_t mem_type_id, hsize_t start, size_t nrecords, + hsize_t table_size, void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hsize_t count[1]; - hsize_t offset[1]; - hsize_t mem_size[1]; - herr_t ret_val = -1; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hsize_t count[1]; + hsize_t offset[1]; + hsize_t mem_size[1]; + herr_t ret_val = -1; /* make sure the read request is in bounds */ - if(start + nrecords > table_size) + if (start + nrecords > table_size) goto out; /* get the dataspace handle */ - if((sid = H5Dget_space(dataset_id)) < 0) + if ((sid = H5Dget_space(dataset_id)) < 0) goto out; /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; - if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; /* create a memory dataspace handle */ mem_size[0] = count[0]; - if((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) + if ((m_sid = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - if((H5Dread(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0) + if ((H5Dread(dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0) goto out; ret_val = 0; out: - if(m_sid > 0) - if(H5Sclose(m_sid) < 0) + if (m_sid > 0) + if (H5Sclose(m_sid) < 0) ret_val = -1; - if(sid > 0) - if(H5Sclose(sid) < 0) + if (sid > 0) + if (H5Sclose(sid) < 0) ret_val = -1; return ret_val; } /* end H5TB_common_read_records() */ - diff --git a/hl/src/H5TBprivate.h b/hl/src/H5TBprivate.h index 17306fbdead..95b58e6e8ee 100644 --- a/hl/src/H5TBprivate.h +++ b/hl/src/H5TBprivate.h @@ -6,13 +6,13 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5TBprivate_H -#define _H5TBprivate_H +#ifndef H5TBprivate_H +#define H5TBprivate_H /* High-level library internal header file */ #include "H5HLprivate2.h" @@ -20,10 +20,9 @@ /* public TB prototypes */ #include "H5TBpublic.h" - -#define TABLE_CLASS "TABLE" -#define TABLE_VERSION "3.0" -#define HLTB_MAX_FIELD_LEN 255 +#define TABLE_CLASS "TABLE" +#define TABLE_VERSION "3.0" +#define HLTB_MAX_FIELD_LEN 255 /*------------------------------------------------------------------------- * @@ -32,11 +31,8 @@ *------------------------------------------------------------------------- */ -herr_t H5TB_common_append_records( hid_t dataset_id, - hid_t mem_type_id, - size_t nrecords, - hsize_t orig_table_size, - const void * data); +herr_t H5TB_common_append_records(hid_t dataset_id, hid_t mem_type_id, size_t nrecords, + hsize_t orig_table_size, const void *data); /*------------------------------------------------------------------------- * @@ -45,16 +41,7 @@ herr_t H5TB_common_append_records( hid_t dataset_id, *------------------------------------------------------------------------- */ - -herr_t H5TB_common_read_records( hid_t dataset_id, - hid_t mem_type_id, - hsize_t start, - size_t nrecords, - hsize_t table_size, - void *data); - - - +herr_t H5TB_common_read_records(hid_t dataset_id, hid_t mem_type_id, hsize_t start, size_t nrecords, + hsize_t table_size, void *data); #endif - diff --git a/hl/src/H5TBpublic.h b/hl/src/H5TBpublic.h index 56aa915cfb1..1750490791f 100644 --- a/hl/src/H5TBpublic.h +++ b/hl/src/H5TBpublic.h @@ -6,20 +6,18 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5TBpublic_H -#define _H5TBpublic_H - +#ifndef H5TBpublic_H +#define H5TBpublic_H #ifdef __cplusplus extern "C" { #endif - /*------------------------------------------------------------------------- * * Create functions @@ -27,20 +25,10 @@ extern "C" { *------------------------------------------------------------------------- */ -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, - void *fill_data, - int compress, - const void *buf ); - +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, + void *fill_data, int compress, const void *buf); /*------------------------------------------------------------------------- * @@ -49,45 +37,21 @@ H5_HLDLL herr_t H5TBmake_table( const char *table_title, *------------------------------------------------------------------------- */ -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 ); - -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 ); - - -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 ); - -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, - const void *buf ); +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); + +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); +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); + +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, + const void *buf); /*------------------------------------------------------------------------- * @@ -96,46 +60,21 @@ H5_HLDLL herr_t H5TBwrite_fields_index( hid_t 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); + +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); +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); -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 ); - - -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 ); - -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 ); - - -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 ); +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); /*------------------------------------------------------------------------- * @@ -144,19 +83,10 @@ H5_HLDLL herr_t H5TBread_records( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords); -H5_HLDLL herr_t H5TBget_table_info ( hid_t loc_id, - const char *dset_name, - hsize_t *nfields, - hsize_t *nrecords ); - -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 ); - +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); /*------------------------------------------------------------------------- * @@ -165,47 +95,22 @@ H5_HLDLL herr_t H5TBget_field_info( hid_t loc_id, *------------------------------------------------------------------------- */ +H5_HLDLL herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords); -H5_HLDLL herr_t H5TBdelete_record( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords ); - - -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 ); +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); -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 ); +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); -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 ); +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); -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 ); - -H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id, - const char *dset_name, - const char *field_name ); +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); +H5_HLDLL herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name); /*------------------------------------------------------------------------- * @@ -214,18 +119,12 @@ H5_HLDLL herr_t H5TBdelete_field( hid_t loc_id, *------------------------------------------------------------------------- */ -H5_HLDLL herr_t H5TBAget_title( hid_t loc_id, - char *table_title ); +H5_HLDLL herr_t H5TBAget_title(hid_t loc_id, char *table_title); -H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, - const char *dset_name, - hid_t dset_id, - unsigned char *dst_buf); +H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf); #ifdef __cplusplus } #endif - #endif - diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h index 3a7b8ee60f2..9960b97607d 100644 --- a/hl/src/hdf5_hl.h +++ b/hl/src/hdf5_hl.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,8 +17,9 @@ * fill this file with lots of gunk... */ -#ifndef _HDF5_HL_H -#define _HDF5_HL_H +#ifndef HDF5_HL_H +#define HDF5_HL_H + #include "hdf5.h" /* hdf5 main library */ #include "H5DOpublic.h" /* dataset optimization */ #include "H5DSpublic.h" /* dimension scales */ @@ -28,5 +29,4 @@ #include "H5PTpublic.h" /* packet table */ #include "H5LDpublic.h" /* lite dataset */ -#endif /*H5_INCLUDE_HL*/ - +#endif /*HDF5_HL_H*/ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a0479415d13..b3c22263923 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,6 +173,14 @@ set (H5EA_HDRS IDE_GENERATED_PROPERTIES ("H5EA" "${H5EA_HDRS}" "${H5EA_SOURCES}" ) +set (H5ES_SOURCES +) +set (H5ES_HDRS + ${HDF5_SRC_DIR}/H5ESpublic.h +) +IDE_GENERATED_PROPERTIES ("H5ES" "${H5ES_HDRS}" "${H5ES_SOURCES}" ) + + set (H5F_SOURCES ${HDF5_SRC_DIR}/H5F.c ${HDF5_SRC_DIR}/H5Faccum.c @@ -372,6 +380,8 @@ IDE_GENERATED_PROPERTIES ("H5HP" "${H5HP_HDRS}" "${H5HP_SOURCES}" ) set (H5I_SOURCES ${HDF5_SRC_DIR}/H5I.c + ${HDF5_SRC_DIR}/H5Idbg.c + ${HDF5_SRC_DIR}/H5Iint.c ${HDF5_SRC_DIR}/H5Itest.c ) set (H5I_HDRS @@ -382,6 +392,7 @@ IDE_GENERATED_PROPERTIES ("H5I" "${H5I_HDRS}" "${H5I_SOURCES}" ) set (H5L_SOURCES ${HDF5_SRC_DIR}/H5L.c + ${HDF5_SRC_DIR}/H5Ldeprec.c ${HDF5_SRC_DIR}/H5Lexternal.c ) set (H5L_HDRS @@ -390,6 +401,15 @@ set (H5L_HDRS IDE_GENERATED_PROPERTIES ("H5L" "${H5L_HDRS}" "${H5L_SOURCES}" ) +set (H5M_SOURCES + ${HDF5_SRC_DIR}/H5M.c +) +set (H5M_HDRS + ${HDF5_SRC_DIR}/H5Mpublic.h +) +IDE_GENERATED_PROPERTIES ("H5M" "${H5M_HDRS}" "${H5M_SOURCES}") + + set (H5MF_SOURCES ${HDF5_SRC_DIR}/H5MF.c ${HDF5_SRC_DIR}/H5MFaggr.c @@ -420,6 +440,7 @@ set (H5MP_HDRS ) IDE_GENERATED_PROPERTIES ("H5MP" "${H5MP_HDRS}" "${H5MP_SOURCES}" ) + set (H5O_SOURCES ${HDF5_SRC_DIR}/H5O.c ${HDF5_SRC_DIR}/H5Oainfo.c @@ -433,6 +454,7 @@ set (H5O_SOURCES ${HDF5_SRC_DIR}/H5Ochunk.c ${HDF5_SRC_DIR}/H5Ocont.c ${HDF5_SRC_DIR}/H5Ocopy.c + ${HDF5_SRC_DIR}/H5Ocopy_ref.c ${HDF5_SRC_DIR}/H5Odbg.c ${HDF5_SRC_DIR}/H5Odeprec.c ${HDF5_SRC_DIR}/H5Odrvinfo.c @@ -480,6 +502,8 @@ set (H5P_SOURCES ${HDF5_SRC_DIR}/H5Pint.c ${HDF5_SRC_DIR}/H5Plapl.c ${HDF5_SRC_DIR}/H5Plcpl.c + ${HDF5_SRC_DIR}/H5Pmapl.c + ${HDF5_SRC_DIR}/H5Pmcpl.c ${HDF5_SRC_DIR}/H5Pocpl.c ${HDF5_SRC_DIR}/H5Pocpypl.c ${HDF5_SRC_DIR}/H5Pstrcpl.c @@ -536,6 +560,7 @@ set (H5S_SOURCES ${HDF5_SRC_DIR}/H5S.c ${HDF5_SRC_DIR}/H5Sall.c ${HDF5_SRC_DIR}/H5Sdbg.c + ${HDF5_SRC_DIR}/H5Sdeprec.c ${HDF5_SRC_DIR}/H5Shyper.c ${HDF5_SRC_DIR}/H5Smpio.c ${HDF5_SRC_DIR}/H5Snone.c @@ -571,14 +596,6 @@ set (H5SM_HDRS IDE_GENERATED_PROPERTIES ("H5SM" "${H5SM_HDRS}" "${H5SM_SOURCES}" ) -set (H5ST_SOURCES - ${HDF5_SRC_DIR}/H5ST.c -) -set (H5ST_HDRS -) -IDE_GENERATED_PROPERTIES ("H5ST" "${H5ST_HDRS}" "${H5ST_SOURCES}" ) - - set (H5T_SOURCES ${HDF5_SRC_DIR}/H5T.c ${HDF5_SRC_DIR}/H5Tarray.c @@ -600,6 +617,7 @@ set (H5T_SOURCES ${HDF5_SRC_DIR}/H5Torder.c ${HDF5_SRC_DIR}/H5Tpad.c ${HDF5_SRC_DIR}/H5Tprecis.c + ${HDF5_SRC_DIR}/H5Tref.c ${HDF5_SRC_DIR}/H5Tstrpad.c ${HDF5_SRC_DIR}/H5Tvisit.c ${HDF5_SRC_DIR}/H5Tvlen.c @@ -627,6 +645,32 @@ set (H5UC_HDRS IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SOURCES}" ) +set (H5VL_SOURCES + ${HDF5_SRC_DIR}/H5VL.c + ${HDF5_SRC_DIR}/H5VLcallback.c + ${HDF5_SRC_DIR}/H5VLint.c + ${HDF5_SRC_DIR}/H5VLnative.c + ${HDF5_SRC_DIR}/H5VLnative_attr.c + ${HDF5_SRC_DIR}/H5VLnative_blob.c + ${HDF5_SRC_DIR}/H5VLnative_dataset.c + ${HDF5_SRC_DIR}/H5VLnative_datatype.c + ${HDF5_SRC_DIR}/H5VLnative_file.c + ${HDF5_SRC_DIR}/H5VLnative_group.c + ${HDF5_SRC_DIR}/H5VLnative_link.c + ${HDF5_SRC_DIR}/H5VLnative_introspect.c + ${HDF5_SRC_DIR}/H5VLnative_object.c + ${HDF5_SRC_DIR}/H5VLnative_token.c + ${HDF5_SRC_DIR}/H5VLpassthru.c +) +set (H5VL_HDRS + ${HDF5_SRC_DIR}/H5VLconnector.h + ${HDF5_SRC_DIR}/H5VLconnector_passthru.h + ${HDF5_SRC_DIR}/H5VLnative.h + ${HDF5_SRC_DIR}/H5VLpassthru.h + ${HDF5_SRC_DIR}/H5VLpublic.h +) +IDE_GENERATED_PROPERTIES ("H5VL" "${H5VL_HDRS}" "${H5VL_SOURCES}" ) + set (H5VM_SOURCES ${HDF5_SRC_DIR}/H5VM.c ) @@ -664,6 +708,45 @@ set (H5Z_HDRS ) IDE_GENERATED_PROPERTIES ("H5Z" "${H5Z_HDRS}" "${H5Z_SOURCES}" ) +set (H5_MODULE_HEADERS + ${HDF5_SRC_DIR}/H5module.h + ${HDF5_SRC_DIR}/H5Amodule.h + ${HDF5_SRC_DIR}/H5ACmodule.h + ${HDF5_SRC_DIR}/H5Bmodule.h + ${HDF5_SRC_DIR}/H5B2module.h + ${HDF5_SRC_DIR}/H5Cmodule.h + ${HDF5_SRC_DIR}/H5CXmodule.h + ${HDF5_SRC_DIR}/H5Dmodule.h + ${HDF5_SRC_DIR}/H5Emodule.h + ${HDF5_SRC_DIR}/H5EAmodule.h + ${HDF5_SRC_DIR}/H5Fmodule.h + ${HDF5_SRC_DIR}/H5FAmodule.h + ${HDF5_SRC_DIR}/H5FDdrvr_module.h + ${HDF5_SRC_DIR}/H5FDmodule.h + ${HDF5_SRC_DIR}/H5FLmodule.h + ${HDF5_SRC_DIR}/H5FSmodule.h + ${HDF5_SRC_DIR}/H5Gmodule.h + ${HDF5_SRC_DIR}/H5HFmodule.h + ${HDF5_SRC_DIR}/H5HGmodule.h + ${HDF5_SRC_DIR}/H5HLmodule.h + ${HDF5_SRC_DIR}/H5Imodule.h + ${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 + ${HDF5_SRC_DIR}/H5PLmodule.h + ${HDF5_SRC_DIR}/H5Rmodule.h + ${HDF5_SRC_DIR}/H5Smodule.h + ${HDF5_SRC_DIR}/H5SLmodule.h + ${HDF5_SRC_DIR}/H5SMmodule.h + ${HDF5_SRC_DIR}/H5Tmodule.h + ${HDF5_SRC_DIR}/H5VLmodule.h + ${HDF5_SRC_DIR}/H5Zmodule.h +) + set (common_SRCS ${H5_SOURCES} ${H5A_SOURCES} @@ -689,6 +772,7 @@ set (common_SRCS ${H5HP_SOURCES} ${H5I_SOURCES} ${H5L_SOURCES} + ${H5M_SOURCES} ${H5MF_SOURCES} ${H5MM_SOURCES} ${H5MP_SOURCES} @@ -702,9 +786,9 @@ set (common_SRCS ${H5S_SOURCES} ${H5SL_SOURCES} ${H5SM_SOURCES} - ${H5ST_SOURCES} ${H5T_SOURCES} ${H5TS_SOURCES} + ${H5VL_SOURCES} ${H5VM_SOURCES} ${H5WB_SOURCES} ${H5Z_SOURCES} @@ -720,6 +804,7 @@ set (H5_PUBLIC_HEADERS ${H5D_HDRS} ${H5E_HDRS} ${H5EA_HDRS} + ${H5ES_HDRS} ${H5F_HDRS} ${H5FA_HDRS} ${H5FD_HDRS} @@ -730,6 +815,7 @@ set (H5_PUBLIC_HEADERS ${H5HL_HDRS} ${H5I_HDRS} ${H5L_HDRS} + ${H5M_HDRS} ${H5MF_HDRS} ${H5MM_HDRS} ${H5MP_HDRS} @@ -741,6 +827,7 @@ set (H5_PUBLIC_HEADERS ${H5S_HDRS} ${H5SM_HDRS} ${H5T_HDRS} + ${H5VL_HDRS} ${H5Z_HDRS} ) @@ -816,6 +903,10 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Lpkg.h ${HDF5_SRC_DIR}/H5Lprivate.h + ${HDF5_SRC_DIR}/H5Mpkg.h + ${HDF5_SRC_DIR}/H5Mprivate.h + + ${HDF5_SRC_DIR}/H5MFpkg.h ${HDF5_SRC_DIR}/H5MFprivate.h ${HDF5_SRC_DIR}/H5MMprivate.h @@ -849,8 +940,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5SMpkg.h ${HDF5_SRC_DIR}/H5SMprivate.h - ${HDF5_SRC_DIR}/H5STprivate.h - ${HDF5_SRC_DIR}/H5Tpkg.h ${HDF5_SRC_DIR}/H5Tprivate.h @@ -858,6 +947,10 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5UCprivate.h + ${HDF5_SRC_DIR}/H5VLnative_private.h + ${HDF5_SRC_DIR}/H5VLpkg.h + ${HDF5_SRC_DIR}/H5VLprivate.h + ${HDF5_SRC_DIR}/H5VMprivate.h ${HDF5_SRC_DIR}/H5WBprivate.h @@ -866,6 +959,8 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Zprivate.h ${HDF5_SRC_DIR}/H5win32defs.h + + ${HDF5_SRC_DIR}/uthash.h ) set (H5_GENERATED_HEADERS @@ -886,8 +981,7 @@ set (H5_PUBLIC_GENERATED_HEADERS option (HDF5_GENERATE_HEADERS "Rebuild Generated Files" OFF) if (HDF5_GENERATE_HEADERS) set_source_files_properties(${H5_GENERATED_HEADERS} PROPERTIES GENERATED TRUE) - find_package (Perl) - if (PERL_FOUND) + if (H5_PERL_FOUND) execute_process ( COMMAND ${PERL_EXECUTABLE} ${HDF5_SOURCE_DIR}/bin/make_err ${HDF5_SRC_DIR}/H5err.txt OUTPUT_VARIABLE SCRIPT_OUTPUT ) @@ -901,7 +995,7 @@ if (HDF5_GENERATE_HEADERS) ) message(STATUS ${SCRIPT_OUTPUT}) else () - message (STATUS "Cannot generate headers - perl not found") + message (WARNING "Cannot generate headers - perl not found") endif () endif () @@ -912,11 +1006,11 @@ endif () if (HDF5_USE_PREGEN) set (HDF5_GENERATED_SOURCE_DIR ${HDF5_USE_PREGEN_DIR}) else () - set (HDF5_GENERATED_SOURCE_DIR ${HDF5_BINARY_DIR}) + set (HDF5_GENERATED_SOURCE_DIR ${HDF5_SRC_BINARY_DIR}) endif () if (BUILD_SHARED_LIBS) - file (MAKE_DIRECTORY "${HDF5_BINARY_DIR}/shared") + file (MAKE_DIRECTORY "${HDF5_SRC_BINARY_DIR}/shared") endif () if (LOCAL_BATCH_TEST) @@ -940,15 +1034,19 @@ if (LOCAL_BATCH_TEST) endif () endif () +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_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + 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> - PRIVATE $<$:"-O0"> ) + target_compile_options(H5detect + PRIVATE "$<$:-O0>" + ) + set (lib_prog_deps ${lib_prog_deps} H5detect) if (HDF5_BATCH_H5DETECT) configure_file ( @@ -956,113 +1054,122 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} ESCAPE_QUOTES @ONLY ) add_custom_command ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c - ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 - COMMAND ${HDF5_BATCH_CMD} - ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} - COMMAND ${CMAKE_COMMAND} - ARGS -E echo "Executed batch command to create H5Tinit.c" + OUTPUT gen_SRCS.stamp1 + 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} - ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + ARGS -E touch gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} ) add_custom_target (gen_H5Tinit COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake ) - if (BUILD_SHARED_LIBS) - add_custom_command ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c - ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" - COMMAND ${CMAKE_COMMAND} - ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 - DEPENDS gen_H5Tinit ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit_created - WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} - ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) - endif () + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) else () - add_custom_command ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c - ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ - ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + add_custom_command (TARGET H5detect POST_BUILD + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ + ARGS H5Tinit.c + BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} - ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + 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 ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c - ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + add_custom_command (TARGET H5detect POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + 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 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 - DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ARGS -E touch shared/shared_gen_SRCS.stamp1 + DEPENDS H5detect H5Tinit.c 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 () - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) else () add_custom_command ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + OUTPUT gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} - ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 - DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ARGS -E touch gen_SRCS.stamp1 + DEPENDS H5Tinit.c WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + COMMENT "Touch existing H5Tinit.c" ) + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) add_custom_command ( - OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + OUTPUT shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + 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 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 - DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ARGS -E touch shared/shared_gen_SRCS.stamp1 + DEPENDS H5Tinit.c 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 () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c) +endif () + add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) -target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${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 $<$:"-O0"> ) +target_compile_options(H5make_libsettings + PRIVATE "$<$:-O0>" +) +set (lib_prog_deps ${lib_prog_deps} H5make_libsettings) -add_custom_command ( - OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c - ${HDF5_BINARY_DIR}/gen_SRCS.stamp2 - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ - ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings) +endif () + +add_custom_command (TARGET H5make_libsettings POST_BUILD + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ + ARGS H5lib_settings.c + BYPRODUCTS H5lib_settings.c gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} - ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2 + ARGS -E touch gen_SRCS.stamp2 DEPENDS H5make_libsettings - WORKING_DIRECTORY ${HDF5_BINARY_DIR} + WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR} + COMMENT "Create H5lib_settings.c" ) -set_source_files_properties (${HDF5_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE) +set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command ( - OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c - ${HDF5_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 + add_custom_command (TARGET H5make_libsettings POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different "${HDF5_BINARY_DIR}/H5lib_settings.c" "${HDF5_BINARY_DIR}/shared/H5lib_settings.c" + 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 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2 - DEPENDS ${HDF5_BINARY_DIR}/H5lib_settings.c - WORKING_DIRECTORY ${HDF5_BINARY_DIR} + ARGS -E touch shared/shared_gen_SRCS.stamp2 + DEPENDS H5make_libsettings H5lib_settings.c + WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR} + COMMENT "Copy H5lib_settings.c to shared folder" ) - set_source_files_properties (${HDF5_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE) + 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" @@ -1073,13 +1180,16 @@ 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) - set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) - add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2) + 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 + COMMENT "Generation target files" + ) - add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) + 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_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" - INTERFACE "$/include>;$" + PRIVATE "${HDF5_SRC_DIR};${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} @@ -1088,7 +1198,7 @@ if (NOT ONLY_SHARED_LIBS) ${HDF_EXTRA_FLAGS} PRIVATE $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> ) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC) target_link_libraries (${HDF5_LIB_TARGET} @@ -1109,14 +1219,17 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) - set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) - add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2) + 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 + 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}) + 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_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_DIR};${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} @@ -1127,7 +1240,7 @@ if (BUILD_SHARED_LIBS) PRIVATE $<$:H5_HAVE_THREADSAFE> $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> ) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_LIBSH_TARGET} @@ -1142,6 +1255,17 @@ if (BUILD_SHARED_LIBS) set (install_targets ${install_targets} ${HDF5_LIBSH_TARGET}) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_SRC_FORMAT ${HDF5_LIB_TARGET}) + else () + clang_format (HDF5_SRC_FORMAT ${HDF5_LIBSH_TARGET}) + endif () +endif () + #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- @@ -1150,7 +1274,7 @@ if (NOT HDF5_INSTALL_NO_DEVELOPMENT) FILES ${H5_PUBLIC_HEADERS} ${H5_PUBLIC_GENERATED_HEADERS} - ${HDF5_BINARY_DIR}/H5pubconf.h + ${HDF5_SRC_BINARY_DIR}/H5pubconf.h DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} COMPONENT @@ -1207,18 +1331,22 @@ set (_PKG_CONFIG_REQUIRES) set (_PKG_CONFIG_REQUIRES_PRIVATE) configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.pc.in - ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + ${HDF_CONFIG_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}.pc @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}.pc DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig COMPONENT libraries ) if (NOT WIN32) - set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND) + set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER}) + else () + set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + endif () configure_file ( ${HDF_RESOURCES_DIR}/libh5cc.in ${HDF5_BINARY_DIR}/CMakeFiles/h5cc @@ -1230,4 +1358,75 @@ if (NOT WIN32) PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT libraries ) + if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND) + #legacy requires a different name + configure_file ( + ${HDF_RESOURCES_DIR}/libh5cc.in + ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc + @ONLY + ) + install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc + DESTINATION ${HDF5_INSTALL_BIN_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT libraries + ) + endif () +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 + # 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) + endif () + + add_dependencies (doxygen hdf5lib_doc) + endif () diff --git a/src/COPYING b/src/COPYING deleted file mode 100644 index 6497ace3da0..00000000000 --- a/src/COPYING +++ /dev/null @@ -1,13 +0,0 @@ - - Copyright by The HDF Group and - The Board of Trustees of the University of Illinois. - All rights reserved. - - The files and subdirectories in this directory are 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://support.hdfgroup.org/ftp/HDF5/releases. If you do - not have access to either file, you may request a copy from - help@hdfgroup.org. - diff --git a/src/H5.c b/src/H5.c index 6d3c33583cc..572e5e58f37 100644 --- a/src/H5.c +++ b/src/H5.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,43 +14,40 @@ /****************/ /* Module Setup */ /****************/ - +#include "H5module.h" /* This source code file is part of the H5 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static void H5__debug_mask(const char*); +static void H5__debug_mask(const char *); #ifdef H5_HAVE_PARALLEL static int H5__mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *flag); #endif /*H5_HAVE_PARALLEL*/ @@ -59,6 +56,8 @@ static int H5__mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *fla /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; /*****************************/ /* Library Private Variables */ @@ -73,23 +72,48 @@ hbool_t H5_api_entered_g = FALSE; #ifdef H5_HAVE_THREADSAFE H5_api_t H5_g; #else -hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ -hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */ +hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */ +hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */ #endif #ifdef H5_HAVE_MPE -hbool_t H5_MPEinit_g = FALSE; /* MPE Library hasn't been initialized */ +hbool_t H5_MPEinit_g = FALSE; /* MPE Library hasn't been initialized */ #endif -char H5_lib_vers_info_g[] = H5_VERS_INFO; -static hbool_t H5_dont_atexit_g = FALSE; -H5_debug_t H5_debug_g; /* debugging info */ - +char H5_lib_vers_info_g[] = H5_VERS_INFO; +static hbool_t H5_dont_atexit_g = FALSE; +H5_debug_t H5_debug_g; /* debugging info */ /*******************/ /* Local Variables */ /*******************/ +/*-------------------------------------------------------------------------- +NAME + H5__init_package -- Initialize interface-specific information +USAGE + herr_t H5__init_package() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. +--------------------------------------------------------------------------*/ +herr_t +H5__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Run the library initialization routine, if it hasn't already ran */ + if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { + if (H5_init_library() < 0) + HGOTO_ERROR(H5E_LIB, H5E_CANTINIT, FAIL, "unable to initialize library") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5__init_package() */ /*-------------------------------------------------------------------------- * NAME @@ -110,16 +134,21 @@ H5_init_library(void) { herr_t ret_value = SUCCEED; + /* Set the 'library initialized' flag as early as possible, to avoid + * possible re-entrancy. + */ + H5_INIT_GLOBAL = TRUE; + FUNC_ENTER_NOAPI(FAIL) #ifdef H5_HAVE_PARALLEL { - int mpi_initialized; - int mpi_finalized; + int mpi_initialized; + int mpi_finalized; int mpi_code; - MPI_Initialized(&mpi_initialized); - MPI_Finalized(&mpi_finalized); + MPI_Initialized(&mpi_initialized); + MPI_Finalized(&mpi_finalized); #ifdef H5_HAVE_MPE /* Initialize MPE instrumentation library. */ @@ -127,7 +156,7 @@ H5_init_library(void) int mpe_code; if (mpi_initialized && !mpi_finalized) { mpe_code = MPE_Init_log(); - HDassert(mpe_code >=0); + HDassert(mpe_code >= 0); H5_MPEinit_g = TRUE; } } @@ -138,15 +167,15 @@ H5_init_library(void) if (mpi_initialized && !mpi_finalized) { int key_val; - if(MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, - (MPI_Comm_delete_attr_function *)H5__mpi_delete_cb, - &key_val, NULL))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_create_keyval( + MPI_COMM_NULL_COPY_FN, (MPI_Comm_delete_attr_function *)H5__mpi_delete_cb, + &key_val, NULL))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_create_keyval failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Comm_set_attr(MPI_COMM_SELF, key_val, NULL))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_attr(MPI_COMM_SELF, key_val, NULL))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_set_attr failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Comm_free_keyval(&key_val))) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_free_keyval(&key_val))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_free_keyval failed", mpi_code) } } @@ -156,24 +185,26 @@ H5_init_library(void) * Make sure the package information is updated. */ HDmemset(&H5_debug_g, 0, sizeof H5_debug_g); - H5_debug_g.pkg[H5_PKG_A].name = "a"; + H5_debug_g.pkg[H5_PKG_A].name = "a"; H5_debug_g.pkg[H5_PKG_AC].name = "ac"; - H5_debug_g.pkg[H5_PKG_B].name = "b"; - H5_debug_g.pkg[H5_PKG_D].name = "d"; - H5_debug_g.pkg[H5_PKG_E].name = "e"; - H5_debug_g.pkg[H5_PKG_F].name = "f"; - H5_debug_g.pkg[H5_PKG_G].name = "g"; + H5_debug_g.pkg[H5_PKG_B].name = "b"; + H5_debug_g.pkg[H5_PKG_D].name = "d"; + H5_debug_g.pkg[H5_PKG_E].name = "e"; + H5_debug_g.pkg[H5_PKG_F].name = "f"; + H5_debug_g.pkg[H5_PKG_G].name = "g"; H5_debug_g.pkg[H5_PKG_HG].name = "hg"; H5_debug_g.pkg[H5_PKG_HL].name = "hl"; - H5_debug_g.pkg[H5_PKG_I].name = "i"; + H5_debug_g.pkg[H5_PKG_I].name = "i"; + H5_debug_g.pkg[H5_PKG_M].name = "m"; H5_debug_g.pkg[H5_PKG_MF].name = "mf"; H5_debug_g.pkg[H5_PKG_MM].name = "mm"; - H5_debug_g.pkg[H5_PKG_O].name = "o"; - H5_debug_g.pkg[H5_PKG_P].name = "p"; - H5_debug_g.pkg[H5_PKG_S].name = "s"; - H5_debug_g.pkg[H5_PKG_T].name = "t"; - H5_debug_g.pkg[H5_PKG_V].name = "v"; - H5_debug_g.pkg[H5_PKG_Z].name = "z"; + H5_debug_g.pkg[H5_PKG_O].name = "o"; + H5_debug_g.pkg[H5_PKG_P].name = "p"; + H5_debug_g.pkg[H5_PKG_S].name = "s"; + H5_debug_g.pkg[H5_PKG_T].name = "t"; + H5_debug_g.pkg[H5_PKG_V].name = "v"; + H5_debug_g.pkg[H5_PKG_VL].name = "vl"; + H5_debug_g.pkg[H5_PKG_Z].name = "z"; /* * Install atexit() library cleanup routines unless the H5dont_atexit() @@ -188,7 +219,7 @@ H5_init_library(void) * This must be entered before the library cleanup code so it's * executed in LIFO order (i.e., last). */ - (void)HDatexit(H5TS_win32_process_exit); + (void)HDatexit(H5TS_win32_process_exit); #endif /* H5_HAVE_THREADSAFE && H5_HAVE_WIN_THREADS */ /* Normal library termination code */ @@ -211,21 +242,23 @@ H5_init_library(void) * When the application does not close the file, routines in the module might * be called via H5_term_library() when shutting down the file. */ - if(H5E_init() < 0) + if (H5E_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") - if(H5P_init() < 0) + if (H5VL_init_phase1() < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") + if (H5P_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if(H5T_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") - if(H5D_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") - if(H5AC_init() < 0) + if (H5AC_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") - if(H5L_init() < 0) + if (H5L_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize link interface") - if(H5FS_init() < 0) + if (H5FS_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface") + /* Finish initializing interfaces that depend on the interfaces above */ + if (H5VL_init_phase2() < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") + /* Debugging? */ H5__debug_mask("-all"); H5__debug_mask(HDgetenv("HDF5_DEBUG")); @@ -234,7 +267,6 @@ H5_init_library(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_init_library() */ - /*------------------------------------------------------------------------- * Function: H5_term_library * @@ -249,9 +281,9 @@ H5_init_library(void) void H5_term_library(void) { - int pending, ntries = 0, n; - size_t at = 0; - char loop[1024]; + int pending, ntries = 0, n; + size_t at = 0; + char loop[1024]; H5E_auto2_t func; #ifdef H5_HAVE_THREADSAFE @@ -261,7 +293,7 @@ H5_term_library(void) #endif /* Don't do anything if the library is already closed */ - if(!(H5_INIT_GLOBAL)) + if (!(H5_INIT_GLOBAL)) goto done; /* Indicate that the library is being shut down */ @@ -278,15 +310,11 @@ H5_term_library(void) * value if they do something that might affect some other interface in a * way that would necessitate some cleanup work in the other interface. */ -#define DOWN(F) \ - (((n = H5##F##_term_package()) && (at + 8) < sizeof loop)? \ - (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), \ - at += HDstrlen(loop + at), \ - n): \ - ((n > 0 && (at + 5) < sizeof loop) ? \ - (HDsprintf(loop + at, "..."), \ - at += HDstrlen(loop + at), \ - n) : n)) +#define DOWN(F) \ + (((n = H5##F##_term_package()) && (at + 8) < sizeof loop) \ + ? (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), at += HDstrlen(loop + at), n) \ + : ((n > 0 && (at + 5) < sizeof loop) ? (HDsprintf(loop + at, "..."), at += HDstrlen(loop + at), n) \ + : n)) do { pending = 0; @@ -305,24 +333,25 @@ H5_term_library(void) pending += DOWN(A_top); pending += DOWN(D_top); pending += DOWN(G_top); + pending += DOWN(M_top); pending += DOWN(R_top); pending += DOWN(S_top); pending += DOWN(T_top); /* Don't shut down the file code until objects in files are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(F); /* Don't shut down the property list code until all objects that might * use property lists are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(P); /* Wait to shut down the "bottom" of various interfaces until the * files are closed, so pieces of the file can be serialized * correctly. */ - if(pending == 0) { + if (pending == 0) { /* Shut down the "bottom" of the attribute, dataset, group, * reference, dataspace, and datatype interfaces, fully closing * out the interfaces now. @@ -330,6 +359,7 @@ H5_term_library(void) pending += DOWN(A); pending += DOWN(D); pending += DOWN(G); + pending += DOWN(M); pending += DOWN(R); pending += DOWN(S); pending += DOWN(T); @@ -340,47 +370,49 @@ H5_term_library(void) * from being closed "out from underneath" of the high-level objects * that depend on them. -QAK */ - if(pending == 0) { + if (pending == 0) { pending += DOWN(AC); + /* Shut down the "pluggable" interfaces, before the plugin framework */ pending += DOWN(Z); pending += DOWN(FD); + pending += DOWN(VL); /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(E); /* Don't shut down the ID code until other APIs which use them are shut down */ - if(pending == 0) + if (pending == 0) pending += DOWN(I); /* Don't shut down the skip list code until everything that uses it is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(SL); /* Don't shut down the free list code until everything that uses it is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(FL); /* Don't shut down the API context code until _everything_ else is down */ - if(pending == 0) + if (pending == 0) pending += DOWN(CX); } /* end if */ - } while(pending && ntries++ < 100); + } while (pending && ntries++ < 100); - if(pending) { + if (pending) { /* Only display the error message if the user is interested in them. */ - if(func) { + if (func) { HDfprintf(stderr, "HDF5: infinite loop closing library\n"); HDfprintf(stderr, " %s\n", loop); #ifndef NDEBUG HDabort(); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end if */ - } /* end if */ + } /* end if */ #ifdef H5_HAVE_MPE /* Close MPE instrumentation library. May need to move this * down if any of the below code involves using the instrumentation code. */ - if(H5_MPEinit_g) { + if (H5_MPEinit_g) { int mpi_initialized; int mpi_finalized; int mpe_code; @@ -390,15 +422,15 @@ H5_term_library(void) if (mpi_initialized && !mpi_finalized) { mpe_code = MPE_Finish_log("h5log"); - HDassert(mpe_code >=0); - } /* end if */ - H5_MPEinit_g = FALSE; /* turn it off no matter what */ - } /* end if */ + HDassert(mpe_code >= 0); + } /* end if */ + H5_MPEinit_g = FALSE; /* turn it off no matter what */ + } /* end if */ #endif /* Free open debugging streams */ - while(H5_debug_g.open_stream) { - H5_debug_open_stream_t *tmp_open_stream; + while (H5_debug_g.open_stream) { + H5_debug_open_stream_t *tmp_open_stream; tmp_open_stream = H5_debug_g.open_stream; (void)HDfclose(H5_debug_g.open_stream->stream); @@ -427,7 +459,6 @@ H5_term_library(void) return; } /* end H5_term_library() */ - /*------------------------------------------------------------------------- * Function: H5dont_atexit * @@ -451,12 +482,12 @@ H5_term_library(void) herr_t H5dont_atexit(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS - H5TRACE0("e",""); + H5TRACE0("e", ""); - if(H5_dont_atexit_g) + if (H5_dont_atexit_g) ret_value = FAIL; else H5_dont_atexit_g = TRUE; @@ -464,7 +495,6 @@ H5dont_atexit(void) FUNC_LEAVE_API_NOFS(ret_value) } /* end H5dont_atexit() */ - /*------------------------------------------------------------------------- * Function: H5garbage_collect * @@ -485,20 +515,19 @@ H5dont_atexit(void) herr_t H5garbage_collect(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE0("e",""); + H5TRACE0("e", ""); /* Call the garbage collection routines in the library */ - if(H5FL_garbage_coll()<0) + if (H5FL_garbage_coll() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect objects") done: FUNC_LEAVE_API(ret_value) -} /* end H5garbage_collect() */ +} /* end H5garbage_collect() */ - /*------------------------------------------------------------------------- * Function: H5set_free_list_limits * @@ -527,25 +556,24 @@ H5garbage_collect(void) *------------------------------------------------------------------------- */ herr_t -H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, - int arr_list_lim, int blk_global_lim, int blk_list_lim) +H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE6("e", "IsIsIsIsIsIs", reg_global_lim, reg_list_lim, arr_global_lim, - arr_list_lim, blk_global_lim, blk_list_lim); + H5TRACE6("e", "IsIsIsIsIsIs", reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, + blk_list_lim); /* Call the free list function to actually set the limits */ - if(H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, - blk_global_lim, blk_list_lim, blk_global_lim, blk_list_lim)<0) + if (H5FL_set_free_list_limits(reg_global_lim, reg_list_lim, arr_global_lim, arr_list_lim, blk_global_lim, + blk_list_lim, blk_global_lim, blk_list_lim) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSET, FAIL, "can't set garbage collection limits") done: FUNC_LEAVE_API(ret_value) -} /* end H5set_free_list_limits() */ +} /* end H5set_free_list_limits() */ - /*------------------------------------------------------------------------- * Function: H5get_free_list_sizes * @@ -569,23 +597,21 @@ 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, size_t *arr_size, size_t *blk_size, size_t *fac_size) { - herr_t ret_value = SUCCEED; /* Return value */ + 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); /* 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) + if (H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get garbage collection sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5get_free_list_sizes() */ +} /* end H5get_free_list_sizes() */ - /*------------------------------------------------------------------------- * Function: H5get_alloc_stats * @@ -613,20 +639,19 @@ H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, herr_t H5get_alloc_stats(H5_alloc_stats_t *stats) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", stats); /* Call the internal allocation stat routine to get the values */ - if(H5MM_get_alloc_stats(stats) < 0) + if (H5MM_get_alloc_stats(stats) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get allocation stats") done: FUNC_LEAVE_API(ret_value) -} /* end H5get_alloc_stats() */ +} /* end H5get_alloc_stats() */ - /*------------------------------------------------------------------------- * Function: H5__debug_mask * @@ -653,84 +678,89 @@ H5get_alloc_stats(H5_alloc_stats_t *stats) static void H5__debug_mask(const char *s) { - FILE *stream = stderr; - char pkg_name[32], *rest; - size_t i; - hbool_t clear; + FILE * stream = stderr; + char pkg_name[32], *rest; + size_t i; + hbool_t clear; while (s && *s) { - if (HDisalpha(*s) || '-'==*s || '+'==*s) { + if (HDisalpha(*s) || '-' == *s || '+' == *s) { /* Enable or Disable debugging? */ - if ('-'==*s) { + if ('-' == *s) { clear = TRUE; s++; - } else if ('+'==*s) { + } + else if ('+' == *s) { clear = FALSE; s++; - } else { + } + else { clear = FALSE; } /* end if */ /* Get the name */ - for (i=0; HDisalpha(*s); i++, s++) - if (i=(size_t)H5_NPKGS) + } /* end if */ + } /* end for */ + if (i >= (size_t)H5_NPKGS) HDfprintf(stderr, "HDF5_DEBUG: ignored %s\n", pkg_name); } /* end if-else */ - - } else if (HDisdigit(*s)) { - int fd = (int)HDstrtol(s, &rest, 0); + } + else if (HDisdigit(*s)) { + int fd = (int)HDstrtol(s, &rest, 0); H5_debug_open_stream_t *open_stream; - if((stream = HDfdopen(fd, "w")) != NULL) { + if ((stream = HDfdopen(fd, "w")) != NULL) { (void)HDsetvbuf(stream, NULL, _IOLBF, (size_t)0); - if(NULL == (open_stream = (H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) { + if (NULL == + (open_stream = (H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) { (void)HDfclose(stream); return; } /* end if */ - open_stream->stream = stream; - open_stream->next = H5_debug_g.open_stream; + open_stream->stream = stream; + open_stream->next = H5_debug_g.open_stream; H5_debug_g.open_stream = open_stream; } /* end if */ s = rest; - } else { + } + else { s++; } /* end if-else */ - } /* end while */ - - return; - + } /* end while */ } /* end H5__debug_mask() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5__mpi_delete_cb * @@ -741,14 +771,15 @@ H5__debug_mask(const char *s) * *------------------------------------------------------------------------- */ -static int H5__mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void H5_ATTR_UNUSED *attr_val, int H5_ATTR_UNUSED *flag) +static int +H5__mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void H5_ATTR_UNUSED *attr_val, + int H5_ATTR_UNUSED *flag) { H5_term_library(); return MPI_SUCCESS; } #endif /*H5_HAVE_PARALLEL*/ - /*------------------------------------------------------------------------- * Function: H5get_libversion * @@ -768,21 +799,23 @@ static int H5__mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED ke herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "*Iu*Iu*Iu", majnum, minnum, relnum); /* Set the version information */ - if (majnum) *majnum = H5_VERS_MAJOR; - if (minnum) *minnum = H5_VERS_MINOR; - if (relnum) *relnum = H5_VERS_RELEASE; + if (majnum) + *majnum = H5_VERS_MAJOR; + if (minnum) + *minnum = H5_VERS_MINOR; + if (relnum) + *relnum = H5_VERS_RELEASE; done: FUNC_LEAVE_API(ret_value) } /* end H5get_libversion() */ - /*------------------------------------------------------------------------- * Function: H5check_version * @@ -798,78 +831,76 @@ H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) * *------------------------------------------------------------------------- */ -#define VERSION_MISMATCH_WARNING \ - "Warning! ***HDF5 library version mismatched error***\n" \ - "The HDF5 header files used to compile this application do not match\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 a different version of static or shared HDF5 library.\n" \ - "You should recompile the application or check your shared library related\n" \ +#define VERSION_MISMATCH_WARNING \ + "Warning! ***HDF5 library version mismatched error***\n" \ + "The HDF5 header files used to compile this application do not match\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 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" herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) { - char lib_str[256]; - 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; - herr_t ret_value = SUCCEED; /* Return value */ + char lib_str[256]; + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); /* Don't check again, if we already have */ if (checked) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED) - { const char *s; /* Environment string for disabling version check */ + { + const char *s; /* Environment string for disabling version check */ /* Allow different versions of the header files and library? */ - s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); + s = HDgetenv("HDF5_DISABLE_VERSION_CHECK"); if (s && HDisdigit(*s)) - disable_version_check = (unsigned int)HDstrtol (s, NULL, 0); + disable_version_check = (unsigned int)HDstrtol(s, NULL, 0); } - if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || - H5_VERS_RELEASE!=relnum) { + if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE != relnum) { switch (disable_version_check) { - case 0: - HDfprintf(stderr, "%s%s", version_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); - /* Show library settings if available */ - HDfprintf (stderr, "%s", H5libhdf5_settings); - - /* 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", - version_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); - /* Show library settings if available */ - HDfprintf (stderr, "%s", H5libhdf5_settings); - break; - default: - /* 2 or higher: continue silently */ - break; + case 0: + HDfprintf(stderr, "%s%s", version_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); + /* Show library settings if available */ + HDfprintf(stderr, "%s", H5libhdf5_settings); + + /* 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", + version_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); + /* Show library settings if available */ + HDfprintf(stderr, "%s", H5libhdf5_settings); + break; + default: + /* 2 or higher: continue silently */ + break; } /* end switch */ } /* end if */ @@ -877,39 +908,38 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Indicate that the version check has been performed */ checked = 1; - if (!disable_version_check){ - /* - * Verify if H5_VERS_INFO is consistent with the other version information. - * 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 */ - if (HDstrcmp(lib_str, H5_lib_vers_info_g)){ - HDfputs ("Warning! Library version information error.\n" - "The HDF5 library version information are not " - "consistent in its source code.\nThis is NOT a fatal error " - "but should be corrected. Setting the environment\n" - "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of 1 " - "will suppress\nthis warning.\n", - stderr); - HDfprintf (stderr, "Library version information are:\n" - "H5_VERS_MAJOR=%d, H5_VERS_MINOR=%d, H5_VERS_RELEASE=%d, " - "H5_VERS_SUBRELEASE=%s,\nH5_VERS_INFO=%s\n", - H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, - H5_VERS_SUBRELEASE, H5_VERS_INFO); - } /* end if */ + if (!disable_version_check) { + /* + * Verify if H5_VERS_INFO is consistent with the other version information. + * 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 */ + if (HDstrcmp(lib_str, H5_lib_vers_info_g) != 0) { + HDfputs("Warning! Library version information error.\n" + "The HDF5 library version information are not " + "consistent in its source code.\nThis is NOT a fatal error " + "but should be corrected. Setting the environment\n" + "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of 1 " + "will suppress\nthis warning.\n", + stderr); + HDfprintf(stderr, + "Library version information are:\n" + "H5_VERS_MAJOR=%d, H5_VERS_MINOR=%d, H5_VERS_RELEASE=%d, " + "H5_VERS_SUBRELEASE=%s,\nH5_VERS_INFO=%s\n", + H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, H5_VERS_SUBRELEASE, H5_VERS_INFO); + } /* end if */ } done: FUNC_LEAVE_API_NOFS(ret_value) } /* end H5check_version() */ - /*------------------------------------------------------------------------- * Function: H5open * @@ -925,7 +955,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) herr_t H5open(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOPUSH(FAIL) /*NO TRACE*/ @@ -936,7 +966,6 @@ H5open(void) FUNC_LEAVE_API_NOPUSH(ret_value) } /* end H5open() */ - /*------------------------------------------------------------------------- * Function: H5close * @@ -955,14 +984,13 @@ H5close(void) * this function for an uninitialized library. */ FUNC_ENTER_API_NOINIT_NOERR_NOFS - H5TRACE0("e",""); + H5TRACE0("e", ""); H5_term_library(); FUNC_LEAVE_API_NOFS(SUCCEED) } /* end H5close() */ - /*------------------------------------------------------------------------- * Function: H5allocate_memory * @@ -995,7 +1023,7 @@ H5allocate_memory(size_t size, hbool_t clear) FUNC_ENTER_API_NOINIT H5TRACE2("*x", "zb", size, clear); - if(clear) + if (clear) ret_value = H5MM_calloc(size); else ret_value = H5MM_malloc(size); @@ -1003,7 +1031,6 @@ H5allocate_memory(size_t size, hbool_t clear) FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5allocate_memory() */ - /*------------------------------------------------------------------------- * Function: H5resize_memory * @@ -1041,7 +1068,6 @@ H5resize_memory(void *mem, size_t size) FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5resize_memory() */ - /*------------------------------------------------------------------------- * Function: H5free_memory * @@ -1066,7 +1092,6 @@ H5free_memory(void *mem) FUNC_LEAVE_API_NOINIT(SUCCEED) } /* end H5free_memory() */ - /*------------------------------------------------------------------------- * Function: H5is_library_threadsafe * @@ -1088,16 +1113,15 @@ H5is_library_threadsafe(hbool_t *is_ts) /* At this time, it is impossible for this to fail. */ #ifdef H5_HAVE_THREADSAFE *is_ts = TRUE; -#else /* H5_HAVE_THREADSAFE */ +#else /* H5_HAVE_THREADSAFE */ *is_ts = FALSE; #endif /* H5_HAVE_THREADSAFE */ FUNC_LEAVE_API_NOINIT(SUCCEED) } /* end H5is_library_threadsafe() */ - -#if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) \ - && defined(H5_HAVE_WIN32_API) && defined(H5_HAVE_WIN_THREADS) +#if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) && defined(H5_HAVE_WIN32_API) && \ + defined(H5_HAVE_WIN_THREADS) /*------------------------------------------------------------------------- * Function: DllMain * @@ -1125,35 +1149,33 @@ DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) BOOL fOkay = TRUE; - switch(fdwReason) - { - case DLL_PROCESS_ATTACH: - break; + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + break; - case DLL_PROCESS_DETACH: - break; + case DLL_PROCESS_DETACH: + break; - case DLL_THREAD_ATTACH: + case DLL_THREAD_ATTACH: #ifdef H5_HAVE_WIN_THREADS - if(H5TS_win32_thread_enter() < 0) - fOkay = FALSE; + if (H5TS_win32_thread_enter() < 0) + fOkay = FALSE; #endif /* H5_HAVE_WIN_THREADS */ - break; + break; - case DLL_THREAD_DETACH: + case DLL_THREAD_DETACH: #ifdef H5_HAVE_WIN_THREADS - if(H5TS_win32_thread_exit() < 0) - fOkay = FALSE; + if (H5TS_win32_thread_exit() < 0) + fOkay = FALSE; #endif /* H5_HAVE_WIN_THREADS */ - break; + break; - default: - /* Shouldn't get here */ - fOkay = FALSE; - break; + default: + /* Shouldn't get here */ + fOkay = FALSE; + break; } return fOkay; } #endif /* H5_HAVE_WIN32_API && H5_BUILT_AS_DYNAMIC_LIB && H5_HAVE_WIN_THREADS && H5_HAVE_THREADSAFE*/ - diff --git a/src/H5A.c b/src/H5A.c index b93cd8bce0a..3d20f83701b 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,29 +15,27 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /* Suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -46,20 +44,17 @@ /* Data structure for callback for locating the index by name */ typedef struct H5A_iter_cb1 { const char *name; - int idx; + int idx; } H5A_iter_cb1; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -67,12 +62,10 @@ typedef struct H5A_iter_cb1 { /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -88,17 +81,37 @@ H5FL_BLK_DEFINE(attr_buf); /* Attribute ID class */ static const H5I_class_t H5I_ATTR_CLS[1] = {{ - H5I_ATTR, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ + H5I_ATTR, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5A_top_package_initialize_s = FALSE; +/*------------------------------------------------------------------------- + * Function: H5A_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5A_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_init() */ - /*-------------------------------------------------------------------------- NAME H5A__init_package -- Initialize interface-specific information @@ -114,14 +127,14 @@ DESCRIPTION herr_t H5A__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* * Create attribute ID type. */ - if(H5I_register_type(H5I_ATTR_CLS) < 0) + if (H5I_register_type(H5I_ATTR_CLS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ @@ -131,7 +144,6 @@ H5A__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__init_package() */ - /*-------------------------------------------------------------------------- NAME H5A_top_term_package @@ -152,25 +164,24 @@ H5A__init_package(void) int H5A_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5A_top_package_initialize_s) { - if(H5I_nmembers(H5I_ATTR) > 0) { - (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); + if (H5A_top_package_initialize_s) { + if (H5I_nmembers(H5I_ATTR) > 0) { + (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5A_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5A_term_package @@ -193,11 +204,11 @@ H5A_top_term_package(void) int H5A_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_ATTR)); HDassert(FALSE == H5A_top_package_initialize_s); @@ -206,14 +217,13 @@ H5A_term_package(void) n += (H5I_dec_type_ref(H5I_ATTR) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_term_package() */ - /*-------------------------------------------------------------------------- * Function: H5Acreate2 * @@ -248,56 +258,58 @@ 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) +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) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") - if(!attr_name) + if (!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be NULL") - if(!*attr_name) + if (!*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be an empty string") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") + + /* Get correct property list */ + if (H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the attribute */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ - /*-------------------------------------------------------------------------- NAME H5Acreate_by_name @@ -329,64 +341,63 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, --------------------------------------------------------------------------*/ 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) +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) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, - acpl_id, aapl_id, lapl_id); + H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") + + /* Get correct property list */ + if (H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") - if(H5P_DEFAULT != lapl_id) { - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link access property list ID") - H5CX_set_lapl(lapl_id); - } /* end if */ + /* Set up location struct */ + 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; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the attribute */ - if(NULL == (attr = H5A__create_by_name(&loc, obj_name, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, type_id, space_id, acpl_id, aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen @@ -409,45 +420,52 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value = H5I_INVALID_HID; + 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; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!attr_name) + if (!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*attr_name) + if (!*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", attr_name) /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_by_name @@ -461,7 +479,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) hid_t aapl_id; IN: Attribute access property list hid_t lapl_id; IN: Link access property list RETURNS - ID of attribute on success, negative on failure + ID of attribute on success, H5I_INVALID_HID on failure DESCRIPTION This function opens an existing attribute for access. The attribute @@ -470,54 +488,58 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ 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) +H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value; + 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; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*s*sii", loc_id, obj_name, attr_name, aapl_id, lapl_id); - /* 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(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + /* Check arguments */ + if (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + if (!obj_name || !*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") + if (!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") - if(H5P_DEFAULT != lapl_id) { - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - H5CX_set_lapl(lapl_id); - } /* end if */ + /* Fill in location struct fields */ + 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; + loc_params.obj_type = H5I_get_type(loc_id); - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Open the attribute */ + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) -} /* H5Aopen_by_name() */ +} /* end H5Aopen_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_by_idx @@ -534,7 +556,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id; IN: Attribute access property list hid_t lapl_id; IN: Link access property list RETURNS - ID of attribute on success, negative on failure + ID of attribute on success, H5I_INVALID_HID on failure DESCRIPTION This function opens an existing attribute for access. The attribute @@ -543,57 +565,64 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ 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) +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) { - H5A_t *attr = NULL; /* Attribute opened */ - H5G_loc_t loc; /* Object location */ - hid_t ret_value; /* Return value */ + 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 */ - FUNC_ENTER_API(FAIL) - H5TRACE7("i", "i*sIiIohii", loc_id, obj_name, idx_type, order, n, aapl_id, - lapl_id); + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE7("i", "i*sIiIohii", loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id); - /* 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(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + /* Check arguments */ + if (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + if (!obj_name || !*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - - if(H5P_DEFAULT != lapl_id) { - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - H5CX_set_lapl(lapl_id); - } /* end if */ + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set attribute access property list info") + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set link access property list info") + + /* Fill in location struct parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + /* Open the attribute */ + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_idx() */ - /*-------------------------------------------------------------------------- NAME H5Awrite @@ -613,34 +642,32 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, herr_t H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); - /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") + if (NULL == buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(attr_id) < 0) + if (H5CX_set_loc(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") - /* Go write the actual data to the attribute */ - if((ret_value = H5A__write(attr, mem_type, buf)) < 0) + /* Write the attribute data */ + if ((ret_value = H5VL_attr_write(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Awrite() */ - /*-------------------------------------------------------------------------- NAME H5Aread @@ -660,30 +687,28 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) herr_t H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); - /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") + if (NULL == buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") - /* Go write the actual data to the attribute */ - if((ret_value = H5A__read(attr, mem_type, buf)) < 0) + /* Read the attribute data */ + if ((ret_value = H5VL_attr_read(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aread() */ - /*-------------------------------------------------------------------------- NAME H5Aget_space @@ -693,7 +718,7 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) hid_t H5Aget_space (attr_id) hid_t attr_id; IN: Attribute to get dataspace of RETURNS - A dataspace ID on success, negative on failure + A dataspace ID on success, H5I_INVALID_HID on failure DESCRIPTION This function retrieves a copy of the dataspace for an attribute. @@ -703,23 +728,25 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) hid_t H5Aget_space(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hid_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); - /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") + + /* Get the dataspace */ + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < + 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace of attribute") - if((ret_value = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_space() */ - /*-------------------------------------------------------------------------- NAME H5Aget_type @@ -729,7 +756,7 @@ H5Aget_space(hid_t attr_id) hid_t H5Aget_type (attr_id) hid_t attr_id; IN: Attribute to get datatype of RETURNS - A datatype ID on success, negative on failure + A datatype ID on success, H5I_INVALID_HID on failure DESCRIPTION This function retrieves a copy of the datatype for an attribute. @@ -739,24 +766,24 @@ H5Aget_space(hid_t attr_id) hid_t H5Aget_type(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hid_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); - /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") - if((ret_value = H5A__get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + /* Get the datatype */ + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype of attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ - /*-------------------------------------------------------------------------- NAME H5Aget_create_plist @@ -767,7 +794,7 @@ H5Aget_type(hid_t attr_id) hid_t attr_id; IN: Attribute to get name of RETURNS This function returns the ID of a copy of the attribute's creation - property list, or negative on failure. + property list, or H5I_INVALID_HID on failure. ERRORS @@ -779,26 +806,27 @@ H5Aget_type(hid_t attr_id) hid_t H5Aget_create_plist(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hid_t ret_value; + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); HDassert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1); - /* Get attribute and default attribute creation property list*/ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") - if((ret_value = H5A__get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + /* Get the acpl */ + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_ACPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, + "unable to get creation property list for attribute") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_create_plist() */ - /*-------------------------------------------------------------------------- NAME H5Aget_name @@ -823,27 +851,32 @@ H5Aget_create_plist(hid_t attr_id) ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { - H5A_t *my_attr; /* Attribute object for ID */ - ssize_t ret_value = -1; + 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); /* check arguments */ - if(NULL == (my_attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an attribute") - if(!buf && buf_size) + if (!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero") + /* Set location struct parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); + /* Get the attribute name */ - if(0 > (ret_value = H5A__get_name(my_attr, buf_size, buf))) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + buf_size, buf, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") done: FUNC_LEAVE_API(ret_value) } /* H5Aget_name() */ - /*------------------------------------------------------------------------- * Function: H5Aget_name_by_idx * @@ -862,57 +895,53 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("Zs", "i*sIiIohxzi", loc_id, obj_name, idx_type, order, n, name, size, - lapl_id); + H5TRACE8("Zs", "i*sIiIohxzi", loc_id, obj_name, idx_type, order, n, name, size, lapl_id); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (!name && size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name cannot be NULL if size is non-zero") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + 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") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(attr->shared->name); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Copy the name into the user's buffer, if given */ - if(name) { - HDstrncpy(name, attr->shared->name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; - } /* end if */ + /* Get the name */ + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + size, name, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get name") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Aget_storage_size * @@ -933,24 +962,25 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, hsize_t H5Aget_storage_size(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hsize_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; + hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", attr_id); - /* Check args */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") - /* Set return value */ - ret_value = attr->shared->data_size; + /* Get the storage size */ + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get acpl") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info * @@ -967,25 +997,31 @@ H5Aget_storage_size(hid_t attr_id) herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) { - H5A_t *attr; /* Attribute object for name */ - herr_t ret_value = SUCCEED; /* Return value */ + 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); /* Check args */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if (!ainfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "attribute_info parameter cannot be NULL") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info_by_name * @@ -1000,49 +1036,48 @@ 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, hid_t lapl_id) +H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, + hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ - herr_t ret_value = SUCCEED; /* Return value */ + 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); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(NULL == ainfo) + if (NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + 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") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Aget_info_by_idx * @@ -1058,52 +1093,53 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ - herr_t ret_value = SUCCEED; /* Return value */ + 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*sIiIoh*xi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id); /* Check args */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(NULL == ainfo) + if (NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + 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") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if (H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Arename * @@ -1120,36 +1156,41 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, old_name, new_name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!old_name) + if (!old_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be NULL") - if(!*old_name) + if (!*old_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be an empty string") - if(!new_name) + if (!new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be NULL") - if(!*new_name) + if (!*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be an empty string") /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_name, new_name)) { - H5G_loc_t loc; /* Object location */ + if (HDstrcmp(old_name, new_name)) { + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; - if(H5G_loc(loc_id, &loc) < 0) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Rename the attribute */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1157,7 +1198,6 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) FUNC_LEAVE_API(ret_value) } /* H5Arename() */ - /*------------------------------------------------------------------------- * Function: H5Arename_by_name * @@ -1172,38 +1212,45 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) *------------------------------------------------------------------------- */ herr_t -H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, - const char *new_attr_name, hid_t lapl_id) +H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, const char *new_attr_name, + hid_t lapl_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*s*s*si", loc_id, obj_name, old_attr_name, new_attr_name, - lapl_id); + H5TRACE5("e", "i*s*s*si", loc_id, obj_name, old_attr_name, new_attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!old_attr_name || !*old_attr_name) + if (!old_attr_name || !*old_attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no old attribute name") - if(!new_attr_name || !*new_attr_name) + if (!new_attr_name || !*new_attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new attribute name") /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_attr_name, new_attr_name)) { - H5G_loc_t loc; /* Object location */ + if (HDstrcmp(old_attr_name, new_attr_name)) { + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + 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") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Rename the attribute */ - if(H5A__rename_by_name(loc, obj_name, old_attr_name, new_attr_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1211,7 +1258,6 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, FUNC_LEAVE_API(ret_value) } /* H5Arename_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate2 @@ -1254,31 +1300,40 @@ 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, H5A_operator2_t op, + void *op_data) { - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of 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 */ - if(H5I_ATTR == H5I_get_type(loc_id)) + 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) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the loc object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over attributes */ - if((ret_value = H5A__iterate(loc_id, idx_type, order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate2() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate_by_name @@ -1323,42 +1378,48 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, attribute. --------------------------------------------------------------------------*/ 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) +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) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object location */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op, - op_data, lapl_id); + H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + 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") + 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; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the loc object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over attributes */ - if((ret_value = H5A__iterate_by_name(&loc, obj_name, idx_type, order, idx, op, op_data)) < 0) + if ((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Adelete @@ -1376,35 +1437,42 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, herr_t H5Adelete(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Delete the attribute */ - if(H5O__attr_remove(loc.oloc, name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete() */ - /*-------------------------------------------------------------------------- NAME H5Adelete_by_name @@ -1422,38 +1490,46 @@ H5Adelete(hid_t loc_id, const char *name) This function removes the named attribute from an object. --------------------------------------------------------------------------*/ herr_t -H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t lapl_id) +H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + 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 */ + 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Delete the attribute */ - if(H5A__delete_by_name(&loc, obj_name, attr_name) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_name() */ - /*-------------------------------------------------------------------------- NAME H5Adelete_by_idx @@ -1479,76 +1555,82 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, object to operate on. --------------------------------------------------------------------------*/ 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) +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) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, obj_name, idx_type, order, n, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + 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") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Delete the attribute */ - if(H5A__delete_by_idx(&loc, obj_name, idx_type, order, n) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_idx() */ - -/*-------------------------------------------------------------------------- - NAME - H5Aclose - PURPOSE - Close an attribute ID - USAGE - herr_t H5Aclose (attr_id) - hid_t attr_id; IN: Attribute to release access to - RETURNS - Non-negative on success/Negative on failure - - DESCRIPTION - This function releases an attribute from use. Further use of the - attribute ID will result in undefined behavior. ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5Aclose + * + * Purpose: Closes access to an attribute and releases resources used by + * it. It is illegal to subsequently use that same dataset + * ID in calls to other attribute functions. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t H5Aclose(hid_t attr_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", attr_id); /* Check arguments */ - if(NULL == H5I_object_verify(attr_id, H5I_ATTR)) + if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Decrement references to that atom (and close it) */ - if(H5I_dec_app_ref(attr_id) < 0) + if (H5I_dec_app_ref(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: FUNC_LEAVE_API(ret_value) } /* H5Aclose() */ - /*------------------------------------------------------------------------- * Function: H5Aexists * @@ -1566,29 +1648,35 @@ H5Aclose(hid_t attr_id) htri_t H5Aexists(hid_t obj_id, const char *attr_name) { - H5G_loc_t loc; /* Object location */ - htri_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "i*s", obj_id, attr_name); /* Check arguments */ - if(H5I_ATTR == H5I_get_type(obj_id)) + if (H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + /* get the object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Check if the attribute exists */ - if((ret_value = H5O__attr_exists(loc.oloc, attr_name)) < 0) + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists() */ - /*------------------------------------------------------------------------- * Function: H5Aexists_by_name * @@ -1603,33 +1691,41 @@ 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) +H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - htri_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("t", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR == H5I_get_type(loc_id)) + if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") - if(!attr_name || !*attr_name) + if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + 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") - if((ret_value = H5A__exists_by_name(loc, obj_name, attr_name)) < 0) + /* get the object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Check existence of attribute */ + if (H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists_by_name() */ - diff --git a/src/H5AC.c b/src/H5AC.c index a8de8ea9a2f..2eadd2102c2 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,50 +29,44 @@ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5C_FRIEND /* Suppress error about including H5Cpkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ - +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5AC__check_if_write_permitted(const H5F_t *f, - hbool_t *write_permitted_ptr); +static herr_t H5AC__check_if_write_permitted(const H5F_t *f, hbool_t *write_permitted_ptr); static herr_t H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, - H5C_auto_size_ctl_t *int_conf_ptr); + H5C_auto_size_ctl_t *int_conf_ptr); #if H5AC_DO_TAGGING_SANITY_CHECKS -static herr_t H5AC__verify_tag(const H5AC_class_t * type); +static herr_t H5AC__verify_tag(const H5AC_class_t *type); #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - /*********************/ /* Package Variables */ /*********************/ @@ -89,7 +83,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; hbool_t H5_coll_api_sanity_check_g = false; #endif /* H5_HAVE_PARALLEL */ - /*******************/ /* Local Variables */ /*******************/ @@ -101,40 +94,38 @@ hbool_t H5_coll_api_sanity_check_g = false; */ static const H5AC_class_t *const H5AC_class_s[] = { - H5AC_BT, /* ( 0) B-tree nodes */ - H5AC_SNODE, /* ( 1) symbol table nodes */ - H5AC_LHEAP_PRFX, /* ( 2) local heap prefix */ - H5AC_LHEAP_DBLK, /* ( 3) local heap data block */ - H5AC_GHEAP, /* ( 4) global heap */ - H5AC_OHDR, /* ( 5) object header */ - H5AC_OHDR_CHK, /* ( 6) object header chunk */ - H5AC_BT2_HDR, /* ( 7) v2 B-tree header */ - H5AC_BT2_INT, /* ( 8) v2 B-tree internal node */ - H5AC_BT2_LEAF, /* ( 9) v2 B-tree leaf node */ - H5AC_FHEAP_HDR, /* (10) fractal heap header */ - H5AC_FHEAP_DBLOCK, /* (11) fractal heap direct block */ - H5AC_FHEAP_IBLOCK, /* (12) fractal heap indirect block */ - H5AC_FSPACE_HDR, /* (13) free space header */ - H5AC_FSPACE_SINFO, /* (14) free space sections */ - H5AC_SOHM_TABLE, /* (15) shared object header message master table */ - H5AC_SOHM_LIST, /* (16) shared message index stored as a list */ - H5AC_EARRAY_HDR, /* (17) extensible array header */ - H5AC_EARRAY_IBLOCK, /* (18) extensible array index block */ - H5AC_EARRAY_SBLOCK, /* (19) extensible array super block */ - H5AC_EARRAY_DBLOCK, /* (20) extensible array data block */ - H5AC_EARRAY_DBLK_PAGE, /* (21) extensible array data block page */ - H5AC_FARRAY_HDR, /* (22) fixed array header */ - H5AC_FARRAY_DBLOCK, /* (23) fixed array data block */ - H5AC_FARRAY_DBLK_PAGE, /* (24) fixed array data block page */ - H5AC_SUPERBLOCK, /* (25) file superblock */ - H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ - H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ - H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ + H5AC_BT, /* ( 0) B-tree nodes */ + H5AC_SNODE, /* ( 1) symbol table nodes */ + H5AC_LHEAP_PRFX, /* ( 2) local heap prefix */ + H5AC_LHEAP_DBLK, /* ( 3) local heap data block */ + H5AC_GHEAP, /* ( 4) global heap */ + H5AC_OHDR, /* ( 5) object header */ + H5AC_OHDR_CHK, /* ( 6) object header chunk */ + H5AC_BT2_HDR, /* ( 7) v2 B-tree header */ + H5AC_BT2_INT, /* ( 8) v2 B-tree internal node */ + H5AC_BT2_LEAF, /* ( 9) v2 B-tree leaf node */ + H5AC_FHEAP_HDR, /* (10) fractal heap header */ + H5AC_FHEAP_DBLOCK, /* (11) fractal heap direct block */ + H5AC_FHEAP_IBLOCK, /* (12) fractal heap indirect block */ + H5AC_FSPACE_HDR, /* (13) free space header */ + H5AC_FSPACE_SINFO, /* (14) free space sections */ + H5AC_SOHM_TABLE, /* (15) shared object header message master table */ + H5AC_SOHM_LIST, /* (16) shared message index stored as a list */ + H5AC_EARRAY_HDR, /* (17) extensible array header */ + H5AC_EARRAY_IBLOCK, /* (18) extensible array index block */ + H5AC_EARRAY_SBLOCK, /* (19) extensible array super block */ + H5AC_EARRAY_DBLOCK, /* (20) extensible array data block */ + H5AC_EARRAY_DBLK_PAGE, /* (21) extensible array data block page */ + H5AC_FARRAY_HDR, /* (22) fixed array header */ + H5AC_FARRAY_DBLOCK, /* (23) fixed array data block */ + H5AC_FARRAY_DBLK_PAGE, /* (24) fixed array data block page */ + H5AC_SUPERBLOCK, /* (25) file superblock */ + H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ + H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ + H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ + H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ }; - - /*------------------------------------------------------------------------- * Function: H5AC_init * @@ -151,7 +142,7 @@ static const H5AC_class_t *const H5AC_class_s[] = { herr_t H5AC_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -160,7 +151,6 @@ H5AC_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_init() */ - /*------------------------------------------------------------------------- * Function: H5AC__init_package * @@ -183,11 +173,11 @@ H5AC__init_package(void) * sanity checks using MPI barriers */ { - const char *s; /* String for environment variables */ + const char *s; /* String for environment variables */ s = HDgetenv("H5_COLL_API_SANITY_CHECK"); - if(s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); + if (s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE; } } @@ -196,7 +186,6 @@ H5AC__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5AC__init_package() */ - /*------------------------------------------------------------------------- * Function: H5AC_term_package * @@ -216,14 +205,13 @@ H5AC_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) + if (H5_PKG_INIT_VAR) /* Reset interface initialization flag */ H5_PKG_INIT_VAR = FALSE; FUNC_LEAVE_NOAPI(0) } /* end H5AC_term_package() */ - /*------------------------------------------------------------------------- * * Function: H5AC_cache_image_pending() @@ -244,8 +232,8 @@ H5AC_term_package(void) hbool_t H5AC_cache_image_pending(const H5F_t *f) { - H5C_t *cache_ptr; - hbool_t ret_value = FALSE; /* Return value */ + H5C_t * cache_ptr; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -259,7 +247,6 @@ H5AC_cache_image_pending(const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_cache_image_pending() */ - /*------------------------------------------------------------------------- * Function: H5AC_create * @@ -278,81 +265,81 @@ H5AC_cache_image_pending(const H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t * image_config_ptr) +H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t *image_config_ptr) { #ifdef H5_HAVE_PARALLEL - char prefix[H5C__PREFIX_LEN] = ""; - H5AC_aux_t * aux_ptr = NULL; + char prefix[H5C__PREFIX_LEN] = ""; + H5AC_aux_t *aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ struct H5C_cache_image_ctl_t int_ci_config = H5C__DEFAULT_CACHE_IMAGE_CTL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(f); HDassert(NULL == f->shared->cache); - HDassert(config_ptr != NULL) ; - HDassert(image_config_ptr != NULL) ; + HDassert(config_ptr != NULL); + HDassert(image_config_ptr != NULL); HDassert(image_config_ptr->version == H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION); HDcompile_assert(NELMTS(H5AC_class_s) == H5AC_NTYPES); HDcompile_assert(H5C__MAX_NUM_TYPE_IDS == H5AC_NTYPES); /* Validate configurations */ - if(H5AC_validate_config(config_ptr) < 0) + if (H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") - if(H5AC_validate_cache_image_config(image_config_ptr) < 0) + if (H5AC_validate_cache_image_config(image_config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache image configuration") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - MPI_Comm mpi_comm; - int mpi_rank; - int mpi_size; + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + MPI_Comm mpi_comm; + int mpi_rank; + int mpi_size; - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get mpi rank") - if((mpi_size = H5F_mpi_get_size(f)) < 0) + if ((mpi_size = H5F_mpi_get_size(f)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get mpi size") - if(NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) + if (NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate H5AC auxiliary structure") - aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; - aux_ptr->mpi_comm = mpi_comm; - aux_ptr->mpi_rank = mpi_rank; - aux_ptr->mpi_size = mpi_size; - aux_ptr->write_permitted = FALSE; - aux_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; - aux_ptr->dirty_bytes = 0; + aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; + aux_ptr->mpi_comm = mpi_comm; + aux_ptr->mpi_rank = mpi_rank; + aux_ptr->mpi_size = mpi_size; + aux_ptr->write_permitted = FALSE; + aux_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; + aux_ptr->dirty_bytes = 0; aux_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->dirty_bytes_propagations = 0; - aux_ptr->unprotect_dirty_bytes = 0; + aux_ptr->dirty_bytes_propagations = 0; + aux_ptr->unprotect_dirty_bytes = 0; aux_ptr->unprotect_dirty_bytes_updates = 0; - aux_ptr->insert_dirty_bytes = 0; - aux_ptr->insert_dirty_bytes_updates = 0; - aux_ptr->move_dirty_bytes = 0; - aux_ptr->move_dirty_bytes_updates = 0; + aux_ptr->insert_dirty_bytes = 0; + aux_ptr->insert_dirty_bytes_updates = 0; + aux_ptr->move_dirty_bytes = 0; + aux_ptr->move_dirty_bytes_updates = 0; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - aux_ptr->d_slist_ptr = NULL; - aux_ptr->c_slist_ptr = NULL; + aux_ptr->d_slist_ptr = NULL; + aux_ptr->c_slist_ptr = NULL; aux_ptr->candidate_slist_ptr = NULL; - aux_ptr->write_done = NULL; - aux_ptr->sync_point_done = NULL; - aux_ptr->p0_image_len = 0; + aux_ptr->write_done = NULL; + aux_ptr->sync_point_done = NULL; + aux_ptr->p0_image_len = 0; HDsprintf(prefix, "%d:", mpi_rank); - if(mpi_rank == 0) { - if(NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (mpi_rank == 0) { + if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create dirtied entry list") - if(NULL == (aux_ptr->c_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (aux_ptr->c_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cleaned entry list") } /* end if */ @@ -360,27 +347,17 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * when the distributed strategy is selected as all processes * will use it in the case of a flush. */ - if(NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create candidate entry list") - if(aux_ptr != NULL) - if(aux_ptr->mpi_rank == 0) - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, H5AC__log_flushed_entry, - (void *)aux_ptr); - else - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, - (void *)aux_ptr); + if (aux_ptr->mpi_rank == 0) + f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), H5AC_class_s, H5AC__check_if_write_permitted, + TRUE, H5AC__log_flushed_entry, (void *)aux_ptr); else - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, NULL); + f->shared->cache = + H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), + H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, (void *)aux_ptr); } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ @@ -388,20 +365,19 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * overwritten shortly by the subsequent set resize config call. * -- JRM */ - f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), - H5AC_class_s, - H5AC__check_if_write_permitted, TRUE, NULL, NULL); + f->shared->cache = + H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, H5AC__DEFAULT_MIN_CLEAN_SIZE, (H5AC_NTYPES - 1), + H5AC_class_s, H5AC__check_if_write_permitted, TRUE, NULL, NULL); #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - if(NULL == f->shared->cache) + if (NULL == f->shared->cache) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") #ifdef H5_HAVE_PARALLEL - if(aux_ptr != NULL) - if(H5C_set_prefix(f->shared->cache, prefix) < 0) + if (aux_ptr != NULL) + if (H5C_set_prefix(f->shared->cache, prefix) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "H5C_set_prefix() failed") #endif /* H5_HAVE_PARALLEL */ @@ -409,12 +385,13 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * This will be JSON until we create a special API call. Trace output * is generated when logging is controlled by the struct. */ - if(H5F_USE_MDC_LOGGING(f)) - if(H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) + if (H5F_USE_MDC_LOGGING(f)) + if (H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, + H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") /* Set the cache parameters */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + if (H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") /* Don't need to get the current H5C image config here since the @@ -427,35 +404,34 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co int_ci_config.generate_image = image_config_ptr->generate_image; int_ci_config.save_resize_status = image_config_ptr->save_resize_status; int_ci_config.entry_ageout = image_config_ptr->entry_ageout; - if(H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) + if (H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxiliary structure */ - if(ret_value < 0) { - if(aux_ptr != NULL) { - if(aux_ptr->d_slist_ptr != NULL) + if (ret_value < 0) { + if (aux_ptr != NULL) { + if (aux_ptr->d_slist_ptr != NULL) H5SL_close(aux_ptr->d_slist_ptr); - if(aux_ptr->c_slist_ptr != NULL) + if (aux_ptr->c_slist_ptr != NULL) H5SL_close(aux_ptr->c_slist_ptr); - if(aux_ptr->candidate_slist_ptr != NULL) + if (aux_ptr->candidate_slist_ptr != NULL) H5SL_close(aux_ptr->candidate_slist_ptr); aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create() */ - /*------------------------------------------------------------------------- * Function: H5AC_dest * @@ -470,10 +446,10 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co * * Changes: * - * In the parallel case, added code to setup the MDC slist + * In the parallel case, added code to setup the MDC slist * before the call to H5AC__flush_entries() and take it down - * afterwards. - * + * afterwards. + * * JRM -- 7/29/20 * *------------------------------------------------------------------------- @@ -481,12 +457,12 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co herr_t H5AC_dest(H5F_t *f) { - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ + hbool_t log_enabled; /* TRUE if logging was set up */ + hbool_t curr_logging; /* TRUE if currently logging */ #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -501,42 +477,37 @@ H5AC_dest(H5F_t *f) #endif /* H5AC_DUMP_STATS_ON_CLOSE */ /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, - &log_enabled, &curr_logging) < 0) + if (H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to get logging status") - if(log_enabled && curr_logging) { + if (log_enabled && curr_logging) { - if(H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) + if (H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, \ - "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") } /* Tear down logging */ - if(log_enabled) { + if (log_enabled) { - if(H5C_log_tear_down(f->shared->cache) < 0) + if (H5C_log_tear_down(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, \ - "mdc logging tear-down failed") + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") } #ifdef H5_HAVE_PARALLEL /* destroying the cache, so clear all collective entries */ - if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) + if (H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, \ - "H5C_clear_coll_entries() failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed") aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); - if(aux_ptr) { + if (aux_ptr) { /* Sanity check */ HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - /* If the file was opened R/W, attempt to flush all entries * from rank 0 & Bcast clean list to other ranks. @@ -544,8 +515,8 @@ H5AC_dest(H5F_t *f) * Must not flush in the R/O case, as this will trigger the * free space manager settle routines. * - * Must also enable the skip list before the call to - * H5AC__flush_entries() and disable it afterwards, as the + * Must also enable the skip list before the call to + * H5AC__flush_entries() and disable it afterwards, as the * skip list will be disabled after the previous flush. * * Note that H5C_dest() does slist setup and take down as well. @@ -555,20 +526,19 @@ H5AC_dest(H5F_t *f) * Fortunately, the cache should be clean or close to it at this * point, so the overhead should be minimal. */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { + if (H5F_ACC_RDWR & H5F_INTENT(f)) { /* enable and load the slist */ - if ( H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0 ) + if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "set slist enabled failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") - if(H5AC__flush_entries(f) < 0) + if (H5AC__flush_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush") /* disable the slist -- should be empty */ - if ( H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0 ) + if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed") } @@ -576,7 +546,7 @@ H5AC_dest(H5F_t *f) #endif /* H5_HAVE_PARALLEL */ /* Destroy the cache */ - if(H5C_dest(f) < 0) + if (H5C_dest(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache") @@ -584,23 +554,23 @@ H5AC_dest(H5F_t *f) #ifdef H5_HAVE_PARALLEL - if(aux_ptr != NULL) { + if (aux_ptr != NULL) { - if(aux_ptr->d_slist_ptr != NULL) { + if (aux_ptr->d_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->d_slist_ptr) == 0); H5SL_close(aux_ptr->d_slist_ptr); } /* end if */ - if(aux_ptr->c_slist_ptr != NULL) { + if (aux_ptr->c_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); H5SL_close(aux_ptr->c_slist_ptr); } /* end if */ - if(aux_ptr->candidate_slist_ptr != NULL) { + if (aux_ptr->candidate_slist_ptr != NULL) { HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); H5SL_close(aux_ptr->candidate_slist_ptr); @@ -608,16 +578,15 @@ H5AC_dest(H5F_t *f) } /* end if */ aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_dest() */ - /*------------------------------------------------------------------------- * Function: H5AC_evict * @@ -634,7 +603,7 @@ H5AC_dest(H5F_t *f) herr_t H5AC_evict(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -644,19 +613,18 @@ H5AC_evict(H5F_t *f) HDassert(f->shared->cache); /* Evict all entries in the cache except the pinned superblock entry */ - if(H5C_evict(f) < 0) + if (H5C_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't evict cache") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict() */ - /*------------------------------------------------------------------------- * Function: H5AC_expunge_entry * @@ -672,10 +640,9 @@ H5AC_evict(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, - unsigned flags) +H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -687,19 +654,18 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - if(H5C_expunge_entry(f, type, addr, flags) < 0) + if (H5C_expunge_entry(f, type, addr, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_flush * @@ -722,7 +688,7 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, herr_t H5AC_flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -733,69 +699,28 @@ H5AC_flush(H5F_t *f) #ifdef H5_HAVE_PARALLEL /* flushing the cache, so clear all collective entries */ - if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) + if (H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed") /* Attempt to flush all entries from rank 0 & Bcast clean list to other ranks */ - if(H5AC__flush_entries(f) < 0) + if (H5AC__flush_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush") #endif /* H5_HAVE_PARALLEL */ /* Flush the cache */ /* (Again, in parallel - writes out the superblock) */ - if(H5C_flush_cache(f, H5AC__NO_FLAGS_SET) < 0) + if (H5C_flush_cache(f, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ - -/*------------------------------------------------------------------------- - * Function: H5AC_force_cache_image_load() - * - * Purpose: On rare occasions, it is necessary to run - * H5MF_tidy_self_referential_fsm_hack() prior to the first - * metadata cache access. This is a problem as if there is a - * cache image at the end of the file, that routine will - * discard it. - * - * We solve this issue by calling this function, which will - * load the cache image and then call - * H5MF_tidy_self_referential_fsm_hack() to discard it. - * - * Return: SUCCEED on success, and FAIL on failure. - * - * Programmer: John Mainzer - * 1/11/17 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC_force_cache_image_load(H5F_t *f) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->cache); - - if(H5C_force_cache_image_load(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't load cache image") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC_force_cache_image_load() */ - - /*------------------------------------------------------------------------- * Function: H5AC_get_entry_status * @@ -820,40 +745,40 @@ H5AC_force_cache_image_load(H5F_t *f) herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) { - hbool_t in_cache; /* Entry @ addr is in the cache */ - hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ - hbool_t is_protected; /* Entry @ addr is in the cache and protected */ - hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ - hbool_t is_corked; - hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ - hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ - hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t in_cache; /* Entry @ addr is in the cache */ + hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ + hbool_t is_protected; /* Entry @ addr is in the cache and protected */ + hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ + hbool_t is_corked; + hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ + hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ + hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((f == NULL) || (!H5F_addr_defined(addr)) || (status == NULL)) + if ((f == NULL) || (!H5F_addr_defined(addr)) || (status == NULL)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") - if(H5C_get_entry_status(f, addr, NULL, &in_cache, &is_dirty, - &is_protected, &is_pinned, &is_corked, &is_flush_dep_parent, &is_flush_dep_child, &image_is_up_to_date) < 0) + if (H5C_get_entry_status(f, addr, NULL, &in_cache, &is_dirty, &is_protected, &is_pinned, &is_corked, + &is_flush_dep_parent, &is_flush_dep_child, &image_is_up_to_date) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_status() failed") - if(in_cache) { + if (in_cache) { *status |= H5AC_ES__IN_CACHE; - if(is_dirty) + if (is_dirty) *status |= H5AC_ES__IS_DIRTY; - if(is_protected) + if (is_protected) *status |= H5AC_ES__IS_PROTECTED; - if(is_pinned) + if (is_pinned) *status |= H5AC_ES__IS_PINNED; - if(is_corked) + if (is_corked) *status |= H5AC_ES__IS_CORKED; - if(is_flush_dep_parent) + if (is_flush_dep_parent) *status |= H5AC_ES__IS_FLUSH_DEP_PARENT; - if(is_flush_dep_child) + if (is_flush_dep_child) *status |= H5AC_ES__IS_FLUSH_DEP_CHILD; - if(image_is_up_to_date) + if (image_is_up_to_date) *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE; } /* end if */ else @@ -863,7 +788,6 @@ H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_entry_status() */ - /*------------------------------------------------------------------------- * Function: H5AC_insert_entry * @@ -879,10 +803,9 @@ H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) *------------------------------------------------------------------------- */ herr_t -H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, - unsigned int flags) +H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -896,45 +819,45 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(thing); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS - if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) + if (!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Bad tag value") #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ /* Insert entry into metadata cache */ - if(H5C_insert_entry(f, type, addr, thing, flags) < 0) + if (H5C_insert_entry(f, type, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { - /* Log the new entry */ - if(H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed") + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { + /* Log the new entry */ + if (H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed") - /* Check if we should try to flush */ - if(aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") - } /* end if */ -} + /* Check if we should try to flush */ + if (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") + } /* end if */ + } #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, + ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_insert_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_load_cache_image_on_next_protect * @@ -950,10 +873,9 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, *------------------------------------------------------------------------- */ herr_t -H5AC_load_cache_image_on_next_protect(H5F_t * f, haddr_t addr, hsize_t len, - hbool_t rw) +H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -962,14 +884,13 @@ H5AC_load_cache_image_on_next_protect(H5F_t * f, haddr_t addr, hsize_t len, HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_load_cache_image_on_next_protect(f, addr, len, rw) < 0) + if (H5C_load_cache_image_on_next_protect(f, addr, len, rw) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "call to H5C_load_cache_image_on_next_protect failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_load_cache_image_on_next_protect() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_dirty * @@ -987,8 +908,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1000,31 +921,30 @@ H5AC_mark_entry_dirty(void *thing) cache_ptr = entry_ptr->cache_ptr; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && - (entry_ptr->is_pinned) && (NULL != aux_ptr)) - if(H5AC__log_dirtied_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && (entry_ptr->is_pinned) && + (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 */ - if(H5C_mark_entry_dirty(thing) < 0) + if (H5C_mark_entry_dirty(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't mark pinned or protected entry dirty") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_dirty() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_clean * @@ -1042,8 +962,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1054,31 +974,30 @@ H5AC_mark_entry_clean(void *thing) cache_ptr = entry_ptr->cache_ptr; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && - (entry_ptr->is_pinned) && (NULL != aux_ptr)) - if(H5AC__log_cleaned_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't log cleaned entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && (entry_ptr->is_pinned) && + (NULL != aux_ptr)) + if (H5AC__log_cleaned_entry(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't log cleaned entry") + } #endif /* H5_HAVE_PARALLEL */ - if(H5C_mark_entry_clean(thing) < 0) + if (H5C_mark_entry_clean(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't mark pinned or protected entry clean") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_unserialized * @@ -1096,8 +1015,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1108,20 +1027,19 @@ H5AC_mark_entry_unserialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - if(H5C_mark_entry_unserialized(thing) < 0) + if (H5C_mark_entry_unserialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "can't mark entry unserialized") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_unserialized() */ - /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_serialized * @@ -1139,8 +1057,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1150,20 +1068,19 @@ H5AC_mark_entry_serialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - if(H5C_mark_entry_serialized(thing) < 0) + if (H5C_mark_entry_serialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "can't mark entry serialized") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_serialized() */ - /*------------------------------------------------------------------------- * Function: H5AC_move_entry * @@ -1181,9 +1098,9 @@ herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { #ifdef H5_HAVE_PARALLEL - H5AC_aux_t *aux_ptr; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1197,31 +1114,30 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne #ifdef H5_HAVE_PARALLEL /* Log moving the entry */ - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) - if(H5AC__log_moved_entry(f, old_addr, new_addr) < 0) + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) + if (H5AC__log_moved_entry(f, old_addr, new_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log moved entry") #endif /* H5_HAVE_PARALLEL */ - if(H5C_move_entry(f->shared->cache, type, old_addr, new_addr) < 0) + if (H5C_move_entry(f->shared->cache, type, old_addr, new_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "H5C_move_entry() failed") #ifdef H5_HAVE_PARALLEL /* Check if we should try to flush */ - if(NULL != aux_ptr && aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if (NULL != aux_ptr && aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_move_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_pin_protected_entry() * @@ -1238,9 +1154,9 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1252,20 +1168,19 @@ H5AC_pin_protected_entry(void *thing) HDassert(cache_ptr); /* Pin entry */ - if(H5C_pin_protected_entry(thing) < 0) + if (H5C_pin_protected_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC_prep_for_file_close @@ -1287,7 +1202,7 @@ H5AC_pin_protected_entry(void *thing) herr_t H5AC_prep_for_file_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1296,29 +1211,28 @@ H5AC_prep_for_file_close(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_prep_for_file_close(f) < 0) + if (H5C_prep_for_file_close(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cache prep for file close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_prep_for_file_close() */ - /*------------------------------------------------------------------------- * * Function: H5AC_prep_for_file_flush * - * Purpose: This function should be called just prior to the first + * Purpose: This function should be called just prior to the first * call to H5AC_flush() during a file flush. * - * Its purpose is to handly any setup required prior to - * metadata cache flush. + * Its purpose is to handly any setup required prior to + * 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 seperate 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 + * Handling this detail in separate calls allows us to avoid + * the overhead of setting up and taking down the skip list * repeatedly. * * Return: Non-negative on success/Negative on failure @@ -1333,7 +1247,7 @@ H5AC_prep_for_file_close(H5F_t *f) herr_t H5AC_prep_for_file_flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1342,7 +1256,7 @@ H5AC_prep_for_file_flush(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if ( H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) + if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist enabled failed") @@ -1352,26 +1266,25 @@ H5AC_prep_for_file_flush(H5F_t *f) } /* H5AC_prep_for_file_flush() */ - /*------------------------------------------------------------------------- * * Function: H5AC_secure_from_file_flush * - * Purpose: This function should be called just after the last + * Purpose: This function should be called just after the last * call to H5AC_flush() during a file flush. * * Its purpose is to perform any necessary cleanup after the * metadata cache flush. * * The objective of the call is to allow the metadata cache - * to do any necessary necessary cleanup work after a cache + * to do any necessary necessary cleanup work after a cache * 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 seperate 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 + * Handling this detail in separate calls allows us to avoid + * the overhead of setting up and taking down the skip list * repeatedly. * * Return: Non-negative on success/Negative on failure @@ -1386,7 +1299,7 @@ H5AC_prep_for_file_flush(H5F_t *f) herr_t H5AC_secure_from_file_flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1395,7 +1308,7 @@ H5AC_secure_from_file_flush(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if ( H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) + if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist enabled failed") @@ -1405,7 +1318,6 @@ H5AC_secure_from_file_flush(H5F_t *f) } /* H5AC_secure_from_file_flush() */ - /*------------------------------------------------------------------------- * * Function: H5AC_create_flush_dependency() @@ -1421,11 +1333,11 @@ H5AC_secure_from_file_flush(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5AC_create_flush_dependency(void * parent_thing, void * child_thing) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1438,20 +1350,20 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing) HDassert(cache_ptr); /* Create the flush dependency */ - if(H5C_create_flush_dependency(parent_thing, child_thing) < 0) + if (H5C_create_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, + (H5AC_info_t *)child_thing, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: H5AC_protect * @@ -1476,11 +1388,10 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing) *------------------------------------------------------------------------- */ void * -H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, - unsigned flags) +H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags) { - void * thing = NULL; /* Pointer to native data structure for entry */ - void * ret_value = NULL; /* Return value */ + void *thing = NULL; /* Pointer to native data structure for entry */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1496,24 +1407,22 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, * only permitted in the parallel case. */ #ifdef H5_HAVE_PARALLEL - HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | \ - H5C__FLUSH_LAST_FLAG | \ - H5C__FLUSH_COLLECTIVELY_FLAG)))); -#else /* H5_HAVE_PARALLEL */ - HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | \ - H5C__FLUSH_LAST_FLAG)))); + HDassert(0 == (flags & + (unsigned)(~(H5C__READ_ONLY_FLAG | H5C__FLUSH_LAST_FLAG | H5C__FLUSH_COLLECTIVELY_FLAG)))); +#else /* H5_HAVE_PARALLEL */ + HDassert(0 == (flags & (unsigned)(~(H5C__READ_ONLY_FLAG | H5C__FLUSH_LAST_FLAG)))); #endif /* H5_HAVE_PARALLEL */ /* Check for invalid access request */ - if((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) + if ((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS - if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) + if (!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Bad tag value") #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - if(NULL == (thing = H5C_protect(f, type, addr, udata, flags))) + if (NULL == (thing = H5C_protect(f, type, addr, udata, flags))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed") /* Set return value */ @@ -1524,15 +1433,15 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, { herr_t fake_ret_value = (NULL == ret_value) ? FAIL : SUCCEED; - if(f->shared->cache->log_info->logging) - if(H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, fake_ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, + fake_ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message") } FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ - /*------------------------------------------------------------------------- * Function: H5AC_resize_entry * @@ -1549,8 +1458,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1562,31 +1471,30 @@ H5AC_resize_entry(void *thing, size_t new_size) HDassert(cache_ptr); /* Resize the entry */ - if(H5C_resize_entry(thing, new_size) < 0) + if (H5C_resize_entry(thing, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + 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(H5AC__log_dirtied_entry(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((!entry_ptr->is_dirty) && (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 */ done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_resize_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_unpin_entry() * @@ -1604,8 +1512,8 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1617,20 +1525,19 @@ H5AC_unpin_entry(void *thing) HDassert(cache_ptr); /* Unpin the entry */ - if(H5C_unpin_entry(thing) < 0) + if (H5C_unpin_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_destroy_flush_dependency() * @@ -1644,11 +1551,11 @@ H5AC_unpin_entry(void *thing) *------------------------------------------------------------------------- */ herr_t -H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ + H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1661,20 +1568,20 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) HDassert(cache_ptr); /* Destroy the flush dependency */ - if(H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) + if (H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed") done: /* If currently logging, generate a message */ - if(cache_ptr != NULL && cache_ptr->log_info != NULL) - if(cache_ptr->log_info->logging) - if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + if (cache_ptr != NULL && cache_ptr->log_info != NULL) + if (cache_ptr->log_info->logging) + if (H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, + (H5AC_info_t *)child_thing, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_destroy_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: H5AC_unprotect * @@ -1713,15 +1620,14 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) *------------------------------------------------------------------------- */ herr_t -H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, - unsigned flags) +H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { - hbool_t dirtied; - hbool_t deleted; + hbool_t dirtied; + hbool_t deleted; #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value=SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1737,55 +1643,54 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(((H5AC_info_t *)thing)->addr == addr); HDassert(((H5AC_info_t *)thing)->type == type); - dirtied = (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || - (((H5AC_info_t *)thing)->dirtied)); + dirtied = + (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || (((H5AC_info_t *)thing)->dirtied)); deleted = (hbool_t)((flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG); /* Check if the size changed out from underneath us, if we're not deleting * the entry. */ - if(dirtied && !deleted) { - size_t curr_size = 0; + if (dirtied && !deleted) { + size_t curr_size = 0; - if((type->image_len)(thing, &curr_size) < 0) + if ((type->image_len)(thing, &curr_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "Can't get size of thing") - if(((H5AC_info_t *)thing)->size != curr_size) + if (((H5AC_info_t *)thing)->size != curr_size) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, FAIL, "size of entry changed") } /* end if */ #ifdef H5_HAVE_PARALLEL - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { - if(dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE) - if(H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0) + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { + if (dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE) + 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) + 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") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - if(H5C_unprotect(f, addr, thing, flags) < 0) + if (H5C_unprotect(f, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5C_unprotect() failed") #ifdef H5_HAVE_PARALLEL /* Check if we should try to flush */ - if((aux_ptr != NULL) && (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if ((aux_ptr != NULL) && (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point") #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(f->shared->cache->log_info->logging) - if(H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0) + if (f->shared->cache->log_info->logging) + if (H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_auto_resize_config * @@ -1799,37 +1704,36 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, - H5AC_cache_config_t *config_ptr) +H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if((cache_ptr == NULL) || (config_ptr == NULL) || - (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) + if ((cache_ptr == NULL) || (config_ptr == NULL) || + (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or config_ptr on entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry") + } #endif /* H5_HAVE_PARALLEL */ /* Retrieve the configuration */ - if(H5C_get_cache_auto_resize_config((const H5C_t *)cache_ptr, &internal_config) < 0) + if (H5C_get_cache_auto_resize_config((const H5C_t *)cache_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_auto_resize_config() failed") - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_resize_enabled() failed") /* Set the information to return */ - if(internal_config.rpt_fcn == NULL) + if (internal_config.rpt_fcn == NULL) config_ptr->rpt_fcn_enabled = FALSE; else config_ptr->rpt_fcn_enabled = TRUE; @@ -1860,27 +1764,26 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, config_ptr->apply_empty_reserve = internal_config.apply_empty_reserve; config_ptr->empty_reserve = internal_config.empty_reserve; #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { - config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; - config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; - } /* end if */ - else { + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { + config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; + config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; + } /* end if */ + else { #endif /* H5_HAVE_PARALLEL */ - config_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; - config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; + config_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; + config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; #ifdef H5_HAVE_PARALLEL - } /* end else */ -} + } /* end else */ + } #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_cache_size * @@ -1894,22 +1797,47 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, - size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr) +H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, + uint32_t *cur_num_entries_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_cache_size((H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, cur_num_entries_ptr) < 0) + if (H5C_get_cache_size((H5C_t *)cache_ptr, max_size_ptr, min_clean_size_ptr, cur_size_ptr, + cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_size() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_size() */ - +/*------------------------------------------------------------------------- + * Function: H5AC_get_cache_flush_in_progess + * + * Purpose: Wrapper function for H5C_get_cache_flush_in_progress(). + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 3/11/05 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_get_cache_flush_in_progress(H5AC_t *cache_ptr, hbool_t *flush_in_progress_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (H5C_get_cache_flush_in_progress((H5C_t *)cache_ptr, flush_in_progress_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_flush_in_progress() failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_get_cache_flush_in_progress() */ + /*------------------------------------------------------------------------- * Function: H5AC_get_cache_hit_rate * @@ -1925,18 +1853,17 @@ H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_s herr_t H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) + if (H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_hit_rate() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_cache_hit_rate() */ - /*------------------------------------------------------------------------- * * Function: H5AC_reset_cache_hit_rate_stats() @@ -1950,20 +1877,19 @@ H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr) *------------------------------------------------------------------------- */ herr_t -H5AC_reset_cache_hit_rate_stats(H5AC_t * cache_ptr) +H5AC_reset_cache_hit_rate_stats(H5AC_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_reset_cache_hit_rate_stats((H5C_t *)cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats((H5C_t *)cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_reset_cache_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5AC_set_cache_auto_resize_config * @@ -1980,27 +1906,27 @@ herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(cache_ptr); - if(cache_ptr == NULL) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry") -} + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); + if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry") + } #endif /* H5_HAVE_PARALLEL */ /* Validate external configuration */ - if(H5AC_validate_config(config_ptr) != SUCCEED) + if (H5AC_validate_config(config_ptr) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") /* If the cache config struct is being used to control logging, perform @@ -2009,53 +1935,52 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config * to write start/stop messages. */ /* close */ - if(config_ptr->close_trace_file) - if(H5C_log_tear_down((H5C_t *)cache_ptr) < 0) + if (config_ptr->close_trace_file) + if (H5C_log_tear_down((H5C_t *)cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") /* open */ - if(config_ptr->open_trace_file) { + if (config_ptr->open_trace_file) { /* Turn on metadata cache logging. * This will be trace output until we create a special API call. JSON * output is generated when logging is controlled by the H5P calls. */ - if(H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) + if (H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") } /* Convert external configuration to internal representation */ - if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) + if (H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__ext_config_2_int_config() failed") /* Set configuration */ - if(H5C_set_cache_auto_resize_config(cache_ptr, &internal_config) < 0) + if (H5C_set_cache_auto_resize_config(cache_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_cache_auto_resize_config() failed") - if(H5C_set_evictions_enabled(cache_ptr, config_ptr->evictions_enabled) < 0) + if (H5C_set_evictions_enabled(cache_ptr, config_ptr->evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_evictions_enabled() failed") #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr; + { + H5AC_aux_t *aux_ptr; - /* Set parallel configuration values */ - /* (Which are only held in the H5AC layer -QAK) */ - if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { - aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold; - aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy; - } /* end if */ -} + /* Set parallel configuration values */ + /* (Which are only held in the H5AC layer -QAK) */ + if (NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { + aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold; + aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy; + } /* end if */ + } #endif /* H5_HAVE_PARALLEL */ done: /* If currently logging, generate a message */ - if(cache_ptr->log_info->logging) - if(H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) + if (cache_ptr->log_info->logging) + if (H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_validate_config() * @@ -2082,57 +2007,55 @@ herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown config version") /* don't bother to test trace_file_name unless open_trace_file is TRUE */ - if(config_ptr->open_trace_file) { - size_t name_len; + if (config_ptr->open_trace_file) { + size_t name_len; /* Can't really test the trace_file_name field without trying to * open the file, so we will content ourselves with a couple of * sanity checks on the length of the file name. */ name_len = HDstrlen(config_ptr->trace_file_name); - if(name_len == 0) + if (name_len == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name is empty") - else if(name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) + else if (name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name too long") } /* end if */ - if((config_ptr->evictions_enabled == FALSE) && - ((config_ptr->incr_mode != H5C_incr__off) || - (config_ptr->flash_incr_mode != H5C_flash_incr__off) || - (config_ptr->decr_mode != H5C_decr__off))) + if ((config_ptr->evictions_enabled == FALSE) && + ((config_ptr->incr_mode != H5C_incr__off) || (config_ptr->flash_incr_mode != H5C_flash_incr__off) || + (config_ptr->decr_mode != H5C_decr__off))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Can't disable evictions while auto-resize is enabled") - if(config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD) + if (config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "dirty_bytes_threshold too small") - else if(config_ptr->dirty_bytes_threshold > H5AC__MAX_DIRTY_BYTES_THRESHOLD) + else if (config_ptr->dirty_bytes_threshold > H5AC__MAX_DIRTY_BYTES_THRESHOLD) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "dirty_bytes_threshold too big") - if((config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY) && - (config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) + if ((config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY) && + (config_ptr->metadata_write_strategy != H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->metadata_write_strategy out of range") - if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) + if (H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__ext_config_2_int_config() failed") - if(H5C_validate_resize_config(&internal_config, H5C_RESIZE_CFG__VALIDATE_ALL) < 0) + if (H5C_validate_resize_config(&internal_config, H5C_RESIZE_CFG__VALIDATE_ALL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "error(s) in new config") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5AC_validate_cache_image_config() * @@ -2160,15 +2083,15 @@ herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) { H5C_cache_image_ctl_t internal_config = H5C__DEFAULT_CACHE_IMAGE_CTL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) + if (config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown image config version") /* don't need to get the current H5C image config here since the @@ -2180,14 +2103,13 @@ H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) internal_config.save_resize_status = config_ptr->save_resize_status; internal_config.entry_ageout = config_ptr->entry_ageout; - if(H5C_validate_cache_image_config(&internal_config) < 0) + if (H5C_validate_cache_image_config(&internal_config) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "error(s) in new cache image config") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_validate_cache_image_config() */ - /*------------------------------------------------------------------------- * * Function: H5AC__check_if_write_permitted @@ -2210,14 +2132,15 @@ H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) static herr_t H5AC__check_if_write_permitted(const H5F_t #ifndef H5_HAVE_PARALLEL -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *f, hbool_t *write_permitted_ptr) + *f, + hbool_t *write_permitted_ptr) { #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; + H5AC_aux_t *aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted = TRUE; + hbool_t write_permitted = TRUE; FUNC_ENTER_STATIC_NOERR @@ -2227,14 +2150,15 @@ H5_ATTR_UNUSED HDassert(f->shared != NULL); HDassert(f->shared->cache != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); - if(aux_ptr != NULL) { + if (aux_ptr != NULL) { HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if((aux_ptr->mpi_rank == 0) || (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) + if ((aux_ptr->mpi_rank == 0) || + (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) write_permitted = aux_ptr->write_permitted; else write_permitted = FALSE; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ *write_permitted_ptr = write_permitted; @@ -2242,7 +2166,6 @@ H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__check_if_write_permitted() */ - /*------------------------------------------------------------------------- * Function: H5AC__ext_config_2_int_config() * @@ -2262,38 +2185,37 @@ H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static herr_t -H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, - H5C_auto_size_ctl_t *int_conf_ptr) +H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, H5C_auto_size_ctl_t *int_conf_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if((ext_conf_ptr == NULL) || (ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) || - (int_conf_ptr == NULL)) + if ((ext_conf_ptr == NULL) || (ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) || + (int_conf_ptr == NULL)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad ext_conf_ptr or inf_conf_ptr on entry") - int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER; - if(ext_conf_ptr->rpt_fcn_enabled) - int_conf_ptr->rpt_fcn = H5C_def_auto_resize_rpt_fcn; + int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER; + if (ext_conf_ptr->rpt_fcn_enabled) + int_conf_ptr->rpt_fcn = H5C_def_auto_resize_rpt_fcn; else - int_conf_ptr->rpt_fcn = NULL; - - int_conf_ptr->set_initial_size = ext_conf_ptr->set_initial_size; - int_conf_ptr->initial_size = ext_conf_ptr->initial_size; - int_conf_ptr->min_clean_fraction = ext_conf_ptr->min_clean_fraction; - int_conf_ptr->max_size = ext_conf_ptr->max_size; - int_conf_ptr->min_size = ext_conf_ptr->min_size; - int_conf_ptr->epoch_length = (int64_t)(ext_conf_ptr->epoch_length); - - int_conf_ptr->incr_mode = ext_conf_ptr->incr_mode; - int_conf_ptr->lower_hr_threshold = ext_conf_ptr->lower_hr_threshold; - int_conf_ptr->increment = ext_conf_ptr->increment; - int_conf_ptr->apply_max_increment = ext_conf_ptr->apply_max_increment; - int_conf_ptr->max_increment = ext_conf_ptr->max_increment; - int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; - int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; - int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; + int_conf_ptr->rpt_fcn = NULL; + + int_conf_ptr->set_initial_size = ext_conf_ptr->set_initial_size; + int_conf_ptr->initial_size = ext_conf_ptr->initial_size; + int_conf_ptr->min_clean_fraction = ext_conf_ptr->min_clean_fraction; + int_conf_ptr->max_size = ext_conf_ptr->max_size; + int_conf_ptr->min_size = ext_conf_ptr->min_size; + int_conf_ptr->epoch_length = (int64_t)(ext_conf_ptr->epoch_length); + + int_conf_ptr->incr_mode = ext_conf_ptr->incr_mode; + int_conf_ptr->lower_hr_threshold = ext_conf_ptr->lower_hr_threshold; + int_conf_ptr->increment = ext_conf_ptr->increment; + int_conf_ptr->apply_max_increment = ext_conf_ptr->apply_max_increment; + int_conf_ptr->max_increment = ext_conf_ptr->max_increment; + int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; + int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; + int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; int_conf_ptr->decr_mode = ext_conf_ptr->decr_mode; int_conf_ptr->upper_hr_threshold = ext_conf_ptr->upper_hr_threshold; @@ -2308,7 +2230,6 @@ H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__ext_config_2_int_config() */ - /*------------------------------------------------------------------------------ * Function: H5AC_ignore_tags() * @@ -2327,7 +2248,7 @@ H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr, herr_t H5AC_ignore_tags(const H5F_t *f) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -2337,14 +2258,13 @@ H5AC_ignore_tags(const H5F_t *f) HDassert(f->shared->cache); /* Set up a new metadata tag */ - if(H5C_ignore_tags(f->shared->cache) < 0) + if (H5C_ignore_tags(f->shared->cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "H5C_ignore_tags() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_ignore_tags() */ - /*------------------------------------------------------------------------------ * Function: H5AC_tag() * @@ -2363,7 +2283,7 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Get the current tag value and return that (if prev_tag is NOT null) */ - if(prev_tag) + if (prev_tag) *prev_tag = H5CX_get_tag(); /* Set the provided tag */ @@ -2372,7 +2292,6 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) FUNC_LEAVE_NOAPI_VOID } /* H5AC_tag */ - /*------------------------------------------------------------------------------ * Function: H5AC_retag_copied_metadata() * @@ -2390,7 +2309,7 @@ H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag) herr_t H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2399,14 +2318,13 @@ H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag) HDassert(f->shared); /* Call cache-level function to re-tag entries with the COPIED tag */ - if(H5C_retag_entries(f->shared->cache, H5AC__COPIED_TAG, metadata_tag) < 0) + if (H5C_retag_entries(f->shared->cache, H5AC__COPIED_TAG, metadata_tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "Can't retag metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_retag_copied_metadata() */ - /*------------------------------------------------------------------------------ * Function: H5AC_flush_tagged_metadata() * @@ -2434,14 +2352,13 @@ H5AC_flush_tagged_metadata(H5F_t *f, haddr_t metadata_tag) HDassert(f->shared); /* Call cache level function to flush metadata entries with specified tag */ - if(H5C_flush_tagged_entries(f, metadata_tag) < 0) + if (H5C_flush_tagged_entries(f, metadata_tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot flush metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush_tagged_metadata */ - /*------------------------------------------------------------------------------ * Function: H5AC_evict_tagged_metadata() * @@ -2469,14 +2386,13 @@ H5AC_evict_tagged_metadata(H5F_t *f, haddr_t metadata_tag, hbool_t match_global) HDassert(f->shared); /* Call cache level function to evict metadata entries with specified tag */ - if(H5C_evict_tagged_entries(f, metadata_tag, match_global) < 0) + if (H5C_evict_tagged_entries(f, metadata_tag, match_global) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot evict metadata") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict_tagged_metadata() */ - /*------------------------------------------------------------------------------ * Function: H5AC_expunge_tag_type_metadata() * @@ -2503,14 +2419,13 @@ H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flag HDassert(f->shared); /* Call cache level function to expunge entries with specified tag and type id */ - if(H5C_expunge_tag_type_metadata(f, tag, type_id, flags) < 0) + if (H5C_expunge_tag_type_metadata(f, tag, type_id, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot expunge tagged type entries") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_tag_type_metadata*/ - /*------------------------------------------------------------------------------ * Function: H5AC_get_tag() * @@ -2537,14 +2452,13 @@ H5AC_get_tag(const void *thing, haddr_t *tag) HDassert(tag); /* Call cache level function to get the tag */ - if(H5C_get_tag(thing, tag) < 0) + if (H5C_get_tag(thing, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot get tag for metadata cache entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_get_tag() */ - /*------------------------------------------------------------------------- * Function: H5AC_cork * @@ -2559,7 +2473,7 @@ H5AC_get_tag(const void *thing, haddr_t *tag) herr_t H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2575,15 +2489,15 @@ H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) * Re-visit this optimization when we optimize tag info management * in the future. */ - if(action == H5AC__GET_CORKED) { + if (action == H5AC__GET_CORKED) { HDassert(corked); - if(H5C_get_num_objs_corked(f->shared->cache) == 0) { + if (H5C_get_num_objs_corked(f->shared->cache) == 0) { *corked = FALSE; HGOTO_DONE(SUCCEED) } } - if(H5C_cork(f->shared->cache, obj_addr, action, corked) < 0) + if (H5C_cork(f->shared->cache, obj_addr, action, corked) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Cannot perform the cork action") done: @@ -2591,7 +2505,7 @@ H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) } /* H5AC_cork() */ #if H5AC_DO_TAGGING_SANITY_CHECKS - + /*------------------------------------------------------------------------- * * Function: H5AC__verify_tag @@ -2609,8 +2523,8 @@ H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) static herr_t H5AC__verify_tag(const H5AC_class_t *type) { - haddr_t tag; /* Entry tag to validate */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag; /* Entry tag to validate */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2618,7 +2532,7 @@ H5AC__verify_tag(const H5AC_class_t *type) tag = H5CX_get_tag(); /* Verify legal tag value */ - if(H5C_verify_tag(type->id, tag) < 0) + if (H5C_verify_tag(type->id, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "tag verification failed") done: @@ -2626,7 +2540,6 @@ H5AC__verify_tag(const H5AC_class_t *type) } /* H5AC__verify_tag */ #endif /* H5AC_DO_TAGGING_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * Function: H5AC_get_entry_ring * @@ -2645,7 +2558,7 @@ H5AC__verify_tag(const H5AC_class_t *type) herr_t H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2655,14 +2568,13 @@ H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring) HDassert(ring); /* Retrieve the ring value for the entry at address */ - if(H5C_get_entry_ring(f, addr, ring) < 0) + if (H5C_get_entry_ring(f, addr, ring) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "Can't retrieve ring for entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_entry_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_set_ring * @@ -2684,7 +2596,7 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) /* Note: orig_ring can be NULL so don't check it with HDassert() */ /* Get the current ring value and return that (if orig_ring is NOT null) */ - if(orig_ring) + if (orig_ring) *orig_ring = H5CX_get_ring(); /* Set the provided ring */ @@ -2693,7 +2605,6 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) FUNC_LEAVE_NOAPI_VOID } /* end H5AC_set_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_unsettle_entry_ring() * @@ -2725,8 +2636,8 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) herr_t H5AC_unsettle_entry_ring(void *_entry) { - H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2734,14 +2645,13 @@ H5AC_unsettle_entry_ring(void *_entry) HDassert(entry); /* Unsettle the entry's ring */ - if(H5C_unsettle_entry_ring(entry) < 0) + if (H5C_unsettle_entry_ring(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unsettle_entry_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_unsettle_ring() * @@ -2770,20 +2680,19 @@ H5AC_unsettle_entry_ring(void *_entry) *------------------------------------------------------------------------- */ herr_t -H5AC_unsettle_ring(H5F_t * f, H5C_ring_t ring) +H5AC_unsettle_ring(H5F_t *f, H5C_ring_t ring) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(FAIL == (ret_value = H5C_unsettle_ring(f, ring))) + if (FAIL == (ret_value = H5C_unsettle_ring(f, ring))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_unsettle_ring() failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unsettle_ring() */ - /*------------------------------------------------------------------------- * Function: H5AC_remove_entry() * @@ -2800,9 +2709,9 @@ H5AC_unsettle_ring(H5F_t * f, H5C_ring_t ring) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ + H5C_t * cache = NULL; /* Pointer to the entry's associated metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2812,20 +2721,19 @@ H5AC_remove_entry(void *_entry) HDassert(cache); /* Remove the entry from the cache*/ - if(H5C_remove_entry(entry) < 0) + if (H5C_remove_entry(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: /* If currently logging, generate a message */ - if(cache != NULL && cache->log_info != NULL) - if(cache->log_info->logging) - if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) + if (cache != NULL && cache->log_info != NULL) + if (cache->log_info->logging) + if (H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_remove_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC_get_mdc_image_info * @@ -2840,11 +2748,11 @@ H5AC_remove_entry(void *_entry) herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5C_get_mdc_image_info((H5C_t *)cache_ptr, image_addr, image_len) < 0) + if (H5C_get_mdc_image_info((H5C_t *)cache_ptr, image_addr, image_len) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index 94f3d83096d..2d24adb7bbf 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,54 +23,45 @@ /****************/ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5AC_stats * @@ -100,7 +91,7 @@ H5AC_stats(const H5F_t *f) } /* H5AC_stats() */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5AC_dump_cache * @@ -117,7 +108,7 @@ H5AC_stats(const H5F_t *f) herr_t H5AC_dump_cache(const H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -126,7 +117,7 @@ H5AC_dump_cache(const H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - if(H5C_dump_cache(f->shared->cache, H5F_OPEN_NAME(f)) < 0) + if (H5C_dump_cache(f->shared->cache, H5F_OPEN_NAME(f)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_dump_cache() failed.") done: @@ -134,7 +125,6 @@ H5AC_dump_cache(const H5F_t *f) } /* H5AC_dump_cache() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_get_entry_ptr_from_addr() @@ -178,8 +168,8 @@ H5AC_dump_cache(const H5F_t *f) herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) { - H5C_t *cache_ptr; /* Ptr to cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; /* Ptr to cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -188,7 +178,7 @@ H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) HDassert(f->shared); cache_ptr = f->shared->cache; - if(H5C_get_entry_ptr_from_addr(cache_ptr, addr, entry_ptr_ptr) < 0) + if (H5C_get_entry_ptr_from_addr(cache_ptr, addr, entry_ptr_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_ptr_from_addr() failed") done: @@ -196,7 +186,6 @@ H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) } /* H5AC_get_entry_ptr_from_addr() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5AC_flush_dependency_exists() * @@ -224,11 +213,10 @@ H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) */ #ifndef NDEBUG herr_t -H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, - hbool_t *fd_exists_ptr) +H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, hbool_t *fd_exists_ptr) { - H5C_t *cache_ptr; /* Ptr to cache */ - herr_t ret_value = FAIL; /* Return value */ + H5C_t *cache_ptr; /* Ptr to cache */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -243,7 +231,6 @@ H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, } /* H5AC_flush_dependency_exists() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_verify_entry_type() @@ -274,12 +261,11 @@ H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, */ #ifndef NDEBUG herr_t -H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, - const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr) +H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, + hbool_t *type_ok_ptr) { - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -288,7 +274,7 @@ H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, HDassert(f->shared); cache_ptr = f->shared->cache; - if(H5C_verify_entry_type(cache_ptr, addr, expected_type, in_cache_ptr, type_ok_ptr) < 0) + if (H5C_verify_entry_type(cache_ptr, addr, expected_type, in_cache_ptr, type_ok_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_verify_entry_type() failed") done: @@ -296,7 +282,6 @@ H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, } /* H5AC_verify_entry_type() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5AC_get_serialization_in_progress * @@ -315,7 +300,7 @@ hbool_t H5AC_get_serialization_in_progress(H5F_t *f) { H5C_t * cache_ptr; - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -331,7 +316,6 @@ H5AC_get_serialization_in_progress(H5F_t *f) } /* H5AC_get_serialization_in_progress() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5AC_cache_is_clean() @@ -353,8 +337,8 @@ 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; - hbool_t ret_value = FALSE; /* Return value */ + H5C_t * cache_ptr; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -368,4 +352,3 @@ H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_cache_is_clean() */ #endif /* NDEBUG */ - diff --git a/src/H5ACmodule.h b/src/H5ACmodule.h index 8c6eae24a5b..d1f969757f5 100644 --- a/src/H5ACmodule.h +++ b/src/H5ACmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5AC package. Including this header means that the source file * is part of the H5AC package. */ -#ifndef _H5ACmodule_H -#define _H5ACmodule_H +#ifndef H5ACmodule_H +#define H5ACmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5AC_MODULE -#define H5_MY_PKG H5AC -#define H5_MY_PKG_ERR H5E_CACHE -#define H5_MY_PKG_INIT YES - -#endif /* _H5ACmodule_H */ +#define H5_MY_PKG H5AC +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT YES +#endif /* H5ACmodule_H */ diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index 747446064c3..ef85c6d3177 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,20 +27,19 @@ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL @@ -48,7 +47,6 @@ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -70,46 +68,41 @@ * removed when they appear in a clean entries broadcast. * ****************************************************************************/ -typedef struct H5AC_slist_entry_t -{ - haddr_t addr; +typedef struct H5AC_slist_entry_t { + haddr_t addr; } 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 */ - unsigned u; /* Counter for position in array */ +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 */ + unsigned u; /* Counter for position in array */ } H5AC_addr_list_ud_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); static herr_t H5AC__broadcast_clean_list(H5AC_t *cache_ptr); -static herr_t H5AC__construct_candidate_list(H5AC_t *cache_ptr, - H5AC_aux_t *aux_ptr, int sync_point_op); -static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); -static herr_t H5AC__propagate_and_apply_candidate_list(H5F_t *f); -static herr_t H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f); +static herr_t H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t *aux_ptr, int sync_point_op); +static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__propagate_and_apply_candidate_list(H5F_t *f); +static herr_t H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f); static herr_t H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr); -static herr_t H5AC__receive_candidate_list(const H5AC_t *cache_ptr, - unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr); + haddr_t **haddr_buf_ptr_ptr); +static herr_t H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, + haddr_t **haddr_buf_ptr_ptr); static herr_t H5AC__receive_and_apply_clean_list(H5F_t *f); static herr_t H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, - haddr_t *candidates_list_ptr); + haddr_t *candidates_list_ptr); static herr_t H5AC__rsp__dist_md_write__flush(H5F_t *f); static herr_t H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f); static herr_t H5AC__rsp__p0_only__flush(H5F_t *f); static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f); - /*********************/ /* Package Variables */ /*********************/ @@ -117,12 +110,10 @@ static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f); /* Declare a free list to manage the H5AC_aux_t struct */ H5FL_DEFINE(H5AC_aux_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -130,8 +121,6 @@ H5FL_DEFINE(H5AC_aux_t); /* Declare a free list to manage the H5AC_slist_entry_t struct */ H5FL_DEFINE_STATIC(H5AC_slist_entry_t); - - /*------------------------------------------------------------------------- * Function: H5AC__set_sync_point_done_callback * @@ -148,10 +137,10 @@ H5FL_DEFINE_STATIC(H5AC_slist_entry_t); *------------------------------------------------------------------------- */ herr_t -H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, - void (* sync_point_done)(unsigned num_writes, haddr_t * written_entries_tbl)) +H5AC__set_sync_point_done_callback(H5C_t *cache_ptr, + void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl)) { - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -166,7 +155,6 @@ H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__set_sync_point_done_callback() */ - /*------------------------------------------------------------------------- * Function: H5AC__set_write_done_callback * @@ -182,9 +170,9 @@ H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) +H5AC__set_write_done_callback(H5C_t *cache_ptr, void (*write_done)(void)) { - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -199,7 +187,6 @@ H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__set_write_done_callback() */ - /*------------------------------------------------------------------------- * Function: H5AC_add_candidate() * @@ -219,11 +206,11 @@ 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_add_candidate(H5AC_t *cache_ptr, haddr_t addr) { - H5AC_aux_t * aux_ptr; - H5AC_slist_entry_t * slist_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -238,23 +225,22 @@ H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr) /* Construct an entry for the supplied address, and insert * it into the candidate slist. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate candidate slist entry") - slist_entry_ptr->addr = addr; + slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->candidate_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->candidate_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist") done: /* Clean up on error */ - if(ret_value < 0) - if(slist_entry_ptr) + if (ret_value < 0) + if (slist_entry_ptr) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_add_candidate() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_candidate_list() @@ -280,14 +266,13 @@ H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr) *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +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; - int mpi_result; - unsigned num_entries; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr = NULL; + haddr_t * haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -309,25 +294,26 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, * any, we are done. */ num_entries = (unsigned)H5SL_count(aux_ptr->candidate_slist_ptr); - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { - size_t buf_size = 0; - unsigned chk_num_entries = 0; + if (num_entries > 0) { + size_t buf_size = 0; + unsigned chk_num_entries = 0; /* convert the candidate list into the format we * 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) + 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.") HDassert(chk_num_entries == num_entries); HDassert(haddr_buf_ptr != NULL); /* Now broadcast the list of candidate entries */ buf_size = sizeof(haddr_t) * num_entries; - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ @@ -335,18 +321,17 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, * back to the caller. Do this so that we can use the same code * to apply the candidate list to all the processes. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__broadcast_candidate_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_clean_list_cb() @@ -361,12 +346,11 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, - void *_udata) +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_addr_list_ud_t * udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ - haddr_t addr; + 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; FUNC_ENTER_STATIC_NOERR @@ -375,7 +359,7 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, HDassert(udata); /* Store the entry's address in the buffer */ - addr = slist_entry_ptr->addr; + addr = slist_entry_ptr->addr; udata->addr_buf_ptr[udata->u] = addr; udata->u++; @@ -385,13 +369,13 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, /* and also remove the matching entry from the dirtied list * if it exists. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(udata->aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(udata->aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__broadcast_clean_list_cb() */ - /*------------------------------------------------------------------------- * * Function: H5AC__broadcast_clean_list() @@ -413,13 +397,13 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, *------------------------------------------------------------------------- */ static herr_t -H5AC__broadcast_clean_list(H5AC_t * cache_ptr) +H5AC__broadcast_clean_list(H5AC_t *cache_ptr) { - haddr_t * addr_buf_ptr = NULL; - H5AC_aux_t * aux_ptr; - int mpi_result; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t * addr_buf_ptr = NULL; + H5AC_aux_t *aux_ptr; + int mpi_result; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -436,30 +420,31 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) * any, we are done. */ num_entries = (unsigned)H5SL_count(aux_ptr->c_slist_ptr); - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { + if (num_entries > 0) { H5AC_addr_list_ud_t udata; - size_t buf_size; + size_t buf_size; /* 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))) + 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.aux_ptr = aux_ptr; udata.addr_buf_ptr = addr_buf_ptr; - udata.u = 0; + 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) + 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") /* Now broadcast the list of cleaned entries */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)addr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)addr_buf_ptr, (int)buf_size, MPI_BYTE, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ @@ -467,17 +452,16 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, addr_buf_ptr); done: - if(addr_buf_ptr) + if (addr_buf_ptr) addr_buf_ptr = (haddr_t *)H5MM_xfree((void *)addr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__broadcast_clean_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__construct_candidate_list() * @@ -499,9 +483,9 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) */ static herr_t H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_NDEBUG_UNUSED *aux_ptr, - int sync_point_op) + int sync_point_op) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -516,29 +500,30 @@ H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_NDEBUG_UNUS HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); HDassert(aux_ptr->candidate_slist_ptr != NULL); HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); - HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || (sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_CACHE)); + HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || + (sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_CACHE)); - switch(sync_point_op) { - case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5C_construct_candidate_list__min_clean((H5C_t *)cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__min_clean() failed.") - break; + switch (sync_point_op) { + case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: + if (H5C_construct_candidate_list__min_clean((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5C_construct_candidate_list__clean_cache((H5C_t *)cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_construct_candidate_list__clean_cache() failed.") - break; + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5C_construct_candidate_list__clean_cache((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "H5C_construct_candidate_list__clean_cache() failed.") + break; default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown sync point operation.") - break; + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown sync point operation.") + break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__construct_candidate_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__copy_candidate_list_to_buffer_cb @@ -553,11 +538,10 @@ 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__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_addr_list_ud_t * udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ + 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 @@ -575,7 +559,6 @@ H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__copy_candidate_list_to_buffer_cb() */ - /*------------------------------------------------------------------------- * * Function: H5AC__copy_candidate_list_to_buffer @@ -609,14 +592,14 @@ H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, */ static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) + haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr = NULL; - H5AC_addr_list_ud_t udata; - haddr_t * haddr_buf_ptr = NULL; - size_t buf_size; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t * aux_ptr = NULL; + H5AC_addr_list_ud_t udata; + haddr_t * haddr_buf_ptr = NULL; + size_t buf_size; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -639,33 +622,32 @@ H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entri * base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if(NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) + if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") /* Set up user data for callback */ - udata.aux_ptr = aux_ptr; + udata.aux_ptr = aux_ptr; udata.addr_buf_ptr = haddr_buf_ptr; - udata.u = 0; + udata.u = 0; /* Free all the candidate list entries, building the address list in the callback */ - if(H5SL_free(aux_ptr->candidate_slist_ptr, H5AC__copy_candidate_list_to_buffer_cb, &udata) < 0) + if (H5SL_free(aux_ptr->candidate_slist_ptr, H5AC__copy_candidate_list_to_buffer_cb, &udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for candidate entries") /* Pass the number of entries and the buffer pointer * back to the caller. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__copy_candidate_list_to_buffer() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_deleted_entry() @@ -686,16 +668,16 @@ 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_slist_entry_t * slist_entry_ptr = NULL; - haddr_t addr; + H5AC_t * cache_ptr; + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + haddr_t addr; FUNC_ENTER_PACKAGE_NOERR /* Sanity checks */ HDassert(entry_ptr); - addr = entry_ptr->addr; + addr = entry_ptr->addr; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); @@ -706,17 +688,16 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr->c_slist_ptr != NULL); /* if the entry appears in the dirtied entry slist, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); /* if the entry appears in the cleaned entry slist, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__log_deleted_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_dirtied_entry() @@ -741,9 +722,9 @@ 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_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -756,36 +737,37 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; - haddr_t addr = entry_ptr->addr; + haddr_t addr = entry_ptr->addr; /* Sanity checks */ HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); - if(NULL == H5SL_search(aux_ptr->d_slist_ptr, (void *)(&addr))) { + if (NULL == H5SL_search(aux_ptr->d_slist_ptr, (void *)(&addr))) { /* insert the address of the entry in the dirty entry list, and * add its size to the dirty_bytes count. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") - slist_entry_ptr->addr = addr; + slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") aux_ptr->dirty_bytes += entry_ptr->size; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->unprotect_dirty_bytes += entry_ptr->size; - aux_ptr->unprotect_dirty_bytes_updates += 1; -#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ + aux_ptr->unprotect_dirty_bytes += entry_ptr->size; + aux_ptr->unprotect_dirty_bytes_updates += 1; +#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ } /* end if */ /* the entry is dirty. If it exists on the cleaned entries list, * remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ else { @@ -794,13 +776,12 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) aux_ptr->unprotect_dirty_bytes += entry_ptr->size; aux_ptr->unprotect_dirty_bytes_updates += 1; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_dirtied_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_cleaned_entry() @@ -819,8 +800,8 @@ 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_aux_t * aux_ptr; + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -833,18 +814,20 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; - haddr_t addr = entry_ptr->addr; + haddr_t addr = entry_ptr->addr; /* Sanity checks */ HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); /* Remove it from both the cleaned list and the dirtied list. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ @@ -855,7 +838,6 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__log_cleaned_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_flushed_entry() @@ -878,13 +860,12 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) *------------------------------------------------------------------------- */ herr_t -H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, - unsigned flags) +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_slist_entry_t * slist_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t cleared; + H5AC_aux_t * aux_ptr; + H5AC_slist_entry_t *slist_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -899,32 +880,33 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, /* Set local flags */ cleared = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); - if(cleared) { + if (cleared) { /* If the entry has been cleared, must remove it from both the * cleaned list and the dirtied list. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); } /* end if */ - else if(was_dirty) { - if(NULL == H5SL_search(aux_ptr->c_slist_ptr, (void *)(&addr))) { + else if (was_dirty) { + if (NULL == H5SL_search(aux_ptr->c_slist_ptr, (void *)(&addr))) { /* insert the address of the entry in the clean entry list. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate clean slist entry .") slist_entry_ptr->addr = addr; - if(H5SL_insert(aux_ptr->c_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->c_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into clean entry slist.") } /* end if */ - } /* end else-if */ + } /* end else-if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_flushed_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_inserted_entry() @@ -948,9 +930,9 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, herr_t H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -962,27 +944,27 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); /* Entry to insert should not be in dirty list currently */ - if(NULL != H5SL_search(aux_ptr->d_slist_ptr, (const void *)(&entry_ptr->addr))) + if (NULL != H5SL_search(aux_ptr->d_slist_ptr, (const void *)(&entry_ptr->addr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Inserted entry already in dirty slist.") /* insert the address of the entry in the dirty entry list, and * add its size to the dirty_bytes count. */ - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") - slist_entry_ptr->addr = entry_ptr->addr; - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + slist_entry_ptr->addr = entry_ptr->addr; + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") /* Entry to insert should not be in clean list either */ - if(NULL != H5SL_search(aux_ptr->c_slist_ptr, (const void *)(&entry_ptr->addr))) + if (NULL != H5SL_search(aux_ptr->c_slist_ptr, (const void *)(&entry_ptr->addr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Inserted entry in clean slist.") } /* end if */ @@ -997,7 +979,6 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_inserted_entry() */ - /*------------------------------------------------------------------------- * * Function: H5AC__log_moved_entry() @@ -1047,12 +1028,12 @@ 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_aux_t * aux_ptr; - hbool_t entry_in_cache; - hbool_t entry_dirty; - size_t entry_size; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t entry_in_cache; + hbool_t entry_dirty; + size_t entry_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1066,14 +1047,14 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); /* get entry status, size, etc here */ - if(H5C_get_entry_status(f, old_addr, &entry_size, &entry_in_cache, - &entry_dirty, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5C_get_entry_status(f, old_addr, &entry_size, &entry_in_cache, &entry_dirty, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get entry status.") - if(!entry_in_cache) + if (!entry_in_cache) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry not in cache.") - if(aux_ptr->mpi_rank == 0) { - H5AC_slist_entry_t * slist_entry_ptr; + if (aux_ptr->mpi_rank == 0) { + H5AC_slist_entry_t *slist_entry_ptr; HDassert(aux_ptr->d_slist_ptr != NULL); HDassert(aux_ptr->c_slist_ptr != NULL); @@ -1081,24 +1062,26 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) /* if the entry appears in the cleaned entry slist, under its old * address, remove it. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&old_addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)(&old_addr)))) slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, slist_entry_ptr); /* if the entry appears in the dirtied entry slist under its old * address, remove it, but don't free it. Set addr to new_addr. */ - if(NULL != (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&old_addr)))) + if (NULL != + (slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)(&old_addr)))) slist_entry_ptr->addr = new_addr; else { - /* otherwise, allocate a new entry that is ready - * for insertion, and increment dirty_bytes. - * - * Note that the fact that the entry wasn't in the dirtied - * list under its old address implies that it must have - * been clean to start with. - */ + /* otherwise, allocate a new entry that is ready + * for insertion, and increment dirty_bytes. + * + * Note that the fact that the entry wasn't in the dirtied + * list under its old address implies that it must have + * been clean to start with. + */ HDassert(!entry_dirty); - if(NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) + if (NULL == (slist_entry_ptr = H5FL_MALLOC(H5AC_slist_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate dirty slist entry .") slist_entry_ptr->addr = new_addr; @@ -1107,27 +1090,26 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) #if H5AC_DEBUG_DIRTY_BYTES_CREATION aux_ptr->move_dirty_bytes += entry_size; aux_ptr->move_dirty_bytes_updates += 1; -#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ +#endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ } /* end else */ /* insert / reinsert the entry in the dirty slist */ - if(H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) + if (H5SL_insert(aux_ptr->d_slist_ptr, slist_entry_ptr, &(slist_entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert entry into dirty entry slist.") } /* end if */ - else if(!entry_dirty) { + else if (!entry_dirty) { aux_ptr->dirty_bytes += entry_size; #if H5AC_DEBUG_DIRTY_BYTES_CREATION aux_ptr->move_dirty_bytes += entry_size; aux_ptr->move_dirty_bytes_updates += 1; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - } /* end else-if */ + } /* end else-if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__log_moved_entry() */ - /*------------------------------------------------------------------------- * Function: H5AC__propagate_and_apply_candidate_list * @@ -1224,14 +1206,14 @@ 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__propagate_and_apply_candidate_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - haddr_t * candidates_list_ptr = NULL; - int mpi_result; - unsigned num_candidates = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * candidates_list_ptr = NULL; + int mpi_result; + unsigned num_candidates = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1247,22 +1229,22 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) /* to prevent "messages from the future" we must synchronize all * processes before we write any entries. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - if(aux_ptr->mpi_rank == 0) { - if(H5AC__broadcast_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) + if (aux_ptr->mpi_rank == 0) { + if (H5AC__broadcast_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't broadcast candidate slist.") HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); } /* end if */ else { - if(H5AC__receive_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) + if (H5AC__receive_candidate_list(cache_ptr, &num_candidates, &candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive candidate broadcast.") } /* end else */ - if(num_candidates > 0) { - herr_t result; + if (num_candidates > 0) { + herr_t result; /* all processes apply the candidate list. * H5C_apply_candidate_list() handles the details of @@ -1273,34 +1255,34 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) aux_ptr->write_permitted = TRUE; /* Apply the candidate list */ - result = H5C_apply_candidate_list(f, cache_ptr, num_candidates, - candidates_list_ptr, aux_ptr->mpi_rank, aux_ptr->mpi_size); + result = H5C_apply_candidate_list(f, cache_ptr, num_candidates, candidates_list_ptr, + aux_ptr->mpi_rank, aux_ptr->mpi_size); /* Disable writes again */ aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't apply candidate list.") /* 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 (aux_ptr->write_done) + (aux_ptr->write_done)(); - /* to prevent "messages from the past" we must synchronize all + /* To prevent "messages from the past" we must synchronize all * processes again before we go on. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - /* if this is process zero, tidy up the dirtied, + /* if this is process zero, tidy up the dirtied, * and flushed and still clean lists. */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__tidy_cache_0_lists(cache_ptr, num_candidates, candidates_list_ptr) < 0) + if (aux_ptr->mpi_rank == 0) + if (H5AC__tidy_cache_0_lists(cache_ptr, num_candidates, candidates_list_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't tidy up process 0 lists.") } /* end if */ @@ -1308,17 +1290,16 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_candidates, candidates_list_ptr); done: - if(candidates_list_ptr) + if (candidates_list_ptr) candidates_list_ptr = (haddr_t *)H5MM_xfree((void *)candidates_list_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__propagate_and_apply_candidate_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__propagate_flushed_and_still_clean_entries_list * @@ -1391,11 +1372,11 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) *------------------------------------------------------------------------- */ static herr_t -H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) +H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1408,20 +1389,18 @@ H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); - if(aux_ptr->mpi_rank == 0) { - if(H5AC__broadcast_clean_list(cache_ptr) < 0) + if (aux_ptr->mpi_rank == 0) { + if (H5AC__broadcast_clean_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't broadcast clean slist.") HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); } /* end if */ - else - if(H5AC__receive_and_apply_clean_list(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive and/or process clean slist broadcast.") + else if (H5AC__receive_and_apply_clean_list(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't receive and/or process clean slist broadcast.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__propagate_flushed_and_still_clean_entries_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_haddr_list() @@ -1443,13 +1422,12 @@ H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) *------------------------------------------------------------------------- */ static herr_t -H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - haddr_t * haddr_buf_ptr = NULL; - int mpi_result; - unsigned num_entries; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t *haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1463,37 +1441,37 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, * can set up a buffer to receive them. If there aren't * any, we are done. */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&num_entries, 1, MPI_UNSIGNED, 0, mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - if(num_entries > 0) { + if (num_entries > 0) { size_t buf_size; /* 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))) + if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") /* Now receive the list of candidate entries */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast((void *)haddr_buf_ptr, (int)buf_size, MPI_BYTE, 0, mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ /* finally, pass the number of entries and the buffer pointer * back to the caller. */ - *num_entries_ptr = num_entries; + *num_entries_ptr = num_entries; *haddr_buf_ptr_ptr = haddr_buf_ptr; done: - if(ret_value < 0) - if(haddr_buf_ptr) + if (ret_value < 0) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_haddr_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_and_apply_clean_list() @@ -1515,11 +1493,11 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, static herr_t H5AC__receive_and_apply_clean_list(H5F_t *f) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; - haddr_t * haddr_buf_ptr = NULL; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * haddr_buf_ptr = NULL; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1533,29 +1511,28 @@ H5AC__receive_and_apply_clean_list(H5F_t *f) HDassert(aux_ptr->mpi_rank != 0); /* Retrieve the clean list from process 0 */ - if(H5AC__receive_haddr_list(aux_ptr->mpi_comm, &num_entries, &haddr_buf_ptr) < 0) + if (H5AC__receive_haddr_list(aux_ptr->mpi_comm, &num_entries, &haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't receive clean list") - if(num_entries > 0) - /* mark the indicated entries as clean */ - if(H5C_mark_entries_as_clean(f, num_entries, haddr_buf_ptr) < 0) + if (num_entries > 0) + /* Mark the indicated entries as clean */ + if (H5C_mark_entries_as_clean(f, num_entries, haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't mark entries clean.") /* if it is defined, call the sync point done callback. Note * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, haddr_buf_ptr); done: - if(haddr_buf_ptr) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_and_apply_clean_list() */ - /*------------------------------------------------------------------------- * * Function: H5AC__receive_candidate_list() @@ -1577,11 +1554,10 @@ H5AC__receive_and_apply_clean_list(H5F_t *f) *------------------------------------------------------------------------- */ static herr_t -H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, - haddr_t **haddr_buf_ptr_ptr) +H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1591,21 +1567,20 @@ H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank != 0); - HDassert(aux_ptr-> metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); + HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); HDassert(num_entries_ptr != NULL); HDassert(*num_entries_ptr == 0); HDassert(haddr_buf_ptr_ptr != NULL); HDassert(*haddr_buf_ptr_ptr == NULL); /* Retrieve the candidate list from process 0 */ - if(H5AC__receive_haddr_list(aux_ptr->mpi_comm, num_entries_ptr, haddr_buf_ptr_ptr) < 0) + if (H5AC__receive_haddr_list(aux_ptr->mpi_comm, num_entries_ptr, haddr_buf_ptr_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't receive clean list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__receive_candidate_list() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__dist_md_write__flush * @@ -1658,12 +1633,12 @@ 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_aux_t * aux_ptr; - haddr_t * haddr_buf_ptr = NULL; - int mpi_result; - unsigned num_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + haddr_t * haddr_buf_ptr = NULL; + int mpi_result; + unsigned num_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1679,16 +1654,16 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) /* first construct the candidate list -- initially, this will be in the * form of a skip list. We will convert it later. */ - if(H5C_construct_candidate_list__clean_cache(cache_ptr) < 0) + if (H5C_construct_candidate_list__clean_cache(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") - if(H5SL_count(aux_ptr->candidate_slist_ptr) > 0) { - herr_t result; + if (H5SL_count(aux_ptr->candidate_slist_ptr) > 0) { + herr_t result; /* convert the candidate list into the format we * are used to receiving from process 0. */ - if(H5AC__copy_candidate_list_to_buffer(cache_ptr, &num_entries, &haddr_buf_ptr) < 0) + if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &num_entries, &haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") /* Initial sync point barrier @@ -1696,40 +1671,40 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) * When flushing from within the close operation from a file, * it's possible to skip this barrier (on the second flush of the cache). */ - if(!H5CX_get_mpi_file_flushing()) - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (!H5CX_get_mpi_file_flushing()) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) /* Enable writes during this operation */ aux_ptr->write_permitted = TRUE; /* Apply the candidate list */ - result = H5C_apply_candidate_list(f, cache_ptr, num_entries, - haddr_buf_ptr, aux_ptr->mpi_rank, aux_ptr->mpi_size); + result = H5C_apply_candidate_list(f, cache_ptr, num_entries, haddr_buf_ptr, aux_ptr->mpi_rank, + aux_ptr->mpi_size); /* Disable writes again */ aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't apply candidate list.") /* 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) + if (aux_ptr->write_done) (aux_ptr->write_done)(); /* final sync point barrier */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - /* if this is process zero, tidy up the dirtied, + /* if this is process zero, tidy up the dirtied, * and flushed and still clean lists. */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__tidy_cache_0_lists(cache_ptr, num_entries, haddr_buf_ptr) < 0) + if (aux_ptr->mpi_rank == 0) + if (H5AC__tidy_cache_0_lists(cache_ptr, num_entries, haddr_buf_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't tidy up process 0 lists.") } /* end if */ @@ -1737,17 +1712,16 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) * that this callback is defined purely for testing purposes, * and should be undefined under normal operating circumstances. */ - if(aux_ptr->sync_point_done) + if (aux_ptr->sync_point_done) (aux_ptr->sync_point_done)(num_entries, haddr_buf_ptr); done: - if(haddr_buf_ptr) + if (haddr_buf_ptr) haddr_buf_ptr = (haddr_t *)H5MM_xfree((void *)haddr_buf_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__dist_md_write__flush() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__dist_md_write__flush_to_min_clean * @@ -1805,10 +1779,10 @@ 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_aux_t * aux_ptr; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1822,17 +1796,18 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); /* Query if evictions are allowed */ - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_get_evictions_enabled() failed.") - if(evictions_enabled) { + if (evictions_enabled) { /* construct candidate list -- process 0 only */ - if(aux_ptr->mpi_rank == 0) - if(H5AC__construct_candidate_list(cache_ptr, aux_ptr, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) + if (aux_ptr->mpi_rank == 0) + 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.") /* propagate and apply candidate list -- all processes */ - if(H5AC__propagate_and_apply_candidate_list(f) < 0) + if (H5AC__propagate_and_apply_candidate_list(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate and apply candidate list.") } /* evictions enabled */ @@ -1840,7 +1815,6 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__dist_md_write__flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__p0_only__flush * @@ -1882,10 +1856,10 @@ 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_aux_t * aux_ptr; - int mpi_result; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + int mpi_result; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1896,8 +1870,7 @@ H5AC__rsp__p0_only__flush(H5F_t *f) aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - HDassert(aux_ptr->metadata_write_strategy == \ - H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); + HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); /* To prevent "messages from the future" we must * synchronize all processes before we start the flush. @@ -1906,16 +1879,16 @@ H5AC__rsp__p0_only__flush(H5F_t *f) * However, when flushing from within the close operation from a file, * it's possible to skip this barrier (on the second flush of the cache). */ - if ( ! H5CX_get_mpi_file_flushing() ) { + if (!H5CX_get_mpi_file_flushing()) { - if ( MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm)) ) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) } /* Flush data to disk, from rank 0 process */ - if(aux_ptr->mpi_rank == 0) { - herr_t result; + if (aux_ptr->mpi_rank == 0) { + herr_t result; /* Enable writes during this operation */ aux_ptr->write_permitted = TRUE; @@ -1927,33 +1900,25 @@ H5AC__rsp__p0_only__flush(H5F_t *f) aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if ( result < 0 ) - + 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 ) { - + if (aux_ptr->write_done) (aux_ptr->write_done)(); - } } /* end if */ /* Propagate cleaned entries to other ranks. */ - if ( H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0 ) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't propagate clean entries list.") + if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate clean entries list.") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5AC__rsp__p0_only__flush() */ - /*------------------------------------------------------------------------- * Function: H5AC__rsp__p0_only__flush_to_min_clean * @@ -1999,10 +1964,10 @@ 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_aux_t * aux_ptr; - hbool_t evictions_enabled; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + hbool_t evictions_enabled; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2016,7 +1981,7 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); /* Query if evictions are allowed */ - if(H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) + if (H5C_get_evictions_enabled((const H5C_t *)cache_ptr, &evictions_enabled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_get_evictions_enabled() failed.") /* Flush if evictions are allowed -- following call @@ -2026,18 +1991,18 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) * * Otherwise, do nothing. */ - if(evictions_enabled) { - int mpi_result; + if (evictions_enabled) { + int mpi_result; /* to prevent "messages from the future" we must synchronize all * processes before we start the flush. This synchronization may * already be done -- hence the do_barrier parameter. */ - if(MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - if(0 == aux_ptr->mpi_rank) { - herr_t result; + if (0 == aux_ptr->mpi_rank) { + herr_t result; /* here, process 0 flushes as many entries as necessary to * comply with the currently specified min clean size. @@ -2055,18 +2020,18 @@ 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) + 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. + * to enforce POSIX semantics on the process used to simulate + * reads and writes in t_cache.c. */ - if(aux_ptr->write_done) + if (aux_ptr->write_done) (aux_ptr->write_done)(); } /* end if */ - if(H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) + if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't propagate clean entries list.") } /* end if */ @@ -2074,7 +2039,6 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__rsp__p0_only__flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5AC__run_sync_point * @@ -2109,9 +2073,9 @@ 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_aux_t * aux_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_t * cache_ptr; + H5AC_aux_t *aux_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2129,18 +2093,12 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || (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, - 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); + HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/r/ru) = %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); #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ /* clear collective access flag on half of the entries in the @@ -2148,56 +2106,58 @@ HDfprintf(stdout, evicted later. All ranks are guaranteed to mark the same entries since we don't modify the order of the collectively accessed entries except through collective access. */ - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.") - switch(aux_ptr->metadata_write_strategy) { + switch (aux_ptr->metadata_write_strategy) { case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - switch(sync_point_op) { + switch (sync_point_op) { case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5AC__rsp__p0_only__flush_to_min_clean(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__p0_only__flush_to_min_clean() failed.") - break; + if (H5AC__rsp__p0_only__flush_to_min_clean(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, + "H5AC__rsp__p0_only__flush_to_min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5AC__rsp__p0_only__flush(f) < 0) + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5AC__rsp__p0_only__flush(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__p0_only__flush() failed.") - break; + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown flush op"); - break; - } /* end switch */ - break; + break; + } /* end switch */ + break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: - switch(sync_point_op) { + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + switch (sync_point_op) { case H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN: - if(H5AC__rsp__dist_md_write__flush_to_min_clean(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__dist_md_write__flush_to_min_clean() failed.") - break; + if (H5AC__rsp__dist_md_write__flush_to_min_clean(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, + "H5AC__rsp__dist_md_write__flush_to_min_clean() failed.") + break; - case H5AC_SYNC_POINT_OP__FLUSH_CACHE: - if(H5AC__rsp__dist_md_write__flush(f) < 0) + case H5AC_SYNC_POINT_OP__FLUSH_CACHE: + if (H5AC__rsp__dist_md_write__flush(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5AC__rsp__dist_md_write__flush() failed.") - break; + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown flush op"); - break; - } /* end switch */ - break; + break; + } /* end switch */ + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown metadata write strategy.") - break; + break; } /* end switch */ /* reset the dirty bytes count */ aux_ptr->dirty_bytes = 0; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - aux_ptr->dirty_bytes_propagations += 1; + aux_ptr->dirty_bytes_propagations += 1; aux_ptr->unprotect_dirty_bytes = 0; aux_ptr->unprotect_dirty_bytes_updates = 0; aux_ptr->insert_dirty_bytes = 0; @@ -2211,7 +2171,6 @@ HDfprintf(stdout, FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__run_sync_point() */ - /*------------------------------------------------------------------------- * Function: H5AC__tidy_cache_0_lists() * @@ -2248,11 +2207,10 @@ HDfprintf(stdout, *------------------------------------------------------------------------- */ static herr_t -H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, - haddr_t *candidates_list_ptr) +H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr) { - H5AC_aux_t * aux_ptr; - unsigned u; + H5AC_aux_t *aux_ptr; + unsigned u; FUNC_ENTER_STATIC_NOERR @@ -2273,26 +2231,27 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, * cleaned list. However, for this metadata write strategy, * we just want to remove all references to the candidate entries. */ - for(u = 0; u < num_candidates; u++) { - H5AC_slist_entry_t * d_slist_entry_ptr; - H5AC_slist_entry_t * c_slist_entry_ptr; - haddr_t addr; + for (u = 0; u < num_candidates; u++) { + H5AC_slist_entry_t *d_slist_entry_ptr; + H5AC_slist_entry_t *c_slist_entry_ptr; + haddr_t addr; addr = candidates_list_ptr[u]; /* addr may be either on the dirtied list, or on the flushed * and still clean list. Remove it. */ - if(NULL != (d_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)&addr))) + if (NULL != + (d_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->d_slist_ptr, (void *)&addr))) d_slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, d_slist_entry_ptr); - if(NULL != (c_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)&addr))) + if (NULL != + (c_slist_entry_ptr = (H5AC_slist_entry_t *)H5SL_remove(aux_ptr->c_slist_ptr, (void *)&addr))) c_slist_entry_ptr = H5FL_FREE(H5AC_slist_entry_t, c_slist_entry_ptr); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5AC__tidy_cache_0_lists() */ - /*------------------------------------------------------------------------- * Function: H5AC__flush_entries * @@ -2311,7 +2270,7 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, herr_t H5AC__flush_entries(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2320,12 +2279,11 @@ H5AC__flush_entries(H5F_t *f) HDassert(f->shared->cache); /* Check if we have >1 ranks */ - if(H5C_get_aux_ptr(f->shared->cache)) - if(H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_CACHE) < 0) + if (H5C_get_aux_ptr(f->shared->cache)) + if (H5AC__run_sync_point(f, H5AC_SYNC_POINT_OP__FLUSH_CACHE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__flush_entries() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 86ff385f99b..7da46a05448 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -30,16 +30,15 @@ #error "Do not include this file outside the H5AC package!" #endif -#ifndef _H5ACpkg_H -#define _H5ACpkg_H +#ifndef H5ACpkg_H +#define H5ACpkg_H /* Get package's private header */ -#include "H5ACprivate.h" /* Metadata cache */ - +#include "H5ACprivate.h" /* Metadata cache */ /* Get needed headers */ -#include "H5Cprivate.h" /* Cache */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Cprivate.h" /* Cache */ +#include "H5FLprivate.h" /* Free Lists */ /*****************************/ /* Package Private Variables */ @@ -48,12 +47,11 @@ /* Declare extern the free list to manage the H5AC_aux_t struct */ H5FL_EXTERN(H5AC_aux_t); - /**************************/ /* Package Private Macros */ /**************************/ -#define H5AC_DEBUG_DIRTY_BYTES_CREATION 0 +#define H5AC_DEBUG_DIRTY_BYTES_CREATION 0 #ifdef H5_HAVE_PARALLEL @@ -61,8 +59,8 @@ H5FL_EXTERN(H5AC_aux_t); * at a sync point. */ -#define H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN 0 -#define H5AC_SYNC_POINT_OP__FLUSH_CACHE 1 +#define H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN 0 +#define H5AC_SYNC_POINT_OP__FLUSH_CACHE 1 #endif /* H5_HAVE_PARALLEL */ @@ -73,12 +71,9 @@ H5FL_EXTERN(H5AC_aux_t); *------------------------------------------------------------------------- */ -#define H5AC__MIN_DIRTY_BYTES_THRESHOLD (size_t) \ - (H5C__MIN_MAX_CACHE_SIZE / 2) -#define H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD (256 * 1024) -#define H5AC__MAX_DIRTY_BYTES_THRESHOLD (size_t) \ - (H5C__MAX_MAX_CACHE_SIZE / 4) - +#define H5AC__MIN_DIRTY_BYTES_THRESHOLD (size_t)(H5C__MIN_MAX_CACHE_SIZE / 2) +#define H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD (256 * 1024) +#define H5AC__MAX_DIRTY_BYTES_THRESHOLD (size_t)(H5C__MAX_MAX_CACHE_SIZE / 4) /**************************************************************************** * @@ -359,57 +354,54 @@ H5FL_EXTERN(H5AC_aux_t); #ifdef H5_HAVE_PARALLEL -#define H5AC__H5AC_AUX_T_MAGIC (unsigned)0x00D0A01 +#define H5AC__H5AC_AUX_T_MAGIC (unsigned)0x00D0A01 -typedef struct H5AC_aux_t -{ - uint32_t magic; +typedef struct H5AC_aux_t { + uint32_t magic; - MPI_Comm mpi_comm; + MPI_Comm mpi_comm; - int mpi_rank; + int mpi_rank; - int mpi_size; + int mpi_size; - hbool_t write_permitted; + hbool_t write_permitted; - size_t dirty_bytes_threshold; + size_t dirty_bytes_threshold; - size_t dirty_bytes; + size_t dirty_bytes; - int32_t metadata_write_strategy; + int32_t metadata_write_strategy; #if H5AC_DEBUG_DIRTY_BYTES_CREATION - unsigned dirty_bytes_propagations; + unsigned dirty_bytes_propagations; - size_t unprotect_dirty_bytes; - unsigned unprotect_dirty_bytes_updates; + size_t unprotect_dirty_bytes; + unsigned unprotect_dirty_bytes_updates; - size_t insert_dirty_bytes; - unsigned insert_dirty_bytes_updates; + size_t insert_dirty_bytes; + unsigned insert_dirty_bytes_updates; - size_t move_dirty_bytes; - unsigned move_dirty_bytes_updates; + size_t move_dirty_bytes; + unsigned move_dirty_bytes_updates; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - H5SL_t * d_slist_ptr; + H5SL_t *d_slist_ptr; - H5SL_t * c_slist_ptr; + H5SL_t *c_slist_ptr; - H5SL_t * candidate_slist_ptr; + H5SL_t *candidate_slist_ptr; - void (* write_done)(void); + void (*write_done)(void); - void (* sync_point_done)(unsigned num_writes, - haddr_t * written_entries_tbl); + void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl); - unsigned p0_image_len; + unsigned p0_image_len; } H5AC_aux_t; /* struct H5AC_aux_t */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ /******************************/ /* Package Private Prototypes */ @@ -420,18 +412,15 @@ typedef struct H5AC_aux_t H5_DLL herr_t H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr); H5_DLL herr_t H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr); H5_DLL herr_t H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr); -H5_DLL herr_t H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, - hbool_t was_dirty, unsigned flags); +H5_DLL herr_t H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags); H5_DLL herr_t H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr); -H5_DLL herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, - haddr_t new_addr); +H5_DLL herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC__flush_entries(H5F_t *f); H5_DLL herr_t H5AC__run_sync_point(H5F_t *f, int sync_point_op); H5_DLL herr_t H5AC__set_sync_point_done_callback(H5C_t *cache_ptr, - void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl)); -H5_DLL herr_t H5AC__set_write_done_callback(H5C_t * cache_ptr, - void (* write_done)(void)); + void (*sync_point_done)(unsigned num_writes, + haddr_t *written_entries_tbl)); +H5_DLL herr_t H5AC__set_write_done_callback(H5C_t *cache_ptr, void (*write_done)(void)); #endif /* H5_HAVE_PARALLEL */ -#endif /* _H5ACpkg_H */ - +#endif /* H5ACpkg_H */ diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 575c791c49d..283989da4ef 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -6,77 +6,77 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: H5ACprivate.h - * Jul 9 1997 - * Robb Matzke + * Created: H5ACprivate.h + * Jul 9 1997 + * Robb Matzke * - * Purpose: Constants and typedefs available to the rest of the - * library. + * Purpose: Constants and typedefs available to the rest of the + * library. * *------------------------------------------------------------------------- */ -#ifndef _H5ACprivate_H -#define _H5ACprivate_H +#ifndef H5ACprivate_H +#define H5ACprivate_H -#include "H5ACpublic.h" /*public prototypes */ +#include "H5ACpublic.h" /*public prototypes */ /* Pivate headers needed by this header */ -#include "H5private.h" /* Generic Functions */ -#include "H5Cprivate.h" /* Cache */ -#include "H5Fprivate.h" /* File access */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Fprivate.h" /* File access */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ /* Global metadata tag values */ -#define H5AC__INVALID_TAG (haddr_t)0 -#define H5AC__IGNORE_TAG (haddr_t)1 -#define H5AC__COPIED_TAG (haddr_t)2 -#define H5AC__SUPERBLOCK_TAG (haddr_t)3 -#define H5AC__FREESPACE_TAG (haddr_t)4 -#define H5AC__SOHM_TAG (haddr_t)5 -#define H5AC__GLOBALHEAP_TAG (haddr_t)6 +#define H5AC__INVALID_TAG (haddr_t)0 +#define H5AC__IGNORE_TAG (haddr_t)1 +#define H5AC__COPIED_TAG (haddr_t)2 +#define H5AC__SUPERBLOCK_TAG (haddr_t)3 +#define H5AC__FREESPACE_TAG (haddr_t)4 +#define H5AC__SOHM_TAG (haddr_t)5 +#define H5AC__GLOBALHEAP_TAG (haddr_t)6 /* Types of metadata objects cached */ typedef enum { - H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ - H5AC_SNODE_ID, /* ( 1) symbol table nodes */ - H5AC_LHEAP_PRFX_ID, /* ( 2) local heap prefix */ - H5AC_LHEAP_DBLK_ID, /* ( 3) local heap data block */ - H5AC_GHEAP_ID, /* ( 4) global heap */ - H5AC_OHDR_ID, /* ( 5) object header */ - H5AC_OHDR_CHK_ID, /* ( 6) object header chunk */ - H5AC_BT2_HDR_ID, /* ( 7) v2 B-tree header */ - H5AC_BT2_INT_ID, /* ( 8) v2 B-tree internal node */ - H5AC_BT2_LEAF_ID, /* ( 9) v2 B-tree leaf node */ - H5AC_FHEAP_HDR_ID, /* (10) fractal heap header */ - H5AC_FHEAP_DBLOCK_ID, /* (11) fractal heap direct block */ - H5AC_FHEAP_IBLOCK_ID, /* (12) fractal heap indirect block */ - H5AC_FSPACE_HDR_ID, /* (13) free space header */ - H5AC_FSPACE_SINFO_ID, /* (14) free space sections */ - H5AC_SOHM_TABLE_ID, /* (15) shared object header message master table */ - H5AC_SOHM_LIST_ID, /* (16) shared message index stored as a list */ - H5AC_EARRAY_HDR_ID, /* (17) extensible array header */ - H5AC_EARRAY_IBLOCK_ID, /* (18) extensible array index block */ - H5AC_EARRAY_SBLOCK_ID, /* (19) extensible array super block */ - H5AC_EARRAY_DBLOCK_ID, /* (20) extensible array data block */ - H5AC_EARRAY_DBLK_PAGE_ID, /* (21) extensible array data block page */ - H5AC_FARRAY_HDR_ID, /* (22) fixed array header */ - H5AC_FARRAY_DBLOCK_ID, /* (23) fixed array data block */ - H5AC_FARRAY_DBLK_PAGE_ID, /* (24) fixed array data block page */ - H5AC_SUPERBLOCK_ID, /* (25) file superblock */ - H5AC_DRVRINFO_ID, /* (26) driver info block (supplements superblock) */ - H5AC_EPOCH_MARKER_ID, /* (27) epoch marker - always internal to cache */ - H5AC_PROXY_ENTRY_ID, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY_ID, /* (29) prefetched entry - always internal to cache */ - H5AC_NTYPES /* Number of types, must be last */ + H5AC_BT_ID = 0, /* ( 0) B-tree nodes */ + H5AC_SNODE_ID, /* ( 1) symbol table nodes */ + H5AC_LHEAP_PRFX_ID, /* ( 2) local heap prefix */ + H5AC_LHEAP_DBLK_ID, /* ( 3) local heap data block */ + H5AC_GHEAP_ID, /* ( 4) global heap */ + H5AC_OHDR_ID, /* ( 5) object header */ + H5AC_OHDR_CHK_ID, /* ( 6) object header chunk */ + H5AC_BT2_HDR_ID, /* ( 7) v2 B-tree header */ + H5AC_BT2_INT_ID, /* ( 8) v2 B-tree internal node */ + H5AC_BT2_LEAF_ID, /* ( 9) v2 B-tree leaf node */ + H5AC_FHEAP_HDR_ID, /* (10) fractal heap header */ + H5AC_FHEAP_DBLOCK_ID, /* (11) fractal heap direct block */ + H5AC_FHEAP_IBLOCK_ID, /* (12) fractal heap indirect block */ + H5AC_FSPACE_HDR_ID, /* (13) free space header */ + H5AC_FSPACE_SINFO_ID, /* (14) free space sections */ + H5AC_SOHM_TABLE_ID, /* (15) shared object header message master table */ + H5AC_SOHM_LIST_ID, /* (16) shared message index stored as a list */ + H5AC_EARRAY_HDR_ID, /* (17) extensible array header */ + H5AC_EARRAY_IBLOCK_ID, /* (18) extensible array index block */ + H5AC_EARRAY_SBLOCK_ID, /* (19) extensible array super block */ + H5AC_EARRAY_DBLOCK_ID, /* (20) extensible array data block */ + H5AC_EARRAY_DBLK_PAGE_ID, /* (21) extensible array data block page */ + H5AC_FARRAY_HDR_ID, /* (22) fixed array header */ + H5AC_FARRAY_DBLOCK_ID, /* (23) fixed array data block */ + H5AC_FARRAY_DBLK_PAGE_ID, /* (24) fixed array data block page */ + H5AC_SUPERBLOCK_ID, /* (25) file superblock */ + H5AC_DRVRINFO_ID, /* (26) driver info block (supplements superblock) */ + H5AC_EPOCH_MARKER_ID, /* (27) epoch marker - always internal to cache */ + H5AC_PROXY_ENTRY_ID, /* (28) cache entry proxy */ + H5AC_PREFETCHED_ENTRY_ID, /* (29) prefetched entry - always internal to cache */ + H5AC_NTYPES /* Number of types, must be last */ } H5AC_type_t; /* H5AC_DUMP_STATS_ON_CLOSE should always be FALSE when @@ -90,30 +90,30 @@ typedef enum { * * NOTE: test/cache plays games with the f->shared->cache, and thus * setting H5AC_DUMP_STATS_ON_CLOSE will generate constant, - * irrelevant data when run with that test program. See - * comments on setup_cache() / takedown_cache() in test/cache_common.c. + * irrelevant data when run with that test program. See + * comments on setup_cache() / takedown_cache() in test/cache_common.c. * for details. * - * If you need to dump stats at file close in test/cache.c, - * use the dump_stats parameter to takedown_cache(), or call - * H5C_stats() directly. - * JRM -- 4/12/15 + * If you need to dump stats at file close in test/cache.c, + * use the dump_stats parameter to takedown_cache(), or call + * H5C_stats() directly. + * JRM -- 4/12/15 * * Added the H5AC_DUMP_IMAGE_STATS_ON_CLOSE #define, which works much * the same way as H5AC_DUMP_STATS_ON_CLOSE. However, the set of stats * displayed is much smaller, and directed purely at the cache image feature. * - * JRM -- 11/1/15 + * JRM -- 11/1/15 */ #if H5C_COLLECT_CACHE_STATS -#define H5AC_DUMP_STATS_ON_CLOSE 0 -#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 +#define H5AC_DUMP_STATS_ON_CLOSE 0 +#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 #else /* H5C_COLLECT_CACHE_STATS */ -#define H5AC_DUMP_STATS_ON_CLOSE 0 -#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 +#define H5AC_DUMP_STATS_ON_CLOSE 0 +#define H5AC_DUMP_IMAGE_STATS_ON_CLOSE 0 #endif /* H5C_COLLECT_CACHE_STATS */ @@ -121,8 +121,8 @@ typedef enum { * At present, these are the same as those given in H5Cprivate.h. */ -#define H5AC__DEFAULT_MAX_CACHE_SIZE H5C__DEFAULT_MAX_CACHE_SIZE -#define H5AC__DEFAULT_MIN_CLEAN_SIZE H5C__DEFAULT_MIN_CLEAN_SIZE +#define H5AC__DEFAULT_MAX_CACHE_SIZE H5C__DEFAULT_MAX_CACHE_SIZE +#define H5AC__DEFAULT_MIN_CLEAN_SIZE H5C__DEFAULT_MIN_CLEAN_SIZE /* Check if we are sanity checking tagging */ #if H5C_DO_TAGGING_SANITY_CHECKS @@ -132,21 +132,21 @@ typedef enum { #endif /* - * Class methods pertaining to caching. Each type of cached object will + * Class methods pertaining to caching. Each type of cached object will * have a constant variable with permanent life-span that describes how * to cache the object. */ -#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG -#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG +#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG +#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG /* Cork actions: cork/uncork/get cork status of an object */ -#define H5AC__SET_CORK H5C__SET_CORK -#define H5AC__UNCORK H5C__UNCORK -#define H5AC__GET_CORKED H5C__GET_CORKED +#define H5AC__SET_CORK H5C__SET_CORK +#define H5AC__UNCORK H5C__UNCORK +#define H5AC__GET_CORKED H5C__GET_CORKED /* Aliases for the "ring" type and values */ -typedef H5C_ring_t H5AC_ring_t; +typedef H5C_ring_t H5AC_ring_t; #define H5AC_RING_INV H5C_RING_UNDEFINED #define H5AC_RING_USER H5C_RING_USER #define H5AC_RING_RDFSM H5C_RING_RDFSM @@ -156,73 +156,73 @@ typedef H5C_ring_t H5AC_ring_t; #define H5AC_RING_NTYPES H5C_RING_NTYPES /* Aliases for 'notify action' type & values */ -typedef H5C_notify_action_t H5AC_notify_action_t; -#define H5AC_NOTIFY_ACTION_AFTER_INSERT H5C_NOTIFY_ACTION_AFTER_INSERT -#define H5AC_NOTIFY_ACTION_AFTER_LOAD H5C_NOTIFY_ACTION_AFTER_LOAD -#define H5AC_NOTIFY_ACTION_AFTER_FLUSH H5C_NOTIFY_ACTION_AFTER_FLUSH -#define H5AC_NOTIFY_ACTION_BEFORE_EVICT H5C_NOTIFY_ACTION_BEFORE_EVICT -#define H5AC_NOTIFY_ACTION_ENTRY_DIRTIED H5C_NOTIFY_ACTION_ENTRY_DIRTIED -#define H5AC_NOTIFY_ACTION_ENTRY_CLEANED H5C_NOTIFY_ACTION_ENTRY_CLEANED -#define H5AC_NOTIFY_ACTION_CHILD_DIRTIED H5C_NOTIFY_ACTION_CHILD_DIRTIED -#define H5AC_NOTIFY_ACTION_CHILD_CLEANED H5C_NOTIFY_ACTION_CHILD_CLEANED +typedef H5C_notify_action_t H5AC_notify_action_t; +#define H5AC_NOTIFY_ACTION_AFTER_INSERT H5C_NOTIFY_ACTION_AFTER_INSERT +#define H5AC_NOTIFY_ACTION_AFTER_LOAD H5C_NOTIFY_ACTION_AFTER_LOAD +#define H5AC_NOTIFY_ACTION_AFTER_FLUSH H5C_NOTIFY_ACTION_AFTER_FLUSH +#define H5AC_NOTIFY_ACTION_BEFORE_EVICT H5C_NOTIFY_ACTION_BEFORE_EVICT +#define H5AC_NOTIFY_ACTION_ENTRY_DIRTIED H5C_NOTIFY_ACTION_ENTRY_DIRTIED +#define H5AC_NOTIFY_ACTION_ENTRY_CLEANED H5C_NOTIFY_ACTION_ENTRY_CLEANED +#define H5AC_NOTIFY_ACTION_CHILD_DIRTIED H5C_NOTIFY_ACTION_CHILD_DIRTIED +#define H5AC_NOTIFY_ACTION_CHILD_CLEANED H5C_NOTIFY_ACTION_CHILD_CLEANED #define H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED -#define H5AC_NOTIFY_ACTION_CHILD_SERIALIZED H5C_NOTIFY_ACTION_CHILD_SERIALIZED +#define H5AC_NOTIFY_ACTION_CHILD_SERIALIZED H5C_NOTIFY_ACTION_CHILD_SERIALIZED -#define H5AC__CLASS_NO_FLAGS_SET H5C__CLASS_NO_FLAGS_SET +#define H5AC__CLASS_NO_FLAGS_SET H5C__CLASS_NO_FLAGS_SET #define H5AC__CLASS_SPECULATIVE_LOAD_FLAG H5C__CLASS_SPECULATIVE_LOAD_FLAG /* The following flags should only appear in test code */ -#define H5AC__CLASS_SKIP_READS H5C__CLASS_SKIP_READS -#define H5AC__CLASS_SKIP_WRITES H5C__CLASS_SKIP_WRITES +#define H5AC__CLASS_SKIP_READS H5C__CLASS_SKIP_READS +#define H5AC__CLASS_SKIP_WRITES H5C__CLASS_SKIP_WRITES -typedef H5C_get_initial_load_size_func_t H5AC_get_initial_load_size_func_t; -typedef H5C_get_final_load_size_func_t H5AC_get_final_load_size_func_t; -typedef H5C_verify_chksum_func_t H5AC_verify_chksum_func_t; -typedef H5C_deserialize_func_t H5AC_deserialize_func_t; -typedef H5C_image_len_func_t H5AC_image_len_func_t; +typedef H5C_get_initial_load_size_func_t H5AC_get_initial_load_size_func_t; +typedef H5C_get_final_load_size_func_t H5AC_get_final_load_size_func_t; +typedef H5C_verify_chksum_func_t H5AC_verify_chksum_func_t; +typedef H5C_deserialize_func_t H5AC_deserialize_func_t; +typedef H5C_image_len_func_t H5AC_image_len_func_t; -#define H5AC__SERIALIZE_NO_FLAGS_SET H5C__SERIALIZE_NO_FLAGS_SET -#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG -#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG +#define H5AC__SERIALIZE_NO_FLAGS_SET H5C__SERIALIZE_NO_FLAGS_SET +#define H5AC__SERIALIZE_RESIZED_FLAG H5C__SERIALIZE_RESIZED_FLAG +#define H5AC__SERIALIZE_MOVED_FLAG H5C__SERIALIZE_MOVED_FLAG -typedef H5C_pre_serialize_func_t H5AC_pre_serialize_func_t; -typedef H5C_serialize_func_t H5AC_serialize_func_t; -typedef H5C_notify_func_t H5AC_notify_func_t; -typedef H5C_free_icr_func_t H5AC_free_icr_func_t; -typedef H5C_get_fsf_size_t H5AC_get_fsf_size_t; +typedef H5C_pre_serialize_func_t H5AC_pre_serialize_func_t; +typedef H5C_serialize_func_t H5AC_serialize_func_t; +typedef H5C_notify_func_t H5AC_notify_func_t; +typedef H5C_free_icr_func_t H5AC_free_icr_func_t; +typedef H5C_get_fsf_size_t H5AC_get_fsf_size_t; -typedef H5C_class_t H5AC_class_t; +typedef H5C_class_t H5AC_class_t; /* Cache entry info */ -typedef H5C_cache_entry_t H5AC_info_t; +typedef H5C_cache_entry_t H5AC_info_t; /* Typedef for metadata cache (defined in H5Cpkg.h) */ -typedef H5C_t H5AC_t; +typedef H5C_t H5AC_t; /* Metadata cache proxy entry type */ typedef struct H5AC_proxy_entry_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions */ - /* (MUST be first field in structure) */ + H5AC_info_t cache_info; /* Information for H5AC cache functions */ + /* (MUST be first field in structure) */ /* General fields */ - haddr_t addr; /* Address of the entry in the file */ - /* (Should be in 'temporary' address space) */ + haddr_t addr; /* Address of the entry in the file */ + /* (Should be in 'temporary' address space) */ /* Parent fields */ - H5SL_t *parents; /* Skip list to track parent addresses */ + H5SL_t *parents; /* Skip list to track parent addresses */ /* Child fields */ - size_t nchildren; /* Number of children */ - size_t ndirty_children; /* Number of dirty children */ - /* (Note that this currently duplicates some cache functionality) */ - size_t nunser_children; /* Number of unserialized children */ - /* (Note that this currently duplicates some cache functionality) */ + size_t nchildren; /* Number of children */ + size_t ndirty_children; /* Number of dirty children */ + /* (Note that this currently duplicates some cache functionality) */ + size_t nunser_children; /* Number of unserialized children */ + /* (Note that this currently duplicates some cache functionality) */ } H5AC_proxy_entry_t; /* Default cache configuration. */ -#define H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ - H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED +#define H5AC__DEFAULT_METADATA_WRITE_STRATEGY H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED +/* clang-format off */ #ifdef H5_HAVE_PARALLEL #define H5AC__DEFAULT_CACHE_CONFIG \ { \ @@ -255,9 +255,9 @@ typedef struct H5AC_proxy_entry_t { /* int epochs_before_eviction = */ 3, \ /* hbool_t apply_empty_reserve = */ TRUE, \ /* double empty_reserve = */ 0.1f, \ - /* size_t dirty_bytes_threshold = */ (256 * 1024), \ - /* int metadata_write_strategy = */ \ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ + /* size_t dirty_bytes_threshold = */ (256 * 1024), \ + /* int metadata_write_strategy = */ \ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ } #else /* H5_HAVE_PARALLEL */ #define H5AC__DEFAULT_CACHE_CONFIG \ @@ -291,9 +291,9 @@ typedef struct H5AC_proxy_entry_t { /* int epochs_before_eviction = */ 3, \ /* hbool_t apply_empty_reserve = */ TRUE, \ /* double empty_reserve = */ 0.1f, \ - /* size_t dirty_bytes_threshold = */ (256 * 1024), \ - /* int metadata_write_strategy = */ \ - H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ + /* size_t dirty_bytes_threshold = */ (256 * 1024), \ + /* int metadata_write_strategy = */ \ + H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ } #endif /* H5_HAVE_PARALLEL */ @@ -304,6 +304,7 @@ typedef struct H5AC_proxy_entry_t { /* hbool_t save_resize_status = */ FALSE, \ /* int32_t entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE \ } +/* clang-format on */ /* * Library prototypes. */ @@ -313,35 +314,34 @@ typedef struct H5AC_proxy_entry_t { * the equivalent flags from H5Cprivate.h. */ -#define H5AC__NO_FLAGS_SET H5C__NO_FLAGS_SET -#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG -#define H5AC__DELETED_FLAG H5C__DELETED_FLAG -#define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG -#define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG -#define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG -#define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG -#define H5AC__FLUSH_CLEAR_ONLY_FLAG H5C__FLUSH_CLEAR_ONLY_FLAG +#define H5AC__NO_FLAGS_SET H5C__NO_FLAGS_SET +#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG +#define H5AC__DELETED_FLAG H5C__DELETED_FLAG +#define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG +#define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG +#define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG +#define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG +#define H5AC__FLUSH_CLEAR_ONLY_FLAG H5C__FLUSH_CLEAR_ONLY_FLAG #define H5AC__FLUSH_MARKED_ENTRIES_FLAG H5C__FLUSH_MARKED_ENTRIES_FLAG #define H5AC__FLUSH_IGNORE_PROTECTED_FLAG H5C__FLUSH_IGNORE_PROTECTED_FLAG -#define H5AC__READ_ONLY_FLAG H5C__READ_ONLY_FLAG -#define H5AC__FREE_FILE_SPACE_FLAG H5C__FREE_FILE_SPACE_FLAG +#define H5AC__READ_ONLY_FLAG H5C__READ_ONLY_FLAG +#define H5AC__FREE_FILE_SPACE_FLAG H5C__FREE_FILE_SPACE_FLAG #define H5AC__TAKE_OWNERSHIP_FLAG H5C__TAKE_OWNERSHIP_FLAG -#define H5AC__FLUSH_LAST_FLAG H5C__FLUSH_LAST_FLAG -#define H5AC__FLUSH_COLLECTIVELY_FLAG H5C__FLUSH_COLLECTIVELY_FLAG - +#define H5AC__FLUSH_LAST_FLAG H5C__FLUSH_LAST_FLAG +#define H5AC__FLUSH_COLLECTIVELY_FLAG H5C__FLUSH_COLLECTIVELY_FLAG /* #defines of flags used to report entry status in the * H5AC_get_entry_status() call. */ -#define H5AC_ES__IN_CACHE 0x0001 -#define H5AC_ES__IS_DIRTY 0x0002 -#define H5AC_ES__IS_PROTECTED 0x0004 -#define H5AC_ES__IS_PINNED 0x0008 -#define H5AC_ES__IS_FLUSH_DEP_PARENT 0x0010 -#define H5AC_ES__IS_FLUSH_DEP_CHILD 0x0020 -#define H5AC_ES__IS_CORKED 0x0040 -#define H5AC_ES__IMAGE_IS_UP_TO_DATE 0x0080 +#define H5AC_ES__IN_CACHE 0x0001 +#define H5AC_ES__IS_DIRTY 0x0002 +#define H5AC_ES__IS_PROTECTED 0x0004 +#define H5AC_ES__IS_PINNED 0x0008 +#define H5AC_ES__IS_FLUSH_DEP_PARENT 0x0010 +#define H5AC_ES__IS_FLUSH_DEP_CHILD 0x0020 +#define H5AC_ES__IS_CORKED 0x0040 +#define H5AC_ES__IMAGE_IS_UP_TO_DATE 0x0080 /* Metadata entry class declarations */ H5_DLLVAR const H5AC_class_t H5AC_BT[1]; @@ -375,101 +375,87 @@ H5_DLLVAR const H5AC_class_t H5AC_EPOCH_MARKER[1]; H5_DLLVAR const H5AC_class_t H5AC_PROXY_ENTRY[1]; H5_DLLVAR const H5AC_class_t H5AC_PREFETCHED_ENTRY[1]; - /* external function declarations: */ H5_DLL herr_t H5AC_init(void); H5_DLL herr_t H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, - H5AC_cache_image_config_t * image_config_ptr); -H5_DLL herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, - unsigned *status_ptr); -H5_DLL herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t addr, void *thing, unsigned int flags); + H5AC_cache_image_config_t *image_config_ptr); +H5_DLL herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status_ptr); +H5_DLL herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, + unsigned int flags); H5_DLL herr_t H5AC_pin_protected_entry(void *thing); 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); -H5_DLL herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, - void *thing, unsigned flags); +H5_DLL herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags); H5_DLL herr_t H5AC_flush(H5F_t *f); H5_DLL herr_t H5AC_mark_entry_dirty(void *thing); H5_DLL herr_t H5AC_mark_entry_clean(void *thing); H5_DLL herr_t H5AC_mark_entry_unserialized(void *thing); H5_DLL herr_t H5AC_mark_entry_serialized(void *thing); -H5_DLL herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t old_addr, haddr_t new_addr); +H5_DLL herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC_dest(H5F_t *f); H5_DLL herr_t H5AC_evict(H5F_t *f); -H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, - haddr_t addr, unsigned flags); +H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5AC_remove_entry(void *entry); -H5_DLL herr_t H5AC_get_cache_auto_resize_config(const H5AC_t * cache_ptr, - H5AC_cache_config_t *config_ptr); -H5_DLL herr_t H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, - size_t *min_clean_size_ptr, size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_get_cache_size(H5AC_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5AC_get_cache_flush_in_progress(H5AC_t *cache_ptr, hbool_t *flush_in_progress_ptr); H5_DLL herr_t H5AC_get_cache_hit_rate(H5AC_t *cache_ptr, double *hit_rate_ptr); H5_DLL herr_t H5AC_reset_cache_hit_rate_stats(H5AC_t *cache_ptr); -H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, - H5AC_cache_config_t *config_ptr); +H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr); H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t *config_ptr); /* Cache image routines */ -H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, - hsize_t len, hbool_t rw); -H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); +H5_DLL herr_t H5AC_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); +H5_DLL herr_t H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr); H5_DLL hbool_t H5AC_cache_image_pending(const H5F_t *f); -H5_DLL herr_t H5AC_force_cache_image_load(H5F_t * f); -H5_DLL herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, - hsize_t *image_len); +H5_DLL herr_t H5AC_force_cache_image_load(H5F_t *f); +H5_DLL herr_t H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); /* Tag & Ring routines */ -H5_DLL void H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag); +H5_DLL void H5AC_tag(haddr_t metadata_tag, haddr_t *prev_tag); H5_DLL herr_t H5AC_flush_tagged_metadata(H5F_t *f, haddr_t metadata_tag); H5_DLL herr_t H5AC_evict_tagged_metadata(H5F_t *f, haddr_t metadata_tag, hbool_t match_global); H5_DLL herr_t H5AC_retag_copied_metadata(const H5F_t *f, haddr_t metadata_tag); H5_DLL herr_t H5AC_ignore_tags(const H5F_t *f); H5_DLL herr_t H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked); H5_DLL herr_t H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *ring); -H5_DLL void H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring); +H5_DLL void H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring); H5_DLL herr_t H5AC_unsettle_entry_ring(void *entry); -H5_DLL herr_t H5AC_unsettle_ring(H5F_t * f, H5AC_ring_t ring); -H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, - unsigned flags); +H5_DLL herr_t H5AC_unsettle_ring(H5F_t *f, H5AC_ring_t ring); +H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5AC_get_tag(const void *thing, /*OUT*/ haddr_t *tag); /* Virtual entry routines */ H5_DLL H5AC_proxy_entry_t *H5AC_proxy_entry_create(void); -H5_DLL herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *parent); -H5_DLL herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *parent); -H5_DLL herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, - void *child); -H5_DLL herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child); -H5_DLL herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry); +H5_DLL herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *parent); +H5_DLL herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *parent); +H5_DLL herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child); +H5_DLL herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child); +H5_DLL herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr); +H5_DLL herr_t H5AC_add_candidate(H5AC_t *cache_ptr, haddr_t addr); #endif /* H5_HAVE_PARALLEL */ /* Debugging functions */ H5_DLL herr_t H5AC_stats(const H5F_t *f); #ifndef NDEBUG -H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); -H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, - void **entry_ptr_ptr); -H5_DLL herr_t H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, - haddr_t child_addr, hbool_t *fd_exists_ptr); -H5_DLL herr_t H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, - const H5AC_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr); +H5_DLL herr_t H5AC_dump_cache(const H5F_t *f); +H5_DLL herr_t H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr); +H5_DLL herr_t H5AC_flush_dependency_exists(H5F_t *f, haddr_t parent_addr, haddr_t child_addr, + hbool_t *fd_exists_ptr); +H5_DLL herr_t H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, const H5AC_class_t *expected_type, + hbool_t *in_cache_ptr, hbool_t *type_ok_ptr); H5_DLL hbool_t H5AC_get_serialization_in_progress(H5F_t *f); H5_DLL hbool_t H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring); #endif /* NDEBUG */ /* end debugging functions */ -#endif /* !_H5ACprivate_H */ - +#endif /* H5ACprivate_H */ diff --git a/src/H5ACproxy_entry.c b/src/H5ACproxy_entry.c index 498d02330ef..b3d31b27084 100644 --- a/src/H5ACproxy_entry.c +++ b/src/H5ACproxy_entry.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,40 +25,35 @@ /****************/ /* Module Setup */ /****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ +#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache (H5AC) callbacks */ static herr_t H5AC__proxy_entry_image_len(const void *thing, size_t *image_len); -static herr_t H5AC__proxy_entry_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); +static herr_t H5AC__proxy_entry_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); static herr_t H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *thing); static herr_t H5AC__proxy_entry_free_icr(void *thing); @@ -68,28 +63,26 @@ static herr_t H5AC__proxy_entry_free_icr(void *thing); /* H5AC proxy entries inherit cache-like properties from H5AC */ const H5AC_class_t H5AC_PROXY_ENTRY[1] = {{ - H5AC_PROXY_ENTRY_ID, /* Metadata client ID */ - "Proxy entry", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - 0, /* Client class behavior flags */ - NULL, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - NULL, /* 'deserialize' callback */ - H5AC__proxy_entry_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5AC__proxy_entry_serialize, /* 'serialize' callback */ - H5AC__proxy_entry_notify, /* 'notify' callback */ - H5AC__proxy_entry_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_PROXY_ENTRY_ID, /* Metadata client ID */ + "Proxy entry", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + 0, /* Client class behavior flags */ + NULL, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + NULL, /* 'deserialize' callback */ + H5AC__proxy_entry_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5AC__proxy_entry_serialize, /* 'serialize' callback */ + H5AC__proxy_entry_notify, /* 'notify' callback */ + H5AC__proxy_entry_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -97,8 +90,6 @@ const H5AC_class_t H5AC_PROXY_ENTRY[1] = {{ /* Declare a free list to manage H5AC_proxy_entry_t objects */ H5FL_DEFINE_STATIC(H5AC_proxy_entry_t); - - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_create * @@ -115,13 +106,13 @@ H5FL_DEFINE_STATIC(H5AC_proxy_entry_t); H5AC_proxy_entry_t * H5AC_proxy_entry_create(void) { - H5AC_proxy_entry_t *pentry = NULL; /* Pointer to new proxy entry */ - H5AC_proxy_entry_t *ret_value = NULL; /* Return value */ + H5AC_proxy_entry_t *pentry = NULL; /* Pointer to new proxy entry */ + H5AC_proxy_entry_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate new proxy entry */ - if(NULL == (pentry = H5FL_CALLOC(H5AC_proxy_entry_t))) + if (NULL == (pentry = H5FL_CALLOC(H5AC_proxy_entry_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "can't allocate proxy entry") /* Set non-zero fields */ @@ -132,14 +123,13 @@ H5AC_proxy_entry_create(void) done: /* Release resources on error */ - if(!ret_value) - if(pentry) + if (!ret_value) + if (pentry) pentry = H5FL_FREE(H5AC_proxy_entry_t, pentry); FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_create() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_add_parent * @@ -155,8 +145,8 @@ H5AC_proxy_entry_create(void) herr_t H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) { - H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Parent entry's cache info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Parent entry's cache info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -165,20 +155,21 @@ H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) HDassert(pentry); /* Add parent to the list of parents */ - if(NULL == pentry->parents) - if(NULL == (pentry->parents = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to create skip list for parents of proxy entry") + if (NULL == pentry->parents) + if (NULL == (pentry->parents = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, + "unable to create skip list for parents of proxy entry") /* Insert parent address into skip list */ - if(H5SL_insert(pentry->parents, parent, &parent->addr) < 0) + if (H5SL_insert(pentry->parents, parent, &parent->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert parent into proxy's skip list") /* Add flush dependency on parent */ - if(pentry->nchildren > 0) { + if (pentry->nchildren > 0) { /* Sanity check */ HDassert(H5F_addr_defined(pentry->addr)); - if(H5AC_create_flush_dependency(parent, pentry) < 0) + if (H5AC_create_flush_dependency(parent, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "unable to set flush dependency on proxy entry") } /* end if */ @@ -186,7 +177,6 @@ H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_add_parent() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_remove_parent * @@ -202,9 +192,9 @@ H5AC_proxy_entry_add_parent(H5AC_proxy_entry_t *pentry, void *_parent) herr_t H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *_parent) { - H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Pointer to the parent entry */ - H5AC_info_t *rem_parent; /* Pointer to the removed parent entry */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_info_t *parent = (H5AC_info_t *)_parent; /* Pointer to the parent entry */ + H5AC_info_t *rem_parent; /* Pointer to the removed parent entry */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -214,31 +204,30 @@ H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *_parent) HDassert(parent); /* Remove parent from skip list */ - if(NULL == (rem_parent = (H5AC_info_t *)H5SL_remove(pentry->parents, &parent->addr))) + if (NULL == (rem_parent = (H5AC_info_t *)H5SL_remove(pentry->parents, &parent->addr))) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "unable to remove proxy entry parent from skip list") - if(!H5F_addr_eq(rem_parent->addr, parent->addr)) + if (!H5F_addr_eq(rem_parent->addr, parent->addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "removed proxy entry parent not the same as real parent") /* Shut down the skip list, if this is the last parent */ - if(0 == H5SL_count(pentry->parents)) { + if (0 == H5SL_count(pentry->parents)) { /* Sanity check */ HDassert(0 == pentry->nchildren); - if(H5SL_close(pentry->parents) < 0) + if (H5SL_close(pentry->parents) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CLOSEERROR, FAIL, "can't close proxy parent skip list") pentry->parents = NULL; } /* end if */ /* Remove flush dependency between the proxy entry and a parent */ - if(pentry->nchildren > 0) - if(H5AC_destroy_flush_dependency(parent, pentry) < 0) + if (pentry->nchildren > 0) + if (H5AC_destroy_flush_dependency(parent, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_remove_parent() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_add_child_cb * @@ -256,21 +245,21 @@ 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_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + 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 */ FUNC_ENTER_STATIC /* Add flush dependency on parent for proxy entry */ - if(H5AC_create_flush_dependency(parent, pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, H5_ITER_ERROR, "unable to set flush dependency for virtual entry") + if (H5AC_create_flush_dependency(parent, pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, H5_ITER_ERROR, + "unable to set flush dependency for virtual entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_add_child_cb() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_add_child * @@ -286,7 +275,7 @@ H5AC__proxy_entry_add_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_ud herr_t H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -295,32 +284,34 @@ H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) HDassert(child); /* Check for first child */ - if(0 == pentry->nchildren) { + if (0 == pentry->nchildren) { /* Get an address, if the proxy doesn't already have one */ - if(!H5F_addr_defined(pentry->addr)) - if(HADDR_UNDEF == (pentry->addr = H5MF_alloc_tmp(f, 1))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "temporary file space allocation failed for proxy entry") + if (!H5F_addr_defined(pentry->addr)) + if (HADDR_UNDEF == (pentry->addr = H5MF_alloc_tmp(f, 1))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "temporary file space allocation failed for proxy entry") /* Insert the proxy entry into the cache */ - if(H5AC_insert_entry(f, H5AC_PROXY_ENTRY, pentry->addr, pentry, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_PROXY_ENTRY, pentry->addr, pentry, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to cache proxy entry") /* Proxies start out clean (insertions are automatically marked dirty) */ - if(H5AC_mark_entry_clean(pentry) < 0) + if (H5AC_mark_entry_clean(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLEAN, FAIL, "can't mark proxy entry clean") /* Proxies start out serialized (insertions are automatically marked unserialized) */ - if(H5AC_mark_entry_serialized(pentry) < 0) + if (H5AC_mark_entry_serialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "can't mark proxy entry clean") - /* If there are currently parents, iterate over the list of parents, creating flush dependency on them */ - if(pentry->parents) - if(H5SL_iterate(pentry->parents, H5AC__proxy_entry_add_child_cb, pentry) < 0) + /* If there are currently parents, iterate over the list of parents, creating flush dependency on them + */ + if (pentry->parents) + if (H5SL_iterate(pentry->parents, H5AC__proxy_entry_add_child_cb, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "can't visit parents") } /* end if */ /* Add flush dependency on proxy entry */ - if(H5AC_create_flush_dependency(pentry, child) < 0) + if (H5AC_create_flush_dependency(pentry, child) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "unable to set flush dependency on proxy entry") /* Increment count of children */ @@ -330,7 +321,6 @@ H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_add_child() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_remove_child_cb * @@ -348,21 +338,21 @@ 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_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + 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 */ FUNC_ENTER_STATIC /* Remove flush dependency on parent for proxy entry */ - if(H5AC_destroy_flush_dependency(parent, pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, H5_ITER_ERROR, "unable to remove flush dependency for proxy entry") + if (H5AC_destroy_flush_dependency(parent, pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, H5_ITER_ERROR, + "unable to remove flush dependency for proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_remove_child_cb() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_remove_child * @@ -378,7 +368,7 @@ H5AC__proxy_entry_remove_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void * herr_t H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -387,26 +377,26 @@ H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) HDassert(child); /* Remove flush dependency on proxy entry */ - if(H5AC_destroy_flush_dependency(pentry, child) < 0) + if (H5AC_destroy_flush_dependency(pentry, child) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to remove flush dependency on proxy entry") /* Decrement count of children */ pentry->nchildren--; /* Check for last child */ - if(0 == pentry->nchildren) { + if (0 == pentry->nchildren) { /* Check for flush dependencies on proxy's parents */ - if(pentry->parents) + if (pentry->parents) /* Iterate over the list of parents, removing flush dependency on them */ - if(H5SL_iterate(pentry->parents, H5AC__proxy_entry_remove_child_cb, pentry) < 0) + if (H5SL_iterate(pentry->parents, H5AC__proxy_entry_remove_child_cb, pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "can't visit parents") /* Unpin proxy */ - if(H5AC_unpin_entry(pentry) < 0) + if (H5AC_unpin_entry(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin proxy entry") /* Remove proxy entry from cache */ - if(H5AC_remove_entry(pentry) < 0) + if (H5AC_remove_entry(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "unable to remove proxy entry") } /* end if */ @@ -414,7 +404,6 @@ H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_remove_child() */ - /*------------------------------------------------------------------------- * Function: H5AC_proxy_entry_dest * @@ -430,7 +419,7 @@ H5AC_proxy_entry_remove_child(H5AC_proxy_entry_t *pentry, void *child) herr_t H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -448,7 +437,6 @@ H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_dest() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_image_len * @@ -475,7 +463,6 @@ H5AC__proxy_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5AC__proxy_entry_image_len() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_serialize * @@ -492,19 +479,18 @@ H5AC__proxy_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t *image_len) */ static herr_t H5AC__proxy_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - /* Should never be invoked */ - HDassert(0 && "Invalid callback?!?"); + /* Should never be invoked */ + HDassert(0 && "Invalid callback?!?"); HERROR(H5E_CACHE, H5E_CANTSERIALIZE, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5AC__proxy_entry_serialize() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_notify * @@ -520,33 +506,33 @@ H5AC__proxy_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED * static herr_t H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) { - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(pentry); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - break; + break; - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Invalid action?!?"); #endif /* NDEBUG */ break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Invalid action?!?"); #endif /* NDEBUG */ - break; + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Sanity checks */ @@ -575,8 +561,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->ndirty_children++; /* Check for first dirty child */ - if(1 == pentry->ndirty_children) - if(H5AC_mark_entry_dirty(pentry) < 0) + if (1 == pentry->ndirty_children) + if (H5AC_mark_entry_dirty(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDIRTY, FAIL, "can't mark proxy entry dirty") break; @@ -588,8 +574,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->ndirty_children--; /* Check for last dirty child */ - if(0 == pentry->ndirty_children) - if(H5AC_mark_entry_clean(pentry) < 0) + if (0 == pentry->ndirty_children) + if (H5AC_mark_entry_clean(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLEAN, FAIL, "can't mark proxy entry clean") break; @@ -598,8 +584,8 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->nunser_children++; /* Check for first unserialized child */ - if(1 == pentry->nunser_children) - if(H5AC_mark_entry_unserialized(pentry) < 0) + if (1 == pentry->nunser_children) + if (H5AC_mark_entry_unserialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNSERIALIZE, FAIL, "can't mark proxy entry unserialized") break; @@ -611,24 +597,23 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) pentry->nunser_children--; /* Check for last unserialized child */ - if(0 == pentry->nunser_children) - if(H5AC_mark_entry_serialized(pentry) < 0) + if (0 == pentry->nunser_children) + if (H5AC_mark_entry_serialized(pentry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "can't mark proxy entry serialized") break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown notify action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC__proxy_entry_notify() */ - /*------------------------------------------------------------------------- * Function: H5AC__proxy_entry_free_icr * @@ -645,16 +630,15 @@ H5AC__proxy_entry_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5AC__proxy_entry_free_icr(void *_thing) { - H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Destroy the proxy entry */ - if(H5AC_proxy_entry_dest(pentry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to destroy proxy entry") + if (H5AC_proxy_entry_dest(pentry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to destroy proxy entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__proxy_entry_free_icr() */ - diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index e6f401060db..f8f4f289c0d 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,8 +21,8 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5ACpublic_H -#define _H5ACpublic_H +#ifndef H5ACpublic_H +#define H5ACpublic_H /* Public headers needed by this file */ #include "H5public.h" @@ -436,137 +436,354 @@ extern "C" { * ****************************************************************************/ -#define H5AC__CURR_CACHE_CONFIG_VERSION 1 -#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 +#define H5AC__CURR_CACHE_CONFIG_VERSION 1 +#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 -#define H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY 0 -#define H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED 1 +#define H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY 0 +#define H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED 1 -typedef struct H5AC_cache_config_t -{ - /* general configuration fields: */ - int version; - - hbool_t rpt_fcn_enabled; - - hbool_t open_trace_file; - hbool_t close_trace_file; - char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; - - hbool_t evictions_enabled; - - hbool_t set_initial_size; - size_t initial_size; - - double min_clean_fraction; - - size_t max_size; - size_t min_size; - - long int epoch_length; +/** + * H5AC_cache_config_t is a public structure intended for use in public APIs. + * At least in its initial incarnation, it is basically a copy of \c struct + * \c H5C_auto_size_ctl_t, minus the \c report_fcn field, and plus the + * \c dirty_bytes_threshold field. + * + * The \c report_fcn field is omitted, as including it would require us to make + * \c H5C_t structure public. + * + * The \c dirty_bytes_threshold field does not appear in \c H5C_auto_size_ctl_t, + * as synchronization between caches on different processes is handled at the \c + * H5AC level, not at the level of \c H5C. Note however that there is + * considerable interaction between this value and the other fields in this + * structure. + * + * Similarly, the \c open_trace_file, \c close_trace_file, and \c + * trace_file_name fields do not appear in \c H5C_auto_size_ctl_t, as most trace + * file issues are handled at the \c H5AC level. The one exception is storage + * of the pointer to the trace file, which is handled by \c H5C. + * + * The structure is in H5ACpublic.h as we may wish to allow different + * configuration options for metadata and raw data caches. + */ +//! +typedef struct H5AC_cache_config_t { + /* general configuration fields: */ + //! + int version; + /**< Integer field indicating the the version of the H5AC_cache_config_t + * in use. This field should be set to #H5AC__CURR_CACHE_CONFIG_VERSION + * (defined in H5ACpublic.h). */ + + hbool_t rpt_fcn_enabled; + /**< Boolean flag indicating whether the adaptive cache resize report + * function is enabled. This field should almost always be set to disabled + * (0). Since resize algorithm activity is reported via stdout, it MUST be + * set to disabled (0) on Windows machines.\n + * The report function is not supported code, and can be expected to change + * between versions of the library. Use it at your own risk. */ + + hbool_t open_trace_file; + /**< Boolean field indicating whether the + * \ref H5AC_cache_config_t.trace_file_name "trace_file_name" + * field should be used to open a trace file for the cache.\n + * The trace file is a debugging feature that allows the capture + * of top level metadata cache requests for purposes of debugging + * and/or optimization. This field should normally be set to 0, as + * trace file collection imposes considerable overhead.\n + * This field should only be set to 1 when the + * \ref H5AC_cache_config_t.trace_file_name "trace_file_name" + * contains the full path of the desired trace file, and either + * there is no open trace file on the cache, or the + * \ref H5AC_cache_config_t.close_trace_file "close_trace_file" + * field is also 1.\n + * The trace file feature is unsupported unless used at the + * direction of The HDF Group. It is intended to allow The HDF + * Group to collect a trace of cache activity in cases of occult + * failures and/or poor performance seen in the field, so as to aid + * in reproduction in the lab. If you use it absent the direction + * of The HDF Group, you are on your own. */ + + hbool_t close_trace_file; + /**< Boolean field indicating whether the current trace file + *(if any) should be closed.\n + * See the above comments on the \ref H5AC_cache_config_t.open_trace_file + * "open_trace_file" field. This field should be set to 0 unless there is + * an open trace file on the cache that you wish to close.\n + * The trace file feature is unsupported unless used at the direction of + * The HDF Group. It is intended to allow The HDF Group to collect a trace + * of cache activity in cases of occult failures and/or poor performance + * seen in the field, so as to aid in reproduction in the lab. If you use + * it absent the direction of The HDF Group, you are on your own. */ + + char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; + /**< Full path of the trace file to be opened if the + * \ref H5AC_cache_config_t.open_trace_file "open_trace_file" field is set + * to 1.\n + * In the parallel case, an ascii representation of the MPI rank of the + * process will be appended to the file name to yield a unique trace file + * name for each process.\n + * The length of the path must not exceed #H5AC__MAX_TRACE_FILE_NAME_LEN + * characters.\n + * The trace file feature is unsupported unless used at the direction of + * The HDF Group. It is intended to allow The HDF Group to collect a trace + * of cache activity in cases of occult failures and/or poor performance + * seen in the field, so as to aid in reproduction in the lab. If you use + * it absent the direction of The HDF Group, you are on your own. */ + + hbool_t evictions_enabled; + /**< A boolean flag indicating whether evictions from the metadata cache + * are enabled. This flag is initially set to enabled (1).\n + * In rare circumstances, the raw data throughput quirements may be so high + * that the user wishes to postpone metadata writes so as to reserve I/O + * throughput for raw data. The \p evictions_enabled field exists to allow + * this. However, this is an extreme step, and you have no business doing + * it unless you have read the User Guide section on metadata caching, and + * have considered all other options carefully.\n + * The \p evictions_enabled field may not be set to disabled (0) + * unless all adaptive cache resizing code is disabled via the + * \ref H5AC_cache_config_t.incr_mode "incr_mode", + * \ref H5AC_cache_config_t.flash_incr_mode "flash_incr_mode", + * \ref H5AC_cache_config_t.decr_mode "decr_mode" fields.\n + * When this flag is set to disabled (\c 0), the metadata cache will not + * attempt to evict entries to make space for new entries, and thus will + * grow without bound.\n + * Evictions will be re-enabled when this field is set back to \c 1. + * This should be done as soon as possible. */ + + hbool_t set_initial_size; + /**< Boolean flag indicating whether the cache should be created + * with a user specified initial size. */ + + size_t initial_size; + /**< If \ref H5AC_cache_config_t.set_initial_size "set_initial_size" + * is set to 1, \p initial_size must contain he desired initial size in + * bytes. This value must lie in the closed interval + * [ \p min_size, \p max_size ]. (see below) */ + + double min_clean_fraction; + /**< This field specifies the minimum fraction of the cache + * that must be kept either clean or empty.\n + * 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 + * for details. */ + + size_t max_size; + /**< Upper bound (in bytes) on the range of values that the + * adaptive cache resize code can select as the maximum cache size. */ + + 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. */ + + long int epoch_length; + /**< Number of cache accesses between runs of the adaptive cache resize + * code. 50,000 is a good starting number. */ + //! /* size increase control fields: */ + //! enum H5C_cache_incr_mode incr_mode; - - double lower_hr_threshold; - - double increment; - - hbool_t apply_max_increment; - size_t max_increment; - - enum H5C_cache_flash_incr_mode flash_incr_mode; - double flash_multiple; - double flash_threshold; - + /**< Enumerated value indicating the operational mode of the automatic + * cache size increase code. At present, only two values listed in + * #H5C_cache_incr_mode are legal. */ + + double lower_hr_threshold; + /**< Hit rate threshold used by the hit rate threshold cache size + * increment algorithm.\n + * When the hit rate over an epoch is below this threshold and the cache + * is full, the maximum size of the cache is multiplied by increment + * (below), and then clipped as necessary to stay within \p max_size, and + * possibly \p max_increment.\n + * This field must lie in the interval [0.0, 1.0]. 0.8 or 0.9 is a good + * place to start. */ + + double increment; + /**< Factor by which the hit rate threshold cache size increment + * algorithm multiplies the current cache max size to obtain a tentative + * new cache size.\n + * The actual cache size increase will be clipped to satisfy the \p max_size + * specified in the general configuration, and possibly max_increment + * below.\n + * The parameter must be greater than or equal to 1.0 -- 2.0 is a reasonable + * value.\n + * If you set it to 1.0, you will effectively disable cache size increases. + */ + + hbool_t apply_max_increment; + /**< Boolean flag indicating whether an upper limit should be applied to + * the size of cache size increases. */ + + size_t max_increment; + /**< Maximum number of bytes by which cache size can be increased in a + * single step -- if applicable. */ + + enum H5C_cache_flash_incr_mode flash_incr_mode; + /**< Enumerated value indicating the operational mode of the flash cache + * size increase code. At present, only two listed values in + * #H5C_cache_flash_incr_mode are legal.*/ + + double flash_multiple; + /**< The factor by which the size of the triggering entry / entry size + * increase is multiplied to obtain the initial cache size increment. This + * increment may be reduced to reflect existing free space in the cache and + * the \p max_size field above.\n + * The parameter must lie in the interval [0.0, 1.0]. 0.1 or 0.05 is a good + * place to start.\n + * At present, this field must lie in the range [0.1, 10.0]. */ + + double flash_threshold; + /**< The factor by which the current maximum cache size is multiplied to + * obtain the minimum size entry / entry size increase which may trigger a + * flash cache size increase. \n + * At present, this value must lie in the range [0.1, 1.0]. */ + //! /* size decrease control fields: */ + //! enum H5C_cache_decr_mode decr_mode; - - double upper_hr_threshold; - - double decrement; - - hbool_t apply_max_decrement; - size_t max_decrement; - - int epochs_before_eviction; - - hbool_t apply_empty_reserve; - double empty_reserve; - + /**< Enumerated value indicating the operational mode of the tomatic + * cache size decrease code. At present, the values listed in + * #H5C_cache_decr_mode are legal.*/ + + double upper_hr_threshold; + /**< Hit rate threshold for the hit rate threshold and ageout with hit + * rate threshold cache size decrement algorithms.\n + * When \p decr_mode is #H5C_decr__threshold, and the hit rate over a given + * epoch exceeds the supplied threshold, the current maximum cache + * size is multiplied by decrement to obtain a tentative new (and smaller) + * maximum cache size.\n + * When \p decr_mode is #H5C_decr__age_out_with_threshold, there is + * no attempt to find and evict aged out entries unless the hit rate in + * the previous epoch exceeded the supplied threshold.\n + * This field must lie in the interval [0.0, 1.0].\n + * For #H5C_incr__threshold, .9995 or .99995 is a good place to start.\n + * For #H5C_decr__age_out_with_threshold, .999 might be more useful.*/ + + double decrement; + /**< In the hit rate threshold cache size decrease algorithm, this + * parameter contains the factor by which the current max cache size is + * multiplied to produce a tentative new cache size.\n + * The actual cache size decrease will be clipped to satisfy the + * \ref H5AC_cache_config_t.min_size "min_size" specified in the general + * configuration, and possibly \ref H5AC_cache_config_t.max_decrement + * "max_decrement".\n + * The parameter must be be in the interval [0.0, 1.0].\n + * If you set it to 1.0, you will effectively + * disable cache size decreases. 0.9 is a reasonable starting point. */ + + hbool_t apply_max_decrement; + /**< Boolean flag indicating ether an upper limit should be applied to + * the size of cache size decreases. */ + + size_t max_decrement; + /**< Maximum number of bytes by which the maximum cache size can be + * decreased in any single step -- if applicable.*/ + + int epochs_before_eviction; + /**< In the ageout based cache size reduction algorithms, this field + * contains the minimum number of epochs an entry must remain unaccessed in + * cache before the cache size reduction algorithm tries to evict it. 3 is a + * reasonable value. */ + + hbool_t apply_empty_reserve; + /**< Boolean flag indicating whether the ageout based decrement + * algorithms will maintain a empty reserve when decreasing cache size. */ + + double empty_reserve; + /**< Empty reserve as a fraction maximum cache size if applicable.\n When + * so directed, the ageout based algorithms will not decrease the maximum + * cache size unless the empty reserve can be met.\n The parameter must lie + * in the interval [0.0, 1.0]. 0.1 or 0.05 is a good place to start. */ + //! /* parallel configuration fields: */ - size_t dirty_bytes_threshold; - int metadata_write_strategy; - + //! + size_t dirty_bytes_threshold; + /**< Threshold number of bytes of dirty metadata generation for + * triggering synchronizations of the metadata caches serving the target + * file in the parallel case.\n Synchronization occurs whenever the number + * 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, + * 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 + * 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 + * actual flushes are distributed across the processes in the computation to + * the extent possible.\n The src/H5ACpublic.h include file in the HDF5 + * library has detailed information on each strategy. */ + //! } H5AC_cache_config_t; +//! +#define H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION 1 -/**************************************************************************** - * - * structure H5AC_cache_image_config_t - * - * H5AC_cache_image_ctl_t is a public structure intended for use in public - * APIs. At least in its initial incarnation, it is a copy of struct - * H5C_cache_image_ctl_t. - * - * The fields of the structure are discussed individually below: - * - * version: Integer field containing the version number of this version - * of the H5C_image_ctl_t structure. Any instance of - * H5C_image_ctl_t passed to the cache must have a known - * version number, or an error will be flagged. - * - * generate_image: Boolean flag indicating whether a cache image should - * be created on file close. - * - * save_resize_status: Boolean flag indicating whether the cache image - * should include the adaptive cache resize configuration and status. - * Note that this field is ignored at present. - * - * entry_ageout: Integer field indicating the maximum number of - * times a prefetched entry can appear in subsequent cache images. - * This field exists to allow the user to avoid the buildup of - * infrequently used entries in long sequences of cache images. - * - * The value of this field must lie in the range - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE (-1) to - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX (100). - * - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE means that no limit - * is imposed on number of times a prefeteched entry can appear - * in subsequent cache images. - * - * A value of 0 prevents prefetched entries from being included - * in cache images. - * - * Positive integers restrict prefetched entries to the specified - * number of appearances. - * - * Note that the number of subsequent cache images that a prefetched - * entry has appeared in is tracked in an 8 bit field. Thus, while - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX can be increased from its - * current value, any value in excess of 255 will be the functional - * equivalent of H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE. - * - ****************************************************************************/ - -#define H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION 1 +#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE -1 +#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX 100 -#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE -1 -#define H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX 100 +//! +/** + * H5AC_cache_image_config_t is a public structure intended for use in public + * APIs. At least in its initial incarnation, it is a copy of \c struct \c + * H5C_cache_image_ctl_t. + */ typedef struct H5AC_cache_image_config_t { - int version; - hbool_t generate_image; - hbool_t save_resize_status; - int entry_ageout; + int version; + /**< Integer field containing the version number of this version of the \c + * H5C_image_ctl_t structure. Any instance of \c H5C_image_ctl_t passed + * to the cache must have a known version number, or an error will be + * flagged. + */ + hbool_t generate_image; + /**< Boolean flag indicating whether a cache image should be created on file + * close. + */ + hbool_t save_resize_status; + /**< Boolean flag indicating whether the cache image should include the + * adaptive cache resize configuration and status. Note that this field + * is ignored at present. + */ + int entry_ageout; + /**< Integer field indicating the maximum number of times a + * prefetched entry can appear in subsequent cache images. This field + * exists to allow the user to avoid the buildup of infrequently used + * entries in long sequences of cache images. + * + * The value of this field must lie in the range \ref + * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE (-1) to \ref + * 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 + * cache images. + * + * A value of 0 prevents prefetched entries from being included in cache + * images. + * + * Positive integers restrict prefetched entries to the specified number + * of appearances. + * + * Note that the number of subsequent cache images that a prefetched entry + * has appeared in is tracked in an 8 bit field. Thus, while \ref + * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX can be increased from its current + * value, any value in excess of 255 will be the functional equivalent of + * \ref H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE. + */ } H5AC_cache_image_config_t; +//! + #ifdef __cplusplus } #endif #endif - diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 843799e9943..3274dd78534 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,24 +26,21 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -54,22 +51,20 @@ */ 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 */ - 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 */ + 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 */ /* upward */ - int cmp; /* Comparison of two attribute names */ + int cmp; /* Comparison of two attribute names */ } H5A_fh_ud_cmp_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -79,51 +74,48 @@ typedef struct H5A_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5A__dense_btree2_corder_store(void *native, const void *udata); static herr_t H5A__dense_btree2_corder_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5A__dense_btree2_name_store(void *native, const void *udata); static herr_t H5A__dense_btree2_name_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Fractal heap function callbacks */ static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); - /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indexing 'name' field of attributes */ -const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ - H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ - "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ - sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ - H5A__dense_btree2_name_store, /* Record storage callback */ - H5A__dense_btree2_name_compare, /* Record comparison callback */ - H5A__dense_btree2_name_encode, /* Record encoding callback */ - H5A__dense_btree2_name_decode, /* Record decoding callback */ - H5A__dense_btree2_name_debug /* Record debugging callback */ +const H5B2_class_t H5A_BT2_NAME[1] = {{ + /* B-tree class information */ + H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ + "H5B2_ATTR_DENSE_NAME_ID", /* Name of B-tree class */ + sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ + H5A__dense_btree2_name_store, /* Record storage callback */ + H5A__dense_btree2_name_compare, /* Record comparison callback */ + H5A__dense_btree2_name_encode, /* Record encoding callback */ + H5A__dense_btree2_name_decode, /* Record decoding callback */ + H5A__dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ -const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ - H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ - "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ - sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ +const H5B2_class_t H5A_BT2_CORDER[1] = {{ + /* B-tree class information */ + H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ + "H5B2_ATTR_DENSE_CORDER_ID", /* Name of B-tree class */ + sizeof(H5A_dense_bt2_corder_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ H5A__dense_btree2_corder_store, /* Record storage callback */ H5A__dense_btree2_corder_compare, /* Record comparison callback */ H5A__dense_btree2_corder_encode, /* Record encoding callback */ @@ -131,18 +123,14 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5A__dense_btree2_corder_debug /* Record debugging callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5A__dense_fh_name_cmp * @@ -159,43 +147,43 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ 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 */ - hbool_t took_ownership = FALSE; /* Whether the "found" operator took ownership of the attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t took_ownership = FALSE; /* Whether the "found" operator took ownership of the attribute */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode attribute information */ - if(NULL == (attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) + if (NULL == + (attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't decode attribute") /* Compare the string values */ udata->cmp = HDstrcmp(udata->name, attr->shared->name); /* Check for correct attribute & callback to make */ - if(udata->cmp == 0 && udata->found_op) { + if (udata->cmp == 0 && udata->found_op) { /* Check whether we should "reconstitute" the shared message info */ - if(udata->record->flags & H5O_MSG_FLAG_SHARED) + if (udata->record->flags & H5O_MSG_FLAG_SHARED) H5SM_reconstitute(&(attr->sh_loc), udata->f, H5O_ATTR_ID, udata->record->id); /* Set the creation order index for the attribute */ attr->shared->crt_idx = udata->record->corder; /* Make callback */ - if((udata->found_op)(attr, &took_ownership, udata->found_op_data) < 0) + if ((udata->found_op)(attr, &took_ownership, udata->found_op_data) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPERATE, FAIL, "attribute found callback failed") } /* end if */ done: /* Release the space allocated for the attrbute */ - if(attr && !took_ownership) + if (attr && !took_ownership) H5O_msg_free(H5O_ATTR_ID, attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fh_name_cmp() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_store * @@ -212,21 +200,20 @@ 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 /* Copy user information info native record */ - nrecord->id = udata->id; - nrecord->flags = udata->common.flags; + nrecord->id = udata->id; + nrecord->flags = udata->common.flags; nrecord->corder = udata->common.corder; - nrecord->hash = udata->common.name_hash; + nrecord->hash = udata->common.name_hash; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_store() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_compare * @@ -244,9 +231,9 @@ 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_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -255,37 +242,37 @@ H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int HDassert(bt2_rec); /* Check hash value */ - if(bt2_udata->name_hash < bt2_rec->hash) + if (bt2_udata->name_hash < bt2_rec->hash) *result = (-1); - else if(bt2_udata->name_hash > bt2_rec->hash) + else if (bt2_udata->name_hash > bt2_rec->hash) *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 */ + 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 */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; - fh_udata.record = bt2_rec; - fh_udata.found_op = bt2_udata->found_op; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; + fh_udata.record = bt2_rec; + fh_udata.found_op = bt2_udata->found_op; fh_udata.found_op_data = bt2_udata->found_op_data; /* up */ fh_udata.cmp = 0; /* Check for attribute in shared storage */ - if(bt2_rec->flags & H5O_MSG_FLAG_SHARED) + if (bt2_rec->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; HDassert(fheap); /* Check if the user's attribute and the B-tree's attribute have the same name */ - if(H5HF_op(fheap, &bt2_rec->id, H5A__dense_fh_name_cmp, &fh_udata) < 0) + if (H5HF_op(fheap, &bt2_rec->id, H5A__dense_fh_name_cmp, &fh_udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Callback will set comparison value */ @@ -296,7 +283,6 @@ H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int FUNC_LEAVE_NOAPI(ret_value) } /* H5A__dense_btree2_name_compare() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_encode * @@ -327,7 +313,6 @@ H5A__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_encode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_decode * @@ -358,7 +343,6 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_decode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_name_debug * @@ -373,21 +357,19 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u, %08lx}\n", indent, "", fwidth, - "Record:", - (hsize_t)nrecord->id.val, (unsigned)nrecord->flags, (unsigned)nrecord->corder, (unsigned long)nrecord->hash); + HDfprintf(stream, "%*s%-*s {%016" PRIx64 ", %02" PRIx8 ", %u, %08" PRIx32 "}\n", indent, "", fwidth, + "Record:", nrecord->id.val, nrecord->flags, (unsigned)nrecord->corder, nrecord->hash); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_debug() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_store * @@ -404,20 +386,19 @@ H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, 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 /* Copy user information info native record */ - nrecord->id = udata->id; - nrecord->flags = udata->common.flags; + nrecord->id = udata->id; + nrecord->flags = udata->common.flags; nrecord->corder = udata->common.corder; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_store() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_compare * @@ -435,8 +416,8 @@ 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_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec; + 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 @@ -445,9 +426,9 @@ H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i HDassert(bt2_rec); /* Check creation order value */ - if(bt2_udata->corder < bt2_rec->corder) + if (bt2_udata->corder < bt2_rec->corder) *result = -1; - else if(bt2_udata->corder > bt2_rec->corder) + else if (bt2_udata->corder > bt2_rec->corder) *result = 1; else *result = 0; @@ -455,7 +436,6 @@ H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_compare() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_encode * @@ -485,7 +465,6 @@ H5A__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_encode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_decode * @@ -515,7 +494,6 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_decode() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_btree2_corder_debug * @@ -530,17 +508,15 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%016Hx, %02x, %u}\n", indent, "", fwidth, - "Record:", - (hsize_t)nrecord->id.val, (unsigned)nrecord->flags, (unsigned)nrecord->corder); + HDfprintf(stream, "%*s%-*s {%016" PRIx64 ", %02" PRIx8 ", %u}\n", indent, "", fwidth, + "Record:", nrecord->id.val, nrecord->flags, (unsigned)nrecord->corder); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_debug() */ - diff --git a/src/H5Adense.c b/src/H5Adense.c index bb7f1220dc1..1575f3ce7bc 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,39 +27,36 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* v2 B-tree creation macros for 'name' field index */ -#define H5A_NAME_BT2_NODE_SIZE 512 -#define H5A_NAME_BT2_MERGE_PERC 40 -#define H5A_NAME_BT2_SPLIT_PERC 100 +#define H5A_NAME_BT2_NODE_SIZE 512 +#define H5A_NAME_BT2_MERGE_PERC 40 +#define H5A_NAME_BT2_SPLIT_PERC 100 /* v2 B-tree creation macros for 'corder' field index */ -#define H5A_CORDER_BT2_NODE_SIZE 512 -#define H5A_CORDER_BT2_MERGE_PERC 40 -#define H5A_CORDER_BT2_SPLIT_PERC 100 +#define H5A_CORDER_BT2_NODE_SIZE 512 +#define H5A_CORDER_BT2_MERGE_PERC 40 +#define H5A_CORDER_BT2_SPLIT_PERC 100 /* Size of stack buffer for serialized attributes */ -#define H5A_ATTR_BUF_SIZE 128 - +#define H5A_ATTR_BUF_SIZE 128 /******************/ /* Local Typedefs */ @@ -71,11 +68,11 @@ */ typedef struct H5A_bt2_od_wrt_t { /* downward */ - 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 */ - haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ + 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 */ + haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_od_wrt_t; /* @@ -84,19 +81,19 @@ typedef struct H5A_bt2_od_wrt_t { */ typedef struct { /* downward (internal) */ - 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 */ + 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 */ /* downward (from application) */ - 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 */ + 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 */ /* upward */ - int op_ret; /* Return value from callback */ + int op_ret; /* Return value from callback */ } H5A_bt2_ud_it_t; /* @@ -106,11 +103,11 @@ typedef struct { */ typedef struct { /* downward (internal) */ - 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 */ + 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 */ - H5A_t *attr; /* Copy of attribute */ + H5A_t *attr; /* Copy of attribute */ } H5A_fh_ud_cp_t; /* @@ -119,8 +116,8 @@ typedef struct { */ typedef struct H5A_bt2_ud_rm_t { /* downward */ - H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ + H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_ud_rm_t; /* @@ -129,40 +126,33 @@ 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 */ - H5_index_t idx_type; /* Index type for operation */ - haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ + 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; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5A__dense_create * @@ -180,10 +170,10 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 @@ -192,84 +182,83 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Set fractal heap creation parameters */ -/* XXX: Give some control of these to applications? */ + /* XXX: Give some control of these to applications? */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5O_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; + fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; /* Create fractal heap for storing attributes */ - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create fractal heap") /* Retrieve the heap's address in the file */ - if(H5HF_get_heap_addr(fheap, &ainfo->fheap_addr) < 0) + if (H5HF_get_heap_addr(fheap, &ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") #ifndef NDEBUG -{ - size_t fheap_id_len; /* Fractal heap ID length */ + { + size_t fheap_id_len; /* Fractal heap ID length */ - /* Retrieve the heap's ID length in the file */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") - HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); -} + /* Retrieve the heap's ID length in the file */ + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") + HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); + } #endif /* NDEBUG */ /* Create the name index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5A_BT2_NAME; + bt2_cparam.cls = H5A_BT2_NAME; bt2_cparam.node_size = (size_t)H5A_NAME_BT2_NODE_SIZE; - bt2_cparam.rrec_size = 4 + /* Name's hash value */ - 4 + /* Creation order index */ - 1 + /* Message flags */ - H5O_FHEAP_ID_LEN; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Name's hash value */ + 4 + /* Creation order index */ + 1 + /* Message flags */ + H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_name, &ainfo->name_bt2_addr) < 0) + if (H5B2_get_addr(bt2_name, &ainfo->name_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") /* Check if we should create a creation order index v2 B-tree */ - if(ainfo->index_corder) { + if (ainfo->index_corder) { /* Create the creation order index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5A_BT2_CORDER; + bt2_cparam.cls = H5A_BT2_CORDER; bt2_cparam.node_size = (size_t)H5A_CORDER_BT2_NODE_SIZE; - bt2_cparam.rrec_size = 4 + /* Creation order index */ - 1 + /* Message flags */ - H5O_FHEAP_ID_LEN; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Creation order index */ + 1 + /* Message flags */ + H5O_FHEAP_ID_LEN; /* Fractal heap ID */ bt2_cparam.split_percent = H5A_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5A_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_corder, &ainfo->corder_bt2_addr) < 0) + if (H5B2_get_addr(bt2_corder, &ainfo->corder_bt2_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_create() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_fnd_cb * @@ -285,8 +274,8 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { - H5A_t const **user_attr = (H5A_t const **)_user_attr; /* User data from v2 B-tree attribute lookup */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_t **user_attr = (const H5A_t **)_user_attr; /* User data from v2 B-tree attribute lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -310,29 +299,25 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) * which may be merged/redistributed, we need to free the dynamically * allocated spaces for the intermediate decoded attribute. */ - if(*user_attr != NULL) { - H5A_t *old_attr = *user_attr; - if(old_attr->shared) { - /* Free any dynamically allocated items */ - if(H5A__free(old_attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") + if (*user_attr != NULL) { + H5A_t *old_attr = *(H5A_t **)_user_attr; - /* Destroy shared attribute struct */ - old_attr->shared = H5FL_FREE(H5A_shared_t, old_attr->shared); - } /* end if */ + /* Free any dynamically allocated items */ + if (old_attr->shared) + if (H5A__shared_free(old_attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") old_attr = H5FL_FREE(H5A_t, old_attr); - } /* end if */ + } /* end if */ /* Take over attribute ownership */ - *user_attr = attr; + *user_attr = attr; *took_ownership = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_open * @@ -348,13 +333,13 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) 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 */ - htri_t attr_exists; /* Attribute exists in v2 B-tree */ - H5A_t *ret_value = NULL; /* Return value */ + 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 */ + htri_t attr_exists; /* Attribute exists in v2 B-tree */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -364,63 +349,62 @@ H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record find */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &ret_value; /* Find & copy the attribute in the 'name' index */ - if((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't search for attribute in name index") - else if(attr_exists == FALSE) + else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute in name index") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_open() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_insert * @@ -436,16 +420,16 @@ H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -455,23 +439,23 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) HDassert(attr); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - 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? */ + 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? */ /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) + else if (shared_mesg > 0) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; else { /* Should this attribute be written as a SOHM? */ - if(H5SM_try_share(f, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) + if (H5SM_try_share(f, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Attributes can't be "unique be shareable" yet */ @@ -479,23 +463,23 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) } /* end else */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check for inserting shared attribute */ - if(mesg_flags & H5O_MSG_FLAG_SHARED) { + if (mesg_flags & H5O_MSG_FLAG_SHARED) { /* Sanity check */ HDassert(attr_sharable); @@ -503,80 +487,79 @@ 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 */ - size_t attr_size; /* Size of serialized attribute in the heap */ + 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 */ - if((attr_size = H5O_msg_raw_size(f, H5O_ATTR_ID, FALSE, attr)) == 0) + if ((attr_size = H5O_msg_raw_size(f, H5O_ATTR_ID, FALSE, attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get message size") /* Wrap the local buffer for serialized attributes */ - if(NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) + if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ - if(NULL == (attr_ptr = H5WB_actual(wb, attr_size))) + if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute or shared message */ - if(H5O_msg_encode(f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, attr) < 0) + if (H5O_msg_encode(f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Insert the serialized attribute into the fractal heap */ /* (sets the heap ID in the user data) */ - if(H5HF_insert(fheap, attr_size, attr_ptr, &udata.id) < 0) + if (H5HF_insert(fheap, attr_size, attr_ptr, &udata.id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert attribute into fractal heap") } /* end else */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ - udata.common.f = f; - udata.common.fheap = fheap; + udata.common.f = f; + udata.common.fheap = fheap; udata.common.shared_fheap = shared_fheap; - udata.common.name = attr->shared->name; - udata.common.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); + udata.common.name = attr->shared->name; + udata.common.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); H5_CHECKED_ASSIGN(udata.common.flags, uint8_t, mesg_flags, unsigned); - udata.common.corder = attr->shared->crt_idx; - udata.common.found_op = NULL; + udata.common.corder = attr->shared->crt_idx; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; /* udata.id already set */ /* Insert attribute into 'name' tracking v2 B-tree */ - if(H5B2_insert(bt2_name, &udata) < 0) + if (H5B2_insert(bt2_name, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") /* Check if we should create a creation order index v2 B-tree record */ - if(ainfo->index_corder) { + if (ainfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ - if(H5B2_insert(bt2_corder, &udata) < 0) + if (H5B2_insert(bt2_corder, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") } /* end if */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_insert() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb2 * @@ -594,7 +577,7 @@ static herr_t H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) { H5A_dense_bt2_corder_rec_t *record = (H5A_dense_bt2_corder_rec_t *)_record; /* Record from B-tree */ - H5O_fheap_id_t *new_heap_id = (H5O_fheap_id_t *)_op_data; /* "op data" from v2 B-tree modify */ + H5O_fheap_id_t *new_heap_id = (H5O_fheap_id_t *)_op_data; /* "op data" from v2 B-tree modify */ FUNC_ENTER_STATIC_NOERR @@ -611,7 +594,6 @@ H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__dense_write_bt2_cb2() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write_bt2_cb * @@ -627,12 +609,12 @@ H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) 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 */ - uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -641,35 +623,37 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) HDassert(op_data); /* Check for modifying shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { + if (record->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM info */ - if(H5O__attr_update_shared(op_data->f, NULL, op_data->attr, NULL) < 0) + if (H5O__attr_update_shared(op_data->f, NULL, op_data->attr, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in shared storage") /* Update record's heap ID */ record->id = op_data->attr->sh_loc.u.heap_id; /* Check if we need to modify the creation order index with new heap ID */ - if(H5F_addr_defined(op_data->corder_bt2_addr)) { - H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ + if (H5F_addr_defined(op_data->corder_bt2_addr)) { + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(op_data->f, op_data->corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(op_data->f, op_data->corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = op_data->f; - udata.fheap = NULL; - udata.shared_fheap = NULL; - udata.name = NULL; - udata.name_hash = 0; - udata.flags = 0; - udata.corder = op_data->attr->shared->crt_idx; - udata.found_op = NULL; + udata.f = op_data->f; + udata.fheap = NULL; + udata.shared_fheap = NULL; + udata.name = NULL; + udata.name_hash = 0; + udata.flags = 0; + udata.corder = op_data->attr->shared->crt_idx; + udata.found_op = NULL; udata.found_op_data = NULL; /* Modify record for creation order index */ - if(H5B2_modify(bt2_corder, &udata, H5A__dense_write_bt2_cb2, &op_data->attr->sh_loc.u.heap_id) < 0) + if (H5B2_modify(bt2_corder, &udata, H5A__dense_write_bt2_cb2, &op_data->attr->sh_loc.u.heap_id) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") } /* end if */ @@ -677,52 +661,51 @@ 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 */ - size_t attr_size; /* Size of serialized attribute in the heap */ + 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 */ - if((attr_size = H5O_msg_raw_size(op_data->f, H5O_ATTR_ID, FALSE, op_data->attr)) == 0) + if ((attr_size = H5O_msg_raw_size(op_data->f, H5O_ATTR_ID, FALSE, op_data->attr)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get attribute size") /* Wrap the local buffer for serialized attributes */ - if(NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) + if (NULL == (wb = H5WB_wrap(attr_buf, sizeof(attr_buf)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for attribute */ - if(NULL == (attr_ptr = H5WB_actual(wb, attr_size))) + if (NULL == (attr_ptr = H5WB_actual(wb, attr_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of attribute */ - if(H5O_msg_encode(op_data->f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, op_data->attr) < 0) + if (H5O_msg_encode(op_data->f, H5O_ATTR_ID, FALSE, (unsigned char *)attr_ptr, op_data->attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute") /* Sanity check */ #ifndef NDEBUG -{ - size_t obj_len; /* Length of existing encoded attribute */ + { + size_t obj_len; /* Length of existing encoded attribute */ - if(H5HF_get_obj_len(op_data->fheap, &record->id, &obj_len) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get object size") - HDassert(obj_len == attr_size); -} + if (H5HF_get_obj_len(op_data->fheap, &record->id, &obj_len) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGETSIZE, FAIL, "can't get object size") + HDassert(obj_len == attr_size); + } #endif /* NDEBUG */ /* Update existing attribute in heap */ /* (might be more efficient as fractal heap 'op' callback, but leave that for later -QAK) */ - if(H5HF_write(op_data->fheap, &record->id, changed, attr_ptr) < 0) + if (H5HF_write(op_data->fheap, &record->id, changed, attr_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute in heap") } /* end else */ done: /* Release resources */ - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_write * @@ -738,13 +721,13 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) herr_t 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -756,68 +739,67 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) HDassert(attr); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = attr->shared->name; - udata.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = NULL; + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = attr->shared->name; + udata.name_hash = H5_checksum_lookup3(attr->shared->name, HDstrlen(attr->shared->name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = NULL; udata.found_op_data = NULL; /* Create the "op_data" for the v2 B-tree record 'modify' callback */ - op_data.f = f; - op_data.fheap = fheap; - op_data.shared_fheap = shared_fheap; - op_data.attr = attr; + op_data.f = f; + op_data.fheap = fheap; + op_data.shared_fheap = shared_fheap; + op_data.attr = attr; op_data.corder_bt2_addr = ainfo->corder_bt2_addr; /* Modify attribute through 'name' tracking v2 B-tree */ - if(H5B2_modify(bt2_name, &udata, H5A__dense_write_bt2_cb, &op_data) < 0) + if (H5B2_modify(bt2_name, &udata, H5A__dense_write_bt2_cb, &op_data) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to modify record in v2 B-tree") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_copy_fh_cb * @@ -834,8 +816,8 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) static herr_t H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5A_fh_ud_cp_t *udata = (H5A_fh_ud_cp_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_fh_ud_cp_t *udata = (H5A_fh_ud_cp_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -846,21 +828,21 @@ H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) * HDF5 routine, it could attempt to re-protect that direct block for the * heap, causing the HDF5 routine called to fail) */ - if(NULL == (udata->attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->attr = (H5A_t *)H5O_msg_decode(udata->f, NULL, H5O_ATTR_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, FAIL, "can't decode attribute") /* Set the creation order index for the attribute */ udata->attr->shared->crt_idx = udata->record->corder; /* Check whether we should "reconstitute" the shared message info */ - if(udata->record->flags & H5O_MSG_FLAG_SHARED) + if (udata->record->flags & H5O_MSG_FLAG_SHARED) H5SM_reconstitute(&(udata->attr->sh_loc), udata->f, H5O_ATTR_ID, udata->record->id); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_copy_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_rename * @@ -874,19 +856,18 @@ H5A__dense_copy_fh_cb(const void *obj, size_t obj_len, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, - const char *new_name) +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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -897,55 +878,55 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, HDassert(new_name); /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record modify */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = old_name; - udata.name_hash = H5_checksum_lookup3(old_name, HDstrlen(old_name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = old_name; + udata.name_hash = H5_checksum_lookup3(old_name, HDstrlen(old_name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.found_op_data = &attr_copy; /* Get copy of attribute through 'name' tracking v2 B-tree */ - if((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((attr_exists = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") - else if(attr_exists == FALSE) + else if (attr_exists == FALSE) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute in name index") HDassert(attr_copy); /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) { + else if (shared_mesg > 0) { /* Reset shared status of copy */ /* (so it will get shared again if necessary) */ attr_copy->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; @@ -956,47 +937,48 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, attr_copy->shared->name = H5MM_xstrdup(new_name); /* Recompute the version to encode the attribute with */ - if(H5A__set_version(f, attr_copy) < 0) + if (H5A__set_version(f, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version") /* Need to remove the attribute from the creation order index v2 B-tree */ - if(ainfo->index_corder) { - htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */ + if (ainfo->index_corder) { + htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */ /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, ainfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation index") /* Set up the creation order to search for */ udata.corder = attr_copy->shared->crt_idx; - if((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0) + if ((corder_attr_exists = H5B2_find(bt2_corder, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") - if(corder_attr_exists) { + if (corder_attr_exists) { H5A_bt2_ud_rm_t rm_udata; /* Set up the creation order in user data for the v2 B-tree 'record remove' callback */ rm_udata.common.corder = attr_copy->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ - if(H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") + if (H5B2_remove(bt2_corder, &rm_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove attribute from creation order index v2 B-tree") } } /* Insert renamed attribute back into dense storage */ /* (Possibly making it shared) */ - if(H5A__dense_insert(f, ainfo, attr_copy) < 0) + if (H5A__dense_insert(f, ainfo, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage") /* Was this attribute shared? */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) { - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr_copy)) > 0) { + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ /* Retrieve ref count for shared attribute */ - if(H5SM_get_refcount(f, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(f, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If the newly shared attribute needs to share "ownership" of the shared @@ -1006,42 +988,41 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, * * *ick* -QAK, 2007/01/08 */ - if(attr_rc == 1) { + if (attr_rc == 1) { /* Increment reference count on attribute components */ - if(H5O__attr_link(f, NULL, attr_copy) < 0) + if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ - } /* end if */ - else if(shared_mesg == 0) { + } /* end if */ + else if (shared_mesg == 0) { /* Increment reference count on attribute components */ /* (so that they aren't deleted when the attribute is removed shortly) */ - if(H5O__attr_link(f, NULL, attr_copy) < 0) + if (H5O__attr_link(f, NULL, attr_copy) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ - else if(shared_mesg < 0) + else if (shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Delete old attribute from dense storage */ - if(H5A__dense_remove(f, ainfo, old_name) < 0) + if (H5A__dense_remove(f, ainfo, old_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(attr_copy) + if (attr_copy) H5O_msg_free(H5O_ATTR_ID, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_rename() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_iterate_bt2_cb * @@ -1054,57 +1035,59 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, * *------------------------------------------------------------------------- */ -static herr_t +static int H5A__dense_iterate_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_it_t *bt2_udata = (H5A_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + const H5A_dense_bt2_name_rec_t *record = + (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ + H5A_bt2_ud_it_t *bt2_udata = (H5A_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC /* Check for skipping attributes */ - if(bt2_udata->skip > 0) + if (bt2_udata->skip > 0) --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 */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5HF_t * fheap; /* Fractal heap handle for attribute storage */ /* Check for iterating over shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) + if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; - fh_udata.attr = NULL; + fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ - if(H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") /* Check which type of callback to make */ - switch(bt2_udata->attr_op->op_type) { - case H5A_ATTR_OP_APP2: - { - H5A_info_t ainfo; /* Info for attribute */ + switch (bt2_udata->attr_op->op_type) { + case H5A_ATTR_OP_APP2: { + H5A_info_t ainfo; /* Info for attribute */ /* Get the attribute information */ - if(H5A__get_info(fh_udata.attr, &ainfo) < 0) + if (H5A__get_info(fh_udata.attr, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") /* Make the application callback */ - ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->shared->name, &ainfo, bt2_udata->op_data); + ret_value = (bt2_udata->attr_op->u.app_op2)(bt2_udata->loc_id, fh_udata.attr->shared->name, + &ainfo, bt2_udata->op_data); break; } #ifndef H5_NO_DEPRECATED_SYMBOLS case H5A_ATTR_OP_APP: /* Make the application callback */ - ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->shared->name, bt2_udata->op_data); + ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->shared->name, + bt2_udata->op_data); break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1117,7 +1100,7 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) HDassert("unknown attribute op type" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /* Release the space allocated for the attribute */ @@ -1129,14 +1112,13 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) bt2_udata->count++; /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_iterate * @@ -1150,16 +1132,16 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ herr_t -H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, - 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) +H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, 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) { - 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 */ - haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1171,12 +1153,12 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, HDassert(attr_op); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ - if(order == H5_ITER_NATIVE) { + if (order == H5_ITER_NATIVE) { HDassert(H5F_addr_defined(ainfo->name_bt2_addr)); bt2_addr = ainfo->name_bt2_addr; } /* end if */ @@ -1194,83 +1176,82 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, } /* end else */ /* 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 */ + 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 */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ - udata.f = f; - udata.fheap = fheap; + udata.f = f; + udata.fheap = fheap; udata.shared_fheap = shared_fheap; - udata.loc_id = loc_id; - udata.skip = skip; - udata.count = 0; - udata.attr_op = attr_op; - udata.op_data = op_data; + udata.loc_id = loc_id; + udata.skip = skip; + udata.count = 0; + udata.attr_op = attr_op; + udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ /* (by hash of name) */ - if((ret_value = H5B2_iterate(bt2, H5A__dense_iterate_bt2_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5A__dense_iterate_bt2_cb, &udata)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); /* Update the last attribute examined, if requested */ - if(last_attr) + if (last_attr) *last_attr = udata.count; } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) + if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Iterate over attributes in table */ - if((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) + if ((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_bt2_cb * @@ -1287,53 +1268,53 @@ 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 */ - H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC /* Check for removing the link from the creation order index */ - if(H5F_addr_defined(udata->corder_bt2_addr)) { + if (H5F_addr_defined(udata->corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(udata->common.f, udata->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(udata->common.f, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ udata->common.corder = attr->shared->crt_idx; /* Remove the record from the creation order index v2 B-tree */ - if(H5B2_remove(bt2_corder, udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree") + if (H5B2_remove(bt2_corder, udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove attribute from creation order index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { + if (record->flags & H5O_MSG_FLAG_SHARED) { /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(udata->common.f, NULL, &(attr->sh_loc)) < 0) + if (H5SM_delete(udata->common.f, NULL, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ - if(H5O__attr_delete(udata->common.f, NULL, attr) < 0) + if (H5O__attr_delete(udata->common.f, NULL, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ - if(H5HF_remove(udata->common.fheap, &record->id) < 0) + if (H5HF_remove(udata->common.fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove * @@ -1349,13 +1330,13 @@ H5A__dense_remove_bt2_cb(const void *_record, void *_udata) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1365,62 +1346,61 @@ H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name && *name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.shared_fheap = shared_fheap; - udata.common.name = name; - udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.shared_fheap = shared_fheap; + udata.common.name = name; + udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.common.found_op = H5A__dense_fnd_cb; /* v2 B-tree comparison callback */ udata.common.found_op_data = &attr_copy; - udata.corder_bt2_addr = ainfo->corder_bt2_addr; + udata.corder_bt2_addr = ainfo->corder_bt2_addr; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2_name, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) + if (H5B2_remove(bt2_name, &udata, H5A__dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from name index v2 B-tree") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(attr_copy) - H5O__msg_free_real(H5O_MSG_ATTR, attr_copy); + if (attr_copy) + H5O_msg_free_real(H5O_MSG_ATTR, attr_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx_bt2_cb * @@ -1436,32 +1416,32 @@ 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; - fh_udata.attr = NULL; + fh_udata.attr = NULL; /* Get correct fractal heap handle to use for operations */ - if(record->flags & H5O_MSG_FLAG_SHARED) + if (record->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; /* Check whether to make a copy of the attribute or just need the shared location info */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr) || !(record->flags & H5O_MSG_FLAG_SHARED)) { + if (H5F_addr_defined(bt2_udata->other_bt2_addr) || !(record->flags & H5O_MSG_FLAG_SHARED)) { /* Call fractal heap 'op' routine, to make copy of attribute to remove */ - if(H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "attribute removal callback failed") HDassert(fh_udata.attr); @@ -1477,11 +1457,11 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Check for removing the link from the "other" index (creation order, when name used and vice versa) */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr)) { - H5A_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(bt2_udata->other_bt2_addr)) { + H5A_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.corder = fh_udata.attr->shared->crt_idx; } /* end if */ @@ -1489,62 +1469,63 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set up the user data for the v2 B-tree 'record remove' callback */ - other_bt2_udata.f = bt2_udata->f; - other_bt2_udata.fheap = bt2_udata->fheap; + other_bt2_udata.f = bt2_udata->f; + other_bt2_udata.fheap = bt2_udata->fheap; other_bt2_udata.shared_fheap = bt2_udata->shared_fheap; - other_bt2_udata.name = fh_udata.attr->shared->name; - other_bt2_udata.name_hash = H5_checksum_lookup3(fh_udata.attr->shared->name, HDstrlen(fh_udata.attr->shared->name), 0); - other_bt2_udata.found_op = NULL; + other_bt2_udata.name = fh_udata.attr->shared->name; + other_bt2_udata.name_hash = + H5_checksum_lookup3(fh_udata.attr->shared->name, HDstrlen(fh_udata.attr->shared->name), 0); + other_bt2_udata.found_op = NULL; other_bt2_udata.found_op_data = NULL; } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set the common information for the v2 B-tree remove operation */ /* Remove the record from the "other" index v2 B-tree */ - if(H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove record from 'other' index v2 B-tree") + if (H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, + "unable to remove record from 'other' index v2 B-tree") } /* end if */ /* Check for removing shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { - H5O_shared_t *sh_loc_ptr; /* Pointer to shared message info for attribute */ + if (record->flags & H5O_MSG_FLAG_SHARED) { + H5O_shared_t *sh_loc_ptr; /* Pointer to shared message info for attribute */ /* Set up pointer to correct shared location */ - if(use_sh_loc) + if (use_sh_loc) sh_loc_ptr = &sh_loc; else sh_loc_ptr = &(fh_udata.attr->sh_loc); /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(bt2_udata->f, NULL, sh_loc_ptr) < 0) + if (H5SM_delete(bt2_udata->f, NULL, sh_loc_ptr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { /* Perform the deletion action on the attribute */ /* (takes care of shared & committed datatype/dataspace components) */ - if(H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) + if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") /* Remove record from fractal heap */ - if(H5HF_remove(fheap, &record->id) < 0) + if (H5HF_remove(fheap, &record->id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") } /* end else */ done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(fh_udata.attr) + if (fh_udata.attr) H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_remove_by_idx * @@ -1559,15 +1540,15 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ 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) +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 */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - 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 */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1576,12 +1557,12 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type HDassert(ainfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. */ - if(order == H5_ITER_NATIVE) { + if (order == H5_ITER_NATIVE) { bt2_addr = ainfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ @@ -1599,79 +1580,78 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type } /* end else */ /* 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 */ + 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 */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.idx_type = idx_type; + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.idx_type = idx_type; udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? ainfo->corder_bt2_addr : ainfo->name_bt2_addr; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) + if (H5B2_remove_by_idx(bt2, order, n, H5A__dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from v2 B-tree index") } /* end if */ else { /* Build the table of attributes for this object */ /* (build table using the name index, but sort according to idx_type) */ - if(H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) + if (H5A__dense_build_table(f, ainfo, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error building table of attributes") /* Check for skipping too many attributes */ - if(n >= atable.nattrs) + if (n >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Delete appropriate attribute from dense storage */ - if(H5A__dense_remove(f, ainfo, ((atable.attrs[n])->shared)->name) < 0) + if (H5A__dense_remove(f, ainfo, ((atable.attrs[n])->shared)->name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end else */ done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_exists * @@ -1688,12 +1668,12 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type 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 */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE @@ -1703,61 +1683,60 @@ H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) HDassert(name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Check if attributes are shared in this file */ - if((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) + 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 */ - if(attr_sharable) { - haddr_t shared_fheap_addr; /* Address of fractal heap to use */ + if (attr_sharable) { + haddr_t shared_fheap_addr; /* Address of fractal heap to use */ /* Retrieve the address of the shared message's fractal heap */ - if(H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, H5O_ATTR_ID, &shared_fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared message heap address") /* Check if there are any shared messages currently */ - if(H5F_addr_defined(shared_fheap_addr)) { + if (H5F_addr_defined(shared_fheap_addr)) { /* Open the fractal heap for shared header messages */ - if(NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) + if (NULL == (shared_fheap = H5HF_open(f, shared_fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") } /* end if */ - } /* end if */ + } /* end if */ /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the "udata" information for v2 B-tree record 'find' */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = shared_fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.flags = 0; - udata.corder = 0; - udata.found_op = NULL; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = shared_fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.flags = 0; + udata.corder = 0; + udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Find the attribute in the 'name' index */ - if((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index") done: /* Release resources */ - if(shared_fheap && H5HF_close(shared_fheap) < 0) + if (shared_fheap && H5HF_close(shared_fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_exists() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_delete_bt2_cb * @@ -1773,54 +1752,54 @@ H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) static herr_t 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for shared attribute */ - if(record->flags & H5O_MSG_FLAG_SHARED) { - H5O_shared_t sh_mesg; /* Temporary shared message info */ + if (record->flags & H5O_MSG_FLAG_SHARED) { + H5O_shared_t sh_mesg; /* Temporary shared message info */ /* "reconstitute" the shared message info for the attribute */ H5SM_reconstitute(&sh_mesg, bt2_udata->f, H5O_ATTR_ID, record->id); /* Decrement the reference count on the shared attribute message */ - if(H5SM_delete(bt2_udata->f, NULL, &sh_mesg) < 0) + if (H5SM_delete(bt2_udata->f, NULL, &sh_mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute") } /* end if */ else { - H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.record = record; /* up */ fh_udata.attr = NULL; /* Call fractal heap 'op' routine, to copy the attribute information */ - if(H5HF_op(bt2_udata->fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, &record->id, H5A__dense_copy_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "heap op callback failed") attr = fh_udata.attr; /* Perform the deletion action on the attribute */ /* (takes care of shared/committed datatype & dataspace components) */ - if(H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) + if (H5O__attr_delete(bt2_udata->f, NULL, fh_udata.attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end else */ done: /* Release resources */ - if(attr) - H5O__msg_free_real(H5O_MSG_ATTR, attr); + if (attr) + H5O_msg_free_real(H5O_MSG_ATTR, attr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_delete * @@ -1836,9 +1815,9 @@ H5A__dense_delete_bt2_cb(const void *_record, void *_bt2_udata) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1847,47 +1826,46 @@ H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Create the "udata" information for v2 B-tree 'delete' */ - udata.f = f; - udata.fheap = fheap; - udata.shared_fheap = NULL; - udata.name = NULL; - udata.name_hash = 0; - udata.flags = 0; - udata.found_op = NULL; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.shared_fheap = NULL; + udata.name = NULL; + udata.name_hash = 0; + udata.flags = 0; + udata.found_op = NULL; /* v2 B-tree comparison callback */ udata.found_op_data = NULL; /* Delete name index v2 B-tree */ - if(H5B2_delete(f, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) + if (H5B2_delete(f, ainfo->name_bt2_addr, NULL, H5A__dense_delete_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") ainfo->name_bt2_addr = HADDR_UNDEF; /* Release resources */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") fheap = NULL; /* Check if we should delete the creation order index v2 B-tree */ - if(H5F_addr_defined(ainfo->corder_bt2_addr)) { + if (H5F_addr_defined(ainfo->corder_bt2_addr)) { /* Delete the creation order index, without adjusting the ref. count on the attributes */ - if(H5B2_delete(f, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, ainfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") ainfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ /* Delete fractal heap */ - if(H5HF_delete(f, ainfo->fheap_addr) < 0) + if (H5HF_delete(f, ainfo->fheap_addr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") ainfo->fheap_addr = HADDR_UNDEF; done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete() */ - diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 616256eff17..e43706f0ba9 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,59 +29,53 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual object layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*-------------------------------------------------------------------------- NAME H5Acreate1 @@ -95,7 +89,7 @@ hid_t space_id; IN: ID of dataspace for attribute hid_t acpl_id; IN: ID of creation property list (currently not used) RETURNS - Non-negative on success/Negative on failure + Non-negative on success/H5I_INVALID_HID on failure DESCRIPTION This function creates an attribute which is attached to the object @@ -110,53 +104,57 @@ --------------------------------------------------------------------------*/ hid_t -H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t acpl_id) +H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - hid_t ret_value; /* Return value */ + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, acpl_id); - /* 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(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + /* Check arguments */ + if (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A__create(&loc, name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + /* Get correct property list */ + if (H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Create the attribute */ + if (NULL == + (attr = H5VL_attr_create(vol_obj, &loc_params, name, type_id, space_id, acpl_id, + H5P_ATTRIBUTE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: - /* Cleanup on failure */ - if(ret_value < 0 && attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Clean up on failure */ + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) -} /* H5Acreate1() */ +} /* end H5Acreate1() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_name @@ -167,7 +165,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t loc_id; IN: Object (dataset or group) to be attached to const char *name; IN: Name of attribute to locate and open RETURNS - ID of attribute on success, negative on failure + ID of attribute on success, H5I_INVALID_HID on failure DESCRIPTION This function opens an existing attribute for access. The attribute @@ -182,39 +180,46 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t H5Aopen_name(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value; + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); - /* 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(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Check arguments */ + if (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, ".", name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute: '%s'", name) + /* Open the attribute */ + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, name, H5P_ATTRIBUTE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Clean up on failure */ + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_name() */ - /*-------------------------------------------------------------------------- NAME H5Aopen_idx @@ -225,7 +230,7 @@ H5Aopen_name(hid_t loc_id, const char *name) hid_t loc_id; IN: Object that attribute is attached to unsigned idx; IN: Index (0-based) attribute to open RETURNS - ID of attribute on success, negative on failure + ID of attribute on success, H5I_INVALID_HID on failure DESCRIPTION This function opens an existing attribute for access. The attribute @@ -240,37 +245,49 @@ H5Aopen_name(hid_t loc_id, const char *name) hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value; + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iIu", loc_id, idx); - /* 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(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx))) + /* Check arguments */ + if (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Open the attribute */ + if (NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, H5P_ATTRIBUTE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Clean up on failure */ + if (H5I_INVALID_HID == ret_value) + if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen_idx() */ - /*-------------------------------------------------------------------------- NAME H5Aget_num_attrs @@ -292,62 +309,32 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) int H5Aget_num_attrs(hid_t loc_id) { - H5O_loc_t *loc; /* Object location for attribute */ - void *obj; - int ret_value; + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + H5O_info2_t oinfo; + int ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", loc_id); - /* check arguments */ - if(H5I_BADID == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad location ID") - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") - switch(H5I_get_type (loc_id)) { - case H5I_DATASET: - if(NULL == (loc = H5D_oloc((H5D_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") - break; - - case H5I_GROUP: - if(NULL == (loc = H5G_oloc((H5G_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") - } /*lint !e788 All appropriate cases are covered */ - - /* Look up the # of attributes for the object */ - if((ret_value = H5O__attr_count(loc)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Get the number of attributes for the object */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &oinfo, H5O_INFO_NUM_ATTRS) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") + + H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); done: FUNC_LEAVE_API(ret_value) } /* H5Aget_num_attrs() */ - /*-------------------------------------------------------------------------- NAME H5Aiterate1 @@ -388,21 +375,26 @@ H5Aget_num_attrs(hid_t loc_id) herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + herr_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5_ITER_ERROR) H5TRACE4("e", "i*Iux*x", loc_id, attr_num, op, op_data); /* 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 (H5I_ATTR == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "location is not valid for an attribute") + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") /* Call attribute iteration routine */ - if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + if ((ret_value = H5VL_attr_optional(vol_obj, H5VL_NATIVE_ATTR_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) } /* H5Aiterate1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Aint.c b/src/H5Aint.c index defd4ebb999..0609f24b5c7 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,79 +26,73 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 */ - 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 */ + 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 */ } H5A_compact_bt_ud_t; /* Data exchange structure to use when building table of dense attributes for an object */ typedef struct { - H5A_attr_table_t *atable; /* Pointer to attribute table to build */ - size_t curr_attr; /* Current attribute to operate on */ + H5A_attr_table_t *atable; /* Pointer to attribute table to build */ + size_t curr_attr; /* Current attribute to operate on */ } H5A_dense_bt_ud_t; /* 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; + 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; } H5A_dense_file_cp_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5A__open_common(const H5G_loc_t *loc, H5A_t *attr); -static herr_t H5A__compact_build_table_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/); +static herr_t H5A__compact_build_table_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_flags_ptr, void *_udata /*in,out*/); static herr_t H5A__dense_build_table_cb(const H5A_t *attr, void *_udata); -static int H5A__attr_cmp_name_inc(const void *attr1, const void *attr2); -static int H5A__attr_cmp_name_dec(const void *attr1, const void *attr2); -static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2); -static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2); -static herr_t H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, - H5_iter_order_t order); -static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5A_attr_iter_op_t *attr_op, void *op_data); +static int H5A__attr_cmp_name_inc(const void *attr1, const void *attr2); +static int H5A__attr_cmp_name_dec(const void *attr1, const void *attr2); +static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2); +static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2); +static herr_t H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_order_t order); +static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5A_attr_iter_op_t *attr_op, void *op_data); /*********************/ /* Package Variables */ @@ -106,51 +100,49 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, /* Format version bounds for attribute */ const unsigned H5O_attr_ver_bounds[] = { - H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */ - H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_ATTR_VERSION_3, /* H5F_LIBVER_V110 */ + H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ -typedef H5A_t* H5A_t_ptr; +typedef H5A_t *H5A_t_ptr; H5FL_SEQ_DEFINE(H5A_t_ptr); - /*------------------------------------------------------------------------- - * Function: H5A__create + * Function: H5A__create * * Purpose: This is the guts of creating an attribute. * * Return: Attribute structure on success, NULL on Failure. * - * Programmer: Quincey Koziol - * April 2, 1998 + * Programmer: Quincey Koziol + * April 2, 1998 * *------------------------------------------------------------------------- */ H5A_t * -H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, - const H5S_t *space, hid_t acpl_id) +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 */ - 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 * 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 */ FUNC_ENTER_PACKAGE_TAG(loc->oloc->addr) /* Check args */ HDassert(loc); - HDassert(name); + HDassert(attr_name); HDassert(type); HDassert(space); @@ -159,90 +151,91 @@ H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, * name, but it's going to be hard to unwind all the special cases on * failure, so just check first, for now - QAK) */ - if((exists = H5O__attr_exists(loc->oloc, name)) < 0) + if ((exists = H5O__attr_exists(loc->oloc, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "error checking attributes") - else if(exists > 0) + else if (exists > 0) HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, NULL, "attribute already exists") /* Check if the dataspace has an extent set (or is NULL) */ - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, NULL, "dataspace extent has not been set") /* Check if the datatype is "sensible" for use in a dataset */ - if(H5T_is_sensible(type) != TRUE) + if (H5T_is_sensible(type) != TRUE) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, NULL, "datatype is not sensible") /* Build the attribute information */ - if(NULL == (attr = H5FL_CALLOC(H5A_t))) + if (NULL == (attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed for attribute info") - if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "can't allocate shared attr structure") - /* If the creation property list is H5P_DEFAULT, use the default character encoding */ - if(acpl_id == H5P_DEFAULT) + /* If the creation property list is H5P_ATTRIBUTE_CREATE_DEFAULT, use the default character encoding */ + HDassert(acpl_id != H5P_DEFAULT); + if (acpl_id == H5P_ATTRIBUTE_CREATE_DEFAULT) attr->shared->encoding = H5F_DEFAULT_CSET; else { - H5P_genplist_t *ac_plist; /* ACPL Property list */ + H5P_genplist_t *ac_plist; /* ACPL Property list */ /* Get a local copy of the attribute creation property list */ - if(NULL == (ac_plist = (H5P_genplist_t *)H5I_object(acpl_id))) + if (NULL == (ac_plist = (H5P_genplist_t *)H5I_object(acpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") - if(H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) + if (H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get character encoding flag") } /* end else */ /* Copy the attribute name */ - attr->shared->name = H5MM_xstrdup(name); + attr->shared->name = H5MM_xstrdup(attr_name); /* Copy datatype */ - if(NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL))) + if (NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info") /* Convert a datatype (if committed) to a transient type if the committed datatype's file location is different from the file location where the attribute will be created */ - if(H5T_convert_committed_datatype(attr->shared->dt, loc->oloc->file) < 0) + if (H5T_convert_committed_datatype(attr->shared->dt, loc->oloc->file) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info") /* Mark datatype as being on disk now */ - if(H5T_set_loc(attr->shared->dt, loc->oloc->file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(attr->shared->dt, H5F_VOL_OBJ(loc->oloc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set the version for datatype */ - if(H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) + if (H5T_set_version(loc->oloc->file, attr->shared->dt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of datatype") /* Copy the dataspace for the attribute */ attr->shared->ds = H5S_copy(space, FALSE, TRUE); /* Set the version for dataspace */ - if(H5S_set_version(loc->oloc->file, attr->shared->ds) < 0) + if (H5S_set_version(loc->oloc->file, attr->shared->ds) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set version of dataspace") /* Copy the object header information */ - if(H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) + if (H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to copy entry") /* Deep copy of the group hierarchy path */ - if(H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy path") /* Check if any of the pieces should be (or are already) shared in the * SOHM table */ - if(H5SM_try_share(attr->oloc.file, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) + if (H5SM_try_share(attr->oloc.file, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share datatype failed") - if(H5SM_try_share(attr->oloc.file, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) + if (H5SM_try_share(attr->oloc.file, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share dataspace failed") /* Check whether datatype is committed & increment ref count * (to maintain ref. count incr/decr similarity with "shared message" * type of datatype sharing) */ - if(H5T_committed(attr->shared->dt)) + if (H5T_is_named(attr->shared->dt)) /* Increment the reference count on the shared datatype */ - if(H5T_link(attr->shared->dt, 1) < 0) + if (H5T_link(attr->shared->dt, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, NULL, "unable to adjust shared datatype link count") /* Compute the size of pieces on disk. This is either the size of the @@ -253,7 +246,7 @@ H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, attr->shared->ds_size = H5O_msg_raw_size(attr->oloc.file, H5O_SDSPACE_ID, FALSE, attr->shared->ds); /* Get # of elements for attribute's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, NULL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); @@ -262,16 +255,16 @@ H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, attr->shared->data_size = nelmts * H5T_GET_SIZE(attr->shared->dt); /* Hold the symbol table entry (and file) open */ - if(H5O_open(&(attr->oloc)) < 0) + if (H5O_open(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open") attr->obj_opened = TRUE; /* Set the version to encode the attribute with */ - if(H5A__set_version(attr->oloc.file, attr) < 0) + if (H5A__set_version(attr->oloc.file, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version") /* Insert the attribute into the object header */ - if(H5O__attr_create(&(attr->oloc), attr) < 0) + if (H5O__attr_create(&(attr->oloc), attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, NULL, "unable to create attribute in object header") /* Set return value */ @@ -279,13 +272,12 @@ H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, done: /* Cleanup on failure */ - if(NULL == ret_value && attr && H5A__close(attr)) + if (NULL == ret_value && attr && H5A__close(attr)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__create() */ - /*------------------------------------------------------------------------- * Function: H5A__create_by_name * @@ -299,15 +291,15 @@ H5A__create(const H5G_loc_t *loc, const char *name, const H5T_t *type, *------------------------------------------------------------------------- */ H5A_t * -H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, - const H5T_t *type, const H5S_t *space, hid_t acpl_id) +H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, const H5T_t *type, + const H5S_t *space, hid_t acpl_id) { - 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -322,12 +314,12 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Go do the real work for attaching the attribute to the object */ - if(NULL == (attr = H5A__create(&obj_loc, attr_name, type, space, acpl_id))) + if (NULL == (attr = H5A__create(&obj_loc, attr_name, type, space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") /* Set return value */ @@ -335,18 +327,17 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__create_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__open_common * @@ -364,12 +355,12 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5A__open_common(const H5G_loc_t *loc, H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* check args */ HDassert(loc); @@ -377,24 +368,24 @@ H5A__open_common(const H5G_loc_t *loc, H5A_t *attr) #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear object location */ - if(H5O_loc_reset(&(attr->oloc)) < 0) + if (H5O_loc_reset(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to reset location") #endif /* H5_USING_MEMCHECKER */ /* Free any previous group hier. path */ - if(H5G_name_free(&(attr->path)) < 0) + if (H5G_name_free(&(attr->path)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release group hier. path") /* Deep copy of the symbol table entry */ - if(H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) + if (H5O_loc_copy_deep(&(attr->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Deep copy of the group hier. path */ - if(H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy entry") /* Hold the symbol table entry (and file) open */ - if(H5O_open(&(attr->oloc)) < 0) + if (H5O_open(&(attr->oloc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") attr->obj_opened = TRUE; @@ -402,24 +393,23 @@ H5A__open_common(const H5G_loc_t *loc, H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_common() */ - /*------------------------------------------------------------------------- - * Function: H5A__open + * Function: H5A__open * - * Purpose: Open an attribute in an object header + * Purpose: Open an attribute in an object header * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * December 9, 2017 + * Programmer: Quincey Koziol + * December 9, 2017 * *------------------------------------------------------------------------- */ H5A_t * H5A__open(const H5G_loc_t *loc, const char *attr_name) { - 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 @@ -428,11 +418,12 @@ H5A__open(const H5G_loc_t *loc, const char *attr_name) HDassert(attr_name); /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_name(loc->oloc, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header for attribute: '%s'", attr_name) + if (NULL == (attr = H5O__attr_open_by_name(loc->oloc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, + "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Finish initializing attribute */ - if(H5A__open_common(loc, attr) < 0) + if (H5A__open_common(loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -440,14 +431,13 @@ H5A__open(const H5G_loc_t *loc, const char *attr_name) done: /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open() */ - /*------------------------------------------------------------------------- * Function: H5A__open_by_idx * @@ -455,21 +445,21 @@ H5A__open(const H5G_loc_t *loc, const char *attr_name) * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * April 2, 1998 + * Programmer: Quincey Koziol + * April 2, 1998 * *------------------------------------------------------------------------- */ H5A_t * -H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -483,16 +473,16 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_idx(obj_loc.oloc, idx_type, order, n))) + if (NULL == (attr = H5O__attr_open_by_idx(obj_loc.oloc, idx_type, order, n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header") /* Finish initializing attribute */ - if(H5A__open_common(&obj_loc, attr) < 0) + if (H5A__open_common(&obj_loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -500,18 +490,17 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5A__open_by_name * @@ -519,20 +508,20 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * December 11, 2006 + * Programmer: Quincey Koziol + * December 11, 2006 * *------------------------------------------------------------------------- */ H5A_t * H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name) { - 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -547,16 +536,16 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Read in attribute from object header */ - if(NULL == (attr = H5O__attr_open_by_name(obj_loc.oloc, attr_name))) + if (NULL == (attr = H5O__attr_open_by_name(obj_loc.oloc, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header") /* Finish initializing attribute */ - if(H5A__open_common(loc, attr) < 0) + if (H5A__open_common(loc, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") /* Set return value */ @@ -564,18 +553,17 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") /* Cleanup on failure */ - if(ret_value == NULL) - if(attr && H5A__close(attr) < 0) + if (ret_value == NULL) + if (attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_name() */ - /*-------------------------------------------------------------------------- NAME H5A__read @@ -595,16 +583,16 @@ 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 */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute*/ - H5T_path_t *tpath = NULL; /* type conversion info */ - hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/ - size_t src_type_size; /* size of source type */ - size_t dst_type_size; /* size of destination type */ - size_t buf_size; /* desired buffer size */ - herr_t ret_value = SUCCEED; + 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 */ + hid_t src_id = -1, dst_id = -1; /* temporary type atoms*/ + size_t src_type_size; /* size of source type */ + size_t dst_type_size; /* size of destination type */ + size_t buf_size; /* desired buffer size */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr) @@ -612,47 +600,49 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, 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, attr->oloc.file) < 0 ) + /* 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_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch VL datatype file pointer") /* Create buffer for data to store on disk */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); - if(nelmts > 0) { + if (nelmts > 0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_GET_SIZE(attr->shared->dt); dst_type_size = H5T_GET_SIZE(mem_type); /* Check if the attribute has any data yet, if not, fill with zeroes */ - if(attr->obj_opened && !attr->shared->data) + if (attr->obj_opened && !attr->shared->data) HDmemset(buf, 0, (dst_type_size * nelmts)); - else { /* Attribute exists and has a value */ + else { /* Attribute exists and has a value */ /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(attr->shared->dt, mem_type))) - HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (tpath = H5T_path_find(attr->shared->dt, mem_type))) + HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if(!H5T_path_noop(tpath)) { - 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) + if (!H5T_path_noop(tpath)) { + 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) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts * MAX(src_type_size, dst_type_size); - if(NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_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))) + 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)); /* Perform datatype conversion. */ - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) + 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") /* Copy the converted data into the user's buffer */ @@ -665,24 +655,23 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) /* Copy the attribute data into the user's buffer */ H5MM_memcpy(buf, attr->shared->data, (dst_type_size * nelmts)); } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + 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) + if (tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__read() */ - /*-------------------------------------------------------------------------- NAME H5A__write @@ -702,17 +691,17 @@ 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 */ - hssize_t snelmts; /* elements in attribute */ - size_t nelmts; /* elements in attribute */ - H5T_path_t *tpath = NULL; /* conversion information*/ - hid_t src_id = -1, dst_id = -1;/* temporary type atoms */ - size_t src_type_size; /* size of source type */ - size_t dst_type_size; /* size of destination type*/ - size_t buf_size; /* desired buffer size */ - herr_t ret_value = SUCCEED; + 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 */ + hssize_t snelmts; /* elements in attribute */ + size_t nelmts; /* elements in attribute */ + H5T_path_t *tpath = NULL; /* conversion information*/ + hid_t src_id = -1, dst_id = -1; /* temporary type atoms */ + size_t src_type_size; /* size of source type */ + size_t dst_type_size; /* size of destination type*/ + size_t buf_size; /* desired buffer size */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr) @@ -721,56 +710,56 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) HDassert(buf); /* Get # of elements for attribute's dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_CHECKED_ASSIGN(nelmts, size_t, snelmts, hssize_t); /* If there's actually data elements for the attribute, make a copy of the data passed in */ - if(nelmts > 0) { + if (nelmts > 0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_GET_SIZE(mem_type); dst_type_size = H5T_GET_SIZE(attr->shared->dt); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(mem_type, attr->shared->dt))) + if (NULL == (tpath = H5T_path_find(mem_type, attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if(!H5T_path_noop(tpath)) { - 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) + if (!H5T_path_noop(tpath)) { + 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") /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts * MAX(src_type_size, dst_type_size); - if(NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_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))) + 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)); /* Perform datatype conversion */ - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) + 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") /* Free the previous attribute data buffer, if there is one */ - if(attr->shared->data) + if (attr->shared->data) attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data); /* Set the pointer to the attribute data to the converted information */ attr->shared->data = tconv_buf; - tconv_owned = TRUE; + tconv_owned = TRUE; } /* end if */ /* No type conversion necessary */ else { HDassert(dst_type_size == src_type_size); /* Allocate the attribute buffer, if there isn't one */ - if(attr->shared->data == NULL) - if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts))) + if (attr->shared->data == NULL) + if (NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the attribute data buffer */ @@ -778,25 +767,24 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) } /* end else */ /* Modify the attribute in the object header */ - if(H5O__attr_write(&(attr->oloc), attr) < 0) + if (H5O__attr_write(&(attr->oloc), attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to modify attribute") } /* end if */ done: /* Release resources */ - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + 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_owned) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__write() */ - /*-------------------------------------------------------------------------- NAME H5A__get_name @@ -816,8 +804,8 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) { - size_t copy_len, nbytes; - ssize_t ret_value = -1; /* Return value */ + size_t copy_len, nbytes; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -829,11 +817,11 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) copy_len = MIN(buf_size - 1, nbytes); /* Copy all/some of the name */ - if(buf && copy_len > 0) { + if (buf && copy_len > 0) { H5MM_memcpy(buf, attr->shared->name, copy_len); /* Terminate the string */ - buf[copy_len]='\0'; + buf[copy_len] = '\0'; } /* end if */ /* Set return value */ @@ -842,7 +830,6 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) FUNC_LEAVE_NOAPI(ret_value) } /* H5A__get_name() */ - /*------------------------------------------------------------------------- * Function: H5A_get_space * @@ -857,8 +844,8 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) hid_t H5A_get_space(H5A_t *attr) { - H5S_t *ds = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *ds = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI_NOINIT @@ -879,7 +866,6 @@ H5A_get_space(H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_space() */ - /*------------------------------------------------------------------------- * Function: H5A__get_type * @@ -893,8 +879,8 @@ H5A_get_space(H5A_t *attr) hid_t H5A__get_type(H5A_t *attr) { - H5T_t *dt = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5T_t *dt = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE @@ -920,18 +906,27 @@ H5A__get_type(H5A_t *attr) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to lock transient datatype") /* Atomize */ - if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") + 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 + * returned datatype + */ + if ((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + } + else { + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") + } done: - if(H5I_INVALID_HID == ret_value) - if(dt && H5T_close(dt) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_type() */ - /*-------------------------------------------------------------------------- NAME H5A__get_create_plist @@ -949,26 +944,26 @@ H5A__get_type(H5A_t *attr) resource leaks will occur. --------------------------------------------------------------------------*/ hid_t -H5A__get_create_plist(H5A_t* attr) +H5A__get_create_plist(H5A_t *attr) { - H5P_genplist_t *plist; /* Default property list */ - hid_t new_plist_id; /* ID of ACPL to return */ - H5P_genplist_t *new_plist; /* ACPL to return */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *plist; /* Default property list */ + hid_t new_plist_id; /* ID of ACPL to return */ + H5P_genplist_t *new_plist; /* ACPL to return */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE - if(NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(H5P_LST_ATTRIBUTE_CREATE_ID_g))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get default ACPL") /* Create the property list object to return */ - if((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0) + if ((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") /* Set the character encoding on the new property list */ - if(H5P_set(new_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) + if (H5P_set(new_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") ret_value = new_plist_id; @@ -977,16 +972,15 @@ H5A__get_create_plist(H5A_t* attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_create_plist() */ - /*------------------------------------------------------------------------- - * Function: H5A__get_info + * Function: H5A__get_info * - * Purpose: Retrieve information about an attribute. + * Purpose: Retrieve information about an attribute. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * February 6, 2007 * *------------------------------------------------------------------------- @@ -994,7 +988,7 @@ H5A__get_create_plist(H5A_t* attr) herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1003,22 +997,21 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) HDassert(ainfo); /* Set info for attribute */ - ainfo->cset = attr->shared->encoding; + ainfo->cset = attr->shared->encoding; ainfo->data_size = attr->shared->data_size; - if(attr->shared->crt_idx == H5O_MAX_CRT_ORDER_IDX) { + if (attr->shared->crt_idx == H5O_MAX_CRT_ORDER_IDX) { ainfo->corder_valid = FALSE; - ainfo->corder = 0; + ainfo->corder = 0; } /* end if */ else { ainfo->corder_valid = TRUE; - ainfo->corder = attr->shared->crt_idx; + ainfo->corder = attr->shared->crt_idx; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ - /*------------------------------------------------------------------------- * Function: H5A__copy * @@ -1027,17 +1020,17 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) * Return: Success: Pointer to a new copy of the OLD_ATTR argument. * Failure: NULL * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ H5A_t * H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) { - H5A_t *new_attr = NULL; - hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t * new_attr = NULL; + hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1045,8 +1038,8 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) HDassert(old_attr); /* Allocate attribute structure */ - if(_new_attr == NULL) { - if(NULL == (new_attr = H5FL_CALLOC(H5A_t))) + if (_new_attr == NULL) { + if (NULL == (new_attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") allocated_attr = TRUE; } /* end if */ @@ -1057,7 +1050,7 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) new_attr->sh_loc = old_attr->sh_loc; /* Deep copy of the group hierarchy path */ - if(H5G_name_copy(&(new_attr->path), &(old_attr->path), H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(new_attr->path), &(old_attr->path), H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy path") /* Share some attribute information */ @@ -1073,88 +1066,95 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) ret_value = new_attr; done: - if(ret_value == NULL) - if(allocated_attr && new_attr && H5A__close(new_attr) < 0) + if (ret_value == NULL) + if (allocated_attr && new_attr && H5A__close(new_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__copy() */ - /*------------------------------------------------------------------------- - * Function: H5A__free + * Function: H5A__shared_free + * + * Purpose: Cleans up the shared attribute data. This will free + * the attribute's shared structure as well. * - * Purpose: Frees all memory associated with an attribute, but does not - * free the H5A_t structure (which should be done in H5T_close). + * attr and attr->shared must not be NULL * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Monday, November 15, 2004 + * Programmer: Quincey Koziol + * Monday, November 15, 2004 * *------------------------------------------------------------------------- */ herr_t -H5A__free(H5A_t *attr) +H5A__shared_free(H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(attr); + HDassert(attr->shared); - /* Free dynamically allocated items */ - if(attr->shared->name) { + /* Free dynamically allocated items. + * When possible, keep trying to shut things down (via HDONE_ERROR). + */ + if (attr->shared->name) { H5MM_xfree(attr->shared->name); attr->shared->name = NULL; } - if(attr->shared->dt) { - if(H5T_close_real(attr->shared->dt) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") + if (attr->shared->dt) { + if (H5T_close_real(attr->shared->dt) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") attr->shared->dt = NULL; } - if(attr->shared->ds) { - if(H5S_close(attr->shared->ds) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") + if (attr->shared->ds) { + if (H5S_close(attr->shared->ds) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") attr->shared->ds = NULL; } - if(attr->shared->data) + if (attr->shared->data) attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data); -done: + /* Destroy shared attribute struct */ + attr->shared = H5FL_FREE(H5A_shared_t, attr->shared); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A__free() */ +} /* end H5A__shared_free() */ - /*------------------------------------------------------------------------- * Function: H5A__close_cb * - * Purpose: Frees an attribute and all associated memory. + * Purpose: Called when the ref count reaches zero on the attribute's ID * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5A__close_cb(H5A_t *attr) +H5A__close_cb(H5VL_object_t *attr_vol_obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - HDassert(attr); - HDassert(attr->shared); + HDassert(attr_vol_obj); - /* Call the actual close routine */ - if(H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "problem closing attribute") + /* Close the attribute */ + if ((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute") + + /* Free the VOL object */ + if (H5VL_free_object(attr_vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__close * @@ -1162,15 +1162,15 @@ H5A__close_cb(H5A_t *attr) * * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke - * Monday, December 8, 1997 + * Programmer: Robb Matzke + * Monday, December 8, 1997 * *------------------------------------------------------------------------- */ herr_t H5A__close(H5A_t *attr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1178,17 +1178,15 @@ H5A__close(H5A_t *attr) HDassert(attr->shared); /* Close the object's symbol-table entry */ - if(attr->obj_opened && (H5O_close(&(attr->oloc), NULL) < 0)) + if (attr->obj_opened && (H5O_close(&(attr->oloc), NULL) < 0)) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info") /* Reference count can be 0. It only happens when H5A__create fails. */ - if(attr->shared->nrefs <= 1) { + if (attr->shared->nrefs <= 1) { /* Free dynamically allocated items */ - if(H5A__free(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") - - /* Destroy shared attribute struct */ - attr->shared = H5FL_FREE(H5A_shared_t, attr->shared); + if (attr->shared) + if (H5A__shared_free(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") } /* end if */ else { /* There are other references to the shared part of the attribute. @@ -1197,28 +1195,27 @@ H5A__close(H5A_t *attr) } /* end else */ /* Free group hierarchy path */ - if(H5G_name_free(&(attr->path)) < 0) + if (H5G_name_free(&(attr->path)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release group hier. path") attr->shared = NULL; - attr = H5FL_FREE(H5A_t, attr); + attr = H5FL_FREE(H5A_t, attr); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close() */ - /*------------------------------------------------------------------------- * Function: H5A_oloc * - * Purpose: Return the object location for an attribute. It's the - * object location for the object to which the attribute - * belongs, not the attribute itself. + * Purpose: Return the object location for an attribute. It's the + * object location for the object to which the attribute + * belongs, not the attribute itself. * - * Return: Success: Ptr to entry - * Failure: NULL + * Return: Success: Ptr to entry + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 6, 1998 * *------------------------------------------------------------------------- @@ -1226,7 +1223,7 @@ H5A__close(H5A_t *attr) H5O_loc_t * H5A_oloc(H5A_t *attr) { - H5O_loc_t *ret_value = NULL; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1239,18 +1236,17 @@ H5A_oloc(H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ - /*------------------------------------------------------------------------- * Function: H5A_nameof * - * Purpose: Return the group hier. path for an attribute. It's the - * group hier. path for the object to which the attribute - * belongs, not the attribute itself. + * Purpose: Return the group hier. path for an attribute. It's the + * group hier. path for the object to which the attribute + * belongs, not the attribute itself. * - * Return: Success: Ptr to entry - * Failure: NULL + * Return: Success: Ptr to entry + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, September 12, 2005 * *------------------------------------------------------------------------- @@ -1258,7 +1254,7 @@ H5A_oloc(H5A_t *attr) H5G_name_t * H5A_nameof(H5A_t *attr) { - H5G_name_t *ret_value = NULL; /* Return value */ + H5G_name_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1271,7 +1267,6 @@ H5A_nameof(H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ - /*------------------------------------------------------------------------- * Function: H5A_type * @@ -1288,7 +1283,7 @@ H5A_nameof(H5A_t *attr) H5T_t * H5A_type(const H5A_t *attr) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1301,15 +1296,14 @@ H5A_type(const H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ - /*------------------------------------------------------------------------- * Function: H5A__exists_by_name * - * Purpose: Private version of H5Aexists_by_name + * Purpose: Private version of H5Aexists_by_name * * Return: TRUE/FALSE/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, November 1, 2007 * *------------------------------------------------------------------------- @@ -1317,11 +1311,11 @@ H5A_type(const H5A_t *attr) htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name) { - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1331,33 +1325,32 @@ H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name) H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Check if the attribute exists */ - if((ret_value = H5O__attr_exists(obj_loc.oloc, attr_name)) < 0) + if ((ret_value = H5O__attr_exists(obj_loc.oloc, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__exists_by_name() */ - /*------------------------------------------------------------------------- - * Function: H5A__compact_build_table_cb + * Function: H5A__compact_build_table_cb * - * Purpose: Object header iterator callback routine to copy attribute + * Purpose: Object header iterator callback routine to copy attribute * into table. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Dec 18 2006 + * Programmer: Quincey Koziol + * Dec 18 2006 * * Modification:Raymond Lu * 24 June 2008 @@ -1366,11 +1359,11 @@ H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name) *------------------------------------------------------------------------- */ static herr_t -H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5A_compact_bt_ud_t *udata = (H5A_compact_bt_ud_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_compact_bt_ud_t *udata = (H5A_compact_bt_ud_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1378,26 +1371,26 @@ H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/ HDassert(mesg); /* Re-allocate the table if necessary */ - if(udata->curr_attr == udata->atable->nattrs) { - H5A_t **new_table; /* New table for attributes */ - size_t new_table_size; /* Number of attributes in new table */ + if (udata->curr_attr == udata->atable->nattrs) { + H5A_t **new_table; /* New table for attributes */ + size_t new_table_size; /* Number of attributes in new table */ /* Allocate larger table */ new_table_size = MAX(1, 2 * udata->atable->nattrs); - if(NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size))) + if (NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "unable to extend attribute table") /* Update table information in user data */ - udata->atable->attrs = new_table; + udata->atable->attrs = new_table; udata->atable->nattrs = new_table_size; } /* end if */ /* Copy attribute into table */ - if(NULL == (udata->atable->attrs[udata->curr_attr] = H5A__copy(NULL, (const H5A_t *)mesg->native))) + if (NULL == (udata->atable->attrs[udata->curr_attr] = H5A__copy(NULL, (const H5A_t *)mesg->native))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Assign [somewhat arbitrary] creation order value, if requested */ - if(udata->bogus_crt_idx) + if (udata->bogus_crt_idx) ((udata->atable->attrs[udata->curr_attr])->shared)->crt_idx = sequence; /* Increment current attribute */ @@ -1407,7 +1400,6 @@ H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/ FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__compact_build_table * @@ -1425,12 +1417,12 @@ H5A__compact_build_table_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/ *------------------------------------------------------------------------- */ herr_t -H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, - H5_iter_order_t order, H5A_attr_table_t *atable) +H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable) { - H5A_compact_bt_ud_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_compact_bt_ud_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1440,29 +1432,29 @@ H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, HDassert(atable); /* Initialize table */ - atable->attrs = NULL; + atable->attrs = NULL; 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; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5A__compact_build_table_cb; - if(H5O__msg_iterate_real(f, oh, H5O_MSG_ATTR, &op, &udata) < 0) + if (H5O__msg_iterate_real(f, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error building attribute table") /* Correct # of attributes in table */ atable->nattrs = udata.curr_attr; /* Don't sort an empty table. */ - if(atable->nattrs > 0) { + if (atable->nattrs > 0) { /* Sort attribute table in correct iteration order */ - if(H5A__attr_sort_table(atable, idx_type, order) < 0) + if (H5A__attr_sort_table(atable, idx_type, order) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSORT, FAIL, "error sorting attribute table") } /* end if */ @@ -1470,25 +1462,24 @@ H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table() */ - /*------------------------------------------------------------------------- - * Function: H5A__dense_build_table_cb + * Function: H5A__dense_build_table_cb * - * Purpose: Callback routine for building table of attributes from dense + * Purpose: Callback routine for building table of attributes from dense * attribute storage. * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ static herr_t H5A__dense_build_table_cb(const H5A_t *attr, void *_udata) { - H5A_dense_bt_ud_t *udata = (H5A_dense_bt_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_dense_bt_ud_t *udata = (H5A_dense_bt_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1498,11 +1489,11 @@ H5A__dense_build_table_cb(const H5A_t *attr, void *_udata) HDassert(udata->curr_attr < udata->atable->nattrs); /* Allocate attribute for entry in the table */ - if(NULL == (udata->atable->attrs[udata->curr_attr] = H5FL_CALLOC(H5A_t))) + if (NULL == (udata->atable->attrs[udata->curr_attr] = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, H5_ITER_ERROR, "can't allocate attribute") /* Copy attribute information. Share the attribute object in copying. */ - if(NULL == H5A__copy(udata->atable->attrs[udata->curr_attr], attr)) + if (NULL == H5A__copy(udata->atable->attrs[udata->curr_attr], attr)) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Increment number of attributes stored */ @@ -1512,31 +1503,30 @@ H5A__dense_build_table_cb(const H5A_t *attr, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_build_table * * Purpose: Builds a table containing a sorted list of attributes for * an object * - * Note: Used for building table of attributes in non-native iteration + * Note: Used for building table of attributes in non-native iteration * order for an index. Uses the "name" index to retrieve records, - * but the 'idx_type' index for sorting them. + * but the 'idx_type' index for sorting them. * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Dec 11, 2006 + * Programmer: Quincey Koziol + * Dec 11, 2006 * *------------------------------------------------------------------------- */ herr_t -H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable) +H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - hsize_t nrec; /* # of records in v2 B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + hsize_t nrec; /* # of records in v2 B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1548,12 +1538,12 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, HDassert(atable); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &nrec) < 0) + if (H5B2_get_nrec(bt2_name, &nrec) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve # of records in index") /* Set size of table */ @@ -1561,29 +1551,29 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, atable->nattrs = (size_t)nrec; /* Allocate space for the table entries */ - if(atable->nattrs > 0) { - H5A_dense_bt_ud_t udata; /* User data for iteration callback */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ + if (atable->nattrs > 0) { + H5A_dense_bt_ud_t udata; /* User data for iteration callback */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ /* Allocate the table to store the attributes */ - if((atable->attrs = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, atable->nattrs)) == NULL) + if ((atable->attrs = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, atable->nattrs)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.atable = atable; + udata.atable = atable; udata.curr_attr = 0; /* Build iterator operator */ - attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5A__dense_build_table_cb; /* Iterate over the links in the group, building a table of the link messages */ - if(H5A__dense_iterate(f, (hid_t)0, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, - (hsize_t)0, NULL, &attr_op, &udata) < 0) + if (H5A__dense_iterate(f, (hid_t)0, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, + &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Sort attribute table in correct iteration order */ - if(H5A__attr_sort_table(atable, idx_type, order) < 0) + if (H5A__attr_sort_table(atable, idx_type, order) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSORT, FAIL, "error sorting attribute table") } /* end if */ else @@ -1591,13 +1581,12 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_name_inc * @@ -1610,8 +1599,8 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, * as equal, their order in the sorted array is undefined. * (i.e. same as strcmp()) * - * Programmer: Quincey Koziol - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -1620,25 +1609,24 @@ H5A__attr_cmp_name_inc(const void *attr1, const void *attr2) { FUNC_ENTER_STATIC_NOERR - FUNC_LEAVE_NOAPI(HDstrcmp((*(const H5A_t * const *)attr1)->shared->name, - (*(const H5A_t * const *)attr2)->shared->name)) + FUNC_LEAVE_NOAPI( + HDstrcmp((*(const H5A_t *const *)attr1)->shared->name, (*(const H5A_t *const *)attr2)->shared->name)) } /* end H5A__attr_cmp_name_inc() */ - /*------------------------------------------------------------------------- - * Function: H5A__attr_cmp_name_dec + * Function: H5A__attr_cmp_name_dec * - * Purpose: Callback routine for comparing two attribute names, in + * Purpose: Callback routine for comparing two attribute names, in * decreasing alphabetic order * - * Return: An integer less than, equal to, or greater than zero if the + * Return: An integer less than, equal to, or greater than zero if the * second argument is considered to be respectively less than, * equal to, or greater than the first. If two members compare * as equal, their order in the sorted array is undefined. * (i.e. opposite of strcmp()) * - * Programmer: Quincey Koziol - * Feb 8 2007 + * Programmer: Quincey Koziol + * Feb 8 2007 * *------------------------------------------------------------------------- */ @@ -1647,37 +1635,37 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) { FUNC_ENTER_STATIC_NOERR - FUNC_LEAVE_NOAPI(HDstrcmp((*(const H5A_t * const *)attr2)->shared->name, - (*(const H5A_t * const *)attr1)->shared->name)) + FUNC_LEAVE_NOAPI( + HDstrcmp((*(const H5A_t *const *)attr2)->shared->name, (*(const H5A_t *const *)attr1)->shared->name)) } /* end H5A__attr_cmp_name_dec() */ - /*------------------------------------------------------------------------- - * Function: H5A__attr_cmp_corder_inc + * Function: H5A__attr_cmp_corder_inc * - * Purpose: Callback routine for comparing two attributes, in + * Purpose: Callback routine for comparing two attributes, in * increasing creation order * - * Return: An integer less than, equal to, or greater than zero if the + * Return: An integer less than, equal to, or greater than zero if the * first argument is considered to be respectively less than, * equal to, or greater than the second. If two members compare * as equal, their order in the sorted array is undefined. * - * Programmer: Quincey Koziol - * Feb 8 2007 + * Programmer: Quincey Koziol + * Feb 8 2007 * *------------------------------------------------------------------------- */ static int H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR - if((*(const H5A_t * const *)attr1)->shared->crt_idx < (*(const H5A_t * const *)attr2)->shared->crt_idx) + if ((*(const H5A_t *const *)attr1)->shared->crt_idx < (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = -1; - else if((*(const H5A_t * const *)attr1)->shared->crt_idx > (*(const H5A_t * const *)attr2)->shared->crt_idx) + else if ((*(const H5A_t *const *)attr1)->shared->crt_idx > + (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = 1; else ret_value = 0; @@ -1685,7 +1673,6 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_inc() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_corder_dec * @@ -1705,13 +1692,14 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) static int H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR - if((*(const H5A_t * const *)attr1)->shared->crt_idx < (*(const H5A_t * const *)attr2)->shared->crt_idx) + if ((*(const H5A_t *const *)attr1)->shared->crt_idx < (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = 1; - else if((*(const H5A_t * const *)attr1)->shared->crt_idx > (*(const H5A_t * const *)attr2)->shared->crt_idx) + else if ((*(const H5A_t *const *)attr1)->shared->crt_idx > + (*(const H5A_t *const *)attr2)->shared->crt_idx) ret_value = -1; else ret_value = 0; @@ -1719,7 +1707,6 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_dec() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_sort_table * @@ -1733,8 +1720,7 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) *------------------------------------------------------------------------- */ static herr_t -H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, - H5_iter_order_t order) +H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_order_t order) { FUNC_ENTER_STATIC_NOERR @@ -1742,20 +1728,20 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, HDassert(atable); /* Pick appropriate comparison routine */ - if(idx_type == H5_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_name_dec); + if (idx_type == H5_INDEX_NAME) { + if (order == H5_ITER_INC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc); + else if (order == H5_ITER_DEC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec); else HDassert(order == H5_ITER_NATIVE); } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t*), H5A__attr_cmp_corder_dec); + if (order == H5_ITER_INC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc); + else if (order == H5_ITER_DEC) + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec); else HDassert(order == H5_ITER_NATIVE); } /* end else */ @@ -1763,7 +1749,6 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__attr_sort_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_iterate_table * @@ -1778,12 +1763,11 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, *------------------------------------------------------------------------- */ herr_t -H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, - hsize_t *last_attr, hid_t loc_id, const H5A_attr_iter_op_t *attr_op, - void *op_data) +H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *last_attr, hid_t loc_id, + const H5A_attr_iter_op_t *attr_op, void *op_data) { - size_t u; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE @@ -1792,20 +1776,19 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, HDassert(attr_op); /* Skip over attributes, if requested */ - if(last_attr) + if (last_attr) *last_attr = skip; /* Iterate over attribute messages */ H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) - for(; u < atable->nattrs && !ret_value; u++) { + for (; u < atable->nattrs && !ret_value; u++) { /* Check which type of callback to make */ - switch(attr_op->op_type) { - case H5A_ATTR_OP_APP2: - { - H5A_info_t ainfo; /* Info for attribute */ + switch (attr_op->op_type) { + case H5A_ATTR_OP_APP2: { + H5A_info_t ainfo; /* Info for attribute */ /* Get the attribute information */ - if(H5A__get_info(atable->attrs[u], &ainfo) < 0) + if (H5A__get_info(atable->attrs[u], &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5_ITER_ERROR, "unable to get attribute info") /* Make the application callback */ @@ -1829,23 +1812,22 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, HDassert("unknown attribute op type" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute op type") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /* Increment the number of entries passed through */ - if(last_attr) + if (last_attr) (*last_attr)++; } /* end for */ /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_iterate_table() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_release_table * @@ -1861,7 +1843,7 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, herr_t H5A__attr_release_table(H5A_attr_table_t *atable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1869,12 +1851,12 @@ H5A__attr_release_table(H5A_attr_table_t *atable) HDassert(atable); /* Release attribute info, if any. */ - if(atable->nattrs > 0) { - size_t u; /* Local index variable */ + if (atable->nattrs > 0) { + size_t u; /* Local index variable */ /* Free attribute message information */ - for(u = 0; u < atable->nattrs; u++) - if(atable->attrs[u] && H5A__close(atable->attrs[u]) < 0) + for (u = 0; u < atable->nattrs; u++) + if (atable->attrs[u] && H5A__close(atable->attrs[u]) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute") } /* end if */ else @@ -1886,7 +1868,6 @@ H5A__attr_release_table(H5A_attr_table_t *atable) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_release_table() */ - /*------------------------------------------------------------------------- * Function: H5A__get_ainfo * @@ -1903,8 +1884,8 @@ H5A__attr_release_table(H5A_attr_table_t *atable) htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value = FAIL; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(oh->cache_info.addr, FAIL) @@ -1914,41 +1895,40 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) HDassert(ainfo); /* Check if the "attribute info" message exists */ - if((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0) + if ((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header") - if(ret_value > 0) { + if (ret_value > 0) { /* Retrieve the "attribute info" structure */ - if(NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo)) + if (NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo)) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message") /* Check if we don't know how many attributes there are */ - if(ainfo->nattrs == HSIZET_MAX) { + if (ainfo->nattrs == HSIZET_MAX) { /* Check if we are using "dense" attribute storage */ - if(H5F_addr_defined(ainfo->fheap_addr)) { + if (H5F_addr_defined(ainfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &ainfo->nattrs) < 0) + if (H5B2_get_nrec(bt2_name, &ainfo->nattrs) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve # of records in index") } /* end if */ else /* Retrieve # of attributes from object header */ ainfo->nattrs = oh->attr_msgs_seen; } /* end if */ - } /* end if */ + } /* end if */ done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5A__get_ainfo() */ - /*------------------------------------------------------------------------- * Function: H5A__set_version * @@ -1966,9 +1946,10 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) herr_t H5A__set_version(const H5F_t *f, H5A_t *attr) { - hbool_t type_shared, space_shared; /* Flags to indicate that shared messages are used for this attribute */ - uint8_t version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t type_shared, + space_shared; /* Flags to indicate that shared messages are used for this attribute */ + uint8_t version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1977,29 +1958,30 @@ H5A__set_version(const H5F_t *f, H5A_t *attr) HDassert(attr); /* Check whether datatype and dataspace are shared */ - if(H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt) > 0) + if (H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt) > 0) type_shared = TRUE; else type_shared = FALSE; - if(H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds) > 0) + if (H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds) > 0) space_shared = TRUE; else space_shared = FALSE; /* Check which version to encode attribute with */ - if(attr->shared->encoding != H5T_CSET_ASCII) - version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ - else if(type_shared || space_shared) - version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ + if (attr->shared->encoding != H5T_CSET_ASCII) + version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ + else if (type_shared || space_shared) + version = + H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */ else - version = H5O_ATTR_VERSION_1; /* Write out basic version */ + version = H5O_ATTR_VERSION_1; /* Write out basic version */ /* Upgrade to the version indicated by the file's low bound if higher */ version = (uint8_t)MAX(version, (uint8_t)H5O_attr_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_ATTR, H5E_BADRANGE, FAIL, "attribute version out of bounds") /* Set the message version */ @@ -2009,7 +1991,6 @@ H5A__set_version(const H5F_t *f, H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__set_version() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_copy_file * @@ -2032,20 +2013,20 @@ H5A__set_version(const H5F_t *f, H5A_t *attr) */ 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) + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info) { - 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 */ - 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 * 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -2056,13 +2037,13 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s HDassert(!cpy_info->copy_without_attr); /* Allocate space for the destination message */ - if(NULL == (attr_dst = H5FL_CALLOC(H5A_t))) + if (NULL == (attr_dst = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the top level of the attribute */ *attr_dst = *attr_src; - if(NULL == (attr_dst->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr_dst->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure") /* Don't have an opened group location for copy */ @@ -2081,19 +2062,19 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Copy attribute's datatype */ /* If source is named, we will keep dst as named, but we will not actually * copy the target and update the message until post copy */ - if(NULL == (attr_dst->shared->dt = H5T_copy(attr_src->shared->dt, H5T_COPY_ALL))) + if (NULL == (attr_dst->shared->dt = H5T_copy(attr_src->shared->dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "cannot copy datatype") /* Set the location of the destination datatype */ - if(H5T_set_loc(attr_dst->shared->dt, file_dst, H5T_LOC_DISK) < 0) + if (H5T_set_loc(attr_dst->shared->dt, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "cannot mark datatype on disk") - if(!H5T_committed(attr_src->shared->dt)) { + if (!H5T_is_named(attr_src->shared->dt)) { /* If the datatype is not named, it may have been shared in the * source file's heap. Un-share it for now. We'll try to shared * it in the destination file below. */ - if(H5O_msg_reset_share(H5O_DTYPE_ID, attr_dst->shared->dt) < 0) + if (H5O_msg_reset_share(H5O_DTYPE_ID, attr_dst->shared->dt) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset datatype sharing") } @@ -2105,16 +2086,16 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Reset the dataspace's sharing in the source file before trying to share * it in the destination. */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->shared->ds) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->shared->ds) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset dataspace sharing") /* Simulate trying to share both the datatype and dataset, to determine the * final size of the messages. This does nothing if the datatype is * committed or sharing is disabled. */ - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute datatype") - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute dataspace") /* Compute the sizes of the datatype and dataspace. This is their raw @@ -2127,70 +2108,74 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Check whether to recompute the size of the attribute */ /* (happens when the datatype or dataspace changes sharing status) */ - if(attr_dst->shared->dt_size != attr_src->shared->dt_size || attr_dst->shared->ds_size != attr_src->shared->ds_size) + if (attr_dst->shared->dt_size != attr_src->shared->dt_size || + attr_dst->shared->ds_size != attr_src->shared->ds_size) *recompute_size = TRUE; /* Get # of elements for destination attribute's dataspace */ - if((sdst_nelmts = H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds)) < 0) + if ((sdst_nelmts = H5S_GET_EXTENT_NPOINTS(attr_dst->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, NULL, "dataspace is invalid") H5_CHECKED_ASSIGN(dst_nelmts, size_t, sdst_nelmts, hssize_t); /* Get size of destination attribute's datatype */ - if(0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt))) + if (0 == (dst_dt_size = H5T_get_size(attr_dst->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") /* Compute the size of the data */ - attr_dst->shared->data_size = dst_nelmts * dst_dt_size; + attr_dst->shared->data_size = dst_nelmts * dst_dt_size; /* Copy (& convert) the data, if necessary */ - if(attr_src->shared->data) { - if(NULL == (attr_dst->shared->data = H5FL_BLK_MALLOC(attr_buf, attr_dst->shared->data_size))) + if (attr_src->shared->data) { + if (NULL == (attr_dst->shared->data = H5FL_BLK_MALLOC(attr_buf, attr_dst->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* 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 */ - 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 */ - hsize_t buf_dim; /* Dimension for buffer */ - size_t nelmts; /* Number of elements in buffer */ - size_t buf_size; /* Size of copy buffer */ + 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 */ + 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 */ + hsize_t buf_dim; /* Dimension for buffer */ + size_t nelmts; /* Number of elements in buffer */ + size_t buf_size; /* Size of copy buffer */ /* Create datatype ID for src datatype */ - if((tid_src = H5I_register(H5I_DATATYPE, attr_src->shared->dt, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, attr_src->shared->dt, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source file datatype") /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(attr_src->shared->dt, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(attr_src->shared->dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) + 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 */ - 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") + 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") /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(attr_src->shared->dt, dt_mem))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, attr_dst->shared->dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between mem and dst datatypes") + if (NULL == (tpath_src_mem = H5T_path_find(attr_src->shared->dt, dt_mem))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between src and mem datatypes") + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, attr_dst->shared->dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(attr_src->shared->dt))) + if (0 == (src_dt_size = H5T_get_size(attr_src->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") - if(0 == (tmp_dt_size = H5T_get_size(dt_mem))) + if (0 == (tmp_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, tmp_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(attr_dst->shared->dt))) + if (0 == (tmp_dt_size = H5T_get_size(attr_dst->shared->dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Set number of whole elements that fit in buffer */ - if(0 == (nelmts = attr_src->shared->data_size / src_dt_size)) + if (0 == (nelmts = attr_src->shared->data_size / src_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "element size too large") /* Set up number of bytes to copy, and initial buffer size */ @@ -2200,99 +2185,98 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s buf_dim = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "can't create simple dataspace") /* Atomize */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to register dataspace ID") } /* end if */ /* Allocate memory for recclaim buf */ - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk") /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk") H5MM_memcpy(buf, attr_src->shared->data, attr_src->shared->data_size); /* Allocate background memory */ - if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + if (H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed") H5MM_memcpy(reclaim_buf, buf, buf_size); /* Set background buffer to all zeros */ - if(bkg_buf) + if (bkg_buf) HDmemset(bkg_buf, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed") H5MM_memcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size); - if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "unable to reclaim variable-length data") - } /* end if */ + } /* end if */ else { HDassert(attr_dst->shared->data_size == attr_src->shared->data_size); H5MM_memcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size); } /* end else */ - } /* end if(attr_src->shared->data) */ + } /* end if(attr_src->shared->data) */ /* Copy the creation order */ attr_dst->shared->crt_idx = attr_src->shared->crt_idx; /* Recompute the version to encode the destination attribute */ - if(H5A__set_version(file_dst, attr_dst) < 0) + if (H5A__set_version(file_dst, attr_dst) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version") /* Recompute the destination attribute's size, if it's a different version */ - if(attr_src->shared->version != attr_dst->shared->version) + if (attr_src->shared->version != attr_dst->shared->version) *recompute_size = TRUE; /* Set return value */ ret_value = attr_dst; done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID") - if(tid_src > 0) + if (tid_src > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(NULL == H5I_remove(tid_src)) + if (NULL == H5I_remove(tid_src)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(tid_dst > 0) + if (tid_dst > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(NULL == H5I_remove(tid_dst)) + if (NULL == H5I_remove(tid_dst)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(tid_mem > 0) + if (tid_mem > 0) /* Decrement the memory datatype ID, it's transient */ - if(H5I_dec_ref(tid_mem) < 0) + if (H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(attr_buf, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(attr_buf, reclaim_buf); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); /* Release destination attribute information on failure */ - if(!ret_value && attr_dst && H5A__close(attr_dst) < 0) + if (!ret_value && attr_dst && H5A__close(attr_dst) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5A__attr_post_copy_file * @@ -2310,11 +2294,11 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s *------------------------------------------------------------------------- */ herr_t -H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, - H5O_loc_t *dst_oloc, const H5A_t *attr_dst, H5O_copy_t *cpy_info) +H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, H5O_loc_t *dst_oloc, + const H5A_t *attr_dst, H5O_copy_t *cpy_info) { - H5F_t *file_src, *file_dst; - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file_src, *file_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2330,9 +2314,9 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, HDassert(file_src); HDassert(file_dst); - if(H5T_committed(attr_src->shared->dt)) { - H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ - H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ + if (H5T_is_named(attr_src->shared->dt)) { + H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ + H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ /* Get group entries for source & destination */ src_oloc_dt = H5T_oloc(attr_src->shared->dt); @@ -2345,7 +2329,7 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, dst_oloc_dt->file = file_dst; /* Copy the shared object from source to destination */ - if(H5O_copy_header_map(src_oloc_dt, dst_oloc_dt, cpy_info, FALSE, NULL, NULL) < 0) + if (H5O_copy_header_map(src_oloc_dt, dst_oloc_dt, cpy_info, FALSE, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Update shared message info from named datatype info */ @@ -2355,29 +2339,26 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, /* Try to share both the datatype and dataset. This does nothing if the * datatype is committed or sharing is disabled. */ - if(H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute datatype") - if(H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_WAS_DEFERRED, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute dataspace") /* Only need to fix reference attribute with real data being copied to * another file. */ - if((NULL != attr_dst->shared->data) && (H5T_get_class(attr_dst->shared->dt, FALSE) == H5T_REFERENCE) ) { + if ((NULL != attr_dst->shared->data) && (H5T_get_class(attr_dst->shared->dt, FALSE) == H5T_REFERENCE)) { /* copy object pointed by reference. The current implementation does not * deal with nested reference such as reference in a compound structure */ /* Check for expanding references */ - if(cpy_info->expand_ref) { - size_t ref_count; - - /* Determine # of reference elements to copy */ - ref_count = attr_dst->shared->data_size / H5T_get_size(attr_dst->shared->dt); - + if (cpy_info->expand_ref) { /* Copy objects referenced in source buffer to destination file and set destination elements */ - if(H5O_copy_expand_ref(file_src, attr_dst->shared->data, file_dst, attr_dst->shared->data, ref_count, H5T_get_ref_type(attr_dst->shared->dt), cpy_info) < 0) + if (H5O_copy_expand_ref(file_src, H5I_INVALID_HID, attr_src->shared->dt, attr_src->shared->data, + attr_src->shared->data_size, file_dst, attr_dst->shared->data, + cpy_info) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") } /* end if */ else @@ -2389,7 +2370,6 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_cb * @@ -2406,9 +2386,9 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, 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; - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5A_dense_file_cp_ud_t *udata = (H5A_dense_file_cp_ud_t *)_udata; + H5A_t * attr_dst = NULL; + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2419,34 +2399,34 @@ H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) HDassert(udata->file); HDassert(udata->cpy_info); - if(NULL == (attr_dst = H5A__attr_copy_file(attr_src, udata->file, udata->recompute_size, udata->cpy_info))) + if (NULL == + (attr_dst = H5A__attr_copy_file(attr_src, udata->file, udata->recompute_size, udata->cpy_info))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") - if(H5A__attr_post_copy_file(udata->oloc_src, attr_src, udata->oloc_dst, attr_dst, udata->cpy_info) < 0) + if (H5A__attr_post_copy_file(udata->oloc_src, attr_src, udata->oloc_dst, attr_dst, udata->cpy_info) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Reset shared location information */ - if(H5O_msg_reset_share(H5O_ATTR_ID, attr_dst) < 0) + if (H5O_msg_reset_share(H5O_ATTR_ID, attr_dst) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset attribute sharing") /* Set COPIED tag for destination object's metadata */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Insert attribute into dense storage */ - if(H5A__dense_insert(udata->file, udata->ainfo, attr_dst) < 0) + if (H5A__dense_insert(udata->file, udata->ainfo, attr_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Reset metadata tag */ H5_END_TAG done: - if(attr_dst && H5A__close(attr_dst) < 0) + if (attr_dst && H5A__close(attr_dst) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close destination attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_all * @@ -2460,13 +2440,13 @@ H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, - H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info) +H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, H5O_loc_t *dst_oloc, + H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info) { - H5A_dense_file_cp_ud_t udata; /* User data for iteration callback */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hbool_t recompute_size = FALSE; /* recompute the size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_dense_file_cp_ud_t udata; /* User data for iteration callback */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hbool_t recompute_size = FALSE; /* recompute the size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2474,25 +2454,24 @@ H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainf HDassert(ainfo_src); HDassert(ainfo_dst); - udata.ainfo = ainfo_dst; /* Destination dense information */ - udata.file = dst_oloc->file; /* Destination file */ - udata.recompute_size = &recompute_size; /* Flag to indicate if size changed */ - udata.cpy_info = cpy_info; /* Information on copying options */ - udata.oloc_src = src_oloc; - udata.oloc_dst = dst_oloc; + udata.ainfo = ainfo_dst; /* Destination dense information */ + udata.file = dst_oloc->file; /* Destination file */ + udata.recompute_size = &recompute_size; /* Flag to indicate if size changed */ + udata.cpy_info = cpy_info; /* Information on copying options */ + udata.oloc_src = src_oloc; + udata.oloc_dst = dst_oloc; - attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.op_type = H5A_ATTR_OP_LIB; attr_op.u.lib_op = H5A__dense_post_copy_file_cb; - if(H5A__dense_iterate(src_oloc->file, (hid_t)0, ainfo_src, H5_INDEX_NAME, - H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, &udata) < 0) + if (H5A__dense_iterate(src_oloc->file, (hid_t)0, ainfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, + NULL, &attr_op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_all */ - /*------------------------------------------------------------------------- * Function: H5A__rename_by_name * @@ -2506,40 +2485,41 @@ H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainf *------------------------------------------------------------------------- */ herr_t -H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, - const char *new_attr_name) +H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, const char *new_attr_name) { - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Call attribute rename routine */ - if(H5O__attr_rename(obj_loc.oloc, old_attr_name, new_attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + /* Avoid thrashing things if the names are the same */ + if (HDstrcmp(old_attr_name, new_attr_name) != 0) { + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if (H5G_loc_find(&loc, obj_name, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Call attribute rename routine */ + if (H5O__attr_rename(obj_loc.oloc, old_attr_name, new_attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__rename_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__iterate_common * @@ -2553,28 +2533,27 @@ H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_na *------------------------------------------------------------------------- */ static herr_t -H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_attr_iter_op_t *attr_op, void *op_data) +H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5A_attr_iter_op_t *attr_op, void *op_data) { - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Call attribute iteration routine */ last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O__attr_iterate(loc_id, idx_type, order, start_idx, &last_attr, attr_op, op_data)) < 0) + if ((ret_value = H5O__attr_iterate(loc_id, idx_type, order, start_idx, &last_attr, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Set the last attribute information */ - if(idx) + if (idx) *idx = last_attr; FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_common() */ - /*------------------------------------------------------------------------- * Function: H5A__iterate * @@ -2585,28 +2564,61 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, *------------------------------------------------------------------------- */ herr_t -H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data) +H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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; + H5I_type_t obj_type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; + attr_op.op_type = H5A_ATTR_OP_APP2; attr_op.u.app_op2 = op; + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if (H5G_loc_find(loc, obj_name, &obj_loc) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found"); + loc_found = TRUE; + + /* Open the object */ + if (NULL == (temp_obj = H5O_open_by_loc(&obj_loc, &obj_type))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + /* Get an ID for the object */ + if ((obj_loc_id = H5VL_wrap_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); + /* Call internal attribute iteration routine */ - if((ret_value = H5A__iterate_common(loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) + if ((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") done: + /* Release resources */ + if (obj_loc_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(obj_loc_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); + } /* end if */ + else if (loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__iterate() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5A__iterate_old * @@ -2620,98 +2632,34 @@ H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, *------------------------------------------------------------------------- */ herr_t -H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, - void *op_data) +H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t idx; /* Index of attribute to start iterating at */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t idx; /* Index of attribute to start iterating at */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP; + attr_op.op_type = H5A_ATTR_OP_APP; attr_op.u.app_op = op; /* Set up index */ idx = (hsize_t)(attr_num ? *attr_num : 0); /* Call internal attribute iteration routine */ - if((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + if ((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < + 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Translate hsize_t index value to legacy unsigned index value*/ - if(attr_num) + if (attr_num) *attr_num = (unsigned)idx; -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_old() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - -/*------------------------------------------------------------------------- - * Function: H5A__iterate_by_name - * - * Purpose: Private version of H5Aiterate_by_name - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * December 6, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, - void *op_data) -{ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Open the object */ - if((obj_loc_id = H5O__open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; - - /* Call attribute iteration routine */ - if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - -done: - /* Release resources */ - if(obj_loc_id > 0) { - if(H5I_dec_app_ref(obj_loc_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - } /* end if */ - else if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5A__iterate_by_name() */ - - /*------------------------------------------------------------------------- * Function: H5A__delete_by_name * @@ -2727,11 +2675,11 @@ H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name) { - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2741,23 +2689,22 @@ H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O__attr_remove(obj_loc.oloc, attr_name) < 0) + if (H5O__attr_remove(obj_loc.oloc, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_name() */ - /*------------------------------------------------------------------------- * Function: H5A__delete_by_idx * @@ -2771,14 +2718,14 @@ H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr *------------------------------------------------------------------------- */ herr_t -H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2788,19 +2735,18 @@ H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O__attr_remove_by_idx(obj_loc.oloc, idx_type, order, n) < 0) + if (H5O__attr_remove_by_idx(obj_loc.oloc, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) + if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_idx() */ - diff --git a/src/H5Amodule.h b/src/H5Amodule.h index 6b835e1fd38..c89c93f0d6f 100644 --- a/src/H5Amodule.h +++ b/src/H5Amodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,52 @@ * H5A package. Including this header means that the source file * is part of the H5A package. */ -#ifndef _H5Amodule_H -#define _H5Amodule_H +#ifndef H5Amodule_H +#define H5Amodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5A_MODULE -#define H5_MY_PKG H5A -#define H5_MY_PKG_ERR H5E_ATTR -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5A +#define H5_MY_PKG_ERR H5E_ATTR +#define H5_MY_PKG_INIT YES -#endif /* _H5Amodule_H */ +/**\defgroup H5A H5A + * + * Use the functions in this module to manage HDF5 attributes. + * + * The Attribute Interface, H5A, provides a mechanism for attaching additional + * information to a dataset, group, or named 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. + * + * 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. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet H5A_examples.c create + * + * \snippet H5A_examples.c read + *
UpdateDelete
+ * \snippet H5A_examples.c update + * + * \snippet H5A_examples.c delete + *
+ * + */ +#endif /* H5Amodule_H */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 0bb6d8fac85..48adeef24d2 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,79 +23,77 @@ #error "Do not include this file outside the H5A package!" #endif -#ifndef _H5Apkg_H -#define _H5Apkg_H +#ifndef H5Apkg_H +#define H5Apkg_H /* * Define this to enable debugging. */ #ifdef NDEBUG -# undef H5A_DEBUG +#undef H5A_DEBUG #endif /* Get package's private header */ #include "H5Aprivate.h" /* Other private headers needed by this file */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace */ -#include "H5Tprivate.h" /* Datatype functions */ - +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace */ +#include "H5Tprivate.h" /* Datatype functions */ /**************************/ /* Package Private Macros */ /**************************/ /* This is the initial version, which does not have support for shared datatypes */ -#define H5O_ATTR_VERSION_1 1 +#define H5O_ATTR_VERSION_1 1 /* This version allows support for shared datatypes & dataspaces by adding a * 'flag' byte indicating when those components are shared. This version * also dropped the alignment on all the components. */ -#define H5O_ATTR_VERSION_2 2 +#define H5O_ATTR_VERSION_2 2 /* Add support for different character encodings of attribute names */ -#define H5O_ATTR_VERSION_3 3 +#define H5O_ATTR_VERSION_3 3 /* The latest version of the format. Look through the 'encode', 'decode' * and 'size' message callbacks for places to change when updating this. */ #define H5O_ATTR_VERSION_LATEST H5O_ATTR_VERSION_3 - /****************************/ /* Package Private Typedefs */ /****************************/ /* Define the shared attribute structure */ typedef struct H5A_shared_t { - uint8_t version; /* Version to encode attribute with */ + uint8_t version; /* Version to encode attribute with */ - char *name; /* Attribute's name */ - H5T_cset_t encoding; /* Character encoding of attribute name */ + char * name; /* Attribute's name */ + H5T_cset_t encoding; /* Character encoding of attribute name */ - H5T_t *dt; /* Attribute's datatype */ - size_t dt_size; /* Size of datatype on disk */ + H5T_t *dt; /* Attribute's datatype */ + size_t dt_size; /* Size of datatype on disk */ - H5S_t *ds; /* Attribute's dataspace */ - size_t ds_size; /* Size of dataspace on disk */ + H5S_t *ds; /* Attribute's dataspace */ + size_t ds_size; /* Size of dataspace on disk */ - 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 */ + 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 */ } H5A_shared_t; /* Define the main attribute structure */ struct H5A_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5O_loc_t oloc; /* Object location for object attribute is on */ - hbool_t obj_opened; /* Object header entry opened? */ - H5G_name_t path; /* Group hierarchy path */ - H5A_shared_t *shared; /* Shared attribute information */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_loc_t oloc; /* Object location for object attribute is on */ + hbool_t obj_opened; /* Object header entry opened? */ + H5G_name_t path; /* Group hierarchy path */ + H5A_shared_t *shared; /* Shared attribute information */ }; /* Typedefs for "dense" attribute storage */ @@ -104,18 +102,18 @@ struct H5A_t { /* Typedef for native 'name' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5A_dense_bt2_name_rec_t { - H5O_fheap_id_t id; /* Heap ID for attribute */ - uint8_t flags; /* Object header message flags for attribute */ - H5O_msg_crt_idx_t corder; /* 'creation order' field value */ - uint32_t hash; /* Hash of 'name' field value */ + H5O_fheap_id_t id; /* Heap ID for attribute */ + uint8_t flags; /* Object header message flags for attribute */ + H5O_msg_crt_idx_t corder; /* 'creation order' field value */ + uint32_t hash; /* Hash of 'name' field value */ } H5A_dense_bt2_name_rec_t; /* Typedef for native 'creation order' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5A_dense_bt2_corder_rec_t { - H5O_fheap_id_t id; /* Heap ID for attribute */ - uint8_t flags; /* Object header message flags for attribute */ - H5O_msg_crt_idx_t corder; /* 'creation order' field value */ + H5O_fheap_id_t id; /* Heap ID for attribute */ + uint8_t flags; /* Object header message flags for attribute */ + H5O_msg_crt_idx_t corder; /* 'creation order' field value */ } H5A_dense_bt2_corder_rec_t; /* Define the 'found' callback function pointer for matching an attribute record in a v2 B-tree */ @@ -128,15 +126,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 */ - 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 */ + 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 */ } H5A_bt2_ud_common_t; /* @@ -145,17 +143,16 @@ typedef struct H5A_bt2_ud_common_t { */ typedef struct H5A_bt2_ud_ins_t { /* downward */ - H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - H5O_fheap_id_t id; /* Heap ID of attribute to insert */ + H5A_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + H5O_fheap_id_t id; /* Heap ID of attribute to insert */ } H5A_bt2_ud_ins_t; /* Data structure to hold table of attributes for an object */ typedef struct { - size_t nattrs; /* # of attributes in table */ - H5A_t **attrs; /* Pointer to array of attribute pointers */ + size_t nattrs; /* # of attributes in table */ + H5A_t **attrs; /* Pointer to array of attribute pointers */ } H5A_attr_table_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -175,49 +172,42 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_NAME[1]; /* The v2 B-tree class for indexing 'creation order' field on attributes */ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Function prototypes for H5A package scope */ -H5_DLL 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); -H5_DLL H5A_t *H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name, const H5T_t *type, const H5S_t *space, - hid_t acpl_id); +H5_DLL 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); +H5_DLL H5A_t *H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name, + const H5T_t *type, const H5S_t *space, hid_t acpl_id); H5_DLL H5A_t *H5A__open(const H5G_loc_t *loc, const char *attr_name); -H5_DLL H5A_t *H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name); -H5_DLL H5A_t *H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL H5A_t *H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); +H5_DLL H5A_t *H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5A__open_common(const H5G_loc_t *loc, H5A_t *attr); H5_DLL H5A_t *H5A__copy(H5A_t *new_attr, const H5A_t *old_attr); -H5_DLL hid_t H5A__get_type(H5A_t *attr); +H5_DLL hid_t H5A__get_type(H5A_t *attr); H5_DLL herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo); -H5_DLL hid_t H5A__get_create_plist(H5A_t* attr); -H5_DLL herr_t H5A__free(H5A_t *attr); +H5_DLL hid_t H5A__get_create_plist(H5A_t *attr); +H5_DLL herr_t H5A__shared_free(H5A_t *attr); H5_DLL herr_t H5A__close(H5A_t *attr); -H5_DLL herr_t H5A__close_cb(H5A_t *attr); +H5_DLL herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj); H5_DLL htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo); H5_DLL herr_t H5A__set_version(const H5F_t *f, H5A_t *attr); H5_DLL herr_t H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, - const char *new_attr_name); -H5_DLL herr_t H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data); -H5_DLL herr_t H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, - void *op_data); + const char *new_attr_name); +H5_DLL herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data); #ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, - H5A_operator1_t op, void *op_data); +H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, - const char *attr_name); -H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name); -H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); -H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); +H5_DLL herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name); +H5_DLL herr_t H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL htri_t H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name); +H5_DLL herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf); +H5_DLL herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf); H5_DLL ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf); /* Attribute "dense" storage routines */ @@ -225,55 +215,47 @@ H5_DLL herr_t H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo); H5_DLL H5A_t *H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); H5_DLL herr_t H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr); H5_DLL herr_t H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr); -H5_DLL herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *old_name, const char *new_name); -H5_DLL herr_t H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, - 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 herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *name); -H5_DLL 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); -H5_DLL htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, - const char *name); +H5_DLL herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, + const char *new_name); +H5_DLL herr_t H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, 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 herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); +H5_DLL 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); +H5_DLL htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name); H5_DLL herr_t H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo); /* Attribute table operations */ -H5_DLL herr_t H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, - H5_iter_order_t order, H5A_attr_table_t *atable); -H5_DLL herr_t H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, - H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable); -H5_DLL herr_t H5A__attr_iterate_table(const H5A_attr_table_t *atable, - hsize_t skip, hsize_t *last_attr, hid_t loc_id, - const H5A_attr_iter_op_t *attr_op, void *op_data); +H5_DLL herr_t H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, + H5A_attr_table_t *atable); +H5_DLL herr_t H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, + H5_iter_order_t order, H5A_attr_table_t *atable); +H5_DLL herr_t H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *last_attr, + hid_t loc_id, const H5A_attr_iter_op_t *attr_op, void *op_data); H5_DLL herr_t H5A__attr_release_table(H5A_attr_table_t *atable); /* Attribute operations */ H5_DLL herr_t H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr); H5_DLL H5A_t *H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name); -H5_DLL 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); -H5_DLL herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, - H5O_shared_t *sh_mesg); +H5_DLL 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); +H5_DLL herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *sh_mesg); H5_DLL herr_t H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr); -H5_DLL herr_t H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, - const char *new_name); -H5_DLL herr_t H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *op, void *op_data); +H5_DLL herr_t H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, const char *new_name); +H5_DLL herr_t H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_attr, const H5A_attr_iter_op_t *op, void *op_data); H5_DLL herr_t H5O__attr_remove(const H5O_loc_t *loc, const char *name); -H5_DLL 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); +H5_DLL 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); H5_DLL htri_t H5O__attr_exists(const H5O_loc_t *loc, const char *name); -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL int H5O__attr_count(const H5O_loc_t *loc); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ H5_DLL H5A_t *H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info); -H5_DLL herr_t H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *mesg_src, - H5O_loc_t *dst_oloc, const H5A_t *mesg_dst, H5O_copy_t *cpy_info); -H5_DLL herr_t H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t * ainfo_src, - H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, H5O_copy_t *cpy_info); + H5O_copy_t *cpy_info); +H5_DLL herr_t H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *mesg_src, H5O_loc_t *dst_oloc, + const H5A_t *mesg_dst, H5O_copy_t *cpy_info); +H5_DLL herr_t H5A__dense_post_copy_file_all(const H5O_loc_t *src_oloc, const H5O_ainfo_t *ainfo_src, + H5O_loc_t *dst_oloc, H5O_ainfo_t *ainfo_dst, + H5O_copy_t *cpy_info); /* Testing functions */ #ifdef H5A_TESTING @@ -281,5 +263,4 @@ H5_DLL htri_t H5A__is_shared_test(hid_t aid); H5_DLL herr_t H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count); #endif /* H5A_TESTING */ -#endif /* _H5Apkg_H */ - +#endif /* H5Apkg_H */ diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index 342ffc89d21..3ed0239d5bc 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,24 +14,22 @@ /* * This file contains private information about the H5D module */ -#ifndef _H5Aprivate_H -#define _H5Aprivate_H +#ifndef H5Aprivate_H +#define H5Aprivate_H /* Include package's public header */ #include "H5Apublic.h" /* Private headers needed by this file */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspace */ -#include "H5Tprivate.h" /* Datatypes */ - +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspace */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -45,41 +43,39 @@ typedef herr_t (*H5A_lib_iterate_t)(const H5A_t *attr, void *op_data); /* Describe kind of callback to make for each attribute */ typedef enum H5A_attr_iter_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5A_ATTR_OP_APP, /* Application callback */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5A_ATTR_OP_APP2, /* Revised application callback */ - H5A_ATTR_OP_LIB /* Library internal callback */ + H5A_ATTR_OP_APP, /* Application callback */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5A_ATTR_OP_APP2, /* Revised application callback */ + H5A_ATTR_OP_LIB /* Library internal callback */ } H5A_attr_iter_op_type_t; typedef struct H5A_attr_iter_op_t { H5A_attr_iter_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5A_operator1_t app_op; /* Application callback for each attribute */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5A_operator2_t app_op2; /* Revised application callback for each attribute */ - H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ + H5A_operator1_t app_op; /* Application callback for each attribute */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5A_operator2_t app_op2; /* Revised application callback for each attribute */ + H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ } u; } H5A_attr_iter_op_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* 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); - -#endif /* _H5Aprivate_H */ +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 7162f6e44e5..01986683b77 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,32 +14,53 @@ /* * This file contains public declarations for the H5A module. */ -#ifndef _H5Apublic_H -#define _H5Apublic_H +#ifndef H5Apublic_H +#define H5Apublic_H /* Public headers needed by this file */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Opublic.h" /* Object Headers */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Opublic.h" /* Object Headers */ +#include "H5Tpublic.h" /* Datatypes */ -/* Information struct for attribute (for H5Aget_info/H5Aget_info_by_idx) */ +//! +/** + * Information struct for H5Aget_info() / H5Aget_info_by_idx() + */ typedef struct { - hbool_t corder_valid; /* Indicate if creation order is valid */ - H5O_msg_crt_idx_t corder; /* Creation order */ - H5T_cset_t cset; /* Character set of attribute name */ - hsize_t data_size; /* Size of raw data */ + hbool_t corder_valid; /**< Indicate if creation order is valid */ + H5O_msg_crt_idx_t corder; /**< Creation order */ + H5T_cset_t cset; /**< Character set of attribute name */ + hsize_t data_size; /**< Size of raw data */ } H5A_info_t; +//! -/* Typedef for H5Aiterate2() callbacks */ -typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, - const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/); - +//! +/** + * Typedef for H5Aiterate2() / H5Aiterate_by_name() callbacks + * \param[in] location_id The identifier for the group, dataset + * or named datatype being iterated over + * \param[in] attr_name The name of the current object attribute + * \param[in] ainfo The attribute’s info struct + * \param[in,out] op_data A pointer to the operator data passed in to + * H5Aiterate2() or H5Aiterate_by_name() + * \returns The return values from an operator are: + * \li Zero causes the iterator to continue, returning zero when + * all attributes have been processed. + * \li Positive causes the iterator to immediately return that + * positive value, indicating short-circuit success. The + * iterator can be restarted at the next attribute. + * \li Negative causes the iterator to immediately return that value, + * indicating failure. The iterator can be restarted at the next + * attribute. + */ +typedef herr_t (*H5A_operator2_t)(hid_t location_id /*in*/, const char *attr_name /*in*/, + const H5A_info_t *ainfo /*in*/, void *op_data /*in,out*/); +//! /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -47,49 +68,946 @@ typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, extern "C" { #endif -H5_DLL 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); -H5_DLL 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); -H5_DLL hid_t H5Aopen(hid_t obj_id, const char *attr_name, hid_t aapl_id); -H5_DLL 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); -H5_DLL 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); -H5_DLL herr_t H5Awrite(hid_t attr_id, hid_t type_id, const void *buf); -H5_DLL herr_t H5Aread(hid_t attr_id, hid_t type_id, void *buf); -H5_DLL herr_t H5Aclose(hid_t attr_id); -H5_DLL hid_t H5Aget_space(hid_t attr_id); -H5_DLL hid_t H5Aget_type(hid_t attr_id); -H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Closes the specified attribute + * + * \attr_id + * + * \return \herr_t + * + * \details H5Aclose() terminates access to the attribute specified by + * \p attr_id by releasing the identifier. + * + * \attention Further use of a released attribute identifier is illegal; a + * function using such an identifier will generate an error. + * + * \since 1.0.0 + * + * \see H5Acreate(), H5Aopen() + */ +H5_DLL herr_t H5Aclose(hid_t attr_id); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Creates an attribute attached to a specified object + * + * \fgdt_loc_id + * \param[in] attr_name Name of attribute + * \param[in] type_id Attribute datatype identifier + * \space_id + * \acpl_id + * \aapl_id + * + * \return \hid_tv{attribute} + * + * \details H5Acreate2() creates an attribute, \p attr_name, which is attached + * to the object specified by the identifier \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. + * + * 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. + * + * 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. + * + * \since 1.8.0 + * + * \see H5Aclose() + * + */ +H5_DLL 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); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Creates an attribute attached to a specified object + * + * \fgdt_loc_id + * \param[in] obj_name Name, relative to \p loc_id, of object that + * attribute is to be attached to + * \param[in] attr_name Attribute name + * \param[in] type_id Attribute datatype identifier + * \space_id + * \acpl_id + * \aapl_id + * \lapl_id + * + * \return \hid_tv{attribute} + * + * \details H5Acreate_by_name() creates an attribute, \p attr_name, which is + * 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). + * + * 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. + * + * 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. + * + * 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 + * + */ +H5_DLL 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); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Deletes an attribute from a specified location + * + * \fgdt_loc_id + * \param[in] attr_name Name of the attribute to delete + * + * \return \herr_t + * + * \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. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Adelete(hid_t loc_id, const char *attr_name); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Deletes an attribute from an object according to index order + * + * \fgdt_loc_id + * \param[in] obj_name Name of object, relative to location, from which + * attribute is to be removed + * \param[in] idx_type Type of index + * \param[in] order Order in which to iterate over index + * \param[in] n Offset within index + * \lapl_id + * + * \return \herr_t + * + * \details H5Adelete_by_idx() removes an attribute, specified by its + * location in an index, from an object. + * + * 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). + * + * 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, + * and \p n are set to #H5_INDEX_NAME, #H5_ITER_INC, and 5, + * respectively, the fifth attribute by alpha-numeric 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. + + * \since 1.8.0 + * + */ +H5_DLL 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); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Removes an attribute from a specified location + * + * \fgdt_loc_id + * \param[in] obj_name Name of object, relative to location, from which + * attribute is to be removed + * \param[in] attr_name Name of attribute to delete + * \lapl_id + * + * \return \herr_t + * + * \details H5Adelete_by_name() removes the attribute \p attr_name + * 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. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Determines whether an attribute with a given name exists on an + * object + * + * \fgdt_loc_id{obj_id} + * \param[in] attr_name Attribute name + * + * \return \htri_t + * + * \details H5Aexists() determines whether the attribute \p attr_name + * exists on the object specified by \p obj_id. + * + * \since 1.8.0 + * + */ +H5_DLL htri_t H5Aexists(hid_t obj_id, const char *attr_name); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Determines whether an attribute with a given name exists on an + * object + * + * \fgdt_loc_id{obj_id} + * \param[in] obj_name Object name + * \param[in] attr_name Attribute name + * \lapl_id + * + * \return \htri_t + * + * \details H5Aexists_by_name() determines whether the attribute + * \p attr_name exists on an object. That object is specified by + * its location and name, \p loc_id and \p obj_name, respectively. + * + * \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). + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to access + * \p obj_name. + * + * \since 1.8.0 + * + */ +H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, const char *attr_name, hid_t lapl_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Gets an attribute creation property list identifier + * + * \attr_id + * + * \return \hid_tv{attribute's creation property list} + * + * \details H5Aget_create_plist() returns an identifier for the attribute + * 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 + * + */ +H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Retrieves attribute information, by attribute identifier + * + * \attr_id + * \param[out] ainfo Attribute information struct + * + * \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 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 + * + */ +H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Retrieves attribute information by attribute index position + * + * \fgdt_loc_id + * \param[in] obj_name Name of object to which attribute is attached, + * relative to location + * \param[in] idx_type Type of index + * \param[in] order Index traversal order + * \param[in] n Attribute’s position in index + * \param[out] ainfo Struct containing returned attribute information + * \lapl_id + * + * \return \herr_t + * + * \details H5Aget_info_by_idx() retrieves information for an attribute + * that is attached to an object, which is specified by its + * location and name, \p loc_id and \p obj_name, respectively. + * 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(). + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to access + * the object, \p obj_name. + * + * \since 1.8.0 + * + */ +H5_DLL 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 /*out*/, hid_t lapl_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Retrieves attribute information, by attribute name + * + * \fgdt_loc_id + * + * \param[in] obj_name Name of object to which attribute is attached, + * relative to location + * \param[in] attr_name Attribute name + * \param[out] ainfo Struct containing returned attribute information + * \lapl_id + * + * \return \herr_t + * + * \details H5Aget_info_by_name() retrieves information for an attribute, + * \p attr_name, that is attached to an object specified by its + * 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. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t 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); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Gets an attribute name + * + * \attr_id + * \param[in] buf_size The size of the buffer to store the name in + * \param[out] buf Buffer to store name in + * + * \return Returns the length of the attribute's name, which may be longer + * than \p buf_size, if successful. Otherwise returns a negative + * value. + * + * \details H5Aget_name() retrieves the name of an attribute specified by + * the identifier, \p attr_id. Up to \p buf_size characters are + * stored in \p buf followed by a \0 string terminator. If the + * name of the attribute is longer than (\p buf_size -1), the + * 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 + * \p bufsize and \p buf. + * + * \since 1.0.0 + * + */ H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); -H5_DLL 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); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Gets an attribute name, by attribute index position + * + * \fgdt_loc_id + * \param[in] obj_name Name of object to which attribute is attached, + * relative to location + * \param[in] idx_type Type of index + * \param[in] order Index traversal order + * \param[in] n Attribute’s position in index + * \param[out] name Attribute name + * \param[in] size Size, in bytes, of attribute name + * \lapl_id + * + * \return Returns attribute name size, in bytes, if successful; + * otherwise returns a negative value. + * + * \details H5Aget_name_by_idx() retrieves the name of an attribute that is + * attached to an object, which is specified by its location and + * name, \p loc_id and \p obj_name, respectively. The attribute is + * 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(). + * + * 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 + * function’s return value will provide the correct value for + * \p size. + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to access + * the object, \p obj_name. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Gets a copy of the dataspace for an attribute + * + * \attr_id + * + * \return \hid_tv{attribute dataspace} + * + * \details H5Aget_space() retrieves a copy of the dataspace for an + * attribute. The dataspace identifier returned from this + * function must be released with H5Sclose() or resource leaks + * will develop. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Aget_space(hid_t attr_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Returns the amount of storage required for an attribute + * + * \attr_id + * + * \return Returns the amount of storage size allocated for the attribute; + * otherwise returns 0 (zero). + * + * \details H5Aget_storage_size() returns the amount of storage that is + * required for the specified attribute, \p attr_id. + * + * \since 1.6.0 + * + */ H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); -H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/); -H5_DLL herr_t 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); -H5_DLL 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 /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); -H5_DLL herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, - const char *old_attr_name, const char *new_attr_name, hid_t lapl_id); -H5_DLL 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); -H5_DLL 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 lapd_id); -H5_DLL herr_t H5Adelete(hid_t loc_id, const char *name); -H5_DLL herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, - const char *attr_name, hid_t lapl_id); -H5_DLL 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); -H5_DLL htri_t H5Aexists(hid_t obj_id, const char *attr_name); -H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, - const char *attr_name, hid_t lapl_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Gets an attribute datatype + * + * \attr_id + * + * \return \hid_t{datatype} + * + * \details H5Aget_type() retrieves a copy of the datatype for an attribute. + * 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. + * + * The datatype identifier returned from this function must be + * released with H5Tclose() or resource leaks will develop. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Aget_type(hid_t attr_id); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Calls user-defined function for each attribute on an object + * + * \fgdt_loc_id + * \param[in] idx_type Type of index + * \param[in] order Order in which to iterate over index + * \param[in,out] idx Initial and returned offset within index + * \param[in] op User-defined function to pass each attribute to + * \param[in,out] op_data User data to pass through to and to be returned + * by iterator operator function + * + * \return \herr_t + * Further note that this function returns the return value of the + * last operator if it was non-zero, which can be a negative value, + * zero if all attributes were processed, or a positive value + * indicating short-circuit success. + * + * \details H5Aiterate2() iterates over the attributes attached to a + * dataset, named datatype, or group, as specified by \p loc_id. + * For each attribute, user-provided data, \p op_data, with + * additional information as defined below, is passed to a + * user-defined function, \p op, which operates on that + * attribute. + * + * 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 + * #H5_ITER_DEC, it would be the fifth attribute from the end of + * the index. + * + * The parameter \p idx is passed in on an H5Aiterate2() call with + * one value and may be returned with another value. The value + * passed in identifies the parameter to be operated on first; + * 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 + * + */ +H5_DLL 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); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Calls user-defined function for each attribute on an object + * + * \fgdt_loc_id + * \param[in] obj_name Name of object, relative to location + * \param[in] idx_type Type of index + * \param[in] order Order in which to iterate over index + * \param[in,out] idx Initial and returned offset within index + * \param[in] op User-defined function to pass each attribute to + * \param[in,out] op_data User data to pass through to and to be returned + * by iterator operator function + * \lapl_id + * + * \return \herr_t + * Further note that this function returns the return value of + * the last operator if it was non-zero, which can be a negative + * value, zero if all attributes were processed, or a positive value + * indicating short-circuit success. + * + * \details H5Aiterate_by_name() iterates over the attributes attached + * to the dataset or group specified with \p loc_id and \p obj_name. + * For each attribute, user-provided data, \p op_data, with + * 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 + * #H5_ITER_DEC, it would be the fifth attribute from the end of + * the index. + * + * The parameter \p idx is passed in on an H5Aiterate_by_name() + * call with one value and may be returned with another value. The + * value passed in identifies the parameter to be operated on first; + * 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. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Opens an attribute for an object specified by object identifier and + * attribute name + * + * \fgdt_loc_id{obj_id} + * \param[in] attr_name Name of attribute to open + * \aapl_id + * + * \return \hid_tv{attribute} + * + * \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. + * + * This function, H5Aopen_by_idx() or H5Aopen_by_name() must be called + * before the attribute can be accessed for any further purpose, + * including reading, writing, or any modification. + * + * The attribute identifier returned by this function must be released + * with H5Aclose() or resource leaks will develop. + * + * \since 1.8.0 + * + * \see H5Aclose(), H5Acreate() + */ +H5_DLL hid_t H5Aopen(hid_t obj_id, const char *attr_name, hid_t aapl_id); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Opens the nth attribute attached to an object + * + * \loc_id + * \param[in] obj_name Name of object to which attribute is attached, + * relative to location + * \param[in] idx_type Type of index + * \param[in] order Index traversal order + * \param[in] n Attribute’s position in index + * \aapl_id + * \lapl_id + * + * \return \hid_tv{attribute} + * + * \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). + * + * 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(). + * + * The attribute access property list, \p aapl_id, is currently + * unused and should currently be #H5P_DEFAULT. + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to access + * the object, \p obj_name. + * + * This function, H5Aopen(), or H5Aopen_by_name() must be called + * before an attribute can be accessed for any further purpose, + * including reading, writing, or any modification. + * + * The attribute identifier returned by this function must be + * released with H5Aclose() or resource leaks will develop. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Opens an attribute for an object by object name and attribute name + * + * \fgdt_loc_id + * \param[in] obj_name Name of object to which attribute is attached, + * relative to \p loc_id + * \param[in] attr_name Name of attribute to open + * \aapl_id + * \lapl_id + * + * \return \hid_tv{attribute} + * + * \details H5Aopen_by_name() opens an existing attribute, \p attr_name, + * that is attached to an object specified by location and name, + * \p loc_id and \p obj_name, respectively. + * + * \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). + * + * The attribute access property list, \p aapl_id, is currently + * unused and should currently be #H5P_DEFAULT. + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to access + * the object, \p obj_name. + * + * This function, H5Aopen(), or H5Aopen_by_idx() must be called + * before an attribute can be accessed for any further purpose, + * including reading, writing, or any modification. + * + * The attribute identifier returned by this function must be + * released with H5Aclose() or resource leaks will develop. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/*-------------------------------------------------------------------------- */ +/** + * \ingroup H5A + * + * \brief Reads the value of an attribute + * + * \attr_id + * \mem_type_id{type_id} + * \param[out] buf Buffer for data to be read + * + * \return \herr_t + * + * \details H5Aread() reads an attribute, specified with \p attr_id. The + * attribute's in-memory datatype is specified with \p type_id. The + * entire attribute is read into \p buf from the file. + * + * Datatype conversion takes place at the time of a read or write and + * is automatic. + * + * \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. + * \since 1.0.0 + * + * \see H5Awrite() + * + */ +H5_DLL herr_t H5Aread(hid_t attr_id, hid_t type_id, void *buf); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Renames an attribute + * + * \fgdt_loc_id + * \param[in] old_name Name of the attribute to be changed + * \param[in] new_name New name for the attribute + * + * \return \herr_t + * + * \details H5Arename() changes the name of the attribute located at + * \p loc_id. + * + * The old name, \p old_name, is changed to the new name, + * \p new_name. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name); +/*--------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Writes data to an attribute + * + * \attr_id + * \mem_type_id{type_id} + * \param[out] buf Data to be written + * + * \return \herr_t + * + * \details H5Awrite() writes an attribute, specified with \p attr_id. The + * 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. + * + * \version 1.8.8 Fortran updated to Fortran2003. + * \version 1.4.2 Fortran \p dims parameter added in this release + * \since 1.0.0 + * \see H5Aread() + * + */ +H5_DLL herr_t H5Awrite(hid_t attr_id, hid_t type_id, const void *buf); +/*-------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \fgdt_loc_id + * \param[in] obj_name Name of object, relative to location, whose + * attribute is to be renamed + * \param[in] old_attr_name Prior attribute name + * \param[in] new_attr_name New attribute name + * \lapl_id + * + * \details H5Arename_by_name() changes the name of attribute that is + * attached to the object specified by \p loc_id and \p obj_name. + * The attribute named \p old_attr_name is renamed + * \p new_attr_name. + * + * The link access property list, \p lapl_id, may provide + * information regarding the properties of links required to + * access the object, \p obj_name. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, + const char *new_attr_name, hid_t lapl_id); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -99,22 +1017,188 @@ H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, /* Macros */ - /* Typedefs */ -/* Typedef for H5Aiterate1() callbacks */ -typedef herr_t (*H5A_operator1_t)(hid_t location_id/*in*/, - const char *attr_name/*in*/, void *operator_data/*in,out*/); - +//! +/** + * \brief Typedef for H5Aiterate1() callbacks + * + * \param[in] location_id The identifier for the group, dataset + * or named datatype being iterated over + * \param[in] attr_name The name of the current object attribute + * \param[in,out] operator_data A pointer to the operator data passed in to + * H5Aiterate1() + * \returns The return values from an operator are: + * \li Zero causes the iterator to continue, returning zero when + * all attributes have been processed. + * \li Positive causes the iterator to immediately return that + * positive value, indicating short-circuit success. The + * iterator can be restarted at the next attribute. + * \li Negative causes the iterator to immediately return that value, + * indicating failure. The iterator can be restarted at the next + * attribute. + */ +typedef herr_t (*H5A_operator1_t)(hid_t location_id /*in*/, const char *attr_name /*in*/, + void *operator_data /*in,out*/); +//! /* Function prototypes */ -H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, - hid_t space_id, hid_t acpl_id); -H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name); -H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); -H5_DLL int H5Aget_num_attrs(hid_t loc_id); -H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, - void *op_data); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Creates an attribute attached to a specified object + * + * \fgdt_loc_id + * \param[in] name Name of attribute to locate and open + * \param[in] type_id Identifier of attribute datatype + * \space_id + * \acpl_id + * + * \return \hid_tv{attribute} + * + * \note The \p acpl parameters is currently not used; specify #H5P_DEFAULT. + * + * \deprecated Deprecated in favor of H5Acreate2() + * + * \details H5Acreate1() creates an attribute, \p name, which is attached + * to the object specified by the identifier \p loc_id. + * + * 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. + * + * \since 1.8.0 + * + * \version 1.8.0 The function H5Acreate() was renamed to H5Acreate1() and + * deprecated in this release. + * + * \see H5Aclose() + * + */ +H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Determines the number of attributes attached to an object + * + * \fgdt_loc_id + * + * \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(). + * + * \details H5Aget_num_attrs() returns the number of attributes attached to + * the object specified by its identifier, \p loc_id. + * + * \since 1.0.0 + * + */ +H5_DLL int H5Aget_num_attrs(hid_t loc_id); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Calls a user’s function for each attribute on an object + * + * \loc_id + * \param[in,out] idx Starting (in) and ending (out) attribute index + * \param[in] op User's function to pass each attribute to + * \param[in,out] op_data User's data to pass through to iterator operator + * function + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function + * H5Aiterate2(). + * + * \details H5Aiterate1() iterates over the attributes of the object + * specified by its identifier, \p loc_id. The object can be a + * group, dataset, or named datatype. For each attribute of the + * object, the \p op_data and some additional information specified + * below are passed to the operator function \p op. The iteration + * begins with the attribute specified by its index, \p idx; the + * index for the next attribute to be processed by the operator, + * \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 + * + */ +H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *idx, H5A_operator1_t op, void *op_data); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Opens the attribute specified by its index + * + * \loc_id + * \param[in] idx Index of the attribute to open + * + * \return \hid_tv{attribute} + * + * \deprecated This function is deprecated in favor of the function + * 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 + * either a group, dataset, or named datatype, all of which may + * have any sort of attribute. The attribute specified by the index, + * \p idx , indicates the attribute to access. The value of \p idx + * is a 0-based, non-negative integer. The attribute identifier + * returned from this function must be released with H5Aclose() + * or resource leaks will develop. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); +/* --------------------------------------------------------------------------*/ +/** + * \ingroup H5A + * + * \brief Opens an attribute specified by name + * + * \loc_id + * \param[in] name Attribute name + * + * \return \hid_tv{attribute} + * + * \deprecated This function is deprecated in favor of the function + * H5Aopen_by_name(). + * + * \details H5Aopen_name() opens an attribute specified by its name, + * \p name, which is attached to the object specified with + * \p loc_id. The location object may be either a group, dataset, + * or named datatype, which may have any sort of attribute. The + * attribute identifier returned from this function must be + * released with H5Aclose() or resource leaks will develop. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Aopen_name(hid_t loc_id, const char *name); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -122,5 +1206,4 @@ H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, } #endif -#endif /* _H5Apublic_H */ - +#endif /* H5Apublic_H */ diff --git a/src/H5Atest.c b/src/H5Atest.c index 36c3d35037c..62d608e1444 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,57 +24,49 @@ /* Module Setup */ /****************/ -#include "H5Amodule.h" /* This source code file is part of the H5A module */ -#define H5A_TESTING /* Suppress warning about H5A testing funcs */ - +#include "H5Amodule.h" /* This source code file is part of the H5A module */ +#define H5A_TESTING /* Suppress warning about H5A testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5A__is_shared_test * @@ -90,13 +82,13 @@ htri_t H5A__is_shared_test(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - htri_t ret_value = FAIL; /* Return value */ + H5A_t *attr; /* Attribute object for ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Check if attribute is shared */ @@ -106,7 +98,6 @@ H5A__is_shared_test(hid_t attr_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__is_shared_test() */ - /*------------------------------------------------------------------------- * Function: H5A__get_shared_rc_test * @@ -122,18 +113,18 @@ 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 */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t * attr; /* Attribute object for ID */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if (NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -141,13 +132,12 @@ H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr)); /* Retrieve ref count for shared or shareable attribute */ - if(H5SM_get_refcount(attr->oloc.file, H5O_ATTR_ID, &attr->sh_loc, ref_count) < 0) + if (H5SM_get_refcount(attr->oloc.file, H5O_ATTR_ID, &attr->sh_loc, ref_count) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_shared_rc_test() */ - diff --git a/src/H5B.c b/src/H5B.c index 79ab6b62d00..55732fa8d6d 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -95,31 +95,33 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ -#define H5B_SIZEOF_HDR(F) \ - (H5_SIZEOF_MAGIC + /*magic number */ \ - 4 + /*type, level, num entries */ \ - 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ +#define H5B_SIZEOF_HDR(F) \ + (H5_SIZEOF_MAGIC + /*magic number */ \ + 4 + /*type, level, num entries */ \ + 2 * H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */ /* Default initializer for H5B_ins_ud_t */ -#define H5B_INS_UD_T_NULL {NULL, HADDR_UNDEF, H5AC__NO_FLAGS_SET} +#define H5B_INS_UD_T_NULL \ + { \ + NULL, HADDR_UNDEF, H5AC__NO_FLAGS_SET \ + } /******************/ /* Local Typedefs */ @@ -127,33 +129,29 @@ /* "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 */ + H5B_info_t *bt_info; /* Information about B-tree */ + 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 */ - haddr_t addr; /* B-tree address */ - unsigned cache_flags; /* Cache flags for H5AC_unprotect() */ + H5B_t * bt; /* B-tree */ + haddr_t addr; /* B-tree address */ + unsigned cache_flags; /* Cache flags for H5AC_unprotect() */ } H5B_ins_ud_t; - /********************/ /* Local Prototypes */ /********************/ -static H5B_ins_t H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, - const H5B_class_t *type, uint8_t *lt_key, 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*/); -static herr_t H5B__insert_child(H5B_t *bt, unsigned *bt_flags, - unsigned idx, haddr_t child, - H5B_ins_t anchor, const void *md_key); -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*/); -static H5B_t * H5B__copy(const H5B_t *old_bt); - +static H5B_ins_t H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8_t *lt_key, + 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*/); +static herr_t H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5B_ins_t anchor, + const void *md_key); +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*/); +static H5B_t *H5B__copy(const H5B_t *old_bt); /*********************/ /* Package Variables */ @@ -171,12 +169,10 @@ H5FL_BLK_DEFINE(native_block); /* Declare a free list to manage the H5B_t struct */ H5FL_DEFINE(H5B_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -190,8 +186,6 @@ H5FL_BLK_DEFINE_STATIC(page); /* Declare a free list to manage the native key offset sequence information */ H5FL_SEQ_DEFINE_STATIC(size_t); - - /*------------------------------------------------------------------------- * Function: H5B_create * @@ -210,10 +204,10 @@ 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_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out*/) { - H5B_t *bt = NULL; - H5B_shared_t *shared=NULL; /* Pointer to shared B-tree info */ + H5B_t * bt = NULL; + H5B_shared_t *shared = NULL; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -228,49 +222,48 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out* /* * Allocate file and memory data structures. */ - if(NULL == (bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") + if (NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); - bt->level = 0; - bt->left = HADDR_UNDEF; - bt->right = HADDR_UNDEF; + bt->level = 0; + bt->left = HADDR_UNDEF; + bt->right = HADDR_UNDEF; bt->nchildren = 0; - if(NULL == (bt->rc_shared = (type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer") + if (NULL == (bt->rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer") H5UC_INC(bt->rc_shared); - shared=(H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); HDassert(shared); - if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || - NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) + if (NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node") /* * Cache the new B-tree node. */ - if(H5AC_insert_entry(f, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") + if (H5AC_insert_entry(f, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") #ifdef H5B_DEBUG H5B__assert(f, *addr_p, shared->type, udata); #endif done: - if(ret_value < 0) { - if(shared && shared->sizeof_rnode>0) { - H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); + if (ret_value < 0) { + if (shared && shared->sizeof_rnode > 0) { + H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); (void)H5MF_xfree(f, H5FD_MEM_BTREE, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ - if(bt) + if (bt) /* Destroy B-tree node */ - if(H5B__node_dest(bt) < 0) + if (H5B__node_dest(bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ +} /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ - /*------------------------------------------------------------------------- * Function: H5B_find * @@ -296,13 +289,13 @@ 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 */ - htri_t ret_value = FAIL; /* Return value */ + unsigned idx = 0, lt = 0, rt; /* Final, left & right key indices */ + int cmp = 1; /* Key comparison value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -317,7 +310,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -326,47 +319,46 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) * Perform a binary search to locate the child which contains * the thing for which we're searching. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - /* compare */ - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, (idx + 1)))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + /* compare */ + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, (idx + 1)))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ /* Check if not found */ - if(cmp) - HGOTO_DONE(FALSE) + if (cmp) + HGOTO_DONE(FALSE) /* * Follow the link to the subtree or to the data node. */ HDassert(idx < bt->nchildren); - if(bt->level > 0) { - if((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in subtree") + if (bt->level > 0) { + if ((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in subtree") } /* end if */ else { - if((ret_value = (type->found)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), udata)) < 0) + if ((ret_value = (type->found)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), udata)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't lookup key in leaf node") } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_find() */ - /*------------------------------------------------------------------------- * Function: H5B__split * @@ -389,14 +381,13 @@ 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__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 */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nleft, nright; /* Number of keys in left & right halves */ + double split_ratios[3]; /* B-tree split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -418,23 +409,23 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, HDassert(bt_ud->bt->nchildren == shared->two_k); /* Get B-tree split ratios */ - if(H5CX_get_btree_split_ratios(split_ratios) < 0) + if (H5CX_get_btree_split_ratios(split_ratios) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree split ratios") #ifdef H5B_DEBUG - if(H5DEBUG(B)) { - const char *side; - - if(!H5F_addr_defined(bt_ud->bt->left) && !H5F_addr_defined(bt_ud->bt->right)) - side = "ONLY"; - else if(!H5F_addr_defined(bt_ud->bt->right)) - side = "RIGHT"; - else if(!H5F_addr_defined(bt_ud->bt->left)) - side = "LEFT"; - else - side = "MIDDLE"; - HDfprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s", - shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side); + if (H5DEBUG(B)) { + const char *side; + + if (!H5F_addr_defined(bt_ud->bt->left) && !H5F_addr_defined(bt_ud->bt->right)) + side = "ONLY"; + else if (!H5F_addr_defined(bt_ud->bt->right)) + side = "RIGHT"; + else if (!H5F_addr_defined(bt_ud->bt->left)) + side = "LEFT"; + else + side = "MIDDLE"; + HDfprintf(H5DEBUG(B), "H5B__split: %3u {%5.3f,%5.3f,%5.3f} %6s", shared->two_k, split_ratios[0], + split_ratios[1], split_ratios[2], side); } #endif @@ -442,38 +433,39 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, * Decide how to split the children of the old node among the old node * and the new node. */ - if(!H5F_addr_defined(bt_ud->bt->right)) - nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ - else if(!H5F_addr_defined(bt_ud->bt->left)) - nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ + if (!H5F_addr_defined(bt_ud->bt->right)) + nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ + else if (!H5F_addr_defined(bt_ud->bt->left)) + nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ else - nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ + nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ /* * Keep the new child in the same node as the child that split. This can * result in nodes that have an unused child when data is written * sequentially, but it simplifies stuff below. */ - if(idx < nleft && nleft == shared->two_k) - --nleft; - else if(idx >= nleft && 0 == nleft) - nleft++; + if (idx < nleft && nleft == shared->two_k) + --nleft; + else if (idx >= nleft && 0 == nleft) + nleft++; nright = shared->two_k - nleft; #ifdef H5B_DEBUG - if(H5DEBUG(B)) + if (H5DEBUG(B)) HDfprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright); #endif /* * Create the new B-tree node. */ - if(H5B_create(f, shared->type, udata, &split_bt_ud->addr/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") - cache_udata.f = f; - cache_udata.type = shared->type; + if (H5B_create(f, shared->type, udata, &split_bt_ud->addr /*out*/) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") + cache_udata.f = f; + cache_udata.type = shared->type; cache_udata.rc_shared = bt_ud->bt->rc_shared; - if(NULL == (split_bt_ud->bt = (H5B_t *)H5AC_protect(f, H5AC_BT, split_bt_ud->addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree") + if (NULL == (split_bt_ud->bt = + (H5B_t *)H5AC_protect(f, H5AC_BT, split_bt_ud->addr, &cache_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree") split_bt_ud->bt->level = bt_ud->bt->level; /* @@ -481,12 +473,9 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, */ split_bt_ud->cache_flags = H5AC__DIRTIED_FLAG; - H5MM_memcpy(split_bt_ud->bt->native, - bt_ud->bt->native + nleft * shared->type->sizeof_nkey, - (nright + 1) * shared->type->sizeof_nkey); - H5MM_memcpy(split_bt_ud->bt->child, - &bt_ud->bt->child[nleft], - nright * sizeof(haddr_t)); + H5MM_memcpy(split_bt_ud->bt->native, bt_ud->bt->native + nleft * shared->type->sizeof_nkey, + (nright + 1) * shared->type->sizeof_nkey); + H5MM_memcpy(split_bt_ud->bt->child, &bt_ud->bt->child[nleft], nright * sizeof(haddr_t)); split_bt_ud->bt->nchildren = nright; @@ -499,18 +488,19 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, /* * Update other sibling pointers. */ - split_bt_ud->bt->left = bt_ud->addr; + split_bt_ud->bt->left = bt_ud->addr; split_bt_ud->bt->right = bt_ud->bt->right; - if(H5F_addr_defined(bt_ud->bt->right)) { - H5B_t *tmp_bt; + if (H5F_addr_defined(bt_ud->bt->right)) { + H5B_t *tmp_bt; - if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, H5AC_BT, bt_ud->bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (tmp_bt = (H5B_t *)H5AC_protect(f, H5AC_BT, bt_ud->bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling") tmp_bt->left = split_bt_ud->addr; - if(H5AC_unprotect(f, H5AC_BT, bt_ud->bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt_ud->bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end if */ @@ -518,18 +508,18 @@ H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, HDassert(bt_ud->cache_flags & H5AC__DIRTIED_FLAG); done: - if(ret_value < 0) { - if(split_bt_ud->bt && H5AC_unprotect(f, H5AC_BT, split_bt_ud->addr, split_bt_ud->bt, split_bt_ud->cache_flags) < 0) + if (ret_value < 0) { + if (split_bt_ud->bt && + H5AC_unprotect(f, H5AC_BT, split_bt_ud->addr, split_bt_ud->bt, split_bt_ud->cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - split_bt_ud->bt = NULL; - split_bt_ud->addr = HADDR_UNDEF; + split_bt_ud->bt = NULL; + split_bt_ud->addr = HADDR_UNDEF; split_bt_ud->cache_flags = H5AC__NO_FLAGS_SET; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__split() */ - /*------------------------------------------------------------------------- * Function: H5B_insert * @@ -548,22 +538,22 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) /* * These are defined this way to satisfy alignment constraints. */ - uint64_t _lt_key[128], _md_key[128], _rt_key[128]; - uint8_t *lt_key=(uint8_t*)_lt_key; - uint8_t *md_key=(uint8_t*)_md_key; - uint8_t *rt_key=(uint8_t*)_rt_key; - - hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE; - haddr_t old_root_addr = HADDR_UNDEF; - 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_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5B_ins_t my_ins = H5B_INS_ERROR; - herr_t ret_value = SUCCEED; + uint64_t _lt_key[128], _md_key[128], _rt_key[128]; + uint8_t *lt_key = (uint8_t *)_lt_key; + uint8_t *md_key = (uint8_t *)_md_key; + uint8_t *rt_key = (uint8_t *)_rt_key; + + hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE; + haddr_t old_root_addr = HADDR_UNDEF; + 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_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + H5B_ins_t my_ins = H5B_INS_ERROR; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -574,27 +564,26 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Protect the root node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - bt_ud.addr = addr; - if(NULL == (bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + bt_ud.addr = addr; + if (NULL == (bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to locate root of B-tree") /* Insert the object */ - if((int)(my_ins = H5B__insert_helper(f, &bt_ud, type, lt_key, - <_key_changed, md_key, udata, rt_key, &rt_key_changed, - &split_bt_ud/*out*/)) < 0) + if ((int)(my_ins = H5B__insert_helper(f, &bt_ud, type, lt_key, <_key_changed, md_key, udata, rt_key, + &rt_key_changed, &split_bt_ud /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") /* Check if the root node split */ - if(H5B_INS_NOOP == my_ins) { + if (H5B_INS_NOOP == my_ins) { /* The root node did not split - just return */ HDassert(!split_bt_ud.bt); HGOTO_DONE(SUCCEED) @@ -607,18 +596,18 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) level = bt_ud.bt->level; /* update left and right keys */ - if(!lt_key_changed) - H5MM_memcpy(lt_key, H5B_NKEY(bt_ud.bt,shared,0), type->sizeof_nkey); - if(!rt_key_changed) - H5MM_memcpy(rt_key, H5B_NKEY(split_bt_ud.bt,shared,split_bt_ud.bt->nchildren), type->sizeof_nkey); + if (!lt_key_changed) + H5MM_memcpy(lt_key, H5B_NKEY(bt_ud.bt, shared, 0), type->sizeof_nkey); + if (!rt_key_changed) + H5MM_memcpy(rt_key, H5B_NKEY(split_bt_ud.bt, shared, split_bt_ud.bt->nchildren), type->sizeof_nkey); /* * Copy the old root node to some other file location and make the new root * at the old root's previous address. This prevents the B-tree from * "moving". */ - H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); - if(HADDR_UNDEF == (old_root_addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) + H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); + if (HADDR_UNDEF == (old_root_addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root") /* @@ -626,17 +615,17 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) */ /* Make a copy of the old root information */ - if(NULL == (new_root_bt = H5B__copy(bt_ud.bt))) + if (NULL == (new_root_bt = H5B__copy(bt_ud.bt))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to copy old root") /* Unprotect the old root so we can move it. Also force it to be marked * dirty so it is written to the new location. */ - if(H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release old root") - bt_ud.bt = NULL; /* Make certain future references will be caught */ + bt_ud.bt = NULL; /* Make certain future references will be caught */ /* Move the location of the old root on the disk */ - if(H5AC_move_entry(f, H5AC_BT, bt_ud.addr, old_root_addr) < 0) + if (H5AC_move_entry(f, H5AC_BT, bt_ud.addr, old_root_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node") bt_ud.addr = old_root_addr; @@ -645,11 +634,11 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) split_bt_ud.cache_flags |= H5AC__DIRTIED_FLAG; /* clear the old root info at the old address (we already copied it) */ - new_root_bt->left = HADDR_UNDEF; + new_root_bt->left = HADDR_UNDEF; new_root_bt->right = HADDR_UNDEF; /* Set the new information for the copy */ - new_root_bt->level = level + 1; + new_root_bt->level = level + 1; new_root_bt->nchildren = 2; new_root_bt->child[0] = bt_ud.addr; @@ -660,31 +649,30 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) H5MM_memcpy(H5B_NKEY(new_root_bt, shared, 2), rt_key, shared->type->sizeof_nkey); /* Insert the modified copy of the old root into the file again */ - if(H5AC_insert_entry(f, H5AC_BT, addr, new_root_bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_BT, addr, new_root_bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to add old B-tree root node to cache") done: - if(ret_value < 0) - if(new_root_bt && H5B__node_dest(new_root_bt) < 0) + if (ret_value < 0) + if (new_root_bt && H5B__node_dest(new_root_bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to free B-tree root node"); - if(bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, bt_ud.cache_flags) < 0) + if (bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect old root") - if(split_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, split_bt_ud.addr, split_bt_ud.bt, split_bt_ud.cache_flags) < 0) + if (split_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, split_bt_ud.addr, split_bt_ud.bt, split_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect new child") #ifdef H5B_DEBUG - if(ret_value >= 0) + if (ret_value >= 0) H5B__assert(f, addr, type, udata); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_insert() */ - /*------------------------------------------------------------------------- * Function: H5B__insert_child * @@ -700,11 +688,11 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) *------------------------------------------------------------------------- */ static herr_t -H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, - haddr_t child, H5B_ins_t anchor, const void *md_key) +H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5B_ins_t anchor, + const void *md_key) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - uint8_t *base; /* Base offset for move */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + uint8_t * base; /* Base offset for move */ FUNC_ENTER_STATIC_NOERR @@ -719,32 +707,30 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, * records to an unlimited dimension chunked dataset) */ base = H5B_NKEY(bt, shared, (idx + 1)); - if((idx + 1) == bt->nchildren) { + if ((idx + 1) == bt->nchildren) { /* Make room for the new key */ H5MM_memcpy(base + shared->type->sizeof_nkey, base, - shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ + shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ H5MM_memcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if(H5B_INS_RIGHT == anchor) - idx++; /* Don't have to memmove() child addresses down, just add new child */ + if (H5B_INS_RIGHT == anchor) + idx++; /* Don't have to memmove() child addresses down, just add new child */ else /* Make room for the new child address */ bt->child[idx + 1] = bt->child[idx]; } /* end if */ else { /* Make room for the new key */ - HDmemmove(base + shared->type->sizeof_nkey, base, - (bt->nchildren - idx) * shared->type->sizeof_nkey); + HDmemmove(base + shared->type->sizeof_nkey, base, (bt->nchildren - idx) * shared->type->sizeof_nkey); H5MM_memcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if(H5B_INS_RIGHT == anchor) + if (H5B_INS_RIGHT == anchor) idx++; /* Make room for the new child address */ - HDmemmove(bt->child + idx + 1, bt->child + idx, - (bt->nchildren - idx) * sizeof(haddr_t)); + HDmemmove(bt->child + idx + 1, bt->child + idx, (bt->nchildren - idx) * sizeof(haddr_t)); } /* end if */ bt->child[idx] = child; @@ -756,7 +742,6 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_insert_child() */ - /*------------------------------------------------------------------------- * Function: H5B__insert_helper * @@ -788,20 +773,20 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, *------------------------------------------------------------------------- */ static H5B_ins_t -H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, - uint8_t *lt_key, 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__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8_t *lt_key, + 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_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 */ - H5B_ins_ud_t child_bt_ud = H5B_INS_UD_T_NULL; /* Child B-tree */ - H5B_ins_ud_t new_child_bt_ud = H5B_INS_UD_T_NULL; /* Newly split child B-tree */ - H5B_ins_t my_ins = H5B_INS_ERROR; - H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ + 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 */ + H5B_ins_ud_t child_bt_ud = H5B_INS_UD_T_NULL; /* Child B-tree */ + H5B_ins_ud_t new_child_bt_ud = H5B_INS_UD_T_NULL; /* Newly split child B-tree */ + H5B_ins_t my_ins = H5B_INS_ERROR; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -831,7 +816,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, *rt_key_changed = FALSE; /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -843,75 +828,78 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, */ rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ /* Set up user data for cache callbacks */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(0 == bt->nchildren) { - /* - * The value being inserted will be the only value in this tree. We - * must necessarily be at level zero. - */ - HDassert(0 == bt->level); - if((type->new_node)(f, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata, - H5B_NKEY(bt, shared, 1), bt->child + 0/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") - bt->nchildren = 1; + if (0 == bt->nchildren) { + /* + * The value being inserted will be the only value in this tree. We + * must necessarily be at level zero. + */ + HDassert(0 == bt->level); + if ((type->new_node)(f, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata, H5B_NKEY(bt, shared, 1), + bt->child + 0 /*out*/) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") + bt->nchildren = 1; bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - idx = 0; + idx = 0; - if(type->follow_min) { - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") - } /* end if */ + if (type->follow_min) { + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") + } /* end if */ else - my_ins = H5B_INS_NOOP; - } else if(cmp < 0 && idx == 0) { - if(bt->level > 0) { + my_ins = H5B_INS_NOOP; + } + else if (cmp < 0 && idx == 0) { + if (bt->level > 0) { /* * The value being inserted is less than any value in this tree. * Follow the minimum branch out of this node to a subtree. */ child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, - udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, - &new_child_bt_ud/*out*/)) < 0) + if ((int)(my_ins = H5B__insert_helper( + f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree") - } else if(type->follow_min) { + } + else if (type->follow_min) { /* * The value being inserted is less than any leaf node out of this * current node. Follow the minimum branch to a leaf node and let * the subclass handle the problem. */ - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") - } else { + } + else { /* * The value being inserted is less than any leaf node out of the * current node. Create a new minimum leaf node out of this B-tree * node. This node is not empty (handled above). */ my_ins = H5B_INS_LEFT; - H5MM_memcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); - if((type->new_node)(f, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata, - md_key, &new_child_bt_ud.addr/*out*/) < 0) + H5MM_memcpy(md_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); + if ((type->new_node)(f, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata, md_key, + &new_child_bt_ud.addr /*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") *lt_key_changed = TRUE; } /* end else */ @@ -919,47 +907,50 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, #ifdef H5_STRICT_FORMAT_CHECKS /* Since we are to the left of the leftmost key there must not be a left * sibling */ - if(H5F_addr_defined(bt->left)) + if (H5F_addr_defined(bt->left)) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "internal error: likely corrupt key values") #endif /* H5_STRICT_FORMAT_CHECKS */ - } else if(cmp > 0 && idx + 1 >= bt->nchildren) { + } + else if (cmp > 0 && idx + 1 >= bt->nchildren) { if (bt->level > 0) { /* - * The value being inserted is larger than any value in this tree. - * Follow the maximum branch out of this node to a subtree. - */ - idx = bt->nchildren - 1; + * The value being inserted is larger than any value in this tree. + * Follow the maximum branch out of this node to a subtree. + */ + idx = bt->nchildren - 1; child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed, - &new_child_bt_ud/*out*/)) < 0) + if ((int)(my_ins = H5B__insert_helper( + f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree") - } else if(type->follow_max) { + } + else if (type->follow_max) { /* * The value being inserted is larger than any leaf node out of the * current node. Follow the maximum branch to a leaf node and let * the subclass handle the problem. */ idx = bt->nchildren - 1; - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") - } else { + } + else { /* * The value being inserted is larger than any leaf node out of the * current node. Create a new maximum leaf node out of this B-tree * node. */ - idx = bt->nchildren - 1; + idx = bt->nchildren - 1; my_ins = H5B_INS_RIGHT; H5MM_memcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); - if((type->new_node)(f, H5B_INS_RIGHT, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), &new_child_bt_ud.addr/*out*/) < 0) + if ((type->new_node)(f, H5B_INS_RIGHT, md_key, udata, H5B_NKEY(bt, shared, idx + 1), + &new_child_bt_ud.addr /*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") *rt_key_changed = TRUE; } /* end else */ @@ -967,49 +958,53 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, #ifdef H5_STRICT_FORMAT_CHECKS /* Since we are to the right of the rightmost key there must not be a * right sibling */ - if(H5F_addr_defined(bt->right)) + if (H5F_addr_defined(bt->right)) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "internal error: likely corrupt key values") #endif /* H5_STRICT_FORMAT_CHECKS */ - } else if(cmp) { - /* - * We couldn't figure out which branch to follow out of this node. THIS - * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. - */ - HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0); + } + else if (cmp) { + /* + * We couldn't figure out which branch to follow out of this node. THIS + * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. + */ + HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0); #ifdef NDEBUG - HDabort(); + HDabort(); #endif /* NDEBUG */ - } else if(bt->level > 0) { - /* - * Follow a branch out of this node to another subtree. - */ - HDassert(idx < bt->nchildren); - child_bt_ud.addr = bt->child[idx]; - if(NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, H5AC__NO_FLAGS_SET))) + } + else if (bt->level > 0) { + /* + * Follow a branch out of this node to another subtree. + */ + HDassert(idx < bt->nchildren); + child_bt_ud.addr = bt->child[idx]; + if (NULL == (child_bt_ud.bt = (H5B_t *)H5AC_protect(f, H5AC_BT, child_bt_ud.addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - if((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, - H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &new_child_bt_ud/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") - } else { - /* - * Follow a branch out of this node to a leaf node of some other type. - */ - HDassert(idx < bt->nchildren); - if((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), - rt_key_changed, &new_child_bt_ud.addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") + if ((int)(my_ins = H5B__insert_helper(f, &child_bt_ud, type, H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), + rt_key_changed, &new_child_bt_ud /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") + } + else { + /* + * Follow a branch out of this node to a leaf node of some other type. + */ + HDassert(idx < bt->nchildren); + if ((int)(my_ins = (type->insert)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &new_child_bt_ud.addr /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") } HDassert((int)my_ins >= 0); /* * Update the left and right keys of the current node. */ - if(*lt_key_changed) { + if (*lt_key_changed) { bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - if(idx > 0) { + if (idx > 0) { HDassert(type->critical_key == H5B_LEFT); HDassert(!(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins)); *lt_key_changed = FALSE; @@ -1017,9 +1012,9 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, else H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); } /* end if */ - if(*rt_key_changed) { + if (*rt_key_changed) { bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - if(idx + 1 < bt->nchildren) { + if (idx + 1 < bt->nchildren) { HDassert(type->critical_key == H5B_RIGHT); HDassert(!(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins)); *rt_key_changed = FALSE; @@ -1032,76 +1027,77 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, * Handle changes/additions to children */ HDassert(!(bt->level == 0) != !(child_bt_ud.bt)); - if(H5B_INS_CHANGE == my_ins) { - /* - * The insertion simply changed the address for the child. - */ - HDassert(!child_bt_ud.bt); - HDassert(bt->level == 0); - bt->child[idx] = new_child_bt_ud.addr; + if (H5B_INS_CHANGE == my_ins) { + /* + * The insertion simply changed the address for the child. + */ + HDassert(!child_bt_ud.bt); + HDassert(bt->level == 0); + bt->child[idx] = new_child_bt_ud.addr; bt_ud->cache_flags |= H5AC__DIRTIED_FLAG; - } else if(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { + } + 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. - */ - if(bt->nchildren == shared->two_k) { - if(H5B__split(f, bt_ud, idx, udata, split_bt_ud/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") - if(idx < bt->nchildren) { - tmp_bt = bt; + /* + * If this node is full then split it before inserting the new child. + */ + if (bt->nchildren == shared->two_k) { + if (H5B__split(f, bt_ud, idx, udata, split_bt_ud /*out*/) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") + if (idx < bt->nchildren) { + tmp_bt = bt; tmp_bt_flags_ptr = &bt_ud->cache_flags; - } else { - idx -= bt->nchildren; - tmp_bt = split_bt_ud->bt; + } + else { + idx -= bt->nchildren; + tmp_bt = split_bt_ud->bt; tmp_bt_flags_ptr = &split_bt_ud->cache_flags; - } - } /* end if */ + } + } /* end if */ else { - tmp_bt = bt; + tmp_bt = bt; tmp_bt_flags_ptr = &bt_ud->cache_flags; - } /* end else */ + } /* end else */ - /* Insert the child */ - if(H5B__insert_child(tmp_bt, tmp_bt_flags_ptr, idx, new_child_bt_ud.addr, my_ins, md_key) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") + /* Insert the child */ + if (H5B__insert_child(tmp_bt, tmp_bt_flags_ptr, idx, new_child_bt_ud.addr, my_ins, md_key) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") } /* end else-if */ /* * If this node split, return the mid key (the one that is shared * by the left and right node). */ - if(split_bt_ud->bt) { - H5MM_memcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey); - ret_value = H5B_INS_RIGHT; + if (split_bt_ud->bt) { + H5MM_memcpy(md_key, H5B_NKEY(split_bt_ud->bt, shared, 0), type->sizeof_nkey); + ret_value = H5B_INS_RIGHT; #ifdef H5B_DEBUG - /* - * The max key in the original left node must be equal to the min key - * in the new node. - */ - cmp = (type->cmp2)(H5B_NKEY(bt, shared, bt->nchildren), udata, - H5B_NKEY(split_bt_ud->bt, shared, 0)); - HDassert(0 == cmp); + /* + * The max key in the original left node must be equal to the min key + * in the new node. + */ + cmp = (type->cmp2)(H5B_NKEY(bt, shared, bt->nchildren), udata, H5B_NKEY(split_bt_ud->bt, shared, 0)); + HDassert(0 == cmp); #endif } /* end if */ else - ret_value = H5B_INS_NOOP; + ret_value = H5B_INS_NOOP; done: - if(child_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, child_bt_ud.addr, child_bt_ud.bt, child_bt_ud.cache_flags) < 0) + if (child_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, child_bt_ud.addr, child_bt_ud.bt, child_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect child") - if(new_child_bt_ud.bt) - if(H5AC_unprotect(f, H5AC_BT, new_child_bt_ud.addr, new_child_bt_ud.bt, new_child_bt_ud.cache_flags) < 0) + if (new_child_bt_ud.bt) + if (H5AC_unprotect(f, H5AC_BT, new_child_bt_ud.addr, new_child_bt_ud.bt, + new_child_bt_ud.cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect new child") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_insert_helper() */ - /*------------------------------------------------------------------------- * Function: H5B__iterate_helper * @@ -1116,15 +1112,14 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, *------------------------------------------------------------------------- */ static herr_t -H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata) +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_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 */ + 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 */ FUNC_ENTER_STATIC @@ -1138,36 +1133,35 @@ H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(udata); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Protect the initial/current node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node") /* Iterate over node's children */ - for(u = 0; u < bt->nchildren && ret_value == H5_ITER_CONT; u++) { - if(bt->level > 0) + for (u = 0; u < bt->nchildren && ret_value == H5_ITER_CONT; u++) { + if (bt->level > 0) ret_value = H5B__iterate_helper(f, type, bt->child[u], op, udata); else ret_value = (*op)(f, H5B_NKEY(bt, shared, u), bt->child[u], H5B_NKEY(bt, shared, u + 1), udata); - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); } /* end for */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__iterate_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_iterate * @@ -1182,10 +1176,9 @@ H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ herr_t -H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata) +H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -1199,13 +1192,12 @@ H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(udata); /* Iterate over the B-tree records */ - if((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) + if ((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_iterate() */ - /*------------------------------------------------------------------------- * Function: H5B__remove_helper * @@ -1231,18 +1223,18 @@ H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ static H5B_ins_t -H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, - uint8_t *lt_key/*out*/, hbool_t *lt_key_changed/*out*/, void *udata, - uint8_t *rt_key/*out*/, hbool_t *rt_key_changed/*out*/) +H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, uint8_t *lt_key /*out*/, + 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; - 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 */ + 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 */ 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 */ - H5B_ins_t ret_value = H5B_INS_ERROR; + unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ + int cmp = 1; /* Key comparison value */ + H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_STATIC @@ -1256,7 +1248,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, HDassert(rt_key && rt_key_changed); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -1265,54 +1257,55 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * Perform a binary search to locate the child which contains the thing * for which we're searching. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node") rt = bt->nchildren; - while(lt < rt && cmp) { - idx = (lt + rt) / 2; - if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) - rt = idx; - else - lt = idx + 1; + while (lt < rt && cmp) { + idx = (lt + rt) / 2; + if ((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) + rt = idx; + else + lt = idx + 1; } /* end while */ - if(cmp) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") + if (cmp) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") /* * Follow the link to the subtree or to the data node. The return value * will be one of H5B_INS_ERROR, H5B_INS_NOOP, or H5B_INS_REMOVE. */ HDassert(idx < bt->nchildren); - if(bt->level > 0) { - /* We're at an internal node -- call recursively */ - if((int)(ret_value = H5B__remove_helper(f, bt->child[idx], type, - level + 1, H5B_NKEY(bt, shared, idx)/*out*/, - lt_key_changed/*out*/, udata, H5B_NKEY(bt, shared, idx + 1)/*out*/, - rt_key_changed/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") - } else if(type->remove) { - /* - * We're at a leaf node but the leaf node points to an object that - * has a removal method. Pass the removal request to the pointed-to - * object and let it decide how to progress. - */ - if((int)(ret_value = (type->remove)(f, bt->child[idx], - H5B_NKEY(bt, shared, idx), lt_key_changed, udata, - H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") - } else { - /* - * We're at a leaf node which points to an object that has no removal - * method. The best we can do is to leave the object alone but - * remove the B-tree reference to the object. - */ - *lt_key_changed = FALSE; - *rt_key_changed = FALSE; - ret_value = H5B_INS_REMOVE; + if (bt->level > 0) { + /* We're at an internal node -- call recursively */ + if ((int)(ret_value = + H5B__remove_helper(f, bt->child[idx], type, level + 1, + H5B_NKEY(bt, shared, idx) /*out*/, lt_key_changed /*out*/, udata, + H5B_NKEY(bt, shared, idx + 1) /*out*/, rt_key_changed /*out*/)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") + } + else if (type->remove) { + /* + * We're at a leaf node but the leaf node points to an object that + * has a removal method. Pass the removal request to the pointed-to + * object and let it decide how to progress. + */ + if ((int)(ret_value = (type->remove)(f, bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, + udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") + } + else { + /* + * We're at a leaf node which points to an object that has no removal + * method. The best we can do is to leave the object alone but + * remove the B-tree reference to the object. + */ + *lt_key_changed = FALSE; + *rt_key_changed = FALSE; + ret_value = H5B_INS_REMOVE; } /* @@ -1323,20 +1316,20 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * key changed and it's the right most key of this node we must update * our right key and indicate that it changed. */ - if(*lt_key_changed) { + if (*lt_key_changed) { HDassert(type->critical_key == H5B_LEFT); bt_flags |= H5AC__DIRTIED_FLAG; - if(idx > 0) + if (idx > 0) /* Don't propagate change out of this B-tree node */ *lt_key_changed = FALSE; else H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); } /* end if */ - if(*rt_key_changed) { + if (*rt_key_changed) { HDassert(type->critical_key == H5B_RIGHT); bt_flags |= H5AC__DIRTIED_FLAG; - if(idx + 1 < bt->nchildren) + if (idx + 1 < bt->nchildren) /* Don't propagate change out of this B-tree node */ *rt_key_changed = FALSE; else @@ -1347,14 +1340,14 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * If the subtree returned H5B_INS_REMOVE then we should remove the * subtree entry from the current node. There are four cases: */ - if(H5B_INS_REMOVE == ret_value) { + if (H5B_INS_REMOVE == ret_value) { /* Clients should not change keys when a node is removed. This function * will handle it as appropriate, based on the value of bt->critical_key */ HDassert(!(*lt_key_changed)); HDassert(!(*rt_key_changed)); - if(1 == bt->nchildren) { + if (1 == bt->nchildren) { /* * The subtree is the only child of this node. Discard both * keys and the subtree pointer. Free this node (unless it's the @@ -1362,116 +1355,123 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, */ /* Only delete the node if it is not the root node. Note that this * "level" is the opposite of bt->level */ - if(level > 0) { + if (level > 0) { /* Fix siblings, making sure that the keys remain consistent * between siblings. Overwrite the key that that is not * "critical" for any child in its node to maintain this * consistency (and avoid breaking key/child consistency) */ - if(H5F_addr_defined(bt->left)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node from tree") + if (H5F_addr_defined(bt->left)) { + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, + H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, + "unable to load node from tree") /* Copy right-most key from deleted node to right-most key * in its left neighbor, but only if it is not the critical * key for the right-most child of the left neighbor */ - if(type->critical_key == H5B_LEFT) - H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), - H5B_NKEY(bt, shared, 1), type->sizeof_nkey); + if (type->critical_key == H5B_LEFT) + H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), H5B_NKEY(bt, shared, 1), + type->sizeof_nkey); sibling->right = bt->right; - if(H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ - if(H5F_addr_defined(bt->right)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") + if (H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, + "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + if (H5F_addr_defined(bt->right)) { + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, + H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, + "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in * its right neighbor, but only if it is not the critical * key for the left-most child of the right neighbor */ - if(type->critical_key == H5B_RIGHT) - H5MM_memcpy(H5B_NKEY(sibling, shared, 0), - H5B_NKEY(bt, shared, 0), type->sizeof_nkey); + if (type->critical_key == H5B_RIGHT) + H5MM_memcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, 0), type->sizeof_nkey); sibling->left = bt->left; - if(H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ + if (H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, + "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ /* Update bt struct */ - bt->left = HADDR_UNDEF; - bt->right = HADDR_UNDEF; + bt->left = HADDR_UNDEF; + bt->right = HADDR_UNDEF; bt->nchildren = 0; /* Delete the node from disk (via the metadata cache) */ bt_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); - if(H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG) < 0) { - bt = NULL; + if (H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG) < 0) { + bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to free B-tree node") } /* end if */ - bt = NULL; + bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; - } else { + } + else { /* We removed the last child in the root node, set the level * back to 0 (as well as nchildren) */ bt->nchildren = 0; - bt->level = 0; + bt->level = 0; bt_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - } else if(0 == idx) { + } + else if (0 == idx) { /* * The subtree is the left-most child of this node. We update the * key and child arrays and lt_key as appropriate, depending on the * status of bt->critical_key. Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) { + if (type->critical_key == H5B_LEFT) { /* Slide all keys down 1, update lt_key */ HDmemmove(H5B_NKEY(bt, shared, 0), H5B_NKEY(bt, shared, 1), - bt->nchildren * type->sizeof_nkey); + bt->nchildren * type->sizeof_nkey); H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey); *lt_key_changed = TRUE; - } else + } + else /* Slide all but the leftmost 2 keys down, leaving the leftmost * key intact (the right key of the leftmost child is * overwritten) */ HDmemmove(H5B_NKEY(bt, shared, 1), H5B_NKEY(bt, shared, 2), - (bt->nchildren - 1) * type->sizeof_nkey); + (bt->nchildren - 1) * type->sizeof_nkey); - HDmemmove(bt->child, - bt->child + 1, - (bt->nchildren - 1) * sizeof(haddr_t)); + HDmemmove(bt->child, bt->child + 1, (bt->nchildren - 1) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; - } else if(idx + 1 == bt->nchildren) { + } + else if (idx + 1 == bt->nchildren) { /* * The subtree is the right-most child of this node. We update the * key and child arrays and rt_key as appropriate, depending on the * status of bt->critical_key. Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) + if (type->critical_key == H5B_LEFT) /* Slide the rightmost key down one, overwriting the left key of * the deleted (righmost) child */ - HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), - H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); + HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), H5B_NKEY(bt, shared, bt->nchildren), + type->sizeof_nkey); else { /* Just update rt_key */ - H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1), - type->sizeof_nkey); + H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1), type->sizeof_nkey); *rt_key_changed = TRUE; } /* end else */ bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; - } else { + } + else { /* * There are subtrees out of this node to both the left and right of * the subtree being removed. The subtree and its critical key are @@ -1479,66 +1479,62 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, * shifted left by one place. The subtree has already been freed. * Return H5B_INS_NOOP. */ - if(type->critical_key == H5B_LEFT) - HDmemmove(H5B_NKEY(bt, shared, idx), - H5B_NKEY(bt, shared, idx + 1), - (bt->nchildren - idx) * type->sizeof_nkey); + if (type->critical_key == H5B_LEFT) + HDmemmove(H5B_NKEY(bt, shared, idx), H5B_NKEY(bt, shared, idx + 1), + (bt->nchildren - idx) * type->sizeof_nkey); else - HDmemmove(H5B_NKEY(bt, shared, idx + 1), - H5B_NKEY(bt, shared, idx + 2), - (bt->nchildren - 1 - idx) * type->sizeof_nkey); + HDmemmove(H5B_NKEY(bt, shared, idx + 1), H5B_NKEY(bt, shared, idx + 2), + (bt->nchildren - 1 - idx) * type->sizeof_nkey); - HDmemmove(bt->child + idx, - bt->child + idx + 1, - (bt->nchildren - 1 - idx) * sizeof(haddr_t)); + HDmemmove(bt->child + idx, bt->child + idx + 1, (bt->nchildren - 1 - idx) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; } /* end else */ - } else /* H5B_INS_REMOVE != ret_value */ + } + else /* H5B_INS_REMOVE != ret_value */ ret_value = H5B_INS_NOOP; /* Patch keys in neighboring trees if necessary */ - if(*lt_key_changed && H5F_addr_defined(bt->left)) { + if (*lt_key_changed && H5F_addr_defined(bt->left)) { HDassert(type->critical_key == H5B_LEFT); HDassert(level > 0); /* Update the rightmost key in the left sibling */ - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->left, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node") - H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), - H5B_NKEY(bt, shared, 0), type->sizeof_nkey); + H5MM_memcpy(H5B_NKEY(sibling, shared, sibling->nchildren), H5B_NKEY(bt, shared, 0), + type->sizeof_nkey); - if(H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end if */ - else if(*rt_key_changed && H5F_addr_defined(bt->right)) { + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + else if (*rt_key_changed && H5F_addr_defined(bt->right)) { HDassert(type->critical_key == H5B_RIGHT); HDassert(level > 0); /* Update the lefttmost key in the right sibling */ - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (sibling = (H5B_t *)H5AC_protect(f, H5AC_BT, bt->right, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect node") - H5MM_memcpy(H5B_NKEY(sibling, shared, 0), - H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); + H5MM_memcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); - if(H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling = NULL; /* Make certain future references will be caught */ - } /* end else */ + sibling = NULL; /* Make certain future references will be caught */ + } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__remove_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_remove * @@ -1559,12 +1555,12 @@ herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { /* These are defined this way to satisfy alignment constraints */ - uint64_t _lt_key[128], _rt_key[128]; - uint8_t *lt_key = (uint8_t*)_lt_key; /*left key*/ - uint8_t *rt_key = (uint8_t*)_rt_key; /*right key*/ - hbool_t lt_key_changed = FALSE; /*left key changed?*/ - hbool_t rt_key_changed = FALSE; /*right key changed?*/ - herr_t ret_value = SUCCEED; /* Return value */ + uint64_t _lt_key[128], _rt_key[128]; + uint8_t *lt_key = (uint8_t *)_lt_key; /*left key*/ + uint8_t *rt_key = (uint8_t *)_rt_key; /*right key*/ + hbool_t lt_key_changed = FALSE; /*left key changed?*/ + hbool_t rt_key_changed = FALSE; /*right key changed?*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1575,8 +1571,9 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* The actual removal */ - if(H5B_INS_ERROR == H5B__remove_helper(f, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") + if (H5B_INS_ERROR == + H5B__remove_helper(f, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") #ifdef H5B_DEBUG H5B__assert(f, addr, type, udata); @@ -1585,7 +1582,6 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_remove() */ - /*------------------------------------------------------------------------- * Function: H5B_delete * @@ -1602,12 +1598,12 @@ 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1617,23 +1613,23 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) HDassert(H5F_addr_defined(addr)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Lock this B-tree node into memory for now */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* Iterate over all children in tree, deleting them */ - if(bt->level > 0) { + if (bt->level > 0) { /* Iterate over all children in node, deleting them */ - for(u = 0; u < bt->nchildren; u++) - if(H5B_delete(f, type, bt->child[u], udata) < 0) + for (u = 0; u < bt->nchildren; u++) + if (H5B_delete(f, type, bt->child[u], udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node") } /* end if */ @@ -1641,26 +1637,24 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */ /* Check for removal callback */ - if(type->remove) { + if (type->remove) { /* Iterate over all entries in node, calling callback */ - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* Call user's callback for each entry */ - if((type->remove)(f, bt->child[u], H5B_NKEY(bt, shared, u), - <_key_changed, udata, H5B_NKEY(bt, shared, u + 1), - &rt_key_changed) < H5B_INS_NOOP) + if ((type->remove)(f, bt->child[u], H5B_NKEY(bt, shared, u), <_key_changed, udata, + H5B_NKEY(bt, shared, u + 1), &rt_key_changed) < H5B_INS_NOOP) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node") } /* end for */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ - /*------------------------------------------------------------------------- * Function: H5B_shared_new * @@ -1677,9 +1671,9 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) H5B_shared_t * H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) { - H5B_shared_t *shared = NULL; /* New shared B-tree struct */ - size_t u; /* Local index variable */ - H5B_shared_t *ret_value = NULL; /* Return value */ + H5B_shared_t *shared = NULL; /* New shared B-tree struct */ + size_t u; /* Local index variable */ + H5B_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1689,43 +1683,43 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) HDassert(type); /* Allocate space for the shared structure */ - if(NULL == (shared = H5FL_CALLOC(H5B_shared_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info") + if (NULL == (shared = H5FL_CALLOC(H5B_shared_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info") /* Set up the "global" information for this file's groups */ - shared->type = type; - shared->two_k = 2 * H5F_KVALUE(f, type); + shared->type = type; + shared->two_k = 2 * H5F_KVALUE(f, type); shared->sizeof_addr = H5F_SIZEOF_ADDR(f); - shared->sizeof_len = H5F_SIZEOF_SIZE(f); + shared->sizeof_len = H5F_SIZEOF_SIZE(f); shared->sizeof_rkey = sizeof_rkey; HDassert(shared->sizeof_rkey); - shared->sizeof_keys = (shared->two_k + 1) * type->sizeof_nkey; - shared->sizeof_rnode = ((size_t)H5B_SIZEOF_HDR(f) + /*node header */ - shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ - (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ + shared->sizeof_keys = (shared->two_k + 1) * type->sizeof_nkey; + shared->sizeof_rnode = ((size_t)H5B_SIZEOF_HDR(f) + /*node header */ + shared->two_k * H5F_SIZEOF_ADDR(f) + /*child pointers */ + (shared->two_k + 1) * shared->sizeof_rkey); /*keys */ HDassert(shared->sizeof_rnode); /* Allocate and clear shared buffers */ - if(NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode))) + if (NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page") HDmemset(shared->page, 0, shared->sizeof_rnode); - if(NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1)))) + if (NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1)))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree native keys") /* Initialize the offsets into the native key buffer */ - for(u = 0; u < (shared->two_k + 1); u++) + for (u = 0; u < (shared->two_k + 1); u++) shared->nkey[u] = u * type->sizeof_nkey; /* Set return value */ ret_value = shared; done: - if(NULL == ret_value) - if(shared) { - if(shared->page) + if (NULL == ret_value) + if (shared) { + if (shared->page) shared->page = H5FL_BLK_FREE(page, shared->page); - if(shared->nkey) + if (shared->nkey) shared->nkey = H5FL_SEQ_FREE(size_t, shared->nkey); shared = H5FL_FREE(H5B_shared_t, shared); } /* end if */ @@ -1733,7 +1727,6 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_shared_new() */ - /*------------------------------------------------------------------------- * Function: H5B_shared_free * @@ -1765,7 +1758,6 @@ H5B_shared_free(void *_shared) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_shared_free() */ - /*------------------------------------------------------------------------- * Function: H5B__copy * @@ -1783,9 +1775,9 @@ H5B_shared_free(void *_shared) static H5B_t * H5B__copy(const H5B_t *old_bt) { - H5B_t *new_node = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_t *ret_value = NULL; /* Return value */ + H5B_t * new_node = NULL; + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1797,7 +1789,7 @@ H5B__copy(const H5B_t *old_bt) HDassert(shared); /* Allocate memory for the new H5B_t object */ - if(NULL == (new_node = H5FL_MALLOC(H5B_t))) + if (NULL == (new_node = H5FL_MALLOC(H5B_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ @@ -1806,8 +1798,8 @@ H5B__copy(const H5B_t *old_bt) /* Reset cache info */ HDmemset(&new_node->cache_info, 0, sizeof(H5AC_info_t)); - if(NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || - NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + if (NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ @@ -1821,18 +1813,17 @@ H5B__copy(const H5B_t *old_bt) ret_value = new_node; done: - if(NULL == ret_value) { - if(new_node) { - new_node->native = H5FL_BLK_FREE(native_block, new_node->native); - new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); - new_node = H5FL_FREE(H5B_t, new_node); + if (NULL == ret_value) { + if (new_node) { + new_node->native = H5FL_BLK_FREE(native_block, new_node->native); + new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); + new_node = H5FL_FREE(H5B_t, new_node); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__copy() */ - /*------------------------------------------------------------------------- * Function: H5B__get_info_helper * @@ -1846,18 +1837,17 @@ 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__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_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned level; /* Node level */ - size_t sizeof_rnode; /* Size of raw (disk) node */ - haddr_t next_addr; /* Address of next node to the right */ - haddr_t left_child; /* Address of left-most child in node */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + haddr_t next_addr; /* Address of next node to the right */ + haddr_t left_child; /* Address of left-most child in node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1872,7 +1862,7 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, HDassert(info_udata->udata); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, info_udata->udata))) + if (NULL == (rc_shared = (type->get_shared)(f, info_udata->udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -1881,23 +1871,23 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, sizeof_rnode = shared->sizeof_rnode; /* Protect the initial/current node */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* Cache information from this node */ left_child = bt->child[0]; - next_addr = bt->right; - level = bt->level; + next_addr = bt->right; + level = bt->level; /* Update B-tree info */ info_udata->bt_info->size += sizeof_rnode; info_udata->bt_info->num_nodes++; /* Release current node */ - if(H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; @@ -1905,10 +1895,10 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, * Follow the right-sibling pointer from node to node until we've * processed all nodes. */ - while(H5F_addr_defined(next_addr)) { + while (H5F_addr_defined(next_addr)) { /* Protect the next node to the right */ addr = next_addr; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "B-tree node") /* Cache information from this node */ @@ -1919,26 +1909,25 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, info_udata->bt_info->num_nodes++; /* Unprotect node */ - if(H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; } /* end while */ /* Check for another "row" of B-tree nodes to iterate over */ - if(level > 0) { - /* Keep following the left-most child until we reach a leaf node. */ - if(H5B__get_info_helper(f, type, left_child, info_udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") + if (level > 0) { + /* Keep following the left-most child until we reach a leaf node. */ + if (H5B__get_info_helper(f, type, left_child, info_udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") } /* end if */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__get_info_helper() */ - /*------------------------------------------------------------------------- * Function: H5B_get_info * @@ -1952,11 +1941,11 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ herr_t -H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_info_t *bt_info, H5B_operator_t op, void *udata) +H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_info, H5B_operator_t op, + void *udata) { - H5B_info_ud_t info_udata; /* User-data for B-tree size iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_info_ud_t info_udata; /* User-data for B-tree size iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1974,23 +1963,22 @@ H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, /* Set up internal user-data for the B-tree 'get info' helper routine */ info_udata.bt_info = bt_info; - info_udata.udata = udata; + info_udata.udata = udata; /* Iterate over the B-tree nodes */ - if(H5B__get_info_helper(f, type, addr, &info_udata) < 0) + if (H5B__get_info_helper(f, type, addr, &info_udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_BADITER, FAIL, "B-tree iteration failed") /* Iterate over the B-tree records, making any "leaf" callbacks */ /* (Only if operator defined) */ - if(op) - if((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) + if (op) + if ((ret_value = H5B__iterate_helper(f, type, addr, op, udata)) < 0) HERROR(H5E_BTREE, H5E_BADITER, "B-tree iteration failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_get_info() */ - /*------------------------------------------------------------------------- * Function: H5B_valid * @@ -2006,10 +1994,10 @@ H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, 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_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - htri_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -2019,32 +2007,31 @@ H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) HDassert(f); HDassert(type); - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "address is undefined") /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, NULL))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + if (NULL == (rc_shared = (type->get_shared)(f, NULL))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") HDassert(H5UC_GET_OBJ(rc_shared) != NULL); /* * Load the tree node. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree node") + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree node") done: /* Release the node */ - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_valid() */ - /*------------------------------------------------------------------------- * Function: H5B__node_dest * @@ -2067,11 +2054,10 @@ H5B__node_dest(H5B_t *bt) HDassert(bt); HDassert(bt->rc_shared); - bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); bt->native = H5FL_BLK_FREE(native_block, bt->native); H5UC_DEC(bt->rc_shared); bt = H5FL_FREE(H5B_t, bt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__node_dest() */ - diff --git a/src/H5B2.c b/src/H5B2.c index 06806aa5de1..5453387d7d0 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,38 +31,32 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -90,27 +84,25 @@ extern const H5B2_class_t H5D_BT2_FILT[1]; extern const H5B2_class_t H5B2_TEST2[1]; const H5B2_class_t *const H5B2_client_class_g[] = { - H5B2_TEST, /* 0 - H5B2_TEST_ID */ - H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ - H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ - H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ - H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ - H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ - H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ - H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ - H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ - H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ - H5D_BT2, /* 10 - H5B2_CDSET_ID */ - H5D_BT2_FILT, /* 11 - H5B2_CDSET_FILT_ID */ - H5B2_TEST2 /* 12 - H5B2_TEST_ID */ + H5B2_TEST, /* 0 - H5B2_TEST_ID */ + H5HF_HUGE_BT2_INDIR, /* 1 - H5B2_FHEAP_HUGE_INDIR_ID */ + H5HF_HUGE_BT2_FILT_INDIR, /* 2 - H5B2_FHEAP_HUGE_FILT_INDIR_ID */ + H5HF_HUGE_BT2_DIR, /* 3 - H5B2_FHEAP_HUGE_DIR_ID */ + H5HF_HUGE_BT2_FILT_DIR, /* 4 - H5B2_FHEAP_HUGE_FILT_DIR_ID */ + H5G_BT2_NAME, /* 5 - H5B2_GRP_DENSE_NAME_ID */ + H5G_BT2_CORDER, /* 6 - H5B2_GRP_DENSE_CORDER_ID */ + H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ + H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ + H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ + H5D_BT2, /* 10 - H5B2_CDSET_ID */ + H5D_BT2_FILT, /* 11 - H5B2_CDSET_FILT_ID */ + H5B2_TEST2 /* 12 - H5B2_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -118,8 +110,6 @@ const H5B2_class_t *const H5B2_client_class_g[] = { /* Declare a free list to manage the H5B2_t struct */ H5FL_DEFINE_STATIC(H5B2_t); - - /*------------------------------------------------------------------------- * Function: H5B2_create * @@ -136,10 +126,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_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 * 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 */ FUNC_ENTER_NOAPI(NULL) @@ -153,25 +143,27 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) HDcompile_assert(H5B2_NUM_BTREE_ID == NELMTS(H5B2_client_class_g)); /* Create shared v2 B-tree header */ - if(HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, cparam, ctx_udata))) + if (HADDR_UNDEF == (hdr_addr = H5B2__hdr_create(f, cparam, ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ - if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) + if (NULL == (bt2 = H5FL_MALLOC(H5B2_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; - if(H5B2__hdr_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment reference count on shared v2 B-tree header") + if (H5B2__hdr_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment reference count on shared v2 B-tree header") /* Increment # of files using this v2 B-tree header */ - if(H5B2__hdr_fuse_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") + if (H5B2__hdr_fuse_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment file reference count on shared v2 B-tree header") /* Set file pointer for this v2 B-tree open context */ bt2->f = f; @@ -180,16 +172,15 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") - if(!ret_value && bt2) - if(H5B2_close(bt2) < 0) + if (!ret_value && bt2) + if (H5B2_close(bt2) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_create() */ - /*------------------------------------------------------------------------- * Function: H5B2_open * @@ -206,9 +197,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_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_NOINIT @@ -217,25 +208,27 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ - if(hdr->pending_delete) + if (hdr->pending_delete) HGOTO_ERROR(H5E_BTREE, H5E_CANTOPENOBJ, NULL, "can't open v2 B-tree pending deletion") /* Create v2 B-tree info */ - if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) + if (NULL == (bt2 = H5FL_MALLOC(H5B2_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Point v2 B-tree wrapper at header */ bt2->hdr = hdr; - if(H5B2__hdr_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment reference count on shared v2 B-tree header") + if (H5B2__hdr_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment reference count on shared v2 B-tree header") /* Increment # of files using this v2 B-tree header */ - if(H5B2__hdr_fuse_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") + if (H5B2__hdr_fuse_incr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, + "can't increment file reference count on shared v2 B-tree header") /* Set file pointer for this v2 B-tree open context */ bt2->f = f; @@ -244,16 +237,15 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") - if(!ret_value && bt2) - if(H5B2_close(bt2) < 0) + if (!ret_value && bt2) + if (H5B2_close(bt2) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_open() */ - /*------------------------------------------------------------------------- * Function: H5B2_insert * @@ -269,8 +261,8 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) herr_t H5B2_insert(H5B2_t *bt2, void *udata) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -285,14 +277,13 @@ H5B2_insert(H5B2_t *bt2, void *udata) hdr = bt2->hdr; /* Insert the record */ - if(H5B2__insert(hdr, udata) < 0) + if (H5B2__insert(hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_insert() */ - /*------------------------------------------------------------------------- * Function: H5B2_update * @@ -311,9 +302,9 @@ 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_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -328,19 +319,20 @@ H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) hdr = bt2->hdr; /* Check if the root node is allocated yet */ - if(!H5F_addr_defined(hdr->root.addr)) { + if (!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ - if(H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + if (H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ /* Attempt to insert record into B-tree */ - if(hdr->depth > 0) { - if(H5B2__update_internal(hdr, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (hdr->depth > 0) { + if (H5B2__update_internal(hdr, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree internal node") } /* end if */ else { - if(H5B2__update_leaf(hdr, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (H5B2__update_leaf(hdr, &hdr->root, &status, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in B-tree leaf node") } /* end else */ @@ -348,13 +340,13 @@ H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) HDassert(H5B2_UPDATE_UNKNOWN != status); /* Use insert algorithm if nodes to leaf full */ - if(H5B2_UPDATE_INSERT_CHILD_FULL == status) { - if(H5B2__insert(hdr, udata) < 0) + if (H5B2_UPDATE_INSERT_CHILD_FULL == status) { + if (H5B2__insert(hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") } /* end if */ - else if(H5B2_UPDATE_SHADOW_DONE == status || H5B2_UPDATE_INSERT_DONE == status) { + else if (H5B2_UPDATE_SHADOW_DONE == status || H5B2_UPDATE_INSERT_DONE == status) { /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") } /* end else-if */ else { @@ -366,7 +358,6 @@ H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_update() */ - /*------------------------------------------------------------------------- * Function: H5B2_get_addr * @@ -396,7 +387,6 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5B2_iterate * @@ -416,8 +406,8 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p) herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -432,15 +422,14 @@ H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) hdr = bt2->hdr; /* Iterate through records */ - if(hdr->root.node_nrec > 0) + if (hdr->root.node_nrec > 0) /* Iterate through nodes */ - if((ret_value = H5B2__iterate_node(hdr, hdr->depth, &hdr->root, hdr, op, op_data)) < 0) + if ((ret_value = H5B2__iterate_node(hdr, hdr->depth, &hdr->root, hdr, op, op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate() */ - /*------------------------------------------------------------------------- * Function: H5B2_find * @@ -466,14 +455,14 @@ 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_node_ptr_t curr_node_ptr; /* Node pointer info for 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 */ - H5B2_nodepos_t curr_pos; /* Position of the current node */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + uint16_t depth; /* Current depth of the tree */ + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + H5B2_nodepos_t curr_pos; /* Position of the current node */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -490,83 +479,87 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) curr_node_ptr = hdr->root; /* Check for empty tree */ - if(curr_node_ptr.node_nrec == 0) + if (curr_node_ptr.node_nrec == 0) HGOTO_DONE(FALSE) /* Check record against min & max records in tree, to attempt to quickly * find candidates or avoid further searching. */ - if(hdr->min_native_rec != NULL) { - if((hdr->cls->compare)(udata, hdr->min_native_rec, &cmp) < 0) + if (hdr->min_native_rec != NULL) { + if ((hdr->cls->compare)(udata, hdr->min_native_rec, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp < 0) - HGOTO_DONE(FALSE) /* Less than the least record--not found */ - else if(cmp == 0) { /* Record is found */ - if(op && (op)(hdr->min_native_rec, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ - if(hdr->max_native_rec != NULL) { - if((hdr->cls->compare)(udata, hdr->max_native_rec, &cmp) < 0) + if (cmp < 0) + HGOTO_DONE(FALSE) /* Less than the least record--not found */ + else if (cmp == 0) { /* Record is found */ + if (op && (op)(hdr->min_native_rec, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ + if (hdr->max_native_rec != NULL) { + if ((hdr->cls->compare)(udata, hdr->max_native_rec, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) - HGOTO_DONE(FALSE) /* Less than the least record--not found */ - else if(cmp == 0) { /* Record is found */ - if(op && (op)(hdr->max_native_rec, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + if (cmp > 0) + HGOTO_DONE(FALSE) /* Less than the least record--not found */ + else if (cmp == 0) { /* Record is found */ + if (op && (op)(hdr->max_native_rec, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Walk down B-tree to find record or leaf node where record is located */ - cmp = -1; + cmp = -1; curr_pos = H5B2_POS_ROOT; - while(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ - next_node_ptr=internal->node_ptrs[idx]; + next_node_ptr = internal->node_ptrs[idx]; /* Set the position of the next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_LEFT; else curr_pos = H5B2_POS_MIDDLE; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_RIGHT; else curr_pos = H5B2_POS_MIDDLE; @@ -576,11 +569,12 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -588,16 +582,18 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ else { /* Make callback for current record */ - if(op && (op)(H5B2_INT_NREC(internal, hdr, idx), op_data) < 0) { + if (op && (op)(H5B2_INT_NREC(internal, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Indicate record found */ @@ -609,29 +605,30 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < + 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp != 0) { + if (cmp != 0) { /* Unlock leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Record not found */ @@ -639,52 +636,54 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) } /* end if */ else { /* Make callback for current record */ - if(op && (op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { + if (op && (op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Check for record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_find() */ - /*------------------------------------------------------------------------- * Function: H5B2_index * @@ -703,14 +702,13 @@ 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_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_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void *parent = NULL; /* Parent of current node */ - uint16_t depth; /* Current depth of the tree */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint16_t depth; /* Current depth of the tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -728,54 +726,57 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, curr_node_ptr = hdr->root; /* Check for empty tree */ - if(curr_node_ptr.node_nrec == 0) + if (curr_node_ptr.node_nrec == 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Check for index greater than the number of records in the tree */ - if(idx >= curr_node_ptr.all_nrec) + if (idx >= curr_node_ptr.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records") /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Check for reverse indexing and map requested index to appropriate forward index */ - if(order == H5_ITER_DEC) + if (order == H5_ITER_DEC) idx = curr_node_ptr.all_nrec - (idx + 1); /* Walk down B-tree to find record or leaf node where record is located */ - while(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ - unsigned u; /* Local index variable */ + while (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + unsigned u; /* Local index variable */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Search for record with correct index */ - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Check if record is in child node */ - if(internal->node_ptrs[u].all_nrec > idx) { + if (internal->node_ptrs[u].all_nrec > idx) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[u]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -786,18 +787,21 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end if */ /* Check if record is in this node */ - if(internal->node_ptrs[u].all_nrec == idx) { + if (internal->node_ptrs[u].all_nrec == idx) { /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, u), op_data) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, u), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_DONE(SUCCEED); @@ -810,18 +814,20 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end for */ /* Check last node pointer */ - if(u == internal->nrec) { + if (u == internal->nrec) { /* Check if record is in child node */ - if(internal->node_ptrs[u].all_nrec > idx) { + if (internal->node_ptrs[u].all_nrec > idx) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[u]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -837,15 +843,15 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ @@ -854,30 +860,29 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, HDassert(idx < leaf->nrec); /* Make callback for correct record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_index() */ - /*------------------------------------------------------------------------- * Function: H5B2_remove * @@ -893,8 +898,8 @@ H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, herr_t H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -908,34 +913,35 @@ H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) hdr = bt2->hdr; /* Check for empty B-tree */ - if(0 == hdr->root.all_nrec) + if (0 == hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Attempt to remove record from B-tree */ - if(hdr->depth > 0) { - hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ + if (hdr->depth > 0) { + hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ - if(H5B2__remove_internal(hdr, &depth_decreased, NULL, NULL, - hdr->depth, &(hdr->cache_info), NULL, H5B2_POS_ROOT, &hdr->root, - udata, op, op_data) < 0) + if (H5B2__remove_internal(hdr, &depth_decreased, NULL, NULL, hdr->depth, &(hdr->cache_info), NULL, + H5B2_POS_ROOT, &hdr->root, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") /* Check for decreasing the depth of the B-tree */ - if(depth_decreased) { + if (depth_decreased) { /* Destroy free list factories for previous depth */ - if(hdr->node_info[hdr->depth].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[hdr->depth].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + if (hdr->node_info[hdr->depth].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[hdr->depth].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ - } /* end if */ + } /* end if */ else { - if(H5B2__remove_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) + if (H5B2__remove_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ @@ -943,14 +949,13 @@ H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) hdr->root.all_nrec--; /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_remove() */ - /*------------------------------------------------------------------------- * Function: H5B2_remove_by_idx * @@ -964,11 +969,10 @@ H5B2_remove(H5B2_t *bt2, void *udata, H5B2_remove_t op, void *op_data) *------------------------------------------------------------------------- */ herr_t -H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, - H5B2_remove_t op, void *op_data) +H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -982,42 +986,43 @@ H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, hdr = bt2->hdr; /* Check for empty B-tree */ - if(0 == hdr->root.all_nrec) + if (0 == hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Check for index greater than the number of records in the tree */ - if(idx >= hdr->root.all_nrec) + if (idx >= hdr->root.all_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree doesn't have that many records") /* Check for reverse indexing and map requested index to appropriate forward index */ - if(H5_ITER_DEC == order) + if (H5_ITER_DEC == order) idx = hdr->root.all_nrec - (idx + 1); /* Attempt to remove record from B-tree */ - if(hdr->depth > 0) { - hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ + if (hdr->depth > 0) { + hbool_t depth_decreased = FALSE; /* Flag to indicate whether the depth of the B-tree decreased */ - if(H5B2__remove_internal_by_idx(hdr, &depth_decreased, NULL, NULL, - hdr->depth, &(hdr->cache_info), NULL, &hdr->root, H5B2_POS_ROOT, - idx, op, op_data) < 0) + if (H5B2__remove_internal_by_idx(hdr, &depth_decreased, NULL, NULL, hdr->depth, &(hdr->cache_info), + NULL, &hdr->root, H5B2_POS_ROOT, idx, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") /* Check for decreasing the depth of the B-tree */ - if(depth_decreased) { + if (depth_decreased) { /* Destroy free list factories for previous depth */ - if(hdr->node_info[hdr->depth].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[hdr->depth].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + if (hdr->node_info[hdr->depth].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[hdr->depth].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[hdr->depth].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") HDassert((uint16_t)(hdr->depth - depth_decreased) < hdr->depth); hdr->depth = (uint16_t)(hdr->depth - depth_decreased); } /* end for */ - } /* end if */ + } /* end if */ else { - if(H5B2__remove_leaf_by_idx(hdr, &hdr->root, H5B2_POS_ROOT, hdr, (unsigned)idx, op, op_data) < 0) + if (H5B2__remove_leaf_by_idx(hdr, &hdr->root, H5B2_POS_ROOT, hdr, (unsigned)idx, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ @@ -1025,14 +1030,13 @@ H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, hdr->root.all_nrec--; /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2_get_nrec * @@ -1060,7 +1064,6 @@ H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_get_nrec() */ - /*------------------------------------------------------------------------- * Function: H5B2_neighbor * @@ -1086,11 +1089,10 @@ H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec) *------------------------------------------------------------------------- */ herr_t -H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, - H5B2_found_t op, void *op_data) +H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1105,16 +1107,17 @@ H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, hdr = bt2->hdr; /* Check for empty tree */ - if(!H5F_addr_defined(hdr->root.addr)) + if (!H5F_addr_defined(hdr->root.addr)) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Attempt to find neighbor record in B-tree */ - if(hdr->depth > 0) { - if(H5B2__neighbor_internal(hdr, hdr->depth, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node") + if (hdr->depth > 0) { + if (H5B2__neighbor_internal(hdr, hdr->depth, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "unable to find neighbor record in B-tree internal node") } /* end if */ else { - if(H5B2__neighbor_leaf(hdr, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) + if (H5B2__neighbor_leaf(hdr, &hdr->root, NULL, range, hdr, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node") } /* end else */ @@ -1122,7 +1125,6 @@ H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_neighbor() */ - /*------------------------------------------------------------------------- * Function: H5B2_modify * @@ -1145,14 +1147,14 @@ H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, 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_node_ptr_t curr_node_ptr; /* Node pointer info for 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 */ - unsigned idx; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5B2_nodepos_t curr_pos; /* Position 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1170,59 +1172,61 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) curr_node_ptr = hdr->root; /* Check for empty tree */ - if(0 == curr_node_ptr.node_nrec) + if (0 == curr_node_ptr.node_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Current depth of the tree */ depth = hdr->depth; /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = hdr; /* Walk down B-tree to find record or leaf node where record is located */ - cmp = -1; + cmp = -1; curr_pos = H5B2_POS_ROOT; - while(depth > 0) { - unsigned internal_flags = H5AC__NO_FLAGS_SET; - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0) { + unsigned internal_flags = H5AC__NO_FLAGS_SET; + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[idx]; /* Set the position of the next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_LEFT; else curr_pos = H5B2_POS_MIDDLE; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) curr_pos = H5B2_POS_RIGHT; else curr_pos = H5B2_POS_MIDDLE; @@ -1232,36 +1236,39 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) } /* end if */ /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ curr_node_ptr = next_node_ptr; } /* end if */ else { - hbool_t changed; /* Whether the 'modify' callback changed the record */ + hbool_t changed; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree find operation") } /* end if */ /* Mark the node as dirty if it changed */ internal_flags |= changed ? H5AC__DIRTIED_FLAG : 0; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_DONE(SUCCEED); @@ -1272,97 +1279,100 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - hbool_t changed = FALSE;/* Whether the 'modify' callback changed the record */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) { + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < + 0) { /* Unlock current node before failing */ H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET); HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ - if(cmp != 0) { + if (cmp != 0) { /* Unlock leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - /* Note: don't push error on stack, leave that to next higher level, - * since many times the B-tree is searched in order to determine - * if an object exists in the B-tree or not. -QAK - */ + /* Note: don't push error on stack, leave that to next higher level, + * since many times the B-tree is searched in order to determine + * if an object exists in the B-tree or not. -QAK + */ #ifdef OLD_WAY - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") -#else /* OLD_WAY */ - HGOTO_DONE(FAIL) -#endif /* OLD_WAY */ + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") +#else /* OLD_WAY */ + HGOTO_DONE(FAIL) +#endif /* OLD_WAY */ } /* end if */ else { /* Make callback for current record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree find operation") } /* end if */ /* Check for modified record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Mark the node as dirty if it changed */ leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end block */ done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_modify() */ - /*------------------------------------------------------------------------- * Function: H5B2_close * @@ -1378,9 +1388,9 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) herr_t H5B2_close(H5B2_t *bt2) { - haddr_t bt2_addr = HADDR_UNDEF; /* Address of v2 B-tree (for deletion) */ - hbool_t pending_delete = FALSE; /* Whether the v2 B-tree is pending deletion */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t bt2_addr = HADDR_UNDEF; /* Address of v2 B-tree (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the v2 B-tree is pending deletion */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1389,45 +1399,47 @@ H5B2_close(H5B2_t *bt2) HDassert(bt2->f); /* Decrement file reference & check if this is the last open v2 B-tree using the shared B-tree header */ - if(0 == H5B2__hdr_fuse_decr(bt2->hdr)) { + if (0 == H5B2__hdr_fuse_decr(bt2->hdr)) { /* Set the shared v2 B-tree header's file context for this operation */ bt2->hdr->f = bt2->f; /* Check for pending B-tree deletion */ - if(bt2->hdr->pending_delete) { + if (bt2->hdr->pending_delete) { /* Set local info, so B-tree deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - bt2_addr = bt2->hdr->addr; + bt2_addr = bt2->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending v2 B-tree deletion */ - if(pending_delete) { - H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ + if (pending_delete) { + H5B2_hdr_t *hdr; /* Another pointer to v2 B-tree header */ /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* Check the header's status in the metadata cache */ - if(H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header, address = %llu", (unsigned long long)bt2_addr) - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* Check the header's status in the metadata cache */ + if (H5AC_get_entry_status(bt2->f, bt2_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for v2 B-tree header, address = %llu", + (unsigned long long)bt2_addr) + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = H5B2__hdr_protect(bt2->f, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(bt2->f, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1437,11 +1449,12 @@ H5B2_close(H5B2_t *bt2) /* (don't put in H5B2__hdr_fuse_decr() as the B-tree header may be evicted * immediately -QAK) */ - if(H5B2__hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + if (H5B2__hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared v2 B-tree header") /* Delete v2 B-tree, starting with header (unprotects header) */ - if(H5B2__hdr_delete(hdr) < 0) + if (H5B2__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") } /* end if */ else { @@ -1449,8 +1462,9 @@ H5B2_close(H5B2_t *bt2) /* (don't put in H5B2__hdr_fuse_decr() as the B-tree header may be evicted * immediately -QAK) */ - if(H5B2__hdr_decr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement reference count on shared v2 B-tree header") + if (H5B2__hdr_decr(bt2->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared v2 B-tree header") } /* end else */ @@ -1461,7 +1475,6 @@ H5B2_close(H5B2_t *bt2) FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_close() */ - /*------------------------------------------------------------------------- * Function: H5B2_delete * @@ -1484,11 +1497,10 @@ H5B2_close(H5B2_t *bt2) *------------------------------------------------------------------------- */ herr_t -H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, - void *op_data) +H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data) { - H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1497,35 +1509,34 @@ H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, HDassert(H5F_addr_defined(addr)); /* Lock the v2 B-tree header into memory */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ - hdr->remove_op = op; + hdr->remove_op = op; hdr->remove_op_data = op_data; /* Check for files using shared v2 B-tree header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared v2 B-tree header's file context for this operation */ hdr->f = f; /* Delete v2 B-tree now, starting with header (unprotects header) */ - if(H5B2__hdr_delete(hdr) < 0) + if (H5B2__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree") hdr = NULL; } /* end if */ done: /* Unprotect the header, if an error occurred */ - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_delete() */ - /*------------------------------------------------------------------------- * Function: H5B2_depend * @@ -1543,8 +1554,8 @@ herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) { /* Local variables */ - H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(SUCCEED) @@ -1561,7 +1572,7 @@ H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) * and the v2 B-tree header has already been setup. If it hasn't, then * set it up. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -1569,16 +1580,15 @@ H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent) hdr->f = bt2->f; /* Add the v2 B-tree as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree as child of proxy") - hdr->parent = parent; + hdr->parent = parent; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2_patch_file * @@ -1602,9 +1612,8 @@ H5B2_patch_file(H5B2_t *bt2, H5F_t *f) HDassert(bt2); HDassert(f); - if(bt2->f != f || bt2->hdr->f != f) + if (bt2->f != f || bt2->hdr->f != f) bt2->f = bt2->hdr->f = f; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_patch_file() */ - diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 3b7dd5d3d9d..e333d61f6fb 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,38 +26,33 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* B-tree format version #'s */ -#define H5B2_HDR_VERSION 0 /* Header */ -#define H5B2_INT_VERSION 0 /* Internal node */ -#define H5B2_LEAF_VERSION 0 /* Leaf node */ - +#define H5B2_HDR_VERSION 0 /* Header */ +#define H5B2_INT_VERSION 0 /* Internal node */ +#define H5B2_LEAF_VERSION 0 /* Leaf node */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -65,31 +60,25 @@ /* 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_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); 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_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); 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_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); static herr_t H5B2__cache_leaf_free_icr(void *thing); @@ -99,70 +88,66 @@ static herr_t H5B2__cache_leaf_free_icr(void *thing); /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_HDR[1] = {{ - H5AC_BT2_HDR_ID, /* Metadata client ID */ - "v2 B-tree header", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_HDR_ID, /* Metadata client ID */ + "v2 B-tree header", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ - H5B2__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_hdr_serialize, /* 'serialize' callback */ - H5B2__cache_hdr_notify, /* 'notify' callback */ - H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_hdr_deserialize, /* 'deserialize' callback */ + H5B2__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_hdr_serialize, /* 'serialize' callback */ + H5B2__cache_hdr_notify, /* 'notify' callback */ + H5B2__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_INT[1] = {{ - H5AC_BT2_INT_ID, /* Metadata client ID */ - "v2 B-tree internal node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_INT_ID, /* Metadata client ID */ + "v2 B-tree internal node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_int_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_int_deserialize, /* 'deserialize' callback */ - H5B2__cache_int_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_int_serialize, /* 'serialize' callback */ - H5B2__cache_int_notify, /* 'notify' callback */ - H5B2__cache_int_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_int_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_int_deserialize, /* 'deserialize' callback */ + H5B2__cache_int_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_int_serialize, /* 'serialize' callback */ + H5B2__cache_int_notify, /* 'notify' callback */ + H5B2__cache_int_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5B2 inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ - H5AC_BT2_LEAF_ID, /* Metadata client ID */ - "v2 B-tree leaf node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_BT2_LEAF_ID, /* Metadata client ID */ + "v2 B-tree leaf node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5B2__cache_leaf_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ - H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ - H5B2__cache_leaf_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B2__cache_leaf_serialize, /* 'serialize' callback */ - H5B2__cache_leaf_notify, /* 'notify' callback */ - H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5B2__cache_leaf_verify_chksum, /* 'verify_chksum' callback */ + H5B2__cache_leaf_deserialize, /* 'deserialize' callback */ + H5B2__cache_leaf_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B2__cache_leaf_serialize, /* 'serialize' callback */ + H5B2__cache_leaf_notify, /* 'notify' callback */ + H5B2__cache_leaf_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_get_initial_load_size * @@ -193,7 +178,6 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_verify_chksum * @@ -210,10 +194,10 @@ H5B2__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -223,13 +207,12 @@ H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_deserialize * @@ -244,17 +227,17 @@ H5B2__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +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 */ + 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 */ FUNC_ENTER_STATIC @@ -263,21 +246,21 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new B-tree header and reset cache info */ - if(NULL == (hdr = H5B2__hdr_alloc(udata->f))) + if (NULL == (hdr = H5B2__hdr_alloc(udata->f))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header") /* Magic number */ - if(HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") + if (HDmemcmp(image, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_HDR_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") + if (*image++ != H5B2_HDR_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") /* B-tree class */ id = (H5B2_subid_t)*image++; - if(id >= H5B2_NUM_BTREE_ID) + if (id >= H5B2_NUM_BTREE_ID) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Node size (in bytes) */ @@ -308,7 +291,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Initialize B-tree header info */ cparam.cls = H5B2_client_class_g[id]; - if(H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) + if (H5B2__hdr_init(hdr, &cparam, udata->ctx_udata, depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info") /* Set the B-tree header's address */ @@ -321,14 +304,13 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = hdr; done: - if(!ret_value && hdr) - if(H5B2__hdr_free(hdr) < 0) + if (!ret_value && hdr) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_image_len * @@ -344,7 +326,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, static herr_t H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ + const H5B2_hdr_t *hdr = (const H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ FUNC_ENTER_STATIC_NOERR @@ -358,7 +340,6 @@ H5B2__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_serialize * @@ -372,12 +353,11 @@ 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 H5_ATTR_UNUSED len, - void *_thing) +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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ FUNC_ENTER_STATIC_NOERR @@ -429,7 +409,6 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_notify * @@ -445,8 +424,8 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -456,14 +435,14 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { - switch(action) { + if (hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: - /* do nothing */ + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Increment the shadow epoch, forcing new modifications to * internal and leaf nodes to create new shadow copies */ hdr->shadow_epoch++; @@ -475,39 +454,43 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ + /* do nothing */ break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* Destroy flush dependency on object header proxy */ - if(H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between v2 B-tree and proxy") + /* Destroy flush dependency on object header proxy */ + if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, + (void *)hdr->top_proxy) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between v2 B-tree and proxy") hdr->parent = NULL; - } /* end if */ + } /* end if */ /* Detach from 'top' proxy for extensible array */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") + if (hdr->top_proxy) { + if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and v2 B-tree 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ - break; + break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); @@ -515,7 +498,6 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_hdr_free_icr * @@ -532,7 +514,7 @@ H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5B2__cache_hdr_free_icr(void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -540,14 +522,13 @@ H5B2__cache_hdr_free_icr(void *thing) HDassert(thing); /* Destroy v2 B-tree header */ - if(H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) + if (H5B2__hdr_free((H5B2_hdr_t *)thing) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_get_initial_load_size * @@ -578,7 +559,6 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_verify_chksum * @@ -595,12 +575,12 @@ 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 */ - 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 */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -609,18 +589,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi HDassert(udata); /* Internal node prefix header + records + child pointer triplets: size with checksum at the end */ - chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); + chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth)); /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_deserialize * @@ -635,18 +615,18 @@ H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, voi *------------------------------------------------------------------------- */ static void * -H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_internal_t *ret_value = NULL; /* Return value */ - int node_nrec = 0; + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned u; /* Local index variable */ + H5B2_internal_t * ret_value = NULL; /* Return value */ + int node_nrec = 0; FUNC_ENTER_STATIC @@ -655,48 +635,52 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new internal node and reset cache info */ - if(NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree information */ - internal->hdr = udata->hdr; - internal->parent = udata->parent; + internal->hdr = udata->hdr; + internal->parent = udata->parent; internal->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_INT_VERSION) + if (*image++ != H5B2_INT_VERSION) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal native keys") + if (NULL == + (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal native keys") /* Allocate space for the node pointers in memory */ - if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal node pointers") + if (NULL == (internal->node_ptrs = + (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for B-tree internal node pointers") /* Set the number of records in the leaf & it's depth */ - internal->nrec = udata->nrec; + internal->nrec = udata->nrec; internal->depth = udata->depth; /* Deserialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -706,13 +690,14 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, /* Deserialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Decode node pointer */ H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size); H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int); - if(udata->depth > 1) - UINT64DECODE_VAR(image, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) + if (udata->depth > 1) + UINT64DECODE_VAR(image, int_node_ptr->all_nrec, + udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) else int_node_ptr->all_nrec = int_node_ptr->node_nrec; @@ -732,14 +717,13 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = internal; done: - if(!ret_value && internal) - if(H5B2__internal_free(internal) < 0) + if (!ret_value && internal) + if (H5B2__internal_free(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_image_len * @@ -755,7 +739,8 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, static herr_t H5B2__cache_int_image_len(const void *_thing, size_t *image_len) { - const H5B2_internal_t *internal = (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ + const H5B2_internal_t *internal = + (const H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ FUNC_ENTER_STATIC_NOERR @@ -770,7 +755,6 @@ H5B2__cache_int_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_int_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_serialize * @@ -784,16 +768,15 @@ 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 H5_ATTR_UNUSED len, - void *_thing) +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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -817,9 +800,9 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize records for internal node */ native = internal->int_native; - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Encode record */ - if((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) + if ((internal->hdr->cls->encode)(image, native, internal->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -829,12 +812,13 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Serialize node pointers for internal node */ int_node_ptr = internal->node_ptrs; - for(u = 0; u < (unsigned)(internal->nrec + 1); u++) { + for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Encode node pointer */ H5F_addr_encode(f, &image, int_node_ptr->addr); UINT64ENCODE_VAR(image, int_node_ptr->node_nrec, internal->hdr->max_nrec_size); - if(internal->depth > 1) - UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); + if (internal->depth > 1) + UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, + internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size); /* Move to next node pointer */ int_node_ptr++; @@ -856,7 +840,6 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_notify * @@ -872,8 +855,8 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -884,34 +867,36 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) HDassert(internal->hdr); /* Check if the file was opened with SWMR-write access */ - if(internal->hdr->swmr_write) { - switch(action) { + if (internal->hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(internal->top_proxy) { - if(H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + if (internal->top_proxy) { + if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between internal node and v2 B-tree " + "'top' proxy") internal->top_proxy = NULL; } /* end if */ break; @@ -919,11 +904,11 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == internal->top_proxy); @@ -931,7 +916,6 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_int_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_int_free_icr * @@ -948,8 +932,8 @@ H5B2__cache_int_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5B2__cache_int_free_icr(void *_thing) { - H5B2_internal_t *internal = (H5B2_internal_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = (H5B2_internal_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -957,14 +941,13 @@ H5B2__cache_int_free_icr(void *_thing) HDassert(internal); /* Release v2 B-tree internal node */ - if(H5B2__internal_free(internal) < 0) + if (H5B2__internal_free(internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_get_initial_load_size * @@ -995,7 +978,6 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_verify_chksum * @@ -1012,12 +994,12 @@ 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 */ - 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 */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1031,13 +1013,12 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_deserialize * @@ -1052,16 +1033,16 @@ H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ static void * -H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, + 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned u; /* Local index variable */ - H5B2_leaf_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -1070,43 +1051,43 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, HDassert(udata); /* Allocate new leaf node and reset cache info */ - if(NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") + if (NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(udata->hdr) < 0) + if (H5B2__hdr_incr(udata->hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ - leaf->hdr = udata->hdr; - leaf->parent = udata->parent; + leaf->hdr = udata->hdr; + leaf->parent = udata->parent; leaf->shadow_epoch = udata->hdr->shadow_epoch; /* Magic number */ - if(HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") + if (HDmemcmp(image, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree leaf node signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5B2_LEAF_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") + if (*image++ != H5B2_LEAF_VERSION) + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree leaf node version") /* B-tree type */ - if(*image++ != (uint8_t)udata->hdr->cls->id) + if (*image++ != (uint8_t)udata->hdr->cls->id) HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ - if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") + if (NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree leaf native keys") /* Set the number of records in the leaf */ leaf->nrec = udata->nrec; /* Deserialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) + if ((udata->hdr->cls->decode)(image, native, udata->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -1129,14 +1110,13 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, ret_value = leaf; done: - if(!ret_value && leaf) - if(H5B2__leaf_free(leaf) < 0) + if (!ret_value && leaf) + if (H5B2__leaf_free(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_image_len * @@ -1152,7 +1132,7 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, static herr_t H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) { - const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ + const H5B2_leaf_t *leaf = (const H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ FUNC_ENTER_STATIC_NOERR @@ -1167,7 +1147,6 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__cache_leaf_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_serialize * @@ -1182,14 +1161,14 @@ H5B2__cache_leaf_image_len(const void *_thing, size_t *image_len) */ static herr_t H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing) + 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1213,9 +1192,9 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H /* Serialize records for leaf node */ native = leaf->leaf_native; - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Encode record */ - if((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) + if ((leaf->hdr->cls->encode)(image, native, leaf->hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record") /* Move to next record */ @@ -1224,7 +1203,8 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H } /* end for */ /* Compute metadata checksum */ - metadata_chksum = H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); + metadata_chksum = + H5_checksum_metadata(_image, (size_t)((const uint8_t *)image - (const uint8_t *)_image), 0); /* Metadata checksum */ UINT32ENCODE(image, metadata_chksum); @@ -1239,7 +1219,6 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_notify * @@ -1255,8 +1234,8 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1267,16 +1246,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) HDassert(leaf->hdr); /* Check if the file was opened with SWMR-write access */ - if(leaf->hdr->swmr_write) { - switch(action) { + if (leaf->hdr->swmr_write) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -1287,14 +1266,16 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) + /* Destroy flush dependency on parent */ + if (H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for v2 B-tree */ - if(leaf->top_proxy) { - if(H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + if (leaf->top_proxy) { + if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) + HGOTO_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") leaf->top_proxy = NULL; } /* end if */ break; @@ -1302,11 +1283,11 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == leaf->top_proxy); @@ -1314,7 +1295,6 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_leaf_notify() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_leaf_free_icr * @@ -1331,8 +1311,8 @@ H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5B2__cache_leaf_free_icr(void *_thing) { - H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1340,10 +1320,9 @@ H5B2__cache_leaf_free_icr(void *_thing) HDassert(leaf); /* Destroy v2 B-tree leaf node */ - if(H5B2__leaf_free(leaf) < 0) + if (H5B2__leaf_free(leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_free_icr() */ - diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 0d93ed6c201..711b2005ec4 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_debug * @@ -86,12 +78,12 @@ */ herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B2_class_t H5_ATTR_NDEBUG_UNUSED *type, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) + const H5B2_class_t H5_ATTR_NDEBUG_UNUSED *type, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t *hdr = NULL; /* B-tree header info */ - unsigned u; /* Local index variable */ - char temp_str[128]; /* Temporary string, for formatting */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* B-tree header info */ + unsigned u; /* Local index variable */ + char temp_str[128]; /* Temporary string, for formatting */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -107,7 +99,7 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(type); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -119,53 +111,38 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - hdr->cache_info.is_dirty ? "True" : "False"); + "Dirty flag:", hdr->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Depth:", hdr->depth); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of records in tree:", hdr->root.all_nrec); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Depth:", - hdr->depth); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of records in tree:", - hdr->root.all_nrec); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in root node:", - hdr->root.node_nrec); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of root node:", - hdr->root.addr); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Split percent:", - hdr->split_percent); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Merge percent:", - hdr->merge_percent); + "Number of records in root node:", hdr->root.node_nrec); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Address of root node:", hdr->root.addr); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Split percent:", hdr->split_percent); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Merge percent:", hdr->merge_percent); /* Print relevant node info */ HDfprintf(stream, "%*sNode Info: (max_nrec/split_nrec/merge_nrec)\n", indent, ""); - for(u = 0; u < (unsigned)(hdr->depth + 1); u++) { + for (u = 0; u < (unsigned)(hdr->depth + 1); u++) { HDsnprintf(temp_str, sizeof(temp_str), "Depth %u:", u); - HDfprintf(stream, "%*s%-*s (%u/%u/%u)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - hdr->node_info[u].max_nrec, hdr->node_info[u].split_nrec, hdr->node_info[u].merge_nrec); + HDfprintf(stream, "%*s%-*s (%u/%u/%u)\n", indent + 3, "", MAX(0, fwidth - 3), temp_str, + hdr->node_info[u].max_nrec, hdr->node_info[u].split_nrec, hdr->node_info[u].merge_nrec); } /* end for */ done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__int_debug * @@ -179,15 +156,15 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ 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__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_internal_t *internal = NULL; /* B-tree internal 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 */ - herr_t ret_value=SUCCEED; /* Return value */ + 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 */ + char temp_str[128]; /* Temporary string, for formatting */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -205,7 +182,7 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrec > 0); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -217,7 +194,8 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_CHECK_OVERFLOW(depth, unsigned, uint16_t); node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) - if(NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") /* Print opening message */ @@ -226,57 +204,46 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - internal->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in node:", - internal->nrec); + "Dirty flag:", internal->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of records in node:", internal->nrec); /* Print all node pointers and records */ - for(u = 0; u < internal->nrec; u++) { + for (u = 0; u < internal->nrec; u++) { /* Print node pointer */ HDsnprintf(temp_str, sizeof(temp_str), "Node pointer #%u: (all/node/addr)", u); - HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - internal->node_ptrs[u].all_nrec, - internal->node_ptrs[u].node_nrec, + HDfprintf(stream, "%*s%-*s (%" PRIuHSIZE "/%u/%" PRIuHADDR ")\n", indent + 3, "", MAX(0, fwidth - 3), + temp_str, internal->node_ptrs[u].all_nrec, internal->node_ptrs[u].node_nrec, internal->node_ptrs[u].addr); /* Print record */ HDsnprintf(temp_str, sizeof(temp_str), "Record #%u:", u); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_INT_NREC(internal, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), hdr->cb_ctx); + (void)(type->debug)(stream, indent + 6, MAX(0, fwidth - 6), H5B2_INT_NREC(internal, hdr, u), + hdr->cb_ctx); } /* end for */ /* Print final node pointer */ HDsnprintf(temp_str, sizeof(temp_str), "Node pointer #%u: (all/node/addr)", u); - HDfprintf(stream, "%*s%-*s (%Hu/%u/%a)\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str, - internal->node_ptrs[u].all_nrec, - internal->node_ptrs[u].node_nrec, + HDfprintf(stream, "%*s%-*s (%" PRIuHSIZE "/%u/%" PRIuHADDR ")\n", indent + 3, "", MAX(0, fwidth - 3), + temp_str, internal->node_ptrs[u].all_nrec, internal->node_ptrs[u].node_nrec, internal->node_ptrs[u].addr); done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") - if(internal && H5AC_unprotect(f, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (internal && H5AC_unprotect(f, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__int_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__leaf_debug * @@ -290,15 +257,15 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ 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__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_node_ptr_t node_ptr; /* Fake node pointer for protect */ - unsigned u; /* Local index variable */ - char temp_str[128]; /* Temporary string, for formatting */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -316,7 +283,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrec > 0); /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5B2__hdr_protect(f, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -328,7 +295,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_CHECK_OVERFLOW(nrec, unsigned, uint16_t); node_ptr.addr = addr; H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) - if(NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Print opening message */ @@ -337,37 +304,30 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of node:", - (unsigned)hdr->node_size); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, + (unsigned)hdr->cls->id); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of node:", (unsigned)hdr->node_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + "Size of raw (disk) record:", (unsigned)hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - leaf->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of records in node:", - leaf->nrec); + "Dirty flag:", leaf->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of records in node:", leaf->nrec); /* Print all node pointers and records */ - for(u = 0; u < leaf->nrec; u++) { + for (u = 0; u < leaf->nrec; u++) { /* Print record */ HDsnprintf(temp_str, sizeof(temp_str), "Record #%u:", u); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_LEAF_NREC(leaf, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), hdr->cb_ctx); + (void)(type->debug)(stream, indent + 6, MAX(0, fwidth - 6), H5B2_LEAF_NREC(leaf, hdr, u), + hdr->cb_ctx); } /* end for */ done: - if(hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - if(leaf && H5AC_unprotect(f, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (leaf && H5AC_unprotect(f, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__leaf_debug() */ - diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 7b8b564d997..bdde5ba2873 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,26 +26,24 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Number of records that fit into leaf node */ -#define H5B2_NUM_LEAF_REC(n, r) \ - (((n) - H5B2_LEAF_PREFIX_SIZE) / (r)) +#define H5B2_NUM_LEAF_REC(n, r) (((n)-H5B2_LEAF_PREFIX_SIZE) / (r)) /* Uncomment this macro to enable extra sanity checking */ /* #define H5B2_DEBUG */ @@ -54,27 +52,22 @@ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -91,8 +84,6 @@ H5FL_SEQ_DEFINE_STATIC(size_t); /* Declare a free list to manage the 'H5B2_node_info_t' sequence information */ H5FL_SEQ_DEFINE(H5B2_node_info_t); - - /*------------------------------------------------------------------------- * Function: H5B2__hdr_init * @@ -106,13 +97,12 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); *------------------------------------------------------------------------- */ herr_t -H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, - uint16_t depth) +H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth) { - size_t sz_max_nrec; /* Temporary variable for range checking */ - unsigned u_max_nrec_size; /* Temporary variable for range checking */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t sz_max_nrec; /* Temporary variable for range checking */ + unsigned u_max_nrec_size; /* Temporary variable for range checking */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -123,7 +113,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, HDassert(cparam); HDassert(cparam->cls); HDassert((cparam->cls->crt_context && cparam->cls->dst_context) || - (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); + (NULL == cparam->cls->crt_context && NULL == cparam->cls->dst_context)); HDassert(cparam->node_size > 0); HDassert(cparam->rrec_size > 0); HDassert(cparam->merge_percent > 0 && cparam->merge_percent <= 100); @@ -136,40 +126,41 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, /* Assign user's information */ hdr->split_percent = cparam->split_percent; hdr->merge_percent = cparam->merge_percent; - hdr->node_size = cparam->node_size; - hdr->rrec_size = cparam->rrec_size; + hdr->node_size = cparam->node_size; + hdr->rrec_size = cparam->rrec_size; /* Assign common type information */ hdr->cls = cparam->cls; /* Allocate "page" for node I/O */ - if(NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) + if (NULL == (hdr->page = H5FL_BLK_MALLOC(node_page, hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(hdr->page, 0, hdr->node_size); /* Allocate array of node info structs */ - if(NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) + if (NULL == (hdr->node_info = H5FL_SEQ_MALLOC(H5B2_node_info_t, (size_t)(hdr->depth + 1)))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); H5_CHECKED_ASSIGN(hdr->node_info[0].max_nrec, unsigned, sz_max_nrec, size_t) - hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100; - hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; + hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100; + hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100; + hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; - if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) + if (NULL == + (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ /* (uses leaf # of records because its the largest) */ - if(NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) + if (NULL == (hdr->nat_off = H5FL_SEQ_MALLOC(size_t, (size_t)hdr->node_info[0].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize offsets in native key block */ /* (uses leaf # of records because its the largest) */ - for(u = 0; u < hdr->node_info[0].max_nrec; u++) + for (u = 0; u < hdr->node_info[0].max_nrec; u++) hdr->nat_off[u] = hdr->cls->nrec_size * u; /* Compute size to store # of records in each node */ @@ -179,8 +170,8 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, HDassert(hdr->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE); /* Initialize internal node info */ - if(depth > 0) { - for(u = 1; u < (unsigned)(depth + 1); u++) { + if (depth > 0) { + for (u = 1; u < (unsigned)(depth + 1); u++) { sz_max_nrec = H5B2_NUM_INT_REC(hdr, u); H5_CHECKED_ASSIGN(hdr->node_info[u].max_nrec, unsigned, sz_max_nrec, size_t) HDassert(hdr->node_info[u].max_nrec <= hdr->node_info[u - 1].max_nrec); @@ -188,39 +179,42 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, hdr->node_info[u].split_nrec = (hdr->node_info[u].max_nrec * hdr->split_percent) / 100; hdr->node_info[u].merge_nrec = (hdr->node_info[u].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[u].cum_max_nrec = ((hdr->node_info[u].max_nrec + 1) * - hdr->node_info[u - 1].cum_max_nrec) + hdr->node_info[u].max_nrec; + hdr->node_info[u].cum_max_nrec = + ((hdr->node_info[u].max_nrec + 1) * hdr->node_info[u - 1].cum_max_nrec) + + hdr->node_info[u].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[u].cum_max_nrec); H5_CHECKED_ASSIGN(hdr->node_info[u].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) - if(NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) + if (NULL == (hdr->node_info[u].nat_rec_fac = + H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") - if(NULL == (hdr->node_info[u].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + if (NULL == (hdr->node_info[u].node_ptr_fac = + H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[u].max_nrec + 1)))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, + "can't create internal 'branch' node node pointer block factory") } /* end for */ - } /* end if */ + } /* end if */ /* Determine if we are doing SWMR writes. Only enable for data chunks for now. */ - hdr->swmr_write = (H5F_INTENT(hdr->f) & H5F_ACC_SWMR_WRITE) > 0 - && (hdr->cls->id == H5B2_CDSET_ID || hdr->cls->id == H5B2_CDSET_FILT_ID); + hdr->swmr_write = (H5F_INTENT(hdr->f) & H5F_ACC_SWMR_WRITE) > 0 && + (hdr->cls->id == H5B2_CDSET_ID || hdr->cls->id == H5B2_CDSET_FILT_ID); /* Reset the shadow epoch */ hdr->shadow_epoch = 0; /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) - if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) + if (hdr->cls->crt_context) + if (NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") done: - if(ret_value < 0) - if(H5B2__hdr_free(hdr) < 0) + if (ret_value < 0) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free shared v2 B-tree info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_alloc * @@ -236,8 +230,8 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, H5B2_hdr_t * H5B2__hdr_alloc(H5F_t *f) { - 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 @@ -247,15 +241,15 @@ H5B2__hdr_alloc(H5F_t *f) HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header") /* Assign non-zero information */ - hdr->f = f; + hdr->f = f; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); - hdr->hdr_size = H5B2_HEADER_SIZE_HDR(hdr); - hdr->root.addr = HADDR_UNDEF; + hdr->hdr_size = H5B2_HEADER_SIZE_HDR(hdr); + hdr->root.addr = HADDR_UNDEF; /* Set return value */ ret_value = hdr; @@ -265,7 +259,6 @@ H5B2__hdr_alloc(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_create * @@ -281,9 +274,9 @@ H5B2__hdr_alloc(H5F_t *f) haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) { - H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_PACKAGE @@ -294,56 +287,58 @@ H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) HDassert(cparam); /* Allocate v2 B-tree header */ - if(NULL == (hdr = H5B2__hdr_alloc(f))) + if (NULL == (hdr = H5B2__hdr_alloc(f))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ - if(H5B2__hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0) + if (H5B2__hdr_init(hdr, cparam, ctx_udata, (uint16_t)0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)hdr->hdr_size))) + if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)hdr->hdr_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, HADDR_UNDEF, "can't create v2 B-tree proxy") /* Cache the new B-tree node */ - if(H5AC_insert_entry(f, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree 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) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, HADDR_UNDEF, "unable to add v2 B-tree header as child of array proxy") + if (hdr->top_proxy) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, HADDR_UNDEF, + "unable to add v2 B-tree header as child of array proxy") /* Set address of v2 B-tree header to return */ ret_value = hdr->addr; done: - if(!H5F_addr_defined(ret_value)) - if(hdr) { + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, HADDR_UNDEF, "unable to remove v2 B-tree header from cache") + if (inserted) + if (H5AC_remove_entry(hdr) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove v2 B-tree header from cache") /* Release header's disk space */ - if(H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_BTREE, hdr->addr, (hsize_t)hdr->hdr_size) < 0) + if (H5F_addr_defined(hdr->addr) && + H5MF_xfree(f, H5FD_MEM_BTREE, hdr->addr, (hsize_t)hdr->hdr_size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free v2 B-tree header") /* Destroy header */ - if(H5B2__hdr_free(hdr) < 0) + if (H5B2__hdr_free(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release v2 B-tree header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_incr * @@ -359,7 +354,7 @@ H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) herr_t H5B2__hdr_incr(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -367,8 +362,8 @@ H5B2__hdr_incr(H5B2_hdr_t *hdr) HDassert(hdr); /* Mark header as un-evictable when a B-tree node is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTPIN, FAIL, "unable to pin v2 B-tree header") /* Increment reference count on B-tree header */ @@ -378,7 +373,6 @@ H5B2__hdr_incr(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_decr * @@ -394,7 +388,7 @@ H5B2__hdr_incr(H5B2_hdr_t *hdr) herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -406,15 +400,14 @@ H5B2__hdr_decr(H5B2_hdr_t *hdr) hdr->rc--; /* Mark header as evictable again when no nodes depend on it */ - if(hdr->rc == 0) - if(H5AC_unpin_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_unpin_entry(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin v2 B-tree header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_fuse_incr * @@ -441,7 +434,6 @@ H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B2__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_fuse_decr * @@ -469,7 +461,6 @@ H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(hdr->file_rc) } /* end H5B2__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_dirty * @@ -485,7 +476,7 @@ H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr) herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -493,14 +484,13 @@ H5B2__hdr_dirty(H5B2_hdr_t *hdr) HDassert(hdr); /* Mark B-tree header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark v2 B-tree header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_dirty() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_protect * @@ -516,9 +506,9 @@ H5B2__hdr_dirty(H5B2_hdr_t *hdr) 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_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 */ FUNC_ENTER_PACKAGE @@ -530,23 +520,24 @@ H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = hdr_addr; + udata.f = f; + udata.addr = hdr_addr; udata.ctx_udata = ctx_udata; /* Protect the header */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, H5AC_BT2_HDR, hdr_addr, &udata, flags))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + if (NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", + (unsigned long long)hdr_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) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for v2 B-tree entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, NULL, "can't create v2 B-tree proxy") /* Add header as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree header as child of proxy") } /* end if */ @@ -555,16 +546,16 @@ H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the header, if it was protected */ - if(hdr && H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + if (hdr && H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_unprotect * @@ -580,7 +571,7 @@ H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -588,14 +579,14 @@ H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags) HDassert(hdr); /* Unprotect the header */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_free * @@ -611,7 +602,7 @@ H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags) herr_t H5B2__hdr_free(H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -619,32 +610,34 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) HDassert(hdr); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) + if (hdr->cb_ctx) { + if ((*hdr->cls->dst_context)(hdr->cb_ctx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy v2 B-tree client callback context") hdr->cb_ctx = NULL; } /* end if */ /* Free the B-tree node buffer */ - if(hdr->page) + if (hdr->page) hdr->page = H5FL_BLK_FREE(node_page, hdr->page); /* Free the array of offsets into the native key block */ - if(hdr->nat_off) + if (hdr->nat_off) hdr->nat_off = H5FL_SEQ_FREE(size_t, hdr->nat_off); /* Release the node info */ - if(hdr->node_info) { - unsigned u; /* Local index variable */ + if (hdr->node_info) { + unsigned u; /* Local index variable */ /* Destroy free list factories */ - for(u = 0; u < (unsigned)(hdr->depth + 1); u++) { - if(hdr->node_info[u].nat_rec_fac) - if(H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory") - if(hdr->node_info[u].node_ptr_fac) - if(H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory") + for (u = 0; u < (unsigned)(hdr->depth + 1); u++) { + if (hdr->node_info[u].nat_rec_fac) + if (H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, + "can't destroy node's native record block factory") + if (hdr->node_info[u].node_ptr_fac) + if (H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, + "can't destroy node's node pointer block factory") } /* end for */ /* Free the array of node info structs */ @@ -652,14 +645,14 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) } /* end if */ /* Release the min & max record info, if set */ - if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); - if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); + if (hdr->min_native_rec) + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); + if (hdr->max_native_rec) + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to destroy v2 B-tree 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -671,7 +664,6 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_free() */ - /*------------------------------------------------------------------------- * Function: H5B2__hdr_delete * @@ -687,8 +679,8 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting v2 B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting v2 B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -696,22 +688,23 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr) HDassert(hdr); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* v2 B-tree header's status in the metadata cache */ - - /* Check the v2 B-tree header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check metadata cache status for v2 B-tree header") - - /* Sanity checks on v2 B-tree header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + { + unsigned hdr_status = 0; /* v2 B-tree header's status in the metadata cache */ + + /* Check the v2 B-tree header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for v2 B-tree header") + + /* Sanity checks on v2 B-tree header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Delete all nodes in B-tree */ - if(H5F_addr_defined(hdr->root.addr)) - if(H5B2__delete_node(hdr, hdr->depth, &hdr->root, hdr, hdr->remove_op, hdr->remove_op_data) < 0) + if (H5F_addr_defined(hdr->root.addr)) + if (H5B2__delete_node(hdr, hdr->depth, &hdr->root, hdr, hdr->remove_op, hdr->remove_op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to delete B-tree nodes") /* Indicate that the heap header should be deleted & file space freed */ @@ -719,9 +712,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ - if(H5B2__hdr_unprotect(hdr, cache_flags) < 0) + if (H5B2__hdr_unprotect(hdr, cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ - diff --git a/src/H5B2int.c b/src/H5B2int.c index 816d8f8ac96..610da6c5f05 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* 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, + const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, + unsigned end_idx, void *old_parent, void *new_parent); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -79,8 +71,6 @@ static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, /* Declare a free list to manage the 'H5B2_node_info_t' sequence information */ H5FL_SEQ_EXTERN(H5B2_node_info_t); - - /*------------------------------------------------------------------------- * Function: H5B2__locate_record * @@ -102,23 +92,23 @@ H5FL_SEQ_EXTERN(H5B2_node_info_t); *------------------------------------------------------------------------- */ herr_t -H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, - const uint8_t *native, const void *udata, unsigned *idx, int *cmp) +H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, const uint8_t *native, + const void *udata, unsigned *idx, int *cmp) { - unsigned lo = 0, hi; /* Low & high index values */ - unsigned my_idx = 0; /* Final index value */ - herr_t ret_value = SUCCEED; + unsigned lo = 0, hi; /* Low & high index values */ + unsigned my_idx = 0; /* Final index value */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE *cmp = -1; hi = nrec; - while(lo < hi && *cmp) { + while (lo < hi && *cmp) { my_idx = (lo + hi) / 2; - if((type->compare)(udata, native + rec_off[my_idx], cmp) < 0) + if ((type->compare)(udata, native + rec_off[my_idx], cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(*cmp < 0) + if (*cmp < 0) hi = my_idx; else lo = my_idx + 1; @@ -130,7 +120,6 @@ H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__locate_record */ - /*------------------------------------------------------------------------- * Function: H5B2__split1 * @@ -146,19 +135,21 @@ H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, */ herr_t H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right 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 */ - 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 */ - uint16_t old_node_nrec; /* Number of records in internal node split */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint16_t *left_nrec, *right_nrec; /* Pointers to child # of 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 */ + uint16_t old_node_nrec; /* Number of records in internal node split */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -168,68 +159,75 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Slide records in parent node up one space, to make room for promoted record */ - if(idx < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size * (internal->nrec - idx)); - HDmemmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); + if (idx < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size * (internal->nrec - idx)); + HDmemmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); } /* end if */ /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_int = NULL, *right_int = NULL; /* Pointers to old & new internal nodes */ + if (depth > 1) { + H5B2_internal_t *left_int = NULL, *right_int = NULL; /* Pointers to old & new internal nodes */ /* Create new internal node */ internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0; - if(H5B2__create_internal(hdr, internal, &(internal->node_ptrs[idx + 1]), (uint16_t)(depth - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") + if (H5B2__create_internal(hdr, internal, &(internal->node_ptrs[idx + 1]), (uint16_t)(depth - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Protect both leaves */ /* (Shadow left node if doing SWMR writes) */ - if(NULL == (left_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == + (left_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_int = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_int; - right_child = right_int; - left_nrec = &(left_int->nrec); - right_nrec = &(right_int->nrec); - left_native = left_int->int_native; - right_native = right_int->int_native; - left_node_ptrs = left_int->node_ptrs; + left_child = left_int; + right_child = right_int; + left_nrec = &(left_int->nrec); + right_nrec = &(right_int->nrec); + left_native = left_int->int_native; + right_native = right_int->int_native; + left_node_ptrs = left_int->node_ptrs; right_node_ptrs = right_int->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf = NULL, *right_leaf = NULL; /* Pointers to old & new leaf nodes */ + H5B2_leaf_t *left_leaf = NULL, *right_leaf = NULL; /* Pointers to old & new leaf nodes */ /* Create new leaf node */ internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec = 0; - if(H5B2__create_leaf(hdr, internal, &(internal->node_ptrs[idx + 1])) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node") + if (H5B2__create_leaf(hdr, internal, &(internal->node_ptrs[idx + 1])) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node") /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Protect both leaves */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end if */ @@ -241,16 +239,17 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Copy "upper half" of records to new child */ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), - H5B2_NAT_NREC(left_native, hdr, mid_record + (unsigned)1), - hdr->cls->nrec_size * (old_node_nrec - (mid_record + (unsigned)1))); + H5B2_NAT_NREC(left_native, hdr, mid_record + (unsigned)1), + hdr->cls->nrec_size * (old_node_nrec - (mid_record + (unsigned)1))); /* Copy "upper half" of node pointers, if the node is an internal node */ - if(depth > 1) + if (depth > 1) H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[mid_record + (unsigned)1]), - sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record)); + sizeof(H5B2_node_ptr_t) * (size_t)(old_node_nrec - mid_record)); /* Copy "middle" record to internal node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, mid_record), + hdr->cls->nrec_size); /* Mark nodes as dirty */ left_child_flags |= H5AC__DIRTIED_FLAG; @@ -261,25 +260,25 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, internal->node_ptrs[idx + 1].node_nrec = *right_nrec = (uint16_t)(old_node_nrec - (mid_record + 1)); /* Determine total number of records in new child nodes */ - if(depth > 1) { - unsigned u; /* Local index variable */ - hsize_t new_left_all_nrec; /* New total number of records in left child */ - hsize_t new_right_all_nrec; /* New total number of records in right child */ + if (depth > 1) { + unsigned u; /* Local index variable */ + hsize_t new_left_all_nrec; /* New total number of records in left child */ + hsize_t new_right_all_nrec; /* New total number of records in right child */ /* Compute total of all records in each child node */ new_left_all_nrec = internal->node_ptrs[idx].node_nrec; - for(u = 0; u < (*left_nrec + (unsigned)1); u++) + for (u = 0; u < (*left_nrec + (unsigned)1); u++) new_left_all_nrec += left_node_ptrs[u].all_nrec; new_right_all_nrec = internal->node_ptrs[idx + 1].node_nrec; - for(u = 0; u < (*right_nrec + (unsigned)1); u++) + for (u = 0; u < (*right_nrec + (unsigned)1); u++) new_right_all_nrec += right_node_ptrs[u].all_nrec; - internal->node_ptrs[idx].all_nrec = new_left_all_nrec; + internal->node_ptrs[idx].all_nrec = new_left_all_nrec; internal->node_ptrs[idx + 1].all_nrec = new_right_all_nrec; } /* end if */ else { - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ @@ -293,38 +292,39 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec++; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)(*right_nrec + 1), left_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, (unsigned)(*right_nrec + 1), + left_child, right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Release child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split1() */ - /*------------------------------------------------------------------------- * Function: H5B2__split_root * @@ -341,12 +341,12 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, herr_t H5B2__split_root(H5B2_hdr_t *hdr) { - H5B2_internal_t *new_root = NULL; /* Pointer to new root node */ - unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */ - H5B2_node_ptr_t old_root_ptr; /* Old node pointer to root node in B-tree */ - size_t sz_max_nrec; /* Temporary variable for range checking */ - unsigned u_max_nrec_size; /* Temporary variable for range checking */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *new_root = NULL; /* Pointer to new root node */ + unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */ + H5B2_node_ptr_t old_root_ptr; /* Old node pointer to root node in B-tree */ + size_t sz_max_nrec; /* Temporary variable for range checking */ + unsigned u_max_nrec_size; /* Temporary variable for range checking */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -357,7 +357,8 @@ H5B2__split_root(H5B2_hdr_t *hdr) hdr->depth++; /* Re-allocate array of node info structs */ - if(NULL == (hdr->node_info = H5FL_SEQ_REALLOC(H5B2_node_info_t, hdr->node_info, (size_t)(hdr->depth + 1)))) + if (NULL == + (hdr->node_info = H5FL_SEQ_REALLOC(H5B2_node_info_t, hdr->node_info, (size_t)(hdr->depth + 1)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update node info for new depth of tree */ @@ -365,43 +366,47 @@ H5B2__split_root(H5B2_hdr_t *hdr) H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].max_nrec, unsigned, sz_max_nrec, size_t) hdr->node_info[hdr->depth].split_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->split_percent) / 100; hdr->node_info[hdr->depth].merge_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->merge_percent) / 100; - hdr->node_info[hdr->depth].cum_max_nrec = ((hdr->node_info[hdr->depth].max_nrec + 1) * - hdr->node_info[hdr->depth - 1].cum_max_nrec) + hdr->node_info[hdr->depth].max_nrec; + hdr->node_info[hdr->depth].cum_max_nrec = + ((hdr->node_info[hdr->depth].max_nrec + 1) * hdr->node_info[hdr->depth - 1].cum_max_nrec) + + hdr->node_info[hdr->depth].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[hdr->depth].cum_max_nrec); H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) - if(NULL == (hdr->node_info[hdr->depth].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[hdr->depth].max_nrec))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") - if(NULL == (hdr->node_info[hdr->depth].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[hdr->depth].max_nrec + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create internal 'branch' node node pointer block factory") + if (NULL == (hdr->node_info[hdr->depth].nat_rec_fac = + H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[hdr->depth].max_nrec))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + if (NULL == (hdr->node_info[hdr->depth].node_ptr_fac = + H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (hdr->node_info[hdr->depth].max_nrec + 1)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't create internal 'branch' node node pointer block factory") /* Keep old root node pointer info */ old_root_ptr = hdr->root; /* Create new internal node to use as root */ hdr->root.node_nrec = 0; - if(H5B2__create_internal(hdr, hdr, &(hdr->root), hdr->depth) < 0) + if (H5B2__create_internal(hdr, hdr, &(hdr->root), hdr->depth) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node") /* Protect new root node */ - if(NULL == (new_root = H5B2__protect_internal(hdr, hdr, &hdr->root, hdr->depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (new_root = H5B2__protect_internal(hdr, hdr, &hdr->root, hdr->depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set first node pointer in root node to old root node pointer info */ new_root->node_ptrs[0] = old_root_ptr; /* Split original root node */ - if(H5B2__split1(hdr, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0) + if (H5B2__split1(hdr, hdr->depth, &(hdr->root), NULL, new_root, &new_root_flags, 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split old root node") done: /* Release new root node (marked as dirty) */ - if(new_root && H5AC_unprotect(hdr->f, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0) + if (new_root && H5AC_unprotect(hdr->f, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split_root() */ - /*------------------------------------------------------------------------- * Function: H5B2__redistribute2 * @@ -416,18 +421,19 @@ H5B2__split_root(H5B2_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned idx) +H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right 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 */ - H5B2_node_ptr_t *left_node_ptrs = NULL, *right_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 */ + 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 */ + 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 */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -436,115 +442,132 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(internal); /* Check for the kind of B-tree node to redistribute */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock left & right B-tree child nodes */ /* (Shadow both nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock left & right B-tree child nodes */ /* (Shadow both nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end else */ #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ /* Determine whether to shuffle records left or right */ - if(*left_nrec < *right_nrec) { + if (*left_nrec < *right_nrec) { /* Moving record from right node to left */ - uint16_t new_right_nrec = (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for right child */ - uint16_t move_nrec = (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */ + uint16_t new_right_nrec = + (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for right child */ + uint16_t move_nrec = + (uint16_t)(*right_nrec - new_right_nrec); /* Number of records to move from right node to left */ /* Copy record from parent node down into left child */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* See if we need to move records from right node */ - if(move_nrec > 1) - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); + if (move_nrec > 1) + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, (*left_nrec + 1)), + H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from right node into parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), + hdr->cls->nrec_size); /* Slide records in right node down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), hdr->cls->nrec_size * new_right_nrec); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), + hdr->cls->nrec_size * new_right_nrec); /* Handle node pointers, if we have an internal node */ - if(depth > 1) { - hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Count the number of records being moved */ - for(u = 0; u < move_nrec; u++) + for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; H5_CHECKED_ASSIGN(left_moved_nrec, hssize_t, moved_nrec, hsize_t) right_moved_nrec -= (hssize_t)moved_nrec; /* Copy node pointers from right node to left */ - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * move_nrec); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * move_nrec); /* Slide node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); + HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), + sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + move_nrec + 1), right_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + move_nrec + 1), right_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update number of records in child nodes */ - *left_nrec = (uint16_t)(*left_nrec + move_nrec); + *left_nrec = (uint16_t)(*left_nrec + move_nrec); *right_nrec = new_right_nrec; /* Mark nodes as dirty */ @@ -554,53 +577,60 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, else { /* Moving record from left node to right */ - uint16_t new_left_nrec = (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for left child */ - uint16_t move_nrec = (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */ + uint16_t new_left_nrec = + (uint16_t)((*left_nrec + *right_nrec) / 2); /* New number of records for left child */ + uint16_t move_nrec = + (uint16_t)(*left_nrec - new_left_nrec); /* Number of records to move from left node to right */ /* Sanity check */ HDassert(*left_nrec > *right_nrec); /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), - H5B2_NAT_NREC(right_native, hdr, 0), - hdr->cls->nrec_size * (*right_nrec)); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Copy record from parent node down into right child */ - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* See if we need to move records from left node */ - if(move_nrec > 1) - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), hdr->cls->nrec_size * (size_t)(move_nrec - 1)); + if (move_nrec > 1) + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), + H5B2_NAT_NREC(left_native, hdr, ((*left_nrec - move_nrec) + 1)), + hdr->cls->nrec_size * (size_t)(move_nrec - 1)); /* Move record from left node into parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(left_native, hdr, (*left_nrec - move_nrec)), hdr->cls->nrec_size); /* Handle node pointers, if we have an internal node */ - if(depth > 1) { - hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec = move_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide node pointers in right node up */ - HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Copy node pointers from left node to right */ - H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * move_nrec); + H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), + sizeof(H5B2_node_ptr_t) * move_nrec); /* Count the number of records being moved */ - for(u = 0; u < move_nrec; u++) + for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; left_moved_nrec -= (hssize_t)moved_nrec; H5_CHECKED_ASSIGN(right_moved_nrec, hssize_t, moved_nrec, hsize_t) } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)move_nrec, left_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, (unsigned)move_nrec, + left_child, right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update number of records in child nodes */ - *left_nrec = new_left_nrec; + *left_nrec = new_left_nrec; *right_nrec = (uint16_t)(*right_nrec + move_nrec); /* Mark nodes as dirty */ @@ -609,42 +639,45 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end else */ /* Update # of records in child nodes */ - internal->node_ptrs[idx].node_nrec = *left_nrec; + internal->node_ptrs[idx].node_nrec = *left_nrec; internal->node_ptrs[idx + 1].node_nrec = *right_nrec; /* Update total # of records in child B-trees */ - if(depth > 1) { - internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + left_moved_nrec); - internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); + if (depth > 1) { + internal->node_ptrs[idx].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + left_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)left_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)left_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Release child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute2() */ - /*------------------------------------------------------------------------- * Function: H5B2__redistribute3 * @@ -659,25 +692,27 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, *------------------------------------------------------------------------- */ herr_t -H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) +H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - 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 */ - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - haddr_t middle_addr; /* 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 */ - 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 */ - 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, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + 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 */ + 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, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -687,79 +722,88 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to redistribute */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ /* (Shadow all nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_internal; - middle_child = middle_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - middle_nrec = &(middle_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - middle_native = middle_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + middle_child = middle_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + middle_nrec = &(middle_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + middle_native = middle_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; middle_node_ptrs = middle_internal->node_ptrs; - right_node_ptrs = right_internal->node_ptrs; + right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child nodes */ /* (Shadow all nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for child nodes */ - left_child = left_leaf; - middle_child = middle_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - middle_nrec = &(middle_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + middle_child = middle_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + middle_nrec = &(middle_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; middle_native = middle_leaf->leaf_native; - right_native = right_leaf->leaf_native; + right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records */ { /* Compute new # of records in each node */ - unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); uint16_t new_middle_nrec = (uint16_t)((total_nrec - 2) / 3); - uint16_t new_left_nrec = (uint16_t)(((total_nrec - 2) - new_middle_nrec) / 2); - uint16_t new_right_nrec = (uint16_t)((total_nrec - 2) - (unsigned)(new_left_nrec + new_middle_nrec)); + uint16_t new_left_nrec = (uint16_t)(((total_nrec - 2) - new_middle_nrec) / 2); + uint16_t new_right_nrec = (uint16_t)((total_nrec - 2) - (unsigned)(new_left_nrec + new_middle_nrec)); uint16_t curr_middle_nrec = *middle_nrec; /* Sanity check rounding */ @@ -767,49 +811,57 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(new_middle_nrec <= new_right_nrec); /* Move records into left node */ - if(new_left_nrec > *left_nrec) { - uint16_t moved_middle_nrec = 0; /* Number of records moved into left node */ + if (new_left_nrec > *left_nrec) { + uint16_t moved_middle_nrec = 0; /* Number of records moved into left node */ /* Move left parent record down to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), + hdr->cls->nrec_size); /* Move records from middle node into left node */ - if((new_left_nrec - 1) > *left_nrec) { + if ((new_left_nrec - 1) > *left_nrec) { moved_middle_nrec = (uint16_t)(new_left_nrec - (*left_nrec + 1)); - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), + H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * moved_middle_nrec); } /* end if */ /* Move record from middle node up to parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), + H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size); moved_middle_nrec++; /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), + hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned move_nptrs; /* Number of node pointers to move */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned move_nptrs; /* Number of node pointers to move */ + unsigned u; /* Local index variable */ /* Move middle node pointers into left node */ move_nptrs = (unsigned)(new_left_nrec - *left_nrec); - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t)*move_nptrs); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * move_nptrs); /* Count the number of records being moved into the left node */ - for(u = 0, moved_nrec = 0; u < move_nptrs; u++) + for (u = 0, moved_nrec = 0; u < move_nptrs; u++) moved_nrec += middle_node_ptrs[u].all_nrec; left_moved_nrec = (hssize_t)(moved_nrec + move_nptrs); middle_moved_nrec -= (hssize_t)(moved_nrec + move_nptrs); /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); + HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), + sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + moved_middle_nrec + 1), middle_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + moved_middle_nrec + 1), + middle_child, left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -821,44 +873,55 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records into right node */ - if(new_right_nrec > *right_nrec) { - unsigned right_nrec_move = (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ + if (new_right_nrec > *right_nrec) { + unsigned right_nrec_move = + (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Move right parent record down to right node */ - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), + H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* Move records from middle node into right node */ - if(right_nrec_move > 1) - H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), hdr->cls->nrec_size * (right_nrec_move - 1)); + if (right_nrec_move > 1) + H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, 0), + H5B2_NAT_NREC(middle_native, hdr, ((curr_middle_nrec - right_nrec_move) + 1)), + hdr->cls->nrec_size * (right_nrec_move - 1)); /* Move record from middle node up to parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec - right_nrec_move)), + hdr->cls->nrec_size); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide the node pointers in right node up */ - HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Move middle node pointers into right node */ - H5MM_memcpy(&(right_node_ptrs[0]), &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), sizeof(H5B2_node_ptr_t) * right_nrec_move); + H5MM_memcpy(&(right_node_ptrs[0]), + &(middle_node_ptrs[(curr_middle_nrec - right_nrec_move) + 1]), + sizeof(H5B2_node_ptr_t) * right_nrec_move); /* Count the number of records being moved into the right node */ - for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; right_moved_nrec = (hssize_t)(moved_nrec + right_nrec_move); middle_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, - 0, (unsigned)right_nrec_move, middle_child, right_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, right_node_ptrs, 0, + (unsigned)right_nrec_move, middle_child, + right_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -870,44 +933,52 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records out of left node */ - if(new_left_nrec < *left_nrec) { - unsigned left_nrec_move = (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ + if (new_left_nrec < *left_nrec) { + unsigned left_nrec_move = + (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ /* Slide middle records up */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * curr_middle_nrec); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), + hdr->cls->nrec_size * curr_middle_nrec); /* Move left parent record down to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), + H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); /* Move left records to middle node */ - if(left_nrec_move > 1) - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), hdr->cls->nrec_size * (left_nrec_move - 1)); + if (left_nrec_move > 1) + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), + hdr->cls->nrec_size * (left_nrec_move - 1)); /* Move left parent record up from left node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), + hdr->cls->nrec_size); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Slide the node pointers in middle node up */ - HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); + HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); /* Move left node pointers into middle node */ - H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), sizeof(H5B2_node_ptr_t) * left_nrec_move); + H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), + sizeof(H5B2_node_ptr_t) * left_nrec_move); /* Count the number of records being moved into the left node */ - for(u = 0, moved_nrec = 0; u < left_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < left_nrec_move; u++) moved_nrec += middle_node_ptrs[u].all_nrec; left_moved_nrec -= (hssize_t)(moved_nrec + left_nrec_move); middle_moved_nrec += (hssize_t)(moved_nrec + left_nrec_move); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - 0, (unsigned)left_nrec_move, left_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, 0, + (unsigned)left_nrec_move, left_child, middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update the current number of records in middle node */ @@ -919,43 +990,51 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Move records out of right node */ - if(new_right_nrec < *right_nrec) { - unsigned right_nrec_move = (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */ + if (new_right_nrec < *right_nrec) { + unsigned right_nrec_move = + (unsigned)(*right_nrec - new_right_nrec); /* Number of records to move out of right node */ /* Move right parent record down to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, curr_middle_nrec), + H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* Move right records to middle node */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), + H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); /* Move right parent record up from right node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), + H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size); /* Slide right records down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), hdr->cls->nrec_size * new_right_nrec); + HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), + hdr->cls->nrec_size * new_right_nrec); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ - unsigned u; /* Local index variable */ + if (depth > 1) { + hsize_t moved_nrec; /* Total number of records moved, for internal redistrib */ + unsigned u; /* Local index variable */ /* Move right node pointers into middle node */ - H5MM_memcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * right_nrec_move); + H5MM_memcpy(&(middle_node_ptrs[curr_middle_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * right_nrec_move); /* Count the number of records being moved into the right node */ - for(u = 0, moved_nrec = 0; u < right_nrec_move; u++) + for (u = 0, moved_nrec = 0; u < right_nrec_move; u++) moved_nrec += right_node_ptrs[u].all_nrec; right_moved_nrec -= (hssize_t)(moved_nrec + right_nrec_move); middle_moved_nrec += (hssize_t)(moved_nrec + right_nrec_move); /* Slide the node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); + HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - (unsigned)(curr_middle_nrec + 1), (unsigned)(curr_middle_nrec + right_nrec_move + 1), right_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends( + hdr, depth, middle_node_ptrs, (unsigned)(curr_middle_nrec + 1), + (unsigned)(curr_middle_nrec + right_nrec_move + 1), right_child, middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Mark nodes as dirty */ @@ -964,25 +1043,28 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, } /* end if */ /* Update # of records in nodes */ - *left_nrec = new_left_nrec; + *left_nrec = new_left_nrec; *middle_nrec = new_middle_nrec; - *right_nrec = new_right_nrec; + *right_nrec = new_right_nrec; } /* end block */ /* Update # of records in child nodes */ internal->node_ptrs[idx - 1].node_nrec = *left_nrec; - internal->node_ptrs[idx].node_nrec = *middle_nrec; + internal->node_ptrs[idx].node_nrec = *middle_nrec; internal->node_ptrs[idx + 1].node_nrec = *right_nrec; /* Update total # of records in child B-trees */ - if(depth > 1) { - internal->node_ptrs[idx - 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx - 1].all_nrec + left_moved_nrec); - internal->node_ptrs[idx].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + middle_moved_nrec); - internal->node_ptrs[idx + 1].all_nrec = (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); + if (depth > 1) { + internal->node_ptrs[idx - 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx - 1].all_nrec + left_moved_nrec); + internal->node_ptrs[idx].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx].all_nrec + middle_moved_nrec); + internal->node_ptrs[idx + 1].all_nrec = + (hsize_t)((hssize_t)internal->node_ptrs[idx + 1].all_nrec + right_moved_nrec); } /* end if */ else { internal->node_ptrs[idx - 1].all_nrec = internal->node_ptrs[idx - 1].node_nrec; - internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; + internal->node_ptrs[idx].all_nrec = internal->node_ptrs[idx].node_nrec; internal->node_ptrs[idx + 1].all_nrec = internal->node_ptrs[idx + 1].node_nrec; } /* end else */ @@ -991,32 +1073,36 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)middle_child); - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, (H5B2_internal_t *)left_child); - H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, (H5B2_internal_t *)right_child); - H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, (H5B2_internal_t *)middle_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)middle_child); + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, + (H5B2_internal_t *)left_child); + H5B2__assert_internal2(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child, + (H5B2_internal_t *)right_child); + H5B2__assert_internal2(internal->node_ptrs[idx + 1].all_nrec, hdr, (H5B2_internal_t *)right_child, + (H5B2_internal_t *)middle_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)middle_child); H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)middle_child, (H5B2_leaf_t *)right_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)right_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Unlock child nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) + if (middle_child && + H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute3() */ - /*------------------------------------------------------------------------- * Function: H5B2__merge2 * @@ -1033,17 +1119,19 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, */ herr_t H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of 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 */ - 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, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + 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, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1054,73 +1142,83 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock left & right B-tree child nodes */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock left & right B-tree child nodes */ /* (Shadow the left node if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records into left node */ { /* Copy record from parent node to proper location */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* Copy records from right node to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Copy node pointers from right node into left node */ - if(depth > 1) - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + if (depth > 1) + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + *right_nrec + 2), right_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + *right_nrec + 2), right_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in left node */ @@ -1129,7 +1227,7 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Mark nodes as dirty */ left_child_flags |= H5AC__DIRTIED_FLAG; right_child_flags |= H5AC__DELETED_FLAG; - if(!(hdr->swmr_write)) + if (!(hdr->swmr_write)) right_child_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; } /* end block */ @@ -1140,9 +1238,11 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, internal->node_ptrs[idx].all_nrec += internal->node_ptrs[idx + 1].all_nrec + 1; /* Slide records in parent node down, to eliminate demoted record */ - if((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + if ((idx + 1) < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1155,12 +1255,12 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec--; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) + if (depth > 1) H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)left_child); else H5B2__assert_leaf(hdr, (H5B2_leaf_t *)left_child); @@ -1168,17 +1268,16 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, done: /* Unlock left node (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") /* Delete right node & remove from cache (marked as dirty) */ - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge2() */ - /*------------------------------------------------------------------------- * Function: H5B2__merge3 * @@ -1195,24 +1294,26 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, */ herr_t H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx) + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */ - haddr_t middle_addr; /* 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 */ - 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 */ - 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 */ - hsize_t middle_moved_nrec; /* Number of records moved, for internal split */ - unsigned left_child_flags = H5AC__NO_FLAGS_SET, right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + 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 */ + hsize_t middle_moved_nrec; /* Number of records moved, for internal split */ + unsigned left_child_flags = H5AC__NO_FLAGS_SET, + right_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + unsigned middle_child_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting child nodes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1223,115 +1324,131 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, HDassert(internal_flags_ptr); /* Check for the kind of B-tree node to split */ - if(depth > 1) { - H5B2_internal_t *left_internal; /* Pointer to left internal node */ - H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ - H5B2_internal_t *right_internal; /* Pointer to right internal node */ + if (depth > 1) { + H5B2_internal_t *left_internal; /* Pointer to left internal node */ + H5B2_internal_t *middle_internal; /* Pointer to middle internal node */ + H5B2_internal_t *right_internal; /* Pointer to right internal node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ /* (Shadow left and middle nodes if doing SWMR writes) */ - if(NULL == (left_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx - 1], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_internal = + H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (right_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx + 1], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_internal; - middle_child = middle_internal; - right_child = right_internal; - left_nrec = &(left_internal->nrec); - middle_nrec = &(middle_internal->nrec); - right_nrec = &(right_internal->nrec); - left_native = left_internal->int_native; - middle_native = middle_internal->int_native; - right_native = right_internal->int_native; - left_node_ptrs = left_internal->node_ptrs; + left_child = left_internal; + middle_child = middle_internal; + right_child = right_internal; + left_nrec = &(left_internal->nrec); + middle_nrec = &(middle_internal->nrec); + right_nrec = &(right_internal->nrec); + left_native = left_internal->int_native; + middle_native = middle_internal->int_native; + right_native = right_internal->int_native; + left_node_ptrs = left_internal->node_ptrs; middle_node_ptrs = middle_internal->node_ptrs; - right_node_ptrs = right_internal->node_ptrs; + right_node_ptrs = right_internal->node_ptrs; } /* end if */ else { - H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ - H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ - H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ + H5B2_leaf_t *left_leaf; /* Pointer to left leaf node */ + H5B2_leaf_t *middle_leaf; /* Pointer to middle leaf node */ + H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child nodes */ /* (Shadow left and middle nodes if doing SWMR writes) */ - if(NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (left_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx - 1], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") left_addr = internal->node_ptrs[idx - 1].addr; - if(NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], hdr->swmr_write, H5AC__NO_FLAGS_SET))) + if (NULL == (middle_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], + hdr->swmr_write, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") middle_addr = internal->node_ptrs[idx].addr; - if(NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (right_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx + 1], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") right_addr = internal->node_ptrs[idx + 1].addr; /* More setup for accessing child node information */ - left_child = left_leaf; - middle_child = middle_leaf; - right_child = right_leaf; - left_nrec = &(left_leaf->nrec); - middle_nrec = &(middle_leaf->nrec); - right_nrec = &(right_leaf->nrec); - left_native = left_leaf->leaf_native; + left_child = left_leaf; + middle_child = middle_leaf; + right_child = right_leaf; + left_nrec = &(left_leaf->nrec); + middle_nrec = &(middle_leaf->nrec); + right_nrec = &(right_leaf->nrec); + left_native = left_leaf->leaf_native; middle_native = middle_leaf->leaf_native; - right_native = right_leaf->leaf_native; + right_native = right_leaf->leaf_native; } /* end else */ /* Redistribute records into left node */ { - unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); + unsigned total_nrec = (unsigned)(*left_nrec + *middle_nrec + *right_nrec + 2); unsigned middle_nrec_move = ((total_nrec - 1) / 2) - *left_nrec; /* Set the base number of records moved from middle node */ middle_moved_nrec = middle_nrec_move; /* Copy record from parent node to proper location in left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec), H5B2_INT_NREC(internal, hdr, idx - 1), + hdr->cls->nrec_size); /* Copy records from middle node to left node */ - H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), hdr->cls->nrec_size * (middle_nrec_move - 1)); + H5MM_memcpy(H5B2_NAT_NREC(left_native, hdr, *left_nrec + 1), H5B2_NAT_NREC(middle_native, hdr, 0), + hdr->cls->nrec_size * (middle_nrec_move - 1)); /* Copy record from middle node to proper location in parent node */ - H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), + H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size); /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); + HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), + hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); /* Move node pointers also if this is an internal node */ - if(depth > 1) { - unsigned u; /* Local index variable */ + if (depth > 1) { + unsigned u; /* Local index variable */ /* Copy node pointers from middle node into left node */ - H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * middle_nrec_move); + H5MM_memcpy(&(left_node_ptrs[*left_nrec + 1]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * middle_nrec_move); /* Count the number of records being moved into the left node */ - for(u = 0; u < middle_nrec_move; u++) + for (u = 0; u < middle_nrec_move; u++) middle_moved_nrec += middle_node_ptrs[u].all_nrec; /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); + HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, - (unsigned)(*left_nrec + 1), (unsigned)(*left_nrec + middle_nrec_move + 1), middle_child, left_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, left_node_ptrs, (unsigned)(*left_nrec + 1), + (unsigned)(*left_nrec + middle_nrec_move + 1), middle_child, + left_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in left & middle nodes */ - *left_nrec = (uint16_t)(*left_nrec + middle_nrec_move); + *left_nrec = (uint16_t)(*left_nrec + middle_nrec_move); *middle_nrec = (uint16_t)(*middle_nrec - middle_nrec_move); /* Mark nodes as dirty */ @@ -1342,20 +1459,24 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Redistribute records into middle node */ { /* Copy record from parent node to proper location in middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size); /* Copy records from right node to middle node */ - H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (*right_nrec)); + H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, *middle_nrec + 1), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Move node pointers also if this is an internal node */ - if(depth > 1) + if (depth > 1) /* Copy node pointers from right node into middle node */ - H5MM_memcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + H5MM_memcpy(&(middle_node_ptrs[*middle_nrec + 1]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Update flush dependencies for grandchildren, if using SWMR */ - if(hdr->swmr_write && depth > 1) - if(H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, - (unsigned)(*middle_nrec + 1), (unsigned)(*middle_nrec + *right_nrec + 2), right_child, middle_child) < 0) + if (hdr->swmr_write && depth > 1) + if (H5B2__update_child_flush_depends(hdr, depth, middle_node_ptrs, (unsigned)(*middle_nrec + 1), + (unsigned)(*middle_nrec + *right_nrec + 2), right_child, + middle_child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child nodes to new parent") /* Update # of records in middle node */ @@ -1364,22 +1485,24 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Mark nodes as dirty */ middle_child_flags |= H5AC__DIRTIED_FLAG; right_child_flags |= H5AC__DELETED_FLAG; - if(!(hdr->swmr_write)) + if (!(hdr->swmr_write)) right_child_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; } /* end block */ /* Update # of records in child nodes */ internal->node_ptrs[idx - 1].node_nrec = *left_nrec; - internal->node_ptrs[idx].node_nrec = *middle_nrec; + internal->node_ptrs[idx].node_nrec = *middle_nrec; /* Update total # of records in child B-trees */ internal->node_ptrs[idx - 1].all_nrec += middle_moved_nrec; internal->node_ptrs[idx].all_nrec += (internal->node_ptrs[idx + 1].all_nrec + 1) - middle_moved_nrec; /* Slide records in parent node down, to eliminate demoted record */ - if((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + if ((idx + 1) < internal->nrec) { + HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1392,36 +1515,37 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, curr_node_ptr->node_nrec--; /* Mark grandparent as dirty, if given */ - if(parent_cache_info_flags_ptr) + if (parent_cache_info_flags_ptr) *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) { - H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, (H5B2_internal_t *)middle_child); + if (depth > 1) { + H5B2__assert_internal2(internal->node_ptrs[idx - 1].all_nrec, hdr, (H5B2_internal_t *)left_child, + (H5B2_internal_t *)middle_child); H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)middle_child); } /* end if */ else { H5B2__assert_leaf2(hdr, (H5B2_leaf_t *)left_child, (H5B2_leaf_t *)middle_child); H5B2__assert_leaf(hdr, (H5B2_leaf_t *)middle_child); - } /* end else */ + } /* end else */ #endif /* H5B2_DEBUG */ done: /* Unlock left & middle nodes (marked as dirty) */ - if(left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) + if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if(middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) + if (middle_child && + H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") /* Delete right node & remove from cache (marked as dirty) */ - if(right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) + if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge3() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert * @@ -1437,7 +1561,7 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, herr_t H5B2__insert(H5B2_hdr_t *hdr, void *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1446,37 +1570,36 @@ H5B2__insert(H5B2_hdr_t *hdr, void *udata) HDassert(udata); /* Check if the root node is allocated yet */ - if(!H5F_addr_defined(hdr->root.addr)) { + if (!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ - if(H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + if (H5B2__create_leaf(hdr, hdr, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ /* Check if we need to split the root node (equiv. to a 1->2 node split) */ - else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { + else if (hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { /* Split root node */ - if(H5B2__split_root(hdr) < 0) + if (H5B2__split_root(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") } /* end if */ /* Attempt to insert record into B-tree */ - if(hdr->depth > 0) { - if(H5B2__insert_internal(hdr, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) + if (hdr->depth > 0) { + if (H5B2__insert_internal(hdr, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") } /* end if */ else { - if(H5B2__insert_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) + if (H5B2__insert_leaf(hdr, &hdr->root, H5B2_POS_ROOT, hdr, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") } /* end else */ /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) + if (H5B2__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert() */ - /*------------------------------------------------------------------------- * Function: H5B2__iterate_node * @@ -1494,17 +1617,17 @@ 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_operator_t op, void *op_data) +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) { - 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 */ - hbool_t node_pinned = FALSE; /* Whether node is pinned */ - unsigned u; /* Local index */ - herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ + 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 */ + hbool_t node_pinned = FALSE; /* Whether node is pinned */ + unsigned u; /* Local index */ + herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ FUNC_ENTER_PACKAGE @@ -1514,86 +1637,94 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_ HDassert(op); /* Protect current node & set up variables */ - if(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node */ + if (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node */ /* 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, (H5B2_node_ptr_t *)curr_node, depth, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ curr_node_class = H5AC_BT2_INT; - node = internal; - node_native = internal->int_native; + node = internal; + node_native = internal->int_native; /* Allocate space for the node pointers in memory */ - if(NULL == (node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers") + if (NULL == (node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal node pointers") /* Copy the node pointers */ - H5MM_memcpy(node_ptrs, internal->node_ptrs, (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1))); + H5MM_memcpy(node_ptrs, internal->node_ptrs, + (sizeof(H5B2_node_ptr_t) * (size_t)(curr_node->node_nrec + 1))); } /* end if */ else { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Set up information about current node */ curr_node_class = H5AC_BT2_LEAF; - node = leaf; - node_native = leaf->leaf_native; + node = leaf; + node_native = leaf->leaf_native; } /* end else */ /* Allocate space for the native keys in memory */ - if(NULL == (native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") + if (NULL == (native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal native keys") /* Copy the native keys */ H5MM_memcpy(native, node_native, (hdr->cls->nrec_size * curr_node->node_nrec)); /* Unlock the node */ - if(H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - if(hdr->swmr_write) + if (hdr->swmr_write) node_pinned = TRUE; else node = NULL; /* Iterate through records, in order */ - for(u = 0; u < curr_node->node_nrec && !ret_value; u++) { + for (u = 0; u < curr_node->node_nrec && !ret_value; u++) { /* Descend into child node, if current node is an internal node */ - if(depth > 0) - if((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) + if (depth > 0) + if ((ret_value = + H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); /* Make callback for current record */ - if(!ret_value) - if((ret_value = (op)(H5B2_NAT_NREC(native, hdr, u), op_data)) < 0) + if (!ret_value) + if ((ret_value = (op)(H5B2_NAT_NREC(native, hdr, u), op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed"); } /* end for */ /* Descend into last child node, if current node is an internal node */ - if(!ret_value && depth > 0) - if((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < 0) + if (!ret_value && depth > 0) + if ((ret_value = H5B2__iterate_node(hdr, (uint16_t)(depth - 1), &(node_ptrs[u]), node, op, op_data)) < + 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); done: /* Unpin the node if it was pinned */ - if(node_pinned && H5AC_unpin_entry(node) < 0) + if (node_pinned && H5AC_unpin_entry(node) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "can't unpin node") /* Release the node pointers & native records, if they were copied */ - if(node_ptrs) + if (node_ptrs) node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE(hdr->node_info[depth].node_ptr_fac, node_ptrs); - if(native) + if (native) native = (uint8_t *)H5FL_FAC_FREE(hdr->node_info[depth].nat_rec_fac, native); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__iterate_node() */ - /*------------------------------------------------------------------------- * Function: H5B2__delete_node * @@ -1608,13 +1739,13 @@ 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, const 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 @@ -1622,58 +1753,63 @@ H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_n HDassert(hdr); HDassert(curr_node); - if(depth > 0) { - H5B2_internal_t *internal; /* Pointer to internal node */ - unsigned u; /* Local index */ + if (depth > 0) { + H5B2_internal_t *internal; /* Pointer to internal node */ + unsigned u; /* Local index */ /* 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 */ + 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 */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ curr_node_class = H5AC_BT2_INT; - node = internal; - native = internal->int_native; + node = internal; + native = internal->int_native; /* Descend into children */ - for(u = 0; u < internal->nrec + (unsigned)1; u++) - if(H5B2__delete_node(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, op, op_data) < 0) + for (u = 0; u < internal->nrec + (unsigned)1; u++) + if (H5B2__delete_node(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node descent failed") } /* end if */ else { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, (H5B2_node_ptr_t *)curr_node, FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Set up information about current node */ curr_node_class = H5AC_BT2_LEAF; - node = leaf; - native = leaf->leaf_native; + node = leaf; + native = leaf->leaf_native; } /* end else */ /* If there's a callback defined, iterate over the records in this node */ - if(op) { - unsigned u; /* Local index */ + if (op) { + unsigned u; /* Local index */ /* Iterate through records in this node */ - for(u = 0; u < curr_node->node_nrec; u++) { + for (u = 0; u < curr_node->node_nrec; u++) { /* Make callback for each record */ - if((op)(H5B2_NAT_NREC(native, hdr, u), op_data) < 0) + if ((op)(H5B2_NAT_NREC(native, hdr, u), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed") } /* end for */ - } /* end if */ + } /* end if */ done: /* Unlock & delete current node */ - if(node && H5AC_unprotect(hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(H5AC__DELETED_FLAG | (hdr->swmr_write ? 0 : H5AC__FREE_FILE_SPACE_FLAG))) < 0) + if (node && H5AC_unprotect( + hdr->f, curr_node_class, curr_node->addr, node, + (unsigned)(H5AC__DELETED_FLAG | (hdr->swmr_write ? 0 : H5AC__FREE_FILE_SPACE_FLAG))) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__delete_node() */ - /*------------------------------------------------------------------------- * Function: H5B2__node_size * @@ -1688,11 +1824,11 @@ 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, hsize_t *btree_size) +H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, + hsize_t *btree_size) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - herr_t ret_value = SUCCEED; /* Iterator return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + herr_t ret_value = SUCCEED; /* Iterator return value */ FUNC_ENTER_PACKAGE @@ -1703,18 +1839,20 @@ 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, (H5B2_node_ptr_t *)curr_node, depth, FALSE, + H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ 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 */ - if(depth > 1) { - unsigned u; /* Local index */ + if (depth > 1) { + unsigned u; /* Local index */ /* Descend into children */ - for(u = 0; u < internal->nrec + (unsigned)1; u++) - if(H5B2__node_size(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, btree_size) < 0) + for (u = 0; u < internal->nrec + (unsigned)1; u++) + if (H5B2__node_size(hdr, (uint16_t)(depth - 1), &(internal->node_ptrs[u]), internal, btree_size) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") - } /* end if */ + } /* end if */ else /* depth is 1: count all the leaf nodes from this node */ *btree_size += (hsize_t)(internal->nrec + 1) * hdr->node_size; @@ -1722,13 +1860,12 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod *btree_size += hdr->node_size; done: - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__node_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__create_flush_depend * @@ -1744,7 +1881,7 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1753,14 +1890,13 @@ H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_flush_depend * @@ -1774,13 +1910,13 @@ 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, void *new_parent) +H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const 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 */ - unsigned node_status = 0; /* Node's status in the metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5AC_class_t *child_class; /* Pointer to child node's class info */ + 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 */ FUNC_ENTER_PACKAGE @@ -1792,26 +1928,28 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, HDassert(new_parent); /* Check the node's entry status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, node_ptr->addr, &node_status) < 0) + if (H5AC_get_entry_status(hdr->f, node_ptr->addr, &node_status) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to check status of B-tree node") /* If the node is in the cache, check for retargeting its parent */ - if(node_status & H5AC_ES__IN_CACHE) { - void **parent_ptr; /* Pointer to child node's parent */ - hbool_t update_deps = FALSE; /* Whether to update flush dependencies */ + if (node_status & H5AC_ES__IN_CACHE) { + void ** parent_ptr = NULL; /* Pointer to child node's parent */ + hbool_t update_deps = FALSE; /* Whether to update flush dependencies */ /* Get child node pointer */ - if(depth > 1) { + if (depth > 1) { 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, (H5B2_node_ptr_t *)node_ptr, (uint16_t)(depth - 1), FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_class = H5AC_BT2_INT; - child = child_int; + child = child_int; - if(child_int->parent == old_parent) { - parent_ptr = &child_int->parent; + if (child_int->parent == old_parent) { + parent_ptr = &child_int->parent; update_deps = TRUE; } /* end if */ else @@ -1821,13 +1959,15 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_leaf_t *child_leaf; /* Protect child */ - if(NULL == (child_leaf = H5B2__protect_leaf(hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, FALSE, H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == + (child_leaf = H5B2__protect_leaf(hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, FALSE, + H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") child_class = H5AC_BT2_LEAF; - child = child_leaf; + child = child_leaf; - if(child_leaf->parent == old_parent) { - parent_ptr = &child_leaf->parent; + if (child_leaf->parent == old_parent) { + parent_ptr = &child_leaf->parent; update_deps = TRUE; } /* end if */ else @@ -1835,29 +1975,28 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, } /* end else */ /* Update flush dependencies if necessary */ - if(update_deps) { + if (update_deps) { /* Sanity check */ HDassert(parent_ptr); /* Switch the flush dependency for the node */ - if(H5B2__destroy_flush_depend((H5AC_info_t *)old_parent, (H5AC_info_t *)child) < 0) + if (H5B2__destroy_flush_depend((H5AC_info_t *)old_parent, (H5AC_info_t *)child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") *parent_ptr = new_parent; - if(H5B2__create_flush_depend((H5AC_info_t *)new_parent, (H5AC_info_t *)child) < 0) + if (H5B2__create_flush_depend((H5AC_info_t *)new_parent, (H5AC_info_t *)child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ - } /* end if */ + } /* end if */ done: /* Unprotect the child */ - if(child) - if(H5AC_unprotect(hdr->f, child_class, node_ptr->addr, child, H5AC__NO_FLAGS_SET) < 0) + if (child) + if (H5AC_unprotect(hdr->f, child_class, node_ptr->addr, child, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__update_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_child_flush_depends * @@ -1871,12 +2010,11 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, *------------------------------------------------------------------------- */ 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) +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) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1889,16 +2027,15 @@ H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, HDassert(new_parent); /* Loop over children */ - for(u = start_idx; u < end_idx; u++) + for (u = start_idx; u < end_idx; u++) /* Update parent for children */ - if(H5B2__update_flush_depend(hdr, depth - 1, &node_ptrs[u], old_parent, new_parent) < 0) + if (H5B2__update_flush_depend(hdr, depth - 1, &node_ptrs[u], old_parent, new_parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__update_child_flush_depends() */ - /*------------------------------------------------------------------------- * Function: H5B2__destroy_flush_depend * @@ -1914,7 +2051,7 @@ H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1923,10 +2060,9 @@ H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__destroy_flush_depend() */ - diff --git a/src/H5B2internal.c b/src/H5B2internal.c index 82f676f9abb..c00f555dfd4 100644 --- a/src/H5B2internal.c +++ b/src/H5B2internal.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,39 +26,33 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr); - /*********************/ /* Package Variables */ /*********************/ @@ -66,18 +60,14 @@ static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t * /* Declare a free list to manage the H5B2_internal_t struct */ H5FL_DEFINE(H5B2_internal_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__create_internal * @@ -92,12 +82,11 @@ H5FL_DEFINE(H5B2_internal_t); *------------------------------------------------------------------------- */ herr_t -H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - uint16_t depth) +H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth) { - H5B2_internal_t *internal = NULL; /* Pointer to new internal node created */ - hbool_t inserted = FALSE; /* Whether the internal node was inserted into cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to new internal node created */ + hbool_t inserted = FALSE; /* Whether the internal node was inserted into cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -107,24 +96,27 @@ H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert(depth > 0); /* Allocate memory for internal node information */ - if(NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal info") + if (NULL == (internal = H5FL_CALLOC(H5B2_internal_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal info") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") + if (H5B2__hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ internal->hdr = hdr; /* Allocate space for the native keys in memory */ - if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") + if (NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].nat_rec_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal native keys") HDmemset(internal->int_native, 0, hdr->cls->nrec_size * hdr->node_info[depth].max_nrec); /* Allocate space for the node pointers in memory */ - if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal node pointers") + if (NULL == + (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(hdr->node_info[depth].node_ptr_fac))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for B-tree internal node pointers") HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth].max_nrec + 1)); /* Set depth of the node */ @@ -137,43 +129,45 @@ H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, internal->shadow_epoch = hdr->shadow_epoch; /* Allocate space on disk for the internal node */ - if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node") + if (HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node") /* Cache the new B-tree node */ - if(H5AC_insert_entry(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache") + if (H5AC_insert_entry(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache") inserted = TRUE; /* Add internal node as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree node as child of proxy") internal->top_proxy = hdr->top_proxy; } /* end if */ done: - if(ret_value < 0) { - if(internal) { + if (ret_value < 0) { + if (internal) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, "unable to remove v2 B-tree internal node from cache") + if (inserted) + if (H5AC_remove_entry(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, + "unable to remove v2 B-tree internal node from cache") /* Release internal node's disk space */ - if(H5F_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release file space for v2 B-tree internal node") + if (H5F_addr_defined(node_ptr->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, + "unable to release file space for v2 B-tree internal node") /* Destroy internal node */ - if(H5B2__internal_free(internal) < 0) + if (H5B2__internal_free(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__create_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__protect_internal * @@ -187,12 +181,12 @@ H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, *------------------------------------------------------------------------- */ H5B2_internal_t * -H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - uint16_t depth, hbool_t shadow, unsigned flags) +H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth, + 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_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 */ FUNC_ENTER_PACKAGE @@ -206,27 +200,29 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for callback */ - udata.f = hdr->f; - udata.hdr = hdr; + udata.f = hdr->f; + udata.hdr = hdr; udata.parent = parent; - udata.nrec = node_ptr->node_nrec; - udata.depth = depth; + udata.nrec = node_ptr->node_nrec; + udata.depth = depth; /* Protect the internal node */ - if(NULL == (internal = (H5B2_internal_t *)H5AC_protect(hdr->f, H5AC_BT2_INT, node_ptr->addr, &udata, flags))) + if (NULL == + (internal = (H5B2_internal_t *)H5AC_protect(hdr->f, H5AC_BT2_INT, node_ptr->addr, &udata, flags))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect B-tree internal node") /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == internal->top_proxy) { + if (hdr->top_proxy && NULL == internal->top_proxy) { /* Add internal node as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree internal node as child of proxy") + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, + "unable to add v2 B-tree internal node as child of proxy") internal->top_proxy = hdr->top_proxy; } /* end if */ /* Shadow the node, if requested */ - if(shadow) - if(H5B2__shadow_internal(internal, node_ptr) < 0) + if (shadow) + if (H5B2__shadow_internal(internal, node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, NULL, "unable to shadow internal node") /* Set return value */ @@ -234,26 +230,29 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the internal node, if it was protected */ - if(internal) { + if (internal) { /* Remove from v2 B-tree's proxy, if added */ - if(internal->top_proxy) { - if(H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, NULL, "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + if (internal->top_proxy) { + if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) + HDONE_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, NULL, + "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") internal->top_proxy = NULL; } /* end if */ /* Unprotect internal node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree internal node, address = %llu", (unsigned long long)node_ptr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree internal node, address = %llu", + (unsigned long long)node_ptr->addr) } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__protect_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__neighbor_internal * @@ -280,14 +279,13 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, - H5B2_found_t op, void *op_data) +H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, + H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, void *op_data) { - H5B2_internal_t *internal; /* Pointer to internal node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal; /* Pointer to internal node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -299,46 +297,51 @@ H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_n HDassert(op); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) idx++; /* Set the neighbor location, if appropriate */ - if(comp == H5B2_COMPARE_LESS) { - if(idx > 0) + if (comp == H5B2_COMPARE_LESS) { + if (idx > 0) neighbor_loc = H5B2_INT_NREC(internal, hdr, idx - 1); } /* end if */ else { HDassert(comp == H5B2_COMPARE_GREATER); - if(idx < internal->nrec) + if (idx < internal->nrec) neighbor_loc = H5B2_INT_NREC(internal, hdr, idx); } /* end else */ /* Attempt to find neighboring record */ - if(depth > 1) { - if(H5B2__neighbor_internal(hdr, (uint16_t)(depth - 1), &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node") + if (depth > 1) { + if (H5B2__neighbor_internal(hdr, (uint16_t)(depth - 1), &internal->node_ptrs[idx], neighbor_loc, comp, + internal, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "unable to find neighbor record in B-tree internal node") } /* end if */ else { - if(H5B2__neighbor_leaf(hdr, &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, op_data) < 0) + if (H5B2__neighbor_leaf(hdr, &internal->node_ptrs[idx], neighbor_loc, comp, internal, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node") } /* end else */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (internal && + H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert_internal * @@ -353,14 +356,13 @@ H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_n */ herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, - H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, - void *udata) + H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, void *udata) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - unsigned idx = 0; /* Location of record which matches key */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + unsigned idx = 0; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -371,7 +373,8 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Sanity check number of records */ @@ -379,17 +382,17 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in /* Split or redistribute child node pointers, if necessary */ { - int cmp; /* Comparison value of records */ - unsigned retries; /* Number of times to attempt redistribution */ - size_t split_nrec; /* Number of records to split node at */ + int cmp; /* Comparison value of records */ + unsigned retries; /* Number of times to attempt redistribution */ + size_t split_nrec; /* Number of records to split node at */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Set the number of redistribution retries */ @@ -404,74 +407,82 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in split_nrec = hdr->node_info[depth - 1].split_nrec; /* Preemptively split/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == split_nrec) { + while (internal->node_ptrs[idx].node_nrec == split_nrec) { /* Attempt to redistribute records among children */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec < split_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec < split_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec < split_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec < split_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec < split_nrec) || - (internal->node_ptrs[idx - 1].node_nrec < split_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec < split_nrec) || + (internal->node_ptrs[idx - 1].node_nrec < split_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__split1(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after split/redistribute) */ - /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching + */ + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Decrement the number of redistribution retries left */ retries--; } /* end while */ - } /* end block */ + } /* end block */ /* Check if this node is left/right-most */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end else */ - } /* end if */ + } /* end if */ /* Attempt to insert node */ - if(depth > 1) { - if(H5B2__insert_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) + if (depth > 1) { + if (H5B2__insert_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], + next_pos, internal, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") } /* end if */ else { - if(H5B2__insert_leaf(hdr, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) + if (H5B2__insert_leaf(hdr, &internal->node_ptrs[idx], next_pos, internal, udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") } /* end else */ @@ -483,21 +494,20 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in done: /* Release the B-tree internal node */ - if(internal) { + if (internal) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") /* Unprotect node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_internal * @@ -514,17 +524,16 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_in *------------------------------------------------------------------------- */ herr_t -H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data) +H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, + void *parent, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - int cmp; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + int cmp; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -535,26 +544,29 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Sanity check number of records */ HDassert(internal->nrec == curr_node_ptr->node_nrec); /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Check for modifying existing record */ - if(0 == cmp) { - hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + if (0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree update operation") } /* end if */ /* Mark the node as dirty if it changed */ @@ -565,43 +577,47 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, } /* end if */ else { /* Adjust index to leave room for node to insert */ - if(cmp > 0) + if (cmp > 0) idx++; /* Check if this node is left/right-most */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end else */ - } /* end if */ + } /* end if */ /* Attempt to update record in child */ - if(depth > 1) { - if(H5B2__update_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in internal B-tree node") + if (depth > 1) { + if (H5B2__update_internal(hdr, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], + status, next_pos, internal, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, + "unable to update record in internal B-tree node") } /* end if */ else { - if(H5B2__update_leaf(hdr, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, op_data) < 0) + if (H5B2__update_leaf(hdr, &internal->node_ptrs[idx], status, next_pos, internal, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in leaf B-tree node") } /* end else */ /* Take actions based on child's status report */ - switch(*status) { + switch (*status) { case H5B2_UPDATE_MODIFY_DONE: /* No action */ break; case H5B2_UPDATE_SHADOW_DONE: /* If child node was shadowed (if SWMR is enabled), mark this node dirty */ - if(hdr->swmr_write) + if (hdr->swmr_write) internal_flags |= H5AC__DIRTIED_FLAG; - /* No further modifications up the tree are necessary though, so downgrade to merely "modified" */ + /* No further modifications up the tree are necessary though, so downgrade to merely + * "modified" */ *status = H5B2_UPDATE_MODIFY_DONE; break; @@ -615,29 +631,30 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, case H5B2_UPDATE_INSERT_CHILD_FULL: /* Split/redistribute this node */ - if(internal->nrec == hdr->node_info[depth].split_nrec) { - hbool_t could_split = FALSE; /* Whether the child node could split */ + if (internal->nrec == hdr->node_info[depth].split_nrec) { + hbool_t could_split = FALSE; /* Whether the child node could split */ - if(idx == 0) { /* Left-most child */ + if (idx == 0) { /* Left-most child */ /* Check for left-most child and its neighbor being close to full */ - if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ /* Check for right-most child and its neighbor being close to full */ - if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; - } /* end else-if */ - else { /* Middle child */ + } /* end else-if */ + else { /* Middle child */ /* Check for middle child and its left neighbor being close to full */ - if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + if ((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; /* Check for middle child and its right neighbor being close to full */ - else if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) - >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + else if ((internal->node_ptrs[idx].node_nrec + + internal->node_ptrs[idx + 1].node_nrec) >= + ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) could_split = TRUE; } /* end if */ @@ -645,19 +662,21 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, * cause a split, punt back up to caller, leaving the * "insert child full" status. */ - if(could_split) { + if (could_split) { /* Release the internal B-tree node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, + internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, + "unable to release internal B-tree node") internal = NULL; /* Punt back to caller */ HGOTO_DONE(SUCCEED); } /* end if */ - } /* end if */ + } /* end if */ /* Release the internal B-tree node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") internal = NULL; @@ -665,8 +684,10 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, *status = H5B2_UPDATE_INSERT_DONE; /* Dodge sideways into inserting a record into this node */ - if(H5B2__insert_internal(hdr, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, parent, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into internal B-tree node") + if (H5B2__insert_internal(hdr, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, + parent, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, + "unable to insert record into internal B-tree node") break; case H5B2_UPDATE_UNKNOWN: @@ -674,32 +695,31 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, HDassert(0 && "Invalid update status"); HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "invalid update status") } /* end switch */ - } /* end else */ + } /* end else */ done: /* Release the internal B-tree node */ - if(internal) { + if (internal) { /* Check if we should shadow this node */ - if(hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) { + if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ - if(*status == H5B2_UPDATE_MODIFY_DONE) + if (*status == H5B2_UPDATE_MODIFY_DONE) *status = H5B2_UPDATE_SHADOW_DONE; } /* end if */ /* Unprotect node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__update_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__shadow_internal * @@ -719,8 +739,8 @@ H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, static herr_t H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) { - H5B2_hdr_t *hdr; /* B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -739,8 +759,8 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) * the readers so there will be no need to shadow. To check if it has been * shadowed, compare the epoch of this node and the header. If this node's * epoch is <= to the header's, it hasn't been shadowed yet. */ - if(internal->shadow_epoch <= hdr->shadow_epoch) { - haddr_t new_node_addr; /* Address to move node to */ + if (internal->shadow_epoch <= hdr->shadow_epoch) { + haddr_t new_node_addr; /* Address to move node to */ /* * We must clone the old node so readers with an out-of-date version of @@ -748,11 +768,11 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) * shadowed node. Remove it from cache but do not mark it free on disk. */ /* Allocate space for the cloned node */ - if(HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move B-tree node") /* Move the location of the node on the disk */ - if(H5AC_move_entry(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, new_node_addr) < 0) + if (H5AC_move_entry(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, new_node_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMOVE, FAIL, "unable to move B-tree node") curr_node_ptr->addr = new_node_addr; @@ -768,7 +788,6 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__shadow_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_internal * @@ -782,21 +801,21 @@ H5B2__shadow_internal(H5B2_internal_t *internal, H5B2_node_ptr_t *curr_node_ptr) *------------------------------------------------------------------------- */ herr_t -H5B2__remove_internal(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, H5B2_nodepos_t curr_pos, - H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data) +H5B2__remove_internal(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, + 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; - 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 */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ - size_t merge_nrec; /* Number of records to merge node at */ - hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ + size_t merge_nrec; /* Number of records to merge node at */ + hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -808,7 +827,8 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") internal_addr = curr_node_ptr->addr; @@ -817,34 +837,35 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* Check for needing to collapse the root node */ /* (The root node is the only internal node allowed to have 1 record) */ - if(internal->nrec == 1 && - ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { + if (internal->nrec == 1 && + ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { /* Merge children of root node */ - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, + 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") /* Let the cache know that the object is deleted */ internal_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) internal_flags |= H5AC__FREE_FILE_SPACE_FLAG; /* Reset information in header's root node pointer */ - curr_node_ptr->addr = internal->node_ptrs[0].addr; + curr_node_ptr->addr = internal->node_ptrs[0].addr; curr_node_ptr->node_nrec = internal->node_ptrs[0].node_nrec; /* Update flush dependency for child, if using SWMR */ - if(hdr->swmr_write) - if(H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) + if (hdr->swmr_write) + if (H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") /* Indicate that the level of the B-tree decreased */ *depth_decreased = TRUE; /* Set pointers for advancing to child node */ - new_cache_info = parent_cache_info; + new_cache_info = parent_cache_info; new_cache_info_flags_ptr = parent_cache_info_flags_ptr; - new_node_ptr = curr_node_ptr; + new_node_ptr = curr_node_ptr; /* Set flag to indicate root was collapsed */ collapsed_root = TRUE; @@ -854,24 +875,25 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end if */ /* Merge or redistribute child node pointers, if necessary */ else { - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - unsigned retries; /* Number of times to attempt redistribution */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + unsigned retries; /* Number of times to attempt redistribution */ /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal node") internal_addr = curr_node_ptr->addr; } /* end if */ /* Locate node pointer for child */ - if(swap_loc) + if (swap_loc) idx = 0; else { - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp >= 0) + if (cmp >= 0) idx++; } /* end else */ @@ -884,7 +906,7 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, retries = 2; /* Preemptively merge/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == merge_nrec) { + while (internal->node_ptrs[idx].node_nrec == merge_nrec) { /* Attempt to redistribute records among children */ /* (NOTE: These 2-node redistributions should actually get the * record to promote from the node with more records. - QAK) @@ -892,46 +914,54 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* (NOTE: This code is the same in both H5B2__remove_internal() and * H5B2__remove_internal_by_idx(), fix bugs in both places! - QAK) */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, (idx - 1)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || - (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || + (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after merge/redistribute) */ - if(swap_loc) + if (swap_loc) idx = 0; else { -/* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require re-searching */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, &cmp) < 0) + /* Actually, this can be easily updated (for 2-node redistrib.) and shouldn't require + * re-searching */ + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, + &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp >= 0) + if (cmp >= 0) idx++; } /* end else */ @@ -940,66 +970,67 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end while */ /* Handle deleting a record from an internal node */ - if(!swap_loc && cmp == 0) { - swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); + if (!swap_loc && cmp == 0) { + swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); swap_parent = internal; } /* end if */ /* Swap record to delete with record from leaf, if we are the last internal node */ - if(swap_loc && depth == 1) - if(H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) + if (swap_loc && depth == 1) + if (H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "Can't swap records in B-tree") /* Set pointers for advancing to child node */ new_cache_info_flags_ptr = &internal_flags; - new_cache_info = &internal->cache_info; - new_node_ptr = &internal->node_ptrs[idx]; + new_cache_info = &internal->cache_info; + new_node_ptr = &internal->node_ptrs[idx]; /* Indicate position of next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Attempt to remove record from child node */ - if(depth > 1) { - if(H5B2__remove_internal(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), - new_cache_info, new_cache_info_flags_ptr, next_pos, new_node_ptr, udata, op, op_data) < 0) + if (depth > 1) { + if (H5B2__remove_internal(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), + new_cache_info, new_cache_info_flags_ptr, next_pos, new_node_ptr, udata, op, + op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") } /* end if */ else { - if(H5B2__remove_leaf(hdr, new_node_ptr, next_pos, new_cache_info, udata, op, op_data) < 0) + if (H5B2__remove_leaf(hdr, new_node_ptr, next_pos, new_cache_info, udata, op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ /* Update record count for node pointer to current node */ - if(!collapsed_root) + if (!collapsed_root) new_node_ptr->all_nrec--; /* Mark node as dirty */ - if(!(hdr->swmr_write && collapsed_root)) + if (!(hdr->swmr_write && collapsed_root)) internal_flags |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG - H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, internal); + H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, + internal); #endif /* H5B2_DEBUG */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_internal_by_idx * @@ -1014,21 +1045,21 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, *------------------------------------------------------------------------- */ 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, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, hsize_t n, H5B2_remove_t op, void *op_data) +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, 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; - 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 */ - unsigned internal_flags = H5AC__NO_FLAGS_SET; - haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ - size_t merge_nrec; /* Number of records to merge node at */ - hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + haddr_t internal_addr = HADDR_UNDEF; /* Address of internal node */ + size_t merge_nrec; /* Number of records to merge node at */ + hbool_t collapsed_root = FALSE; /* Whether the root was collapsed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1040,7 +1071,8 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent_cache_info, curr_node_ptr, depth, FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") internal_addr = curr_node_ptr->addr; HDassert(internal->nrec == curr_node_ptr->node_nrec); @@ -1051,35 +1083,36 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* Check for needing to collapse the root node */ /* (The root node is the only internal node allowed to have 1 record) */ - if(internal->nrec == 1 && - ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { + if (internal->nrec == 1 && + ((internal->node_ptrs[0].node_nrec + internal->node_ptrs[1].node_nrec) <= ((merge_nrec * 2) + 1))) { HDassert(depth == hdr->depth); /* Merge children of root node */ - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, 0) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, + 0) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") /* Let the cache know that the object is deleted */ internal_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) internal_flags |= H5AC__FREE_FILE_SPACE_FLAG; /* Reset information in header's root node pointer */ - curr_node_ptr->addr = internal->node_ptrs[0].addr; + curr_node_ptr->addr = internal->node_ptrs[0].addr; curr_node_ptr->node_nrec = internal->node_ptrs[0].node_nrec; /* Update flush dependency for child, if using SWMR */ - if(hdr->swmr_write) - if(H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) + if (hdr->swmr_write) + if (H5B2__update_flush_depend(hdr, depth, curr_node_ptr, internal, hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update child node to new parent") /* Indicate that the level of the B-tree decreased */ *depth_decreased = TRUE; /* Set pointers for advancing to child node */ - new_cache_info = parent_cache_info; + new_cache_info = parent_cache_info; new_cache_info_flags_ptr = parent_cache_info_flags_ptr; - new_node_ptr = curr_node_ptr; + new_node_ptr = curr_node_ptr; /* Set flag to indicate root was collapsed */ collapsed_root = TRUE; @@ -1089,33 +1122,33 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, } /* end if */ /* Merge or redistribute child node pointers, if necessary */ else { - hsize_t orig_n = n; /* Original index looked for */ + hsize_t orig_n = n; /* Original index looked for */ unsigned idx; /* Location of record which matches key */ - hbool_t found = FALSE; /* Comparison value of records */ + hbool_t found = FALSE; /* Comparison value of records */ unsigned retries; /* Number of times to attempt redistribution */ /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_internal(internal, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal node") internal_addr = curr_node_ptr->addr; } /* end if */ /* Locate node pointer for child */ - if(swap_loc) + if (swap_loc) idx = 0; else { /* Search for record with correct index */ - for(idx = 0; idx < internal->nrec; idx++) { + for (idx = 0; idx < internal->nrec; idx++) { /* Check which child node contains indexed record */ - if(internal->node_ptrs[idx].all_nrec >= n) { + if (internal->node_ptrs[idx].all_nrec >= n) { /* Check if record is in this node */ - if(internal->node_ptrs[idx].all_nrec == n) { + if (internal->node_ptrs[idx].all_nrec == n) { /* Indicate the record was found and that the index * in child nodes is zero from now on */ found = TRUE; - n = 0; + n = 0; /* Increment to next record */ idx++; @@ -1130,7 +1163,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, */ n -= (internal->node_ptrs[idx].all_nrec + 1); } /* end for */ - } /* end else */ + } /* end else */ /* Set the number of redistribution retries */ /* This takes care of the case where a B-tree node needs to be @@ -1141,7 +1174,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, retries = 2; /* Preemptively merge/redistribute a node we will enter */ - while(internal->node_ptrs[idx].node_nrec == merge_nrec) { + while (internal->node_ptrs[idx].node_nrec == merge_nrec) { /* Attempt to redistribute records among children */ /* (NOTE: These 2-node redistributions should actually get the * record to promote from the node with more records. - QAK) @@ -1149,40 +1182,46 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, /* (NOTE: This code is the same in both H5B2__remove_internal() and * H5B2__remove_internal_by_idx(), fix bugs in both places! - QAK) */ - if(idx == 0) { /* Left-most child */ - if(retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (idx == 0) { /* Left-most child */ + if (retries > 0 && (internal->node_ptrs[idx + 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ - else if(idx == internal->nrec) { /* Right-most child */ - if(retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { - if(H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + } /* end else */ + } /* end if */ + else if (idx == internal->nrec) { /* Right-most child */ + if (retries > 0 && (internal->node_ptrs[idx - 1].node_nrec > merge_nrec)) { + if (H5B2__redistribute2(hdr, depth, internal, (idx - 1)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, (idx - 1)) < 0) + if (H5B2__merge2(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, (idx - 1)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Middle child */ - if(retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || - (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { - if(H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, "unable to redistribute child node records") + if (retries > 0 && ((internal->node_ptrs[idx + 1].node_nrec > merge_nrec) || + (internal->node_ptrs[idx - 1].node_nrec > merge_nrec))) { + if (H5B2__redistribute3(hdr, depth, internal, &internal_flags, idx) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTREDISTRIBUTE, FAIL, + "unable to redistribute child node records") } /* end if */ else { - if(H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, &internal_flags, idx) < 0) + if (H5B2__merge3(hdr, depth, curr_node_ptr, parent_cache_info_flags_ptr, internal, + &internal_flags, idx) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to merge child node") } /* end else */ - } /* end else */ + } /* end else */ /* Locate node pointer for child (after merge/redistribute) */ - if(swap_loc) + if (swap_loc) idx = 0; else { /* Count from the original index value again */ @@ -1194,16 +1233,16 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, found = FALSE; /* Search for record with correct index */ - for(idx = 0; idx < internal->nrec; idx++) { + for (idx = 0; idx < internal->nrec; idx++) { /* Check which child node contains indexed record */ - if(internal->node_ptrs[idx].all_nrec >= n) { + if (internal->node_ptrs[idx].all_nrec >= n) { /* Check if record is in this node */ - if(internal->node_ptrs[idx].all_nrec == n) { + if (internal->node_ptrs[idx].all_nrec == n) { /* Indicate the record was found and that the index * in child nodes is zero from now on */ found = TRUE; - n = 0; + n = 0; /* Increment to next record */ idx++; @@ -1218,73 +1257,75 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, */ n -= (internal->node_ptrs[idx].all_nrec + 1); } /* end for */ - } /* end else */ + } /* end else */ /* Decrement the number of redistribution retries left */ retries--; } /* end while */ /* Handle deleting a record from an internal node */ - if(!swap_loc && found) { - swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); + if (!swap_loc && found) { + swap_loc = H5B2_INT_NREC(internal, hdr, idx - 1); swap_parent = internal; } /* end if */ /* Swap record to delete with record from leaf, if we are the last internal node */ - if(swap_loc && depth == 1) - if(H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) + if (swap_loc && depth == 1) + if (H5B2__swap_leaf(hdr, depth, internal, &internal_flags, idx, swap_loc) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSWAP, FAIL, "can't swap records in B-tree") /* Set pointers for advancing to child node */ new_cache_info_flags_ptr = &internal_flags; - new_cache_info = &internal->cache_info; - new_node_ptr = &internal->node_ptrs[idx]; + new_cache_info = &internal->cache_info; + new_node_ptr = &internal->node_ptrs[idx]; /* Indicate position of next node */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_LEFT; } /* end if */ - else if(idx == internal->nrec) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + else if (idx == internal->nrec) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) next_pos = H5B2_POS_RIGHT; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Attempt to remove record from child node */ - if(depth > 1) { - if(H5B2__remove_internal_by_idx(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), - new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, op, op_data) < 0) + if (depth > 1) { + if (H5B2__remove_internal_by_idx(hdr, depth_decreased, swap_loc, swap_parent, (uint16_t)(depth - 1), + new_cache_info, new_cache_info_flags_ptr, new_node_ptr, next_pos, n, + op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree internal node") } /* end if */ else { - if(H5B2__remove_leaf_by_idx(hdr, new_node_ptr, next_pos, new_cache_info, (unsigned)n, op, op_data) < 0) + if (H5B2__remove_leaf_by_idx(hdr, new_node_ptr, next_pos, new_cache_info, (unsigned)n, op, op_data) < + 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record from B-tree leaf node") } /* end else */ /* Update record count for node pointer to child node */ - if(!collapsed_root) + if (!collapsed_root) new_node_ptr->all_nrec--; /* Mark node as dirty */ - if(!(hdr->swmr_write && collapsed_root)) + if (!(hdr->swmr_write && collapsed_root)) internal_flags |= H5AC__DIRTIED_FLAG; #ifdef H5B2_DEBUG - H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, internal); + H5B2__assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec - 1) : new_node_ptr->all_nrec), hdr, + internal); #endif /* H5B2_DEBUG */ done: /* Release the B-tree internal node */ - if(internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) + if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2__internal_free * @@ -1300,7 +1341,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, herr_t H5B2__internal_free(H5B2_internal_t *internal) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1310,16 +1351,18 @@ H5B2__internal_free(H5B2_internal_t *internal) HDassert(internal); /* Release internal node's native key buffer */ - if(internal->int_native) - internal->int_native = (uint8_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, internal->int_native); + if (internal->int_native) + internal->int_native = (uint8_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, + internal->int_native); /* Release internal node's node pointer buffer */ - if(internal->node_ptrs) - internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + if (internal->node_ptrs) + internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_FREE( + internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); /* Decrement ref. count on B-tree header */ - if(H5B2__hdr_decr(internal->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + if (H5B2__hdr_decr(internal->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") /* Sanity check */ HDassert(NULL == internal->top_proxy); @@ -1332,7 +1375,7 @@ H5B2__internal_free(H5B2_internal_t *internal) } /* end H5B2__internal_free() */ #ifdef H5B2_DEBUG - + /*------------------------------------------------------------------------- * Function: H5B2__assert_internal * @@ -1346,33 +1389,33 @@ H5B2__internal_free(H5B2_internal_t *internal) *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal) +H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, + const H5B2_internal_t *internal) { - hsize_t tot_all_nrec; /* Total number of records at or below this node */ - uint16_t u, v; /* Local index variables */ + hsize_t tot_all_nrec; /* Total number of records at or below this node */ + uint16_t u, v; /* Local index variables */ /* General sanity checking on node */ HDassert(internal->nrec <= hdr->node_info->split_nrec); /* Sanity checking on node pointers */ tot_all_nrec = internal->nrec; - for(u = 0; u < internal->nrec + 1; u++) { + for (u = 0; u < internal->nrec + 1; u++) { tot_all_nrec += internal->node_ptrs[u].all_nrec; HDassert(H5F_addr_defined(internal->node_ptrs[u].addr)); HDassert(internal->node_ptrs[u].addr > 0); - for(v = 0; v < u; v++) + for (v = 0; v < u; v++) HDassert(internal->node_ptrs[u].addr != internal->node_ptrs[v].addr); } /* end for */ /* Sanity check all_nrec total in parent */ - if(parent_all_nrec > 0) + if (parent_all_nrec > 0) HDassert(tot_all_nrec == parent_all_nrec); - return(0); + return (0); } /* end H5B2__assert_internal() */ - /*------------------------------------------------------------------------- * Function: H5B2__assert_internal2 * @@ -1386,32 +1429,32 @@ H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_U *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2) +H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, + const H5B2_internal_t *internal, const H5B2_internal_t *internal2) { - hsize_t tot_all_nrec; /* Total number of records at or below this node */ - uint16_t u, v; /* Local index variables */ + hsize_t tot_all_nrec; /* Total number of records at or below this node */ + uint16_t u, v; /* Local index variables */ /* General sanity checking on node */ HDassert(internal->nrec <= hdr->node_info->split_nrec); /* Sanity checking on node pointers */ - tot_all_nrec =internal->nrec; - for(u =0; u < internal->nrec + 1; u++) { + tot_all_nrec = internal->nrec; + for (u = 0; u < internal->nrec + 1; u++) { tot_all_nrec += internal->node_ptrs[u].all_nrec; HDassert(H5F_addr_defined(internal->node_ptrs[u].addr)); HDassert(internal->node_ptrs[u].addr > 0); - for(v = 0; v < u; v++) + for (v = 0; v < u; v++) HDassert(internal->node_ptrs[u].addr != internal->node_ptrs[v].addr); - for(v = 0; v < internal2->nrec + 1; v++) + for (v = 0; v < internal2->nrec + 1; v++) HDassert(internal->node_ptrs[u].addr != internal2->node_ptrs[v].addr); } /* end for */ /* Sanity check all_nrec total in parent */ - if(parent_all_nrec > 0) + if (parent_all_nrec > 0) HDassert(tot_all_nrec == parent_all_nrec); - return(0); + return (0); } /* end H5B2__assert_internal2() */ #endif /* H5B2_DEBUG */ - diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index d2cfbe038e4..20ace84051b 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,40 +26,34 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr); - /*********************/ /* Package Variables */ /*********************/ @@ -67,18 +61,14 @@ static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_pt /* Declare a free list to manage the H5B2_leaf_t struct */ H5FL_DEFINE(H5B2_leaf_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B2__create_leaf * @@ -95,9 +85,9 @@ H5FL_DEFINE(H5B2_leaf_t); herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) { - H5B2_leaf_t *leaf = NULL; /* Pointer to new leaf node created */ - hbool_t inserted = FALSE; /* Whether the leaf node was inserted into cache */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf = NULL; /* Pointer to new leaf node created */ + hbool_t inserted = FALSE; /* Whether the leaf node was inserted into cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -106,18 +96,18 @@ H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) HDassert(node_ptr); /* Allocate memory for leaf information */ - if(NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info") + if (NULL == (leaf = H5FL_CALLOC(H5B2_leaf_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info") /* Increment ref. count on B-tree header */ - if(H5B2__hdr_incr(hdr) < 0) + if (H5B2__hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, FAIL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ leaf->hdr = hdr; /* Allocate space for the native keys in memory */ - if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac))) + if (NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf native keys") HDmemset(leaf->leaf_native, 0, hdr->cls->nrec_size * hdr->node_info[0].max_nrec); @@ -128,43 +118,45 @@ H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) leaf->shadow_epoch = hdr->shadow_epoch; /* Allocate space on disk for the leaf */ - if(HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (node_ptr->addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree leaf node") /* Cache the new B-tree node */ - if(H5AC_insert_entry(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree leaf to cache") inserted = TRUE; /* Add leaf node as child of 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, FAIL, "unable to add v2 B-tree node as child of proxy") leaf->top_proxy = hdr->top_proxy; } /* end if */ done: - if(ret_value < 0) { - if(leaf) { + if (ret_value < 0) { + if (leaf) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, "unable to remove v2 B-tree leaf node from cache") + if (inserted) + if (H5AC_remove_entry(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, + "unable to remove v2 B-tree leaf node from cache") /* Release leaf node's disk space */ - if(H5F_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release file space for v2 B-tree leaf node") + if (H5F_addr_defined(node_ptr->addr) && + H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, + "unable to release file space for v2 B-tree leaf node") /* Destroy leaf node */ - if(H5B2__leaf_free(leaf) < 0) + if (H5B2__leaf_free(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree leaf node") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__create_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__protect_leaf * @@ -178,12 +170,11 @@ H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr) *------------------------------------------------------------------------- */ H5B2_leaf_t * -H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, - hbool_t shadow, unsigned flags) +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_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 */ FUNC_ENTER_PACKAGE @@ -196,26 +187,26 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for callback */ - udata.f = hdr->f; - udata.hdr = hdr; + udata.f = hdr->f; + udata.hdr = hdr; udata.parent = parent; - udata.nrec = node_ptr->node_nrec; + udata.nrec = node_ptr->node_nrec; /* Protect the leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, &udata, flags))) + if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, &udata, flags))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect B-tree leaf node") /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == leaf->top_proxy) { + if (hdr->top_proxy && NULL == leaf->top_proxy) { /* Add leaf node as child of 'top' proxy */ - if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) + if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSET, NULL, "unable to add v2 B-tree leaf node as child of proxy") leaf->top_proxy = hdr->top_proxy; } /* end if */ /* Shadow the node, if requested */ - if(shadow) - if(H5B2__shadow_leaf(leaf, node_ptr) < 0) + if (shadow) + if (H5B2__shadow_leaf(leaf, node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, NULL, "unable to shadow leaf node") /* Set return value */ @@ -223,26 +214,29 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, done: /* Clean up on error */ - if(!ret_value) { + if (!ret_value) { /* Release the leaf node, if it was protected */ - if(leaf) { + if (leaf) { /* Remove from v2 B-tree's proxy, if added */ - if(leaf->top_proxy) { - if(H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, NULL, "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + if (leaf->top_proxy) { + if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) + HDONE_ERROR( + H5E_BTREE, H5E_CANTUNDEPEND, NULL, + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") leaf->top_proxy = NULL; } /* end if */ /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree leaf node, address = %llu", (unsigned long long)node_ptr->addr) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, + "unable to unprotect v2 B-tree leaf node, address = %llu", + (unsigned long long)node_ptr->addr) } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__protect_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__neighbor_leaf * @@ -269,14 +263,13 @@ H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, - void *op_data) +H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, + void *parent, void *udata, H5B2_found_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp = 0; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp = 0; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -287,48 +280,47 @@ H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(op); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) + idx++; + else if (cmp == 0 && comp == H5B2_COMPARE_GREATER) idx++; - else - if(cmp == 0 && comp == H5B2_COMPARE_GREATER) - idx++; /* Set the neighbor location, if appropriate */ - if(comp == H5B2_COMPARE_LESS) { - if(idx > 0) + if (comp == H5B2_COMPARE_LESS) { + if (idx > 0) neighbor_loc = H5B2_LEAF_NREC(leaf, hdr, idx - 1); } /* end if */ else { HDassert(comp == H5B2_COMPARE_GREATER); - if(idx < leaf->nrec) + if (idx < leaf->nrec) neighbor_loc = H5B2_LEAF_NREC(leaf, hdr, idx); } /* end else */ /* Make callback if neighbor record has been found */ - if(neighbor_loc) { + if (neighbor_loc) { /* Make callback for current record */ - if((op)(neighbor_loc, op_data) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree neighbor operation") + if ((op)(neighbor_loc, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, + "'found' callback failed for B-tree neighbor operation") } /* end if */ else HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree") done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__insert_leaf * @@ -342,14 +334,14 @@ H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata) +H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - int cmp; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -359,7 +351,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Must have a leaf node with enough space to insert a record now */ @@ -370,24 +362,25 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Check for inserting into empty leaf */ - if(leaf->nrec == 0) + if (leaf->nrec == 0) idx = 0; else { /* Find correct location to insert this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp == 0) + if (cmp == 0) HGOTO_ERROR(H5E_BTREE, H5E_EXISTS, FAIL, "record is already in B-tree") - if(cmp > 0) + if (cmp > 0) idx++; /* Make room for new record */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end else */ /* Make callback to store record in native form */ - if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) + if ((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") /* Mark the node as dirty */ @@ -402,42 +395,43 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, /* Check for new record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the B-tree leaf node (marked as dirty) */ - if(leaf) { + if (leaf) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__insert_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__update_leaf * @@ -454,15 +448,14 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data) +H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ - int cmp = -1; /* Comparison value of records */ - unsigned idx = 0; /* Location of record which matches key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp = -1; /* Comparison value of records */ + unsigned idx = 0; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -472,7 +465,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Sanity check number of records */ @@ -480,17 +473,17 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Check for inserting into empty leaf */ - if(leaf->nrec == 0) + if (leaf->nrec == 0) idx = 0; else { /* Find correct location to insert this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Check for inserting a record */ - if(0 != cmp) { + if (0 != cmp) { /* Check if the leaf node is full */ - if(curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { + if (curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { /* Indicate that the leaf is full, but we need to insert */ *status = H5B2_UPDATE_INSERT_CHILD_FULL; @@ -499,25 +492,27 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, } /* end if */ /* Adjust index to leave room for record to insert */ - if(cmp > 0) + if (cmp > 0) idx++; /* Make room for new record */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end if */ - } /* end else */ + } /* end else */ /* Check for modifying existing record */ - if(0 == cmp) { - hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + if (0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed == FALSE); - HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, + "'modify' callback failed for B-tree update operation") } /* end if */ /* Mark the node as dirty if it changed */ @@ -531,7 +526,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(curr_node_ptr->node_nrec < hdr->node_info[0].max_nrec); /* Make callback to store record in native form */ - if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) + if ((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") /* Mark the node as dirty */ @@ -550,49 +545,50 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, /* Check for new record being the min or max for the tree */ /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(H5B2_POS_MIDDLE != curr_pos) { - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + if (H5B2_POS_MIDDLE != curr_pos) { + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec == NULL) + if (NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree min record info") H5MM_memcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec == NULL) + if (NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, + "memory allocation failed for v2 B-tree max record info") H5MM_memcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the B-tree leaf node */ - if(leaf) { + if (leaf) { /* Check if we should shadow this node */ - if(hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) { + if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ - if(*status == H5B2_UPDATE_MODIFY_DONE) + if (*status == H5B2_UPDATE_MODIFY_DONE) *status = H5B2_UPDATE_SHADOW_DONE; } /* end if */ /* Unprotect leaf node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__update_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__swap_leaf * @@ -608,14 +604,14 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx, void *swap_loc) +H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned *internal_flags_ptr, + unsigned idx, void *swap_loc) { - const H5AC_class_t *child_class; /* Pointer to child node's class info */ - haddr_t child_addr; /* Address of child node */ - void *child = NULL; /* Pointer to child node */ - uint8_t *child_native; /* Pointer to child's native records */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -626,34 +622,37 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, HDassert(idx <= internal->nrec); /* Check for the kind of B-tree node to swap */ - if(depth > 1) { - H5B2_internal_t *child_internal; /* Pointer to internal node */ + if (depth > 1) { + H5B2_internal_t *child_internal; /* Pointer to internal node */ /* Setup information for unlocking child node */ child_class = H5AC_BT2_INT; /* Lock B-tree child nodes */ - if(NULL == (child_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == + (child_internal = H5B2__protect_internal(hdr, internal, &internal->node_ptrs[idx], + (uint16_t)(depth - 1), FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_addr = internal->node_ptrs[idx].addr; /* More setup for accessing child node information */ - child = child_internal; + child = child_internal; child_native = child_internal->int_native; } /* end if */ else { - H5B2_leaf_t *child_leaf; /* Pointer to leaf node */ + H5B2_leaf_t *child_leaf; /* Pointer to leaf node */ /* Setup information for unlocking child nodes */ child_class = H5AC_BT2_LEAF; /* Lock B-tree child node */ - if(NULL == (child_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (child_leaf = H5B2__protect_leaf(hdr, internal, &internal->node_ptrs[idx], FALSE, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") child_addr = internal->node_ptrs[idx].addr; /* More setup for accessing child node information */ - child = child_leaf; + child = child_leaf; child_native = child_leaf->leaf_native; } /* end else */ @@ -667,7 +666,7 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, #ifdef H5B2_DEBUG H5B2__assert_internal((hsize_t)0, hdr, internal); - if(depth > 1) + if (depth > 1) H5B2__assert_internal(internal->node_ptrs[idx].all_nrec, hdr, (H5B2_internal_t *)child); else H5B2__assert_leaf(hdr, (H5B2_leaf_t *)child); @@ -675,13 +674,12 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, done: /* Unlock child node */ - if(child && H5AC_unprotect(hdr->f, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) + if (child && H5AC_unprotect(hdr->f, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__swap_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__shadow_leaf * @@ -701,8 +699,8 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, static herr_t H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) { - H5B2_hdr_t *hdr; /* B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -721,20 +719,20 @@ H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) * the readers so there will be no need to shadow. To check if it has been * shadowed, compare the epoch of this node and the header. If this node's * epoch is <= to the header's, it hasn't been shadowed yet. */ - if(leaf->shadow_epoch <= hdr->shadow_epoch) { - haddr_t new_node_addr; /* Address to move node to */ + if (leaf->shadow_epoch <= hdr->shadow_epoch) { + haddr_t new_node_addr; /* Address to move node to */ /* - * We must clone the old node so readers with an out-of-date version of - * the parent can still see the correct number of children, via the - * shadowed node. Remove it from cache but do not mark it free on disk. - */ + * We must clone the old node so readers with an out-of-date version of + * the parent can still see the correct number of children, via the + * shadowed node. Remove it from cache but do not mark it free on disk. + */ /* Allocate space for the cloned node */ - if(HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) + if (HADDR_UNDEF == (new_node_addr = H5MF_alloc(hdr->f, H5FD_MEM_BTREE, (hsize_t)hdr->node_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move B-tree node") /* Move the location of the old child on the disk */ - if(H5AC_move_entry(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, new_node_addr) < 0) + if (H5AC_move_entry(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, new_node_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTMOVE, FAIL, "unable to move B-tree node") curr_node_ptr->addr = new_node_addr; @@ -750,7 +748,6 @@ H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__shadow_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_leaf * @@ -764,16 +761,15 @@ H5B2__shadow_leaf(H5B2_leaf_t *leaf, H5B2_node_ptr_t *curr_node_ptr) *------------------------------------------------------------------------- */ herr_t -H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_remove_t op, - void *op_data) +H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata, H5B2_remove_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ - unsigned idx = 0; /* Location of record which matches key */ - int cmp; /* Comparison value of records */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ + unsigned idx = 0; /* Location of record which matches key */ + int cmp; /* Comparison value of records */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -783,7 +779,7 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock current B-tree node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") leaf_addr = curr_node_ptr->addr; @@ -792,47 +788,48 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(leaf->nrec == curr_node_ptr->node_nrec); /* Find correct location to remove this record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record is not in B-tree") /* Check for invalidating the min/max record for the tree */ - if(H5B2_POS_MIDDLE != curr_pos) { + if (H5B2_POS_MIDDLE != curr_pos) { /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec) hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec) hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Make 'remove' callback if there is one */ - if(op) - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) + if (op) + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record into leaf node") /* Update number of records in node */ leaf->nrec--; - if(leaf->nrec > 0) { + if (leaf->nrec > 0) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf node") leaf_addr = curr_node_ptr->addr; } /* end if */ /* Pack record out of leaf */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -840,7 +837,7 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, else { /* Let the cache know that the object is deleted */ leaf_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) leaf_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Reset address of parent node pointer */ @@ -852,13 +849,12 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__remove_leaf_by_idx * @@ -873,14 +869,13 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, *------------------------------------------------------------------------- */ herr_t -H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, - void *op_data) +H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + void *parent, unsigned idx, H5B2_remove_t op, void *op_data) { - H5B2_leaf_t *leaf; /* Pointer to leaf node */ - haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ - unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -890,7 +885,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(H5F_addr_defined(curr_node_ptr->addr)); /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, curr_node_ptr, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") leaf_addr = curr_node_ptr->addr; @@ -900,41 +895,42 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, HDassert(idx < leaf->nrec); /* Check for invalidating the min/max record for the tree */ - if(H5B2_POS_MIDDLE != curr_pos) { + if (H5B2_POS_MIDDLE != curr_pos) { /* (Don't use 'else' for the idx check, to allow for root leaf node) */ - if(idx == 0) { - if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) + if (idx == 0) { + if (H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->min_native_rec) hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ - } /* end if */ - if(idx == (unsigned)(leaf->nrec - 1)) { - if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) + } /* end if */ + if (idx == (unsigned)(leaf->nrec - 1)) { + if (H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if (hdr->max_native_rec) hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Make 'remove' callback if there is one */ - if(op) - if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) + if (op) + if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDELETE, FAIL, "unable to remove record into leaf node") /* Update number of records in node */ leaf->nrec--; - if(leaf->nrec > 0) { + if (leaf->nrec > 0) { /* Shadow the node if doing SWMR writes */ - if(hdr->swmr_write) { - if(H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) + if (hdr->swmr_write) { + if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf node") leaf_addr = curr_node_ptr->addr; } /* end if */ /* Pack record out of leaf */ - if(idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), hdr->cls->nrec_size * (leaf->nrec - idx)); + if (idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -942,7 +938,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, else { /* Let the cache know that the object is deleted */ leaf_flags |= H5AC__DELETED_FLAG; - if(!hdr->swmr_write) + if (!hdr->swmr_write) leaf_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Reset address of parent node pointer */ @@ -954,13 +950,12 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, done: /* Release the B-tree leaf node */ - if(leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) + if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5B2__leaf_free * @@ -976,7 +971,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, herr_t H5B2__leaf_free(H5B2_leaf_t *leaf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -986,12 +981,12 @@ H5B2__leaf_free(H5B2_leaf_t *leaf) HDassert(leaf); /* Release leaf's native key buffer */ - if(leaf->leaf_native) + if (leaf->leaf_native) leaf->leaf_native = (uint8_t *)H5FL_FAC_FREE(leaf->hdr->node_info[0].nat_rec_fac, leaf->leaf_native); /* Decrement ref. count on B-tree header */ - if(H5B2__hdr_decr(leaf->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + if (H5B2__hdr_decr(leaf->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") /* Sanity check */ HDassert(NULL == leaf->top_proxy); @@ -1004,7 +999,7 @@ H5B2__leaf_free(H5B2_leaf_t *leaf) } /* end H5B2__leaf_free() */ #ifdef H5B2_DEBUG - + /*------------------------------------------------------------------------- * Function: H5B2__assert_leaf * @@ -1018,16 +1013,14 @@ H5B2__leaf_free(H5B2_leaf_t *leaf) *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, - const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf) +H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); - return(0); + return (0); } /* end H5B2__assert_leaf() */ - /*------------------------------------------------------------------------- * Function: H5B2__assert_leaf2 * @@ -1041,12 +1034,12 @@ H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf2(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf, const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) +H5B2__assert_leaf2(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf, + const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); - return(0); + return (0); } /* end H5B2__assert_leaf2() */ #endif /* H5B2_DEBUG */ - diff --git a/src/H5B2module.h b/src/H5B2module.h index 6e8c92a74d5..aa0e163b857 100644 --- a/src/H5B2module.h +++ b/src/H5B2module.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,17 +18,15 @@ * H5B2 package. Including this header means that the source file * is part of the H5B2 package. */ -#ifndef _H5B2module_H -#define _H5B2module_H +#ifndef H5B2module_H +#define H5B2module_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5B2_MODULE -#define H5_MY_PKG H5B2 -#define H5_MY_PKG_ERR H5E_BTREE -#define H5_MY_PKG_INIT NO - -#endif /* _H5B2module_H */ - +#define H5_MY_PKG H5B2 +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO +#endif /* H5B2module_H */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 7d73752cc20..8d620cc890d 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,130 +23,120 @@ #error "Do not include this file outside the H5B2 package!" #endif -#ifndef _H5B2pkg_H -#define _H5B2pkg_H +#ifndef H5B2pkg_H +#define H5B2pkg_H /* Get package's private header */ #include "H5B2private.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of storage for number of records per node (on disk) */ -#define H5B2_SIZEOF_RECORDS_PER_NODE (unsigned)2 +#define H5B2_SIZEOF_RECORDS_PER_NODE (unsigned)2 /* Size of a "tree pointer" (on disk) */ /* (essentially, the largest internal pointer allowed) */ -#define H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) ( \ - (sizeof_addr) + \ - H5B2_SIZEOF_RECORDS_PER_NODE + \ - (sizeof_size) \ - ) +#define H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) \ + ((sizeof_addr) + H5B2_SIZEOF_RECORDS_PER_NODE + (sizeof_size)) /* Size of a internal node pointer (on disk) */ -#define H5B2_INT_POINTER_SIZE(h, d) ( \ - (unsigned)(h)->sizeof_addr /* Address of child node */ \ - + (h)->max_nrec_size /* # of records in child node */ \ - + (h)->node_info[(d) - 1].cum_max_nrec_size /* Total # of records in child & below */ \ +#define H5B2_INT_POINTER_SIZE(h, d) \ + ((unsigned)(h)->sizeof_addr /* Address of child node */ \ + + (h)->max_nrec_size /* # of records in child node */ \ + + (h)->node_info[(d)-1].cum_max_nrec_size /* Total # of records in child & below */ \ ) /* Size of checksum information (on disk) */ -#define H5B2_SIZEOF_CHKSUM 4 +#define H5B2_SIZEOF_CHKSUM 4 /* Format overhead for all v2 B-tree metadata in the file */ -#define H5B2_METADATA_PREFIX_SIZE ( \ - (unsigned)H5_SIZEOF_MAGIC /* Signature */ \ - + (unsigned)1 /* Version */ \ - + (unsigned)1 /* Tree type */ \ - + (unsigned)H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \ +#define H5B2_METADATA_PREFIX_SIZE \ + ((unsigned)H5_SIZEOF_MAGIC /* Signature */ \ + + (unsigned)1 /* Version */ \ + + (unsigned)1 /* Tree type */ \ + + (unsigned)H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \ ) /* Size of the v2 B-tree header on disk */ -#define H5B2_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - + (unsigned)4 /* Node size, in bytes */ \ - + (unsigned)2 /* Record size, in bytes */ \ - + (unsigned)2 /* Depth of tree */ \ - + (unsigned)1 /* Split % of full (as integer, ie. "98" means 98%) */ \ - + (unsigned)1 /* Merge % of full (as integer, ie. "98" means 98%) */ \ - + H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) /* Node pointer to root node in tree */ \ +#define H5B2_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ \ + + (unsigned)4 /* Node size, in bytes */ \ + + (unsigned)2 /* Record size, in bytes */ \ + + (unsigned)2 /* Depth of tree */ \ + + (unsigned)1 /* Split % of full (as integer, ie. "98" means 98%) */ \ + + (unsigned)1 /* Merge % of full (as integer, ie. "98" means 98%) */ \ + + H5B2_TREE_POINTER_SIZE(sizeof_addr, sizeof_size) /* Node pointer to root node in tree */ \ ) /* Size of the v2 B-tree header on disk (via file pointer) */ -#define H5B2_HEADER_SIZE_FILE(f) ( \ - H5B2_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5B2_HEADER_SIZE_FILE(f) (H5B2_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the v2 B-tree header on disk (via v2 B-tree header) */ -#define H5B2_HEADER_SIZE_HDR(h) ( \ - H5B2_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5B2_HEADER_SIZE_HDR(h) (H5B2_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the v2 B-tree internal node prefix */ -#define H5B2_INT_PREFIX_SIZE ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - /* */ \ +#define H5B2_INT_PREFIX_SIZE \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ /* */ \ ) /* Size of the v2 B-tree leaf node prefix */ -#define H5B2_LEAF_PREFIX_SIZE ( \ - /* General metadata fields */ \ - H5B2_METADATA_PREFIX_SIZE \ - \ - /* Header specific fields */ \ - /* */ \ +#define H5B2_LEAF_PREFIX_SIZE \ + (/* General metadata fields */ \ + H5B2_METADATA_PREFIX_SIZE \ + \ + /* Header specific fields */ /* */ \ ) /* Macro to retrieve pointer to i'th native record for native record buffer */ -#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)]) +#define H5B2_NAT_NREC(b, hdr, idx) ((b) + (hdr)->nat_off[(idx)]) /* Macro to retrieve pointer to i'th native record for internal node */ -#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx)) +#define H5B2_INT_NREC(i, hdr, idx) H5B2_NAT_NREC((i)->int_native, (hdr), (idx)) /* Macro to retrieve pointer to i'th native record for leaf node */ -#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx)) +#define H5B2_LEAF_NREC(l, hdr, idx) H5B2_NAT_NREC((l)->leaf_native, (hdr), (idx)) /* Number of records that fit into internal node */ /* (accounts for extra node pointer by counting it in with the prefix bytes) */ -#define H5B2_NUM_INT_REC(h, d) \ - (((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d))) +#define H5B2_NUM_INT_REC(h, d) \ + (((h)->node_size - (H5B2_INT_PREFIX_SIZE + H5B2_INT_POINTER_SIZE(h, d))) / \ + ((h)->rrec_size + H5B2_INT_POINTER_SIZE(h, d))) /* Uncomment this macro to enable extra sanity checking */ /* #define H5B2_DEBUG */ - /****************************/ /* Package Private Typedefs */ /****************************/ /* A "node pointer" to another B-tree node */ typedef struct { - haddr_t addr; /* Address of other node */ - uint16_t node_nrec; /* Number of records used in node pointed to */ - hsize_t all_nrec; /* Number of records in node pointed to and all it's children */ + haddr_t addr; /* Address of other node */ + uint16_t node_nrec; /* Number of records used in node pointed to */ + hsize_t all_nrec; /* Number of records in node pointed to and all it's children */ } H5B2_node_ptr_t; /* Information about a node at a given depth */ typedef struct { - unsigned max_nrec; /* Max. number of records in node */ - unsigned split_nrec; /* Number of records to split node at */ - unsigned merge_nrec; /* Number of records to merge node at */ - hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */ - uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ - H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */ - H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ + unsigned max_nrec; /* Max. number of records in node */ + unsigned split_nrec; /* Number of records to split node at */ + unsigned merge_nrec; /* Number of records to merge node at */ + hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */ + uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ + H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */ + H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ } H5B2_node_info_t; /* The B-tree header information */ @@ -155,60 +145,60 @@ typedef struct H5B2_hdr_t { H5AC_info_t cache_info; /* Internal B-tree information (stored) */ - H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ + H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */ /* Information set by user (stored) */ - uint8_t split_percent; /* Percent full at which to split the node, when inserting */ - uint8_t merge_percent; /* Percent full at which to merge the node, when deleting */ - uint32_t node_size; /* Size of B-tree nodes, in bytes */ - uint32_t rrec_size; /* Size of "raw" (on disk) record, in bytes */ + uint8_t split_percent; /* Percent full at which to split the node, when inserting */ + uint8_t merge_percent; /* Percent full at which to merge the node, when deleting */ + uint32_t node_size; /* Size of B-tree nodes, in bytes */ + uint32_t rrec_size; /* Size of "raw" (on disk) record, in bytes */ /* Dynamic information (stored) */ - uint16_t depth; /* B-tree's overall depth */ + uint16_t depth; /* B-tree's overall depth */ /* Derived information from user's information (not stored) */ - uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ + uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ /* Shared internal data structures (not stored) */ - 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 */ - size_t file_rc; /* Reference count of files using this header */ - hbool_t pending_delete; /* B-tree is pending deletion */ - 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 */ - 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 */ + 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 */ + size_t file_rc; /* Reference count of files using this header */ + hbool_t pending_delete; /* B-tree is pending deletion */ + 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 */ + 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 */ /* SWMR / Flush dependency information (not stored) */ - hbool_t swmr_write; /* Whether we are doing SWMR writes */ + 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 - * parent, if it exists, otherwise NULL. - * If the v2 B-tree is being used to index a - * chunked dataset and the dataset metadata is - * modified by a SWMR writer, this field will - * be set equal to the object header proxy - * that is the flush dependency parent - * of the v2 B-tree header. - * - * The field is used to avoid duplicate setups - * of the flush dependency relationship, and to - * allow the v2 B-tree header to destroy the - * flush dependency on receipt of an eviction - * notification from the metadata cache. - */ - uint64_t shadow_epoch; /* Epoch of header, for making shadow copies */ + 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 + * modified by a SWMR writer, this field will + * be set equal to the object header proxy + * that is the flush dependency parent + * of the v2 B-tree header. + * + * The field is used to avoid duplicate setups + * of the flush dependency relationship, and to + * allow the v2 B-tree header to destroy the + * flush dependency on receipt of an eviction + * notification from the metadata cache. + */ + uint64_t shadow_epoch; /* Epoch of header, for making shadow copies */ /* Client information (not stored) */ - const H5B2_class_t *cls; /* Class of B-tree client */ - void *cb_ctx; /* Client callback context */ + const H5B2_class_t *cls; /* Class of B-tree client */ + void * cb_ctx; /* Client callback context */ } H5B2_hdr_t; /* B-tree leaf node information */ @@ -217,14 +207,14 @@ typedef struct H5B2_leaf_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ - uint8_t *leaf_native; /* Pointer to native records */ - uint16_t nrec; /* Number of records in node */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ + 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 */ - uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ + void * parent; /* Flush dependency parent for leaf */ + uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ } H5B2_leaf_t; /* B-tree internal node information */ @@ -233,74 +223,73 @@ 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_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 */ + 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 */ - uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ + 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 */ + H5B2_hdr_t *hdr; /* Pointer to internal v2 B-tree header info */ + H5F_t * f; /* Pointer to file for v2 B-tree */ }; /* Node position, for min/max determination */ typedef enum H5B2_nodepos_t { - H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */ - H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */ - H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */ - H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ + H5B2_POS_ROOT, /* Node is root (i.e. both right & left-most in tree) */ + H5B2_POS_RIGHT, /* Node is right-most in tree, at a given depth */ + H5B2_POS_LEFT, /* Node is left-most in tree, at a given depth */ + H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ } H5B2_nodepos_t; /* Update status */ typedef enum H5B2_update_status_t { - H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ - H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ - H5B2_UPDATE_SHADOW_DONE, /* Update modified existing record and modified node was shadowed */ - H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ - H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ + H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ + H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ + H5B2_UPDATE_SHADOW_DONE, /* Update modified existing record and modified node was shadowed */ + H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ + H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ } 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 */ - haddr_t addr; /* Address of B-tree header in the file */ - void *ctx_udata; /* User-data for protecting */ + 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 */ } 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 */ - H5B2_hdr_t *hdr; /* v2 B-tree header */ - void *parent; /* Flush dependency parent */ - uint16_t nrec; /* Number of records in node to load */ - uint16_t depth; /* Depth of node to load */ + H5F_t * f; /* File that v2 b-tree header is within */ + H5B2_hdr_t *hdr; /* v2 B-tree header */ + 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 */ - H5B2_hdr_t *hdr; /* v2 B-tree header */ - void *parent; /* Flush dependency parent */ - uint16_t nrec; /* Number of records in node to load */ + H5F_t * f; /* File that v2 b-tree header is within */ + H5B2_hdr_t *hdr; /* v2 B-tree header */ + void * parent; /* Flush dependency parent */ + uint16_t nrec; /* Number of records in node to load */ } H5B2_leaf_cache_ud_t; #ifdef H5B2_TESTING /* Node information for testing */ typedef struct H5B2_node_info_test_t { - uint16_t depth; /* Depth of node */ - uint16_t nrec; /* Number of records in node */ + uint16_t depth; /* Depth of node */ + uint16_t nrec; /* Number of records in node */ } H5B2_node_info_test_t; #endif /* H5B2_TESTING */ - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -318,73 +307,65 @@ H5_DLLVAR const H5B2_class_t H5B2_TEST2[1]; /* B-tree record for testing H5B2_TEST2 class */ typedef struct H5B2_test_rec_t { - hsize_t key; /* Key for record */ - hsize_t val; /* Value for record */ + hsize_t key; /* Key for record */ + hsize_t val; /* Value for record */ } H5B2_test_rec_t; #endif /* H5B2_TESTING */ /* Array of v2 B-tree client ID -> client class mappings */ extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* 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, void *old_parent, void *new_parent); -H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +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, + void *old_parent, void *new_parent); +H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Internal node management routines */ H5_DLL herr_t H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); -H5_DLL herr_t H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_internal_t *internal, unsigned idx); -H5_DLL herr_t H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); +H5_DLL herr_t H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned idx); +H5_DLL herr_t H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); H5_DLL herr_t H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); H5_DLL herr_t H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, - unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx); + unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx); /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2__hdr_alloc(H5F_t *f); -H5_DLL haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); -H5_DLL herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, - void *ctx_udata, uint16_t depth); +H5_DLL haddr_t H5B2__hdr_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); +H5_DLL herr_t H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, uint16_t depth); H5_DLL herr_t H5B2__hdr_incr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); -H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, - void *ctx_udata, unsigned flags); -H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr); /* Routines for operating on leaf nodes */ -H5_DLL H5B2_leaf_t * H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, hbool_t shadow, unsigned flags); -H5_DLL herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, - unsigned *internal_flags_ptr, unsigned idx, void *swap_loc); +H5_DLL H5B2_leaf_t *H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, + hbool_t shadow, unsigned flags); +H5_DLL herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, + unsigned *internal_flags_ptr, unsigned idx, void *swap_loc); /* Routines for operating on internal nodes */ -H5_DLL H5B2_internal_t *H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, uint16_t depth, hbool_t shadow, unsigned flags); +H5_DLL H5B2_internal_t *H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, + uint16_t depth, hbool_t shadow, unsigned flags); /* Routines for allocating nodes */ H5_DLL herr_t H5B2__split_root(H5B2_hdr_t *hdr); -H5_DLL herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr); -H5_DLL herr_t H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, - H5B2_node_ptr_t *node_ptr, uint16_t depth); +H5_DLL herr_t H5B2__create_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr); +H5_DLL herr_t H5B2__create_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, uint16_t depth); /* Routines for releasing structures */ H5_DLL herr_t H5B2__hdr_free(H5B2_hdr_t *hdr); @@ -393,74 +374,74 @@ H5_DLL herr_t H5B2__internal_free(H5B2_internal_t *i); /* Routines for inserting records */ H5_DLL herr_t H5B2__insert(H5B2_hdr_t *hdr, void *udata); -H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata); -H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, void *parent, void *udata); +H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *parent, + void *udata); +H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + void *parent, void *udata); /* Routines for update records */ -H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, - unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data); -H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *parent, - void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, + void *op_data); +H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *parent, void *udata, H5B2_modify_t op, + 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, hsize_t *op_data); +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, + hsize_t *op_data); /* Routines for locating records */ -H5_DLL herr_t H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, - size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx, int *result); -H5_DLL herr_t H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, - H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp, - void *parent, void *udata, H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, - H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2__locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, + const uint8_t *native, const void *udata, unsigned *idx, int *result); +H5_DLL herr_t H5B2__neighbor_internal(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, + void *neighbor_loc, H5B2_compare_t comp, void *parent, void *udata, + H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, + H5B2_compare_t comp, void *parent, void *udata, H5B2_found_t op, + void *op_data); /* Routines for removing records */ -H5_DLL herr_t H5B2__remove_internal(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, H5B2_nodepos_t curr_pos, - H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, - void *op_data); -H5_DLL herr_t H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, - H5B2_nodepos_t curr_pos, 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, - 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_internal(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, H5B2_nodepos_t curr_pos, + H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, + void *op_data); +H5_DLL herr_t H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, + 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, + 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, - H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, - void *op_data); + H5B2_nodepos_t curr_pos, void *parent, unsigned idx, H5B2_remove_t op, + 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, const 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, const H5B2_class_t *type, haddr_t obj_addr); -H5_DLL 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 obj_addr); -H5_DLL 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 obj_addr); +H5_DLL herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5B2_class_t *type, haddr_t obj_addr); +H5_DLL 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 obj_addr); +H5_DLL 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 obj_addr); /* Sanity checking routines */ #ifdef H5B2_DEBUG /* Don't label these with H5_ATTR_PURE or you'll get even more warnings... */ -H5_DLL herr_t H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal); -H5_DLL herr_t H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal, const H5B2_internal_t *internal2); +H5_DLL herr_t H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, + const H5B2_internal_t *internal); +H5_DLL herr_t H5B2__assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, + const H5B2_internal_t *internal, const H5B2_internal_t *internal2); H5_DLL herr_t H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf); H5_DLL herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_leaf_t *leaf2); #endif /* H5B2_DEBUG */ @@ -468,10 +449,8 @@ H5_DLL herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, /* Testing routines */ #ifdef H5B2_TESTING H5_DLL herr_t H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr); -H5_DLL int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata); -H5_DLL herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, - H5B2_node_info_test_t *ninfo); +H5_DLL int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata); +H5_DLL herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo); #endif /* H5B2_TESTING */ -#endif /* _H5B2pkg_H */ - +#endif /* H5B2pkg_H */ diff --git a/src/H5B2private.h b/src/H5B2private.h index 9303d4f281d..21ea8236fa2 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,38 +22,42 @@ *------------------------------------------------------------------------- */ -#ifndef _H5B2private_H -#define _H5B2private_H +#ifndef H5B2private_H +#define H5B2private_H /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* B-tree IDs for various internal things. */ typedef enum H5B2_subid_t { - H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ - H5B2_FHEAP_HUGE_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects */ - H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects */ - H5B2_FHEAP_HUGE_DIR_ID, /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */ + H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ + H5B2_FHEAP_HUGE_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, non-filtered 'huge' objects + */ + H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* B-tree is for fractal heap indirectly accessed, filtered 'huge' objects + */ + H5B2_FHEAP_HUGE_DIR_ID, /* B-tree is for fractal heap directly accessed, non-filtered 'huge' objects */ H5B2_FHEAP_HUGE_FILT_DIR_ID, /* B-tree is for fractal heap directly accessed, filtered 'huge' objects */ - H5B2_GRP_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" link storage in groups */ - H5B2_GRP_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" link storage in groups */ - H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ - H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects */ - H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage on objects */ - H5B2_CDSET_ID, /* B-tree is for non-filtered chunked dataset storage w/ >1 unlim dims */ - H5B2_CDSET_FILT_ID, /* B-tree is for filtered chunked dataset storage w/ >1 unlim dims */ - H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ - H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ + H5B2_GRP_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" link storage in groups */ + H5B2_GRP_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" link storage in + groups */ + H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ + H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects + */ + H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage + on objects */ + H5B2_CDSET_ID, /* B-tree is for non-filtered chunked dataset storage w/ >1 unlim dims */ + H5B2_CDSET_FILT_ID, /* B-tree is for filtered chunked dataset storage w/ >1 unlim dims */ + H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ + H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ } H5B2_subid_t; /* Define the operator callback function pointer for H5B2_iterate() */ @@ -70,8 +74,8 @@ typedef herr_t (*H5B2_remove_t)(const void *record, void *op_data); /* Comparisons for H5B2_neighbor() call */ typedef enum H5B2_compare_t { - H5B2_COMPARE_LESS, /* Records with keys less than query value */ - H5B2_COMPARE_GREATER /* Records with keys greater than query value */ + H5B2_COMPARE_LESS, /* Records with keys less than query value */ + H5B2_COMPARE_GREATER /* Records with keys greater than query value */ } H5B2_compare_t; /* @@ -80,77 +84,69 @@ 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 */ - size_t nrec_size; /* Size of native (memory) record */ + H5B2_subid_t id; /* ID of B-tree class, as found in file */ + const char * name; /* Name of B-tree class, for debugging */ + size_t nrec_size; /* Size of native (memory) record */ /* Extensible array client callback methods */ - void *(*crt_context)(void *udata); /* Create context for other client callbacks */ - herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ - herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ + void *(*crt_context)(void *udata); /* Create context for other client callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy client callback context */ + herr_t (*store)(void *nrecord, const void *udata); /* Store application record in native record table */ herr_t (*compare)(const void *rec1, const void *rec2, int *result); /* Compare two native records */ - herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */ - herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ - const void *record, const void *ctx); + herr_t (*encode)(uint8_t *raw, const void *record, + void *ctx); /* Encode record from native form to disk storage form */ + herr_t (*decode)(const uint8_t *raw, void *record, + void *ctx); /* Decode record from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ + const void *record, const void *ctx); }; /* v2 B-tree creation parameters */ typedef struct H5B2_create_t { - const H5B2_class_t *cls; /* v2 B-tree client class */ - uint32_t node_size; /* Size of each node (in bytes) */ - uint32_t rrec_size; /* Size of raw record (in bytes) */ - uint8_t split_percent; /* % full to split nodes */ - uint8_t merge_percent; /* % full to merge nodes */ + const H5B2_class_t *cls; /* v2 B-tree client class */ + uint32_t node_size; /* Size of each node (in bytes) */ + uint32_t rrec_size; /* Size of raw record (in bytes) */ + uint8_t split_percent; /* % full to split nodes */ + uint8_t merge_percent; /* % full to merge nodes */ } H5B2_create_t; /* v2 B-tree metadata statistics info */ typedef struct H5B2_stat_t { - unsigned depth; /* Depth of B-tree */ - hsize_t nrecords; /* Number of records */ + unsigned depth; /* Depth of B-tree */ + hsize_t nrecords; /* Number of records */ } H5B2_stat_t; /* v2 B-tree info (forward decl - defined in H5B2pkg.h) */ typedef struct H5B2_t H5B2_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL H5B2_t *H5B2_create(H5F_t *f, const H5B2_create_t *cparam, - void *ctx_udata); +H5_DLL H5B2_t *H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata); H5_DLL H5B2_t *H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata); -H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr/*out*/); -H5_DLL herr_t H5B2_insert(H5B2_t *bt2, void *udata); -H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data); -H5_DLL htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, - H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, - H5B2_found_t op, void *op_data); -H5_DLL herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, - void *op_data); -H5_DLL herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, - void *op_data); -H5_DLL herr_t H5B2_remove(H5B2_t *b2, void *udata, H5B2_remove_t op, - void *op_data); -H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, - hsize_t idx, H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); -H5_DLL herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size); -H5_DLL herr_t H5B2_close(H5B2_t *bt2); -H5_DLL herr_t H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, - H5B2_remove_t op, void *op_data); -H5_DLL herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); +H5_DLL herr_t H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr /*out*/); +H5_DLL herr_t H5B2_insert(H5B2_t *bt2, void *udata); +H5_DLL herr_t H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data); +H5_DLL htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data); +H5_DLL herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_remove(H5B2_t *b2, void *udata, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_remove_t op, + void *op_data); +H5_DLL herr_t H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec); +H5_DLL herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size); +H5_DLL herr_t H5B2_close(H5B2_t *bt2); +H5_DLL herr_t H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2_depend(H5B2_t *bt2, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); -#endif /* _H5B2private_H */ - +#endif /* H5B2private_H */ diff --git a/src/H5B2stat.c b/src/H5B2stat.c index 5c09b3d225d..47352761d92 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,52 +22,43 @@ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5B2_stat_info * @@ -89,13 +80,12 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) HDassert(info); /* Get information about the B-tree */ - info->depth = bt2->hdr->depth; + info->depth = bt2->hdr->depth; info->nrecords = bt2->hdr->root.all_nrec; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2_stat_info() */ - /*------------------------------------------------------------------------- * Function: H5B2_size * @@ -112,8 +102,8 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) herr_t H5B2_size(H5B2_t *bt2, hsize_t *btree_size) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -131,17 +121,16 @@ H5B2_size(H5B2_t *bt2, hsize_t *btree_size) *btree_size += hdr->hdr_size; /* Iterate through records */ - if(hdr->root.node_nrec > 0) { + if (hdr->root.node_nrec > 0) { /* Check for root node being a leaf */ - if(hdr->depth == 0) + if (hdr->depth == 0) *btree_size += hdr->node_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") + if (H5B2__node_size(hdr, hdr->depth, &hdr->root, hdr, btree_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_size() */ - diff --git a/src/H5B2test.c b/src/H5B2test.c index ee37c5451d2..2b84332b1d2 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,113 +18,102 @@ * */ - /****************/ /* Module Setup */ /****************/ -#include "H5B2module.h" /* This source code file is part of the H5B2 module */ -#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ - +#include "H5B2module.h" /* This source code file is part of the H5B2 module */ +#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* v2 B-tree client callback context */ typedef struct H5B2_test_ctx_t { - uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_size; /* Size of file sizes */ } H5B2_test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 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); static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'test2' B-trees */ static herr_t H5B2__test2_store(void *nrecord, const void *udata); static herr_t H5B2__test2_compare(const void *rec1, const void *rec2, int *result); static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); - +static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* Class structure for testing simple B-tree records */ -const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ - H5B2_TEST_ID, /* Type of B-tree */ - "H5B2_TEST_ID", /* Name of B-tree class */ - sizeof(hsize_t), /* Size of native record */ - H5B2__test_crt_context, /* Create client callback context */ - H5B2__test_dst_context, /* Destroy client callback context */ - H5B2__test_store, /* Record storage callback */ - H5B2__test_compare, /* Record comparison callback */ - H5B2__test_encode, /* Record encoding callback */ - H5B2__test_decode, /* Record decoding callback */ - H5B2__test_debug /* Record debugging callback */ +const H5B2_class_t H5B2_TEST[1] = {{ + /* B-tree class information */ + H5B2_TEST_ID, /* Type of B-tree */ + "H5B2_TEST_ID", /* Name of B-tree class */ + sizeof(hsize_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test_store, /* Record storage callback */ + H5B2__test_compare, /* Record comparison callback */ + H5B2__test_encode, /* Record encoding callback */ + H5B2__test_decode, /* Record decoding callback */ + H5B2__test_debug /* Record debugging callback */ }}; /* Class structure for testing key/value B-tree records */ -const H5B2_class_t H5B2_TEST2[1]={{ /* B-tree class information */ - H5B2_TEST2_ID, /* Type of B-tree */ - "H5B2_TEST2_ID", /* Name of B-tree class */ - sizeof(H5B2_test_rec_t), /* Size of native record */ - H5B2__test_crt_context, /* Create client callback context */ - H5B2__test_dst_context, /* Destroy client callback context */ - H5B2__test2_store, /* Record storage callback */ - H5B2__test2_compare, /* Record comparison callback */ - H5B2__test2_encode, /* Record encoding callback */ - H5B2__test2_decode, /* Record decoding callback */ - H5B2__test2_debug /* Record debugging callback */ +const H5B2_class_t H5B2_TEST2[1] = {{ + /* B-tree class information */ + H5B2_TEST2_ID, /* Type of B-tree */ + "H5B2_TEST2_ID", /* Name of B-tree class */ + sizeof(H5B2_test_rec_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test2_store, /* Record storage callback */ + H5B2__test2_compare, /* Record comparison callback */ + H5B2__test2_encode, /* Record encoding callback */ + H5B2__test2_decode, /* Record decoding callback */ + H5B2__test2_debug /* Record debugging callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /* Declare a free list to manage the H5B2_test_ctx_t struct */ H5FL_DEFINE_STATIC(H5B2_test_ctx_t); - /*------------------------------------------------------------------------- * Function: H5B2__test_crt_context * @@ -141,9 +130,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 */ - H5B2_test_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -151,7 +140,7 @@ H5B2__test_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of lengths in the file */ @@ -164,7 +153,6 @@ H5B2__test_crt_context(void *_f) FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_dst_context * @@ -181,7 +169,7 @@ H5B2__test_crt_context(void *_f) static herr_t H5B2__test_dst_context(void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -194,7 +182,6 @@ H5B2__test_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_store * @@ -218,7 +205,6 @@ H5B2__test_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_store() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_compare * @@ -243,7 +229,6 @@ H5B2__test_compare(const void *rec1, const void *rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_compare() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_encode * @@ -260,7 +245,7 @@ H5B2__test_compare(const void *rec1, const void *rec2, int *result) static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -272,7 +257,6 @@ H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_decode * @@ -289,7 +273,7 @@ H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -301,7 +285,6 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test_debug * @@ -316,20 +299,17 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, - const void H5_ATTR_UNUSED *_udata) +H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR HDassert(record); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Record:", - *(const hsize_t *)record); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Record:", *(const hsize_t *)record); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_store * @@ -353,7 +333,6 @@ H5B2__test2_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_store() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_compare * @@ -378,7 +357,6 @@ H5B2__test2_compare(const void *rec1, const void *rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_compare() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_encode * @@ -395,7 +373,7 @@ H5B2__test2_compare(const void *rec1, const void *rec2, int *result) static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -408,7 +386,6 @@ H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_encode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_decode * @@ -425,7 +402,7 @@ H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) { - H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ FUNC_ENTER_STATIC_NOERR @@ -438,7 +415,6 @@ H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_decode() */ - /*------------------------------------------------------------------------- * Function: H5B2__test2_debug * @@ -453,21 +429,18 @@ H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, - const void H5_ATTR_UNUSED *_udata) +H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR HDassert(record); - HDfprintf(stream, "%*s%-*s (%Hu, %Hu)\n", indent, "", fwidth, "Record:", - ((const H5B2_test_rec_t *)record)->key, - ((const H5B2_test_rec_t *)record)->val); + HDfprintf(stream, "%*s%-*s (%" PRIuHSIZE ", %" PRIuHSIZE ")\n", indent, "", fwidth, + "Record:", ((const H5B2_test_rec_t *)record)->key, ((const H5B2_test_rec_t *)record)->val); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_debug() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_root_addr_test * @@ -495,7 +468,6 @@ H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__get_root_addr_test() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_node_info_test * @@ -511,13 +483,13 @@ 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_node_ptr_t curr_node_ptr; /* Node pointer info for 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint16_t depth; /* Current depth of the tree */ + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -533,52 +505,54 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) /* Make copy of the root node pointer to start search with */ curr_node_ptr = hdr->root; - /* Set initial parent, if doing swmr writes */ - if(hdr->swmr_write) + /* Set initial parent, if doing swmr writes */ + if (hdr->swmr_write) parent = hdr; /* Current depth of the tree */ depth = hdr->depth; /* Check for empty tree */ - if(0 == curr_node_ptr.node_nrec) + if (0 == curr_node_ptr.node_nrec) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree has no records") /* Walk down B-tree to find record or leaf node where record is located */ cmp = -1; - while(depth > 0 && cmp != 0) { - H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ - H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ + while (depth > 0 && cmp != 0) { + H5B2_internal_t *internal; /* Pointer to internal node in B-tree */ + H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */ /* Lock B-tree current node */ - if(NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (internal = H5B2__protect_internal(hdr, parent, &curr_node_ptr, depth, FALSE, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate node pointer for child */ - if(H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx, + &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") - if(cmp > 0) + if (cmp > 0) idx++; - if(cmp != 0) { + if (cmp != 0) { /* Get node pointer for next node to search */ next_node_ptr = internal->node_ptrs[idx]; /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, + (unsigned)(hdr->swmr_write ? H5AC__PIN_ENTRY_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Keep track of parent if necessary */ - if(hdr->swmr_write) + if (hdr->swmr_write) parent = internal; /* Set pointer to next node to load */ @@ -586,12 +560,12 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) } /* end if */ else { /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Fill in information about the node */ ninfo->depth = depth; - ninfo->nrec = curr_node_ptr.node_nrec; + ninfo->nrec = curr_node_ptr.node_nrec; /* Indicate success */ HGOTO_DONE(SUCCEED) @@ -602,48 +576,46 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) } /* end while */ { - H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) + if (NULL == (leaf = H5B2__protect_leaf(hdr, parent, &curr_node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") /* Unpin parent if necessary */ - if(parent) { - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent) { + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") parent = NULL; } /* end if */ /* Locate record */ - if(H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, - udata, &idx, &cmp) < 0) + if (H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx, &cmp) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Unlock current node */ - if(H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Indicate the depth that the record was found */ - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "record not in B-tree") } /* end block */ /* Fill in information about the leaf node */ ninfo->depth = depth; - ninfo->nrec = curr_node_ptr.node_nrec; + ninfo->nrec = curr_node_ptr.node_nrec; done: - if(parent) { + if (parent) { HDassert(ret_value < 0); - if(parent != hdr && H5AC_unpin_entry(parent) < 0) + if (parent != hdr && H5AC_unpin_entry(parent) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__get_node_info_test() */ - /*------------------------------------------------------------------------- * Function: H5B2__get_node_depth_test * @@ -664,8 +636,8 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) int H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) { - H5B2_node_info_test_t ninfo; /* Node information */ - int ret_value = -1; /* Return information */ + H5B2_node_info_test_t ninfo; /* Node information */ + int ret_value = -1; /* Return information */ FUNC_ENTER_PACKAGE @@ -673,7 +645,7 @@ H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) HDassert(bt2); /* Get information abou the node */ - if(H5B2__get_node_info_test(bt2, udata, &ninfo) < 0) + if (H5B2__get_node_info_test(bt2, udata, &ninfo) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, (-1), "error looking up node info") /* Set return value */ @@ -682,4 +654,3 @@ H5B2__get_node_depth_test(H5B2_t *bt2, void *udata) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__get_node_depth_test() */ - diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 80fb200ec1a..ec7457f9c2a 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,70 +26,61 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* 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_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B__cache_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5B inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_BT[1] = {{ - H5AC_BT_ID, /* Metadata client ID */ - "v1 B-tree", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5B__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5B__cache_deserialize, /* 'deserialize' callback */ - H5B__cache_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5B__cache_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5B__cache_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_BT_ID, /* Metadata client ID */ + "v1 B-tree", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5B__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5B__cache_deserialize, /* 'deserialize' callback */ + H5B__cache_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5B__cache_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5B__cache_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5B__cache_get_initial_load_size * @@ -105,8 +96,8 @@ const H5AC_class_t H5AC_BT[1] = {{ 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_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ + H5B_shared_t * shared; /* Pointer to shared B-tree info */ FUNC_ENTER_STATIC_NOERR @@ -124,7 +115,6 @@ H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__cache_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_deserialize * @@ -140,15 +130,15 @@ H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) */ static void * H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - 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 */ - unsigned u; /* Local index variable */ - H5B_t *ret_value = NULL; /* Return value */ + 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 */ + unsigned u; /* Local index variable */ + H5B_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -157,8 +147,8 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda HDassert(udata); /* Allocate the B-tree node in memory */ - if(NULL == (bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct") + if (NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct") HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); /* Set & increment the ref-counted "shared" B-tree information for the node */ @@ -170,26 +160,26 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda HDassert(shared); /* Allocate space for the native keys and child addresses */ - if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for native keys") - if(NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for child addresses") + if (NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for native keys") + if (NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate buffer for child addresses") /* magic number */ - if(HDmemcmp(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree signature") + if (HDmemcmp(image, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree signature") image += H5_SIZEOF_MAGIC; /* node type and level */ - if(*image++ != (uint8_t)udata->type->id) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") + if (*image++ != (uint8_t)udata->type->id) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *image++; /* entries used */ UINT16DECODE(image, bt->nchildren); /* Check if bt->nchildren is greater than two_k */ - if(bt->nchildren > shared->two_k) + if (bt->nchildren > shared->two_k) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "number of children is greater than maximum") /* sibling pointers */ @@ -198,9 +188,9 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda /* the child/key pairs */ native = bt->native; - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* Decode native key value */ - if((udata->type->decode)(shared, image, native) < 0) + if ((udata->type->decode)(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") image += shared->sizeof_rkey; native += udata->type->sizeof_nkey; @@ -210,9 +200,9 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda } /* end for */ /* Decode final key */ - if(bt->nchildren > 0) { + if (bt->nchildren > 0) { /* Decode native key value */ - if((udata->type->decode)(shared, image, native) < 0) + if ((udata->type->decode)(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ @@ -223,14 +213,13 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda ret_value = bt; done: - if(!ret_value && bt) - if(H5B__node_dest(bt) < 0) + if (!ret_value && bt) + if (H5B__node_dest(bt) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_image_len * @@ -246,8 +235,8 @@ 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 */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + 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 @@ -265,7 +254,6 @@ H5B__cache_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B__cache_image_len() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_serialize * @@ -279,15 +267,14 @@ 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__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_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 */ - unsigned u; /* Local index counter */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned u; /* Local index counter */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -308,8 +295,8 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, *image++ = (uint8_t)shared->type->id; /* 2^8 limit: only 1 byte is used to store node level */ - if(bt->level >= HDpow(2, LEVEL_BITS)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level") + if (bt->level >= HDpow(2, LEVEL_BITS)) + HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level") H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t); *image++ = (uint8_t)bt->level; @@ -323,9 +310,9 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, /* child keys and pointers */ native = bt->native; - for(u = 0; u < bt->nchildren; ++u) { + for (u = 0; u < bt->nchildren; ++u) { /* encode the key */ - if(shared->type->encode(shared, image, native) < 0) + if (shared->type->encode(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") image += shared->sizeof_rkey; native += shared->type->sizeof_nkey; @@ -333,9 +320,9 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, /* encode the child address */ H5F_addr_encode(f, &image, bt->child[u]); } /* end for */ - if(bt->nchildren > 0) { + if (bt->nchildren > 0) { /* Encode the final key */ - if(shared->type->encode(shared, image, native) < 0) + if (shared->type->encode(shared, image, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key") image += shared->sizeof_rkey; } /* end if */ @@ -350,7 +337,6 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_serialize() */ - /*------------------------------------------------------------------------- * Function: H5B__cache_free_icr * @@ -366,7 +352,7 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, static herr_t H5B__cache_free_icr(void *thing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -374,10 +360,9 @@ H5B__cache_free_icr(void *thing) HDassert(thing); /* Destroy B-tree node */ - if(H5B__node_dest((H5B_t *)thing) < 0) + if (H5B__node_dest((H5B_t *)thing) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_free_icr() */ - diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index d90085276f5..23d0a8f6920 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,19 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Bmodule.h" /* This source code file is part of the H5B module */ - +#include "H5Bmodule.h" /* This source code file is part of the H5B module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ - /*------------------------------------------------------------------------- * Function: H5B_debug * @@ -54,12 +51,12 @@ 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -77,7 +74,7 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 HDassert(!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)); /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); @@ -85,73 +82,59 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 /* * Load the tree node. */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* * Print the values. */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", + ((shared->type->id) == H5B_SNODE_ID + ? "H5B_SNODE_ID" + : ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Size of node:", shared->sizeof_rnode); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Size of raw (disk) key:", shared->sizeof_rkey); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Tree type ID:", - ((shared->type->id) == H5B_SNODE_ID ? "H5B_SNODE_ID" : - ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of node:", - shared->sizeof_rnode); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of raw (disk) key:", - shared->sizeof_rkey); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - bt->cache_info.is_dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Level:", - bt->level); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of left sibling:", - bt->left); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of right sibling:", - bt->right); - HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, - "Number of children (max):", - bt->nchildren, shared->two_k); + "Dirty flag:", bt->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Level:", bt->level); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Address of left sibling:", bt->left); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Address of right sibling:", bt->right); + HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of children (max):", bt->nchildren, + shared->two_k); /* * Print the child addresses */ - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { HDfprintf(stream, "%*sChild %d...\n", indent, "", u); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", bt->child[u]); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(0, 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) { + if (type->debug_key) { /* Decode the 'left' key & print it */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - "Left Key:"); - HDassert(H5B_NKEY(bt,shared,u)); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, 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); /* 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(0, 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), udata); + (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u + 1), + udata); } /* end if */ - } /* end for */ + } /* end for */ done: - if(bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_debug() */ - /*------------------------------------------------------------------------- * Function: H5B__assert * @@ -170,52 +153,52 @@ 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_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - int ncell, cmp; - static int ncalls = 0; - herr_t status; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t status; + herr_t ret_value = SUCCEED; /* Return value */ /* A queue of child data */ struct child_t { - haddr_t addr; - unsigned level; - struct child_t *next; + haddr_t addr; + unsigned level; + struct child_t *next; } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL; FUNC_ENTER_PACKAGE - if(0 == ncalls++) { - if(H5DEBUG(B)) + if (0 == ncalls++) { + if (H5DEBUG(B)) HDfprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n"); } /* end if */ /* Get shared info for B-tree */ - if(NULL == (rc_shared = (type->get_shared)(f, udata))) + if (NULL == (rc_shared = (type->get_shared)(f, udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") shared = (H5B_shared_t *)H5UC_GET_OBJ(rc_shared); HDassert(shared); /* Initialize the queue */ - cache_udata.f = f; - cache_udata.type = type; + cache_udata.f = f; + cache_udata.type = type; cache_udata.rc_shared = rc_shared; - bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG); + bt = (H5B_t *)H5AC_protect(f, H5AC_BT, addr, &cache_udata, H5AC__READ_ONLY_FLAG); HDassert(bt); shared = (H5B_shared_t *)H5UC_GET_OBJ(bt->rc_shared); HDassert(shared); cur = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(cur); - cur->addr = addr; + cur->addr = addr; cur->level = bt->level; head = tail = cur; status = H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET); HDassert(status >= 0); - bt = NULL; /* Make certain future references will be caught */ + bt = NULL; /* Make certain future references will be caught */ /* * Do a breadth-first search of the tree. New nodes are added to the end @@ -223,58 +206,58 @@ H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) * remove any nodes from the queue because we need them in the uniqueness * test. */ - for(ncell = 0; cur; ncell++) { + for (ncell = 0; cur; ncell++) { bt = (H5B_t *)H5AC_protect(f, H5AC_BT, cur->addr, &cache_udata, H5AC__READ_ONLY_FLAG); HDassert(bt); /* Check node header */ HDassert(bt->level == cur->level); - if(cur->next && cur->next->level == bt->level) + if (cur->next && cur->next->level == bt->level) HDassert(H5F_addr_eq(bt->right, cur->next->addr)); else HDassert(!H5F_addr_defined(bt->right)); - if(prev && prev->level == bt->level) + if (prev && prev->level == bt->level) HDassert(H5F_addr_eq(bt->left, prev->addr)); else HDassert(!H5F_addr_defined(bt->left)); - if(cur->level > 0) { + if (cur->level > 0) { unsigned u; - for(u = 0; u < bt->nchildren; u++) { + for (u = 0; u < bt->nchildren; u++) { /* * Check that child nodes haven't already been seen. If they * have then the tree has a cycle. */ - for(tmp = head; tmp; tmp = tmp->next) + for (tmp = head; tmp; tmp = tmp->next) HDassert(H5F_addr_ne(tmp->addr, bt->child[u])); /* Add the child node to the end of the queue */ tmp = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(tmp); - tmp->addr = bt->child[u]; + tmp->addr = bt->child[u]; tmp->level = bt->level - 1; tail->next = tmp; - tail = tmp; + tail = tmp; /* Check that the keys are monotonically increasing */ cmp = (type->cmp2)(H5B_NKEY(bt, shared, u), udata, H5B_NKEY(bt, shared, u + 1)); HDassert(cmp < 0); } /* end for */ - } /* end if */ + } /* end if */ /* Release node */ status = H5AC_unprotect(f, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET); HDassert(status >= 0); - bt = NULL; /* Make certain future references will be caught */ + bt = NULL; /* Make certain future references will be caught */ /* Advance current location in queue */ prev = cur; - cur = cur->next; + cur = cur->next; } /* end for */ /* Free all entries from queue */ - while(head) { + while (head) { tmp = head->next; H5MM_xfree(head); head = tmp; @@ -284,4 +267,3 @@ H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__assert() */ #endif /* H5B_DEBUG */ - diff --git a/src/H5Bmodule.h b/src/H5Bmodule.h index c8e1546e570..cfd3d534c36 100644 --- a/src/H5Bmodule.h +++ b/src/H5Bmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5B package. Including this header means that the source file * is part of the H5B package. */ -#ifndef _H5Bmodule_H -#define _H5Bmodule_H +#ifndef H5Bmodule_H +#define H5Bmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5B_MODULE -#define H5_MY_PKG H5B -#define H5_MY_PKG_ERR H5E_BTREE -#define H5_MY_PKG_INIT NO - -#endif /* _H5Bmodule_H */ +#define H5_MY_PKG H5B +#define H5_MY_PKG_ERR H5E_BTREE +#define H5_MY_PKG_INIT NO +#endif /* H5Bmodule_H */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index a57584e9d4d..0a796283da3 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -6,42 +6,40 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 - * Thursday, May 15, 2003 + * Programmer: Quincey Koziol + * Thursday, May 15, 2003 * - * Purpose: This file contains declarations which are visible only within - * the H5B package. Source files outside the H5B package should - * include H5Bprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5B package. Source files outside the H5B package should + * include H5Bprivate.h instead. */ #if !(defined H5B_FRIEND || defined H5B_MODULE) #error "Do not include this file outside the H5B package!" #endif -#ifndef _H5Bpkg_H -#define _H5Bpkg_H +#ifndef H5Bpkg_H +#define H5Bpkg_H /* Get package's private header */ #include "H5Bprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Get the native key at a given index */ -#define H5B_NKEY(b, shared, idx) ((b)->native + (shared)->nkey[(idx)]) -#define LEVEL_BITS 8 /* # of bits for node level: 1 byte */ - +#define H5B_NKEY(b, shared, idx) ((b)->native + (shared)->nkey[(idx)]) +#define LEVEL_BITS 8 /* # of bits for node level: 1 byte */ /****************************/ /* Package Private Typedefs */ @@ -49,22 +47,22 @@ /* The B-tree node as stored in memory... */ 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 */ - unsigned level; /*node level */ - unsigned nchildren; /*number of child pointers */ - haddr_t left; /*address of left sibling */ - haddr_t right; /*address of right sibling */ - uint8_t *native; /*array of keys in native format */ - haddr_t *child; /*2k child pointers */ + H5AC_info_t cache_info; /* Information for H5AC cache functions */ + /* _must_ be first field in structure */ + 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 */ + haddr_t right; /*address of right sibling */ + uint8_t *native; /*array of keys in native format */ + haddr_t *child; /*2k child pointers */ } 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 */ - const struct H5B_class_t *type; /* Type of tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ + 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 */ } H5B_cache_ud_t; /*****************************/ @@ -80,7 +78,6 @@ H5FL_BLK_EXTERN(native_block); /* Declare a free list to manage the H5B_t struct */ H5FL_EXTERN(H5B_t); - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -89,5 +86,4 @@ H5_DLL herr_t H5B__node_dest(H5B_t *bt); herr_t H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata); #endif -#endif /*_H5Bpkg_H*/ - +#endif /*H5Bpkg_H*/ diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 55bf5b3a521..265b6c67f5b 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,14 +22,13 @@ *------------------------------------------------------------------------- */ -#ifndef _H5Bprivate_H -#define _H5Bprivate_H - +#ifndef H5Bprivate_H +#define H5Bprivate_H /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5UCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5UCprivate.h" /* Reference counted object functions */ /**************************/ /* Library Private Macros */ @@ -42,10 +41,9 @@ * being enabled. */ #ifdef NDEBUG -# undef H5B_DEBUG +#undef H5B_DEBUG #endif - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -55,47 +53,46 @@ * nodes) they use will need to be stored in the file somewhere. -QAK */ typedef enum H5B_subid_t { - H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ - H5B_CHUNK_ID = 1, /*B-tree is for chunked dataset storage */ - H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ + H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ + H5B_CHUNK_ID = 1, /*B-tree is for chunked dataset storage */ + H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ } H5B_subid_t; /* Define return values from B-tree insertion callbacks */ typedef enum H5B_ins_t { - H5B_INS_ERROR = -1, /*error return value */ - H5B_INS_NOOP = 0, /*insert made no changes */ - H5B_INS_LEFT = 1, /*insert new node to left of cur node */ - H5B_INS_RIGHT = 2, /*insert new node to right of cur node */ - H5B_INS_CHANGE = 3, /*change child address for cur node */ - H5B_INS_FIRST = 4, /*insert first node in (sub)tree */ - H5B_INS_REMOVE = 5 /*remove current node */ + H5B_INS_ERROR = -1, /*error return value */ + H5B_INS_NOOP = 0, /*insert made no changes */ + H5B_INS_LEFT = 1, /*insert new node to left of cur node */ + H5B_INS_RIGHT = 2, /*insert new node to right of cur node */ + H5B_INS_CHANGE = 3, /*change child address for cur node */ + H5B_INS_FIRST = 4, /*insert first node in (sub)tree */ + H5B_INS_REMOVE = 5 /*remove current node */ } H5B_ins_t; /* Enum for specifying the direction of the critical key in relation to the * child */ typedef enum H5B_dir_t { - H5B_LEFT = 0, /* Critical key is to the left */ - H5B_RIGHT = 1 /* Critical key is to the right */ + H5B_LEFT = 0, /* Critical key is to the left */ + H5B_RIGHT = 1 /* Critical key is to the right */ } H5B_dir_t; /* Define the operator callback function pointer for H5B_iterate() */ -typedef int (*H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); +typedef int (*H5B_operator_t)(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); /* Each B-tree has certain information that can be shared across all * the instances of nodes in that B-tree. */ typedef struct H5B_shared_t { - const struct H5B_class_t *type; /* Type of tree */ - unsigned two_k; /* 2*"K" value for tree's nodes */ - size_t sizeof_rkey; /* Size of raw (disk) key */ - size_t sizeof_rnode; /* Size of raw (disk) node */ - 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 */ + const struct H5B_class_t *type; /* Type of tree */ + unsigned two_k; /* 2*"K" value for tree's nodes */ + size_t sizeof_rkey; /* Size of raw (disk) key */ + size_t sizeof_rnode; /* Size of raw (disk) node */ + 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 */ } H5B_shared_t; /* @@ -107,69 +104,57 @@ typedef struct H5B_shared_t { */ typedef struct H5B_class_t { - H5B_subid_t id; /*id as found in file*/ - size_t sizeof_nkey; /*size of native (memory) key*/ - H5UC_t * (*get_shared)(const H5F_t*, const void*); /*shared info for node */ - herr_t (*new_node)(H5F_t*, H5B_ins_t, void*, void*, void*, haddr_t*); - int (*cmp2)(void*, void*, void*); /*compare 2 keys */ - int (*cmp3)(void*, void*, void*); /*compare 3 keys */ - htri_t (*found)(H5F_t*, haddr_t, const void*, void*); + H5B_subid_t id; /*id as found in file*/ + size_t sizeof_nkey; /*size of native (memory) key*/ + H5UC_t *(*get_shared)(const H5F_t *, const void *); /*shared info for node */ + herr_t (*new_node)(H5F_t *, H5B_ins_t, void *, void *, void *, haddr_t *); + int (*cmp2)(void *, void *, void *); /*compare 2 keys */ + int (*cmp3)(void *, void *, void *); /*compare 3 keys */ + htri_t (*found)(H5F_t *, haddr_t, const void *, void *); /* insert new data */ - H5B_ins_t (*insert)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*, - void*, hbool_t*, haddr_t*); + H5B_ins_t (*insert)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, void *, hbool_t *, haddr_t *); /* min insert uses min leaf, not new(), similarly for max insert */ - hbool_t follow_min; - hbool_t follow_max; + hbool_t follow_min; + hbool_t follow_max; /* The direction of the key that is intrinsically associated with each node */ - H5B_dir_t critical_key; + H5B_dir_t critical_key; /* remove existing data */ - H5B_ins_t (*remove)(H5F_t*, haddr_t, void*, hbool_t*, void*, void*, hbool_t*); + H5B_ins_t (*remove)(H5F_t *, haddr_t, void *, hbool_t *, void *, void *, hbool_t *); /* encode, decode, debug key values */ - herr_t (*decode)(const H5B_shared_t*, const uint8_t*, void*); - herr_t (*encode)(const H5B_shared_t*, uint8_t*, const void*); - herr_t (*debug_key)(FILE*, int, int, const void*, const void*); + herr_t (*decode)(const H5B_shared_t *, const uint8_t *, void *); + herr_t (*encode)(const H5B_shared_t *, uint8_t *, const void *); + herr_t (*debug_key)(FILE *, int, int, const void *, const void *); } H5B_class_t; /* Information about B-tree */ typedef struct H5B_info_t { - hsize_t size; /* Size of B-tree nodes */ - hsize_t num_nodes; /* Number of B-tree nodes */ + hsize_t size; /* Size of B-tree nodes */ + hsize_t num_nodes; /* Number of B-tree nodes */ } H5B_info_t; - - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, - haddr_t *addr_p/*out*/); -H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_operator_t op, void *udata); -H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, - H5B_info_t *bt_info, H5B_operator_t op, void *udata); -H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, - void *udata); -H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type, - size_t sizeof_rkey); -H5_DLL herr_t H5B_shared_free(void *_shared); -H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE * stream, - int indent, int fwidth, const H5B_class_t *type, void *udata); +H5_DLL herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out*/); +H5_DLL herr_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_iterate(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata); +H5_DLL herr_t H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_info, + H5B_operator_t op, void *udata); +H5_DLL herr_t H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata); +H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey); +H5_DLL herr_t H5B_shared_free(void *_shared); +H5_DLL herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, + void *udata); H5_DLL htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr); -#endif /* _H5Bprivate_H */ - +#endif /* H5Bprivate_H */ diff --git a/src/H5C.c b/src/H5C.c index 20182da0119..185b421b4d5 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,52 +19,35 @@ * * Purpose: Functions in this file implement a generic cache for * things which exist on disk, and which may be - * unambiguously referenced by their disk addresses. + * unambiguously referenced by their disk addresses. * - * The code in this module was initially written in - * support of a complete re-write of the metadata cache - * in H5AC.c However, other uses for the cache code - * suggested themselves, and thus this file was created - * in an attempt to support re-use. - * - * For a detailed overview of the cache, please see the - * header comment for H5C_t in H5Cpkg.h. + * For a detailed overview of the cache, please see the + * header comment for H5C_t in H5Cpkg.h. * *------------------------------------------------------------------------- */ /************************************************************************** * - * To Do: - * - * Code Changes: - * - * - Remove extra functionality in H5C__flush_single_entry()? - * - * - Change protect/unprotect to lock/unlock. + * To Do: * - * - Flush entries in increasing address order in - * H5C__make_space_in_cache(). + * Code Changes: * - * - Also in H5C__make_space_in_cache(), use high and low water marks - * to reduce the number of I/O calls. + * - Change protect/unprotect to lock/unlock. * - * - When flushing, attempt to combine contiguous entries to reduce - * I/O overhead. Can't do this just yet as some entries are not - * contiguous. Do this in parallel only or in serial as well? + * - Flush entries in increasing address order in + * H5C__make_space_in_cache(). * - * - Create MPI type for dirty objects when flushing in parallel. + * - Also in H5C__make_space_in_cache(), use high and low water marks + * to reduce the number of I/O calls. * - * - Now that TBBT routines aren't used, fix nodes in memory to - * point directly to the skip list node from the LRU list, eliminating - * skip list lookups when evicting objects from the cache. + * - When flushing, attempt to combine contiguous entries to reduce + * I/O overhead. Can't do this just yet as some entries are not + * contiguous. Do this in parallel only or in serial as well? * - * Tests: - * - * - Trim execution time. (This is no longer a major issue with the - * shift from the TBBT to a hash table for indexing.) - * - * - Add random tests. + * - Fix nodes in memory to point directly to the skip list node from + * the LRU list, eliminating skip list lookups when evicting objects + * from the cache. * **************************************************************************/ @@ -72,118 +55,104 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /* suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ #if H5C_DO_MEMORY_SANITY_CHECKS -#define H5C_IMAGE_EXTRA_SPACE 8 +#define H5C_IMAGE_EXTRA_SPACE 8 #define H5C_IMAGE_SANITY_VALUE "DeadBeef" #else /* H5C_DO_MEMORY_SANITY_CHECKS */ #define H5C_IMAGE_EXTRA_SPACE 0 #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - /******************/ /* Local Typedefs */ /******************/ +/* Alias for pointer to cache entry, for use when allocating sequences of them */ +typedef H5C_cache_entry_t *H5C_cache_entry_ptr_t; /********************/ /* Local Prototypes */ /********************/ -static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); +static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); -static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); static herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout(H5F_t * f, - double hit_rate, - enum H5C_resize_status * status_ptr, - size_t * new_max_cache_size_ptr, - hbool_t write_permitted); +static herr_t H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr); +static herr_t 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); +static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr); +static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr); -static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, - size_t old_entry_size, size_t new_entry_size); +static herr_t H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size); static herr_t 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); +static herr_t 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); -static void * H5C_load_entry(H5F_t * f, +static void *H5C__load_entry(H5F_t *f, #ifdef H5_HAVE_PARALLEL - hbool_t coll_access, + hbool_t coll_access, #endif /* H5_HAVE_PARALLEL */ - const H5C_class_t * type, - haddr_t addr, - void * udata); + const H5C_class_t *type, haddr_t addr, void *udata); -static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry); +static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry); -static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry); +static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry); static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring); -static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); - -static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t * type, - haddr_t addr, size_t *len, hbool_t actual); +static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); +static herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); +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); +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); +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); +static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, + const H5C_cache_entry_t *base_entry); #endif /* NDEBUG */ - /*********************/ /* Package Variables */ /*********************/ @@ -194,12 +163,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the tag info struct */ H5FL_DEFINE(H5C_tag_info_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -207,25 +174,23 @@ H5FL_DEFINE(H5C_tag_info_t); /* Declare a free list to manage the H5C_t struct */ H5FL_DEFINE_STATIC(H5C_t); -/* Declare a free list to manage flush dependency arrays */ -H5FL_BLK_DEFINE_STATIC(parent); - +/* Declare a free list to manage arrays of cache entries */ +H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); - /*------------------------------------------------------------------------- * Function: H5C_create * * Purpose: Allocate, initialize, and return the address of a new - * instance of H5C_t. + * instance of H5C_t. * - * In general, the max_cache_size parameter must be positive, - * and the min_clean_size parameter must lie in the closed - * interval [0, max_cache_size]. + * In general, the max_cache_size parameter must be positive, + * and the min_clean_size parameter must lie in the closed + * interval [0, max_cache_size]. * - * The check_write_permitted parameter must either be NULL, - * or point to a function of type H5C_write_permitted_func_t. - * If it is NULL, the cache will use the write_permitted - * flag to determine whether writes are permitted. + * The check_write_permitted parameter must either be NULL, + * or point to a function of type H5C_write_permitted_func_t. + * If it is NULL, the cache will use the write_permitted + * flag to determine whether writes are permitted. * * Return: Success: Pointer to the new instance. * @@ -301,219 +266,212 @@ H5FL_BLK_DEFINE_STATIC(parent); * * 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 + * 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_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 * -H5C_create(size_t max_cache_size, - size_t min_clean_size, - int max_type_id, - 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) +H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, + 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) { - int i; - H5C_t * cache_ptr = NULL; - H5C_t * ret_value = NULL; /* Return value */ + int i; + H5C_t *cache_ptr = NULL; + H5C_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - HDassert( max_cache_size >= H5C__MIN_MAX_CACHE_SIZE ); - HDassert( max_cache_size <= H5C__MAX_MAX_CACHE_SIZE ); - HDassert( min_clean_size <= max_cache_size ); + HDassert(max_cache_size >= H5C__MIN_MAX_CACHE_SIZE); + HDassert(max_cache_size <= H5C__MAX_MAX_CACHE_SIZE); + HDassert(min_clean_size <= max_cache_size); - HDassert( max_type_id >= 0 ); - HDassert( max_type_id < H5C__MAX_NUM_TYPE_IDS ); - HDassert( class_table_ptr ); + HDassert(max_type_id >= 0); + HDassert(max_type_id < H5C__MAX_NUM_TYPE_IDS); + HDassert(class_table_ptr); - for ( i = 0; i <= max_type_id; i++ ) { - HDassert( (class_table_ptr)[i] ); + for (i = 0; i <= max_type_id; i++) { + HDassert((class_table_ptr)[i]); HDassert(HDstrlen((class_table_ptr)[i]->name) > 0); } /* end for */ - if(NULL == (cache_ptr = H5FL_CALLOC(H5C_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (cache_ptr = H5FL_CALLOC(H5C_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + 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))) + 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") /* If we get this far, we should succeed. Go ahead and initialize all * the fields. */ - cache_ptr->magic = H5C__H5C_T_MAGIC; + cache_ptr->magic = H5C__H5C_T_MAGIC; - cache_ptr->flush_in_progress = FALSE; + cache_ptr->flush_in_progress = FALSE; - if(NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) + if (NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed") - cache_ptr->aux_ptr = aux_ptr; + cache_ptr->aux_ptr = aux_ptr; - cache_ptr->max_type_id = max_type_id; + cache_ptr->max_type_id = max_type_id; - cache_ptr->class_table_ptr = class_table_ptr; + cache_ptr->class_table_ptr = class_table_ptr; - cache_ptr->max_cache_size = max_cache_size; - cache_ptr->min_clean_size = min_clean_size; + cache_ptr->max_cache_size = max_cache_size; + cache_ptr->min_clean_size = min_clean_size; - cache_ptr->check_write_permitted = check_write_permitted; - cache_ptr->write_permitted = write_permitted; + cache_ptr->check_write_permitted = check_write_permitted; + cache_ptr->write_permitted = write_permitted; - cache_ptr->log_flush = log_flush; + cache_ptr->log_flush = log_flush; - cache_ptr->evictions_enabled = TRUE; - cache_ptr->close_warning_received = FALSE; + cache_ptr->evictions_enabled = TRUE; + cache_ptr->close_warning_received = FALSE; - cache_ptr->index_len = 0; - cache_ptr->index_size = (size_t)0; - cache_ptr->clean_index_size = (size_t)0; - cache_ptr->dirty_index_size = (size_t)0; + cache_ptr->index_len = 0; + cache_ptr->index_size = (size_t)0; + cache_ptr->clean_index_size = (size_t)0; + cache_ptr->dirty_index_size = (size_t)0; - for(i = 0; i < H5C_RING_NTYPES; i++) { - cache_ptr->index_ring_len[i] = 0; - cache_ptr->index_ring_size[i] = (size_t)0; - cache_ptr->clean_index_ring_size[i] = (size_t)0; - cache_ptr->dirty_index_ring_size[i] = (size_t)0; + for (i = 0; i < H5C_RING_NTYPES; i++) { + cache_ptr->index_ring_len[i] = 0; + cache_ptr->index_ring_size[i] = (size_t)0; + cache_ptr->clean_index_ring_size[i] = (size_t)0; + cache_ptr->dirty_index_ring_size[i] = (size_t)0; - cache_ptr->slist_ring_len[i] = 0; - cache_ptr->slist_ring_size[i] = (size_t)0; + cache_ptr->slist_ring_len[i] = 0; + cache_ptr->slist_ring_size[i] = (size_t)0; } /* end for */ - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) (cache_ptr->index)[i] = NULL; - cache_ptr->il_len = 0; - cache_ptr->il_size = (size_t)0; - cache_ptr->il_head = NULL; - cache_ptr->il_tail = NULL; + cache_ptr->il_len = 0; + cache_ptr->il_size = (size_t)0; + cache_ptr->il_head = NULL; + cache_ptr->il_tail = NULL; /* Tagging Field Initializations */ - cache_ptr->ignore_tags = FALSE; - cache_ptr->num_objs_corked = 0; + cache_ptr->ignore_tags = FALSE; + cache_ptr->num_objs_corked = 0; /* slist field initializations */ - cache_ptr->slist_enabled = ! H5C__SLIST_OPT_ENABLED; - cache_ptr->slist_changed = FALSE; - cache_ptr->slist_len = 0; - cache_ptr->slist_size = (size_t)0; + cache_ptr->slist_enabled = !H5C__SLIST_OPT_ENABLED; + cache_ptr->slist_changed = FALSE; + cache_ptr->slist_len = 0; + cache_ptr->slist_size = (size_t)0; - /* slist_ring_len, slist_ring_size, and + /* slist_ring_len, slist_ring_size, and * slist_ptr initializaed above. */ #if H5C_DO_SANITY_CHECKS - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; #endif /* H5C_DO_SANITY_CHECKS */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - cache_ptr->entry_watched_for_removal = NULL; + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + cache_ptr->entry_watched_for_removal = NULL; - cache_ptr->pl_len = 0; - cache_ptr->pl_size = (size_t)0; - cache_ptr->pl_head_ptr = NULL; - cache_ptr->pl_tail_ptr = NULL; + cache_ptr->pl_len = 0; + cache_ptr->pl_size = (size_t)0; + cache_ptr->pl_head_ptr = NULL; + cache_ptr->pl_tail_ptr = NULL; - cache_ptr->pel_len = 0; - cache_ptr->pel_size = (size_t)0; - cache_ptr->pel_head_ptr = NULL; - cache_ptr->pel_tail_ptr = NULL; + cache_ptr->pel_len = 0; + cache_ptr->pel_size = (size_t)0; + cache_ptr->pel_head_ptr = NULL; + cache_ptr->pel_tail_ptr = NULL; - cache_ptr->LRU_list_len = 0; - cache_ptr->LRU_list_size = (size_t)0; - cache_ptr->LRU_head_ptr = NULL; - cache_ptr->LRU_tail_ptr = NULL; + cache_ptr->LRU_list_len = 0; + cache_ptr->LRU_list_size = (size_t)0; + cache_ptr->LRU_head_ptr = NULL; + cache_ptr->LRU_tail_ptr = NULL; #ifdef H5_HAVE_PARALLEL - cache_ptr->coll_list_len = 0; - cache_ptr->coll_list_size = (size_t)0; - cache_ptr->coll_head_ptr = NULL; - cache_ptr->coll_tail_ptr = NULL; - cache_ptr->coll_write_list = NULL; + cache_ptr->coll_list_len = 0; + cache_ptr->coll_list_size = (size_t)0; + cache_ptr->coll_head_ptr = NULL; + cache_ptr->coll_tail_ptr = NULL; + cache_ptr->coll_write_list = NULL; #endif /* H5_HAVE_PARALLEL */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - cache_ptr->cLRU_list_len = 0; - cache_ptr->cLRU_list_size = (size_t)0; - cache_ptr->cLRU_head_ptr = NULL; - cache_ptr->cLRU_tail_ptr = NULL; - - cache_ptr->dLRU_list_len = 0; - cache_ptr->dLRU_list_size = (size_t)0; - cache_ptr->dLRU_head_ptr = NULL; - cache_ptr->dLRU_tail_ptr = NULL; + cache_ptr->cLRU_list_len = 0; + cache_ptr->cLRU_list_size = (size_t)0; + cache_ptr->cLRU_head_ptr = NULL; + cache_ptr->cLRU_tail_ptr = NULL; + + cache_ptr->dLRU_list_len = 0; + cache_ptr->dLRU_list_size = (size_t)0; + cache_ptr->dLRU_head_ptr = NULL; + cache_ptr->dLRU_tail_ptr = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; - cache_ptr->flash_size_increase_threshold = 0; - cache_ptr->size_decrease_possible = FALSE; - cache_ptr->resize_enabled = FALSE; - cache_ptr->cache_full = FALSE; - cache_ptr->size_decreased = FALSE; - cache_ptr->resize_in_progress = FALSE; - cache_ptr->msic_in_progress = FALSE; - - (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; - (cache_ptr->resize_ctl).rpt_fcn = NULL; - (cache_ptr->resize_ctl).set_initial_size = FALSE; - (cache_ptr->resize_ctl).initial_size = H5C__DEF_AR_INIT_SIZE; - (cache_ptr->resize_ctl).min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; - (cache_ptr->resize_ctl).max_size = H5C__DEF_AR_MAX_SIZE; - (cache_ptr->resize_ctl).min_size = H5C__DEF_AR_MIN_SIZE; - (cache_ptr->resize_ctl).epoch_length = H5C__DEF_AR_EPOCH_LENGTH; - - (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; - (cache_ptr->resize_ctl).lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; - (cache_ptr->resize_ctl).increment = H5C__DEF_AR_INCREMENT; - (cache_ptr->resize_ctl).apply_max_increment = TRUE; - (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; - - (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0f; - (cache_ptr->resize_ctl).flash_threshold = 0.25f; - - (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; - (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; - (cache_ptr->resize_ctl).decrement = H5C__DEF_AR_DECREMENT; - (cache_ptr->resize_ctl).apply_max_decrement = TRUE; - (cache_ptr->resize_ctl).max_decrement = H5C__DEF_AR_MAX_DECREMENT; + cache_ptr->size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->flash_size_increase_threshold = 0; + cache_ptr->size_decrease_possible = FALSE; + cache_ptr->resize_enabled = FALSE; + cache_ptr->cache_full = FALSE; + cache_ptr->size_decreased = FALSE; + cache_ptr->resize_in_progress = FALSE; + cache_ptr->msic_in_progress = FALSE; + + (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; + (cache_ptr->resize_ctl).rpt_fcn = NULL; + (cache_ptr->resize_ctl).set_initial_size = FALSE; + (cache_ptr->resize_ctl).initial_size = H5C__DEF_AR_INIT_SIZE; + (cache_ptr->resize_ctl).min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; + (cache_ptr->resize_ctl).max_size = H5C__DEF_AR_MAX_SIZE; + (cache_ptr->resize_ctl).min_size = H5C__DEF_AR_MIN_SIZE; + (cache_ptr->resize_ctl).epoch_length = H5C__DEF_AR_EPOCH_LENGTH; + + (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; + (cache_ptr->resize_ctl).lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; + (cache_ptr->resize_ctl).increment = H5C__DEF_AR_INCREMENT; + (cache_ptr->resize_ctl).apply_max_increment = TRUE; + (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; + + (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; + (cache_ptr->resize_ctl).flash_multiple = 1.0; + (cache_ptr->resize_ctl).flash_threshold = 0.25; + + (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; + (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; + (cache_ptr->resize_ctl).decrement = H5C__DEF_AR_DECREMENT; + (cache_ptr->resize_ctl).apply_max_decrement = TRUE; + (cache_ptr->resize_ctl).max_decrement = H5C__DEF_AR_MAX_DECREMENT; (cache_ptr->resize_ctl).epochs_before_eviction = H5C__DEF_AR_EPCHS_B4_EVICT; - (cache_ptr->resize_ctl).apply_empty_reserve = TRUE; - (cache_ptr->resize_ctl).empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; + (cache_ptr->resize_ctl).apply_empty_reserve = TRUE; + (cache_ptr->resize_ctl).empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; - cache_ptr->epoch_markers_active = 0; + cache_ptr->epoch_markers_active = 0; /* no need to initialize the ring buffer itself */ - cache_ptr->epoch_marker_ringbuf_first = 1; - cache_ptr->epoch_marker_ringbuf_last = 0; - cache_ptr->epoch_marker_ringbuf_size = 0; + cache_ptr->epoch_marker_ringbuf_first = 1; + cache_ptr->epoch_marker_ringbuf_last = 0; + cache_ptr->epoch_marker_ringbuf_size = 0; /* Initialize all epoch marker entries' fields to zero/FALSE/NULL */ HDmemset(cache_ptr->epoch_markers, 0, sizeof(cache_ptr->epoch_markers)); /* Set non-zero/FALSE/NULL fields for epoch markers */ - for ( i = 0; i < H5C__MAX_EPOCH_MARKERS; i++ ) - { - ((cache_ptr->epoch_markers)[i]).magic = - H5C__H5C_CACHE_ENTRY_T_MAGIC; - ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; - ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; + for (i = 0; i < H5C__MAX_EPOCH_MARKERS; i++) { + ((cache_ptr->epoch_markers)[i]).magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; + ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; } /* Initialize cache image generation on file close related fields. @@ -526,267 +484,214 @@ H5C_create(size_t max_cache_size, cache_ptr->image_ctl.entry_ageout = -1; cache_ptr->image_ctl.flags = H5C_CI__ALL_FLAGS; - cache_ptr->serialization_in_progress= FALSE; - cache_ptr->load_image = FALSE; - cache_ptr->image_loaded = FALSE; - cache_ptr->delete_image = FALSE; - cache_ptr->image_addr = HADDR_UNDEF; - cache_ptr->image_len = 0; - cache_ptr->image_data_len = 0; - - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - cache_ptr->entry_fd_height_change_counter = 0; - - cache_ptr->num_entries_in_image = 0; - cache_ptr->image_entries = NULL; - cache_ptr->image_buffer = NULL; + cache_ptr->serialization_in_progress = FALSE; + cache_ptr->load_image = FALSE; + cache_ptr->image_loaded = FALSE; + cache_ptr->delete_image = FALSE; + cache_ptr->image_addr = HADDR_UNDEF; + cache_ptr->image_len = 0; + cache_ptr->image_data_len = 0; + + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + cache_ptr->entry_fd_height_change_counter = 0; + + cache_ptr->num_entries_in_image = 0; + cache_ptr->image_entries = NULL; + cache_ptr->image_buffer = NULL; /* initialize free space manager related fields: */ - cache_ptr->rdfsm_settled = FALSE; - cache_ptr->mdfsm_settled = FALSE; + cache_ptr->rdfsm_settled = FALSE; + cache_ptr->mdfsm_settled = FALSE; - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "H5C_reset_cache_hit_rate_stats failed") H5C_stats__reset(cache_ptr); - cache_ptr->prefix[0] = '\0'; /* empty string */ + cache_ptr->prefix[0] = '\0'; /* empty string */ #ifndef NDEBUG - cache_ptr->get_entry_ptr_from_addr_counter = 0; + cache_ptr->get_entry_ptr_from_addr_counter = 0; #endif /* NDEBUG */ /* Set return value */ ret_value = cache_ptr; done: - if(NULL == ret_value) { - if(cache_ptr != NULL) { - if(cache_ptr->slist_ptr != NULL) + if (NULL == ret_value) { + if (cache_ptr != NULL) { + if (cache_ptr->slist_ptr != NULL) H5SL_close(cache_ptr->slist_ptr); - if(cache_ptr->tag_list != NULL) + if (cache_ptr->tag_list != NULL) H5SL_close(cache_ptr->tag_list); - if(cache_ptr->log_info != 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); + cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_create() */ - /*------------------------------------------------------------------------- * Function: H5C_def_auto_resize_rpt_fcn * * Purpose: Print results of a automatic cache resize. * - * This function should only be used where HDprintf() behaves - * well -- i.e. not on Windows. + * This function should only be used where HDprintf() behaves + * well -- i.e. not on Windows. * * Return: void * * Programmer: John Mainzer - * 10/27/04 + * 10/27/04 * *------------------------------------------------------------------------- */ void -H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, +H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, #ifndef NDEBUG int32_t version, -#else /* NDEBUG */ +#else /* NDEBUG */ int32_t H5_ATTR_UNUSED version, #endif /* NDEBUG */ - double hit_rate, - enum H5C_resize_status status, - size_t old_max_cache_size, - size_t new_max_cache_size, - size_t old_min_clean_size, - size_t new_min_clean_size) + double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size) { - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER); - switch ( status ) - { + switch (status) { case in_spec: - HDfprintf(stdout, - "%sAuto cache resize -- no change. (hit rate = %lf)\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- no change. (hit rate = %lf)\n", cache_ptr->prefix, + hit_rate); break; case increase: - HDassert( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ); - HDassert( old_max_cache_size < new_max_cache_size ); - - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - - HDfprintf(stdout, - "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); + HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + HDassert(old_max_cache_size < new_max_cache_size); + + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + + HDfprintf(stdout, "%scache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); break; case flash_increase: - HDassert( old_max_cache_size < new_max_cache_size ); - - HDfprintf(stdout, - "%sflash cache resize(%d) -- size threshold = %Zu.\n", - cache_ptr->prefix, - (int)((cache_ptr->resize_ctl).flash_incr_mode), - cache_ptr->flash_size_increase_threshold); - - HDfprintf(stdout, - "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); - break; + HDassert(old_max_cache_size < new_max_cache_size); + + HDfprintf(stdout, "%sflash cache resize(%d) -- size threshold = %zu.\n", cache_ptr->prefix, + (int)((cache_ptr->resize_ctl).flash_incr_mode), + cache_ptr->flash_size_increase_threshold); + + HDfprintf(stdout, "%s cache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; case decrease: - HDassert( old_max_cache_size > new_max_cache_size ); + HDassert(old_max_cache_size > new_max_cache_size); - switch ( (cache_ptr->resize_ctl).decr_mode ) - { + switch ((cache_ptr->resize_ctl).decr_mode) { case H5C_decr__off: - HDfprintf(stdout, - "%sAuto cache resize -- decrease off. HR = %lf\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, + hit_rate); break; case H5C_decr__threshold: - HDassert( hit_rate > - (cache_ptr->resize_ctl).upper_hr_threshold ); + HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); - HDfprintf(stdout, - "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).upper_hr_threshold); + HDfprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).upper_hr_threshold); - HDfprintf(stdout, "%sout of bounds high (%6.5lf).\n", - cache_ptr->prefix, + HDfprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, (cache_ptr->resize_ctl).upper_hr_threshold); break; case H5C_decr__age_out: - HDfprintf(stdout, - "%sAuto cache resize -- decrease by ageout. HR = %lf\n", + HDfprintf(stdout, "%sAuto cache resize -- decrease by ageout. HR = %lf\n", cache_ptr->prefix, hit_rate); break; case H5C_decr__age_out_with_threshold: - HDassert( hit_rate > - (cache_ptr->resize_ctl).upper_hr_threshold ); + HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); HDfprintf(stdout, "%sAuto cache resize -- decrease by ageout with threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).upper_hr_threshold); + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).upper_hr_threshold); break; default: - HDfprintf(stdout, - "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", + HDfprintf(stdout, "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", cache_ptr->prefix, hit_rate); } - HDfprintf(stdout, - "%s cache size decreased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); + HDfprintf(stdout, "%s cache size decreased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); break; case at_max_size: - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - HDfprintf(stdout, - "%s cache already at maximum size so no change.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + HDfprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); break; case at_min_size: - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", - cache_ptr->prefix, hit_rate); - HDfprintf(stdout, "%s cache already at minimum size.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", cache_ptr->prefix, + hit_rate); + HDfprintf(stdout, "%s cache already at minimum size.\n", cache_ptr->prefix); break; case increase_disabled: - HDfprintf(stdout, - "%sAuto cache resize -- increase disabled -- HR = %lf.", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- increase disabled -- HR = %lf.", cache_ptr->prefix, + hit_rate); break; case decrease_disabled: - HDfprintf(stdout, - "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", - cache_ptr->prefix, hit_rate); + HDfprintf(stdout, "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", cache_ptr->prefix, + hit_rate); break; case not_full: - HDassert( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ); - - HDfprintf(stdout, - "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, - (cache_ptr->resize_ctl).lower_hr_threshold); - HDfprintf(stdout, - "%s cache not full so no increase in size.\n", - cache_ptr->prefix); + HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + + HDfprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).lower_hr_threshold); + HDfprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); break; default: - HDfprintf(stdout, "%sAuto cache resize -- unknown status code.\n", - cache_ptr->prefix); + HDfprintf(stdout, "%sAuto cache resize -- unknown status code.\n", cache_ptr->prefix); break; } - - return; - } /* H5C_def_auto_resize_rpt_fcn() */ - /*------------------------------------------------------------------------- - * Function: H5C_free_tag_list_cb + * 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 + * January 2014 * *------------------------------------------------------------------------- */ static herr_t -H5C_free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data) +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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(tag_info); @@ -794,16 +699,15 @@ H5C_free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); FUNC_LEAVE_NOAPI(0) -} /* H5C_free_tag_list_cb() */ +} /* H5C__free_tag_list_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_prep_for_file_close * * Purpose: This function should be called just prior to the cache - * flushes at file close. There should be no protected - * entries in the cache at this point. + * flushes at file close. There should be no protected + * entries in the cache at this point. * * Return: Non-negative on success/Negative on failure * @@ -815,9 +719,9 @@ 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; - hbool_t image_generated = FALSE; /* Whether a cache image was generated */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + hbool_t image_generated = FALSE; /* Whether a cache image was generated */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -833,7 +737,7 @@ H5C_prep_for_file_close(H5F_t *f) * close warning more than once -- the following * if statement handles this. */ - if(cache_ptr->close_warning_received) + if (cache_ptr->close_warning_received) HGOTO_DONE(SUCCEED) cache_ptr->close_warning_received = TRUE; @@ -841,14 +745,12 @@ H5C_prep_for_file_close(H5F_t *f) HDassert(cache_ptr->pl_len == 0); /* Prepare cache image */ - if(H5C__prep_image_for_file_close(f, &image_generated) < 0) + if (H5C__prep_image_for_file_close(f, &image_generated) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cache image") #ifdef H5_HAVE_PARALLEL - if ( ( H5F_INTENT(f) & H5F_ACC_RDWR ) && - ( ! image_generated ) && - ( cache_ptr->aux_ptr != NULL ) && - ( f->shared->fs_persist ) ) { + if ((H5F_INTENT(f) & H5F_ACC_RDWR) && (!image_generated) && (cache_ptr->aux_ptr != NULL) && + (f->shared->fs_persist)) { /* If persistent free space managers are enabled, flushing the * metadata cache may result in the deletion, insertion, and/or * dirtying of entries. @@ -882,16 +784,15 @@ H5C_prep_for_file_close(H5F_t *f) * during a flush, and thus avoid any resulting entrie dirties, * deletions, insertion, or moves during the flush. */ - if(H5C__serialize_cache(f) < 0) + if (H5C__serialize_cache(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialization of the cache failed") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_prep_for_file_close() */ - /*------------------------------------------------------------------------- * Function: H5C_dest * @@ -900,34 +801,34 @@ H5C_prep_for_file_close(H5F_t *f) * This function fails if any object are protected since the * resulting file might not be consistent. * - * Note that *cache_ptr has been freed upon successful return. + * Note that *cache_ptr has been freed upon successful return. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer - * 6/2/04 + * 6/2/04 * * Modifications: * * JRM -- 5/15/20 * - * Updated the function to enable the slist prior to the - * call to H5C__flush_invalidate_cache(). + * 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 + * 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 + * 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_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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -937,33 +838,32 @@ H5C_dest(H5F_t * f) HDassert(cache_ptr->close_warning_received); #if H5AC_DUMP_IMAGE_STATS_ON_CLOSE - if(H5C_image_stats(cache_ptr, TRUE) < 0) + if (H5C_image_stats(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't display cache image stats") #endif /* H5AC_DUMP_IMAGE_STATS_ON_CLOSE */ /* Enable the slist, as it is needed in the flush */ - if ( H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0 ) + 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 ) + 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 ) + if (H5C__generate_cache_image(f, cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, \ - "Can't generate metadata cache image") + 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 + /* 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 ) { + if (cache_ptr->slist_ptr != NULL) { HDassert(cache_ptr->slist_len == 0); HDassert(cache_ptr->slist_size == 0); @@ -974,14 +874,15 @@ H5C_dest(H5F_t * f) } /* end if */ - if(cache_ptr->tag_list != NULL) { + if (cache_ptr->tag_list != NULL) { + + H5SL_destroy(cache_ptr->tag_list, H5C__free_tag_list_cb, 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) { + if (cache_ptr->log_info != NULL) { H5MM_xfree(cache_ptr->log_info); } @@ -989,11 +890,10 @@ H5C_dest(H5F_t * f) #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, - "*** %ld calls to H5C_get_entry_ptr_from_add(). ***\n", - cache_ptr->get_entry_ptr_from_addr_counter); + 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 */ @@ -1004,21 +904,19 @@ H5C_dest(H5F_t * f) 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 ) + 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") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist on flush dest failure failed") } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dest() */ - /*------------------------------------------------------------------------- * Function: H5C_evict * @@ -1027,22 +925,22 @@ H5C_dest(H5F_t * f) * Return: Non-negative on success/Negative on failure * * Programmer: Vailin Choi - * Dec 2013 + * Dec 2013 * * Modifications: * * JRM -- 5/5/20 * * Added code to enable the skip list prior to the call - * to H5C__flush_invalidate_cache(), and disable it - * afterwards. + * to H5C__flush_invalidate_cache(), and disable it + * afterwards. * *------------------------------------------------------------------------- */ herr_t -H5C_evict(H5F_t * f) +H5C_evict(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1050,19 +948,17 @@ H5C_evict(H5F_t * f) HDassert(f); /* Enable the slist, as it is needed in the flush */ - if ( H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0 ) + 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 except the pinned entries */ - if ( H5C__flush_invalidate_cache(f, H5C__EVICT_ALLOW_LAST_PINS_FLAG) < 0 ) + if (H5C__flush_invalidate_cache(f, H5C__EVICT_ALLOW_LAST_PINS_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, - "unable to evict entries in the cache") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict entries in the cache") - /* Disable the slist, - */ - if ( H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) + /* Disable the slist */ + if (H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist disabled failed") @@ -1070,13 +966,12 @@ H5C_evict(H5F_t * f) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict() */ - /*------------------------------------------------------------------------- * Function: H5C_expunge_entry * * Purpose: Use this function to tell the cache to expunge an entry - * from the cache without writing it to disk even if it is - * dirty. The entry may not be either pinned or protected. + * from the cache without writing it to disk even if it is + * dirty. The entry may not be either pinned or protected. * * Return: Non-negative on success/Negative on failure * @@ -1088,10 +983,10 @@ 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_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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -1104,13 +999,13 @@ 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 */ /* Look for entry in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if((entry_ptr == NULL) || (entry_ptr->type != type)) + if ((entry_ptr == NULL) || (entry_ptr->type != type)) /* the target doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) @@ -1118,9 +1013,9 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag HDassert(entry_ptr->type == type); /* Check for entry being pinned or protected */ - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected") - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned") /* If we get this far, call H5C__flush_single_entry() with the @@ -1134,63 +1029,62 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - if(H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry") 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_expunge_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_flush_cache * - * Purpose: Flush (and possibly destroy) the entries contained in the - * specified cache. + * Purpose: Flush (and possibly destroy) the entries contained in the + * specified cache. * - * If the cache contains protected entries, the function will - * fail, as protected entries cannot be flushed. However - * all unprotected entries should be flushed before the - * function returns failure. + * If the cache contains protected entries, the function will + * fail, as protected entries cannot be flushed. However + * all unprotected entries should be flushed before the + * function returns failure. * * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * a request to flush all items and something was protected. * * Programmer: John Mainzer - * 6/2/04 + * 6/2/04 * - * Changes: Modified function to test for slist chamges in - * pre_serialize and serialize callbacks, and re-start - * scans through the slist when such changes occur. + * Changes: Modified function to test for slist chamges in + * pre_serialize and serialize callbacks, and re-start + * scans through the slist when such changes occur. * - * This has been a potential problem for some time, - * and there has been code in this function to deal - * with elements of this issue. However the shift - * to the V3 cache in combination with the activities - * of some of the cache clients (in particular the - * free space manager and the fractal heap) have - * made this re-work necessary. + * This has been a potential problem for some time, + * and there has been code in this function to deal + * with elements of this issue. However the shift + * to the V3 cache in combination with the activities + * of some of the cache clients (in particular the + * free space manager and the fractal heap) have + * made this re-work necessary. * - * JRM -- 12/13/14 + * JRM -- 12/13/14 * - * Modified function to support rings. Basic idea is that - * every entry in the cache is assigned to a ring. Entries - * in the outermost ring are flushed first, followed by - * those in the next outermost ring, and so on until the - * innermost ring is flushed. See header comment on - * H5C_ring_t in H5Cprivate.h for a more detailed - * discussion. + * Modified function to support rings. Basic idea is that + * every entry in the cache is assigned to a ring. Entries + * in the outermost ring are flushed first, followed by + * those in the next outermost ring, and so on until the + * innermost ring is flushed. See header comment on + * H5C_ring_t in H5Cprivate.h for a more detailed + * discussion. * - * JRM -- 8/30/15 + * JRM -- 8/30/15 * - * Modified function to call the free space manager - * settling functions. - * JRM -- 6/9/16 + * Modified function to call the free space manager + * settling functions. + * JRM -- 6/9/16 * *------------------------------------------------------------------------- */ @@ -1198,19 +1092,18 @@ herr_t H5C_flush_cache(H5F_t *f, unsigned flags) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - hbool_t destroy; - hbool_t ignore_protected; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + hbool_t destroy; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1229,13 +1122,13 @@ H5C_flush_cache(H5F_t *f, unsigned flags) HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { index_len += cache_ptr->index_ring_len[i]; index_size += cache_ptr->index_ring_size[i]; clean_index_size += cache_ptr->clean_index_ring_size[i]; dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - slist_len += cache_ptr->slist_ring_len[i]; + slist_len += cache_ptr->slist_ring_len[i]; slist_size += cache_ptr->slist_ring_size[i]; } /* end for */ @@ -1248,67 +1141,65 @@ 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 */ - ignore_protected = ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 ); - destroy = ( (flags & H5C__FLUSH_INVALIDATE_FLAG) != 0 ); - HDassert( ! ( destroy && ignore_protected ) ); - HDassert( ! ( cache_ptr->flush_in_progress ) ); + destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); + HDassert(!(destroy && ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0))); + HDassert(!(cache_ptr->flush_in_progress)); cache_ptr->flush_in_progress = TRUE; - if(destroy) { - if(H5C__flush_invalidate_cache(f, flags) < 0) + if (destroy) { + if (H5C__flush_invalidate_cache(f, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate failed") } /* end if */ else { - /* flush each ring, starting from the outermost ring and + /* flush each ring, starting from the outermost ring and * working inward. */ ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { + while (ring < H5C_RING_NTYPES) { /* Only call the free space manager settle routines when close * warning has been received. */ - if(cache_ptr->close_warning_received) { - switch(ring) { - case H5C_RING_USER: - break; + if (cache_ptr->close_warning_received) { + switch (ring) { + case H5C_RING_USER: + break; - case H5C_RING_RDFSM: + case H5C_RING_RDFSM: /* Settle raw data FSM */ - if(!cache_ptr->rdfsm_settled) - if(H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) + if (!cache_ptr->rdfsm_settled) + if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") - break; + break; - case H5C_RING_MDFSM: + case H5C_RING_MDFSM: /* Settle metadata FSM */ - if(!cache_ptr->mdfsm_settled) - if(H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) + if (!cache_ptr->mdfsm_settled) + if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") - break; + break; - case H5C_RING_SBE: - case H5C_RING_SB: - break; + case H5C_RING_SBE: + case H5C_RING_SB: + break; - default: + default: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") - break; - } /* end switch */ - } /* end if */ + break; + } /* end switch */ + } /* end if */ - if(H5C__flush_ring(f, ring, flags) < 0) + if (H5C__flush_ring(f, ring, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush ring failed") ring++; } /* end while */ - } /* end else */ + } /* end else */ done: cache_ptr->flush_in_progress = FALSE; @@ -1316,66 +1207,64 @@ H5C_flush_cache(H5F_t *f, unsigned flags) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_cache() */ - /*------------------------------------------------------------------------- * Function: H5C_flush_to_min_clean * - * Purpose: Flush dirty entries until the caches min clean size is - * attained. + * Purpose: Flush dirty entries until the caches min clean size is + * attained. * - * This function is used in the implementation of the - * metadata cache in PHDF5. To avoid "messages from the - * future", the cache on process 0 can't be allowed to - * flush entries until the other processes have reached - * the same point in the calculation. If this constraint - * is not met, it is possible that the other processes will - * read metadata generated at a future point in the - * computation. + * This function is used in the implementation of the + * metadata cache in PHDF5. To avoid "messages from the + * future", the cache on process 0 can't be allowed to + * flush entries until the other processes have reached + * the same point in the calculation. If this constraint + * is not met, it is possible that the other processes will + * read metadata generated at a future point in the + * computation. * * * Return: Non-negative on success/Negative on failure or if - * write is not permitted. + * write is not permitted. * * Programmer: John Mainzer - * 9/16/05 + * 9/16/05 * *------------------------------------------------------------------------- */ herr_t -H5C_flush_to_min_clean(H5F_t * f) +H5C_flush_to_min_clean(H5F_t *f) { - H5C_t * cache_ptr; - hbool_t write_permitted; - herr_t ret_value = SUCCEED; + H5C_t * cache_ptr; + hbool_t write_permitted; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get write_permitted") } /* end if */ else write_permitted = cache_ptr->write_permitted; - if(!write_permitted) + if (!write_permitted) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cache write is not permitted!?!") - if(H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) + if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C__make_space_in_cache failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_to_min_clean() */ - /*------------------------------------------------------------------------- * Function: H5C_insert_entry * @@ -1383,64 +1272,59 @@ H5C_flush_to_min_clean(H5F_t * f) * exist on disk yet, but it must have an address and disk * space reserved. * - * Observe that this function cannot occasion a read. + * Observe that this function cannot occasion a read. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer - * 6/2/04 + * 6/2/04 * *------------------------------------------------------------------------- */ herr_t -H5C_insert_entry(H5F_t * f, - const H5C_class_t * type, - haddr_t addr, - void * thing, - unsigned int flags) +H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags) { - H5C_t *cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t insert_pinned; - hbool_t flush_last; + H5C_t * cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t insert_pinned; + hbool_t flush_last; #ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t set_flush_marker; - hbool_t write_permitted = TRUE; - size_t empty_space; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *test_entry_ptr; - hbool_t entry_tagged = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t set_flush_marker; + hbool_t write_permitted = TRUE; + size_t empty_space; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr; + hbool_t entry_tagged = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( type ); - HDassert( type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type ); - HDassert( type->image_len ); - HDassert( H5F_addr_defined(addr) ); - HDassert( thing ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(type); + HDassert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + HDassert(type->image_len); + HDassert(H5F_addr_defined(addr)); + HDassert(thing); #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 */ - set_flush_marker = ( (flags & H5C__SET_FLUSH_MARKER_FLAG) != 0 ); - insert_pinned = ( (flags & H5C__PIN_ENTRY_FLAG) != 0 ); - flush_last = ( (flags & H5C__FLUSH_LAST_FLAG) != 0 ); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); /* Get the ring type from the API context */ ring = H5CX_get_ring(); @@ -1453,60 +1337,60 @@ H5C_insert_entry(H5F_t * f, H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if(test_entry_ptr != NULL) { - if(test_entry_ptr == entry_ptr) + if (test_entry_ptr != NULL) { + if (test_entry_ptr == entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "entry already in cache") else HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "duplicate entry in cache") } /* end if */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; entry_ptr->cache_ptr = cache_ptr; - entry_ptr->addr = addr; - entry_ptr->type = type; + entry_ptr->addr = addr; + entry_ptr->type = type; - entry_ptr->image_ptr = NULL; + entry_ptr->image_ptr = NULL; entry_ptr->image_up_to_date = FALSE; entry_ptr->is_protected = FALSE; entry_ptr->is_read_only = FALSE; entry_ptr->ro_ref_count = 0; - entry_ptr->is_pinned = insert_pinned; + entry_ptr->is_pinned = insert_pinned; entry_ptr->pinned_from_client = insert_pinned; - entry_ptr->pinned_from_cache = FALSE; - entry_ptr->flush_me_last = flush_last; + entry_ptr->pinned_from_cache = FALSE; + entry_ptr->flush_me_last = flush_last; /* newly inserted entries are assumed to be dirty */ entry_ptr->is_dirty = TRUE; /* not protected, so can't be dirtied */ - entry_ptr->dirtied = FALSE; + entry_ptr->dirtied = FALSE; /* Retrieve the size of the thing */ - if((type->image_len)(thing, &(entry_ptr->size)) < 0) + if ((type->image_len)(thing, &(entry_ptr->size)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "can't get size of thing") - HDassert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); + HDassert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); entry_ptr->in_slist = FALSE; #ifdef H5_HAVE_PARALLEL entry_ptr->clear_on_unprotect = FALSE; - entry_ptr->flush_immediately = FALSE; + entry_ptr->flush_immediately = FALSE; #endif /* H5_HAVE_PARALLEL */ - entry_ptr->flush_in_progress = FALSE; + entry_ptr->flush_in_progress = FALSE; entry_ptr->destroy_in_progress = FALSE; entry_ptr->ring = ring; /* Initialize flush dependency fields */ - entry_ptr->flush_dep_parent = NULL; - entry_ptr->flush_dep_nparents = 0; - entry_ptr->flush_dep_parent_nalloc = 0; - entry_ptr->flush_dep_nchildren = 0; - entry_ptr->flush_dep_ndirty_children = 0; - entry_ptr->flush_dep_nunser_children = 0; + entry_ptr->flush_dep_parent = NULL; + entry_ptr->flush_dep_nparents = 0; + entry_ptr->flush_dep_parent_nalloc = 0; + entry_ptr->flush_dep_nchildren = 0; + entry_ptr->flush_dep_ndirty_children = 0; + entry_ptr->flush_dep_nunser_children = 0; entry_ptr->ht_next = NULL; entry_ptr->ht_prev = NULL; @@ -1527,20 +1411,20 @@ H5C_insert_entry(H5F_t * f, #endif /* H5_HAVE_PARALLEL */ /* initialize cache image related fields */ - entry_ptr->include_in_image = FALSE; - entry_ptr->lru_rank = 0; - entry_ptr->image_dirty = FALSE; - entry_ptr->fd_parent_count = 0; - entry_ptr->fd_parent_addrs = NULL; - entry_ptr->fd_child_count = 0; - entry_ptr->fd_dirty_child_count = 0; - entry_ptr->image_fd_height = 0; - entry_ptr->prefetched = FALSE; - entry_ptr->prefetch_type_id = 0; - entry_ptr->age = 0; - entry_ptr->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry_ptr->serialization_count = 0; + entry_ptr->include_in_image = FALSE; + entry_ptr->lru_rank = 0; + entry_ptr->image_dirty = FALSE; + entry_ptr->fd_parent_count = 0; + entry_ptr->fd_parent_addrs = NULL; + entry_ptr->fd_child_count = 0; + entry_ptr->fd_dirty_child_count = 0; + entry_ptr->image_fd_height = 0; + entry_ptr->prefetched = FALSE; + entry_ptr->prefetch_type_id = 0; + entry_ptr->age = 0; + entry_ptr->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry_ptr->serialization_count = 0; #endif /* NDEBUG */ entry_ptr->tl_next = NULL; @@ -1548,33 +1432,32 @@ H5C_insert_entry(H5F_t * f, entry_ptr->tag_info = NULL; /* Apply tag to newly inserted entry */ - if(H5C__tag_entry(cache_ptr, entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") entry_tagged = TRUE; H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) - if(cache_ptr->flash_size_increase_possible && - (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) - if(H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) + if (cache_ptr->flash_size_increase_possible && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__flash_increase_cache_size failed") - if(cache_ptr->index_size >= cache_ptr->max_cache_size) + if (cache_ptr->index_size >= cache_ptr->max_cache_size) empty_space = 0; else empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - if(cache_ptr->evictions_enabled && - (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) - || - (((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)))) { + if (cache_ptr->evictions_enabled && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + (((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)))) { size_t space_needed; - if(empty_space <= entry_ptr->size) + if (empty_space <= entry_ptr->size) cache_ptr->cache_full = TRUE; - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "Can't get write_permitted") } /* end if */ else @@ -1582,7 +1465,7 @@ H5C_insert_entry(H5F_t * f, HDassert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); space_needed = entry_ptr->size; - if(space_needed > cache_ptr->max_cache_size) + if (space_needed > cache_ptr->max_cache_size) space_needed = cache_ptr->max_cache_size; /* Note that space_needed is just the amount of space that @@ -1610,7 +1493,7 @@ H5C_insert_entry(H5F_t * f, * no point in worrying about the third. */ - if(H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__make_space_in_cache failed") } /* end if */ @@ -1623,85 +1506,81 @@ H5C_insert_entry(H5F_t * f, 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 */ /* If the entry's type has a 'notify' callback send a 'after insertion' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry inserted into cache") H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) coll_access = H5CX_get_coll_metadata_read(); entry_ptr->coll_access = coll_access; - if(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) + 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 */ #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 */ - if(ret_value < 0 && entry_tagged) - if(H5C__untag_entry(cache_ptr, entry_ptr) < 0) + if (ret_value < 0 && entry_tagged) + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") FUNC_LEAVE_NOAPI(ret_value) } /* H5C_insert_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_dirty * - * Purpose: Mark a pinned or protected entry as dirty. The target entry - * MUST be either pinned or protected, and MAY be both. + * Purpose: Mark a pinned or protected entry as dirty. The target entry + * MUST be either pinned or protected, and MAY be both. * - * In the protected case, this call is the functional - * equivalent of setting the H5C__DIRTIED_FLAG on an unprotect - * call. + * In the protected case, this call is the functional + * equivalent of setting the H5C__DIRTIED_FLAG on an unprotect + * call. * - * In the pinned but not protected case, if the entry is not - * already dirty, the function places function marks the entry - * dirty and places it on the skip list. + * In the pinned but not protected case, if the entry is not + * already dirty, the function places function marks the entry + * dirty and places it on the skip list. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 5/15/06 * - * JRM -- 11/5/08 - * Added call to H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY() to - * update the new clean_index_size and dirty_index_size - * fields of H5C_t in the case that the entry was clean - * prior to this call, and is pinned and not protected. + * JRM -- 11/5/08 + * Added call to H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY() to + * update the new clean_index_size and dirty_index_size + * fields of H5C_t in the case that the entry was clean + * prior to this call, and is pinned and not protected. * *------------------------------------------------------------------------- */ herr_t H5C_mark_entry_dirty(void *thing) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1712,62 +1591,64 @@ H5C_mark_entry_dirty(void *thing) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if ( entry_ptr->is_protected ) { - HDassert( ! ((entry_ptr)->is_read_only) ); + if (entry_ptr->is_protected) { + HDassert(!((entry_ptr)->is_read_only)); /* set the dirtied flag */ entry_ptr->dirtied = TRUE; /* reset image_up_to_date */ - if(entry_ptr->image_up_to_date) { + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") - }/* end if */ - } /* end if */ - else if ( entry_ptr->is_pinned ) { - hbool_t was_clean; /* Whether the entry was previously clean */ - hbool_t image_was_up_to_date; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ + else if (entry_ptr->is_pinned) { + hbool_t was_clean; /* Whether the entry was previously clean */ + hbool_t image_was_up_to_date; /* Remember previous dirty status */ - was_clean = !entry_ptr->is_dirty; + was_clean = !entry_ptr->is_dirty; /* Check if image is up to date */ image_was_up_to_date = entry_ptr->image_up_to_date; /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; - entry_ptr->image_up_to_date = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->image_up_to_date = FALSE; /* Modify cache data structures */ - if(was_clean) + if (was_clean) H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) - if(!entry_ptr->in_slist) + if (!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) /* Update stats for entry being marked dirty */ H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_clean) { + if (was_clean) { /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end if */ - if(image_was_up_to_date) - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (image_was_up_to_date) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Entry is neither pinned nor protected??") @@ -1776,15 +1657,14 @@ H5C_mark_entry_dirty(void *thing) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_dirty() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_clean * - * Purpose: Mark a pinned entry as clean. The target entry MUST be pinned. + * Purpose: Mark a pinned entry as clean. The target entry MUST be pinned. * - * If the entry is not - * already clean, the function places function marks the entry - * clean and removes it from the skip list. + * If the entry is not + * already clean, the function places function marks the entry + * clean and removes it from the skip list. * * Return: Non-negative on success/Negative on failure * @@ -1796,9 +1676,9 @@ H5C_mark_entry_dirty(void *thing) herr_t H5C_mark_entry_clean(void *_thing) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1810,10 +1690,10 @@ H5C_mark_entry_clean(void *_thing) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Operate on pinned entry */ - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "entry is protected") - else if(entry_ptr->is_pinned) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ + else if (entry_ptr->is_pinned) { + hbool_t was_dirty; /* Whether the entry was previously dirty */ /* Remember previous dirty status */ was_dirty = entry_ptr->is_dirty; @@ -1825,29 +1705,30 @@ H5C_mark_entry_clean(void *_thing) entry_ptr->flush_marker = FALSE; /* Modify cache data structures */ - if(was_dirty) + if (was_dirty) H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) - if(entry_ptr->in_slist) + if (entry_ptr->in_slist) H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) /* Update stats for entry being marked clean */ H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_dirty) { + if (was_dirty) { /* If the entry's type has a 'notify' callback send a 'entry cleaned' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag cleared") + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") /* Propagate the clean up the flush dependency chain, if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_clean(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean") } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Entry is not pinned??") @@ -1855,12 +1736,11 @@ H5C_mark_entry_clean(void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_clean() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_unserialized * - * Purpose: Mark a pinned or protected entry as unserialized. The target - * entry MUST be either pinned or protected, and MAY be both. + * Purpose: Mark a pinned or protected entry as unserialized. The target + * entry MUST be either pinned or protected, and MAY be both. * * Return: Non-negative on success/Negative on failure * @@ -1872,8 +1752,8 @@ H5C_mark_entry_clean(void *_thing) herr_t H5C_mark_entry_unserialized(void *thing) { - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1881,31 +1761,32 @@ H5C_mark_entry_unserialized(void *thing) HDassert(entry); HDassert(H5F_addr_defined(entry->addr)); - if(entry->is_protected || entry->is_pinned) { + if (entry->is_protected || entry->is_pinned) { HDassert(!entry->is_read_only); /* Reset image_up_to_date */ - if(entry->image_up_to_date) { - entry->image_up_to_date = FALSE; + if (entry->image_up_to_date) { + entry->image_up_to_date = FALSE; - if(entry->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "Can't propagate serialization status to fd parents") - }/* end if */ - } /* end if */ + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "Entry to unserialize is neither pinned nor protected??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, + "Entry to unserialize is neither pinned nor protected??") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_unserialized() */ - /*------------------------------------------------------------------------- * Function: H5C_mark_entry_serialized * - * Purpose: Mark a pinned entry as serialized. The target entry MUST be - * pinned. + * Purpose: Mark a pinned entry as serialized. The target entry MUST be + * pinned. * * Return: Non-negative on success/Negative on failure * @@ -1917,8 +1798,8 @@ H5C_mark_entry_unserialized(void *thing) herr_t H5C_mark_entry_serialized(void *_thing) { - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1927,20 +1808,21 @@ H5C_mark_entry_serialized(void *_thing) HDassert(H5F_addr_defined(entry->addr)); /* Operate on pinned entry */ - if(entry->is_protected) + if (entry->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "entry is protected") - else if(entry->is_pinned) { + else if (entry->is_pinned) { /* Check for entry changing status and do notifications, etc. */ - if(!entry->image_up_to_date) { - /* Set the image_up_to_date flag */ + if (!entry->image_up_to_date) { + /* Set the image_up_to_date flag */ entry->image_up_to_date = TRUE; /* Propagate the serialize up the flush dependency chain, if appropriate */ - if(entry->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_serialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Can't propagate flush dep serialize") + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_serialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, + "Can't propagate flush dep serialize") } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Entry is not pinned??") @@ -1948,7 +1830,6 @@ H5C_mark_entry_serialized(void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entry_serialized() */ - /*------------------------------------------------------------------------- * * Function: H5C_move_entry @@ -1964,14 +1845,11 @@ H5C_mark_entry_serialized(void *_thing) *------------------------------------------------------------------------- */ herr_t -H5C_move_entry(H5C_t * cache_ptr, - const H5C_class_t * type, - haddr_t old_addr, - haddr_t new_addr) +H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr) { - H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * test_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1983,15 +1861,14 @@ H5C_move_entry(H5C_t * cache_ptr, 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 */ H5C__SEARCH_INDEX(cache_ptr, old_addr, entry_ptr, FAIL) - if(entry_ptr == NULL || entry_ptr->type != type) + if (entry_ptr == NULL || entry_ptr->type != type) /* the old item doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) @@ -2002,13 +1879,13 @@ H5C_move_entry(H5C_t * cache_ptr, /* (Moving a R/O entry would mark it dirty, which shouldn't * happen. QAK - 2016/12/02) */ - if(entry_ptr->is_read_only) + if (entry_ptr->is_read_only) HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "can't move R/O entry") H5C__SEARCH_INDEX(cache_ptr, new_addr, test_entry_ptr, FAIL) - if(test_entry_ptr != NULL) { /* we are hosed */ - if(test_entry_ptr->type == type) + if (test_entry_ptr != NULL) { /* we are hosed */ + if (test_entry_ptr->type == type) HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "target already moved & reinserted???") else HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "new address already in use?") @@ -2029,32 +1906,33 @@ H5C_move_entry(H5C_t * cache_ptr, * change the addr. If the entry is only in the process of being flushed, * don't mark it as dirty either, lest we confuse the flush call back. */ - if(!entry_ptr->destroy_in_progress) { + if (!entry_ptr->destroy_in_progress) { H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - if(entry_ptr->in_slist) { + if (entry_ptr->in_slist) { HDassert(cache_ptr->slist_ptr); H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) } /* end if */ - } /* end if */ + } /* end if */ entry_ptr->addr = new_addr; - if(!entry_ptr->destroy_in_progress) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ + if (!entry_ptr->destroy_in_progress) { + hbool_t was_dirty; /* Whether the entry was previously dirty */ /* Remember previous dirty status */ was_dirty = entry_ptr->is_dirty; /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; + entry_ptr->is_dirty = TRUE; - /* This shouldn't be needed, but it keeps the test code happy */ - if(entry_ptr->image_up_to_date) { + /* This shouldn't be needed, but it keeps the test code happy */ + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ /* Modify cache data structures */ @@ -2062,49 +1940,49 @@ H5C_move_entry(H5C_t * cache_ptr, H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) /* Skip some actions if we're in the middle of flushing the entry */ - if(!entry_ptr->flush_in_progress) { + if (!entry_ptr->flush_in_progress) { /* Update the replacement policy for the entry */ H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, FAIL) /* Check for entry changing status and do notifications, etc. */ - if(!was_dirty) { + if (!was_dirty) { /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag set") /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, + "Can't propagate flush dep dirty flag") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_move_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_resize_entry * - * Purpose: Resize a pinned or protected entry. + * Purpose: Resize a pinned or protected entry. * - * Resizing an entry dirties it, so if the entry is not - * already dirty, the function places the entry on the - * skip list. + * Resizing an entry dirties it, so if the entry is not + * already dirty, the function places the entry on the + * skip list. * * Return: Non-negative on success/Negative on failure * @@ -2116,9 +1994,9 @@ H5C_move_entry(H5C_t * cache_ptr, herr_t H5C_resize_entry(void *thing, size_t new_size) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2130,20 +2008,20 @@ H5C_resize_entry(void *thing, size_t new_size) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Check for usage errors */ - if(new_size <= 0) + if (new_size <= 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "New size is non-positive") - if(!(entry_ptr->is_pinned || entry_ptr->is_protected)) + if (!(entry_ptr->is_pinned || entry_ptr->is_protected)) 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 */ /* update for change in entry size if necessary */ - if ( entry_ptr->size != new_size ) { - hbool_t was_clean; + if (entry_ptr->size != new_size) { + hbool_t was_clean; /* make note of whether the entry was clean to begin with */ was_clean = !entry_ptr->is_dirty; @@ -2152,111 +2030,107 @@ H5C_resize_entry(void *thing, size_t new_size) entry_ptr->is_dirty = TRUE; /* Reset the image up-to-date status */ - if(entry_ptr->image_up_to_date) { + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ /* Release the current image */ - if(entry_ptr->image_ptr) + if (entry_ptr->image_ptr) entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); /* do a flash cache size increase if appropriate */ - if ( cache_ptr->flash_size_increase_possible ) { + if (cache_ptr->flash_size_increase_possible) { - if ( new_size > entry_ptr->size ) { - size_t size_increase; + if (new_size > entry_ptr->size) { + size_t size_increase; size_increase = new_size - entry_ptr->size; - if(size_increase >= cache_ptr->flash_size_increase_threshold) { - if(H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) + if (size_increase >= cache_ptr->flash_size_increase_threshold) { + if (H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "flash cache increase failed") } } } /* update the pinned and/or protected entry list */ - if(entry_ptr->is_pinned) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pel_len), \ - (cache_ptr->pel_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)) } /* end if */ - if(entry_ptr->is_protected) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), \ - (cache_ptr->pl_size), \ - (entry_ptr->size), (new_size)) + if (entry_ptr->is_protected) { + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), (cache_ptr->pl_size), (entry_ptr->size), + (new_size)) } /* end if */ #ifdef H5_HAVE_PARALLEL - if(entry_ptr->coll_access) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->coll_list_len), \ - (cache_ptr->coll_list_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)) } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /* update statistics just before changing the entry size */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); /* update the hash table */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_size, entry_ptr, was_clean); + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size, entry_ptr, was_clean); /* if the entry is in the skip list, update that too */ - if(entry_ptr->in_slist) - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); + if (entry_ptr->in_slist) + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); - /* finally, update the entry size proper */ - entry_ptr->size = new_size; + /* finally, update the entry size proper */ + entry_ptr->size = new_size; - if(!entry_ptr->in_slist) + if (!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) /* Check for entry changing status and do notifications, etc. */ - if(was_clean) { + if (was_clean) { /* If the entry's type has a 'notify' callback send a 'entry dirtied' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if(entry_ptr->flush_dep_nparents > 0) - if(H5C__mark_flush_dep_dirty(entry_ptr) < 0) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } /* end if */ - } /* end if */ + } /* end if */ 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_resize_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_pin_protected_entry() * - * Purpose: Pin a protected cache entry. The entry must be protected - * at the time of call, and must be unpinned. + * Purpose: Pin a protected cache entry. The entry must be protected + * at the time of call, and must be unpinned. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 4/26/06 * - * Changes: Added extreme sanity checks on entry and exit. + * Changes: Added extreme sanity checks on entry and exit. * JRM -- 4/26/14 * *------------------------------------------------------------------------- @@ -2264,9 +2138,9 @@ H5C_resize_entry(void *thing, size_t new_size) herr_t H5C_pin_protected_entry(void *thing) { - 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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -2278,47 +2152,43 @@ 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 */ - /* Only protected entries can be pinned */ - if(!entry_ptr->is_protected) + if (!entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry isn't protected") /* Pin the entry from a client */ - if(H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") done: #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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_pin_protected_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_protect * * Purpose: If the target entry is not in the cache, load it. If - * necessary, attempt to evict one or more entries to keep - * the cache within its maximum size. + * necessary, attempt to evict one or more entries to keep + * the cache within its maximum size. * - * Mark the target entry as protected, and return its address - * to the caller. The caller must call H5C_unprotect() when - * finished with the entry. + * Mark the target entry as protected, and return its address + * to the caller. The caller must call H5C_unprotect() when + * finished with the entry. * - * While it is protected, the entry may not be either evicted - * or flushed -- nor may it be accessed by another call to - * H5C_protect. Any attempt to do so will result in a failure. + * While it is protected, the entry may not be either evicted + * or flushed -- nor may it be accessed by another call to + * H5C_protect. Any attempt to do so will result in a failure. * * Return: Success: Ptr to the desired entry * Failure: NULL @@ -2328,82 +2198,77 @@ 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_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags) { - H5C_t * cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t hit; - hbool_t have_write_permitted = FALSE; - hbool_t read_only = FALSE; - hbool_t flush_last; + H5C_t * cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t hit; + hbool_t have_write_permitted = FALSE; + hbool_t read_only = FALSE; + hbool_t flush_last; #ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted; - hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ - size_t empty_space; - void * thing; - H5C_cache_entry_t * entry_ptr; - void * ret_value = NULL; /* Return value */ + hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + 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; + H5C_cache_entry_t *entry_ptr; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( type ); - HDassert( type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type ); - HDassert( H5F_addr_defined(addr) ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(type); + HDassert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + 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 */ /* Load the cache image, if requested */ - if(cache_ptr->load_image) { + if (cache_ptr->load_image) { cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) + if (H5C__load_cache_image(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't load cache image") } /* end if */ - read_only = ( (flags & H5C__READ_ONLY_FLAG) != 0 ); - flush_last = ( (flags & H5C__FLUSH_LAST_FLAG) != 0 ); + read_only = ((flags & H5C__READ_ONLY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); /* Get the ring type from the API context */ ring = H5CX_get_ring(); #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) coll_access = H5CX_get_coll_metadata_read(); #endif /* H5_HAVE_PARALLEL */ /* first check to see if the target is in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL) - if(entry_ptr != NULL) { - if(entry_ptr->ring != ring) + if (entry_ptr != NULL) { + if (entry_ptr->ring != ring) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "ring type mismatch occurred for cache entry") HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->prefetched) { + if (entry_ptr->prefetched) { /* This call removes the prefetched entry from the cache, * and replaces it with an entry deserialized from the * image of the prefetched entry. */ - if(H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) + if (H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't deserialize prefetched entry") HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -2412,154 +2277,151 @@ H5C_protect(H5F_t * f, } /* end if */ /* Check for trying to load the wrong type of entry from an address */ - if(entry_ptr->type != type) + if (entry_ptr->type != type) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") - /* if this is a collective metadata read, the entry is not - marked as collective, and is clean, it is possible that - other processes will not have it in its cache and will - expect a bcast of the entry from process 0. So process 0 - will bcast the entry to all other ranks. Ranks that _do_ have - the entry in their cache still have to participate in the - bcast. */ + /* if this is a collective metadata read, the entry is not + marked as collective, and is clean, it is possible that + other processes will not have it in its cache and will + expect a bcast of the entry from process 0. So process 0 + will bcast the entry to all other ranks. Ranks that _do_ have + the entry in their cache still have to participate in the + bcast. */ #ifdef H5_HAVE_PARALLEL - if(coll_access) { - if(!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) { - MPI_Comm comm; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ - int buf_size; + if (coll_access) { + if (!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) { + MPI_Comm comm; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ + int buf_size; - if(MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - if(entry_ptr->image_ptr == NULL) { + if (entry_ptr->image_ptr == NULL) { int mpi_rank; - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + 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) + 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") } /* end if */ HDassert(entry_ptr->image_ptr); H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t); - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* Mark the entry as collective and insert into the collective list */ entry_ptr->coll_access = TRUE; H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) } /* end if */ - else if(entry_ptr->coll_access) { + else if (entry_ptr->coll_access) { H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) } /* end else-if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ #if H5C_DO_TAGGING_SANITY_CHECKS -{ - /* Verify tag value */ - if(cache_ptr->ignore_tags != TRUE) { - haddr_t tag; /* Tag value */ - - /* The entry is already in the cache, but make sure that the tag value - * is still legal. This will ensure that had the entry NOT been in the - * cache, tagging was still set up correctly and it would have received - * a legal tag value after getting loaded from disk. - */ + { + /* Verify tag value */ + if (cache_ptr->ignore_tags != TRUE) { + haddr_t tag; /* Tag value */ + + /* The entry is already in the cache, but make sure that the tag value + * is still legal. This will ensure that had the entry NOT been in the + * cache, tagging was still set up correctly and it would have received + * a legal tag value after getting loaded from disk. + */ - /* Get the tag */ - tag = H5CX_get_tag(); + /* Get the tag */ + tag = H5CX_get_tag(); - if(H5C_verify_tag(entry_ptr->type->id, tag) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") - } /* end if */ -} + if (H5C_verify_tag(entry_ptr->type->id, tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") + } /* end if */ + } #endif - hit = TRUE; + hit = TRUE; thing = (void *)entry_ptr; - - } else { + } + else { /* must try to load the entry from disk. */ hit = FALSE; - if(NULL == (thing = H5C_load_entry(f, + if (NULL == (thing = H5C__load_entry(f, #ifdef H5_HAVE_PARALLEL - coll_access, + coll_access, #endif /* H5_HAVE_PARALLEL */ - type, addr, udata))) + type, addr, udata))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") entry_ptr = (H5C_cache_entry_t *)thing; cache_ptr->entries_loaded_counter++; - entry_ptr->ring = ring; + entry_ptr->ring = ring; #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) #endif /* H5_HAVE_PARALLEL */ /* Apply tag to newly protected entry */ - if(H5C__tag_entry(cache_ptr, entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag metadata entry") /* If the entry is very large, and we are configured to allow it, * we may wish to perform a flash cache size increase. */ - if ( ( cache_ptr->flash_size_increase_possible ) && - ( entry_ptr->size > cache_ptr->flash_size_increase_threshold ) ) { + if ((cache_ptr->flash_size_increase_possible) && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) { - if(H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__flash_increase_cache_size failed") } - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; /* try to free up if necceary and if evictions are permitted. Note * that if evictions are enabled, we will call H5C__make_space_in_cache() * regardless if the min_free_space requirement is not met. */ - if ( ( cache_ptr->evictions_enabled ) && - ( ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size) - || - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size ) - ) - ) { + if ((cache_ptr->evictions_enabled) && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size))) { size_t space_needed; - if(empty_space <= entry_ptr->size) + if (empty_space <= entry_ptr->size) cache_ptr->cache_full = TRUE; - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted 1") else have_write_permitted = TRUE; } /* end if */ else { - write_permitted = cache_ptr->write_permitted; + write_permitted = cache_ptr->write_permitted; have_write_permitted = TRUE; } /* end else */ HDassert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); space_needed = entry_ptr->size; - if(space_needed > cache_ptr->max_cache_size) + if (space_needed > cache_ptr->max_cache_size) space_needed = cache_ptr->max_cache_size; /* Note that space_needed is just the amount of space that @@ -2591,7 +2453,7 @@ H5C_protect(H5F_t * f, * see no point in worrying about the fourth. */ - if(H5C__make_space_in_cache(f, space_needed, write_permitted) < 0 ) + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") } /* end if */ @@ -2604,7 +2466,7 @@ H5C_protect(H5F_t * f, * ******************************************* * * Set the flush_last field - * of the newly loaded entry before inserting it into the + * of the newly loaded entry before inserting it into the * index. Must do this, as the index tracked the number of * entries with the flush_last field set, but assumes that * the field will not change after insertion into the index. @@ -2616,7 +2478,7 @@ H5C_protect(H5F_t * f, H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL) - if ( ( entry_ptr->is_dirty ) && ( ! (entry_ptr->in_slist) ) ) { + if ((entry_ptr->is_dirty) && (!(entry_ptr->in_slist))) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, NULL) } @@ -2636,25 +2498,25 @@ H5C_protect(H5F_t * f, HDassert(entry_ptr->addr == addr); HDassert(entry_ptr->type == type); - if(entry_ptr->is_protected) { - if(read_only && entry_ptr->is_read_only) { - HDassert(entry_ptr->ro_ref_count > 0); - (entry_ptr->ro_ref_count)++; - } /* end if */ + if (entry_ptr->is_protected) { + if (read_only && entry_ptr->is_read_only) { + HDassert(entry_ptr->ro_ref_count > 0); + (entry_ptr->ro_ref_count)++; + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Target already protected & not read only?!?") } /* end if */ else { - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) + H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) - entry_ptr->is_protected = TRUE; + entry_ptr->is_protected = TRUE; - if ( read_only ) { - entry_ptr->is_read_only = TRUE; - entry_ptr->ro_ref_count = 1; - } /* end if */ + if (read_only) { + entry_ptr->is_read_only = TRUE; + entry_ptr->ro_ref_count = 1; + } /* end if */ - entry_ptr->dirtied = FALSE; + entry_ptr->dirtied = FALSE; } /* end else */ H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) @@ -2663,61 +2525,58 @@ H5C_protect(H5F_t * f, ret_value = thing; - if ( ( cache_ptr->evictions_enabled ) && - ( ( cache_ptr->size_decreased ) || - ( ( cache_ptr->resize_enabled ) && - ( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ) ) ) ) { + if ((cache_ptr->evictions_enabled) && + ((cache_ptr->size_decreased) || + ((cache_ptr->resize_enabled) && + (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)))) { - if ( ! have_write_permitted ) { + if (!have_write_permitted) { - if ( cache_ptr->check_write_permitted != NULL ) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted") else have_write_permitted = TRUE; - } else { + } + else { write_permitted = cache_ptr->write_permitted; have_write_permitted = TRUE; - } } - if(cache_ptr->resize_enabled && - (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)) { + if (cache_ptr->resize_enabled && + (cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length)) { - if(H5C__auto_adjust_cache_size(f, write_permitted) < 0) + if (H5C__auto_adjust_cache_size(f, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Cache auto-resize failed") } /* end if */ - if(cache_ptr->size_decreased) { + if (cache_ptr->size_decreased) { cache_ptr->size_decreased = FALSE; /* check to see if the cache is now oversized due to the cache * size reduction. If it is, try to evict enough entries to * bring the cache size down to the current maximum cache size. - * - * Also, if the min_clean_size requirement is not met, we - * should also call H5C__make_space_in_cache() to bring us - * into complience. + * + * Also, if the min_clean_size requirement is not met, we + * should also call H5C__make_space_in_cache() to bring us + * into complience. */ - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - if ( ( cache_ptr->index_size > cache_ptr->max_cache_size ) - || - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size) ) { + if ((cache_ptr->index_size > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)) { - if(cache_ptr->index_size > cache_ptr->max_cache_size) + if (cache_ptr->index_size > cache_ptr->max_cache_size) cache_ptr->cache_full = TRUE; - if(H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0 ) + if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") } } /* end if */ @@ -2728,35 +2587,33 @@ H5C_protect(H5F_t * f, * the cache and protected. We must wait until it is protected so it is not * evicted during the notify callback. */ - if(was_loaded) { + if (was_loaded) { /* If the entry's type has a 'notify' callback send a 'after load' * notice now that the entry is fully integrated into the cache. */ - if(entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, "can't notify client about entry inserted into cache") + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, + "can't notify client about entry inserted into cache") } /* end if */ #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) + 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 */ 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_protect() */ - /*------------------------------------------------------------------------- * * Function: H5C_reset_cache_hit_rate_stats() @@ -2770,73 +2627,71 @@ H5C_protect(H5F_t * f, *------------------------------------------------------------------------- */ herr_t -H5C_reset_cache_hit_rate_stats(H5C_t * cache_ptr) +H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - cache_ptr->cache_hits = 0; - cache_ptr->cache_accesses = 0; + cache_ptr->cache_hits = 0; + cache_ptr->cache_accesses = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_reset_cache_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5C_set_cache_auto_resize_config * - * Purpose: Set the cache automatic resize configuration to the - * provided values if they are in range, and fail if they - * are not. + * Purpose: Set the cache automatic resize configuration to the + * provided values if they are in range, and fail if they + * are not. * - * If the new configuration enables automatic cache resizing, - * coerce the cache max size and min clean size into agreement - * with the new policy and re-set the full cache hit rate - * stats. + * If the new configuration enables automatic cache resizing, + * coerce the cache max size and min clean size into agreement + * with the new policy and re-set the full cache hit rate + * stats. * * Return: SUCCEED on success, and FAIL on failure. * * Programmer: John Mainzer - * 10/8/04 + * 10/8/04 * *------------------------------------------------------------------------- */ herr_t -H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, - H5C_auto_size_ctl_t *config_ptr) +H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) { - size_t new_max_cache_size; - size_t new_min_clean_size; - herr_t ret_value = SUCCEED; /* Return value */ + size_t new_max_cache_size; + size_t new_min_clean_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown config version") /* check general configuration section of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in general configuration fields of new config") /* check size increase control fields of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size increase control fields of new config") /* check size decrease control fields of the config: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size decrease control fields of new config") /* check for conflicts between size increase and size decrease controls: */ - if(H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "conflicting threshold fields in new config") /* will set the increase possible fields to FALSE later if needed */ @@ -2844,16 +2699,15 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, cache_ptr->flash_size_increase_possible = TRUE; cache_ptr->size_decrease_possible = TRUE; - switch(config_ptr->incr_mode) { + switch (config_ptr->incr_mode) { case H5C_incr__off: cache_ptr->size_increase_possible = FALSE; break; case H5C_incr__threshold: - if((config_ptr->lower_hr_threshold <= (double)0.0f) || - (config_ptr->increment <= (double)1.0f) || - ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) - cache_ptr->size_increase_possible = FALSE; + if ((config_ptr->lower_hr_threshold <= 0.0) || (config_ptr->increment <= 1.0) || + ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) + cache_ptr->size_increase_possible = FALSE; break; default: /* should be unreachable */ @@ -2865,28 +2719,27 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * we wait until the end of the function, when this field is set. */ - switch(config_ptr->decr_mode) { + switch (config_ptr->decr_mode) { case H5C_decr__off: cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__threshold: - if((config_ptr->upper_hr_threshold >= (double)1.0f) || - (config_ptr->decrement >= (double)1.0f) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) + if ((config_ptr->upper_hr_threshold >= 1.0) || (config_ptr->decrement >= 1.0) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out: - if(((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= 1.0)) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0))) cache_ptr->size_decrease_possible = FALSE; break; case H5C_decr__age_out_with_threshold: - if(((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= (double)1.0f)) || - ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0)) || - (config_ptr->upper_hr_threshold >= (double)1.0f)) + if (((config_ptr->apply_empty_reserve) && (config_ptr->empty_reserve >= 1.0)) || + ((config_ptr->apply_max_decrement) && (config_ptr->max_decrement <= 0)) || + (config_ptr->upper_hr_threshold >= 1.0)) cache_ptr->size_decrease_possible = FALSE; break; @@ -2894,17 +2747,16 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown decr_mode?!?!?") } /* end switch */ - if(config_ptr->max_size == config_ptr->min_size) { - cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; - cache_ptr->size_decrease_possible = FALSE; + if (config_ptr->max_size == config_ptr->min_size) { + cache_ptr->size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->size_decrease_possible = FALSE; } /* end if */ /* flash_size_increase_possible is intentionally omitted from the * following: */ - cache_ptr->resize_enabled = cache_ptr->size_increase_possible || - cache_ptr->size_decrease_possible; + cache_ptr->resize_enabled = cache_ptr->size_increase_possible || cache_ptr->size_decrease_possible; cache_ptr->resize_ctl = *config_ptr; @@ -2916,22 +2768,20 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * go through the exercise even if the current size is within * range and an initial size has not been provided. */ - if(cache_ptr->resize_ctl.set_initial_size) + if (cache_ptr->resize_ctl.set_initial_size) new_max_cache_size = cache_ptr->resize_ctl.initial_size; - else if(cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) + else if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) new_max_cache_size = cache_ptr->resize_ctl.max_size; - else if(cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) + else if (cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) new_max_cache_size = cache_ptr->resize_ctl.min_size; else new_max_cache_size = cache_ptr->max_cache_size; - new_min_clean_size = (size_t)((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); - + new_min_clean_size = (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); /* since new_min_clean_size is of type size_t, we have * - * ( 0 <= new_min_clean_size ) + * ( 0 <= new_min_clean_size ) * * by definition. */ @@ -2939,25 +2789,25 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, HDassert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); HDassert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); - if(new_max_cache_size < cache_ptr->max_cache_size) + if (new_max_cache_size < cache_ptr->max_cache_size) cache_ptr->size_decreased = TRUE; cache_ptr->max_cache_size = new_max_cache_size; cache_ptr->min_clean_size = new_min_clean_size; - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") /* remove excess epoch markers if any */ - if((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || - (config_ptr->decr_mode == H5C_decr__age_out)) { - if(cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) - if(H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + if ((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || + (config_ptr->decr_mode == H5C_decr__age_out)) { + if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") } /* end if */ - else if(cache_ptr->epoch_markers_active > 0) { - if(H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) + else if (cache_ptr->epoch_markers_active > 0) { + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") } @@ -2969,29 +2819,28 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, * go ahead and configure it. */ - if(cache_ptr->flash_size_increase_possible) { - switch(config_ptr->flash_incr_mode) { + if (cache_ptr->flash_size_increase_possible) { + switch (config_ptr->flash_incr_mode) { case H5C_flash_incr__off: cache_ptr->flash_size_increase_possible = FALSE; 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 */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5C_set_evictions_enabled() * @@ -3008,11 +2857,11 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") /* There is no fundamental reason why we should not permit @@ -3021,9 +2870,8 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) * want to, and allowing it would greatly complicate testing * the feature. Hence the following: */ - if((evictions_enabled != TRUE) && - ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || - (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) + if ((evictions_enabled != TRUE) && ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || + (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't disable evictions when auto resize enabled") cache_ptr->evictions_enabled = evictions_enabled; @@ -3032,27 +2880,26 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_evictions_enabled() */ - /*------------------------------------------------------------------------- * * Function: H5C_set_slist_enabled() * * Purpose: Enable or disable the slist as directed. * - * The slist (skip list) is an address ordered list of - * dirty entries in the metadata cache. However, this + * The slist (skip list) is an address ordered list of + * dirty entries in the metadata cache. However, this * list is only needed during flush and close, where we - * use it to write entries in more or less increasing - * address order. + * use it to write entries in more or less increasing + * address order. * * This function sets up and enables further operations - * on the slist, or disable the slist. This in turn - * allows us to avoid the overhead of maintaining the + * on the slist, or disable the slist. This in turn + * allows us to avoid the overhead of maintaining the * slist when it is not needed. * * - * If the slist_enabled parameter is TRUE, the function - * + * If the slist_enabled parameter is TRUE, the function + * * 1) Verifies that the slist is empty. * * 2) Scans the index list, and inserts all dirty entries @@ -3060,7 +2907,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) * * 3) Sets cache_ptr->slist_enabled = TRUE. * - * Note that the clear_slist parameter is ignored if + * Note that the clear_slist parameter is ignored if * the slist_enabed parameter is TRUE. * * @@ -3074,7 +2921,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) * Thus shutdown proceeds as follows: * * 1) Test to see if the slist is empty. If it is, proceed - * to step 3. + * to step 3. * * 2) Test to see if the clear_slist parameter is TRUE. * @@ -3083,7 +2930,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) * If it isn't, throw an error. * * 3) set cache_ptr->slist_enabled = FALSE. - * + * * Return: SUCCEED on success, and FAIL on failure. * * Programmer: John Mainzer @@ -3096,50 +2943,46 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) *------------------------------------------------------------------------- */ herr_t -H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, - hbool_t clear_slist) +H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_slist) { - H5C_cache_entry_t * entry_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") #if H5C__SLIST_OPT_ENABLED - if ( slist_enabled ) { + if (slist_enabled) { - if ( cache_ptr->slist_enabled ) { + if (cache_ptr->slist_enabled) { HDassert(FALSE); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already enabled?") } - if ( ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { HDassert(FALSE); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty (1)?") } - - /* set cache_ptr->slist_enabled to TRUE so that the slist + /* set cache_ptr->slist_enabled to TRUE so that the slist * mainenance macros will be enabled. */ cache_ptr->slist_enabled = TRUE; - /* scan the index list and insert all dirty entries in the slist */ - entry_ptr = cache_ptr->il_head; + entry_ptr = cache_ptr->il_head; - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { - HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } @@ -3147,32 +2990,31 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, entry_ptr = entry_ptr->il_next; } - /* we don't maintain a dirty index len, so we can't do a cross + /* we don't maintain a dirty index len, so we can't do a cross * check against it. Note that there is no point in cross checking * against the dirty LRU size, as the dirty LRU may not be maintained, - * and in any case, there is no requirement that all dirty entries + * and in any case, there is no requirement that all dirty entries * will reside on the dirty LRU. */ - HDassert( cache_ptr->dirty_index_size == cache_ptr->slist_size ); - - } else { /* take down the skip list */ + HDassert(cache_ptr->dirty_index_size == cache_ptr->slist_size); + } + else { /* take down the skip list */ - if ( ! cache_ptr->slist_enabled ) { + if (!cache_ptr->slist_enabled) { HDassert(FALSE); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already disabled?") } - if ( ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { - if ( clear_slist ) { + if (clear_slist) { H5SL_node_t *node_ptr; node_ptr = H5SL_first(cache_ptr->slist_ptr); - while ( node_ptr != NULL ) { + while (node_ptr != NULL) { entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); @@ -3180,8 +3022,9 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, node_ptr = H5SL_first(cache_ptr->slist_ptr); } - } else { - + } + else { + HDassert(FALSE); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty (2)?") } @@ -3189,8 +3032,8 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, cache_ptr->slist_enabled = FALSE; - HDassert( 0 == cache_ptr->slist_len ); - HDassert( 0 == cache_ptr->slist_size ); + HDassert(0 == cache_ptr->slist_len); + HDassert(0 == cache_ptr->slist_size); } #else /* H5C__SLIST_OPT_ENABLED is FALSE */ @@ -3198,19 +3041,18 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, HDassert(cache_ptr->slist_enabled); #endif /* H5C__SLIST_OPT_ENABLED is FALSE */ - + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_slist_enabled() */ - /*------------------------------------------------------------------------- * Function: H5C_unpin_entry() * - * Purpose: Unpin a cache entry. The entry can be either protected or - * unprotected at the time of call, but must be pinned. + * Purpose: Unpin a cache entry. The entry can be either protected or + * unprotected at the time of call, but must be pinned. * * Return: Non-negative on success/Negative on failure * @@ -3225,9 +3067,9 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, herr_t H5C_unpin_entry(void *_entry_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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -3238,46 +3080,42 @@ 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 */ - /* Unpin the entry */ - if(H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry from client") done: #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 */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unpin_entry() */ - /*------------------------------------------------------------------------- * Function: H5C_unprotect * - * Purpose: Undo an H5C_protect() call -- specifically, mark the - * entry as unprotected, remove it from the protected list, - * and give it back to the replacement policy. + * Purpose: Undo an H5C_protect() call -- specifically, mark the + * entry as unprotected, remove it from the protected list, + * and give it back to the replacement policy. * - * The TYPE and ADDR arguments must be the same as those in - * the corresponding call to H5C_protect() and the THING - * argument must be the value returned by that call to - * H5C_protect(). + * The TYPE and ADDR arguments must be the same as those in + * the corresponding call to H5C_protect() and the THING + * argument must be the value returned by that call to + * H5C_protect(). * * Return: Non-negative on success/Negative on failure * - * If the deleted flag is TRUE, simply remove the target entry - * from the cache, clear it, and free it without writing it to - * disk. + * If the deleted flag is TRUE, simply remove the target entry + * from the cache, clear it, and free it without writing it to + * disk. * * Return: Non-negative on success/Negative on failure * @@ -3356,126 +3194,121 @@ H5C_unpin_entry(void *_entry_ptr) * * * JRM -- 5/8/20 - * Updated for the possibility that the slist will be + * Updated for the possibility that the slist will be * disabled. * *------------------------------------------------------------------------- */ herr_t -H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) +H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) { - H5C_t * cache_ptr; - hbool_t deleted; - hbool_t dirtied; - hbool_t set_flush_marker; - hbool_t pin_entry; - hbool_t unpin_entry; - hbool_t free_file_space; - hbool_t take_ownership; - hbool_t was_clean; + H5C_t * cache_ptr; + hbool_t deleted; + hbool_t dirtied; + hbool_t set_flush_marker; + hbool_t pin_entry; + hbool_t unpin_entry; + hbool_t free_file_space; + hbool_t take_ownership; + hbool_t was_clean; #ifdef H5_HAVE_PARALLEL - hbool_t clear_entry = FALSE; + hbool_t clear_entry = FALSE; #endif /* H5_HAVE_PARALLEL */ - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * test_entry_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *test_entry_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - deleted = ((flags & H5C__DELETED_FLAG) != 0); - dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + deleted = ((flags & H5C__DELETED_FLAG) != 0); + dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( H5F_addr_defined(addr) ); - HDassert( thing ); - HDassert( ! ( pin_entry && unpin_entry ) ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(H5F_addr_defined(addr)); + HDassert(thing); + HDassert(!(pin_entry && unpin_entry)); /* deleted flag must accompany free_file_space */ - HDassert( ( ! free_file_space ) || ( deleted ) ); + HDassert((!free_file_space) || (deleted)); /* deleted flag must accompany take_ownership */ - HDassert( ( ! take_ownership ) || ( deleted ) ); + HDassert((!take_ownership) || (deleted)); /* can't have both free_file_space & take_ownership */ - HDassert( ! ( free_file_space && take_ownership ) ); + HDassert(!(free_file_space && take_ownership)); entry_ptr = (H5C_cache_entry_t *)thing; - HDassert( entry_ptr->addr == addr ); + HDassert(entry_ptr->addr == addr); /* also set the dirtied variable if the dirtied field is set in * the entry. */ dirtied |= entry_ptr->dirtied; - was_clean = ! ( entry_ptr->is_dirty ); + 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") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* if the entry has multiple read only protects, just decrement * the ro_ref_counter. Don't actually unprotect until the ref count * drops to zero. */ - if ( entry_ptr->ro_ref_count > 1 ) { + if (entry_ptr->ro_ref_count > 1) { /* Sanity check */ HDassert(entry_ptr->is_protected); HDassert(entry_ptr->is_read_only); - if ( dirtied ) + if (dirtied) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Read only entry modified??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") /* Reduce the RO ref count */ (entry_ptr->ro_ref_count)--; /* Pin or unpin the entry as requested. */ - if ( pin_entry ) { + if (pin_entry) { /* Pin the entry from a client */ - if ( H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0 ) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, \ - "Can't pin entry by client") + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) - } else if ( unpin_entry ) { + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") + } + else if (unpin_entry) { /* Unpin the entry from a client */ - if ( H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0 ) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, \ - "Can't unpin entry by client") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } /* end if */ - } else { + } + else { - if ( entry_ptr->is_read_only ) { + if (entry_ptr->is_read_only) { /* Sanity check */ HDassert(entry_ptr->ro_ref_count == 1); - if ( dirtied ) + if (dirtied) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Read only entry modified??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") entry_ptr->is_read_only = FALSE; entry_ptr->ro_ref_count = 0; @@ -3498,112 +3331,103 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * are contiguous, with only one dirty flag, we have to let the supplied * functions deal with the resetting the is_dirty flag. */ - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->clear_on_unprotect) { /* Sanity check */ HDassert(entry_ptr->is_dirty); entry_ptr->clear_on_unprotect = FALSE; - if(!dirtied) + if (!dirtied) clear_entry = TRUE; } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ - if ( ! entry_ptr->is_protected ) + if (!entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Entry already unprotected??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Entry already unprotected??") /* Mark the entry as dirty if appropriate */ entry_ptr->is_dirty = (entry_ptr->is_dirty || dirtied); - if ( dirtied ) { + if (dirtied) { - if ( entry_ptr->image_up_to_date ) { + if (entry_ptr->image_up_to_date) { entry_ptr->image_up_to_date = FALSE; - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_unserialized(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "Can't propagate serialization status to fd parents") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Check for newly dirtied entry */ - if ( was_clean && entry_ptr->is_dirty ) { + if (was_clean && entry_ptr->is_dirty) { /* Update index for newly dirtied entry */ H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) - /* If the entry's type has a 'notify' callback send a - * 'entry dirtied' notice now that the entry is fully + /* If the entry's type has a 'notify' callback send a + * 'entry dirtied' notice now that the entry is fully * integrated into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry dirty flag set") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") /* Propagate the flush dep dirty flag up the flush dependency chain - * if appropriate + * if appropriate */ - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_dirty(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ - "Can't propagate flush dep dirty flag") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") } } /* end if */ /* Check for newly clean entry */ - else if ( ! was_clean && ! entry_ptr->is_dirty ) { + else if (!was_clean && !entry_ptr->is_dirty) { - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully * integrated into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry dirty flag cleared") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") /* Propagate the flush dep clean flag up the flush dependency chain - * if appropriate + * if appropriate */ - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_clean(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ - "Can't propagate flush dep dirty flag") - - } + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + } } /* end else-if */ /* Pin or unpin the entry as requested. */ - if ( pin_entry ) { + if (pin_entry) { /* Pin the entry from a client */ - if ( H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0 ) + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, \ - "Can't pin entry by client") - - } else if ( unpin_entry ) { + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") + } + else if (unpin_entry) { /* Unpin the entry from a client */ - if ( H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0 ) + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, \ - "Can't unpin entry by client") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } /* end if */ /* H5C__UPDATE_RP_FOR_UNPROTECT will place the unprotected entry on @@ -3616,13 +3440,13 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* if the entry is dirty, 'or' its flush_marker with the set flush flag, * and then add it to the skip list if it isn't there already. */ - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { entry_ptr->flush_marker |= set_flush_marker; - if ( !entry_ptr->in_slist ) { + if (!entry_ptr->in_slist) { - /* this is a no-op if cache_ptr->slist_enabled is FALSE */ + /* this is a no-op if cache_ptr->slist_enabled is FALSE */ H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } } /* end if */ @@ -3636,32 +3460,30 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * makes good use of existing code. * JRM - 5/19/04 */ - if ( deleted ) { + if (deleted) { - unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_INVALIDATE_FLAG); + unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_INVALIDATE_FLAG); /* verify that the target entry is in the cache. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if ( test_entry_ptr == NULL ) + if (test_entry_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "entry not in hash table?!?") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if ( test_entry_ptr != entry_ptr ) + else if (test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "hash table contains multiple entries for addr?!?") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, + "hash table contains multiple entries for addr?!?") /* Set the 'free file space' flag for the flush, if needed */ - if ( free_file_space ) { + if (free_file_space) { flush_flags |= H5C__FREE_FILE_SPACE_FLAG; } /* Set the "take ownership" flag for the flush, if needed */ - if ( take_ownership ) { + if (take_ownership) { flush_flags |= H5C__TAKE_OWNERSHIP_FLAG; } @@ -3669,40 +3491,34 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* Delete the entry from the skip list on destroy */ flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - HDassert( ( ! cache_ptr->slist_enabled ) || \ - ( ( ( ! was_clean ) || dirtied ) == \ - ( entry_ptr->in_slist ) ) ); + HDassert((!cache_ptr->slist_enabled) || (((!was_clean) || dirtied) == (entry_ptr->in_slist))); - if ( H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0 ) + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Can't flush entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush entry") } /* end if */ #ifdef H5_HAVE_PARALLEL - else if ( clear_entry ) { + else if (clear_entry) { /* verify that the target entry is in the cache. */ H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if ( test_entry_ptr == NULL ) + if (test_entry_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "entry not in hash table?!?") + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if ( test_entry_ptr != entry_ptr ) + else if (test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "hash table contains multiple entries for addr?!?") - if ( H5C__flush_single_entry(f, entry_ptr, - H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Can't clear entry") + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear entry") } /* end else if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ } H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) @@ -3710,19 +3526,16 @@ 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") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unprotect() */ - /*------------------------------------------------------------------------- * * Function: H5C_unsettle_entry_ring @@ -3751,51 +3564,51 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ + H5C_t * cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(entry); HDassert(entry->ring != H5C_RING_UNDEFINED); - HDassert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || (H5C_RING_MDFSM == entry->ring)); + HDassert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || + (H5C_RING_MDFSM == entry->ring)); cache = entry->cache_ptr; HDassert(cache); HDassert(cache->magic == H5C__H5C_T_MAGIC); - switch(entry->ring) { - case H5C_RING_USER: + switch (entry->ring) { + case H5C_RING_USER: /* Do nothing */ - break; - - case H5C_RING_RDFSM: - if(cache->rdfsm_settled) { - if(cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") - cache->rdfsm_settled = FALSE; - } /* end if */ - break; - - case H5C_RING_MDFSM: - if(cache->mdfsm_settled) { - if(cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") - cache->mdfsm_settled = FALSE; - } /* end if */ - break; - - default: - HDassert(FALSE); /* this should be un-reachable */ - break; + break; + + case H5C_RING_RDFSM: + if (cache->rdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache->rdfsm_settled = FALSE; + } /* end if */ + break; + + case H5C_RING_MDFSM: + if (cache->mdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache->mdfsm_settled = FALSE; + } /* end if */ + break; + + default: + HDassert(FALSE); /* this should be un-reachable */ + break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unsettle_entry_ring() */ - /*------------------------------------------------------------------------- * Function: H5C_unsettle_ring() * @@ -3821,9 +3634,9 @@ H5C_unsettle_entry_ring(void *_entry) *------------------------------------------------------------------------- */ herr_t -H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) +H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3836,41 +3649,40 @@ H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) cache_ptr = f->shared->cache; HDassert(H5C__H5C_T_MAGIC == cache_ptr->magic); - switch(ring) { + switch (ring) { case H5C_RING_RDFSM: - if(cache_ptr->rdfsm_settled) { - if(cache_ptr->close_warning_received) + if (cache_ptr->rdfsm_settled) { + if (cache_ptr->close_warning_received) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") cache_ptr->rdfsm_settled = FALSE; } /* end if */ break; case H5C_RING_MDFSM: - if(cache_ptr->mdfsm_settled) { - if(cache_ptr->close_warning_received) + if (cache_ptr->mdfsm_settled) { + if (cache_ptr->close_warning_received) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") cache_ptr->mdfsm_settled = FALSE; } /* end if */ break; - default: - HDassert(FALSE); /* this should be un-reachable */ - break; + default: + HDassert(FALSE); /* this should be un-reachable */ + break; } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_unsettle_ring() */ - /*------------------------------------------------------------------------- * Function: H5C_validate_resize_config() * - * Purpose: Run a sanity check on the specified sections of the - * provided instance of struct H5C_auto_size_ctl_t. + * Purpose: Run a sanity check on the specified sections of the + * provided instance of struct H5C_auto_size_ctl_t. * - * Do nothing and return SUCCEED if no errors are detected, - * and flag an error and return FAIL otherwise. + * Do nothing and return SUCCEED if no errors are detected, + * and flag an error and return FAIL otherwise. * * Return: Non-negative on success/Negative on failure * @@ -3880,58 +3692,54 @@ H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring) *------------------------------------------------------------------------- */ herr_t -H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, - unsigned int tests) +H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - if(config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown config version") - if((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { + if ((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { - if(config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) + if (config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") - if(config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) + if (config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") - if(config_ptr->min_size > config_ptr->max_size) + if (config_ptr->min_size > config_ptr->max_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") - if(config_ptr->set_initial_size && - ((config_ptr->initial_size < config_ptr->min_size) || - (config_ptr->initial_size > config_ptr->max_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "initial_size must be in the interval [min_size, max_size]") + if (config_ptr->set_initial_size && ((config_ptr->initial_size < config_ptr->min_size) || + (config_ptr->initial_size > config_ptr->max_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "initial_size must be in the interval [min_size, max_size]") - if((config_ptr->min_clean_fraction < (double)0.0f) || - (config_ptr->min_clean_fraction > (double)1.0f)) + if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") - if(config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) + if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") - if(config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) + if (config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too big") } /* H5C_RESIZE_CFG__VALIDATE_GENERAL */ - - if((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { - if((config_ptr->incr_mode != H5C_incr__off) && - (config_ptr->incr_mode != H5C_incr__threshold)) + if ((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { + if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - if(config_ptr->incr_mode == H5C_incr__threshold) { - if((config_ptr->lower_hr_threshold < (double)0.0f) || - (config_ptr->lower_hr_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "lower_hr_threshold must be in the range [0.0, 1.0]") + if (config_ptr->incr_mode == H5C_incr__threshold) { + if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "lower_hr_threshold must be in the range [0.0, 1.0]") - if(config_ptr->increment < (double)1.0f) + if (config_ptr->increment < 1.0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") /* no need to check max_increment, as it is a size_t, @@ -3939,44 +3747,40 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, */ } /* H5C_incr__threshold */ - switch(config_ptr->flash_incr_mode) { + switch (config_ptr->flash_incr_mode) { case H5C_flash_incr__off: /* nothing to do here */ break; case H5C_flash_incr__add_space: - if((config_ptr->flash_multiple < (double)0.1f) || - (config_ptr->flash_multiple > (double)10.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flash_multiple must be in the range [0.1, 10.0]") - if((config_ptr->flash_threshold < (double)0.1f) || - (config_ptr->flash_threshold > (double)1.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flash_threshold must be in the range [0.1, 1.0]") + if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_multiple must be in the range [0.1, 10.0]") + if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_threshold must be in the range [0.1, 1.0]") break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") break; } /* end switch */ - } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ + } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ + if ((tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0) { - if ( (tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0 ) { - - if ( ( config_ptr->decr_mode != H5C_decr__off ) && - ( config_ptr->decr_mode != H5C_decr__threshold ) && - ( config_ptr->decr_mode != H5C_decr__age_out ) && - ( config_ptr->decr_mode != H5C_decr__age_out_with_threshold ) - ) { + if ((config_ptr->decr_mode != H5C_decr__off) && (config_ptr->decr_mode != H5C_decr__threshold) && + (config_ptr->decr_mode != H5C_decr__age_out) && + (config_ptr->decr_mode != H5C_decr__age_out_with_threshold)) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") } - if ( config_ptr->decr_mode == H5C_decr__threshold ) { - if(config_ptr->upper_hr_threshold > (double)1.0f) + if (config_ptr->decr_mode == H5C_decr__threshold) { + if (config_ptr->upper_hr_threshold > 1.0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") - if((config_ptr->decrement > (double)1.0f) || - (config_ptr->decrement < (double)0.0f)) + if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t @@ -3984,17 +3788,16 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, */ } /* H5C_decr__threshold */ - if((config_ptr->decr_mode == H5C_decr__age_out) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) { + if ((config_ptr->decr_mode == H5C_decr__age_out) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) { - if(config_ptr->epochs_before_eviction < 1) + if (config_ptr->epochs_before_eviction < 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction must be positive") - if(config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) + if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - if((config_ptr->apply_empty_reserve) && - ((config_ptr->empty_reserve > (double)1.0f) || - (config_ptr->empty_reserve < (double)0.0f))) + if ((config_ptr->apply_empty_reserve) && + ((config_ptr->empty_reserve > 1.0) || (config_ptr->empty_reserve < 0.0))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t @@ -4002,19 +3805,18 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, */ } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - if(config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { - if((config_ptr->upper_hr_threshold > (double)1.0f) || - (config_ptr->upper_hr_threshold < (double)0.0f)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be in the interval [0.0, 1.0]") + if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) { + if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "upper_hr_threshold must be in the interval [0.0, 1.0]") } /* H5C_decr__age_out_with_threshold */ - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - if ( (tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0 ) { - if((config_ptr->incr_mode == H5C_incr__threshold) - && ((config_ptr->decr_mode == H5C_decr__threshold) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) - && (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) + if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { + if ((config_ptr->incr_mode == H5C_incr__threshold) && + ((config_ptr->decr_mode == H5C_decr__threshold) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && + (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ @@ -4022,15 +3824,14 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_validate_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5C_create_flush_dependency() * - * Purpose: Initiates a parent<->child entry flush dependency. The parent + * Purpose: Initiates a parent<->child entry flush dependency. The parent * entry must be pinned or protected at the time of call, and must * have all dependencies removed before the cache can shut down. * - * Note: Flush dependencies in the cache indicate that a child entry + * Note: Flush dependencies in the cache indicate that a child entry * must be flushed to the file before its parent. (This is * currently used to implement Single-Writer/Multiple-Reader (SWMR) * I/O access for data structures in the file). @@ -4046,12 +3847,12 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, *------------------------------------------------------------------------- */ herr_t -H5C_create_flush_dependency(void * parent_thing, void * child_thing) +H5C_create_flush_dependency(void *parent_thing, void *child_thing) { - 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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -4071,19 +3872,19 @@ H5C_create_flush_dependency(void * parent_thing, void * child_thing) { unsigned u; - for(u = 0; u < child_entry->flush_dep_nparents; u++) + for (u = 0; u < child_entry->flush_dep_nparents; u++) HDassert(child_entry->flush_dep_parent[u] != parent_entry); - } /* end block */ + } /* end block */ #endif /* NDEBUG */ /* More sanity checks */ - if(child_entry == parent_entry) + if (child_entry == parent_entry) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry flush dependency parent can't be itself") - if(!(parent_entry->is_protected || parent_entry->is_pinned)) + if (!(parent_entry->is_protected || parent_entry->is_pinned)) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") /* Check for parent not pinned */ - if(!parent_entry->is_pinned) { + if (!parent_entry->is_pinned) { /* Sanity check */ HDassert(parent_entry->flush_dep_nchildren == 0); HDassert(!parent_entry->pinned_from_client); @@ -4098,21 +3899,26 @@ H5C_create_flush_dependency(void * parent_thing, void * child_thing) parent_entry->pinned_from_cache = TRUE; /* Check if we need to resize the child's parent array */ - if(child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { - if(child_entry->flush_dep_parent_nalloc == 0) { + if (child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { + if (child_entry->flush_dep_parent_nalloc == 0) { /* Array does not exist yet, allocate it */ HDassert(!child_entry->flush_dep_parent); - if(NULL == (child_entry->flush_dep_parent = (H5C_cache_entry_t **)H5FL_BLK_MALLOC(parent, H5C_FLUSH_DEP_PARENT_INIT * sizeof(H5C_cache_entry_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_MALLOC(H5C_cache_entry_ptr_t, H5C_FLUSH_DEP_PARENT_INIT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") child_entry->flush_dep_parent_nalloc = H5C_FLUSH_DEP_PARENT_INIT; } /* end if */ else { /* Resize existing array */ HDassert(child_entry->flush_dep_parent); - if(NULL == (child_entry->flush_dep_parent = (H5C_cache_entry_t **)H5FL_BLK_REALLOC(parent, child_entry->flush_dep_parent, 2 * child_entry->flush_dep_parent_nalloc * sizeof(H5C_cache_entry_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + 2 * child_entry->flush_dep_parent_nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") child_entry->flush_dep_parent_nalloc *= 2; } /* end else */ cache_ptr->entry_fd_height_change_counter++; @@ -4126,30 +3932,32 @@ H5C_create_flush_dependency(void * parent_thing, void * child_thing) parent_entry->flush_dep_nchildren++; /* Adjust the number of dirty children */ - if(child_entry->is_dirty) { + if (child_entry->is_dirty) { /* Sanity check */ HDassert(parent_entry->flush_dep_ndirty_children < parent_entry->flush_dep_nchildren); parent_entry->flush_dep_ndirty_children++; /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if(parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag set") + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") } /* end if */ /* adjust the parent's number of unserialized children. Note * that it is possible for and entry to be clean and unserialized. */ - if(!child_entry->image_up_to_date) { + if (!child_entry->image_up_to_date) { HDassert(parent_entry->flush_dep_nunser_children < parent_entry->flush_dep_nchildren); parent_entry->flush_dep_nunser_children++; /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if(parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag reset") + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") } /* end if */ /* Post-conditions, for successful operation */ @@ -4166,11 +3974,10 @@ H5C_create_flush_dependency(void * parent_thing, void * child_thing) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_create_flush_dependency() */ - /*------------------------------------------------------------------------- * Function: H5C_destroy_flush_dependency() * - * Purpose: Terminates a parent<-> child entry flush dependency. The + * Purpose: Terminates a parent<-> child entry flush dependency. The * parent entry must be pinned. * * Return: Non-negative on success/Negative on failure @@ -4181,13 +3988,13 @@ H5C_create_flush_dependency(void * parent_thing, void * child_thing) *------------------------------------------------------------------------- */ herr_t -H5C_destroy_flush_dependency(void *parent_thing, void * child_thing) +H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4204,38 +4011,40 @@ H5C_destroy_flush_dependency(void *parent_thing, void * child_thing) HDassert(cache_ptr == child_entry->cache_ptr); /* Usage checks */ - if(!parent_entry->is_pinned) + if (!parent_entry->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't pinned") - if(NULL == child_entry->flush_dep_parent) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Child entry doesn't have a flush dependency parent array") - if(0 == parent_entry->flush_dep_nchildren) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry flush dependency ref. count has no child dependencies") + if (NULL == child_entry->flush_dep_parent) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Child entry doesn't have a flush dependency parent array") + if (0 == parent_entry->flush_dep_nchildren) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry flush dependency ref. count has no child dependencies") /* Search for parent in child's parent array. This is a linear search * because we do not expect large numbers of parents. If this changes, we * may wish to change the parent array to a skip list */ - for(u = 0; u < child_entry->flush_dep_nparents; u++) - if(child_entry->flush_dep_parent[u] == parent_entry) + for (u = 0; u < child_entry->flush_dep_nparents; u++) + if (child_entry->flush_dep_parent[u] == parent_entry) break; - if(u == child_entry->flush_dep_nparents) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't a flush dependency parent for child entry") + if (u == child_entry->flush_dep_nparents) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry isn't a flush dependency parent for child entry") /* Remove parent entry from child's parent array */ - if(u < (child_entry->flush_dep_nparents - 1)) - HDmemmove(&child_entry->flush_dep_parent[u], - &child_entry->flush_dep_parent[u + 1], - (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); + if (u < (child_entry->flush_dep_nparents - 1)) + HDmemmove(&child_entry->flush_dep_parent[u], &child_entry->flush_dep_parent[u + 1], + (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); child_entry->flush_dep_nparents--; /* Adjust parent entry's nchildren and unpin parent if it goes to zero */ parent_entry->flush_dep_nchildren--; - if(0 == parent_entry->flush_dep_nchildren) { + if (0 == parent_entry->flush_dep_nchildren) { /* Sanity check */ HDassert(parent_entry->pinned_from_cache); /* Check if we should unpin parent entry now */ - if(!parent_entry->pinned_from_client) - if(H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) + if (!parent_entry->pinned_from_client) + if (H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry") /* Mark the entry as unpinned from the cache's action */ @@ -4243,39 +4052,44 @@ H5C_destroy_flush_dependency(void *parent_thing, void * child_thing) } /* end if */ /* Adjust parent entry's ndirty_children */ - if(child_entry->is_dirty) { + if (child_entry->is_dirty) { /* Sanity check */ HDassert(parent_entry->flush_dep_ndirty_children > 0); parent_entry->flush_dep_ndirty_children--; /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if(parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag reset") + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") } /* end if */ /* adjust parent entry's number of unserialized children */ - if(!child_entry->image_up_to_date) { + if (!child_entry->image_up_to_date) { HDassert(parent_entry->flush_dep_nunser_children > 0); parent_entry->flush_dep_nunser_children--; /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if(parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag set") + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") } /* end if */ /* Shrink or free the parent array if apporpriate */ - if(child_entry->flush_dep_nparents == 0) { - child_entry->flush_dep_parent = (H5C_cache_entry_t **)H5FL_BLK_FREE(parent, child_entry->flush_dep_parent); + 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; } /* end if */ - else if(child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT - && child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { - if(NULL == (child_entry->flush_dep_parent = (H5C_cache_entry_t **)H5FL_BLK_REALLOC(parent, child_entry->flush_dep_parent, (child_entry->flush_dep_parent_nalloc / 4) * sizeof(H5C_cache_entry_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for flush dependency parent list") + else if (child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT && + child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + child_entry->flush_dep_parent_nalloc / 4))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") child_entry->flush_dep_parent_nalloc /= 4; } /* end if */ @@ -4283,16 +4097,14 @@ H5C_destroy_flush_dependency(void *parent_thing, void * child_thing) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_destroy_flush_dependency() */ - /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ - /*------------------------------------------------------------------------- * Function: H5C__pin_entry_from_client() * - * Purpose: Internal routine to pin a cache entry from a client action. + * Purpose: Internal routine to pin a cache entry from a client action. * * Return: Non-negative on success/Negative on failure * @@ -4309,7 +4121,7 @@ static herr_t H5C__pin_entry_from_client(H5C_t H5_ATTR_UNUSED *cache_ptr, H5C_cache_entry_t *entry_ptr) #endif { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4319,9 +4131,9 @@ H5C__pin_entry_from_client(H5C_t H5_ATTR_UNUSED *cache_ptr, H5C_cache_entry_t *e HDassert(entry_ptr->is_protected); /* Check if the entry is already pinned */ - if(entry_ptr->is_pinned) { + if (entry_ptr->is_pinned) { /* Check if the entry was pinned through an explicit pin from a client */ - if(entry_ptr->pinned_from_client) + if (entry_ptr->pinned_from_client) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "entry is already pinned") } /* end if */ else { @@ -4337,11 +4149,10 @@ H5C__pin_entry_from_client(H5C_t H5_ATTR_UNUSED *cache_ptr, H5C_cache_entry_t *e FUNC_LEAVE_NOAPI(ret_value) } /* H5C__pin_entry_from_client() */ - /*------------------------------------------------------------------------- * Function: H5C__unpin_entry_real() * - * Purpose: Internal routine to unpin a cache entry. + * Purpose: Internal routine to unpin a cache entry. * * Return: Non-negative on success/Negative on failure * @@ -4351,12 +4162,15 @@ H5C__pin_entry_from_client(H5C_t H5_ATTR_UNUSED *cache_ptr, H5C_cache_entry_t *e *------------------------------------------------------------------------- */ static herr_t -H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, - hbool_t update_rp) +H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ +#if H5C_DO_SANITY_CHECKS FUNC_ENTER_STATIC +#else + FUNC_ENTER_STATIC_NOERR +#endif /* Sanity checking */ HDassert(cache_ptr); @@ -4364,7 +4178,7 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr->is_pinned); /* If requested, update the replacement policy if the entry is not protected */ - if(update_rp && !entry_ptr->is_protected) + if (update_rp && !entry_ptr->is_protected) H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) /* Unpin the entry now */ @@ -4373,15 +4187,16 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, /* Update the stats for an unpin operation */ H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) +#if H5C_DO_SANITY_CHECKS done: +#endif FUNC_LEAVE_NOAPI(ret_value) } /* H5C__unpin_entry_real() */ - /*------------------------------------------------------------------------- * Function: H5C__unpin_entry_from_client() * - * Purpose: Internal routine to unpin a cache entry from a client action. + * Purpose: Internal routine to unpin a cache entry from a client action. * * Return: Non-negative on success/Negative on failure * @@ -4391,10 +4206,9 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, - hbool_t update_rp) +H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4403,14 +4217,14 @@ H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr); /* Error checking (should be sanity checks?) */ - if(!entry_ptr->is_pinned) + if (!entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry isn't pinned") - if(!entry_ptr->pinned_from_client) + if (!entry_ptr->pinned_from_client) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry wasn't pinned by cache client") /* Check if the entry is not pinned from a flush dependency */ - if(!entry_ptr->pinned_from_cache) - if(H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) + if (!entry_ptr->pinned_from_cache) + if (H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") /* Mark the entry as explicitly unpinned by the client */ @@ -4422,18 +4236,18 @@ H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, /*------------------------------------------------------------------------- * - * Function: H5C__auto_adjust_cache_size + * Function: H5C__auto_adjust_cache_size * - * Purpose: Obtain the current full cache hit rate, and compare it - * with the hit rate thresholds for modifying cache size. - * If one of the thresholds has been crossed, adjusts the - * size of the cache accordingly. + * Purpose: Obtain the current full cache hit rate, and compare it + * with the hit rate thresholds for modifying cache size. + * If one of the thresholds has been crossed, adjusts the + * size of the cache accordingly. * - * The function then resets the full cache hit rate - * statistics, and exits. + * The function then resets the full cache hit rate + * statistics, and exits. * * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. + * an attempt to flush a protected item. * * * Programmer: John Mainzer, 10/7/04 @@ -4443,95 +4257,89 @@ H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, static herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) { - 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; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - double hit_rate; - enum H5C_resize_status status = in_spec; /* will change if needed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + double hit_rate; + enum H5C_resize_status status = in_spec; /* will change if needed */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ); - HDassert( (double)0.0f <= (cache_ptr->resize_ctl).min_clean_fraction ); - HDassert( (cache_ptr->resize_ctl).min_clean_fraction <= (double)100.0f ); + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length); + HDassert(0.0 <= (cache_ptr->resize_ctl).min_clean_fraction); + HDassert((cache_ptr->resize_ctl).min_clean_fraction <= 100.0); /* check to see if cache_ptr->resize_in_progress is TRUE. If it, this * is a re-entrant call via a client callback called in the resize * process. To avoid an infinite recursion, set reentrant_call to * TRUE, and goto done. */ - if(cache_ptr->resize_in_progress) { + if (cache_ptr->resize_in_progress) { reentrant_call = TRUE; HGOTO_DONE(SUCCEED) } /* end if */ cache_ptr->resize_in_progress = TRUE; - if(!cache_ptr->resize_enabled) + if (!cache_ptr->resize_enabled) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") - HDassert(((cache_ptr->resize_ctl).incr_mode != H5C_incr__off) || \ - ((cache_ptr->resize_ctl).decr_mode != H5C_decr__off)); + HDassert(((cache_ptr->resize_ctl).incr_mode != H5C_incr__off) || + ((cache_ptr->resize_ctl).decr_mode != H5C_decr__off)); - if(H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - HDassert( ( (double)0.0f <= hit_rate ) && ( hit_rate <= (double)1.0f ) ); + HDassert((0.0 <= hit_rate) && (hit_rate <= 1.0)); - switch((cache_ptr->resize_ctl).incr_mode) { + switch ((cache_ptr->resize_ctl).incr_mode) { case H5C_incr__off: - if(cache_ptr->size_increase_possible) + if (cache_ptr->size_increase_possible) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "size_increase_possible but H5C_incr__off?!?!?") break; case H5C_incr__threshold: - if ( hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold ) { + if (hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold) { - if ( ! cache_ptr->size_increase_possible ) { + if (!cache_ptr->size_increase_possible) { status = increase_disabled; + } + else if (cache_ptr->max_cache_size >= (cache_ptr->resize_ctl).max_size) { - } else if ( cache_ptr->max_cache_size >= - (cache_ptr->resize_ctl).max_size ) { - - HDassert( cache_ptr->max_cache_size == \ - (cache_ptr->resize_ctl).max_size ); + HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).max_size); status = at_max_size; - - } else if ( ! cache_ptr->cache_full ) { + } + else if (!cache_ptr->cache_full) { status = not_full; + } + else { - } else { - - new_max_cache_size = (size_t) - (((double)(cache_ptr->max_cache_size)) * - (cache_ptr->resize_ctl).increment); + new_max_cache_size = + (size_t)(((double)(cache_ptr->max_cache_size)) * (cache_ptr->resize_ctl).increment); /* clip to max size if necessary */ - if ( new_max_cache_size > - (cache_ptr->resize_ctl).max_size ) { + if (new_max_cache_size > (cache_ptr->resize_ctl).max_size) { new_max_cache_size = (cache_ptr->resize_ctl).max_size; } /* clip to max increment if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_increment ) && - ( (cache_ptr->max_cache_size + - (cache_ptr->resize_ctl).max_increment) < - new_max_cache_size ) ) { + if (((cache_ptr->resize_ctl).apply_max_increment) && + ((cache_ptr->max_cache_size + (cache_ptr->resize_ctl).max_increment) < + new_max_cache_size)) { - new_max_cache_size = cache_ptr->max_cache_size + - (cache_ptr->resize_ctl).max_increment; + new_max_cache_size = + cache_ptr->max_cache_size + (cache_ptr->resize_ctl).max_increment; } status = increase; @@ -4555,19 +4363,11 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) * entry. The inserted_epoch_marker flag is used to track this. */ - if ( ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - ) - && - ( cache_ptr->epoch_markers_active < - (cache_ptr->resize_ctl).epochs_before_eviction - ) - ) { - - if(H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) + if ((((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + ((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold)) && + (cache_ptr->epoch_markers_active < (cache_ptr->resize_ctl).epochs_before_eviction)) { + + if (H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't insert new epoch marker") inserted_epoch_marker = TRUE; @@ -4578,49 +4378,42 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) * for action. In either case, status == in_spec at this point. */ - if ( status == in_spec ) { + if (status == in_spec) { - switch ( (cache_ptr->resize_ctl).decr_mode ) - { + switch ((cache_ptr->resize_ctl).decr_mode) { case H5C_decr__off: break; case H5C_decr__threshold: - if ( hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold ) { + if (hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold) { - if ( ! cache_ptr->size_decrease_possible ) { + if (!cache_ptr->size_decrease_possible) { status = decrease_disabled; + } + else if (cache_ptr->max_cache_size <= (cache_ptr->resize_ctl).min_size) { - } else if ( cache_ptr->max_cache_size <= - (cache_ptr->resize_ctl).min_size ) { - - HDassert( cache_ptr->max_cache_size == - (cache_ptr->resize_ctl).min_size ); + HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).min_size); status = at_min_size; + } + else { - } else { - - new_max_cache_size = (size_t) - (((double)(cache_ptr->max_cache_size)) * - (cache_ptr->resize_ctl).decrement); + new_max_cache_size = (size_t)(((double)(cache_ptr->max_cache_size)) * + (cache_ptr->resize_ctl).decrement); /* clip to min size if necessary */ - if ( new_max_cache_size < - (cache_ptr->resize_ctl).min_size ) { + if (new_max_cache_size < (cache_ptr->resize_ctl).min_size) { - new_max_cache_size = - (cache_ptr->resize_ctl).min_size; + new_max_cache_size = (cache_ptr->resize_ctl).min_size; } /* clip to max decrement if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_decrement ) && - ( ((cache_ptr->resize_ctl).max_decrement + - new_max_cache_size) < - cache_ptr->max_cache_size ) ) { + if (((cache_ptr->resize_ctl).apply_max_decrement) && + (((cache_ptr->resize_ctl).max_decrement + new_max_cache_size) < + cache_ptr->max_cache_size)) { - new_max_cache_size = cache_ptr->max_cache_size - - (cache_ptr->resize_ctl).max_decrement; + new_max_cache_size = + cache_ptr->max_cache_size - (cache_ptr->resize_ctl).max_decrement; } status = decrease; @@ -4630,14 +4423,15 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) case H5C_decr__age_out_with_threshold: case H5C_decr__age_out: - if(!inserted_epoch_marker) { - if(!cache_ptr->size_decrease_possible) + if (!inserted_epoch_marker) { + if (!cache_ptr->size_decrease_possible) status = decrease_disabled; else { - if(H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, write_permitted) < 0) + if (H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, + write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ageout code failed") } /* end else */ - } /* end if */ + } /* end if */ break; default: @@ -4646,68 +4440,59 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) } /* cycle the epoch markers here if appropriate */ - if ( ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - ) - && - ( ! inserted_epoch_marker ) - ) { + if ((((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + ((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold)) && + (!inserted_epoch_marker)) { /* move last epoch marker to the head of the LRU list */ - if(H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) + if (H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error cycling epoch marker") } - if ( ( status == increase ) || ( status == decrease ) ) { + if ((status == increase) || (status == decrease)) { old_max_cache_size = cache_ptr->max_cache_size; old_min_clean_size = cache_ptr->min_clean_size; - new_min_clean_size = (size_t) - ((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); + new_min_clean_size = + (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); /* new_min_clean_size is of size_t, and thus must be non-negative. * Hence we have * - * ( 0 <= new_min_clean_size ). + * ( 0 <= new_min_clean_size ). * - * by definition. + * by definition. */ - HDassert( new_min_clean_size <= new_max_cache_size ); - HDassert( (cache_ptr->resize_ctl).min_size <= new_max_cache_size ); - HDassert( new_max_cache_size <= (cache_ptr->resize_ctl).max_size ); + HDassert(new_min_clean_size <= new_max_cache_size); + HDassert((cache_ptr->resize_ctl).min_size <= new_max_cache_size); + HDassert(new_max_cache_size <= (cache_ptr->resize_ctl).max_size); cache_ptr->max_cache_size = new_max_cache_size; cache_ptr->min_clean_size = new_min_clean_size; - if ( status == increase ) { + if (status == increase) { cache_ptr->cache_full = FALSE; - - } else if ( status == decrease ) { + } + else if (status == decrease) { cache_ptr->size_decreased = TRUE; } - /* update flash cache size increase fields as appropriate */ - if ( cache_ptr->flash_size_increase_possible ) { + /* update flash cache size increase fields as appropriate */ + if (cache_ptr->flash_size_increase_possible) { - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { + switch ((cache_ptr->resize_ctl).flash_incr_mode) { case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") 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)); - break; + 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 */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") @@ -4716,43 +4501,36 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) } } - if ( (cache_ptr->resize_ctl).rpt_fcn != NULL ) { - (*((cache_ptr->resize_ctl).rpt_fcn)) - (cache_ptr, - H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, - hit_rate, - status, - old_max_cache_size, - new_max_cache_size, - old_min_clean_size, - new_min_clean_size); + if ((cache_ptr->resize_ctl).rpt_fcn != NULL) { + (*((cache_ptr->resize_ctl).rpt_fcn))(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, status, + old_max_cache_size, new_max_cache_size, old_min_clean_size, + new_min_clean_size); } - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") done: /* Sanity checks */ HDassert(cache_ptr->resize_in_progress); - if(!reentrant_call) + if (!reentrant_call) cache_ptr->resize_in_progress = FALSE; HDassert((!reentrant_call) || (cache_ptr->resize_in_progress)); FUNC_LEAVE_NOAPI(ret_value) } /* H5C__auto_adjust_cache_size() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout * * Purpose: Implement the ageout automatic cache size decrement - * algorithm. Note that while this code evicts aged out - * entries, the code does not change the maximum cache size. - * Instead, the function simply computes the new value (if - * any change is indicated) and reports this value in - * *new_max_cache_size_ptr. + * algorithm. Note that while this code evicts aged out + * entries, the code does not change the maximum cache size. + * Instead, the function simply computes the new value (if + * any change is indicated) and reports this value in + * *new_max_cache_size_ptr. * * Return: Non-negative on success/Negative on failure or if there was * an attempt to flush a protected item. @@ -4763,83 +4541,76 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) *------------------------------------------------------------------------- */ static herr_t -H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * status_ptr, - size_t * new_max_cache_size_ptr, hbool_t write_permitted) +H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted) { - H5C_t * cache_ptr = f->shared->cache; - size_t test_size; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr = f->shared->cache; + size_t test_size; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( ( status_ptr ) && ( *status_ptr == in_spec ) ); - HDassert( ( new_max_cache_size_ptr ) && ( *new_max_cache_size_ptr == 0 ) ); + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert((status_ptr) && (*status_ptr == in_spec)); + HDassert((new_max_cache_size_ptr) && (*new_max_cache_size_ptr == 0)); /* remove excess epoch markers if any */ - if(cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) - if(H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + if (cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") - if ( ( (cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out ) - || - ( ( (cache_ptr->resize_ctl).decr_mode == - H5C_decr__age_out_with_threshold - ) - && - ( hit_rate >= (cache_ptr->resize_ctl).upper_hr_threshold ) - ) - ) { + if (((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out) || + (((cache_ptr->resize_ctl).decr_mode == H5C_decr__age_out_with_threshold) && + (hit_rate >= (cache_ptr->resize_ctl).upper_hr_threshold))) { - if ( cache_ptr->max_cache_size > (cache_ptr->resize_ctl).min_size ){ + if (cache_ptr->max_cache_size > (cache_ptr->resize_ctl).min_size) { /* evict aged out cache entries if appropriate... */ - if(H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) + if (H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries") /* ... and then reduce cache size if appropriate */ - if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { + if (cache_ptr->index_size < cache_ptr->max_cache_size) { - if ( (cache_ptr->resize_ctl).apply_empty_reserve ) { + if ((cache_ptr->resize_ctl).apply_empty_reserve) { test_size = (size_t)(((double)cache_ptr->index_size) / - (1 - (cache_ptr->resize_ctl).empty_reserve)); + (1 - (cache_ptr->resize_ctl).empty_reserve)); - if ( test_size < cache_ptr->max_cache_size ) { + if (test_size < cache_ptr->max_cache_size) { - *status_ptr = decrease; + *status_ptr = decrease; *new_max_cache_size_ptr = test_size; } - } else { + } + else { - *status_ptr = decrease; + *status_ptr = decrease; *new_max_cache_size_ptr = cache_ptr->index_size; } - if ( *status_ptr == decrease ) { + if (*status_ptr == decrease) { /* clip to min size if necessary */ - if ( *new_max_cache_size_ptr < - (cache_ptr->resize_ctl).min_size ) { + if (*new_max_cache_size_ptr < (cache_ptr->resize_ctl).min_size) { - *new_max_cache_size_ptr = - (cache_ptr->resize_ctl).min_size; + *new_max_cache_size_ptr = (cache_ptr->resize_ctl).min_size; } /* clip to max decrement if necessary */ - if ( ( (cache_ptr->resize_ctl).apply_max_decrement ) && - ( ((cache_ptr->resize_ctl).max_decrement + - *new_max_cache_size_ptr) < - cache_ptr->max_cache_size ) ) { + if (((cache_ptr->resize_ctl).apply_max_decrement) && + (((cache_ptr->resize_ctl).max_decrement + *new_max_cache_size_ptr) < + cache_ptr->max_cache_size)) { - *new_max_cache_size_ptr = cache_ptr->max_cache_size - - (cache_ptr->resize_ctl).max_decrement; + *new_max_cache_size_ptr = + cache_ptr->max_cache_size - (cache_ptr->resize_ctl).max_decrement; } } } - } else { + } + else { *status_ptr = at_min_size; } @@ -4851,16 +4622,15 @@ H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * sta } /* H5C__autoadjust__ageout() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout__cycle_epoch_marker * * Purpose: Remove the oldest epoch marker from the LRU list, - * and reinsert it at the head of the LRU list. Also - * remove the epoch marker's index from the head of the - * ring buffer, and re-insert it at the tail of the ring - * buffer. + * and reinsert it at the head of the LRU list. Also + * remove the epoch marker's index from the head of the + * ring buffer, and re-insert it at the tail of the ring + * buffer. * * Return: SUCCEED on success/FAIL on failure. * @@ -4869,17 +4639,17 @@ H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * sta *------------------------------------------------------------------------- */ static herr_t -H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr) +H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; + int i; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active <= 0) + if (cache_ptr->epoch_markers_active <= 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "No active epoch markers on entry?!?!?") /* remove the last marker from both the ring buffer and the LRU list */ @@ -4887,22 +4657,17 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr) i = cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_first]; cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + (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") - if((cache_ptr->epoch_marker_active)[i] != TRUE) + if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - H5C__DLL_REMOVE((&((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)) + H5C__DLL_REMOVE((&((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)) /* now, re-insert it at the head of the LRU list, and at the tail of * the ring buffer. @@ -4913,59 +4678,53 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr) HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); (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") - 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)) + 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: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__autoadjust__ageout__cycle_epoch_marker() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout__evict_aged_out_entries * * Purpose: Evict clean entries in the cache that haven't - * been accessed for at least - * (cache_ptr->resize_ctl).epochs_before_eviction epochs, - * and flush dirty entries that haven't been accessed for - * that amount of time. + * been accessed for at least + * (cache_ptr->resize_ctl).epochs_before_eviction epochs, + * and flush dirty entries that haven't been accessed for + * that amount of time. * - * Depending on configuration, the function will either - * flush or evict all such entries, or all such entries it - * encounters until it has freed the maximum amount of space - * allowed under the maximum decrement. + * Depending on configuration, the function will either + * flush or evict all such entries, or all such entries it + * encounters until it has freed the maximum amount of space + * allowed under the maximum decrement. * - * If we are running in parallel mode, writes may not be - * permitted. If so, the function simply skips any dirty - * entries it may encounter. + * If we are running in parallel mode, writes may not be + * permitted. If so, the function simply skips any dirty + * entries it may encounter. * - * The function makes no attempt to maintain the minimum - * clean size, as there is no guarantee that the cache size - * will be changed. + * The function makes no attempt to maintain the minimum + * clean size, as there is no guarantee that the cache size + * will be changed. * - * If there is no cache size change, the minimum clean size - * constraint will be met through a combination of clean - * entries and free space in the cache. + * If there is no cache size change, the minimum clean size + * constraint will be met through a combination of clean + * entries and free space in the cache. * - * If there is a cache size reduction, the minimum clean size - * will be re-calculated, and will be enforced the next time - * we have to make space in the cache. + * If there is a cache size reduction, the minimum clean size + * will be re-calculated, and will be enforced the next time + * we have to make space in the cache. * * Observe that this function cannot occasion a read. * @@ -4978,21 +4737,21 @@ 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; - size_t eviction_size_limit; - size_t bytes_evicted = 0; - hbool_t prev_is_dirty = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * next_ptr; - H5C_cache_entry_t * prev_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = f->shared->cache; + size_t eviction_size_limit; + size_t bytes_evicted = 0; + hbool_t prev_is_dirty = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *next_ptr; + H5C_cache_entry_t *prev_ptr; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( f ); - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(f); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* if there is a limit on the amount that the cache size can be decrease * in any one round of the cache size reduction algorithm, load that @@ -5000,42 +4759,40 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte * to the equivalent of infinity. The current size of the index will * do nicely. */ - if ( (cache_ptr->resize_ctl).apply_max_decrement ) { + if ((cache_ptr->resize_ctl).apply_max_decrement) { eviction_size_limit = (cache_ptr->resize_ctl).max_decrement; - - } else { + } + else { eviction_size_limit = cache_ptr->index_size; /* i.e. infinity */ } - if ( write_permitted ) { + if (write_permitted) { restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + entry_ptr = cache_ptr->LRU_tail_ptr; - while ( ( entry_ptr != NULL ) && - ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && - ( bytes_evicted < eviction_size_limit ) ) - { + while ((entry_ptr != NULL) && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && + (bytes_evicted < eviction_size_limit)) { hbool_t skipping_entry = FALSE; HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); - next_ptr = entry_ptr->next; + next_ptr = entry_ptr->next; prev_ptr = entry_ptr->prev; - if(prev_ptr != NULL) + if (prev_ptr != NULL) prev_is_dirty = prev_ptr->is_dirty; - if(entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { HDassert(!entry_ptr->prefetched_dirty); /* dirty corked entry is skipped */ - if(entry_ptr->tag_info && entry_ptr->tag_info->corked) + if (entry_ptr->tag_info && entry_ptr->tag_info->corked) skipping_entry = TRUE; else { /* reset entries_removed_counter and @@ -5049,18 +4806,20 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - if(cache_ptr->entries_removed_counter > 1 || cache_ptr->last_entry_removed_ptr == prev_ptr) + if (cache_ptr->entries_removed_counter > 1 || + cache_ptr->last_entry_removed_ptr == prev_ptr) restart_scan = TRUE; } /* end else */ - } /* end if */ - else if(!entry_ptr->prefetched_dirty) { + } /* end if */ + else if (!entry_ptr->prefetched_dirty) { bytes_evicted += entry_ptr->size; - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0 ) + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") } /* end else-if */ else { @@ -5070,26 +4829,24 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte skipping_entry = TRUE; } /* end else */ - if(prev_ptr != NULL) { - if(skipping_entry) + if (prev_ptr != NULL) { + if (skipping_entry) entry_ptr = prev_ptr; - else if(restart_scan || (prev_ptr->is_dirty != prev_is_dirty) - || (prev_ptr->next != next_ptr) - || (prev_ptr->is_protected) - || (prev_ptr->is_pinned)) { + else if (restart_scan || (prev_ptr->is_dirty != prev_is_dirty) || + (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || (prev_ptr->is_pinned)) { /* Something has happened to the LRU -- start over - * from the tail. + * from the tail. */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + entry_ptr = cache_ptr->LRU_tail_ptr; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) } /* end else-if */ else entry_ptr = prev_ptr; - } /* end if */ + } /* end if */ else - entry_ptr = NULL; + entry_ptr = NULL; } /* end while */ /* for now at least, don't bother to maintain the minimum clean size, @@ -5108,7 +4865,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte */ } /* end if */ - else /* ! write_permitted */ { + else /* ! write_permitted */ { /* Since we are not allowed to write, all we can do is evict * any clean entries that we may encounter before we either * hit the eviction size limit, or encounter the epoch marker. @@ -5124,43 +4881,42 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte */ HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); entry_ptr = cache_ptr->LRU_tail_ptr; - while(entry_ptr != NULL && - ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && - (bytes_evicted < eviction_size_limit)) { + while (entry_ptr != NULL && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && + (bytes_evicted < eviction_size_limit)) { HDassert(!(entry_ptr->is_protected)); prev_ptr = entry_ptr->prev; - if(!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if (!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") /* just skip the entry if it is dirty, as we can't do * anything with it now since we can't write. - * - * Since all entries are clean, serialize() will not be called, - * and thus we needn't test to see if the LRU has been changed - * out from under us. + * + * Since all entries are clean, serialize() will not be called, + * and thus we needn't test to see if the LRU has been changed + * out from under us. */ entry_ptr = prev_ptr; } /* end while */ - } /* end else */ + } /* end else */ - if(cache_ptr->index_size < cache_ptr->max_cache_size) + if (cache_ptr->index_size < cache_ptr->max_cache_size) cache_ptr->cache_full = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__autoadjust__ageout__evict_aged_out_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout__insert_new_marker * * Purpose: Find an unused marker cache entry, mark it as used, and - * insert it at the head of the LRU list. Also add the - * marker's index in the epoch_markers array. + * insert it at the head of the LRU list. Also add the + * marker's index in the epoch_markers array. * * Return: SUCCEED on success/FAIL on failure. * @@ -5169,52 +4925,47 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte *------------------------------------------------------------------------- */ static herr_t -H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr) +H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; + int i; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active >= (cache_ptr->resize_ctl).epochs_before_eviction) + if (cache_ptr->epoch_markers_active >= (cache_ptr->resize_ctl).epochs_before_eviction) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Already have a full complement of markers") /* find an unused marker */ i = 0; - while((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) + while ((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) i++; - if(i >= H5C__MAX_EPOCH_MARKERS) + if (i >= H5C__MAX_EPOCH_MARKERS) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker") - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); (cache_ptr->epoch_marker_active)[i] = TRUE; cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); (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") } - 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)) + 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)) cache_ptr->epoch_markers_active += 1; @@ -5224,13 +4975,12 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr) } /* H5C__autoadjust__ageout__insert_new_marker() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout__remove_all_markers * * Purpose: Remove all epoch markers from the LRU list and mark them - * as inactive. + * as inactive. * * Return: SUCCEED on success/FAIL on failure. * @@ -5239,58 +4989,52 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr) *------------------------------------------------------------------------- */ static herr_t -H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr) +H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; - int ring_buf_index; - - FUNC_ENTER_NOAPI_NOINIT + int ring_buf_index; + int i; + herr_t ret_value = SUCCEED; /* Return value */ - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + FUNC_ENTER_STATIC - while ( cache_ptr->epoch_markers_active > 0 ) - { + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + while (cache_ptr->epoch_markers_active > 0) { /* get the index of the last epoch marker in the LRU list * and remove it from the ring buffer. */ ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + (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") - if((cache_ptr->epoch_marker_active)[i] != TRUE) + if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE((&((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, \ + H5C__DLL_REMOVE((&((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)) /* mark the epoch marker as unused. */ (cache_ptr->epoch_marker_active)[i] = FALSE; - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); /* decrement the number of active epoch markers */ cache_ptr->epoch_markers_active -= 1; - HDassert( cache_ptr->epoch_markers_active == \ - cache_ptr->epoch_marker_ringbuf_size ); + HDassert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); } done: @@ -5299,15 +5043,14 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr) } /* H5C__autoadjust__ageout__remove_all_markers() */ - /*------------------------------------------------------------------------- * * Function: H5C__autoadjust__ageout__remove_excess_markers * * Purpose: Remove epoch markers from the end of the LRU list and - * mark them as inactive until the number of active markers - * equals the the current value of - * (cache_ptr->resize_ctl).epochs_before_eviction. + * mark them as inactive until the number of active markers + * equals the the current value of + * (cache_ptr->resize_ctl).epochs_before_eviction. * * Return: SUCCEED on success/FAIL on failure. * @@ -5316,59 +5059,54 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t * cache_ptr) *------------------------------------------------------------------------- */ static herr_t -H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr) +H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int i; - int ring_buf_index; + int ring_buf_index; + int i; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(cache_ptr->epoch_markers_active <= (cache_ptr->resize_ctl).epochs_before_eviction) + if (cache_ptr->epoch_markers_active <= (cache_ptr->resize_ctl).epochs_before_eviction) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "no excess markers on entry") - while(cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) { + while (cache_ptr->epoch_markers_active > (cache_ptr->resize_ctl).epochs_before_eviction) { /* get the index of the last epoch marker in the LRU list * and remove it from the ring buffer. */ ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % - (H5C__MAX_EPOCH_MARKERS + 1); + (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") - if((cache_ptr->epoch_marker_active)[i] != TRUE) + if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE((&((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, \ + H5C__DLL_REMOVE((&((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)) /* mark the epoch marker as unused. */ (cache_ptr->epoch_marker_active)[i] = FALSE; - HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i ); - HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL ); - HDassert( ((cache_ptr->epoch_markers)[i]).prev == NULL ); + HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); + HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); /* decrement the number of active epoch markers */ cache_ptr->epoch_markers_active -= 1; - HDassert( cache_ptr->epoch_markers_active == \ - cache_ptr->epoch_marker_ringbuf_size ); + HDassert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); } done: @@ -5377,7 +5115,6 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr) } /* H5C__autoadjust__ageout__remove_excess_markers() */ - /*------------------------------------------------------------------------- * * Function: H5C__flash_increase_cache_size @@ -5395,55 +5132,48 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t * cache_ptr) *------------------------------------------------------------------------- */ static herr_t -H5C__flash_increase_cache_size(H5C_t * cache_ptr, - size_t old_entry_size, - size_t new_entry_size) +H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size) { - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - size_t space_needed; - enum H5C_resize_status status = flash_increase; /* may change */ - double hit_rate; - herr_t ret_value = SUCCEED; /* Return value */ + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + size_t space_needed; + enum H5C_resize_status status = flash_increase; /* may change */ + double hit_rate; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->flash_size_increase_possible ); - HDassert( new_entry_size > cache_ptr->flash_size_increase_threshold ); - HDassert( old_entry_size < new_entry_size ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->flash_size_increase_possible); + HDassert(new_entry_size > cache_ptr->flash_size_increase_threshold); + HDassert(old_entry_size < new_entry_size); - if(old_entry_size >= new_entry_size) + if (old_entry_size >= new_entry_size) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "old_entry_size >= new_entry_size") space_needed = new_entry_size - old_entry_size; - if ( ( (cache_ptr->index_size + space_needed) > - cache_ptr->max_cache_size ) && - ( cache_ptr->max_cache_size < (cache_ptr->resize_ctl).max_size ) ) { + if (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (cache_ptr->max_cache_size < (cache_ptr->resize_ctl).max_size)) { /* we have work to do */ - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { + switch ((cache_ptr->resize_ctl).flash_incr_mode) { case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") break; case H5C_flash_incr__add_space: - if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { + if (cache_ptr->index_size < cache_ptr->max_cache_size) { - HDassert( (cache_ptr->max_cache_size - cache_ptr->index_size) - < space_needed ); - space_needed -= cache_ptr->max_cache_size - - cache_ptr->index_size; + HDassert((cache_ptr->max_cache_size - cache_ptr->index_size) < space_needed); + space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; } - space_needed = - (size_t)(((double)space_needed) * - (cache_ptr->resize_ctl).flash_multiple); + space_needed = (size_t)(((double)space_needed) * (cache_ptr->resize_ctl).flash_multiple); new_max_cache_size = cache_ptr->max_cache_size + space_needed; @@ -5454,18 +5184,17 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, break; } - if ( new_max_cache_size > (cache_ptr->resize_ctl).max_size ) { + if (new_max_cache_size > (cache_ptr->resize_ctl).max_size) { new_max_cache_size = (cache_ptr->resize_ctl).max_size; } - HDassert( new_max_cache_size > cache_ptr->max_cache_size ); + HDassert(new_max_cache_size > cache_ptr->max_cache_size); - new_min_clean_size = (size_t) - ((double)new_max_cache_size * - ((cache_ptr->resize_ctl).min_clean_fraction)); + new_min_clean_size = + (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); - HDassert( new_min_clean_size <= new_max_cache_size ); + HDassert(new_min_clean_size <= new_max_cache_size); old_max_cache_size = cache_ptr->max_cache_size; old_min_clean_size = cache_ptr->min_clean_size; @@ -5474,19 +5203,17 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, cache_ptr->min_clean_size = new_min_clean_size; /* update flash cache size increase fields as appropriate */ - HDassert ( cache_ptr->flash_size_increase_possible ); + HDassert(cache_ptr->flash_size_increase_possible); - switch ( (cache_ptr->resize_ctl).flash_incr_mode ) - { + switch ((cache_ptr->resize_ctl).flash_incr_mode) { case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flash_size_increase_possible but H5C_flash_incr__off?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") 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 */ @@ -5495,30 +5222,24 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, } /* note that we don't cycle the epoch markers. We can - * argue either way as to whether we should, but for now - * we don't. - */ + * argue either way as to whether we should, but for now + * we don't. + */ - if ( (cache_ptr->resize_ctl).rpt_fcn != NULL ) { + if ((cache_ptr->resize_ctl).rpt_fcn != NULL) { /* get the hit rate for the reporting function. Should still * be good as we haven't reset the hit rate statistics. */ - if(H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - (*((cache_ptr->resize_ctl).rpt_fcn)) - (cache_ptr, - H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, - hit_rate, - status, - old_max_cache_size, - new_max_cache_size, - old_min_clean_size, - new_min_clean_size); + (*((cache_ptr->resize_ctl).rpt_fcn))(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, + status, old_max_cache_size, new_max_cache_size, + old_min_clean_size, new_min_clean_size); } - if(H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) /* this should be impossible... */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") } @@ -5529,37 +5250,36 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, } /* H5C__flash_increase_cache_size() */ - /*------------------------------------------------------------------------- * * Function: H5C__flush_invalidate_cache * - * Purpose: Flush and destroy the entries contained in the target - * cache. + * Purpose: Flush and destroy the entries contained in the target + * cache. * - * If the cache contains protected entries, the function will - * fail, as protected entries cannot be either flushed or - * destroyed. However all unprotected entries should be - * flushed and destroyed before the function returns failure. + * If the cache contains protected entries, the function will + * fail, as protected entries cannot be either flushed or + * destroyed. However all unprotected entries should be + * flushed and destroyed before the function returns failure. * - * While pinned entries can usually be flushed, they cannot - * be destroyed. However, they should be unpinned when all - * the entries that reference them have been destroyed (thus - * reduding the pinned entry's reference count to 0, allowing - * it to be unpinned). + * While pinned entries can usually be flushed, they cannot + * be destroyed. However, they should be unpinned when all + * the entries that reference them have been destroyed (thus + * reduding the pinned entry's reference count to 0, allowing + * it to be unpinned). * - * If pinned entries are present, the function makes repeated - * passes through the cache, flushing all dirty entries - * (including the pinned dirty entries where permitted) and - * destroying all unpinned entries. This process is repeated - * until either the cache is empty, or the number of pinned - * entries stops decreasing on each pass. + * If pinned entries are present, the function makes repeated + * passes through the cache, flushing all dirty entries + * (including the pinned dirty entries where permitted) and + * destroying all unpinned entries. This process is repeated + * until either the cache is empty, or the number of pinned + * entries stops decreasing on each pass. * * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * a request to flush all items and something was protected. * * Programmer: John Mainzer - * 3/24/065 + * 3/24/065 * * Modifications: * @@ -5580,7 +5300,7 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, * Note that this is a pretty bad scenario if it ever * happens. The code I have added should allow us to * handle the situation under all but the worst conditions, - * but one can argue that we should just scream and die if + * but one can argue that we should just scream and die if * we ever detect the condition. * * -- JRM 10/13/07 @@ -5589,15 +5309,15 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, * * * Added support for the H5C__EVICT_ALLOW_LAST_PINS_FLAG. - * This flag is used to flush and evict all entries in + * This flag is used to flush and evict all entries in * the metadata cache that are not pinned -- typically, * everything other than the superblock. * * ??? -- ??/??/?? * - * Added sanity checks to verify that the skip list is - * enabled on entry. On the face of it, it would make - * sense to enable the slist on entry, and disable it + * Added sanity checks to verify that the skip list is + * enabled on entry. On the face of it, it would make + * sense to enable the slist on entry, and disable it * on exit, as this function is not called repeatedly. * However, since this function can be called from * H5C_flush_cache(), this would create cases in the test @@ -5611,9 +5331,9 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, static herr_t H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) { - H5C_t * cache_ptr; - H5C_ring_t ring; - herr_t ret_value = SUCCEED; + H5C_t * cache_ptr; + H5C_ring_t ring; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -5626,50 +5346,49 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) HDassert(cache_ptr->slist_enabled); #if H5C_DO_SANITY_CHECKS -{ - int32_t i; - uint32_t index_len = 0; - uint32_t slist_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - - HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); - HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - - for ( i = H5C_RING_USER; i < H5C_RING_NTYPES; i++ ) { - - index_len += cache_ptr->index_ring_len[i]; - index_size += cache_ptr->index_ring_size[i]; - clean_index_size += cache_ptr->clean_index_ring_size[i]; - dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - - slist_len += cache_ptr->slist_ring_len[i]; - slist_size += cache_ptr->slist_ring_size[i]; + { + int32_t i; + uint32_t index_len = 0; + uint32_t slist_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + + HDassert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ + } /* end for */ - HDassert(cache_ptr->index_len == index_len); - HDassert(cache_ptr->index_size == index_size); - HDassert(cache_ptr->clean_index_size == clean_index_size); - HDassert(cache_ptr->dirty_index_size == dirty_index_size); - HDassert(cache_ptr->slist_len == slist_len); - HDassert(cache_ptr->slist_size == slist_size); -} + HDassert(cache_ptr->index_len == index_len); + HDassert(cache_ptr->index_size == index_size); + HDassert(cache_ptr->clean_index_size == clean_index_size); + HDassert(cache_ptr->dirty_index_size == dirty_index_size); + HDassert(cache_ptr->slist_len == slist_len); + HDassert(cache_ptr->slist_size == slist_size); + } #endif /* H5C_DO_SANITY_CHECKS */ /* remove ageout markers if present */ - if ( cache_ptr->epoch_markers_active > 0 ) { + if (cache_ptr->epoch_markers_active > 0) { - if ( H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0 ) + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "error removing all epoch markers") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") } /* flush invalidate each ring, starting from the outermost ring and @@ -5677,18 +5396,17 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) */ ring = H5C_RING_USER; - while ( ring < H5C_RING_NTYPES) { + while (ring < H5C_RING_NTYPES) { - if(H5C_flush_invalidate_ring(f, ring, flags) < 0) + if (H5C__flush_invalidate_ring(f, ring, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, - "flush invalidate ring failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate ring failed") ring++; } /* end while */ /* Invariants, after destroying all entries in the hash table */ - if( ! ( flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG ) ) { + if (!(flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG)) { HDassert(cache_ptr->index_size == 0); HDassert(cache_ptr->clean_index_size == 0); @@ -5698,12 +5416,12 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) } /* end if */ else { - H5C_cache_entry_t *entry_ptr; /* Cache entry */ - unsigned u; /* Local index variable */ + H5C_cache_entry_t *entry_ptr; /* Cache entry */ + unsigned u; /* Local index variable */ /* All rings except ring 4 should be empty now */ /* (Ring 4 has the superblock) */ - for ( u = H5C_RING_USER; u < H5C_RING_SB; u++ ) { + for (u = H5C_RING_USER; u < H5C_RING_SB; u++) { HDassert(cache_ptr->index_ring_len[u] == 0); HDassert(cache_ptr->index_ring_size[u] == 0); @@ -5715,7 +5433,7 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) entry_ptr = cache_ptr->pel_head_ptr; - while(entry_ptr) { + while (entry_ptr) { /* Check ring */ HDassert(entry_ptr->ring == H5C_RING_SB); @@ -5724,7 +5442,7 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) entry_ptr = entry_ptr->next; } /* end while */ - } /* end else */ + } /* end else */ HDassert(cache_ptr->dirty_index_size == 0); HDassert(cache_ptr->slist_len == 0); @@ -5740,9 +5458,8 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) } /* H5C__flush_invalidate_cache() */ - /*------------------------------------------------------------------------- - * Function: H5C_flush_invalidate_ring + * Function: H5C__flush_invalidate_ring * * Purpose: Flush and destroy the entries contained in the target * cache and ring. @@ -5776,7 +5493,7 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) * 9/1/15 * * Changes: Added support for the H5C__EVICT_ALLOW_LAST_PINS_FLAG. - * This flag is used to flush and evict all entries in + * This flag is used to flush and evict all entries in * the metadata cache that are not pinned -- typically, * everything other than the superblock. * @@ -5784,7 +5501,7 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) * * A recent optimization turns off the slist unless a flush * is in progress. This should not effect this function, as - * it is only called during a flush. Added an assertion to + * it is only called during a flush. Added an assertion to * verify this. * * JRM -- 5/6/20 @@ -5792,26 +5509,26 @@ 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__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) { - 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; - unsigned cooked_flags; - unsigned evict_flags; - H5SL_node_t *node_ptr = NULL; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *next_entry_ptr = NULL; + 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; + unsigned cooked_flags; + unsigned evict_flags; + 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 - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC HDassert(f); HDassert(f->shared); @@ -5830,7 +5547,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) /* Filter out the flags that are not relevant to the flush/invalidate. */ cooked_flags = flags & H5C__FLUSH_CLEAR_ONLY_FLAG; - evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; + evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; /* The flush procedure here is a bit strange. * @@ -5863,14 +5580,14 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) /* compute the number of pinned entries in this ring */ - entry_ptr = cache_ptr->pel_head_ptr; + entry_ptr = cache_ptr->pel_head_ptr; cur_ring_pel_len = 0; - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->ring >= ring); - if(entry_ptr->ring == ring) + if (entry_ptr->ring == ring) cur_ring_pel_len++; entry_ptr = entry_ptr->next; @@ -5879,7 +5596,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) old_ring_pel_len = cur_ring_pel_len; - while(cache_ptr->index_ring_len[ring] > 0) { + while (cache_ptr->index_ring_len[ring] > 0) { /* first, try to flush-destroy any dirty entries. Do this by * making a scan through the slist. Note that new dirty entries @@ -5893,7 +5610,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * Thus for sanity checks we must make note of the initial * slist length and size before we do any flushes. */ - initial_slist_len = cache_ptr->slist_len; + initial_slist_len = cache_ptr->slist_len; initial_slist_size = cache_ptr->slist_size; /* There is also the possibility that entries will be @@ -5906,7 +5623,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * To this end, we must zero these fields before we start * the pass through the slist. */ - cache_ptr->slist_len_increase = 0; + cache_ptr->slist_len_increase = 0; cache_ptr->slist_size_increase = 0; #endif /* H5C_DO_SANITY_CHECKS */ @@ -5915,7 +5632,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * This flag is set to TRUE by H5C__flush_single_entry if the slist * is modified by a pre_serialize, serialize, or notify callback. * - * H5C_flush_invalidate_ring() uses this flag to detect any + * H5C__flush_invalidate_ring() uses this flag to detect any * modifications to the slist that might corrupt the scan of * the slist -- and restart the scan in this event. */ @@ -5924,26 +5641,25 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) /* this done, start the scan of the slist */ restart_slist_scan = TRUE; - while ( restart_slist_scan || ( node_ptr != NULL ) ) { + while (restart_slist_scan || (node_ptr != NULL)) { - if ( restart_slist_scan ) { + if (restart_slist_scan) { restart_slist_scan = FALSE; /* Start at beginning of skip list */ node_ptr = H5SL_first(cache_ptr->slist_ptr); - if ( node_ptr == NULL ) + if (node_ptr == NULL) /* the slist is empty -- break out of inner loop */ break; /* Get cache entry for this node */ next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "next_entry_ptr == NULL ?!?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); @@ -5976,14 +5692,13 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) */ node_ptr = H5SL_next(node_ptr); - if(node_ptr != NULL) { + if (node_ptr != NULL) { next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if(NULL == next_entry_ptr) + if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "next_entry_ptr == NULL ?!?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); @@ -6006,14 +5721,11 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * flush, we must keep the slist in canonical form at all * times. */ - if ( ( ( !entry_ptr->flush_me_last ) || - ( ( entry_ptr->flush_me_last ) && - ( cache_ptr->num_last_entries >= cache_ptr->slist_len ) ) - ) && - ( entry_ptr->flush_dep_nchildren == 0 ) && - ( entry_ptr->ring == ring ) ) { + if (((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && + (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { - if ( entry_ptr->is_protected ) { + if (entry_ptr->is_protected) { /* we have major problems -- but lets flush * everything we can before we flag an error. @@ -6021,15 +5733,13 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) protected_entries++; } /* end if */ - else if ( entry_ptr->is_pinned ) { + else if (entry_ptr->is_pinned) { - if ( H5C__flush_single_entry(f, entry_ptr, - H5C__DURING_FLUSH_FLAG) < 0 ) + if (H5C__flush_single_entry(f, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "dirty pinned entry flush failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed") - if ( cache_ptr->slist_changed ) { + if (cache_ptr->slist_changed) { /* The slist has been modified by something * other than the simple removal of the @@ -6038,24 +5748,22 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * This has the potential to corrupt the * scan through the slist, so restart it. */ - restart_slist_scan = TRUE; + restart_slist_scan = TRUE; cache_ptr->slist_changed = FALSE; H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); } /* end if */ - } /* end else-if */ + } /* end else-if */ else { - if ( H5C__flush_single_entry(f, entry_ptr, - (cooked_flags | - H5C__DURING_FLUSH_FLAG | - H5C__FLUSH_INVALIDATE_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) ) < 0) + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, - "dirty entry flush destroy failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed") - if ( cache_ptr->slist_changed ) { + if (cache_ptr->slist_changed) { /* The slist has been modified by something * other than the simple removal of the @@ -6064,13 +5772,13 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * This has the potential to corrupt the * scan through the slist, so restart it. */ - restart_slist_scan = TRUE; + restart_slist_scan = TRUE; cache_ptr->slist_changed = FALSE; H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) } /* end if */ - } /* end else */ - } /* end if */ - } /* end while loop scanning skip list */ + } /* end else */ + } /* end if */ + } /* end while loop scanning skip list */ #if H5C_DO_SANITY_CHECKS /* It is possible that entries were added to the slist during @@ -6082,17 +5790,15 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * out from under us. */ - if ( node_ptr == NULL ) { + if (node_ptr == NULL) { - HDassert(cache_ptr->slist_len == - (uint32_t)((int32_t)initial_slist_len + - cache_ptr->slist_len_increase)); + HDassert(cache_ptr->slist_len == + (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); - HDassert(cache_ptr->slist_size == - (size_t)((ssize_t)initial_slist_size + - cache_ptr->slist_size_increase)); + HDassert(cache_ptr->slist_size == + (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); } /* end if */ -#endif /* H5C_DO_SANITY_CHECKS */ +#endif /* H5C_DO_SANITY_CHECKS */ /* Since we are doing a destroy, we must make a pass through * the hash table and try to flush - destroy all entries that @@ -6109,30 +5815,26 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) /* reset the counters so that we can detect insertions, loads, * and moves caused by the pre_serialize and serialize calls. */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; next_entry_ptr = cache_ptr->il_head; - while ( next_entry_ptr != NULL ) { + while (next_entry_ptr != NULL) { entry_ptr = next_entry_ptr; HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->ring >= ring); next_entry_ptr = entry_ptr->il_next; - HDassert((next_entry_ptr == NULL) || - (next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC)); + HDassert((next_entry_ptr == NULL) || (next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC)); - if ( ( ( ! entry_ptr->flush_me_last ) || - ( entry_ptr->flush_me_last && - ( cache_ptr->num_last_entries >= cache_ptr->slist_len ) ) - ) && - ( entry_ptr->flush_dep_nchildren == 0 ) && - ( entry_ptr->ring == ring ) ) { + if (((!entry_ptr->flush_me_last) || + (entry_ptr->flush_me_last && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && + (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { - if ( entry_ptr->is_protected ) { + if (entry_ptr->is_protected) { /* we have major problems -- but lets flush and * destroy everything we can before we flag an @@ -6140,12 +5842,12 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) */ protected_entries++; - if ( ! entry_ptr->in_slist ) { + if (!entry_ptr->in_slist) { HDassert(!(entry_ptr->is_dirty)); } } /* end if */ - else if ( ! ( entry_ptr->is_pinned ) ) { + else if (!(entry_ptr->is_pinned)) { /* if *entry_ptr is dirty, it is possible * that one or more other entries may be @@ -6175,14 +5877,12 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) */ cache_ptr->entry_watched_for_removal = next_entry_ptr; - if ( H5C__flush_single_entry(f, entry_ptr, - (cooked_flags | - H5C__DURING_FLUSH_FLAG | - H5C__FLUSH_INVALIDATE_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0 ) + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Entry flush destroy failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed") /* Restart the index list scan if necessary. Must * do this if the next entry is evicted, and also if @@ -6192,29 +5892,27 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * if this results in the size of the pinned entry * failing to decline during the pass. */ - if ( ( ( NULL != next_entry_ptr ) && - ( NULL == cache_ptr->entry_watched_for_removal ) - ) || - ( cache_ptr->entries_loaded_counter > 0 ) || - ( cache_ptr->entries_inserted_counter > 0 ) || - ( cache_ptr->entries_relocated_counter > 0 ) ) { + if (((NULL != next_entry_ptr) && (NULL == cache_ptr->entry_watched_for_removal)) || + (cache_ptr->entries_loaded_counter > 0) || + (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) { next_entry_ptr = cache_ptr->il_head; - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) } /* end if */ else { - cache_ptr->entry_watched_for_removal = NULL; + cache_ptr->entry_watched_for_removal = NULL; } } /* end if */ - } /* end if */ - } /* end for loop scanning hash table */ + } /* end if */ + } /* end for loop scanning hash table */ /* We can't do anything if entries are pinned. The * hope is that the entries will be unpinned as the @@ -6225,15 +5923,15 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * shrinking before it hits zero, we scream and die. */ old_ring_pel_len = cur_ring_pel_len; - entry_ptr = cache_ptr->pel_head_ptr; + entry_ptr = cache_ptr->pel_head_ptr; cur_ring_pel_len = 0; - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->ring >= ring); - if ( entry_ptr->ring == ring ) { + if (entry_ptr->ring == ring) { cur_ring_pel_len++; } @@ -6242,37 +5940,35 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) } /* end while */ - /* Check if the number of pinned entries in the ring is positive, and - * it is not declining. Scream and die if so. - */ - if ( ( cur_ring_pel_len > 0 ) && - ( cur_ring_pel_len >= old_ring_pel_len ) ) { + /* Check if the number of pinned entries in the ring is positive, and + * it is not declining. Scream and die if so. + */ + if ((cur_ring_pel_len > 0) && (cur_ring_pel_len >= old_ring_pel_len)) { /* Don't error if allowed to have pinned entries remaining */ - if ( evict_flags ) { + if (evict_flags) { HGOTO_DONE(TRUE) } - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = %d, ring = %d", \ - (int)cur_ring_pel_len, \ - (int)old_ring_pel_len, (int)ring) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = " + "%d, ring = %d", + (int)cur_ring_pel_len, (int)old_ring_pel_len, (int)ring) } /* end if */ HDassert(protected_entries == cache_ptr->pl_len); - if ( ( protected_entries > 0 ) && - ( protected_entries == cache_ptr->index_len ) ) + if ((protected_entries > 0) && (protected_entries == cache_ptr->index_len)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Only protected entries left in cache, protected_entries = %d",\ - (int)protected_entries) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Only protected entries left in cache, protected_entries = %d", + (int)protected_entries) } /* main while loop */ /* Invariants, after destroying all entries in the ring */ - for ( i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++ ) { + for (i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++) { HDassert(cache_ptr->index_ring_len[i] == 0); HDassert(cache_ptr->index_ring_size[i] == (size_t)0); @@ -6286,24 +5982,21 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) HDassert(protected_entries <= cache_ptr->pl_len); - if ( protected_entries > 0 ) { + if (protected_entries > 0) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Cache has protected entries") - - } else if ( cur_ring_pel_len > 0 ) { + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") + } + else if (cur_ring_pel_len > 0) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't unpin all pinned entries in ring") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't unpin all pinned entries in ring") } done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_flush_invalidate_ring() */ +} /* H5C__flush_invalidate_ring() */ - /*------------------------------------------------------------------------- * * Function: H5C__flush_ring @@ -6329,7 +6022,7 @@ H5C_flush_invalidate_ring(H5F_t * f, H5C_ring_t ring, unsigned flags) * * Changes: A recent optimization turns off the slist unless a flush * is in progress. This should not effect this function, as - * it is only called during a flush. Added an assertion to + * it is only called during a flush. Added an assertion to * verify this. * * JRM -- 5/6/20 @@ -6340,22 +6033,22 @@ 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; - 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; - H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * next_entry_ptr = NULL; + 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; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ - int i; - herr_t ret_value = SUCCEED; + int i; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -6368,20 +6061,18 @@ 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") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - ignore_protected = ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 ); - flush_marked_entries = ( (flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0 ); + ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); + flush_marked_entries = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); - if ( ! flush_marked_entries ) { + if (!flush_marked_entries) { - for ( i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++ ) { + for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) { HDassert(cache_ptr->slist_ring_len[i] == 0); } @@ -6406,9 +6097,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) */ cache_ptr->slist_changed = FALSE; - while ( ( cache_ptr->slist_ring_len[ring] > 0 ) && - ( protected_entries == 0 ) && - ( flushed_entries_last_pass ) ) { + while ((cache_ptr->slist_ring_len[ring] > 0) && (protected_entries == 0) && (flushed_entries_last_pass)) { flushed_entries_last_pass = FALSE; @@ -6429,7 +6118,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * To deal with this, we first make note of the initial * skip list length and size: */ - initial_slist_len = cache_ptr->slist_len; + initial_slist_len = cache_ptr->slist_len; initial_slist_size = cache_ptr->slist_size; /* As mentioned above, there is the possibility that @@ -6442,7 +6131,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * updated elsewhere to account for slist insertions and/or * dirty entry size changes. */ - cache_ptr->slist_len_increase = 0; + cache_ptr->slist_len_increase = 0; cache_ptr->slist_size_increase = 0; /* at the end of the loop, use these values to compute the @@ -6453,16 +6142,16 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) restart_slist_scan = TRUE; - while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) { + while ((restart_slist_scan) || (node_ptr != NULL)) { - if ( restart_slist_scan ) { + if (restart_slist_scan) { restart_slist_scan = FALSE; /* Start at beginning of skip list */ node_ptr = H5SL_first(cache_ptr->slist_ptr); - if ( node_ptr == NULL ) { + if (node_ptr == NULL) { /* the slist is empty -- break out of inner loop */ break; @@ -6471,10 +6160,9 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) /* Get cache entry for this node */ next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "next_entry_ptr == NULL ?!?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); @@ -6505,7 +6193,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(entry_ptr->in_slist); HDassert(entry_ptr->is_dirty); - if ( ( ! flush_marked_entries ) || ( entry_ptr->flush_marker ) ) { + if ((!flush_marked_entries) || (entry_ptr->flush_marker)) { HDassert(entry_ptr->ring >= ring); } @@ -6515,20 +6203,19 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) */ node_ptr = H5SL_next(node_ptr); - if ( node_ptr != NULL ) { + if (node_ptr != NULL) { next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "next_entry_ptr == NULL ?!?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); HDassert(next_entry_ptr->in_slist); - if ( ! flush_marked_entries || next_entry_ptr->flush_marker ) { + if (!flush_marked_entries || next_entry_ptr->flush_marker) { HDassert(next_entry_ptr->ring >= ring); } @@ -6541,20 +6228,16 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) next_entry_ptr = NULL; } - if ( ( ! flush_marked_entries || entry_ptr->flush_marker ) && - ( ( ! entry_ptr->flush_me_last ) || - ( ( entry_ptr->flush_me_last ) && - ( ( cache_ptr->num_last_entries >= cache_ptr->slist_len )|| - ( flush_marked_entries && entry_ptr->flush_marker ) ) - ) - ) && - ( ( entry_ptr->flush_dep_nchildren == 0 ) || - ( entry_ptr->flush_dep_ndirty_children == 0 ) ) && - ( entry_ptr->ring == ring ) ) { + if ((!flush_marked_entries || entry_ptr->flush_marker) && + ((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && ((cache_ptr->num_last_entries >= cache_ptr->slist_len) || + (flush_marked_entries && entry_ptr->flush_marker)))) && + ((entry_ptr->flush_dep_nchildren == 0) || (entry_ptr->flush_dep_ndirty_children == 0)) && + (entry_ptr->ring == ring)) { HDassert(entry_ptr->flush_dep_nunser_children == 0); - if ( entry_ptr->is_protected ) { + if (entry_ptr->is_protected) { /* we probably have major problems -- but lets * flush everything we can before we decide @@ -6566,13 +6249,11 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) } /* end if */ else { - if ( H5C__flush_single_entry(f, entry_ptr, - (flags | H5C__DURING_FLUSH_FLAG)) < 0 ) + if (H5C__flush_single_entry(f, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't flush entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry") - if ( cache_ptr->slist_changed ) { + if (cache_ptr->slist_changed) { /* The slist has been modified by something * other than the simple removal of the @@ -6581,7 +6262,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * This has the potential to corrupt the * scan through the slist, so restart it. */ - restart_slist_scan = TRUE; + restart_slist_scan = TRUE; cache_ptr->slist_changed = FALSE; H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) @@ -6590,34 +6271,32 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) flushed_entries_last_pass = TRUE; } /* end else */ - } /* end if */ - } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ + } /* end if */ + } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ #if H5C_DO_SANITY_CHECKS /* Verify that the slist size and length are as expected. */ - HDassert((uint32_t)((int32_t)initial_slist_len + \ - cache_ptr->slist_len_increase) == cache_ptr->slist_len); - HDassert((size_t)((ssize_t)initial_slist_size + \ - cache_ptr->slist_size_increase) == cache_ptr->slist_size); + HDassert((uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase) == + cache_ptr->slist_len); + HDassert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == + cache_ptr->slist_size); #endif /* H5C_DO_SANITY_CHECKS */ } /* while */ HDassert(protected_entries <= cache_ptr->pl_len); - if ( ( ( cache_ptr->pl_len > 0 ) && ( ! ignore_protected ) ) || - ( tried_to_flush_protected_entry ) ) + if (((cache_ptr->pl_len > 0) && (!ignore_protected)) || (tried_to_flush_protected_entry)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "cache has protected items") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items") #if H5C_DO_SANITY_CHECKS - if ( ! flush_marked_entries ) { + if (!flush_marked_entries) { HDassert(cache_ptr->slist_ring_len[ring] == 0); HDassert(cache_ptr->slist_ring_size[ring] == 0); - } /* end if */ + } /* end if */ #endif /* H5C_DO_SANITY_CHECKS */ done: @@ -6626,7 +6305,6 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) } /* H5C__flush_ring() */ - /*------------------------------------------------------------------------- * * Function: H5C__flush_single_entry @@ -6709,10 +6387,10 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * * * JRM -- 5/8/20 - * Updated sanity checks for the possibility that the slist + * Updated sanity checks for the possibility that the slist * is disabled. * - * Also updated main comment to conform more closely with + * Also updated main comment to conform more closely with * the current state of the code. * *------------------------------------------------------------------------- @@ -6720,22 +6398,22 @@ 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 */ - hbool_t destroy; /* external flag */ - hbool_t clear_only; /* external flag */ - hbool_t free_file_space; /* external flag */ - hbool_t take_ownership; /* external flag */ - hbool_t del_from_slist_on_destroy; /* external flag */ - hbool_t during_flush; /* external flag */ - hbool_t write_entry; /* internal flag */ - hbool_t destroy_entry; /* internal flag */ - hbool_t generate_image; /* internal flag */ - hbool_t update_page_buffer; /* internal flag */ - hbool_t was_dirty; - hbool_t suppress_image_entry_writes = FALSE; - hbool_t suppress_image_entry_frees = FALSE; - haddr_t entry_addr = HADDR_UNDEF; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t take_ownership; /* external flag */ + hbool_t del_from_slist_on_destroy; /* external flag */ + hbool_t during_flush; /* external flag */ + hbool_t write_entry; /* internal flag */ + hbool_t destroy_entry; /* internal flag */ + hbool_t generate_image; /* internal flag */ + hbool_t update_page_buffer; /* internal flag */ + hbool_t was_dirty; + hbool_t suppress_image_entry_writes = FALSE; + hbool_t suppress_image_entry_frees = FALSE; + haddr_t entry_addr = HADDR_UNDEF; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6753,8 +6431,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - del_from_slist_on_destroy = - ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); + del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); @@ -6762,11 +6439,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* Set the flag for destroying the entry, based on the 'take ownership' * and 'destroy' flags */ - if ( take_ownership ) { + if (take_ownership) { destroy_entry = FALSE; - - } else { + } + else { destroy_entry = destroy; } @@ -6774,11 +6451,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* we will write the entry to disk if it exists, is dirty, and if the * clear only flag is not set. */ - if ( entry_ptr->is_dirty && !clear_only ) { + if (entry_ptr->is_dirty && !clear_only) { write_entry = TRUE; - - } else { + } + else { write_entry = FALSE; } @@ -6790,10 +6467,8 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * Set suppress_image_entry_writes to TRUE if indicated by the * image_ctl flags. */ - if ( ( cache_ptr->close_warning_received ) && - ( cache_ptr->image_ctl.generate_image ) && - ( cache_ptr->num_entries_in_image > 0 ) && - ( cache_ptr->image_entries != NULL ) ) { + if ((cache_ptr->close_warning_received) && (cache_ptr->image_ctl.generate_image) && + (cache_ptr->num_entries_in_image > 0) && (cache_ptr->image_entries != NULL)) { /* Sanity checks */ HDassert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); @@ -6804,59 +6479,55 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) suppress_image_entry_frees = TRUE; - if ( cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES ) { + if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) { suppress_image_entry_writes = TRUE; } /* end if */ - } /* end if */ + } /* end if */ - /* run initial sanity checks */ -#if H5C_DO_SANITY_CHECKS - if ( cache_ptr->slist_enabled ) { + /* run initial sanity checks */ +#if H5C_DO_SANITY_CHECKS + if (cache_ptr->slist_enabled) { - if ( entry_ptr->in_slist ) { + if (entry_ptr->in_slist) { HDassert(entry_ptr->is_dirty); - if ( ( entry_ptr->flush_marker ) && ( ! entry_ptr->is_dirty ) ) + if ((entry_ptr->flush_marker) && (!entry_ptr->is_dirty)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "entry in slist failed sanity checks") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks") } /* end if */ else { HDassert(!entry_ptr->is_dirty); HDassert(!entry_ptr->flush_marker); - if ( ( entry_ptr->is_dirty ) || ( entry_ptr->flush_marker ) ) + if ((entry_ptr->is_dirty) || (entry_ptr->flush_marker)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "entry failed sanity checks") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks") } /* end else */ - } else { /* slist is disabled */ - - HDassert( ! entry_ptr->in_slist ); + } + else { /* slist is disabled */ - if ( ! entry_ptr->is_dirty ) { + HDassert(!entry_ptr->in_slist); - if ( entry_ptr->flush_marker ) + if (!entry_ptr->is_dirty) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "flush marked clean entry?") + if (entry_ptr->flush_marker) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush marked clean entry?") } } #endif /* H5C_DO_SANITY_CHECKS */ - if ( entry_ptr->is_protected ) { + if (entry_ptr->is_protected) { HDassert(!entry_ptr->is_protected); /* Attempt to flush a protected entry -- scream and die. */ - HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, \ - "Attempt to flush a protected entry") + HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry") } /* end if */ @@ -6867,7 +6538,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * entry still exists at that point. */ entry_ptr->flush_in_progress = TRUE; - entry_ptr->flush_marker = FALSE; + entry_ptr->flush_marker = FALSE; /* Preserve current dirty state for later */ was_dirty = entry_ptr->is_dirty; @@ -6876,38 +6547,36 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * been requested to generate an image. In those cases, serialize the * entry. */ - if ( write_entry || generate_image ) { + if (write_entry || generate_image) { HDassert(entry_ptr->is_dirty); - if ( NULL == entry_ptr->image_ptr ) { + if (NULL == entry_ptr->image_ptr) { - if ( NULL == (entry_ptr->image_ptr = - H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \ - "memory allocation failed for on disk image buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + 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 */ } /* end if */ - if ( ! ( entry_ptr->image_up_to_date ) ) { + if (!(entry_ptr->image_up_to_date)) { /* Sanity check */ HDassert(!entry_ptr->prefetched); /* Generate the entry's image */ - if ( H5C__generate_image(f, cache_ptr, entry_ptr) < 0 ) + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, \ - "can't generate entry's image") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image") } /* end if ( ! (entry_ptr->image_up_to_date) ) */ - } /* end if */ + } /* end if */ /* Finally, write the image to disk. * @@ -6915,16 +6584,14 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * in the entry's type, we silently skip the write. This * flag should only be used in test code. */ - if ( write_entry ) { + if (write_entry) { HDassert(entry_ptr->is_dirty); #if H5C_DO_SANITY_CHECKS - if ( ( cache_ptr->check_write_permitted ) && - ( ! ( cache_ptr->write_permitted ) ) ) + if ((cache_ptr->check_write_permitted) && (!(cache_ptr->write_permitted))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Write when writes are always forbidden!?!?!") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Write when writes are always forbidden!?!?!") #endif /* H5C_DO_SANITY_CHECKS */ /* Write the image to disk unless the write is suppressed. @@ -6934,44 +6601,34 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * H5AC__CLASS_SKIP_WRITES is set in the entry's type. This * flag should only be used in test code */ - if ( ( ( ! suppress_image_entry_writes ) || - ( ! entry_ptr->include_in_image ) ) && - ( ( (entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0 ) ) { + if (((!suppress_image_entry_writes) || (!entry_ptr->include_in_image)) && + (((entry_ptr->type->flags) & H5C__CLASS_SKIP_WRITES) == 0)) { H5FD_mem_t mem_type = H5FD_MEM_DEFAULT; #ifdef H5_HAVE_PARALLEL - if ( cache_ptr->coll_write_list ) { + if (cache_ptr->coll_write_list) { - if ( H5SL_insert(cache_ptr->coll_write_list, entry_ptr, - &entry_ptr->addr) < 0 ) + if (H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, \ - "unable to insert skip list item") + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") } /* end if */ - else - { + else { #endif /* H5_HAVE_PARALLEL */ - if ( entry_ptr->prefetched ) { + if (entry_ptr->prefetched) { HDassert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - mem_type = cache_ptr-> - class_table_ptr[entry_ptr->prefetch_type_id]-> - mem_type; + mem_type = cache_ptr->class_table_ptr[entry_ptr->prefetch_type_id]->mem_type; } /* end if */ else { mem_type = entry_ptr->type->mem_type; } - if ( H5F_block_write(f, mem_type, entry_ptr->addr, - entry_ptr->size, entry_ptr->image_ptr) < 0 ) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't write image to file") - + if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write image to file") #ifdef H5_HAVE_PARALLEL } #endif /* H5_HAVE_PARALLEL */ @@ -6981,12 +6638,10 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* if the entry has a notify callback, notify it that we have * just flushed the entry. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client of entry flush") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client of entry flush") } /* if ( write_entry ) */ @@ -6999,15 +6654,16 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ /* start by updating the statistics */ - if ( clear_only ) { + if (clear_only) { /* only log a clear if the entry was dirty */ - if ( was_dirty ) { + if (was_dirty) { H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) } /* end if */ - } else if(write_entry) { + } + else if (write_entry) { HDassert(was_dirty); @@ -7022,14 +6678,14 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ /* Update the cache internal data structures. */ - if ( destroy ) { + if (destroy) { /* Sanity checks */ - if ( take_ownership ) { + if (take_ownership) { HDassert(!destroy_entry); - - } else { + } + else { HDassert(destroy_entry); } @@ -7043,12 +6699,10 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * to be removed from the cache, send a 'before eviction' notice while * the entry is still fully integrated in the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry to evict") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") /* Update the cache internal data structures as appropriate * for a destroy. Specifically: @@ -7068,29 +6722,28 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - if ( ( entry_ptr->in_slist ) && ( del_from_slist_on_destroy ) ) { + if ((entry_ptr->in_slist) && (del_from_slist_on_destroy)) { H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) } #ifdef H5_HAVE_PARALLEL /* Check for collective read access flag */ - if ( entry_ptr->coll_access ) { + if (entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) /* Remove entry from tag list */ - if ( H5C__untag_entry(cache_ptr, entry_ptr) < 0 ) + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, \ - "can't remove entry from tag list") + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") /* verify that the entry is no longer part of any flush dependencies */ HDassert(entry_ptr->flush_dep_nparents == 0); @@ -7125,42 +6778,40 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr); /* Check for entry changing status and do notifications, etc. */ - if ( was_dirty ) { + if (was_dirty) { - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully * integrated into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, - entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry dirty flag cleared") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") - /* Propagate the clean flag up the flush dependency chain - * if appropriate + /* Propagate the clean flag up the flush dependency chain + * if appropriate */ - if ( entry_ptr->flush_dep_ndirty_children != 0 ) { + if (entry_ptr->flush_dep_ndirty_children != 0) { HDassert(entry_ptr->flush_dep_ndirty_children == 0); } - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_clean(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, \ - "Can't propagate flush dep clean flag") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean flag") } } /* end if */ - } /* end else */ + } /* end else */ /* reset the flush_in progress flag */ entry_ptr->flush_in_progress = FALSE; /* capture the cache entry address for the log_flush call at the - * end before the entry_ptr gets freed + * end before the entry_ptr gets freed */ entry_addr = entry_ptr->addr; @@ -7169,7 +6820,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * * Now discard the entry if appropriate. */ - if ( destroy ) { + if (destroy) { /* Sanity check */ HDassert(0 == entry_ptr->flush_dep_nparents); @@ -7181,11 +6832,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * * Otherwise, free the buffer if it exists. */ - if ( suppress_image_entry_frees && entry_ptr->include_in_image ) { + if (suppress_image_entry_frees && entry_ptr->include_in_image) { entry_ptr->image_ptr = NULL; - - } else if ( entry_ptr->image_ptr != NULL ) { + } + else if (entry_ptr->image_ptr != NULL) { entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); } @@ -7196,7 +6847,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * If the entry is prefetched, the free_isr routine will dispose of * the flush dependency parents addresses array if necessary. */ - if ( ! entry_ptr->prefetched ) { + if (!entry_ptr->prefetched) { HDassert(0 == entry_ptr->fd_parent_count); HDassert(NULL == entry_ptr->fd_parent_addrs); @@ -7206,7 +6857,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* Check whether we should free the space in the file that * the entry occupies */ - if ( free_file_space ) { + if (free_file_space) { hsize_t fsf_size; @@ -7227,26 +6878,22 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * it to get the size of the block of file space to free. * Otherwise use entry_ptr->size. */ - if ( entry_ptr->type->fsf_size ) { + if (entry_ptr->type->fsf_size) { - if ( (entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) - < 0 ) + if ((entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, \ - "unable to get file space free size") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to get file space free size") - } /* end if */ - else { /* no file space free size callback -- use entry size */ + } /* end if */ + else { /* no file space free size callback -- use entry size */ fsf_size = entry_ptr->size; } /* Release the space on disk */ - if ( H5MF_xfree(f, entry_ptr->type->mem_type, - entry_ptr->addr, fsf_size) < 0 ) + if (H5MF_xfree(f, entry_ptr->type->mem_type, entry_ptr->addr, fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, \ - "unable to free file space for cache entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to free file space for cache entry") } /* end if ( free_file_space ) */ @@ -7271,30 +6918,29 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) cache_ptr->entries_removed_counter++; cache_ptr->last_entry_removed_ptr = entry_ptr; - if ( entry_ptr == cache_ptr->entry_watched_for_removal ) { + if (entry_ptr == cache_ptr->entry_watched_for_removal) { cache_ptr->entry_watched_for_removal = NULL; } /* Check for actually destroying the entry in memory */ /* (As opposed to taking ownership of it) */ - if ( destroy_entry ) { + if (destroy_entry) { - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { /* Reset dirty flag */ entry_ptr->is_dirty = FALSE; - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully * integrated into the cache. */ - if ( ( entry_ptr->type->notify ) && - ( (entry_ptr->type->notify) - (H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0 ) ) + if ((entry_ptr->type->notify) && + ((entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "can't notify client about entry dirty flag cleared") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") } /* end if */ @@ -7307,12 +6953,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* verify that the image has been freed */ HDassert(entry_ptr->image_ptr == NULL); - if ( entry_ptr->type->free_icr((void *)entry_ptr) < 0 ) + if (entry_ptr->type->free_icr((void *)entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "free_icr callback failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") - } /* end if */ + } /* end if */ else { HDassert(take_ownership); @@ -7324,51 +6969,44 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; } /* end else */ - } /* if (destroy) */ + } /* if (destroy) */ /* Check if we have to update the page buffer with cleared entries * so it doesn't go out of date */ - if ( update_page_buffer ) { + if (update_page_buffer) { /* Sanity check */ HDassert(!destroy); HDassert(entry_ptr->image_ptr); - if ( ( f->shared->page_buf ) && - ( f->shared->page_buf->page_size >= entry_ptr->size ) ) { + if ((f->shared->page_buf) && (f->shared->page_buf->page_size >= entry_ptr->size)) { - if ( H5PB_update_entry(f->shared->page_buf, entry_ptr->addr, - entry_ptr->size, entry_ptr->image_ptr) > 0 ) + if (H5PB_update_entry(f->shared->page_buf, entry_ptr->addr, entry_ptr->size, + entry_ptr->image_ptr) > 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Failed to update PB with metadata cache") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Failed to update PB with metadata cache") } /* end if */ - } /* end if */ + } /* end if */ - if ( cache_ptr->log_flush ) { + if (cache_ptr->log_flush) { - if ( (cache_ptr->log_flush)(cache_ptr, entry_addr, - was_dirty, flags) < 0 ) + if ((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "log_flush callback failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") } /* end if */ done: - HDassert( ( ret_value != SUCCEED ) || ( destroy_entry ) || - ( ! entry_ptr->flush_in_progress ) ); + HDassert((ret_value != SUCCEED) || (destroy_entry) || (!entry_ptr->flush_in_progress)); - HDassert( ( ret_value != SUCCEED ) || ( destroy_entry ) || - ( take_ownership ) || ( ! entry_ptr->is_dirty ) ); + HDassert((ret_value != SUCCEED) || (destroy_entry) || (take_ownership) || (!entry_ptr->is_dirty)); FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_single_entry() */ - /*------------------------------------------------------------------------- * * Function: H5C__verify_len_eoa @@ -7391,12 +7029,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) *------------------------------------------------------------------------- */ static herr_t -H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, - size_t *len, hbool_t actual) +H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, hbool_t actual) { - H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ - haddr_t eoa; /* End-of-allocation in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ + haddr_t eoa; /* End-of-allocation in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7409,33 +7046,32 @@ H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, /* Get the file's end-of-allocation value */ eoa = H5F_get_eoa(f, cooked_type); - if(!H5F_addr_defined(eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") + if (!H5F_addr_defined(eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") /* Check for bad address in general */ - if(H5F_addr_gt(addr, eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") + if (H5F_addr_gt(addr, eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") /* Check if the amount of data to read will be past the EOA */ - if(H5F_addr_gt((addr + *len), eoa)) { - if(actual) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") - else - /* Trim down the length of the metadata */ - *len = (size_t)(eoa - addr); + if (H5F_addr_gt((addr + *len), eoa)) { + if (actual) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") + else + /* Trim down the length of the metadata */ + *len = (size_t)(eoa - addr); } /* end if */ - if(*len <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") + if (*len <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__verify_len_eoa() */ - /*------------------------------------------------------------------------- * - * Function: H5C_load_entry + * Function: H5C__load_entry * * Purpose: Attempt to load the entry at the specified disk address * and with the specified type into memory. If successful. @@ -7452,27 +7088,25 @@ H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ static void * -H5C_load_entry(H5F_t * f, +H5C__load_entry(H5F_t *f, #ifdef H5_HAVE_PARALLEL - hbool_t coll_access, + hbool_t coll_access, #endif /* H5_HAVE_PARALLEL */ - const H5C_class_t * type, - haddr_t addr, - void * udata) + 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 */ - H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as cache entry */ - size_t len; /* Size of image in file */ + 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 */ + 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 - int mpi_rank = 0; /* MPI process rank */ - MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ -#endif /* H5_HAVE_PARALLEL */ - void * ret_value = NULL; /* Return value */ + int mpi_rank = 0; /* MPI process rank */ + MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ +#endif /* H5_HAVE_PARALLEL */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(f); @@ -7481,7 +7115,7 @@ H5C_load_entry(H5F_t * f, HDassert(type); HDassert(H5F_addr_defined(addr)); HDassert(type->get_initial_load_size); - if(type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) + if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) HDassert(type->get_final_load_size); else HDassert(NULL == type->get_final_load_size); @@ -7490,44 +7124,43 @@ H5C_load_entry(H5F_t * f, /* Can't see how skip reads could be usefully combined with * the speculative read flag. Hence disallow. */ - HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && - (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); /* Call the get_initial_load_size callback, to retrieve the initial size of image */ - if(type->get_initial_load_size(udata, &len) < 0) + if (type->get_initial_load_size(udata, &len) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") HDassert(len > 0); /* Check for possible speculative read off the end of the file */ - if(type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) - if(H5C__verify_len_eoa(f, type, addr, &len, FALSE) < 0) + if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) + if (H5C__verify_len_eoa(f, type, addr, &len, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid len with respect to EOA") /* Allocate the buffer for reading the on-disk entry image */ - if(NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) + if (NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - if((comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL) + if ((comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ /* Get the on-disk entry image */ - if(0 == (type->flags & H5C__CLASS_SKIP_READS)) { - unsigned tries, max_tries; /* The # of read attempts */ - unsigned retries; /* The # of retries */ - 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 */ - hbool_t len_changed = TRUE; /* Whether to re-check speculative entries */ + if (0 == (type->flags & H5C__CLASS_SKIP_READS)) { + unsigned tries, max_tries; /* The # of read attempts */ + unsigned retries; /* The # of retries */ + 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 */ + hbool_t len_changed = TRUE; /* Whether to re-check speculative entries */ /* Get the # of read attempts */ max_tries = tries = H5F_GET_READ_ATTEMPTS(f); @@ -7540,19 +7173,19 @@ H5C_load_entry(H5F_t * f, * --perform checksum verification */ do { - if(actual_len != len) { - if(NULL == (new_image = H5MM_realloc(image, len + H5C_IMAGE_EXTRA_SPACE))) + if (actual_len != len) { + if (NULL == (new_image = H5MM_realloc(image, len + H5C_IMAGE_EXTRA_SPACE))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") image = (uint8_t *)new_image; #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ } /* end if */ #ifdef H5_HAVE_PARALLEL - if(!coll_access || 0 == mpi_rank) { + if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ - if(H5F_block_read(f, type->mem_type, addr, len, image) < 0) + if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") #ifdef H5_HAVE_PARALLEL } /* end if */ @@ -7560,62 +7193,64 @@ H5C_load_entry(H5F_t * f, * bcast the metadata read from process 0 to all ranks in the file * communicator */ - if(coll_access) { + if (coll_access) { int buf_size; H5_CHECKED_ASSIGN(buf_size, int, len, size_t); - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /* If the entry could be read speculatively and the length is still * changing, check for updating the actual size */ - if((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && len_changed) { + if ((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && len_changed) { /* Retrieve the actual length */ actual_len = len; - if(type->get_final_load_size(image, len, udata, &actual_len) < 0) - continue; /* Transfer control to while() and count towards retries */ + if (type->get_final_load_size(image, len, udata, &actual_len) < 0) + continue; /* Transfer control to while() and count towards retries */ /* Check for the length changing */ - if(actual_len != len) { + if (actual_len != len) { /* Verify that the length isn't past the EOA for the file */ - if(H5C__verify_len_eoa(f, type, addr, &actual_len, TRUE) < 0) + if (H5C__verify_len_eoa(f, type, addr, &actual_len, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "actual_len exceeds EOA") /* Expand buffer to new size */ - if(NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) + if (NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") image = (uint8_t *)new_image; #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - if(actual_len > len) { + if (actual_len > len) { #ifdef H5_HAVE_PARALLEL - if(!coll_access || 0 == mpi_rank) { + if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ /* If the thing's image needs to be bigger for a speculatively * 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) + 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") #ifdef H5_HAVE_PARALLEL } /* If the collective metadata read optimization is turned on, * Bcast the metadata read from process 0 to all ranks in the file * communicator */ - if(coll_access) { + if (coll_access) { int buf_size; H5_CHECKED_ASSIGN(buf_size, int, actual_len - len, size_t); - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(image + len, buf_size, MPI_BYTE, 0, comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(image + len, buf_size, MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ - } /* end if (actual_len != len) */ +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end if (actual_len != len) */ else { /* The length has stabilized */ len_changed = FALSE; @@ -7623,33 +7258,33 @@ H5C_load_entry(H5F_t * f, /* Set the final length */ len = actual_len; } /* else */ - } /* end if */ + } /* end if */ /* If there's no way to verify the checksum for a piece of metadata * (usually because there's no checksum in the file), leave now */ - if(type->verify_chksum == NULL) + if (type->verify_chksum == NULL) break; /* Verify the checksum for the metadata image */ - if((chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) + if ((chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "failure from verify_chksum callback") - if(chk_ret == TRUE) + if (chk_ret == TRUE) break; /* Sleep for some time */ H5_nanosleep(nanosec); - nanosec *= 2; /* Double the sleep time next time */ - } while(--tries); + nanosec *= 2; /* Double the sleep time next time */ + } while (--tries); /* Check for too many tries */ - if(tries == 0) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "incorrect metadatda checksum after all read attempts") + if (tries == 0) + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "incorrect metadata checksum after all read attempts") /* Calculate and track the # of retries */ retries = max_tries - tries; - if(retries) /* Does not track 0 retry */ - if(H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, retries) < 0) + if (retries) /* Does not track 0 retry */ + if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, retries) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries) /* Set the final length (in case it wasn't set earlier) */ @@ -7657,7 +7292,7 @@ H5C_load_entry(H5F_t * f, } /* end if !H5C__CLASS_SKIP_READS */ /* Deserialize the on-disk image into the native memory form */ - if(NULL == (thing = type->deserialize(image, len, udata, &dirty))) + if (NULL == (thing = type->deserialize(image, len, udata, &dirty))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") entry = (H5C_cache_entry_t *)thing; @@ -7671,7 +7306,7 @@ H5C_load_entry(H5F_t * f, * * In the following assert: * - * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); + * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); * * note that type ids 5 & 6 are associated with object headers in the * metadata cache. @@ -7681,74 +7316,74 @@ H5C_load_entry(H5F_t * f, * metadata cache. */ - HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6) ); + HDassert((dirty == FALSE) || (type->id == 5 || type->id == 6)); - entry->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - entry->cache_ptr = f->shared->cache; - entry->addr = addr; - entry->size = len; + entry->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + entry->cache_ptr = f->shared->cache; + entry->addr = addr; + entry->size = len; HDassert(entry->size < H5C_MAX_ENTRY_SIZE); - entry->image_ptr = image; - entry->image_up_to_date = !dirty; - entry->type = type; - entry->is_dirty = dirty; - entry->dirtied = FALSE; - entry->is_protected = FALSE; - entry->is_read_only = FALSE; - entry->ro_ref_count = 0; - entry->is_pinned = FALSE; - entry->in_slist = FALSE; - entry->flush_marker = FALSE; + entry->image_ptr = image; + entry->image_up_to_date = !dirty; + entry->type = type; + entry->is_dirty = dirty; + entry->dirtied = FALSE; + entry->is_protected = FALSE; + entry->is_read_only = FALSE; + entry->ro_ref_count = 0; + entry->is_pinned = FALSE; + entry->in_slist = FALSE; + entry->flush_marker = FALSE; #ifdef H5_HAVE_PARALLEL - entry->clear_on_unprotect = FALSE; - entry->flush_immediately = FALSE; - entry->coll_access = coll_access; + entry->clear_on_unprotect = FALSE; + entry->flush_immediately = FALSE; + entry->coll_access = coll_access; #endif /* H5_HAVE_PARALLEL */ - entry->flush_in_progress = FALSE; - entry->destroy_in_progress = FALSE; + entry->flush_in_progress = FALSE; + entry->destroy_in_progress = FALSE; - entry->ring = H5C_RING_UNDEFINED; + entry->ring = H5C_RING_UNDEFINED; /* Initialize flush dependency fields */ - entry->flush_dep_parent = NULL; - entry->flush_dep_nparents = 0; - entry->flush_dep_parent_nalloc = 0; - entry->flush_dep_nchildren = 0; - entry->flush_dep_ndirty_children = 0; - entry->flush_dep_nunser_children = 0; - entry->ht_next = NULL; - entry->ht_prev = NULL; - entry->il_next = NULL; - entry->il_prev = NULL; - - entry->next = NULL; - entry->prev = NULL; + entry->flush_dep_parent = NULL; + entry->flush_dep_nparents = 0; + entry->flush_dep_parent_nalloc = 0; + entry->flush_dep_nchildren = 0; + entry->flush_dep_ndirty_children = 0; + entry->flush_dep_nunser_children = 0; + entry->ht_next = NULL; + entry->ht_prev = NULL; + entry->il_next = NULL; + entry->il_prev = NULL; + + entry->next = NULL; + entry->prev = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - entry->aux_next = NULL; - entry->aux_prev = NULL; + entry->aux_next = NULL; + entry->aux_prev = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - entry->coll_next = NULL; - entry->coll_prev = NULL; + entry->coll_next = NULL; + entry->coll_prev = NULL; #endif /* H5_HAVE_PARALLEL */ /* initialize cache image related fields */ - entry->include_in_image = FALSE; - entry->lru_rank = 0; - entry->image_dirty = FALSE; - entry->fd_parent_count = 0; - entry->fd_parent_addrs = NULL; - entry->fd_child_count = 0; - entry->fd_dirty_child_count = 0; - entry->image_fd_height = 0; - entry->prefetched = FALSE; - entry->prefetch_type_id = 0; - entry->age = 0; - entry->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry->serialization_count = 0; + entry->include_in_image = FALSE; + entry->lru_rank = 0; + entry->image_dirty = FALSE; + entry->fd_parent_count = 0; + entry->fd_parent_addrs = NULL; + entry->fd_child_count = 0; + entry->fd_dirty_child_count = 0; + entry->image_fd_height = 0; + entry->prefetched = FALSE; + entry->prefetch_type_id = 0; + entry->age = 0; + entry->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry->serialization_count = 0; #endif /* NDEBUG */ entry->tl_next = NULL; @@ -7761,39 +7396,38 @@ H5C_load_entry(H5F_t * f, done: /* Cleanup on error */ - if(NULL == ret_value) { + if (NULL == ret_value) { /* Release resources */ - if(thing && type->free_icr(thing) < 0) + if (thing && type->free_icr(thing) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") - if(image) + if (image) image = (uint8_t *)H5MM_xfree(image); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_load_entry() */ +} /* H5C__load_entry() */ - /*------------------------------------------------------------------------- * * Function: H5C__make_space_in_cache * * Purpose: Attempt to evict cache entries until the index_size - * is at least needed_space below max_cache_size. + * is at least needed_space below max_cache_size. * - * In passing, also attempt to bring cLRU_list_size to a - * value greater than min_clean_size. + * In passing, also attempt to bring cLRU_list_size to a + * value greater than min_clean_size. * - * Depending on circumstances, both of these goals may - * be impossible, as in parallel mode, we must avoid generating - * a write as part of a read (to avoid deadlock in collective - * I/O), and in all cases, it is possible (though hopefully - * highly unlikely) that the protected list may exceed the - * maximum size of the cache. + * Depending on circumstances, both of these goals may + * be impossible, as in parallel mode, we must avoid generating + * a write as part of a read (to avoid deadlock in collective + * I/O), and in all cases, it is possible (though hopefully + * highly unlikely) that the protected list may exceed the + * maximum size of the cache. * - * Thus the function simply does its best, returning success - * unless an error is encountered. + * Thus the function simply does its best, returning success + * unless an error is encountered. * - * Observe that this function cannot occasion a read. + * Observe that this function cannot occasion a read. * * Return: Non-negative on success/Negative on failure. * @@ -7802,26 +7436,26 @@ H5C_load_entry(H5F_t * f, *------------------------------------------------------------------------- */ herr_t -H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) +H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) { - H5C_t * cache_ptr = f->shared->cache; + H5C_t *cache_ptr = f->shared->cache; #if H5C_COLLECT_CACHE_STATS - int32_t clean_entries_skipped = 0; - int32_t dirty_pf_entries_skipped = 0; - int32_t total_entries_scanned = 0; + int32_t clean_entries_skipped = 0; + int32_t dirty_pf_entries_skipped = 0; + int32_t total_entries_scanned = 0; #endif /* H5C_COLLECT_CACHE_STATS */ - uint32_t entries_examined = 0; - uint32_t initial_list_len; - size_t empty_space; - hbool_t reentrant_call = FALSE; - hbool_t prev_is_dirty = FALSE; - hbool_t didnt_flush_entry = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * prev_ptr; - H5C_cache_entry_t * next_ptr; - uint32_t num_corked_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ + uint32_t entries_examined = 0; + uint32_t initial_list_len; + size_t empty_space; + hbool_t reentrant_call = FALSE; + hbool_t prev_is_dirty = FALSE; + hbool_t didnt_flush_entry = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *prev_ptr; + H5C_cache_entry_t *next_ptr; + uint32_t num_corked_entries = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -7836,76 +7470,58 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) * space in cache process. To avoid an infinite recursion, set * reentrant_call to TRUE, and goto done. */ - if(cache_ptr->msic_in_progress) { + if (cache_ptr->msic_in_progress) { reentrant_call = TRUE; HGOTO_DONE(SUCCEED); } /* end if */ cache_ptr->msic_in_progress = TRUE; - if ( write_permitted ) { - restart_scan = FALSE; + if (write_permitted) { + restart_scan = FALSE; initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; + entry_ptr = cache_ptr->LRU_tail_ptr; - if(cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - while ( ( ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size - ) - || - ( - ( empty_space + cache_ptr->clean_index_size ) - < - ( cache_ptr->min_clean_size ) - ) - ) - && - ( entries_examined <= (2 * initial_list_len) ) - && - ( entry_ptr != NULL ) - ) - { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( !(entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - next_ptr = entry_ptr->next; + while ((((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < (cache_ptr->min_clean_size))) && + (entries_examined <= (2 * initial_list_len)) && (entry_ptr != NULL)) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); + + next_ptr = entry_ptr->next; prev_ptr = entry_ptr->prev; - if(prev_ptr != NULL) - prev_is_dirty = prev_ptr->is_dirty; + if (prev_ptr != NULL) + prev_is_dirty = prev_ptr->is_dirty; - if(entry_ptr->is_dirty && - (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { + if (entry_ptr->is_dirty && (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { /* Skip "dirty" corked entries. */ - ++num_corked_entries; + ++num_corked_entries; didnt_flush_entry = TRUE; - - } else if ( ( (entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID ) && - ( ! entry_ptr->flush_in_progress ) && - ( ! entry_ptr->prefetched_dirty ) ) { + } + else if (((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && (!entry_ptr->flush_in_progress) && + (!entry_ptr->prefetched_dirty)) { didnt_flush_entry = FALSE; - if ( entry_ptr->is_dirty ) { + if (entry_ptr->is_dirty) { #if H5C_COLLECT_CACHE_STATS - if ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size ) { + if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) { cache_ptr->entries_scanned_to_make_space++; } #endif /* H5C_COLLECT_CACHE_STATS */ - /* reset entries_removed_counter and + /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot * unexpected removals of entries from the cache, @@ -7916,26 +7532,29 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - if ( ( cache_ptr->entries_removed_counter > 1 ) || - ( cache_ptr->last_entry_removed_ptr == prev_ptr ) ) + if ((cache_ptr->entries_removed_counter > 1) || + (cache_ptr->last_entry_removed_ptr == prev_ptr)) restart_scan = TRUE; - - } else if ( (cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size + } + else if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size #ifdef H5_HAVE_PARALLEL - && !(entry_ptr->coll_access) + && !(entry_ptr->coll_access) #endif /* H5_HAVE_PARALLEL */ - ) { + ) { #if H5C_COLLECT_CACHE_STATS cache_ptr->entries_scanned_to_make_space++; #endif /* H5C_COLLECT_CACHE_STATS */ - if(H5C__flush_single_entry(f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } else { + } + else { /* We have enough space so don't flush clean entry. */ #if H5C_COLLECT_CACHE_STATS clean_entries_skipped++; @@ -7946,8 +7565,8 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) #if H5C_COLLECT_CACHE_STATS total_entries_scanned++; #endif /* H5C_COLLECT_CACHE_STATS */ - - } else { + } + else { /* Skip epoch markers, entries that are in the process * of being flushed, and entries marked as prefetched_dirty @@ -7956,68 +7575,56 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) didnt_flush_entry = TRUE; #if H5C_COLLECT_CACHE_STATS - if(entry_ptr->prefetched_dirty) + if (entry_ptr->prefetched_dirty) dirty_pf_entries_skipped++; #endif /* H5C_COLLECT_CACHE_STATS */ } - if ( prev_ptr != NULL ) { + if (prev_ptr != NULL) { - if ( didnt_flush_entry ) { + if (didnt_flush_entry) { - /* epoch markers don't get flushed, and we don't touch + /* epoch markers don't get flushed, and we don't touch * entries that are in the process of being flushed. * Hence no need for sanity checks, as we haven't * flushed anything. Thus just set entry_ptr to prev_ptr * and go on. - */ + */ entry_ptr = prev_ptr; + } + else if ((restart_scan) || (prev_ptr->is_dirty != prev_is_dirty) || + (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || (prev_ptr->is_pinned)) { - } else if ( ( restart_scan ) - || - ( prev_ptr->is_dirty != prev_is_dirty ) - || - ( prev_ptr->next != next_ptr ) - || - ( prev_ptr->is_protected ) - || - ( prev_ptr->is_pinned ) ) { - - /* something has happened to the LRU -- start over - * from the tail. - */ + /* something has happened to the LRU -- start over + * from the tail. + */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) - - } else { - - entry_ptr = prev_ptr; - - } - } else { - - entry_ptr = NULL; - - } - - entries_examined++; + entry_ptr = cache_ptr->LRU_tail_ptr; + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + } + else { - if ( cache_ptr->index_size >= cache_ptr->max_cache_size ) { + entry_ptr = prev_ptr; + } + } + else { - empty_space = 0; + entry_ptr = NULL; + } - } else { + entries_examined++; - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + if (cache_ptr->index_size >= cache_ptr->max_cache_size) { - } + empty_space = 0; + } + else { - HDassert( cache_ptr->index_size == - (cache_ptr->clean_index_size + - cache_ptr->dirty_index_size) ); + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + } - } + HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + } #if H5C_COLLECT_CACHE_STATS cache_ptr->calls_to_msic++; @@ -8026,81 +7633,71 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; - if ( clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic ) { + if (clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic) { cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; } - if(dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) + if (dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; - if ( total_entries_scanned > cache_ptr->max_entries_scanned_in_msic ) { + if (total_entries_scanned > cache_ptr->max_entries_scanned_in_msic) { cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; } #endif /* H5C_COLLECT_CACHE_STATS */ - - /* NEED: work on a better assert for corked entries */ - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( (cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > - cache_ptr->max_cache_size ) || - ( ( cache_ptr->clean_index_size + empty_space ) - >= cache_ptr->min_clean_size ) || - ( ( num_corked_entries ))); + /* NEED: work on a better assert for corked entries */ + HDassert((entries_examined > (2 * initial_list_len)) || + ((cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > + cache_ptr->max_cache_size) || + ((cache_ptr->clean_index_size + empty_space) >= cache_ptr->min_clean_size) || + ((num_corked_entries))); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size ) ); - HDassert( ( entries_examined > (2 * initial_list_len) ) || - ( cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size ) ); + HDassert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size)); + HDassert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size)); #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + } + else { - } else { - - HDassert( H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS ); + HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS initial_list_len = cache_ptr->cLRU_list_len; - entry_ptr = cache_ptr->cLRU_tail_ptr; - - while ( ( (cache_ptr->index_size + space_needed) - > - cache_ptr->max_cache_size - ) - && - ( entries_examined <= initial_list_len ) - && - ( entry_ptr != NULL ) - ) - { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( (entry_ptr->ro_ref_count) == 0 ); - HDassert( ! (entry_ptr->is_dirty) ); + entry_ptr = cache_ptr->cLRU_tail_ptr; + + while (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (entries_examined <= initial_list_len) && (entry_ptr != NULL)) { + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert((entry_ptr->ro_ref_count) == 0); + HDassert(!(entry_ptr->is_dirty)); prev_ptr = entry_ptr->aux_prev; - if ( ( !(entry_ptr->prefetched_dirty) ) + if ((!(entry_ptr->prefetched_dirty)) #ifdef H5_HAVE_PARALLEL - && ( ! (entry_ptr->coll_access) ) + && (!(entry_ptr->coll_access)) #endif /* H5_HAVE_PARALLEL */ - ) { - if(H5C__flush_single_entry(f, entry_ptr, - H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + ) { + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") } /* end if */ - /* we are scanning the clean LRU, so the serialize function - * will not be called on any entry -- thus there is no - * concern about the list being modified out from under - * this function. - */ + /* we are scanning the clean LRU, so the serialize function + * will not be called on any entry -- thus there is no + * concern about the list being modified out from under + * this function. + */ entry_ptr = prev_ptr; - entries_examined++; + entries_examined++; } #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ } @@ -8108,458 +7705,297 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) done: /* Sanity checks */ HDassert(cache_ptr->msic_in_progress); - if(!reentrant_call) + if (!reentrant_call) cache_ptr->msic_in_progress = FALSE; HDassert((!reentrant_call) || (cache_ptr->msic_in_progress)); FUNC_LEAVE_NOAPI(ret_value) } /* H5C__make_space_in_cache() */ - /*------------------------------------------------------------------------- * - * Function: H5C_validate_lru_list + * Function: H5C__validate_lru_list * * Purpose: Debugging function that scans the LRU list for errors. * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. * * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: John Mainzer, 7/14/05 * - * Changes: - * - * Added code to verify that the LRU contains no pinned - * entries. JRM -- 4/25/14 - * *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS - static herr_t -H5C_validate_lru_list(H5C_t * cache_ptr) +H5C__validate_lru_list(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; - - FUNC_ENTER_NOAPI_NOINIT + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + FUNC_ENTER_STATIC - if ( ( ( cache_ptr->LRU_head_ptr == NULL ) - || - ( cache_ptr->LRU_tail_ptr == NULL ) - ) - && - ( cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr ) - ) { + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + if (((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_tail_ptr == NULL)) && + (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) + 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 ) - ) - ) { - + 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") - } - - 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 ) - ) - ) { + 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") - } 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 ) ) ) { - + 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") - } - - if ( ( entry_ptr != cache_ptr->LRU_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + 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") - } - - if ( ( entry_ptr->is_pinned ) || - ( entry_ptr->pinned_from_client ) || - ( entry_ptr->pinned_from_cache ) ) { + 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") - } len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ( ( cache_ptr->LRU_list_len != len ) || - ( cache_ptr->LRU_list_size != size ) ) { - + if ((cache_ptr->LRU_list_len != len) || (cache_ptr->LRU_list_size != size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } done: - - if ( ret_value != SUCCEED ) { - + 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. * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. * * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: John Mainzer, 4/25/14 * - * Changes: - * - * None. - * *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS - static herr_t -H5C_validate_pinned_entry_list(H5C_t * cache_ptr) +H5C__validate_pinned_entry_list(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; - - FUNC_ENTER_NOAPI_NOINIT + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + FUNC_ENTER_STATIC - if ( ( ( cache_ptr->pel_head_ptr == NULL ) - || - ( cache_ptr->pel_tail_ptr == NULL ) - ) - && - ( cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr ) - ) { + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + if (((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_tail_ptr == NULL)) && + (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) + 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 ) - ) - ) { - + 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") - } - - 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 ) - ) - ) { + 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") - } 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 ) ) ) { - + 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") - } - - if ( ( entry_ptr != cache_ptr->pel_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + 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") - } - - if ( ! entry_ptr->is_pinned ) { + if (!entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") - } - - if ( ! ( ( entry_ptr->pinned_from_client ) || - ( entry_ptr->pinned_from_cache ) ) ) { + if (!(entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ( ( cache_ptr->pel_len != len ) || - ( cache_ptr->pel_size != size ) ) { - + if ((cache_ptr->pel_len != len) || (cache_ptr->pel_size != size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") - } done: - - if ( ret_value != SUCCEED ) { - + 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. * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. * * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: John Mainzer, 4/25/14 * - * Changes: - * - * None. - * *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS - static herr_t -H5C_validate_protected_entry_list(H5C_t * cache_ptr) +H5C__validate_protected_entry_list(H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t * entry_ptr = NULL; + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) - && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) + if (((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) && + (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) + 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 ) - ) - ) { - + 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") - } - - 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 ) - ) - ) { + 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") - } 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 ) ) ) { - + 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") - } - - if ( ( entry_ptr != cache_ptr->pl_tail_ptr ) && - ( ( entry_ptr->next == NULL ) || - ( entry_ptr->next->prev != entry_ptr ) ) ) { + 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") - } - - if ( ! entry_ptr->is_protected ) { + if (!entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") - } - - if ( ( entry_ptr->is_read_only ) && - ( entry_ptr->ro_ref_count <= 0 ) ) { + if (entry_ptr->is_read_only && (entry_ptr->ro_ref_count <= 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") - } len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ( ( cache_ptr->pl_len != len ) || - ( cache_ptr->pl_size != size ) ) { - + if ((cache_ptr->pl_len != len) || (cache_ptr->pl_size != size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") - } done: - - if ( ret_value != SUCCEED ) { - + 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 - * an entry to be in the skip list twice. + * is in present. We need this, as it is possible for + * an entry to be in the skip list twice. * * Return: FALSE if the entry is not in the skip list, and TRUE - * if it is. + * if it is. * * Programmer: John Mainzer, 11/1/14 * - * Changes: - * - * None. - * *------------------------------------------------------------------------- */ #if H5C_DO_SLIST_SANITY_CHECKS - static hbool_t -H5C_entry_in_skip_list(H5C_t * cache_ptr, H5C_cache_entry_t *target_ptr) +H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) { - hbool_t in_slist = FALSE; - H5SL_node_t * node_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; + H5SL_node_t *node_ptr; + hbool_t in_slist; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->slist_ptr ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(cache_ptr->slist_ptr); node_ptr = H5SL_first(cache_ptr->slist_ptr); + in_slist = FALSE; + while ((node_ptr != NULL) && (!in_slist)) { + H5C_cache_entry_t *entry_ptr; - while ( ( node_ptr != NULL ) && ( ! in_slist ) ) - { entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - HDassert( entry_ptr ); - HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); - - if ( entry_ptr == target_ptr ) { - - in_slist = TRUE; - - } else { + HDassert(entry_ptr); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); - node_ptr = H5SL_next(node_ptr); - } + if (entry_ptr == target_ptr) + in_slist = TRUE; + else + node_ptr = H5SL_next(node_ptr); } - return(in_slist); - -} /* H5C_entry_in_skip_list() */ + return (in_slist); +} /* H5C__entry_in_skip_list() */ #endif /* H5C_DO_SLIST_SANITY_CHECKS */ - /*------------------------------------------------------------------------- * * Function: H5C__flush_marked_entries @@ -8571,11 +8007,11 @@ H5C_entry_in_skip_list(H5C_t * cache_ptr, H5C_cache_entry_t *target_ptr) * Programmer: Mike McGreevy * November 3, 2010 * - * Changes: Modified function to setup the slist before calling + * Changes: Modified function to setup the slist before calling * H%C_flush_cache(), and take it down afterwards. Note - * that the slist need not be empty after the call to - * H5C_flush_cache() since we are only flushing marked - * entries. Thus must set the clear_slist parameter + * that the slist need not be empty after the call to + * H5C_flush_cache() since we are only flushing marked + * entries. Thus must set the clear_slist parameter * of H5C_set_slist_enabled to TRUE. * * JRM -- 5/6/20 @@ -8584,7 +8020,7 @@ H5C_entry_in_skip_list(H5C_t * cache_ptr, H5C_cache_entry_t *target_ptr) */ herr_t -H5C__flush_marked_entries(H5F_t * f) +H5C__flush_marked_entries(H5F_t *f) { herr_t ret_value = SUCCEED; @@ -8593,24 +8029,21 @@ H5C__flush_marked_entries(H5F_t * f) /* Assertions */ HDassert(f != NULL); - /* Enable the slist, as it is needed in the flush */ - if ( H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0 ) + if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") - /* Flush all marked entries */ - if ( H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | - H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0 ) + if (H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") /* Disable the slist. Set the clear_slist parameter to TRUE - * since we called H5C_flush_cache() with the + * since we called H5C_flush_cache() with the * H5C__FLUSH_MARKED_ENTRIES_FLAG. */ - if ( H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0 ) + if (H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed") @@ -8620,35 +8053,34 @@ H5C__flush_marked_entries(H5F_t * f) } /* H5C__flush_marked_entries */ - /*------------------------------------------------------------------------- * * Function: H5C_cork * * Purpose: To cork/uncork/get cork status of an object depending on "action": - * H5C__SET_CORK: - * To cork the object - * Return error if the object is already corked - * H5C__UNCORK: - * To uncork the obejct - * Return error if the object is not corked - * H5C__GET_CORKED: - * To retrieve the cork status of an object in - * the parameter "corked" + * H5C__SET_CORK: + * To cork the object + * Return error if the object is already corked + * H5C__UNCORK: + * To uncork the obejct + * Return error if the object is not corked + * H5C__GET_CORKED: + * To retrieve the cork status of an object in + * the parameter "corked" * * Return: Success: Non-negative * Failure: Negative * * Programmer: Vailin Choi - * January 2014 + * January 2014 * *------------------------------------------------------------------------- */ 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 */ - herr_t ret_value = SUCCEED; + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -8660,9 +8092,9 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *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); - if(H5C__GET_CORKED == action) { + if (H5C__GET_CORKED == action) { HDassert(corked); - if(tag_info != NULL && tag_info->corked) + if (tag_info != NULL && tag_info->corked) *corked = TRUE; else *corked = FALSE; @@ -8672,23 +8104,23 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) HDassert(H5C__SET_CORK == action || H5C__UNCORK == action); /* Perform appropriate action */ - if(H5C__SET_CORK == action) { + if (H5C__SET_CORK == action) { /* Check if this is the first entry for this tagged object */ - if(NULL == tag_info) { + if (NULL == tag_info) { /* Allocate new tag info struct */ - if(NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) + if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") /* 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 ) + 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 */ else { /* Check for object already corked */ - if(tag_info->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 */ @@ -8703,7 +8135,7 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) HDassert(tag_info); /* Check for already uncorked */ - if(!tag_info->corked) + if (!tag_info->corked) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "object already uncorked") /* Set the corked status for the entire object */ @@ -8711,11 +8143,11 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) cache_ptr->num_objs_corked--; /* Remove the tag info from the tag list, if there's no more entries with this tag */ - if(0 == tag_info->entry_cnt) { + if (0 == tag_info->entry_cnt) { /* Sanity check */ HDassert(NULL == tag_info->head); - if(H5SL_remove(cache_ptr->tag_list, &(tag_info->tag)) != tag_info) + 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") /* Release the tag info */ @@ -8724,13 +8156,12 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) else HDassert(NULL != tag_info->head); } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_cork() */ - /*------------------------------------------------------------------------- * Function: H5C__mark_flush_dep_dirty() * @@ -8747,10 +8178,10 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) *------------------------------------------------------------------------- */ static herr_t -H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry) +H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8758,24 +8189,26 @@ H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry) HDassert(entry); /* Iterate over the parent entries, if any */ - for(u = 0; u < entry->flush_dep_nparents; u++) { - /* Sanity check */ - HDassert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < entry->flush_dep_parent[u]->flush_dep_nchildren); + for (u = 0; u < entry->flush_dep_nparents; u++) { + /* Sanity check */ + HDassert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < + entry->flush_dep_parent[u]->flush_dep_nchildren); - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[u]->flush_dep_ndirty_children++; + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[u]->flush_dep_ndirty_children++; /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if(entry->flush_dep_parent[u]->type->notify && - (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, entry->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag set") + if (entry->flush_dep_parent[u]->type->notify && + (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, + entry->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__mark_flush_dep_dirty() */ - /*------------------------------------------------------------------------- * Function: H5C__mark_flush_dep_clean() * @@ -8792,10 +8225,10 @@ H5C__mark_flush_dep_dirty(H5C_cache_entry_t * entry) *------------------------------------------------------------------------- */ static herr_t -H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry) +H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry) { - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8806,30 +8239,31 @@ H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry) /* Note reverse iteration order, in case the callback removes the flush * dependency - QAK, 2017/08/12 */ - for(i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity check */ - HDassert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); + for (i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity check */ + HDassert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[i]->flush_dep_ndirty_children--; + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[i]->flush_dep_ndirty_children--; /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if(entry->flush_dep_parent[i]->type->notify && - (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, entry->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry dirty flag reset") + if (entry->flush_dep_parent[i]->type->notify && + (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, + entry->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__mark_flush_dep_clean() */ - /*------------------------------------------------------------------------- * Function: H5C__mark_flush_dep_serialized() * * Purpose: Decrement the flush_dep_nunser_children fields of all the - * target entry's flush dependency parents in response to - * the target entry becoming serialized. + * target entry's flush dependency parents in response to + * the target entry becoming serialized. * * Return: Non-negative on success/Negative on failure * @@ -8839,10 +8273,10 @@ H5C__mark_flush_dep_clean(H5C_cache_entry_t * entry) *------------------------------------------------------------------------- */ herr_t -H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) +H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr) { - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8853,8 +8287,8 @@ H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) /* Note reverse iteration order, in case the callback removes the flush * dependency - QAK, 2017/08/12 */ - for(i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity checks */ + for (i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity checks */ HDassert(entry_ptr->flush_dep_parent); HDassert(entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children > 0); @@ -8863,16 +8297,17 @@ H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children--; /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if(entry_ptr->flush_dep_parent[i]->type->notify && - (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, entry_ptr->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag set") + if (entry_ptr->flush_dep_parent[i]->type->notify && + (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, + entry_ptr->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__mark_flush_dep_serialized() */ - /*------------------------------------------------------------------------- * Function: H5C__mark_flush_dep_unserialized() * @@ -8888,10 +8323,10 @@ H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr) *------------------------------------------------------------------------- */ herr_t -H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) +H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8899,7 +8334,7 @@ H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) HDassert(entry_ptr); /* Iterate over the parent entries, if any */ - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { /* Sanity check */ HDassert(entry_ptr->flush_dep_parent); HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -8910,16 +8345,17 @@ H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children++; /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if(entry_ptr->flush_dep_parent[u]->type->notify && - (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, entry_ptr->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify parent about child entry serialized flag reset") + if (entry_ptr->flush_dep_parent[u]->type->notify && + (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, + entry_ptr->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__mark_flush_dep_unserialized() */ - #ifndef NDEBUG /*------------------------------------------------------------------------- * Function: H5C__assert_flush_dep_nocycle() @@ -8937,10 +8373,9 @@ H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr) *------------------------------------------------------------------------- */ static void -H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t * entry, - const H5C_cache_entry_t * base_entry) +H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, const H5C_cache_entry_t *base_entry) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -8952,47 +8387,46 @@ H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t * entry, HDassert(base_entry != entry); /* Iterate over entry's parents (if any) */ - for(u = 0; u < entry->flush_dep_nparents; u++) - H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); + for (u = 0; u < entry->flush_dep_nparents; u++) + H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); FUNC_LEAVE_NOAPI_VOID } /* H5C__assert_flush_dep_nocycle() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C__serialize_cache * - * Purpose: Serialize (i.e. construct an on disk image) for all entries - * in the metadata cache including clean entries. + * Purpose: Serialize (i.e. construct an on disk image) for all entries + * in the metadata cache including clean entries. * - * Note that flush dependencies and "flush me last" flags - * must be observed in the serialization process. + * Note that flush dependencies and "flush me last" flags + * must be observed in the serialization process. * - * Note also that entries may be loaded, flushed, evicted, - * expunged, relocated, resized, or removed from the cache - * during this process, just as these actions may occur during - * a regular flush. + * Note also that entries may be loaded, flushed, evicted, + * expunged, relocated, resized, or removed from the cache + * during this process, just as these actions may occur during + * a regular flush. * - * However, we are given that the cache will contain no protected - * entries on entry to this routine (although entries may be - * briefly protected and then unprotected during the serialize - * process). + * However, we are given that the cache will contain no protected + * entries on entry to this routine (although entries may be + * briefly protected and then unprotected during the serialize + * process). * - * The objective of this routine is serialize all entries and - * to force all entries into their actual locations on disk. + * The objective of this routine is serialize all entries and + * to force all entries into their actual locations on disk. * - * The initial need for this routine is to settle all entries - * in the cache prior to construction of the metadata cache - * image so that the size of the cache image can be calculated. - * However, I gather that other uses for the routine are - * under consideration. + * The initial need for this routine is to settle all entries + * in the cache prior to construction of the metadata cache + * image so that the size of the cache image can be calculated. + * However, I gather that other uses for the routine are + * under consideration. * * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * a request to flush all items and something was protected. * * Programmer: John Mainzer - * 7/22/15 + * 7/22/15 * *------------------------------------------------------------------------- */ @@ -9000,17 +8434,17 @@ herr_t H5C__serialize_cache(H5F_t *f) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -9030,7 +8464,7 @@ H5C__serialize_cache(H5F_t *f) HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { index_len += cache_ptr->index_ring_len[i]; index_size += cache_ptr->index_ring_size[i]; clean_index_size += cache_ptr->clean_index_ring_size[i]; @@ -9049,9 +8483,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 */ @@ -9063,17 +8496,17 @@ H5C__serialize_cache(H5F_t *f) * case is which any flush depencency parent is serializes more than * once (a correctness issue). */ - { - H5C_cache_entry_t * scan_ptr = NULL; + { + H5C_cache_entry_t *scan_ptr = NULL; scan_ptr = cache_ptr->il_head; - while(scan_ptr != NULL) { - HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - scan_ptr->serialization_count = 0; - scan_ptr = scan_ptr->il_next; + while (scan_ptr != NULL) { + HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + scan_ptr->serialization_count = 0; + scan_ptr = scan_ptr->il_next; } /* end while */ - } /* end block */ -#endif /* NDEBUG */ + } /* end block */ +#endif /* NDEBUG */ /* set cache_ptr->serialization_in_progress to TRUE, and back * to FALSE at the end of the function. Must maintain this flag @@ -9088,23 +8521,23 @@ H5C__serialize_cache(H5F_t *f) * working inward. */ ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { - HDassert(cache_ptr->close_warning_received); - switch(ring) { + while (ring < H5C_RING_NTYPES) { + HDassert(cache_ptr->close_warning_received); + switch (ring) { case H5C_RING_USER: break; case H5C_RING_RDFSM: /* Settle raw data FSM */ - if(!cache_ptr->rdfsm_settled) - if(H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) + if (!cache_ptr->rdfsm_settled) + if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") break; case H5C_RING_MDFSM: /* Settle metadata FSM */ - if(!cache_ptr->mdfsm_settled) - if(H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) + if (!cache_ptr->mdfsm_settled) + if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") break; @@ -9117,7 +8550,7 @@ H5C__serialize_cache(H5F_t *f) break; } /* end switch */ - if(H5C__serialize_ring(f, ring) < 0) + if (H5C__serialize_ring(f, ring) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialize ring failed") ring++; @@ -9128,25 +8561,24 @@ H5C__serialize_cache(H5F_t *f) * FD parents with multiple serializations should have been caught * elsewhere, so no specific check for them here. */ - { - H5C_cache_entry_t * scan_ptr = NULL; + { + H5C_cache_entry_t *scan_ptr = NULL; scan_ptr = cache_ptr->il_head; - while(scan_ptr != NULL) { - HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(scan_ptr->serialization_count <= 1); + while (scan_ptr != NULL) { + HDassert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(scan_ptr->serialization_count <= 1); - scan_ptr = scan_ptr->il_next; + scan_ptr = scan_ptr->il_next; } /* end while */ - } /* end block */ -#endif /* NDEBUG */ + } /* end block */ +#endif /* NDEBUG */ done: cache_ptr->serialization_in_progress = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* H5C__serialize_cache() */ - /*------------------------------------------------------------------------- * Function: H5C__serialize_ring * @@ -9157,16 +8589,16 @@ H5C__serialize_cache(H5F_t *f) * If the cache contains protected entries in the specified * ring, the function will fail, as protected entries cannot * be serialized. However all unprotected entries in the - * target ring should be serialized before the function - * returns failure. + * target ring should be serialized before the function + * returns failure. * * If flush dependencies appear in the target ring, the * function makes repeated passes through the index list - * serializing entries in flush dependency order. + * serializing entries in flush dependency order. * - * All entries outside the H5C_RING_SBE are marked for - * inclusion in the cache image. Entries in H5C_RING_SBE - * and below are marked for exclusion from the image. + * All entries outside the H5C_RING_SBE are marked for + * inclusion in the cache image. Entries in H5C_RING_SBE + * and below are marked for exclusion from the image. * * Return: Non-negative on success/Negative on failure or if there was * a request to flush all items and something was protected. @@ -9179,10 +8611,10 @@ H5C__serialize_cache(H5F_t *f) static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) { - hbool_t done = FALSE; - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr; - herr_t ret_value = SUCCEED; + hbool_t done = FALSE; + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -9272,86 +8704,84 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) * a serialization is not a problem as long as the flush depencency * tree does not change beyond the removal of a leaf. */ - while(!done) { + while (!done) { /* Reset the counters so that we can detect insertions, loads, * moves, and flush dependency height changes caused by the pre_serialize * and serialize callbacks. */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; - done = TRUE; /* set to FALSE if any activity in inner loop */ - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + done = TRUE; /* set to FALSE if any activity in inner loop */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Verify that either the entry is already serialized, or + /* Verify that either the entry is already serialized, or * that it is assigned to either the target or an inner * ring. */ HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - /* Skip flush me last entries or inner ring entries */ - if(!entry_ptr->flush_me_last && entry_ptr->ring == ring) { + /* Skip flush me last entries or inner ring entries */ + if (!entry_ptr->flush_me_last && entry_ptr->ring == ring) { - /* if we encounter an unserialized entry in the current + /* if we encounter an unserialized entry in the current * ring that is not marked flush me last, we are not done. */ - if(!entry_ptr->image_up_to_date) - done = FALSE; + if (!entry_ptr->image_up_to_date) + done = FALSE; - /* Serialize the entry if its image is not up to date + /* Serialize the entry if its image is not up to date * and it has no unserialized flush dependency children. */ - if(!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { - HDassert(entry_ptr->serialization_count == 0); + if (!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { + HDassert(entry_ptr->serialization_count == 0); - /* Serialize the entry */ - if(H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") HDassert(entry_ptr->flush_dep_nunser_children == 0); - HDassert(entry_ptr->serialization_count == 0); + HDassert(entry_ptr->serialization_count == 0); #ifndef NDEBUG /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ + entry_ptr->serialization_count++; +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ /* Check for the cache being perturbed during the entry serialize */ - if((cache_ptr->entries_loaded_counter > 0) || - (cache_ptr->entries_inserted_counter > 0) || - (cache_ptr->entries_relocated_counter > 0)) { + if ((cache_ptr->entries_loaded_counter > 0) || (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) { #if H5C_COLLECT_CACHE_STATS H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ /* Reset the counters */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; /* Restart scan */ entry_ptr = cache_ptr->il_head; } /* end if */ else /* Advance to next entry */ - entry_ptr = entry_ptr->il_next; - } /* while ( entry_ptr != NULL ) */ - } /* while ( ! done ) */ - + entry_ptr = entry_ptr->il_next; + } /* while ( entry_ptr != NULL ) */ + } /* while ( ! done ) */ /* Reset the counters so that we can detect insertions, loads, * moves, and flush dependency height changes caused by the pre_serialize * and serialize callbacks. */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; /* At this point, all entries not marked "flush me last" and in * the current ring or outside it should be serialized and have up @@ -9360,44 +8790,45 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) * verify that all other entries have up to date images. */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring > H5C_RING_UNDEFINED); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring > H5C_RING_UNDEFINED); HDassert(entry_ptr->ring < H5C_RING_NTYPES); HDassert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - if(entry_ptr->ring == ring) { - if(entry_ptr->flush_me_last) { - if(!entry_ptr->image_up_to_date) { - HDassert(entry_ptr->serialization_count == 0); + if (entry_ptr->ring == ring) { + if (entry_ptr->flush_me_last) { + if (!entry_ptr->image_up_to_date) { + HDassert(entry_ptr->serialization_count == 0); HDassert(entry_ptr->flush_dep_nunser_children == 0); - /* Serialize the entry */ - if(H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") /* Check for the cache changing */ - if((cache_ptr->entries_loaded_counter > 0) || - (cache_ptr->entries_inserted_counter > 0) || - (cache_ptr->entries_relocated_counter > 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush_me_last entry serialization triggered restart") + if ((cache_ptr->entries_loaded_counter > 0) || + (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flush_me_last entry serialization triggered restart") HDassert(entry_ptr->flush_dep_nunser_children == 0); - HDassert(entry_ptr->serialization_count == 0); + HDassert(entry_ptr->serialization_count == 0); #ifndef NDEBUG /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ + entry_ptr->serialization_count++; +#endif /* NDEBUG */ } /* end if */ - } /* end if */ + } /* end if */ else { - HDassert(entry_ptr->image_up_to_date); - HDassert(entry_ptr->serialization_count <= 1); + HDassert(entry_ptr->image_up_to_date); + HDassert(entry_ptr->serialization_count <= 1); HDassert(entry_ptr->flush_dep_nunser_children == 0); - } /* end else */ - } /* if ( entry_ptr->ring == ring ) */ + } /* end else */ + } /* if ( entry_ptr->ring == ring ) */ - entry_ptr = entry_ptr->il_next; + entry_ptr = entry_ptr->il_next; } /* while ( entry_ptr != NULL ) */ done: @@ -9405,12 +8836,11 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__serialize_ring() */ - /*------------------------------------------------------------------------- * Function: H5C__serialize_single_entry * * Purpose: Serialize the cache entry pointed to by the entry_ptr - * parameter. + * parameter. * * Return: Non-negative on success/Negative on failure * @@ -9421,7 +8851,7 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9445,17 +8875,18 @@ H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry entry_ptr->flush_in_progress = TRUE; /* Allocate buffer for the entry image if required. */ - if(NULL == entry_ptr->image_ptr) { + if (NULL == entry_ptr->image_ptr) { HDassert(entry_ptr->size > 0); - if(NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ + } /* end if */ /* Generate image for entry */ - if(H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "Can't generate image for cache entry") /* Reset the flush_in progress flag */ @@ -9467,7 +8898,6 @@ H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry FUNC_LEAVE_NOAPI(ret_value) } /* H5C__serialize_single_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__generate_image * @@ -9487,22 +8917,22 @@ H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry * Programmer: Mohamad Chaarawi * 2/10/16 * - * Changes: Updated sanity checks for the possibility that the skip + * Changes: Updated sanity checks for the possibility that the skip * list is disabled. * JRM 5/16/20 * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) { - haddr_t new_addr = HADDR_UNDEF; - haddr_t old_addr = HADDR_UNDEF; - size_t new_len = 0; - unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; - herr_t ret_value = SUCCEED; + haddr_t new_addr = HADDR_UNDEF; + haddr_t old_addr = HADDR_UNDEF; + size_t new_len = 0; + unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; + herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -9519,24 +8949,19 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) old_addr = entry_ptr->addr; /* Call client's pre-serialize callback, if there's one */ - if ( ( entry_ptr->type->pre_serialize ) && - ( (entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, - entry_ptr->addr, entry_ptr->size, - &new_addr, &new_len, - &serialize_flags) < 0 ) ) + if ((entry_ptr->type->pre_serialize) && + ((entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, entry_ptr->addr, entry_ptr->size, &new_addr, + &new_len, &serialize_flags) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unable to pre-serialize entry") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry") /* Check for any flags set in the pre-serialize callback */ - if ( serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET ) { + if (serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) { /* Check for unexpected flags from serialize callback */ - if ( serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | - H5C__SERIALIZE_MOVED_FLAG) ) + if (serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | H5C__SERIALIZE_MOVED_FLAG)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "unknown serialize flag(s)") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)") #ifdef H5_HAVE_PARALLEL /* In the parallel case, resizes and moves in @@ -9565,40 +8990,37 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) * If that ceases to be the case, further * tests will be necessary. */ - if ( cache_ptr->aux_ptr != NULL ) + if (cache_ptr->aux_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "resize/move in serialize occurred in parallel case") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occurred in parallel case") #endif /* If required, resize the buffer and update the entry and the cache - * data structures + * data structures */ - if ( serialize_flags & H5C__SERIALIZE_RESIZED_FLAG ) { + if (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) { /* Sanity check */ HDassert(new_len > 0); /* Allocate a new image buffer */ - if ( NULL == (entry_ptr->image_ptr = - H5MM_realloc(entry_ptr->image_ptr, - new_len + H5C_IMAGE_EXTRA_SPACE)) ) + if (NULL == + (entry_ptr->image_ptr = H5MM_realloc(entry_ptr->image_ptr, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \ - "memory allocation failed for on disk image buffer") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Update statistics for resizing the entry */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, \ - new_len); + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); /* Update the hash table for the size change */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_len, entry_ptr, !(entry_ptr->is_dirty)); + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len, entry_ptr, + !(entry_ptr->is_dirty)); /* The entry can't be protected since we are in the process of * flushing it. Thus we must update the replacement policy data @@ -9609,15 +9031,14 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) /* As we haven't updated the cache data structures for * for the flush or flush destroy yet, the entry should - * be in the slist if the slist is enabled. Since - * H5C__UPDATE_SLIST_FOR_SIZE_CHANGE() is a no-op if the + * be in the slist if the slist is enabled. Since + * H5C__UPDATE_SLIST_FOR_SIZE_CHANGE() is a no-op if the * slist is enabled, call it un-conditionally. */ HDassert(entry_ptr->is_dirty); HDassert((entry_ptr->in_slist) || (!cache_ptr->slist_enabled)); - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \ - new_len); + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len); /* Finally, update the entry for its new size */ entry_ptr->size = new_len; @@ -9627,13 +9048,13 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) /* If required, udate the entry and the cache data structures * for a move */ - if ( serialize_flags & H5C__SERIALIZE_MOVED_FLAG ) { + if (serialize_flags & H5C__SERIALIZE_MOVED_FLAG) { /* Update stats and entries relocated counter */ H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) /* We must update cache data structures for the change in address */ - if ( entry_ptr->addr == old_addr ) { + if (entry_ptr->addr == old_addr) { /* Delete the entry from the hash table and the slist */ H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); @@ -9646,23 +9067,22 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); - } /* end if */ + } /* end if */ else { /* move is already done for us -- just do sanity checks */ HDassert(entry_ptr->addr == new_addr); } } /* end if */ - } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ + } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ /* Serialize object into buffer */ - if ( entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, - (void *)entry_ptr) < 0 ) + if (entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, (void *)entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry") #if H5C_DO_MEMORY_SANITY_CHECKS - HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size,\ - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE)); + HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE)); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ entry_ptr->image_up_to_date = TRUE; @@ -9675,25 +9095,23 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) */ HDassert(entry_ptr->flush_dep_nunser_children == 0); - if ( entry_ptr->flush_dep_nparents > 0 ) { + if (entry_ptr->flush_dep_nparents > 0) { - if ( H5C__mark_flush_dep_serialized(entry_ptr) < 0 ) + if (H5C__mark_flush_dep_serialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, \ - "Can't propagate serialization status to fd parents") + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__generate_image */ - /*------------------------------------------------------------------------- * * Function: H5C_remove_entry * * Purpose: Remove an entry from the cache. Must be not protected, pinned, - * dirty, involved in flush dependencies, etc. + * dirty, involved in flush dependencies, etc. * * Return: Non-negative on success/Negative on failure * @@ -9705,9 +9123,9 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ + H5C_t * cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -9719,11 +9137,11 @@ H5C_remove_entry(void *_entry) HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Check for error conditions */ - if(entry->is_dirty) + if (entry->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove dirty entry from cache") - if(entry->is_protected) + if (entry->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove protected entry from cache") - if(entry->is_pinned) + if (entry->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove pinned entry from cache") /* NOTE: If these two errors are getting tripped because the entry is * in a flush dependency with a freedspace entry, move the checks @@ -9731,10 +9149,12 @@ H5C_remove_entry(void *_entry) * "child being evicted" message to the "before evict" notify * section below. QAK - 2017/08/03 */ - if(entry->flush_dep_nparents > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry with flush dependency parents from cache") - if(entry->flush_dep_nchildren > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry with flush dependency children from cache") + if (entry->flush_dep_nparents > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency parents from cache") + if (entry->flush_dep_nchildren > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency children from cache") /* Additional internal cache consistency checks */ HDassert(!entry->in_slist); @@ -9752,31 +9172,31 @@ H5C_remove_entry(void *_entry) /* If the entry's type has a 'notify' callback, send a 'before eviction' * notice while the entry is still fully integrated in the cache. */ - if(entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) + if (entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") /* Update the cache internal data structures as appropriate for a destroy. * Specifically: - * 1) Delete it from the index - * 2) Delete it from the collective read access list - * 3) Update the replacement policy for eviction - * 4) Remove it from the tag list for this object + * 1) Delete it from the index + * 2) Delete it from the collective read access list + * 3) Update the replacement policy for eviction + * 4) Remove it from the tag list for this object */ H5C__DELETE_FROM_INDEX(cache, entry, FAIL) #ifdef H5_HAVE_PARALLEL /* Check for collective read access flag */ - if(entry->coll_access) { + if (entry->coll_access) { entry->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL) - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL) /* Remove entry from tag list */ - if(H5C__untag_entry(cache, entry) < 0) + if (H5C__untag_entry(cache, entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") /* Increment entries_removed_counter and set last_entry_removed_ptr. @@ -9794,7 +9214,7 @@ H5C_remove_entry(void *_entry) */ cache->entries_removed_counter++; cache->last_entry_removed_ptr = entry; - if(entry == cache->entry_watched_for_removal) + if (entry == cache->entry_watched_for_removal) cache->entry_watched_for_removal = NULL; /* Internal cache data structures should now be up to date, and @@ -9804,7 +9224,7 @@ H5C_remove_entry(void *_entry) */ /* Free the buffer for the on disk image */ - if(entry->image_ptr != NULL) + if (entry->image_ptr != NULL) entry->image_ptr = H5MM_xfree(entry->image_ptr); /* Reset the pointer to the cache the entry is within */ @@ -9818,4 +9238,3 @@ H5C_remove_entry(void *_entry) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__remove_entry() */ - diff --git a/src/H5CS.c b/src/H5CS.c index 324d383ff42..6510c252503 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,20 +25,19 @@ * */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CSprivate.h" /* Function stack */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5CSprivate.h" /* Function stack */ +#include "H5Eprivate.h" /* Error handling */ #ifdef H5_HAVE_CODESTACK -#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */ +#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */ /* A function stack */ typedef struct H5CS_t { - unsigned nused; /* Number of records currently used in stack */ - unsigned nalloc; /* Number of records current allocated for stack */ - const char **rec; /* Array of function records */ + unsigned nused; /* Number of records currently used in stack */ + unsigned nalloc; /* Number of records current allocated for stack */ + const char **rec; /* Array of function records */ } H5CS_t; #ifdef H5_HAVE_THREADSAFE @@ -52,17 +51,16 @@ typedef struct H5CS_t { * by "H5CS_t *fstack =". */ static H5CS_t *H5CS__get_stack(void); -#define H5CS_get_my_stack() H5CS__get_stack() +#define H5CS_get_my_stack() H5CS__get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The function stack. Eventually we'll have some sort of global table so each * thread has it's own stack. The stacks will be created on demand when the * thread first calls H5CS_push(). */ -H5CS_t H5CS_stack_g[1]; -#define H5CS_get_my_stack() (H5CS_stack_g+0) +H5CS_t H5CS_stack_g[1]; +#define H5CS_get_my_stack() (H5CS_stack_g + 0) #endif /* H5_HAVE_THREADSAFE */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5CS__get_stack @@ -87,19 +85,21 @@ H5CS__get_stack(void) FUNC_ENTER_STATIC_NOERR_NOFS fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g); - if(!fstack) { + if (!fstack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS - fstack = (H5CS_t *)LocalAlloc(LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ + fstack = (H5CS_t *)LocalAlloc( + LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ #else - fstack = (H5CS_t *)HDmalloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ + fstack = (H5CS_t *)HDmalloc( + sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ #endif /* H5_HAVE_WIN_THREADS */ HDassert(fstack); /* Set the thread-specific info */ - fstack->nused = 0; + fstack->nused = 0; fstack->nalloc = 0; - fstack->rec = NULL; + fstack->rec = NULL; /* (It's not necessary to release this in this API, it is * released by the "key destructor" set up in the H5TS @@ -110,9 +110,8 @@ H5CS__get_stack(void) FUNC_LEAVE_NOAPI_NOFS(fstack) } /* end H5CS__get_stack() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5CS_print_stack * @@ -128,8 +127,8 @@ H5CS__get_stack(void) herr_t H5CS_print_stack(const H5CS_t *fstack, FILE *stream) { - const int indent = 2; /* Indention level */ - int i; /* Local index ariable */ + const int indent = 2; /* Indention level */ + int i; /* Local index ariable */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -138,23 +137,22 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) HDassert(fstack); /* Default to outputting information to stderr */ - if(!stream) + if (!stream) stream = stderr; HDfprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ HDfprintf(stream, "thread %" PRIu64 ".", H5TS_thread_id()); - if(fstack && fstack->nused>0) + if (fstack && fstack->nused > 0) HDfprintf(stream, " Back trace follows."); HDfputc('\n', stream); - for(i = fstack->nused - 1; i >= 0; --i) + for (i = fstack->nused - 1; i >= 0; --i) HDfprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->rec[i]); FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_print_stack() */ - /*------------------------------------------------------------------------- * Function: H5CS_push * @@ -171,7 +169,7 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) herr_t H5CS_push(const char *func_name) { - H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ + H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -182,7 +180,7 @@ H5CS_push(const char *func_name) HDassert(func_name); /* Check if we need to expand the stack of records */ - if(fstack->nused == fstack->nalloc) { + if (fstack->nused == fstack->nalloc) { size_t na = MAX((fstack->nalloc * 2), H5CS_MIN_NSLOTS); /* Don't use H5MM_realloc here */ @@ -190,7 +188,7 @@ H5CS_push(const char *func_name) /* (Avoid returning an error from this routine, currently -QAK) */ HDassert(x); - fstack->rec = x; + fstack->rec = x; fstack->nalloc = na; } /* end if */ @@ -201,7 +199,6 @@ H5CS_push(const char *func_name) FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_push() */ - /*------------------------------------------------------------------------- * Function: H5CS_pop * @@ -217,7 +214,7 @@ H5CS_push(const char *func_name) herr_t H5CS_pop(void) { - H5CS_t *fstack = H5CS_get_my_stack(); + H5CS_t *fstack = H5CS_get_my_stack(); /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -232,7 +229,6 @@ H5CS_pop(void) FUNC_LEAVE_NOAPI_NOFS(SUCCEED); } /* end H5CS_pop() */ - /*------------------------------------------------------------------------- * Function: H5CS_copy_stack * @@ -248,10 +244,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 */ - unsigned u; /* Local index variable */ - H5CS_t *ret_value = NULL; /* Return value */ + 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 */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFS @@ -261,13 +257,13 @@ H5CS_copy_stack(void) /* Allocate a new stack */ /* (Don't use library allocate code, since this code stack supports it) */ - if(NULL == (new_stack = HDcalloc(1, sizeof(H5CS_t)))) + if (NULL == (new_stack = HDcalloc(1, sizeof(H5CS_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack") - if(NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) + if (NULL == (new_stack->rec = HDcalloc(old_stack->nused, sizeof(const char *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack records") /* Copy old stack to new one, duplicating the strings */ - for(u = 0; u < old_stack->nused; u++) + for (u = 0; u < old_stack->nused; u++) new_stack->rec[u] = HDstrdup(old_stack->rec[u]); new_stack->nused = new_stack->nalloc = old_stack->nused; @@ -278,7 +274,6 @@ H5CS_copy_stack(void) FUNC_LEAVE_NOAPI_NOFS(ret_value) } /* end H5CS_copy_stack() */ - /*------------------------------------------------------------------------- * Function: H5CS_close_stack * @@ -294,7 +289,7 @@ H5CS_copy_stack(void) herr_t H5CS_close_stack(H5CS_t *stack) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -303,20 +298,19 @@ H5CS_close_stack(H5CS_t *stack) HDassert(stack); /* Free stack */ - for(u = 0; u < stack->nused; u++) { - if(stack->rec[u]) + for (u = 0; u < stack->nused; u++) { + if (stack->rec[u]) HDfree((void *)stack->rec[u]); stack->rec[u] = NULL; } /* end for */ - if(stack->rec) { + if (stack->rec) { HDfree(stack->rec); stack->rec = NULL; } /* end if */ - if(stack) + if (stack) HDfree(stack); FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_close_stack() */ #endif /* H5_HAVE_CODESTACK */ - diff --git a/src/H5CSprivate.h b/src/H5CSprivate.h index 467dd9d9751..a238ec7ad1f 100644 --- a/src/H5CSprivate.h +++ b/src/H5CSprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * Header file for function stacks, etc. */ -#ifndef _H5CSprivate_H -#define _H5CSprivate_H +#ifndef H5CSprivate_H +#define H5CSprivate_H #ifdef NOT_YET #include "H5CSpublic.h" @@ -26,11 +26,10 @@ /* Forward declarations for structure fields */ struct H5CS_t; -H5_DLL herr_t H5CS_push(const char *func_name); -H5_DLL herr_t H5CS_pop(void); -H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream); +H5_DLL herr_t H5CS_push(const char *func_name); +H5_DLL herr_t H5CS_pop(void); +H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream); H5_DLL struct H5CS_t *H5CS_copy_stack(void); -H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack); - -#endif /* _H5CSprivate_H */ +H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack); +#endif /* H5CSprivate_H */ diff --git a/src/H5CX.c b/src/H5CX.c index d48470ee51d..ff3620e28fa 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,23 +24,20 @@ /* Module Setup */ /****************/ -#include "H5CXmodule.h" /* This source code file is part of the H5CX module */ - - +#include "H5CXmodule.h" /* This source code file is part of the H5CX module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ @@ -56,7 +53,7 @@ * In order for this macro to work, H5CX_get_my_context() must be preceeded * by "H5CX_node_t *ctx =". */ -#define H5CX_get_my_context() H5CX__get_context() +#define H5CX_get_my_context() H5CX__get_context() #else /* H5_HAVE_THREADSAFE */ /* * The current API context. @@ -65,84 +62,84 @@ #endif /* H5_HAVE_THREADSAFE */ /* Common macro for the retrieving the pointer to a property list */ -#define H5CX_RETRIEVE_PLIST(PL, FAILVAL) \ - /* Check if the property list is already available */ \ - if(NULL == (*head)->ctx.PL) \ - /* Get the property list pointer */ \ - if(NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL,_id)))) \ +#define H5CX_RETRIEVE_PLIST(PL, FAILVAL) \ + /* Check if the property list is already available */ \ + if (NULL == (*head)->ctx.PL) \ + /* Get the property list pointer */ \ + if (NULL == ((*head)->ctx.PL = (H5P_genplist_t *)H5I_object((*head)->ctx.H5_GLUE(PL, _id)))) \ HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, (FAILVAL), "can't get property list") /* Common macro for the duplicated code to retrieve properties from a property list */ -#define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check for default property list */ \ - if((*head)->ctx.H5_GLUE(PL,_id) == (DEF_PL)) \ - H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD, sizeof(H5_GLUE3(H5CX_def_,PL,_cache).PROP_FIELD)); \ - else { \ - /* Retrieve the property list */ \ - H5CX_RETRIEVE_PLIST(PL, FAIL) \ - \ - /* Get the property */ \ - if(H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context") \ - } /* end else */ \ - \ - /* Mark the field as valid */ \ - (*head)->ctx.H5_GLUE(PROP_FIELD,_valid) = TRUE; +#define H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check for default property list */ \ + if ((*head)->ctx.H5_GLUE(PL, _id) == (DEF_PL)) \ + H5MM_memcpy(&(*head)->ctx.PROP_FIELD, &H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD, \ + sizeof(H5_GLUE3(H5CX_def_, PL, _cache).PROP_FIELD)); \ + else { \ + /* Retrieve the property list */ \ + H5CX_RETRIEVE_PLIST(PL, FAIL) \ + \ + /* Get the property */ \ + if (H5P_get((*head)->ctx.PL, (PROP_NAME), &(*head)->ctx.PROP_FIELD) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't retrieve value from API context") \ + } /* end else */ \ + \ + /* Mark the field as valid */ \ + (*head)->ctx.H5_GLUE(PROP_FIELD, _valid) = TRUE; /* Macro for the duplicated code to retrieve properties from a property list */ -#define H5CX_RETRIEVE_PROP_VALID(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check if the value has been retrieved already */ \ - if(!(*head)->ctx.H5_GLUE(PROP_FIELD,_valid)) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ +#define H5CX_RETRIEVE_PROP_VALID(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check if the value has been retrieved already */ \ + if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _valid)) { \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ } /* end if */ #ifdef H5_HAVE_PARALLEL /* Macro for the duplicated code to retrieve possibly set properties from a property list */ -#define H5CX_RETRIEVE_PROP_VALID_SET(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - /* Check if the value has been retrieved already */ \ - if(!((*head)->ctx.H5_GLUE(PROP_FIELD,_valid) || (*head)->ctx.H5_GLUE(PROP_FIELD,_set))) { \ - H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ - } /* end if */ +#define H5CX_RETRIEVE_PROP_VALID_SET(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + /* Check if the value has been retrieved already */ \ + if (!((*head)->ctx.H5_GLUE(PROP_FIELD, _valid) || (*head)->ctx.H5_GLUE(PROP_FIELD, _set))) { \ + H5CX_RETRIEVE_PROP_COMMON(PL, DEF_PL, PROP_NAME, PROP_FIELD) \ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ #if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) /* Macro for the duplicated code to test and set properties for a property list */ -#define H5CX_TEST_SET_PROP(PROP_NAME, PROP_FIELD) \ -{ \ - htri_t check_prop = 0; /* Whether the property exists in the API context's DXPL */ \ - \ - /* Check if property exists in DXPL */ \ - if(!(*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \ - /* Retrieve the dataset transfer property list */ \ - H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ - \ - if((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property") \ - } /* end if */ \ - \ - /* If property was already set or exists (for first set), update it */ \ - if((*head)->ctx.H5_GLUE(PROP_FIELD,_set) || check_prop > 0) { \ - /* Cache the value for later, marking it to set in DXPL when context popped */ \ - (*head)->ctx.PROP_FIELD = PROP_FIELD; \ - (*head)->ctx.H5_GLUE(PROP_FIELD,_set) = TRUE; \ - } /* end if */ \ -} +#define H5CX_TEST_SET_PROP(PROP_NAME, PROP_FIELD) \ + { \ + htri_t check_prop = 0; /* Whether the property exists in the API context's DXPL */ \ + \ + /* Check if property exists in DXPL */ \ + if (!(*head)->ctx.H5_GLUE(PROP_FIELD, _set)) { \ + /* Retrieve the dataset transfer property list */ \ + H5CX_RETRIEVE_PLIST(dxpl, FAIL) \ + \ + if ((check_prop = H5P_exist_plist((*head)->ctx.dxpl, PROP_NAME)) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error checking for property") \ + } /* end if */ \ + \ + /* If property was already set or exists (for first set), update it */ \ + if ((*head)->ctx.H5_GLUE(PROP_FIELD, _set) || check_prop > 0) { \ + /* Cache the value for later, marking it to set in DXPL when context popped */ \ + (*head)->ctx.PROP_FIELD = PROP_FIELD; \ + (*head)->ctx.H5_GLUE(PROP_FIELD, _set) = TRUE; \ + } /* end if */ \ + } #endif /* defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_INSTRUMENTED_LIBRARY) */ #ifdef H5_HAVE_PARALLEL /* Macro for the duplicated code to test and set properties for a property list */ -#define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ - if((*head)->ctx.H5_GLUE(PROP_FIELD,_set)) { \ - /* Retrieve the dataset transfer property list */ \ - H5CX_RETRIEVE_PLIST(dxpl, NULL) \ - \ - /* Set the property */ \ - if(H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property") \ - } /* end if */ +#define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ + if ((*head)->ctx.H5_GLUE(PROP_FIELD, _set)) { \ + /* Retrieve the dataset transfer property list */ \ + H5CX_RETRIEVE_PLIST(dxpl, NULL) \ + \ + /* Set the property */ \ + if (H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting data xfer property") \ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - /******************/ /* Local Typedefs */ /******************/ @@ -180,137 +177,163 @@ */ typedef struct H5CX_t { /* DXPL */ - hid_t dxpl_id; /* DXPL ID for API operation */ - H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ + hid_t dxpl_id; /* DXPL ID for API operation */ + H5P_genplist_t *dxpl; /* Dataset Transfer Property List */ /* LCPL */ - hid_t lcpl_id; /* LCPL ID for API operation */ - H5P_genplist_t *lcpl; /* Link Creation Property List */ + hid_t lcpl_id; /* LCPL ID for API operation */ + H5P_genplist_t *lcpl; /* Link Creation Property List */ /* LAPL */ - hid_t lapl_id; /* LAPL ID for API operation */ - H5P_genplist_t *lapl; /* Link Access Property List */ + hid_t lapl_id; /* LAPL ID for API operation */ + H5P_genplist_t *lapl; /* Link Access Property List */ /* DCPL */ - hid_t dcpl_id; /* DCPL ID for API operation */ - H5P_genplist_t *dcpl; /* Dataset Creation Property List */ + hid_t dcpl_id; /* DCPL ID for API operation */ + H5P_genplist_t *dcpl; /* Dataset Creation Property List */ /* DAPL */ - hid_t dapl_id; /* DAPL ID for API operation */ - H5P_genplist_t *dapl; /* Dataset Access Property List */ + hid_t dapl_id; /* DAPL ID for API operation */ + H5P_genplist_t *dapl; /* Dataset Access Property List */ /* FAPL */ - hid_t fapl_id; /* FAPL ID for API operation */ - H5P_genplist_t *fapl; /* File Access Property List */ + hid_t fapl_id; /* FAPL ID for API operation */ + H5P_genplist_t *fapl; /* File Access Property List */ /* Internal: Object tagging info */ - haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ + haddr_t tag; /* Current object's tag (ohdr chunk #0 address) */ /* Internal: Metadata cache info */ - H5AC_ring_t ring; /* Current metadata cache ring for entries */ + H5AC_ring_t ring; /* Current metadata cache ring for entries */ #ifdef H5_HAVE_PARALLEL /* Internal: Parallel I/O settings */ - hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ - MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ - MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ - hbool_t mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ - hbool_t rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ -#endif /* H5_HAVE_PARALLEL */ + hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ + MPI_Datatype btype; /* MPI datatype for buffer, when using collective I/O */ + MPI_Datatype ftype; /* MPI datatype for file, when using collective I/O */ + hbool_t mpi_file_flushing; /* Whether an MPI-opened file is being flushed */ + hbool_t rank0_bcast; /* Whether a dataset meets read-with-rank0-and-bcast requirements */ +#endif /* H5_HAVE_PARALLEL */ /* 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) */ - hbool_t tconv_buf_valid; /* Whether temporary conversion buffer is valid */ - 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 */ - double btree_split_ratio[3]; /* B-tree split ratios */ - hbool_t btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ - size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ - hbool_t vec_size_valid; /* Whether hyperslab vector is valid */ + 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) */ + hbool_t tconv_buf_valid; /* Whether temporary conversion buffer is valid */ + 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 */ + double btree_split_ratio[3]; /* B-tree split ratios */ + hbool_t btree_split_ratio_valid; /* Whether B-tree split ratios are valid */ + size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ + hbool_t vec_size_valid; /* Whether hyperslab vector is valid */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ - hbool_t io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ - H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ - hbool_t mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ - 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) */ - 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 */ -#endif /* H5_HAVE_PARALLEL */ - H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ - 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) */ - 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 */ - H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ - hbool_t dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ + hbool_t io_xfer_mode_valid; /* Whether parallel transfer mode is valid */ + H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with + this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ + hbool_t mpio_coll_opt_valid; /* Whether parallel transfer option is valid */ + 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) */ + 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 */ +#endif /* H5_HAVE_PARALLEL */ + H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ + 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) */ + 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 */ + H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ + hbool_t dt_conv_cb_valid; /* Whether datatype conversion struct is valid */ /* Return-only DXPL properties to return to application */ #ifdef H5_HAVE_PARALLEL - H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ + H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt; /* Chunk optimization mode used for parallel I/O + (H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME) */ hbool_t mpio_actual_chunk_opt_set; /* Whether chunk optimization mode used for parallel I/O is set */ - H5D_mpio_actual_io_mode_t mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ - hbool_t mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ - uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ - hbool_t mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ - hbool_t mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ - uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ - hbool_t mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ + H5D_mpio_actual_io_mode_t + mpio_actual_io_mode; /* Actual I/O mode used for parallel I/O (H5D_MPIO_ACTUAL_IO_MODE_NAME) */ + hbool_t mpio_actual_io_mode_set; /* Whether actual I/O mode used for parallel I/O is set */ + uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O + (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ + hbool_t mpio_local_no_coll_cause_set; /* Whether local reason for breaking collective I/O is set */ + hbool_t mpio_local_no_coll_cause_valid; /* Whether local reason for breaking collective I/O is valid */ + uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O + (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ + hbool_t mpio_global_no_coll_cause_set; /* Whether global reason for breaking collective I/O is set */ hbool_t mpio_global_no_coll_cause_valid; /* Whether global reason for breaking collective I/O is valid */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ - hbool_t mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ - int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ - hbool_t mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ - int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ - hbool_t mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value is set */ - int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ - hbool_t mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" value is set */ - int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ - hbool_t mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" value is set */ - int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ - hbool_t mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ - hbool_t mpio_coll_rank0_bcast; /* Instrumented "collective chunk multi ratio ind" value (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ - hbool_t mpio_coll_rank0_bcast_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ -#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ -#endif /* H5_HAVE_PARALLEL */ + int mpio_coll_chunk_link_hard; /* Instrumented "collective chunk link hard" value + (H5D_XFER_COLL_CHUNK_LINK_HARD_NAME) */ + hbool_t + mpio_coll_chunk_link_hard_set; /* Whether instrumented "collective chunk link hard" value is set */ + int mpio_coll_chunk_multi_hard; /* Instrumented "collective chunk multi hard" value + (H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME) */ + hbool_t + mpio_coll_chunk_multi_hard_set; /* Whether instrumented "collective chunk multi hard" value is set */ + int mpio_coll_chunk_link_num_true; /* Instrumented "collective chunk link num true" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME) */ + hbool_t mpio_coll_chunk_link_num_true_set; /* Whether instrumented "collective chunk link num true" value + is set */ + int mpio_coll_chunk_link_num_false; /* Instrumented "collective chunk link num false" value + (H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME) */ + hbool_t mpio_coll_chunk_link_num_false_set; /* Whether instrumented "collective chunk link num false" + value is set */ + int mpio_coll_chunk_multi_ratio_coll; /* Instrumented "collective chunk multi ratio coll" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME) */ + hbool_t mpio_coll_chunk_multi_ratio_coll_set; /* Whether instrumented "collective chunk multi ratio coll" + value is set */ + int mpio_coll_chunk_multi_ratio_ind; /* Instrumented "collective chunk multi ratio ind" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ + hbool_t mpio_coll_chunk_multi_ratio_ind_set; /* Whether instrumented "collective chunk multi ratio ind" + value is set */ + hbool_t mpio_coll_rank0_bcast; /* Instrumented "collective chunk multi ratio ind" value + (H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME) */ + hbool_t + mpio_coll_rank0_bcast_set; /* Whether instrumented "collective chunk multi ratio ind" value is set */ +#endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ +#endif /* H5_HAVE_PARALLEL */ /* Cached LCPL properties */ - H5T_cset_t encoding; /* Link name character encoding */ - hbool_t encoding_valid; /* Whether link name character encoding is valid */ - unsigned intermediate_group; /* Whether to create intermediate groups */ - hbool_t intermediate_group_valid; /* Whether create intermediate group flag is valid */ + H5T_cset_t encoding; /* Link name character encoding */ + hbool_t encoding_valid; /* Whether link name character encoding is valid */ + unsigned intermediate_group; /* Whether to create intermediate groups */ + hbool_t intermediate_group_valid; /* Whether create intermediate group flag is valid */ /* Cached LAPL properties */ - size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ - hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ + size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ + hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ /* Cached DCPL properties */ - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - uint8_t ohdr_flags; /* Object header flags */ - hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + uint8_t ohdr_flags; /* Object header flags */ + hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ /* Cached DAPL properties */ - const char *extfile_prefix; /* Prefix for external file */ - hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */ - const char *vds_prefix; /* Prefix for VDS */ - hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */ + const char *extfile_prefix; /* Prefix for external file */ + hbool_t extfile_prefix_valid; /* Whether the prefix for external file is valid */ + const char *vds_prefix; /* Prefix for VDS */ + hbool_t vds_prefix_valid; /* Whether the prefix for VDS is valid */ /* Cached FAPL properties */ - H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ - hbool_t low_bound_valid; /* Whether low_bound property is valid */ - H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ - hbool_t high_bound_valid; /* Whether high_bound property is valid */ + H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ + hbool_t low_bound_valid; /* Whether low_bound property is valid */ + H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ + hbool_t high_bound_valid; /* Whether high_bound property is valid */ + + /* 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 */ + hbool_t vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ } H5CX_t; /* Typedef for nodes on the API context stack */ @@ -320,8 +343,8 @@ typedef struct H5CX_t { * in H5CX__push_common(). */ typedef struct H5CX_node_t { - H5CX_t ctx; /* Context for current API call */ - struct H5CX_node_t *next; /* Pointer to previous context, on stack */ + H5CX_t ctx; /* Context for current API call */ + struct H5CX_node_t *next; /* Pointer to previous context, on stack */ } H5CX_node_t; /* Typedef for cached default dataset transfer property list information */ @@ -332,46 +355,50 @@ typedef struct H5CX_node_t { * up the property in the DXPL. */ 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) */ + 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) */ 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) */ + 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) */ #ifdef H5_HAVE_PARALLEL - H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ - H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ - uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ - uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O (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_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) */ - 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) */ + H5FD_mpio_xfer_t io_xfer_mode; /* Parallel transfer mode for this request (H5D_XFER_IO_XFER_MODE_NAME) */ + H5FD_mpio_collective_opt_t mpio_coll_opt; /* Parallel transfer with independent IO or collective IO with + this mode (H5D_XFER_MPIO_COLLECTIVE_OPT_NAME) */ + uint32_t mpio_local_no_coll_cause; /* Local reason for breaking collective I/O + (H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME) */ + uint32_t mpio_global_no_coll_cause; /* Global reason for breaking collective I/O + (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_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) */ + 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; /* Typedef for cached default link creation property list information */ /* (Same as the cached DXPL struct, above, except for the default LCPL) */ typedef struct H5CX_lcpl_cache_t { - H5T_cset_t encoding; /* Link name character encoding */ - unsigned intermediate_group; /* Whether to create intermediate groups */ + H5T_cset_t encoding; /* Link name character encoding */ + unsigned intermediate_group; /* Whether to create intermediate groups */ } H5CX_lcpl_cache_t; /* Typedef for cached default link access property list information */ /* (Same as the cached DXPL struct, above, except for the default LAPL) */ typedef struct H5CX_lapl_cache_t { - size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ + size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ } H5CX_lapl_cache_t; /* Typedef for cached default dataset creation property list information */ /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - uint8_t ohdr_flags; /* Object header flags */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + uint8_t ohdr_flags; /* Object header flags */ } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -384,8 +411,8 @@ typedef struct H5CX_dapl_cache_t { /* Typedef for cached default file access property list information */ /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_fapl_cache_t { - H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ - H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ + H5F_libver_t low_bound; /* low_bound property for H5Pset_libver_bounds() */ + H5F_libver_t high_bound; /* high_bound property for H5Pset_libver_bounds */ } H5CX_fapl_cache_t; /********************/ @@ -394,10 +421,9 @@ typedef struct H5CX_fapl_cache_t { #ifdef H5_HAVE_THREADSAFE static H5CX_node_t **H5CX__get_context(void); #endif /* H5_HAVE_THREADSAFE */ -static void H5CX__push_common(H5CX_node_t *cnode); +static void H5CX__push_common(H5CX_node_t *cnode); static H5CX_node_t *H5CX__pop_common(void); - /*********************/ /* Package Variables */ /*********************/ @@ -405,14 +431,13 @@ static H5CX_node_t *H5CX__pop_common(void); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*******************/ /* Local Variables */ /*******************/ #ifndef H5_HAVE_THREADSAFE -static H5CX_node_t *H5CX_head_g = NULL; /* Pointer to head of context stack */ -#endif /* H5_HAVE_THREADSAFE */ +static H5CX_node_t *H5CX_head_g = NULL; /* Pointer to head of context stack */ +#endif /* H5_HAVE_THREADSAFE */ /* Define a "default" dataset transfer property list cache structure to use for default DXPLs */ static H5CX_dxpl_cache_t H5CX_def_dxpl_cache; @@ -435,8 +460,9 @@ static H5CX_fapl_cache_t H5CX_def_fapl_cache; /* Declare a static free list to manage H5CX_node_t structs */ H5FL_DEFINE_STATIC(H5CX_node_t); +/* Declare a static free list to manage H5CX_state_t structs */ +H5FL_DEFINE_STATIC(H5CX_state_t); - /*-------------------------------------------------------------------------- NAME H5CX__init_package -- Initialize interface-specific information @@ -450,13 +476,13 @@ DESCRIPTION herr_t H5CX__init_package(void) { - H5P_genplist_t *dx_plist; /* Data transfer property list */ - H5P_genplist_t *lc_plist; /* Link creation property list */ - H5P_genplist_t *la_plist; /* Link access property list */ - H5P_genplist_t *dc_plist; /* Dataset creation property list */ - H5P_genplist_t *da_plist; /* Dataset access property list */ - H5P_genplist_t *fa_plist; /* File access property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dx_plist; /* Data transfer property list */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5P_genplist_t *la_plist; /* Link access property list */ + H5P_genplist_t *dc_plist; /* Dataset creation property list */ + H5P_genplist_t *da_plist; /* Dataset access property list */ + H5P_genplist_t *fa_plist; /* File access property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -466,80 +492,82 @@ H5CX__init_package(void) /* Get the default DXPL cache information */ /* Get the default dataset transfer property list */ - if(NULL == (dx_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) + if (NULL == (dx_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get B-tree split ratios */ - if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &H5CX_def_dxpl_cache.btree_split_ratio) < 0) + if (H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &H5CX_def_dxpl_cache.btree_split_ratio) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") /* Get maximum temporary buffer size value */ - if(H5P_get(dx_plist, H5D_XFER_MAX_TEMP_BUF_NAME, &H5CX_def_dxpl_cache.max_temp_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_MAX_TEMP_BUF_NAME, &H5CX_def_dxpl_cache.max_temp_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve maximum temporary buffer size") /* Get temporary buffer pointer */ - if(H5P_get(dx_plist, H5D_XFER_TCONV_BUF_NAME, &H5CX_def_dxpl_cache.tconv_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_TCONV_BUF_NAME, &H5CX_def_dxpl_cache.tconv_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve temporary buffer pointer") /* Get background buffer pointer */ - if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_NAME, &H5CX_def_dxpl_cache.bkgr_buf) < 0) + if (H5P_get(dx_plist, H5D_XFER_BKGR_BUF_NAME, &H5CX_def_dxpl_cache.bkgr_buf) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve background buffer pointer") /* Get background buffer type */ - if(H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &H5CX_def_dxpl_cache.bkgr_buf_type) < 0) + if (H5P_get(dx_plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &H5CX_def_dxpl_cache.bkgr_buf_type) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve background buffer type") /* Get I/O vector size */ - if(H5P_get(dx_plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &H5CX_def_dxpl_cache.vec_size) < 0) + if (H5P_get(dx_plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &H5CX_def_dxpl_cache.vec_size) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve I/O vector size") #ifdef H5_HAVE_PARALLEL /* Collect Parallel I/O information for possible later use */ - if(H5P_get(dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &H5CX_def_dxpl_cache.io_xfer_mode) < 0) + if (H5P_get(dx_plist, H5D_XFER_IO_XFER_MODE_NAME, &H5CX_def_dxpl_cache.io_xfer_mode) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve parallel transfer method") - if(H5P_get(dx_plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &H5CX_def_dxpl_cache.mpio_coll_opt) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &H5CX_def_dxpl_cache.mpio_coll_opt) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve collective transfer option") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_mode) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_mode) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization option") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_num) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_num) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization threshold") - if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_ratio) < 0) + if (H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &H5CX_def_dxpl_cache.mpio_chunk_opt_ratio) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve chunk optimization ratio") /* Get the local & global reasons for breaking collective I/O values */ - if(H5P_get(dx_plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, &H5CX_def_dxpl_cache.mpio_local_no_coll_cause) < 0) + if (H5P_get(dx_plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, + &H5CX_def_dxpl_cache.mpio_local_no_coll_cause) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve local cause for breaking collective I/O") - if(H5P_get(dx_plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, &H5CX_def_dxpl_cache.mpio_global_no_coll_cause) < 0) + if (H5P_get(dx_plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + &H5CX_def_dxpl_cache.mpio_global_no_coll_cause) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve global cause for breaking collective I/O") #endif /* H5_HAVE_PARALLEL */ /* Get error detection properties */ - if(H5P_get(dx_plist, H5D_XFER_EDC_NAME, &H5CX_def_dxpl_cache.err_detect) < 0) + if (H5P_get(dx_plist, H5D_XFER_EDC_NAME, &H5CX_def_dxpl_cache.err_detect) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve error detection info") /* Get filter callback function */ - if(H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &H5CX_def_dxpl_cache.filter_cb) < 0) + if (H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &H5CX_def_dxpl_cache.filter_cb) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve filter callback function") /* Look at the data transform property */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX terminate routine. -QAK) */ - if(H5P_peek(dx_plist, H5D_XFER_XFORM_NAME, &H5CX_def_dxpl_cache.data_transform) < 0) + if (H5P_peek(dx_plist, H5D_XFER_XFORM_NAME, &H5CX_def_dxpl_cache.data_transform) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve data transform info") /* Get VL datatype alloc info */ - if(H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_func) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_func) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_info) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.alloc_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_FREE_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_func) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_FREE_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_func) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get(dx_plist, H5D_XFER_VLEN_FREE_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_info) < 0) + if (H5P_get(dx_plist, H5D_XFER_VLEN_FREE_INFO_NAME, &H5CX_def_dxpl_cache.vl_alloc_info.free_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") /* Get datatype conversion struct */ - if(H5P_get(dx_plist, H5D_XFER_CONV_CB_NAME, &H5CX_def_dxpl_cache.dt_conv_cb) < 0) + if (H5P_get(dx_plist, H5D_XFER_CONV_CB_NAME, &H5CX_def_dxpl_cache.dt_conv_cb) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve datatype conversion exception callback") /* Reset the "default LCPL cache" information */ @@ -548,15 +576,15 @@ H5CX__init_package(void) /* Get the default LCPL cache information */ /* Get the default link creation property list */ - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_CREATE_DEFAULT))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_CREATE_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get link name character encoding */ - if(H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &H5CX_def_lcpl_cache.encoding) < 0) + if (H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &H5CX_def_lcpl_cache.encoding) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve link name encoding") /* Get flag whether to create intermediate groups */ - if(H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &H5CX_def_lcpl_cache.intermediate_group) < 0) + if (H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &H5CX_def_lcpl_cache.intermediate_group) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve intermediate group creation flag") /* Reset the "default LAPL cache" information */ @@ -565,11 +593,11 @@ H5CX__init_package(void) /* Get the default LAPL cache information */ /* Get the default link access property list */ - if(NULL == (la_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_ACCESS_DEFAULT))) + if (NULL == (la_plist = (H5P_genplist_t *)H5I_object(H5P_LINK_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a link access property list") /* Get number of soft / UD links to traverse */ - if(H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0) + if (H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve number of soft / UD links to traverse") /* Reset the "default DCPL cache" information */ @@ -578,15 +606,15 @@ H5CX__init_package(void) /* Get the default DCPL cache information */ /* Get the default dataset creation property list */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_CREATE_DEFAULT))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_CREATE_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get flag to indicate whether to minimize dataset object header */ - if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) + if (H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") /* Get object header flags */ - if(H5P_get(dc_plist, H5O_CRT_OHDR_FLAGS_NAME, &H5CX_def_dcpl_cache.ohdr_flags) < 0) + if (H5P_get(dc_plist, H5O_CRT_OHDR_FLAGS_NAME, &H5CX_def_dcpl_cache.ohdr_flags) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve object header flags") /* Reset the "default DAPL cache" information */ @@ -595,15 +623,15 @@ H5CX__init_package(void) /* Get the default DAPL cache information */ /* Get the default dataset access property list */ - if(NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) + if (NULL == (da_plist = (H5P_genplist_t *)H5I_object(H5P_DATASET_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get the prefix for the external file */ - if(H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) + if (H5P_peek(da_plist, H5D_ACS_EFILE_PREFIX_NAME, &H5CX_def_dapl_cache.extfile_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for external file") /* Get the prefix for the VDS file */ - if(H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) + if (H5P_peek(da_plist, H5D_ACS_VDS_PREFIX_NAME, &H5CX_def_dapl_cache.vds_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve prefix for VDS") /* Reset the "default FAPL cache" information */ @@ -612,21 +640,20 @@ H5CX__init_package(void) /* Get the default FAPL cache information */ /* Get the default file access property list */ - if(NULL == (fa_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + if (NULL == (fa_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a dataset create property list") /* Get low_bound */ - if(H5P_get(fa_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &H5CX_def_fapl_cache.low_bound) < 0) + if (H5P_get(fa_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &H5CX_def_fapl_cache.low_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - if(H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) + if (H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__init_package() */ - /*------------------------------------------------------------------------- * Function: H5CX_term_package * @@ -646,8 +673,8 @@ H5CX_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - H5CX_node_t *cnode; /* Context node */ + if (H5_PKG_INIT_VAR) { + H5CX_node_t *cnode; /* Context node */ /* Pop the top context node from the stack */ /* (Can't check for errors, as rest of library is shut down) */ @@ -667,7 +694,6 @@ H5CX_term_package(void) FUNC_LEAVE_NOAPI(0) } /* end H5CX_term_package() */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5CX__get_context @@ -692,7 +718,7 @@ H5CX__get_context(void) ctx = (H5CX_node_t **)H5TS_get_thread_local_value(H5TS_apictx_key_g); - if(!ctx) { + if (!ctx) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ @@ -718,9 +744,8 @@ H5CX__get_context(void) /* Set return value */ FUNC_LEAVE_NOAPI(ctx) } /* end H5CX__get_context() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5CX__push_common * @@ -736,7 +761,8 @@ H5CX__get_context(void) static void H5CX__push_common(H5CX_node_t *cnode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_STATIC_NOERR @@ -750,17 +776,16 @@ H5CX__push_common(H5CX_node_t *cnode) cnode->ctx.lcpl_id = H5P_LINK_CREATE_DEFAULT; cnode->ctx.lapl_id = H5P_LINK_ACCESS_DEFAULT; cnode->ctx.fapl_id = H5P_FILE_ACCESS_DEFAULT; - cnode->ctx.tag = H5AC__INVALID_TAG; - cnode->ctx.ring = H5AC_RING_USER; + cnode->ctx.tag = H5AC__INVALID_TAG; + cnode->ctx.ring = H5AC_RING_USER; /* Push context node onto stack */ cnode->next = *head; - *head = cnode; + *head = cnode; FUNC_LEAVE_NOAPI_VOID } /* end H5CX__push_common() */ - /*------------------------------------------------------------------------- * Function: H5CX_push * @@ -776,13 +801,13 @@ H5CX__push_common(H5CX_node_t *cnode) herr_t H5CX_push(void) { - H5CX_node_t *cnode = NULL; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t *cnode = NULL; /* Context node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Allocate & clear API context node */ - if(NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) + if (NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new struct") /* Set context info */ @@ -792,7 +817,6 @@ H5CX_push(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_push() */ - /*------------------------------------------------------------------------- * Function: H5CX_push_special * @@ -810,7 +834,7 @@ H5CX_push(void) void H5CX_push_special(void) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t *cnode; /* Context node */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -824,7 +848,267 @@ H5CX_push_special(void) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_push_special() */ - +/*------------------------------------------------------------------------- + * Function: H5CX_retrieve_state + * + * Purpose: Retrieve the state of an API context, for later resumption. + * + * Note: This routine _only_ tracks the state of API context information + * set before the VOL callback is invoked, not values that are + * set internal to the library. It's main purpose is to provide + * API context state to VOL connectors. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 8, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_retrieve_state(H5CX_state_t **api_state) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + HDassert(api_state); + + /* Allocate & clear API context state */ + if (NULL == (*api_state = H5FL_CALLOC(H5CX_state_t))) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new API context state") + + /* Check for non-default DCPL */ + if (H5P_DATASET_CREATE_DEFAULT != (*head)->ctx.dcpl_id) { + /* Retrieve the DCPL property list */ + H5CX_RETRIEVE_PLIST(dcpl, FAIL) + + /* Copy the DCPL ID */ + if (((*api_state)->dcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dcpl, FALSE)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") + } /* end if */ + else + (*api_state)->dcpl_id = H5P_DATASET_CREATE_DEFAULT; + + /* Check for non-default DXPL */ + if (H5P_DATASET_XFER_DEFAULT != (*head)->ctx.dxpl_id) { + /* Retrieve the DXPL property list */ + H5CX_RETRIEVE_PLIST(dxpl, FAIL) + + /* Copy the DXPL ID */ + if (((*api_state)->dxpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.dxpl, FALSE)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") + } /* end if */ + else + (*api_state)->dxpl_id = H5P_DATASET_XFER_DEFAULT; + + /* Check for non-default LAPL */ + if (H5P_LINK_ACCESS_DEFAULT != (*head)->ctx.lapl_id) { + /* Retrieve the LAPL property list */ + H5CX_RETRIEVE_PLIST(lapl, FAIL) + + /* Copy the LAPL ID */ + if (((*api_state)->lapl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lapl, FALSE)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") + } /* end if */ + else + (*api_state)->lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Check for non-default LCPL */ + if (H5P_LINK_CREATE_DEFAULT != (*head)->ctx.lcpl_id) { + /* Retrieve the LCPL property list */ + H5CX_RETRIEVE_PLIST(lcpl, FAIL) + + /* Copy the LCPL ID */ + if (((*api_state)->lcpl_id = H5P_copy_plist((H5P_genplist_t *)(*head)->ctx.lcpl, FALSE)) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "can't copy property list") + } /* end if */ + else + (*api_state)->lcpl_id = H5P_LINK_CREATE_DEFAULT; + + /* Keep a reference to the current VOL wrapping context */ + (*api_state)->vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx; + if (NULL != (*api_state)->vol_wrap_ctx) { + HDassert((*head)->ctx.vol_wrap_ctx_valid); + if (H5VL_inc_vol_wrapper((*api_state)->vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "can't increment refcount on VOL wrapping context") + } /* end if */ + + /* Keep a copy of the VOL connector property, if there is one */ + if ((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector_id > 0) { + /* Get the connector property */ + H5MM_memcpy(&(*api_state)->vol_connector_prop, &(*head)->ctx.vol_connector_prop, + sizeof(H5VL_connector_prop_t)); + + /* Check for actual VOL connector property */ + if ((*api_state)->vol_connector_prop.connector_id) { + /* 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 */ + + /* Retrieve the connector for the ID */ + if (NULL == + (connector = (H5VL_class_t *)H5I_object((*api_state)->vol_connector_prop.connector_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if (H5VL_copy_connector_info(connector, &new_connector_info, + (*api_state)->vol_connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "connector info copy failed") + (*api_state)->vol_connector_prop.connector_info = new_connector_info; + } /* end if */ + + /* Increment the refcount on the connector ID */ + if (H5I_inc_ref((*api_state)->vol_connector_prop.connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") + } /* end if */ + } /* end if */ + +#ifdef H5_HAVE_PARALLEL + /* Save parallel I/O settings */ + (*api_state)->coll_metadata_read = (*head)->ctx.coll_metadata_read; +#endif /* H5_HAVE_PARALLEL */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_retrieve_state() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_restore_state + * + * Purpose: Restore an API context, from a previously retrieved state. + * + * Note: This routine _only_ resets the state of API context information + * set before the VOL callback is invoked, not values that are + * set internal to the library. It's main purpose is to restore + * API context state from VOL connectors. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 9, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_restore_state(const H5CX_state_t *api_state) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(head && *head); + HDassert(api_state); + + /* Restore the DCPL info */ + (*head)->ctx.dcpl_id = api_state->dcpl_id; + (*head)->ctx.dcpl = NULL; + + /* Restore the DXPL info */ + (*head)->ctx.dxpl_id = api_state->dxpl_id; + (*head)->ctx.dxpl = NULL; + + /* Restore the LAPL info */ + (*head)->ctx.lapl_id = api_state->lapl_id; + (*head)->ctx.lapl = NULL; + + /* Restore the LCPL info */ + (*head)->ctx.lcpl_id = api_state->lcpl_id; + (*head)->ctx.lcpl = NULL; + + /* Restore the VOL wrapper context */ + (*head)->ctx.vol_wrap_ctx = api_state->vol_wrap_ctx; + if (NULL != (*head)->ctx.vol_wrap_ctx) + (*head)->ctx.vol_wrap_ctx_valid = TRUE; + + /* Restore the VOL connector info */ + if (api_state->vol_connector_prop.connector_id) { + H5MM_memcpy(&(*head)->ctx.vol_connector_prop, &api_state->vol_connector_prop, + sizeof(H5VL_connector_prop_t)); + (*head)->ctx.vol_connector_prop_valid = TRUE; + } /* end if */ + +#ifdef H5_HAVE_PARALLEL + /* Restore parallel I/O settings */ + (*head)->ctx.coll_metadata_read = api_state->coll_metadata_read; +#endif /* H5_HAVE_PARALLEL */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5CX_restore_state() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_free_state + * + * Purpose: Free a previously retrievedAPI context state + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 9, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_free_state(H5CX_state_t *api_state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(api_state); + + /* Release the DCPL */ + if (api_state->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if (H5I_dec_ref(api_state->dcpl_id) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DCPL") + + /* Release the DXPL */ + if (api_state->dxpl_id != H5P_DATASET_XFER_DEFAULT) + if (H5I_dec_ref(api_state->dxpl_id) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on DXPL") + + /* Release the LAPL */ + if (api_state->lapl_id != H5P_LINK_ACCESS_DEFAULT) + if (H5I_dec_ref(api_state->lapl_id) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LAPL") + + /* Release the LCPL */ + if (api_state->lcpl_id != H5P_LINK_CREATE_DEFAULT) + if (H5I_dec_ref(api_state->lcpl_id) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on LCPL") + + /* Release the VOL wrapper context */ + if (api_state->vol_wrap_ctx) + if (H5VL_dec_vol_wrapper(api_state->vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on VOL wrapping context") + + /* Release the VOL connector property, if it was set */ + if (api_state->vol_connector_prop.connector_id) { + /* Clean up any VOL connector info */ + if (api_state->vol_connector_prop.connector_info) + if (H5VL_free_connector_info(api_state->vol_connector_prop.connector_id, + api_state->vol_connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + /* Decrement connector ID */ + if (H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0) + HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID") + } /* end if */ + + /* Free the state */ + api_state = H5FL_FREE(H5CX_state_t, api_state); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_free_state() */ + /*------------------------------------------------------------------------- * Function: H5CX_is_def_dxpl * @@ -840,7 +1124,8 @@ H5CX_push_special(void) hbool_t H5CX_is_def_dxpl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -850,7 +1135,6 @@ H5CX_is_def_dxpl(void) FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT); } /* end H5CX_is_def_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_dxpl * @@ -866,7 +1150,8 @@ H5CX_is_def_dxpl(void) void H5CX_set_dxpl(hid_t dxpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -879,7 +1164,6 @@ H5CX_set_dxpl(hid_t dxpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_dcpl * @@ -895,7 +1179,8 @@ H5CX_set_dxpl(hid_t dxpl_id) void H5CX_set_dcpl(hid_t dcpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -908,7 +1193,6 @@ H5CX_set_dcpl(hid_t dcpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_dcpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_libver_bounds * @@ -925,8 +1209,9 @@ H5CX_set_dcpl(hid_t dcpl_id) herr_t H5CX_set_libver_bounds(H5F_t *f) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -934,18 +1219,17 @@ H5CX_set_libver_bounds(H5F_t *f) HDassert(head && *head); /* Set the API context value */ - (*head)->ctx.low_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_LOW_BOUND(f); + (*head)->ctx.low_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_LOW_BOUND(f); (*head)->ctx.high_bound = (f == NULL) ? H5F_LIBVER_LATEST : H5F_HIGH_BOUND(f); /* Mark the values as valid */ - (*head)->ctx.low_bound_valid = TRUE; + (*head)->ctx.low_bound_valid = TRUE; (*head)->ctx.high_bound_valid = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_lcpl * @@ -961,7 +1245,8 @@ H5CX_set_libver_bounds(H5F_t *f) void H5CX_set_lcpl(hid_t lcpl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -974,7 +1259,6 @@ H5CX_set_lcpl(hid_t lcpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_lcpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_lapl * @@ -990,7 +1274,8 @@ H5CX_set_lcpl(hid_t lcpl_id) void H5CX_set_lapl(hid_t lapl_id) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1003,7 +1288,6 @@ H5CX_set_lapl(hid_t lapl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_lapl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_apl * @@ -1019,18 +1303,20 @@ H5CX_set_lapl(hid_t lapl_id) */ herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, - hid_t + hid_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - loc_id, hbool_t + loc_id, + hbool_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - is_collective) + is_collective) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1040,35 +1326,38 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, HDassert(head && *head); /* Set access plist to the default property list of the appropriate class if it's the generic default */ - if(H5P_DEFAULT == *acspl_id) + if (H5P_DEFAULT == *acspl_id) *acspl_id = *libclass->def_plist_id; else { - htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property list */ - htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property list */ - htri_t is_fapl; /* Whether the access property list is (or is derived from) a file access property list */ + htri_t is_lapl; /* Whether the access property list is (or is derived from) a link access property + list */ + htri_t is_dapl; /* Whether the access property list is (or is derived from) a dataset access property + list */ + htri_t is_fapl; /* Whether the access property list is (or is derived from) a file access property + list */ #ifdef H5CX_DEBUG /* Sanity check the access property list class */ - if(TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) + if (TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not the required access property list") #endif /* H5CX_DEBUG*/ /* Check for link access property and set API context if so */ - if((is_lapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_LACC->pclass)) < 0) + if ((is_lapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_LACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for link access class") - else if(is_lapl) + else if (is_lapl) (*head)->ctx.lapl_id = *acspl_id; /* Check for dataset access property and set API context if so */ - if((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) + if ((is_dapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_DACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for dataset access class") - else if(is_dapl) + else if (is_dapl) (*head)->ctx.dapl_id = *acspl_id; /* Check for file access property and set API context if so */ - if((is_fapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_FACC->pclass)) < 0) + if ((is_fapl = H5P_class_isa(*libclass->pclass, *H5P_CLS_FACC->pclass)) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't check for file access class") - else if(is_fapl) + else if (is_fapl) (*head)->ctx.fapl_id = *acspl_id; #ifdef H5_HAVE_PARALLEL @@ -1076,28 +1365,28 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * modify the structural metadata in a file), check if the application * specified a collective metadata read for just this operation. */ - if(!is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - H5P_coll_md_read_flag_t md_coll_read; /* Collective metadata read flag */ + if (!is_collective) { + 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 */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(*acspl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(*acspl_id))) HGOTO_ERROR(H5E_CONTEXT, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the collective metadata read flag */ - if(H5P_peek(plist, H5_COLL_MD_READ_FLAG_NAME, &md_coll_read) < 0) + if (H5P_peek(plist, H5_COLL_MD_READ_FLAG_NAME, &md_coll_read) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "can't get core collective metadata read flag") /* If collective metadata read requested, set collective metadata read flag */ - if(H5P_USER_TRUE == md_coll_read) + if (H5P_USER_TRUE == md_coll_read) is_collective = TRUE; } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - } /* end else */ +#endif /* H5_HAVE_PARALLEL */ + } /* end else */ #ifdef H5_HAVE_PARALLEL /* Check for collective operation */ - if(is_collective) { + if (is_collective) { /* Set collective metadata read flag */ (*head)->ctx.coll_metadata_read = TRUE; @@ -1107,25 +1396,24 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * happens only when the environment variable H5_COLL_BARRIER is set * to non 0. */ - if(H5_coll_api_sanity_check_g) { - MPI_Comm mpi_comm; /* File communicator */ + if (H5_coll_api_sanity_check_g) { + MPI_Comm mpi_comm; /* File communicator */ /* Retrieve the MPI communicator from the loc_id or the fapl_id */ - if(H5F_mpi_retrieve_comm(loc_id, *acspl_id, &mpi_comm) < 0) + if (H5F_mpi_retrieve_comm(loc_id, *acspl_id, &mpi_comm) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_apl() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_loc * @@ -1144,13 +1432,14 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, herr_t H5CX_set_loc(hid_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - loc_id) + loc_id) { #ifdef H5_HAVE_PARALLEL - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1166,28 +1455,95 @@ H5CX_set_loc(hid_t * happens only when the environment variable H5_COLL_BARRIER is set * to non 0. */ - if(H5_coll_api_sanity_check_g) { - MPI_Comm mpi_comm; /* File communicator */ + if (H5_coll_api_sanity_check_g) { + MPI_Comm mpi_comm; /* File communicator */ /* Retrieve the MPI communicator from the loc_id or the fapl_id */ - if(H5F_mpi_retrieve_comm(loc_id, H5P_DEFAULT, &mpi_comm) < 0) + if (H5F_mpi_retrieve_comm(loc_id, H5P_DEFAULT, &mpi_comm) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -#else /* H5_HAVE_PARALLEL */ +#else /* H5_HAVE_PARALLEL */ FUNC_ENTER_NOAPI_NOINIT_NOERR FUNC_LEAVE_NOAPI(SUCCEED) #endif /* H5_HAVE_PARALLEL */ } /* end H5CX_set_loc() */ - +/*------------------------------------------------------------------------- + * Function: H5CX_set_vol_wrap_ctx + * + * Purpose: Sets the VOL object wrapping context for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * October 14, 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vol_wrap_ctx = vol_wrap_ctx; + + /* Mark the value as valid */ + (*head)->ctx.vol_wrap_ctx_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vol_wrap_ctx() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_set_vol_connector_prop + * + * Purpose: Sets the VOL connector ID & info for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 3, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + H5MM_memcpy(&(*head)->ctx.vol_connector_prop, vol_connector_prop, sizeof(H5VL_connector_prop_t)); + + /* Mark the value as valid */ + (*head)->ctx.vol_connector_prop_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vol_connector_prop() */ + /*------------------------------------------------------------------------- * Function: H5CX_get_dxpl * @@ -1203,7 +1559,8 @@ H5CX_set_loc(hid_t hid_t H5CX_get_dxpl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1213,7 +1570,6 @@ H5CX_get_dxpl(void) FUNC_LEAVE_NOAPI((*head)->ctx.dxpl_id) } /* end H5CX_get_dxpl() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_lapl * @@ -1229,7 +1585,8 @@ H5CX_get_dxpl(void) hid_t H5CX_get_lapl(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1239,7 +1596,78 @@ H5CX_get_lapl(void) FUNC_LEAVE_NOAPI((*head)->ctx.lapl_id) } /* end H5CX_get_lapl() */ - +/*------------------------------------------------------------------------- + * Function: H5CX_get_vol_wrap_ctx + * + * Purpose: Retrieves the VOL object wrapping context for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * October 14, 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_wrap_ctx); + HDassert(head && *head); + + /* Check for value that was set */ + if ((*head)->ctx.vol_wrap_ctx_valid) + /* Get the value */ + *vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx; + else + *vol_wrap_ctx = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vol_wrap_ctx() */ + +/*------------------------------------------------------------------------- + * Function: H5CX_get_vol_connector_prop + * + * Purpose: Retrieves the VOL connector ID & info for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * January 3, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) +{ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_connector_prop); + HDassert(head && *head); + + /* Check for value that was set */ + if ((*head)->ctx.vol_connector_prop_valid) + /* Get the value */ + H5MM_memcpy(vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t)); + else + HDmemset(vol_connector_prop, 0, sizeof(H5VL_connector_prop_t)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vol_connector_prop() */ + /*------------------------------------------------------------------------- * Function: H5CX_get_tag * @@ -1255,7 +1683,8 @@ H5CX_get_lapl(void) haddr_t H5CX_get_tag(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1265,7 +1694,6 @@ H5CX_get_tag(void) FUNC_LEAVE_NOAPI((*head)->ctx.tag) } /* end H5CX_get_tag() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ring * @@ -1281,7 +1709,8 @@ H5CX_get_tag(void) H5AC_ring_t H5CX_get_ring(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1292,7 +1721,7 @@ H5CX_get_ring(void) } /* end H5CX_get_ring() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_get_coll_metadata_read * @@ -1308,7 +1737,8 @@ H5CX_get_ring(void) hbool_t H5CX_get_coll_metadata_read(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1318,7 +1748,6 @@ H5CX_get_coll_metadata_read(void) FUNC_LEAVE_NOAPI((*head)->ctx.coll_metadata_read) } /* end H5CX_get_coll_metadata_read() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpi_coll_datatypes * @@ -1336,8 +1765,9 @@ H5CX_get_coll_metadata_read(void) herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1354,7 +1784,6 @@ H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpi_coll_datatypes() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpi_file_flushing * @@ -1370,7 +1799,8 @@ H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype) hbool_t H5CX_get_mpi_file_flushing(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1380,11 +1810,11 @@ H5CX_get_mpi_file_flushing(void) FUNC_LEAVE_NOAPI((*head)->ctx.mpi_file_flushing) } /* end H5CX_get_mpi_file_flushing() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_rank0_bcast * - * Purpose: Retrieves if the dataset meets read-with-rank0-and-bcast requirements for the current API call context. + * Purpose: Retrieves if the dataset meets read-with-rank0-and-bcast requirements for the current API call + *context. * * Return: Non-negative on success / Negative on failure * @@ -1396,7 +1826,8 @@ H5CX_get_mpi_file_flushing(void) hbool_t H5CX_get_mpio_rank0_bcast(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1407,7 +1838,6 @@ H5CX_get_mpio_rank0_bcast(void) } /* end H5CX_get_mpio_rank0_bcast() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_btree_split_ratios * @@ -1423,8 +1853,9 @@ H5CX_get_mpio_rank0_bcast(void) herr_t H5CX_get_btree_split_ratios(double split_ratio[3]) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1433,7 +1864,8 @@ H5CX_get_btree_split_ratios(double split_ratio[3]) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_BTREE_SPLIT_RATIO_NAME, btree_split_ratio) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_BTREE_SPLIT_RATIO_NAME, + btree_split_ratio) /* Get the B-tree split ratio values */ H5MM_memcpy(split_ratio, &(*head)->ctx.btree_split_ratio, sizeof((*head)->ctx.btree_split_ratio)); @@ -1442,7 +1874,6 @@ H5CX_get_btree_split_ratios(double split_ratio[3]) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_btree_split_ratios() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_max_temp_buf * @@ -1458,8 +1889,9 @@ H5CX_get_btree_split_ratios(double split_ratio[3]) herr_t H5CX_get_max_temp_buf(size_t *max_temp_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1477,7 +1909,6 @@ H5CX_get_max_temp_buf(size_t *max_temp_buf) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_max_temp_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_tconv_buf * @@ -1493,8 +1924,9 @@ H5CX_get_max_temp_buf(size_t *max_temp_buf) herr_t H5CX_get_tconv_buf(void **tconv_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1512,7 +1944,6 @@ H5CX_get_tconv_buf(void **tconv_buf) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_tconv_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_bkgr_buf * @@ -1528,8 +1959,9 @@ H5CX_get_tconv_buf(void **tconv_buf) herr_t H5CX_get_bkgr_buf(void **bkgr_buf) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1547,7 +1979,6 @@ H5CX_get_bkgr_buf(void **bkgr_buf) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_bkgr_buf() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_bkgr_buf_type * @@ -1563,8 +1994,9 @@ H5CX_get_bkgr_buf(void **bkgr_buf) herr_t H5CX_get_bkgr_buf_type(H5T_bkg_t *bkgr_buf_type) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1582,7 +2014,6 @@ H5CX_get_bkgr_buf_type(H5T_bkg_t *bkgr_buf_type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_bkgr_buf_type() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vec_size * @@ -1598,8 +2029,9 @@ H5CX_get_bkgr_buf_type(H5T_bkg_t *bkgr_buf_type) herr_t H5CX_get_vec_size(size_t *vec_size) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1618,7 +2050,7 @@ H5CX_get_vec_size(size_t *vec_size) } /* end H5CX_get_vec_size() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_get_io_xfer_mode * @@ -1634,8 +2066,9 @@ H5CX_get_vec_size(size_t *vec_size) herr_t H5CX_get_io_xfer_mode(H5FD_mpio_xfer_t *io_xfer_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1653,7 +2086,6 @@ H5CX_get_io_xfer_mode(H5FD_mpio_xfer_t *io_xfer_mode) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_io_xfer_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_coll_opt * @@ -1669,8 +2101,9 @@ H5CX_get_io_xfer_mode(H5FD_mpio_xfer_t *io_xfer_mode) herr_t H5CX_get_mpio_coll_opt(H5FD_mpio_collective_opt_t *mpio_coll_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1688,7 +2121,6 @@ H5CX_get_mpio_coll_opt(H5FD_mpio_collective_opt_t *mpio_coll_opt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_coll_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_local_no_coll_cause * @@ -1704,8 +2136,9 @@ H5CX_get_mpio_coll_opt(H5FD_mpio_collective_opt_t *mpio_coll_opt) herr_t H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1714,7 +2147,8 @@ H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, mpio_local_no_coll_cause) + H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, + mpio_local_no_coll_cause) /* Get the value */ *mpio_local_no_coll_cause = (*head)->ctx.mpio_local_no_coll_cause; @@ -1723,7 +2157,6 @@ H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_local_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_global_no_coll_cause * @@ -1739,8 +2172,9 @@ H5CX_get_mpio_local_no_coll_cause(uint32_t *mpio_local_no_coll_cause) herr_t H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1749,7 +2183,8 @@ H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, mpio_global_no_coll_cause) + H5CX_RETRIEVE_PROP_VALID_SET(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + mpio_global_no_coll_cause) /* Get the value */ *mpio_global_no_coll_cause = (*head)->ctx.mpio_global_no_coll_cause; @@ -1758,7 +2193,6 @@ H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_global_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_mode * @@ -1774,8 +2208,9 @@ H5CX_get_mpio_global_no_coll_cause(uint32_t *mpio_global_no_coll_cause) herr_t H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1784,7 +2219,8 @@ H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, mpio_chunk_opt_mode) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, + mpio_chunk_opt_mode) /* Get the value */ *mpio_chunk_opt_mode = (*head)->ctx.mpio_chunk_opt_mode; @@ -1793,7 +2229,6 @@ H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_chunk_opt_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_num * @@ -1809,8 +2244,9 @@ H5CX_get_mpio_chunk_opt_mode(H5FD_mpio_chunk_opt_t *mpio_chunk_opt_mode) herr_t H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1819,7 +2255,8 @@ H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, mpio_chunk_opt_num) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, + mpio_chunk_opt_num) /* Get the value */ *mpio_chunk_opt_num = (*head)->ctx.mpio_chunk_opt_num; @@ -1828,7 +2265,6 @@ H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_mpio_chunk_opt_num() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_mpio_chunk_opt_ratio * @@ -1844,8 +2280,9 @@ H5CX_get_mpio_chunk_opt_num(unsigned *mpio_chunk_opt_num) herr_t H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1854,7 +2291,8 @@ H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); - H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, mpio_chunk_opt_ratio) + H5CX_RETRIEVE_PROP_VALID(dxpl, H5P_DATASET_XFER_DEFAULT, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, + mpio_chunk_opt_ratio) /* Get the value */ *mpio_chunk_opt_ratio = (*head)->ctx.mpio_chunk_opt_ratio; @@ -1864,7 +2302,6 @@ H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) } /* end H5CX_get_mpio_chunk_opt_ratio() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_err_detect * @@ -1880,8 +2317,9 @@ H5CX_get_mpio_chunk_opt_ratio(unsigned *mpio_chunk_opt_ratio) herr_t H5CX_get_err_detect(H5Z_EDC_t *err_detect) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1899,7 +2337,6 @@ H5CX_get_err_detect(H5Z_EDC_t *err_detect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_err_detect() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_filter_cb * @@ -1915,8 +2352,9 @@ H5CX_get_err_detect(H5Z_EDC_t *err_detect) herr_t H5CX_get_filter_cb(H5Z_cb_t *filter_cb) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1934,7 +2372,6 @@ H5CX_get_filter_cb(H5Z_cb_t *filter_cb) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_filter_cb() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_data_transform * @@ -1950,8 +2387,9 @@ H5CX_get_filter_cb(H5Z_cb_t *filter_cb) herr_t H5CX_get_data_transform(H5Z_data_xform_t **data_transform) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1961,22 +2399,23 @@ H5CX_get_data_transform(H5Z_data_xform_t **data_transform) HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.data_transform_valid) { + if (!(*head)->ctx.data_transform_valid) { /* Check for default DXPL */ - if((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) + if ((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) (*head)->ctx.data_transform = H5CX_def_dxpl_cache.data_transform; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dxpl) + if (NULL == (*head)->ctx.dxpl) /* Get the dataset transfer property list pointer */ - if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") + if (NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset transfer property list") /* Get data transform info value */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dxpl, H5D_XFER_XFORM_NAME, &(*head)->ctx.data_transform) < 0) + if (H5P_peek((*head)->ctx.dxpl, H5D_XFER_XFORM_NAME, &(*head)->ctx.data_transform) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve data transform info") } /* end else */ @@ -1991,7 +2430,6 @@ H5CX_get_data_transform(H5Z_data_xform_t **data_transform) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vlen_alloc_info * @@ -2007,8 +2445,9 @@ H5CX_get_data_transform(H5Z_data_xform_t **data_transform) herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2018,25 +2457,30 @@ H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) HDassert(H5P_DEFAULT != (*head)->ctx.dxpl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.vl_alloc_info_valid) { + if (!(*head)->ctx.vl_alloc_info_valid) { /* Check for default DXPL */ - if((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) + if ((*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT) (*head)->ctx.vl_alloc_info = H5CX_def_dxpl_cache.vl_alloc_info; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dxpl) + if (NULL == (*head)->ctx.dxpl) /* Get the dataset transfer property list pointer */ - if(NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset transfer property list") + if (NULL == ((*head)->ctx.dxpl = (H5P_genplist_t *)H5I_object((*head)->ctx.dxpl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset transfer property list") /* Get VL datatype alloc info values */ - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_NAME, &(*head)->ctx.vl_alloc_info.alloc_func) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_NAME, &(*head)->ctx.vl_alloc_info.alloc_func) < + 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_INFO_NAME, &(*head)->ctx.vl_alloc_info.alloc_info) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_ALLOC_INFO_NAME, + &(*head)->ctx.vl_alloc_info.alloc_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_NAME, &(*head)->ctx.vl_alloc_info.free_func) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_NAME, &(*head)->ctx.vl_alloc_info.free_func) < + 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") - if(H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_INFO_NAME, &(*head)->ctx.vl_alloc_info.free_info) < 0) + if (H5P_get((*head)->ctx.dxpl, H5D_XFER_VLEN_FREE_INFO_NAME, + &(*head)->ctx.vl_alloc_info.free_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VL datatype alloc info") } /* end else */ @@ -2051,7 +2495,6 @@ H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vlen_alloc_info() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_dt_conv_cb * @@ -2067,8 +2510,9 @@ H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info) herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *dt_conv_cb) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2086,7 +2530,6 @@ H5CX_get_dt_conv_cb(H5T_conv_cb_t *dt_conv_cb) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_dt_conv_cb() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_encoding * @@ -2100,10 +2543,11 @@ H5CX_get_dt_conv_cb(H5T_conv_cb_t *dt_conv_cb) *------------------------------------------------------------------------- */ herr_t -H5CX_get_encoding(H5T_cset_t* encoding) +H5CX_get_encoding(H5T_cset_t *encoding) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2121,7 +2565,6 @@ H5CX_get_encoding(H5T_cset_t* encoding) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_encoding() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_intermediate_group * @@ -2135,10 +2578,11 @@ H5CX_get_encoding(H5T_cset_t* encoding) *------------------------------------------------------------------------- */ herr_t -H5CX_get_intermediate_group(unsigned* crt_intermed_group) +H5CX_get_intermediate_group(unsigned *crt_intermed_group) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2147,7 +2591,8 @@ H5CX_get_intermediate_group(unsigned* crt_intermed_group) HDassert(head && *head); HDassert(H5P_DEFAULT != (*head)->ctx.lcpl_id); - H5CX_RETRIEVE_PROP_VALID(lcpl, H5P_LINK_CREATE_DEFAULT, H5L_CRT_INTERMEDIATE_GROUP_NAME, intermediate_group) + H5CX_RETRIEVE_PROP_VALID(lcpl, H5P_LINK_CREATE_DEFAULT, H5L_CRT_INTERMEDIATE_GROUP_NAME, + intermediate_group) /* Get the value */ *crt_intermed_group = (*head)->ctx.intermediate_group; @@ -2156,7 +2601,6 @@ H5CX_get_intermediate_group(unsigned* crt_intermed_group) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_create_intermediate_group() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_nlinks * @@ -2172,8 +2616,9 @@ H5CX_get_intermediate_group(unsigned* crt_intermed_group) herr_t H5CX_get_nlinks(size_t *nlinks) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2191,81 +2636,81 @@ H5CX_get_nlinks(size_t *nlinks) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_nlinks() */ - /*------------------------------------------------------------------------- - * Function: H5CX_get_dset_min_ohdr_flag + * Function: H5CX_get_libver_bounds * - * Purpose: Retrieves the flag that indicates whether the dataset object - * header should be minimized + * Purpose: Retrieves the low/high bounds for the current API call context. * * Return: Non-negative on success / Negative on failure * - * Programmer: Quincey Koziol - * March 6, 2019 + * Programmer: Vailin Choi + * March 27, 2019 * *------------------------------------------------------------------------- */ herr_t -H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag) +H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - HDassert(dset_min_ohdr_flag); + HDassert(low_bound); + HDassert(high_bound); HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); + HDassert(H5P_DEFAULT != (*head)->ctx.fapl_id); - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, do_min_dset_ohdr) + H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_LOW_BOUND_NAME, low_bound) + H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high_bound) - /* Get the value */ - *dset_min_ohdr_flag = (*head)->ctx.do_min_dset_ohdr; + /* Get the values */ + *low_bound = (*head)->ctx.low_bound; + *high_bound = (*head)->ctx.high_bound; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_dset_min_ohdr_flag() */ +} /* end H5CX_get_libver_bounds() */ - /*------------------------------------------------------------------------- - * Function: H5CX_get_libver_bounds + * Function: H5CX_get_dset_min_ohdr_flag * - * Purpose: Retrieves the low/high bounds for the current API call context. + * Purpose: Retrieves the flag that indicates whether the dataset object + * header should be minimized * * Return: Non-negative on success / Negative on failure * - * Programmer: Vailin Choi - * March 27, 2019 + * Programmer: Quincey Koziol + * March 6, 2019 * *------------------------------------------------------------------------- */ herr_t -H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) +H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - HDassert(low_bound); - HDassert(high_bound); + HDassert(dset_min_ohdr_flag); HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.fapl_id); + HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_LOW_BOUND_NAME, low_bound) - H5CX_RETRIEVE_PROP_VALID(fapl, H5P_FILE_ACCESS_DEFAULT, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high_bound) + H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, + do_min_dset_ohdr) - /* Get the values */ - *low_bound = (*head)->ctx.low_bound; - *high_bound = (*head)->ctx.high_bound; + /* Get the value */ + *dset_min_ohdr_flag = (*head)->ctx.do_min_dset_ohdr; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_libver_bounds() */ +} /* end H5CX_get_dset_min_ohdr_flag() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ext_file_prefix * @@ -2281,8 +2726,9 @@ H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high_bound) herr_t H5CX_get_ext_file_prefix(const char **extfile_prefix) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2292,22 +2738,23 @@ H5CX_get_ext_file_prefix(const char **extfile_prefix) HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.extfile_prefix_valid) { + if (!(*head)->ctx.extfile_prefix_valid) { /* Check for default DAPL */ - if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + if ((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) (*head)->ctx.extfile_prefix = H5CX_def_dapl_cache.extfile_prefix; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dapl) + if (NULL == (*head)->ctx.dapl) /* Get the dataset access property list pointer */ - if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + if (NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset access property list") /* Get the prefix for the external file */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) + if (H5P_peek((*head)->ctx.dapl, H5D_ACS_EFILE_PREFIX_NAME, &(*head)->ctx.extfile_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve external file prefix") } /* end else */ @@ -2322,7 +2769,6 @@ H5CX_get_ext_file_prefix(const char **extfile_prefix) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_ext_file_prefix() */ - /*------------------------------------------------------------------------- * Function: H5CX_get_vds_prefix * @@ -2338,8 +2784,9 @@ H5CX_get_ext_file_prefix(const char **extfile_prefix) herr_t H5CX_get_vds_prefix(const char **vds_prefix) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2349,22 +2796,23 @@ H5CX_get_vds_prefix(const char **vds_prefix) HDassert(H5P_DEFAULT != (*head)->ctx.dapl_id); /* Check if the value has been retrieved already */ - if(!(*head)->ctx.vds_prefix_valid) { + if (!(*head)->ctx.vds_prefix_valid) { /* Check for default DAPL */ - if((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) + if ((*head)->ctx.dapl_id == H5P_DATASET_ACCESS_DEFAULT) (*head)->ctx.vds_prefix = H5CX_def_dapl_cache.vds_prefix; else { /* Check if the property list is already available */ - if(NULL == (*head)->ctx.dapl) + if (NULL == (*head)->ctx.dapl) /* Get the dataset access property list pointer */ - if(NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "can't get default dataset access property list") + if (NULL == ((*head)->ctx.dapl = (H5P_genplist_t *)H5I_object((*head)->ctx.dapl_id))) + HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, + "can't get default dataset access property list") /* Get the prefix for the VDS */ /* (Note: 'peek', not 'get' - if this turns out to be a problem, we may need * to copy it and free this in the H5CX pop routine. -QAK) */ - if(H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) + if (H5P_peek((*head)->ctx.dapl, H5D_ACS_VDS_PREFIX_NAME, &(*head)->ctx.vds_prefix) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve VDS prefix") } /* end else */ @@ -2379,7 +2827,6 @@ H5CX_get_vds_prefix(const char **vds_prefix) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vds_prefix() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_tag * @@ -2395,7 +2842,8 @@ H5CX_get_vds_prefix(const char **vds_prefix) void H5CX_set_tag(haddr_t tag) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2407,7 +2855,6 @@ H5CX_set_tag(haddr_t tag) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_tag() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_ring * @@ -2423,7 +2870,8 @@ H5CX_set_tag(haddr_t tag) void H5CX_set_ring(H5AC_ring_t ring) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2436,7 +2884,7 @@ H5CX_set_ring(H5AC_ring_t ring) } /* end H5CX_set_ring() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_set_coll_metadata_read * @@ -2452,7 +2900,8 @@ H5CX_set_ring(H5AC_ring_t ring) void H5CX_set_coll_metadata_read(hbool_t cmdr) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2464,7 +2913,6 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_coll_metadata_read() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpi_coll_datatypes * @@ -2482,9 +2930,10 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) herr_t H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2499,7 +2948,6 @@ H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_mpi_coll_datatypes() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_io_xfer_mode * @@ -2515,8 +2963,9 @@ H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype) herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2533,7 +2982,6 @@ H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_io_xfer_mode() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_coll_opt * @@ -2549,8 +2997,9 @@ H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode) herr_t H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2567,7 +3016,6 @@ H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_mpio_coll_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpi_file_flushing * @@ -2583,7 +3031,8 @@ H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt) void H5CX_set_mpi_file_flushing(hbool_t flushing) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2595,11 +3044,11 @@ H5CX_set_mpi_file_flushing(hbool_t flushing) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpi_file_flushing() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_rank0_bcast * - * Purpose: Sets the "dataset meets read-with-rank0-and-bcast requirements" flag for the current API call context. + * Purpose: Sets the "dataset meets read-with-rank0-and-bcast requirements" flag for the current API call + *context. * * Return: * @@ -2611,7 +3060,8 @@ H5CX_set_mpi_file_flushing(hbool_t flushing) void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2624,7 +3074,6 @@ H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) } /* end H5CX_set_mpio_rank0_bcast() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_set_vlen_alloc_info * @@ -2638,11 +3087,11 @@ H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast) *------------------------------------------------------------------------- */ herr_t -H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info) +H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2652,8 +3101,8 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, /* Set the API context value */ (*head)->ctx.vl_alloc_info.alloc_func = alloc_func; (*head)->ctx.vl_alloc_info.alloc_info = alloc_info; - (*head)->ctx.vl_alloc_info.free_func = free_func; - (*head)->ctx.vl_alloc_info.free_info = free_info; + (*head)->ctx.vl_alloc_info.free_func = free_func; + (*head)->ctx.vl_alloc_info.free_info = free_info; /* Mark the value as valid */ (*head)->ctx.vl_alloc_info_valid = TRUE; @@ -2662,7 +3111,6 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vlen_alloc_info() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_nlinks * @@ -2678,8 +3126,9 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, herr_t H5CX_set_nlinks(size_t nlinks) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2697,7 +3146,7 @@ H5CX_set_nlinks(size_t nlinks) } /* end H5CX_set_nlinks() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_actual_chunk_opt * @@ -2713,23 +3162,22 @@ H5CX_set_nlinks(size_t nlinks) void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chunk_opt) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_actual_chunk_opt = mpio_actual_chunk_opt; + (*head)->ctx.mpio_actual_chunk_opt = mpio_actual_chunk_opt; (*head)->ctx.mpio_actual_chunk_opt_set = TRUE; FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_actual_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_actual_io_mode * @@ -2745,23 +3193,22 @@ H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t mpio_actual_chun void H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_actual_io_mode = mpio_actual_io_mode; + (*head)->ctx.mpio_actual_io_mode = mpio_actual_io_mode; (*head)->ctx.mpio_actual_io_mode_set = TRUE; FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_actual_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_local_no_coll_cause * @@ -2777,7 +3224,8 @@ H5CX_set_mpio_actual_io_mode(H5D_mpio_actual_io_mode_t mpio_actual_io_mode) void H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2786,16 +3234,15 @@ H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); /* If we're using the default DXPL, don't modify it */ - if((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { + if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_local_no_coll_cause = mpio_local_no_coll_cause; + (*head)->ctx.mpio_local_no_coll_cause = mpio_local_no_coll_cause; (*head)->ctx.mpio_local_no_coll_cause_set = TRUE; } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_mpio_local_no_coll_cause() */ - /*------------------------------------------------------------------------- * Function: H5CX_set_mpio_global_no_coll_cause * @@ -2811,7 +3258,8 @@ H5CX_set_mpio_local_no_coll_cause(uint32_t mpio_local_no_coll_cause) void H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2820,9 +3268,9 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) HDassert((*head)->ctx.dxpl_id != H5P_DEFAULT); /* If we're using the default DXPL, don't modify it */ - if((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { + if ((*head)->ctx.dxpl_id != H5P_DATASET_XFER_DEFAULT) { /* Cache the value for later, marking it to set in DXPL when context popped */ - (*head)->ctx.mpio_global_no_coll_cause = mpio_global_no_coll_cause; + (*head)->ctx.mpio_global_no_coll_cause = mpio_global_no_coll_cause; (*head)->ctx.mpio_global_no_coll_cause_set = TRUE; } /* end if */ @@ -2830,7 +3278,7 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) } /* end H5CX_set_mpio_global_no_coll_cause() */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - + /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_hard * @@ -2848,15 +3296,15 @@ H5CX_set_mpio_global_no_coll_cause(uint32_t mpio_global_no_coll_cause) herr_t H5CX_test_set_mpio_coll_chunk_link_hard(int mpio_coll_chunk_link_hard) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_HARD_NAME, mpio_coll_chunk_link_hard) @@ -2864,7 +3312,6 @@ H5CX_test_set_mpio_coll_chunk_link_hard(int mpio_coll_chunk_link_hard) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_hard() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_hard * @@ -2882,15 +3329,15 @@ H5CX_test_set_mpio_coll_chunk_link_hard(int mpio_coll_chunk_link_hard) herr_t H5CX_test_set_mpio_coll_chunk_multi_hard(int mpio_coll_chunk_multi_hard) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME, mpio_coll_chunk_multi_hard) @@ -2898,7 +3345,6 @@ H5CX_test_set_mpio_coll_chunk_multi_hard(int mpio_coll_chunk_multi_hard) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_hard() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_num_true * @@ -2916,15 +3362,15 @@ H5CX_test_set_mpio_coll_chunk_multi_hard(int mpio_coll_chunk_multi_hard) herr_t H5CX_test_set_mpio_coll_chunk_link_num_true(int mpio_coll_chunk_link_num_true) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME, mpio_coll_chunk_link_num_true) @@ -2932,11 +3378,11 @@ H5CX_test_set_mpio_coll_chunk_link_num_true(int mpio_coll_chunk_link_num_true) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_num_true() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_link_num_false * - * Purpose: Sets the instrumented "collective chunk link num false" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk link num false" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -2950,15 +3396,15 @@ H5CX_test_set_mpio_coll_chunk_link_num_true(int mpio_coll_chunk_link_num_true) herr_t H5CX_test_set_mpio_coll_chunk_link_num_false(int mpio_coll_chunk_link_num_false) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME, mpio_coll_chunk_link_num_false) @@ -2966,11 +3412,11 @@ H5CX_test_set_mpio_coll_chunk_link_num_false(int mpio_coll_chunk_link_num_false) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_link_num_false() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_ratio_coll * - * Purpose: Sets the instrumented "collective chunk multi ratio coll" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk multi ratio coll" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -2984,15 +3430,15 @@ H5CX_test_set_mpio_coll_chunk_link_num_false(int mpio_coll_chunk_link_num_false) herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(int mpio_coll_chunk_multi_ratio_coll) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME, mpio_coll_chunk_multi_ratio_coll) @@ -3000,11 +3446,11 @@ H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(int mpio_coll_chunk_multi_ratio_c FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_ratio_coll() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_chunk_multi_ratio_ind * - * Purpose: Sets the instrumented "collective chunk multi ratio ind" value for the current API call context. + * Purpose: Sets the instrumented "collective chunk multi ratio ind" value for the current API call + *context. * * Note: Only sets value if property set in DXPL * @@ -3018,15 +3464,15 @@ H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(int mpio_coll_chunk_multi_ratio_c herr_t H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(int mpio_coll_chunk_multi_ratio_ind) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME, mpio_coll_chunk_multi_ratio_ind) @@ -3034,7 +3480,6 @@ H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(int mpio_coll_chunk_multi_ratio_in FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_test_set_mpio_coll_chunk_multi_ratio_ind() */ - /*------------------------------------------------------------------------- * Function: H5CX_test_set_mpio_coll_rank0_bcast * @@ -3052,15 +3497,15 @@ H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(int mpio_coll_chunk_multi_ratio_in herr_t H5CX_test_set_mpio_coll_rank0_bcast(hbool_t mpio_coll_rank0_bcast) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ HDassert(head && *head); - HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || - (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); + HDassert(!((*head)->ctx.dxpl_id == H5P_DEFAULT || (*head)->ctx.dxpl_id == H5P_DATASET_XFER_DEFAULT)); H5CX_TEST_SET_PROP(H5D_XFER_COLL_RANK0_BCAST_NAME, mpio_coll_rank0_bcast) @@ -3070,7 +3515,6 @@ H5CX_test_set_mpio_coll_rank0_bcast(hbool_t mpio_coll_rank0_bcast) #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5CX_get_ohdr_flags * @@ -3086,8 +3530,9 @@ H5CX_test_set_mpio_coll_rank0_bcast(hbool_t mpio_coll_rank0_bcast) herr_t H5CX_get_ohdr_flags(uint8_t *ohdr_flags) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3105,7 +3550,6 @@ H5CX_get_ohdr_flags(uint8_t *ohdr_flags) FUNC_LEAVE_NOAPI(ret_value) } /* End H5CX_get_ohdr_flags() */ - /*------------------------------------------------------------------------- * Function: H5CX__pop_common * @@ -3121,8 +3565,9 @@ H5CX_get_ohdr_flags(uint8_t *ohdr_flags) static H5CX_node_t * H5CX__pop_common(void) { - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - H5CX_node_t *ret_value = NULL; /* Return value */ + H5CX_node_t **head = + H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + H5CX_node_t *ret_value = NULL; /* Return value */ #ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC @@ -3152,7 +3597,7 @@ H5CX__pop_common(void) /* Pop the top context node from the stack */ ret_value = (*head); - (*head) = (*head)->next; + (*head) = (*head)->next; #ifdef H5_HAVE_PARALLEL done: @@ -3160,7 +3605,6 @@ H5CX__pop_common(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__pop_common() */ - /*------------------------------------------------------------------------- * Function: H5CX_pop * @@ -3176,13 +3620,13 @@ H5CX__pop_common(void) herr_t H5CX_pop(void) { - H5CX_node_t *cnode; /* Context node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5CX_node_t *cnode; /* Context node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Perform common operations and get top context from stack */ - if(NULL == (cnode = H5CX__pop_common())) + if (NULL == (cnode = H5CX__pop_common())) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "error getting API context node") /* Free the context node */ @@ -3191,4 +3635,3 @@ H5CX_pop(void) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_pop() */ - diff --git a/src/H5CXmodule.h b/src/H5CXmodule.h index 186f8aace88..9fbaab42bd5 100644 --- a/src/H5CXmodule.h +++ b/src/H5CXmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5CX package. Including this header means that the source file * is part of the H5CX package. */ -#ifndef _H5CXmodule_H -#define _H5CXmodule_H +#ifndef H5CXmodule_H +#define H5CXmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5CX_MODULE -#define H5_MY_PKG H5CX -#define H5_MY_PKG_ERR H5E_CONTEXT -#define H5_MY_PKG_INIT YES - -#endif /* _H5CXmodule_H */ +#define H5_MY_PKG H5CX +#define H5_MY_PKG_ERR H5E_CONTEXT +#define H5_MY_PKG_INIT YES +#endif /* H5CXmodule_H */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 4f59327dbe7..f9289cb0e6f 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -13,8 +13,8 @@ /* * Header file for API contexts, etc. */ -#ifndef _H5CXprivate_H -#define _H5CXprivate_H +#ifndef H5CXprivate_H +#define H5CXprivate_H /* Include package's public header */ #ifdef NOT_YET @@ -22,59 +22,79 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #ifdef H5_HAVE_PARALLEL -#include "H5FDprivate.h" /* File drivers */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5FDprivate.h" /* File drivers */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ +/* API context state */ +typedef struct H5CX_state_t { + hid_t dcpl_id; /* DCPL for operation */ + 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 */ + H5VL_connector_prop_t vol_connector_prop; /* VOL connector property */ + +#ifdef H5_HAVE_PARALLEL + /* Internal: Parallel I/O settings */ + hbool_t coll_metadata_read; /* Whether to use collective I/O for metadata read */ +#endif /* H5_HAVE_PARALLEL */ +} H5CX_state_t; /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* Library private routines */ -#ifndef _H5private_H +#ifndef H5private_H H5_DLL herr_t H5CX_push(void); H5_DLL herr_t H5CX_pop(void); -#endif /* _H5private_H */ -H5_DLL void H5CX_push_special(void); +#endif /* H5private_H */ +H5_DLL void H5CX_push_special(void); H5_DLL hbool_t H5CX_is_def_dxpl(void); +/* API context state routines */ +H5_DLL herr_t H5CX_retrieve_state(H5CX_state_t **api_state); +H5_DLL herr_t H5CX_restore_state(const H5CX_state_t *api_state); +H5_DLL herr_t H5CX_free_state(H5CX_state_t *api_state); + /* "Setter" routines for API context info */ -H5_DLL void H5CX_set_dxpl(hid_t dxpl_id); -H5_DLL void H5CX_set_lcpl(hid_t lcpl_id); -H5_DLL void H5CX_set_lapl(hid_t lapl_id); -H5_DLL void H5CX_set_dcpl(hid_t dcpl_id); +H5_DLL void H5CX_set_dxpl(hid_t dxpl_id); +H5_DLL void H5CX_set_lcpl(hid_t lcpl_id); +H5_DLL void H5CX_set_lapl(hid_t lapl_id); +H5_DLL void H5CX_set_dcpl(hid_t dcpl_id); H5_DLL herr_t H5CX_set_libver_bounds(H5F_t *f); -H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, - hid_t loc_id, hbool_t is_collective); +H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t loc_id, + hbool_t is_collective); H5_DLL herr_t H5CX_set_loc(hid_t loc_id); +H5_DLL herr_t H5CX_set_vol_wrap_ctx(void *wrap_ctx); +H5_DLL herr_t H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop); /* "Getter" routines for API context info */ -H5_DLL hid_t H5CX_get_dxpl(void); -H5_DLL hid_t H5CX_get_lapl(void); -H5_DLL haddr_t H5CX_get_tag(void); +H5_DLL hid_t H5CX_get_dxpl(void); +H5_DLL hid_t H5CX_get_lapl(void); +H5_DLL herr_t H5CX_get_vol_wrap_ctx(void **wrap_ctx); +H5_DLL herr_t H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop); +H5_DLL haddr_t H5CX_get_tag(void); H5_DLL H5AC_ring_t H5CX_get_ring(void); #ifdef H5_HAVE_PARALLEL H5_DLL hbool_t H5CX_get_coll_metadata_read(void); -H5_DLL herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype); +H5_DLL herr_t H5CX_get_mpi_coll_datatypes(MPI_Datatype *btype, MPI_Datatype *ftype); H5_DLL hbool_t H5CX_get_mpi_file_flushing(void); H5_DLL hbool_t H5CX_get_mpio_rank0_bcast(void); #endif /* H5_HAVE_PARALLEL */ @@ -102,8 +122,8 @@ H5_DLL herr_t H5CX_get_vlen_alloc_info(H5T_vlen_alloc_info_t *vl_alloc_info); H5_DLL herr_t H5CX_get_dt_conv_cb(H5T_conv_cb_t *cb_struct); /* "Getter" routines for LCPL properties cached in API context */ -H5_DLL herr_t H5CX_get_encoding(H5T_cset_t* encoding); -H5_DLL herr_t H5CX_get_intermediate_group(unsigned* crt_intermed_group); +H5_DLL herr_t H5CX_get_encoding(H5T_cset_t *encoding); +H5_DLL herr_t H5CX_get_intermediate_group(unsigned *crt_intermed_group); /* "Getter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); @@ -123,19 +143,19 @@ H5_DLL herr_t H5CX_get_libver_bounds(H5F_libver_t *low_bound, H5F_libver_t *high H5_DLL void H5CX_set_tag(haddr_t tag); H5_DLL void H5CX_set_ring(H5AC_ring_t ring); #ifdef H5_HAVE_PARALLEL -H5_DLL void H5CX_set_coll_metadata_read(hbool_t cmdr); +H5_DLL void H5CX_set_coll_metadata_read(hbool_t cmdr); H5_DLL herr_t H5CX_set_mpi_coll_datatypes(MPI_Datatype btype, MPI_Datatype ftype); H5_DLL herr_t H5CX_set_mpio_coll_opt(H5FD_mpio_collective_opt_t mpio_coll_opt); -H5_DLL void H5CX_set_mpi_file_flushing(hbool_t flushing); -H5_DLL void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast); +H5_DLL void H5CX_set_mpi_file_flushing(hbool_t flushing); +H5_DLL void H5CX_set_mpio_rank0_bcast(hbool_t rank0_bcast); #endif /* H5_HAVE_PARALLEL */ /* "Setter" routines for DXPL properties cached in API context */ #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); #endif /* H5_HAVE_PARALLEL */ -H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info); +H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info); /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); @@ -157,5 +177,4 @@ H5_DLL herr_t H5CX_test_set_mpio_coll_rank0_bcast(hbool_t rank0_bcast); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ #endif /* H5_HAVE_PARALLEL */ -#endif /* _H5CXprivate_H */ - +#endif /* H5CXprivate_H */ diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index a5ff7bc2591..104f1aff055 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,50 +26,42 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata Cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error Handling */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error Handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C_dump_cache * @@ -84,39 +76,39 @@ *------------------------------------------------------------------------- */ herr_t -H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) +H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) { - H5C_cache_entry_t * entry_ptr; - H5SL_t * slist_ptr = NULL; - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5SL_t * slist_ptr = NULL; + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(cache_ptr != NULL); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_name != NULL ); + HDassert(cache_name != NULL); /* First, create a skip list */ - if(NULL == (slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create skip list") /* Next, scan the index, and insert all entries in the skip list. * Do this, as we want to display cache entries in increasing address * order. */ - for(i = 0; i < H5C__HASH_TABLE_LEN; i++) { + for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { entry_ptr = cache_ptr->index[i]; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) + if (H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't insert entry in skip list") entry_ptr = entry_ptr->ht_next; } /* end while */ - } /* end for */ + } /* end for */ /* If we get this far, all entries in the cache are listed in the * skip list -- scan the skip list generating the desired output. @@ -134,17 +126,18 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) HDfprintf(stdout, "| Prot/Pin/Dirty"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); - i = 0; + i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Print entry */ HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); - if(NULL == entry_ptr->tag_info) + if (NULL == entry_ptr->tag_info) HDfprintf(stdout, " %16s ", "N/A"); else HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); @@ -169,7 +162,7 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) done: /* Discard the skip list */ - if(slist_ptr) + if (slist_ptr) H5SL_close(slist_ptr); FUNC_LEAVE_NOAPI(ret_value) @@ -177,7 +170,7 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) #endif /* NDEBUG */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C_dump_cache_LRU * @@ -194,21 +187,21 @@ H5C_dump_cache(H5C_t * cache_ptr, const char * cache_name) herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) { - H5C_cache_entry_t * entry_ptr; - int i = 0; + H5C_cache_entry_t *entry_ptr; + int i = 0; FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(cache_ptr != NULL); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_name != NULL ); + HDassert(cache_name != NULL); HDfprintf(stdout, "\n\nDump of metadata cache LRU \"%s\"\n", cache_name); - HDfprintf(stdout, "LRU len = %d, LRU size = %d\n", - cache_ptr->LRU_list_len, (int)(cache_ptr->LRU_list_size)); - HDfprintf(stdout, "index_size = %d, max_cache_size = %d, delta = %d\n\n", - (int)(cache_ptr->index_size), (int)(cache_ptr->max_cache_size), + HDfprintf(stdout, "LRU len = %d, LRU size = %d\n", cache_ptr->LRU_list_len, + (int)(cache_ptr->LRU_list_size)); + HDfprintf(stdout, "index_size = %d, max_cache_size = %d, delta = %d\n\n", (int)(cache_ptr->index_size), + (int)(cache_ptr->max_cache_size), (int)(cache_ptr->max_cache_size) - (int)(cache_ptr->index_size)); /* Print header */ @@ -221,26 +214,25 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) HDfprintf(stdout, "| Dirty"); HDfprintf(stdout, "\n"); - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Print entry */ HDfprintf(stdout, "%s%5d ", cache_ptr->prefix, i); HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); - if(NULL == entry_ptr->tag_info) + if (NULL == entry_ptr->tag_info) HDfprintf(stdout, " %16s ", "N/A"); else - HDfprintf(stdout, " 0x%16llx ", - (long long)(entry_ptr->tag_info->tag)); + HDfprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->tag_info->tag)); HDfprintf(stdout, " %5lld ", (long long)(entry_ptr->size)); HDfprintf(stdout, " %d ", (int)(entry_ptr->ring)); - HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), - (entry_ptr->type->name)); + HDfprintf(stdout, " %2d %-32s ", (int)(entry_ptr->type->id), (entry_ptr->type->name)); HDfprintf(stdout, " %d", (int)(entry_ptr->is_dirty)); HDfprintf(stdout, "\n"); @@ -248,13 +240,13 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) entry_ptr = entry_ptr->next; } /* end while */ - HDfprintf(stdout, "----------------------------------------------------------------------------------------------------------------\n"); + HDfprintf(stdout, "--------------------------------------------------------------------------------------" + "--------------------------\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_dump_cache_LRU() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_dump_cache_skip_list @@ -269,7 +261,7 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) * 11/15/14 * * Changes: Updated function for the slist_enabled field in H5C_t. - * Recall that to minimize slist overhead, the slist is + * Recall that to minimize slist overhead, the slist is * empty and not maintained if cache_ptr->slist_enabled is * false. * JRM -- 5/6/20 @@ -278,12 +270,12 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) */ #ifndef NDEBUG herr_t -H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) +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; + herr_t ret_value = SUCCEED; /* Return value */ + int i; + H5C_cache_entry_t *entry_ptr = NULL; + H5SL_node_t * node_ptr = NULL; FUNC_ENTER_NOAPI_NOERR @@ -291,61 +283,51 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(calling_fcn != NULL); - HDfprintf(stdout, "\n\nDumping metadata cache skip list from %s.\n", - calling_fcn); - HDfprintf(stdout, " slist enabled = %d.\n", - (int)(cache_ptr->slist_enabled)); - HDfprintf(stdout, " slist len = %u.\n", cache_ptr->slist_len); - HDfprintf(stdout, " slist size = %lld.\n", - (long long)(cache_ptr->slist_size)); + HDfprintf(stdout, "\n\nDumping metadata cache skip list from %s.\n", calling_fcn); + HDfprintf(stdout, " slist %s.\n", cache_ptr->slist_enabled ? "enabled" : "disabled"); + HDfprintf(stdout, " slist len = %" PRIu32 ".\n", cache_ptr->slist_len); + HDfprintf(stdout, " slist size = %zu.\n", cache_ptr->slist_size); - if(cache_ptr->slist_len > 0) { + if (cache_ptr->slist_len > 0) { /* If we get this far, all entries in the cache are listed in the * skip list -- scan the skip list generating the desired output. */ - HDfprintf(stdout, - "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); + HDfprintf(stdout, "Num: Addr: Len: Prot/Pind: Dirty: Type:\n"); i = 0; node_ptr = H5SL_first(cache_ptr->slist_ptr); - if ( node_ptr != NULL ) { + if (node_ptr != NULL) { entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - - } else { + } + else { entry_ptr = NULL; } - while ( entry_ptr != NULL ) { + while (entry_ptr != NULL) { - HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDfprintf(stdout, - "%s%d 0x%016llx %4lld %d/%d %d %s\n", - cache_ptr->prefix, i, - (long long)(entry_ptr->addr), - (long long)(entry_ptr->size), - (int)(entry_ptr->is_protected), - (int)(entry_ptr->is_pinned), - (int)(entry_ptr->is_dirty), - entry_ptr->type->name); + HDfprintf(stdout, "%s%d 0x%016llx %4lld %d/%d %d %s\n", cache_ptr->prefix, i, + (long long)(entry_ptr->addr), (long long)(entry_ptr->size), + (int)(entry_ptr->is_protected), (int)(entry_ptr->is_pinned), (int)(entry_ptr->is_dirty), + entry_ptr->type->name); - HDfprintf(stdout, " node_ptr = %p, item = %p\n", - node_ptr, H5SL_item(node_ptr)); + HDfprintf(stdout, " node_ptr = %p, item = %p\n", (void *)node_ptr, H5SL_item(node_ptr)); /* increment node_ptr before we delete its target */ node_ptr = H5SL_next(node_ptr); - if ( node_ptr != NULL ) { + if (node_ptr != NULL) { entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - - } else { + } + else { entry_ptr = NULL; } @@ -353,7 +335,7 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) i++; } /* end while */ - } /* end if */ + } /* end if */ HDfprintf(stdout, "\n\n"); @@ -362,7 +344,6 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) } /* H5C_dump_cache_skip_list() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C_set_prefix * @@ -377,14 +358,14 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) *------------------------------------------------------------------------- */ herr_t -H5C_set_prefix(H5C_t * cache_ptr, char * prefix) +H5C_set_prefix(H5C_t *cache_ptr, char *prefix) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || - (prefix == NULL) || (HDstrlen(prefix) >= H5C__PREFIX_LEN)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (prefix == NULL) || + (HDstrlen(prefix) >= H5C__PREFIX_LEN)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") HDstrncpy(&(cache_ptr->prefix[0]), prefix, (size_t)(H5C__PREFIX_LEN)); @@ -395,7 +376,6 @@ H5C_set_prefix(H5C_t * cache_ptr, char * prefix) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_prefix() */ - /*------------------------------------------------------------------------- * Function: H5C_stats * @@ -409,479 +389,327 @@ H5C_set_prefix(H5C_t * cache_ptr, char * prefix) *------------------------------------------------------------------------- */ herr_t -H5C_stats(H5C_t * cache_ptr, - const char * cache_name, +H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t #if !H5C_COLLECT_CACHE_STATS - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5C_COLLECT_CACHE_STATS */ - display_detailed_stats) + display_detailed_stats) { #if H5C_COLLECT_CACHE_STATS - int i; - int64_t total_hits = 0; - int64_t total_misses = 0; - int64_t total_write_protects = 0; - int64_t total_read_protects = 0; - int64_t max_read_protects = 0; - int64_t total_insertions = 0; - int64_t total_pinned_insertions = 0; - int64_t total_clears = 0; - int64_t total_flushes = 0; - int64_t total_evictions = 0; - int64_t total_take_ownerships = 0; - int64_t total_moves = 0; - int64_t total_entry_flush_moves = 0; - int64_t total_cache_flush_moves = 0; - int64_t total_size_increases = 0; - int64_t total_size_decreases = 0; - int64_t total_entry_flush_size_changes = 0; - int64_t total_cache_flush_size_changes = 0; - int64_t total_pins = 0; - int64_t total_unpins = 0; - int64_t total_dirty_pins = 0; - int64_t total_pinned_flushes = 0; - int64_t total_pinned_clears = 0; - int32_t aggregate_max_accesses = 0; - int32_t aggregate_min_accesses = 1000000; - int32_t aggregate_max_clears = 0; - int32_t aggregate_max_flushes = 0; - size_t aggregate_max_size = 0; - int32_t aggregate_max_pins = 0; - double hit_rate; - double prefetch_use_rate; - double average_successful_search_depth = 0.0f; - double average_failed_search_depth = 0.0f; - double average_entries_skipped_per_calls_to_msic = 0.0f; - double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0f; - double average_entries_scanned_per_calls_to_msic = 0.0f; -#endif /* H5C_COLLECT_CACHE_STATS */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + int64_t total_write_protects = 0; + int64_t total_read_protects = 0; + int64_t max_read_protects = 0; + int64_t total_insertions = 0; + int64_t total_pinned_insertions = 0; + int64_t total_clears = 0; + int64_t total_flushes = 0; + int64_t total_evictions = 0; + int64_t total_take_ownerships = 0; + int64_t total_moves = 0; + int64_t total_entry_flush_moves = 0; + int64_t total_cache_flush_moves = 0; + int64_t total_size_increases = 0; + int64_t total_size_decreases = 0; + int64_t total_entry_flush_size_changes = 0; + int64_t total_cache_flush_size_changes = 0; + int64_t total_pins = 0; + int64_t total_unpins = 0; + int64_t total_dirty_pins = 0; + int64_t total_pinned_flushes = 0; + int64_t total_pinned_clears = 0; + int32_t aggregate_max_accesses = 0; + int32_t aggregate_min_accesses = 1000000; + int32_t aggregate_max_clears = 0; + int32_t aggregate_max_flushes = 0; + size_t aggregate_max_size = 0; + int32_t aggregate_max_pins = 0; + double hit_rate; + double prefetch_use_rate; + double average_successful_search_depth = 0.0; + double average_failed_search_depth = 0.0; + double average_entries_skipped_per_calls_to_msic = 0.0; + double average_dirty_pf_entries_skipped_per_call_to_msic = 0.0; + double average_entries_scanned_per_calls_to_msic = 0.0; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* This would normally be an assert, but we need to use an HGOTO_ERROR * call to shut up the compiler. */ - if((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || - (NULL == cache_name)) + if ((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (NULL == cache_name)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or cache_name") #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++ ) { - total_hits += cache_ptr->hits[i]; - total_misses += cache_ptr->misses[i]; - total_write_protects += cache_ptr->write_protects[i]; - total_read_protects += cache_ptr->read_protects[i]; - if(max_read_protects < cache_ptr->max_read_protects[i]) - max_read_protects = cache_ptr->max_read_protects[i]; - total_insertions += cache_ptr->insertions[i]; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; + total_write_protects += cache_ptr->write_protects[i]; + total_read_protects += cache_ptr->read_protects[i]; + if (max_read_protects < cache_ptr->max_read_protects[i]) + max_read_protects = cache_ptr->max_read_protects[i]; + total_insertions += cache_ptr->insertions[i]; total_pinned_insertions += cache_ptr->pinned_insertions[i]; - total_clears += cache_ptr->clears[i]; - total_flushes += cache_ptr->flushes[i]; - total_evictions += cache_ptr->evictions[i]; - total_take_ownerships += cache_ptr->take_ownerships[i]; - total_moves += cache_ptr->moves[i]; - total_entry_flush_moves += cache_ptr->entry_flush_moves[i]; - total_cache_flush_moves += cache_ptr->cache_flush_moves[i]; - total_size_increases += cache_ptr->size_increases[i]; - total_size_decreases += cache_ptr->size_decreases[i]; - total_entry_flush_size_changes - += cache_ptr->entry_flush_size_changes[i]; - total_cache_flush_size_changes - += cache_ptr->cache_flush_size_changes[i]; - total_pins += cache_ptr->pins[i]; - total_unpins += cache_ptr->unpins[i]; - total_dirty_pins += cache_ptr->dirty_pins[i]; - total_pinned_flushes += cache_ptr->pinned_flushes[i]; - total_pinned_clears += cache_ptr->pinned_clears[i]; + total_clears += cache_ptr->clears[i]; + total_flushes += cache_ptr->flushes[i]; + total_evictions += cache_ptr->evictions[i]; + total_take_ownerships += cache_ptr->take_ownerships[i]; + total_moves += cache_ptr->moves[i]; + total_entry_flush_moves += cache_ptr->entry_flush_moves[i]; + total_cache_flush_moves += cache_ptr->cache_flush_moves[i]; + total_size_increases += cache_ptr->size_increases[i]; + total_size_decreases += cache_ptr->size_decreases[i]; + total_entry_flush_size_changes += cache_ptr->entry_flush_size_changes[i]; + total_cache_flush_size_changes += cache_ptr->cache_flush_size_changes[i]; + total_pins += cache_ptr->pins[i]; + total_unpins += cache_ptr->unpins[i]; + total_dirty_pins += cache_ptr->dirty_pins[i]; + total_pinned_flushes += cache_ptr->pinned_flushes[i]; + total_pinned_clears += cache_ptr->pinned_clears[i]; #if H5C_COLLECT_CACHE_ENTRY_STATS - if(aggregate_max_accesses < cache_ptr->max_accesses[i]) + if (aggregate_max_accesses < cache_ptr->max_accesses[i]) aggregate_max_accesses = cache_ptr->max_accesses[i]; - if(aggregate_min_accesses > aggregate_max_accesses) + if (aggregate_min_accesses > aggregate_max_accesses) aggregate_min_accesses = aggregate_max_accesses; - if(aggregate_min_accesses > cache_ptr->min_accesses[i]) + if (aggregate_min_accesses > cache_ptr->min_accesses[i]) aggregate_min_accesses = cache_ptr->min_accesses[i]; - if(aggregate_max_clears < cache_ptr->max_clears[i]) + if (aggregate_max_clears < cache_ptr->max_clears[i]) aggregate_max_clears = cache_ptr->max_clears[i]; - if(aggregate_max_flushes < cache_ptr->max_flushes[i]) + if (aggregate_max_flushes < cache_ptr->max_flushes[i]) aggregate_max_flushes = cache_ptr->max_flushes[i]; - if(aggregate_max_size < cache_ptr->max_size[i]) + if (aggregate_max_size < cache_ptr->max_size[i]) aggregate_max_size = cache_ptr->max_size[i]; - if(aggregate_max_pins < cache_ptr->max_pins[i]) + if (aggregate_max_pins < cache_ptr->max_pins[i]) aggregate_max_pins = cache_ptr->max_pins[i]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - } /* end for */ + } /* end for */ - if((total_hits > 0) || (total_misses > 0)) - hit_rate = (double)100.0f * ((double)(total_hits)) / - ((double)(total_hits + total_misses)); + if ((total_hits > 0) || (total_misses > 0)) + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else - hit_rate = 0.0f; + hit_rate = 0.0; - if(cache_ptr->successful_ht_searches > 0) - average_successful_search_depth = - ((double)(cache_ptr->total_successful_ht_search_depth)) / - ((double)(cache_ptr->successful_ht_searches)); + if (cache_ptr->successful_ht_searches > 0) + average_successful_search_depth = ((double)(cache_ptr->total_successful_ht_search_depth)) / + ((double)(cache_ptr->successful_ht_searches)); - if(cache_ptr->failed_ht_searches > 0) + if (cache_ptr->failed_ht_searches > 0) average_failed_search_depth = - ((double)(cache_ptr->total_failed_ht_search_depth)) / - ((double)(cache_ptr->failed_ht_searches)); - + ((double)(cache_ptr->total_failed_ht_search_depth)) / ((double)(cache_ptr->failed_ht_searches)); - HDfprintf(stdout, "\n%sH5C: cache statistics for %s\n", - cache_ptr->prefix, cache_name); + HDfprintf(stdout, "\n%sH5C: cache statistics for %s\n", cache_ptr->prefix, cache_name); HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "%s hash table insertion / deletions = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->total_ht_insertions), - (long)(cache_ptr->total_ht_deletions)); - - HDfprintf(stdout, - "%s HT successful / failed searches = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->successful_ht_searches), - (long)(cache_ptr->failed_ht_searches)); - - HDfprintf(stdout, - "%s Av. HT suc / failed search depth = %f / %f\n", - cache_ptr->prefix, - average_successful_search_depth, - average_failed_search_depth); - - HDfprintf(stdout, - "%s current (max) index size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->index_size), - (long)(cache_ptr->max_index_size), - (unsigned long)(cache_ptr->index_len), - (unsigned long)(cache_ptr->max_index_len)); - - HDfprintf(stdout, - "%s current (max) clean/dirty idx size = %ld (%ld) / %ld (%ld)\n", - cache_ptr->prefix, - (long)(cache_ptr->clean_index_size), - (long)(cache_ptr->max_clean_index_size), - (long)(cache_ptr->dirty_index_size), - (long)(cache_ptr->max_dirty_index_size)); - - HDfprintf(stdout, - "%s current (max) slist size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->slist_size), - (long)(cache_ptr->max_slist_size), - (unsigned long)(cache_ptr->slist_len), - (unsigned long)(cache_ptr->max_slist_len)); - - HDfprintf(stdout, - "%s current (max) PL size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->pl_size), - (long)(cache_ptr->max_pl_size), - (unsigned long)(cache_ptr->pl_len), + HDfprintf(stdout, "%s hash table insertion / deletions = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->total_ht_insertions), (long)(cache_ptr->total_ht_deletions)); + + HDfprintf(stdout, "%s HT successful / failed searches = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->successful_ht_searches), (long)(cache_ptr->failed_ht_searches)); + + HDfprintf(stdout, "%s Av. HT suc / failed search depth = %f / %f\n", cache_ptr->prefix, + average_successful_search_depth, average_failed_search_depth); + + HDfprintf(stdout, "%s current (max) index size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->index_size), (long)(cache_ptr->max_index_size), + (unsigned long)(cache_ptr->index_len), (unsigned long)(cache_ptr->max_index_len)); + + HDfprintf(stdout, "%s current (max) clean/dirty idx size = %ld (%ld) / %ld (%ld)\n", cache_ptr->prefix, + (long)(cache_ptr->clean_index_size), (long)(cache_ptr->max_clean_index_size), + (long)(cache_ptr->dirty_index_size), (long)(cache_ptr->max_dirty_index_size)); + + HDfprintf(stdout, "%s current (max) slist size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->slist_size), (long)(cache_ptr->max_slist_size), + (unsigned long)(cache_ptr->slist_len), (unsigned long)(cache_ptr->max_slist_len)); + + HDfprintf(stdout, "%s current (max) PL size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->pl_size), (long)(cache_ptr->max_pl_size), (unsigned long)(cache_ptr->pl_len), (unsigned long)(cache_ptr->max_pl_len)); - HDfprintf(stdout, - "%s current (max) PEL size / length = %ld (%ld) / %lu (%lu)\n", - cache_ptr->prefix, - (long)(cache_ptr->pel_size), - (long)(cache_ptr->max_pel_size), - (unsigned long)(cache_ptr->pel_len), - (unsigned long)(cache_ptr->max_pel_len)); + HDfprintf(stdout, "%s current (max) PEL size / length = %ld (%ld) / %lu (%lu)\n", cache_ptr->prefix, + (long)(cache_ptr->pel_size), (long)(cache_ptr->max_pel_size), + (unsigned long)(cache_ptr->pel_len), (unsigned long)(cache_ptr->max_pel_len)); - HDfprintf(stdout, - "%s current LRU list size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->LRU_list_size), - (unsigned long)(cache_ptr->LRU_list_len)); + HDfprintf(stdout, "%s current LRU list size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->LRU_list_size), (unsigned long)(cache_ptr->LRU_list_len)); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - HDfprintf(stdout, - "%s current clean LRU size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->cLRU_list_size), - (unsigned long)(cache_ptr->cLRU_list_len)); - - HDfprintf(stdout, - "%s current dirty LRU size / length = %ld / %lu\n", - cache_ptr->prefix, - (long)(cache_ptr->dLRU_list_size), - (unsigned long)(cache_ptr->dLRU_list_len)); + HDfprintf(stdout, "%s current clean LRU size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->cLRU_list_size), (unsigned long)(cache_ptr->cLRU_list_len)); + + HDfprintf(stdout, "%s current dirty LRU size / length = %ld / %lu\n", cache_ptr->prefix, + (long)(cache_ptr->dLRU_list_size), (unsigned long)(cache_ptr->dLRU_list_len)); #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - HDfprintf(stdout, - "%s Total hits / misses / hit_rate = %ld / %ld / %f\n", - cache_ptr->prefix, - (long)total_hits, - (long)total_misses, - hit_rate); - - HDfprintf(stdout, - "%s Total write / read (max) protects = %ld / %ld (%ld)\n", - cache_ptr->prefix, - (long)total_write_protects, - (long)total_read_protects, - (long)max_read_protects); - - HDfprintf(stdout, - "%s Total clears / flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)total_clears, - (long)total_flushes); - - HDfprintf(stdout, - "%s Total evictions / take ownerships = %ld / %ld\n", - cache_ptr->prefix, - (long)total_evictions, - (long)total_take_ownerships); - - HDfprintf(stdout, - "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", - cache_ptr->prefix, - (long)total_insertions, - (long)total_pinned_insertions, - (long)total_moves); - - HDfprintf(stdout, - "%s Total entry / cache flush moves = %ld / %ld\n", - cache_ptr->prefix, - (long)total_entry_flush_moves, - (long)total_cache_flush_moves); - - HDfprintf(stdout, "%s Total entry size incrs / decrs = %ld / %ld\n", - cache_ptr->prefix, - (long)total_size_increases, - (long)total_size_decreases); - - HDfprintf(stdout, "%s Ttl entry/cache flush size changes = %ld / %ld\n", - cache_ptr->prefix, - (long)total_entry_flush_size_changes, - (long)total_cache_flush_size_changes); - - HDfprintf(stdout, - "%s Total entry pins (dirty) / unpins = %ld (%ld) / %ld\n", - cache_ptr->prefix, - (long)total_pins, - (long)total_dirty_pins, - (long)total_unpins); - - HDfprintf(stdout, "%s Total pinned flushes / clears = %ld / %ld\n", - cache_ptr->prefix, - (long)total_pinned_flushes, - (long)total_pinned_clears); - - HDfprintf(stdout, "%s MSIC: (make space in cache) calls = %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s Total hits / misses / hit_rate = %ld / %ld / %f\n", cache_ptr->prefix, + (long)total_hits, (long)total_misses, hit_rate); + + HDfprintf(stdout, "%s Total write / read (max) protects = %ld / %ld (%ld)\n", cache_ptr->prefix, + (long)total_write_protects, (long)total_read_protects, (long)max_read_protects); + + HDfprintf(stdout, "%s Total clears / flushes = %ld / %ld\n", cache_ptr->prefix, + (long)total_clears, (long)total_flushes); + + HDfprintf(stdout, "%s Total evictions / take ownerships = %ld / %ld\n", cache_ptr->prefix, + (long)total_evictions, (long)total_take_ownerships); + + HDfprintf(stdout, "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, + (long)total_insertions, (long)total_pinned_insertions, (long)total_moves); + + HDfprintf(stdout, "%s Total entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, + (long)total_entry_flush_moves, (long)total_cache_flush_moves); + + HDfprintf(stdout, "%s Total entry size incrs / decrs = %ld / %ld\n", cache_ptr->prefix, + (long)total_size_increases, (long)total_size_decreases); + + HDfprintf(stdout, "%s Ttl entry/cache flush size changes = %ld / %ld\n", cache_ptr->prefix, + (long)total_entry_flush_size_changes, (long)total_cache_flush_size_changes); + + HDfprintf(stdout, "%s Total entry pins (dirty) / unpins = %ld (%ld) / %ld\n", cache_ptr->prefix, + (long)total_pins, (long)total_dirty_pins, (long)total_unpins); + + HDfprintf(stdout, "%s Total pinned flushes / clears = %ld / %ld\n", cache_ptr->prefix, + (long)total_pinned_flushes, (long)total_pinned_clears); + + HDfprintf(stdout, "%s MSIC: (make space in cache) calls = %lld\n", cache_ptr->prefix, (long long)(cache_ptr->calls_to_msic)); if (cache_ptr->calls_to_msic > 0) average_entries_skipped_per_calls_to_msic = - (((double)(cache_ptr->total_entries_skipped_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + (((double)(cache_ptr->total_entries_skipped_in_msic)) / ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, "%s MSIC: Average/max entries skipped = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max entries skipped = %lf / %ld\n", cache_ptr->prefix, (double)average_entries_skipped_per_calls_to_msic, (long)(cache_ptr->max_entries_skipped_in_msic)); - if(cache_ptr->calls_to_msic > 0) + if (cache_ptr->calls_to_msic > 0) average_dirty_pf_entries_skipped_per_call_to_msic = (((double)(cache_ptr->total_dirty_pf_entries_skipped_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, - "%s MSIC: Average/max dirty pf entries skipped = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max dirty pf entries skipped = %lf / %ld\n", cache_ptr->prefix, average_dirty_pf_entries_skipped_per_call_to_msic, (long)(cache_ptr->max_dirty_pf_entries_skipped_in_msic)); - if(cache_ptr->calls_to_msic > 0) + if (cache_ptr->calls_to_msic > 0) average_entries_scanned_per_calls_to_msic = - (((double)(cache_ptr->total_entries_scanned_in_msic)) / - ((double)(cache_ptr->calls_to_msic))); + (((double)(cache_ptr->total_entries_scanned_in_msic)) / ((double)(cache_ptr->calls_to_msic))); - HDfprintf(stdout, "%s MSIC: Average/max entries scanned = %lf / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Average/max entries scanned = %lf / %ld\n", cache_ptr->prefix, (double)average_entries_scanned_per_calls_to_msic, (long)(cache_ptr->max_entries_scanned_in_msic)); - HDfprintf(stdout, "%s MSIC: Scanned to make space(evict) = %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s MSIC: Scanned to make space(evict) = %lld\n", cache_ptr->prefix, (long long)(cache_ptr->entries_scanned_to_make_space)); - HDfprintf(stdout, "%s MSIC: Scanned to satisfy min_clean = %lld\n", - cache_ptr->prefix, - (long long)(cache_ptr->total_entries_scanned_in_msic - - cache_ptr->entries_scanned_to_make_space)); + HDfprintf( + stdout, "%s MSIC: Scanned to satisfy min_clean = %lld\n", cache_ptr->prefix, + (long long)(cache_ptr->total_entries_scanned_in_msic - cache_ptr->entries_scanned_to_make_space)); - HDfprintf(stdout, - "%s slist/LRU/index scan restarts = %lld / %lld / %lld.\n", - cache_ptr->prefix, - (long long)(cache_ptr->slist_scan_restarts), - (long long)(cache_ptr->LRU_scan_restarts), + HDfprintf(stdout, "%s slist/LRU/index scan restarts = %lld / %lld / %lld.\n", cache_ptr->prefix, + (long long)(cache_ptr->slist_scan_restarts), (long long)(cache_ptr->LRU_scan_restarts), (long long)(cache_ptr->index_scan_restarts)); - HDfprintf(stdout, - "%s cache image creations/reads/loads/size = %d / %d /%d / %Hu\n", - cache_ptr->prefix, - cache_ptr->images_created, - cache_ptr->images_read, - cache_ptr->images_loaded, + HDfprintf(stdout, "%s cache image creations/reads/loads/size = %d / %d /%d / %" PRIuHSIZE "\n", + cache_ptr->prefix, cache_ptr->images_created, cache_ptr->images_read, cache_ptr->images_loaded, cache_ptr->last_image_size); - HDfprintf(stdout, - "%s prefetches / dirty prefetches = %lld / %lld\n", - cache_ptr->prefix, - (long long)(cache_ptr->prefetches), - (long long)(cache_ptr->dirty_prefetches)); + HDfprintf(stdout, "%s prefetches / dirty prefetches = %lld / %lld\n", cache_ptr->prefix, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches)); - HDfprintf(stdout, - "%s prefetch hits/flushes/evictions = %lld / %lld / %lld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s prefetch hits/flushes/evictions = %lld / %lld / %lld\n", cache_ptr->prefix, (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID])); - if(cache_ptr->prefetches > 0) - prefetch_use_rate = - (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / - ((double)(cache_ptr->prefetches)); + if (cache_ptr->prefetches > 0) + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else - prefetch_use_rate = 0.0f; + prefetch_use_rate = 0.0; - HDfprintf(stdout, - "%s prefetched entry use rate = %lf\n", - cache_ptr->prefix, - prefetch_use_rate); + HDfprintf(stdout, "%s prefetched entry use rate = %lf\n", cache_ptr->prefix, prefetch_use_rate); #if H5C_COLLECT_CACHE_ENTRY_STATS - HDfprintf(stdout, "%s aggregate max / min accesses = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_accesses, - (int)aggregate_min_accesses); + HDfprintf(stdout, "%s aggregate max / min accesses = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_accesses, (int)aggregate_min_accesses); - HDfprintf(stdout, "%s aggregate max_clears / max_flushes = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_clears, - (int)aggregate_max_flushes); + HDfprintf(stdout, "%s aggregate max_clears / max_flushes = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_clears, (int)aggregate_max_flushes); - HDfprintf(stdout, "%s aggregate max_size / max_pins = %d / %d\n", - cache_ptr->prefix, - (int)aggregate_max_size, - (int)aggregate_max_pins); + HDfprintf(stdout, "%s aggregate max_size / max_pins = %d / %d\n", cache_ptr->prefix, + (int)aggregate_max_size, (int)aggregate_max_pins); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ - if(display_detailed_stats) { - for(i = 0; i <= cache_ptr->max_type_id; i++) { + if (display_detailed_stats) { + for (i = 0; i <= cache_ptr->max_type_id; i++) { HDfprintf(stdout, "\n"); - HDfprintf(stdout, "%s Stats on %s:\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s Stats on %s:\n", cache_ptr->prefix, ((cache_ptr->class_table_ptr))[i]->name); - if((cache_ptr->hits[i] > 0) || (cache_ptr->misses[i] > 0)) - hit_rate = (double)100.0f * ((double)(cache_ptr->hits[i])) / - ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); + if ((cache_ptr->hits[i] > 0) || (cache_ptr->misses[i] > 0)) + hit_rate = 100.0 * ((double)(cache_ptr->hits[i])) / + ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); else - hit_rate = 0.0f; - - HDfprintf(stdout, - "%s hits / misses / hit_rate = %ld / %ld / %f\n", - cache_ptr->prefix, - (long)(cache_ptr->hits[i]), - (long)(cache_ptr->misses[i]), - hit_rate); - - HDfprintf(stdout, - "%s write / read (max) protects = %ld / %ld (%d)\n", - cache_ptr->prefix, - (long)(cache_ptr->write_protects[i]), - (long)(cache_ptr->read_protects[i]), + hit_rate = 0.0; + + HDfprintf(stdout, "%s hits / misses / hit_rate = %ld / %ld / %f\n", cache_ptr->prefix, + (long)(cache_ptr->hits[i]), (long)(cache_ptr->misses[i]), hit_rate); + + HDfprintf(stdout, "%s write / read (max) protects = %ld / %ld (%d)\n", cache_ptr->prefix, + (long)(cache_ptr->write_protects[i]), (long)(cache_ptr->read_protects[i]), (int)(cache_ptr->max_read_protects[i])); - HDfprintf(stdout, - "%s clears / flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->clears[i]), - (long)(cache_ptr->flushes[i])); - - HDfprintf(stdout, - "%s evictions / take ownerships = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->evictions[i]), - (long)(cache_ptr->take_ownerships[i])); - - HDfprintf(stdout, - "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->insertions[i]), - (long)(cache_ptr->pinned_insertions[i]), + HDfprintf(stdout, "%s clears / flushes = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->clears[i]), (long)(cache_ptr->flushes[i])); + + HDfprintf(stdout, "%s evictions / take ownerships = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->evictions[i]), (long)(cache_ptr->take_ownerships[i])); + + HDfprintf(stdout, "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->insertions[i]), (long)(cache_ptr->pinned_insertions[i]), (long)(cache_ptr->moves[i])); - HDfprintf(stdout, - "%s entry / cache flush moves = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->entry_flush_moves[i]), - (long)(cache_ptr->cache_flush_moves[i])); - - HDfprintf(stdout, - "%s size increases / decreases = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->size_increases[i]), - (long)(cache_ptr->size_decreases[i])); - - HDfprintf(stdout, - "%s entry/cache flush size changes = %ld / %ld\n", - cache_ptr->prefix, + HDfprintf(stdout, "%s entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->entry_flush_moves[i]), (long)(cache_ptr->cache_flush_moves[i])); + + HDfprintf(stdout, "%s size increases / decreases = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->size_increases[i]), (long)(cache_ptr->size_decreases[i])); + + HDfprintf(stdout, "%s entry/cache flush size changes = %ld / %ld\n", cache_ptr->prefix, (long)(cache_ptr->entry_flush_size_changes[i]), (long)(cache_ptr->cache_flush_size_changes[i])); + HDfprintf(stdout, "%s entry pins / unpins = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->pins[i]), (long)(cache_ptr->unpins[i])); - HDfprintf(stdout, - "%s entry pins / unpins = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->pins[i]), - (long)(cache_ptr->unpins[i])); - - HDfprintf(stdout, - "%s entry dirty pins/pin'd flushes = %ld / %ld\n", - cache_ptr->prefix, - (long)(cache_ptr->dirty_pins[i]), - (long)(cache_ptr->pinned_flushes[i])); + HDfprintf(stdout, "%s entry dirty pins/pin'd flushes = %ld / %ld\n", cache_ptr->prefix, + (long)(cache_ptr->dirty_pins[i]), (long)(cache_ptr->pinned_flushes[i])); #if H5C_COLLECT_CACHE_ENTRY_STATS - HDfprintf(stdout, - "%s entry max / min accesses = %d / %d\n", - cache_ptr->prefix, - cache_ptr->max_accesses[i], - cache_ptr->min_accesses[i]); - - HDfprintf(stdout, - "%s entry max_clears / max_flushes = %d / %d\n", - cache_ptr->prefix, - cache_ptr->max_clears[i], - cache_ptr->max_flushes[i]); + HDfprintf(stdout, "%s entry max / min accesses = %d / %d\n", cache_ptr->prefix, + cache_ptr->max_accesses[i], cache_ptr->min_accesses[i]); - HDfprintf(stdout, - "%s entry max_size / max_pins = %d / %d\n", - cache_ptr->prefix, - (int)(cache_ptr->max_size[i]), - (int)(cache_ptr->max_pins[i])); + HDfprintf(stdout, "%s entry max_clears / max_flushes = %d / %d\n", cache_ptr->prefix, + cache_ptr->max_clears[i], cache_ptr->max_flushes[i]); + HDfprintf(stdout, "%s entry max_size / max_pins = %d / %d\n", cache_ptr->prefix, + (int)(cache_ptr->max_size[i]), (int)(cache_ptr->max_pins[i])); #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } /* end for */ - } /* end if */ + } /* end if */ HDfprintf(stdout, "\n"); @@ -891,7 +719,6 @@ H5C_stats(H5C_t * cache_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_stats() */ - /*------------------------------------------------------------------------- * * Function: H5C_stats__reset @@ -906,12 +733,12 @@ H5C_stats(H5C_t * cache_ptr, */ void #ifndef NDEBUG -H5C_stats__reset(H5C_t * cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) #else /* NDEBUG */ #if H5C_COLLECT_CACHE_STATS -H5C_stats__reset(H5C_t * cache_ptr) -#else /* H5C_COLLECT_CACHE_STATS */ -H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ #endif /* NDEBUG */ { @@ -923,52 +750,52 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - cache_ptr->hits[i] = 0; - cache_ptr->misses[i] = 0; - cache_ptr->write_protects[i] = 0; - cache_ptr->read_protects[i] = 0; - cache_ptr->max_read_protects[i] = 0; - cache_ptr->insertions[i] = 0; - cache_ptr->pinned_insertions[i] = 0; - cache_ptr->clears[i] = 0; - cache_ptr->flushes[i] = 0; - cache_ptr->evictions[i] = 0; - cache_ptr->take_ownerships[i] = 0; - cache_ptr->moves[i] = 0; - cache_ptr->entry_flush_moves[i] = 0; - cache_ptr->cache_flush_moves[i] = 0; - cache_ptr->pins[i] = 0; - cache_ptr->unpins[i] = 0; - cache_ptr->dirty_pins[i] = 0; - cache_ptr->pinned_flushes[i] = 0; - cache_ptr->pinned_clears[i] = 0; - cache_ptr->size_increases[i] = 0; - cache_ptr->size_decreases[i] = 0; - cache_ptr->entry_flush_size_changes[i] = 0; - cache_ptr->cache_flush_size_changes[i] = 0; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + cache_ptr->hits[i] = 0; + cache_ptr->misses[i] = 0; + cache_ptr->write_protects[i] = 0; + cache_ptr->read_protects[i] = 0; + cache_ptr->max_read_protects[i] = 0; + cache_ptr->insertions[i] = 0; + cache_ptr->pinned_insertions[i] = 0; + cache_ptr->clears[i] = 0; + cache_ptr->flushes[i] = 0; + cache_ptr->evictions[i] = 0; + cache_ptr->take_ownerships[i] = 0; + cache_ptr->moves[i] = 0; + cache_ptr->entry_flush_moves[i] = 0; + cache_ptr->cache_flush_moves[i] = 0; + cache_ptr->pins[i] = 0; + cache_ptr->unpins[i] = 0; + cache_ptr->dirty_pins[i] = 0; + cache_ptr->pinned_flushes[i] = 0; + cache_ptr->pinned_clears[i] = 0; + cache_ptr->size_increases[i] = 0; + cache_ptr->size_decreases[i] = 0; + cache_ptr->entry_flush_size_changes[i] = 0; + cache_ptr->cache_flush_size_changes[i] = 0; } /* end for */ - cache_ptr->total_ht_insertions = 0; - cache_ptr->total_ht_deletions = 0; - cache_ptr->successful_ht_searches = 0; - cache_ptr->total_successful_ht_search_depth = 0; - cache_ptr->failed_ht_searches = 0; - cache_ptr->total_failed_ht_search_depth = 0; + cache_ptr->total_ht_insertions = 0; + cache_ptr->total_ht_deletions = 0; + cache_ptr->successful_ht_searches = 0; + cache_ptr->total_successful_ht_search_depth = 0; + cache_ptr->failed_ht_searches = 0; + cache_ptr->total_failed_ht_search_depth = 0; - cache_ptr->max_index_len = 0; - cache_ptr->max_index_size = (size_t)0; - cache_ptr->max_clean_index_size = (size_t)0; - cache_ptr->max_dirty_index_size = (size_t)0; + cache_ptr->max_index_len = 0; + cache_ptr->max_index_size = (size_t)0; + cache_ptr->max_clean_index_size = (size_t)0; + cache_ptr->max_dirty_index_size = (size_t)0; - cache_ptr->max_slist_len = 0; - cache_ptr->max_slist_size = (size_t)0; + cache_ptr->max_slist_len = 0; + cache_ptr->max_slist_size = (size_t)0; - cache_ptr->max_pl_len = 0; - cache_ptr->max_pl_size = (size_t)0; + cache_ptr->max_pl_len = 0; + cache_ptr->max_pl_size = (size_t)0; - cache_ptr->max_pel_len = 0; - cache_ptr->max_pel_size = (size_t)0; + cache_ptr->max_pel_len = 0; + cache_ptr->max_pel_size = (size_t)0; cache_ptr->calls_to_msic = 0; cache_ptr->total_entries_skipped_in_msic = 0; @@ -979,104 +806,33 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) cache_ptr->max_entries_scanned_in_msic = 0; cache_ptr->entries_scanned_to_make_space = 0; - cache_ptr->slist_scan_restarts = 0; - cache_ptr->LRU_scan_restarts = 0; - cache_ptr->index_scan_restarts = 0; + cache_ptr->slist_scan_restarts = 0; + cache_ptr->LRU_scan_restarts = 0; + cache_ptr->index_scan_restarts = 0; - cache_ptr->images_created = 0; - cache_ptr->images_read = 0; - cache_ptr->images_loaded = 0; - cache_ptr->last_image_size = (hsize_t)0; + cache_ptr->images_created = 0; + cache_ptr->images_read = 0; + cache_ptr->images_loaded = 0; + cache_ptr->last_image_size = (hsize_t)0; - cache_ptr->prefetches = 0; - cache_ptr->dirty_prefetches = 0; - cache_ptr->prefetch_hits = 0; + cache_ptr->prefetches = 0; + cache_ptr->dirty_prefetches = 0; + cache_ptr->prefetch_hits = 0; #if H5C_COLLECT_CACHE_ENTRY_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - cache_ptr->max_accesses[i] = 0; - cache_ptr->min_accesses[i] = 1000000; - cache_ptr->max_clears[i] = 0; - cache_ptr->max_flushes[i] = 0; - cache_ptr->max_size[i] = (size_t)0; - cache_ptr->max_pins[i] = 0; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + cache_ptr->max_accesses[i] = 0; + cache_ptr->min_accesses[i] = 1000000; + cache_ptr->max_clears[i] = 0; + cache_ptr->max_flushes[i] = 0; + cache_ptr->max_size[i] = (size_t)0; + cache_ptr->max_pins[i] = 0; } /* end for */ #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ - - return; } /* H5C_stats__reset() */ -extern void -H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent); - -static void -H5C__dump_parents(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, const char *prefix, int indent) -{ - unsigned u; - - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) - H5C__dump_entry(cache_ptr, entry_ptr->flush_dep_parent[u], TRUE, prefix, indent + 2); -} - -typedef struct H5C__dump_child_ctx_t { - H5C_t *cache_ptr; - const H5C_cache_entry_t *parent; - hbool_t dump_parents; - const char *prefix; - int indent; -} H5C__dump_child_ctx_t; - -static int -H5C__dump_children_cb(H5C_cache_entry_t *entry_ptr, void *_ctx) -{ - H5C__dump_child_ctx_t *ctx = (H5C__dump_child_ctx_t *)_ctx; - - if(entry_ptr->tag_info->tag != entry_ptr->addr) { - unsigned u; - - HDassert(entry_ptr->flush_dep_nparents); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) - if(ctx->parent == entry_ptr->flush_dep_parent[u]) - H5C__dump_entry(ctx->cache_ptr, entry_ptr, ctx->dump_parents, ctx->prefix, ctx->indent + 2); - } /* end if */ - - return(H5_ITER_CONT); -} /* end H5C__dump_children_cb() */ - -static void -H5C__dump_children(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent) -{ - H5C__dump_child_ctx_t ctx; - - HDassert(entry_ptr->tag_info); - - ctx.cache_ptr = cache_ptr; - ctx.parent = entry_ptr; - ctx.dump_parents = dump_parents; - ctx.prefix = prefix; - ctx.indent = indent; - H5C__iter_tagged_entries(cache_ptr, entry_ptr->tag_info->tag, FALSE, H5C__dump_children_cb, &ctx); -} /* end H5C__dump_children() */ - -void -H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, - hbool_t dump_parents, const char *prefix, int indent) -{ - HDassert(cache_ptr); - HDassert(entry_ptr); - - HDfprintf(stderr, "%*s%s: entry_ptr = (%a, '%s', %a, %t, %u, %u/%u)\n", indent, "", prefix, entry_ptr->addr, entry_ptr->type->name, entry_ptr->tag_info ? entry_ptr->tag_info->tag : HADDR_UNDEF, entry_ptr->is_dirty, entry_ptr->flush_dep_nparents, entry_ptr->flush_dep_nchildren, entry_ptr->flush_dep_ndirty_children); - if(dump_parents && entry_ptr->flush_dep_nparents) - H5C__dump_parents(cache_ptr, entry_ptr, "Parent", indent); - if(entry_ptr->flush_dep_nchildren) - H5C__dump_children(cache_ptr, entry_ptr, FALSE, "Child", indent); -} /* end H5C__dump_entry() */ - - /*------------------------------------------------------------------------- * Function: H5C_flush_dependency_exists() * @@ -1104,13 +860,12 @@ H5C__dump_entry(H5C_t *cache_ptr, const H5C_cache_entry_t *entry_ptr, */ #ifndef NDEBUG herr_t -H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, - hbool_t *fd_exists_ptr) +H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, hbool_t *fd_exists_ptr) { - hbool_t fd_exists = FALSE; /* whether flush dependency exists */ - H5C_cache_entry_t * parent_ptr; /* Ptr to parent entry */ - H5C_cache_entry_t * child_ptr; /* Ptr to child entry */ - hbool_t ret_value = FALSE; /* Return value */ + hbool_t fd_exists = FALSE; /* whether flush dependency exists */ + H5C_cache_entry_t *parent_ptr; /* Ptr to parent entry */ + H5C_cache_entry_t *child_ptr; /* Ptr to child entry */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1124,25 +879,25 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL) H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL) - if(parent_ptr && child_ptr) { + if (parent_ptr && child_ptr) { HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(child_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(child_ptr->flush_dep_nparents > 0) { - unsigned u; /* Local index variable */ + if (child_ptr->flush_dep_nparents > 0) { + unsigned u; /* Local index variable */ HDassert(child_ptr->flush_dep_parent); HDassert(child_ptr->flush_dep_parent_nalloc >= child_ptr->flush_dep_nparents); - for(u = 0; u < child_ptr->flush_dep_nparents; u++) { - if(child_ptr->flush_dep_parent[u] == parent_ptr) { + for (u = 0; u < child_ptr->flush_dep_nparents; u++) { + if (child_ptr->flush_dep_parent[u] == parent_ptr) { fd_exists = TRUE; HDassert(parent_ptr->flush_dep_nchildren > 0); break; } /* end if */ - } /* end for */ - } /* end if */ - } /* end if */ + } /* end for */ + } /* end if */ + } /* end if */ *fd_exists_ptr = fd_exists; @@ -1151,7 +906,6 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child } /* H5C_flush_dependency_exists() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_validate_index_list @@ -1172,17 +926,17 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child herr_t H5C_validate_index_list(H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - uint32_t len = 0; - int32_t index_ring_len[H5C_RING_NTYPES]; - size_t size = 0; - size_t clean_size = 0; - size_t dirty_size = 0; - size_t index_ring_size[H5C_RING_NTYPES]; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - int i; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + uint32_t len = 0; + int32_t index_ring_len[H5C_RING_NTYPES]; + size_t size = 0; + size_t clean_size = 0; + size_t dirty_size = 0; + size_t index_ring_size[H5C_RING_NTYPES]; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + int i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1190,89 +944,84 @@ H5C_validate_index_list(H5C_t *cache_ptr) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - for(i = 0; i < H5C_RING_NTYPES; i++) { - index_ring_len[i] = 0; - index_ring_size[i] = 0; - clean_index_ring_size[i] = 0; - dirty_index_ring_size[i] = 0; + for (i = 0; i < H5C_RING_NTYPES; i++) { + index_ring_len[i] = 0; + index_ring_size[i] = 0; + clean_index_ring_size[i] = 0; + dirty_index_ring_size[i] = 0; } /* end if */ - if(((cache_ptr->il_head == NULL) || (cache_ptr->il_tail == NULL)) - && (cache_ptr->il_head != cache_ptr->il_tail)) + if (((cache_ptr->il_head == NULL) || (cache_ptr->il_tail == NULL)) && + (cache_ptr->il_head != cache_ptr->il_tail)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointer validation failed") - if((cache_ptr->index_len == 1) && ((cache_ptr->il_head != cache_ptr->il_tail) - || (cache_ptr->il_head == NULL) || (cache_ptr->il_head->size != cache_ptr->index_size))) + if ((cache_ptr->index_len == 1) && + ((cache_ptr->il_head != cache_ptr->il_tail) || (cache_ptr->il_head == NULL) || + (cache_ptr->il_head->size != cache_ptr->index_size))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointer sanity checks failed") - if((cache_ptr->index_len >= 1) - && ((cache_ptr->il_head == NULL) - || (cache_ptr->il_head->il_prev != NULL) - || (cache_ptr->il_tail == NULL) - || (cache_ptr->il_tail->il_next != NULL))) + if ((cache_ptr->index_len >= 1) && + ((cache_ptr->il_head == NULL) || (cache_ptr->il_head->il_prev != NULL) || + (cache_ptr->il_tail == NULL) || (cache_ptr->il_tail->il_next != NULL))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list length sanity checks failed") entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if((entry_ptr != cache_ptr->il_head) - && ((entry_ptr->il_prev == NULL) || (entry_ptr->il_prev->il_next != entry_ptr))) + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->il_head) && + ((entry_ptr->il_prev == NULL) || (entry_ptr->il_prev->il_next != entry_ptr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointers for entry are invalid") - if((entry_ptr != cache_ptr->il_tail) - && ((entry_ptr->il_next == NULL) || (entry_ptr->il_next->il_prev != entry_ptr))) + if ((entry_ptr != cache_ptr->il_tail) && + ((entry_ptr->il_next == NULL) || (entry_ptr->il_next->il_prev != entry_ptr))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index list pointers for entry are invalid") - HDassert(entry_ptr->ring > 0); - HDassert(entry_ptr->ring < H5C_RING_NTYPES); + HDassert(entry_ptr->ring > 0); + HDassert(entry_ptr->ring < H5C_RING_NTYPES); len++; - index_ring_len[entry_ptr->ring] += 1; + index_ring_len[entry_ptr->ring] += 1; size += entry_ptr->size; index_ring_size[entry_ptr->ring] += entry_ptr->size; - if(entry_ptr->is_dirty) { - dirty_size += entry_ptr->size; - dirty_index_ring_size[entry_ptr->ring] += entry_ptr->size; - } /* end if */ + if (entry_ptr->is_dirty) { + dirty_size += entry_ptr->size; + dirty_index_ring_size[entry_ptr->ring] += entry_ptr->size; + } /* end if */ else { - clean_size += entry_ptr->size; - clean_index_ring_size[entry_ptr->ring] += entry_ptr->size; - } /* end else */ + clean_size += entry_ptr->size; + clean_index_ring_size[entry_ptr->ring] += entry_ptr->size; + } /* end else */ entry_ptr = entry_ptr->il_next; } /* end while */ - if((cache_ptr->index_len != len) || (cache_ptr->il_len != len) - || (cache_ptr->index_size != size) || (cache_ptr->il_size != size) - || (cache_ptr->clean_index_size != clean_size) - || (cache_ptr->dirty_index_size != dirty_size) - || (clean_size + dirty_size != size)) + if ((cache_ptr->index_len != len) || (cache_ptr->il_len != len) || (cache_ptr->index_size != size) || + (cache_ptr->il_size != size) || (cache_ptr->clean_index_size != clean_size) || + (cache_ptr->dirty_index_size != dirty_size) || (clean_size + dirty_size != size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index, clean and dirty sizes for cache are invalid") - size = 0; + size = 0; clean_size = 0; dirty_size = 0; - for(i = 0; i < H5C_RING_NTYPES; i++) { - size += clean_index_ring_size[i] + dirty_index_ring_size[i]; - clean_size += clean_index_ring_size[i]; - dirty_size += dirty_index_ring_size[i]; + for (i = 0; i < H5C_RING_NTYPES; i++) { + size += clean_index_ring_size[i] + dirty_index_ring_size[i]; + clean_size += clean_index_ring_size[i]; + dirty_size += dirty_index_ring_size[i]; } /* end for */ - if((cache_ptr->index_size != size) - || (cache_ptr->clean_index_size != clean_size) - || (cache_ptr->dirty_index_size != dirty_size)) + if ((cache_ptr->index_size != size) || (cache_ptr->clean_index_size != clean_size) || + (cache_ptr->dirty_index_size != dirty_size)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Index, clean and dirty sizes for cache are invalid") done: - if(ret_value != SUCCEED) + if (ret_value != SUCCEED) HDassert(0); FUNC_LEAVE_NOAPI(ret_value) } /* H5C_validate_index_list() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_get_entry_ptr_from_addr() @@ -1313,8 +1062,8 @@ H5C_validate_index_list(H5C_t *cache_ptr) herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1326,7 +1075,7 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -1334,8 +1083,8 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr else { *entry_ptr_ptr = entry_ptr; - /* increment call counter */ - (cache_ptr->get_entry_ptr_from_addr_counter)++; + /* increment call counter */ + (cache_ptr->get_entry_ptr_from_addr_counter)++; } /* end else */ done: @@ -1343,7 +1092,6 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr } /* H5C_get_entry_ptr_from_addr() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C_get_serialization_in_progress * @@ -1371,7 +1119,6 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) } /* H5C_get_serialization_in_progress() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_cache_is_clean() @@ -1393,8 +1140,8 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) hbool_t H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) { - H5C_ring_t ring = H5C_RING_USER; - hbool_t ret_value = TRUE; /* Return value */ + H5C_ring_t ring = H5C_RING_USER; + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1404,11 +1151,11 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) HDassert(inner_ring >= H5C_RING_USER); HDassert(inner_ring <= H5C_RING_SB); - while(ring <= inner_ring) { - if(cache_ptr->dirty_index_ring_size[ring] > 0) + while (ring <= inner_ring) { + if (cache_ptr->dirty_index_ring_size[ring] > 0) HGOTO_DONE(FALSE) - ring++; + ring++; } /* end while */ done: @@ -1416,7 +1163,6 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) } /* H5C_cache_is_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * * Function: H5C_verify_entry_type() @@ -1444,12 +1190,11 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) */ #ifndef NDEBUG herr_t -H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, - const H5C_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr) +H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expected_type, hbool_t *in_cache_ptr, + hbool_t *type_ok_ptr) { - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1463,7 +1208,7 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -1471,14 +1216,13 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, else { *in_cache_ptr = TRUE; - if(entry_ptr->prefetched) - *type_ok_ptr = (expected_type->id == entry_ptr->prefetch_type_id); - else - *type_ok_ptr = (expected_type == entry_ptr->type); + if (entry_ptr->prefetched) + *type_ok_ptr = (expected_type->id == entry_ptr->prefetch_type_id); + else + *type_ok_ptr = (expected_type == entry_ptr->type); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_entry_type() */ #endif /* NDEBUG */ - diff --git a/src/H5Cepoch.c b/src/H5Cepoch.c index 645101952c5..3434feddcc7 100644 --- a/src/H5Cepoch.c +++ b/src/H5Cepoch.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,24 +22,20 @@ *------------------------------------------------------------------------- */ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -54,42 +50,34 @@ * epochs so that they can be evicted from the cache. * ****************************************************************************/ -static herr_t H5C__epoch_marker_get_initial_load_size(void *udata_ptr, - size_t *image_len_ptr); -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, 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, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -static herr_t H5C__epoch_marker_serialize(const H5F_t *f, - void * image_ptr, size_t len, void * thing); +static herr_t H5C__epoch_marker_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); +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, + 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, + haddr_t *new_addr_ptr, size_t *new_len_ptr, + unsigned *flags_ptr); +static herr_t H5C__epoch_marker_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); 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); - +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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ /* id = */ H5AC_EPOCH_MARKER_ID, /* name = */ "epoch marker", @@ -107,7 +95,6 @@ const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ /* fsf_size = */ H5C__epoch_marker_fsf_size, }}; - /*************************************************************************** * Class functions for H5C__EPOCH_MAKER_TYPE: * @@ -117,124 +104,109 @@ const H5AC_class_t H5AC_EPOCH_MARKER[1] = {{ * ***************************************************************************/ - static herr_t -H5C__epoch_marker_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__epoch_marker_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 */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_get_initial_load_size() */ - static herr_t -H5C__epoch_marker_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *actual_len) +H5C__epoch_marker_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED image_len, + void H5_ATTR_UNUSED *udata_ptr, size_t H5_ATTR_UNUSED *actual_len) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_final_get_load_size() */ - static htri_t H5C__epoch_marker_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, - void H5_ATTR_UNUSED *udata_ptr) + void H5_ATTR_UNUSED *udata_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FALSE) } /* end H5C__epoch_marker_verify_chksum() */ - static void * -H5C__epoch_marker_deserialize(const void H5_ATTR_UNUSED * image_ptr, size_t H5_ATTR_UNUSED len, - void H5_ATTR_UNUSED * udata, hbool_t H5_ATTR_UNUSED * dirty_ptr) +H5C__epoch_marker_deserialize(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata, hbool_t H5_ATTR_UNUSED *dirty_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(NULL) } /* end H5C__epoch_marker_deserialize() */ - static herr_t -H5C__epoch_marker_image_len(const void H5_ATTR_UNUSED *thing, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__epoch_marker_image_len(const void H5_ATTR_UNUSED *thing, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_image_len() */ - static herr_t -H5C__epoch_marker_pre_serialize(H5F_t H5_ATTR_UNUSED *f, - void H5_ATTR_UNUSED *thing, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, - haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, - unsigned H5_ATTR_UNUSED *flags_ptr) +H5C__epoch_marker_pre_serialize(H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *thing, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, + haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, + unsigned H5_ATTR_UNUSED *flags_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_pre_serialize() */ - static herr_t H5C__epoch_marker_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_serialize() */ - static herr_t -H5C__epoch_marker_notify(H5C_notify_action_t H5_ATTR_UNUSED action, - void H5_ATTR_UNUSED * thing) +H5C__epoch_marker_notify(H5C_notify_action_t H5_ATTR_UNUSED action, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_notify() */ - static herr_t -H5C__epoch_marker_free_icr(void H5_ATTR_UNUSED * thing) +H5C__epoch_marker_free_icr(void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_free_icr() */ - static herr_t -H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED * thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) +H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED *thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__epoch_marker_fsf_size() */ - diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 0373098f581..f17ff485b26 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,68 +27,64 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#define H5AC_FRIEND /*suppress error about including H5ACpkg */ +#include "H5ACpkg.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ #if H5C_DO_MEMORY_SANITY_CHECKS -#define H5C_IMAGE_EXTRA_SPACE 8 +#define H5C_IMAGE_EXTRA_SPACE 8 #define H5C_IMAGE_SANITY_VALUE "DeadBeef" #else /* H5C_DO_MEMORY_SANITY_CHECKS */ #define H5C_IMAGE_EXTRA_SPACE 0 #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Cache image buffer components, on disk */ -#define H5C__MDCI_BLOCK_SIGNATURE "MDCI" -#define H5C__MDCI_BLOCK_SIGNATURE_LEN 4 -#define H5C__MDCI_BLOCK_VERSION_0 0 +#define H5C__MDCI_BLOCK_SIGNATURE "MDCI" +#define H5C__MDCI_BLOCK_SIGNATURE_LEN 4 +#define H5C__MDCI_BLOCK_VERSION_0 0 /* Metadata cache image header flags -- max 8 bits */ -#define H5C__MDCI_HEADER_HAVE_RESIZE_STATUS 0x01 +#define H5C__MDCI_HEADER_HAVE_RESIZE_STATUS 0x01 /* Metadata cache image entry flags -- max 8 bits */ -#define H5C__MDCI_ENTRY_DIRTY_FLAG 0x01 -#define H5C__MDCI_ENTRY_IN_LRU_FLAG 0x02 -#define H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG 0x04 -#define H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG 0x08 +#define H5C__MDCI_ENTRY_DIRTY_FLAG 0x01 +#define H5C__MDCI_ENTRY_IN_LRU_FLAG 0x02 +#define H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG 0x04 +#define H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG 0x08 /* Limits on flush dependency values, stored in 16-bit values on disk */ -#define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX -#define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX +#define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX +#define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX /* Values for image entry magic field */ -#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08 -#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead +#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08 +#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead /* Maximum ring allowed in image */ -#define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM - +#define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -96,33 +92,27 @@ /* Helper routines */ static size_t H5C__cache_image_block_entry_header_size(const H5F_t *f); static size_t H5C__cache_image_block_header_size(const H5F_t *f); -static herr_t H5C__decode_cache_image_header(const H5F_t *f, - H5C_t *cache_ptr, const uint8_t **buf); -#ifndef NDEBUG /* only used in assertions */ -static herr_t H5C__decode_cache_image_entry(const H5F_t *f, - const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num); +static herr_t H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf); +#ifndef NDEBUG /* only used in assertions */ +static herr_t H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, + unsigned entry_num); #endif /* NDEBUG */ /* only used in assertions */ -static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, - H5C_cache_entry_t *pf_entry_ptr, H5C_cache_entry_t **fd_children); -static herr_t H5C__encode_cache_image_header(const H5F_t *f, - const H5C_t *cache_ptr, uint8_t **buf); -static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, - uint8_t **buf, unsigned entry_num); +static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children); +static herr_t H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf); +static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num); static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr); -static void H5C__prep_for_file_close__compute_fd_heights_real( - H5C_cache_entry_t *entry_ptr, uint32_t fd_height); +static void H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, + uint32_t fd_height); static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr); -static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, - H5C_t *cache_ptr); +static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr); static herr_t H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr); -static H5C_cache_entry_t *H5C__reconstruct_cache_entry(const H5F_t *f, - H5C_t *cache_ptr, const uint8_t **buf); -static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create); -static herr_t H5C__read_cache_image(H5F_t * f, H5C_t *cache_ptr); -static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr); -static herr_t H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr); -static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); - +static H5C_cache_entry_t *H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf); +static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create); +static herr_t H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr); +static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr); +static herr_t H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr); +static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); /*********************/ /* Package Variables */ @@ -131,17 +121,14 @@ static herr_t H5C__free_image_entries_array(H5C_t *cache_ptr); /* Declare a free list to manage H5C_cache_entry_t objects */ H5FL_DEFINE(H5C_cache_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * * Function: H5C_cache_image_pending() @@ -162,7 +149,7 @@ H5FL_DEFINE(H5C_cache_entry_t); hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -175,7 +162,6 @@ H5C_cache_image_pending(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_cache_image_pending() */ - /*------------------------------------------------------------------------- * Function: H5C_cache_image_status() * @@ -199,9 +185,9 @@ H5C_cache_image_pending(const H5C_t *cache_ptr) *------------------------------------------------------------------------- */ herr_t -H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) +H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -214,13 +200,12 @@ H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) HDassert(load_ci_ptr); HDassert(write_ci_ptr); - *load_ci_ptr = cache_ptr->load_image || cache_ptr->image_loaded; + *load_ci_ptr = cache_ptr->load_image || cache_ptr->image_loaded; *write_ci_ptr = cache_ptr->image_ctl.generate_image; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_cache_image_status() */ - /*------------------------------------------------------------------------- * Function: H5C__construct_cache_image_buffer() * @@ -238,12 +223,12 @@ H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) *------------------------------------------------------------------------- */ static herr_t -H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) +H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) { - uint8_t * p; /* Pointer into image buffer */ - uint32_t chksum; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p; /* Pointer into image buffer */ + uint32_t chksum; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -261,25 +246,26 @@ H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) HDassert(cache_ptr->image_data_len <= cache_ptr->image_len); /* Allocate the buffer in which to construct the cache image block */ - if(NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") + if (NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") /* Construct the cache image block header image */ p = (uint8_t *)cache_ptr->image_buffer; - if(H5C__encode_cache_image_header(f, cache_ptr, &p) < 0) + if (H5C__encode_cache_image_header(f, cache_ptr, &p) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTENCODE, FAIL, "header image construction failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_data_len); /* Construct the cache entry images */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) - if(H5C__encode_cache_image_entry(f, cache_ptr, &p, u) < 0) + for (u = 0; u < cache_ptr->num_entries_in_image; u++) + if (H5C__encode_cache_image_entry(f, cache_ptr, &p, u) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTENCODE, FAIL, "entry image construction failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_data_len); /* Construct the adaptive resize status image -- not yet */ /* Compute the checksum and encode */ - chksum = H5_checksum_metadata(cache_ptr->image_buffer, (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); + chksum = H5_checksum_metadata(cache_ptr->image_buffer, + (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); UINT32ENCODE(p, chksum); HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) == cache_ptr->image_data_len); HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) <= cache_ptr->image_len); @@ -289,92 +275,99 @@ H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) * and comparing the result with the original data. */ { - uint32_t old_chksum; - const uint8_t * q; - H5C_t * fake_cache_ptr = NULL; - unsigned v; - herr_t status; /* Status from decoding */ + uint32_t old_chksum; + const uint8_t *q; + H5C_t * fake_cache_ptr = NULL; + unsigned v; + herr_t status; /* Status from decoding */ - fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t)); + fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t)); HDassert(fake_cache_ptr); fake_cache_ptr->magic = H5C__H5C_T_MAGIC; - /* needed for sanity checks */ - fake_cache_ptr->image_len = cache_ptr->image_len; - q = (const uint8_t *)cache_ptr->image_buffer; - status = H5C__decode_cache_image_header(f, fake_cache_ptr, &q); + /* needed for sanity checks */ + fake_cache_ptr->image_len = cache_ptr->image_len; + q = (const uint8_t *)cache_ptr->image_buffer; + status = H5C__decode_cache_image_header(f, fake_cache_ptr, &q); HDassert(status >= 0); HDassert(NULL != p); HDassert(fake_cache_ptr->num_entries_in_image == cache_ptr->num_entries_in_image); - fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_malloc(sizeof(H5C_image_entry_t) * - (size_t)(fake_cache_ptr->num_entries_in_image + 1)); - HDassert(fake_cache_ptr->image_entries); + fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_malloc( + sizeof(H5C_image_entry_t) * (size_t)(fake_cache_ptr->num_entries_in_image + 1)); + HDassert(fake_cache_ptr->image_entries); - for(u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { - (fake_cache_ptr->image_entries)[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; + for (u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { + (fake_cache_ptr->image_entries)[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; (fake_cache_ptr->image_entries)[u].image_ptr = NULL; - /* touch up f->shared->cache to satisfy sanity checks... */ + /* touch up f->shared->cache to satisfy sanity checks... */ f->shared->cache = fake_cache_ptr; - status = H5C__decode_cache_image_entry(f, fake_cache_ptr, &q, u); - HDassert(status >= 0); + status = H5C__decode_cache_image_entry(f, fake_cache_ptr, &q, u); + HDassert(status >= 0); - /* ...and then return f->shared->cache to its correct value */ + /* ...and then return f->shared->cache to its correct value */ f->shared->cache = cache_ptr; - /* verify expected contents */ - HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); - HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); - HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); - HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); - HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); - /* don't check image_fd_height as it is not stored in + /* verify expected contents */ + HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); + HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); + HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); + HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); + HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); + /* don't check image_fd_height as it is not stored in * the metadata cache image block. */ - HDassert((cache_ptr->image_entries)[u].fd_child_count == (fake_cache_ptr->image_entries)[u].fd_child_count); - HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); - HDassert((cache_ptr->image_entries)[u].fd_parent_count == (fake_cache_ptr->image_entries)[u].fd_parent_count); - - for(v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) - HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); - - /* free the fd_parent_addrs array if it exists */ - if((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); - (fake_cache_ptr->image_entries)[u].fd_parent_addrs = (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); - (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; - } /* end if */ + HDassert((cache_ptr->image_entries)[u].fd_child_count == + (fake_cache_ptr->image_entries)[u].fd_child_count); + HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == + (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); + HDassert((cache_ptr->image_entries)[u].fd_parent_count == + (fake_cache_ptr->image_entries)[u].fd_parent_count); + + for (v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) + HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == + (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); + + /* free the fd_parent_addrs array if it exists */ + if ((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { + HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); + (fake_cache_ptr->image_entries)[u].fd_parent_addrs = + (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); + (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; + } /* end if */ else - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); + HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); - HDassert((cache_ptr->image_entries)[u].image_ptr); + HDassert((cache_ptr->image_entries)[u].image_ptr); HDassert((fake_cache_ptr->image_entries)[u].image_ptr); HDassert(!HDmemcmp((cache_ptr->image_entries)[u].image_ptr, (fake_cache_ptr->image_entries)[u].image_ptr, (cache_ptr->image_entries)[u].size)); - (fake_cache_ptr->image_entries)[u].image_ptr = H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); - } /* end for */ + (fake_cache_ptr->image_entries)[u].image_ptr = + H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); + } /* end for */ - HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM); + HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == + cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM); /* 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); - HDassert(chksum == old_chksum); + chksum = H5_checksum_metadata(cache_ptr->image_buffer, + (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); - fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr); - } /* end block */ + fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries); + fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr); + } /* end block */ #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__construct_cache_image_buffer() */ - /*------------------------------------------------------------------------- * Function: H5C__generate_cache_image() * @@ -391,7 +384,7 @@ H5C__construct_cache_image_buffer(H5F_t * f, H5C_t *cache_ptr) herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -403,16 +396,16 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Construct cache image */ - if(H5C__construct_cache_image_buffer(f, cache_ptr) < 0) + if (H5C__construct_cache_image_buffer(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't create metadata cache image") /* Free image entries array */ - if(H5C__free_image_entries_array(cache_ptr) < 0) + if (H5C__free_image_entries_array(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't free image entries array") /* Write cache image block if so configured */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) { - if(H5C__write_cache_image(f, cache_ptr) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) { + if (H5C__write_cache_image(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write metadata cache image block to file") H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr); @@ -426,7 +419,6 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__generate_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C__deserialize_prefetched_entry() * @@ -461,36 +453,34 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) * * Programmer: John Mainzer, 8/10/15 * - * Changes: Updated sanity checks for possibility that the slist + * Changes: Updated sanity checks for possibility that the slist * is disabled. * JRM -- 5/17/20 * *------------------------------------------------------------------------- */ herr_t -H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t **entry_ptr_ptr, const H5C_class_t *type, - haddr_t addr, void *udata) +H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, + const H5C_class_t *type, haddr_t addr, void *udata) { - hbool_t dirty = FALSE; /* Flag indicating whether thing was - * dirtied during deserialize - */ - size_t len; /* Size of image in file */ - 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 - * entry - */ - H5C_cache_entry_t** fd_children = NULL; /* Pointer to a dynamically */ - /* allocated array of pointers to */ - /* the flush dependency children of */ - /* the prefetched entry, or NULL if */ - /* that array does not exist. */ - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG); - int i; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t dirty = FALSE; /* Flag indicating whether thing was + * dirtied during deserialize + */ + size_t len; /* Size of image in file */ + 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 + * entry + */ + H5C_cache_entry_t **fd_children = NULL; /* Pointer to a dynamically */ + /* allocated array of pointers to */ + /* the flush dependency children of */ + /* the prefetched entry, or NULL if */ + /* that array does not exist. */ + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + int i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -521,8 +511,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, /* Can't see how skip reads could be usefully combined with * either the speculative read flag. Hence disallow. */ - HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && - (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); HDassert(H5F_addr_defined(addr)); HDassert(type->get_initial_load_size); HDassert(type->deserialize); @@ -532,7 +521,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * the deserialized entry if appropriate. */ HDassert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); - for(i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { + for (i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { HDassert(pf_entry_ptr->flush_dep_parent); HDassert(pf_entry_ptr->flush_dep_parent[i]); HDassert(pf_entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -540,7 +529,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, HDassert(pf_entry_ptr->fd_parent_addrs); HDassert(pf_entry_ptr->flush_dep_parent[i]->addr == pf_entry_ptr->fd_parent_addrs[i]); - if(H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) + if (H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry parent flush dependency") pf_entry_ptr->fd_parent_addrs[i] = HADDR_UNDEF; @@ -557,12 +546,14 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * pointers to the flush dependency children of *pf_enty_ptr for later * use. */ - if(pf_entry_ptr->fd_child_count > 0) { - if(NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc(sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) + if (pf_entry_ptr->fd_child_count > 0) { + if (NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc( + sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") - if(H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry child flush dependency(s).") + if (H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency(s).") } /* end if */ /* Since the size of the on disk image is known exactly, there is @@ -576,7 +567,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, /* Deserialize the prefetched on-disk image of the entry into the * native memory form */ - if(NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) + if (NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image") ds_entry_ptr = (H5C_cache_entry_t *)thing; @@ -606,33 +597,33 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * hence the value assigned to ds_entry_ptr->is_dirty below. */ - HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6) ); + HDassert((dirty == FALSE) || (type->id == 5 || type->id == 6)); - ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - ds_entry_ptr->cache_ptr = f->shared->cache; - ds_entry_ptr->addr = addr; - ds_entry_ptr->size = len; + ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + ds_entry_ptr->cache_ptr = f->shared->cache; + ds_entry_ptr->addr = addr; + ds_entry_ptr->size = len; HDassert(ds_entry_ptr->size < H5C_MAX_ENTRY_SIZE); - ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; - ds_entry_ptr->image_up_to_date = !dirty; - ds_entry_ptr->type = type; - ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; - ds_entry_ptr->dirtied = FALSE; - ds_entry_ptr->is_protected = FALSE; - ds_entry_ptr->is_read_only = FALSE; - ds_entry_ptr->ro_ref_count = 0; - ds_entry_ptr->is_pinned = FALSE; - ds_entry_ptr->in_slist = FALSE; - ds_entry_ptr->flush_marker = FALSE; + ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; + ds_entry_ptr->image_up_to_date = !dirty; + ds_entry_ptr->type = type; + ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; + ds_entry_ptr->dirtied = FALSE; + ds_entry_ptr->is_protected = FALSE; + ds_entry_ptr->is_read_only = FALSE; + ds_entry_ptr->ro_ref_count = 0; + ds_entry_ptr->is_pinned = FALSE; + ds_entry_ptr->in_slist = FALSE; + ds_entry_ptr->flush_marker = FALSE; #ifdef H5_HAVE_PARALLEL - ds_entry_ptr->clear_on_unprotect = FALSE; - ds_entry_ptr->flush_immediately = FALSE; - ds_entry_ptr->coll_access = FALSE; + ds_entry_ptr->clear_on_unprotect = FALSE; + ds_entry_ptr->flush_immediately = FALSE; + ds_entry_ptr->coll_access = FALSE; #endif /* H5_HAVE_PARALLEL */ - ds_entry_ptr->flush_in_progress = FALSE; - ds_entry_ptr->destroy_in_progress = FALSE; + ds_entry_ptr->flush_in_progress = FALSE; + ds_entry_ptr->destroy_in_progress = FALSE; - ds_entry_ptr->ring = pf_entry_ptr->ring; + ds_entry_ptr->ring = pf_entry_ptr->ring; /* Initialize flush dependency height fields */ ds_entry_ptr->flush_dep_parent = NULL; @@ -643,44 +634,44 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, ds_entry_ptr->flush_dep_nunser_children = 0; /* Initialize fields supporting the hash table: */ - ds_entry_ptr->ht_next = NULL; - ds_entry_ptr->ht_prev = NULL; - ds_entry_ptr->il_next = NULL; - ds_entry_ptr->il_prev = NULL; + ds_entry_ptr->ht_next = NULL; + ds_entry_ptr->ht_prev = NULL; + ds_entry_ptr->il_next = NULL; + ds_entry_ptr->il_prev = NULL; /* Initialize fields supporting replacement policies: */ - ds_entry_ptr->next = NULL; - ds_entry_ptr->prev = NULL; + ds_entry_ptr->next = NULL; + ds_entry_ptr->prev = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - ds_entry_ptr->aux_next = NULL; - ds_entry_ptr->aux_prev = NULL; + ds_entry_ptr->aux_next = NULL; + ds_entry_ptr->aux_prev = NULL; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - pf_entry_ptr->coll_next = NULL; - pf_entry_ptr->coll_prev = NULL; + pf_entry_ptr->coll_next = NULL; + pf_entry_ptr->coll_prev = NULL; #endif /* H5_HAVE_PARALLEL */ /* Initialize cache image related fields */ - ds_entry_ptr->include_in_image = FALSE; - ds_entry_ptr->lru_rank = 0; - ds_entry_ptr->image_dirty = FALSE; - ds_entry_ptr->fd_parent_count = 0; - ds_entry_ptr->fd_parent_addrs = NULL; - ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; - ds_entry_ptr->fd_dirty_child_count = 0; - ds_entry_ptr->image_fd_height = 0; - ds_entry_ptr->prefetched = FALSE; - ds_entry_ptr->prefetch_type_id = 0; - ds_entry_ptr->age = 0; - ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; -#ifndef NDEBUG /* debugging field */ - ds_entry_ptr->serialization_count = 0; + ds_entry_ptr->include_in_image = FALSE; + ds_entry_ptr->lru_rank = 0; + ds_entry_ptr->image_dirty = FALSE; + ds_entry_ptr->fd_parent_count = 0; + ds_entry_ptr->fd_parent_addrs = NULL; + ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; + ds_entry_ptr->fd_dirty_child_count = 0; + ds_entry_ptr->image_fd_height = 0; + ds_entry_ptr->prefetched = FALSE; + ds_entry_ptr->prefetch_type_id = 0; + ds_entry_ptr->age = 0; + ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; +#ifndef NDEBUG /* debugging field */ + ds_entry_ptr->serialization_count = 0; #endif /* NDEBUG */ H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr); /* Apply to to the newly deserialized entry */ - if(H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) + if (H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") /* We have successfully deserialized the prefetched entry. @@ -705,16 +696,16 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, */ pf_entry_ptr->image_ptr = NULL; - if ( pf_entry_ptr->is_dirty ) { + if (pf_entry_ptr->is_dirty) { - HDassert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) || \ + HDassert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) || ((!cache_ptr->slist_enabled) && (!pf_entry_ptr->in_slist))); flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; } /* end if */ - if(H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) + if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't expunge prefetched entry") #ifndef NDEGUG /* verify deletion */ @@ -727,7 +718,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL) HDassert(!ds_entry_ptr->in_slist); - if(ds_entry_ptr->is_dirty) + if (ds_entry_ptr->is_dirty) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL) H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, ds_entry_ptr, FAIL) @@ -737,8 +728,8 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * send an "after load" notice now that the deserialized entry is fully * integrated into the cache. */ - if(ds_entry_ptr->type->notify && - (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) + if (ds_entry_ptr->type->notify && + (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache") /* Restore flush dependencies with the flush dependency children of @@ -747,10 +738,10 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, * then unprotect it afterwards. */ i = 0; - if(fd_children != NULL) { + if (fd_children != NULL) { H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL) ds_entry_ptr->is_protected = TRUE; - while(fd_children[i] != NULL) { + while (fd_children[i] != NULL) { /* Sanity checks */ HDassert((fd_children[i])->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert((fd_children[i])->prefetched); @@ -759,13 +750,13 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, #ifndef NDEBUG { - int j; + int j; hbool_t found; - j = 0; + j = 0; found = FALSE; - while((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { - if((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) + while ((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { + if ((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) found = TRUE; j++; @@ -774,7 +765,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, } #endif /* NDEBUG */ - if(H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) + if (H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency") i++; @@ -792,18 +783,17 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, *entry_ptr_ptr = ds_entry_ptr; done: - if(fd_children) + if (fd_children) fd_children = (H5C_cache_entry_t **)H5MM_xfree((void *)fd_children); /* Release resources on error */ - if(FAIL == ret_value) - if(thing && type->free_icr(thing) < 0) + if (FAIL == ret_value) + if (thing && type->free_icr(thing) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") FUNC_LEAVE_NOAPI(ret_value) } /* H5C__deserialize_prefetched_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__free_image_entries_array * @@ -822,7 +812,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__free_image_entries_array(H5C_t * cache_ptr) +H5C__free_image_entries_array(H5C_t *cache_ptr) { FUNC_ENTER_STATIC_NOERR @@ -834,92 +824,43 @@ H5C__free_image_entries_array(H5C_t * cache_ptr) HDassert(cache_ptr->index_len == 0); /* Check for entries to free */ - if(cache_ptr->image_entries != NULL) { - unsigned u; /* Local index variable */ + if (cache_ptr->image_entries != NULL) { + unsigned u; /* Local index variable */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) { - H5C_image_entry_t *ie_ptr; /* Image entry to release */ + for (u = 0; u < cache_ptr->num_entries_in_image; u++) { + H5C_image_entry_t *ie_ptr; /* Image entry to release */ /* Get pointer to image entry */ - ie_ptr = &((cache_ptr->image_entries)[u]); + ie_ptr = &((cache_ptr->image_entries)[u]); /* Sanity checks */ - HDassert(ie_ptr); + HDassert(ie_ptr); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); - HDassert(ie_ptr->image_ptr); + HDassert(ie_ptr->image_ptr); - /* Free the parent addrs array if appropriate */ - if(ie_ptr->fd_parent_addrs) { - HDassert(ie_ptr->fd_parent_count > 0); + /* Free the parent addrs array if appropriate */ + if (ie_ptr->fd_parent_addrs) { + HDassert(ie_ptr->fd_parent_count > 0); - ie_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(ie_ptr->fd_parent_addrs); + ie_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(ie_ptr->fd_parent_addrs); } /* end if */ else - HDassert(ie_ptr->fd_parent_count == 0); + HDassert(ie_ptr->fd_parent_count == 0); /* Free the image */ ie_ptr->image_ptr = H5MM_xfree(ie_ptr->image_ptr); - /* Set magic field to bad magic so we can detect freed entries */ - ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC; - } /* end for */ + /* Set magic field to bad magic so we can detect freed entries */ + ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC; + } /* end for */ - /* Free the image entries array */ - cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(cache_ptr->image_entries); + /* Free the image entries array */ + cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(cache_ptr->image_entries); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C__free_image_entries_array() */ - -/*------------------------------------------------------------------------- - * Function: H5C_force_cache_image_load() - * - * Purpose: On rare occasions, it is necessary to run - * H5MF_tidy_self_referential_fsm_hack() prior to the first - * metadata cache access. This is a problem as if there is a - * cache image at the end of the file, that routine will - * discard it. - * - * We solve this issue by calling this function, which will - * load the cache image and then call - * H5MF_tidy_self_referential_fsm_hack() to discard it. - * - * Return: SUCCEED on success, and FAIL on failure. - * - * Programmer: John Mainzer - * 1/11/17 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_force_cache_image_load(H5F_t *f) -{ - H5C_t *cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->load_image); - - /* Load the cache image, if requested */ - if(cache_ptr->load_image) { - cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_force_cache_image_load() */ - - /*------------------------------------------------------------------------- * Function: H5C_get_cache_image_config * @@ -935,16 +876,15 @@ H5C_force_cache_image_load(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_image_config(const H5C_t * cache_ptr, - H5C_cache_image_ctl_t *config_ptr) +H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad config_ptr on entry") *config_ptr = cache_ptr->image_ctl; @@ -953,7 +893,6 @@ H5C_get_cache_image_config(const H5C_t * cache_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_image_config() */ - /*------------------------------------------------------------------------- * Function: H5C_image_stats * @@ -968,66 +907,58 @@ H5C_get_cache_image_config(const H5C_t * cache_ptr, */ herr_t #if H5C_COLLECT_CACHE_STATS -H5C_image_stats(H5C_t * cache_ptr, hbool_t print_header) -#else /* H5C_COLLECT_CACHE_STATS */ -H5C_image_stats(H5C_t * cache_ptr, hbool_t H5_ATTR_UNUSED print_header) +H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C_image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) #endif /* H5C_COLLECT_CACHE_STATS */ { #if H5C_COLLECT_CACHE_STATS - int i; - int64_t total_hits = 0; - int64_t total_misses = 0; - double hit_rate; - double prefetch_use_rate; -#endif /* H5C_COLLECT_CACHE_STATS */ - herr_t ret_value = SUCCEED; /* Return value */ + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + double hit_rate; + double prefetch_use_rate; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC) + if (!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") #if H5C_COLLECT_CACHE_STATS - for(i = 0; i <= cache_ptr->max_type_id; i++) { - total_hits += cache_ptr->hits[i]; - total_misses += cache_ptr->misses[i]; + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; } /* end for */ - if((total_hits > 0) || (total_misses > 0)) - hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); + if ((total_hits > 0) || (total_misses > 0)) + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); else - hit_rate = 0.0f; + hit_rate = 0.0; - if(cache_ptr->prefetches > 0) - prefetch_use_rate = (double)100.0f * ((double)(cache_ptr->prefetch_hits)) / - ((double)(cache_ptr->prefetches)); + if (cache_ptr->prefetches > 0) + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); else - prefetch_use_rate = 0.0f; + prefetch_use_rate = 0.0; - if(print_header) { - HDfprintf(stdout, - "\nhit prefetches prefetch image pf hit\n"); - HDfprintf(stdout, - "rate: total: dirty: hits: flshs: evct: size: rate:\n"); + if (print_header) { + HDfprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); + HDfprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n"); } /* end if */ - HDfprintf(stdout, - "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", - hit_rate, - (long long)(cache_ptr->prefetches), - (long long)(cache_ptr->dirty_prefetches), - (long long)(cache_ptr->prefetch_hits), - (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->last_image_size), - prefetch_use_rate); + HDfprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches), + (long long)(cache_ptr->prefetch_hits), + (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->last_image_size), prefetch_use_rate); #endif /* H5C_COLLECT_CACHE_STATS */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_image_stats() */ - /*------------------------------------------------------------------------- * Function: H5C__read_cache_image * @@ -1044,7 +975,7 @@ H5C_image_stats(H5C_t * cache_ptr, hbool_t H5_ATTR_UNUSED print_header) static herr_t H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1056,55 +987,48 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->image_buffer); #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - int mpi_result; + { + H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; + int mpi_result; - if ( ( NULL == aux_ptr ) || ( aux_ptr->mpi_rank == 0 ) ) { + if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || - (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ - /* Read the buffer (if serial access, or rank 0 of parallel access) */ - 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") + /* Read the buffer (if serial access, or rank 0 of parallel access) */ + 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") - H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) + H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) #ifdef H5_HAVE_PARALLEL - if ( aux_ptr ) { + if (aux_ptr) { - /* Broadcast cache image */ - if ( MPI_SUCCESS != - (mpi_result = MPI_Bcast(cache_ptr->image_buffer, - (int)cache_ptr->image_len, MPI_BYTE, - 0, aux_ptr->mpi_comm)) ) + /* Broadcast cache image */ + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, + MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) + HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - } /* end if */ - } /* end if */ - else if ( aux_ptr ) { - - /* Retrieve the contents of the metadata cache image from process 0 */ - if ( MPI_SUCCESS != - (mpi_result = MPI_Bcast(cache_ptr->image_buffer, - (int)cache_ptr->image_len, MPI_BYTE, - 0, aux_ptr->mpi_comm)) ) - - HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", \ - mpi_result) - } /* end else-if */ -} /* end block */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end if */ + else if (aux_ptr) { + + /* Retrieve the contents of the metadata cache image from process 0 */ + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, + MPI_BYTE, 0, aux_ptr->mpi_comm))) + + HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", mpi_result) + } /* end else-if */ + } /* end block */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__read_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C__load_cache_image * @@ -1125,8 +1049,8 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) herr_t H5C__load_cache_image(H5F_t *f) { - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1146,21 +1070,21 @@ H5C__load_cache_image(H5F_t *f) * no image exists, and that the load operation should be skipped * silently. */ - if(H5F_addr_defined(cache_ptr->image_addr)) { + if (H5F_addr_defined(cache_ptr->image_addr)) { /* Sanity checks */ HDassert(cache_ptr->image_len > 0); HDassert(cache_ptr->image_buffer == NULL); /* Allocate space for the image */ - if(NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) + if (NULL == (cache_ptr->image_buffer = H5MM_malloc(cache_ptr->image_len + 1))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for cache image buffer") /* Load the image from file */ - if(H5C__read_cache_image(f, cache_ptr) < 0) + if (H5C__read_cache_image(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") /* Reconstruct cache contents, from image */ - if(H5C__reconstruct_cache_contents(f, cache_ptr) < 0) + if (H5C__reconstruct_cache_contents(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDECODE, FAIL, "Can't reconstruct cache contents from image block") /* Free the image buffer */ @@ -1175,21 +1099,21 @@ H5C__load_cache_image(H5F_t *f) } /* end if */ /* If directed, free the on disk metadata cache image */ - if(cache_ptr->delete_image) { - if(H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove metadata cache image message from superblock extension") + if (cache_ptr->delete_image) { + if (H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove metadata cache image message from superblock extension") /* Reset image block values */ - cache_ptr->image_len = 0; + cache_ptr->image_len = 0; cache_ptr->image_data_len = 0; - cache_ptr->image_addr = HADDR_UNDEF; + cache_ptr->image_addr = HADDR_UNDEF; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__load_cache_image() */ - /*------------------------------------------------------------------------- * Function: H5C_load_cache_image_on_next_protect() * @@ -1219,8 +1143,7 @@ H5C__load_cache_image(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, - hbool_t rw) +H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw) { H5C_t *cache_ptr; @@ -1234,7 +1157,7 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Set information needed to load cache image */ - cache_ptr->image_addr = addr, + cache_ptr->image_addr = addr; cache_ptr->image_len = len; cache_ptr->load_image = TRUE; cache_ptr->delete_image = rw; @@ -1242,7 +1165,6 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_load_cache_image_on_next_protect() */ - /*------------------------------------------------------------------------- * Function: H5C__image_entry_cmp * @@ -1268,9 +1190,11 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, static int H5C__image_entry_cmp(const void *_entry1, const void *_entry2) { - const H5C_image_entry_t *entry1 = (const H5C_image_entry_t *)_entry1; /* Pointer to first image entry to compare */ - const H5C_image_entry_t *entry2 = (const H5C_image_entry_t *)_entry2; /* Pointer to second image entry to compare */ - int ret_value = 0; /* Return value */ + const H5C_image_entry_t *entry1 = + (const H5C_image_entry_t *)_entry1; /* Pointer to first image entry to compare */ + const H5C_image_entry_t *entry2 = + (const H5C_image_entry_t *)_entry2; /* Pointer to second image entry to compare */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1278,25 +1202,24 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2) HDassert(entry1); HDassert(entry2); - if(entry1->image_fd_height > entry2->image_fd_height) + if (entry1->image_fd_height > entry2->image_fd_height) ret_value = -1; - else if(entry1->image_fd_height < entry2->image_fd_height) + else if (entry1->image_fd_height < entry2->image_fd_height) ret_value = 1; else { /* Sanity check */ HDassert(entry1->lru_rank >= -1); HDassert(entry2->lru_rank >= -1); - if(entry1->lru_rank < entry2->lru_rank) + if (entry1->lru_rank < entry2->lru_rank) ret_value = -1; - else if(entry1->lru_rank > entry2->lru_rank) + else if (entry1->lru_rank > entry2->lru_rank) ret_value = 1; } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__image_entry_cmp() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_image_for_file_close * @@ -1347,10 +1270,10 @@ 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; - haddr_t eoa_frag_addr = HADDR_UNDEF; - hsize_t eoa_frag_size = 0; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -1367,10 +1290,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * any group or data set, it is possible that the cache image (if * it exists) has not been read yet. Do this now if required. */ - if(cache_ptr->load_image) { + if (cache_ptr->load_image) { cache_ptr->load_image = FALSE; - if(H5C__load_cache_image(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") + if (H5C__load_cache_image(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") } /* end if */ /* Before we start to generate the cache image (if requested), verify @@ -1387,9 +1310,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * Also verify that the file's high_bound is at least release * 1.10.x, otherwise cancel the request for a cache image */ - if((NULL == f->shared->sblock) || - (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) || - (f->shared->high_bound < H5F_LIBVER_V110)) { + if ((NULL == f->shared->sblock) || (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) || + (f->shared->high_bound < H5F_LIBVER_V110)) { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; cache_ptr->image_ctl = default_image_ctl; @@ -1397,7 +1319,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) } /* end if */ /* Generate the cache image, if requested */ - if(cache_ptr->image_ctl.generate_image) { + if (cache_ptr->image_ctl.generate_image) { /* Create the cache image super block extension message. * * Note that the base address and length of the metadata cache @@ -1412,12 +1334,12 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDCI_SBE_MESG bit is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDCI_SBE_MESG) - if(H5C__write_cache_image_superblock_msg(f, TRUE) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDCI_SBE_MESG) + if (H5C__write_cache_image_superblock_msg(f, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "creation of cache image SB mesg failed.") /* Serialize the cache */ - if(H5C__serialize_cache(f) < 0) + if (H5C__serialize_cache(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "serialization of the cache failed") /* Scan the cache and record data needed to construct the @@ -1436,7 +1358,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * image. With the recent modifications of the free space * manager code, this size should be correct. */ - if(H5C__prep_for_file_close__scan_entries(f, cache_ptr) < 0) + if (H5C__prep_for_file_close__scan_entries(f, cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C__prep_for_file_close__scan_entries failed") HDassert(HADDR_UNDEF == cache_ptr->image_addr); @@ -1444,23 +1366,25 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) /* In the parallel case, overwrite the image_len with the * value computed by process 0. */ - if(cache_ptr->aux_ptr) { /* we have multiple processes */ - int mpi_result; - unsigned p0_image_len; - H5AC_aux_t * aux_ptr; + if (cache_ptr->aux_ptr) { /* we have multiple processes */ + int mpi_result; + unsigned p0_image_len; + H5AC_aux_t *aux_ptr; aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - if(aux_ptr->mpi_rank == 0) { + if (aux_ptr->mpi_rank == 0) { aux_ptr->p0_image_len = (unsigned)cache_ptr->image_data_len; - p0_image_len = aux_ptr->p0_image_len; + p0_image_len = aux_ptr->p0_image_len; - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) HDassert(p0_image_len == aux_ptr->p0_image_len); } /* end if */ else { - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) + if (MPI_SUCCESS != + (mpi_result = MPI_Bcast(&p0_image_len, 1, MPI_UNSIGNED, 0, aux_ptr->mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) aux_ptr->p0_image_len = p0_image_len; @@ -1475,9 +1399,11 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * Note that we allocate the cache image directly from the file * driver so as to avoid unsettling the free space managers. */ - if(HADDR_UNDEF == (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, - (hsize_t)p0_image_len, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") + if (HADDR_UNDEF == + (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, (hsize_t)p0_image_len, + &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, + "can't allocate file space for metadata cache image") } /* end if */ else #endif /* H5_HAVE_PARALLEL */ @@ -1485,9 +1411,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * this space directly from the file driver so as to avoid * unsettling the free space managers. */ - 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") + 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") /* Make note of the eoa after allocation of the cache image * block. This value is used for sanity checking when we @@ -1495,7 +1422,7 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * we destroy the metadata cache. */ HDassert(HADDR_UNDEF == f->shared->eoa_post_mdci_fsalloc); - if(HADDR_UNDEF == (f->shared->eoa_post_mdci_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (f->shared->eoa_post_mdci_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* For now, drop any fragment left over from the allocation of the @@ -1527,8 +1454,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDC_IMAGE_BLK bit is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) - if(H5C__write_cache_image_superblock_msg(f, FALSE) < 0) + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) + if (H5C__write_cache_image_superblock_msg(f, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "update of cache image SB mesg failed") /* At this point: @@ -1565,14 +1492,14 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * allow the file close to continue normally without the * unnecessary generation of the metadata cache image. */ - if(cache_ptr->num_entries_in_image > 0) { - if(H5C__prep_for_file_close__setup_image_entries_array(cache_ptr) < 0) + if (cache_ptr->num_entries_in_image > 0) { + if (H5C__prep_for_file_close__setup_image_entries_array(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "can't setup image entries array.") /* Sort the entries */ HDqsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image, sizeof(H5C_image_entry_t), H5C__image_entry_cmp); - } /* end if */ + } /* end if */ else { /* cancel creation of metadata cache image */ HDassert(cache_ptr->image_entries == NULL); @@ -1581,9 +1508,10 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) * H5C_CI__GEN_MDC_IMAGE_BLK flag is set in * cache_ptr->image_ctl.flags. */ - if(cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) - if(H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove MDC image msg from superblock ext") + if (cache_ptr->image_ctl.flags & H5C_CI__GEN_MDC_IMAGE_BLK) + if (H5F__super_ext_remove_msg(f, H5O_MDCI_MSG_ID) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove MDC image msg from superblock ext") cache_ptr->image_ctl.generate_image = FALSE; } /* end else */ @@ -1596,7 +1524,6 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_image_for_file_close() */ - /*------------------------------------------------------------------------- * Function: H5C_set_cache_image_config * @@ -1626,10 +1553,9 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) *------------------------------------------------------------------------- */ herr_t -H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, - H5C_cache_image_ctl_t *config_ptr) +H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1639,11 +1565,11 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, HDassert(f->shared->cache == f->shared->cache); /* Check arguments */ - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") /* Validate the config: */ - if(H5C_validate_cache_image_config(config_ptr) < 0) + if (H5C_validate_cache_image_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid cache image configuration") #ifdef H5_HAVE_PARALLEL @@ -1652,11 +1578,11 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, * if there is more than one process. * JRM -- 11/8/16 */ - if(cache_ptr->aux_ptr) { - H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; + if (cache_ptr->aux_ptr) { + H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; cache_ptr->image_ctl = default_image_ctl; - HDassert(!(cache_ptr->image_ctl.generate_image)); + HDassert(!(cache_ptr->image_ctl.generate_image)); } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ @@ -1672,7 +1598,7 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, * If it is not, set the image configuration to the default, which has * the effect of silently disabling the cache image if it was requested. */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) + if (H5F_INTENT(f) & H5F_ACC_RDWR) cache_ptr->image_ctl = *config_ptr; else { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; @@ -1681,14 +1607,13 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, HDassert(!(cache_ptr->image_ctl.generate_image)); } /* end else */ #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_set_cache_image_config() */ - /*------------------------------------------------------------------------- * Function: H5C_validate_cache_image_config() * @@ -1706,39 +1631,38 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5C_validate_cache_image_config(H5C_cache_image_ctl_t * ctl_ptr) +H5C_validate_cache_image_config(H5C_cache_image_ctl_t *ctl_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(ctl_ptr == NULL) + if (ctl_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL ctl_ptr on entry") - if(ctl_ptr->version != H5C__CURR_CACHE_IMAGE_CTL_VER) + if (ctl_ptr->version != H5C__CURR_CACHE_IMAGE_CTL_VER) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown cache image control version") /* At present, we do not support inclusion of the adaptive resize * configuration in the cache image. Thus the save_resize_status * field must be FALSE. */ - if(ctl_ptr->save_resize_status != FALSE) + if (ctl_ptr->save_resize_status != FALSE) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unexpected value in save_resize_status field") /* At present, we do not support prefetched entry ageouts. Thus * the entry_ageout field must be set to * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE. */ - if(ctl_ptr->entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) + if (ctl_ptr->entry_ageout != H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unexpected value in entry_ageout field") - if((ctl_ptr->flags & ~H5C_CI__ALL_FLAGS) != 0) + if ((ctl_ptr->flags & ~H5C_CI__ALL_FLAGS) != 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown flag set") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_validate_cache_image_config() */ - /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ @@ -1758,28 +1682,27 @@ H5C_validate_cache_image_config(H5C_cache_image_ctl_t * ctl_ptr) *------------------------------------------------------------------------- */ static size_t -H5C__cache_image_block_entry_header_size(const H5F_t * f) +H5C__cache_image_block_entry_header_size(const H5F_t *f) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 1 + /* type */ - 1 + /* flags */ - 1 + /* ring */ - 1 + /* age */ - 2 + /* dependency child count */ - 2 + /* dirty dep child count */ - 2 + /* dependency parent count */ - 4 + /* index in LRU */ - H5F_SIZEOF_ADDR(f) + /* entry offset */ - H5F_SIZEOF_SIZE(f) ); /* entry length */ + ret_value = (size_t)(1 + /* type */ + 1 + /* flags */ + 1 + /* ring */ + 1 + /* age */ + 2 + /* dependency child count */ + 2 + /* dirty dep child count */ + 2 + /* dependency parent count */ + 4 + /* index in LRU */ + H5F_SIZEOF_ADDR(f) + /* entry offset */ + H5F_SIZEOF_SIZE(f)); /* entry length */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__cache_image_block_entry_header_size() */ - /*------------------------------------------------------------------------- * Function: H5C__cache_image_block_header_size * @@ -1795,23 +1718,22 @@ H5C__cache_image_block_entry_header_size(const H5F_t * f) *------------------------------------------------------------------------- */ static size_t -H5C__cache_image_block_header_size(const H5F_t * f) +H5C__cache_image_block_header_size(const H5F_t *f) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 4 + /* signature */ - 1 + /* version */ - 1 + /* flags */ - H5F_SIZEOF_SIZE(f) + /* image data length */ - 4 ); /* num_entries */ + ret_value = (size_t)(4 + /* signature */ + 1 + /* version */ + 1 + /* flags */ + H5F_SIZEOF_SIZE(f) + /* image data length */ + 4); /* num_entries */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C__cache_image_block_header_size() */ - /*------------------------------------------------------------------------- * Function: H5C__decode_cache_image_header() * @@ -1828,16 +1750,15 @@ H5C__cache_image_block_header_size(const H5F_t * f) *------------------------------------------------------------------------- */ static herr_t -H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, - const uint8_t **buf) +H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf) { - uint8_t version; - uint8_t flags; - hbool_t have_resize_status = FALSE; - size_t actual_header_len; - size_t expected_header_len; - const uint8_t * p; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t version; + uint8_t flags; + hbool_t have_resize_status = FALSE; + size_t actual_header_len; + size_t expected_header_len; + const uint8_t *p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1851,38 +1772,38 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, p = *buf; /* Check signature */ - if(HDmemcmp(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image header signature") + if (HDmemcmp(p, H5C__MDCI_BLOCK_SIGNATURE, (size_t)H5C__MDCI_BLOCK_SIGNATURE_LEN) != 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image header signature") p += H5C__MDCI_BLOCK_SIGNATURE_LEN; /* Check version */ version = *p++; - if(version != (uint8_t)H5C__MDCI_BLOCK_VERSION_0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image version") + if (version != (uint8_t)H5C__MDCI_BLOCK_VERSION_0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image version") /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_HEADER_HAVE_RESIZE_STATUS) - have_resize_status = TRUE; - if(have_resize_status) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "MDC resize status not yet supported") + if (flags & H5C__MDCI_HEADER_HAVE_RESIZE_STATUS) + have_resize_status = TRUE; + if (have_resize_status) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "MDC resize status not yet supported") /* Read image data length */ H5F_DECODE_LENGTH(f, p, cache_ptr->image_data_len); /* For now -- will become <= eventually */ - if(cache_ptr->image_data_len != cache_ptr->image_len) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image data length") + if (cache_ptr->image_data_len != cache_ptr->image_len) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache image data length") /* Read num entries */ UINT32DECODE(p, cache_ptr->num_entries_in_image); - if(cache_ptr->num_entries_in_image == 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache entry count") + if (cache_ptr->num_entries_in_image == 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad metadata cache entry count") /* Verify expected length of header */ - actual_header_len = (size_t)(p - *buf); + actual_header_len = (size_t)(p - *buf); expected_header_len = H5C__cache_image_block_header_size(f); - if(actual_header_len != expected_header_len) + if (actual_header_len != expected_header_len) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad header image len") /* Update buffer pointer */ @@ -1893,7 +1814,7 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, } /* H5C__decode_cache_image_header() */ #ifndef NDEBUG - + /*------------------------------------------------------------------------- * Function: H5C__decode_cache_image_entry() * @@ -1914,28 +1835,27 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, - const uint8_t **buf, unsigned entry_num) +H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num) { - hbool_t is_dirty = FALSE; - hbool_t in_lru = FALSE; /* Only used in assertions */ - hbool_t is_fd_parent = FALSE; /* Only used in assertions */ - hbool_t is_fd_child = FALSE; /* Only used in assertions */ - haddr_t addr; - hsize_t size = 0; - void * image_ptr; - uint8_t flags = 0; - uint8_t type_id; - uint8_t ring; - uint8_t age; - uint16_t fd_child_count; - uint16_t fd_dirty_child_count; - uint16_t fd_parent_count; - haddr_t * fd_parent_addrs = NULL; - int32_t lru_rank; - H5C_image_entry_t * ie_ptr = NULL; - const uint8_t * p; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t is_dirty = FALSE; + hbool_t in_lru = FALSE; /* Only used in assertions */ + hbool_t is_fd_parent = FALSE; /* Only used in assertions */ + hbool_t is_fd_child = FALSE; /* Only used in assertions */ + haddr_t addr; + hsize_t size = 0; + void * image_ptr; + uint8_t flags = 0; + uint8_t type_id; + uint8_t ring; + uint8_t age; + uint16_t fd_child_count; + uint16_t fd_dirty_child_count; + uint16_t fd_parent_count; + haddr_t * fd_parent_addrs = NULL; + int32_t lru_rank; + H5C_image_entry_t *ie_ptr = NULL; + const uint8_t * p; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1960,13 +1880,13 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_ENTRY_DIRTY_FLAG) + if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG) is_dirty = TRUE; - if(flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) + if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) in_lru = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) is_fd_parent = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) is_fd_child = TRUE; /* Decode ring */ @@ -1983,7 +1903,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode dirty dependency child count */ UINT16DECODE(p, fd_dirty_child_count); - if(fd_dirty_child_count > fd_child_count) + if (fd_dirty_child_count > fd_child_count) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid dirty flush dependency child count") /* Decode dependency parent count */ @@ -1996,37 +1916,37 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, /* Decode entry offset */ H5F_addr_decode(f, &p, &addr); - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry offset") /* Decode entry length */ H5F_DECODE_LENGTH(f, p, size); - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry size") /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, FAIL, "Bad entry image len") /* If parent count greater than zero, allocate array for parent * addresses, and decode addresses into the array. */ - if(fd_parent_count > 0) { - int i; /* Local index variable */ + if (fd_parent_count > 0) { + int i; /* Local index variable */ - if(NULL == (fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(fd_parent_count) * H5F_SIZEOF_ADDR(f)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") + if (NULL == (fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(fd_parent_count)*H5F_SIZEOF_ADDR(f)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") - for(i = 0; i < fd_parent_count; i++) { + for (i = 0; i < fd_parent_count; i++) { H5F_addr_decode(f, &p, &(fd_parent_addrs[i])); - if(!H5F_addr_defined(fd_parent_addrs[i])) + if (!H5F_addr_defined(fd_parent_addrs[i])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid flush dependency parent offset") } /* end for */ - } /* end if */ + } /* end if */ /* Allocate buffer for entry image */ - if(NULL == (image_ptr = H5MM_malloc(size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") + if (NULL == (image_ptr = H5MM_malloc(size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(((uint8_t *)image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); @@ -2058,7 +1978,6 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, } /* H5C__decode_cache_image_entry() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------- * Function: H5C__destroy_pf_entry_child_flush_deps() * @@ -2085,14 +2004,14 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, - H5C_cache_entry_t *pf_entry_ptr, H5C_cache_entry_t **fd_children) +H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children) { - H5C_cache_entry_t * entry_ptr; - unsigned entries_visited = 0; - int fd_children_found = 0; - hbool_t found; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + unsigned entries_visited = 0; + int fd_children_found = 0; + hbool_t found; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2109,68 +2028,69 @@ H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, /* Scan each entry on the index list */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Here we look at entry_ptr->flush_dep_nparents and not + /* Here we look at entry_ptr->flush_dep_nparents and not * entry_ptr->fd_parent_count as it is possible that some - * or all of the prefetched flush dependency child relationships - * have already been destroyed. + * or all of the prefetched flush dependency child relationships + * have already been destroyed. */ - if(entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { - unsigned u; /* Local index variable */ + if (entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { + unsigned u; /* Local index variable */ /* Re-init */ - u = 0; - found = FALSE; + u = 0; + found = FALSE; /* Sanity checks */ HDassert(entry_ptr->type); HDassert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - HDassert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); - HDassert(entry_ptr->fd_parent_addrs); - HDassert(entry_ptr->flush_dep_parent); + HDassert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); + HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->flush_dep_parent); /* Look for correct entry */ - while(!found && (u < entry_ptr->fd_parent_count)) { + while (!found && (u < entry_ptr->fd_parent_count)) { /* Sanity check entry */ - HDassert(entry_ptr->flush_dep_parent[u]); - HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->flush_dep_parent[u]); + HDassert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Correct entry? */ - if(pf_entry_ptr == entry_ptr->flush_dep_parent[u]) - found = TRUE; + if (pf_entry_ptr == entry_ptr->flush_dep_parent[u]) + found = TRUE; - u++; + u++; } /* end while */ - if(found) { - HDassert(NULL == fd_children[fd_children_found]); + if (found) { + HDassert(NULL == fd_children[fd_children_found]); /* Remove flush dependency */ - fd_children[fd_children_found] = entry_ptr; - fd_children_found++; - if(H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry child flush dependency") + fd_children[fd_children_found] = entry_ptr; + fd_children_found++; + if (H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency") #ifndef NDEBUG - /* Sanity check -- verify that the address of the parent + /* Sanity check -- verify that the address of the parent * appears in entry_ptr->fd_parent_addrs. Must do a search, * as with flush dependency creates and destroys, * entry_ptr->fd_parent_addrs and entry_ptr->flush_dep_parent * can list parents in different order. */ - found = FALSE; - u = 0; - while(!found && u < entry_ptr->fd_parent_count) { - if(pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) - found = TRUE; - u++; + found = FALSE; + u = 0; + while (!found && u < entry_ptr->fd_parent_count) { + if (pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) + found = TRUE; + u++; } /* end while */ - HDassert(found); -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ + HDassert(found); +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ entries_visited++; entry_ptr = entry_ptr->il_next; @@ -2186,7 +2106,6 @@ H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C__destroy_pf_entry_child_flush_deps() */ - /*------------------------------------------------------------------------- * Function: H5C__encode_cache_image_header() * @@ -2202,14 +2121,13 @@ H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, - uint8_t **buf) +H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf) { - size_t actual_header_len; - size_t expected_header_len; - uint8_t flags = 0; - uint8_t * p; /* Pointer into cache image buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t actual_header_len; + size_t expected_header_len; + uint8_t flags = 0; + uint8_t *p; /* Pointer into cache image buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2238,8 +2156,8 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, /* at present we don't support saving resize status */ HDassert(!cache_ptr->image_ctl.save_resize_status); - if(cache_ptr->image_ctl.save_resize_status) - flags |= H5C__MDCI_HEADER_HAVE_RESIZE_STATUS; + if (cache_ptr->image_ctl.save_resize_status) + flags |= H5C__MDCI_HEADER_HAVE_RESIZE_STATUS; *p++ = flags; @@ -2252,9 +2170,9 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, UINT32ENCODE(p, cache_ptr->num_entries_in_image); /* verify expected length of header */ - actual_header_len = (size_t)(p - *buf); + actual_header_len = (size_t)(p - *buf); expected_header_len = H5C__cache_image_block_header_size(f); - if(actual_header_len != expected_header_len) + if (actual_header_len != expected_header_len) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad header image len") /* Update buffer pointer */ @@ -2264,7 +2182,6 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C__encode_cache_image_header() */ - /*------------------------------------------------------------------------- * Function: H5C__encode_cache_image_entry() * @@ -2280,14 +2197,13 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, *------------------------------------------------------------------------- */ static herr_t -H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, - unsigned entry_num) +H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num) { - 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 */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2310,19 +2226,19 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, p = *buf; /* Encode type */ - if((ie_ptr->type_id < 0) || (ie_ptr->type_id > 255)) + if ((ie_ptr->type_id < 0) || (ie_ptr->type_id > 255)) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "type_id out of range.") *p++ = (uint8_t)(ie_ptr->type_id); /* Compose and encode flags */ - if(ie_ptr->is_dirty) - flags |= H5C__MDCI_ENTRY_DIRTY_FLAG; - if(ie_ptr->lru_rank > 0) - flags |= H5C__MDCI_ENTRY_IN_LRU_FLAG; - if(ie_ptr->fd_child_count > 0) - flags |= H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG; - if(ie_ptr->fd_parent_count > 0) - flags |= H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG; + if (ie_ptr->is_dirty) + flags |= H5C__MDCI_ENTRY_DIRTY_FLAG; + if (ie_ptr->lru_rank > 0) + flags |= H5C__MDCI_ENTRY_IN_LRU_FLAG; + if (ie_ptr->fd_child_count > 0) + flags |= H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG; + if (ie_ptr->fd_parent_count > 0) + flags |= H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG; *p++ = flags; /* Encode ring */ @@ -2332,17 +2248,17 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, *p++ = (uint8_t)(ie_ptr->age); /* Validate and encode dependency child count */ - if(ie_ptr->fd_child_count > H5C__MDCI_MAX_FD_CHILDREN) + if (ie_ptr->fd_child_count > H5C__MDCI_MAX_FD_CHILDREN) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_child_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_child_count)); /* Validate and encode dirty dependency child count */ - if(ie_ptr->fd_dirty_child_count > H5C__MDCI_MAX_FD_CHILDREN) + if (ie_ptr->fd_dirty_child_count > H5C__MDCI_MAX_FD_CHILDREN) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_dirty_child_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_dirty_child_count)); /* Validate and encode dependency parent count */ - if(ie_ptr->fd_parent_count > H5C__MDCI_MAX_FD_PARENTS) + if (ie_ptr->fd_parent_count > H5C__MDCI_MAX_FD_PARENTS) HGOTO_ERROR(H5E_CACHE, H5E_BADRANGE, FAIL, "fd_parent_count out of range") UINT16ENCODE(p, (uint16_t)(ie_ptr->fd_parent_count)); @@ -2356,12 +2272,12 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, H5F_ENCODE_LENGTH(f, p, ie_ptr->size); /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad entry image len") /* Encode dependency parent offsets -- if any */ - for(u = 0; u < ie_ptr->fd_parent_count; u++) - H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); + for (u = 0; u < ie_ptr->fd_parent_count; u++) + H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); /* Copy entry image */ H5MM_memcpy(p, ie_ptr->image_ptr, ie_ptr->size); @@ -2374,7 +2290,6 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, FUNC_LEAVE_NOAPI(ret_value) } /* H5C__encode_cache_image_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__compute_fd_heights * @@ -2441,14 +2356,14 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * parent_ptr; - unsigned entries_removed_from_image = 0; - unsigned external_parent_fd_refs_removed = 0; - unsigned external_child_fd_refs_removed = 0; - hbool_t done = FALSE; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *parent_ptr; + unsigned entries_removed_from_image = 0; + unsigned external_parent_fd_refs_removed = 0; + unsigned external_child_fd_refs_removed = 0; + hbool_t done = FALSE; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2464,36 +2379,35 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * multiple passes through the index list. */ done = FALSE; - while(!done) { - done = TRUE; - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (!done) { + done = TRUE; + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); /* Should this entry be in the image */ - if(entry_ptr->image_dirty && entry_ptr->include_in_image && - (entry_ptr->fd_parent_count > 0)) { - HDassert(entry_ptr->flush_dep_parent != NULL); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + if (entry_ptr->image_dirty && entry_ptr->include_in_image && (entry_ptr->fd_parent_count > 0)) { + HDassert(entry_ptr->flush_dep_parent != NULL); + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); - if(parent_ptr->is_dirty && !parent_ptr->include_in_image && - entry_ptr->include_in_image) { + if (parent_ptr->is_dirty && !parent_ptr->include_in_image && + entry_ptr->include_in_image) { - /* Must remove child from image -- only do this once */ - entries_removed_from_image++; - entry_ptr->include_in_image = FALSE; - } /* end if */ - } /* for */ - } /* end if */ + /* Must remove child from image -- only do this once */ + entries_removed_from_image++; + entry_ptr->include_in_image = FALSE; + } /* end if */ + } /* for */ + } /* end if */ - entry_ptr = entry_ptr->il_next; + entry_ptr = entry_ptr->il_next; } /* while ( entry_ptr != NULL ) */ - } /* while ( ! done ) */ + } /* while ( ! done ) */ /* at present, entries are included in the cache image if they reside * in a specified set of rings. Thus it should be impossible for @@ -2507,79 +2421,81 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * flush dependency parents or children that are not in the cache image. */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if(!entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { - HDassert(entry_ptr->flush_dep_parent != NULL); + while (entry_ptr != NULL) { + if (!entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { + HDassert(entry_ptr->flush_dep_parent != NULL); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); - - if(parent_ptr->include_in_image) { - /* Must remove reference to child */ - HDassert(parent_ptr->fd_child_count > 0); - parent_ptr->fd_child_count--; - - if(entry_ptr->is_dirty) { - HDassert(parent_ptr->fd_dirty_child_count > 0); - parent_ptr->fd_dirty_child_count--; - } /* end if */ - - external_child_fd_refs_removed++; - } /* end if */ - } /* for */ - } /* end if */ - else if(entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); + + if (parent_ptr->include_in_image) { + /* Must remove reference to child */ + HDassert(parent_ptr->fd_child_count > 0); + parent_ptr->fd_child_count--; + + if (entry_ptr->is_dirty) { + HDassert(parent_ptr->fd_dirty_child_count > 0); + parent_ptr->fd_dirty_child_count--; + } /* end if */ + + external_child_fd_refs_removed++; + } /* end if */ + } /* for */ + } /* end if */ + else if (entry_ptr->include_in_image && entry_ptr->flush_dep_nparents > 0) { /* Sanity checks */ - HDassert(entry_ptr->flush_dep_parent != NULL); - HDassert(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count); - HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->flush_dep_parent != NULL); + HDassert(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count); + HDassert(entry_ptr->fd_parent_addrs); - for(u = 0; u < entry_ptr->flush_dep_nparents; u++ ) { - parent_ptr = entry_ptr->flush_dep_parent[u]; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(entry_ptr->ring == parent_ptr->ring); - - if(!parent_ptr->include_in_image) { - /* Must remove reference to parent */ - HDassert(entry_ptr->fd_parent_count > 0); - parent_ptr->fd_child_count--; - - HDassert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]); - - entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF; - external_parent_fd_refs_removed++; - } /* end if */ - } /* for */ - - /* Touch up fd_parent_addrs array if necessary */ - if(entry_ptr->fd_parent_count == 0) { - H5MM_xfree(entry_ptr->fd_parent_addrs); - entry_ptr->fd_parent_addrs = NULL; - } /* end if */ - else if(entry_ptr->flush_dep_nparents > entry_ptr->fd_parent_count) { - haddr_t * old_fd_parent_addrs = entry_ptr->fd_parent_addrs; + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(entry_ptr->ring == parent_ptr->ring); + + if (!parent_ptr->include_in_image) { + /* Must remove reference to parent */ + HDassert(entry_ptr->fd_parent_count > 0); + parent_ptr->fd_child_count--; + + HDassert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]); + + entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF; + external_parent_fd_refs_removed++; + } /* end if */ + } /* for */ + + /* Touch up fd_parent_addrs array if necessary */ + if (entry_ptr->fd_parent_count == 0) { + H5MM_xfree(entry_ptr->fd_parent_addrs); + entry_ptr->fd_parent_addrs = NULL; + } /* end if */ + else if (entry_ptr->flush_dep_nparents > entry_ptr->fd_parent_count) { + haddr_t *old_fd_parent_addrs = entry_ptr->fd_parent_addrs; unsigned v; - if(NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_calloc(sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_addrs)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addr array") + if (NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_calloc( + sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_addrs)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for fd parent addr array") - v = 0; - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { - if(old_fd_parent_addrs[u] != HADDR_UNDEF) { - entry_ptr->fd_parent_addrs[v] = old_fd_parent_addrs[u]; - v++; - } /* end if */ - } /* end for */ + v = 0; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + if (old_fd_parent_addrs[u] != HADDR_UNDEF) { + entry_ptr->fd_parent_addrs[v] = old_fd_parent_addrs[u]; + v++; + } /* end if */ + } /* end for */ - HDassert(v == entry_ptr->fd_parent_count); - } /* end else-if */ - } /* end else-if */ + HDassert(v == entry_ptr->fd_parent_count); + } /* end else-if */ + } /* end else-if */ entry_ptr = entry_ptr->il_next; } /* while (entry_ptr != NULL) */ @@ -2602,17 +2518,16 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) * for all entries that may appear in the cache image. */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - if(entry_ptr->include_in_image && entry_ptr->fd_child_count == 0 && - entry_ptr->fd_parent_count > 0) { - for(u = 0; u < entry_ptr->fd_parent_count; u++) { - parent_ptr = entry_ptr->flush_dep_parent[u]; - - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0) - H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1); - } /* end for */ - } /* end if */ + while (entry_ptr != NULL) { + if (entry_ptr->include_in_image && entry_ptr->fd_child_count == 0 && entry_ptr->fd_parent_count > 0) { + for (u = 0; u < entry_ptr->fd_parent_count; u++) { + parent_ptr = entry_ptr->flush_dep_parent[u]; + + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0) + H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1); + } /* end for */ + } /* end if */ entry_ptr = entry_ptr->il_next; } /* while (entry_ptr != NULL) */ @@ -2621,7 +2536,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__compute_fd_heights() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__compute_fd_heights_real * @@ -2671,8 +2585,7 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) *------------------------------------------------------------------------- */ static void -H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, - uint32_t fd_height) +H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, uint32_t fd_height) { FUNC_ENTER_STATIC_NOERR @@ -2681,28 +2594,28 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->include_in_image); HDassert((entry_ptr->image_fd_height == 0) || (entry_ptr->image_fd_height < fd_height)); - HDassert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) || ((fd_height > 0) && (entry_ptr->fd_child_count > 0))); + HDassert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) || + ((fd_height > 0) && (entry_ptr->fd_child_count > 0))); entry_ptr->image_fd_height = fd_height; - if(entry_ptr->flush_dep_nparents > 0) { + if (entry_ptr->flush_dep_nparents > 0) { unsigned u; - HDassert(entry_ptr->flush_dep_parent); - for(u = 0; u < entry_ptr->fd_parent_count; u++) { + HDassert(entry_ptr->flush_dep_parent); + for (u = 0; u < entry_ptr->fd_parent_count; u++) { H5C_cache_entry_t *parent_ptr; - parent_ptr = entry_ptr->flush_dep_parent[u]; - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + parent_ptr = entry_ptr->flush_dep_parent[u]; + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height) - H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1); + if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height) + H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* H5C__prep_for_file_close__compute_fd_heights_real() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__setup_image_entries_array * @@ -2720,11 +2633,11 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - H5C_image_entry_t * image_entries = NULL; - uint32_t entries_visited = 0; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + H5C_image_entry_t *image_entries = NULL; + uint32_t entries_visited = 0; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2737,73 +2650,73 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) HDassert(cache_ptr->image_entries == NULL); /* Allocate and initialize image_entries array */ - if(NULL == (image_entries = (H5C_image_entry_t *)H5MM_calloc(sizeof(H5C_image_entry_t) * (size_t)(cache_ptr->num_entries_in_image + 1)))) + if (NULL == (image_entries = (H5C_image_entry_t *)H5MM_calloc( + sizeof(H5C_image_entry_t) * (size_t)(cache_ptr->num_entries_in_image + 1)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for image_entries") /* Initialize (non-zero/NULL/FALSE) fields */ - for(u = 0; u <= cache_ptr->num_entries_in_image; u++) { - image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; - image_entries[u].addr = HADDR_UNDEF; - image_entries[u].ring = H5C_RING_UNDEFINED; - image_entries[u].type_id = -1; + for (u = 0; u <= cache_ptr->num_entries_in_image; u++) { + image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; + image_entries[u].addr = HADDR_UNDEF; + image_entries[u].ring = H5C_RING_UNDEFINED; + image_entries[u].type_id = -1; } /* end for */ /* Scan each entry on the index list and populate the image_entries array */ - u = 0; + u = 0; entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->include_in_image) { - /* Since we have already serialized the cache, the following + if (entry_ptr->include_in_image) { + /* Since we have already serialized the cache, the following * should hold. */ HDassert(entry_ptr->image_up_to_date); HDassert(entry_ptr->image_ptr); - HDassert(entry_ptr->type); + HDassert(entry_ptr->type); - image_entries[u].addr = entry_ptr->addr; - image_entries[u].size = entry_ptr->size; - image_entries[u].ring = entry_ptr->ring; + image_entries[u].addr = entry_ptr->addr; + image_entries[u].size = entry_ptr->size; + image_entries[u].ring = entry_ptr->ring; - /* When a prefetched entry is included in the image, store + /* When a prefetched entry is included in the image, store * its underlying type id in the image entry, not * H5AC_PREFETCHED_ENTRY_ID. In passing, also increment - * the age (up to H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX). + * the age (up to H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX). */ - 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 (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) - image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX; - } /* end if */ + if (image_entries[u].age > H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX) + image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX; + } /* end if */ else { - image_entries[u].type_id = entry_ptr->type->id; - image_entries[u].age = 0; - } /* end else */ - - image_entries[u].lru_rank = entry_ptr->lru_rank; - image_entries[u].is_dirty = entry_ptr->is_dirty; - image_entries[u].image_fd_height = entry_ptr->image_fd_height; - image_entries[u].fd_parent_count = entry_ptr->fd_parent_count; - image_entries[u].fd_parent_addrs = entry_ptr->fd_parent_addrs; - image_entries[u].fd_child_count = entry_ptr->fd_child_count; - image_entries[u].fd_dirty_child_count = - entry_ptr->fd_dirty_child_count; - image_entries[u].image_ptr = entry_ptr->image_ptr; - - /* Null out entry_ptr->fd_parent_addrs and set + image_entries[u].type_id = entry_ptr->type->id; + image_entries[u].age = 0; + } /* end else */ + + image_entries[u].lru_rank = entry_ptr->lru_rank; + image_entries[u].is_dirty = entry_ptr->is_dirty; + image_entries[u].image_fd_height = entry_ptr->image_fd_height; + image_entries[u].fd_parent_count = entry_ptr->fd_parent_count; + image_entries[u].fd_parent_addrs = entry_ptr->fd_parent_addrs; + image_entries[u].fd_child_count = entry_ptr->fd_child_count; + image_entries[u].fd_dirty_child_count = entry_ptr->fd_dirty_child_count; + image_entries[u].image_ptr = entry_ptr->image_ptr; + + /* Null out entry_ptr->fd_parent_addrs and set * entry_ptr->fd_parent_count to zero so that ownership of the * flush dependency parents address array is transferred to the - * image entry. + * image entry. */ - entry_ptr->fd_parent_count = 0; - entry_ptr->fd_parent_addrs = NULL; + entry_ptr->fd_parent_count = 0; + entry_ptr->fd_parent_addrs = NULL; u++; - HDassert(u <= cache_ptr->num_entries_in_image); + HDassert(u <= cache_ptr->num_entries_in_image); } /* end if */ entries_visited++; @@ -2824,7 +2737,6 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__setup_image_entries_array() */ - /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__scan_entries * @@ -2858,18 +2770,18 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) static herr_t H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) { - H5C_cache_entry_t * entry_ptr; - hbool_t include_in_image; - unsigned entries_visited = 0; - int lru_rank = 1; - uint32_t num_entries_tentatively_in_image = 0; - uint32_t num_entries_in_image = 0; - size_t image_len; - size_t entry_header_len; - size_t fd_parents_list_len; - int i; - unsigned j; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *entry_ptr; + hbool_t include_in_image; + unsigned entries_visited = 0; + int lru_rank = 1; + uint32_t num_entries_tentatively_in_image = 0; + uint32_t num_entries_in_image = 0; + size_t image_len; + size_t entry_header_len; + size_t fd_parents_list_len; + int i; + unsigned j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2890,85 +2802,87 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) /* Scan each entry on the index list */ entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Since we have already serialized the cache, the following + /* Since we have already serialized the cache, the following * should hold. */ HDassert(entry_ptr->image_up_to_date); HDassert(entry_ptr->image_ptr); - /* Initially, we mark all entries in the rings included + /* Initially, we mark all entries in the rings included * in the cache image as being included in the in the * image. Depending on circumstances, we may exclude some * of these entries later. */ - if(entry_ptr->ring > H5C_MAX_RING_IN_IMAGE) - include_in_image = FALSE; + if (entry_ptr->ring > H5C_MAX_RING_IN_IMAGE) + include_in_image = FALSE; else - include_in_image = TRUE; + include_in_image = TRUE; entry_ptr->include_in_image = include_in_image; - if(include_in_image) { - entry_ptr->lru_rank = -1; - entry_ptr->image_dirty = entry_ptr->is_dirty; - entry_ptr->image_fd_height = 0; /* will compute this later */ + if (include_in_image) { + entry_ptr->lru_rank = -1; + entry_ptr->image_dirty = entry_ptr->is_dirty; + entry_ptr->image_fd_height = 0; /* will compute this later */ - /* Initially, include all flush dependency parents in the + /* Initially, include all flush dependency parents in the * the list of flush dependencies to be stored in the * image. We may remove some or all of these later. */ - if(entry_ptr->flush_dep_nparents > 0) { - /* The parents addresses array may already exist -- reallocate + if (entry_ptr->flush_dep_nparents > 0) { + /* The parents addresses array may already exist -- reallocate * as needed. */ - if(entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count ) { - /* parent addresses array should already be allocated + if (entry_ptr->flush_dep_nparents == entry_ptr->fd_parent_count) { + /* parent addresses array should already be allocated * and of the correct size. */ - HDassert(entry_ptr->fd_parent_addrs); - } /* end if */ - else if(entry_ptr->fd_parent_count > 0) { - HDassert(entry_ptr->fd_parent_addrs); + HDassert(entry_ptr->fd_parent_addrs); + } /* end if */ + else if (entry_ptr->fd_parent_count > 0) { + HDassert(entry_ptr->fd_parent_addrs); entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); - } /* end else-if */ + } /* end else-if */ else { - HDassert(entry_ptr->fd_parent_count == 0); - HDassert(entry_ptr->fd_parent_addrs == NULL); - } /* end else */ - - entry_ptr->fd_parent_count = entry_ptr->flush_dep_nparents; - if(NULL == entry_ptr->fd_parent_addrs) - if(NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc(sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_count)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") - - for(i = 0; i < (int)(entry_ptr->fd_parent_count); i++) { - entry_ptr->fd_parent_addrs[i] = entry_ptr->flush_dep_parent[i]->addr; - HDassert(H5F_addr_defined(entry_ptr->fd_parent_addrs[i])); - } /* end for */ - } /* end if */ - else if(entry_ptr->fd_parent_count > 0) { - HDassert(entry_ptr->fd_parent_addrs); - entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); - } /* end else-if */ + HDassert(entry_ptr->fd_parent_count == 0); + HDassert(entry_ptr->fd_parent_addrs == NULL); + } /* end else */ + + entry_ptr->fd_parent_count = entry_ptr->flush_dep_nparents; + if (NULL == entry_ptr->fd_parent_addrs) + if (NULL == (entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc( + sizeof(haddr_t) * (size_t)(entry_ptr->fd_parent_count)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for fd parent addrs buffer") + + for (i = 0; i < (int)(entry_ptr->fd_parent_count); i++) { + entry_ptr->fd_parent_addrs[i] = entry_ptr->flush_dep_parent[i]->addr; + HDassert(H5F_addr_defined(entry_ptr->fd_parent_addrs[i])); + } /* end for */ + } /* end if */ + else if (entry_ptr->fd_parent_count > 0) { + HDassert(entry_ptr->fd_parent_addrs); + entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree(entry_ptr->fd_parent_addrs); + } /* end else-if */ else - HDassert(entry_ptr->fd_parent_addrs == NULL); + HDassert(entry_ptr->fd_parent_addrs == NULL); - /* Initially, all flush dependency children are included int + /* Initially, all flush dependency children are included int * the count of flush dependency child relationships to be * represented in the cache image. Some or all of these * may be dropped from the image later. */ - if(entry_ptr->flush_dep_nchildren > 0) { - if(!entry_ptr->is_pinned) + if (entry_ptr->flush_dep_nchildren > 0) { + if (!entry_ptr->is_pinned) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "encountered unpinned fd parent?!?") - entry_ptr->fd_child_count = entry_ptr->flush_dep_nchildren; - entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children; - } /* end if */ + entry_ptr->fd_child_count = entry_ptr->flush_dep_nchildren; + entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children; + } /* end if */ - num_entries_tentatively_in_image++; + num_entries_tentatively_in_image++; } /* end if */ entries_visited++; @@ -2999,7 +2913,7 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * exact contents of the image cannot be known until after this * call, computation of the image size is delayed. */ - if(H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0) + if (H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "computation of flush dependency heights failed?!?") /* At this point, all entries that will appear in the cache @@ -3007,12 +2921,12 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * cache image. */ entries_visited = 0; - entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if(entry_ptr->include_in_image) { - if(entry_ptr->fd_parent_count > 0) + if (entry_ptr->include_in_image) { + if (entry_ptr->fd_parent_count > 0) fd_parents_list_len = (size_t)(H5F_SIZEOF_ADDR(f) * entry_ptr->fd_parent_count); else fd_parents_list_len = (size_t)0; @@ -3028,14 +2942,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) HDassert(num_entries_in_image <= num_entries_tentatively_in_image); j = 0; - for(i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) + for (i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) j += cache_ptr->index_ring_len[i]; /* This will change */ HDassert(entries_visited == (num_entries_tentatively_in_image + j)); cache_ptr->num_entries_in_image = num_entries_in_image; - entries_visited = 0; + entries_visited = 0; /* Now scan the LRU list to set the lru_rank fields of all entries * on the LRU. @@ -3048,8 +2962,8 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * the reconstructed LRU should be appropriate. */ entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + while (entry_ptr != NULL) { + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); /* to avoid confusion, don't set lru_rank on epoch markers. @@ -3061,10 +2975,10 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) * Do not set lru_rank or increment lru_rank for entries * that will not be included in the cache image. */ - if(entry_ptr->type->id == H5AC_EPOCH_MARKER_ID) - lru_rank++; - else if(entry_ptr->include_in_image) { - entry_ptr->lru_rank = lru_rank; + if (entry_ptr->type->id == H5AC_EPOCH_MARKER_ID) + lru_rank++; + else if (entry_ptr->include_in_image) { + entry_ptr->lru_rank = lru_rank; lru_rank++; } /* end else-if */ @@ -3080,7 +2994,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__prep_for_file_close__scan_entries() */ - /*------------------------------------------------------------------------- * Function: H5C__reconstruct_cache_contents() * @@ -3100,11 +3013,11 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) static herr_t 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 */ - unsigned u, v; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned u, v; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3119,7 +3032,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) /* Decode metadata cache image header */ p = (uint8_t *)cache_ptr->image_buffer; - if(H5C__decode_cache_image_header(f, cache_ptr, &p) < 0) + if (H5C__decode_cache_image_header(f, cache_ptr, &p) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDECODE, FAIL, "cache image header decode failed") HDassert((size_t)(p - (uint8_t *)cache_ptr->image_buffer) < cache_ptr->image_len); @@ -3129,14 +3042,14 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) HDassert(cache_ptr->num_entries_in_image > 0); /* Reconstruct entries in image */ - for(u = 0; u < cache_ptr->num_entries_in_image; u++) { - /* Create the prefetched entry described by the ith + for (u = 0; u < cache_ptr->num_entries_in_image; u++) { + /* Create the prefetched entry described by the ith * entry in cache_ptr->image_entrise. */ - if(NULL == (pf_entry_ptr = H5C__reconstruct_cache_entry(f, cache_ptr, &p))) + if (NULL == (pf_entry_ptr = H5C__reconstruct_cache_entry(f, cache_ptr, &p))) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "reconstruction of cache entry failed") - /* Note that we make no checks on available cache space before + /* Note that we make no checks on available cache space before * inserting the reconstructed entry into the metadata cache. * * This is OK since the cache must be almost empty at the beginning @@ -3144,66 +3057,66 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) * reconstruction process. */ - /* Insert the prefetched entry in the index */ - H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL) + /* Insert the prefetched entry in the index */ + H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL) - /* If dirty, insert the entry into the slist. */ - if(pf_entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL) + /* If dirty, insert the entry into the slist. */ + if (pf_entry_ptr->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL) /* Append the entry to the LRU */ - H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL) + H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL) - H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty) + H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty) - /* If the prefetched entry is the child in one or more flush + /* If the prefetched entry is the child in one or more flush * dependency relationships, recreate those flush dependencies. */ - for(v = 0; v < pf_entry_ptr->fd_parent_count; v++) { + for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) { /* Sanity checks */ - HDassert(pf_entry_ptr->fd_parent_addrs); - HDassert(H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[v])); + HDassert(pf_entry_ptr->fd_parent_addrs); + HDassert(H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[v])); /* Find the parent entry */ - parent_ptr = NULL; - H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL) - if(parent_ptr == NULL) + parent_ptr = NULL; + H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL) + if (parent_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "fd parent not in cache?!?") /* Sanity checks */ - HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(parent_ptr->addr == pf_entry_ptr->fd_parent_addrs[v]); HDassert(parent_ptr->lru_rank == -1); - /* Must protect parent entry to set up a flush dependency. + /* Must protect parent entry to set up a flush dependency. * Do this now, and then uprotect when done. */ H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL) parent_ptr->is_protected = TRUE; - /* Setup the flush dependency */ - if(H5C_create_flush_dependency(parent_ptr, pf_entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency") + /* Setup the flush dependency */ + if (H5C_create_flush_dependency(parent_ptr, pf_entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency") - /* And now unprotect */ - H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL) - parent_ptr->is_protected = FALSE; + /* And now unprotect */ + H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL) + parent_ptr->is_protected = FALSE; } /* end for */ - } /* end for */ + } /* end for */ #ifndef NDEBUG /* Scan the cache entries, and verify that each entry has * the expected flush dependency status. */ pf_entry_ptr = cache_ptr->il_head; - while(pf_entry_ptr != NULL) { + while (pf_entry_ptr != NULL) { HDassert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) - || (!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY)); - if(pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) + HDassert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) || + (!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY)); + if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) HDassert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); - for(v = 0; v < pf_entry_ptr->fd_parent_count; v++) { + for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) { parent_ptr = pf_entry_ptr->flush_dep_parent[v]; HDassert(parent_ptr); HDassert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -3212,7 +3125,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) HDassert(parent_ptr->flush_dep_nchildren > 0); } /* end for */ - if(pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) { + if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) { HDassert(pf_entry_ptr->fd_child_count == pf_entry_ptr->flush_dep_nchildren); HDassert(pf_entry_ptr->fd_dirty_child_count == pf_entry_ptr->flush_dep_ndirty_children); } /* end if */ @@ -3224,26 +3137,24 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) * prefetched entries. */ { - int lru_rank_holes = 0; + int lru_rank_holes = 0; H5C_cache_entry_t *entry_ptr; - int i; /* Local index variable */ + int i; /* Local index variable */ - i = -1; + i = -1; entry_ptr = cache_ptr->LRU_head_ptr; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); - if ( entry_ptr->prefetched ) { + if (entry_ptr->prefetched) { HDassert(entry_ptr->lru_rank != 0); - HDassert((entry_ptr->lru_rank == -1) || - (entry_ptr->lru_rank > i)); + HDassert((entry_ptr->lru_rank == -1) || (entry_ptr->lru_rank > i)); - if ( ( entry_ptr->lru_rank > 1 ) && - ( entry_ptr->lru_rank > i + 1 ) ) + if ((entry_ptr->lru_rank > 1) && (entry_ptr->lru_rank > i + 1)) lru_rank_holes += entry_ptr->lru_rank - (i + 1); @@ -3254,41 +3165,40 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) entry_ptr = entry_ptr->next; } /* end while */ - /* Holes in the sequences of LRU ranks can appear due to epoch + /* Holes in the sequences of LRU ranks can appear due to epoch * markers. They are left in to allow re-insertion of the * epoch markers on reconstruction of the cache -- thus * the following sanity check will have to be revised when * we add code to store and restore adaptive resize status. */ - HDassert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS); - } /* end block */ + HDassert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS); + } /* end block */ #endif /* NDEBUG */ /* Check to see if the cache is oversize, and evict entries as * necessary to remain within limits. */ - if(cache_ptr->index_size >= cache_ptr->max_cache_size) { - /* cache is oversized -- call H5C__make_space_in_cache() with zero + if (cache_ptr->index_size >= cache_ptr->max_cache_size) { + /* cache is oversized -- call H5C__make_space_in_cache() with zero * space needed to repair the situation if possible. */ hbool_t write_permitted = FALSE; - if(cache_ptr->check_write_permitted != NULL) { - if((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") } /* end if */ else write_permitted = cache_ptr->write_permitted; - if(H5C__make_space_in_cache(f, 0, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "H5C__make_space_in_cache failed") + if (H5C__make_space_in_cache(f, 0, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "H5C__make_space_in_cache failed") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__reconstruct_cache_contents() */ - /*------------------------------------------------------------------------- * Function: H5C__reconstruct_cache_entry() * @@ -3307,20 +3217,19 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) *------------------------------------------------------------------------- */ static H5C_cache_entry_t * -H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, - const uint8_t **buf) +H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **buf) { - H5C_cache_entry_t *pf_entry_ptr = NULL; /* Reconstructed cache entry */ - uint8_t flags = 0; - hbool_t is_dirty = FALSE; -#ifndef NDEBUG /* only used in assertions */ - hbool_t in_lru = FALSE; - hbool_t is_fd_parent = FALSE; - hbool_t is_fd_child = FALSE; + H5C_cache_entry_t *pf_entry_ptr = NULL; /* Reconstructed cache entry */ + uint8_t flags = 0; + hbool_t is_dirty = FALSE; +#ifndef NDEBUG /* only used in assertions */ + hbool_t in_lru = FALSE; + 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 */ + H5C_cache_entry_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -3334,8 +3243,8 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, file_is_rw = cache_ptr->delete_image; /* Allocate space for the prefetched cache entry */ - if(NULL == (pf_entry_ptr = H5FL_CALLOC(H5C_cache_entry_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for prefetched cache entry") + if (NULL == (pf_entry_ptr = H5FL_CALLOC(H5C_cache_entry_t))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for prefetched cache entry") /* Get pointer to buffer */ p = *buf; @@ -3345,14 +3254,14 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode flags */ flags = *p++; - if(flags & H5C__MDCI_ENTRY_DIRTY_FLAG) + if (flags & H5C__MDCI_ENTRY_DIRTY_FLAG) is_dirty = TRUE; -#ifndef NDEBUG /* only used in assertions */ - if(flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) +#ifndef NDEBUG /* only used in assertions */ + if (flags & H5C__MDCI_ENTRY_IN_LRU_FLAG) in_lru = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_PARENT_FLAG) is_fd_parent = TRUE; - if(flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) + if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) is_fd_child = TRUE; #endif /* NDEBUG */ /* only used in assertions */ @@ -3380,18 +3289,20 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode dependency child count */ UINT16DECODE(p, pf_entry_ptr->fd_child_count); - HDassert((is_fd_parent && pf_entry_ptr->fd_child_count > 0) || (!is_fd_parent && pf_entry_ptr->fd_child_count == 0)); + HDassert((is_fd_parent && pf_entry_ptr->fd_child_count > 0) || + (!is_fd_parent && pf_entry_ptr->fd_child_count == 0)); /* Decode dirty dependency child count */ UINT16DECODE(p, pf_entry_ptr->fd_dirty_child_count); - if(!file_is_rw) - pf_entry_ptr->fd_dirty_child_count = 0; - if(pf_entry_ptr->fd_dirty_child_count > pf_entry_ptr->fd_child_count) + if (!file_is_rw) + pf_entry_ptr->fd_dirty_child_count = 0; + if (pf_entry_ptr->fd_dirty_child_count > pf_entry_ptr->fd_child_count) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid dirty flush dependency child count") /* Decode dependency parent count */ UINT16DECODE(p, pf_entry_ptr->fd_parent_count); - HDassert((is_fd_child && pf_entry_ptr->fd_parent_count > 0) || (!is_fd_child && pf_entry_ptr->fd_parent_count == 0)); + HDassert((is_fd_child && pf_entry_ptr->fd_parent_count > 0) || + (!is_fd_child && pf_entry_ptr->fd_parent_count == 0)); /* Decode index in LRU */ INT32DECODE(p, pf_entry_ptr->lru_rank); @@ -3399,37 +3310,38 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Decode entry offset */ H5F_addr_decode(f, &p, &pf_entry_ptr->addr); - if(!H5F_addr_defined(pf_entry_ptr->addr)) + if (!H5F_addr_defined(pf_entry_ptr->addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry offset") /* Decode entry length */ H5F_DECODE_LENGTH(f, p, pf_entry_ptr->size); - if(pf_entry_ptr->size == 0) + if (pf_entry_ptr->size == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry size") /* Verify expected length of entry image */ - if((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) + if ((size_t)(p - *buf) != H5C__cache_image_block_entry_header_size(f)) HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, NULL, "Bad entry image len") /* If parent count greater than zero, allocate array for parent * addresses, and decode addresses into the array. */ - if(pf_entry_ptr->fd_parent_count > 0) { - unsigned u; /* Local index variable */ + if (pf_entry_ptr->fd_parent_count > 0) { + unsigned u; /* Local index variable */ - if(NULL == (pf_entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc((size_t)(pf_entry_ptr->fd_parent_count) * H5F_SIZEOF_ADDR(f)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer") + if (NULL == (pf_entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_malloc( + (size_t)(pf_entry_ptr->fd_parent_count) * H5F_SIZEOF_ADDR(f)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer") - for(u = 0; u < pf_entry_ptr->fd_parent_count; u++) { + for (u = 0; u < pf_entry_ptr->fd_parent_count; u++) { H5F_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u])); - if(!H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[u])) + if (!H5F_addr_defined(pf_entry_ptr->fd_parent_addrs[u])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid flush dependency parent offset") } /* end for */ - } /* end if */ + } /* end if */ /* Allocate buffer for entry image */ - if(NULL == (pf_entry_ptr->image_ptr = H5MM_malloc(pf_entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") + if (NULL == (pf_entry_ptr->image_ptr = H5MM_malloc(pf_entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") #if H5C_DO_MEMORY_SANITY_CHECKS H5MM_memcpy(((uint8_t *)pf_entry_ptr->image_ptr) + size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ @@ -3440,12 +3352,12 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, /* Initialize the rest of the fields in the prefetched entry */ /* (Only need to set non-zero/NULL/FALSE fields, due to calloc() above) */ - pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - pf_entry_ptr->cache_ptr = cache_ptr; - pf_entry_ptr->image_up_to_date = TRUE; - pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; - pf_entry_ptr->prefetched = TRUE; - pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); + pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + pf_entry_ptr->cache_ptr = cache_ptr; + pf_entry_ptr->image_up_to_date = TRUE; + pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; + pf_entry_ptr->prefetched = TRUE; + pf_entry_ptr->prefetched_dirty = is_dirty && (!file_is_rw); /* Sanity checks */ HDassert(pf_entry_ptr->size > 0 && pf_entry_ptr->size < H5C_MAX_ENTRY_SIZE); @@ -3456,13 +3368,12 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, ret_value = pf_entry_ptr; done: - if(NULL == ret_value && pf_entry_ptr) + if (NULL == ret_value && pf_entry_ptr) pf_entry_ptr = H5FL_FREE(H5C_cache_entry_t, pf_entry_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* H5C__reconstruct_cache_entry() */ - /*------------------------------------------------------------------------- * Function: H5C__write_cache_image_superblock_msg * @@ -3483,12 +3394,12 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) { - H5C_t * cache_ptr; - H5O_mdci_t mdci_msg; /* metadata cache image message */ - /* to insert in the superblock */ - /* extension. */ - unsigned mesg_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5O_mdci_t mdci_msg; /* metadata cache image message */ + /* to insert in the superblock */ + /* extension. */ + unsigned mesg_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3507,8 +3418,8 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) */ mdci_msg.addr = cache_ptr->image_addr; #ifdef H5_HAVE_PARALLEL - if(cache_ptr->aux_ptr) { /* we have multiple processes */ - H5AC_aux_t * aux_ptr; + if (cache_ptr->aux_ptr) { /* we have multiple processes */ + H5AC_aux_t *aux_ptr; aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -3519,14 +3430,14 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) mdci_msg.size = cache_ptr->image_len; /* Write metadata cache image message to superblock extension */ - if(H5F__super_ext_write_msg(f, H5O_MDCI_MSG_ID, &mdci_msg, create, mesg_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata cache image message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_MDCI_MSG_ID, &mdci_msg, create, mesg_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, + "can't write metadata cache image message to superblock extension") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__write_cache_image_superblock_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__write_cache_image * @@ -3543,7 +3454,7 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) static herr_t H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3555,22 +3466,22 @@ H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr) HDassert(cache_ptr->image_buffer); #ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; + { + H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - if((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { + HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ - /* Write the buffer (if serial access, or rank 0 for parallel access) */ - if(H5F_block_write(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, cache_ptr->image_buffer) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't write metadata cache image block to file") + /* Write the buffer (if serial access, or rank 0 for parallel access) */ + if (H5F_block_write(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, + cache_ptr->image_buffer) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't write metadata cache image block to file") #ifdef H5_HAVE_PARALLEL - } /* end if */ -} /* end block */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end block */ +#endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__write_cache_image() */ - diff --git a/src/H5Clog.c b/src/H5Clog.c index 794d6bbcec7..14b37d45a8e 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,55 +23,46 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #define H5AC_FRIEND /* Suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ - +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5C_log_set_up * @@ -87,8 +78,8 @@ herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately) { - int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -97,24 +88,24 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h HDassert(log_location); /* Check logging flags */ - if(cache->log_info->enabled) + if (cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging already set up") - /* Get the rank when MPI is in use. Logging clients will usually - * use that to create per-process logs. - */ + /* Get the rank when MPI is in use. Logging clients will usually + * use that to create per-process logs. + */ #ifdef H5_HAVE_PARALLEL - if(NULL != cache->aux_ptr) + if (NULL != cache->aux_ptr) mpi_rank = ((H5AC_aux_t *)(cache->aux_ptr))->mpi_rank; #endif /*H5_HAVE_PARALLEL*/ /* Set up logging */ - if(H5C_LOG_STYLE_JSON == style) { - if(H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) + if (H5C_LOG_STYLE_JSON == style) { + if (H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging") } - else if(H5C_LOG_STYLE_TRACE == style) { - if(H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) + else if (H5C_LOG_STYLE_TRACE == style) { + if (H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging") } else @@ -124,16 +115,15 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h cache->log_info->enabled = TRUE; /* Start logging if requested */ - if(start_immediately) - if(H5C_start_logging(cache) < 0) + if (start_immediately) + if (H5C_start_logging(cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to start logging") - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C_log_tear_down * @@ -149,7 +139,7 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h herr_t H5C_log_tear_down(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -157,27 +147,26 @@ H5C_log_tear_down(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") /* Stop logging if that's going on */ - if(cache->log_info->logging) - if(H5C_stop_logging(cache) < 0) + if (cache->log_info->logging) + if (H5C_stop_logging(cache) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to stop logging") /* Tear down logging */ - if(cache->log_info->cls->tear_down_logging) - if(cache->log_info->cls->tear_down_logging(cache->log_info) < 0) + if (cache->log_info->cls->tear_down_logging) + if (cache->log_info->cls->tear_down_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific tear down call failed") /* Unset logging flags */ cache->log_info->enabled = FALSE; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_tear_down() */ - /*------------------------------------------------------------------------- * Function: H5C_start_logging * @@ -193,7 +182,7 @@ H5C_log_tear_down(H5C_t *cache) herr_t H5C_start_logging(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -201,27 +190,26 @@ H5C_start_logging(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") /* Start logging */ - if(cache->log_info->cls->start_logging) - if(cache->log_info->cls->start_logging(cache->log_info) < 0) + if (cache->log_info->cls->start_logging) + if (cache->log_info->cls->start_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific start call failed") /* Set logging flags */ cache->log_info->logging = TRUE; /* Write a log message */ - if(cache->log_info->cls->write_start_log_msg) - if(cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_start_log_msg) + if (cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write start call failed") - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_start_logging() */ - /*------------------------------------------------------------------------- * Function: H5C_stop_logging * @@ -237,7 +225,7 @@ H5C_start_logging(H5C_t *cache) herr_t H5C_stop_logging(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -245,29 +233,28 @@ H5C_stop_logging(H5C_t *cache) HDassert(cache); /* Check logging flags */ - if(FALSE == cache->log_info->enabled) + if (FALSE == cache->log_info->enabled) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") - if(FALSE == cache->log_info->logging) + if (FALSE == cache->log_info->logging) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not in progress") /* Write a log message */ - if(cache->log_info->cls->write_stop_log_msg) - if(cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_stop_log_msg) + if (cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write stop call failed") /* Stop logging */ - if(cache->log_info->cls->stop_logging) - if(cache->log_info->cls->stop_logging(cache->log_info) < 0) + if (cache->log_info->cls->stop_logging) + if (cache->log_info->cls->stop_logging(cache->log_info) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific stop call failed") /* Set logging flags */ cache->log_info->logging = FALSE; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_stop_logging() */ - /*------------------------------------------------------------------------- * Function: H5C_get_logging_status * @@ -282,8 +269,7 @@ H5C_stop_logging(H5C_t *cache) *------------------------------------------------------------------------- */ herr_t -H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, - /*OUT*/ hbool_t *is_currently_logging) +H5C_get_logging_status(const H5C_t *cache, hbool_t *is_enabled, hbool_t *is_currently_logging) { FUNC_ENTER_NOAPI_NOERR @@ -293,13 +279,12 @@ H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, HDassert(is_currently_logging); /* Get logging flags */ - *is_enabled = cache->log_info->enabled; + *is_enabled = cache->log_info->enabled; *is_currently_logging = cache->log_info->logging; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_get_logging_status() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_create_cache_msg * @@ -315,7 +300,7 @@ H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -323,8 +308,8 @@ H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_create_cache_log_msg) - if(cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_create_cache_log_msg) + if (cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write create cache call failed") done: @@ -350,7 +335,7 @@ H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -358,15 +343,14 @@ H5C_log_write_destroy_cache_msg(H5C_t *cache) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_destroy_cache_log_msg) - if(cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) + if (cache->log_info->cls->write_destroy_cache_log_msg) + if (cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write destroy cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_destroy_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_evict_cache_msg * @@ -390,15 +374,14 @@ H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_evict_cache_log_msg) - if(cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_evict_cache_log_msg) + if (cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write evict cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_evict_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_expunge_entry_msg * @@ -412,8 +395,7 @@ H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value) *------------------------------------------------------------------------- */ herr_t -H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -423,15 +405,15 @@ H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_expunge_entry_log_msg) - if(cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, fxn_ret_value) < 0) + if (cache->log_info->cls->write_expunge_entry_log_msg) + if (cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write expunge entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_expunge_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_flush_cache_msg * @@ -455,15 +437,14 @@ H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value) HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_flush_cache_log_msg) - if(cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + if (cache->log_info->cls->write_flush_cache_log_msg) + if (cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific flush cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_flush_cache_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_insert_entry_msg * @@ -477,8 +458,8 @@ H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value) *------------------------------------------------------------------------- */ herr_t -H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -488,15 +469,15 @@ H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_insert_entry_log_msg) - if(cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, size, fxn_ret_value) < 0) + if (cache->log_info->cls->write_insert_entry_log_msg) + if (cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, + size, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific insert entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_insert_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_entry_dirty_msg * @@ -510,8 +491,7 @@ H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -522,15 +502,15 @@ H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_entry_dirty_log_msg) - if(cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_entry_dirty_log_msg) + if (cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark dirty entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_entry_dirty_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_entry_clean_msg * @@ -544,10 +524,9 @@ H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -556,15 +535,15 @@ H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_entry_clean_log_msg) - if(cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_entry_clean_log_msg) + if (cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark clean entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_entry_clean_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_unserialized_entry_msg * @@ -578,8 +557,7 @@ H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -590,15 +568,15 @@ H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_unserialized_entry_log_msg) - if(cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_unserialized_entry_log_msg) + if (cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark unserialized entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_unserialized_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_mark_serialized_entry_msg * @@ -612,10 +590,9 @@ H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -624,15 +601,15 @@ H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *e /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_mark_serialized_entry_log_msg) - if(cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_mark_serialized_entry_log_msg) + if (cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark serialized entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_mark_serialized_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_move_entry_msg * @@ -646,8 +623,8 @@ H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *e *------------------------------------------------------------------------- */ herr_t -H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -657,15 +634,15 @@ H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_move_entry_log_msg) - if(cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, type_id, fxn_ret_value) < 0) + if (cache->log_info->cls->write_move_entry_log_msg) + if (cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, + type_id, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific move entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_move_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_pin_entry_msg * @@ -679,8 +656,7 @@ H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -691,15 +667,14 @@ H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_pin_entry_log_msg) - if(cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_pin_entry_log_msg) + if (cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific pin entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_pin_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_create_fd_msg * @@ -714,8 +689,8 @@ H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) +H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -727,15 +702,15 @@ H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, /* Write a log message */ HDassert(parent); HDassert(child); - if(cache->log_info->cls->write_create_fd_log_msg) - if(cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + if (cache->log_info->cls->write_create_fd_log_msg) + if (cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific create fd call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_create_fd_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_protect_entry_msg * @@ -749,8 +724,8 @@ H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -761,15 +736,15 @@ H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_protect_entry_log_msg) - if(cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + if (cache->log_info->cls->write_protect_entry_log_msg) + if (cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific protect entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_protect_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_resize_entry_msg * @@ -783,8 +758,8 @@ H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -795,15 +770,15 @@ H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_resize_entry_log_msg) - if(cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, fxn_ret_value) < 0) + if (cache->log_info->cls->write_resize_entry_log_msg) + if (cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific resize entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_resize_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_unpin_entry_msg * @@ -817,8 +792,7 @@ H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -829,15 +803,14 @@ H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_unpin_entry_log_msg) - if(cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_unpin_entry_log_msg) + if (cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unpin entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_unpin_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_destroy_fd_msg * @@ -852,8 +825,8 @@ H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) +H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -865,15 +838,15 @@ H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, /* Write a log message */ HDassert(parent); HDassert(child); - if(cache->log_info->cls->write_destroy_fd_log_msg) - if(cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + if (cache->log_info->cls->write_destroy_fd_log_msg) + if (cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific destroy fd call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_destroy_fd_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_unprotect_entry_msg * @@ -887,8 +860,8 @@ H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -898,15 +871,15 @@ H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, HDassert(cache); /* Write a log message */ - if(cache->log_info->cls->write_unprotect_entry_log_msg) - if(cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, address, type_id, flags, fxn_ret_value) < 0) + if (cache->log_info->cls->write_unprotect_entry_log_msg) + if (cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, address, type_id, + flags, fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unprotect entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_unprotect_entry_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_set_cache_config_msg * @@ -920,8 +893,7 @@ H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, *------------------------------------------------------------------------- */ herr_t -H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, - herr_t fxn_ret_value) +H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -932,15 +904,15 @@ H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *conf /* Write a log message */ HDassert(config); - if(cache->log_info->cls->write_set_cache_config_log_msg) - if(cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, fxn_ret_value) < 0) + if (cache->log_info->cls->write_set_cache_config_log_msg) + if (cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, + fxn_ret_value) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific set cache config call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_set_cache_config_msg() */ - /*------------------------------------------------------------------------- * Function: H5C_log_write_remove_entry_msg * @@ -954,8 +926,7 @@ H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *conf *------------------------------------------------------------------------- */ herr_t -H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { herr_t ret_value = SUCCEED; @@ -966,11 +937,11 @@ H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, /* Write a log message */ HDassert(entry); - if(cache->log_info->cls->write_remove_entry_log_msg) - if(cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + if (cache->log_info->cls->write_remove_entry_log_msg) + if (cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < + 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific remove entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_write_remove_entry_msg() */ - diff --git a/src/H5Clog.h b/src/H5Clog.h index 0235c4ab960..790a0736be3 100644 --- a/src/H5Clog.h +++ b/src/H5Clog.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,11 +15,11 @@ * Purpose: Cache logging header file */ -#ifndef _H5Clog_H -#define _H5Clog_H +#ifndef H5Clog_H +#define H5Clog_H /* Get package's private header */ -#include "H5Cprivate.h" /* Cache */ +#include "H5Cprivate.h" /* Cache */ /**************************/ /* Package Private Macros */ @@ -34,7 +34,7 @@ typedef struct H5C_log_info_t H5C_log_info_t; /* Class for generating logging messages */ typedef struct H5C_log_class_t { - const char *name; /* String for debugging */ + const char *name; /* String for debugging */ /* Callbacks for writing log messages */ herr_t (*tear_down_logging)(H5C_log_info_t *log_info); @@ -47,68 +47,93 @@ typedef struct H5C_log_class_t { herr_t (*write_evict_cache_log_msg)(void *udata, herr_t fxn_ret_value); herr_t (*write_expunge_entry_log_msg)(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); herr_t (*write_flush_cache_log_msg)(void *udata, herr_t fxn_ret_value); - herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); - herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); + herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); + herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); + herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); herr_t (*write_pin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); - herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); - herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); + herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); + herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value); herr_t (*write_unpin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); - herr_t (*write_unprotect_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); - herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); + herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_unprotect_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value); + herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); herr_t (*write_remove_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); } H5C_log_class_t; /* Logging information */ struct H5C_log_info_t { - hbool_t enabled; /* Was the logging set up? */ - hbool_t logging; /* Are we currently logging? */ - H5C_log_class_t *cls; /* Callbacks for writing log messages */ - void *udata; /* Log-specific data */ + 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 */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately); +H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, + hbool_t start_immediately); H5_DLL herr_t H5C_log_tear_down(H5C_t *cache); H5_DLL herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache); H5_DLL herr_t H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, + herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); H5_DLL herr_t H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /* Logging-specific setup functions */ H5_DLL herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); H5_DLL herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); -#endif /* _H5Clog_H */ - +#endif /* H5Clog_H */ diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index ab25a5537ab..18323ca74e9 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,17 +24,16 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -43,12 +42,10 @@ /* Max log message size */ #define H5C_MAX_JSON_LOG_MSG_SIZE 1024 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ @@ -58,7 +55,6 @@ typedef struct H5C_log_json_udata_t { char *message; } H5C_log_json_udata_t; - /********************/ /* Local Prototypes */ /********************/ @@ -73,35 +69,48 @@ static herr_t H5C__json_write_stop_log_msg(void *udata); static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value); static herr_t H5C__json_write_destroy_cache_log_msg(void *udata); static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, + herr_t fxn_ret_value); static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); -static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - +static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value); +static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -109,37 +118,33 @@ static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_ /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_json_log_class_g = { - "json", - H5C__json_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - H5C__json_write_start_log_msg, - H5C__json_write_stop_log_msg, - H5C__json_write_create_cache_log_msg, - H5C__json_write_destroy_cache_log_msg, - H5C__json_write_evict_cache_log_msg, - H5C__json_write_expunge_entry_log_msg, - H5C__json_write_flush_cache_log_msg, - H5C__json_write_insert_entry_log_msg, - H5C__json_write_mark_entry_dirty_log_msg, - H5C__json_write_mark_entry_clean_log_msg, - H5C__json_write_mark_unserialized_entry_log_msg, - H5C__json_write_mark_serialized_entry_log_msg, - H5C__json_write_move_entry_log_msg, - H5C__json_write_pin_entry_log_msg, - H5C__json_write_create_fd_log_msg, - H5C__json_write_protect_entry_log_msg, - H5C__json_write_resize_entry_log_msg, - H5C__json_write_unpin_entry_log_msg, - H5C__json_write_destroy_fd_log_msg, - H5C__json_write_unprotect_entry_log_msg, - H5C__json_write_set_cache_config_log_msg, - H5C__json_write_remove_entry_log_msg -}; - - - +static const H5C_log_class_t H5C_json_log_class_g = {"json", + H5C__json_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + H5C__json_write_start_log_msg, + H5C__json_write_stop_log_msg, + H5C__json_write_create_cache_log_msg, + H5C__json_write_destroy_cache_log_msg, + H5C__json_write_evict_cache_log_msg, + H5C__json_write_expunge_entry_log_msg, + H5C__json_write_flush_cache_log_msg, + H5C__json_write_insert_entry_log_msg, + H5C__json_write_mark_entry_dirty_log_msg, + H5C__json_write_mark_entry_clean_log_msg, + H5C__json_write_mark_unserialized_entry_log_msg, + H5C__json_write_mark_serialized_entry_log_msg, + H5C__json_write_move_entry_log_msg, + H5C__json_write_pin_entry_log_msg, + H5C__json_write_create_fd_log_msg, + H5C__json_write_protect_entry_log_msg, + H5C__json_write_resize_entry_log_msg, + H5C__json_write_unpin_entry_log_msg, + H5C__json_write_destroy_fd_log_msg, + H5C__json_write_unprotect_entry_log_msg, + H5C__json_write_set_cache_config_log_msg, + H5C__json_write_remove_entry_log_msg}; + /*------------------------------------------------------------------------- * Function: H5C__json_write_log_message * @@ -157,7 +162,7 @@ static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) { size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -168,7 +173,7 @@ H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) /* Write the log message and flush */ n_chars = HDstrlen(json_udata->message); - if((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message)) + if ((int)n_chars != HDfprintf(json_udata->outfile, "%s", json_udata->message)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") HDmemset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char))); @@ -176,7 +181,6 @@ H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_log_message() */ - /*------------------------------------------------------------------------- * Function: H5C_log_json_set_up * @@ -205,9 +209,9 @@ 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; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + char * file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -219,12 +223,12 @@ H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi log_info->cls = &H5C_json_log_class_g; /* Allocate memory for the JSON-specific data */ - if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) + if (NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") json_udata = (H5C_log_json_udata_t *)(log_info->udata); /* Allocate memory for the message buffer */ - if(NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) + if (NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Possibly fix up the log file name. @@ -235,41 +239,41 @@ H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi * allocation size = "RANK_" + + dot + + \0 */ n_chars = 5 + 39 + 1 + HDstrlen(log_location) + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + if (NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "can't allocate memory for mdc log file name manipulation") /* Add the rank to the log file name when MPI is in use */ - if(-1 == mpi_rank) + if (-1 == mpi_rank) HDsnprintf(file_name, n_chars, "%s", log_location); else HDsnprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location); /* Open log file and set it to be unbuffered */ - if(NULL == (json_udata->outfile = HDfopen(file_name, "w"))) + if (NULL == (json_udata->outfile = HDfopen(file_name, "w"))) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") HDsetbuf(json_udata->outfile, NULL); - done: - if(file_name) +done: + if (file_name) H5MM_xfree(file_name); /* Free and reset the log info struct on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { /* Free */ - if(json_udata && json_udata->message) + if (json_udata && json_udata->message) H5MM_xfree(json_udata->message); - if(json_udata) + if (json_udata) H5MM_xfree(json_udata); /* Reset */ log_info->udata = NULL; - log_info->cls = NULL; + log_info->cls = NULL; } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_json_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C__json_tear_down_logging * @@ -286,7 +290,7 @@ static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info) { H5C_log_json_udata_t *json_udata = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -300,7 +304,7 @@ H5C__json_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(json_udata->message); /* Close log file */ - if(EOF == HDfclose(json_udata->outfile)) + if (EOF == HDfclose(json_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") json_udata->outfile = NULL; @@ -308,14 +312,13 @@ H5C__json_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(json_udata); /* Reset the log class info and udata */ - log_info->cls = NULL; + log_info->cls = NULL; log_info->udata = NULL; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_tear_down_logging() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_start_log_msg * @@ -332,7 +335,7 @@ static herr_t H5C__json_write_start_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -341,26 +344,24 @@ H5C__json_write_start_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string (opens the JSON array) */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\n\ \"HDF5 metadata cache log messages\" : [\n\ {\ \"timestamp\":%lld,\ \"action\":\"logging start\"\ },\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_start_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_stop_log_msg * @@ -377,7 +378,7 @@ static herr_t H5C__json_write_stop_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -386,25 +387,23 @@ H5C__json_write_stop_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string (closes the JSON array) */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"logging stop\"\ }\n\ ]}\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_stop_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_create_cache_log_msg * @@ -421,7 +420,7 @@ static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -430,25 +429,23 @@ H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"create\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_create_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_destroy_cache_log_msg * @@ -465,7 +462,7 @@ static herr_t H5C__json_write_destroy_cache_log_msg(void *udata) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -474,24 +471,22 @@ H5C__json_write_destroy_cache_log_msg(void *udata) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"destroy\"\ },\n\ -" - , (long long)HDtime(NULL)); +", + (long long)HDtime(NULL)); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_destroy_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_evict_cache_log_msg * @@ -508,7 +503,7 @@ static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -517,25 +512,23 @@ H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"evict\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_evict_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_expunge_entry_log_msg * @@ -549,11 +542,10 @@ H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -562,8 +554,7 @@ H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"expunge\",\ @@ -571,19 +562,17 @@ H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, \"type_id\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); - +", + (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_expunge_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_flush_cache_log_msg * @@ -600,7 +589,7 @@ static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -609,25 +598,23 @@ H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"flush\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_flush_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_insert_entry_log_msg * @@ -641,11 +628,11 @@ H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -654,8 +641,7 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"insert\",\ @@ -665,19 +651,18 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, \"size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, type_id, flags, - (int)size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)size, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_insert_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_entry_dirty_log_msg * @@ -691,11 +676,10 @@ H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -705,26 +689,24 @@ H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *e HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"dirty\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_entry_dirty_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_entry_clean_log_msg * @@ -738,11 +720,10 @@ H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *e *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -752,26 +733,24 @@ H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *e HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"clean\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_entry_clean_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_unserialized_entry_log_msg * @@ -785,11 +764,11 @@ H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *e *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_mark_unserialized_entry_log_msg(void *udata, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -799,26 +778,24 @@ H5C__json_write_mark_unserialized_entry_log_msg(void *udata, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unserialized\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_unserialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_mark_serialize_entry_log_msg * @@ -833,10 +810,10 @@ H5C__json_write_mark_unserialized_entry_log_msg(void *udata, */ static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -846,26 +823,24 @@ H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"serialized\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_mark_serialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_move_entry_log_msg * @@ -879,11 +854,11 @@ H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -892,8 +867,7 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"move\",\ @@ -902,19 +876,18 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad \"type_id\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)old_addr, - (unsigned long)new_addr, type_id, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)old_addr, (unsigned long)new_addr, type_id, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_move_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_pin_entry_log_msg * @@ -928,11 +901,10 @@ H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_ad *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -942,27 +914,24 @@ H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"pin\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_pin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_create_fd_log_msg * @@ -978,10 +947,10 @@ H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, */ static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -992,8 +961,7 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"create_fd\",\ @@ -1001,19 +969,18 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, \"child_addr\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_create_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_protect_entry_log_msg * @@ -1027,12 +994,12 @@ H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - char rw_s[16]; - herr_t ret_value = SUCCEED; + char rw_s[16]; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1041,14 +1008,13 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr HDassert(json_udata->message); HDassert(entry); - if(H5C__READ_ONLY_FLAG == flags) + if (H5C__READ_ONLY_FLAG == flags) HDstrcpy(rw_s, "READ"); else HDstrcpy(rw_s, "WRITE"); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"protect\",\ @@ -1058,19 +1024,18 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr \"size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - type_id, rw_s, (int)entry->size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, type_id, rw_s, (int)entry->size, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_protect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_resize_entry_log_msg * @@ -1084,11 +1049,11 @@ H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entr *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1098,8 +1063,7 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"resize\",\ @@ -1107,19 +1071,17 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry \"new_size\":%d,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)new_size, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)new_size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_resize_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_unpin_entry_log_msg * @@ -1133,11 +1095,10 @@ H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1147,27 +1108,24 @@ H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unpin\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_unpin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_destroy_fd_log_msg * @@ -1183,10 +1141,10 @@ H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, */ static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1197,8 +1155,7 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"destroy_fd\",\ @@ -1206,19 +1163,18 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, \"child_addr\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)parent->addr, (unsigned long)child->addr, + (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_destroy_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_unprotect_entry_log_msg * @@ -1232,11 +1188,11 @@ H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1245,8 +1201,7 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, HDassert(json_udata->message); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"unprotect\",\ @@ -1255,19 +1210,17 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, \"flags\":%x,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, - type_id, flags, (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)address, type_id, flags, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_unprotect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_set_cache_config_log_msg * @@ -1282,10 +1235,10 @@ H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, */ static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t H5_ATTR_NDEBUG_UNUSED *config, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1295,26 +1248,23 @@ H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t HDassert(config); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"set_config\",\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - +", + (long long)HDtime(NULL), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_set_cache_config_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__json_write_remove_entry_log_msg * @@ -1328,11 +1278,10 @@ H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *------------------------------------------------------------------------- */ static herr_t -H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1342,23 +1291,20 @@ H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry HDassert(entry); /* Create the log message string */ - HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, -"\ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\ {\ \"timestamp\":%lld,\ \"action\":\"remove\",\ \"address\":0x%lx,\ \"returned\":%d\ },\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); +", + (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__json_write_log_message(json_udata) < 0) + if (H5C__json_write_log_message(json_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__json_write_remove_entry_log_msg() */ - diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c index 63fe3827b7c..d33d1b05a65 100644 --- a/src/H5Clog_trace.c +++ b/src/H5Clog_trace.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,17 +24,16 @@ /****************/ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Clog.h" /* Cache logging */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -43,12 +42,10 @@ /* Max log message size */ #define H5C_MAX_TRACE_LOG_MSG_SIZE 4096 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ @@ -58,7 +55,6 @@ typedef struct H5C_log_trace_udata_t { char *message; } H5C_log_trace_udata_t; - /********************/ /* Local Prototypes */ /********************/ @@ -68,35 +64,48 @@ static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata); /* Log message callbacks */ static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info); -static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, + herr_t fxn_ret_value); static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); -static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); -static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); -static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); -static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); -static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value); -static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); -static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); - +static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + size_t size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, + unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value); +static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -104,37 +113,33 @@ static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache /* Note that there's no cache set up call since that's the * place where this struct is wired into the cache. */ -static H5C_log_class_t H5C_trace_log_class_g = { - "trace", - H5C__trace_tear_down_logging, - NULL, /* start logging */ - NULL, /* stop logging */ - NULL, /* write start message */ - NULL, /* write stop message */ - NULL, /* write create cache message */ - NULL, /* write destroy cache message */ - NULL, /* write evict cache message */ - H5C__trace_write_expunge_entry_log_msg, - H5C__trace_write_flush_cache_log_msg, - H5C__trace_write_insert_entry_log_msg, - H5C__trace_write_mark_entry_dirty_log_msg, - H5C__trace_write_mark_entry_clean_log_msg, - H5C__trace_write_mark_unserialized_entry_log_msg, - H5C__trace_write_mark_serialized_entry_log_msg, - H5C__trace_write_move_entry_log_msg, - H5C__trace_write_pin_entry_log_msg, - H5C__trace_write_create_fd_log_msg, - H5C__trace_write_protect_entry_log_msg, - H5C__trace_write_resize_entry_log_msg, - H5C__trace_write_unpin_entry_log_msg, - H5C__trace_write_destroy_fd_log_msg, - H5C__trace_write_unprotect_entry_log_msg, - H5C__trace_write_set_cache_config_log_msg, - H5C__trace_write_remove_entry_log_msg -}; - - - +static const H5C_log_class_t H5C_trace_log_class_g = {"trace", + H5C__trace_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + NULL, /* write start message */ + NULL, /* write stop message */ + NULL, /* write create cache message */ + NULL, /* write destroy cache message */ + NULL, /* write evict cache message */ + H5C__trace_write_expunge_entry_log_msg, + H5C__trace_write_flush_cache_log_msg, + H5C__trace_write_insert_entry_log_msg, + H5C__trace_write_mark_entry_dirty_log_msg, + H5C__trace_write_mark_entry_clean_log_msg, + H5C__trace_write_mark_unserialized_entry_log_msg, + H5C__trace_write_mark_serialized_entry_log_msg, + H5C__trace_write_move_entry_log_msg, + H5C__trace_write_pin_entry_log_msg, + H5C__trace_write_create_fd_log_msg, + H5C__trace_write_protect_entry_log_msg, + H5C__trace_write_resize_entry_log_msg, + H5C__trace_write_unpin_entry_log_msg, + H5C__trace_write_destroy_fd_log_msg, + H5C__trace_write_unprotect_entry_log_msg, + H5C__trace_write_set_cache_config_log_msg, + H5C__trace_write_remove_entry_log_msg}; + /*------------------------------------------------------------------------- * Function: H5C__trace_write_log_message * @@ -152,7 +157,7 @@ static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) { size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -163,7 +168,7 @@ H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) /* Write the log message and flush */ n_chars = HDstrlen(trace_udata->message); - if((int)n_chars != HDfprintf(trace_udata->outfile, trace_udata->message)) + if ((int)n_chars != HDfprintf(trace_udata->outfile, "%s", trace_udata->message)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") HDmemset((void *)(trace_udata->message), 0, (size_t)(n_chars * sizeof(char))); @@ -171,7 +176,6 @@ H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_log_message() */ - /*------------------------------------------------------------------------- * Function: H5C_log_trace_set_up * @@ -200,9 +204,9 @@ 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; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + char * file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -214,12 +218,12 @@ H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mp log_info->cls = &H5C_trace_log_class_g; /* Allocate memory for the JSON-specific data */ - if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) + if (NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); /* Allocate memory for the message buffer */ - if(NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) + if (NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Possibly fix up the log file name. @@ -230,44 +234,44 @@ H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mp * allocation size = + dot + + \0 */ n_chars = HDstrlen(log_location) + 1 + 39 + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + if (NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "can't allocate memory for mdc log file name manipulation") /* Add the rank to the log file name when MPI is in use */ - if(-1 == mpi_rank) + if (-1 == mpi_rank) HDsnprintf(file_name, n_chars, "%s", log_location); else HDsnprintf(file_name, n_chars, "%s.%d", log_location, mpi_rank); /* Open log file and set it to be unbuffered */ - if(NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) + if (NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") HDsetbuf(trace_udata->outfile, NULL); /* Write the header */ HDfprintf(trace_udata->outfile, "### HDF5 metadata cache trace file version 1 ###\n"); - done: - if(file_name) +done: + if (file_name) H5MM_xfree(file_name); /* Free and reset the log info struct on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { /* Free */ - if(trace_udata && trace_udata->message) + if (trace_udata && trace_udata->message) H5MM_xfree(trace_udata->message); - if(trace_udata) + if (trace_udata) H5MM_xfree(trace_udata); /* Reset */ log_info->udata = NULL; - log_info->cls = NULL; + log_info->cls = NULL; } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_log_trace_set_up() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_tear_down_logging * @@ -284,7 +288,7 @@ static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info) { H5C_log_trace_udata_t *trace_udata = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -298,7 +302,7 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(trace_udata->message); /* Close log file */ - if(EOF == HDfclose(trace_udata->outfile)) + if (EOF == HDfclose(trace_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") trace_udata->outfile = NULL; @@ -306,14 +310,13 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(trace_udata); /* Reset the log class info and udata */ - log_info->cls = NULL; + log_info->cls = NULL; log_info->udata = NULL; - done: +done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_tear_down_logging() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_expunge_entry_log_msg * @@ -327,11 +330,10 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, - int type_id, herr_t fxn_ret_value) +H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -341,17 +343,16 @@ H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_expunge_entry 0x%lx %d %d\n", - (unsigned long)address, type_id, (int)fxn_ret_value); + (unsigned long)address, type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_expunge_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_flush_cache_log_msg * @@ -368,7 +369,7 @@ static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -377,18 +378,16 @@ H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) HDassert(trace_udata->message); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", - (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_flush_cache_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_insert_entry_log_msg * @@ -402,11 +401,11 @@ H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -416,17 +415,16 @@ H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_insert_entry 0x%lx %d 0x%x %d %d\n", - (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); + (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_insert_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_entry_dirty_log_msg * @@ -440,11 +438,10 @@ H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -455,17 +452,16 @@ H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t * /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_dirty 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_entry_dirty_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_entry_clean_log_msg * @@ -479,11 +475,10 @@ H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t * *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -494,17 +489,16 @@ H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t * /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_clean 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_entry_clean_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_unserialized_entry_log_msg * @@ -518,11 +512,11 @@ H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t * *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, - const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -533,17 +527,16 @@ H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_unserialized 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_unserialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_mark_serialized_entry_log_msg * @@ -558,10 +551,10 @@ H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, */ static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -572,17 +565,16 @@ H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_serialized 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_mark_serialized_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_move_entry_log_msg * @@ -596,11 +588,11 @@ H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entr *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, - int type_id, herr_t fxn_ret_value) +H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -610,17 +602,16 @@ H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_a /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_move_entry 0x%lx 0x%lx %d %d\n", - (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); + (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_move_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_pin_entry_log_msg * @@ -634,11 +625,10 @@ H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_a *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -649,17 +639,16 @@ H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_pin_protected_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_pin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_create_fd_log_msg * @@ -675,10 +664,10 @@ H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, */ static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -689,18 +678,18 @@ H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, HDassert(child); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", - (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", (unsigned long)(parent->addr), + (unsigned long)(child->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_create_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_protect_entry_log_msg * @@ -714,11 +703,11 @@ H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, + unsigned flags, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -729,17 +718,16 @@ H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *ent /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_protect 0x%lx %d 0x%x %d %d\n", - (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); + (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_protect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_resize_entry_log_msg * @@ -753,11 +741,11 @@ H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *ent *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - size_t new_size, herr_t fxn_ret_value) +H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -768,17 +756,16 @@ H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_resize_entry 0x%lx %d %d\n", - (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_resize_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_unpin_entry_log_msg * @@ -792,11 +779,10 @@ H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entr *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -807,17 +793,16 @@ H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unpin_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_unpin_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_destroy_fd_log_msg * @@ -833,10 +818,10 @@ H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry */ static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, - const H5C_cache_entry_t *child, herr_t fxn_ret_value) + const H5C_cache_entry_t *child, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -847,18 +832,18 @@ H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent HDassert(child); /* Create the log message string */ - HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", - (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", (unsigned long)(parent->addr), + (unsigned long)(child->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_destroy_fd_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_unprotect_entry_log_msg * @@ -872,11 +857,11 @@ H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, - int type_id, unsigned flags, herr_t fxn_ret_value) +H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -886,17 +871,16 @@ H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unprotect 0x%lx %d 0x%x %d\n", - (unsigned long)(address), type_id, flags, (int)fxn_ret_value); + (unsigned long)(address), type_id, flags, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_unprotect_entry_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_set_cache_config_log_msg * @@ -911,10 +895,10 @@ H5C__trace_write_unprotect_entry_log_msg(void *udata, haddr_t address, */ static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, - herr_t fxn_ret_value) + herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -925,48 +909,28 @@ H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, - "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", - config->version, - (int)(config->rpt_fcn_enabled), - (int)(config->open_trace_file), - (int)(config->close_trace_file), - config->trace_file_name, - (int)(config->evictions_enabled), - (int)(config->set_initial_size), - (int)(config->initial_size), - config->min_clean_fraction, - (int)(config->max_size), - (int)(config->min_size), - config->epoch_length, - (int)(config->incr_mode), - config->lower_hr_threshold, - config->increment, - (int)(config->flash_incr_mode), - config->flash_multiple, - config->flash_threshold, - (int)(config->apply_max_increment), - (int)(config->max_increment), - (int)(config->decr_mode), - config->upper_hr_threshold, - config->decrement, - (int)(config->apply_max_decrement), - (int)(config->max_decrement), - config->epochs_before_eviction, - (int)(config->apply_empty_reserve), - config->empty_reserve, - config->dirty_bytes_threshold, - config->metadata_write_strategy, - (int)fxn_ret_value); + "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f " + "%d %d %d %f %f %d %d %d %d %f %zu %d %d\n", + config->version, (int)(config->rpt_fcn_enabled), (int)(config->open_trace_file), + (int)(config->close_trace_file), config->trace_file_name, (int)(config->evictions_enabled), + (int)(config->set_initial_size), (int)(config->initial_size), config->min_clean_fraction, + (int)(config->max_size), (int)(config->min_size), config->epoch_length, + (int)(config->incr_mode), config->lower_hr_threshold, config->increment, + (int)(config->flash_incr_mode), config->flash_multiple, config->flash_threshold, + (int)(config->apply_max_increment), (int)(config->max_increment), (int)(config->decr_mode), + config->upper_hr_threshold, config->decrement, (int)(config->apply_max_decrement), + (int)(config->max_decrement), config->epochs_before_eviction, + (int)(config->apply_empty_reserve), config->empty_reserve, config->dirty_bytes_threshold, + config->metadata_write_strategy, (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_set_cache_config_log_msg() */ - /*------------------------------------------------------------------------- * Function: H5C__trace_write_remove_entry_log_msg * @@ -980,11 +944,10 @@ H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *------------------------------------------------------------------------- */ static herr_t -H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, - herr_t fxn_ret_value) +H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value) { H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -995,13 +958,12 @@ H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entr /* Create the log message string */ HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_remove_entry 0x%lx %d\n", - (unsigned long)(entry->addr), (int)fxn_ret_value); + (unsigned long)(entry->addr), (int)fxn_ret_value); /* Write the log message to the file */ - if(H5C__trace_write_log_message(trace_udata) < 0) + if (H5C__trace_write_log_message(trace_udata) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__trace_write_remove_entry_log_msg() */ - diff --git a/src/H5Cmodule.h b/src/H5Cmodule.h index 5b23490837b..26216ec1316 100644 --- a/src/H5Cmodule.h +++ b/src/H5Cmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5C package. Including this header means that the source file * is part of the H5C package. */ -#ifndef _H5Cmodule_H -#define _H5Cmodule_H +#ifndef H5Cmodule_H +#define H5Cmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5C_MODULE -#define H5_MY_PKG H5C -#define H5_MY_PKG_ERR H5E_CACHE -#define H5_MY_PKG_INIT NO - -#endif /* _H5Cmodule_H */ +#define H5_MY_PKG H5C +#define H5_MY_PKG_ERR H5E_CACHE +#define H5_MY_PKG_INIT NO +#endif /* H5Cmodule_H */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index e0b7f17c118..66c6601bf91 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,7 +18,7 @@ * Quincey Koziol * * Purpose: Functions in this file implement support for parallel I/O for - * generic cache code. + * generic cache code. * *------------------------------------------------------------------------- */ @@ -27,22 +27,20 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL /****************/ @@ -50,38 +48,31 @@ /****************/ #define H5C_APPLY_CANDIDATE_LIST__DEBUG 0 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5C__collective_write(H5F_t *f); static herr_t H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES], - unsigned entries_to_clear[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); - + unsigned entries_to_clear[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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5C_apply_candidate_list * @@ -163,43 +154,30 @@ static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * Programmer: John Mainzer * 3/17/10 * - * Changes: Updated sanity checks to allow for the possibility that - * the slist is disabled. - * JRM -- 8/3/20 - * *------------------------------------------------------------------------- */ herr_t -H5C_apply_candidate_list(H5F_t * f, - H5C_t * cache_ptr, - unsigned num_candidates, - haddr_t * candidates_list_ptr, - int mpi_rank, - int mpi_size) +H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr, + int mpi_rank, int mpi_size) { - int i; - int m; - int n; - unsigned first_entry_to_flush; - unsigned last_entry_to_flush; - unsigned total_entries_to_clear = 0; - unsigned total_entries_to_flush = 0; - int * candidate_assignment_table = NULL; - unsigned entries_to_flush[H5C_RING_NTYPES]; - unsigned entries_to_clear[H5C_RING_NTYPES]; - haddr_t addr; - H5C_cache_entry_t * entry_ptr = NULL; - + unsigned first_entry_to_flush; + unsigned last_entry_to_flush; + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; + unsigned * candidate_assignment_table = NULL; + unsigned entries_to_flush[H5C_RING_NTYPES]; + unsigned entries_to_clear[H5C_RING_NTYPES]; + haddr_t addr; + H5C_cache_entry_t *entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - haddr_t last_addr; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ - #if H5C_APPLY_CANDIDATE_LIST__DEBUG - char tbl_buf[1024]; + char tbl_buf[1024]; #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned m, n; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -207,8 +185,7 @@ H5C_apply_candidate_list(H5F_t * f, HDassert(cache_ptr != NULL); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(num_candidates > 0); - HDassert( ( ! cache_ptr->slist_enabled ) || - ( num_candidates <= cache_ptr->slist_len )); + HDassert((!cache_ptr->slist_enabled) || (num_candidates <= cache_ptr->slist_len)); HDassert(candidates_list_ptr != NULL); HDassert(0 <= mpi_rank); HDassert(mpi_rank < mpi_size); @@ -223,92 +200,93 @@ H5C_apply_candidate_list(H5F_t * f, HDmemset(tbl_buf, 0, sizeof(tbl_buf)); HDsprintf(&(tbl_buf[0]), "candidate list = "); - for(u = 0; u < num_candidates; u++) + for (u = 0; u < num_candidates; u++) HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " 0x%llx", (long long)(*(candidates_list_ptr + u))); HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - if(f->coll_md_write) { + if (f->shared->coll_md_write) { /* Sanity check */ HDassert(NULL == cache_ptr->coll_write_list); /* Create skip list of entries for collective write */ - if(NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries") } /* end if */ - n = num_candidates / mpi_size; - m = num_candidates % mpi_size; - HDassert(n >= 0); - if(NULL == (candidate_assignment_table = (int *)H5MM_malloc(sizeof(int) * (size_t)(mpi_size + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for candidate assignment table") + n = num_candidates / (unsigned)mpi_size; + m = num_candidates % (unsigned)mpi_size; + + if (NULL == + (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for candidate assignment table") - candidate_assignment_table[0] = 0; + candidate_assignment_table[0] = 0; candidate_assignment_table[mpi_size] = num_candidates; - if(m == 0) { /* mpi_size is an even divisor of num_candidates */ - HDassert(n > 0); - for(i = 1; i < mpi_size; i++) - candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n; + if (m == 0) { /* mpi_size is an even divisor of num_candidates */ + for (u = 1; u < (unsigned)mpi_size; u++) + candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n; } /* end if */ else { - for(i = 1; i <= m; i++) - candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n + 1; + for (u = 1; u <= m; u++) + candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n + 1; - if(num_candidates < mpi_size) { - for(i = m + 1; i < mpi_size; i++) - candidate_assignment_table[i] = num_candidates; + if (num_candidates < (unsigned)mpi_size) { + for (u = m + 1; u < (unsigned)mpi_size; u++) + candidate_assignment_table[u] = num_candidates; } /* end if */ else { - for(i = m + 1; i < mpi_size; i++) - candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n; + for (u = m + 1; u < (unsigned)mpi_size; u++) + candidate_assignment_table[u] = candidate_assignment_table[u - 1] + n; } /* end else */ - } /* end else */ + } /* end else */ HDassert((candidate_assignment_table[mpi_size - 1] + n) == num_candidates); #if H5C_DO_SANITY_CHECKS /* Verify that the candidate assignment table has the expected form */ - for(i = 1; i < mpi_size - 1; i++) { - int a, b; + for (u = 1; u < (unsigned)(mpi_size - 1); u++) { + unsigned a, b; - a = candidate_assignment_table[i] - candidate_assignment_table[i - 1]; - b = candidate_assignment_table[i + 1] - candidate_assignment_table[i]; + a = candidate_assignment_table[u] - candidate_assignment_table[u - 1]; + b = candidate_assignment_table[u + 1] - candidate_assignment_table[u]; - HDassert( n + 1 >= a ); - HDassert( a >= b ); - HDassert( b >= n ); + HDassert(n + 1 >= a); + HDassert(a >= b); + HDassert(b >= n); } #endif /* H5C_DO_SANITY_CHECKS */ first_entry_to_flush = candidate_assignment_table[mpi_rank]; - last_entry_to_flush = candidate_assignment_table[mpi_rank + 1] - 1; + last_entry_to_flush = candidate_assignment_table[mpi_rank + 1] - 1; #if H5C_APPLY_CANDIDATE_LIST__DEBUG - for ( i = 0; i < 1024; i++ ) - tbl_buf[i] = '\0'; + for (u = 0; u < 1024; u++) + tbl_buf[u] = '\0'; HDsprintf(&(tbl_buf[0]), "candidate assignment table = "); - for(i = 0; i <= mpi_size; i++) - HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]); + for (u = 0; u <= (unsigned)mpi_size; u++) + HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[u]); HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n"); HDfprintf(stdout, "%s", tbl_buf); - HDfprintf(stdout, "%s:%d: flush entries [%u, %u].\n", - FUNC, mpi_rank, first_entry_to_flush, last_entry_to_flush); + HDfprintf(stdout, "%s:%d: flush entries [%u, %u].\n", FUNC, mpi_rank, first_entry_to_flush, + last_entry_to_flush); HDfprintf(stdout, "%s:%d: marking entries.\n", FUNC, mpi_rank); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - for(u = 0; u < num_candidates; u++) { + for (u = 0; u < num_candidates; u++) { addr = candidates_list_ptr[u]; HDassert(H5F_addr_defined(addr)); #if H5C_DO_SANITY_CHECKS - if(u > 0) { - if(last_addr == addr) + if (u > 0) { + if (last_addr == addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "duplicate entry in cleaned list") - else if(last_addr > addr) + else if (last_addr > addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "candidate list not sorted") } /* end if */ @@ -316,11 +294,11 @@ H5C_apply_candidate_list(H5F_t * f, #endif /* H5C_DO_SANITY_CHECKS */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "listed candidate entry not in cache?!?!?") - if(!entry_ptr->is_dirty) + if (!entry_ptr->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not dirty?!?!?") - if(entry_ptr->is_protected) + if (entry_ptr->is_protected) /* For now at least, we can't deal with protected entries. * If we encounter one, scream and die. If it becomes an * issue, we should be able to work around this. @@ -339,7 +317,7 @@ H5C_apply_candidate_list(H5F_t * f, * pinned list shortly, and clear or flush according to these * markings. */ - if(u >= first_entry_to_flush && u <= last_entry_to_flush) { + if (u >= first_entry_to_flush && u <= last_entry_to_flush) { total_entries_to_flush++; entries_to_flush[entry_ptr->ring]++; entry_ptr->flush_immediately = TRUE; @@ -356,28 +334,27 @@ H5C_apply_candidate_list(H5F_t * f, * candidate list is collective and uniform across all * ranks. */ - if(entry_ptr->coll_access) { + if (entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) } /* end if */ - } /* end for */ + } /* end for */ #if H5C_DO_SANITY_CHECKS m = 0; n = 0; - for(i = 0; i < H5C_RING_NTYPES; i++) { - m += (int)entries_to_flush[i]; - n += (int)entries_to_clear[i]; + for (u = 0; u < H5C_RING_NTYPES; u++) { + m += entries_to_flush[u]; + n += entries_to_clear[u]; } /* end if */ HDassert((unsigned)m == total_entries_to_flush); - HDassert((unsigned)n == total_entries_to_clear); + HDassert(n == total_entries_to_clear); #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_APPLY_CANDIDATE_LIST__DEBUG - HDfprintf(stdout, "%s:%d: num candidates/to clear/to flush = %u/%u/%u.\n", - FUNC, mpi_rank, num_candidates, total_entries_to_clear, - total_entries_to_flush); + HDfprintf(stdout, "%s:%d: num candidates/to clear/to flush = %u/%u/%u.\n", FUNC, mpi_rank, num_candidates, + total_entries_to_clear, total_entries_to_flush); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ /* We have now marked all the entries on the candidate list for @@ -390,24 +367,24 @@ H5C_apply_candidate_list(H5F_t * f, * If we don't do this, my experiments indicate that we will have a * noticeably poorer hit ratio as a result. */ - if(H5C__flush_candidate_entries(f, entries_to_flush, entries_to_clear) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates failed") + if (H5C__flush_candidate_entries(f, entries_to_flush, entries_to_clear) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates failed") /* If we've deferred writing to do it collectively, take care of that now */ - if(f->coll_md_write) { + if (f->shared->coll_md_write) { /* Sanity check */ HDassert(cache_ptr->coll_write_list); /* Write collective list */ - if(H5C__collective_write(f) < 0) + if (H5C__collective_write(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "can't write metadata collectively") } /* end if */ done: - if(candidate_assignment_table != NULL) - candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table); - if(cache_ptr->coll_write_list) { - if(H5SL_close(cache_ptr->coll_write_list) < 0) + if (candidate_assignment_table != NULL) + candidate_assignment_table = (unsigned *)H5MM_xfree((void *)candidate_assignment_table); + if (cache_ptr->coll_write_list) { + if (H5SL_close(cache_ptr->coll_write_list) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") cache_ptr->coll_write_list = NULL; } /* end if */ @@ -415,7 +392,6 @@ H5C_apply_candidate_list(H5F_t * f, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_apply_candidate_list() */ - /*------------------------------------------------------------------------- * * Function: H5C_construct_candidate_list__clean_cache @@ -435,82 +411,73 @@ H5C_apply_candidate_list(H5F_t * f, * * Changes: With the slist optimization, the slist is not maintained * unless a flush is in progress. Thus we can not longer use - * cache_ptr->slist_size to determine the total size of + * cache_ptr->slist_size to determine the total size of * the entries we must insert in the candidate list. * * To address this, we now use cache_ptr->dirty_index_size - * instead. + * instead. * * JRM -- 7/27/20 * *------------------------------------------------------------------------- */ herr_t -H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) +H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) { - size_t space_needed; - herr_t ret_value = SUCCEED; /* Return value */ + size_t space_needed; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* As a sanity check, set space needed to the dirty_index_size. This * should be the sum total of the sizes of all the dirty entries - * in the metadata cache. Note that if the slist is enabled, + * in the metadata cache. Note that if the slist is enabled, * cache_ptr->slist_size should equal cache_ptr->dirty_index_size. */ space_needed = cache_ptr->dirty_index_size; - HDassert( ( ! cache_ptr->slist_enabled ) || - ( space_needed == cache_ptr->slist_size ) ); - + HDassert((!cache_ptr->slist_enabled) || (space_needed == cache_ptr->slist_size)); /* Recall that while we shouldn't have any protected entries at this * point, it is possible that some dirty entries may reside on the * pinned list at this point. */ - HDassert( cache_ptr->dirty_index_size <= - (cache_ptr->dLRU_list_size + cache_ptr->pel_size) ); - HDassert( ( ! cache_ptr->slist_enabled ) || - ( cache_ptr->slist_len <= - (cache_ptr->dLRU_list_len + cache_ptr->pel_len) ) ); - + HDassert(cache_ptr->dirty_index_size <= (cache_ptr->dLRU_list_size + cache_ptr->pel_size)); + HDassert((!cache_ptr->slist_enabled) || + (cache_ptr->slist_len <= (cache_ptr->dLRU_list_len + cache_ptr->pel_len))); - if(space_needed > 0) { /* we have work to do */ + if (space_needed > 0) { /* we have work to do */ H5C_cache_entry_t *entry_ptr; - unsigned nominated_entries_count = 0; - size_t nominated_entries_size = 0; - haddr_t nominated_addr; + unsigned nominated_entries_count = 0; + size_t nominated_entries_size = 0; + haddr_t nominated_addr; - HDassert( ( ! cache_ptr->slist_enabled ) || - ( cache_ptr->slist_len > 0 ) ); + HDassert((!cache_ptr->slist_enabled) || (cache_ptr->slist_len > 0)); /* Scan the dirty LRU list from tail forward and nominate sufficient * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while ( ( nominated_entries_size < space_needed ) && - ( ( ! cache_ptr->slist_enabled ) || - ( nominated_entries_count < cache_ptr->slist_len ) ) && - ( entry_ptr != NULL ) ) { + while ((nominated_entries_size < space_needed) && + ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && + (entry_ptr != NULL)) { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( ( ! cache_ptr->slist_enabled ) || - ( entry_ptr->in_slist ) ); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "H5AC_add_candidate() failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; @@ -518,32 +485,30 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) } /* end while */ - HDassert( entry_ptr == NULL ); + HDassert(entry_ptr == NULL); /* it is possible that there are some dirty entries on the * protected entry list as well -- scan it too if necessary */ entry_ptr = cache_ptr->pel_head_ptr; - while ( ( nominated_entries_size < space_needed ) && - ( ( ! cache_ptr->slist_enabled ) || - ( nominated_entries_count < cache_ptr->slist_len ) ) && - ( entry_ptr != NULL ) ) { + while ((nominated_entries_size < space_needed) && + ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && + (entry_ptr != NULL)) { - if(entry_ptr->is_dirty) { + if (entry_ptr->is_dirty) { - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( entry_ptr->in_slist ); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert(entry_ptr->in_slist); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "H5AC_add_candidate() failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; @@ -554,9 +519,8 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) } /* end while */ - HDassert( ( ! cache_ptr->slist_enabled ) || - ( nominated_entries_count == cache_ptr->slist_len ) ); - HDassert( nominated_entries_size == space_needed ); + HDassert((!cache_ptr->slist_enabled) || (nominated_entries_count == cache_ptr->slist_len)); + HDassert(nominated_entries_size == space_needed); } /* end if */ @@ -566,7 +530,6 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) } /* H5C_construct_candidate_list__clean_cache() */ - /*------------------------------------------------------------------------- * Function: H5C_construct_candidate_list__min_clean * @@ -584,7 +547,7 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) * 3/17/10 * * Changes: With the slist optimization, the slist is not maintained - * unless a flush is in progress. Updated sanity checks to + * unless a flush is in progress. Updated sanity checks to * reflect this. * * JRM -- 7/27/20 @@ -592,81 +555,74 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) *------------------------------------------------------------------------- */ herr_t -H5C_construct_candidate_list__min_clean(H5C_t * cache_ptr) +H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) { - size_t space_needed = 0; - herr_t ret_value = SUCCEED; /* Return value */ + size_t space_needed = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( cache_ptr != NULL ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* compute the number of bytes (if any) that must be flushed to get the * cache back within its min clean constraints. */ - if(cache_ptr->max_cache_size > cache_ptr->index_size) { + if (cache_ptr->max_cache_size > cache_ptr->index_size) { - if ( ( (cache_ptr->max_cache_size - cache_ptr->index_size) + - cache_ptr->cLRU_list_size) >= cache_ptr->min_clean_size ) { - - space_needed = 0; + if (((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size) >= + cache_ptr->min_clean_size) { - } else { + space_needed = 0; + } + else { space_needed = cache_ptr->min_clean_size - - ((cache_ptr->max_cache_size - cache_ptr->index_size) + - cache_ptr->cLRU_list_size); + ((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size); } } /* end if */ else { - if(cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) { - - space_needed = 0; + if (cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) { - } else { + space_needed = 0; + } + else { - space_needed = cache_ptr->min_clean_size - - cache_ptr->cLRU_list_size; + space_needed = cache_ptr->min_clean_size - cache_ptr->cLRU_list_size; } } /* end else */ - if(space_needed > 0) { /* we have work to do */ + if (space_needed > 0) { /* we have work to do */ H5C_cache_entry_t *entry_ptr; - unsigned nominated_entries_count = 0; - size_t nominated_entries_size = 0; + unsigned nominated_entries_count = 0; + size_t nominated_entries_size = 0; - HDassert( ( ! cache_ptr->slist_enabled ) || - ( cache_ptr->slist_len > 0 ) ); + HDassert((!cache_ptr->slist_enabled) || (cache_ptr->slist_len > 0)); /* Scan the dirty LRU list from tail forward and nominate sufficient * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while ( ( nominated_entries_size < space_needed ) && - ( ( ! cache_ptr->slist_enabled ) || - ( nominated_entries_count < cache_ptr->slist_len ) ) && - ( entry_ptr != NULL ) && - ( ! entry_ptr->flush_me_last ) ) { + while ((nominated_entries_size < space_needed) && + ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && + (entry_ptr != NULL) && (!entry_ptr->flush_me_last)) { - haddr_t nominated_addr; + haddr_t nominated_addr; - HDassert( ! (entry_ptr->is_protected) ); - HDassert( ! (entry_ptr->is_read_only) ); - HDassert( entry_ptr->ro_ref_count == 0 ); - HDassert( entry_ptr->is_dirty ); - HDassert( ( ! cache_ptr->slist_enabled ) || - ( entry_ptr->in_slist ) ); + HDassert(!(entry_ptr->is_protected)); + HDassert(!(entry_ptr->is_read_only)); + HDassert(entry_ptr->ro_ref_count == 0); + HDassert(entry_ptr->is_dirty); + HDassert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); nominated_addr = entry_ptr->addr; - if(H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) + if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "H5AC_add_candidate() failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; @@ -674,17 +630,15 @@ H5C_construct_candidate_list__min_clean(H5C_t * cache_ptr) } /* end while */ - HDassert( ( ! cache_ptr->slist_enabled ) || - ( nominated_entries_count <= cache_ptr->slist_len ) ); - HDassert( nominated_entries_size <= cache_ptr->dirty_index_size ); - HDassert( nominated_entries_size >= space_needed ); + HDassert((!cache_ptr->slist_enabled) || (nominated_entries_count <= cache_ptr->slist_len)); + HDassert(nominated_entries_size <= cache_ptr->dirty_index_size); + HDassert(nominated_entries_size >= space_needed); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_construct_candidate_list__min_clean() */ - /*------------------------------------------------------------------------- * * Function: H5C_mark_entries_as_clean @@ -717,85 +671,77 @@ 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_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr) { - H5C_t * cache_ptr; - unsigned entries_cleared; - unsigned pinned_entries_cleared; - hbool_t progress; - unsigned entries_examined; - unsigned initial_list_len; - haddr_t addr; - unsigned pinned_entries_marked = 0; + H5C_t * cache_ptr; + unsigned entries_cleared; + unsigned pinned_entries_cleared; + hbool_t progress; + unsigned entries_examined; + unsigned initial_list_len; + haddr_t addr; + unsigned pinned_entries_marked = 0; #if H5C_DO_SANITY_CHECKS - unsigned protected_entries_marked = 0; - unsigned other_entries_marked = 0; - haddr_t last_addr; + unsigned protected_entries_marked = 0; + unsigned other_entries_marked = 0; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_cache_entry_t * clear_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t *clear_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert( ce_array_len > 0 ); - HDassert( ce_array_ptr != NULL ); + HDassert(ce_array_len > 0); + HDassert(ce_array_ptr != NULL); #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 */ - for(u = 0; u < ce_array_len; u++) { + for (u = 0; u < ce_array_len; u++) { addr = ce_array_ptr[u]; #if H5C_DO_SANITY_CHECKS - if(u == 0) + if (u == 0) last_addr = addr; else { - if(last_addr == addr) + if (last_addr == addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Duplicate entry in cleaned list") - if(last_addr > addr) + if (last_addr > addr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cleaned list not sorted") } /* end else */ #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 in for loop") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ #endif /* H5C_DO_SANITY_CHECKS */ - HDassert( H5F_addr_defined(addr) ); + HDassert(H5F_addr_defined(addr)); H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) { + if (entry_ptr == NULL) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, - "H5C_mark_entries_as_clean: entry[%u] = %a not in cache.\n", - u, + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry[%u] = %" PRIuHADDR " not in cache.\n", u, addr); #endif /* H5C_DO_SANITY_CHECKS */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not in cache?!?!?") } /* end if */ - else if(!entry_ptr->is_dirty) { + else if (!entry_ptr->is_dirty) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, - "H5C_mark_entries_as_clean: entry %a is not dirty!?!\n", - addr); + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry %" PRIuHADDR " is not dirty!?!\n", addr); #endif /* H5C_DO_SANITY_CHECKS */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry not dirty?!?!?") } /* end else-if */ @@ -807,16 +753,16 @@ H5C_mark_entries_as_clean(H5F_t * f, /* Make sure first that we clear the collective flag from it so it can be cleared */ - if(TRUE == entry_ptr->coll_access) { + if (TRUE == entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) } /* end if */ entry_ptr->clear_on_unprotect = TRUE; - if(entry_ptr->is_pinned) + if (entry_ptr->is_pinned) pinned_entries_marked++; #if H5C_DO_SANITY_CHECKS - else if(entry_ptr->is_protected) + else if (entry_ptr->is_protected) protected_entries_marked++; else other_entries_marked++; @@ -849,20 +795,20 @@ H5C_mark_entries_as_clean(H5F_t * f, * point. * JRM -- 4/7/15 */ - entries_cleared = 0; + entries_cleared = 0; entries_examined = 0; initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; - while(entry_ptr != NULL && entries_examined <= initial_list_len && - entries_cleared < ce_array_len) { - if(entry_ptr->clear_on_unprotect) { + entry_ptr = cache_ptr->LRU_tail_ptr; + while (entry_ptr != NULL && entries_examined <= initial_list_len && entries_cleared < ce_array_len) { + if (entry_ptr->clear_on_unprotect) { entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->prev; + clear_ptr = entry_ptr; + entry_ptr = entry_ptr->prev; entries_cleared++; - if(H5C__flush_single_entry(f, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) + if (H5C__flush_single_entry(f, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | + H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else @@ -871,69 +817,66 @@ H5C_mark_entries_as_clean(H5F_t * f, } /* end while */ #if H5C_DO_SANITY_CHECKS - HDassert( entries_cleared == other_entries_marked ); + HDassert(entries_cleared == other_entries_marked); #endif /* H5C_DO_SANITY_CHECKS */ /* It is also possible that some of the cleared entries are on the * pinned list. Must scan that also. */ pinned_entries_cleared = 0; - progress = TRUE; - while((pinned_entries_cleared < pinned_entries_marked) && progress) { - progress = FALSE; + progress = TRUE; + while ((pinned_entries_cleared < pinned_entries_marked) && progress) { + progress = FALSE; entry_ptr = cache_ptr->pel_head_ptr; - while(entry_ptr != NULL) { - if(entry_ptr->clear_on_unprotect && entry_ptr->flush_dep_ndirty_children == 0) { + while (entry_ptr != NULL) { + if (entry_ptr->clear_on_unprotect && entry_ptr->flush_dep_ndirty_children == 0) { entry_ptr->clear_on_unprotect = FALSE; - clear_ptr = entry_ptr; - entry_ptr = entry_ptr->next; + clear_ptr = entry_ptr; + entry_ptr = entry_ptr->next; entries_cleared++; pinned_entries_cleared++; progress = TRUE; - if(H5C__flush_single_entry(f, clear_ptr, - (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) + if (H5C__flush_single_entry(f, clear_ptr, + (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | + H5C__UPDATE_PAGE_BUFFER_FLAG)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear entry") } /* end if */ else entry_ptr = entry_ptr->next; - } /* end while */ - } /* end while */ + } /* end while */ + } /* end while */ #if H5C_DO_SANITY_CHECKS - HDassert( entries_cleared == pinned_entries_marked + other_entries_marked ); - HDassert( entries_cleared + protected_entries_marked == ce_array_len ); + HDassert(entries_cleared == pinned_entries_marked + other_entries_marked); + HDassert(entries_cleared + protected_entries_marked == ce_array_len); #endif /* H5C_DO_SANITY_CHECKS */ - HDassert( ( entries_cleared == ce_array_len ) || - ( (ce_array_len - entries_cleared) <= cache_ptr->pl_len ) ); + HDassert((entries_cleared == ce_array_len) || ((ce_array_len - entries_cleared) <= cache_ptr->pl_len)); #if H5C_DO_SANITY_CHECKS - u = 0; + u = 0; entry_ptr = cache_ptr->pl_head_ptr; - while ( entry_ptr != NULL ) - { - if ( entry_ptr->clear_on_unprotect ) { + while (entry_ptr != NULL) { + if (entry_ptr->clear_on_unprotect) { u++; } entry_ptr = entry_ptr->next; } - HDassert( (entries_cleared + u) == ce_array_len ); + HDassert((entries_cleared + u) == ce_array_len); #endif /* H5C_DO_SANITY_CHECKS */ 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) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entries_as_clean() */ - /*------------------------------------------------------------------------- * * Function: H5C_clear_coll_entries @@ -951,15 +894,15 @@ H5C_mark_entries_as_clean(H5F_t * f, herr_t H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) { - uint32_t clear_cnt; - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; + uint32_t clear_cnt; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT entry_ptr = cache_ptr->coll_tail_ptr; clear_cnt = (partial ? cache_ptr->coll_list_len / 2 : cache_ptr->coll_list_len); - while(entry_ptr && clear_cnt > 0) { + while (entry_ptr && clear_cnt > 0) { H5C_cache_entry_t *prev_ptr = entry_ptr->coll_prev; /* Sanity check */ @@ -980,7 +923,6 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_clear_coll_entries */ - /*------------------------------------------------------------------------- * * Function: H5C__collective_write @@ -997,21 +939,19 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) static herr_t H5C__collective_write(H5F_t *f) { - H5AC_t *cache_ptr; - H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; - void *base_buf; - int count; - int *length_array = NULL; - MPI_Aint *buf_array = NULL; - MPI_Aint *offset_array = NULL; - MPI_Datatype btype; - hbool_t btype_created = FALSE; - MPI_Datatype ftype; - hbool_t ftype_created = FALSE; - int mpi_code; - char unused = 0; /* Unused, except for non-NULL pointer value */ - size_t buf_count; - herr_t ret_value = SUCCEED; + H5AC_t * cache_ptr; + H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; + void * base_buf; + int count; + 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; + char unused = 0; /* Unused, except for non-NULL pointer value */ + size_t buf_count; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1022,49 +962,52 @@ H5C__collective_write(H5F_t *f) HDassert(cache_ptr->coll_write_list != NULL); /* Get original transfer mode */ - if(H5CX_get_io_xfer_mode(&orig_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&orig_xfer_mode) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Set transfer mode */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) + if (H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") /* Get number of entries in collective write list */ count = (int)H5SL_count(cache_ptr->coll_write_list); - if(count > 0) { - H5SL_node_t *node; - H5C_cache_entry_t *entry_ptr; - int i; + if (count > 0) { + H5SL_node_t * node; + H5C_cache_entry_t *entry_ptr; + int i; /* Allocate arrays */ - if(NULL == (length_array = (int *)H5MM_malloc((size_t)count * sizeof(int))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective write table length array") - if(NULL == (buf_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective buf table length array") - if(NULL == (offset_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint))) ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for collective offset table length array") + if (NULL == (length_array = (int *)H5MM_malloc((size_t)count * sizeof(int)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective write table length array") + if (NULL == (buf_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective buf table length array") + if (NULL == (offset_array = (MPI_Aint *)H5MM_malloc((size_t)count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for collective offset table length array") /* Fill arrays */ node = H5SL_first(cache_ptr->coll_write_list); HDassert(node); - if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) + if (NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up initial array position & buffer base address */ length_array[0] = (int)entry_ptr->size; - base_buf = entry_ptr->image_ptr; - buf_array[0] = (MPI_Aint)0; + base_buf = entry_ptr->image_ptr; + buf_array[0] = (MPI_Aint)0; offset_array[0] = (MPI_Aint)entry_ptr->addr; node = H5SL_next(node); - i = 1; - while(node) { - if(NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) + i = 1; + while (node) { + if (NULL == (entry_ptr = (H5C_cache_entry_t *)H5SL_item(node))) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't retrieve skip list item") /* Set up array position */ length_array[i] = (int)entry_ptr->size; - buf_array[i] = (MPI_Aint)entry_ptr->image_ptr - (MPI_Aint)base_buf; + buf_array[i] = (MPI_Aint)entry_ptr->image_ptr - (MPI_Aint)base_buf; offset_array[i] = (MPI_Aint)entry_ptr->addr; /* Advance to next node & array location */ @@ -1073,27 +1016,23 @@ H5C__collective_write(H5F_t *f) } /* end while */ /* Create memory MPI type */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed(count, length_array, buf_array, MPI_BYTE, &btype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed(count, length_array, buf_array, MPI_BYTE, &btype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - btype_created = TRUE; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&btype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&btype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Create file MPI type */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed(count, length_array, offset_array, MPI_BYTE, &ftype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed(count, length_array, offset_array, MPI_BYTE, &ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - ftype_created = TRUE; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&ftype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* MPI count to write */ buf_count = 1; } /* end if */ else { - /* Pass trivial buf type, file type to the file driver */ - btype = MPI_BYTE; - ftype = MPI_BYTE; - /* Set non-NULL pointer for I/O operation */ base_buf = &unused; @@ -1102,34 +1041,33 @@ H5C__collective_write(H5F_t *f) } /* end else */ /* Pass buf type, file type to the file driver */ - if(H5CX_set_mpi_coll_datatypes(btype, ftype) < 0) + if (H5CX_set_mpi_coll_datatypes(btype, ftype) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O properties") /* Write data */ - if(H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)0, buf_count, base_buf) < 0) + if (H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)0, buf_count, base_buf) < 0) HGOTO_ERROR(H5E_CACHE, H5E_WRITEERROR, FAIL, "unable to write entries collectively") done: /* Free arrays */ length_array = (int *)H5MM_xfree(length_array); - buf_array = (MPI_Aint *)H5MM_xfree(buf_array); + buf_array = (MPI_Aint *)H5MM_xfree(buf_array); offset_array = (MPI_Aint *)H5MM_xfree(offset_array); /* Free MPI Types */ - if(btype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype))) + if (MPI_BYTE != btype && MPI_SUCCESS != (mpi_code = MPI_Type_free(&btype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(ftype_created && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype))) + if (MPI_BYTE != ftype && MPI_SUCCESS != (mpi_code = MPI_Type_free(&ftype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) /* Reset transfer mode in API context, if changed */ - if(orig_xfer_mode != H5FD_MPIO_COLLECTIVE) - if(H5CX_set_io_xfer_mode(orig_xfer_mode) < 0) + if (orig_xfer_mode != H5FD_MPIO_COLLECTIVE) + if (H5CX_set_io_xfer_mode(orig_xfer_mode) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") FUNC_LEAVE_NOAPI(ret_value); } /* end H5C__collective_write() */ - /*------------------------------------------------------------------------- * Function: H5C__flush_candidate_entries * @@ -1170,20 +1108,20 @@ H5C__collective_write(H5F_t *f) */ static herr_t H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES], - unsigned entries_to_clear[H5C_RING_NTYPES]) + unsigned entries_to_clear[H5C_RING_NTYPES]) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; + H5C_ring_t ring; + H5C_t * cache_ptr; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1207,7 +1145,7 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES HDassert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); HDassert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - for(i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { index_len += cache_ptr->index_ring_len[i]; index_size += cache_ptr->index_ring_size[i]; clean_index_size += cache_ptr->clean_index_ring_size[i]; @@ -1226,9 +1164,8 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES #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 */ @@ -1238,12 +1175,12 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES * working inward. */ ring = H5C_RING_USER; - while(ring < H5C_RING_NTYPES) { - if(H5C__flush_candidates_in_ring(f, ring, entries_to_flush[ring], entries_to_clear[ring]) < 0) + while (ring < H5C_RING_NTYPES) { + if (H5C__flush_candidates_in_ring(f, ring, entries_to_flush[ring], entries_to_clear[ring]) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush candidates in ring failed") ring++; - } /* end while */ + } /* end while */ done: cache_ptr->flush_in_progress = FALSE; @@ -1251,7 +1188,6 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_candidate_entries() */ - /*------------------------------------------------------------------------- * Function: H5C__flush_candidates_in_ring * @@ -1289,25 +1225,23 @@ 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__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flush, unsigned entries_to_clear) { - H5C_t * cache_ptr; - hbool_t progress; - hbool_t restart_scan = FALSE; - unsigned entries_flushed = 0; - unsigned entries_cleared = 0; + H5C_t * cache_ptr; + hbool_t progress; + hbool_t restart_scan = FALSE; + unsigned entries_flushed = 0; + unsigned entries_cleared = 0; #if H5C_DO_SANITY_CHECKS - unsigned init_index_len; + unsigned init_index_len; #endif /* H5C_DO_SANITY_CHECKS */ - unsigned clear_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__GENERATE_IMAGE_FLAG | - H5C__UPDATE_PAGE_BUFFER_FLAG; - unsigned flush_flags = H5C__NO_FLAGS_SET; - unsigned op_flags; + unsigned clear_flags = + H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__GENERATE_IMAGE_FLAG | H5C__UPDATE_PAGE_BUFFER_FLAG; + unsigned flush_flags = H5C__NO_FLAGS_SET; + unsigned op_flags; H5C_cache_entry_t *op_ptr; H5C_cache_entry_t *entry_ptr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1322,9 +1256,8 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, 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 */ @@ -1343,27 +1276,27 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * It is possible that this will change -- hence the assertion. */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - while(((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear)) - && (entry_ptr != NULL)) { - hbool_t prev_is_dirty = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + while (((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear)) && + (entry_ptr != NULL)) { + hbool_t prev_is_dirty = FALSE; H5C_cache_entry_t *next_ptr; /* Entries in the LRU must not have flush dependency children */ HDassert(entry_ptr->flush_dep_nchildren == 0); /* Remember dirty state of entry to advance to */ - if(entry_ptr->prev != NULL) + if (entry_ptr->prev != NULL) prev_is_dirty = entry_ptr->prev->is_dirty; /* If the entry is in the ring */ - if(entry_ptr->ring == ring) { + if (entry_ptr->ring == ring) { /* If this process needs to clear this entry. */ - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->clear_on_unprotect) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = clear_flags; /* Set next entry appropriately */ @@ -1373,11 +1306,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr->clear_on_unprotect = FALSE; entries_cleared++; } /* end if */ - else if(entry_ptr->flush_immediately) { + else if (entry_ptr->flush_immediately) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = flush_flags; /* Set next entry appropriately */ @@ -1399,7 +1332,7 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr = entry_ptr->prev; /* Check for operation */ - if(op_ptr) { + if (op_ptr) { /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot @@ -1418,14 +1351,13 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - if(H5C__flush_single_entry(f, op_ptr, op_flags) < 0) + if (H5C__flush_single_entry(f, op_ptr, op_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") - if(cache_ptr->entries_removed_counter != 0 - || cache_ptr->last_entry_removed_ptr != NULL) + if (cache_ptr->entries_removed_counter != 0 || cache_ptr->last_entry_removed_ptr != NULL) restart_scan = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Remember "next" pointer (after advancing entries) */ next_ptr = entry_ptr; @@ -1435,10 +1367,9 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, } /* end else */ /* Check for restarts, etc. */ - if((entry_ptr != NULL) && - (restart_scan || (entry_ptr->is_dirty != prev_is_dirty) - || (entry_ptr->next != next_ptr) || entry_ptr->is_protected - || entry_ptr->is_pinned)) { + if ((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != prev_is_dirty) || (entry_ptr->next != next_ptr) || + entry_ptr->is_protected || entry_ptr->is_pinned)) { /* Something has happened to the LRU -- start over * from the tail. @@ -1458,11 +1389,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, HDassert(FALSE); /* see comment above */ restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; + entry_ptr = cache_ptr->LRU_tail_ptr; H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) } /* end if */ - } /* end while */ + } /* end while */ /* It is also possible that some of the cleared entries are on the * pinned list. Must scan that also. @@ -1486,26 +1417,26 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * such changes and cause this function to fail if they are detected. */ progress = TRUE; - while(progress && ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { - progress = FALSE; + while (progress && ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + progress = FALSE; entry_ptr = cache_ptr->pel_head_ptr; - while((entry_ptr != NULL) && - ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { + while ((entry_ptr != NULL) && + ((entries_flushed < entries_to_flush) || (entries_cleared < entries_to_clear))) { H5C_cache_entry_t *prev_ptr; - hbool_t next_is_dirty = FALSE; + hbool_t next_is_dirty = FALSE; HDassert(entry_ptr->is_pinned); /* Remember dirty state of entry to advance to */ - if(entry_ptr->next != NULL) + if (entry_ptr->next != NULL) next_is_dirty = entry_ptr->next->is_dirty; - if(entry_ptr->ring == ring && entry_ptr->flush_dep_ndirty_children == 0) { - if(entry_ptr->clear_on_unprotect) { + if (entry_ptr->ring == ring && entry_ptr->flush_dep_ndirty_children == 0) { + if (entry_ptr->clear_on_unprotect) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = clear_flags; /* Reset entry flag */ @@ -1513,11 +1444,11 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entries_cleared++; progress = TRUE; } /* end if */ - else if(entry_ptr->flush_immediately) { + else if (entry_ptr->flush_immediately) { HDassert(entry_ptr->is_dirty); /* Set entry and flags for operation */ - op_ptr = entry_ptr; + op_ptr = entry_ptr; op_flags = flush_flags; /* Reset entry flag */ @@ -1530,7 +1461,7 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, op_ptr = NULL; /* Check for operation */ - if(op_ptr) { + if (op_ptr) { /* reset entries_removed_counter and * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot @@ -1556,14 +1487,13 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * * JRM -- 2/9/17 */ - if(H5C__flush_single_entry(f, op_ptr, op_flags) < 0) + if (H5C__flush_single_entry(f, op_ptr, op_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") - if(cache_ptr->entries_removed_counter != 0 - || cache_ptr->last_entry_removed_ptr != NULL) + if (cache_ptr->entries_removed_counter != 0 || cache_ptr->last_entry_removed_ptr != NULL) restart_scan = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Remember "previous" pointer (after advancing entries) */ prev_ptr = entry_ptr; @@ -1572,10 +1502,9 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, entry_ptr = entry_ptr->next; /* Check for restarts, etc. */ - if((entry_ptr != NULL) && - (restart_scan || (entry_ptr->is_dirty != next_is_dirty) - || (entry_ptr->prev != prev_ptr) || entry_ptr->is_protected - || !entry_ptr->is_pinned)) { + if ((entry_ptr != NULL) && + (restart_scan || (entry_ptr->is_dirty != next_is_dirty) || (entry_ptr->prev != prev_ptr) || + entry_ptr->is_protected || !entry_ptr->is_pinned)) { /* Something has happened to the pinned entry list -- start * over from the head. * @@ -1606,22 +1535,22 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * H5C__UPDATE_STATS_FOR_PEL_SCAN_RESTART(cache_ptr) */ } /* end if */ - } /* end while ( ( entry_ptr != NULL ) && - * ( ( entries_flushed > entries_to_flush ) || - * ( entries_cleared > entries_to_clear ) ) ) - */ - } /* end while ( ( ( entries_flushed > entries_to_flush ) || - * ( entries_cleared > entries_to_clear ) ) && - * ( progress ) ) - */ + } /* end while ( ( entry_ptr != NULL ) && + * ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) ) + */ + } /* end while ( ( ( entries_flushed > entries_to_flush ) || + * ( entries_cleared > entries_to_clear ) ) && + * ( progress ) ) + */ #if H5C_DO_SANITY_CHECKS HDassert(init_index_len == cache_ptr->index_len); #endif /* H5C_DO_SANITY_CHECKS */ - if(entries_flushed != entries_to_flush || entries_cleared != entries_to_clear) { + if (entries_flushed != entries_to_flush || entries_cleared != entries_to_clear) { entry_ptr = cache_ptr->il_head; - while(entry_ptr != NULL) { + while (entry_ptr != NULL) { HDassert(!entry_ptr->clear_on_unprotect || (entry_ptr->ring > ring)); HDassert(!entry_ptr->flush_immediately || (entry_ptr->ring > ring)); entry_ptr = entry_ptr->il_next; @@ -1634,4 +1563,3 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_candidates_in_ring() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 79ebd9ebe6a..99ed4f8dad2 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,21 +17,24 @@ * Purpose: This file contains declarations which are normally visible * only within the H5C package. * - * Source files outside the H5C package should include - * H5Cprivate.h instead. + * Source files outside the H5C package should include + * H5Cprivate.h instead. * - * The one exception to this rule is test/cache.c. The test - * code is easier to write if it can look at the cache's - * internal data structures. Indeed, this is the main - * reason why this file was created. + * The one exception to this rule is test/cache.c. The test + * code is easier to write if it can look at the cache's + * internal data structures. Indeed, this is the main + * reason why this file was created. */ +/* clang-format off */ +/* Maintain current format by disabling format for this file */ + #if !(defined H5C_FRIEND || defined H5C_MODULE) #error "Do not include this file outside the H5C package!" #endif -#ifndef _H5Cpkg_H -#define _H5Cpkg_H +#ifndef H5Cpkg_H +#define H5Cpkg_H /* Get package's private header */ #include "H5Cprivate.h" @@ -50,7 +53,7 @@ /* Cache configuration settings */ #define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ -#define H5C__H5C_T_MAGIC 0x005CAC0E +#define H5C__H5C_T_MAGIC 0x005CAC0E /* Initial allocated size of the "flush_dep_parent" array */ @@ -81,7 +84,7 @@ * to the HGOTO_ERROR macro, which may not be appropriate in all cases. * If so, we will need versions of the insertion and deletion macros which * do not reference the sanity checking macros. - * JRM - 5/5/04 + * JRM - 5/5/04 * * Changes: * @@ -156,14 +159,14 @@ * sanity checking macros. These macro are used to update the size of * a DLL when one of its entries changes size. * - * JRM - 9/8/05 + * JRM - 9/8/05 * * - Added macros supporting the index list -- a doubly liked list of * all entries in the index. This list is necessary to reduce the * cost of visiting all entries in the cache, which was previously * done via a scan of the hash table. * - * JRM - 10/15/15 + * JRM - 10/15/15 * ****************************************************************************/ @@ -591,7 +594,7 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ } /* H5C__IL_DLL_REMOVE() */ - + /*********************************************************************** * * Stats collection macros @@ -626,68 +629,68 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ (cache_ptr)->dirty_index_size; #define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ - (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; + (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; #define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; #define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ - if ( cache_ptr->flush_in_progress ) \ + if ( cache_ptr->flush_in_progress ) \ ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ if ( entry_ptr->flush_in_progress ) \ ((cache_ptr)->entry_flush_moves[(entry_ptr)->type->id])++; \ - (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ + (((cache_ptr)->moves)[(entry_ptr)->type->id])++; \ (cache_ptr)->entries_relocated_counter++; #define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size)\ - if ( cache_ptr->flush_in_progress ) \ + if ( cache_ptr->flush_in_progress ) \ ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ if ( entry_ptr->flush_in_progress ) \ ((cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->size < (new_size) ) { \ - ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ + if ( (entry_ptr)->size < (new_size) ) { \ + ((cache_ptr)->size_increases[(entry_ptr)->type->id])++; \ H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - } else if ( (entry_ptr)->size > (new_size) ) { \ - ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ - } + } else if ( (entry_ptr)->size > (new_size) ) { \ + ((cache_ptr)->size_decreases[(entry_ptr)->type->id])++; \ + } #define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ - (cache_ptr)->total_ht_insertions++; + (cache_ptr)->total_ht_insertions++; #define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - (cache_ptr)->total_ht_deletions++; + (cache_ptr)->total_ht_deletions++; #define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ - if ( success ) { \ - (cache_ptr)->successful_ht_searches++; \ - (cache_ptr)->total_successful_ht_search_depth += depth; \ - } else { \ - (cache_ptr)->failed_ht_searches++; \ - (cache_ptr)->total_failed_ht_search_depth += depth; \ - } + if ( success ) { \ + (cache_ptr)->successful_ht_searches++; \ + (cache_ptr)->total_successful_ht_search_depth += depth; \ + } else { \ + (cache_ptr)->failed_ht_searches++; \ + (cache_ptr)->total_failed_ht_search_depth += depth; \ + } #define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) \ - ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; + ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; #define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->slist_scan_restarts)++; + ((cache_ptr)->slist_scan_restarts)++; #define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->LRU_scan_restarts)++; + ((cache_ptr)->LRU_scan_restarts)++; #define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->index_scan_restarts)++; + ((cache_ptr)->index_scan_restarts)++; #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ { \ @@ -953,7 +956,7 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #endif /* H5C_COLLECT_CACHE_STATS */ - + /*********************************************************************** * * Hash table access and manipulation macros: @@ -970,13 +973,13 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ * the clean_index_size and dirty_index_size fields of H5C_t. Also * added macros to allow us to track entry cleans and dirties. * - * JRM -- 11/5/08 + * JRM -- 11/5/08 * * - Updated existing index macros and sanity check macros to maintain * the index_ring_len, index_ring_size, clean_index_ring_size, and * dirty_index_ring_size fields of H5C_t. * - * JRM -- 9/1/15 + * JRM -- 9/1/15 * * - Updated existing index macros and sanity checks macros to * maintain an doubly linked list of all entries in the index. @@ -990,9 +993,9 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ /* H5C__HASH_TABLE_LEN is defined in H5Cpkg.h. It mut be a power of two. */ -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) +#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) -#define H5C__HASH_FCN(x) (int)((unsigned)((x) & H5C__HASH_MASK) >> 3) +#define H5C__HASH_FCN(x) (int)((unsigned)((x) & H5C__HASH_MASK) >> 3) #if H5C_DO_SANITY_CHECKS @@ -1008,7 +1011,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 ) || \ @@ -1031,7 +1034,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 ) || \ @@ -1068,7 +1071,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 ) || \ @@ -1099,7 +1102,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] > \ @@ -1158,7 +1161,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 ) || \ @@ -1172,9 +1175,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 ) || \ @@ -1193,20 +1196,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] > \ @@ -1320,9 +1323,9 @@ if ( ( (cache_ptr)->index_size != \ #define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) #define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) + entry_ptr, was_clean) #define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) + entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) #define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) @@ -1462,10 +1465,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); \ } @@ -1474,18 +1477,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); \ @@ -1494,14 +1497,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, \ @@ -1511,7 +1514,7 @@ if ( ( (cache_ptr)->index_size != \ entry_ptr) \ } - + /************************************************************************** * * Skip list insertion and deletion macros: @@ -1523,11 +1526,11 @@ if ( ( (cache_ptr)->index_size != \ /*------------------------------------------------------------------------- * - * Macro: H5C__INSERT_ENTRY_IN_SLIST + * Macro: H5C__INSERT_ENTRY_IN_SLIST * * Purpose: Insert the specified instance of H5C_cache_entry_t into - * the skip list in the specified instance of H5C_t. Update - * the associated length and size fields. + * the skip list in the specified instance of H5C_t. Update + * the associated length and size fields. * * Return: N/A * @@ -1535,66 +1538,66 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM -- 7/21/04 - * Updated function to set the in_tree flag when inserting - * an entry into the tree. Also modified the function to - * update the tree size and len fields instead of the similar - * index fields. + * JRM -- 7/21/04 + * Updated function to set the in_tree flag when inserting + * an entry into the tree. Also modified the function to + * update the tree size and len fields instead of the similar + * index fields. * - * All of this is part of the modifications to support the - * hash table. + * All of this is part of the modifications to support the + * hash table. * - * JRM -- 7/27/04 - * Converted the function H5C_insert_entry_in_tree() into - * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of - * wringing a little more speed out of the cache. + * JRM -- 7/27/04 + * Converted the function H5C_insert_entry_in_tree() into + * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of + * wringing a little more speed out of the cache. * - * Note that we don't bother to check if the entry is already - * in the tree -- if it is, H5SL_insert() will fail. + * Note that we don't bother to check if the entry is already + * in the tree -- if it is, H5SL_insert() will fail. * - * QAK -- 11/27/04 - * Switched over to using skip list routines. + * QAK -- 11/27/04 + * Switched over to using skip list routines. * - * JRM -- 6/27/06 - * Added fail_val parameter. + * JRM -- 6/27/06 + * Added fail_val parameter. * - * JRM -- 8/25/06 - * Added the H5C_DO_SANITY_CHECKS version of the macro. + * JRM -- 8/25/06 + * Added the H5C_DO_SANITY_CHECKS version of the macro. * - * This version maintains the slist_len_increase and - * slist_size_increase fields that are used in sanity - * checks in the flush routines. + * This version maintains the slist_len_increase and + * slist_size_increase fields that are used in sanity + * checks in the flush routines. * - * All this is needed as the fractal heap needs to be - * able to dirty, resize and/or move entries during the - * flush. + * All this is needed as the fractal heap needs to be + * able to dirty, resize and/or move entries during the + * flush. * - * JRM -- 12/13/14 - * Added code to set cache_ptr->slist_changed to TRUE - * when an entry is inserted in the slist. + * JRM -- 12/13/14 + * Added code to set cache_ptr->slist_changed to TRUE + * when an entry is inserted in the slist. * - * JRM -- 9/1/15 - * Added code to maintain the cache_ptr->slist_ring_len - * and cache_ptr->slist_ring_size arrays. + * JRM -- 9/1/15 + * Added code to maintain the cache_ptr->slist_ring_len + * and cache_ptr->slist_ring_size arrays. * * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro + * Reworked macro to support the slist_enabled field + * of H5C_t. If slist_enabled == TRUE, the macro * functions as before. Otherwise, the macro is a no-op, * and the slist must be empty. * *------------------------------------------------------------------------- */ -/* NOTE: The H5C__INSERT_ENTRY_IN_SLIST() macro is set up so that - * - * H5C_DO_SANITY_CHECKS +/* NOTE: The H5C__INSERT_ENTRY_IN_SLIST() macro is set up so that + * + * H5C_DO_SANITY_CHECKS * - * and + * and * - * H5C_DO_SLIST_SANITY_CHECKS + * H5C_DO_SLIST_SANITY_CHECKS * - * can be selected independantly. This is easy to miss as the + * can be selected independantly. This is easy to miss as the * two #defines are easy to confuse. */ @@ -1701,7 +1704,7 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_DO_SANITY_CHECKS */ - + /*------------------------------------------------------------------------- * * Function: H5C__REMOVE_ENTRY_FROM_SLIST @@ -1736,8 +1739,8 @@ if ( ( (cache_ptr)->index_size != \ * when an entry is removed from the slist. * * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro + * Reworked macro to support the slist_enabled field + * of H5C_t. If slist_enabled == TRUE, the macro * functions as before. Otherwise, the macro is a no-op, * and the slist must be empty. * @@ -1839,7 +1842,7 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_DO_SANITY_CHECKS */ - + /*------------------------------------------------------------------------- * * Function: H5C__UPDATE_SLIST_FOR_SIZE_CHANGE @@ -1873,8 +1876,8 @@ if ( ( (cache_ptr)->index_size != \ * and cache_ptr->slist_ring_size arrays. * * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro + * Reworked macro to support the slist_enabled field + * of H5C_t. If slist_enabled == TRUE, the macro * functions as before. Otherwise, the macro is a no-op, * and the slist must be empty. * @@ -1969,7 +1972,7 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_DO_SANITY_CHECKS */ - + /************************************************************************** * * Replacement policy update macros: @@ -1981,18 +1984,18 @@ if ( ( (cache_ptr)->index_size != \ /*------------------------------------------------------------------------- * - * Macro: H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS + * Macro: H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS * * Purpose: For efficiency, we sometimes change the order of flushes -- - * but doing so can confuse the replacement policy. This - * macro exists to allow us to specify an entry as the - * most recently touched so we can repair any such - * confusion. + * but doing so can confuse the replacement policy. This + * macro exists to allow us to specify an entry as the + * most recently touched so we can repair any such + * confusion. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the macro - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the macro + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2000,15 +2003,15 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM -- 3/20/06 - * Modified macro to ignore pinned entries. Pinned entries - * do not appear in the data structures maintained by the - * replacement policy code, and thus this macro has nothing - * to do if called for such an entry. + * JRM -- 3/20/06 + * Modified macro to ignore pinned entries. Pinned entries + * do not appear in the data structures maintained by the + * replacement policy code, and thus this macro has nothing + * to do if called for such an entry. * - * JRM -- 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks using the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2030,16 +2033,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 \ @@ -2093,16 +2096,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. */ \ @@ -2111,18 +2114,18 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_EVICTION + * Macro: H5C__UPDATE_RP_FOR_EVICTION * * Purpose: Update the replacement policy data structures for an - * eviction of the specified cache entry. + * eviction of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: Non-negative on success/Negative on failure. * @@ -2130,27 +2133,27 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_eviction() to the - * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_eviction() to the + * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * the pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * the pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/20/06 - * Pinned entries can't be evicted, so this entry should never - * be called on a pinned entry. Added assert to verify this. + * JRM - 3/20/06 + * Pinned entries can't be evicted, so this entry should never + * be called on a pinned entry. Added assert to verify this. * - * JRM -- 3/28/07 - * Added sanity checks for the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks for the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2222,18 +2225,18 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_FLUSH + * Macro: H5C__UPDATE_RP_FOR_FLUSH * * Purpose: Update the replacement policy data structures for a flush - * of the specified cache entry. + * of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2241,29 +2244,29 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_flush() to the - * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_flush() to the + * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two versions, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two versions, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/20/06 - * While pinned entries can be flushed, they don't reside in - * the replacement policy data structures when unprotected. - * Thus I modified this macro to do nothing if the entry is - * pinned. + * JRM - 3/20/06 + * While pinned entries can be flushed, they don't reside in + * the replacement policy data structures when unprotected. + * Thus I modified this macro to do nothing if the entry is + * pinned. * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2285,28 +2288,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 ) { \ @@ -2347,17 +2350,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. */ \ @@ -2366,26 +2369,26 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND + * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. + * insertion of the specified cache entry. * - * Unlike H5C__UPDATE_RP_FOR_INSERTION below, mark the - * new entry as the LEAST recently used entry, not the - * most recently used. + * Unlike H5C__UPDATE_RP_FOR_INSERTION below, mark the + * new entry as the LEAST recently used entry, not the + * most recently used. * - * For now at least, this macro should only be used in - * the reconstruction of the metadata cache from a cache - * image block. + * For now at least, this macro should only be used in + * the reconstruction of the metadata cache from a cache + * image block. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2421,7 +2424,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 \ @@ -2462,7 +2465,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 */ \ @@ -2471,7 +2474,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. */ \ @@ -2480,18 +2483,18 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_INSERTION + * Macro: H5C__UPDATE_RP_FOR_INSERTION * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. + * insertion of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2499,31 +2502,31 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_insertion() to the - * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_insertion() to the + * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/10/06 - * This macro should never be called on a pinned entry. - * Inserted an assert to verify this. + * JRM - 3/10/06 + * This macro should never be called on a pinned entry. + * Inserted an assert to verify this. * - * JRM - 8/9/06 - * Not any more. We must now allow insertion of pinned - * entries. Updated macro to support this. + * JRM - 8/9/06 + * Not any more. We must now allow insertion of pinned + * entries. Updated macro to support this. * - * JRM - 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks using the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2555,7 +2558,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 \ @@ -2596,7 +2599,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 */ \ @@ -2605,7 +2608,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. */ \ @@ -2614,22 +2617,22 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_PROTECT + * Macro: H5C__UPDATE_RP_FOR_PROTECT * * Purpose: Update the replacement policy data structures for a - * protect of the specified cache entry. + * protect of the specified cache entry. * - * To do this, unlink the specified entry from any data - * structures used by the replacement policy, and add the - * entry to the protected list. + * To do this, unlink the specified entry from any data + * structures used by the replacement policy, and add the + * entry to the protected list. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2637,28 +2640,28 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_protect() to the - * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze - * a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_protect() to the + * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze + * a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/17/06 - * Modified macro to attempt to remove pinned entriese from - * the pinned entry list instead of from the data structures - * maintained by the replacement policy. + * JRM - 3/17/06 + * Modified macro to attempt to remove pinned entriese from + * the pinned entry list instead of from the data structures + * maintained by the replacement policy. * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM - 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2674,12 +2677,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 { \ @@ -2690,7 +2693,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 \ @@ -2736,12 +2739,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 { \ @@ -2752,7 +2755,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. */ \ @@ -2770,18 +2773,18 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_MOVE + * Macro: H5C__UPDATE_RP_FOR_MOVE * * Purpose: Update the replacement policy data structures for a - * move of the specified cache entry. + * move of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2802,20 +2805,20 @@ if ( ( (cache_ptr)->index_size != \ HDassert( (entry_ptr)->size > 0 ); \ \ 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 \ @@ -2824,43 +2827,43 @@ 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, \ - (fail_val)) \ + (fail_val)) \ \ } 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. */ \ @@ -2879,20 +2882,20 @@ if ( ( (cache_ptr)->index_size != \ HDassert( (entry_ptr)->size > 0 ); \ \ 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. */ \ @@ -2901,25 +2904,25 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE + * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE * * Purpose: Update the replacement policy data structures for a - * size change of the specified cache entry. + * size change of the specified cache entry. * - * To do this, determine if the entry is pinned. If it is, - * update the size of the pinned entry list. + * To do this, determine if the entry is pinned. If it is, + * update the size of the pinned entry list. * - * If it isn't pinned, the entry must handled by the - * replacement policy. Update the appropriate replacement - * policy data structures. + * If it isn't pinned, the entry must handled by the + * replacement policy. Update the appropriate replacement + * policy data structures. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -2927,9 +2930,9 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -2949,49 +2952,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. */ \ @@ -3011,24 +3014,24 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ HDassert( new_size > 0 ); \ - \ + \ 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. */ \ } \ @@ -3037,22 +3040,22 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPIN + * Macro: H5C__UPDATE_RP_FOR_UNPIN * * Purpose: Update the replacement policy data structures for an - * unpin of the specified cache entry. + * unpin of the specified cache entry. * - * To do this, unlink the specified entry from the protected - * entry list, and re-insert it in the data structures used - * by the current replacement policy. + * To do this, unlink the specified entry from the protected + * entry list, and re-insert it in the data structures used + * by the current replacement policy. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the macro - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the macro + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -3060,9 +3063,9 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. + * JRM -- 3/28/07 + * Added sanity checks based on the new is_read_only and + * ro_ref_count fields of struct H5C_cache_entry_t. * *------------------------------------------------------------------------- */ @@ -3158,22 +3161,22 @@ if ( ( (cache_ptr)->index_size != \ #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPROTECT + * Macro: H5C__UPDATE_RP_FOR_UNPROTECT * * Purpose: Update the replacement policy data structures for an - * unprotect of the specified cache entry. + * unprotect of the specified cache entry. * - * To do this, unlink the specified entry from the protected - * list, and re-insert it in the data structures used by the - * current replacement policy. + * To do this, unlink the specified entry from the protected + * list, and re-insert it in the data structures used by the + * current replacement policy. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * At present, we only support the modified LRU policy, so + * this function deals with that case unconditionally. If + * we ever support other replacement policies, the function + * should switch on the current policy and act accordingly. * * Return: N/A * @@ -3181,24 +3184,24 @@ if ( ( (cache_ptr)->index_size != \ * * Modifications: * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_unprotect() to - * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to - * squeeze a bit more performance out of the cache. + * JRM - 7/27/04 + * Converted the function H5C_update_rp_for_unprotect() to + * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to + * squeeze a bit more performance out of the cache. * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. + * At least for the first cut, I am leaving the comments and + * white space in the macro. If they cause difficulties with + * pre-processor, I'll have to remove them. * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. + * JRM - 7/28/04 + * Split macro into two version, one supporting the clean and + * dirty LRU lists, and the other not. Yet another attempt + * at optimization. * - * JRM - 3/17/06 - * Modified macro to put pinned entries on the pinned entry - * list instead of inserting them in the data structures - * maintained by the replacement policy. + * JRM - 3/17/06 + * Modified macro to put pinned entries on the pinned entry + * list instead of inserting them in the data structures + * maintained by the replacement policy. * *------------------------------------------------------------------------- */ @@ -3447,10 +3450,10 @@ if ( ( (entry_ptr) == NULL ) || \ } \ } /* H5C__COLL_DLL_REMOVE() */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__INSERT_IN_COLL_LIST + * Macro: H5C__INSERT_IN_COLL_LIST * * Purpose: Insert entry into collective entries list * @@ -3477,10 +3480,10 @@ if ( ( (entry_ptr) == NULL ) || \ \ } /* H5C__INSERT_IN_COLL_LIST */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__REMOVE_FROM_COLL_LIST + * Macro: H5C__REMOVE_FROM_COLL_LIST * * Purpose: Remove entry from collective entries list * @@ -3507,10 +3510,10 @@ if ( ( (entry_ptr) == NULL ) || \ \ } /* H5C__REMOVE_FROM_COLL_LIST */ - + /*------------------------------------------------------------------------- * - * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST + * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST * * Purpose: Update entry position in collective entries list * @@ -3563,7 +3566,7 @@ 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. @@ -3571,7 +3574,7 @@ if ( ( (entry_ptr) == NULL ) || \ * 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. + * evicted. * ****************************************************************************/ typedef struct H5C_tag_info_t { @@ -3613,32 +3616,32 @@ typedef struct H5C_tag_info_t { * Note that index_size and index_len now refer to the total size of * and number of entries in the hash table. * - * JRM - 7/19/04 + * JRM - 7/19/04 * * The TBBT has since been replaced with a skip list. This change * greatly predates this note. * - * JRM - 9/26/05 + * JRM - 9/26/05 * - * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. - * This field is used to validate pointers to instances of - * H5C_t. + * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. + * This field is used to validate pointers to instances of + * H5C_t. * * flush_in_progress: Boolean flag indicating whether a flush is in - * progress. + * progress. * * log_info: Information used by the MDC logging functionality. * Described in H5Clog.h. * - * aux_ptr: Pointer to void used to allow wrapper code to associate - * its data with an instance of H5C_t. The H5C cache code - * sets this field to NULL, and otherwise leaves it alone. + * aux_ptr: Pointer to void used to allow wrapper code to associate + * its data with an instance of H5C_t. The H5C cache code + * sets this field to NULL, and otherwise leaves it alone. * - * max_type_id: Integer field containing the maximum type id number assigned - * to a type of entry in the cache. All type ids from 0 to - * max_type_id inclusive must be defined. The names of the - * types are stored in the type_name_table discussed below, and - * indexed by the ids. + * max_type_id: Integer field containing the maximum type id number assigned + * to a type of entry in the cache. All type ids from 0 to + * max_type_id inclusive must be defined. The names of the + * types are stored in the type_name_table discussed below, and + * indexed by the ids. * * class_table_ptr: Pointer to an array of H5C_class_t of length * max_type_id + 1. Entry classes for the cache. @@ -3654,19 +3657,19 @@ typedef struct H5C_tag_info_t { * to reduce its size as entries are unprotected. * * b) When running in parallel mode, the cache may not be - * permitted to flush a dirty entry in response to a read. - * If there are no clean entries available to evict, the - * cache will exceed its maximum size. Again the cache + * permitted to flush a dirty entry in response to a read. + * If there are no clean entries available to evict, the + * cache will exceed its maximum size. Again the cache * will attempt to reduce its size to the max_cache_size * limit on the next cache write. * - * c) When an entry increases in size, the cache may exceed - * the max_cache_size limit until the next time the cache - * attempts to load or insert an entry. + * c) When an entry increases in size, the cache may exceed + * the max_cache_size limit until the next time the cache + * attempts to load or insert an entry. * - * d) When the evictions_enabled field is false (see below), - * the cache size will increase without limit until the - * field is set to true. + * d) When the evictions_enabled field is false (see below), + * the cache size will increase without limit until the + * field is set to true. * * min_clean_size: Nominal minimum number of clean bytes in the cache. * The cache attempts to maintain this number of bytes of @@ -3674,7 +3677,7 @@ typedef struct H5C_tag_info_t { * a soft limit. * * close_warning_received: Boolean flag indicating that a file closing - * warning has been received. + * warning has been received. * * * In addition to the call back functions required for each entry, the @@ -3682,19 +3685,19 @@ typedef struct H5C_tag_info_t { * the cache as a whole: * * check_write_permitted: In certain applications, the cache may not - * be allowed to write to disk at certain time. If specified, - * the check_write_permitted function is used to determine if - * a write is permissible at any given point in time. + * be allowed to write to disk at certain time. If specified, + * the check_write_permitted function is used to determine if + * a write is permissible at any given point in time. * - * If no such function is specified (i.e. this field is NULL), - * the cache uses the following write_permitted field to - * determine whether writes are permitted. + * If no such function is specified (i.e. this field is NULL), + * the cache uses the following write_permitted field to + * determine whether writes are permitted. * * write_permitted: If check_write_permitted is NULL, this boolean flag - * indicates whether writes are permitted. + * indicates whether writes are permitted. * - * log_flush: If provided, this function is called whenever a dirty - * entry is flushed to disk. + * log_flush: If provided, this function is called whenever a dirty + * entry is flushed to disk. * * * In cases where memory is plentiful, and performance is an issue, it may @@ -3702,11 +3705,11 @@ typedef struct H5C_tag_info_t { * writes. The following field is used to implement this. * * evictions_enabled: Boolean flag that is initialized to TRUE. When - * this flag is set to FALSE, the metadata cache will not - * attempt to evict entries to make space for newly protected - * entries, and instead the will grow without limit. + * this flag is set to FALSE, the metadata cache will not + * attempt to evict entries to make space for newly protected + * entries, and instead the will grow without limit. * - * Needless to say, this feature must be used with care. + * Needless to say, this feature must be used with care. * * * The cache requires an index to facilitate searching for entries. The @@ -3724,7 +3727,7 @@ typedef struct H5C_tag_info_t { * index, and must have the same length and size as the index proper. * * index_len: Number of entries currently in the hash table used to index - * the cache. + * the cache. * * index_size: Number of bytes of cache entries currently stored in the * hash table used to index the cache. @@ -3736,84 +3739,84 @@ typedef struct H5C_tag_info_t { * of the cache's memory footprint. * * index_ring_len: Array of integer of length H5C_RING_NTYPES used to - * maintain a count of entries in the index by ring. Note - * that the sum of all the cells in this array must equal - * the value stored in index_len above. + * maintain a count of entries in the index by ring. Note + * that the sum of all the cells in this array must equal + * the value stored in index_len above. * * index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all entries in the index - * by ring. Note that the sum of all cells in this array must - * equal the value stored in index_size above. + * maintain the sum of the sizes of all entries in the index + * by ring. Note that the sum of all cells in this array must + * equal the value stored in index_size above. * * clean_index_size: Number of bytes of clean entries currently stored in - * the hash table. Note that the index_size field (above) - * is also the sum of the sizes of all entries in the cache. - * Thus we should have the invariant that clean_index_size + - * dirty_index_size == index_size. + * the hash table. Note that the index_size field (above) + * is also the sum of the sizes of all entries in the cache. + * Thus we should have the invariant that clean_index_size + + * dirty_index_size == index_size. * - * WARNING: + * WARNING: * - * The value of the clean_index_size must not be mistaken - * for the current clean size of the cache. Rather, the - * clean size of the cache is the current value of - * clean_index_size plus the amount of empty space (if any) + * The value of the clean_index_size must not be mistaken + * for the current clean size of the cache. Rather, the + * clean size of the cache is the current value of + * clean_index_size plus the amount of empty space (if any) * in the cache. * * clean_index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all clean entries in the - * index by ring. Note that the sum of all cells in this array - * must equal the value stored in clean_index_size above. + * maintain the sum of the sizes of all clean entries in the + * index by ring. Note that the sum of all cells in this array + * must equal the value stored in clean_index_size above. * * dirty_index_size: Number of bytes of dirty entries currently stored in - * the hash table. Note that the index_size field (above) - * is also the sum of the sizes of all entries in the cache. - * Thus we should have the invariant that clean_index_size + - * dirty_index_size == index_size. + * the hash table. Note that the index_size field (above) + * is also the sum of the sizes of all entries in the cache. + * Thus we should have the invariant that clean_index_size + + * dirty_index_size == index_size. * * dirty_index_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all dirty entries in the - * index by ring. Note that the sum of all cells in this array - * must equal the value stored in dirty_index_size above. - * - * index: Array of pointer to H5C_cache_entry_t of size - * H5C__HASH_TABLE_LEN. At present, this value is a power - * of two, not the usual prime number. - * - * I hope that the variable size of cache elements, the large - * hash table size, and the way in which HDF5 allocates space - * will combine to avoid problems with periodicity. If so, we - * can use a trivial hash function (a bit-and and a 3 bit left - * shift) with some small savings. - * - * If not, it will become evident in the statistics. Changing - * to the usual prime number length hash table will require - * changing the H5C__HASH_FCN macro and the deletion of the - * H5C__HASH_MASK #define. No other changes should be required. - * - * il_len: Number of entries on the index list. - * - * This must always be equal to index_len. As such, this - * field is redundant. However, the existing linked list - * management macros expect to maintain a length field, so - * this field exists primarily to avoid adding complexity to - * these macros. - * - * il_size: Number of bytes of cache entries currently stored in the - * index list. - * - * This must always be equal to index_size. As such, this - * field is redundant. However, the existing linked list - * management macros expect to maintain a size field, so - * this field exists primarily to avoid adding complexity to - * these macros. - * - * il_head: Pointer to the head of the doubly linked list of entries in + * maintain the sum of the sizes of all dirty entries in the + * index by ring. Note that the sum of all cells in this array + * must equal the value stored in dirty_index_size above. + * + * index: Array of pointer to H5C_cache_entry_t of size + * H5C__HASH_TABLE_LEN. At present, this value is a power + * of two, not the usual prime number. + * + * I hope that the variable size of cache elements, the large + * hash table size, and the way in which HDF5 allocates space + * will combine to avoid problems with periodicity. If so, we + * can use a trivial hash function (a bit-and and a 3 bit left + * shift) with some small savings. + * + * If not, it will become evident in the statistics. Changing + * to the usual prime number length hash table will require + * changing the H5C__HASH_FCN macro and the deletion of the + * H5C__HASH_MASK #define. No other changes should be required. + * + * il_len: Number of entries on the index list. + * + * This must always be equal to index_len. As such, this + * field is redundant. However, the existing linked list + * management macros expect to maintain a length field, so + * this field exists primarily to avoid adding complexity to + * these macros. + * + * il_size: Number of bytes of cache entries currently stored in the + * index list. + * + * This must always be equal to index_size. As such, this + * field is redundant. However, the existing linked list + * management macros expect to maintain a size field, so + * this field exists primarily to avoid adding complexity to + * these macros. + * + * il_head: Pointer to the head of the doubly linked list of entries in * the index list. Note that cache entries on this list are - * linked by their il_next and il_prev fields. + * linked by their il_next and il_prev fields. * * This field is NULL if the index is empty. * - * il_tail: Pointer to the tail of the doubly linked list of entries in + * il_tail: Pointer to the tail of the doubly linked list of entries in * the index list. Note that cache entries on this list are * linked by their il_next and il_prev fields. * @@ -3830,32 +3833,32 @@ typedef struct H5C_tag_info_t { * * The following fields are maintained to facilitate this. * - * entries_removed_counter: Counter that is incremented each time an - * entry is removed from the cache by any means (eviction, - * expungement, or take ownership at this point in time). - * Functions that perform scans on lists may set this field - * to zero prior to calling H5C__flush_single_entry(). - * Unexpected changes to the counter indicate that an entry - * was removed from the cache as a side effect of the flush. - * - * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t - * which contained the last entry to be removed from the cache, - * or NULL if there either is no such entry, or if a function - * performing a scan of a list has set this field to NULL prior - * to calling H5C__flush_single_entry(). - * - * WARNING!!! This field must NEVER be dereferenced. It is - * maintained to allow functions that perform scans of lists - * to compare this pointer with their pointers to next, thus - * allowing them to avoid unnecessary restarts of scans if the - * pointers don't match, and if entries_removed_counter is - * one. - * - * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t + * entries_removed_counter: Counter that is incremented each time an + * entry is removed from the cache by any means (eviction, + * expungement, or take ownership at this point in time). + * Functions that perform scans on lists may set this field + * to zero prior to calling H5C__flush_single_entry(). + * Unexpected changes to the counter indicate that an entry + * was removed from the cache as a side effect of the flush. + * + * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t + * which contained the last entry to be removed from the cache, + * or NULL if there either is no such entry, or if a function + * performing a scan of a list has set this field to NULL prior + * to calling H5C__flush_single_entry(). + * + * WARNING!!! This field must NEVER be dereferenced. It is + * maintained to allow functions that perform scans of lists + * to compare this pointer with their pointers to next, thus + * allowing them to avoid unnecessary restarts of scans if the + * pointers don't match, and if entries_removed_counter is + * one. + * + * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t * which contains the 'next' entry for an iteration. Removing * this entry must trigger a rescan of the iteration, so each * entry removed from the cache is compared against this pointer - * and the pointer is reset to NULL if the watched entry is + * and the pointer is reset to NULL if the watched entry is * removed. * (This functions similarly to a "dead man's switch") * @@ -3870,14 +3873,14 @@ typedef struct H5C_tag_info_t { * are flushed. (this has been changed -- dirty entries are now removed from * the skip list as they are flushed. JRM - 10/25/05) * - * Update 4/21/20: + * Update 4/21/20: * - * Profiling indicates that the cost of maintaining the skip list is + * Profiling indicates that the cost of maintaining the skip list is * significant. As it is only used on flush and close, maintaining it * only when needed is an obvious optimization. * * To do this, we add a flag to control maintenanace of the skip list. - * This flag is initially set to FALSE, which disables all operations + * This flag is initially set to FALSE, which disables all operations * on the skip list. * * At the beginning of either flush or close, we scan the index list, @@ -3885,27 +3888,27 @@ typedef struct H5C_tag_info_t { * on skip list by setting above control flag to true. * * At the end of a complete flush, we verify that the skip list is empty, - * and set the control flag back to false, so as to avoid skip list - * maintenance overhead until the next flush or close. + * and set the control flag back to false, so as to avoid skip list + * maintenance overhead until the next flush or close. * * In the case of a partial flush (i.e. flush marked entries), we remove * all remaining entries from the skip list, and then set the control flag - * back to false -- again avoiding skip list maintenance overhead until + * back to false -- again avoiding skip list maintenance overhead until * the next flush or close. * * slist_enabled: Boolean flag used to control operation of the skip - * list. If this filed is FALSE, operations on the + * list. If this filed is FALSE, operations on the * slist are no-ops, and the slist must be empty. If * it is TRUE, operations on the slist proceed as usual, * and all dirty entries in the metadata cache must be * listed in the slist. * * slist_changed: Boolean flag used to indicate whether the contents of - * the slist has changed since the last time this flag was - * reset. This is used in the cache flush code to detect - * conditions in which pre-serialize or serialize callbacks - * have modified the slist -- which obliges us to restart - * the scan of the slist from the beginning. + * the slist has changed since the last time this flag was + * reset. This is used in the cache flush code to detect + * conditions in which pre-serialize or serialize callbacks + * have modified the slist -- which obliges us to restart + * the scan of the slist from the beginning. * * slist_len: Number of entries currently in the skip list * used to maintain a sorted list of dirty entries in the @@ -3916,14 +3919,14 @@ typedef struct H5C_tag_info_t { * dirty entries in the cache. * * slist_ring_len: Array of integer of length H5C_RING_NTYPES used to - * maintain a count of entries in the slist by ring. Note - * that the sum of all the cells in this array must equal - * the value stored in slist_len above. + * maintain a count of entries in the slist by ring. Note + * that the sum of all the cells in this array must equal + * the value stored in slist_len above. * * slist_ring_size: Array of size_t of length H5C_RING_NTYPES used to * maintain the sum of the sizes of all entries in the - * slist by ring. Note that the sum of all cells in this - * array must equal the value stored in slist_size above. + * slist by ring. Note that the sum of all cells in this + * array must equal the value stored in slist_size above. * * slist_ptr: pointer to the instance of H5SL_t used maintain a sorted * list of dirty entries in the cache. This sorted list has @@ -3938,7 +3941,7 @@ typedef struct H5C_tag_info_t { * some optimizations when I get to it. * * num_last_entries: The number of entries in the cache that can only be - * flushed after all other entries in the cache have + * flushed after all other entries in the cache have * been flushed. At this time, this will only ever be * one entry (the superblock), and the code has been * protected with HDasserts to enforce this. This restraint @@ -3947,10 +3950,10 @@ typedef struct H5C_tag_info_t { * explicit tests for that case should be added when said * HDasserts are removed. * - * Update: There are now two possible last entries - * (superblock and file driver info message). This - * number will probably increase as we add superblock - * messages. JRM -- 11/18/14 + * Update: There are now two possible last entries + * (superblock and file driver info message). This + * number will probably increase as we add superblock + * messages. JRM -- 11/18/14 * * With the addition of the fractal heap, the cache must now deal with * the case in which entries may be dirtied, moved, or have their sizes @@ -3959,12 +3962,12 @@ typedef struct H5C_tag_info_t { * H5C_DO_SANITY_CHECKS is TRUE. * * slist_len_increase: Number of entries that have been added to the - * slist since the last time this field was set to zero. - * Note that this value can be negative. + * slist since the last time this field was set to zero. + * Note that this value can be negative. * * slist_size_increase: Total size of all entries that have been added - * to the slist since the last time this field was set to - * zero. Note that this value can be negative. + * to the slist since the last time this field was set to + * zero. Note that this value can be negative. * * Cache entries belonging to a particular object are "tagged" with that * object's base object header address. @@ -3981,7 +3984,7 @@ typedef struct H5C_tag_info_t { * 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. + * ignore_tags: Boolean flag to disable tag validation during entry insertion. * * num_objs_corked: Unsigned integer field containing the number of objects * that are "corked". The "corked" status of an object is @@ -4020,15 +4023,15 @@ typedef struct H5C_tag_info_t { * * Pinning an entry has the following implications: * - * 1) A pinned entry cannot be evicted. Thus unprotected + * 1) A pinned entry cannot be evicted. Thus unprotected * pinned entries reside in the pinned entry list, instead * of the LRU list(s) (or other lists maintained by the current * replacement policy code). * * 2) A pinned entry can be accessed or modified at any time. * This places an additional burden on the associated pre-serialize - * and serialize callbacks, which must ensure the the entry is in - * a consistent state before creating an image of it. + * and serialize callbacks, which must ensure the the entry is in + * a consistent state before creating an image of it. * * 3) A pinned entry can be marked as dirty (and possibly * change size) while it is unprotected. @@ -4043,21 +4046,21 @@ typedef struct H5C_tag_info_t { * * Maintaining the pinned entry list requires the following fields: * - * pel_len: Number of entries currently residing on the pinned - * entry list. + * pel_len: Number of entries currently residing on the pinned + * entry list. * - * pel_size: Number of bytes of cache entries currently residing on - * the pinned entry list. + * pel_size: Number of bytes of cache entries currently residing on + * the pinned entry list. * * pel_head_ptr: Pointer to the head of the doubly linked list of pinned - * but not protected entries. Note that cache entries on - * this list are linked by their next and prev fields. + * but not protected entries. Note that cache entries on + * this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * * pel_tail_ptr: Pointer to the tail of the doubly linked list of pinned - * but not protected entries. Note that cache entries on - * this list are linked by their next and prev fields. + * but not protected entries. Note that cache entries on + * this list are linked by their next and prev fields. * * This field is NULL if the list is empty. * @@ -4115,13 +4118,13 @@ typedef struct H5C_tag_info_t { * LRU_list_len: Number of cache entries currently on the LRU list. * * Observe that LRU_list_len + pl_len + pel_len must always - * equal index_len. + * equal index_len. * * LRU_list_size: Number of bytes of cache entries currently residing on the * LRU list. * * Observe that LRU_list_size + pl_size + pel_size must always - * equal index_size. + * equal index_size. * * LRU_head_ptr: Pointer to the head of the doubly linked LRU list. Cache * entries on this list are linked by their next and prev fields. @@ -4190,10 +4193,10 @@ typedef struct H5C_tag_info_t { * the structure described below: * * size_increase_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * to increase the size of the cache. Rather than test for - * all the ways this can happen, we simply set this flag when - * we receive a new configuration. + * in the resize_ctl field, it may or may not be possible + * to increase the size of the cache. Rather than test for + * all the ways this can happen, we simply set this flag when + * we receive a new configuration. * * flash_size_increase_possible: Depending on the configuration data given * in the resize_ctl field, it may or may not be possible @@ -4214,37 +4217,37 @@ typedef struct H5C_tag_info_t { * we receive a new configuration. * * resize_enabled: This is another convenience flag which is set whenever - * a new set of values for resize_ctl are provided. Very - * simply, + * a new set of values for resize_ctl are provided. Very + * simply, * - * resize_enabled = size_increase_possible || + * resize_enabled = size_increase_possible || * size_decrease_possible; * - * cache_full: Boolean flag used to keep track of whether the cache is - * full, so we can refrain from increasing the size of a - * cache which hasn't used up the space allotted to it. + * cache_full: Boolean flag used to keep track of whether the cache is + * full, so we can refrain from increasing the size of a + * cache which hasn't used up the space allotted to it. * - * The field is initialized to FALSE, and then set to TRUE - * whenever we attempt to make space in the cache. + * The field is initialized to FALSE, and then set to TRUE + * whenever we attempt to make space in the cache. * * size_decreased: Boolean flag set to TRUE whenever the maximum cache - * size is decreased. The flag triggers a call to - * H5C__make_space_in_cache() on the next call to H5C_protect(). + * size is decreased. The flag triggers a call to + * H5C__make_space_in_cache() on the next call to H5C_protect(). * * resize_in_progress: As the metadata cache has become re-entrant, it is - * possible that a protect may trigger a call to - * H5C__auto_adjust_cache_size(), which may trigger a flush, - * which may trigger a protect, which will result in another - * call to H5C__auto_adjust_cache_size(). + * possible that a protect may trigger a call to + * H5C__auto_adjust_cache_size(), which may trigger a flush, + * which may trigger a protect, which will result in another + * call to H5C__auto_adjust_cache_size(). * - * The resize_in_progress boolean flag is used to detect this, - * and to prevent the infinite recursion that would otherwise - * occur. + * The resize_in_progress boolean flag is used to detect this, + * and to prevent the infinite recursion that would otherwise + * occur. * - * Note that this issue is not hypothetical -- this field - * was added 12/29/15 to fix a bug exposed in the testing - * of changes to the file driver info superblock extension - * management code needed to support rings. + * Note that this issue is not hypothetical -- this field + * was added 12/29/15 to fix a bug exposed in the testing + * of changes to the file driver info superblock extension + * management code needed to support rings. * * msic_in_progress: As the metadata cache has become re-entrant, and as * the free space manager code has become more tightly @@ -4263,62 +4266,62 @@ typedef struct H5C_tag_info_t { * exposed by modifications to test/fheap.c to cause it to * use paged allocation. * - * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration - * data for automatic cache resizing. + * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration + * data for automatic cache resizing. * * epoch_markers_active: Integer field containing the number of epoch - * markers currently in use in the LRU list. This value - * must be in the range [0, H5C__MAX_EPOCH_MARKERS - 1]. + * markers currently in use in the LRU list. This value + * must be in the range [0, H5C__MAX_EPOCH_MARKERS - 1]. * * epoch_marker_active: Array of boolean of length H5C__MAX_EPOCH_MARKERS. - * This array is used to track which epoch markers are currently - * in use. + * This array is used to track which epoch markers are currently + * in use. * * epoch_marker_ringbuf: Array of int of length H5C__MAX_EPOCH_MARKERS + 1. * - * To manage the epoch marker cache entries, it is necessary - * to track their order in the LRU list. This is done with - * epoch_marker_ringbuf. When markers are inserted at the - * head of the LRU list, the index of the marker in the - * epoch_markers array is inserted at the tail of the ring - * buffer. When it becomes the epoch_marker_active'th marker - * in the LRU list, it will have worked its way to the head - * of the ring buffer as well. This allows us to remove it - * without scanning the LRU list if such is required. + * To manage the epoch marker cache entries, it is necessary + * to track their order in the LRU list. This is done with + * epoch_marker_ringbuf. When markers are inserted at the + * head of the LRU list, the index of the marker in the + * epoch_markers array is inserted at the tail of the ring + * buffer. When it becomes the epoch_marker_active'th marker + * in the LRU list, it will have worked its way to the head + * of the ring buffer as well. This allows us to remove it + * without scanning the LRU list if such is required. * * epoch_marker_ringbuf_first: Integer field containing the index of the - * first entry in the ring buffer. + * first entry in the ring buffer. * * epoch_marker_ringbuf_last: Integer field containing the index of the - * last entry in the ring buffer. + * last entry in the ring buffer. * * epoch_marker_ringbuf_size: Integer field containing the number of entries - * in the ring buffer. + * in the ring buffer. * * epoch_markers: Array of instances of H5C_cache_entry_t of length - * H5C__MAX_EPOCH_MARKERS. The entries are used as markers - * in the LRU list to identify cache entries that haven't - * been accessed for some (small) specified number of - * epochs. These entries (if any) can then be evicted and - * the cache size reduced -- ideally without evicting any - * of the current working set. Needless to say, the epoch - * length and the number of epochs before an unused entry - * must be chosen so that all, or almost all, the working - * set will be accessed before the limit. - * - * Epoch markers only appear in the LRU list, never in - * the index or slist. While they are of type - * H5C__EPOCH_MARKER_TYPE, and have associated class - * functions, these functions should never be called. - * - * The addr fields of these instances of H5C_cache_entry_t - * are set to the index of the instance in the epoch_markers - * array, the size is set to 0, and the type field points - * to the constant structure epoch_marker_class defined - * in H5C.c. The next and prev fields are used as usual - * to link the entry into the LRU list. - * - * All other fields are unused. + * H5C__MAX_EPOCH_MARKERS. The entries are used as markers + * in the LRU list to identify cache entries that haven't + * been accessed for some (small) specified number of + * epochs. These entries (if any) can then be evicted and + * the cache size reduced -- ideally without evicting any + * of the current working set. Needless to say, the epoch + * length and the number of epochs before an unused entry + * must be chosen so that all, or almost all, the working + * set will be accessed before the limit. + * + * Epoch markers only appear in the LRU list, never in + * the index or slist. While they are of type + * H5C__EPOCH_MARKER_TYPE, and have associated class + * functions, these functions should never be called. + * + * The addr fields of these instances of H5C_cache_entry_t + * are set to the index of the instance in the epoch_markers + * array, the size is set to 0, and the type field points + * to the constant structure epoch_marker_class defined + * in H5C.c. The next and prev fields are used as usual + * to link the entry into the LRU list. + * + * All other fields are unused. * * * Cache hit rate collection fields: @@ -4328,62 +4331,62 @@ typedef struct H5C_tag_info_t { * collection is enabled. The following fields support this capability. * * cache_hits: Number of cache hits since the last time the cache hit - * rate statistics were reset. Note that when automatic cache - * re-sizing is enabled, this field will be reset every automatic - * resize epoch. + * rate statistics were reset. Note that when automatic cache + * re-sizing is enabled, this field will be reset every automatic + * resize epoch. * * cache_accesses: Number of times the cache has been accessed while - * since the last since the last time the cache hit rate statistics - * were reset. Note that when automatic cache re-sizing is enabled, - * this field will be reset every automatic resize epoch. + * since the last since the last time the cache hit rate statistics + * were reset. Note that when automatic cache re-sizing is enabled, + * this field will be reset every automatic resize epoch. * * * Metadata cache image management related fields. * - * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration - * data for generation of a cache image on file close. + * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration + * data for generation of a cache image on file close. * * serialization_in_progress: Boolean field that is set to TRUE iff - * the cache is in the process of being serialized. This - * field is needed to support the H5C_serialization_in_progress() - * call, which is in turn required for sanity checks in some - * cache clients. + * the cache is in the process of being serialized. This + * field is needed to support the H5C_serialization_in_progress() + * call, which is in turn required for sanity checks in some + * cache clients. * - * load_image: Boolean flag indicating that the metadata cache image - * superblock extension message exists and should be - * read, and the image block read and decoded on the next - * call to H5C_protect(). + * load_image: Boolean flag indicating that the metadata cache image + * superblock extension message exists and should be + * read, and the image block read and decoded on the next + * call to H5C_protect(). * * image_loaded: Boolean flag indicating that the metadata cache has * loaded the metadata cache image as directed by the * MDC cache image superblock extension message. * * delete_image: Boolean flag indicating whether the metadata cache image - * superblock message should be deleted and the cache image - * file space freed after they have been read and decoded. + * superblock message should be deleted and the cache image + * file space freed after they have been read and decoded. * - * This flag should be set to TRUE iff the file is opened - * R/W and there is a cache image to be read. + * This flag should be set to TRUE iff the file is opened + * R/W and there is a cache image to be read. * * image_addr: haddr_t containing the base address of the on disk - * metadata cache image, or HADDR_UNDEF if that value is - * undefined. Note that this field is used both in the - * construction and write, and the read and decode of - * metadata cache image blocks. + * metadata cache image, or HADDR_UNDEF if that value is + * undefined. Note that this field is used both in the + * construction and write, and the read and decode of + * metadata cache image blocks. * - * image_len: hsize_t containing the size of the on disk metadata cache - * image, or zero if that value is undefined. Note that this - * field is used both in the construction and write, and the - * read and decode of metadata cache image blocks. + * image_len: hsize_t containing the size of the on disk metadata cache + * image, or zero if that value is undefined. Note that this + * field is used both in the construction and write, and the + * read and decode of metadata cache image blocks. * * image_data_len: size_t containing the number of bytes of data in the - * on disk metadata cache image, or zero if that value is - * undefined. + * on disk metadata cache image, or zero if that value is + * undefined. * - * In most cases, this value is the same as the image_len - * above. It exists to allow for metadata cache image blocks - * that are larger than the actual image. Thus in all - * cases image_data_len <= image_len. + * In most cases, this value is the same as the image_len + * above. It exists to allow for metadata cache image blocks + * that are larger than the actual image. Thus in all + * cases image_data_len <= image_len. * * To create the metadata cache image, we must first serialize all the * entries in the metadata cache. This is done by a scan of the index. @@ -4410,35 +4413,35 @@ typedef struct H5C_tag_info_t { * Note that all these new fields would work just as well as booleans. * * entries_loaded_counter: Number of entries loaded into the cache - * since the last time this field was reset. + * since the last time this field was reset. * * entries_inserted_counter: Number of entries inserted into the cache - * since the last time this field was reset. + * since the last time this field was reset. * * entries relocated_counter: Number of entries whose base address has - * been changed since the last time this field was reset. + * been changed since the last time this field was reset. * * entry_fd_height_change_counter: Number of entries whose flush dependency - * height has changed since the last time this field was reset. + * height has changed since the last time this field was reset. * * The following fields are used assemble the cache image prior to * writing it to disk. * * num_entries_in_image: Unsigned integer field containing the number of entries - * to be copied into the metadata cache image. Note that - * this value will be less than the number of entries in - * the cache, and the superblock and its related entries - * are not written to the metadata cache image. + * to be copied into the metadata cache image. Note that + * this value will be less than the number of entries in + * the cache, and the superblock and its related entries + * are not written to the metadata cache image. * * image_entries: Pointer to a dynamically allocated array of instance of - * H5C_image_entry_t of length num_entries_in_image, or NULL - * if that array does not exist. This array is used to - * assemble entry data to be included in the image, and to - * sort them by flush dependency height and LRU rank. + * H5C_image_entry_t of length num_entries_in_image, or NULL + * if that array does not exist. This array is used to + * assemble entry data to be included in the image, and to + * sort them by flush dependency height and LRU rank. * * image_buffer: Pointer to the dynamically allocated buffer of length - * image_len in which the metadata cache image is assembled, - * or NULL if that buffer does not exist. + * image_len in which the metadata cache image is assembled, + * or NULL if that buffer does not exist. * * * Free Space Manager Related fields: @@ -4460,13 +4463,13 @@ typedef struct H5C_tag_info_t { * flush is complete. * * rdfsm_settled: Boolean flag indicating whether the raw data free space - * manager is settled -- i.e. whether the correct space has - * been allocated for it in the file. + * manager is settled -- i.e. whether the correct space has + * been allocated for it in the file. * - * Note that the name of this field is deceptive. In the - * multi file case, the flag applies to all free space - * managers that are not involved in allocating space for - * free space manager metadata. + * Note that the name of this field is deceptive. In the + * multi file case, the flag applies to all free space + * managers that are not involved in allocating space for + * free space manager metadata. * * mdfsm_settled: Boolean flag indicating whether the meta data free space * manager is settled -- i.e. whether the correct space has @@ -4474,8 +4477,8 @@ typedef struct H5C_tag_info_t { * * Note that the name of this field is deceptive. In the * multi file case, the flag applies only to free space - * managers that are involved in allocating space for free - * space managers. + * managers that are involved in allocating space for free + * space managers. * * * Statistics collection fields: @@ -4485,144 +4488,144 @@ typedef struct H5C_tag_info_t { * is true. * * hits: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been in cache when requested in - * the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has been in cache when requested in + * the current epoch. * * misses: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has not been in cache when - * requested in the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has not been in cache when + * requested in the current epoch. * * write_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been write protected - * in the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been write protected + * in the current epoch. * - * Observe that (hits + misses) = (write_protects + read_protects). + * Observe that (hits + misses) = (write_protects + read_protects). * * read_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been read protected in - * the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been read protected in + * the current epoch. * * Observe that (hits + misses) = (write_protects + read_protects). * * max_read_protects: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to maximum number of simultaneous read - * protects on any entry with type id equal to the array index - * in the current epoch. + * The cells are used to maximum number of simultaneous read + * protects on any entry with type id equal to the array index + * in the current epoch. * * insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been inserted into the - * cache in the current epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been inserted into the + * cache in the current epoch. * * pinned_insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been inserted - * pinned into the cache in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been inserted + * pinned into the cache in the current epoch. * * clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times a dirty entry with type - * id equal to the array index has been cleared in the current - * epoch. + * are used to record the number of times a dirty entry with type + * id equal to the array index has been cleared in the current + * epoch. * * flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been written to disk in the + * are used to record the number of times an entry with type id + * equal to the array index has been written to disk in the * current epoch. * * evictions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been evicted from the cache in - * the current epoch. + * are used to record the number of times an entry with type id + * equal to the array index has been evicted from the cache in + * the current epoch. * * take_ownerships: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been removed from the - * cache via the H5C__TAKE_OWNERSHIP_FLAG in the current epoch. + * cells are used to record the number of times an entry with + * type id equal to the array index has been removed from the + * cache via the H5C__TAKE_OWNERSHIP_FLAG in the current epoch. * * moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been moved in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been moved in the current + * epoch. * * entry_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been moved - * during its pre-serialize callback in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been moved + * during its pre-serialize callback in the current epoch. * * cache_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been moved - * during a cache flush in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been moved + * during a cache flush in the current epoch. * * pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been pinned in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been pinned in the current + * epoch. * * unpins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been unpinned in the current - * epoch. + * are used to record the number of times an entry with type + * id equal to the array index has been unpinned in the current + * epoch. * - * dirty_pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been marked dirty while pinned - * in the current epoch. + * dirty_pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * are used to record the number of times an entry with type + * id equal to the array index has been marked dirty while pinned + * in the current epoch. * * pinned_flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry - * with type id equal to the array index has been flushed while - * pinned in the current epoch. + * cells are used to record the number of times an entry + * with type id equal to the array index has been flushed while + * pinned in the current epoch. * * pinned_clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry - * with type id equal to the array index has been cleared while - * pinned in the current epoch. + * cells are used to record the number of times an entry + * with type id equal to the array index has been cleared while + * pinned in the current epoch. * * size_increases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has increased in - * size in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has increased in + * size in the current epoch. * * size_decreases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has decreased in - * size in the current epoch. + * The cells are used to record the number of times an entry + * with type id equal to the array index has decreased in + * size in the current epoch. * * entry_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size while in its pre-serialize - * callback. + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the + * array index has changed size while in its pre-serialize + * callback. * * cache_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size during a cache flush + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the + * array index has changed size during a cache flush * * total_ht_insertions: Number of times entries have been inserted into the - * hash table in the current epoch. + * hash table in the current epoch. * * total_ht_deletions: Number of times entries have been deleted from the * hash table in the current epoch. * * successful_ht_searches: int64 containing the total number of successful - * searches of the hash table in the current epoch. + * searches of the hash table in the current epoch. * * total_successful_ht_search_depth: int64 containing the total number of - * entries other than the targets examined in successful - * searches of the hash table in the current epoch. + * entries other than the targets examined in successful + * searches of the hash table in the current epoch. * * failed_ht_searches: int64 containing the total number of unsuccessful * searches of the hash table in the current epoch. * * total_failed_ht_search_depth: int64 containing the total number of * entries examined in unsuccessful searches of the hash - * table in the current epoch. + * table in the current epoch. * * max_index_len: Largest value attained by the index_len field in the * current epoch. @@ -4631,10 +4634,10 @@ typedef struct H5C_tag_info_t { * current epoch. * * max_clean_index_size: Largest value attained by the clean_index_size field - * in the current epoch. + * in the current epoch. * * max_dirty_index_size: Largest value attained by the dirty_index_size field - * in the current epoch. + * in the current epoch. * * max_slist_len: Largest value attained by the slist_len field in the * current epoch. @@ -4685,11 +4688,11 @@ typedef struct H5C_tag_info_t { * The following fields track statistics on cache images. * * images_created: Integer field containing the number of cache images - * created since the last time statistics were reset. + * created since the last time statistics were reset. * - * At present, this field must always be either 0 or 1. - * Further, since cache images are only created at file - * close, this field should only be set at that time. + * At present, this field must always be either 0 or 1. + * Further, since cache images are only created at file + * close, this field should only be set at that time. * * images_read: Integer field containing the number of cache images * read from file. Note that reading an image is different @@ -4704,12 +4707,12 @@ typedef struct H5C_tag_info_t { * from process 0. * * images_loaded: Integer field containing the number of cache images - * loaded since the last time statistics were reset. + * loaded since the last time statistics were reset. * - * At present, this field must always be either 0 or 1. - * Further, since cache images are only loaded at the - * time of the first protect or on file close, this value - * should only change on those events. + * At present, this field must always be either 0 or 1. + * Further, since cache images are only loaded at the + * time of the first protect or on file close, this value + * should only change on those events. * * last_image_size: Size of the most recently loaded metadata cache image * loaded into the cache, or zero if no image has been @@ -4725,11 +4728,11 @@ typedef struct H5C_tag_info_t { * of prefetched entries are tracked in the flushes and evictions arrays * discused above. * - * prefetches: Number of prefetched entries that are loaded to the - * cache. + * prefetches: Number of prefetched entries that are loaded to the + * cache. * * dirty_prefetches: Number of dirty prefetched entries that are loaded - * into the cache. + * into the cache. * * prefetch_hits: Number of prefetched entries that are actually used. * @@ -4745,9 +4748,9 @@ typedef struct H5C_tag_info_t { * obtain estimates of how frequently these restarts occur. * * slist_scan_restarts: Number of times a scan of the slist (that contains - * calls to H5C__flush_single_entry()) has been restarted to - * avoid potential issues with change of status of the next - * entry in the scan. + * calls to H5C__flush_single_entry()) has been restarted to + * avoid potential issues with change of status of the next + * entry in the scan. * * LRU_scan_restarts: Number of times a scan of the LRU list (that contains * calls to H5C__flush_single_entry()) has been restarted to @@ -4755,43 +4758,43 @@ typedef struct H5C_tag_info_t { * entry in the scan. * * index_scan_restarts: Number of times a scan of the index has been - * restarted to avoid potential issues with load, insertion - * or change in flush dependency height of an entry other - * than the target entry as the result of call(s) to the - * pre_serialize or serialize callbacks. + * restarted to avoid potential issues with load, insertion + * or change in flush dependency height of an entry other + * than the target entry as the result of call(s) to the + * pre_serialize or serialize callbacks. * - * Note that at present, this condition can only be triggered - * by a call to H5C_serialize_single_entry(). + * Note that at present, this condition can only be triggered + * by a call to H5C_serialize_single_entry(). * * The remaining stats are collected only when both H5C_COLLECT_CACHE_STATS * and H5C_COLLECT_CACHE_ENTRY_STATS are true. * * max_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been - * accessed in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been + * accessed in the current epoch. * * min_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the minimum number of times any single - * entry with type id equal to the array index has been - * accessed in the current epoch. + * are used to record the minimum number of times any single + * entry with type id equal to the array index has been + * accessed in the current epoch. * * max_clears: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been cleared - * in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been cleared + * in the current epoch. * * max_flushes: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single - * entry with type id equal to the array index has been - * flushed in the current epoch. + * are used to record the maximum number of times any single + * entry with type id equal to the array index has been + * flushed in the current epoch. * - * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells * are used to record the maximum size of any single entry - * with type id equal to the array index that has resided in - * the cache in the current epoch. + * with type id equal to the array index that has resided in + * the cache in the current epoch. * - * max_pins: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells + * max_pins: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells * are used to record the maximum number of times that any single * entry with type id equal to the array index that has been * marked as pinned in the cache in the current epoch. @@ -4799,9 +4802,9 @@ typedef struct H5C_tag_info_t { * * Fields supporting testing: * - * prefix Array of char used to prefix debugging output. The - * field is intended to allow marking of output of with - * the processes mpi rank. + * prefix Array of char used to prefix debugging output. The + * field is intended to allow marking of output of with + * the processes mpi rank. * * get_entry_ptr_from_addr_counter: Counter used to track the number of * times the H5C_get_entry_ptr_from_addr() function has been @@ -4811,147 +4814,147 @@ typedef struct H5C_tag_info_t { ****************************************************************************/ struct H5C_t { - uint32_t magic; - hbool_t flush_in_progress; + uint32_t magic; + hbool_t flush_in_progress; H5C_log_info_t *log_info; - void * aux_ptr; - int32_t max_type_id; + void * aux_ptr; + int32_t max_type_id; const H5C_class_t * const *class_table_ptr; size_t max_cache_size; size_t min_clean_size; - H5C_write_permitted_func_t check_write_permitted; - hbool_t write_permitted; - H5C_log_flush_func_t log_flush; - hbool_t evictions_enabled; - hbool_t close_warning_received; + H5C_write_permitted_func_t check_write_permitted; + hbool_t write_permitted; + H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + hbool_t close_warning_received; /* Fields for maintaining the [hash table] index of entries */ uint32_t index_len; size_t index_size; - uint32_t index_ring_len[H5C_RING_NTYPES]; - size_t index_ring_size[H5C_RING_NTYPES]; - size_t clean_index_size; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_size; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; + uint32_t index_ring_len[H5C_RING_NTYPES]; + size_t index_ring_size[H5C_RING_NTYPES]; + size_t clean_index_size; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_size; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; uint32_t il_len; size_t il_size; - H5C_cache_entry_t * il_head; - H5C_cache_entry_t * il_tail; + H5C_cache_entry_t * il_head; + H5C_cache_entry_t * il_tail; /* Fields to detect entries removed during scans */ - int64_t entries_removed_counter; - H5C_cache_entry_t * last_entry_removed_ptr; - H5C_cache_entry_t * entry_watched_for_removal; + int64_t entries_removed_counter; + H5C_cache_entry_t * last_entry_removed_ptr; + H5C_cache_entry_t * entry_watched_for_removal; /* Fields for maintaining list of in-order entries, for flushing */ hbool_t slist_enabled; - hbool_t slist_changed; + hbool_t slist_changed; uint32_t slist_len; size_t slist_size; - uint32_t slist_ring_len[H5C_RING_NTYPES]; - size_t slist_ring_size[H5C_RING_NTYPES]; + uint32_t slist_ring_len[H5C_RING_NTYPES]; + size_t slist_ring_size[H5C_RING_NTYPES]; H5SL_t * slist_ptr; uint32_t num_last_entries; #if H5C_DO_SANITY_CHECKS - int32_t slist_len_increase; - int64_t slist_size_increase; + int32_t slist_len_increase; + int64_t slist_size_increase; #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ H5SL_t * tag_list; hbool_t ignore_tags; - uint32_t num_objs_corked; + uint32_t num_objs_corked; /* Fields for tracking protected entries */ uint32_t pl_len; size_t pl_size; - H5C_cache_entry_t * pl_head_ptr; - H5C_cache_entry_t * pl_tail_ptr; + H5C_cache_entry_t * pl_head_ptr; + H5C_cache_entry_t * pl_tail_ptr; /* Fields for tracking pinned entries */ uint32_t pel_len; size_t pel_size; - H5C_cache_entry_t * pel_head_ptr; - H5C_cache_entry_t * pel_tail_ptr; + H5C_cache_entry_t * pel_head_ptr; + H5C_cache_entry_t * pel_tail_ptr; /* Fields for complete LRU list of entries */ uint32_t LRU_list_len; size_t LRU_list_size; - H5C_cache_entry_t * LRU_head_ptr; - H5C_cache_entry_t * LRU_tail_ptr; + H5C_cache_entry_t * LRU_head_ptr; + H5C_cache_entry_t * LRU_tail_ptr; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS /* Fields for clean LRU list of entries */ uint32_t cLRU_list_len; size_t cLRU_list_size; - H5C_cache_entry_t * cLRU_head_ptr; - H5C_cache_entry_t * cLRU_tail_ptr; + H5C_cache_entry_t * cLRU_head_ptr; + H5C_cache_entry_t * cLRU_tail_ptr; /* Fields for dirty LRU list of entries */ uint32_t dLRU_list_len; size_t dLRU_list_size; - H5C_cache_entry_t * dLRU_head_ptr; - H5C_cache_entry_t * dLRU_tail_ptr; + H5C_cache_entry_t * dLRU_head_ptr; + H5C_cache_entry_t * dLRU_tail_ptr; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL /* Fields for collective metadata reads */ uint32_t coll_list_len; size_t coll_list_size; - H5C_cache_entry_t * coll_head_ptr; - H5C_cache_entry_t * coll_tail_ptr; + H5C_cache_entry_t * coll_head_ptr; + H5C_cache_entry_t * coll_tail_ptr; /* Fields for collective metadata writes */ H5SL_t * coll_write_list; #endif /* H5_HAVE_PARALLEL */ /* Fields for automatic cache size adjustment */ - hbool_t size_increase_possible; - hbool_t flash_size_increase_possible; - size_t flash_size_increase_threshold; - hbool_t size_decrease_possible; - hbool_t resize_enabled; - hbool_t cache_full; - hbool_t size_decreased; - hbool_t resize_in_progress; - hbool_t msic_in_progress; - H5C_auto_size_ctl_t resize_ctl; + hbool_t size_increase_possible; + hbool_t flash_size_increase_possible; + size_t flash_size_increase_threshold; + hbool_t size_decrease_possible; + hbool_t resize_enabled; + hbool_t cache_full; + hbool_t size_decreased; + hbool_t resize_in_progress; + hbool_t msic_in_progress; + H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ - int32_t epoch_markers_active; - hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; - int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; - int32_t epoch_marker_ringbuf_first; - int32_t epoch_marker_ringbuf_last; - int32_t epoch_marker_ringbuf_size; - H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_markers_active; + hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; + int32_t epoch_marker_ringbuf_first; + int32_t epoch_marker_ringbuf_last; + int32_t epoch_marker_ringbuf_size; + H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; /* Fields for cache hit rate collection */ - int64_t cache_hits; - int64_t cache_accesses; + int64_t cache_hits; + int64_t cache_accesses; /* fields supporting generation of a cache image on file close */ - H5C_cache_image_ctl_t image_ctl; - hbool_t serialization_in_progress; - hbool_t load_image; + H5C_cache_image_ctl_t image_ctl; + hbool_t serialization_in_progress; + hbool_t load_image; hbool_t image_loaded; - hbool_t delete_image; - haddr_t image_addr; - hsize_t image_len; - hsize_t image_data_len; - int64_t entries_loaded_counter; - int64_t entries_inserted_counter; - int64_t entries_relocated_counter; - int64_t entry_fd_height_change_counter; - uint32_t num_entries_in_image; - H5C_image_entry_t * image_entries; + hbool_t delete_image; + haddr_t image_addr; + hsize_t image_len; + hsize_t image_data_len; + int64_t entries_loaded_counter; + int64_t entries_inserted_counter; + int64_t entries_relocated_counter; + int64_t entry_fd_height_change_counter; + uint32_t num_entries_in_image; + H5C_image_entry_t * image_entries; void * image_buffer; /* Free Space Manager Related fields */ - hbool_t rdfsm_settled; - hbool_t mdfsm_settled; + hbool_t rdfsm_settled; + hbool_t mdfsm_settled; #if H5C_COLLECT_CACHE_STATS /* stats fields */ @@ -4980,12 +4983,12 @@ struct H5C_t { int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; /* Fields for hash table operations */ - int64_t total_ht_insertions; - int64_t total_ht_deletions; - int64_t successful_ht_searches; - int64_t total_successful_ht_search_depth; - int64_t failed_ht_searches; - int64_t total_failed_ht_search_depth; + int64_t total_ht_insertions; + int64_t total_ht_deletions; + int64_t successful_ht_searches; + int64_t total_successful_ht_search_depth; + int64_t failed_ht_searches; + int64_t total_failed_ht_search_depth; uint32_t max_index_len; size_t max_index_size; size_t max_clean_index_size; @@ -5014,20 +5017,20 @@ struct H5C_t { int64_t entries_scanned_to_make_space; /* Fields for tracking skip list scan restarts */ - int64_t slist_scan_restarts; - int64_t LRU_scan_restarts; - int64_t index_scan_restarts; + int64_t slist_scan_restarts; + int64_t LRU_scan_restarts; + int64_t index_scan_restarts; /* Fields for tracking cache image operations */ - int32_t images_created; - int32_t images_read; - int32_t images_loaded; - hsize_t last_image_size; + int32_t images_created; + int32_t images_read; + int32_t images_loaded; + hsize_t last_image_size; /* Fields for tracking prefetched entries */ - int64_t prefetches; - int64_t dirty_prefetches; - int64_t prefetch_hits; + int64_t prefetches; + int64_t dirty_prefetches; + int64_t prefetch_hits; #if H5C_COLLECT_CACHE_ENTRY_STATS int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; @@ -5039,7 +5042,7 @@ struct H5C_t { #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ - char prefix[H5C__PREFIX_LEN]; + char prefix[H5C__PREFIX_LEN]; #ifndef NDEBUG int64_t get_entry_ptr_from_addr_counter; @@ -5074,8 +5077,6 @@ 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, hbool_t write_permitted); H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f); -H5_DLL herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, - H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C__serialize_cache(H5F_t *f); H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, void *cb_ctx); @@ -5086,8 +5087,8 @@ H5_DLL herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry); /* Testing functions */ #ifdef H5C_TESTING -H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status); +H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status); #endif /* H5C_TESTING */ -#endif /* _H5Cpkg_H */ - +#endif /* H5Cpkg_H */ +/* clang-format on */ diff --git a/src/H5Cprefetched.c b/src/H5Cprefetched.c index 954dd604868..07fca2bd193 100644 --- a/src/H5Cprefetched.c +++ b/src/H5Cprefetched.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,26 +22,22 @@ *------------------------------------------------------------------------- */ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -51,27 +47,20 @@ * Declarations for prefetched cache entry callbacks. * ****************************************************************************/ -static herr_t H5C__prefetched_entry_get_initial_load_size(void *udata_ptr, - size_t *image_len_ptr); -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, 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, haddr_t *new_addr_ptr, size_t *new_len_ptr, - unsigned *flags_ptr); -static herr_t H5C__prefetched_entry_serialize(const H5F_t *f, void *image_ptr, - size_t len, void *thing); -static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, - void *thing); +static herr_t H5C__prefetched_entry_get_initial_load_size(void *udata_ptr, size_t *image_len_ptr); +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, + 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, + haddr_t *new_addr_ptr, size_t *new_len_ptr, + unsigned *flags_ptr); +static herr_t H5C__prefetched_entry_serialize(const H5F_t *f, void *image_ptr, size_t len, void *thing); +static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, void *thing); static herr_t H5C__prefetched_entry_free_icr(void *thing); -static herr_t H5C__prefetched_entry_fsf_size(const void *thing, - hsize_t *fsf_size_ptr); - +static herr_t H5C__prefetched_entry_fsf_size(const void *thing, hsize_t *fsf_size_ptr); /*********************/ /* Package Variables */ @@ -80,17 +69,14 @@ static herr_t H5C__prefetched_entry_fsf_size(const void *thing, /* Declare external the free list for H5C_cache_entry_t's */ H5FL_EXTERN(H5C_cache_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ /* id = */ H5AC_PREFETCHED_ENTRY_ID, /* name = */ "prefetched entry", @@ -108,8 +94,6 @@ const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ /* fsf_size = */ H5C__prefetched_entry_fsf_size, }}; - - /*************************************************************************** * With two exceptions, these functions should never be called, and thus * there is little point in documenting them separately as they all simply @@ -123,91 +107,83 @@ const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ static herr_t H5C__prefetched_entry_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *image_len_ptr) + size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_get_initial_load_size() */ static herr_t H5C__prefetched_entry_get_final_load_size(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, - size_t H5_ATTR_UNUSED *actual_len_ptr) + size_t H5_ATTR_UNUSED image_len, void H5_ATTR_UNUSED *udata_ptr, + size_t H5_ATTR_UNUSED *actual_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_get_final_load_size() */ static htri_t -H5C__prefetched_entry_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *udata_ptr) +H5C__prefetched_entry_verify_chksum(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_verify_chksum() */ - static void * -H5C__prefetched_entry_deserialize(const void H5_ATTR_UNUSED * image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED * udata, - hbool_t H5_ATTR_UNUSED * dirty_ptr) +H5C__prefetched_entry_deserialize(const void H5_ATTR_UNUSED *image_ptr, size_t H5_ATTR_UNUSED len, + void H5_ATTR_UNUSED *udata, hbool_t H5_ATTR_UNUSED *dirty_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(NULL) } /* end H5C__prefetched_entry_deserialize() */ - static herr_t -H5C__prefetched_entry_image_len(const void H5_ATTR_UNUSED *thing, - size_t H5_ATTR_UNUSED *image_len_ptr) +H5C__prefetched_entry_image_len(const void H5_ATTR_UNUSED *thing, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_image_len() */ - static herr_t H5C__prefetched_entry_pre_serialize(H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *thing, - haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, - haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, - unsigned H5_ATTR_UNUSED *flags_ptr) + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len, + haddr_t H5_ATTR_UNUSED *new_addr_ptr, size_t H5_ATTR_UNUSED *new_len_ptr, + unsigned H5_ATTR_UNUSED *flags_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_pre_serialize() */ - static herr_t -H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, - void H5_ATTR_UNUSED *image_ptr, - size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) +H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, void H5_ATTR_UNUSED *image_ptr, + size_t H5_ATTR_UNUSED len, void H5_ATTR_UNUSED *thing) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_serialize() */ - /*------------------------------------------------------------------------- * Function: H5C__prefetched_entry_notify * @@ -228,9 +204,9 @@ H5C__prefetched_entry_serialize(const H5F_t H5_ATTR_UNUSED *f, static herr_t H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) { - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_thing; - unsigned u; - herr_t ret_value = SUCCEED; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; + unsigned u; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -239,7 +215,7 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->prefetched); - switch(action) { + switch (action) { case H5C_NOTIFY_ACTION_AFTER_INSERT: case H5C_NOTIFY_ACTION_AFTER_LOAD: case H5C_NOTIFY_ACTION_AFTER_FLUSH: @@ -253,8 +229,8 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) break; case H5C_NOTIFY_ACTION_BEFORE_EVICT: - for(u = 0; u < entry_ptr->flush_dep_nparents; u++) { - H5C_cache_entry_t * parent_ptr; + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + H5C_cache_entry_t *parent_ptr; /* Sanity checks */ HDassert(entry_ptr->flush_dep_parent); @@ -264,10 +240,11 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(parent_ptr->flush_dep_nchildren > 0); /* Destroy flush dependency with flush dependency parent */ - if(H5C_destroy_flush_dependency(parent_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "unable to destroy prefetched entry flush dependency") + if (H5C_destroy_flush_dependency(parent_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "unable to destroy prefetched entry flush dependency") - if(parent_ptr->prefetched) { + if (parent_ptr->prefetched) { /* In prefetched entries, the fd_child_count field is * used in sanity checks elsewhere. Thus update this * field to reflect the destruction of the flush @@ -276,7 +253,7 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) HDassert(parent_ptr->fd_child_count > 0); (parent_ptr->fd_child_count)--; } /* end if */ - } /* end for */ + } /* end for */ break; default: @@ -288,7 +265,6 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5C__prefetched_entry_notify() */ - /*------------------------------------------------------------------------- * Function: H5C__prefetched_entry_free_icr * @@ -308,7 +284,7 @@ static herr_t H5C__prefetched_entry_free_icr(void *_thing) { H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -318,15 +294,15 @@ H5C__prefetched_entry_free_icr(void *_thing) HDassert(entry_ptr->prefetched); /* Release array for flush dependency parent addresses */ - if(entry_ptr->fd_parent_addrs != NULL) { - HDassert(entry_ptr->fd_parent_count > 0); - entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree((void *)entry_ptr->fd_parent_addrs); + if (entry_ptr->fd_parent_addrs != NULL) { + HDassert(entry_ptr->fd_parent_count > 0); + entry_ptr->fd_parent_addrs = (haddr_t *)H5MM_xfree((void *)entry_ptr->fd_parent_addrs); } /* end if */ else - HDassert(entry_ptr->fd_parent_count == 0); + 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?") + if (entry_ptr->image_ptr != NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "prefetched entry image buffer still attatched?") entry_ptr = H5FL_FREE(H5C_cache_entry_t, entry_ptr); @@ -334,15 +310,12 @@ H5C__prefetched_entry_free_icr(void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5C__prefetched_entry_free_icr() */ - static herr_t -H5C__prefetched_entry_fsf_size(const void H5_ATTR_UNUSED *thing, - hsize_t H5_ATTR_UNUSED *fsf_size_ptr) +H5C__prefetched_entry_fsf_size(const void H5_ATTR_UNUSED *thing, hsize_t H5_ATTR_UNUSED *fsf_size_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ - HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); + HERROR(H5E_CACHE, H5E_SYSTEM, "called unreachable fcn."); FUNC_LEAVE_NOAPI(FAIL) } /* end H5C__prefetched_entry_fsf_size() */ - diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 6411375d4b5..27a24c41bca 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -6,74 +6,72 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: H5Cprivate.h - * 6/3/04 - * John Mainzer + * Created: H5Cprivate.h + * 6/3/04 + * John Mainzer * - * Purpose: Constants and typedefs available to the rest of the - * library. - * - * Modifications: + * Purpose: Constants and typedefs available to the rest of the + * library. * *------------------------------------------------------------------------- */ -#ifndef _H5Cprivate_H -#define _H5Cprivate_H +#ifndef H5Cprivate_H +#define H5Cprivate_H -#include "H5Cpublic.h" /* public prototypes */ +#include "H5Cpublic.h" /* public prototypes */ /* Private headers needed by this header */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ /* Cache configuration settings */ -#define H5C__MAX_NUM_TYPE_IDS 30 -#define H5C__PREFIX_LEN 32 +#define H5C__MAX_NUM_TYPE_IDS 30 +#define H5C__PREFIX_LEN 32 /* This sanity checking constant was picked out of the air. Increase * or decrease it if appropriate. Its purposes is to detect corrupt * object sizes, so it probably doesn't matter if it is a bit big. * - * JRM - 5/17/04 + * JRM - 5/17/04 */ -#define H5C_MAX_ENTRY_SIZE ((size_t)(32 * 1024 * 1024)) +#define H5C_MAX_ENTRY_SIZE ((size_t)(32 * 1024 * 1024)) #ifdef H5_HAVE_PARALLEL /* we must maintain the clean and dirty LRU lists when we are compiled * with parallel support. */ -#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 1 +#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 1 #else /* H5_HAVE_PARALLEL */ /* The clean and dirty LRU lists don't buy us anything here -- we may * want them on for testing on occasion, but in general they should be * off. */ -#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 +#define H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS 0 #endif /* H5_HAVE_PARALLEL */ /* Flags for cache client class behavior */ -#define H5C__CLASS_NO_FLAGS_SET ((unsigned)0x0) -#define H5C__CLASS_SPECULATIVE_LOAD_FLAG ((unsigned)0x1) +#define H5C__CLASS_NO_FLAGS_SET ((unsigned)0x0) +#define H5C__CLASS_SPECULATIVE_LOAD_FLAG ((unsigned)0x1) /* The following flags may only appear in test code */ -#define H5C__CLASS_SKIP_READS ((unsigned)0x2) -#define H5C__CLASS_SKIP_WRITES ((unsigned)0x4) +#define H5C__CLASS_SKIP_READS ((unsigned)0x2) +#define H5C__CLASS_SKIP_WRITES ((unsigned)0x4) /* Flags for pre-serialize callback */ -#define H5C__SERIALIZE_NO_FLAGS_SET ((unsigned)0) -#define H5C__SERIALIZE_RESIZED_FLAG ((unsigned)0x1) -#define H5C__SERIALIZE_MOVED_FLAG ((unsigned)0x2) +#define H5C__SERIALIZE_NO_FLAGS_SET ((unsigned)0) +#define H5C__SERIALIZE_RESIZED_FLAG ((unsigned)0x1) +#define H5C__SERIALIZE_MOVED_FLAG ((unsigned)0x2) /* Upper and lower limits on cache size. These limits are picked * out of a hat -- you should be able to change them as necessary. @@ -83,24 +81,25 @@ * upper bound on cache size is rather large for the current hash table * size. */ -#define H5C__MAX_MAX_CACHE_SIZE ((size_t)(128 * 1024 * 1024)) -#define H5C__MIN_MAX_CACHE_SIZE ((size_t)(1024)) +#define H5C__MAX_MAX_CACHE_SIZE ((size_t)(128 * 1024 * 1024)) +#define H5C__MIN_MAX_CACHE_SIZE ((size_t)(1024)) /* Default max cache size and min clean size are give here to make * them generally accessible. */ -#define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(4 * 1024 * 1024)) -#define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(2 * 1024 * 1024)) +#define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(4 * 1024 * 1024)) +#define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(2 * 1024 * 1024)) /* Values for cache entry magic field */ -#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A -#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef +#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A +#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef /* Cache configuration validation definitions */ -#define H5C_RESIZE_CFG__VALIDATE_GENERAL 0x1 -#define H5C_RESIZE_CFG__VALIDATE_INCREMENT 0x2 -#define H5C_RESIZE_CFG__VALIDATE_DECREMENT 0x4 -#define H5C_RESIZE_CFG__VALIDATE_INTERACTIONS 0x8 +#define H5C_RESIZE_CFG__VALIDATE_GENERAL 0x1 +#define H5C_RESIZE_CFG__VALIDATE_INCREMENT 0x2 +#define H5C_RESIZE_CFG__VALIDATE_DECREMENT 0x4 +#define H5C_RESIZE_CFG__VALIDATE_INTERACTIONS 0x8 +/* clang-format off */ #define H5C_RESIZE_CFG__VALIDATE_ALL \ ( \ H5C_RESIZE_CFG__VALIDATE_GENERAL | \ @@ -108,30 +107,31 @@ H5C_RESIZE_CFG__VALIDATE_DECREMENT | \ H5C_RESIZE_CFG__VALIDATE_INTERACTIONS \ ) +/* clang-format on */ /* Cache configuration versions */ -#define H5C__CURR_AUTO_SIZE_CTL_VER 1 -#define H5C__CURR_AUTO_RESIZE_RPT_FCN_VER 1 -#define H5C__CURR_CACHE_IMAGE_CTL_VER 1 +#define H5C__CURR_AUTO_SIZE_CTL_VER 1 +#define H5C__CURR_AUTO_RESIZE_RPT_FCN_VER 1 +#define H5C__CURR_CACHE_IMAGE_CTL_VER 1 /* Default configuration settings */ -#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999f -#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9f -#define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) -#define H5C__DEF_AR_INIT_SIZE ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_SIZE ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5f -#define H5C__DEF_AR_INCREMENT 2.0f -#define H5C__DEF_AR_MAX_INCREMENT ((size_t)( 2 * 1024 * 1024)) -#define H5C__DEF_AR_FLASH_MULTIPLE 1.0f -#define H5C__DEV_AR_FLASH_THRESHOLD 0.25f -#define H5C__DEF_AR_DECREMENT 0.9f -#define H5C__DEF_AR_MAX_DECREMENT ((size_t)( 1 * 1024 * 1024)) -#define H5C__DEF_AR_EPCHS_B4_EVICT 3 -#define H5C__DEF_AR_EMPTY_RESERVE 0.05f -#define H5C__MIN_AR_EPOCH_LENGTH 100 -#define H5C__DEF_AR_EPOCH_LENGTH 50000 -#define H5C__MAX_AR_EPOCH_LENGTH 1000000 +#define H5C__DEF_AR_UPPER_THRESHHOLD 0.9999 +#define H5C__DEF_AR_LOWER_THRESHHOLD 0.9 +#define H5C__DEF_AR_MAX_SIZE ((size_t)(16 * 1024 * 1024)) +#define H5C__DEF_AR_INIT_SIZE ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_MIN_SIZE ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5 +#define H5C__DEF_AR_INCREMENT 2.0 +#define H5C__DEF_AR_MAX_INCREMENT ((size_t)(2 * 1024 * 1024)) +#define H5C__DEF_AR_FLASH_MULTIPLE 1.0 +#define H5C__DEV_AR_FLASH_THRESHOLD 0.25 +#define H5C__DEF_AR_DECREMENT 0.9 +#define H5C__DEF_AR_MAX_DECREMENT ((size_t)(1 * 1024 * 1024)) +#define H5C__DEF_AR_EPCHS_B4_EVICT 3 +#define H5C__DEF_AR_EMPTY_RESERVE 0.05 +#define H5C__MIN_AR_EPOCH_LENGTH 100 +#define H5C__DEF_AR_EPOCH_LENGTH 50000 +#define H5C__MAX_AR_EPOCH_LENGTH 1000000 /* #defines of flags used in the flags parameters in some of the * following function calls. Note that not all flags are applicable @@ -139,93 +139,93 @@ * function are ignored in that function. * * These flags apply to all function calls: - * H5C__NO_FLAGS_SET (generic "no flags set" for all fcn calls) + * H5C__NO_FLAGS_SET (generic "no flags set" for all fcn calls) * * * These flags apply to H5C_insert_entry(): - * H5C__SET_FLUSH_MARKER_FLAG - * H5C__PIN_ENTRY_FLAG - * H5C__FLUSH_LAST_FLAG ; super block only - * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only + * H5C__SET_FLUSH_MARKER_FLAG + * H5C__PIN_ENTRY_FLAG + * H5C__FLUSH_LAST_FLAG ; super block only + * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only * * These flags apply to H5C_protect() - * H5C__READ_ONLY_FLAG - * H5C__FLUSH_LAST_FLAG ; super block only - * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only + * H5C__READ_ONLY_FLAG + * H5C__FLUSH_LAST_FLAG ; super block only + * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only * * These flags apply to H5C_unprotect(): - * H5C__SET_FLUSH_MARKER_FLAG - * H5C__DELETED_FLAG - * H5C__DIRTIED_FLAG - * H5C__PIN_ENTRY_FLAG - * H5C__UNPIN_ENTRY_FLAG - * H5C__FREE_FILE_SPACE_FLAG - * H5C__TAKE_OWNERSHIP_FLAG + * H5C__SET_FLUSH_MARKER_FLAG + * H5C__DELETED_FLAG + * H5C__DIRTIED_FLAG + * H5C__PIN_ENTRY_FLAG + * H5C__UNPIN_ENTRY_FLAG + * H5C__FREE_FILE_SPACE_FLAG + * H5C__TAKE_OWNERSHIP_FLAG * * These flags apply to H5C_expunge_entry(): - * H5C__FREE_FILE_SPACE_FLAG + * H5C__FREE_FILE_SPACE_FLAG * * These flags apply to H5C_evict(): - * H5C__EVICT_ALLOW_LAST_PINS_FLAG + * H5C__EVICT_ALLOW_LAST_PINS_FLAG * * These flags apply to H5C_flush_cache(): - * H5C__FLUSH_INVALIDATE_FLAG - * H5C__FLUSH_CLEAR_ONLY_FLAG - * H5C__FLUSH_MARKED_ENTRIES_FLAG - * H5C__FLUSH_IGNORE_PROTECTED_FLAG (can't use this flag in combination - * with H5C__FLUSH_INVALIDATE_FLAG) - * H5C__DURING_FLUSH_FLAG + * H5C__FLUSH_INVALIDATE_FLAG + * H5C__FLUSH_CLEAR_ONLY_FLAG + * H5C__FLUSH_MARKED_ENTRIES_FLAG + * H5C__FLUSH_IGNORE_PROTECTED_FLAG (can't use this flag in combination + * with H5C__FLUSH_INVALIDATE_FLAG) + * H5C__DURING_FLUSH_FLAG * * These flags apply to H5C_flush_single_entry(): - * H5C__FLUSH_INVALIDATE_FLAG - * H5C__FLUSH_CLEAR_ONLY_FLAG - * H5C__FLUSH_MARKED_ENTRIES_FLAG - * H5C__TAKE_OWNERSHIP_FLAG - * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG - * H5C__GENERATE_IMAGE_FLAG - * H5C__UPDATE_PAGE_BUFFER_FLAG + * H5C__FLUSH_INVALIDATE_FLAG + * H5C__FLUSH_CLEAR_ONLY_FLAG + * H5C__FLUSH_MARKED_ENTRIES_FLAG + * H5C__TAKE_OWNERSHIP_FLAG + * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG + * H5C__GENERATE_IMAGE_FLAG + * H5C__UPDATE_PAGE_BUFFER_FLAG */ -#define H5C__NO_FLAGS_SET 0x00000 -#define H5C__SET_FLUSH_MARKER_FLAG 0x00001 -#define H5C__DELETED_FLAG 0x00002 -#define H5C__DIRTIED_FLAG 0x00004 -#define H5C__PIN_ENTRY_FLAG 0x00008 -#define H5C__UNPIN_ENTRY_FLAG 0x00010 -#define H5C__FLUSH_INVALIDATE_FLAG 0x00020 -#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00040 -#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x00080 -#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00100 -#define H5C__READ_ONLY_FLAG 0x00200 -#define H5C__FREE_FILE_SPACE_FLAG 0x00400 -#define H5C__TAKE_OWNERSHIP_FLAG 0x00800 -#define H5C__FLUSH_LAST_FLAG 0x01000 -#define H5C__FLUSH_COLLECTIVELY_FLAG 0x02000 -#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x04000 -#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 -#define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ -#define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ -#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ +#define H5C__NO_FLAGS_SET 0x00000 +#define H5C__SET_FLUSH_MARKER_FLAG 0x00001 +#define H5C__DELETED_FLAG 0x00002 +#define H5C__DIRTIED_FLAG 0x00004 +#define H5C__PIN_ENTRY_FLAG 0x00008 +#define H5C__UNPIN_ENTRY_FLAG 0x00010 +#define H5C__FLUSH_INVALIDATE_FLAG 0x00020 +#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00040 +#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x00080 +#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00100 +#define H5C__READ_ONLY_FLAG 0x00200 +#define H5C__FREE_FILE_SPACE_FLAG 0x00400 +#define H5C__TAKE_OWNERSHIP_FLAG 0x00800 +#define H5C__FLUSH_LAST_FLAG 0x01000 +#define H5C__FLUSH_COLLECTIVELY_FLAG 0x02000 +#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x04000 +#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 +#define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ +#define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ +#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ /* Debugging/sanity checking/statistics settings */ #ifndef NDEBUG -#define H5C_DO_SANITY_CHECKS 1 -#define H5C_DO_SLIST_SANITY_CHECKS 0 -#define H5C_DO_TAGGING_SANITY_CHECKS 1 -#define H5C_DO_EXTREME_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 1 +#define H5C_DO_SLIST_SANITY_CHECKS 0 +#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 * to 0 if NDEBUG is defined */ -#define H5C_DO_SANITY_CHECKS 0 -#define H5C_DO_SLIST_SANITY_CHECKS 0 -#define H5C_DO_TAGGING_SANITY_CHECKS 0 -#define H5C_DO_EXTREME_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 0 +#define H5C_DO_SLIST_SANITY_CHECKS 0 +#define H5C_DO_TAGGING_SANITY_CHECKS 0 +#define H5C_DO_EXTREME_SANITY_CHECKS 0 #endif /* NDEBUG */ /* Cork actions: cork/uncork/get cork status of an object */ -#define H5C__SET_CORK 0x1 -#define H5C__UNCORK 0x2 -#define H5C__GET_CORKED 0x4 +#define H5C__SET_CORK 0x1 +#define H5C__UNCORK 0x2 +#define H5C__GET_CORKED 0x4 /* Note: The memory sanity checks aren't going to work until I/O filters are * changed to call a particular alloc/free routine for their buffers, @@ -235,7 +235,7 @@ * routines that the fractal heap direct block (and global heap) serialize * calls can use when resizing (and re-allocating) their image in the * cache. -QAK */ -#define H5C_DO_MEMORY_SANITY_CHECKS 0 +#define H5C_DO_MEMORY_SANITY_CHECKS 0 /* H5C_COLLECT_CACHE_STATS controls overall collection of statistics * on cache activity. In general, this #define should be set to 1 in @@ -243,9 +243,9 @@ */ #ifndef NDEBUG -#define H5C_COLLECT_CACHE_STATS 1 +#define H5C_COLLECT_CACHE_STATS 1 #else /* NDEBUG */ -#define H5C_COLLECT_CACHE_STATS 0 +#define H5C_COLLECT_CACHE_STATS 0 #endif /* NDEBUG */ /* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics @@ -255,12 +255,11 @@ * H5C_COLLECT_CACHE_STATS is also defined to true. */ #if H5C_COLLECT_CACHE_STATS -#define H5C_COLLECT_CACHE_ENTRY_STATS 1 +#define H5C_COLLECT_CACHE_ENTRY_STATS 1 #else -#define H5C_COLLECT_CACHE_ENTRY_STATS 0 +#define H5C_COLLECT_CACHE_ENTRY_STATS 0 #endif /* H5C_COLLECT_CACHE_STATS */ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -276,204 +275,204 @@ typedef struct H5C_t H5C_t; * used by the metadata cache for each class of metadata cache entry. * The fields of the structure are discussed below: * - * id: Integer field containing the unique ID of the class of metadata - * cache entries. + * id: Integer field containing the unique ID of the class of metadata + * cache entries. * * name: Pointer to a string containing the name of the class of metadata - * cache entries. + * cache entries. * * mem_type: Instance of H5FD_mem_t, that is used to supply the - * mem type passed into H5F_block_read(). + * mem type passed into H5F_block_read(). * * flags: Flags indicating class-specific behavior. * - * Possible flags are: + * Possible flags are: * - * H5C__CLASS_NO_FLAGS_SET: No special processing. + * H5C__CLASS_NO_FLAGS_SET: No special processing. * - * H5C__CLASS_SPECULATIVE_LOAD_FLAG: This flag is used only in + * H5C__CLASS_SPECULATIVE_LOAD_FLAG: This flag is used only in * H5C_load_entry(). When it is set, entries are - * permitted to change their sizes on the first attempt - * to load. - * - * If the new size is larger than the old, the read buffer - * is reallocated to the new size, loaded from file, and the - * deserialize routine is called a second time on the - * new buffer. The entry returned by the first call to - * the deserialize routine is discarded (via the free_icr - * call) after the new size is retrieved (via the image_len - * call). Note that the new size is used as the size of the - * entry in the cache. - * - * If the new size is smaller than the old, no new loads - * or deserializes are performed, but the new size becomes - * the size of the entry in the cache. - * - * When this flag is set, an attempt to read past the - * end of file could occur. In this case, if the size - * returned get_load_size callback would result in a - * read past the end of file, the size is truncated to - * avoid this, and processing proceeds as normal. + * permitted to change their sizes on the first attempt + * to load. + * + * If the new size is larger than the old, the read buffer + * is reallocated to the new size, loaded from file, and the + * deserialize routine is called a second time on the + * new buffer. The entry returned by the first call to + * the deserialize routine is discarded (via the free_icr + * call) after the new size is retrieved (via the image_len + * call). Note that the new size is used as the size of the + * entry in the cache. + * + * If the new size is smaller than the old, no new loads + * or deserializes are performed, but the new size becomes + * the size of the entry in the cache. + * + * When this flag is set, an attempt to read past the + * end of file could occur. In this case, if the size + * returned get_load_size callback would result in a + * read past the end of file, the size is truncated to + * avoid this, and processing proceeds as normal. * * The following flags may only appear in test code. * - * H5C__CLASS_SKIP_READS: This flags is intended only for use in test - * code. When it is set, reads on load will be skipped, - * and an uninitialize buffer will be passed to the - * deserialize function. + * H5C__CLASS_SKIP_READS: This flags is intended only for use in test + * code. When it is set, reads on load will be skipped, + * and an uninitialize buffer will be passed to the + * deserialize function. * - * H5C__CLASS_SKIP_WRITES: This flags is intended only for use in test - * code. When it is set, writes of buffers prepared by the - * serialize callback will be skipped. + * H5C__CLASS_SKIP_WRITES: This flags is intended only for use in test + * code. When it is set, writes of buffers prepared by the + * serialize callback will be skipped. * * GET_INITIAL_LOAD_SIZE: Pointer to the 'get initial load size' function. * - * This function determines the size based on the information in the - * parameter "udata" or an initial speculative guess. The size is - * returned in the parameter "image_len_ptr". + * This function determines the size based on the information in the + * parameter "udata" or an initial speculative guess. The size is + * returned in the parameter "image_len_ptr". * - * For an entry with H5C__CLASS_NO_FLAGS_SET: - * This function returns in "image_len_ptr" the on disk size of the + * For an entry with H5C__CLASS_NO_FLAGS_SET: + * This function returns in "image_len_ptr" the on disk size of the * entry. * - * For an entry with H5C__CLASS_SPECULATIVE_LOAD_FLAG: - * This function returns in "image_len_ptr" an initial guess of the + * For an entry with H5C__CLASS_SPECULATIVE_LOAD_FLAG: + * This function returns in "image_len_ptr" an initial guess of the * entry's on disk size. This many bytes will be loaded from * the file and then passed to 'get_final_load_size' callback * for the actual (final) image length to be determined. * - * The typedef for the get_initial_load_size callback is as follows: + * The typedef for the get_initial_load_size callback is as follows: * - * typedef herr_t (*H5C_get_initial_load_size_func_t)(void *udata_ptr, - * size_t *image_len_ptr); + * typedef herr_t (*H5C_get_initial_load_size_func_t)(void *udata_ptr, + * size_t *image_len_ptr); * - * The parameters of the get_initial_load_size callback are as follows: + * The parameters of the get_initial_load_size callback are as follows: * - * udata_ptr: Pointer to user data provided in the protect call, which - * will also be passed through to the 'get_final_load_size', + * udata_ptr: Pointer to user data provided in the protect call, which + * will also be passed through to the 'get_final_load_size', * 'verify_chksum', and 'deserialize' callbacks. * - * image_len_ptr: Pointer to the length in bytes of the in-file image to + * image_len_ptr: Pointer to the length in bytes of the in-file image to * be deserialized is to be returned. * * This value is used by the cache to determine the size of * the disk image for the metadata, in order to read the disk * image from the file. * - * Processing in the get_load_size function should proceed as follows: + * Processing in the get_load_size function should proceed as follows: * - * If successful, the function will place the length in the *image_len_ptr + * If successful, the function will place the length in the *image_len_ptr * associated with supplied user data and then return SUCCEED. * - * On failure, the function must return FAIL and push error information - * onto the error stack with the error API routines, without modifying + * On failure, the function must return FAIL and push error information + * onto the error stack with the error API routines, without modifying * the value pointed to by image_len_ptr. * * * GET_FINAL_LOAD_SIZE: Pointer to the 'get final load size' function. * - * This function determines the final size of a speculatively loaded + * This function determines the final size of a speculatively loaded * metadata cache entry based on the parameter "image" and the "udata" * parameters. This callback _must_ be implemented for cache clients * which set the H5C__CLASS_SPECULATIVE_LOAD_FLAG and must return the * actual length of on-disk image after being called once. * - * This function might deserialize the needed metadata information to - * determine the actual size. The size is returned in the parameter + * This function might deserialize the needed metadata information to + * determine the actual size. The size is returned in the parameter * "actual_len_ptr". * - * The typedef for the get_load_size callback is as follows: + * The typedef for the get_load_size callback is as follows: * - * typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, - * size_t image_len, - * void *udata_ptr, - * size_t *actual_len_ptr); + * typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, + * size_t image_len, + * void *udata_ptr, + * size_t *actual_len_ptr); * - * The parameters of the get_load_size callback are as follows: + * The parameters of the get_load_size callback are as follows: * - * image_ptr: Pointer to a buffer containing the (possibly partial) + * image_ptr: Pointer to a buffer containing the (possibly partial) * metadata read in. * - * image_len: The length in bytes of the (possibly partial) in-file image + * image_len: The length in bytes of the (possibly partial) in-file image * to be queried for an actual length. * - * udata_ptr: Pointer to user data provided in the protect call, which - * will also be passed through to the 'verify_chksum' and + * udata_ptr: Pointer to user data provided in the protect call, which + * will also be passed through to the 'verify_chksum' and * 'deserialize' callbacks. * - * actual_len_ptr: Pointer to the location containing the actual length - * of the metadata entry on disk. + * actual_len_ptr: Pointer to the location containing the actual length + * of the metadata entry on disk. * - * Processing in the get_final_load_size function should proceed as follows: + * Processing in the get_final_load_size function should proceed as follows: * - * If successful, the function will place the length in the *actual_len_ptr + * If successful, the function will place the length in the *actual_len_ptr * associated with supplied image and/or user data and then return SUCCEED. * - * On failure, the function must return FAIL and push error information - * onto the error stack with the error API routines, without modifying + * On failure, the function must return FAIL and push error information + * onto the error stack with the error API routines, without modifying * the value pointed to by actual_len_ptr. * * * VERIFY_CHKSUM: Pointer to the verify_chksum function. * - * This function verifies the checksum computed for the metadata is - * the same as the checksum stored in the metadata. + * This function verifies the checksum computed for the metadata is + * the same as the checksum stored in the metadata. * - * It computes the checksum based on the metadata stored in the - * parameter "image_ptr" and the actual length of the metadata in the - * parameter "len" which is obtained from the "get_load_size" callback. + * It computes the checksum based on the metadata stored in the + * parameter "image_ptr" and the actual length of the metadata in the + * parameter "len" which is obtained from the "get_load_size" callback. * - * The typedef for the verify_chksum callback is as follows: + * The typedef for the verify_chksum callback is as follows: * - * typedef htri_t (*H5C_verify_chksum_func_t)(const void *image_ptr, - * size_t len, - * void *udata_ptr); + * typedef htri_t (*H5C_verify_chksum_func_t)(const void *image_ptr, + * size_t len, + * void *udata_ptr); * - * The parameters of the verify_chksum callback are as follows: + * The parameters of the verify_chksum callback are as follows: * - * image_ptr: Pointer to a buffer containing the metadata read in. + * image_ptr: Pointer to a buffer containing the metadata read in. * - * len: The actual length of the metadata. + * len: The actual length of the metadata. * - * udata_ptr: Pointer to user data. + * udata_ptr: Pointer to user data. * * * DESERIALIZE: Pointer to the deserialize function. * - * This function must be able to deserialize a buffer containing the + * This function must be able to deserialize a buffer containing the * on-disk image of a metadata cache entry, allocate and initialize the * equivalent in core representation, and return a pointer to that * representation. * - * The typedef for the deserialize callback is as follows: + * The typedef for the deserialize callback is as follows: * - * typedef void *(*H5C_deserialize_func_t)(const void * image_ptr, - * size_t len, + * typedef void *(*H5C_deserialize_func_t)(const void * image_ptr, + * size_t len, * void * udata_ptr, * boolean * dirty_ptr); * - * The parameters of the deserialize callback are as follows: + * The parameters of the deserialize callback are as follows: * - * image_ptr: Pointer to a buffer of length len containing the - * contents of the file starting at addr and continuing - * for len bytes. + * image_ptr: Pointer to a buffer of length len containing the + * contents of the file starting at addr and continuing + * for len bytes. * - * len: Length in bytes of the in file image to be deserialized. + * len: Length in bytes of the in file image to be deserialized. * * This parameter is supplied mainly for sanity checking. * Sanity checks should be performed when compiled in debug * mode, but the parameter may be unused when compiled in * production mode. * - * udata_ptr: Pointer to user data provided in the protect call, which - * must be passed through to the deserialize callback. + * udata_ptr: Pointer to user data provided in the protect call, which + * must be passed through to the deserialize callback. * * dirty_ptr: Pointer to boolean which the deserialize function - * must use to mark the entry dirty if it has to modify - * the entry to clean up file corruption left over from - * an old bug in the HDF5 library. + * must use to mark the entry dirty if it has to modify + * the entry to clean up file corruption left over from + * an old bug in the HDF5 library. * - * Processing in the deserialize function should proceed as follows: + * Processing in the deserialize function should proceed as follows: * * If the image contains valid data, and is of the correct length, * the deserialize function must allocate space for an in-core @@ -501,7 +500,7 @@ typedef struct H5C_t H5C_t; * * IMAGE_LEN: Pointer to the image length callback. * - * The image_len callback is used to obtain the size of newly inserted + * The image_len callback is used to obtain the size of newly inserted * entries and assert verification. * * The typedef for the image_len callback is as follows: @@ -509,58 +508,58 @@ typedef struct H5C_t H5C_t; * typedef herr_t (*H5C_image_len_func_t)(void *thing, * size_t *image_len_ptr); * - * The parameters of the image_len callback are as follows: + * The parameters of the image_len callback are as follows: * - * thing: Pointer to the in core representation of the entry. + * thing: Pointer to the in core representation of the entry. * - * image_len_ptr: Pointer to size_t in which the callback will return - * the length (in bytes) of the cache entry. + * image_len_ptr: Pointer to size_t in which the callback will return + * the length (in bytes) of the cache entry. * - * Processing in the image_len function should proceed as follows: + * Processing in the image_len function should proceed as follows: * - * If successful, the function will place the length of the on disk - * image associated with the in core representation provided in the - * thing parameter in *image_len_ptr, and then return SUCCEED. + * If successful, the function will place the length of the on disk + * image associated with the in core representation provided in the + * thing parameter in *image_len_ptr, and then return SUCCEED. * - * If the function fails, it must return FAIL and push error information + * If the function fails, it must return FAIL and push error information * onto the error stack with the error API routines, and return without * modifying the values pointed to by the image_len_ptr parameter. * * * PRE_SERIALIZE: Pointer to the pre-serialize callback. * - * The pre-serialize callback is invoked by the metadata cache before - * it needs a current on-disk image of the metadata entry for purposes - * either constructing a journal or flushing the entry to disk. - * - * If the client needs to change the address or length of the entry prior - * to flush, the pre-serialize callback is responsible for these actions, - * so that the actual serialize callback (described below) is only - * responsible for serializing the data structure, not moving it on disk - * or resizing it. - * - * In addition, the client may use the pre-serialize callback to - * 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 - * contain no invalid data. - * - * One would think that the base address and length of - * the length of the entry's image on disk would be well known. - * However, that need not be the case as free space section info - * entries will change size (and possibly location) depending on the - * number of blocks of free space being manages, and fractal heap - * direct blocks can change compressed size (and possibly location) - * on serialization if compression is enabled. Similarly, it may - * be necessary to move entries from temporary to real file space. - * - * The pre-serialize callback must report any such changes to the - * cache, which must then update its internal structures as needed. - * - * The typedef for the pre-serialize callback is as follows: - * - * typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, + * The pre-serialize callback is invoked by the metadata cache before + * it needs a current on-disk image of the metadata entry for purposes + * either constructing a journal or flushing the entry to disk. + * + * If the client needs to change the address or length of the entry prior + * to flush, the pre-serialize callback is responsible for these actions, + * so that the actual serialize callback (described below) is only + * responsible for serializing the data structure, not moving it on disk + * or resizing it. + * + * In addition, the client may use the pre-serialize callback to + * 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 + * contain no invalid data. + * + * One would think that the base address and length of + * the length of the entry's image on disk would be well known. + * However, that need not be the case as free space section info + * entries will change size (and possibly location) depending on the + * number of blocks of free space being manages, and fractal heap + * direct blocks can change compressed size (and possibly location) + * on serialization if compression is enabled. Similarly, it may + * be necessary to move entries from temporary to real file space. + * + * The pre-serialize callback must report any such changes to the + * cache, which must then update its internal structures as needed. + * + * The typedef for the pre-serialize callback is as follows: + * + * typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, * void * thing, * haddr_t addr, * size_t len, @@ -568,154 +567,154 @@ typedef struct H5C_t H5C_t; * size_t * new_len_ptr, * unsigned * flags_ptr); * - * The parameters of the pre-serialize callback are as follows: + * The parameters of the pre-serialize callback are as follows: * - * f: File pointer -- needed if other metadata cache entries - * must be modified in the process of serializing the - * target entry. + * f: File pointer -- needed if other metadata cache entries + * must be modified in the process of serializing the + * target entry. * - * thing: Pointer to void containing the address of the in core - * representation of the target metadata cache entry. - * This is the same pointer returned by a protect of the - * addr and len given above. + * thing: Pointer to void containing the address of the in core + * representation of the target metadata cache entry. + * This is the same pointer returned by a protect of the + * addr and len given above. * - * addr: Base address in file of the entry to be serialized. + * addr: Base address in file of the entry to be serialized. * - * This parameter is supplied mainly for sanity checking. - * Sanity checks should be performed when compiled in debug - * mode, but the parameter may be unused when compiled in - * production mode. + * This parameter is supplied mainly for sanity checking. + * Sanity checks should be performed when compiled in debug + * mode, but the parameter may be unused when compiled in + * production mode. * - * len: Length in bytes of the in file image of the entry to be - * serialized. Also the size the image passed to the - * serialize callback (discussed below) unless that - * value is altered by this function. + * len: Length in bytes of the in file image of the entry to be + * serialized. Also the size the image passed to the + * serialize callback (discussed below) unless that + * value is altered by this function. * - * This parameter is supplied mainly for sanity checking. - * Sanity checks should be performed when compiled in debug - * mode, but the parameter may be unused when compiled in - * production mode. + * This parameter is supplied mainly for sanity checking. + * Sanity checks should be performed when compiled in debug + * mode, but the parameter may be unused when compiled in + * production mode. * - * new_addr_ptr: Pointer to haddr_t. If the entry is moved by - * the serialize function, the new on disk base address must - * be stored in *new_addr_ptr, and the appropriate flag set - * in *flags_ptr. + * new_addr_ptr: Pointer to haddr_t. If the entry is moved by + * the serialize function, the new on disk base address must + * be stored in *new_addr_ptr, and the appropriate flag set + * in *flags_ptr. * - * If the entry is not moved by the serialize function, - * *new_addr_ptr is undefined on pre-serialize callback - * return. + * If the entry is not moved by the serialize function, + * *new_addr_ptr is undefined on pre-serialize callback + * return. * - * new_len_ptr: Pointer to size_t. If the entry is resized by the - * serialize function, the new length of the on disk image - * must be stored in *new_len_ptr, and the appropriate flag set + * new_len_ptr: Pointer to size_t. If the entry is resized by the + * serialize function, the new length of the on disk image + * must be stored in *new_len_ptr, and the appropriate flag set * in *flags_ptr. * - * If the entry is not resized by the pre-serialize function, - * *new_len_ptr is undefined on pre-serialize callback - * return. + * If the entry is not resized by the pre-serialize function, + * *new_len_ptr is undefined on pre-serialize callback + * return. * - * flags_ptr: Pointer to an unsigned integer used to return flags - * indicating whether the preserialize function resized or moved - * the entry. If the entry was neither resized or moved, the + * flags_ptr: Pointer to an unsigned integer used to return flags + * indicating whether the preserialize function resized or moved + * the entry. If the entry was neither resized or moved, the * serialize function must set *flags_ptr to zero. The * H5C__SERIALIZE_RESIZED_FLAG or H5C__SERIALIZE_MOVED_FLAG must * be set to indicate a resize or move respectively. * - * If the H5C__SERIALIZE_RESIZED_FLAG is set, the new length - * must be stored in *new_len_ptr. + * If the H5C__SERIALIZE_RESIZED_FLAG is set, the new length + * must be stored in *new_len_ptr. * - * If the H5C__SERIALIZE_MOVED_FLAG flag is set, the - * new image base address must be stored in *new_addr_ptr. + * If the H5C__SERIALIZE_MOVED_FLAG flag is set, the + * new image base address must be stored in *new_addr_ptr. * - * Processing in the pre-serialize function should proceed as follows: + * Processing in the pre-serialize function should proceed as follows: * - * The pre-serialize function must examine the in core representation - * indicated by the thing parameter, if the pre-serialize function does + * The pre-serialize function must examine the in core representation + * indicated by the thing parameter, if the pre-serialize function does * not need to change the size or location of the on-disk image, it must * set *flags_ptr to zero. * - * If the size of the on-disk image must be changed, the pre-serialize + * If the size of the on-disk image must be changed, the pre-serialize * function must load the length of the new image into *new_len_ptr, and * set the H5C__SERIALIZE_RESIZED_FLAG in *flags_ptr. * - * If the base address of the on disk image must be changed, the + * If the base address of the on disk image must be changed, the * pre-serialize function must set *new_addr_ptr to the new base address, * and set the H5C__SERIALIZE_MOVED_FLAG in *flags_ptr. * - * In addition, the pre-serialize callback may perform any other - * processing required before the entry is written to disk + * In addition, the pre-serialize callback may perform any other + * processing required before the entry is written to disk * - * If it is successful, the function must return SUCCEED. + * If it is successful, the function must return SUCCEED. * - * If it fails for any reason, the function must return FAIL and - * push error information on the error stack with the error API - * routines. + * If it fails for any reason, the function must return FAIL and + * push error information on the error stack with the error API + * routines. * * * SERIALIZE: Pointer to the serialize callback. * - * The serialize callback is invoked by the metadata cache whenever - * it needs a current on disk image of the metadata entry for purposes - * either constructing a journal entry or flushing the entry to disk. + * The serialize callback is invoked by the metadata cache whenever + * it needs a current on disk image of the metadata entry for purposes + * either constructing a journal entry or flushing the entry to disk. * - * At this point, the base address and length of the entry's image on + * At this point, the base address and length of the entry's image on * disk must be well known and not change during the serialization * process. * - * While any size and/or location changes must have been handled - * by a pre-serialize call, the client may elect to handle any other - * changes to the entry required to place it in correct form for - * writing to disk in this call. + * While any size and/or location changes must have been handled + * by a pre-serialize call, the client may elect to handle any other + * changes to the entry required to place it in correct form for + * writing to disk in this call. * - * The typedef for the serialize callback is as follows: + * The typedef for the serialize callback is as follows: * - * typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, + * typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, * void * image_ptr, * size_t len, * void * thing); * - * The parameters of the serialize callback are as follows: + * The parameters of the serialize callback are as follows: * - * f: File pointer -- needed if other metadata cache entries - * must be modified in the process of serializing the - * target entry. + * f: File pointer -- needed if other metadata cache entries + * must be modified in the process of serializing the + * target entry. * - * image_ptr: Pointer to a buffer of length len bytes into which a - * serialized image of the target metadata cache entry is - * to be written. + * image_ptr: Pointer to a buffer of length len bytes into which a + * serialized image of the target metadata cache entry is + * to be written. * - * Note that this buffer will not in general be initialized - * to any particular value. Thus the serialize function may - * not assume any initial value and must set each byte in - * the buffer. + * Note that this buffer will not in general be initialized + * to any particular value. Thus the serialize function may + * not assume any initial value and must set each byte in + * the buffer. * - * len: Length in bytes of the in file image of the entry to be - * serialized. Also the size of *image_ptr (below). + * len: Length in bytes of the in file image of the entry to be + * serialized. Also the size of *image_ptr (below). * - * This parameter is supplied mainly for sanity checking. - * Sanity checks should be performed when compiled in debug - * mode, but the parameter may be unused when compiled in - * production mode. + * This parameter is supplied mainly for sanity checking. + * Sanity checks should be performed when compiled in debug + * mode, but the parameter may be unused when compiled in + * production mode. * - * thing: Pointer to void containing the address of the in core - * representation of the target metadata cache entry. - * This is the same pointer returned by a protect of the - * addr and len given above. + * thing: Pointer to void containing the address of the in core + * representation of the target metadata cache entry. + * This is the same pointer returned by a protect of the + * addr and len given above. * - * Processing in the serialize function should proceed as follows: + * Processing in the serialize function should proceed as follows: * - * If there are any remaining changes to the entry required before - * write to disk, they must be dealt with first. + * If there are any remaining changes to the entry required before + * write to disk, they must be dealt with first. * - * The serialize function must then examine the in core - * representation indicated by the thing parameter, and write a - * serialized image of its contents into the provided buffer. + * The serialize function must then examine the in core + * representation indicated by the thing parameter, and write a + * serialized image of its contents into the provided buffer. * - * If it is successful, the function must return SUCCEED. + * If it is successful, the function must return SUCCEED. * - * If it fails for any reason, the function must return FAIL and - * push error information on the error stack with the error API - * routines. + * If it fails for any reason, the function must return FAIL and + * push error information on the error stack with the error API + * routines. * * * NOTIFY: Pointer to the notify callback. @@ -724,98 +723,98 @@ typedef struct H5C_t H5C_t; * action on an entry has taken/will take place and the client indicates * it wishes to be notified about the action. * - * The typedef for the notify callback is as follows: + * The typedef for the notify callback is as follows: * - * typedef herr_t (*H5C_notify_func_t)(H5C_notify_action_t action, + * typedef herr_t (*H5C_notify_func_t)(H5C_notify_action_t action, * void *thing); * - * The parameters of the notify callback are as follows: + * The parameters of the notify callback are as follows: * - * action: An enum indicating the metadata cache action that has taken/ + * action: An enum indicating the metadata cache action that has taken/ * will take place. * - * thing: Pointer to void containing the address of the in core - * representation of the target metadata cache entry. This - * is the same pointer that would be returned by a protect - * of the addr and len of the entry. + * thing: Pointer to void containing the address of the in core + * representation of the target metadata cache entry. This + * is the same pointer that would be returned by a protect + * of the addr and len of the entry. * - * Processing in the notify function should proceed as follows: + * Processing in the notify function should proceed as follows: * - * The notify function may perform any action it would like, including + * The notify function may perform any action it would like, including * metadata cache calls. * - * If the function is successful, it must return SUCCEED. + * If the function is successful, it must return SUCCEED. * - * If it fails for any reason, the function must return FAIL and - * push error information on the error stack with the error API - * routines. + * If it fails for any reason, the function must return FAIL and + * push error information on the error stack with the error API + * routines. * * * FREE_ICR: Pointer to the free ICR callback. * - * The free ICR callback is invoked by the metadata cache when it - * wishes to evict an entry, and needs the client to free the memory - * allocated for the in core representation. + * The free ICR callback is invoked by the metadata cache when it + * wishes to evict an entry, and needs the client to free the memory + * allocated for the in core representation. * - * The typedef for the free ICR callback is as follows: + * The typedef for the free ICR callback is as follows: * - * typedef herr_t (*H5C_free_icr_func_t)(void * thing)); + * typedef herr_t (*H5C_free_icr_func_t)(void * thing)); * - * The parameters of the free ICR callback are as follows: + * The parameters of the free ICR callback are as follows: * - * thing: Pointer to void containing the address of the in core - * representation of the target metadata cache entry. This - * is the same pointer that would be returned by a protect - * of the addr and len of the entry. + * thing: Pointer to void containing the address of the in core + * representation of the target metadata cache entry. This + * is the same pointer that would be returned by a protect + * of the addr and len of the entry. * - * Processing in the free ICR function should proceed as follows: + * Processing in the free ICR function should proceed as follows: * - * The free ICR function must free all memory allocated to the - * in core representation. + * The free ICR function must free all memory allocated to the + * in core representation. * - * If the function is successful, it must return SUCCEED. + * If the function is successful, it must return SUCCEED. * - * If it fails for any reason, the function must return FAIL and - * push error information on the error stack with the error API - * routines. + * If it fails for any reason, the function must return FAIL and + * push error information on the error stack with the error API + * routines. * - * At least when compiled with debug, it would be useful if the - * free ICR call would fail if the in core representation has been - * modified since the last serialize callback. + * At least when compiled with debug, it would be useful if the + * free ICR call would fail if the in core representation has been + * modified since the last serialize callback. * * GET_FSF_SIZE: Pointer to the get file space free size callback. * - * In principle, there is no need for the get file space free size - * callback. However, as an optimization, it is sometimes convenient - * to allocate and free file space for a number of cache entries - * simultaneously in a single contiguous block of file space. + * In principle, there is no need for the get file space free size + * callback. However, as an optimization, it is sometimes convenient + * to allocate and free file space for a number of cache entries + * simultaneously in a single contiguous block of file space. * - * File space allocation is done by the client, so the metadata cache - * need not be involved. However, since the metadata cache typically + * File space allocation is done by the client, so the metadata cache + * need not be involved. However, since the metadata cache typically * handles file space release when an entry is destroyed, some - * adjustment on the part of the metadata cache is required for this - * operation. + * adjustment on the part of the metadata cache is required for this + * operation. * * The get file space free size callback exists to support this - * operation. + * operation. * - * If a group of cache entries that were allocated as a group are to - * be discarded and their file space released, the type of the first - * (i.e. lowest address) entry in the group must implement the - * get free file space size callback. + * If a group of cache entries that were allocated as a group are to + * be discarded and their file space released, the type of the first + * (i.e. lowest address) entry in the group must implement the + * get free file space size callback. * - * To free the file space of all entries in the group in a single - * operation, first expunge all entries other than the first without - * the free file space flag. + * To free the file space of all entries in the group in a single + * operation, first expunge all entries other than the first without + * the free file space flag. * - * Then, to complete the operation, unprotect or expunge the first - * entry in the block with the free file space flag set. Since - * the get free file space callback is implemented, the metadata - * cache will use this callback to get the size of the block to be - * freed, instead of using the size of the entry as is done otherwise. + * Then, to complete the operation, unprotect or expunge the first + * entry in the block with the free file space flag set. Since + * the get free file space callback is implemented, the metadata + * cache will use this callback to get the size of the block to be + * freed, instead of using the size of the entry as is done otherwise. * - * At present this callback is used only by the H5FA and H5EA dblock - * and dblock page client classes. + * At present this callback is used only by the H5FA and H5EA dblock + * and dblock page client classes. * * The typedef for the get_fsf_size callback is as follows: * @@ -829,15 +828,15 @@ typedef struct H5C_t H5C_t; * is the same pointer that would be returned by a protect() * call of the associated addr and len. * - * fs_size_ptr: Pointer to hsize_t in which the callback will return + * fs_size_ptr: Pointer to hsize_t in which the callback will return * the size of the piece of file space to be freed. Note - * that the space to be freed is presumed to have the same - * base address as the cache entry. + * that the space to be freed is presumed to have the same + * base address as the cache entry. * * The function simply returns the size of the block of file space - * to be freed in *fsf_size_ptr. + * to be freed in *fsf_size_ptr. * - * If the function is successful, it must return SUCCEED. + * If the function is successful, it must return SUCCEED. * * If it fails for any reason, the function must return FAIL and * push error information on the error stack with the error API @@ -847,65 +846,62 @@ typedef struct H5C_t H5C_t; /* Actions that can be reported to 'notify' client callback */ typedef enum H5C_notify_action_t { - H5C_NOTIFY_ACTION_AFTER_INSERT, /* Entry has been added to the cache - * via the insert call - */ - H5C_NOTIFY_ACTION_AFTER_LOAD, /* Entry has been loaded into the - * from file via the protect call - */ - H5C_NOTIFY_ACTION_AFTER_FLUSH, /* Entry has just been flushed to - * file. - */ - H5C_NOTIFY_ACTION_BEFORE_EVICT, /* Entry is about to be evicted - * from cache. - */ - H5C_NOTIFY_ACTION_ENTRY_DIRTIED, /* Entry has been marked dirty. */ - H5C_NOTIFY_ACTION_ENTRY_CLEANED, /* Entry has been marked clean. */ - H5C_NOTIFY_ACTION_CHILD_DIRTIED, /* Dependent child has been marked dirty. */ - H5C_NOTIFY_ACTION_CHILD_CLEANED, /* Dependent child has been marked clean. */ + H5C_NOTIFY_ACTION_AFTER_INSERT, /* Entry has been added to the cache + * via the insert call + */ + H5C_NOTIFY_ACTION_AFTER_LOAD, /* Entry has been loaded into the + * from file via the protect call + */ + H5C_NOTIFY_ACTION_AFTER_FLUSH, /* Entry has just been flushed to + * file. + */ + H5C_NOTIFY_ACTION_BEFORE_EVICT, /* Entry is about to be evicted + * from cache. + */ + H5C_NOTIFY_ACTION_ENTRY_DIRTIED, /* Entry has been marked dirty. */ + H5C_NOTIFY_ACTION_ENTRY_CLEANED, /* Entry has been marked clean. */ + H5C_NOTIFY_ACTION_CHILD_DIRTIED, /* Dependent child has been marked dirty. */ + H5C_NOTIFY_ACTION_CHILD_CLEANED, /* Dependent child has been marked clean. */ H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, /* Dependent child has been marked unserialized. */ - H5C_NOTIFY_ACTION_CHILD_SERIALIZED /* Dependent child has been marked serialized. */ + H5C_NOTIFY_ACTION_CHILD_SERIALIZED /* Dependent child has been marked serialized. */ } H5C_notify_action_t; /* Cache client callback function pointers */ typedef herr_t (*H5C_get_initial_load_size_func_t)(void *udata_ptr, size_t *image_len_ptr); -typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, - size_t image_len, void *udata_ptr, size_t *actual_len_ptr); +typedef herr_t (*H5C_get_final_load_size_func_t)(const void *image_ptr, size_t image_len, void *udata_ptr, + size_t *actual_len_ptr); typedef htri_t (*H5C_verify_chksum_func_t)(const void *image_ptr, size_t len, void *udata_ptr); -typedef void *(*H5C_deserialize_func_t)(const void *image_ptr, - size_t len, void *udata_ptr, hbool_t *dirty_ptr); +typedef void *(*H5C_deserialize_func_t)(const void *image_ptr, size_t len, void *udata_ptr, + hbool_t *dirty_ptr); typedef herr_t (*H5C_image_len_func_t)(const void *thing, size_t *image_len_ptr); -typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, void *thing, haddr_t addr, - size_t len, haddr_t *new_addr_ptr, size_t *new_len_ptr, unsigned *flags_ptr); -typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, void *image_ptr, - size_t len, void *thing); +typedef herr_t (*H5C_pre_serialize_func_t)(H5F_t *f, void *thing, haddr_t addr, size_t len, + haddr_t *new_addr_ptr, size_t *new_len_ptr, unsigned *flags_ptr); +typedef herr_t (*H5C_serialize_func_t)(const H5F_t *f, void *image_ptr, size_t len, void *thing); typedef herr_t (*H5C_notify_func_t)(H5C_notify_action_t action, void *thing); typedef herr_t (*H5C_free_icr_func_t)(void *thing); -typedef herr_t (*H5C_get_fsf_size_t)(const void * thing, hsize_t *fsf_size_ptr); +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; - H5FD_mem_t mem_type; - unsigned flags; - H5C_get_initial_load_size_func_t get_initial_load_size; - H5C_get_final_load_size_func_t get_final_load_size; - H5C_verify_chksum_func_t verify_chksum; - H5C_deserialize_func_t deserialize; - H5C_image_len_func_t image_len; - H5C_pre_serialize_func_t pre_serialize; - H5C_serialize_func_t serialize; - H5C_notify_func_t notify; - H5C_free_icr_func_t free_icr; - H5C_get_fsf_size_t fsf_size; + int id; + const char * name; + H5FD_mem_t mem_type; + unsigned flags; + H5C_get_initial_load_size_func_t get_initial_load_size; + H5C_get_final_load_size_func_t get_final_load_size; + H5C_verify_chksum_func_t verify_chksum; + H5C_deserialize_func_t deserialize; + H5C_image_len_func_t image_len; + H5C_pre_serialize_func_t pre_serialize; + H5C_serialize_func_t serialize; + H5C_notify_func_t notify; + H5C_free_icr_func_t free_icr; + H5C_get_fsf_size_t fsf_size; } H5C_class_t; /* Type definitions of callback functions used by the cache as a whole */ -typedef herr_t (*H5C_write_permitted_func_t)(const H5F_t *f, - hbool_t *write_permitted_ptr); -typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, - hbool_t was_dirty, unsigned flags); +typedef herr_t (*H5C_write_permitted_func_t)(const H5F_t *f, hbool_t *write_permitted_ptr); +typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags); /**************************************************************************** * @@ -953,17 +949,16 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, * debugging. */ -#define H5C_RING_UNDEFINED 0 /* shouldn't appear in the cache */ -#define H5C_RING_USER 1 /* outermost ring */ -#define H5C_RING_RDFSM 2 -#define H5C_RING_MDFSM 3 -#define H5C_RING_SBE 4 -#define H5C_RING_SB 5 /* innermost ring */ -#define H5C_RING_NTYPES 6 +#define H5C_RING_UNDEFINED 0 /* shouldn't appear in the cache */ +#define H5C_RING_USER 1 /* outermost ring */ +#define H5C_RING_RDFSM 2 +#define H5C_RING_MDFSM 3 +#define H5C_RING_SBE 4 +#define H5C_RING_SB 5 /* innermost ring */ +#define H5C_RING_NTYPES 6 typedef int H5C_ring_t; - /**************************************************************************** * * structure H5C_cache_entry_t @@ -980,9 +975,9 @@ typedef int H5C_ring_t; * * The fields of this structure are discussed individually below: * - * JRM - 4/26/04 + * JRM - 4/26/04 * - * magic: Unsigned 32 bit integer that must always be set to + * magic: Unsigned 32 bit integer that must always be set to * H5C__H5C_CACHE_ENTRY_T_MAGIC when the entry is valid. * The field must be set to H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC * just before the entry is freed. @@ -1001,129 +996,129 @@ typedef int H5C_ring_t; * detect this case, and re-start its scan from the bottom * of the LRU when this situation occurs. * - * cache_ptr: Pointer to the cache that this entry is contained within. + * cache_ptr: Pointer to the cache that this entry is contained within. * - * addr: Base address of the cache entry on disk. + * addr: Base address of the cache entry on disk. * - * size: Length of the cache entry on disk in bytes Note that unlike + * size: Length of the cache entry on disk in bytes Note that unlike * normal caches, the entries in this cache are of arbitrary size. * - * The file space allocations for cache entries implied by the + * The file space allocations for cache entries implied by the * addr and size fields must be disjoint. * - * image_ptr: Pointer to void. When not NULL, this field points to a - * dynamically allocated block of size bytes in which the - * on disk image of the metadata cache entry is stored. + * image_ptr: Pointer to void. When not NULL, this field points to a + * dynamically allocated block of size bytes in which the + * on disk image of the metadata cache entry is stored. * - * If the entry is dirty, the pre-serialize and serialize - * callbacks must be used to update this image before it is - * written to disk + * If the entry is dirty, the pre-serialize and serialize + * callbacks must be used to update this image before it is + * written to disk * * image_up_to_date: Boolean flag that is set to TRUE when *image_ptr - * is up to date, and set to false when the entry is dirtied. + * is up to date, and set to false when the entry is dirtied. * - * type: Pointer to the instance of H5C_class_t containing pointers - * to the methods for cache entries of the current type. This - * field should be NULL when the instance of H5C_cache_entry_t - * is not in use. + * type: Pointer to the instance of H5C_class_t containing pointers + * to the methods for cache entries of the current type. This + * field should be NULL when the instance of H5C_cache_entry_t + * is not in use. * - * The name is not particularly descriptive, but is retained - * to avoid changes in existing code. + * The name is not particularly descriptive, but is retained + * to avoid changes in existing code. * - * is_dirty: Boolean flag indicating whether the contents of the cache - * entry has been modified since the last time it was written - * to disk. + * is_dirty: Boolean flag indicating whether the contents of the cache + * entry has been modified since the last time it was written + * to disk. * - * dirtied: Boolean flag used to indicate that the entry has been - * dirtied while protected. + * dirtied: Boolean flag used to indicate that the entry has been + * dirtied while protected. * - * This field is set to FALSE in the protect call, and may - * be set to TRUE by the H5C_mark_entry_dirty() call at any - * time prior to the unprotect call. + * This field is set to FALSE in the protect call, and may + * be set to TRUE by the H5C_mark_entry_dirty() call at any + * time prior to the unprotect call. * - * The H5C_mark_entry_dirty() call exists as a convenience - * function for the fractal heap code which may not know if - * an entry is protected or pinned, but knows that is either - * protected or pinned. The dirtied field was added as in - * the parallel case, it is necessary to know whether a - * protected entry is dirty prior to the protect call. + * The H5C_mark_entry_dirty() call exists as a convenience + * function for the fractal heap code which may not know if + * an entry is protected or pinned, but knows that is either + * protected or pinned. The dirtied field was added as in + * the parallel case, it is necessary to know whether a + * protected entry is dirty prior to the protect call. * * is_protected: Boolean flag indicating whether this entry is protected - * (or locked, to use more conventional terms). When it is - * protected, the entry cannot be flushed or accessed until - * it is unprotected (or unlocked -- again to use more - * conventional terms). + * (or locked, to use more conventional terms). When it is + * protected, the entry cannot be flushed or accessed until + * it is unprotected (or unlocked -- again to use more + * conventional terms). * - * Note that protected entries are removed from the LRU lists - * and inserted on the protected list. + * Note that protected entries are removed from the LRU lists + * and inserted on the protected list. * * is_read_only: Boolean flag that is only meaningful if is_protected is - * TRUE. In this circumstance, it indicates whether the - * entry has been protected read-only, or read/write. + * TRUE. In this circumstance, it indicates whether the + * entry has been protected read-only, or read/write. * - * If the entry has been protected read-only (i.e. is_protected - * and is_read_only are both TRUE), we allow the entry to be - * protected more than once. + * If the entry has been protected read-only (i.e. is_protected + * and is_read_only are both TRUE), we allow the entry to be + * protected more than once. * - * In this case, the number of readers is maintained in the - * ro_ref_count field (see below), and unprotect calls simply - * decrement that field until it drops to zero, at which point - * the entry is actually unprotected. + * In this case, the number of readers is maintained in the + * ro_ref_count field (see below), and unprotect calls simply + * decrement that field until it drops to zero, at which point + * the entry is actually unprotected. * * ro_ref_count: Integer field used to maintain a count of the number of - * outstanding read-only protects on this entry. This field - * must be zero whenever either is_protected or is_read_only - * are TRUE. + * outstanding read-only protects on this entry. This field + * must be zero whenever either is_protected or is_read_only + * are TRUE. * - * is_pinned: Boolean flag indicating whether the entry has been pinned - * in the cache. + * is_pinned: Boolean flag indicating whether the entry has been pinned + * in the cache. * - * For very hot entries, the protect / unprotect overhead - * can become excessive. Thus the cache has been extended - * to allow an entry to be "pinned" in the cache. + * For very hot entries, the protect / unprotect overhead + * can become excessive. Thus the cache has been extended + * to allow an entry to be "pinned" in the cache. * - * Pinning an entry in the cache has several implications: + * Pinning an entry in the cache has several implications: * - * 1) A pinned entry cannot be evicted. Thus unprotected - * pinned entries must be stored in the pinned entry - * list, instead of being managed by the replacement - * policy code (LRU at present). + * 1) A pinned entry cannot be evicted. Thus unprotected + * pinned entries must be stored in the pinned entry + * list, instead of being managed by the replacement + * policy code (LRU at present). * - * 2) A pinned entry can be accessed or modified at any time. - * This places an extra burden on the pre-serialize and - * serialize callbacks, which must ensure that a pinned - * entry is consistent and ready to write to disk before - * generating an image. + * 2) A pinned entry can be accessed or modified at any time. + * This places an extra burden on the pre-serialize and + * serialize callbacks, which must ensure that a pinned + * entry is consistent and ready to write to disk before + * generating an image. * - * 3) A pinned entry can be marked as dirty (and possibly - * change size) while it is unprotected. + * 3) A pinned entry can be marked as dirty (and possibly + * change size) while it is unprotected. * - * 4) The flush-destroy code must allow pinned entries to - * be unpinned (and possibly unprotected) during the - * flush. + * 4) The flush-destroy code must allow pinned entries to + * be unpinned (and possibly unprotected) during the + * flush. * - * JRM -- 3/16/06 + * JRM -- 3/16/06 * - * in_slist: Boolean flag indicating whether the entry is in the skip list - * As a general rule, entries are placed in the list when they + * in_slist: Boolean flag indicating whether the entry is in the skip list + * As a general rule, entries are placed in the list when they * are marked dirty. However they may remain in the list after * being flushed. * * Update: Dirty entries are now removed from the skip list - * when they are flushed. + * when they are flushed. * * flush_marker: Boolean flag indicating that the entry is to be flushed - * the next time H5C_flush_cache() is called with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. The flag is reset when - * the entry is flushed for whatever reason. + * the next time H5C_flush_cache() is called with the + * H5C__FLUSH_MARKED_ENTRIES_FLAG. The flag is reset when + * the entry is flushed for whatever reason. * * flush_me_last: Boolean flag indicating that this entry should not be - * flushed from the cache until all other entries without + * flushed from the cache until all other entries without * the flush_me_last flag set have been flushed. * - * Note: + * Note: * - * At this time, the flush_me_last + * At this time, the flush_me_last * flag will only be applied to one entry, the superblock, * and the code utilizing these flags is protected with HDasserts * to enforce this. This restraint can certainly be relaxed in @@ -1132,37 +1127,37 @@ typedef int H5C_ring_t; * will need to be expanded and tested appropriately if that * functionality is desired. * - * Update: There are now two possible last entries - * (superblock and file driver info message). This - * number will probably increase as we add superblock - * messages. JRM -- 11/18/14 + * Update: There are now two possible last entries + * (superblock and file driver info message). This + * number will probably increase as we add superblock + * messages. JRM -- 11/18/14 * * clear_on_unprotect: Boolean flag used only in PHDF5. When H5C is used - * to implement the metadata cache In the parallel case, only - * the cache with mpi rank 0 is allowed to actually write to - * file -- all other caches must retain dirty entries until they - * are advised that the entry is clean. + * to implement the metadata cache In the parallel case, only + * the cache with mpi rank 0 is allowed to actually write to + * file -- all other caches must retain dirty entries until they + * are advised that the entry is clean. * - * This flag is used in the case that such an advisory is - * received when the entry is protected. If it is set when an - * entry is unprotected, and the dirtied flag is not set in - * the unprotect, the entry's is_dirty flag is reset by flushing - * it with the H5C__FLUSH_CLEAR_ONLY_FLAG. + * This flag is used in the case that such an advisory is + * received when the entry is protected. If it is set when an + * entry is unprotected, and the dirtied flag is not set in + * the unprotect, the entry's is_dirty flag is reset by flushing + * it with the H5C__FLUSH_CLEAR_ONLY_FLAG. * * flush_immediately: Boolean flag used only in Phdf5 -- and then only - * for H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED. + * for H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED. * - * When a distributed metadata write is triggered at a - * sync point, this field is used to mark entries that - * must be flushed before leaving the sync point. At all - * other times, this field should be set to FALSE. + * When a distributed metadata write is triggered at a + * sync point, this field is used to mark entries that + * must be flushed before leaving the sync point. At all + * other times, this field should be set to FALSE. * * flush_in_progress: Boolean flag that is set to true iff the entry - * is in the process of being flushed. This allows the cache - * to detect when a call is the result of a flush callback. + * is in the process of being flushed. This allows the cache + * to detect when a call is the result of a flush callback. * * destroy_in_progress: Boolean flag that is set to true iff the entry - * is in the process of being flushed and destroyed. + * is in the process of being flushed and destroyed. * * * Fields supporting rings for flush ordering: @@ -1180,8 +1175,8 @@ typedef int H5C_ring_t; * within rings. Unlike rings, flush dependencies are applied to ALL * writes, not just those triggered by flush or serialize calls. * - * ring: Instance of H5C_ring_t indicating the ring to which this - * entry is assigned. + * ring: Instance of H5C_ring_t indicating the ring to which this + * entry is assigned. * * * Fields supporting the 'flush dependency' feature: @@ -1211,18 +1206,18 @@ typedef int H5C_ring_t; * this field is nonzero, then this entry cannot be flushed. * * flush_dep_nunser_children: Number of flush dependency children - * that are either unserialized, or have a non-zero number of - * positive number of unserialized children. + * that are either unserialized, or have a non-zero number of + * positive number of unserialized children. * - * Note that since there is no requirement that a clean entry - * be serialized, it is possible that flush_dep_nunser_children - * to be greater than flush_dep_ndirty_children. + * Note that since there is no requirement that a clean entry + * be serialized, it is possible that flush_dep_nunser_children + * to be greater than flush_dep_ndirty_children. * - * This field exist to facilitate correct ordering of entry - * serializations when it is necessary to serialize all the - * entries in the metadata cache. Thus in the cache - * serialization, no entry can be serialized unless this - * field contains 0. + * This field exist to facilitate correct ordering of entry + * serializations when it is necessary to serialize all the + * entries in the metadata cache. Thus in the cache + * serialization, no entry can be serialized unless this + * field contains 0. * * Fields supporting the hash table: * @@ -1239,25 +1234,25 @@ typedef int H5C_ring_t; * The il_next and il_prev fields discussed below were added to support * the index list. * - * ht_next: Next pointer used by the hash table to store multiple - * entries in a single hash bin. This field points to the - * next entry in the doubly linked list of entries in the - * hash bin, or NULL if there is no next entry. + * ht_next: Next pointer used by the hash table to store multiple + * entries in a single hash bin. This field points to the + * next entry in the doubly linked list of entries in the + * hash bin, or NULL if there is no next entry. * * ht_prev: Prev pointer used by the hash table to store multiple * entries in a single hash bin. This field points to the * previous entry in the doubly linked list of entries in - * the hash bin, or NULL if there is no previuos entry. + * the hash bin, or NULL if there is no previuos entry. * - * il_next: Next pointer used by the index to maintain a doubly linked - * list of all entries in the index (and thus in the cache). - * This field contains a pointer to the next entry in the - * index list, or NULL if there is no next entry. + * il_next: Next pointer used by the index to maintain a doubly linked + * list of all entries in the index (and thus in the cache). + * This field contains a pointer to the next entry in the + * index list, or NULL if there is no next entry. * - * il_prev: Prev pointer used by the index to maintain a doubly linked - * list of all entries in the index (and thus in the cache). - * This field contains a pointer to the previous entry in the - * index list, or NULL if there is no previous entry. + * il_prev: Prev pointer used by the index to maintain a doubly linked + * list of all entries in the index (and thus in the cache). + * This field contains a pointer to the previous entry in the + * index list, or NULL if there is no previous entry. * * * Fields supporting replacement policies: @@ -1294,43 +1289,43 @@ typedef int H5C_ring_t; * The use of the replacement policy fields under the Modified LRU policy * is discussed below: * - * next: Next pointer in either the LRU, the protected list, or - * the pinned list depending on the current values of - * is_protected and is_pinned. If there is no next entry - * on the list, this field should be set to NULL. + * next: Next pointer in either the LRU, the protected list, or + * the pinned list depending on the current values of + * is_protected and is_pinned. If there is no next entry + * on the list, this field should be set to NULL. * - * prev: Prev pointer in either the LRU, the protected list, - * or the pinned list depending on the current values of - * is_protected and is_pinned. If there is no previous - * entry on the list, this field should be set to NULL. + * prev: Prev pointer in either the LRU, the protected list, + * or the pinned list depending on the current values of + * is_protected and is_pinned. If there is no previous + * entry on the list, this field should be set to NULL. * - * aux_next: Next pointer on either the clean or dirty LRU lists. - * This entry should be NULL when either is_protected or - * is_pinned is true. + * aux_next: Next pointer on either the clean or dirty LRU lists. + * This entry should be NULL when either is_protected or + * is_pinned is true. * - * When is_protected and is_pinned are false, and is_dirty is - * true, it should point to the next item on the dirty LRU - * list. + * When is_protected and is_pinned are false, and is_dirty is + * true, it should point to the next item on the dirty LRU + * list. * - * When is_protected and is_pinned are false, and is_dirty is - * false, it should point to the next item on the clean LRU - * list. In either case, when there is no next item, it - * should be NULL. + * When is_protected and is_pinned are false, and is_dirty is + * false, it should point to the next item on the clean LRU + * list. In either case, when there is no next item, it + * should be NULL. * - * aux_prev: Previous pointer on either the clean or dirty LRU lists. - * This entry should be NULL when either is_protected or - * is_pinned is true. + * aux_prev: Previous pointer on either the clean or dirty LRU lists. + * This entry should be NULL when either is_protected or + * is_pinned is true. * - * When is_protected and is_pinned are false, and is_dirty is - * true, it should point to the previous item on the dirty - * LRU list. + * When is_protected and is_pinned are false, and is_dirty is + * true, it should point to the previous item on the dirty + * LRU list. * - * When is_protected and is_pinned are false, and is_dirty - * is false, it should point to the previous item on the - * clean LRU list. + * When is_protected and is_pinned are false, and is_dirty + * is false, it should point to the previous item on the + * clean LRU list. * - * In either case, when there is no previous item, it should - * be NULL. + * In either case, when there is no previous item, it should + * be NULL. * * Fields supporting the cache image feature: * @@ -1346,170 +1341,170 @@ typedef int H5C_ring_t; * further details. * * include_in_image: Boolean flag indicating whether this entry should - * be included in the metadata cache image. This field should - * always be false prior to the H5C_prep_for_file_close() call. - * During that call, it should be set to TRUE for all entries - * that are to be included in the metadata cache image. At - * present, only the superblock, the superblock extension - * object header and its chunks (if any) are omitted from - * the image. + * be included in the metadata cache image. This field should + * always be false prior to the H5C_prep_for_file_close() call. + * During that call, it should be set to TRUE for all entries + * that are to be included in the metadata cache image. At + * present, only the superblock, the superblock extension + * object header and its chunks (if any) are omitted from + * the image. * - * lru_rank: Rank of the entry in the LRU just prior to file close. + * lru_rank: Rank of the entry in the LRU just prior to file close. * - * Note that the first entry on the LRU has lru_rank 1, - * and that entries not on the LRU at that time will have - * either lru_rank -1 (if pinned) or 0 (if loaded during - * the process of flushing the cache. + * Note that the first entry on the LRU has lru_rank 1, + * and that entries not on the LRU at that time will have + * either lru_rank -1 (if pinned) or 0 (if loaded during + * the process of flushing the cache. * * image_dirty: Boolean flag indicating whether the entry should be marked - * as dirty in the metadata cache image. The flag is set to - * TRUE iff the entry is dirty when H5C_prep_for_file_close() - * is called. + * as dirty in the metadata cache image. The flag is set to + * TRUE iff the entry is dirty when H5C_prep_for_file_close() + * is called. * * fd_parent_count: If the entry is a child in one or more flush dependency - * relationships, this field contains the number of flush - * dependency parents. + * relationships, this field contains the number of flush + * dependency parents. * - * In all other cases, the field is set to zero. + * In all other cases, the field is set to zero. * - * Note that while this count is initially taken from the - * flush dependency fields above, if the entry is in the - * cache image (i.e. include_in_image is TRUE), any parents - * that are not in the image are removed from this count and - * from the fd_parent_addrs array below. + * Note that while this count is initially taken from the + * flush dependency fields above, if the entry is in the + * cache image (i.e. include_in_image is TRUE), any parents + * that are not in the image are removed from this count and + * from the fd_parent_addrs array below. * - * Finally observe that if the entry is dirty and in the - * cache image, and its parent is dirty and not in the cache - * image, then the entry must be removed from the cache image - * to avoid violating the flush dependency flush ordering. + * Finally observe that if the entry is dirty and in the + * cache image, and its parent is dirty and not in the cache + * image, then the entry must be removed from the cache image + * to avoid violating the flush dependency flush ordering. * * fd_parent_addrs: If the entry is a child in one or more flush dependency - * relationship when H5C_prep_for_file_close() is called, this - * field must contain a pointer to an array of size - * fd_parent_count containing the on disk addresses of the - * parent. + * relationship when H5C_prep_for_file_close() is called, this + * field must contain a pointer to an array of size + * fd_parent_count containing the on disk addresses of the + * parent. * - * In all other cases, the field is set to NULL. + * In all other cases, the field is set to NULL. * - * Note that while this list of addresses is initially taken - * from the flush dependency fields above, if the entry is in the - * cache image (i.e. include_in_image is TRUE), any parents - * that are not in the image are removed from this list, and - * and from the fd_parent_count above. + * Note that while this list of addresses is initially taken + * from the flush dependency fields above, if the entry is in the + * cache image (i.e. include_in_image is TRUE), any parents + * that are not in the image are removed from this list, and + * and from the fd_parent_count above. * - * Finally observe that if the entry is dirty and in the - * cache image, and its parent is dirty and not in the cache - * image, then the entry must be removed from the cache image - * to avoid violating the flush dependency flush ordering. + * Finally observe that if the entry is dirty and in the + * cache image, and its parent is dirty and not in the cache + * image, then the entry must be removed from the cache image + * to avoid violating the flush dependency flush ordering. * * fd_child_count: If the entry is a parent in a flush dependency - * relationship, this field contains the number of flush - * dependency children. + * relationship, this field contains the number of flush + * dependency children. * - * In all other cases, the field is set to zero. + * In all other cases, the field is set to zero. * - * Note that while this count is initially taken from the - * flush dependency fields above, if the entry is in the - * cache image (i.e. include_in_image is TRUE), any children - * that are not in the image are removed from this count. + * Note that while this count is initially taken from the + * flush dependency fields above, if the entry is in the + * cache image (i.e. include_in_image is TRUE), any children + * that are not in the image are removed from this count. * * fd_dirty_child_count: If the entry is a parent in a flush dependency - * relationship, this field contains the number of dirty flush - * dependency children. + * relationship, this field contains the number of dirty flush + * dependency children. * - * In all other cases, the field is set to zero. + * In all other cases, the field is set to zero. * - * Note that while this count is initially taken from the - * flush dependency fields above, if the entry is in the - * cache image (i.e. include_in_image is TRUE), any dirty - * children that are not in the image are removed from this - * count. + * Note that while this count is initially taken from the + * flush dependency fields above, if the entry is in the + * cache image (i.e. include_in_image is TRUE), any dirty + * children that are not in the image are removed from this + * count. * * image_fd_height: Flush dependency height of the entry in the cache image. * - * The flush dependency height of any entry involved in a - * flush dependency relationship is defined to be the - * longest flush dependency path from that entry to an entry - * 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 - * 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. - * - * Note that if a child in a flush dependency relationship is - * dirty and in the cache image, and its parent is dirty and - * not in the cache image, then the child must be excluded - * from the cache image to maintain flush ordering. - * - * prefetched: Boolean flag indicating that the on disk image of the entry - * has been loaded into the cache prior any request for the - * entry by the rest of the library. - * - * As of this writing (8/10/15), this can only happen through - * the load of a cache image block, although other scenarios - * are contemplated for the use of this feature. Note that - * unlike the usual prefetch situation, this means that a - * prefetched entry can be dirty, and/or can be a party to - * flush dependency relationship(s). This complicates matters - * somewhat. - * - * The essential feature of a prefetched entry is that it - * consists only of a buffer containing the on disk image of - * the entry. Thus it must be deserialized before it can - * be passed back to the library on a protect call. This - * task is handled by H5C_deserialized_prefetched_entry(). - * In essence, this routine calls the deserialize callback - * provided in the protect call with the on disk image, - * deletes the prefetched entry from the cache, and replaces - * it with the deserialized entry returned by the deserialize - * callback. - * - * Further, if the prefetched entry is a flush dependency parent, - * all its flush dependency children (which must also be - * prefetched entries), must be transferred to the new cache - * entry returned by the deserialization callback. - * - * Finally, if the prefetched entry is a flush dependency child, - * this flush dependency must be destroyed prior to the - * deserialize call. - * - * In addition to the above special processing on the first - * protect call on a prefetched entry (after which is no longer - * a prefetched entry), prefetched entries also require special - * tretment on flush and evict. - * - * On flush, a dirty prefetched entry must simply be written - * to disk and marked clean without any call to any client - * callback. - * - * On eviction, if a prefetched entry is a flush dependency - * child, that flush dependency relationship must be destroyed - * just prior to the eviction. If the flush dependency code - * is working properly, it should be impossible for any entry - * that is a flush dependency parent to be evicted. + * The flush dependency height of any entry involved in a + * flush dependency relationship is defined to be the + * longest flush dependency path from that entry to an entry + * 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 + * 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. + * + * Note that if a child in a flush dependency relationship is + * dirty and in the cache image, and its parent is dirty and + * not in the cache image, then the child must be excluded + * from the cache image to maintain flush ordering. + * + * prefetched: Boolean flag indicating that the on disk image of the entry + * has been loaded into the cache prior any request for the + * entry by the rest of the library. + * + * As of this writing (8/10/15), this can only happen through + * the load of a cache image block, although other scenarios + * are contemplated for the use of this feature. Note that + * unlike the usual prefetch situation, this means that a + * prefetched entry can be dirty, and/or can be a party to + * flush dependency relationship(s). This complicates matters + * somewhat. + * + * The essential feature of a prefetched entry is that it + * consists only of a buffer containing the on disk image of + * the entry. Thus it must be deserialized before it can + * be passed back to the library on a protect call. This + * task is handled by H5C_deserialized_prefetched_entry(). + * In essence, this routine calls the deserialize callback + * provided in the protect call with the on disk image, + * deletes the prefetched entry from the cache, and replaces + * it with the deserialized entry returned by the deserialize + * callback. + * + * Further, if the prefetched entry is a flush dependency parent, + * all its flush dependency children (which must also be + * prefetched entries), must be transferred to the new cache + * entry returned by the deserialization callback. + * + * Finally, if the prefetched entry is a flush dependency child, + * this flush dependency must be destroyed prior to the + * deserialize call. + * + * In addition to the above special processing on the first + * protect call on a prefetched entry (after which is no longer + * a prefetched entry), prefetched entries also require special + * tretment on flush and evict. + * + * On flush, a dirty prefetched entry must simply be written + * to disk and marked clean without any call to any client + * callback. + * + * On eviction, if a prefetched entry is a flush dependency + * child, that flush dependency relationship must be destroyed + * just prior to the eviction. If the flush dependency code + * is working properly, it should be impossible for any entry + * that is a flush dependency parent to be evicted. * * prefetch_type_id: Integer field containing the type ID of the prefetched - * entry. This ID must match the ID of the type provided in any - * protect call on the prefetched entry. + * entry. This ID must match the ID of the type provided in any + * protect call on the prefetched entry. * - * The value of this field is undefined in prefetched is FALSE. + * The value of this field is undefined in prefetched is FALSE. * - * age: Number of times a prefetched entry has appeared in - * subsequent cache images. The field exists to allow - * imposition of a limit on how many times a prefetched - * entry can appear in subsequent cache images without being - * converted to a regular entry. + * age: Number of times a prefetched entry has appeared in + * subsequent cache images. The field exists to allow + * imposition of a limit on how many times a prefetched + * entry can appear in subsequent cache images without being + * converted to a regular entry. * - * This field must be zero if prefetched is FALSE. + * This field must be zero if prefetched is FALSE. * * prefetched_dirty: Boolean field that must be set to FALSE unless the - * following conditions hold: + * following conditions hold: * - * 1) The file has been opened R/O. + * 1) The file has been opened R/O. * - * 2) The entry is either a prefetched entry, or was + * 2) The entry is either a prefetched entry, or was * re-constructed from a prefetched entry. * * 3) The base prefetched entry was marked dirty. @@ -1545,14 +1540,14 @@ typedef int H5C_ring_t; * we deal with this by disabling EOC in the R/O case. * * serialization_count: Integer field used to maintain a count of the - * 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 - * a single cache serialization. + * 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 + * a single cache serialization. * - * This is a debugging field, and thus is maintained only if - * NDEBUG is undefined. + * This is a debugging field, and thus is maintained only if + * NDEBUG is undefined. * * Fields supporting tagged entries: * @@ -1563,15 +1558,15 @@ typedef int H5C_ring_t; * not tagged. Tagged entries have a pointer to the tag info for the object, * which is shared state for all the entries for that object. * - * tl_next: Pointer to the next entry in the tag list for an object. - * NULL for the tail entry in the list, as well as untagged - * entries. + * tl_next: Pointer to the next entry in the tag list for an object. + * NULL for the tail entry in the list, as well as untagged + * entries. * - * tl_prev: Pointer to the previous entry in the tag list for an object. - * NULL for the head entry in the list, as well as untagged - * entries. + * tl_prev: Pointer to the previous entry in the tag list for an object. + * NULL for the head entry in the list, as well as untagged + * entries. * - * tag_info: Pointer to the common tag state for all entries belonging to + * tag_info: Pointer to the common tag state for all entries belonging to * an object. NULL for untagged entries. * * @@ -1581,108 +1576,107 @@ typedef int H5C_ring_t; * and H5C_COLLECT_CACHE_ENTRY_STATS are true. When present, they allow * collection of statistics on individual cache entries. * - * accesses: int32_t containing the number of times this cache entry has - * been referenced in its lifetime. + * accesses: int32_t containing the number of times this cache entry has + * been referenced in its lifetime. * - * clears: int32_t containing the number of times this cache entry has - * been cleared in its life time. + * clears: int32_t containing the number of times this cache entry has + * been cleared in its life time. * - * flushes: int32_t containing the number of times this cache entry has - * been flushed to file in its life time. + * flushes: int32_t containing the number of times this cache entry has + * been flushed to file in its life time. * - * pins: int32_t containing the number of times this cache entry has - * been pinned in cache in its life time. + * pins: int32_t containing the number of times this cache entry has + * been pinned in cache in its life time. * ****************************************************************************/ typedef struct H5C_cache_entry_t { - uint32_t magic; - H5C_t *cache_ptr; - haddr_t addr; - size_t size; - void *image_ptr; - hbool_t image_up_to_date; - const H5C_class_t *type; - hbool_t is_dirty; - hbool_t dirtied; - hbool_t is_protected; - hbool_t is_read_only; - int ro_ref_count; - hbool_t is_pinned; - hbool_t in_slist; - hbool_t flush_marker; - hbool_t flush_me_last; + uint32_t magic; + H5C_t * cache_ptr; + haddr_t addr; + size_t size; + void * image_ptr; + hbool_t image_up_to_date; + const H5C_class_t *type; + hbool_t is_dirty; + hbool_t dirtied; + hbool_t is_protected; + hbool_t is_read_only; + int ro_ref_count; + hbool_t is_pinned; + hbool_t in_slist; + hbool_t flush_marker; + hbool_t flush_me_last; #ifdef H5_HAVE_PARALLEL - hbool_t clear_on_unprotect; - hbool_t flush_immediately; - hbool_t coll_access; + hbool_t clear_on_unprotect; + hbool_t flush_immediately; + hbool_t coll_access; #endif /* H5_HAVE_PARALLEL */ - hbool_t flush_in_progress; - hbool_t destroy_in_progress; + hbool_t flush_in_progress; + hbool_t destroy_in_progress; /* fields supporting rings for purposes of flush ordering */ - H5C_ring_t ring; + H5C_ring_t ring; /* fields supporting the 'flush dependency' feature: */ - struct H5C_cache_entry_t ** flush_dep_parent; - unsigned flush_dep_nparents; - unsigned flush_dep_parent_nalloc; - unsigned flush_dep_nchildren; - unsigned flush_dep_ndirty_children; - unsigned flush_dep_nunser_children; - hbool_t pinned_from_client; - hbool_t pinned_from_cache; + struct H5C_cache_entry_t **flush_dep_parent; + unsigned flush_dep_nparents; + unsigned flush_dep_parent_nalloc; + unsigned flush_dep_nchildren; + unsigned flush_dep_ndirty_children; + unsigned flush_dep_nunser_children; + hbool_t pinned_from_client; + hbool_t pinned_from_cache; /* fields supporting the hash table: */ - struct H5C_cache_entry_t *ht_next; - struct H5C_cache_entry_t *ht_prev; - struct H5C_cache_entry_t *il_next; - struct H5C_cache_entry_t *il_prev; + struct H5C_cache_entry_t *ht_next; + struct H5C_cache_entry_t *ht_prev; + struct H5C_cache_entry_t *il_next; + struct H5C_cache_entry_t *il_prev; /* fields supporting replacement policies: */ - struct H5C_cache_entry_t *next; - struct H5C_cache_entry_t *prev; + struct H5C_cache_entry_t *next; + struct H5C_cache_entry_t *prev; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - struct H5C_cache_entry_t *aux_next; - struct H5C_cache_entry_t *aux_prev; + struct H5C_cache_entry_t *aux_next; + struct H5C_cache_entry_t *aux_prev; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL - struct H5C_cache_entry_t *coll_next; - struct H5C_cache_entry_t *coll_prev; + struct H5C_cache_entry_t *coll_next; + struct H5C_cache_entry_t *coll_prev; #endif /* H5_HAVE_PARALLEL */ /* fields supporting cache image */ - hbool_t include_in_image; - int32_t lru_rank; - hbool_t image_dirty; - uint64_t fd_parent_count; - haddr_t *fd_parent_addrs; - uint64_t fd_child_count; - uint64_t fd_dirty_child_count; - uint32_t image_fd_height; - hbool_t prefetched; - int prefetch_type_id; - int32_t age; - hbool_t prefetched_dirty; - -#ifndef NDEBUG /* debugging field */ - int serialization_count; + hbool_t include_in_image; + int32_t lru_rank; + hbool_t image_dirty; + uint64_t fd_parent_count; + haddr_t *fd_parent_addrs; + uint64_t fd_child_count; + uint64_t fd_dirty_child_count; + uint32_t image_fd_height; + hbool_t prefetched; + int prefetch_type_id; + int32_t age; + hbool_t prefetched_dirty; + +#ifndef NDEBUG /* debugging field */ + int serialization_count; #endif /* NDEBUG */ /* 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_cache_entry_t *tl_next; + struct H5C_cache_entry_t *tl_prev; + struct H5C_tag_info_t * tag_info; #if H5C_COLLECT_CACHE_ENTRY_STATS /* cache entry stats fields */ - int32_t accesses; - int32_t clears; - int32_t flushes; - int32_t pins; + int32_t accesses; + int32_t clears; + int32_t flushes; + int32_t pins; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ } H5C_cache_entry_t; - /**************************************************************************** * * structure H5C_image_entry_t @@ -1694,43 +1688,43 @@ typedef struct H5C_cache_entry_t { * * The fields of this structure are discussed individually below: * - * JRM - 8/5/15 + * JRM - 8/5/15 * - * magic: Unsigned 32 bit integer that must always be set to + * magic: Unsigned 32 bit integer that must always be set to * H5C_IMAGE_ENTRY_T_MAGIC when the entry is valid. * The field must be set to H5C_IMAGE_ENTRY_T_BAD_MAGIC * just before the entry is freed. * - * addr: Base address of the cache entry on disk. + * addr: Base address of the cache entry on disk. * - * size: Length of the cache entry on disk in bytes. + * size: Length of the cache entry on disk in bytes. * - * ring: Instance of H5C_ring_t indicating the flush ordering ring - * to which this entry is assigned. + * ring: Instance of H5C_ring_t indicating the flush ordering ring + * to which this entry is assigned. * - * age: Number of times this prefetech entry has appeared in - * the current sequence of cache images. This field is - * initialized to 0 if the instance of H5C_image_entry_t - * is constructed from a regular entry. + * age: Number of times this prefetech entry has appeared in + * the current sequence of cache images. This field is + * initialized to 0 if the instance of H5C_image_entry_t + * is constructed from a regular entry. * - * If the instance is constructed from a prefetched entry - * currently residing in the metadata cache, the field is - * set to 1 + the age of the prefetched entry, or to - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX if that sum exceeds - * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX. + * If the instance is constructed from a prefetched entry + * currently residing in the metadata cache, the field is + * set to 1 + the age of the prefetched entry, or to + * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX if that sum exceeds + * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX. * - * type_id: Integer field containing the type ID of the entry. + * type_id: Integer field containing the type ID of the entry. * - * lru_rank: Rank of the entry in the LRU just prior to file close. + * lru_rank: Rank of the entry in the LRU just prior to file close. * - * Note that the first entry on the LRU has lru_rank 1, - * and that entries not on the LRU at that time will have - * either lru_rank -1 (if pinned) or 0 (if loaded during - * the process of flushing the cache. + * Note that the first entry on the LRU has lru_rank 1, + * and that entries not on the LRU at that time will have + * either lru_rank -1 (if pinned) or 0 (if loaded during + * the process of flushing the cache. * - * is_dirty: Boolean flag indicating whether the contents of the cache - * entry has been modified since the last time it was written - * to disk as a regular piece of metadata. + * is_dirty: Boolean flag indicating whether the contents of the cache + * entry has been modified since the last time it was written + * to disk as a regular piece of metadata. * * image_fd_height: Flush dependency height of the entry in the cache image. * @@ -1758,17 +1752,17 @@ typedef struct H5C_cache_entry_t { * * Note that while this count is initially taken from the * flush dependency fields in the associated instance of - * H5C_cache_entry_t, if the entry is in the cache image - * (i.e. include_in_image is TRUE), any parents that are - * not in the image are removed from this count and + * H5C_cache_entry_t, if the entry is in the cache image + * (i.e. include_in_image is TRUE), any parents that are + * not in the image are removed from this count and * from the fd_parent_addrs array below. * * Finally observe that if the entry is dirty and in the * cache image, and its parent is dirty and not in the cache * image, then the entry must be removed from the cache image * to avoid violating the flush dependency flush ordering. - * This should have happened before the construction of - * the instance of H5C_image_entry_t. + * This should have happened before the construction of + * the instance of H5C_image_entry_t. * * fd_parent_addrs: If the entry is a child in one or more flush dependency * relationship when H5C_prep_for_file_close() is called, this @@ -1781,27 +1775,27 @@ typedef struct H5C_cache_entry_t { * Note that while this list of addresses is initially taken * from the flush dependency fields in the associated instance of * H5C_cache_entry_t, if the entry is in the cache image - * (i.e. include_in_image is TRUE), any parents that are not - * in the image are removed from this list, and from the - * fd_parent_count above. + * (i.e. include_in_image is TRUE), any parents that are not + * in the image are removed from this list, and from the + * fd_parent_count above. * * Finally observe that if the entry is dirty and in the * cache image, and its parent is dirty and not in the cache * image, then the entry must be removed from the cache image * to avoid violating the flush dependency flush ordering. - * This should have happened before the construction of - * the instance of H5C_image_entry_t. + * This should have happened before the construction of + * the instance of H5C_image_entry_t. * * fd_child_count: If the entry is a parent in a flush dependency - * relationship, this field contains the number of flush - * dependency children. + * relationship, this field contains the number of flush + * dependency children. * - * In all other cases, the field is set to zero. + * In all other cases, the field is set to zero. * * Note that while this count is initially taken from the * flush dependency fields in the associated instance of * H5C_cache_entry_t, if the entry is in the cache image - * (i.e. include_in_image is TRUE), any children + * (i.e. include_in_image is TRUE), any children * that are not in the image are removed from this count. * * fd_dirty_child_count: If the entry is a parent in a flush dependency @@ -1813,35 +1807,35 @@ typedef struct H5C_cache_entry_t { * Note that while this count is initially taken from the * flush dependency fields in the associated instance of * H5C_cache_entry_t, if the entry is in the cache image - * (i.e. include_in_image is TRUE), any dirty children - * that are not in the image are removed from this count. + * (i.e. include_in_image is TRUE), any dirty children + * that are not in the image are removed from this count. * - * image_ptr: Pointer to void. When not NULL, this field points to a - * dynamically allocated block of size bytes in which the - * on disk image of the metadata cache entry is stored. + * image_ptr: Pointer to void. When not NULL, this field points to a + * dynamically allocated block of size bytes in which the + * on disk image of the metadata cache entry is stored. * - * If the entry is dirty, the pre-serialize and serialize - * callbacks must be used to update this image before it is - * written to disk + * If the entry is dirty, the pre-serialize and serialize + * callbacks must be used to update this image before it is + * written to disk * * ****************************************************************************/ typedef struct H5C_image_entry_t { - uint32_t magic; - haddr_t addr; - size_t size; - H5C_ring_t ring; - int32_t age; - int32_t type_id; - int32_t lru_rank; - hbool_t is_dirty; - unsigned image_fd_height; - uint64_t fd_parent_count; - haddr_t *fd_parent_addrs; - uint64_t fd_child_count; - uint64_t fd_dirty_child_count; - void *image_ptr; + uint32_t magic; + haddr_t addr; + size_t size; + H5C_ring_t ring; + int32_t age; + int32_t type_id; + int32_t lru_rank; + hbool_t is_dirty; + unsigned image_fd_height; + uint64_t fd_parent_count; + haddr_t * fd_parent_addrs; + uint64_t fd_child_count; + uint64_t fd_dirty_child_count; + void * image_ptr; } H5C_image_entry_t; /**************************************************************************** @@ -1854,95 +1848,95 @@ typedef struct H5C_image_entry_t { * The fields of the structure are discussed individually below: * * version: Integer field containing the version number of this version - * of the H5C_auto_size_ctl_t structure. Any instance of - * H5C_auto_size_ctl_t passed to the cache must have a known - * version number, or an error will be flagged. + * of the H5C_auto_size_ctl_t structure. Any instance of + * H5C_auto_size_ctl_t passed to the cache must have a known + * version number, or an error will be flagged. * * report_fcn: Pointer to the function that is to be called to report - * activities each time the auto cache resize code is executed. If the - * field is NULL, no call is made. + * activities each time the auto cache resize code is executed. If the + * field is NULL, no call is made. * - * If the field is not NULL, it must contain the address of a function - * of type H5C_auto_resize_report_fcn. + * If the field is not NULL, it must contain the address of a function + * of type H5C_auto_resize_report_fcn. * * set_initial_size: Boolean flag indicating whether the size of the - * initial size of the cache is to be set to the value given in - * the initial_size field. If set_initial_size is FALSE, the - * initial_size field is ignored. + * initial size of the cache is to be set to the value given in + * the initial_size field. If set_initial_size is FALSE, the + * initial_size field is ignored. * * initial_size: If enabled, this field contain the size the cache is - * to be set to upon receipt of this structure. Needless to say, - * initial_size must lie in the closed interval [min_size, max_size]. + * to be set to upon receipt of this structure. Needless to say, + * initial_size must lie in the closed interval [min_size, max_size]. * * min_clean_fraction: double in the range 0 to 1 indicating the fraction - * of the cache that is to be kept clean. This field is only used - * in parallel mode. Typical values are 0.1 to 0.5. + * of the cache that is to be kept clean. This field is only used + * in parallel mode. Typical values are 0.1 to 0.5. * * max_size: Maximum size to which the cache can be adjusted. The - * supplied value must fall in the closed interval - * [MIN_MAX_CACHE_SIZE, MAX_MAX_CACHE_SIZE]. Also, max_size must - * be greater than or equal to min_size. + * supplied value must fall in the closed interval + * [MIN_MAX_CACHE_SIZE, MAX_MAX_CACHE_SIZE]. Also, max_size must + * be greater than or equal to min_size. * * min_size: Minimum size to which the cache can be adjusted. The - * supplied value must fall in the closed interval - * [MIN_MAX_CACHE_SIZE, MAX_MAX_CACHE_SIZE]. Also, min_size must - * be less than or equal to max_size. + * supplied value must fall in the closed interval + * [MIN_MAX_CACHE_SIZE, MAX_MAX_CACHE_SIZE]. Also, min_size must + * be less than or equal to max_size. * * epoch_length: Number of accesses on the cache over which to collect - * hit rate stats before running the automatic cache resize code, - * if it is enabled. + * hit rate stats before running the automatic cache resize code, + * if it is enabled. * - * At the end of an epoch, we discard prior hit rate data and start - * collecting afresh. The epoch_length must lie in the closed - * interval [H5C__MIN_AR_EPOCH_LENGTH, H5C__MAX_AR_EPOCH_LENGTH]. + * At the end of an epoch, we discard prior hit rate data and start + * collecting afresh. The epoch_length must lie in the closed + * interval [H5C__MIN_AR_EPOCH_LENGTH, H5C__MAX_AR_EPOCH_LENGTH]. * * * Cache size increase control fields: * * incr_mode: Instance of the H5C_cache_incr_mode enumerated type whose - * value indicates how we determine whether the cache size should be - * increased. At present there are two possible values: + * value indicates how we determine whether the cache size should be + * increased. At present there are two possible values: * - * H5C_incr__off: Don't attempt to increase the size of the cache - * automatically. + * H5C_incr__off: Don't attempt to increase the size of the cache + * automatically. * - * When this increment mode is selected, the remaining fields - * in the cache size increase section ar ignored. + * When this increment mode is selected, the remaining fields + * in the cache size increase section ar ignored. * - * H5C_incr__threshold: Attempt to increase the size of the cache - * whenever the average hit rate over the last epoch drops - * below the value supplied in the lower_hr_threshold - * field. + * H5C_incr__threshold: Attempt to increase the size of the cache + * whenever the average hit rate over the last epoch drops + * below the value supplied in the lower_hr_threshold + * field. * - * Note that this attempt will fail if the cache is already - * at its maximum size, or if the cache is not already using - * all available space. + * Note that this attempt will fail if the cache is already + * at its maximum size, or if the cache is not already using + * all available space. * * lower_hr_threshold: Lower hit rate threshold. If the increment mode - * (incr_mode) is H5C_incr__threshold and the hit rate drops below the - * value supplied in this field in an epoch, increment the cache size by - * size_increment. Note that cache size may not be incremented above - * max_size, and that the increment may be further restricted by the - * max_increment field if it is enabled. + * (incr_mode) is H5C_incr__threshold and the hit rate drops below the + * value supplied in this field in an epoch, increment the cache size by + * size_increment. Note that cache size may not be incremented above + * max_size, and that the increment may be further restricted by the + * max_increment field if it is enabled. * - * When enabled, this field must contain a value in the range [0.0, 1.0]. - * Depending on the incr_mode selected, it may also have to be less than - * upper_hr_threshold. + * When enabled, this field must contain a value in the range [0.0, 1.0]. + * Depending on the incr_mode selected, it may also have to be less than + * upper_hr_threshold. * * increment: Double containing the multiplier used to derive the new - * cache size from the old if a cache size increment is triggered. - * The increment must be greater than 1.0, and should not exceed 2.0. + * cache size from the old if a cache size increment is triggered. + * The increment must be greater than 1.0, and should not exceed 2.0. * - * The new cache size is obtained by multiplying the current max cache - * size by the increment, and then clamping to max_size and to stay - * within the max_increment as necessary. + * The new cache size is obtained by multiplying the current max cache + * size by the increment, and then clamping to max_size and to stay + * within the max_increment as necessary. * * apply_max_increment: Boolean flag indicating whether the max_increment - * field should be used to limit the maximum cache size increment. + * field should be used to limit the maximum cache size increment. * * max_increment: If enabled by the apply_max_increment field described - * above, this field contains the maximum number of bytes by which the - * cache size can be increased in a single re-size. + * above, this field contains the maximum number of bytes by which the + * cache size can be increased in a single re-size. * * flash_incr_mode: Instance of the H5C_cache_flash_incr_mode enumerated * type whose value indicates whether and by what algorithm we should @@ -1991,101 +1985,100 @@ typedef struct H5C_image_entry_t { * is H5C_flash_incr__add_space. * * flash_threshold: Double containing the factor by which current max cache - * size is multiplied to obtain the size threshold for the add_space - * flash increment algorithm. The field is ignored unless - * flash_incr_mode is H5C_flash_incr__add_space. + * size is multiplied to obtain the size threshold for the add_space + * flash increment algorithm. The field is ignored unless + * flash_incr_mode is H5C_flash_incr__add_space. * * * Cache size decrease control fields: * * decr_mode: Instance of the H5C_cache_decr_mode enumerated type whose - * value indicates how we determine whether the cache size should be - * decreased. At present there are four possibilities. + * value indicates how we determine whether the cache size should be + * decreased. At present there are four possibilities. * - * H5C_decr__off: Don't attempt to decrease the size of the cache - * automatically. + * H5C_decr__off: Don't attempt to decrease the size of the cache + * automatically. * - * When this increment mode is selected, the remaining fields - * in the cache size decrease section are ignored. + * When this increment mode is selected, the remaining fields + * in the cache size decrease section are ignored. * - * H5C_decr__threshold: Attempt to decrease the size of the cache - * whenever the average hit rate over the last epoch rises - * above the value supplied in the upper_hr_threshold - * field. + * H5C_decr__threshold: Attempt to decrease the size of the cache + * whenever the average hit rate over the last epoch rises + * above the value supplied in the upper_hr_threshold + * field. * - * H5C_decr__age_out: At the end of each epoch, search the cache for - * entries that have not been accessed for at least the number - * of epochs specified in the epochs_before_eviction field, and - * evict these entries. Conceptually, the maximum cache size - * is then decreased to match the new actual cache size. However, - * this reduction may be modified by the min_size, the - * max_decrement, and/or the empty_reserve. + * H5C_decr__age_out: At the end of each epoch, search the cache for + * entries that have not been accessed for at least the number + * of epochs specified in the epochs_before_eviction field, and + * evict these entries. Conceptually, the maximum cache size + * is then decreased to match the new actual cache size. However, + * this reduction may be modified by the min_size, the + * max_decrement, and/or the empty_reserve. * - * H5C_decr__age_out_with_threshold: Same as age_out, but we only - * attempt to reduce the cache size when the hit rate observed - * over the last epoch exceeds the value provided in the - * upper_hr_threshold field. + * H5C_decr__age_out_with_threshold: Same as age_out, but we only + * attempt to reduce the cache size when the hit rate observed + * over the last epoch exceeds the value provided in the + * upper_hr_threshold field. * * upper_hr_threshold: Upper hit rate threshold. The use of this field - * varies according to the current decr_mode: + * varies according to the current decr_mode: * - * H5C_decr__off or H5C_decr__age_out: The value of this field is - * ignored. + * H5C_decr__off or H5C_decr__age_out: The value of this field is + * ignored. * - * H5C_decr__threshold: If the hit rate exceeds this threshold in any - * epoch, attempt to decrement the cache size by size_decrement. + * H5C_decr__threshold: If the hit rate exceeds this threshold in any + * epoch, attempt to decrement the cache size by size_decrement. * - * Note that cache size may not be decremented below min_size. + * Note that cache size may not be decremented below min_size. * - * Note also that if the upper_threshold is 1.0, the cache size - * will never be reduced. + * Note also that if the upper_threshold is 1.0, the cache size + * will never be reduced. * - * H5C_decr__age_out_with_threshold: If the hit rate exceeds this - * threshold in any epoch, attempt to reduce the cache size - * by evicting entries that have not been accessed for more - * than the specified number of epochs. + * H5C_decr__age_out_with_threshold: If the hit rate exceeds this + * threshold in any epoch, attempt to reduce the cache size + * by evicting entries that have not been accessed for more + * than the specified number of epochs. * * decrement: This field is only used when the decr_mode is - * H5C_decr__threshold. + * H5C_decr__threshold. * - * The field is a double containing the multiplier used to derive the - * new cache size from the old if a cache size decrement is triggered. - * The decrement must be in the range 0.0 (in which case the cache will + * The field is a double containing the multiplier used to derive the + * new cache size from the old if a cache size decrement is triggered. + * The decrement must be in the range 0.0 (in which case the cache will * try to contract to its minimum size) to 1.0 (in which case the * cache will never shrink). * * apply_max_decrement: Boolean flag used to determine whether decrements - * in cache size are to be limited by the max_decrement field. + * in cache size are to be limited by the max_decrement field. * * max_decrement: Maximum number of bytes by which the cache size can be - * decreased in a single re-size. Note that decrements may also be - * restricted by the min_size of the cache, and (in age out modes) by - * the empty_reserve field. + * decreased in a single re-size. Note that decrements may also be + * restricted by the min_size of the cache, and (in age out modes) by + * the empty_reserve field. * * epochs_before_eviction: Integer field used in H5C_decr__age_out and - * H5C_decr__age_out_with_threshold decrement modes. + * H5C_decr__age_out_with_threshold decrement modes. * - * This field contains the number of epochs an entry must remain - * unaccessed before it is evicted in an attempt to reduce the - * cache size. If applicable, this field must lie in the range - * [1, H5C__MAX_EPOCH_MARKERS]. + * This field contains the number of epochs an entry must remain + * unaccessed before it is evicted in an attempt to reduce the + * cache size. If applicable, this field must lie in the range + * [1, H5C__MAX_EPOCH_MARKERS]. * * apply_empty_reserve: Boolean field controlling whether the empty_reserve - * field is to be used in computing the new cache size when the - * decr_mode is H5C_decr__age_out or H5C_decr__age_out_with_threshold. + * field is to be used in computing the new cache size when the + * decr_mode is H5C_decr__age_out or H5C_decr__age_out_with_threshold. * * empty_reserve: To avoid a constant racheting down of cache size by small - * amounts in the H5C_decr__age_out and H5C_decr__age_out_with_threshold - * modes, this field allows one to require that any cache size - * reductions leave the specified fraction of unused space in the cache. + * amounts in the H5C_decr__age_out and H5C_decr__age_out_with_threshold + * modes, this field allows one to require that any cache size + * reductions leave the specified fraction of unused space in the cache. * - * The value of this field must be in the range [0.0, 1.0]. I would - * expect typical values to be in the range of 0.01 to 0.1. + * The value of this field must be in the range [0.0, 1.0]. I would + * expect typical values to be in the range of 0.01 to 0.1. * ****************************************************************************/ -enum H5C_resize_status -{ +enum H5C_resize_status { in_spec, increase, flash_increase, @@ -2097,40 +2090,41 @@ enum H5C_resize_status not_full }; /* enum H5C_resize_conditions */ -typedef void (*H5C_auto_resize_rpt_fcn)(H5C_t * cache_ptr, int32_t version, - double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, - size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size); +typedef void (*H5C_auto_resize_rpt_fcn)(H5C_t *cache_ptr, int32_t version, double hit_rate, + enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, + size_t new_min_clean_size); typedef struct H5C_auto_size_ctl_t { /* general configuration fields: */ - int32_t version; - H5C_auto_resize_rpt_fcn rpt_fcn; - hbool_t set_initial_size; - size_t initial_size; - double min_clean_fraction; - size_t max_size; - size_t min_size; - int64_t epoch_length; + int32_t version; + H5C_auto_resize_rpt_fcn rpt_fcn; + hbool_t set_initial_size; + size_t initial_size; + double min_clean_fraction; + size_t max_size; + size_t min_size; + int64_t epoch_length; /* size increase control fields: */ - enum H5C_cache_incr_mode incr_mode; - double lower_hr_threshold; - double increment; - hbool_t apply_max_increment; - size_t max_increment; - enum H5C_cache_flash_incr_mode flash_incr_mode; - double flash_multiple; - double flash_threshold; + enum H5C_cache_incr_mode incr_mode; + double lower_hr_threshold; + double increment; + hbool_t apply_max_increment; + size_t max_increment; + enum H5C_cache_flash_incr_mode flash_incr_mode; + double flash_multiple; + double flash_threshold; /* size decrease control fields: */ - enum H5C_cache_decr_mode decr_mode; - double upper_hr_threshold; - double decrement; - hbool_t apply_max_decrement; - size_t max_decrement; - int32_t epochs_before_eviction; - hbool_t apply_empty_reserve; - double empty_reserve; + enum H5C_cache_decr_mode decr_mode; + double upper_hr_threshold; + double decrement; + hbool_t apply_max_decrement; + size_t max_decrement; + int32_t epochs_before_eviction; + hbool_t apply_empty_reserve; + double empty_reserve; } H5C_auto_size_ctl_t; /**************************************************************************** @@ -2146,12 +2140,12 @@ typedef struct H5C_auto_size_ctl_t { * The fields of the structure are discussed individually below: * * version: Integer field containing the version number of this version - * of the H5C_image_ctl_t structure. Any instance of - * H5C_image_ctl_t passed to the cache must have a known - * version number, or an error will be flagged. + * of the H5C_image_ctl_t structure. Any instance of + * H5C_image_ctl_t passed to the cache must have a known + * version number, or an error will be flagged. * * generate_image: Boolean flag indicating whether a cache image should - * be created on file close. + * be created on file close. * * save_resize_status: Boolean flag indicating whether the cache image * should include the adaptive cache resize configuration and status. @@ -2183,67 +2177,62 @@ 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 - * 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 - * be set. + * cache image functinality 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 + * be set. * ****************************************************************************/ -#define H5C_CI__GEN_MDCI_SBE_MESG ((unsigned)0x0001) -#define H5C_CI__GEN_MDC_IMAGE_BLK ((unsigned)0x0002) -#define H5C_CI__SUPRESS_ENTRY_WRITES ((unsigned)0x0004) -#define H5C_CI__WRITE_CACHE_IMAGE ((unsigned)0x0008) +#define H5C_CI__GEN_MDCI_SBE_MESG ((unsigned)0x0001) +#define H5C_CI__GEN_MDC_IMAGE_BLK ((unsigned)0x0002) +#define H5C_CI__SUPRESS_ENTRY_WRITES ((unsigned)0x0004) +#define H5C_CI__WRITE_CACHE_IMAGE ((unsigned)0x0008) /* This #define must set all defined H5C_CI flags. It is * used in the default value for instances of H5C_cache_image_ctl_t. * This value will only be modified in test code. */ -#define H5C_CI__ALL_FLAGS ((unsigned)0x000F) +#define H5C_CI__ALL_FLAGS ((unsigned)0x000F) -#define H5C__DEFAULT_CACHE_IMAGE_CTL \ -{ \ - /* version = */ H5C__CURR_CACHE_IMAGE_CTL_VER, \ - /* generate_image = */ FALSE, \ - /* save_resize_status = */ FALSE, \ - /* entry_ageout = */ H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE, \ - /* flags = */ H5C_CI__ALL_FLAGS \ -} +#define H5C__DEFAULT_CACHE_IMAGE_CTL \ + { \ + H5C__CURR_CACHE_IMAGE_CTL_VER, /* = version */ \ + FALSE, /* = generate_image */ \ + FALSE, /* = save_resize_status */ \ + H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE, /* = entry_ageout */ \ + H5C_CI__ALL_FLAGS /* = flags */ \ + } typedef struct H5C_cache_image_ctl_t { - int32_t version; - hbool_t generate_image; - hbool_t save_resize_status; - int32_t entry_ageout; - unsigned flags; + int32_t version; + hbool_t generate_image; + hbool_t save_resize_status; + int32_t entry_ageout; + unsigned flags; } H5C_cache_image_ctl_t; /* The cache logging output style */ -typedef enum H5C_log_style_t { - H5C_LOG_STYLE_JSON, - H5C_LOG_STYLE_TRACE -} H5C_log_style_t; +typedef enum H5C_log_style_t { H5C_LOG_STYLE_JSON, H5C_LOG_STYLE_TRACE } H5C_log_style_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -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, - 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, enum H5C_resize_status status, - size_t old_max_cache_size, size_t new_max_cache_size, - size_t old_min_clean_size, size_t new_min_clean_size); +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, + 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, + enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, + size_t new_min_clean_size); H5_DLL herr_t H5C_dest(H5F_t *f); H5_DLL herr_t H5C_evict(H5F_t *f); -H5_DLL herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, - unsigned flags); +H5_DLL herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5C_flush_cache(H5F_t *f, unsigned flags); H5_DLL herr_t H5C_flush_tagged_entries(H5F_t *f, haddr_t tag); -H5_DLL herr_t H5C_force_cache_image_load(H5F_t * f); H5_DLL herr_t H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global); H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5C_get_tag(const void *thing, /*OUT*/ haddr_t *tag); @@ -2251,102 +2240,85 @@ H5_DLL herr_t H5C_get_tag(const void *thing, /*OUT*/ haddr_t *tag); herr_t H5C_verify_tag(int id, haddr_t tag); #endif H5_DLL herr_t H5C_flush_to_min_clean(H5F_t *f); -H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, - H5C_auto_size_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_image_config(const H5C_t * cache_ptr, - H5C_cache_image_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, - size_t *min_clean_size_ptr, size_t *cur_size_ptr, - uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); +H5_DLL herr_t H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); +H5_DLL herr_t H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); +H5_DLL herr_t H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); H5_DLL herr_t H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr); -H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, - size_t *size_ptr, hbool_t *in_cache_ptr, hbool_t *is_dirty_ptr, - hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, 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_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in_cache_ptr, + hbool_t *is_dirty_ptr, hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, + 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 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); -H5_DLL herr_t H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, - hsize_t len, hbool_t rw); +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); +H5_DLL herr_t H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); H5_DLL herr_t H5C_mark_entry_dirty(void *thing); H5_DLL herr_t H5C_mark_entry_clean(void *thing); H5_DLL herr_t H5C_mark_entry_unserialized(void *thing); H5_DLL herr_t H5C_mark_entry_serialized(void *thing); -H5_DLL herr_t H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, - haddr_t old_addr, haddr_t new_addr); +H5_DLL herr_t H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr); 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); -H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, - H5C_cache_image_ctl_t *config_ptr); -H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, - hbool_t evictions_enabled); -H5_DLL herr_t H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, - hbool_t clear_slist); +H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); +H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled); +H5_DLL herr_t H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_slist); H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix); -H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, - hbool_t display_detailed_stats); -H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); +H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t display_detailed_stats); +H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); H5_DLL herr_t H5C_unpin_entry(void *thing); H5_DLL herr_t H5C_destroy_flush_dependency(void *parent_thing, void *child_thing); -H5_DLL herr_t H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, - unsigned int flags); -H5_DLL herr_t H5C_validate_cache_image_config(H5C_cache_image_ctl_t * ctl_ptr); -H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, - unsigned int tests); +H5_DLL herr_t H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned int flags); +H5_DLL herr_t H5C_validate_cache_image_config(H5C_cache_image_ctl_t *ctl_ptr); +H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests); H5_DLL herr_t H5C_ignore_tags(H5C_t *cache_ptr); -H5_DLL hbool_t H5C_get_ignore_tags(const H5C_t *cache_ptr); +H5_DLL hbool_t H5C_get_ignore_tags(const H5C_t *cache_ptr); H5_DLL uint32_t H5C_get_num_objs_corked(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag); -H5_DLL herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked); -H5_DLL herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring); -H5_DLL herr_t H5C_unsettle_entry_ring(void *thing); -H5_DLL herr_t H5C_unsettle_ring(H5F_t * f, H5C_ring_t ring); -H5_DLL herr_t H5C_remove_entry(void *thing); -H5_DLL herr_t H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, - hbool_t *write_ci_ptr); -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); +H5_DLL herr_t H5C_retag_entries(H5C_t *cache_ptr, haddr_t src_tag, haddr_t dest_tag); +H5_DLL herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked); +H5_DLL herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring); +H5_DLL herr_t H5C_unsettle_entry_ring(void *thing); +H5_DLL herr_t H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring); +H5_DLL herr_t H5C_remove_entry(void *thing); +H5_DLL herr_t H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr); +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); /* Logging functions */ H5_DLL herr_t H5C_start_logging(H5C_t *cache); H5_DLL herr_t H5C_stop_logging(H5C_t *cache); -H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging); +H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, + /*OUT*/ hbool_t *is_currently_logging); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, - unsigned num_candidates, haddr_t *candidates_list_ptr, int mpi_rank, - int mpi_size); +H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, + haddr_t *candidates_list_ptr, int mpi_rank, int mpi_size); H5_DLL herr_t H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr); H5_DLL herr_t H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr); -H5_DLL herr_t H5C_clear_coll_entries(H5C_t * cache_ptr, hbool_t partial); -H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, - haddr_t *ce_array_ptr); +H5_DLL herr_t H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial); +H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr); #endif /* H5_HAVE_PARALLEL */ -#ifndef NDEBUG /* debugging functions */ -H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); -H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name); +#ifndef NDEBUG /* debugging functions */ +H5_DLL herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name); +H5_DLL herr_t H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name); H5_DLL hbool_t H5C_get_serialization_in_progress(const H5C_t *cache_ptr); H5_DLL hbool_t H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring); -H5_DLL herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); -H5_DLL herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, - void **entry_ptr_ptr); -H5_DLL herr_t H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, - haddr_t child_addr, hbool_t *fd_exists_ptr); -H5_DLL herr_t H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, - const H5C_class_t *expected_type, hbool_t *in_cache_ptr, - hbool_t *type_ok_ptr); -H5_DLL herr_t H5C_validate_index_list(H5C_t *cache_ptr); +H5_DLL herr_t H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn); +H5_DLL herr_t H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr); +H5_DLL herr_t H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child_addr, + hbool_t *fd_exists_ptr); +H5_DLL herr_t H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expected_type, + hbool_t *in_cache_ptr, hbool_t *type_ok_ptr); +H5_DLL herr_t H5C_validate_index_list(H5C_t *cache_ptr); #endif /* NDEBUG */ -#endif /* !_H5Cprivate_H */ - +#endif /* H5Cprivate_H */ diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index 62107d971fd..79ece102944 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,12 +19,10 @@ * * Purpose: Public include file for cache functions. * - * Modifications: - * *------------------------------------------------------------------------- */ -#ifndef _H5Cpublic_H -#define _H5Cpublic_H +#ifndef H5Cpublic_H +#define H5Cpublic_H /* Public headers needed by this file */ #include "H5public.h" @@ -33,24 +31,34 @@ extern "C" { #endif -enum H5C_cache_incr_mode -{ +enum H5C_cache_incr_mode { H5C_incr__off, + /**magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(config_ptr == NULL) + if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad config_ptr on entry.") *config_ptr = cache_ptr->resize_ctl; config_ptr->set_initial_size = FALSE; - config_ptr->initial_size = cache_ptr->max_cache_size; + config_ptr->initial_size = cache_ptr->max_cache_size; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_auto_resize_config() */ - /*------------------------------------------------------------------------- * Function: H5C_get_cache_size * @@ -125,36 +114,59 @@ H5C_get_cache_auto_resize_config(const H5C_t * cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_size(H5C_t * cache_ptr, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - uint32_t * cur_num_entries_ptr) +H5C_get_cache_size(H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, + uint32_t *cur_num_entries_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(max_size_ptr != NULL) + if (max_size_ptr != NULL) *max_size_ptr = cache_ptr->max_cache_size; - if(min_clean_size_ptr != NULL) + if (min_clean_size_ptr != NULL) *min_clean_size_ptr = cache_ptr->min_clean_size; - if(cur_size_ptr != NULL) + if (cur_size_ptr != NULL) *cur_size_ptr = cache_ptr->index_size; - if(cur_num_entries_ptr != NULL) + if (cur_num_entries_ptr != NULL) *cur_num_entries_ptr = cache_ptr->index_len; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_size() */ - +/*------------------------------------------------------------------------- + * Function: H5C_get_cache_flush_in_progress + * + * Purpose: Return flush_in_progress in *flush_in_progress_ptr + * If the parameter is NULL, skip that value. + * + * Return: SUCCEED on success, and FAIL on failure. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_get_cache_flush_in_progress(H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") + + if (flush_in_progress_ptr != NULL) + *flush_in_progress_ptr = cache_ptr->flush_in_progress; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_get_cache_flush_in_progress() */ + /*------------------------------------------------------------------------- * Function: H5C_get_cache_hit_rate * @@ -172,23 +184,22 @@ H5C_get_cache_size(H5C_t * cache_ptr, *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) +H5C_get_cache_hit_rate(H5C_t *cache_ptr, double *hit_rate_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(hit_rate_ptr == NULL) + if (hit_rate_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad hit_rate_ptr on entry.") HDassert(cache_ptr->cache_hits >= 0); HDassert(cache_ptr->cache_accesses >= cache_ptr->cache_hits); - if(cache_ptr->cache_accesses > 0) - *hit_rate_ptr = ((double)(cache_ptr->cache_hits)) / - ((double)(cache_ptr->cache_accesses)); + if (cache_ptr->cache_accesses > 0) + *hit_rate_ptr = ((double)(cache_ptr->cache_hits)) / ((double)(cache_ptr->cache_accesses)); else *hit_rate_ptr = 0.0f; @@ -196,7 +207,6 @@ H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_cache_hit_rate() */ - /*------------------------------------------------------------------------- * * Function: H5C_get_entry_status @@ -220,21 +230,14 @@ H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) *------------------------------------------------------------------------- */ herr_t -H5C_get_entry_status(const H5F_t *f, - haddr_t addr, - size_t * size_ptr, - hbool_t * in_cache_ptr, - hbool_t * is_dirty_ptr, - hbool_t * is_protected_ptr, - hbool_t * is_pinned_ptr, - 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) +H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in_cache_ptr, + hbool_t *is_dirty_ptr, hbool_t *is_protected_ptr, hbool_t *is_pinned_ptr, + 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) { - H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -252,12 +255,12 @@ H5C_get_entry_status(const H5F_t *f, /* this test duplicates two of the above asserts, but we need an * invocation of HGOTO_ERROR to keep the compiler happy. */ - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) { + if (entry_ptr == NULL) { /* the entry doesn't exist in the cache -- report this * and quit. */ @@ -265,21 +268,21 @@ H5C_get_entry_status(const H5F_t *f, } /* end if */ else { *in_cache_ptr = TRUE; - if(size_ptr != NULL) + if (size_ptr != NULL) *size_ptr = entry_ptr->size; - if(is_dirty_ptr != NULL) + if (is_dirty_ptr != NULL) *is_dirty_ptr = entry_ptr->is_dirty; - if(is_protected_ptr != NULL) + if (is_protected_ptr != NULL) *is_protected_ptr = entry_ptr->is_protected; - if(is_pinned_ptr != NULL) + if (is_pinned_ptr != NULL) *is_pinned_ptr = entry_ptr->is_pinned; - if(is_corked_ptr != NULL) + if (is_corked_ptr != NULL) *is_corked_ptr = entry_ptr->tag_info ? entry_ptr->tag_info->corked : FALSE; - if(is_flush_dep_parent_ptr != NULL) + if (is_flush_dep_parent_ptr != NULL) *is_flush_dep_parent_ptr = (entry_ptr->flush_dep_nchildren > 0); - if(is_flush_dep_child_ptr != NULL) + if (is_flush_dep_child_ptr != NULL) *is_flush_dep_child_ptr = (entry_ptr->flush_dep_nparents > 0); - if(image_up_to_date_ptr != NULL ) + if (image_up_to_date_ptr != NULL) *image_up_to_date_ptr = entry_ptr->image_up_to_date; } /* end else */ @@ -287,7 +290,6 @@ H5C_get_entry_status(const H5F_t *f, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_entry_status() */ - /*------------------------------------------------------------------------- * Function: H5C_get_evictions_enabled() * @@ -302,17 +304,16 @@ H5C_get_entry_status(const H5F_t *f, *------------------------------------------------------------------------- */ herr_t -H5C_get_evictions_enabled(const H5C_t *cache_ptr, - hbool_t * evictions_enabled_ptr) +H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL ) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - if(evictions_enabled_ptr == NULL) + if (evictions_enabled_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad evictions_enabled_ptr on entry.") *evictions_enabled_ptr = cache_ptr->evictions_enabled; @@ -321,7 +322,6 @@ H5C_get_evictions_enabled(const H5C_t *cache_ptr, FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_evictions_enabled() */ - /*------------------------------------------------------------------------- * Function: H5C_get_aux_ptr * @@ -349,7 +349,6 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->aux_ptr) } /* H5C_get_aux_ptr() */ - /*------------------------------------------------------------------------- * Function: H5C_get_entry_ring * @@ -368,9 +367,9 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) herr_t H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) { - H5C_t *cache_ptr; /* Pointer to cache */ - H5C_cache_entry_t *entry_ptr; /* Pointer to cache entry at address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; /* Pointer to cache */ + H5C_cache_entry_t *entry_ptr; /* Pointer to cache entry at address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -384,7 +383,7 @@ H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) /* Locate the entry at the address */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if(entry_ptr == NULL) + if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't find entry in index") /* Return the ring value */ @@ -406,21 +405,20 @@ H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) *------------------------------------------------------------------------- */ herr_t -H5C_get_mdc_image_info(H5C_t * cache_ptr, haddr_t *image_addr, hsize_t *image_len) +H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if(image_addr == NULL || image_len == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad image_addr or image_len on entry") - *image_addr = cache_ptr->image_addr; - *image_len = cache_ptr->image_len; + if (image_addr) + *image_addr = cache_ptr->image_addr; + if (image_len) + *image_len = cache_ptr->image_len; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_get_mdc_image_info() */ - diff --git a/src/H5Ctag.c b/src/H5Ctag.c index e92d0e433e8..41abd49aac2 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,68 +27,63 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for tagged entry iterator callback context - evict tagged entries */ typedef struct { - H5F_t *f; /* File pointer for evicting entry */ - hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry - * was evicted when iterating over - * cache - */ - hbool_t pinned_entries_need_evicted;/* Flag to indicate that a pinned - * entry was attempted to be evicted - */ - hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more - * entries marked prefetched_dirty - * were encountered and not - * evicted. - */ + H5F_t * f; /* File pointer for evicting entry */ + hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry + * was evicted when iterating over + * cache + */ + hbool_t pinned_entries_need_evicted; /* Flag to indicate that a pinned + * entry was attempted to be evicted + */ + hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more + * entries marked prefetched_dirty + * were encountered and not + * evicted. + */ } H5C_tag_iter_evict_ctx_t; /* Typedef for tagged entry iterator callback context - expunge tag type metadata */ typedef struct { - H5F_t *f; /* File pointer for evicting entry */ - int type_id; /* Cache entry type to expunge */ - unsigned flags; /* Flags for expunging entry */ + H5F_t * f; /* File pointer for evicting entry */ + int type_id; /* Cache entry type to expunge */ + unsigned flags; /* Flags for expunging entry */ } H5C_tag_iter_ettm_ctx_t; /* Typedef for tagged entry iterator callback context - mark corked */ typedef struct { - hbool_t cork_val; /* Corked value */ + hbool_t cork_val; /* Corked value */ } H5C_tag_iter_cork_ctx_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5C__mark_tagged_entries(H5C_t *cache_ptr, haddr_t tag); - /*********************/ /* Package Variables */ /*********************/ @@ -96,18 +91,14 @@ static herr_t H5C__mark_tagged_entries(H5C_t *cache_ptr, haddr_t tag); /* Declare extern free list to manage the tag info struct */ H5FL_EXTERN(H5C_tag_info_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * * Function: H5C_ignore_tags @@ -131,7 +122,7 @@ H5FL_EXTERN(H5C_tag_info_t); *------------------------------------------------------------------------- */ herr_t -H5C_ignore_tags(H5C_t * cache_ptr) +H5C_ignore_tags(H5C_t *cache_ptr) { FUNC_ENTER_NOAPI_NOERR @@ -145,7 +136,6 @@ H5C_ignore_tags(H5C_t * cache_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_ignore_tags */ - /*------------------------------------------------------------------------- * * Function: H5C_get_ignore_tags @@ -172,7 +162,6 @@ H5C_get_ignore_tags(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->ignore_tags) } /* H5C_get_ignore_tags */ - /*------------------------------------------------------------------------- * * Function: H5C_get_num_objs_corked @@ -198,7 +187,6 @@ H5C_get_num_objs_corked(const H5C_t *cache_ptr) FUNC_LEAVE_NOAPI(cache_ptr->num_objs_corked) } /* H5C_get_num_objs_corked */ - /*------------------------------------------------------------------------- * * Function: H5C__tag_entry @@ -218,9 +206,9 @@ H5C_get_num_objs_corked(const H5C_t *cache_ptr) herr_t H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - haddr_t tag; /* Tag value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + haddr_t tag; /* Tag value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -232,7 +220,7 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Get the tag */ tag = H5CX_get_tag(); - if(cache->ignore_tags) { + if (cache->ignore_tags) { /* if we're ignoring tags, it's because we're running tests on internal functions and may not have inserted a tag value into a given API context before creating some metadata. Thus, @@ -240,13 +228,13 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) arbitrarily set it to something for the sake of passing the tests. If the tag value is set, then we'll just let it get assigned without additional checking for correctness. */ - if(!H5F_addr_defined(tag)) + if (!H5F_addr_defined(tag)) tag = H5AC__IGNORE_TAG; } /* end if */ #if H5C_DO_TAGGING_SANITY_CHECKS else { /* Perform some sanity checks to ensure that a correct tag is being applied */ - if(H5C_verify_tag(entry->type->id, tag) < 0) + if (H5C_verify_tag(entry->type->id, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "tag verification failed") } /* end else */ #endif @@ -255,16 +243,16 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) tag_info = (H5C_tag_info_t *)H5SL_search(cache->tag_list, &tag); /* Check if this is the first entry for this tagged object */ - if(NULL == tag_info) { + if (NULL == tag_info) { /* Allocate new tag info struct */ - if(NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) + if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache 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 ) + 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 */ else @@ -276,9 +264,9 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) HDassert(entry->tag_info == NULL); /* Add the entry to the list for the tagged object */ - entry->tl_next = tag_info->head; + entry->tl_next = tag_info->head; entry->tag_info = tag_info; - if(tag_info->head) + if (tag_info->head) tag_info->head->tl_prev = entry; tag_info->head = entry; tag_info->entry_cnt++; @@ -287,7 +275,6 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__tag_entry */ - /*------------------------------------------------------------------------- * * Function: H5C__untag_entry @@ -305,8 +292,8 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) herr_t 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 */ + H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -316,27 +303,27 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Get the entry's tag info struct */ - if(NULL != (tag_info = entry->tag_info)) { + if (NULL != (tag_info = entry->tag_info)) { /* Remove the entry from the list */ - if(entry->tl_next) + if (entry->tl_next) entry->tl_next->tl_prev = entry->tl_prev; - if(entry->tl_prev) + if (entry->tl_prev) entry->tl_prev->tl_next = entry->tl_next; - if(tag_info->head == entry) + if (tag_info->head == entry) tag_info->head = entry->tl_next; tag_info->entry_cnt--; /* Reset pointers, to avoid confusion */ - entry->tl_next = NULL; - entry->tl_prev = NULL; + entry->tl_next = NULL; + entry->tl_prev = NULL; entry->tag_info = NULL; /* Remove the tag info from the tag list, if there's no more entries with this tag */ - if(!tag_info->corked && 0 == tag_info->entry_cnt) { + if (!tag_info->corked && 0 == tag_info->entry_cnt) { /* Sanity check */ HDassert(NULL == tag_info->head); - if(H5SL_remove(cache->tag_list, &(tag_info->tag)) != tag_info) + 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 */ @@ -350,7 +337,6 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__untag_entry */ - /*------------------------------------------------------------------------- * * Function: H5C__iter_tagged_entries_real @@ -365,11 +351,10 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) *------------------------------------------------------------------------- */ static herr_t -H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, - void *cb_ctx) +H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, void *cb_ctx) { - 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; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -382,9 +367,9 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, tag_info = (H5C_tag_info_t *)H5SL_search(cache->tag_list, &tag); /* If there's any entries for this tag, iterate over them */ - if(tag_info) { - H5C_cache_entry_t *entry; /* Pointer to current entry */ - H5C_cache_entry_t *next_entry; /* Pointer to next entry in hash bucket chain */ + if (tag_info) { + H5C_cache_entry_t *entry; /* Pointer to current entry */ + H5C_cache_entry_t *next_entry; /* Pointer to next entry in hash bucket chain */ /* Sanity check */ HDassert(tag_info->head); @@ -392,24 +377,23 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, /* Iterate over the entries for this tag */ entry = tag_info->head; - while(entry) { + while (entry) { /* Acquire pointer to next entry */ next_entry = entry->tl_next; /* Make callback for entry */ - if((cb)(entry, cb_ctx) != H5_ITER_CONT) + if ((cb)(entry, cb_ctx) != H5_ITER_CONT) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "tagged entry iteration callback failed") /* Advance to next entry */ entry = next_entry; } /* end while */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__iter_tagged_entries_real() */ - /*------------------------------------------------------------------------- * * Function: H5C__iter_tagged_entries @@ -424,10 +408,9 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, *------------------------------------------------------------------------- */ herr_t -H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, - H5C_tag_iter_cb_t cb, void *cb_ctx) +H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, void *cb_ctx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_PACKAGE @@ -437,17 +420,17 @@ H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Iterate over the entries for this tag */ - if(H5C__iter_tagged_entries_real(cache, tag, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, tag, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") /* Check for iterating over global metadata */ - if(match_global) { + if (match_global) { /* Iterate over the entries for SOHM entries */ - if(H5C__iter_tagged_entries_real(cache, H5AC__SOHM_TAG, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, H5AC__SOHM_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") /* Iterate over the entries for global heap entries */ - if(H5C__iter_tagged_entries_real(cache, H5AC__GLOBALHEAP_TAG, cb, cb_ctx) < 0) + if (H5C__iter_tagged_entries_real(cache, H5AC__GLOBALHEAP_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") } /* end if */ @@ -455,7 +438,6 @@ H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, FUNC_LEAVE_NOAPI(ret_value) } /* H5C__iter_tagged_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__evict_tagged_entries_cb @@ -473,7 +455,7 @@ static int H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_evict_ctx_t *ctx = (H5C_tag_iter_evict_ctx_t *)_ctx; /* Get pointer to iterator context */ - int ret_value = H5_ITER_CONT; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -483,18 +465,20 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) HDassert(ctx); /* Attempt to evict entry */ - if(entry->is_protected) + if (entry->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Cannot evict protected entry") - else if(entry->is_dirty) + else if (entry->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Cannot evict dirty entry") - else if(entry->is_pinned) + else if (entry->is_pinned) /* Can't evict at this time, but let's note that we hit a pinned entry and we'll loop back around again (as evicting other entries will hopefully unpin this entry) */ ctx->pinned_entries_need_evicted = TRUE; - else if(!entry->prefetched_dirty) { + else if (!entry->prefetched_dirty) { /* Evict the Entry */ - if(H5C__flush_single_entry(ctx->f, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if (H5C__flush_single_entry(ctx->f, entry, + H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Entry eviction failed.") ctx->evicted_entries_last_pass = TRUE; } @@ -505,7 +489,6 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) FUNC_LEAVE_NOAPI(ret_value) } /* H5C__evict_tagged_entries_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_evict_tagged_entries @@ -520,11 +503,11 @@ 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_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global) { - 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 */ + 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 */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -532,7 +515,7 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) /* Sanity checks */ HDassert(f); HDassert(f->shared); - cache = f->shared->cache; /* Get cache pointer */ + cache = f->shared->cache; /* Get cache pointer */ HDassert(cache != NULL); HDassert(cache->magic == H5C__H5C_T_MAGIC); @@ -543,15 +526,15 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) do { /* Reset pinned/evicted tracking flags */ ctx.pinned_entries_need_evicted = FALSE; - ctx.evicted_entries_last_pass = FALSE; - ctx.skipped_pf_dirty_entries = FALSE; + ctx.evicted_entries_last_pass = FALSE; + ctx.skipped_pf_dirty_entries = FALSE; /* Iterate through entries in the cache */ - if(H5C__iter_tagged_entries(cache, tag, match_global, H5C__evict_tagged_entries_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, match_global, H5C__evict_tagged_entries_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") /* Keep doing this until we have stopped evicted entries */ - } while(TRUE == ctx.evicted_entries_last_pass); + } while (TRUE == ctx.evicted_entries_last_pass); /* In most cases, fail if we have finished evicting entries and pinned * entries still need evicted @@ -578,14 +561,13 @@ H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) * Thus we must ignore ctx.pinned_entries_need_evicted if * ctx.skipped_pf_dirty_entries is TRUE. */ - if((!ctx.skipped_pf_dirty_entries) && (ctx.pinned_entries_need_evicted)) + if ((!ctx.skipped_pf_dirty_entries) && (ctx.pinned_entries_need_evicted)) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Pinned entries still need evicted?!") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict_tagged_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__mark_tagged_entries_cb @@ -610,13 +592,12 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) /* We only want to set the flush marker on entries that * actually need flushed (i.e., dirty ones) */ - if(entry->is_dirty) + if (entry->is_dirty) entry->flush_marker = TRUE; FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5C__mark_tagged_entries_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C__mark_tagged_entries @@ -634,7 +615,7 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) static herr_t H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -646,7 +627,7 @@ H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) /* Iterate through hash table entries, marking those with specified tag, as * well as any major global entries which should always be flushed * when flushing based on tag value */ - if(H5C__iter_tagged_entries(cache, tag, TRUE, H5C__mark_tagged_entries_cb, NULL) < 0) + if (H5C__iter_tagged_entries(cache, tag, TRUE, H5C__mark_tagged_entries_cb, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") done: @@ -654,7 +635,7 @@ H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) } /* H5C__mark_tagged_entries() */ #if H5C_DO_TAGGING_SANITY_CHECKS - + /*------------------------------------------------------------------------- * * Function: H5C_verify_tag @@ -678,10 +659,10 @@ H5C_verify_tag(int id, haddr_t tag) /* Perform some sanity checks on tag value. Certain entry * types require certain tag values, so check that these * constraints are met. */ - if(tag == H5AC__IGNORE_TAG) + if (tag == H5AC__IGNORE_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "cannot ignore a tag while doing verification.") - else if(tag == H5AC__INVALID_TAG) { - if(id != H5AC_PROXY_ENTRY_ID) + else if (tag == H5AC__INVALID_TAG) { + if (id != H5AC_PROXY_ENTRY_ID) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "no metadata tag provided") } /* end else-if */ else { @@ -690,41 +671,42 @@ H5C_verify_tag(int id, haddr_t tag) * constraints are met. */ /* Superblock */ - if((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { - if(tag != H5AC__SUPERBLOCK_TAG) + if ((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { + if (tag != H5AC__SUPERBLOCK_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock not tagged with H5AC__SUPERBLOCK_TAG") } /* end if */ else { - if(tag == H5AC__SUPERBLOCK_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__SUPERBLOCK_TAG applied to non-superblock entry") + if (tag == H5AC__SUPERBLOCK_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, + "H5AC__SUPERBLOCK_TAG applied to non-superblock entry") } /* end else */ /* Free Space Manager */ - if(tag == H5AC__FREESPACE_TAG && ((id != H5AC_FSPACE_HDR_ID) && (id != H5AC_FSPACE_SINFO_ID))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") + if (tag == H5AC__FREESPACE_TAG && ((id != H5AC_FSPACE_HDR_ID) && (id != H5AC_FSPACE_SINFO_ID))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") /* SOHM */ - if((id == H5AC_SOHM_TABLE_ID) || (id == H5AC_SOHM_LIST_ID)) - if(tag != H5AC__SOHM_TAG) + if ((id == H5AC_SOHM_TABLE_ID) || (id == H5AC_SOHM_LIST_ID)) + if (tag != H5AC__SOHM_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry not tagged with H5AC__SOHM_TAG") /* Global Heap */ - if(id == H5AC_GHEAP_ID) { - if(tag != H5AC__GLOBALHEAP_TAG) + if (id == H5AC_GHEAP_ID) { + if (tag != H5AC__GLOBALHEAP_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap not tagged with H5AC__GLOBALHEAP_TAG") } /* end if */ else { - if(tag == H5AC__GLOBALHEAP_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") + if (tag == H5AC__GLOBALHEAP_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, + "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_tag */ #endif - /*------------------------------------------------------------------------- * * Function: H5C_flush_tagged_entries @@ -742,8 +724,8 @@ herr_t H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) { /* Variable Declarations */ - H5C_t *cache_ptr = NULL; - herr_t ret_value = SUCCEED; + H5C_t *cache_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -755,18 +737,17 @@ H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) cache_ptr = f->shared->cache; /* Mark all entries with specified tag */ - if(H5C__mark_tagged_entries(cache_ptr, tag) < 0) + if (H5C__mark_tagged_entries(cache_ptr, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't mark tagged entries") /* Flush all marked entries */ - if(H5C__flush_marked_entries(f) < 0) + if (H5C__flush_marked_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_tagged_entries */ - /*------------------------------------------------------------------------- * * Function: H5C_retag_entries @@ -785,8 +766,8 @@ 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; /* Points to a tag info struct */ + herr_t ret_value = SUCCEED; /* Return value */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -795,12 +776,12 @@ H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) HDassert(cache); /* Remove tag info from tag list */ - if(NULL != (tag_info = (H5C_tag_info_t *)H5SL_remove(cache->tag_list, &src_tag))) { + if (NULL != (tag_info = (H5C_tag_info_t *)H5SL_remove(cache->tag_list, &src_tag))) { /* 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) + 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 */ @@ -808,7 +789,6 @@ H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) FUNC_LEAVE_NOAPI(ret_value) } /* H5C_retag_entries() */ - /*------------------------------------------------------------------------- * * Function: H5C__expunge_tag_type_metadata_cb @@ -827,7 +807,7 @@ static int H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_ettm_ctx_t *ctx = (H5C_tag_iter_ettm_ctx_t *)_ctx; /* Get pointer to iterator context */ - int ret_value = H5_ITER_CONT; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -837,15 +817,14 @@ H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) HDassert(ctx); /* Found one with the same tag and type id */ - if(entry->type->id == ctx->type_id) - if(H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) + if (entry->type->id == ctx->type_id) + if (H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, H5_ITER_ERROR, "can't expunge entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__expunge_tag_type_metadata_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_expunge_tag_type_metadata @@ -863,9 +842,9 @@ 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_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ /* Function enter macro */ FUNC_ENTER_NOAPI(FAIL) @@ -873,24 +852,23 @@ H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags /* Sanity checks */ HDassert(f); HDassert(f->shared); - cache = f->shared->cache; /* Get cache pointer */ + cache = f->shared->cache; /* Get cache pointer */ HDassert(cache != NULL); HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Construct context for iterator callbacks */ - ctx.f = f; + ctx.f = f; ctx.type_id = type_id; - ctx.flags = flags; + ctx.flags = flags; /* Iterate through hash table entries, expunge those with specified tag and type id */ - if(H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_tag_type_metadata_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_tag_type_metadata_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_expunge_tag_type_metadata() */ - /*------------------------------------------------------------------------- * * Function: H5C_get_tag() @@ -905,9 +883,9 @@ H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags *------------------------------------------------------------------------- */ herr_t -H5C_get_tag(const void *thing, haddr_t *tag /*OUT*/) +H5C_get_tag(const void *thing, haddr_t *tag) { - const H5C_cache_entry_t *entry = (const H5C_cache_entry_t *)thing; /* Pointer to cache entry */ + const H5C_cache_entry_t *entry = (const H5C_cache_entry_t *)thing; /* Pointer to cache entry */ FUNC_ENTER_NOAPI_NOERR @@ -920,4 +898,3 @@ H5C_get_tag(const void *thing, haddr_t *tag /*OUT*/) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_get_tag() */ - diff --git a/src/H5Ctest.c b/src/H5Ctest.c index 40d487e2fde..aa0641672c8 100644 --- a/src/H5Ctest.c +++ b/src/H5Ctest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,58 +27,50 @@ /* Module Setup */ /****************/ -#include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5C_TESTING /*suppress warning about H5C testing funcs*/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5C_TESTING /*suppress warning about H5C testing funcs*/ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Cpkg.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for tagged entry iterator callback context - verify cork tag */ typedef struct { - hbool_t status; /* Corked status */ + hbool_t status; /* Corked status */ } H5C_tag_iter_vct_ctx_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - - /*------------------------------------------------------------------------- * Function: H5C__verify_cork_tag_test_cb * @@ -95,8 +87,8 @@ static int H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) { H5C_tag_iter_vct_ctx_t *ctx = (H5C_tag_iter_vct_ctx_t *)_ctx; /* Get pointer to iterator context */ - hbool_t is_corked; /* Corked status for entry */ - int ret_value = H5_ITER_CONT; /* Return value */ + hbool_t is_corked; /* Corked status for entry */ + int ret_value = H5_ITER_CONT; /* Return value */ /* Function enter macro */ FUNC_ENTER_STATIC @@ -109,14 +101,13 @@ H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) is_corked = entry->tag_info ? entry->tag_info->corked : FALSE; /* Verify corked status for entry */ - if(is_corked != ctx->status) + if (is_corked != ctx->status) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, H5_ITER_ERROR, "bad cork status") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__verify_cork_tag_test_cb() */ - /*------------------------------------------------------------------------- * Function: H5C__verify_cork_tag_test * @@ -131,19 +122,25 @@ H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) *------------------------------------------------------------------------- */ herr_t -H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status) +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 */ - H5C_tag_iter_vct_ctx_t ctx; /* Context for iterator callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ /* Function enter macro */ FUNC_ENTER_PACKAGE /* Get file pointer */ - if(NULL == (f = (H5F_t *)H5I_object_verify(fid, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + if (NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* Convert token to address */ + tag = HADDR_UNDEF; + if (H5VL_native_token_to_addr(f, H5I_FILE, tag_token, &tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't get address for token") /* Get cache pointer */ cache = f->shared->cache; @@ -152,10 +149,9 @@ H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status) ctx.status = status; /* Iterate through tagged entries in the cache */ - if(H5C__iter_tagged_entries(cache, tag, FALSE, H5C__verify_cork_tag_test_cb, &ctx) < 0) + if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__verify_cork_tag_test_cb, &ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__verify_cork_tag_test() */ - diff --git a/src/H5D.c b/src/H5D.c index 4828aafa402..b69391fad8f 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,35 +15,33 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -51,13 +49,6 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; -/* Declare extern the free list to manage blocks of VL data */ -H5FL_BLK_EXTERN(vlen_vl_buf); - -/* Declare extern the free list to manage other blocks of VL data */ -H5FL_BLK_EXTERN(vlen_fl_buf); - - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -65,13 +56,10 @@ H5FL_BLK_EXTERN(vlen_fl_buf); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Dcreate2 * @@ -99,43 +87,35 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, - dapl_id); + H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); /* Check arguments */ - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") /* Get link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") /* Get dataset creation property list */ - if(H5P_DEFAULT == dcpl_id) + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "dcpl_id is not a dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, + "dcpl_id is not a dataset create property list ID") /* Set the DCPL for the API context */ H5CX_set_dcpl(dcpl_id); @@ -144,26 +124,34 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") + if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, + dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create dataset") /* Get an ID for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate2() */ - /*------------------------------------------------------------------------- * Function: H5Dcreate_anon * @@ -197,65 +185,56 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, *------------------------------------------------------------------------- */ hid_t -H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, - hid_t dapl_id) +H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") - if(H5P_DEFAULT == dcpl_id) + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the dataset */ + if (NULL == + (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, type_id, space_id, + dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") - /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + /* Get an atom for the dataset */ + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ - - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on newly created object") - } - /* Cleanup on failure */ - if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ - /*------------------------------------------------------------------------- * Function: H5Dopen2 * @@ -274,42 +253,49 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + if (NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, dapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ - /*------------------------------------------------------------------------- * Function: H5Dclose * @@ -324,26 +310,25 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) herr_t H5Dclose(hid_t dset_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == H5I_object_verify(dset_id, H5I_DATASET)) + if (H5I_DATASET != H5I_get_type(dset_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") /* Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref_always_close(dset_id) < 0) + if (H5I_dec_app_ref_always_close(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Dclose() */ - /*------------------------------------------------------------------------- * Function: H5Dget_space * @@ -360,25 +345,25 @@ H5Dclose(hid_t dset_id) hid_t H5Dget_space(hid_t dset_id) { - H5D_t *dset = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataspace */ - if((ret_value = H5D__get_space(dset)) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_space() */ - /*------------------------------------------------------------------------- * Function: H5Dget_space_status * @@ -391,25 +376,25 @@ H5Dget_space(hid_t dset_id) herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { - H5D_t *dset = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Ds", dset_id, allocation); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Get dataspace status */ - if(H5D__get_space_status(dset, allocation) < 0) + if ((ret_value = H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE_STATUS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, allocation)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get space status") done: FUNC_LEAVE_API(ret_value) } /* H5Dget_space_status() */ - /*------------------------------------------------------------------------- * Function: H5Dget_type * @@ -426,25 +411,25 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) hid_t H5Dget_type(hid_t dset_id) { - H5D_t *dset; /* Dataset */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the datatype */ - if((ret_value = H5D__get_type(dset)) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_type() */ - /*------------------------------------------------------------------------- * Function: H5Dget_create_plist * @@ -464,25 +449,25 @@ H5Dget_type(hid_t dset_id) hid_t H5Dget_create_plist(hid_t dset_id) { - H5D_t *dataset; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset creation property list */ - if((ret_value = H5D_get_create_plist(dataset)) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Dget_access_plist * @@ -519,25 +504,25 @@ H5Dget_create_plist(hid_t dset_id) hid_t H5Dget_access_plist(hid_t dset_id) { - H5D_t *dset; /* Dataset structure */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset access property list */ - if((ret_value = H5D_get_access_plist(dset)) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5Dget_storage_size * @@ -556,25 +541,25 @@ H5Dget_access_plist(hid_t dset_id) hsize_t H5Dget_storage_size(hid_t dset_id) { - H5D_t *dset; /* Dataset to query */ - hsize_t ret_value = 0; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") /* Get the storage size */ - if(H5D__get_storage_size(dset, &ret_value) < 0) + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "unable to get storage size") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Dget_offset * @@ -589,24 +574,25 @@ H5Dget_storage_size(hid_t dset_id) haddr_t H5Dget_offset(hid_t dset_id) { - H5D_t *dset; /* Dataset to query */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") /* Get the offset */ - ret_value = H5D__get_offset(dset); + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_offset() */ - /*------------------------------------------------------------------------- * Function: H5Diterate * @@ -667,92 +653,40 @@ 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) +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 */ - H5S_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xiix*x", buf, type_id, space_id, op, operator_data); /* Check args */ - if(NULL == op) + if (NULL == op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator") - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if(H5I_DATATYPE != H5I_get_type(type_id)) + if (H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = op; + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = op; dset_op.u.app_op.type_id = type_id; ret_value = H5S_select_iterate(buf, type, space, &dset_op, operator_data); done: FUNC_LEAVE_API(ret_value) -} /* end H5Diterate() */ - - -/*------------------------------------------------------------------------- - * Function: H5Dvlen_reclaim - * - * Purpose: Frees the buffers allocated for storing variable-length data - * in memory. Only frees the VL data in the selection defined in the - * dataspace. The dataset transfer property list is required to find the - * correct allocation/free methods for the VL data in the buffer. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Thursday, June 10, 1999 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) -{ - H5S_t *space; /* Dataspace for iteration */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf); - - /* Check args */ - if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") - - /* 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, "not xfer parms") - - /* Set DXPL for operation */ - H5CX_set_dxpl(dxpl_id); - - /* Call internal routine */ - ret_value = H5D_vlen_reclaim(type_id, space, buf); - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Dvlen_reclaim() */ +} /* end H5Diterate() */ - /*------------------------------------------------------------------------- * Function: H5Dvlen_get_buf_size * @@ -762,14 +696,6 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) * VL data, in memory. The *size value is modified according to how many * bytes are required to store the VL data in memory. * - * Implementation: This routine actually performs the read with a custom - * memory manager which basically just counts the bytes requested and - * uses a temporary memory buffer (through the H5FL API) to make certain - * enough space is available to perform the read. Then the temporary - * buffer is released and the number of bytes allocated is returned. - * Kinda kludgy, but easier than the other method of trying to figure out - * the sizes without actually reading the data in... - QAK - * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol @@ -780,83 +706,44 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { - H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0}; - H5D_t *dset; /* Dataset for operation */ - 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_sel_iter_op_t dset_op; /* Operator for iteration */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + hbool_t supported; /* Whether 'get vlen buf size' operation is supported by VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iii*h", dataset_id, type_id, space_id, size); /* Check args */ - if(H5I_DATASET != H5I_get_type(dataset_id) || - H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (dset = (H5D_t *)H5I_object(dataset_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") - if(!(H5S_has_extent(space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") - - /* Save the dataset */ - vlen_bufsize.dset = dset; - - /* Get a copy of the dataset's dataspace */ - if(NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to get dataspace") - vlen_bufsize.fspace = fspace; - - /* Create a scalar for the memory dataspace */ - if(NULL == (mspace = H5S_create(H5S_SCALAR))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") - vlen_bufsize.mspace = mspace; - - /* Grab the temporary buffers required */ - if(NULL == (vlen_bufsize.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, (size_t)1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") - if(NULL == (vlen_bufsize.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") - - /* Set the memory manager to the special allocation routine */ - if(H5CX_set_vlen_alloc_info(H5D__vlen_get_buf_size_alloc, &vlen_bufsize, NULL, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VL data allocation routine") - - /* Set the initial number of bytes required */ - vlen_bufsize.size = 0; - - /* Call H5S_select_iterate with args, etc. */ - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = H5D__vlen_get_buf_size; - dset_op.u.app_op.type_id = type_id; - - ret_value = H5S_select_iterate(&bogus, type, space, &dset_op, &vlen_bufsize); - - /* Get the size if we succeeded */ - if(ret_value >= 0) - *size = vlen_bufsize.size; + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(dataset_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + if (H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype identifier") + if (H5I_DATASPACE != H5I_get_type(space_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace identifier") + if (size == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid 'size' pointer") + + /* Check if the 'get_vlen_buf_size' callback is supported */ + supported = FALSE; + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, + &supported) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'get vlen buf size' operation") + if (supported) { + /* Make the 'get_vlen_buf_size' callback */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id, space_id, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get vlen buf size") + } /* end if */ + else { + /* Perform a generic operation that will work with all VOL connectors */ + if (H5D__vlen_get_buf_size_gen(vol_obj, type_id, space_id, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get vlen buf size") + } /* end else */ done: - if(fspace && H5S_close(fspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(mspace && H5S_close(mspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(vlen_bufsize.fl_tbuf != NULL) - vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf); - if(vlen_bufsize.vl_tbuf != NULL) - vlen_bufsize.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.vl_tbuf); - FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_get_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Dset_extent * @@ -870,31 +757,31 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *s herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - if(!size) + if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size array cannot be NULL") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the extent */ - if(H5D__set_extent(dset, size) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set dataset extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Dset_extent() */ - /*------------------------------------------------------------------------- * Function: H5Dflush * @@ -907,29 +794,32 @@ H5Dset_extent(hid_t dset_id, const hsize_t size[]) herr_t H5Dflush(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ - herr_t ret_value = SUCCEED; /* return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Flush dataset information cached in memory */ - if(H5D__flush(dset, dset_id) < 0) + /* Flush dataset information cached in memory + * XXX: Note that we need to pass the ID to the VOL since the H5F_flush_cb_t + * callback needs it and that's in the public API. + */ + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") done: FUNC_LEAVE_API(ret_value) } /* H5Dflush */ - /*------------------------------------------------------------------------- * Function: H5Drefresh * @@ -942,29 +832,29 @@ H5Dflush(hid_t dset_id) herr_t H5Drefresh(hid_t dset_id) { - H5D_t *dset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh the dataset object */ - if((H5D__refresh(dset_id, dset)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") done: FUNC_LEAVE_API(ret_value) } /* end H5Drefresh() */ - /*------------------------------------------------------------------------- * Function: H5Dformat_convert (Internal) * @@ -985,53 +875,29 @@ H5Drefresh(hid_t dset_id) herr_t H5Dformat_convert(hid_t dset_id) { - H5D_t *dset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ + /* Convert the dataset */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: FUNC_LEAVE_API(ret_value) } /* H5Dformat_convert */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_index_type (Internal) * @@ -1045,36 +911,37 @@ H5Dformat_convert(hid_t dset_id) *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type) +H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type) { - H5D_t *dset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*Dk", did, idx_type); + H5TRACE2("e", "i*Dk", dset_id, idx_type); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - - /* Should be a chunked dataset */ - if(dset->shared->layout.type != H5D_CHUNKED) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not chunked") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") + if (NULL == idx_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") /* Get the chunk indexing type */ - if(idx_type) - *idx_type = dset->shared->layout.u.chunk.idx_type; + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, idx_type) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: FUNC_LEAVE_API(ret_value) } /* H5Dget_chunk_index_type() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_storage_size * * Purpose: Returns the size of an allocated chunk. * + * Intended for use with the H5D(O)read_chunk API call so + * the caller can construct an appropriate buffer. + * * Return: Non-negative on success, negative on failure * * Programmer: Matthew Strong (GE Healthcare) @@ -1085,32 +952,29 @@ H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type) herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes) { - H5D_t *dset = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", dset_id, offset, chunk_nbytes); /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") - if(NULL == offset) + if (NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset parameter cannot be NULL") - if(NULL == chunk_nbytes) + if (NULL == chunk_nbytes) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - /* Get the dataset creation property list */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_chunk_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5Dget_num_chunks * @@ -1128,40 +992,34 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n * Return: Non-negative on success, negative on failure * * Programmer: Binh-Minh Ribler - * August 2018 (HDFFV-10615) + * May 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks) { - H5D_t *dset = NULL; - const H5S_t *space; /* Dataspace for dataset */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*h", dset_id, fspace_id, nchunks); /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + 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 == (space = (const H5S_t *)H5I_object_verify(fspace_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace identifier") - if(NULL == nchunks) + if (NULL == nchunks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - /* Get the number of written chunks */ - if(H5D__get_num_chunks(dset, space, nchunks) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, nchunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_num_chunks() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_info * @@ -1180,41 +1038,46 @@ H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks) * Return: Non-negative on success, negative on failure * * Programmer: Binh-Minh Ribler - * August 2018 (HDFFV-10615) + * May 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *offset, unsigned *filter_mask, + haddr_t *addr, hsize_t *size) { - H5D_t *dset = NULL; - const H5S_t *space; /* Dataspace for dataset */ + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + hsize_t nchunks = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE7("e", "iih*h*Iu*a*h", dset_id, fspace_id, chk_index, offset, - filter_mask, addr, size); + H5TRACE7("e", "iih*h*Iu*a*h", dset_id, fspace_id, chk_index, offset, filter_mask, addr, size); /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(fspace_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") - if(NULL == offset && NULL == filter_mask && NULL == addr && NULL == size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments, must have at least one non-null output argument") + if (NULL == offset && NULL == filter_mask && NULL == addr && NULL == size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid arguments, must have at least one non-null output argument") + 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(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + /* Get the number of written chunks to check range */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_NUM_CHUNKS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, &nchunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get number of chunks") + + /* Check range for chunk index */ + if (chk_index >= nchunks) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk index is out of range") /* Call private function to get the chunk info given the chunk's index */ - if(H5D__get_chunk_info(dset, space, chk_index, offset, filter_mask, addr, size) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fspace_id, chk_index, offset, filter_mask, addr, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by index") done: FUNC_LEAVE_API(ret_value); } /* H5Dget_chunk_info() */ - /*------------------------------------------------------------------------- * Function: H5Dget_chunk_info_by_coord * @@ -1232,33 +1095,34 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of * Return: Non-negative on success, negative on failure * * Programmer: Binh-Minh Ribler - * August 2018 (HDFFV-10615) + * May 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, + hsize_t *size) { - H5D_t *dset = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*h*Iu*a*h", dset_id, offset, filter_mask, addr, size); /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == offset) + 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 == filter_mask && NULL == addr && NULL == size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid arguments, must have at least one non-null output argument") + if (NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)") - if(NULL == filter_mask && NULL == addr && NULL == size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments, must have at least one non-null output argument") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + /* Call private function to get the chunk info given the chunk's index */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, offset, filter_mask, addr, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get chunk info by its logical coordinates") - /* Internal function to get the chunk info */ - if (H5D__get_chunk_info_by_coord(dset, offset, filter_mask, addr, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't get chunk info") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_chunk_info_by_coord() */ diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 5b5ff4ac428..861b4281bd4 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,31 +24,29 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-link trees */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-link trees */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -68,82 +66,72 @@ * The chunk's file address is part of the B-tree and not part of the key. */ typedef struct H5D_btree_key_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*logical offset to start*/ - uint32_t nbytes; /*size of stored data */ - unsigned filter_mask; /*excluded filters */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*logical offset to start*/ + uint32_t nbytes; /*size of stored data */ + unsigned filter_mask; /*excluded filters */ } H5D_btree_key_t; /* B-tree callback info for iteration over chunks */ 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 */ + 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 */ } H5D_btree_it_ud_t; /* B-tree callback info for debugging */ typedef struct H5D_btree_dbg_t { - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - unsigned ndims; /* Number of dimensions */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + unsigned ndims; /* Number of dimensions */ } H5D_btree_dbg_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t 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); + const H5O_layout_chunk_t *layout); /* B-tree iterator callbacks */ -static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key, - haddr_t addr, const void *right_key, void *_udata); +static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key, haddr_t addr, const void *right_key, + void *_udata); /* B-tree callbacks */ -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); -static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key); -static htri_t H5D__btree_found(H5F_t *f, haddr_t addr, - const void *_lt_key, void *_udata); -static H5B_ins_t H5D__btree_insert(H5F_t *f, haddr_t addr, - void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, - void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node/*out*/); -static H5B_ins_t H5D__btree_remove( H5F_t *f, haddr_t addr, void *_lt_key, - hbool_t *lt_key_changed, void *_udata, void *_rt_key, hbool_t *rt_key_changed); -static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, - void *_key); -static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, - const void *_key); -static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, - const void *key, 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); +static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key); +static htri_t H5D__btree_found(H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata); +static H5B_ins_t H5D__btree_insert(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node /*out*/); +static H5B_ins_t H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_udata, void *_rt_key, hbool_t *rt_key_changed); +static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); +static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key); +static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *key, const void *udata); /* Chunked layout indexing callbacks */ -static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); - +static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -151,49 +139,47 @@ static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info); /* v1 B-tree indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_BTREE[1] = {{ - FALSE, /* v1 B-tree indices does not support SWMR access */ - H5D__btree_idx_init, /* insert */ - H5D__btree_idx_create, /* create */ - H5D__btree_idx_is_space_alloc, /* is_space_alloc */ - H5D__btree_idx_insert, /* insert */ - H5D__btree_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__btree_idx_iterate, /* iterate */ - H5D__btree_idx_remove, /* remove */ - H5D__btree_idx_delete, /* delete */ - H5D__btree_idx_copy_setup, /* copy_setup */ - H5D__btree_idx_copy_shutdown, /* copy_shutdown */ - H5D__btree_idx_size, /* size */ - H5D__btree_idx_reset, /* reset */ - H5D__btree_idx_dump, /* dump */ - H5D__btree_idx_dest /* destroy */ + FALSE, /* v1 B-tree indices does not support SWMR access */ + H5D__btree_idx_init, /* insert */ + H5D__btree_idx_create, /* create */ + H5D__btree_idx_is_space_alloc, /* is_space_alloc */ + H5D__btree_idx_insert, /* insert */ + H5D__btree_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__btree_idx_iterate, /* iterate */ + H5D__btree_idx_remove, /* remove */ + H5D__btree_idx_delete, /* delete */ + H5D__btree_idx_copy_setup, /* copy_setup */ + H5D__btree_idx_copy_shutdown, /* copy_shutdown */ + H5D__btree_idx_size, /* size */ + H5D__btree_idx_reset, /* reset */ + H5D__btree_idx_dump, /* dump */ + H5D__btree_idx_dest /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* inherits B-tree like properties from H5B */ H5B_class_t H5B_BTREE[1] = {{ - H5B_CHUNK_ID, /*id */ - sizeof(H5D_btree_key_t), /*sizeof_nkey */ - H5D__btree_get_shared, /*get_shared */ - H5D__btree_new_node, /*new */ - H5D__btree_cmp2, /*cmp2 */ - H5D__btree_cmp3, /*cmp3 */ - H5D__btree_found, /*found */ - H5D__btree_insert, /*insert */ - FALSE, /*follow min branch? */ - FALSE, /*follow max branch? */ - H5B_LEFT, /*critical key */ - H5D__btree_remove, /*remove */ - H5D__btree_decode_key, /*decode */ - H5D__btree_encode_key, /*encode */ - H5D__btree_debug_key /*debug */ + H5B_CHUNK_ID, /*id */ + sizeof(H5D_btree_key_t), /*sizeof_nkey */ + H5D__btree_get_shared, /*get_shared */ + H5D__btree_new_node, /*new */ + H5D__btree_cmp2, /*cmp2 */ + H5D__btree_cmp3, /*cmp3 */ + H5D__btree_found, /*found */ + H5D__btree_insert, /*insert */ + FALSE, /*follow min branch? */ + FALSE, /*follow max branch? */ + H5B_LEFT, /*critical key */ + H5D__btree_remove, /*remove */ + H5D__btree_decode_key, /*decode */ + H5D__btree_encode_key, /*encode */ + H5D__btree_debug_key /*debug */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -201,8 +187,6 @@ H5B_class_t H5B_BTREE[1] = {{ /* Declare a free list to manage H5O_layout_chunk_t objects */ H5FL_DEFINE_STATIC(H5O_layout_chunk_t); - - /*------------------------------------------------------------------------- * Function: H5D__btree_get_shared * @@ -220,7 +204,7 @@ H5FL_DEFINE_STATIC(H5O_layout_chunk_t); static H5UC_t * H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) { - const H5D_chunk_common_ud_t *udata = (const H5D_chunk_common_ud_t *) _udata; + const H5D_chunk_common_ud_t *udata = (const H5D_chunk_common_ud_t *)_udata; FUNC_ENTER_STATIC_NOERR @@ -233,7 +217,6 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) FUNC_LEAVE_NOAPI(udata->storage->u.btree.shared) } /* end H5D__btree_get_shared() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_new_node * @@ -253,14 +236,14 @@ H5D__btree_get_shared(const H5F_t H5_ATTR_UNUSED *f, const void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata, - void *_rt_key, haddr_t *addr_p/*out*/) +H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, + haddr_t *addr_p /*out*/) { - 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; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -283,26 +266,25 @@ H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, */ H5_CHECKED_ASSIGN(lt_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); lt_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.layout->ndims; u++) + for (u = 0; u < udata->common.layout->ndims; u++) lt_key->scaled[u] = udata->common.scaled[u]; /* * The right key might already be present. If not, then add a zero-width * chunk. */ - if(H5B_INS_LEFT != op) { - rt_key->nbytes = 0; + if (H5B_INS_LEFT != op) { + rt_key->nbytes = 0; rt_key->filter_mask = 0; - for(u = 0; u < udata->common.layout->ndims; u++) { + for (u = 0; u < udata->common.layout->ndims; u++) { HDassert(udata->common.scaled[u] + 1 > udata->common.scaled[u]); rt_key->scaled[u] = udata->common.scaled[u] + 1; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_new_node() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_cmp2 * @@ -325,10 +307,10 @@ 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_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; - int ret_value = -1; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -343,7 +325,6 @@ H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_cmp2() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_cmp3 * @@ -374,10 +355,10 @@ 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_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; - int ret_value = 0; + 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; FUNC_ENTER_STATIC_NOERR @@ -392,26 +373,24 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) /* slightly odd way the library initializes the right-most node in the */ /* indexed storage B-tree... */ /* (Dump the B-tree with h5debug to look at it) -QAK */ - if(udata->layout->ndims == 2) { - if(udata->scaled[0] > rt_key->scaled[0]) + if (udata->layout->ndims == 2) { + if (udata->scaled[0] > rt_key->scaled[0]) ret_value = 1; - else if(udata->scaled[0] == rt_key->scaled[0] && - udata->scaled[1] >= rt_key->scaled[1]) + else if (udata->scaled[0] == rt_key->scaled[0] && udata->scaled[1] >= rt_key->scaled[1]) ret_value = 1; - else if(udata->scaled[0] < lt_key->scaled[0]) + else if (udata->scaled[0] < lt_key->scaled[0]) ret_value = (-1); } /* end if */ else { - if(H5VM_vector_ge_u(udata->layout->ndims, udata->scaled, rt_key->scaled)) + if (H5VM_vector_ge_u(udata->layout->ndims, udata->scaled, rt_key->scaled)) ret_value = 1; - else if(H5VM_vector_lt_u(udata->layout->ndims, udata->scaled, lt_key->scaled)) + else if (H5VM_vector_lt_u(udata->layout->ndims, udata->scaled, lt_key->scaled)) ret_value = (-1); } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_cmp3() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_found * @@ -437,13 +416,12 @@ 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__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; - const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *) _lt_key; - unsigned u; - htri_t ret_value = TRUE; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -454,21 +432,20 @@ H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, HDassert(lt_key); /* Is this *really* the requested chunk? */ - for(u = 0; u < udata->common.layout->ndims; u++) - if(udata->common.scaled[u] >= (lt_key->scaled[u] + 1)) + for (u = 0; u < udata->common.layout->ndims; u++) + if (udata->common.scaled[u] >= (lt_key->scaled[u] + 1)) HGOTO_DONE(FALSE) /* Initialize return values */ HDassert(lt_key->nbytes > 0); udata->chunk_block.offset = addr; udata->chunk_block.length = lt_key->nbytes; - udata->filter_mask = lt_key->filter_mask; + udata->filter_mask = lt_key->filter_mask; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_found() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_disjoint * @@ -487,8 +464,8 @@ H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, static hbool_t H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -498,15 +475,14 @@ H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) HDassert(scaled2); /* Loop over two chunks, detecting disjointness and getting out quickly */ - for(u = 0; u < n; u++) - if((scaled1[u] + 1) <= scaled2[u] || (scaled2[u] + 1) <= scaled1[u]) + for (u = 0; u < n; u++) + if ((scaled1[u] + 1) <= scaled2[u] || (scaled2[u] + 1) <= scaled1[u]) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_disjoint() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_insert * @@ -536,17 +512,17 @@ H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) *------------------------------------------------------------------------- */ static H5B_ins_t -H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, hbool_t *lt_key_changed, - void *_md_key, void *_udata, void *_rt_key, hbool_t H5_ATTR_UNUSED *rt_key_changed, - haddr_t *new_node_p/*out*/) +H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED addr, void *_lt_key, + hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, + hbool_t H5_ATTR_UNUSED *rt_key_changed, haddr_t *new_node_p /*out*/) { - 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; - int cmp; - unsigned u; - H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ + 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; + int cmp; + unsigned u; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -563,48 +539,47 @@ H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED cmp = H5D__btree_cmp3(lt_key, udata, rt_key); HDassert(cmp <= 0); - if(cmp < 0) { + if (cmp < 0) { /* Negative indices not supported yet */ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") - - } else if(H5VM_vector_eq_u(udata->common.layout->ndims, - udata->common.scaled, lt_key->scaled) && lt_key->nbytes > 0) { + } + else if (H5VM_vector_eq_u(udata->common.layout->ndims, udata->common.scaled, lt_key->scaled) && + lt_key->nbytes > 0) { /* * Already exists. If the new size is not the same as the old size * then we should reallocate storage. */ - if(lt_key->nbytes != udata->chunk_block.length) { - /* Set node's address (already re-allocated by main chunk routines) */ - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + if (lt_key->nbytes != udata->chunk_block.length) { + /* Set node's address (already re-allocated by main chunk routines) */ + HDassert(H5F_addr_defined(udata->chunk_block.offset)); *new_node_p = udata->chunk_block.offset; H5_CHECKED_ASSIGN(lt_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); lt_key->filter_mask = udata->filter_mask; - *lt_key_changed = TRUE; - ret_value = H5B_INS_CHANGE; - } else { - /* Already have address in udata, from main chunk routines */ - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + *lt_key_changed = TRUE; + ret_value = H5B_INS_CHANGE; + } + else { + /* Already have address in udata, from main chunk routines */ + HDassert(H5F_addr_defined(udata->chunk_block.offset)); ret_value = H5B_INS_NOOP; } - - } else if (H5D__chunk_disjoint(udata->common.layout->ndims, - lt_key->scaled, udata->common.scaled)) { - HDassert(H5D__chunk_disjoint(udata->common.layout->ndims, - rt_key->scaled, udata->common.scaled)); + } + else if (H5D__chunk_disjoint(udata->common.layout->ndims, lt_key->scaled, udata->common.scaled)) { + HDassert(H5D__chunk_disjoint(udata->common.layout->ndims, rt_key->scaled, udata->common.scaled)); /* * Split this node, inserting the new new node to the right of the * current node. The MD_KEY is where the split occurs. */ H5_CHECKED_ASSIGN(md_key->nbytes, uint32_t, udata->chunk_block.length, hsize_t); md_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.layout->ndims; u++) + for (u = 0; u < udata->common.layout->ndims; u++) md_key->scaled[u] = udata->common.scaled[u]; - HDassert(H5F_addr_defined(udata->chunk_block.offset)); + HDassert(H5F_addr_defined(udata->chunk_block.offset)); *new_node_p = udata->chunk_block.offset; - ret_value = H5B_INS_RIGHT; - - } else { + ret_value = H5B_INS_RIGHT; + } + else { HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") } @@ -612,7 +587,6 @@ H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_remove * @@ -626,21 +600,19 @@ H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED *------------------------------------------------------------------------- */ static H5B_ins_t -H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ , - hbool_t *lt_key_changed /*out */ , - void H5_ATTR_UNUSED * _udata /*in,out */ , - void H5_ATTR_UNUSED * _rt_key /*in,out */ , - hbool_t *rt_key_changed /*out */ ) +H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */, hbool_t *lt_key_changed /*out */, + void H5_ATTR_UNUSED *_udata /*in,out */, void H5_ATTR_UNUSED *_rt_key /*in,out */, + hbool_t *rt_key_changed /*out */) { - H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; - H5B_ins_t ret_value=H5B_INS_REMOVE; /* Return value */ + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5B_ins_t ret_value = H5B_INS_REMOVE; /* Return value */ FUNC_ENTER_STATIC /* Remove raw data chunk from file */ H5_CHECK_OVERFLOW(lt_key->nbytes, uint32_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes) < 0) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") + if (H5MF_xfree(f, H5FD_MEM_DRAW, addr, (hsize_t)lt_key->nbytes) < 0) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTFREE, H5B_INS_ERROR, "unable to free chunk") /* Mark keys as unchanged */ *lt_key_changed = FALSE; @@ -650,7 +622,6 @@ H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ , FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_decode_key * @@ -666,11 +637,11 @@ H5D__btree_remove(H5F_t *f, haddr_t addr, void *_lt_key /*in,out */ , 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 */ - hsize_t tmp_offset; /* Temporary coordinate offset, from file */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + 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 */ FUNC_ENTER_STATIC @@ -685,8 +656,8 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key /* decode */ UINT32DECODE(raw, key->nbytes); UINT32DECODE(raw, key->filter_mask); - for(u = 0; u < layout->ndims; u++) { - if(layout->dim[u] == 0) + for (u = 0; u < layout->ndims; u++) { + if (layout->dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Retrieve coordinate offset */ @@ -701,7 +672,6 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_decode_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_encode_key * @@ -717,10 +687,10 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key 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; - hsize_t tmp_offset; /* Temporary coordinate offset, from file */ - unsigned u; /* Local index variable */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -735,16 +705,15 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key /* encode */ UINT32ENCODE(raw, key->nbytes); UINT32ENCODE(raw, key->filter_mask); - for(u = 0; u < layout->ndims; u++) { + for (u = 0; u < layout->ndims; u++) { /* Compute coordinate offset from scaled offset */ tmp_offset = key->scaled[u] * layout->dim[u]; - UINT64ENCODE(raw, tmp_offset); + UINT64ENCODE(raw, tmp_offset); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_encode_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_debug_key * @@ -758,12 +727,11 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key *------------------------------------------------------------------------- */ static herr_t -H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, - const void *_udata) +H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) { - const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; - const H5D_btree_dbg_t *udata = (const H5D_btree_dbg_t *)_udata; - unsigned u; + const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; + const H5D_btree_dbg_t *udata = (const H5D_btree_dbg_t *)_udata; + unsigned u; FUNC_ENTER_STATIC_NOERR @@ -772,14 +740,13 @@ H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Chunk size:", (unsigned)key->nbytes); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < udata->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", (key->scaled[u] * udata->common.layout->dim[u])); + for (u = 0; u < udata->ndims; u++) + HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", (key->scaled[u] * udata->common.layout->dim[u])); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_debug_key() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_shared_free * @@ -795,8 +762,8 @@ H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, static herr_t H5D__btree_shared_free(void *_shared) { - H5B_shared_t *shared = (H5B_shared_t *)_shared; - herr_t ret_value = SUCCEED; /* Return value */ + H5B_shared_t *shared = (H5B_shared_t *)_shared; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -804,14 +771,13 @@ H5D__btree_shared_free(void *_shared) shared->udata = H5FL_FREE(H5O_layout_chunk_t, shared->udata); /* Chain up to the generic B-tree shared info free routine */ - if(H5B_shared_free(shared) < 0) + if (H5B_shared_free(shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't free shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_shared_free() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_shared_create * @@ -825,44 +791,42 @@ 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) +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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC /* Set the raw key size */ - sizeof_rkey = 4 + /*storage size */ - 4 + /*filter mask */ - layout->ndims * 8; /*dimension indices */ + sizeof_rkey = 4 + /*storage size */ + 4 + /*filter mask */ + layout->ndims * 8; /*dimension indices */ /* Allocate & initialize global info for the shared structure */ - if(NULL == (shared = H5B_shared_new(f, H5B_BTREE, sizeof_rkey))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") + if (NULL == (shared = H5B_shared_new(f, H5B_BTREE, sizeof_rkey))) + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "local" information for this dataset's chunks */ - if(NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t))) + if (NULL == (my_layout = H5FL_MALLOC(H5O_layout_chunk_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk layout") H5MM_memcpy(my_layout, layout, sizeof(H5O_layout_chunk_t)); shared->udata = my_layout; /* Make shared B-tree info reference counted */ - if(NULL == (store->u.btree.shared = H5UC_create(shared, H5D__btree_shared_free))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") + if (NULL == (store->u.btree.shared = H5UC_create(shared, H5D__btree_shared_free))) + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: - if(ret_value < 0) - if(my_layout) + if (ret_value < 0) + if (my_layout) my_layout = H5FL_FREE(H5O_layout_chunk_t, my_layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_shared_create() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_init * @@ -877,9 +841,9 @@ H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, */ static herr_t H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, - haddr_t dset_ohdr_addr) + haddr_t dset_ohdr_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -894,14 +858,13 @@ H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUS idx_info->storage->u.btree.dset_ohdr_addr = dset_ohdr_addr; /* Allocate the shared structure */ - if(H5D__btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") + if (H5D__btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_create * @@ -923,8 +886,8 @@ H5D__btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUS static herr_t H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -937,18 +900,17 @@ H5D__btree_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* Initialize "user" data for B-tree callbacks, etc. */ - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = idx_info->storage; /* Create the v1 B-tree for the chunk index */ - if(H5B_create(idx_info->f, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0) + if (H5B_create(idx_info->f, H5B_BTREE, &udata, &(idx_info->storage->idx_addr) /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_is_space_alloc * @@ -972,7 +934,6 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__btree_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_insert * @@ -987,9 +948,9 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1005,14 +966,13 @@ H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. */ - if(H5B_insert(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_insert(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_get_addr * @@ -1030,7 +990,7 @@ H5D__btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, static herr_t H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1044,14 +1004,13 @@ H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat HDassert(udata); /* Go get the chunk information from the B-tree */ - if(H5B_find(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_find(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_iterate_cb * @@ -1068,13 +1027,13 @@ H5D__btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat *------------------------------------------------------------------------- */ 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_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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -1091,13 +1050,12 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, chunk_rec.chunk_addr = addr; /* Make "generic chunk" callback */ - if((ret_value = (udata->cb)(&chunk_rec, udata->udata)) < 0) + if ((ret_value = (udata->cb)(&chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_iterate * @@ -1112,11 +1070,10 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, *------------------------------------------------------------------------- */ static int -H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value = -1; /* Return value */ + H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1131,19 +1088,19 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; - udata.cb = chunk_cb; - udata.udata = chunk_udata; + udata.cb = chunk_cb; + udata.udata = chunk_udata; /* Iterate over existing chunks */ - if((ret_value = H5B_iterate(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, H5D__btree_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5B_iterate(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, + H5D__btree_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_remove * @@ -1159,7 +1116,7 @@ H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1174,14 +1131,13 @@ H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t /* Remove the chunk from the v1 B-tree index and release the space for the * chunk (in the B-tree callback). */ - if(H5B_remove(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) + if (H5B_remove(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__btree_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_delete * @@ -1199,7 +1155,7 @@ H5D__btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t static herr_t H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1211,30 +1167,30 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - H5O_storage_chunk_t tmp_storage; /* Local copy of storage info */ - H5D_chunk_common_ud_t udata; /* User data for B-tree operations */ + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + H5O_storage_chunk_t tmp_storage; /* Local copy of storage info */ + H5D_chunk_common_ud_t udata; /* User data for B-tree operations */ /* Set up temporary chunked storage info */ tmp_storage = *idx_info->storage; /* Set up the shared structure */ - if(H5D__btree_shared_create(idx_info->f, &tmp_storage, idx_info->layout) < 0) + if (H5D__btree_shared_create(idx_info->f, &tmp_storage, idx_info->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") /* Set up B-tree user data */ HDmemset(&udata, 0, sizeof udata); - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = &tmp_storage; /* Delete entire B-tree */ - if(H5B_delete(idx_info->f, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0) + if (H5B_delete(idx_info->f, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk B-tree") /* Release the shared B-tree page */ - if(NULL == tmp_storage.u.btree.shared) + if (NULL == tmp_storage.u.btree.shared) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5UC_DEC(tmp_storage.u.btree.shared) < 0) + if (H5UC_DEC(tmp_storage.u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ @@ -1242,7 +1198,6 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_copy_setup * @@ -1256,10 +1211,9 @@ H5D__btree_idx_delete(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -1276,13 +1230,14 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Create shared B-tree info for each file */ - if(H5D__btree_shared_create(idx_info_src->f, idx_info_src->storage, idx_info_src->layout) < 0) + if (H5D__btree_shared_create(idx_info_src->f, idx_info_src->storage, idx_info_src->layout) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for source shared B-tree info") - if(H5D__btree_shared_create(idx_info_dst->f, idx_info_dst->storage, idx_info_dst->layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for destination shared B-tree info") + if (H5D__btree_shared_create(idx_info_dst->f, idx_info_dst->storage, idx_info_dst->layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't create wrapper for destination shared B-tree info") /* Create the root of the B-tree that describes chunked storage in the dest. file */ - if(H5D__btree_idx_create(idx_info_dst) < 0) + if (H5D__btree_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1290,7 +1245,6 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__btree_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_copy_shutdown * @@ -1304,10 +1258,9 @@ H5D__btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, *------------------------------------------------------------------------- */ static herr_t -H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1315,16 +1268,15 @@ H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst); /* Decrement refcount on shared B-tree info */ - if(H5UC_DEC(storage_src->u.btree.shared) < 0) + if (H5UC_DEC(storage_src->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") - if(H5UC_DEC(storage_dst->u.btree.shared) < 0) + if (H5UC_DEC(storage_dst->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_size * @@ -1341,9 +1293,9 @@ H5D__btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, static herr_t H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */ - H5B_info_t bt_info; /* B-tree info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */ + H5B_info_t bt_info; /* B-tree info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1357,11 +1309,11 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) /* Initialize B-tree node user-data */ HDmemset(&udata, 0, sizeof udata); - udata.layout = idx_info->layout; + udata.layout = idx_info->layout; udata.storage = idx_info->storage; /* Get metadata information for B-tree */ - if(H5B_get_info(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0) + if (H5B_get_info(idx_info->f, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree") /* Set the size of the B-tree */ @@ -1371,7 +1323,6 @@ H5D__btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_reset * @@ -1392,14 +1343,13 @@ H5D__btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; storage->u.btree.shared = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_dump * @@ -1420,12 +1370,11 @@ H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__btree_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__btree_idx_dest * @@ -1441,7 +1390,7 @@ H5D__btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1452,16 +1401,15 @@ H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Free the raw B-tree node buffer */ - if(NULL == idx_info->storage->u.btree.shared) + if (NULL == idx_info->storage->u.btree.shared) HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5UC_DEC(idx_info->storage->u.btree.shared) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") + if (H5UC_DEC(idx_info->storage->u.btree.shared) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree_idx_dest() */ - /*------------------------------------------------------------------------- * Function: H5D_btree_debug * @@ -1475,15 +1423,15 @@ H5D__btree_idx_dest(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ herr_t -H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth, unsigned ndims, const uint32_t *dim) +H5D_btree_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, unsigned ndims, + const uint32_t *dim) { - H5D_btree_dbg_t udata; /* User data for B-tree callback */ - H5O_storage_chunk_t storage; /* Storage information for B-tree callback */ - H5O_layout_chunk_t layout; /* Layout information for B-tree callback */ - hbool_t shared_init = FALSE; /* Whether B-tree shared info is initialized */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_btree_dbg_t udata; /* User data for B-tree callback */ + H5O_storage_chunk_t storage; /* Storage information for B-tree callback */ + H5O_layout_chunk_t layout; /* Layout information for B-tree callback */ + hbool_t shared_init = FALSE; /* Whether B-tree shared info is initialized */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1494,33 +1442,31 @@ H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, /* Reset "fake" layout info */ HDmemset(&layout, 0, sizeof(layout)); layout.ndims = ndims; - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) layout.dim[u] = dim[u]; /* Allocate the shared structure */ - if(H5D__btree_shared_create(f, &storage, &layout) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") + if (H5D__btree_shared_create(f, &storage, &layout) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") shared_init = TRUE; /* Set up user data for callback */ - udata.common.layout = &layout; + udata.common.layout = &layout; udata.common.storage = &storage; - udata.common.scaled = NULL; - udata.ndims = ndims; + udata.common.scaled = NULL; + udata.ndims = ndims; /* Dump the records for the B-tree */ (void)H5B_debug(f, addr, stream, indent, fwidth, H5B_BTREE, &udata); done: - if(shared_init) { + if (shared_init) { /* Free the raw B-tree node buffer */ - if(NULL == storage.u.btree.shared) + if (NULL == storage.u.btree.shared) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted shared info nil") - else - if(H5UC_DEC(storage.u.btree.shared) < 0) - HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info") + else if (H5UC_DEC(storage.u.btree.shared) < 0) + HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_btree_debug() */ - diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index d233ce51e56..f9a4a07a039 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,64 +22,60 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for creating callback context */ 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 */ + 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 */ } H5D_bt2_ctx_ud_t; /* The callback context */ typedef struct H5D_bt2_ctx_t { - uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ - size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ - unsigned ndims; /* Number of dimensions in chunk */ - uint32_t *dim; /* Size of chunk in elements */ + uint32_t chunk_size; /* Size of chunk (bytes; constant for unfiltered object) */ + size_t sizeof_addr; /* Size of file addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + unsigned ndims; /* Number of dimensions in chunk */ + uint32_t *dim; /* Size of chunk in elements */ } 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 */ + H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ + void * udata; /* User data for the chunk's callback routine */ } H5D_bt2_it_ud_t; /* User data for compare callback */ typedef struct H5D_bt2_ud_t { - H5D_chunk_rec_t rec; /* The record to search for */ - unsigned ndims; /* Number of dimensions for the chunked dataset */ + H5D_chunk_rec_t rec; /* The record to search for */ + unsigned ndims; /* Number of dimensions for the chunked dataset */ } H5D_bt2_ud_t; - /********************/ /* Local Prototypes */ /********************/ /* 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); @@ -87,14 +83,14 @@ static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); /* v2 B-tree class for indexing non-filtered chunked datasets */ static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* v2 B-tree class for indexing filtered chunked datasets */ static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *u_ctx); +static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *u_ctx); /* Helper routine */ static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info); @@ -116,29 +112,24 @@ static herr_t H5D__bt2_remove_cb(const void *nrecord, void *_udata); static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed); /* Chunked layout indexing callbacks for v2 B-tree indexing */ -static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *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); -static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); -static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); - +static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *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); +static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst); +static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /*********************/ /* Package Variables */ @@ -146,58 +137,58 @@ static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Chunked dataset I/O ops for v2 B-tree indexing */ const H5D_chunk_ops_t H5D_COPS_BT2[1] = {{ - TRUE, /* Fixed array indices support SWMR access */ - H5D__bt2_idx_init, /* init */ - H5D__bt2_idx_create, /* create */ - H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ - H5D__bt2_idx_insert, /* insert */ - H5D__bt2_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__bt2_idx_iterate, /* iterate */ - H5D__bt2_idx_remove, /* remove */ - H5D__bt2_idx_delete, /* delete */ - H5D__bt2_idx_copy_setup, /* copy_setup */ - H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ - H5D__bt2_idx_size, /* size */ - H5D__bt2_idx_reset, /* reset */ - H5D__bt2_idx_dump, /* dump */ - H5D__bt2_idx_dest /* destroy */ + TRUE, /* Fixed array indices support SWMR access */ + H5D__bt2_idx_init, /* init */ + H5D__bt2_idx_create, /* create */ + H5D__bt2_idx_is_space_alloc, /* is_space_alloc */ + H5D__bt2_idx_insert, /* insert */ + H5D__bt2_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__bt2_idx_iterate, /* iterate */ + H5D__bt2_idx_remove, /* remove */ + H5D__bt2_idx_delete, /* delete */ + H5D__bt2_idx_copy_setup, /* copy_setup */ + H5D__bt2_idx_copy_shutdown, /* copy_shutdown */ + H5D__bt2_idx_size, /* size */ + H5D__bt2_idx_reset, /* reset */ + H5D__bt2_idx_dump, /* dump */ + H5D__bt2_idx_dest /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* v2 B-tree class for indexing non-filtered chunked datasets */ -const H5B2_class_t H5D_BT2[1] = {{ /* B-tree class information */ - H5B2_CDSET_ID, /* Type of B-tree */ - "H5B2_CDSET_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_unfilt_encode, /* Record encoding callback */ - H5D__bt2_unfilt_decode, /* Record decoding callback */ - H5D__bt2_unfilt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2[1] = {{ + /* B-tree class information */ + H5B2_CDSET_ID, /* Type of B-tree */ + "H5B2_CDSET_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_unfilt_encode, /* Record encoding callback */ + H5D__bt2_unfilt_decode, /* Record decoding callback */ + H5D__bt2_unfilt_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing filtered chunked datasets */ -const H5B2_class_t H5D_BT2_FILT[1] = {{ /* B-tree class information */ - H5B2_CDSET_FILT_ID, /* Type of B-tree */ - "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ - sizeof(H5D_chunk_rec_t), /* Size of native record */ - H5D__bt2_crt_context, /* Create client callback context */ - H5D__bt2_dst_context, /* Destroy client callback context */ - H5D__bt2_store, /* Record storage callback */ - H5D__bt2_compare, /* Record comparison callback */ - H5D__bt2_filt_encode, /* Record encoding callback */ - H5D__bt2_filt_decode, /* Record decoding callback */ - H5D__bt2_filt_debug /* Record debugging callback */ +const H5B2_class_t H5D_BT2_FILT[1] = {{ + /* B-tree class information */ + H5B2_CDSET_FILT_ID, /* Type of B-tree */ + "H5B2_CDSET_FILT_ID", /* Name of B-tree class */ + sizeof(H5D_chunk_rec_t), /* Size of native record */ + H5D__bt2_crt_context, /* Create client callback context */ + H5D__bt2_dst_context, /* Destroy client callback context */ + H5D__bt2_store, /* Record storage callback */ + H5D__bt2_compare, /* Record comparison callback */ + H5D__bt2_filt_encode, /* Record encoding callback */ + H5D__bt2_filt_decode, /* Record decoding callback */ + H5D__bt2_filt_debug /* Record debugging callback */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -208,8 +199,6 @@ H5FL_DEFINE_STATIC(H5D_bt2_ctx_t); /* Declare a free list to manage the page elements */ H5FL_ARR_DEFINE_STATIC(uint32_t, H5O_LAYOUT_NDIMS); - - /*------------------------------------------------------------------------- * Function: H5D__bt2_crt_context * @@ -226,9 +215,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 @@ -238,16 +227,16 @@ H5D__bt2_crt_context(void *_udata) HDassert(udata->ndims > 0 && udata->ndims < H5O_LAYOUT_NDIMS); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5D_bt2_ctx_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses and set the chunk size and # of dimensions for the dataset */ ctx->sizeof_addr = H5F_SIZEOF_ADDR(udata->f); - ctx->chunk_size = udata->chunk_size; - ctx->ndims = udata->ndims; + ctx->chunk_size = udata->chunk_size; + ctx->ndims = udata->ndims; /* Set up the "local" information for this dataset's chunk dimension sizes */ - if(NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) + if (NULL == (my_dim = (uint32_t *)H5FL_ARR_MALLOC(uint32_t, H5O_LAYOUT_NDIMS))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate chunk dims") H5MM_memcpy(my_dim, udata->dim, H5O_LAYOUT_NDIMS * sizeof(uint32_t)); ctx->dim = my_dim; @@ -257,7 +246,7 @@ H5D__bt2_crt_context(void *_udata) * allowing for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -267,7 +256,6 @@ H5D__bt2_crt_context(void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_dst_context * @@ -283,7 +271,7 @@ H5D__bt2_crt_context(void *_udata) static herr_t H5D__bt2_dst_context(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 */ FUNC_ENTER_STATIC_NOERR @@ -291,7 +279,7 @@ H5D__bt2_dst_context(void *_ctx) HDassert(ctx); /* Free array for chunk dimension sizes */ - if(ctx->dim) + if (ctx->dim) H5FL_ARR_FREE(uint32_t, ctx->dim); /* Release callback context */ ctx = H5FL_FREE(H5D_bt2_ctx_t, ctx); @@ -299,7 +287,6 @@ H5D__bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_store * @@ -316,7 +303,7 @@ H5D__bt2_dst_context(void *_ctx) static herr_t H5D__bt2_store(void *record, const void *_udata) { - 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 */ FUNC_ENTER_STATIC_NOERR @@ -325,7 +312,6 @@ H5D__bt2_store(void *record, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_store() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_compare * @@ -343,10 +329,10 @@ 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_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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -360,7 +346,6 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_compare() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_encode * @@ -377,9 +362,9 @@ 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 */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -389,13 +374,12 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) /* Encode the record's fields */ H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); /* (Don't encode the chunk size & filter mask for non-filtered B-tree records) */ - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_decode * @@ -412,9 +396,9 @@ 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_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -423,15 +407,14 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) /* Decode the record's fields */ H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); - record->nbytes = ctx->chunk_size; + record->nbytes = ctx->chunk_size; record->filter_mask = 0; - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_unfilt_debug * @@ -445,12 +428,11 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +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 */ - unsigned u; /* Local index variable */ + const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -459,17 +441,16 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, HDassert(ctx->chunk_size == record->nbytes); HDassert(0 == record->filter_mask); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_unfilt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_encode * @@ -486,9 +467,9 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, 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 */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -502,13 +483,12 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); UINT64ENCODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64ENCODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64ENCODE(raw, record->scaled[u]); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_decode * @@ -525,9 +505,9 @@ 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_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ - unsigned u; /* Local index variable */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -539,8 +519,8 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); UINT64DECODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, record->filter_mask); - for(u = 0; u < ctx->ndims; u++) - UINT64DECODE(raw, record->scaled[u]); + for (u = 0; u < ctx->ndims; u++) + UINT64DECODE(raw, record->scaled[u]); /* Sanity checks */ HDassert(H5F_addr_defined(record->chunk_addr)); @@ -549,7 +529,6 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_filt_debug * @@ -563,12 +542,11 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, - const void *_record, const void *_ctx) +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 */ - unsigned u; /* Local index variable */ + 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 */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -577,19 +555,18 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, HDassert(H5F_addr_defined(record->chunk_addr)); HDassert(0 != record->nbytes); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Chunk address:", record->chunk_addr); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Chunk size:", (unsigned)record->nbytes); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", record->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < ctx->ndims; u++) - HDfprintf(stream, "%s%Hd", u?", ":"", record->scaled[u] * ctx->dim[u]); + for (u = 0; u < ctx->ndims; u++) + HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", record->scaled[u] * ctx->dim[u]); HDfputs("}\n", stream); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_init * @@ -603,8 +580,8 @@ H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, - const H5S_t H5_ATTR_UNUSED *space, haddr_t dset_ohdr_addr) +H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -616,7 +593,6 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__btree2_idx_depend * @@ -634,10 +610,10 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -659,26 +635,26 @@ H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.btree.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the v2 B-tree a child flush dependency of the dataset's object header proxy */ - if(H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5B2_depend(idx_info->storage->u.btree2.bt2, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree2_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_open() * @@ -699,8 +675,8 @@ H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) static herr_t H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_bt2_ctx_ud_t u_ctx; /* user data for creating context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -715,25 +691,26 @@ H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.btree2.bt2); /* Set up the user data */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Open v2 B-tree for the chunk index */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") + if (NULL == + (idx_info->storage->u.btree2.bt2 = H5B2_open(idx_info->f, idx_info->storage->idx_addr, &u_ctx))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open v2 B-tree for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_create * @@ -748,9 +725,9 @@ H5D__bt2_idx_open(const H5D_chk_idx_info_t *idx_info) static herr_t H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -762,54 +739,55 @@ H5D__bt2_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); - bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ - + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ + bt2_cparam.rrec_size = H5F_SIZEOF_ADDR(idx_info->f) /* Address of chunk */ + + (idx_info->layout->ndims - 1) * 8; /* # of dimensions x 64-bit chunk offsets */ /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* - * Compute the size required for encoding the size of a chunk, + * Compute the size required for encoding the size of a chunk, * allowing for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ - bt2_cparam.cls = H5D_BT2_FILT; + bt2_cparam.rrec_size += chunk_size_len + 4; /* Size of encoded chunk size & filter mask */ + bt2_cparam.cls = H5D_BT2_FILT; } /* end if */ else - bt2_cparam.cls = H5D_BT2; + bt2_cparam.cls = H5D_BT2; - bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; + bt2_cparam.node_size = idx_info->layout->u.btree2.cparam.node_size; bt2_cparam.split_percent = idx_info->layout->u.btree2.cparam.split_percent; bt2_cparam.merge_percent = idx_info->layout->u.btree2.cparam.merge_percent; - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; + u_ctx.dim = idx_info->layout->dim; /* Create the v2 B-tree for the chunked dataset */ - if(NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) + if (NULL == (idx_info->storage->u.btree2.bt2 = H5B2_create(idx_info->f, &bt2_cparam, &u_ctx))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking chunked dataset") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking chunked dataset") + if (H5B2_get_addr(idx_info->storage->u.btree2.bt2, &(idx_info->storage->idx_addr)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get v2 B-tree address for tracking chunked dataset") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__btree2_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__btree2_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_is_space_alloc * @@ -832,7 +810,6 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__bt2_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_mod_cb * @@ -850,19 +827,19 @@ 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_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ + 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 /* Sanity check */ #ifndef NDEBUG -{ - unsigned u; /* Local index variable */ + { + unsigned u; /* Local index variable */ - for(u = 0; u < op_data->ndims; u++) - HDassert(record->scaled[u] == op_data->rec.scaled[u]); -} + for (u = 0; u < op_data->ndims; u++) + HDassert(record->scaled[u] == op_data->rec.scaled[u]); + } #endif /* NDEBUG */ /* Modify record */ @@ -874,7 +851,6 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_mod_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_insert * @@ -895,12 +871,12 @@ H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) */ 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) + const H5D_t H5_ATTR_UNUSED *dset) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -915,41 +891,40 @@ H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, HDassert(H5F_addr_defined(udata->chunk_block.offset)); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* 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") + } /* 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") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Set up callback info */ - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; bt2_udata.rec.chunk_addr = udata->chunk_block.offset; - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ H5_CHECKED_ASSIGN(bt2_udata.rec.nbytes, uint32_t, udata->chunk_block.length, hsize_t); bt2_udata.rec.filter_mask = udata->filter_mask; - } /* end if */ + } /* end if */ else { /* non-filtered chunk */ - bt2_udata.rec.nbytes = idx_info->layout->size; + bt2_udata.rec.nbytes = idx_info->layout->size; bt2_udata.rec.filter_mask = 0; } /* end else */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Update record for v2 B-tree (could be insert or modify) */ - if(H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) + if (H5B2_update(bt2, &bt2_udata, H5D__bt2_mod_cb, &bt2_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUPDATE, FAIL, "unable to update record in v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_found_cb * @@ -974,7 +949,6 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__bt2_found_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_get_addr * @@ -991,11 +965,11 @@ 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1010,63 +984,62 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* 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") + } /* 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") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Clear the found record */ - found_rec.chunk_addr = HADDR_UNDEF; - found_rec.nbytes = 0; + found_rec.chunk_addr = HADDR_UNDEF; + found_rec.nbytes = 0; found_rec.filter_mask = 0; /* Prepare user data for compare callback */ bt2_udata.rec.chunk_addr = HADDR_UNDEF; - bt2_udata.ndims = idx_info->layout->ndims - 1; + bt2_udata.ndims = idx_info->layout->ndims - 1; /* Set the chunk offset to be searched for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->common.scaled[u]; /* Go get chunk information from v2 B-tree */ - if(H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) + if (H5B2_find(bt2, &bt2_udata, H5D__bt2_found_cb, &found_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in v2 B-tree") /* Set common info for the chunk */ udata->chunk_block.offset = found_rec.chunk_addr; /* Check for setting other info */ - if(H5F_addr_defined(udata->chunk_block.offset)) { + if (H5F_addr_defined(udata->chunk_block.offset)) { /* Sanity check */ HDassert(0 != found_rec.nbytes); /* Set other info for the chunk */ - if(idx_info->pline->nused > 0) { /* filtered chunk */ + if (idx_info->pline->nused > 0) { /* filtered chunk */ udata->chunk_block.length = found_rec.nbytes; - udata->filter_mask = found_rec.filter_mask; - } /* end if */ + udata->filter_mask = found_rec.filter_mask; + } /* end if */ else { /* non-filtered chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - } /* end if */ + } /* end if */ else { udata->chunk_block.length = 0; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate_cb * @@ -1086,20 +1059,19 @@ 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 */ - const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ - int ret_value = -1; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR /* Make "generic chunk" callback */ - if((ret_value = (udata->cb)(record, udata->udata)) < 0) + if ((ret_value = (udata->cb)(record, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_iterate * @@ -1113,12 +1085,11 @@ 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) +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 */ - H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -1133,31 +1104,30 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* 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") + } /* 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") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; /* Prepare user data for iterate callback */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the records in the v2 B-tree */ - if((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5D__bt2_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk v2 B-tree"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_remove_cb() * @@ -1176,9 +1146,9 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1187,14 +1157,13 @@ H5D__bt2_remove_cb(const void *_record, void *_udata) /* Free the space in the file for the object being removed */ H5_CHECK_OVERFLOW(record->nbytes, uint32_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, record->chunk_addr, (hsize_t)record->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_remove * @@ -1209,10 +1178,10 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -1226,14 +1195,14 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) { - /* Open existing v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) + if (NULL == idx_info->storage->u.btree2.bt2) { + /* Open existing v2 B-tree */ + if (H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") - } /* 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") + } /* 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") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1242,19 +1211,20 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u bt2_udata.ndims = idx_info->layout->ndims - 1; /* Initialize the record to search for */ - for(u = 0; u < (idx_info->layout->ndims - 1); u++) + for (u = 0; u < (idx_info->layout->ndims - 1); u++) bt2_udata.rec.scaled[u] = udata->scaled[u]; /* Remove the record for the "dataset chunk" object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(bt2, &bt2_udata, (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, idx_info->f) < 0) + if (H5B2_remove(bt2, &bt2_udata, + (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) ? NULL : H5D__bt2_remove_cb, + idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__bt2_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_delete * @@ -1271,9 +1241,9 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u static herr_t H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) { - H5B2_remove_t remove_op; /* The removal callback */ - H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_remove_t remove_op; /* The removal callback */ + H5D_bt2_ctx_ud_t u_ctx; /* data for context call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1285,32 +1255,31 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - /* Set up user data for creating context */ - u_ctx.f = idx_info->f; - u_ctx.ndims = idx_info->layout->ndims - 1; - u_ctx.chunk_size = idx_info->layout->size; - u_ctx.dim = idx_info->layout->dim; - - /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + /* Set up user data for creating context */ + u_ctx.f = idx_info->f; + u_ctx.ndims = idx_info->layout->ndims - 1; + u_ctx.chunk_size = idx_info->layout->size; + u_ctx.dim = idx_info->layout->dim; + + /* Set remove operation. Do not remove chunks in SWMR_WRITE mode */ + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) remove_op = NULL; else remove_op = H5D__bt2_remove_cb; - /* Delete the v2 B-tree */ - /*(space in the file for each object is freed in the 'remove' callback) */ - if(H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") + /* Delete the v2 B-tree */ + /*(space in the file for each object is freed in the 'remove' callback) */ + if (H5B2_delete(idx_info->f, idx_info->storage->idx_addr, &u_ctx, remove_op, idx_info->f) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") - idx_info->storage->idx_addr = HADDR_UNDEF; + idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_setup * @@ -1323,10 +1292,9 @@ H5D__bt2_idx_delete(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1346,15 +1314,15 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source v2 B-tree is open yet */ - if(NULL == idx_info_src->storage->u.btree2.bt2) - if(H5D__bt2_idx_open(idx_info_src) < 0) + if (NULL == idx_info_src->storage->u.btree2.bt2) + if (H5D__bt2_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create v2 B-tree that describes the chunked dataset in the destination file */ - if(H5D__bt2_idx_create(idx_info_dst) < 0) + if (H5D__bt2_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1365,7 +1333,6 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_copy_shutdown * @@ -1378,10 +1345,9 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, *------------------------------------------------------------------------- */ static herr_t -H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1392,12 +1358,12 @@ H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.btree2.bt2); /* Close v2 B-tree for source file */ - if(H5B2_close(storage_src->u.btree2.bt2) < 0) + if (H5B2_close(storage_src->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_src->u.btree2.bt2 = NULL; /* Close v2 B-tree for destination file */ - if(H5B2_close(storage_dst->u.btree2.bt2) < 0) + if (H5B2_close(storage_dst->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close v2 B-tree") storage_dst->u.btree2.bt2 = NULL; @@ -1405,7 +1371,6 @@ H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_size * @@ -1421,8 +1386,8 @@ H5D__bt2_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, static herr_t H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_t *bt2_cdset = NULL; /* Pointer to v2 B-tree structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1436,26 +1401,25 @@ H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open v2 B-tree */ - if(H5D__bt2_idx_open(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + if (H5D__bt2_idx_open(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set convenience pointer to v2 B-tree structure */ bt2_cdset = idx_info->storage->u.btree2.bt2; /* Get v2 B-tree size for indexing chunked dataset */ - if(H5B2_size(bt2_cdset, index_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") + if (H5B2_size(bt2_cdset, index_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve v2 B-tree storage info for chunked dataset") done: /* Close v2 B-tree index */ - if(bt2_cdset && H5B2_close(bt2_cdset) < 0) + if (bt2_cdset && H5B2_close(bt2_cdset) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset") idx_info->storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_reset * @@ -1476,14 +1440,13 @@ H5D__bt2_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dump * @@ -1504,12 +1467,11 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__bt2_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__bt2_idx_dest * @@ -1524,7 +1486,7 @@ H5D__bt2_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1534,14 +1496,14 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the v2-btree is open */ - if(idx_info->storage->u.btree2.bt2) { + if (idx_info->storage->u.btree2.bt2) { - /* 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) + /* 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") /* Close v2 B-tree */ - if(H5B2_close(idx_info->storage->u.btree2.bt2) < 0) + if (H5B2_close(idx_info->storage->u.btree2.bt2) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") idx_info->storage->u.btree2.bt2 = NULL; } /* end if */ @@ -1549,4 +1511,3 @@ H5D__bt2_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__bt2_idx_dest() */ - diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 520341f1506..f335a25886d 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -42,26 +42,24 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#include "H5ACprivate.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File functions */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5ACprivate.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File functions */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ @@ -69,16 +67,17 @@ /* Macros for iterating over chunks to operate on */ #define H5D_CHUNK_GET_FIRST_NODE(map) (map->use_single ? (H5SL_node_t *)(1) : H5SL_first(map->sel_chunks)) -#define H5D_CHUNK_GET_NODE_INFO(map, node) (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) -#define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) +#define H5D_CHUNK_GET_NODE_INFO(map, node) \ + (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) +#define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) /* Sanity check on chunk index types: commonly used by a lot of routines in this file */ -#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ - HDassert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ - (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ - (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ +#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ + HDassert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ + (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ + (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ (H5D_CHUNK_IDX_NONE == (storage)->idx_type && H5D_COPS_NONE == (storage)->ops)); /* @@ -108,10 +107,10 @@ /*#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_NEWLY_DISABLED_FILTERS 0x02u /* Filters have been disabled since - * the last flush */ - +#define H5D_RDCC_DISABLE_FILTERS 0x01u /* Disable filters on this chunk */ +#define H5D_RDCC_NEWLY_DISABLED_FILTERS \ + 0x02u /* Filters have been disabled since \ + * the last flush */ /******************/ /* Local Typedefs */ @@ -119,128 +118,130 @@ /* Raw data chunks are cached. Each entry in the cache is: */ typedef struct H5D_rdcc_ent_t { - hbool_t locked; /*entry is locked in cache */ - hbool_t dirty; /*needs to be written to disk? */ - hbool_t deleted; /*chunk about to be deleted */ - unsigned edge_chunk_state; /*states related to edge chunks (see above) */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ - uint32_t rd_count; /*bytes remaining to be read */ - 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 */ - 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 */ - struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ + hbool_t locked; /*entry is locked in cache */ + hbool_t dirty; /*needs to be written to disk? */ + hbool_t deleted; /*chunk about to be deleted */ + unsigned edge_chunk_state; /*states related to edge chunks (see above) */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ + uint32_t rd_count; /*bytes remaining to be read */ + 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 */ + 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 */ + struct H5D_rdcc_ent_t *tmp_next; /*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev; /*previous item in temporary doubly-linked list */ } H5D_rdcc_ent_t; typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ /* Callback info for iteration to prune chunks */ 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 */ - uint32_t elmts_per_chunk;/* Elements in chunk */ - 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_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 */ + uint32_t elmts_per_chunk; /* Elements in chunk */ + 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; -/* Callback info for iteration to obtain chunk address and the index of the chunk for all chunks in the B-tree. */ +/* Callback info for iteration to obtain chunk address and the index of the chunk for all chunks in the + * B-tree. */ typedef struct H5D_chunk_it_ud2_t { /* down */ - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* up */ - haddr_t *chunk_addr; /* Array of chunk addresses to fill in */ + haddr_t *chunk_addr; /* Array of chunk addresses to fill in */ } 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 */ - size_t buf_size; /* Buffer size */ - hbool_t do_convert; /* Whether to perform type conversions */ + 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 */ + size_t buf_size; /* Buffer size */ + hbool_t do_convert; /* Whether to perform type conversions */ /* needed for converting variable-length data */ - hid_t tid_src; /* Datatype ID for source datatype */ - 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 */ - size_t reclaim_buf_size; /* Reclaim buffer size */ - uint32_t nelmts; /* Number of elements in buffer */ - H5S_t *buf_space; /* Dataspace describing buffer */ + hid_t tid_src; /* Datatype ID for source datatype */ + 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 */ + size_t reclaim_buf_size; /* Reclaim buffer size */ + uint32_t nelmts; /* Number of elements in 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 H5O_pline_t *pline; /* Filter pipeline */ + unsigned dset_ndims; /* Number of dimensions in dataset */ + const hsize_t * dset_dims; /* Dataset dimensions */ /* needed for copy object pointed by refs */ - H5O_copy_t *cpy_info; /* Copy options */ + H5O_copy_t *cpy_info; /* Copy options */ /* needed for getting raw data from chunk cache */ - hbool_t chunk_in_cache; - uint8_t *chunk; /* the unfiltered chunk data */ + hbool_t chunk_in_cache; + uint8_t *chunk; /* the unfiltered chunk data */ } H5D_chunk_it_ud3_t; /* Callback info for iteration to dump index */ typedef struct H5D_chunk_it_ud4_t { - 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 */ + 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 */ } H5D_chunk_it_ud4_t; /* Callback info for iteration to format convert chunks */ 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 */ + 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 */ } 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 */ + unsigned char *rbuf; /* Read buffer to initialize */ + const H5D_t * dset; /* Dataset to operate on */ } H5D_chunk_readvv_ud_t; /* Typedef for chunk info iterator callback */ typedef struct H5D_chunk_info_iter_ud_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset of the chunk */ - hsize_t ndims; /* Number of dimensions in the dataset */ - uint32_t nbytes; /* Size of stored data in the chunk */ - unsigned filter_mask; /* Excluded filters */ - haddr_t chunk_addr; /* Address of the chunk in file */ - hsize_t chunk_idx; /* Chunk index, where the iteration needs to stop */ - hsize_t curr_idx; /* Current index, where the iteration is */ - hbool_t found; /* Whether the chunk was found */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset of the chunk */ + hsize_t ndims; /* Number of dimensions in the dataset */ + uint32_t nbytes; /* Size of stored data in the chunk */ + unsigned filter_mask; /* Excluded filters */ + haddr_t chunk_addr; /* Address of the chunk in file */ + hsize_t chunk_idx; /* Chunk index, where the iteration needs to stop */ + hsize_t curr_idx; /* Current index, where the iteration is */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + hbool_t found; /* Whether the chunk was found */ } H5D_chunk_info_iter_ud_t; /* Callback info for file selection iteration */ typedef struct H5D_chunk_file_iter_ud_t { - H5D_chunk_map_t *fm; /* File->memory chunk mapping info */ + H5D_chunk_map_t *fm; /* File->memory chunk mapping info */ #ifdef H5_HAVE_PARALLEL - const H5D_io_info_t *io_info; /* I/O info for operation */ -#endif /* H5_HAVE_PARALLEL */ + const H5D_io_info_t *io_info; /* I/O info for operation */ +#endif /* H5_HAVE_PARALLEL */ } 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 */ + 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; #endif /* H5_HAVE_PARALLEL */ @@ -251,17 +252,15 @@ typedef struct H5D_chunk_coll_info_t { /* Chunked layout operation callbacks */ 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); -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); -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); +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); +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); +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); 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); @@ -272,56 +271,48 @@ 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); /* "Nonexistent" layout operation callback */ -static ssize_t -H5D__nonexistent_readvv(const H5D_io_info_t *io_info, - size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); +static ssize_t H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, + size_t *chunk_curr_seq, size_t chunk_len_arr[], + hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_offset_arr[]); /* Format convert cb */ static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* 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 H5O_pline_t *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); -static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata); -static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); -static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); -static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, - const H5D_io_info_t *io_info); -static herr_t H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm); -static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm); -static herr_t H5D__chunk_file_cb(void *elem, const H5T_t *type, unsigned ndims, - const hsize_t *coords, void *fm); -static herr_t H5D__chunk_mem_cb(void *elem, const H5T_t *type, unsigned ndims, - const hsize_t *coords, void *fm); +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); +static herr_t H5D__free_chunk_info(void *item, void *key, void *opdata); +static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); +static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); +static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t *io_info); +static herr_t H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm); +static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm); +static herr_t H5D__chunk_file_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords, + void *fm); +static herr_t H5D__chunk_mem_cb(void *elem, const H5T_t *type, unsigned ndims, const hsize_t *coords, + void *fm); 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, 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); +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, + 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_info_t *chunk_info, + size_t chunk_size, const void *fill_buf); +static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2); #endif /* H5_HAVE_PARALLEL */ /* Debugging helper routine callback */ @@ -332,49 +323,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, H5D__chunk_init, H5D__chunk_is_space_alloc, H5D__chunk_is_data_cached, + H5D__chunk_io_init, H5D__chunk_read, H5D__chunk_write, #ifdef H5_HAVE_PARALLEL - H5D__chunk_collective_read, - H5D__chunk_collective_write, + H5D__chunk_collective_read, H5D__chunk_collective_write, #endif /* H5_HAVE_PARALLEL */ - NULL, - NULL, - H5D__chunk_flush, - H5D__chunk_io_term, - H5D__chunk_dest -}}; - + NULL, NULL, H5D__chunk_flush, H5D__chunk_io_term, H5D__chunk_dest}}; /*******************/ /* Local Variables */ /*******************/ /* "nonexistent" storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, +const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{NULL, NULL, NULL, NULL, NULL, NULL, NULL, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__nonexistent_readvv, - NULL, - NULL, - NULL, - NULL -}}; + H5D__nonexistent_readvv, NULL, NULL, NULL, NULL}}; /* Declare a free list to manage the H5F_rdcc_ent_ptr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5D_rdcc_ent_ptr_t); @@ -391,7 +357,6 @@ H5FL_BLK_DEFINE_STATIC(chunk); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_write * @@ -405,16 +370,16 @@ H5FL_EXTERN(H5S_sel_iter_t); *------------------------------------------------------------------------- */ herr_t -H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, - uint32_t data_size, const void *buf) +H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, uint32_t data_size, + const void *buf) { - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - H5F_block_t old_chunk; /* Offset/length of old chunk */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5F_block_t old_chunk; /* Offset/length of old chunk */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -422,13 +387,14 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, HDassert(layout->type == H5D_CHUNKED); /* Allocate dataspace and initialize it if it hasn't been. */ - if(!H5D__chunk_is_space_alloc(&layout->storage)) { - H5D_io_info_t io_info; /* to hold the dset info */ + if (!H5D__chunk_is_space_alloc(&layout->storage)) { + H5D_io_info_t io_info; /* to hold the dset info */ io_info.dset = dset; + io_info.f_sh = H5F_SHARED(dset->oloc.file); /* Allocate storage */ - if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } @@ -437,12 +403,12 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, scaled[dset->shared->ndims] = 0; /* Find out the file address of the chunk (if any) */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ 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)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Set the file block information for the old chunk */ /* (Which is only defined when overwriting an existing chunk) */ @@ -454,22 +420,22 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, */ /* 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.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); /* Set up the size of chunk for user data */ udata.chunk_block.length = data_size; - if(0 == idx_info.pline->nused && H5F_addr_defined(old_chunk.offset)) + if (0 == idx_info.pline->nused && H5F_addr_defined(old_chunk.offset)) /* If there are no filters and we are overwriting the chunk we can just set values */ need_insert = FALSE; else { /* Otherwise, create the chunk it if it doesn't exist, or reallocate the chunk * if its size has changed. */ - if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) + if (H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") /* Cache the new chunk information */ @@ -477,28 +443,29 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, } /* end else */ /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk address isn't defined") /* Evict the (old) entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != udata.idx_hint) { - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + if (UINT_MAX != udata.idx_hint) { + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], FALSE) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") } /* end if */ /* Write the data to the file */ - if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.chunk_block.offset, data_size, buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + data_size, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Insert the chunk record into the index */ - if(need_insert && layout->storage.u.chunk.ops->insert) { + if (need_insert && layout->storage.u.chunk.ops->insert) { /* Set the chunk's filter mask to the new settings */ udata.filter_mask = filters; - if((layout->storage.u.chunk.ops->insert)(&idx_info, &udata, dset) < 0) + if ((layout->storage.u.chunk.ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") } /* end if */ @@ -506,7 +473,6 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_direct_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_read * @@ -520,14 +486,13 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, *------------------------------------------------------------------------- */ herr_t -H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, - void *buf) +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 */ - 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 */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + 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 */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -540,8 +505,7 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, *filters = 0; /* Allocate dataspace and initialize it if it hasn't been. */ - if(!H5D__chunk_is_space_alloc(&layout->storage) - && !H5D__chunk_is_data_cached(dset->shared)) + if (!H5D__chunk_is_space_alloc(&layout->storage) && !H5D__chunk_is_data_cached(dset->shared)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "storage is not initialized") /* Calculate the index of this chunk */ @@ -549,23 +513,23 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, scaled[dset->shared->ndims] = 0; /* Reset fields about the chunk we are looking for */ - udata.filter_mask = 0; + udata.filter_mask = 0; udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Find out the file address of the chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ 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)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Check if the requested chunk exists in the chunk cache */ - if(UINT_MAX != udata.idx_hint) { + if (UINT_MAX != udata.idx_hint) { H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint]; - hbool_t flush; + hbool_t flush; /* Sanity checks */ HDassert(udata.idx_hint < rdcc->nslots); @@ -574,26 +538,27 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, flush = (ent->dirty == TRUE) ? TRUE : FALSE; /* Flush the chunk to disk and clear the cache entry */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], flush) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], flush) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Reset fields about the chunk we are looking for */ - udata.filter_mask = 0; + udata.filter_mask = 0; udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Get the new file address / chunk size after flushing */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") } /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Read the chunk data into the supplied buffer */ - if(H5F_block_read(dset->oloc.file, H5FD_MEM_DRAW, udata.chunk_block.offset, udata.chunk_block.length, buf) < 0) + if (H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + udata.chunk_block.length, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Return the filter mask */ @@ -603,7 +568,6 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_direct_read() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_storage_size * @@ -619,11 +583,11 @@ H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t* filters, 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 */ - 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 */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + 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 */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -635,7 +599,7 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage *storage_size = 0; /* Allocate dataspace and initialize it if it hasn't been. */ - if(!(*layout->ops->is_space_alloc)(&layout->storage)) + if (!(*layout->ops->is_space_alloc)(&layout->storage)) HGOTO_DONE(SUCCEED) /* Calculate the index of this chunk */ @@ -645,24 +609,24 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage /* Reset fields about the chunk we are looking for */ udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Find out the file address of the chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ 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)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* The requested chunk is not in cache or on disk */ - if(!H5F_addr_defined(udata.chunk_block.offset) && UINT_MAX == udata.idx_hint) + if (!H5F_addr_defined(udata.chunk_block.offset) && UINT_MAX == udata.idx_hint) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk storage is not allocated") /* Check if there are filters registered to the dataset */ - if( dset->shared->dcpl_cache.pline.nused > 0 ) { + if (dset->shared->dcpl_cache.pline.nused > 0) { /* Check if the requested chunk exists in the chunk cache */ - if(UINT_MAX != udata.idx_hint) { + if (UINT_MAX != udata.idx_hint) { H5D_rdcc_ent_t *ent = rdcc->slot[udata.idx_hint]; /* Sanity checks */ @@ -670,24 +634,24 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage HDassert(rdcc->slot[udata.idx_hint]); /* If the cached chunk is dirty, it must be flushed to get accurate size */ - if( ent->dirty == TRUE ) { + if (ent->dirty == TRUE) { /* Flush the chunk to disk and clear the cache entry */ - if(H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], TRUE) < 0) + if (H5D__chunk_cache_evict(dset, rdcc->slot[udata.idx_hint], TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Reset fields about the chunk we are looking for */ udata.chunk_block.offset = HADDR_UNDEF; udata.chunk_block.length = 0; - udata.idx_hint = UINT_MAX; + udata.idx_hint = UINT_MAX; /* Get the new file address / chunk size after flushing */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") } } /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Return the chunk size on disk */ @@ -701,7 +665,6 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5D__get_chunk_storage_size */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_info_real * @@ -715,11 +678,11 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage *------------------------------------------------------------------------- */ 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) +H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, + const hsize_t *max_dims) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -729,15 +692,14 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, HDassert(curr_dims); /* Compute the # of chunks in dataset dimensions */ - for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { + 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 */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; - if(H5S_UNLIMITED == max_dims[u]) + if (H5S_UNLIMITED == max_dims[u]) layout->max_chunks[u] = H5S_UNLIMITED; - else - { + else { /* Sanity check */ - if(layout->dim[u] == 0) + if (layout->dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimension size must be > 0, dim = %u ", u) layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; @@ -749,16 +711,13 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, } /* end for */ /* Get the "down" sizes for each dimension */ - if(H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") - if(H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") + H5VM_array_down(ndims, layout->chunks, layout->down_chunks); + H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_info_real() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_info * @@ -774,7 +733,7 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, herr_t H5D__chunk_set_info(const H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -782,18 +741,19 @@ H5D__chunk_set_info(const H5D_t *dset) HDassert(dset); /* Set the base layout information */ - if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, dset->shared->max_dims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") + if (H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, + dset->shared->max_dims) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ - if(dset->shared->layout.storage.u.chunk.ops->resize && (dset->shared->layout.storage.u.chunk.ops->resize)(&dset->shared->layout.u.chunk) < 0) + if (dset->shared->layout.storage.u.chunk.ops->resize && + (dset->shared->layout.storage.u.chunk.ops->resize)(&dset->shared->layout.u.chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to resize chunk index information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_info() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_set_sizes * @@ -812,7 +772,7 @@ H5D__chunk_set_sizes(H5D_t *dset) uint64_t chunk_size; /* Size of chunk in bytes */ unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */ unsigned u; /* Iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -823,18 +783,19 @@ H5D__chunk_set_sizes(H5D_t *dset) dset->shared->layout.u.chunk.ndims++; /* Set the last dimension of the chunk size to the size of the datatype */ - dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = (uint32_t)H5T_GET_SIZE(dset->shared->type); + dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = + (uint32_t)H5T_GET_SIZE(dset->shared->type); /* Compute number of bytes to use for encoding chunk dimensions */ max_enc_bytes_per_dim = 0; - for(u = 0; u < (unsigned)dset->shared->layout.u.chunk.ndims; u++) { - unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ + for (u = 0; u < (unsigned)dset->shared->layout.u.chunk.ndims; u++) { + unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ /* Get encoded size of dim, in bytes */ enc_bytes_per_dim = (H5VM_log2_gen(dset->shared->layout.u.chunk.dim[u]) + 8) / 8; /* Check if this is the largest value so far */ - if(enc_bytes_per_dim > max_enc_bytes_per_dim) + if (enc_bytes_per_dim > max_enc_bytes_per_dim) max_enc_bytes_per_dim = enc_bytes_per_dim; } /* end for */ HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8); @@ -842,12 +803,13 @@ H5D__chunk_set_sizes(H5D_t *dset) /* Compute and store the total size of a chunk */ /* (Use 64-bit value to ensure that we can detect >4GB chunks) */ - for(u = 1, chunk_size = (uint64_t)dset->shared->layout.u.chunk.dim[0]; u < dset->shared->layout.u.chunk.ndims; u++) + for (u = 1, chunk_size = (uint64_t)dset->shared->layout.u.chunk.dim[0]; + u < dset->shared->layout.u.chunk.ndims; u++) chunk_size *= (uint64_t)dset->shared->layout.u.chunk.dim[u]; /* Check for chunk larger than can be represented in 32-bits */ /* (Chunk size is encoded in 32-bit value in v1 B-tree records) */ - if(chunk_size > (uint64_t)0xffffffff) + if (chunk_size > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be < 4GB") H5_CHECKED_ASSIGN(dset->shared->layout.u.chunk.size, uint32_t, chunk_size, uint64_t); @@ -856,7 +818,6 @@ H5D__chunk_set_sizes(H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_set_sizes */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_construct * @@ -872,8 +833,8 @@ H5D__chunk_set_sizes(H5D_t *dset) static herr_t H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -882,24 +843,24 @@ H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) HDassert(dset); /* Check for invalid chunk dimension rank */ - if(0 == dset->shared->layout.u.chunk.ndims) + if (0 == dset->shared->layout.u.chunk.ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "no chunk information set?") - if(dset->shared->layout.u.chunk.ndims != dset->shared->ndims) + if (dset->shared->layout.u.chunk.ndims != dset->shared->ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dimensionality of chunks doesn't match the dataspace") /* Set chunk sizes */ - if(H5D__chunk_set_sizes(dset) < 0) + if (H5D__chunk_set_sizes(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to set chunk sizes") HDassert((unsigned)(dset->shared->layout.u.chunk.ndims) <= NELMTS(dset->shared->layout.u.chunk.dim)); /* Chunked storage is not compatible with external storage (currently) */ - if(dset->shared->dcpl_cache.efl.nused > 0) + if (dset->shared->dcpl_cache.efl.nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "external storage not supported with chunked layout") /* Sanity check dimensions */ - for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { + for (u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { /* Don't allow zero-sized chunk dimensions */ - if(0 == dset->shared->layout.u.chunk.dim[u]) + if (0 == dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be > 0, dim = %u ", u) /* @@ -907,19 +868,20 @@ H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) * the maximum dimension size. If any dimension size is zero, there * will be no such restriction. */ - if(dset->shared->curr_dims[u] && dset->shared->max_dims[u] != H5S_UNLIMITED && dset->shared->max_dims[u] < dset->shared->layout.u.chunk.dim[u]) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "chunk size must be <= maximum dimension size for fixed-sized dimensions") + if (dset->shared->curr_dims[u] && dset->shared->max_dims[u] != H5S_UNLIMITED && + dset->shared->max_dims[u] < dset->shared->layout.u.chunk.dim[u]) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "chunk size must be <= maximum dimension size for fixed-sized dimensions") } /* end for */ /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&dset->shared->layout.storage.u.chunk, TRUE) < 0) + if (H5D_chunk_idx_reset(&dset->shared->layout.storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_init * @@ -934,13 +896,13 @@ H5D__chunk_construct(H5F_t H5_ATTR_UNUSED *f, H5D_t *dset) *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) +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 */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -949,31 +911,31 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) HDassert(dset); H5D_CHUNK_STORAGE_INDEX_CHK(sc); - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID") /* Use the properties in dapl_id if they have been set, otherwise use the properties from the file */ - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots") - if(rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) + if (H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots") + if (rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) rdcc->nslots = H5F_RDCC_NSLOTS(f); - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size") - if(rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) + if (H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size") + if (rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) rdcc->nbytes_max = H5F_RDCC_NBYTES(f); - if(H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks") - if(rdcc->w0 < 0) + if (H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks") + if (rdcc->w0 < 0) rdcc->w0 = H5F_RDCC_W0(f); /* If nbytes_max or nslots is 0, set them both to 0 and avoid allocating space */ - if(!rdcc->nbytes_max || !rdcc->nslots) + if (!rdcc->nbytes_max || !rdcc->nslots) rdcc->nbytes_max = rdcc->nslots = 0; else { rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); - if(NULL == rdcc->slot) + if (NULL == rdcc->slot) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Reset any cached chunk info for this dataset */ @@ -981,21 +943,21 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) } /* end else */ /* Compute scaled dimension info, if dataset dims > 1 */ - if(dset->shared->ndims > 1) { - unsigned u; /* Local index value */ + if (dset->shared->ndims > 1) { + unsigned u; /* Local index value */ - for(u = 0; u < dset->shared->ndims; u++) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + for (u = 0; u < dset->shared->ndims; u++) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ /* Initial scaled dimension sizes */ - if(dset->shared->layout.u.chunk.dim[u] == 0) + if (dset->shared->layout.u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Round up to the next integer # of chunks, to accommodate partial chunks */ rdcc->scaled_dims[u] = (dset->shared->curr_dims[u] + dset->shared->layout.u.chunk.dim[u] - 1) / - dset->shared->layout.u.chunk.dim[u]; + dset->shared->layout.u.chunk.dim[u]; - if( !(scaled_power2up = H5VM_power2up(rdcc->scaled_dims[u])) ) + 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 */ @@ -1004,27 +966,26 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) /* Number of bits required to encode scaled dimension size */ rdcc->scaled_encode_bits[u] = H5VM_log2_gen(rdcc->scaled_power2up[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.f = f; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Allocate any indexing structures */ - if(sc->ops->init && (sc->ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) + 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") /* Set the number of chunks in dataset, etc. */ - if(H5D__chunk_set_info(dset) < 0) + if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set # of chunks for dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_init() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_space_alloc * @@ -1040,8 +1001,8 @@ H5D__chunk_init(H5F_t *f, const H5D_t * const dset, hid_t dapl_id) hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage) { - const H5O_storage_chunk_t *sc = &(storage->u.chunk); - hbool_t ret_value = FALSE; /* Return value */ + const H5O_storage_chunk_t *sc = &(storage->u.chunk); + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -1055,7 +1016,6 @@ H5D__chunk_is_space_alloc(const H5O_storage_t *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_data_cached * @@ -1079,7 +1039,6 @@ H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset) FUNC_LEAVE_NOAPI(shared_dset->cache.chunk.nused > 0) } /* end H5D__chunk_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_init * @@ -1093,17 +1052,16 @@ 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) +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) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ - htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ - unsigned f_ndims; /* The number of dimensions of the file's dataspace */ - int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ + hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ + htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ + unsigned f_ndims; /* The number of dimensions of the file's dataspace */ + int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1112,7 +1070,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf fm->nelmts = nelmts; /* Check if the memory space is scalar & make equivalent memory space */ - if((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space)) < 0) + if ((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimension number") /* Set the number of dimensions for the memory dataspace */ H5_CHECKED_ASSIGN(fm->m_ndims, unsigned, sm_ndims, int); @@ -1126,50 +1084,50 @@ 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((H5S_t *)file_space, old_offset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to normalize selection") /* Decide the number of chunks in each dimension */ - for(u = 0; u < f_ndims; u++) + for (u = 0; u < f_ndims; u++) /* Keep the size of the chunk dimensions as hsize_t for various routines */ fm->chunk_dim[u] = fm->layout->u.chunk.dim[u]; #ifdef H5_HAVE_PARALLEL /* Calculate total chunk in file map*/ fm->select_chunk = NULL; - if(io_info->using_mpi_vfd) { + if (io_info->using_mpi_vfd) { H5_CHECK_OVERFLOW(fm->layout->u.chunk.nchunks, hsize_t, size_t); - if(fm->layout->u.chunk.nchunks) - if(NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc((size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *)))) + if (fm->layout->u.chunk.nchunks) + if (NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc( + (size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - /* Initialize "last chunk" information */ - fm->last_index = (hsize_t)-1; + fm->last_index = (hsize_t)-1; fm->last_chunk_info = NULL; /* Point at the dataspaces */ fm->file_space = file_space; - fm->mem_space = mem_space; + fm->mem_space = mem_space; - if(H5D__chunk_io_init_selections(io_info, type_info, fm) < 0) + if (H5D__chunk_io_init_selections(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file and memory chunk selections") done: /* Reset the global dataspace info */ fm->file_space = NULL; - fm->mem_space = NULL; + 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 (file_space_normalized == TRUE) + if (H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < + 0) /* (Casting away const OK -QAK) */ HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_init_selections * @@ -1183,49 +1141,50 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf *------------------------------------------------------------------------- */ 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) +H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + H5D_chunk_map_t *fm) { - 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC /* Special case for only one element in selection */ /* (usually appending a record) */ - if(fm->nelmts == 1 + if (fm->nelmts == 1 #ifdef H5_HAVE_PARALLEL - && !(io_info->using_mpi_vfd) + && !(io_info->using_mpi_vfd) #endif /* H5_HAVE_PARALLEL */ - && H5S_SEL_ALL != H5S_GET_SELECT_TYPE(fm->file_space)) { + && H5S_SEL_ALL != H5S_GET_SELECT_TYPE(fm->file_space)) { /* Initialize skip list for chunk selections */ fm->sel_chunks = NULL; fm->use_single = TRUE; /* Initialize single chunk dataspace */ - if(NULL == dataset->shared->cache.chunk.single_space) { + if (NULL == dataset->shared->cache.chunk.single_space) { /* Make a copy of the dataspace for the dataset */ - if((dataset->shared->cache.chunk.single_space = H5S_copy(fm->file_space, TRUE, FALSE)) == NULL) + if ((dataset->shared->cache.chunk.single_space = H5S_copy(fm->file_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space") /* Resize chunk's dataspace dimensions to size of chunk */ - if(H5S_set_extent_real(dataset->shared->cache.chunk.single_space, fm->chunk_dim) < 0) + if (H5S_set_extent_real(dataset->shared->cache.chunk.single_space, fm->chunk_dim) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust chunk dimensions") /* Set the single chunk dataspace to 'all' selection */ - if(H5S_select_all(dataset->shared->cache.chunk.single_space, TRUE) < 0) + if (H5S_select_all(dataset->shared->cache.chunk.single_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to set all selection") } /* end if */ fm->single_space = dataset->shared->cache.chunk.single_space; HDassert(fm->single_space); /* Allocate the single chunk information */ - if(NULL == dataset->shared->cache.chunk.single_chunk_info) - if(NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == dataset->shared->cache.chunk.single_chunk_info) + if (NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") fm->single_chunk_info = dataset->shared->cache.chunk.single_chunk_info; HDassert(fm->single_chunk_info); @@ -1234,15 +1193,16 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ fm->mchunk_tmpl = NULL; /* Set up chunk mapping for single element */ - if(H5D__create_chunk_map_single(fm, io_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create chunk selections for single element") + if (H5D__create_chunk_map_single(fm, io_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to create chunk selections for single element") } /* end if */ else { - hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */ + hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */ /* Initialize skip list for chunk selections */ - if(NULL == dataset->shared->cache.chunk.sel_chunks) - if(NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL))) + if (NULL == dataset->shared->cache.chunk.sel_chunks) + if (NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for chunk selections") fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks; HDassert(fm->sel_chunks); @@ -1251,38 +1211,38 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ fm->use_single = FALSE; /* Get type of selection on disk & in memory */ - if((fm->fsel_type = H5S_GET_SELECT_TYPE(fm->file_space)) < H5S_SEL_NONE) + if ((fm->fsel_type = H5S_GET_SELECT_TYPE(fm->file_space)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") - if((fm->msel_type = H5S_GET_SELECT_TYPE(fm->mem_space)) < H5S_SEL_NONE) + if ((fm->msel_type = H5S_GET_SELECT_TYPE(fm->mem_space)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") /* If the selection is NONE or POINTS, set the flag to FALSE */ - if(fm->fsel_type == H5S_SEL_POINTS || fm->fsel_type == H5S_SEL_NONE) + if (fm->fsel_type == H5S_SEL_POINTS || fm->fsel_type == H5S_SEL_NONE) sel_hyper_flag = FALSE; else sel_hyper_flag = TRUE; /* Check if file selection is a not a hyperslab selection */ - if(sel_hyper_flag) { + if (sel_hyper_flag) { /* Build the file selection for each chunk */ - if(H5S_SEL_ALL == fm->fsel_type) { - if(H5D__create_chunk_file_map_all(fm, io_info) < 0) + if (H5S_SEL_ALL == fm->fsel_type) { + if (H5D__create_chunk_file_map_all(fm, io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end if */ else { /* Sanity check */ HDassert(fm->fsel_type == H5S_SEL_HYPERSLABS); - if(H5D__create_chunk_file_map_hyper(fm, io_info) < 0) + if (H5D__create_chunk_file_map_hyper(fm, io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end else */ - } /* end if */ + } /* end if */ else { - H5S_sel_iter_op_t iter_op; /* Operator for iteration */ - H5D_chunk_file_iter_ud_t udata; /* User data for iteration */ + H5S_sel_iter_op_t iter_op; /* Operator for iteration */ + H5D_chunk_file_iter_ud_t udata; /* User data for iteration */ /* Create temporary datatypes for selection iteration */ - if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) + if (NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") /* Initialize the user data */ @@ -1291,89 +1251,89 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ udata.io_info = io_info; #endif /* H5_HAVE_PARALLEL */ - iter_op.op_type = H5S_SEL_ITER_OP_LIB; + iter_op.op_type = H5S_SEL_ITER_OP_LIB; iter_op.u.lib_op = H5D__chunk_file_cb; /* Spaces might not be the same shape, iterate over the file selection directly */ - if(H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, &udata) < 0) + if (H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") /* Reset "last chunk" info */ - fm->last_index = (hsize_t)-1; + fm->last_index = (hsize_t)-1; fm->last_chunk_info = NULL; } /* end else */ /* Build the memory selection for each chunk */ - if(sel_hyper_flag && H5S_SELECT_SHAPE_SAME(fm->file_space, fm->mem_space) == TRUE) { + if (sel_hyper_flag && H5S_SELECT_SHAPE_SAME(fm->file_space, fm->mem_space) == TRUE) { /* Reset chunk template information */ fm->mchunk_tmpl = NULL; /* If the selections are the same shape, use the file chunk information * to generate the memory chunk information quickly. */ - if(H5D__create_chunk_mem_map_hyper(fm) < 0) + if (H5D__create_chunk_mem_map_hyper(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end if */ - else if(sel_hyper_flag && fm->f_ndims == 1 && fm->m_ndims == 1 && - H5S_SELECT_IS_REGULAR(fm->mem_space) && H5S_SELECT_IS_SINGLE(fm->mem_space)) { - if(H5D__create_chunk_mem_map_1d(fm) < 0) + else if (sel_hyper_flag && fm->f_ndims == 1 && fm->m_ndims == 1 && + H5S_SELECT_IS_REGULAR(fm->mem_space) && H5S_SELECT_IS_SINGLE(fm->mem_space)) { + if (H5D__create_chunk_mem_map_1d(fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create file chunk selections") } /* end else-if */ else { - H5S_sel_iter_op_t iter_op; /* Operator for iteration */ - size_t elmt_size; /* Memory datatype size */ + H5S_sel_iter_op_t iter_op; /* Operator for iteration */ + size_t elmt_size; /* Memory datatype size */ /* Make a copy of equivalent memory space */ - if((tmp_mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((tmp_mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* De-select the mem space copy */ - if(H5S_select_none(tmp_mspace) < 0) + if (H5S_select_none(tmp_mspace) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select memory space") /* Save chunk template information */ fm->mchunk_tmpl = tmp_mspace; /* Create temporary datatypes for selection iteration */ - if(!file_type) - if(NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) + if (!file_type) + if (NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") /* Create selection iterator for memory selection */ - if(0 == (elmt_size = H5T_get_size(mem_type))) + if (0 == (elmt_size = H5T_get_size(mem_type))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") - if(H5S_select_iter_init(&(fm->mem_iter), fm->mem_space, elmt_size, 0) < 0) + if (H5S_select_iter_init(&(fm->mem_iter), fm->mem_space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ - iter_op.op_type = H5S_SEL_ITER_OP_LIB; + iter_op.op_type = H5S_SEL_ITER_OP_LIB; iter_op.u.lib_op = H5D__chunk_mem_cb; /* Spaces aren't the same shape, iterate over the memory selection directly */ - if(H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, fm) < 0) + if (H5S_select_iterate(&bogus, file_type, fm->file_space, &iter_op, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end else */ - } /* end else */ + } /* end else */ done: /* Release the [potentially partially built] chunk mapping information if an error occurs */ - if(ret_value < 0) { - if(tmp_mspace && !fm->mchunk_tmpl) - if(H5S_close(tmp_mspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") - if(H5D__chunk_io_term(fm) < 0) + if (ret_value < 0) { + if (tmp_mspace && !fm->mchunk_tmpl) + if (H5S_close(tmp_mspace) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, + "can't release memory chunk dataspace template") + if (H5D__chunk_io_term(fm) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ - if(iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(file_type && (H5T_close_real(file_type) < 0)) + if (file_type && (H5T_close_real(file_type) < 0)) HDONE_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Can't free temporary datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init_selections() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_alloc * @@ -1391,13 +1351,13 @@ 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 *ret_value = NULL; /* Return value */ + 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); @@ -1405,7 +1365,6 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_mem_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_xfree * @@ -1421,12 +1380,14 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) *------------------------------------------------------------------------- */ static void * -H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline) +H5D__chunk_mem_xfree(void *chk, const void *_pline) { + const H5O_pline_t *pline = (const H5O_pline_t *)_pline; + FUNC_ENTER_STATIC_NOERR - if(chk) { - if(pline && pline->nused) + if (chk) { + if (pline && pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1435,7 +1396,6 @@ H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(NULL) } /* H5D__chunk_mem_xfree() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_realloc * @@ -1453,14 +1413,14 @@ H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline) static void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(size); HDassert(pline); - if(pline->nused > 0) + if (pline->nused > 0) ret_value = H5MM_realloc(chk, size); else ret_value = H5FL_BLK_REALLOC(chunk, chk, size); @@ -1468,7 +1428,6 @@ H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_mem_realloc() */ - /*-------------------------------------------------------------------------- NAME H5D__free_chunk_info @@ -1496,21 +1455,20 @@ H5D__free_chunk_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED * HDassert(chunk_info); /* Close the chunk's file dataspace, if it's not shared */ - if(!chunk_info->fspace_shared) + if (!chunk_info->fspace_shared) (void)H5S_close(chunk_info->fspace); else H5S_select_all(chunk_info->fspace, TRUE); /* Close the chunk's memory dataspace, if it's not shared */ - if(!chunk_info->mspace_shared && chunk_info->mspace) + if (!chunk_info->mspace_shared && chunk_info->mspace) (void)H5S_close(chunk_info->mspace); /* Free the actual chunk info */ chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); FUNC_LEAVE_NOAPI(0) -} /* H5D__free_chunk_info() */ - +} /* H5D__free_chunk_info() */ /*------------------------------------------------------------------------- * Function: H5D__create_chunk_map_single @@ -1527,16 +1485,16 @@ H5D__free_chunk_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED * static herr_t H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - H5D_chunk_info_t *chunk_info; /* Chunk information to insert into skip list */ - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk */ - 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 */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Chunk information to insert into skip list */ + hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk */ + 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1544,38 +1502,39 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t HDassert(fm->f_ndims > 0); /* Get coordinate for selection */ - if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Initialize the 'single chunk' file & memory chunk information */ - chunk_info = fm->single_chunk_info; + chunk_info = fm->single_chunk_info; chunk_info->chunk_points = 1; /* Set chunk location & hyperslab size */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) HDassert(sel_start[u] == sel_end[u]); chunk_info->scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; - coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; + coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; } /* end for */ chunk_info->scaled[fm->f_ndims] = 0; /* Calculate the index of this chunk */ - chunk_info->index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, chunk_info->scaled); + chunk_info->index = + H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, chunk_info->scaled); /* Copy selection for file's dataspace into chunk dataspace */ - if(H5S_select_copy(fm->single_space, fm->file_space, FALSE) < 0) + if (H5S_select_copy(fm->single_space, fm->file_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file selection") /* Move selection back to have correct offset in chunk */ - if(H5S_SELECT_ADJUST_U(fm->single_space, coords) < 0) + if (H5S_SELECT_ADJUST_U(fm->single_space, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") #ifdef H5_HAVE_PARALLEL /* store chunk selection information */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_info->index] = chunk_info; #endif /* H5_HAVE_PARALLEL */ @@ -1596,7 +1555,6 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_map_single() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_file_map_all * @@ -1612,24 +1570,25 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t static herr_t H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - 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 chunks) */ - hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ - hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - hsize_t chunk_index; /* "Index" of chunk */ - hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */ - hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */ - hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */ - unsigned num_partial_dims; /* Current number of partial dimensions */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 + chunks) */ + hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ + hsize_t end[H5S_MAX_RANK]; /* Final coordinates of chunk */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + hsize_t chunk_index; /* "Index" of chunk */ + hsize_t curr_partial_clip[H5S_MAX_RANK]; /* Current partial dimension sizes to clip against */ + hsize_t partial_dim_size[H5S_MAX_RANK]; /* Size of a partial dimension */ + hbool_t is_partial_dim[H5S_MAX_RANK]; /* Whether a dimension is currently a partial chunk */ + unsigned num_partial_dims; /* Current number of partial dimensions */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1640,51 +1599,51 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points = fm->nelmts; /* Get dataspace dimensions */ - if(H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(fm->file_space, file_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location, partial dimensions, etc */ num_partial_dims = 0; HDmemset(zeros, 0, sizeof(zeros)); - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) /* Set up start / end coordinates for first chunk */ scaled[u] = 0; coords[u] = 0; - end[u] = fm->chunk_dim[u] - 1; + end[u] = fm->chunk_dim[u] - 1; /* Iniitialize partial chunk dimension information */ partial_dim_size[u] = file_dims[u] % fm->chunk_dim[u]; - if(file_dims[u] < fm->chunk_dim[u]) { + if (file_dims[u] < fm->chunk_dim[u]) { curr_partial_clip[u] = partial_dim_size[u]; - is_partial_dim[u] = TRUE; + is_partial_dim[u] = TRUE; num_partial_dims++; } /* end if */ else { curr_partial_clip[u] = fm->chunk_dim[u]; - is_partial_dim[u] = FALSE; + is_partial_dim[u] = FALSE; } /* end else */ - } /* end for */ + } /* end for */ /* Set the index of this chunk */ chunk_index = 0; /* Create "temporary" chunk for selection operations (copy file space) */ - if(NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL))) + if (NULL == (tmp_fchunk = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk") /* Iterate through each chunk in the dataset */ - while(sel_points) { - H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ - hsize_t chunk_points; /* Number of elements in chunk selection */ + while (sel_points) { + H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ + hsize_t chunk_points; /* Number of elements in chunk selection */ /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ - if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ @@ -1694,22 +1653,23 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for multi-chunk I/O */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = new_chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Set the file chunk dataspace */ - if(NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE))) + if (NULL == (new_chunk_info->fspace = H5S_copy(tmp_fchunk, TRUE, FALSE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy chunk dataspace") new_chunk_info->fspace_shared = FALSE; /* If there are partial dimensions for this chunk, set the hyperslab for them */ - if(num_partial_dims > 0) - if(H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, NULL) < 0) + if (num_partial_dims > 0) + if (H5S_select_hyperslab(new_chunk_info->fspace, H5S_SELECT_SET, zeros, NULL, curr_partial_clip, + NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk selection") /* Set the memory chunk dataspace */ - new_chunk_info->mspace = NULL; + new_chunk_info->mspace = NULL; new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's scaled coordinates */ @@ -1717,7 +1677,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->scaled[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ - if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { + if (H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ @@ -1730,8 +1690,8 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points -= chunk_points; /* Advance to next chunk if we are not done */ - if(sel_points > 0) { - int curr_dim; /* Current dimension to increment */ + if (sel_points > 0) { + int curr_dim; /* Current dimension to increment */ /* Increment chunk index */ chunk_index++; @@ -1745,21 +1705,21 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t end[curr_dim] += fm->chunk_dim[curr_dim]; /* Bring chunk location back into bounds, if necessary */ - if(coords[curr_dim] >= file_dims[curr_dim]) { + if (coords[curr_dim] >= file_dims[curr_dim]) { do { /* Reset current dimension's location to 0 */ coords[curr_dim] = 0; scaled[curr_dim] = 0; - end[curr_dim] = fm->chunk_dim[curr_dim] - 1; + end[curr_dim] = fm->chunk_dim[curr_dim] - 1; /* Check for previous partial chunk in this dimension */ - if(is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) { + if (is_partial_dim[curr_dim] && end[curr_dim] < file_dims[curr_dim]) { /* Sanity check */ HDassert(num_partial_dims > 0); /* Reset partial chunk information for this dimension */ curr_partial_clip[curr_dim] = fm->chunk_dim[curr_dim]; - is_partial_dim[curr_dim] = FALSE; + is_partial_dim[curr_dim] = FALSE; num_partial_dims--; } /* end if */ @@ -1767,40 +1727,39 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t curr_dim--; /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Increment chunk location in current dimension */ coords[curr_dim] += fm->chunk_dim[curr_dim]; scaled[curr_dim]++; end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; } /* end if */ - } while(curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim])); + } while (curr_dim >= 0 && (coords[curr_dim] >= file_dims[curr_dim])); } /* end if */ /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Check for partial chunk in this dimension */ - if(!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) { + if (!is_partial_dim[curr_dim] && file_dims[curr_dim] <= end[curr_dim]) { /* Set partial chunk information for this dimension */ curr_partial_clip[curr_dim] = partial_dim_size[curr_dim]; - is_partial_dim[curr_dim] = TRUE; + is_partial_dim[curr_dim] = TRUE; num_partial_dims++; /* Sanity check */ HDassert(num_partial_dims <= fm->f_ndims); } /* end if */ - } /* end if */ - } /* end if */ - } /* end while */ + } /* end if */ + } /* end if */ + } /* end while */ done: /* Clean up */ - if(tmp_fchunk && H5S_close(tmp_fchunk) < 0) + if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_file_map_all() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_file_map_hyper * @@ -1816,23 +1775,23 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t static herr_t H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #ifndef H5_HAVE_PARALLEL - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5_HAVE_PARALLEL */ - *io_info) + *io_info) { - 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 */ - hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* Final coordinates of chunk */ - hsize_t chunk_index; /* Index of chunk */ - hsize_t start_scaled[H5S_MAX_RANK]; /* Starting scaled coordinates of selection */ - hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ - int curr_dim; /* Current dimension to increment */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ + hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ + hsize_t end[H5O_LAYOUT_NDIMS]; /* Final coordinates of chunk */ + hsize_t chunk_index; /* Index of chunk */ + hsize_t start_scaled[H5S_MAX_RANK]; /* Starting scaled coordinates of selection */ + hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ + int curr_dim; /* Current dimension to increment */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1843,48 +1802,50 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points = fm->nelmts; /* Get bounding box for selection (to reduce the number of chunks to iterate over) */ - if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location & hyperslab size */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Validate this chunk dimension */ - if(fm->layout->u.chunk.dim[u] == 0) + if (fm->layout->u.chunk.dim[u] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", u) scaled[u] = start_scaled[u] = sel_start[u] / fm->layout->u.chunk.dim[u]; coords[u] = start_coords[u] = scaled[u] * fm->layout->u.chunk.dim[u]; - end[u] = (coords[u] + fm->chunk_dim[u]) - 1; + end[u] = (coords[u] + fm->chunk_dim[u]) - 1; } /* end for */ /* Calculate the index of this chunk */ chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled); /* Iterate through each chunk in the dataset */ - while(sel_points) { + 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 */ + 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 */ /* Create dataspace for chunk, 'AND'ing the overall selection with * the current chunk. */ - if(H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, &tmp_fchunk) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to combine file space selection with chunk block") + if (H5S_combine_hyperslab(fm->file_space, H5S_SELECT_AND, coords, NULL, fm->chunk_dim, NULL, + &tmp_fchunk) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, + "unable to combine file space selection with chunk block") /* Resize chunk's dataspace dimensions to size of chunk */ - if(H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0) + if (H5S_set_extent_real(tmp_fchunk, fm->chunk_dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk dimensions") /* Move selection back to have correct offset in chunk */ - if(H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) + if (H5S_SELECT_ADJUST_U(tmp_fchunk, coords) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ - if(NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) + if (NULL == (new_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ @@ -1894,17 +1855,17 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for multi-chunk I/O */ - if(io_info->using_mpi_vfd) + if (io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = new_chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Set the file chunk dataspace */ - new_chunk_info->fspace = tmp_fchunk; + new_chunk_info->fspace = tmp_fchunk; new_chunk_info->fspace_shared = FALSE; - tmp_fchunk = NULL; + tmp_fchunk = NULL; /* Set the memory chunk dataspace */ - new_chunk_info->mspace = NULL; + new_chunk_info->mspace = NULL; new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's scaled coordinates */ @@ -1912,7 +1873,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->scaled[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ - if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { + if (H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ @@ -1925,7 +1886,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t sel_points -= chunk_points; /* Leave if we are done */ - if(sel_points == 0) + if (sel_points == 0) HGOTO_DONE(SUCCEED) } /* end if */ @@ -1941,40 +1902,40 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t scaled[curr_dim]++; /* Bring chunk location back into bounds, if necessary */ - if(coords[curr_dim] > sel_end[curr_dim]) { + if (coords[curr_dim] > sel_end[curr_dim]) { do { /* Reset current dimension's location to 0 */ scaled[curr_dim] = start_scaled[curr_dim]; - coords[curr_dim] = start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ + coords[curr_dim] = + start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; /* Decrement current dimension */ curr_dim--; /* Check for valid current dim */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Increment chunk location in current dimension */ scaled[curr_dim]++; coords[curr_dim] += fm->chunk_dim[curr_dim]; end[curr_dim] = (coords[curr_dim] + fm->chunk_dim[curr_dim]) - 1; } /* end if */ - } while(curr_dim >= 0 && (coords[curr_dim] > sel_end[curr_dim])); + } while (curr_dim >= 0 && (coords[curr_dim] > sel_end[curr_dim])); /* Re-calculate the index of this chunk */ chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled); } /* end if */ - } /* end while */ + } /* end while */ done: /* Clean up on failure */ - if(ret_value < 0) - if(tmp_fchunk && H5S_close(tmp_fchunk) < 0) + if (ret_value < 0) + if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_file_map_hyper() */ - /*------------------------------------------------------------------------- * Function: H5D__create_chunk_mem_map_hyper * @@ -1994,23 +1955,23 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t 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 */ - 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 */ - hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ + 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 */ + hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ + hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(fm->f_ndims>0); + HDassert(fm->f_ndims > 0); /* Check for all I/O going to a single chunk */ - if(H5SL_count(fm->sel_chunks)==1) { + if (H5SL_count(fm->sel_chunks) == 1) { /* Get the node */ curr_node = H5SL_first(fm->sel_chunks); @@ -2027,16 +1988,16 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) } /* end if */ else { /* Get bounding box for file selection */ - if(H5S_SELECT_BOUNDS(fm->file_space, file_sel_start, file_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->file_space, file_sel_start, file_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Get bounding box for memory selection */ - if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Calculate the adjustment for memory selection from file selection */ HDassert(fm->m_ndims == fm->f_ndims); - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { H5_CHECK_OVERFLOW(file_sel_start[u], hsize_t, hssize_t); H5_CHECK_OVERFLOW(mem_sel_start[u], hsize_t, hssize_t); adjust[u] = (hssize_t)file_sel_start[u] - (hssize_t)mem_sel_start[u]; @@ -2044,37 +2005,38 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); - while(curr_node) { - hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ - hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */ - H5S_sel_type chunk_sel_type; /* Chunk's selection type */ + while (curr_node) { + hsize_t coords[H5S_MAX_RANK]; /* Current coordinates of chunk */ + hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */ + H5S_sel_type chunk_sel_type; /* Chunk's selection type */ /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); HDassert(chunk_info); /* Compute the chunk coordinates from the scaled coordinates */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords[u] = chunk_info->scaled[u] * fm->layout->u.chunk.dim[u]; /* Copy the information */ /* Copy the memory dataspace */ - if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") /* Get the chunk's selection type */ - if((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE) + if ((chunk_sel_type = H5S_GET_SELECT_TYPE(chunk_info->fspace)) < H5S_SEL_NONE) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to get type of selection") /* Set memory selection for "all" chunk selections */ - if(H5S_SEL_ALL == chunk_sel_type) { + if (H5S_SEL_ALL == chunk_sel_type) { /* Adjust the chunk coordinates */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords[u] = (hsize_t)((hssize_t)coords[u] - adjust[u]); /* Set to same shape as chunk */ - if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, NULL) < 0) + if (H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, coords, NULL, fm->chunk_dim, + NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection") } /* end if */ else { @@ -2082,31 +2044,30 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HDassert(H5S_SEL_HYPERSLABS == chunk_sel_type); /* Copy the file chunk's selection */ - if(H5S_SELECT_COPY(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) + if (H5S_SELECT_COPY(chunk_info->mspace, chunk_info->fspace, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection") /* Compute the adjustment for this chunk */ - for(u = 0; u < fm->f_ndims; u++) { + for (u = 0; u < fm->f_ndims; u++) { /* Compensate for the chunk offset */ H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t); chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; } /* end for */ /* Adjust the selection */ - if(H5S_SELECT_ADJUST_S(chunk_info->mspace, chunk_adjust) < 0) + if (H5S_SELECT_ADJUST_S(chunk_info->mspace, chunk_adjust) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection") } /* end else */ /* Get the next chunk node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_mem_map_hyper() */ - /*------------------------------------------------------------------------- * Function: H5D__create_mem_map_1d * @@ -2123,17 +2084,17 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ + H5SL_node_t * curr_node; /* Current node in skip list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(fm->f_ndims>0); + HDassert(fm->f_ndims > 0); /* Check for all I/O going to a single chunk */ - if(H5SL_count(fm->sel_chunks)==1) { + if (H5SL_count(fm->sel_chunks) == 1) { /* Get the node */ curr_node = H5SL_first(fm->sel_chunks); @@ -2149,31 +2110,32 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) chunk_info->mspace_shared = TRUE; } /* end if */ else { - hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t mem_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 */ + hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ HDassert(fm->m_ndims == 1); - if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) + if (H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); - while(curr_node) { - hsize_t chunk_points; /* Number of elements in chunk selection */ - hsize_t tmp_count = 1; + while (curr_node) { + hsize_t chunk_points; /* Number of elements in chunk selection */ + hsize_t tmp_count = 1; /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); HDassert(chunk_info); /* Copy the memory dataspace */ - if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) + if ((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") chunk_points = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, &chunk_points) < 0) + if (H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, + &chunk_points) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection") mem_sel_start[0] += chunk_points; @@ -2181,13 +2143,12 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) /* Get the next chunk node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_mem_map_1d() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_file_cb * @@ -2202,24 +2163,26 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_udata) +H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, + 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 */ - 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 */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Calculate the index of this chunk */ - chunk_index = H5VM_chunk_index_scaled(ndims, coords, fm->layout->u.chunk.dim, fm->layout->u.chunk.down_chunks, scaled); + chunk_index = H5VM_chunk_index_scaled(ndims, coords, fm->layout->u.chunk.dim, + fm->layout->u.chunk.down_chunks, scaled); /* Find correct chunk in file & memory skip list */ - if(chunk_index==fm->last_index) { + if (chunk_index == fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached info to operate on. */ @@ -2230,37 +2193,37 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) { - H5S_t *fspace; /* Memory chunk's dataspace */ + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) { + H5S_t *fspace; /* Memory chunk's dataspace */ /* Allocate the file & memory chunk information */ - if (NULL==(chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) + if (NULL == (chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") /* Initialize the chunk information */ /* Set the chunk index */ - chunk_info->index=chunk_index; + chunk_info->index = chunk_index; /* Create a dataspace for the chunk */ - if((fspace = H5S_create_simple(fm->f_ndims,fm->chunk_dim,NULL))==NULL) { + if ((fspace = H5S_create_simple(fm->f_ndims, fm->chunk_dim, NULL)) == NULL) { chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace for chunk") } /* end if */ /* De-select the chunk space */ - if(H5S_select_none(fspace) < 0) { + if (H5S_select_none(fspace) < 0) { (void)H5S_close(fspace); chunk_info = H5FL_FREE(H5D_chunk_info_t, chunk_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to de-select dataspace") } /* end if */ /* Set the file chunk dataspace */ - chunk_info->fspace = fspace; + chunk_info->fspace = fspace; chunk_info->fspace_shared = FALSE; /* Set the memory chunk dataspace */ - chunk_info->mspace = NULL; + chunk_info->mspace = NULL; chunk_info->mspace_shared = FALSE; /* Set the number of selected elements in chunk to zero */ @@ -2272,29 +2235,29 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, 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) { - H5D__free_chunk_info(chunk_info,NULL,NULL); - HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into skip list") + if (H5SL_insert(fm->sel_chunks, chunk_info, &chunk_info->index) < 0) { + H5D__free_chunk_info(chunk_info, NULL, NULL); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert chunk into skip list") } /* end if */ - } /* end if */ + } /* end if */ #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for collective multi-chunk I/O */ - if(udata->io_info->using_mpi_vfd) + if (udata->io_info->using_mpi_vfd) fm->select_chunk[chunk_index] = chunk_info; #endif /* H5_HAVE_PARALLEL */ /* Update the "last chunk seen" information */ - fm->last_index = chunk_index; + fm->last_index = chunk_index; fm->last_chunk_info = chunk_info; } /* end else */ /* Get the offset of the element within the chunk */ - for(u = 0; u < fm->f_ndims; u++) + for (u = 0; u < fm->f_ndims; u++) coords_in_chunk[u] = coords[u] - (scaled[u] * fm->layout->u.chunk.dim[u]); /* Add point to file selection for chunk */ - if(H5S_select_elements(chunk_info->fspace, H5S_SELECT_APPEND, (size_t)1, coords_in_chunk) < 0) + if (H5S_select_elements(chunk_info->fspace, H5S_SELECT_APPEND, (size_t)1, coords_in_chunk) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "unable to select element") /* Increment the number of elemented selected in chunk */ @@ -2304,7 +2267,6 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_cb * @@ -2319,13 +2281,14 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, *------------------------------------------------------------------------- */ 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_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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2333,7 +2296,7 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u chunk_index = H5VM_chunk_index(ndims, coords, fm->layout->u.chunk.dim, fm->layout->u.chunk.down_chunks); /* Find correct chunk in file & memory skip list */ - if(chunk_index == fm->last_index) { + if (chunk_index == fm->last_index) { /* If the chunk index is the same as the last chunk index we used, * get the cached spaces to operate on. */ @@ -2344,43 +2307,42 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u * find the chunk in the skip list. */ /* Get the chunk node from the skip list */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_index))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, H5_ITER_ERROR, "can't locate chunk in skip list") /* Check if the chunk already has a memory space */ - if(NULL == chunk_info->mspace) + if (NULL == chunk_info->mspace) /* Copy the template memory chunk dataspace */ - if(NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE))) + if (NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy file space") /* Update the "last chunk seen" information */ - fm->last_index = chunk_index; + fm->last_index = chunk_index; fm->last_chunk_info = chunk_info; } /* end else */ /* Get coordinates of selection iterator for memory */ - if(H5S_SELECT_ITER_COORDS(&fm->mem_iter, coords_in_mem) < 0) + if (H5S_SELECT_ITER_COORDS(&fm->mem_iter, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, H5_ITER_ERROR, "unable to get iterator coordinates") /* Add point to memory selection for chunk */ - if(fm->msel_type == H5S_SEL_POINTS) { - if(H5S_select_elements(chunk_info->mspace, H5S_SELECT_APPEND, (size_t)1, coords_in_mem) < 0) + if (fm->msel_type == H5S_SEL_POINTS) { + if (H5S_select_elements(chunk_info->mspace, H5S_SELECT_APPEND, (size_t)1, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, H5_ITER_ERROR, "unable to select element") } /* end if */ else { - if(H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem) < 0) + if (H5S_hyper_add_span_element(chunk_info->mspace, fm->m_ndims, coords_in_mem) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, H5_ITER_ERROR, "unable to select element") } /* end else */ /* Move memory selection iterator to next element in selection */ - if(H5S_SELECT_ITER_NEXT(&fm->mem_iter, (size_t)1) < 0) + if (H5S_SELECT_ITER_NEXT(&fm->mem_iter, (size_t)1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, H5_ITER_ERROR, "unable to move to next iterator location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_mem_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cacheable * @@ -2397,9 +2359,9 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_op) { - const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - hbool_t has_filters = FALSE; /* Whether there are filters on the chunk or not */ - htri_t ret_value = FAIL; /* Return value */ + const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ + hbool_t has_filters = FALSE; /* Whether there are filters on the chunk or not */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2410,29 +2372,26 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ /* Must bring the whole chunk in if there are any filters on the chunk. * Make sure to check if filters are on the dataset but disabled for the * chunk because it is a partial edge chunk. */ - if(dataset->shared->dcpl_cache.pline.nused > 0) { - if(dataset->shared->layout.u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + if (dataset->shared->dcpl_cache.pline.nused > 0) { + if (dataset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { has_filters = !H5D__chunk_is_partial_edge_chunk( - io_info->dset->shared->ndims, - io_info->dset->shared->layout.u.chunk.dim, - io_info->store->chunk.scaled, - io_info->dset->shared->curr_dims); + io_info->dset->shared->ndims, io_info->dset->shared->layout.u.chunk.dim, + io_info->store->chunk.scaled, io_info->dset->shared->curr_dims); } /* end if */ else has_filters = TRUE; } /* end if */ - if(has_filters) + if (has_filters) ret_value = TRUE; else { #ifdef H5_HAVE_PARALLEL - /* If MPI based VFD is used and the file is opened for write access, must - * bypass the chunk-cache scheme because other MPI processes could - * be writing to other elements in the same chunk. Do a direct - * write-through of only the elements requested. - */ - if(io_info->using_mpi_vfd && (H5F_ACC_RDWR & H5F_INTENT(dataset->oloc.file))) + /* If MPI based VFD is used and the file is opened for write access, must + * bypass the chunk-cache scheme because other MPI processes could + * be writing to other elements in the same chunk. Do a direct + * write-through of only the elements requested. + */ + if (io_info->using_mpi_vfd && (H5F_ACC_RDWR & H5F_INTENT(dataset->oloc.file))) ret_value = FALSE; else { #endif /* H5_HAVE_PARALLEL */ @@ -2441,38 +2400,39 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ * cache, just write the data to it directly. */ H5_CHECK_OVERFLOW(dataset->shared->layout.u.chunk.size, uint32_t, size_t); - if((size_t)dataset->shared->layout.u.chunk.size > dataset->shared->cache.chunk.nbytes_max) { - if(write_op && !H5F_addr_defined(caddr)) { + if ((size_t)dataset->shared->layout.u.chunk.size > dataset->shared->cache.chunk.nbytes_max) { + if (write_op && !H5F_addr_defined(caddr)) { const H5O_fill_t *fill = &(dataset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* Fill value status */ + H5D_fill_value_t fill_status; /* Fill value status */ /* Revtrieve the fill value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If the fill value needs to be written then we will need * to use the cache to write the fill value */ - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT))) + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || + fill_status == H5D_FILL_VALUE_DEFAULT))) ret_value = TRUE; else ret_value = FALSE; - } else + } + else ret_value = FALSE; - } else + } + else ret_value = TRUE; #ifdef H5_HAVE_PARALLEL } /* end else */ -#endif /* H5_HAVE_PARALLEL */ - } /* end else */ +#endif /* H5_HAVE_PARALLEL */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cacheable() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_read * @@ -2486,20 +2446,20 @@ 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) +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) { - 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 */ - 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 */ - uint32_t src_accessed_bytes = 0; /* Total accessed size in a chunk */ - hbool_t skip_missing_chunks = FALSE; /* Whether to skip missing chunks */ - herr_t ret_value = SUCCEED; /*return value */ + 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 */ + 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 */ + uint32_t src_accessed_bytes = 0; /* Total accessed size in a chunk */ + hbool_t skip_missing_chunks = FALSE; /* Whether to skip missing chunks */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC @@ -2515,69 +2475,69 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t); + H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, + uint32_t); /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ cpt_store.compact.dirty = &cpt_dirty; { - const H5O_fill_t *fill = &(io_info->dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* Fill value status */ + const H5O_fill_t *fill = &(io_info->dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_value_t fill_status; /* Fill value status */ /* Check the fill value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are never to return fill values, or if we would return them * but they aren't set, set the flag to skip missing chunks. */ - if(fill->fill_time == H5D_FILL_TIME_NEVER || - (fill->fill_time == H5D_FILL_TIME_IFSET && - fill_status != H5D_FILL_VALUE_USER_DEFINED && - fill_status != H5D_FILL_VALUE_DEFAULT)) + if (fill->fill_time == H5D_FILL_TIME_NEVER || + (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status != H5D_FILL_VALUE_USER_DEFINED && + fill_status != H5D_FILL_VALUE_DEFAULT)) skip_missing_chunks = TRUE; } /* 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_ud_t udata; /* Chunk index pass-through */ + while (chunk_node) { + H5D_chunk_info_t *chunk_info; /* Chunk information */ + H5D_chunk_ud_t udata; /* Chunk index pass-through */ /* Get the actual chunk information from the skip list node */ chunk_info = H5D_CHUNK_GET_NODE_INFO(fm, chunk_node); /* Get the info for the chunk in the file */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ 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)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); /* Check for non-existant 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 */ - htri_t cacheable; /* Whether the chunk is cacheable */ + 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 */ + htri_t cacheable; /* Whether the chunk is cacheable */ /* Set chunk's [scaled] coordinates */ io_info->store->chunk.scaled = chunk_info->scaled; /* Determine if we should use the chunk cache */ - if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) + if ((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") - if(cacheable) { + if (cacheable) { /* Load the chunk into cache and lock it. */ /* Compute # of bytes accessed in chunk */ @@ -2585,7 +2545,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, src_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->src_type_size; /* Lock the chunk into the cache */ - if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE, FALSE))) + if (NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Set up the storage buffer information for this chunk */ @@ -2594,7 +2554,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Point I/O info at contiguous I/O info for this chunk */ chk_io_info = &cpt_io_info; } /* end if */ - else if(H5F_addr_defined(udata.chunk_block.offset)) { + else if (H5F_addr_defined(udata.chunk_block.offset)) { /* Set up the storage address information for this chunk */ ctg_store.contig.dset_addr = udata.chunk_block.offset; @@ -2607,12 +2567,12 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end else */ /* Perform the actual read operation */ - if((io_info->io_ops.single_read)(chk_io_info, type_info, - (hsize_t)chunk_info->chunk_points, chunk_info->fspace, chunk_info->mspace) < 0) + if ((io_info->io_ops.single_read)(chk_io_info, type_info, (hsize_t)chunk_info->chunk_points, + chunk_info->fspace, chunk_info->mspace) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "chunked read failed") /* Release the cache lock on the chunk. */ - if(chunk && H5D__chunk_unlock(io_info, &udata, FALSE, chunk, src_accessed_bytes) < 0) + if (chunk && H5D__chunk_unlock(io_info, &udata, FALSE, chunk, src_accessed_bytes) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") } /* end if */ @@ -2624,7 +2584,6 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_read() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_write * @@ -2638,18 +2597,18 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ 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) +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) { - 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 */ - H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ - hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ - uint32_t dst_accessed_bytes = 0; /* Total accessed size in a chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ + hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ + uint32_t dst_accessed_bytes = 0; /* Total accessed size in a chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2661,15 +2620,16 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, uint32_t); + H5_CHECKED_ASSIGN(ctg_store.contig.dset_size, hsize_t, io_info->dset->shared->layout.u.chunk.size, + uint32_t); /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ @@ -2677,49 +2637,49 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* 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_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_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 */ + while (chunk_node) { + 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_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 */ /* Get the actual chunk information from the skip list node */ chunk_info = H5D_CHUNK_GET_NODE_INFO(fm, chunk_node); /* Look up the chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") /* Sanity check */ 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)); + (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; /* Determine if we should use the chunk cache */ - if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) + if ((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") - if(cacheable) { + if (cacheable) { /* Load the chunk into cache. But if the whole chunk is written, * simply allocate space instead of load the chunk. */ - hbool_t entire_chunk = TRUE; /* Whether whole chunk is selected */ + hbool_t entire_chunk = TRUE; /* Whether whole chunk is selected */ /* Compute # of bytes accessed in chunk */ H5_CHECK_OVERFLOW(type_info->dst_type_size, /*From:*/ size_t, /*To:*/ uint32_t); dst_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->dst_type_size; /* Determine if we will access all the data in the chunk */ - if(dst_accessed_bytes != ctg_store.contig.dset_size || - (chunk_info->chunk_points * type_info->src_type_size) != ctg_store.contig.dset_size || - fm->fsel_type == H5S_SEL_POINTS) + if (dst_accessed_bytes != ctg_store.contig.dset_size || + (chunk_info->chunk_points * type_info->src_type_size) != ctg_store.contig.dset_size || + fm->fsel_type == H5S_SEL_POINTS) entire_chunk = FALSE; /* Lock the chunk into the cache */ - if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk, FALSE))) + if (NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") /* Set up the storage buffer information for this chunk */ @@ -2730,22 +2690,24 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end if */ else { /* If the chunk hasn't been allocated on disk, do so now. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) { + if (!H5F_addr_defined(udata.chunk_block.offset)) { /* Compose chunked index info struct */ - idx_info.f = io_info->dset->oloc.file; - idx_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - idx_info.layout = &(io_info->dset->shared->layout.u.chunk); + idx_info.f = io_info->dset->oloc.file; + idx_info.pline = &(io_info->dset->shared->dcpl_cache.pline); + idx_info.layout = &(io_info->dset->shared->layout.u.chunk); idx_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); /* Set up the size of chunk for user data */ udata.chunk_block.length = io_info->dset->shared->layout.u.chunk.size; /* Allocate the chunk */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, chunk_info->scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") + if (H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, + chunk_info->scaled) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, + "unable to insert/resize chunk on chunk level") /* Make sure the address of the chunk is returned. */ - if(!H5F_addr_defined(udata.chunk_block.offset)) + if (!H5F_addr_defined(udata.chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "chunk address isn't defined") /* Cache the new chunk information */ @@ -2763,20 +2725,20 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, } /* end else */ /* Perform the actual write operation */ - if((io_info->io_ops.single_write)(chk_io_info, type_info, - (hsize_t)chunk_info->chunk_points, chunk_info->fspace, chunk_info->mspace) < 0) + if ((io_info->io_ops.single_write)(chk_io_info, type_info, (hsize_t)chunk_info->chunk_points, + chunk_info->fspace, chunk_info->mspace) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "chunked write failed") - /* Release the cache lock on the chunk, or insert chunk into index. */ - if(chunk) { - if(H5D__chunk_unlock(io_info, &udata, TRUE, chunk, dst_accessed_bytes) < 0) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") - } /* end if */ - else { - if(need_insert && io_info->dset->shared->layout.storage.u.chunk.ops->insert) - if((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) + /* Release the cache lock on the chunk, or insert chunk into index. */ + if (chunk) { + if (H5D__chunk_unlock(io_info, &udata, TRUE, chunk, dst_accessed_bytes) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk") + } /* end if */ + else { + if (need_insert && io_info->dset->shared->layout.storage.u.chunk.ops->insert) + if ((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") - } /* end else */ + } /* end else */ /* Advance to next chunk in list */ chunk_node = H5D_CHUNK_GET_NEXT_NODE(fm, chunk_node); @@ -2786,7 +2748,6 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_flush * @@ -2803,10 +2764,10 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, static herr_t H5D__chunk_flush(H5D_t *dset) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -2814,19 +2775,18 @@ H5D__chunk_flush(H5D_t *dset) HDassert(dset); /* Loop over all entries in the chunk cache */ - for(ent = rdcc->head; ent; ent = next) { + for (ent = rdcc->head; ent; ent = next) { next = ent->next; - if(H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) nerrors++; } /* end for */ - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_io_term * @@ -2842,12 +2802,12 @@ H5D__chunk_flush(H5D_t *dset) static herr_t H5D__chunk_io_term(const H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC /* Single element I/O vs. multiple element I/O cleanup */ - if(fm->use_single) { + if (fm->use_single) { /* Sanity checks */ HDassert(fm->sel_chunks == NULL); HDassert(fm->single_chunk_info); @@ -2859,17 +2819,17 @@ H5D__chunk_io_term(const H5D_chunk_map_t *fm) } /* end if */ else { /* Release the nodes on the list of selected chunks */ - if(fm->sel_chunks) - if(H5SL_free(fm->sel_chunks, H5D__free_chunk_info, NULL) < 0) + if (fm->sel_chunks) + if (H5SL_free(fm->sel_chunks, H5D__free_chunk_info, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTNEXT, FAIL, "can't iterate over chunks") } /* end else */ /* Free the memory chunk dataspace template */ - if(fm->mchunk_tmpl) - if(H5S_close(fm->mchunk_tmpl) < 0) + if (fm->mchunk_tmpl) + if (H5S_close(fm->mchunk_tmpl) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") #ifdef H5_HAVE_PARALLEL - if(fm->select_chunk) + if (fm->select_chunk) H5MM_xfree(fm->select_chunk); #endif /* H5_HAVE_PARALLEL */ @@ -2877,7 +2837,6 @@ H5D__chunk_io_term(const H5D_chunk_map_t *fm) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_term() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_dest * @@ -2894,12 +2853,12 @@ H5D__chunk_io_term(const H5D_chunk_map_t *fm) 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC_TAG(dset->oloc.addr) @@ -2908,36 +2867,35 @@ H5D__chunk_dest(H5D_t *dset) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Flush all the cached chunks */ - for(ent = rdcc->head; ent; ent = next) { + for (ent = rdcc->head; ent; ent = next) { next = ent->next; - if(H5D__chunk_cache_evict(dset, ent, TRUE) < 0) + if (H5D__chunk_cache_evict(dset, ent, TRUE) < 0) nerrors++; } /* end for */ /* Continue even if there are failures. */ - if(nerrors) + if (nerrors) HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") /* Release cache structures */ - if(rdcc->slot) + if (rdcc->slot) rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); HDmemset(rdcc, 0, sizeof(H5D_rdcc_t)); /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Free any index structures */ - if(sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) + if (sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__chunk_dest() */ - /*------------------------------------------------------------------------- * Function: H5D_chunk_idx_reset * @@ -2953,7 +2911,7 @@ H5D__chunk_dest(H5D_t *dset) herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2963,14 +2921,13 @@ H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) H5D_CHUNK_STORAGE_INDEX_CHK(storage); /* Reset index structures */ - if((storage->ops->reset)(storage, reset_addr) < 0) + if ((storage->ops->reset)(storage, reset_addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset chunk index info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_reset * @@ -2997,7 +2954,6 @@ H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__chunk_cinfo_cache_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_update * @@ -3025,7 +2981,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud H5MM_memcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims); last->addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(last->nbytes, uint32_t, udata->chunk_block.length, hsize_t); - last->chunk_idx = udata->chunk_idx; + last->chunk_idx = udata->chunk_idx; last->filter_mask = udata->filter_mask; /* Indicate that the cached info is valid */ @@ -3034,7 +2990,6 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__chunk_cinfo_cache_update() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cinfo_cache_found * @@ -3050,7 +3005,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udata) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3061,19 +3016,19 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda HDassert(udata->common.scaled); /* Check if the cached information is what is desired */ - if(last->valid) { - unsigned u; /* Local index variable */ + if (last->valid) { + unsigned u; /* Local index variable */ /* Check that the scaled offset is the same */ - for(u = 0; u < udata->common.layout->ndims; u++) - if(last->scaled[u] != udata->common.scaled[u]) + for (u = 0; u < udata->common.layout->ndims; u++) + if (last->scaled[u] != udata->common.scaled[u]) HGOTO_DONE(FALSE) /* Retrieve the information from the cache */ udata->chunk_block.offset = last->addr; udata->chunk_block.length = last->nbytes; - udata->chunk_idx = last->chunk_idx; - udata->filter_mask = last->filter_mask; + udata->chunk_idx = last->chunk_idx; + udata->filter_mask = last->filter_mask; /* Indicate that the data was found */ HGOTO_DONE(TRUE) @@ -3083,7 +3038,6 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_cinfo_cache_found() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_create * @@ -3102,42 +3056,42 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ HDassert(dset); HDassert(H5D_CHUNKED == dset->shared->layout.type); - HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(dset->shared->layout.u.chunk.ndims > 0 && + dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); H5D_CHUNK_STORAGE_INDEX_CHK(sc); #ifndef NDEBUG -{ - unsigned u; /* Local index variable */ + { + unsigned u; /* Local index variable */ - for(u = 0; u < dset->shared->layout.u.chunk.ndims; u++) - HDassert(dset->shared->layout.u.chunk.dim[u] > 0); -} + for (u = 0; u < dset->shared->layout.u.chunk.ndims; u++) + HDassert(dset->shared->layout.u.chunk.dim[u] > 0); + } #endif /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Create the index for the chunks */ - if((sc->ops->create)(&idx_info) < 0) + if ((sc->ops->create)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_create() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_hash_val * @@ -3153,10 +3107,10 @@ H5D__chunk_create(const H5D_t *dset /*in,out*/) static unsigned H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) { - hsize_t val; /* Intermediate value */ - unsigned ndims = shared->ndims; /* Rank of dataset */ - unsigned ret = 0; /* Value to return */ - unsigned u; /* Local index variable */ + hsize_t val; /* Intermediate value */ + unsigned ndims = shared->ndims; /* Rank of dataset */ + unsigned ret = 0; /* Value to return */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -3168,7 +3122,7 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) * other dimensions too */ val = scaled[0]; - for(u = 1; u < ndims; u++) { + for (u = 1; u < ndims; u++) { val <<= shared->cache.chunk.scaled_encode_bits[u]; val ^= scaled[u]; } /* end for */ @@ -3179,7 +3133,6 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) FUNC_LEAVE_NOAPI(ret) } /* H5D__chunk_hash_val() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_lookup * @@ -3194,14 +3147,13 @@ 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__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; /* 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? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3213,43 +3165,44 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, HDassert(udata); /* Initialize the query information about the chunk we are looking for */ - udata->common.layout = &(dset->shared->layout.u.chunk); + udata->common.layout = &(dset->shared->layout.u.chunk); udata->common.storage = sc; - udata->common.scaled = scaled; + udata->common.scaled = scaled; /* Reset information about the chunk we are looking for */ udata->chunk_block.offset = HADDR_UNDEF; udata->chunk_block.length = 0; - udata->filter_mask = 0; - udata->new_unfilt_chunk = FALSE; + udata->filter_mask = 0; + udata->new_unfilt_chunk = FALSE; /* Check for chunk in cache */ - if(dset->shared->cache.chunk.nslots > 0) { + if (dset->shared->cache.chunk.nslots > 0) { /* Determine the chunk's location in the hash table */ idx = H5D__chunk_hash_val(dset->shared, scaled); /* Get the chunk cache entry for that location */ ent = dset->shared->cache.chunk.slot[idx]; - if(ent) { - unsigned u; /* Counter */ + if (ent) { + unsigned u; /* Counter */ /* Speculatively set the 'found' flag */ found = TRUE; /* Verify that the cache entry is the correct chunk */ - for(u = 0; u < dset->shared->ndims; u++) - if(scaled[u] != ent->scaled[u]) { + for (u = 0; u < dset->shared->ndims; u++) + if (scaled[u] != ent->scaled[u]) { found = FALSE; break; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Retrieve chunk addr */ - if(found) { - udata->idx_hint = idx; + if (found) { + udata->idx_hint = idx; udata->chunk_block.offset = ent->chunk_block.offset; - udata->chunk_block.length = ent->chunk_block.length;; + udata->chunk_block.length = ent->chunk_block.length; + ; udata->chunk_idx = ent->chunk_idx; } /* end if */ else { @@ -3257,13 +3210,13 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, udata->idx_hint = UINT_MAX; /* Check for cached information */ - if(!H5D__chunk_cinfo_cache_found(&dset->shared->cache.chunk.last, udata)) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ + if (!H5D__chunk_cinfo_cache_found(&dset->shared->cache.chunk.last, udata)) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; #ifdef H5_HAVE_PARALLEL @@ -3271,57 +3224,53 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, * highly unlikely that users would read the same chunks from all * processes. */ - if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) H5CX_set_coll_metadata_read(FALSE); #endif /* H5_HAVE_PARALLEL */ /* Go get the chunk information */ - if((sc->ops->get_addr)(&idx_info, udata) < 0) + if ((sc->ops->get_addr)(&idx_info, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") - /* - * Cache the information retrieved. - * - * Note that if we are writing to the dataset in parallel and filters - * are involved, we skip caching this information as it is highly likely - * that the chunk information will be invalidated as a result of the - * filter operation (e.g. the chunk gets re-allocated to a different - * address in the file and/or gets re-allocated with a different size). - * If we were to cache this information, subsequent reads/writes would - * retrieve the invalid information and cause a variety of issues. - * - * It has been verified that in the serial library, when writing to chunks - * with the real chunk cache disabled and with filters involved, the - * functions within this file are correctly called in such a manner that - * this single chunk cache is always updated correctly. Therefore, this - * check is not needed for the serial library. - * - * This is an ugly and potentially frail check, but the - * H5D__chunk_cinfo_cache_reset() function is not currently available - * to functions outside of this file, so outside functions can not - * invalidate this single chunk cache. Even if the function were available, - * this check prevents us from doing the work of going through and caching - * each chunk in the write operation, when we're only going to invalidate - * the cache at the end of a parallel write anyway. - * - * - JTH (7/13/2018) - */ + /* + * Cache the information retrieved. + * + * Note that if we are writing to the dataset in parallel and filters + * are involved, we skip caching this information as it is highly likely + * that the chunk information will be invalidated as a result of the + * filter operation (e.g. the chunk gets re-allocated to a different + * address in the file and/or gets re-allocated with a different size). + * If we were to cache this information, subsequent reads/writes would + * retrieve the invalid information and cause a variety of issues. + * + * It has been verified that in the serial library, when writing to chunks + * with the real chunk cache disabled and with filters involved, the + * functions within this file are correctly called in such a manner that + * this single chunk cache is always updated correctly. Therefore, this + * check is not needed for the serial library. + * + * This is an ugly and potentially frail check, but the + * H5D__chunk_cinfo_cache_reset() function is not currently available + * to functions outside of this file, so outside functions can not + * invalidate this single chunk cache. Even if the function were available, + * this check prevents us from doing the work of going through and caching + * each chunk in the write operation, when we're only going to invalidate + * the cache at the end of a parallel write anyway. + * + * - JTH (7/13/2018) + */ #ifdef H5_HAVE_PARALLEL - if ( !( (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) - && (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) - && dset->shared->dcpl_cache.pline.nused - ) - ) + if (!((H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) && + (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) && dset->shared->dcpl_cache.pline.nused)) #endif H5D__chunk_cinfo_cache_update(&dset->shared->cache.chunk.last, udata); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_lookup() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_flush_entry * @@ -3340,12 +3289,12 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) { - 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 */ + 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 */ - FUNC_ENTER_STATIC_TAG(dset->oloc.addr) + FUNC_ENTER_STATIC HDassert(dset); HDassert(dset->shared); @@ -3354,42 +3303,41 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) HDassert(!ent->locked); buf = ent->chunk; - if(ent->dirty) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_ud_t udata; /* pass through B-tree */ - hbool_t must_alloc = FALSE; /* Whether the chunk must be allocated */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + if (ent->dirty) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_ud_t udata; /* pass through B-tree */ + hbool_t must_alloc = FALSE; /* Whether the chunk must be allocated */ + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* Set up user data for index callbacks */ - udata.common.layout = &dset->shared->layout.u.chunk; - udata.common.storage = sc; - udata.common.scaled = ent->scaled; + udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.storage = sc; + udata.common.scaled = ent->scaled; udata.chunk_block.offset = ent->chunk_block.offset; udata.chunk_block.length = dset->shared->layout.u.chunk.size; - udata.filter_mask = 0; - udata.chunk_idx = ent->chunk_idx; + udata.filter_mask = 0; + udata.chunk_idx = ent->chunk_idx; /* Should the chunk be filtered before writing it to disk? */ - if(dset->shared->dcpl_cache.pline.nused - && !(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t alloc = udata.chunk_block.length; /* Bytes allocated for BUF */ - size_t nbytes; /* Chunk size (in bytes) */ + if (dset->shared->dcpl_cache.pline.nused && !(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t alloc = udata.chunk_block.length; /* Bytes allocated for BUF */ + size_t nbytes; /* Chunk size (in bytes) */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + 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) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") - if(!reset) { + if (!reset) { /* * Copy the chunk to a new buffer before running it through * the pipeline because we'll want to save the original buffer * for later. */ - if(NULL == (buf = H5MM_malloc(alloc))) + if (NULL == (buf = H5MM_malloc(alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline") H5MM_memcpy(buf, ent->chunk, alloc); } /* end if */ @@ -3402,15 +3350,15 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) * even if we can't write the data to disk. */ point_of_no_return = TRUE; - ent->chunk = NULL; + ent->chunk = NULL; } /* end else */ H5_CHECKED_ASSIGN(nbytes, size_t, udata.chunk_block.length, hsize_t); - if(H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.filter_mask), - err_detect, filter_cb, &nbytes, &alloc, &buf) < 0) + if (H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.filter_mask), err_detect, + filter_cb, &nbytes, &alloc, &buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ H5_CHECKED_ASSIGN(udata.chunk_block.length, hsize_t, nbytes, size_t); @@ -3418,7 +3366,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Indicate that the chunk must be allocated */ must_alloc = TRUE; } /* end if */ - else if(!H5F_addr_defined(udata.chunk_block.offset)) { + else if (!H5F_addr_defined(udata.chunk_block.offset)) { /* Indicate that the chunk must be allocated */ must_alloc = TRUE; @@ -3426,7 +3374,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) */ ent->edge_chunk_state &= ~H5D_RDCC_NEWLY_DISABLED_FILTERS; } /* end else */ - else if(ent->edge_chunk_state & H5D_RDCC_NEWLY_DISABLED_FILTERS) { + else if (ent->edge_chunk_state & H5D_RDCC_NEWLY_DISABLED_FILTERS) { /* Chunk on disk is still filtered, must insert to allocate correct * size */ must_alloc = TRUE; @@ -3442,17 +3390,18 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Check if the chunk needs to be allocated (it also could exist already * and the chunk alloc operation could resize it) */ - if(must_alloc) { + if (must_alloc) { /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, ent->scaled) < 0) + if (H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, + ent->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Update the chunk entry's info, in case it was allocated or relocated */ @@ -3463,12 +3412,13 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) /* Write the data to the file */ HDassert(H5F_addr_defined(udata.chunk_block.offset)); H5_CHECK_OVERFLOW(udata.chunk_block.length, hsize_t, size_t); - if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.chunk_block.offset, (size_t)udata.chunk_block.length, buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, udata.chunk_block.offset, + (size_t)udata.chunk_block.length, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Insert the chunk record into the index */ - if(need_insert && sc->ops->insert) - if((sc->ops->insert)(&idx_info, &udata, dset) < 0) + if (need_insert && sc->ops->insert) + if ((sc->ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Cache the chunk's info, in case it's accessed again shortly */ @@ -3482,19 +3432,20 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) } /* end if */ /* Reset, but do not free or removed from list */ - if(reset) { + if (reset) { point_of_no_return = FALSE; - if(buf == ent->chunk) + if (buf == ent->chunk) buf = NULL; - if(ent->chunk != NULL) + if (ent->chunk != NULL) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); } /* end if */ done: /* Free the temp buffer only if it's different than the entry chunk */ - if(buf != ent->chunk) + if (buf != ent->chunk) H5MM_xfree(buf); /* @@ -3503,16 +3454,16 @@ H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) * output pipeline failed. Do not free the entry or remove it from the * list. */ - if(ret_value < 0 && point_of_no_return) - if(ent->chunk) + if (ret_value < 0 && point_of_no_return) + if (ent->chunk) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_flush_entry() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cache_evict * @@ -3529,8 +3480,8 @@ 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) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3540,37 +3491,38 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) HDassert(!ent->locked); HDassert(ent->idx < rdcc->nslots); - if(flush) { + if (flush) { /* Flush */ - if(H5D__chunk_flush_entry(dset, ent, TRUE) < 0) + if (H5D__chunk_flush_entry(dset, ent, TRUE) < 0) HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { /* Don't flush, just free chunk */ - if(ent->chunk != NULL) + if (ent->chunk != NULL) ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, - ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) ? NULL - : &(dset->shared->dcpl_cache.pline))); + ((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS) + ? NULL + : &(dset->shared->dcpl_cache.pline))); } /* end else */ /* Unlink from list */ - if(ent->prev) + if (ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; - if(ent->next) + if (ent->next) ent->next->prev = ent->prev; else rdcc->tail = ent->prev; ent->prev = ent->next = NULL; /* Unlink from temporary list */ - if(ent->tmp_prev) { + if (ent->tmp_prev) { HDassert(rdcc->tmp_head->tmp_next); ent->tmp_prev->tmp_next = ent->tmp_next; - if(ent->tmp_next) { + if (ent->tmp_next) { ent->tmp_next->tmp_prev = ent->tmp_prev; - ent->tmp_next = NULL; + ent->tmp_next = NULL; } /* end if */ ent->tmp_prev = NULL; } /* end if */ @@ -3591,7 +3543,6 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cache_evict() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_cache_prune * @@ -3609,14 +3560,14 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) static herr_t H5D__chunk_cache_prune(const H5D_t *dset, size_t size) { - const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - 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 */ - int nerrors = 0; /* Accumulated error count during preemptions */ - herr_t ret_value = SUCCEED;/* Return value */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + 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 */ + int nerrors = 0; /* Accumulated error count during preemptions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3634,71 +3585,72 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size) p[0] = rdcc->head; p[1] = NULL; - while((p[0] || p[1]) && (rdcc->nbytes_used + size) > total) { - int i; /* Local index variable */ + while ((p[0] || p[1]) && (rdcc->nbytes_used + size) > total) { + int i; /* Local index variable */ /* Introduce new pointers */ - for(i = 0; i < nmeth - 1; i++) - if(0 == w[i]) + for (i = 0; i < nmeth - 1; i++) + if (0 == w[i]) p[i + 1] = rdcc->head; /* Compute next value for each pointer */ - for(i = 0; i < nmeth; i++) + for (i = 0; i < nmeth; i++) n[i] = p[i] ? p[i]->next : NULL; /* Give each method a chance */ - for(i = 0; i < nmeth && (rdcc->nbytes_used + size) > total; i++) { - if(0 == i && p[0] && !p[0]->locked && - ((0 == p[0]->rd_count && 0 == p[0]->wr_count) || - (0 == p[0]->rd_count && dset->shared->layout.u.chunk.size == p[0]->wr_count) || - (dset->shared->layout.u.chunk.size == p[0]->rd_count && 0 == p[0]->wr_count))) { + for (i = 0; i < nmeth && (rdcc->nbytes_used + size) > total; i++) { + if (0 == i && p[0] && !p[0]->locked && + ((0 == p[0]->rd_count && 0 == p[0]->wr_count) || + (0 == p[0]->rd_count && dset->shared->layout.u.chunk.size == p[0]->wr_count) || + (dset->shared->layout.u.chunk.size == p[0]->rd_count && 0 == p[0]->wr_count))) { /* - * Method 0: Preempt entries that have been completely written - * and/or completely read but not entries that are partially - * written or partially read. - */ + * Method 0: Preempt entries that have been completely written + * and/or completely read but not entries that are partially + * written or partially read. + */ cur = p[0]; - } else if(1 == i && p[1] && !p[1]->locked) { + } + else if (1 == i && p[1] && !p[1]->locked) { /* - * Method 1: Preempt the entry without regard to - * considerations other than being locked. This is the last - * resort preemption. - */ + * Method 1: Preempt the entry without regard to + * considerations other than being locked. This is the last + * resort preemption. + */ cur = p[1]; - } else { + } + else { /* Nothing to preempt at this point */ cur = NULL; } - if(cur) { - int j; /* Local index variable */ + if (cur) { + int j; /* Local index variable */ - for(j = 0; j < nmeth; j++) { - if(p[j] == cur) + for (j = 0; j < nmeth; j++) { + if (p[j] == cur) p[j] = NULL; - if(n[j] == cur) + if (n[j] == cur) n[j] = cur->next; } /* end for */ - if(H5D__chunk_cache_evict(dset, cur, TRUE) < 0) + if (H5D__chunk_cache_evict(dset, cur, TRUE) < 0) nerrors++; } /* end if */ - } /* end for */ + } /* end for */ /* Advance pointers */ - for(i = 0; i < nmeth; i++) + for (i = 0; i < nmeth; i++) p[i] = n[i]; - for(i = 0; i < nmeth - 1; i++) + for (i = 0; i < nmeth - 1; i++) w[i] -= 1; } /* end while */ - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_cache_prune() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_lock * @@ -3727,22 +3679,23 @@ 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) +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 = &(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 */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - 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 */ - size_t chunk_size; /*size of a chunk */ + const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ + const 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 */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + 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 */ + 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 @@ -3759,7 +3712,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, H5_CHECKED_ASSIGN(chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Check if the chunk is in the cache */ - if(UINT_MAX != udata->idx_hint) { + if (UINT_MAX != udata->idx_hint) { /* Sanity check */ HDassert(udata->idx_hint < rdcc->nslots); HDassert(rdcc->slot[udata->idx_hint]); @@ -3768,13 +3721,13 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, ent = rdcc->slot[udata->idx_hint]; #ifndef NDEBUG -{ - unsigned u; /*counters */ + { + unsigned u; /*counters */ - /* Make sure this is the right chunk */ - for(u = 0; u < layout->u.chunk.ndims - 1; u++) - HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); -} + /* Make sure this is the right chunk */ + for (u = 0; u < layout->u.chunk.ndims - 1; u++) + HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); + } #endif /* NDEBUG */ /* @@ -3783,15 +3736,14 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, rdcc->stats.nhits++; /* Make adjustments if the edge chunk status changed recently */ - if(pline->nused) { + if (pline->nused) { /* If the chunk recently became an unfiltered partial edge chunk * while in cache, we must make some changes to the entry */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { /* If this flag is set then partial chunk filters must be * disabled, and the chunk must not have previously been a * partial chunk (with disabled filters) */ - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); HDassert(!(ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)); HDassert(old_pline->nused); @@ -3802,24 +3754,24 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Reallocate the chunk so H5D__chunk_mem_xfree doesn't get confused */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") H5MM_memcpy(chunk, ent->chunk, chunk_size); ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline); ent->chunk = (uint8_t *)chunk; - chunk = NULL; + chunk = NULL; /* Mark the chunk as having filters disabled as well as "newly * disabled" so it is inserted on flush */ ent->edge_chunk_state |= H5D_RDCC_DISABLE_FILTERS; ent->edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; } /* end if */ - else if(prev_unfilt_chunk) { + else if (prev_unfilt_chunk) { /* If this flag is set then partial chunk filters must be * disabled, and the chunk must have previously been a partial * chunk (with disabled filters) */ - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); HDassert((ent->edge_chunk_state & H5D_RDCC_DISABLE_FILTERS)); HDassert(pline->nused); @@ -3828,82 +3780,79 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Reallocate the chunk so H5D__chunk_mem_xfree doesn't get confused */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") H5MM_memcpy(chunk, ent->chunk, chunk_size); ent->chunk = (uint8_t *)H5D__chunk_mem_xfree(ent->chunk, old_pline); ent->chunk = (uint8_t *)chunk; - chunk = NULL; + chunk = NULL; /* Mark the chunk as having filters enabled */ - ent->edge_chunk_state &= ~(H5D_RDCC_DISABLE_FILTERS - | H5D_RDCC_NEWLY_DISABLED_FILTERS); + ent->edge_chunk_state &= ~(H5D_RDCC_DISABLE_FILTERS | H5D_RDCC_NEWLY_DISABLED_FILTERS); } /* end else */ - } /* end if */ + } /* end if */ /* * If the chunk is not at the beginning of the cache; move it backward * by one slot. This is how we implement the LRU preemption * algorithm. */ - if(ent->next) { - if(ent->next->next) + if (ent->next) { + if (ent->next->next) ent->next->next->prev = ent; else rdcc->tail = ent; ent->next->prev = ent->prev; - if(ent->prev) + if (ent->prev) ent->prev->next = ent->next; else rdcc->head = ent->next; - ent->prev = ent->next; - ent->next = ent->next->next; + ent->prev = ent->next; + ent->next = ent->next->next; ent->prev->next = ent; } /* end if */ - } /* end if */ + } /* end if */ else { - haddr_t chunk_addr; /* Address of chunk on disk */ - hsize_t chunk_alloc; /* Length of chunk on disk */ + haddr_t chunk_addr; /* Address of chunk on disk */ + hsize_t chunk_alloc; /* Length of chunk on disk */ /* Save the chunk info so the cache stays consistent */ - chunk_addr = udata->chunk_block.offset; + chunk_addr = udata->chunk_block.offset; chunk_alloc = udata->chunk_block.length; /* Check if we should disable filters on this chunk */ - if(pline->nused) { - if(udata->new_unfilt_chunk) { - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + if (pline->nused) { + if (udata->new_unfilt_chunk) { + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Disable the filters for writing */ disable_filters = TRUE; - pline = NULL; + pline = NULL; } /* end if */ - else if(prev_unfilt_chunk) { - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + else if (prev_unfilt_chunk) { + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Mark the filters as having been previously disabled (for the * chunk as currently on disk) - disable the filters for reading */ old_pline = NULL; } /* end if */ - else if(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + else if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { /* Check if this is an edge chunk */ - if(H5D__chunk_is_partial_edge_chunk(io_info->dset->shared->ndims, - layout->u.chunk.dim, io_info->store->chunk.scaled, - io_info->dset->shared->curr_dims)) { + if (H5D__chunk_is_partial_edge_chunk(io_info->dset->shared->ndims, layout->u.chunk.dim, + io_info->store->chunk.scaled, + io_info->dset->shared->curr_dims)) { /* Disable the filters for both writing and reading */ disable_filters = TRUE; - old_pline = NULL; - pline = NULL; + old_pline = NULL; + pline = NULL; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ - if(relax) { + if (relax) { /* * Not in the cache, but we're about to overwrite the whole thing * anyway, so just allocate a buffer for it but don't initialize that @@ -3912,7 +3861,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, */ rdcc->stats.nhits++; - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") /* In the case that some dataset functions look through this data, @@ -3926,65 +3875,69 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, */ /* Check if the chunk exists on disk */ - if(H5F_addr_defined(chunk_addr)) { - size_t my_chunk_alloc = chunk_alloc; /* Allocated buffer size */ - size_t buf_alloc = chunk_alloc; /* [Re-]allocated buffer size */ + if (H5F_addr_defined(chunk_addr)) { + size_t my_chunk_alloc = chunk_alloc; /* Allocated buffer size */ + size_t buf_alloc = chunk_alloc; /* [Re-]allocated buffer size */ /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ - if(NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, (udata->new_unfilt_chunk ? old_pline : pline)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") - if(H5F_block_read(dset->oloc.file, H5FD_MEM_DRAW, chunk_addr, my_chunk_alloc, chunk) < 0) + if (NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, + (udata->new_unfilt_chunk ? old_pline : pline)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") + if (H5F_shared_block_read(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, chunk_addr, + my_chunk_alloc, chunk) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk") - if(old_pline && old_pline->nused) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ + if (old_pline && old_pline->nused) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + if (H5CX_get_err_detect(&err_detect) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get error detection info") - if(H5CX_get_filter_cb(&filter_cb) < 0) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get I/O filter callback function") - if(H5Z_pipeline(old_pline, H5Z_FLAG_REVERSE, &(udata->filter_mask), - err_detect, filter_cb, &my_chunk_alloc, &buf_alloc, &chunk) < 0) + if (H5Z_pipeline(old_pline, H5Z_FLAG_REVERSE, &(udata->filter_mask), err_detect, + filter_cb, &my_chunk_alloc, &buf_alloc, &chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, NULL, "data pipeline read failed") /* Reallocate chunk if necessary */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { void *tmp_chunk = chunk; - if(NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, pline))) { + if (NULL == (chunk = H5D__chunk_mem_alloc(my_chunk_alloc, pline))) { (void)H5D__chunk_mem_xfree(tmp_chunk, old_pline); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") } /* end if */ H5MM_memcpy(chunk, tmp_chunk, chunk_size); (void)H5D__chunk_mem_xfree(tmp_chunk, old_pline); } /* end if */ - } /* end if */ + } /* end if */ /* Increment # of cache misses */ rdcc->stats.nmisses++; } /* end if */ else { - H5D_fill_value_t fill_status; + H5D_fill_value_t fill_status; /* Sanity check */ HDassert(fill->alloc_time != H5D_ALLOC_TIME_EARLY); /* Chunk size on disk isn't [likely] the same size as the final chunk * size in memory, so allocate memory big enough. */ - if(NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk") + if (NULL == (chunk = H5D__chunk_mem_alloc(chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk") - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't tell if fill value defined") - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT))) { + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || fill_status == H5D_FILL_VALUE_DEFAULT))) { /* * The chunk doesn't exist in the file. Replicate the fill * value throughout the chunk, if the fill value is defined. @@ -3992,16 +3945,16 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Initialize the fill value buffer */ /* (use the compact dataset storage buffer as the fill value buffer) */ - if(H5D__fill_init(&fb_info, chunk, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, chunk_size) < 0) + if (H5D__fill_init(&fb_info, chunk, NULL, NULL, NULL, NULL, + &dset->shared->dcpl_cache.fill, dset->shared->type, + dset->shared->type_id, (size_t)0, chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, NULL, "can't refill fill value buffer") } /* end if */ else @@ -4010,36 +3963,36 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Increment # of creations */ rdcc->stats.ninits++; } /* end else */ - } /* end else */ + } /* end else */ /* See if the chunk can be cached */ - if(rdcc->nslots > 0 && chunk_size <= rdcc->nbytes_max) { + if (rdcc->nslots > 0 && chunk_size <= rdcc->nbytes_max) { /* Calculate the index */ udata->idx_hint = H5D__chunk_hash_val(io_info->dset->shared, udata->common.scaled); /* Add the chunk to the cache only if the slot is not already locked */ ent = rdcc->slot[udata->idx_hint]; - if(!ent || !ent->locked) { + if (!ent || !ent->locked) { /* Preempt enough things from the cache to make room */ - if(ent) { - if(H5D__chunk_cache_evict(io_info->dset, ent, TRUE) < 0) + if (ent) { + if (H5D__chunk_cache_evict(io_info->dset, ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache") } /* end if */ - if(H5D__chunk_cache_prune(io_info->dset, chunk_size) < 0) + if (H5D__chunk_cache_prune(io_info->dset, chunk_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache") /* Create a new entry */ - if(NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) + if (NULL == (ent = H5FL_CALLOC(H5D_rdcc_ent_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate raw data chunk entry") ent->edge_chunk_state = disable_filters ? H5D_RDCC_DISABLE_FILTERS : 0; - if(udata->new_unfilt_chunk) + if (udata->new_unfilt_chunk) ent->edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; /* Initialize the new entry */ ent->chunk_block.offset = chunk_addr; ent->chunk_block.length = chunk_alloc; - ent->chunk_idx = udata->chunk_idx; + ent->chunk_idx = udata->chunk_idx; H5MM_memcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); H5_CHECKED_ASSIGN(ent->rd_count, uint32_t, chunk_size, size_t); H5_CHECKED_ASSIGN(ent->wr_count, uint32_t, chunk_size, size_t); @@ -4048,15 +4001,15 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Add it to the cache */ HDassert(NULL == rdcc->slot[udata->idx_hint]); rdcc->slot[udata->idx_hint] = ent; - ent->idx = udata->idx_hint; + ent->idx = udata->idx_hint; rdcc->nbytes_used += chunk_size; rdcc->nused++; /* Add it to the linked list */ - if(rdcc->tail) { + if (rdcc->tail) { rdcc->tail->next = ent; - ent->prev = rdcc->tail; - rdcc->tail = ent; + ent->prev = rdcc->tail; + rdcc->tail = ent; } /* end if */ else rdcc->head = rdcc->tail = ent; @@ -4067,16 +4020,16 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, else /* We did not add the chunk to cache */ ent = NULL; - } /* end else */ + } /* end else */ else /* No cache set up, or chunk is too large: chunk is uncacheable */ ent = NULL; } /* end else */ /* Lock the chunk into the cache */ - if(ent) { + if (ent) { HDassert(!ent->locked); ent->locked = TRUE; - chunk = ent->chunk; + chunk = ent->chunk; } /* end if */ else /* @@ -4091,18 +4044,17 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "Can't release fill buffer info") /* Release the chunk allocated, on error */ - if(!ret_value) - if(chunk) + if (!ret_value) + if (chunk) chunk = H5D__chunk_mem_xfree(chunk, pline); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_lock() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_unlock * @@ -4126,12 +4078,12 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, *------------------------------------------------------------------------- */ 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) +H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, + 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); - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout = &(io_info->dset->shared->layout); /* Dataset layout */ + const H5D_rdcc_t * rdcc = &(io_info->dset->shared->cache.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4139,7 +4091,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, HDassert(io_info); HDassert(udata); - if(UINT_MAX == udata->idx_hint) { + if (UINT_MAX == udata->idx_hint) { /* * It's not in the cache, probably because it's too big. If it's * dirty then flush it to disk. In any case, free the chunk. @@ -4147,57 +4099,57 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t is_unfiltered_edge_chunk = FALSE; /* Whether the chunk is an unfiltered edge chunk */ /* Check if we should disable filters on this chunk */ - if(udata->new_unfilt_chunk) { + if (udata->new_unfilt_chunk) { HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); is_unfiltered_edge_chunk = TRUE; } /* end if */ - else if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { + else if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) { /* Check if the chunk is an edge chunk, and disable filters if so */ is_unfiltered_edge_chunk = H5D__chunk_is_partial_edge_chunk( - io_info->dset->shared->ndims, layout->u.chunk.dim, - io_info->store->chunk.scaled, io_info->dset->shared->curr_dims); + io_info->dset->shared->ndims, layout->u.chunk.dim, io_info->store->chunk.scaled, + io_info->dset->shared->curr_dims); } /* end if */ - if(dirty) { - H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ + if (dirty) { + H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ HDmemset(&fake_ent, 0, sizeof(fake_ent)); fake_ent.dirty = TRUE; - if(is_unfiltered_edge_chunk) + if (is_unfiltered_edge_chunk) fake_ent.edge_chunk_state = H5D_RDCC_DISABLE_FILTERS; - if(udata->new_unfilt_chunk) + if (udata->new_unfilt_chunk) fake_ent.edge_chunk_state |= H5D_RDCC_NEWLY_DISABLED_FILTERS; - H5MM_memcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); + H5MM_memcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); HDassert(layout->u.chunk.size > 0); - fake_ent.chunk_idx = udata->chunk_idx; + fake_ent.chunk_idx = udata->chunk_idx; fake_ent.chunk_block.offset = udata->chunk_block.offset; fake_ent.chunk_block.length = udata->chunk_block.length; - fake_ent.chunk = (uint8_t *)chunk; + fake_ent.chunk = (uint8_t *)chunk; - if(H5D__chunk_flush_entry(io_info->dset, &fake_ent, TRUE) < 0) + if (H5D__chunk_flush_entry(io_info->dset, &fake_ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { - if(chunk) - chunk = H5D__chunk_mem_xfree(chunk, (is_unfiltered_edge_chunk ? NULL - : &(io_info->dset->shared->dcpl_cache.pline))); + if (chunk) + chunk = H5D__chunk_mem_xfree( + chunk, (is_unfiltered_edge_chunk ? NULL : &(io_info->dset->shared->dcpl_cache.pline))); } /* end else */ - } /* end if */ + } /* end if */ else { - H5D_rdcc_ent_t *ent; /* Chunk's entry in the cache */ + H5D_rdcc_ent_t *ent; /* Chunk's entry in the cache */ /* Sanity check */ - HDassert(udata->idx_hint < rdcc->nslots); - HDassert(rdcc->slot[udata->idx_hint]); - HDassert(rdcc->slot[udata->idx_hint]->chunk == chunk); + HDassert(udata->idx_hint < rdcc->nslots); + HDassert(rdcc->slot[udata->idx_hint]); + HDassert(rdcc->slot[udata->idx_hint]->chunk == chunk); /* * It's in the cache so unlock it. */ ent = rdcc->slot[udata->idx_hint]; HDassert(ent->locked); - if(dirty) { + if (dirty) { ent->dirty = TRUE; ent->wr_count -= MIN(ent->wr_count, naccessed); } /* end if */ @@ -4210,7 +4162,6 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_unlock() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocated_cb * @@ -4236,7 +4187,6 @@ H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_allocated_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocated * @@ -4254,12 +4204,12 @@ H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -4268,20 +4218,21 @@ H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + 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) + 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Iterate over the chunks */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_allocated_cb, &chunk_bytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") + if ((sc->ops->iterate)(&idx_info, H5D__chunk_allocated_cb, &chunk_bytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") /* Set number of bytes for caller */ *nbytes = chunk_bytes; @@ -4290,7 +4241,6 @@ H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_allocated() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_allocate * @@ -4306,45 +4256,50 @@ 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, hsize_t old_dim[]) +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 */ - 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 */ + 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 */ #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 */ + 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 */ - 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 */ - 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 */ - hbool_t has_unfilt_edge_chunks = FALSE; /* Whether there are partial edge chunks with disabled filters */ - hbool_t unfilt_edge_chunk_dim[H5O_LAYOUT_NDIMS]; /* Whether there are unfiltered edge chunks at the edge of each dimension */ - hsize_t edge_chunk_scaled[H5O_LAYOUT_NDIMS]; /* Offset of the unfiltered edge chunks at the edge of each dimension */ - unsigned nunfilt_edge_chunk_dims = 0; /* Number of dimensions on an edge */ - const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ +#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 */ + 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 */ + hbool_t has_unfilt_edge_chunks = FALSE; /* Whether there are partial edge chunks with disabled filters */ + hbool_t unfilt_edge_chunk_dim[H5O_LAYOUT_NDIMS]; /* Whether there are unfiltered edge chunks at the edge + of each dimension */ + hsize_t edge_chunk_scaled[H5O_LAYOUT_NDIMS]; /* Offset of the unfiltered edge chunks at the edge of each + dimension */ + unsigned nunfilt_edge_chunk_dims = 0; /* Number of dimensions on an edge */ + H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); /* Convenience variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) + FUNC_ENTER_PACKAGE /* Check args */ HDassert(dset && H5D_CHUNKED == layout->type); @@ -4352,7 +4307,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Retrieve the dataset dimensions */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in scaled chunk coordinates is always 0 */ @@ -4360,8 +4315,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* Check if any space dimensions are 0, if so we do not have to do anything */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) - if(space_dim[op_dim] == 0) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) + if (space_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -4369,23 +4324,23 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* Set the MPI-capable file driver flag */ using_mpi = TRUE; /* init chunk info stuff for collective I/O */ chunk_info.num_io = 0; - chunk_info.addr = NULL; - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + chunk_info.addr = NULL; + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /* Calculate the minimum and maximum chunk offsets in each dimension, and * determine if there are any unfiltered partial edge chunks. Note that we * assume here that all elements of space_dim are > 0. This is checked at * the top of this function. */ - for(op_dim=0; op_dim 0, dim = %u ", op_dim) min_unalloc[op_dim] = (old_dim[op_dim] + chunk_dim[op_dim] - 1) / chunk_dim[op_dim]; max_unalloc[op_dim] = (space_dim[op_dim] - 1) / chunk_dim[op_dim]; @@ -4393,13 +4348,11 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* Calculate if there are unfiltered edge chunks at the edge of this * dimension. Note the edge_chunk_scaled is uninitialized for * dimensions where unfilt_edge_chunk_dim is FALSE. Also */ - if((layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && pline->nused > 0 - && space_dim[op_dim] % chunk_dim[op_dim] != 0) { - has_unfilt_edge_chunks = TRUE; + if ((layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && pline->nused > 0 && + space_dim[op_dim] % chunk_dim[op_dim] != 0) { + has_unfilt_edge_chunks = TRUE; unfilt_edge_chunk_dim[op_dim] = TRUE; - edge_chunk_scaled[op_dim] = max_unalloc[op_dim]; + edge_chunk_scaled[op_dim] = max_unalloc[op_dim]; } /* end if */ else unfilt_edge_chunk_dim[op_dim] = FALSE; @@ -4409,7 +4362,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ H5_CHECKED_ASSIGN(orig_chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Check the dataset's fill-value status */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and @@ -4417,22 +4370,21 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ * or if there are any pipeline filters defined, * set the "should fill" flag */ - if((!full_overwrite && (fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && - (fill_status == H5D_FILL_VALUE_USER_DEFINED || - fill_status == H5D_FILL_VALUE_DEFAULT)))) - || pline->nused > 0) + if ((!full_overwrite && + (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && + (fill_status == H5D_FILL_VALUE_USER_DEFINED || fill_status == H5D_FILL_VALUE_DEFAULT)))) || + pline->nused > 0) should_fill = TRUE; /* Check if fill values should be written to chunks */ - if(should_fill) { + 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, (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) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; @@ -4445,40 +4397,42 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* (only do this in advance when the chunk info can be re-used (i.e. * it doesn't contain any non-default VL datatype fill values) */ - if(!fb_info.has_vlen_fill_type && pline->nused > 0) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t buf_size = orig_chunk_size; + if (!fb_info.has_vlen_fill_type && pline->nused > 0) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t buf_size = orig_chunk_size; /* If the dataset has disabled partial chunk filters, create a copy * of the unfiltered fill_buf to use for partial chunks */ - if(has_unfilt_edge_chunks) { - if(NULL == (unfilt_fill_buf = H5D__chunk_mem_alloc(orig_chunk_size, &def_pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") + if (has_unfilt_edge_chunks) { + if (NULL == (unfilt_fill_buf = H5D__chunk_mem_alloc(orig_chunk_size, &def_pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for raw data chunk") H5MM_memcpy(unfilt_fill_buf, fb_info.fill_buf, orig_chunk_size); } /* end if */ /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + 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) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* Push the chunk through the filters */ - if(H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &orig_chunk_size, &buf_size, &fb_info.fill_buf) < 0) + if (H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &orig_chunk_size, &buf_size, + &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(orig_chunk_size > ((size_t)0xffffffff)) + if (orig_chunk_size > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") -#endif /* H5_SIZEOF_SIZE_T > 4 */ +#endif /* H5_SIZEOF_SIZE_T > 4 */ } /* end if */ - } /* end if */ + } /* end if */ /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Loop over all chunks */ @@ -4503,113 +4457,115 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ * */ chunk_size = orig_chunk_size; - for(op_dim = 0; op_dim < space_ndims; op_dim++) { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - unsigned u; /* Local index variable */ - int i; /* Local index variable */ + for (op_dim = 0; op_dim < space_ndims; op_dim++) { + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + unsigned u; /* Local index variable */ + int i; /* Local index variable */ /* Check if allocation along this dimension is really necessary */ - if(min_unalloc[op_dim] > max_unalloc[op_dim]) + if (min_unalloc[op_dim] > max_unalloc[op_dim]) continue; else { /* Reset the chunk offset indices */ HDmemset(scaled, 0, (space_ndims * sizeof(scaled[0]))); scaled[op_dim] = min_unalloc[op_dim]; - if(has_unfilt_edge_chunks) { + if (has_unfilt_edge_chunks) { /* Initialize nunfilt_edge_chunk_dims */ nunfilt_edge_chunk_dims = 0; - for(u = 0; u < space_ndims; u++) - if(unfilt_edge_chunk_dim[u] && scaled[u] - == edge_chunk_scaled[u]) + for (u = 0; u < space_ndims; u++) + if (unfilt_edge_chunk_dim[u] && scaled[u] == edge_chunk_scaled[u]) nunfilt_edge_chunk_dims++; /* Initialize chunk_size and fill_buf */ - if(should_fill && !fb_info.has_vlen_fill_type) { + if (should_fill && !fb_info.has_vlen_fill_type) { HDassert(fb_info_init); HDassert(unfilt_fill_buf); - if(nunfilt_edge_chunk_dims) { - fill_buf = &unfilt_fill_buf; + if (nunfilt_edge_chunk_dims) { + fill_buf = &unfilt_fill_buf; chunk_size = layout->u.chunk.size; } /* end if */ else { - fill_buf = &fb_info.fill_buf; + fill_buf = &fb_info.fill_buf; chunk_size = orig_chunk_size; } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ carry = FALSE; } /* end else */ - while(!carry) { - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + while (!carry) { + hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* Look up this chunk */ - if(H5D__chunk_lookup(dset, scaled, &udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG /* None of the chunks should be allocated */ - if(H5D_CHUNK_IDX_NONE != sc->idx_type) + if (H5D_CHUNK_IDX_NONE != sc->idx_type) HDassert(!H5F_addr_defined(udata.chunk_block.offset)); /* Make sure the chunk is really in the dataset and outside the * original dimensions */ { - unsigned v; /* Local index variable */ - hbool_t outside_orig = FALSE; + unsigned v; /* Local index variable */ + hbool_t outside_orig = FALSE; - for(v = 0; v < space_ndims; v++) { + for (v = 0; v < space_ndims; v++) { HDassert((scaled[v] * chunk_dim[v]) < space_dim[v]); - if((scaled[v] * chunk_dim[v]) >= old_dim[v]) + if ((scaled[v] * chunk_dim[v]) >= old_dim[v]) outside_orig = TRUE; } /* end for */ HDassert(outside_orig); } /* end block */ -#endif /* NDEBUG */ +#endif /* NDEBUG */ /* Check for VL datatype & non-default fill value */ - if(fb_info_init && fb_info.has_vlen_fill_type) { + if (fb_info_init && fb_info.has_vlen_fill_type) { /* Sanity check */ HDassert(should_fill); HDassert(!unfilt_fill_buf); #ifdef H5_HAVE_PARALLEL - HDassert(!using_mpi); /* Can't write VL datatypes in parallel currently */ + HDassert(!using_mpi); /* Can't write VL datatypes in parallel currently */ #endif /* Check to make sure the buffer is large enough. It is * possible (though ill-advised) for the filter to shrink the * buffer. */ - if(fb_info.fill_buf_size < orig_chunk_size) { - if(NULL == (fb_info.fill_buf = H5D__chunk_mem_realloc(fb_info.fill_buf, orig_chunk_size, pline))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory reallocation failed for raw data chunk") + if (fb_info.fill_buf_size < orig_chunk_size) { + if (NULL == + (fb_info.fill_buf = H5D__chunk_mem_realloc(fb_info.fill_buf, orig_chunk_size, pline))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory reallocation failed for raw data chunk") fb_info.fill_buf_size = orig_chunk_size; } /* end if */ /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") /* Check if there are filters which need to be applied to the chunk */ - if((pline->nused > 0) && !nunfilt_edge_chunk_dims) { - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - size_t nbytes = orig_chunk_size; + if ((pline->nused > 0) && !nunfilt_edge_chunk_dims) { + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + size_t nbytes = orig_chunk_size; /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + 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) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* Push the chunk through the filters */ - if(H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &nbytes, &fb_info.fill_buf_size, &fb_info.fill_buf) < 0) + if (H5Z_pipeline(pline, 0, &filter_mask, err_detect, filter_cb, &nbytes, + &fb_info.fill_buf_size, &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ @@ -4623,36 +4579,38 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ } /* end if */ /* Initialize the chunk information */ - udata.common.layout = &layout->u.chunk; - udata.common.storage = sc; - udata.common.scaled = scaled; + udata.common.layout = &layout->u.chunk; + udata.common.storage = sc; + udata.common.scaled = scaled; udata.chunk_block.offset = HADDR_UNDEF; H5_CHECKED_ASSIGN(udata.chunk_block.length, uint32_t, chunk_size, size_t); udata.filter_mask = filter_mask; /* Allocate the chunk (with all processes) */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") + if (H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") HDassert(H5F_addr_defined(udata.chunk_block.offset)); /* Check if fill values should be written to chunks */ - if(should_fill) { + if (should_fill) { /* Sanity check */ HDassert(fb_info_init); HDassert(udata.chunk_block.length == chunk_size); #ifdef H5_HAVE_PARALLEL /* Check if this file is accessed with an MPI-capable file driver */ - if(using_mpi) { + 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)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for chunk addresses") + 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)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "memory allocation failed for chunk addresses") /* Store the chunk's address for later */ chunk_info.addr[chunk_info.num_io] = udata.chunk_block.offset; @@ -4663,62 +4621,64 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ - if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, udata.chunk_block.offset, chunk_size, *fill_buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, + udata.chunk_block.offset, chunk_size, *fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #ifdef H5_HAVE_PARALLEL } /* end else */ -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ /* Insert the chunk record into the index */ - if(need_insert && ops->insert) - if((ops->insert)(&idx_info, &udata, dset) < 0) + if (need_insert && ops->insert) + if ((ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") /* Increment indices and adjust the edge chunk state */ carry = TRUE; - for(i = ((int)space_ndims - 1); i >= 0; --i) { + for (i = ((int)space_ndims - 1); i >= 0; --i) { scaled[i]++; - if(scaled[i] > max_unalloc[i]) { - if((unsigned)i == op_dim) + if (scaled[i] > max_unalloc[i]) { + if ((unsigned)i == op_dim) scaled[i] = min_unalloc[i]; else scaled[i] = 0; /* Check if we just left the edge in this dimension */ - if(unfilt_edge_chunk_dim[i] - && edge_chunk_scaled[i] == max_unalloc[i] - && scaled[i] < edge_chunk_scaled[i]) { + if (unfilt_edge_chunk_dim[i] && edge_chunk_scaled[i] == max_unalloc[i] && + scaled[i] < edge_chunk_scaled[i]) { nunfilt_edge_chunk_dims--; - if(should_fill && nunfilt_edge_chunk_dims == 0 && !fb_info.has_vlen_fill_type) { - HDassert(!H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); - fill_buf = &fb_info.fill_buf; + if (should_fill && nunfilt_edge_chunk_dims == 0 && !fb_info.has_vlen_fill_type) { + HDassert( + !H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); + fill_buf = &fb_info.fill_buf; chunk_size = orig_chunk_size; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Check if we just entered the edge in this dimension */ - if(unfilt_edge_chunk_dim[i] && scaled[i] == edge_chunk_scaled[i]) { + if (unfilt_edge_chunk_dim[i] && scaled[i] == edge_chunk_scaled[i]) { HDassert(edge_chunk_scaled[i] == max_unalloc[i]); nunfilt_edge_chunk_dims++; - if(should_fill && nunfilt_edge_chunk_dims == 1 && !fb_info.has_vlen_fill_type) { - HDassert(H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); - fill_buf = &unfilt_fill_buf; + if (should_fill && nunfilt_edge_chunk_dims == 1 && !fb_info.has_vlen_fill_type) { + HDassert( + H5D__chunk_is_partial_edge_chunk(space_ndims, chunk_dim, scaled, space_dim)); + fill_buf = &unfilt_fill_buf; chunk_size = layout->u.chunk.size; } /* end if */ - } /* end if */ + } /* end if */ carry = FALSE; break; } /* end else */ - } /* end for */ - } /* end while(!carry) */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_unalloc so we don't allocate the same chunk twice. Also * check if this dimension started from 0 (and hence allocated all of * the chunks. */ - if(min_unalloc[op_dim] == 0) + if (min_unalloc[op_dim] == 0) break; else max_unalloc[op_dim] = min_unalloc[op_dim] - 1; @@ -4726,8 +4686,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ #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 (using_mpi && blocks_written) + if (H5D__chunk_collective_fill(dset, &chunk_info, chunk_size, fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #endif /* H5_HAVE_PARALLEL */ @@ -4736,21 +4696,20 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") /* Free the unfiltered fill value buffer */ unfilt_fill_buf = H5D__chunk_mem_xfree(unfilt_fill_buf, &def_pline); #ifdef H5_HAVE_PARALLEL - if(using_mpi && chunk_info.addr) + if (using_mpi && chunk_info.addr) H5MM_free(chunk_info.addr); #endif - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_allocate() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_update_old_edge_chunks * @@ -4770,21 +4729,24 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) { - hsize_t old_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first previously incomplete chunk in each dimension */ - hsize_t max_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* largest offset of chunks that might need to be modified in each dimension */ - hbool_t new_full_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of chunks in this dimension needs to be modified */ + hsize_t old_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first previously incomplete chunk in each + dimension */ + hsize_t max_edge_chunk_sc[H5O_LAYOUT_NDIMS]; /* largest offset of chunks that might need to be modified in + each dimension */ + hbool_t new_full_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of chunks in this dimension needs to be + 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 */ - unsigned space_ndims; /* Dataset's space rank */ - 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 */ - hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned space_ndims; /* Dataset's space rank */ + 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 */ + hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4793,11 +4755,10 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); H5D_CHUNK_STORAGE_INDEX_CHK(&layout->storage.u.chunk); HDassert(dset->shared->dcpl_cache.pline.nused > 0); - HDassert(layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + HDassert(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); /* Retrieve the dataset dimensions */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in chunk_offset is always 0 */ @@ -4805,8 +4766,8 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Check if any current dimensions are smaller than the chunk size, or if * any old dimensions are 0. If so we do not have to do anything. */ - for(op_dim=0; op_dimshared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -4821,12 +4782,12 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* * Determine the edges of the dataset which need to be modified */ - for(op_dim=0; op_dim 0, dim = %u ", op_dim) /* Calculate offset of first previously incomplete chunk in this @@ -4836,24 +4797,24 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Calculate the largest offset of chunks that might need to be * modified in this dimension */ max_edge_chunk_sc[op_dim] = MIN((old_dim[op_dim] - 1) / chunk_dim[op_dim], - MAX((space_dim[op_dim] / chunk_dim[op_dim]), 1) - 1); + MAX((space_dim[op_dim] / chunk_dim[op_dim]), 1) - 1); /* Check for old_dim aligned with chunk boundary in this dimension, if * so we do not need to modify chunks along the edge in this dimension */ - if(old_dim[op_dim] % chunk_dim[op_dim] == 0) + if (old_dim[op_dim] % chunk_dim[op_dim] == 0) continue; /* Check if the dataspace expanded enough to cause the old edge chunks * in this dimension to become full */ - if((space_dim[op_dim]/chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) + if ((space_dim[op_dim] / chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) new_full_dim[op_dim] = TRUE; } /* end for */ /* Main loop: fix old edge chunks */ - for(op_dim=0; op_dim= 0; --i) { - if((unsigned)i != op_dim) { - ++chunk_sc[i]; - if(chunk_sc[i] > (hsize_t) max_edge_chunk_sc[i]) + for (i = ((int)space_ndims - 1); i >= 0; --i) { + if ((unsigned)i != op_dim) { + ++chunk_sc[i]; + if (chunk_sc[i] > (hsize_t)max_edge_chunk_sc[i]) chunk_sc[i] = 0; else { carry = FALSE; break; } /* end else */ - } /* end if */ - } /* end for */ - } /* end while(!carry) */ + } /* end if */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_edge_chunk_sc so we don't modify the same chunk twice. * Also check if this dimension started from 0 (and hence modified all * of the old edge chunks. */ - if(old_edge_chunk_sc[op_dim] == 0) + if (old_edge_chunk_sc[op_dim] == 0) break; else --max_edge_chunk_sc[op_dim]; @@ -4938,41 +4898,41 @@ 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_info_t *chunk_info, size_t chunk_size, + const void *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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the MPI communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) + 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") /* Get the MPI rank */ - if((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Get the MPI size */ - if((mpi_size = H5F_mpi_get_size(dset->oloc.file)) < 0) + if ((mpi_size = H5F_mpi_get_size(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI size") /* Distribute evenly the number of blocks between processes. */ - if(mpi_size == 0) + 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 */ @@ -4984,18 +4944,18 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* 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); + 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)) { + if (num_blocks > 0 || (leftover && leftover > mpi_rank)) { /* 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)))) + 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)))) + 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++) { + 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)]); @@ -5005,7 +4965,7 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Make sure that the addresses in the datatype are * monotonically non-decreasing */ - if(i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) + if (i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) need_addr_sort = TRUE; } /* end for */ @@ -5013,9 +4973,9 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, * distributing. If there are, then round-robin the distribution * to processes 0 -> leftover. */ - if(leftover && leftover > mpi_rank) { + 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])) + if (blocks && (chunk_disp_array[blocks] < chunk_disp_array[blocks - 1])) need_addr_sort = TRUE; block_lens[blocks] = block_len; blocks++; @@ -5024,60 +4984,62 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Ensure that the blocks are sorted in monotonically non-decreasing * order of offset in the file. */ - if(need_addr_sort) + if (need_addr_sort) HDqsort(chunk_disp_array, blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); /* 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_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) + 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))) + 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) + 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))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } /* end if */ /* Set MPI-IO VFD properties */ /* Set MPI datatypes for operation */ - if(H5CX_set_mpi_coll_datatypes(mem_type, file_type) < 0) + if (H5CX_set_mpi_coll_datatypes(mem_type, file_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O properties") /* Get current transfer mode */ - if(H5CX_get_io_xfer_mode(&prev_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&prev_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") have_xfer_mode = TRUE; /* Set transfer mode */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) + if (H5CX_set_io_xfer_mode(H5FD_MPIO_COLLECTIVE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") /* Low-level write (collective) */ - if(H5F_block_write(dset->oloc.file, H5FD_MEM_DRAW, (haddr_t)0, (blocks) ? (size_t)1 : (size_t)0, fill_buf) < 0) + if (H5F_shared_block_write(H5F_SHARED(dset->oloc.file), H5FD_MEM_DRAW, (haddr_t)0, + (blocks) ? (size_t)1 : (size_t)0, fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") /* Barrier so processes don't race ahead */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) done: - if(have_xfer_mode) + if (have_xfer_mode) /* Set transfer mode */ - if(H5CX_set_io_xfer_mode(prev_xfer_mode) < 0) + if (H5CX_set_io_xfer_mode(prev_xfer_mode) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") /* free things */ - if(MPI_BYTE != file_type) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + if (MPI_BYTE != file_type) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(MPI_BYTE != mem_type) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + if (MPI_BYTE != mem_type) + 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_lens); @@ -5085,25 +5047,24 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_fill() */ - static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2) { MPI_Aint _addr1 = (MPI_Aint)0, _addr2 = (MPI_Aint)0; - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - _addr1 = *((const MPI_Aint *) addr1); - _addr2 = *((const MPI_Aint *) addr2); + _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) + if (diff < (MPI_Aint)0) ret_value = -1; - else if(diff > (MPI_Aint)0) + else if (diff > (MPI_Aint)0) ret_value = 1; else ret_value = 0; @@ -5116,7 +5077,6 @@ H5D__chunk_cmp_addr(const void *addr1, const void *addr2) } /* end H5D__chunk_cmp_addr() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_prune_fill * @@ -5133,21 +5093,21 @@ H5D__chunk_cmp_addr(const void *addr1, const void *addr2) 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 */ - 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 */ - 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 */ - H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ - uint32_t bytes_accessed; /* Bytes accessed in chunk */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + 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 */ + H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ + uint32_t bytes_accessed; /* Bytes accessed in chunk */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5156,44 +5116,42 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) H5_CHECKED_ASSIGN(chunk_size, size_t, layout->u.chunk.size, uint32_t); /* Get the info for the chunk in the file */ - if(H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") chk_udata.new_unfilt_chunk = new_unfilt_chunk; /* If this chunk does not exist in cache or on disk, no need to do anything */ - if(!H5F_addr_defined(chk_udata.chunk_block.offset) && UINT_MAX == chk_udata.idx_hint) + if (!H5F_addr_defined(chk_udata.chunk_block.offset) && UINT_MAX == chk_udata.idx_hint) HGOTO_DONE(SUCCEED) /* Initialize the fill value buffer, if necessary */ - if(!udata->fb_info_init) { + if (!udata->fb_info_init) { H5_CHECK_OVERFLOW(udata->elmts_per_chunk, uint32_t, size_t); - if(H5D__fill_init(&udata->fb_info, NULL, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, - dset->shared->type, dset->shared->type_id, (size_t)udata->elmts_per_chunk, - chunk_size) < 0) + if (H5D__fill_init(&udata->fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill, + dset->shared->type, dset->shared->type_id, (size_t)udata->elmts_per_chunk, + chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") udata->fb_info_init = TRUE; } /* end if */ /* Compute the # of elements to leave with existing value, in each dimension */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { count[u] = MIN(layout->u.chunk.dim[u], (udata->space_dim[u] - (scaled[u] * layout->u.chunk.dim[u]))); HDassert(count[u] > 0); } /* end for */ /* Select all elements in chunk, to begin with */ - if(H5S_select_all(udata->chunk_space, TRUE) < 0) + if (H5S_select_all(udata->chunk_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to select space") /* "Subtract out" the elements to keep */ - if(H5S_select_hyperslab(udata->chunk_space, H5S_SELECT_NOTB, udata->hyper_start, NULL, count, NULL) < 0) + if (H5S_select_hyperslab(udata->chunk_space, H5S_SELECT_NOTB, udata->hyper_start, NULL, count, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to select hyperslab") /* Lock the chunk into the cache, to get a pointer to the chunk buffer */ - if(NULL == (chunk = (void *)H5D__chunk_lock(io_info, &chk_udata, FALSE, FALSE))) + if (NULL == (chunk = (void *)H5D__chunk_lock(io_info, &chk_udata, FALSE, FALSE))) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to lock raw data chunk") - /* Fill the selection in the memory buffer */ /* Use the size of the elements in the chunk directly instead of */ /* relying on the fill.size, which might be set to 0 if there is */ @@ -5204,45 +5162,43 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) H5_CHECK_OVERFLOW(sel_nelmts, hsize_t, size_t); /* Check for VL datatype & non-default fill value */ - if(udata->fb_info.has_vlen_fill_type) + if (udata->fb_info.has_vlen_fill_type) /* Re-fill the buffer to use for this I/O operation */ - if(H5D__fill_refill_vl(&udata->fb_info, (size_t)sel_nelmts) < 0) + if (H5D__fill_refill_vl(&udata->fb_info, (size_t)sel_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") /* Allocate the chunk selection iterator */ - if(NULL == (chunk_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (chunk_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator") /* Create a selection iterator for scattering the elements to memory buffer */ - if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0) + if (H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank], 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information") chunk_iter_init = TRUE; /* Scatter the data into memory */ - if(H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk/*out*/) < 0) + if (H5D__scatter_mem(udata->fb_info.fill_buf, chunk_iter, (size_t)sel_nelmts, chunk /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") - /* 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); bytes_accessed = (uint32_t)sel_nelmts * layout->u.chunk.dim[rank]; /* Release lock on chunk */ - if(H5D__chunk_unlock(io_info, &chk_udata, TRUE, chunk, bytes_accessed) < 0) + if (H5D__chunk_unlock(io_info, &chk_udata, TRUE, chunk, bytes_accessed) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk") done: /* Release the selection iterator */ - if(chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0) + if (chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(chunk_iter) + if (chunk_iter) chunk_iter = H5FL_FREE(H5S_sel_iter_t, chunk_iter); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_prune_fill */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_prune_by_extent * @@ -5345,34 +5301,38 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) herr_t H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) { - hsize_t min_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */ - hsize_t max_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */ - hssize_t max_fill_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each dimension */ - hbool_t fill_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension needs to be filled */ - hsize_t min_partial_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first partial (or empty) chunk in each dimension */ - hbool_t new_unfilt_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension are newly unfiltered */ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - 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 */ - unsigned space_ndims; /* Dataset's space rank */ - 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 */ - 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 */ - uint32_t elmts_per_chunk; /* Elements in chunk */ - hbool_t disable_edge_filters = FALSE; /* Whether to disable filters on partial edge chunks */ - hbool_t new_unfilt_chunk = FALSE; /* Whether the chunk is newly unfiltered */ - unsigned u; /* Local index variable */ - const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t min_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of first chunk to modify in each dimension */ + hsize_t max_mod_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk to modify in each dimension */ + hssize_t max_fill_chunk_sc[H5O_LAYOUT_NDIMS]; /* Scaled offset of last chunk that might be filled in each + dimension */ + hbool_t fill_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension needs to be + filled */ + hsize_t min_partial_chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of first partial (or empty) chunk in each + dimension */ + hbool_t new_unfilt_dim[H5O_LAYOUT_NDIMS]; /* Whether the plane of edge chunks in this dimension are newly + unfiltered */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + 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 */ + unsigned space_ndims; /* Dataset's space rank */ + 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 */ + 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 */ + uint32_t elmts_per_chunk; /* Elements in chunk */ + hbool_t disable_edge_filters = FALSE; /* Whether to disable filters on partial edge chunks */ + hbool_t new_unfilt_chunk = FALSE; /* Whether the chunk is newly unfiltered */ + unsigned u; /* Local index variable */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5382,15 +5342,15 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Go get the rank & dimensions (including the element size) */ - space_dim = dset->shared->curr_dims; + space_dim = dset->shared->curr_dims; space_ndims = dset->shared->ndims; /* The last dimension in scaled is always 0 */ scaled[space_ndims] = (hsize_t)0; /* Check if any old dimensions are 0, if so we do not have to do anything */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) - if(old_dim[op_dim] == 0) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) + if (old_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); HGOTO_DONE(SUCCEED) @@ -5402,14 +5362,14 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* (also copy the chunk dimensions into 'hsize_t' array for creating dataspace) */ /* (also compute the dimensions which have been shrunk) */ elmts_per_chunk = 1; - for(u = 0; u < space_ndims; u++) { + for (u = 0; u < space_ndims; u++) { elmts_per_chunk *= layout->u.chunk.dim[u]; - chunk_dim[u] = layout->u.chunk.dim[u]; + chunk_dim[u] = layout->u.chunk.dim[u]; shrunk_dim[u] = (space_dim[u] < old_dim[u]); } /* end for */ /* Create a dataspace for a chunk & set the extent */ - if(NULL == (chunk_space = H5S_create_simple(space_ndims, chunk_dim, NULL))) + if (NULL == (chunk_space = H5S_create_simple(space_ndims, chunk_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Reset hyperslab start array */ @@ -5423,42 +5383,41 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) H5D_BUILD_IO_INFO_RD(&chk_io_info, dset, &chk_store, NULL); /* 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.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; /* Initialize the user data for the iteration */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = &layout->u.chunk; - udata.common.storage = sc; - udata.common.scaled = scaled; - udata.io_info = &chk_io_info; - udata.idx_info = &idx_info; - udata.space_dim = space_dim; - udata.shrunk_dim = shrunk_dim; + udata.common.layout = &layout->u.chunk; + udata.common.storage = sc; + udata.common.scaled = scaled; + udata.io_info = &chk_io_info; + udata.idx_info = &idx_info; + udata.space_dim = space_dim; + udata.shrunk_dim = shrunk_dim; udata.elmts_per_chunk = elmts_per_chunk; - udata.chunk_space = chunk_space; - udata.hyper_start = hyper_start; - udata_init = TRUE; + udata.chunk_space = chunk_space; + udata.hyper_start = hyper_start; + udata_init = TRUE; /* Initialize user data for removal */ - idx_udata.layout = &layout->u.chunk; + idx_udata.layout = &layout->u.chunk; idx_udata.storage = sc; /* Determine if partial edge chunk filters are disabled */ - disable_edge_filters = (layout->u.chunk.flags - & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && (idx_info.pline->nused > 0); + disable_edge_filters = (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (idx_info.pline->nused > 0); /* * Determine the chunks which need to be filled or removed */ HDmemset(min_mod_chunk_sc, 0, sizeof(min_mod_chunk_sc)); HDmemset(max_mod_chunk_sc, 0, sizeof(max_mod_chunk_sc)); - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { /* Validate this chunk dimension */ - if(chunk_dim[op_dim] == 0) + if (chunk_dim[op_dim] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", op_dim) /* Calculate the largest offset of chunks that might need to be @@ -5467,13 +5426,13 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* Calculate the largest offset of chunks that might need to be * filled in this dimension */ - if(0 == space_dim[op_dim]) + if (0 == space_dim[op_dim]) max_fill_chunk_sc[op_dim] = -1; else - max_fill_chunk_sc[op_dim] = (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1) - / chunk_dim[op_dim])); + max_fill_chunk_sc[op_dim] = + (hssize_t)(((MIN(space_dim[op_dim], old_dim[op_dim]) - 1) / chunk_dim[op_dim])); - if(shrunk_dim[op_dim]) { + if (shrunk_dim[op_dim]) { /* Calculate the smallest offset of chunks that might need to be * modified in this dimension. Note that this array contains * garbage for all dimensions which are not shrunk. These locations @@ -5481,41 +5440,41 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) min_mod_chunk_sc[op_dim] = space_dim[op_dim] / chunk_dim[op_dim]; /* Determine if we need to fill chunks in this dimension */ - if((hssize_t)min_mod_chunk_sc[op_dim] == max_fill_chunk_sc[op_dim]) { + if ((hssize_t)min_mod_chunk_sc[op_dim] == max_fill_chunk_sc[op_dim]) { fill_dim[op_dim] = TRUE; /* If necessary, check if chunks in this dimension that need to * be filled are new partial edge chunks */ - if(disable_edge_filters && old_dim[op_dim] >= (min_mod_chunk_sc[op_dim] + 1)) + if (disable_edge_filters && old_dim[op_dim] >= (min_mod_chunk_sc[op_dim] + 1)) new_unfilt_dim[op_dim] = TRUE; else new_unfilt_dim[op_dim] = FALSE; } /* end if */ else { - fill_dim[op_dim] = FALSE; + fill_dim[op_dim] = FALSE; new_unfilt_dim[op_dim] = FALSE; } /* end else */ - } /* end if */ + } /* end if */ else { - fill_dim[op_dim] = FALSE; + fill_dim[op_dim] = FALSE; new_unfilt_dim[op_dim] = FALSE; } /* end else */ /* If necessary, calculate the smallest offset of non-previously full * chunks in this dimension, so we know these chunks were previously * unfiltered */ - if(disable_edge_filters) + if (disable_edge_filters) min_partial_chunk_sc[op_dim] = old_dim[op_dim] / chunk_dim[op_dim]; } /* end for */ /* Main loop: fill or remove chunks */ - for(op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { + for (op_dim = 0; op_dim < (unsigned)space_ndims; op_dim++) { hbool_t dims_outside_fill[H5O_LAYOUT_NDIMS]; /* Dimensions in chunk offset outside fill dimensions */ - int ndims_outside_fill; /* Number of dimensions in chunk offset outside fill dimensions */ - hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ + int ndims_outside_fill; /* Number of dimensions in chunk offset outside fill dimensions */ + hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ /* Check if modification along this dimension is really necessary */ - if(!shrunk_dim[op_dim]) + if (!shrunk_dim[op_dim]) continue; else { HDassert(max_mod_chunk_sc[op_dim] >= min_mod_chunk_sc[op_dim]); @@ -5526,8 +5485,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) /* Initialize "dims_outside_fill" array */ ndims_outside_fill = 0; - for(u = 0; u < space_ndims; u++) - if((hssize_t)scaled[u] > max_fill_chunk_sc[u]) { + for (u = 0; u < space_ndims; u++) + if ((hssize_t)scaled[u] > max_fill_chunk_sc[u]) { dims_outside_fill[u] = TRUE; ndims_outside_fill++; } /* end if */ @@ -5536,101 +5495,104 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) } /* end else */ carry = FALSE; - while(!carry) { - int i; /* Local index variable */ + while (!carry) { + int i; /* Local index variable */ udata.common.scaled = scaled; - if(0 == ndims_outside_fill) { + if (0 == ndims_outside_fill) { HDassert(fill_dim[op_dim]); HDassert(scaled[op_dim] == min_mod_chunk_sc[op_dim]); /* Make sure this is an edge chunk */ - HDassert(H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, space_dim)); + HDassert( + H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, space_dim)); /* Determine if the chunk just became an unfiltered chunk */ - if(new_unfilt_dim[op_dim]) { + if (new_unfilt_dim[op_dim]) { new_unfilt_chunk = TRUE; - for(u = 0; u < space_ndims; u++) - if(scaled[u] == min_partial_chunk_sc[u]) { + for (u = 0; u < space_ndims; u++) + if (scaled[u] == min_partial_chunk_sc[u]) { new_unfilt_chunk = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ /* Make sure that, if we think this is a new unfiltered chunk, * it was previously not an edge chunk */ - HDassert(!new_unfilt_dim[op_dim] || (!new_unfilt_chunk != - !H5D__chunk_is_partial_edge_chunk(space_ndims, layout->u.chunk.dim, scaled, old_dim))); + HDassert(!new_unfilt_dim[op_dim] || + (!new_unfilt_chunk != !H5D__chunk_is_partial_edge_chunk( + space_ndims, layout->u.chunk.dim, scaled, old_dim))); HDassert(!new_unfilt_chunk || new_unfilt_dim[op_dim]); /* Fill the unused parts of the chunk */ - if(H5D__chunk_prune_fill(&udata, new_unfilt_chunk) < 0) + if (H5D__chunk_prune_fill(&udata, new_unfilt_chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write fill value") } /* end if */ else { - H5D_chunk_ud_t chk_udata; /* User data for getting chunk info */ + H5D_chunk_ud_t chk_udata; /* User data for getting chunk info */ #ifndef NDEBUG /* Make sure this chunk is really outside the new dimensions */ { hbool_t outside_dim = FALSE; - for(u = 0; u < space_ndims; u++) - if((scaled[u] * chunk_dim[u]) >= space_dim[u]) { + for (u = 0; u < space_ndims; u++) + if ((scaled[u] * chunk_dim[u]) >= space_dim[u]) { outside_dim = TRUE; break; } /* end if */ HDassert(outside_dim); } /* end block */ -#endif /* NDEBUG */ +#endif /* NDEBUG */ /* Check if the chunk exists in cache or on disk */ - if(H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) + if (H5D__chunk_lookup(dset, scaled, &chk_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk") /* Evict the entry from the cache if present, but do not flush * it to disk */ - if(UINT_MAX != chk_udata.idx_hint) - if(H5D__chunk_cache_evict(dset, rdcc->slot[chk_udata.idx_hint], FALSE) < 0) + if (UINT_MAX != chk_udata.idx_hint) + if (H5D__chunk_cache_evict(dset, rdcc->slot[chk_udata.idx_hint], FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to evict chunk") /* Remove the chunk from disk, if present */ - if(H5F_addr_defined(chk_udata.chunk_block.offset)) { + if (H5F_addr_defined(chk_udata.chunk_block.offset)) { /* Update the offset in idx_udata */ idx_udata.scaled = udata.common.scaled; /* Remove the chunk from disk */ - if((sc->ops->remove)(&idx_info, &idx_udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry from index") + if ((sc->ops->remove)(&idx_info, &idx_udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, + "unable to remove chunk entry from index") } /* end if */ - } /* end else */ + } /* end else */ /* Increment indices */ carry = TRUE; - for(i = (int)(space_ndims - 1); i >= 0; --i) { + for (i = (int)(space_ndims - 1); i >= 0; --i) { scaled[i]++; - if(scaled[i] > max_mod_chunk_sc[i]) { + if (scaled[i] > max_mod_chunk_sc[i]) { /* Left maximum dimensions, "wrap around" and check if this * dimension is no longer outside the fill dimension */ - if((unsigned)i == op_dim) { + if ((unsigned)i == op_dim) { scaled[i] = min_mod_chunk_sc[i]; - if(dims_outside_fill[i] && fill_dim[i]) { + if (dims_outside_fill[i] && fill_dim[i]) { dims_outside_fill[i] = FALSE; ndims_outside_fill--; } /* end if */ - } /* end if */ + } /* end if */ else { scaled[i] = 0; - if(dims_outside_fill[i] && max_fill_chunk_sc[i] >= 0) { + if (dims_outside_fill[i] && max_fill_chunk_sc[i] >= 0) { dims_outside_fill[i] = FALSE; ndims_outside_fill--; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Check if we just went outside the fill dimension */ - if(!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_sc[i]) { + if (!dims_outside_fill[i] && (hssize_t)scaled[i] > max_fill_chunk_sc[i]) { dims_outside_fill[i] = TRUE; ndims_outside_fill++; } /* end if */ @@ -5639,13 +5601,13 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) carry = FALSE; break; } /* end else */ - } /* end for */ - } /* end while(!carry) */ + } /* end for */ + } /* end while(!carry) */ /* Adjust max_mod_chunk_sc so we don't modify the same chunk twice. * Also check if this dimension started from 0 (and hence removed all * of the chunks). */ - if(min_mod_chunk_sc[op_dim] == 0) + if (min_mod_chunk_sc[op_dim] == 0) break; else max_mod_chunk_sc[op_dim] = min_mod_chunk_sc[op_dim] - 1; @@ -5656,10 +5618,10 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) done: /* Release resources */ - if(chunk_space && H5S_close(chunk_space) < 0) + if (chunk_space && H5S_close(chunk_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(udata_init) - if(udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) + if (udata_init) + if (udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) @@ -5683,9 +5645,9 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) static int H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ - unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ - hsize_t chunk_index; + H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ + unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ + hsize_t chunk_index; FUNC_ENTER_STATIC_NOERR @@ -5698,7 +5660,6 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_addrmap_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_addrmap * @@ -5715,11 +5676,11 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) 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 */ - 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 */ + H5D_chk_idx_info_t idx_info; /* Chunked index 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 */ FUNC_ENTER_PACKAGE @@ -5730,18 +5691,18 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) /* Set up user data for B-tree callback */ HDmemset(&udata, 0, sizeof(udata)); - udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.layout = &dset->shared->layout.u.chunk; udata.common.storage = sc; - udata.chunk_addr = chunk_addr; + udata.chunk_addr = chunk_addr; /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Iterate over chunks to build mapping of chunk addresses */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_addrmap_cb, &udata) < 0) + if ((sc->ops->iterate)(&idx_info, H5D__chunk_addrmap_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to iterate over chunk index to build address map") done: @@ -5749,7 +5710,6 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) } /* end H5D__chunk_addrmap() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_delete * @@ -5766,13 +5726,13 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) herr_t H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5O_layout_t layout; /* Dataset layout message */ - hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ - H5O_pline_t pline; /* I/O pipeline message */ - hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ - htri_t exists; /* Flag if header message of interest exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_layout_t layout; /* Dataset layout message */ + hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ + H5O_pline_t pline; /* I/O pipeline message */ + hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ + htri_t exists; /* Flag if header message of interest exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5783,10 +5743,10 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) H5D_CHUNK_STORAGE_INDEX_CHK(&storage->u.chunk); /* Check for I/O pipeline message */ - if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") - else if(exists) { - if(NULL == H5O_msg_read_oh(f, oh, H5O_PLINE_ID, &pline)) + else if (exists) { + if (NULL == H5O_msg_read_oh(f, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O pipeline message") pline_read = TRUE; } /* end else if */ @@ -5794,10 +5754,10 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) HDmemset(&pline, 0, sizeof(pline)); /* Retrieve dataset layout message */ - if((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") - else if(exists) { - if(NULL == H5O_msg_read_oh(f, oh, H5O_LAYOUT_ID, &layout)) + else if (exists) { + if (NULL == H5O_msg_read_oh(f, oh, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout message") layout_read = TRUE; } /* end else if */ @@ -5805,28 +5765,27 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "can't find layout message") /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.pline = &pline; - idx_info.layout = &layout.u.chunk; + idx_info.f = f; + idx_info.pline = &pline; + idx_info.layout = &layout.u.chunk; idx_info.storage = &storage->u.chunk; /* Delete the chunked storage information in the file */ - if((storage->u.chunk.ops->idx_delete)(&idx_info) < 0) + if ((storage->u.chunk.ops->idx_delete)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: /* Clean up any messages read in */ - if(pline_read) - if(H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) + if (pline_read) + if (H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") - if(layout_read) - if(H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if (layout_read) + if (H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_update_cache * @@ -5844,17 +5803,18 @@ 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ HDassert(dset && H5D_CHUNKED == dset->shared->layout.type); - HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(dset->shared->layout.u.chunk.ndims > 0 && + dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Check the rank */ HDassert((dset->shared->layout.u.chunk.ndims - 1) > 1); @@ -5862,25 +5822,25 @@ H5D__chunk_update_cache(H5D_t *dset) /* Add temporary entry list to rdcc */ (void)HDmemset(&tmp_head, 0, sizeof(tmp_head)); rdcc->tmp_head = &tmp_head; - tmp_tail = &tmp_head; + tmp_tail = &tmp_head; /* Recompute the index for each cached chunk that is in a dataset */ - for(ent = rdcc->head; ent; ent = next) { - unsigned old_idx; /* Previous index number */ + for (ent = rdcc->head; ent; ent = next) { + unsigned old_idx; /* Previous index number */ /* Get the pointer to the next cache entry */ next = ent->next; /* Compute the index for the chunk entry */ - old_idx = ent->idx; /* Save for later */ + old_idx = ent->idx; /* Save for later */ ent->idx = H5D__chunk_hash_val(dset->shared, ent->scaled); - if(old_idx != ent->idx) { - H5D_rdcc_ent_t *old_ent; /* Old cache entry */ + if (old_idx != ent->idx) { + H5D_rdcc_ent_t *old_ent; /* Old cache entry */ /* Check if there is already a chunk at this chunk's new location */ old_ent = rdcc->slot[ent->idx]; - if(old_ent != NULL) { + if (old_ent != NULL) { HDassert(old_ent->locked == FALSE); HDassert(old_ent->deleted == FALSE); @@ -5890,8 +5850,8 @@ H5D__chunk_update_cache(H5D_t *dset) HDassert(!old_ent->tmp_next); HDassert(!old_ent->tmp_prev); tmp_tail->tmp_next = old_ent; - old_ent->tmp_prev = tmp_tail; - tmp_tail = old_ent; + old_ent->tmp_prev = tmp_tail; + tmp_tail = old_ent; } /* end if */ /* Insert this chunk into correct location in hash table */ @@ -5900,13 +5860,13 @@ H5D__chunk_update_cache(H5D_t *dset) /* If this chunk was previously on the temporary list and therefore * not in the hash table, remove it from the temporary list. * Otherwise clear the old hash table slot. */ - if(ent->tmp_prev) { + if (ent->tmp_prev) { HDassert(tmp_head.tmp_next); HDassert(tmp_tail != &tmp_head); ent->tmp_prev->tmp_next = ent->tmp_next; - if(ent->tmp_next) { + if (ent->tmp_next) { ent->tmp_next->tmp_prev = ent->tmp_prev; - ent->tmp_next = NULL; + ent->tmp_next = NULL; } /* end if */ else { HDassert(tmp_tail == ent); @@ -5917,18 +5877,18 @@ H5D__chunk_update_cache(H5D_t *dset) else rdcc->slot[old_idx] = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* tmp_tail is no longer needed, and will be invalidated by * H5D_chunk_cache_evict anyways. */ tmp_tail = NULL; /* Evict chunks that are still on the temporary list */ - while(tmp_head.tmp_next) { + while (tmp_head.tmp_next) { ent = tmp_head.tmp_next; /* Remove the old entry from the cache */ - if(H5D__chunk_cache_evict(dset, ent, TRUE) < 0) + if (H5D__chunk_cache_evict(dset, ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") } /* end while */ @@ -5939,7 +5899,6 @@ H5D__chunk_update_cache(H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_update_cache() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_copy_cb * @@ -5956,23 +5915,23 @@ H5D__chunk_update_cache(H5D_t *dset) static int H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud3_t *udata = (H5D_chunk_it_ud3_t *)_udata; /* User data for callback */ - H5D_chunk_ud_t udata_dst; /* User data about new destination chunk */ - hbool_t is_vlen = FALSE; /* Whether datatype is variable-length */ - hbool_t fix_ref = FALSE; /* Whether to fix up references in the dest. file */ - hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ + H5D_chunk_it_ud3_t *udata = (H5D_chunk_it_ud3_t *)_udata; /* User data for callback */ + H5D_chunk_ud_t udata_dst; /* User data about new destination chunk */ + hbool_t is_vlen = FALSE; /* Whether datatype is variable-length */ + hbool_t fix_ref = FALSE; /* Whether to fix up references in the dest. file */ + 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 */ - size_t buf_size = udata->buf_size; /* Size of chunk buffer */ - const H5O_pline_t *pline = udata->pline; /* I/O pipeline for applying filters */ + 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 */ - 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 */ - int ret_value = H5_ITER_CONT; /* Return value */ + 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 */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -5981,81 +5940,85 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Check for filtered chunks */ /* Check for an edge chunk that is not filtered */ - if(pline && pline->nused) { + if (pline && pline->nused) { must_filter = TRUE; - if((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && - H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, udata->dset_dims)) + if ((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, + udata->dset_dims)) must_filter = FALSE; } /* Check parameter for type conversion */ - if(udata->do_convert) { - if(H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0) + if (udata->do_convert) { + if (H5T_detect_class(udata->dt_src, H5T_VLEN, FALSE) > 0) is_vlen = TRUE; - else if((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && (udata->file_src != udata->idx_info_dst->f)) + else if ((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && + (udata->file_src != udata->idx_info_dst->f)) fix_ref = TRUE; else HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy dataset elements") } /* end if */ /* Resize the buf if it is too small to hold the data */ - if(nbytes > buf_size) { - void *new_buf; /* New buffer for data */ + if (nbytes > buf_size) { + void *new_buf; /* New buffer for data */ /* Re-allocate memory for copying the chunk */ - if(NULL == (new_buf = H5MM_realloc(udata->buf, nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + if (NULL == (new_buf = H5MM_realloc(udata->buf, nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") udata->buf = new_buf; - if(udata->bkg) { - if(NULL == (new_buf = H5MM_realloc(udata->bkg, nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + if (udata->bkg) { + if (NULL == (new_buf = H5MM_realloc(udata->bkg, nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") udata->bkg = new_buf; - if(!udata->cpy_info->expand_ref) + if (!udata->cpy_info->expand_ref) HDmemset((uint8_t *)udata->bkg + buf_size, 0, (size_t)(nbytes - buf_size)); bkg = udata->bkg; } /* end if */ - buf = udata->buf; + buf = udata->buf; udata->buf_size = buf_size = nbytes; } /* end if */ - if(udata->chunk_in_cache && udata->chunk) { + if (udata->chunk_in_cache && udata->chunk) { HDassert(!H5F_addr_defined(chunk_rec->chunk_addr)); H5MM_memcpy(buf, udata->chunk, nbytes); udata->chunk = NULL; } else { - 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_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; /* See if the written chunk is in the chunk cache */ - if(shared_fo && shared_fo->cache.chunk.nslots > 0) { + if (shared_fo && shared_fo->cache.chunk.nslots > 0) { /* Determine the chunk's location in the hash table */ idx = H5D__chunk_hash_val(shared_fo, chunk_rec->scaled); /* Get the chunk cache entry for that location */ ent = shared_fo->cache.chunk.slot[idx]; - if(ent) { + if (ent) { /* Speculatively set the 'found' flag */ udata->chunk_in_cache = TRUE; /* Verify that the cache entry is the correct chunk */ - for(u = 0; u < shared_fo->ndims; u++) - if(chunk_rec->scaled[u] != ent->scaled[u]) { + for (u = 0; u < shared_fo->ndims; u++) + if (chunk_rec->scaled[u] != ent->scaled[u]) { udata->chunk_in_cache = FALSE; break; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ - if(udata->chunk_in_cache) { + if (udata->chunk_in_cache) { HDassert(H5F_addr_defined(chunk_rec->chunk_addr)); HDassert(H5F_addr_defined(ent->chunk_block.offset)); @@ -6064,33 +6027,36 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } else { /* read chunk data from the source file */ - if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) + if (H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") } } - /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache */ - if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { + /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache + */ + if (must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { unsigned filter_mask = chunk_rec->filter_mask; - if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0) + if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "data pipeline read failed") } /* end if */ /* Perform datatype conversion, if necessary */ - 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; - 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; - size_t reclaim_buf_size = udata->reclaim_buf_size; + 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; + 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; + size_t reclaim_buf_size = udata->reclaim_buf_size; /* Convert from source file to memory */ H5_CHECK_OVERFLOW(udata->nelmts, uint32_t, size_t); - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, + bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -6100,27 +6066,20 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, udata->nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed") /* Reclaim space from variable length data */ - if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5_ITER_ERROR, "unable to reclaim variable-length data") } /* end if */ - else if(fix_ref) { + else if (fix_ref) { /* Check for expanding references */ /* (background buffer has already been zeroed out, if not expanding) */ - if(udata->cpy_info->expand_ref) { - size_t ref_count; - size_t dt_size; - - /* Determine # of reference elements to copy */ - if((dt_size = H5T_get_size(udata->dt_src)) == 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "size must not be 0") - ref_count = nbytes / dt_size; - + if (udata->cpy_info->expand_ref) { /* Copy the reference elements */ - if(H5O_copy_expand_ref(udata->file_src, buf, udata->idx_info_dst->f, bkg, ref_count, H5T_get_ref_type(udata->dt_src), udata->cpy_info) < 0) + if (H5O_copy_expand_ref(udata->file_src, udata->tid_src, udata->dt_src, buf, nbytes, + udata->idx_info_dst->f, bkg, udata->cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy reference attribute") } /* end if */ @@ -6129,48 +6088,53 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } /* end if */ /* Set up destination chunk callback information for insertion */ - udata_dst.common.layout = udata->idx_info_dst->layout; - udata_dst.common.storage = udata->idx_info_dst->storage; - udata_dst.common.scaled = chunk_rec->scaled; + udata_dst.common.layout = udata->idx_info_dst->layout; + udata_dst.common.storage = udata->idx_info_dst->storage; + udata_dst.common.scaled = chunk_rec->scaled; udata_dst.chunk_block.offset = HADDR_UNDEF; udata_dst.chunk_block.length = chunk_rec->nbytes; - udata_dst.filter_mask = chunk_rec->filter_mask; + udata_dst.filter_mask = chunk_rec->filter_mask; - /* Need to compress variable-length or reference data elements or a chunk found in cache before writing to file */ - if(must_filter && (is_vlen || fix_ref || udata->chunk_in_cache) ) { - if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0) + /* Need to compress variable-length or reference data elements or a chunk found in cache before writing to + * file */ + if (must_filter && (is_vlen || fix_ref || udata->chunk_in_cache)) { + if (H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 /* Check for the chunk expanding too much to encode in a 32-bit value */ - if(nbytes > ((size_t)0xffffffff)) + if (nbytes > ((size_t)0xffffffff)) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length") #endif /* H5_SIZEOF_SIZE_T > 4 */ H5_CHECKED_ASSIGN(udata_dst.chunk_block.length, uint32_t, nbytes, size_t); - udata->buf = buf; + udata->buf = buf; udata->buf_size = buf_size; } /* end if */ udata->chunk_in_cache = FALSE; - udata_dst.chunk_idx = H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, - udata_dst.common.layout->max_down_chunks, udata_dst.common.scaled); + udata_dst.chunk_idx = + H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, udata_dst.common.layout->max_down_chunks, + udata_dst.common.scaled); /* Allocate chunk in the file */ - if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, udata_dst.common.scaled) < 0) + if (H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, + udata_dst.common.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Write chunk data to destination file */ HDassert(H5F_addr_defined(udata_dst.chunk_block.offset)); - if(H5F_block_write(udata->idx_info_dst->f, H5FD_MEM_DRAW, udata_dst.chunk_block.offset, nbytes, buf) < 0) + if (H5F_block_write(udata->idx_info_dst->f, H5FD_MEM_DRAW, udata_dst.chunk_block.offset, nbytes, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file") /* Set metadata tag in API context */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Insert chunk record into index */ - if(need_insert && udata->idx_info_dst->storage->ops->insert) - if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) - HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk addr into index") + if (need_insert && udata->idx_info_dst->storage->ops->insert) + if ((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) + HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, + "unable to insert chunk addr into index") /* Reset metadata tag in API context */ H5_END_TAG @@ -6179,7 +6143,6 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_copy_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_copy * @@ -6194,34 +6157,33 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, - H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, - const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, - const H5O_pline_t *pline_src, H5O_copy_t *cpy_info) +H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk_t *layout_src, H5F_t *f_dst, + H5O_storage_chunk_t *storage_dst, const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, + const H5O_pline_t *pline_src, H5O_copy_t *cpy_info) { - H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ - H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ - H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ - int sndims; /* Rank of dataspace */ - hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ - 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 */ - 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 */ - 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 */ - hbool_t copy_setup_done = FALSE; /* Indicate that 'copy setup' is done */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ + H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ + H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ + int sndims; /* Rank of dataspace */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ + 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 */ + 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 */ + 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 */ + hbool_t copy_setup_done = FALSE; /* Indicate that 'copy setup' is done */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6237,7 +6199,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, HDassert(dt_src); /* Initialize the temporary pipeline info */ - if(NULL == pline_src) { + if (NULL == pline_src) { HDmemset(&_pline, 0, sizeof(_pline)); pline = &_pline; } /* end if */ @@ -6245,118 +6207,119 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, pline = pline_src; /* Layout is not created in the destination file, reset index address */ - if(H5D_chunk_idx_reset(storage_dst, TRUE) < 0) + if (H5D_chunk_idx_reset(storage_dst, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Initialize layout information */ { - unsigned ndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ /* Get the dim info for dataset */ - if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) + if ((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Set the source layout chunk information */ - if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) + if (H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") } /* end block */ /* Compose source & dest chunked index info structs */ - idx_info_src.f = f_src; - idx_info_src.pline = pline; - idx_info_src.layout = layout_src; + idx_info_src.f = f_src; + idx_info_src.pline = pline; + idx_info_src.layout = layout_src; idx_info_src.storage = storage_src; - idx_info_dst.f = f_dst; - idx_info_dst.pline = pline; /* Use same I/O filter pipeline for dest. */ - idx_info_dst.layout = layout_src /* Use same layout for dest. */; + idx_info_dst.f = f_dst; + idx_info_dst.pline = pline; /* Use same I/O filter pipeline for dest. */ + idx_info_dst.layout = layout_src /* Use same layout for dest. */; idx_info_dst.storage = storage_dst; /* Call the index-specific "copy setup" routine */ - if((storage_src->ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up index-specific chunk copying information") + if ((storage_src->ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to set up index-specific chunk copying information") copy_setup_done = TRUE; /* Create datatype ID for src datatype */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* 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 */ - size_t mem_dt_size; /* Memory datatype size */ - size_t tmp_dt_size; /* Temp. datatype size */ - size_t max_dt_size; /* Max atatype size */ - hsize_t buf_dim; /* Dimension for buffer */ + if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { + 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 */ + hsize_t buf_dim; /* Dimension for buffer */ unsigned u; /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + 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, f_dst, H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (max_dt_size = H5T_get_size(dt_src))) + if (0 == (max_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (mem_dt_size = H5T_get_size(dt_mem))) + if (0 == (mem_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, mem_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(dt_dst))) + if (0 == (tmp_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Compute the number of elements per chunk */ nelmts = 1; - for(u = 0; u < (layout_src->ndims - 1); u++) + for (u = 0; u < (layout_src->ndims - 1); u++) nelmts *= layout_src->dim[u]; /* Create the space and set the initial extent */ buf_dim = nelmts; - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + 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 */ - if((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + 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") } /* end if */ /* Set initial buffer sizes */ - buf_size = nelmts * max_dt_size; + buf_size = nelmts * max_dt_size; reclaim_buf_size = nelmts * mem_dt_size; /* Allocate memory for reclaim buf */ - if(NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size))) + if (NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Indicate that type conversion should be performed */ do_convert = TRUE; } /* end if */ else { - if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { /* Indicate that type conversion should be performed */ do_convert = TRUE; } /* end if */ @@ -6366,69 +6329,68 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, } /* end else */ /* Set up conversion buffer, if appropriate */ - if(do_convert) { + if (do_convert) { /* Allocate background memory for converting the chunk */ - if(NULL == (bkg = H5MM_malloc(buf_size))) + if (NULL == (bkg = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Check for reference datatype and no expanding references & clear background buffer */ - if(!cpy_info->expand_ref && - ((H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (f_src != f_dst))) + if (!cpy_info->expand_ref && ((H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (f_src != f_dst))) /* Reset value to zero */ HDmemset(bkg, 0, buf_size); } /* end if */ /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5MM_malloc(buf_size))) + if (NULL == (buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk") /* Initialize the callback structure for the source */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = layout_src; - udata.common.storage = storage_src; - udata.file_src = f_src; - udata.idx_info_dst = &idx_info_dst; - udata.buf = buf; - udata.bkg = bkg; - udata.buf_size = buf_size; - udata.tid_src = tid_src; - udata.tid_mem = tid_mem; - udata.tid_dst = tid_dst; - udata.dt_src = dt_src; - udata.do_convert = do_convert; - udata.tpath_src_mem = tpath_src_mem; - udata.tpath_mem_dst = tpath_mem_dst; - udata.reclaim_buf = reclaim_buf; + udata.common.layout = layout_src; + udata.common.storage = storage_src; + udata.file_src = f_src; + udata.idx_info_dst = &idx_info_dst; + udata.buf = buf; + udata.bkg = bkg; + udata.buf_size = buf_size; + udata.tid_src = tid_src; + udata.tid_mem = tid_mem; + udata.tid_dst = tid_dst; + udata.dt_src = dt_src; + udata.do_convert = do_convert; + udata.tpath_src_mem = tpath_src_mem; + udata.tpath_mem_dst = tpath_mem_dst; + udata.reclaim_buf = reclaim_buf; udata.reclaim_buf_size = reclaim_buf_size; - udata.buf_space = buf_space; - udata.nelmts = nelmts; - udata.pline = pline; - udata.dset_ndims = (unsigned)sndims; - udata.dset_dims = curr_dims; - udata.cpy_info = cpy_info; - udata.chunk_in_cache = FALSE; - udata.chunk = NULL; + udata.buf_space = buf_space; + udata.nelmts = nelmts; + udata.pline = pline; + udata.dset_ndims = (unsigned)sndims; + udata.dset_dims = curr_dims; + udata.cpy_info = cpy_info; + udata.chunk_in_cache = FALSE; + udata.chunk = NULL; /* Iterate over chunks to copy data */ - if((storage_src->ops->iterate)(&idx_info_src, H5D__chunk_copy_cb, &udata) < 0) + if ((storage_src->ops->iterate)(&idx_info_src, H5D__chunk_copy_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to copy data") /* Iterate over the chunk cache to copy data for chunks with undefined address */ - if(udata.cpy_info->shared_fo) { - H5D_rdcc_ent_t *ent, *next; + 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.nbytes = layout_src->size; chunk_rec.filter_mask = 0; - chunk_rec.chunk_addr = HADDR_UNDEF; + chunk_rec.chunk_addr = HADDR_UNDEF; - for(ent = shared_fo->cache.chunk.head; ent; ent = next) { - if(!H5F_addr_defined(ent->chunk_block.offset)) { + for (ent = shared_fo->cache.chunk.head; ent; ent = next) { + if (!H5F_addr_defined(ent->chunk_block.offset)) { H5MM_memcpy(chunk_rec.scaled, ent->scaled, sizeof(chunk_rec.scaled)); - udata.chunk = ent->chunk; + udata.chunk = ent->chunk; udata.chunk_in_cache = TRUE; - if(H5D__chunk_copy_cb(&chunk_rec, &udata) < 0) + if (H5D__chunk_copy_cb(&chunk_rec, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy chunk data in cache") } next = ent->next; @@ -6440,30 +6402,30 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, bkg = udata.bkg; done: - if(sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) + if (sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) H5MM_xfree(buf); - if(bkg) + if (bkg) H5MM_xfree(bkg); - if(reclaim_buf) + if (reclaim_buf) H5MM_xfree(reclaim_buf); /* Clean up any index information */ - if(copy_setup_done) - if(storage_src->ops->copy_shutdown && (storage_src->ops->copy_shutdown)(storage_src, storage_dst) < 0) + if (copy_setup_done) + if (storage_src->ops->copy_shutdown && + (storage_src->ops->copy_shutdown)(storage_src, storage_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_copy() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_bh_info * @@ -6478,17 +6440,16 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, *------------------------------------------------------------------------- */ herr_t -H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, - hsize_t *index_size) +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 */ - H5O_pline_t pline; /* I/O pipeline message */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + 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 */ - hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ - hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ + hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6501,10 +6462,10 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, HDassert(index_size); /* Check for I/O pipeline message */ - if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(exists) { - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_PLINE_ID, &pline)) + else if (exists) { + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't find I/O pipeline message") pline_read = TRUE; } /* end else if */ @@ -6512,37 +6473,36 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, HDmemset(&pline, 0, sizeof(pline)); /* Compose chunked index info struct */ - idx_info.f = loc->file; - idx_info.pline = &pline; - idx_info.layout = &layout->u.chunk; + idx_info.f = loc->file; + idx_info.pline = &pline; + idx_info.layout = &layout->u.chunk; idx_info.storage = sc; /* Get the dataspace for the dataset */ - if(NULL == (space = H5S_read(loc))) + if (NULL == (space = H5S_read(loc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Allocate any indexing structures */ - if(sc->ops->init && (sc->ops->init)(&idx_info, space, loc->addr) < 0) + if (sc->ops->init && (sc->ops->init)(&idx_info, space, loc->addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") idx_info_init = TRUE; /* Get size of index structure */ - if(sc->ops->size && (sc->ops->size)(&idx_info, index_size) < 0) + if (sc->ops->size && (sc->ops->size)(&idx_info, index_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve chunk index info") done: /* Free resources, if they've been initialized */ - if(idx_info_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) + if (idx_info_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") - if(pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) + if (pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") - if(space && H5S_close(space) < 0) + if (space && H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_bh_info() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_dump_index_cb * @@ -6561,33 +6521,35 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud4_t *udata = (H5D_chunk_it_ud4_t *)_udata; /* User data from caller */ + H5D_chunk_it_ud4_t *udata = (H5D_chunk_it_ud4_t *)_udata; /* User data from caller */ FUNC_ENTER_STATIC_NOERR - if(udata->stream) { - unsigned u; /* Local index variable */ + if (udata->stream) { + unsigned u; /* Local index variable */ /* Print header if not already displayed */ - if(!udata->header_displayed) { + if (!udata->header_displayed) { HDfprintf(udata->stream, " Flags Bytes Address Logical Offset\n"); - HDfprintf(udata->stream, " ========== ======== ========== ==============================\n"); + HDfprintf(udata->stream, + " ========== ======== ========== ==============================\n"); /* Set flag that the headers has been printed */ udata->header_displayed = TRUE; } /* end if */ /* Print information about this chunk */ - HDfprintf(udata->stream, " 0x%08x %8Zu %10a [", chunk_rec->filter_mask, chunk_rec->nbytes, chunk_rec->chunk_addr); - for(u = 0; u < udata->ndims; u++) - HDfprintf(udata->stream, "%s%Hu", (u ? ", " : ""), (chunk_rec->scaled[u] * udata->chunk_dim[u])); + HDfprintf(udata->stream, " 0x%08x %8" PRIu32 " %10" PRIuHADDR " [", chunk_rec->filter_mask, + chunk_rec->nbytes, chunk_rec->chunk_addr); + for (u = 0; u < udata->ndims; u++) + HDfprintf(udata->stream, "%s%" PRIuHSIZE, (u ? ", " : ""), + (chunk_rec->scaled[u] * udata->chunk_dim[u])); HDfputs("]\n", udata->stream); } /* end if */ FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_dump_index_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_dump_index * @@ -6605,8 +6567,8 @@ H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_dump_index(H5D_t *dset, FILE *stream) { - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -6615,29 +6577,30 @@ H5D__chunk_dump_index(H5D_t *dset, FILE *stream) H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Only display info if stream is defined */ - if(stream) { - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_chunk_it_ud4_t udata; /* User data for callback */ + if (stream) { + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_chunk_it_ud4_t udata; /* User data for callback */ /* Display info for index */ - if((sc->ops->dump)(sc, stream) < 0) + if ((sc->ops->dump)(sc, stream) < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to dump chunk index info") /* 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.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; idx_info.storage = sc; /* Set up user data for callback */ - udata.stream = stream; + udata.stream = stream; udata.header_displayed = FALSE; - udata.ndims = dset->shared->layout.u.chunk.ndims; - udata.chunk_dim = dset->shared->layout.u.chunk.dim; + udata.ndims = dset->shared->layout.u.chunk.ndims; + udata.chunk_dim = dset->shared->layout.u.chunk.dim; /* Iterate over index and dump chunk info */ - if((sc->ops->iterate)(&idx_info, H5D__chunk_dump_index_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to dump chunk info") + if ((sc->ops->iterate)(&idx_info, H5D__chunk_dump_index_cb, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, + "unable to iterate over chunk index to dump chunk info") } /* end if */ done: @@ -6663,10 +6626,10 @@ H5D__chunk_dump_index(H5D_t *dset, FILE *stream) herr_t H5D__chunk_stats(const H5D_t *dset, hbool_t headers) { - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); - double miss_rate; - char ascii[32]; - herr_t ret_value=SUCCEED; /* Return value */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); + double miss_rate; + char ascii[32]; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -6675,10 +6638,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) if (headers) { HDfprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n"); - HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", - "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); - HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", - "-----", "----", "------", "--------", "-----", "-------"); + HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", "Layer", "Hits", "Misses", "MissRate", + "Inits", "Flushes"); + HDfprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", "-----", "----", "------", "--------", + "-----", "-------"); } #ifdef H5AC_DEBUG @@ -6687,21 +6650,22 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) #endif if (headers) { - if (rdcc->stats.nhits>0 || rdcc->stats.nmisses>0) { - miss_rate = 100.0 * rdcc->stats.nmisses / - (rdcc->stats.nhits + rdcc->stats.nmisses); - } else { + if (rdcc->stats.nhits > 0 || rdcc->stats.nmisses > 0) { + miss_rate = 100.0 * rdcc->stats.nmisses / (rdcc->stats.nhits + rdcc->stats.nmisses); + } + else { miss_rate = 0.0; } if (miss_rate > 100) { - HDsprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); - } else { + HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); + } + else { HDsprintf(ascii, "%7.2f%%", miss_rate); } - HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", - "raw data chunks", rdcc->stats.nhits, rdcc->stats.nmisses, ascii, - rdcc->stats.ninits, (long)(rdcc->stats.nflushes)-(long)(rdcc->stats.ninits)); + HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->stats.nhits, + rdcc->stats.nmisses, ascii, rdcc->stats.ninits, + (long)(rdcc->stats.nflushes) - (long)(rdcc->stats.ninits)); } done: @@ -6709,7 +6673,6 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) } /* end H5D__chunk_stats() */ #endif /* H5D_CHUNK_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5D__nonexistent_readvv_cb * @@ -6729,36 +6692,34 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) *------------------------------------------------------------------------- */ static herr_t -H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size_t len, void *_udata) { H5D_chunk_readvv_ud_t *udata = (H5D_chunk_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Initialize the fill value buffer */ - if(H5D__fill_init(&fb_info, (udata->rbuf + src_off), NULL, NULL, NULL, NULL, - &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type, - udata->dset->shared->type_id, (size_t)0, len) < 0) + if (H5D__fill_init(&fb_info, (udata->rbuf + src_off), NULL, NULL, NULL, NULL, + &udata->dset->shared->dcpl_cache.fill, udata->dset->shared->type, + udata->dset->shared->type_id, (size_t)0, len) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & fill the buffer with VL datatype fill values */ - if(fb_info.has_vlen_fill_type && H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (fb_info.has_vlen_fill_type && H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* H5D__nonexistent_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__nonexistent_readvv * @@ -6780,12 +6741,12 @@ H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size *------------------------------------------------------------------------- */ static ssize_t -H5D__nonexistent_readvv(const H5D_io_info_t *io_info, - size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, size_t *chunk_curr_seq, + size_t chunk_len_arr[], hsize_t chunk_off_arr[], size_t mem_max_nseq, + size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value */ + H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -6803,16 +6764,15 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, udata.dset = io_info->dset; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__nonexistent_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__nonexistent_readvv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized fill value init") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__nonexistent_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_is_partial_edge_chunk * @@ -6828,11 +6788,11 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, *------------------------------------------------------------------------- */ static 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) +H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, const hsize_t scaled[], + const hsize_t *dset_dims) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6843,15 +6803,14 @@ H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims HDassert(chunk_dims); /* check if this is a partial edge chunk */ - for(u = 0; u < dset_ndims; u++) - if(((scaled[u] + 1) * chunk_dims[u]) > dset_dims[u]) + for (u = 0; u < dset_ndims; u++) + if (((scaled[u] + 1) * chunk_dims[u]) > dset_dims[u]) HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_is_partial_edge_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_file_alloc() * @@ -6868,10 +6827,10 @@ H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims */ 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, hsize_t scaled[]) + H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled) { - hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6887,72 +6846,72 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old *need_insert = FALSE; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { + if (idx_info->pline->nused > 0) { /* Sanity/error checking block */ - HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); + HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); { - unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */ - unsigned new_chunk_size_len; /* Size of encoded chunk size */ + unsigned allow_chunk_size_len; /* Allowed size of encoded chunk size */ + unsigned new_chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ allow_chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)(idx_info->layout->size)) + 8) / 8); - if(allow_chunk_size_len > 8) + if (allow_chunk_size_len > 8) allow_chunk_size_len = 8; /* Compute encoded size of chunk */ new_chunk_size_len = (H5VM_log2_gen((uint64_t)(new_chunk->length)) + 8) / 8; - if(new_chunk_size_len > 8) + if (new_chunk_size_len > 8) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "encoded chunk size is more than 8 bytes?!?") /* Check if the chunk became too large to be encoded */ - if(new_chunk_size_len > allow_chunk_size_len) + if (new_chunk_size_len > allow_chunk_size_len) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk size can't be encoded") } /* end block */ - if(old_chunk && H5F_addr_defined(old_chunk->offset)) { + if (old_chunk && H5F_addr_defined(old_chunk->offset)) { /* Sanity check */ - HDassert(!H5F_addr_defined(new_chunk->offset) || H5F_addr_eq(new_chunk->offset, old_chunk->offset)); + HDassert(!H5F_addr_defined(new_chunk->offset) || + H5F_addr_eq(new_chunk->offset, old_chunk->offset)); /* Check for chunk being same size */ - if(new_chunk->length != old_chunk->length) { + if (new_chunk->length != old_chunk->length) { /* Release previous chunk */ /* Only free the old location if not doing SWMR writes - otherwise * we must keep the old chunk around in case a reader has an * outdated version of the B-tree node */ - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, old_chunk->offset, old_chunk->length) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, old_chunk->offset, old_chunk->length) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") alloc_chunk = TRUE; } /* end if */ else { /* Don't need to reallocate chunk, but send its address back up */ - if(!H5F_addr_defined(new_chunk->offset)) + if (!H5F_addr_defined(new_chunk->offset)) new_chunk->offset = old_chunk->offset; } /* end else */ - } /* end if */ + } /* end if */ else { HDassert(!H5F_addr_defined(new_chunk->offset)); alloc_chunk = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { - HDassert(!H5F_addr_defined(new_chunk->offset)); - HDassert(new_chunk->length == idx_info->layout->size); - alloc_chunk = TRUE; - } /* end else */ + HDassert(!H5F_addr_defined(new_chunk->offset)); + HDassert(new_chunk->length == idx_info->layout->size); + alloc_chunk = TRUE; + } /* end else */ /* Actually allocate space for the chunk in the file */ - if(alloc_chunk) { - switch(idx_info->storage->idx_type) { - case H5D_CHUNK_IDX_NONE: - { + if (alloc_chunk) { + switch (idx_info->storage->idx_type) { + case H5D_CHUNK_IDX_NONE: { H5D_chunk_ud_t udata; udata.common.scaled = scaled; - if((idx_info->storage->ops->get_addr)(idx_info, &udata) < 0) + if ((idx_info->storage->ops->get_addr)(idx_info, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") new_chunk->offset = udata.chunk_block.offset; HDassert(new_chunk->length == udata.chunk_block.length); @@ -6965,9 +6924,9 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old case H5D_CHUNK_IDX_BTREE: case H5D_CHUNK_IDX_SINGLE: HDassert(new_chunk->length > 0); - H5_CHECK_OVERFLOW(new_chunk->length, /*From: */uint32_t, /*To: */hsize_t); + H5_CHECK_OVERFLOW(new_chunk->length, /*From: */ uint32_t, /*To: */ hsize_t); new_chunk->offset = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, (hsize_t)new_chunk->length); - if(!H5F_addr_defined(new_chunk->offset)) + if (!H5F_addr_defined(new_chunk->offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") *need_insert = TRUE; break; @@ -6977,7 +6936,7 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old HDassert(0 && "This should never be executed!"); break; } /* end switch */ - } /* end if */ + } /* end if */ HDassert(H5F_addr_defined(new_chunk->offset)); @@ -6985,7 +6944,6 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_file_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_format_convert_cb * @@ -7003,13 +6961,13 @@ H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5D_chunk_it_ud5_t *udata = (H5D_chunk_it_ud5_t *)_udata; /* User data */ - H5D_chk_idx_info_t *new_idx_info; /* The new chunk index information */ - 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 */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_chunk_it_ud5_t *udata = (H5D_chunk_it_ud5_t *)_udata; /* User data */ + H5D_chk_idx_info_t *new_idx_info; /* The new chunk index information */ + 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 */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -7019,32 +6977,35 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) chunk_addr = chunk_rec->chunk_addr; if (new_idx_info->pline->nused && - (new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && - (H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, udata->dset_dims))) { + (new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, + udata->dset_dims))) { /* This is a partial non-filtered edge chunk */ /* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */ unsigned filter_mask = chunk_rec->filter_mask; - H5Z_cb_t filter_cb; /* Filter failure callback struct */ - size_t read_size = nbytes; /* Bytes to read */ + H5Z_cb_t filter_cb; /* Filter failure callback struct */ + size_t read_size = nbytes; /* Bytes to read */ HDassert(read_size == new_idx_info->layout->size); /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer for chunk data */ if (NULL == (buf = H5MM_malloc(read_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, + "memory allocation failed for raw data chunk") /* Read the non-filtered edge chunk */ if (H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") /* Pass the chunk through the pipeline */ - if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &buf) < 0) + if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, + &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed") #if H5_SIZEOF_SIZE_T > 4 @@ -7066,10 +7027,10 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Set up chunk information for insertion to chunk index */ insert_udata.chunk_block.offset = chunk_addr; insert_udata.chunk_block.length = nbytes; - insert_udata.filter_mask = chunk_rec->filter_mask; - insert_udata.common.scaled = chunk_rec->scaled; - insert_udata.common.layout = new_idx_info->layout; - insert_udata.common.storage = new_idx_info->storage; + insert_udata.filter_mask = chunk_rec->filter_mask; + insert_udata.common.scaled = chunk_rec->scaled; + insert_udata.common.layout = new_idx_info->layout; + insert_udata.common.storage = new_idx_info->storage; /* Insert chunk into the v1 B-tree chunk index */ if ((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0) @@ -7082,7 +7043,6 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_format_convert_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_format_convert * @@ -7099,8 +7059,8 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx_info_t *new_idx_info) { - H5D_chunk_it_ud5_t udata; /* User data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_chunk_it_ud5_t udata; /* User data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -7109,18 +7069,18 @@ H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx /* Set up user data */ udata.new_idx_info = new_idx_info; - udata.dset_ndims = dset->shared->ndims; - udata.dset_dims = dset->shared->curr_dims; + udata.dset_ndims = dset->shared->ndims; + udata.dset_dims = dset->shared->curr_dims; - /* Iterate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index */ - if((idx_info->storage->ops->iterate)(idx_info, H5D__chunk_format_convert_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to chunk info") + /* Iterate over the chunks in the current index and insert the chunk addresses into version 1 B-tree index + */ + if ((idx_info->storage->ops->iterate)(idx_info, H5D__chunk_format_convert_cb, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to chunk info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_format_convert() */ - /*------------------------------------------------------------------------- * Function: H5D__get_num_chunks_cb * @@ -7133,7 +7093,7 @@ H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx * Return: H5_ITER_CONT * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ @@ -7141,7 +7101,7 @@ static int H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_udata) { hsize_t *num_chunks = (hsize_t *)_udata; - int ret_value = H5_ITER_CONT; /* Callback return value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7152,7 +7112,6 @@ H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_u FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_num_chunks_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_num_chunks * @@ -7165,18 +7124,18 @@ H5D__get_num_chunks_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_u * Failure: Negative * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t *nchunks) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7189,24 +7148,26 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(rdcc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + 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) + 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.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; /* If the dataset is not written, number of chunks will be 0 */ - if(!H5F_addr_defined(idx_info.storage->idx_addr)) + if (!H5F_addr_defined(idx_info.storage->idx_addr)) *nchunks = 0; else { /* Iterate over the allocated chunks */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, &num_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, + &num_chunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") *nchunks = num_chunks; } @@ -7214,7 +7175,6 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_num_chunks() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_cb * @@ -7225,7 +7185,7 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ * Failure: Negative (H5_ITER_ERROR) * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ @@ -7233,7 +7193,7 @@ static int H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; - int ret_value = H5_ITER_CONT; /* Callback return value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7242,14 +7202,14 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(chunk_info); /* If this is the queried chunk, retrieve its info and stop iterating */ - if(chunk_info->curr_idx == chunk_info->chunk_idx) { - hsize_t ii = 0; /* Dimension index */ + if (chunk_info->curr_idx == chunk_info->chunk_idx) { + hsize_t ii = 0; /* Dimension index */ /* Copy info */ chunk_info->filter_mask = chunk_rec->filter_mask; - chunk_info->chunk_addr = chunk_rec->chunk_addr; - chunk_info->nbytes = chunk_rec->nbytes; - for(ii = 0; ii < chunk_info->ndims; ii++) + chunk_info->chunk_addr = chunk_rec->chunk_addr; + chunk_info->nbytes = chunk_rec->nbytes; + for (ii = 0; ii < chunk_info->ndims; ii++) chunk_info->scaled[ii] = chunk_rec->scaled[ii]; chunk_info->found = TRUE; @@ -7263,33 +7223,33 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info * * Purpose: Iterate over the chunks in the dataset to get the info * of the desired chunk. * - * Note: Currently, this function only gets the number of all written - * chunks, regardless the dataspace. + * Note: Currently, the domain of the index in this function is of all + * the written chunks, regardless the dataspace. * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ herr_t -H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_t chk_index, hsize_t *offset, + unsigned *filter_mask, haddr_t *addr, hsize_t *size) { - 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 */ - hsize_t ii = 0; /* Dimension index */ - herr_t ret_value = SUCCEED;/* Return value */ + 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 */ + hsize_t ii = 0; /* Dimension index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7302,15 +7262,15 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(rdcc); /* Search for cached chunks that haven't been written out */ - for(ent = rdcc->head; ent; ent = ent->next) + 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) + 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.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; /* Set addr & size for when dset is not written or queried chunk is not found */ @@ -7319,41 +7279,41 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ if (size) *size = 0; - /* If the dataset is not written, return without error */ - if(!H5F_addr_defined(idx_info.storage->idx_addr)) - HGOTO_DONE(SUCCEED); - - /* Initialize before iteration */ - udata.chunk_idx = index; - udata.curr_idx = 0; - udata.ndims = dset->shared->ndims; - udata.nbytes = 0; - udata.filter_mask = 0; - udata.chunk_addr = HADDR_UNDEF; - udata.found = FALSE; - - /* Iterate over the allocated chunks */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") - - /* Obtain requested info if the chunk is found */ - if (udata.found) { - if (filter_mask) - *filter_mask = udata.filter_mask; - if (addr) - *addr = udata.chunk_addr; - if (size) - *size = udata.nbytes; - if (offset) - for (ii = 0; ii < udata.ndims; ii++) - offset[ii] = udata.scaled[ii] * dset->shared->layout.u.chunk.dim[ii]; - } + /* If the chunk is written, get its info, otherwise, return without error */ + if (H5F_addr_defined(idx_info.storage->idx_addr)) { + /* Initialize before iteration */ + udata.chunk_idx = chk_index; + udata.curr_idx = 0; + udata.ndims = dset->shared->ndims; + udata.nbytes = 0; + udata.filter_mask = 0; + udata.chunk_addr = HADDR_UNDEF; + udata.found = FALSE; + + /* Iterate over the allocated chunks */ + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_cb, &udata) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") + + /* Obtain requested info if the chunk is found */ + if (udata.found) { + if (filter_mask) + *filter_mask = udata.filter_mask; + if (addr) + *addr = udata.chunk_addr; + if (size) + *size = udata.nbytes; + if (offset) + for (ii = 0; ii < udata.ndims; ii++) + offset[ii] = udata.scaled[ii] * dset->shared->layout.u.chunk.dim[ii]; + } /* end if */ + } /* end if H5F_addr_defined */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_by_coord_cb * @@ -7364,7 +7324,7 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ * Failure: Negative (H5_ITER_ERROR) * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ @@ -7372,9 +7332,9 @@ static int H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_info_iter_ud_t *chunk_info = (H5D_chunk_info_iter_ud_t *)_udata; - hbool_t different = FALSE; /* TRUE when a scaled value pair mismatch */ - hsize_t ii; /* Local index value */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + hbool_t different = FALSE; /* TRUE when a scaled value pair mismatch */ + hsize_t ii; /* Local index value */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR @@ -7389,10 +7349,10 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Same scaled coords means the chunk is found, copy the chunk info */ if (!different) { - chunk_info->nbytes = chunk_rec->nbytes; + chunk_info->nbytes = chunk_rec->nbytes; chunk_info->filter_mask = chunk_rec->filter_mask; - chunk_info->chunk_addr = chunk_rec->chunk_addr; - chunk_info->found = TRUE; + chunk_info->chunk_addr = chunk_rec->chunk_addr; + chunk_info->found = TRUE; /* Stop iterating */ ret_value = H5_ITER_STOP; @@ -7401,7 +7361,6 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_by_coord_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__get_chunk_info_by_coord * @@ -7412,19 +7371,20 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) * Failure: Negative * * Programmer: Binh-Minh Ribler - * September 2018 (HDFFV-10615) + * June 2019 (HDFFV-10677) * *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7435,59 +7395,59 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned* /* Get dataset layout and raw data chunk cache */ layout = &(dset->shared->layout); - rdcc = &(dset->shared->cache.chunk); + 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) + 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) + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") /* Set addr & size for when dset is not written or queried chunk is not found */ - if(addr) + if (addr) *addr = HADDR_UNDEF; - if(size) + if (size) *size = 0; /* 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.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; /* If the dataset is not written, return without errors */ - if(!H5F_addr_defined(idx_info.storage->idx_addr)) { - HGOTO_DONE(SUCCEED); - } + if (H5F_addr_defined(idx_info.storage->idx_addr)) { + /* Calculate the scaled of this chunk */ + H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, udata.scaled); + udata.scaled[dset->shared->ndims] = 0; + + /* Initialize before iteration */ + udata.ndims = dset->shared->ndims; + udata.nbytes = 0; + udata.filter_mask = 0; + udata.chunk_addr = HADDR_UNDEF; + udata.found = FALSE; + + /* Iterate over the allocated chunks to find the requested chunk */ + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_by_coord_cb, + &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve information of the chunk by its scaled coordinates") + + /* Obtain requested info if the chunk is found */ + if (udata.found) { + if (filter_mask) + *filter_mask = udata.filter_mask; + if (addr) + *addr = udata.chunk_addr; + if (size) + *size = udata.nbytes; + } /* end if */ + } /* end if H5F_addr_defined */ - /* Calculate the scaled of this chunk */ - H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, udata.scaled); - udata.scaled[dset->shared->ndims] = 0; - - /* Initialize before iteration */ - udata.ndims = dset->shared->ndims; - udata.nbytes = 0; - udata.filter_mask = 0; - udata.chunk_addr = HADDR_UNDEF; - udata.found = FALSE; - - /* Iterate over the allocated chunks to find the requested chunk */ - if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_chunk_info_by_coord_cb, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve information of the chunk by its scaled coordinates") - - /* If the chunk is found, return the filter mask and chunk address/size */ - if (udata.found) { - if (filter_mask) - *filter_mask = udata.filter_mask; - if (addr) - *addr = udata.chunk_addr; - if (size) - *size = udata.nbytes; - } done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info_by_coord() */ - diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index a4d4629d995..8a2c7705c6a 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,78 +23,61 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ -static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset); +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); -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[]); -static ssize_t H5D__compact_writevv(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[]); -static herr_t H5D__compact_flush(H5D_t *dset); -static herr_t H5D__compact_dest(H5D_t *dset); - +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); +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[]); +static ssize_t H5D__compact_writevv(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[]); +static herr_t H5D__compact_flush(H5D_t *dset); +static herr_t H5D__compact_dest(H5D_t *dset); /*********************/ /* Package Variables */ /*********************/ /* 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, NULL, H5D__compact_is_space_alloc, NULL, H5D__compact_io_init, H5D__contig_read, + H5D__contig_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__compact_readvv, - H5D__compact_writevv, - H5D__compact_flush, - NULL, - H5D__compact_dest -}}; - + H5D__compact_readvv, H5D__compact_writevv, H5D__compact_flush, NULL, H5D__compact_dest}}; /*******************/ /* Local Variables */ @@ -103,8 +86,6 @@ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - - /*------------------------------------------------------------------------- * Function: H5D__compact_fill * @@ -120,9 +101,9 @@ H5FL_BLK_EXTERN(type_conv); herr_t H5D__compact_fill(const H5D_t *dset) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -134,28 +115,26 @@ H5D__compact_fill(const H5D_t *dset) /* Initialize the fill value buffer */ /* (use the compact dataset storage buffer as the fill value buffer) */ - if(H5D__fill_init(&fb_info, dset->shared->layout.storage.u.compact.buf, - NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, dset->shared->layout.storage.u.compact.size) < 0) + if (H5D__fill_init(&fb_info, dset->shared->layout.storage.u.compact.buf, NULL, NULL, NULL, NULL, + &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id, (size_t)0, + dset->shared->layout.storage.u.compact.size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Fill the buffer with VL datatype fill values */ - if(H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) + if (H5D__fill_refill_vl(&fb_info, fb_info.elmts_per_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_construct * @@ -171,11 +150,11 @@ H5D__compact_fill(const H5D_t *dset) static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset) { - hssize_t stmp_size; /* Temporary holder for raw data size */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - hsize_t max_comp_data_size; /* Max. allowed size of compact data */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + hsize_t max_comp_data_size; /* Max. allowed size of compact data */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -184,8 +163,8 @@ H5D__compact_construct(H5F_t *f, H5D_t *dset) HDassert(dset); /* Check for invalid dataset dimensions */ - for(u = 0; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + for (u = 0; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible compact dataset not allowed") /* @@ -203,14 +182,14 @@ H5D__compact_construct(H5F_t *f, H5D_t *dset) * (64KB) minus other layout message fields. */ max_comp_data_size = H5O_MESG_MAX_SIZE - H5D__layout_meta_size(f, &(dset->shared->layout), FALSE); - if(dset->shared->layout.storage.u.compact.size > max_comp_data_size) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size") + if (dset->shared->layout.storage.u.compact.size > max_comp_data_size) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "compact dataset size is bigger than header message maximum size") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_is_space_alloc * @@ -235,7 +214,6 @@ H5D__compact_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(TRUE) } /* end H5D__compact_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_io_init * @@ -250,18 +228,17 @@ 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, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR - io_info->store->compact.buf = io_info->dset->shared->layout.storage.u.compact.buf; + io_info->store->compact.buf = io_info->dset->shared->layout.storage.u.compact.buf; io_info->store->compact.dirty = &io_info->dset->shared->layout.storage.u.compact.dirty; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compact_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_readvv * @@ -281,25 +258,26 @@ H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR *------------------------------------------------------------------------- */ 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[]) +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[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value = H5VM_memcpyvv(io_info->u.rbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr, io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, dset_offset_arr)) < 0) + if ((ret_value = H5VM_memcpyvv(io_info->u.rbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr, + io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, + dset_offset_arr)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__compact_readvv() */ +} /* end H5D__compact_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_writevv * @@ -322,18 +300,20 @@ H5D__compact_readvv(const H5D_io_info_t *io_info, *------------------------------------------------------------------------- */ static ssize_t -H5D__compact_writevv(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[]) +H5D__compact_writevv(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[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value = H5VM_memcpyvv(io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, dset_offset_arr, io_info->u.wbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, mem_offset_arr)) < 0) + if ((ret_value = H5VM_memcpyvv(io_info->store->compact.buf, dset_max_nseq, dset_curr_seq, dset_size_arr, + dset_offset_arr, io_info->u.wbuf, mem_max_nseq, mem_curr_seq, mem_size_arr, + mem_offset_arr)) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") /* Mark the compact dataset's buffer as dirty */ @@ -341,9 +321,8 @@ H5D__compact_writevv(const H5D_io_info_t *io_info, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__compact_writevv() */ +} /* end H5D__compact_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_flush * @@ -359,7 +338,7 @@ H5D__compact_writevv(const H5D_io_info_t *io_info, static herr_t H5D__compact_flush(H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -367,9 +346,9 @@ H5D__compact_flush(H5D_t *dset) HDassert(dset); /* Check if the buffered compact information is dirty */ - if(dset->shared->layout.storage.u.compact.dirty) { + if (dset->shared->layout.storage.u.compact.dirty) { dset->shared->layout.storage.u.compact.dirty = FALSE; - if(H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout)) < 0) { + if (H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout)) < 0) { dset->shared->layout.storage.u.compact.dirty = TRUE; HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") } @@ -379,7 +358,6 @@ H5D__compact_flush(H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_dest * @@ -406,7 +384,6 @@ H5D__compact_dest(H5D_t *dset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compact_dest() */ - /*------------------------------------------------------------------------- * Function: H5D__compact_copy * @@ -421,18 +398,19 @@ H5D__compact_dest(H5D_t *dset) */ herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_dst, - H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info) + H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info) { - 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 */ - 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 */ - H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -445,64 +423,64 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds HDassert(dt_src); /* If the dataset is open in the file, point to "layout" in the shared struct */ - if(shared_fo != NULL) + if (shared_fo != NULL) storage_src = &(shared_fo->layout.storage.u.compact); /* Create datatype ID for src datatype, so it gets freed */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* 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 */ - size_t buf_size; /* Size of copy buffer */ - size_t nelmts; /* Number of elements in buffer */ - size_t src_dt_size; /* Source datatype size */ - size_t tmp_dt_size; /* Temporary datatype size */ - size_t max_dt_size; /* Max atatype size */ - hsize_t buf_dim; /* Dimension for buffer */ + 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 */ + size_t buf_size; /* Size of copy buffer */ + size_t nelmts; /* Number of elements in buffer */ + size_t src_dt_size; /* Source datatype size */ + size_t tmp_dt_size; /* Temporary datatype size */ + size_t max_dt_size; /* Max atatype size */ + hsize_t buf_dim; /* Dimension for buffer */ /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + 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, f_dst, H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(dt_src))) + if (0 == (src_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (tmp_dt_size = H5T_get_size(dt_mem))) + if (0 == (tmp_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, tmp_dt_size); - if(0 == (tmp_dt_size = H5T_get_size(dt_dst))) + if (0 == (tmp_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Set number of whole elements that fit in buffer */ - if(0 == (nelmts = storage_src->size / src_dt_size)) + if (0 == (nelmts = storage_src->size / src_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large") /* Set up number of bytes to copy, and initial buffer size */ @@ -512,31 +490,31 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds buf_dim = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + 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 */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + 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") } /* end if */ /* Allocate memory for recclaim buf */ - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Allocate memory for copying the chunk */ - if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5MM_memcpy(buf, storage_src->buf, storage_src->size); /* allocate temporary bkg buff for data conversion */ - if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -546,26 +524,22 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") H5MM_memcpy(storage_dst->buf, buf, storage_dst->size); - if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data") } /* end if */ - else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { - if(f_src != f_dst) { + else if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (f_src != f_dst) { /* Check for expanding references */ - if(cpy_info->expand_ref) { - size_t ref_count; - - /* Determine # of reference elements to copy */ - ref_count = storage_src->size / H5T_get_size(dt_src); - - /* Copy objects referenced in source buffer to destination file and set destination elements */ - if (H5O_copy_expand_ref(f_src, storage_src->buf, f_dst, - storage_dst->buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0) + if (cpy_info->expand_ref) { + /* Copy objects referenced in source buffer to destination file and set destination elements + */ + if (H5O_copy_expand_ref(f_src, tid_src, dt_src, storage_src->buf, storage_src->size, f_dst, + storage_dst->buf, cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") } /* end if */ else @@ -584,21 +558,20 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds storage_dst->dirty = TRUE; done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(type_conv, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); - if(bkg) + if (bkg) bkg = H5FL_BLK_FREE(type_conv, bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_copy() */ - diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 14c79ebffab..57c15028417 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,115 +25,97 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Callback info for sieve buffer readvv operation */ typedef struct H5D_contig_readvv_sieve_ud_t { - H5F_t *file; /* 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 */ + 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 */ } H5D_contig_readvv_sieve_ud_t; /* Callback info for [plain] readvv operation */ typedef struct H5D_contig_readvv_ud_t { - H5F_t *file; /* File for dataset */ - haddr_t dset_addr; /* Address of dataset */ - unsigned char *rbuf; /* Pointer to buffer to fill */ + 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_t *file; /* 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 */ + 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 */ } H5D_contig_writevv_sieve_ud_t; /* Callback info for [plain] writevv operation */ typedef struct H5D_contig_writevv_ud_t { - H5F_t *file; /* File for dataset */ - haddr_t dset_addr; /* Address of dataset */ - const unsigned char *wbuf; /* Pointer to buffer to write */ + 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; - /********************/ /* Local Prototypes */ /********************/ /* Layout operation callbacks */ -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); -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[]); -static ssize_t H5D__contig_writevv(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[]); -static herr_t H5D__contig_flush(H5D_t *dset); +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); +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[]); +static ssize_t H5D__contig_writevv(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[]); +static herr_t H5D__contig_flush(H5D_t *dset); /* Helper routines */ -static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, - size_t size); - +static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size); /*********************/ /* Package Variables */ /*********************/ /* 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, H5D__contig_init, H5D__contig_is_space_alloc, H5D__contig_is_data_cached, + H5D__contig_io_init, H5D__contig_read, H5D__contig_write, #ifdef H5_HAVE_PARALLEL - H5D__contig_collective_read, - H5D__contig_collective_write, + 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_readvv, H5D__contig_writevv, H5D__contig_flush, NULL, NULL}}; /*******************/ /* Local Variables */ @@ -145,8 +127,6 @@ H5FL_BLK_DEFINE(sieve_buf); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - - /*------------------------------------------------------------------------- * Function: H5D__contig_alloc * @@ -160,9 +140,9 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ herr_t -H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ ) +H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -171,14 +151,13 @@ H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */ ) HDassert(storage); /* Allocate space for the contiguous data */ - if(HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size))) + if (HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, storage->size))) HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_alloc */ - /*------------------------------------------------------------------------- * Function: H5D__contig_fill * @@ -194,23 +173,24 @@ 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 */ - 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) */ - size_t npoints; /* Number of points in space */ - hsize_t offset; /* Offset of dataset */ - size_t max_temp_buf; /* Maximum size of temporary buffer */ + 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) */ + size_t npoints; /* Number of points in space */ + hsize_t offset; /* Offset of dataset */ + size_t max_temp_buf; /* Maximum size of temporary buffer */ #ifdef H5_HAVE_PARALLEL - MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ - int mpi_rank = (-1); /* This process's rank */ - int mpi_code; /* MPI return code */ - 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 */ -#endif /* H5_HAVE_PARALLEL */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ + int mpi_rank = (-1); /* This process's rank */ + int mpi_code; /* MPI return code */ + 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 */ +#endif /* H5_HAVE_PARALLEL */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -223,37 +203,36 @@ H5D__contig_fill(const H5D_io_info_t *io_info) #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ - if(H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* Get the MPI communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) + 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") /* Get the MPI rank */ - if((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI rank") /* Set the MPI-capable file driver flag */ using_mpi = TRUE; - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /* Initialize storage info for this dataset */ store.contig.dset_addr = dset->shared->layout.storage.u.contig.addr; store.contig.dset_size = dset->shared->layout.storage.u.contig.size; /* Get the number of elements in the dataset's dataspace */ - if((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "dataset has negative number of elements") H5_CHECKED_ASSIGN(npoints, size_t, snpoints, hssize_t); /* Get the maximum size of temporary buffers */ - if(H5CX_get_max_temp_buf(&max_temp_buf) < 0) + if (H5CX_get_max_temp_buf(&max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve max. temp. buf size") /* Initialize the fill value buffer */ - if(H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL, - &dset->shared->dcpl_cache.fill, - dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0) + if (H5D__fill_init(&fb_info, NULL, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill, + dset->shared->type, dset->shared->type_id, npoints, max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; @@ -270,67 +249,66 @@ H5D__contig_fill(const H5D_io_info_t *io_info) */ /* Loop through writing the fill value to the dataset */ - while(npoints > 0) { - size_t curr_points; /* Number of elements to write on this iteration of the loop */ - size_t size; /* Size of buffer to write */ + while (npoints > 0) { + size_t curr_points; /* Number of elements to write on this iteration of the loop */ + size_t size; /* Size of buffer to write */ /* Compute # of elements and buffer size to write for this iteration */ curr_points = MIN(fb_info.elmts_per_buf, npoints); - size = curr_points * fb_info.file_elmt_size; + size = curr_points * fb_info.file_elmt_size; /* Check for VL datatype & non-default fill value */ - if(fb_info.has_vlen_fill_type) + if (fb_info.has_vlen_fill_type) /* Re-fill the buffer to use for this I/O operation */ - if(H5D__fill_refill_vl(&fb_info, curr_points) < 0) + if (H5D__fill_refill_vl(&fb_info, curr_points) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer") #ifdef H5_HAVE_PARALLEL - /* Check if this file is accessed with an MPI-capable file driver */ - 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") - - /* Indicate that blocks are being written */ - blocks_written = TRUE; - } /* end if */ - else { -#endif /* H5_HAVE_PARALLEL */ - H5_CHECK_OVERFLOW(size, size_t, hsize_t); - if(H5D__contig_write_one(&ioinfo, offset, size) < 0) + /* Check if this file is accessed with an MPI-capable file driver */ + 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") -#ifdef H5_HAVE_PARALLEL - } /* end else */ + + /* Indicate that blocks are being written */ + blocks_written = TRUE; + } /* end if */ + else { #endif /* H5_HAVE_PARALLEL */ + H5_CHECK_OVERFLOW(size, size_t, hsize_t); + if (H5D__contig_write_one(&ioinfo, offset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") +#ifdef H5_HAVE_PARALLEL + } /* end else */ +#endif /* H5_HAVE_PARALLEL */ - npoints -= curr_points; - offset += size; - } /* end while */ + npoints -= curr_points; + offset += size; + } /* end while */ #ifdef H5_HAVE_PARALLEL /* Only need to block at the barrier if we actually wrote fill values */ /* And if we are using an MPI-capable file driver */ - if(using_mpi && blocks_written) { + if (using_mpi && blocks_written) { /* Wait at barrier to avoid race conditions where some processes are * still writing out fill values and other processes race ahead to data * in, getting bogus data. */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(mpi_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PARALLEL */ done: /* Release the fill buffer info, if it's been initialized */ - if(fb_info_init && H5D__fill_term(&fb_info) < 0) + if (fb_info_init && H5D__fill_term(&fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_delete * @@ -346,7 +324,7 @@ H5D__contig_fill(const H5D_io_info_t *io_info) herr_t H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -355,14 +333,13 @@ H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage) HDassert(storage); /* Free the file space for the chunk */ - if(H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0) + if (H5MF_xfree(f, H5FD_MEM_DRAW, storage->u.contig.addr, storage->u.contig.size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free contiguous storage space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_delete */ - /*------------------------------------------------------------------------- * Function: H5D__contig_construct * @@ -378,13 +355,13 @@ H5D__contig_delete(H5F_t *f, const H5O_storage_t *storage) static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset) { - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -399,24 +376,25 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) */ /* Check for invalid dataset dimensions */ - for(u = 0; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset not allowed") + for (u = 0; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "extendible contiguous non-external dataset not allowed") /* Retrieve the number of elements in the dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; /* Get the datatype's size */ - if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the size of the dataset's contiguous storage */ tmp_size = nelmts * dt_size; /* Check for overflow during multiplication */ - if(nelmts != (tmp_size / dt_size)) + if (nelmts != (tmp_size / dt_size)) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ @@ -427,7 +405,7 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size * from the file access property. (SLU - 2012/3/30) */ - if(tmp_size < tmp_sieve_buf_size) + if (tmp_size < tmp_sieve_buf_size) dset->shared->cache.contig.sieve_buf_size = tmp_size; else dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; @@ -436,7 +414,6 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_init * @@ -451,12 +428,11 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) *------------------------------------------------------------------------- */ static herr_t -H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, - hid_t H5_ATTR_UNUSED dapl_id) +H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, hid_t H5_ATTR_UNUSED dapl_id) { - hsize_t tmp_size; /* Temporary holder for raw data size */ - size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -468,25 +444,25 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(dset->shared->layout.version < 3) { - 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 */ + if (dset->shared->layout.version < 3) { + 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 */ /* Retrieve the number of elements in the dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") nelmts = (hsize_t)snelmts; /* Get the datatype's size */ - if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the size of the dataset's contiguous storage */ tmp_size = nelmts * dt_size; /* Check for overflow during multiplication */ - if(nelmts != (tmp_size / dt_size)) + if (nelmts != (tmp_size / dt_size)) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ @@ -500,7 +476,7 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size * from the file access property. (SLU - 2012/3/30) */ - if(tmp_size < tmp_sieve_buf_size) + if (tmp_size < tmp_sieve_buf_size) dset->shared->cache.contig.sieve_buf_size = tmp_size; else dset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; @@ -509,7 +485,6 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_init() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_is_space_alloc * @@ -525,7 +500,7 @@ H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, const H5D_t *dset, hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -538,7 +513,6 @@ H5D__contig_is_space_alloc(const H5O_storage_t *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_is_data_cached * @@ -562,7 +536,6 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset) FUNC_LEAVE_NOAPI(shared_dset->cache.contig.sieve_size > 0) } /* end H5D__contig_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_io_init * @@ -577,8 +550,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, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -588,7 +561,6 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__contig_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_read * @@ -602,11 +574,10 @@ 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, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -618,14 +589,13 @@ H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); /* Read data */ - if((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0) + if ((io_info->io_ops.single_read)(io_info, type_info, nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "contiguous read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_read() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_write * @@ -639,11 +609,10 @@ H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ 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, + const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -655,14 +624,13 @@ H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); /* Write data */ - if((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0) + if ((io_info->io_ops.single_write)(io_info, type_info, nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "contiguous write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_write() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_write_one * @@ -680,27 +648,26 @@ H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size) { - hsize_t dset_off = offset; /* Offset in dataset */ - size_t dset_len = size; /* Length in dataset */ - size_t dset_curr_seq = 0; /* "Current sequence" in dataset */ - hsize_t mem_off = 0; /* Offset in memory */ - size_t mem_len = size; /* Length in memory */ - size_t mem_curr_seq = 0; /* "Current sequence" in memory */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t dset_off = offset; /* Offset in dataset */ + size_t dset_len = size; /* Length in dataset */ + size_t dset_curr_seq = 0; /* "Current sequence" in dataset */ + hsize_t mem_off = 0; /* Offset in memory */ + size_t mem_len = size; /* Length in memory */ + size_t mem_curr_seq = 0; /* "Current sequence" in memory */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(io_info); - if(H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off, - (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if (H5D__contig_writevv(io_info, (size_t)1, &dset_curr_seq, &dset_len, &dset_off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_write_one() */ +} /* end H5D__contig_write_one() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv_sieve_cb * @@ -714,30 +681,31 @@ H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size_t size) *------------------------------------------------------------------------- */ static herr_t -H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_readvv_sieve_ud_t *udata = (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - H5F_t *file = udata->file; /* File for dataset */ - 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 */ - haddr_t addr; /* Actual address to read */ - haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ - haddr_t contig_end; /* End locations of block to write */ - size_t sieve_size = (size_t)-1; /* Size of sieve buffer */ - haddr_t rel_eoa; /* Relative end of file address */ - hsize_t max_data; /* Actual maximum size of data to cache */ - hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + haddr_t addr; /* Actual address to read */ + haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ + haddr_t contig_end; /* End locations of block to write */ + size_t sieve_size = (size_t)-1; /* Size of sieve buffer */ + haddr_t rel_eoa; /* Relative end of file address */ + hsize_t max_data; /* Actual maximum size of data to cache */ + hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Stash local copies of these value */ - if(dset_contig->sieve_buf != NULL) { + if (dset_contig->sieve_buf != NULL) { sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end if */ /* Compute offset on disk */ @@ -747,22 +715,22 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, buf = udata->rbuf + src_off; /* Check if the sieve buffer is allocated yet */ - if(NULL == dset_contig->sieve_buf) { + if (NULL == dset_contig->sieve_buf) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { - if(H5F_block_read(file, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (len > dset_contig->sieve_buf_size) { + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ - if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) + if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Set up the buffer parameters */ @@ -773,7 +741,8 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Read the new sieve buffer */ - if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ @@ -781,19 +750,14 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; - - /* Stash local copies of these value */ - sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start+sieve_size; } /* end else */ - } /* end if */ + } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end = addr + len - 1; /* If entire read is within the sieve buffer, read it from the buffer */ - if(addr >= sieve_start && contig_end < sieve_end) { + if (addr >= sieve_start && contig_end < sieve_end) { unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start); /* Grab the data out of the buffer */ @@ -802,31 +766,33 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { + if (len > dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ - if((sieve_start >= addr && sieve_start < (contig_end + 1)) - || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { + if ((sieve_start >= addr && sieve_start < (contig_end + 1)) || + ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; } /* end if */ - } /* end if */ + } /* end if */ /* Read directly into the user's buffer */ - if(H5F_block_read(file, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Flush the sieve buffer if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -837,7 +803,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Only need this when resizing sieve buffer */ @@ -851,13 +817,9 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size); H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); - /* Update local copies of sieve information */ - sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; - /* Read the new sieve buffer */ - if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") /* Grab the data out of the buffer (must be first piece of data in buffer ) */ @@ -866,14 +828,13 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Reset sieve buffer dirty flag */ dset_contig->sieve_dirty = FALSE; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv_sieve_cb() */ +} /* end H5D__contig_readvv_sieve_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv_cb * @@ -890,20 +851,19 @@ static herr_t H5D__contig_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { H5D_contig_readvv_ud_t *udata = (H5D_contig_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5F_block_read(udata->file, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), - len, (udata->rbuf + src_off)) < 0) + if (H5F_shared_block_read(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, + (udata->rbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv_cb() */ +} /* end H5D__contig_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_readvv * @@ -923,11 +883,11 @@ H5D__contig_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata *------------------------------------------------------------------------- */ 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_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +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_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -941,41 +901,40 @@ H5D__contig_readvv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Check if data sieving is enabled */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_DATA_SIEVE)) { - H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ + if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { + H5D_contig_readvv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.file = io_info->dset->oloc.file; - udata.dset_contig = &(io_info->dset->shared->cache.contig); + udata.f_sh = io_info->f_sh; + udata.dset_contig = &(io_info->dset->shared->cache.contig); udata.store_contig = &(io_info->store->contig); - udata.rbuf = (unsigned char *)io_info->u.rbuf; + udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_readvv_sieve_cb, &udata)) < 0) + if ((ret_value = + H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_sieve_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer read") } /* end if */ else { - H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + H5D_contig_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.file = io_info->dset->oloc.file; + udata.f_sh = io_info->f_sh; udata.dset_addr = io_info->store->contig.dset_addr; - udata.rbuf = (unsigned char *)io_info->u.rbuf; + udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_readvv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_readvv() */ +} /* end H5D__contig_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv_sieve_cb * @@ -989,30 +948,31 @@ H5D__contig_readvv(const H5D_io_info_t *io_info, *------------------------------------------------------------------------- */ static herr_t -H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, - void *_udata) +H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_writevv_sieve_ud_t *udata = (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - H5F_t *file = udata->file; /* File for dataset */ - 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 */ - haddr_t addr; /* Actual address to read */ - haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ - haddr_t contig_end; /* End locations of block to write */ - size_t sieve_size = (size_t)-1; /* size of sieve buffer */ - haddr_t rel_eoa; /* Relative end of file address */ - hsize_t max_data; /* Actual maximum size of data to cache */ - hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + haddr_t addr; /* Actual address to read */ + haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */ + haddr_t contig_end; /* End locations of block to write */ + size_t sieve_size = (size_t)-1; /* size of sieve buffer */ + haddr_t rel_eoa; /* Relative end of file address */ + hsize_t max_data; /* Actual maximum size of data to cache */ + hsize_t min; /* temporary minimum value (avoids some ugly macro nesting) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Stash local copies of these values */ - if(dset_contig->sieve_buf != NULL) { + if (dset_contig->sieve_buf != NULL) { sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end if */ /* Compute offset on disk */ @@ -1022,26 +982,26 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, buf = udata->wbuf + src_off; /* No data sieve buffer yet, go allocate one */ - if(NULL == dset_contig->sieve_buf) { + if (NULL == dset_contig->sieve_buf) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { - if(H5F_block_write(file, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (len > dset_contig->sieve_buf_size) { + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ else { /* Allocate room for the data sieve buffer */ - if(NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) + if (NULL == (dset_contig->sieve_buf = H5FL_BLK_CALLOC(sieve_buf, dset_contig->sieve_buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Clear memory */ - if(dset_contig->sieve_size > len) + if (dset_contig->sieve_size > len) HDmemset(dset_contig->sieve_buf + len, 0, (dset_contig->sieve_size - len)); /* Determine the new sieve buffer size & location */ dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Set up the buffer parameters */ @@ -1052,9 +1012,10 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); /* Check if there is any point in reading the data from the file */ - if(dset_contig->sieve_size > len) { + if (dset_contig->sieve_size > len) { /* Read the new sieve buffer */ - if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ @@ -1066,16 +1027,16 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Stash local copies of these values */ sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; + sieve_size = dset_contig->sieve_size; + sieve_end = sieve_start + sieve_size; } /* end else */ - } /* end if */ + } /* end if */ else { /* Compute end of sequence to retrieve */ contig_end = addr + len - 1; /* If entire write is within the sieve buffer, write it to the buffer */ - if(addr >= sieve_start && contig_end < sieve_end) { + if (addr >= sieve_start && contig_end < sieve_end) { unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start); /* Put the data into the sieve buffer */ @@ -1087,14 +1048,15 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(len > dset_contig->sieve_buf_size) { + if (len > dset_contig->sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ - if((sieve_start >= addr && sieve_start < (contig_end + 1)) - || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { + if ((sieve_start >= addr && sieve_start < (contig_end + 1)) || + ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -1102,24 +1064,24 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, } /* end if */ /* Force the sieve buffer to be re-read the next time */ - dset_contig->sieve_loc = HADDR_UNDEF; + dset_contig->sieve_loc = HADDR_UNDEF; dset_contig->sieve_size = 0; } /* end if */ /* Write directly from the user's buffer */ - if(H5F_block_write(file, H5FD_MEM_DRAW, addr, len, buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, addr, len, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") } /* end if */ /* Element size fits within the buffer size */ else { /* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */ - if(((addr + len) == sieve_start || addr == sieve_end) && - (len + sieve_size) <= dset_contig->sieve_buf_size && - dset_contig->sieve_dirty) { + if (((addr + len) == sieve_start || addr == sieve_end) && + (len + sieve_size) <= dset_contig->sieve_buf_size && dset_contig->sieve_dirty) { /* Prepend to existing sieve buffer */ - if((addr + len) == sieve_start) { + if ((addr + len) == sieve_start) { /* Move existing sieve information to correct location */ - HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, dset_contig->sieve_size); + HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, + dset_contig->sieve_size); /* Copy in new information (must be first in sieve buffer) */ H5MM_memcpy(dset_contig->sieve_buf, buf, len); @@ -1136,18 +1098,14 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Adjust sieve size */ dset_contig->sieve_size += len; - - /* Update local copies of sieve information */ - sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; } /* end if */ /* Can't add the new data onto the existing sieve buffer */ else { /* Flush the sieve buffer if it's dirty */ - if(dset_contig->sieve_dirty) { + if (dset_contig->sieve_dirty) { /* Write to file */ - if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_write(f_sh, H5FD_MEM_DRAW, sieve_start, sieve_size, + dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ @@ -1158,7 +1116,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, dset_contig->sieve_loc = addr; /* Make certain we don't read off the end of the file */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW))) + if (HADDR_UNDEF == (rel_eoa = H5F_shared_get_eoa(f_sh, H5FD_MEM_DRAW))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine file size") /* Only need this when resizing sieve buffer */ @@ -1172,15 +1130,11 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, min = MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size); H5_CHECKED_ASSIGN(dset_contig->sieve_size, size_t, min, hsize_t); - /* Update local copies of sieve information */ - sieve_start = dset_contig->sieve_loc; - sieve_size = dset_contig->sieve_size; - sieve_end = sieve_start + sieve_size; - /* Check if there is any point in reading the data from the file */ - if(dset_contig->sieve_size > len) { + if (dset_contig->sieve_size > len) { /* Read the new sieve buffer */ - if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, dset_contig->sieve_buf) < 0) + if (H5F_shared_block_read(f_sh, H5FD_MEM_DRAW, dset_contig->sieve_loc, + dset_contig->sieve_size, dset_contig->sieve_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "block read failed") } /* end if */ @@ -1190,15 +1144,14 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, /* Set sieve buffer dirty flag */ dset_contig->sieve_dirty = TRUE; } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv_sieve_cb() */ +} /* end H5D__contig_writevv_sieve_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv_cb * @@ -1214,20 +1167,21 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, static herr_t H5D__contig_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_contig_writevv_ud_t *udata = (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_contig_writevv_ud_t *udata = + (H5D_contig_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5F_block_write(udata->file, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, (udata->wbuf + src_off)) < 0) + if (H5F_shared_block_write(udata->f_sh, H5FD_MEM_DRAW, (udata->dset_addr + dst_off), len, + (udata->wbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "block write failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv_cb() */ +} /* end H5D__contig_writevv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_writevv * @@ -1247,11 +1201,11 @@ H5D__contig_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udat *------------------------------------------------------------------------- */ static ssize_t -H5D__contig_writevv(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_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__contig_writevv(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_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -1265,41 +1219,40 @@ H5D__contig_writevv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Check if data sieving is enabled */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_DATA_SIEVE)) { - H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ + if (H5F_SHARED_HAS_FEATURE(io_info->f_sh, H5FD_FEAT_DATA_SIEVE)) { + H5D_contig_writevv_sieve_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.file = io_info->dset->oloc.file; - udata.dset_contig = &(io_info->dset->shared->cache.contig); + udata.f_sh = io_info->f_sh; + udata.dset_contig = &(io_info->dset->shared->cache.contig); udata.store_contig = &(io_info->store->contig); - udata.wbuf = (const unsigned char *)io_info->u.wbuf; + udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_writevv_sieve_cb, &udata)) < 0) + if ((ret_value = + H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_sieve_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized sieve buffer write") } /* end if */ else { - H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ + H5D_contig_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ /* Set up user data for H5VM_opvv() */ - udata.file = io_info->dset->oloc.file; + udata.f_sh = io_info->f_sh; udata.dset_addr = io_info->store->contig.dset_addr; - udata.wbuf = (const unsigned char *)io_info->u.wbuf; + udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__contig_writevv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__contig_writevv_cb, &udata)) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized read") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__contig_writevv() */ +} /* end H5D__contig_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_flush * @@ -1315,7 +1268,7 @@ H5D__contig_writevv(const H5D_io_info_t *io_info, static herr_t H5D__contig_flush(H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1323,14 +1276,13 @@ H5D__contig_flush(H5D_t *dset) HDassert(dset); /* Flush any data in sieve buffer */ - if(H5D__flush_sieve_buf(dset) < 0) + if (H5D__flush_sieve_buf(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush sieve buffer") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_copy * @@ -1344,41 +1296,41 @@ H5D__contig_flush(H5D_t *dset) *------------------------------------------------------------------------- */ 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 *dt_src, - H5O_copy_t *cpy_info) +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 *dt_src, H5O_copy_t *cpy_info) { - 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 */ - 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 src_dt_size = 0; /* Source datatype size */ - size_t mem_dt_size = 0; /* Memory datatype size */ - size_t dst_dt_size = 0; /* Destination datatype size */ - size_t max_dt_size; /* Max. datatype size */ - size_t nelmts = 0; /* Number of elements in buffer */ - size_t src_nbytes; /* Number of bytes to read from source */ - size_t mem_nbytes; /* Number of bytes to convert in memory */ - 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 */ - 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 */ - hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ - H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ - hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */ - haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */ - haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 src_dt_size = 0; /* Source datatype size */ + size_t mem_dt_size = 0; /* Memory datatype size */ + size_t dst_dt_size = 0; /* Destination datatype size */ + size_t max_dt_size; /* Max. datatype size */ + size_t nelmts = 0; /* Number of elements in buffer */ + size_t src_nbytes; /* Number of bytes to read from source */ + size_t mem_nbytes; /* Number of bytes to convert in memory */ + 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 */ + 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 */ + hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ + H5D_shared_t *shared_fo = + (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ + hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */ + haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */ + haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1390,7 +1342,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, HDassert(dt_src); /* Allocate space for destination raw data */ - if(H5D__contig_alloc(f_dst, storage_dst) < 0) + if (H5D__contig_alloc(f_dst, storage_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to allocate contiguous storage") /* Set up number of bytes to copy, and initial buffer size */ @@ -1402,49 +1354,49 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* Create datatype ID for src datatype. We may or may not use this ID, * but this ensures that the src datatype will be freed. */ - if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + if ((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* If there's a VLEN source datatype, set up type conversion information */ - if(H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { + if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { /* create a memory copy of the variable-length datatype */ - if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") - if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { (void)H5T_close_real(dt_mem); HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ /* create variable-length datatype at the destinaton file */ - if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + 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, f_dst, H5T_LOC_DISK) < 0) { + if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ - if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { (void)H5T_close_real(dt_dst); HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") } /* end if */ /* Set up the conversion functions */ - if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") - if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") /* Determine largest datatype size */ - if(0 == (src_dt_size = H5T_get_size(dt_src))) + if (0 == (src_dt_size = H5T_get_size(dt_src))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") - if(0 == (mem_dt_size = H5T_get_size(dt_mem))) + if (0 == (mem_dt_size = H5T_get_size(dt_mem))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(src_dt_size, mem_dt_size); - if(0 == (dst_dt_size = H5T_get_size(dt_dst))) + if (0 == (dst_dt_size = H5T_get_size(dt_dst))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") max_dt_size = MAX(max_dt_size, dst_dt_size); /* Set maximum number of whole elements that fit in buffer */ - if(0 == (nelmts = buf_size / max_dt_size)) + if (0 == (nelmts = buf_size / max_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large") /* Set the number of bytes to transfer */ @@ -1459,11 +1411,11 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, buf_dim[0] = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) + 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 */ - if((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { + 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") } /* end if */ @@ -1473,9 +1425,9 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ else { /* Check for reference datatype */ - if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { + if (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) { /* Need to fix values of references when copying across files */ - if(f_src != f_dst) + if (f_src != f_dst) fix_ref = TRUE; } /* end if */ @@ -1485,16 +1437,16 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* Allocate space for copy buffer */ HDassert(buf_size); - if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") /* Need extra buffer for datatype conversions, to prevent stranding/leaking memory */ - if(is_vlen || fix_ref) { - if(NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (is_vlen || fix_ref) { + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") /* allocate temporary bkg buff for data conversion */ - if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) + if (NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") } /* end if */ @@ -1504,23 +1456,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* If data sieving is enabled and the dataset is open in the file, set up to copy data out of the sieve buffer if deemed possible later */ - if(H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) && - shared_fo && shared_fo->cache.contig.sieve_buf) { - try_sieve = TRUE; + if (H5F_HAS_FEATURE(f_src, H5FD_FEAT_DATA_SIEVE) && shared_fo && shared_fo->cache.contig.sieve_buf) { + try_sieve = TRUE; sieve_start = shared_fo->cache.contig.sieve_loc; - sieve_end = sieve_start + shared_fo->cache.contig.sieve_size; + sieve_end = sieve_start + shared_fo->cache.contig.sieve_size; } - while(total_src_nbytes > 0) { + while (total_src_nbytes > 0) { /* Check if we should reduce the number of bytes to transfer */ - if(total_src_nbytes < src_nbytes) { + if (total_src_nbytes < src_nbytes) { /* Adjust bytes to transfer */ src_nbytes = (size_t)total_src_nbytes; /* Adjust dataspace describing buffer */ - if(is_vlen) { + if (is_vlen) { /* Adjust destination & memory bytes to transfer */ - nelmts = src_nbytes / src_dt_size; + nelmts = src_nbytes / src_dt_size; dst_nbytes = nelmts * dst_dt_size; mem_nbytes = nelmts * mem_dt_size; @@ -1528,7 +1479,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, buf_dim[0] = nelmts; /* Adjust size of buffer's dataspace */ - if(H5S_set_extent_real(buf_space, buf_dim) < 0) + if (H5S_set_extent_real(buf_space, buf_dim) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to change buffer dataspace size") } /* end if */ else @@ -1537,19 +1488,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ /* If the entire copy is within the sieve buffer, copy data from the sieve buffer */ - if(try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes -1) < sieve_end)) { + if (try_sieve && (addr_src >= sieve_start) && ((addr_src + src_nbytes - 1) < sieve_end)) { unsigned char *base_sieve_buf = shared_fo->cache.contig.sieve_buf + (addr_src - sieve_start); H5MM_memcpy(buf, base_sieve_buf, src_nbytes); - } else + } + 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") + 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") /* Perform datatype conversion, if necessary */ - if(is_vlen) { + if (is_vlen) { /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ @@ -1559,27 +1511,22 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ - if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Reclaim space from variable length data */ - if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data") } /* end if */ - else if(fix_ref) { + else if (fix_ref) { /* Check for expanding references */ - if(cpy_info->expand_ref) { - size_t ref_count; - - /* Determine # of reference elements to copy */ - ref_count = src_nbytes / H5T_get_size(dt_src); - + if (cpy_info->expand_ref) { /* Copy the reference elements */ - if(H5O_copy_expand_ref(f_src, buf, f_dst, bkg, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0) + if (H5O_copy_expand_ref(f_src, tid_src, dt_src, buf, buf_size, f_dst, bkg, cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") /* After fix ref, copy the new reference elements to the buffer to write out */ - H5MM_memcpy(buf, bkg, buf_size); + H5MM_memcpy(buf, bkg, buf_size); } /* end if */ else /* Reset value to zero */ @@ -1587,7 +1534,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end if */ /* Write raw data to destination file */ - if(H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0) + if (H5F_block_write(f_dst, H5FD_MEM_DRAW, addr_dst, dst_nbytes, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write raw data") /* Adjust loop variables */ @@ -1597,21 +1544,20 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end while */ done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(buf) + if (buf) buf = H5FL_BLK_FREE(type_conv, buf); - if(reclaim_buf) + if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); - if(bkg) + if (bkg) bkg = H5FL_BLK_FREE(type_conv, bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_copy() */ - diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index 7220868ae12..d39d357f41e 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,50 +15,42 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Ddebug * @@ -72,23 +64,23 @@ herr_t H5Ddebug(hid_t dset_id) { - H5D_t *dset; /* Dataset to debug */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_t *dset; /* Dataset to debug */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ - if(H5D_CHUNKED == dset->shared->layout.type) + if (H5D_CHUNKED == dset->shared->layout.type) (void)H5D__chunk_dump_index(dset, stdout); - else if(H5D_CONTIGUOUS == dset->shared->layout.type) - HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.storage.u.contig.addr); + else if (H5D_CONTIGUOUS == dset->shared->layout.type) + HDfprintf(stdout, " %-10s %" PRIuHADDR "\n", + "Address:", dset->shared->layout.storage.u.contig.addr); done: FUNC_LEAVE_API(ret_value) } /* end H5Ddebug() */ - diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 8bb9e1e4606..ec1998f0b07 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,56 +29,48 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Dcreate1 * @@ -109,56 +101,60 @@ *------------------------------------------------------------------------- */ hid_t -H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t dcpl_id) +H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t dapl_id = H5P_DEFAULT; /* DAPL used by library */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") - if(H5P_DEFAULT == dcpl_id) + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") + + if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") + else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Set the DCPL for the API context */ + H5CX_set_dcpl(dcpl_id); + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, dapl_id))) + if (NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, type_id, + space_id, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if (H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ - /*------------------------------------------------------------------------- * Function: H5Dopen1 * @@ -179,38 +175,45 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t H5Dopen1(hid_t loc_id, const char *name) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, H5P_DATASET_ACCESS_DEFAULT))) + if (NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, H5P_DATASET_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Get an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: - if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if (H5I_INVALID_HID == ret_value) + if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen1() */ - /*------------------------------------------------------------------------- * Function: H5Dextend * @@ -230,38 +233,113 @@ H5Dopen1(hid_t loc_id, const char *name) herr_t H5Dextend(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Pointer to dataset to modify */ - hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + 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(!size) + if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") - /* Make certain that the dataset dimensions don't decrease */ - /* (Shrinking dimensions is possible with H5Dset_extent, but not H5Dextend) */ - if(H5S_get_simple_extent_dims(dset->shared->space, dset_dims, NULL) < 0) + /* Get the dataspace pointer for the dataset */ + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataspace") + if (H5I_INVALID_HID == sid) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "received an invalid dataspace from the dataset") + if (NULL == (ds = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get dataspace structure from ID") + + /* Get the dataset's current extent */ + if (H5S_get_simple_extent_dims(ds, dset_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - for(u = 0; u < dset->shared->ndims; u++) - if(size[u] > dset_dims[u]) - dset_dims[u] = size[u]; + + /* Get the dataset dimensions */ + ndims = H5S_GET_EXTENT_NDIMS(ds); + + /* Make certain that the dataset dimensions don't decrease in any dimension. + * + * (Shrinking dimensions is possible with H5Dset_extent, but not H5Dextend) + * + * XXX (VOL_MERGE): I feel like we should fail here instead of just silently + * not doing what we're supposed to do. + */ + for (i = 0; i < ndims; i++) + if (size[i] > dset_dims[i]) + dset_dims[i] = size[i]; /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dset_id) < 0) + if (H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Increase size */ - if(H5D__set_extent(dset, dset_dims) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, dset_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to extend dataset") done: + /* Close the dataspace */ + if (sid != H5I_INVALID_HID && H5I_dec_app_ref(sid) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close dataspace") + FUNC_LEAVE_API(ret_value) } /* end H5Dextend() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +/*------------------------------------------------------------------------- + * Function: H5Dvlen_reclaim + * + * Purpose: Frees the buffers allocated for storing variable-length data + * in memory. Only frees the VL data in the selection defined in the + * dataspace. The dataset transfer property list is required to find the + * correct allocation/free methods for the VL data in the buffer. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * Thursday, June 10, 1999 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) +{ + H5S_t *space; /* Dataspace for iteration */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf); + + /* Check args */ + if (H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") + if (!(H5S_has_extent(space))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Call internal routine */ + ret_value = H5T_reclaim(type_id, space, buf); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Dvlen_reclaim() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index a53489e8cd6..abce23308cf 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,30 +25,30 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EAprivate.h" /* Extensible arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EAprivate.h" /* Extensible arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Value to fill unset array elements with */ -#define H5D_EARRAY_FILL HADDR_UNDEF -#define H5D_EARRAY_FILT_FILL {HADDR_UNDEF, 0, 0} - +#define H5D_EARRAY_FILL HADDR_UNDEF +#define H5D_EARRAY_FILT_FILL \ + { \ + HADDR_UNDEF, 0, 0 \ + } /******************/ /* Local Typedefs */ @@ -56,33 +56,32 @@ /* Extensible array create/open user data */ typedef struct H5D_earray_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes) */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes) */ } H5D_earray_ctx_ud_t; /* Extensible array callback context */ typedef struct H5D_earray_ctx_t { - size_t file_addr_len; /* Size of addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + size_t file_addr_len; /* Size of addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ } H5D_earray_ctx_t; /* Extensible Array callback info for iteration over chunks */ typedef struct H5D_earray_it_ud_t { - H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ - 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 */ + H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ + 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 */ } H5D_earray_it_ud_t; /* Native extensible array element for chunks w/filters */ typedef struct H5D_earray_filt_elmt_t { - haddr_t addr; /* Address of chunk */ - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + haddr_t addr; /* Address of chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5D_earray_filt_elmt_t; - /********************/ /* Local Prototypes */ /********************/ @@ -91,119 +90,106 @@ 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 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 herr_t H5D__earray_dst_dbg_context(void *dbg_ctx); /* Extensible array class callbacks for chunks w/filters */ /* (some shared with callbacks for chunks w/o filters) */ static herr_t 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); -static herr_t H5D__earray_filt_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); +static herr_t 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); +static herr_t H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Chunked layout indexing callbacks */ -static herr_t H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout); -static int H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, - FILE *stream); -static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout); +static int H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic extensible array routines */ static herr_t H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info); static herr_t H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info); - /*********************/ /* Package Variables */ /*********************/ /* Extensible array indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{ - TRUE, /* Extensible array indices support SWMR access */ - H5D__earray_idx_init, /* init */ - H5D__earray_idx_create, /* create */ - H5D__earray_idx_is_space_alloc, /* is_space_alloc */ - H5D__earray_idx_insert, /* insert */ - H5D__earray_idx_get_addr, /* get_addr */ - H5D__earray_idx_resize, /* resize */ - H5D__earray_idx_iterate, /* iterate */ - H5D__earray_idx_remove, /* remove */ - H5D__earray_idx_delete, /* delete */ - H5D__earray_idx_copy_setup, /* copy_setup */ - H5D__earray_idx_copy_shutdown, /* copy_shutdown */ - H5D__earray_idx_size, /* size */ - H5D__earray_idx_reset, /* reset */ - H5D__earray_idx_dump, /* dump */ - H5D__earray_idx_dest /* destroy */ + TRUE, /* Extensible array indices support SWMR access */ + H5D__earray_idx_init, /* init */ + H5D__earray_idx_create, /* create */ + H5D__earray_idx_is_space_alloc, /* is_space_alloc */ + H5D__earray_idx_insert, /* insert */ + H5D__earray_idx_get_addr, /* get_addr */ + H5D__earray_idx_resize, /* resize */ + H5D__earray_idx_iterate, /* iterate */ + H5D__earray_idx_remove, /* remove */ + H5D__earray_idx_delete, /* delete */ + H5D__earray_idx_copy_setup, /* copy_setup */ + H5D__earray_idx_copy_shutdown, /* copy_shutdown */ + H5D__earray_idx_size, /* size */ + H5D__earray_idx_reset, /* reset */ + H5D__earray_idx_dump, /* dump */ + H5D__earray_idx_dest /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ /* Extensible array class callbacks for dataset chunks w/o filters */ -const H5EA_class_t H5EA_CLS_CHUNK[1]={{ - H5EA_CLS_CHUNK_ID, /* Type of extensible array */ - "Chunk w/o filters", /* Name of extensible array class */ - sizeof(haddr_t), /* Size of native element */ - H5D__earray_crt_context, /* Create context */ - H5D__earray_dst_context, /* Destroy context */ - H5D__earray_fill, /* Fill block of missing elements callback */ - H5D__earray_encode, /* Element encoding callback */ - H5D__earray_decode, /* Element decoding callback */ - H5D__earray_debug, /* Element debugging callback */ +const H5EA_class_t H5EA_CLS_CHUNK[1] = {{ + H5EA_CLS_CHUNK_ID, /* Type of extensible array */ + "Chunk w/o filters", /* Name of extensible array class */ + sizeof(haddr_t), /* Size of native element */ + H5D__earray_crt_context, /* Create context */ + H5D__earray_dst_context, /* Destroy context */ + H5D__earray_fill, /* Fill block of missing elements callback */ + H5D__earray_encode, /* Element encoding callback */ + H5D__earray_decode, /* Element decoding callback */ + H5D__earray_debug, /* Element debugging callback */ H5D__earray_crt_dbg_context, /* Create debugging context */ H5D__earray_dst_dbg_context /* Destroy debugging context */ }}; /* Extensible array class callbacks for dataset chunks w/filters */ -const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{ - H5EA_CLS_FILT_CHUNK_ID, /* Type of extensible array */ - "Chunk w/filters", /* Name of extensible array class */ +const H5EA_class_t H5EA_CLS_FILT_CHUNK[1] = {{ + H5EA_CLS_FILT_CHUNK_ID, /* Type of extensible array */ + "Chunk w/filters", /* Name of extensible array class */ sizeof(H5D_earray_filt_elmt_t), /* Size of native element */ - H5D__earray_crt_context, /* Create context */ - H5D__earray_dst_context, /* Destroy context */ - H5D__earray_filt_fill, /* Fill block of missing elements callback */ - H5D__earray_filt_encode, /* Element encoding callback */ - H5D__earray_filt_decode, /* Element decoding callback */ - H5D__earray_filt_debug, /* Element debugging callback */ - H5D__earray_crt_dbg_context, /* Create debugging context */ - H5D__earray_dst_dbg_context /* Destroy debugging context */ + H5D__earray_crt_context, /* Create context */ + H5D__earray_dst_context, /* Destroy context */ + H5D__earray_filt_fill, /* Fill block of missing elements callback */ + H5D__earray_filt_encode, /* Element encoding callback */ + H5D__earray_filt_decode, /* Element decoding callback */ + H5D__earray_filt_debug, /* Element debugging callback */ + H5D__earray_crt_dbg_context, /* Create debugging context */ + H5D__earray_dst_dbg_context /* Destroy debugging context */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -213,8 +199,6 @@ const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{ H5FL_DEFINE_STATIC(H5D_earray_ctx_t); H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); - - /*------------------------------------------------------------------------- * Function: H5D__earray_crt_context * @@ -231,9 +215,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 @@ -243,8 +227,9 @@ H5D__earray_crt_context(void *_udata) HDassert(udata->chunk_size > 0); /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5D_earray_ctx_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate extensible array client callback context") + if (NULL == (ctx = H5FL_MALLOC(H5D_earray_ctx_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Initialize the context */ ctx->file_addr_len = H5F_SIZEOF_ADDR(udata->f); @@ -253,7 +238,7 @@ H5D__earray_crt_context(void *_udata) * for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -263,7 +248,6 @@ H5D__earray_crt_context(void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_dst_context * @@ -280,7 +264,7 @@ H5D__earray_crt_context(void *_udata) static herr_t H5D__earray_dst_context(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 */ FUNC_ENTER_STATIC_NOERR @@ -293,7 +277,6 @@ H5D__earray_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_fill * @@ -310,7 +293,7 @@ H5D__earray_dst_context(void *_ctx) static herr_t H5D__earray_fill(void *nat_blk, size_t nelmts) { - haddr_t fill_val = H5D_EARRAY_FILL; /* Value to fill elements with */ + haddr_t fill_val = H5D_EARRAY_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -323,7 +306,6 @@ H5D__earray_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_encode * @@ -340,8 +322,8 @@ 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) { - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -352,7 +334,7 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); @@ -367,7 +349,6 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_decode * @@ -384,9 +365,9 @@ 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) { - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -396,7 +377,7 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); @@ -411,7 +392,6 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_debug * @@ -426,10 +406,9 @@ 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) +H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) { - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -438,14 +417,12 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, - *(const haddr_t *)elmt); + HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_fill * @@ -462,7 +439,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static herr_t H5D__earray_filt_fill(void *nat_blk, size_t nelmts) { - H5D_earray_filt_elmt_t fill_val = H5D_EARRAY_FILT_FILL; /* Value to fill elements with */ + H5D_earray_filt_elmt_t fill_val = H5D_EARRAY_FILT_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -476,7 +453,6 @@ H5D__earray_filt_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_encode * @@ -493,9 +469,10 @@ 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 */ - const H5D_earray_filt_elmt_t *elmt = (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native 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 */ FUNC_ENTER_STATIC_NOERR @@ -506,7 +483,7 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); @@ -523,7 +500,6 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_decode * @@ -540,8 +516,9 @@ 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_filt_elmt_t *elmt = (H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -552,7 +529,7 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); @@ -569,7 +546,6 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_filt_debug * @@ -584,11 +560,11 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx *------------------------------------------------------------------------- */ static herr_t -H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *_elmt) +H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *_elmt) { - const H5D_earray_filt_elmt_t *elmt = (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ - char temp_str[128]; /* Temporary string, for formatting */ + const H5D_earray_filt_elmt_t *elmt = + (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -597,14 +573,13 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, - elmt->addr, elmt->nbytes, elmt->filter_mask); + HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, + elmt->nbytes, elmt->filter_mask); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_crt_dbg_context * @@ -621,11 +596,11 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static void * H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) { - H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ - 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 */ + H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ + 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 */ FUNC_ENTER_STATIC @@ -634,8 +609,9 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) HDassert(H5F_addr_defined(obj_addr)); /* Allocate context for debugging callback */ - if(NULL == (dbg_ctx = H5FL_MALLOC(H5D_earray_ctx_ud_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate extensible array client callback context") + if (NULL == (dbg_ctx = H5FL_MALLOC(H5D_earray_ctx_ud_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Set up the object header location info */ H5O_loc_reset(&obj_loc); @@ -643,20 +619,20 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) obj_loc.addr = obj_addr; /* Open the object header where the layout message resides */ - if(H5O_open(&obj_loc) < 0) + if (H5O_open(&obj_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "can't open object header") obj_opened = TRUE; /* Read the layout message */ - if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) + if (NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") /* close the object header */ - if(H5O_close(&obj_loc, NULL) < 0) + if (H5O_close(&obj_loc, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") /* Create user data */ - dbg_ctx->f = f; + dbg_ctx->f = f; dbg_ctx->chunk_size = layout.u.chunk.size; /* Set return value */ @@ -664,21 +640,20 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) done: /* Cleanup on error */ - if(ret_value == NULL) { + if (ret_value == NULL) { /* Release context structure */ - if(dbg_ctx) + if (dbg_ctx) dbg_ctx = H5FL_FREE(H5D_earray_ctx_ud_t, dbg_ctx); /* Close object header */ - if(obj_opened) - if(H5O_close(&obj_loc, NULL) < 0) + if (obj_opened) + if (H5O_close(&obj_loc, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_dst_dbg_context * @@ -695,7 +670,8 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) static herr_t H5D__earray_dst_dbg_context(void *_dbg_ctx) { - H5D_earray_ctx_ud_t *dbg_ctx = (H5D_earray_ctx_ud_t *)_dbg_ctx; /* Context for extensible array callback */ + H5D_earray_ctx_ud_t *dbg_ctx = + (H5D_earray_ctx_ud_t *)_dbg_ctx; /* Context for extensible array callback */ FUNC_ENTER_STATIC_NOERR @@ -708,7 +684,6 @@ H5D__earray_dst_dbg_context(void *_dbg_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_depend * @@ -726,10 +701,10 @@ 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_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 */ + 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 */ FUNC_ENTER_STATIC @@ -751,26 +726,26 @@ H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.earray.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the extensible array a child flush dependency of the dataset's object header */ - if(H5EA_depend(idx_info->storage->u.earray.ea, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5EA_depend(idx_info->storage->u.earray.ea, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_open * @@ -792,8 +767,8 @@ H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) static herr_t H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_earray_ctx_ud_t udata; /* User data for extensible array open call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_earray_ctx_ud_t udata; /* User data for extensible array open call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -809,23 +784,24 @@ H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.earray.ea); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Open the extensible array for the chunk index */ - if(NULL == (idx_info->storage->u.earray.ea = H5EA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) + if (NULL == + (idx_info->storage->u.earray.ea = H5EA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open extensible array") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__earray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__earray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_init * @@ -839,15 +815,14 @@ H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, - haddr_t dset_ohdr_addr) +H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, haddr_t dset_ohdr_addr) { - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Max. size of dataset dimensions */ - int unlim_dim; /* Rank of the dataset's unlimited dimension */ - int sndims; /* Rank of dataspace */ - unsigned ndims; /* Rank of dataspace */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Max. size of dataset dimensions */ + int unlim_dim; /* Rank of the dataset's unlimited dimension */ + int sndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -861,26 +836,26 @@ H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, HDassert(H5F_addr_defined(dset_ohdr_addr)); /* Get the dim info for dataset */ - if((sndims = H5S_get_simple_extent_dims(space, NULL, max_dims)) < 0) + if ((sndims = H5S_get_simple_extent_dims(space, NULL, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Find the rank of the unlimited dimension */ unlim_dim = (-1); - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { /* Check for unlimited dimension */ - if(H5S_UNLIMITED == max_dims[u]) { + if (H5S_UNLIMITED == max_dims[u]) { /* Check if we've already found an unlimited dimension */ - if(unlim_dim >= 0) + if (unlim_dim >= 0) HGOTO_ERROR(H5E_DATASET, H5E_ALREADYINIT, FAIL, "already found unlimited dimension") /* Set the unlimited dimension */ unlim_dim = (int)u; } /* end if */ - } /* end for */ + } /* end for */ /* Check if we didn't find an unlimited dimension */ - if(unlim_dim < 0) + if (unlim_dim < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNINITIALIZED, FAIL, "didn't find unlimited dimension") /* Set the unlimited dimension for the layout's future use */ @@ -893,7 +868,6 @@ H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_create * @@ -915,9 +889,9 @@ H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, static herr_t H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5EA_create_t cparam; /* Extensible array creation parameters */ - H5D_earray_ctx_ud_t udata; /* User data for extensible array create call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_create_t cparam; /* Extensible array creation parameters */ + H5D_earray_ctx_ud_t udata; /* User data for extensible array create call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -931,21 +905,21 @@ H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.earray.ea); /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - cparam.cls = H5EA_CLS_FILT_CHUNK; + cparam.cls = H5EA_CLS_FILT_CHUNK; cparam.raw_elmt_size = (uint8_t)(H5F_SIZEOF_ADDR(idx_info->f) + chunk_size_len + 4); } /* end if */ else { - cparam.cls = H5EA_CLS_CHUNK; + cparam.cls = H5EA_CLS_CHUNK; cparam.raw_elmt_size = (uint8_t)H5F_SIZEOF_ADDR(idx_info->f); } /* end else */ cparam.max_nelmts_bits = idx_info->layout->u.earray.cparam.max_nelmts_bits; @@ -960,27 +934,27 @@ H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(cparam.max_dblk_page_nelmts_bits > 0); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Create the extensible array for the chunk index */ - if(NULL == (idx_info->storage->u.earray.ea = H5EA_create(idx_info->f, &cparam, &udata))) + if (NULL == (idx_info->storage->u.earray.ea = H5EA_create(idx_info->f, &cparam, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create extensible array") /* Get the address of the extensible array in file */ - if(H5EA_get_addr(idx_info->storage->u.earray.ea, &(idx_info->storage->idx_addr)) < 0) + if (H5EA_get_addr(idx_info->storage->u.earray.ea, &(idx_info->storage->idx_addr)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array address") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__earray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__earray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_is_space_alloc * @@ -1004,7 +978,6 @@ H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__earray_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_insert * @@ -1018,10 +991,10 @@ H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5EA_t *ea; /* Pointer to extensible array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1035,36 +1008,37 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") - if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ + if (udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); elmt.filter_mask = udata->filter_mask; /* Set the info for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &elmt) < 0) + if (H5EA_set(ea, udata->chunk_idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { /* Set the address for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) + if (H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") } /* end else */ @@ -1072,7 +1046,6 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_get_addr * @@ -1090,9 +1063,9 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata static herr_t H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5EA_t *ea; /* Pointer to extensible array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1106,69 +1079,71 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Check for unlimited dim. not being the slowest-changing dim. */ - if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + if (idx_info->layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ unsigned u; /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) swizzled_coords[u] = udata->common.scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); /* Calculate the index of this chunk */ - idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_max_down_chunks); + idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, + idx_info->layout->u.earray.swizzled_max_down_chunks); } /* end if */ else { /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); } /* end else */ udata->chunk_idx = idx; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ /* Get the information for the chunk */ - if(H5EA_get(ea, idx, &elmt) < 0) + if (H5EA_get(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Set the info for the chunk */ udata->chunk_block.offset = elmt.addr; udata->chunk_block.length = elmt.nbytes; - udata->filter_mask = elmt.filter_mask; + udata->filter_mask = elmt.filter_mask; } /* end if */ else { /* Get the address for the chunk */ - if(H5EA_get(ea, idx, &udata->chunk_block.offset) < 0) + if (H5EA_get(ea, idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_resize * @@ -1185,17 +1160,16 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda static herr_t H5D__earray_idx_resize(H5O_layout_chunk_t *layout) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(layout); /* "Swizzle" constant dimensions for this dataset */ - if(layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of # of chunks in each dimension */ - hsize_t swizzled_max_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of max # of chunks in each dimension */ + if (layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of # of chunks in each dimension */ + hsize_t + swizzled_max_chunks[H5O_LAYOUT_NDIMS]; /* Swizzled form of max # of chunks in each dimension */ /* Get the swizzled chunk dimensions */ H5MM_memcpy(layout->u.earray.swizzled_dim, layout->dim, (layout->ndims - 1) * sizeof(layout->dim[0])); @@ -1206,23 +1180,20 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) H5VM_swizzle_coords(hsize_t, swizzled_chunks, layout->u.earray.unlim_dim); /* Get the swizzled "down" sizes for each dimension */ - if(H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") + H5VM_array_down((layout->ndims - 1), swizzled_chunks, layout->u.earray.swizzled_down_chunks); /* Get the swizzled max number of chunks in each dimension */ - H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, (layout->ndims - 1) * sizeof(swizzled_max_chunks[0])); + H5MM_memcpy(swizzled_max_chunks, layout->max_chunks, + (layout->ndims - 1) * sizeof(swizzled_max_chunks[0])); H5VM_swizzle_coords(hsize_t, swizzled_max_chunks, layout->u.earray.unlim_dim); /* Get the swizzled max "down" sizes for each dimension */ - if(H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, layout->u.earray.swizzled_max_down_chunks) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute swizzled 'down' chunk size value") - } /* end if */ + H5VM_array_down((layout->ndims - 1), swizzled_max_chunks, layout->u.earray.swizzled_max_down_chunks); + } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_resize() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_iterate_cb * @@ -1237,39 +1208,39 @@ H5D__earray_idx_resize(H5O_layout_chunk_t *layout) static int H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void *_udata) { - H5D_earray_it_ud_t *udata = (H5D_earray_it_ud_t *)_udata; /* User data */ - unsigned ndims; /* Rank of chunk */ - int curr_dim; /* Current dimension */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_earray_it_ud_t *udata = (H5D_earray_it_ud_t *)_udata; /* User data */ + unsigned ndims; /* Rank of chunk */ + int curr_dim; /* Current dimension */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Compose generic chunk record for callback */ - if(udata->filtered) { + if (udata->filtered) { const H5D_earray_filt_elmt_t *filt_elmt = (const H5D_earray_filt_elmt_t *)_elmt; - udata->chunk_rec.chunk_addr = filt_elmt->addr; - udata->chunk_rec.nbytes = filt_elmt->nbytes; + udata->chunk_rec.chunk_addr = filt_elmt->addr; + udata->chunk_rec.nbytes = filt_elmt->nbytes; udata->chunk_rec.filter_mask = filt_elmt->filter_mask; } /* end if */ else udata->chunk_rec.chunk_addr = *(const haddr_t *)_elmt; /* Make "generic chunk" callback */ - if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + if (H5F_addr_defined(udata->chunk_rec.chunk_addr)) + if ((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; HDassert(ndims > 0); curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ udata->chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { + if (udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ udata->chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -1281,7 +1252,6 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_iterate * @@ -1300,12 +1270,11 @@ 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) +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_stat_t ea_stat; /* Extensible array statistics */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_stat_t ea_stat; /* Extensible array statistics */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1320,38 +1289,39 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } else /* Patch the top level file pointer contained in ea if needed */ + } + else /* Patch the top level file pointer contained in ea if needed */ H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Get the extensible array statistics */ - if(H5EA_get_stats(ea, &ea_stat) < 0) + if (H5EA_get_stats(ea, &ea_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") - if(ea_stat.stored.max_idx_set > 0) { - H5D_earray_it_ud_t udata; /* User data for iteration callback */ + if (ea_stat.stored.max_idx_set > 0) { + H5D_earray_it_ud_t udata; /* User data for iteration callback */ /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); - if(!udata.filtered) { - udata.chunk_rec.nbytes = idx_info->layout->size; + if (!udata.filtered) { + udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the extensible array elements */ - if((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ @@ -1359,7 +1329,6 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_remove * @@ -1375,9 +1344,9 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5EA_t *ea; /* Pointer to extensible array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t *ea; /* Pointer to extensible array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1391,78 +1360,81 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) { + if (NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") - } 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") + } + 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") /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Check for unlimited dim. not being the slowest-changing dim. */ - if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + if (idx_info->layout->u.earray.unlim_dim > 0) { + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ unsigned u; /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) swizzled_coords[u] = udata->scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); /* Calculate the index of this chunk */ - idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, idx_info->layout->u.earray.swizzled_max_down_chunks); + idx = H5VM_chunk_index(ndims, swizzled_coords, idx_info->layout->u.earray.swizzled_dim, + idx_info->layout->u.earray.swizzled_max_down_chunks); } /* end if */ else { /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->scaled); } /* end else */ /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + if (idx_info->pline->nused > 0) { + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ /* Get the info about the chunk for the index */ - if(H5EA_get(ea, idx, &elmt) < 0) + if (H5EA_get(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(elmt.addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the info about the chunk for the index */ - elmt.addr = HADDR_UNDEF; - elmt.nbytes = 0; + elmt.addr = HADDR_UNDEF; + elmt.nbytes = 0; elmt.filter_mask = 0; - if(H5EA_set(ea, idx, &elmt) < 0) + if (H5EA_set(ea, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk info") } /* end if */ else { - haddr_t addr = HADDR_UNDEF; /* Chunk address */ + haddr_t addr = HADDR_UNDEF; /* Chunk address */ /* Get the address of the chunk for the index */ - if(H5EA_get(ea, idx, &addr) < 0) + if (H5EA_get(ea, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the address of the chunk for the index */ addr = HADDR_UNDEF; - if(H5EA_set(ea, idx, &addr) < 0) + if (H5EA_set(ea, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk address") } /* end else */ @@ -1470,7 +1442,6 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t FUNC_LEAVE_NOAPI(ret_value) } /* H5D__earray_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_delete_cb * @@ -1487,8 +1458,8 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t static int H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1499,15 +1470,14 @@ H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(f); /* Remove raw data chunk from file */ - H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) + H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_delete_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_delete * @@ -1529,7 +1499,7 @@ H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) static herr_t H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1541,24 +1511,24 @@ H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { + if (H5F_addr_defined(idx_info->storage->idx_addr)) { H5D_earray_ctx_ud_t ctx_udata; /* User data for extensible array open call */ /* Iterate over the chunk addresses in the extensible array, deleting each chunk */ - if(H5D__earray_idx_iterate(idx_info, H5D__earray_idx_delete_cb, idx_info->f) < 0) + if (H5D__earray_idx_iterate(idx_info, H5D__earray_idx_delete_cb, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk addresses") /* Close extensible array */ - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; /* Set up the context user data */ - ctx_udata.f = idx_info->f; + ctx_udata.f = idx_info->f; ctx_udata.chunk_size = idx_info->layout->size; /* Delete extensible array */ - if(H5EA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) + if (H5EA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk extensible array") idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ @@ -1569,7 +1539,6 @@ H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_copy_setup * @@ -1583,10 +1552,9 @@ H5D__earray_idx_delete(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1604,16 +1572,16 @@ H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source extensible array is open yet */ - if(NULL == idx_info_src->storage->u.earray.ea) + if (NULL == idx_info_src->storage->u.earray.ea) /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info_src) < 0) + if (H5D__earray_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create the extensible array that describes chunked storage in the dest. file */ - if(H5D__earray_idx_create(idx_info_dst) < 0) + if (H5D__earray_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1624,7 +1592,6 @@ H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_copy_shutdown * @@ -1638,10 +1605,9 @@ H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, *------------------------------------------------------------------------- */ static herr_t -H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1652,10 +1618,10 @@ H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.earray.ea); /* Close extensible arrays */ - if(H5EA_close(storage_src->u.earray.ea) < 0) + if (H5EA_close(storage_src->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") storage_src->u.earray.ea = NULL; - if(H5EA_close(storage_dst->u.earray.ea) < 0) + if (H5EA_close(storage_dst->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") storage_dst->u.earray.ea = NULL; @@ -1663,7 +1629,6 @@ H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_size * @@ -1680,9 +1645,9 @@ H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, 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_stat_t ea_stat; /* Extensible array statistics */ - herr_t ret_value = SUCCEED; /* Return value */ + H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_stat_t ea_stat; /* Extensible array statistics */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1696,23 +1661,23 @@ H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open the extensible array in file */ - if(H5D__earray_idx_open(idx_info) < 0) + if (H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; /* Get the extensible array statistics */ - if(H5EA_get_stats(ea, &ea_stat) < 0) + if (H5EA_get_stats(ea, &ea_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") /* Set the size of the extensible array */ - *index_size = ea_stat.computed.hdr_size + ea_stat.computed.index_blk_size - + ea_stat.stored.super_blk_size + ea_stat.stored.data_blk_size; + *index_size = ea_stat.computed.hdr_size + ea_stat.computed.index_blk_size + + ea_stat.stored.super_blk_size + ea_stat.stored.data_blk_size; done: - if(idx_info->storage->u.earray.ea) { - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (idx_info->storage->u.earray.ea) { + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; } /* end if */ @@ -1720,7 +1685,6 @@ H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_reset * @@ -1742,8 +1706,8 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) { - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) { + storage->idx_addr = HADDR_UNDEF; storage->u.earray.dset_ohdr_addr = HADDR_UNDEF; } /* end if */ storage->u.earray.ea = NULL; @@ -1751,7 +1715,6 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_dump * @@ -1773,12 +1736,11 @@ H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__earray_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__earray_idx_dest * @@ -1794,7 +1756,7 @@ H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1804,14 +1766,14 @@ H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the extensible array is open */ - if(idx_info->storage->u.earray.ea) { + if (idx_info->storage->u.earray.ea) { /* 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) + 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") /* Close extensible array */ - if(H5EA_close(idx_info->storage->u.earray.ea) < 0) + if (H5EA_close(idx_info->storage->u.earray.ea) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->storage->u.earray.ea = NULL; } /* end if */ @@ -1819,4 +1781,3 @@ H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_dest() */ - diff --git a/src/H5Defl.c b/src/H5Defl.c index 79cec8c87d6..85c9dbaea44 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,99 +20,77 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 H5O_efl_t *efl; /* Pointer to efl info */ + 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 unsigned char *wbuf; /* Write buffer */ + 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; - /********************/ /* Local Prototypes */ /********************/ /* 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); -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[]); -static ssize_t H5D__efl_writevv(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[]); +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); +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[]); +static ssize_t H5D__efl_writevv(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[]); /* Helper routines */ -static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, - uint8_t *buf); +static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, uint8_t *buf); static herr_t H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, - const uint8_t *buf); - + const uint8_t *buf); /*********************/ /* Package Variables */ /*********************/ /* 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, NULL, H5D__efl_is_space_alloc, NULL, + H5D__efl_io_init, H5D__contig_read, H5D__contig_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - H5D__efl_readvv, - H5D__efl_writevv, - NULL, - NULL, - NULL -}}; - + H5D__efl_readvv, H5D__efl_writevv, NULL, NULL, NULL}}; /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__efl_construct * @@ -128,13 +106,13 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ static herr_t H5D__efl_construct(H5F_t *f, H5D_t *dset) { - size_t dt_size; /* Size of datatype */ - hssize_t stmp_size; /* Temporary holder for raw data size */ - hsize_t tmp_size; /* Temporary holder for raw data size */ - hsize_t max_points; /* Maximum elements */ - hsize_t max_storage; /* Maximum storage size */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t dt_size; /* Size of datatype */ + hssize_t stmp_size; /* Temporary holder for raw data size */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + hsize_t max_points; /* Maximum elements */ + hsize_t max_storage; /* Maximum storage size */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -149,24 +127,24 @@ H5D__efl_construct(H5F_t *f, H5D_t *dset) */ /* Check for invalid dataset dimensions */ - for(u = 1; u < dset->shared->ndims; u++) - if(dset->shared->max_dims[u] > dset->shared->curr_dims[u]) + for (u = 1; u < dset->shared->ndims; u++) + if (dset->shared->max_dims[u] > dset->shared->curr_dims[u]) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "only the first dimension can be extendible") /* Retrieve the size of the dataset's datatype */ - if(0 == (dt_size = H5T_get_size(dset->shared->type))) + if (0 == (dt_size = H5T_get_size(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to determine datatype size") /* Check for storage overflows */ - max_points = H5S_get_npoints_max(dset->shared->space); + max_points = H5S_get_npoints_max(dset->shared->space); max_storage = H5O_efl_total_size(&dset->shared->dcpl_cache.efl); - if(H5S_UNLIMITED == max_points) { - if(H5O_EFL_UNLIMITED != max_storage) + if (H5S_UNLIMITED == max_points) { + if (H5O_EFL_UNLIMITED != max_storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited dataspace but finite storage") } /* end if */ - else if((max_points * dt_size) < max_points) + else if ((max_points * dt_size) < max_points) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace * type size overflowed") - else if((max_points * dt_size) > max_storage) + else if ((max_points * dt_size) > max_storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size") /* Compute the total size of dataset */ @@ -182,7 +160,6 @@ H5D__efl_construct(H5F_t *f, H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_construct() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_is_space_alloc * @@ -207,7 +184,6 @@ H5D__efl_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(TRUE) } /* end H5D__efl_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_io_init * @@ -222,8 +198,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, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -232,7 +208,6 @@ H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__efl_io_init() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_read * @@ -251,17 +226,17 @@ H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNU static herr_t H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, uint8_t *buf) { - int fd = -1; - size_t to_read; + int fd = -1; + size_t to_read; #ifndef NDEBUG - hsize_t tempto_read; + hsize_t tempto_read; #endif /* NDEBUG */ - hsize_t skip = 0; - haddr_t cur; - ssize_t n; - size_t u; /* Local index variable */ - char *full_name = NULL; /* File name with prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t skip = 0; + haddr_t cur; + ssize_t n; + size_t u; /* Local index variable */ + char * full_name = NULL; /* File name with prefix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -272,8 +247,8 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size HDassert(buf || 0 == size); /* Find the first efl member from which to read */ - for (u=0, cur=0; unused; u++) { - if(H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { + for (u = 0, cur = 0; u < efl->nused; u++) { + if (H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { skip = addr - cur; break; } /* end if */ @@ -281,28 +256,28 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size } /* end for */ /* Read the data */ - while(size) { + while (size) { HDassert(buf); - if(u >= efl->nused) + if (u >= efl->nused) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file") - if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) + if (H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + if (H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_RDONLY)) < 0) + if ((fd = HDopen(full_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") - if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) + if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG - tempto_read = MIN((size_t)(efl->slot[u].size-skip), (hsize_t)size); + tempto_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); H5_CHECK_OVERFLOW(tempto_read, hsize_t, size_t); to_read = (size_t)tempto_read; -#else /* NDEBUG */ - to_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); +#else /* NDEBUG */ + to_read = MIN((size_t)(efl->slot[u].size - skip), (hsize_t)size); #endif /* NDEBUG */ - if((n = HDread(fd, buf, to_read)) < 0) + if ((n = HDread(fd, buf, to_read)) < 0) HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") - else if((size_t)n < to_read) + else if ((size_t)n < to_read) HDmemset(buf + n, 0, to_read - (size_t)n); full_name = (char *)H5MM_xfree(full_name); HDclose(fd); @@ -314,15 +289,14 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size } /* end while */ done: - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(fd >= 0) + if (fd >= 0) HDclose(fd); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_read() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_write * @@ -341,16 +315,16 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size static herr_t H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size, const uint8_t *buf) { - int fd = -1; - size_t to_write; + int fd = -1; + size_t to_write; #ifndef NDEBUG - hsize_t tempto_write; + hsize_t tempto_write; #endif /* NDEBUG */ - haddr_t cur; - hsize_t skip = 0; - size_t u; /* Local index variable */ - char *full_name = NULL; /* File name with prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t cur; + hsize_t skip = 0; + size_t u; /* Local index variable */ + char * full_name = NULL; /* File name with prefix */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -361,8 +335,8 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz HDassert(buf || 0 == size); /* Find the first efl member in which to write */ - for(u = 0, cur = 0; u < efl->nused; u++) { - if(H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { + for (u = 0, cur = 0; u < efl->nused; u++) { + if (H5O_EFL_UNLIMITED == efl->slot[u].size || addr < cur + efl->slot[u].size) { skip = addr - cur; break; } /* end if */ @@ -370,33 +344,33 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz } /* end for */ /* Write the data */ - while(size) { + while (size) { HDassert(buf); - if(u >= efl->nused) + if (u >= efl->nused) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file") - if(H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) + if (H5F_OVERFLOW_HSIZET2OFFT((hsize_t)efl->slot[u].offset + skip)) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed") - if(H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) + if (H5_combine_path(dset->shared->extfile_prefix, efl->slot[u].name, &full_name) < 0) HGOTO_ERROR(H5E_EFL, H5E_NOSPACE, FAIL, "can't build external file name") - if((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { - if(HDaccess(full_name, F_OK) < 0) + if ((fd = HDopen(full_name, O_CREAT | O_RDWR, H5_POSIX_CREATE_MODE_RW)) < 0) { + if (HDaccess(full_name, F_OK) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist") else HGOTO_ERROR(H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file") - } /* end if */ - if(HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) + } /* end if */ + if (HDlseek(fd, (HDoff_t)(efl->slot[u].offset + (HDoff_t)skip), SEEK_SET) < 0) HGOTO_ERROR(H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file") #ifndef NDEBUG tempto_write = MIN(efl->slot[u].size - skip, (hsize_t)size); H5_CHECK_OVERFLOW(tempto_write, hsize_t, size_t); to_write = (size_t)tempto_write; -#else /* NDEBUG */ +#else /* NDEBUG */ to_write = MIN((size_t)(efl->slot[u].size - skip), size); #endif /* NDEBUG */ - if((size_t)HDwrite(fd, buf, to_write) != to_write) + if ((size_t)HDwrite(fd, buf, to_write) != to_write) HGOTO_ERROR(H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file") full_name = (char *)H5MM_xfree(full_name); - HDclose (fd); + HDclose(fd); fd = -1; size -= to_write; buf += to_write; @@ -405,15 +379,14 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz } /* end while */ done: - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(fd >= 0) + if (fd >= 0) HDclose(fd); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_write() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_readvv_cb * @@ -429,20 +402,19 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz static herr_t H5D__efl_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_efl_readvv_ud_t *udata = (H5D_efl_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_efl_readvv_ud_t *udata = (H5D_efl_readvv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Read data */ - if(H5D__efl_read(udata->efl, udata->dset, dst_off, len, (udata->rbuf + src_off)) < 0) + if (H5D__efl_read(udata->efl, udata->dset, dst_off, len, (udata->rbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "EFL read failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_readvv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_readvv * @@ -459,12 +431,12 @@ H5D__efl_readvv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) *------------------------------------------------------------------------- */ 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_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +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_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ + H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -482,21 +454,19 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Set up user data for H5VM_opvv() */ - udata.efl = &(io_info->store->efl); + udata.efl = &(io_info->store->efl); udata.dset = io_info->dset; udata.rbuf = (unsigned char *)io_info->u.rbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__efl_readvv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__efl_readvv_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized EFL read") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_readvv() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_writevv_cb * @@ -512,20 +482,19 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, static herr_t H5D__efl_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) { - H5D_efl_writevv_ud_t *udata = (H5D_efl_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_efl_writevv_ud_t *udata = (H5D_efl_writevv_ud_t *)_udata; /* User data for H5VM_opvv() operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Write data */ - if(H5D__efl_write(udata->efl, udata->dset, dst_off, len, (udata->wbuf + src_off)) < 0) + if (H5D__efl_write(udata->efl, udata->dset, dst_off, len, (udata->wbuf + src_off)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "EFL write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_writevv_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_writevv * @@ -542,12 +511,12 @@ H5D__efl_writevv_cb(hsize_t dst_off, hsize_t src_off, size_t len, void *_udata) *------------------------------------------------------------------------- */ static ssize_t -H5D__efl_writevv(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_off_arr[], - size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) +H5D__efl_writevv(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_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, + size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ + H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -565,20 +534,18 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, HDassert(mem_off_arr); /* Set up user data for H5VM_opvv() */ - udata.efl = &(io_info->store->efl); + udata.efl = &(io_info->store->efl); udata.dset = io_info->dset; udata.wbuf = (const unsigned char *)io_info->u.wbuf; /* Call generic sequence operation routine */ - if((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, - mem_max_nseq, mem_curr_seq, mem_len_arr, mem_off_arr, - H5D__efl_writevv_cb, &udata)) < 0) + if ((ret_value = H5VM_opvv(dset_max_nseq, dset_curr_seq, dset_len_arr, dset_off_arr, mem_max_nseq, + mem_curr_seq, mem_len_arr, mem_off_arr, H5D__efl_writevv_cb, &udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPERATE, FAIL, "can't perform vectorized EFL write") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__efl_writevv() */ - /*------------------------------------------------------------------------- * Function: H5D__efl_bh_info * @@ -595,7 +562,7 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -606,7 +573,7 @@ H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size) HDassert(heap_size); /* Get the size of the local heap for EFL's file list */ - if(H5HL_heapsize(f, efl->heap_addr, heap_size) < 0) + if (H5HL_heapsize(f, efl->heap_addr, heap_size) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to retrieve local heap info") done: diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index a9202c2fb7c..0741e8f5518 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,29 +24,29 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FAprivate.h" /* Fixed arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FAprivate.h" /* Fixed arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Value to fill unset array elements with */ -#define H5D_FARRAY_FILL HADDR_UNDEF -#define H5D_FARRAY_FILT_FILL {HADDR_UNDEF, 0, 0} - +#define H5D_FARRAY_FILL HADDR_UNDEF +#define H5D_FARRAY_FILT_FILL \ + { \ + HADDR_UNDEF, 0, 0 \ + } /******************/ /* Local Typedefs */ @@ -54,33 +54,32 @@ /* Fixed array create/open user data */ typedef struct H5D_farray_ctx_ud_t { - const H5F_t *f; /* Pointer to file info */ - uint32_t chunk_size; /* Size of chunk (bytes) */ + const H5F_t *f; /* Pointer to file info */ + uint32_t chunk_size; /* Size of chunk (bytes) */ } H5D_farray_ctx_ud_t; /* Fixed array callback context */ typedef struct H5D_farray_ctx_t { - size_t file_addr_len; /* Size of addresses in the file (bytes) */ - size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ + size_t file_addr_len; /* Size of addresses in the file (bytes) */ + size_t chunk_size_len; /* Size of chunk sizes in the file (bytes) */ } H5D_farray_ctx_t; /* Fixed Array callback info for iteration over chunks */ typedef struct H5D_farray_it_ud_t { - H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ - 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 */ + H5D_chunk_common_ud_t common; /* Common info for Fixed Array user data (must be first) */ + 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 */ } H5D_farray_it_ud_t; /* Native fixed array element for chunks w/filters */ typedef struct H5D_farray_filt_elmt_t { - haddr_t addr; /* Address of chunk */ - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + haddr_t addr; /* Address of chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5D_farray_filt_elmt_t; - /********************/ /* Local Prototypes */ /********************/ @@ -90,51 +89,42 @@ 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 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 herr_t H5D__farray_dst_dbg_context(void *dbg_ctx); /* Fixed array class callbacks for chunks w/filters */ /* (some shared with callbacks for chunks w/o filters) */ static herr_t 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); -static herr_t H5D__farray_filt_decode(const void *raw, void *elmt, size_t nelmts, - void *ctx); -static herr_t H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, - hsize_t idx, const void *elmt); +static herr_t 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); +static herr_t H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Chunked layout indexing callbacks */ -static herr_t H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info); -static herr_t H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); -static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst); +static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); +static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Generic fixed array routines */ static herr_t H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info); @@ -146,62 +136,60 @@ static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info); /* Fixed array indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_FARRAY[1] = {{ - TRUE, /* Fixed array indices support SWMR access */ - H5D__farray_idx_init, /* init */ - H5D__farray_idx_create, /* create */ - H5D__farray_idx_is_space_alloc, /* is_space_alloc */ - H5D__farray_idx_insert, /* insert */ - H5D__farray_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__farray_idx_iterate, /* iterate */ - H5D__farray_idx_remove, /* remove */ - H5D__farray_idx_delete, /* delete */ - H5D__farray_idx_copy_setup, /* copy_setup */ - H5D__farray_idx_copy_shutdown, /* copy_shutdown */ - H5D__farray_idx_size, /* size */ - H5D__farray_idx_reset, /* reset */ - H5D__farray_idx_dump, /* dump */ - H5D__farray_idx_dest /* destroy */ + TRUE, /* Fixed array indices support SWMR access */ + H5D__farray_idx_init, /* init */ + H5D__farray_idx_create, /* create */ + H5D__farray_idx_is_space_alloc, /* is_space_alloc */ + H5D__farray_idx_insert, /* insert */ + H5D__farray_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__farray_idx_iterate, /* iterate */ + H5D__farray_idx_remove, /* remove */ + H5D__farray_idx_delete, /* delete */ + H5D__farray_idx_copy_setup, /* copy_setup */ + H5D__farray_idx_copy_shutdown, /* copy_shutdown */ + H5D__farray_idx_size, /* size */ + H5D__farray_idx_reset, /* reset */ + H5D__farray_idx_dump, /* dump */ + H5D__farray_idx_dest /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Fixed array class callbacks for dataset chunks w/o filters */ -const H5FA_class_t H5FA_CLS_CHUNK[1]={{ - H5FA_CLS_CHUNK_ID, /* Type of fixed array */ - "Chunk w/o filters", /* Name of fixed array class */ - sizeof(haddr_t), /* Size of native element */ - H5D__farray_crt_context, /* Create context */ - H5D__farray_dst_context, /* Destroy context */ - H5D__farray_fill, /* Fill block of missing elements callback */ - H5D__farray_encode, /* Element encoding callback */ - H5D__farray_decode, /* Element decoding callback */ - H5D__farray_debug, /* Element debugging callback */ +const H5FA_class_t H5FA_CLS_CHUNK[1] = {{ + H5FA_CLS_CHUNK_ID, /* Type of fixed array */ + "Chunk w/o filters", /* Name of fixed array class */ + sizeof(haddr_t), /* Size of native element */ + H5D__farray_crt_context, /* Create context */ + H5D__farray_dst_context, /* Destroy context */ + H5D__farray_fill, /* Fill block of missing elements callback */ + H5D__farray_encode, /* Element encoding callback */ + H5D__farray_decode, /* Element decoding callback */ + H5D__farray_debug, /* Element debugging callback */ H5D__farray_crt_dbg_context, /* Create debugging context */ - H5D__farray_dst_dbg_context /* Destroy debugging context */ + H5D__farray_dst_dbg_context /* Destroy debugging context */ }}; /* Fixed array class callbacks for dataset chunks w/filters */ -const H5FA_class_t H5FA_CLS_FILT_CHUNK[1]={{ - H5FA_CLS_FILT_CHUNK_ID, /* Type of fixed array */ - "Chunk w/filters", /* Name of fixed array class */ +const H5FA_class_t H5FA_CLS_FILT_CHUNK[1] = {{ + H5FA_CLS_FILT_CHUNK_ID, /* Type of fixed array */ + "Chunk w/filters", /* Name of fixed array class */ sizeof(H5D_farray_filt_elmt_t), /* Size of native element */ - H5D__farray_crt_context, /* Create context */ - H5D__farray_dst_context, /* Destroy context */ - H5D__farray_filt_fill, /* Fill block of missing elements callback */ - H5D__farray_filt_encode, /* Element encoding callback */ - H5D__farray_filt_decode, /* Element decoding callback */ - H5D__farray_filt_debug, /* Element debugging callback */ - H5D__farray_crt_dbg_context, /* Create debugging context */ - H5D__farray_dst_dbg_context /* Destroy debugging context */ + H5D__farray_crt_context, /* Create context */ + H5D__farray_dst_context, /* Destroy context */ + H5D__farray_filt_fill, /* Fill block of missing elements callback */ + H5D__farray_filt_encode, /* Element encoding callback */ + H5D__farray_filt_decode, /* Element decoding callback */ + H5D__farray_filt_debug, /* Element debugging callback */ + H5D__farray_crt_dbg_context, /* Create debugging context */ + H5D__farray_dst_dbg_context /* Destroy debugging context */ }}; /* Declare a free list to manage the H5D_farray_ctx_t struct */ @@ -210,7 +198,6 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_t); /* Declare a free list to manage the H5D_farray_ctx_ud_t struct */ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); - /*------------------------------------------------------------------------- * Function: H5D__farray_crt_context * @@ -227,9 +214,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_ud_t *udata = (H5D_farray_ctx_ud_t *)_udata; /* User data for fixed array context */ - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -239,17 +226,17 @@ H5D__farray_crt_context(void *_udata) HDassert(udata->chunk_size > 0); /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5D_farray_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5D_farray_ctx_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") - /* Initialize the context */ + /* Initialize the context */ ctx->file_addr_len = H5F_SIZEOF_ADDR(udata->f); /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ ctx->chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)udata->chunk_size) + 8) / 8); - if(ctx->chunk_size_len > 8) + if (ctx->chunk_size_len > 8) ctx->chunk_size_len = 8; /* Set return value */ @@ -259,7 +246,6 @@ H5D__farray_crt_context(void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_dst_context * @@ -276,7 +262,7 @@ H5D__farray_crt_context(void *_udata) static herr_t H5D__farray_dst_context(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 */ FUNC_ENTER_STATIC_NOERR @@ -289,7 +275,6 @@ H5D__farray_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_fill * @@ -306,7 +291,7 @@ H5D__farray_dst_context(void *_ctx) static herr_t H5D__farray_fill(void *nat_blk, size_t nelmts) { - haddr_t fill_val = H5D_FARRAY_FILL; /* Value to fill elements with */ + haddr_t fill_val = H5D_FARRAY_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -319,7 +304,6 @@ H5D__farray_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_encode * @@ -336,8 +320,8 @@ 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) { - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -348,7 +332,7 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); @@ -363,7 +347,6 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_decode * @@ -380,9 +363,9 @@ 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) { - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -392,7 +375,7 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); @@ -407,7 +390,6 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_debug * @@ -422,10 +404,9 @@ 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) +H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) { - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -434,14 +415,12 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, temp_str, - *(const haddr_t *)elmt); + HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_crt_dbg_context * @@ -459,11 +438,11 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static void * H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) { - H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ - 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 */ + H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ + 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 */ FUNC_ENTER_STATIC @@ -472,7 +451,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) HDassert(H5F_addr_defined(obj_addr)); /* Allocate context for debugging callback */ - if(NULL == (dbg_ctx = H5FL_MALLOC(H5D_farray_ctx_ud_t))) + if (NULL == (dbg_ctx = H5FL_MALLOC(H5D_farray_ctx_ud_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Set up the object header location info */ @@ -481,20 +460,20 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) obj_loc.addr = obj_addr; /* Open the object header where the layout message resides */ - if(H5O_open(&obj_loc) < 0) + if (H5O_open(&obj_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "can't open object header") obj_opened = TRUE; /* Read the layout message */ - if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) + if (NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") /* close the object header */ - if(H5O_close(&obj_loc, NULL) < 0) + if (H5O_close(&obj_loc, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") /* Create user data */ - dbg_ctx->f = f; + dbg_ctx->f = f; dbg_ctx->chunk_size = layout.u.chunk.size; /* Set return value */ @@ -502,21 +481,20 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) done: /* Cleanup on error */ - if(ret_value == NULL) { + if (ret_value == NULL) { /* Release context structure */ - if(dbg_ctx) + if (dbg_ctx) dbg_ctx = H5FL_FREE(H5D_farray_ctx_ud_t, dbg_ctx); /* Close object header */ - if(obj_opened) - if(H5O_close(&obj_loc, NULL) < 0) + if (obj_opened) + if (H5O_close(&obj_loc, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_dst_dbg_context * @@ -547,7 +525,6 @@ H5D__farray_dst_dbg_context(void *_dbg_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_fill * @@ -564,7 +541,7 @@ H5D__farray_dst_dbg_context(void *_dbg_ctx) static herr_t H5D__farray_filt_fill(void *nat_blk, size_t nelmts) { - H5D_farray_filt_elmt_t fill_val = H5D_FARRAY_FILT_FILL; /* Value to fill elements with */ + H5D_farray_filt_elmt_t fill_val = H5D_FARRAY_FILT_FILL; /* Value to fill elements with */ FUNC_ENTER_STATIC_NOERR @@ -578,7 +555,6 @@ H5D__farray_filt_fill(void *nat_blk, size_t nelmts) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_fill() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_encode * @@ -595,9 +571,10 @@ 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 */ - const H5D_farray_filt_elmt_t *elmt = (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native 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 */ FUNC_ENTER_STATIC_NOERR @@ -608,7 +585,7 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx HDassert(ctx); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); @@ -625,7 +602,6 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_encode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_decode * @@ -642,8 +618,9 @@ 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_filt_elmt_t *elmt = (H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -654,7 +631,7 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx HDassert(nelmts); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); @@ -671,7 +648,6 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_decode() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_filt_debug * @@ -686,11 +662,11 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx *------------------------------------------------------------------------- */ static herr_t -H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, - const void *_elmt) +H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *_elmt) { - const H5D_farray_filt_elmt_t *elmt = (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ - char temp_str[128]; /* Temporary string, for formatting */ + const H5D_farray_filt_elmt_t *elmt = + (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ + char temp_str[128]; /* Temporary string, for formatting */ FUNC_ENTER_STATIC_NOERR @@ -699,14 +675,13 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); - HDfprintf(stream, "%*s%-*s {%a, %u, %0x}\n", indent, "", fwidth, temp_str, - elmt->addr, elmt->nbytes, elmt->filter_mask); + HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, + elmt->nbytes, elmt->filter_mask); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_filt_debug() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_depend * @@ -724,10 +699,10 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -749,26 +724,26 @@ H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) oloc.addr = idx_info->storage->u.farray.dset_ohdr_addr; /* Get header */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Retrieve the dataset's object header proxy */ - if(NULL == (oh_proxy = H5O_get_proxy(oh))) + if (NULL == (oh_proxy = H5O_get_proxy(oh))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataset object header proxy") /* Make the fixed array a child flush dependency of the dataset's object header proxy */ - if(H5FA_depend(idx_info->storage->u.farray.fa, oh_proxy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header proxy") + if (H5FA_depend(idx_info->storage->u.farray.fa, oh_proxy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header proxy") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_depend() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_init * @@ -782,7 +757,8 @@ H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, haddr_t dset_ohdr_addr) +H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -796,7 +772,6 @@ H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_open * @@ -814,8 +789,8 @@ H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU static herr_t H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) { - H5D_farray_ctx_ud_t udata; /* User data for fixed array open call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_farray_ctx_ud_t udata; /* User data for fixed array open call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -831,23 +806,24 @@ H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) HDassert(NULL == idx_info->storage->u.farray.fa); /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Open the fixed array for the chunk index */ - if(NULL == (idx_info->storage->u.farray.fa = H5FA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) + if (NULL == + (idx_info->storage->u.farray.fa = H5FA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open fixed array") - /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__farray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + /* Check for SWMR writes to the file */ + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__farray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_open() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_create * @@ -869,9 +845,9 @@ H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5FA_create_t cparam; /* Fixed array creation parameters */ - H5D_farray_ctx_ud_t udata; /* User data for fixed array create call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_create_t cparam; /* Fixed array creation parameters */ + H5D_farray_ctx_ud_t udata; /* User data for fixed array create call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -886,21 +862,21 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout->nchunks); /* General parameters */ - if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + if (idx_info->pline->nused > 0) { + unsigned chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. */ chunk_size_len = 1 + ((H5VM_log2_gen((uint64_t)idx_info->layout->size) + 8) / 8); - if(chunk_size_len > 8) + if (chunk_size_len > 8) chunk_size_len = 8; - cparam.cls = H5FA_CLS_FILT_CHUNK; + cparam.cls = H5FA_CLS_FILT_CHUNK; cparam.raw_elmt_size = (uint8_t)(H5F_SIZEOF_ADDR(idx_info->f) + chunk_size_len + 4); } /* end if */ else { - cparam.cls = H5FA_CLS_CHUNK; + cparam.cls = H5FA_CLS_CHUNK; cparam.raw_elmt_size = (uint8_t)H5F_SIZEOF_ADDR(idx_info->f); } /* end else */ cparam.max_dblk_page_nelmts_bits = idx_info->layout->u.farray.cparam.max_dblk_page_nelmts_bits; @@ -908,27 +884,27 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) cparam.nelmts = idx_info->layout->max_nchunks; /* Set up the user data */ - udata.f = idx_info->f; + udata.f = idx_info->f; udata.chunk_size = idx_info->layout->size; /* Create the fixed array for the chunk index */ - if(NULL == (idx_info->storage->u.farray.fa = H5FA_create(idx_info->f, &cparam, &udata))) + if (NULL == (idx_info->storage->u.farray.fa = H5FA_create(idx_info->f, &cparam, &udata))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create fixed array") /* Get the address of the fixed array in file */ - if(H5FA_get_addr(idx_info->storage->u.farray.fa, &(idx_info->storage->idx_addr)) < 0) + if (H5FA_get_addr(idx_info->storage->u.farray.fa, &(idx_info->storage->idx_addr)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array address") /* Check for SWMR writes to the file */ - if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) - if(H5D__farray_idx_depend(idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on object header") + if (H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) + if (H5D__farray_idx_depend(idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_is_space_alloc * @@ -952,7 +928,6 @@ H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__farray_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_insert * @@ -966,10 +941,10 @@ H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) */ static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t H5_ATTR_UNUSED *dset) + const H5D_t H5_ATTR_UNUSED *dset) { - H5FA_t *fa; /* Pointer to fixed array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -983,36 +958,37 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") - if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ + if (udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); elmt.filter_mask = udata->filter_mask; /* Set the info for the chunk */ - if(H5FA_set(fa, udata->chunk_idx, &elmt) < 0) + if (H5FA_set(fa, udata->chunk_idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { /* Set the address for the chunk */ - if(H5FA_set(fa, udata->chunk_idx, &udata->chunk_block.offset) < 0) + if (H5FA_set(fa, udata->chunk_idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") } /* end else */ @@ -1020,7 +996,6 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_get_addr * @@ -1038,9 +1013,9 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1054,52 +1029,53 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); udata->chunk_idx = idx; /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ /* Get the information for the chunk */ - if(H5FA_get(fa, idx, &elmt) < 0) + if (H5FA_get(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Set the info for the chunk */ udata->chunk_block.offset = elmt.addr; udata->chunk_block.length = elmt.nbytes; - udata->filter_mask = elmt.filter_mask; + udata->filter_mask = elmt.filter_mask; } /* end if */ else { /* Get the address for the chunk */ - if(H5FA_get(fa, idx, &udata->chunk_block.offset) < 0) + if (H5FA_get(fa, idx, &udata->chunk_block.offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_iterate_cb * @@ -1115,39 +1091,39 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda static int H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void *_udata) { - H5D_farray_it_ud_t *udata = (H5D_farray_it_ud_t *)_udata; /* User data */ - unsigned ndims; /* Rank of chunk */ - int curr_dim; /* Current dimension */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_farray_it_ud_t *udata = (H5D_farray_it_ud_t *)_udata; /* User data */ + unsigned ndims; /* Rank of chunk */ + int curr_dim; /* Current dimension */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Compose generic chunk record for callback */ - if(udata->filtered) { + if (udata->filtered) { const H5D_farray_filt_elmt_t *filt_elmt = (const H5D_farray_filt_elmt_t *)_elmt; - udata->chunk_rec.chunk_addr = filt_elmt->addr; - udata->chunk_rec.nbytes = filt_elmt->nbytes; + udata->chunk_rec.chunk_addr = filt_elmt->addr; + udata->chunk_rec.nbytes = filt_elmt->nbytes; udata->chunk_rec.filter_mask = filt_elmt->filter_mask; } /* end if */ else udata->chunk_rec.chunk_addr = *(const haddr_t *)_elmt; /* Make "generic chunk" callback */ - if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + if (H5F_addr_defined(udata->chunk_rec.chunk_addr)) + if ((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; HDassert(ndims > 0); curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ udata->chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { + if (udata->chunk_rec.scaled[curr_dim] >= udata->common.layout->max_chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ udata->chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -1159,7 +1135,6 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_iterate * @@ -1174,12 +1149,11 @@ 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) +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_stat_t fa_stat; /* Fixed array statistics */ - int ret_value = FAIL; /* Return value */ + H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_stat_t fa_stat; /* Fixed array statistics */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC @@ -1194,39 +1168,40 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } else /* Patch the top level file pointer contained in fa if needed */ + } + else /* Patch the top level file pointer contained in fa if needed */ H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Get the fixed array statistics */ - if(H5FA_get_stats(fa, &fa_stat) < 0) + if (H5FA_get_stats(fa, &fa_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") /* Check if there are any array elements */ - if(fa_stat.nelmts > 0) { - H5D_farray_it_ud_t udata; /* User data for iteration callback */ + if (fa_stat.nelmts > 0) { + H5D_farray_it_ud_t udata; /* User data for iteration callback */ /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; + udata.common.layout = idx_info->layout; udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); - if(!udata.filtered) { - udata.chunk_rec.nbytes = idx_info->layout->size; + if (!udata.filtered) { + udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; + udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over the fixed array elements */ - if((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) + if ((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ @@ -1234,7 +1209,6 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_remove * @@ -1250,9 +1224,9 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1266,61 +1240,63 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) { + if (NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") - } 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") + } + 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") /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->scaled); + idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->scaled); /* Check for filters on chunks */ - if(idx_info->pline->nused > 0) { - H5D_farray_filt_elmt_t elmt; /* Fixed array element */ + if (idx_info->pline->nused > 0) { + H5D_farray_filt_elmt_t elmt; /* Fixed array element */ /* Get the info about the chunk for the index */ - if(H5FA_get(fa, idx, &elmt) < 0) + if (H5FA_get(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(elmt.addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(elmt.nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, elmt.addr, (hsize_t)elmt.nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the info about the chunk for the index */ - elmt.addr = HADDR_UNDEF; - elmt.nbytes = 0; + elmt.addr = HADDR_UNDEF; + elmt.nbytes = 0; elmt.filter_mask = 0; - if(H5FA_set(fa, idx, &elmt) < 0) + if (H5FA_set(fa, idx, &elmt) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk info") } /* end if */ else { - haddr_t addr = HADDR_UNDEF; /* Chunk address */ + haddr_t addr = HADDR_UNDEF; /* Chunk address */ /* Get the address of the chunk for the index */ - if(H5FA_get(fa, idx, &addr) < 0) + if (H5FA_get(fa, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Remove raw data chunk from file if not doing SWMR writes */ HDassert(H5F_addr_defined(addr)); - if(!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { - H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) + if (!(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE)) { + H5_CHECK_OVERFLOW(idx_info->layout->size, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, addr, (hsize_t)idx_info->layout->size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free chunk") } /* end if */ /* Reset the address of the chunk for the index */ addr = HADDR_UNDEF; - if(H5FA_set(fa, idx, &addr) < 0) + if (H5FA_set(fa, idx, &addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to reset chunk address") } /* end else */ @@ -1328,7 +1304,6 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t FUNC_LEAVE_NOAPI(ret_value) } /* H5D__farray_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_delete_cb * @@ -1345,8 +1320,8 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t static int H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1357,15 +1332,14 @@ H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(f); /* Remove raw data chunk from file */ - H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */uint32_t, /*To: */hsize_t); - if(H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) + H5_CHECK_OVERFLOW(chunk_rec->nbytes, /*From: */ uint32_t, /*To: */ hsize_t); + if (H5MF_xfree(f, H5FD_MEM_DRAW, chunk_rec->chunk_addr, (hsize_t)chunk_rec->nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_delete_cb() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_delete * @@ -1383,7 +1357,7 @@ H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) static herr_t H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1395,24 +1369,24 @@ H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->storage->idx_addr)) { - H5D_farray_ctx_ud_t ctx_udata; /* User data for fixed array open call */ + if (H5F_addr_defined(idx_info->storage->idx_addr)) { + H5D_farray_ctx_ud_t ctx_udata; /* User data for fixed array open call */ /* Iterate over the chunk addresses in the fixed array, deleting each chunk */ - if(H5D__farray_idx_iterate(idx_info, H5D__farray_idx_delete_cb, idx_info->f) < 0) + if (H5D__farray_idx_iterate(idx_info, H5D__farray_idx_delete_cb, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk addresses") /* Close fixed array */ - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; /* Set up the user data */ - ctx_udata.f = idx_info->f; + ctx_udata.f = idx_info->f; ctx_udata.chunk_size = idx_info->layout->size; /* Delete fixed array */ - if(H5FA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) + if (H5FA_delete(idx_info->f, idx_info->storage->idx_addr, &ctx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk fixed array") idx_info->storage->idx_addr = HADDR_UNDEF; } /* end if */ @@ -1423,7 +1397,6 @@ H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_copy_setup * @@ -1437,10 +1410,9 @@ H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst) +H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1458,16 +1430,16 @@ H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Check if the source fixed array is open yet */ - if(NULL == idx_info_src->storage->u.farray.fa) + if (NULL == idx_info_src->storage->u.farray.fa) /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info_src) < 0) + if (H5D__farray_idx_open(idx_info_src) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create the fixed array that describes chunked storage in the dest. file */ - if(H5D__farray_idx_create(idx_info_dst) < 0) + if (H5D__farray_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); @@ -1478,7 +1450,6 @@ H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_copy_shutdown * @@ -1492,10 +1463,9 @@ H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, *------------------------------------------------------------------------- */ static herr_t -H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst) +H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chunk_t *storage_dst) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1506,10 +1476,10 @@ H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, HDassert(storage_dst->u.farray.fa); /* Close fixed arrays */ - if(H5FA_close(storage_src->u.farray.fa) < 0) + if (H5FA_close(storage_src->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") storage_src->u.farray.fa = NULL; - if(H5FA_close(storage_dst->u.farray.fa) < 0) + if (H5FA_close(storage_dst->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") storage_dst->u.farray.fa = NULL; @@ -1517,7 +1487,6 @@ H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_copy_shutdown() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_size * @@ -1534,9 +1503,9 @@ H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, 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_stat_t fa_stat; /* Fixed array statistics */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_stat_t fa_stat; /* Fixed array statistics */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1550,22 +1519,22 @@ H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(index_size); /* Open the fixed array in file */ - if(H5D__farray_idx_open(idx_info) < 0) + if (H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Get the fixed array statistics */ - if(H5FA_get_stats(fa, &fa_stat) < 0) + if (H5FA_get_stats(fa, &fa_stat) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") *index_size = fa_stat.hdr_size; *index_size += fa_stat.dblk_size; done: - if(idx_info->storage->u.farray.fa) { - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (idx_info->storage->u.farray.fa) { + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; } /* end if */ @@ -1573,7 +1542,6 @@ H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_reset * @@ -1595,14 +1563,13 @@ H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) + if (reset_addr) storage->idx_addr = HADDR_UNDEF; storage->u.farray.fa = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_dump * @@ -1624,12 +1591,11 @@ H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__farray_idx_dump() */ - /*------------------------------------------------------------------------- * Function: H5D__farray_idx_dest * @@ -1645,7 +1611,7 @@ H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) static herr_t H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1655,14 +1621,14 @@ H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->storage); /* Check if the fixed array is open */ - if(idx_info->storage->u.farray.fa) { + if (idx_info->storage->u.farray.fa) { /* 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) + 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") /* Close fixed array */ - if(H5FA_close(idx_info->storage->u.farray.fa) < 0) + if (H5FA_close(idx_info->storage->u.farray.fa) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close fixed array") idx_info->storage->u.farray.fa = NULL; } /* end if */ @@ -1670,4 +1636,3 @@ H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_dest() */ - diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 0efe98a4fc6..b7ecdc99a91 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,45 +26,39 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector and array functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5D__fill_release(H5D_fill_buf_info_t *fb_info); - /*********************/ /* Package Variables */ /*********************/ @@ -72,12 +66,10 @@ static herr_t H5D__fill_release(H5D_fill_buf_info_t *fb_info); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -91,7 +83,6 @@ H5FL_BLK_DEFINE_STATIC(zero_fill); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - /*-------------------------------------------------------------------------- NAME H5Dfill @@ -127,24 +118,23 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_ H5TRACE5("e", "*xi*xii", fill, fill_type_id, buf, buf_type_id, space_id); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") - if(NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) + if (NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - if(NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) + if (NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Fill the selection in the memory buffer */ - if(H5D__fill(fill, fill_type, buf, buf_type, space) < 0) + if (H5D__fill(fill, fill_type, buf, buf_type, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: FUNC_LEAVE_API(ret_value) -} /* H5Dfill() */ +} /* H5Dfill() */ - /*-------------------------------------------------------------------------- NAME H5D__fill @@ -174,20 +164,19 @@ 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, const 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 */ - uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element 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 */ - 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 */ + 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 */ + uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -198,32 +187,32 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, HDassert(space); /* Make sure the dataspace has an extent set (or is NULL) */ - if(!(H5S_has_extent(space))) + if (!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") /* Get the memory datatype size */ dst_type_size = H5T_get_size(buf_type); /* If there's no fill value, just use zeros */ - if(fill == NULL) { - void *elem_ptr; /* Pointer to element to use for fill value */ + if (fill == NULL) { + void *elem_ptr; /* Pointer to element to use for fill value */ /* Wrap the local buffer for elements */ - if(NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) + if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (elem_ptr = H5WB_actual_clear(elem_wb, dst_type_size))) + if (NULL == (elem_ptr = H5WB_actual_clear(elem_wb, dst_type_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Fill the selection in the memory buffer */ - if(H5S_select_fill(elem_ptr, dst_type_size, space, buf) < 0) + if (H5S_select_fill(elem_ptr, dst_type_size, space, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") } /* end if */ else { - H5T_path_t *tpath; /* Conversion path information */ - size_t src_type_size; /* Size of source type */ - size_t buf_size; /* Desired buffer size */ + H5T_path_t *tpath; /* Conversion path information */ + size_t src_type_size; /* Size of source type */ + size_t buf_size; /* Desired buffer size */ /* Get the file datatype size */ src_type_size = H5T_get_size(fill_type); @@ -232,15 +221,15 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, buf_size = MAX(src_type_size, dst_type_size); /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(fill_type, buf_type))) + if (NULL == (tpath = H5T_path_find(fill_type, buf_type))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") /* Construct source & destination datatype IDs, if we will need them */ - if(!H5T_path_noop(tpath)) { - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL), FALSE)) < 0) + if (!H5T_path_noop(tpath)) { + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL), FALSE)) < 0) + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") } /* end if */ @@ -248,55 +237,58 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, * then do conversion on each element so that each of them has a copy * of the VL data. */ - if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) { - hsize_t nelmts; /* Number of data elements */ + if (TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) { + hsize_t nelmts; /* Number of data elements */ /* Get the number of elements in the selection */ nelmts = H5S_GET_SELECT_NPOINTS(space); H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); /* Allocate a temporary buffer */ - if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) + if (NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Allocate a background buffer, if necessary */ - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size))) + if (H5T_path_bkg(tpath) && + NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Replicate the file's fill value into the temporary buffer */ H5VM_array_fill(tmp_buf, fill, src_type_size, (size_t)nelmts); /* Convert from file's fill value into memory form */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Allocate the chunk selection iterator */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator") /* Create a selection iterator for scattering the elements to memory buffer */ - if(H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + if (H5S_select_iter_init(mem_iter, space, dst_type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") mem_iter_init = TRUE; /* Scatter the data into memory */ - if(H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf/*out*/) < 0) + if (H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end if */ else { - const uint8_t *fill_buf; /* Buffer to use for writing fill values */ + const uint8_t *fill_buf; /* Buffer to use for writing fill values */ /* Convert disk buffer into memory buffer */ - if(!H5T_path_noop(tpath)) { - void *elem_ptr; /* Pointer to element to use for fill value */ - void *bkg_ptr = NULL; /* Pointer to background element to use for fill value */ + if (!H5T_path_noop(tpath)) { + void *elem_ptr; /* Pointer to element to use for fill value */ + void *bkg_ptr = NULL; /* Pointer to background element to use for fill value */ /* Wrap the local buffer for elements */ - if(NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) + if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (elem_ptr = H5WB_actual(elem_wb, buf_size))) + if (NULL == (elem_ptr = H5WB_actual(elem_wb, buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Copy the user's data into the buffer for conversion */ @@ -304,18 +296,19 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, /* If there's no VL type of data, do conversion first then fill the data into * the memory buffer. */ - if(H5T_path_bkg(tpath)) { + if (H5T_path_bkg(tpath)) { /* Wrap the local buffer for background elements */ - if(NULL == (bkg_elem_wb = H5WB_wrap(bkg_elem_buf, sizeof(bkg_elem_buf)))) + if (NULL == (bkg_elem_wb = H5WB_wrap(bkg_elem_buf, sizeof(bkg_elem_buf)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for element */ - if(NULL == (bkg_ptr = H5WB_actual_clear(bkg_elem_wb, buf_size))) + if (NULL == (bkg_ptr = H5WB_actual_clear(bkg_elem_wb, buf_size))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") } /* end if */ /* Perform datatype conversion */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, elem_ptr, bkg_ptr) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, elem_ptr, bkg_ptr) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Point at element buffer */ @@ -325,33 +318,32 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, fill_buf = (const uint8_t *)fill; /* Fill the selection in the memory buffer */ - if(H5S_select_fill(fill_buf, dst_type_size, space, buf) < 0) + if (H5S_select_fill(fill_buf, dst_type_size, space, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") } /* end else */ - } /* end else */ + } /* end else */ done: - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(src_id != (-1) && H5I_dec_ref(src_id) < 0) + if (src_id != (-1) && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(dst_id != (-1) && H5I_dec_ref(dst_id) < 0) + if (dst_id != (-1) && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tmp_buf) + if (tmp_buf) tmp_buf = H5FL_BLK_FREE(type_conv, tmp_buf); - if(elem_wb && H5WB_unwrap(elem_wb) < 0) + if (elem_wb && H5WB_unwrap(elem_wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") - if(bkg_elem_wb && H5WB_unwrap(bkg_elem_wb) < 0) + if (bkg_elem_wb && H5WB_unwrap(bkg_elem_wb) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__fill() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_init * @@ -365,13 +357,11 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, *------------------------------------------------------------------------- */ 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 total_nelmts, size_t max_buf_size) +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 total_nelmts, size_t max_buf_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -385,29 +375,29 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, HDmemset(fb_info, 0, sizeof(*fb_info)); /* Cache constant information from the dataset */ - fb_info->fill = fill; - fb_info->file_type = dset_type; - fb_info->file_tid = dset_type_id; + fb_info->fill = fill; + fb_info->file_type = dset_type; + fb_info->file_tid = dset_type_id; fb_info->fill_alloc_func = alloc_func; fb_info->fill_alloc_info = alloc_info; - fb_info->fill_free_func = free_func; - fb_info->fill_free_info = free_info; + fb_info->fill_free_func = free_func; + fb_info->fill_free_info = free_info; /* Fill the buffer with the user's fill value */ - if(fill->buf) { - htri_t has_vlen_type; /* Whether the datatype has a VL component */ + if (fill->buf) { + htri_t has_vlen_type; /* Whether the datatype has a VL component */ /* Detect whether the datatype has a VL component */ - if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0) + if ((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?") fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type; /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(fb_info->has_vlen_fill_type) { + if (fb_info->has_vlen_fill_type) { /* Create temporary datatype for conversion operation */ - if(NULL == (fb_info->mem_type = H5T_copy(dset_type, H5T_COPY_TRANSIENT))) + if (NULL == (fb_info->mem_type = H5T_copy(dset_type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy file datatype") - if((fb_info->mem_tid = H5I_register(H5I_DATATYPE, fb_info->mem_type, FALSE)) < 0) + if ((fb_info->mem_tid = H5I_register(H5I_DATATYPE, fb_info->mem_type, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") /* Retrieve sizes of memory & file datatypes */ @@ -420,7 +410,7 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->max_elmt_size = MAX(fb_info->mem_elmt_size, fb_info->file_elmt_size); /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -430,48 +420,50 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, (fb_info->elmts_per_buf * fb_info->max_elmt_size)); /* Allocate fill buffer */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; } /* end if */ else { - if(alloc_func) + if (alloc_func) fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(NULL == fb_info->fill_buf) + if (NULL == fb_info->fill_buf) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ /* Get the datatype conversion path for this operation */ - if(NULL == (fb_info->fill_to_mem_tpath = H5T_path_find(dset_type, fb_info->mem_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (fb_info->fill_to_mem_tpath = H5T_path_find(dset_type, fb_info->mem_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert between src and dst datatypes") /* Get the inverse datatype conversion path for this operation */ - if(NULL == (fb_info->mem_to_dset_tpath = H5T_path_find(fb_info->mem_type, dset_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (fb_info->mem_to_dset_tpath = H5T_path_find(fb_info->mem_type, dset_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert between src and dst datatypes") /* Check if we need to allocate a background buffer */ - if(H5T_path_bkg(fb_info->fill_to_mem_tpath) || H5T_path_bkg(fb_info->mem_to_dset_tpath)) { + if (H5T_path_bkg(fb_info->fill_to_mem_tpath) || H5T_path_bkg(fb_info->mem_to_dset_tpath)) { /* Check for inverse datatype conversion needing a background buffer */ /* (do this first, since it needs a larger buffer) */ - if(H5T_path_bkg(fb_info->mem_to_dset_tpath)) + if (H5T_path_bkg(fb_info->mem_to_dset_tpath)) fb_info->bkg_buf_size = fb_info->elmts_per_buf * fb_info->max_elmt_size; else fb_info->bkg_buf_size = fb_info->max_elmt_size; /* Allocate the background buffer */ - if(NULL == (fb_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, fb_info->bkg_buf_size))) + if (NULL == (fb_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, fb_info->bkg_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ - } /* end if */ + } /* end if */ else { /* If fill value is not library default, use it to set the element size */ HDassert(fill->size >= 0); fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = (size_t)fill->size; /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -481,30 +473,30 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, fb_info->elmts_per_buf * fb_info->max_elmt_size); /* Allocate temporary buffer */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; } /* end if */ else { - if(alloc_func) + if (alloc_func) fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(NULL == fb_info->fill_buf) + if (NULL == fb_info->fill_buf) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ /* Replicate the fill value into the cached buffer */ H5VM_array_fill(fb_info->fill_buf, fill->buf, fb_info->max_elmt_size, fb_info->elmts_per_buf); - } /* end else */ - } /* end if */ - else { /* Fill the buffer with the default fill value */ + } /* end else */ + } /* end if */ + else { /* Fill the buffer with the default fill value */ /* Retrieve size of elements */ fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = H5T_get_size(dset_type); HDassert(fb_info->max_elmt_size > 0); /* Compute the number of elements that fit within a buffer to write */ - if(total_nelmts > 0) + if (total_nelmts > 0) fb_info->elmts_per_buf = MIN(total_nelmts, MAX(1, (max_buf_size / fb_info->max_elmt_size))); else fb_info->elmts_per_buf = max_buf_size / fb_info->max_elmt_size; @@ -514,43 +506,44 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, fb_info->fill_buf_size = MIN(max_buf_size, (fb_info->elmts_per_buf * fb_info->max_elmt_size)); /* Use (and zero) caller's buffer, if provided */ - if(caller_fill_buf) { - fb_info->fill_buf = caller_fill_buf; + if (caller_fill_buf) { + fb_info->fill_buf = caller_fill_buf; fb_info->use_caller_fill_buf = TRUE; HDmemset(fb_info->fill_buf, 0, fb_info->fill_buf_size); } /* end if */ else { - if(alloc_func) { + if (alloc_func) { fb_info->fill_buf = alloc_func(fb_info->fill_buf_size, alloc_info); HDmemset(fb_info->fill_buf, 0, fb_info->fill_buf_size); } /* end if */ else { - htri_t buf_avail = H5FL_BLK_AVAIL(zero_fill, fb_info->fill_buf_size); /* Check if there is an already zeroed out buffer available */ + htri_t buf_avail = H5FL_BLK_AVAIL( + zero_fill, + fb_info->fill_buf_size); /* Check if there is an already zeroed out buffer available */ HDassert(buf_avail != FAIL); /* Allocate temporary buffer (zeroing it if no buffer is available) */ - if(!buf_avail) + if (!buf_avail) fb_info->fill_buf = H5FL_BLK_CALLOC(zero_fill, fb_info->fill_buf_size); else fb_info->fill_buf = H5FL_BLK_MALLOC(zero_fill, fb_info->fill_buf_size); } /* end else */ - if(fb_info->fill_buf == NULL) + if (fb_info->fill_buf == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") } /* end else */ - } /* end else */ + } /* end else */ done: /* Cleanup on error */ - if(ret_value < 0) - if(H5D__fill_term(fb_info) < 0) + if (ret_value < 0) + if (H5D__fill_term(fb_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__fill_init() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_refill_vl * @@ -566,8 +559,8 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, 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 */ + herr_t ret_value = SUCCEED; /* Return value */ + void * buf = NULL; /* Temporary fill buffer */ FUNC_ENTER_PACKAGE @@ -580,49 +573,52 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) H5MM_memcpy(fb_info->fill_buf, fb_info->fill->buf, fb_info->file_elmt_size); /* Reset first element of background buffer, if necessary */ - if(H5T_path_bkg(fb_info->fill_to_mem_tpath)) + if (H5T_path_bkg(fb_info->fill_to_mem_tpath)) HDmemset(fb_info->bkg_buf, 0, fb_info->max_elmt_size); /* Type convert the dataset buffer, to copy any VL components */ - if(H5T_convert(fb_info->fill_to_mem_tpath, fb_info->file_tid, fb_info->mem_tid, (size_t)1, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) + if (H5T_convert(fb_info->fill_to_mem_tpath, fb_info->file_tid, fb_info->mem_tid, (size_t)1, (size_t)0, + (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Replicate the fill value into the cached buffer */ - if(nelmts > 1) - H5VM_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1)); + if (nelmts > 1) + H5VM_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), + fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1)); /* Reset the entire background buffer, if necessary */ - if(H5T_path_bkg(fb_info->mem_to_dset_tpath)) + if (H5T_path_bkg(fb_info->mem_to_dset_tpath)) HDmemset(fb_info->bkg_buf, 0, fb_info->bkg_buf_size); /* Make a copy of the fill buffer so we can free dynamic elements after conversion */ - if(fb_info->fill_alloc_func) + if (fb_info->fill_alloc_func) buf = fb_info->fill_alloc_func(fb_info->fill_buf_size, fb_info->fill_alloc_info); else buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); - if(!buf) + if (!buf) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary fill buffer") H5MM_memcpy(buf, fb_info->fill_buf, fb_info->fill_buf_size); /* Type convert the dataset buffer, to copy any VL components */ - if(H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) + if (H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, + (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") done: - if(buf) { + if (buf) { /* Free dynamically allocated VL elements in fill buffer */ - if(fb_info->fill->type) { - if(H5T_vlen_reclaim_elmt(buf, fb_info->fill->type) < 0) + if (fb_info->fill->type) { + if (H5T_vlen_reclaim_elmt(buf, fb_info->fill->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") } /* end if */ else { - if(H5T_vlen_reclaim_elmt(buf, fb_info->mem_type) < 0) + if (H5T_vlen_reclaim_elmt(buf, fb_info->mem_type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") } /* end else */ /* Free temporary fill buffer */ - if(fb_info->fill_free_func) + if (fb_info->fill_free_func) fb_info->fill_free_func(buf, fb_info->fill_free_info); else buf = H5FL_BLK_FREE(non_zero_fill, buf); @@ -631,7 +627,6 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__fill_refill_vl() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_release * @@ -654,11 +649,11 @@ H5D__fill_release(H5D_fill_buf_info_t *fb_info) HDassert(fb_info->fill); /* Free the buffer for fill values */ - if(!fb_info->use_caller_fill_buf && fb_info->fill_buf) { - if(fb_info->fill_free_func) + if (!fb_info->use_caller_fill_buf && fb_info->fill_buf) { + if (fb_info->fill_free_func) fb_info->fill_free_func(fb_info->fill_buf, fb_info->fill_free_info); else { - if(fb_info->fill->buf) + if (fb_info->fill->buf) fb_info->fill_buf = H5FL_BLK_FREE(non_zero_fill, fb_info->fill_buf); else fb_info->fill_buf = H5FL_BLK_FREE(zero_fill, fb_info->fill_buf); @@ -669,7 +664,6 @@ H5D__fill_release(H5D_fill_buf_info_t *fb_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__fill_release() */ - /*------------------------------------------------------------------------- * Function: H5D__fill_term * @@ -694,15 +688,14 @@ H5D__fill_term(H5D_fill_buf_info_t *fb_info) H5D__fill_release(fb_info); /* Free other resources for vlen fill values */ - if(fb_info->has_vlen_fill_type) { - if(fb_info->mem_tid > 0) + if (fb_info->has_vlen_fill_type) { + if (fb_info->mem_tid > 0) H5I_dec_ref(fb_info->mem_tid); - else if(fb_info->mem_type) + else if (fb_info->mem_type) (void)H5T_close_real(fb_info->mem_type); - if(fb_info->bkg_buf) + if (fb_info->bkg_buf) fb_info->bkg_buf = H5FL_BLK_FREE(type_conv, fb_info->bkg_buf); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__fill_term() */ - diff --git a/src/H5Dint.c b/src/H5Dint.c index 177ff1f350b..5782d70f175 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,33 +15,59 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ +/* 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 */ + 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; + +/* 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_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 */ + hid_t fspace_id; /* Dataset dataspace ID of the dataset we are working on */ + 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 */ +} H5D_vlen_bufsize_generic_t; /********************/ /* Local Prototypes */ @@ -49,19 +75,24 @@ /* 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__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); +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__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); static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); -static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, - hsize_t old_dim[]); +static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); -static herr_t H5D__close_cb(H5D_t *dataset); +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 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, + void *op_data); +static herr_t H5D__check_filters(H5D_t *dataset); /*********************/ /* Package Variables */ @@ -73,12 +104,10 @@ H5FL_BLK_DEFINE(vlen_vl_buf); /* Declare a free list to manage other blocks of VL data */ H5FL_BLK_DEFINE(vlen_fl_buf); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -96,15 +125,18 @@ H5FL_EXTERN(H5D_chunk_info_t); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); +/* Disable warning for intentional identical branches here -QAK */ +H5_GCC_DIAG_OFF("larger-than=") /* Define a static "default" dataset structure to use to initialize new datasets */ static H5D_shared_t H5D_def_dset; +H5_GCC_DIAG_ON("larger-than=") /* Dataset ID class */ static const H5I_class_t H5I_DATASET_CLS[1] = {{ - H5I_DATASET, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ + H5I_DATASET, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ @@ -115,7 +147,6 @@ static hbool_t H5D_top_package_initialize_s = FALSE; static const char *H5D_prefix_ext_env = NULL; static const char *H5D_prefix_vds_env = NULL; - /*------------------------------------------------------------------------- * Function: H5D_init * @@ -129,7 +160,7 @@ static const char *H5D_prefix_vds_env = NULL; herr_t H5D_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -138,7 +169,6 @@ H5D_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_init() */ - /*-------------------------------------------------------------------------- NAME H5D__init_package -- Initialize interface-specific information @@ -157,13 +187,13 @@ NOTES herr_t H5D__init_package(void) { - H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the dataset IDs */ - if(H5I_register_type(H5I_DATASET_CLS) < 0) + if (H5I_register_type(H5I_DATASET_CLS) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the "default dataset" information */ @@ -175,19 +205,19 @@ H5D__init_package(void) /* Get the default dataset creation property list values and initialize the * default dataset with them. */ - if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_ID_g))) + if (NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_ID_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") /* Get the default data storage layout */ - if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") + if (H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default dataset creation properties */ - if(H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.dcpl_cache.efl) < 0) + if (H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.dcpl_cache.efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve external file list") - if(H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.dcpl_cache.fill) < 0) + if (H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.dcpl_cache.fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") - if(H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) + if (H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") /* Mark "top" of interface as initialized, too */ @@ -201,7 +231,6 @@ H5D__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_package() */ - /*------------------------------------------------------------------------- * Function: H5D_top_term_package * @@ -215,12 +244,12 @@ H5D__init_package(void) int H5D_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5D_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASET) > 0) { + if (H5D_top_package_initialize_s) { + if (H5I_nmembers(H5I_DATASET) > 0) { /* The dataset API uses the "force" flag set to true because it * is using the "file objects" (H5FO) API functions to track open * objects in the file. Using the H5FO code means that dataset @@ -245,17 +274,16 @@ H5D_top_term_package(void) */ (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5D_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5D_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5D_term_package * @@ -272,11 +300,11 @@ H5D_top_term_package(void) int H5D_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_DATASET)); HDassert(FALSE == H5D_top_package_initialize_s); @@ -285,14 +313,44 @@ H5D_term_package(void) n += (H5I_dec_type_ref(H5I_DATASET) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5D_term_package() */ - +/*------------------------------------------------------------------------- + * Function: H5D__close_cb + * + * Purpose: Called when the ref count reaches zero on the dataset's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__close_cb(H5VL_object_t *dset_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(dset_vol_obj); + + /* Close the dataset */ + if (H5VL_dataset_close(dset_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset"); + +done: + /* Free the VOL object */ + if (H5VL_free_object(dset_vol_obj) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__close_cb() */ + /*------------------------------------------------------------------------- * Function: H5D__create_named * @@ -304,12 +362,12 @@ H5D_term_package(void) *------------------------------------------------------------------------- */ 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) +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) { - 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -324,17 +382,17 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, /* Set up dataset creation info */ dcrt_info.type_id = type_id; - dcrt_info.space = space; + dcrt_info.space = space; dcrt_info.dcpl_id = dcpl_id; dcrt_info.dapl_id = dapl_id; /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_DATASET; ocrt_info.crt_info = &dcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new dataset and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create and link to dataset") HDassert(ocrt_info.new_obj); @@ -345,7 +403,6 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_named() */ - /*------------------------------------------------------------------------- * Function: H5D__get_space_status * @@ -359,48 +416,48 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, herr_t H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE HDassert(dset); /* 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 */ + 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) + 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))) + 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)) + 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) + 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) + if (space_allocated == 0) *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; - else if(space_allocated == full_size) + else if (space_allocated == full_size) *allocation = H5D_SPACE_STATUS_ALLOCATED; else *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; @@ -408,7 +465,7 @@ H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) else { /* For non-chunked layouts set space status by result of is_space_alloc * function */ - if(dset->shared->layout.ops->is_space_alloc(&dset->shared->layout.storage)) + if (dset->shared->layout.ops->is_space_alloc(&dset->shared->layout.storage)) *allocation = H5D_SPACE_STATUS_ALLOCATED; else *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; @@ -418,7 +475,6 @@ H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_space_status() */ - /*------------------------------------------------------------------------- * Function: H5D__new * @@ -431,14 +487,14 @@ 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 */ - H5P_genplist_t *plist; /* Property list created */ - H5D_shared_t *ret_value = NULL; /* Return value */ + H5D_shared_t * new_dset = NULL; /* New dataset object */ + H5P_genplist_t *plist; /* Property list created */ + H5D_shared_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate new shared dataset structure */ - if(NULL == (new_dset = H5FL_MALLOC(H5D_shared_t))) + if (NULL == (new_dset = H5FL_MALLOC(H5D_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the default dataset information */ @@ -447,30 +503,27 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) /* If we are using the default dataset creation property list, during creation * don't bother to copy it, just increment the reference count */ - if(!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { - if(H5I_inc_ref(dcpl_id, FALSE) < 0) + if (!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { + if (H5I_inc_ref(dcpl_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment default DCPL ID") new_dset->dcpl_id = dcpl_id; } /* end if */ else { /* Get the property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dcpl_id = H5P_copy_plist(plist, FALSE); } /* end else */ - /* Set the DCPL for the API context */ - H5CX_set_dcpl(new_dset->dcpl_id); - - if(!vl_type && creating && dapl_id == H5P_DATASET_ACCESS_DEFAULT) { - if(H5I_inc_ref(dapl_id, FALSE) < 0) + if (!vl_type && creating && dapl_id == H5P_DATASET_ACCESS_DEFAULT) { + if (H5I_inc_ref(dapl_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment default DAPL ID") new_dset->dapl_id = dapl_id; } /* end if */ else { /* Get the property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dapl_id = H5P_copy_plist(plist, FALSE); @@ -480,11 +533,11 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) ret_value = new_dset; done: - if(ret_value == NULL) - if(new_dset != NULL) { - if(new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) + if (ret_value == NULL) + if (new_dset != NULL) { + if (new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") - if(new_dset->dapl_id != 0 && H5I_dec_ref(new_dset->dapl_id) < 0) + if (new_dset->dapl_id != 0 && H5I_dec_ref(new_dset->dapl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") new_dset = H5FL_FREE(H5D_shared_t, new_dset); } /* end if */ @@ -492,7 +545,6 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__new() */ - /*------------------------------------------------------------------------- * Function: H5D__init_type * @@ -506,10 +558,10 @@ 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) { - htri_t relocatable; /* Flag whether the type is relocatable */ - htri_t immutable; /* Flag whether the type is immutable */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t relocatable; /* Flag whether the type is relocatable */ + htri_t immutable; /* Flag whether the type is immutable */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -519,55 +571,54 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) HDassert(type); /* Check whether the datatype is relocatable */ - if((relocatable = H5T_is_relocatable(type)) < 0) + if ((relocatable = H5T_is_relocatable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* Check whether the datatype is immutable */ - if((immutable = H5T_is_immutable(type)) < 0) + if ((immutable = H5T_is_immutable(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?") /* To use at least v18 format versions or not */ use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Copy the datatype if it's a custom datatype or if it'll change when its location is changed */ - if(!immutable || relocatable || use_at_least_v18) { + if (!immutable || relocatable || use_at_least_v18) { /* Copy datatype for dataset */ - if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) + if ((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") /* Convert a datatype (if committed) to a transient type if the committed datatype's file * location is different from the file location where the dataset will be created. */ - if(H5T_convert_committed_datatype(dset->shared->type, file) < 0) + if (H5T_convert_committed_datatype(dset->shared->type, file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info") /* Mark any datatypes as being on disk now */ - if(H5T_set_loc(dset->shared->type, file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(dset->shared->type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't set datatype location") /* Set the version for datatype */ - if(H5T_set_version(file, dset->shared->type) < 0) + if (H5T_set_version(file, dset->shared->type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Get a datatype ID for the dataset's datatype */ - if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) + if ((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ else { - if(H5I_inc_ref(type_id, FALSE) < 0) + if (H5I_inc_ref(type_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment datatype ID") /* 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 = (H5T_t *)type; /* (Cast away const OK - QAK) */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_type() */ - /*------------------------------------------------------------------------- * Function: H5D__cache_dataspace_info * @@ -580,9 +631,9 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) static herr_t H5D__cache_dataspace_info(const H5D_t *dset) { - int sndims; /* Signed number of dimensions of dataspace rank */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + int sndims; /* Signed number of dimensions of dataspace rank */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -590,15 +641,16 @@ H5D__cache_dataspace_info(const H5D_t *dset) HDassert(dset); /* Cache info for dataset's dataspace */ - if((sndims = H5S_get_simple_extent_dims(dset->shared->space, dset->shared->curr_dims, dset->shared->max_dims)) < 0) + if ((sndims = H5S_get_simple_extent_dims(dset->shared->space, dset->shared->curr_dims, + dset->shared->max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't cache dataspace dimensions") dset->shared->ndims = (unsigned)sndims; /* Compute the initial 'power2up' values */ - for(u = 0; u < dset->shared->ndims; u++) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + for (u = 0; u < dset->shared->ndims; u++) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ - if( !(scaled_power2up = H5VM_power2up(dset->shared->curr_dims[u])) ) + if (!(scaled_power2up = H5VM_power2up(dset->shared->curr_dims[u]))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") dset->shared->curr_power2up[u] = scaled_power2up; } @@ -607,7 +659,6 @@ H5D__cache_dataspace_info(const H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__cache_dataspace_info() */ - /*------------------------------------------------------------------------- * Function: H5D__init_space * @@ -621,7 +672,7 @@ 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) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -631,26 +682,25 @@ H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) HDassert(space); /* Copy dataspace for dataset */ - if(NULL == (dset->shared->space = H5S_copy(space, FALSE, TRUE))) + if (NULL == (dset->shared->space = H5S_copy(space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dset) < 0) + if (H5D__cache_dataspace_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Set the version for dataspace */ - if(H5S_set_version(file, dset->shared->space) < 0) + if (H5S_set_version(file, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") /* Set the dataset's dataspace to 'all' selection */ - if(H5S_select_all(dset->shared->space, TRUE) < 0) + if (H5S_select_all(dset->shared->space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set all selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_space() */ - /*------------------------------------------------------------------------- * Function: H5D__use_minimized_dset_headers * @@ -668,7 +718,7 @@ H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) static herr_t H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -676,19 +726,19 @@ H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) HDassert(minimize); /* Get the dataset object header minimize flag for this call */ - if(H5CX_get_dset_min_ohdr_flag(minimize) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset object header minimize flag from API context") + if (H5CX_get_dset_min_ohdr_flag(minimize) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get dataset object header minimize flag from API context") - if(FALSE == *minimize) + if (FALSE == *minimize) *minimize = H5F_get_min_dset_ohdr(file); done: - if(FAIL == ret_value) + if (FAIL == ret_value) *minimize = FALSE; FUNC_LEAVE_NOAPI(ret_value); } /* H5D__use_minimized_dset_headers */ - /*------------------------------------------------------------------------- * Function: H5D__calculate_minimium_header_size * @@ -704,7 +754,7 @@ 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 */ @@ -717,8 +767,8 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) HDassert(dset); HDassert(ohdr); - type = dset->shared->type; - fill_prop = &(dset->shared->dcpl_cache.fill); + type = dset->shared->type; + fill_prop = &(dset->shared->dcpl_cache.fill); use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Datatype message size */ @@ -755,7 +805,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) ret_value += get_value; /* Fill Value (backwards compatability) message size */ - if(fill_prop->buf && !use_at_least_v18) { + if (fill_prop->buf && !use_at_least_v18) { H5O_fill_t old_fill_prop; /* Copy for writing "old" fill value */ /* Shallow copy the fill value property */ @@ -767,14 +817,15 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_ID, &old_fill_prop, 0); if (get_value == 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value (backwards compat) message") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, + "can't get size of fill value (backwards compat) message") ret_value += get_value; } /* Filter/Pipeline message size */ - if(H5D_CHUNKED == dset->shared->layout.type) { + if (H5D_CHUNKED == dset->shared->layout.type) { H5O_pline_t *pline = &dset->shared->dcpl_cache.pline; - if(pline->nused > 0) { + if (pline->nused > 0) { get_value = H5O_msg_size_oh(file, ohdr, H5O_PLINE_ID, pline, 0); if (get_value == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of filter message") @@ -783,7 +834,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) } /* External File Link message size */ - if(dset->shared->dcpl_cache.efl.nused > 0) { + if (dset->shared->dcpl_cache.efl.nused > 0) { get_value = H5O_msg_size_oh(file, ohdr, H5O_EFL_ID, &dset->shared->dcpl_cache.efl, 0); if (get_value == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of external file link message") @@ -791,10 +842,10 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) } /* Modification Time message size */ - if(H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { + if (H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { HDassert(H5O_OH_GET_VERSION(ohdr) >= 1); /* 1 :: H5O_VERSION_1 (H5Opkg.h) */ - if(H5O_OH_GET_VERSION(ohdr) == 1) { + if (H5O_OH_GET_VERSION(ohdr) == 1) { /* v1 object headers store modification time as a message */ time_t mtime; get_value = H5O_msg_size_oh(file, ohdr, H5O_MTIME_NEW_ID, &mtime, 0); @@ -808,7 +859,6 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) FUNC_LEAVE_NOAPI(ret_value); } /* H5D__calculate_minimum_header_size */ - /*------------------------------------------------------------------------- * Function: H5D__prepare_minimized_oh * @@ -825,9 +875,9 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) { - H5O_t *oh = NULL; - size_t ohdr_size = 0; - herr_t ret_value = SUCCEED; + H5O_t *oh = NULL; + size_t ohdr_size = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -835,23 +885,22 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) HDassert(dset); HDassert(oloc); - oh = H5O__create_ohdr(file, dset->shared->dcpl_id); - if(NULL == oh) + oh = H5O_create_ohdr(file, dset->shared->dcpl_id); + if (NULL == oh) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't instantiate object header") ohdr_size = H5D__calculate_minimum_header_size(file, dset, oh); if (ohdr_size == 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") + 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. */ - if(H5O__apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) + 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") done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D__prepare_minimized_oh */ - /*------------------------------------------------------------------------- * Function: H5D__update_oh_info * @@ -864,18 +913,18 @@ 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 */ - 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 */ - 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 */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - hbool_t use_minimized_header = FALSE; /* Flag to use minimized dataset object headers */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + hbool_t use_minimized_header = FALSE; /* Flag to use minimized dataset object headers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -884,22 +933,22 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HDassert(dset); /* Set some local variables, for convenience */ - oloc = &dset->oloc; - layout = &dset->shared->layout; - type = dset->shared->type; + oloc = &dset->oloc; + layout = &dset->shared->layout; + type = dset->shared->type; fill_prop = &dset->shared->dcpl_cache.fill; /* To use at least v18 format versions or not */ use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); /* Retrieve "defined" status of fill value */ - if(H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Special case handling for variable-length types */ - if(H5T_detect_class(type, H5T_VLEN, FALSE)) { + if (H5T_detect_class(type, H5T_VLEN, FALSE)) { /* If the default fill value is chosen for variable-length types, always write it */ - if(fill_prop->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_DEFAULT) { + if (fill_prop->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_DEFAULT) { /* Update dataset creation property */ fill_prop->fill_time = H5D_FILL_TIME_ALLOC; @@ -908,81 +957,84 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) } /* end if */ /* Don't allow never writing fill values with variable-length types */ - if(fill_prop->fill_time == H5D_FILL_TIME_NEVER) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Dataset doesn't support VL datatype when fill value is not defined") + if (fill_prop->fill_time == H5D_FILL_TIME_NEVER) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "Dataset doesn't support VL datatype when fill value is not defined") } /* end if */ /* Determine whether fill value is defined or not */ - if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { + if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { /* Convert fill value buffer to dataset's datatype */ - if(fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(fill_prop, type, &fill_changed) < 0) + if (fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(fill_prop, type, &fill_changed) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type") fill_prop->fill_defined = TRUE; } - else if(fill_status == H5D_FILL_VALUE_UNDEFINED) + else if (fill_status == H5D_FILL_VALUE_UNDEFINED) fill_prop->fill_defined = FALSE; else HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") /* Check for invalid fill & allocation time setting */ - if(fill_prop->fill_defined == FALSE && fill_prop->fill_time == H5D_FILL_TIME_ALLOC) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "fill value writing on allocation set, but no fill value defined") + if (fill_prop->fill_defined == FALSE && fill_prop->fill_time == H5D_FILL_TIME_ALLOC) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "fill value writing on allocation set, but no fill value defined") /* Check if the fill value info changed */ - if(fill_changed) { - H5P_genplist_t *dc_plist; /* Dataset's creation property list */ + if (fill_changed) { + H5P_genplist_t *dc_plist; /* Dataset's creation property list */ /* Get dataset's property list object */ HDassert(dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT); - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Update dataset creation property */ - if(H5P_set(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if (H5P_set(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - if(H5D__use_minimized_dset_headers(file, &use_minimized_header) == FAIL) + if (H5D__use_minimized_dset_headers(file, &use_minimized_header) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") - if(TRUE == use_minimized_header) { - if(H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) + if (TRUE == use_minimized_header) { + if (H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create minimized dataset object header") - } else { + } /* end if */ + else { /* Add the dataset's raw data size to the size of the header, if the * raw data will be stored as compact */ - if(H5D_COMPACT == layout->type) + if (H5D_COMPACT == layout->type) ohdr_size += layout->storage.u.compact.size; /* Create an object header for the dataset */ - if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) + if (H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") } /* if using default/minimized object headers */ HDassert(file == dset->oloc.file); /* Pin the object header */ - if(NULL == (oh = H5O_pin(oloc))) + if (NULL == (oh = H5O_pin(oloc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") /* Write the dataspace header message */ - if(H5S_append(file, oh, dset->shared->space) < 0) + if (H5S_append(file, oh, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update dataspace header message") /* Write the datatype header message */ - if(H5O_msg_append_oh(file, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, type) < 0) + if (H5O_msg_append_oh(file, oh, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT, 0, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update datatype header message") /* Write new fill value message */ - if(H5O_msg_append_oh(file, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, fill_prop) < 0) + if (H5O_msg_append_oh(file, oh, H5O_FILL_NEW_ID, H5O_MSG_FLAG_CONSTANT, 0, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update new fill value header message") /* If there is valid information for the old fill value struct, add it */ /* (only if we aren't using v18 format versions and above */ - if(fill_prop->buf && !use_at_least_v18) { - H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ + if (fill_prop->buf && !use_at_least_v18) { + H5O_fill_t old_fill_prop; /* Copy of fill value property, for writing as "old" fill value */ /* Shallow copy the fill value property */ /* (we only want to make certain that the shared component isn't modified) */ @@ -992,72 +1044,70 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop); /* Write old fill value */ - if(H5O_msg_append_oh(file, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, 0, &old_fill_prop) < 0) + if (H5O_msg_append_oh(file, oh, H5O_FILL_ID, H5O_MSG_FLAG_CONSTANT, 0, &old_fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update old fill value header message") } /* end if */ /* Update/create the layout (and I/O pipeline & EFL) messages */ - if(H5D__layout_oh_create(file, oh, dset, dapl_id) < 0) + if (H5D__layout_oh_create(file, oh, dset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout/pline/efl header message") /* Indicate that the layout information was initialized */ layout_init = TRUE; #ifdef H5O_ENABLE_BOGUS -{ - H5P_genplist_t *dc_plist; /* Dataset's creation property list */ + { + H5P_genplist_t *dc_plist; /* Dataset's creation property list */ - /* Get dataset's property list object */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") + /* Get dataset's property list object */ + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") - /* Check whether to add a "bogus" message */ - if( (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) && - (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0) ) { + /* Check whether to add a "bogus" message */ + if ((H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) && + (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0)) { - uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ - unsigned bogus_id; /* "bogus" ID */ + uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ + unsigned bogus_id; /* "bogus" ID */ - /* Retrieve "bogus" message ID */ - if(H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") - /* Retrieve "bogus" message flags */ - if(H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") + /* Retrieve "bogus" message ID */ + if (H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") + /* Retrieve "bogus" message flags */ + if (H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") - /* Add a "bogus" message (for error testing). */ - if(H5O_bogus_oh(file, oh, bogus_id, (unsigned)bogus_flags) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") - } /* end if */ -} + /* Add a "bogus" message (for error testing). */ + if (H5O_bogus_oh(file, oh, bogus_id, (unsigned)bogus_flags) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") + } /* end if */ + } #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message, if using older format. */ /* (If using v18 format versions and above, the the modification time is part of the object * header and doesn't use a separate message -QAK) */ - if(!use_at_least_v18) - if(H5O_touch_oh(file, oh, TRUE) < 0) + if (!use_at_least_v18) + if (H5O_touch_oh(file, oh, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") done: /* Release pointer to object header itself */ - if(oh != NULL) - if(H5O_unpin(oh) < 0) + if (oh != NULL) + if (H5O_unpin(oh) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") /* Error cleanup */ - if(ret_value < 0) - if(layout_init) + if (ret_value < 0) + if (layout_init) /* Destroy the layout information for the dataset */ - if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) + if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__update_oh_info() */ - - /*-------------------------------------------------------------------------- * Function: H5D__build_file_prefix * @@ -1071,12 +1121,12 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) 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 */ - size_t filepath_len; /* length of file path */ - size_t prefix_len; /* length of prefix */ - size_t file_prefix_len; /* length of expanded prefix */ - herr_t ret_value = SUCCEED; /* Return value */ + const char *prefix = NULL; /* prefix used to look for the file */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1089,19 +1139,19 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(H5F_PREFIX_VDS == prefix_type) { + if (H5F_PREFIX_VDS == prefix_type) { prefix = H5D_prefix_vds_env; - if(prefix == NULL || *prefix == '\0') { - if(H5CX_get_vds_prefix(&prefix) < 0) + if (prefix == NULL || *prefix == '\0') { + if (H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } } - else if(H5F_PREFIX_EFILE == prefix_type) { + else if (H5F_PREFIX_EFILE == prefix_type) { prefix = H5D_prefix_ext_env; - if(prefix == NULL || *prefix == '\0') { - if(H5CX_get_ext_file_prefix(&prefix) < 0) + if (prefix == NULL || *prefix == '\0') { + if (H5CX_get_ext_file_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") } } @@ -1111,34 +1161,33 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** /* Prefix has to be checked for NULL / empty string again because the * code above might have updated it. */ - if(prefix == NULL || *prefix == '\0' || HDstrcmp(prefix, ".") == 0) { + if (prefix == NULL || *prefix == '\0' || HDstrcmp(prefix, ".") == 0) { /* filename is interpreted as relative to the current directory, * does not need to be expanded */ *file_prefix = NULL; } /* end if */ else { - if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { + if (HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { /* Replace ${ORIGIN} at beginning of prefix by directory of HDF5 file */ - filepath_len = HDstrlen(filepath); - prefix_len = HDstrlen(prefix); + filepath_len = HDstrlen(filepath); + prefix_len = HDstrlen(prefix); file_prefix_len = filepath_len + prefix_len - HDstrlen("${ORIGIN}") + 1; - if(NULL == (*file_prefix = (char *)H5MM_malloc(file_prefix_len))) + if (NULL == (*file_prefix = (char *)H5MM_malloc(file_prefix_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer") HDsnprintf(*file_prefix, file_prefix_len, "%s%s", filepath, prefix + HDstrlen("${ORIGIN}")); } /* end if */ else { - if(NULL == (*file_prefix = (char *)H5MM_strdup(prefix))) + if (NULL == (*file_prefix = (char *)H5MM_strdup(prefix))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__build_file_prefix() */ - /*------------------------------------------------------------------------- * Function: H5D__create * @@ -1155,20 +1204,20 @@ 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) +H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id) { - const H5T_t *type; /* Datatype for dataset */ - 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 */ - hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ - hbool_t fill_copied = FALSE; /* Flag to indicate that fill-value message was copied */ - 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 */ + 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 */ + hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + hbool_t fill_copied = FALSE; /* Flag to indicate that fill-value message was copied */ + 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 */ FUNC_ENTER_PACKAGE @@ -1179,23 +1228,26 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HDassert(H5I_GENPROP_LST == H5I_get_type(dcpl_id)); /* Get the dataset's datatype */ - if(NULL == (type = (const H5T_t *)H5I_object(type_id))) + if (NULL == (dt = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the pointer via the VOL plugin */ + type = H5T_get_actual_type(dt); + /* Check if the datatype is "sensible" for use in a dataset */ - if(H5T_is_sensible(type) != TRUE) + if (H5T_is_sensible(type) != TRUE) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") /* Check if the datatype is/contains a VL-type */ - if(H5T_detect_class(type, H5T_VLEN, FALSE)) + if (H5T_detect_class(type, H5T_VLEN, FALSE)) has_vl_type = TRUE; /* Check if the dataspace has an extent set (or is NULL) */ - if(!H5S_has_extent(space)) + if (!H5S_has_extent(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "dataspace extent has not been set.") /* Initialize the dataset object */ - if(NULL == (new_dset = H5FL_CALLOC(H5D_t))) + if (NULL == (new_dset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set up & reset dataset location */ @@ -1204,131 +1256,133 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, H5G_loc_reset(&dset_loc); /* Initialize the shared dataset space */ - if(NULL == (new_dset->shared = H5D__new(dcpl_id, dapl_id, TRUE, has_vl_type))) + if (NULL == (new_dset->shared = H5D__new(dcpl_id, dapl_id, TRUE, has_vl_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy & initialize datatype for dataset */ - if(H5D__init_type(file, new_dset, type_id, type) < 0) + if (H5D__init_type(file, new_dset, type_id, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy datatype") /* Copy & initialize dataspace for dataset */ - if(H5D__init_space(file, new_dset, space) < 0) + if (H5D__init_space(file, new_dset, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy dataspace") /* Set the dataset's checked_filters flag to enable writing */ new_dset->shared->checked_filters = TRUE; /* 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 */ - htri_t ignore_filters = FALSE; /* Ignore optional filters or not */ - - if((ignore_filters = H5Z_ignore_filters(new_dset->shared->dcpl_id, type, space))<0) + 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 */ + htri_t ignore_filters = FALSE; /* Ignore optional filters or not */ + + if ((ignore_filters = H5Z_ignore_filters(new_dset->shared->dcpl_id, dt, space)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "H5Z_has_optional_filter() failed") - if(FALSE == ignore_filters) { + if (FALSE == ignore_filters) { /* Check if the filters in the DCPL can be applied to this dataset */ - if(H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + if (H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + if (H5Z_set_local(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") } /* ignore_filters */ /* Get new dataset's property list object */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(new_dset->shared->dcpl_id))) + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(new_dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") /* Retrieve the properties we need */ pline = &new_dset->shared->dcpl_cache.pline; - if(H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, pline) < 0) + if (H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve pipeline filter") pline_copied = TRUE; - layout = &new_dset->shared->layout; - if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) + layout = &new_dset->shared->layout; + if (H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve layout") layout_copied = TRUE; - fill = &new_dset->shared->dcpl_cache.fill; - if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) + fill = &new_dset->shared->dcpl_cache.fill; + if (H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve fill value info") fill_copied = TRUE; - efl = &new_dset->shared->dcpl_cache.efl; - if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, efl) < 0) + efl = &new_dset->shared->dcpl_cache.efl; + if (H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve external file list") efl_copied = TRUE; - if(FALSE == ignore_filters) { + if (FALSE == ignore_filters) { /* Check that chunked layout is used if filters are enabled */ - if(pline->nused > 0 && H5D_CHUNKED != layout->type) + if (pline->nused > 0 && H5D_CHUNKED != layout->type) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") - } + } /* Check if the alloc_time is the default and error out */ - if(fill->alloc_time == H5D_ALLOC_TIME_DEFAULT) + if (fill->alloc_time == H5D_ALLOC_TIME_DEFAULT) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ - if(layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) + if (layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") } /* end if */ /* Set the version for the I/O pipeline message */ - if(H5O_pline_set_version(file, &new_dset->shared->dcpl_cache.pline) < 0) + if (H5O_pline_set_version(file, &new_dset->shared->dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") /* Set the version for the fill message */ - if(H5O_fill_set_version(file, &new_dset->shared->dcpl_cache.fill) < 0) + if (H5O_fill_set_version(file, &new_dset->shared->dcpl_cache.fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") /* Set the latest version for the layout message */ - if(H5D__layout_set_version(file, &new_dset->shared->layout) < 0) + if (H5D__layout_set_version(file, &new_dset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") - if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { + if (new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { /* Use latest indexing type for layout message version >= 4 */ - if(H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) + if (H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, + &new_dset->shared->dcpl_cache) < 0) 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 */ - if(H5F_HAS_FEATURE(file, H5FD_FEAT_ALLOCATE_EARLY)) + if (H5F_HAS_FEATURE(file, H5FD_FEAT_ALLOCATE_EARLY)) 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) + if (H5D__layout_set_io_ops(new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") /* Create the layout information for the new dataset */ - if(new_dset->shared->layout.ops->construct && (new_dset->shared->layout.ops->construct)(file, new_dset) < 0) + if (new_dset->shared->layout.ops->construct && + (new_dset->shared->layout.ops->construct)(file, new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to construct layout information") /* Update the dataset's object header info. */ - if(H5D__update_oh_info(file, new_dset, new_dset->shared->dapl_id) < 0) + if (H5D__update_oh_info(file, new_dset, new_dset->shared->dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Indicate that the layout information was initialized */ layout_init = TRUE; /* Set up append flush parameters for the dataset */ - if(H5D__append_flush_setup(new_dset, new_dset->shared->dapl_id) < 0) + if (H5D__append_flush_setup(new_dset, new_dset->shared->dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) + if (H5D__build_file_prefix(new_dset, H5F_PREFIX_EFILE, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) + if (H5D__build_file_prefix(new_dset, H5F_PREFIX_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ - if(H5FO_top_incr(new_dset->oloc.file, new_dset->oloc.addr) < 0) + if (H5FO_top_incr(new_dset->oloc.file, new_dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't incr object ref. count") - if(H5FO_insert(new_dset->oloc.file, new_dset->oloc.addr, new_dset->shared, TRUE) < 0) + if (H5FO_insert(new_dset->oloc.file, new_dset->oloc.addr, new_dset->shared, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") new_dset->shared->fo_count = 1; @@ -1336,63 +1390,63 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, ret_value = new_dset; done: - if(!ret_value && new_dset) { - if(new_dset->shared) { - if(layout_init) - if(new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset) < 0) + if (!ret_value && new_dset) { + if (new_dset->shared) { + if (layout_init) + if (new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy layout info") - if(pline_copied) - if(H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) + if (pline_copied) + if (H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset I/O pipeline info") - if(layout_copied) - if(H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) + if (layout_copied) + if (H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info") - if(fill_copied) - if(H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) + if (fill_copied) + if (H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset fill-value info") - if(efl_copied) - if(H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) + if (efl_copied) + if (H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") - if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) + if (new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - if(new_dset->shared->type) { - if(new_dset->shared->type_id > 0) { - if(H5I_dec_ref(new_dset->shared->type_id) < 0) + if (new_dset->shared->type) { + if (new_dset->shared->type_id > 0) { + if (H5I_dec_ref(new_dset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end if */ else { - if(H5T_close_real(new_dset->shared->type) < 0) + if (H5T_close_real(new_dset->shared->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end else */ - } /* end if */ + } /* end if */ - if(H5F_addr_defined(new_dset->oloc.addr)) { - if(H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - if(H5O_close(&(new_dset->oloc), NULL) < 0) + if (H5F_addr_defined(new_dset->oloc.addr)) { + if (H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(new_dset->oloc), NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") - if(file) { - if(H5O_delete(file, new_dset->oloc.addr) < 0) + if (file) { + if (H5O_delete(file, new_dset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ - } /* end if */ - if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) + } /* end if */ + if (new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - if(new_dset->shared->dapl_id != 0 && H5I_dec_ref(new_dset->shared->dapl_id) < 0) + if (new_dset->shared->dapl_id != 0 && H5I_dec_ref(new_dset->shared->dapl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); - new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); - new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); + new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); + new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ new_dset->oloc.file = NULL; - new_dset = H5FL_FREE(H5D_t, new_dset); + new_dset = H5FL_FREE(H5D_t, new_dset); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create() */ - /*------------------------------------------------------------------------- * Function: H5D__open_name * @@ -1405,13 +1459,13 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, H5D_t * H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) { - 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 * 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 */ FUNC_ENTER_PACKAGE @@ -1425,32 +1479,31 @@ H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) H5G_loc_reset(&dset_loc); /* Find the dataset object */ - if(H5G_loc_find(loc, name, &dset_loc) < 0) + if (H5G_loc_find(loc, name, &dset_loc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type) < 0) + if (H5O_obj_type(&oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, NULL, "not a dataset") /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id))) + if (NULL == (dset = H5D_open(&dset_loc, dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't open dataset") /* Set return value */ ret_value = dset; done: - if(!ret_value) - if(loc_found && H5G_loc_free(&dset_loc) < 0) + if (!ret_value) + if (loc_found && H5G_loc_free(&dset_loc) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__open_name() */ - /* *------------------------------------------------------------------------- * Function: H5D_open @@ -1465,11 +1518,11 @@ H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) 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_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 */ FUNC_ENTER_NOAPI(NULL) @@ -1477,40 +1530,40 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HDassert(loc); /* Allocate the dataset structure */ - if(NULL == (dataset = H5FL_CALLOC(H5D_t))) + if (NULL == (dataset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&(dataset->oloc), loc->oloc) < 0) + if (H5O_loc_copy_shallow(&(dataset->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dataset->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dataset->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) + if (H5D__build_file_prefix(dataset, H5F_PREFIX_EFILE, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) + if (H5D__build_file_prefix(dataset, H5F_PREFIX_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ - if(NULL == (shared_fo = (H5D_shared_t *)H5FO_opened(dataset->oloc.file, dataset->oloc.addr))) { + if (NULL == (shared_fo = (H5D_shared_t *)H5FO_opened(dataset->oloc.file, dataset->oloc.addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the dataset object */ - if(H5D__open_oid(dataset, dapl_id) < 0) + if (H5D__open_oid(dataset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") /* Add the dataset to the list of opened objects in the file */ - if(H5FO_insert(dataset->oloc.file, dataset->oloc.addr, dataset->shared, FALSE) < 0) + if (H5FO_insert(dataset->oloc.file, dataset->oloc.addr, dataset->shared, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") /* We're the first dataset to use the the shared info */ @@ -1537,23 +1590,28 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) /* Check whether the external file prefix of the already open dataset * matches the new external file prefix */ - if(extfile_prefix && dataset->shared->extfile_prefix) { - if(HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") - } else { - if(extfile_prefix || dataset->shared->extfile_prefix) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "new external file prefix does not match external file prefix of already open dataset") + if (extfile_prefix && dataset->shared->extfile_prefix) { + if (HDstrcmp(extfile_prefix, dataset->shared->extfile_prefix) != 0) + HGOTO_ERROR( + H5E_DATASET, H5E_CANTOPENOBJ, NULL, + "new external file prefix does not match external file prefix of already open dataset") + } + else { + if (extfile_prefix || dataset->shared->extfile_prefix) + HGOTO_ERROR( + H5E_DATASET, H5E_CANTOPENOBJ, NULL, + "new external file prefix does not match external file prefix of already open dataset") } /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { + if (H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(dataset->oloc)) < 0) + if (H5O_open(&(dataset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -1562,15 +1620,15 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) done: extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - vds_prefix = (char *)H5MM_xfree(vds_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); - if(ret_value == NULL) { + if (ret_value == NULL) { /* Free the location--casting away const*/ - if(dataset) { - if(shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ + if (dataset) { + if (shared_fo == NULL && dataset->shared) { /* Need to free shared fo */ dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); - dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); - dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); + dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); + dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } H5O_loc_free(&(dataset->oloc)); @@ -1578,14 +1636,13 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) dataset = H5FL_FREE(H5D_t, dataset); } /* end if */ - if(shared_fo) + if (shared_fo) shared_fo->fo_count--; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_open() */ - /* *------------------------------------------------------------------------- * Function: H5D__flush_append_setup @@ -1598,7 +1655,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -1607,60 +1664,60 @@ H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) HDassert(dset->shared); /* Set default append flush values */ - HDmemset(&dset->shared->append_flush, 0, sizeof(dset->shared->append_flush)); + HDmemset(&dset->shared->append_flush, 0, sizeof(dset->shared->append_flush)); /* If the dataset is chunked and there is a non-default DAPL */ - if(dapl_id != H5P_DATASET_ACCESS_DEFAULT && dset->shared->layout.type == H5D_CHUNKED) { - H5P_genplist_t *dapl; /* data access property list object pointer */ + if (dapl_id != H5P_DATASET_ACCESS_DEFAULT && dset->shared->layout.type == H5D_CHUNKED) { + H5P_genplist_t *dapl; /* data access property list object pointer */ /* Get dataset access property list */ - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID"); /* Check if append flush property exists */ - if(H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { + if (H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { H5D_append_flush_t info; /* Get append flush property */ - if(H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get append flush info") - if(info.ndims > 0) { - hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ - hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ - int rank; /* dataspace # of dimensions */ - unsigned u; /* local index variable */ + if (info.ndims > 0) { + hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ + hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ + int rank; /* dataspace # of dimensions */ + unsigned u; /* local index variable */ /* Get dataset rank */ - if((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) + if ((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - if(info.ndims != (unsigned)rank) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension rank does not match dataset rank") + if (info.ndims != (unsigned)rank) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, + "boundary dimension rank does not match dataset rank") /* Validate boundary sizes */ - for(u = 0; u < info.ndims; u++) - if(info.boundary[u] != 0) /* when a non-zero boundary is set */ + for (u = 0; u < info.ndims; u++) + if (info.boundary[u] != 0) /* when a non-zero boundary is set */ /* the dimension is extendible? */ - if(max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) + if (max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) break; /* At least one boundary dimension is not extendible */ - if(u != info.ndims) + if (u != info.ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension is not valid") /* Copy append flush settings */ dset->shared->append_flush.ndims = info.ndims; - dset->shared->append_flush.func = info.func; + dset->shared->append_flush.func = info.func; dset->shared->append_flush.udata = info.udata; H5MM_memcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary)); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__append_flush_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__open_oid * @@ -1672,12 +1729,12 @@ 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dataset->oloc.addr) @@ -1685,67 +1742,67 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) HDassert(dataset); /* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */ - if(NULL == (dataset->shared = H5D__new(H5P_DATASET_CREATE_DEFAULT, dapl_id, FALSE, FALSE))) + if (NULL == (dataset->shared = H5D__new(H5P_DATASET_CREATE_DEFAULT, dapl_id, FALSE, FALSE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Open the dataset object */ - if(H5O_open(&(dataset->oloc)) < 0) + if (H5O_open(&(dataset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open") /* Get the type and space */ - if(NULL == (dataset->shared->type = (H5T_t *)H5O_msg_read(&(dataset->oloc), H5O_DTYPE_ID, NULL))) + if (NULL == (dataset->shared->type = (H5T_t *)H5O_msg_read(&(dataset->oloc), H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load type info from dataset header") - if(H5T_set_loc(dataset->shared->type, dataset->oloc.file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(dataset->shared->type, H5F_VOL_OBJ(dataset->oloc.file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") - if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) + if (NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dataset) < 0) + if (H5D__cache_dataspace_info(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Get a datatype ID for the dataset's datatype */ - if((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type, FALSE)) < 0) + if ((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") /* Get dataset creation property list object */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dataset->shared->dcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dataset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Get the layout/pline/efl message information */ - if(H5D__layout_oh_read(dataset, dapl_id, plist) < 0) + if (H5D__layout_oh_read(dataset, dapl_id, plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout/pline/efl info") /* Indicate that the layout information was initialized */ layout_init = TRUE; /* Set up flush append property */ - if(H5D__append_flush_setup(dataset, dapl_id)) + if (H5D__append_flush_setup(dataset, dapl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set up flush append property") /* Point at dataset's copy, to cache it for later */ fill_prop = &dataset->shared->dcpl_cache.fill; /* Try to get the new fill value message from the object header */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_NEW_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_NEW_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_NEW_ID, fill_prop)) + if (msg_exists) { + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_NEW_ID, fill_prop)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") } /* end if */ else { - /* For backward compatibility, try to retrieve the old fill value message */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_ID)) < 0) + /* For backward compatibility, try to retrieve the old fill value message */ + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_ID, fill_prop)) + if (msg_exists) { + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_FILL_ID, fill_prop)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") } /* end if */ else { /* Set the space allocation time appropriately, based on the type of dataset storage */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_COMPACT: fill_prop->alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -1767,24 +1824,24 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet") } /* end switch */ /*lint !e788 All appropriate cases are covered */ - } /* end else */ + } /* end else */ /* If "old" fill value size is 0 (undefined), map it to -1 */ - if(fill_prop->size == 0) + if (fill_prop->size == 0) fill_prop->size = (ssize_t)-1; } /* end if */ alloc_time_state = 0; - if((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) - || (dataset->shared->layout.type == H5D_CONTIGUOUS && fill_prop->alloc_time == H5D_ALLOC_TIME_LATE) - || (dataset->shared->layout.type == H5D_CHUNKED && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR) - || (dataset->shared->layout.type == H5D_VIRTUAL && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR)) + if ((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) || + (dataset->shared->layout.type == H5D_CONTIGUOUS && fill_prop->alloc_time == H5D_ALLOC_TIME_LATE) || + (dataset->shared->layout.type == H5D_CHUNKED && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR) || + (dataset->shared->layout.type == H5D_VIRTUAL && fill_prop->alloc_time == H5D_ALLOC_TIME_INCR)) alloc_time_state = 1; /* Set revised fill value properties, if they are different from the defaults */ - if(H5P_fill_value_cmp(&H5D_def_dset.dcpl_cache.fill, fill_prop, sizeof(H5O_fill_t))) { - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) + if (H5P_fill_value_cmp(&H5D_def_dset.dcpl_cache.fill, fill_prop, sizeof(H5O_fill_t))) { + if (H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set fill value") - if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set allocation time state") } /* end if */ @@ -1793,74 +1850,43 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) * This is important only for parallel I/O where the space must * be fully allocated before I/O can happen. */ - 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)) { + 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)) { H5D_io_info_t io_info; io_info.dset = dataset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_OPEN, FALSE, NULL) < 0) + 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) { - if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) + if (ret_value < 0) { + if (H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") - if(dataset->shared) { - if(layout_init) - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared) { + if (layout_init) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") - if(dataset->shared->space && H5S_close(dataset->shared->space) < 0) + if (dataset->shared->space && H5S_close(dataset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(dataset->shared->type) { - if(dataset->shared->type_id > 0) { - if(H5I_dec_ref(dataset->shared->type_id) < 0) + if (dataset->shared->type) { + if (dataset->shared->type_id > 0) { + if (H5I_dec_ref(dataset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ else { - if(H5T_close_real(dataset->shared->type) < 0) + if (H5T_close_real(dataset->shared->type) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__open_oid() */ - -/*------------------------------------------------------------------------- - * Function: H5D__close_cb - * - * Purpose: Callback routine for closing a dataset ID. Closes the dataset - * object that was attached to the ID. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5D__close_cb(H5D_t *dataset) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* check args */ - HDassert(dataset && dataset->oloc.file && dataset->shared); - HDassert(dataset->shared->fo_count > 0); - - /* Call actual dataset close routine */ - if(H5D_close(dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "can't close dataset"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__close_cb() */ - - /*------------------------------------------------------------------------- * Function: H5D_close * @@ -1874,10 +1900,10 @@ H5D__close_cb(H5D_t *dataset) herr_t H5D_close(H5D_t *dataset) { - hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */ - hbool_t corked; /* Whether the dataset is corked or not */ - hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */ + hbool_t corked; /* Whether the dataset is corked or not */ + hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1891,10 +1917,10 @@ H5D_close(H5D_t *dataset) #endif /* H5D_CHUNK_DEBUG */ dataset->shared->fo_count--; - if(dataset->shared->fo_count == 0) { + if (dataset->shared->fo_count == 0) { /* Flush the dataset's information. Continue to close even if it fails. */ - if(H5D__flush_real(dataset) < 0) + if (H5D__flush_real(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") /* Set a flag to indicate the dataset is closing, before we start freeing things */ @@ -1904,30 +1930,32 @@ H5D_close(H5D_t *dataset) dataset->shared->closing = TRUE; /* Free cached information for each kind of dataset */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Free the data sieve buffer, if it's been allocated */ - if(dataset->shared->cache.contig.sieve_buf) - dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf); + if (dataset->shared->cache.contig.sieve_buf) + dataset->shared->cache.contig.sieve_buf = + (unsigned char *)H5FL_BLK_FREE(sieve_buf, dataset->shared->cache.contig.sieve_buf); break; case H5D_CHUNKED: /* Check for skip list for iterating over chunks during I/O to close */ - if(dataset->shared->cache.chunk.sel_chunks) { + if (dataset->shared->cache.chunk.sel_chunks) { HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0); H5SL_close(dataset->shared->cache.chunk.sel_chunks); dataset->shared->cache.chunk.sel_chunks = NULL; } /* end if */ /* Check for cached single chunk dataspace */ - if(dataset->shared->cache.chunk.single_space) { + if (dataset->shared->cache.chunk.single_space) { (void)H5S_close(dataset->shared->cache.chunk.single_space); dataset->shared->cache.chunk.single_space = NULL; } /* end if */ /* Check for cached single element chunk info */ - if(dataset->shared->cache.chunk.single_chunk_info) { - dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); + if (dataset->shared->cache.chunk.single_chunk_info) { + dataset->shared->cache.chunk.single_chunk_info = + H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ break; @@ -1936,32 +1964,35 @@ H5D_close(H5D_t *dataset) /* Nothing special to do (info freed in the layout destroy) */ break; - case H5D_VIRTUAL: - { + case H5D_VIRTUAL: { size_t i, j; - HDassert(dataset->shared->layout.storage.u.virt.list || (dataset->shared->layout.storage.u.virt.list_nused == 0)); + HDassert(dataset->shared->layout.storage.u.virt.list || + (dataset->shared->layout.storage.u.virt.list_nused == 0)); /* Close source datasets */ - for(i = 0; i < dataset->shared->layout.storage.u.virt.list_nused; i++) { + for (i = 0; i < dataset->shared->layout.storage.u.virt.list_nused; i++) { /* Close source dataset */ - if(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) { + if (dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) { HDassert(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset != dataset); - if(H5D_close(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) < 0) + if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") dataset->shared->layout.storage.u.virt.list[i].source_dset.dset = NULL; } /* end if */ /* Close sub datasets */ - for(j = 0; j < dataset->shared->layout.storage.u.virt.list[i].sub_dset_nused; j++) - if(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) { - HDassert(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset != dataset); - if(H5D_close(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + for (j = 0; j < dataset->shared->layout.storage.u.virt.list[i].sub_dset_nused; j++) + if (dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) { + HDassert(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset != + dataset); + if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) < + 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to close source dataset") dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset = NULL; } /* end if */ - } /* end for */ - } /* end block */ + } /* end for */ + } /* end block */ break; case H5D_LAYOUT_ERROR: @@ -1970,11 +2001,11 @@ H5D_close(H5D_t *dataset) HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Destroy any cached layout information for the dataset */ - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") /* Free the external file prefix */ @@ -1984,43 +2015,42 @@ H5D_close(H5D_t *dataset) dataset->shared->vds_prefix = (char *)H5MM_xfree(dataset->shared->vds_prefix); /* Release layout, fill-value, efl & pipeline messages */ - if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + if (dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) free_failed |= (H5O_msg_reset(H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline) < 0) || - (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) || - (H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) || - (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0); + (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) || + (H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) || + (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0); /* Uncork cache entries with object address tag */ - if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Release datatype, dataspace, and creation and access property lists -- there isn't * much we can do if one of these fails, so we just continue. */ - free_failed |= (H5I_dec_ref(dataset->shared->type_id) < 0) || - (H5S_close(dataset->shared->space) < 0) || - (H5I_dec_ref(dataset->shared->dcpl_id) < 0) || - (H5I_dec_ref(dataset->shared->dapl_id) < 0); + free_failed |= + (H5I_dec_ref(dataset->shared->type_id) < 0) || (H5S_close(dataset->shared->space) < 0) || + (H5I_dec_ref(dataset->shared->dcpl_id) < 0) || (H5I_dec_ref(dataset->shared->dapl_id) < 0); /* Remove the dataset from the list of opened objects in the file */ - if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_delete(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") /* Close the dataset object */ /* (This closes the file, if this is the last object open) */ - if(H5O_close(&(dataset->oloc), &file_closed) < 0) + if (H5O_close(&(dataset->oloc), &file_closed) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") /* Evict dataset metadata if evicting on close */ - if(!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { - if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr) < 0) + if (!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { + if (H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE) < 0) + if (H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") } /* end if */ @@ -2031,46 +2061,46 @@ H5D_close(H5D_t *dataset) * above). */ dataset->oloc.file = NULL; - dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); + dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } /* end if */ else { /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) + if (H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ - if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { - if(H5O_close(&(dataset->oloc), NULL) < 0) + if (H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) { + if (H5O_close(&(dataset->oloc), NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ 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") + if (H5O_loc_free(&(dataset->oloc)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ /* Release the dataset's path info */ - if(H5G_name_free(&(dataset->path)) < 0) + if (H5G_name_free(&(dataset->path)) < 0) free_failed = TRUE; /* Free the dataset's memory structure */ dataset = H5FL_FREE(H5D_t, dataset); /* Check if anything failed in the middle... */ - if(free_failed) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free a component of the dataset, but the dataset was freed anyway.") + if (free_failed) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "couldn't free a component of the dataset, but the dataset was freed anyway.") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_close() */ - /*------------------------------------------------------------------------- * Function: H5D_mult_refresh_close * * Purpose: Closing down the needed information when the dataset has - * multiple opens. (From H5O_refresh_metadata_close()) + * multiple opens. (From H5O__refresh_metadata_close()) * * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- @@ -2078,12 +2108,12 @@ H5D_close(H5D_t *dataset) herr_t H5D_mult_refresh_close(hid_t dset_id) { - H5D_t *dataset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dataset; /* Dataset to refresh */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (dataset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* check args */ @@ -2092,32 +2122,34 @@ H5D_mult_refresh_close(hid_t dset_id) HDassert(dataset->shared); HDassert(dataset->shared->fo_count > 0); - if(dataset->shared->fo_count > 1) { + if (dataset->shared->fo_count > 1) { /* Free cached information for each kind of dataset */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Free the data sieve buffer, if it's been allocated */ - if(dataset->shared->cache.contig.sieve_buf) - dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf); + if (dataset->shared->cache.contig.sieve_buf) + dataset->shared->cache.contig.sieve_buf = + (unsigned char *)H5FL_BLK_FREE(sieve_buf, dataset->shared->cache.contig.sieve_buf); break; case H5D_CHUNKED: /* Check for skip list for iterating over chunks during I/O to close */ - if(dataset->shared->cache.chunk.sel_chunks) { + if (dataset->shared->cache.chunk.sel_chunks) { HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0); H5SL_close(dataset->shared->cache.chunk.sel_chunks); dataset->shared->cache.chunk.sel_chunks = NULL; } /* end if */ /* Check for cached single chunk dataspace */ - if(dataset->shared->cache.chunk.single_space) { + if (dataset->shared->cache.chunk.single_space) { (void)H5S_close(dataset->shared->cache.chunk.single_space); dataset->shared->cache.chunk.single_space = NULL; } /* end if */ /* Check for cached single element chunk info */ - if(dataset->shared->cache.chunk.single_chunk_info) { - dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); + if (dataset->shared->cache.chunk.single_chunk_info) { + dataset->shared->cache.chunk.single_chunk_info = + H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ break; @@ -2133,11 +2165,11 @@ H5D_mult_refresh_close(hid_t dset_id) HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Destroy any cached layout information for the dataset */ - if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) + if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") } /* end if */ @@ -2145,7 +2177,6 @@ H5D_mult_refresh_close(hid_t dset_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_mult_refresh_close() */ - /*------------------------------------------------------------------------- * Function: H5D_mult_refresh_reopen * @@ -2158,7 +2189,7 @@ H5D_mult_refresh_close(hid_t dset_id) herr_t H5D_mult_refresh_reopen(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2166,25 +2197,25 @@ H5D_mult_refresh_reopen(H5D_t *dataset) HDassert(dataset && dataset->oloc.file && dataset->shared); HDassert(dataset->shared->fo_count > 0); - if(dataset->shared->fo_count > 1) { + if (dataset->shared->fo_count > 1) { /* Release dataspace info */ - if(H5S_close(dataset->shared->space) < 0) + if (H5S_close(dataset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") /* Re-load dataspace info */ - if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) + if (NULL == (dataset->shared->space = H5S_read(&(dataset->oloc)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dataset) < 0) + if (H5D__cache_dataspace_info(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") /* Release layout info */ - if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") /* Re-load layout message info */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") } /* end if */ @@ -2192,7 +2223,6 @@ H5D_mult_refresh_reopen(H5D_t *dataset) FUNC_LEAVE_NOAPI(ret_value) } /* H5D_mult_refresh_reopen() */ - /*------------------------------------------------------------------------- * Function: H5D_oloc * @@ -2211,7 +2241,6 @@ H5D_oloc(H5D_t *dataset) FUNC_LEAVE_NOAPI(dataset ? &(dataset->oloc) : (H5O_loc_t *)NULL) } /* end H5D_oloc() */ - /*------------------------------------------------------------------------- * Function: H5D_nameof * @@ -2230,31 +2259,6 @@ H5D_nameof(const H5D_t *dataset) FUNC_LEAVE_NOAPI(dataset ? &(dataset->path) : NULL) } /* end H5D_nameof() */ - -/*------------------------------------------------------------------------- - * Function: H5D_typeof - * - * Purpose: Returns a pointer to the dataset's datatype. The datatype - * is not copied. - * - * Return: Success: Ptr to the dataset's datatype, uncopied. - * Failure: NULL - *------------------------------------------------------------------------- - */ -H5T_t * -H5D_typeof(const H5D_t *dset) -{ - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(dset); - HDassert(dset->shared); - HDassert(dset->shared->type); - - FUNC_LEAVE_NOAPI(dset->shared->type) -} /* end H5D_typeof() */ - - /*------------------------------------------------------------------------- * Function: H5D__alloc_storage * @@ -2264,15 +2268,15 @@ H5D_typeof(const H5D_t *dset) *------------------------------------------------------------------------- */ 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[]) +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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2284,17 +2288,17 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * We assume that external storage is already * allocated by the caller, or at least will be before I/O is performed. */ - if(!(0 == H5S_GET_EXTENT_NPOINTS(dset->shared->space) || dset->shared->dcpl_cache.efl.nused > 0)) { + if (!(0 == H5S_GET_EXTENT_NPOINTS(dset->shared->space) || dset->shared->dcpl_cache.efl.nused > 0)) { /* Get a pointer to the dataset's layout information */ layout = &(dset->shared->layout); - switch(layout->type) { + switch (layout->type) { case H5D_CONTIGUOUS: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Check if we have a zero-sized dataset */ - if(layout->storage.u.contig.size > 0) { + if (layout->storage.u.contig.size > 0) { /* Reserve space in the file for the entire array */ - if(H5D__contig_alloc(f, &layout->storage.u.contig/*out*/) < 0) + if (H5D__contig_alloc(f, &layout->storage.u.contig /*out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage") /* Indicate that we should initialize storage space */ @@ -2309,9 +2313,9 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, break; case H5D_CHUNKED: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Create the root of the index that manages chunked storage */ - if(H5D__chunk_create(dset /*in,out*/) < 0) + if (H5D__chunk_create(dset /*in,out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Indicate that we set the storage addr */ @@ -2325,21 +2329,24 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * the dataset, indicate that space should be allocated, so the * index gets expanded. -QAK */ - if(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && time_alloc == H5D_ALLOC_EXTEND) + if (dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && + time_alloc == H5D_ALLOC_EXTEND) must_init_space = TRUE; break; case H5D_COMPACT: /* Check if space is already allocated */ - if(NULL == layout->storage.u.compact.buf) { + if (NULL == layout->storage.u.compact.buf) { /* Reserve space in layout header message for the entire array. * Starting from the 1.8.7 release, we allow dataspace to have * zero dimension size. So the storage size can be zero. * SLU 2011/4/4 */ - if(layout->storage.u.compact.size > 0) { - if(NULL == (layout->storage.u.compact.buf = H5MM_malloc(layout->storage.u.compact.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for compact dataset") - if(!full_overwrite) + if (layout->storage.u.compact.size > 0) { + if (NULL == + (layout->storage.u.compact.buf = H5MM_malloc(layout->storage.u.compact.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for compact dataset") + if (!full_overwrite) HDmemset(layout->storage.u.compact.buf, 0, layout->storage.u.compact.size); layout->storage.u.compact.dirty = TRUE; @@ -2348,7 +2355,7 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, } else { layout->storage.u.compact.dirty = FALSE; - must_init_space = FALSE; + must_init_space = FALSE; } } /* end if */ break; @@ -2368,12 +2375,12 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ /* Check if we need to initialize the space */ - if(must_init_space) { - if(layout->type == H5D_CHUNKED) { + if (must_init_space) { + if (layout->type == H5D_CHUNKED) { /* If we are doing incremental allocation and the index got * created during a H5Dwrite call, don't initialize the storage * now, wait for the actual writes to each block and let the @@ -2383,25 +2390,29 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, * fill values to the chunks they allocate space for. Yes, * this is icky. -QAK */ - if(!(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR && time_alloc == H5D_ALLOC_WRITE)) - if(H5D__init_storage(io_info, full_overwrite, old_dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") + if (!(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR && + time_alloc == H5D_ALLOC_WRITE)) + if (H5D__init_storage(io_info, full_overwrite, old_dim) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize dataset with fill value") } /* end if */ else { - H5D_fill_value_t fill_status; /* The fill value status */ + H5D_fill_value_t fill_status; /* The fill value status */ /* Check the dataset's fill-value status */ - if(H5P_is_fill_value_defined(&dset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&dset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ - if(dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || - (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) - if(H5D__init_storage(io_info, full_overwrite, old_dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") + if (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || + (dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET && + fill_status == H5D_FILL_VALUE_USER_DEFINED)) + if (H5D__init_storage(io_info, full_overwrite, old_dim) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize dataset with fill value") } /* end else */ - } /* end if */ + } /* end if */ /* If we set the address (and aren't in the middle of creating the * dataset), mark the layout header message for later writing to @@ -2410,9 +2421,9 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, /* (The layout message is already in the dataset's object header, this * operation just sets the address and makes it constant) */ - if(time_alloc != H5D_ALLOC_CREATE && addr_set) + if (time_alloc != H5D_ALLOC_CREATE && addr_set) /* Mark the layout as dirty, for later writing to the file */ - if(H5D__mark(dset, H5D_MARK_LAYOUT) < 0) + if (H5D__mark(dset, H5D_MARK_LAYOUT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ @@ -2420,7 +2431,6 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__alloc_storage() */ - /*------------------------------------------------------------------------- * Function: H5D__init_storage * @@ -2434,8 +2444,8 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]) { - const H5D_t *dset = io_info->dset; /* dataset pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5D_t *dset = io_info->dset; /* dataset pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2444,18 +2454,20 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t switch (dset->shared->layout.type) { case H5D_COMPACT: /* If we will be immediately overwriting the values, don't bother to clear them */ - if(!full_overwrite) { + if (!full_overwrite) { /* Fill the compact dataset storage */ - if(H5D__compact_fill(dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize compact dataset storage") + if (H5D__compact_fill(dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize compact dataset storage") } /* end if */ break; case H5D_CONTIGUOUS: /* Don't write default fill values to external files */ /* If we will be immediately overwriting the values, don't bother to clear them */ - if((dset->shared->dcpl_cache.efl.nused == 0 || dset->shared->dcpl_cache.fill.buf) && !full_overwrite) - if(H5D__contig_fill(io_info) < 0) + if ((dset->shared->dcpl_cache.efl.nused == 0 || dset->shared->dcpl_cache.fill.buf) && + !full_overwrite) + if (H5D__contig_fill(io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") break; @@ -2465,13 +2477,13 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t * for all chunks now and initialize each chunk with the fill value. */ { - hsize_t zero_dim[H5O_LAYOUT_NDIMS] = {0}; + hsize_t zero_dim[H5O_LAYOUT_NDIMS] = {0}; /* Use zeros for old dimensions if not specified */ - if(old_dim == NULL) + if (old_dim == NULL) old_dim = zero_dim; - if(H5D__chunk_allocate(io_info, full_overwrite, old_dim) < 0) + if (H5D__chunk_allocate(io_info, full_overwrite, old_dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") break; } /* end block */ @@ -2485,14 +2497,13 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t HDassert("not implemented yet" && 0); #ifdef NDEBUG HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_storage() */ - /*------------------------------------------------------------------------- * Function: H5D__get_storage_size * @@ -2505,15 +2516,16 @@ H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) - switch(dset->shared->layout.type) { + switch (dset->shared->layout.type) { case H5D_CHUNKED: - if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { - if(H5D__chunk_allocated(dset, storage_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve chunked dataset allocated size") + if ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { + if (H5D__chunk_allocated(dset, storage_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't retrieve chunked dataset allocated size") } /* end if */ else *storage_size = 0; @@ -2521,7 +2533,7 @@ H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) case H5D_CONTIGUOUS: /* Datasets which are not allocated yet are using no space on disk */ - if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) + if ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) *storage_size = dset->shared->layout.storage.u.contig.size; else *storage_size = 0; @@ -2547,7 +2559,6 @@ H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_storage_size() */ - /*------------------------------------------------------------------------- * Function: H5D__get_offset * @@ -2563,13 +2574,13 @@ H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size) haddr_t H5D__get_offset(const H5D_t *dset) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_PACKAGE HDassert(dset); - switch(dset->shared->layout.type) { + switch (dset->shared->layout.type) { case H5D_VIRTUAL: case H5D_CHUNKED: case H5D_COMPACT: @@ -2579,7 +2590,8 @@ H5D__get_offset(const H5D_t *dset) /* If dataspace hasn't been allocated or dataset is stored in * an external file, the value will be HADDR_UNDEF. */ - if(dset->shared->dcpl_cache.efl.nused == 0 || H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) + if (dset->shared->dcpl_cache.efl.nused == 0 || + H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) /* Return the absolute dataset offset from the beginning of file. */ ret_value = dset->shared->layout.storage.u.contig.addr + H5F_BASE_ADDR(dset->oloc.file); break; @@ -2594,83 +2606,179 @@ H5D__get_offset(const H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_offset() */ - /*------------------------------------------------------------------------- - * Function: H5D_vlen_reclaim + * Function: H5D__vlen_get_buf_size_alloc * - * Purpose: Frees the buffers allocated for storing variable-length data - * in memory. Only frees the VL data in the selection defined in the - * dataspace. + * Purpose: This routine makes certain there is enough space in the temporary + * buffer for the new data to read in. All the VL data read in is actually + * placed in this buffer, overwriting the previous data. Needless to say, + * this data is not actually usable. * * Return: Non-negative on success, negative on failure + * *------------------------------------------------------------------------- */ -herr_t -H5D_vlen_reclaim(hid_t type_id, H5S_t *space, void *buf) +static void * +H5D__vlen_get_buf_size_alloc(size_t size, void *info) { - 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 */ + H5D_vlen_bufsize_common_t *vlen_bufsize_com = (H5D_vlen_bufsize_common_t *)info; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC - /* Check args */ - HDassert(H5I_DATATYPE == H5I_get_type(type_id)); - HDassert(space); - HDassert(buf); + /* Check for increasing the size of the temporary space for VL data */ + if (size > vlen_bufsize_com->vl_tbuf_size) { + if (NULL == + (vlen_bufsize_com->vl_tbuf = H5FL_BLK_REALLOC(vlen_vl_buf, vlen_bufsize_com->vl_tbuf, size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't reallocate temporary VL data buffer") + vlen_bufsize_com->vl_tbuf_size = size; + } /* end if */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") + /* Increment size of VL data buffer needed */ + vlen_bufsize_com->size += size; - /* Get the allocation info */ - if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") + /* Set return value */ + ret_value = vlen_bufsize_com->vl_tbuf; - /* Call H5S_select_iterate with args, etc. */ - dset_op.op_type = H5S_SEL_ITER_OP_APP; - dset_op.u.app_op.op = H5T_vlen_reclaim; - dset_op.u.app_op.type_id = type_id; +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__vlen_get_buf_size_alloc() */ - ret_value = H5S_select_iterate(buf, type, space, &dset_op, &vl_alloc_info); +/*------------------------------------------------------------------------- + * Function: H5D__vlen_get_buf_size_cb + * + * Purpose: Dataspace selection iteration callback for H5Dvlen_get_buf_size. + * + * Return: Non-negative on success, negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__vlen_get_buf_size_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, + const hsize_t *point, void *op_data) +{ + H5D_vlen_bufsize_native_t *vlen_bufsize = (H5D_vlen_bufsize_native_t *)op_data; + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); + HDassert(point); + HDassert(op_data); + + /* Select point to read in */ + if (H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5_ITER_ERROR, "can't select point") + + /* Read in the point (with the custom VL memory allocator) */ + if (H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, + vlen_bufsize->common.fl_tbuf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, H5_ITER_ERROR, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_vlen_reclaim() */ +} /* end H5D__vlen_get_buf_size_cb() */ - /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size_alloc + * Function: H5D__vlen_get_buf_size * - * Purpose: This routine makes certain there is enough space in the temporary - * buffer for the new data to read in. All the VL data read in is actually - * placed in this buffer, overwriting the previous data. Needless to say, - * this data is not actually usable. + * Purpose: This routine checks the number of bytes required to store the VL + * data from the dataset, using the space_id for the selection in the + * dataset on disk and the type_id for the memory representation of the + * VL data, in memory. The *size value is modified according to how many + * bytes are required to store the VL data in memory. + * + * Implementation: This routine actually performs the read with a custom + * memory manager which basically just counts the bytes requested and + * uses a temporary memory buffer (through the H5FL API) to make certain + * enough space is available to perform the read. Then the temporary + * buffer is released and the number of bytes allocated is returned. + * Kinda kludgy, but easier than the other method of trying to figure out + * the sizes without actually reading the data in... - QAK + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, August 11, 1999 * - * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ -void * -H5D__vlen_get_buf_size_alloc(size_t size, void *info) +herr_t +H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size) { - H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)info; - void *ret_value = NULL; /* Return value */ + 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 */ + char bogus; /* bogus value to pass to H5Diterate() */ + 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 */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_PACKAGE - /* Get a temporary pointer to space for the VL data */ - if((vlen_bufsize->vl_tbuf = H5FL_BLK_REALLOC(vlen_vl_buf, vlen_bufsize->vl_tbuf, size)) != NULL) - vlen_bufsize->size += size; + /* Check args */ + if (NULL == (type = (H5T_t *)H5I_object(type_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") + if (NULL == (space = (H5S_t *)H5I_object(space_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") + if (!(H5S_has_extent(space))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") + + /* Save the dataset */ + vlen_bufsize.dset = dset; + + /* Get a copy of the dataset's dataspace */ + if (NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to get dataspace") + vlen_bufsize.fspace = fspace; + + /* Create a scalar for the memory dataspace */ + if (NULL == (mspace = H5S_create(H5S_SCALAR))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + vlen_bufsize.mspace = mspace; + + /* Grab the temporary buffers required */ + if (NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") + if (NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") + vlen_bufsize.common.vl_tbuf_size = 1; + + /* Set the memory manager to the special allocation routine */ + if (H5CX_set_vlen_alloc_info(H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VL data allocation routine") + + /* Set the initial number of bytes required */ + vlen_bufsize.common.size = 0; - /* Set return value */ - ret_value = vlen_bufsize->vl_tbuf; + /* Call H5S_select_iterate with args, etc. */ + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = H5D__vlen_get_buf_size_cb; + dset_op.u.app_op.type_id = type_id; + + ret_value = H5S_select_iterate(&bogus, type, space, &dset_op, &vlen_bufsize); + + /* Get the size if we succeeded */ + if (ret_value >= 0) + *size = vlen_bufsize.common.size; + +done: + if (fspace && H5S_close(fspace) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + if (mspace && H5S_close(mspace) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + if (vlen_bufsize.common.fl_tbuf != NULL) + vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); + if (vlen_bufsize.common.vl_tbuf != NULL) + vlen_bufsize.common.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.common.vl_tbuf); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__vlen_get_buf_size_alloc() */ +} /* end H5D__vlen_get_buf_size() */ - /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size + * Function: H5D__vlen_get_buf_size_gen_cb * * Purpose: This routine checks the number of bytes required to store a single * element from a dataset in memory, creating a selection with just the @@ -2690,40 +2798,156 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ -herr_t -H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, - unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) +static herr_t +H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, + const hsize_t *point, void *op_data) { - H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)op_data; - H5T_t *dt; /* Datatype for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_vlen_bufsize_generic_t *vlen_bufsize = (H5D_vlen_bufsize_generic_t *)op_data; + H5T_t * dt; /* Datatype for operation */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC + /* Sanity check */ + HDassert(point); HDassert(op_data); - HDassert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object(type_id))) + if (NULL == (dt = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a datatype") /* Make certain there is enough fixed-length buffer available */ - if(NULL == (vlen_bufsize->fl_tbuf = H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->fl_tbuf, H5T_get_size(dt)))) + if (NULL == (vlen_bufsize->common.fl_tbuf = + H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->common.fl_tbuf, H5T_get_size(dt)))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ - if(H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + if (H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, vlen_bufsize->fl_tbuf) < 0) + if (H5VL_dataset_read(vlen_bufsize->dset_vol_obj, type_id, vlen_bufsize->mspace_id, + vlen_bufsize->fspace_id, vlen_bufsize->dxpl_id, vlen_bufsize->common.fl_tbuf, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__vlen_get_buf_size() */ +} /* end H5D__vlen_get_buf_size_gen_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5D__vlen_get_buf_size_gen + * + * Purpose: Generic routine to checks the number of bytes required to store the + * VL data from the dataset. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * Friday, December 20, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, hsize_t *size) +{ + 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 */ + char bogus; /* Bogus value to pass to H5Diterate() */ + 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 */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + if (NULL == (type = (H5T_t *)H5I_object(type_id))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not an valid datatype") + if (NULL == (space = (H5S_t *)H5I_object(space_id))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "invalid dataspace") + if (!(H5S_has_extent(space))) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "dataspace does not have extent set") + + /* Save the dataset */ + vlen_bufsize.dset_vol_obj = vol_obj; + + /* Get a copy of the dataset's dataspace */ + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &vlen_bufsize.fspace_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace") + if (NULL == (vlen_bufsize.fspace = (H5S_t *)H5I_object(vlen_bufsize.fspace_id))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Create a scalar for the memory dataspace */ + if (NULL == (mspace = H5S_create(H5S_SCALAR))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create dataspace") + if ((vlen_bufsize.mspace_id = H5I_register(H5I_DATASPACE, mspace, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") + + /* Grab the temporary buffers required */ + if (NULL == (vlen_bufsize.common.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, H5T_get_size(type)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "no temporary buffers available") + if (NULL == (vlen_bufsize.common.vl_tbuf = H5FL_BLK_MALLOC(vlen_vl_buf, (size_t)1))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "no temporary buffers available") + vlen_bufsize.common.vl_tbuf_size = 1; + + /* Set the VL allocation callbacks on a DXPL */ + if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(H5P_DATASET_XFER_DEFAULT))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get default DXPL") + if ((vlen_bufsize.dxpl_id = H5P_copy_plist(dxpl, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy property list"); + if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(vlen_bufsize.dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get copied DXPL") + if (H5P_set_vlen_mem_manager(dxpl, H5D__vlen_get_buf_size_alloc, &vlen_bufsize.common, NULL, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VL data allocation routine on DXPL") + + /* Set the initial number of bytes required */ + vlen_bufsize.common.size = 0; + + /* Call H5S_select_iterate with args, etc. */ + dset_op.op_type = H5S_SEL_ITER_OP_APP; + dset_op.u.app_op.op = H5D__vlen_get_buf_size_gen_cb; + dset_op.u.app_op.type_id = type_id; + + ret_value = H5S_select_iterate(&bogus, type, space, &dset_op, &vlen_bufsize); + + /* Get the size if we succeeded */ + if (ret_value >= 0) + *size = vlen_bufsize.common.size; + +done: + if (vlen_bufsize.fspace_id >= 0) { + if (H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") + vlen_bufsize.fspace = NULL; + } /* end if */ + if (vlen_bufsize.fspace && H5S_close(vlen_bufsize.fspace) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + if (vlen_bufsize.mspace_id >= 0) { + if (H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") + mspace = NULL; + } /* end if */ + if (mspace && H5S_close(mspace) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + if (vlen_bufsize.common.fl_tbuf != NULL) + vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); + if (vlen_bufsize.common.vl_tbuf != NULL) + vlen_bufsize.common.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.common.vl_tbuf); + if (vlen_bufsize.dxpl_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(vlen_bufsize.dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close property list") + dxpl = NULL; + } /* end if */ + if (dxpl && H5P_close(dxpl) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release DXPL") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__vlen_get_buf_size_gen() */ - /*------------------------------------------------------------------------- * Function: H5D__check_filters * @@ -2732,13 +2956,13 @@ H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ -herr_t +static herr_t H5D__check_filters(H5D_t *dataset) { - H5O_fill_t *fill; /* Dataset's fill value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill; /* Dataset's fill value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Check args */ HDassert(dataset); @@ -2749,31 +2973,30 @@ H5D__check_filters(H5D_t *dataset) * that requires writing on an extend. */ fill = &dataset->shared->dcpl_cache.fill; - if(!dataset->shared->checked_filters) { - H5D_fill_value_t fill_status; /* Whether the fill value is defined */ + if (!dataset->shared->checked_filters) { + H5D_fill_value_t fill_status; /* Whether the fill value is defined */ /* Retrieve the "defined" status of the fill value */ - if(H5P_is_fill_value_defined(fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(fill, &fill_status) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.") /* See if we can check the filter status */ - if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { - if(fill->fill_time == H5D_FILL_TIME_ALLOC || - (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) { + if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { + if (fill->fill_time == H5D_FILL_TIME_ALLOC || + (fill->fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED)) { /* Filters must have encoding enabled. Ensure that all filters can be applied */ - if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) + if (H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__check_filters() */ - /*------------------------------------------------------------------------- * Function: H5D__set_extent * @@ -2786,11 +3009,11 @@ H5D__check_filters(H5D_t *dataset) herr_t H5D__set_extent(H5D_t *dset, const hsize_t *size) { - hsize_t curr_dims[H5S_MAX_RANK]; /* Current dimension sizes */ - htri_t changed; /* Whether the dataspace changed size */ - size_t u, v; /* Local index variable */ - unsigned dim_idx; /* Dimension index */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t curr_dims[H5S_MAX_RANK]; /* Current dimension sizes */ + htri_t changed; /* Whether the dataspace changed size */ + size_t u, v; /* Local index variable */ + unsigned dim_idx; /* Dimension index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -2799,17 +3022,18 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) HDassert(size); /* Check if we are allowed to modify this file */ - if(0 == (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") - /* Check if we are allowed to modify the space; only datasets with chunked and external storage are allowed to be modified */ - if(H5D_COMPACT == dset->shared->layout.type) + /* Check if we are allowed to modify the space; only datasets with chunked and external storage are + * allowed to be modified */ + if (H5D_COMPACT == dset->shared->layout.type) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataset has compact storage") - if(H5D_CONTIGUOUS == dset->shared->layout.type && 0 == dset->shared->dcpl_cache.efl.nused) + if (H5D_CONTIGUOUS == dset->shared->layout.type && 0 == dset->shared->dcpl_cache.efl.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "dataset has contiguous storage") /* Check if the filters in the DCPL will need to encode, and if so, can they? */ - if(H5D__check_filters(dset) < 0) + if (H5D__check_filters(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't apply filters") /* Keep the current dataspace dimensions for later */ @@ -2817,61 +3041,63 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) H5MM_memcpy(curr_dims, dset->shared->curr_dims, H5S_MAX_RANK * sizeof(curr_dims[0])); /* Modify the size of the dataspace */ - if((changed = H5S_set_extent(dset->shared->space, size)) < 0) + if ((changed = H5S_set_extent(dset->shared->space, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Don't bother updating things, unless they've changed */ - if(changed) { - hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */ - hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */ - hbool_t update_chunks = FALSE; /* Flag to indicate chunk cache update is needed */ + if (changed) { + hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */ + hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */ + hbool_t update_chunks = FALSE; /* Flag to indicate chunk cache update is needed */ /* Determine if we are shrinking and/or expanding any dimensions */ - for(dim_idx = 0; dim_idx < dset->shared->ndims; dim_idx++) { + for (dim_idx = 0; dim_idx < dset->shared->ndims; dim_idx++) { /* Check for various status changes */ - if(size[dim_idx] < curr_dims[dim_idx]) + if (size[dim_idx] < curr_dims[dim_idx]) shrink = TRUE; - if(size[dim_idx] > curr_dims[dim_idx]) + if (size[dim_idx] > curr_dims[dim_idx]) expand = TRUE; /* Chunked storage specific checks */ - if(H5D_CHUNKED == dset->shared->layout.type && dset->shared->ndims > 1) { - hsize_t scaled; /* Scaled value */ + if (H5D_CHUNKED == dset->shared->layout.type && dset->shared->ndims > 1) { + hsize_t scaled; /* Scaled value */ /* Compute the scaled dimension size value */ - if(dset->shared->layout.u.chunk.dim[dim_idx] == 0) + if (dset->shared->layout.u.chunk.dim[dim_idx] == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk size must be > 0, dim = %u ", dim_idx) scaled = size[dim_idx] / dset->shared->layout.u.chunk.dim[dim_idx]; /* Check if scaled dimension size changed */ - if(scaled != dset->shared->cache.chunk.scaled_dims[dim_idx]) { - hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ + if (scaled != dset->shared->cache.chunk.scaled_dims[dim_idx]) { + hsize_t scaled_power2up; /* Scaled value, rounded to next power of 2 */ /* Update the scaled dimension size value for the current dimension */ dset->shared->cache.chunk.scaled_dims[dim_idx] = scaled; /* Check if algorithm for computing hash values will change */ - if((scaled > dset->shared->cache.chunk.nslots && - dset->shared->cache.chunk.scaled_dims[dim_idx] <= dset->shared->cache.chunk.nslots) - || (scaled <= dset->shared->cache.chunk.nslots && - dset->shared->cache.chunk.scaled_dims[dim_idx] > dset->shared->cache.chunk.nslots)) + if ((scaled > dset->shared->cache.chunk.nslots && + dset->shared->cache.chunk.scaled_dims[dim_idx] <= + dset->shared->cache.chunk.nslots) || + (scaled <= dset->shared->cache.chunk.nslots && + dset->shared->cache.chunk.scaled_dims[dim_idx] > dset->shared->cache.chunk.nslots)) update_chunks = TRUE; - if(!(scaled_power2up = H5VM_power2up(scaled))) + if (!(scaled_power2up = H5VM_power2up(scaled))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") /* Check if the number of bits required to encode the scaled size value changed */ - if(dset->shared->cache.chunk.scaled_power2up[dim_idx] != scaled_power2up) { + if (dset->shared->cache.chunk.scaled_power2up[dim_idx] != scaled_power2up) { /* Update the 'power2up' & 'encode_bits' values for the current dimension */ dset->shared->cache.chunk.scaled_power2up[dim_idx] = scaled_power2up; - dset->shared->cache.chunk.scaled_encode_bits[dim_idx] = H5VM_log2_gen(scaled_power2up); + dset->shared->cache.chunk.scaled_encode_bits[dim_idx] = + H5VM_log2_gen(scaled_power2up); /* Indicate that the cached chunk indices need to be updated */ update_chunks = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Update the cached copy of the dataset's dimensions */ dset->shared->curr_dims[dim_idx] = size[dim_idx]; @@ -2882,34 +3108,38 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) *------------------------------------------------------------------------- */ /* Update the index values for the cached chunks for this dataset */ - if(H5D_CHUNKED == dset->shared->layout.type) { + if (H5D_CHUNKED == dset->shared->layout.type) { /* Set the cached chunk info */ - if(H5D__chunk_set_info(dset) < 0) + if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks") /* Check if updating the chunk cache indices is necessary */ - if(update_chunks) + if (update_chunks) /* Update the chunk cache indices */ - if(H5D__chunk_update_cache(dset) < 0) + if (H5D__chunk_update_cache(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") } /* end if */ /* Operations for virtual datasets */ - if(H5D_VIRTUAL == dset->shared->layout.type) { + if (H5D_VIRTUAL == dset->shared->layout.type) { /* Check that the dimensions of the VDS are large enough */ - if(H5D_virtual_check_min_dims(dset) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + if (H5D_virtual_check_min_dims(dset) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions " + "in all selections") /* Patch the virtual selection dataspaces */ - for(u = 0; u < dset->shared->layout.storage.u.virt.list_nused; u++) { + for (u = 0; u < dset->shared->layout.storage.u.virt.list_nused; u++) { /* Patch extent */ - if(H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].source_dset.virtual_select, size) < 0) + if (H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].source_dset.virtual_select, + size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") dset->shared->layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; /* Patch sub-source datasets */ - for(v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nalloc; v++) - if(H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].sub_dset[v].virtual_select, size) < 0) + for (v = 0; v < dset->shared->layout.storage.u.virt.list[u].sub_dset_nused; v++) + if (H5S_set_extent(dset->shared->layout.storage.u.virt.list[u].sub_dset[v].virtual_select, + size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end for */ @@ -2919,12 +3149,12 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) } /* end if */ /* Allocate space for the new parts of the dataset, if appropriate */ - if(expand && dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + if (expand && dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY) { H5D_io_info_t io_info; io_info.dset = dset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_EXTEND, FALSE, curr_dims) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_EXTEND, FALSE, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset storage") } /*------------------------------------------------------------------------- @@ -2933,23 +3163,25 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) * and if the chunks are written *------------------------------------------------------------------------- */ - if(H5D_CHUNKED == dset->shared->layout.type) { - if(shrink && ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage) - || (dset->shared->layout.ops->is_data_cached && (*dset->shared->layout.ops->is_data_cached)(dset->shared)))) + if (H5D_CHUNKED == dset->shared->layout.type) { + if (shrink && ((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage) || + (dset->shared->layout.ops->is_data_cached && + (*dset->shared->layout.ops->is_data_cached)(dset->shared)))) /* Remove excess chunks */ - if(H5D__chunk_prune_by_extent(dset, curr_dims) < 0) + if (H5D__chunk_prune_by_extent(dset, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks") /* Update chunks that are no longer edge chunks as a result of * expansion */ - if(expand && (dset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) - && (dset->shared->dcpl_cache.pline.nused > 0)) - if(H5D__chunk_update_old_edge_chunks(dset, curr_dims) < 0) + if (expand && + (dset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && + (dset->shared->dcpl_cache.pline.nused > 0)) + if (H5D__chunk_update_old_edge_chunks(dset, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to do update old edge chunks") } /* end if */ /* Mark the dataspace as dirty, for later writing to the file */ - if(H5D__mark(dset, H5D_MARK_SPACE) < 0) + if (H5D__mark(dset, H5D_MARK_SPACE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ @@ -2957,7 +3189,6 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__set_extent() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_sieve_buf * @@ -2970,7 +3201,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) herr_t H5D__flush_sieve_buf(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2978,11 +3209,13 @@ H5D__flush_sieve_buf(H5D_t *dataset) HDassert(dataset); /* Flush the raw data buffer, if we have a dirty one */ - if(dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { - HDassert(dataset->shared->layout.type != H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ + if (dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { + HDassert(dataset->shared->layout.type != + H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ /* Write dirty data sieve buffer to file */ - if(H5F_block_write(dataset->oloc.file, H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, + if (H5F_shared_block_write( + H5F_SHARED(dataset->oloc.file), H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, dataset->shared->cache.contig.sieve_size, dataset->shared->cache.contig.sieve_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") @@ -2994,7 +3227,6 @@ H5D__flush_sieve_buf(H5D_t *dataset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush_sieve_buf() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_real * @@ -3007,7 +3239,7 @@ H5D__flush_sieve_buf(H5D_t *dataset) herr_t H5D__flush_real(H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) @@ -3016,16 +3248,15 @@ H5D__flush_real(H5D_t *dataset) HDassert(dataset->shared); /* Avoid flushing the dataset (again) if it's closing */ - if(!dataset->shared->closing) + if (!dataset->shared->closing) /* Flush cached raw data for each kind of dataset layout */ - if(dataset->shared->layout.ops->flush && (dataset->shared->layout.ops->flush)(dataset) < 0) + if (dataset->shared->layout.ops->flush && (dataset->shared->layout.ops->flush)(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush raw data") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__flush_real() */ - /*------------------------------------------------------------------------- * Function: H5D__flush * @@ -3038,7 +3269,7 @@ H5D__flush_real(H5D_t *dataset) herr_t H5D__flush(H5D_t *dset, hid_t dset_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3047,18 +3278,17 @@ H5D__flush(H5D_t *dset, hid_t dset_id) HDassert(dset->shared); /* Flush any dataset information still cached in memory */ - if(H5D__flush_real(dset) < 0) + if (H5D__flush_real(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush cached dataset info") /* Flush object's metadata to file */ - if(H5O_flush_common(&dset->oloc, dset_id) < 0) + if (H5O_flush_common(&dset->oloc, dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset and object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush() */ - /*------------------------------------------------------------------------- * Function: H5D__format_convert * @@ -3072,81 +3302,83 @@ H5D__flush(H5D_t *dset, hid_t dset_id) herr_t 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) /* Check args */ HDassert(dataset); - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CHUNKED: HDassert(dataset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE); - if(NULL == (newlayout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if (NULL == (newlayout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer") /* Set up the current index info */ - idx_info.f = dataset->oloc.file; - idx_info.pline = &dataset->shared->dcpl_cache.pline; - idx_info.layout = &dataset->shared->layout.u.chunk; + idx_info.f = dataset->oloc.file; + idx_info.pline = &dataset->shared->dcpl_cache.pline; + idx_info.layout = &dataset->shared->layout.u.chunk; idx_info.storage = &dataset->shared->layout.storage.u.chunk; /* Copy the current layout info to the new layout */ H5MM_memcpy(newlayout, &dataset->shared->layout, sizeof(H5O_layout_t)); /* Set up info for version 1 B-tree in the new layout */ - newlayout->version = H5O_LAYOUT_VERSION_3; - newlayout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - newlayout->storage.u.chunk.idx_addr = HADDR_UNDEF; - newlayout->storage.u.chunk.ops = H5D_COPS_BTREE; + newlayout->version = H5O_LAYOUT_VERSION_3; + newlayout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; + newlayout->storage.u.chunk.idx_addr = HADDR_UNDEF; + newlayout->storage.u.chunk.ops = H5D_COPS_BTREE; newlayout->storage.u.chunk.u.btree.shared = NULL; /* Set up the index info to version 1 B-tree */ - new_idx_info.f = dataset->oloc.file; - new_idx_info.pline = &dataset->shared->dcpl_cache.pline; - new_idx_info.layout = &(newlayout->u).chunk; + new_idx_info.f = dataset->oloc.file; + new_idx_info.pline = &dataset->shared->dcpl_cache.pline; + new_idx_info.layout = &(newlayout->u).chunk; new_idx_info.storage = &(newlayout->storage).u.chunk; /* Initialize version 1 B-tree */ - if(new_idx_info.storage->ops->init && (new_idx_info.storage->ops->init)(&new_idx_info, dataset->shared->space, dataset->oloc.addr) < 0) + if (new_idx_info.storage->ops->init && + (new_idx_info.storage->ops->init)(&new_idx_info, dataset->shared->space, dataset->oloc.addr) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") init_new_index = TRUE; /* If the current chunk index exists */ - if(H5F_addr_defined(idx_info.storage->idx_addr)) { + if (H5F_addr_defined(idx_info.storage->idx_addr)) { /* Create v1 B-tree chunk index */ - if((new_idx_info.storage->ops->create)(&new_idx_info) < 0) + if ((new_idx_info.storage->ops->create)(&new_idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") /* Iterate over the chunks in the current index and insert the chunk addresses * into the version 1 B-tree chunk index */ - if(H5D__chunk_format_convert(dataset, &idx_info, &new_idx_info) < 0) + if (H5D__chunk_format_convert(dataset, &idx_info, &new_idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate/convert chunk index") } /* end if */ /* Delete the old "current" layout message */ - if(H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) + if (H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message") delete_old_layout = TRUE; /* Append the new layout message to the object header */ - if(H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, newlayout) < 0) + if (H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, newlayout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout header message") add_new_layout = TRUE; /* Release the old (current) chunk index */ - if(idx_info.storage->ops->dest && (idx_info.storage->ops->dest)(&idx_info) < 0) + if (idx_info.storage->ops->dest && (idx_info.storage->ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") /* Copy the new layout to the dataset's layout */ @@ -3158,7 +3390,8 @@ H5D__format_convert(H5D_t *dataset) case H5D_COMPACT: HDassert(dataset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT); dataset->shared->layout.version = H5O_LAYOUT_VERSION_DEFAULT; - if(H5O_msg_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dataset->shared->layout)) < 0) + if (H5O_msg_write(&(dataset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, + &(dataset->shared->layout)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") break; @@ -3174,42 +3407,43 @@ H5D__format_convert(H5D_t *dataset) } /* end switch */ done: - if(ret_value < 0 && dataset->shared->layout.type == H5D_CHUNKED) { + if (ret_value < 0 && dataset->shared->layout.type == H5D_CHUNKED) { /* Remove new layout message */ - if(add_new_layout) - if(H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) + if (add_new_layout) + if (H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message") /* Add back old layout message */ - if(delete_old_layout) - if(H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &dataset->shared->layout) < 0) + if (delete_old_layout) + if (H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &dataset->shared->layout) < + 0) HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to add layout header message") /* Clean up v1 b-tree chunk index */ - if(init_new_index) { - if(H5F_addr_defined(new_idx_info.storage->idx_addr)) { + if (init_new_index) { + if (H5F_addr_defined(new_idx_info.storage->idx_addr)) { /* Check for valid address i.e. tag */ - if(!H5F_addr_defined(dataset->oloc.addr)) + if (!H5F_addr_defined(dataset->oloc.addr)) HDONE_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "address undefined") /* Expunge from cache all v1 B-tree type entries associated with tag */ - if(H5AC_expunge_tag_type_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_BT_ID, H5AC__NO_FLAGS_SET)) + if (H5AC_expunge_tag_type_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_BT_ID, + H5AC__NO_FLAGS_SET)) HDONE_ERROR(H5E_DATASET, H5E_CANTEXPUNGE, FAIL, "unable to expunge index metadata") } /* end if */ /* Delete v1 B-tree chunk index */ - if(new_idx_info.storage->ops->dest && (new_idx_info.storage->ops->dest)(&new_idx_info) < 0) + if (new_idx_info.storage->ops->dest && (new_idx_info.storage->ops->dest)(&new_idx_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") } /* end if */ - } /* end if */ + } /* end if */ - if(newlayout != NULL) + if (newlayout != NULL) newlayout = (H5O_layout_t *)H5MM_xfree(newlayout); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__format_convert() */ - /*------------------------------------------------------------------------- * Function: H5D__mark * @@ -3222,8 +3456,8 @@ H5D__format_convert(H5D_t *dataset) herr_t H5D__mark(const H5D_t *dataset, unsigned flags) { - H5O_t *oh = NULL; /* Pointer to dataset's object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Pointer to dataset's object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3232,16 +3466,16 @@ H5D__mark(const H5D_t *dataset, unsigned flags) HDassert(!(flags & (unsigned)~(H5D_MARK_SPACE | H5D_MARK_LAYOUT))); /* Mark aspects of the dataset as dirty */ - if(flags) { - unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */ + if (flags) { + unsigned update_flags = H5O_UPDATE_TIME; /* Modification time flag */ /* Pin the object header */ - if(NULL == (oh = H5O_pin(&dataset->oloc))) + if (NULL == (oh = H5O_pin(&dataset->oloc))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPIN, FAIL, "unable to pin dataset object header") /* Update the layout on disk, if it's been changed */ - if(flags & H5D_MARK_LAYOUT) { - if(H5D__layout_oh_write(dataset, oh, update_flags) < 0) + if (flags & H5D_MARK_LAYOUT) { + if (H5D__layout_oh_write(dataset, oh, update_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout info") /* Reset the "update the modification time" flag, so we only do it once */ @@ -3249,8 +3483,8 @@ H5D__mark(const H5D_t *dataset, unsigned flags) } /* end if */ /* Update the dataspace on disk, if it's been changed */ - if(flags & H5D_MARK_SPACE) { - if(H5S_write(dataset->oloc.file, oh, update_flags, dataset->shared->space) < 0) + if (flags & H5D_MARK_SPACE) { + if (H5S_write(dataset->oloc.file, oh, update_flags, dataset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Reset the "update the modification time" flag, so we only do it once */ @@ -3263,14 +3497,13 @@ H5D__mark(const H5D_t *dataset, unsigned flags) done: /* Release pointer to object header */ - if(oh != NULL) - if(H5O_unpin(oh) < 0) + if (oh != NULL) + if (H5O_unpin(oh) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mark() */ - /*------------------------------------------------------------------------- * Function: H5D__flush_all_cb * @@ -3283,9 +3516,9 @@ H5D__mark(const H5D_t *dataset, unsigned flags) static int H5D__flush_all_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) { - H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -3294,16 +3527,15 @@ H5D__flush_all_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) HDassert(f); /* Check for dataset in same file */ - if(f == dataset->oloc.file) + if (f == dataset->oloc.file) /* Flush the dataset's information */ - if(H5D__flush_real(dataset) < 0) + if (H5D__flush_real(dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__flush_all_cb() */ - /*------------------------------------------------------------------------- * Function: H5D_flush_all * @@ -3314,9 +3546,9 @@ H5D__flush_all_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5D_flush_all(const H5F_t *f) +H5D_flush_all(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3324,14 +3556,13 @@ H5D_flush_all(const H5F_t *f) HDassert(f); /* Iterate over all the open datasets */ - if(H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0) /* Casting away const OK -QAK */ + if (H5I_iterate(H5I_DATASET, H5D__flush_all_cb, f, FALSE) < 0) /* Casting away const OK -QAK */ HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_flush_all() */ - /*------------------------------------------------------------------------- * Function: H5D_get_create_plist * @@ -3346,37 +3577,37 @@ H5D_flush_all(const H5F_t *f) hid_t H5D_get_create_plist(const H5D_t *dset) { - H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ - H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ - H5O_layout_t copied_layout; /* Layout to tweak */ - H5O_fill_t copied_fill; /* Fill value to tweak */ - H5O_efl_t copied_efl; /* External file list to tweak */ - hid_t new_dcpl_id = FAIL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ + H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ + H5O_layout_t copied_layout; /* Layout to tweak */ + H5O_fill_t copied_fill; /* Fill value to tweak */ + H5O_efl_t copied_efl; /* External file list to tweak */ + hid_t new_dcpl_id = FAIL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) + if (NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ - if((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0) + if ((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&dset->oloc, new_plist) < 0) + if (H5O_get_create_plist(&dset->oloc, new_plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object creation info") /* Get the layout property */ - if(H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if (H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout") /* Reset layout values set when dataset is created */ copied_layout.ops = NULL; - switch(copied_layout.type) { + switch (copied_layout.type) { case H5D_COMPACT: copied_layout.storage.u.compact.buf = H5MM_xfree(copied_layout.storage.u.compact.buf); HDmemset(&copied_layout.storage.u.compact, 0, sizeof(copied_layout.storage.u.compact)); @@ -3392,10 +3623,11 @@ H5D_get_create_plist(const H5D_t *dset) copied_layout.u.chunk.size = 0; /* Reset index info, if the chunk ops are set */ - if(copied_layout.storage.u.chunk.ops) + if (copied_layout.storage.u.chunk.ops) /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") + if (H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to reset chunked storage index in dest") /* Reset chunk index ops */ copied_layout.storage.u.chunk.ops = NULL; @@ -3403,7 +3635,7 @@ H5D_get_create_plist(const H5D_t *dset) case H5D_VIRTUAL: copied_layout.storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - copied_layout.storage.u.virt.serial_list_hobjid.idx = 0; + copied_layout.storage.u.virt.serial_list_hobjid.idx = 0; break; case H5D_LAYOUT_ERROR: @@ -3413,102 +3645,103 @@ H5D_get_create_plist(const H5D_t *dset) } /* end switch */ /* Set back the (possibly modified) layout property to property list */ - if(H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if (H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set layout") /* Get the fill value property */ - if(H5P_peek(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + if (H5P_peek(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value") /* Check if there is a fill value, but no type yet */ - if(copied_fill.buf != NULL && copied_fill.type == NULL) { - H5T_path_t *tpath; /* Conversion information*/ + if (copied_fill.buf != NULL && copied_fill.type == NULL) { + H5T_path_t *tpath; /* Conversion information*/ /* Copy the dataset type into the fill value message */ - if(NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) + if (NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset datatype for fill value") /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") + if (NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type))) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest data types") /* Convert disk form of fill value into memory form */ - if(!H5T_path_noop(tpath)) { - hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ - size_t bkg_size; /* Size of background buffer */ + if (!H5T_path_noop(tpath)) { + hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + size_t bkg_size; /* Size of background buffer */ /* Wrap copies of types to convert */ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(copied_fill.type, H5T_COPY_TRANSIENT), FALSE); - if(dst_id < 0) + if (dst_id < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE); - if(src_id < 0) { + if (src_id < 0) { H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_GET_SIZE(copied_fill.type), H5T_GET_SIZE(dset->shared->type)); - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") } /* end if */ /* Convert fill value */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf) < 0) { + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, + bkg_buf) < 0) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ /* Release local resources */ - if(H5I_dec_ref(src_id) < 0) + if (H5I_dec_ref(src_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(H5I_dec_ref(dst_id) < 0) + if (H5I_dec_ref(dst_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ + } /* end if */ /* Set back the (possibly modified) fill value property to property list */ - if(H5P_poke(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + if (H5P_poke(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set fill value") /* Get the fill value property */ - if(H5P_peek(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + if (H5P_peek(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get external file list") /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ - if(copied_efl.slot) { + if (copied_efl.slot) { unsigned u; copied_efl.heap_addr = HADDR_UNDEF; - for(u = 0; u < copied_efl.nused; u++) + for (u = 0; u < copied_efl.nused; u++) copied_efl.slot[u].name_offset = 0; } /* end if */ /* Set back the (possibly modified) external file list property to property list */ - if(H5P_poke(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + if (H5P_poke(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set external file list") /* Set the return value */ ret_value = new_dcpl_id; done: - if(ret_value < 0) - if(new_dcpl_id > 0) - if(H5I_dec_app_ref(new_dcpl_id) < 0) + if (ret_value < 0) + if (new_dcpl_id > 0) + if (H5I_dec_app_ref(new_dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5D_get_access_plist * @@ -3522,90 +3755,92 @@ 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 */ - hid_t new_dapl_id = FAIL; - hid_t ret_value = FAIL; + 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 */ + hid_t new_dapl_id = FAIL; + hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT /* Make a copy of the dataset's dataset access property list */ - if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(dset->shared->dapl_id))) + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(dset->shared->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") - if((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) + if ((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy dataset access property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* If the dataset is chunked then copy the rdcc & append flush parameters. * Otherwise, use the default values. */ - if(dset->shared->layout.type == H5D_CHUNKED) { - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0) + if (dset->shared->layout.type == H5D_CHUNKED) { + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") - if(H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes_max)) < 0) + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes_max)) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") - if(H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0) + if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") - if(H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &dset->shared->append_flush) < 0) + if (H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &dset->shared->append_flush) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set append flush property") - } else { + } + else { /* Get the default FAPL */ - if(NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) + if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_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) - 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_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) - 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_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) - 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_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") /* Set the append flush property to its default value */ - if(H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &def_append_flush_info) < 0) + if (H5P_set(new_plist, H5D_ACS_APPEND_FLUSH_NAME, &def_append_flush_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set append flush property") - }/* end if-else */ + } /* 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) + 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) + 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") /* Set the vds prefix option */ - if(H5P_set(new_plist, H5D_ACS_VDS_PREFIX_NAME, &(dset->shared->vds_prefix)) < 0) + if (H5P_set(new_plist, H5D_ACS_VDS_PREFIX_NAME, &(dset->shared->vds_prefix)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vds prefix") /* Set the external file prefix option */ - if(H5P_set(new_plist, H5D_ACS_EFILE_PREFIX_NAME, &(dset->shared->extfile_prefix)) < 0) + if (H5P_set(new_plist, H5D_ACS_EFILE_PREFIX_NAME, &(dset->shared->extfile_prefix)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file prefix") /* Set the return value */ ret_value = new_dapl_id; done: - if(ret_value < 0) - if(new_dapl_id > 0) - if(H5I_dec_app_ref(new_dapl_id) < 0) + if (ret_value < 0) + if (new_dapl_id > 0) + if (H5I_dec_app_ref(new_dapl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5D__get_space * @@ -3618,34 +3853,33 @@ H5D_get_access_plist(const H5D_t *dset) hid_t H5D__get_space(const H5D_t *dset) { - H5S_t *space = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *space = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE /* If the layout is virtual, update the extent */ - if(dset->shared->layout.type == H5D_VIRTUAL) - if(H5D__virtual_set_extent_unlim(dset) < 0) + if (dset->shared->layout.type == H5D_VIRTUAL) + if (H5D__virtual_set_extent_unlim(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update virtual dataset extent") /* Read the dataspace message and return a dataspace object */ - if(NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) + if (NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") /* Create an atom */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: - if(ret_value < 0) - if(space != NULL) - if(H5S_close(space) < 0) + if (ret_value < 0) + if (space != NULL) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_space() */ - /*------------------------------------------------------------------------- * Function: H5D__get_type * @@ -3659,39 +3893,47 @@ H5D__get_space(const H5D_t *dset) hid_t H5D__get_type(const H5D_t *dset) { - H5T_t *dt = NULL; - hid_t ret_value = FAIL; + H5T_t *dt = NULL; + hid_t ret_value = FAIL; FUNC_ENTER_PACKAGE /* Patch the datatype's "top level" file pointer */ - if(H5T_patch_file(dset->shared->type, dset->oloc.file) < 0) + if (H5T_patch_file(dset->shared->type, dset->oloc.file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer") /* Copy the dataset's datatype */ - if(NULL == (dt = H5T_copy_reopen(dset->shared->type))) + if (NULL == (dt = H5T_copy_reopen(dset->shared->type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") /* Lock copied type */ - if(H5T_lock(dt, FALSE) < 0) + if (H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype") - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + /* Create an atom */ + 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 + * returned datatype. + */ + if ((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } /* end if */ + else if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_type() */ - /*------------------------------------------------------------------------- * Function: H5D__refresh * @@ -3703,9 +3945,9 @@ H5D__get_type(const H5D_t *dset) herr_t H5D__refresh(hid_t dset_id, H5D_t *dset) { - H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */ - hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */ + hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3714,27 +3956,26 @@ H5D__refresh(hid_t dset_id, H5D_t *dset) HDassert(dset->shared); /* If the layout is virtual... */ - if(dset->shared->layout.type == H5D_VIRTUAL) { + if (dset->shared->layout.type == H5D_VIRTUAL) { /* Hold open the source datasets' files */ - if(H5D__virtual_hold_source_dset_files(dset, &head) < 0) + if (H5D__virtual_hold_source_dset_files(dset, &head) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "unable to hold VDS source files open") virt_dsets_held = TRUE; /* Refresh source datasets for virtual dataset */ - if(H5D__virtual_refresh_source_dsets(dset) < 0) + if (H5D__virtual_refresh_source_dsets(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh VDS source datasets") } /* end if */ /* Refresh dataset object */ - if((H5O_refresh_metadata(dset_id, dset->oloc)) < 0) + if ((H5O_refresh_metadata(dset_id, dset->oloc)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh dataset") done: /* Release hold on (source) virtual datasets' files */ - if(virt_dsets_held) - if(H5D__virtual_release_source_dset_files(head) < 0) + if (virt_dsets_held) + if (H5D__virtual_release_source_dset_files(head) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't release VDS source files held open") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__refresh() */ - diff --git a/src/H5Dio.c b/src/H5Dio.c index f8303fd8a0f..355aec18d49 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,60 +15,49 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Sprivate.h" /* Dataspace */ - -#ifdef H5_HAVE_PARALLEL -/* Remove this if H5R_DATASET_REGION is no longer used in this file */ -#include "H5Rpublic.h" -#endif /*H5_HAVE_PARALLEL*/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Sprivate.h" /* Dataspace */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Setup/teardown routines */ -static herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, - hsize_t *offset_copy/*out*/); -static herr_t H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, - H5D_storage_t *store, H5D_io_info_t *io_info); -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); +static herr_t H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *store, + H5D_io_info_t *io_info); +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); #ifdef H5_HAVE_PARALLEL -static herr_t H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, - const H5S_t *file_space, const H5S_t *mem_space, const H5D_type_info_t *type_info); +static herr_t H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_space, + const H5S_t *mem_space, const H5D_type_info_t *type_info); #endif /* H5_HAVE_PARALLEL */ static herr_t H5D__typeinfo_term(const H5D_type_info_t *type_info); - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -79,23 +68,24 @@ H5FL_BLK_DEFINE(type_conv); /* Declare a free list to manage the H5D_chunk_map_t struct */ H5FL_DEFINE(H5D_chunk_map_t); - - /*------------------------------------------------------------------------- * Function: H5D__get_offset_copy * - * Purpose: Gets a copy of the user's offset array that is guaraneteed - * to be suitable for use by the library. + * Purpose: Copies an offset buffer and performs bounds checks on the + * values. + * + * This helper function ensures that the offset buffer given + * by the user is suitable for use with the rest of the library. * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy) { unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -127,7 +117,6 @@ H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_c } /* end H5D__get_offset_copy() */ - /*------------------------------------------------------------------------- * Function: H5Dread * @@ -159,49 +148,40 @@ H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_c *------------------------------------------------------------------------- */ herr_t -H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, void *buf/*out*/) +H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + void *buf /*out*/) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, - dxpl_id, buf); + H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); + + /* Check arguments */ + if (mem_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid memory dataspace ID") + if (file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file dataspace ID") /* Get dataset pointer */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* 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, "not xfer parms") - - /* Set DXPL for operation */ - H5CX_set_dxpl(dxpl_id); + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Read the data */ - if (H5D__read(dset, mem_type_id, mem_space, file_space, buf) < 0) + if ((ret_value = H5VL_dataset_read(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dread() */ - /*------------------------------------------------------------------------- * Function: H5Dread_chunk * @@ -215,23 +195,17 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, *--------------------------------------------------------------------------- */ herr_t -H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, - void *buf) +H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) { - H5D_t *dset = NULL; - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf); /* Check arguments */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if (H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") if (!offset) @@ -242,28 +216,18 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil /* 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") - - /* Set DXPL for operation */ - H5CX_set_dxpl(dxpl_id); - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + 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") /* Read the raw chunk */ - if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, + filters, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dread_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Dwrite * @@ -296,49 +260,40 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil *------------------------------------------------------------------------- */ herr_t -H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, const void *buf) +H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + const void *buf) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, - dxpl_id, buf); + H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); - /* Get dataset pointer and ensure it's associated with a file */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + /* Check arguments */ + if (mem_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid memory dataspace ID") + if (file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file dataspace ID") - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + /* Get dataset pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") /* 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, "not xfer parms") - - /* Set DXPL for operation */ - H5CX_set_dxpl(dxpl_id); + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Write the data */ - if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + if ((ret_value = H5VL_dataset_write(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dwrite() */ - /*------------------------------------------------------------------------- * Function: H5Dwrite_chunk * @@ -352,24 +307,19 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, *------------------------------------------------------------------------- */ herr_t -H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, - size_t data_size, const void *buf) +H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, + const void *buf) { - H5D_t *dset = NULL; - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); /* Check arguments */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if (H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") if (!offset) @@ -385,28 +335,18 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of /* 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") - - /* Set DXPL for operation */ - H5CX_set_dxpl(dxpl_id); - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + 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") /* Write chunk */ - if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, + offset, data_size_32, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: FUNC_LEAVE_API(ret_value) } /* end H5Dwrite_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__read * @@ -421,84 +361,85 @@ 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, const H5S_t *mem_space, const 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 */ - 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 */ - /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ - /* file_space. */ - /* */ - /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ - /* comparing the mem_space and the data_space, */ - /* and the mem_space have different rank. */ - /* */ - /* Note that if this variable is used, the */ - /* projected mem space must be discarded at the */ - /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ - hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ - char fake_char; /* Temporary variable for NULL buffer pointers */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + /* projection of the supplied mem_space to a new */ + /* dataspace with rank equal to that of */ + /* file_space. */ + /* */ + /* This field is only used if */ + /* H5S_select_shape_same() returns TRUE when */ + /* comparing the mem_space and the data_space, */ + /* and the mem_space have different rank. */ + /* */ + /* Note that if this variable is used, the */ + /* projected mem space must be discarded at the */ + /* end of the function to avoid a memory leak. */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ + hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ + char fake_char; /* Temporary variable for NULL buffer pointers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) /* check args */ HDassert(dataset && dataset->oloc.file); - if(!file_space) + if (!file_space) file_space = dataset->shared->space; - if(!mem_space) + if (!mem_space) mem_space = file_space; nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Set up datatype info for operation */ - if(H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) + 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") type_info_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Check for non-MPI-based VFD */ - if(!(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI))) { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + if (!(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI))) { + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ /* Get I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Collective access is not permissible without a MPI based VFD */ - if(io_xfer_mode == H5FD_MPIO_COLLECTIVE) + if (io_xfer_mode == H5FD_MPIO_COLLECTIVE) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based drivers only") - } /* end if */ + } /* end if */ #endif /*H5_HAVE_PARALLEL*/ /* Make certain that the number of elements in each selection is the same */ - if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") + if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "src and dest dataspaces have different number of elements selected") /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ - if(NULL == buf) { + if (NULL == buf) { /* Check for any elements selected (which is invalid) */ - if(nelmts > 0) + if (nelmts > 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ buf = &fake_char; } /* end if */ /* Make sure that both selections have their extents set */ - if(!(H5S_has_extent(file_space))) + if (!(H5S_has_extent(file_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") - if(!(H5S_has_extent(mem_space))) + if (!(H5S_has_extent(mem_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* H5S_select_shape_same() has been modified to accept topologically identical @@ -514,23 +455,23 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer as * well. */ - if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && - H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + 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. */ /* 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, (const void **)&adj_buf, type_info.dst_type_size) < 0) + 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) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); HDassert(adj_buf); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = adj_buf; - } /* end if */ - + buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */ + } /* end if */ /* Retrieve dataset properties */ /* */ @@ -541,26 +482,30 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * fill time is NEVER, there is no way to tell whether part of data * has been overwritten. So just proceed in reading. */ - if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*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))) { - H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ + if (nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && + !(*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))) { + H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ /* Retrieve dataset's fill-value properties */ - if(H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Should be impossible, but check anyway... */ - if(fill_status == H5D_FILL_VALUE_UNDEFINED && - (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET)) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read") + if (fill_status == H5D_FILL_VALUE_UNDEFINED && + (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC || + dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET)) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, + "read failed: dataset doesn't exist, no data can be read") /* If we're never going to fill this dataset, just leave the junk in the user's buffer */ - if(dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_NEVER) + if (dataset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_NEVER) HGOTO_DONE(SUCCEED) /* Go fill the user's selection with the dataset's fill value */ - if(H5D__fill(dataset->shared->dcpl_cache.fill.buf, dataset->shared->type, buf, type_info.mem_type, mem_space) < 0) + if (H5D__fill(dataset->shared->dcpl_cache.fill.buf, dataset->shared->type, buf, type_info.mem_type, + mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed") else HGOTO_DONE(SUCCEED) @@ -568,56 +513,56 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Set up I/O operation */ io_info.op_type = H5D_IO_OP_READ; - io_info.u.rbuf = buf; - if(H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) + io_info.u.rbuf = buf; + if (H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to set up I/O operation") /* Sanity check that space is allocated, if there are elements */ - if(nelmts > 0) - 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); + if (nelmts > 0) + 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); /* Allocate the chunk map */ - if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + 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 && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if (io_info.layout_ops.io_init && + (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info") io_op_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Adjust I/O info for any parallel I/O */ - if(H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) + if (H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O") #endif /*H5_HAVE_PARALLEL*/ /* Invoke correct "high level" I/O routine */ - if((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if ((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: /* Shut down the I/O op information */ - if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) + if (io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") - if(fm) + if (fm) fm = H5FL_FREE(H5D_chunk_map_t, fm); /* Shut down datatype info for operation */ - if(type_info_init && H5D__typeinfo_term(&type_info) < 0) + if (type_info_init && H5D__typeinfo_term(&type_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") /* discard projected mem space if it was created */ - if(NULL != projected_mem_space) - if(H5S_close(projected_mem_space) < 0) + if (NULL != projected_mem_space) + if (H5S_close(projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down projected memory dataspace") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__read() */ - /*------------------------------------------------------------------------- * Function: H5D__write * @@ -632,31 +577,31 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, *------------------------------------------------------------------------- */ 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, const H5S_t *mem_space, const 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 */ - 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 */ - /* projection of the supplied mem_space to a new */ - /* dataspace with rank equal to that of */ - /* file_space. */ - /* */ - /* This field is only used if */ - /* H5S_select_shape_same() returns TRUE when */ - /* comparing the mem_space and the data_space, */ - /* and the mem_space have different rank. */ - /* */ - /* Note that if this variable is used, the */ - /* projected mem space must be discarded at the */ - /* end of the function to avoid a memory leak. */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ - hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ - char fake_char; /* Temporary variable for NULL buffer pointers */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + /* projection of the supplied mem_space to a new */ + /* dataspace with rank equal to that of */ + /* file_space. */ + /* */ + /* This field is only used if */ + /* H5S_select_shape_same() returns TRUE when */ + /* comparing the mem_space and the data_space, */ + /* and the mem_space have different rank. */ + /* */ + /* Note that if this variable is used, the */ + /* projected mem space must be discarded at the */ + /* end of the function to avoid a memory leak. */ + H5D_storage_t store; /* union of EFL and chunk pointer in file space */ + hsize_t nelmts; /* total number of elmts */ + hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ + char fake_char; /* Temporary variable for NULL buffer pointers */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dataset->oloc.addr) @@ -664,73 +609,75 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HDassert(dataset && dataset->oloc.file); /* 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) + if (!dataset->shared->checked_filters) { + if (H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") dataset->shared->checked_filters = TRUE; } /* end if */ /* Check if we are allowed to write to this file */ - if(0 == (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up datatype info for operation */ - if(H5D__typeinfo_init(dataset, mem_type_id, TRUE, &type_info) < 0) + if (H5D__typeinfo_init(dataset, mem_type_id, TRUE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") type_info_init = TRUE; /* Various MPI based checks */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)) { /* If MPI based VFD is used, no VL or region reference datatype support yet. */ /* This is because they use the global heap in the file and we don't */ /* support parallel access of that yet */ - if(H5T_is_vl_storage(type_info.mem_type) > 0) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing VL or region reference datatypes yet") + if (H5T_is_vl_storage(type_info.mem_type) > 0) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "Parallel IO does not support writing VL or region reference datatypes yet") } /* end if */ else { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ /* Get I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Collective access is not permissible without a MPI based VFD */ - if(io_xfer_mode == H5FD_MPIO_COLLECTIVE) + if (io_xfer_mode == H5FD_MPIO_COLLECTIVE) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "collective access for MPI-based driver only") - } /* end else */ + } /* end else */ #endif /*H5_HAVE_PARALLEL*/ /* Initialize dataspace information */ - if(!file_space) + if (!file_space) file_space = dataset->shared->space; - if(!mem_space) + if (!mem_space) mem_space = file_space; nelmts = H5S_GET_SELECT_NPOINTS(mem_space); /* Make certain that the number of elements in each selection is the same */ - if(nelmts != H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected") + if (nelmts != H5S_GET_SELECT_NPOINTS(file_space)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "src and dest dataspaces have different number of elements selected") /* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */ - if(NULL == buf) { + if (NULL == buf) { /* Check for any elements selected (which is invalid) */ - if(nelmts > 0) + if (nelmts > 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ buf = &fake_char; } /* end if */ /* Make sure that both selections have their extents set */ - if(!(H5S_has_extent(file_space))) + if (!(H5S_has_extent(file_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file dataspace does not have extent set") - if(!(H5S_has_extent(mem_space))) + if (!(H5S_has_extent(mem_space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "memory dataspace does not have extent set") /* H5S_select_shape_same() has been modified to accept topologically @@ -746,21 +693,22 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * Note that in general, this requires us to touch up the memory buffer * as well. */ - if(TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && - H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + 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. */ /* 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, (const void **)&adj_buf, type_info.src_type_size) < 0) + 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) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); HDassert(adj_buf); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = adj_buf; + buf = adj_buf; } /* end if */ /* Retrieve dataset properties */ @@ -768,88 +716,88 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Set up I/O operation */ io_info.op_type = H5D_IO_OP_WRITE; - io_info.u.wbuf = buf; - if(H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) + io_info.u.wbuf = buf; + if (H5D__ioinfo_init(dataset, &type_info, &store, &io_info) < 0) 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)) { - hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ - hbool_t full_overwrite; /* Whether we are over-writing all the elements */ + if (nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { + hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ + hbool_t full_overwrite; /* Whether we are over-writing all the elements */ /* Get the number of elements in file dataset's dataspace */ - if((file_nelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) + if ((file_nelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset") /* Always allow fill values to be written if the dataset has a VL datatype */ - if(H5T_detect_class(dataset->shared->type, H5T_VLEN, FALSE)) + if (H5T_detect_class(dataset->shared->type, H5T_VLEN, FALSE)) full_overwrite = FALSE; else full_overwrite = (hbool_t)((hsize_t)file_nelmts == nelmts ? TRUE : FALSE); /* Allocate storage */ - if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, full_overwrite, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, full_overwrite, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* end if */ /* Allocate the chunk map */ - if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + 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 && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if (io_info.layout_ops.io_init && + (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info") io_op_init = TRUE; #ifdef H5_HAVE_PARALLEL /* Adjust I/O info for any parallel I/O */ - if(H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) + if (H5D__ioinfo_adjust(&io_info, dataset, file_space, mem_space, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O") #endif /*H5_HAVE_PARALLEL*/ /* Invoke correct "high level" I/O routine */ - if((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) + if ((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") #ifdef OLD_WAY -/* - * This was taken out because it can be called in a parallel program with - * independent access, causing the metadata cache to get corrupted. Its been - * disabled for all types of access (serial as well as parallel) to make the - * modification time consistent for all programs. -QAK - * - * We should set a value in the dataset's shared information instead and flush - * it to the file when the dataset is being closed. -QAK - */ + /* + * This was taken out because it can be called in a parallel program with + * independent access, causing the metadata cache to get corrupted. Its been + * disabled for all types of access (serial as well as parallel) to make the + * modification time consistent for all programs. -QAK + * + * We should set a value in the dataset's shared information instead and flush + * it to the file when the dataset is being closed. -QAK + */ /* * Update modification time. We have to do this explicitly because * writing to a dataset doesn't necessarily change the object header. */ - if(H5O_touch(&(dataset->oloc), FALSE) < 0) + if (H5O_touch(&(dataset->oloc), FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time") #endif /* OLD_WAY */ done: /* Shut down the I/O op information */ - if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) + if (io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") - if(fm) + if (fm) fm = H5FL_FREE(H5D_chunk_map_t, fm); /* Shut down datatype info for operation */ - if(type_info_init && H5D__typeinfo_term(&type_info) < 0) + if (type_info_init && H5D__typeinfo_term(&type_info) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") /* discard projected mem space if it was created */ - if(NULL != projected_mem_space) - if(H5S_close(projected_mem_space) < 0) + if (NULL != projected_mem_space) + if (H5S_close(projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down projected memory dataspace") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__write() */ - /*------------------------------------------------------------------------- * Function: H5D__ioinfo_init * @@ -864,8 +812,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, *------------------------------------------------------------------------- */ static herr_t -H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, - H5D_storage_t *store, H5D_io_info_t *io_info) +H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *store, H5D_io_info_t *io_info) { FUNC_ENTER_STATIC_NOERR @@ -877,30 +824,31 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, HDassert(io_info); /* Set up "normal" I/O fields */ - io_info->dset = dset; + io_info->dset = dset; + io_info->f_sh = H5F_SHARED(dset->oloc.file); io_info->store = store; /* Set I/O operations to initial values */ io_info->layout_ops = *dset->shared->layout.ops; /* Set the "high-level" I/O operations for the dataset */ - io_info->io_ops.multi_read = dset->shared->layout.ops->ser_read; + io_info->io_ops.multi_read = dset->shared->layout.ops->ser_read; io_info->io_ops.multi_write = dset->shared->layout.ops->ser_write; /* Set the I/O operations for reading/writing single blocks on disk */ - if(type_info->is_xform_noop && type_info->is_conv_noop) { + if (type_info->is_xform_noop && type_info->is_conv_noop) { /* * If there is no data transform or type conversion then read directly into * the application's buffer. This saves at least one mem-to-mem copy. */ - io_info->io_ops.single_read = H5D__select_read; + io_info->io_ops.single_read = H5D__select_read; io_info->io_ops.single_write = H5D__select_write; } /* end if */ else { /* * This is the general case (type conversion, usually). */ - io_info->io_ops.single_read = H5D__scatgath_read; + io_info->io_ops.single_read = H5D__scatgath_read; io_info->io_ops.single_write = H5D__scatgath_write; } /* end else */ @@ -912,7 +860,6 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__ioinfo_init() */ - /*------------------------------------------------------------------------- * Function: H5D__typeinfo_init * @@ -927,13 +874,12 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ 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) +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 */ - H5Z_data_xform_t *data_transform; /* Data transform info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -942,26 +888,26 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, HDassert(dset); /* Patch the top level file pointer for dt->shared->u.vlen.f if needed */ - if(H5T_patch_vlen_file(dset->shared->type, dset->oloc.file) < 0 ) + if (H5T_patch_vlen_file(dset->shared->type, H5F_VOL_OBJ(dset->oloc.file)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch VL datatype file pointer") /* Initialize type info safely */ HDmemset(type_info, 0, sizeof(*type_info)); /* Get the memory & dataset datatypes */ - if(NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) + if (NULL == (type_info->mem_type = (const H5T_t *)H5I_object_verify(mem_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") type_info->dset_type = dset->shared->type; - if(do_write) { - src_type = type_info->mem_type; - dst_type = dset->shared->type; + if (do_write) { + src_type = type_info->mem_type; + dst_type = dset->shared->type; type_info->src_type_id = mem_type_id; type_info->dst_type_id = dset->shared->type_id; } /* end if */ else { - src_type = dset->shared->type; - dst_type = type_info->mem_type; + src_type = dset->shared->type; + dst_type = type_info->mem_type; type_info->src_type_id = dset->shared->type_id; type_info->dst_type_id = mem_type_id; } /* end else */ @@ -973,73 +919,72 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, * enough value in xfer_parms since turning off datatype conversion also * turns off background preservation. */ - if(NULL == (type_info->tpath = H5T_path_find(src_type, dst_type))) + if (NULL == (type_info->tpath = H5T_path_find(src_type, dst_type))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") /* Precompute some useful information */ type_info->src_type_size = H5T_get_size(src_type); type_info->dst_type_size = H5T_get_size(dst_type); type_info->max_type_size = MAX(type_info->src_type_size, type_info->dst_type_size); - type_info->is_conv_noop = H5T_path_noop(type_info->tpath); + type_info->is_conv_noop = H5T_path_noop(type_info->tpath); type_info->is_xform_noop = H5Z_xform_noop(data_transform); - if(type_info->is_xform_noop && type_info->is_conv_noop) { + if (type_info->is_xform_noop && type_info->is_conv_noop) { type_info->cmpd_subset = NULL; - type_info->need_bkg = H5T_BKG_NO; + type_info->need_bkg = H5T_BKG_NO; } /* end if */ else { - 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 */ + 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 */ /* Get info from API context */ - if(H5CX_get_max_temp_buf(&max_temp_buf) < 0) + if (H5CX_get_max_temp_buf(&max_temp_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve max. temp. buf size") - if(H5CX_get_tconv_buf(&tconv_buf) < 0) + if (H5CX_get_tconv_buf(&tconv_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve temp. conversion buffer pointer") - if(H5CX_get_bkgr_buf(&bkgr_buf) < 0) + if (H5CX_get_bkgr_buf(&bkgr_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve background conversion buffer pointer") - if(H5CX_get_bkgr_buf_type(&bkgr_buf_type) < 0) + if (H5CX_get_bkgr_buf_type(&bkgr_buf_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve background buffer type") /* Check if the datatypes are compound subsets of one another */ type_info->cmpd_subset = H5T_path_compound_subset(type_info->tpath); /* Check if we need a background buffer */ - if(do_write && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE)) + if (do_write && H5T_detect_class(dset->shared->type, H5T_VLEN, FALSE)) type_info->need_bkg = H5T_BKG_YES; else { - H5T_bkg_t path_bkg; /* Type conversion's background info */ + H5T_bkg_t path_bkg; /* Type conversion's background info */ - if((path_bkg = H5T_path_bkg(type_info->tpath))) { + if ((path_bkg = H5T_path_bkg(type_info->tpath))) { /* Retrieve the bkgr buffer property */ type_info->need_bkg = bkgr_buf_type; type_info->need_bkg = MAX(path_bkg, type_info->need_bkg); } /* end if */ else type_info->need_bkg = H5T_BKG_NO; /*never needed even if app says yes*/ - } /* end else */ - + } /* end else */ /* Set up datatype conversion/background buffers */ target_size = max_temp_buf; /* If the buffer is too small to hold even one element, try to make it bigger */ - if(target_size < type_info->max_type_size) { - hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ + if (target_size < type_info->max_type_size) { + hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ /* Detect if we have all default settings for buffers */ - default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == max_temp_buf) - && (NULL == tconv_buf) && (NULL == bkgr_buf)); + default_buffer_info = + (hbool_t)((H5D_TEMP_BUF_SIZE == max_temp_buf) && (NULL == tconv_buf) && (NULL == bkgr_buf)); /* Check if we are using the default buffer info */ - if(default_buffer_info) + if (default_buffer_info) /* OK to get bigger for library default settings */ target_size = type_info->max_type_size; else @@ -1051,42 +996,43 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, type_info->request_nelmts = target_size / type_info->max_type_size; /* Sanity check elements in temporary buffer */ - if(type_info->request_nelmts == 0) + if (type_info->request_nelmts == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. */ - if(NULL == (type_info->tconv_buf = (uint8_t *)tconv_buf)) { + if (NULL == (type_info->tconv_buf = (uint8_t *)tconv_buf)) { /* Allocate temporary buffer */ - if(NULL == (type_info->tconv_buf = H5FL_BLK_CALLOC(type_conv, target_size))) + if (NULL == (type_info->tconv_buf = H5FL_BLK_CALLOC(type_conv, target_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") type_info->tconv_buf_allocated = TRUE; } /* end if */ - if(type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)bkgr_buf)) { - size_t bkg_size; /* Desired background buffer size */ + if (type_info->need_bkg && NULL == (type_info->bkg_buf = (uint8_t *)bkgr_buf)) { + size_t bkg_size; /* Desired background buffer size */ /* Compute the background buffer size */ /* (don't try to use buffers smaller than the default size) */ bkg_size = type_info->request_nelmts * type_info->dst_type_size; - if(bkg_size < max_temp_buf) + if (bkg_size < max_temp_buf) bkg_size = max_temp_buf; /* Allocate background buffer */ /* (Need calloc()-like call since memory needs to be initialized) */ - if(NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") + if (NULL == (type_info->bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for background conversion") type_info->bkg_buf_allocated = TRUE; } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__typeinfo_init() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5D__ioinfo_adjust * @@ -1100,11 +1046,10 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, *------------------------------------------------------------------------- */ static herr_t -H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, - const H5S_t *file_space, const H5S_t *mem_space, - const H5D_type_info_t *type_info) +H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_space, const H5S_t *mem_space, + const H5D_type_info_t *type_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1121,34 +1066,34 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, * the DXPL (if it's non-default) was previously used in a collective * I/O operation. */ - if(!H5CX_is_def_dxpl()) { + if (!H5CX_is_def_dxpl()) { H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_NO_CHUNK_OPTIMIZATION); H5CX_set_mpio_actual_io_mode(H5D_MPIO_NO_COLLECTIVE); } /* end if */ /* Make any parallel I/O adjustments */ - if(io_info->using_mpi_vfd) { + if (io_info->using_mpi_vfd) { H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ - htri_t opt; /* Flag whether a selection is optimizable */ + htri_t opt; /* Flag whether a selection is optimizable */ /* Get the original state of parallel I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Get MPI communicator */ - if(MPI_COMM_NULL == (io_info->comm = H5F_mpi_get_comm(dset->oloc.file))) + if (MPI_COMM_NULL == (io_info->comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator") /* Check if we can set direct MPI-IO read/write functions */ - if((opt = H5D__mpio_opt_possible(io_info, file_space, mem_space, type_info)) < 0) + if ((opt = H5D__mpio_opt_possible(io_info, file_space, mem_space, type_info)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "invalid check for direct IO dataspace ") /* Check if we can use the optimized parallel I/O routines */ - if(opt == TRUE) { + if (opt == TRUE) { /* Override the I/O op pointers to the MPI-specific routines */ - io_info->io_ops.multi_read = dset->shared->layout.ops->par_read; - io_info->io_ops.multi_write = dset->shared->layout.ops->par_write; - io_info->io_ops.single_read = H5D__mpio_select_read; + io_info->io_ops.multi_read = dset->shared->layout.ops->par_read; + io_info->io_ops.multi_write = dset->shared->layout.ops->par_write; + io_info->io_ops.single_read = H5D__mpio_select_read; io_info->io_ops.single_write = H5D__mpio_select_write; } /* end if */ else { @@ -1157,41 +1102,46 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, * 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" }; + 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") + 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++) { + 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. + /* Check if there were any previous error messages included. If so, prepend a + * semicolon to separate the messages. */ - if(local_error_message_previously_written) + if (local_error_message_previously_written) HDstrncat(local_no_collective_cause_string, "; ", 2); HDstrncat(local_no_collective_cause_string, cause_strings[idx], cause_strlen); @@ -1199,44 +1149,43 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, 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 (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) + 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 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 */ /* 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 */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { /* Change the xfer_mode to independent for handling the I/O */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) + 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") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__ioinfo_adjust() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5D__typeinfo_term * @@ -1255,15 +1204,14 @@ H5D__typeinfo_term(const H5D_type_info_t *type_info) FUNC_ENTER_STATIC_NOERR /* Check for releasing datatype conversion & background buffers */ - if(type_info->tconv_buf_allocated) { + if (type_info->tconv_buf_allocated) { HDassert(type_info->tconv_buf); (void)H5FL_BLK_FREE(type_conv, type_info->tconv_buf); } /* end if */ - if(type_info->bkg_buf_allocated) { + if (type_info->bkg_buf_allocated) { HDassert(type_info->bkg_buf); (void)H5FL_BLK_FREE(type_conv, type_info->bkg_buf); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__typeinfo_term() */ - diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 2447fb6a5cb..c02b89eb018 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,56 +15,48 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLprivate.h" /* Local heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLprivate.h" /* Local heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ /* Format version bounds for layout */ const unsigned H5O_layout_ver_bounds[] = { - H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ - H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ + H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */ + H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - - /*------------------------------------------------------------------------- * Function: H5D__layout_set_io_ops * @@ -81,7 +73,7 @@ const unsigned H5O_layout_ver_bounds[] = { herr_t H5D__layout_set_io_ops(const H5D_t *dataset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -89,9 +81,9 @@ H5D__layout_set_io_ops(const H5D_t *dataset) HDassert(dataset); /* Set the I/O functions for each layout type */ - switch(dataset->shared->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: - if(dataset->shared->dcpl_cache.efl.nused > 0) + if (dataset->shared->dcpl_cache.efl.nused > 0) dataset->shared->layout.ops = H5D_LOPS_EFL; else dataset->shared->layout.ops = H5D_LOPS_CONTIG; @@ -101,7 +93,7 @@ H5D__layout_set_io_ops(const H5D_t *dataset) dataset->shared->layout.ops = H5D_LOPS_CHUNK; /* Set the chunk operations */ - switch(dataset->shared->layout.u.chunk.idx_type) { + switch (dataset->shared->layout.u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_BTREE; break; @@ -151,7 +143,6 @@ H5D__layout_set_io_ops(const H5D_t *dataset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_io_ops() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_meta_size * @@ -170,7 +161,7 @@ H5D__layout_set_io_ops(const H5D_t *dataset) size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -178,32 +169,32 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ HDassert(f); HDassert(layout); - ret_value = 1 + /* Version number */ - 1; /* layout class type */ + ret_value = 1 + /* Version number */ + 1; /* layout class type */ - switch(layout->type) { + switch (layout->type) { case H5D_COMPACT: /* This information only present in older versions of message */ /* Size of raw data */ ret_value += 2; - if(include_compact_data) + if (include_compact_data) ret_value += layout->storage.u.compact.size; /* data for compact dataset */ break; case H5D_CONTIGUOUS: /* This information only present in older versions of message */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ - ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; case H5D_CHUNKED: - if(layout->version < H5O_LAYOUT_VERSION_4) { + if (layout->version < H5O_LAYOUT_VERSION_4) { /* Number of dimensions (1 byte) */ HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); ret_value++; /* B-tree address */ - ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ /* Dimension sizes */ ret_value += layout->u.chunk.ndims * 4; @@ -226,9 +217,10 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ /* Type of chunk index */ ret_value++; - switch(layout->u.chunk.idx_type) { + switch (layout->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, 0, "v1 B-tree index type found for layout message >v3") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, 0, + "v1 B-tree index type found for layout message >v3") case H5D_CHUNK_IDX_NONE: /* nothing */ @@ -236,10 +228,10 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ case H5D_CHUNK_IDX_SINGLE: /* Possible filter information */ - if(layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - ret_value += H5F_SIZEOF_SIZE(f); /* Size of chunk (in file) */ - ret_value += 4; /* Filter mask for chunk */ - } /* end if */ + if (layout->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + ret_value += H5F_SIZEOF_SIZE(f); /* Size of chunk (in file) */ + ret_value += 4; /* Filter mask for chunk */ + } /* end if */ break; case H5D_CHUNK_IDX_FARRAY: @@ -268,8 +260,8 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ break; case H5D_VIRTUAL: - ret_value += H5F_SIZEOF_ADDR(f); /* Address of global heap */ - ret_value += 4; /* Global heap index */ + ret_value += H5F_SIZEOF_ADDR(f); /* Address of global heap */ + ret_value += 4; /* Global heap index */ break; case H5D_LAYOUT_ERROR: @@ -282,7 +274,6 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_meta_size() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_set_version * @@ -297,8 +288,8 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ herr_t H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -310,7 +301,7 @@ H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) version = MAX(layout->version, H5O_layout_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "layout version out of bounds") /* Set the message version */ @@ -320,7 +311,6 @@ H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_version() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_set_latest_indexing * @@ -334,10 +324,9 @@ H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout) *------------------------------------------------------------------------- */ herr_t -H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, - const H5D_dcpl_cache_t *dcpl_cache) +H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -347,104 +336,104 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, HDassert(dcpl_cache); /* The indexing methods only apply to chunked datasets (currently) */ - if(layout->type == H5D_CHUNKED) { - int sndims; /* Rank of dataspace */ - unsigned ndims; /* Rank of dataspace */ + if (layout->type == H5D_CHUNKED) { + int sndims; /* Rank of dataspace */ + unsigned ndims; /* Rank of dataspace */ /* Query the dimensionality of the dataspace */ - if((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) + if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "invalid dataspace rank") ndims = (unsigned)sndims; /* Avoid scalar/null dataspace */ - if(ndims > 0) { - hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ - hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ - unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ - hbool_t single = TRUE; /* Fulfill single chunk indexing */ - unsigned u; /* Local index variable */ + if (ndims > 0) { + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ + hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ + unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ + hbool_t single = TRUE; /* Fulfill single chunk indexing */ + unsigned u; /* Local index variable */ /* Query the dataspace's dimensions */ - if(H5S_get_simple_extent_dims(space, cur_dims, max_dims) < 0) + if (H5S_get_simple_extent_dims(space, cur_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace max. dimensions") /* Spin through the max. dimensions, looking for unlimited dimensions */ - for(u = 0; u < ndims; u++) { - if(max_dims[u] == H5S_UNLIMITED) + for (u = 0; u < ndims; u++) { + if (max_dims[u] == H5S_UNLIMITED) unlim_count++; - if(cur_dims[u] != max_dims[u] || cur_dims[u] != layout->u.chunk.dim[u]) + if (cur_dims[u] != max_dims[u] || cur_dims[u] != layout->u.chunk.dim[u]) single = FALSE; } /* end for */ /* Chunked datasets with unlimited dimension(s) */ - if(unlim_count) { /* dataset with unlimited dimension(s) must be chunked */ - if(1 == unlim_count) { /* Chunked dataset with only 1 unlimited dimension */ + if (unlim_count) { /* dataset with unlimited dimension(s) must be chunked */ + if (1 == unlim_count) { /* Chunked dataset with only 1 unlimited dimension */ /* Set the chunk index type to an extensible array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY; - layout->storage.u.chunk.ops = H5D_COPS_EARRAY; + layout->storage.u.chunk.ops = H5D_COPS_EARRAY; /* Set the extensible array creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.earray.cparam.max_nelmts_bits = H5D_EARRAY_MAX_NELMTS_BITS; - layout->u.chunk.u.earray.cparam.idx_blk_elmts = H5D_EARRAY_IDX_BLK_ELMTS; + layout->u.chunk.u.earray.cparam.max_nelmts_bits = H5D_EARRAY_MAX_NELMTS_BITS; + layout->u.chunk.u.earray.cparam.idx_blk_elmts = H5D_EARRAY_IDX_BLK_ELMTS; layout->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS; - layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; - layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; - } /* end if */ + layout->u.chunk.u.earray.cparam.data_blk_min_elmts = H5D_EARRAY_DATA_BLK_MIN_ELMTS; + layout->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = + H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS; + } /* end if */ else { /* Chunked dataset with > 1 unlimited dimensions */ /* Set the chunk index type to v2 B-tree */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_BT2; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_BT2; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BT2; - layout->storage.u.chunk.ops = H5D_COPS_BT2; + layout->storage.u.chunk.ops = H5D_COPS_BT2; /* Set the v2 B-tree creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.btree2.cparam.node_size = H5D_BT2_NODE_SIZE; + layout->u.chunk.u.btree2.cparam.node_size = H5D_BT2_NODE_SIZE; layout->u.chunk.u.btree2.cparam.split_percent = H5D_BT2_SPLIT_PERC; - layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; - } /* end else */ - } /* end if */ - else { /* Chunked dataset with fixed dimensions */ + layout->u.chunk.u.btree2.cparam.merge_percent = H5D_BT2_MERGE_PERC; + } /* end else */ + } /* end if */ + else { /* Chunked dataset with fixed dimensions */ /* Check for correct condition for using "single chunk" chunk index */ - if(single) { - layout->u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; + if (single) { + layout->u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_SINGLE; - layout->storage.u.chunk.ops = H5D_COPS_SINGLE; + layout->storage.u.chunk.ops = H5D_COPS_SINGLE; } /* end if */ - else if(!dcpl_cache->pline.nused && - dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { + else if (!dcpl_cache->pline.nused && dcpl_cache->fill.alloc_time == H5D_ALLOC_TIME_EARLY) { /* Set the chunk index type to "none" Index */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_NONE; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_NONE; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_NONE; - layout->storage.u.chunk.ops = H5D_COPS_NONE; + layout->storage.u.chunk.ops = H5D_COPS_NONE; } /* end else-if */ else { /* Set the chunk index type to Fixed Array */ - layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; + layout->u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; layout->storage.u.chunk.idx_type = H5D_CHUNK_IDX_FARRAY; - layout->storage.u.chunk.ops = H5D_COPS_FARRAY; + layout->storage.u.chunk.ops = H5D_COPS_FARRAY; /* Set the fixed array creation parameters */ /* (use hard-coded defaults for now, until we give applications * control over this with a property list - QAK) */ - layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; + layout->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = + H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS; } /* end else */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_latest_indexing() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_create * @@ -461,11 +450,11 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -475,20 +464,21 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) HDassert(dset); /* Set some local variables, for convenience */ - layout = &dset->shared->layout; + layout = &dset->shared->layout; fill_prop = &dset->shared->dcpl_cache.fill; /* Update the filters message, if this is a chunked dataset */ - if(layout->type == H5D_CHUNKED) { - H5O_pline_t *pline; /* Dataset's I/O pipeline information */ + if (layout->type == H5D_CHUNKED) { + H5O_pline_t *pline; /* Dataset's I/O pipeline information */ pline = &dset->shared->dcpl_cache.pline; - if(pline->nused > 0 && H5O_msg_append_oh(file, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0) + if (pline->nused > 0 && + H5O_msg_append_oh(file, oh, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ /* Initialize the layout information for the new dataset */ - if(dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dset, dapl_id) < 0) + if (dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") /* Indicate that the layout information was initialized */ @@ -498,61 +488,60 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) * Allocate storage if space allocate time is early; otherwise delay * allocation until later. */ - if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) { + if (fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) { H5D_io_info_t io_info; io_info.dset = dset; - if(H5D__alloc_storage(&io_info, H5D_ALLOC_CREATE, FALSE, NULL) < 0) + if (H5D__alloc_storage(&io_info, H5D_ALLOC_CREATE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* Update external storage message, if it's used */ - if(dset->shared->dcpl_cache.efl.nused > 0) { + 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 */ - size_t heap_size = H5HL_ALIGN(1); - size_t u; + 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; /* Determine size of heap needed to stored the file names */ - for(u = 0; u < efl->nused; ++u) + for (u = 0; u < efl->nused; ++u) heap_size += H5HL_ALIGN(HDstrlen(efl->slot[u].name) + 1); /* Create the heap for the EFL file names */ - if(H5HL_create(file, heap_size, &efl->heap_addr/*out*/) < 0) + if (H5HL_create(file, heap_size, &efl->heap_addr /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create EFL file name heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file, efl->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(file, efl->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_DATASET, H5E_CANTPROTECT, FAIL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if(UFAIL == H5HL_insert(file, heap, (size_t)1, "")) { + if (H5HL_insert(file, heap, (size_t)1, "", &name_offset) < 0) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") - } /* end if */ - - for(u = 0; u < efl->nused; ++u) { - size_t offset; /* Offset of file name in heap */ + } + for (u = 0; u < efl->nused; ++u) { /* Insert file name into heap */ - if(UFAIL == (offset = H5HL_insert(file, heap, - HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name))) { + if (H5HL_insert(file, heap, HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name, &name_offset) < + 0) { H5HL_unprotect(heap); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert file name into heap") - } /* end if */ + } /* Store EFL file name offset */ - efl->slot[u].name_offset = offset; - } /* end for */ + efl->slot[u].name_offset = name_offset; + } /* Release the heap */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to unprotect EFL file name heap") heap = NULL; /* Insert EFL message into dataset object header */ - if(H5O_msg_append_oh(file, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0) + if (H5O_msg_append_oh(file, oh, H5O_EFL_ID, H5O_MSG_FLAG_CONSTANT, 0, efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message") } /* end if */ @@ -560,34 +549,32 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) /* (Don't make layout message constant unless allocation time is early and * non-filtered and has >0 elements, since space may not be allocated -QAK) */ /* (Note: this is relying on H5D__alloc_storage not calling H5O_msg_write during dataset creation) */ - if(fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type - && !dset->shared->dcpl_cache.pline.nused - && (0 != H5S_GET_EXTENT_NPOINTS(dset->shared->space))) + if (fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY && H5D_COMPACT != layout->type && + !dset->shared->dcpl_cache.pline.nused && (0 != H5S_GET_EXTENT_NPOINTS(dset->shared->space))) layout_mesg_flags = H5O_MSG_FLAG_CONSTANT; else - layout_mesg_flags = 0; + layout_mesg_flags = 0; /* Store VDS info in global heap */ - if(H5D_VIRTUAL == layout->type) - if(H5D__virtual_store_layout(file, layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") + if (H5D_VIRTUAL == layout->type) + if (H5D__virtual_store_layout(file, layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") /* Create layout message */ - if(H5O_msg_append_oh(file, oh, H5O_LAYOUT_ID, layout_mesg_flags, 0, layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") + if (H5O_msg_append_oh(file, oh, H5O_LAYOUT_ID, layout_mesg_flags, 0, layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") done: /* Error cleanup */ - if(ret_value < 0) - if(layout_init) + if (ret_value < 0) + if (layout_init) /* Destroy any cached layout information for the dataset */ - if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) + if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__layout_oh_create() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_read * @@ -604,9 +591,9 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) 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 layout_copied = FALSE; /* Flag to indicate that layout message was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -615,15 +602,15 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) HDassert(plist); /* Get the optional filters message */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") - if(msg_exists) { + if (msg_exists) { /* Retrieve the I/O pipeline message */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline)) + 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") /* Set the I/O pipeline info in the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) + if (H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ @@ -633,20 +620,20 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) * values are copied to the dataset create plist so the user can query * them. */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) + if (NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") layout_copied = TRUE; /* Check for external file list message (which might not exist) */ - if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID)) < 0) + 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) { + if (msg_exists) { /* Retrieve the EFL message */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl)) + 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") /* Set the EFL info in the property list */ - if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0) + if (H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set external file list") /* Set the dataset's I/O operations */ @@ -657,31 +644,31 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) HDassert(dataset->shared->layout.ops); /* Initialize the layout information for the dataset */ - if(dataset->shared->layout.ops->init && (dataset->shared->layout.ops->init)(dataset->oloc.file, dataset, dapl_id) < 0) + if (dataset->shared->layout.ops->init && + (dataset->shared->layout.ops->init)(dataset->oloc.file, dataset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") /* Adjust chunk dimensions to omit datatype size (in last dimension) for creation property */ - if(H5D_CHUNKED == dataset->shared->layout.type) + if (H5D_CHUNKED == dataset->shared->layout.type) dataset->shared->layout.u.chunk.ndims--; /* Copy layout to the DCPL */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) + if (H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout") /* Set chunk sizes */ - if(H5D_CHUNKED == dataset->shared->layout.type) - if(H5D__chunk_set_sizes(dataset) < 0) + if (H5D_CHUNKED == dataset->shared->layout.type) + if (H5D__chunk_set_sizes(dataset) < 0) 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) + 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") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_read() */ - /*------------------------------------------------------------------------- * Function: H5D__layout_oh_write * @@ -698,8 +685,8 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) herr_t H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags) { - htri_t msg_exists; /* Whether the layout message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t msg_exists; /* Whether the layout message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -708,15 +695,15 @@ H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags) HDassert(oh); /* Check if the layout message has been added to the dataset's header */ - if((msg_exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + if ((msg_exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to check if layout message exists") - if(msg_exists) { + if (msg_exists) { /* Write the layout message to the dataset's header */ - if(H5O_msg_write_oh(dataset->oloc.file, oh, H5O_LAYOUT_ID, 0, update_flags, &dataset->shared->layout) < 0) + if (H5O_msg_write_oh(dataset->oloc.file, oh, H5O_LAYOUT_ID, 0, update_flags, + &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update layout message") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_write() */ - diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h index 27ccf545ff7..595c7146fd0 100644 --- a/src/H5Dmodule.h +++ b/src/H5Dmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,48 @@ * H5D package. Including this header means that the source file * is part of the H5D package. */ -#ifndef _H5Dmodule_H -#define _H5Dmodule_H +#ifndef H5Dmodule_H +#define H5Dmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5D_MODULE -#define H5_MY_PKG H5D -#define H5_MY_PKG_ERR H5E_DATASET -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5D +#define H5_MY_PKG_ERR H5E_DATASET +#define H5_MY_PKG_INIT YES -#endif /* _H5Dmodule_H */ +/**\defgroup H5D 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 + * properties. Datasets are used by other HDF5 APIs and referenced either by + * name or by a handle. Such handles can be obtained by either creating or + * opening the dataset. + * + * Typical stages in the HDF5 dataset life cycle are shown below in introductory + * examples. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet H5D_examples.c create + * + * \snippet H5D_examples.c read + *
UpdateDelete
+ * \snippet H5D_examples.c update + * + * \snippet H5D_examples.c delete + *
+ * + */ +#endif /* H5Dmodule_H */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 38a6dbdfff8..752c144f623 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,24 +25,23 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector */ #ifdef H5_HAVE_PARALLEL @@ -67,7 +66,7 @@ #define H5D_OBTAIN_ALL_CHUNK_ADDR_COL 2 /* Macros to define the default ratio of obtaining all chunk addresses for one linked-chunk IO case */ -#define H5D_ALL_CHUNK_ADDR_THRES_COL 30 +#define H5D_ALL_CHUNK_ADDR_THRES_COL 30 #define H5D_ALL_CHUNK_ADDR_THRES_COL_NUM 10000 /***** Macros for multi-chunk collective IO case. *****/ @@ -77,31 +76,29 @@ */ /* Macros to represent different IO modes(NONE, Independent or collective)for multiple chunk IO case */ -#define H5D_CHUNK_IO_MODE_COL 1 +#define H5D_CHUNK_IO_MODE_COL 1 /* Macros to represent the regularity of the selection for multiple chunk IO case. */ -#define H5D_CHUNK_SELECT_REG 1 - +#define H5D_CHUNK_SELECT_REG 1 /******************/ /* 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; + haddr_t chunk_addr; H5D_chunk_info_t chunk_info; } H5D_chunk_addr_info_t; /* Rank 0 Bcast values */ typedef enum H5D_mpio_no_rank0_bcast_cause_t { - H5D_MPIO_RANK0_BCAST = 0x00, - H5D_MPIO_RANK0_NOT_H5S_ALL = 0x01, - H5D_MPIO_RANK0_NOT_CONTIGUOUS = 0x02, - H5D_MPIO_RANK0_NOT_FIXED_SIZE = 0x04, + H5D_MPIO_RANK0_BCAST = 0x00, + H5D_MPIO_RANK0_NOT_H5S_ALL = 0x01, + H5D_MPIO_RANK0_NOT_CONTIGUOUS = 0x02, + H5D_MPIO_RANK0_NOT_FIXED_SIZE = 0x04, H5D_MPIO_RANK0_GREATER_THAN_2GB = 0x08 } H5D_mpio_no_rank0_bcast_cause_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 @@ -186,91 +183,93 @@ typedef enum H5D_mpio_no_rank0_bcast_cause_t { * 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; + 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_filtered_collective_io_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); -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); -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); -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); -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__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); +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); +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); +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); +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); -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[]); -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); + H5D_chunk_addr_info_t chunk_addr_info_array[], int many_chunk_opt); +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[]); +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); +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); + 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 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); + const H5D_io_info_t * io_info, + const H5D_type_info_t * type_info, + const H5D_chunk_map_t * fm); +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); + const void *filtered_collective_io_info_entry2); #endif - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5D__mpio_opt_possible * @@ -286,15 +285,15 @@ static int H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered *------------------------------------------------------------------------- */ 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) +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) { - H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ - unsigned local_cause[2] = {0,0}; /* [0] Local reason(s) for breaking collective mode */ - /* [1] Flag if dataset is both: H5S_ALL and small */ - unsigned global_cause[2] = {0,0}; /* Global reason(s) for breaking collective mode */ - htri_t is_vl_storage; /* Whether the dataset's datatype is stored in a variable-length form */ - htri_t ret_value = SUCCEED; /* Return value */ + H5FD_mpio_xfer_t io_xfer_mode; /* MPI I/O transfer mode */ + unsigned local_cause[2] = {0, 0}; /* [0] Local reason(s) for breaking collective mode */ + /* [1] Flag if dataset is both: H5S_ALL and small */ + unsigned global_cause[2] = {0, 0}; /* Global reason(s) for breaking collective mode */ + htri_t is_vl_storage; /* Whether the dataset's datatype is stored in a variable-length form */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -304,47 +303,46 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, HDassert(file_space); HDassert(type_info); - /* For independent I/O, get out quickly and don't try to form consensus */ - if(H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&io_xfer_mode) < 0) /* Set error flag, but keep going */ local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; - if(io_xfer_mode == H5FD_MPIO_INDEPENDENT) + if (io_xfer_mode == H5FD_MPIO_INDEPENDENT) local_cause[0] |= H5D_MPIO_SET_INDEPENDENT; /* Optimized MPI types flag must be set */ /* (based on 'HDF5_MPI_OPT_TYPES' environment variable) */ - if(!H5FD_mpi_opt_types_g) + if (!H5FD_mpi_opt_types_g) local_cause[0] |= H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED; /* Don't allow collective operations if datatype conversions need to happen */ - if(!type_info->is_conv_noop) + if (!type_info->is_conv_noop) local_cause[0] |= H5D_MPIO_DATATYPE_CONVERSION; /* Don't allow collective operations if data transform operations should occur */ - if(!type_info->is_xform_noop) + if (!type_info->is_xform_noop) local_cause[0] |= H5D_MPIO_DATA_TRANSFORMS; /* Check whether these are both simple or scalar dataspaces */ - if(!((H5S_SIMPLE == H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(mem_space)) - && (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(file_space)))) + if (!((H5S_SIMPLE == H5S_GET_EXTENT_TYPE(mem_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(mem_space)) && + (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(file_space) || H5S_SCALAR == H5S_GET_EXTENT_TYPE(file_space)))) local_cause[0] |= H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES; /* Dataset storage must be contiguous or chunked */ - if(!(io_info->dset->shared->layout.type == H5D_CONTIGUOUS || - io_info->dset->shared->layout.type == H5D_CHUNKED)) + if (!(io_info->dset->shared->layout.type == H5D_CONTIGUOUS || + io_info->dset->shared->layout.type == H5D_CHUNKED)) local_cause[0] |= H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET; /* check if external-file storage is used */ - if(io_info->dset->shared->dcpl_cache.efl.nused > 0) + if (io_info->dset->shared->dcpl_cache.efl.nused > 0) local_cause[0] |= H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET; - /* The handling of memory space is different for chunking and contiguous - * storage. For contiguous storage, mem_space and file_space won't change - * when it it is doing disk IO. For chunking storage, mem_space will - * change for different chunks. So for chunking storage, whether we can - * use collective IO will defer until each chunk IO is reached. - */ + /* The handling of memory space is different for chunking and contiguous + * storage. For contiguous storage, mem_space and file_space won't change + * when it it is doing disk IO. For chunking storage, mem_space will + * change for different chunks. So for chunking storage, whether we can + * use collective IO will defer until each chunk IO is reached. + */ #if MPI_VERSION < 3 /* @@ -352,9 +350,8 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, * 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) + 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) local_cause[0] |= H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED; #endif @@ -363,29 +360,29 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, */ /* Check to see if the process is reading the entire dataset */ - if(H5S_GET_SELECT_TYPE(file_space) != H5S_SEL_ALL) + 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 */ - else if(H5D_CONTIGUOUS != io_info->dset->shared->layout.type) + 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. */ local_cause[1] |= H5D_MPIO_RANK0_NOT_CONTIGUOUS; - else if((is_vl_storage = H5T_is_vl_storage(type_info->dset_type)) < 0) + else if ((is_vl_storage = H5T_is_vl_storage(type_info->dset_type)) < 0) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; - else if(is_vl_storage) + else if (is_vl_storage) local_cause[1] |= H5D_MPIO_RANK0_NOT_FIXED_SIZE; else { - size_t type_size; /* Size of dataset's datatype */ + size_t type_size; /* Size of dataset's datatype */ /* Retrieve the size of the dataset's datatype */ - if(0 == (type_size = H5T_GET_SIZE(type_info->dset_type))) + if (0 == (type_size = H5T_GET_SIZE(type_info->dset_type))) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; else { - hssize_t snelmts; /* [Signed] # of elements in dataset's dataspace */ + hssize_t snelmts; /* [Signed] # of elements in dataset's dataspace */ /* Retrieve the size of the dataset's datatype */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) + if ((snelmts = H5S_GET_EXTENT_NPOINTS(file_space)) < 0) local_cause[0] |= H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE; else { hsize_t dset_size; @@ -393,26 +390,27 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, /* Determine dataset size */ dset_size = ((hsize_t)snelmts) * type_size; - /* If the size of the dataset is less than 2GB then do an MPI_Bcast - * of the data from one process instead of having all the processes - * involved in the collective I/O. - */ - if(dset_size > ((hsize_t)(2.0F * H5_GB) - 1)) + /* If the size of the dataset is less than 2GB then do an MPI_Bcast + * of the data from one process instead of having all the processes + * involved in the collective I/O. + */ + if (dset_size > ((hsize_t)(2.0F * H5_GB) - 1)) local_cause[1] |= H5D_MPIO_RANK0_GREATER_THAN_2GB; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Check for independent I/O */ - if(local_cause[0] & H5D_MPIO_SET_INDEPENDENT) + if (local_cause[0] & H5D_MPIO_SET_INDEPENDENT) global_cause[0] = local_cause[0]; else { - int mpi_code; /* MPI error code */ + int mpi_code; /* MPI error code */ /* Form consensus opinion among all processes about whether to perform * collective I/O */ - if(MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_cause, &global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allreduce(local_cause, global_cause, 2, MPI_UNSIGNED, MPI_BOR, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) } /* end else */ @@ -421,12 +419,12 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, H5CX_set_mpio_global_no_coll_cause(global_cause[0]); /* Set read-with-rank0-and-bcast flag if possible */ - if(global_cause[0] == 0 && global_cause[1] == 0) { + if (global_cause[0] == 0 && global_cause[1] == 0) { H5CX_set_mpio_rank0_bcast(TRUE); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY H5CX_test_set_mpio_coll_rank0_bcast(TRUE); #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - } /* end if */ + } /* end if */ /* Set the return value, based on the global cause */ ret_value = global_cause[0] > 0 ? FALSE : TRUE; @@ -435,7 +433,6 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, FUNC_LEAVE_NOAPI(ret_value) } /* H5D__mpio_opt_possible() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_select_read * @@ -449,22 +446,24 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, */ 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, const H5S_t H5_ATTR_UNUSED *file_space, + const 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 */ + const H5D_contig_storage_t *store_contig = + &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE H5_CHECK_OVERFLOW(mpi_buf_count, hsize_t, size_t); - if(H5F_block_read(io_info->dset->oloc.file, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, io_info->u.rbuf) < 0) + if (H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, + io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "can't finish collective parallel read") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_select_read() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_select_write * @@ -478,23 +477,25 @@ 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, const H5S_t H5_ATTR_UNUSED *file_space, + const 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 */ + const H5D_contig_storage_t *store_contig = + &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE /*OKAY: CAST DISCARDS CONST QUALIFIER*/ H5_CHECK_OVERFLOW(mpi_buf_count, hsize_t, size_t); - if(H5F_block_write(io_info->dset->oloc.file, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, io_info->u.wbuf) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't finish collective parallel write") + if (H5F_shared_block_write(io_info->f_sh, H5FD_MEM_DRAW, store_contig->dset_addr, (size_t)mpi_buf_count, + io_info->u.wbuf) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't finish collective parallel write") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_select_write() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_array_gatherv * @@ -524,17 +525,18 @@ H5D__mpio_select_write(const H5D_io_info_t *io_info, const H5D_type_info_t H5_AT *------------------------------------------------------------------------- */ 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 *)) +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; + 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 @@ -547,38 +549,43 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, /* 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))) + 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 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 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)))) + 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)))) + 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. + * 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))) + 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))) + 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 */ @@ -586,26 +593,29 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, 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); + 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++) + 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); + 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))) + 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))) + 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 */ @@ -613,7 +623,7 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, HDqsort(gathered_array, gathered_array_num_entries, array_entry_size, sort_func); } /* end if */ - *_gathered_array = gathered_array; + *_gathered_array = gathered_array; *_gathered_array_num_entries = gathered_array_num_entries; done: @@ -625,7 +635,6 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_array_gatherv() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_get_sum_chunk * @@ -640,30 +649,29 @@ H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, *------------------------------------------------------------------------- */ static herr_t -H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - int *sum_chunkf) +H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, int *sum_chunkf) { - int num_chunkf; /* Number of chunks to iterate over */ + int num_chunkf; /* Number of chunks to iterate over */ size_t ori_num_chunkf; - int mpi_code; /* MPI return code */ + int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Get the number of chunks to perform I/O on */ - num_chunkf = 0; + num_chunkf = 0; ori_num_chunkf = H5SL_count(fm->sel_chunks); H5_CHECKED_ASSIGN(num_chunkf, int, ori_num_chunkf, size_t); /* Determine the summation of number of chunks for all processes */ - if(MPI_SUCCESS != (mpi_code = MPI_Allreduce(&num_chunkf, sum_chunkf, 1, MPI_INT, MPI_SUM, io_info->comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Allreduce(&num_chunkf, sum_chunkf, 1, MPI_INT, MPI_SUM, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_get_sum_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_collective_read * @@ -679,11 +687,11 @@ 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, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const 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; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -691,7 +699,7 @@ H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_ HDassert(H5FD_MPIO == H5F_DRIVER_ID(io_info->dset->oloc.file)); /* Call generic internal collective I/O routine */ - if(H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) + if (H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't finish shared collective MPI-IO") /* Set the actual I/O mode property. internal_collective_io will not break to @@ -703,7 +711,6 @@ H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_collective_read() */ - /*------------------------------------------------------------------------- * Function: H5D__contig_collective_write * @@ -719,11 +726,11 @@ 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, - H5D_chunk_map_t H5_ATTR_UNUSED *fm) + hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const 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; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -731,7 +738,7 @@ H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type HDassert(H5FD_MPIO == H5F_DRIVER_ID(io_info->dset->oloc.file)); /* Call generic internal collective I/O routine */ - if(H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) + if (H5D__inter_collective_io(io_info, type_info, file_space, mem_space) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't finish shared collective MPI-IO") /* Set the actual I/O mode property. internal_collective_io will not break to @@ -743,7 +750,6 @@ H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_collective_write() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_io * @@ -781,16 +787,15 @@ H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type *------------------------------------------------------------------------- */ 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) +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; + int io_option = H5D_MULTI_CHUNK_IO_MORE_OPT; + int sum_chunk = -1; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY - htri_t temp_not_link_io = FALSE; + htri_t temp_not_link_io = FALSE; #endif - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -805,58 +810,61 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf H5CX_set_coll_metadata_read(FALSE); /* Check the optional property list for the collective chunk IO optimization option */ - if(H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) + if (H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option") - if(H5FD_MPIO_CHUNK_ONE_IO == chunk_opt_mode) - io_option = H5D_ONE_LINK_CHUNK_IO; /*no opt*/ + if (H5FD_MPIO_CHUNK_ONE_IO == chunk_opt_mode) + io_option = H5D_ONE_LINK_CHUNK_IO; /*no opt*/ /* direct request to multi-chunk-io */ - else if(H5FD_MPIO_CHUNK_MULTI_IO == chunk_opt_mode) + else if (H5FD_MPIO_CHUNK_MULTI_IO == chunk_opt_mode) io_option = H5D_MULTI_CHUNK_IO; /* 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 */ + 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) + 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) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option threshold value") + if (H5CX_get_mpio_chunk_opt_num(&one_link_chunk_io_threshold) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "couldn't get chunk optimization option threshold value") /* step 1: choose an IO option */ - /* If the average number of chunk per process is greater than a threshold, we will do one link chunked IO. */ - if((unsigned)sum_chunk / (unsigned)mpi_size >= one_link_chunk_io_threshold) + /* If the average number of chunk per process is greater than a threshold, we will do one link chunked + * IO. */ + if ((unsigned)sum_chunk / (unsigned)mpi_size >= one_link_chunk_io_threshold) io_option = H5D_ONE_LINK_CHUNK_IO_MORE_OPT; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY else temp_not_link_io = TRUE; #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ - } /* end else */ + } /* end else */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY -{ - /*** Set collective chunk user-input optimization APIs. ***/ - if(H5D_ONE_LINK_CHUNK_IO == io_option) { - if(H5CX_test_set_mpio_coll_chunk_link_hard(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ - else if(H5D_MULTI_CHUNK_IO == io_option) { - if(H5CX_test_set_mpio_coll_chunk_multi_hard(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end else-if */ - else if(H5D_ONE_LINK_CHUNK_IO_MORE_OPT == io_option) { - if(H5CX_test_set_mpio_coll_chunk_link_num_true(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ - else if(temp_not_link_io) { - if(H5CX_test_set_mpio_coll_chunk_link_num_false(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - } /* end if */ -} + { + /*** Set collective chunk user-input optimization APIs. ***/ + if (H5D_ONE_LINK_CHUNK_IO == io_option) { + if (H5CX_test_set_mpio_coll_chunk_link_hard(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + else if (H5D_MULTI_CHUNK_IO == io_option) { + if (H5CX_test_set_mpio_coll_chunk_multi_hard(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end else-if */ + else if (H5D_ONE_LINK_CHUNK_IO_MORE_OPT == io_option) { + if (H5CX_test_set_mpio_coll_chunk_link_num_true(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + else if (temp_not_link_io) { + if (H5CX_test_set_mpio_coll_chunk_link_num_false(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + } /* end if */ + } #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* step 2: Go ahead to do IO.*/ @@ -864,37 +872,38 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf case H5D_ONE_LINK_CHUNK_IO: 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) { + 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") + 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) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish filtered linked chunk MPI-IO") + else if (H5D__link_chunk_filtered_collective_io(io_info, type_info, fm) < 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) < 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) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple filtered chunk MPI-IO") + if (io_info->dset->shared->dcpl_cache.pline.nused > 0) { + 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 /* 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) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple chunk MPI-IO") break; } /* end switch */ @@ -902,7 +911,6 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_read * @@ -918,22 +926,21 @@ 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, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Call generic selection operation */ - if(H5D__chunk_collective_io(io_info, type_info, fm) < 0) + if (H5D__chunk_collective_io(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_read() */ - /*------------------------------------------------------------------------- * Function: H5D__chunk_collective_write * @@ -949,22 +956,21 @@ 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, const H5S_t H5_ATTR_UNUSED *file_space, + const H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Call generic selection operation */ - if(H5D__chunk_collective_io(io_info, type_info, fm) < 0) + if (H5D__chunk_collective_io(io_info, type_info, fm) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_write() */ - /*------------------------------------------------------------------------- * Function: H5D__link_chunk_collective_io * @@ -983,26 +989,28 @@ 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) +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_addr_info_t *chunk_addr_info_array = NULL; - MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with seletion */ - hbool_t chunk_final_mtype_is_derived = FALSE; - MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with seletion */ - 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 = 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 mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; + MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with seletion */ + hbool_t chunk_final_mtype_is_derived = FALSE; + MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with seletion */ + 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 = + 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 mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1014,9 +1022,10 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Get the sum # of chunks, if not already available */ - if(sum_chunk < 0) { - 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 (sum_chunk < 0) { + 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"); } /* end if */ /* Retrieve total # of chunks in dataset */ @@ -1026,15 +1035,15 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ * the dataset. [This sometimes is used by developers who want the * equivalent of compressed contiguous datasets - QAK] */ - 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 */ + 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 */ /* Check for this process having selection in this chunk */ chunk_node = H5SL_first(fm->sel_chunks); - if(chunk_node == NULL) { + if (chunk_node == NULL) { /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */ fspace = mspace = NULL; @@ -1042,11 +1051,11 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ ctg_store.contig.dset_addr = 0; } /* end if */ else { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */ + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */ /* Get the chunk info, for the selection in the chunk */ - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skip list") /* Set the dataspace info for I/O */ @@ -1054,7 +1063,7 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ mspace = chunk_info->mspace; /* Look up address of chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk address") ctg_store.contig.dset_addr = udata.chunk_block.offset; } /* end else */ @@ -1063,66 +1072,72 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ io_info->store = &ctg_store; #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before inter_collective_io for total chunk = 1 \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before inter_collective_io for total chunk = 1 \n"); #endif /* Perform I/O */ - if(H5D__inter_collective_io(io_info, type_info, fspace, mspace) < 0) + if (H5D__inter_collective_io(io_info, type_info, fspace, mspace) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") } /* end if */ else { - hsize_t mpi_buf_count; /* Number of MPI types */ - size_t num_chunk; /* Number of chunks for this process */ - size_t u; /* Local index variable */ + hsize_t mpi_buf_count; /* Number of MPI types */ + size_t num_chunk; /* Number of chunks for this process */ + size_t u; /* Local index variable */ /* Get the number of chunks with a selection */ 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "total_chunks = %zu, num_chunk = %zu\n", total_chunks, num_chunk); #endif /* Set up MPI datatype for chunks selected */ - if(num_chunk) { + if (num_chunk) { /* Allocate chunking information */ - if(NULL == (chunk_addr_info_array = (H5D_chunk_addr_info_t *)H5MM_malloc(num_chunk * sizeof(H5D_chunk_addr_info_t)))) + if (NULL == (chunk_addr_info_array = + (H5D_chunk_addr_info_t *)H5MM_malloc(num_chunk * sizeof(H5D_chunk_addr_info_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk array buffer") - if(NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory datatype buffer") - if(NULL == (chunk_ftype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) + if (NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory datatype buffer") + if (NULL == (chunk_ftype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file datatype buffer") - if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc(num_chunk * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer") - if(NULL == (chunk_mem_disp_array = (MPI_Aint *)H5MM_calloc(num_chunk * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory displacement buffer") - if(NULL == (chunk_mpi_mem_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) + if (NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc(num_chunk * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk file displacement buffer") + if (NULL == (chunk_mem_disp_array = (MPI_Aint *)H5MM_calloc(num_chunk * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory displacement buffer") + if (NULL == (chunk_mpi_mem_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory counts buffer") - if(NULL == (chunk_mpi_file_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) + if (NULL == (chunk_mpi_file_counts = (int *)H5MM_calloc(num_chunk * sizeof(int)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file counts buffer") - if(NULL == (chunk_mbt_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk memory is derived datatype flags buffer") - if(NULL == (chunk_mft_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file is derived datatype flags buffer") + if (NULL == (chunk_mbt_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk memory is derived datatype flags buffer") + if (NULL == (chunk_mft_is_derived_array = (hbool_t *)H5MM_calloc(num_chunk * sizeof(hbool_t)))) + 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"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before sorting the chunk address \n"); #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) < 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"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "after sorting the chunk address \n"); #endif /* Obtain MPI derived datatype from all individual chunks */ - for(u = 0; u < num_chunk; u++) { + for (u = 0; u < num_chunk; u++) { hsize_t *permute_map = NULL; /* array that holds the mapping from the old, out-of-order displacements to the in-order displacements of the MPI datatypes of the @@ -1134,46 +1149,43 @@ if(H5DEBUG(D)) * and will be fed into the next call to H5S_mpio_space_type * where it will be freed. */ - if(H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.fspace, - type_info->src_type_size, - &chunk_ftype[u], /* OUT: datatype created */ - &chunk_mpi_file_counts[u], /* OUT */ - &(chunk_mft_is_derived_array[u]), /* OUT */ - TRUE, /* this is a file space, - so permute the - datatype if the point - selections are out of - order */ - &permute_map,/* OUT: a map to indicate the - permutation of points - selected in case they - are out of order */ - &is_permuted /* OUT */) < 0) + if (H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.fspace, type_info->src_type_size, + &chunk_ftype[u], /* OUT: datatype created */ + &chunk_mpi_file_counts[u], /* OUT */ + &(chunk_mft_is_derived_array[u]), /* OUT */ + TRUE, /* this is a file space, + so permute the + datatype if the point + selections are out of + order */ + &permute_map, /* OUT: a map to indicate the + permutation of points + selected in case they + are out of order */ + &is_permuted /* OUT */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI file type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(permute_map); - if(H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.mspace, - type_info->dst_type_size, &chunk_mtype[u], - &chunk_mpi_mem_counts[u], - &(chunk_mbt_is_derived_array[u]), - FALSE, /* this is a memory - space, so if the file - space is not - permuted, there is no - need to permute the - datatype if the point - selections are out of - order*/ - &permute_map, /* IN: the permutation map - generated by the - file_space selection - and applied to the - memory selection */ - &is_permuted /* IN */) < 0) + if (H5S_mpio_space_type(chunk_addr_info_array[u].chunk_info.mspace, type_info->dst_type_size, + &chunk_mtype[u], &chunk_mpi_mem_counts[u], + &(chunk_mbt_is_derived_array[u]), FALSE, /* this is a memory + space, so if the file + space is not + permuted, there is no + need to permute the + datatype if the point + selections are out of + order*/ + &permute_map, /* IN: the permutation map + generated by the + file_space selection + and applied to the + memory selection */ + &is_permuted /* IN */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI buf type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(!permute_map); /* Chunk address relative to the first chunk */ @@ -1185,34 +1197,38 @@ if(H5DEBUG(D)) } /* end for */ /* Create final MPI derived datatype for the file */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_file_counts, chunk_disp_array, chunk_ftype, &chunk_final_ftype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_file_counts, chunk_disp_array, + chunk_ftype, &chunk_final_ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_ftype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_ftype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) chunk_final_ftype_is_derived = TRUE; /* Create final MPI derived datatype for memory */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_mem_counts, chunk_mem_disp_array, chunk_mtype, &chunk_final_mtype))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct((int)num_chunk, chunk_mpi_mem_counts, chunk_mem_disp_array, + chunk_mtype, &chunk_final_mtype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_mtype))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&chunk_final_mtype))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) chunk_final_mtype_is_derived = TRUE; /* Free the file & memory MPI datatypes for each chunk */ - for(u = 0; u < num_chunk; u++) { - if(chunk_mbt_is_derived_array[u]) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_mtype + u))) + for (u = 0; u < num_chunk; u++) { + if (chunk_mbt_is_derived_array[u]) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_mtype + u))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(chunk_mft_is_derived_array[u]) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_ftype + u))) + if (chunk_mft_is_derived_array[u]) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(chunk_ftype + u))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) } /* end for */ /* We have a single, complicated MPI datatype for both memory & file */ - mpi_buf_count = (hsize_t)1; - } /* end if */ - else { /* no selection at all for this process */ + mpi_buf_count = (hsize_t)1; + } /* end if */ + else { /* no selection at all for this process */ ctg_store.contig.dset_addr = 0; /* Set the MPI datatype */ @@ -1220,56 +1236,57 @@ if(H5DEBUG(D)) chunk_final_mtype = MPI_BYTE; /* No chunks selected for this process */ - mpi_buf_count = (hsize_t)0; + mpi_buf_count = (hsize_t)0; } /* end else */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before coming to final collective IO\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before coming to final collective IO\n"); #endif /* Set up the base storage address for this chunk */ io_info->store = &ctg_store; /* Perform final collective I/O operation */ - if(H5D__final_collective_io(io_info, type_info, mpi_buf_count, chunk_final_ftype, chunk_final_mtype) < 0) + if (H5D__final_collective_io(io_info, type_info, mpi_buf_count, chunk_final_ftype, + chunk_final_mtype) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") } /* 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before freeing memory inside H5D_link_collective_io ret_value = %d\n", + ret_value); #endif /* Release resources */ - if(chunk_addr_info_array) + if (chunk_addr_info_array) H5MM_xfree(chunk_addr_info_array); - if(chunk_mtype) + if (chunk_mtype) H5MM_xfree(chunk_mtype); - if(chunk_ftype) + if (chunk_ftype) H5MM_xfree(chunk_ftype); - if(chunk_disp_array) + if (chunk_disp_array) H5MM_xfree(chunk_disp_array); - if(chunk_mem_disp_array) + if (chunk_mem_disp_array) H5MM_xfree(chunk_mem_disp_array); - if(chunk_mpi_mem_counts) + if (chunk_mpi_mem_counts) H5MM_xfree(chunk_mpi_mem_counts); - if(chunk_mpi_file_counts) + if (chunk_mpi_file_counts) H5MM_xfree(chunk_mpi_file_counts); - if(chunk_mbt_is_derived_array) + if (chunk_mbt_is_derived_array) H5MM_xfree(chunk_mbt_is_derived_array); - if(chunk_mft_is_derived_array) + if (chunk_mft_is_derived_array) H5MM_xfree(chunk_mft_is_derived_array); /* Free the MPI buf and file types, if they were derived */ - if(chunk_final_mtype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_mtype))) + if (chunk_final_mtype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_mtype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(chunk_final_ftype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_ftype))) + if (chunk_final_ftype_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_final_ftype))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__link_chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__link_chunk_filtered_collective_io * @@ -1319,21 +1336,22 @@ if(H5DEBUG(D)) */ 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) { 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 *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; FUNC_ENTER_STATIC @@ -1356,7 +1374,8 @@ 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__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < + 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 */ @@ -1365,15 +1384,15 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in 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.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.layout = index_info.layout; udata.common.storage = index_info.storage; - udata.filter_mask = 0; + udata.filter_mask = 0; /* Iterate through all the chunks in the collective write operation, * updating each chunk with the data modifications from other processes, @@ -1387,8 +1406,10 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in /* Gather the new chunk sizes to all processes for a collective reallocation * of the chunks in the file. */ - 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) + 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 */ @@ -1396,15 +1417,17 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in 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) + &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)))) + 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))) + 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 @@ -1424,14 +1447,16 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in * 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++) + 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)); + H5MM_memcpy(chunk_list, &collective_chunk_list[offset], + num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t)); /* 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) + 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") /* Override the write buffer to point to the address of the first @@ -1441,11 +1466,11 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in } /* 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; + 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; + io_info->store = &ctg_store; /* Perform I/O */ if (H5D__final_collective_io(io_info, type_info, mpi_buf_count, file_type, mem_type) < 0) @@ -1455,14 +1480,14 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in * in this iteration 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.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; + 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 */ + } /* end if */ done: /* Free resources used by a process which had some selection */ @@ -1488,7 +1513,6 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__link_chunk_filtered_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__multi_chunk_collective_io * @@ -1507,25 +1531,27 @@ 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) { - 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; - 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 */ + 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; + 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 */ - 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; + 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; FUNC_ENTER_STATIC @@ -1544,17 +1570,17 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "total_chunk %zu\n", 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) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "unable to obtain MPIO mode") /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ @@ -1562,7 +1588,7 @@ if(H5DEBUG(D)) /* Set up compact I/O info object */ H5MM_memcpy(&cpt_io_info, io_info, sizeof(cpt_io_info)); - cpt_io_info.store = &cpt_store; + cpt_io_info.store = &cpt_store; cpt_io_info.layout_ops = *H5D_LOPS_COMPACT; /* Initialize temporary compact storage info */ @@ -1572,38 +1598,39 @@ if(H5DEBUG(D)) io_info->store = &store; /* 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 */ + 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 */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"mpi_rank = %d, chunk index = %Zu\n", mpi_rank, u); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "mpi_rank = %d, chunk index = %zu\n", mpi_rank, u); #endif /* Get the chunk info for this chunk, if there are elements selected */ chunk_info = fm->select_chunk[u]; /* Set the storage information for chunks with selections */ - if(chunk_info) { + if (chunk_info) { HDassert(chunk_info->index == u); /* Pass in chunk's coordinates in a union. */ - store.chunk.scaled = chunk_info->scaled; + store.chunk.scaled = chunk_info->scaled; } /* end if */ /* Collective IO for this chunk, * Note: even there is no selection for this process, the process still * needs to contribute MPI NONE TYPE. */ - if(chunk_io_option[u] == H5D_CHUNK_IO_MODE_COL) { + 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "inside collective chunk IO mpi_rank = %d, chunk index = %zu\n", + mpi_rank, u); #endif /* Set the file & memory dataspaces */ - if(chunk_info) { + if (chunk_info) { fspace = chunk_info->fspace; mspace = chunk_info->mspace; @@ -1613,7 +1640,7 @@ if(H5DEBUG(D)) * to ease switching between to mixed I/O without checking the current * value of the property. You can see the definition in H5Ppublic.h */ - actual_io_mode = (H5D_mpio_actual_io_mode_t) (actual_io_mode | H5D_MPIO_CHUNK_COLLECTIVE); + actual_io_mode = (H5D_mpio_actual_io_mode_t)(actual_io_mode | H5D_MPIO_CHUNK_COLLECTIVE); } /* end if */ else { @@ -1621,8 +1648,8 @@ if(H5DEBUG(D)) } /* end else */ /* Switch back to collective I/O */ - if(last_coll_opt_mode != H5FD_MPIO_COLLECTIVE_IO) { - if(H5CX_set_mpio_coll_opt(H5FD_MPIO_COLLECTIVE_IO) < 0) + if (last_coll_opt_mode != H5FD_MPIO_COLLECTIVE_IO) { + if (H5CX_set_mpio_coll_opt(H5FD_MPIO_COLLECTIVE_IO) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't switch to collective I/O") last_coll_opt_mode = H5FD_MPIO_COLLECTIVE_IO; } /* end if */ @@ -1631,32 +1658,33 @@ if(H5DEBUG(D)) ctg_store.contig.dset_addr = chunk_addr[u]; /* Perform the I/O */ - if(H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) + 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") - } /* end if */ - else { /* possible independent IO for this chunk */ + } /* 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "inside independent IO mpi_rank = %d, chunk index = %zu\n", mpi_rank, + u); #endif HDassert(chunk_io_option[u] == 0); /* Set the file & memory dataspaces */ - if(chunk_info) { + if (chunk_info) { fspace = chunk_info->fspace; mspace = chunk_info->mspace; /* Update the local variable tracking the actual io mode. */ - actual_io_mode = (H5D_mpio_actual_io_mode_t) (actual_io_mode | H5D_MPIO_CHUNK_INDEPENDENT); + actual_io_mode = (H5D_mpio_actual_io_mode_t)(actual_io_mode | H5D_MPIO_CHUNK_INDEPENDENT); } /* end if */ else { fspace = mspace = NULL; } /* end else */ /* Using independent I/O with file setview.*/ - if(last_coll_opt_mode != H5FD_MPIO_INDIVIDUAL_IO) { - if(H5CX_set_mpio_coll_opt(H5FD_MPIO_INDIVIDUAL_IO) < 0) + if (last_coll_opt_mode != H5FD_MPIO_INDIVIDUAL_IO) { + if (H5CX_set_mpio_coll_opt(H5FD_MPIO_INDIVIDUAL_IO) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't switch to individual I/O") last_coll_opt_mode = H5FD_MPIO_INDIVIDUAL_IO; } /* end if */ @@ -1665,28 +1693,27 @@ if(H5DEBUG(D)) ctg_store.contig.dset_addr = chunk_addr[u]; /* Perform the I/O */ - if(H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) + 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"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "after inter collective IO\n"); #endif } /* end else */ - } /* end for */ + } /* end for */ /* Write the local value of actual io mode to the API context. */ H5CX_set_mpio_actual_io_mode(actual_io_mode); done: - if(chunk_io_option) + if (chunk_io_option) H5MM_xfree(chunk_io_option); - if(chunk_addr) + if (chunk_addr) H5MM_xfree(chunk_addr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__multi_chunk_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__multi_chunk_filtered_collective_io * @@ -1745,23 +1772,25 @@ if(H5DEBUG(D)) */ 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) { 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 *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; FUNC_ENTER_STATIC @@ -1784,16 +1813,17 @@ 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__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list") /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); - ctg_io_info.store = &ctg_store; + ctg_io_info.store = &ctg_store; ctg_io_info.layout_ops = *H5D_LOPS_CONTIG; /* Initialize temporary contiguous storage info */ - ctg_store.contig.dset_size = (hsize_t) io_info->dset->shared->layout.u.chunk.size; + 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 */ @@ -1803,7 +1833,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i 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 */ + } /* end if */ else { /* Filtered collective write */ H5D_chk_idx_info_t index_info; H5D_chunk_ud_t udata; @@ -1811,37 +1841,38 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i 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.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.layout = index_info.layout; udata.common.storage = index_info.storage; - udata.filter_mask = 0; + 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))) + 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); + 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)))) + 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)))) + 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)))) + 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)))) + 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 @@ -1850,7 +1881,8 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i */ 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); + hbool_t have_chunk_to_process = + (i < chunk_list_num_entries) && (mpi_rank == chunk_list[i].owners.new_owner); if (have_chunk_to_process) if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) @@ -1859,8 +1891,10 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i /* Gather the new chunk sizes to all processes for a collective re-allocation * of the chunks in the file */ - 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) + 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 @@ -1870,15 +1904,18 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i 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) + &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)))) + 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 (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))) + 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) /* If this process has a chunk to work on, create a MPI type for the @@ -1888,26 +1925,30 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i size_t offset; int mpi_type_count; - for (j = 0, offset = 0; j < (size_t) mpi_rank; j++) + 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)); + 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]))) + 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]))) + 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]))) + 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]))) + 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; @@ -1923,34 +1964,36 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i } /* end if */ else { mem_type_array[i] = file_type_array[i] = MPI_BYTE; - mpi_buf_count = 0; + mpi_buf_count = 0; } /* end else */ /* 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_array[i], + mem_type_array[i]) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") /* 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.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; + 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") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, + "unable to insert chunk address into index") } /* end for */ - if (collective_chunk_list){ + if (collective_chunk_list) { H5MM_free(collective_chunk_list); collective_chunk_list = NULL; } /* end if */ - if (has_chunk_selected_array){ + if (has_chunk_selected_array) { H5MM_free(has_chunk_selected_array); has_chunk_selected_array = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Free the MPI file and memory types, if they were derived */ for (i = 0; i < max_num_chunks; i++) { @@ -1962,7 +2005,7 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_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 */ + } /* end else */ done: if (chunk_list) { @@ -1987,7 +2030,6 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__multi_chunk_filtered_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__inter_collective_io * @@ -2002,20 +2044,20 @@ 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, const H5S_t *file_space, + const 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_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 */ FUNC_ENTER_STATIC - if((file_space != NULL) && (mem_space != NULL)) { - int mpi_file_count; /* Number of file "objects" to transfer */ + 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, out-of-order displacements to the in-order displacements of the MPI datatypes of the @@ -2027,39 +2069,40 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * and will be fed into the next call to H5S_mpio_space_type * where it will be freed. */ - if(H5S_mpio_space_type(file_space, type_info->src_type_size, - &mpi_file_type, &mpi_file_count, &mft_is_derived, /* OUT: datatype created */ - TRUE, /* this is a file space, so - permute the datatype if the - point selection is out of - order */ - &permute_map, /* OUT: a map to indicate - the permutation of - points selected in - case they are out of - order */ - &is_permuted /* OUT */) < 0) + if (H5S_mpio_space_type(file_space, type_info->src_type_size, &mpi_file_type, &mpi_file_count, + &mft_is_derived, /* OUT: datatype created */ + TRUE, /* this is a file space, so + permute the datatype if the + point selection is out of + order */ + &permute_map, /* OUT: a map to indicate + the permutation of + points selected in + case they are out of + order */ + &is_permuted /* OUT */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI file type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(permute_map); - if(H5S_mpio_space_type(mem_space, type_info->src_type_size, - &mpi_buf_type, &mpi_buf_count, &mbt_is_derived, /* OUT: datatype created */ - FALSE, /* this is a memory space, so if - the file space is not - permuted, there is no need to - permute the datatype if the - point selections are out of - order*/ - &permute_map /* IN: the permutation map - generated by the - file_space selection - and applied to the - memory selection */, - &is_permuted /* IN */) < 0) + if (H5S_mpio_space_type(mem_space, type_info->src_type_size, &mpi_buf_type, &mpi_buf_count, + &mbt_is_derived, /* OUT: datatype created */ + FALSE, /* this is a memory space, so if + the file space is not + permuted, there is no need to + permute the datatype if the + point selections are out of + order*/ + &permute_map /* IN: the permutation map + generated by the + file_space selection + and applied to the + memory selection */ + , + &is_permuted /* IN */) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create MPI buffer type") /* Sanity check */ - if(is_permuted) + if (is_permuted) HDassert(!permute_map); } /* end if */ else { @@ -2072,30 +2115,29 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf } /* end else */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"before final collective IO \n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before final collective IO \n"); #endif /* Perform final collective I/O operation */ - if(H5D__final_collective_io(io_info, type_info, (hsize_t)mpi_buf_count, mpi_file_type, mpi_buf_type) < 0) + if (H5D__final_collective_io(io_info, type_info, (hsize_t)mpi_buf_count, mpi_file_type, mpi_buf_type) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish collective MPI-IO") done: /* Free the MPI buf and file types, if they were derived */ - if(mbt_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_buf_type))) + if (mbt_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_buf_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if(mft_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_file_type))) + 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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before leaving inter_collective_io ret_value = %d\n", ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__inter_collective_io() */ - /*------------------------------------------------------------------------- * Function: H5D__final_collective_io * @@ -2109,35 +2151,34 @@ if(H5DEBUG(D)) *------------------------------------------------------------------------- */ 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) +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) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Pass buf type, file type to the file driver. */ - if(H5CX_set_mpi_coll_datatypes(mpi_buf_type, mpi_file_type) < 0) + 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") - if(io_info->op_type == H5D_IO_OP_WRITE) { - if((io_info->io_ops.single_write)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) + if (io_info->op_type == H5D_IO_OP_WRITE) { + if ((io_info->io_ops.single_write)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") } /* end if */ else { - if((io_info->io_ops.single_read)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) + if ((io_info->io_ops.single_read)(io_info, type_info, mpi_buf_count, NULL, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") } /* end else */ done: #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D),"ret_value before leaving final_collective_io=%d\n",ret_value); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "ret_value before leaving final_collective_io=%d\n", ret_value); #endif - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__final_collective_io */ - /*------------------------------------------------------------------------- * Function: H5D__cmp_chunk_addr * @@ -2155,17 +2196,16 @@ if(H5DEBUG(D)) static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2) { - haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; + haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC_NOERR - addr1 = ((const H5D_chunk_addr_info_t *)chunk_addr_info1)->chunk_addr; - addr2 = ((const H5D_chunk_addr_info_t *)chunk_addr_info2)->chunk_addr; + addr1 = ((const H5D_chunk_addr_info_t *)chunk_addr_info1)->chunk_addr; + addr2 = ((const H5D_chunk_addr_info_t *)chunk_addr_info2)->chunk_addr; - FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) + FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) } /* end H5D__cmp_chunk_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__cmp_filtered_collective_io_info_entry * @@ -2183,20 +2223,23 @@ 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) +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; 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; + 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; FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) } /* end H5D__cmp_filtered_collective_io_info_entry() */ #if MPI_VERSION >= 3 - + /*------------------------------------------------------------------------- * Function: H5D__cmp_filtered_collective_io_info_entry_owner * @@ -2215,20 +2258,22 @@ H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_in *------------------------------------------------------------------------- */ 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_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, + const void *filtered_collective_io_info_entry2) { int owner1 = -1, owner2 = -1; 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; + 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; FUNC_LEAVE_NOAPI(owner1 - owner2) } /* end H5D__cmp_filtered_collective_io_info_entry_owner() */ #endif - /*------------------------------------------------------------------------- * Function: H5D__sort_chunk * @@ -2243,8 +2288,8 @@ H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective * Parameters: * Input: H5D_io_info_t* io_info, * H5D_chunk_map_t *fm(global chunk map struct) - * Input/Output: H5D_chunk_addr_info_t chunk_addr_info_array[] : array to store chunk address and information - * many_chunk_opt : flag to optimize the way to obtain chunk addresses + * Input/Output: H5D_chunk_addr_info_t chunk_addr_info_array[] : array to store chunk address + *and information many_chunk_opt : flag to optimize the way to obtain chunk addresses * for many chunks * * Return: Non-negative on success/Negative on failure @@ -2256,24 +2301,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) { - 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 */ + 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 */ FUNC_ENTER_STATIC /* Retrieve # of MPI processes */ - if((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) + 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 @@ -2285,56 +2330,59 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, * for each process. */ bsearch_coll_chunk_threshold = (sum_chunk * 100) / ((int)fm->layout->u.chunk.nchunks * mpi_size); - if((bsearch_coll_chunk_threshold > H5D_ALL_CHUNK_ADDR_THRES_COL) - && ((sum_chunk / mpi_size) >= H5D_ALL_CHUNK_ADDR_THRES_COL_NUM)) + if ((bsearch_coll_chunk_threshold > H5D_ALL_CHUNK_ADDR_THRES_COL) && + ((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); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "many_chunk_opt= %d\n", 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) { + 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"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "Coming inside H5D_OBTAIN_ALL_CHUNK_ADDR_COL\n"); #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))) + 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) + 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) + 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") } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(total_chunk_addr_array, (int)(sizeof(haddr_t) * fm->layout->u.chunk.nchunks), MPI_BYTE, (int)0, io_info->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(total_chunk_addr_array, + (int)(sizeof(haddr_t) * fm->layout->u.chunk.nchunks), + MPI_BYTE, (int)0, io_info->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) } /* end if */ /* Start at first node in chunk skip list */ i = 0; - if(NULL == (chunk_node = H5SL_first(fm->sel_chunks))) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL,"couldn't get chunk node from skipped list") + if (NULL == (chunk_node = H5SL_first(fm->sel_chunks))) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk node from skipped list") /* Iterate over all chunks for this process */ - while(chunk_node) { - if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL,"couldn't get chunk info from skipped list") + while (chunk_node) { + if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") - if(many_chunk_opt == H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ + if (many_chunk_opt == H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { + H5D_chunk_ud_t udata; /* User data for querying chunk info */ /* Get address of chunk */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") chunk_addr = udata.chunk_block.offset; } /* end if */ @@ -2342,7 +2390,7 @@ if(H5DEBUG(D)) chunk_addr = total_chunk_addr_array[chunk_info->index]; /* Check if chunk addresses are not in increasing order in the file */ - if(i > 0 && chunk_addr < chunk_addr_info_array[i - 1].chunk_addr) + if (i > 0 && chunk_addr < chunk_addr_info_array[i - 1].chunk_addr) do_sort = TRUE; /* Set the address & info for this chunk */ @@ -2355,23 +2403,22 @@ if(H5DEBUG(D)) } /* end while */ #ifdef H5D_DEBUG -if(H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before Qsort\n"); + if (H5DEBUG(D)) + HDfprintf(H5DEBUG(D), "before Qsort\n"); #endif - if(do_sort) { + if (do_sort) { size_t num_chunks = H5SL_count(fm->sel_chunks); HDqsort(chunk_addr_info_array, num_chunks, sizeof(chunk_addr_info_array[0]), H5D__cmp_chunk_addr); } /* end if */ done: - if(total_chunk_addr_array) + if (total_chunk_addr_array) H5MM_xfree(total_chunk_addr_array); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__sort_chunk() */ - /*------------------------------------------------------------------------- * Function: H5D__obtain_mpio_mode * @@ -2392,7 +2439,8 @@ if(H5DEBUG(D)) * c) Build MPI derived datatype to combine "chunk address" and "assign_io" information * in order to do MPI Bcast only once * d) MPI Bcast the IO mode and chunk address information for each chunk. - * 4) Each process then retrieves IO mode and chunk address information to assign_io_mode and chunk_addr. + * 4) Each process then retrieves IO mode and chunk address information to assign_io_mode and + *chunk_addr. * * Parameters: * @@ -2409,17 +2457,17 @@ if(H5DEBUG(D)) *------------------------------------------------------------------------- */ 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[]) +H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assign_io_mode[], + haddr_t chunk_addr[]) { 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; + 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; @@ -2430,91 +2478,90 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, FUNC_ENTER_STATIC /* Assign the rank 0 to the root */ - root = 0; - comm = io_info->comm; + 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) + 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) + 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) + if (H5CX_get_mpio_chunk_opt_ratio(&percent_nproc_per_chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get percent nproc per chunk") /* if ratio is 0, perform collective io */ - if(0 == percent_nproc_per_chunk) { - if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address"); - for(ic = 0; ic < total_chunks; ic++) - assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; + if (0 == percent_nproc_per_chunk) { + if (H5D__chunk_addrmap(io_info, chunk_addr) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address"); + for (ic = 0; ic < total_chunks; ic++) + assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; HGOTO_DONE(SUCCEED) } /* end if */ - threshold_nproc_per_chunk = (unsigned)mpi_size * percent_nproc_per_chunk/100; + threshold_nproc_per_chunk = (unsigned)mpi_size * percent_nproc_per_chunk / 100; /* Allocate memory */ - if(NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) + if (NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate I/O mode info buffer") - if(NULL == (mergebuf = (uint8_t *)H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) + if (NULL == (mergebuf = (uint8_t *)H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mergebuf buffer") - tempbuf = mergebuf + total_chunks; - if(mpi_rank == root) - if(NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * (size_t)mpi_size))) + tempbuf = mergebuf + total_chunks; + if (mpi_rank == root) + if (NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * (size_t)mpi_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate recv I/O mode info buffer") /* Obtain the regularity and selection information for all chunks in this process. */ - chunk_node = H5SL_first(fm->sel_chunks); - while(chunk_node) { - chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); + chunk_node = H5SL_first(fm->sel_chunks); + while (chunk_node) { + chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); io_mode_info[chunk_info->index] = H5D_CHUNK_SELECT_REG; /* this chunk is selected and is "regular" */ - chunk_node = H5SL_next(chunk_node); + chunk_node = H5SL_next(chunk_node); } /* end while */ /* Gather all the information */ H5_CHECK_OVERFLOW(total_chunks, size_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Gather(io_mode_info, (int)total_chunks, MPI_BYTE, - recv_io_mode_info, (int)total_chunks, MPI_BYTE, root, comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Gather(io_mode_info, (int)total_chunks, MPI_BYTE, recv_io_mode_info, + (int)total_chunks, MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Gather failed", mpi_code) /* Calculate the mode for IO(collective, independent or none) at root process */ - if(mpi_rank == root) { - size_t nproc; - unsigned* nproc_per_chunk; + if (mpi_rank == root) { + size_t nproc; + unsigned *nproc_per_chunk; /* 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)))) + if (NULL == (nproc_per_chunk = (unsigned *)H5MM_calloc(total_chunks * sizeof(unsigned)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate nproc_per_chunk buffer") /* calculating the chunk address */ - if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) { + if (H5D__chunk_addrmap(io_info, chunk_addr) < 0) { H5MM_free(nproc_per_chunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") } /* end if */ /* checking for number of process per chunk and regularity of the selection*/ - for(nproc = 0; nproc < (size_t)mpi_size; nproc++) { + for (nproc = 0; nproc < (size_t)mpi_size; nproc++) { uint8_t *tmp_recv_io_mode_info = recv_io_mode_info + (nproc * total_chunks); /* Calculate the number of process per chunk and adding irregular selection option */ - for(ic = 0; ic < total_chunks; ic++, tmp_recv_io_mode_info++) { - if(*tmp_recv_io_mode_info != 0) { + for (ic = 0; ic < total_chunks; ic++, tmp_recv_io_mode_info++) { + if (*tmp_recv_io_mode_info != 0) { nproc_per_chunk[ic]++; } /* end if */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /* Calculating MPIO mode for each chunk (collective, independent, none) */ - for(ic = 0; ic < total_chunks; ic++) { - if(nproc_per_chunk[ic] > MAX(1, threshold_nproc_per_chunk)) { + for (ic = 0; ic < total_chunks; ic++) { + if (nproc_per_chunk[ic] > MAX(1, threshold_nproc_per_chunk)) { assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; } /* end if */ - } /* end for */ - + } /* end for */ /* merge buffer io_mode info and chunk addr into one */ H5MM_memcpy(mergebuf, assign_io_mode, total_chunks); @@ -2524,38 +2571,39 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ - if((sizeof(haddr_t) + 1) * total_chunks > INT_MAX) + if ((sizeof(haddr_t) + 1) * total_chunks > INT_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) H5MM_memcpy(assign_io_mode, mergebuf, total_chunks); H5MM_memcpy(chunk_addr, tempbuf, sizeof(haddr_t) * total_chunks); #ifdef H5_HAVE_INSTRUMENTED_LIBRARY -{ - hbool_t coll_op = FALSE; + { + hbool_t coll_op = FALSE; + + for (ic = 0; ic < total_chunks; ic++) + if (assign_io_mode[ic] == H5D_CHUNK_IO_MODE_COL) { + if (H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") + coll_op = TRUE; + break; + } /* end if */ - for(ic = 0; ic < total_chunks; ic++) - if(assign_io_mode[ic] == H5D_CHUNK_IO_MODE_COL) { - if(H5CX_test_set_mpio_coll_chunk_multi_ratio_coll(0) < 0) + if (!coll_op) + if (H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") - coll_op = TRUE; - break; - } /* end if */ - - if(!coll_op) - if(H5CX_test_set_mpio_coll_chunk_multi_ratio_ind(0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property value") -} + } #endif done: - if(io_mode_info) + if (io_mode_info) H5MM_free(io_mode_info); - if(mergebuf) + if (mergebuf) H5MM_free(mergebuf); - if(recv_io_mode_info) { + if (recv_io_mode_info) { HDassert(mpi_rank == root); H5MM_free(recv_io_mode_info); } /* end if */ @@ -2563,7 +2611,6 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__obtain_mpio_mode() */ - /*------------------------------------------------------------------------- * Function: H5D__construct_filtered_io_info_list * @@ -2584,13 +2631,15 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, */ 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) + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t **chunk_list, size_t *num_entries) { - 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; /* 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; FUNC_ENTER_STATIC @@ -2607,35 +2656,37 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ 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; - if(NULL == (local_info_array = (H5D_filtered_collective_io_info_t *) H5MM_malloc(num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) + if (NULL == (local_info_array = (H5D_filtered_collective_io_info_t *)H5MM_malloc( + num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate local io info array buffer") chunk_node = H5SL_first(fm->sel_chunks); - for(i = 0; chunk_node; i++) { - chunk_info = (H5D_chunk_info_t *) H5SL_item(chunk_node); + for (i = 0; chunk_node; i++) { + chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node); /* Obtain this chunk's address */ - if(H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) + 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].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].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.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; + 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 @@ -2648,22 +2699,26 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ 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; + (local_info_array[i].io_size >= (hsize_t)chunk_npoints * type_info->dst_type_size) ? TRUE + : FALSE; chunk_node = H5SL_next(chunk_node); } /* end for */ - } /* end if */ + } /* 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) + 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)") + HGOTO_ERROR( + H5E_DATASET, H5E_WRITEERROR, FAIL, + "unable to redistribute shared chunks - MPI version < 3 (MPI_Mprobe and MPI_Imrecv missing)") #endif - *chunk_list = local_info_array; + *chunk_list = local_info_array; *num_entries = num_chunks_selected; done: @@ -2671,7 +2726,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ } /* end H5D__construct_filtered_io_info_list() */ #if MPI_VERSION >= 3 - + /*------------------------------------------------------------------------- * Function: H5D__chunk_redistribute_shared_chunks * @@ -2713,23 +2768,27 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ */ 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) + const H5D_chunk_map_t * fm, + H5D_filtered_collective_io_info_t *local_chunk_array, + size_t * local_chunk_array_num_entries) { - 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; + 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; FUNC_ENTER_STATIC @@ -2747,58 +2806,63 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty H5CX_set_libver_bounds(NULL); if (*local_chunk_array_num_entries) - if (NULL == (send_requests = (MPI_Request *) H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request)))) + 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") - if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) + 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") - /* 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. + /* 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. */ - 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) + 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") /* 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)))) + 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 (NULL == (send_displacements = (int *) H5MM_malloc((size_t) mpi_size * sizeof(int)))) + 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 (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") + 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") 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; + 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; /* Process each set of duplicate entries caused by another process writing to the same chunk */ do { chunk_entry = shared_chunks_info_array[i]; - send_counts[chunk_entry.owners.original_owner] += (int) sizeof(chunk_entry); + send_counts[chunk_entry.owners.original_owner] += (int)sizeof(chunk_entry); /* 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]) + 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; num_writers++; - } while (++i < shared_chunks_info_array_num_entries && shared_chunks_info_array[i].chunk_states.chunk_current.offset == last_seen_addr); + } while (++i < shared_chunks_info_array_num_entries && + shared_chunks_info_array[i].chunk_states.chunk_current.offset == last_seen_addr); /* 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; + shared_chunks_info_array[set_begin_index].num_writers = num_writers; } /* end for */ num_assigned_chunks_array[new_chunk_owner]++; @@ -2807,19 +2871,22 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty /* 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 */ - if(shared_chunks_info_array_num_entries > 1) + 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); + 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++) + for (i = 1; i < (size_t)mpi_size; i++) send_displacements[i] = send_displacements[i - 1] + send_counts[i - 1]; } /* end if */ /* 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))) + 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) if (shared_chunks_info_array) { @@ -2833,7 +2900,8 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty * 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 *)))) + 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") for (i = 0, last_assigned_idx = 0; i < *local_chunk_array_num_entries; i++) { @@ -2841,50 +2909,54 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty if (mpi_rank != chunk_entry->owners.new_owner) { H5D_chunk_info_t *chunk_info = NULL; - unsigned char *mod_data_p = NULL; + unsigned char * mod_data_p = NULL; hsize_t iter_nelmts; size_t mod_data_size; /* 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))) + 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") /* 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) + 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") 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; + mod_data_size += (size_t)iter_nelmts * type_info->src_type_size; - 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 (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") /* 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) + 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, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") + 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; /* 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)) + 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") /* 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]))) + 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) - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + 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; @@ -2897,11 +2969,14 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty MPI_Status status; size_t j; - 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)))) + 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") - 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 *)))) + 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") for (j = 0; j < chunk_entry->num_writers - 1; j++) { @@ -2911,35 +2986,39 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty * 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))) + 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]))) + 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 */ + } /* end if */ local_chunk_array[last_assigned_idx++] = local_chunk_array[i]; } /* end else */ - } /* end for */ + } /* end for */ *local_chunk_array_num_entries = last_assigned_idx; /* 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)))) + 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") H5_CHECK_OVERFLOW(num_send_requests, size_t, int); - if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int) num_send_requests, send_requests, send_statuses))) + 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 */ @@ -2975,7 +3054,6 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty } /* end H5D__chunk_redistribute_shared_chunks() */ #endif - /*------------------------------------------------------------------------- * Function: H5D__mpio_filtered_collective_write_type * @@ -2992,14 +3070,14 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty *------------------------------------------------------------------------- */ 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_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) { - MPI_Aint *write_buf_array = NULL; /* Relative displacements of filtered chunk data buffers */ + 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; + int * length_array = NULL; /* Filtered Chunk lengths */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -3012,40 +3090,46 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun if (num_entries > 0) { size_t i; int mpi_code; - void *base_buf; + 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") + 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); + HDqsort(chunk_list, num_entries, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); 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; + 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 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))) + 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))) + 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))) @@ -3053,17 +3137,16 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun } /* end if */ done: - if(write_buf_array) + if (write_buf_array) H5MM_free(write_buf_array); - if(file_offset_array) + if (file_offset_array) H5MM_free(file_offset_array); - if(length_array) + if (length_array) H5MM_free(length_array); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_filtered_collective_write_type() */ - /*------------------------------------------------------------------------- * Function: H5D__filtered_collective_chunk_entry_io * @@ -3081,27 +3164,28 @@ H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chun */ 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) + const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5D_chunk_map_t *fm) { 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 */ + 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 */ + 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 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 + 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; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -3111,18 +3195,18 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk HDassert(fm); /* Retrieve filter settings from API context */ - if(H5CX_get_err_detect(&err_detect) < 0) + 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) + if (H5CX_get_filter_cb(&filter_cb) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") /* 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))) + 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") 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; + true_chunk_size = (hsize_t)extent_npoints * type_info->src_type_size; /* 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 @@ -3137,7 +3221,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk /* 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(!chunk_entry->full_overwrite || io_info->op_type == H5D_IO_OP_READ) { + if (!chunk_entry->full_overwrite || io_info->op_type == H5D_IO_OP_READ) { H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ chunk_entry->chunk_states.new_chunk.length = chunk_entry->chunk_states.chunk_current.length; @@ -3147,24 +3231,25 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk * this should be refactored to use collective chunk reads - JTH */ /* Get the original state of parallel I/O transfer mode */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* Change the xfer_mode to independent for handling the I/O */ - if(H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) + 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(H5F_block_read(io_info->dset->oloc.file, H5FD_MEM_DRAW, chunk_entry->chunk_states.chunk_current.offset, - chunk_entry->chunk_states.new_chunk.length, chunk_entry->buf) < 0) + 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") /* Return to the original I/O transfer mode setting */ - if(H5CX_set_io_xfer_mode(xfer_mode) < 0) + if (H5CX_set_io_xfer_mode(xfer_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") - 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) + 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 { @@ -3172,10 +3257,10 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk } /* end else */ /* Initialize iterator for memory selection */ - if (NULL == (mem_iter = (H5S_sel_iter_t *) H5MM_malloc(sizeof(H5S_sel_iter_t)))) + 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") - if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) + 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; @@ -3185,26 +3270,27 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk * from the current process, then apply any modifications from other processes. Finally, * filter the newly-updated chunk. */ - switch(io_info->op_type) { + 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)))) + 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(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") + 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; iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) + 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") - if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) + 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") iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0) + 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") break; @@ -3212,20 +3298,21 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk case H5D_IO_OP_WRITE: iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) + 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") /* 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)) + 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") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") mem_iter_init = FALSE; /* 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") + 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; iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); @@ -3233,43 +3320,45 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk /* 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) + 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") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + 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(MPI_SUCCESS != (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests, - chunk_entry->async_info.receive_requests_array, MPI_STATUSES_IGNORE))) + 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) /* 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++) { + for (i = 0; i < (size_t)chunk_entry->async_info.num_receive_requests; i++) { const unsigned char *mod_data_p; /* 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))) + if (NULL == (dataspace = H5S_decode(&mod_data_p))) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") - 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") + 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; iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace); /* 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) + 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") - if(H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + 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) + if (dataspace) { + if (H5S_close(dataspace) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") dataspace = NULL; } @@ -3277,14 +3366,14 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk } /* end for */ /* 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) + 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 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)) + 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; @@ -3314,5 +3403,4 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__filtered_collective_chunk_entry_io() */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index 751d06746ac..b2dfd1a819d 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,51 +28,43 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Non Index chunking I/O ops */ -static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__none_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t 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 *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__none_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); - +static herr_t H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t 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 *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__none_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); /*********************/ /* Package Variables */ @@ -80,36 +72,32 @@ static herr_t H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *strea /* Non Index chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_NONE[1] = {{ - FALSE, /* Non-indexed chunking don't current support SWMR access */ - NULL, /* init */ - H5D__none_idx_create, /* create */ - H5D__none_idx_is_space_alloc, /* is_space_alloc */ - NULL, /* insert */ - H5D__none_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__none_idx_iterate, /* iterate */ - H5D__none_idx_remove, /* remove */ - H5D__none_idx_delete, /* delete */ - H5D__none_idx_copy_setup, /* copy_setup */ - NULL, /* copy_shutdown */ - H5D__none_idx_size, /* size */ - H5D__none_idx_reset, /* reset */ - H5D__none_idx_dump, /* dump */ - NULL /* dest */ + FALSE, /* Non-indexed chunking don't current support SWMR access */ + NULL, /* init */ + H5D__none_idx_create, /* create */ + H5D__none_idx_is_space_alloc, /* is_space_alloc */ + NULL, /* insert */ + H5D__none_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__none_idx_iterate, /* iterate */ + H5D__none_idx_remove, /* remove */ + H5D__none_idx_delete, /* delete */ + H5D__none_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__none_idx_size, /* size */ + H5D__none_idx_reset, /* reset */ + H5D__none_idx_dump, /* dump */ + NULL /* dest */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__none_idx_create * @@ -125,9 +113,9 @@ const H5D_chunk_ops_t H5D_COPS_NONE[1] = {{ static herr_t H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info) { - hsize_t nbytes; /* Total size of dataset chunks */ - haddr_t addr; /* The address of dataset chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Total size of dataset chunks */ + haddr_t addr; /* The address of dataset chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -139,15 +127,15 @@ H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout); HDassert(idx_info->storage); HDassert(idx_info->layout->max_nchunks); - HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* address of data shouldn't be defined */ + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* address of data shouldn't be defined */ /* Calculate size of max dataset chunks */ nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; /* Allocate space for max dataset chunks */ addr = H5MF_alloc(idx_info->f, H5FD_MEM_DRAW, nbytes); - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") + if (!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "file allocation failed") /* This is the address of the dataset chunks */ idx_info->storage->idx_addr = addr; @@ -156,7 +144,6 @@ H5D__none_idx_create(const H5D_chk_idx_info_t *idx_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_is_space_alloc * @@ -179,7 +166,6 @@ H5D__none_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__none_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_get_addr * @@ -208,19 +194,19 @@ H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* Calculate the index of this chunk */ - udata->chunk_idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, udata->common.scaled); + udata->chunk_idx = H5VM_array_offset_pre((idx_info->layout->ndims - 1), idx_info->layout->max_down_chunks, + udata->common.scaled); /* Calculate the address of the chunk */ udata->chunk_block.offset = idx_info->storage->idx_addr + udata->chunk_idx * idx_info->layout->size; /* Update the other (constant) information for the chunk */ udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->filter_mask = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__none_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_iterate * @@ -234,15 +220,14 @@ H5D__none_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata *------------------------------------------------------------------------- */ static int -H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_chunk_rec_t chunk_rec; /* generic chunk record */ - unsigned ndims; /* Rank of chunk */ - unsigned u; /* Local index variable */ - int curr_dim; /* Current rank */ - hsize_t idx; /* Array index of chunk */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5D_chunk_rec_t chunk_rec; /* generic chunk record */ + unsigned ndims; /* Rank of chunk */ + unsigned u; /* Local index variable */ + int curr_dim; /* Current rank */ + hsize_t idx; /* Array index of chunk */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -259,14 +244,14 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Initialize generic chunk record */ HDmemset(&chunk_rec, 0, sizeof(chunk_rec)); - chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.nbytes = idx_info->layout->size; chunk_rec.filter_mask = 0; ndims = idx_info->layout->ndims - 1; HDassert(ndims > 0); /* Iterate over all the chunks in the dataset's dataspace */ - for(u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { + for (u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { /* Calculate the index of this chunk */ idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); @@ -274,17 +259,18 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, chunk_rec.chunk_addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; /* Make "generic chunk" callback */ - if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, H5_ITER_ERROR, "failure in generic chunk iterator callback") + if ((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, H5_ITER_ERROR, + "failure in generic chunk iterator callback") /* Update coordinates of chunk in dataset */ curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Increment coordinate in current dimension */ chunk_rec.scaled[curr_dim]++; /* Check if we went off the end of the current dimension */ - if(chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { + if (chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { /* Reset coordinate & move to next faster dimension */ chunk_rec.scaled[curr_dim] = 0; curr_dim--; @@ -292,13 +278,12 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, else break; } /* end while */ - } /* end for */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_remove * @@ -315,7 +300,8 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, *------------------------------------------------------------------------- */ 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__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, + H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) { FUNC_ENTER_STATIC_NOERR @@ -324,7 +310,6 @@ H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chun FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__none_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_delete * @@ -340,8 +325,8 @@ H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, H5D_chun static herr_t H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) { - hsize_t nbytes; /* Size of all chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -352,11 +337,11 @@ H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(!idx_info->pline->nused); /* Shouldn't have filter defined on entering here */ HDassert(idx_info->layout); HDassert(idx_info->storage); - HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* should be defined */ + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); /* should be defined */ /* chunk size * max # of chunks */ nbytes = idx_info->layout->max_nchunks * idx_info->layout->size; - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks") idx_info->storage->idx_addr = HADDR_UNDEF; @@ -365,7 +350,6 @@ H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_copy_setup * @@ -379,9 +363,9 @@ 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -405,7 +389,7 @@ H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_inf H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Allocate dataset chunks in the dest. file */ - if(H5D__none_idx_create(idx_info_dst) < 0) + if (H5D__none_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Reset metadata tag */ @@ -415,7 +399,6 @@ H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_inf FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__none_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_size * @@ -441,7 +424,6 @@ H5D__none_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t *i FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_reset * @@ -462,13 +444,12 @@ H5D__none_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__none_idx_dump * @@ -489,8 +470,7 @@ H5D__none_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__none_idx_dump() */ - diff --git a/src/H5Doh.c b/src/H5Doh.c index 588123b6c3b..f6245d5be0a 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,78 +15,70 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -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 hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref); -static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +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 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); - +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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{ - H5O_TYPE_DATASET, /* object type */ - "dataset", /* object name, for debugging */ - H5O__dset_get_copy_file_udata, /* get 'copy file' user data */ + H5O_TYPE_DATASET, /* object type */ + "dataset", /* object name, for debugging */ + H5O__dset_get_copy_file_udata, /* get 'copy file' user data */ H5O__dset_free_copy_file_udata, /* free 'copy file' user data */ - H5O__dset_isa, /* "isa" message */ - H5O__dset_open, /* open an object of this class */ - H5O__dset_create, /* create an object of this class */ - H5O__dset_get_oloc, /* get an object header location for an object */ - H5O__dset_bh_info, /* get the index & heap info for an object */ - H5O__dset_flush /* flush an opened object of this class */ + H5O__dset_isa, /* "isa" message */ + H5O__dset_open, /* open an object of this class */ + H5O__dset_create, /* create an object of this class */ + H5O__dset_get_oloc, /* get an object header location for an object */ + H5O__dset_bh_info, /* get the index & heap info for an object */ + H5O__dset_flush /* flush an opened object of this class */ }}; /* Declare a free list to manage the H5D_copy_file_ud_t struct */ H5FL_DEFINE(H5D_copy_file_ud_t); - /*------------------------------------------------------------------------- * Function: H5O__dset_get_copy_file_udata * @@ -105,19 +97,18 @@ H5FL_DEFINE(H5D_copy_file_ud_t); static void * H5O__dset_get_copy_file_udata(void) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for the 'copy file' user data for copying datasets */ - if(NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5D_copy_file_ud_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_get_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_free_copy_file_udata * @@ -142,15 +133,15 @@ H5O__dset_free_copy_file_udata(void *_udata) HDassert(udata); /* Release copy of dataset's dataspace extent, if it was set */ - if(udata->src_space_extent) + if (udata->src_space_extent) H5O_msg_free(H5O_SDSPACE_ID, udata->src_space_extent); /* Release copy of dataset's datatype, if it was set */ - if(udata->src_dtype) + if (udata->src_dtype) H5T_close_real(udata->src_dtype); /* Release copy of dataset's filter pipeline, if it was set */ - if(udata->common.src_pline) + if (udata->common.src_pline) H5O_msg_free(H5O_PLINE_ID, udata->common.src_pline); /* Release space for 'copy file' user data */ @@ -159,7 +150,6 @@ H5O__dset_free_copy_file_udata(void *_udata) FUNC_LEAVE_NOAPI_VOID } /* end H5O__dset_free_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_isa * @@ -180,30 +170,29 @@ H5O__dset_free_copy_file_udata(void *_udata) static htri_t H5O__dset_isa(const H5O_t *oh) { - htri_t exists; /* Flag if header message of interest exists */ - htri_t ret_value = TRUE; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); /* Datatype */ - if((exists = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(!exists) + else if (!exists) HGOTO_DONE(FALSE) /* Layout */ - if((exists = H5O_msg_exists_oh(oh, H5O_SDSPACE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_SDSPACE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") - else if(!exists) + else if (!exists) HGOTO_DONE(FALSE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_isa() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_open * @@ -217,17 +206,19 @@ H5O__dset_isa(const H5O_t *oh) * *------------------------------------------------------------------------- */ -static hid_t -H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +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 */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5D_t *dset = NULL; /* Dataset opened */ + hid_t dapl_id; /* dapl to use to open this dataset */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_DATASET; + /* Get the LAPL (which is a superclass of DAPLs) from the API context, but * if it's the default link access property list or a custom link access * property list but not a dataset access property list, use the default @@ -235,39 +226,36 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) * additional properties that DAPLs have) */ dapl_id = H5CX_get_lapl(); - if(dapl_id == H5P_LINK_ACCESS_DEFAULT) + if (dapl_id == H5P_LINK_ACCESS_DEFAULT) dapl_id = H5P_DATASET_ACCESS_DEFAULT; else { - htri_t is_lapl, is_dapl; /* Class of LAPL from API context */ + htri_t is_lapl, is_dapl; /* Class of LAPL from API context */ /* Check class of LAPL from API context */ - if((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get LAPL status") - if((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get DAPL status") + if ((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get LAPL status") + if ((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get DAPL status") /* Switch to default DAPL if not an actual DAPL in the API context */ - if(!is_dapl && is_lapl) + if (!is_dapl && is_lapl) dapl_id = H5P_DATASET_ACCESS_DEFAULT; } /* end else */ /* Open the dataset */ - if(NULL == (dset = H5D_open(obj_loc, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") + if (NULL == (dset = H5D_open(obj_loc, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") - /* Register an ID for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") + ret_value = (void *)dset; done: - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + if (NULL == ret_value) + if (dset && H5D_close(dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_open() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_create * @@ -284,9 +272,9 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) 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_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 */ FUNC_ENTER_STATIC @@ -296,27 +284,27 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Create the the dataset */ - if(NULL == (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) + if (NULL == + (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") /* Set up the new dataset's location */ - if(NULL == (obj_loc->oloc = H5D_oloc(dset))) + if (NULL == (obj_loc->oloc = H5D_oloc(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of dataset") - if(NULL == (obj_loc->path = H5D_nameof(dset))) + if (NULL == (obj_loc->path = H5D_nameof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of dataset") /* Set the return value */ ret_value = dset; done: - if(ret_value == NULL) - if(dset && H5D_close(dset) < 0) + if (ret_value == NULL) + if (dset && H5D_close(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_create() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_get_oloc * @@ -333,24 +321,23 @@ 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 */ - H5O_loc_t *ret_value = NULL; /* Return value */ + H5D_t * dset; /* Dataset opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the dataset */ - if(NULL == (dset = (H5D_t *)H5I_object(obj_id))) + if (NULL == (dset = (H5D_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the dataset's object header location */ - if(NULL == (ret_value = H5D_oloc(dset))) + if (NULL == (ret_value = H5D_oloc(dset))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_get_oloc() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_bh_info * @@ -368,12 +355,12 @@ 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) { - H5O_layout_t layout; /* Data storage layout message */ - H5O_efl_t efl; /* External File List message */ - hbool_t layout_read = FALSE; /* Whether the layout message was read */ - hbool_t efl_read = FALSE; /* Whether the external file list message was read */ - htri_t exists; /* Flag if header message of interest exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t layout; /* Data storage layout message */ + H5O_efl_t efl; /* External File List message */ + hbool_t layout_read = FALSE; /* Whether the layout message was read */ + hbool_t efl_read = FALSE; /* Whether the external file list message was read */ + htri_t exists; /* Flag if header message of interest exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -385,57 +372,56 @@ H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Get the layout message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_LAYOUT_ID, &layout)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_LAYOUT_ID, &layout)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") layout_read = TRUE; /* Check for chunked dataset storage */ - if(layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { + if (layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { /* Get size of chunk index */ - if(H5D__chunk_bh_info(loc, oh, &layout, &(bh_info->index_size)) < 0) + if (H5D__chunk_bh_info(loc, oh, &layout, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info") } /* end if */ - else if(layout.type == H5D_VIRTUAL - && (layout.storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { + else if (layout.type == H5D_VIRTUAL && (layout.storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { size_t virtual_heap_size; /* Get size of global heap object for virtual dataset */ - if(H5HG_get_obj_size(loc->file, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping") + if (H5HG_get_obj_size(loc->file, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get global heap size for virtual dataset mapping") /* Return heap size */ bh_info->heap_size = (hsize_t)virtual_heap_size; } /* end if */ /* Check for External File List message in the object header */ - if((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") + if ((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") - if(exists && H5D__efl_is_space_alloc(&layout.storage)) { + if (exists && H5D__efl_is_space_alloc(&layout.storage)) { /* Start with clean EFL info */ HDmemset(&efl, 0, sizeof(efl)); - /* Get External File List message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_EFL_ID, &efl)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") + /* Get External File List message from the object header */ + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_EFL_ID, &efl)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") efl_read = TRUE; - /* Get size of local heap for EFL message's file list */ - if(H5D__efl_bh_info(loc->file, &efl, &(bh_info->heap_size)) < 0) + /* Get size of local heap for EFL message's file list */ + if (H5D__efl_bh_info(loc->file, &efl, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine EFL heap info") } /* end if */ done: /* Free messages, if they've been read in */ - if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if (layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") - if(efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) + if (efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_bh_info() */ - /*------------------------------------------------------------------------- * Function: H5O__dset_flush * @@ -452,9 +438,9 @@ 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 */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -462,15 +448,14 @@ H5O__dset_flush(void *_obj_ptr) HDassert(&dset->oloc); /* Check that the object found is the correct type */ - if(H5O_obj_type(&dset->oloc, &obj_type) < 0) + if (H5O_obj_type(&dset->oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) + if (obj_type != H5O_TYPE_DATASET) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(H5D__flush_real(dset) < 0) + if (H5D__flush_real(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_flush() */ - diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 3899a3bcb1a..64f2c7a263f 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,19 +23,19 @@ #error "Do not include this file outside the H5D package!" #endif -#ifndef _H5Dpkg_H -#define _H5Dpkg_H +#ifndef H5Dpkg_H +#define H5Dpkg_H /* Get package's private header */ #include "H5Dprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Package Private Macros */ @@ -45,42 +45,43 @@ #define H5D_MINHDR_SIZE 256 /* [Simple] Macro to construct a H5D_io_info_t from it's components */ -#define H5D_BUILD_IO_INFO_WRT(io_info, ds, str, buf) \ - (io_info)->dset = ds; \ - (io_info)->store = str; \ - (io_info)->op_type = H5D_IO_OP_WRITE; \ - (io_info)->u.wbuf = buf -#define H5D_BUILD_IO_INFO_RD(io_info, ds, str, buf) \ - (io_info)->dset = ds; \ - (io_info)->store = str; \ - (io_info)->op_type = H5D_IO_OP_READ; \ - (io_info)->u.rbuf = buf +#define H5D_BUILD_IO_INFO_WRT(io_info, ds, str, buf) \ + (io_info)->dset = ds; \ + (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ + (io_info)->store = str; \ + (io_info)->op_type = H5D_IO_OP_WRITE; \ + (io_info)->u.wbuf = buf +#define H5D_BUILD_IO_INFO_RD(io_info, ds, str, buf) \ + (io_info)->dset = ds; \ + (io_info)->f_sh = H5F_SHARED((ds)->oloc.file); \ + (io_info)->store = str; \ + (io_info)->op_type = H5D_IO_OP_READ; \ + (io_info)->u.rbuf = buf /* Flags for marking aspects of a dataset dirty */ #define H5D_MARK_SPACE 0x01 -#define H5D_MARK_LAYOUT 0x02 +#define H5D_MARK_LAYOUT 0x02 /* Default creation parameters for chunk index data structures */ /* See H5O_layout_chunk_t */ /* Fixed array creation values */ -#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ -#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ +#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* Extensible array creation values */ -#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ -#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ +#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ +#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ #define H5D_EARRAY_IDX_BLK_ELMTS 4 #define H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS 4 #define H5D_EARRAY_DATA_BLK_MIN_ELMTS 16 -#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* v2 B-tree creation values for raw meta_size */ -#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ -#define H5D_BT2_NODE_SIZE 2048 -#define H5D_BT2_SPLIT_PERC 100 -#define H5D_BT2_MERGE_PERC 40 - +#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ +#define H5D_BT2_NODE_SIZE 2048 +#define H5D_BT2_SPLIT_PERC 100 +#define H5D_BT2_MERGE_PERC 40 /****************************/ /* Package Private Typedefs */ @@ -89,25 +90,25 @@ /* Typedef for datatype information for raw data I/O operation */ 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 */ - hid_t src_type_id; /* Source datatype ID */ - hid_t dst_type_id; /* Destination datatype ID */ + 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 */ + hid_t src_type_id; /* Source datatype ID */ + hid_t dst_type_id; /* Destination datatype ID */ /* Computed/derived values */ - size_t src_type_size; /* Size of source type */ - size_t dst_type_size; /* Size of destination type */ - size_t max_type_size; /* Size of largest source/destination type */ - hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ - hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ - 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 */ - hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ - uint8_t *bkg_buf; /* Background buffer */ - hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ + size_t src_type_size; /* Size of source type */ + size_t dst_type_size; /* Size of destination type */ + size_t max_type_size; /* Size of largest source/destination type */ + hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ + hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ + 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 */ + hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ + uint8_t * bkg_buf; /* Background buffer */ + hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; /* Forward declaration of structs used below */ @@ -117,121 +118,127 @@ typedef struct H5D_shared_t H5D_shared_t; /* Function pointers for I/O on particular types of dataset layouts */ typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, H5D_t *dset); -typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, const H5D_t *dset, - hid_t dapl_id); +typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, const H5D_t *dset, hid_t dapl_id); 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); -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, 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, 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[], 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[]); -typedef ssize_t (*H5D_layout_writevv_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[], 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[]); + 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); +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, + 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, + 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[], + 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[]); +typedef ssize_t (*H5D_layout_writevv_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[], + 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[]); typedef herr_t (*H5D_layout_flush_func_t)(H5D_t *dataset); typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm); typedef herr_t (*H5D_layout_dest_func_t)(H5D_t *dataset); /* Typedef for grouping layout I/O routines */ typedef struct H5D_layout_ops_t { - H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ - H5D_layout_init_func_t init; /* Layout initializer for dataset */ - H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ - H5D_layout_is_data_cached_func_t is_data_cached; /* Query routine to determine if any raw data is cached. If routine is not present then the layout type never caches raw data. */ - H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ - H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ - H5D_layout_write_func_t ser_write; /* High-level I/O routine for writing data in serial */ + H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ + H5D_layout_init_func_t init; /* Layout initializer for dataset */ + H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ + H5D_layout_is_data_cached_func_t + is_data_cached; /* Query routine to determine if any raw data is cached. If routine is not present + then the layout type never caches raw data. */ + H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ + H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ + H5D_layout_write_func_t ser_write; /* High-level I/O routine for writing data in serial */ #ifdef H5_HAVE_PARALLEL - H5D_layout_read_func_t par_read; /* High-level I/O routine for reading data in parallel */ - H5D_layout_write_func_t par_write; /* High-level I/O routine for writing data in parallel */ -#endif /* H5_HAVE_PARALLEL */ - H5D_layout_readvv_func_t readvv; /* Low-level I/O routine for reading data */ - H5D_layout_writevv_func_t writevv; /* Low-level I/O routine for writing data */ - H5D_layout_flush_func_t flush; /* Low-level I/O routine for flushing raw data */ - H5D_layout_io_term_func_t io_term; /* I/O shutdown routine */ - H5D_layout_dest_func_t dest; /* Destroy layout info */ + H5D_layout_read_func_t par_read; /* High-level I/O routine for reading data in parallel */ + H5D_layout_write_func_t par_write; /* High-level I/O routine for writing data in parallel */ +#endif /* H5_HAVE_PARALLEL */ + H5D_layout_readvv_func_t readvv; /* Low-level I/O routine for reading data */ + H5D_layout_writevv_func_t writevv; /* Low-level I/O routine for writing data */ + H5D_layout_flush_func_t flush; /* Low-level I/O routine for flushing raw data */ + H5D_layout_io_term_func_t io_term; /* I/O shutdown routine */ + H5D_layout_dest_func_t dest; /* Destroy layout info */ } 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); + const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const 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); + const H5D_type_info_t *type_info, hsize_t nelmts, + const H5S_t *file_space, const H5S_t *mem_space); /* Typedef for raw data I/O framework info */ typedef struct H5D_io_ops_t { - H5D_layout_read_func_t multi_read; /* High-level I/O routine for reading data */ - H5D_layout_write_func_t multi_write; /* High-level I/O routine for writing data */ - H5D_io_single_read_func_t single_read; /* I/O routine for reading single block */ - H5D_io_single_write_func_t single_write; /* I/O routine for writing single block */ + H5D_layout_read_func_t multi_read; /* High-level I/O routine for reading data */ + H5D_layout_write_func_t multi_write; /* High-level I/O routine for writing data */ + H5D_io_single_read_func_t single_read; /* I/O routine for reading single block */ + H5D_io_single_write_func_t single_write; /* I/O routine for writing single block */ } H5D_io_ops_t; /* Typedefs for dataset storage information */ typedef struct { - haddr_t dset_addr; /* Address of dataset in file */ - hsize_t dset_size; /* Total size of dataset in file */ + haddr_t dset_addr; /* Address of dataset in file */ + hsize_t dset_size; /* Total size of dataset in file */ } H5D_contig_storage_t; typedef struct { - hsize_t *scaled; /* Scaled coordinates for a chunk */ + hsize_t *scaled; /* Scaled coordinates for a chunk */ } H5D_chunk_storage_t; typedef struct { - void *buf; /* Buffer for compact dataset */ - hbool_t *dirty; /* Pointer to dirty flag to mark */ + void * buf; /* Buffer for compact dataset */ + hbool_t *dirty; /* Pointer to dirty flag to mark */ } H5D_compact_storage_t; typedef union H5D_storage_t { - H5D_contig_storage_t contig; /* Contiguous information for dataset */ - H5D_chunk_storage_t chunk; /* Chunk information for dataset */ + H5D_contig_storage_t contig; /* Contiguous information for dataset */ + H5D_chunk_storage_t chunk; /* Chunk information for dataset */ H5D_compact_storage_t compact; /* Compact information for dataset */ - H5O_efl_t efl; /* External file list information for dataset */ + H5O_efl_t efl; /* External file list information for dataset */ } H5D_storage_t; /* Typedef for raw data I/O operation info */ typedef enum H5D_io_op_type_t { - H5D_IO_OP_READ, /* Read operation */ - H5D_IO_OP_WRITE /* Write operation */ + H5D_IO_OP_READ, /* Read operation */ + H5D_IO_OP_WRITE /* Write operation */ } H5D_io_op_type_t; typedef struct H5D_io_info_t { - const H5D_t *dset; /* Pointer to dataset being operated on */ + const H5D_t *dset; /* Pointer to dataset being operated on */ + /* QAK: Delete the f_sh field when oloc has a shared file pointer? */ + H5F_shared_t *f_sh; /* Pointer to shared file struct that dataset is within */ #ifdef H5_HAVE_PARALLEL - 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_layout_ops_t layout_ops; /* Dataset layout I/O operation function pointers */ - H5D_io_ops_t io_ops; /* I/O operation function pointers */ + 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_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 */ - const void *wbuf; /* Pointer to buffer to write */ + void * rbuf; /* Pointer to buffer for read */ + const void *wbuf; /* Pointer to buffer to write */ } u; } H5D_io_info_t; - /******************/ /* Chunk typedefs */ /******************/ /* 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 */ - H5O_storage_chunk_t *storage; /* Chunk storage 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; /* @@ -246,10 +253,10 @@ typedef struct H5D_chk_idx_info_t { * The chunk's file address, filter mask and size on disk are not key values. */ typedef struct H5D_chunk_rec_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ - uint32_t nbytes; /* Size of stored data */ - uint32_t filter_mask; /* Excluded filters */ - haddr_t chunk_addr; /* Address of chunk in file */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ + uint32_t nbytes; /* Size of stored data */ + uint32_t filter_mask; /* Excluded filters */ + haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; /* @@ -258,124 +265,121 @@ 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_storage_chunk_t *storage; /* Chunk storage description */ - const hsize_t *scaled; /* Scaled coordinates for a chunk */ + 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 */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ typedef struct H5D_chunk_ud_t { /* Downward */ - H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ + H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* Upward */ - unsigned idx_hint; /* Index of chunk in cache, if present */ - H5F_block_t chunk_block; /* Offset/length of chunk in file */ - unsigned filter_mask; /* Excluded filters */ - hbool_t new_unfilt_chunk; /* Whether the chunk just became unfiltered */ - hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + H5F_block_t chunk_block; /* Offset/length of chunk in file */ + unsigned filter_mask; /* Excluded filters */ + hbool_t new_unfilt_chunk; /* Whether the chunk just became unfiltered */ + hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ -typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, - void *udata); +typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, void *udata); /* Typedefs for chunk operations */ -typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); +typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); typedef herr_t (*H5D_chunk_create_func_t)(const H5D_chk_idx_info_t *idx_info); typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_storage_chunk_t *storage); -typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); +typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); typedef herr_t (*H5D_chunk_resize_func_t)(H5O_layout_chunk_t *layout); -typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); +typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); typedef herr_t (*H5D_chunk_delete_func_t)(const H5D_chk_idx_info_t *idx_info); typedef herr_t (*H5D_chunk_copy_setup_func_t)(const H5D_chk_idx_info_t *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); + const H5D_chk_idx_info_t *idx_info_dst); typedef herr_t (*H5D_chunk_copy_shutdown_func_t)(H5O_storage_chunk_t *storage_src, - H5O_storage_chunk_t *storage_dst); -typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info, - hsize_t *idx_size); + H5O_storage_chunk_t *storage_dst); +typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info, hsize_t *idx_size); typedef herr_t (*H5D_chunk_reset_func_t)(H5O_storage_chunk_t *storage, hbool_t reset_addr); -typedef herr_t (*H5D_chunk_dump_func_t)(const H5O_storage_chunk_t *storage, - FILE *stream); +typedef herr_t (*H5D_chunk_dump_func_t)(const H5O_storage_chunk_t *storage, FILE *stream); typedef herr_t (*H5D_chunk_dest_func_t)(const H5D_chk_idx_info_t *idx_info); /* Typedef for grouping chunk I/O routines */ typedef struct H5D_chunk_ops_t { - hbool_t can_swim; /* Flag to indicate that the index supports SWMR access */ - H5D_chunk_init_func_t init; /* Routine to initialize indexing information in memory */ - H5D_chunk_create_func_t create; /* Routine to create chunk index */ - H5D_chunk_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage/index is allocated */ - H5D_chunk_insert_func_t insert; /* Routine to insert a chunk into an index */ - H5D_chunk_get_addr_func_t get_addr; /* Routine to retrieve address of chunk in file */ - H5D_chunk_resize_func_t resize; /* Routine to update chunk index info after resizing dataset */ - H5D_chunk_iterate_func_t iterate; /* Routine to iterate over chunks */ - H5D_chunk_remove_func_t remove; /* Routine to remove a chunk from an index */ - H5D_chunk_delete_func_t idx_delete; /* Routine to delete index & all chunks from file*/ + hbool_t can_swim; /* Flag to indicate that the index supports SWMR access */ + H5D_chunk_init_func_t init; /* Routine to initialize indexing information in memory */ + H5D_chunk_create_func_t create; /* Routine to create chunk index */ + H5D_chunk_is_space_alloc_func_t + is_space_alloc; /* Query routine to determine if storage/index is allocated */ + H5D_chunk_insert_func_t insert; /* Routine to insert a chunk into an index */ + H5D_chunk_get_addr_func_t get_addr; /* Routine to retrieve address of chunk in file */ + H5D_chunk_resize_func_t resize; /* Routine to update chunk index info after resizing dataset */ + H5D_chunk_iterate_func_t iterate; /* Routine to iterate over chunks */ + H5D_chunk_remove_func_t remove; /* Routine to remove a chunk from an index */ + H5D_chunk_delete_func_t idx_delete; /* Routine to delete index & all chunks from file*/ H5D_chunk_copy_setup_func_t copy_setup; /* Routine to perform any necessary setup for copying chunks */ - H5D_chunk_copy_shutdown_func_t copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */ - H5D_chunk_size_func_t size; /* Routine to get size of indexing information */ - H5D_chunk_reset_func_t reset; /* Routine to reset indexing information */ - H5D_chunk_dump_func_t dump; /* Routine to dump indexing information */ - H5D_chunk_dest_func_t dest; /* Routine to destroy indexing information in memory */ + H5D_chunk_copy_shutdown_func_t + copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */ + H5D_chunk_size_func_t size; /* Routine to get size of indexing information */ + H5D_chunk_reset_func_t reset; /* Routine to reset indexing information */ + H5D_chunk_dump_func_t dump; /* Routine to dump indexing information */ + H5D_chunk_dest_func_t dest; /* Routine to destroy indexing information in memory */ } H5D_chunk_ops_t; /* Structure holding information about a chunk's selection for mapping */ 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 */ - 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 */ - hbool_t mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ + 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 */ + 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 */ + hbool_t mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ } H5D_chunk_info_t; /* Main structure holding the mapping between file chunks and memory */ typedef struct H5D_chunk_map_t { - H5O_layout_t *layout; /* Dataset layout information*/ - hsize_t nelmts; /* Number of elements selected in file & memory dataspaces */ + 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 */ + const 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 */ + const 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 */ - H5S_sel_type fsel_type; /* Selection type in file */ + unsigned m_ndims; /* Number of dimensions for memory dataspace */ + H5S_sel_type msel_type; /* Selection type in memory */ + H5S_sel_type fsel_type; /* Selection type in file */ - H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ + H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ - 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 */ + 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 */ - hsize_t last_index; /* Index of last chunk operated on */ - H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ + hsize_t last_index; /* Index of last chunk operated on */ + H5D_chunk_info_t *last_chunk_info; /* Pointer to last chunk's info */ - hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ + hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ #ifdef H5_HAVE_PARALLEL - H5D_chunk_info_t **select_chunk; /* Store the information about whether this chunk is selected or not */ -#endif /* H5_HAVE_PARALLEL */ + H5D_chunk_info_t **select_chunk; /* Store the information about whether this chunk is selected or not */ +#endif /* H5_HAVE_PARALLEL */ } H5D_chunk_map_t; /* Cached information about a particular chunk */ typedef struct H5D_chunk_cached_t { - hbool_t valid; /*whether cache info is valid*/ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ - haddr_t addr; /*file address of chunk */ - uint32_t nbytes; /*size of stored data */ - hsize_t chunk_idx; /*index of chunk in dataset */ - unsigned filter_mask; /*excluded filters */ + hbool_t valid; /*whether cache info is valid*/ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ + haddr_t addr; /*file address of chunk */ + uint32_t nbytes; /*size of stored data */ + hsize_t chunk_idx; /*index of chunk in dataset */ + unsigned filter_mask; /*excluded filters */ } H5D_chunk_cached_t; /****************************/ @@ -384,46 +388,48 @@ 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 */ - struct H5D_virtual_held_file_t *next; /* Pointer to next node in list */ + 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; /* The raw data chunk cache */ -struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ +struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ typedef struct H5D_rdcc_t { struct { - unsigned ninits; /* Number of chunk creations */ - unsigned nhits; /* Number of cache hits */ - unsigned nmisses; /* Number of cache misses */ - unsigned nflushes; /* Number of cache flushes */ + unsigned ninits; /* Number of chunk creations */ + unsigned nhits; /* Number of cache hits */ + unsigned nmisses; /* Number of cache misses */ + unsigned nflushes; /* Number of cache flushes */ } stats; - size_t nbytes_max; /* Maximum cached raw data in bytes */ - size_t nslots; /* Number of chunk slots allocated */ - double w0; /* Chunk preemption policy */ - struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ - struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ - struct H5D_rdcc_ent_t *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table (slot). The head entry is a sentinel (does not refer to an actual chunk). */ - size_t nbytes_used; /* Current cached raw data in bytes */ - 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 */ + size_t nbytes_max; /* Maximum cached raw data in bytes */ + size_t nslots; /* Number of chunk slots allocated */ + double w0; /* Chunk preemption policy */ + struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ + struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ + struct H5D_rdcc_ent_t + *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table + (slot). The head entry is a sentinel (does not refer to an actual chunk). */ + size_t nbytes_used; /* Current cached raw data in bytes */ + 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 */ /* Cached information about scaled dataspace dimensions */ - hsize_t scaled_dims[H5S_MAX_RANK]; /* The scaled dim sizes */ - hsize_t scaled_power2up[H5S_MAX_RANK]; /* The scaled dim sizes, rounded up to next power of 2 */ - unsigned scaled_encode_bits[H5S_MAX_RANK]; /* The number of bits needed to encode the scaled dim sizes */ + hsize_t scaled_dims[H5S_MAX_RANK]; /* The scaled dim sizes */ + hsize_t scaled_power2up[H5S_MAX_RANK]; /* The scaled dim sizes, rounded up to next power of 2 */ + unsigned scaled_encode_bits[H5S_MAX_RANK]; /* The number of bits needed to encode the scaled dim sizes */ } H5D_rdcc_t; /* The raw data contiguous data cache */ typedef struct H5D_rdcdc_t { - unsigned char *sieve_buf; /* Buffer to hold data sieve buffer */ - haddr_t sieve_loc; /* File location (offset) of the data sieve buffer */ - size_t sieve_size; /* Size of the data sieve buffer used (in bytes) */ - size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ - hbool_t sieve_dirty; /* Flag to indicate that the data sieve buffer is dirty */ + unsigned char *sieve_buf; /* Buffer to hold data sieve buffer */ + haddr_t sieve_loc; /* File location (offset) of the data sieve buffer */ + size_t sieve_size; /* Size of the data sieve buffer used (in bytes) */ + size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ + hbool_t sieve_dirty; /* Flag to indicate that the data sieve buffer is dirty */ } H5D_rdcdc_t; /* @@ -433,96 +439,86 @@ typedef struct H5D_rdcdc_t { * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t. */ 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 */ - 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 */ - H5O_layout_t layout; /* Data layout */ - hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ + 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 */ + 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 */ + H5O_layout_t layout; /* Data layout */ + hbool_t checked_filters; /* TRUE if dataset passes can_apply check */ /* Cached dataspace info */ - unsigned ndims; /* The dataset's dataspace rank */ - hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ - hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ - hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ + unsigned ndims; /* The dataset's dataspace rank */ + hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ + hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ + hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ /* Buffered/cached information for types of raw data storage*/ struct { - H5D_rdcdc_t contig; /* Information about contiguous data */ - /* (Note that the "contig" cache - * information can be used by a chunked - * dataset in certain circumstances) - */ - H5D_rdcc_t chunk; /* Information about chunked data */ + H5D_rdcdc_t contig; /* Information about contiguous data */ + /* (Note that the "contig" cache + * information can be used by a chunked + * dataset in certain circumstances) + */ + H5D_rdcc_t chunk; /* Information about chunked data */ } cache; - H5D_append_flush_t append_flush; /* Append flush property information */ - char *extfile_prefix; /* expanded external file prefix */ - char *vds_prefix; /* expanded vds prefix */ + H5D_append_flush_t append_flush; /* Append flush property information */ + char * extfile_prefix; /* expanded external file prefix */ + char * vds_prefix; /* expanded vds prefix */ }; struct H5D_t { - H5O_loc_t oloc; /* Object header location */ - H5G_name_t path; /* Group hierarchy path */ - H5D_shared_t *shared; /* cached information from file */ + H5O_loc_t oloc; /* Object header location */ + H5G_name_t path; /* Group hierarchy path */ + H5D_shared_t *shared; /* cached information from file */ }; /* Enumerated type for allocating dataset's storage */ typedef enum { - H5D_ALLOC_CREATE, /* Dataset is being created */ - H5D_ALLOC_OPEN, /* Dataset is being opened */ - H5D_ALLOC_EXTEND, /* Dataset's dataspace is being extended */ - H5D_ALLOC_WRITE /* Dataset is being extended */ + H5D_ALLOC_CREATE, /* Dataset is being created */ + H5D_ALLOC_OPEN, /* Dataset is being opened */ + H5D_ALLOC_EXTEND, /* Dataset's dataspace is being extended */ + H5D_ALLOC_WRITE /* Dataset is being extended */ } H5D_time_alloc_t; - /* Typedef for dataset creation operation */ typedef struct { - hid_t type_id; /* Datatype for dataset */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t dcpl_id; /* Dataset creation property list */ - hid_t dapl_id; /* Dataset access property list */ + hid_t type_id; /* Datatype for dataset */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t dcpl_id; /* Dataset creation property list */ + hid_t dapl_id; /* Dataset access property list */ } H5D_obj_create_t; /* 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 */ - H5MM_free_t fill_free_func; /* Routine to call for freeing fill buffer */ - 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 */ - 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 */ - 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 */ - 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 */ - size_t max_elmt_size; /* Max. size of memory or file datatype */ - size_t elmts_per_buf; /* # of elements that fit into a buffer */ - hbool_t has_vlen_fill_type; /* Whether the datatype for the fill value has a variable-length component */ + H5MM_allocate_t fill_alloc_func; /* Routine to call for allocating fill buffer */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ + size_t max_elmt_size; /* Max. size of memory or file datatype */ + size_t elmts_per_buf; /* # of elements that fit into a buffer */ + hbool_t has_vlen_fill_type; /* Whether the datatype for the fill value has a variable-length component */ } H5D_fill_buf_info_t; -/* Internal data structure for computing variable-length dataset's total size */ -typedef struct { - H5D_t *dset; /* Dataset for operation */ - H5S_t *fspace; /* Dataset's dataspace for operation */ - H5S_t *mspace; /* Memory dataspace for operation */ - 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 */ - hsize_t size; /* Accumulated number of bytes for the selection */ -} H5D_vlen_bufsize_t; - - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -549,166 +545,150 @@ H5_DLLVAR const H5B2_class_t H5D_BT2_FILT[1]; /* Array of versions for Layout */ 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 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); -H5_DLL 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[]); -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__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 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); +H5_DLL 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[]); +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__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 haddr_t H5D__get_offset(const H5D_t *dset); -H5_DLL void *H5D__vlen_get_buf_size_alloc(size_t size, void *info); -H5_DLL herr_t H5D__vlen_get_buf_size(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *op_data); -H5_DLL herr_t H5D__check_filters(H5D_t *dataset); -H5_DLL herr_t H5D__set_extent(H5D_t *dataset, const hsize_t *size); -H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset); -H5_DLL herr_t H5D__flush_real(H5D_t *dataset); -H5_DLL herr_t H5D__flush(H5D_t *dset, hid_t dset_id); -H5_DLL herr_t H5D__mark(const H5D_t *dataset, unsigned flags); -H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); +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, + hsize_t *size); +H5_DLL herr_t H5D__set_extent(H5D_t *dataset, const hsize_t *size); +H5_DLL herr_t H5D__flush_sieve_buf(H5D_t *dataset); +H5_DLL herr_t H5D__flush_real(H5D_t *dataset); +H5_DLL herr_t H5D__flush(H5D_t *dset, hid_t dset_id); +H5_DLL herr_t H5D__mark(const H5D_t *dataset, unsigned flags); +H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); /* To convert a dataset's chunk indexing type to v1 B-tree */ 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, 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, const void *buf); +H5_DLL 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*/); +H5_DLL 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); /* 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); -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); +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); +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); /* 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); -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); +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); +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); /* Functions that operate on dataset's layout information */ H5_DLL herr_t H5D__layout_set_io_ops(const H5D_t *dataset); -H5_DLL size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, - hbool_t include_compact_data); +H5_DLL size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data); H5_DLL herr_t H5D__layout_set_version(H5F_t *f, H5O_layout_t *layout); -H5_DLL herr_t H5D__layout_set_latest_indexing(H5O_layout_t *layout, - const H5S_t *space, const H5D_dcpl_cache_t *dcpl_cache); -H5_DLL herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, - hid_t dapl_id); -H5_DLL herr_t H5D__layout_oh_read(H5D_t *dset, hid_t dapl_id, - H5P_genplist_t *plist); +H5_DLL herr_t H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, + const H5D_dcpl_cache_t *dcpl_cache); +H5_DLL herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id); +H5_DLL herr_t H5D__layout_oh_read(H5D_t *dset, hid_t dapl_id, H5P_genplist_t *plist); H5_DLL herr_t H5D__layout_oh_write(const H5D_t *dataset, H5O_t *oh, unsigned update_flags); /* Functions that operate on contiguous storage */ -H5_DLL herr_t H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage); +H5_DLL herr_t H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage); 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); -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); -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); +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); +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); +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); /* Functions that operate on chunked dataset storage */ -H5_DLL htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, - hbool_t write_op); -H5_DLL herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/); -H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); +H5_DLL htri_t H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_op); +H5_DLL herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/); +H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); H5_DLL hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage); H5_DLL hbool_t H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset); -H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, - H5D_chunk_ud_t *udata); -H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes); -H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, 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, hsize_t scaled[]); -H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); -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); +H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udata); +H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes); +H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, + 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 herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); +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 H5_DLL herr_t H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]); #endif /* H5_HAVE_PARALLEL */ H5_DLL herr_t H5D__chunk_update_cache(H5D_t *dset); -H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, - H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, - const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, - const H5O_pline_t *pline_src, H5O_copy_t *cpy_info); -H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, - H5O_layout_t *layout, hsize_t *btree_size); +H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk_t *layout_src, + H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, + const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, + const H5O_pline_t *pline_src, H5O_copy_t *cpy_info); +H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_t *btree_size); H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, FILE *stream); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *store); -H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, - hsize_t *offset, uint32_t data_size, const void *buf); -H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, - uint32_t *filters, void *buf); +H5_DLL herr_t H5D__get_offset_copy(const H5D_t *dset, const hsize_t *offset, hsize_t *offset_copy); +H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, + uint32_t data_size, const void *buf); +H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t *filters, void *buf); #ifdef H5D_CHUNK_DEBUG H5_DLL herr_t H5D__chunk_stats(const H5D_t *dset, hbool_t headers); #endif /* H5D_CHUNK_DEBUG */ /* format convert */ -H5_DLL herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx_info_t *new_idx_info); +H5_DLL herr_t H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, + H5D_chk_idx_info_t *new_idx_info); /* Functions that operate on compact dataset storage */ H5_DLL herr_t H5D__compact_fill(const H5D_t *dset); -H5_DLL herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, - H5F_t *f_dst, H5O_storage_compact_t *storage_dst, H5T_t *src_dtype, - H5O_copy_t *cpy_info); +H5_DLL herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst, + H5O_storage_compact_t *storage_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info); /* Functions that operate on virtual dataset storage */ -H5_DLL herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_copy_layout(H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset); -H5_DLL herr_t H5D__virtual_reset_layout(H5O_layout_t *layout); -H5_DLL herr_t H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage); -H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src, H5O_layout_t *layout_dst); -H5_DLL herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); +H5_DLL herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_copy_layout(H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset); +H5_DLL herr_t H5D__virtual_reset_layout(H5O_layout_t *layout); +H5_DLL herr_t H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage); +H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src, H5O_layout_t *layout_dst); +H5_DLL herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); H5_DLL hbool_t H5D__virtual_is_space_alloc(const H5O_storage_t *storage); -H5_DLL herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, - H5D_virtual_held_file_t **head); -H5_DLL herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset); -H5_DLL herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head); +H5_DLL herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t **head); +H5_DLL herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset); +H5_DLL herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head); /* Functions that operate on EFL (External File List)*/ H5_DLL hbool_t H5D__efl_is_space_alloc(const H5O_storage_t *storage); -H5_DLL herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size); +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); -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); +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); +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); H5_DLL herr_t H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts); H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); @@ -718,38 +698,35 @@ H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); #ifndef H5Dmpio_DEBUG #define H5Dmpio_DEBUG #endif /*H5Dmpio_DEBUG*/ -#endif/*H5S_DEBUG*/ +#endif /*H5S_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); +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); /* 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); +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); /* 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, 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, H5D_chunk_map_t *fm); +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, + 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, + 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, 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, H5D_chunk_map_t *fm); +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, + 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, + 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 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); #endif /* H5_HAVE_PARALLEL */ @@ -763,5 +740,4 @@ H5_DLL herr_t H5D__layout_type_test(hid_t did, H5D_layout_t *layout_type); H5_DLL herr_t H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused); #endif /* H5D_TESTING */ -#endif /*_H5Dpkg_H*/ - +#endif /*H5Dpkg_H*/ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 6fb788943f9..f9ef7727b98 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,18 +14,17 @@ /* * This file contains private information about the H5D module */ -#ifndef _H5Dprivate_H -#define _H5Dprivate_H +#ifndef H5Dprivate_H +#define H5Dprivate_H /* Include package's public header */ #include "H5Dpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ @@ -37,89 +36,90 @@ * to have any effect. */ #ifdef NDEBUG -# undef H5D_DEBUG +#undef H5D_DEBUG #endif /* ======== Dataset creation property names ======== */ -#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ -#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ -#define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ -#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ -#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize"/* Minimize object header */ +#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ +#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ +#define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ +#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize" /* Minimize object header */ /* ======== Dataset access property names ======== */ -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ -#define H5D_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ -#define H5D_ACS_VDS_VIEW_NAME "vds_view" /* VDS view option */ -#define H5D_ACS_VDS_PRINTF_GAP_NAME "vds_printf_gap" /* VDS printf gap size */ -#define H5D_ACS_VDS_PREFIX_NAME "vds_prefix" /* VDS file prefix */ -#define H5D_ACS_APPEND_FLUSH_NAME "append_flush" /* Append flush actions */ -#define H5D_ACS_EFILE_PREFIX_NAME "external file prefix" /* External file prefix */ +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ +#define H5D_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ +#define H5D_ACS_VDS_VIEW_NAME "vds_view" /* VDS view option */ +#define H5D_ACS_VDS_PRINTF_GAP_NAME "vds_printf_gap" /* VDS printf gap size */ +#define H5D_ACS_VDS_PREFIX_NAME "vds_prefix" /* VDS file prefix */ +#define H5D_ACS_APPEND_FLUSH_NAME "append_flush" /* Append flush actions */ +#define H5D_ACS_EFILE_PREFIX_NAME "external file prefix" /* External file prefix */ /* ======== Data transfer properties ======== */ -#define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ -#define H5D_XFER_TCONV_BUF_NAME "tconv_buf" /* Type conversion buffer */ -#define H5D_XFER_BKGR_BUF_NAME "bkgr_buf" /* Background buffer */ -#define H5D_XFER_BKGR_BUF_TYPE_NAME "bkgr_buf_type" /* Background buffer type */ -#define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" /* B-tree node splitting ratio */ -#define H5D_XFER_VLEN_ALLOC_NAME "vlen_alloc" /* Vlen allocation function */ -#define H5D_XFER_VLEN_ALLOC_INFO_NAME "vlen_alloc_info" /* Vlen allocation info */ -#define H5D_XFER_VLEN_FREE_NAME "vlen_free" /* Vlen free function */ -#define H5D_XFER_VLEN_FREE_INFO_NAME "vlen_free_info" /* Vlen free info */ -#define H5D_XFER_VFL_ID_NAME "vfl_id" /* File driver ID */ -#define H5D_XFER_VFL_INFO_NAME "vfl_info" /* File driver info */ -#define H5D_XFER_HYPER_VECTOR_SIZE_NAME "vec_size" /* Hyperslab vector size */ -#define H5D_XFER_IO_XFER_MODE_NAME "io_xfer_mode" /* I/O transfer mode */ -#define H5D_XFER_MPIO_COLLECTIVE_OPT_NAME "mpio_collective_opt" /* Optimization of MPI-IO transfer mode */ -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME "mpio_chunk_opt_hard" -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME "mpio_chunk_opt_num" -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME "mpio_chunk_opt_ratio" +#define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ +#define H5D_XFER_TCONV_BUF_NAME "tconv_buf" /* Type conversion buffer */ +#define H5D_XFER_BKGR_BUF_NAME "bkgr_buf" /* Background buffer */ +#define H5D_XFER_BKGR_BUF_TYPE_NAME "bkgr_buf_type" /* Background buffer type */ +#define H5D_XFER_BTREE_SPLIT_RATIO_NAME "btree_split_ratio" /* B-tree node splitting ratio */ +#define H5D_XFER_VLEN_ALLOC_NAME "vlen_alloc" /* Vlen allocation function */ +#define H5D_XFER_VLEN_ALLOC_INFO_NAME "vlen_alloc_info" /* Vlen allocation info */ +#define H5D_XFER_VLEN_FREE_NAME "vlen_free" /* Vlen free function */ +#define H5D_XFER_VLEN_FREE_INFO_NAME "vlen_free_info" /* Vlen free info */ +#define H5D_XFER_VFL_ID_NAME "vfl_id" /* File driver ID */ +#define H5D_XFER_VFL_INFO_NAME "vfl_info" /* File driver info */ +#define H5D_XFER_HYPER_VECTOR_SIZE_NAME "vec_size" /* Hyperslab vector size */ +#define H5D_XFER_IO_XFER_MODE_NAME "io_xfer_mode" /* I/O transfer mode */ +#define H5D_XFER_MPIO_COLLECTIVE_OPT_NAME "mpio_collective_opt" /* Optimization of MPI-IO transfer mode */ +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME "mpio_chunk_opt_hard" +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME "mpio_chunk_opt_num" +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME "mpio_chunk_opt_ratio" #define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME "actual_chunk_opt_mode" -#define H5D_MPIO_ACTUAL_IO_MODE_NAME "actual_io_mode" -#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME "local_no_collective_cause" /* cause of broken collective I/O in each process */ -#define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME "global_no_collective_cause" /* cause of broken collective I/O in all processes */ -#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ -#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ -#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ -#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ +#define H5D_MPIO_ACTUAL_IO_MODE_NAME "actual_io_mode" +#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME \ + "local_no_collective_cause" /* cause of broken collective I/O in each process */ +#define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME \ + "global_no_collective_cause" /* cause of broken collective I/O in all processes */ +#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ +#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ +#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ +#define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ -#define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" -#define H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME "coll_chunk_multi_hard" -#define H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME "coll_chunk_link_true" -#define H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME "coll_chunk_link_false" +#define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" +#define H5D_XFER_COLL_CHUNK_MULTI_HARD_NAME "coll_chunk_multi_hard" +#define H5D_XFER_COLL_CHUNK_LINK_NUM_TRUE_NAME "coll_chunk_link_true" +#define H5D_XFER_COLL_CHUNK_LINK_NUM_FALSE_NAME "coll_chunk_link_false" #define H5D_XFER_COLL_CHUNK_MULTI_RATIO_COLL_NAME "coll_chunk_multi_coll" -#define H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME "coll_chunk_multi_ind" +#define H5D_XFER_COLL_CHUNK_MULTI_RATIO_IND_NAME "coll_chunk_multi_ind" /* Definitions for all collective chunk instrumentation properties */ -#define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) -#define H5D_XFER_COLL_CHUNK_DEF 1 +#define H5D_XFER_COLL_CHUNK_SIZE sizeof(unsigned) +#define H5D_XFER_COLL_CHUNK_DEF 1 /* General collective I/O instrumentation properties */ -#define H5D_XFER_COLL_RANK0_BCAST_NAME "coll_rank0_bcast" +#define H5D_XFER_COLL_RANK0_BCAST_NAME "coll_rank0_bcast" /* Definitions for general collective I/O instrumentation properties */ -#define H5D_XFER_COLL_RANK0_BCAST_SIZE sizeof(hbool_t) -#define H5D_XFER_COLL_RANK0_BCAST_DEF FALSE +#define H5D_XFER_COLL_RANK0_BCAST_SIZE sizeof(hbool_t) +#define H5D_XFER_COLL_RANK0_BCAST_DEF FALSE #endif /* H5_HAVE_INSTRUMENTED_LIBRARY */ /* Default temporary buffer size */ -#define H5D_TEMP_BUF_SIZE (1024 * 1024) +#define H5D_TEMP_BUF_SIZE (1024 * 1024) /* Default I/O vector size */ -#define H5D_IO_VECTOR_SIZE 1024 +#define H5D_IO_VECTOR_SIZE 1024 /* Default VL allocation & free info */ -#define H5D_VLEN_ALLOC NULL -#define H5D_VLEN_ALLOC_INFO NULL -#define H5D_VLEN_FREE NULL -#define H5D_VLEN_FREE_INFO NULL +#define H5D_VLEN_ALLOC NULL +#define H5D_VLEN_ALLOC_INFO NULL +#define H5D_VLEN_FREE NULL +#define H5D_VLEN_FREE_INFO NULL /* Default virtual dataset list size */ #define H5D_VIRTUAL_DEF_LIST_SIZE 8 - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -129,32 +129,30 @@ typedef struct H5D_t H5D_t; /* Typedef for cached dataset creation property list information */ typedef struct H5D_dcpl_cache_t { - H5O_fill_t fill; /* Fill value info (H5D_CRT_FILL_VALUE_NAME) */ - H5O_pline_t pline; /* I/O pipeline info (H5O_CRT_PIPELINE_NAME) */ - H5O_efl_t efl; /* External file list info (H5D_CRT_EXT_FILE_LIST_NAME) */ + H5O_fill_t fill; /* Fill value info (H5D_CRT_FILL_VALUE_NAME) */ + H5O_pline_t pline; /* I/O pipeline info (H5O_CRT_PIPELINE_NAME) */ + H5O_efl_t efl; /* External file list info (H5D_CRT_EXT_FILE_LIST_NAME) */ } 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 */ + 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 */ } H5D_copy_file_ud_t; /* Structure for dataset append flush property (H5Pset_append_flush) */ 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 */ + 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 */ } H5D_append_flush_t; - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ @@ -166,32 +164,26 @@ 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 H5T_t *H5D_typeof(const H5D_t *dset); -H5_DLL herr_t H5D_flush_all(const 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); - -/* Functions that operate on vlen data */ -H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, void *buf); +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); /* Functions that operate on chunked storage */ H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); /* Functions that operate on virtual storage */ -H5_DLL herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, - const H5S_t *src_space, H5O_virtual_space_status_t space_status); -H5_DLL herr_t H5D_virtual_check_mapping_post( - const H5O_storage_virtual_ent_t *ent); +H5_DLL herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, + H5O_virtual_space_status_t space_status); +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, - H5O_storage_virtual_name_seg_t **parsed_name, size_t *static_strlen, - size_t *nsubs); +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); /* Functions that operate on indexed storage */ -H5_DLL herr_t H5D_btree_debug(H5F_t *f, haddr_t addr, FILE * stream, - int indent, int fwidth, unsigned ndims, const uint32_t *dim); - -#endif /* _H5Dprivate_H */ +H5_DLL herr_t H5D_btree_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, unsigned ndims, + const uint32_t *dim); +#endif /* H5Dprivate_H */ diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 42d0a938e3f..b73e62dc343 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains public declarations for the H5D module. */ -#ifndef _H5Dpublic_H -#define _H5Dpublic_H +#ifndef H5Dpublic_H +#define H5Dpublic_H /* System headers needed by this file */ @@ -28,95 +28,137 @@ /*****************/ /* 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_NSLOTS_DEFAULT ((size_t)-1) +#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t)-1) +#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) /* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ -#define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) +#define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) /*******************/ /* Public Typedefs */ /*******************/ -/* Values for the H5D_LAYOUT property */ +//! +/** + * Values for the H5D_LAYOUT property + */ typedef enum H5D_layout_t { - H5D_LAYOUT_ERROR = -1, + 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_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_t; +//! -/* Types of chunk index data structures */ +//! +/** + * Types of chunk index data structures + */ typedef enum H5D_chunk_index_t { - H5D_CHUNK_IDX_BTREE = 0, /* v1 B-tree index (default) */ - H5D_CHUNK_IDX_SINGLE = 1, /* Single Chunk index (cur dims[]=max dims[]=chunk dims[]; filtered & non-filtered) */ - H5D_CHUNK_IDX_NONE = 2, /* Implicit: No Index (H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ - H5D_CHUNK_IDX_FARRAY = 3, /* Fixed array (for 0 unlimited dims) */ - H5D_CHUNK_IDX_EARRAY = 4, /* Extensible array (for 1 unlimited dim) */ - H5D_CHUNK_IDX_BT2 = 5, /* v2 B-tree index (for >1 unlimited dims) */ - H5D_CHUNK_IDX_NTYPES /* This one must be last! */ + H5D_CHUNK_IDX_BTREE = 0, /**< v1 B-tree index (default) */ + H5D_CHUNK_IDX_SINGLE = + 1, /**< Single Chunk index (cur dims[]=max dims[]=chunk dims[]; filtered & non-filtered) */ + H5D_CHUNK_IDX_NONE = 2, /**< Implicit: No Index (#H5D_ALLOC_TIME_EARLY, non-filtered, fixed dims) */ + H5D_CHUNK_IDX_FARRAY = 3, /**< Fixed array (for 0 unlimited dims) */ + H5D_CHUNK_IDX_EARRAY = 4, /**< Extensible array (for 1 unlimited dim) */ + H5D_CHUNK_IDX_BT2 = 5, /**< v2 B-tree index (for >1 unlimited dims) */ + H5D_CHUNK_IDX_NTYPES /**< This one must be last! */ } H5D_chunk_index_t; +//! -/* Values for the space allocation time property */ +//! +/** + * 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, + H5D_ALLOC_TIME_DEFAULT = 0, + H5D_ALLOC_TIME_EARLY = 1, + H5D_ALLOC_TIME_LATE = 2, + H5D_ALLOC_TIME_INCR = 3 } H5D_alloc_time_t; +//! -/* Values for the status of space allocation */ +//! +/** + * 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, + H5D_SPACE_STATUS_NOT_ALLOCATED = 0, + H5D_SPACE_STATUS_PART_ALLOCATED = 1, + H5D_SPACE_STATUS_ALLOCATED = 2 } H5D_space_status_t; +//! -/* Values for time of writing fill value property */ +//! +/** + * Values for time of writing fill value property + */ typedef enum H5D_fill_time_t { - H5D_FILL_TIME_ERROR = -1, + H5D_FILL_TIME_ERROR = -1, H5D_FILL_TIME_ALLOC = 0, - H5D_FILL_TIME_NEVER = 1, - H5D_FILL_TIME_IFSET = 2 + H5D_FILL_TIME_NEVER = 1, + H5D_FILL_TIME_IFSET = 2 } H5D_fill_time_t; +//! -/* Values for fill value status */ +//! +/** + * 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, + H5D_FILL_VALUE_UNDEFINED = 0, + H5D_FILL_VALUE_DEFAULT = 1, + H5D_FILL_VALUE_USER_DEFINED = 2 } H5D_fill_value_t; +//! -/* Values for VDS bounds option */ +//! +/** + * 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, + H5D_VDS_FIRST_MISSING = 0, + H5D_VDS_LAST_AVAILABLE = 1 } H5D_vds_view_t; +//! -/* Callback for H5Pset_append_flush() in a dataset access property list */ +//! +/** + * Callback for H5Pset_append_flush() in a dataset access property list + */ 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() */ -typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, - const hsize_t *point, void *operator_data); +//! +/** + * Define the operator function pointer for H5Diterate() + */ +typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, + void *operator_data); +//! -/* Define the operator function pointer for H5Dscatter() */ -typedef herr_t (*H5D_scatter_func_t)(const void **src_buf/*out*/, - size_t *src_buf_bytes_used/*out*/, +//! +/** + * Define the operator function pointer for H5Dscatter() + */ +typedef herr_t (*H5D_scatter_func_t)(const void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *op_data); +//! -/* Define the operator function pointer for H5Dgather() */ -typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, - size_t dst_buf_bytes_used, void *op_data); - +//! +/** + * Define the operator function pointer for H5Dgather() + */ +typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_used, void *op_data); +//! /********************/ /* Public Variables */ @@ -129,47 +171,1269 @@ typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, extern "C" { #endif -H5_DLL 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); -H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id, - hid_t plist_id, hid_t dapl_id); -H5_DLL hid_t H5Dopen2(hid_t file_id, const char *name, hid_t dapl_id); -H5_DLL herr_t H5Dclose(hid_t dset_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Creates a new dataset and links it into the file + * + * \fgdta_loc_id + * \param[in] name Name of the dataset to create + * \type_id + * \space_id + * \lcpl_id + * \dcpl_id + * \dapl_id + * + * \return \hid_t{dataset} + * + * \details H5Dcreate2() creates a new dataset named \p name at + * the location specified by \p loc_id, and associates constant + * and initial persistent properties with that dataset, including + * the datatype \p dtype_id, the dataspace \p space_id, and + * other properties as specified by the dataset creation property + * list \p dcpl_id and the access property list \p dapl_id, + * respectively. Once created, the dataset is opened for access. + * + * \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 + * 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 + * of the link(s) by which the new dataset is accessed and the + * 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 + * 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. + * + * \since 1.8.0 + * + * \see H5Dopen2(), H5Dclose(), H5Tset_size() + * + */ +H5_DLL 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); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Creates a dataset in a file without linking it into the file + * structure + * + * \fgdta_loc_id + * \type_id + * \space_id + * \dcpl_id + * \dapl_id + * + * \return \hid_t{dataset} + * + * \details H5Dcreate_anon() creates a dataset in the file specified + * by \p loc_id. + * + * \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 + * 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 + * 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. + * + * \since 1.8.0 + * + * \see H5Olink(), H5Dcreate(), Using Identifiers + * + */ +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); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Creates a new dataset and links it into the file + * + * \fgdta_loc_id + * \param[in] name Name of the dataset to open + * \dapl_id + * + * \return \hid_t{dataset} + * + * \details H5Dopen2() opens the existing dataset specified + * by a location identifier and name, \p loc_id and \p name, + * respectively. + * + * \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 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() + * + */ +H5_DLL hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id); + +/** + * -------------------------------------------------------------------------- + *\ingroup H5D + * + * \brief Returns an identifier for a copy of the dataspace for a dataset + * + * \dset_id + * + * \return \hid_t{dataspace} + * + * \details H5Dget_space() makes a copy of the dataspace of + * the dataset specified by \p dset_id. The function returns an + * identifier for the new copy of the dataspace. + * + * A dataspace identifier returned from this function should + * be released with H5Sclose() when the identifier is no longer + * needed so that resource leaks will not occur. + * + * \see H5Sclose() + * + */ H5_DLL hid_t H5Dget_space(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * \todo Document this function! + */ H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns an identifier for a copy of the datatype for a dataset + * + * \dset_id + * + * \return \hid_t{datatype} + * + * \details H5Dget_type() returns an identifier of a copy of + * the datatype for a dataset. + * + * 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. + * + */ H5_DLL hid_t H5Dget_type(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns an identifier for a copy of the dataset creation + * property list for a dataset + * + * \dset_id + * + * \return \hid_t{dataset creation property list} + * + * \details H5Dget_create_plist() returns an identifier for + * 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. + * + */ H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns the dataset access property list associated with + * a dataset + * + * \dset_id + * + * \return \hid_t{dataset access property list} + * + * \details H5Dget_access_plist() returns a copy of the + * dataset access property list used to open the specified + * dataset, \p dset_id. Modifications to the returned property + * list will have no effect on the dataset it was retrieved from. + * + * The chunk cache parameters in the returned property lists will + * be those used by the dataset. If the properties in the file + * access property list were used to determine the dataset's + * chunk cache configuration, then those properties will be + * present in the returned dataset access property list. If + * the dataset does not use a chunked layout, then the chunk + * cache properties will be set to the default. The chunk cache + * properties in the returned list are considered to be “set”, + * and any use of this list will override the corresponding + * properties in the file’s file access property list. + * + * 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 + * + */ H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns the amount of storage allocated for a dataset + * + * \dset_id + * + * \return Returns the amount of storage space, in bytes, or 0 (zero). + * + * \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. + * + * \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 + * number of allocated chunks times the chunk size. + * \li For filtered chunked datasets, the returned size is the + * space required to store the filtered data. For example, if a + * 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. + * + * \attention 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); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns the amount of storage allocated within the file for a + * raw data chunk in a dataset + * + * \dset_id + * \param[in] offset Logical offset in the dataset for the chunk to query + * \param[out] chunk_bytes The size in bytes for the chunk + * + * \return \herr_t + * + * \details H5Dget_chunk_storage_size() returns the size in bytes + * allocated in the file for a raw data chunk as specified by + * its logical \p offset in the dataset \p dset_id. The size is + * returned in \p chunk_nbytes. It is the size of the compressed + * data if the chunk is filtered and the size may be zero if no + * storage is allocated yet for the dataset. + * + * \since 1.10.2 + * + */ H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Retrieves number of chunks that have nonempty intersection with a + * specified selection + * + * \dset_id + * \param[in] fspace_id File dataspace selection identifier + * \param[out] nchunks Number of chunks in the selection + * + * \return \herr_t + * + * \details H5Dget_num_chunks() retrieves the number of chunks + * nchunks in a set of selected elements specified by \p fspace_id + * for a dataset specified by the identifier \p dset_id. If \p + * fspace_id is #H5S_ALL, the function will retrieve the total + * number of chunks stored for the dataset. + * + * \p fspace_id specifies the file dataspace selection. It is + * intended to take #H5S_ALL for specifying the current selection. + * + * \note Please be aware that this function currently does not + * 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 + * the dataspace for the dataset using H5Dget_space() and pass that + * in for \p fspace_id. This will be fixed in coming releases. + * + * \since 1.10.5 + * + */ 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 *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); -H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \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[out] addr Chunk address in the file + * \param[out] size Chunk size in bytes, 0 if chunk doesn’t exist + * + * \return \herr_t + * + * \details H5Dget_chunk_info_by_coord() retrieves the \p filter_mask, \p size, + * and \p addr for a chunk in the dataset specified by \p dset_id, + * using the coordinates specified by \p offset. + * + * If the queried chunk does not exist in the file, \p size will + * be set to 0, \p addr to \c HADDR_UNDEF, and the buffer \p + * filter_mask will not be modified. + * + * \p offset is a pointer to a one-dimensional array with a size + * equal to the dataset’s rank. Each element is the logical + * position of the chunk’s first element in a dimension. + * + * \since 1.10.5 + * + */ +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 Retrieves information about a chunk specified by its index + * + * \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] addr Chunk address in the file + * \param[out] size Chunk size in bytes, 0 if chunk doesn’t 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 + * 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. + * + * \p chk_idx is the chunk index in the selection. 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 + * + * \note As of 1.10.5, the dataspace intersection is not yet + * 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. + * + * \note Please be aware that this function currently does not + * 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 + * the dataspace for the dataset using H5Dget_space() and pass that + * in for \p fspace_id. This will be fixed in coming releases. + * + * \since 1.10.5 + * + */ +H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *offset, + unsigned *filter_mask, haddr_t *addr, hsize_t *size); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Returns dataset address in file + * + * \dset_id + * + * \return Returns the offset in bytes; otherwise, returns \c HADDR_UNDEF, + * a negative value. + * + * \details H5Dget_offset() returns the address in the file of + * the dataset, \p dset_id. That address is expressed as the + * offset in bytes from the beginning of the file. + * + * \since 1.6.0 + * + */ H5_DLL haddr_t H5Dget_offset(hid_t dset_id); -H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf/*out*/); -H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf); -H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, - const hsize_t *offset, size_t data_size, const void *buf); -H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, - const hsize_t *offset, uint32_t *filters, void *buf); -H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, - H5D_operator_t op, void *operator_data); -H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); -H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size); -H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type, void *buf, - hid_t buf_type, hid_t space); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Reads raw data from a dataset into a provided buffer + * + * \dset_id Identifier of the dataset to read from + * \param[in] mem_type_id Identifier of the memory datatype + * \param[in] mem_space_id Identifier of the memory dataspace + * \param[in] file_space_id Identifier of the dataset's dataspace in the file + * \param[in] dxpl_id Identifier of a transfer property list + * \param[out] buf Buffer to receive data read from file + * + * \return \herr_t + * + * \details H5Dread() reads a dataset, specified by its identifier + * \p dset_id, from the file into an application memory buffer \p + * buf. Data transfer properties are defined by the argument \p + * dxpl_id. The memory datatype of the (partial) dataset + * is identified by the identifier \p mem_type_id. The part + * of the dataset to read is defined by \p mem_space_id and \p + * file_space_id. + * + * \p file_space_id is used to specify only the selection within + * the file dataset's dataspace. Any dataspace specified in \p + * file_space_id is ignored by the library and the dataset's + * dataspace is always used. \p file_space_id can be the constant + * #H5S_ALL, which indicates that the entire file dataspace, + * as defined by the current dimensions of the dataset, is to + * be selected. + * + * \p mem_space_id is used to specify both the memory dataspace + * and the selection within that dataspace. \p mem_space_id can + * be the constant #H5S_ALL, in which case the file dataspace is + * 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 behavior of the library for the various combinations of + * valid dataspace identifiers and #H5S_ALL for the \p mem_space_id + * and the \p file_space_id parameters is described below: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
mem_space_idfile_space_idBehavior
valid dataspace IDvalid dataspace ID\p mem_space_id specifies the memory dataspace and the + * selection within it. \p file_space_id specifies the + * selection within the file dataset's dataspace.
#H5S_ALLvalid dataspace IDThe file dataset's dataspace is used for the memory + * dataspace and the selection specified with \p file_space_id + * specifies the selection within it. The combination of the + * file dataset's dataspace and the selection from + * \p file_space_id is used for memory also.
valid dataspace ID#H5S_ALL\p mem_space_id specifies the memory dataspace and the + * selection within it. The selection within the file + * dataset's dataspace is set to the "all" selection.
#H5S_ALL#H5S_ALLThe file dataset's dataspace is used for the memory + * dataspace and the selection within the memory dataspace + * is set to the "all" selection. The selection within the + * file dataset's dataspace is set to the "all" selection.
+ * + * \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. + * + * \p dxpl_id can be the constant #H5P_DEFAULT, in which case the + * default data transfer properties are used. + * + */ +H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf /*out*/); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Writes raw data from a buffer to a dataset + * + * \param[in] dset_id Identifier of the dataset to read from + * \param[in] mem_type_id Identifier of the memory datatype + * \param[in] mem_space_id Identifier of the memory dataspace + * \param[in] file_space_id Identifier of the dataset's dataspace in the file + * \dxpl_id + * \param[out] buf Buffer with data to be written to the file + * + * \return \herr_t + * + * \details H5Dwrite() writes a (partial) dataset, specified by + * its identifier \p dset_id, from the application memory buffer \p + * buf into the file. Data transfer properties are defined by the + * argument \p dxpl_id. The memory datatype of the (partial) + * dataset is identified by the identifier \p mem_type_id. The + * part of the dataset to write is defined by \p mem_space_id + * and \p file_space_id. + * + * If \p mem_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. + * + * \p file_space_id is used to specify only the selection within + * the file dataset's dataspace. Any dataspace specified in \p + * file_space_id is ignored by the library and the dataset's + * dataspace is always used. \p file_space_id can be the constant + * #H5S_ALL, which indicates that the entire file dataspace, + * as defined by the current dimensions of the dataset, is to + * be selected. + * + * \p mem_space_id is used to specify both the memory dataspace + * and the selection within that dataspace. mem_space_id can be + * the constant #H5S_ALL, in which case the file dataspace is + * used for the memory dataspace and the selection defined with \p + * file_space_id is used for the selection within that dataspace. + * + * The behavior of the library for the various combinations of + * valid dataspace IDs and #H5S_ALL for the mem_space_id and + * thefile_space_id parameters is described below: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\c mem_space_id\c file_space_idBehavior
valid dataspace IDvalid dataspace ID\p mem_space_id specifies the memory dataspace and the + * selection within it. \p file_space_id specifies the + * selection within the file dataset's dataspace.
#H5S_ALLvalid dataspace IDThe file dataset's dataspace is used for the memory + * dataspace and the selection specified with \p file_space_id + * specifies the selection within it. The combination of the + * file dataset's dataspace and the selection from \p + * file_space_id is used for memory also. valid dataspace + * ID
valid dataspace ID#H5S_ALL\p mem_space_id specifies the memory dataspace and the + * selection within it. The selection within the file + * dataset's dataspace is set to "all" selection.
#H5S_ALL#H5S_ALLThe file dataset's dataspace is used for the memory + * dataspace and the selection within the memory dataspace is + * set to the "all" selection. The selection within the file + * dataset's dataspace is set to the "all" + * selection.
+ * Setting an "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. + * + * \p dxpl_id can be the constant #H5P_DEFAULT, in which + * case the default data transfer properties are used. + * + * Writing to a dataset will fail if the HDF5 file was not opened + * with write access permissions. + * + * If the dataset's space allocation time is set to + * #H5D_ALLOC_TIME_LATE or #H5D_ALLOC_TIME_INCR and the space for + * the dataset has not yet been allocated, that space is allocated + * when the first raw data is written to the dataset. Unused space + * in the dataset will be written with fill values at the same + * time if the dataset's fill time is set to #H5D_FILL_TIME_IFSET + * or #H5D_FILL_TIME_ALLOC. + * + * \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 + * to the file from any of the parallel processes, so parallel + * applications should always attempt to write identical data to + * the dataset from all processes. + * + * \see H5Pset_fill_time(), H5Pset_alloc_time() + * + */ +H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Writes a raw data chunk from a buffer directly to a dataset in a file + * + * \dset_id + * \dxpl_id + * \param[in] filters Mask for identifying the filters in use + * \param[in] offset Logical position of the chunk’s first element in the + * dataspace + * \param[in] data_size Size of the actual data to be written in bytes + * \param[in] buf Buffer containing data to be written to the chunk + * + * \return \herr_t + * + * \details H5Dwrite_chunk() writes a raw data chunk as specified + * by its logical offset \p offset in a chunked dataset \p dset_id + * from the application memory buffer \p buf to the dataset in + * the file. Typically, the data in \p buf is preprocessed in + * memory by a custom transformation, such as compression. The + * chunk will bypass the library’s internal data transfer + * 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 + * 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. + * This mask is saved with the chunk in the file. + * + * \p offset is an array specifying the logical position of the + * first element of the chunk in the dataset’s dataspace. The + * length of the offset array must equal the number of dimensions, + * or rank, of the dataspace. The values in offset must not exceed + * the dimension limits and must specify a point that falls on + * a dataset chunk boundary. + * + * \p data_size is the size in bytes of the chunk, representing + * the number of bytes to be read from the buffer \p buf. If the + * data chunk has been precompressed, \p data_size should be the + * size of the compressed data. + * + * \p buf is the memory buffer containing data to be written to + * the chunk in the file. + * + * \attention Exercise caution when using H5Dread_chunk() and + * H5Dwrite_chunk(), as they read and write data chunks directly + * 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. + * + * \note H5Dread_chunk() and H5Dwrite_chunk() are not supported under + * parallel and do not support variable length types. + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, + size_t data_size, const void *buf); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Reads a raw data chunk directly from a dataset in a file into + * a buffer + * + * \dset_id + * \dxpl_id + * \param[in] offset Logical position of the chunk’s first element in the + * dataspace + * \param[in,out] filters Mask for identifying the filters in use + * \param[out] buf Buffer containing data to be written to the chunk + * + * \return \herr_t + * + * \details H5Dread_chunk() reads a raw data chunk as specified by + * its logical offset \p offset in a chunked dataset \p dset_id + * from the dataset in the file into the application memory + * buffer \p buf. The data in \p buf is read directly from the + * file bypassing the library’s internal data transfer pipeline, + * including filters. + * + * \p offset is an array specifying the logical position of the + * first element of the chunk in the dataset’s dataspace. The + * length of the \p offset array must equal the number of dimensions, + * or rank, of the dataspace. The values in \p offset must not exceed + * 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 + * (0 ≤ position < 32) is turned on. + * + * \p buf is the memory buffer containing the chunk read from + * the dataset in the file. + * + * \attention Exercise caution when using H5Dread_chunk() and + * H5Dwrite_chunk(), as they read and write data chunks directly + * 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. + * + * \note H5Dread_chunk() and H5Dwrite_chunk() are not supported under + * parallel and do not support variable length types. + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, + void *buf); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Iterates over all selected elements in a dataspace + * + * \param[in,out] buf Buffer containing the elements to iterate over + * \type_id + * \space_id + * \param[in] op Function pointer + * \param[in,out] operator_data User-defined data + * + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \details H5Diterate() iterates over all the data elements + * 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. + * + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Determines the number of bytes required to store variable-length + * (VL) data + * + * \dset_id + * \type_id + * \space_id + * \param[out] size Size in bytes of the memory buffer required to store + * the VL data + * + * \return \herr_t + * + * \details H5Dvlen_get_buf_size() determines the number of bytes + * required to store the VL data from the dataset, using \p + * space_id for the selection in the dataset on disk and the \p + * type_id for the memory representation of the VL data in memory. + * \p size is returned with the number of bytes required to store + * the VL data in memory. + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dset_id, hid_t type_id, hid_t space_id, hsize_t *size); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Fills dataspace elements with a fill value in a memory buffer + * + * \param[in] fill Pointer to the fill value to be used + * \param[in] fill_type_id Fill value datatype identifier + * \param[in,out] buf Pointer to the memory buffer containing the + * selection to be filled + * \param[in] buf_type_id Datatype of dataspace elements to be filled + * \space_id + * + * \return \herr_t + * + * \details H5Dfill() fills the dataspace selection in memory, \p space_id, + * 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. + * + * \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. + * + * \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() + * + */ +H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Changes the sizes of a dataset’s dimensions + * + * \dset_id + * \param[in] size[] Array containing the new magnitude of each dimension + * of the dataset + * + * \return \herr_t + * + * \details H5Dset_extent() sets the current dimensions of the + * chunked dataset \p dset_id to the sizes specified in size. + * + * \p size is a 1-dimensional array with n elements, where \p n is + * the rank of the dataset’s current dataspace. + * + * This function can be applied to the following datasets: + * - A chunked dataset with unlimited dimensions + * - A chunked dataset with fixed dimensions if the new dimension + * sizes are less than the maximum sizes set with maxdims (see + * H5Screate_simple()) + * - An external dataset with unlimited dimensions + * - An external dataset with fixed dimensions if the new dimension + * sizes are less than the maximum sizes set with \p maxdims + * + * Note that external datasets are always contiguous and can be + * extended only along the first dimension. + * + * Space on disk is immediately allocated for the new dataset extent if + * the dataset’s space allocation time is set to #H5D_ALLOC_TIME_EARLY. + * + * Fill values will be written to the dataset in either of the + * following situations, but not otherwise: + * + * - If the dataset’s fill time is set to #H5D_FILL_TIME_IFSET and a + * fill value is defined (see H5Pset_fill_time() and + * H5Pset_fill_value()) + * - 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. + * + * \li 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. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Flushes all buffers associated with a dataset to disk + * + * \dset_id + * + * \return \herr_t + * + * \details H5Dflush() causes all buffers associated with a + * dataset to be immediately flushed to disk without removing + * the data from the cache. + * + * \note HDF5 does not possess full control over buffering. + * H5Dflush() 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. + * + */ H5_DLL herr_t H5Dflush(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Refreshes all buffers associated with a dataset + * + * \dset_id + * + * \return \herr_t + * + * \details H5Drefresh() causes all buffers associated with a + * dataset to be cleared and immediately re-loaded with updated + * contents from disk. + * + * This function essentially closes the dataset, evicts all + * metadata associated with it from the cache, and then re-opens + * the dataset. The reopened dataset is automatically re-registered + * with the same identifier. + * + * \since 1.10.2 + * + */ H5_DLL herr_t H5Drefresh(hid_t dset_id); -H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, - hid_t dst_space_id, void *dst_buf); -H5_DLL 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); -H5_DLL herr_t H5Ddebug(hid_t dset_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Scatters data into a selection within a memory buffer + * + * \param[in] op Callback function which provides data to be scattered + * \param[in] op_data User-defined pointer to data required by op + * \param[in] type_id Identifier for the datatype describing the data in + * both the source and destination buffers + * \param[in] dst_space_id Identifier for the dataspace for destination + * \param[out] dst_buf Destination buffer which the data will be scattered to + * + * \return \herr_t + * + * \details H5Dscatter() retrieves data from the supplied callback + * \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 + * 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 + * the source and destination buffers. + * + * \p dst_buf must be at least as large as the number of elements + * in the extent of \p dst_space_id times the size in bytes of + * \p type_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. + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, + void *dst_buf); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Gathers data from a selection within a memory buffer + * raw data chunk in a dataset + * + * \param[in] src_space_id Dataspace identifier for the source buffer + * \param[in] src_buf Source buffer which the data will be gathered from + * \param[in] type_id Datatype identifier for the source + * \param[in] dst_buf_size Size in bytes of \p dst_buf + * \param[out] dst_buf Destination buffer for the gathered data + * \param[in] op Callback function which handles the gathered data + * \param[in] op_data User-defined pointer to data required by \p op + * + * \return \herr_t + * + * \details H5Dgather() retrieves data from a selection within the supplied + * buffer src_buf and passes it to the supplied callback function + * \p op in a contiguous form. + * + * The dataspace \p src_space_id describes both the dimensions of + * the source buffer and the selection within the source buffer + * to gather data from. + * + * \p src_buf must be at least the size of the gathered data, that + * is, the number of elements in the extent of \p src_space_id + * times the size in bytes of \p type_id. + * + * The datatype \p type_id describes the data in both the source + * and destination buffers. This information is used to calculate + * the element size. + * + * The data is gathered into \p dst_buf, which needs to be large + * 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. + * 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, + * 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 + * until all gathered elements have been passed to the callback + * in \p dst_buf. The callback function should return zero (0) + * to indicate success, and a negative value to indicate failure. + * + * \since 1.10.2 + * + */ +H5_DLL 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); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Closes the specified dataset + * + * \dset_id + * + * \return \herr_t + * + * \details H5Dclose() ends access to a dataset specified by \p dset_id + * and releases resources used by it. + * + * \attention Further use of a released dataset identifier is illegal; a + * function using such an identifier will generate an error. + * + * \since 1.8.0 + * + * \see H5Dcreate2(), H5Dopen2() + * + */ +H5_DLL herr_t H5Dclose(hid_t dset_id); /* 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); @@ -186,28 +1450,198 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); * These symbols are no longer used in the library. */ /* Property names for H5DOwrite_chunk */ -#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" -#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" -#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" -#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" +#define H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME "direct_chunk_flag" +#define H5D_XFER_DIRECT_CHUNK_WRITE_FILTERS_NAME "direct_chunk_filters" +#define H5D_XFER_DIRECT_CHUNK_WRITE_OFFSET_NAME "direct_chunk_offset" +#define H5D_XFER_DIRECT_CHUNK_WRITE_DATASIZE_NAME "direct_chunk_datasize" /* Property names for H5DOread_chunk */ -#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" -#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" -#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" +#define H5D_XFER_DIRECT_CHUNK_READ_FLAG_NAME "direct_chunk_read_flag" +#define H5D_XFER_DIRECT_CHUNK_READ_OFFSET_NAME "direct_chunk_read_offset" +#define H5D_XFER_DIRECT_CHUNK_READ_FILTERS_NAME "direct_chunk_read_filters" /* Typedefs */ - /* Function prototypes */ -H5_DLL hid_t H5Dcreate1(hid_t file_id, const char *name, hid_t type_id, - hid_t space_id, hid_t dcpl_id); -H5_DLL hid_t H5Dopen1(hid_t file_id, const char *name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Creates a dataset at the specified location + * + * \fgdta_loc_id + * \param[in] name Name of the dataset to create + * \type_id + * \space_id + * \dcpl_id + * + * \return \hid_t{dataset} + * + * \deprecated This function is deprecated in favor of the function 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 + * file, group, dataset, named datatype or attribute. If an attribute, + * dataset, or named datatype is specified for \p loc_id then the + * dataset will be created at the location where the attribute, + * dataset, or named datatype is attached. + * + * \p name can be a relative path based at \p loc_id or an absolute + * path from the root of the file. Use of this function requires that + * any intermediate groups specified in the path already exist. + * + * 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 the file, which may differ from the + * datatype and dataspace in application memory. + * + * Names within a group are unique: H5Dcreate1() will return an error + * if a link with the name specified in name already exists at the + * location specified in \p loc_id. + * + * As is the case for any object in a group, the length of a dataset + * name is not limited. + * + * \p dcpl_id is an #H5P_DATASET_CREATE property list created with \p + * H5reate1() and initialized with various property list functions + * described in Property List Interface. + * + * H5Dcreate() and H5Dcreate_anon() return an error if the dataset’s + * datatype includes a variable-length (VL) datatype and the fill value + * is undefined, i.e., set to \c NULL in the dataset creation property + * list. Such a VL datatype may be directly included, indirectly + * included as part of a compound or array datatype, or indirectly + * included as part of a nested compound or array datatype. + * + * 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 + * resources it uses. + * + * See H5Dcreate_anon() for discussion of the differences between + * H5Dcreate() and H5Dcreate_anon(). + * + * The HDF5 library provides flexible means of specifying a fill value, + * of specifying when space will be allocated for a dataset, and of + * specifying when fill values will be written to a dataset. + * + * \version 1.8.0 Function H5Dcreate() renamed to H5Dcreate1() and deprecated in this release. + * \since 1.0.0 + * + * \see H5Dopen2(), H5Dclose(), H5Tset_size() + * + */ +H5_DLL hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Opens an existing dataset + * + * \fgdta_loc_id + * \param[in] name Name of the dataset to access + * + * \return \hid_t{dataset} + * + * \deprecated This function is deprecated in favor of the function 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, + * named datatype or attribute. If an attribute, dataset, or named + * datatype is specified for loc_id then the dataset will be opened at + * the location where the attribute, dataset, or named datatype is + * attached. name is a dataset name and is used to identify the dataset + * in the file. + * + * A dataset opened with this function should be closed with H5Dclose() + * when the dataset is no longer needed so that resource leaks will not + * develop. + * + * \version 1.8.0 Function H5Dopen() renamed to H5Dopen1() and deprecated in this release. + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Dopen1(hid_t loc_id, const char *name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Extends a dataset + * + * \dset_id + * \param[in] size Array containing the new size of each dimension + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function 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 + * that of the dataspace of the dataset being changed. + * + * This function can be applied to the following datasets: + * \li Any dataset with unlimited dimensions + * \li A dataset with fixed dimensions if the current dimension sizes + * are less than the maximum sizes set with \c maxdims + * (see H5Screate_simple()) + * + * Space on disk is immediately allocated for the new dataset extent if + * the dataset’s space allocation time is set to + * #H5D_ALLOC_TIME_EARLY. Fill values will be written to the dataset if + * the dataset’s fill time is set to #H5D_FILL_TIME_IFSET or + * #H5D_FILL_TIME_ALLOC. (See H5Pset_fill_time() and + * H5Pset_alloc_time().) + * + * 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. + * + * \version 1.8.0 Function Function deprecated in this release. Parameter size + * syntax changed to \Code{const hsize_t size[]} in this release. + * + */ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Reclaims variable-length (VL) datatype memory buffers + * + * \type_id + * \space_id + * \dxpl_id + * \param[in] buf Pointer to the buffer to be reclaimed + * + * \return \herr_t + * + * \deprecated This function has been deprecated in HDF5-1.12 in favor of the + * function H5Treclaim(). + * + * \details H5Dvlen_reclaim() reclaims memory buffers created to store VL + * datatypes. + * + * 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 + * \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 + * zero out the VL information after the memory has been reclaimed. + * + * If nested VL datatypes were used to create the buffer, this routine + * frees them from the bottom up, releasing all the memory without + * creating memory leaks. + * + * \version 1.12.0 Routine was deprecated + * + */ +H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif -#endif /* _H5Dpublic_H */ - +#endif /* H5Dpublic_H */ diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index cdf9da2f0e6..1888adb1d21 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,48 +15,42 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, - H5S_sel_iter_t *file_iter, size_t nelmts, const void *buf); -static size_t H5D__gather_file(const H5D_io_info_t *io_info, - H5S_sel_iter_t *file_iter, size_t nelmts, void *buf); -static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, - const H5D_type_info_t *type_info, void *user_buf/*out*/); +static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts, + const void *buf); +static size_t H5D__gather_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts, + void *buf); +static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, + void *user_buf /*out*/); static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info); - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -70,8 +64,6 @@ H5FL_SEQ_EXTERN(size_t); /* Declare extern free list to manage sequences of hsize_t */ H5FL_SEQ_EXTERN(hsize_t); - - /*------------------------------------------------------------------------- * Function: H5D__scatter_file * @@ -89,21 +81,20 @@ H5FL_SEQ_EXTERN(hsize_t); *------------------------------------------------------------------------- */ 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__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 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 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 */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ + 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 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 */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -116,36 +107,36 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, /* Set up temporary I/O info object */ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info)); tmp_io_info.op_type = H5D_IO_OP_WRITE; - tmp_io_info.u.wbuf = _buf; + tmp_io_info.u.wbuf = _buf; /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Reset the current sequence information */ mem_curr_seq = dset_curr_seq = 0; orig_mem_len = mem_len = nelem * iter->elmt_size; - mem_off = 0; + mem_off = 0; /* Write sequence list out */ - if((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq, - len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if ((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") /* Update buffer */ @@ -157,15 +148,14 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__scatter_file() */ - /*------------------------------------------------------------------------- * Function: H5D__gather_file * @@ -188,21 +178,20 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, *------------------------------------------------------------------------- */ 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__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 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 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 */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - size_t ret_value = nelmts; /* Return value */ + H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ + 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 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 */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + size_t ret_value = nelmts; /* Return value */ FUNC_ENTER_STATIC @@ -217,36 +206,36 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, /* Set up temporary I/O info object */ H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info)); tmp_io_info.op_type = H5D_IO_OP_READ; - tmp_io_info.u.rbuf = _buf; + tmp_io_info.u.rbuf = _buf; /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array") /* Loop until all elements are read */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to read */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Reset the current sequence information */ mem_curr_seq = dset_curr_seq = 0; orig_mem_len = mem_len = nelem * iter->elmt_size; - mem_off = 0; + mem_off = 0; /* Read sequence list in */ - if((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq, - len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0) + if ((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1, + &mem_curr_seq, &mem_len, &mem_off) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error") /* Update buffer */ @@ -258,15 +247,14 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__gather_file() */ - /*------------------------------------------------------------------------- * Function: H5D__scatter_mem * @@ -283,20 +271,19 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, *------------------------------------------------------------------------- */ herr_t -H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, - void *_buf/*out*/) +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 */ - 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 */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Number of elements scattered */ + 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 */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Number of elements scattered */ FUNC_ENTER_PACKAGE @@ -307,27 +294,27 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, HDassert(buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) - HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { /* Get the number of bytes in sequence */ curr_len = len[curr_seq]; @@ -343,15 +330,14 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__scatter_mem() */ +} /* H5D__scatter_mem() */ - /*------------------------------------------------------------------------- * Function: H5D__gather_mem * @@ -370,20 +356,19 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, *------------------------------------------------------------------------- */ size_t -H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, - void *_tgath_buf/*out*/) +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 */ - 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 */ - size_t nelem; /* Number of elements used in sequences */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - size_t ret_value = nelmts; /* Number of elements gathered */ + 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 */ + 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 */ + size_t nelem; /* Number of elements used in sequences */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + size_t ret_value = nelmts; /* Number of elements gathered */ FUNC_ENTER_STATIC @@ -394,27 +379,27 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, HDassert(tgath_buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array") /* Loop until all elements are written */ - while(nelmts > 0) { + while (nelmts > 0) { /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) - HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { /* Get the number of bytes in sequence */ curr_len = len[curr_seq]; @@ -430,15 +415,14 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__gather_mem() */ +} /* H5D__gather_mem() */ - /*------------------------------------------------------------------------- * Function: H5D__scatgath_read * @@ -452,19 +436,19 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, *------------------------------------------------------------------------- */ 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) +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) { - 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*/ - hbool_t bkg_iter_init = FALSE; /* Background 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 smine_start; /* Strip mine start loc */ - size_t smine_nelmts; /* Elements per strip */ - herr_t ret_value = SUCCEED; /* Return value */ + 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*/ + hbool_t bkg_iter_init = FALSE; /* Background 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 smine_start; /* Strip mine start loc */ + size_t smine_nelmts; /* Elements per strip */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -476,31 +460,32 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HDassert(buf); /* Check for NOOP read */ - if(nelmts == 0) + if (nelmts == 0) HGOTO_DONE(SUCCEED) /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Figure out the strip mine size. */ - if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, type_info->src_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") - file_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0) + file_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") - mem_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0) + mem_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") - bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ + bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ /* Start strip mining... */ - for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { - size_t n; /* Elements operated on */ + for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { + size_t n; /* Elements operated on */ /* Go figure out how many elements to read from the file */ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start)); @@ -512,73 +497,72 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * if necessary. */ - /* + /* * Gather data */ - n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf/*out*/); - if(n != smine_nelmts) + n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") /* If the source and destination are compound types and subset of each other * and no conversion is needed, copy the data directly into user's buffer and * bypass the rest of steps. */ - if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) { - if(H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0) + if (type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) { + if (H5D__compound_opt_read(smine_nelmts, mem_iter, type_info, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ else { - if(H5T_BKG_YES == type_info->need_bkg) { - n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); - if(n != smine_nelmts) + if (H5T_BKG_YES == type_info->need_bkg) { + n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ /* * Perform datatype conversion. */ - if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, - smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, - type_info->bkg_buf) < 0) + if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts, + (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") /* Do the data transform after the conversion (since we're using type mem_type) */ - if(!type_info->is_xform_noop) { - H5Z_data_xform_t *data_transform; /* Data transform info */ + if (!type_info->is_xform_noop) { + H5Z_data_xform_t *data_transform; /* Data transform info */ /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") - if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform") } /* Scatter the data into memory */ - if(H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf/*out*/) < 0) + if (H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf /*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end else */ - } /* end for */ + } /* end for */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) + if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(bkg_iter) + if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__scatgath_read() */ - /*------------------------------------------------------------------------- * Function: H5D__scatgath_write * @@ -592,19 +576,19 @@ 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) +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) { - 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*/ - hbool_t bkg_iter_init = FALSE; /* Background 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 smine_start; /* Strip mine start loc */ - size_t smine_nelmts; /* Elements per strip */ - herr_t ret_value = SUCCEED; /* Return value */ + 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*/ + hbool_t bkg_iter_init = FALSE; /* Background 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 smine_start; /* Strip mine start loc */ + size_t smine_nelmts; /* Elements per strip */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -616,31 +600,33 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in HDassert(buf); /* Check for NOOP write */ - if(nelmts == 0) + if (nelmts == 0) HGOTO_DONE(SUCCEED) /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Figure out the strip mine size. */ - if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") - file_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0) + file_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") - mem_iter_init = TRUE; /*file selection iteration info has been initialized */ - if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + mem_iter_init = TRUE; /*file selection iteration info has been initialized */ + if (H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size, + H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") - bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ + bkg_iter_init = TRUE; /*file selection iteration info has been initialized */ /* Start strip mining... */ - for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { - size_t n; /* Elements operated on */ + for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) { + size_t n; /* Elements operated on */ /* Go figure out how many elements to read from the file */ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start)); @@ -651,8 +637,8 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in * buffer. Also gather data from the file into the background buffer * if necessary. */ - n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf/*out*/); - if(n != smine_nelmts) + n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed") /* If the source and destination are compound types and the destination is @@ -661,66 +647,65 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in * is a subset of the destination, the optimization is done in conversion * function H5T_conv_struct_opt to protect the background data. */ - if(type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset - && type_info->dst_type_size == type_info->cmpd_subset->copy_size) { - if(H5D__compound_opt_write(smine_nelmts, type_info) < 0) + if (type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset && + type_info->dst_type_size == type_info->cmpd_subset->copy_size) { + if (H5D__compound_opt_write(smine_nelmts, type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ else { - if(H5T_BKG_YES == type_info->need_bkg) { - n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/); - if(n != smine_nelmts) + if (H5T_BKG_YES == type_info->need_bkg) { + n = H5D__gather_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf /*out*/); + if (n != smine_nelmts) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") } /* end if */ /* Do the data transform before the type conversion (since * transforms must be done in the memory type). */ - if(!type_info->is_xform_noop) { - H5Z_data_xform_t *data_transform; /* Data transform info */ + if (!type_info->is_xform_noop) { + H5Z_data_xform_t *data_transform; /* Data transform info */ /* Retrieve info from API context */ - if(H5CX_get_data_transform(&data_transform) < 0) + if (H5CX_get_data_transform(&data_transform) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info") - if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < + 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform") } /* * Perform datatype conversion. */ - if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, - smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, - type_info->bkg_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts, + (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end else */ /* * Scatter the data out to the file. */ - if(H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0) + if (H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); - if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) + if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(bkg_iter) + if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__scatgath_write() */ - /*------------------------------------------------------------------------- * Function: H5D__compound_opt_read * @@ -754,17 +739,17 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in *------------------------------------------------------------------------- */ static herr_t -H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, - const H5D_type_info_t *type_info, void *user_buf/*out*/) +H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info, + void *user_buf /*out*/) { - 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 src_stride, dst_stride, copy_size; - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 src_stride, dst_stride, copy_size; + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -774,21 +759,21 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, HDassert(type_info); HDassert(type_info->cmpd_subset); HDassert(H5T_SUBSET_SRC == type_info->cmpd_subset->subset || - H5T_SUBSET_DST == type_info->cmpd_subset->subset); + H5T_SUBSET_DST == type_info->cmpd_subset->subset); HDassert(user_buf); /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Get source & destination strides */ @@ -800,22 +785,22 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, /* Loop until all elements are written */ xdbuf = type_info->tconv_buf; - while(nelmts > 0) { - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being processed */ - size_t elmtno; /* Element counter */ + while (nelmts > 0) { + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being processed */ + size_t elmtno; /* Element counter */ /* Get list of sequences for selection to write */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - size_t curr_off; /* Offset of bytes left to process in sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ - size_t curr_nelmts; /* Number of elements to process in sequence */ - uint8_t *xubuf; - size_t i; /* Local index variable */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + size_t curr_off; /* Offset of bytes left to process in sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ + size_t curr_nelmts; /* Number of elements to process in sequence */ + uint8_t *xubuf; + size_t i; /* Local index variable */ /* Get the number of bytes and offset in sequence */ curr_len = len[curr_seq]; @@ -824,17 +809,17 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, /* Decide the number of elements and position in the buffer. */ curr_nelmts = curr_len / dst_stride; - xubuf = ubuf + curr_off; + xubuf = ubuf + curr_off; /* Copy the data into the right place. */ - for(i = 0; i < curr_nelmts; i++) { + for (i = 0; i < curr_nelmts; i++) { HDmemmove(xubuf, xdbuf, copy_size); /* Update pointers */ xdbuf += src_stride; xubuf += dst_stride; } /* end for */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ nelmts -= elmtno; @@ -842,15 +827,14 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compound_opt_read() */ - /*------------------------------------------------------------------------- * Function: H5D__compound_opt_write * @@ -887,9 +871,9 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) { - uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */ - size_t src_stride, dst_stride; /* Strides through source & destination datatypes */ - size_t i; /* Local index variable */ + uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */ + size_t src_stride, dst_stride; /* Strides through source & destination datatypes */ + size_t i; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -904,7 +888,7 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) /* Loop until all elements are written */ xsbuf = (uint8_t *)type_info->tconv_buf; xdbuf = (uint8_t *)type_info->tconv_buf; - for(i = 0; i < nelmts; i++) { + for (i = 0; i < nelmts; i++) { HDmemmove(xdbuf, xsbuf, dst_stride); /* Update pointers */ @@ -915,7 +899,6 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compound_opt_write() */ - /*------------------------------------------------------------------------- * Function: H5Dscatter * @@ -933,71 +916,70 @@ 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) +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 */ - 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 */ - 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 */ - size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "x*xii*x", op, op_data, type_id, dst_space_id, dst_buf); /* Check args */ - if(op == NULL) + if (op == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == (dst_space= (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) + if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(dst_buf == NULL) + if (dst_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") /* Get datatype element size */ - if(0 == (type_size = H5T_GET_SIZE(type))) + if (0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") /* Get number of elements in dataspace */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize selection iterator */ - if(H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) + if (H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") iter_init = TRUE; /* Loop until all data has been scattered */ - while(nelmts > 0) { + while (nelmts > 0) { /* Make callback to retrieve data */ - if(op(&src_buf, &src_buf_nbytes, op_data) < 0) + if (op(&src_buf, &src_buf_nbytes, op_data) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") /* Calculate number of elements */ nelmts_scatter = src_buf_nbytes / type_size; /* Check callback results */ - if(!src_buf) + if (!src_buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer") - if(src_buf_nbytes == 0) + if (src_buf_nbytes == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0") - if(src_buf_nbytes % type_size) + if (src_buf_nbytes % type_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size") - if(nelmts_scatter > (size_t)nelmts) + if (nelmts_scatter > (size_t)nelmts) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") /* Scatter data */ - if(H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) + if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") nelmts -= (hssize_t)nelmts_scatter; @@ -1005,15 +987,14 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, done: /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_API(ret_value) -} /* H5Dscatter() */ +} /* H5Dscatter() */ - /*------------------------------------------------------------------------- * Function: H5Dgather * @@ -1031,71 +1012,72 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ - hssize_t nelmts; /* Number of remaining elements in selection */ - size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ - size_t nelmts_gathered; /* Number of elements gathered from src_buf */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hssize_t nelmts; /* Number of remaining elements in selection */ + size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ + size_t nelmts_gathered; /* Number of elements gathered from src_buf */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*xiz*xx*x", src_space_id, src_buf, type_id, dst_buf_size, - dst_buf, op, op_data); + H5TRACE7("e", "i*xiz*xx*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data); /* Check args */ - if(NULL == (src_space= (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(src_buf == NULL) + if (src_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(dst_buf_size == 0) + if (dst_buf_size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0") - if(dst_buf == NULL) + if (dst_buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") /* Get datatype element size */ - if(0 == (type_size = H5T_GET_SIZE(type))) + if (0 == (type_size = H5T_GET_SIZE(type))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") /* Get number of elements in dst_buf_size */ dst_buf_nelmts = dst_buf_size / type_size; - if(dst_buf_nelmts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer is not large enough to hold one element") + if (dst_buf_nelmts == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination buffer is not large enough to hold one element") /* Get number of elements in dataspace */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") /* If dst_buf is not large enough to hold all the elements, make sure there * is a callback */ - if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) + if (((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize selection iterator */ - if(H5S_select_iter_init(iter, src_space, type_size, 0) < 0) + if (H5S_select_iter_init(iter, src_space, type_size, 0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") iter_init = TRUE; /* Loop until all data has been scattered */ - while(nelmts > 0) { + while (nelmts > 0) { /* Gather data */ - if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) + if (0 == + (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed") HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts)); /* Make callback to process dst_buf */ - if(op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) + if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") nelmts -= (hssize_t)nelmts_gathered; @@ -1104,11 +1086,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, done: /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_API(ret_value) -} /* H5Dgather() */ - +} /* H5Dgather() */ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 5a5c49146ae..7d2ead13202 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,42 +21,36 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* 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, + const H5S_t *file_space, const H5S_t *mem_space); /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ @@ -70,8 +64,6 @@ H5FL_SEQ_DEFINE(hsize_t); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); - - /*------------------------------------------------------------------------- * Function: H5D__select_io * @@ -85,25 +77,25 @@ 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, const H5S_t *file_space, + const 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 */ - 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 */ - size_t file_nseq; /* Number of sequences generated in memory */ - size_t dxpl_vec_size; /* Vector length from API context's DXPL */ - size_t vec_size; /* Vector length */ - ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + size_t file_nseq; /* Number of sequences generated in memory */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -114,16 +106,16 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, HDassert(io_info->u.rbuf); /* Check for only one element in selection */ - if(nelmts == 1) { - hsize_t single_mem_off; /* Offset in memory */ - hsize_t single_file_off; /* Offset in the file */ - size_t single_mem_len; /* Length in memory */ - size_t single_file_len; /* Length in the file */ + if (nelmts == 1) { + hsize_t single_mem_off; /* Offset in memory */ + hsize_t single_file_off; /* Offset in the file */ + size_t single_mem_len; /* Length in memory */ + size_t single_file_len; /* Length in the file */ /* Get offset of first element in selections */ - if(H5S_SELECT_OFFSET(file_space, &single_file_off) < 0) + if (H5S_SELECT_OFFSET(file_space, &single_file_off) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "can't retrieve file selection offset") - if(H5S_SELECT_OFFSET(mem_space, &single_mem_off) < 0) + if (H5S_SELECT_OFFSET(mem_space, &single_mem_off) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "can't retrieve memory selection offset") /* Set up necessary information for I/O operation */ @@ -134,17 +126,17 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, single_file_len = single_mem_len = elmt_size; /* Perform I/O on memory and file sequences */ - if(io_info->op_type == H5D_IO_OP_READ) { - if((tmp_file_len = (*io_info->layout_ops.readvv)(io_info, - file_nseq, &curr_file_seq, &single_file_len, &single_file_off, - mem_nseq, &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) + if (io_info->op_type == H5D_IO_OP_READ) { + if ((tmp_file_len = (*io_info->layout_ops.readvv)( + io_info, file_nseq, &curr_file_seq, &single_file_len, &single_file_off, mem_nseq, + &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") } /* end if */ else { HDassert(io_info->op_type == H5D_IO_OP_WRITE); - if((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, - file_nseq, &curr_file_seq, &single_file_len, &single_file_off, - mem_nseq, &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) + if ((tmp_file_len = (*io_info->layout_ops.writevv)( + io_info, file_nseq, &curr_file_seq, &single_file_len, &single_file_off, mem_nseq, + &curr_mem_seq, &single_mem_len, &single_mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") } /* end else */ @@ -152,53 +144,54 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, HDassert(((size_t)tmp_file_len % elmt_size) == 0); } /* end if */ else { - size_t mem_nelem; /* Number of elements used in memory sequences */ - size_t file_nelem; /* Number of elements used in file sequences */ + size_t mem_nelem; /* Number of elements used in memory sequences */ + size_t file_nelem; /* Number of elements used in file sequences */ /* Get info from API context */ - if(H5CX_get_vec_size(&dxpl_vec_size) < 0) + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") /* Allocate the vector I/O arrays */ - if(dxpl_vec_size > H5D_IO_VECTOR_SIZE) + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) vec_size = dxpl_vec_size; else vec_size = H5D_IO_VECTOR_SIZE; - if(NULL == (mem_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (mem_len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") - if(NULL == (file_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + if (NULL == (file_len = H5FL_SEQ_MALLOC(size_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") - if(NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + if (NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") /* Allocate the iterators */ - if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator") - if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator") /* Initialize file iterator */ - if(H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) + if (H5S_select_iter_init(file_iter, file_space, elmt_size, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - file_iter_init = 1; /* File selection iteration info has been initialized */ + file_iter_init = 1; /* File selection iteration info has been initialized */ /* Initialize memory iterator */ - if(H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0) + if (H5S_select_iter_init(mem_iter, mem_space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - mem_iter_init = 1; /* Memory selection iteration info has been initialized */ + mem_iter_init = 1; /* Memory selection iteration info has been initialized */ /* Initialize sequence counts */ curr_mem_seq = curr_file_seq = 0; mem_nseq = file_nseq = 0; /* Loop, until all bytes are processed */ - while(nelmts > 0) { + while (nelmts > 0) { /* Check if more file sequences are needed */ - if(curr_file_seq >= file_nseq) { + if (curr_file_seq >= file_nseq) { /* Get sequences for file selection */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(file_iter, vec_size, nelmts, &file_nseq, &file_nelem, + file_off, file_len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Start at the beginning of the sequences again */ @@ -206,9 +199,10 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end if */ /* Check if more memory sequences are needed */ - if(curr_mem_seq >= mem_nseq) { + if (curr_mem_seq >= mem_nseq) { /* Get sequences for memory selection */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, + mem_len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Start at the beginning of the sequences again */ @@ -216,53 +210,52 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end if */ /* Perform I/O on memory and file sequences */ - if(io_info->op_type == H5D_IO_OP_READ) { - if((tmp_file_len = (*io_info->layout_ops.readvv)(io_info, - file_nseq, &curr_file_seq, file_len, file_off, - mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) + if (io_info->op_type == H5D_IO_OP_READ) { + if ((tmp_file_len = + (*io_info->layout_ops.readvv)(io_info, file_nseq, &curr_file_seq, file_len, file_off, + mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") } /* end if */ else { HDassert(io_info->op_type == H5D_IO_OP_WRITE); - if((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, - file_nseq, &curr_file_seq, file_len, file_off, - mem_nseq, &curr_mem_seq, mem_len, mem_off)) < 0) + if ((tmp_file_len = (*io_info->layout_ops.writevv)(io_info, file_nseq, &curr_file_seq, + file_len, file_off, mem_nseq, + &curr_mem_seq, mem_len, mem_off)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") } /* end else */ /* Decrement number of elements left to process */ HDassert(((size_t)tmp_file_len % elmt_size) == 0); - if(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 */ + } /* end else */ done: /* Release selection iterators */ - if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) + if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(file_iter) + if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); - if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(mem_iter) + if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); /* Release vector arrays, if allocated */ - if(file_len) + if (file_len) file_len = H5FL_SEQ_FREE(size_t, file_len); - if(file_off) + if (file_off) file_off = H5FL_SEQ_FREE(hsize_t, file_off); - if(mem_len) + if (mem_len) mem_len = H5FL_SEQ_FREE(size_t, mem_len); - if(mem_off) + if (mem_off) mem_off = H5FL_SEQ_FREE(hsize_t, mem_off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_io() */ - /*------------------------------------------------------------------------- * Function: H5D__select_read * @@ -276,8 +269,8 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, *------------------------------------------------------------------------- */ 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) +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) { herr_t ret_value = SUCCEED; /* Return value */ @@ -285,15 +278,13 @@ H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Call generic selection operation */ H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); - if(H5D__select_io(io_info, type_info->src_type_size, (size_t)nelmts, - file_space, mem_space) < 0) + if (H5D__select_io(io_info, type_info->src_type_size, (size_t)nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_read() */ - /*------------------------------------------------------------------------- * Function: H5D__select_write * @@ -307,8 +298,8 @@ 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) +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) { herr_t ret_value = SUCCEED; /* Return value */ @@ -316,11 +307,9 @@ H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info /* Call generic selection operation */ H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t); - if(H5D__select_io(io_info, type_info->dst_type_size, (size_t)nelmts, - file_space, mem_space) < 0) + if (H5D__select_io(io_info, type_info->dst_type_size, (size_t)nelmts, file_space, mem_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_write() */ - diff --git a/src/H5Dsingle.c b/src/H5Dsingle.c index cd71e936b0c..50cf6a12c43 100644 --- a/src/H5Dsingle.c +++ b/src/H5Dsingle.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,55 +26,47 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Single Chunk Index chunking I/O ops */ -static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t *space, haddr_t dset_ohdr_addr); -static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, + haddr_t dset_ohdr_addr); +static herr_t H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage); -static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata, const H5D_t *dset); -static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_ud_t *udata); -static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); -static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_common_ud_t *udata); -static herr_t 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 *idx_info_src, - const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, - hsize_t *size); -static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); -static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); - +static herr_t H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, + const H5D_t *dset); +static herr_t H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); +static int H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, + void *chunk_udata); +static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata); +static herr_t 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 *idx_info_src, + const H5D_chk_idx_info_t *idx_info_dst); +static herr_t H5D__single_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); +static herr_t H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); /*********************/ /* Package Variables */ @@ -82,36 +74,32 @@ static herr_t H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *str /* Non Index chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ - FALSE, /* Single Chunk indexing doesn't current support SWMR access */ - H5D__single_idx_init, /* init */ - H5D__single_idx_create, /* create */ - H5D__single_idx_is_space_alloc, /* is_space_alloc */ - H5D__single_idx_insert, /* insert */ - H5D__single_idx_get_addr, /* get_addr */ - NULL, /* resize */ - H5D__single_idx_iterate, /* iterate */ - H5D__single_idx_remove, /* remove */ - H5D__single_idx_delete, /* delete */ - H5D__single_idx_copy_setup, /* copy_setup */ - NULL, /* copy_shutdown */ - H5D__single_idx_size, /* size */ - H5D__single_idx_reset, /* reset */ - H5D__single_idx_dump, /* dump */ - NULL /* destroy */ + FALSE, /* Single Chunk indexing doesn't current support SWMR access */ + H5D__single_idx_init, /* init */ + H5D__single_idx_create, /* create */ + H5D__single_idx_is_space_alloc, /* is_space_alloc */ + H5D__single_idx_insert, /* insert */ + H5D__single_idx_get_addr, /* get_addr */ + NULL, /* resize */ + H5D__single_idx_iterate, /* iterate */ + H5D__single_idx_remove, /* remove */ + H5D__single_idx_delete, /* delete */ + H5D__single_idx_copy_setup, /* copy_setup */ + NULL, /* copy_shutdown */ + H5D__single_idx_size, /* size */ + H5D__single_idx_reset, /* reset */ + H5D__single_idx_dump, /* dump */ + NULL /* destroy */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5D__single_idx_init * @@ -125,8 +113,8 @@ const H5D_chunk_ops_t H5D_COPS_SINGLE[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, - const H5S_t H5_ATTR_UNUSED *space, haddr_t H5_ATTR_UNUSED dset_ohdr_addr) +H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNUSED *space, + haddr_t H5_ATTR_UNUSED dset_ohdr_addr) { FUNC_ENTER_STATIC_NOERR @@ -137,15 +125,14 @@ H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, HDassert(idx_info->layout); HDassert(idx_info->storage); - if(idx_info->pline->nused) - idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; + if (idx_info->pline->nused) + idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; else - idx_info->layout->flags = 0; + idx_info->layout->flags = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_init() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_create * @@ -173,15 +160,14 @@ H5D__single_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout->nchunks == 1); HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); - if(idx_info->pline->nused) - HDassert(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); + if (idx_info->pline->nused) + HDassert(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER); else - HDassert(!(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); + HDassert(!(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_create() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_is_space_alloc * @@ -204,7 +190,6 @@ H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) FUNC_LEAVE_NOAPI((hbool_t)H5F_addr_defined(storage->idx_addr)) } /* end H5D__single_idx_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_insert * @@ -217,10 +202,9 @@ H5D__single_idx_is_space_alloc(const H5O_storage_chunk_t *storage) *------------------------------------------------------------------------- */ static herr_t -H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, - const H5D_t *dset) +H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, const H5D_t *dset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -238,22 +222,21 @@ H5D__single_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(H5F_addr_defined(udata->chunk_block.offset)); idx_info->storage->idx_addr = udata->chunk_block.offset; - if(idx_info->pline->nused > 0) { + if (idx_info->pline->nused > 0) { H5_CHECKED_ASSIGN(idx_info->storage->u.single.nbytes, uint32_t, udata->chunk_block.length, hsize_t); - idx_info->storage->u.single.filter_mask = udata->filter_mask; + idx_info->storage->u.single.filter_mask = udata->filter_mask; } /* end if */ - if(dset) - if(dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) + if (dset) + if (dset->shared->dcpl_cache.fill.alloc_time != H5D_ALLOC_TIME_EARLY || idx_info->pline->nused > 0) /* Mark the layout dirty so that the address of the single chunk will be flushed later */ - if(H5D__mark(dset, H5D_MARK_LAYOUT) < 0) + if (H5D__mark(dset, H5D_MARK_LAYOUT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark layout as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5D__single_idx_insert() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_get_addr * @@ -282,21 +265,20 @@ H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); udata->chunk_block.offset = idx_info->storage->idx_addr; - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - udata->chunk_block.length = idx_info->storage->u.single.nbytes; - udata->filter_mask = idx_info->storage->u.single.filter_mask; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + udata->chunk_block.length = idx_info->storage->u.single.nbytes; + udata->filter_mask = idx_info->storage->u.single.filter_mask; } /* end if */ else { - udata->chunk_block.length = idx_info->layout->size; - udata->filter_mask = 0; + udata->chunk_block.length = idx_info->layout->size; + udata->filter_mask = 0; } /* end else */ - if(!H5F_addr_defined(udata->chunk_block.offset)) + if (!H5F_addr_defined(udata->chunk_block.offset)) udata->chunk_block.length = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5D__single_idx_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_iterate * @@ -309,11 +291,10 @@ H5D__single_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda *------------------------------------------------------------------------- */ static int -H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, - H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) +H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_chunk_rec_t chunk_rec; /* generic chunk record */ - int ret_value = -1; /* Return value */ + H5D_chunk_rec_t chunk_rec; /* generic chunk record */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -331,23 +312,22 @@ H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDmemset(&chunk_rec, 0, sizeof(chunk_rec)); chunk_rec.chunk_addr = idx_info->storage->idx_addr; - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { - chunk_rec.nbytes = idx_info->storage->u.single.nbytes; - chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + chunk_rec.nbytes = idx_info->storage->u.single.nbytes; + chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask; } /* end if */ else { - chunk_rec.nbytes = idx_info->layout->size; - chunk_rec.filter_mask = 0; + chunk_rec.nbytes = idx_info->layout->size; + chunk_rec.filter_mask = 0; } /* end else */ /* Make "generic chunk" callback */ - if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + if ((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_iterate() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_remove * @@ -362,8 +342,8 @@ H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info, static herr_t H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) { - hsize_t nbytes; /* Size of all chunks */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nbytes; /* Size of all chunks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -375,12 +355,12 @@ H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t HDassert(idx_info->storage); HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); - if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) - nbytes = idx_info->storage->u.single.nbytes; + if (idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) + nbytes = idx_info->storage->u.single.nbytes; else - nbytes = idx_info->layout->size; + nbytes = idx_info->layout->size; - if(H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) + if (H5MF_xfree(idx_info->f, H5FD_MEM_DRAW, idx_info->storage->idx_addr, nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, H5_ITER_ERROR, "unable to free dataset chunks") idx_info->storage->idx_addr = HADDR_UNDEF; @@ -389,7 +369,6 @@ H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t FUNC_LEAVE_NOAPI(ret_value) } /* H5D__single_idx_remove() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_delete * @@ -405,7 +384,7 @@ H5D__single_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t static herr_t H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -416,15 +395,14 @@ H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->layout); HDassert(idx_info->storage); - if(H5F_addr_defined(idx_info->storage->idx_addr)) - ret_value = H5D__single_idx_remove(idx_info, NULL); + if (H5F_addr_defined(idx_info->storage->idx_addr)) + ret_value = H5D__single_idx_remove(idx_info, NULL); else - HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_delete() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_copy_setup * @@ -438,9 +416,9 @@ 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -462,7 +440,7 @@ H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_i H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Set up information at the destination file */ - if(H5D__single_idx_create(idx_info_dst) < 0) + if (H5D__single_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Reset metadata tag */ @@ -472,7 +450,6 @@ H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_i FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__single_idx_copy_setup() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_size * @@ -498,7 +475,6 @@ H5D__single_idx_size(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, hsize_t FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_size() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_reset * @@ -519,13 +495,12 @@ H5D__single_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) HDassert(storage); /* Reset index info */ - if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + if (reset_addr) + storage->idx_addr = HADDR_UNDEF; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_reset() */ - /*------------------------------------------------------------------------- * Function: H5D__single_idx_dump * @@ -546,8 +521,7 @@ H5D__single_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", storage->idx_addr); + HDfprintf(stream, " Address: %" PRIuHADDR "\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__single_idx_dump() */ - diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 19fa172caa8..f37682d3c32 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,45 +21,38 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ -#define H5D_TESTING /*suppress warning about H5D testing funcs*/ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ +#define H5D_TESTING /*suppress warning about H5D testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5D__layout_version_test @@ -82,23 +75,22 @@ herr_t H5D__layout_version_test(hid_t did, unsigned *version) { - H5D_t *dset; /* Pointer to dataset to query */ + H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(version) + if (version) *version = dset->shared->layout.version; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_version_test() */ +} /* H5D__layout_version_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_contig_size_test @@ -121,25 +113,24 @@ H5D__layout_version_test(hid_t did, unsigned *version) herr_t H5D__layout_contig_size_test(hid_t did, hsize_t *size) { - H5D_t *dset; /* Pointer to dataset to query */ + H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(size) { + if (size) { HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); *size = dset->shared->layout.storage.u.contig.size; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_contig_size_test() */ +} /* H5D__layout_contig_size_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_compact_dirty_test @@ -168,19 +159,18 @@ H5D__layout_compact_dirty_test(hid_t did, hbool_t *dirty) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - if(dirty) { + if (dirty) { HDassert(dset->shared->layout.type == H5D_COMPACT); *dirty = dset->shared->layout.storage.u.compact.dirty; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_compact_dirty_test() */ +} /* H5D__layout_compact_dirty_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_type_test @@ -203,25 +193,24 @@ H5D__layout_compact_dirty_test(hid_t did, hbool_t *dirty) herr_t H5D__layout_type_test(hid_t did, H5D_layout_t *layout_type) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE HDassert(layout_type); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(layout_type) + if (layout_type) *layout_type = dset->shared->layout.type; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_type_test() */ +} /* H5D__layout_type_test() */ - /*-------------------------------------------------------------------------- NAME H5D__layout_idx_type_test @@ -244,25 +233,24 @@ H5D__layout_type_test(hid_t did, H5D_layout_t *layout_type) herr_t H5D__layout_idx_type_test(hid_t did, H5D_chunk_index_t *idx_type) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(dset->shared->layout.type != H5D_CHUNKED) + if (dset->shared->layout.type != H5D_CHUNKED) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not chunked") - if(idx_type) + if (idx_type) *idx_type = dset->shared->layout.u.chunk.idx_type; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__layout_idx_type_test() */ +} /* H5D__layout_idx_type_test() */ - /*-------------------------------------------------------------------------- NAME H5D__current_cache_size_test @@ -285,26 +273,25 @@ H5D__layout_idx_type_test(hid_t did, H5D_chunk_index_t *idx_type) herr_t H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(nbytes_used) { + if (nbytes_used) { HDassert(dset->shared->layout.type == H5D_CHUNKED); *nbytes_used = dset->shared->cache.chunk.nbytes_used; } /* end if */ - if(nused) { + if (nused) { HDassert(dset->shared->layout.type == H5D_CHUNKED); *nused = dset->shared->cache.chunk.nused; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5D__current_cache_size_test() */ - +} /* H5D__current_cache_size_test() */ diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 01365099875..beee8c691ab 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -46,26 +46,25 @@ /* Module Setup */ /****************/ -#include "H5Dmodule.h" /* This source code file is part of the H5D module */ - +#include "H5Dmodule.h" /* This source code file is part of the H5D module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property Lists */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property Lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -74,76 +73,56 @@ /* Default size for sub_dset array */ #define H5D_VIRTUAL_DEF_SUB_DSET_SIZE 128 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* 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); -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); -static herr_t H5D__virtual_flush(H5D_t *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); +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); +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, - 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, - 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_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, + 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, + 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, + const H5S_t *file_space, const 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); -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); - +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); +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); /*********************/ /* 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, H5D__virtual_init, H5D__virtual_is_space_alloc, + H5D__virtual_is_data_cached, NULL, H5D__virtual_read, + H5D__virtual_write, #ifdef H5_HAVE_PARALLEL - NULL, - NULL, + NULL, NULL, #endif /* H5_HAVE_PARALLEL */ - NULL, - NULL, - H5D__virtual_flush, - NULL, - NULL -}}; - + NULL, NULL, H5D__virtual_flush, NULL, NULL}}; /*******************/ /* Local Variables */ @@ -155,8 +134,6 @@ H5FL_DEFINE(H5O_storage_virtual_name_seg_t); /* Declare a static free list to manage H5D_virtual_file_list_t structs */ H5FL_DEFINE_STATIC(H5D_virtual_held_file_t); - - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_mapping_pre * @@ -173,60 +150,66 @@ H5FL_DEFINE_STATIC(H5D_virtual_held_file_t); */ herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, - H5O_virtual_space_status_t space_status) + H5O_virtual_space_status_t space_status) { - H5S_sel_type select_type; /* Selection type */ - hsize_t nelmts_vs; /* Number of elements in virtual selection */ - hsize_t nelmts_ss; /* Number of elements in source selection */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_sel_type select_type; /* Selection type */ + hsize_t nelmts_vs; /* Number of elements in virtual selection */ + hsize_t nelmts_ss; /* Number of elements in source selection */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for point selections (currently unsupported) */ - if(H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(vspace))) + if (H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(vspace))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get selection type") - if(select_type == H5S_SEL_POINTS) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "point selections not currently supported with virtual datasets") - if(H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(src_space))) + if (select_type == H5S_SEL_POINTS) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "point selections not currently supported with virtual datasets") + if (H5S_SEL_ERROR == (select_type = H5S_GET_SELECT_TYPE(src_space))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get selection type") - if(select_type == H5S_SEL_POINTS) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "point selections not currently supported with virtual datasets") + if (select_type == H5S_SEL_POINTS) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "point selections not currently supported with virtual datasets") /* Get number of elements in spaces */ nelmts_vs = (hsize_t)H5S_GET_SELECT_NPOINTS(vspace); nelmts_ss = (hsize_t)H5S_GET_SELECT_NPOINTS(src_space); /* Check for unlimited vspace */ - if(nelmts_vs == H5S_UNLIMITED) { + if (nelmts_vs == H5S_UNLIMITED) { /* Check for unlimited src_space */ - if(nelmts_ss == H5S_UNLIMITED) { - hsize_t nenu_vs; /* Number of elements in the non-unlimited dimensions of vspace */ - hsize_t nenu_ss; /* Number of elements in the non-unlimited dimensions of src_space */ + if (nelmts_ss == H5S_UNLIMITED) { + hsize_t nenu_vs; /* Number of elements in the non-unlimited dimensions of vspace */ + hsize_t nenu_ss; /* Number of elements in the non-unlimited dimensions of src_space */ /* Non-printf unlimited selection. Make sure both selections have * the same number of elements in the non-unlimited dimension. Note * we can always check this even if the space status is invalid * because unlimited selections are never dependent on the extent. */ - if(H5S_get_select_num_elem_non_unlim(vspace, &nenu_vs) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") - if(H5S_get_select_num_elem_non_unlim(src_space, &nenu_ss) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "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 virtual spaces") + if (H5S_get_select_num_elem_non_unlim(vspace, &nenu_vs) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "can't get number of elements in non-unlimited dimension") + if (H5S_get_select_num_elem_non_unlim(src_space, &nenu_ss) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "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 " + "virtual spaces") } /* end if */ /* We will handle the printf case after parsing the source names */ } /* end if */ - else if(space_status != H5O_VIRTUAL_STATUS_INVALID) + else if (space_status != H5O_VIRTUAL_STATUS_INVALID) /* Limited selections. Check number of points is the same. */ - if(nelmts_vs != nelmts_ss) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual and source space selections have different numbers of elements") + if (nelmts_vs != nelmts_ss) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual and source space selections have different numbers of elements") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_mapping_pre() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_mapping_post * @@ -243,10 +226,10 @@ H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, herr_t 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -255,46 +238,52 @@ H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) nelmts_ss = (hsize_t)H5S_GET_SELECT_NPOINTS(ent->source_select); /* Check for printf selection */ - if((nelmts_vs == H5S_UNLIMITED) && (nelmts_ss != H5S_UNLIMITED)) { + if ((nelmts_vs == H5S_UNLIMITED) && (nelmts_ss != H5S_UNLIMITED)) { /* Make sure there at least one %b substitution in the source file or * dataset name */ - if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unlimited virtual selection, limited source selection, and no printf specifiers in source names") + if ((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "unlimited virtual selection, limited source selection, and no printf specifiers in " + "source names") /* Make sure virtual space uses hyperslab selection */ - if(H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select) != H5S_SEL_HYPERSLABS) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "virtual selection with printf mapping must be hyperslab") + if (H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select) != H5S_SEL_HYPERSLABS) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "virtual selection with printf mapping must be hyperslab") /* Check that the number of elements in one block in the virtual * selection matches the total number of elements in the source * selection, if the source space status is not invalid (virtual space * status does not matter here because it is unlimited) */ - if(ent->source_space_status != H5O_VIRTUAL_STATUS_INVALID) { + if (ent->source_space_status != H5O_VIRTUAL_STATUS_INVALID) { /* Get first block in virtual selection */ - if(NULL == (tmp_space = H5S_hyper_get_unlim_block(ent->source_dset.virtual_select, (hsize_t)0))) + if (NULL == (tmp_space = H5S_hyper_get_unlim_block(ent->source_dset.virtual_select, (hsize_t)0))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get first block in virtual selection") /* Check number of points */ nelmts_vs = (hsize_t)H5S_GET_SELECT_NPOINTS(tmp_space); - if(nelmts_vs != nelmts_ss) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual (single block) and source space selections have different numbers of elements") + if (nelmts_vs != nelmts_ss) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual (single block) and source space selections have different numbers of elements") } /* end if */ - } /* end if */ + } /* end if */ 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") + 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") done: /* Free temporary space */ - if(tmp_space) - if(H5S_close(tmp_space) < 0) + if (tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_mapping_post() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_update_min_dims * @@ -313,14 +302,14 @@ 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_ent_t *ent = &virt->list[idx]; - H5S_sel_type sel_type; - int rank; - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; - int i; - herr_t ret_value = SUCCEED; + 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; + hsize_t bounds_start[H5S_MAX_RANK]; + hsize_t bounds_end[H5S_MAX_RANK]; + int i; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -329,33 +318,31 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) HDassert(idx < virt->list_nalloc); /* Get type of selection */ - if(H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select))) + if (H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection type") /* Do not update min_dims for "all" or "none" selections */ - if((sel_type == H5S_SEL_ALL) || (sel_type == H5S_SEL_NONE)) + if ((sel_type == H5S_SEL_ALL) || (sel_type == H5S_SEL_NONE)) HGOTO_DONE(SUCCEED) /* Get rank of vspace */ - if((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get selection bounds */ - if(H5S_SELECT_BOUNDS(ent->source_dset.virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(ent->source_dset.virtual_select, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Update min_dims */ - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) /* Don't check unlimited dimensions in the selection */ - if((i != ent->unlim_dim_virtual) - && (bounds_end[i] >= virt->min_dims[i])) + if ((i != ent->unlim_dim_virtual) && (bounds_end[i] >= virt->min_dims[i])) virt->min_dims[i] = bounds_end[i] + (hsize_t)1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_update_min_dims() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_check_min_dims * @@ -372,10 +359,10 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) herr_t H5D_virtual_check_min_dims(const H5D_t *dset) { - int rank; - hsize_t dims[H5S_MAX_RANK]; - int i; - herr_t ret_value = SUCCEED; + int rank; + hsize_t dims[H5S_MAX_RANK]; + int i; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -384,31 +371,32 @@ H5D_virtual_check_min_dims(const H5D_t *dset) HDassert(dset->shared->layout.type == H5D_VIRTUAL); /* Get rank of dataspace */ - if((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Verify that dimensions are larger than min_dims */ - for(i = 0; i < rank; i++) - if(dims[i] < dset->shared->layout.storage.u.virt.min_dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + for (i = 0; i < rank; i++) + if (dims[i] < dset->shared->layout.storage.u.virt.min_dims[i]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions in " + "all selections") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_min_dims() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_store_layout * * Purpose: Store virtual dataset layout information, for new dataset * * Note: We assume here that the contents of the heap block cannot - * change! If this ever stops being the case we must change - * this code to allow overwrites of the heap block. -NAF + * change! If this ever stops being the case we must change + * this code to allow overwrites of the heap block. -NAF * * Return: Success: SUCCEED * Failure: FAIL @@ -421,15 +409,15 @@ H5D_virtual_check_min_dims(const H5D_t *dset) 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 */ - 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 */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -439,13 +427,13 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) HDassert(virt->serial_list_hobjid.addr == HADDR_UNDEF); /* Create block if # of used entries > 0 */ - if(virt->list_nused > 0) { + if (virt->list_nused > 0) { /* Set the low/high bounds according to 'f' for the API context */ H5CX_set_libver_bounds(f); /* Allocate array for caching results of strlen */ - if(NULL == (str_size = (size_t *)H5MM_malloc(2 * virt->list_nused * sizeof(size_t)))) + if (NULL == (str_size = (size_t *)H5MM_malloc(2 * virt->list_nused * sizeof(size_t)))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array") /* @@ -456,9 +444,9 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) block_size = (size_t)1 + H5F_SIZEOF_SIZE(f); /* Calculate size of each entry */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; - hssize_t select_serial_size; /* Size of serialized selection */ + hssize_t select_serial_size; /* Size of serialized selection */ HDassert(ent->source_file_name); HDassert(ent->source_dset_name); @@ -474,12 +462,12 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) block_size += str_size[(2 * i) + 1]; /* Source selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_select)) < 0) + if ((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; /* Virtual dataset selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_dset.virtual_select)) < 0) + if ((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; } /* end for */ @@ -487,12 +475,10 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Checksum */ block_size += 4; - /* Allocate heap block */ - if(NULL == (heap_block = (uint8_t *)H5MM_malloc(block_size))) + if (NULL == (heap_block = (uint8_t *)H5MM_malloc(block_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate heap block") - /* * Encode heap block */ @@ -506,7 +492,7 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) H5F_ENCODE_LENGTH(f, heap_block_p, tmp_nentries) /* Encode each entry */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Source file name */ H5MM_memcpy((char *)heap_block_p, ent->source_file_name, str_size[2 * i]); @@ -517,11 +503,11 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) heap_block_p += str_size[(2 * i) + 1]; /* Source selection */ - if(H5S_SELECT_SERIALIZE(ent->source_select, &heap_block_p) < 0) + if (H5S_SELECT_SERIALIZE(ent->source_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize source selection") /* Virtual selection */ - if(H5S_SELECT_SERIALIZE(ent->source_dset.virtual_select, &heap_block_p) < 0) + if (H5S_SELECT_SERIALIZE(ent->source_dset.virtual_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize virtual selection") } /* end for */ @@ -530,18 +516,18 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) UINT32ENCODE(heap_block_p, chksum) /* Insert block into global heap */ - if(H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < 0) /* Casting away const OK --NAF */ + if (H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < + 0) /* Casting away const OK --NAF */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to insert virtual dataset heap block") } /* end if */ done: heap_block = (uint8_t *)H5MM_xfree(heap_block); - str_size = (size_t *)H5MM_xfree(str_size); + str_size = (size_t *)H5MM_xfree(str_size); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_store_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy_layout * @@ -561,12 +547,12 @@ 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; - hid_t orig_source_fapl; - hid_t orig_source_dapl; - H5P_genplist_t *plist; - size_t i; - herr_t ret_value = SUCCEED; + H5O_storage_virtual_t * virt = &layout->storage.u.virt; + hid_t orig_source_fapl; + hid_t orig_source_dapl; + H5P_genplist_t * plist; + size_t i; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -575,124 +561,120 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Save original entry list and top-level property lists and reset in layout * so the originals aren't closed on error */ - orig_source_fapl = virt->source_fapl; + orig_source_fapl = virt->source_fapl; virt->source_fapl = -1; - orig_source_dapl = virt->source_dapl; + orig_source_dapl = virt->source_dapl; virt->source_dapl = -1; - orig_list = virt->list; - virt->list = NULL; + orig_list = virt->list; + virt->list = NULL; /* Copy entry list */ - if(virt->list_nused > 0) { + if (virt->list_nused > 0) { HDassert(orig_list); /* Allocate memory for the list */ - if(NULL == (virt->list = H5MM_calloc(virt->list_nused * sizeof(virt->list[0])))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for virtual dataset entry list") + if (NULL == (virt->list = H5MM_calloc(virt->list_nused * sizeof(virt->list[0])))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "unable to allocate memory for virtual dataset entry list") virt->list_nalloc = virt->list_nused; /* Copy the list entries, though set source_dset.dset and sub_dset to * NULL */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Copy virtual selection */ - if(NULL == (ent->source_dset.virtual_select - = H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (ent->source_dset.virtual_select = + H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Copy original source names */ - if(NULL == (ent->source_file_name - = H5MM_strdup(orig_list[i].source_file_name))) + if (NULL == (ent->source_file_name = H5MM_strdup(orig_list[i].source_file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") - if(NULL == (ent->source_dset_name - = H5MM_strdup(orig_list[i].source_dset_name))) + if (NULL == (ent->source_dset_name = H5MM_strdup(orig_list[i].source_dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") /* Copy source selection */ - if(NULL == (ent->source_select - = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) + if (NULL == (ent->source_select = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Initialize clipped selections */ - if(orig_list[i].unlim_dim_virtual < 0) { - ent->source_dset.clipped_source_select = ent->source_select; + if (orig_list[i].unlim_dim_virtual < 0) { + ent->source_dset.clipped_source_select = ent->source_select; ent->source_dset.clipped_virtual_select = ent->source_dset.virtual_select; } /* end if */ /* Copy parsed names */ - if(H5D__virtual_copy_parsed_name(&ent->parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) + if (H5D__virtual_copy_parsed_name(&ent->parsed_source_file_name, + orig_list[i].parsed_source_file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source file name") ent->psfn_static_strlen = orig_list[i].psfn_static_strlen; - ent->psfn_nsubs = orig_list[i].psfn_nsubs; - if(H5D__virtual_copy_parsed_name(&ent->parsed_source_dset_name, orig_list[i].parsed_source_dset_name) < 0) + ent->psfn_nsubs = orig_list[i].psfn_nsubs; + if (H5D__virtual_copy_parsed_name(&ent->parsed_source_dset_name, + orig_list[i].parsed_source_dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source dataset name") ent->psdn_static_strlen = orig_list[i].psdn_static_strlen; - ent->psdn_nsubs = orig_list[i].psdn_nsubs; + ent->psdn_nsubs = orig_list[i].psdn_nsubs; /* Copy source names in source dset or add reference as appropriate */ - if(orig_list[i].source_dset.file_name) { - if(orig_list[i].source_dset.file_name - == orig_list[i].source_file_name) + if (orig_list[i].source_dset.file_name) { + if (orig_list[i].source_dset.file_name == orig_list[i].source_file_name) ent->source_dset.file_name = ent->source_file_name; - else if(orig_list[i].parsed_source_file_name - && (orig_list[i].source_dset.file_name - != orig_list[i].parsed_source_file_name->name_segment)) { + else if (orig_list[i].parsed_source_file_name && + (orig_list[i].source_dset.file_name != + orig_list[i].parsed_source_file_name->name_segment)) { HDassert(ent->parsed_source_file_name); HDassert(ent->parsed_source_file_name->name_segment); ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; } /* end if */ - else - if(NULL == (ent->source_dset.file_name - = H5MM_strdup(orig_list[i].source_dset.file_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + else if (NULL == + (ent->source_dset.file_name = H5MM_strdup(orig_list[i].source_dset.file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") } /* end if */ - if(orig_list[i].source_dset.dset_name) { - if(orig_list[i].source_dset.dset_name - == orig_list[i].source_dset_name) + if (orig_list[i].source_dset.dset_name) { + if (orig_list[i].source_dset.dset_name == orig_list[i].source_dset_name) ent->source_dset.dset_name = ent->source_dset_name; - else if(orig_list[i].parsed_source_dset_name - && (orig_list[i].source_dset.dset_name - != orig_list[i].parsed_source_dset_name->name_segment)) { + else if (orig_list[i].parsed_source_dset_name && + (orig_list[i].source_dset.dset_name != + orig_list[i].parsed_source_dset_name->name_segment)) { HDassert(ent->parsed_source_dset_name); HDassert(ent->parsed_source_dset_name->name_segment); ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; } /* end if */ - else - if(NULL == (ent->source_dset.dset_name - = H5MM_strdup(orig_list[i].source_dset.dset_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + else if (NULL == + (ent->source_dset.dset_name = H5MM_strdup(orig_list[i].source_dset.dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") } /* end if */ /* Copy other fields in entry */ - ent->unlim_dim_source = orig_list[i].unlim_dim_source; - ent->unlim_dim_virtual = orig_list[i].unlim_dim_virtual; - ent->unlim_extent_source = orig_list[i].unlim_extent_source; + ent->unlim_dim_source = orig_list[i].unlim_dim_source; + ent->unlim_dim_virtual = orig_list[i].unlim_dim_virtual; + ent->unlim_extent_source = orig_list[i].unlim_extent_source; ent->unlim_extent_virtual = orig_list[i].unlim_extent_virtual; - ent->clip_size_source = orig_list[i].clip_size_source; - ent->clip_size_virtual = orig_list[i].clip_size_virtual; - ent->source_space_status = orig_list[i].source_space_status; + ent->clip_size_source = orig_list[i].clip_size_source; + ent->clip_size_virtual = orig_list[i].clip_size_virtual; + ent->source_space_status = orig_list[i].source_space_status; ent->virtual_space_status = orig_list[i].virtual_space_status; } /* end for */ - } /* end if */ + } /* end if */ else { /* Zero out other fields related to list, just to be sure */ - virt->list = NULL; + virt->list = NULL; virt->list_nalloc = 0; } /* end else */ /* Copy property lists */ - if(orig_source_fapl >= 0) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_fapl, H5I_GENPROP_LST))) + if (orig_source_fapl >= 0) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_fapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((virt->source_fapl = H5P_copy_plist(plist, FALSE)) < 0) + if ((virt->source_fapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy fapl") } /* end if */ - if(orig_source_dapl >= 0) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_dapl, H5I_GENPROP_LST))) + if (orig_source_dapl >= 0) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_dapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((virt->source_dapl = H5P_copy_plist(plist, FALSE)) < 0) + if ((virt->source_dapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dapl") } /* end if */ @@ -701,14 +683,13 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) done: /* Release allocated resources on failure */ - if(ret_value < 0) - if(H5D__virtual_reset_layout(layout) < 0) + if (ret_value < 0) + if (H5D__virtual_reset_layout(layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset virtual layout") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_reset_layout * @@ -728,9 +709,9 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) herr_t H5D__virtual_reset_layout(H5O_layout_t *layout) { - size_t i, j; - H5O_storage_virtual_t *virt = &layout->storage.u.virt; - herr_t ret_value = SUCCEED; + size_t i, j; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -740,10 +721,10 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) /* Free the list entries. Note we always attempt to free everything even in * the case of a failure. Because of this, and because we free the list * afterwards, we do not need to zero out the memory in the list. */ - for(i = 0; i < virt->list_nused; i++) { + for (i = 0; i < virt->list_nused; i++) { H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Free source_dset */ - if(H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) + if (H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") /* Free original source names */ @@ -751,14 +732,14 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) (void)H5MM_xfree(ent->source_dset_name); /* Free sub_dset */ - for(j = 0; j < ent->sub_dset_nalloc; j++) - if(H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) + for (j = 0; j < ent->sub_dset_nalloc; j++) + if (H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") ent->sub_dset = H5MM_xfree(ent->sub_dset); /* Free source_select */ - if(ent->source_select) - if(H5S_close(ent->source_select) < 0) + if (ent->source_select) + if (H5S_close(ent->source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") /* Free parsed_source_file_name */ @@ -769,19 +750,19 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) } /* Free the list */ - virt->list = H5MM_xfree(virt->list); + virt->list = H5MM_xfree(virt->list); virt->list_nalloc = (size_t)0; - virt->list_nused = (size_t)0; + virt->list_nused = (size_t)0; (void)HDmemset(virt->min_dims, 0, sizeof(virt->min_dims)); /* Close access property lists */ - if(virt->source_fapl >= 0) { - if(H5I_dec_ref(virt->source_fapl) < 0) + if (virt->source_fapl >= 0) { + if (H5I_dec_ref(virt->source_fapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source fapl") virt->source_fapl = -1; } - if(virt->source_dapl >= 0) { - if(H5I_dec_ref(virt->source_dapl) < 0) + if (virt->source_dapl >= 0) { + if (H5I_dec_ref(virt->source_dapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source dapl") virt->source_dapl = -1; } @@ -794,7 +775,6 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_reset_layout() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy * @@ -810,15 +790,15 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) herr_t H5D__virtual_copy(H5F_t *f_dst, H5O_layout_t *layout_dst) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE #ifdef NOT_YET /* Check for copy to the same file */ - if(f_dst == f_src) { + if (f_dst == f_src) { /* Increase reference count on global heap object */ - if((heap_rc = H5HG_link(f_dst, (H5HG_t *)&(layout_dst->u.virt.serial_list_hobjid), 1)) < 0) + if ((heap_rc = H5HG_link(f_dst, (H5HG_t *)&(layout_dst->u.virt.serial_list_hobjid), 1)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMODIFY, FAIL, "unable to adjust global heap reference count") } /* end if */ else @@ -826,18 +806,17 @@ H5D__virtual_copy(H5F_t *f_dst, H5O_layout_t *layout_dst) { /* Reset global heap id */ layout_dst->storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - layout_dst->storage.u.virt.serial_list_hobjid.idx = (size_t)0; + layout_dst->storage.u.virt.serial_list_hobjid.idx = (size_t)0; /* Write the VDS data to destination file's heap */ - if(H5D__virtual_store_layout(f_dst, layout_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") + if (H5D__virtual_store_layout(f_dst, layout_dst) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to store VDS info") } /* end block/else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_delete * @@ -855,7 +834,7 @@ H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage) { #ifdef NOT_YET int heap_rc; /* Reference count of global heap object */ -#endif /* NOT_YET */ +#endif /* NOT_YET */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -866,27 +845,26 @@ H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage) HDassert(storage->type == H5D_VIRTUAL); /* Check for global heap block */ - if(storage->u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { + if (storage->u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { #ifdef NOT_YET /* Unlink the global heap block */ - if((heap_rc = H5HG_link(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid), -1)) < 0) + if ((heap_rc = H5HG_link(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid), -1)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMODIFY, FAIL, "unable to adjust global heap reference count") - if(heap_rc == 0) + if (heap_rc == 0) #endif /* NOT_YET */ /* Delete the global heap block */ - if(H5HG_remove(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid)) < 0) + if (H5HG_remove(f, (H5HG_t *)&(storage->u.virt.serial_list_hobjid)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "unable to remove heap object") } /* end if */ /* Clear global heap ID in storage */ storage->u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - storage->u.virt.serial_list_hobjid.idx = 0; + storage->u.virt.serial_list_hobjid.idx = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_delete */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_open_source_dset * @@ -900,13 +878,12 @@ H5D__virtual_delete(H5F_t *f, H5O_storage_t *storage) *------------------------------------------------------------------------- */ 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) +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 */ - hbool_t src_file_open = FALSE; /* Whether we have opened and need to close src_file */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -918,17 +895,19 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, HDassert(source_dset->dset_name); /* Check if we need to open the source file */ - if(HDstrcmp(source_dset->file_name, ".")) { - unsigned intent; /* File access permissions */ + if (HDstrcmp(source_dset->file_name, ".") != 0) { + unsigned intent; /* File access permissions */ /* Get the virtual dataset's file open flags ("intent") */ intent = H5F_INTENT(vdset->oloc.file); /* Try opening the file */ - src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix, source_dset->file_name, intent, vdset->shared->layout.storage.u.virt.source_fapl); + src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix, + source_dset->file_name, intent, + vdset->shared->layout.storage.u.virt.source_fapl); /* If we opened the source file here, we should close it when leaving */ - if(src_file) + if (src_file) src_file_open = TRUE; else /* Reset the error stack */ @@ -938,20 +917,21 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, /* Source file is ".", use the virtual dataset's file */ src_file = vdset->oloc.file; - if(src_file) { - H5G_loc_t src_root_loc; /* Object location of source file root group */ + if (src_file) { + H5G_loc_t src_root_loc; /* Object location of source file root group */ /* Set up the root group in the destination file */ - if(NULL == (src_root_loc.oloc = H5G_oloc(H5G_rootof(src_file)))) + if (NULL == (src_root_loc.oloc = H5G_oloc(H5G_rootof(src_file)))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (src_root_loc.path = H5G_nameof(H5G_rootof(src_file)))) + if (NULL == (src_root_loc.path = H5G_nameof(H5G_rootof(src_file)))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Try opening the source dataset */ - source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, vdset->shared->layout.storage.u.virt.source_dapl); + source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, + vdset->shared->layout.storage.u.virt.source_dapl); /* Dataset does not exist */ - if(NULL == source_dset->dset) { + if (NULL == source_dset->dset) { /* Reset the error stack */ H5E_clear_stack(NULL); @@ -962,24 +942,23 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, source_dset->dset_exists = TRUE; /* Patch the source selection if necessary */ - if(virtual_ent->source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { - if(H5S_extent_copy(virtual_ent->source_select, source_dset->dset->shared->space) < 0) + if (virtual_ent->source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { + if (H5S_extent_copy(virtual_ent->source_select, source_dset->dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") virtual_ent->source_space_status = H5O_VIRTUAL_STATUS_CORRECT; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(src_file_open) - if(H5F_efc_close(vdset->oloc.file, src_file) < 0) + if (src_file_open) + if (H5F_efc_close(vdset->oloc.file, src_file) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close source file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_open_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_reset_source_dset * @@ -993,10 +972,10 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, - H5O_storage_virtual_srcdset_t *source_dset) +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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1004,55 +983,51 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, HDassert(source_dset); /* Free dataset */ - if(source_dset->dset) { - if(H5D_close(source_dset->dset) < 0) + if (source_dset->dset) { + if (H5D_close(source_dset->dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") source_dset->dset = NULL; } /* end if */ /* Free file name */ - if(virtual_ent->parsed_source_file_name - && (source_dset->file_name - != virtual_ent->parsed_source_file_name->name_segment)) + if (virtual_ent->parsed_source_file_name && + (source_dset->file_name != virtual_ent->parsed_source_file_name->name_segment)) source_dset->file_name = (char *)H5MM_xfree(source_dset->file_name); else - HDassert((source_dset->file_name == virtual_ent->source_file_name) - || (virtual_ent->parsed_source_file_name - && (source_dset->file_name - == virtual_ent->parsed_source_file_name->name_segment)) - || !source_dset->file_name); + HDassert((source_dset->file_name == virtual_ent->source_file_name) || + (virtual_ent->parsed_source_file_name && + (source_dset->file_name == virtual_ent->parsed_source_file_name->name_segment)) || + !source_dset->file_name); /* Free dataset name */ - if(virtual_ent->parsed_source_dset_name - && (source_dset->dset_name - != virtual_ent->parsed_source_dset_name->name_segment)) + if (virtual_ent->parsed_source_dset_name && + (source_dset->dset_name != virtual_ent->parsed_source_dset_name->name_segment)) source_dset->dset_name = (char *)H5MM_xfree(source_dset->dset_name); else - HDassert((source_dset->dset_name == virtual_ent->source_dset_name) - || (virtual_ent->parsed_source_dset_name - && (source_dset->dset_name - == virtual_ent->parsed_source_dset_name->name_segment)) - || !source_dset->dset_name); + HDassert((source_dset->dset_name == virtual_ent->source_dset_name) || + (virtual_ent->parsed_source_dset_name && + (source_dset->dset_name == virtual_ent->parsed_source_dset_name->name_segment)) || + !source_dset->dset_name); /* Free clipped virtual selection */ - if(source_dset->clipped_virtual_select) { - if(source_dset->clipped_virtual_select != source_dset->virtual_select) - if(H5S_close(source_dset->clipped_virtual_select) < 0) + if (source_dset->clipped_virtual_select) { + if (source_dset->clipped_virtual_select != source_dset->virtual_select) + if (H5S_close(source_dset->clipped_virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual selection") source_dset->clipped_virtual_select = NULL; } /* end if */ /* Free virtual selection */ - if(source_dset->virtual_select) { - if(H5S_close(source_dset->virtual_select) < 0) + if (source_dset->virtual_select) { + if (H5S_close(source_dset->virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") source_dset->virtual_select = NULL; } /* end if */ /* Free clipped source selection */ - if(source_dset->clipped_source_select) { - if(source_dset->clipped_source_select != virtual_ent->source_select) - if(H5S_close(source_dset->clipped_source_select) < 0) + if (source_dset->clipped_source_select) { + if (source_dset->clipped_source_select != virtual_ent->source_select) + if (H5S_close(source_dset->clipped_source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source selection") source_dset->clipped_source_select = NULL; } /* end if */ @@ -1066,7 +1041,6 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_reset_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_str_append * @@ -1081,10 +1055,9 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, - size_t *buf_size) +H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, size_t *buf_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1097,36 +1070,35 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, HDassert(buf_size); /* Allocate or extend buffer if necessary */ - if(!*buf) { + if (!*buf) { HDassert(!*p); HDassert(*buf_size == 0); /* Allocate buffer */ - if(NULL == (*buf = (char *)H5MM_malloc(src_len + (size_t)1))) + if (NULL == (*buf = (char *)H5MM_malloc(src_len + (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") *buf_size = src_len + (size_t)1; - *p = *buf; + *p = *buf; } /* end if */ else { size_t p_offset = (size_t)(*p - *buf); /* Offset of p within buf */ /* Extend buffer if necessary */ - if((p_offset + src_len + (size_t)1) > *buf_size) { - char *tmp_buf; + if ((p_offset + src_len + (size_t)1) > *buf_size) { + char * tmp_buf; size_t tmp_buf_size; /* Calculate new size of buffer */ - tmp_buf_size = MAX(p_offset + src_len + (size_t)1, - *buf_size * (size_t)2); + tmp_buf_size = MAX(p_offset + src_len + (size_t)1, *buf_size * (size_t)2); /* Reallocate buffer */ - if(NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) + if (NULL == (tmp_buf = (char *)H5MM_realloc(*buf, tmp_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to reallocate name segment buffer") - *buf = tmp_buf; + *buf = tmp_buf; *buf_size = tmp_buf_size; - *p = *buf + p_offset; + *p = *buf + p_offset; } /* end if */ - } /* end else */ + } /* end else */ /* Copy string to *p. Note that since src in not NULL terminated, we must * use memcpy */ @@ -1142,7 +1114,6 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, FUNC_LEAVE_NOAPI(ret_value); } /* end H5D__virtual_str_append() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_parse_source_name * @@ -1156,20 +1127,19 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, *------------------------------------------------------------------------- */ 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) +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; - size_t name_seg_size = 0; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + size_t name_seg_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1180,38 +1150,40 @@ H5D_virtual_parse_source_name(const char *source_name, HDassert(nsubs); /* Initialize p and tmp_static_strlen */ - p = source_name; + p = source_name; tmp_static_strlen = tmp_strlen = HDstrlen(source_name); /* Iterate over name */ /* Note this will not work with UTF-8! We should support this eventually * -NAF 5/18/2015 */ - while((pct = HDstrchr(p, '%'))) { + while ((pct = HDstrchr(p, '%'))) { HDassert(pct >= p); /* Allocate name segment struct if necessary */ - if(!*tmp_parsed_name_p) - if(NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (!*tmp_parsed_name_p) + if (NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Check for type of format specifier */ - if(pct[1] == 'b') { + if (pct[1] == 'b') { /* Check for blank string before specifier */ - if(pct != p) + if (pct != p) /* Append string to name segment */ - if(H5D__virtual_str_append(p, (size_t)(pct - p), &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, (size_t)(pct - p), &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") /* Update other variables */ tmp_parsed_name_p = &(*tmp_parsed_name_p)->next; tmp_static_strlen -= 2; tmp_nsubs++; - name_seg_p = NULL; + name_seg_p = NULL; name_seg_size = 0; } /* end if */ - else if(pct[1] == '%') { + else if (pct[1] == '%') { /* Append string to name segment (include first '%') */ - if(H5D__virtual_str_append(p, (size_t)(pct - p) + (size_t)1, &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, (size_t)(pct - p) + (size_t)1, &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") /* Update other variables */ @@ -1225,32 +1197,33 @@ H5D_virtual_parse_source_name(const char *source_name, /* Copy last segment of name, if any, unless the parsed name was not * allocated */ - if(tmp_parsed_name) { + if (tmp_parsed_name) { HDassert(p >= source_name); - if(*p == '\0') + if (*p == '\0') HDassert((size_t)(p - source_name) == tmp_strlen); else { HDassert((size_t)(p - source_name) < tmp_strlen); /* Allocate name segment struct if necessary */ - if(!*tmp_parsed_name_p) - if(NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (!*tmp_parsed_name_p) + if (NULL == (*tmp_parsed_name_p = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Append string to name segment */ - if(H5D__virtual_str_append(p, tmp_strlen - (size_t)(p - source_name), &name_seg_p, &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) + if (H5D__virtual_str_append(p, tmp_strlen - (size_t)(p - source_name), &name_seg_p, + &(*tmp_parsed_name_p)->name_segment, &name_seg_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to append name segment") } /* end else */ - } /* end if */ + } /* end if */ /* Set return values */ - *parsed_name = tmp_parsed_name; + *parsed_name = tmp_parsed_name; tmp_parsed_name = NULL; - *static_strlen = tmp_static_strlen; - *nsubs = tmp_nsubs; + *static_strlen = tmp_static_strlen; + *nsubs = tmp_nsubs; done: - if(tmp_parsed_name) { + if (tmp_parsed_name) { HDassert(ret_value < 0); H5D_virtual_free_parsed_name(tmp_parsed_name); } /* end if */ @@ -1258,7 +1231,6 @@ H5D_virtual_parse_source_name(const char *source_name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_parse_source_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_copy_parsed_name * @@ -1272,13 +1244,12 @@ H5D_virtual_parse_source_name(const char *source_name, *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, - H5O_storage_virtual_name_seg_t *src) +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 **p_dst = &tmp_dst; - herr_t ret_value = SUCCEED; + 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; FUNC_ENTER_STATIC @@ -1286,14 +1257,14 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, HDassert(dst); /* Walk over parsed name, duplicating it */ - while(p_src) { + while (p_src) { /* Allocate name segment struct */ - if(NULL == (*p_dst = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) + if (NULL == (*p_dst = H5FL_CALLOC(H5O_storage_virtual_name_seg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name segment struct") /* Duplicate name segment */ - if(p_src->name_segment) { - if(NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) + if (p_src->name_segment) { + if (NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") } /* end if */ @@ -1303,11 +1274,11 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, } /* end while */ /* Set dst */ - *dst = tmp_dst; + *dst = tmp_dst; tmp_dst = NULL; done: - if(tmp_dst) { + if (tmp_dst) { HDassert(ret_value < 0); H5D_virtual_free_parsed_name(tmp_dst); } /* end if */ @@ -1315,7 +1286,6 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy_parsed_name() */ - /*------------------------------------------------------------------------- * Function: H5D_virtual_free_parsed_name * @@ -1332,12 +1302,12 @@ herr_t H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) { H5O_storage_virtual_name_seg_t *next_seg; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Walk name segments, freeing them */ - while(name_seg) { + while (name_seg) { (void)H5MM_xfree(name_seg->name_segment); next_seg = name_seg->next; (void)H5FL_FREE(H5O_storage_virtual_name_seg_t, name_seg); @@ -1348,7 +1318,6 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_free_parsed_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_build_source_name * @@ -1362,12 +1331,11 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) *------------------------------------------------------------------------- */ 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) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + char * tmp_name = NULL; /* Name buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1376,44 +1344,44 @@ H5D__virtual_build_source_name(char *source_name, HDassert(built_name); /* Check for static name */ - if(nsubs == 0) { - if(parsed_name) + if (nsubs == 0) { + if (parsed_name) *built_name = parsed_name->name_segment; else *built_name = source_name; } /* end if */ else { const H5O_storage_virtual_name_seg_t *name_seg = parsed_name; - char *p; - hsize_t blockno_down = blockno; - size_t blockno_len = 1; - size_t name_len; - size_t name_len_rem; - size_t seg_len; - size_t nsubs_rem = nsubs; + char * p; + hsize_t blockno_down = blockno; + size_t blockno_len = 1; + size_t name_len; + size_t name_len_rem; + size_t seg_len; + size_t nsubs_rem = nsubs; HDassert(parsed_name); /* Calculate length of printed block number */ do { blockno_down /= (hsize_t)10; - if(blockno_down == 0) + if (blockno_down == 0) break; blockno_len++; - } while(1); + } while (1); /* Calculate length of name buffer */ name_len_rem = name_len = static_strlen + (nsubs * blockno_len) + (size_t)1; /* Allocate name buffer */ - if(NULL == (tmp_name = (char *)H5MM_malloc(name_len))) + if (NULL == (tmp_name = (char *)H5MM_malloc(name_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate name buffer") p = tmp_name; /* Build name */ do { /* Add name segment */ - if(name_seg->name_segment) { + if (name_seg->name_segment) { seg_len = HDstrlen(name_seg->name_segment); HDassert(seg_len > 0); HDassert(seg_len < name_len_rem); @@ -1423,9 +1391,9 @@ H5D__virtual_build_source_name(char *source_name, } /* end if */ /* Add block number */ - if(nsubs_rem > 0) { + if (nsubs_rem > 0) { HDassert(blockno_len < name_len_rem); - if(HDsnprintf(p, name_len_rem, "%llu", (long long unsigned)blockno) < 0) + if (HDsnprintf(p, name_len_rem, "%llu", (long long unsigned)blockno) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write block number to string") name_len_rem -= blockno_len; p += blockno_len; @@ -1434,15 +1402,15 @@ H5D__virtual_build_source_name(char *source_name, /* Advance name_seg */ name_seg = name_seg->next; - } while(name_seg); + } while (name_seg); /* Assign built_name */ *built_name = tmp_name; - tmp_name = NULL; + tmp_name = NULL; } /* end else */ done: - if(tmp_name) { + if (tmp_name) { HDassert(ret_value < 0); H5MM_free(tmp_name); } /* end if */ @@ -1450,7 +1418,6 @@ H5D__virtual_build_source_name(char *source_name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_build_source_name() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_set_extent_unlim * @@ -1470,13 +1437,13 @@ herr_t H5D__virtual_set_extent_unlim(const H5D_t *dset) { H5O_storage_virtual_t *storage; - hsize_t new_dims[H5S_MAX_RANK]; - hsize_t curr_dims[H5S_MAX_RANK]; - hsize_t clip_size; - int rank; - hbool_t changed = FALSE; /* Whether the VDS extent changed */ - size_t i, j; - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t new_dims[H5S_MAX_RANK]; + hsize_t curr_dims[H5S_MAX_RANK]; + hsize_t clip_size; + int rank; + hbool_t changed = FALSE; /* Whether the VDS extent changed */ + size_t i, j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1487,48 +1454,52 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); /* Get rank of VDS */ - if((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Initialize new_dims to HSIZE_UNDEF */ - for(i = 0; i < (size_t)rank; i++) + for (i = 0; i < (size_t)rank; i++) new_dims[i] = HSIZE_UNDEF; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for unlimited dimension */ - if(storage->list[i].unlim_dim_virtual >= 0) { + if (storage->list[i].unlim_dim_virtual >= 0) { /* Check for "printf" source dataset resolution */ - if(storage->list[i].unlim_dim_source >= 0 ) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Open source dataset */ - if(!storage->list[i].source_dset.dset) - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (!storage->list[i].source_dset.dset) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* Check if source dataset is open */ - if(storage->list[i].source_dset.dset) { + if (storage->list[i].source_dset.dset) { /* Retrieve current source dataset extent and patch mapping */ - if(H5S_extent_copy(storage->list[i].source_select, storage->list[i].source_dset.dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_select, + 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 */ - if(H5S_get_simple_extent_dims(storage->list[i].source_select, curr_dims, NULL) < 0) + 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") /* Check if the source extent in the unlimited dimension * changed since the last time the VDS extent/mapping * was updated */ - if(curr_dims[storage->list[i].unlim_dim_source] - == storage->list[i].unlim_extent_source) + if (curr_dims[storage->list[i].unlim_dim_source] == storage->list[i].unlim_extent_source) /* Use cached result for clip size */ clip_size = storage->list[i].clip_size_virtual; else { /* Get size that virtual selection would be clipped to * to match size of source selection within source * extent */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_dset.virtual_select, storage->list[i].source_select, curr_dims[storage->list[i].unlim_dim_source], storage->view == H5D_VDS_FIRST_MISSING); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_dset.virtual_select, storage->list[i].source_select, + curr_dims[storage->list[i].unlim_dim_source], + storage->view == H5D_VDS_FIRST_MISSING); /* If we are setting the extent by the last available * data, clip virtual_select and source_select. Note @@ -1537,144 +1508,183 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) * already be clipped to the correct size. Likewise, * if we used the cached clip_size the source selection * will already be correct. */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { - if(clip_size != storage->list[i].clip_size_virtual) { + if (storage->view == H5D_VDS_LAST_AVAILABLE) { + if (clip_size != storage->list[i].clip_size_virtual) { /* Close previous clipped virtual selection, if * any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy( + storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, + "unable to copy virtual selection") /* Clip virtual selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, clip_size)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + clip_size)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "failed to clip unlimited selection") } /* end if */ /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, + "unable to copy source selection") /* Clip source selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, curr_dims[storage->list[i].unlim_dim_source])) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + curr_dims[storage->list[i].unlim_dim_source])) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "failed to clip unlimited selection") } /* end if */ /* Update cached values unlim_extent_source and * clip_size_virtual */ storage->list[i].unlim_extent_source = curr_dims[storage->list[i].unlim_dim_source]; - storage->list[i].clip_size_virtual = clip_size; + storage->list[i].clip_size_virtual = clip_size; } /* end else */ - } /* end if */ + } /* end if */ else clip_size = 0; } /* end if */ else { /* printf mapping */ - hsize_t first_missing = 0; /* First missing dataset in the current block of missing datasets */ + hsize_t first_missing = + 0; /* First missing dataset in the current block of missing datasets */ /* Search for source datasets */ HDassert(storage->printf_gap != HSIZE_UNDEF); - for(j = 0; j <= (storage->printf_gap + first_missing); j++) { + for (j = 0; j <= (storage->printf_gap + first_missing); j++) { /* Check for running out of space in sub_dset array */ - if(j >= (hsize_t)storage->list[i].sub_dset_nalloc) { - if(storage->list[i].sub_dset_nalloc == 0) { + if (j >= (hsize_t)storage->list[i].sub_dset_nalloc) { + if (storage->list[i].sub_dset_nalloc == 0) { /* Allocate sub_dset */ - if(NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc(H5D_VIRTUAL_DEF_SUB_DSET_SIZE * sizeof(H5O_storage_virtual_srcdset_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate sub dataset array") + if (NULL == + (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc( + H5D_VIRTUAL_DEF_SUB_DSET_SIZE * sizeof(H5O_storage_virtual_srcdset_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate sub dataset array") storage->list[i].sub_dset_nalloc = H5D_VIRTUAL_DEF_SUB_DSET_SIZE; } /* end if */ else { H5O_storage_virtual_srcdset_t *tmp_sub_dset; /* Extend sub_dset */ - if(NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc(storage->list[i].sub_dset, 2 * storage->list[i].sub_dset_nalloc * sizeof(H5O_storage_virtual_srcdset_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend sub dataset array") + if (NULL == + (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc( + storage->list[i].sub_dset, 2 * storage->list[i].sub_dset_nalloc * + sizeof(H5O_storage_virtual_srcdset_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to extend sub dataset array") storage->list[i].sub_dset = tmp_sub_dset; /* Clear new space in sub_dset */ - (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, storage->list[i].sub_dset_nalloc * sizeof(H5O_storage_virtual_srcdset_t)); + (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, + storage->list[i].sub_dset_nalloc * + sizeof(H5O_storage_virtual_srcdset_t)); /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc *= 2; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the dataset was already opened */ - if(storage->list[i].sub_dset[j].dset_exists) + if (storage->list[i].sub_dset[j].dset_exists) first_missing = j + 1; else { /* Resolve file name */ - if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") + if (!storage->list[i].sub_dset[j].file_name) + if (H5D__virtual_build_source_name(storage->list[i].source_file_name, + storage->list[i].parsed_source_file_name, + storage->list[i].psfn_static_strlen, + storage->list[i].psfn_nsubs, j, + &storage->list[i].sub_dset[j].file_name) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to build source file name") /* Resolve dset name */ - if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") + if (!storage->list[i].sub_dset[j].dset_name) + if (H5D__virtual_build_source_name(storage->list[i].source_dset_name, + storage->list[i].parsed_source_dset_name, + storage->list[i].psdn_static_strlen, + storage->list[i].psdn_nsubs, j, + &storage->list[i].sub_dset[j].dset_name) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to build source dataset name") /* Resolve virtual selection for block */ - if(!storage->list[i].sub_dset[j].virtual_select) - if(NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block(storage->list[i].source_dset.virtual_select, j))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get block in unlimited selection") + if (!storage->list[i].sub_dset[j].virtual_select) + if (NULL == + (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block( + storage->list[i].source_dset.virtual_select, j))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get block in unlimited selection") /* Initialize clipped selections */ - if(!storage->list[i].sub_dset[j].clipped_source_select) - storage->list[i].sub_dset[j].clipped_source_select = storage->list[i].source_select; - if(!storage->list[i].sub_dset[j].clipped_virtual_select) - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + if (!storage->list[i].sub_dset[j].clipped_source_select) + storage->list[i].sub_dset[j].clipped_source_select = + storage->list[i].source_select; + if (!storage->list[i].sub_dset[j].clipped_virtual_select) + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; /* Open source dataset */ - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") - if(storage->list[i].sub_dset[j].dset) { + if (storage->list[i].sub_dset[j].dset) { /* Update first_missing */ first_missing = j + 1; /* Close source dataset so we don't have huge * numbers of datasets open */ - if(H5D_close(storage->list[i].sub_dset[j].dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + if (H5D_close(storage->list[i].sub_dset[j].dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to close source dataset") storage->list[i].sub_dset[j].dset = NULL; } /* end if */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ /* Check if the size changed */ - if((first_missing == (hsize_t)storage->list[i].sub_dset_nused) - && (storage->list[i].clip_size_virtual != HSIZE_UNDEF)) + if ((first_missing == (hsize_t)storage->list[i].sub_dset_nused) && + (storage->list[i].clip_size_virtual != HSIZE_UNDEF)) /* Use cached clip_size */ clip_size = storage->list[i].clip_size_virtual; else { /* Check for no datasets */ - if(first_missing == 0) + if (first_missing == 0) /* Set clip size to 0 */ clip_size = (hsize_t)0; else { - hsize_t bounds_start[H5S_MAX_RANK]; - hsize_t bounds_end[H5S_MAX_RANK]; + hsize_t bounds_start[H5S_MAX_RANK]; + hsize_t bounds_end[H5S_MAX_RANK]; /* Get clip size from selection */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { + if (storage->view == H5D_VDS_LAST_AVAILABLE) { /* Get bounds from last valid virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing - (hsize_t)1].virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS( + storage->list[i].sub_dset[first_missing - (hsize_t)1].virtual_select, + bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Set clip_size to bounds_end in unlimited @@ -1684,113 +1694,121 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) else { /* Get bounds from first missing virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing].virtual_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(storage->list[i].sub_dset[first_missing].virtual_select, + bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Set clip_size to bounds_start in unlimited * dimension */ clip_size = bounds_start[storage->list[i].unlim_dim_virtual]; } /* end else */ - } /* end else */ + } /* end else */ /* Set sub_dset_nused and clip_size_virtual */ - storage->list[i].sub_dset_nused = (size_t)first_missing; + storage->list[i].sub_dset_nused = (size_t)first_missing; storage->list[i].clip_size_virtual = clip_size; } /* end else */ - } /* end else */ + } /* end else */ /* Update new_dims */ - if((new_dims[storage->list[i].unlim_dim_virtual] == HSIZE_UNDEF) - || (storage->view == H5D_VDS_FIRST_MISSING ? (clip_size < (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]) - : (clip_size > (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]))) + if ((new_dims[storage->list[i].unlim_dim_virtual] == HSIZE_UNDEF) || + (storage->view == H5D_VDS_FIRST_MISSING + ? (clip_size < (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]) + : (clip_size > (hsize_t)new_dims[storage->list[i].unlim_dim_virtual]))) new_dims[storage->list[i].unlim_dim_virtual] = clip_size; } /* end if */ /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Calculate new extent */ - for(i = 0; i < (size_t)rank; i++) { - if(new_dims[i] == HSIZE_UNDEF) + for (i = 0; i < (size_t)rank; i++) { + if (new_dims[i] == HSIZE_UNDEF) new_dims[i] = curr_dims[i]; - else if(new_dims[i] < storage->min_dims[i]) + else if (new_dims[i] < storage->min_dims[i]) new_dims[i] = storage->min_dims[i]; - if(new_dims[i] != curr_dims[i]) + if (new_dims[i] != curr_dims[i]) changed = TRUE; } /* end for */ /* Update extent if it changed */ - if(changed) { + if (changed) { /* Update VDS extent */ - if(H5S_set_extent(dset->shared->space, new_dims) < 0) + if (H5S_set_extent(dset->shared->space, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Mark the space as dirty, for later writing to the file */ - if(H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) - if(H5D__mark(dset, H5D_MARK_SPACE) < 0) + if (H5F_INTENT(dset->oloc.file) & H5F_ACC_RDWR) + if (H5D__mark(dset, H5D_MARK_SPACE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to mark dataspace as dirty") } /* end if */ /* If we did not change the VDS dimensions, there is nothing more to update */ - if(changed || (!storage->init && (storage->view == H5D_VDS_FIRST_MISSING))) { + if (changed || (!storage->init && (storage->view == H5D_VDS_FIRST_MISSING))) { /* Iterate over mappings again to update source selections and virtual * mapping extents */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* If there is an unlimited dimension, we are setting extent by the * minimum of mappings, and the virtual extent in the unlimited * dimension has changed since the last time the VDS extent/mapping * was updated, we must adjust the selections */ - if((storage->list[i].unlim_dim_virtual >= 0) - && (storage->view == H5D_VDS_FIRST_MISSING) - && (new_dims[storage->list[i].unlim_dim_virtual] - != storage->list[i].unlim_extent_virtual)) { + if ((storage->list[i].unlim_dim_virtual >= 0) && (storage->view == H5D_VDS_FIRST_MISSING) && + (new_dims[storage->list[i].unlim_dim_virtual] != storage->list[i].unlim_extent_virtual)) { /* Check for "printf" style mapping */ - if(storage->list[i].unlim_dim_source >= 0) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = + H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Clip space to virtual extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, new_dims[storage->list[i].unlim_dim_source])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + new_dims[storage->list[i].unlim_dim_source])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Get size that source selection will be clipped to to * match size of virtual selection */ - clip_size = H5S_hyper_get_clip_extent(storage->list[i].source_select, storage->list[i].source_dset.clipped_virtual_select, FALSE); + clip_size = + H5S_hyper_get_clip_extent(storage->list[i].source_select, + storage->list[i].source_dset.clipped_virtual_select, FALSE); /* Check if the clip size changed */ - if(clip_size != storage->list[i].clip_size_source) { + if (clip_size != storage->list[i].clip_size_source) { /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Clip source selection */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Update cached value clip_size_source */ storage->list[i].clip_size_source = clip_size; } /* end if */ - } /* end if */ + } /* end if */ else { /* printf mapping */ hsize_t first_inc_block; @@ -1798,32 +1816,38 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) /* Get index of first incomplete block in virtual * selection */ - first_inc_block = H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, new_dims[storage->list[i].unlim_dim_virtual], &partial_block); + first_inc_block = H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, + new_dims[storage->list[i].unlim_dim_virtual], &partial_block); /* Iterate over sub datasets */ - for(j = 0; j < storage->list[i].sub_dset_nalloc; j++) { + for (j = 0; j < storage->list[i].sub_dset_nalloc; j++) { /* Close previous clipped source selection, if any */ - if(storage->list[i].sub_dset[j].clipped_source_select - != storage->list[i].source_select) { - if(storage->list[i].sub_dset[j].clipped_source_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].sub_dset[j].clipped_source_select != + storage->list[i].source_select) { + if (storage->list[i].sub_dset[j].clipped_source_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") /* Initialize clipped source selection to point to * base source selection */ - storage->list[i].sub_dset[j].clipped_source_select = storage->list[i].source_select; + storage->list[i].sub_dset[j].clipped_source_select = + storage->list[i].source_select; } /* end if */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].sub_dset[j].clipped_virtual_select - != storage->list[i].sub_dset[j].virtual_select) { - if(storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") /* Initialize clipped virtual selection to point to * unclipped virtual selection */ - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; } /* end if */ /* Only initialize clipped selections if it is a @@ -1832,13 +1856,13 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) * source extent here. For unused blocks we will never * need clipped selections (until the extent is * recalculated in this function). */ - if(j >= (size_t)first_inc_block) { + if (j >= (size_t)first_inc_block) { /* Clear clipped source and virtual selections */ - storage->list[i].sub_dset[j].clipped_source_select = NULL; + storage->list[i].sub_dset[j].clipped_source_select = NULL; storage->list[i].sub_dset[j].clipped_virtual_select = NULL; } /* end if */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ /* Update cached value unlim_extent_virtual */ storage->list[i].unlim_extent_virtual = new_dims[storage->list[i].unlim_dim_virtual]; @@ -1846,30 +1870,30 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) /* Update top level virtual_select and clipped_virtual_select * extents */ - if(H5S_set_extent(storage->list[i].source_dset.virtual_select, new_dims) < 0) + if (H5S_set_extent(storage->list[i].source_dset.virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if((storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select) - && storage->list[i].source_dset.clipped_virtual_select) - if(H5S_set_extent(storage->list[i].source_dset.clipped_virtual_select, new_dims) < 0) + if ((storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select) && + storage->list[i].source_dset.clipped_virtual_select) + if (H5S_set_extent(storage->list[i].source_dset.clipped_virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Update sub dataset virtual_select and clipped_virtual_select * extents */ - for(j = 0; j < storage->list[i].sub_dset_nalloc; j++) - if(storage->list[i].sub_dset[j].virtual_select) { - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, new_dims) < 0) + for (j = 0; j < storage->list[i].sub_dset_nalloc; j++) + if (storage->list[i].sub_dset[j].virtual_select) { + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if((storage->list[i].sub_dset[j].clipped_virtual_select - != storage->list[i].sub_dset[j].virtual_select) - && storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, new_dims) < 0) + if ((storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) && + storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, new_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end if */ else HDassert(!storage->list[i].sub_dset[j].clipped_virtual_select); } /* end for */ - } /* end if */ + } /* end if */ /* Mark layout as fully initialized */ storage->init = TRUE; @@ -1878,7 +1902,6 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_set_extent_unlim() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_init_all * @@ -1898,11 +1921,11 @@ static herr_t H5D__virtual_init_all(const H5D_t *dset) { H5O_storage_virtual_t *storage; - hsize_t virtual_dims[H5S_MAX_RANK]; - hsize_t source_dims[H5S_MAX_RANK]; - hsize_t clip_size; - size_t i, j; - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t virtual_dims[H5S_MAX_RANK]; + hsize_t source_dims[H5S_MAX_RANK]; + hsize_t clip_size; + size_t i, j; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1913,147 +1936,178 @@ H5D__virtual_init_all(const H5D_t *dset) HDassert((storage->view == H5D_VDS_FIRST_MISSING) || (storage->view == H5D_VDS_LAST_AVAILABLE)); /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(dset->shared->space, virtual_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(dset->shared->space, virtual_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for unlimited dimension */ - if(storage->list[i].unlim_dim_virtual >= 0) { + if (storage->list[i].unlim_dim_virtual >= 0) { /* Check for "printf" source dataset resolution */ - if(storage->list[i].unlim_dim_source >= 0 ) { + if (storage->list[i].unlim_dim_source >= 0) { /* Non-printf mapping */ /* Open source dataset */ - if(!storage->list[i].source_dset.dset) - if(H5D__virtual_open_source_dset(dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (!storage->list[i].source_dset.dset) + if (H5D__virtual_open_source_dset(dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* Check if source dataset is open */ - if(storage->list[i].source_dset.dset) { + if (storage->list[i].source_dset.dset) { /* Retrieve current source dataset extent and patch mapping */ - if(H5S_extent_copy(storage->list[i].source_select, storage->list[i].source_dset.dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_select, + 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 */ - if(H5S_get_simple_extent_dims(storage->list[i].source_select, source_dims, NULL) < 0) + 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") /* Get size that source selection would be clipped to to * match size of virtual selection */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_select, storage->list[i].source_dset.virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual], FALSE); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_select, storage->list[i].source_dset.virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual], FALSE); /* Close previous clipped virtual selection, if any */ - if(storage->list[i].source_dset.clipped_virtual_select) { - HDassert(storage->list[i].source_dset.clipped_virtual_select - != storage->list[i].source_dset.virtual_select); - if(H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].source_dset.clipped_virtual_select) { + HDassert(storage->list[i].source_dset.clipped_virtual_select != + storage->list[i].source_dset.virtual_select); + if (H5S_close(storage->list[i].source_dset.clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") } /* end if */ /* Copy virtual selection */ - if(NULL == (storage->list[i].source_dset.clipped_virtual_select = H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_virtual_select = + H5S_copy(storage->list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Close previous clipped source selection, if any */ - if(storage->list[i].source_dset.clipped_source_select) { - HDassert(storage->list[i].source_dset.clipped_source_select - != storage->list[i].source_select); - if(H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].source_dset.clipped_source_select) { + HDassert(storage->list[i].source_dset.clipped_source_select != + storage->list[i].source_select); + if (H5S_close(storage->list[i].source_dset.clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") } /* end if */ /* Copy source selection */ - if(NULL == (storage->list[i].source_dset.clipped_source_select = H5S_copy(storage->list[i].source_select, FALSE, TRUE))) + if (NULL == (storage->list[i].source_dset.clipped_source_select = + H5S_copy(storage->list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Check if the clip size is within the current extent of * the source dataset */ - if(clip_size <= source_dims[storage->list[i].unlim_dim_source]) { + if (clip_size <= source_dims[storage->list[i].unlim_dim_source]) { /* Clip virtual selection to extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Clip source selection to clip_size */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") } /* end if */ else { /* Get size that virtual selection will be clipped to to * match size of source selection within source extent */ - clip_size = H5S_hyper_get_clip_extent_match(storage->list[i].source_dset.virtual_select, storage->list[i].source_select, source_dims[storage->list[i].unlim_dim_source], FALSE); + clip_size = H5S_hyper_get_clip_extent_match( + storage->list[i].source_dset.virtual_select, storage->list[i].source_select, + source_dims[storage->list[i].unlim_dim_source], FALSE); /* Clip virtual selection to clip_size */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, clip_size)) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_virtual_select, + clip_size)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* Clip source selection to extent */ - if(H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, source_dims[storage->list[i].unlim_dim_source])) + if (H5S_hyper_clip_unlim(storage->list[i].source_dset.clipped_source_select, + source_dims[storage->list[i].unlim_dim_source])) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") } /* end else */ - } /* end if */ + } /* end if */ else { HDassert(!storage->list[i].source_dset.clipped_virtual_select); HDassert(!storage->list[i].source_dset.clipped_source_select); } /* end else */ - } /* end if */ + } /* end if */ else { /* printf mapping */ - size_t sub_dset_max; + size_t sub_dset_max; hbool_t partial_block; /* Get number of sub-source datasets in current extent */ - sub_dset_max = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, virtual_dims[storage->list[i].unlim_dim_virtual], &partial_block); - if(partial_block) + sub_dset_max = (size_t)H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, + virtual_dims[storage->list[i].unlim_dim_virtual], &partial_block); + if (partial_block) sub_dset_max++; /* Allocate or grow the sub_dset array if necessary */ - if(!storage->list[i].sub_dset) { + if (!storage->list[i].sub_dset) { /* Allocate sub_dset array */ - if(NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc(sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) + if (NULL == (storage->list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_calloc( + sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate sub dataset array") /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc = sub_dset_max; } /* end if */ - else if(sub_dset_max > storage->list[i].sub_dset_nalloc) { + else if (sub_dset_max > storage->list[i].sub_dset_nalloc) { H5O_storage_virtual_srcdset_t *tmp_sub_dset; /* Extend sub_dset array */ - if(NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc(storage->list[i].sub_dset, sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) + if (NULL == (tmp_sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_realloc( + storage->list[i].sub_dset, + sub_dset_max * sizeof(H5O_storage_virtual_srcdset_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend sub dataset array") storage->list[i].sub_dset = tmp_sub_dset; /* Clear new space in sub_dset */ - (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, (sub_dset_max - storage->list[i].sub_dset_nalloc) * sizeof(H5O_storage_virtual_srcdset_t)); + (void)HDmemset(&storage->list[i].sub_dset[storage->list[i].sub_dset_nalloc], 0, + (sub_dset_max - storage->list[i].sub_dset_nalloc) * + sizeof(H5O_storage_virtual_srcdset_t)); /* Update sub_dset_nalloc */ storage->list[i].sub_dset_nalloc = sub_dset_max; } /* end if */ /* Iterate over sub dsets */ - for(j = 0; j < sub_dset_max; j++) { + for (j = 0; j < sub_dset_max; j++) { /* Resolve file name */ - if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) + if (!storage->list[i].sub_dset[j].file_name) + if (H5D__virtual_build_source_name( + storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, + storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, + &storage->list[i].sub_dset[j].file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") /* Resolve dset name */ - if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) + if (!storage->list[i].sub_dset[j].dset_name) + if (H5D__virtual_build_source_name( + storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, + storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, + &storage->list[i].sub_dset[j].dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") /* Resolve virtual selection for block */ - if(!storage->list[i].sub_dset[j].virtual_select) - if(NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block(storage->list[i].source_dset.virtual_select, j))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get block in unlimited selection") + if (!storage->list[i].sub_dset[j].virtual_select) + if (NULL == (storage->list[i].sub_dset[j].virtual_select = H5S_hyper_get_unlim_block( + storage->list[i].source_dset.virtual_select, j))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get block in unlimited selection") /* Close previous clipped source selection, if any */ - if(storage->list[i].sub_dset[j].clipped_source_select != storage->list[i].source_select) { - if(storage->list[i].sub_dset[j].clipped_source_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source dataspace") + if (storage->list[i].sub_dset[j].clipped_source_select != + storage->list[i].source_select) { + if (storage->list[i].sub_dset[j].clipped_source_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_source_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped source dataspace") /* Initialize clipped source selection to point to base * source selection */ @@ -2061,23 +2115,26 @@ H5D__virtual_init_all(const H5D_t *dset) } /* end if */ /* Close previous clipped virtual selection, if any */ - if(storage->list[i].sub_dset[j].clipped_virtual_select != storage->list[i].sub_dset[j].virtual_select) { - if(storage->list[i].sub_dset[j].clipped_virtual_select) - if(H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual dataspace") + if (storage->list[i].sub_dset[j].clipped_virtual_select != + storage->list[i].sub_dset[j].virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) + if (H5S_close(storage->list[i].sub_dset[j].clipped_virtual_select) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "unable to release clipped virtual dataspace") /* Initialize clipped virtual selection to point to * unclipped virtual selection */ - storage->list[i].sub_dset[j].clipped_virtual_select = storage->list[i].sub_dset[j].virtual_select; + storage->list[i].sub_dset[j].clipped_virtual_select = + storage->list[i].sub_dset[j].virtual_select; } /* end if */ /* Clear clipped selections if this is a partial block, * defer calculation of real clipped selections to * H5D__virtual_pre_io() as we may not have a valid source * extent here */ - if((j == (sub_dset_max - 1)) && partial_block) { + if ((j == (sub_dset_max - 1)) && partial_block) { /* Clear clipped source and virtual selections */ - storage->list[i].sub_dset[j].clipped_source_select = NULL; + storage->list[i].sub_dset[j].clipped_source_select = NULL; storage->list[i].sub_dset[j].clipped_virtual_select = NULL; } /* end else */ /* Note we do not need to open the source file, this will @@ -2087,7 +2144,7 @@ H5D__virtual_init_all(const H5D_t *dset) /* Update sub_dset_nused */ storage->list[i].sub_dset_nused = sub_dset_max; } /* end else */ - } /* end if */ + } /* end if */ else { /* Limited mapping, just make sure the clipped selections were * already set. Again, no need to open the source file. */ @@ -2102,7 +2159,6 @@ H5D__virtual_init_all(const H5D_t *dset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_init_all() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_init * @@ -2119,11 +2175,11 @@ H5D__virtual_init_all(const H5D_t *dset) 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 */ - hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset (unused) */ - size_t i; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenience 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 */ FUNC_ENTER_PACKAGE @@ -2133,8 +2189,10 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) HDassert(storage->list || (storage->list_nused == 0)); /* Check that the dimensions of the VDS are large enough */ - if(H5D_virtual_check_min_dims(dset) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") + if (H5D_virtual_check_min_dims(dset) < 0) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "virtual dataset dimensions not large enough to contain all limited dimensions in all selections") /* Patch the virtual selection dataspaces. Note we always patch the space * status because this layout could be from an old version held in the @@ -2144,11 +2202,11 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) * remove offset from selections. We only have to update * source_space_status and virtual_space_status because others will be based * on these and should therefore already have been normalized. */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { HDassert(storage->list[i].sub_dset_nalloc == 0); /* Patch extent */ - if(H5S_extent_copy(storage->list[i].source_dset.virtual_select, dset->shared->space) < 0) + if (H5S_extent_copy(storage->list[i].source_dset.virtual_select, dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent") storage->list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; @@ -2156,36 +2214,64 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) storage->list[i].source_space_status = H5O_VIRTUAL_STATUS_INVALID; /* Normalize offsets, toss out old offset values */ - if(H5S_hyper_normalize_offset(storage->list[i].source_dset.virtual_select, old_offset) < 0) + if (H5S_hyper_normalize_offset(storage->list[i].source_dset.virtual_select, old_offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") - if(H5S_hyper_normalize_offset(storage->list[i].source_select, old_offset) < 0) + if (H5S_hyper_normalize_offset(storage->list[i].source_select, old_offset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") } /* end for */ /* Get dataset access property list */ - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + if (NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID") /* Get view option */ - if(H5P_get(dapl, H5D_ACS_VDS_VIEW_NAME, &storage->view) < 0) + if (H5P_get(dapl, H5D_ACS_VDS_VIEW_NAME, &storage->view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get virtual view option") /* Get printf gap if view is H5D_VDS_LAST_AVAILABLE, otherwise set to 0 */ - if(storage->view == H5D_VDS_LAST_AVAILABLE) { - if(H5P_get(dapl, H5D_ACS_VDS_PRINTF_GAP_NAME, &storage->printf_gap) < 0) + if (storage->view == H5D_VDS_LAST_AVAILABLE) { + if (H5P_get(dapl, H5D_ACS_VDS_PRINTF_GAP_NAME, &storage->printf_gap) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get virtual printf gap") } /* end if */ else storage->printf_gap = (hsize_t)0; /* Retrieve VDS file FAPL to layout */ - if(storage->source_fapl <= 0) - if((storage->source_fapl = H5F_get_access_plist(f, FALSE)) < 0) + if (storage->source_fapl <= 0) { + 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) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fapl") + /* Get property list pointer */ + if (NULL == (source_fapl = (H5P_genplist_t *)H5I_object(storage->source_fapl))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + + /* Source files must always be opened with H5F_CLOSE_WEAK close degree */ + if (H5P_set(source_fapl, H5F_ACS_CLOSE_DEGREE_NAME, &close_degree) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") + } /* end if */ +#ifndef NDEBUG + else { + H5P_genplist_t * source_fapl = NULL; /* Source file FAPL */ + H5F_close_degree_t close_degree; /* Close degree for source files */ + + /* Get property list pointer */ + if (NULL == (source_fapl = (H5P_genplist_t *)H5I_object(storage->source_fapl))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + + /* Verify H5F_CLOSE_WEAK close degree is set */ + if (H5P_get(source_fapl, H5F_ACS_CLOSE_DEGREE_NAME, &close_degree) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree") + + HDassert(close_degree == H5F_CLOSE_WEAK); + } /* end else */ +#endif /* NDEBUG */ + /* Copy DAPL to layout */ - if(storage->source_dapl <= 0) - if((storage->source_dapl = H5P_copy_plist(dapl, FALSE)) < 0) + if (storage->source_dapl <= 0) + if ((storage->source_dapl = H5P_copy_plist(dapl, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dapl") /* Mark layout as not fully initialized (must be done prior to I/O for @@ -2196,7 +2282,6 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_init() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_is_space_alloc * @@ -2214,7 +2299,7 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) hbool_t H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2228,7 +2313,6 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_is_space_alloc() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_is_data_cached * @@ -2244,39 +2328,39 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) static hbool_t H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset) { - const H5O_storage_virtual_t *storage; /* Convenience pointer */ - size_t i, j; /* Local index variables */ - hbool_t ret_value = FALSE; /* Return value */ + const H5O_storage_virtual_t *storage; /* Convenience pointer */ + size_t i, j; /* Local index variables */ + hbool_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(shared_dset); storage = &shared_dset->layout.storage.u.virt; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + 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++) + 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 */ - 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(storage->list[i].sub_dset[j].dset->shared)) + 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( + storage->list[i].sub_dset[j].dset->shared)) HGOTO_DONE(TRUE); } /* end if */ - else - if(storage->list[i].source_dset.dset - && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached - && storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached(storage->list[i].source_dset.dset->shared)) - HGOTO_DONE(TRUE); + else if (storage->list[i].source_dset.dset && + storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached && + storage->list[i].source_dset.dset->shared->layout.ops->is_data_cached( + storage->list[i].source_dset.dset->shared)) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_is_data_cached() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_pre_io * @@ -2293,17 +2377,16 @@ 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, const H5S_t *file_space, + const 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 */ - hsize_t bounds_end[H5S_MAX_RANK]; /* Selection bounds end */ - int rank; - hbool_t bounds_init = FALSE; /* Whether bounds_start, bounds_end, and rank are valid */ - size_t i, j, k; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + hssize_t select_nelmts; /* Number of elements in selection */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Selection bounds start */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Selection bounds end */ + int rank = 0; + hbool_t bounds_init = FALSE; /* Whether bounds_start, bounds_end, and rank are valid */ + size_t i, j, k; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2314,37 +2397,37 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(tot_nelmts); /* Initialize layout if necessary */ - if(!storage->init) - if(H5D__virtual_init_all(io_info->dset) < 0) + if (!storage->init) + if (H5D__virtual_init_all(io_info->dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize virtual layout") /* Initialize tot_nelmts */ *tot_nelmts = 0; /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that the virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { hbool_t partial_block; HDassert(storage->list[i].unlim_dim_virtual >= 0); /* Get selection bounds if necessary */ - if(!bounds_init) { + if (!bounds_init) { /* Get rank of VDS */ - if((rank = H5S_GET_EXTENT_NDIMS(io_info->dset->shared->space)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(io_info->dset->shared->space)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get selection bounds */ - if(H5S_SELECT_BOUNDS(file_space, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(file_space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Adjust bounds_end to represent the extent just enclosing them * (add 1) */ - for(j = 0; j < (size_t)rank; j++) + for (j = 0; j < (size_t)rank; j++) bounds_end[j]++; /* Bounds are now initialized */ @@ -2352,28 +2435,33 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, } /* end if */ /* Get index of first block in virtual selection */ - storage->list[i].sub_dset_io_start = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, bounds_start[storage->list[i].unlim_dim_virtual], NULL); + storage->list[i].sub_dset_io_start = + (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, + bounds_start[storage->list[i].unlim_dim_virtual], NULL); /* Get index of first block outside of virtual selection */ - storage->list[i].sub_dset_io_end = (size_t)H5S_hyper_get_first_inc_block(storage->list[i].source_dset.virtual_select, bounds_end[storage->list[i].unlim_dim_virtual], &partial_block); - if(partial_block) + storage->list[i].sub_dset_io_end = (size_t)H5S_hyper_get_first_inc_block( + storage->list[i].source_dset.virtual_select, bounds_end[storage->list[i].unlim_dim_virtual], + &partial_block); + if (partial_block) storage->list[i].sub_dset_io_end++; - if(storage->list[i].sub_dset_io_end > storage->list[i].sub_dset_nused) + if (storage->list[i].sub_dset_io_end > storage->list[i].sub_dset_nused) storage->list[i].sub_dset_io_end = storage->list[i].sub_dset_nused; /* Iterate over sub-source dsets */ - for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { /* Check for clipped virtual selection */ - if(!storage->list[i].sub_dset[j].clipped_virtual_select) { + if (!storage->list[i].sub_dset[j].clipped_virtual_select) { hsize_t start[H5S_MAX_RANK]; /* This should only be NULL if this is a partial block */ HDassert((j == (storage->list[i].sub_dset_io_end - 1)) && partial_block); /* If the source space status is not correct, we must try to * open the source dataset to patch it */ - if(storage->list[i].source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { + if (storage->list[i].source_space_status != H5O_VIRTUAL_STATUS_CORRECT) { HDassert(!storage->list[i].sub_dset[j].dset); - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") } /* end if */ @@ -2382,119 +2470,140 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, * cannot do this and we will leave them NULL. This doesn't * hurt anything because we can't do I/O because the dataset * must not have been found. */ - if(storage->list[i].source_space_status == H5O_VIRTUAL_STATUS_CORRECT) { + if (storage->list[i].source_space_status == H5O_VIRTUAL_STATUS_CORRECT) { hsize_t tmp_dims[H5S_MAX_RANK]; hsize_t vbounds_end[H5S_MAX_RANK]; /* Get bounds of virtual selection */ - if(H5S_SELECT_BOUNDS(storage->list[i].sub_dset[j].virtual_select, tmp_dims, vbounds_end) < 0) + if (H5S_SELECT_BOUNDS(storage->list[i].sub_dset[j].virtual_select, tmp_dims, + vbounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") HDassert(bounds_init); /* Convert bounds to extent (add 1) */ - for(k = 0; k < (size_t)rank; k++) + for (k = 0; k < (size_t)rank; k++) vbounds_end[k]++; /* Temporarily set extent of virtual selection to bounds */ - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, vbounds_end) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, vbounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") /* Get current VDS dimensions */ - if(H5S_get_simple_extent_dims(io_info->dset->shared->space, tmp_dims, NULL) < 0) + if (H5S_get_simple_extent_dims(io_info->dset->shared->space, tmp_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS dimensions") /* Copy virtual selection */ - if(NULL == (storage->list[i].sub_dset[j].clipped_virtual_select = H5S_copy(storage->list[i].sub_dset[j].virtual_select, FALSE, TRUE))) + if (NULL == (storage->list[i].sub_dset[j].clipped_virtual_select = + H5S_copy(storage->list[i].sub_dset[j].virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Clip virtual selection to real virtual extent */ (void)HDmemset(start, 0, sizeof(start)); - if(H5S_select_hyperslab(storage->list[i].sub_dset[j].clipped_virtual_select, H5S_SELECT_AND, start, NULL, tmp_dims, NULL) < 0) + if (H5S_select_hyperslab(storage->list[i].sub_dset[j].clipped_virtual_select, + H5S_SELECT_AND, start, NULL, tmp_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "unable to clip hyperslab") /* Project intersection of virtual space and clipped * virtual space onto source space (create * clipped_source_select) */ - if(H5S_select_project_intersection(storage->list[i].sub_dset[j].virtual_select, storage->list[i].source_select, storage->list[i].sub_dset[j].clipped_virtual_select, &storage->list[i].sub_dset[j].clipped_source_select, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + storage->list[i].sub_dset[j].virtual_select, storage->list[i].source_select, + storage->list[i].sub_dset[j].clipped_virtual_select, + &storage->list[i].sub_dset[j].clipped_source_select, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Set extents of virtual_select and * clipped_virtual_select to virtual extent */ - if(H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, tmp_dims) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].virtual_select, tmp_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") - if(H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, tmp_dims) < 0) + if (H5S_set_extent(storage->list[i].sub_dset[j].clipped_virtual_select, tmp_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of dataspace") } /* end if */ - } /* end if */ + } /* end if */ /* Only continue if we managed to obtain a * clipped_virtual_select */ - if(storage->list[i].sub_dset[j].clipped_virtual_select) { + if (storage->list[i].sub_dset[j].clipped_virtual_select) { /* Project intersection of file space and mapping virtual space * onto memory space */ - if(H5S_select_project_intersection(file_space, mem_space, storage->list[i].sub_dset[j].clipped_virtual_select, &storage->list[i].sub_dset[j].projected_mem_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + file_space, mem_space, storage->list[i].sub_dset[j].clipped_virtual_select, + &storage->list[i].sub_dset[j].projected_mem_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Check number of elements selected */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].sub_dset[j].projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS( + storage->list[i].sub_dset[j].projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Check if anything is selected */ - if(select_nelmts > (hssize_t)0) { + if (select_nelmts > (hssize_t)0) { /* Open source dataset */ - if(!storage->list[i].sub_dset[j].dset) + if (!storage->list[i].sub_dset[j].dset) /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].sub_dset[j]) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].sub_dset[j]) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, + "unable to open source dataset") /* If the source dataset is not open, mark the selected * elements as zero so projected_mem_space is freed */ - if(!storage->list[i].sub_dset[j].dset) + if (!storage->list[i].sub_dset[j].dset) select_nelmts = (hssize_t)0; } /* end if */ /* If there are not elements selected in this mapping, free * projected_mem_space, otherwise update tot_nelmts */ - if(select_nelmts == (hssize_t)0) { - if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") + if (select_nelmts == (hssize_t)0) { + if (H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, + "can't close projected memory space") storage->list[i].sub_dset[j].projected_mem_space = NULL; } /* end if */ else *tot_nelmts += (hsize_t)select_nelmts; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { - if(storage->list[i].source_dset.clipped_virtual_select) { + if (storage->list[i].source_dset.clipped_virtual_select) { /* Project intersection of file space and mapping virtual space onto * memory space */ - if(H5S_select_project_intersection(file_space, mem_space, storage->list[i].source_dset.clipped_virtual_select, &storage->list[i].source_dset.projected_mem_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto memory space") + if (H5S_select_project_intersection( + file_space, mem_space, storage->list[i].source_dset.clipped_virtual_select, + &storage->list[i].source_dset.projected_mem_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto memory space") /* Check number of elements selected, add to tot_nelmts */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(storage->list[i].source_dset.projected_mem_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS( + storage->list[i].source_dset.projected_mem_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Check if anything is selected */ - if(select_nelmts > (hssize_t)0) { + if (select_nelmts > (hssize_t)0) { /* Open source dataset */ - if(!storage->list[i].source_dset.dset) + if (!storage->list[i].source_dset.dset) /* Try to open dataset */ - if(H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], &storage->list[i].source_dset) < 0) + if (H5D__virtual_open_source_dset(io_info->dset, &storage->list[i], + &storage->list[i].source_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset") /* If the source dataset is not open, mark the selected elements * as zero so projected_mem_space is freed */ - if(!storage->list[i].source_dset.dset) + if (!storage->list[i].source_dset.dset) select_nelmts = (hssize_t)0; } /* end if */ /* If there are not elements selected in this mapping, free * projected_mem_space, otherwise update tot_nelmts */ - if(select_nelmts == (hssize_t)0) { - if(H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + if (select_nelmts == (hssize_t)0) { + if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected memory space") storage->list[i].source_dset.projected_mem_space = NULL; } /* end if */ @@ -2510,14 +2619,13 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(storage->list[i].unlim_dim_virtual >= 0); HDassert(!storage->list[i].source_dset.dset); } /* end else */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_pre_io() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_post_io * @@ -2533,8 +2641,8 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, static herr_t H5D__virtual_post_io(H5O_storage_virtual_t *storage) { - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2542,32 +2650,31 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) HDassert(storage); /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + 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++) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) /* Close projected memory space */ - if(storage->list[i].sub_dset[j].projected_mem_space) { - if(H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) + if (storage->list[i].sub_dset[j].projected_mem_space) { + if (H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") storage->list[i].sub_dset[j].projected_mem_space = NULL; } /* end if */ - } /* end if */ + } /* end if */ 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 (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 */ /* 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_post_io() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_read_one * @@ -2581,11 +2688,11 @@ 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) +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 *projected_src_space = NULL; /* File space for selection in a single source dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2594,37 +2701,40 @@ H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Only perform I/O if there is a projected memory space, otherwise there * were no elements in the projection or the source dataset could not be * opened */ - if(source_dset->projected_mem_space) { + if (source_dset->projected_mem_space) { HDassert(source_dset->dset); HDassert(source_dset->clipped_source_select); /* Project intersection of file space and mapping virtual space onto * mapping source space */ - if(H5S_select_project_intersection(source_dset->clipped_virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") + if (H5S_select_project_intersection(source_dset->clipped_virtual_select, + source_dset->clipped_source_select, file_space, + &projected_src_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto source space") /* Perform read on source dataset */ - if(H5D__read(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->u.rbuf) < 0) + if (H5D__read(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, + projected_src_space, io_info->u.rbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read source dataset") /* Close projected_src_space */ - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") projected_src_space = NULL; } /* end if */ done: /* Release allocated resources on failure */ - if(projected_src_space) { + if (projected_src_space) { HDassert(ret_value < 0); - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read_one() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_read * @@ -2638,15 +2748,14 @@ 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, + const H5S_t *file_space, const 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 */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2662,101 +2771,100 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, #ifdef H5_HAVE_PARALLEL /* Parallel reads are not supported (yet) */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "parallel reads not supported on virtual datasets") #endif /* H5_HAVE_PARALLEL */ /* Prepare for I/O operation */ - if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + if (H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that the virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + 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++) - if(H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end if */ 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") + 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") } /* end for */ /* Fill unmapped part of buffer with fill value */ - if(tot_nelmts < nelmts) { - H5D_fill_value_t fill_status; /* Fill value status */ + if (tot_nelmts < nelmts) { + H5D_fill_value_t fill_status; /* Fill value status */ /* Check the fill value status */ - if(H5P_is_fill_value_defined(&io_info->dset->shared->dcpl_cache.fill, &fill_status) < 0) + if (H5P_is_fill_value_defined(&io_info->dset->shared->dcpl_cache.fill, &fill_status) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Always write fill value to memory buffer unless it is undefined */ - if(fill_status != H5D_FILL_VALUE_UNDEFINED) { + if (fill_status != H5D_FILL_VALUE_UNDEFINED) { /* Start with fill space equal to memory space */ - if(NULL == (fill_space = H5S_copy(mem_space, FALSE, TRUE))) + if (NULL == (fill_space = H5S_copy(mem_space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy memory selection") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + 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++) - if(storage->list[i].sub_dset[j].projected_mem_space) - if(H5S_select_subtract(fill_space, storage->list[i].sub_dset[j].projected_mem_space) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (storage->list[i].sub_dset[j].projected_mem_space) + if (H5S_select_subtract(fill_space, + storage->list[i].sub_dset[j].projected_mem_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") } /* end if */ - else - if(storage->list[i].source_dset.projected_mem_space) - /* Subtract projected memory space from fill space */ - if(H5S_select_subtract(fill_space, storage->list[i].source_dset.projected_mem_space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") + else if (storage->list[i].source_dset.projected_mem_space) + /* Subtract projected memory space from fill space */ + if (H5S_select_subtract(fill_space, storage->list[i].source_dset.projected_mem_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to clip fill selection") /* Write fill values to memory buffer */ - if(H5D__fill(io_info->dset->shared->dcpl_cache.fill.buf, io_info->dset->shared->type, io_info->u.rbuf, type_info->mem_type, fill_space) < 0) + if (H5D__fill(io_info->dset->shared->dcpl_cache.fill.buf, io_info->dset->shared->type, + io_info->u.rbuf, type_info->mem_type, fill_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "filling buf failed") #ifndef NDEBUG /* Make sure the total number of elements written (including fill * values) >= nelmts */ { - hssize_t select_nelmts; /* Number of elements in selection */ + hssize_t select_nelmts; /* Number of elements in selection */ /* Get number of elements in fill dataspace */ - if((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(fill_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + if ((select_nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(fill_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, + "unable to get number of elements in selection") /* Verify number of elements is correct. Note that since we * don't check for overlap we can't assert that these are equal */ HDassert((tot_nelmts + (hsize_t)select_nelmts) >= nelmts); } /* end block */ -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ +#endif /* NDEBUG */ + } /* end if */ + } /* end if */ done: /* Cleanup I/O operation */ - if(H5D__virtual_post_io(storage) < 0) + if (H5D__virtual_post_io(storage) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") /* Close fill space */ - if(fill_space) - if(H5S_close(fill_space) < 0) + if (fill_space) + if (H5S_close(fill_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_write_one * @@ -2770,11 +2878,11 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ 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) +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 *projected_src_space = NULL; /* File space for selection in a single source dataset */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2782,7 +2890,7 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Only perform I/O if there is a projected memory space, otherwise there * were no elements in the projection */ - if(source_dset->projected_mem_space) { + if (source_dset->projected_mem_space) { HDassert(source_dset->dset); HDassert(source_dset->clipped_source_select); @@ -2791,31 +2899,34 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, * extent in the unlimited dimension. -NAF */ /* Project intersection of file space and mapping virtual space onto * mapping source space */ - if(H5S_select_project_intersection(source_dset->clipped_virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") + if (H5S_select_project_intersection(source_dset->clipped_virtual_select, + source_dset->clipped_source_select, file_space, + &projected_src_space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, + "can't project virtual intersection onto source space") /* Perform write on source dataset */ - if(H5D__write(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, projected_src_space, io_info->u.wbuf) < 0) + if (H5D__write(source_dset->dset, type_info->dst_type_id, source_dset->projected_mem_space, + projected_src_space, io_info->u.wbuf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write to source dataset") /* Close projected_src_space */ - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") projected_src_space = NULL; } /* end if */ done: /* Release allocated resources on failure */ - if(projected_src_space) { + if (projected_src_space) { HDassert(ret_value < 0); - if(H5S_close(projected_src_space) < 0) + if (H5S_close(projected_src_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write_one() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_write * @@ -2829,14 +2940,13 @@ 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) +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) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2852,47 +2962,46 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, #ifdef H5_HAVE_PARALLEL /* Parallel writes are not supported (yet) */ - if(H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(io_info->dset->oloc.file, H5FD_FEAT_HAS_MPI)) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "parallel writes not supported on virtual datasets") #endif /* H5_HAVE_PARALLEL */ /* Prepare for I/O operation */ - if(H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) + if (H5D__virtual_pre_io(io_info, storage, file_space, mem_space, &tot_nelmts) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "unable to prepare for I/O operation") /* Fail if there are unmapped parts of the selection as they would not be * written */ - if(tot_nelmts != nelmts) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "write requested to unmapped portion of virtual dataset") + if (tot_nelmts != nelmts) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "write requested to unmapped portion of virtual dataset") /* Iterate over mappings */ - for(i = 0; i < storage->list_nused; i++) { + for (i = 0; i < storage->list_nused; i++) { /* Sanity check that virtual space has been patched by now */ HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + 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++) - if(H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) + for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) + if (H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].sub_dset[j]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") } /* end if */ 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") + 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") } /* end for */ done: /* Cleanup I/O operation */ - if(H5D__virtual_post_io(storage) < 0) + if (H5D__virtual_post_io(storage) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_flush * @@ -2908,9 +3017,9 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, static herr_t H5D__virtual_flush(H5D_t *dset) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - size_t i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + size_t i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2920,27 +3029,25 @@ H5D__virtual_flush(H5D_t *dset) storage = &dset->shared->layout.storage.u.virt; /* Flush only open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) - if(storage->list[i].sub_dset[j].dset) + for (j = 0; j < storage->list[i].sub_dset_nused; j++) + if (storage->list[i].sub_dset[j].dset) /* Flush source dataset */ - if(H5D__flush_real(storage->list[i].sub_dset[j].dset) < 0) + if (H5D__flush_real(storage->list[i].sub_dset[j].dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush source dataset") } /* end if */ - else - if(storage->list[i].source_dset.dset) - /* Flush source dataset */ - if(H5D__flush_real(storage->list[i].source_dset.dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to flush source dataset") + else if (storage->list[i].source_dset.dset) + /* Flush source dataset */ + if (H5D__flush_real(storage->list[i].source_dset.dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to flush source dataset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_flush() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_hold_source_dset_files * @@ -2956,10 +3063,10 @@ 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 */ - H5D_virtual_held_file_t *tmp; /* Temporary held file node */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -2971,52 +3078,50 @@ H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t * storage = &dset->shared->layout.storage.u.virt; /* Hold only files for open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { - size_t j; /* Local index variable */ + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + size_t j; /* Local index variable */ /* Iterate over sub-source dsets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) - if(storage->list[i].sub_dset[j].dset) { + for (j = 0; j < storage->list[i].sub_dset_nused; j++) + if (storage->list[i].sub_dset[j].dset) { /* Hold open the file */ H5F_INCR_NOPEN_OBJS(storage->list[i].sub_dset[j].dset->oloc.file); /* Allocate a node for this file */ - if(NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) + if (NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") /* Set up node & connect to list */ tmp->file = storage->list[i].sub_dset[j].dset->oloc.file; tmp->next = *head; - *head = tmp; + *head = tmp; } /* end if */ + } /* end if */ + else if (storage->list[i].source_dset.dset) { + /* Hold open the file */ + H5F_INCR_NOPEN_OBJS(storage->list[i].source_dset.dset->oloc.file); + + /* Allocate a node for this file */ + if (NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") + + /* Set up node & connect to list */ + tmp->file = storage->list[i].source_dset.dset->oloc.file; + tmp->next = *head; + *head = tmp; } /* end if */ - else - if(storage->list[i].source_dset.dset) { - /* Hold open the file */ - H5F_INCR_NOPEN_OBJS(storage->list[i].source_dset.dset->oloc.file); - - /* Allocate a node for this file */ - if(NULL == (tmp = H5FL_MALLOC(H5D_virtual_held_file_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate held file node") - - /* Set up node & connect to list */ - tmp->file = storage->list[i].source_dset.dset->oloc.file; - tmp->next = *head; - *head = tmp; - } /* end if */ done: - if(ret_value < 0) + if (ret_value < 0) /* Release hold on files and delete list on error */ - if(*head && H5D__virtual_release_source_dset_files(*head) < 0) + if (*head && H5D__virtual_release_source_dset_files(*head) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release source datasets' files held open") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_hold_source_dset_files() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_refresh_source_dset * @@ -3032,8 +3137,9 @@ H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t * static herr_t H5D__virtual_refresh_source_dset(H5D_t **dset) { - hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ + H5VL_object_t *vol_obj = NULL; /* VOL object stored with the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3041,22 +3147,27 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) HDassert(dset && *dset); /* Get a temporary identifier for this source dataset */ - if((temp_id = H5I_register(H5I_DATASET, *dset, FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register source dataset ID") + if ((temp_id = H5VL_wrap_register(H5I_DATASET, *dset, FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register (temporary) source dataset ID") /* Refresh source dataset */ - if(H5D__refresh(temp_id, *dset) < 0) + if (H5D__refresh(temp_id, *dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") /* Discard the identifier & replace the dataset */ - if(NULL == (*dset = (H5D_t *)H5I_remove(temp_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID") + if (NULL == (*dset = (H5D_t *)H5VL_object_unwrap(vol_obj))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve library object from VOL object") + vol_obj->data = NULL; done: + if (vol_obj && H5VL_free_object(vol_obj) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dset() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_refresh_source_dsets * @@ -3072,9 +3183,9 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) herr_t H5D__virtual_refresh_source_dsets(H5D_t *dset) { - H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3085,31 +3196,30 @@ H5D__virtual_refresh_source_dsets(H5D_t *dset) storage = &dset->shared->layout.storage.u.virt; /* Refresh only open datasets */ - for(i = 0; i < storage->list_nused; i++) + for (i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { - size_t j; /* Local index variable */ + if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { + size_t j; /* Local index variable */ /* Iterate over sub-source datasets */ - for(j = 0; j < storage->list[i].sub_dset_nused; j++) + for (j = 0; j < storage->list[i].sub_dset_nused; j++) /* Check if sub-source dataset is open */ - if(storage->list[i].sub_dset[j].dset) + if (storage->list[i].sub_dset[j].dset) /* Refresh sub-source dataset */ - if(H5D__virtual_refresh_source_dset(&storage->list[i].sub_dset[j].dset) < 0) + if (H5D__virtual_refresh_source_dset(&storage->list[i].sub_dset[j].dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") } /* end if */ 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") + 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") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dsets() */ - /*------------------------------------------------------------------------- * Function: H5D__virtual_release_source_dset_files * @@ -3125,13 +3235,13 @@ H5D__virtual_refresh_source_dsets(H5D_t *dset) herr_t H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Release hold on files and delete list */ - while(head) { - H5D_virtual_held_file_t *tmp = head->next; /* Temporary pointer to next node */ + while (head) { + H5D_virtual_held_file_t *tmp = head->next; /* Temporary pointer to next node */ /* Release hold on file */ H5F_DECR_NOPEN_OBJS(head->file); @@ -3141,7 +3251,7 @@ H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) * essentially "private" to the virtual dataset, since it wasn't * opened through an API routine -QAK) */ - if(H5F_try_close(head->file, NULL) < 0) + if (H5F_try_close(head->file, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") /* Delete node */ @@ -3154,4 +3264,3 @@ H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_release_source_dset_files() */ - diff --git a/src/H5E.c b/src/H5E.c index a56181d18ef..bcadd6333f9 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -43,53 +43,48 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Epkg.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* HDF5 error class */ -#define H5E_CLS_NAME "HDF5" -#define H5E_CLS_LIB_NAME "HDF5" - +#define H5E_CLS_NAME "HDF5" +#define H5E_CLS_LIB_NAME "HDF5" /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Static function declarations */ -static herr_t H5E__set_default_auto(H5E_t *stk); +static herr_t H5E__set_default_auto(H5E_t *stk); static H5E_cls_t *H5E__register_class(const char *cls_name, const char *lib_name, const char *version); -static herr_t H5E__unregister_class(H5E_cls_t *cls); -static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); -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 herr_t H5E__unregister_class(H5E_cls_t *cls); +static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size); +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 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 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); /*********************/ /* Package Variables */ @@ -98,12 +93,10 @@ static ssize_t H5E__get_num(const H5E_t *err_stack); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -119,30 +112,28 @@ H5FL_DEFINE_STATIC(H5E_msg_t); /* Error class ID class */ static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ - H5I_ERROR_CLASS, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ + H5I_ERROR_CLASS, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ (H5I_free_t)H5E__unregister_class /* Callback routine for closing objects of this class */ }}; /* Error message ID class */ static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ - H5I_ERROR_MSG, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ + H5I_ERROR_MSG, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */ }}; /* Error stack ID class */ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ - H5I_ERROR_STACK, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ + H5I_ERROR_STACK, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ (H5I_free_t)H5E__close_stack /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5E_init * @@ -158,7 +149,7 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ herr_t H5E_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -167,7 +158,6 @@ H5E_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_init() */ - /*-------------------------------------------------------------------------- * Function: H5E__init_package * @@ -183,23 +173,23 @@ H5E_init(void) herr_t H5E__init_package(void) { - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - char lib_vers[128]; /* Buffer to constructu library version within */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + H5E_msg_t *msg; /* Pointer to new error message */ + char lib_vers[128]; /* Buffer to constructu library version within */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the error class IDs */ - if(H5I_register_type(H5I_ERRCLS_CLS) < 0) + if (H5I_register_type(H5I_ERRCLS_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Initialize the atom group for the major error IDs */ - if(H5I_register_type(H5I_ERRMSG_CLS) < 0) + if (H5I_register_type(H5I_ERRMSG_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Initialize the atom group for the error stacks */ - if(H5I_register_type(H5I_ERRSTK_CLS) < 0) + if (H5I_register_type(H5I_ERRSTK_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") #ifndef H5_HAVE_THREADSAFE @@ -209,20 +199,20 @@ H5E__init_package(void) /* Allocate the HDF5 error class */ HDassert(H5E_ERR_CLS_g == (-1)); - HDsnprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, (HDstrlen(H5_VERS_SUBRELEASE) > 0 ? "-"H5_VERS_SUBRELEASE : "")); - if(NULL == (cls = H5E__register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) + HDsnprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, + (HDstrlen(H5_VERS_SUBRELEASE) > 0 ? "-" H5_VERS_SUBRELEASE : "")); + if (NULL == (cls = H5E__register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "class initialization failed") - if((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls, FALSE)) < 0) + if ((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls, FALSE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class") - /* Include the automatically generated error code initialization */ - #include "H5Einit.h" +/* Include the automatically generated error code initialization */ +#include "H5Einit.h" done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__init_package() */ - /*------------------------------------------------------------------------- * Function: H5E_term_package * @@ -241,11 +231,11 @@ H5E__init_package(void) int H5E_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { int64_t ncls, nmsg, nstk; /* Check if there are any open error stacks, classes or messages */ @@ -253,33 +243,47 @@ H5E_term_package(void) nmsg = H5I_nmembers(H5I_ERROR_MSG); nstk = H5I_nmembers(H5I_ERROR_STACK); - if((ncls + nmsg + nstk) > 0) { + if ((ncls + nmsg + nstk) > 0) { + /* Clear the default error stack. Note that + * the following H5I_clear_type calls do not + * force the clears and will not be able to + * clear any error message IDs that are still + * in use by the default error stack unless we + * clear that stack manually. + * + * Error message IDs will typically still be + * in use by the default error stack when the + * application does H5E_BEGIN/END_TRY cleanup + * at the very end. + */ + H5E_clear_stack(NULL); + /* Clear any outstanding error stacks */ - if(nstk > 0) - (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); + if (nstk > 0) + (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); /* Clear all the error classes */ - if(ncls > 0) { + if (ncls > 0) { (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); /* Reset the HDF5 error class, if its been closed */ - if(H5I_nmembers(H5I_ERROR_CLASS) == 0) + if (H5I_nmembers(H5I_ERROR_CLASS) == 0) H5E_ERR_CLS_g = -1; } /* end if */ /* Clear all the error messages */ - if(nmsg > 0) { + if (nmsg > 0) { (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); /* Reset the HDF5 error messages, if they've been closed */ - if(H5I_nmembers(H5I_ERROR_MSG) == 0) { - /* Include the automatically generated error code termination */ - #include "H5Eterm.h" + if (H5I_nmembers(H5I_ERROR_MSG) == 0) { +/* Include the automatically generated error code termination */ +#include "H5Eterm.h" } /* end if */ - } /* end if */ + } /* end if */ n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Destroy the error class, message, and stack id groups */ n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); @@ -287,15 +291,14 @@ H5E_term_package(void) n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5E_term_package() */ - /*-------------------------------------------------------------------------- * Function: H5E__set_default_auto * @@ -317,14 +320,14 @@ H5E__set_default_auto(H5E_t *stk) #ifndef H5_NO_DEPRECATED_SYMBOLS #ifdef H5_USE_16_API_DEFAULT stk->auto_op.vers = 1; -#else /* H5_USE_16_API */ +#else /* H5_USE_16_API */ stk->auto_op.vers = 2; #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.is_default = TRUE; -#else /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_op.is_default = TRUE; +#else /* H5_NO_DEPRECATED_SYMBOLS */ stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -333,7 +336,6 @@ H5E__set_default_auto(H5E_t *stk) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__set_default_auto() */ - #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- * Function: H5E__get_stack @@ -359,7 +361,7 @@ H5E__get_stack(void) estack = (H5E_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); - if(!estack) { + if (!estack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ @@ -386,9 +388,8 @@ H5E__get_stack(void) /* Set return value */ FUNC_LEAVE_NOAPI(estack) } /* end H5E__get_stack() */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ - /*------------------------------------------------------------------------- * Function: H5E__free_class * @@ -410,15 +411,14 @@ H5E__free_class(H5E_cls_t *cls) HDassert(cls); /* Free error class structure */ - cls->cls_name = (char *)H5MM_xfree((void*)cls->cls_name); - cls->lib_name = (char *)H5MM_xfree((void*)cls->lib_name); - cls->lib_vers = (char *)H5MM_xfree((void*)cls->lib_vers); - cls = H5FL_FREE(H5E_cls_t, cls); + cls->cls_name = (char *)H5MM_xfree((void *)cls->cls_name); + cls->lib_name = (char *)H5MM_xfree((void *)cls->lib_name); + cls->lib_vers = (char *)H5MM_xfree((void *)cls->lib_vers); + cls = H5FL_FREE(H5E_cls_t, cls); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__free_class() */ - /*------------------------------------------------------------------------- * Function: H5Eregister_class * @@ -435,29 +435,28 @@ H5E__free_class(H5E_cls_t *cls) hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls; /* Pointer to error class */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*s*s*s", cls_name, lib_name, version); /* Check arguments */ - if(cls_name == NULL || lib_name == NULL || version == NULL) + if (cls_name == NULL || lib_name == NULL || version == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid string") /* Create the new error class object */ - if(NULL == (cls = H5E__register_class(cls_name, lib_name, version))) + if (NULL == (cls = H5E__register_class(cls_name, lib_name, version))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error class") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_CLASS, cls, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_CLASS, cls, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error class") done: FUNC_LEAVE_API(ret_value) } /* end H5Eregister_class() */ - /*------------------------------------------------------------------------- * Function: H5E__register_class * @@ -474,8 +473,8 @@ H5Eregister_class(const char *cls_name, const char *lib_name, const char *versio static H5E_cls_t * H5E__register_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls = NULL; /* Pointer to error class */ - H5E_cls_t *ret_value = NULL; /* Return value */ + H5E_cls_t *cls = NULL; /* Pointer to error class */ + H5E_cls_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -485,29 +484,28 @@ H5E__register_class(const char *cls_name, const char *lib_name, const char *vers HDassert(version); /* Allocate space for new error class */ - if(NULL == (cls = H5FL_CALLOC(H5E_cls_t))) + if (NULL == (cls = H5FL_CALLOC(H5E_cls_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate string information */ - if(NULL == (cls->cls_name = H5MM_xstrdup(cls_name))) + if (NULL == (cls->cls_name = H5MM_xstrdup(cls_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cls->lib_name = H5MM_xstrdup(lib_name))) + if (NULL == (cls->lib_name = H5MM_xstrdup(lib_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (cls->lib_vers = H5MM_xstrdup(version))) + if (NULL == (cls->lib_vers = H5MM_xstrdup(version))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the return value */ ret_value = cls; done: - if(!ret_value) - if(cls && H5E__free_class(cls) < 0) + if (!ret_value) + if (cls && H5E__free_class(cls) < 0) HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class") FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__register_class() */ - /*------------------------------------------------------------------------- * Function: H5Eunregister_class * @@ -523,27 +521,26 @@ H5E__register_class(const char *cls_name, const char *lib_name, const char *vers herr_t H5Eunregister_class(hid_t class_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", class_id); /* Check arguments */ - if(H5I_ERROR_CLASS != H5I_get_type(class_id)) + if (H5I_ERROR_CLASS != H5I_get_type(class_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(class_id) < 0) + if (H5I_dec_app_ref(class_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") done: FUNC_LEAVE_API(ret_value) } /* end H5Eunregister_class() */ - /*------------------------------------------------------------------------- * Function: H5E__unregister_class * @@ -559,7 +556,7 @@ H5Eunregister_class(hid_t class_id) static herr_t H5E__unregister_class(H5E_cls_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -567,18 +564,17 @@ H5E__unregister_class(H5E_cls_t *cls) HDassert(cls); /* Iterate over all the messages and delete those in this error class */ - if(H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, FALSE) < 0) + if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_BADITER, FAIL, "unable to free all messages in this error class") /* Free error class structure */ - if(H5E__free_class(cls) < 0) + if (H5E__free_class(cls) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "unable to free error class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__unregister_class() */ - /*------------------------------------------------------------------------- * Function: H5Eget_class_name * @@ -595,25 +591,24 @@ H5E__unregister_class(H5E_cls_t *cls) ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size) { - H5E_cls_t *cls; /* Pointer to error class */ - ssize_t ret_value = -1; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", class_id, name, size); /* Get the error class */ - if(NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error class ID") /* Retrieve the class name */ - if((ret_value = H5E__get_class_name(cls, name, size)) < 0) + if ((ret_value = H5E__get_class_name(cls, name, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error class name") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_class_name() */ - /*------------------------------------------------------------------------- * Function: H5E__get_class_name * @@ -630,7 +625,7 @@ H5Eget_class_name(hid_t class_id, char *name, size_t size) static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) { - ssize_t len = -1; /* Length of error class's name */ + ssize_t len = -1; /* Length of error class's name */ FUNC_ENTER_STATIC_NOERR @@ -641,17 +636,16 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) len = (ssize_t)HDstrlen(cls->cls_name); /* Set the user's buffer, if provided */ - if(name) { - HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); - if((size_t)len >= size) - name[size - 1] = '\0'; + if (name) { + HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); + if ((size_t)len >= size) + name[size - 1] = '\0'; } /* end if */ /* Return the full length */ FUNC_LEAVE_NOAPI(len) } /* end H5E__get_class_name() */ - /*------------------------------------------------------------------------- * Function: H5E__close_msg_cb * @@ -669,9 +663,9 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) { - H5E_msg_t *err_msg = (H5E_msg_t*)obj_ptr; - H5E_cls_t *cls = (H5E_cls_t*)udata; - int ret_value = H5_ITER_CONT; /* Return value */ + H5E_msg_t *err_msg = (H5E_msg_t *)obj_ptr; + H5E_cls_t *cls = (H5E_cls_t *)udata; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -679,10 +673,10 @@ H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) HDassert(err_msg); /* Close the message if it is in the class being closed */ - if(err_msg->cls == cls) { - if(H5E__close_msg(err_msg) < 0) + if (err_msg->cls == cls) { + if (H5E__close_msg(err_msg) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "unable to close error message") - if(NULL == H5I_remove(obj_id)) + if (NULL == H5I_remove(obj_id)) HGOTO_ERROR(H5E_ERROR, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove error message") } /* end if */ @@ -690,7 +684,6 @@ H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__close_msg_cb() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_msg * @@ -706,24 +699,23 @@ H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata) herr_t H5Eclose_msg(hid_t err_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", err_id); /* Check arguments */ - if(H5I_ERROR_MSG != H5I_get_type(err_id)) + if (H5I_ERROR_MSG != H5I_get_type(err_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* Decrement the counter. It will be freed if the count reaches zero. */ - if(H5I_dec_app_ref(err_id) < 0) + if (H5I_dec_app_ref(err_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclose_msg() */ - /*------------------------------------------------------------------------- * Function: H5E__close_msg * @@ -752,7 +744,6 @@ H5E__close_msg(H5E_msg_t *err) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__close_msg() */ - /*------------------------------------------------------------------------- * Function: H5Ecreate_msg * @@ -769,29 +760,29 @@ H5E__close_msg(H5E_msg_t *err) hid_t H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) { - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + H5E_msg_t *msg; /* Pointer to new error message */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iEt*s", class_id, msg_type, msg_str); /* Check arguments */ - if(msg_type != H5E_MAJOR && msg_type != H5E_MINOR) + if (msg_type != H5E_MAJOR && msg_type != H5E_MINOR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "not a valid message type") - if(msg_str == NULL) + if (msg_str == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "message is NULL") /* Get the error class */ - if(NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an error class ID") /* Create the new error message object */ - if(NULL == (msg = H5E__create_msg(cls, msg_type, msg_str))) + if (NULL == (msg = H5E__create_msg(cls, msg_type, msg_str))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error message") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_MSG, msg, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_MSG, msg, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error message") done: @@ -814,8 +805,8 @@ H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) static H5E_msg_t * H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) { - H5E_msg_t *msg = NULL; /* Pointer to new error message */ - H5E_msg_t *ret_value = NULL; /* Return value */ + H5E_msg_t *msg = NULL; /* Pointer to new error message */ + H5E_msg_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -825,27 +816,26 @@ H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) HDassert(msg_str); /* Allocate new message object */ - if(NULL == (msg = H5FL_MALLOC(H5E_msg_t))) + if (NULL == (msg = H5FL_MALLOC(H5E_msg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Fill new message object */ - msg->cls = cls; + msg->cls = cls; msg->type = msg_type; - if(NULL == (msg->msg = H5MM_xstrdup(msg_str))) + if (NULL == (msg->msg = H5MM_xstrdup(msg_str))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = msg; done: - if(!ret_value) - if(msg && H5E__close_msg(msg) < 0) + if (!ret_value) + if (msg && H5E__close_msg(msg) < 0) HDONE_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, NULL, "unable to close error message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__create_msg() */ - /*------------------------------------------------------------------------- * Function: H5Eget_msg * @@ -862,25 +852,24 @@ H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) { - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t ret_value = -1; /* Return value */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API_NOCLEAR((-1)) H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error message ID") /* Get the message's text */ - if((ret_value = H5E__get_msg(msg, type, msg_str, size)) < 0) + if ((ret_value = H5E__get_msg(msg, type, msg_str, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error message text") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_msg() */ - /*------------------------------------------------------------------------- * Function: H5Ecreate_stack * @@ -897,28 +886,27 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) hid_t H5Ecreate_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE0("i",""); + H5TRACE0("i", ""); /* Allocate a new error stack */ - if(NULL == (stk = H5FL_CALLOC(H5E_t))) + if (NULL == (stk = H5FL_CALLOC(H5E_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Set the "automatic" error reporting info to the library default */ H5E__set_default_auto(stk); /* Register the stack */ - if((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Ecreate_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eget_current_stack * @@ -936,26 +924,25 @@ H5Ecreate_stack(void) hid_t H5Eget_current_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5I_INVALID_HID) - H5TRACE0("i",""); + H5TRACE0("i", ""); /* Get the current stack */ - if(NULL == (stk = H5E__get_current_stack())) + if (NULL == (stk = H5E__get_current_stack())) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error stack") /* Register the stack */ - if((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__get_current_stack * @@ -972,51 +959,52 @@ 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 */ - unsigned u; /* Local index variable */ - H5E_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC /* Get a pointer to the current error stack */ - if(NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack") + if (NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' + in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack") /* Allocate a new error stack */ - if(NULL == (estack_copy = H5FL_CALLOC(H5E_t))) + if (NULL == (estack_copy = H5FL_CALLOC(H5E_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make a copy of current error stack */ estack_copy->nused = current_stack->nused; - for(u = 0; u < current_stack->nused; u++) { + for (u = 0; u < current_stack->nused; u++) { H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); - new_error = &(estack_copy->slot[u]); + new_error = &(estack_copy->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(current_error->cls_id, FALSE) < 0) + if (H5I_inc_ref(current_error->cls_id, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error class") new_error->cls_id = current_error->cls_id; - if(H5I_inc_ref(current_error->maj_num, FALSE) < 0) + if (H5I_inc_ref(current_error->maj_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->maj_num = current_error->maj_num; - if(H5I_inc_ref(current_error->min_num, FALSE) < 0) + if (H5I_inc_ref(current_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->min_num = current_error->min_num; - if(NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) + if (NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) + if (NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") new_error->line = current_error->line; - if(NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) + if (NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end for */ /* Copy the "automatic" error reporting information */ - estack_copy->auto_op = current_stack->auto_op; + estack_copy->auto_op = current_stack->auto_op; estack_copy->auto_data = current_stack->auto_data; /* Empty current error stack */ @@ -1026,14 +1014,13 @@ H5E__get_current_stack(void) ret_value = estack_copy; done: - if(ret_value == NULL) - if(estack_copy) + if (ret_value == NULL) + if (estack_copy) estack_copy = H5FL_FREE(H5E_t, estack_copy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__get_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eset_current_stack * @@ -1051,24 +1038,24 @@ herr_t H5Eset_current_stack(hid_t err_stack) { H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", err_stack); - if(err_stack != H5E_DEFAULT) { - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (err_stack != H5E_DEFAULT) { + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Set the current error stack */ - if(H5E__set_current_stack(estack) < 0) + if (H5E__set_current_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "unable to set error stack") /* * Decrement the counter on the error stack. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(err_stack) < 0) + if (H5I_dec_app_ref(err_stack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ @@ -1076,7 +1063,6 @@ H5Eset_current_stack(hid_t err_stack) FUNC_LEAVE_API(ret_value) } /* end H5Eset_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__set_current_stack * @@ -1092,9 +1078,9 @@ H5Eset_current_stack(hid_t err_stack) static herr_t H5E__set_current_stack(H5E_t *estack) { - H5E_t *current_stack; /* Default error stack */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * current_stack; /* Default error stack */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1102,37 +1088,38 @@ H5E__set_current_stack(H5E_t *estack) HDassert(estack); /* Get a pointer to the current error stack */ - if(NULL == (current_stack = H5E__get_my_stack ())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + if (NULL == (current_stack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' + in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Empty current error stack */ H5E_clear_stack(current_stack); /* Copy new stack to current error stack */ current_stack->nused = estack->nused; - for(u = 0; u < current_stack->nused; u++) { + for (u = 0; u < current_stack->nused; u++) { H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); - new_error = &(estack->slot[u]); + new_error = &(estack->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(new_error->cls_id, FALSE) < 0) + if (H5I_inc_ref(new_error->cls_id, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->cls_id = new_error->cls_id; - if(H5I_inc_ref(new_error->maj_num, FALSE) < 0) + if (H5I_inc_ref(new_error->maj_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->maj_num = new_error->maj_num; - if(H5I_inc_ref(new_error->min_num, FALSE) < 0) + if (H5I_inc_ref(new_error->min_num, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to increment ref count on error class") current_error->min_num = new_error->min_num; - if(NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) + if (NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) + if (NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") current_error->line = new_error->line; - if(NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) + if (NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end for */ @@ -1140,7 +1127,6 @@ H5E__set_current_stack(H5E_t *estack) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__set_current_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eclose_stack * @@ -1156,21 +1142,21 @@ H5E__set_current_stack(H5E_t *estack) herr_t H5Eclose_stack(hid_t stack_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", stack_id); - if(H5E_DEFAULT != stack_id) { + if (H5E_DEFAULT != stack_id) { /* Check arguments */ - if(H5I_ERROR_STACK != H5I_get_type(stack_id)) + if (H5I_ERROR_STACK != H5I_get_type(stack_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* * Decrement the counter on the error stack. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(stack_id) < 0) + if (H5I_dec_app_ref(stack_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ @@ -1178,7 +1164,6 @@ H5Eclose_stack(hid_t stack_id) FUNC_LEAVE_API(ret_value) } /* end H5Eclose_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__close_stack * @@ -1208,7 +1193,6 @@ H5E__close_stack(H5E_t *estack) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__close_stack() */ - /*------------------------------------------------------------------------- * Function: H5Eget_num * @@ -1225,16 +1209,17 @@ H5E__close_stack(H5E_t *estack) ssize_t H5Eget_num(hid_t error_stack_id) { - H5E_t *estack; /* Error stack to operate on */ - ssize_t ret_value; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR((-1)) H5TRACE1("Zs", "i", error_stack_id); /* Need to check for errors */ - if(error_stack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (error_stack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get current error stack") } /* end if */ else { @@ -1242,19 +1227,18 @@ H5Eget_num(hid_t error_stack_id) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an error stack ID") } /* end else */ /* Get the number of errors on stack */ - if((ret_value = H5E__get_num(estack)) < 0) + if ((ret_value = H5E__get_num(estack)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get number of errors") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_num() */ - /*------------------------------------------------------------------------- * Function: H5E__get_num * @@ -1278,7 +1262,6 @@ H5E__get_num(const H5E_t *estack) FUNC_LEAVE_NOAPI((ssize_t)estack->nused) } /* end H5E__get_num() */ - /*------------------------------------------------------------------------- * Function: H5Epop * @@ -1295,15 +1278,16 @@ herr_t H5Epop(hid_t err_stack, size_t count) { H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "iz", err_stack, count); /* 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 non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { @@ -1311,23 +1295,22 @@ H5Epop(hid_t err_stack, size_t count) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Range limit the number of errors to pop off stack */ - if(count > estack->nused) + if (count > estack->nused) count = estack->nused; /* Pop the errors off the stack */ - if(H5E__pop(estack, count) < 0) + if (H5E__pop(estack, count) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't pop errors from stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Epop() */ - /*------------------------------------------------------------------------- * Function: H5Epush2 * @@ -1349,93 +1332,61 @@ H5Epop(hid_t err_stack, size_t count) * *------------------------------------------------------------------------- */ +H5_ATTR_FORMAT(printf, 8, 9) herr_t -H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) +H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *fmt, ...) { - va_list ap; /* Varargs info */ - H5E_t *estack; /* Pointer to error stack to modify */ -#ifndef H5_HAVE_VASPRINTF - int tmp_len; /* Current size of description buffer */ - int desc_len; /* Actual length of description when formatted */ -#endif /* H5_HAVE_VASPRINTF */ - 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 */ + va_list ap; /* Varargs info */ + 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 */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) - H5TRACE8("e", "i*s*sIuiii*s", err_stack, file, func, line, cls_id, maj_id, - min_id, fmt); + H5TRACE8("e", "i*s*sIuiii*s", err_stack, file, func, line, cls_id, maj_id, min_id, fmt); - if(err_stack == H5E_DEFAULT) - estack = NULL; + if (err_stack == H5E_DEFAULT) + estack = NULL; else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ -/* Note that the variable-argument parsing for the format is identical in - * the H5E_printf_stack() routine - correct errors and make changes in both - * places. -QAK - */ + /* Note that the variable-argument parsing for the format is identical in + * the H5E_printf_stack() routine - correct errors and make changes in both + * places. -QAK + */ /* Format the description */ HDva_start(ap, fmt); va_started = TRUE; -#ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ - if(HDvasprintf(&tmp, fmt, ap) < 0) + if (HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") -#else /* H5_HAVE_VASPRINTF */ - /* Allocate space for the formatted description buffer */ - tmp_len = 128; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { - /* shutdown & restart the va_list */ - HDva_end(ap); - HDva_start(ap, fmt); - - /* Release the previous description, it's too small */ - H5MM_xfree(tmp); - - /* Allocate a description of the appropriate length */ - tmp_len = desc_len + 1; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end while */ -#endif /* H5_HAVE_VASPRINTF */ /* Push the error on the stack */ - if(H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") done: - if(va_started) + if (va_started) HDva_end(ap); -#ifdef H5_HAVE_VASPRINTF /* Memory was allocated with HDvasprintf so it needs to be freed * with HDfree */ - if(tmp) + if (tmp) HDfree(tmp); -#else /* H5_HAVE_VASPRINTF */ - if(tmp) - H5MM_xfree(tmp); -#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ - /*------------------------------------------------------------------------- * Function: H5Eclear2 * @@ -1451,33 +1402,32 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, herr_t H5Eclear2(hid_t err_stack) { - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + 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) H5TRACE1("e", "i", err_stack); /* Need to check for errors */ - if(err_stack == H5E_DEFAULT) - estack = NULL; + if (err_stack == H5E_DEFAULT) + estack = NULL; else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Clear the error stack */ - if(H5E_clear_stack(estack) < 0) + if (H5E_clear_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclear2() */ - /*------------------------------------------------------------------------- * Function: H5Eprint2 * @@ -1496,35 +1446,35 @@ 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 */ + 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*/ /* 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 non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Print error stack */ - if(H5E__print(estack, stream, FALSE) < 0) + if (H5E__print(estack, stream, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eprint2() */ - /*------------------------------------------------------------------------- * Function: H5Ewalk2 * @@ -1541,38 +1491,38 @@ 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_walk_op_t op; /* Operator for walking error stack */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ /* 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 non-threaded case */ + if (err_stack == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if(NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) + if (NULL == (estack = (H5E_t *)H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Walk the error stack */ - op.vers = 2; + op.vers = 2; op.u.func2 = stack_func; - if((ret_value = H5E__walk(estack, direction, &op, client_data)) < 0) + if ((ret_value = H5E__walk(estack, direction, &op, client_data)) < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); done: FUNC_LEAVE_API(ret_value) } /* end H5Ewalk2() */ - /*------------------------------------------------------------------------- * Function: H5Eget_auto2 * @@ -1591,39 +1541,44 @@ 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_auto_op_t op; /* Error stack function */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t op; /* Error stack function */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE3("e", "i*x**x", estack_id, func, client_data); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &op, client_data) < 0) + if (H5E__get_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") #ifndef H5_NO_DEPRECATED_SYMBOLS /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto1 */ - if(!op.is_default && op.vers == 1) + if (!op.is_default && op.vers == 1) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called") #endif /* H5_NO_DEPRECATED_SYMBOLS */ - if(func) + if (func) *func = op.func2; done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_auto2() */ - /*------------------------------------------------------------------------- * Function: H5Eset_auto2 * @@ -1649,29 +1604,34 @@ 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_auto_op_t op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE3("e", "ix*x", estack_id, func, client_data); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &op, NULL) < 0) + if (H5E__get_auto(estack, &op, NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Set the automatic error reporting information */ - if(func != op.func2_default) + if (func != op.func2_default) op.is_default = FALSE; else op.is_default = TRUE; @@ -1682,14 +1642,13 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) /* Set the automatic error reporting function */ op.func2 = func; - if(H5E__set_auto(estack, &op, client_data) < 0) + if (H5E__set_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: FUNC_LEAVE_API(ret_value) } /* end H5Eset_auto2() */ - /*------------------------------------------------------------------------- * Function: H5Eauto_is_v2 * @@ -1708,22 +1667,28 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) herr_t H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) { - H5E_t *estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "i*Iu", estack_id, is_stack); - if(estack_id == H5E_DEFAULT) { - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack_id == H5E_DEFAULT) { + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ - else - if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) + else { + /* Only clear the error stack if it's not the default stack */ + H5E_clear_stack(NULL); + + if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + } /* end else */ /* Check if the error stack reporting function is the "newer" stack type */ - if(is_stack) + if (is_stack) #ifndef H5_NO_DEPRECATED_SYMBOLS *is_stack = estack->auto_op.vers > 1; #else @@ -1733,4 +1698,3 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) done: FUNC_LEAVE_API(ret_value) } /* end H5Eauto_is_v2() */ - diff --git a/src/H5EA.c b/src/H5EA.c index bf50452a546..4d6b7c1167f 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,30 +31,26 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -62,23 +58,18 @@ /* Typedef for generically unprotecting an object */ typedef herr_t (*H5EA__unprotect_func_t)(void *thing, unsigned cache_flags); - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -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); -static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, - void *ctx_udata); - +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); +static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata); /*********************/ /* Package Variables */ @@ -93,17 +84,15 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * client class.. */ const H5EA_class_t *const H5EA_client_class_g[] = { - H5EA_CLS_CHUNK, /* 0 - H5EA_CLS_CHUNK_ID */ - H5EA_CLS_FILT_CHUNK, /* 1 - H5EA_CLS_FILT_CHUNK_ID */ - H5EA_CLS_TEST, /* ? - H5EA_CLS_TEST_ID */ + H5EA_CLS_CHUNK, /* 0 - H5EA_CLS_CHUNK_ID */ + H5EA_CLS_FILT_CHUNK, /* 1 - H5EA_CLS_FILT_CHUNK_ID */ + H5EA_CLS_TEST, /* ? - H5EA_CLS_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -114,7 +103,6 @@ H5FL_DEFINE_STATIC(H5EA_t); /* Declare a PQ free list to manage the element */ H5FL_BLK_DEFINE(ea_native_elmt); - /*------------------------------------------------------------------------- * Function: H5EA__new * @@ -128,13 +116,12 @@ 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)) +BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, + H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + H5EA_t * ea = NULL; /* Pointer to new extensible array */ + H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ /* * Check arguments. @@ -143,25 +130,25 @@ H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) 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") + if (NULL == (ea = H5FL_CALLOC(H5EA_t))) + H5E_THROW(H5E_CANTALLOC, "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") + 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") /* Check for pending array deletion */ - if(from_open && hdr->pending_delete) + if (from_open && hdr->pending_delete) H5E_THROW(H5E_CANTOPENOBJ, "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") + if (H5EA__hdr_incr(ea->hdr) < 0) + H5E_THROW(H5E_CANTINC, "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") + if (H5EA__hdr_fuse_incr(ea->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ ea->f = f; @@ -169,17 +156,16 @@ H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(STATIC) /* end H5EA__new() */ +END_FUNC(STATIC) /* end H5EA__new() */ - /*------------------------------------------------------------------------- * Function: H5EA_create * @@ -193,13 +179,12 @@ 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)) +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 *ea = NULL; /* Pointer to new extensible array */ - haddr_t ea_addr; /* Array header address */ + H5EA_t *ea = NULL; /* Pointer to new extensible array */ + haddr_t ea_addr; /* Array header address */ /* * Check arguments. @@ -211,25 +196,24 @@ H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) HDcompile_assert(H5EA_NUM_CLS_ID == NELMTS(H5EA_client_class_g)); /* 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") + if (HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "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") + if (NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_create() */ +END_FUNC(PRIV) /* end H5EA_create() */ - /*------------------------------------------------------------------------- * Function: H5EA_open * @@ -243,12 +227,10 @@ 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)) +BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ /* * Check arguments. @@ -257,21 +239,20 @@ H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) 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") + if (NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; -CATCH + CATCH - if(!ret_value) - if(ea && H5EA_close(ea) < 0) + if (!ret_value) + if (ea && H5EA_close(ea) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_open() */ +END_FUNC(PRIV) /* end H5EA_open() */ - /*------------------------------------------------------------------------- * Function: H5EA_get_nelmts * @@ -284,9 +265,7 @@ END_FUNC(PRIV) /* end H5EA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) /* Local variables */ @@ -299,9 +278,8 @@ H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) /* Retrieve the max. index set */ *nelmts = ea->hdr->stats.stored.max_idx_set; -END_FUNC(PRIV) /* end H5EA_get_nelmts() */ +END_FUNC(PRIV) /* end H5EA_get_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5EA_get_addr * @@ -314,9 +292,7 @@ END_FUNC(PRIV) /* end H5EA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) /* Local variables */ @@ -330,9 +306,8 @@ H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) /* Retrieve the address of the extensible array's header */ *addr = ea->hdr->addr; -END_FUNC(PRIV) /* end H5EA_get_addr() */ +END_FUNC(PRIV) /* end H5EA_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5EA__lookup_elmt * @@ -346,22 +321,21 @@ 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)) +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 */ - 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 */ + 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 */ /* * Check arguments. @@ -379,18 +353,18 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, hdr->f = ea->f; /* Reset the pointers to the 'thing' info */ - *thing = NULL; - *thing_elmt_buf = NULL; - *thing_elmt_idx = 0; + *thing = NULL; + *thing_elmt_buf = NULL; + *thing_elmt_idx = 0; *thing_unprot_func = (H5EA__unprotect_func_t)NULL; /* Check if we should create the index block */ - if(!H5F_addr_defined(hdr->idx_blk_addr)) { + if (!H5F_addr_defined(hdr->idx_blk_addr)) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the index block */ hdr->idx_blk_addr = H5EA__iblock_create(hdr, &stats_changed); - if(!H5F_addr_defined(hdr->idx_blk_addr)) + if (!H5F_addr_defined(hdr->idx_blk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create index block") hdr_dirty = TRUE; } /* end if */ @@ -399,21 +373,22 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* 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) + 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) /* Check if element is in index block */ - if(idx < hdr->cparam.idx_blk_elmts) { + if (idx < hdr->cparam.idx_blk_elmts) { /* Set 'thing' info to refer to the index block */ - *thing = iblock; - *thing_elmt_buf = (uint8_t *)iblock->elmts; - *thing_elmt_idx = idx; + *thing = iblock; + *thing_elmt_buf = (uint8_t *)iblock->elmts; + *thing_elmt_idx = idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__iblock_unprotect; } /* end if */ else { - unsigned sblk_idx; /* Which superblock does this index fall in? */ - size_t dblk_idx; /* Data block index */ - hsize_t elmt_idx; /* Offset of element in super block */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ + size_t dblk_idx; /* Data block index */ + hsize_t elmt_idx; /* Offset of element in super block */ /* Get super block index where element is located */ sblk_idx = H5EA__dblock_sblk_idx(hdr, idx); @@ -422,22 +397,25 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx = idx - (hdr->cparam.idx_blk_elmts + hdr->sblk_info[sblk_idx].start_idx); /* Check for data block containing element address in the index block */ - if(sblk_idx < iblock->nsblks) { + if (sblk_idx < iblock->nsblks) { /* Compute the data block index in index block */ - dblk_idx = (size_t)(hdr->sblk_info[sblk_idx].start_dblk + (elmt_idx / hdr->sblk_info[sblk_idx].dblk_nelmts)); + dblk_idx = (size_t)(hdr->sblk_info[sblk_idx].start_dblk + + (elmt_idx / hdr->sblk_info[sblk_idx].dblk_nelmts)); HDassert(dblk_idx < iblock->ndblk_addrs); /* Check if the data block has been allocated on disk yet */ - if(!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) { + if (!H5F_addr_defined(iblock->dblk_addrs[dblk_idx])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t dblk_addr; /* Address of data block created */ - hsize_t dblk_off; /* Offset of data block in array */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t dblk_addr; /* Address of data block created */ + hsize_t dblk_off; /* Offset of data block in array */ /* Create data block */ - dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); - if(!H5F_addr_defined(dblk_addr)) + dblk_off = hdr->sblk_info[sblk_idx].start_idx + + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); + 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") /* Set data block address in index block */ @@ -449,40 +427,44 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* 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]) + 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]) /* Adjust index to offset in data block */ elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts; /* 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) + 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) dblock->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block */ - *thing = dblock; - *thing_elmt_buf = (uint8_t *)dblock->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblock; + *thing_elmt_buf = (uint8_t *)dblock->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect; } /* end if */ else { - size_t sblk_off; /* Offset of super block in index block array of super blocks */ + size_t sblk_off; /* Offset of super block in index block array of super blocks */ /* Calculate offset of super block in index block's array */ sblk_off = sblk_idx - iblock->nsblks; /* Check if the super block has been allocated on disk yet */ - if(!H5F_addr_defined(iblock->sblk_addrs[sblk_off])) { + if (!H5F_addr_defined(iblock->sblk_addrs[sblk_off])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t sblk_addr; /* Address of data block created */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t sblk_addr; /* Address of data block created */ /* Create super block */ sblk_addr = H5EA__sblock_create(hdr, iblock, &stats_changed, sblk_idx); - if(!H5F_addr_defined(sblk_addr)) + if (!H5F_addr_defined(sblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array super block") /* Set super block address in index block */ @@ -494,37 +476,46 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* 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]) + 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]) /* Compute the data block index in super block */ dblk_idx = (size_t)(elmt_idx / sblock->dblk_nelmts); HDassert(dblk_idx < sblock->ndblks); /* Check if the data block has been allocated on disk yet */ - if(!H5F_addr_defined(sblock->dblk_addrs[dblk_idx])) { + if (!H5F_addr_defined(sblock->dblk_addrs[dblk_idx])) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ - haddr_t dblk_addr; /* Address of data block created */ - hsize_t dblk_off; /* Offset of data block in array */ + if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + haddr_t dblk_addr; /* Address of data block created */ + hsize_t dblk_off; /* Offset of data block in array */ /* Create data block */ - dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); - if(!H5F_addr_defined(dblk_addr)) + dblk_off = hdr->sblk_info[sblk_idx].start_idx + + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); + 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") /* Set data block address in index block */ sblock->dblk_addrs[dblk_idx] = dblk_addr; sblock_cache_flags |= H5AC__DIRTIED_FLAG; - /* Create flush dependency on header, if extending the array and one doesn't already exist */ - 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, "unable to create flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + /* Create flush dependency on header, if extending the array and one doesn't already exist + */ + 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, + "unable to create flush dependency between super block and header, address " + "= %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else H5_LEAVE(SUCCEED) } /* end if */ @@ -533,10 +524,10 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx %= sblock->dblk_nelmts; /* Check if the data block is paged */ - if(sblock->dblk_npages) { - haddr_t dblk_page_addr; /* Address of data block page */ - size_t page_idx; /* Index of page within data block */ - size_t page_init_idx; /* Index of 'page init' bit */ + if (sblock->dblk_npages) { + haddr_t dblk_page_addr; /* Address of data block page */ + size_t page_idx; /* Index of page within data block */ + size_t page_init_idx; /* Index of 'page init' bit */ /* Compute page index */ page_idx = (size_t)elmt_idx / hdr->dblk_page_nelmts; @@ -548,16 +539,15 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, elmt_idx %= hdr->dblk_page_nelmts; /* Compute data block page address */ - dblk_page_addr = sblock->dblk_addrs[dblk_idx] + - H5EA_DBLOCK_PREFIX_SIZE(sblock) + - (page_idx * sblock->dblk_page_size); + dblk_page_addr = sblock->dblk_addrs[dblk_idx] + H5EA_DBLOCK_PREFIX_SIZE(sblock) + + (page_idx * sblock->dblk_page_size); /* Check if page has been initialized yet */ - if(!H5VM_bit_get(sblock->page_init, page_init_idx)) { + if (!H5VM_bit_get(sblock->page_init, page_init_idx)) { /* Check if we are allowed to create the thing */ - if(0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ + 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) + if (H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) H5E_THROW(H5E_CANTCREATE, "unable to create data block page") /* Mark data block page as initialized in super block */ @@ -569,79 +559,89 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, } /* 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) + 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) /* 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) + 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) dblk_page->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block page */ - *thing = dblk_page; - *thing_elmt_buf = (uint8_t *)dblk_page->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblk_page; + *thing_elmt_buf = (uint8_t *)dblk_page->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblk_page_unprotect; } /* end if */ else { /* 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]) + 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]) /* 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) + 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) dblock->has_hdr_depend = TRUE; } /* end if */ /* Set 'thing' info to refer to the data block */ - *thing = dblock; - *thing_elmt_buf = (uint8_t *)dblock->elmts; - *thing_elmt_idx = elmt_idx; + *thing = dblock; + *thing_elmt_buf = (uint8_t *)dblock->elmts; + *thing_elmt_idx = elmt_idx; *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Sanity checks */ HDassert(*thing != NULL); HDassert(*thing_unprot_func != NULL); -CATCH + CATCH /* Reset 'thing' info on error */ - if(ret_value < 0) { - *thing = NULL; - *thing_elmt_buf = NULL; - *thing_elmt_idx = 0; + if (ret_value < 0) { + *thing = NULL; + *thing_elmt_buf = NULL; + *thing_elmt_idx = 0; *thing_unprot_func = (H5EA__unprotect_func_t)NULL; } /* end if */ /* Check for updating array statistics */ - if(stats_changed) + if (stats_changed) hdr_dirty = TRUE; /* Check for header modified */ - if(hdr_dirty) - if(H5EA__hdr_modified(hdr) < 0) + if (hdr_dirty) + if (H5EA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") /* Release resources */ - if(iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) + if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "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) + if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") - if(dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") - if(dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + 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") -END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ +END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ - /*------------------------------------------------------------------------- * Function: H5EA_set * @@ -654,18 +654,16 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) /* Local variables */ - 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 */ - 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 */ + 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 */ + 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 */ /* * Check arguments. @@ -678,7 +676,8 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) /* Look up the array metadata containing the element we want to set */ 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) + 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") /* Sanity check */ @@ -687,25 +686,25 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) HDassert(thing_unprot_func); /* Set element in thing's element buffer */ - H5MM_memcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), elmt, + hdr->cparam.cls->nat_elmt_size); thing_cache_flags |= H5AC__DIRTIED_FLAG; /* Update max. element set in array, if appropriate */ - if(will_extend) { + if (will_extend) { /* Update the max index for the array */ hdr->stats.stored.max_idx_set = idx + 1; - if(H5EA__hdr_modified(hdr) < 0) + if (H5EA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") } /* end if */ -CATCH + CATCH /* Release resources */ - if(thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) + if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_set() */ +END_FUNC(PRIV) /* end H5EA_set() */ - /*------------------------------------------------------------------------- * Function: H5EA_get * @@ -718,14 +717,13 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) /* Local variables */ - 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; /* Function pointer for unprotecting the array metadata */ + 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 */ /* * Check arguments. @@ -734,41 +732,42 @@ H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) HDassert(hdr); /* Check for element beyond max. element in array */ - if(idx >= hdr->stats.stored.max_idx_set) { + if (idx >= hdr->stats.stored.max_idx_set) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "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 */ - hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ + 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 */ /* Set the shared array header's file context for this operation */ hdr->f = ea->f; /* 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) + 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") /* Check if the thing holding the element has been created yet */ - if(NULL == thing) { + if (NULL == thing) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") } /* end if */ else /* Get element from thing's element buffer */ - H5MM_memcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(elmt, thing_elmt_buf + (hdr->cparam.cls->nat_elmt_size * thing_elmt_idx), + hdr->cparam.cls->nat_elmt_size); } /* end else */ -CATCH + CATCH /* Release thing */ - if(thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) + if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_get() */ +END_FUNC(PRIV) /* end H5EA_get() */ - /*------------------------------------------------------------------------- * Function: H5EA_depend * @@ -782,12 +781,10 @@ END_FUNC(PRIV) /* end H5EA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ /* * Check arguments. @@ -801,7 +798,7 @@ H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) * and another data structure in the file has already been set up. * If it hasn't, do so now. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -809,16 +806,15 @@ H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) hdr->f = ea->f; /* Add the extensible array as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + 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") hdr->parent = parent; } /* end if */ -CATCH + CATCH -END_FUNC(PRIV) /* end H5EA_depend() */ +END_FUNC(PRIV) /* end H5EA_depend() */ - /*------------------------------------------------------------------------- * Function: H5EA_close * @@ -831,13 +827,11 @@ END_FUNC(PRIV) /* end H5EA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5EA_close(H5EA_t *ea)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Local variables */ - hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ - haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ + haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ /* * Check arguments. @@ -845,46 +839,48 @@ H5EA_close(H5EA_t *ea)) HDassert(ea); /* Close the header, if it was set */ - if(ea->hdr) { - /* Decrement file reference & check if this is the last open extensible array using the shared array header */ - if(0 == H5EA__hdr_fuse_decr(ea->hdr)) { + if (ea->hdr) { + /* Decrement file reference & check if this is the last open extensible array using the shared array + * header */ + if (0 == H5EA__hdr_fuse_decr(ea->hdr)) { /* Set the shared array header's file context for this operation */ ea->hdr->f = ea->f; /* Shut down anything that can't be put in the header's 'flush' callback */ /* Check for pending array deletion */ - if(ea->hdr->pending_delete) { + if (ea->hdr->pending_delete) { /* Set local info, so array deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - ea_addr = ea->hdr->addr; + ea_addr = ea->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending array deletion */ - if(pending_delete) { - H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ + if (pending_delete) { + H5EA_hdr_t *hdr; /* Another pointer to extensible array header */ #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* 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") - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* 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") + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* 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))) + 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") /* Set the shared array header's file context for this operation */ @@ -894,11 +890,11 @@ H5EA_close(H5EA_t *ea)) /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5EA__hdr_decr(ea->hdr) < 0) + if (H5EA__hdr_decr(ea->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ - if(H5EA__hdr_delete(hdr) < 0) + if (H5EA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") } /* end if */ else { @@ -906,19 +902,18 @@ H5EA_close(H5EA_t *ea)) /* (don't put in H5EA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5EA__hdr_decr(ea->hdr) < 0) + if (H5EA__hdr_decr(ea->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") } /* end else */ - } /* end if */ + } /* end if */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); -CATCH + CATCH -END_FUNC(PRIV) /* end H5EA_close() */ +END_FUNC(PRIV) /* end H5EA_close() */ - /*------------------------------------------------------------------------- * Function: H5EA_delete * @@ -931,12 +926,10 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ /* * Check arguments. @@ -945,31 +938,31 @@ H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) 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) + 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) /* Check for files using shared array header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared array header's file context for this operation */ hdr->f = f; /* Delete array now, starting with header (unprotects header) */ - if(H5EA__hdr_delete(hdr) < 0) + if (H5EA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") hdr = NULL; } /* end if */ -CATCH + CATCH /* Unprotect the header, if an error occurred */ - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PRIV) /* end H5EA_delete() */ +END_FUNC(PRIV) /* end H5EA_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA_iterate * @@ -982,14 +975,13 @@ 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)) +BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, + H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) /* Local variables */ - uint8_t *elmt = NULL; - hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + uint8_t *elmt = NULL; + hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ /* Check arguments */ HDassert(ea); @@ -997,30 +989,29 @@ H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) HDassert(udata); /* Allocate space for a native array element */ - if(NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) + 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") /* 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 && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ - if(H5EA_get(ea, u, elmt) < 0) + if (H5EA_get(ea, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if ((cb_ret = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); H5_LEAVE(cb_ret) } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH - if(elmt) + if (elmt) elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); -END_FUNC(PRIV) /* end H5EA_iterate() */ +END_FUNC(PRIV) /* end H5EA_iterate() */ - /*------------------------------------------------------------------------- * Function: H5EA_patch_file * @@ -1033,9 +1024,7 @@ END_FUNC(PRIV) /* end H5EA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_patch_file(H5EA_t *ea, H5F_t *f)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_patch_file(H5EA_t *ea, H5F_t *f)) /* Local variables */ @@ -1045,8 +1034,7 @@ H5EA_patch_file(H5EA_t *ea, H5F_t *f)) HDassert(ea); HDassert(f); - if(ea->f != f || ea->hdr->f != f) + if (ea->f != f || ea->hdr->f != f) ea->f = ea->hdr->f = f; -END_FUNC(PRIV) /* end H5EA_patch_file() */ - +END_FUNC(PRIV) /* end H5EA_patch_file() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index f7534fbb3ea..2a3153c6bc9 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,47 +26,41 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap format version #'s */ -#define H5EA_HDR_VERSION 0 /* Header */ -#define H5EA_IBLOCK_VERSION 0 /* Index block */ -#define H5EA_SBLOCK_VERSION 0 /* Super block */ -#define H5EA_DBLOCK_VERSION 0 /* Data block */ - +#define H5EA_HDR_VERSION 0 /* Header */ +#define H5EA_IBLOCK_VERSION 0 /* Index block */ +#define H5EA_SBLOCK_VERSION 0 /* Super block */ +#define H5EA_DBLOCK_VERSION 0 /* Data block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -74,163 +68,147 @@ /* 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_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); 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_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); 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_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); 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_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); static herr_t H5EA__cache_dblock_free_icr(void *thing); 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 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 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); static herr_t H5EA__cache_dblk_page_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5EA header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_HDR[1] = {{ - H5AC_EARRAY_HDR_ID, /* Metadata client ID */ - "Extensible Array Header", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_hdr_deserialize, /* 'deserialize' callback */ - H5EA__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_hdr_serialize, /* 'serialize' callback */ - H5EA__cache_hdr_notify, /* 'notify' callback */ - H5EA__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_EARRAY_HDR_ID, /* Metadata client ID */ + "Extensible Array Header", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_hdr_deserialize, /* 'deserialize' callback */ + H5EA__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_hdr_serialize, /* 'serialize' callback */ + H5EA__cache_hdr_notify, /* 'notify' callback */ + H5EA__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5EA index block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_IBLOCK[1] = {{ - H5AC_EARRAY_IBLOCK_ID, /* Metadata client ID */ - "Extensible Array Index Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_IBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_iblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_iblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_iblock_serialize, /* 'serialize' callback */ - H5EA__cache_iblock_notify, /* 'notify' callback */ - H5EA__cache_iblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_EARRAY_IBLOCK_ID, /* Metadata client ID */ + "Extensible Array Index Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_IBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_iblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_iblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_iblock_serialize, /* 'serialize' callback */ + H5EA__cache_iblock_notify, /* 'notify' callback */ + H5EA__cache_iblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5EA super block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_SBLOCK[1] = {{ - H5AC_EARRAY_SBLOCK_ID, /* Metadata client ID */ - "Extensible Array Super Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_SBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_sblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_sblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_sblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_sblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_sblock_serialize, /* 'serialize' callback */ - H5EA__cache_sblock_notify, /* 'notify' callback */ - H5EA__cache_sblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_EARRAY_SBLOCK_ID, /* Metadata client ID */ + "Extensible Array Super Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_SBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_sblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_sblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_sblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_sblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_sblock_serialize, /* 'serialize' callback */ + H5EA__cache_sblock_notify, /* 'notify' callback */ + H5EA__cache_sblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5EA data block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_DBLOCK[1] = {{ - H5AC_EARRAY_DBLOCK_ID, /* Metadata client ID */ - "Extensible Array Data Block", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5EA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_dblock_deserialize, /* 'deserialize' callback */ - H5EA__cache_dblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_dblock_serialize, /* 'serialize' callback */ - H5EA__cache_dblock_notify, /* 'notify' callback */ - H5EA__cache_dblock_free_icr, /* 'free_icr' callback */ - H5EA__cache_dblock_fsf_size, /* 'fsf_size' callback */ + H5AC_EARRAY_DBLOCK_ID, /* Metadata client ID */ + "Extensible Array Data Block", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5EA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_dblock_deserialize, /* 'deserialize' callback */ + H5EA__cache_dblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_dblock_serialize, /* 'serialize' callback */ + H5EA__cache_dblock_notify, /* 'notify' callback */ + H5EA__cache_dblock_free_icr, /* 'free_icr' callback */ + H5EA__cache_dblock_fsf_size, /* 'fsf_size' callback */ }}; /* H5EA data block page inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ - H5AC_EARRAY_DBLK_PAGE_ID, /* Metadata client ID */ - "Extensible Array Data Block Page", /* Metadata client name (for debugging) */ - H5FD_MEM_EARRAY_DBLK_PAGE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_EARRAY_DBLK_PAGE_ID, /* Metadata client ID */ + "Extensible Array Data Block Page", /* Metadata client name (for debugging) */ + H5FD_MEM_EARRAY_DBLK_PAGE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5EA__cache_dblk_page_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5EA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ - H5EA__cache_dblk_page_deserialize, /* 'deserialize' callback */ - H5EA__cache_dblk_page_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5EA__cache_dblk_page_serialize, /* 'serialize' callback */ - H5EA__cache_dblk_page_notify, /* 'notify' callback */ - H5EA__cache_dblk_page_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5EA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ + H5EA__cache_dblk_page_deserialize, /* 'deserialize' callback */ + H5EA__cache_dblk_page_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5EA__cache_dblk_page_serialize, /* 'serialize' callback */ + H5EA__cache_dblk_page_notify, /* 'notify' callback */ + H5EA__cache_dblk_page_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_get_initial_load_size * @@ -243,9 +221,8 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; /* User data for callback */ @@ -258,9 +235,8 @@ H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* 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() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_verify_chksum * @@ -274,14 +250,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -289,12 +264,11 @@ H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_deserialize * @@ -308,17 +282,16 @@ 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)) +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 */ - H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ - H5EA_hdr_t *hdr = NULL; /* Extensible array info */ + H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ + 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Check arguments */ HDassert(image); @@ -327,37 +300,40 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert(H5F_addr_defined(udata->addr)); /* 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") + if (NULL == (hdr = H5EA__hdr_alloc(udata->f))) + H5E_THROW(H5E_CANTALLOC, "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)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") + if (HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5EA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array header version") + if (*image++ != H5EA_HDR_VERSION) + H5E_THROW(H5E_VERSION, "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") + if (id >= H5EA_NUM_CLS_ID) + H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") hdr->cparam.cls = H5EA_client_class_g[id]; /* General array creation/configuration information */ - hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ - hdr->cparam.max_nelmts_bits = *image++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - hdr->cparam.idx_blk_elmts = *image++; /* # of elements to store in index block */ - hdr->cparam.data_blk_min_elmts = *image++; /* Min. # of elements per data block */ - hdr->cparam.sup_blk_min_data_ptrs = *image++; /* Min. # of data block pointers for a super block */ - hdr->cparam.max_dblk_page_nelmts_bits = *image++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ + hdr->cparam.max_nelmts_bits = + *image++; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ + hdr->cparam.idx_blk_elmts = *image++; /* # of elements to store in index block */ + hdr->cparam.data_blk_min_elmts = *image++; /* Min. # of elements per data block */ + hdr->cparam.sup_blk_min_data_ptrs = *image++; /* Min. # of data block pointers for a super block */ + hdr->cparam.max_dblk_page_nelmts_bits = + *image++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of + elements in data block page */ /* Array statistics */ - hdr->stats.computed.hdr_size = len; /* Size of header in file */ + hdr->stats.computed.hdr_size = len; /* Size of header in file */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.super_blk_size); /* Size of super blocks created */ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.ndata_blks); /* Number of data blocks created */ @@ -369,15 +345,15 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, H5F_addr_decode(udata->f, &image, &hdr->idx_blk_addr); /* Address of index block */ /* Index block statistics */ - if(H5F_addr_defined(hdr->idx_blk_addr)) { - H5EA_iblock_t iblock; /* Fake index block for computing size */ + if (H5F_addr_defined(hdr->idx_blk_addr)) { + H5EA_iblock_t iblock; /* Fake index block for computing size */ /* Set index block count for file */ hdr->stats.computed.nindex_blks = 1; /* Set up fake index block for computing size on disk */ - iblock.hdr = hdr; - iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock.hdr = hdr; + iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock.ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; @@ -385,9 +361,9 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hdr->stats.computed.index_blk_size = H5EA_IBLOCK_SIZE(&iblock); } /* end if */ else { - hdr->stats.computed.nindex_blks = 0; /* Number of index blocks in file */ - hdr->stats.computed.index_blk_size = 0; /* Size of index blocks in file */ - } /* end else */ + hdr->stats.computed.nindex_blks = 0; /* Number of index blocks in file */ + hdr->stats.computed.index_blk_size = 0; /* Size of index blocks in file */ + } /* end else */ /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -402,23 +378,22 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == len); /* Finish initializing extensible array header */ - if(H5EA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + if (H5EA__hdr_init(hdr, udata->ctx_udata) < 0) + H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(hdr && H5EA__hdr_dest(hdr) < 0) + if (!ret_value) + if (hdr && H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") -END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_image_len * @@ -431,12 +406,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ + const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(hdr); @@ -445,9 +419,8 @@ H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_serialize * @@ -460,15 +433,13 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -487,12 +458,15 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ - *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ - *image++ = hdr->cparam.max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - *image++ = hdr->cparam.idx_blk_elmts; /* # of elements to store in index block */ - *image++ = hdr->cparam.data_blk_min_elmts; /* Min. # of elements per data block */ - *image++ = hdr->cparam.sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - *image++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ + *image++ = hdr->cparam.max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to + store max. # of elements */ + *image++ = hdr->cparam.idx_blk_elmts; /* # of elements to store in index block */ + *image++ = hdr->cparam.data_blk_min_elmts; /* Min. # of elements per data block */ + *image++ = hdr->cparam.sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + *image++ = + hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ /* Array statistics */ H5F_ENCODE_LENGTH(f, image, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ @@ -503,7 +477,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le H5F_ENCODE_LENGTH(f, image, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ - H5F_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ + H5F_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -514,9 +488,8 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_notify * @@ -529,70 +502,71 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { + if (hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; - case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* 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") + /* 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") hdr->parent = NULL; - } /* end if */ + } /* 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") + 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") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ - break; + break; default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_free_icr * @@ -606,22 +580,19 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_hdr_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_hdr_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array header */ - if(H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) + if (H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array header") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_get_initial_load_size * @@ -634,13 +605,12 @@ 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)) +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 */ - H5EA_iblock_t iblock; /* Fake index block for computing size */ + H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ + H5EA_iblock_t iblock; /* Fake index block for computing size */ /* Check arguments */ HDassert(hdr); @@ -648,17 +618,16 @@ H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set up fake index block for computing size on disk */ HDmemset(&iblock, 0, sizeof(iblock)); - iblock.hdr = (H5EA_hdr_t *)hdr; /* Casting away 'const' OK - QAK */ - iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock.hdr = (H5EA_hdr_t *)hdr; /* Casting away 'const' OK - QAK */ + iblock.nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock.ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; /* Set the image length size */ *image_len = (size_t)H5EA_IBLOCK_SIZE(&iblock); -END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_verify_chksum * @@ -672,14 +641,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -687,12 +655,11 @@ H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_deserialize * @@ -706,69 +673,69 @@ 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)) +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 */ - H5EA_iblock_t *iblock = NULL; /* Index block info */ - 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 */ + H5EA_iblock_t *iblock = NULL; /* Index block info */ + 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 */ /* Check arguments */ HDassert(image); HDassert(hdr); /* 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") + if (NULL == (iblock = H5EA__iblock_alloc(hdr))) + H5E_THROW(H5E_CANTALLOC, "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)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") + if (HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + H5E_THROW(H5E_BADVALUE, "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") + if (*image++ != H5EA_IBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "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") + if (*image++ != (uint8_t)hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "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") + if (H5F_addr_ne(arr_addr, hdr->addr)) + H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") /* Internal information */ /* Decode elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) { + if (hdr->cparam.idx_blk_elmts > 0) { /* 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) + 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") image += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size); } /* end if */ /* Decode data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { + if (iblock->ndblk_addrs > 0) { /* Decode addresses of data blocks in index block */ - for(u = 0; u < iblock->ndblk_addrs; u++) + for (u = 0; u < iblock->ndblk_addrs; u++) H5F_addr_decode(hdr->f, &image, &iblock->dblk_addrs[u]); } /* end if */ /* Decode super block addresses in index block */ - if(iblock->nsblk_addrs > 0) { + if (iblock->nsblk_addrs > 0) { /* Decode addresses of super blocks in index block */ - for(u = 0; u < iblock->nsblk_addrs; u++) + for (u = 0; u < iblock->nsblk_addrs; u++) H5F_addr_decode(hdr->f, &image, &iblock->sblk_addrs[u]); } /* end if */ @@ -790,16 +757,15 @@ H5EA__cache_iblock_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = iblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(iblock && H5EA__iblock_dest(iblock) < 0) + if (!ret_value) + if (iblock && H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") -END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_image_len * @@ -812,12 +778,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ + const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(iblock); @@ -826,9 +791,8 @@ H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = iblock->size; -END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_serialize * @@ -841,15 +805,14 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -876,28 +839,29 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Encode elements in index block */ - if(iblock->hdr->cparam.idx_blk_elmts > 0) { + if (iblock->hdr->cparam.idx_blk_elmts > 0) { /* 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) + 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") image += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size); } /* end if */ /* Encode data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->ndblk_addrs > 0) { + size_t u; /* Local index variable */ /* Encode addresses of data blocks in index block */ - for(u = 0; u < iblock->ndblk_addrs; u++) + for (u = 0; u < iblock->ndblk_addrs; u++) H5F_addr_encode(f, &image, iblock->dblk_addrs[u]); } /* end if */ /* Encode data block addresses in index block */ - if(iblock->nsblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->nsblk_addrs > 0) { + size_t u; /* Local index variable */ /* Encode addresses of super blocks in index block */ - for(u = 0; u < iblock->nsblk_addrs; u++) + for (u = 0; u < iblock->nsblk_addrs; u++) H5F_addr_encode(f, &image, iblock->sblk_addrs[u]); } /* end if */ @@ -910,11 +874,10 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_notify * @@ -927,23 +890,24 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(iblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: 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) + 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) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -958,13 +922,16 @@ H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) 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) + 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) /* 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") + 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") iblock->top_proxy = NULL; } /* end if */ break; @@ -972,16 +939,15 @@ H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_free_icr * @@ -995,22 +961,19 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_iblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_iblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array index block */ - if(H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) + if (H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_get_initial_load_size * @@ -1023,13 +986,12 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ - H5EA_sblock_t sblock; /* Fake super block for computing size */ + H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ + H5EA_sblock_t sblock; /* Fake super block for computing size */ /* Check arguments */ HDassert(udata); @@ -1041,12 +1003,12 @@ H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set up fake super block for computing size on disk */ /* (Note: extracted from H5EA__sblock_alloc) */ HDmemset(&sblock, 0, sizeof(sblock)); - sblock.hdr = udata->hdr; - sblock.ndblks = udata->hdr->sblk_info[udata->sblk_idx].ndblks; + sblock.hdr = udata->hdr; + sblock.ndblks = udata->hdr->sblk_info[udata->sblk_idx].ndblks; sblock.dblk_nelmts = udata->hdr->sblk_info[udata->sblk_idx].dblk_nelmts; /* Check if # of elements in data blocks requires paging */ - if(sblock.dblk_nelmts > udata->hdr->dblk_page_nelmts) { + if (sblock.dblk_nelmts > udata->hdr->dblk_page_nelmts) { /* Compute # of pages in each data block from this super block */ sblock.dblk_npages = sblock.dblk_nelmts / udata->hdr->dblk_page_nelmts; @@ -1064,9 +1026,8 @@ H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Set the image length size */ *image_len = (size_t)H5EA_SBLOCK_SIZE(&sblock); -END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_verify_chksum * @@ -1080,14 +1041,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -1095,12 +1055,11 @@ H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_deserialize * @@ -1114,18 +1073,17 @@ 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)) +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 */ - 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 */ - 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 */ + 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 */ + 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 */ /* Sanity check */ HDassert(udata); @@ -1135,29 +1093,29 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->sblk_addr)); /* 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") + 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") /* 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)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") + if (HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + H5E_THROW(H5E_BADVALUE, "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") + if (*image++ != H5EA_SBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "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") + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "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") + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) + H5E_THROW(H5E_BADVALUE, "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); @@ -1165,8 +1123,9 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, /* Internal information */ /* Check for 'page init' bitmasks for this super block */ - if(sblock->dblk_npages > 0) { - size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ + if (sblock->dblk_npages > 0) { + size_t tot_page_init_size = + sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ /* Retrieve the 'page init' bitmasks */ H5MM_memcpy(sblock->page_init, image, tot_page_init_size); @@ -1174,7 +1133,7 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, } /* end if */ /* Decode data block addresses */ - for(u = 0; u < sblock->ndblks; u++) + for (u = 0; u < sblock->ndblks; u++) H5F_addr_decode(udata->hdr->f, &image, &sblock->dblk_addrs[u]); /* Sanity check */ @@ -1195,16 +1154,15 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = sblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(sblock && H5EA__sblock_dest(sblock) < 0) + if (!ret_value) + if (sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") -END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_image_len * @@ -1217,12 +1175,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ + const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(sblock); @@ -1231,9 +1188,8 @@ H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = sblock->size; -END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_serialize * @@ -1246,16 +1202,15 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - size_t u; /* Local index variable */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + size_t u; /* Local index variable */ /* check arguments */ HDassert(f); @@ -1283,8 +1238,9 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Check for 'page init' bitmasks for this super block */ - if(sblock->dblk_npages > 0) { - size_t tot_page_init_size = sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ + if (sblock->dblk_npages > 0) { + size_t tot_page_init_size = + sblock->ndblks * sblock->dblk_page_init_size; /* Compute total size of 'page init' buffer */ /* Store the 'page init' bitmasks */ H5MM_memcpy(image, sblock->page_init, tot_page_init_size); @@ -1292,7 +1248,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED } /* end if */ /* Encode addresses of data blocks in super block */ - for(u = 0; u < sblock->ndblks; u++) + for (u = 0; u < sblock->ndblks; u++) H5F_addr_encode(f, &image, sblock->dblk_addrs[u]); /* Compute metadata checksum */ @@ -1304,9 +1260,8 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_notify * @@ -1319,50 +1274,62 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(sblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: 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, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between super block and index block, address = %llu", + (unsigned long long)sblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* 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, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + if (sblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and header, address = %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; } /* end if */ break; 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, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and index block, address = %llu", + (unsigned long long)sblock->addr) /* 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, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) + if (sblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between super block and header, address = %llu", + (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; } /* end if */ /* 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") + 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") sblock->top_proxy = NULL; } /* end if */ break; @@ -1379,16 +1346,15 @@ H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_free_icr * @@ -1402,22 +1368,19 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_sblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_sblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array super block */ - if(H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) + if (H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_get_initial_load_size * @@ -1430,13 +1393,12 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ - H5EA_dblock_t dblock; /* Fake data block for computing size */ + H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ + H5EA_dblock_t dblock; /* Fake data block for computing size */ /* Check arguments */ HDassert(udata); @@ -1457,24 +1419,23 @@ H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) * before we invoke either H5EA_DBLOCK_PREFIX_SIZE() or * H5EA_DBLOCK_SIZE(). */ - dblock.hdr = udata->hdr; + dblock.hdr = udata->hdr; dblock.nelmts = udata->nelmts; - if(udata->nelmts > udata->hdr->dblk_page_nelmts) { + if (udata->nelmts > udata->hdr->dblk_page_nelmts) { /* Set the # of pages in the direct block */ dblock.npages = udata->nelmts / udata->hdr->dblk_page_nelmts; - HDassert(udata->nelmts==(dblock.npages * udata->hdr->dblk_page_nelmts)); + HDassert(udata->nelmts == (dblock.npages * udata->hdr->dblk_page_nelmts)); } /* end if */ /* Set the image length size */ - if(!dblock.npages) + if (!dblock.npages) *image_len = H5EA_DBLOCK_SIZE(&dblock); else *image_len = H5EA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_verify_chksum * @@ -1488,14 +1449,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -1503,12 +1463,11 @@ H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_deserialize * @@ -1522,17 +1481,16 @@ 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)) +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 */ - 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ /* Check arguments */ HDassert(udata); @@ -1542,8 +1500,8 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(H5F_addr_defined(udata->dblk_addr)); /* 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") + if (NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") HDassert(((!dblock->npages) && (len == H5EA_DBLOCK_SIZE(dblock))) || (len == H5EA_DBLOCK_PREFIX_SIZE(dblock))); @@ -1552,22 +1510,22 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED dblock->addr = udata->dblk_addr; /* Magic number */ - if(HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") + if (HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) + H5E_THROW(H5E_BADVALUE, "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") + if (*image++ != H5EA_DBLOCK_VERSION) + H5E_THROW(H5E_VERSION, "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") + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) + H5E_THROW(H5E_BADTYPE, "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") + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) + H5E_THROW(H5E_BADVALUE, "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); @@ -1575,10 +1533,10 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Internal information */ /* Only decode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* 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) + 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") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1602,16 +1560,15 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblock && H5EA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") -END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_image_len * @@ -1624,26 +1581,24 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); HDassert(image_len); /* Set the image length size */ - if(!dblock->npages) + if (!dblock->npages) *image_len = dblock->size; else *image_len = (size_t)H5EA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_serialize * @@ -1656,15 +1611,14 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -1692,11 +1646,11 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Internal information */ /* Only encode elements if the data block is not paged */ - if(!dblock->npages) { + if (!dblock->npages) { /* Encode elements in data block */ /* 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) + 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") image += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1710,11 +1664,10 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_notify * @@ -1727,50 +1680,60 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: 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) + 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) 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, "unable to destroy flush dependency between direct block and header, address = %llu", (unsigned long long)dblock->addr) + if (dblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between direct block and header, address = %llu", + (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; } /* end if */ break; 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) + 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) /* 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, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) + if (dblock->has_hdr_depend) { + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block and header, address = %llu", + (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; } /* end if */ /* 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") + 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") dblock->top_proxy = NULL; } /* end if */ break; @@ -1787,16 +1750,15 @@ H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_free_icr * @@ -1810,22 +1772,19 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5EA__cache_dblock_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblock_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array data block */ - if(H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) + if (H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_fsf_size * @@ -1855,12 +1814,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) /* Local variables */ - const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); @@ -1870,9 +1828,8 @@ H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ +END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_get_initial_load_size * @@ -1885,12 +1842,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ + H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ /* Check arguments */ HDassert(udata); @@ -1900,9 +1856,8 @@ H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* 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() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_verify_chksum * @@ -1916,14 +1871,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -1931,12 +1885,11 @@ H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_deserialize * @@ -1950,16 +1903,16 @@ 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)) +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 */ - 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 */ + 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 */ /* Sanity check */ HDassert(udata); @@ -1968,8 +1921,8 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->dblk_page_addr)); /* 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") + 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") /* Set the extensible array data block page's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1978,7 +1931,8 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, /* 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->hdr->dblk_page_nelmts, udata->hdr->cb_ctx) < 0) + 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") image += (udata->hdr->dblk_page_nelmts * udata->hdr->cparam.raw_elmt_size); @@ -2000,16 +1954,15 @@ H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) + 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() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_image_len * @@ -2022,12 +1975,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblk_page); @@ -2036,9 +1988,8 @@ H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_serialize * @@ -2051,15 +2002,14 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(f); @@ -2072,7 +2022,8 @@ H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Encode elements in data block page */ /* 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) + 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") image += (dblk_page->hdr->dblk_page_nelmts * dblk_page->hdr->cparam.raw_elmt_size); @@ -2085,11 +2036,10 @@ H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_notify * @@ -2102,50 +2052,63 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(dblk_page); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: 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, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + if (H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between data block page and parent, address = %llu", + (unsigned long long)dblk_page->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* 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) + 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) dblk_page->has_hdr_depend = FALSE; } /* end if */ break; 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, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW( + H5E_CANTUNDEPEND, + "unable to destroy flush dependency between data block page and parent, address = %llu", + (unsigned long long)dblk_page->addr) /* 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) + 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) 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") + 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") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -2162,16 +2125,15 @@ H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ - /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_free_icr * @@ -2185,18 +2147,15 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblk_page_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array data block page */ - if(H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) + if (H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array data block page") -CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ + CATCH +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index e5b68be3715..72d2f38cb04 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__hdr_debug * @@ -90,14 +79,13 @@ * *------------------------------------------------------------------------- */ -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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -109,70 +97,54 @@ H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(cls); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + if (NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Header size:", - hdr->size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Raw Element Size:", - (unsigned)hdr->cparam.raw_elmt_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Native Element Size (on this platform):", - hdr->cparam.cls->nat_elmt_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in array):", - (unsigned)hdr->cparam.max_nelmts_bits); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size:", hdr->size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of elements in index block:", - (unsigned)hdr->cparam.idx_blk_elmts); + "Raw Element Size:", (unsigned)hdr->cparam.raw_elmt_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "Native Element Size (on this platform):", hdr->cparam.cls->nat_elmt_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of elements per data block:", - (unsigned)hdr->cparam.data_blk_min_elmts); + "Log2(Max. # of elements in array):", (unsigned)hdr->cparam.max_nelmts_bits); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of data block pointers for a super block:", - (unsigned)hdr->cparam.sup_blk_min_data_ptrs); + "# of elements in index block:", (unsigned)hdr->cparam.idx_blk_elmts); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in data block page):", - (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Highest element index stored (+1):", - hdr->stats.stored.max_idx_set); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of super blocks created:", - hdr->stats.stored.nsuper_blks); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of data blocks created:", - hdr->stats.stored.ndata_blks); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements 'realized':", - hdr->stats.stored.nelmts); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Index Block Address:", - hdr->idx_blk_addr); - -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + "Min. # of elements per data block:", (unsigned)hdr->cparam.data_blk_min_elmts); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Min. # of data block pointers for a super block:", + (unsigned)hdr->cparam.sup_blk_min_data_ptrs); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Log2(Max. # of elements in data block page):", + (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Highest element index stored (+1):", hdr->stats.stored.max_idx_set); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of super blocks created:", hdr->stats.stored.nsuper_blks); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of data blocks created:", hdr->stats.stored.ndata_blks); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of elements 'realized':", hdr->stats.stored.nelmts); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Index Block Address:", hdr->idx_blk_addr); + + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_debug() */ +END_FUNC(PKG) /* end H5EA__hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_debug * @@ -185,15 +157,14 @@ 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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -206,96 +177,89 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + 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") /* 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) + 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) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Index Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Index Block size:", - iblock->size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in index block:", - iblock->ndblk_addrs); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of super block addresses in index block:", - iblock->nsblk_addrs); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Index Block size:", iblock->size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "# of data block addresses in index block:", iblock->ndblk_addrs); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "# of super block addresses in index block:", iblock->nsblk_addrs); /* Check if there are any elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) { - unsigned u; /* Local index variable */ + if (hdr->cparam.idx_blk_elmts > 0) { + unsigned u; /* Local index variable */ /* Print the elements in the index block */ HDfprintf(stream, "%*sElements in Index Block:\n", indent, ""); - for(u = 0; u < hdr->cparam.idx_blk_elmts; u++) { + for (u = 0; u < hdr->cparam.idx_blk_elmts; u++) { /* Call the class's 'debug' callback */ - 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) + 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") } /* end for */ - } /* end if */ + } /* end if */ /* Check if there are any data block addresses in index block */ - if(iblock->ndblk_addrs > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (iblock->ndblk_addrs > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the data block addresses in the index block */ HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, ""); - for(u = 0; u < iblock->ndblk_addrs; u++) { + for (u = 0; u < iblock->ndblk_addrs; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - iblock->dblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + iblock->dblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Check if there are any super block addresses in index block */ - if(iblock->nsblk_addrs > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (iblock->nsblk_addrs > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the super block addresses in the index block */ HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, ""); - for(u = 0; u < iblock->nsblk_addrs; u++) { + for (u = 0; u < iblock->nsblk_addrs; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - iblock->sblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + iblock->sblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) + if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__iblock_debug() */ +END_FUNC(PKG) /* end H5EA__iblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_debug * @@ -308,15 +272,14 @@ 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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -329,63 +292,58 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + 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") /* 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) + 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) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Super Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Super Block size:", - sblock->size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in super block:", - sblock->ndblks); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of elements in data blocks from this super block:", - sblock->dblk_nelmts); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Super Block size:", sblock->size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "# of data block addresses in super block:", sblock->ndblks); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "# of elements in data blocks from this super block:", sblock->dblk_nelmts); /* Check if there are any data block addresses in super block */ - if(sblock->ndblks > 0) { - char temp_str[128]; /* Temporary string, for formatting */ + if (sblock->ndblks > 0) { + char temp_str[128]; /* Temporary string, for formatting */ unsigned u; /* Local index variable */ /* Print the data block addresses in the super block */ HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, ""); - for(u = 0; u < sblock->ndblks; u++) { + for (u = 0; u < sblock->ndblks; u++) { /* Print address */ HDsprintf(temp_str, "Address #%u:", u); - HDfprintf(stream, "%*s%-*s %a\n", (indent + 3), "", MAX(0, (fwidth - 3)), - temp_str, - sblock->dblk_addrs[u]); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, + sblock->dblk_addrs[u]); } /* end for */ - } /* end if */ + } /* end if */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) + if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__sblock_debug() */ +END_FUNC(PKG) /* end H5EA__sblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_debug * @@ -398,16 +356,16 @@ 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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -421,48 +379,43 @@ H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(dblk_nelmts > 0); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + 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") /* 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 = %llu", (unsigned long long)addr) + 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) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array data Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data Block size:", - dblock->size); - + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Data Block size:", dblock->size); /* Print the elements in the index block */ HDfprintf(stream, "%*sElements:\n", indent, ""); - for(u = 0; u < dblk_nelmts; u++) { + for (u = 0; u < dblk_nelmts; u++) { /* 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) + 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") } /* end for */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") - if(dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") - if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__dblock_debug() */ - +END_FUNC(PKG) /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index ee5c90412f2..b42599c420a 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,54 +26,45 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,8 +72,6 @@ /* Declare a free list to manage the H5EA_dblk_page_t struct */ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); - - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_alloc * @@ -95,43 +84,41 @@ 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)) +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 *dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ /* 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") + if (NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) + H5E_THROW(H5E_CANTALLOC, "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") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ dblk_page->parent = parent; /* Allocate buffer for elements in data block page */ - if(NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) + 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") /* Set the return value */ ret_value = dblk_page; -CATCH - if(!ret_value) - if(dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) + CATCH + 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(PKG) /* end H5EA__dblk_page_alloc() */ +END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_create * @@ -144,57 +131,55 @@ 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)) +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 */ - H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* 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") + if (NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; dblk_page->size = H5EA_DBLK_PAGE_SIZE(hdr); /* 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) + 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") /* 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") + 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") 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) + 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") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ -CATCH - if(ret_value < 0) - if(dblk_page) { + CATCH + if (ret_value < 0) + if (dblk_page) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblk_page) < 0) + if (inserted) + if (H5AC_remove_entry(dblk_page) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block page from cache") /* Destroy data block page */ - if(H5EA__dblk_page_dest(dblk_page) < 0) + if (H5EA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_create() */ +END_FUNC(PKG) /* end H5EA__dblk_page_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_protect * @@ -208,14 +193,13 @@ 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)) +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_cache_ud_t udata; /* Information needed for loading data block page */ + 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 */ /* Sanity check */ HDassert(hdr); @@ -225,18 +209,20 @@ H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; + udata.hdr = hdr; + udata.parent = parent; udata.dblk_page_addr = dblk_page_addr; /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblk_page->top_proxy) { + 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) + 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") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ @@ -244,17 +230,19 @@ H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + 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) + 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) } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ +END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_unprotect * @@ -268,9 +256,8 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) /* Local variables */ @@ -278,14 +265,14 @@ H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ +END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_dest * @@ -298,26 +285,24 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) /* Sanity check */ HDassert(dblk_page); HDassert(!dblk_page->has_hdr_depend); /* Check if header field has been initialized */ - if(dblk_page->hdr) { + if (dblk_page->hdr) { /* Check if buffer for data block page elements has been initialized */ - if(dblk_page->elmts) { + 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) + 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") dblk_page->elmts = NULL; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(dblk_page->hdr) < 0) + if (H5EA__hdr_decr(dblk_page->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -328,7 +313,6 @@ H5EA__dblk_page_dest(H5EA_dblk_page_t *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() */ + CATCH +END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index d540a3c718b..45696c7c3b0 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -82,8 +73,6 @@ /* Declare a free list to manage the H5EA_dblock_t struct */ H5FL_DEFINE_STATIC(H5EA_dblock_t); - - /*------------------------------------------------------------------------- * Function: H5EA__dblock_alloc * @@ -96,12 +85,11 @@ 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)) +BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, + H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ /* Check arguments */ HDassert(hdr); @@ -109,12 +97,12 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) HDassert(nelmts > 0); /* 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") + if (NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) + H5E_THROW(H5E_CANTALLOC, "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") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -122,28 +110,27 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) dblock->nelmts = nelmts; /* Check if the data block is not going to be paged */ - if(nelmts > hdr->dblk_page_nelmts) { + if (nelmts > hdr->dblk_page_nelmts) { /* Set the # of pages in the direct block */ dblock->npages = nelmts / hdr->dblk_page_nelmts; HDassert(nelmts == (dblock->npages * hdr->dblk_page_nelmts)); } /* end if */ else { /* Allocate buffer for elements in data block */ - if(NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) + if (NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; -CATCH - if(!ret_value) - if(dblock && H5EA__dblock_dest(dblock) < 0) + CATCH + if (!ret_value) + if (dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_alloc() */ +END_FUNC(PKG) /* end H5EA__dblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_create * @@ -156,15 +143,14 @@ 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)) +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)) /* 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 */ + 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 */ /* Sanity check */ HDassert(hdr); @@ -172,8 +158,8 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, HDassert(nelmts > 0); /* 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") + if (NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Set size of data block on disk */ dblock->size = H5EA_DBLOCK_SIZE(dblock); @@ -182,24 +168,24 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, dblock->block_off = dblk_off; /* 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") + 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") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ - if(!dblock->npages) + if (!dblock->npages) /* Clear any elements in data block to fill value */ - if((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) + 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") /* 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") + 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") 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) + 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") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -217,26 +203,26 @@ H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, /* Set address of data block to return */ ret_value = dblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(dblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (dblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblock) < 0) + if (inserted) + if (H5AC_remove_entry(dblock) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy data block */ - if(H5EA__dblock_dest(dblock) < 0) + if (H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_create() */ +END_FUNC(PKG) /* end H5EA__dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_sblk_idx * @@ -250,12 +236,10 @@ 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)) +BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) /* Local variables */ - unsigned sblk_idx; /* Which superblock does this index fall in? */ + unsigned sblk_idx; /* Which superblock does this index fall in? */ /* Sanity check */ HDassert(hdr); @@ -265,15 +249,14 @@ H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) idx -= hdr->cparam.idx_blk_elmts; /* Determine the superblock information for the index */ - H5_CHECK_OVERFLOW(idx, /*From:*/hsize_t, /*To:*/uint64_t); + 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() */ +END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_protect * @@ -286,14 +269,13 @@ 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)) +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_cache_ud_t udata; /* Information needed for loading data block */ + H5EA_dblock_t * dblock; /* Extensible array data block */ + H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ /* Sanity check */ HDassert(hdr); @@ -304,19 +286,21 @@ H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; - udata.nelmts = dblk_nelmts; + udata.hdr = hdr; + udata.parent = parent; + udata.nelmts = dblk_nelmts; udata.dblk_addr = dblk_addr; /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblock->top_proxy) { + 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) + 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") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -324,18 +308,19 @@ H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + 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) + 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 */ -END_FUNC(PKG) /* end H5EA__dblock_protect() */ +END_FUNC(PKG) /* end H5EA__dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_unprotect * @@ -348,9 +333,8 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) /* Local variables */ @@ -358,14 +342,14 @@ H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) 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) + 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) -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_delete * @@ -378,13 +362,11 @@ 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)) +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)) /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ /* Sanity check */ HDassert(hdr); @@ -393,41 +375,41 @@ H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, HDassert(dblk_nelmts > 0); /* 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) + 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) /* Check if this is a paged data block */ - if(dblk_nelmts > hdr->dblk_page_nelmts) { - size_t npages = dblk_nelmts / hdr->dblk_page_nelmts; /* Number of pages in data block */ - haddr_t dblk_page_addr; /* Address of each data block page */ - size_t dblk_page_size; /* Size of each data block page */ - size_t u; /* Local index variable */ + if (dblk_nelmts > hdr->dblk_page_nelmts) { + size_t npages = dblk_nelmts / hdr->dblk_page_nelmts; /* Number of pages in data block */ + haddr_t dblk_page_addr; /* Address of each data block page */ + size_t dblk_page_size; /* Size of each data block page */ + size_t u; /* Local index variable */ /* Set up initial state */ dblk_page_addr = dblk_addr + H5EA_DBLOCK_PREFIX_SIZE(dblock); - dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) - + H5EA_SIZEOF_CHKSUM; + dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; /* Iterate over pages in data block */ - for(u = 0; u < npages; u++) { + for (u = 0; u < npages; u++) { /* 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) + 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") /* Advance to next page address */ dblk_page_addr += dblk_page_size; } /* end for */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* 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) + 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") -END_FUNC(PKG) /* end H5EA__dblock_delete() */ +END_FUNC(PKG) /* end H5EA__dblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__dblock_dest * @@ -440,28 +422,26 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__dblock_dest(H5EA_dblock_t *dblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); HDassert(!dblock->has_hdr_depend); /* Check if shared header field has been initialized */ - if(dblock->hdr) { + if (dblock->hdr) { /* Check if we've got elements in the data block */ - if(dblock->elmts && !dblock->npages) { + if (dblock->elmts && !dblock->npages) { /* Free buffer for data block elements */ HDassert(dblock->nelmts > 0); - if(H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 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") - dblock->elmts = NULL; + dblock->elmts = NULL; dblock->nelmts = 0; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(dblock->hdr) < 0) + if (H5EA__hdr_decr(dblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -472,7 +452,6 @@ H5EA__dblock_dest(H5EA_dblock_t *dblock)) /* Free the data block itself */ dblock = H5FL_FREE(H5EA_dblock_t, dblock); -CATCH - -END_FUNC(PKG) /* end H5EA__dblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__dblock_dest() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 8b4d5f7ae2a..7f142af3684 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,24 +26,21 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -55,9 +52,7 @@ #endif /* NDEBUG */ /* # of elements in a data block for a particular super block */ -#define H5EA_SBLK_DBLK_NELMTS(s, m) \ - (size_t)H5_EXP2(((s) + 1) / 2) * (m) - +#define H5EA_SBLK_DBLK_NELMTS(s, m) (size_t) H5_EXP2(((s) + 1) / 2) * (m) /******************/ /* Local Typedefs */ @@ -66,27 +61,22 @@ /* Alias for pointer to factory, for use when allocating sequences of them */ typedef H5FL_fac_head_t *H5FL_fac_head_ptr_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -100,8 +90,6 @@ H5FL_SEQ_DEFINE_STATIC(H5FL_fac_head_ptr_t); /* Declare a free list to manage the H5EA_sblk_info_t sequence information */ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); - - /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc * @@ -114,40 +102,37 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_hdr_t *, NULL, NULL, -H5EA__hdr_alloc(H5F_t *f)) +BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; /* Set the internal parameters for the array */ - hdr->f = f; - hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + hdr->f = f; + hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); /* Set the return value */ ret_value = hdr; -CATCH - if(!ret_value) - if(hdr && H5EA__hdr_dest(hdr) < 0) + CATCH + if (!ret_value) + if (hdr && H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_alloc() */ +END_FUNC(PKG) /* end H5EA__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_init * @@ -183,14 +168,12 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) /* Local variables */ - 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 */ + 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 */ /* Sanity check */ HDassert(hdr); @@ -199,22 +182,22 @@ H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) HDassert(hdr->cparam.sup_blk_min_data_ptrs); /* Compute general information */ - hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5VM_log2_of2(hdr->cparam.data_blk_min_elmts)); + hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5VM_log2_of2(hdr->cparam.data_blk_min_elmts)); hdr->dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; - hdr->arr_off_size = (unsigned char)H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits); + hdr->arr_off_size = (unsigned char)H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits); /* Allocate information for each super block */ - if(NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) + 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") /* Compute information about each super block */ - start_idx = 0; + start_idx = 0; start_dblk = 0; - for(u = 0; u < hdr->nsblks; u++) { - hdr->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); + for (u = 0; u < hdr->nsblks; u++) { + hdr->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2); hdr->sblk_info[u].dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(u, hdr->cparam.data_blk_min_elmts); - hdr->sblk_info[u].start_idx = start_idx; - hdr->sblk_info[u].start_dblk = start_dblk; + hdr->sblk_info[u].start_idx = start_idx; + hdr->sblk_info[u].start_dblk = start_dblk; /* Advance starting indices for next super block */ start_idx += (hsize_t)hdr->sblk_info[u].ndblks * (hsize_t)hdr->sblk_info[u].dblk_nelmts; @@ -225,16 +208,15 @@ H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE_HDR(hdr); /* 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))) + 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 + CATCH -END_FUNC(PKG) /* end H5EA__hdr_init() */ +END_FUNC(PKG) /* end H5EA__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc_elmts * @@ -247,60 +229,60 @@ 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)) +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 */ - unsigned idx; /* Index of element buffer factory in header */ + void * elmts = NULL; /* Element buffer allocated */ + unsigned idx; /* Index of element buffer factory in header */ /* Check arguments */ HDassert(hdr); HDassert(nelmts > 0); /* Compute the index of the element buffer factory */ - H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t); + H5_CHECK_OVERFLOW(nelmts, /*From:*/ size_t, /*To:*/ uint32_t); idx = H5VM_log2_of2((uint32_t)nelmts) - H5VM_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts); /* Check for needing to increase size of array of factories */ - if(idx >= hdr->elmt_fac.nalloc) { - H5FL_fac_head_t **new_fac; /* New array of element factories */ - size_t new_nalloc = MAX3(1, (idx + 1), (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */ + if (idx >= hdr->elmt_fac.nalloc) { + H5FL_fac_head_t **new_fac; /* New array of element factories */ + size_t new_nalloc = + MAX3(1, (idx + 1), (2 * hdr->elmt_fac.nalloc)); /* New number of factories allocated */ /* 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") + 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") /* Zero out new elements allocated */ - HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, (new_nalloc - hdr->elmt_fac.nalloc) * sizeof(H5FL_fac_head_ptr_t)); + HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, + (new_nalloc - hdr->elmt_fac.nalloc) * sizeof(H5FL_fac_head_ptr_t)); /* Update information about element factories in header */ hdr->elmt_fac.nalloc = new_nalloc; - hdr->elmt_fac.fac = new_fac; + hdr->elmt_fac.fac = new_fac; } /* end if */ /* 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))) + 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") } /* end if */ /* Allocate buffer for elements in index block */ - if(NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) + if (NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer") /* Set the return value */ ret_value = elmts; -CATCH - if(!ret_value) - if(elmts) + CATCH + if (!ret_value) + if (elmts) elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ +END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_free_elmts * @@ -313,12 +295,10 @@ 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)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) /* Local variables */ - unsigned idx; /* Index of element buffer factory in header */ + unsigned idx; /* Index of element buffer factory in header */ /* Check arguments */ HDassert(hdr); @@ -326,7 +306,7 @@ H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) HDassert(elmts); /* Compute the index of the element buffer factory */ - H5_CHECK_OVERFLOW(nelmts, /*From:*/size_t, /*To:*/uint32_t); + H5_CHECK_OVERFLOW(nelmts, /*From:*/ size_t, /*To:*/ uint32_t); idx = H5VM_log2_of2((uint32_t)nelmts) - H5VM_log2_of2((uint32_t)hdr->cparam.data_blk_min_elmts); /* Free buffer for elements in index block */ @@ -334,9 +314,8 @@ H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) HDassert(hdr->elmt_fac.fac[idx]); elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ +END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_create * @@ -349,54 +328,57 @@ END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Extensible array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5EA_hdr_t *hdr = NULL; /* Extensible array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Check arguments */ HDassert(f); HDassert(cparam); #ifndef NDEBUG -{ - unsigned sblk_idx; /* Super block index for first "actual" super block */ - size_t dblk_nelmts; /* Number of data block elements */ - size_t dblk_page_nelmts; /* Number of elements in a data block page */ - - /* Check for valid parameters */ - if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "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") - 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) - if(cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "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") - if(!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "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") - - /* 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") - - 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") -} + { + unsigned sblk_idx; /* Super block index for first "actual" super block */ + size_t dblk_nelmts; /* Number of data block elements */ + size_t dblk_page_nelmts; /* Number of elements in a data block page */ + + /* Check for valid parameters */ + if (cparam->raw_elmt_size == 0) + H5E_THROW(H5E_BADVALUE, "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") + 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) + if (cparam->sup_blk_min_data_ptrs < 2) + H5E_THROW(H5E_BADVALUE, "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") + if (!POWER_OF_TWO(cparam->data_blk_min_elmts)) + H5E_THROW(H5E_BADVALUE, "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") + + /* 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") + + 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") + } #endif /* NDEBUG */ /* Allocate space for the shared information */ - if(NULL == (hdr = H5EA__hdr_alloc(f))) + if (NULL == (hdr = H5EA__hdr_alloc(f))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ @@ -406,51 +388,51 @@ H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam)); /* Finish initializing extensible array header */ - if(H5EA__hdr_init(hdr, ctx_udata) < 0) + if (H5EA__hdr_init(hdr, ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "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))) + 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") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "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) + 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") 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) + 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") /* Set address of array header to return */ ret_value = hdr->addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(hdr) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) + if (inserted) + if (H5AC_remove_entry(hdr) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy header */ - if(H5EA__hdr_dest(hdr) < 0) + if (H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") } /* end if */ -END_FUNC(PKG) /* end H5EA__hdr_create() */ +END_FUNC(PKG) /* end H5EA__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_incr * @@ -463,26 +445,23 @@ END_FUNC(PKG) /* end H5EA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_incr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as un-evictable when something is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) H5E_THROW(H5E_CANTPIN, "unable to pin extensible array header") /* Increment reference count on shared header */ hdr->rc++; -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_incr() */ +END_FUNC(PKG) /* end H5EA__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_decr * @@ -495,9 +474,7 @@ END_FUNC(PKG) /* end H5EA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_decr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -507,17 +484,16 @@ H5EA__hdr_decr(H5EA_hdr_t *hdr)) hdr->rc--; /* Mark header as evictable again when nothing depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) H5E_THROW(H5E_CANTUNPIN, "unable to unpin extensible array header") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_decr() */ +END_FUNC(PKG) /* end H5EA__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_incr * @@ -530,9 +506,7 @@ END_FUNC(PKG) /* end H5EA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -540,9 +514,8 @@ 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() */ +END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_decr * @@ -555,9 +528,7 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -size_t, 0, -, -H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -569,9 +540,8 @@ H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ +END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_modified * @@ -584,23 +554,20 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_modified(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); HDassert(hdr->f); /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as dirty") -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_modified() */ +END_FUNC(PKG) /* end H5EA__hdr_modified() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_protect * @@ -613,14 +580,12 @@ 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)) +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_cache_ud_t udata; /* User data for cache callbacks */ + H5EA_hdr_t * hdr; /* Extensible array header */ + H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ /* Sanity check */ HDassert(f); @@ -630,34 +595,34 @@ H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = ea_addr; + udata.f = f; + udata.addr = ea_addr; udata.ctx_udata = ctx_udata; /* 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) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + 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) + 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) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for extensible array entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "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) + 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") } /* end if */ /* Set return value */ ret_value = hdr; -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__hdr_protect() */ +END_FUNC(PKG) /* end H5EA__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_unprotect * @@ -670,9 +635,7 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) /* Local variables */ @@ -680,14 +643,14 @@ H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_delete * @@ -700,50 +663,47 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_delete(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_delete(H5EA_hdr_t *hdr)) /* Local variables */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ /* 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) + H5E_THROW(H5E_CANTGET, "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); + } /* end block */ #endif /* NDEBUG */ /* Check for index block */ - if(H5F_addr_defined(hdr->idx_blk_addr)) { + if (H5F_addr_defined(hdr->idx_blk_addr)) { /* Delete index block */ - if(H5EA__iblock_delete(hdr) < 0) + if (H5EA__iblock_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "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 + CATCH /* Unprotect the header, deleting it if an error hasn't occurred */ - if(H5EA__hdr_unprotect(hdr, cache_flags) < 0) + if (H5EA__hdr_unprotect(hdr, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_delete() */ +END_FUNC(PKG) /* end H5EA__hdr_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__hdr_dest * @@ -756,49 +716,47 @@ END_FUNC(PKG) /* end H5EA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__hdr_dest(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Check arguments */ HDassert(hdr); HDassert(hdr->rc == 0); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) + 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") } /* end if */ hdr->cb_ctx = NULL; /* Check for data block element buffer factory info to free */ - if(hdr->elmt_fac.fac) { - unsigned u; /* Local index variable */ + if (hdr->elmt_fac.fac) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(hdr->elmt_fac.nalloc > 0); /* Iterate over factories, shutting them down */ - for(u = 0; u < hdr->elmt_fac.nalloc; u++) { + for (u = 0; u < hdr->elmt_fac.nalloc; u++) { /* Check if this factory has been initialized */ - if(hdr->elmt_fac.fac[u]) { - if(H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) + 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") hdr->elmt_fac.fac[u] = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Free factory array */ hdr->elmt_fac.fac = (H5FL_fac_head_t **)H5FL_SEQ_FREE(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac); } /* end if */ /* Free the super block info array */ - if(hdr->sblk_info) + if (hdr->sblk_info) hdr->sblk_info = (H5EA_sblk_info_t *)H5FL_SEQ_FREE(H5EA_sblk_info_t, hdr->sblk_info); /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -806,7 +764,6 @@ H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Free the shared info itself */ hdr = H5FL_FREE(H5EA_hdr_t, hdr); -CATCH - -END_FUNC(PKG) /* end H5EA__hdr_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__hdr_dest() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index c45d15aee0f..1ef7980ad25 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -88,8 +79,6 @@ H5FL_BLK_DEFINE_STATIC(idx_blk_elmt_buf); /* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE_STATIC(haddr_t); - - /*------------------------------------------------------------------------- * Function: H5EA__iblock_alloc * @@ -102,59 +91,58 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5EA_iblock_t *, NULL, NULL, -H5EA__iblock_alloc(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t *hdr)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ /* 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") + if (NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) + H5E_THROW(H5E_CANTALLOC, "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") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") iblock->hdr = hdr; /* Set non-zero internal fields */ iblock->addr = HADDR_UNDEF; /* Compute information */ - iblock->nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); + iblock->nsblks = H5EA_SBLK_FIRST_IDX(hdr->cparam.sup_blk_min_data_ptrs); iblock->ndblk_addrs = 2 * ((size_t)hdr->cparam.sup_blk_min_data_ptrs - 1); iblock->nsblk_addrs = hdr->nsblks - iblock->nsblks; /* Allocate buffer for elements in index block */ - if(hdr->cparam.idx_blk_elmts > 0) - if(NULL == (iblock->elmts = H5FL_BLK_MALLOC(idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) + if (hdr->cparam.idx_blk_elmts > 0) + 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") /* 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))) + 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") /* 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))) + 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") /* Set the return value */ ret_value = iblock; -CATCH - if(!ret_value) - if(iblock && H5EA__iblock_dest(iblock) < 0) + CATCH + 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() */ +END_FUNC(PKG) /* end H5EA__iblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_create * @@ -167,62 +155,61 @@ 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)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) /* 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 */ + 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 */ /* Sanity check */ HDassert(hdr); HDassert(stats_changed); /* Allocate the index block */ - if(NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + if (NULL == (iblock = H5EA__iblock_alloc(hdr))) + H5E_THROW(H5E_CANTALLOC, "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") + 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") iblock->addr = iblock_addr; /* Clear any elements in index block to fill value */ - if(hdr->cparam.idx_blk_elmts > 0) { + 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) + 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") } /* end if */ /* Reset any data block addresses in the index block */ - if(iblock->ndblk_addrs > 0) { - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + if (iblock->ndblk_addrs > 0) { + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ /* Set all the data block addresses to "undefined" address value */ H5VM_array_fill(iblock->dblk_addrs, &tmp_addr, sizeof(haddr_t), iblock->ndblk_addrs); } /* end if */ /* Reset any super block addresses in the index block */ - if(iblock->nsblk_addrs > 0) { - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill super block addresses with */ + if (iblock->nsblk_addrs > 0) { + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill super block addresses with */ /* Set all the super block addresses to "undefined" address value */ H5VM_array_fill(iblock->sblk_addrs, &tmp_addr, sizeof(haddr_t), iblock->nsblk_addrs); } /* end if */ /* 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") + 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") 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) + 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") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -230,7 +217,7 @@ H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) /* Update extensible array index block statistics */ HDassert(0 == hdr->stats.computed.nindex_blks); HDassert(0 == hdr->stats.computed.index_blk_size); - hdr->stats.computed.nindex_blks = 1; + hdr->stats.computed.nindex_blks = 1; hdr->stats.computed.index_blk_size = iblock->size; /* Increment count of elements "realized" */ @@ -242,26 +229,26 @@ H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) /* Set address of index block to return */ ret_value = iblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(iblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (iblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(iblock) < 0) + if (inserted) + if (H5AC_remove_entry(iblock) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy index block */ - if(H5EA__iblock_dest(iblock) < 0) + if (H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_create() */ +END_FUNC(PKG) /* end H5EA__iblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_protect * @@ -274,12 +261,10 @@ 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)) +BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ /* Sanity check */ HDassert(hdr); @@ -288,13 +273,15 @@ H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == iblock->top_proxy) { + 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) + 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") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -302,17 +289,18 @@ H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) /* Set return value */ ret_value = iblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + 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) + 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) } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_protect() */ +END_FUNC(PKG) /* end H5EA__iblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_unprotect * @@ -325,9 +313,8 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) /* Local variables */ @@ -335,14 +322,14 @@ H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_delete * @@ -355,34 +342,34 @@ END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_delete(H5EA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr)) /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ /* Sanity check */ HDassert(hdr); HDassert(H5F_addr_defined(hdr->idx_blk_addr)); /* 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) + 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) /* Check for index block having data block pointers */ - if(iblock->ndblk_addrs > 0) { - unsigned sblk_idx; /* Current super block index */ - unsigned dblk_idx; /* Current data block index w/in super block */ - size_t u; /* Local index variable */ + if (iblock->ndblk_addrs > 0) { + unsigned sblk_idx; /* Current super block index */ + unsigned dblk_idx; /* Current data block index w/in super block */ + size_t u; /* Local index variable */ /* Iterate over data blocks */ sblk_idx = dblk_idx = 0; - for(u = 0; u < iblock->ndblk_addrs; u++) { + for (u = 0; u < iblock->ndblk_addrs; u++) { /* Check for data block existing */ - if(H5F_addr_defined(iblock->dblk_addrs[u])) { + if (H5F_addr_defined(iblock->dblk_addrs[u])) { /* Delete data block */ - if(H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) + 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") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -391,37 +378,38 @@ H5EA__iblock_delete(H5EA_hdr_t *hdr)) dblk_idx++; /* Check for moving to next super block */ - if(dblk_idx >= hdr->sblk_info[sblk_idx].ndblks) { + if (dblk_idx >= hdr->sblk_info[sblk_idx].ndblks) { sblk_idx++; dblk_idx = 0; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Check for index block having data block pointers (not yet) */ - if(iblock->nsblk_addrs > 0) { - size_t u; /* Local index variable */ + if (iblock->nsblk_addrs > 0) { + size_t u; /* Local index variable */ /* Iterate over super blocks */ - for(u = 0; u < iblock->nsblk_addrs; u++) { + for (u = 0; u < iblock->nsblk_addrs; u++) { /* Check for data block existing */ - if(H5F_addr_defined(iblock->sblk_addrs[u])) { + if (H5F_addr_defined(iblock->sblk_addrs[u])) { /* Delete super block */ - if(H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) + 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") iblock->sblk_addrs[u] = HADDR_UNDEF; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ -CATCH + CATCH /* 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) + 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") -END_FUNC(PKG) /* end H5EA__iblock_delete() */ +END_FUNC(PKG) /* end H5EA__iblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__iblock_dest * @@ -434,40 +422,38 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__iblock_dest(H5EA_iblock_t *iblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) /* Sanity check */ HDassert(iblock); /* Check if shared header field has been initialized */ - if(iblock->hdr) { + if (iblock->hdr) { /* Check if we've got elements in the index block */ - if(iblock->elmts) { + if (iblock->elmts) { /* Free buffer for index block elements */ HDassert(iblock->hdr->cparam.idx_blk_elmts > 0); iblock->elmts = H5FL_BLK_FREE(idx_blk_elmt_buf, iblock->elmts); } /* end if */ /* Check if we've got data block addresses in the index block */ - if(iblock->dblk_addrs) { + if (iblock->dblk_addrs) { /* Free buffer for index block data block addresses */ HDassert(iblock->ndblk_addrs > 0); - iblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->dblk_addrs); + iblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->dblk_addrs); iblock->ndblk_addrs = 0; } /* end if */ /* Check if we've got super block addresses in the index block */ - if(iblock->sblk_addrs) { + if (iblock->sblk_addrs) { /* Free buffer for index block super block addresses */ HDassert(iblock->nsblk_addrs > 0); - iblock->sblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->sblk_addrs); + iblock->sblk_addrs = H5FL_SEQ_FREE(haddr_t, iblock->sblk_addrs); iblock->nsblk_addrs = 0; } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(iblock->hdr) < 0) + if (H5EA__hdr_decr(iblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") iblock->hdr = NULL; } /* end if */ @@ -478,7 +464,6 @@ H5EA__iblock_dest(H5EA_iblock_t *iblock)) /* Free the index block itself */ iblock = H5FL_FREE(H5EA_iblock_t, iblock); -CATCH - -END_FUNC(PKG) /* end H5EA__iblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__iblock_dest() */ diff --git a/src/H5EAint.c b/src/H5EAint.c index ef8cd7a5265..472cfb4e617 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA__create_flush_depend * @@ -90,23 +79,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") -CATCH + CATCH -END_FUNC(PKG) /* end H5EA__create_flush_depend() */ +END_FUNC(PKG) /* end H5EA__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5EA__destroy_flush_depend * @@ -119,19 +106,17 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") -CATCH - -END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ + CATCH +END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ diff --git a/src/H5EAmodule.h b/src/H5EAmodule.h index c3a4c7ce17d..1833e406013 100644 --- a/src/H5EAmodule.h +++ b/src/H5EAmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5EA package. Including this header means that the source file * is part of the H5EA package. */ -#ifndef _H5EAmodule_H -#define _H5EAmodule_H +#ifndef H5EAmodule_H +#define H5EAmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5EA_MODULE -#define H5_MY_PKG H5EA -#define H5_MY_PKG_ERR H5E_EARRAY -#define H5_MY_PKG_INIT NO - -#endif /* _H5EAmodule_H */ +#define H5_MY_PKG H5EA +#define H5_MY_PKG_ERR H5E_EARRAY +#define H5_MY_PKG_INIT NO +#endif /* H5EAmodule_H */ diff --git a/src/H5EApkg.h b/src/H5EApkg.h index b70231dfd9d..bfa85885dc5 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,15 +23,14 @@ #error "Do not include this file outside the H5EA package!" #endif -#ifndef _H5EApkg_H -#define _H5EApkg_H +#ifndef H5EApkg_H +#define H5EApkg_H /* Get package's private header */ #include "H5EAprivate.h" /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -39,114 +38,114 @@ /* Fill value for extensible array test class */ #ifdef H5EA_TESTING -#define H5EA_TEST_FILL ((uint64_t)ULLONG_MAX) +#define H5EA_TEST_FILL ((uint64_t)ULLONG_MAX) #endif /* H5EA_TESTING */ /* Size of checksum information (on disk) */ -#define H5EA_SIZEOF_CHKSUM 4 +#define H5EA_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for extensible array metadata */ -#define H5EA_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + 1 /* Array type */ \ - + ((c) ? H5EA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ +#define H5EA_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + 1 /* Array type */ \ + + ((c) ? H5EA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ ) /* Size of the extensible array header on disk */ -#define H5EA_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* General array information */ \ - + 1 /* Element Size */ \ - + 1 /* Max. # of elements bits */ \ - + 1 /* # of elements to store in index block */ \ - + 1 /* Min. # elements per data block */ \ - + 1 /* Min. # of data block pointers for a super block */ \ - + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \ - \ - /* Extensible Array statistics fields */ \ - + (sizeof_size) /* Number of super blocks created */ \ - + (sizeof_size) /* Size of super blocks created */ \ - + (sizeof_size) /* Number of data blocks created */ \ - + (sizeof_size) /* Size of data blocks created */ \ - + (sizeof_size) /* Max. index set */ \ - + (sizeof_size) /* Number of elements 'realized' */ \ - \ - /* Extensible Array Header specific fields */ \ - + (sizeof_addr) /* File address of index block */ \ +#define H5EA_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* General array information */ \ + + 1 /* Element Size */ \ + + 1 /* Max. # of elements bits */ \ + + 1 /* # of elements to store in index block */ \ + + 1 /* Min. # elements per data block */ \ + + 1 /* Min. # of data block pointers for a super block */ \ + + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements \ + in data block page */ \ + \ + /* Extensible Array statistics fields */ \ + + (sizeof_size) /* Number of super blocks created */ \ + + (sizeof_size) /* Size of super blocks created */ \ + + (sizeof_size) /* Number of data blocks created */ \ + + (sizeof_size) /* Size of data blocks created */ \ + + (sizeof_size) /* Max. index set */ \ + + (sizeof_size) /* Number of elements 'realized' */ \ + \ + /* Extensible Array Header specific fields */ \ + + (sizeof_addr) /* File address of index block */ \ ) /* Size of the extensible array header on disk (via file pointer) */ -#define H5EA_HEADER_SIZE_FILE(f) ( \ - H5EA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5EA_HEADER_SIZE_FILE(f) (H5EA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the extensible array header on disk (via extensible array header) */ -#define H5EA_HEADER_SIZE_HDR(h) ( \ - H5EA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5EA_HEADER_SIZE_HDR(h) (H5EA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the extensible array index block on disk */ -#define H5EA_IBLOCK_SIZE(i) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (i)->hdr->sizeof_addr /* File address of array owning the block */ \ - \ - /* Extensible Array Index Block specific fields */ \ - + ((size_t)(i)->hdr->cparam.idx_blk_elmts * (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \ - + ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \ - + ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \ +#define H5EA_IBLOCK_SIZE(i) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (i)->hdr->sizeof_addr /* File address of array owning the block */ \ + \ + /* Extensible Array Index Block specific fields */ \ + + ((size_t)(i)->hdr->cparam.idx_blk_elmts * \ + (size_t)(i)->hdr->cparam.raw_elmt_size) /* Elements in index block */ \ + + ((i)->ndblk_addrs * (i)->hdr->sizeof_addr) /* Data block addresses in index block */ \ + + ((i)->nsblk_addrs * (i)->hdr->sizeof_addr) /* Super block addresses in index block */ \ ) /* Size of the extensible array super block on disk */ -#define H5EA_SBLOCK_SIZE(s) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (s)->hdr->sizeof_addr /* File address of array owning the block */ \ - + (s)->hdr->arr_off_size /* Offset of the block in the array */ \ - \ - /* Extensible Array Super Block specific fields */ \ - + ((s)->ndblks * (s)->dblk_page_init_size) /* Data block 'page init' bitmasks in super block (can be 0 if no pages) */ \ - + ((s)->ndblks * (s)->hdr->sizeof_addr) /* Data block addresses in super block */ \ +#define H5EA_SBLOCK_SIZE(s) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (s)->hdr->sizeof_addr /* File address of array owning the block */ \ + + (s)->hdr->arr_off_size /* Offset of the block in the array */ \ + \ + /* Extensible Array Super Block specific fields */ \ + + \ + ((s)->ndblks * \ + (s)->dblk_page_init_size) /* Data block 'page init' bitmasks in super block (can be 0 if no pages) */ \ + + ((s)->ndblks * (s)->hdr->sizeof_addr) /* Data block addresses in super block */ \ ) /* Size of the extensible array data block prefix on disk */ -#define H5EA_DBLOCK_PREFIX_SIZE(d) ( \ - /* General metadata fields */ \ - H5EA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (d)->hdr->sizeof_addr /* File address of array owning the block */ \ - + (d)->hdr->arr_off_size /* Offset of the block in the array */ \ +#define H5EA_DBLOCK_PREFIX_SIZE(d) \ + (/* General metadata fields */ \ + H5EA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (d)->hdr->sizeof_addr /* File address of array owning the block */ \ + + (d)->hdr->arr_off_size /* Offset of the block in the array */ \ ) /* Size of the extensible array data block on disk */ -#define H5EA_DBLOCK_SIZE(d) ( \ - /* Data block prefix size */ \ - H5EA_DBLOCK_PREFIX_SIZE(d) \ - \ - /* Extensible Array Data Block specific fields */ \ - + ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in data block */ \ - + ((d)->npages * H5EA_SIZEOF_CHKSUM) /* Checksum for each page */ \ +#define H5EA_DBLOCK_SIZE(d) \ + (/* Data block prefix size */ \ + H5EA_DBLOCK_PREFIX_SIZE(d) \ + \ + /* Extensible Array Data Block specific fields */ \ + + ((d)->nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) /* Elements in data block */ \ + + ((d)->npages * H5EA_SIZEOF_CHKSUM) /* Checksum for each page */ \ ) /* Size of the extensible array data block page on disk */ -#define H5EA_DBLK_PAGE_SIZE(h) ( \ - + ((h)->dblk_page_nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ - + H5EA_SIZEOF_CHKSUM /* Checksum for each page */ \ +#define H5EA_DBLK_PAGE_SIZE(h) \ + (+((h)->dblk_page_nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ + + H5EA_SIZEOF_CHKSUM /* Checksum for each page */ \ ) /* Compute the # of bytes required to store an offset into a given buffer size */ -#define H5EA_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) +#define H5EA_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) /* Compute the first super block index that will hold a certain # of data block pointers */ -#define H5EA_SBLK_FIRST_IDX(m) (2 * H5VM_log2_of2((uint32_t)m)) +#define H5EA_SBLK_FIRST_IDX(m) (2 * H5VM_log2_of2((uint32_t)m)) /****************************/ /* Package Private Typedefs */ @@ -154,10 +153,10 @@ /* Information for each super block in extensible array */ typedef struct H5EA_sblk_info_t { - size_t ndblks; /* Number of data blocks for a super block */ - size_t dblk_nelmts; /* Number of elements in each data block for super block */ - hsize_t start_idx; /* Index of first element in super block */ - hsize_t start_dblk; /* Index of first data block in super block */ + size_t ndblks; /* Number of data blocks for a super block */ + size_t dblk_nelmts; /* Number of elements in each data block for super block */ + hsize_t start_idx; /* Index of first element in super block */ + hsize_t start_dblk; /* Index of first data block in super block */ } H5EA_sblk_info_t; /* The extensible array header information */ @@ -169,63 +168,63 @@ typedef struct H5EA_hdr_t { H5AC_info_t cache_info; /* Extensible array configuration/creation parameters (stored in header) */ - H5EA_create_t cparam; /* Creation parameters for extensible array */ + H5EA_create_t cparam; /* Creation parameters for extensible array */ /* Index block information (stored in header) */ - haddr_t idx_blk_addr; /* Address of index block in header */ + haddr_t idx_blk_addr; /* Address of index block in header */ /* Statistics for array (stored in index block, actually) */ /* (header and index number/size fields not stored) */ - H5EA_stat_t stats; /* Statistics for extensible array */ + H5EA_stat_t stats; /* Statistics for extensible array */ /* Data block element buffer factory info (not stored in header) */ struct { - size_t nalloc; /* Number of factories allocated */ - H5FL_fac_head_t **fac; /* Array of factories for data block element buffers */ + size_t nalloc; /* Number of factories allocated */ + H5FL_fac_head_t **fac; /* Array of factories for data block element buffers */ } elmt_fac; /* Computed/cached values (not stored in header) */ - 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 */ - 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 */ - size_t sizeof_size; /* Size of file sizes */ - unsigned char arr_off_size; /* Size of array offsets (in bytes) */ + 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 */ + 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 */ + size_t sizeof_size; /* Size of file sizes */ + unsigned char arr_off_size; /* Size of array offsets (in bytes) */ /* Super block information (not stored) */ - size_t nsblks; /* Number of superblocks needed for array */ - H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ + size_t nsblks; /* Number of superblocks needed for array */ + H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */ /* Data block information (not stored) */ - size_t dblk_page_nelmts; /* # of elements per data block page */ + size_t dblk_page_nelmts; /* # of elements per data block page */ /* Client information (not stored) */ - void *cb_ctx; /* Callback context */ + void *cb_ctx; /* Callback context */ /* 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 - * parent, if it exists, otherwise NULL. - * If the extensible array is being used - * to index a chunked dataset and the - * dataset metadata is modified by a - * SWMR writer, this field will be set - * equal to the object header proxy - * that is the flush dependency parent - * of the extensible array header. - * - * The field is used to avoid duplicate - * setups of the flush dependency - * relationship, and to allow the - * extensible array header to destroy - * the flush dependency on receipt of - * an eviction notification from the - * metadata cache. - */ + 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 + * parent, if it exists, otherwise NULL. + * If the extensible array is being used + * to index a chunked dataset and the + * dataset metadata is modified by a + * SWMR writer, this field will be set + * equal to the object header proxy + * that is the flush dependency parent + * of the extensible array header. + * + * The field is used to avoid duplicate + * setups of the flush dependency + * relationship, and to allow the + * extensible array header to destroy + * the flush dependency on receipt of + * an eviction notification from the + * metadata cache. + */ } H5EA_hdr_t; /* The extensible array index block information */ @@ -234,22 +233,22 @@ typedef struct H5EA_iblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - 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 */ + 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 */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this index block on disk */ - size_t size; /* Size of index block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this index block on disk */ + size_t size; /* Size of index block on disk */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ /* Computed/cached values (not stored) */ - size_t nsblks; /* # of super blocks whose data block addresses are in index block */ - size_t ndblk_addrs; /* Number of pointers to data blocks in index block */ - size_t nsblk_addrs; /* Number of pointers to super blocks in index block */ + size_t nsblks; /* # of super blocks whose data block addresses are in index block */ + size_t ndblk_addrs; /* Number of pointers to data blocks in index block */ + size_t nsblk_addrs; /* Number of pointers to super blocks in index block */ } H5EA_iblock_t; /* The extensible array super block information */ @@ -258,27 +257,27 @@ typedef struct H5EA_sblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - hsize_t block_off; /* Offset of the block within the array's address space */ - haddr_t *dblk_addrs; /* Addresses of data blocks in super block */ - uint8_t *page_init; /* Bitmap of whether a data block page is initialized */ + hsize_t block_off; /* Offset of the block within the array's address space */ + haddr_t *dblk_addrs; /* Addresses of data blocks in super block */ + uint8_t *page_init; /* Bitmap of whether a data block page is initialized */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this index block on disk */ - size_t size; /* Size of index block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this index block on disk */ + size_t size; /* Size of index block on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + 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 */ - size_t ndblks; /* # of data block addresses that are in super block */ - size_t dblk_nelmts; /* # of elements for data blocks reachable through this super block */ - size_t dblk_npages; /* # of pages in each data block */ - size_t dblk_page_init_size; /* Size of 'page init' bitmask for each data block */ - size_t dblk_page_size; /* Size of a data block page */ + unsigned idx; /* Super block index within the extensible array */ + size_t ndblks; /* # of data block addresses that are in super block */ + size_t dblk_nelmts; /* # of elements for data blocks reachable through this super block */ + size_t dblk_npages; /* # of pages in each data block */ + size_t dblk_page_init_size; /* Size of 'page init' bitmask for each data block */ + size_t dblk_page_size; /* Size of a data block page */ } H5EA_sblock_t; /* The extensible array data block information */ @@ -287,22 +286,22 @@ typedef struct H5EA_dblock_t { H5AC_info_t cache_info; /* 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 */ + hsize_t block_off; /* Offset of the block within the array's address space */ + void * elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this data block on disk */ - size_t size; /* Size of data block on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this data block on disk */ + size_t size; /* Size of data block on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + 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 nelmts; /* Number of elements in block */ + size_t npages; /* Nummber of pages in a block (zero if not paged) */ } H5EA_dblock_t; /* The extensible array data block page information */ @@ -311,17 +310,17 @@ typedef struct H5EA_dbk_page_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - void *elmts; /* Buffer for elements stored in data block page */ + void *elmts; /* Buffer for elements stored in data block page */ /* Internal array information (not stored) */ - H5EA_hdr_t *hdr; /* Shared array header info */ - haddr_t addr; /* Address of this data block page on disk */ - size_t size; /* Size of data block page on disk */ + H5EA_hdr_t *hdr; /* Shared array header info */ + haddr_t addr; /* Address of this data block page on disk */ + size_t size; /* Size of data block page on disk */ /* SWMR / Flush dependency information (not stored) */ - hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ + 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,46 +328,46 @@ 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 */ + H5EA_hdr_t *hdr; /* Pointer to internal extensible array header info */ + 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 */ - haddr_t addr; /* Address of header on disk */ - void *ctx_udata; /* User context for class */ + H5F_t * f; /* Pointer to file for extensible array */ + haddr_t addr; /* Address of header on disk */ + 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_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 */ + 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 */ } 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) */ - size_t nelmts; /* Number of elements in data block */ - haddr_t dblk_addr; /* Address of data block */ + H5EA_hdr_t *hdr; /* Shared extensible array information */ + 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_sblock_t *parent; /* Pointer to parent object for data block page (super block) */ - haddr_t dblk_page_addr; /* Address of data block page */ + 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; #ifdef H5EA_TESTING typedef struct H5EA__ctx_cb_t { - herr_t (*encode)(const void *elmt, size_t nelmts, void *udata); /* Perform action during encode step */ - void *udata; /* User data for encode action */ + herr_t (*encode)(const void *elmt, size_t nelmts, void *udata); /* Perform action during encode step */ + void *udata; /* User data for encode action */ } H5EA__ctx_cb_t; #endif /* H5EA_TESTING */ @@ -382,96 +381,84 @@ H5_DLLVAR const H5EA_class_t H5EA_CLS_TEST[1]; /* Array of extensible array client ID -> client class mappings */ H5_DLLVAR const H5EA_class_t *const H5EA_client_class_g[H5EA_NUM_CLS_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Generic routines */ -H5_DLL herr_t H5EA__create_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); -H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +H5_DLL herr_t H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); +H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Header routines */ 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 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); -H5_DLL herr_t H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr); -H5_DLL size_t H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_modified(H5EA_hdr_t *hdr); -H5_DLL H5EA_hdr_t *H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, - void *ctx_udata, unsigned flags); -H5_DLL herr_t H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5EA__hdr_delete(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr); +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 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); +H5_DLL herr_t H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr); +H5_DLL size_t H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_modified(H5EA_hdr_t *hdr); +H5_DLL H5EA_hdr_t *H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags); +H5_DLL herr_t H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5EA__hdr_delete(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr); /* Index block routines */ H5_DLL H5EA_iblock_t *H5EA__iblock_alloc(H5EA_hdr_t *hdr); -H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed); +H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed); H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags); -H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags); -H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr); -H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock); +H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags); +H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr); +H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock); /* Super block routines */ -H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - unsigned sblk_idx); -H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - hbool_t *stats_changed, unsigned sblk_idx); -H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx, unsigned flags); -H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags); -H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, - haddr_t sblk_addr, unsigned sblk_idx); -H5_DLL herr_t H5EA__sblock_dest(H5EA_sblock_t *sblock); +H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx); +H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, + unsigned sblk_idx); +H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, + unsigned sblk_idx, unsigned flags); +H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags); +H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, + unsigned sblk_idx); +H5_DLL herr_t H5EA__sblock_dest(H5EA_sblock_t *sblock); /* Data block routines */ -H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, - size_t nelmts); -H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, - hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts); +H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts); +H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, + size_t nelmts); H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx); -H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, - haddr_t dblk_addr, size_t dblk_nelmts, unsigned flags); -H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags); -H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, - haddr_t dblk_addr, size_t dblk_nelmts); +H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, + size_t dblk_nelmts, unsigned flags); +H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags); +H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts); H5_DLL herr_t H5EA__dblock_dest(H5EA_dblock_t *dblock); /* Data block page routines */ H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent); -H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, - haddr_t addr); -H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, - H5EA_sblock_t *parent, haddr_t dblk_page_addr, unsigned flags); -H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, - unsigned cache_flags); -H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page); +H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr); +H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, + haddr_t dblk_page_addr, unsigned flags); +H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags); +H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page); /* Debugging routines for dumping file structures */ -H5_DLL 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); -H5_DLL herr_t H5EA__iblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, - haddr_t hdr_addr, haddr_t obj_addr); -H5_DLL 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); -H5_DLL 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); +H5_DLL 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); +H5_DLL herr_t H5EA__iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr); +H5_DLL 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); +H5_DLL 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); /* Testing routines */ #ifdef H5EA_TESTING H5_DLL herr_t H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam); -H5_DLL int H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2); +H5_DLL int H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2); #endif /* H5EA_TESTING */ -#endif /* _H5EApkg_H */ - +#endif /* H5EApkg_H */ diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index af0ef3a22dc..19dabd9ecfd 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,8 +23,8 @@ *------------------------------------------------------------------------- */ -#ifndef _H5EAprivate_H -#define _H5EAprivate_H +#ifndef H5EAprivate_H +#define H5EAprivate_H /* Include package's public header */ #ifdef NOT_YET @@ -32,28 +32,26 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* Extensible array class IDs */ typedef enum H5EA_cls_id_t { - H5EA_CLS_CHUNK_ID = 0, /* Extensible array is for indexing dataset chunks w/o filters */ - H5EA_CLS_FILT_CHUNK_ID, /* Extensible array is for indexing dataset chunks w/filters */ + H5EA_CLS_CHUNK_ID = 0, /* Extensible array is for indexing dataset chunks w/o filters */ + H5EA_CLS_FILT_CHUNK_ID, /* Extensible array is for indexing dataset chunks w/filters */ /* Start real class IDs at 0 -QAK */ /* (keep these last) */ - H5EA_CLS_TEST_ID, /* Extensible array is for testing (do not use for actual data) */ - H5EA_NUM_CLS_ID /* Number of Extensible Array class IDs (must be last) */ + H5EA_CLS_TEST_ID, /* Extensible array is for testing (do not use for actual data) */ + H5EA_NUM_CLS_ID /* Number of Extensible Array class IDs (must be last) */ } H5EA_cls_id_t; /* @@ -61,30 +59,36 @@ typedef enum H5EA_cls_id_t { * variable of this type that contains class variables and methods. */ 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) */ - size_t nat_elmt_size; /* Size of native (memory) element */ + H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */ + 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, 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 */ - herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */ + void *(*crt_context)(void *udata); /* Create context for other callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy context */ + herr_t (*fill)(void * nat_blk, + size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ + herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, + void *ctx); /* Encode elements from native form to disk storage form */ + herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, + void *ctx); /* Decode elements from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, + const void *elmt); /* Print an element for debugging */ void *(*crt_dbg_ctx)(H5F_t *f, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ + herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ } H5EA_class_t; /* Extensible array creation parameters */ typedef struct H5EA_create_t { - const H5EA_class_t *cls; /* Class of extensible array to create */ - uint8_t raw_elmt_size; /* Element size in file (in bytes) */ - uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - uint8_t idx_blk_elmts; /* # of elements to store in index block */ - uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ - uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + const H5EA_class_t *cls; /* Class of extensible array to create */ + uint8_t raw_elmt_size; /* Element size in file (in bytes) */ + uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of + elements */ + uint8_t idx_blk_elmts; /* # of elements to store in index block */ + uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ + uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed + to store max. # of elements in data block page */ } H5EA_create_t; /* Extensible array metadata statistics info */ @@ -94,19 +98,20 @@ typedef struct H5EA_create_t { typedef struct H5EA_stat_t { /* Non-stored (i.e. computed) fields */ struct { - hsize_t hdr_size; /* Size of header */ - hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ - hsize_t index_blk_size; /* Size of index blocks allocated */ + hsize_t hdr_size; /* Size of header */ + hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ + hsize_t index_blk_size; /* Size of index blocks allocated */ } computed; /* Stored fields */ struct { - hsize_t nsuper_blks; /* # of super blocks */ - hsize_t super_blk_size; /* Size of super blocks allocated */ - hsize_t ndata_blks; /* # of data blocks */ - hsize_t data_blk_size; /* Size of data blocks allocated */ - hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */ - hsize_t nelmts; /* # of elements "realized" */ + hsize_t nsuper_blks; /* # of super blocks */ + hsize_t super_blk_size; /* Size of super blocks allocated */ + hsize_t ndata_blks; /* # of data blocks */ + hsize_t data_blk_size; /* Size of data blocks allocated */ + hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value + with be '1', if no elements have been stored, this value will be '0') */ + hsize_t nelmts; /* # of elements "realized" */ } stored; } H5EA_stat_t; @@ -116,7 +121,6 @@ typedef struct H5EA_t H5EA_t; /* Define the operator callback function pointer for H5EA_iterate() */ typedef int (*H5EA_operator_t)(hsize_t idx, const void *_elmt, void *_udata); - /*****************************/ /* Library-private Variables */ /*****************************/ @@ -127,24 +131,22 @@ H5_DLLVAR const H5EA_class_t H5EA_CLS_CHUNK[1]; /* The Extensible Array class for dataset chunks w/ filters*/ H5_DLLVAR const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]; - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL H5EA_t *H5EA_create(H5F_t *f, const H5EA_create_t *cparam, - void *ctx_udata); +H5_DLL H5EA_t *H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata); H5_DLL H5EA_t *H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata); -H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); -H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); -H5_DLL herr_t H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt); -H5_DLL herr_t H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt); -H5_DLL herr_t H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5EA_iterate(H5EA_t *fa, H5EA_operator_t op, void *udata); -H5_DLL herr_t H5EA_close(H5EA_t *ea); -H5_DLL herr_t H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata); -H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f); +H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); +H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); +H5_DLL herr_t H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt); +H5_DLL herr_t H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt); +H5_DLL herr_t H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5EA_iterate(H5EA_t *fa, H5EA_operator_t op, void *udata); +H5_DLL herr_t H5EA_close(H5EA_t *ea); +H5_DLL herr_t H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata); +H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats); @@ -153,5 +155,4 @@ H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats); #ifdef H5EA_DEBUGGING #endif /* H5EA_DEBUGGING */ -#endif /* _H5EAprivate_H */ - +#endif /* H5EAprivate_H */ diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index b5b9d94c7b3..86392179674 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,55 +26,46 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -88,8 +79,6 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); /* Declare a free list to manage blocks of 'page init' bitmasks */ H5FL_BLK_DEFINE(page_init); - - /*------------------------------------------------------------------------- * Function: H5EA__sblock_alloc * @@ -102,41 +91,40 @@ 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)) +BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, + H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ /* 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") + if (NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) + H5E_THROW(H5E_CANTALLOC, "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") + if (H5EA__hdr_incr(hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") sblock->hdr = hdr; /* Set non-zero internal fields */ sblock->parent = parent; - sblock->addr = HADDR_UNDEF; + sblock->addr = HADDR_UNDEF; /* Compute/cache information */ - sblock->idx = sblk_idx; + sblock->idx = sblk_idx; sblock->ndblks = hdr->sblk_info[sblk_idx].ndblks; HDassert(sblock->ndblks); sblock->dblk_nelmts = hdr->sblk_info[sblk_idx].dblk_nelmts; /* Allocate buffer for data block addresses in super block */ - if(NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) + 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") /* Check if # of elements in data blocks requires paging */ - if(sblock->dblk_nelmts > hdr->dblk_page_nelmts) { + if (sblock->dblk_nelmts > hdr->dblk_page_nelmts) { /* Compute # of pages in each data block from this super block */ sblock->dblk_npages = sblock->dblk_nelmts / hdr->dblk_page_nelmts; @@ -151,25 +139,24 @@ H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) HDassert(sblock->dblk_page_init_size > 0); /* 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))) + 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") /* Compute data block page size */ - sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) - + H5EA_SIZEOF_CHKSUM; + sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; } /* end if */ /* Set the return value */ ret_value = sblock; -CATCH - if(!ret_value) - if(sblock && H5EA__sblock_dest(sblock) < 0) + CATCH + if (!ret_value) + if (sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_alloc() */ +END_FUNC(PKG) /* end H5EA__sblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_create * @@ -182,24 +169,23 @@ 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)) +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)) /* 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 */ + 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 */ /* Sanity check */ HDassert(hdr); HDassert(stats_changed); /* 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") + if (NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set size of super block on disk */ sblock->size = H5EA_SBLOCK_SIZE(sblock); @@ -208,21 +194,21 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_chang sblock->block_off = hdr->sblk_info[sblk_idx].start_idx; /* 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") + 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") sblock->addr = sblock_addr; /* Reset data block addresses to "undefined" address value */ H5VM_array_fill(sblock->dblk_addrs, &tmp_addr, sizeof(haddr_t), sblock->ndblks); /* 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") + 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") 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) + 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") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -237,26 +223,26 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_chang /* Set address of super block to return */ ret_value = sblock_addr; -CATCH - if(!H5F_addr_defined(ret_value)) - if(sblock) { + CATCH + if (!H5F_addr_defined(ret_value)) + if (sblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(sblock) < 0) + if (inserted) + if (H5AC_remove_entry(sblock) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy super block */ - if(H5EA__sblock_dest(sblock) < 0) + if (H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_create() */ +END_FUNC(PKG) /* end H5EA__sblock_create() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_protect * @@ -269,14 +255,13 @@ 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)) +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_cache_ud_t udata; /* Information needed for loading super block */ + H5EA_sblock_t * sblock = NULL; /* Pointer to super block */ + H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ /* Sanity check */ HDassert(hdr); @@ -286,19 +271,21 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.parent = parent; - udata.sblk_idx = sblk_idx; + udata.hdr = hdr; + udata.parent = parent; + udata.sblk_idx = sblk_idx; udata.sblk_addr = sblk_addr; /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == sblock->top_proxy) { + 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) + 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") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -306,17 +293,18 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, /* Set return value */ ret_value = sblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + 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) + 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 */ -END_FUNC(PKG) /* end H5EA__sblock_protect() */ +END_FUNC(PKG) /* end H5EA__sblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_unprotect * @@ -329,9 +317,8 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) /* Local variables */ @@ -339,14 +326,14 @@ H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ +END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_delete * @@ -359,42 +346,41 @@ 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)) +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 */ - H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ - size_t u; /* Local index variable */ + H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ + size_t u; /* Local index variable */ /* Sanity check */ HDassert(hdr); HDassert(H5F_addr_defined(sblk_addr)); /* 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) + 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) /* Iterate over data blocks */ - for(u = 0; u < sblock->ndblks; u++) { + for (u = 0; u < sblock->ndblks; u++) { /* Check for data block existing */ - if(H5F_addr_defined(sblock->dblk_addrs[u])) { + 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) + 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") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH /* 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) + 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") -END_FUNC(PKG) /* end H5EA__sblock_delete() */ +END_FUNC(PKG) /* end H5EA__sblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5EA__sblock_dest * @@ -407,28 +393,26 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5EA__sblock_dest(H5EA_sblock_t *sblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) /* Sanity check */ HDassert(sblock); HDassert(!sblock->has_hdr_depend); /* Check if shared header field has been initialized */ - if(sblock->hdr) { + if (sblock->hdr) { /* Free buffer for super block data block addresses, if there are any */ - if(sblock->dblk_addrs) + if (sblock->dblk_addrs) sblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, sblock->dblk_addrs); /* Free buffer for super block 'page init' bitmask, if there is one */ - if(sblock->page_init) { + if (sblock->page_init) { HDassert(sblock->dblk_npages > 0); sblock->page_init = H5FL_BLK_FREE(page_init, sblock->page_init); } /* end if */ /* Decrement reference count on shared info */ - if(H5EA__hdr_decr(sblock->hdr) < 0) + if (H5EA__hdr_decr(sblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") sblock->hdr = NULL; } /* end if */ @@ -439,7 +423,6 @@ H5EA__sblock_dest(H5EA_sblock_t *sblock)) /* Free the super block itself */ sblock = H5FL_FREE(H5EA_sblock_t, sblock); -CATCH - -END_FUNC(PKG) /* end H5EA__sblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5EA__sblock_dest() */ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 68e0b1e4529..47b9a869dbe 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,59 +26,48 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ - +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5EA_get_stats * @@ -91,9 +80,7 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) /* Local variables */ @@ -106,5 +93,4 @@ H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) /* Copy extensible array statistics */ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats)); -END_FUNC(PRIV) /* end H5EA_get_stats() */ - +END_FUNC(PRIV) /* end H5EA_get_stats() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index a0802bc7e58..dd669fc44d7 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,32 +22,28 @@ /* Module Declaration */ /**********************/ -#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ +#include "H5EAmodule.h" /* This source code file is part of the H5EA module */ #define H5EA_TESTING - /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Sanity checking value for callback contexts */ -#define H5EA__TEST_BOGUS_VAL 42 - +#define H5EA__TEST_BOGUS_VAL 42 /******************/ /* Local Typedefs */ @@ -55,28 +51,26 @@ /* Callback context */ typedef struct H5EA__test_ctx_t { - uint32_t bogus; /* Placeholder field to verify that context is working */ - H5EA__ctx_cb_t *cb; /* Pointer to context's callback action */ + uint32_t bogus; /* Placeholder field to verify that context is working */ + H5EA__ctx_cb_t *cb; /* Pointer to context's callback action */ } H5EA__test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 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); /*********************/ @@ -84,7 +78,7 @@ static herr_t H5EA__test_dst_dbg_context(void *_ctx); /*********************/ /* Extensible array testing class information */ -const H5EA_class_t H5EA_CLS_TEST[1]={{ +const H5EA_class_t H5EA_CLS_TEST[1] = {{ H5EA_CLS_TEST_ID, /* Type of Extensible array */ "Testing", /* Name of Extensible Array class */ sizeof(uint64_t), /* Size of native element */ @@ -98,12 +92,10 @@ const H5EA_class_t H5EA_CLS_TEST[1]={{ H5EA__test_dst_dbg_context /* Destroy debugging context */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -114,8 +106,6 @@ H5FL_DEFINE_STATIC(H5EA__test_ctx_t); /* Declare a free list to manage the H5EA__ctx_cb_t struct */ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); - - /*------------------------------------------------------------------------- * Function: H5EA__test_crt_context * @@ -129,32 +119,29 @@ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5EA__test_crt_context(void *_udata)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata)) /* Local variables */ - H5EA__test_ctx_t *ctx; /* Context for callbacks */ - H5EA__ctx_cb_t *udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ + H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ /* Sanity checks */ /* 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") + if (NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) + H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; - ctx->cb = udata; + ctx->cb = udata; /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_crt_context() */ +END_FUNC(STATIC) /* end H5EA__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_dst_context * @@ -168,12 +155,10 @@ END_FUNC(STATIC) /* end H5EA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_dst_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_context(void *_ctx)) /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ /* Sanity checks */ HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); @@ -181,9 +166,8 @@ H5EA__test_dst_context(void *_ctx)) /* Release context structure */ ctx = H5FL_FREE(H5EA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_context() */ +END_FUNC(STATIC) /* end H5EA__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_fill * @@ -197,12 +181,10 @@ END_FUNC(STATIC) /* end H5EA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_fill(void *nat_blk, size_t nelmts)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_fill(void *nat_blk, size_t nelmts)) /* Local variables */ - uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ + uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ /* Sanity checks */ HDassert(nat_blk); @@ -210,9 +192,8 @@ H5EA__test_fill(void *nat_blk, size_t nelmts)) H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5EA__test_fill() */ +END_FUNC(STATIC) /* end H5EA__test_fill() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_encode * @@ -226,13 +207,12 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) /* 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 */ + 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 */ /* Sanity checks */ HDassert(raw); @@ -241,13 +221,13 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Check for callback action */ - if(ctx->cb) { - if((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) + 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 */ /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ UINT64ENCODE(raw, *elmt); @@ -259,11 +239,10 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) nelmts--; } /* end while */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_encode() */ +END_FUNC(STATIC) /* end H5EA__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_decode * @@ -277,16 +256,15 @@ 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)) +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 */ +/* Local variables */ #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 */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + 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 */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ /* Sanity checks */ HDassert(raw); @@ -295,7 +273,7 @@ H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDE HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ UINT64DECODE(raw, *elmt); @@ -307,9 +285,8 @@ H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDE nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5EA__test_decode() */ +END_FUNC(STATIC) /* end H5EA__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_debug * @@ -323,13 +300,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) /* Local variables */ - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ /* Sanity checks */ HDassert(stream); @@ -338,9 +313,9 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(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); + (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5EA__test_debug() */ +END_FUNC(STATIC) /* end H5EA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__test_crt_dbg_context @@ -354,25 +329,23 @@ 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)) +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 */ - H5EA__ctx_cb_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) + if (NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ +END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__test_dst_dbg_context * @@ -385,21 +358,18 @@ END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5EA__test_dst_dbg_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_dbg_context(void *_ctx)) /* Local variables */ - H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ + H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ HDassert(_ctx); /* Release context structure */ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ +END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5EA__get_cparam_test * @@ -413,25 +383,22 @@ 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)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) /* Check arguments. */ HDassert(ea); HDassert(cparam); /* Get extensible array creation parameters */ - cparam->raw_elmt_size = ea->hdr->cparam.raw_elmt_size; - cparam->max_nelmts_bits = ea->hdr->cparam.max_nelmts_bits; - cparam->idx_blk_elmts = ea->hdr->cparam.idx_blk_elmts; - cparam->sup_blk_min_data_ptrs = ea->hdr->cparam.sup_blk_min_data_ptrs; - cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; + cparam->raw_elmt_size = ea->hdr->cparam.raw_elmt_size; + cparam->max_nelmts_bits = ea->hdr->cparam.max_nelmts_bits; + cparam->idx_blk_elmts = ea->hdr->cparam.idx_blk_elmts; + cparam->sup_blk_min_data_ptrs = ea->hdr->cparam.sup_blk_min_data_ptrs; + 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() */ +END_FUNC(PKG) /* end H5EA__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5EA__cmp_cparam_test * @@ -445,41 +412,39 @@ 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)) +BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, + H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) /* Check arguments. */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ - if(cparam1->raw_elmt_size < cparam2->raw_elmt_size) + if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) H5_LEAVE(-1) - else if(cparam1->raw_elmt_size > cparam2->raw_elmt_size) + else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) H5_LEAVE(1) - if(cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) + if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) H5_LEAVE(-1) - else if(cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) + else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) H5_LEAVE(1) - if(cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) + if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) H5_LEAVE(-1) - else if(cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) + else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) H5_LEAVE(1) - if(cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) + if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) H5_LEAVE(-1) - else if(cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) + else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) H5_LEAVE(1) - if(cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) + if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) H5_LEAVE(-1) - else if(cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) + else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) H5_LEAVE(1) - if(cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) + if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) H5_LEAVE(-1) - else if(cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) + else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) H5_LEAVE(1) -CATCH - -END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ + CATCH +END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h new file mode 100644 index 00000000000..28b41fa6d5f --- /dev/null +++ b/src/H5ESpublic.h @@ -0,0 +1,55 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5ES (event set) module. + */ + +#ifndef H5ESpublic_H +#define H5ESpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* 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_t; + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* H5ESpublic_H */ diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 4fd9022edb9..f9c9196cc1d 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,12 +15,13 @@ /* Add new errors to H5err.txt file */ -#ifndef _H5Edefin_H -#define _H5Edefin_H +#ifndef H5Edefin_H +#define H5Edefin_H /* Major error IDs */ hid_t H5E_FUNC_g = FAIL; /* Function entry/exit */ hid_t H5E_FILE_g = FAIL; /* File accessibility */ +hid_t H5E_VOL_g = FAIL; /* Virtual Object Layer */ hid_t H5E_SOHM_g = FAIL; /* Shared Object Header Messages */ hid_t H5E_SYM_g = FAIL; /* Symbol table */ hid_t H5E_PLUGIN_g = FAIL; /* Plugin for dynamically loaded library */ @@ -33,10 +34,12 @@ hid_t H5E_RESOURCE_g = FAIL; /* Resource unavailable */ hid_t H5E_RS_g = FAIL; /* Reference Counted Strings */ hid_t H5E_FARRAY_g = FAIL; /* Fixed Array */ hid_t H5E_HEAP_g = FAIL; /* Heap */ +hid_t H5E_MAP_g = FAIL; /* Map */ hid_t H5E_ATTR_g = FAIL; /* Attribute */ hid_t H5E_IO_g = FAIL; /* Low-level I/O */ hid_t H5E_EFL_g = FAIL; /* External file list */ hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */ +hid_t H5E_LIB_g = FAIL; /* General library infrastructure */ hid_t H5E_PAGEBUF_g = FAIL; /* Page Buffering */ hid_t H5E_FSPACE_g = FAIL; /* Free Space Manager */ hid_t H5E_DATASET_g = FAIL; /* Dataset */ @@ -145,6 +148,7 @@ hid_t H5E_NOTHDF5_g = FAIL; /* Not an HDF5 file */ hid_t H5E_BADFILE_g = FAIL; /* Bad file ID accessed */ hid_t H5E_TRUNCATED_g = FAIL; /* File has been truncated */ hid_t H5E_MOUNT_g = FAIL; /* File mount error */ +hid_t H5E_CANTDELETEFILE_g = FAIL; /* Unable to delete file */ hid_t H5E_CANTLOCKFILE_g = FAIL; /* Unable to lock file */ hid_t H5E_CANTUNLOCKFILE_g = FAIL; /* Unable to unlock file */ @@ -182,7 +186,6 @@ hid_t H5E_CANTDEPEND_g = FAIL; /* Unable to create a flush dependency * hid_t H5E_CANTUNDEPEND_g = FAIL; /* Unable to destroy a flush dependency */ hid_t H5E_CANTNOTIFY_g = FAIL; /* Unable to notify object about action */ hid_t H5E_LOGGING_g = FAIL; /* Failure in the cache logging framework */ -hid_t H5E_LOGFAIL_g = FAIL; /* old H5E_LOGGING_g (maintained for binary compatibility) */ hid_t H5E_CANTCORK_g = FAIL; /* Unable to cork an object */ hid_t H5E_CANTUNCORK_g = FAIL; /* Unable to uncork an object */ diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 046830f1ed0..9431089ea27 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,55 +29,46 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Epkg.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Eget_major * @@ -94,23 +85,23 @@ char * 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 */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size; + H5E_type_t type; + char * msg_str = NULL; + char * ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", maj); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(maj, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") /* Get the size & type of the message's text */ - if((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) + if ((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - if(type != H5E_MAJOR) + if (type != H5E_MAJOR) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one") /* Application will free this */ @@ -118,19 +109,18 @@ H5Eget_major(H5E_major_t maj) msg_str = (char *)H5MM_malloc((size_t)size); /* Get the text for the message */ - if(H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) + if (H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") ret_value = msg_str; done: - if(!ret_value) + if (!ret_value) msg_str = (char *)H5MM_xfree(msg_str); FUNC_LEAVE_API(ret_value) } /* end H5Eget_major() */ - /*------------------------------------------------------------------------- * Function: H5Eget_minor * @@ -147,23 +137,23 @@ H5Eget_major(H5E_major_t maj) char * 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 */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size; + H5E_type_t type; + char * msg_str = NULL; + char * ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", min); /* Get the message object */ - if(NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG))) + if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(min, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") /* Get the size & type of the message's text */ - if((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) + if ((size = H5E__get_msg(msg, &type, NULL, (size_t)0)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - if(type != H5E_MINOR) + if (type != H5E_MINOR) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one") /* Application will free this */ @@ -171,19 +161,18 @@ H5Eget_minor(H5E_minor_t min) msg_str = (char *)H5MM_malloc((size_t)size); /* Get the text for the message */ - if(H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) + if (H5E__get_msg(msg, NULL, msg_str, (size_t)size) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") ret_value = msg_str; done: - if(!ret_value) + if (!ret_value) msg_str = (char *)H5MM_xfree(msg_str); FUNC_LEAVE_API(ret_value) } /* end H5Eget_minor() */ - /*------------------------------------------------------------------------- * Function: H5Epush1 * @@ -205,24 +194,22 @@ H5Eget_minor(H5E_minor_t min) *------------------------------------------------------------------------- */ herr_t -H5Epush1(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str) +H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE6("e", "*s*sIuii*s", file, func, line, maj, min, str); /* Push the error on the default error stack */ - if(H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) + if (H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Epush1() */ - /*------------------------------------------------------------------------- * Function: H5Eclear1 * @@ -243,17 +230,16 @@ H5Eclear1(void) /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) - H5TRACE0("e",""); + H5TRACE0("e", ""); /* Clear the default error stack */ - if(H5E_clear_stack(NULL) < 0) + if (H5E_clear_stack(NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eclear1() */ - /*------------------------------------------------------------------------- * Function: H5Eprint1 * @@ -273,25 +259,25 @@ H5Eclear1(void) herr_t H5Eprint1(FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ + 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*/ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Print error stack */ - if(H5E__print(estack, stream, TRUE) < 0) + if (H5E__print(estack, stream, TRUE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eprint1() */ - /*------------------------------------------------------------------------- * Function: H5Ewalk1 * @@ -309,28 +295,28 @@ 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_walk_op_t walk_op; /* Error stack walking callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Walk the error stack */ - walk_op.vers = 1; + walk_op.vers = 1; walk_op.u.func1 = func; - if(H5E__walk(estack, direction, &walk_op, client_data) < 0) + if (H5E__walk(estack, direction, &walk_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Ewalk1() */ - /*------------------------------------------------------------------------- * Function: H5Eget_auto1 * @@ -350,33 +336,33 @@ 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_auto_op_t auto_op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t auto_op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*x**x", func, client_data); /* Retrieve default error stack */ - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &auto_op, client_data) < 0) + if (H5E__get_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto2 */ - if(!auto_op.is_default && auto_op.vers == 2) + if (!auto_op.is_default && auto_op.vers == 2) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto2 has been called") - if(func) + if (func) *func = auto_op.func1; done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_auto1() */ - /*------------------------------------------------------------------------- * Function: H5Eset_auto1 * @@ -403,34 +389,34 @@ 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_auto_op_t auto_op; /* Error stack operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t * estack; /* Error stack to operate on */ + H5E_auto_op_t auto_op; /* Error stack operator */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) H5TRACE2("e", "x*x", func, client_data); - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Get the automatic error reporting information */ - if(H5E__get_auto(estack, &auto_op, NULL) < 0) + if (H5E__get_auto(estack, &auto_op, NULL) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") /* Set the automatic error reporting information */ auto_op.vers = 1; - if(func != auto_op.func1_default) + if (func != auto_op.func1_default) auto_op.is_default = FALSE; else auto_op.is_default = TRUE; auto_op.func1 = func; - if(H5E__set_auto(estack, &auto_op, client_data) < 0) + if (H5E__set_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: FUNC_LEAVE_API(ret_value) } /* end H5Eset_auto1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Einit.h b/src/H5Einit.h index e9b5db84ab5..d27e550e8c5 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ /* Add new errors to H5err.txt file */ -#ifndef _H5Einit_H -#define _H5Einit_H +#ifndef H5Einit_H +#define H5Einit_H /*********************/ /* Major error codes */ @@ -32,6 +32,11 @@ if((msg = H5E__create_msg(cls, H5E_MAJOR, "File accessibility"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_FILE_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +HDassert(H5E_VOL_g==(-1)); +if((msg = H5E__create_msg(cls, H5E_MAJOR, "Virtual Object Layer"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_VOL_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HDassert(H5E_SOHM_g==(-1)); if((msg = H5E__create_msg(cls, H5E_MAJOR, "Shared Object Header Messages"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -92,6 +97,11 @@ if((msg = H5E__create_msg(cls, H5E_MAJOR, "Heap"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_HEAP_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +HDassert(H5E_MAP_g==(-1)); +if((msg = H5E__create_msg(cls, H5E_MAJOR, "Map"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_MAP_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HDassert(H5E_ATTR_g==(-1)); if((msg = H5E__create_msg(cls, H5E_MAJOR, "Attribute"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -112,6 +122,11 @@ if((msg = H5E__create_msg(cls, H5E_MAJOR, "Ternary Search Trees"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_TST_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +HDassert(H5E_LIB_g==(-1)); +if((msg = H5E__create_msg(cls, H5E_MAJOR, "General library infrastructure"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_LIB_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HDassert(H5E_PAGEBUF_g==(-1)); if((msg = H5E__create_msg(cls, H5E_MAJOR, "Page Buffering"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -543,6 +558,11 @@ if((msg = H5E__create_msg(cls, H5E_MINOR, "File mount error"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_MOUNT_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +HDassert(H5E_CANTDELETEFILE_g==(-1)); +if((msg = H5E__create_msg(cls, H5E_MINOR, "Unable to delete file"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTDELETEFILE_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HDassert(H5E_CANTLOCKFILE_g==(-1)); if((msg = H5E__create_msg(cls, H5E_MINOR, "Unable to lock file"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -712,11 +732,6 @@ if((msg = H5E__create_msg(cls, H5E_MINOR, "Failure in the cache logging framewor HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_LOGGING_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") -HDassert(H5E_LOGFAIL_g==(-1)); -if((msg = H5E__create_msg(cls, H5E_MINOR, "old H5E_LOGGING_g (maintained for binary compatibility)"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_LOGFAIL_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HDassert(H5E_CANTCORK_g==(-1)); if((msg = H5E__create_msg(cls, H5E_MINOR, "Unable to cork an object"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") diff --git a/src/H5Eint.c b/src/H5Eint.c index cf1d649e681..3fd4099ec60 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,52 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Emodule.h" /* This source code file is part of the H5E module */ - +#include "H5Emodule.h" /* This source code file is part of the H5E module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Epkg.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5TSprivate.h" /* Thread stuff */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5TSprivate.h" /* Thread stuff */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Printing information */ typedef struct H5E_print_t { - FILE *stream; - H5E_cls_t cls; + FILE * stream; + H5E_cls_t cls; } H5E_print_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ #ifndef H5_NO_DEPRECATED_SYMBOLS -static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, - void *client_data); +static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data); #endif /* H5_NO_DEPRECATED_SYMBOLS */ -static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, - void *client_data); +static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); - /*********************/ /* Package Variables */ /*********************/ @@ -83,7 +75,6 @@ static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries); H5E_t H5E_stack_g[1]; #endif /* H5_HAVE_THREADSAFE */ - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -98,7 +89,6 @@ hid_t H5E_ERR_CLS_g = FAIL; /* Include the automatically generated error code definitions */ #include "H5Edefin.h" - /*******************/ /* Local Variables */ /*******************/ @@ -107,12 +97,10 @@ hid_t H5E_ERR_CLS_g = FAIL; /* * variables used for MPI error reporting */ -char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -int H5E_mpi_error_str_len; +char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +int H5E_mpi_error_str_len; #endif /* H5_HAVE_PARALLEL */ - - /*------------------------------------------------------------------------- * Function: H5E__get_msg * @@ -129,7 +117,7 @@ int H5E_mpi_error_str_len; ssize_t H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) { - ssize_t len = -1; /* Length of error message */ + ssize_t len = -1; /* Length of error message */ FUNC_ENTER_PACKAGE_NOERR @@ -140,14 +128,14 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) len = (ssize_t)HDstrlen(msg->msg); /* Copy the message into the user's buffer, if given */ - if(msg_str) { - HDstrncpy(msg_str, msg->msg, MIN((size_t)(len+1), size)); - if((size_t)len >= size) - msg_str[size - 1] = '\0'; + if (msg_str) { + HDstrncpy(msg_str, msg->msg, MIN((size_t)(len + 1), size)); + if ((size_t)len >= size) + msg_str[size - 1] = '\0'; } /* end if */ /* Give the message type, if asked */ - if(type) + if (type) *type = msg->type; /* Set the return value to the full length of the message */ @@ -155,7 +143,7 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) } /* end H5E__get_msg() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5E__walk1_cb * @@ -192,15 +180,15 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) 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 */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ - herr_t ret_value = SUCCEED; + 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 */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -208,7 +196,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) HDassert(err_desc); /* If no client data was passed, output to stderr */ - if(!client_data) + if (!client_data) stream = stderr; else stream = eprint->stream; @@ -218,31 +206,31 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) min_ptr = (H5E_msg_t *)H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!maj_ptr || !min_ptr) + if (!maj_ptr || !min_ptr) HGOTO_DONE(FAIL) - if(maj_ptr->msg) + if (maj_ptr->msg) maj_str = maj_ptr->msg; - if(min_ptr->msg) + if (min_ptr->msg) min_str = min_ptr->msg; /* Get error class info */ cls_ptr = maj_ptr->cls; /* Print error class header if new class */ - if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + if (eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name) != 0) { /* update to the new class information */ - if(cls_ptr->cls_name) + if (cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) + if (cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) + if (cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; HDfprintf(stream, "%s-DIAG: Error detected in %s (%s) ", - (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), - (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), - (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL @@ -252,7 +240,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { + if (mpi_initialized && !mpi_finalized) { MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDfprintf(stream, "MPI-process %d", mpi_rank); } /* end if */ @@ -266,14 +254,13 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) } /* end if */ /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) - have_desc=0; + if (err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + have_desc = 0; /* Print error message */ - HDfprintf(stream, "%*s#%03d: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); + HDfprintf(stream, "%*s#%03d: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, + err_desc->line, err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); HDfprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); HDfprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); @@ -282,7 +269,6 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) } /* end H5E__walk1_cb() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*------------------------------------------------------------------------- * Function: H5E__walk2_cb * @@ -317,15 +303,15 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) 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 */ - unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ - herr_t ret_value = SUCCEED; + 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 */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC_NOERR @@ -333,7 +319,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) HDassert(err_desc); /* If no client data was passed, output to stderr */ - if(!client_data) + if (!client_data) stream = stderr; else stream = eprint->stream; @@ -343,12 +329,12 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) min_ptr = (H5E_msg_t *)H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!maj_ptr || !min_ptr) + if (!maj_ptr || !min_ptr) HGOTO_DONE(FAIL) - if(maj_ptr->msg) + if (maj_ptr->msg) maj_str = maj_ptr->msg; - if(min_ptr->msg) + if (min_ptr->msg) min_str = min_ptr->msg; /* Get error class info. Don't use the class of the major or minor error because @@ -356,23 +342,23 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) cls_ptr = (H5E_cls_t *)H5I_object_verify(err_desc->cls_id, H5I_ERROR_CLASS); /* Check for bad pointer(s), but can't issue error, just leave */ - if(!cls_ptr) + if (!cls_ptr) HGOTO_DONE(FAIL) /* Print error class header if new class */ - if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + if (eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name) != 0) { /* update to the new class information */ - if(cls_ptr->cls_name) + if (cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) + if (cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) + if (cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; HDfprintf(stream, "%s-DIAG: Error detected in %s (%s) ", - (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), - (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), - (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL @@ -382,7 +368,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { + if (mpi_initialized && !mpi_finalized) { MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); HDfprintf(stream, "MPI-process %d", mpi_rank); } /* end if */ @@ -396,14 +382,13 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) } /* end if */ /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + if (err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) have_desc = 0; /* Print error message */ - HDfprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); + HDfprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", H5E_INDENT, "", n, err_desc->file_name, + err_desc->line, err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); HDfprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); HDfprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); @@ -411,7 +396,6 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__walk2_cb() */ - /*------------------------------------------------------------------------- * Function: H5E__print * @@ -431,9 +415,9 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) { - H5E_print_t eprint; /* Callback information to pass to H5E_walk() */ - H5E_walk_op_t walk_op; /* Error stack walking callback */ - herr_t ret_value = SUCCEED; + H5E_print_t eprint; /* Callback information to pass to H5E_walk() */ + H5E_walk_op_t walk_op; /* Error stack walking callback */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -441,7 +425,7 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) HDassert(estack); /* If no stream was given, use stderr */ - if(!stream) + if (!stream) eprint.stream = stderr; else eprint.stream = stream; @@ -450,20 +434,20 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) HDmemset(&eprint.cls, 0, sizeof(H5E_cls_t)); /* Walk the error stack */ - if(bk_compatible) { + if (bk_compatible) { #ifndef H5_NO_DEPRECATED_SYMBOLS - walk_op.vers = 1; + walk_op.vers = 1; walk_op.u.func1 = H5E__walk1_cb; - if(H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void*)&eprint) < 0) + if (H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void *)&eprint) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ HDassert(0 && "version 1 error stack print without deprecated symbols!"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ else { - walk_op.vers = 2; + walk_op.vers = 2; walk_op.u.func2 = H5E__walk2_cb; - if(H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void*)&eprint) < 0) + if (H5E__walk(estack, H5E_WALK_DOWNWARD, &walk_op, (void *)&eprint) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") } /* end else */ @@ -471,7 +455,6 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__print() */ - /*------------------------------------------------------------------------- * Function: H5E__walk * @@ -503,11 +486,10 @@ H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) *------------------------------------------------------------------------- */ herr_t -H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, - void *client_data) +H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, void *client_data) { - int i; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + int i; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -516,74 +498,74 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o HDassert(op); /* check args, but rather than failing use some default value */ - if(direction != H5E_WALK_UPWARD && direction != H5E_WALK_DOWNWARD) - direction = H5E_WALK_UPWARD; + if (direction != H5E_WALK_UPWARD && direction != H5E_WALK_DOWNWARD) + direction = H5E_WALK_UPWARD; /* Walk the stack if a callback function was given */ - if(op->vers == 1) { + if (op->vers == 1) { #ifndef H5_NO_DEPRECATED_SYMBOLS - if(op->u.func1) { + if (op->u.func1) { H5E_error1_t old_err; ret_value = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) { + if (H5E_WALK_UPWARD == direction) { + for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; old_err.func_name = estack->slot[i].func_name; old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; ret_value = (op->u.func1)(i, &old_err, client_data); } /* end for */ - } /* end if */ + } /* end if */ else { H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) { + for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) { /* Point to each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; old_err.func_name = estack->slot[i].func_name; old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; ret_value = (op->u.func1)((int)(estack->nused - (size_t)(i + 1)), &old_err, client_data); } /* end for */ - } /* end else */ + } /* end else */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); } /* end if */ -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ HDassert(0 && "version 1 error stack walk without deprecated symbols!"); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + } /* end if */ else { HDassert(op->vers == 2); - if(op->u.func2) { + if (op->u.func2) { ret_value = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) + if (H5E_WALK_UPWARD == direction) { + for (i = 0; i < (int)estack->nused && ret_value == H5_ITER_CONT; i++) ret_value = (op->u.func2)((unsigned)i, estack->slot + i, client_data); } /* end if */ else { H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) - ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, client_data); + for (i = (int)(estack->nused - 1); i >= 0 && ret_value == H5_ITER_CONT; i--) + ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, + client_data); } /* end else */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); } /* end if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__walk() */ - /*------------------------------------------------------------------------- * Function: H5E__get_auto * @@ -607,15 +589,14 @@ H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data) HDassert(estack); /* Retrieve the requested information */ - if(op) + if (op) *op = estack->auto_op; - if(client_data) + if (client_data) *client_data = estack->auto_data; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__get_auto() */ - /*------------------------------------------------------------------------- * Function: H5E__set_auto * @@ -647,13 +628,12 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) HDassert(estack); /* Set the automatic error reporting info */ - estack->auto_op = *op; + estack->auto_op = *op; estack->auto_data = client_data; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5E__set_auto() */ - /*------------------------------------------------------------------------- * Function: H5E_printf_stack * @@ -667,17 +647,13 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) *------------------------------------------------------------------------- */ herr_t -H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) +H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *fmt, ...) { - va_list ap; /* Varargs info */ -#ifndef H5_HAVE_VASPRINTF - int tmp_len; /* Current size of description buffer */ - int desc_len; /* Actual length of description when formatted */ -#endif /* H5_HAVE_VASPRINTF */ - 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 */ + va_list ap; /* Varargs info */ + 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 */ /* * WARNING: We cannot call HERROR() from within this function or else we @@ -694,63 +670,35 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin HDassert(min_id > 0); HDassert(fmt); -/* Note that the variable-argument parsing for the format is identical in - * the H5Epush2() routine - correct errors and make changes in both - * places. -QAK - */ + /* Note that the variable-argument parsing for the format is identical in + * the H5Epush2() routine - correct errors and make changes in both + * places. -QAK + */ /* Start the variable-argument parsing */ HDva_start(ap, fmt); va_started = TRUE; -#ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ - if(HDvasprintf(&tmp, fmt, ap) < 0) + if (HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_DONE(FAIL) -#else /* H5_HAVE_VASPRINTF */ - /* Allocate space for the formatted description buffer */ - tmp_len = 128; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_DONE(FAIL) - - /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { - /* shutdown & restart the va_list */ - HDva_end(ap); - HDva_start(ap, fmt); - - /* Release the previous description, it's too small */ - H5MM_xfree(tmp); - - /* Allocate a description of the appropriate length */ - tmp_len = desc_len + 1; - if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) - HGOTO_DONE(FAIL) - } /* end while */ -#endif /* H5_HAVE_VASPRINTF */ /* Push the error on the stack */ - if(H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) + if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_DONE(FAIL) done: - if(va_started) + if (va_started) HDva_end(ap); -#ifdef H5_HAVE_VASPRINTF /* Memory was allocated with HDvasprintf so it needs to be freed * with HDfree */ - if(tmp) + if (tmp) HDfree(tmp); -#else /* H5_HAVE_VASPRINTF */ - if(tmp) - H5MM_xfree(tmp); -#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__push_stack * @@ -772,10 +720,10 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin *------------------------------------------------------------------------- */ herr_t -H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc) +H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, + hid_t min_id, const char *desc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* * WARNING: We cannot call HERROR() from within this function or else we @@ -792,19 +740,20 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line HDassert(min_id > 0); /* Check for 'default' error stack */ - if(estack == NULL) - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack == NULL) + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_DONE(FAIL) /* * Don't fail if arguments are bad. Instead, substitute some default * value. */ - if(!func) + if (!func) func = "Unknown_Function"; - if(!file) + if (!file) file = "Unknown_File"; - if(!desc) + if (!desc) desc = "No description given"; /* @@ -812,32 +761,31 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line */ HDassert(estack); - if(estack->nused < H5E_NSLOTS) { + if (estack->nused < H5E_NSLOTS) { /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(cls_id, FALSE) < 0) + if (H5I_inc_ref(cls_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].cls_id = cls_id; - if(H5I_inc_ref(maj_id, FALSE) < 0) + estack->slot[estack->nused].cls_id = cls_id; + if (H5I_inc_ref(maj_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].maj_num = maj_id; - if(H5I_inc_ref(min_id, FALSE) < 0) + estack->slot[estack->nused].maj_num = maj_id; + if (H5I_inc_ref(min_id, FALSE) < 0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].min_num = min_id; - if(NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) + estack->slot[estack->nused].min_num = min_id; + if (NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) HGOTO_DONE(FAIL) - if(NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) + if (NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) HGOTO_DONE(FAIL) - estack->slot[estack->nused].line = line; - if(NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) + estack->slot[estack->nused].line = line; + if (NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) HGOTO_DONE(FAIL) - estack->nused++; + estack->nused++; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__push_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__clear_entries * @@ -854,9 +802,9 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line static herr_t H5E__clear_entries(H5E_t *estack, size_t nentries) { - H5E_error2_t *error; /* Pointer to error stack entry to clear */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5E_error2_t *error; /* Pointer to error stack entry to clear */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -865,25 +813,25 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) HDassert(estack->nused >= nentries); /* Empty the error stack from the top down */ - for(u = 0; nentries > 0; nentries--, u++) { + for (u = 0; nentries > 0; nentries--, u++) { error = &(estack->slot[estack->nused - (u + 1)]); /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_num) < 0) + if (H5I_dec_ref(error->min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_num) < 0) + if (H5I_dec_ref(error->maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->cls_id) < 0) + if (H5I_dec_ref(error->cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") /* Release strings */ - if(error->func_name) - error->func_name = (const char *) H5MM_xfree_const(error->func_name); - if(error->file_name) - error->file_name = (const char *) H5MM_xfree_const(error->file_name); - if(error->desc) - error->desc = (const char *) H5MM_xfree_const(error->desc); + if (error->func_name) + error->func_name = (const char *)H5MM_xfree_const(error->func_name); + if (error->file_name) + error->file_name = (const char *)H5MM_xfree_const(error->file_name); + if (error->desc) + error->desc = (const char *)H5MM_xfree_const(error->desc); } /* Decrement number of errors on stack */ @@ -893,7 +841,6 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__clear_entries() */ - /*------------------------------------------------------------------------- * Function: H5E_clear_stack * @@ -910,26 +857,26 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) herr_t H5E_clear_stack(H5E_t *estack) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check for 'default' error stack */ - if(estack == NULL) - if(NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if (estack == NULL) + if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in + non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Empty the error stack */ HDassert(estack); - if(estack->nused) - if(H5E__clear_entries(estack, estack->nused) < 0) + if (estack->nused) + if (H5E__clear_entries(estack, estack->nused) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_clear_stack() */ - /*------------------------------------------------------------------------- * Function: H5E__pop * @@ -946,7 +893,7 @@ H5E_clear_stack(H5E_t *estack) herr_t H5E__pop(H5E_t *estack, size_t count) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -955,14 +902,13 @@ H5E__pop(H5E_t *estack, size_t count) HDassert(estack->nused >= count); /* Remove the entries from the error stack */ - if(H5E__clear_entries(estack, count) < 0) + if (H5E__clear_entries(estack, count) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't remove errors from stack") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__pop() */ - /*------------------------------------------------------------------------- * Function: H5E_dump_api_stack * @@ -980,32 +926,31 @@ H5E__pop(H5E_t *estack, size_t count) herr_t H5E_dump_api_stack(hbool_t is_api) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Only dump the error stack during an API call */ - if(is_api) { + if (is_api) { H5E_t *estack = H5E__get_my_stack(); HDassert(estack); #ifdef H5_NO_DEPRECATED_SYMBOLS - if(estack->auto_op.func2) - (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - if(estack->auto_op.vers == 1) { - if(estack->auto_op.func1) + if (estack->auto_op.func2) + (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + if (estack->auto_op.vers == 1) { + if (estack->auto_op.func1) (void)((estack->auto_op.func1)(estack->auto_data)); } /* end if */ else { - if(estack->auto_op.func2) + if (estack->auto_op.func2) (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); } /* end else */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_dump_api_stack() */ - diff --git a/src/H5Emodule.h b/src/H5Emodule.h index fbfc262fa92..43d5d36e431 100644 --- a/src/H5Emodule.h +++ b/src/H5Emodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,17 +18,44 @@ * H5E package. Including this header means that the source file * is part of the H5E package. */ -#ifndef _H5Emodule_H -#define _H5Emodule_H +#ifndef H5Emodule_H +#define H5Emodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5E_MODULE -#define H5_MY_PKG H5E -#define H5_MY_PKG_ERR H5E_ERROR -#define H5_MY_PKG_INIT YES - -#endif /* _H5Emodule_H */ +#define H5_MY_PKG H5E +#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. + */ +#endif /* H5Emodule_H */ diff --git a/src/H5Epkg.h b/src/H5Epkg.h index eac58297b6d..30ff084eaeb 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,24 +23,23 @@ #error "Do not include this file outside the H5E package!" #endif -#ifndef _H5Epkg_H -#define _H5Epkg_H +#ifndef H5Epkg_H +#define H5Epkg_H /* Get package's private header */ #include "H5Eprivate.h" /* Other private headers needed by this file */ - /**************************/ /* Package Private Macros */ /**************************/ /* Amount to indent each error */ -#define H5E_INDENT 2 +#define H5E_INDENT 2 /* Number of slots in an error stack */ -#define H5E_NSLOTS 32 +#define H5E_NSLOTS 32 #ifdef H5_HAVE_THREADSAFE /* @@ -52,7 +51,7 @@ * In order for this macro to work, H5E__get_my_stack() must be preceeded * by "H5E_t *estack =". */ -#define H5E__get_my_stack() H5E__get_stack() +#define H5E__get_my_stack() H5E__get_stack() #else /* H5_HAVE_THREADSAFE */ /* * The current error stack. @@ -60,7 +59,6 @@ #define H5E__get_my_stack() (H5E_stack_g + 0) #endif /* H5_HAVE_THREADSAFE */ - /****************************/ /* Package Private Typedefs */ /****************************/ @@ -68,53 +66,52 @@ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ #ifndef H5_NO_DEPRECATED_SYMBOLS typedef struct { - unsigned vers; /* Which version callback to use */ - hbool_t is_default; /* If the printing function is the library's own. */ - H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ - H5E_auto2_t func2; /* New-style callback, with error stack param. */ - H5E_auto1_t func1_default; /* The saved library's default function - old style. */ - H5E_auto2_t func2_default; /* The saved library's default function - new style. */ + unsigned vers; /* Which version callback to use */ + hbool_t is_default; /* If the printing function is the library's own. */ + H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ + H5E_auto2_t func2; /* New-style callback, with error stack param. */ + H5E_auto1_t func1_default; /* The saved library's default function - old style. */ + H5E_auto2_t func2_default; /* The saved library's default function - new style. */ } H5E_auto_op_t; -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ typedef struct { - H5E_auto2_t func2; /* Only the new style callback function is available. */ + H5E_auto2_t func2; /* Only the new style callback function is available. */ } H5E_auto_op_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ typedef struct { - unsigned vers; /* Which version callback to use */ + unsigned vers; /* Which version callback to use */ union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5E_walk1_t func1; /* Old-style callback, NO error stack param. */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5E_walk2_t func2; /* New-style callback, with error stack param. */ - }u; + H5E_walk1_t func1; /* Old-style callback, NO error stack param. */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5E_walk2_t func2; /* New-style callback, with error stack param. */ + } u; } H5E_walk_op_t; /* Error class */ typedef struct H5E_cls_t { - char *cls_name; /* Name of error class */ - char *lib_name; /* Name of library within class */ - char *lib_vers; /* Version of library */ + char *cls_name; /* Name of error class */ + char *lib_name; /* Name of library within class */ + char *lib_vers; /* Version of library */ } H5E_cls_t; /* Major or minor message */ typedef struct H5E_msg_t { - 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 */ + 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; /* Error stack */ 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 */ + 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 */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -123,10 +120,9 @@ struct H5E_t { /* * The current error stack. */ -H5_DLLVAR H5E_t H5E_stack_g[1]; +H5_DLLVAR H5E_t H5E_stack_g[1]; #endif /* H5_HAVE_THREADSAFE */ - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -134,18 +130,14 @@ H5_DLL herr_t H5E__term_deprec_interface(void); #ifdef H5_HAVE_THREADSAFE H5_DLL H5E_t *H5E__get_stack(void); #endif /* H5_HAVE_THREADSAFE */ -H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc); -H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, - char *msg, size_t size); -H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat); -H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, - const H5E_walk_op_t *op, void *client_data); -H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, - void **client_data); -H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, - void *client_data); -H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count); - -#endif /* _H5Epkg_H */ - +H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *desc); +H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); +H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat); +H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op, + void *client_data); +H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data); +H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data); +H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count); + +#endif /* H5Epkg_H */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 130a8fd1061..4cd8b703fd9 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * Header file for error values, etc. */ -#ifndef _H5Eprivate_H -#define _H5Eprivate_H +#ifndef H5Eprivate_H +#define H5Eprivate_H #include "H5Epublic.h" @@ -30,16 +30,17 @@ typedef struct H5E_t H5E_t; * and a FUNC_LEAVE() within a function body. The arguments are the major * error number, the minor error number, and a description of the error. */ -#define HERROR(maj_id, min_id, ...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) +#define HERROR(maj_id, min_id, ...) \ + H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) /* * HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR * (Shouldn't need to be used outside this header file) */ -#define HCOMMON_ERROR(maj, min, ...) \ - HERROR(maj, min, __VA_ARGS__); \ - err_occurred = TRUE; \ - err_occurred = err_occurred; /* Shut GCC warnings up! */ +#define HCOMMON_ERROR(maj, min, ...) \ + HERROR(maj, min, __VA_ARGS__); \ + err_occurred = TRUE; \ + err_occurred = err_occurred; /* Shut GCC warnings up! */ /* * HDONE_ERROR macro, used to facilitate error reporting between a @@ -50,10 +51,11 @@ typedef struct H5E_t H5E_t; * (This macro can also be used to push an error and set the return value * without jumping to any labels) */ -#define HDONE_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - ret_value = ret_val; \ -} +#define HDONE_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + ret_value = ret_val; \ + } /* * HGOTO_ERROR macro, used to facilitate error reporting between a @@ -62,20 +64,22 @@ typedef struct H5E_t H5E_t; * error string. The return value is assigned to a variable `ret_value' and * control branches to the `done' label. */ -#define HGOTO_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ + } /* * HGOTO_ERROR_TAG macro, used like HGOTO_ERROR between H5_BEGIN_TAG and * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ -#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) { \ - H5AC_tag(prv_tag, NULL); \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) \ + { \ + H5AC_tag(prv_tag, NULL); \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ + } /* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() @@ -83,16 +87,21 @@ typedef struct H5E_t H5E_t; * value which is assigned to the `ret_value' variable. Control branches to * the `done' label. */ -#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} +#define HGOTO_DONE(ret_val) \ + { \ + ret_value = ret_val; \ + goto done; \ + } /* * HGOTO_DONE_TAG macro, used like HGOTO_DONE between H5_BEGIN_TAG and * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ -#define HGOTO_DONE_TAG(ret_val) { \ - H5AC_tag(prv_tag, NULL); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_DONE_TAG(ret_val) \ + { \ + H5AC_tag(prv_tag, NULL); \ + HGOTO_DONE(ret_val) \ + } /* * Macros handling system error messages as described in C standard. @@ -102,38 +111,75 @@ typedef struct H5E_t H5E_t; /* Retrieve the error code description string and push it onto the error * stack. */ -#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) { \ - int myerrno = errno; \ - HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \ -} -#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) { \ - int myerrno = errno; \ - HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \ -} +#ifndef H5_HAVE_WIN32_API +#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + /* Other projects may rely on the description format to get the errno and any changes should be \ + * considered as an API change \ + */ \ + HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \ + HDstrerror(myerrno)); \ + } +#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + /* Other projects may rely on the description format to get the errno and any changes should be \ + * considered as an API change \ + */ \ + HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \ + HDstrerror(myerrno)); \ + } +#else /* H5_HAVE_WIN32_API */ +/* On Windows we also emit the result of GetLastError(). This call returns a DWORD, which is always a + * 32-bit unsigned type. Note that on Windows, either errno or GetLastError() (but probably not both) will + * be useful depending on whether a C/POSIX or Win32 call failed. The other value will likely be zero, + * though I wouldn't count on that. + */ +#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + DWORD win_error = GetLastError(); \ + /* Other projects may rely on the description format to get the errno and any changes should be \ + * considered as an API change \ + */ \ + HDONE_ERROR(majorcode, minorcode, retcode, \ + "%s, errno = %d, error message = '%s', Win32 GetLastError() = %" PRIu32 "", str, \ + myerrno, HDstrerror(myerrno), win_error); \ + } +#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + DWORD win_error = GetLastError(); \ + /* Other projects may rely on the description format to get the errno and any changes should be \ + * considered as an API change \ + */ \ + HGOTO_ERROR(majorcode, minorcode, retcode, \ + "%s, errno = %d, error message = '%s', Win32 GetLastError() = %" PRIu32 "", str, \ + myerrno, HDstrerror(myerrno), win_error); \ + } +#endif /* H5_HAVE_WIN32_API */ #ifdef H5_HAVE_PARALLEL /* * MPI error handling macros. */ -extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -extern int H5E_mpi_error_str_len; - -#define HMPI_ERROR(mpierr){ \ - MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ - HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ -} -#define HMPI_DONE_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} -#define HMPI_GOTO_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} +extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +extern int H5E_mpi_error_str_len; + +#define HMPI_DONE_ERROR(retcode, str, mpierr) \ + { \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, "%s: MPI error string is '%s'", str, H5E_mpi_error_str); \ + } +#define HMPI_GOTO_ERROR(retcode, str, mpierr) \ + { \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, "%s: MPI error string is '%s'", str, H5E_mpi_error_str); \ + } #endif /* H5_HAVE_PARALLEL */ - /******************************************************************************/ /* Revisions to Error Macros, to go with Revisions to FUNC_ENTER/LEAVE Macros */ /******************************************************************************/ @@ -144,7 +190,8 @@ extern int H5E_mpi_error_str_len; * 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__) +#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 @@ -153,11 +200,12 @@ extern int H5E_mpi_error_str_len; * 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; \ -} +#define H5_LEAVE(v) \ + { \ + ret_value = v; \ + if (!past_catch) \ + goto catch_except; \ + } /* * H5E_THROW macro, used to facilitate error reporting between a @@ -166,23 +214,24 @@ extern int H5E_mpi_error_str_len; * 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) \ -} +#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; - +#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, hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); +H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); H5_DLL herr_t H5E_clear_stack(H5E_t *estack); H5_DLL herr_t H5E_dump_api_stack(hbool_t is_api); -#endif /* _H5Eprivate_H */ - +#endif /* H5Eprivate_H */ diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 0922a95f7e0..375e92d39b9 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ /* Add new errors to H5err.txt file */ -#ifndef _H5Epubgen_H -#define _H5Epubgen_H +#ifndef H5Epubgen_H +#define H5Epubgen_H #ifdef __cplusplus extern "C" { @@ -28,6 +28,7 @@ extern "C" { #define H5E_FUNC (H5OPEN H5E_FUNC_g) #define H5E_FILE (H5OPEN H5E_FILE_g) +#define H5E_VOL (H5OPEN H5E_VOL_g) #define H5E_SOHM (H5OPEN H5E_SOHM_g) #define H5E_SYM (H5OPEN H5E_SYM_g) #define H5E_PLUGIN (H5OPEN H5E_PLUGIN_g) @@ -40,10 +41,12 @@ extern "C" { #define H5E_RS (H5OPEN H5E_RS_g) #define H5E_FARRAY (H5OPEN H5E_FARRAY_g) #define H5E_HEAP (H5OPEN H5E_HEAP_g) +#define H5E_MAP (H5OPEN H5E_MAP_g) #define H5E_ATTR (H5OPEN H5E_ATTR_g) #define H5E_IO (H5OPEN H5E_IO_g) #define H5E_EFL (H5OPEN H5E_EFL_g) #define H5E_TST (H5OPEN H5E_TST_g) +#define H5E_LIB (H5OPEN H5E_LIB_g) #define H5E_PAGEBUF (H5OPEN H5E_PAGEBUF_g) #define H5E_FSPACE (H5OPEN H5E_FSPACE_g) #define H5E_DATASET (H5OPEN H5E_DATASET_g) @@ -63,6 +66,7 @@ extern "C" { #define H5E_CACHE (H5OPEN H5E_CACHE_g) H5_DLLVAR hid_t H5E_FUNC_g; /* Function entry/exit */ H5_DLLVAR hid_t H5E_FILE_g; /* File accessibility */ +H5_DLLVAR hid_t H5E_VOL_g; /* Virtual Object Layer */ H5_DLLVAR hid_t H5E_SOHM_g; /* Shared Object Header Messages */ H5_DLLVAR hid_t H5E_SYM_g; /* Symbol table */ H5_DLLVAR hid_t H5E_PLUGIN_g; /* Plugin for dynamically loaded library */ @@ -75,10 +79,12 @@ H5_DLLVAR hid_t H5E_RESOURCE_g; /* Resource unavailable */ H5_DLLVAR hid_t H5E_RS_g; /* Reference Counted Strings */ H5_DLLVAR hid_t H5E_FARRAY_g; /* Fixed Array */ H5_DLLVAR hid_t H5E_HEAP_g; /* Heap */ +H5_DLLVAR hid_t H5E_MAP_g; /* Map */ H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */ H5_DLLVAR hid_t H5E_IO_g; /* Low-level I/O */ H5_DLLVAR hid_t H5E_EFL_g; /* External file list */ H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */ +H5_DLLVAR hid_t H5E_LIB_g; /* General library infrastructure */ H5_DLLVAR hid_t H5E_PAGEBUF_g; /* Page Buffering */ H5_DLLVAR hid_t H5E_FSPACE_g; /* Free Space Manager */ H5_DLLVAR hid_t H5E_DATASET_g; /* Dataset */ @@ -243,6 +249,7 @@ H5_DLLVAR hid_t H5E_OPENERROR_g; /* Can't open directory or file */ #define H5E_BADFILE (H5OPEN H5E_BADFILE_g) #define H5E_TRUNCATED (H5OPEN H5E_TRUNCATED_g) #define H5E_MOUNT (H5OPEN H5E_MOUNT_g) +#define H5E_CANTDELETEFILE (H5OPEN H5E_CANTDELETEFILE_g) #define H5E_CANTLOCKFILE (H5OPEN H5E_CANTLOCKFILE_g) #define H5E_CANTUNLOCKFILE (H5OPEN H5E_CANTUNLOCKFILE_g) H5_DLLVAR hid_t H5E_FILEEXISTS_g; /* File already exists */ @@ -254,6 +261,7 @@ H5_DLLVAR hid_t H5E_NOTHDF5_g; /* Not an HDF5 file */ H5_DLLVAR hid_t H5E_BADFILE_g; /* Bad file ID accessed */ H5_DLLVAR hid_t H5E_TRUNCATED_g; /* File has been truncated */ H5_DLLVAR hid_t H5E_MOUNT_g; /* File mount error */ +H5_DLLVAR hid_t H5E_CANTDELETEFILE_g; /* Unable to delete file */ H5_DLLVAR hid_t H5E_CANTLOCKFILE_g; /* Unable to lock file */ H5_DLLVAR hid_t H5E_CANTUNLOCKFILE_g; /* Unable to unlock file */ @@ -297,7 +305,6 @@ H5_DLLVAR hid_t H5E_NOIDS_g; /* Out of IDs for group */ #define H5E_CANTUNDEPEND (H5OPEN H5E_CANTUNDEPEND_g) #define H5E_CANTNOTIFY (H5OPEN H5E_CANTNOTIFY_g) #define H5E_LOGGING (H5OPEN H5E_LOGGING_g) -#define H5E_LOGFAIL (H5OPEN H5E_LOGFAIL_g) #define H5E_CANTCORK (H5OPEN H5E_CANTCORK_g) #define H5E_CANTUNCORK (H5OPEN H5E_CANTUNCORK_g) H5_DLLVAR hid_t H5E_CANTFLUSH_g; /* Unable to flush data from cache */ @@ -325,7 +332,6 @@ H5_DLLVAR hid_t H5E_CANTDEPEND_g; /* Unable to create a flush dependency */ H5_DLLVAR hid_t H5E_CANTUNDEPEND_g; /* Unable to destroy a flush dependency */ H5_DLLVAR hid_t H5E_CANTNOTIFY_g; /* Unable to notify object about action */ H5_DLLVAR hid_t H5E_LOGGING_g; /* Failure in the cache logging framework */ -H5_DLLVAR hid_t H5E_LOGFAIL_g; /* old H5E_LOGGING_g (maintained for binary compatibility) */ H5_DLLVAR hid_t H5E_CANTCORK_g; /* Unable to cork an object */ H5_DLLVAR hid_t H5E_CANTUNCORK_g; /* Unable to uncork an object */ diff --git a/src/H5Epublic.h b/src/H5Epublic.h index ed142177c43..2f529b330b9 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,45 +14,53 @@ /* * This file contains public declarations for the H5E module. */ -#ifndef _H5Epublic_H -#define _H5Epublic_H +#ifndef H5Epublic_H +#define H5Epublic_H -#include /*FILE arg of H5Eprint() */ +#include /*FILE arg of H5Eprint() */ /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* Value for the default error stack */ -#define H5E_DEFAULT (hid_t)0 +#define H5E_DEFAULT (hid_t)0 -/* Different kinds of error information */ -typedef enum H5E_type_t { - H5E_MAJOR, - H5E_MINOR -} H5E_type_t; +/** + * Different kinds of error information + */ +typedef enum H5E_type_t { H5E_MAJOR, H5E_MINOR } H5E_type_t; -/* Information about an error; element of error stack */ +/** + * Information about an error; element of error stack + */ typedef struct H5E_error2_t { - hid_t cls_id; /*class ID */ - hid_t maj_num; /*major error ID */ - hid_t min_num; /*minor error number */ - unsigned line; /*line in file where error occurs */ - const char *func_name; /*function in which error occurred */ - const char *file_name; /*file in which error occurred */ - const char *desc; /*optional supplied description */ + hid_t cls_id; + /**< Class ID */ + hid_t maj_num; + /**< Major error ID */ + hid_t min_num; + /**< Minor error number */ + unsigned line; + /**< Line in file where error occurs */ + const char *func_name; + /**< Function in which error occurred */ + const char *file_name; + /**< File in which error occurred */ + const char *desc; + /**< Optional supplied description */ } H5E_error2_t; /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN -#ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* H5private_H */ /* HDF5 error class */ -#define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g) +#define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g) H5_DLLVAR hid_t H5E_ERR_CLS_g; /* Include the automatically generated public header information */ @@ -64,119 +72,570 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * trying something that's likely or expected to fail. The code to try can * be nested between calls to H5Eget_auto() and H5Eset_auto(), but it's * easier just to use this macro like: - * H5E_BEGIN_TRY { - * ...stuff here that's likely to fail... + * H5E_BEGIN_TRY { + * ...stuff here that's likely to fail... * } H5E_END_TRY; * * Warning: don't break, return, or longjmp() from the body of the loop or - * the error reporting won't be properly restored! + * the error reporting won't be properly restored! * * These two macros still use the old API functions for backward compatibility * purpose. */ #ifndef H5_NO_DEPRECATED_SYMBOLS -#define H5E_BEGIN_TRY { \ - unsigned H5E_saved_is_v2; \ - union { \ - H5E_auto1_t efunc1; \ - H5E_auto2_t efunc2; \ - } H5E_saved; \ - void *H5E_saved_edata; \ - \ - (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \ - if(H5E_saved_is_v2) { \ - (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \ - (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \ - } else { \ - (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \ - (void)H5Eset_auto1(NULL, NULL); \ - } +#define H5E_BEGIN_TRY \ + { \ + unsigned H5E_saved_is_v2; \ + union { \ + H5E_auto1_t efunc1; \ + H5E_auto2_t efunc2; \ + } H5E_saved; \ + void *H5E_saved_edata; \ + \ + (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \ + if (H5E_saved_is_v2) { \ + (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \ + } \ + else { \ + (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \ + (void)H5Eset_auto1(NULL, NULL); \ + } -#define H5E_END_TRY \ - if(H5E_saved_is_v2) \ - (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \ - else \ - (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \ -} +#define H5E_END_TRY \ + if (H5E_saved_is_v2) \ + (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \ + else \ + (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \ + } #else /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5E_BEGIN_TRY { \ - H5E_auto2_t saved_efunc; \ - void *H5E_saved_edata; \ - \ - (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ - (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - -#define H5E_END_TRY \ - (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ -} +#define H5E_BEGIN_TRY \ + { \ + H5E_auto2_t saved_efunc; \ + void * H5E_saved_edata; \ + \ + (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + +#define H5E_END_TRY \ + (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \ + } #endif /* H5_NO_DEPRECATED_SYMBOLS */ /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ -#define H5Epush_sim(func, cls, maj, min, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str) +#define H5Epush_sim(func, cls, maj, min, str) \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str) /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ -#define H5Epush_ret(func, cls, maj, min, str, ret) { \ - H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ - return(ret); \ -} +#define H5Epush_ret(func, cls, maj, min, str, ret) \ + do { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + return (ret); \ + } while (0) /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in * And goto a label after pushing error onto stack. */ -#define H5Epush_goto(func, cls, maj, min, str, label) { \ - H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ - goto label; \ -} +#define H5Epush_goto(func, cls, maj, min, str, label) \ + { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + goto label; \ + } -/* Error stack traversal direction */ +/** + * Error stack traversal direction + */ typedef enum H5E_direction_t { - H5E_WALK_UPWARD = 0, /*begin deep, end at API function */ - H5E_WALK_DOWNWARD = 1 /*begin at API function, end deep */ + H5E_WALK_UPWARD = 0, /**< begin w/ most specific error, end at API function */ + H5E_WALK_DOWNWARD = 1 /**< begin at API function, end w/ most specific error */ } H5E_direction_t; - #ifdef __cplusplus extern "C" { #endif /* Error stack traversal callback function pointers */ -typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, - void *client_data); +//! +/** + * \brief Callback function for H5Ewalk2() + * + * \param[in] n Indexed error position in the stack + * \param[in] err_desc Pointer to a data structure describing the error + * \param[in] client_data Pointer to client data in the format expected by the + * user-defined function + * \return \herr_t + */ +typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, void *client_data); +//! + +//! +/** + * \brief Callback function for H5Eset_auto2() + * + * \estack_id{estack} + * \param[in] client_data Pointer to client data in the format expected by the + * user-defined function + * \return \herr_t + */ typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data); +//! /* Public API functions */ -H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, - const char *version); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Registers a client library or application program to the HDF5 error API + * + * \param[in] cls_name Name of the error class + * \param[in] lib_name Name of the client library or application to which the error class belongs + * \param[in] version Version of the client library or application to which the + error class belongs. Can be \c NULL. + * \return Returns a class identifier on success; otherwise returns H5I_INVALID_ID. + * + * \details H5Eregister_class() registers a client library or application + * program to the HDF5 error API so that the client library or + * application program can report errors together with the HDF5 + * library. It receives an identifier for this error class for further + * error operations. The library name and version number will be + * printed out in the error message as a preamble. + * + * \since 1.8.0 + */ +H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Removes an error class + * + * \param[in] class_id Error class identifier. + * \return \herr_t + * + * \details H5Eunregister_class() removes the error class specified by \p + * class_id. All the major and minor errors in this class will also be + * closed. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eunregister_class(hid_t class_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Closes an error message + * + * \param[in] err_id An error message identifier + * \return \herr_t + * + * \details H5Eclose_msg() closes an error message identifier, which can be + * either a major or minor message. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eclose_msg(hid_t err_id); -H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); -H5_DLL hid_t H5Ecreate_stack(void); -H5_DLL hid_t H5Eget_current_stack(void); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Adds a major error message to an error class + * + * \param[in] cls An error class identifier + * \param[in] msg_type The type of the error message + * \param[in] msg Major error message + * \return \herr_t + * + * \details H5Ecreate_msg() adds an error message to an error class defined by + * client library or application program. The error message can be + * either major or minor as indicated by the parameter \p msg_type. + * + * Use H5Eclose_msg() to close the message identifier returned by this + * function. + * + * \since 1.8.0 + */ +H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Creates a new, empty error stack + * + * \return \hid_ti{error stack} + * + * \details H5Ecreate_stack() creates a new empty error stack and returns the + * new stack’s identifier. Use H5Eclose_stack() to close the error stack + * identifier returned by this function. + * + * \since 1.8.0 + */ +H5_DLL hid_t H5Ecreate_stack(void); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Returns a copy of the current error stack + * + * \return \hid_ti{error stack} + * + * \details H5Eget_current_stack() copies the current error stack and returns an + * error stack identifier for the new copy. + * + * \since 1.8.0 + */ +H5_DLL hid_t H5Eget_current_stack(void); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Closes an error stack handle + * + * \estack_id{stack_id} + * + * \return \herr_t + * + * \details H5Eclose_stack() closes the error stack handle \p stack_id + * and releases its resources. #H5E_DEFAULT cannot be closed. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eclose_stack(hid_t stack_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Retrieves error class name + * + * \param[in] class_id Error class identifier + * \param[out] name Buffer for the error class name + * \param[in] size The maximum number of characters the class name to be returned + * by this function in\p name. + * \return Returns non-negative value as on success; otherwise returns negative value. + * + * \details H5Eget_class_name() retrieves the name of the error class specified + * by the class identifier. If non-NULL pointer is passed in for \p + * name and \p size is greater than zero, the class name of \p size + * long is returned. The length of the error class name is also + * returned. If NULL is passed in as \p name, only the length of class + * name is returned. If zero is returned, it means no name. The user is + * responsible for allocating sufficient buffer space for the name. + * + * \since 1.8.0 + */ H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Replaces the current error stack + * + * \estack_id{err_stack_id} + * + * \return \herr_t + * + * \details H5Eset_current_stack() replaces the content of the current error + * stack with a copy of the content of the error stack specified by + * \p err_stack_id, and it closes the error stack specified by + * \p err_stack_id. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); -H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Pushes a new error record onto an error stack + * + * \estack_id{err_stack}. If the identifier is #H5E_DEFAULT, the error record + * will be pushed to the current stack. + * \param[in] file Name of the file in which the error was detected + * \param[in] func Name of the function in which the error was detected + * \param[in] line Line number in the file where the error was detected + * \param[in] cls_id Error class identifier + * \param[in] maj_id Major error identifier + * \param[in] min_id Minor error identifier + * \param[in] msg Error description string + * \return \herr_t + * + * \details H5Epush2() pushes a new error record onto the error stack specified + * by \p err_stack.\n + * The error record contains the error class identifier \p cls_id, the + * major and minor message identifiers \p maj_id and \p min_id, the + * function name \p func where the error was detected, the file name \p + * file and line number \p line in the file where the error was + * detected, and an error description \p msg.\n + * The major and minor errors must be in the same error class.\n + * The function name, filename, and error description strings must be + * statically allocated.\n + * \p msg can be a format control string with additional + * arguments. This design of appending additional arguments is similar + * to the system and C functions printf() and fprintf(). + * + * \since 1.8.0 + */ +H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *msg, ...); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Deletes specified number of error messages from the error stack + * + * \estack_id{err_stack} + * \param[in] count The number of error messages to be deleted from the top + * of error stack + * \return \herr_t + * + * \details H5Epop() deletes the number of error records specified in \p count + * from the top of the error stack specified by \p err_stack (including + * major, minor messages and description). The number of error messages + * to be deleted is specified by \p count. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Prints the specified error stack in a default manner + * + * \estack_id{err_stack} + * \param[in] stream File pointer, or \c NULL for \c stderr + * \return \herr_t + * + * \details H5Eprint2() prints the error stack specified by \p err_stack on the + * specified stream, \p stream. Even if the error stack is empty, a + * one-line message of the following form will be printed: + * \code{.unparsed} + * HDF5-DIAG: Error detected in HDF5 library version: 1.5.62 thread 0. + * \endcode + * + * A similar line will appear before the error messages of each error + * class stating the library name, library version number, and thread + * identifier. + * + * If \p err_stack is #H5E_DEFAULT, the current error stack will be + * printed. + * + * H5Eprint2() is a convenience function for H5Ewalk2() with a function + * that prints error messages. Users are encouraged to write their own + * more specific error handlers. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream); -H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, - void *client_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Walks the specified error stack, calling the specified function + * + * \estack_id{err_stack} + * \param[in] direction Direction in which the error stack is to be walked + * \param[in] func Function to be called for each error encountered + * \param[in] client_data Data to be passed to \p func + * \return \herr_t + * + * \details H5Ewalk2() walks the error stack specified by err_stack for the + * current thread and calls the function specified in \p func for each + * error along the way. + * + * If the value of \p err_stack is #H5E_DEFAULT, then H5Ewalk2() walks + * the current error stack. + * + * \p direction specifies whether the stack is walked from the inside + * out or the outside in. A value of #H5E_WALK_UPWARD means to begin + * with the most specific error and end at the API; a value of + * #H5E_WALK_DOWNWARD means to start at the API and end at the + * innermost function where the error was first detected. + * + * \p func, a function conforming to the #H5E_walk2_t prototype, will + * be called for each error in the error stack. Its arguments will + * include an index number \c n (beginning at zero regardless of stack + * traversal direction), an error stack entry \c err_desc, and the \c + * client_data pointer passed to H5Eprint(). The #H5E_walk2_t prototype + * is as follows: + * \snippet this H5E_walk2_t_snip + * + * \since 1.8.0 + */ +H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, void *client_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Returns the settings for the automatic error stack traversal + * function and its data + * + * \estack_id + * \param[out] func The function currently set to be called upon an error condition + * \param[out] client_data Data currently set to be passed to the error function + * \return \herr_t + * + * \details H5Eget_auto2() returns the settings for the automatic error stack + * traversal function, \p func, and its data, \p client_data, that are + * associated with the error stack specified by \p estack_id. + * + * Either or both of the \p func and \p client_data arguments may be + * \c NULL, in which case the value is not returned. + * + * The library initializes its default error stack traversal functions + * to H5Eprint1() and H5Eprint2(). A call to H5Eget_auto2() returns + * H5Eprint2() or the user-defined function passed in through + * H5Eset_auto2(). A call to H5Eget_auto1() returns H5Eprint1() or the + * user-defined function passed in through H5Eset_auto1(). However, if + * the application passes in a user-defined function through + * H5Eset_auto1(), it should call H5Eget_auto1() to query the traversal + * function. If the application passes in a user-defined function + * through H5Eset_auto2(), it should call H5Eget_auto2() to query the + * traversal function. + * + * Mixing the new style and the old style functions will cause a + * failure. For example, if the application sets a user-defined + * old-style traversal function through H5Eset_auto1(), a call to + * H5Eget_auto2() will fail and will indicate that the application has + * mixed H5Eset_auto1() and H5Eget_auto2(). On the other hand, mixing + * H5Eset_auto2() and H5Eget_auto1() will also cause a failure. But if + * the traversal functions are the library’s default H5Eprint1() or + * H5Eprint2(), mixing H5Eset_auto1() and H5Eget_auto2() or mixing + * H5Eset_auto2() and H5Eget_auto1() does not fail. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Turns automatic error printing on or off + * + * \estack_id + * \param[in] func Function to be called upon an error condition + * \param[in] client_data Data passed to the error function + * \return \herr_t + * + * \details H5Eset_auto2() turns on or off automatic printing of errors for the + * error stack specified with \p estack_id. An \p estack_id value of + * #H5E_DEFAULT indicates the current stack. + * + * When automatic printing is turned on, by the use of a non-null \p func + * pointer, any API function which returns an error indication will + * first call \p func, passing it \p client_data as an argument. + * + * \p func, a function compliant with the #H5E_auto2_t prototype, is + * defined in the H5Epublic.h source code file as: + * \snippet this H5E_auto2_t_snip + * + * When the library is first initialized, the auto printing function is + * set to H5Eprint2() (cast appropriately) and \p client_data is the + * standard error stream pointer, \c stderr. + * + * Automatic stack traversal is always in the #H5E_WALK_DOWNWARD + * direction. + * + * Automatic error printing is turned off with a H5Eset_auto2() call + * with a \c NULL \p func pointer. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Clears the specified error stack or the error stack for the current thread + * + * \estack_id{err_stack} + * \return \herr_t + * + * \details H5Eclear2() clears the error stack specified by \p err_stack, or, if + * \p err_stack is set to #H5E_DEFAULT, the error stack for the current + * thread. + * + * \p err_stack is an error stack identifier, such as that returned by + * H5Eget_current_stack(). + * + * The current error stack is also cleared whenever an API function is + * called, with certain exceptions (for instance, H5Eprint1() or + * H5Eprint2()). + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eclear2(hid_t err_stack); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Determines the type of error stack + * + * \estack_id{err_stack} + * \param[out] is_stack A flag indicating which error stack \c typedef the + * specified error stack conforms to + * + * \return \herr_t + * + * \details H5Eauto_is_v2() determines whether the error auto reporting function + * for an error stack conforms to the #H5E_auto2_t \c typedef or the + * #H5E_auto1_t \c typedef. + * + * The \p is_stack parameter is set to 1 if the error stack conforms to + * #H5E_auto2_t and 0 if it conforms to #H5E_auto1_t. + * + * \since 1.8.0 + */ H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack); -H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, - size_t size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Retrieves an error message + * + * \param[in] msg_id Error message identifier + * \param[out] type The type of the error message Valid values are #H5E_MAJOR + * and #H5E_MINOR. + * \param[out] msg Error message buffer + * \param[in] size The length of error message to be returned by this function + * \return Returns the size of the error message in bytes on success; otherwise + * returns a negative value. + * + * \details H5Eget_msg() retrieves the error message including its length and + * type. The error message is specified by \p msg_id. The user is + * responsible for passing in sufficient buffer space for the + * message. If \p msg is not NULL and \p size is greater than zero, the + * error message of \p size long is returned. The length of the message + * is also returned. If NULL is passed in as \p msg, only the length + * and type of the message is returned. If the return value is zero, it + * means there is no message. + * + * \since 1.8.0 + */ +H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Retrieves the number of error messages in an error stack + * + * \estack_id{error_stack_id} + * \return Returns a non-negative value on success; otherwise returns a negative value. + * + * \details H5Eget_num() retrieves the number of error records in the error + * stack specified by \p error_stack_id (including major, minor + * messages and description). + * + * \since 1.8.0 + */ H5_DLL ssize_t H5Eget_num(hid_t error_stack_id); - /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -188,33 +647,261 @@ H5_DLL ssize_t H5Eget_num(hid_t error_stack_id); /* Alias major & minor error types to hid_t's, for compatibility with new * error API in v1.8 */ -typedef hid_t H5E_major_t; -typedef hid_t H5E_minor_t; +typedef hid_t H5E_major_t; +typedef hid_t H5E_minor_t; -/* Information about an error element of error stack. */ +/** + * Information about an error element of error stack. + */ typedef struct H5E_error1_t { - H5E_major_t maj_num; /*major error number */ - H5E_minor_t min_num; /*minor error number */ - const char *func_name; /*function in which error occurred */ - const char *file_name; /*file in which error occurred */ - unsigned line; /*line in file where error occurs */ - const char *desc; /*optional supplied description */ + H5E_major_t maj_num; /**< major error number */ + H5E_minor_t min_num; /**< minor error number */ + const char *func_name; /**< function in which error occurred */ + const char *file_name; /**< file in which error occurred */ + unsigned line; /**< line in file where error occurs */ + const char *desc; /**< optional supplied description */ } H5E_error1_t; /* Error stack traversal callback function pointers */ +//! +/** + * \brief Callback function for H5Ewalk1() + * + * \param[in] n Indexed error position in the stack + * \param[in] err_desc Pointer to a data structure describing the error + * \param[in] client_data Pointer to client data in the format expected by the + * user-defined function + * \return \herr_t + */ typedef herr_t (*H5E_walk1_t)(int n, H5E_error1_t *err_desc, void *client_data); +//! + +//! +/** + * \brief Callback function for H5Eset_auto1() + * + * \param[in] client_data Pointer to client data in the format expected by the + * user-defined function + * \return \herr_t + */ typedef herr_t (*H5E_auto1_t)(void *client_data); +//! /* Function prototypes */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Clears the error stack for the current thread + * + * \return \herr_t + * + * \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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Returns the current settings for the automatic error stack traversal + * function and its data + * + * \param[out] func Current setting for the function to be called upon an error + * condition + * \param[out] client_data Current setting for the data passed to the error + * function + * \return \herr_t + * + * \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 + * value is not returned. + * + * The library initializes its default error stack traversal functions + * to H5Eprint1() and H5Eprint2(). A call to H5Eget_auto2() returns + * H5Eprint2() or the user-defined function passed in through + * H5Eset_auto2(). A call to H5Eget_auto1() returns H5Eprint1() or the + * user-defined function passed in through H5Eset_auto1(). However, if + * the application passes in a user-defined function through + * H5Eset_auto1(), it should call H5Eget_auto1() to query the traversal + * function. If the application passes in a user-defined function + * through H5Eset_auto2(), it should call H5Eget_auto2() to query the + * traversal function. + * + * Mixing the new style and the old style functions will cause a + * failure. For example, if the application sets a user-defined + * old-style traversal function through H5Eset_auto1(), a call to + * H5Eget_auto2() will fail and will indicate that the application has + * mixed H5Eset_auto1() and H5Eget_auto2(). On the other hand, mixing + * H5Eset_auto2() and H5Eget_auto1() will also cause a failure. But if + * the traversal functions are the library’s default H5Eprint1() or + * 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); -H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Pushes a new error record onto the error stack + * + * \param[in] file Name of the file in which the error was detected + * \param[in] func Name of the function in which the error was detected + * \param[in] line Line number in the file where the error was detected + * \param[in] maj Major error identifier + * \param[in] min Minor error identifier + * \param[in] str Error description string + * \return \herr_t + * + * \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 + * and \p min_num, the function \p func where the error was detected, the + * name of the file \p file where the error was detected, the line \p line + * within that file, and an error description string \p str.\n + * The function name, filename, and error description strings must be statically + * 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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Prints the current error stack in a default manner + * + * \param[in] stream File pointer, or \c NULL for \c stderr + * \return \herr_t + * + * \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: + * \code{.unparsed} + * HDF5-DIAG: Error detected in thread 0. + * \endcode + * H5Eprint1() is a convenience function for H5Ewalk1() with a function + * 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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Turns automatic error printing on or off + * + * \param[in] func Function to be called upon an error condition + * \param[in] client_data Data passed to the error function + * \return \herr_t + * + * \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 + * client_data as an argument. + * + * \p func, a function conforming to the #H5E_auto1_t prototype, is + * defined in the H5Epublic.h source code file as: + * \snippet this H5E_auto1_t_snip + * + * When the library is first initialized, the auto printing function is + * set to H5Eprint1() (cast appropriately) and \p client_data is the + * standard error stream pointer, \c stderr. + * + * 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); -H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, - void *client_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Walks the current error stack, calling the specified function + * + * \param[in] direction Direction in which the error stack is to be walked + * \param[in] func Function to be called for each error encountered + * \param[in] client_data Data to be passed to \p func + * \return \herr_t + * + * \details H5Ewalk1() walks the error stack for the current thread and calls + * the function specified in \p func for each error along the way. + * + * \p direction specifies whether the stack is walked from the inside + * out or the outside in. A value of #H5E_WALK_UPWARD means to begin + * with the most specific error and end at the API; a value of + * #H5E_WALK_DOWNWARD means to start at the API and end at the + * innermost function where the error was first detected. + * + * \p func, a function conforming to the #H5E_walk1_t prototype, will + * be called for each error in the error stack. Its arguments will + * include an index number \c n (beginning at zero regardless of stack + * traversal direction), an error stack entry \c err_desc, and the \c + * client_data pointer passed to H5Eprint(). The #H5E_walk1_t prototype + * 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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Returns a character string describing an error specified by a major + * error number + * + * \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. + * + * \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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Returns a character string describing an error specified by a minor + * error number + * + * \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. + * + * \attention In the Release 1.8.x series, H5Eget_minor() returns a string of + * dynamic allocated \c char array. An application calling this + * function from an HDF5 library of Release 1.8.0 or later must free + * 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 */ @@ -222,5 +909,4 @@ H5_DLL char *H5Eget_minor(H5E_minor_t min); } #endif -#endif /* end _H5Epublic_H */ - +#endif /* end H5Epublic_H */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 63556a58673..4eff528d6ea 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,13 +15,14 @@ /* Add new errors to H5err.txt file */ -#ifndef _H5Eterm_H -#define _H5Eterm_H +#ifndef H5Eterm_H +#define H5Eterm_H /* Reset major error IDs */ H5E_FUNC_g= H5E_FILE_g= +H5E_VOL_g= H5E_SOHM_g= H5E_SYM_g= H5E_PLUGIN_g= @@ -34,10 +35,12 @@ H5E_RESOURCE_g= H5E_RS_g= H5E_FARRAY_g= H5E_HEAP_g= +H5E_MAP_g= H5E_ATTR_g= H5E_IO_g= H5E_EFL_g= H5E_TST_g= +H5E_LIB_g= H5E_PAGEBUF_g= H5E_FSPACE_g= H5E_DATASET_g= @@ -147,6 +150,7 @@ H5E_NOTHDF5_g= H5E_BADFILE_g= H5E_TRUNCATED_g= H5E_MOUNT_g= +H5E_CANTDELETEFILE_g= H5E_CANTLOCKFILE_g= H5E_CANTUNLOCKFILE_g= @@ -184,7 +188,6 @@ H5E_CANTDEPEND_g= H5E_CANTUNDEPEND_g= H5E_CANTNOTIFY_g= H5E_LOGGING_g= -H5E_LOGFAIL_g= H5E_CANTCORK_g= H5E_CANTUNCORK_g= diff --git a/src/H5F.c b/src/H5F.c index 2b3dba1f48b..3d044c50968 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,27 +15,22 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ @@ -45,33 +40,51 @@ /* Local Typedefs */ /******************/ +/* User data for traversal routine to get ID counts */ +typedef struct { + size_t obj_count; /* Number of objects counted so far */ + unsigned types; /* Types of objects to be counted */ +} H5F_trav_obj_cnt_t; + +/* User data for traversal routine to get ID lists */ +typedef struct { + size_t max_objs; /* Maximum # of IDs to record */ + hid_t *oid_list; /* Array of recorded IDs*/ + size_t obj_count; /* Number of objects counted so far */ +} H5F_trav_obj_ids_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ +/* Callback for getting object counts in a file */ +static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key); + +/* Callback for getting IDs for open objects in a file */ +static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); - /*------------------------------------------------------------------------- * Function: H5Fget_create_plist * @@ -81,34 +94,32 @@ * * Return: Success: Object ID for a copy of the file creation * property list. + * * Failure: H5I_INVALID_HID + * *------------------------------------------------------------------------- */ hid_t H5Fget_create_plist(hid_t file_id) { - H5F_t *file; /* File info */ - H5P_genplist_t *plist; /* Property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") - if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file creation property list") /* Retrieve the file creation property list */ - if((ret_value = H5P_copy_plist(plist, TRUE)) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Fget_access_plist * @@ -122,31 +133,56 @@ H5Fget_create_plist(hid_t file_id) * * Return: Success: Object ID for a copy of the file access * property list. + * * Failure: H5I_INVALID_HID + * *------------------------------------------------------------------------- */ hid_t H5Fget_access_plist(hid_t file_id) { - H5F_t *f; /* File info */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file's access property list */ - if((ret_value = H5F_get_access_plist(f, TRUE)) < 0) + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_access_plist() */ - +/*------------------------------------------------------------------------- + * Function: H5F__get_all_count_cb + * + * Purpose: Get counter of all object types currently open. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * + * Failure: H5_ITER_ERROR + * + *------------------------------------------------------------------------- + */ +static int +H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) +{ + H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + udata->obj_count++; + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_all_count_cb */ + /*------------------------------------------------------------------------- * Function: H5Fget_obj_count * @@ -154,76 +190,189 @@ H5Fget_access_plist(hid_t file_id) * (files, datasets, groups and datatypes) in the same file. * * Return: Success: The number of opened object IDs + * * Failure: -1 + * *------------------------------------------------------------------------- */ ssize_t H5Fget_obj_count(hid_t file_id, unsigned types) { - H5F_t *f = NULL; /* File to query */ - size_t obj_count = 0; /* Number of opened objects */ - ssize_t ret_value = 0; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE2("Zs", "iIu", file_id, types); /* Check arguments */ - if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file id") - if(0 == (types & H5F_OBJ_ALL)) + if (0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "H5F_get_obj_count failed") - - /* Set return value */ - ret_value = (ssize_t)obj_count; + /* If the 'special' ID wasn't passed in, just make a normal call to + * count the IDs in the file. + */ + if (file_id != (hid_t)H5F_OBJ_ALL) { + H5VL_object_t *vol_obj; + + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file id") + + /* Get the count */ + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, + &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object count in file(s)") + } + /* If we passed in the 'special' ID, get the count for everything open in the + * library, iterating over all open files and getting the object count for each. + */ + else { + H5F_trav_obj_cnt_t udata; + + /* Set up callback context */ + udata.types = types | H5F_OBJ_LOCAL; + udata.obj_count = 0; + + if (types & H5F_OBJ_FILE) + if (H5I_iterate(H5I_FILE, H5F__get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") + if (types & H5F_OBJ_DATASET) + if (H5I_iterate(H5I_DATASET, H5F__get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") + if (types & H5F_OBJ_GROUP) + if (H5I_iterate(H5I_GROUP, H5F__get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") + if (types & H5F_OBJ_DATATYPE) + if (H5I_iterate(H5I_DATATYPE, H5F__get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") + if (types & H5F_OBJ_ATTR) + if (H5I_iterate(H5I_ATTR, H5F__get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") + + /* Set return value */ + ret_value = (ssize_t)udata.obj_count; + } /* end else */ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_count() */ - +/*------------------------------------------------------------------------- + * Function: H5F__get_all_ids_cb + * + * Purpose: Get IDs of all currently open objects of a given type. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * + * Failure: H5_ITER_ERROR + * + *------------------------------------------------------------------------- + */ +static int +H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key) +{ + H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + if (udata->obj_count >= udata->max_objs) + HGOTO_DONE(H5_ITER_STOP); + + /* Add the ID to the array */ + udata->oid_list[udata->obj_count] = obj_id; + udata->obj_count++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F__get_all_ids_cb */ + /*------------------------------------------------------------------------- * Function: H5Fget_object_ids * * Purpose: Public function to return a list of opened object IDs. * + * NOTE: Type mismatch - You can ask for more objects than can be + * returned. + * + * NOTE: Currently, the IDs' ref counts are not incremented. Is this + * intentional and documented? + * * Return: Success: The number of IDs in oid_list + * * Failure: -1 + * *------------------------------------------------------------------------- */ ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) { - H5F_t *f = NULL; /* File to query */ - size_t obj_id_count = 0; /* Number of open objects */ - ssize_t ret_value = 0; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iIuz*i", file_id, types, max_objs, oid_list); /* Check arguments */ - if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file id") - if(0 == (types & H5F_OBJ_ALL)) + if (0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") - if(!oid_list) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "object ID list is NULL") + if (!oid_list) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "object ID list cannot be NULL") /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_id_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "H5F_get_obj_ids failed") + /* If the 'special' ID wasn't passed in, just make a normal VOL call to + * get the IDs from the file. + */ + if (file_id != (hid_t)H5F_OBJ_ALL) { + H5VL_object_t *vol_obj; - /* Set the return value */ - ret_value = (ssize_t)obj_id_count; + /* get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") + + /* Get the IDs */ + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_IDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, + max_objs, oid_list, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object ids in file(s)") + } /* end if */ + /* If we passed in the 'special' ID, get the count for everything open in the + * library, iterating over all open files and getting the object count for each. + * + * XXX: Note that the RM states that passing in a negative value for max_objs + * gets you all the objects. This technically works, but is clearly wrong + * behavior since max_objs is an unsigned type. + */ + else { + H5F_trav_obj_ids_t udata; + + /* Set up callback context */ + udata.max_objs = max_objs; + udata.oid_list = oid_list; + udata.obj_count = 0; + + if (types & H5F_OBJ_FILE) + if (H5I_iterate(H5I_FILE, H5F__get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") + if (types & H5F_OBJ_DATASET) + if (H5I_iterate(H5I_DATASET, H5F__get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") + if (types & H5F_OBJ_GROUP) + if (H5I_iterate(H5I_GROUP, H5F__get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") + if (types & H5F_OBJ_DATATYPE) + if (H5I_iterate(H5I_DATATYPE, H5F__get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") + if (types & H5F_OBJ_ATTR) + if (H5I_iterate(H5I_ATTR, H5F__get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") + + /* Set return value */ + ret_value = (ssize_t)udata.obj_count; + } /* end else */ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_ids() */ - /*------------------------------------------------------------------------- * Function: H5Fget_vfd_handle * @@ -237,37 +386,33 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) { - H5F_t *file; /* File to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii**x", file_id, fapl_id, file_handle); /* Check args */ - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(file, fapl_id, file_handle) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_VFD_HANDLE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, file_handle, fapl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_vfd_handle() */ - /*------------------------------------------------------------------------- - * Function: H5Fis_hdf5 - * - * Purpose: Check the file signature to detect an HDF5 file. + * Function: H5Fis_accessible * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Purpose: Check if the file can be opened with the given fapl. * * Return: Success: TRUE/FALSE * Failure: -1 (includes file does not exist) @@ -275,27 +420,32 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) *------------------------------------------------------------------------- */ htri_t -H5Fis_hdf5(const char *name) +H5Fis_accessible(const char *filename, hid_t fapl_id) { - htri_t ret_value; /* Return value */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("t", "*s", name); + H5TRACE2("t", "*si", filename, fapl_id); - /* Check args and all the boring stuff. */ - if(!name || !*name) + /* Check args */ + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") - /* call the private is_HDF5 function */ - /* (Should not trigger raw data I/O - QAK, 2018/01/03) */ - if((ret_value = H5F__is_hdf5(name)) < 0) + /* Check the file access property list */ + if (H5P_DEFAULT == fapl_id) + fapl_id = H5P_FILE_ACCESS_DEFAULT; + else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + + /* Check if file is accessible */ + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") done: FUNC_LEAVE_API(ret_value) -} /* end H5Fis_hdf5() */ +} /* end H5Fis_accessible() */ - /*------------------------------------------------------------------------- * Function: H5Fcreate * @@ -322,64 +472,86 @@ H5Fis_hdf5(const char *name) hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /* File struct for new file */ - hid_t ret_value; /* return value */ + 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 */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); /* Check/fix arguments */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") /* In this routine, we only accept the following flags: * H5F_ACC_EXCL, H5F_ACC_TRUNC and H5F_ACC_SWMR_WRITE */ - if(flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE)) + if (flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid flags") /* The H5F_ACC_EXCL and H5F_ACC_TRUNC flags are mutually exclusive */ - if((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) + if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "mutually exclusive flags for file creation") /* Check file creation property list */ - if(H5P_DEFAULT == fcpl_id) + if (H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list") + else if (TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") + /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ - if(0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ + if (0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - /* Create a new file or truncate an existing file */ - if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id))) + /* Create a new file or truncate an existing file through the VOL */ + if (NULL == (new_file = H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file") /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier") + + /* Make the 'post open' callback */ + supported = FALSE; + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: - if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") - FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ - /*------------------------------------------------------------------------- * Function: H5Fopen * @@ -400,48 +572,74 @@ 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) { - H5F_t *new_file = NULL; /* file struct for new file */ - hid_t ret_value; /* Return value */ + 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 */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*sIui", filename, flags, fapl_id); /* Check arguments */ - if(!filename || !*filename) + if (!filename || !*filename) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") /* Reject undefined flags (~H5F_ACC_PUBLIC_FLAGS) and the H5F_ACC_TRUNC & H5F_ACC_EXCL flags */ - if((flags & ~H5F_ACC_PUBLIC_FLAGS) || - (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) + if ((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") + /* XXX (VOL MERGE): Might want to move SWMR flag checks to H5F_open() */ /* Asking for SWMR write access on a read-only file is invalid */ - if((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR write access on a file open for read-only access is not allowed") + if ((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, + "SWMR write access on a file open for read-only access is not allowed") /* Asking for SWMR read access on a non-read-only file is invalid */ - if((flags & H5F_ACC_SWMR_READ) && (flags & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR read access on a file open for read-write access is not allowed") + if ((flags & H5F_ACC_SWMR_READ) && (flags & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, + "SWMR read access on a file open for read-write access is not allowed") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Open the file */ - if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") + + /* Open the file through the VOL layer */ + if (NULL == (new_file = H5VL_file_open(&connector_prop, filename, flags, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") /* Get an ID for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") + + /* Make the 'post open' callback */ + supported = FALSE; + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: - if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ - /*------------------------------------------------------------------------- * Function: H5Fflush * @@ -456,114 +654,32 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { - H5F_t *f = NULL; /* File to flush */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object info */ + H5I_type_t obj_type; /* Type of object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); - switch(H5I_get_type(object_id)) { - case H5I_FILE: - if(NULL == (f = (H5F_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - break; - - case H5I_GROUP: - { - H5G_t *grp; - - if(NULL == (grp = (H5G_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") - oloc = H5G_oloc(grp); - } - break; - - case H5I_DATATYPE: - { - H5T_t *type; - - if(NULL == (type = (H5T_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") - oloc = H5T_oloc(type); - } - break; - - case H5I_DATASET: - { - H5D_t *dset; - - if(NULL == (dset = (H5D_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - oloc = H5D_oloc(dset); - } - break; - - case H5I_ATTR: - { - H5A_t *attr; - - if(NULL == (attr = (H5A_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") - oloc = H5A_oloc(attr); - } - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* end switch */ - - if(!f) { - if(!oloc) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file") - f = oloc->file; - } /* end if */ - if(!f) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") - - /* Flush the file */ - /* - * Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - hid_t fapl_id = H5P_DEFAULT; /* FAPL to use */ - - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, object_id, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access property list info") - - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ - else - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end if */ + /* Get the type of object we're flushing + sanity check */ + obj_type = H5I_get_type(object_id); + if (H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && + H5I_DATASET != obj_type && H5I_ATTR != obj_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Flush the object */ + if (H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)obj_type, + (int)scope) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fflush() */ - /*------------------------------------------------------------------------- * Function: H5Fclose * @@ -581,24 +697,79 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) herr_t H5Fclose(hid_t file_id) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check arguments */ - if(H5I_FILE != H5I_get_type(file_id)) + if (H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") /* Close the file */ - if(H5F__close(file_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "closing file ID failed") + if (H5I_dec_app_ref(file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Fclose() */ - +/*------------------------------------------------------------------------- + * Function: H5Fdelete + * + * Purpose: Deletes an HDF5 file. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fdelete(const char *filename, hid_t fapl_id) +{ + 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; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "*si", filename, fapl_id); + + /* Check args */ + if (!filename || !*filename) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") + + /* Make sure this is HDF5 storage for this VOL connector */ + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &is_hdf5) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") + if (!is_hdf5) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "not an HDF5 file") + + /* Delete the file */ + if (H5VL_file_specific(NULL, H5VL_FILE_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, + filename, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETEFILE, FAIL, "unable to delete the file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fdelete() */ + /*------------------------------------------------------------------------- * Function: H5Freopen * @@ -609,47 +780,55 @@ H5Fclose(hid_t file_id) * anywhere and no files are mounted on it. * * Return: Success: New file ID + * * Failure: H5I_INVALID_HID + * *------------------------------------------------------------------------- */ hid_t H5Freopen(hid_t file_id) { - H5F_t *old_file = NULL; - H5F_t *new_file = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); - /* Check arguments */ - if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") - /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F__new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") + /* Reopen the file */ + if (H5VL_file_specific(vol_obj, H5VL_FILE_REOPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL connector") - /* Duplicate old file's names */ - new_file->open_name = H5MM_xstrdup(old_file->open_name); - new_file->actual_name = H5MM_xstrdup(old_file->actual_name); - new_file->extpath = H5MM_xstrdup(old_file->extpath); + /* Make sure that worked */ + if (NULL == file) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register an ID for file handle") + /* Get an atom for the file */ + if ((ret_value = H5VL_register(H5I_FILE, file, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier") + + /* Make the 'post open' callback */ + supported = FALSE; + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback") done: - if(ret_value < 0 && new_file) - if(H5F__dest(new_file, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "can't close file") - FUNC_LEAVE_API(ret_value) } /* end H5Freopen() */ - /*------------------------------------------------------------------------- * Function: H5Fget_intent * @@ -669,38 +848,59 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) H5TRACE2("e", "i*Iu", file_id, intent_flags); /* If no intent flags were passed in, exit quietly */ - if(intent_flags) { - H5F_t *file; /* Pointer to file structure */ + if (intent_flags) { + H5VL_object_t *vol_obj; /* File info */ /* Get the internal file structure */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY. - */ - if(H5F_INTENT(file) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } /* end if */ - else { - *intent_flags = H5F_ACC_RDONLY; - - /* Check for SWMR read access on the file */ - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } /* end else */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* Get the flags */ + if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_INTENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, intent_flags)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags") } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_intent() */ - +/*------------------------------------------------------------------------- + * Function: H5Fget_fileno + * + * Purpose: Public API to retrieve the file's 'file number' that uniquely + * identifies each open file. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_fileno(hid_t file_id, unsigned long *fnumber) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*Ul", file_id, fnumber); + + /* If no fnumber pointer was passed in, exit quietly */ + if (fnumber) { + H5VL_object_t *vol_obj; /* File info */ + + /* Get the internal file structure */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* Get the flags */ + if ((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fnumber)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's 'file number'") + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fget_fileno() */ + /*------------------------------------------------------------------------- * Function: H5Fget_freespace * @@ -713,28 +913,25 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) hssize_t H5Fget_freespace(hid_t file_id) { - H5F_t *file; /* File object for file ID */ - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; + hssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Hs", "i", file_id); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the amount of free space in the file */ - if(H5MF_get_freespace(file, &tot_space, NULL) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SPACE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") - ret_value = (hssize_t)tot_space; - done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_freespace() */ - /*------------------------------------------------------------------------- * Function: H5Fget_filesize * @@ -749,32 +946,27 @@ H5Fget_freespace(hid_t file_id) herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { - H5F_t *file; /* File object for file ID */ - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", file_id, size); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (!size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size parameter cannot be NULL") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the file size */ - if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - base_addr = H5FD_get_base_addr(file->shared->lf); - - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ - done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_filesize() */ - /*------------------------------------------------------------------------- * Function: H5Fget_file_image * @@ -813,28 +1005,27 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) *------------------------------------------------------------------------- */ ssize_t -H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) +H5Fget_file_image(hid_t file_id, void *buf, size_t buf_len) { - H5F_t *file; /* File object for file ID */ - ssize_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* File object for file ID */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) - H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); + H5TRACE3("Zs", "i*xz", file_id, buf, buf_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") - /* call private get_file_image function */ - /* (Should not trigger raw data I/O - QAK, 2018/01/03) */ - if((ret_value = H5F__get_file_image(file, buf_ptr, buf_len)) < 0) + /* Get the file image */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FILE_IMAGE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, buf, &ret_value, buf_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_file_image() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_config * @@ -850,29 +1041,31 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) +H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", file_id, config_ptr); + H5TRACE2("e", "i*x", file_id, config); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") + if ((NULL == config) || (config->version != H5AC__CURR_CACHE_CONFIG_VERSION)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad configptr") + + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the metadata cache configuration */ - if(H5AC_get_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_CONF, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + config) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Fset_mdc_config * @@ -887,25 +1080,25 @@ H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set the metadata cache configuration */ - if(H5AC_set_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MDC_CONFIG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: FUNC_LEAVE_API(ret_value) } /* H5Fset_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_hit_rate * @@ -919,29 +1112,29 @@ H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) +H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*d", file_id, hit_rate_ptr); + H5TRACE2("e", "i*d", file_id, hit_rate); /* Check args */ - if(NULL == hit_rate_ptr) + if (NULL == hit_rate) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the current hit rate */ - if(H5AC_get_cache_hit_rate(file->shared->cache, hit_rate_ptr) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_HR, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + hit_rate) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_hit_rate() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_size * @@ -956,32 +1149,28 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, - size_t *cur_size_ptr, int *cur_num_entries_ptr) +H5Fget_mdc_size(hid_t file_id, size_t *max_size, size_t *min_clean_size, size_t *cur_size, + int *cur_num_entries) { - H5F_t *file; /* File object for file ID */ - uint32_t cur_num_entries; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*z*z*z*Is", file_id, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, cur_num_entries_ptr); + H5TRACE5("e", "i*z*z*z*Is", file_id, max_size, min_clean_size, cur_size, cur_num_entries); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the size data */ - if(H5AC_get_cache_size(file->shared->cache, max_size_ptr, min_clean_size_ptr, cur_size_ptr, &cur_num_entries) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + max_size, min_clean_size, cur_size, cur_num_entries) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_size() */ - /*------------------------------------------------------------------------- * Function: H5Freset_mdc_hit_rate_stats * @@ -1001,25 +1190,25 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(file->shared->cache) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: FUNC_LEAVE_API(ret_value) } /* H5Freset_mdc_hit_rate_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_name * @@ -1040,48 +1229,34 @@ H5Freset_mdc_hit_rate_stats(hid_t file_id) *------------------------------------------------------------------------- */ ssize_t -H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) +H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) { - H5F_t *f; /* Top file in mount hierarchy */ - size_t len; - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a valid object ID") - f = loc.oloc->file; - } /* end else */ - - len = HDstrlen(H5F_OPEN_NAME(f)); + /* Check the type */ + type = H5I_get_type(obj_id); + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file or file object") - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") - /* Set return value */ - ret_value = (ssize_t)len; + /* Get the filename via the VOL */ + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, + name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ - /*------------------------------------------------------------------------- * Function: H5Fget_info2 * @@ -1098,43 +1273,36 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); /* Check args */ - if(!finfo) + if (!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file info pointer can't be NULL") - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ + /* Check the type */ + type = H5I_get_type(obj_id); + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - f = loc.oloc->file; - } /* end else */ - HDassert(f->shared); + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Get the file info */ - if(H5F__get_info(f, finfo) < 0) + /* Get the file information */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)type, finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info2() */ - /*------------------------------------------------------------------------- * Function: H5Fget_metadata_read_retry_info * @@ -1148,29 +1316,29 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File object for file ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, info); /* Check args */ - if(!info) + if (!info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Get the file pointer */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the retry info */ - if(H5F__get_metadata_read_retry_info(file, info) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_metadata_read_retry_info() */ - /*------------------------------------------------------------------------- * Function: H5Fget_free_sections * @@ -1184,30 +1352,29 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) *------------------------------------------------------------------------- */ ssize_t -H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, - H5F_sect_info_t *sect_info/*out*/) +H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info /*out*/) { - H5F_t *file; /* Top file in mount hierarchy */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj = NULL; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") - if(sect_info && nsects == 0) + if (sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") /* Get the free-space section information in the file */ - if((ret_value = H5MF_get_free_sections(file, type, nsects, sect_info)) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, sect_info, &ret_value, (int)type, nsects) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_free_sections() */ - /*------------------------------------------------------------------------- * Function: H5Fclear_elink_file_cache * @@ -1222,31 +1389,55 @@ H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, herr_t H5Fclear_elink_file_cache(hid_t file_id) { - H5F_t *file; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ - if(file->shared->efc) - if(H5F__efc_release(file->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: FUNC_LEAVE_API(ret_value) } /* end H5Fclear_elink_file_cache() */ - /*------------------------------------------------------------------------- * Function: H5Fstart_swmr_write * * Purpose: To enable SWMR writing mode for the file * + * 1) Refresh opened objects: part 1 + * 2) Flush & reset accumulator + * 3) Mark the file in SWMR writing mode + * 4) Set metadata read attempts and retries info + * 5) Disable accumulator + * 6) Evict all cache entries except the superblock + * 7) Refresh opened objects (part 2) + * 8) Unlock the file + * + * Pre-conditions: + * + * 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: + * --only allow datasets and groups without attributes + * --disallow named datatype with/without attributes + * --disallow opened attributes attached to objects + * + * NOTE: Currently, only opened groups and datasets are allowed + * when enabling SWMR via H5Fstart_swmr_write(). + * Will later implement a different approach-- + * set up flush dependency/proxy even for file opened without + * SWMR to resolve issues with opened objects. + * * Return: Success: Non-negative * Failure: Negative *------------------------------------------------------------------------- @@ -1254,29 +1445,29 @@ H5Fclear_elink_file_cache(hid_t file_id) herr_t H5Fstart_swmr_write(hid_t file_id) { - H5F_t *file = NULL; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Start SWMR writing */ - if(H5F__start_swmr_write(file) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_SWMR_WRITE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: FUNC_LEAVE_API(ret_value) } /* end H5Fstart_swmr_write() */ - /*------------------------------------------------------------------------- * Function: H5Fstart_mdc_logging * @@ -1290,25 +1481,25 @@ H5Fstart_swmr_write(hid_t file_id) herr_t H5Fstart_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5C_start_logging(file->shared->cache) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_START_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") done: FUNC_LEAVE_API(ret_value) } /* H5Fstart_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5Fstop_mdc_logging * @@ -1323,25 +1514,25 @@ H5Fstart_mdc_logging(hid_t file_id) herr_t H5Fstop_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5C_stop_logging(file->shared->cache) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_STOP_MDC_LOGGING, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") done: FUNC_LEAVE_API(ret_value) } /* H5Fstop_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_logging_status * @@ -1354,28 +1545,27 @@ H5Fstop_mdc_logging(hid_t file_id) *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, - hbool_t *is_currently_logging) +H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, hbool_t *is_currently_logging) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*b", file_id, is_enabled, is_currently_logging); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - /* Call MDC logging function */ - if(H5C_get_logging_status(file->shared->cache, is_enabled, is_currently_logging) < 0) + /* Call mdc logging function */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, is_enabled, is_currently_logging) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_logging_status() */ - /*------------------------------------------------------------------------- * Function: H5Fset_libver_bounds * @@ -1391,29 +1581,29 @@ H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { - H5F_t *f; /* File */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File as VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", file_id, low, high); /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the library's version bounds */ - if(H5F__set_libver_bounds(f, low, high) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, low, high) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) } /* end H5Fset_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Fformat_convert (Internal) * @@ -1428,33 +1618,29 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) herr_t H5Fformat_convert(hid_t file_id) { - H5F_t *f; /* File to flush */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(H5I_FILE != H5I_get_type(file_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Get file object */ - if(NULL == (f = (H5F_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "file_id parameter is not a valid file identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(file_id) < 0) + if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the format */ - if(H5F__format_convert(f) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_FORMAT_CONVERT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: FUNC_LEAVE_API(ret_value) } /* end H5Fformat_convert() */ - /*------------------------------------------------------------------------- * Function: H5Freset_page_buffering_stats * @@ -1467,27 +1653,25 @@ H5Fformat_convert(hid_t file_id) herr_t H5Freset_page_buffering_stats(hid_t file_id) { - H5F_t *file; /* File to reset stats on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File to reset stats on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object(file_id))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if(NULL == file->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") /* Reset the statistics */ - if(H5PB_reset_stats(file->shared->page_buf) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: FUNC_LEAVE_API(ret_value) -} /* H5Freset_page_buffering_stats() */ +} /* H5Freset_page_buffering_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_page_buffering_stats * @@ -1498,33 +1682,30 @@ H5Freset_page_buffering_stats(hid_t file_id) *------------------------------------------------------------------------- */ herr_t -H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], - unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], unsigned misses[2], + unsigned evictions[2], unsigned bypasses[2]) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions, - bypasses); + H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions, bypasses); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if(NULL == file->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") - if(NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) + if (NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") /* Get the statistics */ - if(H5PB_get_stats(file->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, accesses, hits, misses, evictions, bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_page_buffering_stats() */ - /*------------------------------------------------------------------------- * Function: H5Fget_mdc_image_info * @@ -1541,27 +1722,25 @@ H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2 herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*a*h", file_id, image_addr, image_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - if(NULL == image_addr || NULL == image_len) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL image addr or image len") /* Go get the address and size of the cache image */ - if(H5AC_get_mdc_image_info(file->shared->cache, image_addr, image_len) < 0) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, image_addr, image_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_image_info() */ - /*------------------------------------------------------------------------- * Function: H5Fget_eoa * @@ -1576,34 +1755,28 @@ H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa) { - H5F_t *file; /* File object for file ID */ - haddr_t rel_eoa; /* Relative address of EOA */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*a", file_id, eoa); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* The real work */ - if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + /* Only do work if valid pointer to fill in */ + if (eoa) { + /* Retrieve the EOA for the file */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_EOA, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") + } /* end if */ - /* (Note compensating for base address subtraction in internal routine) */ - if(eoa) - *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf); done: FUNC_LEAVE_API(ret_value) } /* H5Fget_eoa() */ - /*------------------------------------------------------------------------- * Function: H5Fincrement_filesize * @@ -1616,36 +1789,25 @@ H5Fget_eoa(hid_t file_id, haddr_t *eoa) herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment) { - H5F_t *file; /* File object for file ID */ - haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", file_id, increment); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* Get the maximum of EOA and EOF */ - if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - /* Set EOA to the maximum value + increment */ - /* H5FD_set_eoa() will add base_addr to max_eof_eoa */ - if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + /* Increment the file size */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_INCR_FILESIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to increment file size") done: FUNC_LEAVE_API(ret_value) } /* H5Fincrement_filesize() */ - /*------------------------------------------------------------------------- * Function: H5Fget_dset_no_attrs_hint * @@ -1659,26 +1821,27 @@ H5Fincrement_filesize(hid_t file_id, hsize_t increment) herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize) { - H5F_t *file = NULL; /* File object for file ID */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", file_id, minimize); - if(NULL == minimize) + if (NULL == minimize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "out pointer 'minimize' cannot be NULL") - file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == file) + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - *minimize = H5F_GET_MIN_DSET_OHDR(file); + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: FUNC_LEAVE_API(ret_value) } /* H5Fget_dset_no_attrs_hint */ - /*------------------------------------------------------------------------- * Function: H5Fset_dset_no_attrs_hint * @@ -1692,19 +1855,20 @@ H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize) herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize) { - H5F_t *file = NULL; /* File object for file ID */ + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, minimize); - file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); - if(NULL == file) + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - H5F_SET_MIN_DSET_OHDR(file, minimize); + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") done: FUNC_LEAVE_API(ret_value) } /* H5Fset_dset_no_attrs_hint */ - diff --git a/src/H5FA.c b/src/H5FA.c index ee99bb2a109..05b0bd8a1e8 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,45 +27,38 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static H5FA_t *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); /*********************/ /* Package Variables */ @@ -80,17 +73,15 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * client class.. */ const H5FA_class_t *const H5FA_client_class_g[] = { - H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ - H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ - H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ + H5FA_CLS_CHUNK, /* 0 - H5FA_CLS_CHUNK_ID */ + H5FA_CLS_FILT_CHUNK, /* 1 - H5FA_CLS_FILT_CHUNK_ID */ + H5FA_CLS_TEST, /* ? - H5FA_CLS_TEST_ID */ }; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -101,8 +92,6 @@ H5FL_DEFINE_STATIC(H5FA_t); /* Declare a PQ free list to manage the element */ H5FL_BLK_DEFINE(fa_native_elmt); - - /*------------------------------------------------------------------------- * Function: H5FA__new * @@ -116,13 +105,12 @@ 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)) +BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, + H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t * fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ /* * Check arguments. @@ -131,25 +119,25 @@ H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) 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") + if (NULL == (fa = H5FL_CALLOC(H5FA_t))) + H5E_THROW(H5E_CANTALLOC, "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") + 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") /* Check for pending array deletion */ - if(from_open && hdr->pending_delete) + if (from_open && hdr->pending_delete) H5E_THROW(H5E_CANTOPENOBJ, "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") + if (H5FA__hdr_incr(fa->hdr) < 0) + H5E_THROW(H5E_CANTINC, "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") + if (H5FA__hdr_fuse_incr(fa->hdr) < 0) + H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -157,17 +145,16 @@ H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ +END_FUNC(STATIC) /* end H5FA__new() */ - /*------------------------------------------------------------------------- * Function: H5FA_create * @@ -181,13 +168,12 @@ 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)) +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 *fa = NULL; /* Pointer to new fixed array */ - haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *fa = NULL; /* Pointer to new fixed array */ + haddr_t fa_addr; /* Fixed array header address */ /* * Check arguments. @@ -199,25 +185,24 @@ H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) HDcompile_assert(H5FA_NUM_CLS_ID == NELMTS(H5FA_client_class_g)); /* Create fixed array header */ - if(HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) + if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) H5E_THROW(H5E_CANTINIT, "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") + if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ +END_FUNC(PRIV) /* end H5FA_create() */ - /*------------------------------------------------------------------------- * Function: H5FA_open * @@ -231,12 +216,10 @@ 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)) +BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ /* * Check arguments. @@ -245,21 +228,20 @@ H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) 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") + if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) + H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; -CATCH + CATCH - if(!ret_value) - if(fa && H5FA_close(fa) < 0) + if (!ret_value) + if (fa && H5FA_close(fa) < 0) H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ +END_FUNC(PRIV) /* end H5FA_open() */ - /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts * @@ -272,9 +254,7 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) /* Local variables */ @@ -287,9 +267,8 @@ H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ +END_FUNC(PRIV) /* end H5FA_get_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5FA_get_addr * @@ -302,9 +281,7 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) /* Local variables */ @@ -318,9 +295,8 @@ H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ +END_FUNC(PRIV) /* end H5FA_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5FA_set * @@ -333,17 +309,16 @@ 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)) +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 */ - 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 */ + 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 */ /* * Check arguments. @@ -355,80 +330,84 @@ H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) hdr->f = fa->f; /* Check if we need to create the fixed array data block */ - if(!H5F_addr_defined(hdr->dblk_addr)) { + if (!H5F_addr_defined(hdr->dblk_addr)) { /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); - if(!H5F_addr_defined(hdr->dblk_addr)) + if (!H5F_addr_defined(hdr->dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") } /* end if */ 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) + 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) /* Check for paging data block */ - if(!dblock->npages) { + if (!dblock->npages) { /* Set element in data block */ - H5MM_memcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, + hdr->cparam.cls->nat_elmt_size); dblock_cache_flags |= H5AC__DIRTIED_FLAG; - } /* end if */ - else { /* paging */ - size_t page_idx; /* Index of page within data block */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - size_t elmt_idx; /* Element index within the page */ - haddr_t dblk_page_addr; /* Address of data block page */ + } /* end if */ + else { /* paging */ + size_t page_idx; /* Index of page within data block */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + size_t elmt_idx; /* Element index within the page */ + haddr_t dblk_page_addr; /* Address of data block page */ /* Compute the page & element index */ page_idx = (size_t)(idx / dblock->dblk_page_nelmts); elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts); /* Get the address of the data block page */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + - ((hsize_t)page_idx * dblock->dblk_page_size); + dblk_page_addr = + dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size); /* Check for using last page, to set the number of elements on the page */ - if((page_idx + 1) == dblock->npages) + if ((page_idx + 1) == dblock->npages) dblk_page_nelmts = dblock->last_page_nelmts; else dblk_page_nelmts = dblock->dblk_page_nelmts; /* Check if the page has been created yet */ - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + 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) + if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) H5E_THROW(H5E_CANTCREATE, "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); - dblock_cache_flags |= H5AC__DIRTIED_FLAG; - } /* end if */ + /* Mark data block page as initialized in data block */ + H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); + dblock_cache_flags |= H5AC__DIRTIED_FLAG; + } /* end if */ /* 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) + 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) /* Set the element in the data block page */ - H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, + hdr->cparam.cls->nat_elmt_size); dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ -CATCH + CATCH /* Check for header modified */ - if(hdr_dirty) - if(H5FA__hdr_modified(hdr) < 0) + if (hdr_dirty) + if (H5FA__hdr_modified(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") /* Release resources */ - if(dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) + if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) + 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") -END_FUNC(PRIV) /* end H5FA_set() */ +END_FUNC(PRIV) /* end H5FA_set() */ - /*------------------------------------------------------------------------- * Function: H5FA_get * @@ -441,14 +420,12 @@ 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)) +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 */ - H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + 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 */ /* * Check arguments. @@ -460,72 +437,78 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) hdr->f = fa->f; /* Check if the fixed array data block has been allocated on disk yet */ - if(!H5F_addr_defined(hdr->dblk_addr)) { + if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ - if((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "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) + 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) /* Check for paged data block */ - if(!dblock->npages) + if (!dblock->npages) /* Retrieve element from data block */ - H5MM_memcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), hdr->cparam.cls->nat_elmt_size); - else { /* paging */ - size_t page_idx; /* Index of page within data block */ + H5MM_memcpy(elmt, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), + hdr->cparam.cls->nat_elmt_size); + else { /* paging */ + size_t page_idx; /* Index of page within data block */ /* Compute the page index */ page_idx = (size_t)(idx / dblock->dblk_page_nelmts); /* Check if the page is defined yet */ - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + 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) + if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") /* We've retrieved the value, leave now */ H5_LEAVE(SUCCEED) - } /* end if */ - else { /* get the page */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - size_t elmt_idx; /* Element index within the page */ - haddr_t dblk_page_addr; /* Address of data block page */ + } /* end if */ + else { /* get the page */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + size_t elmt_idx; /* Element index within the page */ + haddr_t dblk_page_addr; /* Address of data block page */ /* Compute the element index */ elmt_idx = (size_t)(idx % dblock->dblk_page_nelmts); /* Compute the address of the data block */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + ((hsize_t)page_idx * dblock->dblk_page_size); + dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock) + + ((hsize_t)page_idx * dblock->dblk_page_size); /* Check for using last page, to set the number of elements on the page */ - if((page_idx + 1) == dblock->npages) + if ((page_idx + 1) == dblock->npages) dblk_page_nelmts = dblock->last_page_nelmts; else dblk_page_nelmts = dblock->dblk_page_nelmts; /* 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) + 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) /* Retrieve element from data block */ - H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), hdr->cparam.cls->nat_elmt_size); + H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), + hdr->cparam.cls->nat_elmt_size); } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ -CATCH - if(dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + CATCH + if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + 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") -END_FUNC(PRIV) /* end H5FA_get() */ +END_FUNC(PRIV) /* end H5FA_get() */ - /*------------------------------------------------------------------------- * Function: H5FA_close * @@ -538,13 +521,11 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_close(H5FA_t *fa)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Local variables */ - hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ - haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ + haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ /* * Check arguments. @@ -552,46 +533,47 @@ H5FA_close(H5FA_t *fa)) HDassert(fa); /* 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 */ - if(0 == H5FA__hdr_fuse_decr(fa->hdr)) { + if (fa->hdr) { + /* Decrement file reference & check if this is the last open fixed array using the shared array header + */ + if (0 == H5FA__hdr_fuse_decr(fa->hdr)) { /* Set the shared array header's file context for this operation */ fa->hdr->f = fa->f; /* Shut down anything that can't be put in the header's 'flush' callback */ /* Check for pending array deletion */ - if(fa->hdr->pending_delete) { + if (fa->hdr->pending_delete) { /* Set local info, so array deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - fa_addr = fa->hdr->addr; + fa_addr = fa->hdr->addr; } /* end if */ - } /* end if */ + } /* end if */ /* Check for pending array deletion */ - if(pending_delete) { - H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ + if (pending_delete) { + H5FA_hdr_t *hdr; /* Another pointer to fixed array header */ #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Header's status in the metadata cache */ - - /* 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") - - /* Sanity checks on header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PINNED); - HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); -} + { + unsigned hdr_status = 0; /* Header's status in the metadata cache */ + + /* 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") + + /* Sanity checks on header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PINNED); + HDassert(!(hdr_status & H5AC_ES__IS_PROTECTED)); + } #endif /* NDEBUG */ /* 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))) + 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") /* Set the shared array header's file context for this operation */ @@ -601,11 +583,11 @@ H5FA_close(H5FA_t *fa)) /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5FA__hdr_decr(fa->hdr) < 0) + if (H5FA__hdr_decr(fa->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ - if(H5FA__hdr_delete(hdr) < 0) + if (H5FA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") } /* end if */ else { @@ -613,19 +595,18 @@ H5FA_close(H5FA_t *fa)) /* (don't put in H5FA_hdr_fuse_decr() as the array header may be evicted * immediately -QAK) */ - if(H5FA__hdr_decr(fa->hdr) < 0) + if (H5FA__hdr_decr(fa->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") } /* end else */ - } /* end if */ + } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); -CATCH + CATCH -END_FUNC(PRIV) /* end H5FA_close() */ +END_FUNC(PRIV) /* end H5FA_close() */ - /*------------------------------------------------------------------------- * Function: H5FA_delete * @@ -638,12 +619,10 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ /* * Check arguments. @@ -652,31 +631,31 @@ H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) 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) + 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) /* Check for files using shared array header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Set the shared array header's file context for this operation */ hdr->f = f; /* Delete array now, starting with header (unprotects header) */ - if(H5FA__hdr_delete(hdr) < 0) + if (H5FA__hdr_delete(hdr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") hdr = NULL; } /* end if */ -CATCH + CATCH /* Unprotect the header, if an error occurred */ - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ +END_FUNC(PRIV) /* end H5FA_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA_iterate * @@ -692,14 +671,13 @@ 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)) +BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, + H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) /* Local variables */ - uint8_t *elmt = NULL; - hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + uint8_t *elmt = NULL; + hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ /* * Check arguments. @@ -709,30 +687,29 @@ H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) 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))) + 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") /* 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 && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ - if(H5FA_get(fa, u, elmt) < 0) + if (H5FA_get(fa, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if ((cb_ret = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); H5_LEAVE(cb_ret) } /* end if */ - } /* end for */ + } /* end for */ -CATCH + CATCH - if(elmt) + if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ +END_FUNC(PRIV) /* end H5FA_iterate() */ - /*------------------------------------------------------------------------- * Function: H5FA_depend * @@ -746,12 +723,10 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ /* * Check arguments. @@ -765,7 +740,7 @@ H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) * and another data structure in the file has already been set up. * If it hasn't, do so now. */ - if(NULL == hdr->parent) { + if (NULL == hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); @@ -773,16 +748,15 @@ H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) hdr->f = fa->f; /* Add the fixed array as a child of the parent (proxy) */ - if(H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) + 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") hdr->parent = parent; } /* end if */ -CATCH + CATCH -END_FUNC(PRIV) /* end H5FA_depend() */ +END_FUNC(PRIV) /* end H5FA_depend() */ - /*------------------------------------------------------------------------- * Function: H5FA_patch_file * @@ -795,9 +769,7 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) /* Local variables */ @@ -807,7 +779,7 @@ H5FA_patch_file(H5FA_t *fa, H5F_t *f)) HDassert(fa); HDassert(f); - if(fa->f != f || fa->hdr->f != f) + if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ +END_FUNC(PRIV) /* end H5FA_patch_file() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 90770fb6caf..1b127c73a07 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,45 +26,39 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fixed Array format version #'s */ -#define H5FA_HDR_VERSION 0 /* Header */ -#define H5FA_DBLOCK_VERSION 0 /* Data block */ - +#define H5FA_HDR_VERSION 0 /* Header */ +#define H5FA_DBLOCK_VERSION 0 /* Data block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -72,106 +66,95 @@ /* 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_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); 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_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); static herr_t H5FA__cache_dblock_free_icr(void *thing); 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_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); static herr_t H5FA__cache_dblk_page_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5FA header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_HDR[1] = {{ - H5AC_FARRAY_HDR_ID, /* Metadata client ID */ - "Fixed-array Header", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_hdr_deserialize, /* 'deserialize' callback */ - H5FA__cache_hdr_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_hdr_serialize, /* 'serialize' callback */ - H5FA__cache_hdr_notify, /* 'notify' callback */ - H5FA__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_FARRAY_HDR_ID, /* Metadata client ID */ + "Fixed-array Header", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FA__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_hdr_deserialize, /* 'deserialize' callback */ + H5FA__cache_hdr_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_hdr_serialize, /* 'serialize' callback */ + H5FA__cache_hdr_notify, /* 'notify' callback */ + H5FA__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5FA data block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_DBLOCK[1] = {{ - H5AC_FARRAY_DBLOCK_ID, /* Metadata client ID */ - "Fixed Array Data Block", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_dblock_deserialize, /* 'deserialize' callback */ - H5FA__cache_dblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_dblock_serialize, /* 'serialize' callback */ - H5FA__cache_dblock_notify, /* 'notify' callback */ - H5FA__cache_dblock_free_icr, /* 'free_icr' callback */ - H5FA__cache_dblock_fsf_size, /* 'fsf_size' callback */ + H5AC_FARRAY_DBLOCK_ID, /* Metadata client ID */ + "Fixed Array Data Block", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FA__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_dblock_deserialize, /* 'deserialize' callback */ + H5FA__cache_dblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_dblock_serialize, /* 'serialize' callback */ + H5FA__cache_dblock_notify, /* 'notify' callback */ + H5FA__cache_dblock_free_icr, /* 'free_icr' callback */ + H5FA__cache_dblock_fsf_size, /* 'fsf_size' callback */ }}; /* H5FA data block page inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ - H5AC_FARRAY_DBLK_PAGE_ID, /* Metadata client ID */ - "Fixed Array Data Block Page", /* Metadata client name (for debugging) */ - H5FD_MEM_FARRAY_DBLK_PAGE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_FARRAY_DBLK_PAGE_ID, /* Metadata client ID */ + "Fixed Array Data Block Page", /* Metadata client name (for debugging) */ + H5FD_MEM_FARRAY_DBLK_PAGE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5FA__cache_dblk_page_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ - H5FA__cache_dblk_page_deserialize, /* 'deserialize' callback */ - H5FA__cache_dblk_page_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5FA__cache_dblk_page_serialize, /* 'serialize' callback */ - H5FA__cache_dblk_page_notify, /* 'notify' callback */ - H5FA__cache_dblk_page_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FA__cache_dblk_page_verify_chksum, /* 'verify_chksum' callback */ + H5FA__cache_dblk_page_deserialize, /* 'deserialize' callback */ + H5FA__cache_dblk_page_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5FA__cache_dblk_page_serialize, /* 'serialize' callback */ + H5FA__cache_dblk_page_notify, /* 'notify' callback */ + H5FA__cache_dblk_page_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_get_initial_load_size * @@ -184,9 +167,8 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; /* User data for callback */ @@ -199,9 +181,8 @@ H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) /* 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() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_verify_chksum * @@ -215,14 +196,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -230,12 +210,11 @@ H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_deserialize * @@ -249,17 +228,16 @@ 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)) +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 */ - H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ - H5FA_hdr_t *hdr = NULL; /* Fixed array info */ + H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ + 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ + const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t stored_chksum; /* Stored metadata checksum value */ /* Check arguments */ HDassert(udata); @@ -267,50 +245,50 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert(H5F_addr_defined(udata->addr)); /* Allocate space for the fixed array data structure */ - if(NULL == (hdr = H5FA__hdr_alloc(udata->f))) + if (NULL == (hdr = H5FA__hdr_alloc(udata->f))) H5E_THROW(H5E_CANTALLOC, "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)) + if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FA_HDR_VERSION) + if (*image++ != H5FA_HDR_VERSION) H5E_THROW(H5E_VERSION, "wrong fixed array header version") /* Fixed array class */ id = (H5FA_cls_id_t)*image++; - if(id >= H5FA_NUM_CLS_ID) + if (id >= H5FA_NUM_CLS_ID) H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") hdr->cparam.cls = H5FA_client_class_g[id]; /* General array creation/configuration information */ - hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ + hdr->cparam.raw_elmt_size = *image++; /* Element size in file (in bytes) */ hdr->cparam.max_dblk_page_nelmts_bits = *image++; /* Log2(Max. # of elements in data block page) - - i.e. # of bits needed to store max. # of - elements in data block page. */ + i.e. # of bits needed to store max. # of + elements in data block page. */ /* Array statistics */ - H5F_DECODE_LENGTH(udata->f, image, hdr->cparam.nelmts); /* Number of elements */ + H5F_DECODE_LENGTH(udata->f, image, hdr->cparam.nelmts); /* Number of elements */ /* Internal information */ - H5F_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ + H5F_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ /* Check for data block */ - if(H5F_addr_defined(hdr->dblk_addr)) { - H5FA_dblock_t dblock; /* Fake data block for computing size */ - size_t dblk_page_nelmts; /* # of elements per data block page */ + if (H5F_addr_defined(hdr->dblk_addr)) { + H5FA_dblock_t dblock; /* Fake data block for computing size */ + size_t dblk_page_nelmts; /* # of elements per data block page */ /* Set up fake data block for computing size on disk */ - dblock.hdr = hdr; + dblock.hdr = hdr; dblock.dblk_page_init_size = 0; - dblock.npages = 0; - dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; - if(hdr->cparam.nelmts > dblk_page_nelmts) { + dblock.npages = 0; + dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; + if (hdr->cparam.nelmts > dblk_page_nelmts) { dblock.npages = (size_t)(((hdr->cparam.nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); dblock.dblk_page_init_size = (dblock.npages + 7) / 8; } /* end if */ @@ -332,23 +310,22 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert((size_t)(image - (const uint8_t *)_image) == len); /* Finish initializing fixed array header */ - if(H5FA__hdr_init(hdr, udata->ctx_udata) < 0) + if (H5FA__hdr_init(hdr, udata->ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(hdr && H5FA__hdr_dest(hdr) < 0) + if (!ret_value) + if (hdr && H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_image_len * @@ -361,12 +338,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ + const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(hdr); @@ -375,9 +351,8 @@ H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_serialize * @@ -390,15 +365,13 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* check arguments */ HDassert(f); @@ -417,14 +390,16 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ - *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ - *image++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + *image++ = hdr->cparam.raw_elmt_size; /* Element size in file (in bytes) */ + *image++ = + hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ /* Array statistics */ - H5F_ENCODE_LENGTH(f, image, hdr->stats.nelmts); /* Number of elements for the fixed array */ + H5F_ENCODE_LENGTH(f, image, hdr->stats.nelmts); /* Number of elements for the fixed array */ /* Internal information */ - H5F_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ + H5F_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -435,9 +410,8 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_notify * @@ -450,20 +424,19 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(hdr); /* Check if the file was opened with SWMR-write access */ - if(hdr->swmr_write) { + if (hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -480,20 +453,24 @@ H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) /* If hdr->parent != NULL, hdr->parent is used to destroy * the flush dependency before the header is evicted. */ - if(hdr->parent) { + if (hdr->parent) { /* Sanity check */ HDassert(hdr->top_proxy); - /* 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") + /* 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") hdr->parent = NULL; - } /* end if */ + } /* 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, "unable to destroy flush dependency between header and fixed array 'top' proxy") + 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 fixed array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ break; @@ -501,19 +478,18 @@ H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ else HDassert(NULL == hdr->parent); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_free_icr * @@ -527,22 +503,19 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_hdr_free_icr(void *thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_hdr_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the extensible array header */ - if(H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) + if (H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array header") -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ +END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_get_initial_load_size * @@ -555,14 +528,13 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - 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 */ + 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 */ /* Check arguments */ HDassert(udata); @@ -579,22 +551,21 @@ H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) * dblock->npages * dblock->dblk_page_init_size */ - dblock.hdr = udata->hdr; + dblock.hdr = udata->hdr; dblk_page_nelmts = (size_t)1 << udata->hdr->cparam.max_dblk_page_nelmts_bits; - if(udata->hdr->cparam.nelmts > dblk_page_nelmts) { + if (udata->hdr->cparam.nelmts > dblk_page_nelmts) { dblock.npages = (size_t)(((udata->hdr->cparam.nelmts + dblk_page_nelmts) - 1) / dblk_page_nelmts); dblock.dblk_page_init_size = (dblock.npages + 7) / 8; } /* end if */ /* Set the image length size */ - if(!dblock.npages) + if (!dblock.npages) *image_len = (size_t)H5FA_DBLOCK_SIZE(&dblock); else *image_len = (size_t)H5FA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_verify_chksum * @@ -608,14 +579,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -623,12 +593,11 @@ H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_deserialize * @@ -642,61 +611,61 @@ 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)) +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 */ - 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - haddr_t arr_addr; /* Address of array header in the file */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + haddr_t arr_addr; /* Address of array header in the file */ /* Sanity check */ HDassert(udata); HDassert(udata->hdr); /* Allocate the fixed array data block */ - if(NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) + if (NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) H5E_THROW(H5E_CANTALLOC, "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))); + HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock))) || + (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock))); /* Set the fixed array data block's information */ dblock->addr = udata->dblk_addr; /* Magic number */ - if(HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FA_DBLOCK_VERSION) + if (*image++ != H5FA_DBLOCK_VERSION) H5E_THROW(H5E_VERSION, "wrong fixed array data block version") /* Fixed array type */ - if(*image++ != (uint8_t)udata->hdr->cparam.cls->id) + if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) H5E_THROW(H5E_BADTYPE, "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)) + if (H5F_addr_ne(arr_addr, udata->hdr->addr)) H5E_THROW(H5E_BADVALUE, "wrong fixed array header address") /* Page initialization flags */ - if(dblock->npages > 0) { - H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); + 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) { + if (!dblock->npages) { /* 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, (size_t)udata->hdr->cparam.nelmts, udata->hdr->cb_ctx) < 0) + 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") image += (udata->hdr->cparam.nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -719,16 +688,15 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblock && H5FA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_image_len * @@ -741,26 +709,24 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); HDassert(image_len); /* Set the image length size */ - if(!dblock->npages) + if (!dblock->npages) *image_len = (size_t)dblock->size; else *image_len = H5FA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_serialize * @@ -773,15 +739,14 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Check arguments */ HDassert(f); @@ -804,19 +769,20 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED H5F_addr_encode(f, &image, dblock->hdr->addr); /* Page init flags */ - if(dblock->npages > 0) { + if (dblock->npages > 0) { /* 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) { + if (!dblock->npages) { /* Encode elements in data block */ /* Convert from native elements in memory into raw elements on disk */ - 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) + 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") image += (dblock->hdr->cparam.nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -830,11 +796,10 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_notify * @@ -847,9 +812,8 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; @@ -858,17 +822,20 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) HDassert(dblock); /* Check if the file was opened with SWMR-write access */ - if(dblock->hdr->swmr_write) { + if (dblock->hdr->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + 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, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) + if (H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) + H5E_THROW( + H5E_CANTDEPEND, + "unable to create flush dependency between data block and header, address = %llu", + (unsigned long long)dblock->addr) break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -879,14 +846,15 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) 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) + /* 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") /* 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") + 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") dblock->top_proxy = NULL; } /* end if */ break; @@ -894,18 +862,16 @@ H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ - - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_free_icr * @@ -919,24 +885,21 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5FA__cache_dblock_free_icr(void *_thing)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblock_free_icr(void *_thing)) - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); /* Release the fixed array data block */ - if(H5FA__dblock_dest(dblock) < 0) + if (H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_fsf_size * @@ -966,11 +929,10 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + 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 */ + const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblock); @@ -980,9 +942,8 @@ H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ +END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_get_initial_load_size * @@ -995,12 +956,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* Local variables */ - H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ + H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ /* Check arguments */ HDassert(udata); @@ -1011,9 +971,8 @@ H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) /* 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() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_verify_chksum * @@ -1027,14 +986,13 @@ 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)) +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 */ - 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 */ + 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 */ /* Check arguments */ HDassert(image); @@ -1042,12 +1000,11 @@ H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_deserialize * @@ -1061,16 +1018,16 @@ 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)) +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 */ - 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 */ + 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 */ /* Sanity check */ HDassert(udata); @@ -1079,7 +1036,7 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, HDassert(H5F_addr_defined(udata->dblk_page_addr)); /* Allocate the fixed array data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) + 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") /* Set the fixed array data block's information */ @@ -1089,7 +1046,7 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, /* 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) + 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") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); @@ -1111,16 +1068,15 @@ H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Release resources */ - if(!ret_value) - if(dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) + 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") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_image_len * @@ -1133,12 +1089,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Local variables */ - const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ /* Check arguments */ HDassert(dblk_page); @@ -1147,9 +1102,8 @@ H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_serialize * @@ -1162,15 +1116,14 @@ 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)) +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 */ - 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 */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Sanity check */ HDassert(f); @@ -1183,7 +1136,8 @@ H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Encode elements in data block page */ /* 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) + 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") image += (dblk_page->nelmts * dblk_page->hdr->cparam.raw_elmt_size); @@ -1196,11 +1150,10 @@ H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_ima /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_notify * @@ -1213,18 +1166,17 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, + H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ /* Sanity check */ HDassert(dblk_page); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -1233,9 +1185,10 @@ H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* 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") + 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") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -1252,16 +1205,15 @@ H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) default: #ifdef NDEBUG H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_free_icr * @@ -1275,18 +1227,15 @@ 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)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblk_page_free_icr(void *thing)) /* Check arguments */ HDassert(thing); /* Release the fixed array data block page */ - if(H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) + if (H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page") -CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ + CATCH +END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index b578cf2cb8e..8c2c9a8b1e2 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,29 +24,25 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5Oprivate.h" /* Object Header */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5Oprivate.h" /* Object Header */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -55,28 +51,22 @@ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__hdr_debug * @@ -89,14 +79,13 @@ * *------------------------------------------------------------------------- */ -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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -108,52 +97,43 @@ H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(cls); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + if (NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") /* Print opening message */ HDfprintf(stream, "%*sFixed Array Header...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Header size:", - hdr->size); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size:", hdr->size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Raw Element Size:", - (unsigned)hdr->cparam.raw_elmt_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Native Element Size (on this platform):", - hdr->cparam.cls->nat_elmt_size); - + "Raw Element Size:", (unsigned)hdr->cparam.raw_elmt_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "Native Element Size (on this platform):", hdr->cparam.cls->nat_elmt_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of elements in data block page:", - (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits)); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. # of elements in data block page:", + (unsigned)((size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits)); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements in Fixed Array:", hdr->stats.nelmts); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of elements in Fixed Array:", hdr->stats.nelmts); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Fixed Array Data Block Address:", hdr->dblk_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Fixed Array Data Block Address:", hdr->dblk_addr); -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_debug() */ - +END_FUNC(PKG) /* end H5FA__hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_debug * @@ -166,16 +146,15 @@ 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)) +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)) /* 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 */ /* Check arguments */ HDassert(f); @@ -188,94 +167,99 @@ H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, HDassert(H5F_addr_defined(obj_addr)); /* Check for debugging context callback available */ - if(cls->crt_dbg_ctx) + if (cls->crt_dbg_ctx) /* Create debugging context */ - if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) + if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) H5E_THROW(H5E_CANTGET, "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))) + 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") /* 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) + 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) /* Print opening message */ HDfprintf(stream, "%*sFixed Array data Block...\n", indent, ""); /* Print the values */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of Data Block:", dblock->addr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data Block size:", dblock->size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements in Data Block:", hdr->cparam.nelmts); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of pages in Data Block:", dblock->npages); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements per Data Block page:", dblock->dblk_page_nelmts); - - if(dblock->npages) { /* paging */ - size_t dblk_page_nelmts; /* # of elements in a data block page */ - haddr_t dblk_page_addr; /* Address of a data block page */ - size_t page_idx; /* Page index within data block */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Array class ID:", hdr->cparam.cls->name); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Address of Data Block:", dblock->addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Data Block size:", dblock->size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of elements in Data Block:", hdr->cparam.nelmts); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Number of pages in Data Block:", dblock->npages); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "Number of elements per Data Block page:", dblock->dblk_page_nelmts); + + if (dblock->npages) { /* paging */ + size_t dblk_page_nelmts; /* # of elements in a data block page */ + haddr_t dblk_page_addr; /* Address of a data block page */ + size_t page_idx; /* Page index within data block */ HDfprintf(stream, "%*sPaging:\n", indent, ""); /* Iterate over the pages */ - dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); + dblk_page_addr = dblock->addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); dblk_page_nelmts = dblock->dblk_page_nelmts; - /* Read and print each page's elements in the data block */ - for(page_idx = 0; page_idx < dblock->npages; page_idx++) { - if(!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { - HDfprintf(stream, "%*s%-*s %Hu %s\n", indent, "", fwidth, - "Page %Zu:", page_idx, "empty"); + /* Read and print each page's elements in the data block */ + for (page_idx = 0; page_idx < dblock->npages; page_idx++) { + if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { + HDfprintf(stream, "%*s%-*s %zu %s\n", indent, "", fwidth, "Page %zu:", page_idx, "empty"); - } /* end if */ - else { /* get the page */ - H5FA_dblk_page_t *dblk_page; /* Pointer to a data block page */ - hsize_t nelmts_left; /* Remaining elements in the last data block page */ + } /* end if */ + else { /* get the page */ + H5FA_dblk_page_t *dblk_page; /* Pointer to a data block page */ + hsize_t nelmts_left; /* Remaining elements in the last data block page */ /* Check for last page */ - if(((page_idx + 1) == dblock->npages) && (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts)) + if (((page_idx + 1) == dblock->npages) && + (nelmts_left = hdr->cparam.nelmts % dblock->dblk_page_nelmts)) dblk_page_nelmts = (size_t)nelmts_left; - 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) + 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) - HDfprintf(stream, "%*sElements in page %Zu:\n", indent, "", page_idx); - for(u = 0; u < dblk_page_nelmts; u++) { + HDfprintf(stream, "%*sElements in page %zu:\n", indent, "", page_idx); + for (u = 0; u < dblk_page_nelmts; u++) { /* Call the class's 'debug' callback */ - 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) + 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") } /* end for */ - if(H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) + if (H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* paging */ - } /* end for npages */ - } /* end if */ - else { /* not paging */ + } /* end for npages */ + } /* end if */ + else { /* not paging */ /* Print the elements in the data block */ HDfprintf(stream, "%*sElements:\n", indent, ""); - for(u = 0; u < hdr->cparam.nelmts; u++) { + for (u = 0; u < hdr->cparam.nelmts; u++) { /* 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) + 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") } /* end for */ - } /* end else */ + } /* end else */ -CATCH - if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) + CATCH + if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") - if(dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") - if(hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__dblock_debug() */ - +END_FUNC(PKG) /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index effdeb29c97..0f5ee292d01 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,53 +24,44 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,8 +72,6 @@ H5FL_DEFINE_STATIC(H5FA_dblk_page_t); /* Declare a free list to manage the page elements */ H5FL_BLK_DEFINE(page_elmts); - - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_alloc * @@ -95,22 +84,20 @@ 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)) +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 *dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ - if(NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) + if (NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") /* Share common array information */ - if(H5FA__hdr_incr(hdr) < 0) + if (H5FA__hdr_incr(hdr) < 0) H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblk_page->hdr = hdr; @@ -118,21 +105,20 @@ H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) dblk_page->nelmts = nelmts; /* 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))) + 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") /* Set the return value */ ret_value = dblk_page; -CATCH + CATCH - if(!ret_value) - if(dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) + 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") -END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ +END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_create * @@ -145,64 +131,62 @@ END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) /* Local variables */ - H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); #endif /* H5FA_DEBUG */ /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ - if(NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) + if (NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; dblk_page->size = H5FA_DBLK_PAGE_SIZE(hdr, nelmts); #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: dblk_page->size = %Zu\n", FUNC, dblk_page->size); + HDfprintf(stderr, "%s: dblk_page->size = %Zu\n", FUNC, dblk_page->size); #endif /* H5FA_DEBUG */ /* Clear any elements in data block page to fill value */ - if((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) + 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") /* 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) + 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") 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) + 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") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ -CATCH - if(ret_value < 0) - if(dblk_page) { + CATCH + if (ret_value < 0) + if (dblk_page) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblk_page) < 0) + if (inserted) + if (H5AC_remove_entry(dblk_page) < 0) H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block page from cache") /* Destroy data block page */ - if(H5FA__dblk_page_dest(dblk_page) < 0) + if (H5FA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_create() */ +END_FUNC(PKG) /* end H5FA__dblk_page_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_protect * @@ -216,17 +200,16 @@ 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)) +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_cache_ud_t udata; /* Information needed for loading data block page */ + 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 */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* Sanity check */ @@ -237,18 +220,20 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; - udata.nelmts = dblk_page_nelmts; + udata.hdr = hdr; + udata.nelmts = dblk_page_nelmts; udata.dblk_page_addr = dblk_page_addr; /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblk_page->top_proxy) { + 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) + 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") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ @@ -256,18 +241,19 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Set return value */ ret_value = dblk_page; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) { + 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) + 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) } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ +END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_unprotect * @@ -281,28 +267,27 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) - /* Local variables */ +/* Local variables */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* Sanity check */ HDassert(dblk_page); /* 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) + 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 + CATCH -END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ +END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_dest * @@ -315,23 +300,21 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) /* Sanity check */ HDassert(dblk_page); /* Check if header field has been initialized */ - if(dblk_page->hdr) { + if (dblk_page->hdr) { /* Check if buffer for data block page elements has been initialized */ - if(dblk_page->elmts) { + if (dblk_page->elmts) { /* Free buffer for data block page elements */ dblk_page->elmts = H5FL_BLK_FREE(page_elmts, dblk_page->elmts); } /* end if */ /* Decrement reference count on shared info */ - if(H5FA__hdr_decr(dblk_page->hdr) < 0) + if (H5FA__hdr_decr(dblk_page->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -342,7 +325,6 @@ H5FA__dblk_page_dest(H5FA_dblk_page_t *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() */ + CATCH +END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index a6a8ced9fab..21e2e03166e 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,54 +24,45 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -85,7 +76,6 @@ H5FL_BLK_DEFINE(chunk_elmts); /* Declare a free list to manage blocks of 'page init' bitmasks */ H5FL_BLK_DEFINE(fa_page_init); - /*------------------------------------------------------------------------- * Function: H5FA__dblock_alloc * @@ -98,23 +88,21 @@ H5FL_BLK_DEFINE(fa_page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_dblock_t *, NULL, NULL, -H5FA__dblock_alloc(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t *hdr)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + H5FA_dblock_t *dblock = NULL; /* fixed array data block */ /* Check arguments */ HDassert(hdr); HDassert(hdr->cparam.nelmts > 0); /* Allocate memory for the data block */ - if(NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) + if (NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") /* Share common array information */ - if(H5FA__hdr_incr(hdr) < 0) + if (H5FA__hdr_incr(hdr) < 0) H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") dblock->hdr = hdr; @@ -122,7 +110,7 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) dblock->dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits; /* Check if this data block should be paged */ - if(hdr->cparam.nelmts > dblock->dblk_page_nelmts) { + if (hdr->cparam.nelmts > dblock->dblk_page_nelmts) { /* Compute number of pages */ hsize_t npages = ((hdr->cparam.nelmts + dblock->dblk_page_nelmts) - 1) / dblock->dblk_page_nelmts; @@ -137,14 +125,14 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) HDassert(dblock->dblk_page_init_size > 0); /* Allocate space for 'page init' flags */ - if(NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size))) + 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") /* Compute data block page size */ dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM; /* Compute the # of elements on last page */ - if(0 == hdr->cparam.nelmts % dblock->dblk_page_nelmts) + if (0 == hdr->cparam.nelmts % dblock->dblk_page_nelmts) dblock->last_page_nelmts = dblock->dblk_page_nelmts; else dblock->last_page_nelmts = (size_t)(hdr->cparam.nelmts % dblock->dblk_page_nelmts); @@ -153,23 +141,22 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr)) hsize_t dblk_size = hdr->cparam.nelmts * hdr->cparam.cls->nat_elmt_size; /* 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))) + 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") } /* end else */ /* Set the return value */ ret_value = dblock; -CATCH + CATCH - if(!ret_value) - if(dblock && H5FA__dblock_dest(dblock) < 0) + if (!ret_value) + if (dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_alloc() */ +END_FUNC(PKG) /* end H5FA__dblock_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_create * @@ -182,45 +169,44 @@ 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)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) /* 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 */ + 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 */ /* Sanity check */ HDassert(hdr); HDassert(hdr_dirty); /* Allocate the data block */ - if(NULL == (dblock = H5FA__dblock_alloc(hdr))) + if (NULL == (dblock = H5FA__dblock_alloc(hdr))) H5E_THROW(H5E_CANTALLOC, "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))) + 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") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ - if(!dblock->npages) + 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) + 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") /* Cache the new fixed array data block */ - if(H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + 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") 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) + 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") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -231,27 +217,27 @@ H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) /* Set address of data block to return */ ret_value = dblock_addr; -CATCH + CATCH - if(!H5F_addr_defined(ret_value)) - if(dblock) { + if (!H5F_addr_defined(ret_value)) + if (dblock) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(dblock) < 0) + if (inserted) + if (H5AC_remove_entry(dblock) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy data block */ - if(H5FA__dblock_dest(dblock) < 0) + if (H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblock_create() */ +END_FUNC(PKG) /* end H5FA__dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_protect * @@ -264,13 +250,12 @@ 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)) +BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, + H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) /* Local variables */ - H5FA_dblock_t *dblock; /* Fixed array data block */ - H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5FA_dblock_t * dblock; /* Fixed array data block */ + H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ /* Sanity check */ HDassert(hdr); @@ -280,17 +265,19 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data */ - udata.hdr = hdr; + udata.hdr = hdr; udata.dblk_addr = dblk_addr; /* 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) + 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) /* Create top proxy, if it doesn't exist */ - if(hdr->top_proxy && NULL == dblock->top_proxy) { + 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) + 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") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -298,17 +285,18 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) /* Set return value */ ret_value = dblock; -CATCH + CATCH /* Clean up on error */ - if(!ret_value) + 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) + 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) -END_FUNC(PKG) /* end H5FA__dblock_protect() */ +END_FUNC(PKG) /* end H5FA__dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_unprotect * @@ -321,9 +309,8 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) /* Local variables */ @@ -331,14 +318,14 @@ H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ +END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_delete * @@ -351,50 +338,49 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ /* Sanity check */ HDassert(hdr); HDassert(H5F_addr_defined(dblk_addr)); /* 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) + 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) /* Check if data block is paged */ - if(dblock->npages) { - haddr_t dblk_page_addr; /* Address of each data block page */ - size_t u; /* Local index variable */ + if (dblock->npages) { + haddr_t dblk_page_addr; /* Address of each data block page */ + size_t u; /* Local index variable */ /* Set up initial state */ dblk_page_addr = dblk_addr + H5FA_DBLOCK_PREFIX_SIZE(dblock); /* Iterate over pages in data block */ - for(u = 0; u < dblock->npages; u++) { + for (u = 0; u < dblock->npages; u++) { /* 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) + 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") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* end for */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* 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) + 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") -END_FUNC(PKG) /* end H5FA__dblock_delete() */ +END_FUNC(PKG) /* end H5FA__dblock_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA__dblock_dest * @@ -407,32 +393,30 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__dblock_dest(H5FA_dblock_t *dblock)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); /* Check if shared header field has been initialized */ - if(dblock->hdr) { + if (dblock->hdr) { /* Check if we've got elements in the data block */ - if(dblock->elmts && !dblock->npages) { + if (dblock->elmts && !dblock->npages) { /* Free buffer for data block elements */ HDassert(dblock->hdr->cparam.nelmts > 0); dblock->elmts = H5FL_BLK_FREE(chunk_elmts, dblock->elmts); } /* end if */ /* Check if data block is paged */ - if(dblock->npages) { + if (dblock->npages) { /* Free buffer for 'page init' bitmask, if there is one */ HDassert(dblock->dblk_page_init_size > 0); - if(dblock->dblk_page_init) + if (dblock->dblk_page_init) dblock->dblk_page_init = H5FL_BLK_FREE(fa_page_init, dblock->dblk_page_init); } /* end if */ /* Decrement reference count on shared info */ - if(H5FA__hdr_decr(dblock->hdr) < 0) + if (H5FA__hdr_decr(dblock->hdr) < 0) H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -443,7 +427,6 @@ H5FA__dblock_dest(H5FA_dblock_t *dblock)) /* Free the data block itself */ dblock = H5FL_FREE(H5FA_dblock_t, dblock); -CATCH - -END_FUNC(PKG) /* end H5FA__dblock_dest() */ + CATCH +END_FUNC(PKG) /* end H5FA__dblock_dest() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index b25d50b1bb2..867160fc0fe 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,54 +24,45 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -79,7 +70,6 @@ /* Declare a free list to manage the H5FA_hdr_t struct */ H5FL_DEFINE_STATIC(H5FA_hdr_t); - /*------------------------------------------------------------------------- * Function: H5FA__hdr_alloc * @@ -92,41 +82,38 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5FA_hdr_t *, NULL, NULL, -H5FA__hdr_alloc(H5F_t *f)) +BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) + if (NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; /* Set the internal parameters for the array */ - hdr->f = f; - hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + hdr->f = f; + hdr->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); hdr->sizeof_size = H5F_SIZEOF_SIZE(f); /* Set the return value */ ret_value = hdr; -CATCH + CATCH - if(!ret_value) - if(hdr && H5FA__hdr_dest(hdr) < 0) + 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() */ +END_FUNC(PKG) /* end H5FA__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_init * @@ -139,9 +126,7 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) /* Local variables */ @@ -155,16 +140,15 @@ H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) hdr->stats.nelmts = hdr->cparam.nelmts; /* 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))) + 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 */ -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_init() */ +END_FUNC(PKG) /* end H5FA__hdr_init() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_create * @@ -177,32 +161,31 @@ END_FUNC(PKG) /* end H5FA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, + H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Fixed array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + H5FA_hdr_t *hdr = NULL; /* Fixed array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ /* Check arguments */ HDassert(f); HDassert(cparam); #ifndef NDEBUG -{ - /* Check for valid parameters */ - if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "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") - if(cparam->nelmts == 0) - H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") -} + { + /* Check for valid parameters */ + if (cparam->raw_elmt_size == 0) + H5E_THROW(H5E_BADVALUE, "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") + if (cparam->nelmts == 0) + H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") + } #endif /* NDEBUG */ /* Allocate space for the shared information */ - if(NULL == (hdr = H5FA__hdr_alloc(f))) + if (NULL == (hdr = H5FA__hdr_alloc(f))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") hdr->dblk_addr = HADDR_UNDEF; @@ -211,52 +194,52 @@ H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) H5MM_memcpy(&hdr->cparam, cparam, sizeof(hdr->cparam)); /* Finish initializing fixed array header */ - if(H5FA__hdr_init(hdr, ctx_udata) < 0) + if (H5FA__hdr_init(hdr, ctx_udata) < 0) H5E_THROW(H5E_CANTINIT, "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))) + 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") /* Create 'top' proxy for extensible array entries */ - if(hdr->swmr_write) - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (hdr->swmr_write) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "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) + 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") 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) + 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") /* Set address of array header to return */ ret_value = hdr->addr; -CATCH + CATCH - if(!H5F_addr_defined(ret_value)) - if(hdr) { + if (!H5F_addr_defined(ret_value)) + if (hdr) { /* Remove from cache, if inserted */ - if(inserted) - if(H5AC_remove_entry(hdr) < 0) + if (inserted) + if (H5AC_remove_entry(hdr) < 0) H5E_THROW(H5E_CANTREMOVE, "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) + 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") /* Destroy header */ - if(H5FA__hdr_dest(hdr) < 0) + if (H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy Fixed Array header") } /* end if */ -END_FUNC(PKG) /* end H5FA__hdr_create() */ +END_FUNC(PKG) /* end H5FA__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_incr * @@ -269,26 +252,23 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_incr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as un-evictable when something is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) H5E_THROW(H5E_CANTPIN, "unable to pin fixed array header") /* Increment reference count on shared header */ hdr->rc++; -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_incr() */ +END_FUNC(PKG) /* end H5FA__hdr_incr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_decr * @@ -301,9 +281,7 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_decr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -313,17 +291,16 @@ H5FA__hdr_decr(H5FA_hdr_t *hdr)) hdr->rc--; /* Mark header as evictable again when nothing depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) H5E_THROW(H5E_CANTUNPIN, "unable to unpin fixed array header") } /* end if */ -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_decr() */ +END_FUNC(PKG) /* end H5FA__hdr_decr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_incr * @@ -336,9 +313,7 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -346,9 +321,8 @@ 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() */ +END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_decr * @@ -361,9 +335,7 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -size_t, 0, -, -H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); @@ -375,9 +347,8 @@ H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ +END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_modified * @@ -390,22 +361,19 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_modified(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_modified(H5FA_hdr_t *hdr)) /* Sanity check */ HDassert(hdr); /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as dirty") -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_modified() */ +END_FUNC(PKG) /* end H5FA__hdr_modified() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_protect * @@ -418,13 +386,12 @@ 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)) +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_cache_ud_t udata; /* User data for cache callbacks */ + H5FA_hdr_t * hdr; /* Fixed array header */ + H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ /* Sanity check */ HDassert(f); @@ -434,34 +401,34 @@ H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up user data for cache callbacks */ - udata.f = f; - udata.addr = fa_addr; + udata.f = f; + udata.addr = fa_addr; udata.ctx_udata = ctx_udata; /* 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) - hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + 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) + 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) { + if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for fixed array entries */ - if(NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) + if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) H5E_THROW(H5E_CANTCREATE, "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) + 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 */ /* Set return value */ ret_value = hdr; -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__hdr_protect() */ +END_FUNC(PKG) /* end H5FA__hdr_protect() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_unprotect * @@ -474,9 +441,7 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) /* Local variables */ @@ -484,14 +449,14 @@ H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) 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) + 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 + CATCH -END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ +END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete * @@ -504,50 +469,47 @@ END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_delete(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_delete(H5FA_hdr_t *hdr)) /* Local variables */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ /* 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) + H5E_THROW(H5E_CANTGET, "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); + } /* end block */ #endif /* NDEBUG */ /* Check for Fixed Array Data block */ - if(H5F_addr_defined(hdr->dblk_addr)) { + if (H5F_addr_defined(hdr->dblk_addr)) { /* Delete Fixed Array Data block */ - if(H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) + if (H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array data 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 + CATCH /* 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) + if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_delete() */ +END_FUNC(PKG) /* end H5FA__hdr_delete() */ - /*------------------------------------------------------------------------- * Function: H5FA__hdr_dest * @@ -560,24 +522,22 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__hdr_dest(H5FA_hdr_t *hdr)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Check arguments */ HDassert(hdr); HDassert(hdr->rc == 0); /* Destroy the callback context */ - if(hdr->cb_ctx) { - if((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) + 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 */ hdr->cb_ctx = NULL; /* Destroy the 'top' proxy */ - if(hdr->top_proxy) { - if(H5AC_proxy_entry_dest(hdr->top_proxy) < 0) + if (hdr->top_proxy) { + if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ @@ -585,7 +545,6 @@ H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Free the shared info itself */ hdr = H5FL_FREE(H5FA_hdr_t, hdr); -CATCH - -END_FUNC(PKG) /* end H5FA__hdr_dest() */ + CATCH +END_FUNC(PKG) /* end H5FA__hdr_dest() */ diff --git a/src/H5FAint.c b/src/H5FAint.c index 3a1375ac725..864c7ee8149 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,58 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5FApkg.h" /* Fixed Arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5FApkg.h" /* Fixed Arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA__create_flush_depend * @@ -90,23 +79,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") -CATCH + CATCH -END_FUNC(PKG) /* end H5FA__create_flush_depend() */ +END_FUNC(PKG) /* end H5FA__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5FA__destroy_flush_depend * @@ -119,19 +106,17 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, + H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) /* Sanity check */ HDassert(parent_entry); HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") -CATCH - -END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ + CATCH +END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ diff --git a/src/H5FAmodule.h b/src/H5FAmodule.h index 57a85b1a2ed..ef814aeb19c 100644 --- a/src/H5FAmodule.h +++ b/src/H5FAmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5FA package. Including this header means that the source file * is part of the H5FA package. */ -#ifndef _H5FAmodule_H -#define _H5FAmodule_H +#ifndef H5FAmodule_H +#define H5FAmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5FA_MODULE -#define H5_MY_PKG H5FA -#define H5_MY_PKG_ERR H5E_FARRAY -#define H5_MY_PKG_INIT NO - -#endif /* _H5FAmodule_H */ +#define H5_MY_PKG H5FA +#define H5_MY_PKG_ERR H5E_FARRAY +#define H5_MY_PKG_INIT NO +#endif /* H5FAmodule_H */ diff --git a/src/H5FApkg.h b/src/H5FApkg.h index 2baee883cf6..c4bf93485fb 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,16 +22,15 @@ #error "Do not include this file outside the H5FA package!" #endif -#ifndef _H5FApkg_H -#define _H5FApkg_H +#ifndef H5FApkg_H +#define H5FApkg_H /* Get package's private header */ #include "H5FAprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -40,76 +39,72 @@ /* Define this to display debugging information for the Fixed Array layer */ /* #define H5FA_DEBUG */ - /* Fill value for fixed array test class */ #ifdef H5FA_TESTING -#define H5FA_TEST_FILL ((uint64_t)ULLONG_MAX) +#define H5FA_TEST_FILL ((uint64_t)ULLONG_MAX) #endif /* H5FA_TESTING */ /* Size of checksum information (on disk) */ -#define H5FA_SIZEOF_CHKSUM 4 +#define H5FA_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for fixed array metadata */ -#define H5FA_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + 1 /* Array type */ \ - + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ +#define H5FA_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + 1 /* Array type */ \ + + ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \ ) /* Size of the Fixed Array header on disk */ -#define H5FA_HEADER_SIZE(sizeof_addr, sizeof_size) ( \ - /* General metadata fields */ \ - H5FA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* General array information */ \ - + 1 /* Element Size */ \ - + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \ - \ - /* Fixed Array statistics fields */ \ - + (sizeof_size) /* # of elements in the fixed array */ \ - \ - /* Fixed Array Header specific fields */ \ - + (sizeof_addr) /* File address of Fixed Array data block */ \ +#define H5FA_HEADER_SIZE(sizeof_addr, sizeof_size) \ + (/* General metadata fields */ \ + H5FA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* General array information */ \ + + 1 /* Element Size */ \ + + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements \ + in data block page */ \ + \ + /* Fixed Array statistics fields */ \ + + (sizeof_size) /* # of elements in the fixed array */ \ + \ + /* Fixed Array Header specific fields */ \ + + (sizeof_addr) /* File address of Fixed Array data block */ \ ) /* Size of the fixed array header on disk (via file pointer) */ -#define H5FA_HEADER_SIZE_FILE(f) ( \ - H5FA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f)) \ - ) +#define H5FA_HEADER_SIZE_FILE(f) (H5FA_HEADER_SIZE(H5F_SIZEOF_ADDR(f), H5F_SIZEOF_SIZE(f))) /* Size of the fixed array header on disk (via fixed array header) */ -#define H5FA_HEADER_SIZE_HDR(h) ( \ - H5FA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size) \ - ) +#define H5FA_HEADER_SIZE_HDR(h) (H5FA_HEADER_SIZE((h)->sizeof_addr, (h)->sizeof_size)) /* Size of the Fixed Array data block prefix on disk */ -#define H5FA_DBLOCK_PREFIX_SIZE(d) ( \ - /* General metadata fields */ \ - H5FA_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Sanity-checking fields */ \ - + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \ - \ - /* Fixed Array Data Block specific fields */ \ - + (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \ +#define H5FA_DBLOCK_PREFIX_SIZE(d) \ + (/* General metadata fields */ \ + H5FA_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Sanity-checking fields */ \ + + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \ + \ + /* Fixed Array Data Block specific fields */ \ + + (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \ ) /* Size of the Fixed Array data block on disk */ -#define H5FA_DBLOCK_SIZE(d) ( \ - /* Data block prefix size */ \ - H5FA_DBLOCK_PREFIX_SIZE(d) \ - \ - /* Fixed Array Elements|Pages of Elements*/ \ - + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) \ - + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \ +#define H5FA_DBLOCK_SIZE(d) \ + (/* Data block prefix size */ \ + H5FA_DBLOCK_PREFIX_SIZE(d) \ + \ + /* Fixed Array Elements|Pages of Elements*/ \ + + ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) + \ + ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \ ) /* Size of the Fixed Array data block page on disk */ -#define H5FA_DBLK_PAGE_SIZE(h, nelmts) ( \ - /* Fixed Array Data Block Page */ \ - + (nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ - + H5FA_SIZEOF_CHKSUM /* Checksum for each page */ \ +#define H5FA_DBLK_PAGE_SIZE(h, nelmts) \ + ( /* Fixed Array Data Block Page */ \ + +(nelmts * (size_t)(h)->cparam.raw_elmt_size) /* Elements in data block page */ \ + + H5FA_SIZEOF_CHKSUM /* Checksum for each page */ \ ) /****************************/ @@ -122,48 +117,48 @@ typedef struct H5FA_hdr_t { H5AC_info_t cache_info; /* Fixed array configuration/creation parameters (stored in header) */ - H5FA_create_t cparam; /* Creation parameters for Fixed Array */ + H5FA_create_t cparam; /* Creation parameters for Fixed Array */ /* Fixed Array data block information (stored in header) */ - haddr_t dblk_addr; /* Address of Fixed Array Data block */ + haddr_t dblk_addr; /* Address of Fixed Array Data block */ /* Statistics for Fixed Array (stored in header) */ - H5FA_stat_t stats; /* Statistcs for Fixed Array */ + H5FA_stat_t stats; /* Statistcs for Fixed Array */ /* Computed/cached values (not stored in header) */ - 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 */ - 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 */ - size_t sizeof_size; /* Size of file sizes */ + 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 */ + 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 */ + size_t sizeof_size; /* Size of file sizes */ /* Client information (not stored) */ - void *cb_ctx; /* Callback context */ + void *cb_ctx; /* Callback context */ /* 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 - * parent, if it exists, otherwise NULL. - * If the fixed array is being used - * to index a chunked dataset and the - * dataset metadata is modified by a - * SWMR writer, this field will be set - * equal to the object header proxy - * that is the flush dependency parent - * of the fixed array header. - * - * The field is used to avoid duplicate - * setups of the flush dependency - * relationship, and to allow the - * fixed array header to destroy - * the flush dependency on receipt of - * an eviction notification from the - * metadata cache. - */ + 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 + * parent, if it exists, otherwise NULL. + * If the fixed array is being used + * to index a chunked dataset and the + * dataset metadata is modified by a + * SWMR writer, this field will be set + * equal to the object header proxy + * that is the flush dependency parent + * of the fixed array header. + * + * The field is used to avoid duplicate + * setups of the flush dependency + * relationship, and to allow the + * fixed array header to destroy + * the flush dependency on receipt of + * an eviction notification from the + * metadata cache. + */ } H5FA_hdr_t; /* The fixed array data block information */ @@ -172,25 +167,25 @@ typedef struct H5FA_dblock_t { H5AC_info_t cache_info; /* 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 */ + uint8_t *dblk_page_init; /* Bitmap of whether a data block page is initialized */ + void * elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ - H5FA_hdr_t *hdr; /* Shared array header info */ + H5FA_hdr_t *hdr; /* Shared array header info */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ /* 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 */ + 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 */ /* Fixed Array data block information (not stored) */ - size_t dblk_page_nelmts; /* # of elements per data block page */ - size_t dblk_page_size; /* Size of a data block page */ - size_t dblk_page_init_size; /* Size of 'page init' bitmask */ + size_t dblk_page_nelmts; /* # of elements per data block page */ + size_t dblk_page_size; /* Size of a data block page */ + size_t dblk_page_init_size; /* Size of 'page init' bitmask */ } H5FA_dblock_t; /* The fixed array data block page information */ @@ -199,50 +194,48 @@ typedef struct H5FA_dbk_page_t { H5AC_info_t cache_info; /* Fixed array information (stored) */ - void *elmts; /* Buffer for elements stored in data block page */ + void *elmts; /* Buffer for elements stored in data block page */ /* Internal array information (not stored) */ - H5FA_hdr_t *hdr; /* Shared array header info */ + H5FA_hdr_t *hdr; /* Shared array header info */ /* SWMR / Flush dependency information (not stored) */ - H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ + H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ /* Computed/cached values (not stored) */ - haddr_t addr; /* Address of this data block page on disk */ - size_t size; /* Size of data block page on disk */ - size_t nelmts; /* Number of elements in data block page */ + haddr_t addr; /* Address of this data block page on disk */ + size_t size; /* Size of data block page on disk */ + size_t nelmts; /* Number of elements in data block page */ } H5FA_dblk_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 */ + H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */ + 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 */ - haddr_t addr; /* Address of header on disk */ - void *ctx_udata; /* User context for class */ + H5F_t * f; /* Pointer to file for fixed array */ + haddr_t addr; /* Address of header on disk */ + void * ctx_udata; /* User context for class */ } H5FA_hdr_cache_ud_t; /* Info needed for loading data block */ typedef struct H5FA_dblock_cache_ud_t { - H5FA_hdr_t *hdr; /* Shared fixed array information */ - haddr_t dblk_addr; /* Address of data block on disk */ + H5FA_hdr_t *hdr; /* Shared fixed array information */ + haddr_t dblk_addr; /* Address of data block on disk */ } H5FA_dblock_cache_ud_t; /* Info needed for loading data block page */ typedef struct H5FA_dblk_page_cache_ud_t { H5FA_hdr_t *hdr; /* Shared fixed array information */ - size_t nelmts; /* Number of elements in data block page */ + size_t nelmts; /* Number of elements in data block page */ haddr_t dblk_page_addr; /* Address of data block page on disk */ } H5FA_dblk_page_cache_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -253,58 +246,57 @@ H5_DLLVAR const H5FA_class_t H5FA_CLS_TEST[1]; /* Array of fixed array client ID -> client class mappings */ H5_DLLVAR const H5FA_class_t *const H5FA_client_class_g[H5FA_NUM_CLS_ID]; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Generic routines */ -H5_DLL herr_t H5FA__create_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); -H5_DLL herr_t H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, - H5AC_info_t *child_entry); +H5_DLL herr_t H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); +H5_DLL herr_t H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Header routines */ 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 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); -H5_DLL herr_t H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr); -H5_DLL size_t H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_modified(H5FA_hdr_t *hdr); +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 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); +H5_DLL herr_t H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr); +H5_DLL size_t H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_modified(H5FA_hdr_t *hdr); H5_DLL H5FA_hdr_t *H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags); -H5_DLL herr_t H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags); -H5_DLL herr_t H5FA__hdr_delete(H5FA_hdr_t *hdr); -H5_DLL herr_t H5FA__hdr_dest(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags); +H5_DLL herr_t H5FA__hdr_delete(H5FA_hdr_t *hdr); +H5_DLL herr_t H5FA__hdr_dest(H5FA_hdr_t *hdr); /* Data block routines */ H5_DLL H5FA_dblock_t *H5FA__dblock_alloc(H5FA_hdr_t *hdr); -H5_DLL haddr_t H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty); -H5_DLL unsigned H5FA__dblock_sblk_idx(const H5FA_hdr_t *hdr, hsize_t idx); +H5_DLL haddr_t H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty); +H5_DLL unsigned H5FA__dblock_sblk_idx(const H5FA_hdr_t *hdr, hsize_t idx); H5_DLL H5FA_dblock_t *H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags); -H5_DLL herr_t H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags); -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); +H5_DLL herr_t H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags); +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 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); -H5_DLL herr_t H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags); -H5_DLL herr_t H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page); +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); +H5_DLL herr_t H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags); +H5_DLL herr_t H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page); /* Debugging routines for dumping file structures */ -H5_DLL 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); -H5_DLL 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); +H5_DLL 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); +H5_DLL 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); /* Testing routines */ #ifdef H5FA_TESTING H5_DLL herr_t H5FA__get_cparam_test(const H5FA_t *ea, H5FA_create_t *cparam); -H5_DLL int H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2); +H5_DLL int H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2); #endif /* H5FA_TESTING */ -#endif /* _H5FApkg_H */ - +#endif /* H5FApkg_H */ diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h index 98a9af4c5dc..26057bf4e15 100644 --- a/src/H5FAprivate.h +++ b/src/H5FAprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,8 +21,8 @@ *------------------------------------------------------------------------- */ -#ifndef _H5FAprivate_H -#define _H5FAprivate_H +#ifndef H5FAprivate_H +#define H5FAprivate_H /* Include package's public header */ #ifdef NOT_YET @@ -30,28 +30,26 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* Fixed Array class IDs */ typedef enum H5FA_cls_id_t { - H5FA_CLS_CHUNK_ID = 0, /* Fixed array is for indexing dataset chunks w/o filters */ - H5FA_CLS_FILT_CHUNK_ID, /* Fixed array is for indexing dataset chunks w/filters */ + H5FA_CLS_CHUNK_ID = 0, /* Fixed array is for indexing dataset chunks w/o filters */ + H5FA_CLS_FILT_CHUNK_ID, /* Fixed array is for indexing dataset chunks w/filters */ /* Start real class IDs at 0 -QAK */ /* (keep these last) */ - H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */ - H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */ + H5FA_CLS_TEST_ID, /* Fixed array is for testing (do not use for actual data) */ + H5FA_NUM_CLS_ID /* Number of Fixed Array class IDs (must be last) */ } H5FA_cls_id_t; /* @@ -59,40 +57,44 @@ typedef enum H5FA_cls_id_t { * variable of this type that contains class variables and methods. */ 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) */ - size_t nat_elmt_size; /* Size of native (memory) element */ + H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */ + 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, 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 */ - herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */ + void *(*crt_context)(void *udata); /* Create context for other callbacks */ + herr_t (*dst_context)(void *ctx); /* Destroy context */ + herr_t (*fill)(void * nat_blk, + size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ + herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, + void *ctx); /* Encode elements from native form to disk storage form */ + herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, + void *ctx); /* Decode elements from disk storage form to native form */ + herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, + const void *elmt); /* Print an element for debugging */ void *(*crt_dbg_ctx)(H5F_t *f, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ + herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ } H5FA_class_t; /* Fixed array creation parameters */ typedef struct H5FA_create_t { - const H5FA_class_t *cls; /* Class of Fixed Array to create */ - uint8_t raw_elmt_size; /* Element size in file (in bytes) */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - - * i.e. # of bits needed to store max. # of elements - * in a data block page - */ - hsize_t nelmts; /* # of elements in array */ + const H5FA_class_t *cls; /* Class of Fixed Array to create */ + uint8_t raw_elmt_size; /* Element size in file (in bytes) */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - + * i.e. # of bits needed to store max. # of elements + * in a data block page + */ + hsize_t nelmts; /* # of elements in array */ } H5FA_create_t; /* Fixed array metadata statistics info */ typedef struct H5FA_stat_t { /* Non-stored (i.e. computed) fields */ - hsize_t hdr_size; /* Size of header */ - hsize_t dblk_size; /* Size of data block */ + hsize_t hdr_size; /* Size of header */ + hsize_t dblk_size; /* Size of data block */ /* Stored fields */ - hsize_t nelmts; /* # of elements */ + hsize_t nelmts; /* # of elements */ } H5FA_stat_t; /* Fixed Array info (forward decl - defined in H5FApkg.h) */ @@ -101,7 +103,6 @@ typedef struct H5FA_t H5FA_t; /* Define the operator callback function pointer for H5FA_iterate() */ typedef int (*H5FA_operator_t)(hsize_t idx, const void *_elmt, void *_udata); - /*****************************/ /* Library-private Variables */ /*****************************/ @@ -112,24 +113,22 @@ H5_DLLVAR const H5FA_class_t H5FA_CLS_CHUNK[1]; /* The Fixed Array class for dataset chunks w/ filters*/ H5_DLLVAR const H5FA_class_t H5FA_CLS_FILT_CHUNK[1]; - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL H5FA_t *H5FA_create(H5F_t *f, const H5FA_create_t *cparam, - void *ctx_udata); +H5_DLL H5FA_t *H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata); H5_DLL H5FA_t *H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata); -H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts); -H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr); -H5_DLL herr_t H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt); -H5_DLL herr_t H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt); -H5_DLL herr_t H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent); -H5_DLL herr_t H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata); -H5_DLL herr_t H5FA_close(H5FA_t *fa); -H5_DLL herr_t H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata); -H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); +H5_DLL herr_t H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts); +H5_DLL herr_t H5FA_get_addr(const H5FA_t *fa, haddr_t *addr); +H5_DLL herr_t H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt); +H5_DLL herr_t H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt); +H5_DLL herr_t H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent); +H5_DLL herr_t H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata); +H5_DLL herr_t H5FA_close(H5FA_t *fa); +H5_DLL herr_t H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata); +H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); @@ -138,5 +137,4 @@ H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); #ifdef H5FA_DEBUGGING #endif /* H5FA_DEBUGGING */ -#endif /* _H5FAprivate_H */ - +#endif /* H5FAprivate_H */ diff --git a/src/H5FAstat.c b/src/H5FAstat.c index 882da99d1d7..1fdf47fc913 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,59 +24,48 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ - +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FA_get_stats * @@ -89,14 +78,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, -herr_t, SUCCEED, -, -H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) +BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) - /* Local variables */ +/* Local variables */ #ifdef H5FA_DEBUG -HDfprintf(stderr, "%s: Called\n", FUNC); + HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ /* @@ -108,5 +95,4 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Copy fixed array statistics */ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats)); -END_FUNC(PRIV) /* end H5FA_get_stats() */ - +END_FUNC(PRIV) /* end H5FA_get_stats() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 2bcdc0136fd..6dd6e00c5b1 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,32 +20,28 @@ /* Module Declaration */ /**********************/ -#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ +#include "H5FAmodule.h" /* This source code file is part of the H5FA module */ #define H5FA_TESTING - /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FApkg.h" /* Fixed Arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FApkg.h" /* Fixed Arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Sanity checking value for callback contexts */ -#define H5FA__TEST_BOGUS_VAL 42 - +#define H5FA__TEST_BOGUS_VAL 42 /******************/ /* Local Typedefs */ @@ -53,35 +49,32 @@ /* Callback context */ typedef struct H5FA__test_ctx_t { - uint32_t bogus; /* Placeholder field to verify that context is working */ + uint32_t bogus; /* Placeholder field to verify that context is working */ } H5FA__test_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 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 */ /*********************/ /* Fixed array testing class information */ -const H5FA_class_t H5FA_CLS_TEST[1]={{ +const H5FA_class_t H5FA_CLS_TEST[1] = {{ H5FA_CLS_TEST_ID, /* Type of Fixed array */ "Testing", /* Name of fixed array class */ sizeof(uint64_t), /* Size of native element */ @@ -95,12 +88,10 @@ const H5FA_class_t H5FA_CLS_TEST[1]={{ H5FA__test_dst_context /* Destroy debugging context */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -108,8 +99,6 @@ const H5FA_class_t H5FA_CLS_TEST[1]={{ /* Declare a free list to manage the H5FA__test_ctx_t struct */ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5FA__test_crt_context * @@ -123,15 +112,13 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -void *, NULL, NULL, -H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) +BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) /* Local variables */ - H5FA__test_ctx_t *ctx; /* Context for callbacks */ + H5FA__test_ctx_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") /* Initialize the context */ @@ -140,11 +127,10 @@ H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__test_crt_context() */ +END_FUNC(STATIC) /* end H5FA__test_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_dst_context * @@ -157,12 +143,10 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_dst_context(void *_ctx)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_dst_context(void *_ctx)) /* Local variables */ - H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ + H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ /* Sanity checks */ HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); @@ -170,9 +154,8 @@ H5FA__test_dst_context(void *_ctx)) /* Release context structure */ ctx = H5FL_FREE(H5FA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5FA__test_dst_context() */ +END_FUNC(STATIC) /* end H5FA__test_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_fill * @@ -185,12 +168,10 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, -H5FA__test_fill(void *nat_blk, size_t nelmts)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_fill(void *nat_blk, size_t nelmts)) /* Local variables */ - uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ + uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ /* Sanity checks */ HDassert(nat_blk); @@ -198,9 +179,8 @@ H5FA__test_fill(void *nat_blk, size_t nelmts)) H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5FA__test_fill() */ +END_FUNC(STATIC) /* end H5FA__test_fill() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_encode * @@ -213,15 +193,14 @@ 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)) +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 */ +/* Local variables */ #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 */ + 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 */ /* Sanity checks */ HDassert(raw); @@ -230,7 +209,7 @@ H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUS HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Encode native elements into raw elements */ - while(nelmts) { + while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ UINT64ENCODE(raw, *elmt); @@ -242,9 +221,8 @@ H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUS nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_encode() */ +END_FUNC(STATIC) /* end H5FA__test_encode() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_decode * @@ -257,16 +235,15 @@ 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)) +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 */ +/* Local variables */ #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 */ + 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 */ /* Sanity checks */ HDassert(raw); @@ -275,7 +252,7 @@ H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNU HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Decode raw elements into native elements */ - while(nelmts) { + while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ UINT64DECODE(raw, *elmt); @@ -287,9 +264,8 @@ H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNU nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_decode() */ +END_FUNC(STATIC) /* end H5FA__test_decode() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_debug * @@ -302,13 +278,11 @@ 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)) +BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, + H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) /* Local variables */ - char temp_str[128]; /* Temporary string, for formatting */ + char temp_str[128]; /* Temporary string, for formatting */ /* Sanity checks */ HDassert(stream); @@ -317,11 +291,10 @@ H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /* Print element */ HDsprintf(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); + (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5FA__test_debug() */ +END_FUNC(STATIC) /* end H5FA__test_debug() */ - /*------------------------------------------------------------------------- * Function: H5FA__test_crt_dbg_context * @@ -335,15 +308,14 @@ 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)) +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 */ - H5FA__test_ctx_t *ctx; /* Context for callbacks */ + H5FA__test_ctx_t *ctx; /* Context for callbacks */ /* Allocate new context structure */ - if(NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") /* Initialize the context */ @@ -352,11 +324,10 @@ H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_a /* Set return value */ ret_value = ctx; -CATCH + CATCH -END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ +END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ - /*------------------------------------------------------------------------- * Function: H5FA__get_cparam_test * @@ -369,9 +340,7 @@ 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)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) /* Check arguments. */ HDassert(fa); @@ -379,11 +348,10 @@ H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) /* Get fixed array creation parameters */ cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; - cparam->nelmts = fa->hdr->cparam.nelmts; + cparam->nelmts = fa->hdr->cparam.nelmts; -END_FUNC(PKG) /* end H5FA__get_cparam_test() */ +END_FUNC(PKG) /* end H5FA__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5FA__cmp_cparam_test * @@ -396,21 +364,19 @@ END_FUNC(PKG) /* end H5FA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, -int, 0, -, -H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) +BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, + H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) /* Check arguments. */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ - if(cparam1->raw_elmt_size < cparam2->raw_elmt_size) + if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) H5_LEAVE(-1) - else if(cparam1->raw_elmt_size > cparam2->raw_elmt_size) + else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) H5_LEAVE(1) -CATCH - -END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ + CATCH +END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ diff --git a/src/H5FD.c b/src/H5FD.c index 991b7b71155..11cbdc4868c 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,43 +23,39 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5FD__free_cls(H5FD_class_t *cls); -static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags/*out*/); +static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/); /*********************/ /* Package Variables */ @@ -68,12 +64,10 @@ static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags/*out*/); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -94,14 +88,12 @@ static unsigned long H5FD_file_serial_no_g; /* File driver ID class */ static const H5I_class_t H5I_VFL_CLS[1] = {{ - H5I_VFL, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */ + H5I_VFL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -114,11 +106,11 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ herr_t H5FD__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - if(H5I_register_type(H5I_VFL_CLS) < 0) + if (H5I_register_type(H5I_VFL_CLS) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Reset the file serial numbers */ @@ -128,7 +120,6 @@ H5FD__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_term_package * @@ -147,29 +138,28 @@ H5FD__init_package(void) int H5FD_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - if(H5I_nmembers(H5I_VFL) > 0) { + if (H5_PKG_INIT_VAR) { + if (H5I_nmembers(H5I_VFL) > 0) { (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Destroy the VFL driver ID group */ n += (H5I_dec_type_ref(H5I_VFL) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5FD_term_package() */ - /*------------------------------------------------------------------------- * Function: H5FD__free_cls * @@ -195,8 +185,9 @@ H5FD__free_cls(H5FD_class_t *cls) * driver a chance to free singletons or other resources which will become * invalid once the class structure is freed. */ - if(cls->terminate && cls->terminate() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEOBJ, FAIL, "virtual file driver '%s' did not terminate cleanly", cls->name) + if (cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEOBJ, FAIL, "virtual file driver '%s' did not terminate cleanly", + cls->name) H5MM_xfree(cls); @@ -204,7 +195,6 @@ H5FD__free_cls(H5FD_class_t *cls) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__free_cls() */ - /*------------------------------------------------------------------------- * Function: H5FDregister * @@ -224,36 +214,38 @@ H5FD__free_cls(H5FD_class_t *cls) hid_t H5FDregister(const H5FD_class_t *cls) { - H5FD_mem_t type; - hid_t ret_value = H5I_INVALID_HID; + H5FD_mem_t type; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", cls); /* Check arguments */ - if(!cls) + if (!cls) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null class pointer is disallowed") - if(!cls->open || !cls->close) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'open' and/or 'close' methods are not defined") - if(!cls->get_eoa || !cls->set_eoa) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eoa' and/or 'set_eoa' methods are not defined") - if(!cls->get_eof) + if (!cls->open || !cls->close) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'open' and/or 'close' methods are not defined") + if (!cls->get_eoa || !cls->set_eoa) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'get_eoa' and/or 'set_eoa' methods are not defined") + if (!cls->get_eof) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eof' method is not defined") - if(!cls->read || !cls->write) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'read' and/or 'write' method is not defined") + if (!cls->read || !cls->write) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'read' and/or 'write' method is not defined") for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) - if(cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES) + if (cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid free-list mapping") /* Create the new class ID */ - if((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0) + if ((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: FUNC_LEAVE_API(ret_value) } /* end H5FDregister() */ - /*------------------------------------------------------------------------- * Function: H5FD_register * @@ -273,10 +265,10 @@ H5FDregister(const H5FD_class_t *cls) 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_mem_t type; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + const H5FD_class_t *cls = (const H5FD_class_t *)_cls; + H5FD_class_t * saved = NULL; + H5FD_mem_t type; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -286,28 +278,28 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) HDassert(cls->get_eoa && cls->set_eoa); HDassert(cls->get_eof); HDassert(cls->read && cls->write); - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { HDassert(cls->fl_map[type] >= H5FD_MEM_NOLIST && cls->fl_map[type] < H5FD_MEM_NTYPES); } /* Copy the class structure so the caller can reuse or free it */ - if(NULL == (saved = (H5FD_class_t *)H5MM_malloc(size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for file driver class struct") + if (NULL == (saved = (H5FD_class_t *)H5MM_malloc(size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, + "memory allocation failed for file driver class struct") H5MM_memcpy(saved, cls, size); /* Create the new class ID */ - if((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) + if ((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: - if(H5I_INVALID_HID == ret_value) - if(saved) + if (H5I_INVALID_HID == ret_value) + if (saved) saved = (H5FD_class_t *)H5MM_xfree(saved); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_register() */ - /*------------------------------------------------------------------------- * Function: H5FDunregister * @@ -323,24 +315,23 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) herr_t H5FDunregister(hid_t driver_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", driver_id); /* Check arguments */ - if(NULL == H5I_object_verify(driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver") /* The H5FD_class_t struct will be freed by this function */ - if(H5I_dec_app_ref(driver_id) < 0) + if (H5I_dec_app_ref(driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver") done: FUNC_LEAVE_API(ret_value) } /* end H5FDunregister() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_class * @@ -361,23 +352,23 @@ H5FDunregister(hid_t driver_id) H5FD_class_t * H5FD_get_class(hid_t id) { - H5FD_class_t *ret_value = NULL; + H5FD_class_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - if(H5I_VFL == H5I_get_type(id)) + if (H5I_VFL == H5I_get_type(id)) ret_value = (H5FD_class_t *)H5I_object(id); else { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") ret_value = H5FD_get_class(driver_prop.driver_id); } /* end if */ @@ -389,7 +380,6 @@ H5FD_get_class(hid_t id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_class() */ - /*------------------------------------------------------------------------- * Function: H5FD_sb_size * @@ -406,7 +396,7 @@ H5FD_get_class(hid_t id) hsize_t H5FD_sb_size(H5FD_t *file) { - hsize_t ret_value = 0; + hsize_t ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -415,14 +405,13 @@ H5FD_sb_size(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_size) + if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_sb_encode * @@ -438,9 +427,9 @@ H5FD_sb_size(H5FD_t *file) *------------------------------------------------------------------------- */ herr_t -H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) +H5FD_sb_encode(H5FD_t *file, char *name /*out*/, uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -449,14 +438,13 @@ H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_encode && (file->cls->sb_encode)(file, name/*out*/, buf/*out*/) < 0) + if (file->cls->sb_encode && (file->cls->sb_encode)(file, name /*out*/, buf /*out*/) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sb_encode() */ - /*------------------------------------------------------------------------- * Function: H5FD__sb_decode * @@ -469,7 +457,7 @@ H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf) static herr_t H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -478,14 +466,13 @@ H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) + if (file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sb_decode() */ - /*------------------------------------------------------------------------- * Function: H5FD_sb_load * @@ -498,7 +485,7 @@ H5FD__sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -509,20 +496,19 @@ H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf) /* Check if driver matches driver information saved. Unfortunately, we can't push this * function to each specific driver because we're checking if the driver is correct. */ - if(!HDstrncmp(name, "NCSAfami", (size_t)8) && HDstrcmp(file->cls->name, "family")) + if (!HDstrncmp(name, "NCSAfami", (size_t)8) && HDstrcmp(file->cls->name, "family") != 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "family driver should be used") - if(!HDstrncmp(name, "NCSAmult", (size_t)8) && HDstrcmp(file->cls->name, "multi")) + if (!HDstrncmp(name, "NCSAmult", (size_t)8) && HDstrcmp(file->cls->name, "multi") != 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "multi driver should be used") /* Decode driver information */ - if(H5FD__sb_decode(file, name, buf) < 0) + if (H5FD__sb_decode(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDECODE, FAIL, "unable to decode driver information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sb_load() */ - /*------------------------------------------------------------------------- * Function: H5FD_fapl_get * @@ -548,7 +534,7 @@ H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf) void * H5FD_fapl_get(H5FD_t *file) { - void *ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -557,14 +543,13 @@ H5FD_fapl_get(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->fapl_get) + if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD_free_driver_info * @@ -577,22 +562,22 @@ H5FD_fapl_get(H5FD_t *file) herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(driver_id > 0 && driver_info) { - H5FD_class_t *driver; + if (driver_id > 0 && driver_info) { + H5FD_class_t *driver; /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Allow driver to free info or do it ourselves */ - if(driver->fapl_free) { + if (driver->fapl_free) { /* Free the const pointer */ /* Cast through uintptr_t to de-const memory */ - if((driver->fapl_free)((void *)(uintptr_t)driver_info) < 0) + if ((driver->fapl_free)((void *)(uintptr_t)driver_info) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") } else @@ -603,7 +588,6 @@ H5FD_free_driver_info(hid_t driver_id, const void *driver_info) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_free_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5FDopen * @@ -657,27 +641,25 @@ H5FD_free_driver_info(hid_t driver_id, const void *driver_info) H5FD_t * H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_t *ret_value = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_API(NULL) H5TRACE4("*x", "*sIuia", name, flags, fapl_id, maxaddr); /* Check arguments */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(fapl_id,H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Call private function */ - if(NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr))) + if (NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_open * @@ -692,52 +674,52 @@ 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_driver_prop_t driver_prop; /* Property for driver ID & info */ - 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_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 */ + 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 */ FUNC_ENTER_NOAPI(NULL) /* Sanity checks */ - if(0 == maxaddr) + if (0 == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range") /* Get file access property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Get the VFD to open the file with */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") /* Get driver info */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id))) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list") - if(NULL == driver->open) + if (NULL == driver->open) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method") /* Query driver flag */ - if(H5FD_driver_query(driver, &driver_flags) < 0) + if (H5FD_driver_query(driver, &driver_flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't query VFD flags") /* Get initial file image info */ - if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file image info") /* If an image is provided, make sure the driver supports this feature */ HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) || ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); - if((file_image_info.buffer != NULL) && !(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) + if ((file_image_info.buffer != NULL) && !(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file image set, but not supported.") /* Dispatch to file driver */ - if(HADDR_UNDEF == maxaddr) + if (HADDR_UNDEF == maxaddr) maxaddr = driver->maxaddr; - if(NULL == (file = (driver->open)(name, flags, fapl_id, maxaddr))) + if (NULL == (file = (driver->open)(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed") /* Set the file access flags */ @@ -747,21 +729,21 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) * driver ID to prevent it from being freed while this file is open. */ file->driver_id = driver_prop.driver_id; - if(H5I_inc_ref(file->driver_id, FALSE) < 0) + if (H5I_inc_ref(file->driver_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - file->cls = driver; + file->cls = driver; file->maxaddr = maxaddr; - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") /* Retrieve the VFL driver feature flags */ - if(H5FD__query(file, &(file->feature_flags)) < 0) + if (H5FD__query(file, &(file->feature_flags)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver") /* Increment the global serial number & assign it to this H5FD_t object */ - if(++H5FD_file_serial_no_g == 0) { + if (++H5FD_file_serial_no_g == 0) { /* (Just error out if we wrap around for now...) */ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to get file serial number") } /* end if */ @@ -779,7 +761,6 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_open() */ - /*------------------------------------------------------------------------- * Function: H5FDclose * @@ -796,26 +777,25 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) herr_t H5FDclose(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", file); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_close(file) < 0) + if (H5FD_close(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") done: FUNC_LEAVE_API(ret_value) } /* end H5FDclose() */ - /*------------------------------------------------------------------------- * Function: H5FD_close * @@ -839,21 +819,20 @@ H5FD_close(H5FD_t *file) /* Prepare to close file by clearing all public fields */ driver = file->cls; - if(H5I_dec_ref(file->driver_id) < 0) + if (H5I_dec_ref(file->driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") /* Dispatch to the driver for actual close. If the driver fails to * close the file then the file will be in an unusable state. */ HDassert(driver->close); - if((driver->close)(file) < 0) + if ((driver->close)(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "close failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_close() */ - /*------------------------------------------------------------------------- * Function: H5FDcmp * @@ -876,7 +855,7 @@ H5FD_close(H5FD_t *file) int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value = -1; + int ret_value = -1; FUNC_ENTER_API(-1) /* return value is arbitrary */ H5TRACE2("Is", "*x*x", f1, f2); @@ -888,7 +867,6 @@ H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) FUNC_LEAVE_API(ret_value) } /* end H5FDcmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_cmp * @@ -903,26 +881,26 @@ H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */ - if((!f1 || !f1->cls) && (!f2 || !f2->cls)) + if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) - if(!f1 || !f1->cls) + if (!f1 || !f1->cls) HGOTO_DONE(-1) - if(!f2 || !f2->cls) + if (!f2 || !f2->cls) HGOTO_DONE(1) - if(f1->cls < f2->cls) + if (f1->cls < f2->cls) HGOTO_DONE(-1) - if(f1->cls > f2->cls) + if (f1->cls > f2->cls) HGOTO_DONE(1) /* Files are same driver; no cmp callback */ - if(!f1->cls->cmp) { - if(f1 < f2) + if (!f1->cls->cmp) { + if (f1 < f2) HGOTO_DONE(-1) - if(f1 > f2) + if (f1 > f2) HGOTO_DONE(1) HGOTO_DONE(0) } @@ -934,7 +912,6 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FDquery * @@ -946,30 +923,29 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) *------------------------------------------------------------------------- */ int -H5FDquery(const H5FD_t *file, unsigned long *flags/*out*/) +H5FDquery(const H5FD_t *file, unsigned long *flags /*out*/) { - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_API((-1)) H5TRACE2("Is", "*xx", file, flags); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file class pointer cannot be NULL") - if(!flags) + if (!flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "flags parameter cannot be NULL") /* Call private function */ - if(H5FD__query(file, flags) < 0) + if (H5FD__query(file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "unable to query feature flags") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_query * @@ -980,9 +956,9 @@ H5FDquery(const H5FD_t *file, unsigned long *flags/*out*/) *------------------------------------------------------------------------- */ static herr_t -H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/) +H5FD__query(const H5FD_t *file, unsigned long *flags /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -992,18 +968,17 @@ H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/) HDassert(flags); /* Dispatch to driver (if available) */ - if(file->cls->query) { - if((file->cls->query)(file, flags) < 0) + if (file->cls->query) { + if ((file->cls->query)(file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to query feature flags") } else - *flags=0; + *flags = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_query() */ - /*------------------------------------------------------------------------- * Function: H5FDalloc * @@ -1043,31 +1018,30 @@ H5FD__query(const H5FD_t *file, unsigned long *flags/*out*/) haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE4("a", "*xMtih", file, type, dxpl_id, size); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type") - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request") - if(H5P_DEFAULT == dxpl_id) + 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, HADDR_UNDEF, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL))) + if (HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") /* (Note compensating for base address subtraction in internal routine) */ @@ -1077,7 +1051,6 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) FUNC_LEAVE_API(ret_value) } /* end H5FDalloc() */ - /*------------------------------------------------------------------------- * Function: H5FDfree * @@ -1095,37 +1068,35 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xMtiah", file, type, dxpl_id, addr, size); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type") - if(H5P_DEFAULT == dxpl_id) + 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, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD__free_real(file, type, addr - file->base_addr, size) < 0) + if (H5FD__free_real(file, type, addr - file->base_addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDfree() */ - /*------------------------------------------------------------------------- * Function: H5FDget_eoa * @@ -1140,21 +1111,21 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE2("a", "*xMt", file, type); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file type") /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed") /* (Note compensating for base address subtraction in internal routine) */ @@ -1164,7 +1135,6 @@ H5FDget_eoa(H5FD_t *file, H5FD_mem_t type) FUNC_LEAVE_API(ret_value) } /* end H5FDget_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FDset_eoa * @@ -1189,31 +1159,30 @@ H5FDget_eoa(H5FD_t *file, H5FD_mem_t type) herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xMta", file, type, addr); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file type") - if(!H5F_addr_defined(addr) || addr > file->maxaddr) + if (!H5F_addr_defined(addr) || addr > file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value") /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_set_eoa(file, type, addr - file->base_addr) < 0) + if (H5FD_set_eoa(file, type, addr - file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDset_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FDget_eof * @@ -1238,19 +1207,19 @@ H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value; + haddr_t ret_value; FUNC_ENTER_API(HADDR_UNDEF) H5TRACE2("a", "*xMt", file, type); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") /* Call private function */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed") /* (Note compensating for base address subtraction in internal routine) */ @@ -1260,7 +1229,6 @@ H5FDget_eof(H5FD_t *file, H5FD_mem_t type) FUNC_LEAVE_API(ret_value) } /* end H5FDget_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_maxaddr * @@ -1274,7 +1242,7 @@ H5FDget_eof(H5FD_t *file, H5FD_mem_t type) haddr_t H5FD_get_maxaddr(const H5FD_t *file) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -1288,7 +1256,6 @@ H5FD_get_maxaddr(const H5FD_t *file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_maxaddr() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_feature_flags * @@ -1313,7 +1280,6 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_get_feature_flags() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_feature_flags * @@ -1337,7 +1303,6 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_feature_flags() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_fs_type_map * @@ -1350,7 +1315,7 @@ H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags) herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1360,9 +1325,9 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) HDassert(type_map); /* Check for VFD class providing a type map retrieval rouine */ - if(file->cls->get_type_map) { + if (file->cls->get_type_map) { /* Retrieve type mapping for this file */ - if((file->cls->get_type_map)(file, type_map) < 0) + if ((file->cls->get_type_map)(file, type_map) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get type map failed") } /* end if */ else @@ -1373,7 +1338,6 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_fs_type_map() */ - /*------------------------------------------------------------------------- * Function: H5FDread * @@ -1392,42 +1356,39 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) *------------------------------------------------------------------------- */ herr_t -H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - void *buf/*out*/) +H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiazx", file, type, dxpl_id, addr, size, buf); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(!buf) + if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + 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, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_read(file, type, addr - file->base_addr, size, buf) < 0) + if (H5FD_read(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDread() */ - /*------------------------------------------------------------------------- * Function: H5FDwrite * @@ -1441,42 +1402,39 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size *------------------------------------------------------------------------- */ herr_t -H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *buf) +H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiaz*x", file, type, dxpl_id, addr, size, buf); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(!buf) + if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ - if(H5P_DEFAULT == dxpl_id) + 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, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_write(file, type, addr - file->base_addr, size, buf) < 0) + if (H5FD_write(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDwrite() */ - /*------------------------------------------------------------------------- * Function: H5FDflush * @@ -1490,35 +1448,33 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xib", file, dxpl_id, closing); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(H5P_DEFAULT == dxpl_id) + 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, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(H5FD_flush(file, closing) < 0) + if (H5FD_flush(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDflush() */ - /*------------------------------------------------------------------------- * Function: H5FD_flush * @@ -1531,7 +1487,7 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) herr_t H5FD_flush(H5FD_t *file, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1540,14 +1496,13 @@ H5FD_flush(H5FD_t *file, hbool_t closing) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0) + if (file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_flush() */ - /*------------------------------------------------------------------------- * Function: H5FDtruncate * @@ -1560,36 +1515,34 @@ H5FD_flush(H5FD_t *file, hbool_t closing) herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xib", file, dxpl_id, closing); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(H5P_DEFAULT == dxpl_id) + 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, "not a data transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Call private function */ - if(H5FD_truncate(file, closing) < 0) + if (H5FD_truncate(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDtruncate() */ - /*------------------------------------------------------------------------- - * Function: H5FD_truncate + * Function: H5FD_truncate * * Purpose: Private version of H5FDtruncate() * @@ -1600,7 +1553,7 @@ H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) herr_t H5FD_truncate(H5FD_t *file, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1609,14 +1562,13 @@ H5FD_truncate(H5FD_t *file, hbool_t closing) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0) + if (file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver truncate request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FDlock * @@ -1629,27 +1581,25 @@ H5FD_truncate(H5FD_t *file, hbool_t closing) herr_t H5FDlock(H5FD_t *file, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*xb", file, rw); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_lock(file, rw) < 0) + if (H5FD_lock(file, rw) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "file lock request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDlock() */ - - /*------------------------------------------------------------------------- * Function: H5FD_lock * @@ -1662,7 +1612,7 @@ H5FDlock(H5FD_t *file, hbool_t rw) herr_t H5FD_lock(H5FD_t *file, hbool_t rw) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1671,14 +1621,13 @@ H5FD_lock(H5FD_t *file, hbool_t rw) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->lock && (file->cls->lock)(file, rw) < 0) + if (file->cls->lock && (file->cls->lock)(file, rw) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "driver lock request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_lock() */ - /*------------------------------------------------------------------------- * Function: H5FDunlock * @@ -1691,26 +1640,25 @@ H5FD_lock(H5FD_t *file, hbool_t rw) herr_t H5FDunlock(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", file); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") /* Call private function */ - if(H5FD_unlock(file) < 0) + if (H5FD_unlock(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "file unlock request failed") done: FUNC_LEAVE_API(ret_value) } /* end H5FDunlock() */ - /*------------------------------------------------------------------------- * Function: H5FD_unlock * @@ -1723,7 +1671,7 @@ H5FDunlock(H5FD_t *file) herr_t H5FD_unlock(H5FD_t *file) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1732,14 +1680,13 @@ H5FD_unlock(H5FD_t *file) HDassert(file->cls); /* Dispatch to driver */ - if(file->cls->unlock && (file->cls->unlock)(file) < 0) + if (file->cls->unlock && (file->cls->unlock)(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "driver unlock request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_unlock() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_fileno * @@ -1766,7 +1713,6 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_get_fileno() */ - /*-------------------------------------------------------------------------- * Function: H5FDget_vfd_handle * @@ -1786,27 +1732,26 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) H5TRACE3("e", "*xi**x", file, fapl_id, file_handle); /* Check arguments */ - if(!file) + if (!file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") - if(!file->cls) + if (!file->cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") - if(FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fapl_id parameter is not a file access property list") - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle parameter cannot be NULL") /* Call private function */ - if(H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0) + if (H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: - if(FAIL == ret_value) + if (FAIL == ret_value) *file_handle = NULL; FUNC_LEAVE_API(ret_value) } /* end H5FDget_vfd_handle() */ - /*-------------------------------------------------------------------------- * Function: H5FD_get_vfd_handle * @@ -1829,16 +1774,15 @@ H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) HDassert(file_handle); /* Dispatch to driver */ - if(NULL == file->cls->get_handle) + if (NULL == file->cls->get_handle) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method") - if((file->cls->get_handle)(file, fapl_id, file_handle) < 0) + if ((file->cls->get_handle)(file, fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_vfd_handle() */ - /*-------------------------------------------------------------------------- * Function: H5FD_set_base_addr * @@ -1863,7 +1807,6 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_base_addr() */ - /*-------------------------------------------------------------------------- * Function: H5FD_get_base_addr * @@ -1886,7 +1829,6 @@ H5FD_get_base_addr(const H5FD_t *file) FUNC_LEAVE_NOAPI(file->base_addr) } /* end H5FD_get_base_addr() */ - /*-------------------------------------------------------------------------- * Function: H5FD_set_paged_aggr * @@ -1910,30 +1852,29 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_paged_aggr() */ - /*------------------------------------------------------------------------- -* Function: H5FDdriver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver ID is passed -* in as a parameter. -* -* Return: Non-negative on success/Negative on failure -* -*------------------------------------------------------------------------- -*/ + * Function: H5FDdriver_query + * + * Purpose: Similar to H5FD_query(), but intended for cases when we don't + * have a file available (e.g. before one is opened). Since we + * can't use the file to get the driver, the driver ID is passed + * in as a parameter. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ herr_t -H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/) +H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/) { - H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", driver_id, flags); /* Check arguments */ - if(NULL == flags) + if (NULL == flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flags parameter cannot be NULL") /* Check for the driver to query and then query it */ @@ -1945,4 +1886,3 @@ H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/) done: FUNC_LEAVE_API(ret_value) } /* end H5FDdriver_query() */ - diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 7608d619861..3bb95f724ec 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,16 +22,16 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDcore.h" /* Core file driver */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDcore.h" /* Core file driver */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; @@ -41,8 +41,8 @@ static htri_t ignore_disabled_file_locks_s = FAIL; /* The skip list node type. Represents a region in the file. */ typedef struct H5FD_core_region_t { - haddr_t start; /* Start address of the region */ - haddr_t end; /* End address of the region */ + haddr_t start; /* Start address of the region */ + haddr_t end; /* End address of the region */ } H5FD_core_region_t; /* The description of a file belonging to this driver. The 'eoa' and 'eof' @@ -50,23 +50,24 @@ typedef struct H5FD_core_region_t { * of the file (the current size of the underlying memory). */ typedef struct H5FD_core_t { - H5FD_t pub; /* public stuff, must be first */ - char *name; /* for equivalence testing */ - unsigned char *mem; /* the underlying memory */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* current allocated size */ - size_t increment; /* multiples for mem allocation */ - hbool_t backing_store; /* write to file name on flush */ - size_t bstore_page_size; /* backing store page size */ - hbool_t ignore_disabled_file_locks; - int fd; /* backing store file descriptor */ + H5FD_t pub; /* public stuff, must be first */ + char * name; /* for equivalence testing */ + unsigned char *mem; /* the underlying memory */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* current allocated size */ + size_t increment; /* multiples for mem allocation */ + hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t bstore_page_size; /* backing store page size */ + hbool_t ignore_disabled_file_locks; + int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -82,25 +83,29 @@ typedef struct H5FD_core_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; - - HANDLE hFile; /* Native windows file handle */ -#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 */ + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; + + HANDLE hFile; /* Native windows file handle */ +#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 */ } H5FD_core_t; /* Driver-specific file access properties */ typedef struct H5FD_core_fapl_t { - size_t increment; /* how much to grow memory */ - hbool_t backing_store; /* write to file name on flush */ + size_t increment; /* how much to grow memory */ + hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t page_size; /* Page size for tracked writes */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_WRITE_TRACKING_FLAG FALSE +#define H5FD_CORE_WRITE_TRACKING_PAGE_SIZE 524288 /* These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. @@ -115,76 +120,73 @@ typedef struct H5FD_core_fapl_t { * REGION_OVERFLOW: Checks whether an address and size pair describe data * which can be addressed entirely in memory. */ -#define MAXADDR ((haddr_t)((~(size_t)0)-1)) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) -#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (size_t)((A)+(Z))<(size_t)(A)) +#define MAXADDR ((haddr_t)((~(size_t)0) - 1)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || (A) > (haddr_t)MAXADDR) +#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (size_t)((A) + (Z)) < (size_t)(A)) /* Prototypes */ -static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); -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 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); -static herr_t H5FD__core_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end); +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 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); +static herr_t H5FD__core_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__core_unlock(H5FD_t *_file); +static herr_t H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__core_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_core_g = { - "core", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__core_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_core_fapl_t), /* fapl_size */ - H5FD__core_fapl_get, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__core_open, /* open */ - H5FD__core_close, /* close */ - H5FD__core_cmp, /* cmp */ - H5FD__core_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__core_get_eoa, /* get_eoa */ - H5FD__core_set_eoa, /* set_eoa */ - H5FD__core_get_eof, /* get_eof */ - H5FD__core_get_handle, /* get_handle */ - H5FD__core_read, /* read */ - H5FD__core_write, /* write */ - H5FD__core_flush, /* flush */ - H5FD__core_truncate, /* truncate */ - H5FD__core_lock, /* lock */ - H5FD__core_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "core", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__core_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_core_fapl_t), /* fapl_size */ + H5FD__core_fapl_get, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__core_open, /* open */ + H5FD__core_close, /* close */ + H5FD__core_cmp, /* cmp */ + H5FD__core_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__core_get_eoa, /* get_eoa */ + H5FD__core_set_eoa, /* set_eoa */ + H5FD__core_get_eof, /* get_eof */ + H5FD__core_get_handle, /* get_handle */ + H5FD__core_read, /* read */ + H5FD__core_write, /* write */ + H5FD__core_flush, /* flush */ + H5FD__core_truncate, /* truncate */ + H5FD__core_lock, /* lock */ + H5FD__core_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Define a free list to manage the region type */ H5FL_DEFINE(H5FD_core_region_t); - /*------------------------------------------------------------------------- * Function: H5FD__core_add_dirty_region * @@ -198,13 +200,13 @@ H5FL_DEFINE(H5FD_core_region_t); static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) { - H5FD_core_region_t *b_item = NULL; - H5FD_core_region_t *a_item = NULL; - H5FD_core_region_t *item = NULL; - haddr_t b_addr = 0; - haddr_t a_addr = 0; - hbool_t create_new_node = TRUE; - herr_t ret_value = SUCCEED; + H5FD_core_region_t *b_item = NULL; + H5FD_core_region_t *a_item = NULL; + H5FD_core_region_t *item = NULL; + haddr_t b_addr = 0; + haddr_t a_addr = 0; + hbool_t create_new_node = TRUE; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -213,30 +215,30 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) HDassert(start <= end); /* Adjust the dirty region to the nearest block boundaries */ - if(start % file->bstore_page_size != 0) + if (start % file->bstore_page_size != 0) start = (start / file->bstore_page_size) * file->bstore_page_size; - if(end % file->bstore_page_size != (file->bstore_page_size - 1)) { + if (end % file->bstore_page_size != (file->bstore_page_size - 1)) { end = (((end / file->bstore_page_size) + 1) * file->bstore_page_size) - 1; - if(end > file->eof) + if (end > file->eof) end = file->eof - 1; } /* end if */ /* Get the regions before and after the intended insertion point */ - b_addr = start +1; + b_addr = start + 1; a_addr = end + 2; b_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &b_addr); a_item = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &a_addr); /* Check to see if we need to extend the upper end of the NEW region */ - if(a_item) - if(start < a_item->start && end < a_item->end) { + if (a_item) + if (start < a_item->start && end < a_item->end) { /* Extend the end of the NEW region to match the existing AFTER region */ end = a_item->end; } /* end if */ /* Attempt to extend the PREV region */ - if(b_item) - if(start <= b_item->end + 1) { + if (b_item) + if (start <= b_item->end + 1) { /* Need to set this for the delete algorithm */ start = b_item->start; @@ -248,10 +250,10 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) } /* end if */ /* Remove any old nodes that are no longer needed */ - while(a_item && a_item->start > start) { + while (a_item && a_item->start > start) { H5FD_core_region_t *less; - haddr_t key = a_item->start - 1; + haddr_t key = a_item->start - 1; /* Save the previous node before we trash this one */ less = (H5FD_core_region_t *)H5SL_less(file->dirty_list, &key); @@ -261,36 +263,36 @@ H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) a_item = H5FL_FREE(H5FD_core_region_t, a_item); /* Set up to check the next node */ - if(less) + if (less) a_item = less; } /* end while */ /* Insert the new node */ - if(create_new_node) { - if(NULL == (item = (H5FD_core_region_t *)H5SL_search(file->dirty_list, &start))) { + if (create_new_node) { + if (NULL == (item = (H5FD_core_region_t *)H5SL_search(file->dirty_list, &start))) { /* Ok to insert. No pre-existing node with that key. */ - item = (H5FD_core_region_t *)H5FL_CALLOC(H5FD_core_region_t); + item = (H5FD_core_region_t *)H5FL_CALLOC(H5FD_core_region_t); item->start = start; - item->end = end; - if(H5SL_insert(file->dirty_list, item, &item->start) < 0) - HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't insert new dirty region: (%llu, %llu)\n", (unsigned long long)start, (unsigned long long)end) + item->end = end; + if (H5SL_insert(file->dirty_list, item, &item->start) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't insert new dirty region: (%llu, %llu)\n", + (unsigned long long)start, (unsigned long long)end) } /* end if */ else { /* Store the new item endpoint if it's bigger */ item->end = (item->end < end) ? end : item->end; - } /* end else */ - } /* end if */ + } + } else { /* Update the size of the before region */ - if(b_item->end < end) + if (b_item->end < end) b_item->end = end; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_add_dirty_region() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_destroy_dirty_list * @@ -310,13 +312,13 @@ H5FD__core_destroy_dirty_list(H5FD_core_t *file) HDassert(file); /* Destroy the list, including any remaining list elements */ - if(file->dirty_list) { + if (file->dirty_list) { H5FD_core_region_t *region = NULL; - while(NULL != (region = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) + while (NULL != (region = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) region = H5FL_FREE(H5FD_core_region_t, region); - if(H5SL_close(file->dirty_list) < 0) + if (H5SL_close(file->dirty_list) < 0) HGOTO_ERROR(H5E_SLIST, H5E_CLOSEERROR, FAIL, "can't close core vfd dirty list") file->dirty_list = NULL; } /* end if */ @@ -325,7 +327,6 @@ H5FD__core_destroy_dirty_list(H5FD_core_t *file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_destroy_dirty_list() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_write_to_bstore * @@ -338,11 +339,11 @@ 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) { - unsigned char *ptr = file->mem + addr; /* mutable pointer into the - * buffer (can't change mem) - */ - HDoff_t offset = (HDoff_t)addr; /* Offset to write at */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned char *ptr = file->mem + addr; /* mutable pointer into the + * buffer (can't change mem) + */ + HDoff_t offset = (HDoff_t)addr; /* Offset to write at */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -350,19 +351,19 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if((HDoff_t)addr != HDlseek(file->fd, (off_t)addr, SEEK_SET)) + if ((HDoff_t)addr != HDlseek(file->fd, (off_t)addr, SEEK_SET)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store") #endif /* H5_HAVE_PREADWRITE */ while (size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -370,20 +371,26 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, ptr, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, ptr, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "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, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "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, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -398,7 +405,6 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_write_to_bstore() */ - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -411,28 +417,27 @@ 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 */ - herr_t ret_value = SUCCEED; + char * lock_env_var = NULL; /* Environment variable pointer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - if(H5FD_core_init() < 0) + if (H5FD_core_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize core VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_core_init * @@ -450,11 +455,11 @@ H5FD__init_package(void) hid_t H5FD_core_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) + if (H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -464,7 +469,6 @@ H5FD_core_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__core_term * @@ -488,7 +492,98 @@ H5FD__core_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__core_term() */ - +/*------------------------------------------------------------------------- + * Function: H5Pset_core_write_tracking + * + * Purpose: Enables/disables core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); + + /* The page size cannot be zero */ + if (page_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if (H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if (NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); + fa.increment = old_fa->increment; + fa.backing_store = old_fa->backing_store; + fa.write_tracking = is_enabled; + fa.page_size = page_size; + + /* Set the property values & the driver for the FAPL */ + if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_core_write_tracking() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_core_write_tracking + * + * Purpose: Gets information about core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +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 */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if (H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Get values */ + if (is_enabled) + *is_enabled = fa->write_tracking; + if (page_size) + *page_size = fa->page_size; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_core_write_tracking() */ + /*------------------------------------------------------------------------- * Function: H5Pset_fapl_core * @@ -506,27 +601,32 @@ H5FD__core_term(void) herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5FD_core_fapl_t fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t * plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izb", fapl_id, increment, backing_store); /* Check argument */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - fa.increment = increment; - fa.backing_store = backing_store; + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); + fa.increment = increment; + fa.backing_store = backing_store; + fa.write_tracking = H5FD_CORE_WRITE_TRACKING_FLAG; + fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; - ret_value = H5P_set_driver(plist, H5FD_CORE, &fa); + /* Set the property values & the driver for the FAPL */ + if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_core() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_core * @@ -542,30 +642,29 @@ 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 */ - const H5FD_core_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, increment, backing_store); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_CORE != H5P_peek_driver(plist)) + if (H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(increment) + if (increment) *increment = fa->increment; - if(backing_store) + if (backing_store) *backing_store = fa->backing_store; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_core() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_fapl_get * @@ -582,17 +681,19 @@ 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_fapl_t *fa; - void *ret_value = NULL; /* Return value */ + H5FD_core_t * file = (H5FD_core_t *)_file; + H5FD_core_fapl_t *fa; /* Core VFD info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(NULL == (fa = (H5FD_core_fapl_t *)H5MM_calloc(sizeof(H5FD_core_fapl_t)))) + if (NULL == (fa = (H5FD_core_fapl_t *)H5MM_calloc(sizeof(H5FD_core_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fa->increment = file->increment; - fa->backing_store = (hbool_t)(file->fd >= 0); + fa->increment = file->increment; + fa->backing_store = (hbool_t)(file->fd >= 0); + fa->write_tracking = file->write_tracking; + fa->page_size = file->bstore_page_size; /* Set return value */ ret_value = fa; @@ -601,7 +702,6 @@ H5FD__core_fapl_get(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD___core_open * @@ -620,77 +720,80 @@ 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) { - int o_flags; - H5FD_core_t *file = NULL; - const H5FD_core_fapl_t *fa = NULL; - H5P_genplist_t *plist; /* Property list pointer */ + int o_flags; + H5FD_core_t * file = NULL; + const H5FD_core_fapl_t *fa = NULL; + 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 */ + h5_stat_t sb; + int fd = -1; + H5FD_file_image_info_t file_image_info; + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") HDassert(H5P_DEFAULT != fapl_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) o_flags |= O_EXCL; + if (H5F_ACC_TRUNC & flags) + o_flags |= O_TRUNC; + if (H5F_ACC_CREAT & flags) + o_flags |= O_CREAT; + if (H5F_ACC_EXCL & flags) + o_flags |= O_EXCL; /* Retrieve initial file image info */ - if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial file image info") /* If the file image exists and this is an open, make sure the file doesn't exist */ HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) || ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); HDmemset(&sb, 0, sizeof(sb)); - if((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { - if(HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0) + if ((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { + if (HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists") /* If backing store is requested, create and stat the file * Note: We are forcing the O_CREAT flag here, even though this is * technically an open. */ - if(fa->backing_store) { - if((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) + if (fa->backing_store) { + if ((fd = HDopen(name, o_flags | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ - } /* end if */ + } /* end if */ /* Open backing store, and get stat() from file. The only case that backing * store is off is when the backing_store flag is off and H5F_ACC_CREAT is * on. */ - else if(fa->backing_store || !(H5F_ACC_CREAT & flags)) { - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) + else if (fa->backing_store || !(H5F_ACC_CREAT & flags)) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ /* Create the new file struct */ - if(NULL == (file = (H5FD_core_t *)H5MM_calloc(sizeof(H5FD_core_t)))) + if (NULL == (file = (H5FD_core_t *)H5MM_calloc(sizeof(H5FD_core_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; - if(name && *name) + if (name && *name) file->name = H5MM_xstrdup(name); /* The increment comes from either the file access property list or the @@ -706,53 +809,54 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->fi_callbacks = file_image_info.callbacks; /* Check the file locking flags in the fapl */ - if(ignore_disabled_file_locks_s != FAIL) + if (ignore_disabled_file_locks_s != FAIL) /* The environment variable was set, so use that preferentially */ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s; else { /* Use the value in the property list */ - if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) + if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property") } - if(fd >= 0) { + if (fd >= 0) { /* Retrieve information for determining uniqueness of file */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ - } /* end if */ + } /* end if */ /* If an existing file is opened, load the whole file into memory. */ - if(!(H5F_ACC_CREAT & flags)) { + if (!(H5F_ACC_CREAT & flags)) { size_t size; /* Retrieve file size */ - if(file_image_info.buffer && file_image_info.size > 0) + if (file_image_info.buffer && file_image_info.size > 0) size = file_image_info.size; else size = (size_t)sb.st_size; /* Check if we should allocate the memory buffer and read in existing data */ - if(size) { + if (size) { /* Allocate memory for the file's data, using the file image callback if available. */ - if(file->fi_callbacks.image_malloc) { - if(NULL == (file->mem = (unsigned char*)file->fi_callbacks.image_malloc(size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata))) + if (file->fi_callbacks.image_malloc) { + if (NULL == (file->mem = (unsigned char *)file->fi_callbacks.image_malloc( + size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "image malloc callback failed") } /* end if */ else { - if(NULL == (file->mem = (unsigned char*)H5MM_malloc(size))) + if (NULL == (file->mem = (unsigned char *)H5MM_malloc(size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "unable to allocate memory block") } /* end else */ @@ -760,9 +864,11 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->eof = size; /* If there is an initial file image, copy it, using the callback if possible */ - if(file_image_info.buffer && file_image_info.size > 0) { - if(file->fi_callbacks.image_memcpy) { - if(file->mem != file->fi_callbacks.image_memcpy(file->mem, file_image_info.buffer, size, H5FD_FILE_IMAGE_OP_FILE_OPEN, file->fi_callbacks.udata)) + if (file_image_info.buffer && file_image_info.size > 0) { + if (file->fi_callbacks.image_memcpy) { + if (file->mem != file->fi_callbacks.image_memcpy(file->mem, file_image_info.buffer, size, + H5FD_FILE_IMAGE_OP_FILE_OPEN, + file->fi_callbacks.udata)) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, NULL, "image_memcpy callback failed") } /* end if */ else @@ -774,17 +880,17 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr * partial results, and the end of the file. */ - uint8_t *mem = file->mem; /* memory pointer for writes */ - HDoff_t offset = (HDoff_t)0; /* offset for reading */ + uint8_t *mem = file->mem; /* memory pointer for writes */ + HDoff_t offset = (HDoff_t)0; /* offset for reading */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -792,20 +898,27 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, mem, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else bytes_read = HDread(file->fd, mem, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "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, (unsigned long long)bytes_read, (unsigned long long)offset); + HGOTO_ERROR( + H5E_IO, H5E_READERROR, NULL, + "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, + (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ HDassert(bytes_read >= 0); @@ -814,47 +927,40 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr mem += bytes_read; size -= (size_t)bytes_read; } /* end while */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ + + /* Get the write tracking & page size */ + file->write_tracking = fa->write_tracking; + file->bstore_page_size = fa->page_size; /* Set up write tracking if the backing store is on */ file->dirty_list = NULL; - if(fa->backing_store) { - hbool_t write_tracking_flag = FALSE; /* what the user asked for */ - hbool_t use_write_tracking = FALSE; /* what we're actually doing */ - - /* Get the write tracking flag */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &write_tracking_flag) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking flag"); - - /* Get the page size */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &(file->bstore_page_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking page size"); + if (fa->backing_store) { + hbool_t use_write_tracking = FALSE; /* what we're actually doing */ /* default is to have write tracking OFF for create (hence the check to see * if the user explicitly set a page size) and ON with the default page size * on open (when not read-only). */ /* Only use write tracking if the file is open for writing */ - use_write_tracking = - TRUE == write_tracking_flag /* user asked for write tracking */ - && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ - && file->bstore_page_size != 0; /* page size is not zero */ + use_write_tracking = (TRUE == fa->write_tracking) /* user asked for write tracking */ + && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ + && (file->bstore_page_size != 0); /* page size is not zero */ /* initialize the dirty list */ - if(use_write_tracking) { - if(NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (use_write_tracking) + if (NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, NULL, "can't create core vfd dirty region list"); - } /* end if */ } /* end if */ /* Set return value */ ret_value = (H5FD_t *)file; done: - if(!ret_value && file) { - if(file->fd >= 0) + if (!ret_value && file) { + if (file->fd >= 0) HDclose(file->fd); H5MM_xfree(file->name); H5MM_xfree(file->mem); @@ -864,7 +970,6 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_close * @@ -880,29 +985,30 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr static herr_t H5FD__core_close(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Flush any changed buffers */ - if(H5FD__core_flush(_file, (hid_t)-1, TRUE) < 0) + if (H5FD__core_flush(_file, (hid_t)-1, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush core vfd backing store") /* Destroy the dirty region list */ - if(file->dirty_list) - if(H5FD__core_destroy_dirty_list(file) != SUCCEED) + if (file->dirty_list) + if (H5FD__core_destroy_dirty_list(file) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free core vfd dirty region list") /* Release resources */ - if(file->fd >= 0) + if (file->fd >= 0) HDclose(file->fd); - if(file->name) + if (file->name) H5MM_xfree(file->name); - if(file->mem) { + if (file->mem) { /* Use image callback if available */ - if(file->fi_callbacks.image_free) { - if(file->fi_callbacks.image_free(file->mem, H5FD_FILE_IMAGE_OP_FILE_CLOSE, file->fi_callbacks.udata) < 0) + if (file->fi_callbacks.image_free) { + if (file->fi_callbacks.image_free(file->mem, H5FD_FILE_IMAGE_OP_FILE_CLOSE, + file->fi_callbacks.udata) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else @@ -915,7 +1021,6 @@ H5FD__core_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_cmp * @@ -936,54 +1041,66 @@ H5FD__core_close(H5FD_t *_file) static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; - const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; - int ret_value = 0; + const H5FD_core_t *f1 = (const H5FD_core_t *)_f1; + const H5FD_core_t *f2 = (const H5FD_core_t *)_f2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(f1->fd >= 0 && f2->fd >= 0) { + if (f1->fd >= 0 && f2->fd >= 0) { /* Compare low level file information for backing store */ #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif /*H5_HAVE_WIN32_API*/ - } /* end if */ + } /* end if */ else { - if (NULL==f1->name && NULL==f2->name) { - if (f1name && NULL == f2->name) { + if (f1 < f2) HGOTO_DONE(-1) - if (f1>f2) + if (f1 > f2) HGOTO_DONE(1) HGOTO_DONE(0) } /* end if */ - if (NULL==f1->name) + if (NULL == f1->name) HGOTO_DONE(-1) - if (NULL==f2->name) + if (NULL == f2->name) HGOTO_DONE(1) ret_value = HDstrcmp(f1->name, f2->name); @@ -993,7 +1110,6 @@ H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_query * @@ -1008,12 +1124,13 @@ H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *------------------------------------------------------------------------- */ static herr_t -H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) +H5FD__core_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR + /* clang-format off */ /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; @@ -1030,11 +1147,11 @@ H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ } } /* end if */ + /* clang-format on */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__core_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_eoa * @@ -1052,14 +1169,13 @@ H5FD__core_query(const H5FD_t * _file, unsigned long *flags /* out */) static haddr_t H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__core_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_set_eoa * @@ -1077,12 +1193,12 @@ H5FD__core_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(ADDR_OVERFLOW(addr)) + if (ADDR_OVERFLOW(addr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow") file->eoa = addr; @@ -1091,7 +1207,6 @@ H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_eof * @@ -1111,14 +1226,13 @@ H5FD__core_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) static haddr_t H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__core_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_get_handle * @@ -1132,38 +1246,38 @@ H5FD__core_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) +H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ - if(!file_handle) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") + if (!file_handle) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl && H5P_DEFAULT != fapl) { - H5P_genplist_t *plist; /* Property list pointer */ + if (H5P_FILE_ACCESS_DEFAULT != fapl && H5P_DEFAULT != fapl) { + H5P_genplist_t *plist; /* Property list pointer */ /* Get the FAPL */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl))) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, FAIL, "not a file access property list") /* Check if private property for retrieving the backing store POSIX * file descriptor is set. (This should not be set except within the * library) QAK - 2009/12/04 */ - if(H5P_exist_plist(plist, H5F_ACS_WANT_POSIX_FD_NAME) > 0) { - hbool_t want_posix_fd; /* Setting for retrieving file descriptor from core VFD */ + if (H5P_exist_plist(plist, H5F_ACS_WANT_POSIX_FD_NAME) > 0) { + hbool_t want_posix_fd; /* Setting for retrieving file descriptor from core VFD */ /* Get property */ - if(H5P_get(plist, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) + if (H5P_get(plist, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get property of retrieving file descriptor") /* If property is set, pass back the file descriptor instead of the memory address */ - if(want_posix_fd) + if (want_posix_fd) *file_handle = &(file->fd); else *file_handle = &(file->mem); @@ -1178,7 +1292,6 @@ H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_read * @@ -1197,10 +1310,10 @@ H5FD__core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) */ static herr_t H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf /*out*/) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1219,11 +1332,11 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU #ifndef NDEBUG hsize_t temp_nbytes; - temp_nbytes = file->eof-addr; - H5_CHECK_OVERFLOW(temp_nbytes,hsize_t,size_t); - nbytes = MIN(size,(size_t)temp_nbytes); -#else /* NDEBUG */ - nbytes = MIN(size,(size_t)(file->eof-addr)); + temp_nbytes = file->eof - addr; + H5_CHECK_OVERFLOW(temp_nbytes, hsize_t, size_t); + nbytes = MIN(size, (size_t)temp_nbytes); +#else /* NDEBUG */ + nbytes = MIN(size, (size_t)(file->eof - addr)); #endif /* NDEBUG */ H5MM_memcpy(buf, file->mem + addr, nbytes); @@ -1240,7 +1353,6 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_write * @@ -1257,10 +1369,10 @@ H5FD__core_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU */ static herr_t H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1268,7 +1380,7 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN HDassert(buf); /* Check for overflow conditions */ - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed") /* @@ -1277,23 +1389,27 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN * careful of non-Posix realloc() that doesn't understand what to do when * the first argument is null. */ - if(addr + size > file->eof) { + if (addr + size > file->eof) { unsigned char *x; - size_t new_eof; + size_t new_eof; /* Determine new size of memory buffer */ H5_CHECKED_ASSIGN(new_eof, size_t, file->increment * ((addr + size) / file->increment), hsize_t); - if((addr + size) % file->increment) + if ((addr + size) % file->increment) new_eof += file->increment; /* (Re)allocate memory for the file buffer, using callbacks if available */ - if(file->fi_callbacks.image_realloc) { - if(NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc(file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block of %llu bytes with callback", (unsigned long long)new_eof) + if (file->fi_callbacks.image_realloc) { + if (NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc( + file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block of %llu bytes with callback", + (unsigned long long)new_eof) } /* end if */ else { - if(NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block of %llu bytes", (unsigned long long)new_eof) + if (NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block of %llu bytes", (unsigned long long)new_eof) } /* end else */ HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); @@ -1303,12 +1419,15 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN } /* end if */ /* Add the buffer region to the dirty list if using that optimization */ - if(file->dirty_list) { + if (file->dirty_list) { haddr_t start = addr; - haddr_t end = addr + (haddr_t)size - 1; + haddr_t end = addr + (haddr_t)size - 1; - if(H5FD__core_add_dirty_region(file, start, end) != SUCCEED) - HGOTO_ERROR(H5E_VFL, H5E_CANTINSERT, FAIL, "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", (unsigned long long)start, (unsigned long long)end) + if (H5FD__core_add_dirty_region(file, start, end) != SUCCEED) + HGOTO_ERROR( + H5E_VFL, H5E_CANTINSERT, FAIL, + "unable to add core VFD dirty region during write call - addresses: start=%llu end=%llu", + (unsigned long long)start, (unsigned long long)end) } /* Write from BUF to memory */ @@ -1321,7 +1440,6 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_flush * @@ -1338,8 +1456,8 @@ H5FD__core_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN static herr_t H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1347,32 +1465,32 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN if (file->dirty && file->fd >= 0 && file->backing_store) { /* Use the dirty list, if available */ - if(file->dirty_list) { + if (file->dirty_list) { H5FD_core_region_t *item = NULL; - size_t size; + size_t size; - while(NULL != (item = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) { + while (NULL != (item = (H5FD_core_region_t *)H5SL_remove_first(file->dirty_list))) { /* The file may have been truncated, so check for that * and skip or adjust as necessary. */ - if(item->start < file->eof) { - if(item->end >= file->eof) + if (item->start < file->eof) { + if (item->end >= file->eof) item->end = file->eof - 1; size = (size_t)((item->end - item->start) + 1); - if(H5FD__core_write_to_bstore(file, item->start, size) != SUCCEED) + if (H5FD__core_write_to_bstore(file, item->start, size) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") } /* end if */ item = H5FL_FREE(H5FD_core_region_t, item); - } /* end while */ + } /* end while */ } /* end if */ /* Otherwise, write the entire file out at once */ else { - if(H5FD__core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) + if (H5FD__core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") } /* end else */ @@ -1383,7 +1501,6 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_truncate * @@ -1408,7 +1525,7 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN * If we are not closing, we realloc the buffer to size equal * to the smallest multiple of the allocation increment that * equals or exceeds the eoa and set the eof accordingly. - * Note that we no longer truncate the backing store to the + * Note that we no longer truncate the backing store to the * new eof if applicable. * -- JRM * @@ -1422,52 +1539,55 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; - size_t new_eof; /* New size of memory buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; + size_t new_eof; /* New size of memory buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); /* if we are closing and not using backing store, do nothing */ - if(!closing || file->backing_store) { - if(closing) /* set eof to eoa */ + if (!closing || file->backing_store) { + if (closing) /* set eof to eoa */ new_eof = file->eoa; else { /* set eof to smallest multiple of increment that exceeds eoa */ /* Determine new size of memory buffer */ H5_CHECKED_ASSIGN(new_eof, size_t, file->increment * (file->eoa / file->increment), hsize_t); - if(file->eoa % file->increment) + if (file->eoa % file->increment) new_eof += file->increment; } /* end else */ /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eof, (haddr_t)new_eof)) { - unsigned char *x; /* Pointer to new buffer for file data */ + if (!H5F_addr_eq(file->eof, (haddr_t)new_eof)) { + unsigned char *x; /* Pointer to new buffer for file data */ /* (Re)allocate memory for the file buffer, using callback if available */ - if(file->fi_callbacks.image_realloc) { - if(NULL == (x = (unsigned char *)file->fi_callbacks.image_realloc(file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block with callback") + if (file->fi_callbacks.image_realloc) { + if (NULL == + (x = (unsigned char *)file->fi_callbacks.image_realloc( + file->mem, new_eof, H5FD_FILE_IMAGE_OP_FILE_RESIZE, file->fi_callbacks.udata))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "unable to allocate memory block with callback") } /* end if */ else { - if(NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) + if (NULL == (x = (unsigned char *)H5MM_realloc(file->mem, new_eof))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to allocate memory block") } /* end else */ - if(file->eof < new_eof) + if (file->eof < new_eof) HDmemset(x + file->eof, 0, (size_t)(new_eof - file->eof)); file->mem = x; /* Update backing store, if using it and if closing */ - if(closing && (file->fd >= 0) && file->backing_store) { + if (closing && (file->fd >= 0) && file->backing_store) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Windows uses this odd QuadPart union for 32/64-bit portability */ li.QuadPart = (__int64)file->eoa; @@ -1478,17 +1598,17 @@ H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) + if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") } bError = SetEndOfFile(file->hFile); - if(0 == bError) + if (0 == bError) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if(-1 == HDftruncate(file->fd, (HDoff_t)new_eof)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)new_eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -1497,20 +1617,19 @@ H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing /* Update the eof value */ file->eof = new_eof; } /* end if */ - } /* end if(file->eof < file->eoa) */ + } /* end if(file->eof < file->eoa) */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_lock * * Purpose: To place an advisory lock on a file. - * The lock type to apply depends on the parameter "rw": - * TRUE--opens for write: an exclusive lock - * FALSE--opens for read: a shared lock + * The lock type to apply depends on the parameter "rw": + * TRUE--opens for write: an exclusive lock + * FALSE--opens for read: a shared lock * * Return: SUCCEED/FAIL * @@ -1521,9 +1640,9 @@ H5FD__core_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw) { - H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1532,13 +1651,13 @@ H5FD__core_lock(H5FD_t *_file, hbool_t rw) /* Only set the lock if there is a file descriptor. If no file * descriptor, this is a no-op. */ - if(file->fd >= 0) { + if (file->fd >= 0) { /* Set exclusive or shared lock based on rw status */ lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1547,13 +1666,12 @@ H5FD__core_lock(H5FD_t *_file, hbool_t rw) else HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD__core_unlock * @@ -1568,16 +1686,16 @@ H5FD__core_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__core_unlock(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_core_t *file = (H5FD_core_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); - if(file->fd >= 0) - if(HDflock(file->fd, LOCK_UN) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (file->fd >= 0) + if (HDflock(file->fd, LOCK_UN) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1590,4 +1708,3 @@ H5FD__core_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_unlock() */ - diff --git a/src/H5FDcore.h b/src/H5FDcore.h index 63b6f271b54..d456c3efb57 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,19 +20,78 @@ #ifndef H5FDcore_H #define H5FDcore_H -#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE (H5FD_core_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_core_init(void); -H5_DLL herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, - hbool_t backing_store); -H5_DLL herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, - hbool_t *backing_store/*out*/); + +/** + * \ingroup FAPL + * + * \brief Modifies the file access property list to use the #H5FD_CORE driver + * + * \fapl_id + * \param[in] increment Size, in bytes, of memory increments + * \param[in] backing_store Boolean flag indicating whether to write the file + * contents to disk when the file is closed + * \returns \herr_t + * + * \details H5Pset_fapl_core() modifies the file access property list to use the + * #H5FD_CORE driver. + * + * The #H5FD_CORE driver enables an application to work with a file in + * memory, speeding reads and writes as no disk access is made. File + * contents are stored only in memory until the file is closed. The \p + * backing_store parameter determines whether file contents are ever + * written to disk. + * + * \p increment specifies the increment by which allocated memory is to + * be increased each time more memory is required. + * + * While using H5Fcreate() to create a core file, if the \p + * backing_store is set to 1 (TRUE), the file contents are flushed to a + * file with the same name as this core file when the file is closed or + * access to the file is terminated in memory. + * + * The application is allowed to open an existing file with #H5FD_CORE + * driver. While using H5Fopen() to open an existing file, if the \p + * backing_store is set to 1 (TRUE) and the \c flags for H5Fopen() is set to + * #H5F_ACC_RDWR, any change to the file contents are saved to the file + * when the file is closed. If \p backing_store is set to 0 (FALSE) and the \c + * flags for H5Fopen() is set to #H5F_ACC_RDWR, any change to the file + * contents will be lost when the file is closed. If the flags for + * H5Fopen() is set to #H5F_ACC_RDONLY, no change to the file is + * allowed either in memory or on file. + * + * \note Currently this driver cannot create or open family or multi files. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store); + +/** + * \ingroup FAPL + * + * \brief Queries core file driver properties + * + * \fapl_id + * \param[out] increment Size, in bytes, of memory increments + * \param[out] backing_store Boolean flag indicating whether to write the file + * contents to disk when the file is closed + * \returns \herr_t + * + * \details H5Pget_fapl_core() queries the #H5FD_CORE driver properties as set + * by H5Pset_fapl_core(). + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 94ab28713be..35da1f17f76 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,16 +22,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDdirect.h" /* Direct file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDdirect.h" /* Direct file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_DIRECT @@ -42,16 +41,16 @@ static hid_t H5FD_DIRECT_g = 0; static htri_t ignore_disabled_file_locks_s = FAIL; /* File operations */ -#define OP_UNKNOWN 0 +#define OP_UNKNOWN 0 #define OP_READ 1 -#define OP_WRITE 2 +#define OP_WRITE 2 /* Driver-specific file access properties */ typedef struct H5FD_direct_fapl_t { size_t mboundary; /* Memory boundary for alignment */ - size_t fbsize; /* File system block size */ - size_t cbsize; /* Maximal buffer size for copying user data */ - hbool_t must_align; /* Decides if data alignment is required */ + size_t fbsize; /* File system block size */ + size_t cbsize; /* Maximal buffer size for copying user data */ + hbool_t must_align; /* Decides if data alignment is required */ } H5FD_direct_fapl_t; /* @@ -67,21 +66,21 @@ typedef struct H5FD_direct_fapl_t { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_direct_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - int op; /*last operation */ - H5FD_direct_fapl_t fa; /*file access properties */ - hbool_t ignore_disabled_file_locks; + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + int op; /*last operation */ + H5FD_direct_fapl_t fa; /*file access properties */ + hbool_t ignore_disabled_file_locks; #ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the @@ -113,75 +112,70 @@ typedef struct H5FD_direct_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* 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 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); -static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags); -static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_direct_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_direct_unlock(H5FD_t *_file); - +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 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); +static herr_t H5FD__direct_query(const H5FD_t *_f1, unsigned long *flags); +static haddr_t H5FD__direct_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__direct_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__direct_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__direct_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__direct_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_direct_g = { - "direct", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_direct_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_direct_fapl_t), /*fapl_size */ - H5FD_direct_fapl_get, /*fapl_get */ - H5FD_direct_fapl_copy, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_direct_open, /*open */ - H5FD_direct_close, /*close */ - H5FD_direct_cmp, /*cmp */ - H5FD_direct_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_direct_get_eoa, /*get_eoa */ - H5FD_direct_set_eoa, /*set_eoa */ - H5FD_direct_get_eof, /*get_eof */ - H5FD_direct_get_handle, /*get_handle */ - H5FD_direct_read, /*read */ - H5FD_direct_write, /*write */ - NULL, /*flush */ - H5FD_direct_truncate, /*truncate */ - H5FD_direct_lock, /*lock */ - H5FD_direct_unlock, /*unlock */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ + "direct", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__direct_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_direct_fapl_t), /* fapl_size */ + H5FD__direct_fapl_get, /* fapl_get */ + H5FD__direct_fapl_copy, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__direct_open, /* open */ + H5FD__direct_close, /* close */ + H5FD__direct_cmp, /* cmp */ + H5FD__direct_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__direct_get_eoa, /* get_eoa */ + H5FD__direct_set_eoa, /* set_eoa */ + H5FD__direct_get_eof, /* get_eof */ + H5FD__direct_get_handle, /* get_handle */ + H5FD__direct_read, /* read */ + H5FD__direct_write, /* write */ + NULL, /* flush */ + H5FD__direct_truncate, /* truncate */ + H5FD__direct_lock, /* lock */ + H5FD__direct_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_direct_t struct */ H5FL_DEFINE_STATIC(H5FD_direct_t); - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -197,28 +191,27 @@ DESCRIPTION static herr_t H5FD__init_package(void) { - char *lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; + char * lock_env_var = NULL; /* Environment variable pointer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - if(H5FD_direct_init() < 0) + if (H5FD_direct_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_init * @@ -236,12 +229,12 @@ H5FD__init_package(void) hid_t H5FD_direct_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) - H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE); + H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ ret_value = H5FD_DIRECT_g; @@ -250,9 +243,8 @@ H5FD_direct_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_direct_init() */ - /*--------------------------------------------------------------------------- - * Function: H5FD_direct_term + * Function: H5FD__direct_term * * Purpose: Shut down the VFD * @@ -264,17 +256,16 @@ H5FD_direct_init(void) *--------------------------------------------------------------------------- */ static herr_t -H5FD_direct_term(void) +H5FD__direct_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ - H5FD_DIRECT_g=0; + H5FD_DIRECT_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_direct_term() */ +} /* end H5FD__direct_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_direct * @@ -292,26 +283,26 @@ 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 */ - H5FD_direct_fapl_t fa; - herr_t ret_value; + H5P_genplist_t * plist; /* Property list pointer */ + H5FD_direct_fapl_t fa; + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE4("e", "izzz", fapl_id, boundary, block_size, cbuf_size); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t)); - if(boundary != 0) + if (boundary != 0) fa.mboundary = boundary; else fa.mboundary = MBOUNDARY_DEF; - if(block_size != 0) + if (block_size != 0) fa.fbsize = block_size; else fa.fbsize = FBSIZE_DEF; - if(cbuf_size != 0) + if (cbuf_size != 0) fa.cbsize = cbuf_size; else fa.cbsize = CBSIZE_DEF; @@ -320,7 +311,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu fa.must_align = TRUE; /* Copy buffer size must be a multiple of file block size */ - if(fa.cbsize % fa.fbsize != 0) + if (fa.cbsize % fa.fbsize != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size") ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa); @@ -329,7 +320,6 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_direct * @@ -346,25 +336,25 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*out*/, - size_t *cbuf_size/*out*/) +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 */ - const H5FD_direct_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_direct_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ixxx", fapl_id, boundary, block_size, cbuf_size); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_DIRECT != H5P_peek_driver(plist)) + if (H5FD_DIRECT != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = H5P_peek_driver_info(plist))) + if (NULL == (fa = H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(boundary) + if (boundary) *boundary = fa->mboundary; - if(block_size) + if (block_size) *block_size = fa->fbsize; if (cbuf_size) *cbuf_size = fa->cbsize; @@ -373,9 +363,8 @@ H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*o FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_direct() */ - /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_get + * Function: H5FD__direct_fapl_get * * Purpose: Returns a file access property list which indicates how the * specified file is being accessed. The return list could be @@ -392,23 +381,21 @@ H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*o *------------------------------------------------------------------------- */ static void * -H5FD_direct_fapl_get(H5FD_t *_file) +H5FD__direct_fapl_get(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - void *ret_value; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value= H5FD_direct_fapl_copy(&(file->fa)); + ret_value = H5FD__direct_fapl_copy(&(file->fa)); -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_fapl_get() */ +} /* end H5FD__direct_fapl_get() */ - /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_copy + * Function: H5FD__direct_fapl_copy * * Purpose: Copies the direct-specific file access properties. * @@ -422,12 +409,12 @@ H5FD_direct_fapl_get(H5FD_t *_file) *------------------------------------------------------------------------- */ static void * -H5FD_direct_fapl_copy(const void *_old_fa) +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)); + 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)); - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(new_fa); @@ -435,11 +422,10 @@ H5FD_direct_fapl_copy(const void *_old_fa) H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_direct_fapl_t)); FUNC_LEAVE_NOAPI(new_fa) -} /* end H5FD_direct_fapl_copy() */ +} /* end H5FD__direct_fapl_copy() */ - /*------------------------------------------------------------------------- - * Function: H5FD_direct_open + * Function: H5FD__direct_open * * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file. * @@ -455,64 +441,67 @@ 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) +H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - int fd=(-1); - H5FD_direct_t *file=NULL; - H5FD_direct_fapl_t *fa; + int o_flags; + int fd = (-1); + H5FD_direct_t * file = NULL; + const H5FD_direct_fapl_t *fa; #ifdef H5_HAVE_WIN32_API - HFILE filehandle; + HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - H5P_genplist_t *plist; /* Property list */ - void *buf1, *buf2; - H5FD_t *ret_value = NULL; + h5_stat_t sb; + H5P_genplist_t *plist; /* Property list */ + void * buf1, *buf2; + H5FD_t * ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check on file offsets */ - HDassert(sizeof(HDoff_t)>=sizeof(size_t)); + HDassert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if (0==maxaddr || HADDR_UNDEF==maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; + if (H5F_ACC_TRUNC & flags) + o_flags |= O_TRUNC; + if (H5F_ACC_CREAT & flags) + o_flags |= O_CREAT; + if (H5F_ACC_EXCL & flags) + o_flags |= O_EXCL; /* Flag for Direct I/O */ o_flags |= O_DIRECT; /* Open the file */ - if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW))<0) + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - if (HDfstat(fd, &sb)<0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ - if (NULL==(file=H5FL_CALLOC(H5FD_direct_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_direct_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") /* Get the driver specific information */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); @@ -520,19 +509,19 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd file->fileindexlo = fileinfo.nFileIndexLow; #else file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /*H5_HAVE_WIN32_API*/ file->fa.mboundary = fa->mboundary; - file->fa.fbsize = fa->fbsize; - file->fa.cbsize = fa->cbsize; + file->fa.fbsize = fa->fbsize; + file->fa.cbsize = fa->cbsize; /* Check the file locking flags in the fapl */ - if(ignore_disabled_file_locks_s != FAIL) + if (ignore_disabled_file_locks_s != FAIL) /* The environment variable was set, so use that preferentially */ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s; else { /* Use the value in the property list */ - if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) + if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property") } @@ -544,58 +533,62 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd * HDposix_memalign. */ buf1 = HDmalloc(sizeof(int)); - if(HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) + if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") - if(o_flags & O_CREAT) { - if(HDwrite(file->fd, buf1, sizeof(int))<0) { - if(HDwrite(file->fd, buf2, file->fa.fbsize)<0) + if (o_flags & O_CREAT) { + if (HDwrite(file->fd, buf1, sizeof(int)) < 0) { + if (HDwrite(file->fd, buf2, file->fa.fbsize) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; - } else { + } + else { file->fa.must_align = FALSE; - HDftruncate(file->fd, (HDoff_t)0); + if (-1 == HDftruncate(file->fd, (HDoff_t)0)) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, NULL, "unable to truncate file") } - } else { - if(HDread(file->fd, buf1, sizeof(int))<0) { - if(HDread(file->fd, buf2, file->fa.fbsize)<0) + } + else { + if (HDread(file->fd, buf1, sizeof(int)) < 0) { + if (HDread(file->fd, buf2, file->fa.fbsize) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "file system may not support Direct I/O") else file->fa.must_align = TRUE; - } else { - if(o_flags & O_RDWR) { - if(HDlseek(file->fd, (HDoff_t)0, SEEK_SET) < 0) + } + else { + if (o_flags & O_RDWR) { + if (HDlseek(file->fd, (HDoff_t)0, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, NULL, "unable to seek to proper position") - if(HDwrite(file->fd, buf1, sizeof(int))<0) + if (HDwrite(file->fd, buf1, sizeof(int)) < 0) file->fa.must_align = TRUE; else file->fa.must_align = FALSE; - } else + } + else file->fa.must_align = FALSE; } } - if(buf1) + if (buf1) HDfree(buf1); - if(buf2) + if (buf2) HDfree(buf2); /* Set return value */ - ret_value=(H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value==NULL) { - if(fd>=0) + if (ret_value == NULL) { + if (fd >= 0) HDclose(fd); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_close + * Function: H5FD__direct_close * * Purpose: Closes the file. * @@ -609,25 +602,24 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_close(H5FD_t *_file) +H5FD__direct_close(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - if (HDclose(file->fd)<0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") - H5FL_FREE(H5FD_direct_t,file); + H5FL_FREE(H5FD_direct_t, file); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_cmp + * Function: H5FD__direct_cmp * * Purpose: Compares two files belonging to this driver using an * arbitrary (but consistent) ordering. @@ -643,36 +635,46 @@ H5FD_direct_close(H5FD_t *_file) *------------------------------------------------------------------------- */ static int -H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +H5FD__direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1; - const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2; - int ret_value=0; + const H5FD_direct_t *f1 = (const H5FD_direct_t *)_f1; + const H5FD_direct_t *f2 = (const H5FD_direct_t *)_f2; + int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API - if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) - if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) + if (f1->fileindexhi < f2->fileindexhi) + HGOTO_DONE(-1) + if (f1->fileindexhi > f2->fileindexhi) + HGOTO_DONE(1) - if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) - if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) + if (f1->fileindexlo < f2->fileindexlo) + HGOTO_DONE(-1) + if (f1->fileindexlo > f2->fileindexlo) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif @@ -680,9 +682,8 @@ H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_query + * Function: H5FD__direct_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -697,26 +698,26 @@ H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out */) +H5FD__direct_query(const H5FD_t H5_ATTR_UNUSED *_f, unsigned long *flags /* out */) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ } FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eoa + * Function: H5FD__direct_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -732,18 +733,17 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out *------------------------------------------------------------------------- */ static haddr_t -H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_set_eoa + * Function: H5FD__direct_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -759,20 +759,19 @@ H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; + H5FD_direct_t *file = (H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eof + * Function: H5FD__direct_get_eof * * Purpose: Returns the end-of-file marker, which is the greater of * either the Unix end-of-file or the HDF5 end-of-address @@ -790,16 +789,15 @@ H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) *------------------------------------------------------------------------- */ static haddr_t -H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t *)_file; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } - /*------------------------------------------------------------------------- * Function: H5FD_diect_get_handle * @@ -813,14 +811,14 @@ H5FD_direct_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) +H5FD__direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_direct_t *file = (H5FD_direct_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -828,9 +826,8 @@ H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_han FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_read + * Function: H5FD__direct_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -847,29 +844,29 @@ H5FD_direct_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_han *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) +H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p2; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; - haddr_t read_size; /* Size to read into copy buffer */ - size_t copy_size = size; /* Size remaining to read when using copy buffer */ - size_t copy_offset; /* Offset into copy buffer of the requested data */ - - FUNC_ENTER_NOAPI_NOINIT + H5FD_direct_t *file = (H5FD_direct_t *)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value = SUCCEED; /* Return value */ + size_t alloc_size; + void * copy_buf = NULL, *p2; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; + haddr_t read_size; /* Size to read into copy buffer */ + size_t copy_size = size; /* Size remaining to read when using copy buffer */ + size_t copy_offset; /* Offset into copy buffer of the requested data */ + + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); /* Check for overflow conditions */ - if (HADDR_UNDEF==addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") @@ -883,138 +880,135 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN * copy buffer size. */ _boundary = file->fa.mboundary; - _fbsize = file->fa.fbsize; - _cbsize = file->fa.cbsize; + _fbsize = file->fa.fbsize; + _cbsize = file->fa.cbsize; /* if the data is aligned or the system doesn't require data to be aligned, * read it directly from the file. If not, read a bigger * and aligned data first, then copy the data into memory buffer. */ - if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_READ!=file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* Read the aligned data in file first, being careful of interrupted - * system calls and partial results. */ - while (size>0) { - do { - nbytes = HDread(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - if (0==nbytes) { - /* end of file but not end of format address space */ - HDmemset(buf, 0, size); - break; + if (!_must_align || ((addr % _fbsize == 0) && (size % _fbsize == 0) && ((size_t)buf % _boundary == 0))) { + /* Seek to the correct location */ + if ((addr != file->pos || OP_READ != file->op) && HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + /* Read the aligned data in file first, being careful of interrupted + * system calls and partial results. */ + while (size > 0) { + do { + nbytes = HDread(file->fd, buf, size); + } while (-1 == nbytes && EINTR == errno); + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if (0 == nbytes) { + /* end of file but not end of format address space */ + HDmemset(buf, 0, size); + break; + } + HDassert(nbytes >= 0); + HDassert((size_t)nbytes <= size); + H5_CHECK_OVERFLOW(nbytes, ssize_t, size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); + addr += (haddr_t)nbytes; + buf = (char *)buf + nbytes; + } } - HDassert(nbytes>=0); - HDassert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (char*)buf + nbytes; - } - } else { - /* Calculate where we will begin copying from the copy buffer */ - copy_offset = (size_t)(addr % _fbsize); - - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; - if(alloc_size > _cbsize) - alloc_size = _cbsize; - HDassert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - - /* look for the aligned position for reading the data */ - HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); - if(HDlseek(file->fd, (HDoff_t)((addr / _fbsize) * _fbsize), - SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - /* - * Read the aligned data in file into aligned buffer first, then copy the data - * into the final buffer. If the data size is bigger than maximal copy buffer - * size, do the reading by segment (the outer while loop). If not, do one step - * reading. - */ - do { - /* Read the aligned data in file first. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's especially true when the data in - * file is smaller than ALLOC_SIZE. */ - HDmemset(copy_buf, 0, alloc_size); - - /* Calculate how much data we have to read in this iteration - * (including unused parts of blocks) */ - if((copy_size + copy_offset) < alloc_size) - read_size = ((copy_size + copy_offset - 1) / _fbsize + 1) - * _fbsize; - else - read_size = alloc_size; + else { + /* Calculate where we will begin copying from the copy buffer */ + copy_offset = (size_t)(addr % _fbsize); + + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. */ + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + if (alloc_size > _cbsize) + alloc_size = _cbsize; + HDassert(!(alloc_size % _fbsize)); + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + + /* look for the aligned position for reading the data */ + HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)((addr / _fbsize) * _fbsize), SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - HDassert(!(read_size % _fbsize)); + /* + * Read the aligned data in file into aligned buffer first, then copy the data + * into the final buffer. If the data size is bigger than maximal copy buffer + * size, do the reading by segment (the outer while loop). If not, do one step + * reading. + */ do { - nbytes = HDread(file->fd, copy_buf, read_size); - } while(-1==nbytes && EINTR==errno); - - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - - /* Copy the needed data from the copy buffer to the output - * buffer, and update copy_size. If the copy buffer does not - * contain the rest of the data, just copy what's in the copy - * buffer and also update read_addr and copy_offset to read the - * next section of data. */ - p2 = (unsigned char*)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { - H5MM_memcpy(buf, p2, copy_size); - buf = (unsigned char *)buf + copy_size; - copy_size = 0; - } /* end if */ - else { - H5MM_memcpy(buf, p2, alloc_size - copy_offset); - buf = (unsigned char*)buf + alloc_size - copy_offset; - copy_size -= alloc_size - copy_offset; - copy_offset = 0; - } /* end else */ - } while (copy_size > 0); - - /*Final step: update address*/ - addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); - - if(copy_buf) { - /* Free with HDfree since it came from posix_memalign */ - HDfree(copy_buf); - copy_buf = NULL; + /* Read the aligned data in file first. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's especially true when the data in + * file is smaller than ALLOC_SIZE. */ + HDmemset(copy_buf, 0, alloc_size); + + /* Calculate how much data we have to read in this iteration + * (including unused parts of blocks) */ + if ((copy_size + copy_offset) < alloc_size) + read_size = ((copy_size + copy_offset - 1) / _fbsize + 1) * _fbsize; + else + read_size = alloc_size; + + HDassert(!(read_size % _fbsize)); + do { + nbytes = HDread(file->fd, copy_buf, read_size); + } while (-1 == nbytes && EINTR == errno); + + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + + /* Copy the needed data from the copy buffer to the output + * buffer, and update copy_size. If the copy buffer does not + * contain the rest of the data, just copy what's in the copy + * buffer and also update read_addr and copy_offset to read the + * next section of data. */ + p2 = (unsigned char *)copy_buf + copy_offset; + if ((copy_size + copy_offset) <= alloc_size) { + H5MM_memcpy(buf, p2, copy_size); + buf = (unsigned char *)buf + copy_size; + copy_size = 0; } /* end if */ + else { + H5MM_memcpy(buf, p2, alloc_size - copy_offset); + buf = (unsigned char *)buf + alloc_size - copy_offset; + copy_size -= alloc_size - copy_offset; + copy_offset = 0; + } /* end else */ + } while (copy_size > 0); + + /*Final step: update address*/ + addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); + + if (copy_buf) { + /* Free with HDfree since it came from posix_memalign */ + HDfree(copy_buf); + copy_buf = NULL; + } /* end if */ } /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value<0) { + if (ret_value < 0) { /* Free with HDfree since it came from posix_memalign */ - if(copy_buf) + if (copy_buf) HDfree(copy_buf); /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_write + * Function: H5FD__direct_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1030,32 +1024,32 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) +H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, const void *buf) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p1; - const void *p3; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; - haddr_t write_addr; /* Address to write copy buffer */ - haddr_t write_size; /* Size to write from copy buffer */ - haddr_t read_size; /* Size to read into copy buffer */ - size_t copy_size = size; /* Size remaining to write when using copy buffer */ - size_t copy_offset; /* Offset into copy buffer of the data to write */ - - FUNC_ENTER_NOAPI_NOINIT + H5FD_direct_t *file = (H5FD_direct_t *)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value = SUCCEED; /* Return value */ + size_t alloc_size; + void * copy_buf = NULL, *p1; + const void * p3; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; + haddr_t write_addr; /* Address to write copy buffer */ + haddr_t write_size; /* Size to write from copy buffer */ + haddr_t read_size; /* Size to read into copy buffer */ + size_t copy_size = size; /* Size remaining to write when using copy buffer */ + size_t copy_offset; /* Offset into copy buffer of the data to write */ + + FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); /* Check for overflow conditions */ - if (HADDR_UNDEF==addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") @@ -1069,185 +1063,181 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U * copy buffer size. */ _boundary = file->fa.mboundary; - _fbsize = file->fa.fbsize; - _cbsize = file->fa.cbsize; + _fbsize = file->fa.fbsize; + _cbsize = file->fa.cbsize; /* if the data is aligned or the system doesn't require data to be aligned, * write it directly to the file. If not, read a bigger and aligned data * first, update buffer with user data, then write the data out. */ - if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_WRITE!=file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - while (size>0) { - do { - nbytes = HDwrite(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - HDassert(nbytes>0); - HDassert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (const char*)buf + nbytes; - } - } else { - /* Calculate where we will begin reading from (on disk) and where we - * will begin copying from the copy buffer */ - write_addr = (addr / _fbsize) * _fbsize; - copy_offset = (size_t)(addr % _fbsize); - - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. - */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; - if(alloc_size > _cbsize) - alloc_size = _cbsize; - HDassert(!(alloc_size % _fbsize)); - - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - - /* look for the right position for reading or writing the data */ - if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - p3 = buf; - do { - /* Calculate how much data we have to write in this iteration - * (including unused parts of blocks) */ - if((copy_size + copy_offset) < alloc_size) - write_size = ((copy_size + copy_offset - 1) / _fbsize + 1) - * _fbsize; - else - write_size = alloc_size; - - /* - * Read the aligned data first if the aligned region doesn't fall - * entirely in the range to be written. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's especially true when the data in - * file is smaller than ALLOC_SIZE. Only read the entire section if - * both ends are misaligned, otherwise only read the block on the - * misaligned end. + if (!_must_align || ((addr % _fbsize == 0) && (size % _fbsize == 0) && ((size_t)buf % _boundary == 0))) { + /* Seek to the correct location */ + if ((addr != file->pos || OP_WRITE != file->op) && HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + while (size > 0) { + do { + nbytes = HDwrite(file->fd, buf, size); + } while (-1 == nbytes && EINTR == errno); + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + HDassert(nbytes > 0); + HDassert((size_t)nbytes <= size); + H5_CHECK_OVERFLOW(nbytes, ssize_t, size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); + addr += (haddr_t)nbytes; + buf = (const char *)buf + nbytes; + } + } + else { + /* Calculate where we will begin reading from (on disk) and where we + * will begin copying from the copy buffer */ + write_addr = (addr / _fbsize) * _fbsize; + copy_offset = (size_t)(addr % _fbsize); + + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. */ - HDmemset(copy_buf, 0, _fbsize); - - if(copy_offset > 0) { - if((write_addr + write_size) > (addr + size)) { - HDassert((write_addr + write_size) - (addr + size) < _fbsize); - read_size = write_size; - p1 = copy_buf; - } /* end if */ - else { - read_size = _fbsize; - p1 = copy_buf; - } /* end else */ - } /* end if */ - else if((write_addr + write_size) > (addr + size)) { - HDassert((write_addr + write_size) - (addr + size) < _fbsize); - read_size = _fbsize; - p1 = (unsigned char *)copy_buf + write_size - _fbsize; - - /* Seek to the last block, for reading */ - HDassert(!((write_addr + write_size - _fbsize) % _fbsize)); - if(HDlseek(file->fd, - (HDoff_t)(write_addr + write_size - _fbsize), - SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ - else - p1 = NULL; + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + if (alloc_size > _cbsize) + alloc_size = _cbsize; + HDassert(!(alloc_size % _fbsize)); - if(p1) { - HDassert(!(read_size % _fbsize)); - do { - nbytes = HDread(file->fd, p1, read_size); - } while (-1==nbytes && EINTR==errno); + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - } /* end if */ + /* look for the right position for reading or writing the data */ + if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* look for the right position and append or copy the data to be written to - * the aligned buffer. - * Consider all possible situations here: file address is not aligned on - * file block size; the end of data address is not aligned; the end of data - * address is aligned; data size is smaller or bigger than maximal copy size. - */ - p1 = (unsigned char *)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { - H5MM_memcpy(p1, p3, copy_size); - copy_size = 0; + p3 = buf; + do { + /* Calculate how much data we have to write in this iteration + * (including unused parts of blocks) */ + if ((copy_size + copy_offset) < alloc_size) + write_size = ((copy_size + copy_offset - 1) / _fbsize + 1) * _fbsize; + else + write_size = alloc_size; + + /* + * Read the aligned data first if the aligned region doesn't fall + * entirely in the range to be written. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's especially true when the data in + * file is smaller than ALLOC_SIZE. Only read the entire section if + * both ends are misaligned, otherwise only read the block on the + * misaligned end. + */ + HDmemset(copy_buf, 0, _fbsize); + + if (copy_offset > 0) { + if ((write_addr + write_size) > (addr + size)) { + HDassert((write_addr + write_size) - (addr + size) < _fbsize); + read_size = write_size; + p1 = copy_buf; } /* end if */ else { - H5MM_memcpy(p1, p3, alloc_size - copy_offset); - p3 = (const unsigned char *)p3 + (alloc_size - copy_offset); - copy_size -= alloc_size - copy_offset; - copy_offset = 0; + read_size = _fbsize; + p1 = copy_buf; } /* end else */ + } /* end if */ + else if ((write_addr + write_size) > (addr + size)) { + HDassert((write_addr + write_size) - (addr + size) < _fbsize); + read_size = _fbsize; + p1 = (unsigned char *)copy_buf + write_size - _fbsize; + + /* Seek to the last block, for reading */ + HDassert(!((write_addr + write_size - _fbsize) % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)(write_addr + write_size - _fbsize), SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + } /* end if */ + else + p1 = NULL; - /*look for the aligned position for writing the data*/ - HDassert(!(write_addr % _fbsize)); - if(HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + if (p1) { + HDassert(!(read_size % _fbsize)); + do { + nbytes = HDread(file->fd, p1, read_size); + } while (-1 == nbytes && EINTR == errno); - /* - * Write the data. It doesn't truncate the extra data introduced by - * alignment because that step is done in H5FD_direct_flush. - */ - HDassert(!(write_size % _fbsize)); - do { - nbytes = HDwrite(file->fd, copy_buf, write_size); - } while (-1==nbytes && EINTR==errno); - - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - - /* update the write address */ - write_addr += write_size; - } while (copy_size > 0); - - /*Update the address and size*/ - addr = write_addr; - buf = (const char*)buf + size; - - if(copy_buf) { - /* Free with HDfree since it came from posix_memalign */ - HDfree(copy_buf); - copy_buf = NULL; + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + } /* end if */ + + /* look for the right position and append or copy the data to be written to + * the aligned buffer. + * Consider all possible situations here: file address is not aligned on + * file block size; the end of data address is not aligned; the end of data + * address is aligned; data size is smaller or bigger than maximal copy size. + */ + p1 = (unsigned char *)copy_buf + copy_offset; + if ((copy_size + copy_offset) <= alloc_size) { + H5MM_memcpy(p1, p3, copy_size); + copy_size = 0; + } /* end if */ + else { + H5MM_memcpy(p1, p3, alloc_size - copy_offset); + p3 = (const unsigned char *)p3 + (alloc_size - copy_offset); + copy_size -= alloc_size - copy_offset; + copy_offset = 0; + } /* end else */ + + /*look for the aligned position for writing the data*/ + HDassert(!(write_addr % _fbsize)); + if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + /* + * Write the data. It doesn't truncate the extra data introduced by + * alignment because that step is done in H5FD_direct_flush. + */ + HDassert(!(write_size % _fbsize)); + do { + nbytes = HDwrite(file->fd, copy_buf, write_size); + } while (-1 == nbytes && EINTR == errno); + + if (-1 == nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + + /* update the write address */ + write_addr += write_size; + } while (copy_size > 0); + + /*Update the address and size*/ + addr = write_addr; + buf = (const char *)buf + size; + + if (copy_buf) { + /* Free with HDfree since it came from posix_memalign */ + HDfree(copy_buf); + copy_buf = NULL; } /* end if */ } /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if (file->pos>file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value<0) { + if (ret_value < 0) { /* Free with HDfree since it came from posix_memalign */ - if(copy_buf) + if (copy_buf) HDfree(copy_buf); /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD_direct_truncate + * Function: H5FD__direct_truncate * * Purpose: Makes sure that the true file size is the same (or larger) * than the end-of-address. @@ -1262,20 +1252,20 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); /* Extend the file to make sure it's large enough */ - if (file->eoa!=file->eof) { + if (file->eoa != file->eof) { #ifdef H5_HAVE_WIN32_API - HFILE filehandle; /* Windows file handle */ - LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ + HFILE filehandle; /* Windows file handle */ + LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(file->fd); @@ -1283,11 +1273,11 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT /* Translate 64-bit integers into form Windows wants */ /* [This algorithm is from the Windows documentation for SetFilePointer()] */ li.QuadPart = (LONGLONG)file->eoa; - (void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); - if(SetEndOfFile((HANDLE)filehandle)==0) + (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); + if (SetEndOfFile((HANDLE)filehandle) == 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if (-1==HDftruncate(file->fd, (HDoff_t)file->eoa)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -1296,23 +1286,22 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } - else if (file->fa.must_align){ - /*Even though eof is equal to eoa, file is still truncated because Direct I/O - *write introduces some extra data for alignment. - */ - if (-1==HDftruncate(file->fd, (HDoff_t)file->eof)) + else if (file->fa.must_align) { + /*Even though eof is equal to eoa, file is still truncated because Direct I/O + *write introduces some extra data for alignment. + */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_truncate() */ +} /* end H5FD__direct_truncate() */ - /*------------------------------------------------------------------------- - * Function: H5FD_direct_lock + * Function: H5FD__direct_lock * * Purpose: To place an advisory lock on a file. * The lock type to apply depends on the parameter "rw": @@ -1326,13 +1315,13 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATT *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_lock(H5FD_t *_file, hbool_t rw) +H5FD__direct_lock(H5FD_t *_file, hbool_t rw) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); @@ -1340,8 +1329,8 @@ H5FD_direct_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1353,11 +1342,10 @@ H5FD_direct_lock(H5FD_t *_file, hbool_t rw) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_lock() */ +} /* end H5FD__direct_lock() */ - /*------------------------------------------------------------------------- - * Function: H5FD_direct_unlock + * Function: H5FD__direct_unlock * * Purpose: To remove the existing lock on the file * @@ -1368,17 +1356,17 @@ H5FD_direct_lock(H5FD_t *_file, hbool_t rw) *------------------------------------------------------------------------- */ static herr_t -H5FD_direct_unlock(H5FD_t *_file) +H5FD__direct_unlock(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, LOCK_UN) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1390,7 +1378,6 @@ H5FD_direct_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_direct_unlock() */ +} /* end H5FD__direct_unlock() */ #endif /* H5_HAVE_DIRECT */ - diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index 630a1e607f6..f06de7f4160 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,9 +21,9 @@ #define H5FDdirect_H #ifdef H5_HAVE_DIRECT -# define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT (H5FD_direct_init()) #else -# define H5FD_DIRECT (-1) +#define H5FD_DIRECT (H5I_INVALID_HID) #endif /* H5_HAVE_DIRECT */ #ifdef H5_HAVE_DIRECT @@ -33,15 +33,75 @@ extern "C" { /* Default values for memory boundary, file block size, and maximal copy buffer size. * Application can set these values through the function H5Pset_fapl_direct. */ -#define MBOUNDARY_DEF 4096 -#define FBSIZE_DEF 4096 -#define CBSIZE_DEF 16*1024*1024 +#define MBOUNDARY_DEF 4096 +#define FBSIZE_DEF 4096 +#define CBSIZE_DEF 16 * 1024 * 1024 H5_DLL hid_t H5FD_direct_init(void); -H5_DLL herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, - size_t cbuf_size); -H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, - size_t *block_size/*out*/, size_t *cbuf_size/*out*/); + +/** + * \ingroup FAPL + * + * \brief Sets up use of the direct I/O driver + * + * \fapl_id + * \param[in] alignment Required memory alignment boundary + * \param[in] block_size File system block size + * \param[in] cbuf_size Copy buffer size + * \returns \herr_t + * + * \details H5Pset_fapl_direct() sets the file access property list, \p fapl_id, + * to use the direct I/O driver, #H5FD_DIRECT. With this driver, data + * is written to or read from the file synchronously without being + * cached by the system. + * + * File systems usually require the data address in memory, the file + * address, and the size of the data to be aligned. The HDF5 library’s + * direct I/O driver is able to handle unaligned data, though that will + * consume some additional memory resources and may slow + * performance. To get better performance, use the system function \p + * posix_memalign to align the data buffer in memory and the HDF5 + * function H5Pset_alignment() to align the data in the file. Be aware, + * however, that aligned data I/O may cause the HDF5 file to be bigger + * than the actual data size would otherwise require because the + * alignment may leave some holes in the file. + * + * \p alignment specifies the required alignment boundary in memory. + * + * \p block_size specifies the file system block size. A value of 0 + * (zero) means to use HDF5 library’s default value of 4KB. + * + * \p cbuf_size specifies the copy buffer size. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, size_t cbuf_size); + +/** + * \ingroup FAPL + * + * \brief Retrieves direct I/O driver settings + * + * \fapl_id + * \param[out] boundary Required memory alignment boundary + * \param[out] block_size File system block size + * \param[out] cbuf_size Copy buffer size + * \returns \herr_t + * + * \details H5Pget_fapl_direct() retrieves the required memory alignment (\p + * alignment), file system block size (\p block_size), and copy buffer + * size (\p cbuf_size) settings for the direct I/O driver, #H5FD_DIRECT, + * from the file access property list \p fapl_id. + * + * See H5Pset_fapl_direct() for discussion of these values, + * requirements, and important considerations. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size /*out*/, + size_t *cbuf_size /*out*/); #ifdef __cplusplus } @@ -50,4 +110,3 @@ H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, #endif /* H5_HAVE_DIRECT */ #endif - diff --git a/src/H5FDdrvr_module.h b/src/H5FDdrvr_module.h index 34beb321d6f..1d20fce6609 100644 --- a/src/H5FDdrvr_module.h +++ b/src/H5FDdrvr_module.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5FD driver package. Including this header means that the source file * is part of the H5FD driver package. */ -#ifndef _H5FDdrvr_module_H -#define _H5FDdrvr_module_H +#ifndef H5FDdrvr_module_H +#define H5FDdrvr_module_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ -#define H5_MY_PKG H5FD -#define H5_MY_PKG_ERR H5E_FILE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES #define H5_PKG_SINGLE_SOURCE -#endif /* _H5FDdrvr_module_H */ - +#endif /* H5FDdrvr_module_H */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 290d743a88e..adfa1a31aa7 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -6,44 +6,43 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: Robb Matzke - * Monday, November 10, 1997 - * - * Purpose: Implements a family of files that acts as a single hdf5 - * file. The purpose is to be able to split a huge file on a - * 64-bit platform, transfer all the <2GB members to a 32-bit - * platform, and then access the entire huge file on the 32-bit - * platform. - * - * All family members are logically the same size although their - * physical sizes may vary. The logical member size is - * determined by looking at the physical size of the first member - * when the file is opened. When creating a file family, the - * first member is created with a predefined physical size - * (actually, this happens when the file family is flushed, and - * can be quite time consuming on file systems that don't - * implement holes, like nfs). + * Programmer: Robb Matzke + * Monday, November 10, 1997 + * + * Purpose: Implements a family of files that acts as a single hdf5 + * file. The purpose is to be able to split a huge file on a + * 64-bit platform, transfer all the <2GB members to a 32-bit + * platform, and then access the entire huge file on the 32-bit + * platform. + * + * All family members are logically the same size although their + * physical sizes may vary. The logical member size is + * determined by looking at the physical size of the first member + * when the file is opened. When creating a file family, the + * first member is created with a predefined physical size + * (actually, this happens when the file family is flushed, and + * can be quite time consuming on file systems that don't + * implement holes, like nfs). * */ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDfamily.h" /* Family file driver */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDfamily.h" /* Family file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The size of the member name buffers */ #define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096 @@ -53,96 +52,92 @@ static hid_t H5FD_FAMILY_g = 0; /* The description of a file belonging to this driver. */ typedef struct H5FD_family_t { - H5FD_t pub; /*public stuff, must be first */ - hid_t memb_fapl_id; /*file access property list for members */ - hsize_t memb_size; /*actual size of each member file */ - hsize_t pmem_size; /*member size passed in from property */ - unsigned nmembs; /*number of family members */ - 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 */ - unsigned flags; /*flags for opening additional members */ + H5FD_t pub; /*public stuff, must be first */ + hid_t memb_fapl_id; /*file access property list for members */ + hsize_t memb_size; /*actual size of each member file */ + hsize_t pmem_size; /*member size passed in from property */ + unsigned nmembs; /*number of family members */ + 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 */ + unsigned flags; /*flags for opening additional members */ /* Information from properties set by 'h5repart' tool */ - hsize_t mem_newsize; /*new member size passed in as private - * property. It's used only by h5repart */ - hbool_t repart_members; /* Whether to mark the superblock dirty - * when it is loaded, so that the family - * member sizes can be re-encoded */ + hsize_t mem_newsize; /*new member size passed in as private + * property. It's used only by h5repart */ + hbool_t repart_members; /* Whether to mark the superblock dirty + * when it is loaded, so that the family + * member sizes can be re-encoded */ } H5FD_family_t; /* Driver-specific file access properties */ typedef struct H5FD_family_fapl_t { - hsize_t memb_size; /*size of each member */ - hid_t memb_fapl_id; /*file access property list of each memb*/ + hsize_t memb_size; /*size of each member */ + hid_t memb_fapl_id; /*file access property list of each memb*/ } 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 herr_t H5FD__family_fapl_free(void *_fa); +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 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*/); -static herr_t H5FD__family_sb_decode(H5FD_t *_file, const char *name, - const unsigned char *buf); -static H5FD_t *H5FD__family_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD__family_close(H5FD_t *_file); -static int H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD__family_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD__family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); +static herr_t H5FD__family_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static H5FD_t *H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__family_close(H5FD_t *_file); +static int H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__family_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__family_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); +static herr_t H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa); static haddr_t 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); -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*/); -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); -static herr_t H5FD__family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__family_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__family_unlock(H5FD_t *_file); +static herr_t H5FD__family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +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*/); +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); +static herr_t H5FD__family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__family_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__family_unlock(H5FD_t *_file); /* The class struct */ static const H5FD_class_t H5FD_family_g = { - "family", /* name */ - HADDR_MAX, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__family_term, /* terminate */ - H5FD__family_sb_size, /* sb_size */ - H5FD__family_sb_encode, /* sb_encode */ - H5FD__family_sb_decode, /* sb_decode */ - sizeof(H5FD_family_fapl_t), /* fapl_size */ - H5FD__family_fapl_get, /* fapl_get */ - H5FD__family_fapl_copy, /* fapl_copy */ - H5FD__family_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__family_open, /* open */ - H5FD__family_close, /* close */ - H5FD__family_cmp, /* cmp */ - H5FD__family_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__family_get_eoa, /* get_eoa */ - H5FD__family_set_eoa, /* set_eoa */ - H5FD__family_get_eof, /* get_eof */ - H5FD__family_get_handle, /* get_handle */ - H5FD__family_read, /* read */ - H5FD__family_write, /* write */ - H5FD__family_flush, /* flush */ - H5FD__family_truncate, /* truncate */ - H5FD__family_lock, /* lock */ - H5FD__family_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "family", /* name */ + HADDR_MAX, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__family_term, /* terminate */ + H5FD__family_sb_size, /* sb_size */ + H5FD__family_sb_encode, /* sb_encode */ + H5FD__family_sb_decode, /* sb_decode */ + sizeof(H5FD_family_fapl_t), /* fapl_size */ + H5FD__family_fapl_get, /* fapl_get */ + H5FD__family_fapl_copy, /* fapl_copy */ + H5FD__family_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__family_open, /* open */ + H5FD__family_close, /* close */ + H5FD__family_cmp, /* cmp */ + H5FD__family_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__family_get_eoa, /* get_eoa */ + H5FD__family_set_eoa, /* set_eoa */ + H5FD__family_get_eof, /* get_eof */ + H5FD__family_get_handle, /* get_handle */ + H5FD__family_read, /* read */ + H5FD__family_write, /* write */ + H5FD__family_flush, /* flush */ + H5FD__family_truncate, /* truncate */ + H5FD__family_lock, /* lock */ + H5FD__family_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -162,14 +157,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_family_init() < 0) + if (H5FD_family_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize family VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_init * @@ -187,11 +181,11 @@ H5FD__init_package(void) hid_t H5FD_family_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) + if (H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -201,11 +195,10 @@ H5FD_family_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_family_init() */ - /*--------------------------------------------------------------------------- - * Function: H5FD__family_term + * Function: H5FD__family_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * * Returns: Non-negative on success or negative on failure * @@ -220,26 +213,25 @@ H5FD__family_term(void) FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ - H5FD_FAMILY_g=0; + H5FD_FAMILY_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__family_term() */ - /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_family + * Function: H5Pset_fapl_family * - * Purpose: Sets the file access property list FAPL_ID to use the family - * driver. The MEMB_SIZE is the size in bytes of each file - * member (used only when creating a new file) and the - * MEMB_FAPL_ID is a file access property list to be used for - * each family member. + * Purpose: Sets the file access property list FAPL_ID to use the family + * driver. The MEMB_SIZE is the size in bytes of each file + * member (used only when creating a new file) and the + * MEMB_FAPL_ID is a file access property list to be used for + * each family member. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -247,27 +239,26 @@ H5FD__family_term(void) herr_t 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 */ + herr_t ret_value; + H5FD_family_fapl_t fa = {0, -1}; + H5P_genplist_t * plist; /* Property list pointer */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihi", fapl_id, msize, memb_fapl_id); /* Check arguments */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_DEFAULT == memb_fapl_id) + if (H5P_DEFAULT == memb_fapl_id) memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + else if (TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") /* Initialize driver specific information. */ - fa.memb_size = msize; + fa.memb_size = msize; fa.memb_fapl_id = memb_fapl_id; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_FAMILY, &fa); @@ -275,42 +266,41 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_family + * Function: H5Pget_fapl_family * - * Purpose: Returns information about the family file access property - * list though the function arguments. + * Purpose: Returns information about the family file access property + * list though the function arguments. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, hid_t *memb_fapl_id/*out*/) +H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize /*out*/, hid_t *memb_fapl_id /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_family_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + const H5FD_family_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, msize, memb_fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_FAMILY != H5P_peek_driver(plist)) + if (H5FD_FAMILY != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if(msize) + if (msize) *msize = fa->memb_size; - if(memb_fapl_id) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) + if (memb_fapl_id) { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") *memb_fapl_id = H5P_copy_plist(plist, TRUE); } /* end if */ @@ -319,18 +309,17 @@ H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, hid_t *memb_fapl_id/*ou FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_fapl_get + * Function: H5FD__family_fapl_get * - * Purpose: Gets a file access property list which could be used to - * create an identical file. + * Purpose: Gets a file access property list which could be used to + * create an identical file. * - * Return: Success: Ptr to new file access property list. + * Return: Success: Ptr to new file access property list. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * *------------------------------------------------------------------------- @@ -338,43 +327,42 @@ H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, hid_t *memb_fapl_id/*ou static void * H5FD__family_fapl_get(H5FD_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 */ + 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 */ FUNC_ENTER_STATIC - if(NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) + if (NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") fa->memb_size = file->memb_size; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(file->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); /* Set return value */ - ret_value=fa; + ret_value = fa; done: - if(ret_value==NULL) - if(fa!=NULL) + if (ret_value == NULL) + if (fa != NULL) H5MM_xfree(fa); FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_fapl_copy + * Function: H5FD__family_fapl_copy * - * Purpose: Copies the family-specific file access properties. + * Purpose: Copies the family-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -382,52 +370,51 @@ H5FD__family_fapl_get(H5FD_t *_file) 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 */ + 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 */ FUNC_ENTER_STATIC - if(NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) + if (NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the fields of the structure */ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); /* Deep copy the property list objects in the structure */ - if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(new_fa->memb_fapl_id, FALSE)<0) + if (old_fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { + if (H5I_inc_ref(new_fa->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") } /* end if */ else { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") new_fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); } /* end else */ /* Set return value */ - ret_value=new_fa; + ret_value = new_fa; done: - if(ret_value==NULL) - if(new_fa!=NULL) + if (ret_value == NULL) + if (new_fa != NULL) H5MM_xfree(new_fa); FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_fapl_free + * Function: H5FD__family_fapl_free * - * Purpose: Frees the family-specific file access properties. + * Purpose: Frees the family-specific file access properties. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -435,12 +422,12 @@ H5FD__family_fapl_copy(const void *_old_fa) static herr_t H5FD__family_fapl_free(void *_fa) { - H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_fapl_t *fa = (H5FD_family_fapl_t *)_fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(H5I_dec_ref(fa->memb_fapl_id) < 0) + if (H5I_dec_ref(fa->memb_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(fa); @@ -448,18 +435,17 @@ H5FD__family_fapl_free(void *_fa) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_sb_size + * Function: H5FD__family_sb_size * - * Purpose: Returns the size of the private information to be stored in - * the superblock. + * Purpose: Returns the size of the private information to be stored in + * the superblock. * - * Return: Success: The super block driver data size. + * Return: Success: The super block driver data size. * - * Failure: never fails + * Failure: never fails * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- @@ -474,29 +460,28 @@ H5FD__family_sb_size(H5FD_t H5_ATTR_UNUSED *_file) FUNC_LEAVE_NOAPI(8) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_sb_encode + * Function: H5FD__family_sb_encode * - * Purpose: Encode driver information for the superblock. The NAME - * argument is a nine-byte buffer which will be initialized with - * an eight-character name/version number and null termination. + * Purpose: Encode driver information for the superblock. The NAME + * argument is a nine-byte buffer which will be initialized with + * an eight-character name/version number and null termination. * - * The encoding is the member file size and name template. + * The encoding is the member file size and name template. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5FD__family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +H5FD__family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_family_t *file = (H5FD_family_t*)_file; + H5FD_family_t *file = (H5FD_family_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -517,21 +502,20 @@ H5FD__family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__family_sb_encode() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_sb_decode + * Function: H5FD__family_sb_decode * - * Purpose: This function has 2 separate purpose. One is to decodes the + * Purpose: This function has 2 separate purpose. One is to decodes the * superblock information for this driver. The NAME argument is * the eight-character (plus null termination) name stored in i * the file. The FILE argument is updated according to the * information in the superblock. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Tuesday, May 10, 2005 * *------------------------------------------------------------------------- @@ -539,9 +523,9 @@ H5FD__family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out static herr_t H5FD__family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsigned char *buf) { - H5FD_family_t *file = (H5FD_family_t*)_file; - uint64_t msize; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + uint64_t msize; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -552,16 +536,18 @@ H5FD__family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const uns * h5repart is being used to change member file size. h5repart will open * files for read and write. When the files are closed, metadata will be * flushed to the files and updated to this new size */ - if(file->mem_newsize) + if (file->mem_newsize) file->memb_size = file->pmem_size = file->mem_newsize; else { /* Default - use the saved member size */ - if(file->pmem_size == H5F_FAMILY_DEFAULT) - file->pmem_size = msize; + if (file->pmem_size == H5F_FAMILY_DEFAULT) + file->pmem_size = msize; /* Check if member size from file access property is correct */ - if(msize != file->pmem_size) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size) + if (msize != file->pmem_size) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "Family member size should be %lu. But the size from file access property is %lu", + (unsigned long)msize, (unsigned long)file->pmem_size) /* Update member file size to the size saved in the superblock. * That's the size intended to be. */ @@ -572,19 +558,18 @@ H5FD__family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const uns FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_sb_decode() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_open + * Function: H5FD__family_open * - * Purpose: Creates and/or opens a family of files as an HDF5 file. + * Purpose: Creates and/or opens a family of files as an HDF5 file. * - * Return: Success: A pointer to a new file dat structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file dat structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -595,97 +580,96 @@ H5FD__family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const uns * memb_name & temp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static H5FD_t * -H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) +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; - hsize_t eof = HADDR_UNDEF; - unsigned t_flags = flags & ~H5F_ACC_CREAT; - H5FD_t *ret_value = NULL; + H5FD_family_t *file = NULL; + char * memb_name = NULL, *temp = NULL; + hsize_t eof = HADDR_UNDEF; + unsigned t_flags = flags & ~H5F_ACC_CREAT; + H5FD_t * ret_value = NULL; FUNC_ENTER_STATIC /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") /* Initialize file from file access properties */ - if(NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) + if (NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") - if(H5P_FILE_ACCESS_DEFAULT == fapl_id) { + if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { file->memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; - if(H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) + if (H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - file->memb_size = 1024 * 1024 * 1024; /*1GB. Actual member size to be updated later */ - file->pmem_size = 1024 * 1024 * 1024; /*1GB. Member size passed in through property */ - file->mem_newsize = 0; /*New member size used by h5repart only */ - } /* end if */ + file->memb_size = 1024 * 1024 * 1024; /*1GB. Actual member size to be updated later */ + file->pmem_size = 1024 * 1024 * 1024; /*1GB. Member size passed in through property */ + 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))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Check for new family file size. It's used by h5repart only. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { /* Get the new family file size */ - if(H5P_get(plist, H5F_ACS_FAMILY_NEWSIZE_NAME, &file->mem_newsize) < 0) + if (H5P_get(plist, H5F_ACS_FAMILY_NEWSIZE_NAME, &file->mem_newsize) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get new family member size") /* Set flag for later */ file->repart_members = TRUE; } /* end if */ - if(fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(fa->memb_fapl_id, FALSE) < 0) + if (fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { + if (H5I_inc_ref(fa->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->memb_fapl_id = fa->memb_fapl_id; } /* end if */ else { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fa->memb_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") file->memb_fapl_id = H5P_copy_plist(plist, FALSE); - } /* end else */ + } /* end else */ file->memb_size = fa->memb_size; /* Actual member size to be updated later */ file->pmem_size = fa->memb_size; /* Member size passed in through property */ - } /* end else */ - file->name = H5MM_strdup(name); + } /* end else */ + file->name = H5MM_strdup(name); file->flags = flags; /* Allocate space for the string buffers */ - if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate member name") - if(NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate temporary member name") /* Check that names are unique */ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 0); HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 1); - if(!HDstrcmp(memb_name, temp)) + if (!HDstrcmp(memb_name, temp)) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") /* Open all the family members */ - while(1) { + while (1) { HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, file->nmembs); /* Enlarge member array */ - if(file->nmembs >= file->amembs) { + if (file->nmembs >= file->amembs) { unsigned n = MAX(64, 2 * file->amembs); H5FD_t **x; HDassert(n > 0); - if(NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) + if (NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members") file->amembs = n; - file->memb = x; + file->memb = x; } /* end if */ /* @@ -693,10 +677,12 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, * otherwise an open failure means that we've reached the last member. * Allow H5F_ACC_CREAT only on the first family member. */ - H5E_BEGIN_TRY { - file->memb[file->nmembs] = H5FDopen(memb_name, - (0==file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + file->memb[file->nmembs] = + H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); + } + H5E_END_TRY; if (!file->memb[file->nmembs]) { if (0 == file->nmembs) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file") @@ -710,57 +696,57 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, * smaller than the size specified through H5Pset_fapl_family(). Update the actual * member size. */ - if ((eof=H5FDget_eof(file->memb[0], H5FD_MEM_DEFAULT))) file->memb_size = eof; + if ((eof = H5FDget_eof(file->memb[0], H5FD_MEM_DEFAULT))) + file->memb_size = eof; - ret_value=(H5FD_t *)file; + ret_value = (H5FD_t *)file; done: /* Release resources */ - if(memb_name) + if (memb_name) H5MM_xfree(memb_name); - if(temp) + if (temp) H5MM_xfree(temp); /* Cleanup and fail */ - if(ret_value == NULL && file != NULL) { - unsigned nerrors = 0; /* Number of errors closing member files */ - unsigned u; /* Local index variable */ + if (ret_value == NULL && file != NULL) { + unsigned nerrors = 0; /* Number of errors closing member files */ + unsigned u; /* Local index variable */ /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_close(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_close(file->memb[u]) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close member files") - if(file->memb) + if (file->memb) H5MM_xfree(file->memb); - if(H5I_dec_ref(file->memb_fapl_id) < 0) + if (H5I_dec_ref(file->memb_fapl_id) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") - if(file->name) + if (file->name) H5MM_xfree(file->name); H5MM_xfree(file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_open() */ -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- - * Function: H5FD__family_close + * Function: H5FD__family_close * - * Purpose: Closes a family of files. + * Purpose: Closes a family of files. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative with as many members closed as - * possible. The only subsequent operation - * permitted on the file is a close operation. + * Failure: Negative with as many members closed as + * possible. The only subsequent operation + * permitted on the file is a close operation. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -768,29 +754,29 @@ H5_GCC_DIAG_ON(format-nonliteral) static herr_t H5FD__family_close(H5FD_t *_file) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned nerrors = 0; /* Number of errors while closing member files */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned nerrors = 0; /* Number of errors while closing member files */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ - for(u = 0; u < file->nmembs; u++) { - if(file->memb[u]) { - if(H5FD_close(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) { + if (file->memb[u]) { + if (H5FD_close(file->memb[u]) < 0) nerrors++; else file->memb[u] = NULL; } /* end if */ - } /* end for */ - if(nerrors) + } /* end for */ + if (nerrors) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files") /* Clean up other stuff */ - if(H5I_dec_ref(file->memb_fapl_id) < 0) + if (H5I_dec_ref(file->memb_fapl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(file->memb); @@ -800,19 +786,18 @@ H5FD__family_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_close() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_cmp + * Function: H5FD__family_cmp * - * Purpose: Compares two file families to see if they are the same. It - * does this by comparing the first member of the two families. + * Purpose: Compares two file families to see if they are the same. It + * does this by comparing the first member of the two families. * - * Return: Success: like strcmp() + * Return: Success: like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -820,9 +805,9 @@ H5FD__family_close(H5FD_t *_file) static int H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_family_t *f1 = (const H5FD_family_t*)_f1; - const H5FD_family_t *f2 = (const H5FD_family_t*)_f2; - int ret_value = 0; + const H5FD_family_t *f1 = (const H5FD_family_t *)_f1; + const H5FD_family_t *f2 = (const H5FD_family_t *)_f2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR @@ -834,57 +819,56 @@ H5FD__family_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_cmp() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_query + * Function: H5FD__family_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- */ static herr_t -H5FD__family_query(const H5FD_t * _file, unsigned long *flags /* out */) +H5FD__family_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; /* Family VFD info */ + const H5FD_family_t *file = (const H5FD_family_t *)_file; /* Family VFD info */ FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes. */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ /* Check for flags that are set by h5repart */ - if(file && file->repart_members) - *flags |= H5FD_FEAT_DIRTY_DRVRINFO_LOAD; /* Mark the superblock dirty when it is loaded (so the family member sizes are rewritten) */ - } /* end if */ + if (file && file->repart_members) + *flags |= H5FD_FEAT_DIRTY_DRVRINFO_LOAD; /* Mark the superblock dirty when it is loaded (so the + family member sizes are rewritten) */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__family_query() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_get_eoa + * Function: H5FD__family_get_eoa * - * Purpose: Returns the end-of-address marker for the file. The EOA - * marker is the first address past the last byte allocated in - * the format address space. + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. * - * Return: Success: The end-of-address-marker + * Return: Success: The end-of-address-marker * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -892,24 +876,23 @@ H5FD__family_query(const H5FD_t * _file, unsigned long *flags /* out */) static haddr_t H5FD__family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; + const H5FD_family_t *file = (const H5FD_family_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_set_eoa + * Function: H5FD__family_set_eoa * - * Purpose: Set the end-of-address marker for the file. + * Purpose: Set the end-of-address marker for the file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -920,89 +903,90 @@ H5FD__family_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * memb_name in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static herr_t 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; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + haddr_t addr = abs_eoa; + char * memb_name = NULL; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for the member name buffer */ - if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) + if (NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate member name") - for(u = 0; addr || u < file->nmembs; u++) { + for (u = 0; addr || u < file->nmembs; u++) { /* Enlarge member array */ - if(u >= file->amembs) { + if (u >= file->amembs) { unsigned n = MAX(64, 2 * file->amembs); H5FD_t **x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") file->amembs = n; - file->memb = x; + file->memb = x; file->nmembs = u; } /* end if */ /* Create another file if necessary */ - if(u >= file->nmembs || !file->memb[u]) { - file->nmembs = MAX(file->nmembs, u+1); + if (u >= file->nmembs || !file->memb[u]) { + file->nmembs = MAX(file->nmembs, u + 1); HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, file->name, u); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, - file->memb_fapl_id, (haddr_t)file->memb_size); - } H5E_END_TRY; - if(NULL == file->memb[u]) + file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, + (haddr_t)file->memb_size); + } + H5E_END_TRY; + if (NULL == file->memb[u]) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file") } /* end if */ /* Set the EOA marker for the member */ /* (Note compensating for base address addition in internal routine) */ H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - if(addr > (haddr_t)file->memb_size) { - if(H5FD_set_eoa(file->memb[u], type, ((haddr_t)file->memb_size - file->pub.base_addr)) < 0) + if (addr > (haddr_t)file->memb_size) { + if (H5FD_set_eoa(file->memb[u], type, ((haddr_t)file->memb_size - file->pub.base_addr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr -= file->memb_size; } /* end if */ else { - if(H5FD_set_eoa(file->memb[u], type, (addr - file->pub.base_addr)) < 0) + if (H5FD_set_eoa(file->memb[u], type, (addr - file->pub.base_addr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set file eoa") addr = 0; } /* end else */ - } /* end for */ + } /* end for */ file->eoa = abs_eoa; done: /* Release resources */ - if(memb_name) + if (memb_name) H5MM_xfree(memb_name); FUNC_LEAVE_NOAPI(ret_value) } -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - /*------------------------------------------------------------------------- - * Function: H5FD__family_get_eof + * Function: H5FD__family_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the total family size or the current EOA marker. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the total family size or the current EOA marker. * - * Return: Success: End of file address, the first address past - * the end of the family of files or the current - * EOA, whichever is larger. + * Return: Success: End of file address, the first address past + * the end of the family of files or the current + * EOA, whichever is larger. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1010,10 +994,10 @@ H5_GCC_DIAG_ON(format-nonliteral) static haddr_t H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) { - const H5FD_family_t *file = (const H5FD_family_t*)_file; - haddr_t eof=0; - int i; /* Local index variable */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + const H5FD_family_t *file = (const H5FD_family_t *)_file; + haddr_t eof = 0; + int i; /* Local index variable */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1023,10 +1007,10 @@ H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * loop with i==0. */ HDassert(file->nmembs > 0); - for(i = (int)file->nmembs - 1; i >= 0; --i) { - if((eof = H5FD_get_eof(file->memb[i], type)) != 0) + for (i = (int)file->nmembs - 1; i >= 0; --i) { + if ((eof = H5FD_get_eof(file->memb[i], type)) != 0) break; - if(0 == i) + if (0 == i) break; } /* end for */ @@ -1037,7 +1021,7 @@ H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * The file size is the number of members before the i'th member plus the * size of the i'th member. */ - eof += ((unsigned)i)*file->memb_size; + eof += ((unsigned)i) * file->memb_size; /* Set return value */ ret_value = eof; @@ -1045,7 +1029,6 @@ H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD__family_get_handle * @@ -1059,25 +1042,25 @@ 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_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_family_t *file = (H5FD_family_t *)_file; - H5P_genplist_t *plist; - hsize_t offset; - int memb; - herr_t ret_value = FAIL; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + H5P_genplist_t *plist; + hsize_t offset; + int memb; + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC /* Get the plist structure and family offset */ - if(NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) + if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get offset for family driver") - if(offset > (file->memb_size * file->nmembs)) + if (offset > (file->memb_size * file->nmembs)) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "offset is bigger than file size") - memb = (int)(offset/file->memb_size); + memb = (int)(offset / file->memb_size); ret_value = H5FD_get_vfd_handle(file->memb[memb], fapl, file_handle); @@ -1085,36 +1068,35 @@ H5FD__family_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_read + * Function: H5FD__family_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, contents of buffer BUF are undefined. + * Failure: -1, contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ 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*/) + void *_buf /*out*/) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned char *buf = (unsigned char*)_buf; - haddr_t sub; - size_t req; - hsize_t tempreq; - unsigned u; /* Local index variable */ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_family_t * file = (H5FD_family_t *)_file; + unsigned char * buf = (unsigned char *)_buf; + haddr_t sub; + size_t req; + hsize_t tempreq; + unsigned u; /* Local index variable */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1122,26 +1104,26 @@ H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Read from each member */ - while(size > 0) { + while (size > 0) { H5_CHECKED_ASSIGN(u, unsigned, addr / file->memb_size, hsize_t); sub = addr % file->memb_size; - /* This check is for mainly for IA32 architecture whose size_t's size - * is 4 bytes, to prevent overflow when user application is trying to - * write files bigger than 4GB. */ - tempreq = file->memb_size-sub; - if(tempreq > SIZET_MAX) - tempreq = SIZET_MAX; + /* This check is for mainly for IA32 architecture whose size_t's size + * is 4 bytes, to prevent overflow when user application is trying to + * write files bigger than 4GB. */ + tempreq = file->memb_size - sub; + if (tempreq > SIZET_MAX) + tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - HDassert(unmembs); + HDassert(u < file->nmembs); - if (H5FDread(file->memb[u], type, dxpl_id, sub, req, buf)<0) + if (H5FDread(file->memb[u], type, dxpl_id, sub, req, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed") addr += req; @@ -1153,35 +1135,33 @@ H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_write + * Function: H5FD__family_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ 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_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; - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1189,11 +1169,11 @@ H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, * Get the member data transfer property list. If the transfer property * list does not belong to this driver then assume defaults. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Write to each member */ - while (size>0) { + while (size > 0) { H5_CHECKED_ASSIGN(u, unsigned, addr / file->memb_size, hsize_t); sub = addr % file->memb_size; @@ -1201,14 +1181,14 @@ H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /* This check is for mainly for IA32 architecture whose size_t's size * is 4 bytes, to prevent overflow when user application is trying to * write files bigger than 4GB. */ - tempreq = file->memb_size-sub; - if(tempreq > SIZET_MAX) - tempreq = SIZET_MAX; + tempreq = file->memb_size - sub; + if (tempreq > SIZET_MAX) + tempreq = SIZET_MAX; req = MIN(size, (size_t)tempreq); - HDassert(unmembs); + HDassert(u < file->nmembs); - if (H5FDwrite(file->memb[u], type, dxpl_id, sub, req, buf)<0) + if (H5FDwrite(file->memb[u], type, dxpl_id, sub, req, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed") addr += req; @@ -1220,16 +1200,15 @@ H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5FD__family_flush + * Function: H5FD__family_flush * - * Purpose: Flushes all family members. + * Purpose: Flushes all family members. * - * Return: Success: 0 - * Failure: -1, as many files flushed as possible. + * Return: Success: 0 + * Failure: -1, as many files flushed as possible. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1237,34 +1216,33 @@ H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, static herr_t H5FD__family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned u, nerrors = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned u, nerrors = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - for(u = 0; u < file->nmembs; u++) - if(file->memb[u] && H5FD_flush(file->memb[u], closing) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u] && H5FD_flush(file->memb[u], closing) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_flush() */ - /*------------------------------------------------------------------------- - * Function: H5FD__family_truncate + * Function: H5FD__family_truncate * - * Purpose: Truncates all family members. + * Purpose: Truncates all family members. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, as many files truncated as possible. + * Failure: -1, as many files truncated as possible. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, February 23, 2008 * *------------------------------------------------------------------------- @@ -1272,24 +1250,23 @@ H5FD__family_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) static herr_t H5FD__family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_family_t *file = (H5FD_family_t*)_file; - unsigned u, nerrors = 0; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned u, nerrors = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - for(u = 0; u < file->nmembs; u++) - if(file->memb[u] && H5FD_truncate(file->memb[u], closing) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u] && H5FD_truncate(file->memb[u], closing) < 0) nerrors++; - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__family_lock * @@ -1307,26 +1284,26 @@ H5FD__family_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closi static herr_t H5FD__family_lock(H5FD_t *_file, hbool_t rw) { - H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Place the lock on all the member files */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_lock(file->memb[u], rw) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_lock(file->memb[u], rw) < 0) break; /* If one of the locks failed, try to unlock the locked member files * in an attempt to return to a fully unlocked state. */ - if(u < file->nmembs) { - unsigned v; /* Local index variable */ + if (u < file->nmembs) { + unsigned v; /* Local index variable */ - for(v = 0; v < u; v++) { - if(H5FD_unlock(file->memb[v]) < 0) + for (v = 0; v < u; v++) { + if (H5FD_unlock(file->memb[v]) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files") } /* end for */ @@ -1337,7 +1314,6 @@ H5FD__family_lock(H5FD_t *_file, hbool_t rw) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD__family_unlock * @@ -1352,19 +1328,18 @@ H5FD__family_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__family_unlock(H5FD_t *_file) { - H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Remove the lock on the member files */ - for(u = 0; u < file->nmembs; u++) - if(file->memb[u]) - if(H5FD_unlock(file->memb[u]) < 0) + for (u = 0; u < file->nmembs; u++) + if (file->memb[u]) + if (H5FD_unlock(file->memb[u]) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_unlock() */ - diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 45bdcccb4a2..20ef5325924 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,21 +20,68 @@ #ifndef H5FDfamily_H #define H5FDfamily_H -#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY (H5FD_family_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_family_init(void); -H5_DLL herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, - hid_t memb_fapl_id); -H5_DLL herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/, - hid_t *memb_fapl_id/*out*/); + +/** + * \ingroup FAPL + * + * \brief Sets the file access property list to use the family driver + * + * \fapl_id + * \param[in] memb_size Size in bytes of each file member + * \param[in] memb_fapl_id Identifier of file access property list for + * each family member + * \returns \herr_t + * + * \details H5Pset_fapl_family() sets the file access property list identifier, + * \p fapl_id, to use the family driver. + * + * \p memb_size is the size in bytes of each file member. This size + * will be saved in file when the property list \p fapl_id is used to + * create a new file. If \p fapl_id is used to open an existing file, + * \p memb_size has to be equal to the original size saved in file. A + * failure with an error message indicating the correct member size + * will be returned if \p memb_size does not match the size saved. If + * any user does not know the original size, #H5F_FAMILY_DEFAULT can be + * passed in. The library will retrieve the saved size. + * + * \p memb_fapl_id is the identifier of the file access property list + * to be used for each family member. + * + * \version 1.8.0 Behavior of the \p memb_size parameter was changed. + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id); + +/** + * \ingroup FAPL + * + * \brief Returns file access property list information + * + * \fapl_id + * \param[out] memb_size Size in bytes of each file member + * \param[out] memb_fapl_id Identifier of file access property list for + * each family member + * \returns \herr_t + * + * \details H5Pget_fapl_family() returns file access property list for use with + * the family driver. This information is returned through the output + * parameters. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size /*out*/, hid_t *memb_fapl_id /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index c604c9c58fa..9f0614e4835 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -29,13 +29,13 @@ #include "H5FDdrvr_module.h" #endif /* H5_HAVE_LIBHDFS */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDhdfs.h" /* hdfs file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDhdfs.h" /* hdfs file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_LIBHDFS @@ -47,11 +47,11 @@ * some bad symbol interpretation that raises a warning that is out of our * control. */ -H5_GCC_DIAG_OFF(strict-prototypes) -H5_GCC_DIAG_OFF(undef) +H5_GCC_DIAG_OFF("strict-prototypes") +H5_GCC_DIAG_OFF("undef") #include -H5_GCC_DIAG_ON(strict-prototypes) -H5_GCC_DIAG_ON(undef) +H5_GCC_DIAG_ON("strict-prototypes") +H5_GCC_DIAG_ON("undef") /* toggle function call prints: 1 turns on */ #define HDFS_DEBUG 0 @@ -77,35 +77,32 @@ static hid_t H5FD_HDFS_g = 0; * 2^(10+(1*16)) = 2^26 = 64MB * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] */ -#define HDFS_STATS_BASE 2 -#define HDFS_STATS_INTERVAL 1 +#define HDFS_STATS_BASE 2 +#define HDFS_STATS_INTERVAL 1 #define HDFS_STATS_START_POWER 10 #define HDFS_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. * Used in computing boundaries between stats bins. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define HDFS_STATS_POW(bin_i, out_ptr) { \ - unsigned long long donotshadowresult = 1; \ - unsigned donotshadowindex = 0; \ - for(donotshadowindex = 0; \ - donotshadowindex < (((bin_i) * HDFS_STATS_INTERVAL) + \ - HDFS_STATS_START_POWER); \ - donotshadowindex++) \ - { \ - donotshadowresult *= HDFS_STATS_BASE; \ - } \ - *(out_ptr) = donotshadowresult; \ -} +#define HDFS_STATS_POW(bin_i, out_ptr) \ + { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i)*HDFS_STATS_INTERVAL) + HDFS_STATS_START_POWER); \ + donotshadowindex++) { \ + donotshadowresult *= HDFS_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ + } /* array to hold pre-computed boundaries for stats bins */ static unsigned long long hdfs_stats_boundaries[HDFS_STATS_BIN_COUNT]; - /*************************************************************************** * * Structure: hdfs_statsbin @@ -146,13 +143,11 @@ typedef struct { #endif /* HDFS_STATS */ - /* "unique" identifier for `hdfs_t` structures. * Randomly generated by unweighted dice rolls. */ #define HDFS_HDFST_MAGIC 0x1AD5DE84 - /*************************************************************************** * * Structure: hdfs_t @@ -191,14 +186,12 @@ typedef struct { *************************************************************************** */ typedef struct { - unsigned long magic; - hdfsFS filesystem; - hdfsFileInfo *fileinfo; - hdfsFile file; + unsigned long magic; + hdfsFS filesystem; + hdfsFileInfo *fileinfo; + hdfsFile file; } hdfs_t; - - /*************************************************************************** * * Structure: H5FD_hdfs_t @@ -255,16 +248,15 @@ typedef struct { * * Programmer: Jacob Smith * - *************************************************************************** - */ + ***************************************************************************/ typedef struct H5FD_hdfs_t { - H5FD_t pub; - H5FD_hdfs_fapl_t fa; - haddr_t eoa; - hdfs_t *hdfs_handle; + H5FD_t pub; + H5FD_hdfs_fapl_t fa; + haddr_t eoa; + hdfs_t * hdfs_handle; #if HDFS_STATS - hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; - hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; + hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; + hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; #endif } H5FD_hdfs_t; @@ -278,74 +270,70 @@ typedef struct H5FD_hdfs_t { * Only included if HDFS code should compile. * */ -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) /* 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 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); static int H5FD__hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD__hdfs_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__hdfs_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD__hdfs_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__hdfs_get_handle(H5FD_t *_file, hid_t fapl, - void** file_handle); -static herr_t H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD__hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD__hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); +static herr_t H5FD__hdfs_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD__hdfs_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD__hdfs_unlock(H5FD_t *_file); -static herr_t H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t * fa); +static herr_t H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t *fa); static const H5FD_class_t H5FD_hdfs_g = { - "hdfs", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__hdfs_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_hdfs_fapl_t), /* fapl_size */ - H5FD__hdfs_fapl_get, /* fapl_get */ - H5FD__hdfs_fapl_copy, /* fapl_copy */ - H5FD__hdfs_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__hdfs_open, /* open */ - H5FD__hdfs_close, /* close */ - H5FD__hdfs_cmp, /* cmp */ - H5FD__hdfs_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__hdfs_get_eoa, /* get_eoa */ - H5FD__hdfs_set_eoa, /* set_eoa */ - H5FD__hdfs_get_eof, /* get_eof */ - H5FD__hdfs_get_handle, /* get_handle */ - H5FD__hdfs_read, /* read */ - H5FD__hdfs_write, /* write */ - NULL, /* flush */ - H5FD__hdfs_truncate, /* truncate */ - H5FD__hdfs_lock, /* lock */ - H5FD__hdfs_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "hdfs", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__hdfs_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_hdfs_fapl_t), /* fapl_size */ + H5FD__hdfs_fapl_get, /* fapl_get */ + H5FD__hdfs_fapl_copy, /* fapl_copy */ + H5FD__hdfs_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__hdfs_open, /* open */ + H5FD__hdfs_close, /* close */ + H5FD__hdfs_cmp, /* cmp */ + H5FD__hdfs_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__hdfs_get_eoa, /* get_eoa */ + H5FD__hdfs_set_eoa, /* set_eoa */ + H5FD__hdfs_get_eof, /* get_eof */ + H5FD__hdfs_get_handle, /* get_handle */ + H5FD__hdfs_read, /* read */ + H5FD__hdfs_write, /* write */ + NULL, /* flush */ + H5FD__hdfs_truncate, /* truncate */ + H5FD__hdfs_lock, /* lock */ + H5FD__hdfs_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_hdfs_t struct */ H5FL_DEFINE_STATIC(H5FD_hdfs_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -362,14 +350,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_hdfs_init() < 0) + if (H5FD_hdfs_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize hdfs VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_hdfs_init * @@ -386,10 +373,10 @@ H5FD__init_package(void) hid_t H5FD_hdfs_init(void) { + hid_t ret_value = H5I_INVALID_HID; #if HDFS_STATS unsigned int bin_i; #endif - hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -397,18 +384,18 @@ H5FD_hdfs_init(void) HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(H5I_VFL != H5I_get_type(H5FD_HDFS_g)) + if (H5I_VFL != H5I_get_type(H5FD_HDFS_g)) H5FD_HDFS_g = H5FD_register(&H5FD_hdfs_g, sizeof(H5FD_class_t), FALSE); #if HDFS_STATS /* pre-compute statsbin boundaries */ - for(bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { + for (bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { unsigned long long value = 0; HDFS_STATS_POW(bin_i, &value) hdfs_stats_boundaries[bin_i] = value; - } /* end for */ + } #endif ret_value = H5FD_HDFS_g; @@ -417,7 +404,6 @@ H5FD_hdfs_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_hdfs_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__hdfs_term * @@ -445,7 +431,6 @@ H5FD__hdfs_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__hdfs_term() */ - /*-------------------------------------------------------------------------- * Function: H5FD__hdfs_handle_open * @@ -460,13 +445,13 @@ H5FD__hdfs_term(void) *-------------------------------------------------------------------------- */ static hdfs_t * -H5FD__hdfs_handle_open(const char *path, const char *namenode_name, - const int32_t namenode_port, const char *user_name, - const char *kerberos_ticket_cache, const int32_t stream_buffer_size) +H5FD__hdfs_handle_open(const char *path, const char *namenode_name, const int32_t namenode_port, + const char *user_name, const char *kerberos_ticket_cache, + 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 @@ -474,17 +459,17 @@ H5FD__hdfs_handle_open(const char *path, const char *namenode_name, HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(path == NULL || path[0] == '\0') + if (path == NULL || path[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "path cannot be null") - if(namenode_name == NULL) + if (namenode_name == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "namenode name cannot be null") - if(namenode_port < 0 || namenode_port > 65535) + if (namenode_port < 0 || namenode_port > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "namenode port must be non-negative and <= 65535") - if(stream_buffer_size < 0) + if (stream_buffer_size < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "buffer size must non-negative") handle = (hdfs_t *)H5MM_malloc(sizeof(hdfs_t)); - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle") handle->magic = (unsigned long)HDFS_HDFST_MAGIC; @@ -493,40 +478,40 @@ H5FD__hdfs_handle_open(const char *path, const char *namenode_name, handle->file = NULL; /* TODO: not a pointer; NULL may cause bug */ builder = hdfsNewBuilder(); - if(!builder) + if (!builder) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "(hdfs) failed to create builder") hdfsBuilderSetNameNode(builder, namenode_name); hdfsBuilderSetNameNodePort(builder, (tPort)namenode_port); - if(user_name != NULL && user_name[0] != '\0') + if (user_name != NULL && user_name[0] != '\0') hdfsBuilderSetUserName(builder, user_name); - if(kerberos_ticket_cache != NULL && kerberos_ticket_cache[0] != '\0') + if (kerberos_ticket_cache != NULL && kerberos_ticket_cache[0] != '\0') hdfsBuilderSetKerbTicketCachePath(builder, kerberos_ticket_cache); /* Call to `hdfsBuilderConnect` releases builder, regardless of success. */ handle->filesystem = hdfsBuilderConnect(builder); - if(!handle->filesystem) + if (!handle->filesystem) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "(hdfs) could not connect to default namenode") handle->fileinfo = hdfsGetPathInfo(handle->filesystem, path); - if(!handle->fileinfo) + if (!handle->fileinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "hdfsGetPathInfo failed") handle->file = hdfsOpenFile(handle->filesystem, path, O_RDONLY, stream_buffer_size, 0, 0); - if(!handle->file) + if (!handle->file) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "(hdfs) could not open") ret_value = handle; done: - if(ret_value == NULL && handle != NULL) { + if (ret_value == NULL && handle != NULL) { /* error; clean up */ HDassert(handle->magic == HDFS_HDFST_MAGIC); handle->magic++; - if(handle->file != NULL) - if(FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) + if (handle->file != NULL) + if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close hdfs file handle") - if(handle->fileinfo != NULL) + if (handle->fileinfo != NULL) hdfsFreeFileInfo(handle->fileinfo, 1); - if(handle->filesystem != NULL) - if(FAIL == (hdfsDisconnect(handle->filesystem))) + if (handle->filesystem != NULL) + if (FAIL == (hdfsDisconnect(handle->filesystem))) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to disconnect from hdfs") H5MM_xfree(handle); } @@ -534,7 +519,6 @@ H5FD__hdfs_handle_open(const char *path, const char *namenode_name, FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_handle_open() */ - /*-------------------------------------------------------------------------- * Function: H5FD__hdfs_handle_close * @@ -560,19 +544,19 @@ H5FD__hdfs_handle_close(hdfs_t *handle) HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null") - if(handle->magic != HDFS_HDFST_MAGIC) + if (handle->magic != HDFS_HDFST_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic") handle->magic++; - if(handle->file != NULL) - if(FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) + if (handle->file != NULL) + if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close hdfs file handle") - if(handle->fileinfo != NULL) + if (handle->fileinfo != NULL) hdfsFreeFileInfo(handle->fileinfo, 1); - if(handle->filesystem != NULL) - if(FAIL == (hdfsDisconnect(handle->filesystem))) + if (handle->filesystem != NULL) + if (FAIL == (hdfsDisconnect(handle->filesystem))) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to disconnect hdfs file system") H5MM_xfree(handle); @@ -581,7 +565,6 @@ H5FD__hdfs_handle_close(hdfs_t *handle) FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_handle_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__hdfs_validate_config() * @@ -603,7 +586,7 @@ H5FD__hdfs_handle_close(hdfs_t *handle) *------------------------------------------------------------------------- */ static herr_t -H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t * fa) +H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t *fa) { herr_t ret_value = SUCCEED; @@ -611,30 +594,28 @@ H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t * fa) HDassert(fa != NULL); - if(fa->version != H5FD__CURR_HDFS_FAPL_T_VERSION) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_hdfs_fapl_t version"); - if(fa->namenode_port > 65535) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); - if(fa->namenode_port < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); + if (fa->version != H5FD__CURR_HDFS_FAPL_T_VERSION) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_hdfs_fapl_t version"); + if (fa->namenode_port > 65535) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); + if (fa->namenode_port < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid namenode port number"); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_hdfs * * Purpose: Modify the file access property list to use the H5FD_HDFS - * 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_hdfs_fapl_t * * Return: SUCCEED/FAIL * - * Programmer: John Mainzer - * 9/10/17 + * Programmer: Jacob Smith 2018 * *------------------------------------------------------------------------- */ @@ -654,9 +635,9 @@ H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) #endif plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(plist == NULL) + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(FAIL == H5FD__hdfs_validate_config(fa)) + if (FAIL == H5FD__hdfs_validate_config(fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid hdfs config") ret_value = H5P_set_driver(plist, H5FD_HDFS, (void *)fa); @@ -665,7 +646,6 @@ H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) FUNC_LEAVE_API(ret_value) } /* H5Pset_fapl_hdfs() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_hdfs * @@ -682,39 +662,39 @@ H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) +H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_dst) { - const H5FD_hdfs_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + const H5FD_hdfs_fapl_t *fa_src = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", fapl_id, fa_out); + H5TRACE2("e", "i*x", fapl_id, fa_dst); #if HDFS_DEBUG HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(fa_out == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL") + if (fa_dst == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst ptr is NULL") plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(plist == NULL) + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_HDFS != H5P_peek_driver(plist)) + + if (H5FD_HDFS != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - fa = (const H5FD_hdfs_fapl_t *)H5P_peek_driver_info(plist); - if(fa == NULL) + fa_src = (const H5FD_hdfs_fapl_t *)H5P_peek_driver_info(plist); + if (fa_src == NULL) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Copy the hdfs fapl data out */ - HDmemcpy(fa_out, fa, sizeof(H5FD_hdfs_fapl_t)); + H5MM_memcpy(fs_dst, fa_src, sizeof(H5FD_hdfs_fapl_t)); done: FUNC_LEAVE_API(ret_value) } /* H5Pget_fapl_hdfs() */ - /*------------------------------------------------------------------------- * Function: H5FD__hdfs_fapl_get * @@ -733,29 +713,28 @@ H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) 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 fa = (H5FD_hdfs_fapl_t *)H5MM_calloc(sizeof(H5FD_hdfs_fapl_t)); - if(fa == NULL) + if (fa == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed") /* Copy the fields of the structure */ - HDmemcpy(fa, &(file->fa), sizeof(H5FD_hdfs_fapl_t)); + H5MM_memcpy(fa, &(file->fa), sizeof(H5FD_hdfs_fapl_t)); ret_value = fa; done: - if(ret_value == NULL && fa != NULL) + if (ret_value == NULL && fa != NULL) H5MM_xfree(fa); /* clean up on error */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD__hdfs_fapl_copy * @@ -773,27 +752,26 @@ H5FD__hdfs_fapl_get(H5FD_t *_file) 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; + 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; FUNC_ENTER_STATIC new_fa = (H5FD_hdfs_fapl_t *)H5MM_malloc(sizeof(H5FD_hdfs_fapl_t)); - if(new_fa == NULL) + if (new_fa == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed") - HDmemcpy(new_fa, old_fa, sizeof(H5FD_hdfs_fapl_t)); + H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_hdfs_fapl_t)); ret_value = new_fa; done: - if(ret_value == NULL && new_fa != NULL) + if (ret_value == NULL && new_fa != NULL) H5MM_xfree(new_fa); /* clean up on error */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD__hdfs_fapl_free * @@ -809,7 +787,7 @@ H5FD__hdfs_fapl_copy(const void *_old_fa) static herr_t H5FD__hdfs_fapl_free(void *_fa) { - H5FD_hdfs_fapl_t *fa = (H5FD_hdfs_fapl_t*)_fa; + H5FD_hdfs_fapl_t *fa = (H5FD_hdfs_fapl_t *)_fa; FUNC_ENTER_STATIC_NOERR @@ -820,7 +798,6 @@ H5FD__hdfs_fapl_free(void *_fa) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD__hdfs_fapl_free() */ - #if HDFS_STATS /*---------------------------------------------------------------------------- * @@ -852,17 +829,17 @@ hdfs__reset_stats(H5FD_hdfs_t *file) FUNC_ENTER_STATIC #if HDFS_DEBUG - HDprintf("hdfs__reset_stats() called\n"); + HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(file == NULL) + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file was null") - for(i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { - file->raw[i].bytes = 0; - file->raw[i].count = 0; - file->raw[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; - file->raw[i].max = 0; + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)HDFS_STATS_STARTING_MIN; + file->raw[i].max = 0; file->meta[i].bytes = 0; file->meta[i].count = 0; @@ -876,7 +853,6 @@ hdfs__reset_stats(H5FD_hdfs_t *file) } /* hdfs__reset_stats */ #endif /* HDFS_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_open() @@ -903,10 +879,10 @@ 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_hdfs_fapl_t fa; + H5FD_t * ret_value = NULL; + H5FD_hdfs_t * file = NULL; + hdfs_t * handle = NULL; + H5FD_hdfs_fapl_t fa; FUNC_ENTER_STATIC @@ -918,53 +894,52 @@ H5FD__hdfs_open(const char *path, unsigned flags, hid_t fapl_id, haddr_t maxaddr HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!path || !*path) + if (!path || !*path) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") - if(flags != H5F_ACC_RDONLY) + if (flags != H5F_ACC_RDONLY) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed") - if(fapl_id == H5P_DEFAULT || fapl_id == H5P_FILE_ACCESS_DEFAULT) + if (fapl_id == H5P_DEFAULT || fapl_id == H5P_FILE_ACCESS_DEFAULT) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "fapl cannot be H5P_DEFAULT") - if(FAIL == H5Pget_fapl_hdfs(fapl_id, &fa)) + if (FAIL == H5Pget_fapl_hdfs(fapl_id, &fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") - handle = H5FD__hdfs_handle_open(path, fa.namenode_name, fa.namenode_port, - fa.user_name, fa.kerberos_ticket_cache, fa.stream_buffer_size); - if(handle == NULL) + handle = H5FD__hdfs_handle_open(path, fa.namenode_name, fa.namenode_port, fa.user_name, + fa.kerberos_ticket_cache, fa.stream_buffer_size); + if (handle == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "could not open") HDassert(handle->magic == HDFS_HDFST_MAGIC); /* Create new file struct */ file = H5FL_CALLOC(H5FD_hdfs_t); - if(file == NULL) + if (file == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct") file->hdfs_handle = handle; - HDmemcpy(&(file->fa), &fa, sizeof(H5FD_hdfs_fapl_t)); + H5MM_memcpy(&(file->fa), &fa, sizeof(H5FD_hdfs_fapl_t)); #if HDFS_STATS - if(FAIL == hdfs__reset_stats(file)) + if (FAIL == hdfs__reset_stats(file)) HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, "unable to reset file statistics") #endif /* HDFS_STATS */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value == NULL) { - if(handle != NULL) - if(FAIL == H5FD__hdfs_handle_close(handle)) + if (ret_value == NULL) { + if (handle != NULL) + if (FAIL == H5FD__hdfs_handle_close(handle)) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close HDFS file handle") - if(file != NULL) + if (file != NULL) file = H5FL_FREE(H5FD_hdfs_t, file); } /* end if null return value (error) */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_open() */ - #if HDFS_STATS /*---------------------------------------------------------------------------- @@ -1025,70 +1000,70 @@ 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; double average_meta = 0.0; double average_raw = 0.0; - unsigned long long min_meta = (unsigned long long)HDFS_STATS_STARTING_MIN; - unsigned long long min_raw = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long min_meta = (unsigned long long)HDFS_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)HDFS_STATS_STARTING_MIN; unsigned long long max_meta = 0; 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 */ unsigned suffix_i = 0; - const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; + const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; FUNC_ENTER_STATIC - if(stream == NULL) + if (stream == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null") - if(file == NULL) + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file cannot be null") - if(file->hdfs_handle == NULL) + if (file->hdfs_handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hdfs handle cannot be null") - if(file->hdfs_handle->magic != HDFS_HDFST_MAGIC) + if (file->hdfs_handle->magic != HDFS_HDFST_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hdfs handle has invalid magic") /******************* * AGGREGATE STATS * *******************/ - for(i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { const hdfs_statsbin *r = &file->raw[i]; const hdfs_statsbin *m = &file->meta[i]; - if(m->min < min_meta) + if (m->min < min_meta) min_meta = m->min; - if(r->min < min_raw) - min_raw = r->min; - if(m->max > max_meta) + if (r->min < min_raw) + min_raw = r->min; + if (m->max > max_meta) max_meta = m->max; - if(r->max > max_raw) - max_raw = r->max; + if (r->max > max_raw) + max_raw = r->max; - count_raw += r->count; + count_raw += r->count; count_meta += m->count; - bytes_raw += r->bytes; + bytes_raw += r->bytes; bytes_meta += m->bytes; } - if(count_raw > 0) - average_raw = (double)bytes_raw / (double)count_raw; - if(count_meta > 0) + if (count_raw > 0) + average_raw = (double)bytes_raw / (double)count_raw; + if (count_meta > 0) average_meta = (double)bytes_meta / (double)count_meta; /****************** * PRINT OVERVIEW * ******************/ - HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", - count_raw + count_meta, count_meta, count_raw); - HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", - bytes_raw + bytes_meta, bytes_meta, bytes_raw); + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", count_raw + count_meta, count_meta, + count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", bytes_raw + bytes_meta, bytes_meta, + bytes_raw); - if(count_raw + count_meta == 0) + if (count_raw + count_meta == 0) goto done; /************************* @@ -1097,21 +1072,21 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) HDfprintf(stream, "SIZES meta raw\n"); HDfprintf(stream, " min "); - if(count_meta == 0) + if (count_meta == 0) HDfprintf(stream, " 0.000 "); else { re_dub = (double)min_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); } - if(count_raw == 0) + if (count_raw == 0) HDfprintf(stream, " 0.000 \n"); else { re_dub = (double)min_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); @@ -1119,26 +1094,26 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) HDfprintf(stream, " avg "); re_dub = (double)average_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); re_dub = (double)average_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); HDfprintf(stream, " max "); re_dub = (double)max_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); re_dub = (double)max_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); @@ -1147,12 +1122,10 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) * PRINT INDIVIDUAL BIN STATS * ******************************/ - HDfprintf(stream, - "BINS # of reads total bytes average size\n"); - HDfprintf(stream, - " up-to meta raw meta raw meta raw\n"); + HDfprintf(stream, "BINS # of reads total bytes average size\n"); + HDfprintf(stream, " up-to meta raw meta raw meta raw\n"); - for(i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { + for (i = 0; i <= HDFS_STATS_BIN_COUNT; i++) { const hdfs_statsbin *m; const hdfs_statsbin *r; unsigned long long range_end = 0; @@ -1167,59 +1140,57 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) m = &file->meta[i]; r = &file->raw[i]; - if(r->count == 0 && m->count == 0) + if (r->count == 0 && m->count == 0) continue; range_end = hdfs_stats_boundaries[i]; - if(i == HDFS_STATS_BIN_COUNT) { - range_end = hdfs_stats_boundaries[i-1]; + if (i == HDFS_STATS_BIN_COUNT) { + range_end = hdfs_stats_boundaries[i - 1]; HDfprintf(stream, ">"); } else HDfprintf(stream, " "); bm_val = (double)m->bytes; - for(suffix_i = 0; bm_val >= 1024.0; suffix_i++) + for (suffix_i = 0; bm_val >= 1024.0; suffix_i++) bm_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); bm_suffix = suffixes[suffix_i]; br_val = (double)r->bytes; - for(suffix_i = 0; br_val >= 1024.0; suffix_i++) + for (suffix_i = 0; br_val >= 1024.0; suffix_i++) br_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); br_suffix = suffixes[suffix_i]; - if(m->count > 0) + if (m->count > 0) am_val = (double)(m->bytes) / (double)(m->count); - for(suffix_i = 0; am_val >= 1024.0; suffix_i++) + for (suffix_i = 0; am_val >= 1024.0; suffix_i++) am_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); am_suffix = suffixes[suffix_i]; - if(r->count > 0) + if (r->count > 0) ar_val = (double)(r->bytes) / (double)(r->count); - for(suffix_i = 0; ar_val >= 1024.0; suffix_i++) + for (suffix_i = 0; ar_val >= 1024.0; suffix_i++) ar_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); ar_suffix = suffixes[suffix_i]; re_dub = (double)range_end; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); - HDfprintf( - stream, - " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", - re_dub, suffixes[suffix_i], /* bin ceiling */ - m->count, /* metadata reads */ - r->count, /* rawdata reads */ - bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ - am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, + suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ HDfflush(stream); } @@ -1228,7 +1199,6 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) } /* hdfs__fprint_stats */ #endif /* HDFS_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_close() @@ -1249,8 +1219,8 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) static herr_t H5FD__hdfs_close(H5FD_t *_file) { - herr_t ret_value = SUCCEED; H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1264,13 +1234,13 @@ H5FD__hdfs_close(H5FD_t *_file) HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); /* Close the underlying request handle */ - if(file->hdfs_handle != NULL) - if(FAIL == H5FD__hdfs_handle_close(file->hdfs_handle)) + if (file->hdfs_handle != NULL) + if (FAIL == H5FD__hdfs_handle_close(file->hdfs_handle)) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close HDFS file handle") #if HDFS_STATS /* TODO: mechanism to re-target stats printout */ - if(FAIL == hdfs__fprint_stats(stdout, file)) + if (FAIL == hdfs__fprint_stats(stdout, file)) HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, "problem while writing file statistics") #endif /* HDFS_STATS */ @@ -1281,7 +1251,6 @@ H5FD__hdfs_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__hdfs_close() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_cmp() @@ -1292,8 +1261,8 @@ H5FD__hdfs_close(H5FD_t *_file) * field-by-field. * * Return: - * + Equivalent: 0 - * + Not Equivalent: -1 + * Equivalent: 0 + * Not Equivalent: -1 * * Programmer: Gerd Herber * May 2018 @@ -1306,8 +1275,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 @@ -1325,22 +1294,41 @@ H5FD__hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HDassert(finfo1 != NULL); HDassert(finfo2 != NULL); - if(finfo1->mKind != finfo2->mKind) { HGOTO_DONE(-1); } - if(finfo1->mName != finfo2->mName) { HGOTO_DONE(-1); } - if(finfo1->mLastMod != finfo2->mLastMod) { HGOTO_DONE(-1); } - if(finfo1->mSize != finfo2->mSize) { HGOTO_DONE(-1); } - if(finfo1->mReplication != finfo2->mReplication) { HGOTO_DONE(-1); } - if(finfo1->mBlockSize != finfo2->mBlockSize) { HGOTO_DONE(-1); } - if(HDstrcmp(finfo1->mOwner, finfo2->mOwner)) { HGOTO_DONE(-1); } - if(HDstrcmp(finfo1->mGroup, finfo2->mGroup)) { HGOTO_DONE(-1); } - if(finfo1->mPermissions != finfo2->mPermissions) { HGOTO_DONE(-1); } - if(finfo1->mLastAccess != finfo2->mLastAccess) { HGOTO_DONE(-1); } + if (finfo1->mKind != finfo2->mKind) { + HGOTO_DONE(-1); + } + if (finfo1->mName != finfo2->mName) { + HGOTO_DONE(-1); + } + if (finfo1->mLastMod != finfo2->mLastMod) { + HGOTO_DONE(-1); + } + if (finfo1->mSize != finfo2->mSize) { + HGOTO_DONE(-1); + } + if (finfo1->mReplication != finfo2->mReplication) { + HGOTO_DONE(-1); + } + if (finfo1->mBlockSize != finfo2->mBlockSize) { + HGOTO_DONE(-1); + } + if (HDstrcmp(finfo1->mOwner, finfo2->mOwner)) { + HGOTO_DONE(-1); + } + if (HDstrcmp(finfo1->mGroup, finfo2->mGroup)) { + HGOTO_DONE(-1); + } + if (finfo1->mPermissions != finfo2->mPermissions) { + HGOTO_DONE(-1); + } + if (finfo1->mLastAccess != finfo2->mLastAccess) { + HGOTO_DONE(-1); + } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__hdfs_query * @@ -1369,7 +1357,7 @@ H5FD__hdfs_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) HDfprintf(stdout, "called %s.\n", FUNC); #endif - if(flags) { + if (flags) { *flags = 0; *flags |= H5FD_FEAT_DATA_SIEVE; } @@ -1377,7 +1365,6 @@ H5FD__hdfs_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD__hdfs_query() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_get_eoa() @@ -1411,7 +1398,6 @@ H5FD__hdfs_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__hdfs_get_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_set_eoa() @@ -1445,7 +1431,6 @@ H5FD__hdfs_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD__hdfs_set_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_get_eof() @@ -1478,10 +1463,9 @@ H5FD__hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) HDassert(file->hdfs_handle != NULL); HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); - FUNC_LEAVE_NOAPI((size_t) file->hdfs_handle->fileinfo->mSize) + FUNC_LEAVE_NOAPI((size_t)file->hdfs_handle->fileinfo->mSize) } /* end H5FD__hdfs_get_eof() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_get_handle() @@ -1502,8 +1486,8 @@ H5FD__hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__hdfs_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - herr_t ret_value = SUCCEED; H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1511,7 +1495,7 @@ H5FD__hdfs_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_hand HDfprintf(stdout, "called %s.\n", FUNC); #endif /* HDFS_DEBUG */ - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = file->hdfs_handle; @@ -1520,7 +1504,6 @@ H5FD__hdfs_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_hand FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__hdfs_get_handle() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_read() @@ -1544,12 +1527,12 @@ H5FD__hdfs_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_hand *------------------------------------------------------------------------- */ static herr_t -H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf) +H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf) { - herr_t ret_value = SUCCEED; H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; size_t filesize = 0; + herr_t ret_value = SUCCEED; #if HDFS_STATS /* working variables for storing stats */ hdfs_statsbin *bin = NULL; @@ -1567,34 +1550,32 @@ H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, HDassert(file->hdfs_handle->magic == HDFS_HDFST_MAGIC); HDassert(buf != NULL); - filesize = (size_t) file->hdfs_handle->fileinfo->mSize; + filesize = (size_t)file->hdfs_handle->fileinfo->mSize; - if((addr > filesize) || ((addr + size) > filesize)) + if ((addr > filesize) || ((addr + size) > filesize)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") - if(FAIL == hdfsPread(file->hdfs_handle->filesystem, file->hdfs_handle->file, - (tOffset)addr, buf, (tSize)size)) + if (FAIL == + hdfsPread(file->hdfs_handle->filesystem, file->hdfs_handle->file, (tOffset)addr, buf, (tSize)size)) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to execute read") #if HDFS_STATS /* Find which "bin" this read fits in. Can be "overflow" bin. */ - for(bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) - if((unsigned long long)size < hdfs_stats_boundaries[bin_i]) + for (bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) + if ((unsigned long long)size < hdfs_stats_boundaries[bin_i]) break; - bin = (type == H5FD_MEM_DRAW) - ? &file->raw[bin_i] - : &file->meta[bin_i]; + bin = (type == H5FD_MEM_DRAW) ? &file->raw[bin_i] : &file->meta[bin_i]; /* Store collected stats in appropriate bin */ - if(bin->count == 0) { + if (bin->count == 0) { bin->min = size; bin->max = size; } else { - if(size < bin->min) + if (size < bin->min) bin->min = size; - if(size > bin->max) + if (size > bin->max) bin->max = size; } bin->count++; @@ -1606,7 +1587,6 @@ H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__hdfs_read() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_write() @@ -1626,9 +1606,8 @@ H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, *------------------------------------------------------------------------- */ static herr_t -H5FD__hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, - const void H5_ATTR_UNUSED *buf) +H5FD__hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; @@ -1644,7 +1623,6 @@ H5FD__hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__hdfs_write() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_truncate() @@ -1667,7 +1645,7 @@ H5FD__hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, */ static herr_t H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) + hbool_t H5_ATTR_UNUSED closing) { herr_t ret_value = SUCCEED; @@ -1683,7 +1661,6 @@ H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__hdfs_truncate() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_lock() @@ -1694,7 +1671,7 @@ H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, * No effect on Read-Only S3 file. * * Suggestion: remove lock/unlock from class - * > would result in error at H5FD_[un]lock() (H5FD.c) + * would result in error at H5FD_[un]lock() (H5FD.c) * * Return: * @@ -1706,16 +1683,13 @@ H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5FD__hdfs_lock( - H5FD_t H5_ATTR_UNUSED *_file, - hbool_t H5_ATTR_UNUSED rw) +H5FD__hdfs_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw) { FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__hdfs_lock() */ - /*------------------------------------------------------------------------- * * Function: H5FD__hdfs_unlock() @@ -1786,4 +1760,3 @@ H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) } #endif /* H5_HAVE_LIBHDFS */ - diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index 58d7e6e1e11..219d0acdfa8 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -16,16 +16,16 @@ * Programmer: Jacob Smith * 2018-04-23 * - * Purpose: The public header file for the hdfs driver. + * Purpose: The public header file for the hdfs driver. */ #ifndef H5FDhdfs_H #define H5FDhdfs_H #ifdef H5_HAVE_LIBHDFS -#define H5FD_HDFS (H5FD_hdfs_init()) +#define H5FD_HDFS (H5FD_hdfs_init()) #else /* H5_HAVE_LIBHDFS */ -#define H5FD_HDFS (-1) +#define H5FD_HDFS (H5I_INVALID_HID) #endif /* H5_HAVE_LIBHDFS */ /**************************************************************************** @@ -94,8 +94,8 @@ #define H5FD__CURR_HDFS_FAPL_T_VERSION 1 -#define H5FD__HDFS_NODE_NAME_SPACE 128 -#define H5FD__HDFS_USER_NAME_SPACE 128 +#define H5FD__HDFS_NODE_NAME_SPACE 128 +#define H5FD__HDFS_USER_NAME_SPACE 128 #define H5FD__HDFS_KERB_CACHE_PATH_SPACE 128 typedef struct H5FD_hdfs_fapl_t { @@ -112,7 +112,19 @@ extern "C" { #endif H5_DLL hid_t H5FD_hdfs_init(void); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa); #ifdef __cplusplus @@ -120,4 +132,3 @@ H5_DLL herr_t H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa); #endif #endif /* ifndef H5FDhdfs_H */ - diff --git a/src/H5FDint.c b/src/H5FDint.c index 8a2148af761..25d77d174e1 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,56 +24,46 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FD_locate_signature * @@ -88,13 +78,13 @@ herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) { - haddr_t addr = HADDR_UNDEF; - haddr_t eoa = HADDR_UNDEF; - haddr_t eof = HADDR_UNDEF; - uint8_t buf[H5F_SIGNATURE_LEN]; - unsigned n; - unsigned maxpow; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t addr = HADDR_UNDEF; + haddr_t eoa = HADDR_UNDEF; + haddr_t eof = HADDR_UNDEF; + uint8_t buf[H5F_SIGNATURE_LEN]; + unsigned n; + unsigned maxpow; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -103,33 +93,33 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) HDassert(sig_addr); /* Find the least N such that 2^N is larger than the file size */ - eof = H5FD_get_eof(file, H5FD_MEM_SUPER); - eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); + eof = H5FD_get_eof(file, H5FD_MEM_SUPER); + eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); addr = MAX(eof, eoa); - if(HADDR_UNDEF == addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value") - for(maxpow = 0; addr; maxpow++) + for (maxpow = 0; addr; maxpow++) addr >>= 1; maxpow = MAX(maxpow, 9); /* Search for the file signature at format address zero followed by * powers of two larger than 9. */ - for(n = 8; n < maxpow; n++) { + for (n = 8; n < maxpow; n++) { addr = (8 == n) ? 0 : (haddr_t)1 << n; - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") - if(H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) + if (H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") - if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) + if (!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) break; } /* If the signature was not found then reset the EOA value and return * HADDR_UNDEF. */ - if(n >= maxpow) { - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) + if (n >= maxpow) { + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value") *sig_addr = HADDR_UNDEF; } @@ -141,7 +131,6 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_locate_signature() */ - /*------------------------------------------------------------------------- * Function: H5FD_read * @@ -152,10 +141,10 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) *------------------------------------------------------------------------- */ herr_t -H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -173,7 +162,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ @@ -183,25 +172,26 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o * objects being written within the file by the application performing * SWMR write operations. */ - if(!(file->access_flags & H5F_ACC_SWMR_READ)) { - haddr_t eoa; + if (!(file->access_flags & H5F_ACC_SWMR_READ)) { + haddr_t eoa; - if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - if((addr + file->base_addr + size) > eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)(addr + file->base_addr), (unsigned long long)size, (unsigned long long)eoa) + if ((addr + file->base_addr + size) > eoa) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", + (unsigned long long)(addr + file->base_addr), (unsigned long long)size, + (unsigned long long)eoa) } /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_write * @@ -214,9 +204,9 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - hid_t dxpl_id; /* DXPL for operation */ - haddr_t eoa = HADDR_UNDEF; /* EOA for file */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id; /* DXPL for operation */ + haddr_t eoa = HADDR_UNDEF; /* EOA for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -234,25 +224,25 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ - if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - if((addr + file->base_addr + size) > eoa) + if ((addr + file->base_addr + size) > eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%llu, eoa=%llu", - (unsigned long long)(addr+ file->base_addr), (unsigned long long)size, (unsigned long long)eoa) + (unsigned long long)(addr + file->base_addr), (unsigned long long)size, + (unsigned long long)eoa) /* Dispatch to driver */ - if((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_eoa * @@ -270,7 +260,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -278,14 +268,13 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) HDassert(H5F_addr_defined(addr) && addr <= file->maxaddr); /* Dispatch to driver, convert to absolute address */ - if((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) + if ((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eoa * @@ -305,14 +294,14 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") /* Adjust for base address in file (convert to relative address) */ @@ -322,7 +311,6 @@ H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eof * @@ -342,15 +330,15 @@ H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(file->cls->get_eof) { - if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) + if (file->cls->get_eof) { + if (HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed") } else @@ -363,23 +351,22 @@ H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eof() */ - /*------------------------------------------------------------------------- -* Function: H5FD_driver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver is passed in -* as a parameter. -* -* Return: SUCCEED/FAIL -* -*------------------------------------------------------------------------- -*/ + * Function: H5FD_driver_query + * + * Purpose: Similar to H5FD_query(), but intended for cases when we don't + * have a file available (e.g. before one is opened). Since we + * can't use the file to get the driver, the driver is passed in + * as a parameter. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t -H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) +H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -387,11 +374,10 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) HDassert(flags); /* Check for the driver to query and then query it */ - if(driver->query) + if (driver->query) ret_value = (driver->query)(NULL, flags); else *flags = 0; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_driver_query() */ - diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 5d1b536ebee..7214b75e15b 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,16 +26,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDlog.h" /* Logging file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDlog.h" /* Logging file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_LOG_g = 0; @@ -45,9 +44,9 @@ 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 */ + size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; /* Define strings for the different file memory types @@ -55,14 +54,9 @@ typedef struct H5FD_log_fapl_t { * Note that H5FD_MEM_NOLIST is not listed here since it has * a negative value. */ -static const char *flavors[]={ - "H5FD_MEM_DEFAULT", - "H5FD_MEM_SUPER", - "H5FD_MEM_BTREE", - "H5FD_MEM_DRAW", - "H5FD_MEM_GHEAP", - "H5FD_MEM_LHEAP", - "H5FD_MEM_OHDR", +static const char *flavors[] = { + "H5FD_MEM_DEFAULT", "H5FD_MEM_SUPER", "H5FD_MEM_BTREE", "H5FD_MEM_DRAW", + "H5FD_MEM_GHEAP", "H5FD_MEM_LHEAP", "H5FD_MEM_OHDR", }; /* The description of a file belonging to this driver. The `eoa' and `eof' @@ -77,14 +71,14 @@ static const char *flavors[]={ * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_log_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the unix file */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ - haddr_t pos; /* current file I/O position */ - H5FD_file_op_t op; /* last operation */ - hbool_t ignore_disabled_file_locks; - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the unix file */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ + haddr_t pos; /* current file I/O position */ + H5FD_file_op_t op; /* last operation */ + hbool_t ignore_disabled_file_locks; + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -92,8 +86,8 @@ typedef struct H5FD_log_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -109,35 +103,35 @@ typedef struct H5FD_log_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ /* Information from properties set by 'h5repart' tool * * Whether to eliminate the family driver info and convert this file to * a single file */ - hbool_t fam_to_single; + 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 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 */ - unsigned long long total_truncate_ops; /* Total number of truncate operations */ - double total_read_time; /* Total time spent in read operations */ - double total_write_time; /* Total time spent in write operations */ - 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 */ - H5FD_log_fapl_t fa; /* Driver-specific file access properties */ + 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 */ + unsigned long long total_truncate_ops; /* Total number of truncate operations */ + double total_read_time; /* Total time spent in read operations */ + double total_write_time; /* Total time spent in write operations */ + 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 */ + H5FD_log_fapl_t fa; /* Driver-specific file access properties */ } H5FD_log_t; /* @@ -155,77 +149,73 @@ typedef struct H5FD_log_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF == (A) + (Z) || \ - (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* 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 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); -static int H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD__log_query(const H5FD_t *_f1, unsigned long *flags); +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 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); +static int H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__log_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -static herr_t H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - hsize_t size); +static herr_t H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); static haddr_t H5FD__log_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__log_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD__log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__log_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__log_unlock(H5FD_t *_file); +static herr_t H5FD__log_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__log_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__log_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_log_g = { - "log", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__log_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_log_fapl_t), /* fapl_size */ - H5FD__log_fapl_get, /* fapl_get */ - H5FD__log_fapl_copy, /* fapl_copy */ - H5FD__log_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__log_open, /* open */ - H5FD__log_close, /* close */ - H5FD__log_cmp, /* cmp */ - H5FD__log_query, /* query */ - NULL, /* get_type_map */ - H5FD__log_alloc, /* alloc */ - H5FD__log_free, /* free */ - H5FD__log_get_eoa, /* get_eoa */ - H5FD__log_set_eoa, /* set_eoa */ - H5FD__log_get_eof, /* get_eof */ - H5FD__log_get_handle, /* get_handle */ - H5FD__log_read, /* read */ - H5FD__log_write, /* write */ - NULL, /* flush */ - H5FD__log_truncate, /* truncate */ - H5FD__log_lock, /* lock */ - H5FD__log_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "log", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__log_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_log_fapl_t), /* fapl_size */ + H5FD__log_fapl_get, /* fapl_get */ + H5FD__log_fapl_copy, /* fapl_copy */ + H5FD__log_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__log_open, /* open */ + H5FD__log_close, /* close */ + H5FD__log_cmp, /* cmp */ + H5FD__log_query, /* query */ + NULL, /* get_type_map */ + H5FD__log_alloc, /* alloc */ + H5FD__log_free, /* free */ + H5FD__log_get_eoa, /* get_eoa */ + H5FD__log_set_eoa, /* set_eoa */ + H5FD__log_get_eof, /* get_eof */ + H5FD__log_get_handle, /* get_handle */ + H5FD__log_read, /* read */ + H5FD__log_write, /* write */ + NULL, /* flush */ + H5FD__log_truncate, /* truncate */ + H5FD__log_lock, /* lock */ + H5FD__log_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_log_t struct */ H5FL_DEFINE_STATIC(H5FD_log_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -238,28 +228,27 @@ H5FL_DEFINE_STATIC(H5FD_log_t); static herr_t H5FD__init_package(void) { - char *lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; + char * lock_env_var = NULL; /* Environment variable pointer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - if(H5FD_log_init() < 0) + if (H5FD_log_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_log_init * @@ -277,11 +266,11 @@ H5FD__init_package(void) hid_t H5FD_log_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) + if (H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -291,7 +280,6 @@ H5FD_log_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__log_term * @@ -315,7 +303,6 @@ H5FD__log_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_log * @@ -332,39 +319,41 @@ H5FD__log_term(void) herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size) { - H5FD_log_fapl_t fa; /* File access property list information */ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; /* Return value */ + H5FD_log_fapl_t fa; /* File access property list information */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sULz", fapl_id, logfile, flags, buf_size); + /* Do this first, so that we don't try to free a wild pointer if + * H5P_object_verify() fails. + */ + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + /* Check arguments */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); - /* Duplicate the log file string * A little wasteful, since this string will just be copied later, but * passing it in as a pointer sets off a chain of impossible-to-resolve * const cast warnings. */ - if(logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile))) + if (logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to copy log file name") - fa.flags = flags; + fa.flags = flags; fa.buf_size = buf_size; - ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); + ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); done: - if(fa.logfile) + if (fa.logfile) H5MM_free(fa.logfile); FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_log() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_fapl_get * @@ -384,8 +373,8 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si static void * H5FD__log_fapl_get(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - void *ret_value = NULL; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -395,7 +384,6 @@ H5FD__log_fapl_get(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_fapl_copy * @@ -412,41 +400,40 @@ H5FD__log_fapl_get(H5FD_t *_file) 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 */ + 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 */ FUNC_ENTER_STATIC HDassert(old_fa); /* Allocate the new FAPL info */ - if(NULL == (new_fa = (H5FD_log_fapl_t *)H5MM_calloc(sizeof(H5FD_log_fapl_t)))) + if (NULL == (new_fa = (H5FD_log_fapl_t *)H5MM_calloc(sizeof(H5FD_log_fapl_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") /* Copy the general information */ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_log_fapl_t)); /* Deep copy the log file name */ - if(old_fa->logfile != NULL) - if(NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) + if (old_fa->logfile != NULL) + if (NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name") /* Set return value */ ret_value = new_fa; done: - if(NULL == ret_value) - if(new_fa) { - if(new_fa->logfile) + if (NULL == ret_value) + if (new_fa) { + if (new_fa->logfile) new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_fapl_free * @@ -462,19 +449,18 @@ H5FD__log_fapl_copy(const void *_old_fa) static herr_t H5FD__log_fapl_free(void *_fa) { - H5FD_log_fapl_t *fa = (H5FD_log_fapl_t*)_fa; + H5FD_log_fapl_t *fa = (H5FD_log_fapl_t *)_fa; FUNC_ENTER_STATIC_NOERR /* Free the fapl information */ - if(fa->logfile) + if (fa->logfile) fa->logfile = (char *)H5MM_xfree(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_fapl_free() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_open * @@ -493,18 +479,18 @@ 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 */ - const H5FD_log_fapl_t *fa; /* File access property list information */ - int fd = -1; /* File descriptor */ - int o_flags; /* Flags for open() call */ + 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 */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -512,81 +498,84 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + /* Initialize timers */ + H5_timer_init(&open_timer); + H5_timer_init(&stat_timer); + /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) + if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) + if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) + if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Get the driver specific information */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) + if (NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Start timer for open() call */ - if(fa->flags & H5FD_LOG_TIME_OPEN) { - H5_timer_init(&open_timer); + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_start(&open_timer); - } /* end if */ /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); - } /* end if */ + HGOTO_ERROR( + H5E_FILE, H5E_CANTOPENFILE, NULL, + "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", + name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + } /* Stop timer for open() call */ - if(fa->flags & H5FD_LOG_TIME_OPEN) + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_stop(&open_timer); /* Start timer for stat() call */ - if(fa->flags & H5FD_LOG_TIME_STAT) { - H5_timer_init(&stat_timer); + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_start(&stat_timer); - } /* end if */ /* Get the file stats */ - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Stop timer for stat() call */ - if(fa->flags & H5FD_LOG_TIME_STAT) + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_stop(&stat_timer); /* Create the new file struct */ - if(NULL == (file = H5FL_CALLOC(H5FD_log_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_log_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ /* Retain a copy of the name used to open the file, for possible error reporting */ @@ -595,87 +584,86 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the flags for logging */ file->fa.flags = fa->flags; - if(fa->logfile) + if (fa->logfile) file->fa.logfile = H5MM_strdup(fa->logfile); else file->fa.logfile = NULL; file->fa.buf_size = fa->buf_size; /* Check if we are doing any logging at all */ - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Allocate buffers for tracking file accesses and data "flavor" */ file->iosize = fa->buf_size; - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { file->nread = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nread); - } /* end if */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { + } + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { file->nwrite = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nwrite); - } /* end if */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + } + if (file->fa.flags & H5FD_LOG_FLAVOR) { file->flavor = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->flavor); - } /* end if */ + } /* Set the log file pointer */ - if(fa->logfile) + if (fa->logfile) file->logfp = HDfopen(fa->logfile, "w"); else file->logfp = stderr; /* Log the timer values */ - if(file->fa.flags & H5FD_LOG_TIME_OPEN) { - H5_timevals_t open_times; /* Elapsed time for open() call */ + if (file->fa.flags & H5FD_LOG_TIME_OPEN) { + H5_timevals_t open_times; /* Elapsed time for open() call */ H5_timer_get_times(open_timer, &open_times); HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); - } /* end if */ - if(file->fa.flags & H5FD_LOG_TIME_STAT) { - H5_timevals_t stat_times; /* Elapsed time for stat() call */ + } + if (file->fa.flags & H5FD_LOG_TIME_STAT) { + H5_timevals_t stat_times; /* Elapsed time for stat() call */ H5_timer_get_times(stat_timer, &stat_times); HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); - } /* end if */ - } /* end if */ + } + } /* Check the file locking flags in the fapl */ - if(ignore_disabled_file_locks_s != FAIL) + if (ignore_disabled_file_locks_s != FAIL) /* The environment variable was set, so use that preferentially */ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s; else { /* Use the value in the property list */ - if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) + if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property") } /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { + if (H5P_FILE_ACCESS_DEFAULT != fapl_id) { /* This step is for h5repart tool only. If user wants to change file driver from * family to one that uses single files (sec2, etc.) while using h5repart, this * private property should be set so that in the later step, the library can ignore * the family driver information saved in the superblock. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) - if(H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) + if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") - } /* end if */ + } /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(NULL == ret_value) { - if(fd >= 0) + if (NULL == ret_value) { + if (fd >= 0) HDclose(fd); - if(file) + if (file) file = H5FL_FREE(H5FD_log_t, file); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_close * @@ -692,125 +680,137 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) static herr_t H5FD__log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - H5_timer_t close_timer; /* Timer for close() call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); + /* Initialize timer */ + H5_timer_init(&close_timer); + /* Start timer for close() call */ - if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timer_init(&close_timer); + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_start(&close_timer); - } /* end if */ /* Close the underlying file */ - if(HDclose(file->fd) < 0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Stop timer for close() call */ - if(file->fa.flags&H5FD_LOG_TIME_CLOSE) + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_stop(&close_timer); /* Dump I/O information */ - if(file->fa.flags != 0) { - haddr_t addr; - haddr_t last_addr; + if (file->fa.flags != 0) { + haddr_t addr; + haddr_t last_addr; unsigned char last_val; - if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timevals_t close_times; /* Elapsed time for close() call */ + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { + H5_timevals_t close_times; /* Elapsed time for close() call */ H5_timer_get_times(close_timer, &close_times); HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); - } /* end if */ + } /* Dump the total number of seek/read/write operations */ - if(file->fa.flags & H5FD_LOG_NUM_READ) + if (file->fa.flags & H5FD_LOG_NUM_READ) HDfprintf(file->logfp, "Total number of read operations: %llu\n", file->total_read_ops); - if(file->fa.flags & H5FD_LOG_NUM_WRITE) + if (file->fa.flags & H5FD_LOG_NUM_WRITE) HDfprintf(file->logfp, "Total number of write operations: %llu\n", file->total_write_ops); - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) HDfprintf(file->logfp, "Total number of seek operations: %llu\n", file->total_seek_ops); - if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + if (file->fa.flags & H5FD_LOG_NUM_TRUNCATE) HDfprintf(file->logfp, "Total number of truncate operations: %llu\n", file->total_truncate_ops); /* Dump the total time in seek/read/write */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) HDfprintf(file->logfp, "Total time in read operations: %f s\n", file->total_read_time); - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) HDfprintf(file->logfp, "Total time in write operations: %f s\n", file->total_write_time); - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, "Total time in seek operations: %f s\n", file->total_seek_time); - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) HDfprintf(file->logfp, "Total time in truncate operations: %f s\n", file->total_truncate_time); /* Dump the write I/O information */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { HDfprintf(file->logfp, "Dumping write I/O information:\n"); - last_val = file->nwrite[0]; + last_val = file->nwrite[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->nwrite[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - last_val = file->nwrite[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->nwrite[addr] != last_val) { + HDfprintf(file->logfp, + "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) written to %3d times\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + last_val = file->nwrite[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } + HDfprintf(file->logfp, + "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) written to %3d times\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + } /* Dump the read I/O information */ - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { HDfprintf(file->logfp, "Dumping read I/O information:\n"); - last_val = file->nread[0]; + last_val = file->nread[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->nread[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - last_val = file->nread[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->nread[addr] != last_val) { + HDfprintf(file->logfp, + "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) read from %3d times\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + last_val = file->nread[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } + HDfprintf(file->logfp, + "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) read from %3d times\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); + } /* Dump the I/O flavor information */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDfprintf(file->logfp, "Dumping I/O flavor information:\n"); - last_val = file->flavor[0]; + last_val = file->flavor[0]; last_addr = 0; - addr = 1; - while(addr < file->eoa) { - if(file->flavor[addr] != last_val) { - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - last_val = file->flavor[addr]; + addr = 1; + while (addr < file->eoa) { + if (file->flavor[addr] != last_val) { + HDfprintf(file->logfp, + "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) flavor is %s\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); + last_val = file->flavor[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ - HDfprintf(file->logfp, "\tAddr %10a-%10a (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - } /* end if */ + } + HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) flavor is %s\n", + last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); + } /* Free the logging information */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) + if (file->fa.flags & H5FD_LOG_FILE_WRITE) file->nwrite = (unsigned char *)H5MM_xfree(file->nwrite); - if(file->fa.flags & H5FD_LOG_FILE_READ) + if (file->fa.flags & H5FD_LOG_FILE_READ) file->nread = (unsigned char *)H5MM_xfree(file->nread); - if(file->fa.flags & H5FD_LOG_FLAVOR) + if (file->fa.flags & H5FD_LOG_FLAVOR) file->flavor = (unsigned char *)H5MM_xfree(file->flavor); - if(file->logfp != stderr) + if (file->logfp != stderr) HDfclose(file->logfp); } /* end if */ - if(file->fa.logfile) + if (file->fa.logfile) file->fa.logfile = (char *)H5MM_xfree(file->fa.logfile); /* Release the file info */ @@ -820,7 +820,6 @@ H5FD__log_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_cmp * @@ -839,36 +838,48 @@ H5FD__log_close(H5FD_t *_file) static int H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; - const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; - int ret_value = 0; + const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; + const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) - - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) + + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) HGOTO_DONE(-1) - if(f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) HGOTO_DONE(-1) - if(f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif @@ -876,7 +887,6 @@ H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_query * @@ -893,30 +903,32 @@ H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) static herr_t H5FD__log_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ + *flags |= + H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ /* Check for flags that are set by h5repart */ - if(file && file->fam_to_single) - *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + if (file && file->fam_to_single) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which + eliminates it) */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_alloc * @@ -933,9 +945,9 @@ H5FD__log_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t *)_file; - haddr_t addr; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + haddr_t addr; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -946,16 +958,18 @@ H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hs file->eoa = addr + size; /* Retain the (first) flavor of the information written to the file */ - if(file->fa.flags != 0) { - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags != 0) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], (int)type, (size_t)size); - } /* end if */ + } - if(file->fa.flags & H5FD_LOG_ALLOC) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", addr, (addr + size) - 1, size, flavors[type]); - } /* end if */ + if (file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, + "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", addr, + (haddr_t)((addr + size) - 1), size, flavors[type]); + } /* Set return value */ ret_value = addr; @@ -963,7 +977,6 @@ H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hs FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_free * @@ -977,30 +990,29 @@ H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hs *------------------------------------------------------------------------- */ static herr_t -H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, hsize_t size) +H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Reset the flavor of the information in the file */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the file memory freed */ - if(file->fa.flags & H5FD_LOG_FREE) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", addr, (addr + size) - 1, size, flavors[type]); - } /* end if */ + if (file->fa.flags & H5FD_LOG_FREE) + HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", + addr, (haddr_t)((addr + size) - 1), size, flavors[type]); + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_free() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_get_eoa * @@ -1019,14 +1031,13 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, static haddr_t H5FD__log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__log_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_set_eoa * @@ -1044,50 +1055,53 @@ H5FD__log_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR - if(file->fa.flags != 0) { + if (file->fa.flags != 0) { /* Check for increasing file size */ - if(H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + if (H5F_addr_gt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { hsize_t size = addr - file->eoa; /* Retain the flavor of the space allocated by the extension */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); - } /* end if */ + } /* Log the extension like an allocation */ - if(file->fa.flags & H5FD_LOG_ALLOC) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); - } /* end if */ + if (file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, + "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", + file->eoa, addr, size, flavors[type]); + } /* Check for decreasing file size */ - if(H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { + if (H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { hsize_t size = file->eoa - addr; /* Reset the flavor of the space freed by the shrink */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { + if (file->fa.flags & H5FD_LOG_FLAVOR) { HDassert((addr + size) < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the shrink like a free */ - if(file->fa.flags & H5FD_LOG_FREE) - HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Freed\n", file->eoa, addr, size, flavors[type]); - } /* end if */ - } /* end if */ + if (file->fa.flags & H5FD_LOG_FREE) + HDfprintf(file->logfp, + "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", + file->eoa, addr, size, flavors[type]); + } + } file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_get_eof * @@ -1108,14 +1122,13 @@ H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) static haddr_t H5FD__log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__log_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_get_handle * @@ -1131,12 +1144,12 @@ H5FD__log_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_log_t *file = (H5FD_log_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -1145,7 +1158,6 @@ H5FD__log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handl FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_read * @@ -1163,105 +1175,107 @@ H5FD__log_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handl *------------------------------------------------------------------------- */ 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_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; - 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 */ - H5_timevals_t read_times; /* Elapsed time for read operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5_timevals_t read_times; /* Elapsed time for read operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&read_timer); + /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) /* Log the I/O information about the read */ - if(file->fa.flags != 0) { - size_t tmp_size = size; + if (file->fa.flags != 0) { + size_t tmp_size = size; haddr_t tmp_addr = addr; /* Log information about the number of times these locations are read */ - if(file->fa.flags & H5FD_LOG_FILE_READ) { + if (file->fa.flags & H5FD_LOG_FILE_READ) { HDassert((addr + size) < file->iosize); - while(tmp_size-- > 0) + while (tmp_size-- > 0) file->nread[tmp_addr++]++; - } /* end if */ - } /* end if */ + } + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ - if(addr != file->pos || OP_READ != file->op) { + if (addr != file->pos || OP_READ != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* Stop timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_stop(&seek_timer); /* Add to the number of seeks, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; /* Add to the total seek time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ - if(file->fa.flags & H5FD_LOG_LOC_SEEK) { - HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); + if (file->fa.flags & H5FD_LOG_LOC_SEEK) { + HDfprintf(file->logfp, "Seek: From %10" PRIuHADDR " To %10" PRIuHADDR, file->pos, addr); /* Add the seek time, if we're tracking that. * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ + else + HDfprintf(file->logfp, "\n"); + } + } #endif /* H5_HAVE_PREADWRITE */ /* Start timer for read operation */ - if(file->fa.flags & H5FD_LOG_TIME_READ) { - H5_timer_init(&read_timer); + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_start(&read_timer); - } /* end if */ /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -1269,30 +1283,37 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else - bytes_read = HDread(file->fd, buf, bytes_in); + bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - if(file->fa.flags & H5FD_LOG_LOC_READ) - HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); - } /* end if */ + if (file->fa.flags & H5FD_LOG_LOC_READ) + HDfprintf(file->logfp, "Error! Reading: %10" PRIuHADDR "-%10" PRIuHADDR " (%10zu bytes)\n", + orig_addr, (orig_addr + orig_size) - 1, orig_size); + + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, " + "bytes actually read = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_read, (unsigned long long)offset); + } - if(0 == bytes_read) { - /* end of file but not end of format address space */ + if (0 == bytes_read) { + /* End of file but not end of format address space */ HDmemset(buf, 0, size); break; - } /* end if */ + } HDassert(bytes_read >= 0); HDassert((size_t)bytes_read <= size); @@ -1300,58 +1321,60 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had size -= (size_t)bytes_read; addr += (haddr_t)bytes_read; buf = (char *)buf + bytes_read; - - } /* end while */ + } /* Stop timer for read operation */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_stop(&read_timer); /* Add to the number of reads, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_READ) + if (file->fa.flags & H5FD_LOG_NUM_READ) file->total_read_ops++; /* Add to the total read time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_READ) { + if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_get_times(read_timer, &read_times); file->total_read_time += read_times.elapsed; - } /* end if */ + } /* Log information about the read */ - if(file->fa.flags & H5FD_LOG_LOC_READ) { - HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Read", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); + if (file->fa.flags & H5FD_LOG_LOC_READ) { + HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10zu bytes) (%s) Read", orig_addr, + (orig_addr + orig_size) - 1, orig_size, flavors[type]); /* Verify that we are reading in the type of data we allocated in this location */ - if(file->flavor) { - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[orig_addr] || (H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT); - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + if (file->flavor) { + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[orig_addr] || + (H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT); + HDassert(type == H5FD_MEM_DEFAULT || + type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || + (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); + } /* Add the read time, if we're tracking that. * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_READ) + if (file->fa.flags & H5FD_LOG_TIME_READ) HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; - } /* end if */ + file->op = OP_UNKNOWN; + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_write * @@ -1367,20 +1390,16 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had *------------------------------------------------------------------------- */ 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_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; - 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 */ - H5_timevals_t write_times; /* Elapsed time for write operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5_timevals_t write_times; /* Elapsed time for write operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1388,89 +1407,98 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDassert(size > 0); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&write_timer); + /* Verify that we are writing out the type of data we allocated in this location */ - if(file->flavor) { - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); - HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + if (file->flavor) { + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || + (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); + HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || + (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); + } /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) + if (REGION_OVERFLOW(addr, size)) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", + (unsigned long long)addr, (unsigned long long)size) /* Log the I/O information about the write */ - if(file->fa.flags & H5FD_LOG_FILE_WRITE) { - size_t tmp_size = size; + if (file->fa.flags & H5FD_LOG_FILE_WRITE) { + size_t tmp_size = size; haddr_t tmp_addr = addr; /* Log information about the number of times these locations are read */ HDassert((addr + size) < file->iosize); - while(tmp_size-- > 0) + while (tmp_size-- > 0) file->nwrite[tmp_addr++]++; - } /* end if */ + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if(addr != file->pos || OP_WRITE != file->op) { + if (addr != file->pos || OP_WRITE != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* Stop timer for seek() call */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_stop(&seek_timer); /* Add to the number of seeks, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_SEEK) + if (file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; /* Add to the total seek time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ - if(file->fa.flags & H5FD_LOG_LOC_SEEK) { - HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); + if (file->fa.flags & H5FD_LOG_LOC_SEEK) { + HDfprintf(file->logfp, "Seek: From %10" PRIuHADDR " To %10" PRIuHADDR, file->pos, addr); /* Add the seek time, if we're tracking that. * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_SEEK) + if (file->fa.flags & H5FD_LOG_TIME_SEEK) HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ + else + HDfprintf(file->logfp, "\n"); + } + } #endif /* H5_HAVE_PREADWRITE */ /* Start timer for write operation */ - if(file->fa.flags&H5FD_LOG_TIME_WRITE) { - H5_timer_init(&write_timer); + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_start(&write_timer); - } /* end if */ /* * Write the data, being careful of interrupted system calls and partial * results */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -1478,23 +1506,30 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - if(file->fa.flags & H5FD_LOG_LOC_WRITE) - HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + if (file->fa.flags & H5FD_LOG_LOC_WRITE) + HDfprintf(file->logfp, "Error! Writing: %10" PRIuHADDR "-%10" PRIuHADDR " (%10zu bytes)\n", + orig_addr, (orig_addr + orig_size) - 1, orig_size); + + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = " + "%llu, bytes actually written = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -1506,58 +1541,59 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha } /* end while */ /* Stop timer for write operation */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_stop(&write_timer); /* Add to the number of writes, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_WRITE) + if (file->fa.flags & H5FD_LOG_NUM_WRITE) file->total_write_ops++; /* Add to the total write time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) { + if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_get_times(write_timer, &write_times); file->total_write_time += write_times.elapsed; - } /* end if */ + } /* Log information about the write */ - if(file->fa.flags & H5FD_LOG_LOC_WRITE) { - HDfprintf(file->logfp, "%10a-%10a (%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 algorithm */ - if(file->fa.flags & H5FD_LOG_FLAVOR) { - if((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { + if (file->fa.flags & H5FD_LOG_LOC_WRITE) { + 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 + * algorithm */ + if (file->fa.flags & H5FD_LOG_FLAVOR) { + if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { HDmemset(&file->flavor[orig_addr], (int)type, orig_size); HDfprintf(file->logfp, " (fresh)"); - } /* end if */ - } /* end if */ + } + } /* Add the write time, if we're tracking that. * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_WRITE) + if (file->fa.flags & H5FD_LOG_TIME_WRITE) HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); - } /* end if */ + else + HDfprintf(file->logfp, "\n"); + } /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if(file->pos > file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; - } /* end if */ + file->op = OP_UNKNOWN; + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_truncate * @@ -1574,98 +1610,98 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha static herr_t H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_log_t *file = (H5FD_log_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eoa, file->eof)) { - H5_timer_t trunc_timer; /* Timer for truncate operation */ - H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + if (!H5F_addr_eq(file->eoa, file->eof)) { + H5_timer_t trunc_timer; /* Timer for truncate operation */ + H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + + /* Initialize timer */ + H5_timer_init(&trunc_timer); /* Start timer for truncate operation */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { - H5_timer_init(&trunc_timer); + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_start(&trunc_timer); - } /* end if */ #ifdef H5_HAVE_WIN32_API -{ - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + { + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() * Only used as an error code here. */ - /* Windows uses this odd QuadPart union for 32/64-bit portability */ - li.QuadPart = (__int64)file->eoa; + /* Windows uses this odd QuadPart union for 32/64-bit portability */ + li.QuadPart = (__int64)file->eoa; - /* Extend the file to make sure it's large enough. - * - * Since INVALID_SET_FILE_POINTER can technically be a valid return value - * from SetFilePointer(), we also need to check GetLastError(). - */ - dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { - DWORD dwError; /* DWORD error code from GetLastError() */ + /* Extend the file to make sure it's large enough. + * + * Since INVALID_SET_FILE_POINTER can technically be a valid return value + * from SetFilePointer(), we also need to check GetLastError(). + */ + dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); + if (INVALID_SET_FILE_POINTER == dwPtrLow) { + DWORD dwError; /* DWORD error code from GetLastError() */ - dwError = GetLastError(); - if(dwError != NO_ERROR ) - HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } /* end if */ + dwError = GetLastError(); + if (dwError != NO_ERROR) + HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") + } - if(0 == SetEndOfFile(file->hFile)) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -} -#else /* H5_HAVE_WIN32_API */ + if (0 == SetEndOfFile(file->hFile)) + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") + } +#else /* H5_HAVE_WIN32_API */ /* Truncate/extend the file */ - if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ /* Stop timer for truncate operation */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_stop(&trunc_timer); /* Add to the number of truncates, when tracking that */ - if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + if (file->fa.flags & H5FD_LOG_NUM_TRUNCATE) file->total_truncate_ops++; /* Add to the total truncate time, when tracking that */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_get_times(trunc_timer, &trunc_times); file->total_truncate_time += trunc_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual truncate events. */ - if(file->fa.flags & H5FD_LOG_TRUNCATE) { - HDfprintf(file->logfp, "Truncate: To %10a", file->eoa); + if (file->fa.flags & H5FD_LOG_TRUNCATE) { + HDfprintf(file->logfp, "Truncate: To %10" PRIuHADDR, file->eoa); /* Add the truncate time, if we're tracking that. * Note that the truncate time is NOT emitted for when just H5FD_LOG_TIME_TRUNCATE * is set. */ - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); - else - HDfprintf(file->logfp, "\n"); - } /* end if */ + else + HDfprintf(file->logfp, "\n"); + } /* Update the eof value */ file->eof = file->eoa; /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_lock * @@ -1681,9 +1717,9 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ static herr_t H5FD__log_lock(H5FD_t *_file, hbool_t rw) { - H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1694,8 +1730,8 @@ H5FD__log_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1709,7 +1745,6 @@ H5FD__log_lock(H5FD_t *_file, hbool_t rw) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD__log_unlock * @@ -1724,15 +1759,15 @@ H5FD__log_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__log_unlock(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, LOCK_UN) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1745,4 +1780,3 @@ H5FD__log_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_unlock() */ - diff --git a/src/H5FDlog.h b/src/H5FDlog.h index db51f3da47a..969c09131cc 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,48 +20,455 @@ #ifndef H5FDlog_H #define H5FDlog_H -#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG (H5FD_log_init()) /* Flags for H5Pset_fapl_log() */ /* Flags for tracking 'meta' operations (truncate) */ -#define H5FD_LOG_TRUNCATE 0x00000001 -#define H5FD_LOG_META_IO (H5FD_LOG_TRUNCATE) +#define H5FD_LOG_TRUNCATE 0x00000001 +#define H5FD_LOG_META_IO (H5FD_LOG_TRUNCATE) /* Flags for tracking where reads/writes/seeks occur */ -#define H5FD_LOG_LOC_READ 0x00000002 -#define H5FD_LOG_LOC_WRITE 0x00000004 -#define H5FD_LOG_LOC_SEEK 0x00000008 -#define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK) +#define H5FD_LOG_LOC_READ 0x00000002 +#define H5FD_LOG_LOC_WRITE 0x00000004 +#define H5FD_LOG_LOC_SEEK 0x00000008 +#define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ | H5FD_LOG_LOC_WRITE | H5FD_LOG_LOC_SEEK) /* Flags for tracking number of times each byte is read/written */ #define H5FD_LOG_FILE_READ 0x00000010 #define H5FD_LOG_FILE_WRITE 0x00000020 -#define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE) +#define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ | H5FD_LOG_FILE_WRITE) /* Flag for tracking "flavor" (type) of information stored at each byte */ -#define H5FD_LOG_FLAVOR 0x00000040 +#define H5FD_LOG_FLAVOR 0x00000040 /* Flags for tracking total number of reads/writes/seeks/truncates */ -#define H5FD_LOG_NUM_READ 0x00000080 -#define H5FD_LOG_NUM_WRITE 0x00000100 -#define H5FD_LOG_NUM_SEEK 0x00000200 +#define H5FD_LOG_NUM_READ 0x00000080 +#define H5FD_LOG_NUM_WRITE 0x00000100 +#define H5FD_LOG_NUM_SEEK 0x00000200 #define H5FD_LOG_NUM_TRUNCATE 0x00000400 -#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK|H5FD_LOG_NUM_TRUNCATE) +#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ | H5FD_LOG_NUM_WRITE | H5FD_LOG_NUM_SEEK | H5FD_LOG_NUM_TRUNCATE) /* Flags for tracking time spent in open/stat/read/write/seek/truncate/close */ -#define H5FD_LOG_TIME_OPEN 0x00000800 -#define H5FD_LOG_TIME_STAT 0x00001000 -#define H5FD_LOG_TIME_READ 0x00002000 -#define H5FD_LOG_TIME_WRITE 0x00004000 -#define H5FD_LOG_TIME_SEEK 0x00008000 +#define H5FD_LOG_TIME_OPEN 0x00000800 +#define H5FD_LOG_TIME_STAT 0x00001000 +#define H5FD_LOG_TIME_READ 0x00002000 +#define H5FD_LOG_TIME_WRITE 0x00004000 +#define H5FD_LOG_TIME_SEEK 0x00008000 #define H5FD_LOG_TIME_TRUNCATE 0x00010000 -#define H5FD_LOG_TIME_CLOSE 0x00020000 -#define H5FD_LOG_TIME_IO (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_STAT|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_TRUNCATE|H5FD_LOG_TIME_CLOSE) +#define H5FD_LOG_TIME_CLOSE 0x00020000 +#define H5FD_LOG_TIME_IO \ + (H5FD_LOG_TIME_OPEN | H5FD_LOG_TIME_STAT | H5FD_LOG_TIME_READ | H5FD_LOG_TIME_WRITE | \ + H5FD_LOG_TIME_SEEK | H5FD_LOG_TIME_TRUNCATE | H5FD_LOG_TIME_CLOSE) /* Flags for tracking allocation/release of space in file */ -#define H5FD_LOG_ALLOC 0x00040000 -#define H5FD_LOG_FREE 0x00080000 -#define H5FD_LOG_ALL (H5FD_LOG_FREE|H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO|H5FD_LOG_META_IO) +#define H5FD_LOG_ALLOC 0x00040000 +#define H5FD_LOG_FREE 0x00080000 +#define H5FD_LOG_ALL \ + (H5FD_LOG_FREE | H5FD_LOG_ALLOC | H5FD_LOG_TIME_IO | H5FD_LOG_NUM_IO | H5FD_LOG_FLAVOR | \ + H5FD_LOG_FILE_IO | H5FD_LOG_LOC_IO | H5FD_LOG_META_IO) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_log_init(void); + +/** + * \ingroup FAPL + * + * \brief Sets up the logging virtual file driver (#H5FD_LOG) for use + * + * \fapl_id + * \param[in] logfile Name of the log file + * \param[in] flags Flags specifying the types of logging activity + * \param[in] buf_size The size of the logging buffers, in bytes (see description) + * \returns \herr_t + * + * \details H5Pset_fapl_log() modifies the file access property list to use the + * logging driver, #H5FD_LOG. The logging virtual file driver (VFD) is + * a clone of the standard SEC2 (#H5FD_SEC2) driver with additional + * facilities for logging VFD metrics and activity to a file. + * + * \p logfile is the name of the file in which the logging entries are + * to be recorded. + * + * The actions to be logged are specified in the parameter \p flags + * using the pre-defined constants described in the following + * table. Multiple flags can be set through the use of a logical \c OR + * contained in parentheses. For example, logging read and write + * locations would be specified as + * \Code{(H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE)}. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Table1: Logging Flags
+ * #H5FD_LOG_LOC_READ + * + * Track the location and length of every read, write, or seek operation. + *
#H5FD_LOG_LOC_WRITE
#H5FD_LOG_LOC_SEEK
+ * #H5FD_LOG_LOC_IO + * + * Track all I/O locations and lengths. The logical equivalent of the following: + * \Code{(#H5FD_LOG_LOC_READ | #H5FD_LOG_LOC_WRITE | #H5FD_LOG_LOC_SEEK)} + *
+ * #H5FD_LOG_FILE_READ + * + * Track the number of times each byte is read or written. + *
#H5FD_LOG_FILE_WRITE
+ * #H5FD_LOG_FILE_IO + * + * Track the number of times each byte is read and written. The logical + * equivalent of the following: + * \Code{(#H5FD_LOG_FILE_READ | #H5FD_LOG_FILE_WRITE)} + *
+ * #H5FD_LOG_FLAVOR + * + * Track the type, or flavor, of information stored at each byte. + *
+ * #H5FD_LOG_NUM_READ + * + * Track the total number of read, write, seek, or truncate operations that occur. + *
#H5FD_LOG_NUM_WRITE
#H5FD_LOG_NUM_SEEK
#H5FD_LOG_NUM_TRUNCATE
+ * #H5FD_LOG_NUM_IO + * + * Track the total number of all types of I/O operations. The logical equivalent + * of the following: + * \Code{(#H5FD_LOG_NUM_READ | #H5FD_LOG_NUM_WRITE | #H5FD_LOG_NUM_SEEK | #H5FD_LOG_NUM_TRUNCATE)} + *
+ * #H5FD_LOG_TIME_OPEN + * + * Track the time spent in open, stat, read, write, seek, or close operations. + *
#H5FD_LOG_TIME_STAT
#H5FD_LOG_TIME_READ
#H5FD_LOG_TIME_WRITE
#H5FD_LOG_TIME_SEEK
#H5FD_LOG_TIME_CLOSE
+ * #H5FD_LOG_TIME_IO + * + * Track the time spent in each of the above operations. The logical equivalent + * of the following: + * \Code{(#H5FD_LOG_TIME_OPEN | #H5FD_LOG_TIME_STAT | #H5FD_LOG_TIME_READ | #H5FD_LOG_TIME_WRITE | + * #H5FD_LOG_TIME_SEEK | #H5FD_LOG_TIME_CLOSE)} + *
+ * #H5FD_LOG_ALLOC + * + * Track the allocation of space in the file. + *
+ * #H5FD_LOG_ALL + * + * Track everything. The logical equivalent of the following: + * \Code{(#H5FD_LOG_ALLOC | #H5FD_LOG_TIME_IO | #H5FD_LOG_NUM_IO | #H5FD_LOG_FLAVOR | #H5FD_LOG_FILE_IO | + * #H5FD_LOG_LOC_IO)} + *
+ * The logging driver can track the number of times each byte in the file is + * read from or written to (using #H5FD_LOG_FILE_READ and #H5FD_LOG_FILE_WRITE) + * and what kind of data is at that location (e.g., metadata, raw data; using + * #H5FD_LOG_FLAVOR). This information is tracked in internal buffers of size + * buf_size, which must be at least the maximum size in bytes of the file to be + * logged while the log driver is in use.\n + * One buffer of size buf_size will be created for each of #H5FD_LOG_FILE_READ, + * #H5FD_LOG_FILE_WRITE and #H5FD_LOG_FLAVOR when those flags are set; these + * buffers will not grow as the file increases in size. + * + * \par Output: + * This section describes the logging driver (LOG VFD) output.\n + * The table, immediately below, describes output of the various logging driver + * flags and function calls. A list of valid flavor values, describing the type + * of data stored, follows the table. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Table2: Logging Output
FlagVFD CallOutput and Comments
#H5FD_LOG_LOC_READRead + * \Code{%10a-%10a (%10Zu bytes) (%s) Read}\n\n + * Start position\n + * End position\n + * Number of bytes\n + * Flavor of read\n\n + * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set. + *
#H5FD_LOG_LOC_READRead Error + * \Code{Error! Reading: %10a-%10a (%10Zu bytes)}\n\n + * Same parameters as non-error entry. + *
#H5FD_LOG_LOC_WRITEWrite + * \Code{%10a-%10a (%10Zu bytes) (%s) Written}\n\n + * Start position\n + * End position\n + * Number of bytes\n + * Flavor of write\n\n + * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set. + *
#H5FD_LOG_LOC_WRITEWrite Error + * \Code{Error! Writing: %10a-%10a (%10Zu bytes)}\n\n + * Same parameters as non-error entry. + *
#H5FD_LOG_LOC_SEEKRead, Write + * \Code{Seek: From %10a-%10a}\n\n + * Start position\n + * End position\n\n + * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set. + *
#H5FD_LOG_FILE_READClose + * Begins with:\n + * Dumping read I/O information\n\n + * Then, for each range of identical values, there is this line:\n + * \Code{Addr %10-%10 (%10lu bytes) read from %3d times}\n\n + * Start address\n + * End address\n + * Number of bytes\n + * Number of times read\n\n + * Note: The data buffer is scanned and each range of identical values + * gets one entry in the log file to save space and make it easier to read. + *
#H5FD_LOG_FILE_WRITEClose + * Begins with:\n + * Dumping read I/O information\n\n + * Then, for each range of identical values, there is this line:\n + * \Code{Addr %10-%10 (%10lu bytes) written to %3d times}\n\n + * Start address\n + * End address\n + * Number of bytes\n + * Number of times written\n\n + * Note: The data buffer is scanned and each range of identical values + * gets one entry in the log file to save space and make it easier to read. + *
#H5FD_LOG_FLAVORClose + * Begins with:\n + * Dumping I/O flavor information\n\n + * Then, for each range of identical values, there is this line:\n + * \Code{Addr %10-%10 (%10lu bytes) flavor is %s}\n\n + * Start address\n + * End address\n + * Number of bytes\n + * Flavor\n\n + * Note: The data buffer is scanned and each range of identical values + * gets one entry in the log file to save space and make it easier to read. + *
#H5FD_LOG_NUM_READClose + * Total number of read operations: \Code{%11u} + *
#H5FD_LOG_NUM_WRITEClose + * Total number of write operations: \Code{%11u} + *
#H5FD_LOG_NUM_SEEKClose + * Total number of seek operations: \Code{%11u} + *
#H5FD_LOG_NUM_TRUNCATEClose + * Total number of truncate operations: \Code{%11u} + *
#H5FD_LOG_TIME_OPENOpen + * Open took: \Code{(\%f s)} + *
#H5FD_LOG_TIME_READClose, Read + * Total time in read operations: \Code{\%f s}\n\n + * See also: #H5FD_LOG_LOC_READ + *
#H5FD_LOG_TIME_WRITEClose, Write + * Total time in write operations: \Code{\%f s}\n\n + * See also: #H5FD_LOG_LOC_WRITE + *
#H5FD_LOG_TIME_SEEKClose, Read, Write + * Total time in write operations: \Code{\%f s}\n\n + * See also: #H5FD_LOG_LOC_SEEK or #H5FD_LOG_LOC_WRITE + *
#H5FD_LOG_TIME_CLOSEClose + * Close took: \Code{(\%f s)} + *
#H5FD_LOG_TIME_STATOpen + * Stat took: \Code{(\%f s)} + *
#H5FD_LOG_ALLOCAlloc + * \Code{%10-%10 (%10Hu bytes) (\%s) Allocated}\n\n + * Start of address space\n + * End of address space\n + * Total size allocation\n + * Flavor of allocation + *
+ * + * \par Flavors: + * The \Emph{flavor} describes the type of stored information. The following + * table lists the flavors that appear in log output and briefly describes each. + * These terms are provided here to aid in the construction of log message + * parsers; a full description is beyond the scope of this document. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Table3: Flavors of logged data
FlavorDescription
#H5FD_MEM_NOLISTError value
#H5FD_MEM_DEFAULTValue not yet set.\n + * May also be a datatype set in a larger allocation that will be + * suballocated by the library.
#H5FD_MEM_SUPERSuperblock data
#H5FD_MEM_BTREEB-tree data
#H5FD_MEM_DRAWRaw data (for example, contents of a dataset)
#H5FD_MEM_GHEAPGlobal heap data
#H5FD_MEM_LHEAPLocal heap data
#H5FD_MEM_OHDRObject header data
+ * + * \version 1.8.7 The flags parameter has been changed from \Code{unsigned int} + * to \Code{unsigned long long}. + * The implementation of the #H5FD_LOG_TIME_OPEN, #H5FD_LOG_TIME_READ, + * #H5FD_LOG_TIME_WRITE, and #H5FD_LOG_TIME_SEEK flags has been finished. + * New flags were added: #H5FD_LOG_NUM_TRUNCATE and #H5FD_LOG_TIME_STAT. + * \version 1.6.0 The \c verbosity parameter has been removed. + * Two new parameters have been added: \p flags of type \Code{unsigned} and + * \p buf_size of type \Code{size_t}. + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size); #ifdef __cplusplus @@ -69,4 +476,3 @@ H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long #endif #endif - diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 6bee4a7f145..f604eaf6dd3 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,19 +17,19 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_MIRROR_VFD -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmirror.h" /* "Mirror" definitions */ -#include "H5FDmirror_priv.h" /* Private header for the mirror VFD */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmirror.h" /* "Mirror" definitions */ +#include "H5FDmirror_priv.h" /* Private header for the mirror VFD */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_MIRROR_g = 0; @@ -60,145 +60,138 @@ typedef struct H5FD_mirror_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) #ifndef BSWAP_64 -#define BSWAP_64(X) \ - (uint64_t)( (((X) & 0x00000000000000FF) << 56) \ - | (((X) & 0x000000000000FF00) << 40) \ - | (((X) & 0x0000000000FF0000) << 24) \ - | (((X) & 0x00000000FF000000) << 8) \ - | (((X) & 0x000000FF00000000) >> 8) \ - | (((X) & 0x0000FF0000000000) >> 24) \ - | (((X) & 0x00FF000000000000) >> 40) \ - | (((X) & 0xFF00000000000000) >> 56)) +#define BSWAP_64(X) \ + (uint64_t)((((X)&0x00000000000000FF) << 56) | (((X)&0x000000000000FF00) << 40) | \ + (((X)&0x0000000000FF0000) << 24) | (((X)&0x00000000FF000000) << 8) | \ + (((X)&0x000000FF00000000) >> 8) | (((X)&0x0000FF0000000000) >> 24) | \ + (((X)&0x00FF000000000000) >> 40) | (((X)&0xFF00000000000000) >> 56)) #endif /* BSWAP_64 */ /* Debugging flabs for verbose tracing -- nonzero to enable */ -#define MIRROR_DEBUG_OP_CALLS 0 +#define MIRROR_DEBUG_OP_CALLS 0 #define MIRROR_DEBUG_XMIT_BYTES 0 #if MIRROR_DEBUG_XMIT_BYTES -#define LOG_XMIT_BYTES(label, buf, len) do { \ - ssize_t bytes_written = 0; \ - const unsigned char *b = NULL; \ - \ - HDfprintf(stdout, "%s bytes:\n```\n", (label)); \ - \ - /* print whole lines */ \ - while ((len - bytes_written) >= 32) { \ - b = (const unsigned char *)(buf) + bytes_written; \ - HDfprintf(stdout, \ - "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X" \ - " %02X%02X%02X%02X %02X%02X%02X%02X\n", \ - bytes_written, \ - b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], \ - b[8], b[9], b[10],b[11], b[12],b[13],b[14],b[15], \ - b[16],b[17],b[18],b[19], b[20],b[21],b[22],b[23], \ - b[24],b[25],b[26],b[27], b[28],b[29],b[30],b[31]); \ - bytes_written += 32; \ - } \ - \ - /* start partial line */ \ - if (len > bytes_written) { \ - HDfprintf(stdout, "%04zX ", bytes_written); \ - } \ - \ - /* partial line blocks */ \ - while ((len - bytes_written) >= 4) { \ - HDfprintf(stdout, " %02X%02X%02X%02X", \ - (buf)[bytes_written], (buf)[bytes_written+1], \ - (buf)[bytes_written+2], (buf)[bytes_written+3]); \ - bytes_written += 4; \ - } \ - \ - /* block separator before partial block */ \ - if (len > bytes_written) { \ - HDfprintf(stdout, " "); \ - } \ - \ - /* partial block individual bytes */ \ - while (len > bytes_written) { \ - HDfprintf(stdout, "%02X", (buf)[bytes_written++]); \ - } \ - \ - /* end partial line */ \ - HDfprintf(stdout, "\n"); \ - HDfprintf(stdout, "```\n"); \ - HDfflush(stdout); \ -} while (0) +#define LOG_XMIT_BYTES(label, buf, len) \ + do { \ + ssize_t bytes_written = 0; \ + const unsigned char *b = NULL; \ + \ + HDfprintf(stdout, "%s bytes:\n```\n", (label)); \ + \ + /* print whole lines */ \ + while ((len - bytes_written) >= 32) { \ + b = (const unsigned char *)(buf) + bytes_written; \ + HDfprintf(stdout, \ + "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X\n", \ + bytes_written, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], \ + b[11], b[12], b[13], b[14], b[15], b[16], b[17], b[18], b[19], b[20], b[21], b[22], \ + b[23], b[24], b[25], b[26], b[27], b[28], b[29], b[30], b[31]); \ + bytes_written += 32; \ + } \ + \ + /* start partial line */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, "%04zX ", bytes_written); \ + } \ + \ + /* partial line blocks */ \ + while ((len - bytes_written) >= 4) { \ + HDfprintf(stdout, " %02X%02X%02X%02X", (buf)[bytes_written], (buf)[bytes_written + 1], \ + (buf)[bytes_written + 2], (buf)[bytes_written + 3]); \ + bytes_written += 4; \ + } \ + \ + /* block separator before partial block */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, " "); \ + } \ + \ + /* partial block individual bytes */ \ + while (len > bytes_written) { \ + HDfprintf(stdout, "%02X", (buf)[bytes_written++]); \ + } \ + \ + /* end partial line */ \ + HDfprintf(stdout, "\n"); \ + HDfprintf(stdout, "```\n"); \ + HDfflush(stdout); \ + } while (0) #else #define LOG_XMIT_BYTES(label, buf, len) /* no-op */ -#endif /* MIRROR_DEBUG_XMIT_BYTE */ +#endif /* MIRROR_DEBUG_XMIT_BYTE */ #if MIRROR_DEBUG_OP_CALLS -#define LOG_OP_CALL(name) do { \ - HDprintf("called %s()\n", (name)); \ - HDfflush(stdout); \ -} while (0) +#define LOG_OP_CALL(name) \ + do { \ + HDprintf("called %s()\n", (name)); \ + HDfflush(stdout); \ + } while (0) #else #define LOG_OP_CALL(name) /* no-op */ -#endif /* MIRROR_DEBUG_OP_CALLS */ +#endif /* MIRROR_DEBUG_OP_CALLS */ /* 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 herr_t H5FD__mirror_fapl_free(void *_fa); +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 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); +static herr_t H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static H5FD_t *H5FD__mirror_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD__mirror_close(H5FD_t *_file); -static herr_t H5FD__mirror_query(const H5FD_t *_file, unsigned long *flags); -static herr_t H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD__mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD__mirror_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); -static herr_t H5FD__mirror_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__mirror_unlock(H5FD_t *_file); +static H5FD_t *H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__mirror_close(H5FD_t *_file); +static herr_t H5FD__mirror_query(const H5FD_t *_file, unsigned long *flags); +static herr_t H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__mirror_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__mirror_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__mirror_unlock(H5FD_t *_file); static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file); static const H5FD_class_t H5FD_mirror_g = { - "mirror", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__mirror_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - H5FD__mirror_fapl_get, /* fapl_get */ - H5FD__mirror_fapl_copy, /* fapl_copy */ - H5FD__mirror_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__mirror_open, /* open */ - H5FD__mirror_close, /* close */ - NULL, /* cmp */ - H5FD__mirror_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__mirror_get_eoa, /* get_eoa */ - H5FD__mirror_set_eoa, /* set_eoa */ - H5FD__mirror_get_eof, /* get_eof */ - NULL, /* get_handle */ - H5FD__mirror_read, /* read */ - H5FD__mirror_write, /* write */ - NULL, /* flush */ - H5FD__mirror_truncate, /* truncate */ - H5FD__mirror_lock, /* lock */ - H5FD__mirror_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "mirror", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__mirror_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + H5FD__mirror_fapl_get, /* fapl_get */ + H5FD__mirror_fapl_copy, /* fapl_copy */ + H5FD__mirror_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__mirror_open, /* open */ + H5FD__mirror_close, /* close */ + NULL, /* cmp */ + H5FD__mirror_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__mirror_get_eoa, /* get_eoa */ + H5FD__mirror_set_eoa, /* set_eoa */ + H5FD__mirror_get_eof, /* get_eof */ + NULL, /* get_handle */ + H5FD__mirror_read, /* read */ + H5FD__mirror_write, /* write */ + NULL, /* flush */ + H5FD__mirror_truncate, /* truncate */ + H5FD__mirror_lock, /* lock */ + H5FD__mirror_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the transmission buffers */ @@ -210,7 +203,6 @@ H5FL_DEFINE_STATIC(H5FD_mirror_t); /* Declare a free list to manage the H5FD_mirror_xmit_open_t struct */ H5FL_DEFINE_STATIC(H5FD_mirror_xmit_open_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -228,14 +220,13 @@ H5FD__init_package(void) LOG_OP_CALL(FUNC); - if(H5FD_mirror_init() < 0) + if (H5FD_mirror_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mirror VFD"); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_init * @@ -251,11 +242,11 @@ H5FD_mirror_init(void) { hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) 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); ret_value = H5FD_MIRROR_g; @@ -264,7 +255,6 @@ H5FD_mirror_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mirror_init() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_term * @@ -286,7 +276,6 @@ H5FD__mirror_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mirror_term() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint16 * @@ -309,13 +298,12 @@ H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf) HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); + H5MM_memcpy(&n, _buf, sizeof(n)); *out = (uint16_t)HDntohs(n); return 2; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint16() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint32 * @@ -338,13 +326,12 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); + H5MM_memcpy(&n, _buf, sizeof(n)); *out = (uint32_t)HDntohl(n); return 4; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint32() */ - /* --------------------------------------------------------------------------- * Function: is_host_little_endian * @@ -368,13 +355,12 @@ is_host_little_endian(void) } echeck; echeck.u32 = 0xA1B2C3D4; - if(echeck.u8[0] == 0xD4) + if (echeck.u8[0] == 0xD4) return TRUE; else return FALSE; } /* end is_host_little_endian() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint64 * @@ -399,8 +385,8 @@ H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) HDassert(_buf && out); - HDmemcpy(&n, _buf, sizeof(n)); - if(TRUE == is_host_little_endian()) + H5MM_memcpy(&n, _buf, sizeof(n)); + if (TRUE == is_host_little_endian()) *out = BSWAP_64(n); else *out = n; @@ -408,7 +394,6 @@ H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) return 8; } /* end H5FD__mirror_xmit_decode_uint64() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_decode_uint8 * @@ -427,12 +412,11 @@ H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *_buf) HDassert(_buf && out); - HDmemcpy(out, _buf, sizeof(uint8_t)); + H5MM_memcpy(out, _buf, sizeof(uint8_t)); return 1; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint8() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint16 * @@ -455,12 +439,11 @@ H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v) HDassert(_dest); n = (uint16_t)HDhtons(v); - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); return 2; } /* end H5FD__mirror_xmit_encode_uint16() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint32 * @@ -483,12 +466,11 @@ H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v) HDassert(_dest); n = (uint32_t)HDhtonl(v); - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); return 4; } /* end H5FD__mirror_xmit_encode_uint32() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint64 * @@ -510,14 +492,13 @@ H5FD__mirror_xmit_encode_uint64(unsigned char *_dest, uint64_t v) HDassert(_dest); - if(TRUE == is_host_little_endian()) + if (TRUE == is_host_little_endian()) n = BSWAP_64(v); - HDmemcpy(_dest, &n, sizeof(n)); + H5MM_memcpy(_dest, &n, sizeof(n)); return 8; } /* H5FD__mirror_xmit_encode_uint64() */ - /* --------------------------------------------------------------------------- * Function: H5FD__mirror_xmit_encode_uint8 * @@ -538,12 +519,11 @@ H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) HDassert(dest); - HDmemcpy(dest, &v, sizeof(v)); + H5MM_memcpy(dest, &v, sizeof(v)); return 1; } /* end H5FD__mirror_xmit_encode_uint8() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_header * @@ -564,8 +544,7 @@ H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -575,17 +554,14 @@ H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->magic), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->version), &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), - &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), - &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->op), &buf[n_eaten]); HDassert(n_eaten == H5FD_MIRROR_XMIT_HEADER_SIZE); return n_eaten; } /* end H5FD_mirror_xmit_decode_header() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_lock * @@ -606,8 +582,7 @@ H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -622,7 +597,6 @@ H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_open * @@ -644,8 +618,7 @@ H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -656,18 +629,14 @@ H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->flags), &buf[n_eaten]); n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->maxaddr), &buf[n_eaten]); - n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size_t_blob), - &buf[n_eaten]); - HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) - == n_eaten); - HDstrncpy(out->filename, (const char *)&buf[n_eaten], - H5FD_MIRROR_XMIT_FILEPATH_MAX - 1); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size_t_blob), &buf[n_eaten]); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_eaten); + HDstrncpy(out->filename, (const char *)&buf[n_eaten], H5FD_MIRROR_XMIT_FILEPATH_MAX - 1); out->filename[H5FD_MIRROR_XMIT_FILEPATH_MAX - 1] = 0; /* force final NULL */ return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_decode_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_reply * @@ -689,8 +658,7 @@ H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -700,16 +668,13 @@ H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->status), &buf[n_eaten]); - HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) - == n_eaten); - HDstrncpy(out->message, (const char *)&buf[n_eaten], - H5FD_MIRROR_STATUS_MESSAGE_MAX - 1); + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_eaten); + HDstrncpy(out->message, (const char *)&buf[n_eaten], H5FD_MIRROR_STATUS_MESSAGE_MAX - 1); out->message[H5FD_MIRROR_STATUS_MESSAGE_MAX - 1] = 0; /* force NULL term */ return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_decode_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_set_eoa * @@ -730,8 +695,7 @@ H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -747,7 +711,6 @@ H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_set_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_decode_write * @@ -768,8 +731,7 @@ H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, - const unsigned char *buf) +H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf) { size_t n_eaten = 0; @@ -786,7 +748,6 @@ H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, return n_eaten; } /* end H5FD_mirror_xmit_decode_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_header * @@ -802,8 +763,7 @@ H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_header(unsigned char *dest, - const H5FD_mirror_xmit_t *x) +H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x) { size_t n_writ = 0; @@ -811,17 +771,16 @@ H5FD_mirror_xmit_encode_header(unsigned char *dest, HDassert(dest && x); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->magic); - n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->version); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->session_token); - n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->xmit_count); - n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->op); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->magic); + n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->version); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->session_token); + n_writ += H5FD__mirror_xmit_encode_uint32((dest + n_writ), x->xmit_count); + n_writ += H5FD__mirror_xmit_encode_uint8((dest + n_writ), x->op); HDassert(n_writ == H5FD_MIRROR_XMIT_HEADER_SIZE); return n_writ; } /* end H5FD_mirror_xmit_encode_header() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_lock * @@ -836,8 +795,7 @@ H5FD_mirror_xmit_encode_header(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_lock(unsigned char *dest, - const H5FD_mirror_xmit_lock_t *x) +H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x) { size_t n_writ = 0; @@ -845,15 +803,13 @@ H5FD_mirror_xmit_encode_lock(unsigned char *dest, HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->rw); HDassert(n_writ == H5FD_MIRROR_XMIT_LOCK_SIZE); return n_writ; } /* end H5FD_mirror_xmit_encode_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_open * @@ -869,8 +825,7 @@ H5FD_mirror_xmit_encode_lock(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_open(unsigned char *dest, - const H5FD_mirror_xmit_open_t *x) +H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x) { size_t n_writ = 0; @@ -881,19 +836,16 @@ H5FD_mirror_xmit_encode_open(unsigned char *dest, /* clear entire structure, but especially its filepath string area */ HDmemset(dest, 0, H5FD_MIRROR_XMIT_OPEN_SIZE); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->flags); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->maxaddr); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size_t_blob); - HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) - == n_writ); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) == n_writ); HDstrncpy((char *)&dest[n_writ], x->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX); return H5FD_MIRROR_XMIT_OPEN_SIZE; } /* end H5FD_mirror_xmit_encode_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_reply * @@ -910,8 +862,7 @@ H5FD_mirror_xmit_encode_open(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_reply(unsigned char *dest, - const H5FD_mirror_xmit_reply_t *x) +H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x) { size_t n_writ = 0; @@ -922,17 +873,14 @@ H5FD_mirror_xmit_encode_reply(unsigned char *dest, /* clear entire structure, but especially its message string area */ HDmemset(dest, 0, H5FD_MIRROR_XMIT_REPLY_SIZE); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->status); - HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) - == n_writ); + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) == n_writ); HDstrncpy((char *)&dest[n_writ], x->message, H5FD_MIRROR_STATUS_MESSAGE_MAX); return H5FD_MIRROR_XMIT_REPLY_SIZE; } /* end H5FD_mirror_xmit_encode_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_set_eoa * @@ -948,8 +896,7 @@ H5FD_mirror_xmit_encode_reply(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, - const H5FD_mirror_xmit_eoa_t *x) +H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x) { size_t n_writ = 0; @@ -957,8 +904,7 @@ H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->eoa_addr); HDassert(n_writ == H5FD_MIRROR_XMIT_EOA_SIZE); @@ -966,7 +912,6 @@ H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, return n_writ; } /* end H5FD_mirror_xmit_encode_set_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_encode_write * @@ -982,8 +927,7 @@ H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, * --------------------------------------------------------------------------- */ size_t -H5FD_mirror_xmit_encode_write(unsigned char *dest, - const H5FD_mirror_xmit_write_t *x) +H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x) { size_t n_writ = 0; @@ -991,8 +935,7 @@ H5FD_mirror_xmit_encode_write(unsigned char *dest, HDassert(dest && x); - n_writ += H5FD_mirror_xmit_encode_header(dest, - (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD_mirror_xmit_encode_header(dest, (const H5FD_mirror_xmit_t *)&(x->pub)); n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->offset); n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size); @@ -1001,7 +944,6 @@ H5FD_mirror_xmit_encode_write(unsigned char *dest, return n_writ; } /* end H5FD_mirror_xmit_encode_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_close * @@ -1019,13 +961,12 @@ H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && (H5FD_MIRROR_OP_CLOSE == xmit->op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && (H5FD_MIRROR_OP_CLOSE == xmit->op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_close() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_lock * @@ -1043,13 +984,12 @@ H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_LOCK == xmit->pub.op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_LOCK == xmit->pub.op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_lock() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_open * @@ -1067,14 +1007,13 @@ H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_OPEN == xmit->pub.op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_OPEN == xmit->pub.op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_open() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_eoa * @@ -1092,13 +1031,12 @@ H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_eoa() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_reply * @@ -1116,13 +1054,12 @@ H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_REPLY == xmit->pub.op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_REPLY == xmit->pub.op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_reply() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_write * @@ -1140,13 +1077,12 @@ H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit) HDassert(xmit); - if((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_WRITE == xmit->pub.op)) + if ((TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && (H5FD_MIRROR_OP_WRITE == xmit->pub.op)) return TRUE; return FALSE; } /* end H5FD_mirror_xmit_is_write() */ - /* --------------------------------------------------------------------------- * Function: H5FD_mirror_xmit_is_xmit * @@ -1164,13 +1100,12 @@ H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) HDassert(xmit); - if((H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version)) + if ((H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version)) return FALSE; return TRUE; } /* end H5FD_mirror_xmit_is_xmit() */ - /* ---------------------------------------------------------------------------- * Function: H5FD__mirror_verify_reply * @@ -1185,10 +1120,10 @@ 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; - struct H5FD_mirror_xmit_reply_t reply; - ssize_t read_ret = 0; - herr_t ret_value = SUCCEED; + 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 @@ -1197,38 +1132,37 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file) HDassert(file && file->sock_fd); xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); read_ret = HDread(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_REPLY_SIZE); - if(read_ret < 0) + if (read_ret < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to read reply"); - if(read_ret != H5FD_MIRROR_XMIT_REPLY_SIZE) + if (read_ret != H5FD_MIRROR_XMIT_REPLY_SIZE) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unexpected read size"); LOG_XMIT_BYTES("reply", xmit_buf, read_ret); - if(H5FD_mirror_xmit_decode_reply(&reply, xmit_buf) != H5FD_MIRROR_XMIT_REPLY_SIZE) + if (H5FD_mirror_xmit_decode_reply(&reply, xmit_buf) != H5FD_MIRROR_XMIT_REPLY_SIZE) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unable to decode reply xmit"); - if(H5FD_mirror_xmit_is_reply(&reply) != TRUE) + if (H5FD_mirror_xmit_is_reply(&reply) != TRUE) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "xmit op code was not REPLY"); - if(reply.pub.session_token != file->xmit.session_token) + if (reply.pub.session_token != file->xmit.session_token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "wrong session"); - if(reply.pub.xmit_count != (file->xmit_i)++) + if (reply.pub.xmit_count != (file->xmit_i)++) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "xmit out of sync"); - if(reply.status != H5FD_MIRROR_STATUS_OK) + if (reply.status != H5FD_MIRROR_STATUS_OK) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "%s", (const char *)(reply.message)); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__mirror_verify_reply() */ - /* ------------------------------------------------------------------------- * Function: H5FD__mirror_fapl_get * @@ -1242,31 +1176,30 @@ 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 LOG_OP_CALL(FUNC); fa = (H5FD_mirror_fapl_t *)H5MM_calloc(sizeof(H5FD_mirror_fapl_t)); - if(NULL == fa) + if (NULL == fa) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "calloc failed"); - HDmemcpy(fa, &(file->fa), sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(fa, &(file->fa), sizeof(H5FD_mirror_fapl_t)); ret_value = fa; done: - if(ret_value == NULL) - if(fa != NULL) + if (ret_value == NULL) + if (fa != NULL) H5MM_xfree(fa); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_fapl_get() */ - /* ------------------------------------------------------------------------- * Function: H5FD__mirror_fapl_copy * @@ -1280,29 +1213,28 @@ 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 LOG_OP_CALL(FUNC); new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t)); - if(new_fa == NULL) + if (new_fa == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed"); - HDmemcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); ret_value = new_fa; done: - if(ret_value == NULL) - if(new_fa != NULL) + if (ret_value == NULL) + if (new_fa != NULL) H5MM_xfree(new_fa); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_fapl_free * @@ -1314,7 +1246,7 @@ H5FD__mirror_fapl_copy(const void *_old_fa) static herr_t H5FD__mirror_fapl_free(void *_fa) { - H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t*)_fa; + H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t *)_fa; FUNC_ENTER_STATIC_NOERR @@ -1330,50 +1262,48 @@ H5FD__mirror_fapl_free(void *_fa) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mirror_fapl_free() */ - /* ------------------------------------------------------------------------- * Function: H5Pget_fapl_mirror * * Purpose: Get the configuration information for this fapl. - * Data is memcopied into the fa_out pointer. + * Data is memcopied into the fa_dst pointer. * * Return: SUCCEED/FAIL * ------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) +H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_dst) { - const H5FD_mirror_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + const H5FD_mirror_fapl_t *fa_src = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", fapl_id, fa_out); + H5TRACE2("e", "i*x", fapl_id, fa_dst); LOG_OP_CALL(FUNC); - if(NULL == fa_out) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL"); + if (NULL == fa_dst) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL"); plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - if(H5P_peek_driver(plist) != H5FD_MIRROR) + if (H5P_peek_driver(plist) != H5FD_MIRROR) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver"); - fa = (const H5FD_mirror_fapl_t *)H5P_peek_driver_info(plist); - if(NULL == fa) + fa_src = (const H5FD_mirror_fapl_t *)H5P_peek_driver_info(plist); + if (NULL == fa_src) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info"); - HDassert(fa->magic == H5FD_MIRROR_FAPL_MAGIC); /* sanity check */ + HDassert(fa_src->magic == H5FD_MIRROR_FAPL_MAGIC); /* sanity check */ - HDmemcpy(fa_out, fa, sizeof(H5FD_mirror_fapl_t)); + H5MM_memcpy(fa_dst, fa_src, sizeof(H5FD_mirror_fapl_t)); done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_fapl_mirror() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mirror * @@ -1386,8 +1316,8 @@ H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) { - H5P_genplist_t *plist = NULL; - herr_t ret_value = FAIL; + H5P_genplist_t *plist = NULL; + herr_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, fa); @@ -1395,13 +1325,13 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) LOG_OP_CALL(FUNC); plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - if(NULL == fa) + if (NULL == fa) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null fapl_t pointer"); - if(H5FD_MIRROR_FAPL_MAGIC != fa->magic) + if (H5FD_MIRROR_FAPL_MAGIC != fa->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fapl_t magic"); - if(H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown fapl_t version"); ret_value = H5P_set_driver(plist, H5FD_MIRROR, (const void *)fa); @@ -1410,7 +1340,6 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mirror() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_open * @@ -1426,19 +1355,16 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) *------------------------------------------------------------------------- */ static H5FD_t * -H5FD__mirror_open(const char *name, - unsigned flags, - hid_t fapl_id, - haddr_t maxaddr) +H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { 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 @@ -1448,20 +1374,20 @@ H5FD__mirror_open(const char *name, /* Check arguments */ /* --------------- */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name"); - if(HDstrlen(name) >= H5FD_MIRROR_XMIT_FILEPATH_MAX) + if (HDstrlen(name) >= H5FD_MIRROR_XMIT_FILEPATH_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "filename is too long"); - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr"); - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr"); - if(H5Pget_fapl_mirror(fapl_id, &fa) == FAIL) + if (H5Pget_fapl_mirror(fapl_id, &fa) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get config info"); - if(H5FD_MIRROR_FAPL_MAGIC != fa.magic) + if (H5FD_MIRROR_FAPL_MAGIC != fa.magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl magic"); - if(H5FD_MIRROR_CURR_FAPL_T_VERSION != fa.version) + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa.version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl version"); /* --------------------- */ @@ -1469,16 +1395,16 @@ H5FD__mirror_open(const char *name, /* --------------------- */ live_socket = HDsocket(AF_INET, SOCK_STREAM, 0); - if(live_socket < 0) + if (live_socket < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket"); - target_addr.sin_family = AF_INET; - target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); + target_addr.sin_family = AF_INET; + target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); target_addr.sin_addr.s_addr = HDinet_addr(fa.remote_ip); HDmemset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero); addr_size = sizeof(target_addr); - if(HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) + if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't connect to remote server"); /* ------------- */ @@ -1486,63 +1412,62 @@ H5FD__mirror_open(const char *name, /* ------------- */ file = (H5FD_mirror_t *)H5FL_CALLOC(H5FD_mirror_t); - if(NULL == file) + if (NULL == file) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct"); file->sock_fd = live_socket; - file->xmit_i = 0; + file->xmit_i = 0; - file->xmit.magic = H5FD_MIRROR_XMIT_MAGIC; - file->xmit.version = H5FD_MIRROR_XMIT_CURR_VERSION; - file->xmit.xmit_count = file->xmit_i++; + file->xmit.magic = H5FD_MIRROR_XMIT_MAGIC; + file->xmit.version = H5FD_MIRROR_XMIT_CURR_VERSION; + file->xmit.xmit_count = file->xmit_i++; file->xmit.session_token = (uint32_t)(0x01020304 ^ file->sock_fd); /* TODO: hashing? */ /* int --> uint32_t may truncate on some systems... shouldn't matter? */ open_xmit = (H5FD_mirror_xmit_open_t *)H5FL_CALLOC(H5FD_mirror_xmit_open_t); - if(NULL == open_xmit) + if (NULL == open_xmit) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate open_xmit struct"); - file->xmit.op = H5FD_MIRROR_OP_OPEN; - open_xmit->pub = file->xmit; - open_xmit->flags = (uint32_t)flags; - open_xmit->maxaddr = (uint64_t)maxaddr; + file->xmit.op = H5FD_MIRROR_OP_OPEN; + open_xmit->pub = file->xmit; + open_xmit->flags = (uint32_t)flags; + open_xmit->maxaddr = (uint64_t)maxaddr; open_xmit->size_t_blob = (uint64_t)((size_t)(-1)); - HDsnprintf(open_xmit->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX-1, "%s", name); + HDsnprintf(open_xmit->filename, H5FD_MIRROR_XMIT_FILEPATH_MAX - 1, "%s", name); xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_open(xmit_buf, open_xmit) != H5FD_MIRROR_XMIT_OPEN_SIZE) + if (H5FD_mirror_xmit_encode_open(xmit_buf, open_xmit) != H5FD_MIRROR_XMIT_OPEN_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to encode open"); LOG_XMIT_BYTES("open", xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to transmit open"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid reply"); ret_value = (H5FD_t *)file; done: - if(NULL == ret_value) { - if(file) + if (NULL == ret_value) { + if (file) file = H5FL_FREE(H5FD_mirror_t, file); - if(live_socket >= 0 && HDclose(live_socket) < 0) + if (live_socket >= 0 && HDclose(live_socket) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "can't close socket"); } - if(open_xmit) + if (open_xmit) open_xmit = H5FL_FREE(H5FD_mirror_xmit_open_t, open_xmit); - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_close * @@ -1561,10 +1486,10 @@ H5FD__mirror_open(const char *name, static herr_t H5FD__mirror_close(H5FD_t *_file) { - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - unsigned char *xmit_buf = NULL; - int xmit_encoded = 0; /* monitor point of failure */ - herr_t ret_value = SUCCEED; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + unsigned char *xmit_buf = NULL; + int xmit_encoded = 0; /* monitor point of failure */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1575,59 +1500,58 @@ H5FD__mirror_close(H5FD_t *_file) HDassert(file->sock_fd >= 0); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_CLOSE; + file->xmit.op = H5FD_MIRROR_OP_CLOSE; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to encode close"); xmit_encoded = 1; LOG_XMIT_BYTES("close", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); - if(HDclose(file->sock_fd) < 0) + if (HDclose(file->sock_fd) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); done: - if(ret_value == FAIL) { - if(xmit_encoded == 0) { + if (ret_value == FAIL) { + if (xmit_encoded == 0) { /* Encode failed; send GOODBYE to force writer halt. * We can ignore any response from the writer, if we receive * any reply at all. */ - if(HDwrite(file->sock_fd, "GOODBYE", HDstrlen("GOODBYE")) < 0) { + if (HDwrite(file->sock_fd, "GOODBYE", HDstrlen("GOODBYE")) < 0) { HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); - if(HDclose(file->sock_fd) < 0) + if (HDclose(file->sock_fd) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); file->sock_fd = -1; /* invalidate for later */ - } /* end if problem writing goodbye; go down hard */ - else - if(HDshutdown(file->sock_fd, SHUT_WR) < 0) - HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't shutdown socket write: %s", HDstrerror(errno)); + } /* end if problem writing goodbye; go down hard */ + else if (HDshutdown(file->sock_fd, SHUT_WR) < 0) + HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't shutdown socket write: %s", + HDstrerror(errno)); } /* end if xmit encode failed */ - if(file->sock_fd >= 0) - if(HDclose(file->sock_fd) < 0) + if (file->sock_fd >= 0) + if (HDclose(file->sock_fd) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); } /* end if error */ file = H5FL_FREE(H5FD_mirror_t, file); /* always release resources */ - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_query * @@ -1651,19 +1575,14 @@ H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) * is never included. * -- JOS 2020-01-13 */ - if(flags) - *flags = H5FD_FEAT_AGGREGATE_METADATA \ - | H5FD_FEAT_ACCUMULATE_METADATA \ - | H5FD_FEAT_DATA_SIEVE \ - | H5FD_FEAT_AGGREGATE_SMALLDATA \ - | H5FD_FEAT_POSIX_COMPAT_HANDLE \ - | H5FD_FEAT_SUPPORTS_SWMR_IO \ - | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; + if (flags) + *flags = H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | + H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5FD__mirror_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_get_eoa * @@ -1690,7 +1609,6 @@ H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__mirror_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_set_eoa * @@ -1704,10 +1622,10 @@ H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) 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; - herr_t ret_value = SUCCEED; + H5FD_mirror_xmit_eoa_t xmit_eoa; + unsigned char * xmit_buf = NULL; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1718,35 +1636,34 @@ H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) file->eoa = addr; /* local copy */ file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_SET_EOA; + file->xmit.op = H5FD_MIRROR_OP_SET_EOA; - xmit_eoa.pub = file->xmit; - xmit_eoa.type = (uint8_t)type; + xmit_eoa.pub = file->xmit; + xmit_eoa.type = (uint8_t)type; xmit_eoa.eoa_addr = (uint64_t)addr; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_set_eoa(xmit_buf, &xmit_eoa) != H5FD_MIRROR_XMIT_EOA_SIZE) + if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, &xmit_eoa) != H5FD_MIRROR_XMIT_EOA_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode set-eoa"); LOG_XMIT_BYTES("set-eoa", xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit set-eoa"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_get_eof * @@ -1774,7 +1691,6 @@ H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__mirror_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_read * @@ -1784,9 +1700,8 @@ H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ 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) +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 @@ -1795,7 +1710,6 @@ H5FD__mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, FUNC_LEAVE_NOAPI(FAIL) } /* end H5FD__mirror_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_write * @@ -1814,13 +1728,13 @@ H5FD__mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, *------------------------------------------------------------------------- */ static herr_t -H5FD__mirror_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__mirror_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_mirror_xmit_write_t xmit_write; - unsigned char *xmit_buf = NULL; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mirror_xmit_write_t xmit_write; + unsigned char * xmit_buf = NULL; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1830,46 +1744,45 @@ H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, HDassert(buf); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_WRITE; + file->xmit.op = H5FD_MIRROR_OP_WRITE; - xmit_write.pub = file->xmit; - xmit_write.size = (uint64_t)size; + xmit_write.pub = file->xmit; + xmit_write.size = (uint64_t)size; xmit_write.offset = (uint64_t)addr; - xmit_write.type = (uint8_t)type; + xmit_write.type = (uint8_t)type; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); /* Notify Writer of incoming data to write. */ - if(H5FD_mirror_xmit_encode_write(xmit_buf, &xmit_write) != H5FD_MIRROR_XMIT_WRITE_SIZE) + if (H5FD_mirror_xmit_encode_write(xmit_buf, &xmit_write) != H5FD_MIRROR_XMIT_WRITE_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode write"); LOG_XMIT_BYTES("write", xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit write"); /* Check that our write xmission was received */ - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); /* Send the data to be written */ - if(HDwrite(file->sock_fd, buf, size) < 0) + if (HDwrite(file->sock_fd, buf, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit data"); /* Writer should reply that it got the data and is still okay/ready */ - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_truncate * @@ -1880,43 +1793,41 @@ H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5FD__mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) +H5FD__mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - unsigned char *xmit_buf = NULL; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + unsigned char *xmit_buf = NULL; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; + file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode truncate"); LOG_XMIT_BYTES("truncate", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit truncate"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_lock * @@ -1932,43 +1843,42 @@ 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; - herr_t ret_value = SUCCEED; + unsigned char * xmit_buf = NULL; + H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_LOCK; + file->xmit.op = H5FD_MIRROR_OP_LOCK; xmit_lock.pub = file->xmit; - xmit_lock.rw = (uint64_t)rw; + xmit_lock.rw = (uint64_t)rw; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_lock(xmit_buf, &xmit_lock) != H5FD_MIRROR_XMIT_LOCK_SIZE) + if (H5FD_mirror_xmit_encode_lock(xmit_buf, &xmit_lock) != H5FD_MIRROR_XMIT_LOCK_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode lock"); LOG_XMIT_BYTES("lock", xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit lock"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__mirror_lock */ - /*------------------------------------------------------------------------- * Function: H5FD__mirror_unlock * @@ -1980,38 +1890,37 @@ H5FD__mirror_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__mirror_unlock(H5FD_t *_file) { - unsigned char *xmit_buf = NULL; - H5FD_mirror_t *file = (H5FD_mirror_t *)_file; - herr_t ret_value = SUCCEED; + unsigned char *xmit_buf = NULL; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC LOG_OP_CALL(FUNC); file->xmit.xmit_count = (file->xmit_i)++; - file->xmit.op = H5FD_MIRROR_OP_UNLOCK; + file->xmit.op = H5FD_MIRROR_OP_UNLOCK; xmit_buf = H5FL_BLK_MALLOC(xmit, H5FD_MIRROR_XMIT_BUFFER_MAX); - if(NULL == xmit_buf) + if (NULL == xmit_buf) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate xmit buffer"); - if(H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) != H5FD_MIRROR_XMIT_HEADER_SIZE) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode unlock"); LOG_XMIT_BYTES("unlock", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); - if(HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit unlock"); - if(H5FD__mirror_verify_reply(file) == FAIL) + if (H5FD__mirror_verify_reply(file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); done: - if(xmit_buf) + if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__mirror_unlock */ #endif /* H5_HAVE_MIRROR_VFD */ - diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index 7d15c1b112f..49e24c1b0f3 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -51,18 +51,30 @@ extern "C" { * IP address string of "Mirror Server" remote host. * --------------------------------------------------------------------------- */ -#define H5FD_MIRROR_FAPL_MAGIC 0xF8DD514C +#define H5FD_MIRROR_FAPL_MAGIC 0xF8DD514C #define H5FD_MIRROR_CURR_FAPL_T_VERSION 1 -#define H5FD_MIRROR_MAX_IP_LEN 32 +#define H5FD_MIRROR_MAX_IP_LEN 32 typedef struct H5FD_mirror_fapl_t { uint32_t magic; uint32_t version; - int handshake_port; - char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; + int handshake_port; + char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; } H5FD_mirror_fapl_t; -H5_DLL hid_t H5FD_mirror_init(void); +H5_DLL hid_t H5FD_mirror_init(void); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); #ifdef __cplusplus @@ -76,4 +88,3 @@ H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); #endif /* H5_HAVE_MIRROR_VFD */ #endif /* H5FDmirror_H */ - diff --git a/src/H5FDmirror_priv.h b/src/H5FDmirror_priv.h index dc1544130c7..21de97b78a2 100644 --- a/src/H5FDmirror_priv.h +++ b/src/H5FDmirror_priv.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -34,7 +34,7 @@ extern "C" { #define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ #define H5FD_MIRROR_XMIT_CURR_VERSION 1 -#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B +#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B #define H5FD_MIRROR_OP_OPEN 1 #define H5FD_MIRROR_OP_CLOSE 2 @@ -45,8 +45,8 @@ extern "C" { #define H5FD_MIRROR_OP_LOCK 7 #define H5FD_MIRROR_OP_UNLOCK 8 -#define H5FD_MIRROR_STATUS_OK 0 -#define H5FD_MIRROR_STATUS_ERROR 1 +#define H5FD_MIRROR_STATUS_OK 0 +#define H5FD_MIRROR_STATUS_ERROR 1 #define H5FD_MIRROR_STATUS_MESSAGE_MAX 256 /* Dedicated error message size */ /* Maximum length of a path/filename string, including the NULL-terminator. @@ -60,19 +60,16 @@ extern "C" { * must be reflected here. * */ #define H5FD_MIRROR_XMIT_HEADER_SIZE 14 -#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) -#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) -#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) -#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) -#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) +#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) +#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) +#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) +#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) +#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) /* Maximum length of any xmit. */ -#define H5FD_MIRROR_XMIT_BUFFER_MAX MAX2( MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, \ - H5FD_MIRROR_XMIT_EOA_SIZE, \ - H5FD_MIRROR_XMIT_LOCK_SIZE), \ - MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, \ - H5FD_MIRROR_XMIT_REPLY_SIZE, \ - H5FD_MIRROR_XMIT_WRITE_SIZE) ) \ +#define H5FD_MIRROR_XMIT_BUFFER_MAX \ + MAX2(MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, H5FD_MIRROR_XMIT_EOA_SIZE, H5FD_MIRROR_XMIT_LOCK_SIZE), \ + MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, H5FD_MIRROR_XMIT_REPLY_SIZE, H5FD_MIRROR_XMIT_WRITE_SIZE)) /* --------------------------------------------------------------------------- * Structure: H5FD_mirror_xmit_t @@ -264,14 +261,12 @@ typedef struct H5FD_mirror_xmit_reply_t { * --------------------------------------------------------------------------- */ typedef struct H5FD_mirror_xmit_write_t { - H5FD_mirror_xmit_t pub; - uint8_t type; - uint64_t offset; - uint64_t size; + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t offset; + uint64_t size; } H5FD_mirror_xmit_write_t; - - /* Encode/decode routines are required to "pack" the xmit data into a known * byte format for transmission over the wire. * @@ -320,4 +315,3 @@ H5_DLL hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit); #endif /* H5_HAVE_MIRROR_VFD */ #endif /* H5FDmirror_priv_H */ - diff --git a/src/H5FDmodule.h b/src/H5FDmodule.h index 11686be1797..0b92b27da01 100644 --- a/src/H5FDmodule.h +++ b/src/H5FDmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5FD package. Including this header means that the source file * is part of the H5FD package. */ -#ifndef _H5FDmodule_H -#define _H5FDmodule_H +#ifndef H5FDmodule_H +#define H5FDmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5FD_MODULE -#define H5_MY_PKG H5FD -#define H5_MY_PKG_ERR H5E_VFL -#define H5_MY_PKG_INIT YES - -#endif /* _H5FDmodule_H */ +#define H5_MY_PKG H5FD +#define H5_MY_PKG_ERR H5E_VFL +#define H5_MY_PKG_INIT YES +#endif /* H5FDmodule_H */ diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index 82af11a8ecb..048b8f3635f 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,18 +19,16 @@ * */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* Common MPI file driver */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* Common MPI file driver */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_PARALLEL - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_rank * @@ -50,24 +48,23 @@ H5FD_mpi_get_rank(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - int ret_value; + int ret_value; FUNC_ENTER_NOAPI(FAIL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_rank); /* All MPI drivers must implement this */ + HDassert(cls->get_rank); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_rank)(file))<0) + if ((ret_value = (cls->get_rank)(file)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_rank() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_size * @@ -86,24 +83,23 @@ int H5FD_mpi_get_size(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - int ret_value; + int ret_value; FUNC_ENTER_NOAPI(FAIL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_size); /* All MPI drivers must implement this */ + HDassert(cls->get_size); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_size)(file))<0) + if ((ret_value = (cls->get_size)(file)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_size() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_get_comm * @@ -122,24 +118,23 @@ MPI_Comm H5FD_mpi_get_comm(const H5FD_t *file) { const H5FD_class_mpi_t *cls; - MPI_Comm ret_value; + MPI_Comm ret_value; FUNC_ENTER_NOAPI(MPI_COMM_NULL) HDassert(file); cls = (const H5FD_class_mpi_t *)(file->cls); HDassert(cls); - HDassert(cls->get_comm); /* All MPI drivers must implement this */ + HDassert(cls->get_comm); /* All MPI drivers must implement this */ /* Dispatch to driver */ - if ((ret_value=(cls->get_comm)(file))==MPI_COMM_NULL) + if ((ret_value = (cls->get_comm)(file)) == MPI_COMM_NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_get_comm() */ - /*------------------------------------------------------------------------- * Function: H5FD_mpi_MPIOff_to_haddr * @@ -158,19 +153,18 @@ H5FD_mpi_get_comm(const H5FD_t *file) haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off) { - haddr_t ret_value=HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_NOAPI_NOINIT_NOERR if (mpi_off != (MPI_Offset)(haddr_t)mpi_off) - ret_value=HADDR_UNDEF; + ret_value = HADDR_UNDEF; else - ret_value=(haddr_t)mpi_off; + ret_value = (haddr_t)mpi_off; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_mpi_haddr_to_MPIOff * @@ -187,9 +181,9 @@ H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off) *------------------------------------------------------------------------- */ herr_t -H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) +H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off /*out*/) { - herr_t ret_value=FAIL; + herr_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -199,120 +193,15 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/) *mpi_off = (MPI_Offset)addr; if (addr != (haddr_t)((MPI_Offset)addr)) - ret_value=FAIL; + ret_value = FAIL; else - ret_value=SUCCEED; + ret_value = SUCCEED; FUNC_LEAVE_NOAPI(ret_value) } - -/*------------------------------------------------------------------------- - * Function: H5FD_mpi_comm_info_dup - * - * Purpose: Make duplicates of communicator and Info object. - * If the Info object is in fact MPI_INFO_NULL, no duplicate - * is made but the same value assigned to the new Info object - * handle. - * - * Return: Success: Non-negative. The new communicator and Info - * object handles are returned via comm_new and - * info_new pointers. - * - * Failure: Negative. - * - * Programmer: Albert Cheng - * Jan 8, 2003 - *------------------------------------------------------------------------- - */ -herr_t -H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info, MPI_Comm *comm_new, MPI_Info *info_new) -{ - herr_t ret_value=SUCCEED; - MPI_Comm comm_dup=MPI_COMM_NULL; - MPI_Info info_dup=MPI_INFO_NULL; - int mpi_code; - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (MPI_COMM_NULL == comm) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument") - if (!comm_new || !info_new) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "bad pointers") - - /* Dup them. Using temporary variables for error recovery cleanup. */ - if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(comm, &comm_dup))) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) - if (MPI_INFO_NULL != info){ - if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(info, &info_dup))) - HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code) - }else{ - /* No dup, just copy it. */ - info_dup = info; - } - - /* Set MPI_ERRORS_RETURN on comm_dup so that MPI failures are not fatal, - and return codes can be checked and handled. May 23, 2017 FTW */ - if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_errhandler(comm_dup, MPI_ERRORS_RETURN))) - HMPI_GOTO_ERROR(FAIL, "MPI_Errhandler_set failed", mpi_code) - - /* copy them to the return arguments */ - *comm_new = comm_dup; - *info_new = info_dup; - -done: - if (FAIL == ret_value){ - /* need to free anything created here */ - if (MPI_COMM_NULL != comm_dup) - MPI_Comm_free(&comm_dup); - if (MPI_INFO_NULL != info_dup) - MPI_Info_free(&info_dup); - } - - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpi_comm_info_free - * - * Purpose: Free the communicator and Info object. - * If comm or info is in fact MPI_COMM_NULL or MPI_INFO_NULL - * respectively, no action occurs to it. - * - * Return: Success: Non-negative. The values the pointers refer - * to will be set to the corresponding NULL - * handles. - * - * Failure: Negative. - * - * Programmer: Albert Cheng - * Jan 8, 2003 - *------------------------------------------------------------------------- - */ -herr_t -H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info) -{ - herr_t ret_value=SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (!comm || !info) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument") - - if (MPI_COMM_NULL != *comm) - MPI_Comm_free(comm); - if (MPI_INFO_NULL != *info) - MPI_Info_free(info); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - #ifdef NOT_YET - + /*------------------------------------------------------------------------- * Function: H5FD_mpio_wait_for_left_neighbor * @@ -339,24 +228,24 @@ H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info) herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - char msgbuf[1]; - MPI_Status rcvstat; - int mpi_code; /* mpi return code */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + char msgbuf[1]; + MPI_Status rcvstat; + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); /* Portably initialize MPI status variable */ - HDmemset(&rcvstat,0,sizeof(MPI_Status)); + HDmemset(&rcvstat, 0, sizeof(MPI_Status)); /* p0 has no left neighbor; all other procs wait for msg */ if (file->mpi_rank != 0) { - if (MPI_SUCCESS != (mpi_code=MPI_Recv( &msgbuf, 1, MPI_CHAR, - file->mpi_rank-1, MPI_ANY_TAG, file->comm, &rcvstat ))) + if (MPI_SUCCESS != (mpi_code = MPI_Recv(&msgbuf, 1, MPI_CHAR, file->mpi_rank - 1, MPI_ANY_TAG, + file->comm, &rcvstat))) HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mpi_code) } @@ -364,7 +253,6 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5FD_mpio_signal_right_neighbor * @@ -391,18 +279,19 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file) herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - char msgbuf[1]; - int mpi_code; /* mpi return code */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + char msgbuf[1]; + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); - if(file->mpi_rank != (file->mpi_size - 1)) - if(MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, file->mpi_rank + 1, 0, file->comm))) + if (file->mpi_rank != (file->mpi_size - 1)) + if (MPI_SUCCESS != + (mpi_code = MPI_Send(&msgbuf, 0 /*empty msg*/, MPI_CHAR, file->mpi_rank + 1, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mpi_code) done: @@ -410,4 +299,3 @@ H5FD_mpio_signal_right_neighbor(H5FD_t *_file) } #endif /* NOT_YET */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index da9f59b2593..cf493015a04 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -34,27 +34,28 @@ */ #define H5D_MULTI_CHUNK_IO_COL_THRESHOLD 60 -/* Type of I/O for data transfer properties */ +/** + * Type of I/O for data transfer properties + */ typedef enum H5FD_mpio_xfer_t { - H5FD_MPIO_INDEPENDENT = 0, /*zero is the default*/ - H5FD_MPIO_COLLECTIVE + H5FD_MPIO_INDEPENDENT = 0, /**< Use independent I/O access */ + H5FD_MPIO_COLLECTIVE /**< Use collective I/O access */ } H5FD_mpio_xfer_t; /* Type of chunked dataset I/O */ typedef enum H5FD_mpio_chunk_opt_t { H5FD_MPIO_CHUNK_DEFAULT = 0, - H5FD_MPIO_CHUNK_ONE_IO, /*zero is the default*/ + H5FD_MPIO_CHUNK_ONE_IO, /*zero is the default*/ H5FD_MPIO_CHUNK_MULTI_IO } H5FD_mpio_chunk_opt_t; /* Type of collective I/O */ typedef enum H5FD_mpio_collective_opt_t { H5FD_MPIO_COLLECTIVE_IO = 0, - H5FD_MPIO_INDIVIDUAL_IO /*zero is the default*/ + H5FD_MPIO_INDIVIDUAL_IO /*zero is the default*/ } H5FD_mpio_collective_opt_t; /* Include all the MPI VFL headers */ -#include "H5FDmpio.h" /* MPI I/O file driver */ +#include "H5FDmpio.h" /* MPI I/O file driver */ #endif /* H5FDmpi_H */ - diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index c1e119825b9..c0b14ce3b6a 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,17 +21,16 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_PARALLEL @@ -43,7 +42,7 @@ static hid_t H5FD_MPIO_g = 0; /* Whether to allow collective I/O operations */ -/* (Value can be set from environment variable also) */ +/* (Can be changed by setting "HDF5_MPI_OPT_TYPES" environment variable to '0' or '1') */ hbool_t H5FD_mpi_opt_types_g = TRUE; /* @@ -58,105 +57,104 @@ static char H5FD_mpi_native_g[] = "native"; * driver doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpio_t { - H5FD_t pub; /* Public stuff, must be first */ - MPI_File f; /* MPIO file handle */ - MPI_Comm comm; /* MPI Communicator */ - MPI_Info info; /* MPI info object */ - int mpi_rank; /* This process's rank */ - int mpi_size; /* Total number of processes */ - haddr_t eof; /* End-of-file marker */ - haddr_t eoa; /* End-of-address marker */ - haddr_t last_eoa; /* Last known end-of-address marker */ - haddr_t local_eof; /* Local end-of-file address for each process */ + H5FD_t pub; /* Public stuff, must be first */ + MPI_File f; /* MPIO file handle */ + MPI_Comm comm; /* MPI Communicator */ + MPI_Info info; /* MPI info object */ + int mpi_rank; /* This process's rank */ + int mpi_size; /* Total number of processes */ + haddr_t eof; /* End-of-file marker */ + haddr_t eoa; /* End-of-address marker */ + haddr_t last_eoa; /* Last known end-of-address marker */ + haddr_t local_eof; /* Local end-of-file address for each process */ } H5FD_mpio_t; /* Private Prototypes */ /* Callbacks */ -static herr_t H5FD_mpio_term(void); -static void *H5FD_mpio_fapl_get(H5FD_t *_file); -static void *H5FD_mpio_fapl_copy(const void *_old_fa); -static herr_t H5FD_mpio_fapl_free(void *_fa); -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); -static herr_t H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); -static haddr_t H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_mpio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static int H5FD_mpio_mpi_rank(const H5FD_t *_file); -static int H5FD_mpio_mpi_size(const H5FD_t *_file); -static MPI_Comm H5FD_mpio_communicator(const H5FD_t *_file); +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 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); +static herr_t H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD__mpio_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__mpio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__mpio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static int H5FD__mpio_mpi_rank(const H5FD_t *_file); +static int H5FD__mpio_mpi_size(const H5FD_t *_file); +static MPI_Comm H5FD__mpio_communicator(const H5FD_t *_file); /* The MPIO file driver information */ static const H5FD_class_mpi_t H5FD_mpio_g = { - { /* Start of superclass information */ - "mpio", /*name */ - HADDR_MAX, /*maxaddr */ - H5F_CLOSE_SEMI, /* fc_degree */ - H5FD_mpio_term, /*terminate */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_mpio_fapl_t), /*fapl_size */ - H5FD_mpio_fapl_get, /*fapl_get */ - H5FD_mpio_fapl_copy, /*fapl_copy */ - H5FD_mpio_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_mpio_open, /*open */ - H5FD_mpio_close, /*close */ - NULL, /*cmp */ - H5FD_mpio_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_mpio_get_eoa, /*get_eoa */ - H5FD_mpio_set_eoa, /*set_eoa */ - H5FD_mpio_get_eof, /*get_eof */ - H5FD_mpio_get_handle, /*get_handle */ - H5FD_mpio_read, /*read */ - H5FD_mpio_write, /*write */ - H5FD_mpio_flush, /*flush */ - H5FD_mpio_truncate, /*truncate */ - NULL, /*lock */ - NULL, /*unlock */ - H5FD_FLMAP_DICHOTOMY /*fl_map */ - }, /* End of superclass information */ - H5FD_mpio_mpi_rank, /*get_rank */ - H5FD_mpio_mpi_size, /*get_size */ - H5FD_mpio_communicator /*get_comm */ + { + /* Start of superclass information */ + "mpio", /*name */ + HADDR_MAX, /*maxaddr */ + H5F_CLOSE_SEMI, /*fc_degree */ + H5FD__mpio_term, /*terminate */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD__mpio_open, /*open */ + H5FD__mpio_close, /*close */ + NULL, /*cmp */ + H5FD__mpio_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD__mpio_get_eoa, /*get_eoa */ + H5FD__mpio_set_eoa, /*set_eoa */ + H5FD__mpio_get_eof, /*get_eof */ + H5FD__mpio_get_handle, /*get_handle */ + H5FD__mpio_read, /*read */ + H5FD__mpio_write, /*write */ + H5FD__mpio_flush, /*flush */ + H5FD__mpio_truncate, /*truncate */ + NULL, /*lock */ + NULL, /*unlock */ + H5FD_FLMAP_DICHOTOMY /*fl_map */ + }, /* End of superclass information */ + H5FD__mpio_mpi_rank, /*get_rank */ + H5FD__mpio_mpi_size, /*get_size */ + H5FD__mpio_communicator /*get_comm */ }; #ifdef H5FDmpio_DEBUG -/* Flags to control debug actions in H5Fmpio. - * Meant to be indexed by characters. - * - * 'c' show result of MPI_Get_count after read - * 'r' show read offset and size - * 't' trace function entry and exit - * 'w' show write offset and size +/* Flags to control debug actions in the MPI-IO VFD. + * (Meant to be indexed by characters) + * + * These flags can be set with either (or both) the environment variable + * "H5FD_mpio_Debug" set to a string containing one or more characters + * (flags) or by setting them as a string value for the + * "H5F_mpio_debug_key" MPI Info key. + * + * Supported characters in 'H5FD_mpio_Debug' string: + * 't' trace function entry and exit + * 'r' show read offset and size + * 'w' show write offset and size + * '0'-'9' only show output from a single MPI rank (ranks 0-9 supported) */ -static int H5FD_mpio_Debug[256] = - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; +static int H5FD_mpio_debug_flags_s[256]; +static int H5FD_mpio_debug_rank_s = -1; + +/* Indicate if this rank should output tracing info */ +#define H5FD_MPIO_TRACE_THIS_RANK(file) \ + (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == (file)->mpi_rank) #endif - /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -179,14 +177,48 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_mpio_init() < 0) + if (H5FD_mpio_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mpio VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - +#ifdef H5FDmpio_DEBUG + +/*--------------------------------------------------------------------------- + * Function: H5FD__mpio_parse_debug_str + * + * Purpose: Parse a string for debugging flags + * + * Returns: N/A + * + * Programmer: Quincey Koziol + * Wednesday, Aug 12, 2020 + * + *--------------------------------------------------------------------------- + */ +static void +H5FD__mpio_parse_debug_str(const char *s) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(s); + + /* Set debug mask */ + while (*s) { + if ((int)(*s) >= (int)'0' && (int)(*s) <= (int)'9') + H5FD_mpio_debug_rank_s = ((int)*s) - (int)'0'; + else + H5FD_mpio_debug_flags_s[(int)*s]++; + s++; + } /* end while */ + + FUNC_LEAVE_NOAPI_VOID +} /* end H5FD__mpio_parse_debug_str() */ +#endif /* H5FDmpio_DEBUG */ + /*------------------------------------------------------------------------- * Function: H5FD_mpio_init * @@ -204,39 +236,35 @@ H5FD__init_package(void) hid_t H5FD_mpio_init(void) { -#ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited = 0; -#endif /* H5FDmpio_DEBUG */ - const char *s; /* String for environment variables */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Register the MPI-IO VFD, if it isn't already */ - if(H5I_VFL != H5I_get_type(H5FD_MPIO_g)) + if (H5I_VFL != H5I_get_type(H5FD_MPIO_g)) H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g, sizeof(H5FD_class_mpi_t), FALSE); - /* Allow MPI buf-and-file-type optimizations? */ - s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if(s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); - H5FD_mpi_opt_types_g = (0 == env_val) ? FALSE : TRUE; - } + if (!H5FD_mpio_Debug_inited) { + const char *s; /* String for environment variables */ + + /* Allow MPI buf-and-file-type optimizations? */ + s = HDgetenv("HDF5_MPI_OPT_TYPES"); + if (s && HDisdigit(*s)) + H5FD_mpi_opt_types_g = (0 == HDstrtol(s, NULL, 0)) ? FALSE : TRUE; #ifdef H5FDmpio_DEBUG - if(!H5FD_mpio_Debug_inited) { + /* Clear the flag buffer */ + HDmemset(H5FD_mpio_debug_flags_s, 0, sizeof(H5FD_mpio_debug_flags_s)); + /* Retrieve MPI-IO debugging environment variable */ s = HDgetenv("H5FD_mpio_Debug"); - if(s) { - /* Set debug mask */ - while(*s) { - H5FD_mpio_Debug[(int)*s]++; - s++; - } /* end while */ - } /* end if */ + if (s) + H5FD__mpio_parse_debug_str(s); +#endif /* H5FDmpio_DEBUG */ + H5FD_mpio_Debug_inited++; } /* end if */ -#endif /* H5FDmpio_DEBUG */ /* Set return value */ ret_value = H5FD_MPIO_g; @@ -245,7 +273,6 @@ H5FD_mpio_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpio_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__mpio_term * @@ -259,17 +286,16 @@ H5FD_mpio_init(void) *--------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_term(void) +H5FD__mpio_term(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Reset VFL ID */ H5FD_MPIO_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mpio_term() */ +} /* end H5FD__mpio_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_mpio * @@ -304,33 +330,33 @@ H5FD_mpio_term(void) herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) { - H5FD_mpio_fapl_t fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("e", "iMcMi", fapl_id, comm, info); /* Check arguments */ - if(fapl_id == H5P_DEFAULT) + if (fapl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - if(MPI_COMM_NULL == comm) + if (MPI_COMM_NULL == comm) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "MPI_COMM_NULL is not a valid communicator") - /* Initialize driver specific properties */ - fa.comm = comm; - fa.info = info; + /* Set the MPI communicator and info object */ + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator") + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object") /* duplication is done during driver setting. */ - ret_value = H5P_set_driver(plist, H5FD_MPIO, &fa); + ret_value = H5P_set_driver(plist, H5FD_MPIO, NULL); done: FUNC_LEAVE_API(ret_value) } /* H5Pset_fapl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_mpio * @@ -355,59 +381,50 @@ 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/*out*/, MPI_Info *info/*out*/) +H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm /*out*/, MPI_Info *info /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_mpio_fapl_t *fa; /* MPIO fapl info */ - MPI_Comm comm_tmp = MPI_COMM_NULL; - hbool_t comm_copied = FALSE; /* MPI Comm has been duplicated */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, comm, info); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_MPIO != H5P_peek_driver(plist)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - - /* Store the duplicated communicator in a temporary variable for error */ - /* recovery in case the INFO duplication fails. */ - if(comm) { - if(MPI_SUCCESS != (mpi_code = MPI_Comm_dup(fa->comm, &comm_tmp))) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) - comm_copied = TRUE; - } /* end if */ - - if(info) { - if(MPI_INFO_NULL != fa->info) { - if(MPI_SUCCESS != (mpi_code = MPI_Info_dup(fa->info, info))) - HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code) - } /* end if */ - else - /* do not dup it */ + /* Set comm and info in case we have problems */ + if (comm) + *comm = MPI_COMM_NULL; + if (info) *info = MPI_INFO_NULL; - } /* end if */ - /* Store the copied communicator, now that the Info object has been - * successfully copied. - */ - if(comm) - *comm = comm_tmp; + /* Check arguments */ + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") + if (H5FD_MPIO != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "VFL driver is not MPI-I/O") + + /* Get the MPI communicator and info object */ + if (comm) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator") + if (info) + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info object") done: - if(ret_value < 0) - /* need to free anything created here */ - if(comm_copied) - MPI_Comm_free(&comm_tmp); + /* Clean up anything duplicated on errors. The free calls will set + * the output values to MPI_COMM|INFO_NULL. + */ + if (ret_value != SUCCEED) { + if (comm) + if (H5_mpi_comm_free(comm) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + if (info) + if (H5_mpi_info_free(info) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") + } FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio * @@ -433,29 +450,28 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/) herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDt", dxpl_id, xfer_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") - if(H5FD_MPIO_INDEPENDENT != xfer_mode && H5FD_MPIO_COLLECTIVE != xfer_mode) + if (H5FD_MPIO_INDEPENDENT != xfer_mode && H5FD_MPIO_COLLECTIVE != xfer_mode) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) + if (H5P_set(plist, H5D_XFER_IO_XFER_MODE_NAME, &xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pget_dxpl_mpio * @@ -473,28 +489,27 @@ H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode) *------------------------------------------------------------------------- */ herr_t -H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) +H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dxpl_id, xfer_mode); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Get the transfer mode */ - if(xfer_mode) - if(H5P_get(plist, H5D_XFER_IO_XFER_MODE_NAME, xfer_mode) < 0) + if (xfer_mode) + if (H5P_get(plist, H5D_XFER_IO_XFER_MODE_NAME, xfer_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_dxpl_mpio() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_collective_opt * @@ -516,27 +531,26 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) herr_t H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDc", dxpl_id, opt_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &opt_mode) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_collective_opt() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt * @@ -558,27 +572,26 @@ H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mo herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDh", dxpl_id, opt_mode); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &opt_mode) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt_num * @@ -598,27 +611,26 @@ H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode) herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, num_chunk_per_proc); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &num_chunk_per_proc) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &num_chunk_per_proc) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt_num() */ - /*------------------------------------------------------------------------- * Function: H5Pset_dxpl_mpio_chunk_opt_ratio * @@ -641,163 +653,26 @@ H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc) herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_num_proc_per_chunk) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", dxpl_id, percent_num_proc_per_chunk); /* Check arguments */ - if(dxpl_id == H5P_DEFAULT) + if (dxpl_id == H5P_DEFAULT) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list") - if(NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl") /* Set the transfer mode */ - if(H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &percent_num_proc_per_chunk) < 0) + if (H5P_set(plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &percent_num_proc_per_chunk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dxpl_mpio_chunk_opt_ratio() */ - -/*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_get - * - * Purpose: Returns a file access property list which could be used to - * create another file the same as this one. - * - * Return: Success: Ptr to new file access property list with all - * fields copied from the file pointer. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, August 13, 1999 - * - *------------------------------------------------------------------------- - */ -static void * -H5FD_mpio_fapl_get(H5FD_t *_file) -{ - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - H5FD_mpio_fapl_t *fa = NULL; - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(file); - HDassert(H5FD_MPIO == file->pub.driver_id); - - if(NULL == (fa = (H5FD_mpio_fapl_t *)H5MM_calloc(sizeof(H5FD_mpio_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Duplicate communicator and Info object. */ - if(FAIL == H5FD_mpi_comm_info_dup(file->comm, file->info, &fa->comm, &fa->info)) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") - - /* Set return value */ - ret_value = fa; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_copy - * - * Purpose: Copies the mpio-specific file access properties. - * - * Return: Success: Ptr to a new property list - * - * Failure: NULL - * - * Programmer: Albert Cheng - * Jan 8, 2003 - * - *------------------------------------------------------------------------- - */ -static void * -H5FD_mpio_fapl_copy(const void *_old_fa) -{ - void *ret_value = NULL; - const H5FD_mpio_fapl_t *old_fa = (const H5FD_mpio_fapl_t*)_old_fa; - H5FD_mpio_fapl_t *new_fa = NULL; - - FUNC_ENTER_NOAPI_NOINIT -#ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -HDfprintf(stderr, "enter H5FD_mpio_fapl_copy\n"); -#endif - - if(NULL == (new_fa = (H5FD_mpio_fapl_t *)H5MM_malloc(sizeof(H5FD_mpio_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Copy the general information */ - H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_mpio_fapl_t)); - - /* Duplicate communicator and Info object. */ - if(FAIL == H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info, &new_fa->comm, &new_fa->info)) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") - ret_value = new_fa; - -done: - if (NULL == ret_value){ - /* cleanup */ - if (new_fa) - H5MM_xfree(new_fa); - } - -#ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -HDfprintf(stderr, "leaving H5FD_mpio_fapl_copy\n"); -#endif - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_fapl_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpio_fapl_free - * - * Purpose: Frees the mpio-specific file access properties. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Albert Cheng - * Jan 8, 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_mpio_fapl_free(void *_fa) -{ - herr_t ret_value = SUCCEED; - H5FD_mpio_fapl_t *fa = (H5FD_mpio_fapl_t*)_fa; - - FUNC_ENTER_NOAPI_NOINIT_NOERR -#ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -HDfprintf(stderr, "in H5FD_mpio_fapl_free\n"); -#endif - HDassert(fa); - - /* Free the internal communicator and INFO object */ - HDassert(MPI_COMM_NULL!=fa->comm); - H5FD_mpi_comm_info_free(&fa->comm, &fa->info); - H5MM_xfree(fa); - -#ifdef H5FDmpio_DEBUG -if (H5FD_mpio_Debug[(int)'t']) -HDfprintf(stderr, "leaving H5FD_mpio_fapl_free\n"); -#endif - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_fapl_free() */ - - /*------------------------------------------------------------------------- * Function: H5FD_set_mpio_atomicity * @@ -813,37 +688,33 @@ HDfprintf(stderr, "leaving H5FD_mpio_fapl_free\n"); herr_t H5FD_set_mpio_atomicity(H5FD_t *_file, hbool_t flag) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ - int temp_flag; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif - if(FALSE == flag) - temp_flag = 0; - else - temp_flag = 1; - /* set atomicity value */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, temp_flag))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_atomicity(file->f, (int)(flag != FALSE)))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_atomicity", mpi_code) done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_mpio_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_mpio_atomicity * @@ -859,37 +730,39 @@ H5FD_set_mpio_atomicity(H5FD_t *_file, hbool_t flag) herr_t H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; int temp_flag; - herr_t ret_value = SUCCEED; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Get atomicity value */ - if(MPI_SUCCESS != (mpi_code = MPI_File_get_atomicity(file->f, &temp_flag))) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_atomicity(file->f, &temp_flag))) HMPI_GOTO_ERROR(FAIL, "MPI_File_get_atomicity", mpi_code) - if(0 != temp_flag) + if (0 != temp_flag) *flag = TRUE; else *flag = FALSE; done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_mpio_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5FD__mpio_open * @@ -909,145 +782,135 @@ 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_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR_UNUSED maxaddr) { - H5FD_mpio_t *file=NULL; - MPI_File fh; - unsigned file_opened=0; /* Flag to indicate that the file was successfully opened */ - int mpi_amode; - int mpi_rank; /* MPI rank of this process */ - int mpi_size; /* Total number of MPI processes */ - int mpi_code; /* mpi return code */ - MPI_Offset size; - const H5FD_mpio_fapl_t *fa = NULL; - H5FD_mpio_fapl_t _fa; - H5P_genplist_t *plist; /* Property list pointer */ - MPI_Comm comm_dup = MPI_COMM_NULL; - MPI_Info info_dup = MPI_INFO_NULL; - H5FD_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - + 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 */ + MPI_File fh; /* MPI file handle */ + hbool_t file_opened = FALSE; /* Flag to indicate that the file was successfully opened */ + int mpi_amode; /* MPI file access flags */ + int mpi_rank = INT_MAX; /* MPI rank of this process */ + int mpi_size; /* Total number of MPI processes */ + MPI_Offset file_size; /* File size (of existing files) */ #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", FUNC, name, flags, (int)fapl_id, (unsigned long)maxaddr); + hbool_t H5FD_mpio_debug_t_flag = FALSE; #endif + int mpi_code; /* MPI return code */ + H5FD_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC /* Get a pointer to the fapl */ - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MPIO != H5P_peek_driver(plist)) { - _fa.comm = MPI_COMM_SELF; /*default*/ - _fa.info = MPI_INFO_NULL; /*default*/ - fa = &_fa; - } /* end if */ - else { - if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") - } /* end else */ - /* Duplicate communicator and Info object for use by this file. */ - if(FAIL == H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup)) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") + /* Get the MPI communicator and info object from the property list */ + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI communicator") + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI info object") + + /* Get the MPI rank of this process and the total number of processes */ + if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(comm, &mpi_rank))) + HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) + if (MPI_SUCCESS != (mpi_code = MPI_Comm_size(comm, &mpi_size))) + HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) + +#ifdef H5FDmpio_DEBUG + H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && + (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == mpi_rank)); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering - name = \"%s\", flags = 0x%x, fapl_id = %d, maxaddr = %lu\n", + FUNC, mpi_rank, name, flags, (int)fapl_id, (unsigned long)maxaddr); +#endif /* Convert HDF5 flags to MPI-IO flags */ /* Some combinations are illegal; let MPI-IO figure it out */ - mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; - if(flags & H5F_ACC_CREAT) + mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; + if (flags & H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE; - if(flags & H5F_ACC_EXCL) + if (flags & H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; #ifdef H5FDmpio_DEBUG /* Check for debug commands in the info parameter */ - if(MPI_INFO_NULL != info_dup) { + if (MPI_INFO_NULL != info) { char debug_str[128]; - int flag; - - MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); - if(flag) { - int i; + int flag; - HDfprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); - for(i = 0; debug_str[i]/*end of string*/ && i < 128/*just in case*/; ++i) - H5FD_mpio_Debug[(int)debug_str[i]] = 1; - } /* end if */ + MPI_Info_get(info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); + if (flag) + H5FD__mpio_parse_debug_str(debug_str); } /* end if */ #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_open(comm_dup, name, mpi_amode, info_dup, &fh))) + if (MPI_SUCCESS != (mpi_code = MPI_File_open(comm, name, mpi_amode, info, &fh))) HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code) - file_opened=1; - - /* Get the MPI rank of this process and the total number of processes */ - if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (comm_dup, &mpi_rank))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) - if (MPI_SUCCESS != (mpi_code=MPI_Comm_size (comm_dup, &mpi_size))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) + file_opened = TRUE; /* Build the return value and initialize it */ - if(NULL == (file = (H5FD_mpio_t *)H5MM_calloc(sizeof(H5FD_mpio_t)))) + if (NULL == (file = (H5FD_mpio_t *)H5MM_calloc(sizeof(H5FD_mpio_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - file->f = fh; - file->comm = comm_dup; - file->info = info_dup; + file->f = fh; + file->comm = comm; + file->info = info; file->mpi_rank = mpi_rank; file->mpi_size = mpi_size; /* Only processor p0 will get the filesize and broadcast it. */ - if (mpi_rank == 0) { - if (MPI_SUCCESS != (mpi_code=MPI_File_get_size(fh, &size))) + if (mpi_rank == 0) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(fh, &file_size))) HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code) - } /* end if */ /* Broadcast file size */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, comm_dup))) + 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) /* Determine if the file should be truncated */ - if(size && (flags & H5F_ACC_TRUNC)) { - if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(fh, (MPI_Offset)0))) + if (file_size && (flags & H5F_ACC_TRUNC)) { + /* Truncate the file */ + if (MPI_SUCCESS != (mpi_code = MPI_File_set_size(fh, (MPI_Offset)0))) HMPI_GOTO_ERROR(NULL, "MPI_File_set_size failed", mpi_code) /* Don't let any proc return until all have truncated the file. */ - if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(comm_dup))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(comm))) HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mpi_code) /* File is zero size now */ - size = 0; + file_size = 0; } /* end if */ /* Set the size of the file (from library's perspective) */ - file->eof = H5FD_mpi_MPIOff_to_haddr(size); + file->eof = H5FD_mpi_MPIOff_to_haddr(file_size); file->local_eof = file->eof; /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value == NULL) { - if(file_opened) + if (ret_value == NULL) { + if (file_opened) MPI_File_close(&fh); - if (MPI_COMM_NULL != comm_dup) - MPI_Comm_free(&comm_dup); - if (MPI_INFO_NULL != info_dup) - MPI_Info_free(&info_dup); - if (file) - H5MM_xfree(file); + if (H5_mpi_comm_free(&comm) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI communicator") + if (H5_mpi_info_free(&info) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI info object") + if (file) + H5MM_xfree(file); } /* end if */ #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_open() */ +} /* end H5FD__mpio_open() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_close + * Function: H5FD__mpio_close * * Purpose: Closes a file. This is collective. * @@ -1059,17 +922,21 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_close(H5FD_t *_file) +H5FD__mpio_close(H5FD_t *_file) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); + int mpi_rank = file->mpi_rank; +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1077,25 +944,25 @@ H5FD_mpio_close(H5FD_t *_file) HDassert(H5FD_MPIO == file->pub.driver_id); /* MPI_File_close sets argument to MPI_FILE_NULL */ - if(MPI_SUCCESS != (mpi_code = MPI_File_close(&(file->f)/*in,out*/))) + if (MPI_SUCCESS != (mpi_code = MPI_File_close(&(file->f)))) HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code) /* Clean up other stuff */ - H5FD_mpi_comm_info_free(&file->comm, &file->info); + H5_mpi_comm_free(&file->comm); + H5_mpi_info_free(&file->info); H5MM_xfree(file); done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_close() */ +} /* end H5FD__mpio_close() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_query + * Function: H5FD__mpio_query * * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) @@ -1108,26 +975,26 @@ H5FD_mpio_close(H5FD_t *_file) *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) +H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out */) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *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 */ + *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 */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mpio_query() */ +} /* end H5FD__mpio_query() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_eoa + * Function: H5FD__mpio_get_eoa * * Purpose: Gets the end-of-address marker for the file. The EOA marker * is the first address past the last byte allocated in the @@ -1142,22 +1009,21 @@ H5FD_mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out *------------------------------------------------------------------------- */ static haddr_t -H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eoa) -} /* end H5FD_mpio_get_eoa() */ +} /* end H5FD__mpio_get_eoa() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_set_eoa + * Function: H5FD__mpio_set_eoa * * Purpose: Set the end-of-address marker for the file. This function is * called shortly after an existing HDF5 file is opened in order @@ -1171,11 +1037,11 @@ H5FD_mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +H5FD__mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); @@ -1184,11 +1050,10 @@ H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) file->eoa = addr; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FD_mpio_set_eoa() */ +} /* end H5FD__mpio_set_eoa() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_eof + * Function: H5FD__mpio_get_eof * * Purpose: Gets the end-of-file marker for the file. The EOF marker * is the real size of the file. @@ -1214,22 +1079,21 @@ H5FD_mpio_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) *------------------------------------------------------------------------- */ static haddr_t -H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +H5FD__mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->eof) -} /* end H5FD_mpio_get_eof() */ +} /* end H5FD__mpio_get_eof() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_handle + * Function: H5FD__mpio_get_handle * * Purpose: Returns the file handle of MPIO file driver. * @@ -1239,58 +1103,26 @@ H5FD_mpio_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) * Sept. 16, 2002 * *------------------------------------------------------------------------- -*/ + */ static herr_t -H5FD_mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle) +H5FD__mpio_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->f); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_get_handle() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpio_get_info - * - * Purpose: Returns the file info of MPIO file driver. - * - * Returns: Non-negative if succeed or negative if fails. - * - * Programmer: John Mainzer - * April 4, 2017 - * - *------------------------------------------------------------------------- -*/ -static herr_t -H5FD_mpio_get_info(H5FD_t *_file, void** mpi_info) -{ - H5FD_mpio_t *file = (H5FD_mpio_t *)_file; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - if(!mpi_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mpi info not valid") - - *mpi_info = &(file->info); - -done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5FD_mpio_get_info() */ - +} /* end H5FD__mpio_get_handle() */ /*------------------------------------------------------------------------- - * Function: H5FD_mpio_read + * Function: H5FD__mpio_read * * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR * into buffer BUF according to data transfer properties in @@ -1311,63 +1143,68 @@ H5FD_mpio_get_info(H5FD_t *_file, void** mpi_info) *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) +H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - MPI_Offset mpi_off; - MPI_Status mpi_stat; /* Status from I/O operation */ - int mpi_code; /* mpi return code */ - MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ - int size_i; /* Integer copy of 'size' to read */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + MPI_Offset mpi_off; + MPI_Status mpi_stat; /* Status from I/O operation */ + MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ + int size_i; /* Integer copy of 'size' to read */ #if MPI_VERSION >= 3 - MPI_Count bytes_read = 0; /* Number of bytes read in */ - MPI_Count type_size; /* MPI datatype used for I/O's size */ - MPI_Count io_size; /* Actual number of bytes requested */ - MPI_Count n; + MPI_Count bytes_read = 0; /* Number of bytes read in */ + MPI_Count type_size; /* MPI datatype used for I/O's size */ + MPI_Count io_size; /* Actual number of bytes requested */ + MPI_Count n; #else - int bytes_read = 0; /* Number of bytes read in */ - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ - int n; + int bytes_read = 0; /* Number of bytes read in */ + int type_size; /* MPI datatype used for I/O's size */ + int io_size; /* Actual number of bytes requested */ + int n; +#endif + hbool_t use_view_this_time = 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)); + hbool_t H5FD_mpio_debug_r_flag = (H5FD_mpio_debug_flags_s[(int)'r'] && H5FD_MPIO_TRACE_THIS_RANK(file)); #endif - hbool_t use_view_this_time = FALSE; - hbool_t rank0_bcast = FALSE; /* If read-with-rank0-and-bcast flag was used */ - herr_t ret_value = SUCCEED; + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); HDassert(buf); /* Portably initialize MPI status variable */ - HDmemset(&mpi_stat,0,sizeof(MPI_Status)); + HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); /* some numeric conversions */ - if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/) < 0) + 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) + 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[(int)'r']) - HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld size_i = %d\n", FUNC, file->mpi_rank, (long)mpi_off, + size_i); #endif /* Only look for MPI views for raw data transfers */ - if(type == H5FD_MEM_DRAW) { - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ + if (type == H5FD_MEM_DRAW) { + H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ /* Get the transfer mode from the API context */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* @@ -1376,20 +1213,21 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if(H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) + if (H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O datatypes") /* * Set the file view when we are using MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for @@ -1397,72 +1235,85 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, */ mpi_off = 0; } /* end if */ - } /* end if */ + } /* end if */ /* Read the data. */ - if(use_view_this_time) { + if (use_view_this_time) { H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: using MPIO collective mode\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) using MPIO collective mode\n", FUNC, file->mpi_rank); #endif /* 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) + if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_op property") - if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { + if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing MPI collective IO\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI collective IO\n", FUNC, file->mpi_rank); #endif /* Check whether we should read from rank 0 and broadcast to other ranks */ - if(H5CX_get_mpio_rank0_bcast()) { + if (H5CX_get_mpio_rank0_bcast()) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing read-rank0-and-MPI_Bcast\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing read-rank0-and-MPI_Bcast\n", FUNC, file->mpi_rank); #endif /* Indicate path we've taken */ rank0_bcast = TRUE; /* Read on rank 0 Bcast to other ranks */ - if(file->mpi_rank == 0) - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + if (file->mpi_rank == 0) + 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) - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(buf, size_i, buf_type, 0, file->comm))) + 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 */ else - 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) + /* 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) } /* end if */ else { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'r']) - HDfprintf(stdout, "%s: doing MPI independent IO\n", FUNC); + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + /* Perform independent read operation */ + 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) } /* end else */ /* * Reset the file view when we used MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + else { +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); +#endif + + /* Perform independent read operation */ + 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) + } /* end else */ /* Only retrieve bytes read if this rank _actually_ participated in I/O */ - if(!rank0_bcast || (rank0_bcast && file->mpi_rank == 0) ) { + 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) } /* end if */ @@ -1473,15 +1324,15 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, /* NOTE: This could be optimized further to be combined with the broadcast * of the data. (QAK - 2019/1/2) */ - if(rank0_bcast) - if(MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_LONG_LONG, 0, file->comm)) + if (rank0_bcast) + if (MPI_SUCCESS != MPI_Bcast(&bytes_read, 1, MPI_LONG_LONG, 0, file->comm)) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", 0) - /* Get the type's size */ + /* Get the type's size */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) @@ -1489,28 +1340,26 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, io_size = type_size * size_i; /* Check for read failure */ - if(bytes_read < 0 || bytes_read > io_size) + if (bytes_read < 0 || bytes_read > io_size) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") /* * This gives us zeroes beyond end of physical MPI file. */ - if((n = (io_size - bytes_read)) > 0) - HDmemset((char*)buf+bytes_read, 0, (size_t)n); + if ((n = (io_size - bytes_read)) > 0) + HDmemset((char *)buf + bytes_read, 0, (size_t)n); done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_read() */ - +} /* end H5FD__mpio_read() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_write + * Function: H5FD__mpio_write * * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR * from buffer BUF according to data transfer properties in @@ -1531,38 +1380,43 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_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__mpio_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_mpio_t *file = (H5FD_mpio_t*)_file; - MPI_Offset mpi_off; - MPI_Status mpi_stat; /* Status from I/O operation */ - MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ - int mpi_code; /* MPI return code */ + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; + MPI_Offset mpi_off; + MPI_Status mpi_stat; /* Status from I/O operation */ + MPI_Datatype buf_type = MPI_BYTE; /* MPI description of the selection in memory */ #if MPI_VERSION >= 3 - MPI_Count bytes_written; - MPI_Count type_size; /* MPI datatype used for I/O's size */ - MPI_Count io_size; /* Actual number of bytes requested */ + MPI_Count bytes_written; + MPI_Count type_size; /* MPI datatype used for I/O's size */ + MPI_Count io_size; /* Actual number of bytes requested */ #else - int bytes_written; - int type_size; /* MPI datatype used for I/O's size */ - int io_size; /* Actual number of bytes requested */ + int bytes_written; + int type_size; /* MPI datatype used for I/O's size */ + int io_size; /* Actual number of bytes requested */ #endif - int size_i; - hbool_t use_view_this_time = FALSE; - H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ - herr_t ret_value = SUCCEED; + int size_i; + hbool_t use_view_this_time = FALSE; + hbool_t derived_type = FALSE; + H5FD_mpio_xfer_t xfer_mode; /* I/O transfer mode */ +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); + hbool_t H5FD_mpio_debug_w_flag = (H5FD_mpio_debug_flags_s[(int)'w'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ HDassert(file); - HDassert(H5FD_MPIO==file->pub.driver_id); + HDassert(H5FD_MPIO == file->pub.driver_id); HDassert(buf); /* Verify that no data is written when between MPI_Barrier()s during file flush */ @@ -1572,19 +1426,18 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, HDmemset(&mpi_stat, 0, sizeof(MPI_Status)); /* some numeric conversions */ - if(H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 0) + if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off) < 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[(int)'w']) - HDfprintf(stdout, "%s: mpi_off = %ld size_i = %d\n", FUNC, (long)mpi_off, size_i); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld size_i = %d\n", FUNC, file->mpi_rank, (long)mpi_off, + size_i); #endif /* Get the transfer mode from the API context */ - if(H5CX_get_io_xfer_mode(&xfer_mode) < 0) + if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") /* @@ -1593,20 +1446,21 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, * us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which * could mean "use MPI_BYTE" by convention). */ - if(xfer_mode == H5FD_MPIO_COLLECTIVE) { - MPI_Datatype file_type; + if (xfer_mode == H5FD_MPIO_COLLECTIVE) { + MPI_Datatype file_type; /* Remember that views are used */ use_view_this_time = TRUE; /* Prepare for a full-blown xfer using btype, ftype, and disp */ - if(H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) + if (H5CX_get_mpi_coll_datatypes(&buf_type, &file_type) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O datatypes") /* * Set the file view when we are using MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for @@ -1614,60 +1468,88 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, */ 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) { + if (use_view_this_time) { H5FD_mpio_collective_opt_t coll_opt_mode; #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n"); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) using MPIO collective mode\n", FUNC, file->mpi_rank); #endif /* 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) + if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_op property") - if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { + if (coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "H5FD_mpio_write: doing MPI collective IO\n"); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI collective IO\n", FUNC, file->mpi_rank); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + /* Perform collective write operation */ + if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code) } /* end if */ else { - if(type != H5FD_MEM_DRAW) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Metadata Coll opt property should be collective at this point") + if (type != H5FD_MEM_DRAW) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, + "Metadata Coll opt property should be collective at this point") + #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "H5FD_mpio_write: doing MPI independent IO\n"); + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); #endif - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + /* Perform independent write operation */ + if (MPI_SUCCESS != + (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) } /* end else */ /* Reset the file view when we used MPI derived types */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, + H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) + else { +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); +#endif + + /* Perform independent write operation */ + if (MPI_SUCCESS != (mpi_code = MPI_File_write_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code) + } /* end else */ /* How many bytes were actually written? */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_written))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) - /* Get the type's size */ + /* Get the type's size */ #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size_x(buf_type, &type_size))) #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_size(buf_type, &type_size))) #endif HMPI_GOTO_ERROR(FAIL, "MPI_Type_size failed", mpi_code) @@ -1675,7 +1557,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, io_size = type_size * size_i; /* Check for write failure */ - if(bytes_written != io_size) + if (bytes_written != io_size || bytes_written < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Each process will keep track of its perceived EOF value locally, and @@ -1686,21 +1568,23 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, * potentially be wrong.) */ file->eof = HADDR_UNDEF; - if(bytes_written && ((bytes_written + addr) > file->local_eof)) - file->local_eof = addr + bytes_written; + if (bytes_written && (((haddr_t)bytes_written + addr) > file->local_eof)) + file->local_eof = addr + (haddr_t)bytes_written; done: + if (derived_type) + MPI_Type_free(&buf_type); + #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving, proc %d: ret_value = %d\n", FUNC, file->mpi_rank, ret_value ); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving: ret_value = %d\n", FUNC, file->mpi_rank, ret_value); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_write() */ +} /* end H5FD__mpio_write() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_flush + * Function: H5FD__mpio_flush * * Purpose: Makes sure that all data is on disk. This is collective. * @@ -1712,17 +1596,20 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +H5FD__mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - int mpi_code; /* mpi return code */ - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + int mpi_code; /* mpi return code */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ @@ -1730,34 +1617,34 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) HDassert(H5FD_MPIO == file->pub.driver_id); /* Only sync the file if we are not going to immediately close it */ - if(!closing) - if(MPI_SUCCESS != (mpi_code = MPI_File_sync(file->f))) + if (!closing) + if (MPI_SUCCESS != (mpi_code = MPI_File_sync(file->f))) HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mpi_code) done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_flush() */ +} /* end H5FD__mpio_flush() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_truncate + * Function: H5FD__mpio_truncate * * Purpose: Make certain the file's size matches it's allocated size * * This is a little sticky in the mpio case, as it is not * easy for us to track the current EOF by extracting it from - * write calls. + * write calls, since other ranks could have written to the + * file beyond the local EOF. * - * Instead, we first check to see if the eoa has changed since + * Instead, we first check to see if the EOA has changed since * the last call to this function. If it has, we call * MPI_File_get_size() to determine the current EOF, and * only call MPI_File_set_size() if this value disagrees - * with the current eoa. + * with the current EOA. * * Return: SUCCEED/FAIL * @@ -1767,26 +1654,29 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) +H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - herr_t ret_value = SUCCEED; + H5FD_mpio_t *file = (H5FD_mpio_t *)_file; +#ifdef H5FDmpio_DEBUG + hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); +#endif + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Entering\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Entering\n", FUNC, file->mpi_rank); #endif /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); - if(!H5F_addr_eq(file->eoa, file->last_eoa)) { - int mpi_code; /* mpi return code */ - MPI_Offset size; - MPI_Offset needed_eof; + if (!H5F_addr_eq(file->eoa, file->last_eoa)) { + int mpi_code; /* mpi return code */ + MPI_Offset size; + MPI_Offset needed_eof; /* In principle, it is possible for the size returned by the * call to MPI_File_get_size() to depend on whether writes from @@ -1800,29 +1690,29 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ * Check the "MPI file closing" flag in the API context to determine * if we can skip the barrier. */ - if(!H5CX_get_mpi_file_flushing()) - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) + if (!H5CX_get_mpi_file_flushing()) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) 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(MPI_SUCCESS != (mpi_code = MPI_File_get_size(file->f, &size))) + if (0 == file->mpi_rank) + if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(file->f, &size))) HMPI_GOTO_ERROR(FAIL, "MPI_File_get_size failed", mpi_code) /* Broadcast file size */ - if(MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, file->comm))) + 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(H5FD_mpi_haddr_to_MPIOff(file->eoa, &needed_eof) < 0) + 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") - /* eoa != eof. Set eof to eoa */ - if(size != needed_eof) { + /* EOA != EOF. Set EOF to EOA */ + if (size != needed_eof) { /* Extend the file's size */ - if(MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, needed_eof))) + if (MPI_SUCCESS != (mpi_code = MPI_File_set_size(file->f, needed_eof))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code) /* In general, we must wait until all processes have finished @@ -1834,7 +1724,7 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ * not be an issue at file close. If so, we may be able to * optimize out the following barrier in that case. */ - if(MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) } /* end if */ @@ -1844,16 +1734,15 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ done: #ifdef H5FDmpio_DEBUG - if(H5FD_mpio_Debug[(int)'t']) - HDfprintf(stdout, "%s: Leaving\n", FUNC); + if (H5FD_mpio_debug_t_flag) + HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_mpio_truncate() */ +} /* end H5FD__mpio_truncate() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_mpi_rank + * Function: H5FD__mpio_mpi_rank * * Purpose: Returns the MPI rank for a process * @@ -1866,22 +1755,21 @@ H5FD_mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ *------------------------------------------------------------------------- */ static int -H5FD_mpio_mpi_rank(const H5FD_t *_file) +H5FD__mpio_mpi_rank(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_rank) -} /* end H5FD_mpio_mpi_rank() */ +} /* end H5FD__mpio_mpi_rank() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_mpi_size + * Function: H5FD__mpio_mpi_size * * Purpose: Returns the number of MPI processes * @@ -1894,22 +1782,21 @@ H5FD_mpio_mpi_rank(const H5FD_t *_file) *------------------------------------------------------------------------- */ static int -H5FD_mpio_mpi_size(const H5FD_t *_file) +H5FD__mpio_mpi_size(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->mpi_size) -} /* end H5FD_mpio_mpi_size() */ +} /* end H5FD__mpio_mpi_size() */ - /*------------------------------------------------------------------------- - * Function: H5FD_mpio_communicator + * Function: H5FD__mpio_communicator * * Purpose: Returns the MPI communicator for the file. * @@ -1922,18 +1809,16 @@ H5FD_mpio_mpi_size(const H5FD_t *_file) *------------------------------------------------------------------------- */ static MPI_Comm -H5FD_mpio_communicator(const H5FD_t *_file) +H5FD__mpio_communicator(const H5FD_t *_file) { - const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file; + const H5FD_mpio_t *file = (const H5FD_mpio_t *)_file; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(file); HDassert(H5FD_MPIO == file->pub.driver_id); FUNC_LEAVE_NOAPI(file->comm) -} /* end H5FD_mpio_communicator() */ - +} /* end H5FD__mpio_communicator() */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 9d021538b65..8caf11c76cd 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,9 +23,9 @@ /* Macros */ #ifdef H5_HAVE_PARALLEL -# define H5FD_MPIO (H5FD_mpio_init()) +#define H5FD_MPIO (H5FD_mpio_init()) #else -# define H5FD_MPIO (-1) +#define H5FD_MPIO (H5I_INVALID_HID) #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_PARALLEL @@ -45,14 +45,236 @@ H5_DLLVAR hbool_t H5FD_mpi_opt_types_g; extern "C" { #endif H5_DLL hid_t H5FD_mpio_init(void); + +/** + * \ingroup FAPL + * + * \brief Stores MPI IO communicator information to the file access property list + * + * \fapl_id + * \param[in] comm MPI-2 communicator + * \param[in] info MPI-2 info object + * \returns \herr_t + * + * \details H5Pset_fapl_mpio() stores the user-supplied MPI IO parameters \p + * comm, for communicator, and \p info, for information, in the file + * access property list \p fapl_id. That property list can then be used + * to create and/or open a file. + * + * H5Pset_fapl_mpio() is available only in the parallel HDF5 library + * and is not a collective function. + * + * \p comm is the MPI communicator to be used for file open, as defined + * in \c MPI_File_open of MPI-2. This function makes a duplicate of the + * communicator, so modifications to \p comm after this function call + * returns have no effect on the file access property list. + * + * \p info is the MPI Info object to be used for file open, as defined + * in MPI_File_open() of MPI-2. This function makes a duplicate copy of + * the Info object, so modifications to the Info object after this + * function call returns will have no effect on the file access + * property list. + * + * If the file access property list already contains previously-set + * communicator and Info values, those values will be replaced and the + * old communicator and Info object will be freed. + * + * \note Raw dataset chunk caching is not currently supported when using this + * file driver in read/write mode. All calls to H5Dread() and H5Dwrite() + * will access the disk directly, and H5Pset_cache() and + * H5Pset_chunk_cache() will have no effect on performance.\n + * Raw dataset chunk caching is supported when this driver is used in + * read-only mode. + * + * \version 1.4.5 Handling of the MPI Communicator and Info object changed at + * this release. A duplicate of each of these is now stored in the property + * list instead of pointers to each. + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info); -H5_DLL herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, - MPI_Info *info/*out*/); + +/** + * \ingroup FAPL + * + * \brief Returns MPI IO communicator information + * + * \fapl_id + * \param[out] comm MPI-2 communicator + * \param[out] info MPI-2 info object + * \returns \herr_t + * + * \details If the file access property list is set to the #H5FD_MPIO driver, + * H5Pget_fapl_mpio() returns duplicates of the stored MPI communicator + * and Info object through the \p comm and \p info pointers, if those + * values are non-null. + * + * Since the MPI communicator and Info object are duplicates of the + * stored information, future modifications to the access property list + * will not affect them. It is the responsibility of the application to + * free these objects. + * + * \version 1.4.5 Handling of the MPI Communicator and Info object changed at + * this release. A duplicate of each of these is now stored in the + * property list instead of pointers to each. + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm /*out*/, MPI_Info *info /*out*/); + +/** + * \ingroup DXPL + * + * \brief Sets data transfer mode + * + * \dxpl_id + * \param[in] xfer_mode Transfer mode + * \returns \herr_t + * + * \details H5Pset_dxpl_mpio() sets the data transfer property list \p dxpl_id + * to use transfer mode \p xfer_mode. The property list can then be + * used to control the I/O transfer mode during data I/O operations. + * + * Valid transfer modes are #H5FD_MPIO_INDEPENDENT (default) and + * #H5FD_MPIO_COLLECTIVE. + * + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode); -H5_DLL herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/); + +/** + * \ingroup DXPL + * + * \brief Returns the data transfer mode + * + * \dxpl_id + * \param[out] xfer_mode Transfer mode + * \returns \herr_t + * + * \details H5Pget_dxpl_mpio() queries the data transfer mode currently set in + * the data transfer property list \p dxpl_id. + * + * Upon return, \p xfer_mode contains the data transfer mode, if it is + * non-null. + * + * H5Pget_dxpl_mpio() is not a collective function. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode /*out*/); + +/** + * \ingroup DXPL + * + * \brief Sets data transfer mode + * + * \dxpl_id + * \param[in] opt_mode Transfer mode + * \returns \herr_t + * + * \details H5Pset_dxpl_mpio() sets the data transfer property list \p dxpl_id + * to use transfer mode xfer_mode. The property list can then be used + * to control the I/O transfer mode during data I/O operations. + * + * Valid transfer modes are #H5FD_MPIO_INDEPENDENT (default) and + * #H5FD_MPIO_COLLECTIVE. + * + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collective_opt_t opt_mode); + +/** + * \ingroup DXPL + * + * \brief Sets a flag specifying linked-chunk I/O or multi-chunk I/O + * + * \dxpl_id + * \param[in] opt_mode Transfer mode + * \returns \herr_t + * + * \details H5Pset_dxpl_mpio_chunk_opt() specifies whether I/O is to be + * performed as linked-chunk I/O or as multi-chunk I/O. This function + * overrides the HDF5 library's internal algorithm for determining + * which mechanism to use. + * + * When an application uses collective I/O with chunked storage, the + * HDF5 library normally uses an internal algorithm to determine + * whether that I/O activity should be conducted as one linked-chunk + * I/O or as multi-chunk I/O. H5Pset_dxpl_mpio_chunk_opt() is provided + * so that an application can override the library's algorithm in + * circumstances where the library might lack the information needed to + * make an optimal decision. + * + * H5Pset_dxpl_mpio_chunk_opt() works by setting one of the following + * flags in the parameter \p opt_mode: + * - #H5FD_MPIO_CHUNK_ONE_IO - Do one-link chunked I/O + * - #H5FD_MPIO_CHUNK_MULTI_IO - Do multi-chunked I/O + * + * This function works by setting a corresponding property in the + * dataset transfer property list \p dxpl_id. + * + * The library performs I/O in the specified manner unless it + * determines that the low-level MPI IO package does not support the + * requested behavior; in such cases, the HDF5 library will internally + * use independent I/O. + * + * Use of this function is optional. + * + * \todo Add missing version information + * + */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode); + +/** + * \ingroup DXPL + * + * \brief Sets a numeric threshold for linked-chunk I/O + * + * \dxpl_id + * \param[in] num_chunk_per_proc + * \returns \herr_t + * + * \details H5Pset_dxpl_mpio_chunk_opt_num() sets a numeric threshold for the + * use of linked-chunk I/O. + * + * The library will calculate the average number of chunks selected by + * each process when doing collective access with chunked storage. If + * the number is greater than the threshold set in \p + * num_chunk_per_proc, the library will use linked-chunk I/O; + * otherwise, a separate I/O process will be invoked for each chunk + * (multi-chunk I/O). + * + * \todo Add missing version information + * + */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc); + +/** + * \ingroup DXPL + * + * \brief Sets a ratio threshold for collective I/O + * + * \dxpl_id + * \param[in] percent_num_proc_per_chunk + * \returns \herr_t + * + * \details H5Pset_dxpl_mpio_chunk_opt_ratio() sets a threshold for the use of + * collective I/O based on the ratio of processes with collective + * access to a dataset with chunked storage. The decision whether to + * use collective I/O is made on a per-chunk basis. + * + * The library will calculate the percentage of the total number of + * processes, the ratio, that hold selections in each chunk. If that + * percentage is greater than the threshold set in \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 + * + */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_num_proc_per_chunk); #ifdef __cplusplus } @@ -61,4 +283,3 @@ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_n #endif /* H5_HAVE_PARALLEL */ #endif - diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index d183511363d..92266244f2f 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -6,21 +6,21 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: Robb Matzke - * Monday, November 10, 1997 - * - * Purpose: Implements a file driver which dispatches I/O requests to - * other file drivers depending on the purpose of the address - * region being accessed. For instance, all meta-data could be - * place in one file while all raw data goes to some other file. - * This also serves as an example of coding a complex file driver, - * therefore, it should not use any non-public definitions. + * Programmer: Robb Matzke + * Monday, November 10, 1997 + * + * Purpose: Implements a file driver which dispatches I/O requests to + * other file drivers depending on the purpose of the address + * region being accessed. For instance, all meta-data could be + * place in one file while all raw data goes to some other file. + * This also serves as an example of coding a complex file driver, + * therefore, it should not use any non-public definitions. */ #include #include @@ -28,51 +28,62 @@ #include "hdf5.h" - #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 +#define TRUE 1 +#endif + +/* Windows doesn't like some POSIX names and redefines them with an + * underscore + */ +#ifdef _WIN32 +#define my_strdup _strdup +#else +#define my_strdup strdup #endif /* Loop through all mapped files */ -#define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) { \ - H5FD_mem_t ITER, LOOPVAR; \ - unsigned SEEN[H5FD_MEM_NTYPES]; \ - \ - memset(SEEN, 0, sizeof SEEN); \ - for (ITER=H5FD_MEM_SUPER; ITER0 && LOOPVAR 0 && LOOPVAR < H5FD_MEM_NTYPES); \ + if (SEEN[LOOPVAR]++) \ + continue; /* Need two front-ends, since they are nested sometimes */ -#define UNIQUE_MEMBERS(MAP, LOOPVAR) \ - UNIQUE_MEMBERS_CORE(MAP, _unmapped, _seen, LOOPVAR) -#define UNIQUE_MEMBERS2(MAP, LOOPVAR) \ - UNIQUE_MEMBERS_CORE(MAP, _unmapped2, _seen2, LOOPVAR) +#define UNIQUE_MEMBERS(MAP, LOOPVAR) UNIQUE_MEMBERS_CORE(MAP, _unmapped, _seen, LOOPVAR) +#define UNIQUE_MEMBERS2(MAP, LOOPVAR) UNIQUE_MEMBERS_CORE(MAP, _unmapped2, _seen2, LOOPVAR) -#define ALL_MEMBERS(LOOPVAR) { \ - H5FD_mem_t LOOPVAR; \ - for (LOOPVAR=H5FD_MEM_DEFAULT; LOOPVARsizeof(meta_name) - QK & JK - 2013/01/17 */ - strncpy(meta_name, meta_ext, sizeof(meta_name)); + strncpy(meta_name, meta_ext, sizeof(meta_name)); meta_name[sizeof(meta_name) - 1] = '\0'; } - else - sprintf(meta_name, "%%s%s", meta_ext); + else + sprintf(meta_name, "%%s%s", meta_ext); } else { - strncpy(meta_name, "%s.meta", sizeof(meta_name)); + strncpy(meta_name, "%s.meta", sizeof(meta_name)); meta_name[sizeof(meta_name) - 1] = '\0'; } memb_name[H5FD_MEM_SUPER] = meta_name; /* process raw filename */ - if(raw_ext) { - if(strstr(raw_ext, "%s")) { + if (raw_ext) { + if (strstr(raw_ext, "%s")) { /* Note: this doesn't accommodate for when the '%s' in the user's * string is at a position >sizeof(raw_name) - QK & JK - 2013/01/17 */ - strncpy(raw_name, raw_ext, sizeof(raw_name)); + strncpy(raw_name, raw_ext, sizeof(raw_name)); raw_name[sizeof(raw_name) - 1] = '\0'; } - else - sprintf(raw_name, "%%s%s", raw_ext); + else + sprintf(raw_name, "%%s%s", raw_ext); } else { - strncpy(raw_name, "%s.raw", sizeof(raw_name)); + strncpy(raw_name, "%s.raw", sizeof(raw_name)); raw_name[sizeof(raw_name) - 1] = '\0'; } memb_name[H5FD_MEM_DRAW] = raw_name; /* The sizes */ memb_addr[H5FD_MEM_SUPER] = 0; - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2; + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; return H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE); } - /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_multi + * Function: H5Pset_fapl_multi * - * Purpose: Sets the file access property list FAPL_ID to use the multi - * driver. The MEMB_MAP array maps memory usage types to other - * memory usage types and is the mechanism which allows the - * caller to specify how many files are created. The array - * contains H5FD_MEM_NTYPES entries which are either the value - * H5FD_MEM_DEFAULT or a memory usage type and the number of - * unique values determines the number of files which are - * opened. For each memory usage type which will be associated - * with a file the MEMB_FAPL array should have a property list - * and the MEMB_NAME array should be a name generator (a - * printf-style format with a %s which will be replaced with the - * name passed to H5FDopen(), usually from H5Fcreate() or - * H5Fopen()). + * Purpose: Sets the file access property list FAPL_ID to use the multi + * driver. The MEMB_MAP array maps memory usage types to other + * memory usage types and is the mechanism which allows the + * caller to specify how many files are created. The array + * contains H5FD_MEM_NTYPES entries which are either the value + * H5FD_MEM_DEFAULT or a memory usage type and the number of + * unique values determines the number of files which are + * opened. For each memory usage type which will be associated + * with a file the MEMB_FAPL array should have a property list + * and the MEMB_NAME array should be a name generator (a + * printf-style format with a %s which will be replaced with the + * name passed to H5FDopen(), usually from H5Fcreate() or + * H5Fopen()). * - * If RELAX is set then opening an existing file for read-only - * access will not fail if some file members are missing. This - * allows a file to be accessed in a limited sense if just the - * meta data is available. + * If RELAX is set then opening an existing file for read-only + * access will not fail if some file members are missing. This + * allows a file to be accessed in a limited sense if just the + * meta data is available. * - * Defaults: Default values for each of the optional arguments are: + * Defaults: Default values for each of the optional arguments are: * - * memb_map: The default member map has the value - * H5FD_MEM_DEFAULT for each element. + * memb_map: The default member map has the value + * H5FD_MEM_DEFAULT for each element. * - * memb_fapl: The value H5P_DEFAULT for each element. + * memb_fapl: The value H5P_DEFAULT for each element. * - * memb_name: The string `%s-X.h5' where `X' is one of the - * letters `s' (H5FD_MEM_SUPER), - * `b' (H5FD_MEM_BTREE), `r' (H5FD_MEM_DRAW), - * `g' (H5FD_MEM_GHEAP), 'l' (H5FD_MEM_LHEAP), - * `o' (H5FD_MEM_OHDR). + * memb_name: The string `%s-X.h5' where `X' is one of the + * letters `s' (H5FD_MEM_SUPER), + * `b' (H5FD_MEM_BTREE), `r' (H5FD_MEM_DRAW), + * `g' (H5FD_MEM_GHEAP), 'l' (H5FD_MEM_LHEAP), + * `o' (H5FD_MEM_OHDR). * - * memb_addr: The value HADDR_UNDEF for each element. + * memb_addr: The value HADDR_UNDEF for each element. * * - * Example: To set up a multi file access property list which partitions - * data into meta and raw files each being 1/2 of the address - * space one would say: + * Example: To set up a multi file access property list which partitions + * data into meta and raw files each being 1/2 of the address + * space one would say: * - * H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - * hid_t memb_fapl[H5FD_MEM_NTYPES]; - * const char *memb[H5FD_MEM_NTYPES]; - * haddr_t memb_addr[H5FD_MEM_NTYPES]; + * H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + * hid_t memb_fapl[H5FD_MEM_NTYPES]; + * const char *memb[H5FD_MEM_NTYPES]; + * haddr_t memb_addr[H5FD_MEM_NTYPES]; * - * // The mapping... - * for (mt=0; mt=H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1) - if (H5FD_MEM_DEFAULT==mmt) mmt = mt; - - /* - * All members of MEMB_FAPL must be either defaults or actual file - * access property lists. - */ - if (H5P_DEFAULT!=memb_fapl[mmt] && TRUE!=H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1) - - /* All names must be defined */ - if (!memb_name[mmt] || !memb_name[mmt][0]) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1) + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + /* Map usage type */ + mmt = memb_map[mt]; + if (mmt < 0 || mmt >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); + if (H5FD_MEM_DEFAULT == mmt) + mmt = mt; + + /* + * All members of MEMB_FAPL must be either defaults or actual file + * access property lists. + */ + if (H5P_DEFAULT != memb_fapl[mmt] && TRUE != H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); + + /* All names must be defined */ + if (!memb_name[mmt] || !memb_name[mmt][0]) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); } /* @@ -492,97 +463,93 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, * struct since all members will be copied by H5Pset_driver(). */ memset(&fa, 0, sizeof(H5FD_multi_fapl_t)); - memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); - memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t)); - memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*)); - memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); + memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); + memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES * sizeof(hid_t)); + memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES * sizeof(char *)); + memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); fa.relax = relax; /* Patch up H5P_DEFAULT property lists for members */ - for (mt=H5FD_MEM_DEFAULT; mtmemb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); + memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); if (memb_fapl) { - for (mt=H5FD_MEM_DEFAULT; mtmemb_fapl[mt]>=0) - memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); - else - memb_fapl[mt] = fa->memb_fapl[mt]; /*default or bad ID*/ - } + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (fa->memb_fapl[mt] >= 0) + memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]); + else + memb_fapl[mt] = fa->memb_fapl[mt]; /*default or bad ID*/ + } } - if(memb_name) { - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - if(fa->memb_name[mt]) - memb_name[mt] = my_strdup(fa->memb_name[mt]); - else - memb_name[mt] = NULL; - } + if (memb_name) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (fa->memb_name[mt]) + memb_name[mt] = my_strdup(fa->memb_name[mt]); + else + memb_name[mt] = NULL; + } } if (memb_addr) - memcpy(memb_addr, fa->memb_addr, H5FD_MEM_NTYPES*sizeof(haddr_t)); + memcpy(memb_addr, fa->memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); if (relax) - *relax = fa->relax; + *relax = fa->relax; return 0; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_size + * Function: H5FD_multi_sb_size * - * Purpose: Returns the size of the private information to be stored in - * the superblock. + * Purpose: Returns the size of the private information to be stored in + * the superblock. * - * Return: Success: The super block driver data size. + * Return: Success: The super block driver data size. * - * Failure: never fails + * Failure: never fails * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- @@ -590,65 +557,65 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, static hsize_t H5FD_multi_sb_size(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - unsigned nseen = 0; - hsize_t nbytes = 8; /*size of header*/ + H5FD_multi_t *file = (H5FD_multi_t *)_file; + unsigned nseen = 0; + hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* How many unique files? */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - nseen++; - } END_MEMBERS; + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + nseen++; + } + END_MEMBERS; /* Addresses and EOA markers */ nbytes += nseen * 2 * 8; /* Name templates */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - size_t n = strlen(file->fa.memb_name[mt])+1; - nbytes += (n+7) & ~((size_t)0x0007); - } END_MEMBERS; + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + size_t n = strlen(file->fa.memb_name[mt]) + 1; + nbytes += (n + 7) & ~((size_t)0x0007); + } + END_MEMBERS; return nbytes; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_encode + * Function: H5FD_multi_sb_encode * - * Purpose: Encode driver information for the superblock. The NAME - * argument is a nine-byte buffer which will be initialized with - * an eight-character name/version number and null termination. + * Purpose: Encode driver information for the superblock. The NAME + * argument is a nine-byte buffer which will be initialized with + * an eight-character name/version number and null termination. * - * The encoding is a six-byte member mapping followed two bytes - * which are unused. For each unique file in usage-type order - * encode all the starting addresses as unsigned 64-bit integers, - * then all the EOA values as unsigned 64-bit integers, then all - * the template names as null terminated strings which are - * multiples of 8 characters. + * The encoding is a six-byte member mapping followed two bytes + * which are unused. For each unique file in usage-type order + * encode all the starting addresses as unsigned 64-bit integers, + * then all the EOA values as unsigned 64-bit integers, then all + * the template names as null terminated strings which are + * multiples of 8 characters. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, - unsigned char *buf/*out*/) +H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - haddr_t memb_eoa; - unsigned char *p; - size_t nseen; - size_t i; - H5FD_mem_t m; - static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + haddr_t memb_eoa; + unsigned char * p; + size_t nseen; + size_t i; + H5FD_mem_t m; + static const char *func = "H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -657,10 +624,10 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, strncpy(name, "NCSAmulti", (size_t)8); name[8] = '\0'; - assert(7==H5FD_MEM_NTYPES); + assert(7 == H5FD_MEM_NTYPES); - for (m=H5FD_MEM_SUPER; mfa.memb_map[m]; + for (m = H5FD_MEM_SUPER; m < H5FD_MEM_NTYPES; m = (H5FD_mem_t)(m + 1)) { + buf[m - 1] = (unsigned char)file->fa.memb_map[m]; } buf[6] = 0; buf[7] = 0; @@ -672,49 +639,50 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, /* Encode all starting addresses and EOA values */ nseen = 0; - p = buf+8; - assert(sizeof(haddr_t)<=8); - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + p = buf + 8; + assert(sizeof(haddr_t) <= 8); + UNIQUE_MEMBERS (file->fa.memb_map, mt) { memcpy(p, &(file->fa.memb_addr[mt]), sizeof(haddr_t)); p += sizeof(haddr_t); memb_eoa = H5FDget_eoa(file->memb[mt], mt); memcpy(p, &memb_eoa, sizeof(haddr_t)); p += sizeof(haddr_t); nseen++; - } END_MEMBERS; - if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen*2, buf+8, NULL, H5P_DEFAULT)<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) + } + END_MEMBERS; + if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen * 2, buf + 8, NULL, H5P_DEFAULT) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); /* Encode all name templates */ - p = buf + 8 + nseen*2*8; - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + 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); p += n; - for (i=n; i%8; i++) + for (i = n; i % 8; i++) *p++ = '\0'; - } END_MEMBERS; + } + END_MEMBERS; return 0; } /* end H5FD_multi_sb_encode() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_sb_decode + * Function: H5FD_multi_sb_decode * - * Purpose: Decodes the superblock information for this driver. The NAME - * argument is the eight-character (plus null termination) name - * stored in the file. + * Purpose: Decodes the superblock information for this driver. The NAME + * argument is the eight-character (plus null termination) name + * stored in the file. * - * The FILE argument is updated according to the information in - * the superblock. This may mean that some member files are - * closed and others are opened. + * The FILE argument is updated according to the information in + * the superblock. This may mean that some member files are + * closed and others are opened. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 16, 1999 * *------------------------------------------------------------------------- @@ -722,67 +690,72 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*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; - 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]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - haddr_t memb_eoa[H5FD_MEM_NTYPES]; - haddr_t *ap; - static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ + 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]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + haddr_t memb_eoa[H5FD_MEM_NTYPES]; + haddr_t * ap; + static const char *func = "H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Make sure the name/version number is correct */ - if (strcmp(name, "NCSAmult")) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1) + if (strcmp(name, "NCSAmult") != 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1); /* Set default values */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { memb_addr[mt] = HADDR_UNDEF; - memb_eoa[mt] = HADDR_UNDEF; + memb_eoa[mt] = HADDR_UNDEF; memb_name[mt] = NULL; - } END_MEMBERS; + } + END_MEMBERS; /* * Read the map and count the unique members. */ memset(map, 0, sizeof map); - for (i=0; i<6; i++) { - map[i+1] = (H5FD_mem_t)buf[i]; - if (file->fa.memb_map[i+1]!=map[i+1]) - map_changed=TRUE; + for (i = 0; i < 6; i++) { + map[i + 1] = (H5FD_mem_t)buf[i]; + if (file->fa.memb_map[i + 1] != map[i + 1]) + map_changed = TRUE; } - UNIQUE_MEMBERS(map, mt) { + UNIQUE_MEMBERS (map, mt) { nseen++; - } END_MEMBERS; + } + END_MEMBERS; buf += 8; /* Decode Address and EOA values */ - assert(sizeof(haddr_t)<=8); - memcpy(x, buf, (nseen*2*8)); - buf += nseen*2*8; - if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, H5P_DEFAULT)<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1) - ap = (haddr_t*)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */ - UNIQUE_MEMBERS(map, mt) { + assert(sizeof(haddr_t) <= 8); + memcpy(x, buf, (nseen * 2 * 8)); + buf += nseen * 2 * 8; + if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen * 2, x, NULL, H5P_DEFAULT) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); + ap = (haddr_t *)((void *)x); /* Extra (void *) cast to quiet "cast to create alignment" warning - + 2019/07/05, QAK */ + UNIQUE_MEMBERS (map, mt) { memb_addr[_unmapped] = *ap++; - memb_eoa[_unmapped] = *ap++; - } END_MEMBERS; + memb_eoa[_unmapped] = *ap++; + } + END_MEMBERS; /* Decode name templates */ - UNIQUE_MEMBERS(map, mt) { - size_t n = strlen((const char *)buf)+1; + UNIQUE_MEMBERS (map, mt) { + size_t n = strlen((const char *)buf) + 1; memb_name[_unmapped] = (const char *)buf; - buf += (n+7) & ~((unsigned)0x0007); - } END_MEMBERS; + buf += (n + 7) & ~((unsigned)0x0007); + } + END_MEMBERS; /* * Use the mapping saved in the superblock in preference to the one @@ -792,67 +765,72 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) */ if (map_changed) { /* Commit map */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; + } + END_MEMBERS; /* Close files which are unused now */ memset(in_use, 0, sizeof in_use); - UNIQUE_MEMBERS(map, mt) { + UNIQUE_MEMBERS (map, mt) { in_use[mt] = TRUE; - } END_MEMBERS; - ALL_MEMBERS(mt) { + } + END_MEMBERS; + ALL_MEMBERS (mt) { if (!in_use[mt] && file->memb[mt]) { (void)H5FDclose(file->memb[mt]); file->memb[mt] = NULL; } file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; + } + END_MEMBERS; } /* Commit member starting addresses and name templates */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { file->fa.memb_addr[mt] = memb_addr[mt]; if (memb_name[mt]) { if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); file->fa.memb_name[mt] = my_strdup(memb_name[mt]); } - } END_MEMBERS; - if (compute_next(file)<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1) + } + END_MEMBERS; + if (compute_next(file) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1); /* Open all necessary files */ - if (open_members(file)<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1) + if (open_members(file) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1); /* Set the EOA marker for all open files */ - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + UNIQUE_MEMBERS (file->fa.memb_map, mt) { if (file->memb[mt]) - if(H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt])<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1) + if (H5FDset_eoa(file->memb[mt], mt, memb_eoa[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "set_eoa() failed", -1); - /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) */ + /* Save the individual EOAs in one place for later comparison (in H5FD_multi_set_eoa) + */ file->memb_eoa[mt] = memb_eoa[mt]; - } END_MEMBERS; + } + END_MEMBERS; return 0; } /* end H5FD_multi_sb_decode() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_get + * Function: H5FD_multi_fapl_get * - * Purpose: Returns a file access property list which indicates how the - * specified file is being accessed. The return list could be - * used to access another file the same way. + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. * - * Return: Success: Ptr to new file access property list with all - * members copied from the file struct. + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * *------------------------------------------------------------------------- @@ -860,7 +838,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) static void * H5FD_multi_fapl_get(H5FD_t *_file) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -868,17 +846,16 @@ H5FD_multi_fapl_get(H5FD_t *_file) return H5FD_multi_fapl_copy(&(file->fa)); } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_copy + * Function: H5FD_multi_fapl_copy * - * Purpose: Copies the multi-specific file access properties. + * Purpose: Copies the multi-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -886,10 +863,10 @@ H5FD_multi_fapl_get(H5FD_t *_file) 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)); - int nerrors = 0; - static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */ + 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)); + int nerrors = 0; + static const char * func = "H5FD_multi_fapl_copy"; /* Function Name for error reporting */ assert(new_fa); @@ -897,47 +874,48 @@ H5FD_multi_fapl_copy(const void *_old_fa) H5Eclear2(H5E_DEFAULT); memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); - ALL_MEMBERS(mt) { - if (old_fa->memb_fapl[mt]>=0) { - if (H5Iinc_ref(old_fa->memb_fapl[mt]) < 0) { + ALL_MEMBERS (mt) { + if (old_fa->memb_fapl[mt] >= 0) { + if (H5Iinc_ref(old_fa->memb_fapl[mt]) < 0) { nerrors++; break; } - new_fa->memb_fapl[mt] = old_fa->memb_fapl[mt]; - } - if (old_fa->memb_name[mt]) { - new_fa->memb_name[mt] = my_strdup(old_fa->memb_name[mt]); + new_fa->memb_fapl[mt] = old_fa->memb_fapl[mt]; + } + if (old_fa->memb_name[mt]) { + new_fa->memb_name[mt] = my_strdup(old_fa->memb_name[mt]); if (NULL == new_fa->memb_name[mt]) { nerrors++; break; } - } - } END_MEMBERS; + } + } + END_MEMBERS; if (nerrors) { - ALL_MEMBERS(mt) { - if (new_fa->memb_fapl[mt]>=0) + ALL_MEMBERS (mt) { + if (new_fa->memb_fapl[mt] >= 0) (void)H5Idec_ref(new_fa->memb_fapl[mt]); if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]); - } END_MEMBERS; + } + END_MEMBERS; free(new_fa); - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL); } return new_fa; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_fapl_free + * Function: H5FD_multi_fapl_free * - * Purpose: Frees the multi-specific file access properties. + * Purpose: Frees the multi-specific file access properties. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -945,37 +923,37 @@ H5FD_multi_fapl_copy(const void *_old_fa) static herr_t H5FD_multi_fapl_free(void *_fa) { - H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t*)_fa; - static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ + H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t *)_fa; + static const char *func = "H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - if (fa->memb_fapl[mt]>=0) - if(H5Idec_ref(fa->memb_fapl[mt])<0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1) - if (fa->memb_name[mt]) + ALL_MEMBERS (mt) { + if (fa->memb_fapl[mt] >= 0) + if (H5Idec_ref(fa->memb_fapl[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", -1); + if (fa->memb_name[mt]) free(fa->memb_name[mt]); - } END_MEMBERS; + } + END_MEMBERS; free(fa); return 0; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_open + * Function: H5FD_multi_open * - * Purpose: Creates and/or opens a multi HDF5 file. + * Purpose: Creates and/or opens a multi HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -983,20 +961,20 @@ 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; - hid_t close_fapl=-1; + 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 */ + H5FD_mem_t m; + static const char * func = "H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); /* * Initialize the file from the file access properties, using default @@ -1004,17 +982,17 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr * in H5FD_multi_set_eoa depends on the proper initialization of memb_eoa * in H5FD_multi_t. */ - if(NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) - if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) { + if (NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); + if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) { close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if(H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) } fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); assert(fa); - ALL_MEMBERS(mt) { - file->fa.memb_map[mt] = fa->memb_map[mt]; + ALL_MEMBERS (mt) { + file->fa.memb_map[mt] = fa->memb_map[mt]; file->fa.memb_addr[mt] = fa->memb_addr[mt]; if (fa->memb_fapl[mt] >= 0) H5Iinc_ref(fa->memb_fapl[mt]); @@ -1023,17 +1001,18 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->fa.memb_name[mt] = my_strdup(fa->memb_name[mt]); else file->fa.memb_name[mt] = NULL; - } END_MEMBERS; + } + END_MEMBERS; file->fa.relax = fa->relax; - file->flags = flags; - file->name = my_strdup(name); + file->flags = flags; + file->name = my_strdup(name); if (close_fapl >= 0) - if(H5Pclose(close_fapl) < 0) + if (H5Pclose(close_fapl) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTCLOSEOBJ, "can't close property list", error) - /* Compute derived properties and open member files */ - if (compute_next(file) < 0) - H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error); + /* Compute derived properties and open member files */ + if (compute_next(file) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, + "compute_next() failed", error); if (open_members(file) < 0) H5Epush_goto(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error); @@ -1043,16 +1022,20 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr if (NULL == file->memb[m]) goto error; - return (H5FD_t*)file; + return (H5FD_t *)file; error: /* Cleanup and fail */ if (file) { - ALL_MEMBERS(mt) { - if (file->memb[mt]) (void)H5FDclose(file->memb[mt]); - if (file->fa.memb_fapl[mt] >= 0) (void)H5Idec_ref(file->fa.memb_fapl[mt]); - if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) + (void)H5FDclose(file->memb[mt]); + if (file->fa.memb_fapl[mt] >= 0) + (void)H5Idec_ref(file->fa.memb_fapl[mt]); + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + } + END_MEMBERS; if (file->name) free(file->name); free(file); @@ -1060,19 +1043,18 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr return NULL; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_close + * Function: H5FD_multi_close * - * Purpose: Closes a multi file. + * Purpose: Closes a multi file. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative with as many members closed as - * possible. The only subsequent operation - * permitted on the file is a close operation. + * Failure: Negative with as many members closed as + * possible. The only subsequent operation + * permitted on the file is a close operation. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1080,53 +1062,56 @@ 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; - int nerrors=0; - static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + int nerrors = 0; + static const char *func = "H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Close as many members as possible */ - ALL_MEMBERS(mt) { - if (file->memb[mt]) { - if (H5FDclose(file->memb[mt])<0) { - nerrors++; - } else { - file->memb[mt] = NULL; - } - } - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) { + if (H5FDclose(file->memb[mt]) < 0) { + nerrors++; + } + else { + file->memb[mt] = NULL; + } + } + } + END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1); /* Clean up other stuff */ - ALL_MEMBERS(mt) { - if (file->fa.memb_fapl[mt]>=0) (void)H5Idec_ref(file->fa.memb_fapl[mt]); - if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->fa.memb_fapl[mt] >= 0) + (void)H5Idec_ref(file->fa.memb_fapl[mt]); + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + } + END_MEMBERS; free(file->name); free(file); return 0; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_cmp + * Function: H5FD_multi_cmp * - * Purpose: Compares two file families to see if they are the same. It - * does this by comparing the first common member of the two - * families. If the families have no members in common then the - * file with the earliest member is smaller than the other file. - * We abort if neither file has any members. + * Purpose: Compares two file families to see if they are the same. It + * does this by comparing the first common member of the two + * families. If the families have no members in common then the + * file with the earliest member is smaller than the other file. + * We abort if neither file has any members. * - * Return: Success: like strcmp() + * Return: Success: like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by th caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1134,44 +1119,44 @@ H5FD_multi_close(H5FD_t *_file) static int H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_multi_t *f1 = (const H5FD_multi_t*)_f1; - const H5FD_multi_t *f2 = (const H5FD_multi_t*)_f2; - H5FD_mem_t out_mt = H5FD_MEM_DEFAULT; - int cmp=0; + const H5FD_multi_t *f1 = (const H5FD_multi_t *)_f1; + const H5FD_multi_t *f2 = (const H5FD_multi_t *)_f2; + H5FD_mem_t out_mt = H5FD_MEM_DEFAULT; + int cmp = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { out_mt = mt; - if(f1->memb[mt] && f2->memb[mt]) + if (f1->memb[mt] && f2->memb[mt]) break; - if(!cmp) { - if(f1->memb[mt]) + if (!cmp) { + if (f1->memb[mt]) cmp = -1; - else if(f2->memb[mt]) + else if (f2->memb[mt]) cmp = 1; - } - } END_MEMBERS; - assert(cmp || out_mt=H5FD_MEM_NTYPES) + } + } + END_MEMBERS; + assert(cmp || out_mt < H5FD_MEM_NTYPES); + if (out_mt >= H5FD_MEM_NTYPES) return cmp; return H5FDcmp(f1->memb[out_mt], f2->memb[out_mt]); } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_query + * Function: H5FD_multi_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, September 26, 2000 * *------------------------------------------------------------------------- @@ -1180,30 +1165,29 @@ static herr_t H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ - _f=_f; + (void)_f; /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_USE_ALLOC_SIZE; /* OK just pass the allocation size to the alloc callback */ - *flags |= H5FD_FEAT_PAGED_AGGR; /* OK special file space mapping for paged aggregation */ - } /* end if */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_USE_ALLOC_SIZE; /* OK just pass the allocation size to the alloc callback */ + *flags |= H5FD_FEAT_PAGED_AGGR; /* OK special file space mapping for paged aggregation */ + } /* end if */ - return(0); + return (0); } /* end H5FD_multi_query() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_type_map + * Function: H5FD_multi_get_type_map * - * Purpose: Retrieve the memory type mapping for this file + * Purpose: Retrieve the memory type mapping for this file * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 9, 2008 * *------------------------------------------------------------------------- @@ -1211,27 +1195,26 @@ H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) static herr_t H5FD_multi_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) { - const H5FD_multi_t *file = (const H5FD_multi_t*)_file; + const H5FD_multi_t *file = (const H5FD_multi_t *)_file; /* Copy file's free space type mapping */ memcpy(type_map, file->fa.memb_map, sizeof(file->fa.memb_map)); - return(0); + return (0); } /* end H5FD_multi_get_type_map() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_eoa + * Function: H5FD_multi_get_eoa * - * Purpose: Returns the end-of-address marker for the file. The EOA - * marker is the first address past the last byte allocated in - * the format address space. + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. * - * Return: Success: The end-of-address-marker + * Return: Success: The end-of-address-marker * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1239,9 +1222,9 @@ H5FD_multi_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) static haddr_t 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 */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1252,78 +1235,89 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) * Here the code finds the biggest EOA for individual file if * the query is for TYPE == H5FD_MEM_DEFAULT. */ - if(H5FD_MEM_DEFAULT == type) { - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + if (H5FD_MEM_DEFAULT == type) { + UNIQUE_MEMBERS (file->fa.memb_map, mt) { haddr_t memb_eoa; - if (file->memb[mt]) { + if (file->memb[mt]) { /* Retrieve EOA */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { memb_eoa = H5FDget_eoa(file->memb[mt], mt); - } H5E_END_TRY; + } + H5E_END_TRY; - if(HADDR_UNDEF == memb_eoa) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", HADDR_UNDEF) - if(memb_eoa>0) + if (HADDR_UNDEF == memb_eoa) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", + HADDR_UNDEF); + if (memb_eoa > 0) memb_eoa += file->fa.memb_addr[mt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - memb_eoa = file->memb_next[mt]; - assert(HADDR_UNDEF != memb_eoa); - } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) - } - - if(memb_eoa > eoa) + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + memb_eoa = file->memb_next[mt]; + assert(HADDR_UNDEF != memb_eoa); + } + else { + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF); + } + + if (memb_eoa > eoa) eoa = memb_eoa; - } END_MEMBERS; - } else { + } + END_MEMBERS; + } + else { H5FD_mem_t mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) + if (H5FD_MEM_DEFAULT == mmt) mmt = type; - if(file->memb[mmt]) { - H5E_BEGIN_TRY { - eoa = H5FDget_eoa(file->memb[mmt], mmt); - } H5E_END_TRY; + if (file->memb[mmt]) { + H5E_BEGIN_TRY + { + eoa = H5FDget_eoa(file->memb[mmt], mmt); + } + H5E_END_TRY; - if(HADDR_UNDEF == eoa) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", HADDR_UNDEF) - if(eoa > 0) + if (HADDR_UNDEF == eoa) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", + HADDR_UNDEF); + if (eoa > 0) eoa += file->fa.memb_addr[mmt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - eoa = file->memb_next[mmt]; - assert(HADDR_UNDEF != eoa); - } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF) - } + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + eoa = file->memb_next[mmt]; + assert(HADDR_UNDEF != eoa); + } + else { + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eoa", HADDR_UNDEF); + } } return eoa; } /* end H5FD_multi_get_eoa() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_set_eoa + * Function: H5FD_multi_set_eoa * - * Purpose: Set the end-of-address marker for the file by savig the new - * EOA value in the file struct. Also set the EOA marker for the - * subfile in which the new EOA value falls. We don't set the - * EOA values of any other subfiles. + * Purpose: Set the end-of-address marker for the file by savig the new + * EOA value in the file struct. Also set the EOA marker for the + * subfile in which the new EOA value falls. We don't set the + * EOA values of any other subfiles. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1331,17 +1325,17 @@ 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_mem_t mmt; - herr_t status; - static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) { - if(H5FD_MEM_DEFAULT == type) + if (H5FD_MEM_DEFAULT == mmt) { + if (H5FD_MEM_DEFAULT == type) mmt = H5FD_MEM_SUPER; else mmt = type; @@ -1357,35 +1351,37 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) * address, the EOAs of v1.6 and v1.8 files are the same. It won't cause * any trouble. (Please see Issue 2598 in Jira) SLU - 2011/6/21 */ - if(H5FD_MEM_SUPER == mmt && file->memb_eoa[H5FD_MEM_SUPER] > 0 && eoa > (file->memb_next[H5FD_MEM_SUPER] / 2)) + if (H5FD_MEM_SUPER == mmt && file->memb_eoa[H5FD_MEM_SUPER] > 0 && + eoa > (file->memb_next[H5FD_MEM_SUPER] / 2)) return 0; assert(eoa >= file->fa.memb_addr[mmt]); assert(eoa < file->memb_next[mmt]); - H5E_BEGIN_TRY { - status = H5FDset_eoa(file->memb[mmt], mmt, (eoa - file->fa.memb_addr[mmt])); - } H5E_END_TRY; - if(status < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1) + H5E_BEGIN_TRY + { + status = H5FDset_eoa(file->memb[mmt], mmt, (eoa - file->fa.memb_addr[mmt])); + } + H5E_END_TRY; + if (status < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1); return 0; } /* end H5FD_multi_set_eoa() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_get_eof + * Function: H5FD_multi_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the total multi size or the current EOA marker. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the total multi size or the current EOA marker. * - * Return: Success: End of file address, the first address past - * the end of the multi of files or the current - * EOA, whichever is larger. + * Return: Success: End of file address, the first address past + * the end of the multi of files or the current + * EOA, whichever is larger. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1393,71 +1389,82 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) static haddr_t 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 */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(H5FD_MEM_DEFAULT == type) { - UNIQUE_MEMBERS(file->fa.memb_map, mt) { + if (H5FD_MEM_DEFAULT == type) { + UNIQUE_MEMBERS (file->fa.memb_map, mt) { haddr_t tmp_eof; - if(file->memb[mt]) { + if (file->memb[mt]) { /* Retrieve EOF */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { tmp_eof = H5FDget_eof(file->memb[mt], type); - } H5E_END_TRY; + } + H5E_END_TRY; - if(HADDR_UNDEF == tmp_eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF) - if(tmp_eof > 0) + if (HADDR_UNDEF == tmp_eof) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", + HADDR_UNDEF); + if (tmp_eof > 0) tmp_eof += file->fa.memb_addr[mt]; - } else if(file->fa.relax) { + } + else if (file->fa.relax) { /* * The member is not open yet (maybe it doesn't exist). Make the * best guess about the end-of-file. */ tmp_eof = file->memb_next[mt]; assert(HADDR_UNDEF != tmp_eof); - } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) } - if(tmp_eof > eof) + else { + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); + } + if (tmp_eof > eof) eof = tmp_eof; - } END_MEMBERS; - } else { + } + END_MEMBERS; + } + else { H5FD_mem_t mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT == mmt) + if (H5FD_MEM_DEFAULT == mmt) mmt = type; - if(file->memb[mmt]) { + if (file->memb[mmt]) { /* Retrieve EOF */ - H5E_BEGIN_TRY { - eof = H5FDget_eof(file->memb[mmt], mmt); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + eof = H5FDget_eof(file->memb[mmt], mmt); + } + H5E_END_TRY; - if(HADDR_UNDEF == eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF) - if(eof > 0) + if (HADDR_UNDEF == eof) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", + HADDR_UNDEF); + if (eof > 0) eof += file->fa.memb_addr[mmt]; - } else if(file->fa.relax) { - /* - * The member is not open yet (maybe it doesn't exist). Make the - * best guess about the end-of-file. - */ - eof = file->memb_next[mmt]; - assert(HADDR_UNDEF != eof); - } else { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF) - } + } + else if (file->fa.relax) { + /* + * The member is not open yet (maybe it doesn't exist). Make the + * best guess about the end-of-file. + */ + eof = file->memb_next[mmt]; + assert(HADDR_UNDEF != eof); + } + else { + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF); + } } return eof; } - /*------------------------------------------------------------------------- * Function: H5FD_multi_get_handle * @@ -1471,34 +1478,35 @@ 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_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - 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 */ + 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 */ /* Get data type for multi driver */ - if(H5Pget_multi_type(fapl, &type) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", -1) - if(type=H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1) + if (H5Pget_multi_type(fapl, &type) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't get data type for multi driver", + -1); + if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "data type is out of range", -1); mmt = file->fa.memb_map[type]; - if(H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; return (H5FDget_vfd_handle(file->memb[mmt], fapl, file_handle)); } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_alloc + * Function: H5FD_multi_alloc * - * Purpose: Allocate file memory. + * Purpose: Allocate file memory. * - * Return: Success: Address of new memory + * Return: Success: Address of new memory * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 12, 1999 * *------------------------------------------------------------------------- @@ -1506,54 +1514,55 @@ 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_mem_t mmt; - haddr_t addr; - static const char *func="H5FD_multi_alloc"; /* Function Name for error reporting */ + 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 */ mmt = file->fa.memb_map[type]; - if (H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; /* XXX: NEED to work on this again */ - if(file->pub.paged_aggr) { - ALL_MEMBERS(mt) { - if(file->memb[mt]) + if (file->pub.paged_aggr) { + ALL_MEMBERS (mt) { + if (file->memb[mt]) file->memb[mt]->paged_aggr = file->pub.paged_aggr; - } END_MEMBERS; + } + END_MEMBERS; } - if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF) + if (HADDR_UNDEF == (addr = H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF); addr += file->fa.memb_addr[mmt]; -/*#ifdef TMP - if ( addr + size > file->eoa ) { + /*#ifdef TMP + if ( addr + size > file->eoa ) { - if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { + if ( H5FD_multi_set_eoa(_file, addr + size) < 0 ) { - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, \ - "can't set eoa", HADDR_UNDEF) - } - } -#else - if ( addr + size > file->eoa ) - file->eoa = addr + size; -#endif */ + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, \ + "can't set eoa", HADDR_UNDEF); + } + } + #else + if ( addr + size > file->eoa ) + file->eoa = addr + size; + #endif */ return addr; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_free + * Function: H5FD_multi_free * - * Purpose: Frees memory + * Purpose: Frees memory * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 12, 1999 * *------------------------------------------------------------------------- @@ -1561,128 +1570,124 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) static herr_t H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mmt; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mmt; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); mmt = file->fa.memb_map[type]; - if (H5FD_MEM_DEFAULT==mmt) mmt = type; + if (H5FD_MEM_DEFAULT == mmt) + mmt = type; - assert(addr>=file->fa.memb_addr[mmt]); - assert(addr+size<=file->memb_next[mmt]); - return H5FDfree(file->memb[mmt], mmt, dxpl_id, addr-file->fa.memb_addr[mmt], size); + assert(addr >= file->fa.memb_addr[mmt]); + assert(addr + size <= file->memb_next[mmt]); + return H5FDfree(file->memb[mmt], mmt, dxpl_id, addr - file->fa.memb_addr[mmt], size); } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_read + * Function: H5FD_multi_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, contents of buffer BUF are undefined. + * Failure: -1, contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *_buf/*out*/) +H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf /*out*/) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; - haddr_t start_addr = 0; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; + haddr_t start_addr = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Find the file to which this address belongs */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - mmt = file->fa.memb_map[mt]; - if(H5FD_MEM_DEFAULT == mmt) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + mmt = file->fa.memb_map[mt]; + if (H5FD_MEM_DEFAULT == mmt) mmt = mt; - assert(mmt > 0 && mmt < H5FD_MEM_NTYPES); + assert(mmt > 0 && mmt < H5FD_MEM_NTYPES); - if(file->fa.memb_addr[mmt] > addr) + if (file->fa.memb_addr[mmt] > addr) continue; - if(file->fa.memb_addr[mmt] >= start_addr) { - start_addr = file->fa.memb_addr[mmt]; - hi = mmt; - } /* end if */ - } /* end for */ + if (file->fa.memb_addr[mmt] >= start_addr) { + start_addr = file->fa.memb_addr[mmt]; + hi = mmt; + } /* end if */ + } /* end for */ assert(hi > 0); /* Read from that member */ return H5FDread(file->memb[hi], type, dxpl_id, addr - start_addr, size, _buf); } /* end H5FD_multi_read() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_write + * Function: H5FD_multi_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *_buf) +H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; - haddr_t start_addr = 0; + H5FD_multi_t *file = (H5FD_multi_t *)_file; + H5FD_mem_t mt, mmt, hi = H5FD_MEM_DEFAULT; + haddr_t start_addr = 0; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Find the file to which this address belongs */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - mmt = file->fa.memb_map[mt]; - if(H5FD_MEM_DEFAULT == mmt) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + mmt = file->fa.memb_map[mt]; + if (H5FD_MEM_DEFAULT == mmt) mmt = mt; - assert(mmt > 0 && mmt 0 && mmt < H5FD_MEM_NTYPES); - if(file->fa.memb_addr[mmt] > addr) + if (file->fa.memb_addr[mmt] > addr) continue; - if(file->fa.memb_addr[mmt] >= start_addr) { - start_addr = file->fa.memb_addr[mmt]; - hi = mmt; - } /* end if */ - } /* end for */ + if (file->fa.memb_addr[mmt] >= start_addr) { + start_addr = file->fa.memb_addr[mmt]; + hi = mmt; + } /* end if */ + } /* end for */ assert(hi > 0); /* Write to that member */ return H5FDwrite(file->memb[hi], type, dxpl_id, addr - start_addr, size, _buf); } /* end H5FD_multi_write() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_flush + * Function: H5FD_multi_flush * - * Purpose: Flushes all multi members. + * Purpose: Flushes all multi members. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, as many files flushed as possible. + * Failure: -1, as many files flushed as possible. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1690,13 +1695,13 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, 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_mem_t mt; - int nerrors=0; - static const char *func="H5FD_multi_flush"; /* Function Name for error reporting */ + 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 */ #if 0 - H5FD_mem_t mmt; + H5FD_mem_t mmt; /* Debugging stuff... */ fprintf(stderr, "multifile access information:\n"); @@ -1704,9 +1709,9 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) /* print the map */ fprintf(stderr, " map="); for (mt=1; mtmemb_map[mt]; - if (H5FD_MEM_DEFAULT==mmt) mmt = mt; - fprintf(stderr, "%s%d", 1==mt?"":",", (int)mmt); + mmt = file->memb_map[mt]; + if (H5FD_MEM_DEFAULT==mmt) mmt = mt; + fprintf(stderr, "%s%d", 1==mt?"":",", (int)mmt); } fprintf(stderr, "\n"); @@ -1716,14 +1721,14 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) fprintf(stderr, " ------ -------------------- -------------------- -------------------- ------------------------------\n"); for (mt=1; mtmemb_addr[mt]) { - haddr_t eoa = H5FDget_eoa(file->memb[mt], mt); - fprintf(stderr, " %6d %20llu %20llu %20llu %s\n", - (int)mt, (unsigned long long)(file->memb_addr[mt]), - (unsigned long long)eoa, - (unsigned long long)(file->memb_next[mt]), - file->memb_name[mt]); - } + if (HADDR_UNDEF!=file->memb_addr[mt]) { + haddr_t eoa = H5FDget_eoa(file->memb[mt], mt); + fprintf(stderr, " %6d %20llu %20llu %20llu %s\n", + (int)mt, (unsigned long long)(file->memb_addr[mt]), + (unsigned long long)eoa, + (unsigned long long)(file->memb_next[mt]), + file->memb_name[mt]); + } } #endif @@ -1731,29 +1736,31 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) H5Eclear2(H5E_DEFAULT); /* Flush each file */ - for (mt=H5FD_MEM_SUPER; mtmemb[mt]) { - H5E_BEGIN_TRY { - if (H5FDflush(file->memb[mt],dxpl_id,closing)<0) nerrors++; - } H5E_END_TRY; - } + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDflush(file->memb[mt], dxpl_id, closing) < 0) + nerrors++; + } + H5E_END_TRY; + } } if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1); return 0; } - /*------------------------------------------------------------------------- - * Function: H5FD_multi_truncate + * Function: H5FD_multi_truncate * - * Purpose: Truncates all multi members. + * Purpose: Truncates all multi members. * - * Return: Success: 0 - * Failure: -1, as many files truncated as possible. + * Return: Success: 0 + * Failure: -1, as many files truncated as possible. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 31, 2008 * *------------------------------------------------------------------------- @@ -1761,136 +1768,141 @@ 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_mem_t mt; - int nerrors=0; - static const char *func="H5FD_multi_truncate"; /* Function Name for error reporting */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Truncate each file */ - for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - if(file->memb[mt]) { - H5E_BEGIN_TRY { - if(H5FDtruncate(file->memb[mt], dxpl_id, closing) < 0) + for (mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDtruncate(file->memb[mt], dxpl_id, closing) < 0) nerrors++; - } H5E_END_TRY; - } + } + H5E_END_TRY; + } } - if(nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error truncating member files", -1) + if (nerrors) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error truncating member files", -1); return 0; } /* end H5FD_multi_truncate() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_lock + * Function: H5FD_multi_lock * - * Purpose: Place a lock on all multi members. - * When there is error in locking a member file, it will not - * proceed further and will try to remove the locks of those - * member files that are locked before error is encountered. + * Purpose: Place a lock on all multi members. + * When there is error in locking a member file, it will not + * proceed further and will try to remove the locks of those + * member files that are locked before error is encountered. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Vailin Choi; March 2015 + * Programmer: Vailin Choi; March 2015 * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_lock(H5FD_t *_file, hbool_t rw) { - H5FD_multi_t *file = (H5FD_multi_t*)_file; - int nerrors = 0; - H5FD_mem_t out_mt; - static const char *func="H5FD_multi_unlock"; /* Function Name for error reporting */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Lock all member files */ - ALL_MEMBERS(mt) { + ALL_MEMBERS (mt) { out_mt = mt; - if(file->memb[mt]) { - H5E_BEGIN_TRY { - if(H5FDlock(file->memb[mt], rw) < 0) { + if (file->memb[mt]) { + H5E_BEGIN_TRY + { + if (H5FDlock(file->memb[mt], rw) < 0) { nerrors++; break; } /* end if */ - } H5E_END_TRY; + } + H5E_END_TRY; } /* end if */ - } END_MEMBERS; + } + END_MEMBERS; /* Try to unlock the member files that are locked before error is encountered */ - if(nerrors) { + if (nerrors) { H5FD_mem_t k; - for(k = H5FD_MEM_DEFAULT; k < out_mt; k = (H5FD_mem_t)(k + 1)) { - H5E_BEGIN_TRY { - if(H5FDunlock(file->memb[k]) < 0) + for (k = H5FD_MEM_DEFAULT; k < out_mt; k = (H5FD_mem_t)(k + 1)) { + H5E_BEGIN_TRY + { + if (H5FDunlock(file->memb[k]) < 0) nerrors++; - } H5E_END_TRY; + } + H5E_END_TRY; } /* end for */ - } /* end if */ + } /* end if */ - if(nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "error locking member files", -1) + if (nerrors) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "error locking member files", -1); return 0; } /* H5FD_multi_lock() */ - /*------------------------------------------------------------------------- - * Function: H5FD_multi_unlock + * Function: H5FD_multi_unlock * - * Purpose: Remove the lock on all multi members. - * It will try to unlock all member files but will record error - * encountered. + * Purpose: Remove the lock on all multi members. + * It will try to unlock all member files but will record error + * encountered. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Vailin Choi; March 2015 + * Programmer: Vailin Choi; March 2015 * *------------------------------------------------------------------------- */ static herr_t H5FD_multi_unlock(H5FD_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 */ + H5FD_multi_t * file = (H5FD_multi_t *)_file; + int nerrors = 0; + static const char *func = "H5FD_multi_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - if(file->memb[mt]) - if(H5FDunlock(file->memb[mt]) < 0) - nerrors++; - } END_MEMBERS; + ALL_MEMBERS (mt) { + if (file->memb[mt]) + if (H5FDunlock(file->memb[mt]) < 0) + nerrors++; + } + END_MEMBERS; - if(nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "error unlocking member files", -1) + if (nerrors) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "error unlocking member files", -1); return 0; } /* H5FD_multi_unlock() */ - /*------------------------------------------------------------------------- - * Function: compute_next + * Function: compute_next * - * Purpose: Compute the memb_next[] values of the file based on the - * file's member map and the member starting addresses. + * Purpose: Compute the memb_next[] values of the file based on the + * file's member map and the member starting addresses. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 23, 1999 * *------------------------------------------------------------------------- @@ -1901,37 +1913,39 @@ compute_next(H5FD_multi_t *file) /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - ALL_MEMBERS(mt) { - file->memb_next[mt] = HADDR_UNDEF; - } END_MEMBERS; - - UNIQUE_MEMBERS(file->fa.memb_map, mt1) { - UNIQUE_MEMBERS2(file->fa.memb_map, mt2) { - if (file->fa.memb_addr[mt1]fa.memb_addr[mt2] && - (HADDR_UNDEF==file->memb_next[mt1] || - file->memb_next[mt1]>file->fa.memb_addr[mt2])) { - file->memb_next[mt1] = file->fa.memb_addr[mt2]; - } - } END_MEMBERS; - if (HADDR_UNDEF==file->memb_next[mt1]) { - file->memb_next[mt1] = HADDR_MAX; /*last member*/ - } - } END_MEMBERS; + ALL_MEMBERS (mt) { + file->memb_next[mt] = HADDR_UNDEF; + } + END_MEMBERS; + + UNIQUE_MEMBERS (file->fa.memb_map, mt1) { + UNIQUE_MEMBERS2(file->fa.memb_map, mt2) + { + if (file->fa.memb_addr[mt1] < file->fa.memb_addr[mt2] && + (HADDR_UNDEF == file->memb_next[mt1] || file->memb_next[mt1] > file->fa.memb_addr[mt2])) { + file->memb_next[mt1] = file->fa.memb_addr[mt2]; + } + } + END_MEMBERS; + if (HADDR_UNDEF == file->memb_next[mt1]) { + file->memb_next[mt1] = HADDR_MAX; /*last member*/ + } + } + END_MEMBERS; return 0; } - /*------------------------------------------------------------------------- - * Function: open_members + * Function: open_members * - * Purpose: Opens all members which are not opened yet. + * Purpose: Opens all members which are not opened yet. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 23, 1999 * *------------------------------------------------------------------------- @@ -1942,19 +1956,19 @@ compute_next(H5FD_multi_t *file) * tmp in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(format-nonliteral) +H5_GCC_DIAG_OFF("format-nonliteral") static int open_members(H5FD_multi_t *file) { - char tmp[H5FD_MULT_MAX_FILE_NAME_LEN]; - int nerrors = 0; - static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ + char tmp[H5FD_MULT_MAX_FILE_NAME_LEN]; + int nerrors = 0; + static const char *func = "(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - UNIQUE_MEMBERS(file->fa.memb_map, mt) { - if(file->memb[mt]) + UNIQUE_MEMBERS (file->fa.memb_map, mt) { + if (file->memb[mt]) continue; /*already open*/ assert(file->fa.memb_name[mt]); /* Note: This truncates the user's filename down to only sizeof(tmp) @@ -1963,23 +1977,25 @@ open_members(H5FD_multi_t *file) sprintf(tmp, file->fa.memb_name[mt], file->name); tmp[sizeof(tmp) - 1] = '\0'; - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF); - } H5E_END_TRY; - if(!file->memb[mt]) { - if(!file->fa.relax || (file->flags & H5F_ACC_RDWR)) - nerrors++; } - } END_MEMBERS; + H5E_END_TRY; + if (!file->memb[mt]) { + if (!file->fa.relax || (file->flags & H5F_ACC_RDWR)) + nerrors++; + } + } + END_MEMBERS; if (nerrors) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1); return 0; } -H5_GCC_DIAG_ON(format-nonliteral) +H5_GCC_DIAG_ON("format-nonliteral") - -#ifdef _H5private_H +#ifdef H5private_H /* * This is not related to the functionality of the driver code. * It is added here to trigger warning if HDF5 private definitions are included diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index b3c3c62685a..62cc9c8843f 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,24 +20,237 @@ #ifndef H5FDmulti_H #define H5FDmulti_H -#define H5FD_MULTI (H5FD_multi_init()) +#define H5FD_MULTI (H5FD_multi_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_multi_init(void); -H5_DLL 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); -H5_DLL herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, - hid_t *memb_fapl/*out*/, char **memb_name/*out*/, - haddr_t *memb_addr/*out*/, hbool_t *relax/*out*/); -H5_DLL herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, - hid_t meta_plist_id, const char *raw_ext, - hid_t raw_plist_id); + +/** + * \ingroup FAPL + * + * \brief Sets up use of the multi-file driver + * + * \fapl_id + * \param[in] memb_map Maps memory usage types to other memory usage types + * \param[in] memb_fapl Property list for each memory usage type + * \param[in] memb_name Name generator for names of member files + * \param[in] memb_addr The offsets within the virtual address space, from 0 + * (zero) to #HADDR_MAX, at which each type of data storage begins + * \param[in] relax Allows read-only access to incomplete file sets when \c TRUE + * \returns \herr_t + * + * \details H5Pset_fapl_multi() sets the file access property list \p fapl_id to + * use the multi-file driver. + * + * The multi-file driver enables different types of HDF5 data and + * metadata to be written to separate files. These files are viewed by + * the HDF5 library and the application as a single virtual HDF5 file + * with a single HDF5 file address space. The types of data that can be + * broken out into separate files include raw data, the superblock, + * B-tree data, global heap data, local heap data, and object + * headers. At the programmer's discretion, two or more types of data + * can be written to the same file while other types of data are + * written to separate files. + * + * The array \p memb_map maps memory usage types to other memory usage + * types and is the mechanism that allows the caller to specify how + * many files are created. The array contains #H5FD_MEM_NTYPES entries, + * which are either the value #H5FD_MEM_DEFAULT or a memory usage + * type. The number of unique values determines the number of files + * that are opened. + * + * The array \p memb_fapl contains a property list for each memory + * usage type that will be associated with a file. + * + * The array \p memb_name should be a name generator (a + * \Code{printf}-style format with a \Code{%s} which will be replaced + * with the name passed to H5FDopen(), usually from H5Fcreate() or + * H5Fopen()). + * + * The array \p memb_addr specifies the offsets within the virtual + * address space, from 0 (zero) to #HADDR_MAX, at which each type of + * data storage begins. + * + * If \p relax is set to 1 (TRUE), then opening an existing file for + * read-only access will not fail if some file members are + * missing. This allows a file to be accessed in a limited sense if + * just the meta data is available. + * + * Default values for each of the optional arguments are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\p memb_mapThe default member map contains the value #H5FD_MEM_DEFAULT for each element.
+ * \p memb_fapl + * + * The default value is #H5P_DEFAULT for each element. + *
+ * \p memb_name + * + * The default string is \Code{%s-X.h5} where \c X is one of the following letters: + * - \c s for #H5FD_MEM_SUPER + * - \c b for #H5FD_MEM_BTREE + * - \c r for #H5FD_MEM_DRAW + * - \c g for #H5FD_MEM_GHEAP + * - \c l for #H5FD_MEM_LHEAP + * - \c o for #H5FD_MEM_OHDR + *
+ * \p memb_addr + * + * The default setting is that the address space is equally divided + * among all of the elements: + * - #H5FD_MEM_SUPER \Code{-> 0 * (HADDR_MAX/6)} + * - #H5FD_MEM_BTREE \Code{-> 1 * (HADDR_MAX/6)} + * - #H5FD_MEM_DRAW \Code{-> 2 * (HADDR_MAX/6)} + * - #H5FD_MEM_GHEAP \Code{-> 3 * (HADDR_MAX/6)} + * - #H5FD_MEM_LHEAP \Code{-> 4 * (HADDR_MAX/6)} + * - #H5FD_MEM_OHDR \Code{-> 5 * (HADDR_MAX/6)} + *
+ * + * \par Example: + * The following code sample sets up a multi-file access property list that + * partitions data into meta and raw files, each being one-half of the address:\n + * \code + * H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + * hid_t memb_fapl[H5FD_MEM_NTYPES]; + * const char *memb[H5FD_MEM_NTYPES]; + * haddr_t memb_addr[H5FD_MEM_NTYPES]; + * + * // The mapping... + * for (mt=0; mt typedef enum { H5FD_FILE_IMAGE_OP_NO_OP, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, + /**< Passed to the \p image_malloc and \p image_memcpy callbacks when a + * file image buffer is to be copied while being set in a file access + * property list (FAPL)*/ H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, + /**< Passed to the \p image_malloc and \p image_memcpy callbacks + * when a file image buffer is to be copied when a FAPL is copied*/ H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, + /** -/* Define structure to hold file image callbacks */ +/** + * Define structure to hold file image callbacks + */ +//! typedef struct { - void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, - void *udata); - void *(*image_memcpy)(void *dest, const void *src, size_t size, - H5FD_file_image_op_t file_image_op, void *udata); - void *(*image_realloc)(void *ptr, size_t size, - H5FD_file_image_op_t file_image_op, void *udata); - herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, + /** + * \param[in] size Size in bytes of the file image buffer to allocate + * \param[in] file_image_op A value from H5FD_file_image_op_t indicating + * the operation being performed on the file image + * when this callback is invoked + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, void *udata); + //! + /** + * \param[in] dest Address of the destination buffer + * \param[in] src Address of the source buffer + * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating + * the operation being performed on the file image + * when this callback is invoked + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + void *(*image_memcpy)(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); - void *(*udata_copy)(void *udata); - herr_t (*udata_free)(void *udata); + //! + /** + * \param[in] ptr Pointer to the buffer being reallocated + * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating + * the operation being performed on the file image + * when this callback is invoked + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + void *(*image_realloc)(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); + //! + /** + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); + //! + /** + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + void *(*udata_copy)(void *udata); + //! + /** + * \param[in] udata Value passed in in the H5Pset_file_image_callbacks + * parameter \p udata + */ + //! + herr_t (*udata_free)(void *udata); + //! + /** + * \brief The final field in the #H5FD_file_image_callbacks_t struct, + * provides a pointer to user-defined data. This pointer will be + * passed to the image_malloc, image_memcpy, image_realloc, and + * image_free callbacks. Define udata as NULL if no user-defined + * data is provided. + */ void *udata; } H5FD_file_image_callbacks_t; +//! #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ -H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); +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); -H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); +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); +H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, hsize_t size); +H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); +H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); -H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); -H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, void *buf/*out*/); -H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); -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); +H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf /*out*/); +H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); +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 */ -H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); +H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); #ifdef __cplusplus } #endif #endif - diff --git a/src/H5FDros3.c b/src/H5FDros3.c index c0247163f06..2470c8b61d5 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,14 +25,14 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDros3.h" /* ros3 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5FDs3comms.h" /* S3 Communications */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDros3.h" /* ros3 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FDs3comms.h" /* S3 Communications */ #ifdef H5_HAVE_ROS3_VFD @@ -63,29 +63,27 @@ static hid_t H5FD_ROS3_g = 0; * 2^(10+(1*16)) = 2^26 = 64MB * Reads of 64MB or greater fall in "overflow" bin[BIN_COUNT] */ -#define ROS3_STATS_BASE 2 -#define ROS3_STATS_INTERVAL 1 +#define ROS3_STATS_BASE 2 +#define ROS3_STATS_INTERVAL 1 #define ROS3_STATS_START_POWER 10 #define ROS3_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - /* * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. * Used in computing boundaries between stats bins. */ -#define ROS3_STATS_POW(bin_i, out_ptr) { \ - unsigned long long donotshadowresult = 1; \ - unsigned donotshadowindex = 0; \ - for (donotshadowindex = 0; \ - donotshadowindex < (((bin_i) * ROS3_STATS_INTERVAL) + \ - ROS3_STATS_START_POWER); \ - donotshadowindex++) \ - { \ - donotshadowresult *= ROS3_STATS_BASE; \ - } \ - *(out_ptr) = donotshadowresult; \ -} +#define ROS3_STATS_POW(bin_i, out_ptr) \ + { \ + unsigned long long donotshadowresult = 1; \ + unsigned donotshadowindex = 0; \ + for (donotshadowindex = 0; \ + donotshadowindex < (((bin_i)*ROS3_STATS_INTERVAL) + ROS3_STATS_START_POWER); \ + donotshadowindex++) { \ + donotshadowresult *= ROS3_STATS_BASE; \ + } \ + *(out_ptr) = donotshadowresult; \ + } /* array to hold pre-computed boundaries for stats bins */ @@ -192,13 +190,13 @@ typedef struct { * ***************************************************************************/ typedef struct H5FD_ros3_t { - H5FD_t pub; - H5FD_ros3_fapl_t fa; - haddr_t eoa; - s3r_t *s3r_handle; + H5FD_t pub; + H5FD_ros3_fapl_t fa; + haddr_t eoa; + s3r_t * s3r_handle; #if ROS3_STATS - ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; - ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; + ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; + ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; #endif } H5FD_ros3_t; @@ -212,74 +210,70 @@ typedef struct H5FD_ros3_t { * Only included if it may be used -- ROS3 VFD is enabled. * */ -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) /* 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 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); static int H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD__ros3_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD__ros3_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__ros3_get_handle(H5FD_t *_file, hid_t fapl, - void** file_handle); -static herr_t H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, void *buf); -static herr_t H5FD__ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, - haddr_t addr, size_t size, const void *buf); -static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, - hbool_t closing); +static herr_t H5FD__ros3_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD__ros3_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD__ros3_unlock(H5FD_t *_file); -static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t * fa); +static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa); static const H5FD_class_t H5FD_ros3_g = { - "ros3", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__ros3_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_ros3_fapl_t), /* fapl_size */ - H5FD__ros3_fapl_get, /* fapl_get */ - H5FD__ros3_fapl_copy, /* fapl_copy */ - H5FD__ros3_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__ros3_open, /* open */ - H5FD__ros3_close, /* close */ - H5FD__ros3_cmp, /* cmp */ - H5FD__ros3_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__ros3_get_eoa, /* get_eoa */ - H5FD__ros3_set_eoa, /* set_eoa */ - H5FD__ros3_get_eof, /* get_eof */ - H5FD__ros3_get_handle, /* get_handle */ - H5FD__ros3_read, /* read */ - H5FD__ros3_write, /* write */ - NULL, /* flush */ - H5FD__ros3_truncate, /* truncate */ - H5FD__ros3_lock, /* lock */ - H5FD__ros3_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "ros3", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__ros3_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_ros3_fapl_t), /* fapl_size */ + H5FD__ros3_fapl_get, /* fapl_get */ + H5FD__ros3_fapl_copy, /* fapl_copy */ + H5FD__ros3_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__ros3_open, /* open */ + H5FD__ros3_close, /* close */ + H5FD__ros3_cmp, /* cmp */ + H5FD__ros3_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__ros3_get_eoa, /* get_eoa */ + H5FD__ros3_set_eoa, /* set_eoa */ + H5FD__ros3_get_eof, /* get_eof */ + H5FD__ros3_get_handle, /* get_handle */ + H5FD__ros3_read, /* read */ + H5FD__ros3_write, /* write */ + NULL, /* flush */ + H5FD__ros3_truncate, /* truncate */ + H5FD__ros3_lock, /* lock */ + H5FD__ros3_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_ros3_t struct */ H5FL_DEFINE_STATIC(H5FD_ros3_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -298,14 +292,13 @@ H5FD__init_package(void) FUNC_ENTER_STATIC - if(H5FD_ros3_init() < 0) + if (H5FD_ros3_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize ros3 VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_ros3_init * @@ -327,13 +320,13 @@ H5FD_ros3_init(void) unsigned int bin_i; #endif - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) #if ROS3_DEBUG 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 ROS3_STATS @@ -347,14 +340,12 @@ H5FD_ros3_init(void) } #endif - /* Set return value */ ret_value = H5FD_ROS3_g; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_ros3_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__ros3_term * @@ -381,7 +372,6 @@ H5FD__ros3_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__ros3_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_ros3 * @@ -413,10 +403,10 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) #endif plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(plist == NULL) + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(FAIL == H5FD__ros3_validate_config(fa)) + if (FAIL == H5FD__ros3_validate_config(fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid ros3 config") ret_value = H5P_set_driver(plist, H5FD_ROS3, (void *)fa); @@ -425,7 +415,6 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_ros3() */ - /*------------------------------------------------------------------------- * Function: H5FD__ros3_validate_config() * @@ -447,7 +436,7 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) *------------------------------------------------------------------------- */ static herr_t -H5FD__ros3_validate_config(const H5FD_ros3_fapl_t * fa) +H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa) { herr_t ret_value = SUCCEED; @@ -455,19 +444,18 @@ H5FD__ros3_validate_config(const H5FD_ros3_fapl_t * fa) HDassert(fa != NULL); - if(fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_ros3_fapl_t version"); + if (fa->version != H5FD_CURR_ROS3_FAPL_T_VERSION) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown H5FD_ros3_fapl_t version"); /* if set to authenticate, region and id cannot be empty strings */ - if(fa->authenticate == TRUE) - if((fa->aws_region[0] == '\0') || (fa->secret_id[0] == '\0')) + if (fa->authenticate == TRUE) + if ((fa->aws_region[0] == '\0') || (fa->secret_id[0] == '\0')) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Inconsistent authentication information"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_validate_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_ros3 * @@ -484,41 +472,40 @@ H5FD__ros3_validate_config(const H5FD_ros3_fapl_t * fa) *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out) +H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_dst) { - const H5FD_ros3_fapl_t *fa = NULL; - H5P_genplist_t *plist = NULL; + const H5FD_ros3_fapl_t *fa_src = NULL; + H5P_genplist_t * plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", fapl_id, fa_out); + H5TRACE2("e", "i*x", fapl_id, fa_dst); #if ROS3_DEBUG HDfprintf(stdout, "H5Pget_fapl_ros3() called.\n"); #endif - if(fa_out == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL") + if (fa_dst == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL") plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); - if(plist == NULL) + if (plist == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_ROS3 != H5P_peek_driver(plist)) + if (H5FD_ROS3 != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - fa = (const H5FD_ros3_fapl_t *)H5P_peek_driver_info(plist); - if(fa == NULL) + fa_src = (const H5FD_ros3_fapl_t *)H5P_peek_driver_info(plist); + if (fa_src == NULL) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Copy the ros3 fapl data out */ - HDmemcpy(fa_out, fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(fa_dst, fa_src, sizeof(H5FD_ros3_fapl_t)); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_ros3() */ - /*------------------------------------------------------------------------- * Function: H5FD__ros3_fapl_get * @@ -537,31 +524,30 @@ H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out) 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 fa = (H5FD_ros3_fapl_t *)H5MM_calloc(sizeof(H5FD_ros3_fapl_t)); - if(fa == NULL) + if (fa == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the fields of the structure */ - HDmemcpy(fa, &(file->fa), sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(fa, &(file->fa), sizeof(H5FD_ros3_fapl_t)); /* Set return value */ ret_value = fa; done: - if(ret_value == NULL) - if(fa != NULL) + if (ret_value == NULL) + if (fa != NULL) H5MM_xfree(fa); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD__ros3_fapl_copy * @@ -579,28 +565,27 @@ H5FD__ros3_fapl_get(H5FD_t *_file) 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; + 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; FUNC_ENTER_STATIC new_fa = (H5FD_ros3_fapl_t *)H5MM_malloc(sizeof(H5FD_ros3_fapl_t)); - if(new_fa == NULL) + if (new_fa == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - HDmemcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_ros3_fapl_t)); ret_value = new_fa; done: - if(ret_value == NULL) - if(new_fa != NULL) + if (ret_value == NULL) + if (new_fa != NULL) H5MM_xfree(new_fa); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5FD__ros3_fapl_free * @@ -616,7 +601,7 @@ H5FD__ros3_fapl_copy(const void *_old_fa) static herr_t H5FD__ros3_fapl_free(void *_fa) { - H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t*)_fa; + H5FD_ros3_fapl_t *fa = (H5FD_ros3_fapl_t *)_fa; FUNC_ENTER_STATIC_NOERR @@ -661,14 +646,14 @@ ros3_reset_stats(H5FD_ros3_t *file) HDprintf("ros3_reset_stats() called\n"); #endif - if(file == NULL) + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file was null"); - for(i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { - file->raw[i].bytes = 0; - file->raw[i].count = 0; - file->raw[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; - file->raw[i].max = 0; + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + file->raw[i].bytes = 0; + file->raw[i].count = 0; + file->raw[i].min = (unsigned long long)ROS3_STATS_STARTING_MIN; + file->raw[i].max = 0; file->meta[i].bytes = 0; file->meta[i].count = 0; @@ -681,7 +666,6 @@ ros3_reset_stats(H5FD_ros3_t *file) } /* end ros3_reset_stats() */ #endif /* ROS3_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_open() @@ -716,13 +700,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; - char iso8601now[ISO8601_SIZE]; - unsigned char signing_key[SHA256_DIGEST_LENGTH]; - s3r_t *handle = NULL; - H5FD_ros3_fapl_t fa; - H5FD_t *ret_value = 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; + H5FD_ros3_fapl_t fa; + H5FD_t * ret_value = NULL; FUNC_ENTER_STATIC @@ -734,44 +718,44 @@ H5FD__ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!url || !*url) + if (!url || !*url) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") - if(flags != H5F_ACC_RDONLY) + if (flags != H5F_ACC_RDONLY) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, NULL, "only Read-Only access allowed") - if(FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) + if (FAIL == H5Pget_fapl_ros3(fapl_id, &fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get property list") - if(CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) + if (CURLE_OK != curl_global_init(CURL_GLOBAL_DEFAULT)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to initialize curl global (placeholder flags)") /* open file; procedure depends on whether or not the fapl instructs to * authenticate requests or not. */ - if(fa.authenticate == TRUE) { + 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 */ now = gmnow(); - HDassert( now != NULL ); - if(ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) + HDassert(now != NULL); + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while writing iso8601 timestamp") - if(FAIL == H5FD_s3comms_signing_key(signing_key, (const char *)fa.secret_key, - (const char *)fa.aws_region, (const char *)iso8601now)) + if (FAIL == H5FD_s3comms_signing_key(signing_key, (const char *)fa.secret_key, + (const char *)fa.aws_region, (const char *)iso8601now)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem while computing signing key") - handle = H5FD_s3comms_s3r_open( url, (const char *)fa.aws_region, - (const char *)fa.secret_id, (const unsigned char *)signing_key); + handle = H5FD_s3comms_s3r_open(url, (const char *)fa.aws_region, (const char *)fa.secret_id, + (const unsigned char *)signing_key); } else handle = H5FD_s3comms_s3r_open(url, NULL, NULL, NULL); - if(handle == NULL) + if (handle == NULL) /* If we want to check CURL's say on the matter in a controlled * fashion, this is the place to do it, but would need to make a * few minor changes to s3comms `s3r_t` and `s3r_read()`. @@ -780,28 +764,28 @@ H5FD__ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* create new file struct */ file = H5FL_CALLOC(H5FD_ros3_t); - if(file == NULL) + if (file == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->s3r_handle = handle; - HDmemcpy(&(file->fa), &fa, sizeof(H5FD_ros3_fapl_t)); + H5MM_memcpy(&(file->fa), &fa, sizeof(H5FD_ros3_fapl_t)); #if ROS3_STATS - if(FAIL == ros3_reset_stats(file)) + if (FAIL == ros3_reset_stats(file)) HGOTO_ERROR(H5E_INTERNAL, H5E_UNINITIALIZED, NULL, "unable to reset file statistics") #endif /* ROS3_STATS */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(ret_value == NULL) { - if(handle != NULL) - if(FAIL == H5FD_s3comms_s3r_close(handle)) + if (ret_value == NULL) { + if (handle != NULL) + if (FAIL == H5FD_s3comms_s3r_close(handle)) HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close s3 file handle") - if(file != NULL) + if (file != NULL) file = H5FL_FREE(H5FD_ros3_t, file); curl_global_cleanup(); /* early cleanup because open failed */ - } /* end if null return value (error) */ + } /* end if null return value (error) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_open() */ @@ -865,31 +849,31 @@ 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; double average_meta = 0.0; double average_raw = 0.0; - unsigned long long min_meta = (unsigned long long)ROS3_STATS_STARTING_MIN; - unsigned long long min_raw = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long min_meta = (unsigned long long)ROS3_STATS_STARTING_MIN; + unsigned long long min_raw = (unsigned long long)ROS3_STATS_STARTING_MIN; unsigned long long max_meta = 0; 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 */ unsigned suffix_i = 0; - const char suffixes[] = { ' ', 'K', 'M', 'G', 'T', 'P' }; + const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; FUNC_ENTER_STATIC - if(stream == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null" ); - if(file == NULL) + if (stream == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file stream cannot be null"); + if (file == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file cannot be null"); - if(file->s3r_handle == NULL) + if (file->s3r_handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "s3 request handle cannot be null"); - if(file->s3r_handle->purl == NULL) + if (file->s3r_handle->purl == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parsed url structure cannot be null"); purl = file->s3r_handle->purl; @@ -898,15 +882,16 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) ******************/ HDfprintf(stream, "stats for %s://%s", purl->scheme, purl->host); - if(purl->port != NULL && purl->port[0] != '\0') + if (purl->port != NULL && purl->port[0] != '\0') HDfprintf(stream, ":%s", purl->port); - if(purl->query != NULL && purl->query[0] != '\0') { + if (purl->query != NULL && purl->query[0] != '\0') { if (purl->path != NULL && purl->path[0] != '\0') HDfprintf(stream, "/%s", purl->path); else HDfprintf(stream, "/"); HDfprintf(stream, "?%s", purl->query); - } else if (purl->path != NULL && purl->path[0] != '\0') { + } + else if (purl->path != NULL && purl->path[0] != '\0') { HDfprintf(stream, "/%s", purl->path); } HDfprintf(stream, "\n"); @@ -915,39 +900,39 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) * AGGREGATE STATS * *******************/ - for(i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { const ros3_statsbin *r = &file->raw[i]; const ros3_statsbin *m = &file->meta[i]; - if(m->min < min_meta) + if (m->min < min_meta) min_meta = m->min; - if(r->min < min_raw) - min_raw = r->min; - if(m->max > max_meta) + if (r->min < min_raw) + min_raw = r->min; + if (m->max > max_meta) max_meta = m->max; - if(r->max > max_raw) - max_raw = r->max; + if (r->max > max_raw) + max_raw = r->max; - count_raw += r->count; + count_raw += r->count; count_meta += m->count; - bytes_raw += r->bytes; + bytes_raw += r->bytes; bytes_meta += m->bytes; } - if(count_raw > 0) + if (count_raw > 0) average_raw = (double)bytes_raw / (double)count_raw; - if(count_meta > 0) + if (count_meta > 0) average_meta = (double)bytes_meta / (double)count_meta; /****************** * PRINT OVERVIEW * ******************/ - HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", - count_raw + count_meta, count_meta, count_raw); - HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", - bytes_raw + bytes_meta, bytes_meta, bytes_raw); + HDfprintf(stream, "TOTAL READS: %llu (%llu meta, %llu raw)\n", count_raw + count_meta, count_meta, + count_raw); + HDfprintf(stream, "TOTAL BYTES: %llu (%llu meta, %llu raw)\n", bytes_raw + bytes_meta, bytes_meta, + bytes_raw); - if(count_raw + count_meta == 0) + if (count_raw + count_meta == 0) goto done; /************************* @@ -956,21 +941,21 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) HDfprintf(stream, "SIZES meta raw\n"); HDfprintf(stream, " min "); - if(count_meta == 0) + if (count_meta == 0) HDfprintf(stream, " 0.000 "); else { re_dub = (double)min_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); } - if(count_raw == 0) + if (count_raw == 0) HDfprintf(stream, " 0.000 \n"); else { re_dub = (double)min_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); @@ -978,26 +963,26 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) HDfprintf(stream, " avg "); re_dub = (double)average_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); re_dub = (double)average_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); HDfprintf(stream, " max "); re_dub = (double)max_meta; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c ", re_dub, suffixes[suffix_i]); re_dub = (double)max_raw; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); HDfprintf(stream, "%8.3lf%c\n", re_dub, suffixes[suffix_i]); @@ -1006,12 +991,10 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) * PRINT INDIVIDUAL BIN STATS * ******************************/ - HDfprintf(stream, - "BINS # of reads total bytes average size\n"); - HDfprintf(stream, - " up-to meta raw meta raw meta raw\n"); + HDfprintf(stream, "BINS # of reads total bytes average size\n"); + HDfprintf(stream, " up-to meta raw meta raw meta raw\n"); - for(i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { + for (i = 0; i <= ROS3_STATS_BIN_COUNT; i++) { const ros3_statsbin *m; const ros3_statsbin *r; unsigned long long range_end = 0; @@ -1026,58 +1009,57 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) m = &file->meta[i]; r = &file->raw[i]; - if(r->count == 0 && m->count == 0) + if (r->count == 0 && m->count == 0) continue; range_end = ros3_stats_boundaries[i]; - if(i == ROS3_STATS_BIN_COUNT) { - range_end = ros3_stats_boundaries[i-1]; + if (i == ROS3_STATS_BIN_COUNT) { + range_end = ros3_stats_boundaries[i - 1]; HDfprintf(stream, ">"); } else HDfprintf(stream, " "); bm_val = (double)m->bytes; - for(suffix_i = 0; bm_val >= 1024.0; suffix_i++) + for (suffix_i = 0; bm_val >= 1024.0; suffix_i++) bm_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); bm_suffix = suffixes[suffix_i]; br_val = (double)r->bytes; - for(suffix_i = 0; br_val >= 1024.0; suffix_i++) + for (suffix_i = 0; br_val >= 1024.0; suffix_i++) br_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); br_suffix = suffixes[suffix_i]; - if(m->count > 0) + if (m->count > 0) am_val = (double)(m->bytes) / (double)(m->count); - for(suffix_i = 0; am_val >= 1024.0; suffix_i++) + for (suffix_i = 0; am_val >= 1024.0; suffix_i++) am_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); am_suffix = suffixes[suffix_i]; - if(r->count > 0) + if (r->count > 0) ar_val = (double)(r->bytes) / (double)(r->count); - for(suffix_i = 0; ar_val >= 1024.0; suffix_i++) + for (suffix_i = 0; ar_val >= 1024.0; suffix_i++) ar_val /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); ar_suffix = suffixes[suffix_i]; re_dub = (double)range_end; - for(suffix_i = 0; re_dub >= 1024.0; suffix_i++) + for (suffix_i = 0; re_dub >= 1024.0; suffix_i++) re_dub /= 1024.0; HDassert(suffix_i < sizeof(suffixes)); - HDfprintf(stream, - " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", - re_dub, suffixes[suffix_i], /* bin ceiling */ - m->count, /* metadata reads */ - r->count, /* rawdata reads */ - bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ - am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, + suffixes[suffix_i], /* bin ceiling */ + m->count, /* metadata reads */ + r->count, /* rawdata reads */ + bm_val, bm_suffix, /* metadata bytes */ + br_val, br_suffix, /* rawdata bytes */ + am_val, am_suffix, /* metadata average */ + ar_val, ar_suffix); /* rawdata average */ HDfflush(stream); } @@ -1088,7 +1070,6 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) } /* ros3_fprint_stats */ #endif /* ROS3_STATS */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_close() @@ -1124,12 +1105,12 @@ H5FD__ros3_close(H5FD_t H5_ATTR_UNUSED *_file) /* Close the underlying request handle */ - if(FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) + if (FAIL == H5FD_s3comms_s3r_close(file->s3r_handle)) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close S3 request handle") #if ROS3_STATS /* TODO: mechanism to re-target stats printout */ - if(ros3_fprint_stats(stdout, file) == FAIL) + if (ros3_fprint_stats(stdout, file) == FAIL) HGOTO_ERROR(H5E_INTERNAL, H5E_ERROR, FAIL, "problem while writing file statistics") #endif /* ROS3_STATS */ @@ -1142,7 +1123,6 @@ H5FD__ros3_close(H5FD_t H5_ATTR_UNUSED *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_close() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_cmp() @@ -1176,8 +1156,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; @@ -1201,78 +1181,77 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HDassert(purl2->host != NULL); /* URL: SCHEME */ - if(HDstrcmp(purl1->scheme, purl2->scheme)) + if (HDstrcmp(purl1->scheme, purl2->scheme)) HGOTO_DONE(-1) /* URL: HOST */ - if(HDstrcmp(purl1->host, purl2->host)) + if (HDstrcmp(purl1->host, purl2->host)) HGOTO_DONE(-1) /* URL: PORT */ - if(purl1->port && purl2->port) { - if(HDstrcmp(purl1->port, purl2->port)) + if (purl1->port && purl2->port) { + if (HDstrcmp(purl1->port, purl2->port)) HGOTO_DONE(-1) } - else if(purl1->port) + else if (purl1->port) HGOTO_DONE(-1) - else if(purl2->port) + else if (purl2->port) HGOTO_DONE(-1) /* URL: PATH */ - if(purl1->path && purl2->path) { - if(HDstrcmp(purl1->path, purl2->path)) + if (purl1->path && purl2->path) { + if (HDstrcmp(purl1->path, purl2->path)) HGOTO_DONE(-1) } - else if(purl1->path && !purl2->path) + else if (purl1->path && !purl2->path) HGOTO_DONE(-1) - else if(purl2->path && !purl1->path) + else if (purl2->path && !purl1->path) HGOTO_DONE(-1) /* URL: QUERY */ - if(purl1->query && purl2->query) { - if(HDstrcmp(purl1->query, purl2->query)) + if (purl1->query && purl2->query) { + if (HDstrcmp(purl1->query, purl2->query)) HGOTO_DONE(-1) } - else if(purl1->query && !purl2->query) + else if (purl1->query && !purl2->query) HGOTO_DONE(-1) - else if(purl2->query && !purl1->query) + else if (purl2->query && !purl1->query) HGOTO_DONE(-1) /* FAPL: AWS_REGION */ - if(f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') { - if(HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) + if (f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') { + if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) HGOTO_DONE(-1) } - else if(f1->fa.aws_region[0] != '\0') + else if (f1->fa.aws_region[0] != '\0') HGOTO_DONE(-1) - else if(f2->fa.aws_region[0] != '\0') + else if (f2->fa.aws_region[0] != '\0') HGOTO_DONE(-1) /* FAPL: SECRET_ID */ - if(f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') { - if(HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) + if (f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') { + if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) HGOTO_DONE(-1) } - else if(f1->fa.secret_id[0] != '\0') + else if (f1->fa.secret_id[0] != '\0') HGOTO_DONE(-1) - else if(f2->fa.secret_id[0] != '\0') + else if (f2->fa.secret_id[0] != '\0') HGOTO_DONE(-1) /* FAPL: SECRET_KEY */ - if(f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') { - if(HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) + if (f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') { + if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) HGOTO_DONE(-1) } - else if(f1->fa.secret_key[0] != '\0') + else if (f1->fa.secret_key[0] != '\0') HGOTO_DONE(-1) - else if(f2->fa.secret_key[0] != '\0') + else if (f2->fa.secret_key[0] != '\0') HGOTO_DONE(-1) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__ros3_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__ros3_query * @@ -1302,7 +1281,7 @@ H5FD__ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) #endif /* Set the VFL feature flags that this driver supports */ - if(flags) { + if (flags) { *flags = 0; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_DATA_SIEVE; @@ -1311,7 +1290,6 @@ H5FD__ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD__ros3_query() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_get_eoa() @@ -1345,7 +1323,6 @@ H5FD__ros3_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__ros3_get_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_set_eoa() @@ -1379,7 +1356,6 @@ H5FD__ros3_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD__ros3_set_eoa() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_get_eof() @@ -1412,7 +1388,6 @@ H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) FUNC_LEAVE_NOAPI(H5FD_s3comms_s3r_get_filesize(file->s3r_handle)) } /* end H5FD__ros3_get_eof() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_get_handle() @@ -1431,8 +1406,7 @@ H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) *------------------------------------------------------------------------- */ static herr_t -H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, - void **file_handle) +H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; herr_t ret_value = SUCCEED; @@ -1443,7 +1417,7 @@ H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, HDfprintf(stdout, "H5FD__ros3_get_handle() called.\n"); #endif - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = file->s3r_handle; @@ -1452,7 +1426,6 @@ H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_get_handle() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_read() @@ -1476,9 +1449,8 @@ H5FD__ros3_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, *------------------------------------------------------------------------- */ static herr_t -H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, - void *buf) +H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf) { H5FD_ros3_t *file = (H5FD_ros3_t *)_file; size_t filesize = 0; @@ -1489,7 +1461,6 @@ H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, unsigned bin_i = 0; #endif /* ROS3_STATS */ - FUNC_ENTER_STATIC #if ROS3_DEBUG @@ -1502,31 +1473,29 @@ H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, filesize = H5FD_s3comms_s3r_get_filesize(file->s3r_handle); - if((addr > filesize) || ((addr + size) > filesize)) + if ((addr > filesize) || ((addr + size) > filesize)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "range exceeds file address") - if(H5FD_s3comms_s3r_read(file->s3r_handle, addr, size, buf) == FAIL) + if (H5FD_s3comms_s3r_read(file->s3r_handle, addr, size, buf) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to execute read") #if ROS3_STATS /* Find which "bin" this read fits in. Can be "overflow" bin. */ - for(bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) - if((unsigned long long)size < ros3_stats_boundaries[bin_i]) + for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) + if ((unsigned long long)size < ros3_stats_boundaries[bin_i]) break; - bin = (type == H5FD_MEM_DRAW) - ? &file->raw[bin_i] - : &file->meta[bin_i]; + bin = (type == H5FD_MEM_DRAW) ? &file->raw[bin_i] : &file->meta[bin_i]; /* Store collected stats in appropriate bin */ - if(bin->count == 0) { + if (bin->count == 0) { bin->min = size; bin->max = size; } else { - if(size < bin->min) + if (size < bin->min) bin->min = size; - if(size > bin->max) + if (size > bin->max) bin->max = size; } bin->count++; @@ -1538,7 +1507,6 @@ H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_read() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_write() @@ -1558,9 +1526,8 @@ H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, *------------------------------------------------------------------------- */ static herr_t -H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr, - size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) +H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf) { herr_t ret_value = FAIL; @@ -1576,7 +1543,6 @@ H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__ros3_write() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_truncate() @@ -1599,7 +1565,7 @@ H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, */ static herr_t H5FD__ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, - hbool_t H5_ATTR_UNUSED closing) + hbool_t H5_ATTR_UNUSED closing) { herr_t ret_value = SUCCEED; @@ -1615,7 +1581,6 @@ H5FD__ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__ros3_truncate() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_lock() @@ -1638,15 +1603,13 @@ H5FD__ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id, *------------------------------------------------------------------------- */ static herr_t -H5FD__ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, - hbool_t H5_ATTR_UNUSED rw) +H5FD__ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw) { FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__ros3_lock() */ - /*------------------------------------------------------------------------- * * Function: H5FD__ros3_unlock() @@ -1674,4 +1637,3 @@ H5FD__ros3_unlock(H5FD_t H5_ATTR_UNUSED *_file) } /* end H5FD__ros3_unlock() */ #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDros3.h b/src/H5FDros3.h index 457326e0d8e..8e42ca23fee 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,9 +22,9 @@ #define H5FDros3_H #ifdef H5_HAVE_ROS3_VFD -#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3 (H5FD_ros3_init()) #else -#define H5FD_ROS3 (H5I_INVALID_HID) +#define H5FD_ROS3 (H5I_INVALID_HID) #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_ROS3_VFD @@ -71,11 +71,11 @@ * ****************************************************************************/ -#define H5FD_CURR_ROS3_FAPL_T_VERSION 1 +#define H5FD_CURR_ROS3_FAPL_T_VERSION 1 -#define H5FD_ROS3_MAX_REGION_LEN 32 -#define H5FD_ROS3_MAX_SECRET_ID_LEN 128 -#define H5FD_ROS3_MAX_SECRET_KEY_LEN 128 +#define H5FD_ROS3_MAX_REGION_LEN 32 +#define H5FD_ROS3_MAX_SECRET_ID_LEN 128 +#define H5FD_ROS3_MAX_SECRET_KEY_LEN 128 typedef struct H5FD_ros3_fapl_t { int32_t version; @@ -85,13 +85,24 @@ typedef struct H5FD_ros3_fapl_t { char secret_key[H5FD_ROS3_MAX_SECRET_KEY_LEN + 1]; } H5FD_ros3_fapl_t; - #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_ros3_init(void); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_out); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa); #ifdef __cplusplus @@ -101,5 +112,3 @@ H5_DLL herr_t H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa); #endif /* H5_HAVE_ROS3_VFD */ #endif /* ifndef H5FDros3_H */ - - diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index 4c762d12523..ee5b5ec67b0 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -67,7 +67,6 @@ */ #define S3COMMS_MAX_RANGE_STRING_SIZE 128 - /******************/ /* Local Typedefs */ /******************/ @@ -81,9 +80,9 @@ * pointer to data region and record of bytes written (offset) */ struct s3r_datastruct { - unsigned long magic; - char *data; - size_t size; + unsigned long magic; + char * data; + size_t size; }; #define S3COMMS_CALLBACK_DATASTRUCT_MAGIC 0x28c2b2ul @@ -91,10 +90,7 @@ struct s3r_datastruct { /* Local Prototypes */ /********************/ -size_t curlwritecallback(char *ptr, - size_t size, - size_t nmemb, - void *userdata); +size_t curlwritecallback(char *ptr, size_t size, size_t nmemb, void *userdata); herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); @@ -114,7 +110,6 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); /* Functions */ /*************/ - /*---------------------------------------------------------------------------- * * Function: curlwritecallback() @@ -139,20 +134,17 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle); *---------------------------------------------------------------------------- */ size_t -curlwritecallback(char *ptr, - size_t size, - size_t nmemb, - void *userdata) +curlwritecallback(char *ptr, size_t size, size_t nmemb, void *userdata) { struct s3r_datastruct *sds = (struct s3r_datastruct *)userdata; size_t product = (size * nmemb); size_t written = 0; - if(sds->magic != S3COMMS_CALLBACK_DATASTRUCT_MAGIC) + if (sds->magic != S3COMMS_CALLBACK_DATASTRUCT_MAGIC) return written; if (size > 0) { - HDmemcpy(&(sds->data[sds->size]), ptr, product); + H5MM_memcpy(&(sds->data[sds->size]), ptr, product); sds->size += product; written = product; } @@ -160,7 +152,6 @@ curlwritecallback(char *ptr, return written; } /* end curlwritecallback() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_node_set() @@ -215,17 +206,14 @@ curlwritecallback(char *ptr, *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_hrb_node_set( - hrb_node_t **L, - const char *name, - const char *value) +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; @@ -238,14 +226,14 @@ H5FD_s3comms_hrb_node_set( HDprintf("NAME: %s\n", name); HDprintf("VALUE: %s\n", value); HDprintf("LIST:\n->"); - for(node_ptr = (*L); node_ptr != NULL; node_ptr = node_ptr->next) + for (node_ptr = (*L); node_ptr != NULL; node_ptr = node_ptr->next) HDfprintf(stdout, "{%s}\n->", node_ptr->cat); HDprintf("(null)\n"); HDfflush(stdout); node_ptr = NULL; #endif - if(name == NULL) + if (name == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to operate on null name"); namelen = HDstrlen(name); @@ -256,9 +244,9 @@ H5FD_s3comms_hrb_node_set( /* copy and lowercase name */ lowername = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); - if(lowername == NULL) + if (lowername == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for lowercase name copy."); - for(i = 0; i < namelen; i++) + for (i = 0; i < namelen; i++) lowername[i] = (char)HDtolower((int)name[i]); lowername[namelen] = 0; @@ -266,35 +254,34 @@ H5FD_s3comms_hrb_node_set( * If NULL, we will be removing a node or doing nothing, so no need for * copies */ - if(value != NULL) { + if (value != NULL) { int ret = 0; size_t valuelen = HDstrlen(value); size_t catlen = namelen + valuelen + 2; /* +2 from ": " */ - size_t catwrite = catlen + 3; /* 3 not 1 to quiet compiler warning */ - + size_t catwrite = catlen + 3; /* 3 not 1 to quiet compiler warning */ namecpy = (char *)H5MM_malloc(sizeof(char) * (namelen + 1)); - if(namecpy == NULL) + if (namecpy == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for name copy."); - HDmemcpy(namecpy, name, (namelen + 1)); + H5MM_memcpy(namecpy, name, (namelen + 1)); valuecpy = (char *)H5MM_malloc(sizeof(char) * (valuelen + 1)); - if(valuecpy == NULL) + if (valuecpy == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for value copy."); - HDmemcpy(valuecpy, value, (valuelen + 1)); + H5MM_memcpy(valuecpy, value, (valuelen + 1)); nvcat = (char *)H5MM_malloc(sizeof(char) * catwrite); - if(nvcat == NULL) + if (nvcat == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for concatenated string."); ret = HDsnprintf(nvcat, catwrite, "%s: %s", name, value); - if(ret < 0 || (size_t)ret > catlen) + if (ret < 0 || (size_t)ret > catlen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot concatenate `%s: %s", name, value); - HDassert( catlen == HDstrlen(nvcat) ); + HDassert(catlen == HDstrlen(nvcat)); /* create new_node, should we need it */ new_node = (hrb_node_t *)H5MM_malloc(sizeof(hrb_node_t)); - if(new_node == NULL) + if (new_node == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot make space for new set."); new_node->magic = S3COMMS_HRB_NODE_MAGIC; @@ -309,12 +296,13 @@ H5FD_s3comms_hrb_node_set( * ACT ON LIST * ***************/ - if(*L == NULL) { - if(value == NULL) + if (*L == NULL) { + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove node from empty list") else { #if S3COMMS_DEBUG -HDprintf("CREATE NEW\n"); HDfflush(stdout); + HDprintf("CREATE NEW\n"); + HDfflush(stdout); #endif /******************* * CREATE NEW LIST * @@ -332,19 +320,20 @@ HDprintf("CREATE NEW\n"); HDfflush(stdout); /* sanity-check pointer passed in */ - HDassert( (*L) != NULL ); - HDassert( (*L)->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert((*L) != NULL); + HDassert((*L)->magic == S3COMMS_HRB_NODE_MAGIC); node_ptr = (*L); /* Check whether to modify/remove first node in list */ - if(HDstrcmp(lowername, node_ptr->lowername) == 0) { + if (HDstrcmp(lowername, node_ptr->lowername) == 0) { is_looking = FALSE; if (value == NULL) { #if S3COMMS_DEBUG -HDprintf("REMOVE HEAD\n"); HDfflush(stdout); + HDprintf("REMOVE HEAD\n"); + HDfflush(stdout); #endif /*************** * REMOVE HEAD * @@ -353,41 +342,48 @@ HDprintf("REMOVE HEAD\n"); HDfflush(stdout); *L = node_ptr->next; #if S3COMMS_DEBUG -HDprintf("FREEING CAT (node)\n"); HDfflush(stdout); + HDprintf("FREEING CAT (node)\n"); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->cat); #if S3COMMS_DEBUG -HDprintf("FREEING LOWERNAME (node)\n"); HDfflush(stdout); + HDprintf("FREEING LOWERNAME (node)\n"); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->lowername); #if S3COMMS_DEBUG -HDprintf("FREEING NAME (node)\n"); HDfflush(stdout); + HDprintf("FREEING NAME (node)\n"); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->name); #if S3COMMS_DEBUG -HDprintf("FREEING VALUE (node)\n"); HDfflush(stdout); + HDprintf("FREEING VALUE (node)\n"); + HDfflush(stdout); #endif H5MM_xfree(node_ptr->value); #if S3COMMS_DEBUG -HDprintf("MAGIC OK? %s\n", - (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); -HDfflush(stdout); + HDprintf("MAGIC OK? %s\n", (node_ptr->magic == S3COMMS_HRB_NODE_MAGIC) ? "YES" : "NO"); + HDfflush(stdout); #endif - HDassert( node_ptr->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(node_ptr->magic == S3COMMS_HRB_NODE_MAGIC); node_ptr->magic += 1ul; #if S3COMMS_DEBUG -HDprintf("FREEING POINTER\n"); HDfflush(stdout); + HDprintf("FREEING POINTER\n"); + HDfflush(stdout); #endif H5MM_xfree(node_ptr); #if S3COMMS_DEBUG -HDprintf("FREEING WORKING LOWERNAME\n"); HDfflush(stdout); + HDprintf("FREEING WORKING LOWERNAME\n"); + HDfflush(stdout); #endif - H5MM_xfree(lowername); lowername = NULL; + H5MM_xfree(lowername); + lowername = NULL; } else { #if S3COMMS_DEBUG -HDprintf("MODIFY HEAD\n"); HDfflush(stdout); + HDprintf("MODIFY HEAD\n"); + HDfflush(stdout); #endif /*************** * MODIFY HEAD * @@ -397,27 +393,27 @@ HDprintf("MODIFY HEAD\n"); HDfflush(stdout); H5MM_xfree(node_ptr->name); H5MM_xfree(node_ptr->value); - node_ptr->name = namecpy; + node_ptr->name = namecpy; node_ptr->value = valuecpy; - node_ptr->cat = nvcat; + node_ptr->cat = nvcat; H5MM_xfree(lowername); lowername = NULL; new_node->magic += 1ul; H5MM_xfree(new_node); - new_node = NULL; + new_node = NULL; } } - else - if (HDstrcmp(lowername, node_ptr->lowername) < 0) { + else if (HDstrcmp(lowername, node_ptr->lowername) < 0) { is_looking = FALSE; - if(value == NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove a node 'before' head") else { #if S3COMMS_DEBUG -HDprintf("PREPEND NEW HEAD\n"); HDfflush(stdout); + HDprintf("PREPEND NEW HEAD\n"); + HDfflush(stdout); #endif /******************* * INSERT NEW HEAD * @@ -428,7 +424,7 @@ HDprintf("PREPEND NEW HEAD\n"); HDfflush(stdout); new_node->lowername = lowername; new_node->cat = nvcat; new_node->next = node_ptr; - *L = new_node; + *L = new_node; } } @@ -436,22 +432,23 @@ HDprintf("PREPEND NEW HEAD\n"); HDfflush(stdout); * SEARCH LIST * ***************/ - while(is_looking) { - if(node_ptr->next == NULL) { + while (is_looking) { + if (node_ptr->next == NULL) { is_looking = FALSE; - if(value == NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node") else { #if S3COMMS_DEBUG -HDprintf("APPEND A NODE\n"); HDfflush(stdout); + HDprintf("APPEND A NODE\n"); + HDfflush(stdout); #endif /******************* * APPEND NEW NODE * *******************/ - HDassert( HDstrcmp(lowername, node_ptr->lowername) > 0 ); + HDassert(HDstrcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -459,22 +456,22 @@ HDprintf("APPEND A NODE\n"); HDfflush(stdout); node_ptr->next = new_node; } } - else - if(HDstrcmp(lowername, node_ptr->next->lowername) < 0) { + else if (HDstrcmp(lowername, node_ptr->next->lowername) < 0) { is_looking = FALSE; - if(value == NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trying to remove absent node") else { #if S3COMMS_DEBUG -HDprintf("INSERT A NODE\n"); HDfflush(stdout); + HDprintf("INSERT A NODE\n"); + HDfflush(stdout); #endif /******************* * INSERT NEW NODE * *******************/ - HDassert( HDstrcmp(lowername, node_ptr->lowername) > 0 ); + HDassert(HDstrcmp(lowername, node_ptr->lowername) > 0); new_node->name = namecpy; new_node->value = valuecpy; new_node->lowername = lowername; @@ -483,28 +480,28 @@ HDprintf("INSERT A NODE\n"); HDfflush(stdout); node_ptr->next = new_node; } } - else - if(HDstrcmp(lowername, node_ptr->next->lowername) == 0) { + else if (HDstrcmp(lowername, node_ptr->next->lowername) == 0) { is_looking = FALSE; - if(value == NULL) { + if (value == NULL) { /***************** * REMOVE A NODE * *****************/ hrb_node_t *tmp = node_ptr->next; - node_ptr->next = tmp->next; + node_ptr->next = tmp->next; #if S3COMMS_DEBUG -HDprintf("REMOVE A NODE\n"); HDfflush(stdout); + HDprintf("REMOVE A NODE\n"); + HDfflush(stdout); #endif H5MM_xfree(tmp->cat); H5MM_xfree(tmp->lowername); H5MM_xfree(tmp->name); H5MM_xfree(tmp->value); - HDassert( tmp->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(tmp->magic == S3COMMS_HRB_NODE_MAGIC); tmp->magic += 1ul; H5MM_xfree(tmp); @@ -513,7 +510,8 @@ HDprintf("REMOVE A NODE\n"); HDfflush(stdout); } else { #if S3COMMS_DEBUG -HDprintf("MODIFY A NODE\n"); HDfflush(stdout); + HDprintf("MODIFY A NODE\n"); + HDfflush(stdout); #endif /***************** * MODIFY A NODE * @@ -524,7 +522,7 @@ HDprintf("MODIFY A NODE\n"); HDfflush(stdout); H5MM_xfree(node_ptr->value); H5MM_xfree(node_ptr->cat); - HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(new_node->magic == S3COMMS_HRB_NODE_MAGIC); new_node->magic += 1ul; H5MM_xfree(new_node); H5MM_xfree(lowername); @@ -541,23 +539,23 @@ HDprintf("MODIFY A NODE\n"); HDfflush(stdout); * KEEP LOOKING * ****************/ - node_ptr = node_ptr->next; + node_ptr = node_ptr->next; } } /* end while is_looking */ done: - if(ret_value == FAIL) { + if (ret_value == FAIL) { /* clean up */ - if(nvcat != NULL) + if (nvcat != NULL) H5MM_xfree(nvcat); - if(namecpy != NULL) + if (namecpy != NULL) H5MM_xfree(namecpy); - if(lowername != NULL) + if (lowername != NULL) H5MM_xfree(lowername); - if(valuecpy != NULL) + if (valuecpy != NULL) H5MM_xfree(valuecpy); - if(new_node != NULL) { - HDassert( new_node->magic == S3COMMS_HRB_NODE_MAGIC ); + if (new_node != NULL) { + HDassert(new_node->magic == S3COMMS_HRB_NODE_MAGIC); new_node->magic += 1ul; H5MM_xfree(new_node); } @@ -566,7 +564,6 @@ HDprintf("MODIFY A NODE\n"); HDfflush(stdout); FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_hrb_node_set() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_destroy() @@ -606,8 +603,8 @@ HDprintf("MODIFY A NODE\n"); HDfflush(stdout); herr_t H5FD_s3comms_hrb_destroy(hrb_t **_buf) { - hrb_t *buf = NULL; - herr_t ret_value = SUCCEED; + hrb_t *buf = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -615,9 +612,9 @@ H5FD_s3comms_hrb_destroy(hrb_t **_buf) HDfprintf(stdout, "called H5FD_s3comms_hrb_destroy.\n"); #endif - if(_buf != NULL && *_buf != NULL) { + if (_buf != NULL && *_buf != NULL) { buf = *_buf; - if(buf->magic != S3COMMS_HRB_MAGIC) + if (buf->magic != S3COMMS_HRB_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pointer's magic does not match."); H5MM_xfree(buf->verb); @@ -632,7 +629,6 @@ H5FD_s3comms_hrb_destroy(hrb_t **_buf) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_hrb_destroy() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_hrb_init_request() @@ -663,18 +659,16 @@ H5FD_s3comms_hrb_destroy(hrb_t **_buf) *---------------------------------------------------------------------------- */ hrb_t * -H5FD_s3comms_hrb_init_request(const char *_verb, - const char *_resource, - const char *_http_version) +H5FD_s3comms_hrb_init_request(const char *_verb, const char *_resource, const char *_http_version) { - hrb_t *request = NULL; - char *res = NULL; - size_t reslen = 0; - hrb_t *ret_value = NULL; - char *verb = NULL; - size_t verblen = 0; - char *vrsn = NULL; - size_t vrsnlen = 0; + hrb_t *request = NULL; + char * res = NULL; + size_t reslen = 0; + hrb_t *ret_value = NULL; + char * verb = NULL; + size_t verblen = 0; + char * vrsn = NULL; + size_t vrsnlen = 0; FUNC_ENTER_NOAPI_NOINIT @@ -682,56 +676,54 @@ H5FD_s3comms_hrb_init_request(const char *_verb, HDfprintf(stdout, "called H5FD_s3comms_hrb_init_request.\n"); #endif - if(_resource == NULL) + if (_resource == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "resource string cannot be null."); /* populate valid NULLs with defaults */ - if(_verb == NULL) + if (_verb == NULL) _verb = "GET"; - if(_http_version == NULL) + if (_http_version == NULL) _http_version = "HTTP/1.1"; /* malloc space for and prepare structure */ request = (hrb_t *)H5MM_malloc(sizeof(hrb_t)); - if(request == NULL) + if (request == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for request structure"); request->magic = S3COMMS_HRB_MAGIC; request->body = NULL; request->body_len = 0; request->first_header = NULL; - /* malloc and copy strings for the structure */ reslen = HDstrlen(_resource); if (_resource[0] == '/') { - res = (char *)H5MM_malloc(sizeof(char) * (reslen+1)); - if(res == NULL) + res = (char *)H5MM_malloc(sizeof(char) * (reslen + 1)); + if (res == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); - HDmemcpy(res, _resource, (reslen+1)); + H5MM_memcpy(res, _resource, (reslen + 1)); } else { - res = (char *)H5MM_malloc(sizeof(char) * (reslen+2)); - if(res == NULL) + res = (char *)H5MM_malloc(sizeof(char) * (reslen + 2)); + if (res == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "no space for resource string"); *res = '/'; - HDmemcpy((&res[1]), _resource, (reslen+1)); - HDassert( (reslen+1) == HDstrlen(res) ); + H5MM_memcpy((&res[1]), _resource, (reslen + 1)); + HDassert((reslen + 1) == HDstrlen(res)); } /* end if (else resource string not starting with '/') */ verblen = HDstrlen(_verb) + 1; - verb = (char *)H5MM_malloc(sizeof(char) * verblen); - if(verb == NULL) + verb = (char *)H5MM_malloc(sizeof(char) * verblen); + if (verb == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for verb string"); HDstrncpy(verb, _verb, verblen); vrsnlen = HDstrlen(_http_version) + 1; - vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); - if(vrsn == NULL) + vrsn = (char *)H5MM_malloc(sizeof(char) * vrsnlen); + if (vrsn == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no space for http-version string"); HDstrncpy(vrsn, _http_version, vrsnlen); - /* place new copies into structure */ request->resource = res; request->verb = verb; @@ -742,25 +734,23 @@ H5FD_s3comms_hrb_init_request(const char *_verb, done: /* if there is an error, clean up after ourselves */ if (ret_value == NULL) { - if(request != NULL) + if (request != NULL) H5MM_xfree(request); - if(vrsn != NULL) + if (vrsn != NULL) H5MM_xfree(vrsn); - if(verb != NULL) + if (verb != NULL) H5MM_xfree(verb); - if(res != NULL) + if (res != NULL) H5MM_xfree(res); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_hrb_init_request() */ - /**************************************************************************** * S3R FUNCTIONS ****************************************************************************/ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_close() @@ -793,9 +783,9 @@ H5FD_s3comms_s3r_close(s3r_t *handle) HDfprintf(stdout, "called H5FD_s3comms_s3r_close.\n"); #endif - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); - if(handle->magic != S3COMMS_S3R_MAGIC) + if (handle->magic != S3COMMS_S3R_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); curl_easy_cleanup(handle->curlhandle); @@ -804,10 +794,10 @@ H5FD_s3comms_s3r_close(s3r_t *handle) H5MM_xfree(handle->region); H5MM_xfree(handle->signing_key); - HDassert( handle->httpverb != NULL ); + HDassert(handle->httpverb != NULL); H5MM_xfree(handle->httpverb); - if(FAIL == H5FD_s3comms_free_purl(handle->purl)) + if (FAIL == H5FD_s3comms_free_purl(handle->purl)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to release parsed url structure") H5MM_xfree(handle); @@ -816,7 +806,6 @@ H5FD_s3comms_s3r_close(s3r_t *handle) FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_close */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_get_filesize() @@ -844,13 +833,12 @@ H5FD_s3comms_s3r_get_filesize(s3r_t *handle) FUNC_ENTER_NOAPI_NOINIT_NOERR - if(handle != NULL) + if (handle != NULL) ret_value = handle->filesize; FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_get_filesize */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_getsize() @@ -887,15 +875,12 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle) { uintmax_t content_length = 0; - CURL *curlh = NULL; - char *end = NULL; - char *headerresponse = NULL; - struct s3r_datastruct sds = { - S3COMMS_CALLBACK_DATASTRUCT_MAGIC, - NULL, - 0 }; - char *start = NULL; - herr_t ret_value = SUCCEED; + CURL * curlh = NULL; + char * end = NULL; + char * headerresponse = NULL; + struct s3r_datastruct sds = {S3COMMS_CALLBACK_DATASTRUCT_MAGIC, NULL, 0}; + char * start = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -903,11 +888,11 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) HDfprintf(stdout, "called H5FD_s3comms_s3r_getsize.\n"); #endif - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); - if(handle->magic != S3COMMS_S3R_MAGIC) + if (handle->magic != S3COMMS_S3R_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); - if(handle->curlhandle == NULL) + if (handle->curlhandle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.") /******************** @@ -915,20 +900,20 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) ********************/ curlh = handle->curlhandle; - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, 1L)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, 1L)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, &sds)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, &sds)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA)."); - HDassert( handle->httpverb == NULL ); + HDassert(handle->httpverb == NULL); handle->httpverb = (char *)H5MM_malloc(sizeof(char) * 16); - if(handle->httpverb == NULL) + if (handle->httpverb == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for S3 request HTTP verb"); - HDmemcpy(handle->httpverb, "HEAD", 5); + H5MM_memcpy(handle->httpverb, "HEAD", 5); headerresponse = (char *)H5MM_malloc(sizeof(char) * CURL_MAX_HTTP_HEADER); - if(headerresponse == NULL) + if (headerresponse == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "unable to allocate space for curl header response"); sds.data = headerresponse; @@ -940,10 +925,10 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * but, with a NULL destination and NOBODY and HEADERDATA supplied above, * only http metadata will be sent by server and recorded by s3comms */ - if(FAIL == H5FD_s3comms_s3r_read(handle, 0, 0, NULL)) + if (FAIL == H5FD_s3comms_s3r_read(handle, 0, 0, NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem in reading during getsize."); - if(sds.size > CURL_MAX_HTTP_HEADER) + if (sds.size > CURL_MAX_HTTP_HEADER) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HTTP metadata buffer overrun") else if (sds.size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "No HTTP metadata") @@ -952,19 +937,18 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) HDfprintf(stderr, "GETSIZE: OK\n"); #endif - /****************** * PARSE RESPONSE * ******************/ start = HDstrstr(headerresponse, "\r\nContent-Length: "); - if(start == NULL) + if (start == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find \"Content-Length\" in response."); /* move "start" to beginning of value in line; find end of line */ start = start + HDstrlen("\r\nContent-Length: "); - end = HDstrstr(start, "\r\n"); - if(end == NULL) + end = HDstrstr(start, "\r\n"); + if (end == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not find end of content length line"); /* place null terminator at end of numbers @@ -972,11 +956,13 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) *end = '\0'; content_length = HDstrtoumax((const char *)start, NULL, 0); - if(UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) + if (UINTMAX_MAX > SIZE_MAX && content_length > SIZE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "content_length overflows size_t"); - if(content_length == 0 || errno == ERANGE) /* errno set by HDstrtoumax*/ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert found \"Content-Length\" response (\"%s\")", start); /* range is null-terminated, remember */ + if (content_length == 0 || errno == ERANGE) /* errno set by HDstrtoumax*/ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "could not convert found \"Content-Length\" response (\"%s\")", + start); /* range is null-terminated, remember */ handle->filesize = (size_t)content_length; @@ -984,10 +970,10 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) * UNDO HEAD SETTINGS * **********************/ - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, NULL)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_NOBODY, NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_NOBODY)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, NULL)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HEADERDATA, NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HEADERDATA)."); done: @@ -997,7 +983,6 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_s3r_getsize */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_open() @@ -1038,16 +1023,13 @@ H5FD_s3comms_s3r_getsize(s3r_t *handle) *---------------------------------------------------------------------------- */ s3r_t * -H5FD_s3comms_s3r_open(const char *url, - const char *region, - const char *id, - const unsigned char *signing_key) +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 @@ -1055,62 +1037,60 @@ H5FD_s3comms_s3r_open(const char *url, HDfprintf(stdout, "called H5FD_s3comms_s3r_open.\n"); #endif - if(url == NULL || url[0] == '\0') + if (url == NULL || url[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "url cannot be null."); - if(FAIL == H5FD_s3comms_parse_url(url, &purl)) + if (FAIL == H5FD_s3comms_parse_url(url, &purl)) /* probably a malformed url, but could be internal error */ HGOTO_ERROR(H5E_ARGS, H5E_CANTCREATE, NULL, "unable to create parsed url structure"); - HDassert( purl != NULL ); /* if above passes, this must be true */ - HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); + HDassert(purl != NULL); /* if above passes, this must be true */ + HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); handle = (s3r_t *)H5MM_malloc(sizeof(s3r_t)); - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, NULL, "could not malloc space for handle."); - handle->magic = S3COMMS_S3R_MAGIC; - handle->purl = purl; - handle->filesize = 0; - handle->region = NULL; - handle->secret_id = NULL; - handle->signing_key = NULL; - handle->httpverb = NULL; + handle->magic = S3COMMS_S3R_MAGIC; + handle->purl = purl; + handle->filesize = 0; + handle->region = NULL; + handle->secret_id = NULL; + handle->signing_key = NULL; + handle->httpverb = NULL; /************************************* * RECORD AUTHENTICATION INFORMATION * *************************************/ - if((region != NULL && *region != '\0') || - (id != NULL && *id != '\0') || - (signing_key != NULL)) { + if ((region != NULL && *region != '\0') || (id != NULL && *id != '\0') || (signing_key != NULL)) { /* if one exists, all three must exist */ - if(region == NULL || region[0] == '\0') + if (region == NULL || region[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "region cannot be null."); - if(id == NULL || id[0] == '\0') + if (id == NULL || id[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "secret id cannot be null."); - if(signing_key == NULL) + if (signing_key == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "signing key cannot be null."); /* copy strings */ - tmplen = HDstrlen(region) + 1; + tmplen = HDstrlen(region) + 1; handle->region = (char *)H5MM_malloc(sizeof(char) * tmplen); - if(handle->region == NULL) + if (handle->region == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle region copy."); - HDmemcpy(handle->region, region, tmplen); + H5MM_memcpy(handle->region, region, tmplen); - tmplen = HDstrlen(id) + 1; + tmplen = HDstrlen(id) + 1; handle->secret_id = (char *)H5MM_malloc(sizeof(char) * tmplen); - if(handle->secret_id == NULL) + if (handle->secret_id == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle ID copy."); - HDmemcpy(handle->secret_id, id, tmplen); + H5MM_memcpy(handle->secret_id, id, tmplen); - tmplen = SHA256_DIGEST_LENGTH; + tmplen = SHA256_DIGEST_LENGTH; handle->signing_key = (unsigned char *)H5MM_malloc(sizeof(unsigned char) * tmplen); - if(handle->signing_key == NULL) + if (handle->signing_key == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "could not malloc space for handle key copy."); - HDmemcpy(handle->signing_key, signing_key, tmplen); + H5MM_memcpy(handle->signing_key, signing_key, tmplen); } /* if authentication information provided */ /************************ @@ -1118,22 +1098,22 @@ H5FD_s3comms_s3r_open(const char *url, ************************/ curlh = curl_easy_init(); - if(curlh == NULL) + if (curlh == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem creating curl easy handle!"); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPGET, 1L)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPGET, 1L)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTPGET)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_HTTP_VERSION)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_FAILONERROR, 1L)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_FAILONERROR, 1L)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_FAILONERROR)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEFUNCTION, curlwritecallback)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEFUNCTION, curlwritecallback)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_WRITEFUNCTION)."); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_URL, url)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_URL, url)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "error while setting CURL option (CURLOPT_URL)."); #if S3COMMS_CURL_VERBOSITY > 1 @@ -1150,29 +1130,29 @@ H5FD_s3comms_s3r_open(const char *url, * GET FILE SIZE * *******************/ - if(FAIL == H5FD_s3comms_s3r_getsize(handle)) + if (FAIL == H5FD_s3comms_s3r_getsize(handle)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "problem in H5FD_s3comms_s3r_getsize."); /********************* * FINAL PREPARATION * *********************/ - HDassert( handle->httpverb != NULL ); - HDmemcpy(handle->httpverb, "GET", 4); + HDassert(handle->httpverb != NULL); + H5MM_memcpy(handle->httpverb, "GET", 4); ret_value = handle; done: - if(ret_value == NULL) { - if(curlh != NULL) + if (ret_value == NULL) { + if (curlh != NULL) curl_easy_cleanup(curlh); - if(FAIL == H5FD_s3comms_free_purl(purl)) + if (FAIL == H5FD_s3comms_free_purl(purl)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to free parsed url structure") - if(handle != NULL) { + if (handle != NULL) { H5MM_xfree(handle->region); H5MM_xfree(handle->secret_id); H5MM_xfree(handle->signing_key); - if(handle->httpverb != NULL) + if (handle->httpverb != NULL) H5MM_xfree(handle->httpverb); H5MM_xfree(handle); } @@ -1181,7 +1161,6 @@ H5FD_s3comms_s3r_open(const char *url, FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_s3comms_s3r_open */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_s3r_read() @@ -1224,23 +1203,20 @@ H5FD_s3comms_s3r_open(const char *url, *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_s3r_read(s3r_t *handle, - haddr_t offset, - size_t len, - void *dest) +H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) { - 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; - int ret = 0; /* working variable to check */ - /* return value of HDsnprintf */ - struct s3r_datastruct *sds = NULL; - herr_t ret_value = SUCCEED; + 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; + int ret = 0; /* working variable to check */ + /* return value of HDsnprintf */ + struct s3r_datastruct *sds = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1252,16 +1228,16 @@ H5FD_s3comms_s3r_read(s3r_t *handle, * ABSOLUTELY NECESSARY SANITY-CHECKS * **************************************/ - if(handle == NULL) + if (handle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle cannot be null."); - if(handle->magic != S3COMMS_S3R_MAGIC) + if (handle->magic != S3COMMS_S3R_MAGIC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has invalid magic."); - if(handle->curlhandle == NULL) + if (handle->curlhandle == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) curlhandle.") - if(handle->purl == NULL) + if (handle->purl == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle has bad (null) url.") - HDassert( handle->purl->magic == S3COMMS_PARSED_URL_MAGIC ); - if(offset > handle->filesize || (len + offset) > handle->filesize) + HDassert(handle->purl->magic == S3COMMS_PARSED_URL_MAGIC); + if (offset > handle->filesize || (len + offset) > handle->filesize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to read past EoF") curlh = handle->curlhandle; @@ -1270,16 +1246,17 @@ H5FD_s3comms_s3r_read(s3r_t *handle, * PREPARE WRITEDATA * *********************/ - if(dest != NULL) { + if (dest != NULL) { sds = (struct s3r_datastruct *)H5MM_malloc(sizeof(struct s3r_datastruct)); - if(sds == NULL) + if (sds == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc destination datastructure."); sds->magic = S3COMMS_CALLBACK_DATASTRUCT_MAGIC; - sds->data = (char *)dest; - sds->size = 0; - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEDATA, sds)) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "error while setting CURL option (CURLOPT_WRITEDATA)."); + sds->data = (char *)dest; + sds->size = 0; + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_WRITEDATA, sds)) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, + "error while setting CURL option (CURLOPT_WRITEDATA)."); } /********************* @@ -1287,21 +1264,20 @@ H5FD_s3comms_s3r_read(s3r_t *handle, *********************/ if (len > 0) { - rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE+1) ); - if(rangebytesstr == NULL) + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); + if (rangebytesstr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string."); - ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), - "bytes="H5_PRINTF_HADDR_FMT"-"H5_PRINTF_HADDR_FMT, - offset, offset + len - 1); - if(ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=%" PRIuHADDR "-%" PRIuHADDR, + offset, offset + len - 1); + if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); - } else if(offset > 0) { - rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE+1)); - if(rangebytesstr == NULL) + } + else if (offset > 0) { + rangebytesstr = (char *)H5MM_malloc(sizeof(char) * (S3COMMS_MAX_RANGE_STRING_SIZE + 1)); + if (rangebytesstr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "could not malloc range format string."); - ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), - "bytes="H5_PRINTF_HADDR_FMT"-", offset); - if(ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) + ret = HDsnprintf(rangebytesstr, (S3COMMS_MAX_RANGE_STRING_SIZE), "bytes=%" PRIuHADDR "-", offset); + if (ret <= 0 || ret >= S3COMMS_MAX_RANGE_STRING_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format HTTP Range value"); } @@ -1311,39 +1287,41 @@ H5FD_s3comms_s3r_read(s3r_t *handle, if (handle->signing_key == NULL) { /* Do not authenticate. */ - if(rangebytesstr != NULL) { + if (rangebytesstr != NULL) { /* Pass in range directly */ char *bytesrange_ptr = NULL; /* pointer past "bytes=" portion */ bytesrange_ptr = HDstrchr(rangebytesstr, '='); - HDassert( bytesrange_ptr != NULL ); + HDassert(bytesrange_ptr != NULL); bytesrange_ptr++; /* move to first char past '=' */ - HDassert( *bytesrange_ptr != '\0' ); + HDassert(*bytesrange_ptr != '\0'); - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, bytesrange_ptr)) - HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "error while setting CURL option (CURLOPT_RANGE). "); + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, bytesrange_ptr)) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, + "error while setting CURL option (CURLOPT_RANGE). "); } - } else { + } + else { /* authenticate request */ - char authorization[512+1]; - /* 512 := approximate max length... - * 67 - * + 8 - * + 64 - * + 128 - * + 20 - * + 128 - */ - char buffer1[512+1]; /* -> Canonical Request -> Signature */ - char buffer2[256+1]; /* -> String To Sign -> Credential */ + char authorization[512 + 1]; + /* 512 := approximate max length... + * 67 + * + 8 + * + 64 + * + 128 + * + 20 + * + 128 + */ + char buffer1[512 + 1]; /* -> Canonical Request -> Signature */ + char buffer2[256 + 1]; /* -> String To Sign -> Credential */ char iso8601now[ISO8601_SIZE]; - char signed_headers[48+1]; - /* should be large enough for nominal listing: - * "host;range;x-amz-content-sha256;x-amz-date" - * + '\0', with "range;" possibly absent - */ + char signed_headers[48 + 1]; + /* should be large enough for nominal listing: + * "host;range;x-amz-content-sha256;x-amz-date" + * + '\0', with "range;" possibly absent + */ /* zero start of strings */ authorization[0] = 0; @@ -1354,88 +1332,86 @@ H5FD_s3comms_s3r_read(s3r_t *handle, /**** VERIFY INFORMATION EXISTS ****/ - if(handle->region == NULL) + if (handle->region == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null region."); - if(handle->secret_id == NULL) + if (handle->secret_id == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null secret_id."); - if(handle->signing_key == NULL) + if (handle->signing_key == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null signing_key."); - if(handle->httpverb == NULL) + if (handle->httpverb == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null httpverb."); - if(handle->purl->host == NULL) + if (handle->purl->host == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null host."); - if(handle->purl->path == NULL) + if (handle->purl->path == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "handle must have non-null resource."); /**** CREATE HTTP REQUEST STRUCTURE (hrb_t) ****/ - request = H5FD_s3comms_hrb_init_request( - (const char *)handle->httpverb, - (const char *)handle->purl->path, - "HTTP/1.1"); - if(request == NULL) + request = H5FD_s3comms_hrb_init_request((const char *)handle->httpverb, + (const char *)handle->purl->path, "HTTP/1.1"); + if (request == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not allocate hrb_t request."); - HDassert( request->magic == S3COMMS_HRB_MAGIC ); + HDassert(request->magic == S3COMMS_HRB_MAGIC); now = gmnow(); - if(ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) + if (ISO8601NOW(iso8601now, now) != (ISO8601_SIZE - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not format ISO8601 time."); - if(FAIL == H5FD_s3comms_hrb_node_set( &headers, "x-amz-date", (const char *)iso8601now)) + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-date", (const char *)iso8601now)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-date header") - if(headers == NULL) + if (headers == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); - if(FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-content-sha256", (const char *)EMPTY_SHA256)) + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "x-amz-content-sha256", (const char *)EMPTY_SHA256)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set x-amz-content-sha256 header") - if(headers == NULL) + if (headers == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); - if(rangebytesstr != NULL) { - if(FAIL == H5FD_s3comms_hrb_node_set( &headers, "Range", rangebytesstr)) + if (rangebytesstr != NULL) { + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Range", rangebytesstr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set range header") - if(headers == NULL) + if (headers == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); } - if(FAIL == H5FD_s3comms_hrb_node_set(&headers, "Host", handle->purl->host)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set host header") - if(headers == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); - HDassert( headers->magic == S3COMMS_HRB_NODE_MAGIC ); + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, "Host", handle->purl->host)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set host header") + if (headers == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); + HDassert(headers->magic == S3COMMS_HRB_NODE_MAGIC); request->first_header = headers; /**** COMPUTE AUTHORIZATION ****/ /* buffer1 -> canonical request */ - if(FAIL == H5FD_s3comms_aws_canonical_request(buffer1, 512, signed_headers, 48, request)) + if (FAIL == H5FD_s3comms_aws_canonical_request(buffer1, 512, signed_headers, 48, request)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad canonical request"); /* buffer2->string-to-sign */ - if(FAIL == H5FD_s3comms_tostringtosign(buffer2, buffer1, iso8601now, handle->region)) + if (FAIL == H5FD_s3comms_tostringtosign(buffer2, buffer1, iso8601now, handle->region)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad string-to-sign"); /* buffer1 -> signature */ - if(FAIL == H5FD_s3comms_HMAC_SHA256(handle->signing_key, SHA256_DIGEST_LENGTH, buffer2, HDstrlen(buffer2), buffer1)) + if (FAIL == H5FD_s3comms_HMAC_SHA256(handle->signing_key, SHA256_DIGEST_LENGTH, buffer2, + HDstrlen(buffer2), buffer1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad signature"); iso8601now[8] = 0; /* trim to yyyyMMDD */ ret = S3COMMS_FORMAT_CREDENTIAL(buffer2, handle->secret_id, iso8601now, handle->region, "s3"); - if(ret == 0 || ret >= S3COMMS_MAX_CREDENTIAL_SIZE) + if (ret == 0 || ret >= S3COMMS_MAX_CREDENTIAL_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format aws4 credential string"); - ret = HDsnprintf( authorization, 512, - "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", - buffer2, signed_headers, buffer1); - if(ret <= 0 || ret >= 512) + ret = HDsnprintf(authorization, 512, "AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s", + buffer2, signed_headers, buffer1); + if (ret <= 0 || ret >= 512) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to format aws4 authorization string"); /* append authorization header to http request buffer */ - if(H5FD_s3comms_hrb_node_set(&headers, "Authorization", (const char *)authorization) == FAIL) + if (H5FD_s3comms_hrb_node_set(&headers, "Authorization", (const char *)authorization) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to set Authorization header") - if(headers == NULL) + if (headers == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem building headers list."); /* update hrb's "first header" pointer */ @@ -1444,22 +1420,23 @@ H5FD_s3comms_s3r_read(s3r_t *handle, /**** SET CURLHANDLE HTTP HEADERS FROM GENERATED DATA ****/ node = request->first_header; - while(node != NULL) { - HDassert( node->magic == S3COMMS_HRB_NODE_MAGIC ); + while (node != NULL) { + HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); curlheaders = curl_slist_append(curlheaders, (const char *)node->cat); - if(curlheaders == NULL) + if (curlheaders == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not append header to curl slist."); node = node->next; } /* sanity-check */ - if(curlheaders == NULL) + if (curlheaders == NULL) /* above loop was probably never run */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "curlheaders was never populated."); /* finally, set http headers in curl handle */ - if(curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, curlheaders) != CURLE_OK) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while setting CURL option (CURLOPT_HTTPHEADER)."); + if (curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, curlheaders) != CURLE_OK) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "error while setting CURL option (CURLOPT_HTTPHEADER)."); } /* end if should authenticate (info provided) */ /******************* @@ -1475,39 +1452,38 @@ H5FD_s3comms_s3r_read(s3r_t *handle, char curlerrbuf[CURL_ERROR_SIZE]; curlerrbuf[0] = '\0'; - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, curlerrbuf)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem setting error buffer") p_status = curl_easy_perform(curlh); - if(p_status != CURLE_OK) { - if(CURLE_OK != curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode)) + if (p_status != CURLE_OK) { + if (CURLE_OK != curl_easy_getinfo(curlh, CURLINFO_RESPONSE_CODE, &httpcode)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem getting response code") - HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", - p_status, httpcode); + HDfprintf(stderr, "CURL ERROR CODE: %d\nHTTP CODE: %d\n", p_status, httpcode); HDfprintf(stderr, "%s\n", curl_easy_strerror(p_status)); HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "problem while performing request."); } - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_ERRORBUFFER, NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem unsetting error buffer") } /* verbose error reporting */ #else p_status = curl_easy_perform(curlh); - if(p_status != CURLE_OK) + if (p_status != CURLE_OK) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "curl cannot perform request") #endif #if S3COMMS_DEBUG - if(dest != NULL) { + if (dest != NULL) { HDfprintf(stderr, "len: %d\n", (int)len); HDfprintf(stderr, "CHECKING FOR BUFFER OVERFLOW\n"); - if(sds == NULL) + if (sds == NULL) HDfprintf(stderr, "sds is NULL!\n"); else { HDfprintf(stderr, "sds: 0x%lx\n", (long long)sds); HDfprintf(stderr, "sds->size: %d\n", (int)sds->size); - if(len > sds->size) + if (len > sds->size) HDfprintf(stderr, "buffer overwrite\n"); } } @@ -1518,47 +1494,45 @@ H5FD_s3comms_s3r_read(s3r_t *handle, done: /* clean any malloc'd resources */ - if(curlheaders != NULL) { + if (curlheaders != NULL) { curl_slist_free_all(curlheaders); curlheaders = NULL; } - if(rangebytesstr != NULL) { + if (rangebytesstr != NULL) { H5MM_xfree(rangebytesstr); rangebytesstr = NULL; } - if(sds != NULL) { + if (sds != NULL) { H5MM_xfree(sds); sds = NULL; } - if(request != NULL) { - while(headers != NULL) - if(FAIL == H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) + if (request != NULL) { + while (headers != NULL) + if (FAIL == H5FD_s3comms_hrb_node_set(&headers, headers->name, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header node") - HDassert( NULL == headers ); - if(FAIL == H5FD_s3comms_hrb_destroy(&request)) + HDassert(NULL == headers); + if (FAIL == H5FD_s3comms_hrb_destroy(&request)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot release header request structure") - HDassert( NULL == request ); + HDassert(NULL == request); } - if(curlh != NULL) { + if (curlh != NULL) { /* clear any Range */ - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_RANGE, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_RANGE") /* clear headers */ - if(CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL)) + if (CURLE_OK != curl_easy_setopt(curlh, CURLOPT_HTTPHEADER, NULL)) HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot unset CURLOPT_HTTPHEADER") } FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_s3r_read */ - /**************************************************************************** * MISCELLANEOUS FUNCTIONS ****************************************************************************/ - /*---------------------------------------------------------------------------- * * Function: gmnow() @@ -1581,19 +1555,18 @@ 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() */ - if((time_t)(-1) != HDtime(now_ptr)) + if ((time_t)(-1) != HDtime(now_ptr)) ret_value = HDgmtime(now_ptr); - HDassert( ret_value != NULL ); + HDassert(ret_value != NULL); return ret_value; } /* end gmnow() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_aws_canonical_request() @@ -1634,12 +1607,8 @@ gmnow(void) *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_aws_canonical_request( - char *canonical_request_dest, - int _cr_size, - char *signed_headers_dest, - int _sh_size, - hrb_t *http_request) +H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int _cr_size, char *signed_headers_dest, + int _sh_size, hrb_t *http_request) { hrb_node_t *node = NULL; const char *query_params = ""; /* unused at present */ @@ -1649,8 +1618,8 @@ H5FD_s3comms_aws_canonical_request( size_t sh_size = (size_t)_sh_size; size_t cr_len = 0; /* working length of canonical request str */ size_t sh_len = 0; /* working length of signed headers str */ - char tmpstr[256+1]; - tmpstr[256] = 0; /* terminating NULL */ + char tmpstr[256 + 1]; + tmpstr[256] = 0; /* terminating NULL */ /* "query params" refers to the optional element in the URL, e.g. * http://bucket.aws.com/myfile.txt?max-keys=2&prefix=J @@ -1668,49 +1637,48 @@ H5FD_s3comms_aws_canonical_request( HDfprintf(stdout, "called H5FD_s3comms_aws_canonical_request.\n"); #endif - if(http_request == NULL) + if (http_request == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hrb object cannot be null."); - HDassert( http_request->magic == S3COMMS_HRB_MAGIC ); + HDassert(http_request->magic == S3COMMS_HRB_MAGIC); - if(canonical_request_dest == NULL) + if (canonical_request_dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request destination cannot be null."); - if(signed_headers_dest == NULL) + if (signed_headers_dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "signed headers destination cannot be null."); /* HTTP verb, resource path, and query string lines */ - cr_len = (HDstrlen(http_request->verb) + - HDstrlen(http_request->resource) + - HDstrlen(query_params) + - (size_t)3); /* three newline chars */ - if(cr_len >= cr_size) + cr_len = (HDstrlen(http_request->verb) + HDstrlen(http_request->resource) + HDstrlen(query_params) + + (size_t)3); /* three newline chars */ + if (cr_len >= cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); /* TODO: compiler warning */ - ret = HDsnprintf(canonical_request_dest, (cr_size - 1), - "%s\n%s\n%s\n", - http_request->verb, http_request->resource, query_params); - if(ret < 0 || (size_t)ret >= cr_size) + ret = HDsnprintf(canonical_request_dest, (cr_size - 1), "%s\n%s\n%s\n", http_request->verb, + http_request->resource, query_params); + if (ret < 0 || (size_t)ret >= cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to compose canonical request first line"); /* write in canonical headers, building signed headers concurrently */ node = http_request->first_header; /* assumed sorted */ - while(node != NULL) { + while (node != NULL) { HDassert(node->magic == S3COMMS_HRB_NODE_MAGIC); - ret = HDsnprintf( tmpstr, 256, "%s:%s\n", node->lowername, node->value); - if(ret < 0 || ret >= 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to concatenate HTTP header %s:%s", node->lowername, node->value); + ret = HDsnprintf(tmpstr, 256, "%s:%s\n", node->lowername, node->value); + if (ret < 0 || ret >= 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to concatenate HTTP header %s:%s", + node->lowername, node->value); cr_len += HDstrlen(tmpstr); - if(cr_len + 1 > cr_size) + if (cr_len + 1 > cr_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in canonical request"); HDstrcat(canonical_request_dest, tmpstr); - ret = HDsnprintf( tmpstr, 256, "%s;", node->lowername); - if(ret < 0 || ret >= 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to append semicolon to lowername %s", node->lowername); + ret = HDsnprintf(tmpstr, 256, "%s;", node->lowername); + if (ret < 0 || ret >= 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to append semicolon to lowername %s", + node->lowername); sh_len += HDstrlen(tmpstr); - if(sh_len + 1 > sh_size) + if (sh_len + 1 > sh_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not enough space in signed headers"); HDstrcat(signed_headers_dest, tmpstr); @@ -1733,7 +1701,6 @@ H5FD_s3comms_aws_canonical_request( FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_aws_canonical_request() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_bytes_to_hex() @@ -1766,11 +1733,7 @@ H5FD_s3comms_aws_canonical_request( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_bytes_to_hex( - char *dest, - const unsigned char *msg, - size_t msg_len, - hbool_t lowercase) +H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, hbool_t lowercase) { size_t i = 0; herr_t ret_value = SUCCEED; @@ -1781,15 +1744,15 @@ H5FD_s3comms_bytes_to_hex( HDfprintf(stdout, "called H5FD_s3comms_bytes_to_hex.\n"); #endif - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hex destination cannot be null.") - if(msg == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bytes sequence cannot be null.") + if (msg == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bytes sequence cannot be null.") for (i = 0; i < msg_len; i++) { int chars_written = HDsnprintf(&(dest[i * 2]), 3, /* 'X', 'X', '\n' */ - (lowercase == TRUE) ? "%02x" : "%02X", msg[i]); - if(chars_written != 2) + (lowercase == TRUE) ? "%02x" : "%02X", msg[i]); + if (chars_written != 2) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem while writing hex chars for %c", msg[i]); } @@ -1797,7 +1760,6 @@ H5FD_s3comms_bytes_to_hex( FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_bytes_to_hex() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_free_purl() @@ -1826,17 +1788,17 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) HDprintf("called H5FD_s3comms_free_purl.\n"); #endif - if(purl != NULL) { - HDassert( purl->magic == S3COMMS_PARSED_URL_MAGIC ); - if(purl->scheme != NULL) + if (purl != NULL) { + HDassert(purl->magic == S3COMMS_PARSED_URL_MAGIC); + if (purl->scheme != NULL) H5MM_xfree(purl->scheme); - if(purl->host != NULL) + if (purl->host != NULL) H5MM_xfree(purl->host); - if(purl->port != NULL) + if (purl->port != NULL) H5MM_xfree(purl->port); - if(purl->path != NULL) + if (purl->path != NULL) H5MM_xfree(purl->path); - if(purl->query != NULL) + if (purl->query != NULL) H5MM_xfree(purl->query); purl->magic += 1ul; H5MM_xfree(purl); @@ -1845,7 +1807,6 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_s3comms_free_purl() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_HMAC_SHA256() @@ -1877,12 +1838,8 @@ H5FD_s3comms_free_purl(parsed_url_t *purl) *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_HMAC_SHA256( - const unsigned char *key, - size_t key_len, - const char *msg, - size_t msg_len, - char *dest) +H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *msg, size_t msg_len, + char *dest) { unsigned char md[SHA256_DIGEST_LENGTH]; unsigned int md_len = SHA256_DIGEST_LENGTH; @@ -1894,20 +1851,18 @@ H5FD_s3comms_HMAC_SHA256( HDfprintf(stdout, "called H5FD_s3comms_HMAC_SHA256.\n"); #endif - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null."); - HMAC(EVP_sha256(), key, (int)key_len, (const unsigned char *)msg, - msg_len, md, &md_len); + HMAC(EVP_sha256(), key, (int)key_len, (const unsigned char *)msg, msg_len, md, &md_len); - if(H5FD_s3comms_bytes_to_hex(dest, (const unsigned char *)md, (size_t)md_len, true) == FAIL) + if (H5FD_s3comms_bytes_to_hex(dest, (const unsigned char *)md, (size_t)md_len, true) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not convert to hex string."); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_HMAC_SHA256 */ - /*----------------------------------------------------------------------------- * * Function: H5FD__s3comms_load_aws_creds_from_file() @@ -1958,12 +1913,8 @@ H5FD_s3comms_HMAC_SHA256( *----------------------------------------------------------------------------- */ static herr_t -H5FD__s3comms_load_aws_creds_from_file( - FILE *file, - const char *profile_name, - char *key_id, - char *access_key, - char *aws_region) +H5FD__s3comms_load_aws_creds_from_file(FILE *file, const char *profile_name, char *key_id, char *access_key, + char *aws_region) { char profile_line[32]; char buffer[128]; @@ -1972,17 +1923,17 @@ H5FD__s3comms_load_aws_creds_from_file( "aws_access_key_id", "aws_secret_access_key", }; - char * const setting_pointers[] = { + char *const setting_pointers[] = { aws_region, key_id, access_key, }; - unsigned setting_count = 3; - herr_t ret_value = SUCCEED; - unsigned buffer_i = 0; - unsigned setting_i = 0; - int found_setting = 0; - char *line_buffer = &(buffer[0]); + unsigned setting_count = 3; + herr_t ret_value = SUCCEED; + unsigned buffer_i = 0; + unsigned setting_i = 0; + int found_setting = 0; + char * line_buffer = &(buffer[0]); FUNC_ENTER_STATIC @@ -1991,56 +1942,56 @@ H5FD__s3comms_load_aws_creds_from_file( #endif /* format target line for start of profile */ - if(32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) + if (32 < HDsnprintf(profile_line, 32, "[%s]", profile_name)) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format profile label") /* look for start of profile */ do { /* clear buffer */ - for(buffer_i=0; buffer_i < 128; buffer_i++) + for (buffer_i = 0; buffer_i < 128; buffer_i++) buffer[buffer_i] = 0; - line_buffer = fgets(line_buffer, 128, file); - if(line_buffer == NULL) /* reached end of file */ + line_buffer = HDfgets(line_buffer, 128, file); + if (line_buffer == NULL) /* reached end of file */ goto done; } while (HDstrncmp(line_buffer, profile_line, HDstrlen(profile_line))); /* extract credentials from lines */ do { /* clear buffer */ - for(buffer_i=0; buffer_i < 128; buffer_i++) - buffer[buffer_i] = 0; + for (buffer_i = 0; buffer_i < 128; buffer_i++) + buffer[buffer_i] = 0; /* collect a line from file */ - line_buffer = fgets(line_buffer, 128, file); - if(line_buffer == NULL) + line_buffer = HDfgets(line_buffer, 128, file); + if (line_buffer == NULL) goto done; /* end of file */ /* loop over names to see if line looks like assignment */ - for(setting_i = 0; setting_i < setting_count; setting_i++) { + for (setting_i = 0; setting_i < setting_count; setting_i++) { size_t setting_name_len = 0; const char *setting_name = NULL; char line_prefix[128]; - setting_name = setting_names[setting_i]; + setting_name = setting_names[setting_i]; setting_name_len = HDstrlen(setting_name); - if(HDsnprintf(line_prefix, 128, "%s=", setting_name) < 0) + if (HDsnprintf(line_prefix, 128, "%s=", setting_name) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format line prefix") /* found a matching name? */ - if(!HDstrncmp(line_buffer, line_prefix, setting_name_len + 1)) { + if (!HDstrncmp(line_buffer, line_prefix, setting_name_len + 1)) { found_setting = 1; /* skip NULL destination buffer */ - if(setting_pointers[setting_i] == NULL) - break; + if (setting_pointers[setting_i] == NULL) + break; /* advance to end of name in string */ do { line_buffer++; } while (*line_buffer != 0 && *line_buffer != '='); - if(*line_buffer == 0 || *(line_buffer+1) == 0) + if (*line_buffer == 0 || *(line_buffer + 1) == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incomplete assignment in file") line_buffer++; /* was pointing at '='; advance */ @@ -2049,20 +2000,19 @@ H5FD__s3comms_load_aws_creds_from_file( /* "trim" tailing whitespace by replacing with null terminator*/ buffer_i = 0; - while(!HDisspace(setting_pointers[setting_i][buffer_i])) + while (!HDisspace(setting_pointers[setting_i][buffer_i])) buffer_i++; setting_pointers[setting_i][buffer_i] = '\0'; break; /* have read setting; don't compare with others */ - } /* end if possible name match */ - } /* end for each setting name */ + } /* end if possible name match */ + } /* end for each setting name */ } while (found_setting); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__s3comms_load_aws_creds_from_file() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_load_aws_profile() @@ -2096,16 +2046,14 @@ H5FD__s3comms_load_aws_creds_from_file( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_load_aws_profile(const char *profile_name, - char *key_id_out, - char *secret_access_key_out, - char *aws_region_out) +H5FD_s3comms_load_aws_profile(const char *profile_name, char *key_id_out, char *secret_access_key_out, + char *aws_region_out) { herr_t ret_value = SUCCEED; - FILE *credfile = NULL; - char awspath[117]; - char filepath[128]; - int ret = 0; + FILE * credfile = NULL; + char awspath[117]; + char filepath[128]; + int ret = 0; FUNC_ENTER_NOAPI_NOINIT @@ -2114,54 +2062,53 @@ H5FD_s3comms_load_aws_profile(const char *profile_name, #endif #ifdef H5_HAVE_WIN32_API - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("USERPROFILE")) ; + ret = HDsnprintf(awspath, 117, "%s/.aws/", HDgetenv("USERPROFILE")); #else - ret = HDsnprintf(awspath, 117, "%s/.aws/", getenv("HOME")) ; + ret = HDsnprintf(awspath, 117, "%s/.aws/", HDgetenv("HOME")); #endif - if(ret < 0 || (size_t)ret >= 117) + if (ret < 0 || (size_t)ret >= 117) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format home-aws path") ret = HDsnprintf(filepath, 128, "%s%s", awspath, "credentials"); - if(ret < 0 || (size_t)ret >= 128) + if (ret < 0 || (size_t)ret >= 128) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format credentials path") credfile = HDfopen(filepath, "r"); - if(credfile != NULL) { - if(H5FD__s3comms_load_aws_creds_from_file(credfile, profile_name, key_id_out, - secret_access_key_out, aws_region_out) == FAIL) + if (credfile != NULL) { + if (H5FD__s3comms_load_aws_creds_from_file(credfile, profile_name, key_id_out, secret_access_key_out, + aws_region_out) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws credentials") - if(HDfclose(credfile) == EOF) + if (HDfclose(credfile) == EOF) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close credentials file") credfile = NULL; } /* end if credential file opened */ ret = HDsnprintf(filepath, 128, "%s%s", awspath, "config"); - if(ret < 0 || (size_t)ret >= 128) + if (ret < 0 || (size_t)ret >= 128) HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, FAIL, "unable to format config path") credfile = HDfopen(filepath, "r"); - if(credfile != NULL) { - if(H5FD__s3comms_load_aws_creds_from_file( credfile, profile_name, - (*key_id_out == 0) ? key_id_out : NULL, + if (credfile != NULL) { + if (H5FD__s3comms_load_aws_creds_from_file( + credfile, profile_name, (*key_id_out == 0) ? key_id_out : NULL, (*secret_access_key_out == 0) ? secret_access_key_out : NULL, (*aws_region_out == 0) ? aws_region_out : NULL) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to load from aws config") - if(HDfclose(credfile) == EOF) + if (HDfclose(credfile) == EOF) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close config file") credfile = NULL; } /* end if credential file opened */ /* fail if not all three settings were loaded */ - if(*key_id_out == 0 || *secret_access_key_out == 0 || *aws_region_out == 0) + if (*key_id_out == 0 || *secret_access_key_out == 0 || *aws_region_out == 0) ret_value = FAIL; done: - if(credfile != NULL) - if(HDfclose(credfile) == EOF) + if (credfile != NULL) + if (HDfclose(credfile) == EOF) HDONE_ERROR(H5E_ARGS, H5E_ARGS, FAIL, "problem error-closing aws configuration file") FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_load_aws_profile() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_nlowercase() @@ -2189,10 +2136,7 @@ H5FD_s3comms_load_aws_profile(const char *profile_name, *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_nlowercase( - char *dest, - const char *s, - size_t len) +H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len) { herr_t ret_value = SUCCEED; @@ -2202,11 +2146,11 @@ H5FD_s3comms_nlowercase( HDfprintf(stdout, "called H5FD_s3comms_nlowercase.\n"); #endif - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null."); - if(len > 0) { - HDmemcpy(dest, s, len); + if (len > 0) { + H5MM_memcpy(dest, s, len); do { len--; dest[len] = (char)HDtolower((int)dest[len]); @@ -2217,7 +2161,6 @@ H5FD_s3comms_nlowercase( FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_nlowercase() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_parse_url() @@ -2250,17 +2193,15 @@ H5FD_s3comms_nlowercase( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_parse_url( - const char *str, - parsed_url_t **_purl) +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 */ - long int len = 0; /* substring length */ - long int urllen = 0; /* length of passed-in url string */ - unsigned int i = 0; - herr_t ret_value = FAIL; + 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 */ + long int len = 0; /* substring length */ + long int urllen = 0; /* length of passed-in url string */ + unsigned int i = 0; + herr_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT; @@ -2268,13 +2209,13 @@ H5FD_s3comms_parse_url( HDprintf("called H5FD_s3comms_parse_url.\n"); #endif - if(str == NULL || *str == '\0') + if (str == NULL || *str == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid url string"); urllen = (long int)HDstrlen(str); purl = (parsed_url_t *)H5MM_malloc(sizeof(parsed_url_t)); - if(purl == NULL) + if (purl == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for parsed_url_t"); purl->magic = S3COMMS_PARSED_URL_MAGIC; purl->scheme = NULL; @@ -2288,26 +2229,25 @@ H5FD_s3comms_parse_url( ***************/ tmpstr = HDstrchr(curstr, ':'); - if(tmpstr == NULL) + if (tmpstr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction: probably not URL"); len = tmpstr - curstr; - HDassert( (0 <= len) && (len < urllen) ); + HDassert((0 <= len) && (len < urllen)); /* check for restrictions */ - for(i = 0; i < len; i++) { + for (i = 0; i < len; i++) { /* scheme = [a-zA-Z+-.]+ (terminated by ":") */ - if(!HDisalpha(curstr[i]) && '+' != curstr[i] && '-' != curstr[i] && - '.' != curstr[i]) + if (!HDisalpha(curstr[i]) && '+' != curstr[i] && '-' != curstr[i] && '.' != curstr[i]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid SCHEME construction"); } /* copy lowercased scheme to structure */ purl->scheme = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if(purl->scheme == NULL) + if (purl->scheme == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for SCHEME"); HDstrncpy(purl->scheme, curstr, (size_t)len); purl->scheme[len] = '\0'; - for(i = 0; i < len; i++ ) + for (i = 0; i < len; i++) purl->scheme[i] = (char)HDtolower(purl->scheme[i]); /* Skip "://" */ @@ -2318,32 +2258,32 @@ H5FD_s3comms_parse_url( * READ HOST * *************/ - if(*curstr == '[') { + if (*curstr == '[') { /* IPv6 */ - while(']' != *tmpstr) { + while (']' != *tmpstr) { /* end of string reached! */ - if(tmpstr == 0) + if (tmpstr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reached end of URL: incomplete IPv6 HOST"); tmpstr++; } tmpstr++; } /* end if (IPv6) */ else { - while(0 != *tmpstr) { - if(':' == *tmpstr || '/' == *tmpstr || '?' == *tmpstr) + while (0 != *tmpstr) { + if (':' == *tmpstr || '/' == *tmpstr || '?' == *tmpstr) break; tmpstr++; } } /* end else (IPv4) */ len = tmpstr - curstr; - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "HOST substring cannot be empty") - else if(len > urllen) + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of HOST substring"); /* copy host */ purl->host = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if(purl->host == NULL) + if (purl->host == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for HOST"); HDstrncpy(purl->host, curstr, (size_t)len); purl->host[len] = 0; @@ -2352,23 +2292,23 @@ H5FD_s3comms_parse_url( * READ PORT * *************/ - if(':' == *tmpstr) { + if (':' == *tmpstr) { tmpstr += 1; /* advance past ':' */ curstr = tmpstr; - while((0 != *tmpstr) && ('/' != *tmpstr) && ('?' != *tmpstr)) + while ((0 != *tmpstr) && ('/' != *tmpstr) && ('?' != *tmpstr)) tmpstr++; len = tmpstr - curstr; - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT element cannot be empty") - else if(len > urllen) + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PORT substring"); - for(i = 0; i < len; i ++) - if(!HDisdigit(curstr[i])) + for (i = 0; i < len; i++) + if (!HDisdigit(curstr[i])) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "PORT is not a decimal string"); /* copy port */ purl->port = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if(purl->port == NULL) + if (purl->port == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PORT"); HDstrncpy(purl->port, curstr, (size_t)len); purl->port[len] = 0; @@ -2378,20 +2318,20 @@ H5FD_s3comms_parse_url( * READ PATH * *************/ - if('/' == *tmpstr) { + if ('/' == *tmpstr) { /* advance past '/' */ tmpstr += 1; curstr = tmpstr; /* seek end of PATH */ - while((0 != *tmpstr) && ('?' != *tmpstr)) + while ((0 != *tmpstr) && ('?' != *tmpstr)) tmpstr++; len = tmpstr - curstr; - if(len > urllen) + if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of PATH substring"); - if(len > 0) { + if (len > 0) { purl->path = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if(purl->path == NULL) + if (purl->path == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for PATH"); HDstrncpy(purl->path, curstr, (size_t)len); purl->path[len] = 0; @@ -2402,34 +2342,33 @@ H5FD_s3comms_parse_url( * READ QUERY * **************/ - if('?' == *tmpstr) { + if ('?' == *tmpstr) { tmpstr += 1; curstr = tmpstr; - while(0 != *tmpstr) + while (0 != *tmpstr) tmpstr++; len = tmpstr - curstr; - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "QUERY cannot be empty") - else if(len > urllen) + else if (len > urllen) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem with length of QUERY substring"); purl->query = (char *)H5MM_malloc(sizeof(char) * (size_t)(len + 1)); - if(purl->query == NULL) + if (purl->query == NULL) HGOTO_ERROR(H5E_ARGS, H5E_CANTALLOC, FAIL, "can't allocate space for QUERY"); HDstrncpy(purl->query, curstr, (size_t)len); purl->query[len] = 0; } /* end if QUERY exists */ - *_purl = purl; - ret_value = SUCCEED; + *_purl = purl; + ret_value = SUCCEED; done: - if(ret_value == FAIL) + if (ret_value == FAIL) H5FD_s3comms_free_purl(purl); FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_parse_url() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_percent_encode_char() @@ -2470,17 +2409,14 @@ H5FD_s3comms_parse_url( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_percent_encode_char( - char *repr, - const unsigned char c, - size_t *repr_len) +H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr_len) { - unsigned int i = 0; - int chars_written = 0; - herr_t ret_value = SUCCEED; + unsigned int i = 0; + int chars_written = 0; + herr_t ret_value = SUCCEED; #if S3COMMS_DEBUG - unsigned char s[2] = {c, 0}; - unsigned char hex[3] = {0, 0, 0}; + unsigned char s[2] = {c, 0}; + unsigned char hex[3] = {0, 0, 0}; #endif FUNC_ENTER_NOAPI_NOINIT @@ -2489,8 +2425,8 @@ H5FD_s3comms_percent_encode_char( HDfprintf(stdout, "called H5FD_s3comms_percent_encode_char.\n"); #endif - if(repr == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.") + if (repr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination `repr`.") #if S3COMMS_DEBUG H5FD_s3comms_bytes_to_hex((char *)hex, s, 1, FALSE); @@ -2498,31 +2434,31 @@ H5FD_s3comms_percent_encode_char( HDfprintf(stdout, " CHAR-HEX: \"%s\"\n", hex); #endif - if(c <= (unsigned char)0x7f) { + if (c <= (unsigned char)0x7f) { /* character represented in a single "byte" * and single percent-code */ #if S3COMMS_DEBUG HDfprintf(stdout, " SINGLE-BYTE\n"); #endif - *repr_len = 3; + *repr_len = 3; chars_written = HDsnprintf(repr, 4, "%%%02X", c); - if(chars_written < 0) + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); } /* end if single-byte unicode char */ else { /* multi-byte, multi-percent representation */ - unsigned int acc = 0; /* byte accumulator */ - unsigned int k = 0; /* uint character representation */ - unsigned int stack_size = 0; - unsigned char stack[4] = {0, 0, 0, 0}; + unsigned int acc = 0; /* byte accumulator */ + unsigned int k = 0; /* uint character representation */ + unsigned int stack_size = 0; + unsigned char stack[4] = {0, 0, 0, 0}; #if S3COMMS_DEBUG HDfprintf(stdout, " MULTI-BYTE\n"); #endif stack_size = 0; - k = (unsigned int)c; - *repr_len = 0; + k = (unsigned int)c; + *repr_len = 0; do { /* push number onto stack in six-bit slices */ @@ -2530,7 +2466,7 @@ H5FD_s3comms_percent_encode_char( acc >>= 6; /* cull least */ acc <<= 6; /* six bits */ stack[stack_size++] = (unsigned char)(k - acc); - k = acc >> 6; + k = acc >> 6; } while (k > 0); /* `stack` now has two to four six-bit 'numbers' to be put into @@ -2540,11 +2476,7 @@ H5FD_s3comms_percent_encode_char( #if S3COMMS_DEBUG HDfprintf(stdout, " STACK:\n {\n"); for (i = 0; i < stack_size; i++) { - H5FD_s3comms_bytes_to_hex( - (char *)hex, - (&stack[i]), - 1, - FALSE); + H5FD_s3comms_bytes_to_hex((char *)hex, (&stack[i]), 1, FALSE); hex[2] = 0; HDfprintf(stdout, " %s,\n", hex); } @@ -2561,8 +2493,8 @@ H5FD_s3comms_percent_encode_char( acc += (stack_size > 2) ? 0x20 : 0; /* 0x00100000 */ acc += (stack_size > 3) ? 0x10 : 0; /* 0x00010000 */ stack_size--; - chars_written = HDsnprintf( repr, 4, "%%%02X", (unsigned char)(acc + stack[stack_size])); - if(chars_written < 0) + chars_written = HDsnprintf(repr, 4, "%%%02X", (unsigned char)(acc + stack[stack_size])); + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); *repr_len += 3; @@ -2571,14 +2503,14 @@ H5FD_s3comms_percent_encode_char( ************************/ /* 10xxxxxx */ - for(i = 0; i < stack_size; i++) { - chars_written = HDsnprintf( &repr[i*3 + 3], 4, - "%%%02X", (unsigned char)(0x80 + stack[stack_size - 1 - i])); - if(chars_written < 0) + for (i = 0; i < stack_size; i++) { + chars_written = + HDsnprintf(&repr[i * 3 + 3], 4, "%%%02X", (unsigned char)(0x80 + stack[stack_size - 1 - i])); + if (chars_written < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cannot write char %c", c); *repr_len += 3; } /* end for each continuation byte */ - } /* end else (multi-byte) */ + } /* end else (multi-byte) */ *(repr + *repr_len) = '\0'; @@ -2586,7 +2518,6 @@ H5FD_s3comms_percent_encode_char( FUNC_LEAVE_NOAPI(ret_value); } /* H5FD_s3comms_percent_encode_char */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_signing_key() @@ -2626,19 +2557,15 @@ H5FD_s3comms_percent_encode_char( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_signing_key( - unsigned char *md, - const char *secret, - const char *region, - const char *iso8601now) +H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, const char *iso8601now) { - char *AWS4_secret = NULL; - size_t AWS4_secret_len = 0; - unsigned char datekey[SHA256_DIGEST_LENGTH]; - unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; - unsigned char dateregionservicekey[SHA256_DIGEST_LENGTH]; - int ret = 0; /* return value of HDsnprintf */ - herr_t ret_value = SUCCEED; + char * AWS4_secret = NULL; + size_t AWS4_secret_len = 0; + unsigned char datekey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; + unsigned char dateregionservicekey[SHA256_DIGEST_LENGTH]; + int ret = 0; /* return value of HDsnprintf */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -2646,56 +2573,37 @@ H5FD_s3comms_signing_key( HDfprintf(stdout, "called H5FD_s3comms_signing_key.\n"); #endif - if(md == NULL) + if (md == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Destination `md` cannot be NULL.") - if(secret == NULL) + if (secret == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`secret` cannot be NULL.") - if(region == NULL) + if (region == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`region` cannot be NULL.") - if(iso8601now == NULL) + if (iso8601now == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`iso8601now` cannot be NULL.") AWS4_secret_len = 4 + HDstrlen(secret) + 1; - AWS4_secret = (char*)H5MM_malloc(sizeof(char *) * AWS4_secret_len); - if(AWS4_secret == NULL) + AWS4_secret = (char *)H5MM_malloc(sizeof(char *) * AWS4_secret_len); + if (AWS4_secret == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Could not allocate space.") /* prepend "AWS4" to start of the secret key */ - ret = HDsnprintf(AWS4_secret, AWS4_secret_len,"%s%s", "AWS4", secret); - if((size_t)ret != (AWS4_secret_len - 1)) + ret = HDsnprintf(AWS4_secret, AWS4_secret_len, "%s%s", "AWS4", secret); + if ((size_t)ret != (AWS4_secret_len - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem writing AWS4+secret `%s`", secret); /* hash_func, key, len(key), msg, len(msg), digest_dest, digest_len_dest * we know digest length, so ignore via NULL */ - HMAC(EVP_sha256(), - (const unsigned char *)AWS4_secret, - (int)HDstrlen(AWS4_secret), - (const unsigned char*)iso8601now, - 8, /* 8 --> length of 8 --> "yyyyMMDD" */ - datekey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)datekey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)region, - HDstrlen(region), - dateregionkey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)dateregionkey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)"s3", - 2, - dateregionservicekey, - NULL); - HMAC(EVP_sha256(), - (const unsigned char *)dateregionservicekey, - SHA256_DIGEST_LENGTH, - (const unsigned char *)"aws4_request", - 12, - md, - NULL); + HMAC(EVP_sha256(), (const unsigned char *)AWS4_secret, (int)HDstrlen(AWS4_secret), + (const unsigned char *)iso8601now, 8, /* 8 --> length of 8 --> "yyyyMMDD" */ + datekey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)datekey, SHA256_DIGEST_LENGTH, (const unsigned char *)region, + HDstrlen(region), dateregionkey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)dateregionkey, SHA256_DIGEST_LENGTH, + (const unsigned char *)"s3", 2, dateregionservicekey, NULL); + HMAC(EVP_sha256(), (const unsigned char *)dateregionservicekey, SHA256_DIGEST_LENGTH, + (const unsigned char *)"aws4_request", 12, md, NULL); done: H5MM_xfree(AWS4_secret); @@ -2703,7 +2611,6 @@ H5FD_s3comms_signing_key( FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_s3comms_signing_key() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_tostringtosign() @@ -2741,14 +2648,10 @@ H5FD_s3comms_signing_key( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_tostringtosign( - char *dest, - const char *req, - const char *now, - const char *region) +H5FD_s3comms_tostringtosign(char *dest, const char *req, const char *now, const char *region) { unsigned char checksum[SHA256_DIGEST_LENGTH * 2 + 1]; - size_t d = 0; + size_t d = 0; char day[9]; char hexsum[SHA256_DIGEST_LENGTH * 2 + 1]; size_t i = 0; @@ -2762,45 +2665,45 @@ H5FD_s3comms_tostringtosign( HDfprintf(stdout, "called H5FD_s3comms_tostringtosign.\n"); #endif - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer cannot be null.") - if(req == NULL) + if (req == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "canonical request cannot be null.") - if(now == NULL) + if (now == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Timestring cannot be NULL.") - if(region == NULL) + if (region == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Region cannot be NULL.") - for(i = 0; i < 128; i++) + for (i = 0; i < 128; i++) tmp[i] = '\0'; - for(i = 0; i < SHA256_DIGEST_LENGTH * 2 + 1; i++) { + for (i = 0; i < SHA256_DIGEST_LENGTH * 2 + 1; i++) { checksum[i] = '\0'; - hexsum[i] = '\0'; + hexsum[i] = '\0'; } HDstrncpy(day, now, 8); day[8] = '\0'; - ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); - if(ret <= 0 || ret >= 127) + ret = HDsnprintf(tmp, 127, "%s/%s/s3/aws4_request", day, region); + if (ret <= 0 || ret >= 127) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "problem adding day and region to string") - HDmemcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); + H5MM_memcpy((dest + d), "AWS4-HMAC-SHA256\n", 17); d = 17; - HDmemcpy((dest+d), now, HDstrlen(now)); + H5MM_memcpy((dest + d), now, HDstrlen(now)); d += HDstrlen(now); dest[d++] = '\n'; - HDmemcpy((dest + d), tmp, HDstrlen(tmp)); + H5MM_memcpy((dest + d), tmp, HDstrlen(tmp)); d += HDstrlen(tmp); dest[d++] = '\n'; SHA256((const unsigned char *)req, HDstrlen(req), checksum); - if(H5FD_s3comms_bytes_to_hex(hexsum, (const unsigned char *)checksum, - SHA256_DIGEST_LENGTH, true) == FAIL) + if (H5FD_s3comms_bytes_to_hex(hexsum, (const unsigned char *)checksum, SHA256_DIGEST_LENGTH, true) == + FAIL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not create hex string"); - for(i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) + for (i = 0; i < SHA256_DIGEST_LENGTH * 2; i++) dest[d++] = hexsum[i]; dest[d] = '\0'; @@ -2809,7 +2712,6 @@ H5FD_s3comms_tostringtosign( FUNC_LEAVE_NOAPI(ret_value) } /* end H5ros3_tostringtosign() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_trim() @@ -2840,10 +2742,7 @@ H5FD_s3comms_tostringtosign( *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_trim(char *dest, - char *s, - size_t s_len, - size_t *n_written) +H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written) { herr_t ret_value = SUCCEED; @@ -2853,32 +2752,32 @@ H5FD_s3comms_trim(char *dest, HDfprintf(stdout, "called H5FD_s3comms_trim.\n"); #endif - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be null.") - if(s == NULL) + if (s == NULL) s_len = 0; - if(s_len > 0) { + if (s_len > 0) { /* Find first non-whitespace character from start; * reduce total length per character. */ - while((s_len > 0) && HDisspace((unsigned char)s[0]) && s_len > 0) { - s++; - s_len--; + while ((s_len > 0) && HDisspace((unsigned char)s[0]) && s_len > 0) { + s++; + s_len--; } /* Find first non-whitespace character from tail; * reduce length per-character. * If length is 0 already, there is no non-whitespace character. */ - if(s_len > 0) { + if (s_len > 0) { do { s_len--; - } while(HDisspace((unsigned char)s[s_len])); + } while (HDisspace((unsigned char)s[s_len])); s_len++; /* write output into dest */ - HDmemcpy(dest, s, s_len); + H5MM_memcpy(dest, s, s_len); } } @@ -2888,7 +2787,6 @@ H5FD_s3comms_trim(char *dest, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_s3comms_trim() */ - /*---------------------------------------------------------------------------- * * Function: H5FD_s3comms_uriencode() @@ -2928,15 +2826,10 @@ H5FD_s3comms_trim(char *dest, *---------------------------------------------------------------------------- */ herr_t -H5FD_s3comms_uriencode( - char *dest, - const char *s, - size_t s_len, - hbool_t encode_slash, - size_t *n_written) +H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_slash, size_t *n_written) { - char c = 0; - size_t dest_off = 0; + char c = 0; + size_t dest_off = 0; char hex_buffer[13]; size_t hex_off = 0; size_t hex_len = 0; @@ -2949,35 +2842,37 @@ H5FD_s3comms_uriencode( HDfprintf(stdout, "H5FD_s3comms_uriencode called.\n"); #endif - if(s == NULL) + if (s == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source string cannot be NULL"); - if(dest == NULL) + if (dest == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination cannot be NULL"); /* Write characters to destination, converting to percent-encoded * "hex-utf-8" strings if necessary. * e.g., '$' -> "%24" */ - for(s_off = 0; s_off < s_len; s_off++) { + for (s_off = 0; s_off < s_len; s_off++) { c = s[s_off]; - if(HDisalnum(c) || c == '.' || c == '-' || c == '_' || - c == '~' || (c == '/' && encode_slash == FALSE)) + if (HDisalnum(c) || c == '.' || c == '-' || c == '_' || c == '~' || + (c == '/' && encode_slash == FALSE)) dest[dest_off++] = c; else { hex_off = 0; - if(H5FD_s3comms_percent_encode_char(hex_buffer, (const unsigned char)c, - &hex_len) == FAIL) { + if (H5FD_s3comms_percent_encode_char(hex_buffer, (const unsigned char)c, &hex_len) == FAIL) { hex_buffer[0] = c; hex_buffer[1] = 0; - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to percent-encode character \'%s\' " "at %d in \"%s\"", hex_buffer, (int)s_off, s); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to percent-encode character \'%s\' " + "at %d in \"%s\"", + hex_buffer, (int)s_off, s); } - for(hex_off = 0; hex_off < hex_len; hex_off++) + for (hex_off = 0; hex_off < hex_len; hex_off++) dest[dest_off++] = hex_buffer[hex_off]; } /* end else (not a regular character) */ - } /* end for each character */ + } /* end for each character */ - if(dest_off < s_len) + if (dest_off < s_len) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer overflow"); *n_written = dest_off; @@ -2987,4 +2882,3 @@ H5FD_s3comms_uriencode( } /* H5FD_s3comms_uriencode */ #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index 90c66505df4..da6a62d7bb7 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -52,7 +52,7 @@ * *****************************************************************************/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_ROS3_VFD @@ -69,8 +69,7 @@ /* hexadecimal string of pre-computed sha256 checksum of the empty string * hex(sha256sum("")) */ -#define EMPTY_SHA256 \ -"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +#define EMPTY_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" /* string length (plus null terminator) * example ISO8601-format string: "20170713T145903Z" (YYYYmmdd'T'HHMMSS'_') @@ -98,8 +97,7 @@ * *--------------------------------------------------------------------------- */ -#define ISO8601NOW(dest, now_gm) \ -strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) +#define ISO8601NOW(dest, now_gm) strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) /*--------------------------------------------------------------------------- * @@ -117,9 +115,7 @@ strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) * *--------------------------------------------------------------------------- */ -#define RFC7231NOW(dest, now_gm) \ -strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) - +#define RFC7231NOW(dest, now_gm) strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) /* Reasonable maximum length of a credential string. * Provided for error-checking S3COMMS_FORMAT_CREDENTIAL (below). @@ -131,7 +127,6 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) */ #define S3COMMS_MAX_CREDENTIAL_SIZE 155 - /*--------------------------------------------------------------------------- * * Macro: H5FD_S3COMMS_FORMAT_CREDENTIAL() @@ -162,16 +157,14 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) * *--------------------------------------------------------------------------- */ -#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ -HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, \ - "%s/%s/%s/%s/aws4_request", \ - (access), (iso8601_date), (region), (service)) +#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ + HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, "%s/%s/%s/%s/aws4_request", (access), (iso8601_date), \ + (region), (service)) /********************* * PUBLIC STRUCTURES * *********************/ - /*---------------------------------------------------------------------------- * * Structure: hrb_node_t @@ -256,15 +249,14 @@ HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, */ 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 - /*---------------------------------------------------------------------------- * * Structure: hrb_t @@ -332,17 +324,16 @@ typedef struct hrb_node_t { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *body; - size_t body_len; - hrb_node_t *first_header; - char *resource; - char *verb; - char *version; + unsigned long magic; + char * body; + size_t body_len; + hrb_node_t * first_header; + char * resource; + char * verb; + char * version; } hrb_t; #define S3COMMS_HRB_MAGIC 0x6DCC84UL - /*---------------------------------------------------------------------------- * * Structure: parsed_url_t @@ -396,16 +387,15 @@ typedef struct { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *scheme; /* required */ - char *host; /* required */ - char *port; - char *path; - char *query; + unsigned long magic; + char * scheme; /* required */ + char * host; /* required */ + char * port; + char * path; + char * query; } parsed_url_t; #define S3COMMS_PARSED_URL_MAGIC 0x21D0DFUL - /*---------------------------------------------------------------------------- * * Structure: s3r_t @@ -486,12 +476,12 @@ typedef struct { */ 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; @@ -505,9 +495,7 @@ extern "C" { * DECLARATION OF HTTP FIELD LIST ROUTINES * *******************************************/ -H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, - const char *name, - const char *value); +H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value); /*********************************************** * DECLARATION OF HTTP REQUEST BUFFER ROUTINES * @@ -515,9 +503,7 @@ H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, H5_DLL herr_t H5FD_s3comms_hrb_destroy(hrb_t **buf); -H5_DLL hrb_t * H5FD_s3comms_hrb_init_request(const char *verb, - const char *resource, - const char *host); +H5_DLL hrb_t *H5FD_s3comms_hrb_init_request(const char *verb, const char *resource, const char *host); /************************************* * DECLARATION OF S3REQUEST ROUTINES * @@ -527,78 +513,50 @@ H5_DLL herr_t H5FD_s3comms_s3r_close(s3r_t *handle); H5_DLL size_t H5FD_s3comms_s3r_get_filesize(s3r_t *handle); -H5_DLL s3r_t * H5FD_s3comms_s3r_open(const char url[], - const char region[], - const char id[], - const unsigned char signing_key[]); +H5_DLL s3r_t *H5FD_s3comms_s3r_open(const char url[], const char region[], const char id[], + const unsigned char signing_key[]); -H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, - haddr_t offset, - size_t len, - void *dest); +H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest); /********************************* * DECLARATION OF OTHER ROUTINES * *********************************/ -H5_DLL struct tm * gmnow(void); +H5_DLL struct tm *gmnow(void); -H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, - int cr_size, - char *signed_headers_dest, - int sh_size, - hrb_t *http_request); +H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int cr_size, + char *signed_headers_dest, int sh_size, hrb_t *http_request); -H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, - const unsigned char *msg, - size_t msg_len, - hbool_t lowercase); +H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, + hbool_t lowercase); H5_DLL herr_t H5FD_s3comms_free_purl(parsed_url_t *purl); -H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, - size_t key_len, - const char *msg, - size_t msg_len, - char *dest); +H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *msg, + size_t msg_len, char *dest); -H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, - char *key_id_out, - char *secret_access_key_out, - char *aws_region_out); +H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, char *key_id_out, char *secret_access_key_out, + char *aws_region_out); -H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, - const char *s, - size_t len); +H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len); -H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, - parsed_url_t **purl); +H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, parsed_url_t **purl); -H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, - const unsigned char c, - size_t *repr_len); +H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr_len); -H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, - const char *secret, - const char *region, - const char *iso8601now); +H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, + const char *iso8601now); -H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, - const char *req_str, - const char *now, - const char *region); +H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, const char *req_str, const char *now, + const char *region); -H5_DLL herr_t H5FD_s3comms_trim(char *dest, - char *s, - size_t s_len, - size_t *n_written); +H5_DLL herr_t H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written); -H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, - hbool_t encode_slash, size_t *n_written); +H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_slash, + size_t *n_written); #ifdef __cplusplus } #endif #endif /* H5_HAVE_ROS3_VFD */ - diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 147d08f16a3..6fe12822559 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,16 +25,15 @@ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsec2.h" /* Sec2 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsec2.h" /* Sec2 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; @@ -54,14 +53,14 @@ static htri_t ignore_disabled_file_locks_s = FAIL; * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the filesystem file descriptor */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ - haddr_t pos; /* current file I/O position */ - H5FD_file_op_t op; /* last operation */ - hbool_t ignore_disabled_file_locks; - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the filesystem file descriptor */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ + haddr_t pos; /* current file I/O position */ + H5FD_file_op_t op; /* last operation */ + hbool_t ignore_disabled_file_locks; + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -69,8 +68,8 @@ typedef struct H5FD_sec2_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -86,19 +85,19 @@ typedef struct H5FD_sec2_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ /* Information from properties set by 'h5repart' tool * * Whether to eliminate the family driver info and convert this file to * a single file. */ - hbool_t fam_to_single; + hbool_t fam_to_single; } H5FD_sec2_t; /* @@ -116,71 +115,68 @@ typedef struct H5FD_sec2_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF == (A) + (Z) || \ - (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* Prototypes */ -static herr_t H5FD__sec2_term(void); -static H5FD_t *H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); -static herr_t H5FD__sec2_close(H5FD_t *_file); -static int H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD__sec2_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD__sec2_term(void); +static H5FD_t *H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD__sec2_close(H5FD_t *_file); +static int H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__sec2_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD__sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD__sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__sec2_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__sec2_unlock(H5FD_t *_file); +static herr_t H5FD__sec2_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__sec2_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__sec2_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_sec2_g = { - "sec2", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__sec2_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__sec2_open, /* open */ - H5FD__sec2_close, /* close */ - H5FD__sec2_cmp, /* cmp */ - H5FD__sec2_query, /* query */ - NULL, /* get_type_map */ - NULL, /* alloc */ - NULL, /* free */ - H5FD__sec2_get_eoa, /* get_eoa */ - H5FD__sec2_set_eoa, /* set_eoa */ - H5FD__sec2_get_eof, /* get_eof */ - H5FD__sec2_get_handle, /* get_handle */ - H5FD__sec2_read, /* read */ - H5FD__sec2_write, /* write */ - NULL, /* flush */ - H5FD__sec2_truncate, /* truncate */ - H5FD__sec2_lock, /* lock */ - H5FD__sec2_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "sec2", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__sec2_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__sec2_open, /* open */ + H5FD__sec2_close, /* close */ + H5FD__sec2_cmp, /* cmp */ + H5FD__sec2_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD__sec2_get_eoa, /* get_eoa */ + H5FD__sec2_set_eoa, /* set_eoa */ + H5FD__sec2_get_eof, /* get_eof */ + H5FD__sec2_get_handle, /* get_handle */ + H5FD__sec2_read, /* read */ + H5FD__sec2_write, /* write */ + NULL, /* flush */ + H5FD__sec2_truncate, /* truncate */ + H5FD__sec2_lock, /* lock */ + H5FD__sec2_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ H5FL_DEFINE_STATIC(H5FD_sec2_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -193,28 +189,27 @@ H5FL_DEFINE_STATIC(H5FD_sec2_t); static herr_t H5FD__init_package(void) { - char *lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; + char * lock_env_var = NULL; /* Environment variable pointer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - if(H5FD_sec2_init() < 0) + if (H5FD_sec2_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_sec2_init * @@ -232,11 +227,11 @@ H5FD__init_package(void) hid_t H5FD_sec2_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if(H5I_VFL != H5I_get_type(H5FD_SEC2_g)) + if (H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ @@ -246,7 +241,6 @@ H5FD_sec2_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__sec2_term * @@ -270,7 +264,6 @@ H5FD__sec2_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__sec2_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_sec2 * @@ -288,13 +281,13 @@ H5FD__sec2_term(void) herr_t H5Pset_fapl_sec2(hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL); @@ -303,7 +296,6 @@ H5Pset_fapl_sec2(hid_t fapl_id) FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_sec2() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_open * @@ -322,15 +314,15 @@ H5Pset_fapl_sec2(hid_t fapl_id) static H5FD_t * H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_sec2_t *file = NULL; /* sec2 VFD info */ - int fd = -1; /* File descriptor */ - int o_flags; /* Flags for open() call */ + H5FD_sec2_t *file = NULL; /* sec2 VFD info */ + int fd = -1; /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif h5_stat_t sb; - H5P_genplist_t *plist; /* Property list pointer */ - H5FD_t *ret_value = NULL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -338,66 +330,69 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; - if(H5F_ACC_TRUNC & flags) + if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; - if(H5F_ACC_CREAT & flags) + if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; - if(H5F_ACC_EXCL & flags) + if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Open the file */ - if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { + if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + HGOTO_ERROR( + H5E_FILE, H5E_CANTOPENFILE, NULL, + "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", + name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ - if(HDfstat(fd, &sb) < 0) + if (HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") /* Create the new file struct */ - if(NULL == (file = H5FL_CALLOC(H5FD_sec2_t))) + if (NULL == (file = H5FL_CALLOC(H5FD_sec2_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); - if(INVALID_HANDLE_VALUE == file->hFile) + if (INVALID_HANDLE_VALUE == file->hFile) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file handle") - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get Windows file information") - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ /* Get the FAPL */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, NULL, "not a file access property list") /* Check the file locking flags in the fapl */ - if(ignore_disabled_file_locks_s != FAIL) + if (ignore_disabled_file_locks_s != FAIL) /* The environment variable was set, so use that preferentially */ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s; else { /* Use the value in the property list */ - if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) + if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &file->ignore_disabled_file_locks) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get ignore disabled file locks property") } @@ -406,33 +401,32 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->filename[sizeof(file->filename) - 1] = '\0'; /* Check for non-default FAPL */ - if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { + if (H5P_FILE_ACCESS_DEFAULT != fapl_id) { /* This step is for h5repart tool only. If user wants to change file driver from * family to one that uses single files (sec2, etc.) while using h5repart, this * private property should be set so that in the later step, the library can ignore * the family driver information saved in the superblock. */ - if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) - if(H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) + if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) + if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") } /* end if */ /* Set return value */ - ret_value = (H5FD_t*)file; + ret_value = (H5FD_t *)file; done: - if(NULL == ret_value) { - if(fd >= 0) + if (NULL == ret_value) { + if (fd >= 0) HDclose(fd); - if(file) + if (file) file = H5FL_FREE(H5FD_sec2_t, file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_close * @@ -449,8 +443,8 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr static herr_t H5FD__sec2_close(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -458,7 +452,7 @@ H5FD__sec2_close(H5FD_t *_file) HDassert(file); /* Close the underlying file */ - if(HDclose(file->fd) < 0) + if (HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Release the file info */ @@ -468,7 +462,6 @@ H5FD__sec2_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_cmp * @@ -487,42 +480,53 @@ H5FD__sec2_close(H5FD_t *_file) static int H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; - const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; - int ret_value = 0; + const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; + const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) HGOTO_DONE(-1) - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) HGOTO_DONE(1) - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) HGOTO_DONE(-1) - if(f1->nFileIndexHigh > f2->nFileIndexHigh) HGOTO_DONE(1) - - if(f1->nFileIndexLow < f2->nFileIndexLow) HGOTO_DONE(-1) - if(f1->nFileIndexLow > f2->nFileIndexLow) HGOTO_DONE(1) + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + HGOTO_DONE(-1) + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + HGOTO_DONE(1) + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + HGOTO_DONE(-1) + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + HGOTO_DONE(1) + + if (f1->nFileIndexLow < f2->nFileIndexLow) + HGOTO_DONE(-1) + if (f1->nFileIndexLow > f2->nFileIndexLow) + HGOTO_DONE(1) #else /* H5_HAVE_WIN32_API */ #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) HGOTO_DONE(-1) - if(f1->device > f2->device) HGOTO_DONE(1) -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + HGOTO_DONE(-1) + if (f1->device > f2->device) + HGOTO_DONE(1) +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + HGOTO_DONE(-1) + if (HDmemcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) HGOTO_DONE(-1) - if(f1->inode > f2->inode) HGOTO_DONE(1) + if (f1->inode < f2->inode) + HGOTO_DONE(-1) + if (f1->inode > f2->inode) + HGOTO_DONE(1) #endif /* H5_HAVE_WIN32_API */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_query * @@ -539,7 +543,7 @@ H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) static herr_t H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ FUNC_ENTER_STATIC_NOERR @@ -550,25 +554,27 @@ H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) * reflected in H5FDmirror.c * -- JOS 2020-01-13 */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ - *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ + *flags |= + H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ /* Check for flags that are set by h5repart */ - if(file && file->fam_to_single) - *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + if (file && file->fam_to_single) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which + eliminates it) */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__sec2_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_get_eoa * @@ -586,14 +592,13 @@ H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD__sec2_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_set_eoa * @@ -611,7 +616,7 @@ H5FD__sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; FUNC_ENTER_STATIC_NOERR @@ -620,7 +625,6 @@ H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__sec2_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_get_eof * @@ -639,14 +643,13 @@ H5FD__sec2_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) static haddr_t H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(file->eof) } /* end H5FD__sec2_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_get_handle * @@ -662,12 +665,12 @@ H5FD__sec2_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - if(!file_handle) + if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); @@ -676,7 +679,6 @@ H5FD__sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_hand FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_read * @@ -694,12 +696,12 @@ H5FD__sec2_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_hand *------------------------------------------------------------------------- */ static herr_t -H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, size_t size, void *buf /*out*/) +H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf /*out*/) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -707,29 +709,29 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ - if(addr != file->pos || OP_READ != file->op) - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (addr != file->pos || OP_READ != file->op) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") #endif /* H5_HAVE_PREADWRITE */ /* Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to read */ + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -737,23 +739,29 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - if(bytes_read > 0) + if (bytes_read > 0) offset += bytes_read; #else - bytes_read = HDread(file->fd, buf, bytes_in); + bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_read && EINTR == errno); + } while (-1 == bytes_read && EINTR == errno); - if(-1 == bytes_read) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_read) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, + "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, " + "bytes actually read = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ - if(0 == bytes_read) { + if (0 == bytes_read) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); break; @@ -769,19 +777,18 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU /* Update current position */ file->pos = addr; - file->op = OP_READ; + file->op = OP_READ; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_write * @@ -797,12 +804,12 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU *------------------------------------------------------------------------- */ static herr_t -H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, - haddr_t addr, size_t size, const void *buf) +H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, const void *buf) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -810,29 +817,30 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) + if (REGION_OVERFLOW(addr, size)) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", + (unsigned long long)addr, (unsigned long long)size) #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ - if(addr != file->pos || OP_WRITE != file->op) - if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + if (addr != file->pos || OP_WRITE != file->op) + if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") #endif /* H5_HAVE_PREADWRITE */ /* Write the data, being careful of interrupted system calls and partial * results */ - while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ + while (size > 0) { + h5_posix_io_t bytes_in = 0; /* # of bytes to write */ + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. */ - if(size > H5_POSIX_MAX_IO_BYTES) + if (size > H5_POSIX_MAX_IO_BYTES) bytes_in = H5_POSIX_MAX_IO_BYTES; else bytes_in = (h5_posix_io_t)size; @@ -840,20 +848,26 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - if(bytes_wrote > 0) + if (bytes_wrote > 0) offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ - } while(-1 == bytes_wrote && EINTR == errno); + } while (-1 == bytes_wrote && EINTR == errno); - if(-1 == bytes_wrote) { /* error */ - int myerrno = errno; - time_t mytime = HDtime(NULL); + if (-1 == bytes_wrote) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " + "error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = " + "%llu, bytes actually written = %llu, offset = %llu", + HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, + (unsigned long long)size, (unsigned long long)bytes_in, + (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ HDassert(bytes_wrote > 0); @@ -866,21 +880,20 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN /* Update current position and eof */ file->pos = addr; - file->op = OP_WRITE; - if(file->pos > file->eof) + file->op = OP_WRITE; + if (file->pos > file->eof) file->eof = file->pos; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_truncate * @@ -897,22 +910,22 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN static herr_t H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UNUSED closing) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); /* Extend the file to make sure it's large enough */ - if(!H5F_addr_eq(file->eoa, file->eof)) { + if (!H5F_addr_eq(file->eoa, file->eof)) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Windows uses this odd QuadPart union for 32/64-bit portability */ li.QuadPart = (__int64)file->eoa; @@ -923,17 +936,17 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) + if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") } bError = SetEndOfFile(file->hFile); - if(0 == bError) + if (0 == bError) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* H5_HAVE_WIN32_API */ - if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) +#else /* H5_HAVE_WIN32_API */ + if (-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ @@ -942,14 +955,13 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + file->op = OP_UNKNOWN; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_lock * @@ -967,9 +979,9 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR static herr_t H5FD__sec2_lock(H5FD_t *_file, hbool_t rw) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - int lock_flags; /* file locking flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -979,8 +991,8 @@ H5FD__sec2_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -994,7 +1006,6 @@ H5FD__sec2_lock(H5FD_t *_file, hbool_t rw) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_lock() */ - /*------------------------------------------------------------------------- * Function: H5FD__sec2_unlock * @@ -1009,15 +1020,15 @@ H5FD__sec2_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__sec2_unlock(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) { + if (HDflock(file->fd, LOCK_UN) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) { /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ @@ -1030,4 +1041,3 @@ H5FD__sec2_unlock(H5FD_t *_file) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_unlock() */ - diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index d669582fc39..541ac71b2ff 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,13 +20,13 @@ #ifndef H5FDsec2_H #define H5FDsec2_H -#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2 (H5FD_sec2_init()) #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5FD_sec2_init(void); +H5_DLL hid_t H5FD_sec2_init(void); H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #ifdef __cplusplus @@ -34,4 +34,3 @@ H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #endif #endif - diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 81d5e3c303f..339c413fd86 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FLprivate.h" /* Free lists */ /****************/ /* Local Macros */ @@ -48,32 +46,26 @@ /* Define this to display information about file allocations */ /* #define H5FD_ALLOC_DEBUG */ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -81,10 +73,8 @@ /* Declare a free list to manage the H5FD_free_t struct */ H5FL_DEFINE(H5FD_free_t); - - /*------------------------------------------------------------------------- - * Function: H5FD_extend + * Function: H5FD__extend * * Purpose: Extend the EOA space of a file. * @@ -99,12 +89,12 @@ H5FL_DEFINE(H5FD_free_t); *------------------------------------------------------------------------- */ static haddr_t -H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) +H5FD__extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) { - haddr_t eoa; /* Address of end-of-allocated space */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa; /* Address of end-of-allocated space */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(file); @@ -116,7 +106,7 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) eoa = file->cls->get_eoa(file, type); /* Check for overflow when extending */ - if(H5F_addr_overflow(eoa, size) || (eoa + size) > file->maxaddr) + if (H5F_addr_overflow(eoa, size) || (eoa + size) > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") /* Set the [NOT aligned] address to return */ @@ -124,14 +114,13 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) /* Extend the end-of-allocated space address */ eoa += size; - if(file->cls->set_eoa(file, type, eoa) < 0) + if (file->cls->set_eoa(file, type, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_extend() */ +} /* end H5FD__extend() */ - /*------------------------------------------------------------------------- * Function: H5FD__alloc_real * @@ -148,19 +137,18 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hsize_t size) *------------------------------------------------------------------------- */ haddr_t -H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, - hsize_t *frag_size) +H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - hsize_t orig_size = size; /* Original allocation size */ - haddr_t eoa; /* Address of end-of-allocated space */ - hsize_t extra; /* Extra space to allocate, to align request */ - unsigned long flags = 0; /* Driver feature flags */ - hbool_t use_alloc_size; /* Just pass alloc size to the driver */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + hsize_t orig_size = size; /* Original allocation size */ + haddr_t eoa; /* Address of end-of-allocated space */ + hsize_t extra; /* Extra space to allocate, to align request */ + unsigned long flags = 0; /* Driver feature flags */ + hbool_t use_alloc_size; /* Just pass alloc size to the driver */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ 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 = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5FD_ALLOC_DEBUG */ /* check args */ @@ -170,7 +158,7 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HDassert(size > 0); /* Check for query driver and call it */ - if(file->cls->query) + if (file->cls->query) (file->cls->query)(file, &flags); /* Check for the driver feature flag */ @@ -181,39 +169,41 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); /* Compute extra space to allocate, if this should be aligned */ extra = 0; - if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) { - hsize_t mis_align; /* Amount EOA is misaligned */ + if (!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) { + hsize_t mis_align; /* Amount EOA is misaligned */ /* Check for EOA already aligned */ - if((mis_align = (eoa % file->alignment)) > 0) { + if ((mis_align = (eoa % file->alignment)) > 0) { extra = file->alignment - mis_align; - if(frag_addr) - *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ - if(frag_size) + if (frag_addr) + *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ + if (frag_size) *frag_size = extra; } /* end if */ - } /* end if */ + } /* end if */ /* Dispatch to driver `alloc' callback or extend the end-of-address marker */ - /* For the multi/split driver: the size passed down to the alloc callback is the original size from H5FD_alloc() */ - /* For all other drivers: the size passed down to the alloc callback is the size + [possibly] alignment size */ - if(file->cls->alloc) { + /* For the multi/split driver: the size passed down to the alloc callback is the original size from + * H5FD_alloc() */ + /* For all other drivers: the size passed down to the alloc callback is the size + [possibly] alignment + * size */ + if (file->cls->alloc) { ret_value = (file->cls->alloc)(file, type, H5CX_get_dxpl(), use_alloc_size ? size : size + extra); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed") } /* end if */ else { - ret_value = H5FD_extend(file, type, size + extra); - if(!H5F_addr_defined(ret_value)) + ret_value = H5FD__extend(file, type, size + extra); + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver eoa update request failed") } /* end else */ /* Set the [possibly aligned] address to return */ - if(!use_alloc_size) + if (!use_alloc_size) ret_value += extra; /* Post-condition sanity check */ - if(!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) + if (!file->paged_aggr && file->alignment > 1 && orig_size >= file->threshold) HDassert(!(ret_value % file->alignment)); /* Convert absolute file offset to relative address */ @@ -221,12 +211,11 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); done: #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5FD_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__alloc_real() */ - /*------------------------------------------------------------------------- * Function: H5FD_alloc * @@ -246,10 +235,9 @@ HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); *------------------------------------------------------------------------- */ haddr_t -H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, - haddr_t *frag_addr, hsize_t *frag_size) +H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -261,18 +249,17 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, /* Call the real 'alloc' routine */ ret_value = H5FD__alloc_real(file, type, size, frag_addr, frag_size); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "real 'alloc' request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark EOA info as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD__free_real * @@ -289,7 +276,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, H5F_t *f, hsize_t size, herr_t H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -300,58 +287,58 @@ 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 = %a, size = %Hu\n", FUNC, (unsigned)type, addr, size); #endif /* H5FD_ALLOC_DEBUG */ /* Sanity checking */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file offset") /* Convert address to absolute file offset */ addr += file->base_addr; /* More sanity checking */ - if(addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr) + if (addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file free space region to free") /* Check for file driver 'free' callback and call it if available */ - if(file->cls->free) { + if (file->cls->free) { #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: Letting VFD free space\n", FUNC); + HDfprintf(stderr, "%s: Letting VFD free space\n", FUNC); #endif /* H5FD_ALLOC_DEBUG */ - if((file->cls->free)(file, type, H5CX_get_dxpl(), addr, size) < 0) + if ((file->cls->free)(file, type, H5CX_get_dxpl(), addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ /* Check if this free block is at the end of file allocated space. * Truncate it if this is true. */ - else if(file->cls->get_eoa) { - haddr_t eoa; + else if (file->cls->get_eoa) { + haddr_t eoa; eoa = file->cls->get_eoa(file, type); #ifdef H5FD_ALLOC_DEBUG -HDfprintf(stderr, "%s: eoa = %a\n", FUNC, eoa); + HDfprintf(stderr, "%s: eoa = %a\n", FUNC, eoa); #endif /* H5FD_ALLOC_DEBUG */ - if(eoa == (addr + size)) { + 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 = %a\n", FUNC, addr); #endif /* H5FD_ALLOC_DEBUG */ - if(file->cls->set_eoa(file, type, addr) < 0) + if (file->cls->set_eoa(file, type, addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "set end of space allocation request failed") } /* end if */ - } /* end else-if */ + } /* end else-if */ 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 = %a, size = %Hu\n", FUNC, (unsigned)type, + addr, size); #endif /* H5FD_ALLOC_DEBUG */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__free_real() */ - /*------------------------------------------------------------------------- * Function: H5FD_free * @@ -373,7 +360,7 @@ HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUN herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -384,18 +371,17 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size) HDassert(size > 0); /* Call the real 'free' routine */ - if(H5FD__free_real(file, type, addr, size) < 0) + if (H5FD__free_real(file, type, addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "real 'free' request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA info as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_free() */ - /*------------------------------------------------------------------------- * Function: H5FD_try_extend * @@ -417,8 +403,8 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t addr, hsize_t size) htri_t H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_t extra_requested) { - haddr_t eoa; /* End of allocated space in file */ - htri_t ret_value = FALSE; /* Return value */ + haddr_t eoa; /* End of allocated space in file */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -430,20 +416,20 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ HDassert(f); /* Retrieve the end of the address space */ - if(HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type))) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Adjust block end by base address of the file, to create absolute address */ blk_end += file->base_addr; /* Check if the block is exactly at the end of the file */ - if(H5F_addr_eq(blk_end, eoa)) { + if (H5F_addr_eq(blk_end, eoa)) { /* Extend the object by extending the underlying file */ - if(HADDR_UNDEF == H5FD_extend(file, type, extra_requested)) + if (HADDR_UNDEF == H5FD__extend(file, type, extra_requested)) HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed") /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA info as dirty") /* Indicate success */ @@ -453,4 +439,3 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_try_extend() */ - diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index d0ed250d409..93ba154217d 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,36 +19,36 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsplitter.h" /* Splitter file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsplitter.h" /* Splitter file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SPLITTER_g = 0; /* Driver-specific file access properties */ typedef struct H5FD_splitter_fapl_t { - hid_t rw_fapl_id; /* fapl for the R/W channel */ - hid_t wo_fapl_id; /* fapl for the W/O channel */ - char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file name for the W/O channel */ - char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file to record errors reported by the W/O channel */ - hbool_t ignore_wo_errs; /* TRUE to ignore errors on the W/O channel */ + hid_t rw_fapl_id; /* fapl for the R/W channel */ + hid_t wo_fapl_id; /* fapl for the W/O channel */ + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file name for the W/O channel */ + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file to record errors reported by the W/O channel */ + hbool_t ignore_wo_errs; /* TRUE to ignore errors on the W/O channel */ } H5FD_splitter_fapl_t; /* The information of this splitter */ 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 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_splitter_t; /* @@ -66,101 +66,103 @@ typedef struct H5FD_splitter_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || (HDoff_t)((A) + (Z)) < (HDoff_t)(A)) /* This macro provides a wrapper for shared fail-log-ignore behavior * for errors arising in the splitter's W/O channel. * Logs an error entry in a log file, if the file exists. * If not set to ignore errors, registers an error with the library. */ -#define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ -{ \ - H5FD__splitter_log_error((file), (funcname), (mesg)); \ - if(FALSE == (file)->fa.ignore_wo_errs) \ - HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ -} +#define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ + { \ + H5FD__splitter_log_error((file), (funcname), (mesg)); \ + if (FALSE == (file)->fa.ignore_wo_errs) \ + HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ + } #define H5FD_SPLITTER_DEBUG_OP_CALLS 0 /* debugging print toggle; 0 disables */ #if H5FD_SPLITTER_DEBUG_OP_CALLS -#define H5FD_SPLITTER_LOG_CALL(name) do { \ - HDprintf("called %s()\n", (name)); \ - HDfflush(stdout); \ -} while (0) +#define H5FD_SPLITTER_LOG_CALL(name) \ + do { \ + HDprintf("called %s()\n", (name)); \ + HDfflush(stdout); \ + } while (0) #else #define H5FD_SPLITTER_LOG_CALL(name) /* no-op */ -#endif /* H5FD_SPLITTER_DEBUG_OP_CALLS */ +#endif /* H5FD_SPLITTER_DEBUG_OP_CALLS */ /* Private functions */ /* Print error messages from W/O channel to log file */ static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg); -static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); +static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); /* Prototypes */ -static herr_t H5FD__splitter_term(void); +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 herr_t H5FD__splitter_fapl_free(void *_fapl); +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 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); -static int H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); -static herr_t H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); +static herr_t H5FD__splitter_close(H5FD_t *_file); +static int H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); +static herr_t H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); static haddr_t H5FD__splitter_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); -static herr_t H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +static herr_t H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); static haddr_t H5FD__splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); +static herr_t H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); static haddr_t H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); -static herr_t H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle); -static herr_t H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf); -static herr_t H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); -static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD__splitter_unlock(H5FD_t *_file); +static herr_t H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle); +static herr_t H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD__splitter_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_splitter_g = { - "splitter", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__splitter_term, /* terminate */ - H5FD__splitter_sb_size, /* sb_size */ - H5FD__splitter_sb_encode, /* sb_encode */ - H5FD__splitter_sb_decode, /* sb_decode */ + "splitter", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__splitter_term, /* terminate */ + H5FD__splitter_sb_size, /* sb_size */ + H5FD__splitter_sb_encode, /* sb_encode */ + H5FD__splitter_sb_decode, /* sb_decode */ sizeof(H5FD_splitter_fapl_t), /* fapl_size */ - H5FD__splitter_fapl_get, /* fapl_get */ - H5FD__splitter_fapl_copy, /* fapl_copy */ - H5FD__splitter_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__splitter_open, /* open */ - H5FD__splitter_close, /* close */ - H5FD__splitter_cmp, /* cmp */ - H5FD__splitter_query, /* query */ - H5FD__splitter_get_type_map, /* get_type_map */ - H5FD__splitter_alloc, /* alloc */ - H5FD__splitter_free, /* free */ - H5FD__splitter_get_eoa, /* get_eoa */ - H5FD__splitter_set_eoa, /* set_eoa */ - H5FD__splitter_get_eof, /* get_eof */ - H5FD__splitter_get_handle, /* get_handle */ - H5FD__splitter_read, /* read */ - H5FD__splitter_write, /* write */ - H5FD__splitter_flush, /* flush */ - H5FD__splitter_truncate, /* truncate */ - H5FD__splitter_lock, /* lock */ - H5FD__splitter_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + H5FD__splitter_fapl_get, /* fapl_get */ + H5FD__splitter_fapl_copy, /* fapl_copy */ + H5FD__splitter_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__splitter_open, /* open */ + H5FD__splitter_close, /* close */ + H5FD__splitter_cmp, /* cmp */ + H5FD__splitter_query, /* query */ + H5FD__splitter_get_type_map, /* get_type_map */ + H5FD__splitter_alloc, /* alloc */ + H5FD__splitter_free, /* free */ + H5FD__splitter_get_eoa, /* get_eoa */ + H5FD__splitter_set_eoa, /* set_eoa */ + H5FD__splitter_get_eof, /* get_eof */ + H5FD__splitter_get_handle, /* get_handle */ + H5FD__splitter_read, /* read */ + H5FD__splitter_write, /* write */ + H5FD__splitter_flush, /* flush */ + H5FD__splitter_truncate, /* truncate */ + H5FD__splitter_lock, /* lock */ + H5FD__splitter_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; /* Declare a free list to manage the H5FD_splitter_t struct */ @@ -169,7 +171,6 @@ H5FL_DEFINE_STATIC(H5FD_splitter_t); /* Declare a free list to manage the H5FD_splitter_fapl_t struct */ H5FL_DEFINE_STATIC(H5FD_splitter_fapl_t); - /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -187,14 +188,13 @@ H5FD__init_package(void) H5FD_SPLITTER_LOG_CALL(FUNC); - if(H5FD_splitter_init() < 0) + if (H5FD_splitter_init() < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize splitter VFD") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_splitter_init * @@ -210,11 +210,11 @@ H5FD_splitter_init(void) { hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) H5FD_SPLITTER_LOG_CALL(FUNC); - if(H5I_VFL != H5I_get_type(H5FD_SPLITTER_g)) + if (H5I_VFL != H5I_get_type(H5FD_SPLITTER_g)) H5FD_SPLITTER_g = H5FDregister(&H5FD_splitter_g); ret_value = H5FD_SPLITTER_g; @@ -223,7 +223,6 @@ H5FD_splitter_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD__splitter_term * @@ -245,8 +244,7 @@ H5FD__splitter_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__splitter_term() */ - - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * Function: H5FD__copy_plist * * Purpose: Sanity-wrapped H5P_copy_plist() for each channel. @@ -256,11 +254,10 @@ H5FD__splitter_term(void) *------------------------------------------------------------------------- */ static int -H5FD__copy_plist(hid_t fapl_id, - hid_t *id_out_ptr) +H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr) { - int ret_value = 0; - H5P_genplist_t *plist_ptr = NULL; + int ret_value = 0; + H5P_genplist_t *plist_ptr = NULL; FUNC_ENTER_STATIC @@ -268,22 +265,21 @@ H5FD__copy_plist(hid_t fapl_id, HDassert(id_out_ptr != NULL); - if(FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a file access property list"); plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id); - if(NULL == plist_ptr) + if (NULL == plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "unable to get property list"); *id_out_ptr = H5P_copy_plist(plist_ptr, FALSE); - if(H5I_INVALID_HID == *id_out_ptr) + if (H5I_INVALID_HID == *id_out_ptr) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, -1, "unable to copy file access property list"); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD__copy_plist() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_splitter * @@ -296,8 +292,8 @@ H5FD__copy_plist(hid_t fapl_id, 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; + H5FD_splitter_fapl_t *info = NULL; + H5P_genplist_t * plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -305,11 +301,11 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) H5FD_SPLITTER_LOG_CALL(FUNC); - if(H5FD_SPLITTER_MAGIC != vfd_config->magic) + if (H5FD_SPLITTER_MAGIC != vfd_config->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid configuration (magic number mismatch)") - if(H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid config (version number mismatch)") - if(NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list") /* Make sure that the W/O channel supports write-only capability. @@ -318,28 +314,28 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the * determining attribute. */ - if(H5P_DEFAULT != vfd_config->wo_fapl_id) { - H5FD_class_t *wo_driver = NULL; - H5FD_driver_prop_t wo_driver_prop; - H5P_genplist_t *wo_plist_ptr = NULL; - unsigned long wo_driver_flags = 0; + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + H5FD_class_t * wo_driver = NULL; + H5FD_driver_prop_t wo_driver_prop; + 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); - if(NULL == wo_plist_ptr) + if (NULL == wo_plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) + if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info") wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id); - if(NULL == wo_driver) + if (NULL == wo_driver) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list") - if(H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) + if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags") - if(0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) + if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver") } /* end if W/O VFD is non-default */ info = H5FL_CALLOC(H5FD_splitter_fapl_t); - if(NULL == info) + if (NULL == info) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") info->ignore_wo_errs = vfd_config->ignore_wo_errs; @@ -349,13 +345,13 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) 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) { - if(FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) + if (H5P_DEFAULT != vfd_config->rw_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") info->rw_fapl_id = vfd_config->rw_fapl_id; } - if(H5P_DEFAULT != vfd_config->wo_fapl_id) { - if(FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") info->wo_fapl_id = vfd_config->wo_fapl_id; } @@ -363,74 +359,72 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info); done: - if(info) + if (info) info = H5FL_FREE(H5FD_splitter_fapl_t, info); FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_splitter() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fapl_splitter * * Purpose: Returns information about the splitter file access property - * list through the structure config_out. + * list through the structure config. * - * Will fail if config_out is received without pre-set valid + * Will fail if config is received without pre-set valid * magic and version information. * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out) +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) - H5TRACE2("e", "i*Dr", fapl_id, config_out); + H5TRACE2("e", "i*Dr", fapl_id, config); H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(config_out == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config_out pointer is null") - if(H5FD_SPLITTER_MAGIC != config_out->magic) + if (config == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config pointer is null") + if (H5FD_SPLITTER_MAGIC != config->magic) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (magic number mismatch)") - if(H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config_out->version) + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (version unsafe)") /* Pre-set out FAPL IDs with intent to replace these values */ - config_out->rw_fapl_id = H5I_INVALID_HID; - config_out->wo_fapl_id = H5I_INVALID_HID; + config->rw_fapl_id = H5I_INVALID_HID; + config->wo_fapl_id = H5I_INVALID_HID; /* Check and get the splitter fapl */ - if(NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) + if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) + 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_out->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(config_out->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); - config_out->ignore_wo_errs = fapl_ptr->ignore_wo_errs; + 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); + config->ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O FAPLs */ - if(H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config_out->rw_fapl_id)) < 0) + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config->rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy R/W FAPL"); - if(H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config_out->wo_fapl_id)) < 0) + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config->wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_splitter() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_flush * @@ -442,24 +436,23 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out) static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC H5FD_SPLITTER_LOG_CALL(FUNC); /* Public API for dxpl "context" */ - if(H5FDflush(file->rw_file, dxpl_id, closing) < 0) + if (H5FDflush(file->rw_file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush R/W file") - if(H5FDflush(file->wo_file, dxpl_id, closing) < 0) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush W/O file") + if (H5FDflush(file->wo_file, dxpl_id, closing) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_read * @@ -475,11 +468,11 @@ H5FD__splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closin *------------------------------------------------------------------------- */ static herr_t -H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, - hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf) +H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, + size_t size, void *buf) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -489,21 +482,20 @@ H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, HDassert(buf); /* Check for overflow conditions */ - if(!H5F_addr_defined(addr)) + if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) - if(REGION_OVERFLOW(addr, size)) + if (REGION_OVERFLOW(addr, size)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) /* Only read from R/W channel */ /* Public API for dxpl "context" */ - if(H5FDread(file->rw_file, type, dxpl_id, addr, size, buf) < 0) + if (H5FDread(file->rw_file, type, dxpl_id, addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "Reading from R/W channel failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_read() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_write * @@ -515,32 +507,31 @@ H5FD__splitter_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, *------------------------------------------------------------------------- */ static herr_t -H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, - haddr_t addr, size_t size, const void *buf) +H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + 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 H5FD_SPLITTER_LOG_CALL(FUNC); - if(NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(dxpl_id))) + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Write to each file */ /* Public API for dxpl "context" */ - if(H5FDwrite(file->rw_file, type, dxpl_id, addr, size, buf) < 0) + if (H5FDwrite(file->rw_file, type, dxpl_id, addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "R/W file write failed") - if(H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write W/O file") + if (H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_write() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_fapl_get * @@ -557,7 +548,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 @@ -568,7 +559,6 @@ H5FD__splitter_fapl_get(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_fapl_copy * @@ -582,8 +572,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 @@ -592,30 +582,29 @@ H5FD__splitter_fapl_copy(const void *_old_fa) HDassert(old_fa_ptr); new_fa_ptr = H5FL_CALLOC(H5FD_splitter_fapl_t); - if(NULL == new_fa_ptr) + if (NULL == new_fa_ptr) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") - HDmemcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t)); + 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); /* Copy R/W and W/O FAPLs */ - if(H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) + if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); - if(H5FD__copy_plist(old_fa_ptr->wo_fapl_id, &(new_fa_ptr->wo_fapl_id)) < 0) + if (H5FD__copy_plist(old_fa_ptr->wo_fapl_id, &(new_fa_ptr->wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); ret_value = (void *)new_fa_ptr; done: - if(NULL == ret_value) - if(new_fa_ptr) + if (NULL == ret_value) + if (new_fa_ptr) new_fa_ptr = H5FL_FREE(H5FD_splitter_fapl_t, new_fa_ptr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_fapl_copy() */ - /*-------------------------------------------------------------------------- * Function: H5FD__splitter_fapl_free * @@ -627,7 +616,7 @@ H5FD__splitter_fapl_copy(const void *_old_fa) static herr_t H5FD__splitter_fapl_free(void *_fapl) { - H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t*)_fapl; + H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t *)_fapl; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -637,9 +626,9 @@ H5FD__splitter_fapl_free(void *_fapl) /* Check arguments */ HDassert(fapl); - if(H5I_dec_ref(fapl->rw_fapl_id) < 0) + if (H5I_dec_ref(fapl->rw_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close R/W FAPL ID") - if(H5I_dec_ref(fapl->wo_fapl_id) < 0) + if (H5I_dec_ref(fapl->wo_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close W/O FAPL ID") /* Free the property list */ @@ -649,7 +638,6 @@ H5FD__splitter_fapl_free(void *_fapl) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_fapl_free() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_open * @@ -664,39 +652,38 @@ 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 H5FD_SPLITTER_LOG_CALL(FUNC); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") - if(0 == maxaddr || HADDR_UNDEF == maxaddr) + if (0 == maxaddr || HADDR_UNDEF == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") - if(ADDR_OVERFLOW(maxaddr)) + if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") - if((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || - (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id)) ) + if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))) /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter") file_ptr = (H5FD_splitter_t *)H5FL_CALLOC(H5FD_splitter_t); - if(NULL == file_ptr) + if (NULL == file_ptr) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct") file_ptr->fa.rw_fapl_id = H5I_INVALID_HID; file_ptr->fa.wo_fapl_id = H5I_INVALID_HID; /* Get the driver-specific file access properties */ plist_ptr = (H5P_genplist_t *)H5I_object(splitter_fapl_id); - if(NULL == plist_ptr) + if (NULL == plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr); - if(NULL == fapl_ptr) + if (NULL == fapl_ptr) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info") /* Copy simpler info */ @@ -705,45 +692,45 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha file_ptr->fa.ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O channel FAPLs. */ - if(H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(file_ptr->fa.rw_fapl_id)) < 0) + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(file_ptr->fa.rw_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); - if(H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(file_ptr->fa.wo_fapl_id)) < 0) + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(file_ptr->fa.wo_fapl_id)) < 0) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); /* Prepare log file if necessary. * If application wants to ignore the errors from W/O channel and * provided a name for the log file, then open it */ - if(!file_ptr->logfp) { - if(file_ptr->fa.log_file_path[0] != '\0') { + if (!file_ptr->logfp) { + if (file_ptr->fa.log_file_path[0] != '\0') { file_ptr->logfp = HDfopen(file_ptr->fa.log_file_path, "w"); - if(file_ptr->logfp == NULL) + if (file_ptr->logfp == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open log file") } /* end if logfile path given */ - } /* end if logfile pointer/handle does not exist */ + } /* end if logfile pointer/handle does not exist */ file_ptr->rw_file = H5FD_open(name, flags, fapl_ptr->rw_fapl_id, HADDR_UNDEF); - if(!file_ptr->rw_file) + if (!file_ptr->rw_file) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open R/W file") file_ptr->wo_file = H5FD_open(fapl_ptr->wo_path, flags, fapl_ptr->wo_fapl_id, HADDR_UNDEF); - if(!file_ptr->wo_file) - H5FD_SPLITTER_WO_ERROR(file_ptr, FUNC, H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open W/O file") + if (!file_ptr->wo_file) + H5FD_SPLITTER_WO_ERROR(file_ptr, FUNC, H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open W/O file") - ret_value = (H5FD_t*)file_ptr; + ret_value = (H5FD_t *)file_ptr; done: - if(NULL == ret_value) { - if(file_ptr) { - if(H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) + if (NULL == ret_value) { + if (file_ptr) { + if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) H5I_dec_ref(file_ptr->fa.rw_fapl_id); - if(H5I_INVALID_HID != file_ptr->fa.wo_fapl_id) + if (H5I_INVALID_HID != file_ptr->fa.wo_fapl_id) H5I_dec_ref(file_ptr->fa.wo_fapl_id); - if(file_ptr->rw_file) + if (file_ptr->rw_file) H5FD_close(file_ptr->rw_file); - if(file_ptr->wo_file) + if (file_ptr->wo_file) H5FD_close(file_ptr->wo_file); - if(file_ptr->logfp) + if (file_ptr->logfp) HDfclose(file_ptr->logfp); H5FL_FREE(H5FD_splitter_t, file_ptr); } @@ -752,7 +739,6 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_open() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_close * @@ -775,19 +761,19 @@ H5FD__splitter_close(H5FD_t *_file) /* Sanity check */ HDassert(file); - if(H5I_dec_ref(file->fa.rw_fapl_id) < 0) + if (H5I_dec_ref(file->fa.rw_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close R/W FAPL") - if(H5I_dec_ref(file->fa.wo_fapl_id) < 0) + if (H5I_dec_ref(file->fa.wo_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close W/O FAPL") - if(file->rw_file) - if(H5FD_close(file->rw_file) == FAIL) + if (file->rw_file) + if (H5FD_close(file->rw_file) == FAIL) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close R/W file") - if(file->wo_file) - if(H5FD_close(file->wo_file) == FAIL) + if (file->wo_file) + if (H5FD_close(file->wo_file) == FAIL) H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close W/O file") - if(file->logfp) { + if (file->logfp) { HDfclose(file->logfp); file->logfp = NULL; } @@ -800,7 +786,6 @@ H5FD__splitter_close(H5FD_t *_file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_close() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_get_eoa * @@ -827,14 +812,13 @@ H5FD__splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) HDassert(file); HDassert(file->rw_file); - if((ret_value = H5FD_get_eoa(file->rw_file, type)) == HADDR_UNDEF) + if ((ret_value = H5FD_get_eoa(file->rw_file, type)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, HADDR_UNDEF, "unable to get eoa") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_get_eoa */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_set_eoa * @@ -848,8 +832,8 @@ H5FD__splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -860,17 +844,16 @@ H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t ad HDassert(file->rw_file); HDassert(file->wo_file); - if(H5FD_set_eoa(file->rw_file, type, addr) < 0) + if (H5FD_set_eoa(file->rw_file, type, addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "H5FDset_eoa failed for R/W file") - if(H5FD_set_eoa(file->wo_file, type, addr) < 0) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTSET, FAIL, "unable to set EOA for W/O file") + if (H5FD_set_eoa(file->wo_file, type, addr) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTSET, FAIL, "unable to set EOA for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_get_eof * @@ -886,8 +869,8 @@ H5FD__splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t ad static haddr_t H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { - const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC @@ -897,14 +880,13 @@ H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) HDassert(file); HDassert(file->rw_file); - if(HADDR_UNDEF == (ret_value = H5FD_get_eof(file->rw_file, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file->rw_file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "unable to get eof") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_get_eof */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_truncate * @@ -916,8 +898,8 @@ H5FD__splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -927,17 +909,16 @@ H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) HDassert(file->rw_file); HDassert(file->wo_file); - if(H5FDtruncate(file->rw_file, dxpl_id, closing) < 0) + if (H5FDtruncate(file->rw_file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate R/W file") - if(H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate W/O file") + if (H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_truncate */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_sb_size * @@ -966,13 +947,12 @@ H5FD__splitter_sb_size(H5FD_t *_file) HDassert(file); HDassert(file->rw_file); - if(file->rw_file) + if (file->rw_file) ret_value = H5FD_sb_size(file->rw_file); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_sb_size */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_sb_encode * @@ -982,10 +962,10 @@ H5FD__splitter_sb_size(H5FD_t *_file) *------------------------------------------------------------------------- */ static herr_t -H5FD__splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -995,14 +975,13 @@ H5FD__splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*o HDassert(file); HDassert(file->rw_file); - if(file->rw_file && H5FD_sb_encode(file->rw_file, name, buf) < 0) + if (file->rw_file && H5FD_sb_encode(file->rw_file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTENCODE, FAIL, "unable to encode the superblock in R/W file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_sb_encode */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_sb_decode * @@ -1016,8 +995,8 @@ H5FD__splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*o static herr_t H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1027,14 +1006,13 @@ H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *b HDassert(file); HDassert(file->rw_file); - if(H5FD_sb_load(file->rw_file, name, buf) < 0) + if (H5FD_sb_load(file->rw_file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDECODE, FAIL, "unable to decode the superblock in R/W file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_sb_decode */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_cmp * @@ -1047,9 +1025,9 @@ H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *b static int H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; - const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; - herr_t ret_value = 0; /* Return value */ + const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; + const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1063,7 +1041,6 @@ H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_cmp */ - /*-------------------------------------------------------------------------- * Function: H5FD__splitter_get_handle * @@ -1074,11 +1051,10 @@ H5FD__splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) *-------------------------------------------------------------------------- */ static herr_t -H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, - void **file_handle) +H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void **file_handle) { - H5FD_splitter_t *file = (H5FD_splitter_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1090,14 +1066,13 @@ H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, HDassert(file_handle); /* Only do for R/W channel */ - if(H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) + if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to get handle of R/W file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_get_handle */ - /*-------------------------------------------------------------------------- * Function: H5FD__splitter_lock * @@ -1109,8 +1084,8 @@ H5FD__splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1120,18 +1095,17 @@ H5FD__splitter_lock(H5FD_t *_file, hbool_t rw) HDassert(file->rw_file); /* Place the lock on each file */ - if(H5FD_lock(file->rw_file, rw) < 0) + if (H5FD_lock(file->rw_file, rw) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock R/W file") - if(file->wo_file != NULL) - if(H5FD_lock(file->wo_file, rw) < 0) + if (file->wo_file != NULL) + if (H5FD_lock(file->wo_file, rw) < 0) H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTLOCKFILE, FAIL, "unable to lock W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_lock */ - /*-------------------------------------------------------------------------- * Function: H5FD__splitter_unlock * @@ -1143,8 +1117,8 @@ H5FD__splitter_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD__splitter_unlock(H5FD_t *_file) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1155,18 +1129,17 @@ H5FD__splitter_unlock(H5FD_t *_file) HDassert(file->rw_file); /* Remove the lock on each file */ - if(H5FD_unlock(file->rw_file) < 0) + if (H5FD_unlock(file->rw_file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock R/W file") - if(file->wo_file != NULL) - if(H5FD_unlock(file->wo_file) < 0) + if (file->wo_file != NULL) + if (H5FD_unlock(file->wo_file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_unlock */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_query * @@ -1186,18 +1159,18 @@ H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) H5FD_SPLITTER_LOG_CALL(FUNC); - if(file) { + if (file) { HDassert(file); HDassert(file->rw_file); - if(H5FDquery(file->rw_file, flags) < 0) + if (H5FDquery(file->rw_file, flags) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to query R/W file"); } else { /* There is no file. Because this is a pure passthrough VFD, * it has no features of its own. */ - if(flags) + if (flags) *flags = 0; } @@ -1205,7 +1178,6 @@ H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_query() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_alloc * @@ -1217,8 +1189,8 @@ H5FD__splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD__splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_STATIC @@ -1229,17 +1201,16 @@ H5FD__splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size HDassert(file->rw_file); /* Allocate memory for each file, only return the return value for R/W file. */ - if((ret_value = H5FDalloc(file->rw_file, type, dxpl_id, size)) == HADDR_UNDEF) + if ((ret_value = H5FDalloc(file->rw_file, type, dxpl_id, size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate for R/W file") - if(H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to alloc for W/O file") + if (H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to alloc for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_get_type_map * @@ -1263,14 +1234,13 @@ H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) HDassert(file->rw_file); /* Retrieve memory type mapping for R/W channel only */ - if(H5FD_get_fs_type_map(file->rw_file, type_map) < 0) + if (H5FD_get_fs_type_map(file->rw_file, type_map) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to allocate for R/W file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_get_type_map() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_free * @@ -1282,8 +1252,8 @@ H5FD__splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) static herr_t H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { - H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1293,17 +1263,16 @@ H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, HDassert(file); HDassert(file->rw_file); - if(H5FDfree(file->rw_file, type, dxpl_id, addr, size) < 0) + if (H5FDfree(file->rw_file, type, dxpl_id, addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free for R/W file") - if(H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) - H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, FAIL, "unable to free for W/O file") + if (H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) + H5FD_SPLITTER_WO_ERROR(file, FUNC, H5E_VFL, H5E_CANTINIT, FAIL, "unable to free for W/O file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_free() */ - /*------------------------------------------------------------------------- * Function: H5FD__splitter_log_error * @@ -1326,21 +1295,20 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const HDassert(atfunc && *atfunc); HDassert(msg && *msg); - if(file->logfp != NULL) { + if (file->logfp != NULL) { size_t size; - char *s; + char * s; size = HDstrlen(atfunc) + HDstrlen(msg) + 3; /* ':', ' ', '\n' */ - s = (char *)HDmalloc(sizeof(char) * (size + 1)); - if(NULL == s) + s = (char *)H5MM_malloc(sizeof(char) * (size + 1)); + if (NULL == s) ret_value = FAIL; - else if(size < (size_t)HDsnprintf(s, size+1, "%s: %s\n", atfunc, msg)) + else if (size < (size_t)HDsnprintf(s, size + 1, "%s: %s\n", atfunc, msg)) ret_value = FAIL; - else if(size != HDfwrite(s, 1, size, file->logfp)) + else if (size != HDfwrite(s, 1, size, file->logfp)) ret_value = FAIL; - HDfree(s); + H5MM_free(s); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_log_error() */ - diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index 5a5ef29b039..ee6e7c53a7c 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -75,20 +75,32 @@ * ---------------------------------------------------------------------------- */ typedef struct H5FD_splitter_vfd_config_t { - int32_t magic; + int32_t magic; unsigned int version; - hid_t rw_fapl_id; - hid_t wo_fapl_id; - char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; - char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; - hbool_t ignore_wo_errs; + hid_t rw_fapl_id; + hid_t wo_fapl_id; + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; + hbool_t ignore_wo_errs; } H5FD_splitter_vfd_config_t; #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_splitter_init(void); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); + +/** + * \ingroup FAPL + * + * \todo Add missing documentation + */ H5_DLL herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); #ifdef __cplusplus @@ -96,4 +108,3 @@ H5_DLL herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *co #endif #endif - diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 68b286196ee..3d0332fcc54 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -41,8 +41,8 @@ #ifdef H5_HAVE_WIN32_API /* The following two defines must be before any windows headers are included */ -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ -#define NOGDI /* Exclude Graphic Display Interface macros */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#define NOGDI /* Exclude Graphic Display Interface macros */ #include #include @@ -60,10 +60,10 @@ static size_t H5_STDIO_MAX_IO_BYTES_g = (size_t)-1; /* File operations */ typedef enum { - H5FD_STDIO_OP_UNKNOWN=0, - H5FD_STDIO_OP_READ=1, - H5FD_STDIO_OP_WRITE=2, - H5FD_STDIO_OP_SEEK=3 + H5FD_STDIO_OP_UNKNOWN = 0, + H5FD_STDIO_OP_READ = 1, + H5FD_STDIO_OP_WRITE = 2, + H5FD_STDIO_OP_SEEK = 3 } H5FD_stdio_file_op; /* The description of a file belonging to this driver. The 'eoa' and 'eof' @@ -78,15 +78,15 @@ typedef enum { * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_stdio_t { - H5FD_t pub; /* public stuff, must be first */ - 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 */ - haddr_t pos; /* current file I/O position */ - unsigned write_access; /* Flag to indicate the file was opened with write access */ - hbool_t ignore_disabled_file_locks; - H5FD_stdio_file_op op; /* last operation */ + H5FD_t pub; /* public stuff, must be first */ + 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 */ + haddr_t pos; /* current file I/O position */ + unsigned write_access; /* Flag to indicate the file was opened with write access */ + hbool_t ignore_disabled_file_locks; + H5FD_stdio_file_op op; /* last operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -94,8 +94,8 @@ typedef struct H5FD_stdio_t { * and will use the 'device + inodes' scheme as opposed to the * Windows code further below. */ - dev_t device; /* file device number */ - ino_t inode; /* file i-node number */ + dev_t device; /* file device number */ + ino_t inode; /* file i-node number */ #else /* Files in windows are uniquely identified by the volume serial * number and the file index (both low and high parts). @@ -111,21 +111,21 @@ typedef struct H5FD_stdio_t { * * http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx */ - DWORD nFileIndexLow; - DWORD nFileIndexHigh; - DWORD dwVolumeSerialNumber; + DWORD nFileIndexLow; + DWORD nFileIndexHigh; + DWORD dwVolumeSerialNumber; - HANDLE hFile; /* Native windows file handle */ -#endif /* H5_HAVE_WIN32_API */ + HANDLE hFile; /* Native windows file handle */ +#endif /* H5_HAVE_WIN32_API */ } H5FD_stdio_t; /* Use similar structure as in H5private.h by defining Windows stuff first. */ #ifdef H5_HAVE_WIN32_API #ifndef H5_HAVE_MINGW - #define file_fseek _fseeki64 - #define file_offset_t __int64 - #define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ - #define file_ftell _ftelli64 +#define file_fseek _fseeki64 +#define file_offset_t __int64 +#define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ +#define file_ftell _ftelli64 #endif /* H5_HAVE_MINGW */ #endif /* H5_HAVE_WIN32_API */ @@ -133,10 +133,10 @@ typedef struct H5FD_stdio_t { * more platform-independent names. */ #ifndef file_fseek - #define file_fseek fseeko - #define file_offset_t off_t - #define file_ftruncate ftruncate - #define file_ftell ftello +#define file_fseek fseeko +#define file_offset_t off_t +#define file_ftruncate ftruncate +#define file_ftell ftello #endif /* file_fseek */ /* These macros check for overflow of various quantities. These macros @@ -154,69 +154,68 @@ typedef struct H5FD_stdio_t { * argument of the file seek function. */ /* adding for windows NT filesystem support. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A)) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(file_offset_t) - 1)) - 1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF == (A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A, Z) \ + (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || HADDR_UNDEF == (A) + (Z) || \ + (file_offset_t)((A) + (Z)) < (file_offset_t)(A)) /* Prototypes */ -static herr_t H5FD_stdio_term(void); -static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, - hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_stdio_close(H5FD_t *lf); -static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2); -static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags); +static herr_t H5FD_stdio_term(void); +static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_stdio_close(H5FD_t *lf); +static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_stdio_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); static haddr_t H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); -static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); -static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw); -static herr_t H5FD_stdio_unlock(H5FD_t *_file); +static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle); +static herr_t H5FD_stdio_read(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_stdio_write(H5FD_t *lf, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, + const void *buf); +static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_stdio_unlock(H5FD_t *_file); static const H5FD_class_t H5FD_stdio_g = { - "stdio", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD_stdio_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - 0, /* fapl_size */ - NULL, /* fapl_get */ - NULL, /* fapl_copy */ - NULL, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD_stdio_open, /* open */ - H5FD_stdio_close, /* close */ - H5FD_stdio_cmp, /* cmp */ - H5FD_stdio_query, /* query */ - NULL, /* get_type_map */ - H5FD_stdio_alloc, /* alloc */ - NULL, /* free */ - H5FD_stdio_get_eoa, /* get_eoa */ - H5FD_stdio_set_eoa, /* set_eoa */ - H5FD_stdio_get_eof, /* get_eof */ - H5FD_stdio_get_handle, /* get_handle */ - H5FD_stdio_read, /* read */ - H5FD_stdio_write, /* write */ - H5FD_stdio_flush, /* flush */ - H5FD_stdio_truncate, /* truncate */ - H5FD_stdio_lock, /* lock */ - H5FD_stdio_unlock, /* unlock */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + "stdio", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_stdio_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_stdio_open, /* open */ + H5FD_stdio_close, /* close */ + H5FD_stdio_cmp, /* cmp */ + H5FD_stdio_query, /* query */ + NULL, /* get_type_map */ + H5FD_stdio_alloc, /* alloc */ + NULL, /* free */ + H5FD_stdio_get_eoa, /* get_eoa */ + H5FD_stdio_set_eoa, /* set_eoa */ + H5FD_stdio_get_eof, /* get_eof */ + H5FD_stdio_get_handle, /* get_handle */ + H5FD_stdio_read, /* read */ + H5FD_stdio_write, /* write */ + H5FD_stdio_flush, /* flush */ + H5FD_stdio_truncate, /* truncate */ + H5FD_stdio_lock, /* lock */ + H5FD_stdio_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ }; - /*------------------------------------------------------------------------- * Function: H5FD_stdio_init * @@ -235,19 +234,19 @@ static const H5FD_class_t H5FD_stdio_g = { hid_t H5FD_stdio_init(void) { - char *lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check the use disabled file locks environment variable */ lock_env_var = getenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = 1; /* Override: Ignore disabled locks */ - else if(lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = 0; /* Override: Don't ignore disabled locks */ + if (lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = 1; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = 0; /* Override: Don't ignore disabled locks */ else - ignore_disabled_file_locks_s = -1; /* Environment variable not set, or not set correctly */ + ignore_disabled_file_locks_s = -1; /* Environment variable not set, or not set correctly */ if (H5I_VFL != H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); @@ -255,7 +254,6 @@ H5FD_stdio_init(void) return H5FD_STDIO_g; } /* end H5FD_stdio_init() */ - /*--------------------------------------------------------------------------- * Function: H5FD_stdio_term * @@ -277,7 +275,6 @@ H5FD_stdio_term(void) return 0; } /* end H5FD_stdio_term() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_stdio * @@ -295,20 +292,19 @@ H5FD_stdio_term(void) herr_t H5Pset_fapl_stdio(hid_t fapl_id) { - static const char *func = "H5FDset_fapl_stdio"; /*for error reporting*/ + static const char *func = "H5FDset_fapl_stdio"; /*for error reporting*/ /*NO TRACE*/ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) + if (0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1); return H5Pset_driver(fapl_id, H5FD_STDIO, NULL); } /* end H5Pset_fapl_stdio() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_open * @@ -334,143 +330,147 @@ 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) +H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - FILE *f = NULL; - unsigned write_access = 0; /* File opened with write access? */ - H5FD_stdio_t *file = NULL; - static const char *func = "H5FD_stdio_open"; /* Function Name for error reporting */ + FILE * f = NULL; + unsigned write_access = 0; /* File opened with write access? */ + 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; -#else /* H5_HAVE_WIN32_API */ - struct stat sb; -#endif /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ + struct stat sb; +#endif /* H5_HAVE_WIN32_API */ /* Sanity check on file offsets */ assert(sizeof(file_offset_t) >= sizeof(size_t)); /* Quiet compiler */ - fapl_id = fapl_id; + (void)fapl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL); if (0 == maxaddr || HADDR_UNDEF == maxaddr) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL); if (ADDR_OVERFLOW(maxaddr)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL); /* Tentatively open file in read-only mode, to check for existence */ - if(flags & H5F_ACC_RDWR) + if (flags & H5F_ACC_RDWR) f = fopen(name, "rb+"); else f = fopen(name, "rb"); - if(!f) { + if (!f) { /* File doesn't exist */ - if(flags & H5F_ACC_CREAT) { + if (flags & H5F_ACC_CREAT) { assert(flags & H5F_ACC_RDWR); - f = fopen(name, "wb+"); - write_access = 1; /* Note the write access */ + f = fopen(name, "wb+"); + write_access = 1; /* Note the write access */ } else - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "file doesn't exist and CREAT wasn't specified", NULL) - } else if(flags & H5F_ACC_EXCL) { + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, + "file doesn't exist and CREAT wasn't specified", NULL); + } + else if (flags & H5F_ACC_EXCL) { /* File exists, but EXCL is passed. Fail. */ assert(flags & H5F_ACC_CREAT); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FILEEXISTS, "file exists but CREAT and EXCL were specified", NULL) - } else if(flags & H5F_ACC_RDWR) { - if(flags & H5F_ACC_TRUNC) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_FILEEXISTS, + "file exists but CREAT and EXCL were specified", NULL); + } + else if (flags & H5F_ACC_RDWR) { + if (flags & H5F_ACC_TRUNC) f = freopen(name, "wb+", f); - write_access = 1; /* Note the write access */ - } /* end if */ + write_access = 1; /* Note the write access */ + } /* end if */ /* Note there is no need to reopen if neither TRUNC nor EXCL are specified, * as the tentative open will work */ - if(!f) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL) + if (!f) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL); /* Build the return value */ - if(NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) { + if (NULL == (file = (H5FD_stdio_t *)calloc((size_t)1, sizeof(H5FD_stdio_t)))) { fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); } /* end if */ - file->fp = f; - file->op = H5FD_STDIO_OP_SEEK; - file->pos = HADDR_UNDEF; - file->write_access = write_access; /* Note the write_access for later */ - if(file_fseek(file->fp, (file_offset_t)0, SEEK_END) < 0) { + file->fp = f; + file->op = H5FD_STDIO_OP_SEEK; + file->pos = HADDR_UNDEF; + file->write_access = write_access; /* Note the write_access for later */ + if (file_fseek(file->fp, (file_offset_t)0, SEEK_END) < 0) { file->op = H5FD_STDIO_OP_UNKNOWN; - } else { + } + else { file_offset_t x = file_ftell(file->fp); - assert (x >= 0); + assert(x >= 0); file->eof = (haddr_t)x; } /* Check the file locking flags in the fapl */ - if(ignore_disabled_file_locks_s != -1) + if (ignore_disabled_file_locks_s != -1) /* The environment variable was set, so use that preferentially */ file->ignore_disabled_file_locks = ignore_disabled_file_locks_s; else { hbool_t unused; /* Use the value in the property list */ - if(H5Pget_file_locking(fapl_id, &unused, &file->ignore_disabled_file_locks) < 0) { + if (H5Pget_file_locking(fapl_id, &unused, &file->ignore_disabled_file_locks) < 0) { free(file); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTGET, "unable to get use disabled file locks property", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTGET, + "unable to get use disabled file locks property", NULL); } } /* Get the file descriptor (needed for truncate and some Windows information) */ #ifdef H5_HAVE_WIN32_API file->fd = _fileno(file->fp); -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ file->fd = fileno(file->fp); #endif /* H5_HAVE_WIN32_API */ - if(file->fd < 0) { + if (file->fd < 0) { free(file); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get file descriptor", NULL); } /* end if */ - #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(file->fd); - if(INVALID_HANDLE_VALUE == file->hFile) { + if (INVALID_HANDLE_VALUE == file->hFile) { free(file); fclose(f); H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file handle", NULL); } /* end if */ - if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) { + if (!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) { free(file); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file descriptor information", NULL); + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, + "unable to get Windows file descriptor information", NULL); } /* end if */ - file->nFileIndexHigh = fileinfo.nFileIndexHigh; - file->nFileIndexLow = fileinfo.nFileIndexLow; + file->nFileIndexHigh = fileinfo.nFileIndexHigh; + file->nFileIndexLow = fileinfo.nFileIndexLow; file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber; -#else /* H5_HAVE_WIN32_API */ - if(fstat(file->fd, &sb) < 0) { +#else /* H5_HAVE_WIN32_API */ + if (fstat(file->fd, &sb) < 0) { free(file); fclose(f); - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL); } /* end if */ file->device = sb.st_dev; - file->inode = sb.st_ino; + file->inode = sb.st_ino; #endif /* H5_HAVE_WIN32_API */ - return((H5FD_t*)file); + return ((H5FD_t *)file); } /* end H5FD_stdio_open() */ - /*------------------------------------------------------------------------- * Function: H5F_stdio_close * @@ -489,21 +489,20 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, static herr_t H5FD_stdio_close(H5FD_t *_file) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_close"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); if (fclose(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1); free(file); return 0; } /* end H5FD_stdio_close() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_cmp * @@ -523,41 +522,52 @@ H5FD_stdio_close(H5FD_t *_file) static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; - const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; + const H5FD_stdio_t *f1 = (const H5FD_stdio_t *)_f1; + const H5FD_stdio_t *f2 = (const H5FD_stdio_t *)_f2; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); #ifdef H5_HAVE_WIN32_API - if(f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) return -1; - if(f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) return 1; - - if(f1->nFileIndexHigh < f2->nFileIndexHigh) return -1; - if(f1->nFileIndexHigh > f2->nFileIndexHigh) return 1; - - if(f1->nFileIndexLow < f2->nFileIndexLow) return -1; - if(f1->nFileIndexLow > f2->nFileIndexLow) return 1; + if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) + return -1; + if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) + return 1; + + if (f1->nFileIndexHigh < f2->nFileIndexHigh) + return -1; + if (f1->nFileIndexHigh > f2->nFileIndexHigh) + return 1; + + if (f1->nFileIndexLow < f2->nFileIndexLow) + return -1; + if (f1->nFileIndexLow > f2->nFileIndexLow) + return 1; #else /* H5_HAVE_WIN32_API */ #ifdef H5_DEV_T_IS_SCALAR - if(f1->device < f2->device) return -1; - if(f1->device > f2->device) return 1; -#else /* H5_DEV_T_IS_SCALAR */ + if (f1->device < f2->device) + return -1; + if (f1->device > f2->device) + return 1; +#else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) return -1; - if(memcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) return 1; + if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) + return -1; + if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) + return 1; #endif /* H5_DEV_T_IS_SCALAR */ - if(f1->inode < f2->inode) return -1; - if(f1->inode > f2->inode) return 1; + if (f1->inode < f2->inode) + return -1; + if (f1->inode > f2->inode) + return 1; #endif /* H5_HAVE_WIN32_API */ return 0; } /* H5FD_stdio_cmp() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_query * @@ -577,26 +587,26 @@ static herr_t H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) { /* Quiet the compiler */ - _f=_f; + (void)_f; /* Set the VFL feature flags that this driver supports. * * Note that this VFD does not support SWMR due to the unpredictable * nature of the buffering layer. */ - if(flags) { + if (flags) { *flags = 0; - *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default + VFD */ } return 0; } /* end H5FD_stdio_query() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_alloc * @@ -618,12 +628,12 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, hsize_t size) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - haddr_t addr; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; + haddr_t addr; /* Quiet compiler */ - type = type; - dxpl_id = dxpl_id; + (void)type; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -636,7 +646,6 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp return addr; } /* end H5FD_stdio_alloc() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eoa * @@ -662,12 +671,11 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) H5Eclear2(H5E_DEFAULT); /* Quiet compiler */ - type = type; + (void)type; return file->eoa; } /* end H5FD_stdio_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_set_eoa * @@ -687,20 +695,19 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Quiet the compiler */ - type = type; + (void)type; file->eoa = addr; return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_eof * @@ -722,21 +729,20 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Quiet the compiler */ - type = type; + (void)type; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Quiet the compiler */ - type = type; + (void)type; - return(file->eof); + return (file->eof); } /* end H5FD_stdio_get_eof() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_get_handle * @@ -752,23 +758,22 @@ 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; - static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ /* Quiet the compiler */ - fapl = fapl; + (void)fapl; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); *file_handle = &(file->fp); - if(*file_handle == NULL) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) + if (*file_handle == NULL) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1); return 0; } /* end H5FD_stdio_get_handle() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_read * @@ -788,24 +793,24 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) *------------------------------------------------------------------------- */ 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_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; - static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ /* Quiet the compiler */ - type = type; - dxpl_id = dxpl_id; + (void)type; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check for overflow */ - if (HADDR_UNDEF==addr) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + if (HADDR_UNDEF == addr) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); /* Check easy cases */ if (0 == size) @@ -816,19 +821,18 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl } /* Seek to the correct file position. */ - if (!(file->op == H5FD_STDIO_OP_READ || file->op == H5FD_STDIO_OP_SEEK) || - file->pos != addr) { + if (!(file->op == H5FD_STDIO_OP_READ || file->op == H5FD_STDIO_OP_SEEK) || file->pos != addr) { if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } file->pos = addr; } /* Read zeros past the logical end of file (physical is handled below) */ if (addr + size > file->eof) { - size_t nbytes = (size_t) (addr + size - file->eof); + size_t nbytes = (size_t)(addr + size - file->eof); memset((unsigned char *)buf + size - nbytes, 0, nbytes); size -= nbytes; } @@ -837,26 +841,26 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl * will advance the file position by N. If N is zero or an error * occurs then the file position is undefined. */ - while(size > 0) { + while (size > 0) { - size_t bytes_in = 0; /* # of bytes to read */ - size_t bytes_read = 0; /* # of bytes actually read */ - size_t item_size = 1; /* size of items in bytes */ + size_t bytes_in = 0; /* # of bytes to read */ + size_t bytes_read = 0; /* # of bytes actually read */ + size_t item_size = 1; /* size of items in bytes */ - if(size > H5_STDIO_MAX_IO_BYTES_g) + if (size > H5_STDIO_MAX_IO_BYTES_g) bytes_in = H5_STDIO_MAX_IO_BYTES_g; else bytes_in = size; bytes_read = fread(buf, item_size, bytes_in, file->fp); - if(0 == bytes_read && ferror(file->fp)) { /* error */ - file->op = H5FD_STDIO_OP_UNKNOWN; + if (0 == bytes_read && ferror(file->fp)) { /* error */ + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_READERROR, "fread failed", -1); } /* end if */ - if(0 == bytes_read && feof(file->fp)) { + if (0 == bytes_read && feof(file->fp)) { /* end of file but not end of format address space */ memset((unsigned char *)buf, 0, size); break; @@ -868,13 +872,12 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl } /* end while */ /* Update the file position data. */ - file->op = H5FD_STDIO_OP_READ; + file->op = H5FD_STDIO_OP_READ; file->pos = addr; return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_write * @@ -893,32 +896,31 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl *------------------------------------------------------------------------- */ 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_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; - static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; - type = type; + (void)dxpl_id; + (void)type; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Check for overflow conditions */ if (HADDR_UNDEF == addr) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); if (REGION_OVERFLOW(addr, size)) - H5Epush_ret (func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1); /* Seek to the correct file position. */ - if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || - file->pos != addr) { + if ((file->op != H5FD_STDIO_OP_WRITE && file->op != H5FD_STDIO_OP_SEEK) || file->pos != addr) { if (file_fseek(file->fp, (file_offset_t)addr, SEEK_SET) < 0) { - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "fseek failed", -1); } file->pos = addr; } @@ -927,23 +929,23 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp * advanced by the number of bytes read. On failure, the file position is * undefined. */ - while(size > 0) { + while (size > 0) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ - size_t item_size = 1; /* size of items in bytes */ + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + size_t item_size = 1; /* size of items in bytes */ - if(size > H5_STDIO_MAX_IO_BYTES_g) + if (size > H5_STDIO_MAX_IO_BYTES_g) bytes_in = H5_STDIO_MAX_IO_BYTES_g; else bytes_in = size; bytes_wrote = fwrite(buf, item_size, bytes_in, file->fp); - if(bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(file->fp))) { /* error */ - file->op = H5FD_STDIO_OP_UNKNOWN; + if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(file->fp))) { /* error */ + file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1); } /* end if */ assert(bytes_wrote > 0); @@ -955,7 +957,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp } /* Update seek optimizing data. */ - file->op = H5FD_STDIO_OP_WRITE; + file->op = H5FD_STDIO_OP_WRITE; file->pos = addr; /* Update EOF if necessary */ @@ -965,7 +967,6 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp return 0; } - /*------------------------------------------------------------------------- * Function: H5FD_stdio_flush * @@ -985,31 +986,30 @@ 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; - static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Only try to flush the file if we have write access */ - if(file->write_access) { - if(!closing) { - if(fflush(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) + if (file->write_access) { + if (!closing) { + if (fflush(file->fp) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ - } /* end if */ + } /* end if */ return 0; } /* end H5FD_stdio_flush() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_truncate * @@ -1028,31 +1028,30 @@ 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_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ + H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; - closing = closing; + (void)dxpl_id; + (void)closing; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Only try to flush the file if we have write access */ - if(file->write_access) { + if (file->write_access) { /* Makes sure that the true file size is the same as the end-of-address. */ - if(file->eoa != file->eof) { + if (file->eoa != file->eof) { #ifdef H5_HAVE_WIN32_API - LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ - DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() - * Only used as an error code here. - */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ + LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ + DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() + * Only used as an error code here. + */ + DWORD dwError; /* DWORD error code from GetLastError() */ + BOOL bError; /* Boolean error flag */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); @@ -1066,22 +1065,24 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, * from SetFilePointer(), we also need to check GetLastError(). */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); - if(INVALID_SET_FILE_POINTER == dwPtrLow) { + if (INVALID_SET_FILE_POINTER == dwPtrLow) { dwError = GetLastError(); - if(dwError != NO_ERROR ) - H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_FILEOPEN, "unable to set file pointer", -1) + if (dwError != NO_ERROR) + H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_FILEOPEN, "unable to set file pointer", -1); } bError = SetEndOfFile(file->hFile); - if(0 == bError) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#else /* H5_HAVE_WIN32_API */ + if (0 == bError) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, + "unable to truncate/extend file properly", -1); +#else /* H5_HAVE_WIN32_API */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Truncate file to proper length */ - if(-1 == file_ftruncate(file->fd, (file_offset_t)file->eoa)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) + if (-1 == file_ftruncate(file->fd, (file_offset_t)file->eoa)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, + "unable to truncate/extend file properly", -1); #endif /* H5_HAVE_WIN32_API */ /* Update the eof value */ @@ -1089,19 +1090,18 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, /* Reset last file I/O information */ file->pos = HADDR_UNDEF; - file->op = H5FD_STDIO_OP_UNKNOWN; + file->op = H5FD_STDIO_OP_UNKNOWN; } /* end if */ - } /* end if */ + } /* end if */ else { /* Double-check for problems */ - if(file->eoa > file->eof) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa > eof!", -1) + if (file->eoa > file->eof) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_TRUNCATED, "eoa > eof!", -1); } /* end else */ return 0; } /* end H5FD_stdio_truncate() */ - /*------------------------------------------------------------------------- * Function: H5FD_stdio_lock * @@ -1121,9 +1121,9 @@ 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 */ - int lock_flags; /* file locking flags */ - static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ + 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 */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1134,19 +1134,19 @@ H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) lock_flags = rw ? LOCK_EX : LOCK_SH; /* Place a non-blocking lock on the file */ - if(flock(file->fd, lock_flags | LOCK_NB) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) + if (flock(file->fd, lock_flags | LOCK_NB) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ errno = 0; else - H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "file lock failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTLOCKFILE, "file lock failed", -1); } /* end if */ /* Flush the stream */ - if(fflush(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) + if (fflush(file->fp) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); #endif /* H5_HAVE_FLOCK */ @@ -1172,8 +1172,8 @@ static herr_t H5FD_stdio_unlock(H5FD_t *_file) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* VFD file struct */ - static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ + 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 */ H5Eclear2(H5E_DEFAULT); @@ -1181,18 +1181,18 @@ H5FD_stdio_unlock(H5FD_t *_file) assert(file); /* Flush the stream */ - if(fflush(file->fp) < 0) - H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1) + if (fflush(file->fp) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "fflush failed", -1); /* Place a non-blocking lock on the file */ - if(flock(file->fd, LOCK_UN) < 0) { - if(file->ignore_disabled_file_locks && ENOSYS == errno) + if (flock(file->fd, LOCK_UN) < 0) { + if (file->ignore_disabled_file_locks && ENOSYS == errno) /* When errno is set to ENOSYS, the file system does not support * locking, so ignore it. */ errno = 0; else - H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "file unlock failed", -1) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "file unlock failed", -1); } /* end if */ #endif /* H5_HAVE_FLOCK */ @@ -1200,8 +1200,7 @@ H5FD_stdio_unlock(H5FD_t *_file) return 0; } /* end H5FD_stdio_unlock() */ - -#ifdef _H5private_H +#ifdef H5private_H /* * This is not related to the functionality of the driver code. * It is added here to trigger warning if HDF5 private definitions are included @@ -1209,4 +1208,3 @@ H5FD_stdio_unlock(H5FD_t *_file) */ #error "Do not use HDF5 private definitions" #endif - diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index 9a5bc78efdf..9db92edf834 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,13 +22,27 @@ #include "H5Ipublic.h" -#define H5FD_STDIO (H5FD_stdio_init()) +#define H5FD_STDIO (H5FD_stdio_init()) #ifdef __cplusplus extern "C" { #endif H5_DLL hid_t H5FD_stdio_init(void); +/** + * \ingroup FAPL + * + * \brief Sets the standard I/O driver + * + * \fapl_id + * \returns \herr_t + * + * \details H5Pset_fapl_stdio() modifies the file access property list to use + * the standard I/O driver, H5FDstdio(). + * + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_fapl_stdio(hid_t fapl_id); #ifdef __cplusplus diff --git a/src/H5FDtest.c b/src/H5FDtest.c index 7afc1bfc757..4a907e554f4 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,51 +25,43 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ -#define H5FD_TESTING /* Suppress warning about H5FD testing funcs */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ +#define H5FD_TESTING /* Suppress warning about H5FD testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5FDpkg.h" /* File Drivers */ +#include "H5private.h" /* Generic Functions */ +#include "H5FDpkg.h" /* File Drivers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FD__supports_swmr_test() * @@ -104,11 +96,10 @@ H5FD__supports_swmr_test(const char *vfd_name) FUNC_ENTER_NOAPI_NOINIT_NOERR - if(!vfd_name || !HDstrcmp(vfd_name, "") || !HDstrcmp(vfd_name, "nomatch")) + if (!vfd_name || !HDstrcmp(vfd_name, "") || !HDstrcmp(vfd_name, "nomatch")) ret_value = TRUE; else ret_value = !HDstrcmp(vfd_name, "log") || !HDstrcmp(vfd_name, "sec2"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__supports_swmr_test() */ - diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 76c4f18af38..6ce33a746c2 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -6,25 +6,24 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDwindows.h" /* Windows file driver */ -#include "H5FDsec2.h" /* Windows file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDwindows.h" /* Windows file driver */ +#include "H5FDsec2.h" /* Windows file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_WINDOWS - /*------------------------------------------------------------------------- * Function: H5Pset_fapl_windows * @@ -48,13 +47,13 @@ herr_t H5Pset_fapl_windows(hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_WINDOWS, NULL); @@ -64,4 +63,3 @@ H5Pset_fapl_windows(hid_t fapl_id) } /* end H5Pset_fapl_windows() */ #endif /* H5_HAVE_WINDOWS */ - diff --git a/src/H5FDwindows.h b/src/H5FDwindows.h index 5e237127ecb..79e73b66e1b 100644 --- a/src/H5FDwindows.h +++ b/src/H5FDwindows.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,12 +21,42 @@ #ifndef H5FDwindows_H #define H5FDwindows_H -#define H5FD_WINDOWS (H5FD_sec2_init()) +#define H5FD_WINDOWS (H5FD_sec2_init()) #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +/** + * \ingroup FAPL + * + * \brief Sets the Windows I/O driver + * + * \fapl_id + * \returns \herr_t + * + * \details H5Pset_fapl_windows() sets the default HDF5 Windows I/O driver on + * Windows systems. + * + * Since the HDF5 library uses this driver, #H5FD_WINDOWS, by default + * on Windows systems, it is not normally necessary for a user + * application to call H5Pset_fapl_windows(). While it is not + * recommended, there may be times when a user chooses to set a + * different HDF5 driver, such as the standard I/O driver (#H5FD_STDIO) + * or the sec2 driver (#H5FD_SEC2), in a Windows + * application. H5Pset_fapl_windows() is provided so that the + * application can return to the Windows I/O driver when the time + * comes. + * + * Only the Windows driver is tested on Windows systems; other drivers + * are used at the application’s and the user’s risk. + * + * Furthermore, the Windows driver is tested and available only on + * Windows systems; it is not available on non-Windows systems. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pset_fapl_windows(hid_t fapl_id); #ifdef __cplusplus @@ -34,4 +64,3 @@ H5_DLL herr_t H5Pset_fapl_windows(hid_t fapl_id); #endif /* __cplusplus */ #endif /* H5FDwindows_H */ - diff --git a/src/H5FL.c b/src/H5FL.c index e50616a785e..95188d5bb3d 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,15 +25,14 @@ * move frequently accessed free lists to the head of the queue. */ -#include "H5FLmodule.h" /* This source code file is part of the H5FL module */ - +#include "H5FLmodule.h" /* This source code file is part of the H5FL module */ /* #define H5FL_DEBUG */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ /* * Private type definitions @@ -43,111 +42,112 @@ Default limits on how much memory can accumulate on each free list before it is garbage collected. */ -static size_t H5FL_reg_glb_mem_lim=1*1024*1024; /* Default to 1MB limit on all regular free lists */ -static size_t H5FL_reg_lst_mem_lim=1*65536; /* Default to 64KB limit on each regular free list */ -static size_t H5FL_arr_glb_mem_lim=4*1024*1024; /* Default to 4MB limit on all array free lists */ -static size_t H5FL_arr_lst_mem_lim=4*65536; /* Default to 256KB limit on each array free list */ -static size_t H5FL_blk_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all block free lists */ -static size_t H5FL_blk_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each block free list */ -static size_t H5FL_fac_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all factory free lists */ -static size_t H5FL_fac_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each factory free list */ +static size_t H5FL_reg_glb_mem_lim = 1 * 1024 * 1024; /* Default to 1MB limit on all regular free lists */ +static size_t H5FL_reg_lst_mem_lim = 1 * 65536; /* Default to 64KB limit on each regular free list */ +static size_t H5FL_arr_glb_mem_lim = 4 * 1024 * 1024; /* Default to 4MB limit on all array free lists */ +static size_t H5FL_arr_lst_mem_lim = 4 * 65536; /* Default to 256KB limit on each array free list */ +static size_t H5FL_blk_glb_mem_lim = 16 * 1024 * 1024; /* Default to 16MB limit on all block free lists */ +static size_t H5FL_blk_lst_mem_lim = 1024 * 1024; /* Default to 1024KB (1MB) limit on each block free list */ +static size_t H5FL_fac_glb_mem_lim = 16 * 1024 * 1024; /* Default to 16MB limit on all factory free lists */ +static size_t H5FL_fac_lst_mem_lim = + 1024 * 1024; /* Default to 1024KB (1MB) limit on each factory free list */ /* A garbage collection node for regular free lists */ typedef struct H5FL_reg_gc_node_t { - 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_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; /* The garbage collection head for regular free lists */ typedef struct H5FL_reg_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_reg_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_reg_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_reg_gc_list_t; /* The head of the list of things to garbage collect */ -static H5FL_reg_gc_list_t H5FL_reg_gc_head={0,NULL}; +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 */ - struct H5FL_gc_arr_node_t *next; /* Pointer to the next node in the list of things 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; /* The garbage collection head for array free lists */ typedef struct H5FL_gc_arr_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_gc_arr_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_gc_arr_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_gc_arr_list_t; /* The head of the list of array things to garbage collect */ -static H5FL_gc_arr_list_t H5FL_arr_gc_head={0,NULL}; +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 */ - struct H5FL_blk_gc_node_t *next; /* Pointer to the next node in the list of things 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; /* The garbage collection head for blocks */ typedef struct H5FL_blk_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_blk_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_blk_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_blk_gc_list_t; /* The head of the list of PQs to garbage collect */ -static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL}; +static H5FL_blk_gc_list_t H5FL_blk_gc_head = {0, NULL}; /* A garbage collection node for factory free lists */ struct H5FL_fac_gc_node_t { - H5FL_fac_head_t *list; /* Pointer to the head of the list to garbage collect */ - struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ + H5FL_fac_head_t * list; /* Pointer to the head of the list to garbage collect */ + struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ }; /* The garbage collection head for factory free lists */ typedef struct H5FL_fac_gc_list_t { - size_t mem_freed; /* Amount of free memory on list */ - struct H5FL_fac_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_fac_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ } H5FL_fac_gc_list_t; /* Data structure to store each block in factory free list */ struct H5FL_fac_node_t { - struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ + struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ }; /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; /* The head of the list of factory things to garbage collect */ -static H5FL_fac_gc_list_t H5FL_fac_gc_head={0,NULL}; +static H5FL_fac_gc_list_t H5FL_fac_gc_head = {0, NULL}; #ifdef H5FL_TRACK /* Extra headers needed */ -#include "H5CSprivate.h" /* Function stack */ +#include "H5CSprivate.h" /* Function stack */ /* Head of "outstanding allocations" list */ 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 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); -static int H5FL__reg_term(void); +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); +static int H5FL__reg_term(void); static H5FL_blk_node_t *H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size); static H5FL_blk_node_t *H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size); -static herr_t H5FL__blk_init(H5FL_blk_head_t *head); -static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head); -static herr_t H5FL__blk_gc(void); -static int H5FL__blk_term(void); -static herr_t H5FL__arr_init(H5FL_arr_head_t *head); -static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head); -static herr_t H5FL__arr_gc(void); -static int H5FL__arr_term(void); -static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head); -static herr_t H5FL__fac_gc(void); -static int H5FL__fac_term_all(void); +static herr_t H5FL__blk_init(H5FL_blk_head_t *head); +static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head); +static herr_t H5FL__blk_gc(void); +static int H5FL__blk_term(void); +static herr_t H5FL__arr_init(H5FL_arr_head_t *head); +static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head); +static herr_t H5FL__arr_gc(void); +static int H5FL__arr_term(void); +static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head); +static herr_t H5FL__fac_gc(void); +static int H5FL__fac_term_all(void); /* Declare a free list to manage the H5FL_blk_node_t struct */ H5FL_DEFINE(H5FL_blk_node_t); @@ -158,7 +158,6 @@ H5FL_DEFINE(H5FL_fac_gc_node_t); /* Declare a free list to manage the H5FL_fac_head_t struct */ H5FL_DEFINE(H5FL_fac_head_t); - /*-------------------------------------------------------------------------- NAME H5FL_term_package @@ -169,7 +168,7 @@ H5FL_DEFINE(H5FL_fac_head_t); RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -181,11 +180,11 @@ H5FL_DEFINE(H5FL_fac_head_t); int H5FL_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Garbage collect any nodes on the free lists */ (void)H5FL_garbage_coll(); @@ -196,32 +195,32 @@ H5FL_term_package(void) n += H5FL__blk_term(); /* Mark interface closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ #ifdef H5FL_TRACK /* If we haven't freed all the allocated memory, dump out the list now */ - if(n > 0 && H5FL_out_head_g) { + if (n > 0 && H5FL_out_head_g) { H5FL_track_t *trk = H5FL_out_head_g; /* Dump information about all the outstanding allocations */ - while(trk != NULL) { + while (trk != NULL) { /* Print information about the outstanding block */ - HDfprintf(stderr,"%s: Outstanding allocation:\n", FUNC); - HDfprintf(stderr,"\tPtr: %p, File: %s, Function: %s, Line: %d\n", (((unsigned char *)trk) + sizeof(H5FL_track_t)), trk->file, trk->func, trk->line); + HDfprintf(stderr, "%s: Outstanding allocation:\n", FUNC); + HDfprintf(stderr, "\tPtr: %p, File: %s, Function: %s, Line: %d\n", + (((unsigned char *)trk) + sizeof(H5FL_track_t)), trk->file, trk->func, trk->line); H5CS_print_stack(trk->stack, stderr); /* Advance to next node */ trk = trk->next; } /* end while */ - } /* end if */ -#endif /* H5FL_TRACK */ + } /* end if */ +#endif /* H5FL_TRACK */ FUNC_LEAVE_NOAPI(n) } /* end H5FL_term_package() */ - /*------------------------------------------------------------------------- * Function: H5FL__malloc * @@ -239,26 +238,25 @@ H5FL_term_package(void) static void * H5FL__malloc(size_t mem_size) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Attempt to allocate the memory requested */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) { + if (NULL == (ret_value = H5MM_malloc(mem_size))) { /* If we can't allocate the memory now, try garbage collecting first */ - if(H5FL_garbage_coll()<0) + if (H5FL_garbage_coll() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during allocation") /* Now try allocating the memory again */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) + if (NULL == (ret_value = H5MM_malloc(mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__malloc() */ +} /* end H5FL__malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_init * @@ -276,30 +274,30 @@ H5FL__malloc(size_t mem_size) static herr_t H5FL__reg_init(H5FL_reg_head_t *head) { - H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_reg_gc_node_t *)H5MM_malloc(sizeof(H5FL_reg_gc_node_t)))) + if (NULL == (new_node = (H5FL_reg_gc_node_t *)H5MM_malloc(sizeof(H5FL_reg_gc_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_reg_gc_head.first; - H5FL_reg_gc_head.first=new_node; + new_node->next = H5FL_reg_gc_head.first; + H5FL_reg_gc_head.first = new_node; /* Indicate that the free list is initialized */ head->init = TRUE; /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ - if(head->sizesize=sizeof(H5FL_reg_node_t); + if (head->size < sizeof(H5FL_reg_node_t)) + head->size = sizeof(H5FL_reg_node_t); - /* Make certain there's room for tracking information, if any */ + /* Make certain there's room for tracking information, if any */ #ifdef H5FL_TRACK head->size += sizeof(H5FL_track_t); #endif /* H5FL_TRACK */ @@ -308,7 +306,6 @@ H5FL__reg_init(H5FL_reg_head_t *head) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__reg_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_free * @@ -324,7 +321,7 @@ H5FL__reg_init(H5FL_reg_head_t *head) void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj) { - void *ret_value=NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_reg_malloc/calloc * -NAF */ @@ -344,54 +341,53 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ #ifdef H5FL_DEBUG - HDmemset(obj,255,head->size); + HDmemset(obj, 255, head->size); #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ HDassert(head->init); /* Link into the free list */ - ((H5FL_reg_node_t *)obj)->next=head->list; + ((H5FL_reg_node_t *)obj)->next = head->list; /* Point free list at the node freed */ - head->list=(H5FL_reg_node_t *)obj; + head->list = (H5FL_reg_node_t *)obj; /* Increment the number of blocks on free list */ head->onlist++; /* Increment the amount of "regular" freed memory globally */ - H5FL_reg_gc_head.mem_freed+=head->size; + H5FL_reg_gc_head.mem_freed += head->size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->onlist * head->size > H5FL_reg_lst_mem_lim) - if(H5FL__reg_gc_list(head) < 0) + if (head->onlist * head->size > H5FL_reg_lst_mem_lim) + if (H5FL__reg_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on regular free lists */ - if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim) - if(H5FL__reg_gc() < 0) + if (H5FL_reg_gc_head.mem_freed > H5FL_reg_glb_mem_lim) + if (H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_free() */ +} /* end H5FL_reg_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_malloc * @@ -408,7 +404,7 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -416,27 +412,27 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__reg_init(head) < 0) + if (!head->init) + if (H5FL__reg_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'regular' blocks") /* Check for nodes available on the free list first */ - if(head->list!=NULL) { + if (head->list != NULL) { /* Get a pointer to the block on the free list */ - ret_value=(void *)(head->list); + ret_value = (void *)(head->list); /* Remove node from free list */ - head->list=head->list->next; + head->list = head->list->next; /* Decrement the number of blocks & memory on free list */ head->onlist--; /* Decrement the amount of global "regular" free list memory in use */ - H5FL_reg_gc_head.mem_freed-=(head->size); + H5FL_reg_gc_head.mem_freed -= (head->size); } /* end if */ /* Otherwise allocate a node */ else { - if(NULL == (ret_value = H5FL__malloc(head->size))) + if (NULL == (ret_value = H5FL__malloc(head->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ @@ -454,7 +450,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) /* 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) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -464,9 +460,8 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_malloc() */ +} /* end H5FL_reg_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_reg_calloc * @@ -483,7 +478,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -491,18 +486,17 @@ H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Allocate the block */ - if (NULL==(ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ /* (Accommodate tracking information, if present) */ - HDmemset(ret_value,0,head->size - H5FL_TRACK_SIZE); + HDmemset(ret_value, 0, head->size - H5FL_TRACK_SIZE); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_reg_calloc() */ +} /* end H5FL_reg_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_gc_list * @@ -525,8 +519,8 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) /* For each free list being garbage collected, walk through the nodes and free them */ free_list = head->list; - while(free_list != NULL) { - H5FL_reg_node_t *tmp; /* Temporary node pointer */ + while (free_list != NULL) { + H5FL_reg_node_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = free_list->next; @@ -545,13 +539,12 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) H5FL_reg_gc_head.mem_freed -= (head->onlist * head->size); /* Indicate no free nodes on the free list */ - head->list = NULL; + head->list = NULL; head->onlist = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__reg_gc_list() */ +} /* end H5FL__reg_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__reg_gc * @@ -568,16 +561,16 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head) static herr_t H5FL__reg_gc(void) { - H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_reg_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__reg_gc_list(gc_node->list) < 0) + if (H5FL__reg_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -589,9 +582,8 @@ H5FL__reg_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__reg_gc() */ +} /* end H5FL__reg_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL_reg_term @@ -602,7 +594,7 @@ H5FL__reg_gc(void) RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -620,26 +612,27 @@ H5FL__reg_gc(void) static int H5FL__reg_term(void) { - H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_reg_gc_head.first != NULL) { - H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_reg_gc_head.first != NULL) { + H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ /* Get a copy of the next node */ tmp = H5FL_reg_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, (int)H5FL_reg_gc_head.first->list->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.first->list->name, + (int)H5FL_reg_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ - if(H5FL_reg_gc_head.first->list->allocated > 0) { + if (H5FL_reg_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_reg_gc_head.first->next = left; - left = H5FL_reg_gc_head.first; + left = H5FL_reg_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -657,9 +650,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f H5FL_reg_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_reg_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__reg_term() */ +} /* end H5FL__reg_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_find_list * @@ -680,47 +672,46 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f static H5FL_blk_node_t * H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ + H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ FUNC_ENTER_STATIC_NOERR /* Find the correct free list */ - temp=*head; + temp = *head; /* Check if the node is at the head of the list */ - if(temp && temp->size!=size) { - temp=temp->next; + if (temp && temp->size != size) { + temp = temp->next; - while(temp!=NULL) { + while (temp != NULL) { /* Check if we found the correct node */ - if(temp->size==size) { + if (temp->size == size) { /* Take the node found out of it's current position */ - if(temp->next==NULL) { - temp->prev->next=NULL; + if (temp->next == NULL) { + temp->prev->next = NULL; } /* end if */ else { - temp->prev->next=temp->next; - temp->next->prev=temp->prev; + temp->prev->next = temp->next; + temp->next->prev = temp->prev; } /* end else */ /* Move the found node to the head of the list */ - temp->prev=NULL; - temp->next=*head; - (*head)->prev=temp; - *head=temp; + temp->prev = NULL; + temp->next = *head; + (*head)->prev = temp; + *head = temp; /* Get out */ break; } /* end if */ - temp=temp->next; + temp = temp->next; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(temp) } /* end H5FL__blk_find_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_create_list * @@ -739,31 +730,30 @@ H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size) static H5FL_blk_node_t * H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *ret_value = NULL; /* Return value */ + H5FL_blk_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate room for the new free list node */ - if(NULL == (ret_value = H5FL_CALLOC(H5FL_blk_node_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5FL_blk_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed for chunk info") /* Set the correct values for the new free list */ ret_value->size = size; /* Attach to head of priority queue */ - if(NULL == *head) + if (NULL == *head) *head = ret_value; else { ret_value->next = *head; - (*head)->prev = ret_value; - *head = ret_value; + (*head)->prev = ret_value; + *head = ret_value; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__blk_create_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_init * @@ -781,30 +771,29 @@ H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size) static herr_t H5FL__blk_init(H5FL_blk_head_t *head) { - H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_blk_gc_node_t *)H5MM_malloc(sizeof(H5FL_blk_gc_node_t)))) + if (NULL == (new_node = (H5FL_blk_gc_node_t *)H5MM_malloc(sizeof(H5FL_blk_gc_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->pq = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_blk_gc_head.first; - H5FL_blk_gc_head.first=new_node; + new_node->next = H5FL_blk_gc_head.first; + H5FL_blk_gc_head.first = new_node; /* Indicate that the PQ is initialized */ head->init = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__blk_init() */ +} /* end H5FL__blk_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_free_block_avail * @@ -822,8 +811,8 @@ H5FL__blk_init(H5FL_blk_head_t *head) htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - htri_t ret_value = FAIL; /* Return value */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -832,7 +821,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ - if((free_list = H5FL__blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL) + if ((free_list = H5FL__blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL) ret_value = TRUE; else ret_value = FALSE; @@ -840,7 +829,6 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free_block_avail() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_malloc * @@ -860,9 +848,9 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) void * 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 */ + 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 */ FUNC_ENTER_NOAPI(NULL) @@ -871,35 +859,36 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) HDassert(size); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__blk_init(head) < 0) + if (!head->init) + if (H5FL__blk_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'block' list") /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ - if(NULL != (free_list = H5FL__blk_find_list(&(head->head), size)) && NULL != free_list->list) { + if (NULL != (free_list = H5FL__blk_find_list(&(head->head), size)) && NULL != free_list->list) { /* Remove the first node from the free list */ - temp=free_list->list; - free_list->list=free_list->list->next; + temp = free_list->list; + free_list->list = free_list->list->next; /* Decrement the number of blocks & memory used on free list */ free_list->onlist--; head->onlist--; - head->list_mem-=size; + head->list_mem -= size; /* Decrement the amount of global "block" free list memory in use */ - H5FL_blk_gc_head.mem_freed-=size; + H5FL_blk_gc_head.mem_freed -= size; } /* end if */ /* No free list available, or there are no nodes on the list, allocate a new node to give to the user */ else { /* Check if there was no free list for native blocks of this size */ - if(NULL == free_list) + if (NULL == free_list) /* Create a new list node and insert it to the queue */ free_list = H5FL__blk_create_list(&(head->head), size); HDassert(free_list); /* Allocate new node, with room for the page info header and the actual page data */ - if(NULL == (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size))) + if (NULL == + (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk") /* Increment the number of blocks of this size */ @@ -910,10 +899,10 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) } /* end else */ /* Initialize the block allocated */ - temp->size=size; + temp->size = size; /* Set the return value to the block itself */ - ret_value=((char *)temp)+sizeof(H5FL_blk_list_t); + ret_value = ((char *)temp) + sizeof(H5FL_blk_list_t); #ifdef H5FL_TRACK /* Copy allocation location information */ @@ -926,7 +915,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) /* 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) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -938,7 +927,6 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_calloc * @@ -959,7 +947,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - 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) @@ -968,17 +956,16 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) HDassert(size); /* Allocate the block */ - if (NULL==(ret_value = H5FL_blk_malloc(head,size H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_blk_malloc(head, size H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear the block to zeros */ - HDmemset(ret_value,0,size); + HDmemset(ret_value, 0, size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_free * @@ -998,10 +985,10 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) void * 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 */ + 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 */ /* NOINIT OK here because this must be called after H5FL_blk_malloc/calloc * -NAF */ @@ -1021,37 +1008,40 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ /* Get the pointer to the native block info header in front of the native block to free */ - temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_blk_list_t *)(( + void *)((unsigned char *)block - + (sizeof(H5FL_blk_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Save the block's size for later */ - free_size=temp->size; + free_size = temp->size; #ifdef H5FL_DEBUG - HDmemset(temp,255,free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE); + HDmemset(temp, 255, free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE); #endif /* H5FL_DEBUG */ /* Check if there is a free list for native blocks of this size */ - if(NULL == (free_list = H5FL__blk_find_list(&(head->head), free_size))) + if (NULL == (free_list = H5FL__blk_find_list(&(head->head), free_size))) /* No free list available, create a new list node and insert it to the queue */ free_list = H5FL__blk_create_list(&(head->head), free_size); HDassert(free_list); /* Prepend the free'd native block to the front of the free list */ - temp->next = free_list->list; /* Note: Overwrites the size field in union */ + temp->next = free_list->list; /* Note: Overwrites the size field in union */ free_list->list = temp; /* Increment the number of blocks on free list */ @@ -1064,20 +1054,19 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem > H5FL_blk_lst_mem_lim) - if(H5FL__blk_gc_list(head) < 0) + if (head->list_mem > H5FL_blk_lst_mem_lim) + if (H5FL__blk_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on block free lists */ - if(H5FL_blk_gc_head.mem_freed > H5FL_blk_glb_mem_lim) - if(H5FL__blk_gc() < 0) + if (H5FL_blk_gc_head.mem_freed > H5FL_blk_glb_mem_lim) + if (H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_blk_realloc * @@ -1096,7 +1085,7 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS) { - void *ret_value=NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1105,21 +1094,24 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ HDassert(new_size); /* Check if we are actually re-allocating a block */ - if(block!=NULL) { - H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ + if (block != NULL) { + H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ /* Get the pointer to the chunk info header in front of the chunk to free */ - temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_blk_list_t *)(( + void *)((unsigned char *)block - + (sizeof(H5FL_blk_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* check if we are actually changing the size of the buffer */ - if(new_size!=temp->size) { - size_t blk_size; /* Temporary block size */ + if (new_size != temp->size) { + size_t blk_size; /* Temporary block size */ - if((ret_value=H5FL_blk_malloc(head,new_size H5FL_TRACK_INFO_INT))==NULL) + if ((ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block") - blk_size=MIN(new_size,temp->size); - H5MM_memcpy(ret_value,block,blk_size); - H5FL_blk_free(head,block); + blk_size = MIN(new_size, temp->size); + H5MM_memcpy(ret_value, block, blk_size); + H5FL_blk_free(head, block); } /* end if */ else { #ifdef H5FL_TRACK @@ -1139,18 +1131,17 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ trk->line = call_line; } #endif /* H5FL_TRACK */ - ret_value=block; + ret_value = block; } /* end if */ - } /* end if */ + } /* end if */ /* Not re-allocating, just allocate a fresh block */ else - ret_value=H5FL_blk_malloc(head,new_size H5FL_TRACK_INFO_INT); + ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_blk_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_gc_list * @@ -1167,23 +1158,23 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head) { - H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list page node */ + H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list page node */ FUNC_ENTER_STATIC_NOERR /* Loop through all the nodes in the block free list queue */ blk_head = head->head; - while(blk_head != NULL) { - H5FL_blk_node_t *blk_next; /* Temp. ptr to the next free list node */ - H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ + while (blk_head != NULL) { + H5FL_blk_node_t *blk_next; /* Temp. ptr to the next free list node */ + H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */ /* Sanity check */ HDassert((blk_head->onlist && blk_head->list) || (0 == blk_head->onlist && NULL == blk_head->list)); /* Loop through all the blocks in the free list, freeing them */ list = blk_head->list; - while(list != NULL) { - H5FL_blk_list_t *next; /* Temp. ptr to the free list list node */ + while (list != NULL) { + H5FL_blk_list_t *next; /* Temp. ptr to the free list list node */ /* Get the pointer to the next node */ next = list->next; @@ -1206,20 +1197,20 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) H5FL_blk_gc_head.mem_freed -= (blk_head->onlist * blk_head->size); /* Indicate no free nodes on the free list */ - blk_head->list = NULL; + blk_head->list = NULL; blk_head->onlist = 0; /* Get pointer to next node */ blk_next = blk_head->next; /* Check for list completely unused now */ - if(0 == blk_head->allocated) { + if (0 == blk_head->allocated) { /* Patch this node out of the PQ */ - if(head->head == blk_head) + if (head->head == blk_head) head->head = blk_head->next; - if(blk_head->prev) + if (blk_head->prev) blk_head->prev->next = blk_head->next; - if(blk_head->next) + if (blk_head->next) blk_head->next->prev = blk_head->prev; /* Free the free list node */ @@ -1237,9 +1228,8 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) HDassert(0 == head->list_mem); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__blk_gc_list() */ +} /* end H5FL__blk_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__blk_gc * @@ -1256,16 +1246,16 @@ H5FL__blk_gc_list(H5FL_blk_head_t *head) static herr_t H5FL__blk_gc(void) { - H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_blk_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* For each free list being garbage collected, walk through the nodes and free them */ - if(H5FL__blk_gc_list(gc_node->pq) < 0) + if (H5FL__blk_gc_list(gc_node->pq) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -1277,9 +1267,8 @@ H5FL__blk_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__blk_gc() */ +} /* end H5FL__blk_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL__blk_term @@ -1290,7 +1279,7 @@ H5FL__blk_gc(void) RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -1302,26 +1291,27 @@ H5FL__blk_gc(void) static int H5FL__blk_term(void) { - H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_blk_gc_head.first != NULL) { - H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_blk_gc_head.first != NULL) { + H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_blk_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, (int)H5FL_blk_gc_head.first->pq->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, + (int)H5FL_blk_gc_head.first->pq->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ - if(H5FL_blk_gc_head.first->pq->allocated > 0) { + if (H5FL_blk_gc_head.first->pq->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_blk_gc_head.first->next = left; - left = H5FL_blk_gc_head.first; + left = H5FL_blk_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -1339,9 +1329,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f H5FL_blk_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__blk_term() */ +} /* end H5FL__blk_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_init * @@ -1359,29 +1348,30 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f static herr_t H5FL__arr_init(H5FL_arr_head_t *head) { - H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ - size_t u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* return value*/ + H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_gc_arr_node_t *)H5MM_malloc(sizeof(H5FL_gc_arr_node_t)))) + if (NULL == (new_node = (H5FL_gc_arr_node_t *)H5MM_malloc(sizeof(H5FL_gc_arr_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = head; /* Link in to the garbage collection list */ - new_node->next=H5FL_arr_gc_head.first; - H5FL_arr_gc_head.first=new_node; + new_node->next = H5FL_arr_gc_head.first; + H5FL_arr_gc_head.first = new_node; /* Allocate room for the free lists */ - if(NULL == (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem * sizeof(H5FL_arr_node_t)))) + if (NULL == + (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem * sizeof(H5FL_arr_node_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the size of each array */ - for(u = 0; u < (size_t)head->maxelem; u++) + for (u = 0; u < (size_t)head->maxelem; u++) head->list_arr[u].size = head->base_size + (head->elem_size * u); /* Indicate that the free list is initialized */ @@ -1391,7 +1381,6 @@ H5FL__arr_init(H5FL_arr_head_t *head) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL__arr_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_free * @@ -1408,10 +1397,10 @@ H5FL__arr_init(H5FL_arr_head_t *head) void * 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 */ + 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 */ /* NOINIT OK here because this must be called after H5FL_arr_malloc/calloc * -NAF */ @@ -1419,7 +1408,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* The H5MM_xfree code allows obj to null */ if (!obj) - HGOTO_DONE (NULL) + HGOTO_DONE(NULL) /* Double check parameters */ HDassert(head); @@ -1428,46 +1417,47 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) HDassert(head->init); /* 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 */ + temp = (H5FL_arr_list_t *)(( + void *)((unsigned char *)obj - + sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Get the number of elements */ - free_nelem=temp->nelem; + free_nelem = temp->nelem; /* Double-check that there is enough room for arrays of this size */ - HDassert((int)free_nelem<=head->maxelem); + HDassert((int)free_nelem <= head->maxelem); /* Link into the free list */ - temp->next=head->list_arr[free_nelem].list; + temp->next = head->list_arr[free_nelem].list; /* Point free list at the node freed */ - head->list_arr[free_nelem].list=temp; + head->list_arr[free_nelem].list = temp; /* Get the size of arrays with this many elements */ - mem_size=head->list_arr[free_nelem].size; + mem_size = head->list_arr[free_nelem].size; /* Increment the number of blocks & memory used on free list */ head->list_arr[free_nelem].onlist++; - head->list_mem+=mem_size; + head->list_mem += mem_size; /* Increment the amount of "array" freed memory globally */ - H5FL_arr_gc_head.mem_freed+=mem_size; + H5FL_arr_gc_head.mem_freed += mem_size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem > H5FL_arr_lst_mem_lim) - if(H5FL__arr_gc_list(head) < 0) + if (head->list_mem > H5FL_arr_lst_mem_lim) + if (H5FL__arr_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on array free lists */ - if(H5FL_arr_gc_head.mem_freed > H5FL_arr_glb_mem_lim) - if(H5FL__arr_gc() < 0) + if (H5FL_arr_gc_head.mem_freed > H5FL_arr_glb_mem_lim) + if (H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_free() */ +} /* end H5FL_arr_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_malloc * @@ -1484,9 +1474,9 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { - 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 */ + 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 */ FUNC_ENTER_NOAPI(NULL) @@ -1495,35 +1485,35 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) HDassert(elem); /* Make certain the list is initialized first */ - if(!head->init) - if(H5FL__arr_init(head) < 0) + if (!head->init) + if (H5FL__arr_init(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks") /* Sanity check that the number of elements is supported */ - HDassert(elem<=(unsigned) head->maxelem); + HDassert(elem <= (unsigned)head->maxelem); /* Get the set of the memory block */ - mem_size=head->list_arr[elem].size; + mem_size = head->list_arr[elem].size; /* Check for nodes available on the free list first */ - if(head->list_arr[elem].list!=NULL) { + if (head->list_arr[elem].list != NULL) { /* Get a pointer to the block on the free list */ - new_obj=head->list_arr[elem].list; + new_obj = head->list_arr[elem].list; /* Remove node from free list */ - head->list_arr[elem].list=head->list_arr[elem].list->next; + head->list_arr[elem].list = head->list_arr[elem].list->next; /* Decrement the number of blocks & memory used on free list */ head->list_arr[elem].onlist--; - head->list_mem-=mem_size; + head->list_mem -= mem_size; /* Decrement the amount of global "array" free list memory in use */ - H5FL_arr_gc_head.mem_freed-=mem_size; + H5FL_arr_gc_head.mem_freed -= mem_size; } /* 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) + mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks of this size */ @@ -1534,16 +1524,15 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) } /* end else */ /* Initialize the new object */ - new_obj->nelem=elem; + new_obj->nelem = elem; /* Get a pointer to the new block */ - ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t); + ret_value = ((char *)new_obj) + sizeof(H5FL_arr_list_t); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_malloc() */ +} /* end H5FL_arr_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_calloc * @@ -1560,7 +1549,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1569,7 +1558,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))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ @@ -1577,9 +1566,8 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_calloc() */ +} /* end H5FL_arr_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_arr_realloc * @@ -1594,9 +1582,9 @@ 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) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1605,20 +1593,22 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) HDassert(new_elem); /* Check if we are really allocating the object */ - if(obj == NULL) + if (obj == NULL) ret_value = H5FL_arr_malloc(head, new_elem); else { - H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ + H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ /* Sanity check that the number of elements is supported */ HDassert((int)new_elem <= head->maxelem); /* Get the pointer to the info header in front of the block to free */ - temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + temp = (H5FL_arr_list_t *)(( + void *)((unsigned char *)obj - + sizeof(H5FL_arr_list_t))); /*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 */ + 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); @@ -1635,9 +1625,8 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) } /* end else */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_arr_realloc() */ +} /* end H5FL_arr_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_gc_list * @@ -1654,19 +1643,19 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head) { - unsigned u; /* Counter for array of free lists */ + unsigned u; /* Counter for array of free lists */ FUNC_ENTER_STATIC_NOERR /* Walk through the array of free lists */ - for(u = 0; u < (unsigned)head->maxelem; u++) { - if(head->list_arr[u].onlist > 0) { + for (u = 0; u < (unsigned)head->maxelem; u++) { + if (head->list_arr[u].onlist > 0) { H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ /* For each free list being garbage collected, walk through the nodes and free them */ arr_free_list = head->list_arr[u].list; - while(arr_free_list != NULL) { - H5FL_arr_list_t *tmp; /* Temporary node pointer */ + while (arr_free_list != NULL) { + H5FL_arr_list_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = arr_free_list->next; @@ -1689,18 +1678,17 @@ H5FL__arr_gc_list(H5FL_arr_head_t *head) H5FL_arr_gc_head.mem_freed -= (head->list_arr[u].onlist * head->list_arr[u].size); /* Indicate no free nodes on the free list */ - head->list_arr[u].list = NULL; + head->list_arr[u].list = NULL; head->list_arr[u].onlist = 0; } /* end if */ - } /* end for */ + } /* end for */ /* Double check that all the memory on this list is recycled */ HDassert(head->list_mem == 0); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__arr_gc_list() */ +} /* end H5FL__arr_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__arr_gc * @@ -1717,16 +1705,16 @@ H5FL__arr_gc_list(H5FL_arr_head_t *head) static herr_t H5FL__arr_gc(void) { - H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_STATIC /* Walk through all the free lists, free()'ing the nodes */ gc_arr_node = H5FL_arr_gc_head.first; - while(gc_arr_node != NULL) { + while (gc_arr_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__arr_gc_list(gc_arr_node->list) < 0) + if (H5FL__arr_gc_list(gc_arr_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -1738,9 +1726,8 @@ H5FL__arr_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__arr_gc() */ +} /* end H5FL__arr_gc() */ - /*-------------------------------------------------------------------------- NAME H5FL__arr_term @@ -1751,7 +1738,7 @@ H5FL__arr_gc(void) RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -1763,25 +1750,26 @@ H5FL__arr_gc(void) static int H5FL__arr_term(void) { - H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ + H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */ FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */ left = NULL; - while(H5FL_arr_gc_head.first != NULL) { - H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_arr_gc_head.first != NULL) { + H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_arr_gc_head.first->next; /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG -HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, (int)H5FL_arr_gc_head.first->list->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, + (int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ - if(H5FL_arr_gc_head.first->list->allocated > 0) { + if (H5FL_arr_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ H5FL_arr_gc_head.first->next = left; - left = H5FL_arr_gc_head.first; + left = H5FL_arr_gc_head.first; } /* end if */ /* No allocations left open for list, get rid of it */ else { @@ -1802,9 +1790,8 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.f H5FL_arr_gc_head.first = left; FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first != NULL ? 1 : 0) -} /* end H5FL__arr_term() */ +} /* end H5FL__arr_term() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_free * @@ -1833,12 +1820,11 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) HDassert(head->queue.init); /* Use block routine */ - H5FL_blk_free(&(head->queue),obj); + H5FL_blk_free(&(head->queue), obj); FUNC_LEAVE_NOAPI(NULL) -} /* end H5FL_seq_free() */ +} /* end H5FL_seq_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_malloc * @@ -1855,7 +1841,7 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1867,9 +1853,8 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) ret_value = H5FL_blk_malloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_malloc() */ +} /* end H5FL_seq_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_calloc * @@ -1886,7 +1871,7 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1898,9 +1883,8 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) ret_value = H5FL_blk_calloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_calloc() */ +} /* end H5FL_seq_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_seq_realloc * @@ -1915,9 +1899,9 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) *------------------------------------------------------------------------- */ void * -H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_PARAMS) +H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI_NOERR @@ -1929,9 +1913,8 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P ret_value = H5FL_blk_realloc(&(head->queue), obj, head->size * new_elem H5FL_TRACK_INFO_INT); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_seq_realloc() */ +} /* end H5FL_seq_realloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_init * @@ -1948,9 +1931,9 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P 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_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 */ FUNC_ENTER_NOAPI(NULL) @@ -1958,31 +1941,31 @@ H5FL_fac_init(size_t size) HDassert(size > 0); /* Allocate room for the new factory */ - if(NULL == (factory = (H5FL_fac_head_t *)H5FL_CALLOC(H5FL_fac_head_t))) + if (NULL == (factory = (H5FL_fac_head_t *)H5FL_CALLOC(H5FL_fac_head_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for factory object") /* Set size of blocks for factory */ factory->size = size; /* Allocate a new garbage collection node */ - if(NULL == (new_node = (H5FL_fac_gc_node_t *)H5FL_MALLOC(H5FL_fac_gc_node_t))) + if (NULL == (new_node = (H5FL_fac_gc_node_t *)H5FL_MALLOC(H5FL_fac_gc_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize the new garbage collection node */ new_node->list = factory; /* Link in to the garbage collection list */ - new_node->next = H5FL_fac_gc_head.first; + new_node->next = H5FL_fac_gc_head.first; H5FL_fac_gc_head.first = new_node; - if(new_node->next) - new_node->next->list->prev_gc=new_node; + if (new_node->next) + new_node->next->list->prev_gc = new_node; /* The new factory's prev_gc field will be set to NULL */ /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ - if(factory->size < sizeof(H5FL_fac_node_t)) + if (factory->size < sizeof(H5FL_fac_node_t)) factory->size = sizeof(H5FL_fac_node_t); - /* Make certain there's room for tracking information, if any */ + /* Make certain there's room for tracking information, if any */ #ifdef H5FL_TRACK factory->size += sizeof(H5FL_track_t); #endif /* H5FL_TRACK */ @@ -1994,17 +1977,16 @@ H5FL_fac_init(size_t size) ret_value = factory; done: - if(!ret_value) { - if(factory) + if (!ret_value) { + if (factory) factory = H5FL_FREE(H5FL_fac_head_t, factory); - if(new_node) + if (new_node) new_node = H5FL_FREE(H5FL_fac_gc_node_t, new_node); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_init() */ +} /* end H5FL_fac_init() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_free * @@ -2020,7 +2002,7 @@ H5FL_fac_init(size_t size) void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2039,21 +2021,21 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) trk->func = H5MM_xfree(trk->func); /* Remove from "outstanding allocations" list */ - if(trk == H5FL_out_head_g) { + if (trk == H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; - if(H5FL_out_head_g) + if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { trk->prev->next = trk->next; - if(trk->next) + if (trk->next) trk->next->prev = trk->prev; } /* end else */ } #endif /* H5FL_TRACK */ #ifdef H5FL_DEBUG - HDmemset(obj,255,head->size); + HDmemset(obj, 255, head->size); #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ @@ -2073,20 +2055,19 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->onlist * head->size > H5FL_fac_lst_mem_lim) - if(H5FL__fac_gc_list(head) < 0) + if (head->onlist * head->size > H5FL_fac_lst_mem_lim) + if (H5FL__fac_gc_list(head) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") /* Then check the global amount memory on factory free lists */ - if(H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) - if(H5FL__fac_gc() < 0) + if (H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) + if (H5FL__fac_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_free() */ +} /* end H5FL_fac_free() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_malloc * @@ -2103,7 +2084,7 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2113,22 +2094,22 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) HDassert(head->init); /* Check for nodes available on the free list first */ - if(head->list!=NULL) { + if (head->list != NULL) { /* Get a pointer to the block on the free list */ - ret_value=(void *)(head->list); + ret_value = (void *)(head->list); /* Remove node from free list */ - head->list=head->list->next; + head->list = head->list->next; /* Decrement the number of blocks & memory on free list */ head->onlist--; /* Decrement the amount of global "factory" free list memory in use */ - H5FL_fac_gc_head.mem_freed-=(head->size); + H5FL_fac_gc_head.mem_freed -= (head->size); } /* end if */ /* Otherwise allocate a node */ else { - if(NULL == (ret_value = H5FL__malloc(head->size))) + if (NULL == (ret_value = H5FL__malloc(head->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks allocated in list */ @@ -2146,7 +2127,7 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) /* 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) + if (H5FL_out_head_g) H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; H5FL_out_head_g = (H5FL_track_t *)ret_value; @@ -2156,9 +2137,8 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_malloc() */ +} /* end H5FL_fac_malloc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_calloc * @@ -2175,7 +2155,7 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2184,18 +2164,17 @@ H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) HDassert(head); /* Allocate the block */ - if (NULL==(ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT))) + if (NULL == (ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ /* (Accommodate tracking information, if present) */ - HDmemset(ret_value,0,head->size - H5FL_TRACK_SIZE); + HDmemset(ret_value, 0, head->size - H5FL_TRACK_SIZE); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_calloc() */ +} /* end H5FL_fac_calloc() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_gc_list * @@ -2218,8 +2197,8 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) /* For each free list being garbage collected, walk through the nodes and free them */ free_list = head->list; - while(free_list != NULL) { - H5FL_fac_node_t *tmp; /* Temporary node pointer */ + while (free_list != NULL) { + H5FL_fac_node_t *tmp; /* Temporary node pointer */ /* Get the pointer to the next node */ tmp = free_list->next; @@ -2238,13 +2217,12 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) H5FL_fac_gc_head.mem_freed -= (head->onlist * head->size); /* Indicate no free nodes on the free list */ - head->list = NULL; + head->list = NULL; head->onlist = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FL__fac_gc_list() */ +} /* end H5FL__fac_gc_list() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_gc * @@ -2261,16 +2239,16 @@ H5FL__fac_gc_list(H5FL_fac_head_t *head) static herr_t H5FL__fac_gc(void) { - H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ - herr_t ret_value = SUCCEED; /* return value*/ + H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value = SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT /* Walk through all the free lists, free()'ing the nodes */ gc_node = H5FL_fac_gc_head.first; - while(gc_node != NULL) { + while (gc_node != NULL) { /* Release the free nodes on the list */ - if(H5FL__fac_gc_list(gc_node->list) < 0) + if (H5FL__fac_gc_list(gc_node->list) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") /* Go on to the next free list to garbage collect */ @@ -2282,9 +2260,8 @@ H5FL__fac_gc(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL__fac_gc() */ +} /* end H5FL__fac_gc() */ - /*------------------------------------------------------------------------- * Function: H5FL_fac_term * @@ -2301,8 +2278,8 @@ H5FL__fac_gc(void) herr_t H5FL_fac_term(H5FL_fac_head_t *factory) { - H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + herr_t ret_value = SUCCEED; /* Return value */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2311,29 +2288,31 @@ H5FL_fac_term(H5FL_fac_head_t *factory) HDassert(factory); /* Garbage collect all the blocks in the factory's free list */ - if(H5FL__fac_gc_list(factory) < 0) + if (H5FL__fac_gc_list(factory) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of factory failed") /* Verify that all the blocks have been freed */ - if(factory->allocated > 0) + if (factory->allocated > 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "factory still has objects allocated") /* Unlink block free list for factory from global free list */ - if(factory->prev_gc) { - H5FL_fac_gc_node_t *last = factory->prev_gc; /* Garbage collection node before the one being removed */ + if (factory->prev_gc) { + H5FL_fac_gc_node_t *last = + factory->prev_gc; /* Garbage collection node before the one being removed */ HDassert(last->next->list == factory); - tmp = last->next->next; + tmp = last->next->next; last->next = H5FL_FREE(H5FL_fac_gc_node_t, last->next); last->next = tmp; - if(tmp) + if (tmp) tmp->list->prev_gc = last; - } else { + } + else { HDassert(H5FL_fac_gc_head.first->list == factory); - tmp = H5FL_fac_gc_head.first->next; + tmp = H5FL_fac_gc_head.first->next; H5FL_fac_gc_head.first = H5FL_FREE(H5FL_fac_gc_node_t, H5FL_fac_gc_head.first); H5FL_fac_gc_head.first = tmp; - if(tmp) + if (tmp) tmp->list->prev_gc = NULL; } /* end else */ @@ -2342,9 +2321,8 @@ H5FL_fac_term(H5FL_fac_head_t *factory) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_fac_term() */ +} /* end H5FL_fac_term() */ - /*------------------------------------------------------------------------- * Function: H5FL__fac_term_all * @@ -2364,13 +2342,14 @@ H5FL__fac_term_all(void) FUNC_ENTER_STATIC_NOERR /* Free the nodes on the garbage collection list */ - while(H5FL_fac_gc_head.first != NULL) { - H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + while (H5FL_fac_gc_head.first != NULL) { + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ tmp = H5FL_fac_gc_head.first->next; #ifdef H5FL_DEBUG -HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, (int)H5FL_fac_gc_head.first->list->allocated); + HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_head.first->list->size, + (int)H5FL_fac_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ /* The list cannot have any allocations outstanding */ @@ -2386,9 +2365,8 @@ HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_h } /* end while */ FUNC_LEAVE_NOAPI(0) -} /* end H5FL__fac_term_all() */ +} /* end H5FL__fac_term_all() */ - /*------------------------------------------------------------------------- * Function: H5FL_garbage_coll * @@ -2405,31 +2383,30 @@ HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_h herr_t H5FL_garbage_coll(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Garbage collect the free lists for array objects */ - if(H5FL__arr_gc() < 0) + if (H5FL__arr_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect array objects") /* Garbage collect free lists for blocks */ - if(H5FL__blk_gc() < 0) + if (H5FL__blk_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect block objects") /* Garbage collect the free lists for regular objects */ - if(H5FL__reg_gc() < 0) + if (H5FL__reg_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") /* Garbage collect the free lists for factory objects */ - if(H5FL__fac_gc() < 0) + if (H5FL__fac_gc() < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect factory objects") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_garbage_coll() */ +} /* end H5FL_garbage_coll() */ - /*------------------------------------------------------------------------- * Function: H5FL_set_free_list_limits * @@ -2458,11 +2435,10 @@ H5FL_garbage_coll(void) *------------------------------------------------------------------------- */ herr_t -H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, - int arr_list_lim, int blk_global_lim, int blk_list_lim, int fac_global_lim, - int fac_list_lim) +H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, + int blk_global_lim, int blk_list_lim, int fac_global_lim, int fac_list_lim) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -2485,9 +2461,8 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l H5FL_fac_lst_mem_lim = (fac_list_lim == -1 ? UINT_MAX : (size_t)fac_list_lim); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FL_set_free_list_limits() */ +} /* end H5FL_set_free_list_limits() */ - /*------------------------------------------------------------------------- * Function: H5FL_get_free_list_sizes * @@ -2511,20 +2486,19 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l *------------------------------------------------------------------------- */ herr_t -H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, - size_t *fac_size) +H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size) { FUNC_ENTER_NOAPI_NOERR /* Retrieve the amount of "regular" memory used */ - if(reg_size) { - H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of lists */ + if (reg_size) { + H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of lists */ /* Walk through all the free lists, counting the amount of memory */ *reg_size = 0; - gc_node = H5FL_reg_gc_head.first; - while(gc_node != NULL) { - H5FL_reg_head_t *reg_list = gc_node->list; /* Head of list */ + gc_node = H5FL_reg_gc_head.first; + while (gc_node != NULL) { + H5FL_reg_head_t *reg_list = gc_node->list; /* Head of list */ /* Sanity check */ HDassert(reg_list->init); @@ -2535,27 +2509,27 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_node = gc_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "array" memory used */ - if(arr_size) { - H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ + if (arr_size) { + H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */ /* Walk through all the free lists, counting the amount of memory */ - *arr_size = 0; + *arr_size = 0; gc_arr_node = H5FL_arr_gc_head.first; - while(gc_arr_node != NULL) { - H5FL_arr_head_t *head = gc_arr_node->list; /* Head of array list elements */ + while (gc_arr_node != NULL) { + H5FL_arr_head_t *head = gc_arr_node->list; /* Head of array list elements */ /* Sanity check */ HDassert(head->init); /* Check for any allocated elements in this list */ - if(head->allocated > 0) { + if (head->allocated > 0) { unsigned u; /* Walk through the free lists for array sizes */ - for(u = 0; u < (unsigned)head->maxelem; u++) + for (u = 0; u < (unsigned)head->maxelem; u++) /* Add the amount of memory for this size */ *arr_size += head->list_arr[u].allocated * head->list_arr[u].size; } /* end if */ @@ -2563,21 +2537,21 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_arr_node = gc_arr_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "block" memory used */ - if(blk_size) { - H5FL_blk_gc_node_t *gc_blk_node; /* Pointer into the list of things */ + if (blk_size) { + H5FL_blk_gc_node_t *gc_blk_node; /* Pointer into the list of things */ /* Walk through all the free lists */ gc_blk_node = H5FL_blk_gc_head.first; - *blk_size = 0; - while(gc_blk_node != NULL) { - H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list block node */ + *blk_size = 0; + while (gc_blk_node != NULL) { + H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list block node */ /* Loop through all the nodes in the block free list queue */ blk_head = gc_blk_node->pq->head; - while(blk_head != NULL) { + while (blk_head != NULL) { /* Add size of blocks on this list */ *blk_size += (blk_head->allocated * blk_head->size); @@ -2588,17 +2562,17 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list */ gc_blk_node = gc_blk_node->next; } /* end while */ - } /* end if */ + } /* end if */ /* Retrieve the amount of "factory" memory used */ - if(fac_size) { - H5FL_fac_gc_node_t *gc_fac_node; /* Pointer into the list of things to garbage collect */ + if (fac_size) { + H5FL_fac_gc_node_t *gc_fac_node; /* Pointer into the list of things to garbage collect */ /* Walk through all the free lists */ gc_fac_node = H5FL_fac_gc_head.first; - *fac_size = 0; - while(gc_fac_node != NULL) { - H5FL_fac_head_t *fac_head = gc_fac_node->list; /* Head node for factory list */ + *fac_size = 0; + while (gc_fac_node != NULL) { + H5FL_fac_head_t *fac_head = gc_fac_node->list; /* Head node for factory list */ /* Add size of blocks on this list */ *fac_size += (fac_head->allocated * fac_head->size); @@ -2606,8 +2580,7 @@ H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, /* Go on to the next free list to garbage collect */ gc_fac_node = gc_fac_node->next; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_get_free_list_sizes() */ - diff --git a/src/H5FLmodule.h b/src/H5FLmodule.h index dbce75c792b..95c0b49aade 100644 --- a/src/H5FLmodule.h +++ b/src/H5FLmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5FL package. Including this header means that the source file * is part of the H5FL package. */ -#ifndef _H5FLmodule_H -#define _H5FLmodule_H +#ifndef H5FLmodule_H +#define H5FLmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5FL_MODULE -#define H5_MY_PKG H5FL -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO - -#endif /* _H5FLmodule_H */ +#define H5_MY_PKG H5FL +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO +#endif /* H5FLmodule_H */ diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index a2c019a4a9c..42581acb7cc 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,13 +21,13 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5FLprivate_H -#define _H5FLprivate_H +#ifndef H5FLprivate_H +#define H5FLprivate_H /* Public headers needed by this file */ #ifdef LATER -#include "H5FLpublic.h" /*API prototypes */ -#endif /* LATER */ +#include "H5FLpublic.h" /*API prototypes */ +#endif /* LATER */ /* Private headers needed by this file */ @@ -51,23 +51,23 @@ /* #define H5FL_TRACK */ #ifdef H5FL_TRACK /* Macro for inclusion in the free list allocation calls */ -#define H5FL_TRACK_INFO ,__FILE__, FUNC, __LINE__ +#define H5FL_TRACK_INFO , __FILE__, FUNC, __LINE__ /* Macro for inclusion in internal free list allocation calls */ -#define H5FL_TRACK_INFO_INT ,call_file, call_func, call_line +#define H5FL_TRACK_INFO_INT , call_file, call_func, call_line /* Macro for inclusion in the free list allocation parameters */ -#define H5FL_TRACK_PARAMS ,const char *call_file, const char *call_func, int call_line +#define H5FL_TRACK_PARAMS , const char *call_file, const char *call_func, int call_line /* Forward declarations for structure fields */ 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 */ - int line; /* Line # within 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 */ } H5FL_track_t; @@ -79,7 +79,7 @@ typedef struct H5FL_track_t { #define H5FL_TRACK_INFO #define H5FL_TRACK_INFO_INT #define H5FL_TRACK_PARAMS -#define H5FL_TRACK_SIZE 0 +#define H5FL_TRACK_SIZE 0 #endif /* H5FL_TRACK */ /* @@ -88,44 +88,44 @@ typedef struct H5FL_track_t { /* Data structure to store each block in free list */ typedef struct H5FL_reg_node_t { - struct H5FL_reg_node_t *next; /* Pointer to next block in free list */ + struct H5FL_reg_node_t *next; /* Pointer to next block in free list */ } H5FL_reg_node_t; /* Data structure for free list of blocks */ 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 */ - size_t size; /* Size of the blocks in the list */ - H5FL_reg_node_t *list; /* List of free blocks */ + 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 */ + size_t size; /* Size of the blocks in the list */ + H5FL_reg_node_t *list; /* List of free blocks */ } H5FL_reg_head_t; /* * Macros for defining & using free lists for a type */ -#define H5FL_REG_NAME(t) H5_##t##_reg_free_list +#define H5FL_REG_NAME(t) H5_##t##_reg_free_list #ifndef H5_NO_REG_FREE_LISTS /* Common macros for H5FL_DEFINE & H5FL_DEFINE_STATIC */ -#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,#t,sizeof(t),NULL} +#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t) = {0, 0, 0, #t, sizeof(t), NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ -#define H5FL_EXTERN(t) H5_DLLVAR H5FL_reg_head_t H5FL_REG_NAME(t) +#define H5FL_EXTERN(t) H5_DLLVAR H5FL_reg_head_t H5FL_REG_NAME(t) /* Declare a static free list to manage objects of type 't' */ -#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) +#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) /* Allocate an object of type 't' */ -#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO) /* Allocate an object of type 't' and clear it to all zeros */ -#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO) +#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO) /* Free an object of type 't' */ -#define H5FL_FREE(t,obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)),obj) +#define H5FL_FREE(t, obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)), obj) /* Re-allocating an object of type 't' is not defined, because these free-lists * only support fixed sized types, like structs, etc.. @@ -136,171 +136,173 @@ typedef struct H5FL_reg_head_t { /* Common macro for H5FL_DEFINE & H5FL_DEFINE_STATIC */ #define H5FL_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_REG_NAME(t) -#define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) -#define H5FL_EXTERN(t) H5_DLLVAR H5FL_DEFINE_COMMON(t) -#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) -#define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t)) -#define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t)) -#define H5FL_FREE(t,obj) (t *)H5MM_xfree(obj) +#define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) +#define H5FL_EXTERN(t) H5_DLLVAR H5FL_DEFINE_COMMON(t) +#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t) +#define H5FL_MALLOC(t) (t *)H5MM_malloc(sizeof(t)) +#define H5FL_CALLOC(t) (t *)H5MM_calloc(sizeof(t)) +#define H5FL_FREE(t, obj) (t *)H5MM_xfree(obj) #endif /* H5_NO_REG_FREE_LISTS */ /* Data structure to store information about each block allocated */ 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 */ + 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 */ } H5FL_blk_list_t; /* Data structure for priority queue node of block free lists */ 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 */ - 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 */ + 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 */ + 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; /* Data structure for priority queue of native block free lists */ typedef struct H5FL_blk_head_t { - hbool_t init; /* Whether the free list has been initialized */ - 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 */ - H5FL_blk_node_t *head; /* Pointer to first free list in queue */ + hbool_t init; /* Whether the free list has been initialized */ + 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 */ + H5FL_blk_node_t *head; /* Pointer to first free list in queue */ } H5FL_blk_head_t; /* * Macros for defining & using priority queues */ -#define H5FL_BLK_NAME(t) H5_##t##_blk_free_list +#define H5FL_BLK_NAME(t) H5_##t##_blk_free_list #ifndef H5_NO_BLK_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ -#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL} +#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t) = {0, 0, 0, 0, #t "_blk", NULL} /* Declare a free list to manage objects of type 't' */ -#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) /* Reference a free list for type 't' defined in another file */ -#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_blk_head_t H5FL_BLK_NAME(t) +#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_blk_head_t H5FL_BLK_NAME(t) /* Declare a static free list to manage objects of type 't' */ -#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) /* Allocate a block of type 't' */ -#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO) /* Allocate a block of type 't' and clear it to zeros */ -#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)),size H5FL_TRACK_INFO) +#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO) /* Free a block of type 't' */ -#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)),blk) +#define H5FL_BLK_FREE(t, blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)), blk) /* Re-allocate a block of type 't' */ -#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)),blk,new_size H5FL_TRACK_INFO) +#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 */ -#define H5FL_BLK_AVAIL(t,size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)),size) +#define H5FL_BLK_AVAIL(t, size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)), size) #else /* H5_NO_BLK_FREE_LISTS */ /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ #define H5FL_BLK_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_BLK_NAME(t) -#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) -#define H5FL_BLK_MALLOC(t,size) (uint8_t *)H5MM_malloc(size) -#define H5FL_BLK_CALLOC(t,size) (uint8_t *)H5MM_calloc(size) -#define H5FL_BLK_FREE(t,blk) (uint8_t *)H5MM_xfree(blk) -#define H5FL_BLK_REALLOC(t,blk,new_size) (uint8_t *)H5MM_realloc(blk,new_size) -#define H5FL_BLK_AVAIL(t,size) (FALSE) +#define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_EXTERN(t) H5_DLLVAR H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t) +#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5MM_malloc(size) +#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5MM_calloc(size) +#define H5FL_BLK_FREE(t, blk) (uint8_t *)H5MM_xfree(blk) +#define H5FL_BLK_REALLOC(t, blk, new_size) (uint8_t *)H5MM_realloc(blk, new_size) +#define H5FL_BLK_AVAIL(t, size) (FALSE) #endif /* H5_NO_BLK_FREE_LISTS */ /* Data structure to store each array in free list */ 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 */ + 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 */ } H5FL_arr_list_t; /* Data structure for each size of array element */ typedef struct H5FL_arr_node_t { size_t size; /* Size of the blocks in the list (in bytes) */ /* (Note: base_size + <# of elem> * elem_size) */ - unsigned allocated; /* Number of blocks allocated of this element size */ - unsigned onlist; /* Number of blocks on free list */ + unsigned allocated; /* Number of blocks allocated of this element size */ + unsigned onlist; /* Number of blocks on free list */ H5FL_arr_list_t *list; /* List of free blocks */ } H5FL_arr_node_t; /* Data structure for free list of array blocks */ 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 */ - 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 */ + 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 */ + 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 */ H5FL_arr_node_t *list_arr; /* Array of lists of free blocks */ } H5FL_arr_head_t; /* * Macros for defining & using free lists for an array of a type */ -#define H5FL_ARR_NAME(t) H5_##t##_arr_free_list +#define H5FL_ARR_NAME(t) H5_##t##_arr_free_list #ifndef H5_NO_ARR_FREE_LISTS /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */ -#define H5FL_ARR_DEFINE_COMMON(b,t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,b,sizeof(t),NULL} +#define H5FL_ARR_DEFINE_COMMON(b, t, m) \ + H5FL_arr_head_t H5FL_ARR_NAME(t) = {0, 0, 0, #t "_arr", m + 1, b, sizeof(t), NULL} /* Declare a free list to manage arrays of type 't' */ -#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(0,t,m) +#define H5FL_ARR_DEFINE(t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(0, t, m) /* Declare a free list to manage base 'b' + arrays of type 't' */ -#define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) +#define H5FL_BARR_DEFINE(b, t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m) /* Reference a free list for arrays of type 't' defined in another file */ -#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_arr_head_t H5FL_ARR_NAME(t) +#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_arr_head_t H5FL_ARR_NAME(t) /* Declare a static free list to manage arrays of type 't' */ -#define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(0,t,m) +#define H5FL_ARR_DEFINE_STATIC(t, m) static H5FL_ARR_DEFINE_COMMON(0, t, m) /* Declare a static free list to manage base 'b' + arrays of type 't' */ -#define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(sizeof(b),t,m) +#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) /* 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) /* Free an array of type 't' */ -#define H5FL_ARR_FREE(t,obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)),obj) +#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) #else /* H5_NO_ARR_FREE_LISTS */ /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */ -#define H5FL_ARR_DEFINE_COMMON(t,m) size_t H5FL_ARR_NAME(t) - -#define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = 0 -#define H5FL_BARR_DEFINE(b,t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) -#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_ARR_DEFINE_COMMON(t,m) -#define H5FL_ARR_DEFINE_STATIC(t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = 0 -#define H5FL_BARR_DEFINE_STATIC(b,t,m) static H5FL_ARR_DEFINE_COMMON(t,m) = sizeof(b) -#define H5FL_ARR_MALLOC(t,elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) -#define H5FL_ARR_CALLOC(t,elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem)*sizeof(t))) -#define H5FL_ARR_FREE(t,obj) (t *)H5MM_xfree(obj) -#define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,H5FL_ARR_NAME(t) + ((new_elem)*sizeof(t))) +#define H5FL_ARR_DEFINE_COMMON(t, m) size_t H5FL_ARR_NAME(t) + +#define H5FL_ARR_DEFINE(t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(t, m) = 0 +#define H5FL_BARR_DEFINE(b, t, m) H5_DLL H5FL_ARR_DEFINE_COMMON(t, m) = sizeof(b) +#define H5FL_ARR_EXTERN(t) H5_DLLVAR H5FL_ARR_DEFINE_COMMON(t, m) +#define H5FL_ARR_DEFINE_STATIC(t, m) static H5FL_ARR_DEFINE_COMMON(t, m) = 0 +#define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(t, m) = sizeof(b) +#define H5FL_ARR_MALLOC(t, elem) H5MM_malloc(H5FL_ARR_NAME(t) + ((elem) * sizeof(t))) +#define H5FL_ARR_CALLOC(t, elem) H5MM_calloc(H5FL_ARR_NAME(t) + ((elem) * sizeof(t))) +#define H5FL_ARR_FREE(t, obj) (t *)H5MM_xfree(obj) +#define H5FL_ARR_REALLOC(t, obj, new_elem) H5MM_realloc(obj, H5FL_ARR_NAME(t) + ((new_elem) * sizeof(t))) #endif /* H5_NO_ARR_FREE_LISTS */ /* Data structure for free list of sequence blocks */ typedef struct H5FL_seq_head_t { - H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ - size_t size; /* Size of the sequence elements in the list */ + H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ + size_t size; /* Size of the sequence elements in the list */ } H5FL_seq_head_t; /* @@ -309,60 +311,61 @@ typedef struct H5FL_seq_head_t { * Sequences are like arrays, except they have no upper limit. * */ -#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list +#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list #ifndef H5_NO_SEQ_FREE_LISTS /* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ -#define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)} +#define H5FL_SEQ_DEFINE_COMMON(t) \ + H5FL_seq_head_t H5FL_SEQ_NAME(t) = {{0, 0, 0, 0, #t "_seq", NULL}, sizeof(t)} /* Declare a free list to manage sequences of type 't' */ -#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) /* Reference a free list for sequences of type 't' defined in another file */ -#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_seq_head_t H5FL_SEQ_NAME(t) +#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_seq_head_t H5FL_SEQ_NAME(t) /* Declare a static free list to manage sequences of type 't' */ -#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) /* Allocate a sequence of type 't' */ -#define H5FL_SEQ_MALLOC(t,elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_MALLOC(t, elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO) /* Allocate a sequence of type 't' and clear it to all zeros */ -#define H5FL_SEQ_CALLOC(t,elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO) +#define H5FL_SEQ_CALLOC(t, elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO) /* Free a sequence of type 't' */ -#define H5FL_SEQ_FREE(t,obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj) +#define H5FL_SEQ_FREE(t, obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)), obj) /* Re-allocate a sequence of type 't' */ -#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO) +#define H5FL_SEQ_REALLOC(t, obj, new_elem) \ + (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)), obj, new_elem H5FL_TRACK_INFO) #else /* H5_NO_SEQ_FREE_LISTS */ /* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ #define H5FL_SEQ_DEFINE_COMMON(t) int H5_ATTR_UNUSED H5FL_SEQ_NAME(t) -#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) -#define H5FL_SEQ_MALLOC(t,elem) (t *)H5MM_malloc((elem)*sizeof(t)) -#define H5FL_SEQ_CALLOC(t,elem) (t *)H5MM_calloc((elem)*sizeof(t)) -#define H5FL_SEQ_FREE(t,obj) (t *)H5MM_xfree(obj) -#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t)) +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_EXTERN(t) H5_DLLVAR H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_MALLOC(t, elem) (t *)H5MM_malloc((elem) * sizeof(t)) +#define H5FL_SEQ_CALLOC(t, elem) (t *)H5MM_calloc((elem) * sizeof(t)) +#define H5FL_SEQ_FREE(t, obj) (t *)H5MM_xfree(obj) +#define H5FL_SEQ_REALLOC(t, obj, new_elem) (t *)H5MM_realloc(obj, (new_elem) * sizeof(t)) #endif /* H5_NO_SEQ_FREE_LISTS */ /* Forward declarations of the data structures for free list block factory */ typedef struct H5FL_fac_gc_node_t H5FL_fac_gc_node_t; -typedef struct H5FL_fac_node_t H5FL_fac_node_t; +typedef struct H5FL_fac_node_t H5FL_fac_node_t; /* Data structure for free list block factory */ typedef struct H5FL_fac_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 */ - size_t size; /* Size of the blocks in the list */ - H5FL_fac_node_t *list; /* List of free blocks */ - H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ + hbool_t init; /* Whether the free list has been initialized */ + unsigned allocated; /* Number of blocks allocated */ + unsigned onlist; /* Number of blocks on free list */ + size_t size; /* Size of the blocks in the list */ + H5FL_fac_node_t * list; /* List of free blocks */ + H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ } H5FL_fac_head_t; - /* * Macros for defining & using free list factories * @@ -381,15 +384,15 @@ typedef struct H5FL_fac_head_t { #define H5FL_FAC_FREE(f, obj) H5FL_fac_free(f, obj) #else /* H5_NO_FAC_FREE_LISTS */ -#define H5FL_FAC_MALLOC(f) H5MM_malloc(f->size) -#define H5FL_FAC_CALLOC(f) H5MM_calloc(f->size) +#define H5FL_FAC_MALLOC(f) H5MM_malloc(f->size) +#define H5FL_FAC_CALLOC(f) H5MM_calloc(f->size) #define H5FL_FAC_FREE(f, obj) H5MM_xfree(obj) #endif /* H5_NO_FAC_FREE_LISTS */ /* * Library prototypes. */ - /* Block free lists */ +/* 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); @@ -397,36 +400,36 @@ H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_si H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size); /* Regular free lists */ -H5_DLL void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj); +H5_DLL void *H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_reg_free(H5FL_reg_head_t *head, void *obj); /* Array free lists */ -H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); -H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); -H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); -H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); +H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); +H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); +H5_DLL void *H5FL_arr_free(H5FL_arr_head_t *head, void *obj); +H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); /* Sequence free lists */ -H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj); -H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_seq_free(H5FL_seq_head_t *head, void *obj); +H5_DLL void *H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); /* Factory free lists */ H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size); -H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); -H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); +H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); +H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); /* General free list routines */ H5_DLL herr_t H5FL_garbage_coll(void); -H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim, - int fac_global_lim, int fac_list_lim); -H5_DLL herr_t H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, - size_t *blk_size, size_t *fac_size); -H5_DLL int H5FL_term_interface(void); +H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, + int arr_list_lim, int blk_global_lim, int blk_list_lim, + int fac_global_lim, int fac_list_lim); +H5_DLL herr_t H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, + size_t *fac_size); +H5_DLL int H5FL_term_interface(void); #endif diff --git a/src/H5FO.c b/src/H5FO.c index 7bbf7fac0ad..441d2847b7d 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,28 +19,27 @@ * */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Oprivate.h" /* Object headers */ /* Private typedefs */ /* 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 */ - hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ + haddr_t addr; /* Address of object header for 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; /* Information about counted objects in a file */ typedef struct H5FO_obj_count_t { - haddr_t addr; /* Address of object header for object */ - hsize_t count; /* Number of times object is opened */ + haddr_t addr; /* Address of object header for object */ + hsize_t count; /* Number of times object is opened */ } H5FO_obj_count_t; /* Declare a free list to manage the H5FO_open_obj_t struct */ @@ -49,7 +48,6 @@ H5FL_DEFINE_STATIC(H5FO_open_obj_t); /* Declare a free list to manage the H5FO_obj_count_t struct */ H5FL_DEFINE_STATIC(H5FO_obj_count_t); - /*-------------------------------------------------------------------------- NAME H5FO_create @@ -71,7 +69,7 @@ H5FL_DEFINE_STATIC(H5FO_obj_count_t); herr_t H5FO_create(const H5F_t *f) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -80,14 +78,13 @@ H5FO_create(const H5F_t *f) HDassert(f->shared); /* Create container used to store open object info */ - if((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) + if ((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_create() */ - /*-------------------------------------------------------------------------- NAME H5FO_opened @@ -112,7 +109,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 @@ -123,7 +120,7 @@ H5FO_opened(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs,&addr))) { + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) { ret_value = open_obj->obj; HDassert(ret_value != NULL); } /* end if */ @@ -133,7 +130,6 @@ H5FO_opened(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_opened() */ - /*-------------------------------------------------------------------------- NAME H5FO_insert @@ -158,8 +154,8 @@ H5FO_opened(const H5F_t *f, haddr_t addr) herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -171,23 +167,22 @@ H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) HDassert(obj); /* Allocate new opened object information structure */ - if((open_obj=H5FL_MALLOC(H5FO_open_obj_t))==NULL) - HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") + if ((open_obj = H5FL_MALLOC(H5FO_open_obj_t)) == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Assign information */ - open_obj->addr=addr; - open_obj->obj=obj; - open_obj->deleted=delete_flag; + open_obj->addr = addr; + open_obj->obj = obj; + open_obj->deleted = delete_flag; /* Insert into container */ - if(H5SL_insert(f->shared->open_objs,&open_obj->addr,open_obj)<0) - HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") + if (H5SL_insert(f->shared->open_objs, &open_obj->addr, open_obj) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert object into container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_insert() */ - /*-------------------------------------------------------------------------- NAME H5FO_delete @@ -210,8 +205,8 @@ H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag) herr_t H5FO_delete(H5F_t *f, haddr_t addr) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -222,12 +217,12 @@ H5FO_delete(H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Remove from container */ - if(NULL == (open_obj = (H5FO_open_obj_t *)H5SL_remove(f->shared->open_objs, &addr))) - HGOTO_ERROR(H5E_CACHE,H5E_CANTRELEASE,FAIL,"can't remove object from container") + if (NULL == (open_obj = (H5FO_open_obj_t *)H5SL_remove(f->shared->open_objs, &addr))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container") /* Check if the object was deleted from the file */ - if(open_obj->deleted) { - if(H5O_delete(f, addr) < 0) + if (open_obj->deleted) { + if (H5O_delete(f, addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") } /* end if */ @@ -238,7 +233,6 @@ H5FO_delete(H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_delete() */ - /*-------------------------------------------------------------------------- NAME H5FO_mark @@ -261,8 +255,8 @@ H5FO_delete(H5F_t *f, haddr_t addr) herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - herr_t ret_value=SUCCEED; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -273,7 +267,7 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) open_obj->deleted = deleted; else ret_value = FAIL; @@ -281,7 +275,6 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_mark() */ - /*-------------------------------------------------------------------------- NAME H5FO_marked @@ -305,8 +298,8 @@ H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted) hbool_t H5FO_marked(const H5F_t *f, haddr_t addr) { - H5FO_open_obj_t *open_obj; /* Information about open object */ - hbool_t ret_value = FALSE; /* Return value */ + H5FO_open_obj_t *open_obj; /* Information about open object */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -317,13 +310,12 @@ H5FO_marked(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) + if (NULL != (open_obj = (H5FO_open_obj_t *)H5SL_search(f->shared->open_objs, &addr))) ret_value = open_obj->deleted; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_marked() */ - /*-------------------------------------------------------------------------- NAME H5FO_dest @@ -345,7 +337,7 @@ H5FO_marked(const H5F_t *f, haddr_t addr) herr_t H5FO_dest(const H5F_t *f) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -355,20 +347,19 @@ H5FO_dest(const H5F_t *f) HDassert(f->shared->open_objs); /* Check if the object info set is empty */ - if(H5SL_count(f->shared->open_objs)!=0) + if (H5SL_count(f->shared->open_objs) != 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object info set container */ - if(H5SL_close(f->shared->open_objs)<0) + if (H5SL_close(f->shared->open_objs) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") - f->shared->open_objs=NULL; + f->shared->open_objs = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_dest() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_create @@ -390,7 +381,7 @@ H5FO_dest(const H5F_t *f) herr_t H5FO_top_create(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -398,14 +389,13 @@ H5FO_top_create(H5F_t *f) HDassert(f); /* Create container used to store open object info */ - if((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) + if ((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_create() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_incr @@ -428,8 +418,8 @@ H5FO_top_create(H5F_t *f) herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -439,28 +429,27 @@ H5FO_top_incr(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { (obj_count->count)++; } /* end if */ else { /* Allocate new opened object information structure */ - if(NULL == (obj_count = H5FL_MALLOC(H5FO_obj_count_t))) - HGOTO_ERROR(H5E_CACHE,H5E_NOSPACE,FAIL,"memory allocation failed") + if (NULL == (obj_count = H5FL_MALLOC(H5FO_obj_count_t))) + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Assign information */ - obj_count->addr = addr; + obj_count->addr = addr; obj_count->count = 1; /* Insert into container */ - if(H5SL_insert(f->obj_count, &obj_count->addr, obj_count) < 0) - HGOTO_ERROR(H5E_CACHE,H5E_CANTINSERT,FAIL,"can't insert object into container") + if (H5SL_insert(f->obj_count, &obj_count->addr, obj_count) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert object into container") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_incr() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_decr @@ -483,8 +472,8 @@ H5FO_top_incr(const H5F_t *f, haddr_t addr) herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -494,19 +483,19 @@ H5FO_top_decr(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) { /* Decrement the reference count for the object */ (obj_count->count)--; - if(obj_count->count == 0) { + if (obj_count->count == 0) { /* Remove from container */ - if(NULL == (obj_count = (H5FO_obj_count_t *)H5SL_remove(f->obj_count, &addr))) + if (NULL == (obj_count = (H5FO_obj_count_t *)H5SL_remove(f->obj_count, &addr))) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "can't remove object from container") /* Release the object information */ obj_count = H5FL_FREE(H5FO_obj_count_t, obj_count); } /* end if */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't decrement ref. count") @@ -514,7 +503,6 @@ H5FO_top_decr(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_decr() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_count @@ -537,8 +525,8 @@ H5FO_top_decr(const H5F_t *f, haddr_t addr) hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr) { - H5FO_obj_count_t *obj_count; /* Ref. count for object */ - hsize_t ret_value; /* Return value */ + H5FO_obj_count_t *obj_count; /* Ref. count for object */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -548,7 +536,7 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Get the object node from the container */ - if(NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) + if (NULL != (obj_count = (H5FO_obj_count_t *)H5SL_search(f->obj_count, &addr))) ret_value = obj_count->count; else ret_value = 0; @@ -556,7 +544,6 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_count() */ - /*-------------------------------------------------------------------------- NAME H5FO_top_dest @@ -578,7 +565,7 @@ H5FO_top_count(const H5F_t *f, haddr_t addr) herr_t H5FO_top_dest(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -587,11 +574,11 @@ H5FO_top_dest(H5F_t *f) HDassert(f->obj_count); /* Check if the object count set is empty */ - if(H5SL_count(f->obj_count) != 0) + if (H5SL_count(f->obj_count) != 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "objects still in open object info set") /* Release the open object count set container */ - if(H5SL_close(f->obj_count) < 0) + if (H5SL_close(f->obj_count) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTCLOSEOBJ, FAIL, "can't close open object info set") f->obj_count = NULL; @@ -599,4 +586,3 @@ H5FO_top_dest(H5F_t *f) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_top_dest() */ - diff --git a/src/H5FOprivate.h b/src/H5FOprivate.h index 49e8126abca..7b512668169 100644 --- a/src/H5FOprivate.h +++ b/src/H5FOprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,38 +14,37 @@ /* * This file contains library private information about the H5FO module */ -#ifndef _H5FOprivate_H -#define _H5FOprivate_H +#ifndef H5FOprivate_H +#define H5FOprivate_H #ifdef LATER #include "H5FOpublic.h" #endif /* LATER */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5SLprivate.h" /* Skip lists */ /* Typedefs */ /* Typedef for open object cache */ -typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ +typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ /* Macros */ /* 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 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); +H5_DLL herr_t H5FO_create(const H5F_t *f); +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); H5_DLL hbool_t H5FO_marked(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_dest(const H5F_t *f); -H5_DLL herr_t H5FO_top_create(H5F_t *f); -H5_DLL herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_dest(const H5F_t *f); +H5_DLL herr_t H5FO_top_create(H5F_t *f); +H5_DLL herr_t H5FO_top_incr(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_top_decr(const H5F_t *f, haddr_t addr); H5_DLL hsize_t H5FO_top_count(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_top_dest(H5F_t *f); - -#endif /* _H5FOprivate_H */ +H5_DLL herr_t H5FO_top_dest(H5F_t *f); +#endif /* H5FOprivate_H */ diff --git a/src/H5FS.c b/src/H5FS.c index cb60c0edeae..c85790c06da 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,35 +25,30 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -62,7 +57,6 @@ static herr_t H5FS__sinfo_free_sect_cb(void *item, void *key, void *op_data); static herr_t H5FS__sinfo_free_node_cb(void *item, void *key, void *op_data); - /*********************/ /* Package Variables */ /*********************/ @@ -76,18 +70,14 @@ H5FL_SEQ_DEFINE(H5FS_section_class_t); /* Declare a free list to manage the H5FS_t struct */ H5FL_DEFINE(H5FS_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS_create * @@ -102,15 +92,15 @@ H5FL_DEFINE(H5FS_t); *------------------------------------------------------------------------- */ H5FS_t * -H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, - uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) +H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, + const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { - H5FS_t *fspace = NULL; /* New free space structure */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t *fspace = NULL; /* New free space structure */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, nclasses); + HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, nclasses); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -122,28 +112,28 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl /* * Allocate free space structure */ - if(NULL == (fspace = H5FS__new(f, nclasses, classes, cls_init_udata))) + if (NULL == (fspace = H5FS__new(f, nclasses, classes, cls_init_udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list") /* Initialize creation information for free space manager */ - fspace->client = fs_create->client; + fspace->client = fs_create->client; fspace->shrink_percent = fs_create->shrink_percent; fspace->expand_percent = fs_create->expand_percent; - fspace->max_sect_addr = fs_create->max_sect_addr; - fspace->max_sect_size = fs_create->max_sect_size; - fspace->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; + fspace->max_sect_addr = fs_create->max_sect_addr; + fspace->max_sect_size = fs_create->max_sect_size; + fspace->swmr_write = (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0; - fspace->alignment = alignment; + fspace->alignment = alignment; fspace->align_thres = threshold; /* Check if the free space tracker is supposed to be persistent */ - if(fs_addr) { + if (fs_addr) { /* Allocate space for the free space header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)fspace->hdr_size))) + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)fspace->hdr_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "file allocation failed for free space header") /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, NULL, "can't add free space header to cache") /* Return free space header address to caller, if desired */ @@ -156,21 +146,20 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl /* 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 = %a\n", FUNC, fspace, fspace->addr); #endif /* H5FS_DEBUG */ done: - if(!ret_value && fspace) - if(H5FS__hdr_dest(fspace) < 0) + if (!ret_value && fspace) + if (H5FS__hdr_dest(fspace) < 0) 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 = %d\n", FUNC, ret_value); #endif /* H5FS_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_create() */ - /*------------------------------------------------------------------------- * Function: H5FS_open * @@ -185,16 +174,17 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ 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_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_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5FS_t *ret_value = NULL; /* Return value */ + 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 */ 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 = %a, nclasses = %Zu\n", FUNC, fs_addr, + nclasses); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -203,33 +193,34 @@ HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %a, nclasses = %Zu\ HDassert(classes); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = nclasses; - cache_udata.classes = classes; + cache_udata.f = f; + cache_udata.nclasses = nclasses; + cache_udata.classes = classes; cache_udata.cls_init_udata = cls_init_udata; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; /* Protect the free space header */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (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->rc = %u\n", FUNC, fspace->rc); + 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->rc = %u\n", FUNC, fspace->rc); #endif /* H5FS_DEBUG */ /* Increment the reference count on the free space manager header */ HDassert(fspace->rc <= 1); - if(H5FS__incr(fspace) < 0) + if (H5FS__incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") - fspace->alignment = alignment; + fspace->alignment = alignment; fspace->align_thres = threshold; /* Unlock free space header */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, NULL, "unable to release free space header") /* Set return value */ @@ -239,7 +230,6 @@ HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_open() */ - /*------------------------------------------------------------------------- * Function: H5FS_delete * @@ -255,13 +245,13 @@ HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr) { - 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 */ + 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 = %a\n", FUNC, fs_addr); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -270,58 +260,60 @@ HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_ad /* Initialize user data for protecting the free space manager */ /* (no class information necessary for delete) */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; #ifdef H5FS_DEBUG -{ - unsigned fspace_status = 0; /* Free space section info's status in the metadata cache */ + { + unsigned fspace_status = 0; /* Free space section info's status in the metadata cache */ - /* Sanity check */ - HDassert(H5F_addr_defined(fs_addr)); + /* Sanity check */ + HDassert(H5F_addr_defined(fs_addr)); - /* Check the free space section info's status in the metadata cache */ - if(H5AC_get_entry_status(f, fs_addr, &fspace_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for free space section info") + /* Check the free space section info's status in the metadata cache */ + if (H5AC_get_entry_status(f, fs_addr, &fspace_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free space section info") - HDfprintf(stderr, "%s: fspace_status = %0x: ", FUNC, fspace_status); - if(fspace_status) { - hbool_t printed = FALSE; + HDfprintf(stderr, "%s: fspace_status = %0x: ", FUNC, fspace_status); + if (fspace_status) { + hbool_t printed = FALSE; - if(fspace_status & H5AC_ES__IN_CACHE) { - HDfprintf(stderr, "H5AC_ES__IN_CACHE"); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_DIRTY) { - HDfprintf(stderr, "%sH5AC_ES__IS_DIRTY", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_PROTECTED) { - HDfprintf(stderr, "%sH5AC_ES__IS_PROTECTED", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_PINNED) { - HDfprintf(stderr, "%sH5AC_ES__IS_PINNED", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_FLUSH_DEP_PARENT) { - HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_PARENT", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - if(fspace_status & H5AC_ES__IS_FLUSH_DEP_CHILD) { - HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_CHILD", (printed ? " | " : "")); - printed = TRUE; - } /* end if */ - } /* end if */ - HDfprintf(stderr, "\n"); -} + if (fspace_status & H5AC_ES__IN_CACHE) { + HDfprintf(stderr, "H5AC_ES__IN_CACHE"); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_DIRTY) { + HDfprintf(stderr, "%sH5AC_ES__IS_DIRTY", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_PROTECTED) { + HDfprintf(stderr, "%sH5AC_ES__IS_PROTECTED", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_PINNED) { + HDfprintf(stderr, "%sH5AC_ES__IS_PINNED", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_FLUSH_DEP_PARENT) { + HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_PARENT", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + if (fspace_status & H5AC_ES__IS_FLUSH_DEP_CHILD) { + HDfprintf(stderr, "%sH5AC_ES__IS_FLUSH_DEP_CHILD", (printed ? " | " : "")); + printed = TRUE; + } /* end if */ + } /* end if */ + HDfprintf(stderr, "\n"); + } #endif /* H5FS_DEBUG */ /* Protect the free space header */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space header") /* Sanity check */ @@ -329,27 +321,28 @@ HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_ad /* 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 = %a\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 */ + if (fspace->serial_sect_count > 0) { + unsigned sinfo_status = 0; /* Free space section info's status in the metadata cache */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->sect_addr)); HDassert(fspace->alloc_sect_size > 0); /* Check the free space section info's status in the metadata cache */ - if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for free space section info") + if (H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free space section info") /* If the free space section info is in the cache, expunge it now */ - if(sinfo_status & H5AC_ES__IN_CACHE) { + if (sinfo_status & H5AC_ES__IN_CACHE) { /* Sanity checks on direct block */ HDassert(!(sinfo_status & H5AC_ES__IS_PINNED)); HDassert(!(sinfo_status & H5AC_ES__IS_PROTECTED)); #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); + HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); #endif /* H5FS_DEBUG */ /* Evict the free space section info from the metadata cache */ /* (Free file space) */ @@ -362,33 +355,34 @@ HDfprintf(stderr, "%s: Expunging free space section info from cache\n", FUNC); if (!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) cache_flags |= H5AC__FREE_FILE_SPACE_FLAG; - if(H5AC_expunge_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, cache_flags) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove free space section info from cache") + if (H5AC_expunge_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, cache_flags) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, + "unable to remove free space section info from cache") } /* end block */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Done expunging free space section info from cache\n", FUNC); -#endif /* H5FS_DEBUG */ + HDfprintf(stderr, "%s: Done expunging free space section info from cache\n", FUNC); +#endif /* H5FS_DEBUG */ } /* end if */ else { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Deleting free space section info from file\n", FUNC); + HDfprintf(stderr, "%s: Deleting free space section info from file\n", FUNC); #endif /* H5FS_DEBUG */ /* Release the space in the file */ - if(!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, fspace->sect_addr)) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end else */ - } /* end if */ + } /* end if */ done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_delete() */ - /*------------------------------------------------------------------------- * Function: H5FS_close * @@ -405,7 +399,7 @@ HDfprintf(stderr, "%s: Deleting free space section info from file\n", FUNC); herr_t H5FS_close(H5F_t *f, H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -413,64 +407,74 @@ 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 = %a, fspace->sinfo = %p\n", FUNC, fspace, + fspace->addr, fspace->sinfo); #endif /* H5FS_DEBUG */ /* Check if section info is valid */ /* (i.e. the header "owns" the section info and it's not in the cache) */ - if(fspace->sinfo) { + 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", 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, fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, + "%s: fspace->tot_sect_count = %Hu, fspace->serial_sect_count = %Hu, fspace->sect_addr = " + "%a, 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, + fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_DEBUG */ /* If there are sections to serialize, update them */ /* (if the free space manager is persistent) */ - if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { + if (fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC); + HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC); #endif /* H5FS_DEBUG */ - if(fspace->sinfo->dirty) { + if (fspace->sinfo->dirty) { /* Check if the section info is "floating" */ - if(!H5F_addr_defined(fspace->sect_addr)) { + if (!H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); /* Allocate space for the section info in file */ - if(H5F_USE_TMP_SPACE(f)) { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc_tmp(f, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (H5F_USE_TMP_SPACE(f)) { + if (HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc_tmp(f, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") } /* end if */ else { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (HADDR_UNDEF == + (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") } /* end if */ fspace->alloc_sect_size = (size_t)fspace->sect_size; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end if */ - } /* end if */ + } /* end if */ else /* Sanity check that section info has address */ HDassert(H5F_addr_defined(fspace->sect_addr)); /* Cache the free space section info */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") } /* end if */ else { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: NOT storing section info in file\n", FUNC); + HDfprintf(stderr, "%s: NOT storing section info in file\n", FUNC); #endif /* H5FS_DEBUG */ /* Check if space for the section info is allocated */ - if(H5F_addr_defined(fspace->sect_addr)) { + if (H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ /* (section info should only be in the file if the header is */ HDassert(H5F_addr_defined(fspace->addr)); #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); + HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); #endif /* H5FS_DEBUG */ /* Check if the section info is for the free space in the file */ /* (NOTE: This is the "bootstrapping" special case for the @@ -478,75 +482,81 @@ HDfprintf(stderr, "%s: Section info allocated though\n", FUNC); * section info and re-creating it as a section in the * manager. -QAK) */ - if(fspace->client == H5FS_CLIENT_FILE_ID) { - htri_t status; /* "can absorb" status for section into */ + if (fspace->client == H5FS_CLIENT_FILE_ID) { + htri_t status; /* "can absorb" status for section into */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info is for file free space\n", FUNC); + HDfprintf(stderr, "%s: Section info is for file free space\n", FUNC); #endif /* H5FS_DEBUG */ /* Try to shrink the file or absorb the section info into a block aggregator */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info in temp. address space went 'go away'\n", FUNC); + HDfprintf(stderr, "%s: Section info in temp. address space went 'go away'\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end if */ else { - if((status = H5MF_try_shrink(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, fspace->alloc_sect_size)) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for absorbing section info") - else if(status == FALSE) { + if ((status = H5MF_try_shrink(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, + fspace->alloc_sect_size)) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, + "can't check for absorbing section info") + else if (status == FALSE) { /* Section info can't "go away", but it's free. Allow * header to record it */ #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Section info can't 'go away', header will own it\n", FUNC); -#endif /* H5FS_DEBUG */ + HDfprintf(stderr, "%s: Section info can't 'go away', header will own it\n", FUNC); +#endif /* H5FS_DEBUG */ } /* end if */ else { #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Section info went 'go away'\n", FUNC); + HDfprintf(stderr, "%s: Section info went 'go away'\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { - haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ - hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ + haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ + hsize_t old_alloc_sect_size = + fspace->alloc_sect_size; /* Previous size of section info in file */ #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); + HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); #endif /* H5FS_DEBUG */ /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") /* Free previous serialized sections disk space */ - if(!H5F_IS_TMP_ADDR(f, old_sect_addr)) { - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, old_sect_addr)) { + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Destroy section info */ - if(H5FS__sinfo_dest(fspace->sinfo) < 0) + if (H5FS__sinfo_dest(fspace->sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space section info") } /* end else */ @@ -555,23 +565,22 @@ HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); } /* end if */ else { /* Just sanity checks... */ - if(fspace->serial_sect_count > 0) + if (fspace->serial_sect_count > 0) /* Sanity check that section info has address */ HDassert(H5F_addr_defined(fspace->sect_addr)); } /* end else */ /* Decrement the reference count on the free space manager header */ - if(H5FS__decr(fspace) < 0) + if (H5FS__decr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header") done: #ifdef H5FS_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_value, fspace->rc); + HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_value, fspace->rc); #endif /* H5FS_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_close() */ - /*------------------------------------------------------------------------- * Function: H5FS__new * @@ -586,12 +595,11 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_va *------------------------------------------------------------------------- */ H5FS_t * -H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], - void *cls_init_udata) +H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata) { - H5FS_t *fspace = NULL; /* Free space manager */ - size_t u; /* Local index variable */ - H5FS_t *ret_value = NULL; /* Return value */ + H5FS_t *fspace = NULL; /* Free space manager */ + size_t u; /* Local index variable */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -601,17 +609,18 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes /* * Allocate free space structure */ - if(NULL == (fspace = H5FL_CALLOC(H5FS_t))) + if (NULL == (fspace = H5FL_CALLOC(H5FS_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space free list") /* Set immutable free list parameters */ H5_CHECKED_ASSIGN(fspace->nclasses, uint16_t, nclasses, size_t); - if(nclasses > 0) { - if(NULL == (fspace->sect_cls = H5FL_SEQ_MALLOC(H5FS_section_class_t, nclasses))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section class array") + if (nclasses > 0) { + if (NULL == (fspace->sect_cls = H5FL_SEQ_MALLOC(H5FS_section_class_t, nclasses))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for free space section class array") /* Initialize the section classes for this free space list */ - for(u = 0; u < nclasses; u++) { + for (u = 0; u < nclasses; u++) { /* Make certain that section class type can be used as an array index into this array */ HDassert(u == classes[u]->type); @@ -619,39 +628,39 @@ H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes H5MM_memcpy(&fspace->sect_cls[u], classes[u], sizeof(H5FS_section_class_t)); /* Call the class initialization routine, if there is one */ - if(fspace->sect_cls[u].init_cls) - if((fspace->sect_cls[u].init_cls)(&fspace->sect_cls[u], cls_init_udata) < 0) + if (fspace->sect_cls[u].init_cls) + if ((fspace->sect_cls[u].init_cls)(&fspace->sect_cls[u], cls_init_udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "unable to initialize section class") /* Determine maximum class-specific serialization size for each section */ - if(fspace->sect_cls[u].serial_size > fspace->max_cls_serial_size) + if (fspace->sect_cls[u].serial_size > fspace->max_cls_serial_size) fspace->max_cls_serial_size = fspace->sect_cls[u].serial_size; } /* end for */ - } /* end if */ + } /* end if */ /* Initialize non-zero information for new free space manager */ - fspace->addr = HADDR_UNDEF; - fspace->hdr_size = (size_t)H5FS_HEADER_SIZE(f); + fspace->addr = HADDR_UNDEF; + fspace->hdr_size = (size_t)H5FS_HEADER_SIZE(f); fspace->sect_addr = HADDR_UNDEF; /* Set return value */ ret_value = fspace; done: - if(!ret_value) - if(fspace) { + if (!ret_value) + if (fspace) { /* Should probably call the class 'term' callback for all classes * that have had their 'init' callback called... -QAK */ - if(fspace->sect_cls) - fspace->sect_cls = (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); + if (fspace->sect_cls) + fspace->sect_cls = + (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); fspace = H5FL_FREE(H5FS_t, fspace); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__new() */ - /*------------------------------------------------------------------------- * Function: H5FS_size * @@ -681,7 +690,6 @@ H5FS_size(const H5FS_t *fspace, hsize_t *meta_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__incr * @@ -697,11 +705,11 @@ H5FS_size(const H5FS_t *fspace, hsize_t *meta_size) herr_t H5FS__incr(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ 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 = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -710,8 +718,8 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp HDassert(fspace); /* Check if we should pin the header in the cache */ - if(fspace->rc == 0 && H5F_addr_defined(fspace->addr)) - if(H5AC_pin_protected_entry(fspace) < 0) + if (fspace->rc == 0 && H5F_addr_defined(fspace->addr)) + if (H5AC_pin_protected_entry(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPIN, FAIL, "unable to pin free space header") /* Increment reference count on header */ @@ -721,7 +729,6 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__incr() */ - /*------------------------------------------------------------------------- * Function: H5FS__decr * @@ -737,11 +744,11 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp herr_t H5FS__decr(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ 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 = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -753,22 +760,21 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp fspace->rc--; /* Check if we should unpin the header in the cache */ - if(fspace->rc == 0) { - if(H5F_addr_defined(fspace->addr)) { - if(H5AC_unpin_entry(fspace) < 0) + if (fspace->rc == 0) { + if (H5F_addr_defined(fspace->addr)) { + if (H5AC_unpin_entry(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") } /* end if */ else { - if(H5FS__hdr_dest(fspace) < 0) + if (H5FS__hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space header") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__decr() */ - /*------------------------------------------------------------------------- * Function: H5FS__dirty * @@ -784,7 +790,7 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp herr_t H5FS__dirty(H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -792,16 +798,15 @@ H5FS__dirty(H5FS_t *fspace) HDassert(fspace); /* Check if the free space manager is persistent */ - if(H5F_addr_defined(fspace->addr)) + if (H5F_addr_defined(fspace->addr)) /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(fspace) < 0) + if (H5AC_mark_entry_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__dirty() */ - /*------------------------------------------------------------------------- * Function: H5FS_alloc_hdr() * @@ -817,7 +822,7 @@ H5FS__dirty(H5FS_t *fspace) herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -825,24 +830,23 @@ H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr) HDassert(f); HDassert(fspace); - if(!H5F_addr_defined(fspace->addr)) { + if (!H5F_addr_defined(fspace->addr)) { /* Allocate space for the free space header */ - if(HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)H5FS_HEADER_SIZE(f)))) + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, (hsize_t)H5FS_HEADER_SIZE(f)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header") /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") } /* end if */ - if(fs_addr) + if (fs_addr) *fs_addr = fspace->addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_alloc_hdr() */ - /*------------------------------------------------------------------------- * Function: H5FS_alloc_sect() * @@ -858,7 +862,7 @@ H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr) herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -866,17 +870,17 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); - if(!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) { - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (!H5F_addr_defined(fspace->sect_addr) && fspace->sinfo && fspace->serial_sect_count > 0) { + if (HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info") fspace->alloc_sect_size = fspace->sect_size; /* Mark free-space header as dirty */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") /* Cache the free-space section info */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") /* Since space has been allocated for the section info and the sinfo @@ -890,7 +894,6 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_alloc_sect() */ - /*------------------------------------------------------------------------- * Function: H5FS_free() * @@ -906,9 +909,9 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace) herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) { - haddr_t saved_addr; /* Previous address of item */ - unsigned cache_flags; /* Flags for unprotecting cache entries */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t saved_addr; /* Previous address of item */ + unsigned cache_flags; /* Flags for unprotecting cache entries */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -916,85 +919,89 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) HDassert(f); HDassert(fspace); - cache_flags = H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG;; + cache_flags = H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; + ; /* Free space for section info */ - if(H5F_addr_defined(fspace->sect_addr)) { - hsize_t saved_size; /* Size of previous section info */ - unsigned sinfo_status = 0; /* Section info cache status */ + if (H5F_addr_defined(fspace->sect_addr)) { + hsize_t saved_size; /* Size of previous section info */ + unsigned sinfo_status = 0; /* Section info cache status */ /* Check whether free-space manager section info is in cache or not */ - if(H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info") + if (H5AC_get_entry_status(f, fspace->sect_addr, &sinfo_status) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free-space section info") /* Load free-space manager section info */ - if(sinfo_status & H5AC_ES__IN_CACHE || !fspace->sinfo) { - H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ + if (sinfo_status & H5AC_ES__IN_CACHE || !fspace->sinfo) { + H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ /* Protect the free space sections */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, + &cache_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") /* Unload and release ownership of the free-space manager section info */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") } /* end if */ saved_addr = fspace->sect_addr; saved_size = fspace->alloc_sect_size; - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* Free space for the free-space manager section info */ - if(!H5F_IS_TMP_ADDR(f, saved_addr)) { - if(free_file_space && - H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, saved_addr, saved_size) < 0) + if (!H5F_IS_TMP_ADDR(f, saved_addr)) { + if (free_file_space && H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, saved_addr, saved_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") } /* end if */ /* Mark free-space manager header as dirty */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ /* Free space for header */ - if(H5F_addr_defined(fspace->addr)) { - unsigned hdr_status = 0; /* Header entry status */ + if (H5F_addr_defined(fspace->addr)) { + unsigned hdr_status = 0; /* Header entry status */ /* Check whether free-space manager header is in cache or not */ - if(H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to check metadata cache status for free-space section info") + if (H5AC_get_entry_status(f, fspace->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, + "unable to check metadata cache status for free-space section info") - if(hdr_status & H5AC_ES__IN_CACHE) { + if (hdr_status & H5AC_ES__IN_CACHE) { H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ /* Protect the free-space manager header */ /* (no class information necessary since it's in the cache) */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fspace->addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") + if (NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fspace->addr, &cache_udata, + H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space section info") /* Unpin the free-space manager header */ - if(H5AC_unpin_entry(fspace) < 0) + if (H5AC_unpin_entry(fspace) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header") /* Unload and release ownership of the free-space header */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fspace->addr, fspace, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") } /* end if */ - saved_addr = fspace->addr; + saved_addr = fspace->addr; fspace->addr = HADDR_UNDEF; /* Free space for the free-space manager header */ - if(free_file_space && - H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) + if (free_file_space && + H5MF_xfree(f, H5FD_MEM_FSPACE_HDR, saved_addr, (hsize_t)H5FS_HEADER_SIZE(f)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header") } /* end if */ @@ -1002,7 +1009,6 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_free() */ - /*------------------------------------------------------------------------- * Function: H5FS__hdr_dest * @@ -1018,8 +1024,8 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) herr_t H5FS__hdr_dest(H5FS_t *fspace) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1029,15 +1035,15 @@ H5FS__hdr_dest(H5FS_t *fspace) HDassert(fspace); /* Terminate the section classes for this free space list */ - for(u = 0; u < fspace->nclasses ; u++) { + for (u = 0; u < fspace->nclasses; u++) { /* Call the class termination routine, if there is one */ - if(fspace->sect_cls[u].term_cls) - if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) + if (fspace->sect_cls[u].term_cls) + if ((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class") } /* end for */ /* Release the memory for the free space section classes */ - if(fspace->sect_cls) + if (fspace->sect_cls) fspace->sect_cls = (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); /* Free free space info */ @@ -1047,7 +1053,6 @@ H5FS__hdr_dest(H5FS_t *fspace) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__hdr_dest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_free_sect_cb * @@ -1063,8 +1068,8 @@ H5FS__hdr_dest(H5FS_t *fspace) 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -1075,9 +1080,8 @@ H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) (*sinfo->fspace->sect_cls[sect->type].free)(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FS__sinfo_free_sect_cb() */ +} /* H5FS__sinfo_free_sect_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_free_node_cb * @@ -1093,7 +1097,7 @@ H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) static herr_t H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) { - H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ + H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ FUNC_ENTER_STATIC_NOERR @@ -1107,9 +1111,8 @@ H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5FS__sinfo_free_node_cb() */ +} /* H5FS__sinfo_free_node_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_dest * @@ -1125,8 +1128,8 @@ H5FS__sinfo_free_node_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) herr_t H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1138,8 +1141,8 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) HDassert(sinfo->bins); /* Clear out lists of nodes */ - for(u = 0; u < sinfo->nbins; u++) - if(sinfo->bins[u].bin_list) { + for (u = 0; u < sinfo->nbins; u++) + if (sinfo->bins[u].bin_list) { H5SL_destroy(sinfo->bins[u].bin_list, H5FS__sinfo_free_node_cb, sinfo); sinfo->bins[u].bin_list = NULL; } /* end if */ @@ -1148,8 +1151,8 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); /* Release skip list for merging sections */ - if(sinfo->merge_list) - if(H5SL_close(sinfo->merge_list) < 0) + if (sinfo->merge_list) + if (H5SL_close(sinfo->merge_list) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy section merging skip list") /* Decrement the reference count on free space header */ @@ -1157,7 +1160,7 @@ H5FS__sinfo_dest(H5FS_sinfo_t *sinfo) * disappearing immediately) */ sinfo->fspace->sinfo = NULL; - if(H5FS__decr(sinfo->fspace) < 0) + if (H5FS__decr(sinfo->fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header") sinfo->fspace = NULL; @@ -1186,7 +1189,7 @@ H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count) } #ifdef H5FS_DEBUG_ASSERT - + /*------------------------------------------------------------------------- * Function: H5FS__assert * @@ -1205,7 +1208,7 @@ H5FS__assert(const H5FS_t *fspace) FUNC_ENTER_PACKAGE_NOERR /* Checks for section info, if it's available */ - if(fspace->sinfo) { + if (fspace->sinfo) { /* Sanity check sections */ H5FS__sect_assert(fspace); @@ -1222,4 +1225,3 @@ H5FS__assert(const H5FS_t *fspace) FUNC_LEAVE_NOAPI_VOID } /* end H5FS__assert() */ #endif /* H5FS_DEBUG_ASSERT */ - diff --git a/src/H5FScache.c b/src/H5FScache.c index 4d1a91a4280..39f0333757d 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,31 +26,28 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* File free space format version #'s */ -#define H5FS_HDR_VERSION 0 /* Header */ -#define H5FS_SINFO_VERSION 0 /* Serialized sections */ - +#define H5FS_HDR_VERSION 0 /* Header */ +#define H5FS_SINFO_VERSION 0 /* Serialized sections */ /******************/ /* Local Typedefs */ @@ -58,17 +55,15 @@ /* 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 */ - unsigned sect_cnt_size; /* # of bytes to encode section size counts in */ + H5FS_sinfo_t *sinfo; /* Free space section info */ + 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; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -80,81 +75,72 @@ 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); -static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +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); +static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *thing); 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); -static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +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); +static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *thing); static herr_t H5FS__cache_sinfo_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5FS header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FSPACE_HDR[1] = {{ - H5AC_FSPACE_HDR_ID, /* Metadata client ID */ - "Free Space Header", /* Metadata client name (for debugging) */ - H5FD_MEM_FSPACE_HDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5FS__cache_hdr_deserialize, /* 'deserialize' callback */ - H5FS__cache_hdr_image_len, /* 'image_len' callback */ - H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ - H5FS__cache_hdr_serialize, /* 'serialize' callback */ - H5FS__cache_hdr_notify, /* 'notify' callback */ - H5FS__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_FSPACE_HDR_ID, /* Metadata client ID */ + "Free Space Header", /* Metadata client name (for debugging) */ + H5FD_MEM_FSPACE_HDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FS__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FS__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5FS__cache_hdr_deserialize, /* 'deserialize' callback */ + H5FS__cache_hdr_image_len, /* 'image_len' callback */ + H5FS__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ + H5FS__cache_hdr_serialize, /* 'serialize' callback */ + H5FS__cache_hdr_notify, /* 'notify' callback */ + H5FS__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5FS section info inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{ - H5AC_FSPACE_SINFO_ID, /* Metadata client ID */ - "Free Space Section Info", /* Metadata client name (for debugging) */ - H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */ - H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */ - H5FS__cache_sinfo_image_len, /* 'image_len' callback */ - H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */ - H5FS__cache_sinfo_serialize, /* 'serialize' callback */ - H5FS__cache_sinfo_notify, /* 'notify' callback */ - H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_FSPACE_SINFO_ID, /* Metadata client ID */ + "Free Space Section Info", /* Metadata client name (for debugging) */ + H5FD_MEM_FSPACE_SINFO, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5FS__cache_sinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5FS__cache_sinfo_verify_chksum, /* 'verify_chksum' callback */ + H5FS__cache_sinfo_deserialize, /* 'deserialize' callback */ + H5FS__cache_sinfo_image_len, /* 'image_len' callback */ + H5FS__cache_sinfo_pre_serialize, /* 'pre_serialize' callback */ + H5FS__cache_sinfo_serialize, /* 'serialize' callback */ + H5FS__cache_sinfo_notify, /* 'notify' callback */ + H5FS__cache_sinfo_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_get_initial_load_size * @@ -185,7 +171,6 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_verify_chksum * @@ -202,10 +187,10 @@ H5FS__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5FS__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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -215,13 +200,12 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_deserialize * @@ -240,14 +224,14 @@ H5FS__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE */ static void * H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - unsigned nclasses; /* Number of section classes */ - H5FS_t *ret_value = NULL; /* Return value */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + unsigned nclasses; /* Number of section classes */ + H5FS_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -257,24 +241,24 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len HDassert(udata->f); /* Allocate a new free space manager */ - if(NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata))) + if (NULL == (fspace = H5FS__new(udata->f, udata->nclasses, udata->classes, udata->cls_init_udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set free space manager's internal information */ fspace->addr = udata->addr; /* Magic number */ - if(HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FS_HDR_VERSION) + if (*image++ != H5FS_HDR_VERSION) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version") /* Client ID */ fspace->client = (H5FS_client_t)*image++; - if(fspace->client >= H5FS_NUM_CLIENT_ID) + if (fspace->client >= H5FS_NUM_CLIENT_ID) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header") /* Total space tracked */ @@ -292,7 +276,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len /* # of section classes */ /* (only check if we actually have some classes) */ UINT16DECODE(image, nclasses); - if(fspace->nclasses > 0 && nclasses > fspace->nclasses) + if (fspace->nclasses > 0 && nclasses > fspace->nclasses) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "section class count mismatch") /* Shrink percent */ @@ -331,14 +315,13 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len done: /* Release resources */ - if(!ret_value && fspace) - if(H5FS__hdr_dest(fspace) < 0) + if (!ret_value && fspace) + if (H5FS__hdr_dest(fspace) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_image_len * @@ -355,7 +338,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len static herr_t H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */ + const H5FS_t *fspace = (const H5FS_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -371,7 +354,6 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_pre_serialize * @@ -400,13 +382,13 @@ 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 H5_ATTR_UNUSED len, haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, - size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) +H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_UNUSED len, + 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 */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -420,11 +402,11 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(new_len); HDassert(flags); - if(fspace->sinfo) { + if (fspace->sinfo) { H5AC_ring_t ring; /* Retrieve the ring type for the header */ - if(H5AC_get_entry_ring(f, addr, &ring) < 0) + if (H5AC_get_entry_ring(f, addr, &ring) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "unable to get property value"); /* Set the ring type for the section info in the API context */ @@ -508,26 +490,54 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * as dirty, as the metadata cache would not be attempting to * serialize the header if it thought it was clean. */ - if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { + if (fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); - if(!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */ + if (!H5F_addr_defined(fspace->sect_addr)) { /* case 1 */ haddr_t tag = HADDR_UNDEF; + haddr_t sect_addr; + hsize_t saved_sect_size, new_sect_size; /* allocate file space for the section info, and insert it * into the metadata cache. */ - if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") - - fspace->alloc_sect_size = (size_t)fspace->sect_size; + saved_sect_size = fspace->sect_size; + if (HADDR_UNDEF == + (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") + + /* fspace->sect_size may change in size after H5MF_alloc(). + * If increased in size, free the previous allocation and + * allocate again with the bigger fspace->sect_size. + */ + if (fspace->sect_size > saved_sect_size) { + + new_sect_size = fspace->sect_size; + + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, saved_sect_size) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") + + if (HADDR_UNDEF == + (sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, new_sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") + fspace->sect_size = new_sect_size; + fspace->alloc_sect_size = new_sect_size; + } + else { + fspace->alloc_sect_size = saved_sect_size; + fspace->sect_size = saved_sect_size; + } + fspace->sect_addr = sect_addr; /* Get the tag for this free space manager and use it to insert the entry */ - if(H5AC_get_tag((const void *)fspace, &tag) < 0) + if (H5AC_get_tag((const void *)fspace, &tag) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTTAG, FAIL, "can't get tag for metadata cache object") H5_BEGIN_TAG(tag) - if(H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR_TAG(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") H5_END_TAG @@ -537,8 +547,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * so set fspace->sinfo to NULL. */ fspace->sinfo = NULL; - } /* end if */ - else if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */ + } /* end if */ + else if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* case 2 */ haddr_t new_sect_addr; /* move the section info from temporary (AKA imaginary) file @@ -553,18 +563,20 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") + if (HADDR_UNDEF == + (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, + "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; HDassert(fspace->sinfo->cache_info.size == fspace->alloc_sect_size); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move section info") fspace->sect_addr = new_sect_addr; - } /* end else-if */ + } /* end else-if */ else { /* case 3 -- nothing to do but sanity checking */ /* if my reading of the code is correct, this should always * be the case. If not, we will have to add code to resize @@ -573,15 +585,15 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(fspace->sect_size > 0); HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); } /* end else */ - } /* end else */ + } /* end else */ else { /* for one reason or another (see comment above) there should * not be any file space allocated for the section info. */ - HDassert(!H5F_addr_defined(fspace->sect_addr)); + HDassert(!H5F_addr_defined(fspace->sect_addr)); } /* end else */ - } /* end if */ - else if(H5F_addr_defined(fspace->sect_addr)) { + } /* end if */ + else if (H5F_addr_defined(fspace->sect_addr)) { /* Here the metadata cache is managing the section info. * * Do some sanity checks, and then test to see if the section @@ -589,15 +601,14 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * real file space lest the header be written to file with * a nonsense section info address. */ - if(!H5F_POINT_OF_NO_RETURN(f)) { - HDassert(fspace->serial_sect_count > 0); + if (!H5F_POINT_OF_NO_RETURN(f)) { HDassert(fspace->sect_size > 0); HDassert(fspace->alloc_sect_size == (size_t)fspace->sect_size); } /* end if */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { unsigned sect_status = 0; - haddr_t new_sect_addr; + haddr_t new_sect_addr; /* we have work to do -- must relocate section info into * real file space. @@ -607,7 +618,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, * cache. Further, since fspace->sinfo is NULL, it must be * unprotected and un-pinned. Start by verifying this. */ - if(H5AC_get_entry_status(f, fspace->sect_addr, §_status) < 0) + if (H5AC_get_entry_status(f, fspace->sect_addr, §_status) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info status") HDassert(sect_status & H5AC_ES__IN_CACHE); @@ -615,7 +626,8 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert((sect_status & H5AC_ES__IS_PINNED) == 0); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (HADDR_UNDEF == + (new_sect_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; @@ -624,7 +636,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, HDassert(!H5F_addr_eq(fspace->sect_addr, new_sect_addr)); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, new_sect_addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info") /* Update the internal address for the section info */ @@ -633,9 +645,9 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, /* No need to mark the header dirty, as we are about to * serialize it. */ - } /* end if */ - } /* end else-if */ - else { /* there is no section info at present */ + } /* end if */ + } /* end else-if */ + else { /* there is no section info at present */ /* do some sanity checks */ HDassert(fspace->serial_sect_count == 0); HDassert(fspace->tot_sect_count == fspace->ghost_sect_count); @@ -646,13 +658,12 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_serialize * @@ -670,13 +681,12 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -696,13 +706,11 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN * into real file space if necessary before this function was called. * The following asserts are a cursory check on this. */ - HDassert((! H5F_addr_defined(fspace->sect_addr)) || (! H5F_IS_TMP_ADDR(f, fspace->sect_addr))); + HDassert((!H5F_addr_defined(fspace->sect_addr)) || (!H5F_IS_TMP_ADDR(f, fspace->sect_addr))); - if(!H5F_POINT_OF_NO_RETURN(f)) - HDassert((! H5F_addr_defined(fspace->sect_addr)) || - ((fspace->serial_sect_count > 0) && - (fspace->sect_size > 0) && - (fspace->alloc_sect_size == (size_t)fspace->sect_size))); + if (!H5F_POINT_OF_NO_RETURN(f)) + HDassert((!H5F_addr_defined(fspace->sect_addr)) || + ((fspace->sect_size > 0) && (fspace->alloc_sect_size == (size_t)fspace->sect_size))); /* Magic number */ H5MM_memcpy(image, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); @@ -764,7 +772,6 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_notify * @@ -780,8 +787,8 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN herr_t H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -789,7 +796,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) HDassert(fspace); /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -797,7 +804,7 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: - if(H5AC_unsettle_entry_ring(fspace) < 0) + if (H5AC_unsettle_entry_ring(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFLUSH, FAIL, "unable to mark FSM ring as unsettled") break; @@ -813,16 +820,15 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) default: #ifdef NDEBUG HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__cache_hdr_notify() */ +} /* end H5FS__cache_hdr_notify() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_hdr_free_icr * @@ -843,8 +849,8 @@ H5FS__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5FS__cache_hdr_free_icr(void *_thing) { - H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -857,14 +863,13 @@ H5FS__cache_hdr_free_icr(void *_thing) HDassert(!fspace->sinfo); /* Destroy free space header */ - if(H5FS__hdr_dest(fspace) < 0) + if (H5FS__hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_get_initial_load_size() * @@ -880,9 +885,9 @@ H5FS__cache_hdr_free_icr(void *_thing) *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) +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 @@ -900,7 +905,6 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_sinfo_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_verify_chksum * @@ -917,10 +921,10 @@ H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5FS__cache_sinfo_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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -930,13 +934,12 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_deserialize * @@ -955,16 +958,17 @@ H5FS__cache_sinfo_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU */ static void * H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_NDEBUG_UNUSED *dirty) + 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 */ - 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 */ - uint32_t stored_chksum; /* Stored metadata checksum */ - void * ret_value = NULL; /* Return value */ + 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 */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -977,52 +981,53 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(dirty); /* Allocate a new free space section info */ - if(NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace))) + if (NULL == (sinfo = H5FS__sinfo_new(udata->f, fspace))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* initialize old_sect_size */ H5_CHECKED_ASSIGN(old_sect_size, size_t, fspace->sect_size, hsize_t); /* Magic number */ - if(HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5FS_SINFO_VERSION) + if (*image++ != H5FS_SINFO_VERSION) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections version") /* Address of free space header for these sections */ H5F_addr_decode(udata->f, &image, &fs_addr); - if(H5F_addr_ne(fs_addr, fspace->addr)) + if (H5F_addr_ne(fs_addr, fspace->addr)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect header address for free space sections") /* Check for any serialized sections */ - 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 */ + 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 */ + 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); /* Reset the section count, the "add" routine will update it */ - old_tot_sect_count = fspace->tot_sect_count; - old_serial_sect_count = fspace->serial_sect_count; - old_ghost_sect_count = fspace->ghost_sect_count; - old_tot_space = fspace->tot_space; - fspace->tot_sect_count = 0; + old_tot_sect_count = fspace->tot_sect_count; + old_serial_sect_count = fspace->serial_sect_count; + old_ghost_sect_count = fspace->ghost_sect_count; + old_tot_space = fspace->tot_space; + fspace->tot_sect_count = 0; fspace->serial_sect_count = 0; - fspace->ghost_sect_count = 0; - fspace->tot_space = 0; + fspace->ghost_sect_count = 0; + fspace->tot_space = 0; /* Walk through the image, deserializing sections */ do { - hsize_t sect_size = 0; /* Current section size */ - size_t node_count = 0; /* # of sections of this size */ - size_t u; /* Local index variable */ + hsize_t sect_size = 0; /* Current section size */ + size_t node_count = 0; /* # of sections of this size */ + size_t u; /* Local index variable */ /* The number of sections of this node's size */ UINT64DECODE_VAR(image, node_count, sect_cnt_size); @@ -1033,11 +1038,11 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(sect_size); /* Loop over nodes of this size */ - for(u = 0; u < node_count; u++) { - H5FS_section_info_t *new_sect; /* Section that was deserialized */ - haddr_t sect_addr = 0; /* Address of free space section in the address space */ - unsigned sect_type; /* Type of free space section */ - unsigned des_flags; /* Flags from deserialize callback */ + for (u = 0; u < node_count; u++) { + H5FS_section_info_t *new_sect; /* Section that was deserialized */ + haddr_t sect_addr = 0; /* Address of free space section in the address space */ + unsigned sect_type; /* Type of free space section */ + unsigned des_flags; /* Flags from deserialize callback */ /* The address of the section */ UINT64DECODE_VAR(image, sect_addr, sinfo->sect_off_size); @@ -1048,21 +1053,27 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* Call 'deserialize' callback for this section */ des_flags = 0; HDassert(fspace->sect_cls[sect_type].deserialize); - if(NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize) (&fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags))) + if (NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize)( + &fspace->sect_cls[sect_type], image, sect_addr, sect_size, &des_flags))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDECODE, NULL, "can't deserialize section") /* Update offset in serialization image */ image += fspace->sect_cls[sect_type].serial_size; /* Insert section in free space manager, unless requested not to */ - if(!(des_flags & H5FS_DESERIALIZE_NO_ADD)) - if(H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, "can't add section to free space manager") + if (!(des_flags & H5FS_DESERIALIZE_NO_ADD)) + if (H5FS_sect_add(udata->f, fspace, new_sect, H5FS_ADD_DESERIALIZING, udata) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, NULL, + "can't add section to free space manager") } /* end for */ - } while(image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM)); + + if (fspace->tot_sect_count == old_tot_sect_count) + break; + + } while (image < (((const uint8_t *)_image + old_sect_size) - H5FS_SIZEOF_CHKSUM)); /* Sanity check */ - HDassert((size_t)(image - (const uint8_t *)_image) == (old_sect_size - H5FS_SIZEOF_CHKSUM)); + HDassert((size_t)(image - (const uint8_t *)_image) <= (old_sect_size - H5FS_SIZEOF_CHKSUM)); HDassert(old_sect_size == fspace->sect_size); HDassert(old_tot_sect_count == fspace->tot_sect_count); HDassert(old_serial_sect_count == fspace->serial_sect_count); @@ -1072,24 +1083,26 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* checksum verification already done in verify_chksum cb */ + /* There may be empty space between entries and chksum */ + chksum_image = (const uint8_t *)(_image) + old_sect_size - H5FS_SIZEOF_CHKSUM; /* Metadata checksum */ - UINT32DECODE(image, stored_chksum); + UINT32DECODE(chksum_image, stored_chksum); /* Sanity check */ - HDassert((size_t)(image - (const uint8_t *)_image) == old_sect_size); + HDassert((image == chksum_image) || + ((size_t)((image - (const uint8_t *)_image) + (chksum_image - image)) == old_sect_size)); /* Set return value */ ret_value = sinfo; done: - if(!ret_value && sinfo) - if(H5FS__sinfo_dest(sinfo) < 0) + if (!ret_value && sinfo) + if (H5FS__sinfo_dest(sinfo) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_image_len * @@ -1106,7 +1119,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l static herr_t H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) { - const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */ + const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -1125,7 +1138,6 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS__cache_sinfo_image_len() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_pre_serialize * @@ -1143,14 +1155,13 @@ 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 H5_ATTR_NDEBUG_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, - unsigned *flags) +H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_NDEBUG_UNUSED len, + 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 */ - haddr_t sinfo_addr; /* Address for section info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + H5FS_t * fspace; /* Free space header */ + haddr_t sinfo_addr; /* Address for section info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1170,20 +1181,16 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, HDassert(new_len); HDassert(flags); - /* we shouldn't be called if the section info is empty, unless we hit the point of no return. */ - if(!H5F_POINT_OF_NO_RETURN(f)) - HDassert(fspace->serial_sect_count > 0); - sinfo_addr = addr; /* this will change if we relocate the section data */ /* Check for section info at temporary address */ - if(H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { + if (H5F_IS_TMP_ADDR(f, fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); HDassert(H5F_addr_eq(fspace->sect_addr, addr)); /* Allocate space for the section info in file */ - if(HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) + if (HADDR_UNDEF == (sinfo_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FSPACE_SINFO, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; @@ -1192,20 +1199,20 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, HDassert(!H5F_addr_eq(sinfo->fspace->sect_addr, sinfo_addr)); /* Let the metadata cache know the section info moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FSPACE_SINFO, sinfo->fspace->sect_addr, sinfo_addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMOVE, FAIL, "unable to move section info") /* Update the internal address for the section info */ sinfo->fspace->sect_addr = sinfo_addr; /* Mark free space header as dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) + if (H5AC_mark_entry_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ - if(!H5F_addr_eq(addr, sinfo_addr)) { + if (!H5F_addr_eq(addr, sinfo_addr)) { *new_addr = sinfo_addr; - *flags = H5C__SERIALIZE_MOVED_FLAG; + *flags = H5C__SERIALIZE_MOVED_FLAG; } /* end if */ else *flags = 0; @@ -1214,7 +1221,6 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_serialize * @@ -1232,15 +1238,15 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, *------------------------------------------------------------------------- */ static herr_t -H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, - void *_thing) +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_iter_ud_t udata; /* User data for callbacks */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - unsigned bin; /* Current bin we are on */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + unsigned bin; /* Current bin we are on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1267,34 +1273,35 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, H5F_addr_encode(f, &image, sinfo->fspace->addr); /* Set up user data for iterator */ - udata.sinfo = sinfo; - udata.image = ℑ + udata.sinfo = sinfo; + udata.image = ℑ udata.sect_cnt_size = H5VM_limit_enc_size((uint64_t)sinfo->fspace->serial_sect_count); /* Iterate over all the bins */ - for(bin = 0; bin < sinfo->nbins; bin++) + for (bin = 0; bin < sinfo->nbins; bin++) /* Check if there are any sections in this bin */ - if(sinfo->bins[bin].bin_list) + if (sinfo->bins[bin].bin_list) /* Iterate over list of section size nodes for bin */ - if(H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0) + if (H5SL_iterate(sinfo->bins[bin].bin_list, H5FS__sinfo_serialize_node_cb, &udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes") - /* Compute checksum */ - metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); + /* There may be empty space between entries and chksum */ + chksum_image = (uint8_t *)(_image) + len - H5FS_SIZEOF_CHKSUM; + metadata_chksum = H5_checksum_metadata(_image, (size_t)(chksum_image - (uint8_t *)_image), 0); /* Metadata checksum */ - UINT32ENCODE(image, metadata_chksum); + UINT32ENCODE(chksum_image, metadata_chksum); /* Sanity check */ - HDassert((size_t)(image - (uint8_t *)_image) == sinfo->fspace->sect_size); + HDassert((chksum_image == image) || + ((size_t)((image - (uint8_t *)_image) + (chksum_image - image)) == sinfo->fspace->sect_size)); HDassert(sinfo->fspace->sect_size <= sinfo->fspace->alloc_sect_size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_serialize() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_notify * @@ -1310,8 +1317,8 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, herr_t H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1319,17 +1326,20 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) HDassert(sinfo); /* Check if the file was opened with SWMR-write access */ - if(sinfo->fspace->swmr_write) { + if (sinfo->fspace->swmr_write) { /* Determine which action to take */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ - if(H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)sinfo->fspace->sect_addr) + if (H5FS__create_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) + HGOTO_ERROR( + H5E_FSPACE, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and header, address = %llu", + (unsigned long long)sinfo->fspace->sect_addr) break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: @@ -1340,25 +1350,24 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - /* Destroy flush dependency on parent */ - if(H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) + /* Destroy flush dependency on parent */ + if (H5FS__destroy_flush_depend((H5AC_info_t *)sinfo->fspace, (H5AC_info_t *)sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__cache_sinfo_notify() */ +} /* end H5FS__cache_sinfo_notify() */ - /*------------------------------------------------------------------------- * Function: H5FS__cache_sinfo_free_icr * @@ -1380,8 +1389,8 @@ H5FS__cache_sinfo_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5FS__cache_sinfo_free_icr(void *_thing) { - H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1394,14 +1403,13 @@ H5FS__cache_sinfo_free_icr(void *_thing) HDassert(sinfo->fspace->cache_info.is_pinned); /* Destroy free space info */ - if(H5FS__sinfo_dest(sinfo) < 0) + if (H5FS__sinfo_dest(sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_serialize_sect_cb * @@ -1418,10 +1426,10 @@ H5FS__cache_sinfo_free_icr(void *_thing) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1434,7 +1442,7 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat sect_cls = &udata->sinfo->fspace->sect_cls[sect->type]; /* Check if this section should be serialized (i.e. is not a ghost section) */ - if(!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) { + if (!(sect_cls->flags & H5FS_CLS_GHOST_OBJ)) { /* The address of the section */ UINT64ENCODE_VAR(*udata->image, sect->addr, udata->sinfo->sect_off_size); @@ -1442,8 +1450,8 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat *(*udata->image)++ = (uint8_t)sect->type; /* Call 'serialize' callback for this section */ - if(sect_cls->serialize) { - if((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0) + if (sect_cls->serialize) { + if ((*sect_cls->serialize)(sect_cls, sect, *udata->image) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSERIALIZE, FAIL, "can't synchronize section") /* Update offset in serialization buffer */ @@ -1457,7 +1465,6 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_serialize_sect_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_serialize_node_cb * @@ -1474,9 +1481,9 @@ 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_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -1486,7 +1493,7 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat HDassert(udata->image); /* Check if this node has any serializable sections */ - if(fspace_node->serial_count > 0) { + if (fspace_node->serial_count > 0) { /* The number of serializable sections of this node's size */ UINT64ENCODE_VAR(*udata->image, fspace_node->serial_count, udata->sect_cnt_size); @@ -1495,11 +1502,10 @@ H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat /* Iterate through all the sections of this size */ HDassert(fspace_node->sect_list); - if(H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0) + if (H5SL_iterate(fspace_node->sect_list, H5FS__sinfo_serialize_sect_cb, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_serialize_node_cb() */ - diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index 9708e9e7d98..3862b53a005 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,56 +26,47 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ -#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ -#define H5MF_DEBUGGING /* Need access to file space debugging routines */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ +#define H5MF_DEBUGGING /* Need access to file space debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* File free space */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* File free space */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FS_debug * @@ -91,9 +82,9 @@ 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_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -107,16 +98,17 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = addr; + cache_udata.addr = addr; /* * Load the free space header. */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header") /* Print opening message */ @@ -125,55 +117,40 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Free space client:", - (fspace->client == H5FS_CLIENT_FHEAP_ID ? "Fractal heap" : - (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown"))); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total free space tracked:", - fspace->tot_space); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total number of free space sections tracked:", - fspace->tot_sect_count); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of serializable free space sections tracked:", - fspace->serial_sect_count); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of ghost free space sections tracked:", - fspace->ghost_sect_count); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Free space client:", + (fspace->client == H5FS_CLIENT_FHEAP_ID + ? "Fractal heap" + : (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown"))); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Total free space tracked:", fspace->tot_space); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Total number of free space sections tracked:", fspace->tot_sect_count); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of serializable free space sections tracked:", fspace->serial_sect_count); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Number of ghost free space sections tracked:", fspace->ghost_sect_count); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of free space section classes:", - (unsigned)fspace->nclasses); - HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, - "Shrink percent:", - fspace->shrink_percent); - HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, - "Expand percent:", - fspace->expand_percent); + "Number of free space section classes:", (unsigned)fspace->nclasses); + HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, "Shrink percent:", fspace->shrink_percent); + HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, "Expand percent:", fspace->expand_percent); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of bits for section address space:", - fspace->max_sect_addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Maximum section size:", - fspace->max_sect_size); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Serialized sections address:", - fspace->sect_addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Serialized sections size used:", - fspace->sect_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Serialized sections size allocated:", - fspace->alloc_sect_size); + "# of bits for section address space:", fspace->max_sect_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Maximum section size:", fspace->max_sect_size); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Serialized sections address:", fspace->sect_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Serialized sections size used:", fspace->sect_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, + "Serialized sections size allocated:", fspace->alloc_sect_size); done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_debug() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_debug * @@ -189,7 +166,7 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -203,15 +180,14 @@ H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *str HDassert(fwidth >= 0); /* Call the section's debugging routine */ - if(fspace->sect_cls[sect->type].debug) - if((fspace->sect_cls[sect->type].debug)(sect, stream, indent, fwidth) < 0) + if (fspace->sect_cls[sect->type].debug) + if ((fspace->sect_cls[sect->type].debug)(sect, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sect_debug() */ - /*------------------------------------------------------------------------- * Function: H5FS_sects_debug * @@ -225,13 +201,13 @@ H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *str *------------------------------------------------------------------------- */ 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_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_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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -247,16 +223,17 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent HDassert(H5F_addr_defined(client_addr)); /* Initialize user data for protecting the free space manager */ - cache_udata.f = f; - cache_udata.nclasses = 0; - cache_udata.classes = NULL; + cache_udata.f = f; + cache_udata.nclasses = 0; + cache_udata.classes = NULL; cache_udata.cls_init_udata = NULL; - cache_udata.addr = fs_addr; + cache_udata.addr = fs_addr; /* * Load the free space header. */ - if(NULL == (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == + (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header") /* Retrieve the client id */ @@ -266,7 +243,7 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent /* (set the "deleted" flag for the unprotect, so the cache entry is removed * and reloaded later, with the correct client information -QAK) */ - if(H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") fspace = NULL; @@ -276,14 +253,14 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent /* * Print the values. */ - switch(client) { + switch (client) { case H5FS_CLIENT_FHEAP_ID: - if(H5HF_sects_debug(f, client_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + if (H5HF_sects_debug(f, client_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump fractal heap free space sections") break; case H5FS_CLIENT_FILE_ID: - if(H5MF_sects_debug(f, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + if (H5MF_sects_debug(f, fs_addr, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_SYSTEM, FAIL, "unable to dump file free space sections") break; @@ -294,9 +271,8 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent } /* end switch */ done: - if(fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) + if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sects_debug() */ - diff --git a/src/H5FSint.c b/src/H5FSint.c index 926b8186584..0ab975b5895 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,57 +26,47 @@ /* Module Declaration */ /**********************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********************/ /* Other Packages Used */ /***********************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error Handling */ -#include "H5FSpkg.h" /* Free Space Managers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5FSpkg.h" /* Free Space Managers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5FS_init * @@ -94,7 +84,7 @@ herr_t H5FS_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOERR /* FUNC_ENTER() does all the work */ @@ -102,7 +92,6 @@ H5FS_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_init() */ - /*------------------------------------------------------------------------- * Function: H5FS__create_flush_depend * @@ -118,7 +107,7 @@ H5FS_init(void) herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -127,14 +116,13 @@ H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Create a flush dependency between parent and child entry */ - if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__create_flush_depend() */ +} /* end H5FS__create_flush_depend() */ - /*------------------------------------------------------------------------- * Function: H5FS__destroy_flush_depend * @@ -150,7 +138,7 @@ H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -159,10 +147,9 @@ H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) HDassert(child_entry); /* Destroy a flush dependency between parent and child entry */ - if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS__destroy_flush_depend() */ - +} /* end H5FS__destroy_flush_depend() */ diff --git a/src/H5FSmodule.h b/src/H5FSmodule.h index 88c663b4fc2..a40c1034d16 100644 --- a/src/H5FSmodule.h +++ b/src/H5FSmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5FS package. Including this header means that the source file * is part of the H5FS package. */ -#ifndef _H5FSmodule_H -#define _H5FSmodule_H +#ifndef H5FSmodule_H +#define H5FSmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5FS_MODULE -#define H5_MY_PKG H5FS -#define H5_MY_PKG_ERR H5E_FSPACE -#define H5_MY_PKG_INIT NO - -#endif /* _H5FSmodule_H */ +#define H5_MY_PKG H5FS +#define H5_MY_PKG_ERR H5E_FSPACE +#define H5_MY_PKG_INIT NO +#endif /* H5FSmodule_H */ diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 0cc328ef660..ba2cf03cdb1 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,8 +23,8 @@ #error "Do not include this file outside the H5FS package!" #endif -#ifndef _H5FSpkg_H -#define _H5FSpkg_H +#ifndef H5FSpkg_H +#define H5FSpkg_H /* Uncomment this macro to enable debugging output for free space manager */ /* #define H5FS_DEBUG */ @@ -36,90 +36,89 @@ /* #define H5FS_DEBUG_ASSERT */ /* Get package's private header */ -#include "H5FSprivate.h" /* File free space */ +#include "H5FSprivate.h" /* File free space */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of checksum information (on disk) */ -#define H5FS_SIZEOF_CHKSUM 4 +#define H5FS_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for free space metadata */ -#define H5FS_METADATA_PREFIX_SIZE ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + 1 /* Version */ \ - + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \ +#define H5FS_METADATA_PREFIX_SIZE \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + 1 /* Version */ \ + + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \ ) /* Size of the fractal heap header on disk */ -#define H5FS_HEADER_SIZE(f) ( \ - /* General metadata fields */ \ - H5FS_METADATA_PREFIX_SIZE \ - \ - /* Free space header specific fields */ \ - + 1 /* Client ID */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* # of ghost sections tracked */ \ - + 2 /* Number of section classes */ \ - + 2 /* Shrink percent */ \ - + 2 /* Expand percent */ \ - + 2 /* Size of address space for sections (log2 of value) */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \ - + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \ - + (unsigned)H5F_SIZEOF_SIZE(f) /* Allocated size of serialized free space sections */ \ +#define H5FS_HEADER_SIZE(f) \ + (/* General metadata fields */ \ + H5FS_METADATA_PREFIX_SIZE \ + \ + /* Free space header specific fields */ \ + + 1 /* Client ID */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* # of ghost sections tracked */ \ + + 2 /* Number of section classes */ \ + + 2 /* Shrink percent */ \ + + 2 /* Expand percent */ \ + + 2 /* Size of address space for sections (log2 of value) */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \ + + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \ + + (unsigned)H5F_SIZEOF_SIZE(f) /* Allocated size of serialized free space sections */ \ ) /* Size of the free space serialized sections on disk */ -#define H5FS_SINFO_PREFIX_SIZE(f) ( \ - /* General metadata fields */ \ - H5FS_METADATA_PREFIX_SIZE \ - \ - /* Free space serialized sections specific fields */ \ - + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of free space header for these sections */ \ +#define H5FS_SINFO_PREFIX_SIZE(f) \ + (/* General metadata fields */ \ + H5FS_METADATA_PREFIX_SIZE \ + \ + /* Free space serialized sections specific fields */ \ + + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of free space header for these sections */ \ ) - /****************************/ /* Package Private Typedefs */ /****************************/ /* 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 */ - 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 */ - haddr_t addr; /* Address of header */ + 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 */ + 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 */ - H5FS_t *fspace; /* free space manager */ + H5F_t * f; /* File that free space section info is within */ + H5FS_t *fspace; /* free space manager */ } H5FS_sinfo_cache_ud_t; /* Free space section bin info */ typedef struct H5FS_bin_t { - size_t tot_sect_count; /* Total # of sections in this bin */ - size_t serial_sect_count; /* # of serializable sections in this bin */ - size_t ghost_sect_count; /* # of un-serializable sections in this bin */ - H5SL_t *bin_list; /* Skip list of differently sized sections */ + size_t tot_sect_count; /* Total # of sections in this bin */ + size_t serial_sect_count; /* # of serializable sections in this bin */ + size_t ghost_sect_count; /* # of un-serializable sections in this bin */ + H5SL_t *bin_list; /* Skip list of differently sized sections */ } H5FS_bin_t; /* Free space node for free space sections of the same size */ typedef struct H5FS_node_t { - hsize_t sect_size; /* Size of all sections on list */ - size_t serial_count; /* # of serializable sections on list */ - size_t ghost_count; /* # of un-serializable sections on list */ - H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */ + hsize_t sect_size; /* Size of all sections on list */ + size_t serial_count; /* # of serializable sections on list */ + size_t ghost_count; /* # of un-serializable sections on list */ + H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */ } H5FS_node_t; /* Free space section info */ @@ -127,23 +126,23 @@ typedef struct H5FS_sinfo_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; -/* Stored information */ - H5FS_bin_t *bins; /* Array of lists of lists of free sections */ + /* Stored information */ + H5FS_bin_t *bins; /* Array of lists of lists of free sections */ -/* Computed/cached values */ - hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */ + /* Computed/cached values */ + hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */ unsigned nbins; /* Number of bins */ - size_t serial_size; /* Total size of all serializable sections */ - size_t tot_size_count; /* Total number of differently sized sections */ - size_t serial_size_count; /* Total number of differently sized serializable sections */ - size_t ghost_size_count; /* Total number of differently sized un-serializable sections */ + size_t serial_size; /* Total size of all serializable sections */ + size_t tot_size_count; /* Total number of differently sized sections */ + size_t serial_size_count; /* Total number of differently sized serializable sections */ + size_t ghost_size_count; /* Total number of differently sized un-serializable sections */ 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 */ + /* Memory data structures (not stored directly) */ + H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */ } H5FS_sinfo_t; /* Free space header info */ @@ -151,48 +150,46 @@ struct H5FS_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; -/* Stored information */ + /* Stored information */ /* Statistics about sections managed */ - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ + hsize_t tot_space; /* Total amount of space tracked */ + hsize_t tot_sect_count; /* Total # of sections tracked */ + hsize_t serial_sect_count; /* # of serializable sections tracked */ + hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ /* Creation parameters */ - H5FS_client_t client; /* Type of user of this free space manager */ - uint16_t nclasses; /* Number of section classes handled */ - unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ - unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ - unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ - hsize_t max_sect_size; /* Maximum size of section to track */ + H5FS_client_t client; /* Type of user of this free space manager */ + uint16_t nclasses; /* Number of section classes handled */ + unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ + unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ + unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ + hsize_t max_sect_size; /* Maximum size of section to track */ /* Serialized section information */ - haddr_t sect_addr; /* Address of the section info in the file */ - hsize_t sect_size; /* Size of the section info in the file */ - hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ - -/* Computed/cached values */ - unsigned rc; /* Count of outstanding references to struct */ - haddr_t addr; /* Address of free space header on disk */ - size_t hdr_size; /* Size of free space header on disk */ - H5FS_sinfo_t *sinfo; /* Section information */ - hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ - unsigned sinfo_lock_count; /* # of times the section info has been locked */ - hbool_t sinfo_protected; /* Whether the section info was protected when locked */ - hbool_t sinfo_modified; /* Whether the section info has been modified while locked */ - unsigned sinfo_accmode; /* Access mode for protecting the section info */ - /* must be either H5C__NO_FLAGS_SET (i.e r/w) */ - /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */ - size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ - hsize_t alignment; /* Alignment */ - hsize_t align_thres; /* Threshold for alignment */ - - -/* Memory data structures (not stored directly) */ + haddr_t sect_addr; /* Address of the section info in the file */ + hsize_t sect_size; /* Size of the section info in the file */ + hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ + + /* Computed/cached values */ + unsigned rc; /* Count of outstanding references to struct */ + haddr_t addr; /* Address of free space header on disk */ + size_t hdr_size; /* Size of free space header on disk */ + H5FS_sinfo_t *sinfo; /* Section information */ + hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ + unsigned sinfo_lock_count; /* # of times the section info has been locked */ + hbool_t sinfo_protected; /* Whether the section info was protected when locked */ + hbool_t sinfo_modified; /* Whether the section info has been modified while locked */ + unsigned sinfo_accmode; /* Access mode for protecting the section info */ + /* must be either H5C__NO_FLAGS_SET (i.e r/w) */ + /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */ + size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ + hsize_t alignment; /* Alignment */ + hsize_t align_thres; /* Threshold for alignment */ + + /* Memory data structures (not stored directly) */ H5FS_section_class_t *sect_cls; /* Array of section classes for this free list */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -209,7 +206,6 @@ H5FL_EXTERN(H5FS_sinfo_t); /* Declare a free list to manage the H5FS_t struct */ H5FL_EXTERN(H5FS_t); - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -219,11 +215,11 @@ H5_DLL herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t * H5_DLL herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Free space manager header routines */ -H5_DLL H5FS_t *H5FS__new(const H5F_t *f, uint16_t nclasses, - const H5FS_section_class_t *classes[], void *cls_init_udata); -H5_DLL herr_t H5FS__incr(H5FS_t *fspace); -H5_DLL herr_t H5FS__decr(H5FS_t *fspace); -H5_DLL herr_t H5FS__dirty(H5FS_t *fspace); +H5_DLL H5FS_t *H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], + void *cls_init_udata); +H5_DLL herr_t H5FS__incr(H5FS_t *fspace); +H5_DLL herr_t H5FS__decr(H5FS_t *fspace); +H5_DLL herr_t H5FS__dirty(H5FS_t *fspace); /* Free space section routines */ H5_DLL H5FS_sinfo_t *H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace); @@ -241,8 +237,7 @@ H5_DLL void H5FS__sect_assert(const H5FS_t *fspace); /* Testing routines */ #ifdef H5FS_TESTING H5_DLL herr_t H5FS__get_cparam_test(const H5FS_t *fh, H5FS_create_t *cparam); -H5_DLL int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2); +H5_DLL int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2); #endif /* H5FS_TESTING */ -#endif /* _H5FSpkg_H */ - +#endif /* H5FSpkg_H */ diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index e02a8e256ea..fdc5c912bc9 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,59 +22,67 @@ *------------------------------------------------------------------------- */ -#ifndef _H5FSprivate_H -#define _H5FSprivate_H +#ifndef H5FSprivate_H +#define H5FSprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Library Private Macros */ /**************************/ /* Flags for H5FS_section_class_t 'flags' field */ -#define H5FS_CLS_GHOST_OBJ 0x01 /* Objects in this class shouldn't be - * serialized to the file. - */ -#define H5FS_CLS_SEPAR_OBJ 0x02 /* Objects in this class shouldn't - * participate in merge operations. - */ -#define H5FS_CLS_MERGE_SYM 0x04 /* Objects in this class only merge - * with other objects in this class. - */ -#define H5FS_CLS_ADJUST_OK 0x08 /* Objects in this class can be merged - * without requiring a can_adjust/adjust - * callback pair. - */ +#define H5FS_CLS_GHOST_OBJ \ + 0x01 /* Objects in this class shouldn't be \ + * serialized to the file. \ + */ +#define H5FS_CLS_SEPAR_OBJ \ + 0x02 /* Objects in this class shouldn't \ + * participate in merge operations. \ + */ +#define H5FS_CLS_MERGE_SYM \ + 0x04 /* Objects in this class only merge \ + * with other objects in this class. \ + */ +#define H5FS_CLS_ADJUST_OK \ + 0x08 /* Objects in this class can be merged \ + * without requiring a can_adjust/adjust \ + * callback pair. \ + */ /* Flags for H5FS_add() */ -#define H5FS_ADD_DESERIALIZING 0x01 /* Free space is being deserialized - */ -#define H5FS_ADD_RETURNED_SPACE 0x02 /* Section was previously allocated - * and is being returned to the - * free space manager (usually - * as a result of freeing an - * object) - */ -#define H5FS_ADD_SKIP_VALID 0x04 /* Don't check validity after adding - * this section. (state of the - * managed sections is in flux) - */ - -#define H5FS_PAGE_END_NO_ADD 0x08 /* For "small" page fs: - * Don't add section to free space: - * when the section is at page end and - * when the section size is <= "small" - */ +#define H5FS_ADD_DESERIALIZING \ + 0x01 /* Free space is being deserialized \ + */ +#define H5FS_ADD_RETURNED_SPACE \ + 0x02 /* Section was previously allocated \ + * and is being returned to the \ + * free space manager (usually \ + * as a result of freeing an \ + * object) \ + */ +#define H5FS_ADD_SKIP_VALID \ + 0x04 /* Don't check validity after adding \ + * this section. (state of the \ + * managed sections is in flux) \ + */ + +#define H5FS_PAGE_END_NO_ADD \ + 0x08 /* For "small" page fs: \ + * Don't add section to free space: \ + * when the section is at page end and \ + * when the section size is <= "small" \ + */ /* Flags for deserialize callback */ -#define H5FS_DESERIALIZE_NO_ADD 0x01 /* Don't add section to free space - * manager after it's deserialized - * (its only here for it's side- - * effects). - */ - +#define H5FS_DESERIALIZE_NO_ADD \ + 0x01 /* Don't add section to free space \ + * manager after it's deserialized \ + * (its only here for it's side- \ + * effects). \ + */ /****************************/ /* Library Private Typedefs */ @@ -89,76 +97,83 @@ typedef struct H5FS_section_info_t H5FS_section_info_t; /* Free space section class info */ typedef struct H5FS_section_class_t { /* Class variables */ - 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 */ + 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 */ /* Class methods */ - herr_t (*init_cls)(struct H5FS_section_class_t *, void *); /* Routine to initialize class-specific settings */ - herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */ + herr_t (*init_cls)(struct H5FS_section_class_t *, + void *); /* Routine to initialize class-specific settings */ + herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */ /* Object methods */ - herr_t (*add)(H5FS_section_info_t **, unsigned *, void *); /* Routine called when section is about to be added to manager */ - herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, uint8_t *); /* Routine to serialize a "live" section into a buffer */ - H5FS_section_info_t *(*deserialize)(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 */ - 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 */ - herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */ - herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */ - herr_t (*valid)(const struct H5FS_section_class_t *, const H5FS_section_info_t *); /* Routine to check if a section is valid */ - H5FS_section_info_t *(*split)(H5FS_section_info_t *, hsize_t); /* Routine to create the split section */ - herr_t (*debug)(const H5FS_section_info_t *, FILE *, int , int ); /* Routine to dump debugging information about a section */ + herr_t (*add)(H5FS_section_info_t **, unsigned *, + void *); /* Routine called when section is about to be added to manager */ + herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, + uint8_t *); /* Routine to serialize a "live" section into a buffer */ + H5FS_section_info_t *(*deserialize)( + 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 */ + 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 */ + herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */ + herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */ + herr_t (*valid)(const struct H5FS_section_class_t *, + const H5FS_section_info_t *); /* Routine to check if a section is valid */ + H5FS_section_info_t *(*split)(H5FS_section_info_t *, hsize_t); /* Routine to create the split section */ + herr_t (*debug)(const H5FS_section_info_t *, FILE *, int, + int); /* Routine to dump debugging information about a section */ } H5FS_section_class_t; /* State of section ("live" or "serialized") */ typedef enum H5FS_section_state_t { - H5FS_SECT_LIVE, /* Section has "live" memory references */ - H5FS_SECT_SERIALIZED /* Section is in "serialized" form */ + H5FS_SECT_LIVE, /* Section has "live" memory references */ + H5FS_SECT_SERIALIZED /* Section is in "serialized" form */ } H5FS_section_state_t; /* Free space section info */ struct H5FS_section_info_t { - haddr_t addr; /* Offset of free space section in the address space */ - hsize_t size; /* Size of free space section */ - unsigned type; /* Type of free space section (i.e. class) */ - H5FS_section_state_t state; /* Whether the section is in "serialized" or "live" form */ + haddr_t addr; /* Offset of free space section in the address space */ + hsize_t size; /* Size of free space section */ + unsigned type; /* Type of free space section (i.e. class) */ + H5FS_section_state_t state; /* Whether the section is in "serialized" or "live" form */ }; /* Free space client IDs for identifying user of free space */ typedef enum H5FS_client_t { - H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */ - H5FS_CLIENT_FILE_ID, /* Free space is used by file */ - H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */ + H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */ + H5FS_CLIENT_FILE_ID, /* Free space is used by file */ + H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */ } H5FS_client_t; /* Free space creation parameters */ typedef struct H5FS_create_t { - H5FS_client_t client; /* Client's ID */ - unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ - unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ - unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ - hsize_t max_sect_size; /* Maximum size of section to track */ + H5FS_client_t client; /* Client's ID */ + unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ + unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ + unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ + hsize_t max_sect_size; /* Maximum size of section to track */ } H5FS_create_t; /* Free space statistics info */ typedef struct H5FS_stat_t { - hsize_t tot_space; /* Total amount of space tracked */ - hsize_t tot_sect_count; /* Total # of sections tracked */ - hsize_t serial_sect_count; /* # of serializable sections tracked */ - hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ - haddr_t addr; /* Address of free space header on disk */ - hsize_t hdr_size; /* Size of the free-space header on disk */ - haddr_t sect_addr; /* Address of the section info in the file */ - hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ - hsize_t sect_size; /* Size of the section info in the file */ + hsize_t tot_space; /* Total amount of space tracked */ + hsize_t tot_sect_count; /* Total # of sections tracked */ + hsize_t serial_sect_count; /* # of serializable sections tracked */ + hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ + haddr_t addr; /* Address of free space header on disk */ + hsize_t hdr_size; /* Size of the free-space header on disk */ + haddr_t sect_addr; /* Address of the section info in the file */ + hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ + hsize_t sect_size; /* Size of the section info in the file */ } H5FS_stat_t; /* Typedef for iteration operations */ -typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, - void *operator_data/*in,out*/); - +typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, void *operator_data /*in,out*/); /*****************************/ /* Library-private Variables */ @@ -167,7 +182,6 @@ typedef herr_t (*H5FS_operator_t)(H5FS_section_info_t *sect, /* Declare a free list to manage the H5FS_section_class_t sequence information */ H5FL_SEQ_EXTERN(H5FS_section_class_t); - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -176,52 +190,44 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t); H5_DLL herr_t H5FS_init(void); /* Free space manager routines */ -H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, - uint16_t nclasses, const H5FS_section_class_t *classes[], - void *cls_init_udata, hsize_t alignment, hsize_t threshold); -H5_DLL 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); -H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size); -H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr); -H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr); -H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space); +H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, + const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, + hsize_t threshold); +H5_DLL 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); +H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size); +H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr); +H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace); +H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr); +H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace); +H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space); /* Free space section routines */ -H5_DLL herr_t H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node, - unsigned flags, void *op_data); -H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, - H5FS_section_info_t *sect, unsigned flags, void *op_data); -H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, - hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data); +H5_DLL herr_t H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node, unsigned flags, + void *op_data); +H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, + void *op_data); +H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, + hsize_t extra_requested, unsigned flags, void *op_data); H5_DLL herr_t H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node); -H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, - H5FS_section_info_t **node); +H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node); H5_DLL herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data); -H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, - hsize_t *nsects); -H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, - H5FS_section_info_t *sect, uint16_t new_class); -H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, - void *op_data); +H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects); +H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class); +H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data); /* Statistics routine */ H5_DLL herr_t H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats); H5_DLL herr_t H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count); /* free space manager settling routines */ -H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, - haddr_t *fs_addr_ptr); +H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr_ptr); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); -H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, haddr_t fs_addr, haddr_t client_addr); -H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, - FILE *stream, int indent, int fwidth); - -#endif /* _H5FSprivate_H */ +H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, + haddr_t client_addr); +H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, + int fwidth); +#endif /* H5FSprivate_H */ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 1206839e8cd..6ba1bc34ee4 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,69 +23,60 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for skip list iterator callback for iterating over section size nodes */ typedef struct { - H5FS_t *fspace; /* Free space manager info */ - H5FS_operator_t op; /* Operator for the iteration */ - void *op_data; /* Information to pass to the operator */ + H5FS_t * fspace; /* Free space manager info */ + H5FS_operator_t op; /* Operator for the iteration */ + void * op_data; /* Information to pass to the operator */ } H5FS_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, - unsigned flags); +static herr_t H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags); static herr_t H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls); static herr_t H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node, - const H5FS_section_class_t *cls); + const H5FS_section_class_t *cls); static herr_t H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect); -static herr_t H5FS__sect_unlink_rest(H5FS_t *fspace, - const H5FS_section_class_t *cls, H5FS_section_info_t *sect); + H5FS_section_info_t *sect); +static herr_t H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, + H5FS_section_info_t *sect); static herr_t H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect); static herr_t H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect); -static herr_t H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect, unsigned flags); -static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, - unsigned flags); -static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, - void *op_data); + H5FS_section_info_t *sect); +static herr_t H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect, + unsigned flags); +static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags); +static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data); static htri_t H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node); static herr_t H5FS__sect_serialize_size(H5FS_t *fspace); - /*********************/ /* Package Variables */ /*********************/ @@ -99,18 +90,14 @@ H5FL_SEQ_DEFINE(H5FS_bin_t); /* Declare a free list to manage the H5FS_sinfo_t struct */ H5FL_DEFINE(H5FS_sinfo_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_new * @@ -127,8 +114,8 @@ H5FL_DEFINE(H5FS_sinfo_t); H5FS_sinfo_t * H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace) { - H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ - H5FS_sinfo_t *ret_value = NULL; /* Return value */ + H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ + H5FS_sinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -136,31 +123,33 @@ 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 = %a\n", FUNC, fspace->addr); #endif /* H5FS_SINFO_DEBUG */ /* Allocate the free space header */ - if(NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t))) + if (NULL == (sinfo = H5FL_CALLOC(H5FS_sinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set non-zero values */ - sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size); + sinfo->nbins = H5VM_log2_gen(fspace->max_sect_size); sinfo->sect_prefix_size = H5FS_SINFO_PREFIX_SIZE(f); - sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8; - sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size); + 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_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, sinfo->sect_off_size, sinfo->sect_len_size); + HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\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, + sinfo->sect_off_size, sinfo->sect_len_size); #endif /* H5FS_SINFO_DEBUG */ /* Allocate space for the section size bins */ - if(NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section bin array") + if (NULL == (sinfo->bins = H5FL_SEQ_CALLOC(H5FS_bin_t, (size_t)sinfo->nbins))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for free space section bin array") /* Increment the reference count on the free space manager header */ - if(H5FS__incr(fspace) < 0) + if (H5FS__incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") sinfo->fspace = fspace; @@ -173,9 +162,9 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", ret_value = sinfo; done: - if(ret_value == NULL && sinfo) { + if (ret_value == NULL && sinfo) { /* Release bins for skip lists */ - if(sinfo->bins) + if (sinfo->bins) sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); /* Release free space section info */ @@ -185,7 +174,6 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_new() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_lock * @@ -206,14 +194,16 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", static herr_t H5FS__sinfo_lock(H5F_t *f, H5FS_t *fspace, unsigned accmode) { - H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_sinfo_cache_ud_t cache_udata; /* User-data for cache callback */ + herr_t ret_value = SUCCEED; /* Return value */ 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 = %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); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -226,53 +216,58 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* If the free space header doesn't already "own" the section info, load * section info or create it */ - if(fspace->sinfo) { + if (fspace->sinfo) { /* Check if the section info was protected & we want a different access mode */ /* only H5AC__READ_ONLY_FLAG may appear in fspace->sinfo_accmode */ HDassert(((fspace->sinfo_accmode) & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); - if(fspace->sinfo_protected && accmode != fspace->sinfo_accmode) { + if (fspace->sinfo_protected && accmode != fspace->sinfo_accmode) { /* Check if we need to switch from read-only access to read-write */ - if(0 == (accmode & (unsigned)(~H5AC__READ_ONLY_FLAG))) { + if (0 == (accmode & (unsigned)(~H5AC__READ_ONLY_FLAG))) { /* Unprotect the read-only section info */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, + H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, + "unable to release free space section info") /* Re-protect the section info with read-write access */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect( + f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Switch the access mode we have */ fspace->sinfo_accmode = H5AC__NO_FLAGS_SET; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* If the section address is defined, load it from the file */ - if(H5F_addr_defined(fspace->sect_addr)) { + if (H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sinfo_protected == FALSE); HDassert(H5F_addr_defined(fspace->addr)); #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, + fspace->sect_addr); #endif /* H5FS_SINFO_DEBUG */ /* Protect the free space sections */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.fspace = fspace; - if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, &cache_udata, accmode))) + if (NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, + &cache_udata, accmode))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Remember that we protected the section info & the access mode */ fspace->sinfo_protected = TRUE; - fspace->sinfo_accmode = accmode; + fspace->sinfo_accmode = accmode; } /* end if */ else { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Creating new section info\n", FUNC); + HDfprintf(stderr, "%s: Creating new section info\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Sanity check */ HDassert(fspace->tot_sect_count == 0); @@ -280,13 +275,13 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC); HDassert(fspace->ghost_sect_count == 0); /* Allocate and initialize free space section info */ - if(NULL == (fspace->sinfo = H5FS__sinfo_new(f, fspace))) + if (NULL == (fspace->sinfo = H5FS__sinfo_new(f, fspace))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create section info") /* Set initial size of section info to 0 */ fspace->sect_size = fspace->alloc_sect_size = 0; } /* end if */ - } /* end if */ + } /* end if */ HDassert(fspace->rc == 2); /* Increment the section info lock count */ @@ -294,19 +289,34 @@ HDfprintf(stderr, "%s: Creating new section info\n", FUNC); 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 = %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); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_lock() */ - /*------------------------------------------------------------------------- * Function: H5FS__sinfo_unlock * * Purpose: Release the section info, either giving ownership back to * the cache or letting the free space header keep it. * + * Add the fix in this routine to resolve the potential infinite loop + * problem when allocating file space for the meta data of the + * self-referential free-space managers at file closing. + * + * On file close or flushing, when the section info is modified + * and protected/unprotected, does not allow the section info size + * to shrink: + * --if the current allocated section info size in fspace->sect_size is + * larger than the previous section info size in fpsace->alloc_sect_size, + * release the section info + * --Otherwise, set the fspace->sect_size to be the same as + * fpsace->alloc_sect_size. This means fspace->sect_size may be larger + * than what is actually needed. + * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol @@ -317,13 +327,18 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" static herr_t H5FS__sinfo_unlock(H5F_t *f, H5FS_t *fspace, hbool_t modified) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ 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: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\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: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\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", + 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); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -333,9 +348,9 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" HDassert(fspace->sinfo); /* Check if we modified any section */ - if(modified) { + if (modified) { /* Check if the section info was protected with a different access mode */ - if(fspace->sinfo_protected && (0 != ((fspace->sinfo_accmode) & H5AC__READ_ONLY_FLAG))) + if (fspace->sinfo_protected && (0 != ((fspace->sinfo_accmode) & H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDIRTY, FAIL, "attempt to modify read-only section info") /* If we modified the section info, mark it dirty */ @@ -347,7 +362,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* Assume that the modification will affect the statistics in the header * and mark that dirty also */ - if(H5FS__dirty(fspace) < 0) + if (H5FS__dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ @@ -355,23 +370,38 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" fspace->sinfo_lock_count--; /* Check if section info lock count dropped to zero */ - if(fspace->sinfo_lock_count == 0) { - hbool_t release_sinfo_space = FALSE; /* Flag to indicate section info space in file should be released */ + if (fspace->sinfo_lock_count == 0) { + hbool_t release_sinfo_space = + FALSE; /* Flag to indicate section info space in file should be released */ + hbool_t closing_or_flushing = f->shared->closing; /* Is closing or flushing in progress */ + + /* Check whether cache-flush is in progress if closing is not. */ + if (!closing_or_flushing && + H5AC_get_cache_flush_in_progress(f->shared->cache, &closing_or_flushing) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get flush_in_progress") /* Check if we actually protected the section info */ - if(fspace->sinfo_protected) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + if (fspace->sinfo_protected) { + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->addr)); /* Check if we've made new changes to the section info while locked */ - if(fspace->sinfo_modified) { + if (fspace->sinfo_modified) { /* Note that we've modified the section info */ cache_flags |= H5AC__DIRTIED_FLAG; - /* Check if the section info size in the file has changed */ - if(fspace->sect_size != fspace->alloc_sect_size) + /* On file close or flushing, does not allow section info to shrink in size */ + if (closing_or_flushing) { + if (fspace->sect_size > fspace->alloc_sect_size) + cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; + else + fspace->sect_size = fspace->alloc_sect_size; + + /* Check if the section info size in the file has changed */ + } + else if (fspace->sect_size != fspace->alloc_sect_size) cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; } /* end if */ @@ -383,87 +413,100 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* (Possibly dirty) */ /* (Possibly taking ownership from the cache) */ #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags); + HDfprintf(stderr, "%s: Unprotecting section info, cache_flags = %u\n", FUNC, cache_flags); #endif /* H5FS_SINFO_DEBUG */ - if(H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, cache_flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") /* Reset the protected flag on the section info */ fspace->sinfo_protected = FALSE; /* Check if header is taking ownership of section info */ - if((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) { + if ((cache_flags & H5AC__TAKE_OWNERSHIP_FLAG)) { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC); + HDfprintf(stderr, "%s: Taking ownership of section info\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Set flag to release section info space in file */ release_sinfo_space = TRUE; } /* end if */ else { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); + HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Free space header relinquished ownership of section info */ fspace->sinfo = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if the section info was modified */ - if(fspace->sinfo_modified) { + if (fspace->sinfo_modified) { /* Check if we need to release section info in the file */ - if(H5F_addr_defined(fspace->sect_addr)) + if (H5F_addr_defined(fspace->sect_addr)) { /* Set flag to release section info space in file */ - release_sinfo_space = TRUE; + /* On file close or flushing, only need to release section info with size + bigger than previous section */ + if (closing_or_flushing) { + if (fspace->sect_size > fspace->alloc_sect_size) + release_sinfo_space = TRUE; + else + fspace->sect_size = fspace->alloc_sect_size; + } + else + release_sinfo_space = TRUE; + } else HDassert(fspace->alloc_sect_size == 0); + } /* end if */ else { /* Sanity checks... */ - if(H5F_addr_defined(fspace->sect_addr)) + if (H5F_addr_defined(fspace->sect_addr)) HDassert(fspace->alloc_sect_size == fspace->sect_size); else HDassert(fspace->alloc_sect_size == 0); } /* end else */ - } /* end else */ + } /* end else */ /* Reset the "section info modified" flag */ fspace->sinfo_modified = FALSE; /* Check if header needs to release section info in the file */ - if(release_sinfo_space) { - haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ - hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ + if (release_sinfo_space) { + haddr_t old_sect_addr = fspace->sect_addr; /* Previous location of section info in file */ + hsize_t old_alloc_sect_size = fspace->alloc_sect_size; /* Previous size of section info in file */ /* Sanity check */ HDassert(H5F_addr_defined(fspace->addr)); /* Reset section info in header */ - fspace->sect_addr = HADDR_UNDEF; + fspace->sect_addr = HADDR_UNDEF; fspace->alloc_sect_size = 0; /* If we haven't already marked the header dirty, do so now */ - if(!modified) - if(H5FS__dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + if (!modified) + if (H5FS__dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", FUNC, old_sect_addr, old_alloc_sect_size); + HDfprintf(stderr, + "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", + FUNC, old_sect_addr, old_alloc_sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Release space for section info in file */ - if(!H5F_IS_TMP_ADDR(f, old_sect_addr)) - if(H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) + if (!H5F_IS_TMP_ADDR(f, old_sect_addr)) + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, old_sect_addr, old_alloc_sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") } /* end if */ - } /* end if */ + } /* end if */ done: #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_unlock() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_serialize_size * @@ -485,14 +528,15 @@ H5FS__sect_serialize_size(H5FS_t *fspace) HDassert(fspace); /* Compute the size of the buffer required to serialize all the sections */ - if(fspace->serial_sect_count > 0) { - size_t sect_buf_size; /* Section buffer size */ + if (fspace->serial_sect_count > 0) { + size_t sect_buf_size; /* Section buffer size */ /* Serialized sections prefix */ sect_buf_size = fspace->sinfo->sect_prefix_size; /* Count for each differently sized serializable section */ - sect_buf_size += fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); + sect_buf_size += + fspace->sinfo->serial_size_count * H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); /* Size for each differently sized serializable section */ sect_buf_size += fspace->sinfo->serial_size_count * fspace->sinfo->sect_len_size; @@ -516,7 +560,6 @@ H5FS__sect_serialize_size(H5FS_t *fspace) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS__sect_serialize_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_increase * @@ -531,10 +574,9 @@ H5FS__sect_serialize_size(H5FS_t *fspace) *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, - unsigned flags) +H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -547,7 +589,7 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, fspace->tot_sect_count++; /* Check for serializable or 'ghost' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Sanity check */ HDassert(cls->serial_size == 0); @@ -563,17 +605,16 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, /* Update the free space sections' serialized size */ /* (if we're not deserializing the sections from disk) */ - if(!(flags & H5FS_ADD_DESERIALIZING)) { - if(H5FS__sect_serialize_size(fspace) < 0) + if (!(flags & H5FS_ADD_DESERIALIZING)) { + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_increase() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_decrease * @@ -590,7 +631,7 @@ H5FS__sect_increase(H5FS_t *fspace, const H5FS_section_class_t *cls, static herr_t H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -603,7 +644,7 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) fspace->tot_sect_count--; /* Check for serializable or 'ghost' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Sanity check */ HDassert(cls->serial_size == 0); @@ -618,7 +659,7 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) fspace->sinfo->serial_size -= cls->serial_size; /* Update the free space sections' serialized size */ - if(H5FS__sect_serialize_size(fspace) < 0) + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") } /* end else */ @@ -626,7 +667,6 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_decrease() */ - /*------------------------------------------------------------------------- * Function: H5FS__size_node_decr * @@ -641,9 +681,9 @@ H5FS__sect_decrease(H5FS_t *fspace, const H5FS_section_class_t *cls) */ static herr_t H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node, - const H5FS_section_class_t *cls) + const H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -659,7 +699,7 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node sinfo->bins[bin].tot_sect_count--; /* Check for 'ghost' or 'serializable' section */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { /* Decrement node's ghost section count */ fspace_node->ghost_count--; @@ -667,7 +707,7 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node sinfo->bins[bin].ghost_sect_count--; /* If the node has no more ghost sections, decrement number of ghost section sizes managed */ - if(fspace_node->ghost_count == 0) + if (fspace_node->ghost_count == 0) sinfo->ghost_size_count--; } /* end if */ else { @@ -677,14 +717,15 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node /* Decrement bin's serializable section count */ sinfo->bins[bin].serial_sect_count--; - /* If the node has no more serializable sections, decrement number of serializable section sizes managed */ - if(fspace_node->serial_count == 0) + /* If the node has no more serializable sections, decrement number of serializable section sizes + * managed */ + if (fspace_node->serial_count == 0) sinfo->serial_size_count--; } /* end else */ /* Check for no more nodes on list of that size */ - if(H5SL_count(fspace_node->sect_list) == 0) { - H5FS_node_t *tmp_fspace_node; /* Free space list size node */ + if (H5SL_count(fspace_node->sect_list) == 0) { + H5FS_node_t *tmp_fspace_node; /* Free space list size node */ /* Sanity checks */ HDassert(fspace_node->ghost_count == 0); @@ -692,11 +733,11 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node /* Remove size tracking list from bin */ tmp_fspace_node = (H5FS_node_t *)H5SL_remove(sinfo->bins[bin].bin_list, &fspace_node->sect_size); - if(tmp_fspace_node == NULL || tmp_fspace_node != fspace_node) + if (tmp_fspace_node == NULL || tmp_fspace_node != fspace_node) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") /* Destroy skip list for size tracking node */ - if(H5SL_close(fspace_node->sect_list) < 0) + if (H5SL_close(fspace_node->sect_list) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size tracking node's skip list") /* Release free space list node */ @@ -710,7 +751,6 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__size_node_decr() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_unlink_size * @@ -725,13 +765,12 @@ 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__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_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 */ + 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 */ FUNC_ENTER_STATIC @@ -744,27 +783,26 @@ H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, /* Determine correct bin which holds items of at least the section's size */ bin = H5VM_log2_gen(sect->size); HDassert(bin < sinfo->nbins); - if(sinfo->bins[bin].bin_list == NULL) + if (sinfo->bins[bin].bin_list == NULL) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "node's bin is empty?") /* Find space node for section's size */ - if((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size)) == NULL) + if ((fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size)) == NULL) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section size node") /* Remove the section's node from the list */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace_node->sect_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(sinfo, bin, fspace_node, cls) < 0) + if (H5FS__size_node_decr(sinfo, bin, fspace_node, cls) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_unlink_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_unlink_rest * @@ -780,10 +818,9 @@ H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect) +H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -794,16 +831,16 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, HDassert(sect); /* Remove node from merge list, if it was entered there */ - if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { + if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") } /* end if */ /* Update section info & check if we need less room for the serialized free space sections */ - if(H5FS__sect_decrease(fspace, cls) < 0) + if (H5FS__sect_decrease(fspace, cls) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk") /* Decrement amount of free space managed */ @@ -813,7 +850,6 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_unlink_rest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_remove_real * @@ -829,8 +865,8 @@ H5FS__sect_unlink_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, static herr_t H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect) { - const H5FS_section_class_t *cls; /* Class of section */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *cls; /* Class of section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -843,18 +879,18 @@ H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect) cls = &fspace->sect_cls[sect->type]; /* Remove node from size tracked data structures */ - if(H5FS__sect_unlink_size(fspace->sinfo, cls, sect) < 0) + if (H5FS__sect_unlink_size(fspace->sinfo, cls, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from size tracking data structures") /* Update rest of free space manager data structures for node removal */ - if(H5FS__sect_unlink_rest(fspace, cls, sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__sect_unlink_rest(fspace, cls, sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_remove_real() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_remove * @@ -870,8 +906,8 @@ H5FS__sect_remove_real(H5FS_t *fspace, H5FS_section_info_t *sect) herr_t H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -881,23 +917,22 @@ H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) HDassert(sect); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Perform actual section removal */ - if(H5FS__sect_remove_real(fspace, sect) < 0) + if (H5FS__sect_remove_real(fspace, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove section") done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_remove() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link_size * @@ -911,13 +946,12 @@ H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect) +H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */ - hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */ - unsigned bin; /* Bin to put the free space section in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_node_t *fspace_node = NULL; /* Pointer to free space node of the correct size */ + hbool_t fspace_node_alloc = FALSE; /* Whether the free space node was allocated */ + unsigned bin; /* Bin to put the free space section in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -930,8 +964,8 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, /* Determine correct bin which holds items of the section's size */ bin = H5VM_log2_gen(sect->size); HDassert(bin < sinfo->nbins); - if(sinfo->bins[bin].bin_list == NULL) { - if(NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL))) + if (sinfo->bins[bin].bin_list == NULL) { + if (NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") } /* end if */ else @@ -939,20 +973,20 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, fspace_node = (H5FS_node_t *)H5SL_search(sinfo->bins[bin].bin_list, §->size); /* Check if we need to create a new skip list for nodes of this size */ - if(fspace_node == NULL) { + if (fspace_node == NULL) { /* Allocate new free list size node */ - if(NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t))) + if (NULL == (fspace_node = H5FL_MALLOC(H5FS_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for free space node") fspace_node_alloc = TRUE; /* Initialize the free list size node */ - fspace_node->sect_size = sect->size; + fspace_node->sect_size = sect->size; fspace_node->serial_count = fspace_node->ghost_count = 0; - if(NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") /* Insert new free space size node into bin's list */ - if(H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0) + if (H5SL_insert(sinfo->bins[bin].bin_list, fspace_node, &fspace_node->sect_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list") fspace_node_alloc = FALSE; /* (owned by the bin skip list now, don't need to free on error) */ @@ -965,12 +999,12 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, * the bin's skiplist is also a skiplist...) */ sinfo->bins[bin].tot_sect_count++; - if(cls->flags & H5FS_CLS_GHOST_OBJ) { + if (cls->flags & H5FS_CLS_GHOST_OBJ) { sinfo->bins[bin].ghost_sect_count++; fspace_node->ghost_count++; /* Check for first ghost section in node */ - if(fspace_node->ghost_count == 1) + if (fspace_node->ghost_count == 1) sinfo->ghost_size_count++; } /* end if */ else { @@ -978,26 +1012,26 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, fspace_node->serial_count++; /* Check for first serializable section in node */ - if(fspace_node->serial_count == 1) + if (fspace_node->serial_count == 1) sinfo->serial_size_count++; } /* end else */ /* Insert free space node into correct skip list */ - if(H5SL_insert(fspace_node->sect_list, sect, §->addr) < 0) + if (H5SL_insert(fspace_node->sect_list, sect, §->addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into skip list") done: - if(ret_value < 0) - if(fspace_node && fspace_node_alloc) { - if(fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy size free space node's skip list") + if (ret_value < 0) + if (fspace_node && fspace_node_alloc) { + if (fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, + "can't destroy size free space node's skip list") fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link_size() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link_rest * @@ -1012,10 +1046,10 @@ H5FS__sect_link_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, *------------------------------------------------------------------------- */ static herr_t -H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, - H5FS_section_info_t *sect, unsigned flags) +H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, H5FS_section_info_t *sect, + unsigned flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1025,16 +1059,18 @@ H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, HDassert(sect); /* Add section to the address-ordered list of sections, if allowed */ - if(!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { - if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") - if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") + if (!(cls->flags & H5FS_CLS_SEPAR_OBJ)) { + if (fspace->sinfo->merge_list == NULL) + if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, + "can't create skip list for merging free space sections") + if (H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space node into merging skip list") } /* end if */ /* Update section info & check if we need more room for the serialized free space sections */ - if(H5FS__sect_increase(fspace, cls, flags) < 0) + if (H5FS__sect_increase(fspace, cls, flags) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't increase free space section size on disk") /* Increment amount of free space managed */ @@ -1044,7 +1080,6 @@ H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link_rest() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_link * @@ -1060,8 +1095,8 @@ H5FS__sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, static herr_t H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) { - const H5FS_section_class_t *cls; /* Class of section */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *cls; /* Class of section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1074,18 +1109,18 @@ H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) cls = &fspace->sect_cls[sect->type]; /* Add section to size tracked data structures */ - if(H5FS__sect_link_size(fspace->sinfo, cls, sect) < 0) + if (H5FS__sect_link_size(fspace->sinfo, cls, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to size tracking data structures") /* Update rest of free space manager data structures for section addition */ - if(H5FS__sect_link_rest(fspace, cls, sect, flags) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't add section to non-size tracking data structures") + if (H5FS__sect_link_rest(fspace, cls, sect, flags) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't add section to non-size tracking data structures") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_link() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_merge * @@ -1102,11 +1137,11 @@ H5FS__sect_link(H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags) static herr_t H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) { - H5FS_section_class_t *sect_cls; /* Section's class */ - hbool_t modified; /* Flag to indicate merge or shrink occurred */ - hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */ - htri_t status; /* Status value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_class_t *sect_cls; /* Section's class */ + hbool_t modified; /* Flag to indicate merge or shrink occurred */ + hbool_t remove_sect = FALSE; /* Whether a section should be removed before shrinking */ + htri_t status; /* Status value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1117,13 +1152,13 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) HDassert((*sect)->size); /* Loop until no more merging */ - if(fspace->sinfo->merge_list) { + if (fspace->sinfo->merge_list) { do { - H5SL_node_t *less_sect_node; /* Skip list node for section less than new section */ - H5SL_node_t *greater_sect_node; /* Skip list node for section greater than new 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 */ + 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_class_t *tmp_sect_cls; /* Temporary section's class */ + hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */ /* Reset 'modification occurred' flag */ modified = FALSE; @@ -1132,9 +1167,9 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) less_sect_node = H5SL_below(fspace->sinfo->merge_list, &(*sect)->addr); /* Check for node before new node able to merge with new node */ - if(less_sect_node) { + if (less_sect_node) { /* Check for node greater than section */ - greater_sect_node = H5SL_next(less_sect_node); + greater_sect_node = H5SL_next(less_sect_node); greater_sect_node_valid = TRUE; /* Get section for 'less than' skip list node */ @@ -1142,85 +1177,88 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Get classes for right & left sections */ tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; - sect_cls = &fspace->sect_cls[(*sect)->type]; + sect_cls = &fspace->sect_cls[(*sect)->type]; /* Check if sections of the left most class can merge with sections * of another class & whether the sections are the same type, * then check for 'can merge' callback */ - if((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type)) - && tmp_sect_cls->can_merge) { + if ((!(tmp_sect_cls->flags & H5FS_CLS_MERGE_SYM) || (tmp_sect->type == (*sect)->type)) && + tmp_sect_cls->can_merge) { /* Determine if the sections can merge */ - if((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0) + if ((status = (*tmp_sect_cls->can_merge)(tmp_sect, *sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections") - if(status > 0) { + if (status > 0) { /* Sanity check */ HDassert(tmp_sect_cls->merge); /* Remove 'less than' node from data structures */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Merge the two sections together */ - if((*tmp_sect_cls->merge)(&tmp_sect, *sect, op_data) < 0) + if ((*tmp_sect_cls->merge)(&tmp_sect, *sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") /* Retarget section pointer to 'less than' node that was merged into */ *sect = tmp_sect; - if(*sect == NULL) - HGOTO_DONE(ret_value); + if (*sect == NULL) + HGOTO_DONE(ret_value); /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Look for section after new (or merged) section, if not already determined */ - if(!greater_sect_node_valid) + if (!greater_sect_node_valid) greater_sect_node = H5SL_above(fspace->sinfo->merge_list, &(*sect)->addr); /* Check for node after new node able to merge with new node */ - if(greater_sect_node) { + if (greater_sect_node) { /* Get section for 'greater than' skip list node */ tmp_sect = (H5FS_section_info_t *)H5SL_item(greater_sect_node); /* Get classes for right & left sections */ - sect_cls = &fspace->sect_cls[(*sect)->type]; + sect_cls = &fspace->sect_cls[(*sect)->type]; tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; /* Check if sections of the left most class can merge with sections * of another class & whether the sections are the same type, * then check for 'can merge' callback */ - if((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type)) - && sect_cls->can_merge) { + if ((!(sect_cls->flags & H5FS_CLS_MERGE_SYM) || ((*sect)->type == tmp_sect->type)) && + sect_cls->can_merge) { /* Determine if the sections can merge */ - if((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0) + if ((status = (*sect_cls->can_merge)(*sect, tmp_sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't check for merging sections") - if(status > 0) { + if (status > 0) { /* Sanity check */ HDassert(sect_cls->merge); /* Remove 'greater than' node from data structures */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Merge the two sections together */ - if((*sect_cls->merge)(sect, tmp_sect, op_data) < 0) + if ((*sect_cls->merge)(sect, tmp_sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't merge two sections") - /* It's possible that the merge caused the section to be deleted (particularly in the paged allocation case) */ - if(*sect == NULL) + /* It's possible that the merge caused the section to be deleted (particularly in the + * paged allocation case) */ + if (*sect == NULL) HGOTO_DONE(ret_value); /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } /* end if */ - } while(modified); + } /* end if */ + } /* end if */ + } while (modified); } /* end if */ HDassert(*sect); @@ -1231,32 +1269,33 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Check for (possibly merged) section able to shrink the size of the container */ sect_cls = &fspace->sect_cls[(*sect)->type]; - if(sect_cls->can_shrink) { - if((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0) + if (sect_cls->can_shrink) { + if ((status = (*sect_cls->can_shrink)(*sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container") - if(status > 0) { + if (status > 0) { /* Remove SECT from free-space manager */ /* (only possible to happen on second+ pass through loop) */ - if(remove_sect) { - if(H5FS__sect_remove_real(fspace, *sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (remove_sect) { + if (H5FS__sect_remove_real(fspace, *sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") remove_sect = FALSE; } /* end if */ /* Shrink the container */ /* (callback can indicate that it has discarded the section by setting *sect to NULL) */ HDassert(sect_cls->shrink); - if((*sect_cls->shrink)(sect, op_data) < 0) + if ((*sect_cls->shrink)(sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container") /* If this section was shrunk away, we may need to shrink another section */ - if(*sect == NULL) { + if (*sect == NULL) { /* Check for sections on merge list */ - if(fspace->sinfo->merge_list) { - H5SL_node_t *last_node; /* Last node in merge list */ + if (fspace->sinfo->merge_list) { + H5SL_node_t *last_node; /* Last node in merge list */ /* Check for last node in the merge list */ - if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { + if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { /* Get the pointer to the last section, from the last node */ *sect = (H5FS_section_info_t *)H5SL_item(last_node); HDassert(*sect); @@ -1264,24 +1303,23 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Indicate that this section needs to be removed if it causes a shrink */ remove_sect = TRUE; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Indicate successful merge occurred */ modified = TRUE; } /* end if */ - } /* end if */ - } while(modified && *sect); + } /* end if */ + } while (modified && *sect); /* Check for section that was shrunk away and next section not shrinking */ - if(remove_sect && (*sect != NULL)) + if (remove_sect && (*sect != NULL)) *sect = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_merge() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_add * @@ -1295,18 +1333,18 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) *------------------------------------------------------------------------- */ herr_t -H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, - void *op_data) +H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data) { - H5FS_section_class_t *cls; /* Section's class */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_section_class_t *cls; /* Section's class */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + herr_t ret_value = SUCCEED; /* Return value */ 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 = {%a, %Hu, %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. */ @@ -1316,24 +1354,24 @@ HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->siz HDassert(sect->size); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Call "add" section class callback, if there is one */ cls = &fspace->sect_cls[sect->type]; - if(cls->add) - if((*cls->add)(§, &flags, op_data) < 0) + if (cls->add) + if ((*cls->add)(§, &flags, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") /* Check for merging returned space with existing section node */ - if(flags & H5FS_ADD_RETURNED_SPACE) { + if (flags & H5FS_ADD_RETURNED_SPACE) { #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Returning space\n", FUNC); + HDfprintf(stderr, "%s: Returning space\n", FUNC); #endif /* H5FS_SINFO_DEBUG */ /* Attempt to merge returned section with existing sections */ - if(H5FS__sect_merge(fspace, §, op_data) < 0) + if (H5FS__sect_merge(fspace, §, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections") } /* end if */ @@ -1341,34 +1379,33 @@ HDfprintf(stderr, "%s: Returning space\n", FUNC); /* (If section has been completely merged or shrunk away, 'sect' will * be NULL at this point - QAK) */ - if(sect) - if(H5FS__sect_link(fspace, sect, flags) < 0) + if (sect) + if (H5FS__sect_link(fspace, sect, flags) < 0) 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 = %Hu\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) */ - if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_PAGE_END_NO_ADD))) + if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_PAGE_END_NO_ADD))) sinfo_modified = TRUE; done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") #ifdef H5FS_DEBUG_ASSERT -if(!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID))) - H5FS__assert(fspace); + if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID))) + H5FS__assert(fspace); #endif /* H5FS_DEBUG_ASSERT */ #ifdef H5FS_SINFO_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_add() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_extend * @@ -1382,17 +1419,18 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ htri_t -H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, - hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data) +H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize_t extra_requested, + unsigned flags, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + htri_t ret_value = FALSE; /* Return value */ 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 = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size, + extra_requested); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -1404,39 +1442,38 @@ HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, ad /* 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 = %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); #endif /* H5FS_SINFO_DEBUG */ - if(fspace->tot_sect_count > 0) { - H5FS_section_info_t *sect; /* Temporary free space section */ + if (fspace->tot_sect_count > 0) { + H5FS_section_info_t *sect; /* Temporary free space section */ /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; + /* -/* + Pseudo-code for algorithm: -Pseudo-code for algorithm: - -_section_ = _region.addr_> -if(_section_) - if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_) - - if(_section.size_ > _extra_requested_) - if() - - - else - - - - -*/ + _section_ = _region.addr_> + if(_section_) + if(_section_ adjoins _region_ && _section.size_ >= _extra_requested_) + + if(_section.size_ > _extra_requested_) + if() + + + else + + + + + */ /* Look for a section after block to extend */ - if((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) { + if ((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) { /* Check if this section adjoins the block and is large enough to * fulfill extension request. * @@ -1444,12 +1481,13 @@ if(_section_) * possible neighboring nodes and is not at the end of the file * (or it would have been eliminated), etc) */ - if(sect->size >= extra_requested && (addr + size) == sect->addr) { - H5FS_section_class_t *cls; /* Section's class */ + if (sect->size >= extra_requested && (addr + size) == sect->addr) { + H5FS_section_class_t *cls; /* Section's class */ /* Remove section from data structures */ - if(H5FS__sect_remove_real(fspace, sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") /* Get class for section */ cls = &fspace->sect_cls[sect->type]; @@ -1460,30 +1498,32 @@ if(_section_) * for the current usage, so I've deferred messing with * it. - QAK - 2008/01/08) */ - if(sect->size > extra_requested) { + if (sect->size > extra_requested) { /* Sanity check (for now) */ HDassert(cls->flags & H5FS_CLS_ADJUST_OK); /* Adjust section by amount requested */ sect->addr += extra_requested; sect->size -= extra_requested; - if(cls->add) - if((*cls->add)(§, &flags, op_data) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "'add' section class callback failed") + if (cls->add) + if ((*cls->add)(§, &flags, op_data) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "'add' section class callback failed") /* Re-adding the section could cause it to disappear (particularly when paging) */ - if(sect) { + if (sect) { /* Re-add adjusted section to free sections data structures */ - if(H5FS__sect_link(fspace, sect, 0) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if (H5FS__sect_link(fspace, sect, 0) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") } /* end if */ - } /* end if */ + } /* end if */ else { /* Sanity check */ HDassert(sect->size == extra_requested); /* Exact match, so just free section */ - if((*cls->free)(sect) < 0) + if ((*cls->free)(sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't free section") } /* end else */ @@ -1493,18 +1533,17 @@ if(_section_) /* Indicate success */ HGOTO_DONE(TRUE); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_extend() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_merge * @@ -1520,13 +1559,12 @@ if(_section_) *------------------------------------------------------------------------- */ htri_t -H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, - unsigned flags, void *op_data) +H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - hsize_t saved_fs_size; /* Copy of the free-space section size */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + hsize_t saved_fs_size; /* Copy of the free-space section size */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1538,39 +1576,39 @@ H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, HDassert(sect->size); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") - sinfo_valid = TRUE; + sinfo_valid = TRUE; saved_fs_size = sect->size; /* Attempt to merge/shrink section with existing sections */ - if(H5FS__sect_merge(fspace, §, op_data) < 0) + if (H5FS__sect_merge(fspace, §, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMERGE, FAIL, "can't merge sections") /* Check if section is shrunk and/or merged away completely */ - if(!sect) { + if (!sect) { sinfo_modified = TRUE; HGOTO_DONE(TRUE) } /* end if */ else { /* Check if section is merged */ - if(sect->size > saved_fs_size) { - if(H5FS__sect_link(fspace, sect, flags) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if (sect->size > saved_fs_size) { + if (H5FS__sect_link(fspace, sect, flags) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") sinfo_modified = TRUE; HGOTO_DONE(TRUE) } /* end if */ - } /* end else */ + } /* end else */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_merge() */ - /*------------------------------------------------------------------------- * Function: H5FS__sect_find_node * @@ -1587,13 +1625,13 @@ H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, static htri_t H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node) { - H5FS_node_t *fspace_node; /* Free list size node */ - unsigned bin; /* Bin to put the free space section in */ - htri_t ret_value = FALSE; /* Return value */ + H5FS_node_t *fspace_node; /* Free list size 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; - const H5FS_section_class_t *cls; /* Class of section */ - hsize_t alignment; + H5SL_node_t * curr_size_node = NULL; + const H5FS_section_class_t *cls; /* Class of section */ + hsize_t alignment; FUNC_ENTER_STATIC @@ -1608,12 +1646,12 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node bin = H5VM_log2_gen(request); HDassert(bin < fspace->sinfo->nbins); alignment = fspace->alignment; - if(!((alignment > 1) && (request >= fspace->align_thres))) + if (!((alignment > 1) && (request >= fspace->align_thres))) alignment = 0; /* no alignment */ do { /* Check if there's any sections in this bin */ - if(fspace->sinfo->bins[bin].bin_list) { + if (fspace->sinfo->bins[bin].bin_list) { if (!alignment) { /* no alignment */ /* Find the first free space section that is large enough to fulfill request */ @@ -1621,28 +1659,32 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node * lists, this is actually a "best fit" algorithm) */ /* Look for large enough free space section in this bin */ - if((fspace_node = (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) { + if ((fspace_node = + (H5FS_node_t *)H5SL_greater(fspace->sinfo->bins[bin].bin_list, &request))) { /* Take first node off of the list (ie. node w/lowest address) */ - if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") + if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove_first(fspace_node->sect_list))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space node from skip list") /* Get section's class */ cls = &fspace->sect_cls[(*node)->type]; /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") - if(H5FS__sect_unlink_rest(fspace, cls, *node) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__size_node_decr(fspace->sinfo, bin, fspace_node, cls) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space size node from skip list") + if (H5FS__sect_unlink_rest(fspace, cls, *node) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") /* Indicate that we found a node for the request */ HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* alignment is set */ /* get the first node of a certain size in this bin */ curr_size_node = H5SL_first(fspace->sinfo->bins[bin].bin_list); while (curr_size_node != NULL) { - H5FS_node_t *curr_fspace_node=NULL; - H5SL_node_t *curr_sect_node=NULL; + H5FS_node_t *curr_fspace_node = NULL; + H5SL_node_t *curr_sect_node = NULL; /* Get the free space node for free space sections of the same size */ curr_fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); @@ -1650,10 +1692,10 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node /* Get the Skip list which holds pointers to actual free list sections */ curr_sect_node = (H5SL_node_t *)H5SL_first(curr_fspace_node->sect_list); - while(curr_sect_node != NULL) { - H5FS_section_info_t *curr_sect=NULL; - hsize_t mis_align=0, frag_size=0; - H5FS_section_info_t *split_sect=NULL; + while (curr_sect_node != NULL) { + H5FS_section_info_t *curr_sect = NULL; + hsize_t mis_align = 0, frag_size = 0; + H5FS_section_info_t *split_sect = NULL; /* Get section node */ curr_sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); @@ -1666,19 +1708,23 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node HDassert(alignment); HDassert(cls); - if((mis_align = curr_sect->addr % alignment)) + if ((mis_align = curr_sect->addr % alignment)) frag_size = alignment - mis_align; - if((curr_sect->size >= (request + frag_size)) && (cls->split)) { + if ((curr_sect->size >= (request + frag_size)) && (cls->split)) { /* remove the section with aligned address */ - if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove(curr_fspace_node->sect_list, &curr_sect->addr))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") + if (NULL == (*node = (H5FS_section_info_t *)H5SL_remove( + curr_fspace_node->sect_list, &curr_sect->addr))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space node from skip list") /* Decrement # of sections in section size node */ - if(H5FS__size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space size node from skip list") + if (H5FS__size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, + "can't remove free space size node from skip list") - if(H5FS__sect_unlink_rest(fspace, cls, *node) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") + if (H5FS__sect_unlink_rest(fspace, cls, *node) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, + "can't remove section from non-size tracking data structures") /* * The split() callback splits NODE into 2 sections: @@ -1686,10 +1732,11 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node * NODE's addr & size are updated to point to the remaining aligned section * split_sect is re-added to free-space */ - if(mis_align) { + if (mis_align) { split_sect = cls->split(*node, frag_size); - if((H5FS__sect_link(fspace, split_sect, 0) < 0)) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") + if ((H5FS__sect_link(fspace, split_sect, 0) < 0)) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space section into skip list") /* sanity check */ HDassert(split_sect->addr < (*node)->addr); HDassert(request <= (*node)->size); @@ -1705,17 +1752,16 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node /* Get the next size node in the bin */ curr_size_node = H5SL_next(curr_size_node); } /* end while of curr_size_node */ - } /* else of alignment */ - } /* if bin_list */ + } /* else of alignment */ + } /* if bin_list */ /* Advance to next larger bin */ bin++; - } while(bin < fspace->sinfo->nbins); + } while (bin < fspace->sinfo->nbins); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sect_find_node() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_find * @@ -1732,9 +1778,9 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t sinfo_modified = FALSE; /* Whether the section info was modified */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1745,26 +1791,26 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** HDassert(node); /* Check for any sections on free space list */ - if(fspace->tot_sect_count > 0) { + if (fspace->tot_sect_count > 0) { /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Look for node in bins */ - if((ret_value = H5FS__sect_find_node(fspace, request, node)) < 0) + if ((ret_value = H5FS__sect_find_node(fspace, request, node)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from bins") /* Decrement # of sections on free list, if we found an object */ - if(ret_value > 0) { + if (ret_value > 0) { /* Note that we've modified the section info */ sinfo_modified = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") #ifdef H5FS_DEBUG_ASSERT @@ -1773,9 +1819,8 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_find() */ - /*------------------------------------------------------------------------- - * Function: H5FS_iterate_sect_cb + * Function: H5FS__iterate_sect_cb * * Purpose: Skip list iterator callback to iterate over free space sections * of a particular size @@ -1788,13 +1833,13 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** *------------------------------------------------------------------------- */ static herr_t -H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect_info); @@ -1802,16 +1847,15 @@ H5FS_iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) HDassert(udata->op); /* Make callback for this section */ - if((*udata->op)(sect_info, udata->op_data) < 0) + if ((*udata->op)(sect_info, udata->op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "iteration callback failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FS_iterate_sect_cb() */ +} /* H5FS__iterate_sect_cb() */ - /*------------------------------------------------------------------------- - * Function: H5FS_iterate_node_cb + * Function: H5FS__iterate_node_cb * * Purpose: Skip list iterator callback to iterate over free space sections * in a bin @@ -1824,13 +1868,13 @@ 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__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_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(fspace_node); @@ -1839,14 +1883,13 @@ H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) /* Iterate through all the sections of this size */ HDassert(fspace_node->sect_list); - if(H5SL_iterate(fspace_node->sect_list, H5FS_iterate_sect_cb, udata) < 0) + if (H5SL_iterate(fspace_node->sect_list, H5FS__iterate_sect_cb, udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section nodes") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FS_iterate_node_cb() */ +} /* H5FS__iterate_node_cb() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_iterate * @@ -1862,9 +1905,9 @@ H5FS_iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) { - H5FS_iter_ud_t udata; /* User data for callbacks */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FS_iter_ud_t udata; /* User data for callbacks */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1873,39 +1916,38 @@ H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) HDassert(op); /* Set up user data for iterator */ - udata.fspace = fspace; - udata.op = op; + udata.fspace = fspace; + udata.op = op; udata.op_data = op_data; /* Iterate over sections, if there are any */ - if(fspace->tot_sect_count) { - unsigned bin; /* Current bin we are on */ + if (fspace->tot_sect_count) { + unsigned bin; /* Current bin we are on */ /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__READ_ONLY_FLAG) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Iterate over all the bins */ - for(bin = 0; bin < fspace->sinfo->nbins; bin++) { + for (bin = 0; bin < fspace->sinfo->nbins; bin++) { /* Check if there are any sections in this bin */ - if(fspace->sinfo->bins[bin].bin_list) { + if (fspace->sinfo->bins[bin].bin_list) { /* Iterate over list of section size nodes for bin */ - if(H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS_iterate_node_cb, &udata) < 0) + if (H5SL_iterate(fspace->sinfo->bins[bin].bin_list, H5FS__iterate_node_cb, &udata) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over section size nodes") } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, FALSE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, FALSE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_iterate() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_stats * @@ -1927,15 +1969,14 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects) HDassert(fspace); /* Get the stats desired */ - if(tot_space) + if (tot_space) *tot_space = fspace->tot_space; - if(nsects) + if (nsects) *nsects = fspace->tot_sect_count; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS_sect_stats() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_change_class * @@ -1950,14 +1991,13 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects) *------------------------------------------------------------------------- */ herr_t -H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, - uint16_t new_class) +H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class) { - const H5FS_section_class_t *old_cls; /* Old class of section */ - const H5FS_section_class_t *new_cls; /* New class of section */ - unsigned old_class; /* Old class ID of section */ - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *old_cls; /* Old class of section */ + const H5FS_section_class_t *new_cls; /* New class of section */ + unsigned old_class; /* Old class ID of section */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1968,23 +2008,23 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, HDassert(new_class < fspace->nclasses); /* Get a pointer to the section info */ - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; /* Get class info */ old_class = sect->type; - old_cls = &fspace->sect_cls[sect->type]; - new_cls = &fspace->sect_cls[new_class]; + old_cls = &fspace->sect_cls[sect->type]; + new_cls = &fspace->sect_cls[new_class]; /* Check if the section's class change will affect the # of serializable or ghost sections */ - if((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) { - H5FS_node_t *fspace_node; /* Free list size node */ - unsigned bin; /* Bin to put the free space section in */ - hbool_t to_ghost; /* Flag if the section is changing to a ghost section */ + if ((old_cls->flags & H5FS_CLS_GHOST_OBJ) != (new_cls->flags & H5FS_CLS_GHOST_OBJ)) { + H5FS_node_t *fspace_node; /* Free list size node */ + unsigned bin; /* Bin to put the free space section in */ + hbool_t to_ghost; /* Flag if the section is changing to a ghost section */ /* Determine if this section is becoming a ghost or is becoming serializable */ - if(old_cls->flags & H5FS_CLS_GHOST_OBJ) + if (old_cls->flags & H5FS_CLS_GHOST_OBJ) to_ghost = FALSE; else to_ghost = TRUE; @@ -2002,7 +2042,7 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, HDassert(fspace_node); /* Adjust serializable/ghost counts */ - if(to_ghost) { + if (to_ghost) { /* Adjust global section count totals */ fspace->serial_sect_count--; fspace->ghost_sect_count++; @@ -2016,9 +2056,9 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, fspace_node->ghost_count++; /* Check if we switched a section size node's status */ - if(fspace_node->serial_count == 0) + if (fspace_node->serial_count == 0) fspace->sinfo->serial_size_count--; - if(fspace_node->ghost_count == 1) + if (fspace_node->ghost_count == 1) fspace->sinfo->ghost_size_count++; } /* end if */ else { @@ -2035,39 +2075,41 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, fspace_node->ghost_count--; /* Check if we switched a section size node's status */ - if(fspace_node->serial_count == 1) + if (fspace_node->serial_count == 1) fspace->sinfo->serial_size_count++; - if(fspace_node->ghost_count == 0) + if (fspace_node->ghost_count == 0) fspace->sinfo->ghost_size_count--; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the section's class change will affect the mergable 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 */ + 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 */ /* Determine if this section is becoming mergable or is becoming separate */ - if(old_cls->flags & H5FS_CLS_SEPAR_OBJ) + if (old_cls->flags & H5FS_CLS_SEPAR_OBJ) to_mergable = TRUE; else to_mergable = FALSE; /* Add or remove section from merge list, as appropriate */ - if(to_mergable) { - if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") - if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") + if (to_mergable) { + if (fspace->sinfo->merge_list == NULL) + if (NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, + "can't create skip list for merging free space sections") + if (H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, + "can't insert free space node into merging skip list") } /* end if */ else { H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ tmp_sect_node = (H5FS_section_info_t *)H5SL_remove(fspace->sinfo->merge_list, §->addr); - if(tmp_sect_node == NULL || tmp_sect_node != sect) + if (tmp_sect_node == NULL || tmp_sect_node != sect) HGOTO_ERROR(H5E_FSPACE, H5E_NOTFOUND, FAIL, "can't find section node on size list") } /* end else */ - } /* end if */ + } /* end if */ /* Change the section's class */ sect->type = new_class; @@ -2077,19 +2119,19 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, fspace->sinfo->serial_size += fspace->sect_cls[new_class].serial_size; /* Update current space used for free space sections */ - if(H5FS__sect_serialize_size(fspace) < 0) + if (H5FS__sect_serialize_size(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCOMPUTE, FAIL, "can't adjust free space section size on disk") done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_change_class() */ #ifdef H5FS_DEBUG_ASSERT - + /*------------------------------------------------------------------------- * Function: H5FS__sect_assert * @@ -2105,7 +2147,7 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, void H5FS__sect_assert(const H5FS_t *fspace) { - hsize_t separate_obj; /* The number of separate objects managed */ + hsize_t separate_obj; /* The number of separate objects managed */ FUNC_ENTER_PACKAGE_NOERR @@ -2113,72 +2155,72 @@ H5FS__sect_assert(const H5FS_t *fspace) separate_obj = 0; /* Check for bins to work on */ - if(fspace->sinfo->bins) { - hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */ - hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */ - hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */ - size_t acc_tot_size_count; /* Accumulated total section size count from bins */ - size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */ - size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */ - unsigned u; /* Local index variable */ + if (fspace->sinfo->bins) { + hsize_t acc_tot_sect_count; /* Accumulated total section count from bins */ + hsize_t acc_serial_sect_count; /* Accumulated serializable section count from bins */ + hsize_t acc_ghost_sect_count; /* Accumulated ghost section count from bins */ + size_t acc_tot_size_count; /* Accumulated total section size count from bins */ + size_t acc_serial_size_count; /* Accumulated serializable section size count from bins */ + size_t acc_ghost_size_count; /* Accumulated ghost section size count from bins */ + unsigned u; /* Local index variable */ /* Walk through all sections in bins */ - acc_tot_sect_count = 0; + acc_tot_sect_count = 0; acc_serial_sect_count = 0; - acc_ghost_sect_count = 0; - acc_tot_size_count = 0; + acc_ghost_sect_count = 0; + acc_tot_size_count = 0; acc_serial_size_count = 0; - acc_ghost_size_count = 0; - for(u = 0; u < fspace->sinfo->nbins; u++) { + acc_ghost_size_count = 0; + for (u = 0; u < fspace->sinfo->nbins; u++) { acc_tot_sect_count += fspace->sinfo->bins[u].tot_sect_count; acc_serial_sect_count += fspace->sinfo->bins[u].serial_sect_count; acc_ghost_sect_count += fspace->sinfo->bins[u].ghost_sect_count; - if(fspace->sinfo->bins[u].bin_list) { - H5SL_node_t *curr_size_node; /* Current section size node in skip list */ - size_t bin_serial_count; /* # of serializable sections in this bin */ - size_t bin_ghost_count; /* # of ghost sections in this bin */ + if (fspace->sinfo->bins[u].bin_list) { + H5SL_node_t *curr_size_node; /* Current section size node in skip list */ + size_t bin_serial_count; /* # of serializable sections in this bin */ + size_t bin_ghost_count; /* # of ghost sections in this bin */ acc_tot_size_count += H5SL_count(fspace->sinfo->bins[u].bin_list); /* Walk through the sections in this bin */ - curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list); + curr_size_node = H5SL_first(fspace->sinfo->bins[u].bin_list); bin_serial_count = 0; - bin_ghost_count = 0; - while(curr_size_node != NULL) { + bin_ghost_count = 0; + while (curr_size_node != NULL) { H5FS_node_t *fspace_node; /* Section size node */ H5SL_node_t *curr_sect_node; /* Current section node in skip list */ - size_t size_serial_count; /* # of serializable sections of this size */ - size_t size_ghost_count; /* # of ghost sections of this size */ + size_t size_serial_count; /* # of serializable sections of this size */ + size_t size_ghost_count; /* # of ghost sections of this size */ /* Get section size node */ fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); /* Check sections on list */ - curr_sect_node = H5SL_first(fspace_node->sect_list); + curr_sect_node = H5SL_first(fspace_node->sect_list); size_serial_count = 0; - size_ghost_count = 0; - while(curr_sect_node != NULL) { - H5FS_section_class_t *cls; /* Class of section */ - H5FS_section_info_t *sect; /* Section */ + size_ghost_count = 0; + while (curr_sect_node != NULL) { + H5FS_section_class_t *cls; /* Class of section */ + H5FS_section_info_t * sect; /* Section */ /* Get section node & it's class */ sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); - cls = &fspace->sect_cls[sect->type]; + cls = &fspace->sect_cls[sect->type]; /* Sanity check section */ HDassert(H5F_addr_defined(sect->addr)); HDassert(fspace_node->sect_size == sect->size); - if(cls->valid) + if (cls->valid) (*cls->valid)(cls, sect); /* Add to correct count */ - if(cls->flags & H5FS_CLS_GHOST_OBJ) + if (cls->flags & H5FS_CLS_GHOST_OBJ) size_ghost_count++; else size_serial_count++; /* Count node, if separate */ - if(cls->flags & H5FS_CLS_SEPAR_OBJ) + if (cls->flags & H5FS_CLS_SEPAR_OBJ) separate_obj++; /* Get the next section node in the list */ @@ -2190,9 +2232,9 @@ H5FS__sect_assert(const H5FS_t *fspace) HDassert(fspace_node->ghost_count == size_ghost_count); /* Add to global count of serializable & ghost section sizes */ - if(fspace_node->serial_count > 0) + if (fspace_node->serial_count > 0) acc_serial_size_count++; - if(fspace_node->ghost_count > 0) + if (fspace_node->ghost_count > 0) acc_ghost_size_count++; /* Add to bin's serializable & ghost counts */ @@ -2208,7 +2250,7 @@ H5FS__sect_assert(const H5FS_t *fspace) HDassert(fspace->sinfo->bins[u].serial_sect_count == bin_serial_count); HDassert(fspace->sinfo->bins[u].ghost_sect_count == bin_ghost_count); } /* end if */ - } /* end for */ + } /* end for */ /* Check counts from bins vs. global counts */ HDassert(fspace->sinfo->tot_size_count == acc_tot_size_count); @@ -2226,14 +2268,13 @@ H5FS__sect_assert(const H5FS_t *fspace) } /* end else */ /* Make certain that the number of sections on the address list is correct */ - if(fspace->sinfo->merge_list) + if (fspace->sinfo->merge_list) HDassert(fspace->tot_sect_count == (separate_obj + H5SL_count(fspace->sinfo->merge_list))); FUNC_LEAVE_NOAPI_VOID } /* end H5FS__sect_assert() */ #endif /* H5FS_DEBUG_ASSERT */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_try_shrink_eoa * @@ -2249,141 +2290,88 @@ H5FS__sect_assert(const H5FS_t *fspace) htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data) { - hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ - hbool_t section_removed = FALSE; /* Whether a section was removed */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t sinfo_valid = FALSE; /* Whether the section info is valid */ + hbool_t section_removed = FALSE; /* Whether a section was removed */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments. */ HDassert(fspace); - if(H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) + if (H5FS__sinfo_lock(f, fspace, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't get section info") sinfo_valid = TRUE; - if(fspace->sinfo && fspace->sinfo->merge_list) { - H5SL_node_t *last_node; /* Last node in merge list */ + if (fspace->sinfo && fspace->sinfo->merge_list) { + H5SL_node_t *last_node; /* Last node in merge list */ /* 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_class_t *tmp_sect_cls; /* Temporary section's class */ + if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { + 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 */ tmp_sect = (H5FS_section_info_t *)H5SL_item(last_node); HDassert(tmp_sect); tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; - if(tmp_sect_cls->can_shrink) { + if (tmp_sect_cls->can_shrink) { /* Check if the section can be shrunk away */ - if((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0) + if ((ret_value = (*tmp_sect_cls->can_shrink)(tmp_sect, op_data)) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTSHRINK, FAIL, "can't check for shrinking container") - if(ret_value > 0) { + if (ret_value > 0) { HDassert(tmp_sect_cls->shrink); /* Remove section from free space manager */ - if(H5FS__sect_remove_real(fspace, tmp_sect) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + if (H5FS__sect_remove_real(fspace, tmp_sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, + "can't remove section from internal data structures") section_removed = TRUE; /* Shrink away section */ - if((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0) + if ((*tmp_sect_cls->shrink)(&tmp_sect, op_data) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't shrink free space container") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ done: /* Release the section info */ - if(sinfo_valid && H5FS__sinfo_unlock(f, fspace, section_removed) < 0) + if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, section_removed) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_shrink_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FS_vfd_alloc_hdr_and_section_info_if_needed * - * Purpose: This function is part of a hack to patch over a design - * flaw in the free space managers for file space allocation. - * Specifically, if a free space manager allocates space for - * its own section info, it is possible for it to - * go into an infinite loop as it: - * - * 1) computes the size of the section info - * - * 2) allocates file space for the section info - * - * 3) notices that the size of the section info - * has changed - * - * 4) deallocates the section info file space and - * returns to 1) above. - * - * Similarly, if it allocates space for its own header, it - * can go into an infinite loop as it: - * - * 1) allocates space for the header - * - * 2) notices that the free space manager is empty - * and thus should not have file space allocated - * to its header - * - * 3) frees the space allocated to the header - * - * 4) notices that the free space manager is not - * empty and thus must have file space allocated - * to it, and thus returns to 1) above. - * - * In a nutshell, the solution applied in this hack is to - * deallocate file space for the free space manager(s) that - * handle FSM header and/or section info file space allocations, - * wait until all other allocation/deallocation requests have - * been handled, and then test to see if the free space manager(s) - * in question are empty. If they are, do nothing. If they - * are not, allocate space for them at end of file bypassing the - * usual file space allocation calls, and thus avoiding the - * potential infinite loops. - * - * The purpose of this function is to allocate file space for + * Purpose: The purpose of this function is to allocate file space for * the header and section info of the target free space manager - * directly from the VFD if needed. In this case the function - * also re-inserts the header and section info in the metadata - * cache with this allocation. - * - * When paged allocation is not enabled, allocation of space - * for the free space manager header and section info is - * straight forward -- we simply allocate the space directly - * from file driver. - * - * Note that if f->shared->alignment > 1, and EOA is not a - * multiple of the alignment, it is possible that performing - * these allocations may generate a fragment of file space in - * addition to the space allocated for the section info. This - * excess space is dropped on the floor. As shall be seen, - * it will usually be reclaimed later. - * - * When page allocation is enabled, things are more difficult, - * as there is the possibility that page buffering will be - * enabled when the free space managers are read. To allow - * for this, we must ensure that space allocated for the - * free space manager header and section info is either larger - * than a page, or resides completely within a page. - * - * Do this by allocating space for the free space header and - * section info starting at page boundaries, and extending - * allocation to the next page boundary. This of course wastes - * space, but see below. - * - * On the first free space allocation / deallocation after the - * next file open, we will read the self referential free space - * managers, float them and reduce the EOA to its value prior - * to allocation of file space for the self referential free - * space managers on the preceeding file close. This EOA value - * is stored in the free space manager superblock extension - * message. + * if they are not allocated yet. + * + * The previous hack in this routine to avoid the potential infinite + * loops by allocating file space directly from the end of the file + * is removed. The allocation can now be done via the usual + * file space allocation call H5MF_alloc(). + * + * The design flaw is addressed by not allowing the size + * of section info to shrink. This means, when trying to allocate + * section info size X via H5MF_alloc() and the section info size + * after H5MF_alloc() changes to Y: + * --if Y is larger than X, free the just allocated file space X + * via H5MF_xfree() and set fspace->sect_size to Y. + * This routine will be called again later from + * H5MF_settle_meta_data_fsm() to allocate section info with the + * larger fpsace->sect_size Y. + * --if Y is smaller than X, no further allocation is needed and + * fspace->sect_size and fspace->alloc_sect_size are set to X. + * This means fspace->sect_size may be larger than what is + * actually needed. + * + * This routine also re-inserts the header and section info in the + * metadata cache with this allocation. * * Return: Success: non-negative * Failure: negative @@ -2394,16 +2382,13 @@ H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data) *------------------------------------------------------------------------- */ herr_t -H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, - haddr_t *fs_addr_ptr) +H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr_ptr) { - hsize_t hdr_alloc_size; - hsize_t sinfo_alloc_size; - haddr_t sect_addr = HADDR_UNDEF; /* address of sinfo */ - haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ - hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ - haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t hdr_alloc_size; + hsize_t sinfo_alloc_size; + haddr_t sect_addr = HADDR_UNDEF; /* address of sinfo */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2417,12 +2402,6 @@ H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, /* the section info should be unlocked */ HDassert(fspace->sinfo_lock_count == 0); - /* no space should be allocated */ - HDassert(*fs_addr_ptr == HADDR_UNDEF); - HDassert(fspace->addr == HADDR_UNDEF); - HDassert(fspace->sect_addr == HADDR_UNDEF); - HDassert(fspace->alloc_sect_size == 0); - /* persistent free space managers must be enabled */ HDassert(f->shared->fs_persist); @@ -2434,128 +2413,115 @@ H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, HDassert((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE)); - if(fspace->serial_sect_count > 0) { + if (fspace->serial_sect_count > 0 && fspace->sinfo) { /* the section info is floating, so space->sinfo should be defined */ - HDassert(fspace->sinfo); - - /* start by allocating file space for the header */ - /* Get the EOA for the file -- need for sanity check below */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_HDR))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + if (!H5F_addr_defined(fspace->addr)) { - /* check for overlap into temporary allocation space */ - if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "hdr file space alloc will overlap into 'temporary' file space") + /* start by allocating file space for the header */ - hdr_alloc_size = H5FS_HEADER_SIZE(f); + /* Get the EOA for the file -- need for sanity check below */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_HDR))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* if page allocation is enabled, extend the hdr_alloc_size to the - * next page boundary. - */ - if(H5F_PAGED_AGGR(f)) { - HDassert(0 == (eoa % f->shared->fs_page_size)); + /* check for overlap into temporary allocation space */ + if (H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, + "hdr file space alloc will overlap into 'temporary' file space") - hdr_alloc_size = ((hdr_alloc_size / f->shared->fs_page_size) + 1) * f->shared->fs_page_size; + hdr_alloc_size = H5FS_HEADER_SIZE(f); - HDassert(hdr_alloc_size >= H5FS_HEADER_SIZE(f)); - HDassert((hdr_alloc_size % f->shared->fs_page_size) == 0); - } /* end if */ + if (H5F_PAGED_AGGR(f)) + HDassert(0 == (eoa % f->shared->fs_page_size)); - /* allocate space for the hdr */ - if(HADDR_UNDEF == (fspace->addr = H5FD_alloc(f->shared->lf, H5FD_MEM_FSPACE_HDR, - f, hdr_alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space for hdr") + /* Allocate space for the free space header */ + if (HADDR_UNDEF == (fspace->addr = H5MF_alloc(f, H5FD_MEM_FSPACE_HDR, hdr_alloc_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for free space header") - /* if the file alignment is 1, there should be no - * eoa fragment. Otherwise, drop any fragment on the floor. - */ - HDassert((eoa_frag_size == 0) || (f->shared->alignment != 1)); + /* Cache the new free space header (pinned) */ + if (H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") - /* Cache the new free space header (pinned) */ - if(H5AC_insert_entry(f, H5AC_FSPACE_HDR, fspace->addr, fspace, H5AC__PIN_ENTRY_FLAG) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space header to cache") + *fs_addr_ptr = fspace->addr; + } - *fs_addr_ptr = fspace->addr; + if (!H5F_addr_defined(fspace->sect_addr)) { - /* now allocate file space for the section info */ + /* now allocate file space for the section info */ - /* Get the EOA for the file -- need for sanity check below */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_SINFO))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "Unable to get eoa") + /* Get the EOA for the file -- need for sanity check below */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_FSPACE_SINFO))) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* check for overlap into temporary allocation space */ - if(H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_BADRANGE, FAIL, "sinfo file space alloc will overlap into 'temporary' file space") + /* check for overlap into temporary allocation space */ + if (H5F_IS_TMP_ADDR(f, (eoa + fspace->sect_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_BADRANGE, FAIL, + "sinfo file space alloc will overlap into 'temporary' file space") - sinfo_alloc_size = fspace->sect_size; + sinfo_alloc_size = fspace->sect_size; - /* if paged allocation is enabled, extend the sinfo_alloc_size to the - * next page boundary. - */ - if(H5F_PAGED_AGGR(f)) { - HDassert(0 == (eoa % f->shared->fs_page_size)); + if (H5F_PAGED_AGGR(f)) + HDassert(0 == (eoa % f->shared->fs_page_size)); - sinfo_alloc_size = ((sinfo_alloc_size / f->shared->fs_page_size) + 1) * f->shared->fs_page_size; + /* allocate space for the section info */ + if (HADDR_UNDEF == (sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, sinfo_alloc_size))) + HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for section info") - HDassert(sinfo_alloc_size >= fspace->sect_size); - HDassert((sinfo_alloc_size % f->shared->fs_page_size) == 0); - } /* end if */ - - /* allocate space for the section info */ - if(HADDR_UNDEF == (sect_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_FSPACE_SINFO, - f, sinfo_alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTALLOC, FAIL, "can't allocate file space") - - /* if the file alignment is 1, there should be no - * eoa fragment. Otherwise, drop the fragment on the floor. - */ - HDassert((eoa_frag_size == 0) || (f->shared->alignment != 1)); + /* update fspace->alloc_sect_size and fspace->sect_addr to reflect + * the allocation + */ + if (fspace->sect_size > sinfo_alloc_size) { + hsize_t saved_sect_size = fspace->sect_size; - /* update fspace->alloc_sect_size and fspace->sect_addr to reflect - * the allocation - */ - fspace->alloc_sect_size = fspace->sect_size; - fspace->sect_addr = sect_addr; - - /* insert the new section info into the metadata cache. */ - - /* Question: Do we need to worry about this insertion causing an - * eviction from the metadata cache? Think on this. If so, add a - * flag to H5AC_insert() to force it to skip the call to make space in - * cache. - * - * On reflection, no. - * - * On a regular file close, any eviction will not change the - * the contents of the free space manager(s), as all entries - * should have correct file space allocated by the time this - * function is called. - * - * In the cache image case, the selection of entries for inclusion - * in the cache image will not take place until after this call. - * (Recall that this call is made during the metadata fsm settle - * routine, which is called during the serialization routine in - * the cache image case. Entries are not selected for inclusion - * in the image until after the cache is serialized.) - * - * JRM -- 11/4/16 - */ - if(H5AC_insert_entry(f, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sinfo to cache") + if (H5MF_xfree(f, H5FD_MEM_FSPACE_SINFO, sect_addr, sinfo_alloc_size) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space sections") + fspace->sect_size = saved_sect_size; + } + else { + fspace->alloc_sect_size = sinfo_alloc_size; + fspace->sect_size = sinfo_alloc_size; + fspace->sect_addr = sect_addr; + + /* insert the new section info into the metadata cache. */ + + /* Question: Do we need to worry about this insertion causing an + * eviction from the metadata cache? Think on this. If so, add a + * flag to H5AC_insert() to force it to skip the call to make space in + * cache. + * + * On reflection, no. + * + * On a regular file close, any eviction will not change the + * the contents of the free space manager(s), as all entries + * should have correct file space allocated by the time this + * function is called. + * + * In the cache image case, the selection of entries for inclusion + * in the cache image will not take place until after this call. + * (Recall that this call is made during the metadata fsm settle + * routine, which is called during the serialization routine in + * the cache image case. Entries are not selected for inclusion + * in the image until after the cache is serialized.) + * + * JRM -- 11/4/16 + */ + if (H5AC_insert_entry(f, H5AC_FSPACE_SINFO, sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sinfo to cache") - /* We have changed the sinfo address -- Mark free space header dirty */ - if(H5AC_mark_entry_dirty(fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") + /* We have changed the sinfo address -- Mark free space header dirty */ + if (H5AC_mark_entry_dirty(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, + "unable to mark free space header as dirty") - /* since space has been allocated for the section info and the sinfo - * has been inserted into the cache, relinquish ownership (i.e. float) - * the section info. - */ - fspace->sinfo = NULL; + /* since space has been allocated for the section info and the sinfo + * has been inserted into the cache, relinquish ownership (i.e. float) + * the section info. + */ + fspace->sinfo = NULL; + } + } } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_vfd_alloc_hdr_and_section_info_if_needed() */ - diff --git a/src/H5FSstat.c b/src/H5FSstat.c index e2ad5bbf46e..2b181679d7f 100644 --- a/src/H5FSstat.c +++ b/src/H5FSstat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,53 +20,43 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* Free-space manager */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* Free-space manager */ /****************/ /* Local Macros */ /****************/ - /********************/ /* Package Typedefs */ /********************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS_stat_info * @@ -89,16 +79,15 @@ H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats) HDassert(stats); /* Report statistics for free space */ - stats->tot_space = frsp->tot_space; - stats->tot_sect_count = frsp->tot_sect_count; + stats->tot_space = frsp->tot_space; + stats->tot_sect_count = frsp->tot_sect_count; stats->serial_sect_count = frsp->serial_sect_count; - stats->ghost_sect_count = frsp->ghost_sect_count; - stats->addr = frsp->addr; - stats->hdr_size = (hsize_t)H5FS_HEADER_SIZE(f); - stats->sect_addr = frsp->sect_addr; - stats->alloc_sect_size = frsp->alloc_sect_size; - stats->sect_size = frsp->sect_size; + stats->ghost_sect_count = frsp->ghost_sect_count; + stats->addr = frsp->addr; + stats->hdr_size = (hsize_t)H5FS_HEADER_SIZE(f); + stats->sect_addr = frsp->sect_addr; + stats->alloc_sect_size = frsp->alloc_sect_size; + stats->sect_size = frsp->sect_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS_stat_info() */ - diff --git a/src/H5FStest.c b/src/H5FStest.c index 120a9a8ad70..cd452d1e1c8 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,54 +20,44 @@ /* Module Setup */ /****************/ -#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ -#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */ - +#include "H5FSmodule.h" /* This source code file is part of the H5FS module */ +#define H5FS_TESTING /* Suppress warning about H5FS testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* Free-space manager */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* Free-space manager */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FS__get_cparam_test * @@ -90,16 +80,15 @@ H5FS__get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam) HDassert(frsp); HDassert(cparam); - cparam->client = frsp->client; + cparam->client = frsp->client; cparam->shrink_percent = frsp->shrink_percent; cparam->expand_percent = frsp->expand_percent; - cparam->max_sect_addr = frsp->max_sect_addr; - cparam->max_sect_size = frsp->max_sect_size; + cparam->max_sect_addr = frsp->max_sect_addr; + cparam->max_sect_size = frsp->max_sect_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FS__get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5FS__cmp_cparam_test * @@ -116,7 +105,7 @@ H5FS__get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam) int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -124,32 +113,31 @@ H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2 HDassert(cparam1); HDassert(cparam2); - if(cparam1->client < cparam2->client) + if (cparam1->client < cparam2->client) HGOTO_DONE(-1) - else if(cparam1->client > cparam2->client) + else if (cparam1->client > cparam2->client) HGOTO_DONE(1) - if(cparam1->shrink_percent < cparam2->shrink_percent) + if (cparam1->shrink_percent < cparam2->shrink_percent) HGOTO_DONE(-1) - else if(cparam1->shrink_percent > cparam2->shrink_percent) + else if (cparam1->shrink_percent > cparam2->shrink_percent) HGOTO_DONE(1) - if(cparam1->expand_percent < cparam2->expand_percent) + if (cparam1->expand_percent < cparam2->expand_percent) HGOTO_DONE(-1) - else if(cparam1->expand_percent > cparam2->expand_percent) + else if (cparam1->expand_percent > cparam2->expand_percent) HGOTO_DONE(1) - if(cparam1->max_sect_size < cparam2->max_sect_size) + if (cparam1->max_sect_size < cparam2->max_sect_size) HGOTO_DONE(-1) - else if(cparam1->max_sect_size > cparam2->max_sect_size) + else if (cparam1->max_sect_size > cparam2->max_sect_size) HGOTO_DONE(1) - if(cparam1->max_sect_addr < cparam2->max_sect_addr) + if (cparam1->max_sect_addr < cparam2->max_sect_addr) HGOTO_DONE(-1) - else if(cparam1->max_sect_addr > cparam2->max_sect_addr) + else if (cparam1->max_sect_addr > cparam2->max_sect_addr) HGOTO_DONE(1) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__cmp_cparam_test */ - diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 02f475de9a9..aed5812e63e 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,29 +28,26 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Metadata accumulator controls */ -#define H5F_ACCUM_THROTTLE 8 -#define H5F_ACCUM_THRESHOLD 2048 -#define H5F_ACCUM_MAX_SIZE (1024 *1024) /* Max. accum. buf size (max. I/Os will be 1/2 this size) */ - +#define H5F_ACCUM_THROTTLE 8 +#define H5F_ACCUM_THRESHOLD 2048 +#define H5F_ACCUM_MAX_SIZE (1024 * 1024) /* Max. accum. buf size (max. I/Os will be 1/2 this size) */ /******************/ /* Local Typedefs */ @@ -58,31 +55,26 @@ /* Enumerated type to indicate how data will be added to accumulator */ typedef enum { - H5F_ACCUM_PREPEND, /* Data will be prepended to accumulator */ - H5F_ACCUM_APPEND /* Data will be appended to accumulator */ + H5F_ACCUM_PREPEND, /* Data will be prepended to accumulator */ + H5F_ACCUM_APPEND /* Data will be appended to accumulator */ } H5F_accum_adjust_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -90,8 +82,6 @@ typedef enum { /* Declare a PQ free list to manage the metadata accumulator buffer */ H5FL_BLK_DEFINE_STATIC(meta_accum); - - /*------------------------------------------------------------------------- * Function: H5F__accum_read * @@ -110,11 +100,10 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); *------------------------------------------------------------------------- */ herr_t -H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, - size_t size, void *buf/*out*/) +H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_t *file; /* File driver pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_t *file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -126,38 +115,38 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, file = f_sh->lf; /* Check if this information is in the metadata accumulator */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { - H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ /* Set up alias for file's metadata accumulator info */ accum = &f_sh->accum; - if(size < H5F_ACCUM_MAX_SIZE) { + if (size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Current read adjoins or overlaps with metadata accumulator */ - if(H5F_addr_overlap(addr, size, accum->loc, accum->size) - || ((addr + size) == accum->loc) - || (accum->loc + accum->size) == addr) { - size_t amount_before; /* Amount to read before current accumulator */ - haddr_t new_addr; /* New address of the accumulator buffer */ - size_t new_size; /* New size of the accumulator buffer */ + if (H5F_addr_overlap(addr, size, accum->loc, accum->size) || ((addr + size) == accum->loc) || + (accum->loc + accum->size) == addr) { + size_t amount_before; /* Amount to read before current accumulator */ + haddr_t new_addr; /* New address of the accumulator buffer */ + size_t new_size; /* New size of the accumulator buffer */ /* Compute new values for accumulator */ new_addr = MIN(addr, accum->loc); new_size = (size_t)(MAX((addr + size), (accum->loc + accum->size)) - new_addr); /* Check if we need more buffer space */ - if(new_size > accum->alloc_size) { - size_t new_alloc_size; /* New size of accumulator */ + if (new_size > accum->alloc_size) { + size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(new_size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_alloc_size; @@ -167,7 +156,7 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ /* Read the part before the metadata accumulator */ - if(addr < accum->loc) { + if (addr < accum->loc) { /* Set the amount to read */ H5_CHECKED_ASSIGN(amount_before, size_t, (accum->loc - addr), hsize_t); @@ -175,25 +164,27 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, HDmemmove(accum->buf + amount_before, accum->buf, accum->size); /* Adjust dirty region tracking info, if present */ - if(accum->dirty) + if (accum->dirty) accum->dirty_off += amount_before; /* Dispatch to driver */ - if(H5FD_read(file, map_type, addr, amount_before, accum->buf) < 0) + if (H5FD_read(file, map_type, addr, amount_before, accum->buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ else amount_before = 0; /* Read the part after the metadata accumulator */ - if((addr + size) > (accum->loc + accum->size)) { - size_t amount_after; /* Amount to read at a time */ + if ((addr + size) > (accum->loc + accum->size)) { + size_t amount_after; /* Amount to read at a time */ /* Set the amount to read */ - H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)), hsize_t); + H5_CHECKED_ASSIGN(amount_after, size_t, ((addr + size) - (accum->loc + accum->size)), + hsize_t); /* Dispatch to driver */ - if(H5FD_read(file, map_type, (accum->loc + accum->size), amount_after, (accum->buf + accum->size + amount_before)) < 0) + if (H5FD_read(file, map_type, (accum->loc + accum->size), amount_after, + (accum->buf + accum->size + amount_before)) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end if */ @@ -201,19 +192,19 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, H5MM_memcpy(buf, accum->buf + (addr - new_addr), size); /* Adjust the accumulator address & size */ - accum->loc = new_addr; + accum->loc = new_addr; accum->size = new_size; } /* end if */ /* Current read doesn't overlap with metadata accumulator, read it from file */ else { /* Dispatch to driver */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ - } /* end if */ + } /* end if */ else { /* Read the data */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") /* Check for overlap w/dirty accumulator */ @@ -221,15 +212,15 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, * information in the accumulator with [some of] the information * just read in. -QAK) */ - if(accum->dirty && - H5F_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) { - haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */ - size_t buf_off; /* Offset of dirty region in buffer */ - size_t dirty_off; /* Offset within dirty region */ - size_t overlap_size; /* Size of overlap with dirty region */ + if (accum->dirty && + H5F_addr_overlap(addr, size, accum->loc + accum->dirty_off, accum->dirty_len)) { + haddr_t dirty_loc = accum->loc + accum->dirty_off; /* File offset of dirty information */ + size_t buf_off; /* Offset of dirty region in buffer */ + size_t dirty_off; /* Offset within dirty region */ + size_t overlap_size; /* Size of overlap with dirty region */ /* Check for read starting before beginning dirty region */ - if(H5F_addr_le(addr, dirty_loc)) { + if (H5F_addr_le(addr, dirty_loc)) { /* Compute offset of dirty region within buffer */ buf_off = (size_t)(dirty_loc - addr); @@ -237,26 +228,27 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, dirty_off = 0; /* Check for read ending within dirty region */ - if(H5F_addr_lt(addr + size, dirty_loc + accum->dirty_len)) + if (H5F_addr_lt(addr + size, dirty_loc + accum->dirty_len)) overlap_size = (size_t)((addr + size) - buf_off); - else /* Access covers whole dirty region */ + else /* Access covers whole dirty region */ overlap_size = accum->dirty_len; - } /* end if */ + } /* end if */ else { /* Read starts after beginning of dirty region */ /* Compute dirty offset within buffer and overlap size */ - buf_off = 0; - dirty_off = (size_t)(addr - dirty_loc); + buf_off = 0; + dirty_off = (size_t)(addr - dirty_loc); overlap_size = (size_t)((dirty_loc + accum->dirty_len) - addr); } /* end else */ /* Copy the dirty region to buffer */ - H5MM_memcpy((unsigned char *)buf + buf_off, (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size); + H5MM_memcpy((unsigned char *)buf + buf_off, + (unsigned char *)accum->buf + accum->dirty_off + dirty_off, overlap_size); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Read the data */ - if(H5FD_read(file, map_type, addr, size, buf) < 0) + if (H5FD_read(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "driver read request failed") } /* end else */ @@ -264,7 +256,6 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_read() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_adjust * @@ -278,10 +269,9 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, *------------------------------------------------------------------------- */ static herr_t -H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, - H5F_accum_adjust_t adjust, size_t size) +H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, H5F_accum_adjust_t adjust, size_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -292,70 +282,75 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, HDassert(size <= H5F_ACCUM_MAX_SIZE); /* Check if we need more buffer space */ - if((size + accum->size) > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ + if ((size + accum->size) > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)((size + accum->size) - 1))); /* Check for accumulator getting too big */ - if(new_size > H5F_ACCUM_MAX_SIZE) { - size_t shrink_size; /* Amount to shrink accumulator by */ - size_t remnant_size; /* Amount left in accumulator */ + if (new_size > H5F_ACCUM_MAX_SIZE) { + size_t shrink_size; /* Amount to shrink accumulator by */ + size_t remnant_size; /* Amount left in accumulator */ /* Cap the accumulator's growth, leaving some room */ /* Determine the amounts to work with */ - if(size > (H5F_ACCUM_MAX_SIZE / 2)) { - new_size = H5F_ACCUM_MAX_SIZE; - shrink_size = accum->size; + if (size > (H5F_ACCUM_MAX_SIZE / 2)) { + new_size = H5F_ACCUM_MAX_SIZE; + shrink_size = accum->size; remnant_size = 0; } /* end if */ else { - if(H5F_ACCUM_PREPEND == adjust) { - new_size = (H5F_ACCUM_MAX_SIZE / 2); - shrink_size = (H5F_ACCUM_MAX_SIZE / 2); + if (H5F_ACCUM_PREPEND == adjust) { + new_size = (H5F_ACCUM_MAX_SIZE / 2); + shrink_size = (H5F_ACCUM_MAX_SIZE / 2); remnant_size = accum->size - shrink_size; } /* end if */ else { size_t adjust_size = size + accum->dirty_len; /* Check if we can slide the dirty region down, to accommodate the request */ - if(accum->dirty && (adjust_size <= H5F_ACCUM_MAX_SIZE)) { - if((ssize_t)(H5F_ACCUM_MAX_SIZE - (accum->dirty_off + adjust_size)) >= (ssize_t)(2 * size)) + if (accum->dirty && (adjust_size <= H5F_ACCUM_MAX_SIZE)) { + if ((ssize_t)(H5F_ACCUM_MAX_SIZE - (accum->dirty_off + adjust_size)) >= + (ssize_t)(2 * size)) shrink_size = accum->dirty_off / 2; else shrink_size = accum->dirty_off; remnant_size = accum->size - shrink_size; - new_size = remnant_size + size; + new_size = remnant_size + size; } /* end if */ else { - new_size = (H5F_ACCUM_MAX_SIZE / 2); - shrink_size = (H5F_ACCUM_MAX_SIZE / 2); + new_size = (H5F_ACCUM_MAX_SIZE / 2); + shrink_size = (H5F_ACCUM_MAX_SIZE / 2); remnant_size = accum->size - shrink_size; } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Check if we need to flush accumulator data to file */ - if(accum->dirty) { + if (accum->dirty) { /* Check whether to accumulator will be prepended or appended */ - if(H5F_ACCUM_PREPEND == adjust) { + if (H5F_ACCUM_PREPEND == adjust) { /* Check if the dirty region overlaps the region to eliminate from the accumulator */ - if((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { - /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if ((accum->size - shrink_size) < (accum->dirty_off + accum->dirty_len)) { + /* Write out the dirty region from the metadata accumulator, with dispatch to driver + */ + if (H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), + accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ accum->dirty = FALSE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check if the dirty region overlaps the region to eliminate from the accumulator */ - if(shrink_size > accum->dirty_off) { - /* Write out the dirty region from the metadata accumulator, with dispatch to driver */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) + if (shrink_size > accum->dirty_off) { + /* Write out the dirty region from the metadata accumulator, with dispatch to driver + */ + if (H5FD_write(file, H5FD_MEM_DEFAULT, (accum->loc + accum->dirty_off), + accum->dirty_len, (accum->buf + accum->dirty_off)) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -365,43 +360,42 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, /* Adjust dirty region tracking info */ accum->dirty_off -= shrink_size; } /* end else */ - } /* end if */ + } /* end if */ /* Trim the accumulator's use of its buffer */ accum->size = remnant_size; /* When appending, need to adjust location of accumulator */ - if(H5F_ACCUM_APPEND == adjust) { + if (H5F_ACCUM_APPEND == adjust) { /* Move remnant of accumulator down */ HDmemmove(accum->buf, (accum->buf + shrink_size), remnant_size); /* Adjust accumulator's location */ accum->loc += shrink_size; } /* end if */ - } /* end if */ + } /* end if */ /* Check for accumulator needing to be reallocated */ - if(new_size > accum->alloc_size) { - unsigned char *new_buf; /* New buffer to hold the accumulated metadata */ + if (new_size > accum->alloc_size) { + unsigned char *new_buf; /* New buffer to hold the accumulated metadata */ /* Reallocate the metadata accumulator buffer */ - if(NULL == (new_buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + if (NULL == (new_buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata accumulator buffer") /* Update accumulator info */ - accum->buf = new_buf; + accum->buf = new_buf; accum->alloc_size = new_size; /* Clear the memory */ HDmemset(accum->buf + accum->size, 0, (accum->alloc_size - (accum->size + size))); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_adjust() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_write * @@ -416,11 +410,10 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, *------------------------------------------------------------------------- */ herr_t -H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, - size_t size, const void *buf) +H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t size, const void *buf) { - H5FD_t *file; /* File driver pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_t *file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -433,22 +426,22 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, file = f_sh->lf; /* Check for accumulating metadata */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { - H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && map_type != H5FD_MEM_DRAW) { + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ /* Set up alias for file's metadata accumulator info */ accum = &f_sh->accum; - if(size < H5F_ACCUM_MAX_SIZE) { + if (size < H5F_ACCUM_MAX_SIZE) { /* Sanity check */ HDassert(!accum->buf || (accum->alloc_size >= accum->size)); /* Check if there is already metadata in the accumulator */ - if(accum->size > 0) { + if (accum->size > 0) { /* Check if the new metadata adjoins the beginning of the current accumulator */ - if((addr + size) == accum->loc) { + if ((addr + size) == accum->loc) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Move the existing metadata to the proper location */ @@ -462,78 +455,79 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) + if (accum->dirty) accum->dirty_len = size + accum->dirty_off + accum->dirty_len; else { accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ accum->dirty_off = 0; } /* end if */ /* Check if the new metadata adjoins the end of the current accumulator */ - else if(addr == (accum->loc + accum->size)) { + else if (addr == (accum->loc + accum->size)) { /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Copy the new metadata to the end */ H5MM_memcpy(accum->buf + accum->size, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) + if (accum->dirty) accum->dirty_len = size + (accum->size - accum->dirty_off); else { accum->dirty_off = accum->size; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ /* Set the new size of the metadata accumulator */ accum->size += size; } /* end if */ /* Check if the piece of metadata being written overlaps the metadata accumulator */ - else if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { - size_t add_size; /* New size of the accumulator buffer */ + else if (H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + size_t add_size; /* New size of the accumulator buffer */ /* Check if the new metadata is entirely within the current accumulator */ - if(addr >= accum->loc && (addr + size) <= (accum->loc + accum->size)) { + if (addr >= accum->loc && (addr + size) <= (accum->loc + accum->size)) { size_t dirty_off = (size_t)(addr - accum->loc); /* Copy the new metadata to the proper location within the accumulator */ H5MM_memcpy(accum->buf + dirty_off, buf, size); /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= accum->dirty_off) { - if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + if (dirty_off <= accum->dirty_off) { + if ((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) accum->dirty_len = (accum->dirty_off + accum->dirty_len) - dirty_off; else accum->dirty_len = size; accum->dirty_off = dirty_off; } /* end if */ else { - if((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) + if ((dirty_off + size) <= (accum->dirty_off + accum->dirty_len)) ; /* accum->dirty_len doesn't change */ else accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ - } /* end if */ + } /* end if */ else { accum->dirty_off = dirty_off; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the new metadata overlaps the beginning of the current accumulator */ - else if(addr < accum->loc && (addr + size) <= (accum->loc + accum->size)) { - size_t old_offset; /* Offset of old data within the accumulator buffer */ + else if (addr < accum->loc && (addr + size) <= (accum->loc + accum->size)) { + size_t old_offset; /* Offset of old data within the accumulator buffer */ - /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ + /* Calculate the amount we will need to add to the accumulator size, based on the + * amount of overlap */ H5_CHECKED_ASSIGN(add_size, size_t, (accum->loc - addr), hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, add_size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_PREPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Calculate the proper offset of the existing metadata */ @@ -550,11 +544,11 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { size_t curr_dirty_end = add_size + accum->dirty_off + accum->dirty_len; accum->dirty_off = 0; - if(size <= curr_dirty_end) + if (size <= curr_dirty_end) accum->dirty_len = curr_dirty_end; else accum->dirty_len = size; @@ -562,18 +556,20 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, else { accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the new metadata overlaps the end of the current accumulator */ - else if(addr >= accum->loc && (addr + size) > (accum->loc + accum->size)) { - size_t dirty_off; /* Offset of dirty region */ + else if (addr >= accum->loc && (addr + size) > (accum->loc + accum->size)) { + size_t dirty_off; /* Offset of dirty region */ - /* Calculate the amount we will need to add to the accumulator size, based on the amount of overlap */ - H5_CHECKED_ASSIGN(add_size, size_t, (addr + size) - (accum->loc + accum->size), hsize_t); + /* Calculate the amount we will need to add to the accumulator size, based on the + * amount of overlap */ + H5_CHECKED_ASSIGN(add_size, size_t, (addr + size) - (accum->loc + accum->size), + hsize_t); /* Check if we need to adjust accumulator size */ - if(H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, add_size) < 0) + if (H5F__accum_adjust(accum, file, H5F_ACCUM_APPEND, add_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Compute offset of dirty region (after adjusting accumulator) */ @@ -586,34 +582,36 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, accum->size += add_size; /* Adjust the dirty region and mark accumulator dirty */ - if(accum->dirty) { + if (accum->dirty) { /* Check for new metadata starting before current dirty region */ - if(dirty_off <= accum->dirty_off) { + if (dirty_off <= accum->dirty_off) { accum->dirty_off = dirty_off; accum->dirty_len = size; } /* end if */ else { accum->dirty_len = (dirty_off + size) - accum->dirty_off; } /* end else */ - } /* end if */ + } /* end if */ else { accum->dirty_off = dirty_off; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* New metadata overlaps both ends of the current accumulator */ else { /* Check if we need more buffer space */ - if(size > accum->alloc_size) { - size_t new_alloc_size; /* New size of accumulator */ + if (size > accum->alloc_size) { + size_t new_alloc_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_alloc_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == + (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_alloc_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_alloc_size; @@ -626,20 +624,21 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, H5MM_memcpy(accum->buf, buf, size); /* Set the new size & location of the metadata accumulator */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* New piece of metadata doesn't adjoin or overlap the existing accumulator */ else { /* Write out the existing metadata accumulator, with dispatch to driver */ - if(accum->dirty) { - if(H5FD_write(file, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if (accum->dirty) { + if (H5FD_write(file, H5FD_MEM_DEFAULT, accum->loc + accum->dirty_off, + accum->dirty_len, accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset accumulator dirty flag */ @@ -648,16 +647,17 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Cache the new piece of metadata */ /* Check if we need to resize the buffer */ - if(size > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ - size_t clear_size; /* Size of memory that needs clearing */ + if (size > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ + size_t clear_size; /* Size of memory that needs clearing */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Grow the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_size; @@ -668,21 +668,23 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ else { /* Check if we should shrink the accumulator buffer */ - if(size < (accum->alloc_size / H5F_ACCUM_THROTTLE) && - accum->alloc_size > H5F_ACCUM_THRESHOLD) { - size_t tmp_size = (accum->alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ + if (size < (accum->alloc_size / H5F_ACCUM_THROTTLE) && + accum->alloc_size > H5F_ACCUM_THRESHOLD) { + size_t tmp_size = + (accum->alloc_size / H5F_ACCUM_THROTTLE); /* New size of accumulator buffer */ /* Shrink the accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, tmp_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, tmp_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = tmp_size; } /* end if */ - } /* end else */ + } /* end else */ /* Update the metadata accumulator information */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Store the piece of metadata in the accumulator */ @@ -691,21 +693,22 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* No metadata in the accumulator, grab this piece and keep it */ else { /* Check if we need to reallocate the buffer */ - if(size > accum->alloc_size) { - size_t new_size; /* New size of accumulator */ + if (size > accum->alloc_size) { + size_t new_size; /* New size of accumulator */ /* Adjust the buffer size to be a power of 2 that is large enough to hold data */ new_size = (size_t)1 << (1 + H5VM_log2_gen((uint64_t)(size - 1))); /* Reallocate the metadata accumulator buffer */ - if(NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer") + if (NULL == (accum->buf = H5FL_BLK_REALLOC(meta_accum, accum->buf, new_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate metadata accumulator buffer") /* Note the new buffer size */ accum->alloc_size = new_size; @@ -715,7 +718,7 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, } /* end if */ /* Update the metadata accumulator information */ - accum->loc = addr; + accum->loc = addr; accum->size = size; /* Store the piece of metadata in the accumulator */ @@ -724,68 +727,70 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, /* Adjust the dirty region and mark accumulator dirty */ accum->dirty_off = 0; accum->dirty_len = size; - accum->dirty = TRUE; + accum->dirty = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { /* Make certain that data in accumulator is visible before new write */ - if((H5F_SHARED_INTENT(f_sh) & H5F_ACC_SWMR_WRITE) > 0) + if ((H5F_SHARED_INTENT(f_sh) & H5F_ACC_SWMR_WRITE) > 0) /* Flush if dirty and reset accumulator */ - if(H5F__accum_reset(f_sh, TRUE) < 0) + if (H5F__accum_reset(f_sh, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Write the data */ - if(H5FD_write(file, map_type, addr, size, buf) < 0) + if (H5FD_write(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Check for overlap w/accumulator */ /* (Note that this could be improved by updating the accumulator * with [some of] the information just read in. -QAK) */ - if(H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + if (H5F_addr_overlap(addr, size, accum->loc, accum->size)) { /* Check for write starting before beginning of accumulator */ - if(H5F_addr_le(addr, accum->loc)) { + if (H5F_addr_le(addr, accum->loc)) { /* Check for write ending within accumulator */ - if(H5F_addr_le(addr + size, accum->loc + accum->size)) { - size_t overlap_size; /* Size of overlapping region */ + if (H5F_addr_le(addr + size, accum->loc + accum->size)) { + size_t overlap_size; /* Size of overlapping region */ /* Compute overlap size */ overlap_size = (size_t)((addr + size) - accum->loc); /* Check for dirty region */ - if(accum->dirty) { - haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ + if (accum->dirty) { + haddr_t dirty_start = + accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = + dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ - if(H5F_addr_le(dirty_end, addr + size)) { - accum->dirty = FALSE; + if (H5F_addr_le(dirty_end, addr + size)) { + accum->dirty = FALSE; accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling after write */ - if(H5F_addr_le(addr + size, dirty_start)) + if (H5F_addr_le(addr + size, dirty_start)) accum->dirty_off = overlap_size; - else { /* Dirty region overlaps w/written region */ + else { /* Dirty region overlaps w/written region */ accum->dirty_off = 0; accum->dirty_len -= (size_t)((addr + size) - dirty_start); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Trim bottom of accumulator off */ accum->loc += overlap_size; accum->size -= overlap_size; HDmemmove(accum->buf, accum->buf + overlap_size, accum->size); - } /* end if */ - else { /* Access covers whole accumulator */ + } /* end if */ + else { /* Access covers whole accumulator */ /* Reset accumulator, but don't flush */ - if(H5F__accum_reset(f_sh, FALSE) < 0) + if (H5F__accum_reset(f_sh, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") - } /* end else */ - } /* end if */ - else { /* Write starts after beginning of accumulator */ - size_t overlap_size; /* Size of overlapping region */ + } /* end else */ + } /* end if */ + else { /* Write starts after beginning of accumulator */ + size_t overlap_size; /* Size of overlapping region */ /* Sanity check */ HDassert(H5F_addr_gt(addr + size, accum->loc + accum->size)); @@ -794,33 +799,35 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, overlap_size = (size_t)((accum->loc + accum->size) - addr); /* Check for dirty region */ - if(accum->dirty) { - haddr_t dirty_start = accum->loc + accum->dirty_off; /* File address of start of dirty region */ - haddr_t dirty_end = dirty_start + accum->dirty_len; /* File address of end of dirty region */ + if (accum->dirty) { + haddr_t dirty_start = + accum->loc + accum->dirty_off; /* File address of start of dirty region */ + haddr_t dirty_end = + dirty_start + accum->dirty_len; /* File address of end of dirty region */ /* Check if entire dirty region is overwritten */ - if(H5F_addr_ge(dirty_start, addr)) { - accum->dirty = FALSE; + if (H5F_addr_ge(dirty_start, addr)) { + accum->dirty = FALSE; accum->dirty_len = 0; } /* end if */ else { /* Check for dirty region falling before write */ - if(H5F_addr_le(dirty_end, addr)) + if (H5F_addr_le(dirty_end, addr)) ; /* noop */ - else /* Dirty region overlaps w/written region */ + else /* Dirty region overlaps w/written region */ accum->dirty_len = (size_t)(addr - dirty_start); } /* end if */ - } /* end if */ + } /* end if */ /* Trim top of accumulator off */ accum->size -= overlap_size; } /* end else */ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ else { /* Write the data */ - if(H5FD_write(file, map_type, addr, size, buf) < 0) + if (H5FD_write(file, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end else */ @@ -828,7 +835,6 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_write() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_free * @@ -843,12 +849,11 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, *------------------------------------------------------------------------- */ herr_t -H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, - hsize_t size) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ + H5FD_t * file; /* File driver pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -862,9 +867,9 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr file = f_sh->lf; /* Adjust the metadata accumulator to remove the freed block, if it overlaps */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) - && H5F_addr_overlap(addr, size, accum->loc, accum->size)) { - size_t overlap_size; /* Size of overlap with accumulator */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && + H5F_addr_overlap(addr, size, accum->loc, accum->size)) { + size_t overlap_size; /* Size of overlap with accumulator */ /* Sanity check */ /* (The metadata accumulator should not intersect w/raw data */ @@ -872,17 +877,17 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr HDassert(H5FD_MEM_GHEAP != type); /* (global heap data is being treated as raw data currently) */ /* Check for overlapping the beginning of the accumulator */ - if(H5F_addr_le(addr, accum->loc)) { + if (H5F_addr_le(addr, accum->loc)) { /* Check for completely overlapping the accumulator */ - if(H5F_addr_ge(addr + size, accum->loc + accum->size)) { + if (H5F_addr_ge(addr + size, accum->loc + accum->size)) { /* Reset the accumulator, but don't free buffer */ - accum->loc = HADDR_UNDEF; - accum->size = 0; + accum->loc = HADDR_UNDEF; + accum->size = 0; accum->dirty = FALSE; } /* end if */ /* Block to free must end within the accumulator */ else { - size_t new_accum_size; /* Size of new accumulator buffer */ + size_t new_accum_size; /* Size of new accumulator buffer */ /* Calculate the size of the overlap with the accumulator, etc. */ H5_CHECKED_ASSIGN(overlap_size, size_t, (addr + size) - accum->loc, haddr_t); @@ -896,13 +901,13 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr accum->size = new_accum_size; /* Adjust the dirty region and possibly mark accumulator clean */ - if(accum->dirty) { + if (accum->dirty) { /* Check if block freed is entirely before dirty region */ - if(overlap_size < accum->dirty_off) + if (overlap_size < accum->dirty_off) accum->dirty_off -= overlap_size; else { /* Check if block freed ends within dirty region */ - if(overlap_size < (accum->dirty_off + accum->dirty_len)) { + if (overlap_size < (accum->dirty_off + accum->dirty_len)) { accum->dirty_len = (accum->dirty_off + accum->dirty_len) - overlap_size; accum->dirty_off = 0; } /* end if */ @@ -910,45 +915,47 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr else accum->dirty = FALSE; } /* end else */ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ /* Block to free must start within the accumulator */ else { - haddr_t dirty_end = accum->loc + accum->dirty_off + accum->dirty_len; + haddr_t dirty_end = accum->loc + accum->dirty_off + accum->dirty_len; haddr_t dirty_start = accum->loc + accum->dirty_off; /* Calculate the size of the overlap with the accumulator */ H5_CHECKED_ASSIGN(overlap_size, size_t, (accum->loc + accum->size) - addr, haddr_t); /* Check if block to free begins before end of dirty region */ - if(accum->dirty && H5F_addr_lt(addr, dirty_end)) { + if (accum->dirty && H5F_addr_lt(addr, dirty_end)) { haddr_t tail_addr; /* Calculate the address of the tail to write */ tail_addr = addr + size; /* Check if the block to free begins before dirty region */ - if(H5F_addr_lt(addr, dirty_start)) { + if (H5F_addr_lt(addr, dirty_start)) { /* Check if block to free is entirely before dirty region */ - if(H5F_addr_le(tail_addr, dirty_start)) { + if (H5F_addr_le(tail_addr, dirty_start)) { /* Write out the entire dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, accum->buf + accum->dirty_off) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start, accum->dirty_len, + accum->buf + accum->dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Block to free overlaps with some/all of dirty region */ /* Check for unfreed dirty region to write */ - else if(H5F_addr_lt(tail_addr, dirty_end)) { + else if (H5F_addr_lt(tail_addr, dirty_end)) { size_t write_size; size_t dirty_delta; - write_size = (size_t)(dirty_end - tail_addr); + write_size = (size_t)(dirty_end - tail_addr); dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, + accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ @@ -958,22 +965,23 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr /* Block to free begins at beginning of or in middle of dirty region */ else { /* Check if block to free ends before end of dirty region */ - if(H5F_addr_lt(tail_addr, dirty_end)) { + if (H5F_addr_lt(tail_addr, dirty_end)) { size_t write_size; size_t dirty_delta; - write_size = (size_t)(dirty_end - tail_addr); + write_size = (size_t)(dirty_end - tail_addr); dirty_delta = accum->dirty_len - write_size; HDassert(write_size > 0); /* Write out the unfreed end of the dirty region of the accumulator */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, accum->buf + accum->dirty_off + dirty_delta) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, dirty_start + dirty_delta, write_size, + accum->buf + accum->dirty_off + dirty_delta) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ /* Check for block to free beginning at same location as dirty region */ - if(H5F_addr_eq(addr, dirty_start)) { + if (H5F_addr_eq(addr, dirty_start)) { /* Reset dirty flag */ accum->dirty = FALSE; } /* end if */ @@ -981,20 +989,19 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr else { accum->dirty_len = (size_t)(addr - dirty_start); } /* end else */ - } /* end else */ + } /* end else */ } /* end if */ /* Adjust the accumulator information */ accum->size = accum->size - overlap_size; } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_free() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_flush * @@ -1010,7 +1017,7 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr herr_t H5F__accum_flush(H5F_shared_t *f_sh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1018,14 +1025,15 @@ H5F__accum_flush(H5F_shared_t *f_sh) HDassert(f_sh); /* Check if we need to flush out the metadata accumulator */ - if((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && f_sh->accum.dirty) { - H5FD_t *file; /* File driver pointer */ + if ((f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) && f_sh->accum.dirty) { + H5FD_t *file; /* File driver pointer */ /* Translate to file driver pointer */ file = f_sh->lf; /* Flush the metadata contents */ - if(H5FD_write(file, H5FD_MEM_DEFAULT, f_sh->accum.loc + f_sh->accum.dirty_off, f_sh->accum.dirty_len, f_sh->accum.buf + f_sh->accum.dirty_off) < 0) + if (H5FD_write(file, H5FD_MEM_DEFAULT, f_sh->accum.loc + f_sh->accum.dirty_off, f_sh->accum.dirty_len, + f_sh->accum.buf + f_sh->accum.dirty_off) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") /* Reset the dirty flag */ @@ -1036,7 +1044,6 @@ H5F__accum_flush(H5F_shared_t *f_sh) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_flush() */ - /*------------------------------------------------------------------------- * Function: H5F__accum_reset * @@ -1052,7 +1059,7 @@ H5F__accum_flush(H5F_shared_t *f_sh) herr_t H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1060,24 +1067,23 @@ H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush) HDassert(f_sh); /* Flush any dirty data in accumulator, if requested */ - if(flush) - if(H5F__accum_flush(f_sh) < 0) + if (flush) + if (H5F__accum_flush(f_sh) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "can't flush metadata accumulator") /* Check if we need to reset the metadata accumulator information */ - if(f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { + if (f_sh->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) { /* Free the buffer */ - if(f_sh->accum.buf) + if (f_sh->accum.buf) f_sh->accum.buf = H5FL_BLK_FREE(meta_accum, f_sh->accum.buf); /* Reset the buffer sizes & location */ f_sh->accum.alloc_size = f_sh->accum.size = 0; - f_sh->accum.loc = HADDR_UNDEF; - f_sh->accum.dirty = FALSE; - f_sh->accum.dirty_len = 0; + f_sh->accum.loc = HADDR_UNDEF; + f_sh->accum.dirty = FALSE; + f_sh->accum.dirty_len = 0; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__accum_reset() */ - diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index 2b368d54c2e..d689737566e 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -33,19 +33,17 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5HGprivate.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5HGprivate.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -55,40 +53,32 @@ * Maximum length of the CWFS list, the list of remembered collections that * have free space. */ -#define H5F_NCWFS 16 - +#define H5F_NCWFS 16 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F_cwfs_add * @@ -105,7 +95,7 @@ herr_t H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -119,23 +109,25 @@ H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) * necessary to make room. We remove the right-most entry that has less * free space than this heap. */ - if(NULL == f->shared->cwfs) { - if(NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5F_NCWFS * sizeof(H5HG_heap_t *)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate CWFS for file") - f->shared->cwfs[0] = heap; - f->shared->ncwfs = 1; - } else if(H5F_NCWFS == f->shared->ncwfs) { - int i; /* Local index variable */ - - for(i = H5F_NCWFS - 1; i >= 0; --i) - if(H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { + if (NULL == f->shared->cwfs) { + if (NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5F_NCWFS * sizeof(H5HG_heap_t *)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate CWFS for file") + f->shared->cwfs[0] = heap; + f->shared->ncwfs = 1; + } + else if (H5F_NCWFS == f->shared->ncwfs) { + int i; /* Local index variable */ + + for (i = H5F_NCWFS - 1; i >= 0; --i) + if (H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, (size_t)i * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; break; } /* end if */ - } else { + } + else { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, f->shared->ncwfs * sizeof(H5HG_heap_t *)); - f->shared->cwfs[0] = heap; + f->shared->cwfs[0] = heap; f->shared->ncwfs += 1; } /* end else */ @@ -143,7 +135,6 @@ H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_add() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_find_free_heap * @@ -161,9 +152,9 @@ H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr) { - unsigned cwfsno; /* Local index for iterating over collections */ - hbool_t found = FALSE; /* Flag to indicate a heap with enough space was found */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cwfsno; /* Local index for iterating over collections */ + hbool_t found = FALSE; /* Flag to indicate a heap with enough space was found */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -188,59 +179,60 @@ H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr) * * JRM - 5/24/04 */ - for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) - if(H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]) >= need) { - *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); + for (cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) + if (H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]) >= need) { + *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); found = TRUE; - break; - } /* end if */ + break; + } /* end if */ /* * If we didn't find any collection with enough free space the check if * we can extend any of the collections to make enough room. */ - if(!found) { + if (!found) { size_t new_need; - for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) { + for (cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) { new_need = need; new_need -= H5HG_FREE_SIZE(f->shared->cwfs[cwfsno]); new_need = MAX(H5HG_SIZE(f->shared->cwfs[cwfsno]), new_need); - if((H5HG_SIZE(f->shared->cwfs[cwfsno]) + new_need) <= H5HG_MAXSIZE) { - htri_t was_extended; /* Whether the heap was extended */ + if ((H5HG_SIZE(f->shared->cwfs[cwfsno]) + new_need) <= H5HG_MAXSIZE) { + htri_t was_extended; /* Whether the heap was extended */ - was_extended = H5MF_try_extend(f, H5FD_MEM_GHEAP, H5HG_ADDR(f->shared->cwfs[cwfsno]), (hsize_t)H5HG_SIZE(f->shared->cwfs[cwfsno]), (hsize_t)new_need); - if(was_extended < 0) + was_extended = + H5MF_try_extend(f, H5FD_MEM_GHEAP, H5HG_ADDR(f->shared->cwfs[cwfsno]), + (hsize_t)H5HG_SIZE(f->shared->cwfs[cwfsno]), (hsize_t)new_need); + if (was_extended < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "error trying to extend heap") - else if(was_extended == TRUE) { - if(H5HG_extend(f, H5HG_ADDR(f->shared->cwfs[cwfsno]), new_need) < 0) + else if (was_extended == TRUE) { + if (H5HG_extend(f, H5HG_ADDR(f->shared->cwfs[cwfsno]), new_need) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to extend global heap collection") *addr = H5HG_ADDR(f->shared->cwfs[cwfsno]); found = TRUE; break; } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ - if(found) { + if (found) { /* Move the collection forward in the CWFS list, if it's not * already at the front */ - if(cwfsno > 0) { + if (cwfsno > 0) { H5HG_heap_t *tmp = f->shared->cwfs[cwfsno]; - f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno - 1]; + f->shared->cwfs[cwfsno] = f->shared->cwfs[cwfsno - 1]; f->shared->cwfs[cwfsno - 1] = tmp; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_find_free_heap() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_advance_heap * @@ -257,8 +249,8 @@ H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr) herr_t H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -267,16 +259,16 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) HDassert(f->shared); HDassert(heap); - for(u = 0; u < f->shared->ncwfs; u++) - if(f->shared->cwfs[u] == heap) { - if(u) { - f->shared->cwfs[u] = f->shared->cwfs[u - 1]; + for (u = 0; u < f->shared->ncwfs; u++) + if (f->shared->cwfs[u] == heap) { + if (u) { + f->shared->cwfs[u] = f->shared->cwfs[u - 1]; f->shared->cwfs[u - 1] = heap; } /* end if */ break; } /* end if */ - if(add_heap && u >= f->shared->ncwfs) { - f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5F_NCWFS); + if (add_heap && u >= f->shared->ncwfs) { + f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5F_NCWFS); f->shared->cwfs[f->shared->ncwfs - 1] = heap; } /* end if */ @@ -284,7 +276,6 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_advance_heap() */ - /*------------------------------------------------------------------------- * Function: H5F_cwfs_remove_heap * @@ -301,8 +292,8 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) herr_t H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -311,15 +302,14 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) HDassert(heap); /* Remove the heap from the CWFS list */ - for(u = 0; u < shared->ncwfs; u++) { - if(shared->cwfs[u] == heap) { + for (u = 0; u < shared->ncwfs; u++) { + if (shared->cwfs[u] == heap) { shared->ncwfs -= 1; HDmemmove(shared->cwfs + u, shared->cwfs + u + 1, (shared->ncwfs - u) * sizeof(H5HG_heap_t *)); break; } /* end if */ - } /* end for */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_remove_heap() */ - diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 09f68298c40..5157180e328 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,18 +17,16 @@ * Purpose: File object debugging functions. */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Pprivate.h" /* Property lists */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Pprivate.h" /* Property lists */ - - /*------------------------------------------------------------------------- * Function: H5F_debug * @@ -46,9 +44,9 @@ herr_t H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) { - H5P_genplist_t *plist; /* File creation property list */ - hsize_t userblock_size; /* Userblock size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* File creation property list */ + hsize_t userblock_size; /* Userblock size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -59,73 +57,69 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Get property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve file creation properties */ - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get userblock size") /* debug */ HDfprintf(stream, "%*sFile Super Block...\n", indent, ""); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "File name (as opened):", H5F_OPEN_NAME(f)); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "File name (as opened):", H5F_OPEN_NAME(f)); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f)); - HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, - "File access flags", f->shared->flags); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "File open reference count:", f->shared->nrefs); - HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth, - "Address of super block:", f->shared->sblock->base_addr); - HDfprintf(stream, "%*s%-*s %Hu bytes\n", indent, "", fwidth, - "Size of userblock:", userblock_size); + "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f)); + HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "File access flags", f->shared->flags); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "File open reference count:", f->shared->nrefs); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (abs)\n", indent, "", fwidth, + "Address of super block:", f->shared->sblock->base_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " bytes\n", indent, "", fwidth, + "Size of userblock:", userblock_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Superblock version number:", f->shared->sblock->super_vers); + "Superblock version number:", f->shared->sblock->super_vers); /* Hard-wired versions */ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Free list version number:", (unsigned)HDF5_FREESPACE_VERSION); + "Free list version number:", (unsigned)HDF5_FREESPACE_VERSION); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Root group symbol table entry version number:", (unsigned)HDF5_OBJECTDIR_VERSION); + "Root group symbol table entry version number:", (unsigned)HDF5_OBJECTDIR_VERSION); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Shared header version number:", (unsigned)HDF5_SHAREDHEADER_VERSION); + "Shared header version number:", (unsigned)HDF5_SHAREDHEADER_VERSION); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr); + "Size of file offsets (haddr_t type):", (unsigned)f->shared->sizeof_addr); HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, - "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size); + "Size of file lengths (hsize_t type):", (unsigned)f->shared->sizeof_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); + "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); + "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]); + "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]); HDfprintf(stream, "%*s%-*s 0x%02x\n", indent, "", fwidth, - "File status flags:", (unsigned)(f->shared->sblock->status_flags)); - HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Superblock extension address:", f->shared->sblock->ext_addr); - HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Shared object header message table address:", f->shared->sohm_addr); + "File status flags:", (unsigned)(f->shared->sblock->status_flags)); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth, + "Superblock extension address:", f->shared->sblock->ext_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth, + "Shared object header message table address:", f->shared->sohm_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Shared object header message version number:", (unsigned) f->shared->sohm_vers); + "Shared object header message version number:", (unsigned)f->shared->sohm_vers); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of shared object header message indexes:", (unsigned) f->shared->sohm_nindexes); + "Number of shared object header message indexes:", (unsigned)f->shared->sohm_nindexes); - HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Address of driver information block:", f->shared->sblock->driver_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth, + "Address of driver information block:", f->shared->sblock->driver_addr); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Root group symbol table entry:", - f->shared->root_grp ? "" : "(none)"); - if(f->shared->root_grp) { - if(f->shared->sblock->root_ent) /* Use real root group symbol table entry */ + "Root group symbol table entry:", f->shared->root_grp ? "" : "(none)"); + if (f->shared->root_grp) { + 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 */ - H5G_entry_t root_ent; /* Constructed root symbol table entry */ + H5O_loc_t * root_oloc; /* Root object location */ + H5G_entry_t root_ent; /* Constructed root symbol table entry */ /* Reset the root group entry */ H5G__ent_reset(&root_ent); @@ -133,15 +127,14 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) /* Build up a simulated root group symbol table entry */ root_oloc = H5G_oloc(f->shared->root_grp); HDassert(root_oloc); - root_ent.type = H5G_NOTHING_CACHED; + root_ent.type = H5G_NOTHING_CACHED; root_ent.header = root_oloc->addr; /* Display root group symbol table entry info */ H5G__ent_debug(&root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_debug() */ - diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index bd5c7ba1d5a..81ffcdf51b6 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,127 +29,143 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Fget_info1 * * Purpose: Gets general information about the file, including: - * 1. Get storage size for superblock extension if there is one. + * 1. Get storage size for superblock extension if there is one. * 2. Get the amount of btree and heap storage for entries * in the SOHM table if there is one. - * 3. The amount of free space tracked in the file. - * - * Return: Success: non-negative on success - * Failure: Negative + * 3. The amount of free space tracked in the file. * - * Programmer: Vailin Choi - * July 11, 2007 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ - H5F_info2_t finfo2; /* Current file info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; + H5F_info2_t finfo2; /* Current file info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); /* Check args */ - if(!finfo) + if (!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") - f = loc.oloc->file; - } /* end else */ - HDassert(f->shared); - - /* Get the current file info */ - if(H5F__get_info(f, &finfo2) < 0) + /* Check the type */ + type = H5I_get_type(obj_id); + if (H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && + H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Get the file information */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + type, &finfo2) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ finfo->super_ext_size = finfo2.super.super_ext_size; - finfo->sohm.hdr_size = finfo2.sohm.hdr_size; + finfo->sohm.hdr_size = finfo2.sohm.hdr_size; finfo->sohm.msgs_info = finfo2.sohm.msgs_info; done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info1() */ - +/*------------------------------------------------------------------------- + * Function: H5Fis_hdf5 + * + * Purpose: Check the file signature to detect an HDF5 file. + * + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. + * + * Return: TRUE/FALSE/FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5Fis_hdf5(const char *name) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_API((-1)) + H5TRACE1("t", "*s", name); + + /* Check args and all the boring stuff. */ + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") + + /* Check if file is accessible */ + if (H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable to determine if file is accessible as HDF5") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fis_hdf5() */ + /*------------------------------------------------------------------------- * Function: H5Fset_latest_format * * Purpose: Enable switching between latest or non-latest format while * a file is open. * This is deprecated starting release 1.10.2 and is modified - * to call the private H5F__set_libver_bounds() to set the + * to call the private H5F_set_libver_bounds() to set the * bounds. * * Before release 1.10.2, the library supports only two @@ -180,29 +196,34 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { - H5F_t *f; /* File */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File as VOL object */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* 'low' and 'high' are both initialized to LATEST. - If latest format is not expected, set 'low' to EARLIEST */ - if(!latest_format) + * If latest format is not expected, set 'low' to EARLIEST + */ + if (!latest_format) low = H5F_LIBVER_EARLIEST; - /* Call private set_libver_bounds function to set the bounds */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + /* Set the library's version bounds */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)low, (int)high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) } /* end H5Fset_latest_format() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 46adfc7d0bb..3f9a22ff49e 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,54 +24,54 @@ *------------------------------------------------------------------------- */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* Special values for the "tag" field below */ -#define H5F_EFC_TAG_DEFAULT -1 -#define H5F_EFC_TAG_LOCK -2 -#define H5F_EFC_TAG_CLOSE -3 -#define H5F_EFC_TAG_DONTCLOSE -4 +#define H5F_EFC_TAG_DEFAULT -1 +#define H5F_EFC_TAG_LOCK -2 +#define H5F_EFC_TAG_CLOSE -3 +#define H5F_EFC_TAG_DONTCLOSE -4 /* 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 */ - 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 */ + 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 */ } 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 */ - 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() */ + 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() */ }; /* Private prototypes */ static herr_t H5F__efc_release_real(H5F_efc_t *efc); static herr_t H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent); -static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail); -static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail); +static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail); +static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail); /* Free lists */ H5FL_DEFINE_STATIC(H5F_efc_ent_t); H5FL_DEFINE_STATIC(H5F_efc_t); - /*------------------------------------------------------------------------- * Function: H5F__efc_create * @@ -90,8 +90,8 @@ H5FL_DEFINE_STATIC(H5F_efc_t); H5F_efc_t * H5F__efc_create(unsigned max_nfiles) { - H5F_efc_t *efc = NULL; /* EFC object */ - H5F_efc_t *ret_value = NULL; /* Return value */ + H5F_efc_t *efc = NULL; /* EFC object */ + H5F_efc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -99,7 +99,7 @@ H5F__efc_create(unsigned max_nfiles) HDassert(max_nfiles > 0); /* Allocate EFC struct */ - if(NULL == (efc = H5FL_CALLOC(H5F_efc_t))) + if (NULL == (efc = H5FL_CALLOC(H5F_efc_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize maximum number of files */ @@ -112,13 +112,12 @@ H5F__efc_create(unsigned max_nfiles) ret_value = efc; done: - if(ret_value == NULL && efc) + if (ret_value == NULL && efc) efc = H5FL_FREE(H5F_efc_t, efc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_create() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_open * @@ -141,10 +140,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 */ - hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ - H5F_t *ret_value = NULL; /* Return value */ + 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 */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5F_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -153,16 +154,32 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HDassert(parent->shared); HDassert(name); + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + /* Get external file cache */ efc = parent->shared->efc; /* Check if the EFC exists. If it does not, just call H5F_open(). We * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ - if(!efc) { - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (!efc) { + if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") + /* Make file post open call */ + if (H5F__post_open(ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") + /* Increment the number of open objects to prevent the file from being * closed out from under us - "simulate" having an open file id. Note * that this behaviour replaces the calls to H5F_incr_nopen_objs() and @@ -174,31 +191,31 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Search the skip list for name if the skip list exists, create the skip * list otherwise */ - if(efc->slist) { - if(efc->nfiles > 0) + if (efc->slist) { + if (efc->nfiles > 0) ent = (H5F_efc_ent_t *)H5SL_search(efc->slist, name); } /* end if */ else { HDassert(efc->nfiles == 0); - if(NULL == (efc->slist = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (efc->slist = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't create skip list") } /* end else */ /* If we found the file update the LRU list and return the cached file, * otherwise open the file and cache it */ - if(ent) { + if (ent) { HDassert(efc->LRU_head); HDassert(efc->LRU_tail); /* Move ent to the head of the LRU list, if it is not already there */ - if(ent->LRU_prev) { + if (ent->LRU_prev) { HDassert(efc->LRU_head != ent); /* Remove from current position. Note that once we touch the LRU * list we cannot revert to the previous state. Make sure there can * be no errors between when we first touch the LRU list and when * the cache is in a consistent state! */ - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent->LRU_prev; else { HDassert(efc->LRU_tail == ent); @@ -207,10 +224,10 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi ent->LRU_prev->LRU_next = ent->LRU_next; /* Add to head of LRU list */ - ent->LRU_next = efc->LRU_head; + ent->LRU_next = efc->LRU_head; ent->LRU_next->LRU_prev = ent; - ent->LRU_prev = NULL; - efc->LRU_head = ent; + ent->LRU_prev = NULL; + efc->LRU_head = ent; } /* end if */ /* Mark the file as open */ @@ -218,23 +235,28 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi } /* end if */ else { /* Check if we need to evict something */ - if(efc->nfiles == efc->max_nfiles) { + if (efc->nfiles == efc->max_nfiles) { /* Search for an unopened file from the tail */ - for(ent = efc->LRU_tail; ent && ent->nopen; ent = ent->LRU_prev); + for (ent = efc->LRU_tail; ent && ent->nopen; ent = ent->LRU_prev) + ; /* Evict the file if found, otherwise just open the target file and * do not add it to cache */ - if(ent) { - if(H5F__efc_remove_ent(efc, ent) < 0) + if (ent) { + if (H5F__efc_remove_ent(efc, ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, NULL, "can't remove entry from external file cache") /* Do not free ent, we will recycle it below */ } /* end if */ else { /* Cannot cache file, just open file and return */ - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") + /* Make file post open call */ + if (H5F__post_open(ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") + /* Increment the number of open objects to prevent the file from * being closed out from under us - "simulate" having an open * file id */ @@ -242,37 +264,41 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HGOTO_DONE(ret_value) } /* end else */ - } /* end if */ + } /* end if */ else /* Allocate new entry */ - if(NULL == (ent = H5FL_MALLOC(H5F_efc_ent_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ent = H5FL_MALLOC(H5F_efc_ent_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build new entry */ - if(NULL == (ent->name = H5MM_strdup(name))) + if (NULL == (ent->name = H5MM_strdup(name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Open the file */ - if(NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") open_file = TRUE; + /* Make file post open call */ + if (H5F__post_open(ent->file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") + /* Increment the number of open objects to prevent the file from being * closed out from under us - "simulate" having an open file id */ ent->file->nopen_objs++; /* Add the file to the cache */ /* Skip list */ - if(H5SL_insert(efc->slist, ent, ent->name) < 0) + if (H5SL_insert(efc->slist, ent, ent->name) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, NULL, "can't insert entry into skip list") /* Add to head of LRU list and update tail if necessary */ ent->LRU_next = efc->LRU_head; - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent; ent->LRU_prev = NULL; efc->LRU_head = ent; - if(!efc->LRU_tail) { + if (!efc->LRU_tail) { HDassert(!ent->LRU_next); efc->LRU_tail = ent; } /* end if */ @@ -282,7 +308,7 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi /* Update nfiles and nrefs */ efc->nfiles++; - if(ent->file->shared->efc) + if (ent->file->shared->efc) ent->file->shared->efc->nrefs++; } /* end else */ @@ -295,21 +321,20 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi ret_value = ent->file; done: - if(!ret_value) - if(ent) { - if(open_file) { + if (!ret_value) + if (ent) { + if (open_file) { ent->file->nopen_objs--; - if(H5F_try_close(ent->file, NULL) < 0) + if (H5F_try_close(ent->file, NULL) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close external file") } /* end if */ ent->name = (char *)H5MM_xfree(ent->name); - ent = H5FL_FREE(H5F_efc_ent_t, ent); + ent = H5FL_FREE(H5F_efc_ent_t, ent); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_open() */ - /*------------------------------------------------------------------------- * Function: H5F_efc_close * @@ -328,9 +353,9 @@ 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_ent_t *ent = NULL; /* Entry for target file in efc */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_NOINIT @@ -346,9 +371,9 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) /* Check if the EFC exists. If it does not, just call H5F_try_close(). We * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ - if(!efc) { + if (!efc) { file->nopen_objs--; - if(H5F_try_close(file, NULL) < 0) + if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") HGOTO_DONE(SUCCEED) @@ -359,10 +384,11 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) * the head. In the unlikely case that the file is not found, just call * H5F_try_close(). This could happen if the EFC was full of open files * when the file was opened. */ - for(ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next); - if(!ent) { + for (ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next) + ; + if (!ent) { file->nopen_objs--; - if(H5F_try_close(file, NULL) < 0) + if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") } /* end if */ else @@ -373,7 +399,6 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_efc_close() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_max_nfiles * @@ -398,7 +423,6 @@ H5F__efc_max_nfiles(H5F_efc_t *efc) FUNC_LEAVE_NOAPI(efc->max_nfiles) } /* end H5F__efc_max_nfiles */ - /*------------------------------------------------------------------------- * Function: H5F__efc_release_real * @@ -417,9 +441,9 @@ H5F__efc_max_nfiles(H5F_efc_t *efc) static herr_t H5F__efc_release_real(H5F_efc_t *efc) { - H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_efc_ent_t *prev_ent = NULL; /* Previous EFC entry */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_efc_ent_t *prev_ent = NULL; /* Previous EFC entry */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -431,21 +455,20 @@ H5F__efc_release_real(H5F_efc_t *efc) * would require a cycle, a cycle would necessarily invoke * H5F__efc_try_close(), and that function checks the status of the lock * before calling this one. */ - HDassert((efc->tag == H5F_EFC_TAG_DEFAULT) - || (efc->tag == H5F_EFC_TAG_CLOSE)); + HDassert((efc->tag == H5F_EFC_TAG_DEFAULT) || (efc->tag == H5F_EFC_TAG_CLOSE)); efc->tag = H5F_EFC_TAG_LOCK; /* Walk down the LRU list, releasing any files that are not opened by an EFC * client */ ent = efc->LRU_head; - while(ent) - if(!ent->nopen) { - if(H5F__efc_remove_ent(efc, ent) < 0) + while (ent) + if (!ent->nopen) { + if (H5F__efc_remove_ent(efc, ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "can't remove entry from external file cache") /* Free the entry and move to next entry in LRU list */ prev_ent = ent; - ent = ent->LRU_next; + ent = ent->LRU_next; prev_ent = H5FL_FREE(H5F_efc_ent_t, prev_ent); } /* end if */ else @@ -460,7 +483,6 @@ H5F__efc_release_real(H5F_efc_t *efc) FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__efc_release_real() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_release * @@ -479,7 +501,7 @@ H5F__efc_release_real(H5F_efc_t *efc) herr_t H5F__efc_release(H5F_efc_t *efc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -487,14 +509,13 @@ H5F__efc_release(H5F_efc_t *efc) HDassert(efc); /* Call 'real' routine */ - if(H5F__efc_release_real(efc) < 0) + if (H5F__efc_release_real(efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't remove entry from external file cache") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_efc_release() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_destroy * @@ -513,20 +534,20 @@ H5F__efc_release(H5F_efc_t *efc) herr_t H5F__efc_destroy(H5F_efc_t *efc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(efc); - if(efc->nfiles > 0) { + if (efc->nfiles > 0) { /* Release (clear) the efc */ - if(H5F__efc_release_real(efc) < 0) + if (H5F__efc_release_real(efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* If there are still cached files, return an error */ - if(efc->nfiles > 0) + if (efc->nfiles > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't destroy EFC after incomplete release") } /* end if */ @@ -535,8 +556,8 @@ H5F__efc_destroy(H5F_efc_t *efc) HDassert(efc->LRU_tail == NULL); /* Close skip list */ - if(efc->slist) - if(H5SL_close(efc->slist) < 0) + if (efc->slist) + if (H5SL_close(efc->slist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close skip list") /* Free EFC object */ @@ -546,7 +567,6 @@ H5F__efc_destroy(H5F_efc_t *efc) FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__efc_destroy() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_remove_ent * @@ -564,7 +584,7 @@ H5F__efc_destroy(H5F_efc_t *efc) static herr_t H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -574,17 +594,17 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) HDassert(ent); /* Remove from skip list */ - if(ent != H5SL_remove(efc->slist, ent->name)) + if (ent != H5SL_remove(efc->slist, ent->name)) HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "can't delete entry from skip list") /* Remove from LRU list */ - if(ent->LRU_next) + if (ent->LRU_next) ent->LRU_next->LRU_prev = ent->LRU_prev; else { HDassert(efc->LRU_tail == ent); efc->LRU_tail = ent->LRU_prev; } /* end else */ - if(ent->LRU_prev) + if (ent->LRU_prev) ent->LRU_prev->LRU_next = ent->LRU_next; else { HDassert(efc->LRU_head == ent); @@ -593,7 +613,7 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) /* Update nfiles and nrefs */ efc->nfiles--; - if(ent->file->shared->efc) + if (ent->file->shared->efc) ent->file->shared->efc->nrefs--; /* Free the name */ @@ -604,7 +624,7 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) * However we must still manipulate the nopen_objs field to prevent the file * from being closed out from under us. */ ent->file->nopen_objs--; - if(H5F_try_close(ent->file, NULL) < 0) + if (H5F_try_close(ent->file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") ent->file = NULL; @@ -612,7 +632,6 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_remove_ent() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close_tag1 * @@ -630,8 +649,8 @@ H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent) 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_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR @@ -644,17 +663,17 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) HDassert(*tail); /* Recurse into this file's cached files */ - for(ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { + for (ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { esf = ent->file->shared; - if(esf->efc) { + if (esf->efc) { /* If tag were 0, that would mean there are more actual references * than are counted by nrefs */ HDassert(esf->efc->tag != 0); /* If tag has been set, we have already visited this file so just * decrement tag and continue */ - if(esf->efc->tag > 0) + if (esf->efc->tag > 0) esf->efc->tag--; /* If there are references that are not from an EFC, it will never * be possible to close the file. Just continue. Also continue if @@ -662,8 +681,8 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) * that the reference counts will never match for the root file, but * that's ok because the root file will always have a tag and enter * the branch above. */ - else if((esf->nrefs == esf->efc->nrefs) - && (esf->efc->tag != H5F_EFC_TAG_LOCK) && !(ent->nopen)) { + else if ((esf->nrefs == esf->efc->nrefs) && (esf->efc->tag != H5F_EFC_TAG_LOCK) && + !(ent->nopen)) { /* If we get here, this file's "tmp_next" pointer must be NULL */ HDassert(esf->efc->tmp_next == NULL); @@ -671,22 +690,21 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) /* If nrefs > 1, Add this file to the list of files with nrefs > * 1 and initialize tag to the number of references (except this * one) */ - if(esf->nrefs > 1) { + if (esf->nrefs > 1) { (*tail)->efc->tmp_next = esf; - *tail = esf; - esf->efc->tag = (int)esf->nrefs - 1; + *tail = esf; + esf->efc->tag = (int)esf->nrefs - 1; } /* end if */ /* Recurse into the entry */ H5F__efc_try_close_tag1(ent->file->shared, tail); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ FUNC_LEAVE_NOAPI_VOID } /* end H5F__efc_try_close_tag1() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close_tag2 * @@ -704,8 +722,8 @@ H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) 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_efc_ent_t *ent = NULL; /* EFC entry */ + H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR @@ -714,7 +732,7 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) HDassert(sf->efc); /* Recurse into this file's cached files */ - for(ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { + for (ent = sf->efc->LRU_head; ent; ent = ent->LRU_next) { esf = ent->file->shared; /* Only recurse if the file is tagged CLOSE or DEFAULT. If it is tagged @@ -725,39 +743,36 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) * make sure we do not go off into somewhere cb1 didn't touch. The * root file should never be tagged DEFAULT here, so the reference check * is still appropriate. */ - if((esf->efc) && ((esf->efc->tag == H5F_EFC_TAG_CLOSE) - || ((esf->efc->tag == H5F_EFC_TAG_DEFAULT) - && (esf->nrefs == esf->efc->nrefs) && !(ent->nopen)))) { + if ((esf->efc) && + ((esf->efc->tag == H5F_EFC_TAG_CLOSE) || + ((esf->efc->tag == H5F_EFC_TAG_DEFAULT) && (esf->nrefs == esf->efc->nrefs) && !(ent->nopen)))) { /* tag should always be CLOSE is nrefs > 1 or DEFAULT if nrefs == 1 * here */ - HDassert(((esf->nrefs > 1) - && ((esf->efc->tag == H5F_EFC_TAG_CLOSE))) - || ((esf->nrefs == 1) - && (esf->efc->tag == H5F_EFC_TAG_DEFAULT))); + HDassert(((esf->nrefs > 1) && ((esf->efc->tag == H5F_EFC_TAG_CLOSE))) || + ((esf->nrefs == 1) && (esf->efc->tag == H5F_EFC_TAG_DEFAULT))); /* If tag is set to DONTCLOSE, we have already visited this file * *or* it will be the start point of another iteration so just * continue */ - if(esf->efc->tag != H5F_EFC_TAG_DONTCLOSE) { + if (esf->efc->tag != H5F_EFC_TAG_DONTCLOSE) { /* If tag is CLOSE, set to DONTCLOSE and add to the list of * uncloseable files. */ - if(esf->efc->tag == H5F_EFC_TAG_CLOSE) { - esf->efc->tag = H5F_EFC_TAG_DONTCLOSE; - esf->efc->tmp_next = NULL; + if (esf->efc->tag == H5F_EFC_TAG_CLOSE) { + esf->efc->tag = H5F_EFC_TAG_DONTCLOSE; + esf->efc->tmp_next = NULL; (*tail)->efc->tmp_next = esf; - *tail = esf; + *tail = esf; } /* end if */ /* Recurse into the entry */ H5F__efc_try_close_tag2(esf, tail); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ FUNC_LEAVE_NOAPI_VOID } /* end H5F__efc_try_close_tag2() */ - /*------------------------------------------------------------------------- * Function: H5F__efc_try_close * @@ -811,12 +826,14 @@ H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) herr_t H5F__efc_try_close(H5F_t *f) { - H5F_shared_t *tail; /* Tail of linked list of found files. Head will be f->shared. */ - H5F_shared_t *uncloseable_head = NULL; /* Head of linked list of files found to be uncloseable by the first pass */ - H5F_shared_t *uncloseable_tail = NULL; /* Tail of linked list of files found to be uncloseable by the first pass */ - H5F_shared_t *sf; /* Temporary file pointer */ - H5F_shared_t *next; /* Temporary file pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_shared_t *tail; /* Tail of linked list of found files. Head will be f->shared. */ + H5F_shared_t *uncloseable_head = + NULL; /* Head of linked list of files found to be uncloseable by the first pass */ + H5F_shared_t *uncloseable_tail = + NULL; /* Tail of linked list of files found to be uncloseable by the first pass */ + H5F_shared_t *sf; /* Temporary file pointer */ + H5F_shared_t *next; /* Temporary file pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -828,12 +845,12 @@ H5F__efc_try_close(H5F_t *f) HDassert(f->shared->nrefs > 1); HDassert(f->shared->efc->tag < 0); - if(f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { + if (f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { /* We must have reentered this function, and we should close this file. * In actuality, we just release the EFC, the recursion should * eventually reduce this file's reference count to 1 (though possibly * not from this call to H5F__efc_release_real()). */ - if(H5F__efc_release_real(f->shared->efc) < 0) + if (H5F__efc_release_real(f->shared->efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* If we marked the file as closeable, there must be no open files in @@ -859,9 +876,8 @@ H5F__efc_try_close(H5F_t *f) * not close/release it */ /* If nfiles is 0, then there is nothing to do. Just return. This may also * occur on reentry (for example if this file was previously released). */ - if((f->shared->nrefs != f->shared->efc->nrefs + 1) - || (f->shared->efc->tag == H5F_EFC_TAG_DONTCLOSE) - || (f->shared->efc->nfiles == 0)) + if ((f->shared->nrefs != f->shared->efc->nrefs + 1) || (f->shared->efc->tag == H5F_EFC_TAG_DONTCLOSE) || + (f->shared->efc->nfiles == 0)) /* We must have reentered this function, and we should not close this * file. Just return. */ HGOTO_DONE(SUCCEED) @@ -889,13 +905,13 @@ H5F__efc_try_close(H5F_t *f) /* Check if f->shared->efc->tag dropped to 0. If it did not, * we cannot close anything. Just reset temporary values and return. */ - if(f->shared->efc->tag > 0) { + if (f->shared->efc->tag > 0) { sf = f->shared; - while(sf) { - next = sf->efc->tmp_next; - sf->efc->tag = H5F_EFC_TAG_DEFAULT; + while (sf) { + next = sf->efc->tmp_next; + sf->efc->tag = H5F_EFC_TAG_DEFAULT; sf->efc->tmp_next = NULL; - sf = next; + sf = next; } /* end while */ HGOTO_DONE(SUCCEED) } /* end if */ @@ -903,19 +919,19 @@ H5F__efc_try_close(H5F_t *f) /* Run through the linked list , separating into two lists, one with tag == * 0 and one with tag > 0. Mark them as either H5F_EFC_TAG_CLOSE or * H5F_EFC_TAG_DONTCLOSE as appropriate. */ - sf = f->shared; + sf = f->shared; tail = NULL; - while(sf) { + while (sf) { HDassert(sf->efc->tag >= 0); next = sf->efc->tmp_next; - if(sf->efc->tag > 0) { + if (sf->efc->tag > 0) { /* Remove from main list */ HDassert(tail); tail->efc->tmp_next = sf->efc->tmp_next; - sf->efc->tmp_next = NULL; + sf->efc->tmp_next = NULL; /* Add to uncloseable list */ - if(!uncloseable_head) + if (!uncloseable_head) uncloseable_head = sf; else uncloseable_tail->efc->tmp_next = sf; @@ -926,7 +942,7 @@ H5F__efc_try_close(H5F_t *f) } /* end if */ else { sf->efc->tag = H5F_EFC_TAG_CLOSE; - tail = sf; + tail = sf; } /* end else */ sf = next; } /* end while */ @@ -939,20 +955,20 @@ H5F__efc_try_close(H5F_t *f) * so we know when to stop. We do not need to keep track of the closeable * list any more. */ sf = uncloseable_head; - if(sf) { + if (sf) { tail = uncloseable_tail; HDassert(tail); - while(sf != tail->efc->tmp_next) { + while (sf != tail->efc->tmp_next) { H5F__efc_try_close_tag2(sf, &uncloseable_tail); sf = sf->efc->tmp_next; } /* end while */ - } /* end if */ + } /* end if */ /* If the root file's tag is still H5F_EFC_TAG_CLOSE, release its EFC. This * should start the recursive release that should close all closeable files. * Also, see the top of this function. */ - if(f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { - if(H5F__efc_release_real(f->shared->efc) < 0) + if (f->shared->efc->tag == H5F_EFC_TAG_CLOSE) { + if (H5F__efc_release_real(f->shared->efc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") /* Make sure the file's reference count is now 1 and will be closed by @@ -962,18 +978,17 @@ H5F__efc_try_close(H5F_t *f) /* Clean up uncloseable files (reset tag and tmp_next). All closeable files * should have been closed, and therefore do not need to be cleaned up. */ - if(uncloseable_head) { + if (uncloseable_head) { sf = uncloseable_head; - while(sf) { + while (sf) { next = sf->efc->tmp_next; HDassert(sf->efc->tag == H5F_EFC_TAG_DONTCLOSE); - sf->efc->tag = H5F_EFC_TAG_DEFAULT; + sf->efc->tag = H5F_EFC_TAG_DEFAULT; sf->efc->tmp_next = NULL; - sf = next; + sf = next; } /* end while */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_try_close() */ - diff --git a/src/H5Ffake.c b/src/H5Ffake.c index 36fea5bb0cf..1aae0fd08a2 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -6,22 +6,20 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ /* PRIVATE PROTOTYPES */ - /*------------------------------------------------------------------------- * Function: H5F_fake_alloc * @@ -41,19 +39,19 @@ H5F_t * H5F_fake_alloc(uint8_t sizeof_size) { - H5F_t *f = NULL; /* Pointer to fake file struct */ - H5F_t *ret_value = NULL; /* Return value */ + H5F_t *f = NULL; /* Pointer to fake file struct */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate faked file struct */ - if(NULL == (f = H5FL_CALLOC(H5F_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - if(NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") + if (NULL == (f = H5FL_CALLOC(H5F_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") + if (NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") /* Only set fields necessary for clients */ - if(sizeof_size == 0) + if (sizeof_size == 0) f->shared->sizeof_size = H5F_OBJ_SIZE_SIZE; else f->shared->sizeof_size = sizeof_size; @@ -62,13 +60,12 @@ H5F_fake_alloc(uint8_t sizeof_size) ret_value = f; done: - if(!ret_value) + if (!ret_value) H5F_fake_free(f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_fake_alloc() */ - /*------------------------------------------------------------------------- * Function: H5F_fake_free * @@ -88,13 +85,12 @@ H5F_fake_free(H5F_t *f) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Free faked file struct */ - if(f) { + if (f) { /* Destroy shared file struct */ - if(f->shared) + if (f->shared) f->shared = H5FL_FREE(H5F_shared_t, f->shared); f = H5FL_FREE(H5F_t, f); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F_fake_free() */ - diff --git a/src/H5Fint.c b/src/H5Fint.c index eaa5a02ebcb..a8039b2e853 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,29 +15,30 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ @@ -49,40 +50,43 @@ /* 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 */ + 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 */ struct { - hbool_t local; /* Set flag for "local" file searches */ + 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 */ - size_t max_nobjs; /* Maximum # of IDs to put into array */ + size_t list_index; /* Current index in open ID array */ + size_t max_nobjs; /* Maximum # of IDs to put into array */ } H5F_olist_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, 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 herr_t H5F__close_cb(H5VL_object_t *file_vol_obj); +static herr_t H5F__set_vol_conn(H5F_t *file); +static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, + 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 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__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); +static herr_t H5F__dest(H5F_t *f, hbool_t flush); +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); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); - /*********************/ /* Package Variables */ /*********************/ @@ -96,12 +100,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; */ htri_t use_locks_env_g = FAIL; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -114,14 +116,34 @@ H5FL_DEFINE(H5F_shared_t); /* File ID class */ static const H5I_class_t H5I_FILE_CLS[1] = {{ - H5I_FILE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */ + H5I_FILE, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */ }}; +/*------------------------------------------------------------------------- + * Function: H5F_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5F_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_init() */ - /*-------------------------------------------------------------------------- NAME H5F__init_package -- Initialize interface-specific information @@ -136,25 +158,24 @@ DESCRIPTION herr_t H5F__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* * Initialize the atom group for the file IDs. */ - if(H5I_register_type(H5I_FILE_CLS) < 0) + if (H5I_register_type(H5I_FILE_CLS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Check the file locking environment variable */ - if(H5F__parse_file_lock_env_var(&use_locks_env_g) < 0) + if (H5F__parse_file_lock_env_var(&use_locks_env_g) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to parse file locking environment variable") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__init_package() */ - /*------------------------------------------------------------------------- * Function: H5F_term_package * @@ -173,15 +194,15 @@ H5F__init_package(void) int H5F_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - if(H5I_nmembers(H5I_FILE) > 0) { + if (H5_PKG_INIT_VAR) { + if (H5I_nmembers(H5I_FILE) > 0) { (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); @@ -190,15 +211,54 @@ H5F_term_package(void) n += (H5I_dec_type_ref(H5I_FILE) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5F_term_package() */ - +/*------------------------------------------------------------------------- + * Function: H5F__close_cb + * + * Purpose: Closes a file or causes the close operation to be pended. + * This function is called from the API and gets called + * by H5Fclose->H5I_dec_ref->H5F__close_cb when H5I_dec_ref() + * decrements the file ID reference count to zero. The file ID + * is removed from the H5I_FILE group by H5I_dec_ref() just + * before H5F__close_cb() is called. If there are open object + * headers then the close is pended by moving the file to the + * H5I_FILE_CLOSING ID group (the f->closing contains the ID + * assigned to file). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F__close_cb(H5VL_object_t *file_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(file_vol_obj); + + /* Close the file */ + if (H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + + /* Free the VOL object; it is unnecessary to unwrap the VOL + * object before freeing it, as the object was not wrapped */ + if (H5VL_free_object(file_vol_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__close_cb() */ + /*------------------------------------------------------------------------- * Function: H5F__parse_file_lock_env_var * @@ -214,23 +274,73 @@ H5F_term_package(void) herr_t H5F__parse_file_lock_env_var(htri_t *use_locks) { - char *lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ FUNC_ENTER_PACKAGE_NOERR /* Check the file locking environment variable */ lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); - if(lock_env_var && (!HDstrcmp(lock_env_var, "FALSE") || !HDstrcmp(lock_env_var, "0"))) - *use_locks = FALSE; /* Override: Never use locks */ - else if(lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "BEST_EFFORT") || !HDstrcmp(lock_env_var, "1"))) - *use_locks = TRUE; /* Override: Always use locks */ + if (lock_env_var && (!HDstrcmp(lock_env_var, "FALSE") || !HDstrcmp(lock_env_var, "0"))) + *use_locks = FALSE; /* Override: Never use locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "BEST_EFFORT") || + !HDstrcmp(lock_env_var, "1"))) + *use_locks = TRUE; /* Override: Always use locks */ else - *use_locks = FAIL; /* Environment variable not set, or not set correctly */ + *use_locks = FAIL; /* Environment variable not set, or not set correctly */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__parse_file_lock_env_var() */ - +/*------------------------------------------------------------------------- + * Function: H5F__set_vol_conn + * + * Purpose: Set the VOL connector ID and info for a file. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(file); + + /* Retrieve a copy of the "top-level" connector property, before any pass-through + * connectors modified or unwrapped it. + */ + if (H5CX_get_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL connector info from API context") + + /* Sanity check */ + HDassert(0 != connector_prop.connector_id); + + /* Retrieve the connector for the ID */ + if (NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info, if it exists */ + if (connector_prop.connector_info) + if (H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, + connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") + + /* Cache the connector ID & info for the container */ + file->shared->vol_id = connector_prop.connector_id; + file->shared->vol_info = new_connector_info; + if (H5I_inc_ref(file->shared->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__set_vol_conn() */ + /*------------------------------------------------------------------------- * Function: H5F_get_access_plist * @@ -250,12 +360,13 @@ H5F__parse_file_lock_env_var(htri_t *use_locks) 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 */ - 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 */ - unsigned efc_size = 0; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + unsigned efc_size = 0; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -263,88 +374,118 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HDassert(f); /* Make a copy of the default file access property list */ - if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) + if ((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Copy properties of the file access property list */ - if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") - if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots") - if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) + if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size") - if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) + if (H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks") - if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) + if (H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold") - if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) + if (H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment") - if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) + if (H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference") - if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size") - if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size") - if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) + if (H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size") - if(H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'low' bound for library format versions") - if(H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'high' bound for library format versions") - if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) + if (H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set 'low' bound for library format versions") + if (H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set 'high' bound for library format versions") + if (H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'read attempts ' flag") - if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) + if (H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set object flush callback") - if(f->shared->efc) + if (f->shared->efc) efc_size = H5F__efc_max_nfiles(f->shared->efc); - if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size") - if(f->shared->page_buf != NULL) { - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->page_buf->max_size)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set page buffer size") - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->page_buf->min_meta_perc)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum metadata fraction of page buffer") - if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->page_buf->min_raw_perc)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum raw data fraction of page buffer") + if (H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set elink file cache size") + if (f->shared->page_buf != NULL) { + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->page_buf->max_size)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set page buffer size") + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, + &(f->shared->page_buf->min_meta_perc)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set minimum metadata fraction of page buffer") + if (H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->page_buf->min_raw_perc)) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, + "can't set minimum raw data fraction of page buffer") } /* end if */ #ifdef H5_HAVE_PARALLEL - if(H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") - if(H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->coll_md_write)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") + if (H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read flag") + if (H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read flag") + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + MPI_Comm mpi_comm; + MPI_Info mpi_info; + + /* Retrieve and set MPI communicator */ + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get MPI communicator") + if (H5P_set(new_plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &mpi_comm) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set MPI communicator") + + /* Retrieve and set MPI info object */ + if (H5P_get(old_plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &mpi_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get MPI info object") + if (H5P_set(new_plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &mpi_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set MPI info object") + } #endif /* H5_HAVE_PARALLEL */ - if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < + 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") /* Prepare the driver property */ - driver_prop.driver_id = f->shared->lf->driver_id; + driver_prop.driver_id = f->shared->lf->driver_id; driver_prop.driver_info = H5FD_fapl_get(f->shared->lf); - driver_prop_copied = TRUE; + driver_prop_copied = TRUE; /* Set the driver property */ - if(H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info") + /* Set the VOL connector property */ + connector_prop.connector_id = f->shared->vol_id; + connector_prop.connector_info = f->shared->vol_info; + if (H5P_set(new_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector ID & info") + /* Set the file close degree appropriately */ - if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) + if (f->shared->fc_degree == H5F_CLOSE_DEFAULT && + H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") - else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) + else if (f->shared->fc_degree != H5F_CLOSE_DEFAULT && + H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") done: /* Release the copy of the driver info, if it was set up */ - if(driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) + if (driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_access_plist() */ - /*------------------------------------------------------------------------- * Function: H5F_get_obj_count * @@ -357,7 +498,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -365,14 +506,13 @@ H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_i HDassert(obj_id_count_ptr); /* Perform the query */ - if((ret_value = H5F__get_objects(f, types, 0, NULL, app_ref, obj_id_count_ptr)) < 0) + if ((ret_value = H5F__get_objects(f, types, 0, NULL, app_ref, obj_id_count_ptr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F__get_objects failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_obj_count() */ - /*------------------------------------------------------------------------- * Function: H5F_get_obj_ids * @@ -382,9 +522,10 @@ H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_i *------------------------------------------------------------------------- */ 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) +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) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -392,14 +533,13 @@ H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list HDassert(obj_id_count_ptr); /* Perform the query */ - if((ret_value = H5F__get_objects(f, types, max_objs, oid_list, app_ref, obj_id_count_ptr)) < 0) + if ((ret_value = H5F__get_objects(f, types, max_objs, oid_list, app_ref, obj_id_count_ptr)) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F__get_objects failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_obj_ids() */ - /*--------------------------------------------------------------------------- * Function: H5F__get_objects * @@ -411,11 +551,12 @@ H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list *--------------------------------------------------------------------------- */ static herr_t -H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr) +H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, + size_t *obj_id_count_ptr) { - size_t obj_id_count = 0; /* Number of open IDs */ - H5F_olist_t olist; /* Structure to hold search results */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t obj_id_count = 0; /* Number of open IDs */ + H5F_olist_t olist; /* Structure to hold search results */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -423,26 +564,26 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id HDassert(obj_id_count_ptr); /* Set up search information */ - olist.obj_id_list = (max_nobjs==0 ? NULL : obj_id_list); + olist.obj_id_list = (max_nobjs == 0 ? NULL : obj_id_list); olist.obj_id_count = &obj_id_count; olist.list_index = 0; olist.max_nobjs = max_nobjs; /* Determine if we are searching for local or global objects */ - if(types & H5F_OBJ_LOCAL) { - olist.file_info.local = TRUE; + if (types & H5F_OBJ_LOCAL) { + olist.file_info.local = TRUE; olist.file_info.ptr.file = f; } /* end if */ else { - olist.file_info.local = FALSE; + olist.file_info.local = FALSE; olist.file_info.ptr.shared = f ? f->shared : NULL; } /* end else */ /* Iterate through file IDs to count the number, and put their * IDs on the object list. */ - if(types & H5F_OBJ_FILE) { + if (types & H5F_OBJ_FILE) { olist.obj_type = H5I_FILE; - if(H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0) + if (H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") } /* end if */ @@ -450,10 +591,10 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id * or the caller wants to get the list of IDs and the list isn't full, * search through dataset IDs to count number of datasets, and put their * IDs on the object list */ - if(!olist.max_nobjs || (olist.max_nobjs && olist.list_indexobj_type == H5I_FILE) { - if((olist->file_info.local && - (!olist->file_info.ptr.file || - (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file))) || - (!olist->file_info.local && - (!olist->file_info.ptr.shared || - (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared)))) { + if (olist->obj_type == H5I_FILE) { + if ((olist->file_info.local && + (!olist->file_info.ptr.file || + (olist->file_info.ptr.file && (H5F_t *)obj_ptr == olist->file_info.ptr.file))) || + (!olist->file_info.local && + (!olist->file_info.ptr.shared || + (olist->file_info.ptr.shared && ((H5F_t *)obj_ptr)->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } /* end if */ - } /* end if */ - else { /* Either count opened object IDs or put the IDs on the list */ - H5O_loc_t *oloc; /* Group entry info for object */ + } /* end if */ + } /* end if */ + else { /* Either count opened object IDs or put the IDs on the list */ + H5O_loc_t *oloc; /* Group entry info for object */ - switch(olist->obj_type) { + switch (olist->obj_type) { case H5I_ATTR: oloc = H5A_oloc((H5A_t *)obj_ptr); break; @@ -553,49 +693,55 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) break; case H5I_DATATYPE: - if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) - oloc = H5T_oloc((H5T_t*)obj_ptr); + if (H5T_is_named((H5T_t *)obj_ptr) == TRUE) + oloc = H5T_oloc((H5T_t *)obj_ptr); else oloc = NULL; break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, + "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: case H5I_DATASPACE: - case H5I_REFERENCE: 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_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "unknown or invalid data object") } /* end switch */ - if((olist->file_info.local && - ((!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || - (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) || - (oloc && oloc->file == olist->file_info.ptr.file))) || - (!olist->file_info.local && - ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || - (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || - (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { + if ((olist->file_info.local && ((!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && + H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file == olist->file_info.ptr.file))) || + (!olist->file_info.local && + ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && + H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; } /* end if */ - } /* end else */ + } /* end else */ - if(add_obj) { + if (add_obj) { /* Add the object's ID to the ID list, if appropriate */ - if(olist->obj_id_list) { + if (olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; } /* end if */ /* Increment the number of open objects */ - if(olist->obj_id_count) + if (olist->obj_id_count) (*olist->obj_id_count)++; /* Check if we've filled up the array. Return H5_ITER_STOP only if @@ -603,15 +749,14 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) * preset to H5_ITER_CONT) because H5I_iterate needs the return value of * H5_ITER_CONT to continue the iteration. */ - if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) - HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ - } /* end if */ + if (olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) + HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_objects_cb() */ - /*-------------------------------------------------------------------------- * Function: H5F__build_name * @@ -620,30 +765,32 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) * Return: SUCCEED/FAIL *--------------------------------------------------------------------------*/ static herr_t -H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) +H5F__build_name(const char *prefix, const char *file_name, char **full_name /*out*/) { - size_t prefix_len; /* length of prefix */ - size_t fname_len; /* Length of external link file name */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t prefix_len; /* length of prefix */ + size_t fname_len; /* Length of external link file name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC prefix_len = HDstrlen(prefix); - fname_len = HDstrlen(file_name); + fname_len = HDstrlen(file_name); /* Allocate a buffer to hold the filename + prefix + possibly the delimiter + terminating null byte */ - if(NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2 + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == (*full_name = (char *)H5MM_malloc(prefix_len + fname_len + 2 + + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate filename buffer") /* Compose the full file name */ - HDsnprintf(*full_name, (prefix_len + fname_len + 2 + 2), "%s%s%s", prefix, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ - ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), file_name); + HDsnprintf(*full_name, (prefix_len + fname_len + 2 + 2), "%s%s%s", + prefix, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + ((prefix_len == 0 || H5_CHECK_DELIMITER(prefix[prefix_len - 1])) ? "" : H5_DIR_SEPS), + file_name); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__build_name() */ - /*-------------------------------------------------------------------------- * Function: H5F__getenv_prefix_name * @@ -655,10 +802,10 @@ H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out * Return: A pointer to a pathname (can't fail but can return NULL) --------------------------------------------------------------------------*/ static char * -H5F__getenv_prefix_name(char **env_prefix/*in,out*/) +H5F__getenv_prefix_name(char **env_prefix /*in,out*/) { - char *strret; /* Pointer to next separator */ - char *ret_value = NULL; /* Return value */ + char *strret; /* Pointer to next separator */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -667,7 +814,7 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) /* Advance to next component, if possible */ strret = HDstrchr(*env_prefix, H5_COLON_SEPC); - if(strret == NULL) + if (strret == NULL) *env_prefix = NULL; else { /* Advance to next component */ @@ -680,7 +827,6 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__getenv_prefix_name() */ - /*------------------------------------------------------------------------- * Function: H5F_prefix_open_file * @@ -690,16 +836,15 @@ H5F__getenv_prefix_name(char **env_prefix/*in,out*/) *------------------------------------------------------------------------- */ H5F_t * -H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, - const char *prop_prefix, const char *file_name, unsigned file_intent, - hid_t fapl_id) +H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const char *prop_prefix, + 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 */ - size_t temp_file_name_len; /* Length of temporary file name */ - H5F_t *ret_value = NULL; /* Return value */ + 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 */ + size_t temp_file_name_len; /* Length of temporary file name */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -707,17 +852,17 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, file_intent &= (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ); /* Copy the file name to use */ - if(NULL == (temp_file_name = H5MM_strdup(file_name))) + if (NULL == (temp_file_name = H5MM_strdup(file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") temp_file_name_len = HDstrlen(temp_file_name); /* Target file_name is an absolute pathname: see RM for detailed description */ - if(H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { + if (H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { /* Try opening file */ - src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Adjust temporary file name if file not opened */ - if(NULL == src_file) { + if (NULL == src_file) { char *ptr; /* Reset the error stack */ @@ -734,13 +879,13 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, HDstrncpy(temp_file_name, ptr, temp_file_name_len); temp_file_name[temp_file_name_len - 1] = '\0'; } /* end if */ - } /* end if */ - else if(H5_CHECK_ABS_DRIVE(file_name)) { + } /* end if */ + else if (H5_CHECK_ABS_DRIVE(file_name)) { /* Try opening file */ src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Adjust temporary file name if file not opened */ - if(NULL == src_file) { + if (NULL == src_file) { /* Reset the error stack */ H5E_clear_stack(NULL); @@ -748,63 +893,65 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, HDstrncpy(temp_file_name, &file_name[2], temp_file_name_len); temp_file_name[temp_file_name_len - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Try searching from paths set in the environment variable */ - if(src_file == NULL) { + if (src_file == NULL) { char *env_prefix; /* Get the appropriate environment variable */ - if(H5F_PREFIX_VDS == prefix_type) + if (H5F_PREFIX_VDS == prefix_type) env_prefix = HDgetenv("HDF5_VDS_PREFIX"); - else if(H5F_PREFIX_ELINK == prefix_type) + else if (H5F_PREFIX_ELINK == prefix_type) env_prefix = HDgetenv("HDF5_EXT_PREFIX"); else HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "prefix type is not sensible") /* If environment variable is defined, iterate through prefixes it defines */ - if(NULL != env_prefix) { + if (NULL != env_prefix) { char *tmp_env_prefix, *saved_env; /* Make a copy of the environment variable string */ - if(NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix))) + if (NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Loop over prefixes in environment variable */ - while((tmp_env_prefix) && (*tmp_env_prefix)) { + while ((tmp_env_prefix) && (*tmp_env_prefix)) { char *out_prefix_name; - out_prefix_name = H5F__getenv_prefix_name(&tmp_env_prefix/*in,out*/); - if(out_prefix_name && (*out_prefix_name)) { - if(H5F__build_name(out_prefix_name, temp_file_name, &full_name/*out*/) < 0) { + out_prefix_name = H5F__getenv_prefix_name(&tmp_env_prefix /*in,out*/); + if (out_prefix_name && (*out_prefix_name)) { + if (H5F__build_name(out_prefix_name, temp_file_name, &full_name /*out*/) < 0) { saved_env = (char *)H5MM_xfree(saved_env); HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") } /* end if */ /* Try opening file */ - src_file = H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = + H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Release copy of file name */ full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); /* Leave if file was opened */ else break; + H5E_clear_stack(NULL); } /* end if */ - } /* end while */ + } /* end while */ saved_env = (char *)H5MM_xfree(saved_env); } /* end if */ - } /* end if */ + } /* end if */ /* Try searching from property list */ - if(src_file == NULL && prop_prefix) { + if (src_file == NULL && prop_prefix) { /* Construct name to open */ - if(H5F__build_name(prop_prefix, temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name(prop_prefix, temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ @@ -814,18 +961,18 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ /* Try searching from main file's "extpath": see description in H5F_open() & H5_build_extpath() */ - if(src_file == NULL) { + if (src_file == NULL) { char *dspath; - if(NULL != (dspath = H5F_EXTPATH(primary_file))) { + if (NULL != (dspath = H5F_EXTPATH(primary_file))) { /* Construct name to open */ - if(H5F__build_name(dspath, temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name(dspath, temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ @@ -835,41 +982,39 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ - } /* end if */ + } /* end if */ /* Try the relative file_name stored in temp_file_name */ - if(src_file == NULL) { + if (src_file == NULL) { /* Try opening file */ src_file = H5F__efc_open(primary_file, temp_file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ /* try the 'resolved' name for the virtual file */ - if(src_file == NULL) { + if (src_file == NULL) { char *ptr = NULL; /* Copy resolved file name */ - if(NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(primary_file)))) + if (NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(primary_file)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "can't duplicate resolved file name string") /* get last component of file_name */ H5_GET_LAST_DELIMITER(actual_file_name, ptr) - if(!ptr) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file, file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) - - /* Truncate filename portion from actual file name path */ - *ptr = '\0'; + if (ptr) + /* Truncate filename portion from actual file name path */ + *ptr = '\0'; /* Build new file name for the external file */ - if(H5F__build_name(actual_file_name, temp_file_name, &full_name/*out*/) < 0) + if (H5F__build_name((ptr ? actual_file_name : ""), temp_file_name, &full_name /*out*/) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") actual_file_name = (char *)H5MM_xfree(actual_file_name); @@ -880,7 +1025,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, full_name = (char *)H5MM_xfree(full_name); /* Check for file not opened */ - if(NULL == src_file) + if (NULL == src_file) /* Reset the error stack */ H5E_clear_stack(NULL); } /* end if */ @@ -889,60 +1034,68 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, ret_value = src_file; done: - if((NULL == ret_value) && src_file) - if(H5F_efc_close(primary_file, src_file) < 0) + if ((NULL == ret_value) && src_file) + if (H5F_efc_close(primary_file, src_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close source file") - if(full_name) + if (full_name) full_name = (char *)H5MM_xfree(full_name); - if(temp_file_name) + if (temp_file_name) temp_file_name = (char *)H5MM_xfree(temp_file_name); - if(actual_file_name) + if (actual_file_name) actual_file_name = (char *)H5MM_xfree(actual_file_name); FUNC_LEAVE_NOAPI(ret_value) } /* H5F_prefix_open_file() */ - /*------------------------------------------------------------------------- * Function: H5F__is_hdf5 * * Purpose: Check the file signature to detect an HDF5 file. * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. - * * Return: TRUE/FALSE/FAIL *------------------------------------------------------------------------- */ htri_t -H5F__is_hdf5(const char *name) +H5F__is_hdf5(const char *name, hid_t fapl_id) { - H5FD_t *file = NULL; /* Low-level file struct */ - haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Open the file */ - if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) + /* NOTE: This now uses the fapl_id that was passed in, so H5Fis_accessible() + * should work with arbitrary VFDs, unlike H5Fis_hdf5(). + */ + if (NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to open file") - /* The file is an hdf5 file if the hdf5 file signature can be found */ - if(H5FD_locate_signature(file, &sig_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "error while trying to locate file signature") - ret_value = (HADDR_UNDEF != sig_addr); + /* If the file is already open, it's an HDF5 file + * + * If the file is open with an exclusive lock on an operating system that enforces + * mandatory file locks (like Windows), creating a new file handle and attempting + * to read through it will fail so we have to try this first. + */ + if ((shared = H5F__sfile_search(file)) != NULL) + ret_value = TRUE; + else { + /* The file is an HDF5 file if the HDF5 file signature can be found */ + if (H5FD_locate_signature(file, &sig_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "error while trying to locate file signature") + ret_value = (HADDR_UNDEF != sig_addr); + } done: /* Close the file */ - if(file) - if(H5FD_close(file) < 0 && TRUE == ret_value) + if (file) + if (H5FD_close(file) < 0 && TRUE == ret_value) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__is_hdf5() */ - /*------------------------------------------------------------------------- * Function: H5F__new * @@ -959,46 +1112,46 @@ H5F__is_hdf5(const char *name) * *------------------------------------------------------------------------- */ -H5F_t * +static H5F_t * H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL; - H5F_t *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC - if(NULL == (f = H5FL_CALLOC(H5F_t))) + if (NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = H5I_INVALID_HID; + f->id_exists = FALSE; - if(shared) { + if (shared) { HDassert(lf == NULL); f->shared = shared; } else { - H5P_genplist_t *plist; /* Property list */ - unsigned efc_size; /* External file cache size */ - size_t u; /* Local index variable */ + H5P_genplist_t *plist; /* Property list */ + unsigned efc_size; /* External file cache size */ + size_t u; /* Local index variable */ HDassert(lf != NULL); - if(NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) + if (NULL == (f->shared = H5FL_CALLOC(H5F_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") - f->shared->flags = flags; + f->shared->flags = flags; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; f->shared->accum.loc = HADDR_UNDEF; - f->shared->lf = lf; + f->shared->lf = lf; /* Initialization for handling file space */ - for(u = 0; u < NELMTS(f->shared->fs_addr); u++) { + for (u = 0; u < NELMTS(f->shared->fs_addr); u++) { f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; - f->shared->fs_addr[u] = HADDR_UNDEF; - f->shared->fs_man[u] = NULL; + f->shared->fs_addr[u] = HADDR_UNDEF; + f->shared->fs_man[u] = NULL; } - f->shared->first_alloc_dealloc = FALSE; - f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; - f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; + /* This will be stored as eoa_pre_fsm_fsalloc in the fsinfo message */ + /* This is done to be backward compatible with 1.10 library that has the FSM hack */ + f->shared->eoa_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_mdci_fsalloc = HADDR_UNDEF; /* Initialization for handling file space (for paged aggregation) */ @@ -1011,96 +1164,98 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F * new file handle. We do this early because some values might need * to change as the file is being opened. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") f->shared->fcpl_id = H5P_copy_plist(plist, FALSE); /* Get the FCPL values to cache */ - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr) < 0) + if (H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address") - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size) < 0) + if (H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get number of SOHM indexes") HDassert(f->shared->sohm_nindexes < 255); - if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space strategy") - if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &f->shared->fs_persist) < 0) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &f->shared->fs_persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space persisting status") - if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get free-space section threshold") - if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &f->shared->fs_page_size) < 0) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &f->shared->fs_page_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space page size") HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation * when persisting free-space or using paged aggregation strategy. */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") /* Get the FAPL values to cache */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") - if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache number of slots") - if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache byte size") - if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) + if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk") - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") - if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME,&(f->shared->gc_ref)) < 0) + if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") - if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) + if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") - if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) + if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'low' bound for library format versions") - if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) + if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'high' bound for library format versions") - if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) + if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &(f->shared->use_mdc_logging)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'use mdc logging' flag") - if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) + if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &(f->shared->start_mdc_log_on_access)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'start mdc log on access' flag") - if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) + if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get metadata cache size") f->shared->meta_aggr.feature_flag = H5FD_FEAT_AGGREGATE_METADATA; - if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) + if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' cache size") f->shared->sdata_aggr.feature_flag = H5FD_FEAT_AGGREGATE_SMALLDATA; - if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") - if(efc_size > 0) - if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) + if (efc_size > 0) + if (NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL - if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) + if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->shared->coll_md_read)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get collective metadata read flag") - if(H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->coll_md_write)) < 0) + if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->shared->coll_md_write)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get collective metadata write flag") #endif /* H5_HAVE_PARALLEL */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") /* Get the VFD values to cache */ f->shared->maxaddr = H5FD_get_maxaddr(lf); - if(!H5F_addr_defined(f->shared->maxaddr)) + if (!H5F_addr_defined(f->shared->maxaddr)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad maximum address from VFD") - if(H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0) + if (H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get feature flags from VFD") /* Require the SWMR feature flag if SWMR I/O is desired */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO) && (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO) && + (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use a SWMR-compatible VFD when SWMR is specified") - if(H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) + if (H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get free space type mapping from VFD") - if(H5MF_init_merge_flags(f) < 0) + if (H5MF_init_merge_flags(f->shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "problem initializing free space merge flags") f->shared->tmp_addr = f->shared->maxaddr; /* Disable temp. space allocation for parallel I/O (for now) */ @@ -1114,42 +1269,46 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F */ f->shared->use_tmp_space = !H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI); - /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts */ - if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &f->shared->read_attempts) < 0) + /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts + */ + if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &f->shared->read_attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get the # of read attempts") - /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if not set */ - /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */ - if(H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) { + /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if + * not set */ + /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS + * (set or not set) */ + if (H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) { /* If no value for read attempts has been set, use the default */ - if(!f->shared->read_attempts) + if (!f->shared->read_attempts) f->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS; /* Turn off accumulator with SWMR */ f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; - if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") } else { /* If no value for read attempts has been set, use the default */ - if(!f->shared->read_attempts) + if (!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; } /* Determine the # of bins for metdata read retries */ - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't set retries and retries_nbins") /* Get the metadata cache log location (if we're logging) */ { - char *mdc_log_location = NULL; /* location of metadata cache log location */ + char *mdc_log_location = NULL; /* location of metadata cache log location */ - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &mdc_log_location) < 0) + if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &mdc_log_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get mdc log location") - if(mdc_log_location != NULL) { + if (mdc_log_location != NULL) { size_t len = HDstrlen(mdc_log_location); - if(NULL == (f->shared->mdc_log_location = (char *)H5MM_calloc((len + 1) * sizeof(char)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name") + if (NULL == (f->shared->mdc_log_location = (char *)H5MM_calloc((len + 1) * sizeof(char)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, + "can't allocate memory for mdc log file name") HDstrncpy(f->shared->mdc_log_location, mdc_log_location, len); } else @@ -1157,54 +1316,60 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F } /* end block */ /* Get object flush callback information */ - if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) + if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") + /* Get the VOL connector info */ + if (H5F__set_vol_conn(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't cache VOL connector info") + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ - if(H5AC_create(f, &(f->shared->mdc_initCacheCfg), &(f->shared->mdc_initCacheImageCfg)) < 0) + if (H5AC_create(f, &(f->shared->mdc_initCacheCfg), &(f->shared->mdc_initCacheImageCfg)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create metadata cache") /* Create the file's "open object" information */ - if(H5FO_create(f) < 0) + if (H5FO_create(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Add new "shared" struct to list of open files */ - if(H5F__sfile_add(f->shared) < 0) + if (H5F__sfile_add(f->shared) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to append to list of open files") } /* end else */ f->shared->nrefs++; /* Create the file's "top open object" information */ - if(H5FO_top_create(f) < 0) + if (H5FO_top_create(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure") /* Set return value */ ret_value = f; done: - if(!ret_value && f) { - if(!shared) { + if (!ret_value && f) { + HDassert(NULL == f->vol_obj); + + if (!shared) { /* Attempt to clean up some of the shared file structures */ - if(f->shared->efc) - if(H5F__efc_destroy(f->shared->efc) < 0) + if (f->shared->efc) + if (H5F__efc_destroy(f->shared->efc) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache") - if(f->shared->fcpl_id > 0) - if(H5I_dec_ref(f->shared->fcpl_id) < 0) + if (f->shared->fcpl_id > 0) + if (H5I_dec_ref(f->shared->fcpl_id) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_shared_t, f->shared); } + f = H5FL_FREE(H5F_t, f); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__new() */ - /*------------------------------------------------------------------------- * Function: H5F__dest * @@ -1216,26 +1381,29 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ -herr_t +static herr_t H5F__dest(H5F_t *f, hbool_t flush) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); HDassert(f->shared); - if(1 == f->shared->nrefs) { - int actype; /* metadata cache type (enum value) */ + if (1 == f->shared->nrefs) { + int actype; /* metadata cache type (enum value) */ + + /* Mark this file as closing */ + f->shared->closing = TRUE; /* Flush at this point since the file will be closed (phase 1). * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. */ - if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase1(f) < 0) + if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) + if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)") @@ -1243,7 +1411,7 @@ H5F__dest(H5F_t *f, hbool_t flush) * This allows the cache to set up for creating a metadata cache * image if this has been requested. */ - if(H5AC_prep_for_file_close(f) < 0) + if (H5AC_prep_for_file_close(f) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "metadata cache prep for close failed") @@ -1251,8 +1419,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * Only try to flush the file if it was opened with write access, and if * the caller requested a flush. */ - if((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) - if(H5F__flush_phase2(f, TRUE) < 0) + if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) + if (H5F__flush_phase2(f, TRUE) < 0) /* Push error, but keep going */ HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)") @@ -1265,8 +1433,8 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Release the external file cache */ - if(f->shared->efc) { - if(H5F__efc_destroy(f->shared->efc) < 0) + if (f->shared->efc) { + if (H5F__efc_destroy(f->shared->efc) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't destroy external file cache") f->shared->efc = NULL; @@ -1281,7 +1449,7 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Release objects that depend on the superblock being initialized */ - if(f->shared->sblock) { + if (f->shared->sblock) { /* Shutdown file free space manager(s) */ /* (We should release the free space information now (before * truncating the file and before the metadata cache is shut @@ -1298,8 +1466,8 @@ H5F__dest(H5F_t *f, hbool_t flush) * * -- JRM */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - if(H5MF_close(f) < 0) + if (H5F_ACC_RDWR & H5F_INTENT(f)) { + if (H5MF_close(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info") @@ -1311,13 +1479,13 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Flush the file again (if requested), as shutting down the * free space manager may dirty some data structures again. */ - if(flush) { + if (flush) { /* Clear status_flags */ f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_WRITE_ACCESS); f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); /* Mark EOA info dirty in cache, so change will get encoded */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") @@ -1328,12 +1496,12 @@ H5F__dest(H5F_t *f, hbool_t flush) * At most, this should change the superblock or the * superblock extension messages. */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, TRUE) < 0) + if (H5FD_truncate(f->shared->lf, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") @@ -1342,18 +1510,18 @@ H5F__dest(H5F_t *f, hbool_t flush) */ HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); } /* end if */ - } /* end if */ + } /* end if */ /* if it exists, unpin the driver information block cache entry, * since we're about to destroy the cache */ - if(f->shared->drvinfo) - if(H5AC_unpin_entry(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) + if (H5AC_unpin_entry(f->shared->drvinfo) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin drvinfo") /* Unpin the superblock, since we're about to destroy the cache */ - if(H5AC_unpin_entry(f->shared->sblock) < 0) + if (H5AC_unpin_entry(f->shared->sblock) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") f->shared->sblock = NULL; @@ -1367,7 +1535,7 @@ H5F__dest(H5F_t *f, hbool_t flush) HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); /* Remove shared file struct from list of open files */ - if(H5F__sfile_remove(f->shared) < 0) + if (H5F__sfile_remove(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") @@ -1375,70 +1543,83 @@ H5F__dest(H5F_t *f, hbool_t flush) /* (Flushes any remaining dirty entries, which should only be the * superblock and / or driver info at this point) */ - if(H5AC_dest(f)) + if (H5AC_dest(f)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Shutdown the page buffer cache */ - if(H5PB_dest(f->shared) < 0) + if (H5PB_dest(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing page buffer cache") /* Clean up the metadata cache log location string */ - if(f->shared->mdc_log_location) + if (f->shared->mdc_log_location) f->shared->mdc_log_location = (char *)H5MM_xfree(f->shared->mdc_log_location); /* * Do not close the root group since we didn't count it, but free * the memory associated with it. */ - if(f->shared->root_grp) { + if (f->shared->root_grp) { /* Free the root group */ - if(H5G_root_free(f->shared->root_grp) < 0) + if (H5G_root_free(f->shared->root_grp) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->root_grp = NULL; } /* end if */ /* Destroy other components of the file */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") - if(H5FO_dest(f) < 0) + if (H5FO_dest(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") f->shared->cwfs = (struct H5HG_heap_t **)H5MM_xfree(f->shared->cwfs); - if(H5G_node_close(f) < 0) + if (H5G_node_close(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") /* Destroy file creation properties */ - if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) + if (H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list") - if(H5I_dec_ref(f->shared->fcpl_id) < 0) + if (H5I_dec_ref(f->shared->fcpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list") + /* Clean up the cached VOL connector ID & info */ + if (f->shared->vol_info) + if (H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + if (f->shared->vol_id > 0) + if (H5I_dec_ref(f->shared->vol_id) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID") + f->shared->vol_cls = NULL; + /* Close the file */ - if(H5FD_close(f->shared->lf) < 0) + if (H5FD_close(f->shared->lf) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Free mount table */ - f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); + f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); f->shared->mtab.nalloc = 0; + /* Free the external link file */ + f->shared->extpath = (char *)H5MM_xfree(f->shared->extpath); + /* Clean up the metadata retries array */ - for(actype = 0; actype < (int)H5AC_NTYPES; actype++) - if(f->shared->retries[actype]) + for (actype = 0; actype < (int)H5AC_NTYPES; actype++) + if (f->shared->retries[actype]) f->shared->retries[actype] = (uint32_t *)H5MM_xfree(f->shared->retries[actype]); /* Destroy shared file struct */ f->shared = (H5F_shared_t *)H5FL_FREE(H5F_shared_t, f->shared); - } - else if(f->shared->nrefs > 0) { + else if (f->shared->nrefs > 0) { /* * There are other references to the shared part of the file. * Only decrement the reference count. @@ -1447,18 +1628,31 @@ H5F__dest(H5F_t *f, hbool_t flush) } /* Free the non-shared part of the file */ - f->open_name = (char *)H5MM_xfree(f->open_name); + f->open_name = (char *)H5MM_xfree(f->open_name); f->actual_name = (char *)H5MM_xfree(f->actual_name); - f->extpath = (char *)H5MM_xfree(f->extpath); - if(H5FO_top_dest(f) < 0) + if (f->vol_obj) { + void *vol_wrap_ctx = NULL; + + /* If a VOL wrapping context is available, retrieve it + * and unwrap file VOL object + */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + if (vol_wrap_ctx && (NULL == H5VL_object_unwrap(f->vol_obj))) + HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't unwrap VOL object") + + if (H5VL_free_object(f->vol_obj) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + f->vol_obj = NULL; + } + 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); + f = H5FL_FREE(H5F_t, f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__dest() */ - /*------------------------------------------------------------------------- * Function: H5F__check_if_using_file_locks * @@ -1485,7 +1679,7 @@ H5F__dest(H5F_t *f, hbool_t flush) static herr_t H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1493,18 +1687,17 @@ H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking) *use_file_locking = TRUE; /* Check the fapl property */ - if(H5P_get(fapl, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0) + if (H5P_get(fapl, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get use file locking flag") /* Check the environment variable */ - if(use_locks_env_g != FAIL) + if (use_locks_env_g != FAIL) *use_file_locking = (use_locks_env_g == TRUE) ? TRUE : FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__check_if_using_file_locks() */ - /*------------------------------------------------------------------------- * Function: H5F_open * @@ -1581,39 +1774,39 @@ 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' */ - unsigned tent_flags; /*tentative flags */ - 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; - unsigned page_buf_min_raw_perc = 0; - hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ - hbool_t clear = FALSE; /*clear the status_flags */ - hbool_t evict_on_close; /* evict on close value from plist */ - 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 * 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 */ + H5F_close_degree_t fc_degree; /*file close degree */ + size_t page_buf_size; + unsigned page_buf_min_meta_perc = 0; + unsigned page_buf_min_raw_perc = 0; + hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ + hbool_t clear = FALSE; /*clear the status_flags */ + hbool_t evict_on_close; /* evict on close value from plist */ + 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 */ FUNC_ENTER_NOAPI(NULL) /* - * If the driver has a `cmp' method then the driver is capable of + * If the driver has a 'cmp' method then the driver is capable of * determining when two file handles refer to the same file and the * library can insure that when the application opens a file twice * that the two handles coordinate their operations appropriately. * Otherwise it is the application's responsibility to never open the * same file more than once at a time. */ - if(NULL == (drvr = H5FD_get_class(fapl_id))) + if (NULL == (drvr = H5FD_get_class(fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") /* Get the file access property list, for future queries */ - if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") /* Check if we are using file locking */ @@ -1631,36 +1824,24 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * application's responsibility to prevent this situation (there's no * way for us to detect it here anyway). */ - if(drvr->cmp) - tent_flags = flags & ~(H5F_ACC_CREAT|H5F_ACC_TRUNC|H5F_ACC_EXCL); + if (drvr->cmp) + tent_flags = flags & ~(H5F_ACC_CREAT | H5F_ACC_TRUNC | H5F_ACC_EXCL); else tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if(tent_flags == flags) { -#ifndef H5_USING_MEMCHECKER - time_t mytime = HDtime(NULL); - - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) -#else /* H5_USING_MEMCHECKER */ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) -#endif /* H5_USING_MEMCHECKER */ - } /* end if */ + 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; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { -#ifndef H5_USING_MEMCHECKER - time_t mytime = HDtime(NULL); - - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) -#else /* H5_USING_MEMCHECKER */ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) -#endif /* H5_USING_MEMCHECKER */ - } /* end if */ + 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) { + if ((shared = H5F__sfile_search(lf)) != NULL) { /* * The file is already open, so use that one instead of the one we * just opened. We only one one H5FD_t* per file so one doesn't @@ -1671,68 +1852,72 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * readers don't expect the file to change under them), or if the * SWMR write/read access flags don't agree. */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") - if(flags & H5F_ACC_TRUNC) + if (flags & H5F_ACC_TRUNC) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") - if(flags & H5F_ACC_EXCL) + if (flags & H5F_ACC_EXCL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") - if((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) + if ((flags & H5F_ACC_RDWR) && 0 == (shared->flags & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") - if((flags & H5F_ACC_SWMR_WRITE) && 0 == (shared->flags & H5F_ACC_SWMR_WRITE)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR write access flag not the same for file that is already open") - if((flags & H5F_ACC_SWMR_READ) && !((shared->flags & H5F_ACC_SWMR_WRITE) || (shared->flags & H5F_ACC_SWMR_READ) || (shared->flags & H5F_ACC_RDWR))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") + if ((flags & H5F_ACC_SWMR_WRITE) && 0 == (shared->flags & H5F_ACC_SWMR_WRITE)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "SWMR write access flag not the same for file that is already open") + if ((flags & H5F_ACC_SWMR_READ) && + !((shared->flags & H5F_ACC_SWMR_WRITE) || (shared->flags & H5F_ACC_SWMR_READ) || + (shared->flags & H5F_ACC_RDWR))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if ((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { /* Check if tentative open was good enough */ - if(flags != tent_flags) { + if (flags != tent_flags) { /* * This file is not yet open by the library and the flags we used to * open it are different than the desired flags. Close the tentative * file and open it for real. */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") - if(NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) + if (NULL == (lf = H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Place an advisory lock on the file */ - if(use_file_locking) - if(H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { + if (use_file_locking) + if (H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { /* Locking failed - Closing will remove the lock */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, NULL, "unable to lock the file") } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { + if (NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct - * returned is NULL, H5FD_close() will never be called via H5F_dest() + * returned is NULL, H5FD_close() will never be called via H5F__dest() * so we have to close lf here before heading to the error handling. */ - if(H5FD_close(lf) < 0) + if (H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure") } /* end if */ /* Need to set status_flags in the superblock if the driver has a 'lock' method */ - if(drvr->lock) + if (drvr->lock) set_flag = TRUE; } /* end else */ /* Check to see if both SWMR and cache image are requested. Fail if so */ - if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) + if (H5C_cache_image_status(file, &ci_load, &ci_write) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") - if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) + if ((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't have both SWMR and cache image") /* Retain the name the file was opened with */ @@ -1740,33 +1925,34 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Short cuts */ shared = file->shared; - lf = shared->lf; + lf = shared->lf; /* Set the file locking flag. If the file is already open, the file * requested file locking flag must match that of the open file. */ - if(shared->nrefs == 1) + if (shared->nrefs == 1) file->shared->use_file_locking = use_file_locking; - else if(shared->nrefs > 1) - if(file->shared->use_file_locking != use_file_locking) + else if (shared->nrefs > 1) + if (file->shared->use_file_locking != use_file_locking) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file locking flag values don't match") /* Check if page buffering is enabled */ - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size") - if(page_buf_size) { + if (page_buf_size) { #ifdef H5_HAVE_PARALLEL /* Collective metadata writes are not supported with page buffering */ - if(file->coll_md_write) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "collective metadata writes are not supported with page buffering") + if (file->shared->coll_md_write) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "collective metadata writes are not supported with page buffering") /* Temporary: fail file create when page buffering feature is enabled for parallel */ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "page buffering is disabled for parallel") #endif /* H5_HAVE_PARALLEL */ /* Query for other page buffer cache properties */ - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &page_buf_min_meta_perc) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &page_buf_min_meta_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum metadata fraction of page buffer") - if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &page_buf_min_raw_perc) < 0) + if (H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get minimum raw data fraction of page buffer") } /* end if */ @@ -1774,41 +1960,42 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * Read or write the file superblock, depending on whether the file is * empty or not. */ - if(0 == (MAX(H5FD_get_eof(lf, H5FD_MEM_SUPER), H5FD_get_eoa(lf, H5FD_MEM_SUPER))) && (flags & H5F_ACC_RDWR)) { + if (0 == (MAX(H5FD_get_eof(lf, H5FD_MEM_SUPER), H5FD_get_eoa(lf, H5FD_MEM_SUPER))) && + (flags & H5F_ACC_RDWR)) { /* * We've just opened a fresh new file (or truncated one). We need * to create & write the superblock. */ /* Create the page buffer before initializing the superblock */ - if(page_buf_size) - if(H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + if (page_buf_size) + if (H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") /* Initialize information about the superblock and allocate space for it */ /* (Writes superblock extension messages, if there are any) */ - if(H5F__super_init(file) < 0) + if (H5F__super_init(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to allocate file superblock") /* Create and open the root group */ /* (This must be after the space for the superblock is allocated in * the file, since the superblock must be at offset 0) */ - if(H5G_mkroot(file, TRUE) < 0) + if (H5G_mkroot(file, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") } /* end if */ - else if(1 == shared->nrefs) { + else if (1 == shared->nrefs) { /* Read the superblock if it hasn't been read before. */ - if(H5F__super_read(file, a_plist, TRUE) < 0) + if (H5F__super_read(file, a_plist, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Create the page buffer before initializing the superblock */ - if(page_buf_size) - if(H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) + if (page_buf_size) + if (H5PB_create(shared, page_buf_size, page_buf_min_meta_perc, page_buf_min_raw_perc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create page buffer") /* Open the root group */ - if(H5G_mkroot(file, FALSE) < 0) + if (H5G_mkroot(file, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ @@ -1818,27 +2005,27 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * second time or later, verify the access property list value matches * the degree in shared file structure. */ - if(H5P_get(a_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) + if (H5P_get(a_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree") - if(shared->nrefs == 1) { - if(fc_degree == H5F_CLOSE_DEFAULT) + if (shared->nrefs == 1) { + if (fc_degree == H5F_CLOSE_DEFAULT) shared->fc_degree = lf->cls->fc_degree; else shared->fc_degree = fc_degree; } /* end if */ - else if(shared->nrefs > 1) { - if(fc_degree == H5F_CLOSE_DEFAULT && shared->fc_degree != lf->cls->fc_degree) + else if (shared->nrefs > 1) { + if (fc_degree == H5F_CLOSE_DEFAULT && shared->fc_degree != lf->cls->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") - if(fc_degree != H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) + if (fc_degree != H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* end if */ /* This is a private property to clear the status_flags in the super block */ /* Use by h5clear and a routine in test/flush2.c to clear the test file's status_flags */ - if(H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { - if(H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) + if (H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { + if (H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get clearance for status_flags") - else if(clear) + else if (clear) file->shared->sblock->status_flags = 0; } /* end if */ @@ -1847,81 +2034,114 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * or later, verify that the access property list value matches the value * in shared file structure. */ - if(H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) + if (H5P_get(a_plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get evict on close value") - if(shared->nrefs == 1) + if (shared->nrefs == 1) shared->evict_on_close = evict_on_close; - else if(shared->nrefs > 1) { - if(shared->evict_on_close != evict_on_close) + else if (shared->nrefs > 1) { + if (shared->evict_on_close != evict_on_close) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "file evict-on-close value doesn't match") } /* end if */ /* Formulate the absolute path for later search of target file for external links */ - if(H5_build_extpath(name, &file->extpath) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") + if (shared->nrefs == 1) { + if (H5_build_extpath(name, &file->shared->extpath) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build extpath") + } /* Formulate the actual file name, after following symlinks, etc. */ - if(H5F__build_actual_name(file, a_plist, name, &file->actual_name) < 0) + if (H5F__build_actual_name(file, a_plist, name, &file->actual_name) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to build actual name") - if(set_flag) { - if(H5F_INTENT(file) & H5F_ACC_RDWR) { /* Set and check consistency of status_flags */ + if (set_flag) { + if (H5F_INTENT(file) & H5F_ACC_RDWR) { /* Set and check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ - if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { + if (file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS || - file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write/SWMR write (may use to clear file consistency flags)") + if (file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS || + file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is already open for write/SWMR write (may use to clear " + "file consistency flags)") } /* version 3 superblock */ file->shared->sblock->status_flags |= H5F_SUPER_WRITE_ACCESS; - if(H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) + if (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) file->shared->sblock->status_flags |= H5F_SUPER_SWMR_WRITE_ACCESS; /* Flush the superblock & superblock extension */ - if(H5F_super_dirty(file) < 0) + if (H5F_super_dirty(file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, NULL, "unable to mark superblock as dirty") - if(H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(file, H5AC__SUPERBLOCK_TAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock") - if(H5F_flush_tagged_metadata(file, file->shared->sblock->ext_addr) < 0) + if (H5F_flush_tagged_metadata(file, file->shared->sblock->ext_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock extension") /* Remove the file lock for SWMR_WRITE */ - if(use_file_locking && (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)) { - if(H5FD_unlock(file->shared->lf) < 0) + if (use_file_locking && (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)) { + if (H5FD_unlock(file->shared->lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, NULL, "unable to unlock the file") - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* H5F_ACC_RDONLY: check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ - if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) { - if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && - !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - || - (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && - file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is not already open for SWMR writing") + if (file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { + if (H5F_INTENT(file) & H5F_ACC_SWMR_READ) { + if ((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && + !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) || + (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && + file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is not already open for SWMR writing") } /* end if */ - else if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) || - (file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write (may use to clear file consistency flags)") + else if ((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) || + (file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, + "file is already open for write (may use to clear file " + "consistency flags)") } /* version 3 superblock */ - } /* end else */ - } /* end if set_flag */ + } /* end else */ + } /* end if set_flag */ /* Success */ ret_value = file; done: - if((NULL == ret_value) && file) - if(H5F__dest(file, FALSE) < 0) + if ((NULL == ret_value) && file) + if (H5F__dest(file, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ - +/*------------------------------------------------------------------------- + * Function: H5F__post_open + * + * Purpose: Finishes file open after wrapper context for file has been + * set. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F__post_open(H5F_t *f) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check arguments */ + HDassert(f); + + /* Store a vol object in the file struct */ + if (NULL == (f->vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, f, f->shared->vol_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't create VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__post_open() */ + /*------------------------------------------------------------------------- * Function: H5F_flush_phase1 * @@ -1934,7 +2154,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) static herr_t H5F__flush_phase1(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1942,7 +2162,7 @@ H5F__flush_phase1(H5F_t *f) HDassert(f); /* Flush any cached dataset storage raw data */ - if(H5D_flush_all(f) < 0) + if (H5D_flush_all(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") @@ -1952,14 +2172,13 @@ H5F__flush_phase1(H5F_t *f) /* (needs to happen before cache flush, with superblock write, since the * 'eoa' value is written in superblock -QAK) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase1() */ - /*------------------------------------------------------------------------- * Function: H5F__flush_phase2 * @@ -1972,7 +2191,7 @@ H5F__flush_phase1(H5F_t *f) static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1980,17 +2199,17 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) HDassert(f); /* Inform the metadata cache that we are about to flush */ - if(H5AC_prep_for_file_flush(f) < 0) + if (H5AC_prep_for_file_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "prep for MDC flush failed") /* Flush the entire metadata cache */ - if(H5AC_flush(f) < 0) + if (H5AC_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { /* Since we just returned from a call to H5AC_flush(), we just * passed through a barrier. Hence we can skip the barrier on * entry to the mpio file driver truncate call below, and the first @@ -2001,45 +2220,44 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) #endif /* H5_HAVE_PARALLEL */ /* Truncate the file to the current allocated size */ - if(H5FD_truncate(f->shared->lf, closing) < 0) + if (H5FD_truncate(f->shared->lf, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") /* Flush the entire metadata cache again since the EOA could have changed in the truncate call. */ - if(H5AC_flush(f) < 0) + if (H5AC_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) /* Reset the "flushing the file" flag */ H5CX_set_mpi_file_flushing(FALSE); #endif /* H5_HAVE_PARALLEL */ /* Inform the metadata cache that we are done with the flush */ - if(H5AC_secure_from_file_flush(f) < 0) + if (H5AC_secure_from_file_flush(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "secure from MDC flush failed") /* Flush out the metadata accumulator */ - if(H5F__accum_flush(f->shared) < 0) + if (H5F__accum_flush(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") /* Flush the page buffer */ - if(H5PB_flush(f->shared) < 0) + if (H5PB_flush(f->shared) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "page buffer flush failed") /* Flush file buffers to disk. */ - if(H5FD_flush(f->shared->lf, closing) < 0) + if (H5FD_flush(f->shared->lf, closing) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "low level flush failed") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase2() */ - /*------------------------------------------------------------------------- * Function: H5F__flush * @@ -2052,7 +2270,7 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) herr_t H5F__flush(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2060,100 +2278,58 @@ H5F__flush(H5F_t *f) HDassert(f); /* First phase of flushing data */ - if(H5F__flush_phase1(f) < 0) + if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") /* Second phase of flushing data */ - if(H5F__flush_phase2(f, FALSE) < 0) + if (H5F__flush_phase2(f, FALSE) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush() */ - /*------------------------------------------------------------------------- * Function: H5F__close * - * Purpose: Internal routine to close a file. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5F__close(hid_t file_id) -{ - H5F_t *f; /* File pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Flush file if this is the last reference to this id and we have write - * intent, unless it will be flushed by the "shared" file being closed. - * This is only necessary to replicate previous behaviour, and could be - * disabled by an option/property to improve performance. - */ - if(NULL == (f = (H5F_t *)H5I_object(file_id))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid file identifier") - if((f->shared->nrefs > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - int nref; /* Number of references to file ID */ - - if((nref = H5I_get_ref(file_id, FALSE)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ - - /* Decrement reference count on file ID */ - /* (When it reaches zero the file will be closed) */ - if(H5I_dec_app_ref(file_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "decrementing file ID failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F__close() */ - - -/*------------------------------------------------------------------------- - * Function: H5F__close_cb + * Purpose: Closes a file or causes the close operation to be pended. + * This function is called two ways: from the API it gets called + * by H5Fclose->H5I_dec_ref->H5F__close when H5I_dec_ref() + * decrements the file ID reference count to zero. The file ID + * is removed from the H5I_FILE group by H5I_dec_ref() just + * before H5F__close() is called. If there are open object + * headers then the close is pended by moving the file to the + * H5I_FILE_CLOSING ID group (the f->closing contains the ID + * assigned to file). * - * Purpose: Closes a file or causes the close operation to be pended. - * This function is called from the API and gets called - * by H5Fclose->H5I_dec_ref->H5F__close_cb when H5I_dec_ref() - * decrements the file ID reference count to zero. The file ID - * is removed from the H5I_FILE group by H5I_dec_ref() just - * before H5F__close_cb() is called. If there are open object - * headers then the close is pended by moving the file to the - * H5I_FILE_CLOSING ID group (the f->closing contains the ID - * assigned to file). + * This function is also called directly from H5O_close() when + * the last object header is closed for the file and the file + * has a pending close. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5F__close_cb(H5F_t *f) +H5F__close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); - HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */ /* Perform checks for "semi" file close degree here, since closing the * file is not allowed if there are objects still open. */ - if(f->shared->fc_degree == H5F_CLOSE_SEMI) { - unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ - unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ + if (f->shared->fc_degree == H5F_CLOSE_SEMI) { + unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ + unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if (H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2161,22 +2337,21 @@ H5F__close_cb(H5F_t *f) * without decrementing the file ID's reference count and triggering * a "real" attempt at closing the file. */ - if(nopen_files == 1 && nopen_objs > 0) + if (nopen_files == 1 && nopen_objs > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") } /* Reset the file ID for this file */ - f->file_id = H5I_INVALID_HID; + f->id_exists = FALSE; /* Attempt to close the file/mount hierarchy */ - if(H5F_try_close(f, NULL) < 0) + if (H5F_try_close(f, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F__close_cb() */ +} /* end H5F__close() */ - /*------------------------------------------------------------------------- * Function: H5F_try_close * @@ -2192,9 +2367,9 @@ H5F__close_cb(H5F_t *f) herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) { - unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ - unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ + unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2208,18 +2383,18 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * It's needed by the evict-on-close code. Clients can ignore * this value by passing in NULL. */ - if(was_closed) + if (was_closed) *was_closed = FALSE; /* Check if this file is already in the process of closing */ - if(f->closing) { - if(was_closed) + if (f->closing) { + if (was_closed) *was_closed = TRUE; HGOTO_DONE(SUCCEED) } /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if (H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* @@ -2232,7 +2407,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * H5F_CLOSE_STRONG: if there are still objects open, close them * first, then close file. */ - switch(f->shared->fc_degree) { + switch (f->shared->fc_degree) { case H5F_CLOSE_WEAK: /* * If file or object IDS are still open then delay deletion of @@ -2240,13 +2415,13 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * caches and update the object header anyway so that failing to * close all objects isn't a major problem. */ - if((nopen_files + nopen_objs) > 0) + if ((nopen_files + nopen_objs) > 0) HGOTO_DONE(SUCCEED) break; case H5F_CLOSE_SEMI: /* Can leave safely if file IDs are still open on this file */ - if(nopen_files > 0) + if (nopen_files > 0) HGOTO_DONE(SUCCEED) /* Sanity check: If close degree if "semi" and we have gotten this @@ -2254,15 +2429,17 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) */ HDassert(nopen_files == 0 && nopen_objs == 0); - /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & close */ + /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & + * close */ break; case H5F_CLOSE_STRONG: /* If there are other open files in the hierarchy, we can leave now */ - if(nopen_files > 0) + if (nopen_files > 0) HGOTO_DONE(SUCCEED) - /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall through to flush & close */ + /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall + * through to flush & close */ break; case H5F_CLOSE_DEFAULT: @@ -2274,26 +2451,28 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) f->closing = TRUE; /* If the file close degree is "strong", close all the open objects in this file */ - if(f->shared->fc_degree == H5F_CLOSE_STRONG) { - HDassert(nopen_files == 0); + if (f->shared->fc_degree == H5F_CLOSE_STRONG) { + HDassert(nopen_files == 0); /* Forced close of all opened objects in this file */ - if(f->nopen_objs > 0) { - size_t obj_count; /* # of open objects */ - hid_t objs[128]; /* Array of objects to close */ - herr_t result; /* Local result from obj ID query */ - size_t u; /* Local index variable */ + if (f->nopen_objs > 0) { + size_t obj_count; /* # of open objects */ + hid_t objs[128]; /* Array of objects to close */ + herr_t result; /* Local result from obj ID query */ + size_t u; /* Local index variable */ /* Get the list of IDs of open dataset, group, & attribute objects */ - while((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_ATTR, (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 - && obj_count != 0 ) { + while ((result = H5F_get_obj_ids( + f, H5F_OBJ_LOCAL | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_ATTR, + (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 && + obj_count != 0) { /* Try to close all the open objects in this file */ - for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u]) < 0) + for (u = 0; u < obj_count; u++) + if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(1)") /* Get the list of IDs of open named datatype objects */ @@ -2301,58 +2480,88 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * they could be using one of the named datatypes and then the * open named datatype ID will get closed twice) */ - while((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE, (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, &obj_count)) <= 0 - && obj_count != 0) { + while ((result = H5F_get_obj_ids(f, H5F_OBJ_LOCAL | H5F_OBJ_DATATYPE, + (int)(sizeof(objs) / sizeof(objs[0])), objs, FALSE, + &obj_count)) <= 0 && + obj_count != 0) { /* Try to close all the open objects in this file */ - for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u]) < 0) + for (u = 0; u < obj_count; u++) + if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } - if(result < 0) + if (result < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(2)") } /* end if */ - } /* end if */ + } /* end if */ /* Check if this is a child file in a mounting hierarchy & proceed up the * hierarchy if so. */ - if(f->parent) - if(H5F_try_close(f->parent, NULL) < 0) + if (f->parent) + if (H5F_try_close(f->parent, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close parent file") /* Unmount and close each child before closing the current file. */ - if(H5F__close_mounts(f) < 0) + if (H5F__close_mounts(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't unmount child files") /* If there is more than one reference to the shared file struct and the * file has an external file cache, we should see if it can be closed. This * can happen if a cycle is formed with external file caches. */ - if(f->shared->efc && (f->shared->nrefs > 1)) - if(H5F__efc_try_close(f) < 0) + if (f->shared->efc && (f->shared->nrefs > 1)) + if (H5F__efc_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't attempt to close EFC") - /* Delay flush until the shared file struct is closed, in H5F__dest. If the - * application called H5Fclose, it would have been flushed in that function - * (unless it will have been flushed in H5F_dest anyways). - */ - /* Destroy the H5F_t struct and decrement the reference count for the * 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) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") /* Since we closed the file, this should be set to TRUE */ - if(was_closed) + if (was_closed) *was_closed = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_try_close() */ - +/*------------------------------------------------------------------------- + * Function: H5F__reopen + * + * Purpose: Reopen a file. The new file handle which is returned points + * to the same file as the specified file handle. Both handles + * share caches and other information. The only difference + * between the handles is that the new handle is not mounted + * anywhere and no files are mounted on it. + * + * Return: Success: A pointer to a file struct + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5F_t * +H5F__reopen(H5F_t *f) +{ + H5F_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get a new "top level" file struct, sharing the same "low level" file struct */ + if (NULL == (ret_value = H5F__new(f->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file") + + /* Duplicate old file's names */ + ret_value->open_name = H5MM_xstrdup(f->open_name); + ret_value->actual_name = H5MM_xstrdup(f->actual_name); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__reopen() */ + /*------------------------------------------------------------------------- * Function: H5F_get_id * @@ -2366,32 +2575,30 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) *------------------------------------------------------------------------- */ hid_t -H5F_get_id(H5F_t *file, hbool_t app_ref) +H5F_get_id(H5F_t *file) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(file->file_id == H5I_INVALID_HID) { - /* Get an atom for the file */ - if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file") + if (H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) { + /* resurrect the ID - Register an ID with the native connector */ + if ((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + file->id_exists = TRUE; } else { /* Increment reference count on existing ID */ - if(H5I_inc_ref(file->file_id, app_ref) < 0) + if (H5I_inc_ref(ret_value, FALSE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "incrementing file ID failed") } /* end else */ - ret_value = file->file_id; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_id() */ - /*------------------------------------------------------------------------- * Function: H5F_incr_nopen_objs * @@ -2412,7 +2619,6 @@ H5F_incr_nopen_objs(H5F_t *f) FUNC_LEAVE_NOAPI(++f->nopen_objs) } /* end H5F_incr_nopen_objs() */ - /*------------------------------------------------------------------------- * Function: H5F_decr_nopen_objs * @@ -2433,7 +2639,6 @@ H5F_decr_nopen_objs(H5F_t *f) FUNC_LEAVE_NOAPI(--f->nopen_objs) } /* end H5F_decr_nopen_objs() */ - /*------------------------------------------------------------------------- * Function: H5F__build_actual_name * @@ -2446,14 +2651,14 @@ H5F_decr_nopen_objs(H5F_t *f) */ static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, - char **actual_name/*out*/) + char **actual_name /*out*/) { - hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */ + hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */ #ifdef H5_HAVE_SYMLINK /* This has to be declared here to avoid unfreed resources on errors */ - char *realname = NULL; /* Fully resolved path name of file */ -#endif /* H5_HAVE_SYMLINK */ - herr_t ret_value = SUCCEED; /* Return value */ + char *realname = NULL; /* Fully resolved path name of file */ +#endif /* H5_HAVE_SYMLINK */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2471,90 +2676,90 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n */ #ifdef H5_HAVE_SYMLINK /* Check for POSIX I/O compatible file handle */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE)) { - h5_stat_t lst; /* Stat info from lstat() call */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE)) { + h5_stat_t lst; /* Stat info from lstat() call */ /* Call lstat() on the file's name */ - if(HDlstat(name, &lst) < 0) + if (HDlstat(name, &lst) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stat info for file") /* 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 */ - 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 */ + if (S_IFLNK == (lst.st_mode & S_IFMT)) { + H5P_genplist_t *new_fapl; /* Duplicated FAPL */ + 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 */ /* Allocate realname buffer */ - if(NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char)))) + if (NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Perform a sanity check that the file or link wasn't switched * between when we opened it and when we called lstat(). This is * according to the security best practices for lstat() documented - * here: https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link + * here: + * https://www.securecoding.cert.org/confluence/display/seccode/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link */ /* Copy the FAPL object to modify */ - if((new_fapl_id = H5P_copy_plist(fapl, FALSE)) < 0) + if ((new_fapl_id = H5P_copy_plist(fapl, FALSE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy file access property list") - if(NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id))) + 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 */ want_posix_fd = TRUE; - if(H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) + 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") /* Retrieve the file handle */ - if(H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0) + if (H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve POSIX file descriptor") /* Stat the filename we're resolving */ - if(HDstat(name, &st) < 0) + if (HDstat(name, &st) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to stat file") /* Stat the file we opened */ - if(HDfstat(*fd, &fst) < 0) + if (HDfstat(*fd, &fst) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to fstat file") /* Verify that the files are really the same */ - if(st.st_mode != fst.st_mode || st.st_ino != fst.st_ino || st.st_dev != fst.st_dev) + if (st.st_mode != fst.st_mode || st.st_ino != fst.st_ino || st.st_dev != fst.st_dev) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "files' st_ino or st_dev fields changed!") /* Get the resolved path for the file name */ - if(NULL == HDrealpath(name, realname)) + if (NULL == HDrealpath(name, realname)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve real path for file") /* Duplicate the resolved path for the file name */ - if(NULL == (*actual_name = (char *)H5MM_strdup(realname))) + if (NULL == (*actual_name = (char *)H5MM_strdup(realname))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate real path") } /* end if */ - } /* end if */ -#endif /* H5_HAVE_SYMLINK */ + } /* end if */ +#endif /* H5_HAVE_SYMLINK */ /* Check if we've resolved the file's name */ - if(NULL == *actual_name) { + if (NULL == *actual_name) { /* Just duplicate the name used to open the file */ - if(NULL == (*actual_name = (char *)H5MM_strdup(name))) + if (NULL == (*actual_name = (char *)H5MM_strdup(name))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't duplicate open name") } /* end else */ done: /* Close the property list */ - if(new_fapl_id > 0) - if(H5I_dec_app_ref(new_fapl_id) < 0) + if (new_fapl_id > 0) + if (H5I_dec_app_ref(new_fapl_id) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL") #ifdef H5_HAVE_SYMLINK - if(realname) + if (realname) realname = (char *)H5MM_xfree(realname); #endif /* H5_HAVE_SYMLINK */ FUNC_LEAVE_NOAPI(ret_value) } /* H5F__build_actual_name() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_encode_len * @@ -2566,9 +2771,9 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n *------------------------------------------------------------------------- */ void -H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) +H5F_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2576,22 +2781,21 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) HDassert(addr_len); HDassert(pp && *pp); - if(H5F_addr_defined(addr)) { - for(u = 0; u < addr_len; u++) { + if (H5F_addr_defined(addr)) { + for (u = 0; u < addr_len; u++) { *(*pp)++ = (uint8_t)(addr & 0xff); addr >>= 8; } /* end for */ HDassert("overflow" && 0 == addr); } /* end if */ else { - for(u = 0; u < addr_len; u++) + for (u = 0; u < addr_len; u++) *(*pp)++ = 0xff; } /* end else */ FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_encode_len() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_encode * @@ -2603,7 +2807,7 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) +H5F_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2615,7 +2819,6 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_encode() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_decode_len * @@ -2630,10 +2833,10 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) +H5F_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { - hbool_t all_zero = TRUE; /* True if address was all zeroes */ - unsigned u; /* Local index variable */ + hbool_t all_zero = TRUE; /* True if address was all zeroes */ + unsigned u; /* Local index variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2646,40 +2849,38 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr *addr_p = 0; /* Decode bytes from address */ - for(u = 0; u < addr_len; u++) { - uint8_t c; /* Local decoded byte */ + for (u = 0; u < addr_len; u++) { + uint8_t c; /* Local decoded byte */ /* Get decoded byte (and advance pointer) */ c = *(*pp)++; /* Check for non-undefined address byte value */ - if(c != 0xff) + if (c != 0xff) all_zero = FALSE; - if(u < sizeof(*addr_p)) { - haddr_t tmp = c; /* Local copy of address, for casting */ + if (u < sizeof(*addr_p)) { + haddr_t tmp = c; /* Local copy of address, for casting */ /* Shift decoded byte to correct position */ - tmp <<= (u * 8); /*use tmp to get casting right */ + tmp <<= (u * 8); /*use tmp to get casting right */ /* Merge into already decoded bytes */ *addr_p |= tmp; } /* end if */ - else - if(!all_zero) - HDassert(0 == **pp); /*overflow */ - } /* end for */ + else if (!all_zero) + HDassert(0 == **pp); /*overflow */ + } /* end for */ /* If 'all_zero' is still TRUE, the address was entirely composed of '0xff' * bytes, which is the encoded form of 'HADDR_UNDEF', so set the destination * to that value */ - if(all_zero) + if (all_zero) *addr_p = HADDR_UNDEF; FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_decode_len() */ - /*------------------------------------------------------------------------- * Function: H5F_addr_decode * @@ -2694,7 +2895,7 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr *------------------------------------------------------------------------- */ void -H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) +H5F_addr_decode(const H5F_t *f, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2706,7 +2907,6 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o FUNC_LEAVE_NOAPI_VOID } /* end H5F_addr_decode() */ - /*------------------------------------------------------------------------- * Function: H5F_set_grp_btree_shared * @@ -2731,7 +2931,6 @@ H5F_set_grp_btree_shared(H5F_t *f, H5UC_t *rc) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_grp_btree_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_addr * @@ -2755,7 +2954,6 @@ H5F_set_sohm_addr(H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_vers * @@ -2779,7 +2977,6 @@ H5F_set_sohm_vers(H5F_t *f, unsigned vers) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_vers() */ - /*------------------------------------------------------------------------- * Function: H5F_set_sohm_nindexes * @@ -2803,7 +3000,6 @@ H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_sohm_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5F_set_store_msg_crt_idx * @@ -2827,7 +3023,6 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_store_msg_crt_idx() */ - /*------------------------------------------------------------------------- * Function: H5F__set_libver_bounds() * @@ -2845,7 +3040,7 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2854,7 +3049,7 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) HDassert(f->shared); /* Set the bounds only if the existing setting is different from the inputs */ - if(f->shared->low_bound != low || f->shared->high_bound != high) { + if (f->shared->low_bound != low || f->shared->high_bound != high) { /* Call the flush routine, for this file */ /* Note: This is done in case the binary format for representing a * metadata entry class changes when the file format low / high @@ -2875,11 +3070,11 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) * * QAK - April, 2018 */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Set the new bounds */ - f->shared->low_bound = low; + f->shared->low_bound = low; f->shared->high_bound = high; } @@ -2887,7 +3082,6 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) FUNC_LEAVE_NOAPI(ret_value) } /* H5F__set_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5F__get_file_image * @@ -2900,17 +3094,17 @@ H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high) ssize_t H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) { - H5FD_t *fd_ptr; /* file driver */ - haddr_t eoa; /* End of file address */ - ssize_t ret_value = -1; /* Return value */ + H5FD_t *fd_ptr; /* file driver */ + haddr_t eoa; /* End of file address */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE /* Check args */ - if(!file || !file->shared || !file->shared->lf) + if (!file || !file->shared || !file->shared->lf) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer") fd_ptr = file->shared->lf; - if(!fd_ptr->cls) + if (!fd_ptr->cls) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer") /* the address space used by the split and multi file drivers is not @@ -2931,7 +3125,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * * JRM -- 11/11/22 */ - if(HDstrcmp(fd_ptr->cls->name, "multi") == 0) + if (HDstrcmp(fd_ptr->cls->name, "multi") == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.") /* While the family file driver is conceptually fully compatible @@ -2942,7 +3136,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * * While this problem is quire solvable, the required time and * resources are lacking at present. Hence, for now, we don't - * allow the get file image operation to be perfomed on files + * allow the get file image operation to be performed on files * opened with the family file driver. * * Observe that the following test only looks at the top level @@ -2953,30 +3147,30 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * in the future. * JRM -- 12/21/11 */ - if(HDstrcmp(fd_ptr->cls->name, "family") == 0) + if (HDstrcmp(fd_ptr->cls->name, "family") == 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.") /* Go get the actual file size */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size") /* set ret_value = to eoa -- will overwrite this if appropriate */ ret_value = (ssize_t)eoa; /* test to see if a buffer was provided -- if not, we are done */ - if(buf_ptr != NULL) { - size_t space_needed; /* size of file image */ + if (buf_ptr != NULL) { + size_t space_needed; /* size of file image */ unsigned tmp, tmp_size; /* Check for buffer too small */ - if((haddr_t)buf_len < eoa) + if ((haddr_t)buf_len < eoa) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small") space_needed = (size_t)eoa; /* read in the file image */ /* (Note compensation for base address addition in internal routine) */ - if(H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) + if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed") /* Offset to "status_flags" in the superblock */ @@ -2993,7 +3187,6 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_file_image() */ - /*------------------------------------------------------------------------- * Function: H5F__get_info * @@ -3006,7 +3199,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3019,28 +3212,27 @@ H5F__get_info(H5F_t *f, H5F_info2_t *finfo) HDmemset(finfo, 0, sizeof(*finfo)); /* Get the size of the superblock and any superblock extensions */ - if(H5F__super_size(f, &finfo->super.super_size, &finfo->super.super_ext_size) < 0) + if (H5F__super_size(f, &finfo->super.super_size, &finfo->super.super_ext_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock sizes") /* Get the size of any persistent free space */ - if(H5MF_get_freespace(f, &finfo->free.tot_space, &finfo->free.meta_size) < 0) + if (H5MF_get_freespace(f, &finfo->free.tot_space, &finfo->free.meta_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve free space information") /* Check for SOHM info */ - if(H5F_addr_defined(f->shared->sohm_addr)) - if(H5SM_ih_size(f, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) + if (H5F_addr_defined(f->shared->sohm_addr)) + if (H5SM_ih_size(f, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve SOHM index & heap storage info") /* Set version # fields */ finfo->super.version = f->shared->sblock->super_vers; - finfo->sohm.version = f->shared->sohm_vers; - finfo->free.version = HDF5_FREESPACE_VERSION; + finfo->sohm.version = f->shared->sohm_vers; + finfo->free.version = HDF5_FREESPACE_VERSION; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__get_info() */ - /*------------------------------------------------------------------------- * Function: H5F_track_metadata_read_retries * @@ -3056,9 +3248,9 @@ H5F__get_info(H5F_t *f, H5F_info2_t *finfo) herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) { - unsigned log_ind; /* Index to the array of retries based on log10 of retries */ - double tmp; /* Temporary value, to keep compiler quiet */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned log_ind; /* Index to the array of retries based on log10 of retries */ + double tmp; /* Temporary value, to keep compiler quiet */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3071,12 +3263,13 @@ H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) HDassert(actype < H5AC_NTYPES); /* Allocate memory for retries */ - if(NULL == f->shared->retries[actype]) - if(NULL == (f->shared->retries[actype] = (uint32_t *)H5MM_calloc((size_t)f->shared->retries_nbins * sizeof(uint32_t)))) + if (NULL == f->shared->retries[actype]) + if (NULL == (f->shared->retries[actype] = + (uint32_t *)H5MM_calloc((size_t)f->shared->retries_nbins * sizeof(uint32_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Index to retries based on log10 */ - tmp = HDlog10((double)retries); + tmp = HDlog10((double)retries); log_ind = (unsigned)tmp; HDassert(log_ind < f->shared->retries_nbins); @@ -3087,7 +3280,6 @@ H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) FUNC_LEAVE_NOAPI(ret_value) } /* H5F_track_metadata_read_retries() */ - /*------------------------------------------------------------------------- * Function: H5F_set_retries * @@ -3101,7 +3293,7 @@ H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) herr_t H5F_set_retries(H5F_t *f) { - double tmp; /* Temporary variable */ + double tmp; /* Temporary variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3114,17 +3306,16 @@ H5F_set_retries(H5F_t *f) /* Initialize the # of bins for retries */ f->shared->retries_nbins = 0; - if(f->shared->read_attempts > 1) { + if (f->shared->read_attempts > 1) { /* Use HDceil to ensure that the log10 value is rounded up to the nearest integer before casting to unsigned */ - tmp = HDceil(HDlog10((double)f->shared->read_attempts)); + tmp = HDceil(HDlog10((double)f->shared->read_attempts)); f->shared->retries_nbins = (unsigned)tmp; } FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_retries() */ - /*------------------------------------------------------------------------- * Function: H5F_object_flush_cb * @@ -3138,7 +3329,7 @@ H5F_set_retries(H5F_t *f) herr_t H5F_object_flush_cb(H5F_t *f, hid_t obj_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3147,14 +3338,14 @@ H5F_object_flush_cb(H5F_t *f, hid_t obj_id) HDassert(f->shared); /* Invoke object flush callback if there is one */ - if(f->shared->object_flush.func && f->shared->object_flush.func(obj_id, f->shared->object_flush.udata) < 0) + if (f->shared->object_flush.func && + f->shared->object_flush.func(obj_id, f->shared->object_flush.udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "object flush callback returns error") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_object_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5F__set_base_addr * @@ -3166,7 +3357,7 @@ H5F_object_flush_cb(H5F_t *f, hid_t obj_id) herr_t H5F__set_base_addr(const H5F_t *f, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3174,14 +3365,13 @@ H5F__set_base_addr(const H5F_t *f, haddr_t addr) HDassert(f->shared); /* Dispatch to driver */ - if(H5FD_set_base_addr(f->shared->lf, addr) < 0) + if (H5FD_set_base_addr(f->shared->lf, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_base_addr request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_base_addr() */ - /*------------------------------------------------------------------------- * Function: H5F__set_eoa * @@ -3193,7 +3383,7 @@ H5F__set_base_addr(const H5F_t *f, haddr_t addr) herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3201,14 +3391,14 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) HDassert(f->shared); /* Dispatch to driver */ - if(H5FD_set_eoa(f->shared->lf, type, addr) < 0) + /* (H5FD_set_eoa() will add base_addr to addr) */ + if (H5FD_set_eoa(f->shared->lf, type, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F__set_paged_aggr * @@ -3220,7 +3410,7 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) herr_t H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3229,14 +3419,13 @@ H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) HDassert(f->shared); /* Dispatch to driver */ - if(H5FD_set_paged_aggr(f->shared->lf, paged) < 0) + if (H5FD_set_paged_aggr(f->shared->lf, paged) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set paged aggr mode failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_paged_aggr() */ - /*------------------------------------------------------------------------- * Function: H5F__get_max_eof_eoa * @@ -3248,10 +3437,10 @@ H5F__set_paged_aggr(const H5F_t *f, hbool_t paged) herr_t H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa) { - haddr_t eof; /* Relative address for EOF */ - haddr_t eoa; /* Relative address for EOA */ + haddr_t eof; /* Relative address for EOF */ + haddr_t eoa; /* Relative address for EOA */ haddr_t tmp_max; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3265,7 +3454,7 @@ H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa) /* Determine the maximum */ tmp_max = MAX(eof, eoa); - if(HADDR_UNDEF == tmp_max) + if (HADDR_UNDEF == tmp_max) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed") *max_eof_eoa = tmp_max; @@ -3274,35 +3463,8 @@ H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_max_eof_eoa() */ -#ifdef H5_HAVE_PARALLEL - -/*------------------------------------------------------------------------- - * Function: H5F_set_coll_md_read - * - * Purpose: Set the coll_md_read field with a new value. - * - * Return: Success: SUCCEED - * Failure: FAIL - *------------------------------------------------------------------------- - */ -void -H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr) -{ - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(f); - - f->coll_md_read = cmr; - - FUNC_LEAVE_NOAPI_VOID -} /* H5F_set_coll_md_read() */ -#endif /* H5_HAVE_PARALLEL */ - - /*------------------------------------------------------------------------- - * Function: H5F__get_metadata_read_retry_info + * Function: H5F_get_metadata_read_retry_info * * Purpose: Private function to retrieve the collection of read retries * for metadata items with checksum. @@ -3312,13 +3474,13 @@ H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr) *------------------------------------------------------------------------- */ herr_t -H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) +H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) { - unsigned i, j; /* Local index variable */ - size_t tot_size; /* Size of each retries[i] */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i, j; /* Local index variable */ + size_t tot_size; /* Size of each retries[i] */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(file); @@ -3331,7 +3493,7 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) HDmemset(info->retries, 0, sizeof(info->retries)); /* Return if there are no bins -- no retries */ - if(!info->nbins) + if (!info->nbins) HGOTO_DONE(SUCCEED); /* Calculate size for each retries[i] */ @@ -3339,7 +3501,7 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) /* Map and copy information to info's retries for metadata items with tracking for read retries */ j = 0; - for(i = 0; i < H5AC_NTYPES; i++) { + for (i = 0; i < H5AC_NTYPES; i++) { switch (i) { case H5AC_OHDR_ID: case H5AC_OHDR_CHK_ID: @@ -3363,13 +3525,13 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) case H5AC_FARRAY_DBLK_PAGE_ID: case H5AC_SUPERBLOCK_ID: HDassert(j < H5F_NUM_METADATA_READ_RETRY_TYPES); - if(file->shared->retries[i] != NULL) { + if (file->shared->retries[i] != NULL) { /* Allocate memory for retries[i] * * This memory should be released by the user with * the H5free_memory() call. */ - if(NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size))) + if (NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the information */ @@ -3387,10 +3549,8 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F__get_metadata_read_retry_info() */ +} /* end H5F_get_metadata_read_retry_info() */ - - /*------------------------------------------------------------------------- * Function: H5F__start_swmr_write * @@ -3428,17 +3588,18 @@ H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) herr_t H5F__start_swmr_write(H5F_t *f) { - hbool_t ci_load = FALSE; /* whether MDC ci load requested */ - 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t ci_load = FALSE; /* whether MDC ci load requested */ + 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3447,64 +3608,79 @@ H5F__start_swmr_write(H5F_t *f) HDassert(f->shared); /* Should have write permission */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) == 0) + if ((H5F_INTENT(f) & H5F_ACC_RDWR) == 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no write intent on file") /* Check superblock version */ - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version - should be at least 3") /* Check for correct file format version */ - if((f->shared->low_bound != H5F_LIBVER_V110) || (f->shared->high_bound != H5F_LIBVER_V110)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file format version does not support SWMR - needs to be 1.10 or greater") + if ((f->shared->low_bound < H5F_LIBVER_V110) || (f->shared->high_bound < H5F_LIBVER_V110)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "file format version does not support SWMR - needs to be 1.10 or greater") /* Should not be marked for SWMR writing mode already */ - if(f->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) + if (f->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file already in SWMR writing mode") /* Check to see if cache image is enabled. Fail if so */ - if(H5C_cache_image_status(f, &ci_load, &ci_write) < 0) + if (H5C_cache_image_status(f, &ci_load, &ci_write) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status") - if(ci_load || ci_write ) + if (ci_load || ci_write) HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and MDC cache image") /* Flush the superblock extension */ - if(H5F_flush_tagged_metadata(f, f->shared->sblock->ext_addr) < 0) + if (H5F_flush_tagged_metadata(f, f->shared->sblock->ext_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock extension") /* Flush data buffers */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Get the # of opened named datatypes and attributes */ - if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) + if (H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(nt_attr_count > 0) + if (nt_attr_count > 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file") /* Get the # of opened datasets and groups */ - if(H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) + if (H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(grp_dset_count > 0) { + 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) + 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") - if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) + 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") - if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) + 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") - if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) + 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") /* 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, &grp_dset_count) < 0) + if (H5F_get_obj_ids(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, + &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") - /* Refresh opened objects (groups, datasets) in the file */ - for(u = 0; u < grp_dset_count; u++) { - H5O_loc_t *oloc; /* object location */ - H5G_loc_t tmp_loc; + /* Save the VOL connector and the object wrapping context for the refresh step */ + if (grp_dset_count > 0) { + H5VL_object_t *vol_obj; + + /* Get the VOL object for one of the IDs */ + if (NULL == (vol_obj = H5VL_vol_object(obj_ids[0]))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Get the (top) connector for the ID */ + vol_connector = vol_obj->connector; + } /* end if */ + + /* 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 */ + H5G_loc_t tmp_loc; /* Set up the id's group location */ obj_glocs[u].oloc = &obj_olocs[u]; @@ -3512,7 +3688,7 @@ H5F__start_swmr_write(H5F_t *f) H5G_loc_reset(&obj_glocs[u]); /* get the id's object location */ - if((oloc = H5O_get_loc(obj_ids[u])) == NULL) + 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 */ @@ -3520,13 +3696,13 @@ H5F__start_swmr_write(H5F_t *f) H5G_loc_copy(&obj_glocs[u], &tmp_loc, H5_COPY_DEEP); /* Close the object */ - if(H5I_dec_ref(obj_ids[u]) < 0) + if (H5I_dec_ref(obj_ids[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "decrementing object ID failed") } /* end for */ - } /* end if */ + } /* end if */ /* Flush and reset the accumulator */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Turn on SWMR write in shared file open flags */ @@ -3539,50 +3715,61 @@ H5F__start_swmr_write(H5F_t *f) f->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS; /* Initialize "retries" and "retries_nbins" */ - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins") /* Turn off usage of accumulator */ f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; - if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD") setup = TRUE; /* Place an advisory lock on the file */ - if(H5F_USE_FILE_LOCKING(f)) - if(H5FD_lock(f->shared->lf, TRUE) < 0) { + if (H5F_USE_FILE_LOCKING(f)) { + /* Have to unlock on Windows as Win32 doesn't support changing the lock + * type (exclusive vs shared) with a second call. + */ + if (H5FD_unlock(f->shared->lf) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file") + } + if (H5FD_lock(f->shared->lf, TRUE) < 0) { HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, FAIL, "unable to lock the file") } + } /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* Flush the superblock */ - if(H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock") /* Evict all flushed entries in the cache except the pinned superblock */ - if(H5F__evict_cache_entries(f) < 0) + if (H5F__evict_cache_entries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information") /* 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], TRUE) < 0) + for (u = 0; u < grp_dset_count; u++) + if (H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_connector, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") + /* Unlock the file */ + if (H5FD_unlock(f->shared->lf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to unlock the file") + done: - if(ret_value < 0 && setup) { + 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) + if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD") /* Reset the # of read attempts */ f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - if(H5F_set_retries(f) < 0) + if (H5F_set_retries(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins") /* Un-set H5F_ACC_SWMR_WRITE in shared open flags */ @@ -3592,33 +3779,27 @@ H5F__start_swmr_write(H5F_t *f) f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* Flush the superblock */ - if(H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) + if (H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock") } /* end if */ - /* Unlock the file */ - if(H5F_USE_FILE_LOCKING(f)) - if(H5FD_unlock(f->shared->lf) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file") - /* Free memory */ - if(obj_ids) + if (obj_ids) H5MM_xfree(obj_ids); - if(obj_glocs) + if (obj_glocs) H5MM_xfree(obj_glocs); - if(obj_olocs) + if (obj_olocs) H5MM_xfree(obj_olocs); - if(obj_paths) + if (obj_paths) H5MM_xfree(obj_paths); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__start_swmr_write() */ - /*------------------------------------------------------------------------- * Function: H5F__format_convert * @@ -3631,8 +3812,8 @@ H5F__start_swmr_write(H5F_t *f) herr_t H5F__format_convert(H5F_t *f) { - hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t mark_dirty = FALSE; /* Whether to mark the file's superblock dirty */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3641,29 +3822,30 @@ H5F__format_convert(H5F_t *f) HDassert(f->shared); /* Check if the superblock should be downgraded */ - if(f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { + if (f->shared->sblock->super_vers > HDF5_SUPERBLOCK_VERSION_V18_LATEST) { f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_V18_LATEST; - mark_dirty = TRUE; + mark_dirty = TRUE; } /* Check for persistent freespace manager, which needs to be downgraded */ - if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { + if (!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { /* Check to remove free-space manager info message from superblock extension */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + if (H5F_addr_defined(f->shared->sblock->ext_addr)) + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") /* Close freespace manager */ - if(H5MF_try_close(f) < 0) + if (H5MF_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to free free-space address") /* Set non-persistent freespace manager */ - f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; - f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; + f->shared->fs_strategy = H5F_FILE_SPACE_STRATEGY_DEF; + f->shared->fs_persist = H5F_FREE_SPACE_PERSIST_DEF; f->shared->fs_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; f->shared->fs_page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; @@ -3672,16 +3854,77 @@ H5F__format_convert(H5F_t *f) } /* end if */ /* Check if we should mark the superblock dirty */ - if(mark_dirty) + if (mark_dirty) /* Mark superblock as dirty */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__format_convert() */ - +/*------------------------------------------------------------------------- + * Function: H5F_get_file_id + * + * Purpose: The private version of H5Iget_file_id(), obtains the file + * ID given an object ID. + * + * Return: Success: The file ID associated with the object + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = obj_type; + + /* Retrieve VOL file from object */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &vol_obj_file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file from object") + + /* Check if the file's ID already exists */ + if (H5I_find_id(vol_obj_file, H5I_FILE, &file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed") + + /* If the ID does not exist, register it with the VOL connector */ + if (H5I_INVALID_HID == file_id) { + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + if ((file_id = H5VL_wrap_register(H5I_FILE, vol_obj_file, app_ref)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + } /* end if */ + else { + /* Increment ref count on existing ID */ + if (H5I_inc_ref(file_id, app_ref) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") + } /* end else */ + + /* Set return value */ + ret_value = file_id; + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_file_id() */ + /*------------------------------------------------------------------------- * Function: H5F_set_min_dset_ohdr * @@ -3704,4 +3947,3 @@ H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_min_dset_ohdr() */ - diff --git a/src/H5Fio.c b/src/H5Fio.c index 0a2effb8af8..5a9d2c17c87 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,56 +26,88 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* 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 "H5PBprivate.h" /* Page Buffer */ - +#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 "H5PBprivate.h" /* Page Buffer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/*------------------------------------------------------------------------- + * Function: H5F_shared_block_read + * + * Purpose: Reads some data from a file/server/etc into a buffer. + * The data is contiguous. The address is relative to the base + * address for the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Jul 10 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) +{ + H5FD_mem_t map_type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f_sh); + HDassert(buf); + HDassert(H5F_addr_defined(addr)); + + /* Check for attempting I/O on 'temporary' file address */ + if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) + HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + + /* Pass through page buffer layer */ + if (H5PB_read(f_sh, map_type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_shared_block_read() */ - /*------------------------------------------------------------------------- * Function: H5F_block_read * @@ -91,10 +123,10 @@ *------------------------------------------------------------------------- */ herr_t -H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_mem_t map_type; /* Mapped memory type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mem_t map_type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -105,21 +137,63 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/* HDassert(H5F_addr_defined(addr)); /* Check for attempting I/O on 'temporary' file address */ - if(H5F_addr_le(f->shared->tmp_addr, (addr + size))) + if (H5F_addr_le(f->shared->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; /* Pass through page buffer layer */ - if(H5PB_read(f->shared, map_type, addr, size, buf) < 0) + if (H5PB_read(f->shared, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_block_read() */ - +/*------------------------------------------------------------------------- + * Function: H5F_shared_block_write + * + * Purpose: Writes some data from memory to a file/server/etc. The + * data is contiguous. The address is relative to the base + * address. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Jul 10 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) +{ + H5FD_mem_t map_type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f_sh); + HDassert(H5F_SHARED_INTENT(f_sh) & H5F_ACC_RDWR); + HDassert(buf); + HDassert(H5F_addr_defined(addr)); + + /* Check for attempting I/O on 'temporary' file address */ + if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) + HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + + /* Pass through page buffer layer */ + if (H5PB_write(f_sh, map_type, addr, size, buf) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_shared_block_write() */ + /*------------------------------------------------------------------------- * Function: H5F_block_write * @@ -137,8 +211,8 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/* herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - H5FD_mem_t map_type; /* Mapped memory type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mem_t map_type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -150,21 +224,20 @@ H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void HDassert(H5F_addr_defined(addr)); /* Check for attempting I/O on 'temporary' file address */ - if(H5F_addr_le(f->shared->tmp_addr, (addr + size))) + if (H5F_addr_le(f->shared->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") /* Treat global heap as raw data */ map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; /* Pass through page buffer layer */ - if(H5PB_write(f->shared, map_type, addr, size, buf) < 0) + if (H5PB_write(f->shared, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_block_write() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_tagged_metadata * @@ -186,22 +259,21 @@ H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag) FUNC_ENTER_NOAPI(FAIL) /* Use tag to search for and flush associated metadata */ - if(H5AC_flush_tagged_metadata(f, tag) < 0) + if (H5AC_flush_tagged_metadata(f, tag) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Flush and reset the accumulator */ - if(H5F__accum_reset(f->shared, TRUE) < 0) + if (H5F__accum_reset(f->shared, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator") /* Flush file buffers to disk. */ - if(H5FD_flush(f->shared->lf, FALSE) < 0) + if (H5FD_flush(f->shared->lf, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_flush_tagged_metadata */ - /*------------------------------------------------------------------------- * Function: H5F_evict_tagged_metadata * @@ -222,14 +294,13 @@ H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag) FUNC_ENTER_NOAPI(FAIL) /* Evict the object's metadata */ - if(H5AC_evict_tagged_metadata(f, tag, TRUE) < 0) + if (H5AC_evict_tagged_metadata(f, tag, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F_evict_tagged_metadata */ - /*------------------------------------------------------------------------- * Function: H5F__evict_cache_entries * @@ -253,37 +324,36 @@ H5F__evict_cache_entries(H5F_t *f) HDassert(f->shared); /* Evict all except pinned entries in the cache */ - if(H5AC_evict(f) < 0) + if (H5AC_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict all except pinned entries") #ifndef NDEBUG -{ - unsigned status = 0; - uint32_t cur_num_entries; - - /* Retrieve status of the superblock */ - if(H5AC_get_entry_status(f, (haddr_t)0, &status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") - - /* Verify status of the superblock entry in the cache */ - if(!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") - - /* Get the number of cache entries */ - if(H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - /* Should be the only one left in the cache (the superblock) */ - if(cur_num_entries != 1) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct") -} + { + unsigned status = 0; + uint32_t cur_num_entries; + + /* Retrieve status of the superblock */ + if (H5AC_get_entry_status(f, (haddr_t)0, &status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") + + /* Verify status of the superblock entry in the cache */ + if (!(status & H5AC_ES__IN_CACHE) || !(status & H5AC_ES__IS_PINNED)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get entry status") + + /* Get the number of cache entries */ + if (H5AC_get_cache_size(f->shared->cache, NULL, NULL, NULL, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + /* Should be the only one left in the cache (the superblock) */ + if (cur_num_entries != 1) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "number of cache entries is not correct") + } #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5F__evict_cache_entries() */ - /*------------------------------------------------------------------------- * Function: H5F_get_checksums * @@ -300,7 +370,7 @@ H5F__evict_cache_entries(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/, uint32_t *c_chksum/*out*/) +H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum /*out*/, uint32_t *c_chksum /*out*/) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -309,8 +379,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/ HDassert(buf_size); /* Return the stored checksum */ - if(s_chksum) { - const uint8_t *chk_p; /* Pointer into raw data buffer */ + if (s_chksum) { + const uint8_t *chk_p; /* Pointer into raw data buffer */ /* Offset to the checksum in the buffer */ chk_p = buf + buf_size - H5_SIZEOF_CHKSUM; @@ -320,9 +390,8 @@ H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/ } /* end if */ /* Return the computed checksum for the buffer */ - if(c_chksum) - *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0); + if (c_chksum) + *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F_get_chksums() */ - diff --git a/src/H5Fmodule.h b/src/H5Fmodule.h index fb362fce079..7f0299a0b05 100644 --- a/src/H5Fmodule.h +++ b/src/H5Fmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,54 @@ * H5F package. Including this header means that the source file * is part of the H5F package. */ -#ifndef _H5Fmodule_H -#define _H5Fmodule_H +#ifndef H5Fmodule_H +#define H5Fmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5F_MODULE -#define H5_MY_PKG H5F -#define H5_MY_PKG_ERR H5E_FILE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5F +#define H5_MY_PKG_ERR H5E_FILE +#define H5_MY_PKG_INIT YES -#endif /* _H5Fmodule_H */ +/** + * \defgroup H5F H5F + * + * Use the functions in this module to manage HDF5 files. + * + * In the code snippets below, we show the skeletal life cycle of an HDF5 file, + * when creating a new file (left) or when opening an existing file (right). + * File creation is essentially controlled through \ref FCPL, and file access to + * new and existing files is controlled through \ref FAPL. The file \c name and + * 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
+ * \snippet H5F_examples.c life_cycle + * + * \snippet H5F_examples.c life_cycle_w_open + *
+ * + * In addition to general file management functions, there are three categories + * of functions that deal with advanced file management tasks and use cases: + * 1. The control of the HDF5 \ref MDC + * 2. The use of (MPI-) \ref PH5F HDF5 + * 3. The \ref SWMR pattern + * + * \defgroup MDC Metadata Cache + * \ingroup H5F + * \defgroup PH5F Parallel + * \ingroup H5F + * \defgroup SWMR Single Writer Multiple Readers + * \ingroup H5F + */ +#endif /* H5Fmodule_H */ diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 3c7946df2e2..06f2a63f29d 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -6,29 +6,28 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* PRIVATE PROTOTYPES */ static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); - /*------------------------------------------------------------------------- * Function: H5F__close_mounts * @@ -44,8 +43,8 @@ static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsign herr_t H5F__close_mounts(H5F_t *f) { - unsigned u; /* Local index */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -57,21 +56,21 @@ H5F__close_mounts(H5F_t *f) */ for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) { /* Only unmount children mounted to this top level file structure */ - if(f->shared->mtab.child[u].file->parent == f) { + if (f->shared->mtab.child[u].file->parent == f) { /* Detach the child file from the parent file */ f->shared->mtab.child[u].file->parent = NULL; /* Close the internal group maintaining the mount point */ - if(H5G_close(f->shared->mtab.child[u].group) < 0) + if (H5G_close(f->shared->mtab.child[u].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close child group") /* Close the child file */ - if(H5F_try_close(f->shared->mtab.child[u].file, NULL) < 0) + if (H5F_try_close(f->shared->mtab.child[u].file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") /* Eliminate the mount point from the table */ HDmemmove(f->shared->mtab.child + u, f->shared->mtab.child + u + 1, - (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); + (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); f->shared->mtab.nmounts--; f->nmounts--; } @@ -83,7 +82,6 @@ H5F__close_mounts(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__close_mounts() */ - /*------------------------------------------------------------------------- * Function: H5F__mount * @@ -101,16 +99,16 @@ 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 */ - 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -130,24 +128,24 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED * the parent & child files have the same file close degree, and * that the mount wouldn't introduce a cycle in the mount tree. */ - if(child->parent) + if (child->parent) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") - if(H5G_loc_find(loc, name, &mp_loc) < 0) + if (H5G_loc_find(loc, name, &mp_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") /* If the mount location is holding its file open, that file will close * and remove the mount as soon as we exit this function. Prevent the * user from doing this. */ - if(mp_loc.oloc->holding_file != FALSE) + if (mp_loc.oloc->holding_file != FALSE) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount path cannot contain links to external files") /* Open the mount point group */ - if(NULL == (mount_point = H5G_open(&mp_loc))) + if (NULL == (mount_point = H5G_open(&mp_loc))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") /* Check if the proposed mount point group is already a mount point */ - if(H5G_MOUNTED(mount_point)) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + if (H5G_MOUNTED(mount_point)) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Retrieve information from the mount point group */ /* (Some of which we had before but was reset in mp_loc when the group @@ -159,13 +157,13 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED HDassert(mp_loc.oloc); mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); - for(ancestor = parent; ancestor; ancestor = ancestor->parent) { - if(ancestor->shared == child->shared) + for (ancestor = parent; ancestor; ancestor = ancestor->parent) { + if (ancestor->shared == child->shared) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") } /* Make certain that the parent & child files have the same "file close degree" */ - if(parent->shared->fc_degree != child->shared->fc_degree) + if (parent->shared->fc_degree != child->shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mounted file has different file close degree than parent") /* @@ -174,68 +172,69 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED * `md' will be the index where the child should be inserted. */ lt = md = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - H5O_loc_t *oloc; /*temporary symbol table entry */ + rt = parent->shared->mtab.nmounts; + cmp = -1; + while (lt < rt && cmp) { + H5O_loc_t *oloc; /*temporary symbol table entry */ - md = (lt + rt) / 2; + md = (lt + rt) / 2; oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); - if(cmp < 0) + cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; } - if(cmp > 0) + if (cmp > 0) md++; - if(!cmp) + if (!cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ - if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { - unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); - H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); + if (parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { + unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); + H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, + n * sizeof(parent->shared->mtab.child[0])); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->shared->mtab.child = x; + parent->shared->mtab.child = x; parent->shared->mtab.nalloc = n; } /* Insert into table */ HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, - (parent->shared->mtab.nmounts-md) * sizeof(parent->shared->mtab.child[0])); + (parent->shared->mtab.nmounts - md) * sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts++; parent->nmounts++; parent->shared->mtab.child[md].group = mount_point; - parent->shared->mtab.child[md].file = child; - child->parent = parent; + parent->shared->mtab.child[md].file = child; + child->parent = parent; /* Set the group's mountpoint flag */ - if(H5G_mount(parent->shared->mtab.child[md].group) < 0) + if (H5G_mount(parent->shared->mtab.child[md].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to set group mounted flag") /* Get the group location for the root group in the file to unmount */ - if(NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) + if (NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) + if (NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ - if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, - mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) + if (H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, + root_loc.oloc->file, root_loc.path->full_path_r) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: - if(ret_value < 0) { - if(mount_point) { - if(H5G_close(mount_point) < 0) + if (ret_value < 0) { + if (mount_point) { + if (H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") } else { - if(H5G_loc_free(&mp_loc) < 0) + if (H5G_loc_free(&mp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") } } @@ -243,7 +242,6 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__mount() */ - /*------------------------------------------------------------------------- * Function: H5F__unmount * @@ -265,17 +263,17 @@ 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 */ - 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 */ - H5G_loc_t mp_loc; /* entry used to open mount point*/ - hbool_t mp_loc_setup = FALSE; /* Whether mount point location is set up */ - H5G_loc_t root_loc; /* Group location of root of file to unmount */ - int child_idx; /* Index of child in parent's mtab */ - herr_t ret_value = SUCCEED; /*return value */ + 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 */ + H5G_loc_t mp_loc; /* entry used to open mount point*/ + hbool_t mp_loc_setup = FALSE; /* Whether mount point location is set up */ + H5G_loc_t root_loc; /* Group location of root of file to unmount */ + int child_idx; /* Index of child in parent's mtab */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE @@ -292,23 +290,23 @@ H5F__unmount(H5G_loc_t *loc, const char *name) * If we get the root group and the file has a parent in the mount tree, * then we must have found the mount point. */ - if(H5G_loc_find(loc, name, &mp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &mp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") mp_loc_setup = TRUE; - child = mp_loc.oloc->file; - mnt_oloc = H5G_oloc(child->shared->root_grp); - child_idx = -1; + child = mp_loc.oloc->file; + mnt_oloc = H5G_oloc(child->shared->root_grp); + child_idx = -1; - if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { - unsigned u; /*counters */ + if (child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { + unsigned u; /*counters */ /* * We've been given the root group of the child. We do a reverse * lookup in the parent's mount table to find the correct entry. */ parent = child->parent; - for(u = 0; u < parent->shared->mtab.nmounts; u++) { - if(parent->shared->mtab.child[u].file->shared == child->shared) { + for (u = 0; u < parent->shared->mtab.nmounts; u++) { + if (parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ child_idx = (int)u; break; @@ -316,37 +314,37 @@ H5F__unmount(H5G_loc_t *loc, const char *name) } } else { - unsigned lt, rt, md = 0; /*binary search indices */ - int cmp; /*binary search comparison value*/ + unsigned lt, rt, md = 0; /*binary search indices */ + int cmp; /*binary search comparison value*/ /* We've been given the mount point in the parent. We use a binary * search in the parent to locate the mounted file, if any. */ parent = child; /*we guessed wrong*/ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; + while (lt < rt && cmp) { + md = (lt + rt) / 2; mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); - if (cmp<0) + cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); + if (cmp < 0) rt = md; else lt = md + 1; } - if(cmp) + if (cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ child_idx = (int)md; H5G_loc_free(&mp_loc); mp_loc_setup = FALSE; - mp_loc.oloc = mnt_oloc; - mp_loc.path = H5G_nameof(parent->shared->mtab.child[md].group); - child = parent->shared->mtab.child[child_idx].file; + mp_loc.oloc = mnt_oloc; + mp_loc.path = H5G_nameof(parent->shared->mtab.child[md].group); + child = parent->shared->mtab.child[child_idx].file; /* Set the parent to be the actual parent of the discovered child. * Could be different due to the shared mount table. */ @@ -358,42 +356,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name) child_group = parent->shared->mtab.child[child_idx].group; /* Get the group location for the root group in the file to unmount */ - if(NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) + if (NULL == (root_loc.oloc = H5G_oloc(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) + if (NULL == (root_loc.path = H5G_nameof(child->shared->root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Search the open IDs replace names to reflect unmount operation */ - if(H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, - mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) + if (H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, + root_loc.oloc->file, root_loc.path->full_path_r) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, (parent->shared->mtab.child + (unsigned)child_idx) + 1, - ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * sizeof(parent->shared->mtab.child[0])); + HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, + (parent->shared->mtab.child + (unsigned)child_idx) + 1, + ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * + sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts -= 1; parent->nmounts -= 1; /* Unmount the child file from the parent file */ - if(H5G_unmount(child_group) < 0) + if (H5G_unmount(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to reset group mounted flag") - if(H5G_close(child_group) < 0) + if (H5G_close(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close unmounted group") /* Detach child file from parent & see if it should close */ child->parent = NULL; - if(H5F_try_close(child, NULL) < 0) + if (H5F_try_close(child, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") done: /* Free the mount point location's information, if it's been set up */ - if(mp_loc_setup) + if (mp_loc_setup) H5G_loc_free(&mp_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__unmount() */ - /*------------------------------------------------------------------------- * Function: H5F_is_mount * @@ -410,13 +409,13 @@ H5F__unmount(H5G_loc_t *loc, const char *name) hbool_t H5F_is_mount(const H5F_t *file) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(file); - if(file->parent != NULL) + if (file->parent != NULL) ret_value = TRUE; else ret_value = FALSE; @@ -424,7 +423,6 @@ H5F_is_mount(const H5F_t *file) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_mount() */ - /*------------------------------------------------------------------------- * Function: H5Fmount * @@ -438,53 +436,56 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; /* Parent location */ - H5F_t *child = NULL; /* Child object */ - H5I_type_t loc_type; /* ID type of location */ - H5I_type_t child_type; /* ID type of child */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ + H5VL_object_t *child_vol_obj = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ loc_type = H5I_get_type(loc_id); - if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") child_type = H5I_get_type(child_id); - if(H5I_FILE != child_type) + if (H5I_FILE != child_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") - if(H5P_DEFAULT == plist_id) + if (H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; - else - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") + else if (TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(H5G_loc(loc_id, &loc) < 0) + if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Get the child object */ - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + if (NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + /* Check if both objects are associated with the same VOL connector */ + if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") + /* Perform the mount operation */ - if(H5F__mount(&loc, name, child, plist_id) < 0) + if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name, child_vol_obj->data, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) } /* end H5Fmount() */ - /*------------------------------------------------------------------------- * Function: H5Funmount * @@ -504,39 +505,39 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Parent location */ - H5I_type_t loc_type; /* ID type of location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Parent object */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ loc_type = H5I_get_type(loc_id); - if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(H5G_loc(loc_id, &loc) < 0) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Perform the unmount operation */ - if(H5F__unmount(&loc, name) < 0) + if (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) } /* end H5Funmount() */ - /*------------------------------------------------------------------------- * Function: H5F__mount_count_ids_recurse * @@ -553,7 +554,7 @@ H5Funmount(hid_t loc_id, const char *name) static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { - unsigned u; /* Local index value */ + unsigned u; /* Local index value */ FUNC_ENTER_STATIC_NOERR @@ -563,7 +564,7 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob HDassert(nopen_objs); /* If this file is still open, increment number of file IDs open */ - if(f->file_id > 0) + if (H5F_ID_EXISTS(f)) *nopen_files += 1; /* Increment number of open objects in file @@ -573,11 +574,11 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob *nopen_objs += (f->nopen_objs - f->nmounts); /* Iterate over files mounted in this file and add in their open ID counts also */ - for(u = 0; u < f->shared->mtab.nmounts; u++) { + for (u = 0; u < f->shared->mtab.nmounts; u++) { /* Only recurse on children mounted to this top level file structure */ - if(f->shared->mtab.child[u].file->parent == f) { + if (f->shared->mtab.child[u].file->parent == f) { /* Increment the open object count if the mount point group has an open ID */ - if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) + if (H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) *nopen_objs += 1; H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); @@ -587,7 +588,6 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob FUNC_LEAVE_NOAPI_VOID } /* end H5F__mount_count_ids_recurse() */ - /*------------------------------------------------------------------------- * Function: H5F__mount_count_ids * @@ -611,7 +611,7 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) HDassert(nopen_objs); /* Find the top file in the mounting hierarchy */ - while(f->parent) + while (f->parent) f = f->parent; /* Count open IDs in the hierarchy */ @@ -620,9 +620,8 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__mount_count_ids() */ - /*------------------------------------------------------------------------- - * Function: H5F_flush_mounts_recurse + * Function: H5F__flush_mounts_recurse * * Purpose: Flush a mount hierarchy, recursively * @@ -634,35 +633,34 @@ H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) *------------------------------------------------------------------------- */ static herr_t -H5F_flush_mounts_recurse(H5F_t *f) +H5F__flush_mounts_recurse(H5F_t *f) { - unsigned nerrors = 0; /* Errors from recursive flushes */ - unsigned u; /* Index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nerrors = 0; /* Errors from recursive flushes */ + unsigned u; /* Index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); /* Flush all child files, not stopping for errors */ - for(u = 0; u < f->shared->mtab.nmounts; u++) - if(H5F_flush_mounts_recurse(f->shared->mtab.child[u].file) < 0) + for (u = 0; u < f->shared->mtab.nmounts; u++) + if (H5F__flush_mounts_recurse(f->shared->mtab.child[u].file) < 0) nerrors++; /* Call the "real" flush routine, for this file */ - if(H5F__flush(f) < 0) + if (H5F__flush(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Check flush errors for children - errors are already on the stack */ - if(nerrors) + if (nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's child mounts") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_flush_mounts_recurse() */ +} /* end H5F__flush_mounts_recurse() */ - /*------------------------------------------------------------------------- * Function: H5F_flush_mounts * @@ -678,7 +676,7 @@ H5F_flush_mounts_recurse(H5F_t *f) herr_t H5F_flush_mounts(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -686,18 +684,17 @@ H5F_flush_mounts(H5F_t *f) HDassert(f); /* Find the top file in the mount hierarchy */ - while(f->parent) + while (f->parent) f = f->parent; /* Flush the mounted file hierarchy */ - if(H5F_flush_mounts_recurse(f) < 0) + if (H5F__flush_mounts_recurse(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush_mounts() */ - /*------------------------------------------------------------------------- * Function: H5F_traverse_mount * @@ -712,14 +709,14 @@ H5F_flush_mounts(H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) +H5F_traverse_mount(H5O_loc_t *oloc /*in,out*/) { - H5F_t *parent = oloc->file, /* File of object */ - *child = NULL; /* Child file */ - unsigned lt, rt, md = 0; /* Binary search indices */ - int cmp; - H5O_loc_t *mnt_oloc = NULL; /* Object location for mount points */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *parent = oloc->file, /* File of object */ + *child = NULL; /* Child file */ + unsigned lt, rt, md = 0; /* Binary search indices */ + int cmp; + H5O_loc_t *mnt_oloc = NULL; /* Object location for mount points */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -735,21 +732,21 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) * Use a binary search to find the potential mount point in the mount * table for the parent */ - lt = 0; - rt = parent->shared->mtab.nmounts; + lt = 0; + rt = parent->shared->mtab.nmounts; cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; + while (lt < rt && cmp) { + md = (lt + rt) / 2; mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); - if(cmp < 0) + cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); + if (cmp < 0) rt = md; else lt = md + 1; } /* Copy root info over to ENT */ - if(0 == cmp) { + if (0 == cmp) { /* Get the child file */ child = parent->shared->mtab.child[md].file; @@ -757,11 +754,11 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) mnt_oloc = H5G_oloc(child->shared->root_grp); /* Release the mount point */ - if(H5O_loc_free(oloc) < 0) + if (H5O_loc_free(oloc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to free object location") /* Copy the entry for the root group */ - if(H5O_loc_copy_deep(oloc, mnt_oloc) < 0) + if (H5O_loc_copy_deep(oloc, mnt_oloc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy object location") /* In case the shared root group info points to a different file handle @@ -771,9 +768,8 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) /* Switch to child's file */ parent = child; } /* end if */ - } while(!cmp); + } while (!cmp); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_traverse_mount() */ - diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index fe85c899171..97bfefdcd0a 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,85 +26,48 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* 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 "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 */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifdef H5_HAVE_PARALLEL - -/*------------------------------------------------------------------------- - * Function: H5F_get_mpi_handle - * - * Purpose: Retrieves MPI File handle. - * - * Return: Success: The size (positive) - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle) -{ - herr_t ret_value = SUCCEED; - hid_t fapl_id = H5I_INVALID_HID; - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(f && f->shared); - - /* Dispatch to driver */ - if ((ret_value = H5FD_get_vfd_handle(f->shared->lf, fapl_id, (void **)f_handle)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get mpi file handle") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_get_mpi_handle() */ - - /*------------------------------------------------------------------------- * Function: H5F_mpi_get_rank * @@ -136,7 +99,6 @@ H5F_mpi_get_rank(const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_rank() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_get_comm * @@ -154,7 +116,7 @@ H5F_mpi_get_rank(const H5F_t *f) MPI_Comm H5F_mpi_get_comm(const H5F_t *f) { - MPI_Comm ret_value = MPI_COMM_NULL; + MPI_Comm ret_value = MPI_COMM_NULL; FUNC_ENTER_NOAPI(MPI_COMM_NULL) @@ -168,7 +130,37 @@ H5F_mpi_get_comm(const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_comm() */ - +/*------------------------------------------------------------------------- + * Function: H5F_shared_mpi_get_size + * + * Purpose: Retrieves the size of an MPI process. + * + * Return: Success: The size (positive) + * + * Failure: Negative + * + * Programmer: John Mainzer + * Friday, May 6, 2005 + * + *------------------------------------------------------------------------- + */ +int +H5F_shared_mpi_get_size(const H5F_shared_t *f_sh) +{ + int ret_value = -1; + + FUNC_ENTER_NOAPI((-1)) + + HDassert(f_sh); + + /* Dispatch to driver */ + if ((ret_value = H5FD_mpi_get_size(f_sh->lf)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "driver get_size request failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_shared_mpi_get_size() */ + /*------------------------------------------------------------------------- * Function: H5F_mpi_get_size * @@ -200,9 +192,8 @@ H5F_mpi_get_size(const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_get_size() */ - /*------------------------------------------------------------------------- - * Function: H5Fset_mpi_atomicity + * Function: H5F_set_mpi_atomicity * * Purpose: Private call to set the atomicity mode * @@ -211,31 +202,97 @@ H5F_mpi_get_size(const H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) +H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "ib", file_id, flag); + FUNC_ENTER_NOAPI(FAIL); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HDassert(file); /* Check VFD */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode") + if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect VFL driver, does not support MPI atomicity mode"); /* Set atomicity value */ if (H5FD_set_mpio_atomicity(file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag"); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_set_mpi_atomicity() */ + +/*------------------------------------------------------------------------- + * Function: H5Fset_mpi_atomicity + * + * Purpose: Sets the atomicity mode + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * Feb 14, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) +{ + H5VL_object_t *vol_obj = NULL; + int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL); + H5TRACE2("e", "ib", file_id, flag); + + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Set atomicity value */ + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, va_flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); + +done: + FUNC_LEAVE_API(ret_value); } /* end H5Fset_mpi_atomicity() */ - +/*------------------------------------------------------------------------- + * Function: H5F_get_mpi_atomicity + * + * Purpose: Private call to get the atomicity mode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + /* Check args */ + HDassert(file); + HDassert(flag); + + /* Check VFD */ + if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "incorrect VFL driver, does not support MPI atomicity mode"); + + /* Get atomicity value */ + if (H5FD_get_mpio_atomicity(file->shared->lf, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_get_mpi_atomicity() */ + /*------------------------------------------------------------------------- * Function: H5Fget_mpi_atomicity * @@ -252,29 +309,25 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", file_id, flag); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - - /* Check VFD */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode") + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); /* Get atomicity value */ - if (H5FD_get_mpio_atomicity(file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag") + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* end H5Fget_mpi_atomicity() */ - /*------------------------------------------------------------------------- * Function: H5F_mpi_retrieve_comm * @@ -294,7 +347,7 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -306,42 +359,36 @@ H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) /* if the loc_id is valid, then get the comm from the file attached to the loc_id */ - if(H5I_INVALID_HID != 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) + if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") f = loc.oloc->file; HDassert(f); /* Check if MPIO driver is used */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { /* retrieve the file communicator */ - if(MPI_COMM_NULL == (*mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (*mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") } } /* otherwise, this is from H5Fopen or H5Fcreate and has to be collective */ else { - H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ - if(NULL == (plist = H5P_object_verify(acspl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(acspl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_MPIO == H5P_peek_driver(plist)) { - const H5FD_mpio_fapl_t *fa; /* MPIO fapl info */ - - if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad VFL driver info") - - *mpi_comm = fa->comm; - } + if (H5FD_MPIO == H5P_peek_driver(plist)) + if (H5P_peek(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, mpi_comm) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_retrieve_comm */ #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index cc37d19dd2a..087c9c9ae9b 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,61 +23,59 @@ #error "Do not include this file outside the H5F package!" #endif -#ifndef _H5Fpkg_H -#define _H5Fpkg_H +#ifndef H5Fpkg_H +#define H5Fpkg_H /* Get package's private header */ #include "H5Fprivate.h" /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Bprivate.h" /* B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5PBprivate.h" /* Page buffer */ -#include "H5UCprivate.h" /* Reference counted object functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ +#include "H5UCprivate.h" /* Reference counted object functions */ /* * Feature: Define this constant on the compiler command-line if you want to * see some debugging messages on the debug stream. */ #ifdef NDEBUG -# undef H5F_DEBUG +#undef H5F_DEBUG #endif /* Superblock status flags */ -#define H5F_SUPER_WRITE_ACCESS 0x01 -#define H5F_SUPER_FILE_OK 0x02 -#define H5F_SUPER_SWMR_WRITE_ACCESS 0x04 -#define H5F_SUPER_ALL_FLAGS (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK | H5F_SUPER_SWMR_WRITE_ACCESS) +#define H5F_SUPER_WRITE_ACCESS 0x01 +#define H5F_SUPER_FILE_OK 0x02 +#define H5F_SUPER_SWMR_WRITE_ACCESS 0x04 +#define H5F_SUPER_ALL_FLAGS (H5F_SUPER_WRITE_ACCESS | H5F_SUPER_FILE_OK | H5F_SUPER_SWMR_WRITE_ACCESS) /* Mask for removing private file access flags */ -#define H5F_ACC_PUBLIC_FLAGS 0x007fu +#define H5F_ACC_PUBLIC_FLAGS 0x007fu /* Free space section+aggregator merge flags */ -#define H5F_FS_MERGE_METADATA 0x01 /* Section can merge with metadata aggregator */ -#define H5F_FS_MERGE_RAWDATA 0x02 /* Section can merge with small 'raw' data aggregator */ +#define H5F_FS_MERGE_METADATA 0x01 /* Section can merge with metadata aggregator */ +#define H5F_FS_MERGE_RAWDATA 0x02 /* Section can merge with small 'raw' data aggregator */ /* Macro to abstract checking whether file is using a free space manager */ -#define H5F_HAVE_FREE_SPACE_MANAGER(F) \ - ((F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || \ +#define H5F_HAVE_FREE_SPACE_MANAGER(F) \ + ((F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || \ (F)->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) /* Macros for encoding/decoding superblock */ -#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ -#define H5F_DRVINFOBLOCK_HDR_SIZE 16 /* Size of superblock driver info header */ +#define H5F_MAX_DRVINFOBLOCK_SIZE 1024 /* Maximum size of superblock driver info buffer */ +#define H5F_DRVINFOBLOCK_HDR_SIZE 16 /* Size of superblock driver info header */ /* Superblock sizes for various versions */ -#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ +#define H5F_SIZEOF_CHKSUM 4 /* Checksum size in the file */ /* Fixed-size portion at the beginning of all superblocks */ -#define H5F_SUPERBLOCK_FIXED_SIZE ( H5F_SIGNATURE_LEN \ - + 1) /* superblock version */ +#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 @@ -92,65 +90,67 @@ * of the super block. Note that the current value is one byte larger * than it needs to be. */ -#define H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE 7 +#define H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE 7 /* Macros for computing variable-size superblock size */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ - (2 /* freespace, and root group versions */ \ - + 1 /* reserved */ \ - + 3 /* shared header vers, size of address, size of lengths */ \ - + 1 /* reserved */ \ - + 4 /* group leaf k, group internal k */ \ - + 4) /* consistency flags */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) \ - ( H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ - + 2 /* indexed B-tree internal k */ \ - + 2 /* reserved */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* driver block address */ \ - + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ -#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) \ - ( 2 /* size of address, size of lengths */ \ - + 1 /* consistency flags */ \ - + (sizeof_addr) /* base address */ \ - + (sizeof_addr) /* superblock extension address */ \ - + (sizeof_addr) /* EOF address */ \ - + (sizeof_addr) /* root group object header address */ \ - + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ -#define H5F_SUPERBLOCK_VARLEN_SIZE(v, sizeof_addr, sizeof_size) ( \ - (v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) : 0) \ - + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) : 0) \ - + (v >= 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) : 0)) +#define H5F_SUPERBLOCK_VARLEN_SIZE_COMMON \ + (2 /* freespace, and root group versions */ \ + + 1 /* reserved */ \ + + 3 /* shared header vers, size of address, size of lengths */ \ + + 1 /* reserved */ \ + + 4 /* group leaf k, group internal k */ \ + + 4) /* consistency flags */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) \ + (H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) \ + (H5F_SUPERBLOCK_VARLEN_SIZE_COMMON /* Common variable-length info */ \ + + 2 /* indexed B-tree internal k */ \ + + 2 /* reserved */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* driver block address */ \ + + H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)) /* root group ptr */ +#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) \ + (2 /* size of address, size of lengths */ \ + + 1 /* consistency flags */ \ + + (sizeof_addr) /* base address */ \ + + (sizeof_addr) /* superblock extension address */ \ + + (sizeof_addr) /* EOF address */ \ + + (sizeof_addr) /* root group object header address */ \ + + H5F_SIZEOF_CHKSUM) /* superblock checksum (keep this last) */ +#define H5F_SUPERBLOCK_VARLEN_SIZE(v, sizeof_addr, sizeof_size) \ + ((v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(sizeof_addr, sizeof_size) : 0) + \ + (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(sizeof_addr, sizeof_size) : 0) + \ + (v >= 2 ? H5F_SUPERBLOCK_VARLEN_SIZE_V2(sizeof_addr) : 0)) /* Total size of superblock, depends on superblock version */ -#define H5F_SUPERBLOCK_SIZE(s) ( H5F_SUPERBLOCK_FIXED_SIZE \ - + H5F_SUPERBLOCK_VARLEN_SIZE((s)->super_vers, (s)->sizeof_addr, (s)->sizeof_size)) +#define H5F_SUPERBLOCK_SIZE(s) \ + (H5F_SUPERBLOCK_FIXED_SIZE + \ + H5F_SUPERBLOCK_VARLEN_SIZE((s)->super_vers, (s)->sizeof_addr, (s)->sizeof_size)) /* For superblock version 0 & 1: - Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) */ -#define H5F_SUPER_STATUS_OFF_V01 \ - (unsigned)(2 /* freespace, and root group versions */ \ - + 1 /* reserved */ \ - + 3 /* shared header vers, size of address, size of lengths */ \ - + 1 /* reserved */ \ - + 4) /* group leaf k, group internal k */ + Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) + */ +#define H5F_SUPER_STATUS_OFF_V01 \ + (unsigned)(2 /* freespace, and root group versions */ \ + + 1 /* reserved */ \ + + 3 /* shared header vers, size of address, size of lengths */ \ + + 1 /* reserved */ \ + + 4) /* group leaf k, group internal k */ -#define H5F_SUPER_STATUS_OFF(v) (v >= 2 ? (unsigned)2 : H5F_SUPER_STATUS_OFF_V01) +#define H5F_SUPER_STATUS_OFF(v) (v >= 2 ? (unsigned)2 : H5F_SUPER_STATUS_OFF_V01) /* Offset to the file consistency flags (status_flags) in the superblock */ #define H5F_SUPER_STATUS_FLAGS_OFF(v) (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPER_STATUS_OFF(v)) /* Size of file consistency flags (status_flags) in the superblock */ -#define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4) +#define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4) /* Forward declaration external file cache struct used below (defined in * H5Fefc.c) */ @@ -158,49 +158,49 @@ 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 */ - hbool_t ignore_drvrinfo; /* Indicate if the driver info should be ignored */ -/* OUT: */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + /* IN: */ + 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 */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ - haddr_t stored_eof; /* End-of-file in file */ - hbool_t drvrinfo_removed; /* Indicate if the driver info was removed */ - unsigned super_vers; /* Superblock version obtained in get_load_size callback. - * It will be used later in verify_chksum callback - */ + haddr_t stored_eof; /* End-of-file in file */ + hbool_t drvrinfo_removed; /* Indicate if the driver info was removed */ + unsigned super_vers; /* Superblock version obtained in get_load_size callback. + * It will be used later in verify_chksum callback + */ } 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 */ - haddr_t driver_addr; /* address of driver info block */ + H5F_t * f; /* Pointer to file */ + haddr_t driver_addr; /* address of driver info block */ } H5F_drvrinfo_cache_ud_t; /* Structure for metadata & "small [raw] data" block aggregation fields */ struct H5F_blk_aggr_t { - unsigned long feature_flag; /* Feature flag type */ - hsize_t alloc_size; /* Size for allocating new blocks */ - hsize_t tot_size; /* Total amount of bytes aggregated into block */ - hsize_t size; /* Current size of block left */ - haddr_t addr; /* Location of block left */ + unsigned long feature_flag; /* Feature flag type */ + hsize_t alloc_size; /* Size for allocating new blocks */ + hsize_t tot_size; /* Total amount of bytes aggregated into block */ + hsize_t size; /* Current size of block left */ + haddr_t addr; /* Location of block left */ }; /* Structure for metadata accumulator fields */ typedef struct H5F_meta_accum_t { - unsigned char *buf; /* Buffer to hold the accumulated metadata */ - haddr_t loc; /* File location (offset) of the accumulated metadata */ - size_t size; /* Size of the accumulated metadata buffer used (in bytes) */ - size_t alloc_size; /* Size of the accumulated metadata buffer allocated (in bytes) */ - size_t dirty_off; /* Offset of the dirty region in the accumulator buffer */ - size_t dirty_len; /* Length of the dirty region in the accumulator buffer */ - hbool_t dirty; /* Flag to indicate that the accumulated metadata is dirty */ + unsigned char *buf; /* Buffer to hold the accumulated metadata */ + haddr_t loc; /* File location (offset) of the accumulated metadata */ + size_t size; /* Size of the accumulated metadata buffer used (in bytes) */ + size_t alloc_size; /* Size of the accumulated metadata buffer allocated (in bytes) */ + size_t dirty_off; /* Offset of the dirty region in the accumulator buffer */ + size_t dirty_len; /* Length of the dirty region in the accumulator buffer */ + hbool_t dirty; /* Flag to indicate that the accumulated metadata is dirty */ } H5F_meta_accum_t; /* A record of the mount table */ typedef struct H5F_mount_t { - struct H5G_t *group; /* Mount point group held open */ - struct H5F_t *file; /* File mounted at that point */ + struct H5G_t *group; /* Mount point group held open */ + struct H5F_t *file; /* File mounted at that point */ } H5F_mount_t; /* @@ -208,28 +208,28 @@ typedef struct H5F_mount_t { * to which this table belongs. */ typedef struct H5F_mtab_t { - unsigned nmounts;/* Number of children which are mounted */ - unsigned nalloc; /* Number of mount slots allocated */ - H5F_mount_t *child; /* An array of mount records */ + unsigned nmounts; /* Number of children which are mounted */ + unsigned nalloc; /* Number of mount slots allocated */ + H5F_mount_t *child; /* An array of mount records */ } H5F_mtab_t; /* Structure specifically to store superblock. This was originally * maintained entirely within H5F_shared_t, but is now extracted * here because the superblock is now handled by the cache */ typedef struct H5F_super_t { - H5AC_info_t cache_info; /* Cache entry information structure */ - unsigned super_vers; /* Superblock version */ - uint8_t sizeof_addr; /* Size of addresses in file */ - uint8_t sizeof_size; /* Size of offsets in file */ - uint8_t status_flags; /* File status flags */ - unsigned sym_leaf_k; /* Size of leaves in symbol tables */ + H5AC_info_t cache_info; /* Cache entry information structure */ + unsigned super_vers; /* Superblock version */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ + uint8_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Size of leaves in symbol tables */ unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ - haddr_t base_addr; /* Absolute base address for rel.addrs. */ - /* (superblock for file is at this offset) */ - haddr_t ext_addr; /* Relative address of superblock extension */ - haddr_t driver_addr; /* File driver information block address */ - haddr_t root_addr; /* Root group address */ - H5G_entry_t *root_ent; /* Root group symbol table entry */ + haddr_t base_addr; /* Absolute base address for rel.addrs. */ + /* (superblock for file is at this offset) */ + haddr_t ext_addr; /* Relative address of superblock extension */ + haddr_t driver_addr; /* File driver information block address */ + haddr_t root_addr; /* Root group address */ + H5G_entry_t *root_ent; /* Root group symbol table entry */ } H5F_super_t; /* @@ -240,122 +240,129 @@ 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 */ - H5O_drvinfo_t *drvinfo; /* Pointer to the (pinned) driver info - * cache entry. This field is only defined - * for older versions of the super block, - * and then only when a driver information - * block is present. At all other times - * it should be NULL. - */ - hbool_t drvinfo_sb_msg_exists; /* Convenience field used to track - * whether the driver info superblock - * extension message has been created - * yet. This field should be TRUE iff the - * superblock extension exists and contains - * a driver info message. Under all other - * circumstances, it must be set to FALSE. - */ - unsigned nrefs; /* Ref count for times file is opened */ - unsigned flags; /* Access Permissions for file */ - H5F_mtab_t mtab; /* File mount table */ - H5F_efc_t *efc; /* External file cache */ + 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, + * and then only when a driver information + * block is present. At all other times + * it should be NULL. + */ + hbool_t drvinfo_sb_msg_exists; /* Convenience field used to track + * whether the driver info superblock + * extension message has been created + * yet. This field should be TRUE iff the + * superblock extension exists and contains + * a driver info message. Under all other + * circumstances, it must be set to FALSE. + */ + unsigned nrefs; /* Ref count for times file is opened */ + unsigned flags; /* Access Permissions for file */ + H5F_mtab_t mtab; /* File mount table */ + H5F_efc_t *efc; /* External file cache */ /* Cached values from FCPL/superblock */ - uint8_t sizeof_addr; /* Size of addresses in file */ - uint8_t sizeof_size; /* Size of offsets in file */ - haddr_t sohm_addr; /* Relative address of shared object header message table */ - unsigned sohm_vers; /* Version of shared message table on disk */ - unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ + uint8_t sizeof_addr; /* Size of addresses in file */ + uint8_t sizeof_size; /* Size of offsets in file */ + haddr_t sohm_addr; /* Relative address of shared object header message table */ + unsigned sohm_vers; /* Version of shared message table on disk */ + unsigned sohm_nindexes; /* Number of shared messages indexes in the table */ 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 */ - H5AC_cache_config_t - mdc_initCacheCfg; /* initial configuration for the */ - /* metadata cache. This structure is */ - /* fixed at creation time and should */ - /* not change thereafter. */ - H5AC_cache_image_config_t - mdc_initCacheImageCfg; /* initial configuration for the */ - /* generate metadata cache image on */ - /* close option. This structure is */ - /* fixed at creation time and should */ - /* not change thereafter. */ - 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 */ - 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 */ - size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ - size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ - double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ - size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ - hsize_t threshold; /* Threshold for alignment */ - hsize_t alignment; /* Alignment */ - unsigned gc_ref; /* Garbage-collect references? */ - H5F_libver_t low_bound; /* The 'low' bound of library format versions */ - H5F_libver_t high_bound; /* The 'high' bound of library format versions */ - 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 */ - hbool_t use_file_locking; /* Whether or not to use file locking */ + haddr_t maxaddr; /* Maximum address for file */ + + 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 */ + /* not change thereafter. */ + H5AC_cache_image_config_t mdc_initCacheImageCfg; /* initial configuration for the */ + /* generate metadata cache image on */ + /* close option. This structure is */ + /* fixed at creation time and should */ + /* not change thereafter. */ + 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 */ + 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 */ + size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ + size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ + double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ + size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ + hsize_t threshold; /* Threshold for alignment */ + hsize_t alignment; /* Alignment */ + unsigned gc_ref; /* Garbage-collect references? */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + 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 */ + 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 */ /* File space allocation information */ - H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ - hsize_t fs_threshold; /* Free space section threshold */ - hbool_t fs_persist; /* Free-space persist or not */ - unsigned fs_version; /* Free-space version: */ - /* It is used to update fsinfo message in the superblock - extension when closing down the free-space managers */ - hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ - haddr_t tmp_addr; /* Next address to use for temp. space in the file */ - hbool_t point_of_no_return; /* Flag to indicate that we can't go back and delete a freespace header when it's used up */ - - 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 */ - hbool_t first_alloc_dealloc; /* TRUE iff free space managers */ - /* are persistent and have not */ - /* been used accessed for either */ - /* allocation or deallocation */ - /* since file open. */ - haddr_t eoa_pre_fsm_fsalloc; /* eoa pre file space allocation */ - /* for self referential FSMs */ - haddr_t eoa_post_fsm_fsalloc; /* eoa post file space allocation */ - /* for self referential FSMs */ - haddr_t eoa_post_mdci_fsalloc; /* eoa past file space allocation */ - /* for metadata cache image, or */ - /* HADDR_UNDEF if no cache image. */ + H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ + hsize_t fs_threshold; /* Free space section threshold */ + hbool_t fs_persist; /* Free-space persist or not */ + unsigned fs_version; /* Free-space version: */ + /* It is used to update fsinfo message in the superblock + extension when closing down the free-space managers */ + hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ + haddr_t tmp_addr; /* Next address to use for temp. space in the file */ + hbool_t point_of_no_return; /* Flag to indicate that we can't go back and delete a freespace header when + it's used up */ + + 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 */ + 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 */ + /* for self referential FSMs */ + haddr_t eoa_post_mdci_fsalloc; /* eoa past file space allocation */ + /* for metadata cache image, or */ + /* HADDR_UNDEF if no cache image. */ /* Free-space aggregation info */ - unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ - H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ - H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info (if aggregating metadata allocations) */ - H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info (if aggregating "small data" allocations) */ + unsigned fs_aggr_merge[H5FD_MEM_NTYPES]; /* Flags for whether free space can merge with aggregator(s) */ + H5FD_mem_t fs_type_map[H5FD_MEM_NTYPES]; /* Mapping of "real" file space type into tracked type */ + H5F_blk_aggr_t meta_aggr; /* Metadata aggregation info (if aggregating metadata allocations) */ + H5F_blk_aggr_t sdata_aggr; /* "Small data" aggregation info (if aggregating "small data" allocations) */ /* Paged aggregation info */ - hsize_t fs_page_size; /* File space page size */ - size_t pgend_meta_thres; /* Do not track page end meta section <= this threshold */ + hsize_t fs_page_size; /* File space page size */ + size_t pgend_meta_thres; /* Do not track page end meta section <= this threshold */ /* Metadata accumulator information */ - H5F_meta_accum_t accum; /* Metadata accumulator info */ + H5F_meta_accum_t accum; /* Metadata accumulator info */ /* 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 */ + 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 */ /* Object flush info */ - H5F_object_flush_t object_flush; /* Information for object flush callback */ - hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ + H5F_object_flush_t object_flush; /* Information for object flush callback */ + hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ + + char *extpath; /* Path for searching target external link file */ + +#ifdef H5_HAVE_PARALLEL + H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ + hbool_t coll_md_write; /* Do all metadata writes collectively */ +#endif /* H5_HAVE_PARALLEL */ }; /* @@ -364,20 +371,16 @@ 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. */ - char *extpath; /* Path for searching target external link file */ - H5F_shared_t *shared; /* The shared file info */ - unsigned nopen_objs; /* Number of open object headers */ - H5FO_t *obj_count; /* # of time each object is opened through top file structure */ - hid_t file_id; /* ID of this file */ - hbool_t closing; /* File is in the process of being closed */ - struct H5F_t *parent; /* Parent file that this file is mounted to */ - unsigned nmounts; /* Number of children mounted to this file */ -#ifdef H5_HAVE_PARALLEL - H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ - hbool_t coll_md_write; /* Do all metadata writes collectively */ -#endif /* H5_HAVE_PARALLEL */ + 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 */ + 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 */ + unsigned nmounts; /* Number of children mounted to this file */ }; /*****************************/ @@ -400,19 +403,18 @@ H5_DLLVAR htri_t use_locks_env_g; /******************************/ /* General routines */ -H5_DLL H5F_t *H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); -H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); -H5_DLL herr_t H5F__flush(H5F_t *f); -H5_DLL htri_t H5F__is_hdf5(const char *name); +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); -H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL herr_t H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info); -H5_DLL herr_t H5F__format_convert(H5F_t *f); -H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); -H5_DLL herr_t H5F__close(hid_t file_id); -H5_DLL herr_t H5F__close_cb(H5F_t *f); -H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); -H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); +H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); +H5_DLL herr_t H5F__format_convert(H5F_t *f); +H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); +H5_DLL herr_t H5F__close(H5F_t *f); +H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); +H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); +H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); /* File mount related routines */ H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); @@ -428,13 +430,15 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags); +H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, + unsigned mesg_flags); H5_DLL herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id); H5_DLL herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created); /* Metadata accumulator routines */ H5_DLL herr_t H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + const void *buf); H5_DLL herr_t H5F__accum_free(H5F_shared_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); 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); @@ -442,20 +446,20 @@ 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 H5F_shared_t *H5F__sfile_search(H5FD_t *lf); -H5_DLL herr_t H5F__sfile_remove(H5F_shared_t *shared); +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); -H5_DLL herr_t H5F__efc_try_close(H5F_t *f); +H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); +H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); +H5_DLL herr_t H5F__efc_try_close(H5F_t *f); /* Space allocation routines */ H5_DLL haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); -H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); +H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); +H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); @@ -472,8 +476,8 @@ H5_DLL herr_t H5F__get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t H5_DLL herr_t H5F__check_cached_stab_test(hid_t file_id); H5_DLL herr_t H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); H5_DLL herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); +H5_DLL htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2); H5_DLL herr_t H5F__reparse_file_lock_variable_test(void); #endif /* H5F_TESTING */ -#endif /* _H5Fpkg_H */ - +#endif /* H5Fpkg_H */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index cb6e6fed479..5c5937b038a 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ * This file contains macros & information for file access */ -#ifndef _H5Fprivate_H -#define _H5Fprivate_H +#ifndef H5Fprivate_H +#define H5Fprivate_H /* Early typedefs to avoid circular dependencies */ typedef struct H5F_t H5F_t; @@ -25,15 +25,15 @@ typedef struct H5F_t H5F_t; #include "H5Fpublic.h" /* Public headers needed by this file */ -#include "H5FDpublic.h" /* File drivers */ +#include "H5FDpublic.h" /* File drivers */ /* Private headers needed by this file */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL -#include "H5Pprivate.h" /* Property lists */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5Pprivate.h" /* Property lists */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ @@ -44,102 +44,124 @@ typedef struct H5F_t H5F_t; * Currently, all file meta-data is little-endian. */ -# define INT16ENCODE(p, i) { \ - *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ -} - -# define UINT16ENCODE(p, i) { \ - *(p) = (uint8_t)( (unsigned)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); (p)++; \ -} - -# define INT32ENCODE(p, i) { \ - *(p) = (uint8_t)( (uint32_t)(i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); (p)++; \ -} - -# define UINT32ENCODE(p, i) { \ - *(p) = (uint8_t)( (i) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 8) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 16) & 0xff); (p)++; \ - *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ -} +#define INT16ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } + +#define UINT16ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } + +#define INT32ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((uint32_t)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); \ + (p)++; \ + } + +#define UINT32ENCODE(p, i) \ + { \ + *(p) = (uint8_t)((i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 24) & 0xff); \ + (p)++; \ + } /* Encode an unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define ENCODE_VAR(p, typ, n, l) { \ - typ _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for(_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t*)(p) + l; \ -} +#define ENCODE_VAR(p, typ, n, l) \ + { \ + typ _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < l; _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + l; \ + } /* Encode a 32-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) - -# define INT64ENCODE(p, n) { \ - int64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ - (p) = (uint8_t*)(p)+8; \ -} - -# define UINT64ENCODE(p, n) { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = 0; \ - (p) = (uint8_t*)(p) + 8; \ -} +#define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + +#define INT64ENCODE(p, n) \ + { \ + int64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ + (p) = (uint8_t *)(p) + 8; \ + } + +#define UINT64ENCODE(p, n) \ + { \ + uint64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = 0; \ + (p) = (uint8_t *)(p) + 8; \ + } /* Encode a 64-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) +#define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) /* Encode a 64-bit unsigned integer and its length into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VARLEN(p, n) { \ - uint64_t __n = (uint64_t)(n); \ - unsigned _s = H5VM_limit_enc_size(__n); \ - \ - *(p)++ = (uint8_t)_s; \ - UINT64ENCODE_VAR(p, __n, _s); \ -} - -# define H5_ENCODE_UNSIGNED(p, n) { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32ENCODE(p, n) \ -} +#define UINT64ENCODE_VARLEN(p, n) \ + { \ + uint64_t __n = (uint64_t)(n); \ + unsigned _s = H5VM_limit_enc_size(__n); \ + \ + *(p)++ = (uint8_t)_s; \ + UINT64ENCODE_VAR(p, __n, _s); \ + } + +#define H5_ENCODE_UNSIGNED(p, n) \ + { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32ENCODE(p, n) \ + } /* Assumes the endianness of uint64_t is the same as double */ -# define H5_ENCODE_DOUBLE(p, n) { \ - uint64_t _n; \ - size_t _u; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - H5MM_memcpy(&_n, &n, sizeof(double)); \ - for(_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t *)(p) + 8; \ -} +#define H5_ENCODE_DOUBLE(p, n) \ + { \ + uint64_t _n; \ + size_t _u; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + H5MM_memcpy(&_n, &n, sizeof(double)); \ + for (_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + 8; \ + } /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting @@ -149,381 +171,457 @@ typedef struct H5F_t H5F_t; * correctly even if i is actually a 64bit int like in a Cray. */ -# define INT16DECODE(p, i) { \ - (i) = (int16_t)((*(p) & 0xff)); (p)++; \ - (i) |= (int16_t)(((*(p) & 0xff) << 8) | \ - ((*(p) & 0x80) ? ~0xffff : 0x0)); (p)++; \ -} - -# define UINT16DECODE(p, i) { \ - (i) = (uint16_t) (*(p) & 0xff); (p)++; \ - (i) |= (uint16_t)((*(p) & 0xff) << 8); (p)++; \ -} - -# define INT32DECODE(p, i) { \ - (i) = ((int32_t)(*(p) & (unsigned)0xff)); (p)++; \ - (i) |= ((int32_t)(*(p) & (unsigned)0xff) << 8); (p)++; \ - (i) |= ((int32_t)(*(p) & (unsigned)0xff) << 16); (p)++; \ - (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | \ - ((*(p) & (unsigned)0x80) ? (unsigned)(~0xffffffff) : (unsigned)0x0))); (p)++; \ -} - -# define UINT32DECODE(p, i) { \ - (i) = (uint32_t)(*(p) & 0xff); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 8); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 16); (p)++; \ - (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ -} +#define INT16DECODE(p, i) \ + { \ + (i) = (int16_t)((*(p)&0xff)); \ + (p)++; \ + (i) |= (int16_t)(((*(p)&0xff) << 8) | ((*(p)&0x80) ? ~0xffff : 0x0)); \ + (p)++; \ + } + +#define UINT16DECODE(p, i) \ + { \ + (i) = (uint16_t)(*(p)&0xff); \ + (p)++; \ + (i) |= (uint16_t)((*(p)&0xff) << 8); \ + (p)++; \ + } + +#define INT32DECODE(p, i) \ + { \ + (i) = ((int32_t)(*(p)&0xff)); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | ((*(p)&0x80) ? ~0xffffffffULL : 0x0ULL))); \ + (p)++; \ + } + +#define UINT32DECODE(p, i) \ + { \ + (i) = (uint32_t)(*(p)&0xff); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 24); \ + (p)++; \ + } /* Decode a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -# define DECODE_VAR(p, n, l) { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ -} +#define DECODE_VAR(p, n, l) \ + { \ + size_t _i; \ + \ + n = 0; \ + (p) += l; \ + for (_i = 0; _i < l; _i++) \ + n = (n << 8) | *(--p); \ + (p) += l; \ + } /* Decode a variable-sized buffer into a 32-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) - -# define INT64DECODE(p, n) { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(int64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ -} - -# define UINT64DECODE(p, n) { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(uint64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ -} +#define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + +#define INT64DECODE(p, n) \ + { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(int64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } + +#define UINT64DECODE(p, n) \ + { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(uint64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } /* Decode a variable-sized buffer into a 64-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) +#define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) /* Decode a 64-bit unsigned integer and its length from a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -# define UINT64DECODE_VARLEN(p, n) { \ - unsigned _s = *(p)++; \ - \ - UINT64DECODE_VAR(p, n, _s); \ -} - -# define H5_DECODE_UNSIGNED(p, n) { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32DECODE(p, n) \ -} +#define UINT64DECODE_VARLEN(p, n) \ + { \ + unsigned _s = *(p)++; \ + \ + UINT64DECODE_VAR(p, n, _s); \ + } + +#define H5_DECODE_UNSIGNED(p, n) \ + { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32DECODE(p, n) \ + } /* Assumes the endianness of uint64_t is the same as double */ -# define H5_DECODE_DOUBLE(p, n) { \ - uint64_t _n; \ - size_t _u; \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - _n = 0; \ - (p) += 8; \ - for(_u = 0; _u < sizeof(uint64_t); _u++) \ - _n = (_n << 8) | *(--p); \ - H5MM_memcpy(&(n), &_n, sizeof(double)); \ - (p) += 8; \ -} - +#define H5_DECODE_DOUBLE(p, n) \ + { \ + uint64_t _n; \ + size_t _u; \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + _n = 0; \ + (p) += 8; \ + for (_u = 0; _u < sizeof(uint64_t); _u++) \ + _n = (_n << 8) | *(--p); \ + H5MM_memcpy(&(n), &_n, sizeof(double)); \ + (p) += 8; \ + } + +/* clang-format off */ /* Address-related macros */ -#define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ - HADDR_UNDEF==(X)+(haddr_t)(Z) || \ +#define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ + HADDR_UNDEF==(X)+(haddr_t)(Z) || \ (X)+(haddr_t)(Z)<(X)) #define H5F_addr_defined(X) ((X)!=HADDR_UNDEF) /* The H5F_addr_eq() macro guarantees that Y is not HADDR_UNDEF by making * certain that X is not HADDR_UNDEF and then checking that X equals Y */ -#define H5F_addr_eq(X,Y) ((X)!=HADDR_UNDEF && \ +#define H5F_addr_eq(X,Y) ((X)!=HADDR_UNDEF && \ (X)==(Y)) #define H5F_addr_ne(X,Y) (!H5F_addr_eq((X),(Y))) -#define H5F_addr_lt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_lt(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)<(Y)) -#define H5F_addr_le(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_le(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)<=(Y)) -#define H5F_addr_gt(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_gt(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)>(Y)) -#define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ - (Y)!=HADDR_UNDEF && \ +#define H5F_addr_ge(X,Y) ((X)!=HADDR_UNDEF && \ + (Y)!=HADDR_UNDEF && \ (X)>=(Y)) -#define H5F_addr_cmp(X,Y) (H5F_addr_eq((X), (Y)) ? 0 : \ +#define H5F_addr_cmp(X,Y) (H5F_addr_eq((X), (Y)) ? 0 : \ (H5F_addr_lt((X), (Y)) ? -1 : 1)) #define H5F_addr_pow2(N) ((haddr_t)1<<(N)) #define H5F_addr_overlap(O1,L1,O2,L2) (((O1) < (O2) && ((O1) + (L1)) > (O2)) || \ ((O1) >= (O2) && (O1) < ((O2) + (L2)))) +/* clang-format on */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_MODULE -#define H5F_LOW_BOUND(F) ((F)->shared->low_bound) -#define H5F_HIGH_BOUND(F) ((F)->shared->high_bound) -#define H5F_SHARED_INTENT(F_SH) ((F_SH)->flags) -#define H5F_INTENT(F) ((F)->shared->flags) -#define H5F_OPEN_NAME(F) ((F)->open_name) -#define H5F_ACTUAL_NAME(F) ((F)->actual_name) -#define H5F_EXTPATH(F) ((F)->extpath) -#define H5F_SHARED(F) ((F)->shared) -#define H5F_SAME_SHARED(F1, F2) ((F1)->shared == (F2)->shared) -#define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) -#define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) -#define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) -#define H5F_FILE_ID(F) ((F)->file_id) -#define H5F_PARENT(F) ((F)->parent) -#define H5F_NMOUNTS(F) ((F)->nmounts) -#define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts) -#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id) -#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno) -#define H5F_SHARED_HAS_FEATURE(F_SH,FL) ((F_SH)->lf->feature_flags & (FL)) -#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL)) -#define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) -#define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) -#define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) -#define H5F_NREFS(F) ((F)->shared->nrefs) -#define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) -#define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) -#define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) -#define H5F_SET_SOHM_ADDR(F, A) ((F)->shared->sohm_addr = (A)) -#define H5F_SOHM_VERS(F) ((F)->shared->sohm_vers) -#define H5F_SET_SOHM_VERS(F, V) ((F)->shared->sohm_vers = (V)) -#define H5F_SOHM_NINDEXES(F) ((F)->shared->sohm_nindexes) -#define H5F_SET_SOHM_NINDEXES(F, N) ((F)->shared->sohm_nindexes = (N)) -#define H5F_FCPL(F) ((F)->shared->fcpl_id) -#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) -#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close) -#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) -#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) -#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) -#define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) -#define H5F_GC_REF(F) ((F)->shared->gc_ref) -#define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) -#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL)) -#define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) -#define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) -#define H5F_USE_TMP_SPACE(F) ((F)->shared->fs.use_tmp_space) -#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR))) +#define H5F_LOW_BOUND(F) ((F)->shared->low_bound) +#define H5F_HIGH_BOUND(F) ((F)->shared->high_bound) +#define H5F_SHARED_INTENT(F_SH) ((F_SH)->flags) +#define H5F_INTENT(F) ((F)->shared->flags) +#define H5F_OPEN_NAME(F) ((F)->open_name) +#define H5F_ACTUAL_NAME(F) ((F)->actual_name) +#define H5F_EXTPATH(F) ((F)->shared->extpath) +#define H5F_SHARED(F) ((F)->shared) +#define H5F_SAME_SHARED(F1, F2) ((F1)->shared == (F2)->shared) +#define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) +#define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) +#define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) +#define H5F_ID_EXISTS(F) ((F)->id_exists) +#define H5F_PARENT(F) ((F)->parent) +#define H5F_NMOUNTS(F) ((F)->nmounts) +#define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts) +#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id) +#define H5F_GET_FILENO(F, FILENUM) ((FILENUM) = (F)->shared->lf->fileno) +#define H5F_SHARED_HAS_FEATURE(F_SH, FL) ((F_SH)->lf->feature_flags & (FL)) +#define H5F_HAS_FEATURE(F, FL) ((F)->shared->lf->feature_flags & (FL)) +#define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) +#define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) +#define H5F_KVALUE(F, T) ((F)->shared->sblock->btree_k[(T)->id]) +#define H5F_NREFS(F) ((F)->shared->nrefs) +#define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) +#define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) +#define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) +#define H5F_SET_SOHM_ADDR(F, A) ((F)->shared->sohm_addr = (A)) +#define H5F_SOHM_VERS(F) ((F)->shared->sohm_vers) +#define H5F_SET_SOHM_VERS(F, V) ((F)->shared->sohm_vers = (V)) +#define H5F_SOHM_NINDEXES(F) ((F)->shared->sohm_nindexes) +#define H5F_SET_SOHM_NINDEXES(F, N) ((F)->shared->sohm_nindexes = (N)) +#define H5F_FCPL(F) ((F)->shared->fcpl_id) +#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree) +#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close) +#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) +#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) +#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) +#define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size) +#define H5F_GC_REF(F) ((F)->shared->gc_ref) +#define H5F_STORE_MSG_CRT_IDX(F) ((F)->shared->store_msg_crt_idx) +#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL)) +#define H5F_GRP_BTREE_SHARED(F) ((F)->shared->grp_btree_shared) +#define H5F_SET_GRP_BTREE_SHARED(F, RC) (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL) +#define H5F_USE_TMP_SPACE(F) ((F)->shared->fs.use_tmp_space) +#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR))) #ifdef H5_HAVE_PARALLEL -#define H5F_COLL_MD_READ(F) ((F)->coll_md_read) +#define H5F_COLL_MD_READ(F) ((F)->shared->coll_md_read) #endif /* H5_HAVE_PARALLEL */ -#define H5F_USE_MDC_LOGGING(F) ((F)->shared->use_mdc_logging) -#define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access) -#define H5F_MDC_LOG_LOCATION(F) ((F)->shared->mdc_log_location) -#define H5F_ALIGNMENT(F) ((F)->shared->alignment) -#define H5F_THRESHOLD(F) ((F)->shared->threshold) -#define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) -#define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) -#define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) -#define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) -#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) -#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) -#define H5F_USE_FILE_LOCKING(F) ((F)->shared->use_file_locking) +#define H5F_USE_MDC_LOGGING(F) ((F)->shared->use_mdc_logging) +#define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access) +#define H5F_MDC_LOG_LOCATION(F) ((F)->shared->mdc_log_location) +#define H5F_ALIGNMENT(F) ((F)->shared->alignment) +#define H5F_THRESHOLD(F) ((F)->shared->threshold) +#define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) +#define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) +#define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) +#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) +#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) +#define H5F_VOL_CLS(F) ((F)->shared->vol_cls) +#define H5F_VOL_OBJ(F) ((F)->vol_obj) +#define H5F_USE_FILE_LOCKING(F) ((F)->shared->use_file_locking) #else /* H5F_MODULE */ -#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) -#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) -#define H5F_SHARED_INTENT(F_SH) (H5F_shared_get_intent(F_SH)) -#define H5F_INTENT(F) (H5F_get_intent(F)) -#define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) -#define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) -#define H5F_EXTPATH(F) (H5F_get_extpath(F)) -#define H5F_SHARED(F) (H5F_get_shared(F)) -#define H5F_SAME_SHARED(F1, F2) (H5F_same_shared((F1), (F2))) -#define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) -#define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) -#define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) -#define H5F_FILE_ID(F) (H5F_get_file_id(F)) -#define H5F_PARENT(F) (H5F_get_parent(F)) -#define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) -#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F)) -#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F)) -#define H5F_GET_FILENO(F,FILENUM) (H5F_get_fileno((F), &(FILENUM))) -#define H5F_SHARED_HAS_FEATURE(F_SH,FL) (H5F_shared_has_feature(F_SH,FL)) -#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL)) -#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) -#define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) -#define H5F_KVALUE(F,T) (H5F_Kvalue(F,T)) -#define H5F_NREFS(F) (H5F_get_nrefs(F)) -#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) -#define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) -#define H5F_SOHM_ADDR(F) (H5F_get_sohm_addr(F)) -#define H5F_SET_SOHM_ADDR(F, A) (H5F_set_sohm_addr((F), (A))) -#define H5F_SOHM_VERS(F) (H5F_get_sohm_vers(F)) -#define H5F_SET_SOHM_VERS(F, V) (H5F_set_sohm_vers((F), (V))) -#define H5F_SOHM_NINDEXES(F) (H5F_get_sohm_nindexes(F)) -#define H5F_SET_SOHM_NINDEXES(F, N) (H5F_set_sohm_nindexes((F), (N))) -#define H5F_FCPL(F) (H5F_get_fcpl(F)) -#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) -#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F)) -#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F)) -#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) -#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) -#define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) -#define H5F_GC_REF(F) (H5F_gc_ref(F)) -#define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) -#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) (H5F_set_store_msg_crt_idx((F), (FL))) -#define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) -#define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) -#define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) -#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) +#define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) +#define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) +#define H5F_SHARED_INTENT(F_SH) (H5F_shared_get_intent(F_SH)) +#define H5F_INTENT(F) (H5F_get_intent(F)) +#define H5F_OPEN_NAME(F) (H5F_get_open_name(F)) +#define H5F_ACTUAL_NAME(F) (H5F_get_actual_name(F)) +#define H5F_EXTPATH(F) (H5F_get_extpath(F)) +#define H5F_SHARED(F) (H5F_get_shared(F)) +#define H5F_SAME_SHARED(F1, F2) (H5F_same_shared((F1), (F2))) +#define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) +#define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) +#define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) +#define H5F_ID_EXISTS(F) (H5F_file_id_exists(F)) +#define H5F_PARENT(F) (H5F_get_parent(F)) +#define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) +#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F)) +#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F)) +#define H5F_GET_FILENO(F, FILENUM) (H5F_get_fileno((F), &(FILENUM))) +#define H5F_SHARED_HAS_FEATURE(F_SH, FL) (H5F_shared_has_feature(F_SH, FL)) +#define H5F_HAS_FEATURE(F, FL) (H5F_has_feature(F, FL)) +#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) +#define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) +#define H5F_KVALUE(F, T) (H5F_Kvalue(F, T)) +#define H5F_NREFS(F) (H5F_get_nrefs(F)) +#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) +#define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) +#define H5F_SOHM_ADDR(F) (H5F_get_sohm_addr(F)) +#define H5F_SET_SOHM_ADDR(F, A) (H5F_set_sohm_addr((F), (A))) +#define H5F_SOHM_VERS(F) (H5F_get_sohm_vers(F)) +#define H5F_SET_SOHM_VERS(F, V) (H5F_set_sohm_vers((F), (V))) +#define H5F_SOHM_NINDEXES(F) (H5F_get_sohm_nindexes(F)) +#define H5F_SET_SOHM_NINDEXES(F, N) (H5F_set_sohm_nindexes((F), (N))) +#define H5F_FCPL(F) (H5F_get_fcpl(F)) +#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F)) +#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F)) +#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F)) +#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) +#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) +#define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F)) +#define H5F_GC_REF(F) (H5F_gc_ref(F)) +#define H5F_STORE_MSG_CRT_IDX(F) (H5F_store_msg_crt_idx(F)) +#define H5F_SET_STORE_MSG_CRT_IDX(F, FL) (H5F_set_store_msg_crt_idx((F), (FL))) +#define H5F_GRP_BTREE_SHARED(F) (H5F_grp_btree_shared(F)) +#define H5F_SET_GRP_BTREE_SHARED(F, RC) (H5F_set_grp_btree_shared((F), (RC))) +#define H5F_USE_TMP_SPACE(F) (H5F_use_tmp_space(F)) +#define H5F_IS_TMP_ADDR(F, ADDR) (H5F_is_tmp_addr((F), (ADDR))) #ifdef H5_HAVE_PARALLEL -#define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F)) +#define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F)) #endif /* H5_HAVE_PARALLEL */ -#define H5F_USE_MDC_LOGGING(F) (H5F_use_mdc_logging(F)) -#define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F)) -#define H5F_MDC_LOG_LOCATION(F) (H5F_mdc_log_location(F)) -#define H5F_ALIGNMENT(F) (H5F_get_alignment(F)) -#define H5F_THRESHOLD(F) (H5F_get_threshold(F)) -#define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) -#define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) -#define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) -#define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) -#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) -#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) -#define H5F_USE_FILE_LOCKING(F) (H5F_get_use_file_locking(F)) +#define H5F_USE_MDC_LOGGING(F) (H5F_use_mdc_logging(F)) +#define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F)) +#define H5F_MDC_LOG_LOCATION(F) (H5F_mdc_log_location(F)) +#define H5F_ALIGNMENT(F) (H5F_get_alignment(F)) +#define H5F_THRESHOLD(F) (H5F_get_threshold(F)) +#define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) +#define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) +#define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) +#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) +#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) +#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F)) +#define H5F_VOL_OBJ(F) (H5F_get_vol_obj(F)) +#define H5F_USE_FILE_LOCKING(F) (H5F_get_use_file_locking(F)) #endif /* H5F_MODULE */ - /* Macros to encode/decode offset/length's for storing in the file */ -#define H5F_ENCODE_OFFSET(f,p,o) switch(H5F_SIZEOF_ADDR(f)) { \ - case 4: UINT32ENCODE(p,o); break; \ - case 8: UINT64ENCODE(p,o); break; \ - case 2: UINT16ENCODE(p,o); break; \ -} - -#define H5F_DECODE_OFFSET(f,p,o) switch (H5F_SIZEOF_ADDR (f)) { \ - case 4: UINT32DECODE(p, o); break; \ - case 8: UINT64DECODE(p, o); break; \ - case 2: UINT16DECODE(p, o); break; \ -} - -#define H5F_ENCODE_LENGTH_LEN(p,l,s) switch(s) { \ - case 4: UINT32ENCODE(p,l); break; \ - case 8: UINT64ENCODE(p,l); break; \ - case 2: UINT16ENCODE(p,l); break; \ - default: HDassert("bad sizeof size" && 0); \ -} - -#define H5F_ENCODE_LENGTH(f,p,l) H5F_ENCODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) - -#define H5F_DECODE_LENGTH_LEN(p,l,s) switch(s) { \ - case 4: UINT32DECODE(p,l); break; \ - case 8: UINT64DECODE(p,l); break; \ - case 2: UINT16DECODE(p,l); break; \ - default: HDassert("bad sizeof size" && 0); \ -} - -#define H5F_DECODE_LENGTH(f,p,l) H5F_DECODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) +#define H5F_ENCODE_OFFSET(f, p, o) \ + switch (H5F_SIZEOF_ADDR(f)) { \ + case 4: \ + UINT32ENCODE(p, o); \ + break; \ + case 8: \ + UINT64ENCODE(p, o); \ + break; \ + case 2: \ + UINT16ENCODE(p, o); \ + break; \ + } + +#define H5F_DECODE_OFFSET(f, p, o) \ + switch (H5F_SIZEOF_ADDR(f)) { \ + case 4: \ + UINT32DECODE(p, o); \ + break; \ + case 8: \ + UINT64DECODE(p, o); \ + break; \ + case 2: \ + UINT16DECODE(p, o); \ + break; \ + } + +#define H5F_ENCODE_LENGTH_LEN(p, l, s) \ + switch (s) { \ + case 4: \ + UINT32ENCODE(p, l); \ + break; \ + case 8: \ + UINT64ENCODE(p, l); \ + break; \ + case 2: \ + UINT16ENCODE(p, l); \ + break; \ + default: \ + HDassert("bad sizeof size" && 0); \ + } + +#define H5F_ENCODE_LENGTH(f, p, l) H5F_ENCODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f)) + +#define H5F_DECODE_LENGTH_LEN(p, l, s) \ + switch (s) { \ + case 4: \ + UINT32DECODE(p, l); \ + break; \ + case 8: \ + UINT64DECODE(p, l); \ + break; \ + case 2: \ + UINT16DECODE(p, l); \ + break; \ + default: \ + HDassert("bad sizeof size" && 0); \ + } + +#define H5F_DECODE_LENGTH(f, p, l) DECODE_VAR(p, l, H5F_SIZEOF_SIZE(f)) /* * Macros that check for overflows. These are somewhat dangerous to fiddle * with. */ #if (H5_SIZEOF_SIZE_T >= H5_SIZEOF_OFF_T) -# define H5F_OVERFLOW_SIZET2OFFT(X) \ - ((size_t)(X)>=(size_t)((size_t)1<<(8*sizeof(HDoff_t)-1))) +#define H5F_OVERFLOW_SIZET2OFFT(X) ((size_t)(X) >= (size_t)((size_t)1 << (8 * sizeof(HDoff_t) - 1))) #else -# define H5F_OVERFLOW_SIZET2OFFT(X) 0 +#define H5F_OVERFLOW_SIZET2OFFT(X) 0 #endif #if (H5_SIZEOF_HSIZE_T >= H5_SIZEOF_OFF_T) -# define H5F_OVERFLOW_HSIZET2OFFT(X) \ - ((hsize_t)(X) >= (hsize_t)((hsize_t)1 << (8 * sizeof(HDoff_t) - 1))) +#define H5F_OVERFLOW_HSIZET2OFFT(X) ((hsize_t)(X) >= (hsize_t)((hsize_t)1 << (8 * sizeof(HDoff_t) - 1))) #else -# define H5F_OVERFLOW_HSIZET2OFFT(X) 0 +#define H5F_OVERFLOW_HSIZET2OFFT(X) 0 #endif /* Sizes of object addresses & sizes in the file (in bytes) */ -#define H5F_OBJ_ADDR_SIZE sizeof(haddr_t) -#define H5F_OBJ_SIZE_SIZE sizeof(hsize_t) +#define H5F_OBJ_ADDR_SIZE sizeof(haddr_t) +#define H5F_OBJ_SIZE_SIZE sizeof(hsize_t) /* File-wide default character encoding can not yet be set via the file * creation property list and is always ASCII. */ #define H5F_DEFAULT_CSET H5T_CSET_ASCII /* ========= File Creation properties ============ */ -#define H5F_CRT_USER_BLOCK_NAME "block_size" /* Size of the file user block in bytes */ -#define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" /* 1/2 rank for symbol table leaf nodes */ -#define H5F_CRT_SYM_LEAF_DEF 4 -#define H5F_CRT_BTREE_RANK_NAME "btree_rank" /* 1/2 rank for btree internal nodes */ -#define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" /* Byte number in an address */ -#define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" /* Byte number for object size */ -#define H5F_CRT_SUPER_VERS_NAME "super_version" /* Version number of the superblock */ -#define H5F_CRT_SHMSG_NINDEXES_NAME "num_shmsg_indexes" /* Number of shared object header message indexes */ +#define H5F_CRT_USER_BLOCK_NAME "block_size" /* Size of the file user block in bytes */ +#define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" /* 1/2 rank for symbol table leaf nodes */ +#define H5F_CRT_SYM_LEAF_DEF 4 +#define H5F_CRT_BTREE_RANK_NAME "btree_rank" /* 1/2 rank for btree internal nodes */ +#define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" /* Byte number in an address */ +#define H5F_CRT_OBJ_BYTE_NUM_NAME "obj_byte_num" /* Byte number for object size */ +#define H5F_CRT_SUPER_VERS_NAME "super_version" /* Version number of the superblock */ +/* Number of shared object header message indexes */ +#define H5F_CRT_SHMSG_NINDEXES_NAME "num_shmsg_indexes" #define H5F_CRT_SHMSG_INDEX_TYPES_NAME "shmsg_message_types" /* Types of message in each index */ -#define H5F_CRT_SHMSG_INDEX_MINSIZE_NAME "shmsg_message_minsize" /* Minimum size of messages in each index */ -#define H5F_CRT_SHMSG_LIST_MAX_NAME "shmsg_list_max" /* Shared message list maximum size */ -#define H5F_CRT_SHMSG_BTREE_MIN_NAME "shmsg_btree_min" /* Shared message B-tree minimum size */ -#define H5F_CRT_FILE_SPACE_STRATEGY_NAME "file_space_strategy" /* File space handling strategy */ -#define H5F_CRT_FREE_SPACE_PERSIST_NAME "free_space_persist" /* Free-space persisting status */ -#define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */ -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */ - - +/* Minimum size of messages in each index */ +#define H5F_CRT_SHMSG_INDEX_MINSIZE_NAME "shmsg_message_minsize" +#define H5F_CRT_SHMSG_LIST_MAX_NAME "shmsg_list_max" /* Shared message list maximum size */ +#define H5F_CRT_SHMSG_BTREE_MIN_NAME "shmsg_btree_min" /* Shared message B-tree minimum size */ +#define H5F_CRT_FILE_SPACE_STRATEGY_NAME "file_space_strategy" /* File space handling strategy */ +#define H5F_CRT_FREE_SPACE_PERSIST_NAME "free_space_persist" /* Free-space persisting status */ +#define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */ +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */ /* ========= File Access properties ============ */ -#define H5F_ACS_META_CACHE_INIT_CONFIG_NAME "mdc_initCacheCfg" /* Initial metadata cache resize configuration */ -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ -#define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ -#define H5F_ACS_ALIGN_THRHD_NAME "threshold" /* Threshold for alignment */ -#define H5F_ACS_ALIGN_NAME "align" /* Alignment */ -#define H5F_ACS_META_BLOCK_SIZE_NAME "meta_block_size" /* Minimum metadata allocation block size (when aggregating metadata allocations) */ -#define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ -#define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ -#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ -#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ -#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ -#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ -#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ -#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single" /* Whether to convert family to a single-file driver. (private property only used by h5repart) */ -#define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ -#define H5F_ACS_LIBVER_LOW_BOUND_NAME "libver_low_bound" /* 'low' bound of library format versions */ -#define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */ -#define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ -#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ -#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ -#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ -#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */ -#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */ - /* Private property used only by h5clear */ -#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */ - /* Private property used only by h5clear */ -#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ -#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME "core_write_tracking_flag" /* Whether or not core VFD backing store write tracking is enabled */ -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME "core_write_tracking_page_size" /* The page size in kiB when core VFD write tracking is enabled */ -#define H5F_ACS_COLL_MD_WRITE_FLAG_NAME "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not */ -#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ -#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */ -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */ -#define H5F_ACS_USE_FILE_LOCKING_NAME "use_file_locking" /* whether or not we use file locks for SWMR control and to prevent multiple writers */ -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME "ignore_disabled_file_locks" /* whether or not we ignore "locks disabled" errors */ +#define H5F_ACS_META_CACHE_INIT_CONFIG_NAME \ + "mdc_initCacheCfg" /* Initial metadata cache resize configuration */ +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ +#define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ +#define H5F_ACS_ALIGN_THRHD_NAME "threshold" /* Threshold for alignment */ +#define H5F_ACS_ALIGN_NAME "align" /* Alignment */ +#define H5F_ACS_META_BLOCK_SIZE_NAME \ + "meta_block_size" /* Minimum metadata allocation block size (when aggregating metadata allocations) */ +#define H5F_ACS_SIEVE_BUF_SIZE_NAME \ + "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ +#define H5F_ACS_SDATA_BLOCK_SIZE_NAME \ + "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data \ + allocations) */ +#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ +#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ +#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ +#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ +#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ +#define H5F_ACS_FAMILY_NEWSIZE_NAME \ + "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ +#define H5F_ACS_FAMILY_TO_SINGLE_NAME \ + "family_to_single" /* Whether to convert family to a single-file driver. (private property only used by \ + h5repart) */ +#define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ +#define H5F_ACS_LIBVER_LOW_BOUND_NAME "libver_low_bound" /* 'low' bound of library format versions */ +#define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */ +#define H5F_ACS_WANT_POSIX_FD_NAME \ + "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address \ + */ +#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ +#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ +#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ +#define H5F_ACS_FILE_IMAGE_INFO_NAME \ + "file_image_info" /* struct containing initial file image and callback info */ +#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME \ + "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) \ + */ +#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */ +/* Private property used only by h5clear */ +#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */ +/* Private property used only by h5clear */ +#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ +#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME \ + "start_mdc_log_on_access" /* Whether logging starts on file create/open */ +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME \ + "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ +#define H5F_ACS_COLL_MD_WRITE_FLAG_NAME \ + "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not \ + */ +#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME \ + "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ +#define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME \ + "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */ +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME \ + "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */ +#define H5F_ACS_USE_FILE_LOCKING_NAME \ + "use_file_locking" /* whether or not we use file locks for SWMR control and to prevent multiple writers \ + */ +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME \ + "ignore_disabled_file_locks" /* whether or not we ignore "locks disabled" errors */ +#ifdef H5_HAVE_PARALLEL +#define H5F_ACS_MPI_PARAMS_COMM_NAME "mpi_params_comm" /* the MPI communicator */ +#define H5F_ACS_MPI_PARAMS_INFO_NAME "mpi_params_info" /* the MPI info struct */ +#endif /* H5_HAVE_PARALLEL */ /* ======================== File Mount properties ====================*/ -#define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ - +#define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */ #ifdef H5_HAVE_PARALLEL /* Which process writes metadata */ @@ -531,121 +629,124 @@ typedef struct H5F_t H5F_t; #endif /* H5_HAVE_PARALLEL */ /* Define the HDF5 file signature */ -#define H5F_SIGNATURE "\211HDF\r\n\032\n" +#define H5F_SIGNATURE "\211HDF\r\n\032\n" #define H5F_SIGNATURE_LEN 8 /* Version #'s of the major components of the file format */ -#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ -#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */ -#define HDF5_SUPERBLOCK_VERSION_2 2 /* Revised version with superblock extension and checksum */ -#define HDF5_SUPERBLOCK_VERSION_3 3 /* With file locking and consistency flags (at least this version for SWMR support) */ -#define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_3 /* The maximum super block format */ -#define HDF5_SUPERBLOCK_VERSION_V18_LATEST HDF5_SUPERBLOCK_VERSION_2 /* The latest superblock version for v18 */ -#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ -#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ -#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ -#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/ +#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */ +#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */ +#define HDF5_SUPERBLOCK_VERSION_2 2 /* Revised version with superblock extension and checksum */ +#define HDF5_SUPERBLOCK_VERSION_3 \ + 3 /* With file locking and consistency flags (at least this version for SWMR support) */ +#define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_3 /* The maximum super block format */ +#define HDF5_SUPERBLOCK_VERSION_V18_LATEST \ + HDF5_SUPERBLOCK_VERSION_2 /* The latest superblock version for v18 */ +#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */ +#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */ +#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */ +#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/ /* B-tree internal 'K' values */ -#define HDF5_BTREE_SNODE_IK_DEF 16 -#define HDF5_BTREE_CHUNK_IK_DEF 32 /* Note! this value is assumed - to be 32 for version 0 - of the superblock and - if it is changed, the code - must compensate. -QAK - */ -#define HDF5_BTREE_IK_MAX_ENTRIES 65536 /* 2^16 - 2 bytes for storing entries (children) */ - /* See format specification on version 1 B-trees */ +#define HDF5_BTREE_SNODE_IK_DEF 16 +#define HDF5_BTREE_CHUNK_IK_DEF \ + 32 /* Note! this value is assumed \ + to be 32 for version 0 \ + of the superblock and \ + if it is changed, the code \ + must compensate. -QAK \ + */ +#define HDF5_BTREE_IK_MAX_ENTRIES 65536 /* 2^16 - 2 bytes for storing entries (children) */ +/* See format specification on version 1 B-trees */ /* Default file space handling strategy */ -#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR +#define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR /* Default free space section threshold used by free-space managers */ -#define H5F_FREE_SPACE_PERSIST_DEF FALSE +#define H5F_FREE_SPACE_PERSIST_DEF FALSE /* Default free space section threshold used by free-space managers */ -#define H5F_FREE_SPACE_THRESHOLD_DEF 1 +#define H5F_FREE_SPACE_THRESHOLD_DEF 1 /* For paged aggregation: default file space page size when not set */ -#define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096 +#define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096 /* For paged aggregation: minimum value for file space page size */ -#define H5F_FILE_SPACE_PAGE_SIZE_MIN 512 +#define H5F_FILE_SPACE_PAGE_SIZE_MIN 512 /* For paged aggregation: maximum value for file space page size: 1 gigabyte */ -#define H5F_FILE_SPACE_PAGE_SIZE_MAX 1024*1024*1024 +#define H5F_FILE_SPACE_PAGE_SIZE_MAX 1024 * 1024 * 1024 /* For paged aggregation: drop free-space with size <= this threshold for small meta section */ -#define H5F_FILE_SPACE_PGEND_META_THRES 0 +#define H5F_FILE_SPACE_PGEND_META_THRES 0 /* Default for threshold for alignment (can be set via H5Pset_alignment()) */ -#define H5F_ALIGN_DEF 1 +#define H5F_ALIGN_DEF 1 /* Default for alignment (can be set via H5Pset_alignment()) */ -#define H5F_ALIGN_THRHD_DEF 1 +#define H5F_ALIGN_THRHD_DEF 1 /* Default size for meta data aggregation block (can be set via H5Pset_meta_block_size()) */ -#define H5F_META_BLOCK_SIZE_DEF 2048 +#define H5F_META_BLOCK_SIZE_DEF 2048 /* Default size for small data aggregation block (can be set via H5Pset_small_data_block_size()) */ -#define H5F_SDATA_BLOCK_SIZE_DEF 2048 +#define H5F_SDATA_BLOCK_SIZE_DEF 2048 /* Check for file using paged aggregation */ -#define H5F_PAGED_AGGR(F) (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size) +#define H5F_SHARED_PAGED_AGGR(F_SH) ((F_SH)->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && (F_SH)->fs_page_size) +#define H5F_PAGED_AGGR(F) (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size) /* Metadata read attempt values */ -#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */ -#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */ - +#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */ +#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */ /* Macros to define signatures of all objects in the file */ /* Size of signature information (on disk) */ /* (all on-disk signatures should be this length) */ -#define H5_SIZEOF_MAGIC 4 +#define H5_SIZEOF_MAGIC 4 /* Size of checksum information (on disk) */ /* (all on-disk checksums should be this length) */ -#define H5_SIZEOF_CHKSUM 4 +#define H5_SIZEOF_CHKSUM 4 /* v1 B-tree node signature */ -#define H5B_MAGIC "TREE" +#define H5B_MAGIC "TREE" /* v2 B-tree signatures */ -#define H5B2_HDR_MAGIC "BTHD" /* Header */ -#define H5B2_INT_MAGIC "BTIN" /* Internal node */ -#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ +#define H5B2_HDR_MAGIC "BTHD" /* Header */ +#define H5B2_INT_MAGIC "BTIN" /* Internal node */ +#define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */ /* Extensible array signatures */ -#define H5EA_HDR_MAGIC "EAHD" /* Header */ -#define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */ -#define H5EA_SBLOCK_MAGIC "EASB" /* Super block */ -#define H5EA_DBLOCK_MAGIC "EADB" /* Data block */ +#define H5EA_HDR_MAGIC "EAHD" /* Header */ +#define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */ +#define H5EA_SBLOCK_MAGIC "EASB" /* Super block */ +#define H5EA_DBLOCK_MAGIC "EADB" /* Data block */ /* Fixed array signatures */ -#define H5FA_HDR_MAGIC "FAHD" /* Header */ -#define H5FA_DBLOCK_MAGIC "FADB" /* Data block */ +#define H5FA_HDR_MAGIC "FAHD" /* Header */ +#define H5FA_DBLOCK_MAGIC "FADB" /* Data block */ /* Free space signatures */ -#define H5FS_HDR_MAGIC "FSHD" /* Header */ -#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ +#define H5FS_HDR_MAGIC "FSHD" /* Header */ +#define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */ /* Symbol table node signature */ -#define H5G_NODE_MAGIC "SNOD" +#define H5G_NODE_MAGIC "SNOD" /* Fractal heap signatures */ -#define H5HF_HDR_MAGIC "FRHP" /* Header */ -#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ -#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ +#define H5HF_HDR_MAGIC "FRHP" /* Header */ +#define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */ +#define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */ /* Global heap signature */ -#define H5HG_MAGIC "GCOL" +#define H5HG_MAGIC "GCOL" /* Local heap signature */ -#define H5HL_MAGIC "HEAP" +#define H5HL_MAGIC "HEAP" /* Object header signatures */ -#define H5O_HDR_MAGIC "OHDR" /* Header */ -#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ +#define H5O_HDR_MAGIC "OHDR" /* Header */ +#define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */ /* Shared Message signatures */ -#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ -#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ +#define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */ +#define H5SM_LIST_MAGIC "SMLI" /* Shared Message List */ /****************************/ /* Library Private Typedefs */ @@ -669,152 +770,155 @@ 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 */ + H5F_flush_cb_t func; /* The callback function */ + void * udata; /* User data */ } H5F_object_flush_t; /* Concise info about a block of bytes in a file */ typedef struct H5F_block_t { - haddr_t offset; /* Offset of the block in the file */ - hsize_t length; /* Length of the block in the file */ + haddr_t offset; /* Offset of the block in the file */ + hsize_t length; /* Length of the block in the file */ } H5F_block_t; /* Enum for free space manager state */ typedef enum H5F_fs_state_t { - H5F_FS_STATE_CLOSED = 0, /* Free space manager is closed */ - H5F_FS_STATE_OPEN = 1, /* Free space manager has been opened */ - H5F_FS_STATE_DELETING = 2 /* Free space manager is being deleted */ + H5F_FS_STATE_CLOSED = 0, /* Free space manager is closed */ + H5F_FS_STATE_OPEN = 1, /* Free space manager has been opened */ + H5F_FS_STATE_DELETING = 2 /* Free space manager is being deleted */ } H5F_fs_state_t; /* For paged aggregation */ /* The values 0 to 6 is the same as H5F_mem_t */ typedef enum H5F_mem_page_t { - H5F_MEM_PAGE_DEFAULT = 0, /* Not used */ - H5F_MEM_PAGE_SUPER = 1, - H5F_MEM_PAGE_BTREE = 2, - H5F_MEM_PAGE_DRAW = 3, - H5F_MEM_PAGE_GHEAP = 4, - H5F_MEM_PAGE_LHEAP = 5, - H5F_MEM_PAGE_OHDR = 6, + H5F_MEM_PAGE_DEFAULT = 0, /* Not used */ + H5F_MEM_PAGE_SUPER = 1, + H5F_MEM_PAGE_BTREE = 2, + H5F_MEM_PAGE_DRAW = 3, + H5F_MEM_PAGE_GHEAP = 4, + H5F_MEM_PAGE_LHEAP = 5, + H5F_MEM_PAGE_OHDR = 6, H5F_MEM_PAGE_LARGE_SUPER = 7, H5F_MEM_PAGE_LARGE_BTREE = 8, - H5F_MEM_PAGE_LARGE_DRAW = 9, + H5F_MEM_PAGE_LARGE_DRAW = 9, H5F_MEM_PAGE_LARGE_GHEAP = 10, H5F_MEM_PAGE_LARGE_LHEAP = 11, - H5F_MEM_PAGE_LARGE_OHDR = 12, - H5F_MEM_PAGE_NTYPES = 13 /* Sentinel value - must be last */ + H5F_MEM_PAGE_LARGE_OHDR = 12, + H5F_MEM_PAGE_NTYPES = 13 /* Sentinel value - must be last */ } H5F_mem_page_t; /* Aliases for H5F_mem_page_t enum values */ -#define H5F_MEM_PAGE_META H5F_MEM_PAGE_SUPER /* Small-sized meta data */ -#define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */ +#define H5F_MEM_PAGE_META H5F_MEM_PAGE_SUPER /* Small-sized meta data */ +#define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */ /* Type of prefix for opening prefixed files */ typedef enum H5F_prefix_open_t { - H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ - H5F_PREFIX_ELINK = 1, /* External link prefix */ - H5F_PREFIX_EFILE = 2 /* External file prefix */ + H5F_PREFIX_VDS = 0, /* Virtual dataset prefix */ + H5F_PREFIX_ELINK = 1, /* External link prefix */ + H5F_PREFIX_EFILE = 2 /* External file prefix */ } H5F_prefix_open_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* Private functions */ +H5_DLL herr_t H5F_init(void); H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); -H5_DLL herr_t H5F_start_swmr_write(H5F_t *file); +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 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 hid_t H5F_get_file_id(const H5F_t *f); -H5_DLL H5F_t *H5F_get_parent(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, hbool_t app_ref); -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_first_alloc_dealloc(const H5F_t *f); -H5_DLL haddr_t H5F_get_eoa_pre_fsm_fsalloc(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 hbool_t H5F_get_file_locking(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); /* Functions than retrieve values set/cached from the superblock/FCPL */ -H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); -H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); -H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); -H5_DLL unsigned H5F_get_nrefs(const H5F_t *f); -H5_DLL uint8_t H5F_sizeof_addr(const H5F_t *f); -H5_DLL uint8_t H5F_sizeof_size(const H5F_t *f); -H5_DLL haddr_t H5F_get_sohm_addr(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_addr(H5F_t *f, haddr_t addr); -H5_DLL unsigned H5F_get_sohm_vers(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_vers(H5F_t *f, unsigned vers); -H5_DLL unsigned H5F_get_sohm_nindexes(const H5F_t *f); -H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes); -H5_DLL hid_t H5F_get_fcpl(const H5F_t *f); +H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); +H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); +H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); +H5_DLL unsigned H5F_get_nrefs(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_addr(const H5F_t *f); +H5_DLL uint8_t H5F_sizeof_size(const H5F_t *f); +H5_DLL haddr_t H5F_get_sohm_addr(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_addr(H5F_t *f, haddr_t addr); +H5_DLL unsigned H5F_get_sohm_vers(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_vers(H5F_t *f, unsigned vers); +H5_DLL unsigned H5F_get_sohm_nindexes(const H5F_t *f); +H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes); +H5_DLL hid_t H5F_get_fcpl(const H5F_t *f); H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f); -H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f); -H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); -H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f); -H5_DLL double H5F_rdcc_w0(const H5F_t *f); -H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f); -H5_DLL unsigned H5F_gc_ref(const H5F_t *f); -H5_DLL unsigned H5F_use_latest_flags(const H5F_t *f, unsigned fl); -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 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); -H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); -H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); +H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f); +H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); +H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f); +H5_DLL double H5F_rdcc_w0(const H5F_t *f); +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 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); +H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); +H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); #ifdef H5_HAVE_PARALLEL H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f); -H5_DLL void H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t flag); #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); -H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); +H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); +H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hbool_t H5F_shared_has_feature(const H5F_shared_t *f, unsigned feature); H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature); H5_DLL haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type); H5_DLL haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type); -H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); +H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); /* Functions that check file mounting information */ H5_DLL hbool_t H5F_is_mount(const H5F_t *file); H5_DLL hbool_t H5F_has_mount(const H5F_t *file); -H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); -H5_DLL herr_t H5F_flush_mounts(H5F_t *f); +H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc /*in,out*/); +H5_DLL herr_t H5F_flush_mounts(H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + void *buf /*out*/); +H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/); +H5_DLL herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, + const void *buf); H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Functions that flush or evict */ @@ -827,6 +931,7 @@ H5_DLL herr_t H5F_get_checksums(const uint8_t *buf, size_t chk_size, uint32_t *s /* Routine to track the # of retries */ H5_DLL herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries); H5_DLL herr_t H5F_set_retries(H5F_t *f); +H5_DLL herr_t H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info); /* Routine to invoke callback function upon object flush */ H5_DLL herr_t H5F_object_flush_cb(H5F_t *f, hid_t obj_id); @@ -850,11 +955,13 @@ H5_DLL herr_t H5F_eoa_dirty(H5F_t *f); /* Parallel I/O (i.e. MPI) related routines */ #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle); -H5_DLL int H5F_mpi_get_rank(const H5F_t *f); +H5_DLL int H5F_mpi_get_rank(const H5F_t *f); H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f); -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 int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); +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); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ @@ -862,7 +969,8 @@ H5_DLL herr_t H5F_efc_close(H5F_t *parent, H5F_t *file); /* File prefix routines */ H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, - const char *prop_prefix, const char *file_name, unsigned file_intent, hid_t fapl_id); + const char *prop_prefix, const char *file_name, unsigned file_intent, + hid_t fapl_id); /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); @@ -871,7 +979,6 @@ H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t H5_DLL herr_t H5F_cwfs_remove_heap(H5F_shared_t *shared, struct H5HG_heap_t *heap); /* Debugging functions */ -H5_DLL herr_t H5F_debug(H5F_t *f, FILE * stream, int indent, int fwidth); - -#endif /* _H5Fprivate_H */ +H5_DLL herr_t H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth); +#endif /* H5Fprivate_H */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 14dbe703ef0..89238b6dc80 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains public declarations for the H5F module. */ -#ifndef _H5Fpublic_H -#define _H5Fpublic_H +#ifndef H5Fpublic_H +#define H5Fpublic_H /* Public header files needed by this file */ #include "H5public.h" @@ -24,19 +24,19 @@ /* When this header is included from a private header, don't make calls to H5check() */ #undef H5CHECK -#ifndef _H5private_H -#define H5CHECK H5check(), -#else /* _H5private_H */ +#ifndef H5private_H +#define H5CHECK H5check(), +#else /* H5private_H */ #define H5CHECK -#endif /* _H5private_H */ +#endif /* H5private_H */ /* When this header is included from a private HDF5 header, don't make calls to H5open() */ #undef H5OPEN -#ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* H5private_H */ /* * These are the bits that can be passed to the `flags' argument of @@ -47,48 +47,47 @@ * We're assuming that these constants are used rather early in the hdf5 * session. */ -#define H5F_ACC_RDONLY (H5CHECK H5OPEN 0x0000u) /*absence of rdwr => rd-only */ -#define H5F_ACC_RDWR (H5CHECK H5OPEN 0x0001u) /*open for read and write */ -#define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /*overwrite existing files */ -#define H5F_ACC_EXCL (H5CHECK H5OPEN 0x0004u) /*fail if file already exists*/ +#define H5F_ACC_RDONLY (H5CHECK H5OPEN 0x0000u) /**< Absence of RDWR: read-only */ +#define H5F_ACC_RDWR (H5CHECK H5OPEN 0x0001u) /**< Open for read and write */ +#define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /**< Overwrite existing files */ +#define H5F_ACC_EXCL (H5CHECK H5OPEN 0x0004u) /**< Fail if file already exists*/ /* NOTE: 0x0008u was H5F_ACC_DEBUG, now deprecated */ -#define H5F_ACC_CREAT (H5CHECK H5OPEN 0x0010u) /*create non-existing files */ -#define H5F_ACC_SWMR_WRITE (H5CHECK 0x0020u) /*indicate that this file is - * open for writing in a - * single-writer/multi-reader (SWMR) - * scenario. Note that the - * process(es) opening the file - * for reading must open the file - * with RDONLY access, and use - * the special "SWMR_READ" access - * flag. */ -#define H5F_ACC_SWMR_READ (H5CHECK 0x0040u) /*indicate that this file is - * open for reading in a - * single-writer/multi-reader (SWMR) - * scenario. Note that the - * process(es) opening the file - * for SWMR reading must also - * open the file with the RDONLY - * flag. */ - -/* Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the - * parent file. */ -#define H5F_ACC_DEFAULT (H5CHECK H5OPEN 0xffffu) /*ignore setting on lapl */ +#define H5F_ACC_CREAT (H5CHECK H5OPEN 0x0010u) /**< Create non-existing files */ +#define H5F_ACC_SWMR_WRITE \ + (H5CHECK 0x0020u) /**< Indicate that this file is open for writing in a \ + * single-writer/multi-reader (SWMR) scenario. \ + * Note that the process(es) opening the file for reading \ + * must open the file with #H5F_ACC_RDONLY and use the \ + * #H5F_ACC_SWMR_READ access flag. */ +#define H5F_ACC_SWMR_READ \ + (H5CHECK 0x0040u) /**< Indicate that this file is open for reading in a \ + * single-writer/multi-reader (SWMR) scenario. Note that \ + * the process(es) opening the file for SWMR reading must \ + * also open the file with the #H5F_ACC_RDONLY flag. */ + +/** + * Default property list identifier + * + * \internal Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the parent file. + * \internal ignore setting on lapl + */ +#define H5F_ACC_DEFAULT (H5CHECK H5OPEN 0xffffu) /* Flags for H5Fget_obj_count() & H5Fget_obj_ids() calls */ -#define H5F_OBJ_FILE (0x0001u) /* File objects */ -#define H5F_OBJ_DATASET (0x0002u) /* Dataset objects */ -#define H5F_OBJ_GROUP (0x0004u) /* Group objects */ -#define H5F_OBJ_DATATYPE (0x0008u) /* Named datatype objects */ -#define H5F_OBJ_ATTR (0x0010u) /* Attribute objects */ -#define H5F_OBJ_ALL (H5F_OBJ_FILE|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR) -#define H5F_OBJ_LOCAL (0x0020u) /* Restrict search to objects opened through current file ID */ - /* (as opposed to objects opened through any file ID accessing this file) */ +#define H5F_OBJ_FILE (0x0001u) /**< File objects */ +#define H5F_OBJ_DATASET (0x0002u) /**< Dataset objects */ +#define H5F_OBJ_GROUP (0x0004u) /**< Group objects */ +#define H5F_OBJ_DATATYPE (0x0008u) /**< Named datatype objects */ +#define H5F_OBJ_ATTR (0x0010u) /**< Attribute objects */ +#define H5F_OBJ_ALL (H5F_OBJ_FILE | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR) +#define H5F_OBJ_LOCAL \ + (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 #ifdef H5_HAVE_PARALLEL -/* +/** * Use this constant string as the MPI_Info key to set H5Fmpio debug flags. * To turn on H5Fmpio debug flags, set the MPI_Info value with this key to * have the value of a string consisting of the characters that turn on the @@ -97,124 +96,150 @@ #define H5F_MPIO_DEBUG_KEY "H5F_mpio_debug_key" #endif /* H5_HAVE_PARALLEL */ -/* The difference between a single file and a set of mounted files */ +/** + * The scope of an operation such as H5Fflush(), e.g., + * a single file vs. a set of mounted files + */ typedef enum H5F_scope_t { - H5F_SCOPE_LOCAL = 0, /*specified file handle only */ - H5F_SCOPE_GLOBAL = 1 /*entire virtual file */ + H5F_SCOPE_LOCAL = 0, /**< The specified file handle only */ + H5F_SCOPE_GLOBAL = 1 /**< The entire virtual file */ } H5F_scope_t; -/* Unlimited file size for H5Pset_external() */ -#define H5F_UNLIMITED ((hsize_t)(-1L)) +/** + * Unlimited file size for H5Pset_external() + */ +#define H5F_UNLIMITED ((hsize_t)(-1L)) -/* How does file close behave? - * H5F_CLOSE_DEFAULT - Use the degree pre-defined by underlining VFL - * H5F_CLOSE_WEAK - file closes only after all opened objects are closed - * H5F_CLOSE_SEMI - if no opened objects, file is close; otherwise, file - close fails - * H5F_CLOSE_STRONG - if there are opened objects, close them first, then - close file +/** + * How does file close behave? */ typedef enum H5F_close_degree_t { - H5F_CLOSE_DEFAULT = 0, - H5F_CLOSE_WEAK = 1, - H5F_CLOSE_SEMI = 2, - H5F_CLOSE_STRONG = 3 + H5F_CLOSE_DEFAULT = 0, /**< Use the degree pre-defined by underlying VFD */ + H5F_CLOSE_WEAK = 1, /**< File closes only after all opened objects are closed */ + H5F_CLOSE_SEMI = 2, /**< If no opened objects, file is closed; otherwise, file close fails */ + H5F_CLOSE_STRONG = 3 /**< If there are opened objects, close them first, then close file */ } H5F_close_degree_t; -/* Current "global" information about file */ +/** + * Current "global" information about file + */ +//! typedef struct H5F_info2_t { struct { - unsigned version; /* Superblock version # */ - hsize_t super_size; /* Superblock size */ - hsize_t super_ext_size; /* Superblock extension size */ + unsigned version; /**< Superblock version # */ + hsize_t super_size; /**< Superblock size */ + hsize_t super_ext_size; /**< Superblock extension size */ } super; struct { - unsigned version; /* Version # of file free space management */ - hsize_t meta_size; /* Free space manager metadata size */ - hsize_t tot_space; /* Amount of free space in the file */ + unsigned version; /**< Version # of file free space management */ + hsize_t meta_size; /**< Free space manager metadata size */ + hsize_t tot_space; /**< Amount of free space in the file */ } free; struct { - unsigned version; /* Version # of shared object header info */ - hsize_t hdr_size; /* Shared object header message header size */ - H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ + unsigned version; /**< Version # of shared object header info */ + hsize_t hdr_size; /**< Shared object header message header size */ + H5_ih_info_t msgs_info; /**< Shared object header message index & heap size */ } sohm; } H5F_info2_t; +//! -/* - * Types of allocation requests. The values larger than H5FD_MEM_DEFAULT +/** + * Types of allocation requests. The values larger than #H5FD_MEM_DEFAULT * should not change other than adding new types to the end. These numbers * might appear in files. * - * Note: please change the log VFD flavors array if you change this - * enumeration. + * \internal Please change the log VFD flavors array if you change this + * enumeration. */ typedef enum H5F_mem_t { - H5FD_MEM_NOLIST = -1, /* Data should not appear in the free list. - * Must be negative. - */ - H5FD_MEM_DEFAULT = 0, /* Value not yet set. Can also be the - * datatype set in a larger allocation - * that will be suballocated by the library. - * Must be zero. - */ - H5FD_MEM_SUPER = 1, /* Superblock data */ - H5FD_MEM_BTREE = 2, /* B-tree data */ - H5FD_MEM_DRAW = 3, /* Raw data (content of datasets, etc.) */ - H5FD_MEM_GHEAP = 4, /* Global heap data */ - H5FD_MEM_LHEAP = 5, /* Local heap data */ - H5FD_MEM_OHDR = 6, /* Object header data */ - - H5FD_MEM_NTYPES /* Sentinel value - must be last */ + H5FD_MEM_NOLIST = -1, /**< Data should not appear in the free list. + * Must be negative. + */ + H5FD_MEM_DEFAULT = 0, /**< Value not yet set. Can also be the + * datatype set in a larger allocation + * that will be suballocated by the library. + * Must be zero. + */ + H5FD_MEM_SUPER = 1, /**< Superblock data */ + H5FD_MEM_BTREE = 2, /**< B-tree data */ + H5FD_MEM_DRAW = 3, /**< Raw data (content of datasets, etc.) */ + H5FD_MEM_GHEAP = 4, /**< Global heap data */ + H5FD_MEM_LHEAP = 5, /**< Local heap data */ + H5FD_MEM_OHDR = 6, /**< Object header data */ + + H5FD_MEM_NTYPES /**< Sentinel value - must be last */ } H5F_mem_t; -/* Free space section information */ +/** + * Free space section information + */ +//! typedef struct H5F_sect_info_t { - haddr_t addr; /* Address of free space section */ - hsize_t size; /* Size of free space section */ + haddr_t addr; /**< Address of free space section */ + hsize_t size; /**< Size of free space section */ } H5F_sect_info_t; +//! -/* Library's format versions */ +/** + * Library's format versions + */ typedef enum H5F_libver_t { - H5F_LIBVER_ERROR = -1, - H5F_LIBVER_EARLIEST = 0, /* Use the earliest possible format for storing objects */ - H5F_LIBVER_V18 = 1, /* Use the latest v18 format for storing objects */ - H5F_LIBVER_V110 = 2, /* Use the latest v10 format for storing objects */ + H5F_LIBVER_ERROR = -1, + H5F_LIBVER_EARLIEST = 0, /**< Use the earliest possible format for storing objects */ + 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_t; -#define H5F_LIBVER_LATEST H5F_LIBVER_V110 +#define H5F_LIBVER_LATEST H5F_LIBVER_V112 -/* File space handling strategy */ +/** + * File space handling strategy + */ +//! typedef enum H5F_fspace_strategy_t { - H5F_FSPACE_STRATEGY_FSM_AGGR = 0, /* Mechanisms: free-space managers, aggregators, and virtual file drivers */ - /* This is the library default when not set */ - H5F_FSPACE_STRATEGY_PAGE = 1, /* Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers */ - H5F_FSPACE_STRATEGY_AGGR = 2, /* Mechanisms: aggregators and virtual file drivers */ - H5F_FSPACE_STRATEGY_NONE = 3, /* Mechanisms: virtual file drivers */ - H5F_FSPACE_STRATEGY_NTYPES /* must be last */ + H5F_FSPACE_STRATEGY_FSM_AGGR = 0, /**< Mechanisms: free-space managers, aggregators, and virtual file + drivers This is the library default when not set */ + H5F_FSPACE_STRATEGY_PAGE = + 1, /**< Mechanisms: free-space managers with embedded paged aggregation and virtual file drivers */ + H5F_FSPACE_STRATEGY_AGGR = 2, /**< Mechanisms: aggregators and virtual file drivers */ + H5F_FSPACE_STRATEGY_NONE = 3, /**< Mechanisms: virtual file drivers */ + H5F_FSPACE_STRATEGY_NTYPES /**< Sentinel */ } H5F_fspace_strategy_t; +//! -/* Deprecated: File space handling strategy for release 1.10.0 */ -/* They are mapped to H5F_fspace_strategy_t as defined above from release 1.10.1 onwards */ +/** + * File space handling strategy for release 1.10.0 + * + * \deprecated 1.10.1 + */ typedef enum H5F_file_space_type_t { - H5F_FILE_SPACE_DEFAULT = 0, /* Default (or current) free space strategy setting */ - H5F_FILE_SPACE_ALL_PERSIST = 1, /* Persistent free space managers, aggregators, virtual file driver */ - H5F_FILE_SPACE_ALL = 2, /* Non-persistent free space managers, aggregators, virtual file driver */ - /* This is the library default */ - H5F_FILE_SPACE_AGGR_VFD = 3, /* Aggregators, Virtual file driver */ - H5F_FILE_SPACE_VFD = 4, /* Virtual file driver */ - H5F_FILE_SPACE_NTYPES /* must be last */ + H5F_FILE_SPACE_DEFAULT = 0, /**< Default (or current) free space strategy setting */ + H5F_FILE_SPACE_ALL_PERSIST = 1, /**< Persistent free space managers, aggregators, virtual file driver */ + H5F_FILE_SPACE_ALL = 2, /**< Non-persistent free space managers, aggregators, virtual file driver + This is the library default */ + H5F_FILE_SPACE_AGGR_VFD = 3, /**< Aggregators, Virtual file driver */ + H5F_FILE_SPACE_VFD = 4, /**< Virtual file driver */ + H5F_FILE_SPACE_NTYPES /**< Sentinel */ } H5F_file_space_type_t; -/* Data structure to report the collection of read retries for metadata items with checksum */ -/* Used by public routine H5Fget_metadata_read_retry_info() */ -#define H5F_NUM_METADATA_READ_RETRY_TYPES 21 +//! +#define H5F_NUM_METADATA_READ_RETRY_TYPES 21 + +/** + * Data structure to report the collection of read retries for metadata items with checksum as + * used by H5Fget_metadata_read_retry_info() + */ typedef struct H5F_retry_info_t { - unsigned nbins; + unsigned nbins; uint32_t *retries[H5F_NUM_METADATA_READ_RETRY_TYPES]; } H5F_retry_info_t; +//! -/* Callback for H5Pset_object_flush_cb() in a file access property list */ +/** + * Callback for H5Pset_object_flush_cb() in a file access property list + */ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); /*********************/ @@ -224,62 +249,1495 @@ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); extern "C" { #endif -/* Functions in H5F.c */ -H5_DLL htri_t H5Fis_hdf5(const char *filename); -H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, - hid_t create_plist, hid_t access_plist); -H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, - hid_t access_plist); -H5_DLL hid_t H5Freopen(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Checks if a file can be opened with a given file access property + * list + * + * \param[in] container_name Name of a file + * \fapl_id + * + * \return \htri_t + * + * \details H5Fis_accessible() checks if the file specified by \p + * container_name can be opened with the file access property list + * \p fapl_id. + * + * \note The H5Fis_accessible() function enables files to be checked with a + * given file access property list, unlike H5Fis_hdf5(), which only uses + * the default file driver when opening a file. + * + * \since 1.12.0 + * + */ +H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); +/** + * \ingroup H5F + * + * \brief Creates an HDF5 file + * + * \param[in] filename Name of the file to create + * \param[in] flags File access flags. Allowable values are: + * - #H5F_ACC_TRUNC: Truncate file, if it already exists, + * erasing all data previously stored in the file + * - #H5F_ACC_EXCL: Fail if file already exists + * \fcpl_id + * \fapl_id + * \return \hid_t{file} + * + * \details H5Fcreate() is the primary function for creating HDF5 files; it + * creates a new HDF5 file with the specified name and property lists. + * + * The \p filename parameter specifies the name of the new file. + * + * The \p flags parameter specifies whether an existing file is to be + * overwritten. It should be set to either #H5F_ACC_TRUNC to overwrite + * an existing file or #H5F_ACC_EXCL, instructing the function to fail + * if the file already exists. + * + * New files are always created in read-write mode, so the read-write + * and read-only flags, #H5F_ACC_RDWR and #H5F_ACC_RDONLY, + * respectively, are not relevant in this function. Further note that + * a specification of #H5F_ACC_RDONLY will be ignored; the file will + * be created in read-write mode, regardless. + * + * More complex behaviors of file creation and access are controlled + * through the file creation and file access property lists, + * \p fcpl_id and \p fapl_id, respectively. The value of #H5P_DEFAULT + * for any property list value indicates that the library should use + * the default values for that appropriate property list. + * + * The return value is a file identifier for the newly-created file; + * this file identifier should be closed by calling H5Fclose() when + * it is no longer needed. + * + * \par Example + * \snippet H5F_examples.c minimal + * + * \note #H5F_ACC_TRUNC and #H5F_ACC_EXCL are mutually exclusive; use + * exactly one. + * + * \note An additional flag, #H5F_ACC_DEBUG, prints debug information. This + * flag can be combined with one of the above values using the bit-wise + * OR operator (\c |), but it is used only by HDF5 library developers; + * \Emph{it is neither tested nor supported for use in applications}. + * + * \attention \Bold{Special case — File creation in the case of an already-open file:} + * If a file being created is already opened, by either a previous + * H5Fopen() or H5Fcreate() call, the HDF5 library may or may not + * detect that the open file and the new file are the same physical + * file. (See H5Fopen() regarding the limitations in detecting the + * re-opening of an already-open file.)\n + * If the library detects that the file is already opened, + * H5Fcreate() will return a failure, regardless of the use of + * #H5F_ACC_TRUNC.\n + * If the library does not detect that the file is already opened + * and #H5F_ACC_TRUNC is not used, H5Fcreate() will return a failure + * because the file already exists. Note that this is correct + * behavior.\n + * But if the library does not detect that the file is already + * opened and #H5F_ACC_TRUNC is used, H5Fcreate() will truncate the + * existing file and return a valid file identifier. Such a + * truncation of a currently-opened file will almost certainly + * result in errors. While unlikely, the HDF5 library may not be + * able to detect, and thus report, such errors.\n + * Applications should avoid calling H5Fcreate() with an already + * opened file. + * + * \since 1.0.0 + * + * \see H5Fopen(), H5Fclose() + * + */ +H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +/** + * \ingroup H5F + * + * \brief Opens an existing HDF5 file + * + * \param[in] filename Name of the file to be opened + * \param[in] flags File access flags. Allowable values are: + * - #H5F_ACC_RDWR: Allows read and write access to file + * - #H5F_ACC_RDONLY: Allows read-only access to file + * - #H5F_ACC_RDWR \c | #H5F_ACC_SWMR_WRITE: Indicates that + * the file is open for writing in a + * single-writer/multi-writer (SWMR) scenario. + * - #H5F_ACC_RDONLY \c | #H5F_ACC_SWMR_READ: Indicates + * that the file is open for reading in a + * single-writer/multi-reader (SWMR) scenario. + * - An additional flag, #H5F_ACC_DEBUG, prints debug + * information. This flag can be combined with one of the + * above values using the bit-wise OR operator (\c |), but + * it is used only by HDF5 library developers; + * \Emph{it is neither tested nor supported} for use in + * applications. + * \fapl_id + * \return \hid_t{file} + * + * \details H5Fopen() is the primary function for accessing existing HDF5 files. + * This function opens the named file in the specified access mode and + * with the specified access property list. + * + * Note that H5Fopen() does not create a file if it does not already + * exist; see H5Fcreate(). + * + * The \p filename parameter specifies the name of the file to be + * opened. + * + * The \p fapl_id parameter specifies the file access property list. + * 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 + * read-write or read-only mode, #H5F_ACC_RDWR or #H5F_ACC_RDONLY, + * respectively. More complex behaviors of file access are controlled + * through the file-access property list. + * + * The return value is a file identifier for the open file; this file + * identifier should be closed by calling H5Fclose() when it is no + * longer needed. + * + * \par Example + * \snippet H5F_examples.c open + * + * \note #H5F_ACC_RDWR and #H5F_ACC_RDONLY are mutually exclusive; use + * exactly one. + * + * \attention \Bold{Special cases — Multiple opens:} A file can often be opened + * with a new H5Fopen() call without closing an already-open + * identifier established in a previous H5Fopen() or H5Fcreate() + * call. Each such H5Fopen() call will return a unique identifier + * and the file can be accessed through any of these identifiers as + * long as the identifier remains valid. In such multiply-opened + * cases, the open calls must use the same flags argument and the + * file access property lists must use the same file close degree + * property setting (see the external link discussion below and + * H5Pset_fclose_degree()).\n + * In some cases, such as files on a local Unix file system, the + * HDF5 library can detect that a file is multiply opened and will + * maintain coherent access among the file identifiers.\n + * But in many other cases, such as parallel file systems or + * networked file systems, it is not always possible to detect + * multiple opens of the same physical file. In such cases, HDF5 + * will treat the file identifiers as though they are accessing + * different files and will be unable to maintain coherent access. + * Errors are likely to result in these cases. While unlikely, the + * HDF5 library may not be able to detect, and thus report, + * such errors.\n + * It is generally recommended that applications avoid multiple + * opens of the same file. + * + * \attention \Bold{Special restriction on multiple opens of a file first + * opened by means of an external link:} When an external link is + * followed, the external file is always opened with the weak file + * close degree property setting, #H5F_CLOSE_WEAK (see + * H5Lcreate_external() and H5Pset_fclose_degree()). If the file is + * reopened with H5Fopen while it remains held open from such an + * external link call, the file access property list used in the + * open call must include the file close degree setting + * #H5F_CLOSE_WEAK or the open will fail. + * + * \version 1.10.0 The #H5F_ACC_SWMR_WRITE and #H5F_ACC_SWMR_READ flags were added. + * + * \see H5Fclose() + * + */ +H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id); +/** + * \ingroup H5F + * + * \brief Returns a new identifier for a previously-opened HDF5 file + * + * \param[in] file_id Identifier of a file for which an additional identifier + * is required + * + * \return \hid_t{file} + * + * \details H5Freopen() returns a new file identifier for an already-open HDF5 + * file, as specified by \p file_id. Both identifiers share caches and + * other information. The only difference between the identifiers is + * that the new identifier is not mounted anywhere and no files are + * mounted on it. + * + * The new file identifier should be closed by calling H5Fclose() when + * it is no longer needed. + * + * \note Note that there is no circumstance under which H5Freopen() can + * actually open a closed file; the file must already be open and have an + * active \p file_id. E.g., one cannot close a file with H5Fclose() on + * \p file_id then use H5Freopen() on \p file_id to reopen it. + * + */ +H5_DLL hid_t H5Freopen(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Flushes all buffers associated with a file to storage + * + * \loc_id{object_id} + * \param[in] scope The scope of the flush action + * + * \return \herr_t + * + * \details H5Fflush() causes all buffers associated with a file to be + * immediately flushed to storage without removing the data from the + * cache. + * + * \p object_id can be any object associated with the file, including + * the file itself, a dataset, a group, an attribute, or a named + * datatype. + * + * \p scope specifies whether the scope of the flush action is + * global or local. Valid values are as follows: + * \scopes + * + * \par Example + * \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 + * (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. + * + */ H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); +/** + * \ingroup H5F + * + * \brief Terminates access to an HDF5 file + * + * \file_id + * \return \herr_t + * + * \details H5Fclose() terminates access to an HDF5 file (specified by + * \p file_id) by flushing all data to storage. + * + * If this is the last file identifier open for the file and no other + * access identifier is open (e.g., a dataset identifier, group + * identifier, or shared datatype identifier), the file will be fully + * closed and access will end. + * + * \par Example + * \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 + * 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 + * containing it, \c data_sample will remain open and accessible + * (including writable) until it is explicitly closed. The file will be + * 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 + * 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 + * destroy its AFS token after H5Fclose() has returned successfully. This + * would make any future access to the file, or any object within it, + * illegal.\n + * In such situations, applications must close all open objects in a file + * before calling H5Fclose. It is generally recommended to do so in all + * cases. + * + * \see H5Fopen() + * + */ H5_DLL herr_t H5Fclose(hid_t file_id); -H5_DLL hid_t H5Fget_create_plist(hid_t file_id); -H5_DLL hid_t H5Fget_access_plist(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Deletes an HDF5 file + * + * \param[in] filename Name of the file to delete + * \fapl_id + * + * \return \herr_t + * + * \details H5Fdelete() deletes an HDF5 file \p filename with a file access + * property list \p fapl_id. The \p fapl_id should be configured with + * the same VOL connector or VFD that was used to open the file. + * + * This API was introduced for use with the Virtual Object Layer + * (VOL). With the VOL, HDF5 "files" can map to arbitrary storage + * schemes such as object stores and relational database tables. The + * data created by these implementations may be inconvenient for a + * user to remove without a detailed knowledge of the storage scheme. + * H5Fdelete() gives VOL connector authors the ability to add + * connector-specific delete code to their connectors so that users + * can remove these "files" without detailed knowledge of the storage + * scheme. + * + * For a VOL connector, H5Fdelete() deletes the file in a way that + * makes sense for the specified VOL connector. + * + * For the native HDF5 connector, HDF5 files will be deleted via the + * VFDs, each of which will have to be modified to delete the files it + * creates. + * + * For all implementations, H5Fdelete() will first check if the file + * is an HDF5 file via H5Fis_accessible(). This is done to ensure that + * H5Fdelete() cannot be used as an arbitrary file deletion call. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Fdelete(const char *filename, hid_t fapl_id); +/** + * \ingroup H5F + * + * \brief Returns a file creation property list identifier + * + * \file_id + * \return \hid_t{file creation property list} + * + * \details H5Fget_create_plist() returns the file creation property list + * identifier identifying the creation properties used to create this + * file. This function is useful for duplicating properties when + * creating another file. + * + * The creation property list identifier should be released with + * H5Pclose(). + * + */ +H5_DLL hid_t H5Fget_create_plist(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Returns a file access property list identifier + * + * \file_id + * \return \hid_t{file access property list} + * + * \details H5Fget_access_plist() returns the file access property list + * identifier of the specified file. + * + */ +H5_DLL hid_t H5Fget_access_plist(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Determines the read/write or read-only status of a file + * + * \file_id + * \param[out] intent Access mode flag as originally passed with H5Fopen() + * + * \return \herr_t + * + * \details Given the identifier of an open file, \p file_id, H5Fget_intent() + * retrieves the intended access mode" flag passed with H5Fopen() when + * the file was opened. + * + * The value of the flag is returned in \p intent. Valid values are as + * follows: + * \file_access + * + * \note The function will not return an error if intent is NULL; it will + * simply do nothing. + * + * \version 1.10.0 Function enhanced to work with SWMR functionality. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent); +/** + * \ingroup H5F + * + * \brief Retrieves a file's file number that uniquely identifies an open file + * + * \file_id + * \param[out] fileno A buffer to hold the file number + * + * \return \herr_t + * + * \details H5Fget_fileno() retrieves a file number for a file specified by the + * file identifier \p file_id and the pointer \p fnumber to the file + * number. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Fget_fileno(hid_t file_id, unsigned long *fileno); +/** + * \ingroup H5F + * + * \brief Returns the number of open object identifiers for an open file + * + * \file_id or #H5F_OBJ_ALL for all currently-open HDF5 files + * \param[in] types Type of object for which identifiers are to be returned + * + * \return Returns the number of open objects if successful; otherwise returns + * a negative value. + * + * \details Given the identifier of an open file, file_id, and the desired + * object types, types, H5Fget_obj_count() returns the number of open + * object identifiers for the file. + * + * To retrieve a count of open identifiers for open objects in all + * HDF5 application files that are currently open, pass the value + * #H5F_OBJ_ALL in \p file_id. + * + * The types of objects to be counted are specified in types as + * follows: + * \obj_types + * + * Multiple object types can be combined with the + * logical \c OR operator (|). For example, the expression + * \c (#H5F_OBJ_DATASET|#H5F_OBJ_GROUP) would call for datasets and + * groups. + * + * \version 1.6.8, 1.8.2 Function return type changed to \c ssize_t. + * \version 1.6.5 #H5F_OBJ_LOCAL has been added as a qualifier on the types + * of objects to be counted. #H5F_OBJ_LOCAL restricts the + * search to objects opened through current file identifier. + * + */ H5_DLL ssize_t H5Fget_obj_count(hid_t file_id, unsigned types); +/** + *------------------------------------------------------------------------- + * \ingroup H5F + * + * \brief Returns a list of open object identifiers + * + * \file_id or #H5F_OBJ_ALL for all currently-open HDF5 files + * \param[in] types Type of object for which identifiers are to be returned + * \param[in] max_objs Maximum number of object identifiers to place into + * \p obj_id_list + * \param[out] obj_id_list Pointer to the returned buffer of open object + * identifiers + * + * \return Returns number of objects placed into \p obj_id_list if successful; + * otherwise returns a negative value. + * + * \details Given the file identifier \p file_id and the type of objects to be + * identified, types, H5Fget_obj_ids() returns the list of identifiers + * for all open HDF5 objects fitting the specified criteria. + * + * To retrieve identifiers for open objects in all HDF5 application + * files that are currently open, pass the value #H5F_OBJ_ALL in + * \p file_id. + * + * The types of object identifiers to be retrieved are specified in + * types using the codes listed for the same parameter in + * H5Fget_obj_count(). + * + * To retrieve a count of open objects, use the H5Fget_obj_count() + * function. This count can be used to set the \p max_objs parameter. + * + * \version 1.8.2 Function return type changed to \c ssize_t and \p + * max_objs parameter datatype changed to \c size_t. + * \version 1.6.8 Function return type changed to \c ssize_t and \p + * max_objs parameter datatype changed to \c size_t. + * \since 1.6.0 + * + */ H5_DLL ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *obj_id_list); +/** + * \ingroup H5F + * + * \brief Returns pointer to the file handle from the virtual file driver + * + * \file_id + * \fapl_id{fapl} + * \param[out] file_handle Pointer to the file handle being used by the + * low-level virtual file driver + * + * \return \herr_t + * + * \details Given the file identifier \p file_id and the file access property + * list \p fapl_id, H5Fget_vfd_handle() returns a pointer to the file + * handle from the low-level file driver currently being used by the + * HDF5 library for file I/O. + * + * \note For most drivers, the value of \p fapl_id will be #H5P_DEFAULT. For + * the \c FAMILY or \c MULTI drivers, this value should be defined + * through the property list functions: H5Pset_family_offset() for the + * \c FAMILY driver and H5Pset_multi_type() for the \c MULTI driver + * + * \since 1.6.0 + * + */ H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle); +/** + * \ingroup H5F + * + * \brief Mounts an HDF5 file + * + * \loc_id{loc} + * \param[in] name Name of the group onto which the file specified by \p child + * is to be mounted + * \file_id{child} + * \param[in] plist File mount property list identifier. Pass #H5P_DEFAULT! + * + * \return \herr_t + * + * \details H5Fmount() mounts the file specified by \p child onto the object + * specified by \p loc and \p name using the mount properties \p plist + * If the object specified by \p loc is a dataset, named datatype or + * attribute, then the file will be mounted at the location where the + * attribute, dataset, or named datatype is attached. + * + * \par Example + * \snippet H5F_examples.c mount + * + * \note To date, no file mount properties have been defined in HDF5. The + * proper value to pass for \p plist is #H5P_DEFAULT, indicating the + * default file mount property list. + * + */ H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist); +/** + * \ingroup H5F + * + * \brief Unounts an HDF5 file + * + * \loc_id{loc} + * \param[in] name Name of the mount point + * + * \return \herr_t + * + * \details Given a mount point, H5Funmount() dissociates the mount point's + * file from the file mounted there. This function does not close + * either file. + * + * The mount point can be either the group in the parent or the root + * group of the mounted file (both groups have the same name). If the + * mount point was opened before the mount then it is the group in the + * parent; if it was opened after the mount then it is the root group + * of the child. + * + */ H5_DLL herr_t H5Funmount(hid_t loc, const char *name); +/** + * \ingroup H5F + * + * \brief Returns the amount of free space in a file (in bytes) + * + * \file_id + * + * \return Returns the amount of free space in the file if successful; + * otherwise returns a negative value. + * + * \details Given the identifier of an open file, \p file_id, + * H5Fget_freespace() returns the amount of space that is unused by + * any objects in the file. + * + * The interpretation of this number depends on the configured free space + * management strategy. For example, if the HDF5 library only tracks free + * space in a file from a file open or create until that file is closed, + * then this routine will report the free space that has been created + * during that interval. + * + * \since 1.6.1 + * + */ H5_DLL hssize_t H5Fget_freespace(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Returns the size of an HDF5 file (in bytes) + * + * \file_id + * \param[out] size Size of the file, in bytes + * + * \return \herr_t + * + * \details H5Fget_filesize() returns the size of the HDF5 file specified by + * \p file_id. + * + * The returned size is that of the entire file, as opposed to only + * the HDF5 portion of the file. I.e., size includes the user block, + * if any, the HDF5 portion of the file, and any data that may have + * been appended beyond the data written through the HDF5 library. + * + * \since 1.6.3 + * + */ H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size); +/** + * \ingroup H5F + * + * \brief Retrieves the file's end-of-allocation (EOA) + * + * \file_id + * \param[out] eoa The file's EOA + * + * \return \herr_t + * + * \details H5Fget_eoa() retrieves the file's EOA and returns it in the + * parameter eoa. + * + * \since 1.10.2 + * + */ H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); +/** + * \ingroup H5F + * + * \brief Sets the file' EOA to the maximum of (EOA, EOF) + increment + * + * \file_id + * \param[in] increment The number of bytes to be added to the maximum of + * (EOA, EOF) + * + * \return \herr_t + * + * \details H5Fincrement_filesize() sets the file's EOA to the maximum of (EOA, + * EOF) + \p increment. The EOA is the end-of-file address stored in + * the file's superblock while EOF is the file's actual end-of-file. + * + * \since 1.10.2 + * + */ H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); -H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); -H5_DLL herr_t H5Fget_mdc_config(hid_t file_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Fget_mdc_hit_rate(hid_t file_id, double * hit_rate_ptr); -H5_DLL herr_t H5Fget_mdc_size(hid_t file_id, - size_t * max_size_ptr, - size_t * min_clean_size_ptr, - size_t * cur_size_ptr, - int * cur_num_entries_ptr); +/** + * \ingroup H5F + * + * \brief Retrieves a copy of the image of an existing, open file + * + * \file_id + * \param[out] buf_ptr Pointer to the buffer into which the image of the + * HDF5 file is to be copied. If \p buf_ptr is NULL, + * no data will be copied but the function’s return value + * will still indicate the buffer size required (or a + * negative value on error). + * \param[out] buf_len Size of the supplied buffer + * + * \return ssize_t + * + * \details H5Fget_file_image() retrieves a copy of the image of an existing, + * open file. This routine can be used with files opened using the + * SEC2 (or POSIX), STDIO, and Core (or Memory) virtual file drivers + * (VFDs). + * + * If the return value of H5Fget_file_image() is a positive value, it + * will be the length in bytes of the buffer required to store the + * file image. So if the file size is unknown, it can be safely + * determined with an initial H5Fget_file_image() call with buf_ptr + * set to NULL. The file image can then be retrieved with a second + * H5Fget_file_image() call with \p buf_len set to the initial call’s + * return value. + * + * While the current file size can also be retrieved with + * H5Fget_filesize(), that call may produce a larger value than is + * needed. The value returned by H5Fget_filesize() includes the user + * block, if it exists, and any unallocated space at the end of the + * file. It is safe in all situations to get the file size with + * H5Fget_file_image() and it often produces a value that is more + * appropriate for the size of a file image buffer. + * + * \note \Bold{Recommended Reading:} This function is part of the file image + * operations feature set. It is highly recommended to study the guide + * \ref_file_image_ops before using this feature set. + * + * \attention H5Pget_file_image() will fail, returning a negative value, if the + * file is too large for the supplied buffer. + * + * \see H5LTopen_file_image(), H5Pset_file_image(), H5Pget_file_image(), + * H5Pset_file_image_callbacks(), H5Pget_file_image_callbacks() + * + * \since 1.8.0 + * + */ +H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len); +/** + * \ingroup MDC + * + * \brief Obtains current metadata cache configuration for target file + * + * \file_id + * \param[in,out] config_ptr Pointer to the H5AC_cache_config_t instance in which + * the current metadata cache configuration is to be + * reported. The fields of this structure are discussed + * \ref H5AC-cache-config-t "here". + * \return \herr_t + * + * \note The \c in direction applies only to the H5AC_cache_config_t::version + * field. All other fields are out parameters. + * + * \details H5Fget_mdc_config() loads the current metadata cache configuration + * into the instance of H5AC_cache_config_t pointed to by the \p config_ptr + * parameter.\n + * The fields of the H5AC_cache_config_t structure are shown below: + * \snippet H5ACpublic.h H5AC_cache_config_t_snip + * \click4more + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); +/** + * \ingroup MDC + * + * \brief Attempts to configure metadata cache of target file + * + * \file_id + * \param[in,out] config_ptr Pointer to the H5AC_cache_config_t instance + * containing the desired configuration. + * The fields of this structure are discussed + * \ref H5AC-cache-config-t "here". + * \return \herr_t + * + * \details H5Fset_mdc_config() attempts to configure the file's metadata cache + * according configuration supplied in \p config_ptr. + * \snippet H5ACpublic.h H5AC_cache_config_t_snip + * \click4more + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr); +/** + * \ingroup MDC + * + * \brief Obtains target file's metadata cache hit rate + * + * \file_id + * \param[out] hit_rate_ptr Pointer to the double in which the hit rate is returned. Note that + * \p hit_rate_ptr is undefined if the API call fails + * \return \herr_t + * + * \details H5Fget_mdc_hit_rate() queries the metadata cache of the target file to obtain its hit rate + * \Code{(cache hits / (cache hits + cache misses))} since the last time hit rate statistics + * were reset. If the cache has not been accessed since the last time the hit rate stats were + * reset, the hit rate is defined to be 0.0. + * + * The hit rate stats can be reset either manually (via H5Freset_mdc_hit_rate_stats()), or + * automatically. If the cache's adaptive resize code is enabled, the hit rate stats will be + * reset once per epoch. If they are reset manually as well, the cache may behave oddly. + * + * See the overview of the metadata cache in the special topics section of the user manual for + * details on the metadata cache and its adaptive resize algorithms. + * + */ +H5_DLL herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr); +/** + * \ingroup MDC + * + * \brief Obtains current metadata cache size data for specified file + * + * \file_id + * \param[out] max_size_ptr Pointer to the location in which the current cache maximum size is to be + * returned, or NULL if this datum is not desired + * \param[out] min_clean_size_ptr Pointer to the location in which the current cache minimum clean + * size is to be returned, or NULL if that datum is not desired + * \param[out] cur_size_ptr Pointer to the location in which the current cache size is to be returned, + * or NULL if that datum is not desired + * \param[out] cur_num_entries_ptr Pointer to the location in which the current number of entries in + * the cache is to be returned, or NULL if that datum is not desired + * \returns \herr_t + * + * \details H5Fget_mdc_size() queries the metadata cache of the target file for the desired size + * information, and returns this information in the locations indicated by the pointer + * parameters. If any pointer parameter is NULL, the associated data is not returned. + * + * If the API call fails, the values returned via the pointer parameters are undefined. + * + * If adaptive cache resizing is enabled, the cache maximum size and minimum clean size + * may change at the end of each epoch. Current size and current number of entries can + * change on each cache access. + * + * Current size can exceed maximum size under certain conditions. See the overview of the + * metadata cache in the special topics section of the user manual for a discussion of this. + * + */ +H5_DLL herr_t H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, + size_t *cur_size_ptr, int *cur_num_entries_ptr); +/** + * \ingroup MDC + * + * \brief Resets hit rate statistics counters for the target file + * + * \file_id + * \returns \herr_t + * + * \details + * \parblock + * H5Freset_mdc_hit_rate_stats() resets the hit rate statistics counters in the metadata cache + * associated with the specified file. + * + * If the adaptive cache resizing code is enabled, the hit rate statistics are reset at the beginning + * of each epoch. This API call allows you to do the same thing from your program. + * + * The adaptive cache resizing code may behave oddly if you use this call when adaptive cache resizing + * is enabled. However, the call should be useful if you choose to control metadata cache size from your + * program. + * + * See \ref_mdc_in_hdf5 for details about the metadata cache and the adaptive cache resizing + * algorithms. If you have not read, understood, and thought about the material covered in that + * documentation, + * you should not be using this API call. + * \endparblock + * + */ H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Retrieves name of file to which object belongs + * + * \obj_id + * \param[out] name Buffer for the file name + * \param[in] size Size, in bytes, of the \p name buffer + * + * \return Returns the length of the file name if successful; otherwise returns + * a negative value. + * + * \details H5Fget_name() retrieves the name of the file to which the object \p + * obj_id belongs. The object can be a file, group, dataset, + * attribute, or named datatype. + * + * Up to \p size characters of the file 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 + * size, is unknown, a preliminary H5Fget_name() call can be made by + * setting \p name to NULL. The return value of this call will be the + * size of the file name; that value plus one (1) can then be assigned + * to size for a second H5Fget_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.) + * + * If an error occurs, the buffer pointed to by \p name is unchanged + * and the function returns a negative value. + * + * \since 1.6.3 + * + */ H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); -H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo); +/** + * \ingroup H5F + * + * \brief Retrieves name of file to which object belongs + * + * \fgdta_obj_id + * \param[out] file_info Buffer for global file information + * + * \return \herr_t + * + * \details H5Fget_info2() returns global information for the file associated + * with the object identifier \p obj_id in the H5F_info2_t \c struct + * named \p file_info. + * + * \p obj_id is an identifier for any object in the file of interest. + * + * H5F_info2_t struct is defined in H5Fpublic.h as follows: + * \snippet this H5F_info2_t_snip + * + * The \c super sub-struct contains the following information: + * \li \c vers is the version number of the superblock. + * \li \c super_size is the size of the superblock. + * \li \c super_ext_size is the size of the superblock extension. + * + * The \c free sub-struct contains the following information: + * \li vers is the version number of the free-space manager. + * \li \c hdr_size is the size of the free-space manager header. + * \li \c tot_space is the total amount of free space in the file. + * + * The \c sohm sub-struct contains shared object header message + * information as follows: + * \li \c vers is the version number of the shared object header information. + * \li \c hdr_size is the size of the shared object header message. + * \li \c msgs_info is an H5_ih_info_t struct defined in H5public.h as + * follows: \snippet H5public.h H5_ih_info_t_snip + * \li \p index_size is the summed size of all the shared object + * header indexes. Each index might be either a B-tree or + * a list. + * \li \p heap_size is the size of the heap. + * + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *file_info); +/** + * \ingroup SWMR + * + * \brief Retrieves the collection of read retries for metadata entries with checksum + * + * \file_id + * \param[out] info Struct containing the collection of read retries for metadata + * entries with checksum + * \return \herr_t\n + * + * \details \Bold{Failure Modes:} + * \li When the input identifier is not a file identifier. + * \li When the pointer to the output structure is NULL. + * \li When the memory allocation for \p retries failed. + * + * \details H5Fget_metadata_read_retry_info() retrieves information regarding the number + * of read retries for metadata entries with checksum for the file \p file_id. + * This information is reported in the H5F_retry_info_t struct defined in + * H5Fpublic.h as follows: + * \snippet this H5F_retry_info_t_snip + * \c nbins is the number of bins for each \c retries[i] of metadata entry \c i. + * It is calculated based on the current number of read attempts used in the + * library and logarithmic base 10. + * + * If read retries are incurred for a metadata entry \c i, the library will + * allocate memory for \Code{retries[i] (nbins * sizeof(uint32_t)} and store + * the collection of retries there. If there are no retries for a metadata entry + * \c i, \Code{retries[i]} will be NULL. After a call to this routine, users should + * free each \Code{retries[i]} that is non-NULL, otherwise resource leak will occur. + * + * For the library default read attempts of 100 for SWMR access, nbins will be 2 + * as depicted below: + * \li \Code{retries[i][0]} is the number of 1 to 9 read retries. + * \li \Code{retries[i][1]} is the number of 10 to 99 read retries. + * For the library default read attempts of 1 for non-SWMR access, \c nbins will + * be 0 and each \Code{retries[i]} will be NULL. + * + * The following table lists the 21 metadata entries of \Code{retries[]}: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Index for \Code{retries[]}Metadata entries*
0Object header (version 2)
1Object header chunk (version 2)
2B-tree header (version 2)
3B-tree internal node (version 2)
4B-tree leaf node (version 2)
5Fractal heap header
6Fractal heap direct block (optional checksum)
7Fractal heap indirect block
8Free-space header
9Free-space sections
10Shared object header message table
11Shared message record list
12Extensive array header
13Extensive array index block
14Extensive array super block
15Extensive array data block
16Extensive array data block page
17Fixed array super block
18Fixed array data block
19Fixed array data block page
20File's superblock (version 2)
* All entries are of version 0 (zero) unless indicated + * otherwise.
+ * + * \note On a system that is not atomic, the library might possibly read inconsistent + * metadata with checksum when performing single-writer/multiple-reader (SWMR) + * operations for an HDF5 file. Upon encountering such situations, the library + * will try reading the metadata again for a set number of times to attempt to + * obtain consistent data. The maximum number of read attempts used by the library + * will be either the value set via H5Pset_metadata_read_attempts() or the library + * default value when a value is not set.\n + * When the current number of metadata read attempts used in the library is unable + * to remedy the reading of inconsistent metadata on a system, the user can assess + * the information obtained via this routine to derive a different maximum value. + * The information can also be helpful for debugging purposes to identify potential + * issues with metadata flush dependencies and SWMR implementation in general. + * + * \since 1.10.0 + * + */ H5_DLL herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); +/** + * \ingroup SWMR + * + * \brief Retrieves free-space section information for a file + * + * \file_id + * + * \return \herr_t + * + * \details H5Fstart_swmr_write() will activate SWMR writing mode for a file + * associated with \p file_id. This routine will prepare and ensure + * the file is safe for SWMR writing as follows: + * \li Check that the file is opened with write access (#H5F_ACC_RDWR). + * \li Check that the file is opened with the latest library format to + * ensure data structures with check-summed metadata are used. + * \li Check that the file is not already marked in SWMR writing mode. + * \li Enable reading retries for check-summed metadata to remedy + * possible checksum failures from reading inconsistent metadata + * on a system that is not atomic. + * \li Turn off usage of the library's accumulator to avoid possible + * ordering problem on a system that is not atomic. + * \li Perform a flush of the file’s data buffers and metadata to set + * a consistent state for starting SWMR write operations. + * + * Library objects are groups, datasets, and committed datatypes. For + * the current implementation, groups and datasets can remain open when + * activating SWMR writing mode, but not committed datatypes. Attributes + * attached to objects cannot remain open either. + * + * \since 1.10.0 + * + */ H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); -H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, - size_t nsects, H5F_sect_info_t *sect_info/*out*/); +/** + * \ingroup H5F + * + * \brief Retrieves free-space section information for a file + * + * \file_id + * \param[in] type The file memory allocation type + * \param[in] nsects The number of free-space sections + * \param[out] sect_info Array of instances of H5F_sect_info_t in which + * the free-space section information is to be returned + * + * \return Returns the number of free-space sections for the specified + * free-space manager in the file; otherwise returns a negative value. + * + * \details H5Fget_free_sections() retrieves free-space section information for + * the free-space manager with type that is associated with file + * \p file_id. If type is #H5FD_MEM_DEFAULT, this routine retrieves + * free-space section information for all the free-space managers in + * the file. + * + * Valid values for \p type are the following: + * \mem_types + * + * H5F_sect_info_t is defined as follows (in H5Fpublic.h): + * \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 + * 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 + * the specified free-space manager will be returned. Users can then + * allocate space for entries in \p sect_info, each of which is + * defined as an H5F_sect_info_t \c struct. + * + * \attention \Bold{Failure Modes:} This routine will fail when the following + * is true: + * \li The library fails to retrieve the file creation property list + * associated with \p file_id. + * \li If the parameter \p sect_info is non-null, but the parameter + * \p nsects is equal to 0. + * \li The library fails to retrieve free-space section information + * for the file. + * + * \since 1.10.0 + * + */ +H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, + H5F_sect_info_t *sect_info /*out*/); +/** + * \ingroup H5F + * + * \brief Clears the external link open file cache + * + * \file_id + * \return \herr_t + * + * \details H5Fclear_elink_file_cache() evicts all the cached child files in + * the specified file’s external file cache, causing them to be closed + * if there is nothing else holding them open. + * + * H5Fclear_elink_file_cache() does not close the cache itself; + * subsequent external link traversals from the parent file will again + * cache the target file. See H5Pset_elink_file_cache_size() for + * information on closing the file cache. + * + * \see H5Pset_elink_file_cache_size(), H5Pget_elink_file_cache_size() + * + * \since 1.8.7 + * + */ H5_DLL herr_t H5Fclear_elink_file_cache(hid_t file_id); +/** + * \ingroup H5F + * + * \brief Enables the switch of version bounds setting for a file + * + * \file_id + * \param[in] low The earliest version of the library that will be used for + * writing objects + * \param[in] high The latest version of the library that will be used for + * writing objects + * + * \return \herr_t + * + * \details H5Fset_libver_bounds() enables the switch of version bounds setting + * for an open file associated with \p file_id. + * + * For the parameters \p low and \p high, see the description for + * H5Pset_libver_bounds(). + * + * \par Example + * \snippet H5F_examples.c libver_bounds + * + * \since 1.10.2 + * + */ H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); +/** + * \ingroup MDC + * + * \brief Starts logging metadata cache events if logging was previously enabled + * + * \file_id + * + * \return \herr_t + * + * \details The metadata cache is a central part of the HDF5 library through + * which all \Emph{file metadata} reads and writes take place. File + * metadata is normally invisible to the user and is used by the + * library for purposes such as locating and indexing data. File + * metadata should not be confused with user metadata, which consists + * of attributes created by users and attached to HDF5 objects such + * as datasets via H5A API calls. + * + * Due to the complexity of the cache, a trace/logging feature has been + * created that can be used by HDF5 developers for debugging and performance + * analysis. The functions that control this functionality will normally be + * of use to a very limited number of developers outside of The HDF Group. + * The functions have been documented to help users create logs that can + * be sent with bug reports. + * + * Control of the log functionality is straightforward. Logging is enabled + * via the H5Pset_mdc_log_options() function, which will modify the file + * access property list used to open or create a file. This function has + * a flag that determines whether logging begins at file open or starts + * in a paused state. Log messages can then be controlled via the + * H5Fstart_mdc_logging() and H5Fstop_mdc_logging() functions. + * H5Pget_mdc_log_options() can be used to examine a file access property + * list, and H5Fget_mdc_logging_status() will return the current state of + * the logging flags. + * + * The log format is described in the \ref_mdc_logging document. + * + * \note Logging can only be started or stopped if metadata cache logging was enabled + * via H5Pset_mdc_log_options().\n + * When enabled and currently logging, the overhead of the logging feature will + * almost certainly be significant.\n + * The log file is opened when the HDF5 file is opened or created and not when + * this function is called for the first time.\n + * This function opens the log file and starts logging metadata cache operations + * for a particular file. Calling this function when logging has already been + * enabled will be considered an error. + * + * \since 1.10.0 + * + */ H5_DLL herr_t H5Fstart_mdc_logging(hid_t file_id); +/** + * \ingroup MDC + * + * \brief Stops logging metadata cache events if logging was previously enabled and is currently ongoing + * + * \file_id + * + * \return \herr_t + * + * \details The metadata cache is a central part of the HDF5 library through + * which all \Emph{file metadata} reads and writes take place. File + * metadata is normally invisible to the user and is used by the + * library for purposes such as locating and indexing data. File + * metadata should not be confused with user metadata, which consists + * of attributes created by users and attached to HDF5 objects such + * as datasets via H5A API calls. + * + * Due to the complexity of the cache, a trace/logging feature has been + * created that can be used by HDF5 developers for debugging and performance + * analysis. The functions that control this functionality will normally be + * of use to a very limited number of developers outside of The HDF Group. + * The functions have been documented to help users create logs that can + * be sent with bug reports. + * + * Control of the log functionality is straightforward. Logging is enabled + * via the H5Pset_mdc_log_options() function, which will modify the file + * access property list used to open or create a file. This function has + * a flag that determines whether logging begins at file open or starts + * in a paused state. Log messages can then be controlled via the + * H5Fstart_mdc_logging() and H5Fstop_mdc_logging() functions. + * H5Pget_mdc_log_options() can be used to examine a file access property + * list, and H5Fget_mdc_logging_status() will return the current state of + * the logging flags. + * + * The log format is described in the \ref_mdc_logging document. + * + * \note Logging can only be started or stopped if metadata cache logging was enabled + * via H5Pset_mdc_log_options().\n + * This function only suspends the logging operations. The log file will remain + * open and will not be closed until the HDF5 file is closed. + * + * \since 1.10.0 + * + */ H5_DLL herr_t H5Fstop_mdc_logging(hid_t file_id); -H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, - /*OUT*/ hbool_t *is_enabled, - /*OUT*/ hbool_t *is_currently_logging); +/** + * \ingroup MDC + * + * \brief Gets the current metadata cache logging status + * + * \file_id + * \param[out] is_enabled Whether logging is enabled + * \param[out] is_currently_logging Whether events are currently being logged + * \return \herr_t + * + * \details The metadata cache is a central part of the HDF5 library through + * which all \Emph{file metadata} reads and writes take place. File + * metadata is normally invisible to the user and is used by the + * library for purposes such as locating and indexing data. File + * metadata should not be confused with user metadata, which consists + * of attributes created by users and attached to HDF5 objects such + * as datasets via H5A API calls. + * + * Due to the complexity of the cache, a trace/logging feature has been + * created that can be used by HDF5 developers for debugging and performance + * analysis. The functions that control this functionality will normally be + * of use to a very limited number of developers outside of The HDF Group. + * The functions have been documented to help users create logs that can + * be sent with bug reports. + * + * Control of the log functionality is straightforward. Logging is enabled + * via the H5Pset_mdc_log_options() function, which will modify the file + * access property list used to open or create a file. This function has + * a flag that determines whether logging begins at file open or starts + * in a paused state. Log messages can then be controlled via the + * H5Fstart_mdc_logging() and H5Fstop_mdc_logging() functions. + * H5Pget_mdc_log_options() can be used to examine a file access property + * list, and H5Fget_mdc_logging_status() will return the current state of + * the logging flags. + * + * The log format is described in the \ref_mdc_logging document. + * + * \note Unlike H5Fstart_mdc_logging() and H5Fstop_mdc_logging(), this function can + * be called on any open file identifier. + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, hbool_t *is_currently_logging); +/** + * \ingroup SWMR + * + * \todo UFO? + */ H5_DLL herr_t H5Fformat_convert(hid_t fid); +/** + * \ingroup H5F + * + * \brief Resets the page buffer statistics + * + * \file_id + * + * \return \herr_t + * + * \details H5Freset_page_buffering_stats() resets the page buffer statistics + * for a specified file identifier \p file_id. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); -H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], - unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); +/** + * \ingroup H5F + * + * \brief Retrieves statistics about page access when it is enabled + * + * \file_id + * \param[out] accesses Two integer array for the number of metadata and raw + * data accesses to the page buffer + * \param[out] hits Two integer array for the number of metadata and raw data + * hits in the page buffer + * \param[out] misses Two integer array for the number of metadata and raw data + * misses in the page buffer + * \param[out] evictions Two integer array for the number of metadata and raw + * data evictions from the page buffer + * \param[out] bypasses Two integer array for the number of metadata and raw + * data accesses that bypass the page buffer + * + * \return \herr_t + * + * \details H5Fget_page_buffering_stats() retrieves page buffering statistics + * such as the number of metadata and raw data accesses (\p accesses), + * hits (\p hits), misses (\p misses), evictions (\p evictions), and + * accesses that bypass the page buffer (\p bypasses). + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); +/** + * \ingroup MDC + * + * \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_size Length of the cache image if it exists, or 0 if it does not + * \returns \herr_t + * + * \details + * \parblock + * H5Fget_mdc_image_info() returns information about a cache image if it exists. + * + * When an HDF5 file is opened in Read/Write mode, any metadata cache image will + * be read and deleted from the file on the first metadata cache access (or, if + * persistent free space managers are enabled, on the first file space + * allocation / deallocation, or read of free space manager status, whichever + * comes first). + * + * Thus, if the file is opened Read/Write, H5Fget_mdc_image_info() should be called + * immediately after file open and before any other operation. If H5Fget_mdc_image_info() + * is called after the cache image is loaded, it will correctly report that no cache image + * exists, as the image will have already been read and deleted from the file. In the Read Only + * case, the function may be called at any time, as any cache image will not be deleted + * from the file. + * \endparblock + * + * \since 1.10.1 + */ H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); +/** + * \ingroup H5F + * + * \brief Retrieves the setting for whether or not a file will create minimized + * dataset object headers + * + * \file_id + * \param[out] minimize Flag indicating whether the library will or will not + * create minimized dataset object headers + * + * \return \herr_t + * + * \details H5Fget_dset_no_attrs_hint() retrieves the no dataset attributes + * hint setting for the file specified by the file identifier \p + * 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. + * + * \since 1.10.5 + * + */ H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); +/** + * \ingroup H5F + * + * \brief Sets the flag to create minimized dataset object headers + * + * \file_id + * \param[in] minimize Flag indicating whether the library will or will not + * create minimized dataset object headers + * + * \return \herr_t + * + * \details H5Fset_dset_no_attrs_hint() sets the no dataset attributes hint + * setting for the file specified by the file identifier \p file_id. + * If the boolean flag \p minimize is set to \c TRUE, then the library + * will create minimized dataset object headers in the file. + * \Bold{All} files that refer to the same file-on-disk will be + * affected by the most recent setting, regardless of the file + * identifier/handle (e.g., as returned by H5Fopen()). By setting the + * \p minimize flag to \c TRUE, the library expects that no attributes + * will be added to the dataset - attributes can be added, but they + * are appended with a continuation message, which can reduce + * performance. + * + * \attention This setting interacts with H5Pset_dset_no_attrs_hint(): if + * either is set to \c TRUE, then the created dataset's object header + * will be minimized. + * + * \since 1.10.5 + * + */ H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); #ifdef H5_HAVE_PARALLEL +/** + * \ingroup PH5F + * + * \brief Sets the MPI atomicity mode + * + * \file_id + * \param[in] flag Logical flag for atomicity setting. Valid values are: + * \li \c 1 -- Sets MPI file access to atomic mode. + * \li \c 0 -- Sets MPI file access to nonatomic mode. + * \returns \herr_t + * + * \par Motivation + * H5Fset_mpi_atomicity() is applicable only in parallel environments using MPI I/O. + * The function is one of the tools used to ensure sequential consistency. This means + * that a set of operations will behave as though they were performed in a serial + * order consistent with the program order. + * + * \details + * \parblock + * H5Fset_mpi_atomicity() sets MPI consistency semantics for data access to the file, + * \p file_id. + * + * If \p flag is set to \c 1, all file access operations will appear atomic, guaranteeing + * sequential consistency. If \p flag is set to \c 0, enforcement of atomic file access + * will be turned off. + * + * H5Fset_mpi_atomicity() is a collective function and all participating processes must + * pass the same values for \p file_id and \p flag. + * + * This function is available only when the HDF5 library is configured with parallel support + * (\Code{--enable-parallel}). It is useful only when used with the #H5FD_MPIO driver + * (see H5Pset_fapl_mpio()). + * \endparblock + * + * \attention + * \parblock + * H5Fset_mpi_atomicity() calls \Code{MPI_File_set_atomicity} underneath and is not supported + * if the execution platform does not support \Code{MPI_File_set_atomicity}. When it is + * supported and used, the performance of data access operations may drop significantly. + * + * In certain scenarios, even when \Code{MPI_File_set_atomicity} is supported, setting + * atomicity with H5Fset_mpi_atomicity() and \p flag set to 1 does not always yield + * strictly atomic updates. For example, some H5Dwrite() calls translate to multiple + * \Code{MPI_File_write_at} calls. This happens in all cases where the high-level file + * access routine translates to multiple lower level file access routines. + * The following scenarios will raise this issue: + * \li Non-contiguous file access using independent I/O + * \li Partial collective I/O using chunked access + * \li Collective I/O using filters or when data conversion is required + * + * This issue arises because MPI atomicity is a matter of MPI file access operations rather + * than HDF5 access operations. But the user is normally seeking atomicity at the HDF5 level. + * To accomplish this, the application must set a barrier after a write, H5Dwrite(), but before + * the next read, H5Dread(), in addition to calling H5Fset_mpi_atomicity().The barrier will + * guarantee that all underlying write operations execute atomically before the read + * operations starts. This ensures additional ordering semantics and will normally produce + * the desired behavior. + * \endparblock + * + * \see \ref_cons_semantics + * + * \since 1.8.9 + * + */ H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); +/** + * \ingroup PH5F + * + * \brief Retrieves the atomicity mode in use + * + * \file_id + * \param[out] flag Logical flag for atomicity setting. Valid values are: + * \li 1 -- MPI file access is set to atomic mode. + * \li 0 -- MPI file access is set to nonatomic mode. + * \returns \herr_t + * + * \details H5Fget_mpi_atomicity() retrieves the current consistency semantics mode for + * data access for the file \p file_id. + * + * Upon successful return, \p flag will be set to \c 1 if file access is set + * to atomic mode and \c 0 if file access is set to nonatomic mode. + * + * \see \ref_cons_semantics + * + * \since 1.8.9 + * + */ H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); #endif /* H5_HAVE_PARALLEL */ @@ -290,28 +1748,103 @@ H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); #ifndef H5_NO_DEPRECATED_SYMBOLS /* Macros */ -#define H5F_ACC_DEBUG (H5CHECK H5OPEN 0x0000u) /*print debug info (deprecated)*/ +#define H5F_ACC_DEBUG (H5CHECK H5OPEN 0x0000u) /**< Print debug info \deprecated In which version? */ /* Typedefs */ -/* Current "global" information about file */ +/** + * Current "global" information about file + */ +//! typedef struct H5F_info1_t { - hsize_t super_ext_size; /* Superblock extension size */ + hsize_t super_ext_size; /**< Superblock extension size */ struct { - hsize_t hdr_size; /* Shared object header message header size */ - H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ + hsize_t hdr_size; /**< Shared object header message header size */ + H5_ih_info_t msgs_info; /**< Shared object header message index & heap size */ } sohm; } H5F_info1_t; - +//! /* Function prototypes */ -H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo); +/** + * \ingroup H5F + * + * \brief Retrieves name of file to which object belongs + * + * \fgdta_obj_id + * \param[out] file_info Buffer for global file information + * + * \return \herr_t + * + * \deprecated This function has been renamed from H5Fget_info() and is + * deprecated in favor of the macro #H5Fget_info or the function + * H5Fget_info2(). + * + * \details H5Fget_info1() returns global information for the file associated + * with the object identifier \p obj_id in the H5F_info1_t \c struct + * named \p file_info. + * + * \p obj_id is an identifier for any object in the file of interest. + * + * H5F_info1_t struct is defined in H5Fpublic.h as follows: + * \snippet this H5F_info1_t_snip + * + * \c super_ext_size is the size of the superblock extension. + * + * The \c sohm sub-struct contains shared object header message + * information as follows: + * \li \c hdr_size is the size of the shared object header message. + * \li \c msgs_info is an H5_ih_info_t struct defined in H5public.h as + * follows: \snippet H5public.h H5_ih_info_t_snip + * + * \li \p index_size is the summed size of all the shared object + * header indexes. Each index might be either a B-tree or + * a list. + * + * \version 1.10.0 Function H5Fget_info() renamed to H5Fget_info1() and + * deprecated in this release. + * + * \since 1.8.0 + * + */ +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 + * + * \file_id + * \param[in] latest_format Latest format flag + * + * \return \herr_t + * + * \deprecated When? + * + * \todo In which version was this function deprecated? + * + */ H5_DLL herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format); +/** + * \ingroup H5F + * + * \brief Determines whether a file is in the HDF5 format + * + * \param[in] file_name File name + * + * \return \htri_t + * + * \deprecated When? + * + * \details H5Fis_hdf5() determines whether a file is in the HDF5 format. + * + * \todo In which version was this function deprecated? + * + */ +H5_DLL htri_t H5Fis_hdf5(const char *file_name); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif -#endif /* _H5Fpublic_H */ - +#endif /* H5Fpublic_H */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 32587bfffca..04792b42750 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,54 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F_shared_get_intent * @@ -95,7 +85,6 @@ H5F_shared_get_intent(const H5F_shared_t *f_sh) FUNC_LEAVE_NOAPI(f_sh->flags) } /* end H5F_shared_get_intent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_intent * @@ -117,7 +106,6 @@ H5F_get_intent(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->flags) } /* end H5F_get_intent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_low_bound * @@ -142,7 +130,6 @@ H5F_get_low_bound(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->low_bound) } /* end H5F_get_low_bound() */ - /*------------------------------------------------------------------------- * Function: H5F_get_high_bound * @@ -167,7 +154,6 @@ H5F_get_high_bound(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->high_bound) } /* end H5F_get_high_bound() */ - /*------------------------------------------------------------------------- * Function: H5F_get_open_name * @@ -189,7 +175,6 @@ H5F_get_open_name(const H5F_t *f) FUNC_LEAVE_NOAPI(f->open_name) } /* end H5F_get_open_name() */ - /*------------------------------------------------------------------------- * Function: H5F_get_actual_name * @@ -211,13 +196,12 @@ H5F_get_actual_name(const H5F_t *f) FUNC_LEAVE_NOAPI(f->actual_name) } /* end H5F_get_actual_name() */ - /*------------------------------------------------------------------------- * Function: H5F_get_extpath * * Purpose: Retrieve the file's 'extpath' flags - * This is used by H5L_extern_traverse() and H5D_build_file_prefix() to retrieve the main file's location - * when searching the target file. + * This is used by H5L_extern_traverse() and H5D_build_file_prefix() + * to retrieve the main file's location when searching the target file. * * Return: 'extpath' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- @@ -229,12 +213,12 @@ H5F_get_extpath(const H5F_t *f) FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); - HDassert(f->extpath); + HDassert(f->shared); + HDassert(f->shared->extpath); - FUNC_LEAVE_NOAPI(f->extpath) + FUNC_LEAVE_NOAPI(f->shared->extpath) } /* end H5F_get_extpath() */ - /*------------------------------------------------------------------------- * Function: H5F_get_shared * @@ -254,7 +238,6 @@ H5F_get_shared(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared) } /* end H5F_get_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_same_shared * @@ -277,7 +260,6 @@ H5F_same_shared(const H5F_t *f1, const H5F_t *f2) FUNC_LEAVE_NOAPI(f1->shared == f2->shared) } /* end H5F_same_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nopen_objs * @@ -297,27 +279,25 @@ H5F_get_nopen_objs(const H5F_t *f) FUNC_LEAVE_NOAPI(f->nopen_objs) } /* end H5F_get_nopen_objs() */ - /*------------------------------------------------------------------------- - * Function: H5F_get_file_id + * Function: H5F_file_id_exists * - * Purpose: Retrieve the file's 'file_id' value + * Purpose: Determines if a file ID exists for this file struct * - * Return: 'file_id' on success/abort on failure (shouldn't fail) + * Return: TRUE/FALSE *------------------------------------------------------------------------- */ -hid_t -H5F_get_file_id(const H5F_t *f) +hbool_t +H5F_file_id_exists(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); - FUNC_LEAVE_NOAPI(f->file_id) -} /* end H5F_get_file_id() */ + FUNC_LEAVE_NOAPI(f->id_exists) +} /* end H5F_file_id_exists() */ - /*------------------------------------------------------------------------- * Function: H5F_get_parent * @@ -337,7 +317,6 @@ H5F_get_parent(const H5F_t *f) FUNC_LEAVE_NOAPI(f->parent) } /* end H5F_get_parent() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nmounts * @@ -357,7 +336,6 @@ H5F_get_nmounts(const H5F_t *f) FUNC_LEAVE_NOAPI(f->nmounts) } /* end H5F_get_nmounts() */ - /*------------------------------------------------------------------------- * Function: H5F_get_read_attempts * @@ -377,7 +355,6 @@ H5F_get_read_attempts(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->read_attempts) } /* end H5F_get_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fcpl * @@ -399,7 +376,6 @@ H5F_get_fcpl(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->fcpl_id) } /* end H5F_get_fcpl() */ - /*------------------------------------------------------------------------- * Function: H5F_sizeof_addr * @@ -422,7 +398,6 @@ H5F_sizeof_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sizeof_addr) } /* end H5F_sizeof_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_sizeof_size * @@ -445,7 +420,6 @@ H5F_sizeof_size(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sizeof_size) } /* H5F_sizeof_size() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_addr * @@ -466,7 +440,6 @@ H5F_get_sohm_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_addr) } /* end H5F_get_sohm_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_vers * @@ -487,7 +460,6 @@ H5F_get_sohm_vers(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_vers) } /* end H5F_get_sohm_vers() */ - /*------------------------------------------------------------------------- * Function: H5F_get_sohm_nindexes * @@ -508,7 +480,6 @@ H5F_get_sohm_nindexes(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sohm_nindexes) } /* end H5F_get_sohm_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5F_sym_leaf_k * @@ -534,7 +505,6 @@ H5F_sym_leaf_k(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sblock->sym_leaf_k) } /* end H5F_sym_leaf_k() */ - /*------------------------------------------------------------------------- * Function: H5F_get_min_dset_ohdr * @@ -553,7 +523,6 @@ H5F_get_min_dset_ohdr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->crt_dset_min_ohdr_flag) } /* end H5F_get_min_dset_ohdr */ - /*------------------------------------------------------------------------- * Function: H5F_Kvalue * @@ -580,7 +549,6 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) FUNC_LEAVE_NOAPI(f->shared->sblock->btree_k[type->id]) } /* end H5F_Kvalue() */ - /*------------------------------------------------------------------------- * Function: H5F_get_nrefs * @@ -601,7 +569,6 @@ H5F_get_nrefs(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->nrefs) } /* end H5F_get_nrefs() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_nslots * @@ -626,7 +593,6 @@ H5F_rdcc_nslots(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_nslots) } /* end H5F_rdcc_nelmts() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_nbytes * @@ -651,7 +617,6 @@ H5F_rdcc_nbytes(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_nbytes) } /* end H5F_rdcc_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5F_rdcc_w0 * @@ -676,7 +641,6 @@ H5F_rdcc_w0(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->rdcc_w0) } /* end H5F_rdcc_w0() */ - /*------------------------------------------------------------------------- * Function: H5F_get_base_addr * @@ -700,7 +664,6 @@ H5F_get_base_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sblock->base_addr) } /* end H5F_get_base_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_grp_btree_shared * @@ -725,7 +688,6 @@ H5F_grp_btree_shared(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->grp_btree_shared) } /* end H5F_grp_btree_shared() */ - /*------------------------------------------------------------------------- * Function: H5F_sieve_buf_size * @@ -750,7 +712,6 @@ H5F_sieve_buf_size(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->sieve_buf_size) } /* end H5F_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5F_gc_ref * @@ -778,7 +739,6 @@ H5F_gc_ref(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->gc_ref) } /* end H5F_gc_ref() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fc_degree * @@ -800,7 +760,6 @@ H5F_get_fc_degree(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->fc_degree) } /* end H5F_get_fc_degree() */ - /*------------------------------------------------------------------------- * Function: H5F_get_evict_on_close * @@ -824,7 +783,6 @@ H5F_get_evict_on_close(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->evict_on_close) } /* end H5F_get_evict_on_close() */ - /*------------------------------------------------------------------------- * Function: H5F_store_msg_crt_idx * @@ -846,7 +804,6 @@ H5F_store_msg_crt_idx(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->store_msg_crt_idx) } /* end H5F_store_msg_crt_idx() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_has_feature * @@ -867,7 +824,6 @@ H5F_shared_has_feature(const H5F_shared_t *f_sh, unsigned feature) FUNC_LEAVE_NOAPI((hbool_t)(f_sh->lf->feature_flags & feature)) } /* end H5F_shared_has_feature() */ - /*------------------------------------------------------------------------- * Function: H5F_has_feature * @@ -886,10 +842,9 @@ H5F_has_feature(const H5F_t *f, unsigned feature) HDassert(f); HDassert(f->shared); - FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags&feature)) + FUNC_LEAVE_NOAPI((hbool_t)(f->shared->lf->feature_flags & feature)) } /* end H5F_has_feature() */ - /*------------------------------------------------------------------------- * Function: H5F_get_driver_id * @@ -913,7 +868,6 @@ H5F_get_driver_id(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->lf->driver_id) } /* end H5F_get_driver_id() */ - /*------------------------------------------------------------------------- * Function: H5F_get_fileno * @@ -927,7 +881,7 @@ H5F_get_driver_id(const H5F_t *f) herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -937,14 +891,13 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) HDassert(filenum); /* Retrieve the file's serial number */ - if(H5FD_get_fileno(f->shared->lf, filenum) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") + if (H5FD_get_fileno(f->shared->lf, filenum) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_fileno() */ - /*------------------------------------------------------------------------- * Function: H5F_shared_get_eoa * @@ -956,21 +909,20 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(f_sh); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f_sh->lf, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(f_sh->lf, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_shared_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F_get_eoa * @@ -982,7 +934,7 @@ H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type) haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -990,14 +942,13 @@ H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) HDassert(f->shared); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) + if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5F_get_vfd_handle * @@ -1011,7 +962,7 @@ H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1020,14 +971,13 @@ H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle) HDassert(file_handle); /* Get the VFD handle */ - if(H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0) + if (H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_vfd_handle() */ - /*------------------------------------------------------------------------- * Function: H5F_is_tmp_addr * @@ -1051,7 +1001,6 @@ H5F_is_tmp_addr(const H5F_t *f, haddr_t addr) FUNC_LEAVE_NOAPI(H5F_addr_le(f->shared->tmp_addr, addr)) } /* end H5F_is_tmp_addr() */ - /*------------------------------------------------------------------------- * Function: H5F_use_tmp_space * @@ -1076,7 +1025,7 @@ H5F_use_tmp_space(const H5F_t *f) } /* end H5F_use_tmp_space() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5F_coll_md_read * @@ -1094,11 +1043,10 @@ H5F_coll_md_read(const H5F_t *f) HDassert(f); - FUNC_LEAVE_NOAPI(f->coll_md_read) + FUNC_LEAVE_NOAPI(f->shared->coll_md_read) } /* end H5F_coll_md_read() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5F_use_mdc_logging * @@ -1122,7 +1070,6 @@ H5F_use_mdc_logging(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->use_mdc_logging) } /* end H5F_use_mdc_logging() */ - /*------------------------------------------------------------------------- * Function: H5F_start_mdc_log_on_access * @@ -1146,7 +1093,6 @@ H5F_start_mdc_log_on_access(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->start_mdc_log_on_access) } /* end H5F_start_mdc_log_on_access() */ - /*------------------------------------------------------------------------- * Function: H5F_mdc_log_location * @@ -1170,7 +1116,6 @@ H5F_mdc_log_location(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->mdc_log_location) } /* end H5F_mdc_log_location() */ - /*------------------------------------------------------------------------- * Function: H5F_get_alignment * @@ -1192,7 +1137,6 @@ H5F_get_alignment(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->alignment) } /* end H5F_get_alignment() */ - /*------------------------------------------------------------------------- * Function: H5F_get_threshold * @@ -1214,7 +1158,6 @@ H5F_get_threshold(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->threshold) } /* end H5F_get_threshold() */ - /*------------------------------------------------------------------------- * Function: H5F_get_pgend_meta_thres * @@ -1236,7 +1179,6 @@ H5F_get_pgend_meta_thres(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->pgend_meta_thres) } /* end H5F_get_pgend_meta_thres() */ - /*------------------------------------------------------------------------- * Function: H5F_get_point_of_no_return * @@ -1258,18 +1200,17 @@ H5F_get_point_of_no_return(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->point_of_no_return) } /* end H5F_get_point_of_no_return() */ - /*------------------------------------------------------------------------- - * Function: H5F_get_first_alloc_dealloc + * Function: H5F_get_null_fsm_addr * - * Purpose: Retrieve the 'first alloc / dealloc' value for the file. + * Purpose: Retrieve the 'null_fsm_addr' value for the file. * - * Return: Success: Non-negative, the 'first_alloc_dealloc' + * Return: Success: Non-negative, the 'null_fsm_addr' * Failure: (can't happen) *------------------------------------------------------------------------- */ hbool_t -H5F_get_first_alloc_dealloc(const H5F_t *f) +H5F_get_null_fsm_addr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1277,32 +1218,88 @@ H5F_get_first_alloc_dealloc(const H5F_t *f) HDassert(f); HDassert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->first_alloc_dealloc) -} /* end H5F_get_first_alloc_dealloc() */ + FUNC_LEAVE_NOAPI(f->shared->null_fsm_addr) +} /* end H5F_get_null_fsm_addr() */ - /*------------------------------------------------------------------------- - * Function: H5F_get_eoa_pre_fsm_fsalloc + * Function: H5F_get_vol_cls * - * Purpose: Retrieve the 'EOA pre-FSM fsalloc' value for the file. + * Purpose: Get the VOL class for the file + * + * Return: VOL class pointer for file, can't fail + * + * Programmer: Quincey Koziol + * Saturday, August 17, 2019 * - * Return: Success: Non-negative, the 'EOA pre-FSM fsalloc' - * Failure: (can't happen) *------------------------------------------------------------------------- */ -haddr_t -H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f) +const H5VL_class_t * +H5F_get_vol_cls(const H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->vol_cls) +} /* end H5F_get_vol_cls */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_vol_obj + * + * Purpose: Get the VOL object for the file + * + * Return: VOL object pointer for file, can't fail + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5F_get_vol_obj(const H5F_t *f) { - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(f); + + FUNC_LEAVE_NOAPI(f->vol_obj) +} /* end H5F_get_vol_obj */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_cont_info + * + * Purpose: Get the VOL container info for the file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Saturday, August 17, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ HDassert(f); HDassert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->eoa_pre_fsm_fsalloc) -} /* end H5F_get_eoa_pre_fsm_fsalloc() */ + /* Verify structure version */ + if (info->version != H5VL_CONTAINER_INFO_VERSION) + HGOTO_ERROR(H5E_FILE, H5E_VERSION, FAIL, "wrong container info version #") + + /* Set the container info fields */ + info->feature_flags = 0; /* None currently defined */ + info->token_size = H5F_SIZEOF_ADDR(f); + info->blob_id_size = H5HG_HEAP_ID_SIZE(f); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_cont_info */ - /*------------------------------------------------------------------------- * Function: H5F_get_file_locking * @@ -1322,4 +1319,3 @@ H5F_get_file_locking(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->use_file_locking) } /* end H5F_get_file_locking */ - diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index 9a9bbabc677..be45e786466 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -6,26 +6,26 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free lists */ /* PRIVATE TYPEDEFS */ /* Struct for tracking "shared" file structs */ typedef struct H5F_sfile_node_t { - H5F_shared_t *shared; /* Pointer to "shared" file struct */ - struct H5F_sfile_node_t *next; /* Pointer to next node */ + H5F_shared_t * shared; /* Pointer to "shared" file struct */ + struct H5F_sfile_node_t *next; /* Pointer to next node */ } H5F_sfile_node_t; /* PRIVATE PROTOTYPES */ @@ -38,7 +38,6 @@ H5FL_DEFINE_STATIC(H5F_sfile_node_t); /* Declare a local variable to track the shared file information */ H5F_sfile_node_t *H5F_sfile_head_g = NULL; - /*------------------------------------------------------------------------- * Function: H5F_sfile_assert_num * @@ -56,18 +55,18 @@ H5F_sfile_assert_num(unsigned n) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(n == 0) { + if (n == 0) { /* Sanity checking */ HDassert(H5F_sfile_head_g == NULL); } /* end if */ else { - unsigned count; /* Number of open shared files */ - H5F_sfile_node_t *curr; /* Current shared file node */ + unsigned count; /* Number of open shared files */ + H5F_sfile_node_t *curr; /* Current shared file node */ /* Iterate through low-level files for matching low-level file info */ - curr = H5F_sfile_head_g; + curr = H5F_sfile_head_g; count = 0; - while(curr) { + while (curr) { /* Increment # of open shared file structs */ count++; @@ -82,7 +81,6 @@ H5F_sfile_assert_num(unsigned n) FUNC_LEAVE_NOAPI_VOID } /* H5F_sfile_assert_num() */ - /*------------------------------------------------------------------------- * Function: H5F__sfile_add * @@ -98,8 +96,8 @@ H5F_sfile_assert_num(unsigned n) herr_t H5F__sfile_add(H5F_shared_t *shared) { - H5F_sfile_node_t *new_shared; /* New shared file node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_sfile_node_t *new_shared; /* New shared file node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -121,7 +119,6 @@ H5F__sfile_add(H5F_shared_t *shared) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__sfile_add() */ - /*------------------------------------------------------------------------- * Function: H5F__sfile_search * @@ -139,7 +136,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 @@ -148,9 +145,9 @@ H5F__sfile_search(H5FD_t *lf) /* Iterate through low-level files for matching low-level file info */ curr = H5F_sfile_head_g; - while(curr) { + while (curr) { /* Check for match */ - if(0 == H5FD_cmp(curr->shared->lf, lf)) + if (0 == H5FD_cmp(curr->shared->lf, lf)) HGOTO_DONE(curr->shared) /* Advance to next shared file node */ @@ -161,7 +158,6 @@ H5F__sfile_search(H5FD_t *lf) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__sfile_search() */ - /*------------------------------------------------------------------------- * Function: H5F__sfile_remove * @@ -177,9 +173,9 @@ H5F__sfile_search(H5FD_t *lf) herr_t H5F__sfile_remove(H5F_shared_t *shared) { - H5F_sfile_node_t *curr; /* Current shared file node */ - H5F_sfile_node_t *last; /* Last shared file node */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_sfile_node_t *curr; /* Current shared file node */ + H5F_sfile_node_t *last; /* Last shared file node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -189,18 +185,18 @@ H5F__sfile_remove(H5F_shared_t *shared) /* Locate shared file node with correct shared file */ last = NULL; curr = H5F_sfile_head_g; - while(curr && curr->shared != shared) { + while (curr && curr->shared != shared) { /* Advance to next node */ last = curr; curr = curr->next; } /* end while */ /* Indicate error if the node wasn't found */ - if(curr == NULL) + if (curr == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOTFOUND, FAIL, "can't find shared file info") /* Remove node found from list */ - if(last != NULL) + if (last != NULL) /* Removing middle or tail node in list */ last->next = curr->next; else @@ -214,4 +210,3 @@ H5F__sfile_remove(H5F_shared_t *shared) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__sfile_remove() */ - diff --git a/src/H5Fspace.c b/src/H5Fspace.c index 3d969f91a6d..29495f181c3 100644 --- a/src/H5Fspace.c +++ b/src/H5Fspace.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,54 +26,44 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F__alloc * @@ -95,7 +85,7 @@ haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { - haddr_t ret_value = 0; /* Return value */ + haddr_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -107,32 +97,32 @@ H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t * HDassert(size > 0); /* Check whether the file can use temporary addresses */ - if(f->shared->use_tmp_space) { - haddr_t eoa; /* Current EOA for the file */ + if (f->shared->use_tmp_space) { + haddr_t eoa; /* Current EOA for the file */ /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if (H5F_addr_gt((eoa + size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") } /* end if */ /* Call the file driver 'alloc' routine */ ret_value = H5FD_alloc(f->shared->lf, type, f, size, frag_addr, frag_size); - if(!H5F_addr_defined(ret_value)) + if (!H5F_addr_defined(ret_value)) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, HADDR_UNDEF, "file driver 'alloc' request failed") /* Mark EOA dirty */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark EOA as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__alloc() */ - /*------------------------------------------------------------------------- * Function: H5F__free * @@ -154,7 +144,7 @@ H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t * herr_t H5F__free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -166,18 +156,17 @@ H5F__free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size) HDassert(size > 0); /* Call the file driver 'free' routine */ - if(H5FD_free(f->shared->lf, type, f, addr, size) < 0) + if (H5FD_free(f->shared->lf, type, f, addr, size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "file driver 'free' request failed") /* Mark EOA dirty */ - if(H5F_eoa_dirty(f) < 0) + if (H5F_eoa_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__free() */ - /*------------------------------------------------------------------------- * Function: H5F__try_extend * @@ -199,7 +188,7 @@ H5F__free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size) htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE @@ -211,7 +200,7 @@ H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_reques HDassert(extra_requested > 0); /* Extend the object by extending the underlying file */ - if((ret_value = H5FD_try_extend(f->shared->lf, type, f, blk_end, extra_requested)) < 0) + if ((ret_value = H5FD_try_extend(f->shared->lf, type, f, blk_end, extra_requested)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTEXTEND, FAIL, "driver try extend request failed") /* H5FD_try_extend() updates driver message and marks the superblock @@ -221,4 +210,3 @@ H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_reques done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__try_extend() */ - diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 18cd700e812..0c71dd275c6 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,47 +15,40 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#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 "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#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 "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr); static herr_t H5F__update_super_ext_driver_msg(H5F_t *f); -herr_t H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo); - /*********************/ /* Package Variables */ @@ -68,28 +61,18 @@ herr_t H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo); /* Declare a free list to manage the H5F_super_t struct */ H5FL_DEFINE(H5F_super_t); - /*******************/ /* Local Variables */ /*******************/ /* Format version bounds for superblock */ static const unsigned HDF5_superblock_ver_bounds[] = { - HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ - HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ - HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ + HDF5_SUPERBLOCK_VERSION_DEF, /* H5F_LIBVER_EARLIEST */ + HDF5_SUPERBLOCK_VERSION_2, /* H5F_LIBVER_V18 */ + HDF5_SUPERBLOCK_VERSION_3, /* H5F_LIBVER_V110 */ + HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; -/* Format version bounds for fsinfo message */ -/* This message exists starting library release v1.10 */ -static const unsigned H5O_fsinfo_ver_bounds[] = { - H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ - H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ - H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ - H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ -}; - - /*------------------------------------------------------------------------- * Function: H5F__super_ext_create * @@ -105,7 +88,7 @@ static const unsigned H5O_fsinfo_ver_bounds[] = { static herr_t H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -117,9 +100,11 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) HDassert(ext_ptr); /* Check for older version of superblock format that can't support superblock extensions */ - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers) - else if(H5F_addr_defined(f->shared->sblock->ext_addr)) + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, + "superblock extension not permitted with version %u of superblock", + f->shared->sblock->super_vers) + else if (H5F_addr_defined(f->shared->sblock->ext_addr)) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!") else { /* The superblock extension isn't actually a group, but the @@ -131,7 +116,7 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) * extension. */ H5O_loc_reset(ext_ptr); - if(H5O_create(f, (size_t)0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) + if (H5O_create(f, (size_t)0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") /* Record the address of the superblock extension */ @@ -142,7 +127,6 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_create() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_open * @@ -158,7 +142,7 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) herr_t H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -173,14 +157,13 @@ H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) ext_ptr->addr = ext_addr; /* Open the superblock extension object header */ - if(H5O_open(ext_ptr) < 0) + if (H5O_open(ext_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_open() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_close * @@ -196,8 +179,8 @@ H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -206,34 +189,33 @@ H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created) HDassert(ext_ptr); /* Check if extension was created */ - if(was_created) { + if (was_created) { /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Increment link count on superblock extension's object header */ - if(H5O_link(ext_ptr, 1) < 0) + if (H5O_link(ext_ptr, 1) < 0) HGOTO_ERROR(H5E_FILE, H5E_LINKCOUNT, FAIL, "unable to increment hard link count") /* Decrement refcount on superblock extension's object header in memory */ - if(H5O_dec_rc_by_loc(ext_ptr) < 0) + if (H5O_dec_rc_by_loc(ext_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement refcount on superblock extension"); } /* end if */ /* Twiddle the number of open objects to avoid closing the file. */ f->nopen_objs++; - if(H5O_close(ext_ptr, NULL) < 0) + if (H5O_close(ext_ptr, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension") f->nopen_objs--; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_close() */ - /*------------------------------------------------------------------------- * Function: H5F__update_super_ext_driver_msg * @@ -255,8 +237,8 @@ H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created) static herr_t H5F__update_super_ext_driver_msg(H5F_t *f) { - H5F_super_t *sblock; /* Pointer to the super block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock; /* Pointer to the super block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -271,11 +253,11 @@ H5F__update_super_ext_driver_msg(H5F_t *f) /* Update the driver information message in the superblock extension * if appropriate. */ - if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { - if(H5F_addr_defined(sblock->ext_addr)) { + if (sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + if (H5F_addr_defined(sblock->ext_addr)) { /* Check for ignoring the driver info for this file */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { - size_t driver_size; /* Size of driver info block (bytes)*/ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + size_t driver_size; /* Size of driver info block (bytes)*/ /* Check for driver info */ H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t); @@ -284,15 +266,15 @@ H5F__update_super_ext_driver_msg(H5F_t *f) * the driver info superblock extension message has * already been created. */ - if(driver_size > 0) { - H5O_drvinfo_t drvinfo; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t drvinfo; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Write the message to the superblock extension. @@ -302,18 +284,19 @@ H5F__update_super_ext_driver_msg(H5F_t *f) */ drvinfo.len = driver_size; drvinfo.buf = dbuf; - if(H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message") + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "unable to update driver info header message") } /* end if driver_size > 0 */ - } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ - } /* end if superblock extension exists */ - } /* end if sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ + } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ + } /* end if superblock extension exists */ + } /* end if sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__update_super_ext_driver_msg() */ - /*------------------------------------------------------------------------- * Function: H5F__super_read * @@ -333,20 +316,20 @@ H5F__update_super_ext_driver_msg(H5F_t *f) 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_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 */ - 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 */ - unsigned rw_flags; /* Read/write permissions for file */ - hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; + 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 */ + 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 */ + unsigned rw_flags; /* Read/write permissions for file */ + hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ #ifdef H5_HAVE_PARALLEL - int mpi_size = 1; -#endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_size = 1; +#endif /* H5_HAVE_PARALLEL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SUPERBLOCK_TAG) @@ -360,8 +343,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Find the superblock */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - if((mpi_size = H5F_mpi_get_size(f)) < 0) + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + if ((mpi_size = H5F_mpi_get_size(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") /* If we are an MPI application with at least two processes, the @@ -373,56 +356,58 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * fact that we have skipped actually calling MPI functions to determine * our MPI rank and size. */ - if(mpi_size > 1) { + if (mpi_size > 1) { MPI_Comm this_comm; - int mpi_rank; - int mpi_result; + int mpi_rank; + int mpi_result; /* Sanity check */ HDassert(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)); /* Set up MPI info */ - if((mpi_rank = H5F_mpi_get_rank(f)) < 0) + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Can't get MPI rank") - if(MPI_COMM_NULL == (this_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (this_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* Search for the file's signature only with rank 0 process */ - if(0 == mpi_rank) { + if (0 == mpi_rank) { herr_t status; /* Try detecting file's siganture */ /* (Don't leave before Bcast, to avoid hang on error) */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { status = H5FD_locate_signature(file, &super_addr); - } H5E_END_TRY; + } + H5E_END_TRY; /* Set superblock address to undefined on error */ - if(status < 0) + if (status < 0) super_addr = HADDR_UNDEF; } /* end if */ /* Broadcast superblock address to other processes */ - if(MPI_SUCCESS != (mpi_result = MPI_Bcast(&super_addr, sizeof(super_addr), MPI_BYTE, 0, this_comm))) + if (MPI_SUCCESS != (mpi_result = MPI_Bcast(&super_addr, sizeof(super_addr), MPI_BYTE, 0, this_comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) } /* end if */ else { /* Locate the signature as per per the serial library */ #endif /* H5_HAVE_PARALLEL */ - if(H5FD_locate_signature(file, &super_addr) < 0) + if (H5FD_locate_signature(file, &super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") #ifdef H5_HAVE_PARALLEL - } /* end else */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - if(!H5F_addr_defined(super_addr)) + if (!H5F_addr_defined(super_addr)) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") /* Check for userblock present */ - if(H5F_addr_gt(super_addr, 0)) { + if (H5F_addr_gt(super_addr, 0)) { /* Set the base address for the file in the VFD now */ - if(H5F__set_base_addr(f, super_addr) < 0) + if (H5F__set_base_addr(f, super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver") } /* end if */ @@ -435,32 +420,32 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) #ifdef H5_HAVE_PARALLEL rw_flags |= H5C__FLUSH_COLLECTIVELY_FLAG; #endif /* H5_HAVE_PARALLEL */ - if(!(H5F_INTENT(f) & H5F_ACC_RDWR)) + if (!(H5F_INTENT(f) & H5F_ACC_RDWR)) rw_flags |= H5AC__READ_ONLY_FLAG; /* Get the shared file creation property list */ - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "can't get property list") /* Make certain we can read the fixed-size portion of the superblock */ - if(H5F__set_eoa(f, H5FD_MEM_SUPER, - (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) + if (H5F__set_eoa(f, H5FD_MEM_SUPER, + (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "set end of space allocation request failed") /* Set up the user data for cache callbacks */ - udata.f = f; + udata.f = f; udata.ignore_drvrinfo = H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO); - udata.sym_leaf_k = 0; - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) + udata.sym_leaf_k = 0; + if (H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") - udata.stored_eof = HADDR_UNDEF; + udata.stored_eof = HADDR_UNDEF; udata.drvrinfo_removed = FALSE; /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Look up the superblock */ - if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) + if (NULL == (sblock = (H5F_super_t *)H5AC_protect(f, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock") /* @@ -487,29 +472,29 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Check to ensure that superblock version 3 is used for SWMR-write access */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version for SWMR is less than 3") } /* Upgrade low_bound to at least V18 when encountering version 2 superblock */ - if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2) f->shared->low_bound = MAX(H5F_LIBVER_V18, f->shared->low_bound); /* Upgrade low_bound to at least V110 when encountering version 3 superblock */ - if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) + if (sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); /* Version bounds check */ - if(sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + if (sblock->super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version exceeds high bound") /* Pin the superblock in the cache */ - if(H5AC_pin_protected_entry(sblock) < 0) + if (H5AC_pin_protected_entry(sblock) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTPIN, FAIL, "unable to pin superblock") /* Mark the superblock dirty if it was modified during loading */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && udata.ignore_drvrinfo && udata.drvrinfo_removed) { + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && udata.ignore_drvrinfo && udata.drvrinfo_removed) { HDassert(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2); sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -523,55 +508,52 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Check if superblock address is different from base address and adjust * base address and "end of file" address if so. */ - if(!H5F_addr_eq(super_addr, sblock->base_addr)) { - /* Check if the superblock moved earlier in the file */ - if(H5F_addr_lt(super_addr, sblock->base_addr)) - udata.stored_eof -= (sblock->base_addr - super_addr); - else - /* The superblock moved later in the file */ - udata.stored_eof += (super_addr - sblock->base_addr); + if (!H5F_addr_eq(super_addr, sblock->base_addr)) { + /* If the superblock moved in the file, adjust the EOF */ + /* (Handles moving earlier & later) */ + udata.stored_eof -= (sblock->base_addr - super_addr); /* Adjust base address for offsets of the HDF5 data in the file */ sblock->base_addr = super_addr; /* Set the base address for the file in the VFD now */ - if(H5F__set_base_addr(f, sblock->base_addr) < 0) + if (H5F__set_base_addr(f, sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver") /* Indicate that the superblock should be marked dirty */ - if((rw_flags & H5AC__READ_ONLY_FLAG) == 0) + if ((rw_flags & H5AC__READ_ONLY_FLAG) == 0) sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ /* Set information in the file's creation property list */ - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &sblock->super_vers) < 0) + if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &sblock->super_vers) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set superblock version") - if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sblock->sizeof_addr) < 0) + if (H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sblock->sizeof_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set byte number in an address") - if(H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sblock->sizeof_size) < 0) + if (H5P_set(c_plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sblock->sizeof_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set byte number for object size") /* Handle the B-tree 'K' values */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { /* Sanity check */ HDassert(udata.sym_leaf_k != 0); /* Set the symbol table internal node 'K' value */ - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &udata.sym_leaf_k) < 0) + if (H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &udata.sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") sblock->sym_leaf_k = udata.sym_leaf_k; /* Set the B-tree internal node values, etc */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) + if (H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, udata.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") H5MM_memcpy(sblock->btree_k, udata.btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); } /* end if */ else { /* Get the (default) B-tree internal node values, etc */ /* (Note: these may be reset in a superblock extension) */ - if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) + if (H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") - if(H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + if (H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") } /* end else */ @@ -579,7 +561,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * The user-defined data is the area of the file before the base * address. */ - if(H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &sblock->base_addr) < 0) + if (H5P_set(c_plist, H5F_CRT_USER_BLOCK_NAME, &sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set userblock size") /* @@ -608,28 +590,31 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Check if this private property exists in fapl */ - if(H5P_exist_plist(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) - if(H5P_get(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0) + if (H5P_exist_plist(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) + if (H5P_get(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get skip EOF check value") - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) { + if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) { /* * When the file is opened for SWMR read access, skip the check if: * --the file is already marked for SWMR writing and * --the file has version 3 superblock for SWMR support */ - if((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) && - (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && - sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) + if ((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) && + (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && + sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) skip_eof_check = TRUE; } /* end if */ - if(!skip_eof_check && initial_read) { - if(HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT))) + if (!skip_eof_check && initial_read) { + if (HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to determine file size") /* (Account for the stored EOA being absolute offset -QAK) */ - if((eof + sblock->base_addr) < udata.stored_eof) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)udata.stored_eof) + if ((eof + sblock->base_addr) < udata.stored_eof) + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, + "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", + (unsigned long long)eof, (unsigned long long)sblock->base_addr, + (unsigned long long)udata.stored_eof) } /* end if */ /* @@ -641,10 +626,10 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) H5AC_set_ring(H5AC_RING_SBE, NULL); /* Decode the optional driver information block */ - if(H5F_addr_defined(sblock->driver_addr)) { - 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 */ + if (H5F_addr_defined(sblock->driver_addr)) { + 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 */ /* Sanity check - driver info block should only be defined for * superblock version < 2. @@ -658,17 +643,19 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* extend EOA so we can read at least the fixed sized * portion of the driver info block */ - if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) /* will extend eoa later if required */ + if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < + 0) /* will extend eoa later if required */ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") /* Look up the driver info block */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, + &drvrinfo_udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load driver info block") /* Loading the driver info block is enough to set up the right info */ /* Check if we need to rewrite the driver info block info */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) drvinfo_flags |= H5AC__DIRTIED_FLAG; /* set the pin entry flag so that the driver information block @@ -677,7 +664,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) drvinfo_flags |= H5AC__PIN_ENTRY_FLAG; /* Release the driver info block */ - if(H5AC_unprotect(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) + if (H5AC_unprotect(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, drvinfo_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to release driver info block") /* save a pointer to the driver information cache entry */ @@ -685,16 +672,16 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) } /* end if */ /* (Account for the stored EOA being absolute offset -NAF) */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, udata.stored_eof - sblock->base_addr) < 0) + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, udata.stored_eof - sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set end-of-address marker for file") /* Decode the optional superblock extension info */ - if(H5F_addr_defined(sblock->ext_addr)) { - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ - H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ - size_t u; /* Local index variable */ - htri_t status; /* Status for message existing */ + if (H5F_addr_defined(sblock->ext_addr)) { + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_btreek_t btreek; /* v1 B-tree 'K' value message from superblock extension */ + H5O_drvinfo_t drvinfo; /* Driver info message from superblock extension */ + size_t u; /* Local index variable */ + htri_t status; /* Status for message existing */ /* Sanity check - superblock extension should only be defined for * superblock version >= 2. @@ -704,32 +691,32 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Check for superblock extension being located "outside" the stored * 'eoa' value, which can occur with the split/multi VFD. */ - if(H5F_addr_gt(sblock->ext_addr, udata.stored_eof)) { + if (H5F_addr_gt(sblock->ext_addr, udata.stored_eof)) { /* Set the 'eoa' for the object header memory type large enough * to give some room for a reasonably sized superblock extension. * (This is _rather_ a kludge -QAK) */ - if(H5F__set_eoa(f, H5FD_MEM_OHDR, (haddr_t)(sblock->ext_addr + 1024)) < 0) + if (H5F__set_eoa(f, H5FD_MEM_OHDR, (haddr_t)(sblock->ext_addr + 1024)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set end-of-address marker for file") } /* end if */ /* Open the superblock extension */ - if(H5F__super_ext_open(f, sblock->ext_addr, &ext_loc) < 0) + if (H5F__super_ext_open(f, sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") /* Check for the extension having a 'driver info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { + if (status) { /* Check for ignoring the driver info for this file */ - if(!udata.ignore_drvrinfo) { + if (!udata.ignore_drvrinfo) { /* Retrieve the 'driver info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo)) + if (NULL == H5O_msg_read(&ext_loc, H5O_DRVINFO_ID, &drvinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") /* Validate and decode driver information */ - if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { + if (H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "unable to decode driver information") } /* end if */ @@ -740,148 +727,157 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) HDassert(FALSE == f->shared->drvinfo_sb_msg_exists); f->shared->drvinfo_sb_msg_exists = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Read in the shared OH message information if there is any */ - if(H5SM_get_info(&ext_loc, c_plist) < 0) + if (H5SM_get_info(&ext_loc, c_plist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to read SOHM table information") /* Check for the extension having a 'v1 B-tree "K"' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_BTREEK_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { + if (status) { /* Retrieve the 'v1 B-tree "K"' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek)) + if (NULL == H5O_msg_read(&ext_loc, H5O_BTREEK_ID, &btreek)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "v1 B-tree 'K' info message not present") /* Set non-default v1 B-tree 'K' value info from file */ sblock->btree_k[H5B_CHUNK_ID] = btreek.btree_k[H5B_CHUNK_ID]; sblock->btree_k[H5B_SNODE_ID] = btreek.btree_k[H5B_SNODE_ID]; - sblock->sym_leaf_k = btreek.sym_leaf_k; + sblock->sym_leaf_k = btreek.sym_leaf_k; /* Set non-default v1 B-tree 'K' values in the property list */ - if(H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) + if (H5P_set(c_plist, H5F_CRT_BTREE_RANK_NAME, btreek.btree_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes") - if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) + if (H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set rank for symbol table leaf nodes") } /* end if */ /* Check for the extension having a 'free-space manager info' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { - uint8_t flags; /* Message flags */ + if (status) { + uint8_t flags; /* Message flags */ /* Get message flags */ - if(H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to message flags for free-space manager info message") + if (H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to message flags for free-space manager info message") /* If message is NOT marked "unknown"--set up file space info */ - if(!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { - H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */ - hbool_t null_fsm_addr = FALSE; /* Whether to drop free-space to the floor */ + if (!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { + H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */ + /* f->shared->null_fsm_addr: Whether to drop free-space to the floor */ /* The h5clear tool uses this property to tell the library * to drop free-space to the floor */ - if(H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) - if(H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &null_fsm_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr") + if (H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) + if (H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &f->shared->null_fsm_addr) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, + "can't get clearance for persisting fsm addr") /* Retrieve the 'file space info' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) + if (NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message") /* Version bounds check */ - if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION || - fsinfo.version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)]) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + if (H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, + "File space info message's version out of bounds") /* Update changed values */ - if(f->shared->fs_version != fsinfo.version) + if (f->shared->fs_version != fsinfo.version) f->shared->fs_version = fsinfo.version; - if(f->shared->fs_strategy != fsinfo.strategy) { + if (f->shared->fs_strategy != fsinfo.strategy) { f->shared->fs_strategy = fsinfo.strategy; /* Set non-default strategy in the property list */ - if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) + if (H5P_set(c_plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &fsinfo.strategy) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ - if(f->shared->fs_persist != fsinfo.persist) { + if (f->shared->fs_persist != fsinfo.persist) { f->shared->fs_persist = fsinfo.persist; /* Set non-default strategy in the property list */ - if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &fsinfo.persist) < 0) + if (H5P_set(c_plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &fsinfo.persist) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ - if(f->shared->fs_threshold != fsinfo.threshold) { + if (f->shared->fs_threshold != fsinfo.threshold) { f->shared->fs_threshold = fsinfo.threshold; /* Set non-default threshold in the property list */ - if(H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) + if (H5P_set(c_plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &fsinfo.threshold) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space strategy") } /* end if */ HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); HDassert(fsinfo.page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); - if(f->shared->fs_page_size != fsinfo.page_size) { + if (f->shared->fs_page_size != fsinfo.page_size) { f->shared->fs_page_size = fsinfo.page_size; /* Set file space page size in the property list */ - if(H5P_set(c_plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsinfo.page_size) < 0) + if (H5P_set(c_plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsinfo.page_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file space page size") } /* end if */ - if(f->shared->pgend_meta_thres != fsinfo.pgend_meta_thres) + if (f->shared->pgend_meta_thres != fsinfo.pgend_meta_thres) /* Initialize page end meta threshold */ f->shared->pgend_meta_thres = fsinfo.pgend_meta_thres; - if(f->shared->eoa_pre_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc) - f->shared->eoa_pre_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc; + if (f->shared->eoa_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc) + f->shared->eoa_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc; - /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF - * in the absence of persistent free space managers. - */ - /* If the following two conditions are true: + /* + * If the following two conditions are true: * (1) skipping EOF check (skip_eof_check) - * (2) dropping free-space to the floor (null_fsm_addr) - * skip the asserts as "eoa_pre_fsm_fsalloc" may be undefined + * (2) dropping free-space to the floor (f->shared->null_fsm_addr) + * skip the asserts as "eoa_fsm_fsalloc" may be undefined * for a crashed file with persistent free space managers. - * #1 and #2 are enabled when the tool h5clear --increment + * The above two conditions are enabled when the tool h5clear --increment * option is used. */ - if(!skip_eof_check && !null_fsm_addr) { - HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF)); - HDassert(!f->shared->first_alloc_dealloc); - } /* end if */ - - /* As "eoa_pre_fsm_fsalloc" may be undefined for a crashed file - * with persistent free space managers, therefore, set - * "first_alloc_dealloc" when the condition - * "dropping free-space to the floor is true. - * This will ensure that no action is done to settle things on file - * close via H5MF_settle_meta_data_fsm() and H5MF_settle_raw_data_fsm(). + if (!skip_eof_check && !f->shared->null_fsm_addr) + HDassert((!f->shared->fs_persist) || (f->shared->eoa_fsm_fsalloc != HADDR_UNDEF)); + + /* + * A crashed file with persistent free-space managers may have + * undefined f->shared->eoa_fsm_fsalloc. + * eoa_fsm_fsalloc is the final eoa which is saved in the free-space + * info message's eoa_pre_fsm_fsalloc field for backward compatibility. + * If the tool h5clear sets to dropping free-space to the floor + * as indicated by f->shared->null_fsm_addr, we are not going to + * perform actions to settle things on file close in the routines + * H5MF_settle_meta_data_fsm() and H5MF_settle_raw_data_fsm(). + * + * We remove the following check: + * if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF || null_fsm_addr) && + * (H5F_INTENT(f) & H5F_ACC_RDWR)) + * f->shared->first_alloc_dealloc = TRUE; + * + * Because: + * --there is no more f->shared->eoa_pre_fsm_fsalloc and + * f->shared->first_alloc_dealloc + * --the check for null_fsm_addr is directly done in H5MF_settle_meta_data_fsm() + * and H5MF_settle_raw_data_fsm() */ - if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF || null_fsm_addr) && - (H5F_INTENT(f) & H5F_ACC_RDWR)) - f->shared->first_alloc_dealloc = TRUE; f->shared->fs_addr[0] = HADDR_UNDEF; - for(u = 1; u < NELMTS(f->shared->fs_addr); u++) + for (u = 1; u < NELMTS(f->shared->fs_addr); u++) f->shared->fs_addr[u] = fsinfo.fs_addr[u - 1]; /* If the following two conditions are true: * (1) file is persisting free-space - * (2) dropping free-space to the floor (null_fsm_addr) + * (2) dropping free-space to the floor (f->shared->null_fsm_addr) * nullify the addresses of the FSMs */ - if(f->shared->fs_persist && null_fsm_addr) - for(u = 0; u < NELMTS(fsinfo.fs_addr); u++) + if (f->shared->fs_persist && f->shared->null_fsm_addr) + for (u = 0; u < NELMTS(fsinfo.fs_addr); u++) f->shared->fs_addr[u] = fsinfo.fs_addr[u] = HADDR_UNDEF; /* For fsinfo.mapped: remove the FSINFO message from the superblock extension and write a new message to the extension */ - /* For null_fsm_addr: just update FSINFO message in the superblock extension */ - if(((fsinfo.mapped || null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) { + /* For f->shared->null_fsm_addr: just update FSINFO message in the superblock extension */ + if (((fsinfo.mapped || f->shared->null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) { /* Do the same kluge until we know for sure. VC */ #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ @@ -891,35 +887,45 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * be set -- verify that it is NULL, and then set it. * Set it back to NULL when we are done. */ - HDassert(f->shared->sblock == NULL); - f->shared->sblock = sblock; + HDassert(f->shared->sblock == NULL); + f->shared->sblock = sblock; #endif /* JRM */ - if(null_fsm_addr) { - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") + if (f->shared->null_fsm_addr) { + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, + H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") } else { - if(H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension") + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) { +#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ + f->shared->sblock = NULL; +#endif /* JRM */ + + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, + "error in removing message from superblock extension") + } - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, + H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") } #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; #endif /* JRM */ } /* end if */ - } /* end if not marked "unknown" */ - } /* end if */ + } /* end if not marked "unknown" */ + } /* end if */ /* Check for the extension having a 'metadata cache image' message */ - if((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID)) < 0) + if ((status = H5O_msg_exists(&ext_loc, H5O_MDCI_MSG_ID)) < 0) HGOTO_ERROR(H5E_FILE, H5E_EXISTS, FAIL, "unable to read object header") - if(status) { - hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); - H5O_mdci_t mdci_msg; + if (status) { + hbool_t rw = ((rw_flags & H5AC__READ_ONLY_FLAG) == 0); + H5O_mdci_t mdci_msg; /* if the metadata cache image superblock extension message exists, * read its contents and pass the data on to the metadata cache. @@ -934,16 +940,17 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) */ /* Retrieve the 'metadata cache image message' structure */ - if(NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg)) + if (NULL == H5O_msg_read(&ext_loc, H5O_MDCI_MSG_ID, &mdci_msg)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache image message") /* Indicate to the cache that there's an image to load on first protect call */ - if(H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "call to H5AC_load_cache_image_on_next_protect failed"); + if (H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, + "call to H5AC_load_cache_image_on_next_protect failed"); } /* end if */ /* Close superblock extension */ - if(H5F__super_ext_close(f, &ext_loc, FALSE) < 0) + if (H5F__super_ext_close(f, &ext_loc, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close file's superblock extension") } /* end if */ @@ -951,24 +958,23 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* (NOTE: only for later versions of superblock, earlier versions are handled * earlier in this routine. */ - if(((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && - sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && - H5F_addr_defined(sblock->ext_addr)) { + if (((rw_flags & H5AC__READ_ONLY_FLAG) == 0) && sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && + H5F_addr_defined(sblock->ext_addr)) { /* Check for modifying the driver info when opening the file */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) { - size_t driver_size; /* Size of driver info block (bytes) */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_DIRTY_DRVRINFO_LOAD)) { + size_t driver_size; /* Size of driver info block (bytes) */ /* Check for driver info message */ H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t); - if(driver_size > 0) { - H5O_drvinfo_t drvinfo; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t drvinfo; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Set the driver info information for the superblock extension */ @@ -987,73 +993,74 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) HDassert(f->shared->sblock == NULL); f->shared->sblock = sblock; #endif /* JRM */ - if(H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, FALSE, H5O_MSG_NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; #endif /* JRM */ } /* end if */ - } /* end if */ + } /* end if */ /* Check for eliminating the driver info block */ - else if(H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { + else if (H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { /* Remove the driver info message from the superblock extension */ - if(H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension") + if (H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") /* Check if the superblock extension was removed */ - if(!H5F_addr_defined(sblock->ext_addr)) + if (!H5F_addr_defined(sblock->ext_addr)) sblock_flags |= H5AC__DIRTIED_FLAG; } /* end if */ - } /* end if */ + } /* end if */ /* Set the pointer to the pinned superblock */ f->shared->sblock = sblock; /* Set the page aggregation mode */ - if(H5F__set_paged_aggr(f, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + if (H5F__set_paged_aggr(f, (hbool_t)H5F_PAGED_AGGR(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set paged_aggr status for file driver") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release the superblock */ - if(sblock && H5AC_unprotect(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) + if (sblock && H5AC_unprotect(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") /* If we have failed, make sure no entries are left in the * metadata cache, so that it can be shut down and discarded. */ - if(ret_value < 0) { + if (ret_value < 0) { /* Unpin and discard drvinfo cache entry */ - if(f->shared->drvinfo) { - if(H5AC_unpin_entry(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) { + if (H5AC_unpin_entry(f->shared->drvinfo) < 0) 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 (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 */ /* Unpin & discard superblock */ - if(sblock) { + if (sblock) { /* Unpin superblock in cache */ - if(H5AC_unpin_entry(sblock) < 0) + if (H5AC_unpin_entry(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5F__super_read() */ - /*------------------------------------------------------------------------- * Function: H5F__super_init * @@ -1072,51 +1079,52 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) herr_t H5F__super_init(H5F_t *f) { - H5F_super_t *sblock = NULL; /* Superblock cache structure */ - hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */ - H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ - hbool_t drvinfo_in_cache = 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 */ - 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 */ - hbool_t need_ext; /* Whether the superblock extension is needed */ - hbool_t ext_created = FALSE; /* Whether the extension has been created */ - hbool_t non_default_fs_settings = FALSE; /* Whether the file has non-default free-space settings */ - herr_t ret_value = SUCCEED; /* Return Value */ + H5F_super_t *sblock = NULL; /* Superblock cache structure */ + hbool_t sblock_in_cache = FALSE; /* Whether the superblock has been inserted into the metadata cache */ + H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ + hbool_t drvinfo_in_cache = + 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 */ + 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 */ + hbool_t need_ext; /* Whether the superblock extension is needed */ + hbool_t ext_created = FALSE; /* Whether the extension has been created */ + hbool_t non_default_fs_settings = FALSE; /* Whether the file has non-default free-space settings */ + herr_t ret_value = SUCCEED; /* Return Value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SUPERBLOCK_TAG) /* Allocate space for the superblock */ - if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize various address information */ - sblock->base_addr = HADDR_UNDEF; - sblock->ext_addr = HADDR_UNDEF; + sblock->base_addr = HADDR_UNDEF; + sblock->ext_addr = HADDR_UNDEF; sblock->driver_addr = HADDR_UNDEF; - sblock->root_addr = HADDR_UNDEF; + sblock->root_addr = HADDR_UNDEF; /* Get the shared file creation property list */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Initialize sym_leaf_k */ - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size") /* Initialize btree_k */ - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes") /* Check for non-default free-space settings */ - if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) + if (!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) non_default_fs_settings = TRUE; /* @@ -1149,12 +1157,13 @@ H5F__super_init(H5F_t *f) * Creating a file with SWMR-write access will * upgrade superblock version and low_bound */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { - super_vers = HDF5_SUPERBLOCK_VERSION_3; + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) { + super_vers = HDF5_SUPERBLOCK_VERSION_3; f->shared->low_bound = MAX(H5F_LIBVER_V110, f->shared->low_bound); - /* Bump superblock version to create superblock extension for SOHM info */ - } else if(f->shared->sohm_nindexes > 0) + /* Bump superblock version to create superblock extension for SOHM info */ + } + else if (f->shared->sohm_nindexes > 0) super_vers = HDF5_SUPERBLOCK_VERSION_2; /* * Bump superblock version to create superblock extension for: @@ -1163,33 +1172,33 @@ H5F__super_init(H5F_t *f) * -- non-default free-space threshold or * -- non-default page_size */ - else if(non_default_fs_settings) + else if (non_default_fs_settings) super_vers = HDF5_SUPERBLOCK_VERSION_2; /* Check for non-default indexed storage B-tree internal 'K' value * and set the version # of the superblock to 1 if it is a non-default * value. */ - else if(sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) + else if (sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF) super_vers = HDF5_SUPERBLOCK_VERSION_1; /* Finalize superblock version to that allowed by the file's low bound if higher */ super_vers = MAX(super_vers, HDF5_superblock_ver_bounds[f->shared->low_bound]); /* Version bounds check */ - if(super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) + if (super_vers > HDF5_superblock_ver_bounds[f->shared->high_bound]) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "superblock version out of bounds") /* If a newer superblock version is required, set it here */ - if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { - H5P_genplist_t *c_plist; /* Property list */ + if (super_vers != HDF5_SUPERBLOCK_VERSION_DEF) { + H5P_genplist_t *c_plist; /* Property list */ - if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") - if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version") } /* end if */ - if(H5FD_set_paged_aggr(f->shared->lf, (hbool_t)H5F_PAGED_AGGR(f)) < 0) + if (H5FD_set_paged_aggr(f->shared->lf, (hbool_t)H5F_PAGED_AGGR(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set paged_aggr status for file driver") /* @@ -1198,35 +1207,36 @@ H5F__super_init(H5F_t *f) * base address is set to the same thing as the superblock for * now. */ - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get userblock size") /* Sanity check the userblock size vs. the file's allocation alignment */ - if(userblock_size > 0) { + if (userblock_size > 0) { /* Set up the alignment to use for page or aggr fs */ hsize_t alignment = H5F_PAGED_AGGR(f) ? f->shared->fs_page_size : f->shared->alignment; - if(userblock_size < alignment) + if (userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment") - if(0 != (userblock_size % alignment)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment") + if (0 != (userblock_size % alignment)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "userblock size must be an integral multiple of file object alignment") } /* end if */ - sblock->base_addr = userblock_size; + sblock->base_addr = userblock_size; sblock->status_flags = 0; /* Reserve space for the userblock */ - if(H5F__set_eoa(f, H5FD_MEM_SUPER, userblock_size) < 0) + if (H5F__set_eoa(f, H5FD_MEM_SUPER, userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for userblock") /* Set the base address for the file in the VFD now, after allocating * space for userblock. */ - if(H5F__set_base_addr(f, sblock->base_addr) < 0) + if (H5F__set_base_addr(f, sblock->base_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "failed to set base address for file driver") /* Save a local copy of the superblock version number, size of addresses & offsets */ - sblock->super_vers = super_vers; + sblock->super_vers = super_vers; sblock->sizeof_addr = f->shared->sizeof_addr; sblock->sizeof_size = f->shared->sizeof_size; @@ -1240,12 +1250,12 @@ H5F__super_init(H5F_t *f) * for the driver info block, and sets the driver info block * address regardless of the version of the superblock. */ - if(driver_size > 0) { + if (driver_size > 0) { /* Add in the driver info header, for older superblocks */ /* Superblock versions >= 2 will put the driver info in a message * and don't need the header -QAK, 1/4/2017 */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) + if (super_vers < HDF5_SUPERBLOCK_VERSION_2) driver_size += H5F_DRVINFOBLOCK_HDR_SIZE; /* @@ -1261,14 +1271,15 @@ H5F__super_init(H5F_t *f) * at the beginning of the file and only the first allocation request is * required to return memory at format address zero. */ - if(super_vers < HDF5_SUPERBLOCK_VERSION_2) + if (super_vers < HDF5_SUPERBLOCK_VERSION_2) superblock_size += driver_size; /* Set the ring type in the API context */ H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Insert superblock into cache, pinned */ - if(H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache") sblock_in_cache = TRUE; @@ -1276,8 +1287,8 @@ 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)) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock") + if (HADDR_UNDEF == 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 */ f->shared->drvinfo = NULL; @@ -1287,12 +1298,12 @@ H5F__super_init(H5F_t *f) */ /* Files with SOHM indices always need the superblock extension */ - if(f->shared->sohm_nindexes > 0) { + if (f->shared->sohm_nindexes > 0) { HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); need_ext = TRUE; } /* end if */ /* Files with non-default free space settings always need the superblock extension */ - else if(non_default_fs_settings) { + else if (non_default_fs_settings) { HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2); need_ext = TRUE; } /* end if */ @@ -1300,14 +1311,14 @@ H5F__super_init(H5F_t *f) * for the superblock extension, check for non-default values to store * in it. */ - else if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + else if (super_vers >= HDF5_SUPERBLOCK_VERSION_2) { /* Check for non-default v1 B-tree 'K' values to store */ - if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) + if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) need_ext = TRUE; /* Check for driver info to store */ - else if(driver_size > 0) + else if (driver_size > 0) need_ext = TRUE; else need_ext = FALSE; @@ -1319,7 +1330,7 @@ H5F__super_init(H5F_t *f) H5AC_set_ring(H5AC_RING_SBE, NULL); /* Create the superblock extension for "extra" superblock data, if necessary. */ - if(need_ext) { + if (need_ext) { /* The superblock extension isn't actually a group, but the * default group creation list should work fine. * If we don't supply a size for the object header, HDF5 will @@ -1328,50 +1339,52 @@ H5F__super_init(H5F_t *f) * be tuned if more information is added to the superblock * extension. */ - if(H5F__super_ext_create(f, &ext_loc) < 0) + if (H5F__super_ext_create(f, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension") ext_created = TRUE; /* Create the Shared Object Header Message table and register it with * the metadata cache, if this file supports shared messages. */ - if(f->shared->sohm_nindexes > 0) { + if (f->shared->sohm_nindexes > 0) { /* Initialize the shared message code & write the SOHM message to the extension */ - if(H5SM_init(f, plist, &ext_loc) < 0) + if (H5SM_init(f, plist, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create SOHM table") } /* Check for non-default v1 B-tree 'K' values to store */ - if(sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || - sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || - sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { - H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */ + if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || + sblock->btree_k[H5B_CHUNK_ID] != HDF5_BTREE_CHUNK_IK_DEF || + sblock->sym_leaf_k != H5F_CRT_SYM_LEAF_DEF) { + H5O_btreek_t btreek; /* v1 B-tree 'K' value message for superblock extension */ /* Write v1 B-tree 'K' value information to the superblock extension */ btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID]; btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID]; - btreek.sym_leaf_k = sblock->sym_leaf_k; - if(H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message") + btreek.sym_leaf_k = sblock->sym_leaf_k; + if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &btreek) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, + "unable to update v1 B-tree 'K' value header message") } /* end if */ /* Check for driver info to store */ - if(driver_size > 0) { - H5O_drvinfo_t info; /* Driver info */ - uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ + if (driver_size > 0) { + H5O_drvinfo_t info; /* Driver info */ + uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); /* Encode driver-specific data */ HDmemset(dbuf, 0, sizeof(dbuf)); - if(H5FD_sb_encode(f->shared->lf, info.name, dbuf) < 0) + if (H5FD_sb_encode(f->shared->lf, info.name, dbuf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Write driver info information to the superblock extension */ info.len = driver_size; info.buf = dbuf; - if(H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &info) < 0) + if (H5O_msg_create(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update driver info header message") HDassert(FALSE == f->shared->drvinfo_sb_msg_exists); @@ -1379,39 +1392,40 @@ H5F__super_init(H5F_t *f) } /* end if */ /* Check for non-default free-space info settings */ - if(non_default_fs_settings) { + if (non_default_fs_settings) { H5F_mem_page_t ptype; - H5O_fsinfo_t fsinfo; /* Free space manager info message */ + H5O_fsinfo_t fsinfo; /* Free space manager info message */ /* Write free-space manager info message to superblock extension object header if needed */ - 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.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; - fsinfo.mapped = FALSE; + fsinfo.mapped = FALSE; /* Set the version for the fsinfo message */ - if(H5O__fsinfo_set_version(f, &fsinfo) < 0) + if (H5O_fsinfo_set_version(H5F_LOW_BOUND(f), H5F_HIGH_BOUND(f), &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set version of fsinfo") f->shared->fs_version = fsinfo.version; - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &fsinfo) < 0) + if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, + H5O_UPDATE_TIME, &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message") - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Check for creating an "old-style" driver info block */ - if(driver_size > 0) { + if (driver_size > 0) { /* Sanity check */ HDassert(H5F_addr_defined(sblock->driver_addr)); /* Allocate space for the driver info */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for driver info message") /* Set up driver info message */ @@ -1423,9 +1437,11 @@ H5F__super_init(H5F_t *f) H5_CHECKED_ASSIGN(drvinfo->len, size_t, H5FD_sb_size(f->shared->lf), hsize_t); /* Insert driver info block into cache */ - if(H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | + H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add driver info block to cache") - drvinfo_in_cache = TRUE; + drvinfo_in_cache = TRUE; f->shared->drvinfo = drvinfo; } /* end if */ else @@ -1434,25 +1450,25 @@ H5F__super_init(H5F_t *f) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close superblock extension, if it was created */ - if(ext_created && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) + if (ext_created && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") /* Cleanup on failure */ - if(ret_value < 0) { + if (ret_value < 0) { /* Check if the driver info block has been allocated yet */ - if(drvinfo) { + if (drvinfo) { /* Check if we've cached it already */ - if(drvinfo_in_cache) { + if (drvinfo_in_cache) { /* Unpin drvinfo in cache */ - if(H5AC_unpin_entry(drvinfo) < 0) + if (H5AC_unpin_entry(drvinfo) < 0) 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 (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 */ else @@ -1461,31 +1477,30 @@ H5F__super_init(H5F_t *f) } /* end if */ /* Check if the superblock has been allocated yet */ - if(sblock) { + if (sblock) { /* Check if we've cached it already */ - if(sblock_in_cache) { + if (sblock_in_cache) { /* Unpin superblock in cache */ - if(H5AC_unpin_entry(sblock) < 0) + if (H5AC_unpin_entry(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ else /* Free superblock */ - if(H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") + if (H5F__super_free(sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") /* Reset variables in file structure */ f->shared->sblock = NULL; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5F__super_init() */ - /*------------------------------------------------------------------------- * Function: H5F_eoa_dirty * @@ -1502,7 +1517,7 @@ H5F__super_init(H5F_t *f) herr_t H5F_eoa_dirty(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1512,20 +1527,20 @@ H5F_eoa_dirty(H5F_t *f) HDassert(f->shared->sblock); /* Mark superblock dirty in cache, so change to EOA will get encoded */ - if(H5F_super_dirty(f) < 0) + if (H5F_super_dirty(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") /* If the driver information block exists, mark it dirty as well * so that the change in eoa will be reflected there as well if * appropriate. */ - if(f->shared->drvinfo) { - if(H5AC_mark_entry_dirty(f->shared->drvinfo) < 0) + if (f->shared->drvinfo) { + if (H5AC_mark_entry_dirty(f->shared->drvinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark drvinfo as dirty") } /* end if */ /* If the driver info is stored as a message, update that instead */ - else if(f->shared->drvinfo_sb_msg_exists) { - if(H5F__update_super_ext_driver_msg(f) < 0) + else if (f->shared->drvinfo_sb_msg_exists) { + if (H5F__update_super_ext_driver_msg(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark drvinfo message as dirty") } @@ -1533,7 +1548,6 @@ H5F_eoa_dirty(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* H5F_eoa_dirty() */ - /*------------------------------------------------------------------------- * Function: H5F_super_dirty * @@ -1550,7 +1564,7 @@ H5F_eoa_dirty(H5F_t *f) herr_t H5F_super_dirty(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1560,14 +1574,13 @@ H5F_super_dirty(H5F_t *f) HDassert(f->shared->sblock); /* Mark superblock dirty in cache, so change to EOA will get encoded */ - if(H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (H5AC_mark_entry_dirty(f->shared->sblock) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_super_dirty() */ - /*------------------------------------------------------------------------- * Function: H5F__super_free * @@ -1598,7 +1611,6 @@ H5F__super_free(H5F_super_t *sblock) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F__super_free() */ - /*------------------------------------------------------------------------- * Function: H5F__super_size * @@ -1615,8 +1627,8 @@ H5F__super_free(H5F_super_t *sblock) herr_t H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1626,14 +1638,14 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) HDassert(f->shared->sblock); /* Set the superblock size */ - if(super_size) - *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock); + if (super_size) + *super_size = (hsize_t)H5F_SUPERBLOCK_SIZE(f->shared->sblock); /* Set the superblock extension size */ - if(super_ext_size) { - if(H5F_addr_defined(f->shared->sblock->ext_addr)) { - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - H5O_hdr_info_t hdr_info; /* Object info for superblock extension */ + if (super_ext_size) { + if (H5F_addr_defined(f->shared->sblock->ext_addr)) { + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_hdr_info_t hdr_info; /* Object info for superblock extension */ /* Set up "fake" object location for superblock extension */ H5O_loc_reset(&ext_loc); @@ -1644,7 +1656,7 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Get object header info for superblock extension */ - if(H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) + if (H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info") /* Set the superblock extension size */ @@ -1657,13 +1669,12 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_size() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_write_msg() * @@ -1676,15 +1687,14 @@ H5F__super_size(H5F_t *f, hsize_t *super_size, hsize_t *super_ext_size) *------------------------------------------------------------------------- */ herr_t -H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, - hbool_t may_create, unsigned mesg_flags) +H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - hbool_t ext_created = FALSE; /* Whether superblock extension was created */ - hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */ - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - htri_t status; /* Indicate whether the message exists or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + hbool_t ext_created = FALSE; /* Whether superblock extension was created */ + hbool_t ext_opened = FALSE; /* Whether superblock extension was opened */ + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + htri_t status; /* Indicate whether the message exists or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1697,13 +1707,13 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Open/create the superblock extension object header */ - if(H5F_addr_defined(f->shared->sblock->ext_addr)) { - if(H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) + if (H5F_addr_defined(f->shared->sblock->ext_addr)) { + if (H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension") } /* end if */ else { HDassert(may_create); - if(H5F__super_ext_create(f, &ext_loc) < 0) + if (H5F__super_ext_create(f, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension") ext_created = TRUE; } /* end else */ @@ -1711,44 +1721,44 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, ext_opened = TRUE; /* Check if message with ID does not exist in the object header */ - if((status = H5O_msg_exists(&ext_loc, id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check object header for message or message exists") + if ((status = H5O_msg_exists(&ext_loc, id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to check object header for message or message exists") /* Check for creating vs. writing */ - if(may_create) { - if(status) + if (may_create) { + if (status) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist") /* Create the message with ID in the superblock extension */ - if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) + if (H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to create the message in object header") } /* end if */ else { - if(!status) + if (!status) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist") /* Update the message with ID in the superblock extension */ - if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) + if (H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to write the message in object header") } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close the superblock extension, if it was opened */ - if(ext_opened && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) + if (ext_opened && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") /* Mark superblock dirty in cache, if superblock extension was created */ - if(ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_write_msg() */ - /*------------------------------------------------------------------------- * Function: H5F__super_ext_remove_msg * @@ -1763,12 +1773,12 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5O_loc_t ext_loc; /* "Object location" for superblock extension */ - hbool_t ext_opened = FALSE; /* Whether the superblock extension was opened */ - int null_count = 0; /* # of null messages */ - htri_t status; /* Indicate whether the message exists or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + hbool_t ext_opened = FALSE; /* Whether the superblock extension was opened */ + int null_count = 0; /* # of null messages */ + htri_t status; /* Indicate whether the message exists or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1779,88 +1789,46 @@ H5F__super_ext_remove_msg(H5F_t *f, unsigned id) H5AC_set_ring(H5AC_RING_SBE, &orig_ring); /* Open superblock extension object header */ - if(H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) + if (H5F__super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in starting file's superblock extension") ext_opened = TRUE; /* Check if message with ID exists in the object header */ - if((status = H5O_msg_exists(&ext_loc, id)) < 0) + if ((status = H5O_msg_exists(&ext_loc, id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message") - else if(status) { + else if (status) { /* message exists */ - H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */ + H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */ /* Remove the message */ - if(H5O_msg_remove(&ext_loc, id, H5O_ALL, TRUE) < 0) + if (H5O_msg_remove(&ext_loc, id, H5O_ALL, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete free-space manager info message") /* Get info for the superblock extension's object header */ - if(H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) + if (H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info") /* If the object header is an empty base chunk, remove superblock extension */ - if(hdr_info.nchunks == 1) { - if((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID)) < 0) + if (hdr_info.nchunks == 1) { + if ((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages") - else if((unsigned)null_count == hdr_info.nmesgs) { + else if ((unsigned)null_count == hdr_info.nmesgs) { HDassert(H5F_addr_defined(ext_loc.addr)); - if(H5O_delete(f, ext_loc.addr) < 0) + if (H5O_delete(f, ext_loc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages") f->shared->sblock->ext_addr = HADDR_UNDEF; } /* end else-if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Close superblock extension object header, if opened */ - if(ext_opened && H5F__super_ext_close(f, &ext_loc, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") + if (ext_opened && H5F__super_ext_close(f, &ext_loc, FALSE) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_remove_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5O__fsinfo_set_version - * - * Purpose: Set the version to encode the fsinfo message with. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi; June 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo) -{ - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(f); - HDassert(fsinfo); - - version = H5O_FSINFO_VERSION_1; - - /* Upgrade to the version indicated by the file's low bound if higher */ - if(H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)] != H5O_INVALID_VERSION) - version = MAX(version, H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)]); - - /* Version bounds check */ - if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION || - version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)]) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") - - /* Set the message version */ - fsinfo->version = version; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__fsinfo_set_version() */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 329bf211b51..28ff82f8452 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,73 +26,61 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache (H5AC) callbacks */ static herr_t H5F__cache_superblock_get_initial_load_size(void *udata, size_t *image_len); -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 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_serialize(const H5F_t *f, void *image, size_t len, void *thing); 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 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 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_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5F__cache_drvrinfo_free_icr(void *thing); /* Local encode/decode routines */ -static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, - const uint8_t **image_ref, const H5F_superblock_cache_ud_t *udata, - hbool_t extend_eoa); -static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name, - const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata, - hbool_t extend_eoa); - +static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, + const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa); +static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name, const uint8_t **image_ref, + H5F_drvrinfo_cache_ud_t *udata, hbool_t extend_eoa); /*********************/ /* Package Variables */ @@ -100,41 +88,40 @@ static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name /* H5F superblock inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SUPERBLOCK[1] = {{ - H5AC_SUPERBLOCK_ID, /* Metadata client ID */ - "Superblock", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5F__cache_superblock_get_initial_load_size,/* 'get_initial_load_size' callback */ - H5F__cache_superblock_get_final_load_size, /* 'get_final_load_size' callback */ - H5F__cache_superblock_verify_chksum, /* 'verify_chksum' callback */ - H5F__cache_superblock_deserialize, /* 'deserialize' callback */ - H5F__cache_superblock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5F__cache_superblock_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5F__cache_superblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_SUPERBLOCK_ID, /* Metadata client ID */ + "Superblock", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5F__cache_superblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5F__cache_superblock_get_final_load_size, /* 'get_final_load_size' callback */ + H5F__cache_superblock_verify_chksum, /* 'verify_chksum' callback */ + H5F__cache_superblock_deserialize, /* 'deserialize' callback */ + H5F__cache_superblock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5F__cache_superblock_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5F__cache_superblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5F driver info block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_DRVRINFO[1] = {{ - H5AC_DRVRINFO_ID, /* Metadata client ID */ - "Driver info block", /* Metadata client name (for debugging) */ - H5FD_MEM_SUPER, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5F__cache_drvrinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5F__cache_drvrinfo_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5F__cache_drvrinfo_deserialize, /* 'deserialize' callback */ - H5F__cache_drvrinfo_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5F__cache_drvrinfo_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5F__cache_drvrinfo_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_DRVRINFO_ID, /* Metadata client ID */ + "Driver info block", /* Metadata client name (for debugging) */ + H5FD_MEM_SUPER, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5F__cache_drvrinfo_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5F__cache_drvrinfo_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5F__cache_drvrinfo_deserialize, /* 'deserialize' callback */ + H5F__cache_drvrinfo_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5F__cache_drvrinfo_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5F__cache_drvrinfo_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -142,13 +129,10 @@ const H5AC_class_t H5AC_DRVRINFO[1] = {{ /* Declare extern the free list to manage the H5F_super_t struct */ H5FL_EXTERN(H5F_super_t); - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5F__superblock_prefix_decode * @@ -163,10 +147,10 @@ H5FL_EXTERN(H5F_super_t); */ static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, - const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa) + const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa) { - const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ - htri_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -182,7 +166,7 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, /* Superblock version */ sblock->super_vers = *image++; - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number") /* Sanity check */ @@ -191,7 +175,7 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, /* Determine the size of addresses & size of offsets, for computing the * variable-sized portion of the superblock. */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { sblock->sizeof_addr = image[4]; sblock->sizeof_size = image[5]; } /* end if */ @@ -199,23 +183,24 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, sblock->sizeof_addr = image[0]; sblock->sizeof_size = image[1]; } /* end else */ - if(sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 && - sblock->sizeof_addr != 8 && sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32) + if (sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 && sblock->sizeof_addr != 8 && + sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address") - if(sblock->sizeof_size != 2 && sblock->sizeof_size != 4 && - sblock->sizeof_size != 8 && sblock->sizeof_size != 16 && sblock->sizeof_size != 32) + if (sblock->sizeof_size != 2 && sblock->sizeof_size != 4 && sblock->sizeof_size != 8 && + sblock->sizeof_size != 16 && sblock->sizeof_size != 32) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size") /* Check for extending the EOA for the file */ - if(extend_eoa) { - size_t variable_size; /* Variable size of superblock */ + if (extend_eoa) { + size_t variable_size; /* Variable size of superblock */ /* Determine the size of the variable-length part of the superblock */ - variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size); + variable_size = + (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size); HDassert(variable_size > 0); /* Make certain we can read the variable-sized portion of the superblock */ - if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0) + if (H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") } /* end if */ @@ -226,7 +211,6 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__superblock_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5F__drvrinfo_prefix_decode * @@ -240,13 +224,12 @@ H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref, *------------------------------------------------------------------------- */ static herr_t -H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, - const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata, - hbool_t extend_eoa) +H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, const uint8_t **image_ref, + H5F_drvrinfo_cache_ud_t *udata, hbool_t extend_eoa) { - const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ - unsigned drv_vers; /* Version of driver info block */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */ + unsigned drv_vers; /* Version of driver info block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -259,7 +242,7 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, /* Version number */ drv_vers = *image++; - if(drv_vers != HDF5_DRIVERINFO_VERSION_0) + if (drv_vers != HDF5_DRIVERINFO_VERSION_0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number") image += 3; /* reserved bytes */ @@ -268,28 +251,28 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, UINT32DECODE(image, drvrinfo->len); /* Driver name and/or version */ - if(drv_name) { + if (drv_name) { H5MM_memcpy(drv_name, (const char *)image, (size_t)8); drv_name[8] = '\0'; image += 8; /* advance past name/version */ - } /* end if */ + } /* end if */ /* Extend the EOA if required so that we can read the complete driver info block */ - if(extend_eoa) { - haddr_t eoa; /* Current EOA for the file */ - haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */ + if (extend_eoa) { + haddr_t eoa; /* Current EOA for the file */ + haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */ /* Get current EOA... */ eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER); - if(!H5F_addr_defined(eoa)) + if (!H5F_addr_defined(eoa)) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* ... if it is too small, extend it. */ min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo->len; /* If it grew, set it */ - if(H5F_addr_gt(min_eoa, eoa)) - if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0) + if (H5F_addr_gt(min_eoa, eoa)) + if (H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed") } /* end if */ @@ -300,7 +283,6 @@ H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__drvrinfo_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_get_initial_load_size * @@ -322,13 +304,12 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t HDassert(image_len); /* Set the initial image length size */ - *image_len = H5F_SUPERBLOCK_FIXED_SIZE + /* Fixed size of superblock */ + *image_len = H5F_SUPERBLOCK_FIXED_SIZE + /* Fixed size of superblock */ H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_superblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_get_final_load_size * @@ -343,12 +324,12 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t */ 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) + 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 */ + H5F_super_t sblock; /* Temporary file superblock */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -360,21 +341,20 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDE HDassert(image_len >= H5F_SUPERBLOCK_FIXED_SIZE + 6); /* Deserialize the file superblock's prefix */ - if(H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0) + if (H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file superblock prefix") /* Save the version to be used in verify_chksum callback */ udata->super_vers = sblock.super_vers; /* Set the final size for the cache image */ - *actual_len = H5F_SUPERBLOCK_FIXED_SIZE + - (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size); + *actual_len = H5F_SUPERBLOCK_FIXED_SIZE + (size_t)H5F_SUPERBLOCK_VARLEN_SIZE( + sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_verify_chksum * @@ -391,11 +371,11 @@ 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 */ - htri_t ret_value = TRUE; /* Return value */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -404,19 +384,18 @@ H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata HDassert(udata); /* No checksum for version 0 & 1 */ - if(udata->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { + if (udata->super_vers >= HDF5_SUPERBLOCK_VERSION_2) { - /* Get stored and computed checksums */ - H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); + /* Get stored and computed checksums */ + H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_deserialize * @@ -432,12 +411,12 @@ 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) + hbool_t H5_ATTR_UNUSED *dirty) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -448,59 +427,59 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6); /* Allocate space for the superblock */ - if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) + if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) 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) + if (H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0) 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) { - uint32_t status_flags; /* File status flags */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ - unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ - unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + uint32_t status_flags; /* File status flags */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ + unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ - /* Freespace version (hard-wired) */ - if(HDF5_FREESPACE_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") + /* Freespace version (hard-wired) */ + if (HDF5_FREESPACE_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") - /* Root group version number (hard-wired) */ - if(HDF5_OBJECTDIR_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") + /* Root group version number (hard-wired) */ + if (HDF5_OBJECTDIR_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Shared header version number (hard-wired) */ - if(HDF5_SHAREDHEADER_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") + /* Shared header version number (hard-wired) */ + if (HDF5_SHAREDHEADER_VERSION != *image++) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") - /* 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 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 */ + /* Skip over size of file sizes (already decoded) */ + image++; + udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ - /* Skip over reserved byte */ - image++; + /* Skip over reserved byte */ + image++; - /* Various B-tree sizes */ - 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") - udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ + /* Various B-tree sizes */ + 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") + udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ /* Need 'get' call to set other array values */ 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") - udata->btree_k[H5B_SNODE_ID] = snode_btree_k; + if (snode_btree_k == 0) + 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 * for the indexed storage B-tree internal 'K' value later. */ @@ -509,89 +488,90 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS UINT32DECODE(image, status_flags); HDassert(status_flags <= 255); 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") + if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") - /* + /* * 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) { - 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 */ - 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 */ - 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(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") - - /* 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") - - /* Set the root group address to the correct value */ - sblock->root_addr = sblock->root_ent->header; - - /* This step is for h5repart tool only. If user wants to change file driver + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + 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 */ + 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 */ + 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 (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") + + /* 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") + + /* Set the root group address to the correct value */ + sblock->root_addr = sblock->root_ent->header; + + /* This step is for h5repart tool only. If user wants to change file driver * from family to sec2 while using h5repart, set the driver address to * undefined to let the library ignore the family driver information saved * in the superblock. */ - if(udata->ignore_drvrinfo && H5F_addr_defined(sblock->driver_addr)) { - /* Eliminate the driver info */ - sblock->driver_addr = HADDR_UNDEF; + if (udata->ignore_drvrinfo && H5F_addr_defined(sblock->driver_addr)) { + /* Eliminate the driver info */ + sblock->driver_addr = HADDR_UNDEF; udata->drvrinfo_removed = TRUE; - } /* end if */ + } /* end if */ - /* NOTE: Driver info block is decoded separately, later */ + /* NOTE: Driver info block is decoded separately, later */ } /* end if */ else { - uint32_t read_chksum; /* Checksum read from file */ + 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 */ + 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 */ + /* Skip over size of file sizes (already decoded) */ + image++; + udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ - /* 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") + /* 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") - /* Base, superblock extension, end of file & root group object header addresses */ - 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->root_addr/*out*/); + /* Base, superblock extension, end of file & root group object header addresses */ + 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->root_addr /*out*/); - /* checksum verification already done in verify_chksum cb */ + /* checksum verification already done in verify_chksum cb */ - /* Decode checksum */ - UINT32DECODE(image, read_chksum); + /* Decode checksum */ + UINT32DECODE(image, read_chksum); - /* The Driver Information Block may not appear with the version - * 2 super block. Thus we set the driver_addr field of the in + /* The Driver Information Block may not appear with the version + * 2 super block. Thus we set the driver_addr field of the in * core representation of the super block HADDR_UNDEF to prevent * any attempt to load the Driver Information Block. - */ - sblock->driver_addr = HADDR_UNDEF; + */ + sblock->driver_addr = HADDR_UNDEF; } /* end else */ /* Sanity check */ @@ -602,14 +582,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS done: /* Release the [possibly partially initialized] superblock on error */ - if(!ret_value && sblock) - if(H5F__super_free(sblock) < 0) + if (!ret_value && sblock) + if (H5F__super_free(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_image_len * @@ -625,7 +604,7 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS static herr_t H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) { - const H5F_super_t *sblock = (const H5F_super_t *)_thing; /* Pointer to the object */ + const H5F_super_t *sblock = (const H5F_super_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -641,7 +620,6 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_superblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_serialize * @@ -655,13 +633,12 @@ 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 H5_ATTR_UNUSED len, - void *_thing) +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 */ - haddr_t rel_eof; /* Relative EOF for file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ + uint8_t * image = _image; /* Pointer into raw data buffer */ + haddr_t rel_eof; /* Relative EOF for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -682,15 +659,15 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU *image++ = (uint8_t)sblock->super_vers; /* Check for older version of superblock format */ - if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { - *image++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ - *image++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ - *image++ = 0; /* reserved*/ + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + *image++ = (uint8_t)HDF5_FREESPACE_VERSION; /* (hard-wired) */ + *image++ = (uint8_t)HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ + *image++ = 0; /* reserved*/ - *image++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ + *image++ = (uint8_t)HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ *image++ = sblock->sizeof_addr; *image++ = sblock->sizeof_size; - *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ UINT16ENCODE(image, sblock->sym_leaf_k); UINT16ENCODE(image, sblock->btree_k[H5B_SNODE_ID]); @@ -700,11 +677,11 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU * Versions of the superblock >0 have the indexed storage B-tree * internal 'K' value stored */ - if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { UINT16ENCODE(image, sblock->btree_k[H5B_CHUNK_ID]); - *image++ = 0; /*reserved */ - *image++ = 0; /*reserved */ - } /* end if */ + *image++ = 0; /*reserved */ + *image++ = 0; /*reserved */ + } /* end if */ /* Encode the base address */ H5F_addr_encode(f, &image, sblock->base_addr); @@ -725,15 +702,15 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU H5F_addr_encode(f, &image, sblock->driver_addr); /* Encode the root group object entry, including the cached stab info */ - if(H5G_ent_encode(f, &image, sblock->root_ent) < 0) + if (H5G_ent_encode(f, &image, sblock->root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTENCODE, FAIL, "can't encode root group symbol table entry") /* NOTE: Driver info block is handled separately */ - } /* end if */ - else { /* sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ - uint32_t chksum; /* Checksum temporary variable */ - H5O_loc_t *root_oloc; /* Pointer to root group's object location */ + } /* end if */ + else { /* sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 */ + uint32_t chksum; /* Checksum temporary variable */ + H5O_loc_t *root_oloc; /* Pointer to root group's object location */ /* Size of file addresses & offsets, and status flags */ *image++ = sblock->sizeof_addr; @@ -756,7 +733,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU H5F_addr_encode(f, &image, (rel_eof + sblock->base_addr)); /* Retrieve information for root group */ - if(NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) + if (NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to retrieve root group information") /* Encode address of root group's object header */ @@ -779,7 +756,6 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_superblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_superblock_free_icr * @@ -800,8 +776,8 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU static herr_t H5F__cache_superblock_free_icr(void *_thing) { - H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -811,14 +787,13 @@ H5F__cache_superblock_free_icr(void *_thing) HDassert(sblock->cache_info.type == H5AC_SUPERBLOCK); /* Destroy superblock */ - if(H5F__super_free(sblock) < 0) + if (H5F__super_free(sblock) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free superblock") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_superblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_get_initial_load_size * @@ -840,12 +815,11 @@ H5F__cache_drvrinfo_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *i HDassert(image_len); /* Set the initial image length size */ - *image_len = H5F_DRVINFOBLOCK_HDR_SIZE; /* Fixed size portion of driver info block */ + *image_len = H5F_DRVINFOBLOCK_HDR_SIZE; /* Fixed size portion of driver info block */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_drvrinfo_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_get_final_load_size * @@ -860,12 +834,12 @@ H5F__cache_drvrinfo_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *i */ 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) + void *_udata, size_t *actual_len) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -877,7 +851,7 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBU HDassert(image_len == H5F_DRVINFOBLOCK_HDR_SIZE); /* Deserialize the file driver info's prefix */ - if(H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0) + if (H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file driver info prefix") /* Set the final size for the cache image */ @@ -887,7 +861,6 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBU FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_drvrinfo_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_deserialize * @@ -903,13 +876,13 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBU */ static void * H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) + hbool_t H5_ATTR_UNUSED *dirty) { - 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 */ - char drv_name[9]; /* Name of driver */ - H5O_drvinfo_t *ret_value = NULL; /* Return value */ + 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 */ + char drv_name[9]; /* Name of driver */ + H5O_drvinfo_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -920,19 +893,19 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(udata->f); /* Allocate space for the driver info */ - if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message") + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message") /* Deserialize the file driver info's prefix */ - if(H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0) + if (H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file driver info prefix") /* Sanity check */ HDassert(len == (H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo->len)); /* Validate and decode driver information */ - if(H5FD_sb_load(udata->f->shared->lf, drv_name, image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "unable to decode driver information") + if (H5FD_sb_load(udata->f->shared->lf, drv_name, image) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "unable to decode driver information") /* Sanity check */ HDassert((size_t)(image - (const uint8_t *)_image) <= len); @@ -942,13 +915,12 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED done: /* Release the [possibly partially initialized] driver info message on error */ - if(!ret_value && drvinfo) + if (!ret_value && drvinfo) H5MM_xfree(drvinfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_drvrinfo_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_image_len * @@ -964,7 +936,7 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED static herr_t H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) { - const H5O_drvinfo_t *drvinfo = (const H5O_drvinfo_t *)_thing; /* Pointer to the object */ + const H5O_drvinfo_t *drvinfo = (const H5O_drvinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -975,13 +947,12 @@ H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) HDassert(image_len); /* Set the image length size */ - *image_len = (size_t)(H5F_DRVINFOBLOCK_HDR_SIZE + /* Fixed-size portion of driver info block */ - drvinfo->len); /* Variable-size portion of driver info block */ + *image_len = (size_t)(H5F_DRVINFOBLOCK_HDR_SIZE + /* Fixed-size portion of driver info block */ + drvinfo->len); /* Variable-size portion of driver info block */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_drvrinfo_image_len() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_serialize * @@ -995,13 +966,12 @@ 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 H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1018,15 +988,15 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBU /* Encode the driver information block */ *image++ = HDF5_DRIVERINFO_VERSION_0; /* Version */ - *image++ = 0; /* reserved */ - *image++ = 0; /* reserved */ - *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ + *image++ = 0; /* reserved */ /* Driver info size, excluding header */ UINT32ENCODE(image, drvinfo->len); /* Encode driver-specific data */ - if(H5FD_sb_encode(f->shared->lf, (char *)image, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) + if (H5FD_sb_encode(f->shared->lf, (char *)image, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information") /* Advance buffer pointer past name & variable-sized portion of driver info */ @@ -1039,7 +1009,6 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBU FUNC_LEAVE_NOAPI(ret_value) } /* H5F__cache_drvrinfo_serialize() */ - /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_free_icr * @@ -1060,7 +1029,7 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBU static herr_t H5F__cache_drvrinfo_free_icr(void *_thing) { - H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ + H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ FUNC_ENTER_STATIC_NOERR @@ -1074,4 +1043,3 @@ H5F__cache_drvrinfo_free_icr(void *_thing) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F__cache_drvrinfo_free_icr() */ - diff --git a/src/H5Ftest.c b/src/H5Ftest.c index d0ddb46afab..1f5e7e2f53c 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,61 +26,53 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ -#define H5F_TESTING /* Suppress warning about H5F testing funcs */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg.h */ -#define H5G_TESTING /* Suppress warning about H5G testing funcs */ -#define H5SM_FRIEND /* Suppress error about including H5SMpkg.h */ -#define H5SM_TESTING /* Suppress warning about H5SM testing funcs */ - +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#define H5F_TESTING /* Suppress warning about H5F testing funcs */ +#define H5G_FRIEND /* Suppress error about including H5Gpkg.h */ +#define H5G_TESTING /* Suppress warning about H5G testing funcs */ +#define H5SM_FRIEND /* Suppress error about including H5SMpkg.h */ +#define H5SM_TESTING /* Suppress warning about H5SM testing funcs */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMpkg.h" /* Shared object header messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5F__get_sohm_mesg_count_test * @@ -96,33 +88,32 @@ herr_t H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count) { - H5F_t *file; /* File info */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * file; /* File info */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Retrieve count for message type */ - if(H5SM__get_mesg_count_test(file, type_id, mesg_count) < 0) + if (H5SM__get_mesg_count_test(file, type_id, mesg_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve shared message count") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sohm_mesg_count_test() */ - /*------------------------------------------------------------------------- * Function: H5F__check_cached_stab_test * @@ -141,33 +132,32 @@ 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 */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t * file; /* File info */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Verify the cached stab info */ - if(H5G__verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0) + if (H5G__verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->sblock->root_ent) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to verify cached symbol table info") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__check_cached_stab_test() */ - /*------------------------------------------------------------------------- * Function: H5F__get_maxaddr_test * @@ -183,13 +173,13 @@ H5F__check_cached_stab_test(hid_t file_id) herr_t H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -199,7 +189,6 @@ H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_maxaddr_test() */ - /*------------------------------------------------------------------------- * Function: H5F__get_sbe_addr_test * @@ -216,13 +205,13 @@ H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if (NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -232,7 +221,39 @@ H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sbe_addr_test() */ - +/*------------------------------------------------------------------------- + * Function: H5F__same_file_test + * + * Purpose: Check if two file IDs refer to the same underlying file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Oct 13, 2018 + * + *------------------------------------------------------------------------- + */ +htri_t +H5F__same_file_test(hid_t file_id1, hid_t file_id2) +{ + H5F_t *file1, *file2; /* File info */ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (NULL == (file1 = (H5F_t *)H5VL_object_verify(file_id1, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + if (NULL == (file2 = (H5F_t *)H5VL_object_verify(file_id2, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* If they are using the same underlying "shared" file struct, they are the same file */ + ret_value = (file1->shared == file2->shared); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__same_file_test() */ + /*------------------------------------------------------------------------- * Function: H5F__reparse_file_lock_variable_test * @@ -258,10 +279,9 @@ H5F__reparse_file_lock_variable_test(void) FUNC_ENTER_PACKAGE /* Check the file locking environment variable */ - if(H5F__parse_file_lock_env_var(&use_locks_env_g) < 0) + if (H5F__parse_file_lock_env_var(&use_locks_env_g) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to parse file locking environment variable") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__reparse_file_lock_variable_test() */ - diff --git a/src/H5G.c b/src/H5G.c index 288239bca8c..f5d1dc523f1 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -75,40 +75,37 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ +/* Group close callback */ +static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj); /*********************/ /* Package Variables */ @@ -117,29 +114,47 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Group ID class */ static const H5I_class_t H5I_GROUP_CLS[1] = {{ - H5I_GROUP, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ + H5I_GROUP, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5G_top_package_initialize_s = FALSE; +/*------------------------------------------------------------------------- + * Function: H5G_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5G_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_init() */ - /*------------------------------------------------------------------------- * Function: H5G__init_package * @@ -162,13 +177,13 @@ static hbool_t H5G_top_package_initialize_s = FALSE; herr_t H5G__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - /* Initialize the atom group for the group IDs */ - if(H5I_register_type(H5I_GROUP_CLS) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") + /* Initialize the ID group for the group IDs */ + if (H5I_register_type(H5I_GROUP_CLS) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ H5G_top_package_initialize_s = TRUE; @@ -177,7 +192,6 @@ H5G__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__init_package() */ - /*------------------------------------------------------------------------- * Function: H5G_top_term_package * @@ -195,25 +209,24 @@ H5G__init_package(void) int H5G_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5G_top_package_initialize_s) { - if(H5I_nmembers(H5I_GROUP) > 0) { + if (H5G_top_package_initialize_s) { + if (H5I_nmembers(H5I_GROUP) > 0) { (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ - if(0 == n) + if (0 == n) H5G_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5G_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5G_term_package * @@ -234,11 +247,11 @@ H5G_top_term_package(void) int H5G_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_GROUP)); HDassert(FALSE == H5G_top_package_initialize_s); @@ -247,14 +260,44 @@ H5G_term_package(void) n += (H5I_dec_type_ref(H5I_GROUP) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5G_term_package() */ - +/*------------------------------------------------------------------------- + * Function: H5G__close_cb + * + * Purpose: Called when the ref count reaches zero on the group's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__close_cb(H5VL_object_t *grp_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(grp_vol_obj); + + /* Close the group */ + if (H5VL_group_close(grp_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") + + /* Free the VOL object */ + if (H5VL_free_object(grp_vol_obj) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__close_cb() */ + /*------------------------------------------------------------------------- * Function: H5Gcreate2 * @@ -279,58 +322,66 @@ H5G_term_package(void) *------------------------------------------------------------------------- */ hid_t -H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, - hid_t gapl_id) +H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - /* Get correct property list */ - if(H5P_DEFAULT == lcpl_id) + /* Check link creation property list */ + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a link creation property list") /* Check group creation property list */ - if(H5P_DEFAULT == gcpl_id) + if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") + else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group creation property list") /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the group */ + if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, lcpl_id, gcpl_id, gapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + + /* Get an ID for the group */ + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle") done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ - /*------------------------------------------------------------------------- * Function: H5Gcreate_anon * @@ -366,63 +417,50 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; - H5G_t *grp = NULL; - H5G_obj_create_t gcrt_info; /* Information for group creation */ - hid_t ret_value; + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - /* Check group creation property list */ - if(H5P_DEFAULT == gcpl_id) + if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") + else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) - HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); -done: - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of group") + /* Create the group */ + if (NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, H5P_LINK_CREATE_DEFAULT, gcpl_id, + gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on newly created object") - } /* end if */ + /* Get an ID for the group */ + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle") +done: /* Cleanup on failure */ - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ - /*------------------------------------------------------------------------- * Function: H5Gopen2 * @@ -441,40 +479,48 @@ 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) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ - hid_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the group */ - if(NULL == (grp = H5G__open_name(&loc, name))) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, gapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ - /*------------------------------------------------------------------------- * Function: H5Gget_create_plist * @@ -491,25 +537,25 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) hid_t H5Gget_create_plist(hid_t group_id) { - H5G_t *group = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", group_id); /* Check args */ - if(NULL == (group = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID") - /* Retrieve the GCPL */ - if((ret_value = H5G_get_create_plist(group)) < 0) + /* Get the group creation property list for the group */ + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_GCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info * @@ -520,35 +566,38 @@ H5Gget_create_plist(hid_t group_id) *------------------------------------------------------------------------- */ herr_t -H5Gget_info(hid_t grp_id, H5G_info_t *grp_info) +H5Gget_info(hid_t loc_id, H5G_info_t *group_info) { - H5I_type_t id_type; /* Type of ID */ - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", grp_id, grp_info); + H5TRACE2("e", "i*x", loc_id, group_info); /* Check args */ - id_type = H5I_get_type(grp_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(!grp_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + id_type = H5I_get_type(loc_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID") + if (!group_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Get group location */ - if(H5G_loc(grp_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, grp_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = id_type; + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info_by_name * @@ -560,36 +609,46 @@ H5Gget_info(hid_t grp_id, H5G_info_t *grp_info) *------------------------------------------------------------------------- */ herr_t -H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, - hid_t lapl_id) +H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "i*s*xi", loc_id, name, grp_info, lapl_id); + H5TRACE4("e", "i*s*xi", loc_id, name, group_info, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!grp_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (!group_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set up location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, name, grp_info/*out*/) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Gget_info_by_idx * @@ -601,41 +660,54 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, *------------------------------------------------------------------------- */ 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 *grp_info, hid_t lapl_id) +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) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + 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, group_name, idx_type, order, n, grp_info, - lapl_id); + H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, group_info, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!grp_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if (!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if (!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!group_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, group_name, idx_type, order, n, grp_info/*out*/) < 0) + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Gclose * @@ -649,26 +721,25 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, herr_t H5Gclose(hid_t group_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); - /* Check args */ - if(NULL == H5I_object_verify(group_id, H5I_GROUP)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + /* Check arguments */ + if (H5I_GROUP != H5I_get_type(group_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") - /* Decrement the counter on the group atom. It will be freed if the count + /* Decrement the counter on the group ID. It will be freed if the count * reaches zero. */ - if(H5I_dec_app_ref(group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + if (H5I_dec_app_ref(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "decrementing group ID failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Gclose() */ - /*------------------------------------------------------------------------- * Function: H5Gflush * @@ -684,29 +755,29 @@ H5Gclose(hid_t group_id) herr_t H5Gflush(hid_t group_id) { - H5G_t *grp; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(group_id) < 0) + if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Flush metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group and object flush callback") + /* Flush group's metadata to file */ + if (H5VL_group_specific(vol_obj, H5VL_GROUP_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < + 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") done: FUNC_LEAVE_API(ret_value) } /* H5Gflush */ - /*------------------------------------------------------------------------- * Function: H5Grefresh * @@ -722,25 +793,25 @@ H5Gflush(hid_t group_id) herr_t H5Grefresh(hid_t group_id) { - H5G_t *grp; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(group_id) < 0) + if (H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call private function to refresh group object */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + /* Refresh group's metadata */ + if (H5VL_group_specific(vol_obj, H5VL_GROUP_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") done: FUNC_LEAVE_API(ret_value) } /* H5Grefresh */ - diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 918e18c15ee..dd147ae084e 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,23 +26,20 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -53,21 +50,19 @@ */ 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 */ - H5B2_found_t found_op; /* Callback when correct link is found */ - void *found_op_data; /* Callback data when correct link is found */ + 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 */ /* upward */ - int cmp; /* Comparison of two link names */ + int cmp; /* Comparison of two link names */ } H5G_fh_ud_cmp_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -77,46 +72,43 @@ typedef struct H5G_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5G__dense_btree2_corder_store(void *native, const void *udata); static herr_t H5G__dense_btree2_corder_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5G__dense_btree2_corder_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5G__dense_btree2_corder_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5G__dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5G__dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G__dense_btree2_name_store(void *native, const void *udata); static herr_t H5G__dense_btree2_name_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5G__dense_btree2_name_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5G__dense_btree2_name_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5G__dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5G__dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Fractal heap function callbacks */ static herr_t H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); - /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indexing 'name' field of links */ -const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ - H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ - "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ - sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ - NULL, /* Create client callback context */ - NULL, /* Destroy client callback context */ - H5G__dense_btree2_name_store, /* Record storage callback */ - H5G__dense_btree2_name_compare, /* Record comparison callback */ - H5G__dense_btree2_name_encode, /* Record encoding callback */ - H5G__dense_btree2_name_decode, /* Record decoding callback */ - H5G__dense_btree2_name_debug /* Record debugging callback */ +const H5B2_class_t H5G_BT2_NAME[1] = {{ + /* B-tree class information */ + H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ + "H5B2_GRP_DENSE_NAME_ID", /* Name of B-tree class */ + sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ + NULL, /* Create client callback context */ + NULL, /* Destroy client callback context */ + H5G__dense_btree2_name_store, /* Record storage callback */ + H5G__dense_btree2_name_compare, /* Record comparison callback */ + H5G__dense_btree2_name_encode, /* Record encoding callback */ + H5G__dense_btree2_name_decode, /* Record decoding callback */ + H5G__dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ -const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ +const H5B2_class_t H5G_BT2_CORDER[1] = {{ + /* B-tree class information */ H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */ "H5B2_GRP_DENSE_CORDER_ID", /* Name of B-tree class */ sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */ @@ -133,13 +125,10 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__dense_fh_name_cmp * @@ -156,22 +145,23 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Compare the string values */ udata->cmp = HDstrcmp(udata->name, lnk->name); /* Check for correct link & callback to make */ - if(udata->cmp == 0 && udata->found_op) { - if((udata->found_op)(lnk, udata->found_op_data) < 0) + if (udata->cmp == 0 && udata->found_op) { + if ((udata->found_op)(lnk, udata->found_op_data) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link found callback failed") } /* end if */ @@ -182,7 +172,6 @@ H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_fh_name_cmp() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_store * @@ -199,7 +188,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 @@ -211,7 +200,6 @@ H5G__dense_btree2_name_store(void *_nrecord, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_name_store() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_compare * @@ -229,9 +217,9 @@ 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_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -240,28 +228,28 @@ H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int HDassert(bt2_rec); /* Check hash value */ - if(bt2_udata->name_hash < bt2_rec->hash) + if (bt2_udata->name_hash < bt2_rec->hash) *result = (-1); - else if(bt2_udata->name_hash > bt2_rec->hash) + else if (bt2_udata->name_hash > bt2_rec->hash) *result = 1; else { - H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ + H5G_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; - fh_udata.found_op = bt2_udata->found_op; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; + fh_udata.found_op = bt2_udata->found_op; fh_udata.found_op_data = bt2_udata->found_op_data; /* up */ fh_udata.cmp = 0; /* Check if the user's link and the B-tree's link have the same name */ - if(H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G__dense_fh_name_cmp, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, bt2_rec->id, H5G__dense_fh_name_cmp, &fh_udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Callback will set comparison value */ @@ -272,7 +260,6 @@ H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int FUNC_LEAVE_NOAPI(ret_value) } /* H5G__dense_btree2_name_compare() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_encode * @@ -300,7 +287,6 @@ H5G__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_name_encode() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_decode * @@ -328,7 +314,6 @@ H5G__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_name_decode() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_name_debug * @@ -343,23 +328,21 @@ H5G__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", - (unsigned)nrecord->hash); - for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", (unsigned)nrecord->hash); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_name_debug() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_corder_store * @@ -376,7 +359,7 @@ H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, 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 +371,6 @@ H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_corder_store() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_corder_compare * @@ -406,8 +388,8 @@ 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_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec; + 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 @@ -416,9 +398,9 @@ H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i HDassert(bt2_rec); /* Check creation order value */ - if(bt2_udata->corder < bt2_rec->corder) + if (bt2_udata->corder < bt2_rec->corder) *result = -1; - else if(bt2_udata->corder > bt2_rec->corder) + else if (bt2_udata->corder > bt2_rec->corder) *result = 1; else *result = 0; @@ -426,7 +408,6 @@ H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, i FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_corder_compare() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_corder_encode * @@ -454,7 +435,6 @@ H5G__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_corder_encode() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_corder_decode * @@ -482,7 +462,6 @@ H5G__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_corder_decode() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_btree2_corder_debug * @@ -497,19 +476,17 @@ H5G__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5G__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", - (unsigned long long)nrecord->corder); - for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) + HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", (unsigned long long)nrecord->corder); + for (u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5G__dense_btree2_corder_debug() */ - diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 22b0488f161..471319360e0 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,91 +26,79 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ -#define H5G_NODE_VERS 1 /* Symbol table node version number */ - +#define H5G_NODE_VERS 1 /* Symbol table node version number */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 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_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5G__cache_node_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Symbol table nodes inherit cache-like properties from H5AC */ const H5AC_class_t H5AC_SNODE[1] = {{ - H5AC_SNODE_ID, /* Metadata client ID */ - "Symbol table node", /* Metadata client name (for debugging) */ - H5FD_MEM_BTREE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5G__cache_node_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5G__cache_node_deserialize, /* 'deserialize' callback */ - H5G__cache_node_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5G__cache_node_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5G__cache_node_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_SNODE_ID, /* Metadata client ID */ + "Symbol table node", /* Metadata client name (for debugging) */ + H5FD_MEM_BTREE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5G__cache_node_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5G__cache_node_deserialize, /* 'deserialize' callback */ + H5G__cache_node_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5G__cache_node_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5G__cache_node_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /* Declare extern the free list to manage the H5G_node_t struct */ H5FL_EXTERN(H5G_node_t); /* Declare extern the free list to manage sequences of H5G_entry_t's */ H5FL_SEQ_EXTERN(H5G_entry_t); - /*------------------------------------------------------------------------- * Function: H5G__cache_node_get_initial_load_size() * @@ -128,7 +116,7 @@ H5FL_SEQ_EXTERN(H5G_entry_t); static herr_t H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) { - H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -142,7 +130,6 @@ H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__cache_node_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_deserialize * @@ -165,14 +152,13 @@ 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) +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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -183,19 +169,19 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate symbol table data structures */ - if(NULL == (sym = H5FL_CALLOC(H5G_node_t))) + if (NULL == (sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") sym->node_size = (size_t)(H5G_NODE_SIZE(f)); - if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) + if (NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* magic */ - if(HDmemcmp(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "bad symbol table node signature") image += H5_SIZEOF_MAGIC; /* version */ - if(H5G_NODE_VERS != *image++) + if (H5G_NODE_VERS != *image++) HGOTO_ERROR(H5E_SYM, H5E_VERSION, NULL, "bad symbol table node version") /* reserved */ @@ -205,21 +191,20 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, UINT16DECODE(image, sym->nsyms); /* entries */ - if(H5G__ent_decode_vec(f, &image, image_end, sym->entry, sym->nsyms) < 0) + if (H5G__ent_decode_vec(f, &image, image_end, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries") /* Set return value */ ret_value = sym; done: - if(!ret_value) - if(sym && H5G__node_free(sym) < 0) + if (!ret_value) + if (sym && H5G__node_free(sym) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_image_len * @@ -252,7 +237,6 @@ H5G__cache_node_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__cache_node_image_len() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_serialize * @@ -270,12 +254,11 @@ 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) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to object */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -301,7 +284,7 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, UINT16ENCODE(image, sym->nsyms); /* entries */ - if(H5G__ent_encode_vec(f, &image, sym->entry, sym->nsyms) < 0) + if (H5G__ent_encode_vec(f, &image, sym->entry, sym->nsyms) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't serialize") /* Clear rest of symbol table node */ @@ -311,7 +294,6 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_serialize() */ - /*------------------------------------------------------------------------- * Function: H5G__cache_node_free_icr * @@ -332,8 +314,8 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, static herr_t H5G__cache_node_free_icr(void *_thing) { - H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to the object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -343,10 +325,9 @@ H5G__cache_node_free_icr(void *_thing) HDassert(sym->cache_info.type == H5AC_SNODE); /* Destroy symbol table node */ - if(H5G__node_free(sym) < 0) + if (H5G__node_free(sym) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_free_icr() */ - diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index d926f111852..af188d8cedf 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,51 +21,48 @@ * *------------------------------------------------------------------------- */ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ /* Private typedefs */ /* User data for link message iteration when building link table */ typedef struct { H5G_link_table_t *ltable; /* Pointer to link table to build */ - size_t curr_lnk; /* Current link to operate on */ + size_t curr_lnk; /* Current link to operate on */ } H5G_iter_bt_t; /* User data for deleting a link in the link messages */ typedef struct { /* downward */ - 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 */ + 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; /* User data for link message iteration when querying link info */ typedef struct { /* downward */ - const char *name; /* Name to search for */ + const char *name; /* Name to search for */ /* upward */ - H5O_link_t *lnk; /* Link struct to fill in */ - hbool_t found; /* Flag to indicate that the object was found */ + H5O_link_t *lnk; /* Link struct to fill in */ + hbool_t found; /* Flag to indicate that the object was found */ } H5G_iter_lkp_t; /* Private macros */ /* PRIVATE PROTOTYPES */ static herr_t H5G__compact_build_table_cb(const void *_mesg, unsigned idx, void *_udata); -static herr_t H5G__compact_build_table(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - H5G_link_table_t *ltable); +static herr_t H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable); static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata); - /*------------------------------------------------------------------------- * Function: H5G__compact_build_table_cb * @@ -82,9 +79,9 @@ static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED 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 */ - herr_t ret_value=H5_ITER_CONT; /* Return value */ + 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 */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -94,7 +91,7 @@ H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void HDassert(udata->curr_lnk < udata->ltable->nlinks); /* Copy link message into table */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) + if (NULL == H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") /* Increment current link entry to operate on */ @@ -104,7 +101,6 @@ H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_build_table * @@ -120,10 +116,10 @@ H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *------------------------------------------------------------------------- */ static herr_t -H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) +H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -137,26 +133,26 @@ H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, ltable->nlinks = (size_t)linfo->nlinks; /* Allocate space for the table entries */ - if(ltable->nlinks > 0) { - H5G_iter_bt_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Message operator */ + if (ltable->nlinks > 0) { + H5G_iter_bt_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Message operator */ /* Allocate the link table */ - if((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) + if ((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.ltable = ltable; + udata.ltable = ltable; udata.curr_lnk = 0; /* Iterate through the link messages, adding them to the table */ - op.op_type = H5O_MESG_OP_APP; + op.op_type = H5O_MESG_OP_APP; op.u.app_op = H5G__compact_build_table_cb; - if(H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) + if (H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(ltable, idx_type, order) < 0) + if (H5G__link_sort_table(ltable, idx_type, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else @@ -166,7 +162,6 @@ H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_insert * @@ -184,7 +179,7 @@ H5G__compact_build_table(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -193,14 +188,13 @@ H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk) HDassert(obj_lnk); /* Insert link message into group */ - if(H5O_msg_create(grp_oloc, H5O_LINK_ID, 0, H5O_UPDATE_TIME, obj_lnk) < 0) + if (H5O_msg_create(grp_oloc, H5O_LINK_ID, 0, H5O_UPDATE_TIME, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_get_name_by_idx * @@ -215,12 +209,11 @@ H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk) *------------------------------------------------------------------------- */ ssize_t -H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char* name, - size_t size) +H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, char *name, size_t size) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value = -1; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -228,32 +221,31 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(oloc); /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") + if (idx >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(ltable.lnks[idx].name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, ltable.lnks[idx].name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_remove_common_cb * @@ -270,9 +262,9 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, 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 */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + 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 */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -281,9 +273,9 @@ H5G__compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, vo HDassert(udata); /* If we've found the right link, get the object type */ - if(HDstrcmp(lnk->name, udata->name) == 0) { + if (HDstrcmp(lnk->name, udata->name) == 0) { /* Replace path names for link being removed */ - if(H5G__link_name_replace(udata->file, udata->grp_full_path_r, lnk) < 0) + if (H5G__link_name_replace(udata->file, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object type") /* Stop the iteration, we found the correct link */ @@ -294,7 +286,6 @@ H5G__compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, vo FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove_common_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_remove * @@ -308,11 +299,10 @@ H5G__compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, vo *------------------------------------------------------------------------- */ herr_t -H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name) +H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name) { H5G_iter_rm_t udata; /* Data to pass through OH iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -320,19 +310,18 @@ H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, HDassert(name && *name); /* Initialize data to pass through object header iteration */ - udata.file = oloc->file; + udata.file = oloc->file; udata.grp_full_path_r = grp_full_path_r; - udata.name = name; + udata.name = name; /* Iterate over the link messages to delete the right one */ - if(H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G__compact_remove_common_cb, &udata, TRUE) < 0) + if (H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G__compact_remove_common_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_remove_by_idx * @@ -346,13 +335,12 @@ H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, *------------------------------------------------------------------------- */ herr_t -H5G__compact_remove_by_idx(const H5O_loc_t *oloc, 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) +H5G__compact_remove_by_idx(const H5O_loc_t *oloc, 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) { - H5G_link_table_t ltable = {0, NULL};/* Link table */ - H5G_iter_rm_t udata; /* Data to pass through OH iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + H5G_iter_rm_t udata; /* Data to pass through OH iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -360,31 +348,30 @@ H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(linfo); /* Build table of all link messages, sorted according to desired order */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(n >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") + if (n >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") /* Initialize data to pass through object header iteration */ - udata.file = oloc->file; + udata.file = oloc->file; udata.grp_full_path_r = grp_full_path_r; - udata.name = ltable.lnks[n].name; + udata.name = ltable.lnks[n].name; /* Iterate over the link messages to delete the right one */ - if(H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G__compact_remove_common_cb, &udata, TRUE) < 0) + if (H5O_msg_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G__compact_remove_common_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_iterate * @@ -398,12 +385,12 @@ H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, *------------------------------------------------------------------------- */ herr_t -H5G__compact_iterate(const H5O_loc_t *oloc, 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) +H5G__compact_iterate(const H5O_loc_t *oloc, 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) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value = FAIL; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -413,22 +400,21 @@ H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(op); /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup_cb * @@ -445,9 +431,9 @@ H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, 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 */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + 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 */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -456,10 +442,10 @@ H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_ud HDassert(udata); /* Check for name to get information */ - if(HDstrcmp(lnk->name, udata->name) == 0) { - if(udata->lnk) { + if (HDstrcmp(lnk->name, udata->name) == 0) { + if (udata->lnk) { /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, lnk, udata->lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, lnk, udata->lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") } /* end if */ @@ -474,7 +460,6 @@ H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_ud FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup * @@ -490,9 +475,9 @@ H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_ud htri_t H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) { - H5G_iter_lkp_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Message operator */ - htri_t ret_value = FAIL; /* Return value */ + H5G_iter_lkp_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Message operator */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -501,14 +486,14 @@ H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) HDassert(name && *name); /* Set up user data for iteration */ - udata.name = name; - udata.lnk = lnk; + udata.name = name; + udata.lnk = lnk; udata.found = FALSE; /* Iterate through the link messages, adding them to the table */ - op.op_type = H5O_MESG_OP_APP; + op.op_type = H5O_MESG_OP_APP; op.u.app_op = H5G__compact_lookup_cb; - if(H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) + if (H5O_msg_iterate(oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") /* Determine if we found the link we were looking for */ @@ -518,7 +503,6 @@ H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G__compact_lookup_by_idx * @@ -533,11 +517,11 @@ H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk) *------------------------------------------------------------------------- */ herr_t -H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) +H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { - H5G_link_table_t ltable = {0, NULL};/* Link table */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -547,90 +531,21 @@ H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, HDassert(lnk); /* Build table of all link messages, sorted according to desired order */ - if(H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) + if (H5G__compact_build_table(oloc, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") /* Check for going out of bounds */ - if(n >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") + if (n >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_by_idx() */ - -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G__compact_get_type_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sep 12, 2005 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__compact_get_type_by_idx(H5O_loc_t *oloc, const H5O_linfo_t *linfo, - hsize_t idx) -{ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(oloc); - - /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table") - - /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound") - - /* Determine type of object */ - if(ltable.lnks[idx].type == H5L_TYPE_SOFT) - ret_value = H5G_LINK; - else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) - ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = oloc->file; - tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - - /* Map to group object type */ - if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } else { - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") - } /* end else */ - -done: - /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__compact_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 2e5e58853c4..6100361f177 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,44 +27,42 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap creation parameters for "dense" link storage */ -#define H5G_FHEAP_MAN_WIDTH 4 -#define H5G_FHEAP_MAN_START_BLOCK_SIZE 512 -#define H5G_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) -#define H5G_FHEAP_MAN_MAX_INDEX 32 -#define H5G_FHEAP_MAN_START_ROOT_ROWS 1 -#define H5G_FHEAP_CHECKSUM_DBLOCKS TRUE -#define H5G_FHEAP_MAX_MAN_SIZE (4 * 1024) +#define H5G_FHEAP_MAN_WIDTH 4 +#define H5G_FHEAP_MAN_START_BLOCK_SIZE 512 +#define H5G_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) +#define H5G_FHEAP_MAN_MAX_INDEX 32 +#define H5G_FHEAP_MAN_START_ROOT_ROWS 1 +#define H5G_FHEAP_CHECKSUM_DBLOCKS TRUE +#define H5G_FHEAP_MAX_MAN_SIZE (4 * 1024) /* v2 B-tree creation macros for 'name' field index */ -#define H5G_NAME_BT2_NODE_SIZE 512 -#define H5G_NAME_BT2_MERGE_PERC 40 -#define H5G_NAME_BT2_SPLIT_PERC 100 +#define H5G_NAME_BT2_NODE_SIZE 512 +#define H5G_NAME_BT2_MERGE_PERC 40 +#define H5G_NAME_BT2_SPLIT_PERC 100 /* v2 B-tree creation macros for 'corder' field index */ -#define H5G_CORDER_BT2_NODE_SIZE 512 -#define H5G_CORDER_BT2_MERGE_PERC 40 -#define H5G_CORDER_BT2_SPLIT_PERC 100 +#define H5G_CORDER_BT2_NODE_SIZE 512 +#define H5G_CORDER_BT2_MERGE_PERC 40 +#define H5G_CORDER_BT2_SPLIT_PERC 100 /* Size of stack buffer for serialized link */ -#define H5G_LINK_BUF_SIZE 128 - +#define H5G_LINK_BUF_SIZE 128 /******************/ /* Local Typedefs */ @@ -73,7 +71,7 @@ /* Data exchange structure to use when building table of links in group */ typedef struct { H5G_link_table_t *ltable; /* Pointer to link table to build */ - size_t curr_lnk; /* Current link to operate on */ + size_t curr_lnk; /* Current link to operate on */ } H5G_dense_bt_ud_t; /* @@ -82,17 +80,17 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t *f; /* Pointer to file that fractal heap is in */ - H5HF_t *fheap; /* Fractal heap handle */ - hsize_t count; /* # of links examined */ + 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 */ + 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 */ /* upward */ - int op_ret; /* Return value from callback */ + int op_ret; /* Return value from callback */ } H5G_bt2_ud_it_t; /* @@ -101,10 +99,10 @@ 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 */ /* upward */ - H5O_link_t *lnk; /* Copy of link */ + H5O_link_t *lnk; /* Copy of link */ } H5G_fh_ud_it_t; /* @@ -113,11 +111,11 @@ typedef struct { */ typedef struct { /* downward */ - 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 */ - hbool_t replace_names; /* Whether to replace the names of open objects */ + 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 */ + hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_bt2_ud_rm_t; /* @@ -126,10 +124,10 @@ typedef struct { */ typedef struct { /* downward */ - 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 */ + 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 */ } H5G_fh_ud_rm_t; /* @@ -138,11 +136,11 @@ typedef struct { */ typedef struct { /* downward */ - 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 */ + 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 */ } H5G_bt2_ud_rmbi_t; /* @@ -151,10 +149,10 @@ 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 */ /* upward */ - H5O_link_t *lnk; /* Pointer to link to remove */ + H5O_link_t *lnk; /* Pointer to link to remove */ } H5G_fh_ud_rmbi_t; /* @@ -163,15 +161,15 @@ typedef struct { */ typedef struct { /* downward (internal) */ - 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 */ /* downward (from application) */ - char *name; /* Name buffer to fill */ - size_t name_size; /* Size of name buffer to fill */ + char * name; /* Name buffer to fill */ + size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + ssize_t name_len; /* Full length of name */ } H5G_bt2_ud_gnbi_t; /* @@ -180,14 +178,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 */ /* downward (from application) */ - char *name; /* Name buffer to fill */ - size_t name_size; /* Size of name buffer to fill */ + char * name; /* Name buffer to fill */ + size_t name_size; /* Size of name buffer to fill */ /* upward */ - ssize_t name_len; /* Full length of name */ + ssize_t name_len; /* Full length of name */ } H5G_fh_ud_gnbi_t; /* @@ -196,11 +194,11 @@ typedef struct { */ typedef struct { /* downward (internal) */ - 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 */ /* upward */ - H5O_link_t *lnk; /* Pointer to link */ + H5O_link_t *lnk; /* Pointer to link */ } H5G_bt2_ud_lbi_t; /* @@ -209,39 +207,32 @@ 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 */ /* upward */ - H5O_link_t *lnk; /* Pointer to link */ + H5O_link_t *lnk; /* Pointer to link */ } H5G_fh_ud_lbi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__dense_create * @@ -257,13 +248,13 @@ typedef struct { herr_t 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 */ - size_t fheap_id_len; /* Fractal heap ID length */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + size_t fheap_id_len; /* Fractal heap ID length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -274,79 +265,78 @@ H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) HDassert(linfo); /* Set fractal heap creation parameters */ -/* XXX: Give some control of these to applications? */ + /* XXX: Give some control of these to applications? */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5G_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5G_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5G_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5G_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5G_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5G_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5G_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.max_man_size = H5G_FHEAP_MAX_MAN_SIZE; - if(pline) + fheap_cparam.managed.max_direct_size = H5G_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5G_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5G_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5G_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.max_man_size = H5G_FHEAP_MAX_MAN_SIZE; + if (pline) fheap_cparam.pline = *pline; /* Create fractal heap for storing links */ - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create fractal heap") /* Retrieve the heap's address in the file */ - if(H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0) + if (H5HF_get_heap_addr(fheap, &(linfo->fheap_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get fractal heap address") /* Retrieve the heap's ID length in the file */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") HDassert(fheap_id_len == H5G_DENSE_FHEAP_ID_LEN); /* Create the name index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5G_BT2_NAME; + bt2_cparam.cls = H5G_BT2_NAME; bt2_cparam.node_size = (size_t)H5G_NAME_BT2_NODE_SIZE; H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t); - bt2_cparam.rrec_size = 4 + /* Name's hash value */ - (uint32_t)fheap_id_len; /* Fractal heap ID */ + bt2_cparam.rrec_size = 4 + /* Name's hash value */ + (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_NAME_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_NAME_BT2_MERGE_PERC; - if(NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_name = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for name index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0) + if (H5B2_get_addr(bt2_name, &(linfo->name_bt2_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for name index") /* Check if we should create a creation order index v2 B-tree */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Create the creation order index v2 B-tree */ HDmemset(&bt2_cparam, 0, sizeof(bt2_cparam)); - bt2_cparam.cls = H5G_BT2_CORDER; + bt2_cparam.cls = H5G_BT2_CORDER; bt2_cparam.node_size = (size_t)H5G_CORDER_BT2_NODE_SIZE; H5_CHECK_OVERFLOW(fheap_id_len, /* From: */ hsize_t, /* To: */ uint32_t); - bt2_cparam.rrec_size = 8 + /* Creation order value */ - (uint32_t)fheap_id_len; /* Fractal heap ID */ + bt2_cparam.rrec_size = 8 + /* Creation order value */ + (uint32_t)fheap_id_len; /* Fractal heap ID */ bt2_cparam.split_percent = H5G_CORDER_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5G_CORDER_BT2_MERGE_PERC; - if(NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) + if (NULL == (bt2_corder = H5B2_create(f, &bt2_cparam, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create v2 B-tree for creation order index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0) + if (H5B2_get_addr(bt2_corder, &(linfo->corder_bt2_addr)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for creation order index") } /* end if */ done: /* Close the open objects */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_create() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_insert * @@ -362,15 +352,15 @@ H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) 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 */ - size_t link_size; /* Size of serialized link in the heap */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + size_t link_size; /* Size of serialized link in the heap */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -382,74 +372,73 @@ H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) HDassert(lnk); /* Find out the size of buffer needed for serialized link */ - if((link_size = H5O_msg_raw_size(f, H5O_LINK_ID, FALSE, lnk)) == 0) + if ((link_size = H5O_msg_raw_size(f, H5O_LINK_ID, FALSE, lnk)) == 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get link size") /* Wrap the local buffer for serialized link */ - if(NULL == (wb = H5WB_wrap(link_buf, sizeof(link_buf)))) + if (NULL == (wb = H5WB_wrap(link_buf, sizeof(link_buf)))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for link */ - if(NULL == (link_ptr = H5WB_actual(wb, link_size))) + if (NULL == (link_ptr = H5WB_actual(wb, link_size))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Create serialized form of link */ - if(H5O_msg_encode(f, H5O_LINK_ID, FALSE, (unsigned char *)link_ptr, lnk) < 0) + if (H5O_msg_encode(f, H5O_LINK_ID, FALSE, (unsigned char *)link_ptr, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode link") /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Insert the serialized link into the fractal heap */ - if(H5HF_insert(fheap, link_size, link_ptr, udata.id) < 0) + if (H5HF_insert(fheap, link_size, link_ptr, udata.id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Create the callback information for v2 B-tree record insertion */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = lnk->name; - udata.common.name_hash = H5_checksum_lookup3(lnk->name, HDstrlen(lnk->name), 0); - udata.common.corder = lnk->corder; - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = lnk->name; + udata.common.name_hash = H5_checksum_lookup3(lnk->name, HDstrlen(lnk->name), 0); + udata.common.corder = lnk->corder; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; /* udata.id already set in H5HF_insert() call */ /* Insert link into 'name' tracking v2 B-tree */ - if(H5B2_insert(bt2_name, &udata) < 0) + if (H5B2_insert(bt2_name, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") /* Check if we should create a creation order index v2 B-tree record */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Open the creation order index v2 B-tree */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(NULL == (bt2_corder = H5B2_open(f, linfo->corder_bt2_addr, NULL))) + if (NULL == (bt2_corder = H5B2_open(f, linfo->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Insert the record into the creation order index v2 B-tree */ - if(H5B2_insert(bt2_corder, &udata) < 0) + if (H5B2_insert(bt2_corder, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert record into v2 B-tree") } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup_cb * @@ -465,9 +454,9 @@ H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -478,14 +467,13 @@ H5G__dense_lookup_cb(const void *_lnk, void *_user_lnk) HDassert(user_lnk); /* Copy link information */ - if(H5O_msg_copy(H5O_LINK_ID, lnk, user_lnk) == NULL) + if (H5O_msg_copy(H5O_LINK_ID, lnk, user_lnk) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup * @@ -499,13 +487,12 @@ H5G__dense_lookup_cb(const void *_lnk, void *_user_lnk) *------------------------------------------------------------------------- */ htri_t -H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, - H5O_link_t *lnk) +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 */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -518,36 +505,35 @@ H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, HDassert(lnk); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Construct the user data for v2 B-tree callback */ - udata.f = f; - udata.fheap = fheap; - udata.name = name; - udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.found_op = H5G__dense_lookup_cb; /* v2 B-tree comparison callback */ + udata.f = f; + udata.fheap = fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.found_op = H5G__dense_lookup_cb; /* v2 B-tree comparison callback */ udata.found_op_data = lnk; /* Find & copy the named link in the 'name' index */ - if((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) + if ((ret_value = H5B2_find(bt2_name, &udata, NULL, NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in name index") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup_by_idx_fh_cb * @@ -564,29 +550,29 @@ H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode link information & keep a copy */ - if(NULL == (tmp_lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (tmp_lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, tmp_lnk, udata->lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, tmp_lnk, udata->lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: /* Release the space allocated for the link */ - if(tmp_lnk) + if (tmp_lnk) H5O_msg_free(H5O_LINK_ID, tmp_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup_by_idx_bt2_cb * @@ -602,27 +588,26 @@ H5G__dense_lookup_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) 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_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + 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_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.lnk = bt2_udata->lnk; /* Call fractal heap 'op' routine, to copy the link information */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G__dense_lookup_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G__dense_lookup_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "link found callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_lookup_by_idx * @@ -637,14 +622,14 @@ H5G__dense_lookup_by_idx_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ 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) +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 */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - 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 */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -656,7 +641,7 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, HDassert(lnk); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. * If the order is native, use the B-tree for names. @@ -678,59 +663,58 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_lbi_t udata; /* User data for v2 B-tree link lookup */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree callback */ - udata.f = f; + udata.f = f; udata.fheap = fheap; - udata.lnk = lnk; + udata.lnk = lnk; /* Find & copy the link in the appropriate index */ - if(H5B2_index(bt2, order, n, H5G__dense_lookup_by_idx_bt2_cb, &udata) < 0) + if (H5B2_index(bt2, order, n, H5G__dense_lookup_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to locate link in index") - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Copy link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, <able.lnks[n], lnk)) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_build_table_cb * @@ -748,8 +732,8 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, static herr_t H5G__dense_build_table_cb(const H5O_link_t *lnk, void *_udata) { - H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -759,7 +743,7 @@ H5G__dense_build_table_cb(const H5O_link_t *lnk, void *_udata) HDassert(udata->curr_lnk < udata->ltable->nlinks); /* Copy link information */ - if(H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL) + if (H5O_msg_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") /* Increment number of links stored */ @@ -769,7 +753,6 @@ H5G__dense_build_table_cb(const H5O_link_t *lnk, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_build_table_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_build_table * @@ -787,10 +770,10 @@ H5G__dense_build_table_cb(const H5O_link_t *lnk, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, - H5_iter_order_t order, H5G_link_table_t *ltable) +H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, + H5G_link_table_t *ltable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -804,23 +787,24 @@ H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, ltable->nlinks = (size_t)linfo->nlinks; /* Allocate space for the table entries */ - if(ltable->nlinks > 0) { - H5G_dense_bt_ud_t udata; /* User data for iteration callback */ + if (ltable->nlinks > 0) { + H5G_dense_bt_ud_t udata; /* User data for iteration callback */ /* Allocate the table to store the links */ - if((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) + if ((ltable->lnks = (H5O_link_t *)H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set up user data for iteration */ - udata.ltable = ltable; + udata.ltable = ltable; udata.curr_lnk = 0; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G__dense_iterate(f, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G__dense_build_table_cb, &udata) < 0) + if (H5G__dense_iterate(f, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, + H5G__dense_build_table_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(ltable, idx_type, order) < 0) + if (H5G__link_sort_table(ltable, idx_type, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else @@ -830,7 +814,6 @@ H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_iterate_fh_cb * @@ -847,8 +830,8 @@ H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, static herr_t H5G__dense_iterate_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_it_t *udata = (H5G_fh_ud_it_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_it_t *udata = (H5G_fh_ud_it_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -859,14 +842,14 @@ H5G__dense_iterate_fh_cb(const void *obj, size_t obj_len, void *_udata) * HDF5 routine, it could attempt to re-protect that direct block for the * heap, causing the HDF5 routine called to fail - QAK) */ - if(NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_iterate_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_iterate_bt2_cb * @@ -882,24 +865,24 @@ H5G__dense_iterate_fh_cb(const void *obj, size_t obj_len, void *_udata) 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 */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + 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 */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC /* Check for skipping links */ - if(bt2_udata->skip > 0) + if (bt2_udata->skip > 0) --bt2_udata->skip; else { - H5G_fh_ud_it_t fh_udata; /* User data for fractal heap 'op' callback */ + H5G_fh_ud_it_t fh_udata; /* User data for fractal heap 'op' callback */ /* Prepare user data for callback */ /* down */ fh_udata.f = bt2_udata->f; /* Call fractal heap 'op' routine, to copy the link information */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G__dense_iterate_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G__dense_iterate_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") /* Make the callback */ @@ -914,14 +897,13 @@ H5G__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) bt2_udata->count++; /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_iterate_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_iterate * @@ -935,15 +917,14 @@ H5G__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ 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) +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 */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - 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 */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -955,7 +936,7 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, HDassert(op); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -977,66 +958,65 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { HDassert(H5F_addr_defined(linfo->name_bt2_addr)); bt2_addr = linfo->name_bt2_addr; } /* end if */ /* Check on iteration order */ - if(order == H5_ITER_NATIVE) { - H5G_bt2_ud_it_t udata; /* User data for iterator callback */ + if (order == H5_ITER_NATIVE) { + H5G_bt2_ud_it_t udata; /* User data for iterator callback */ /* Sanity check */ HDassert(H5F_addr_defined(bt2_addr)); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Construct the user data for v2 B-tree iterator callback */ - udata.f = f; - udata.fheap = fheap; - udata.skip = skip; - udata.count = 0; - udata.op = op; + udata.f = f; + udata.fheap = fheap; + udata.skip = skip; + udata.count = 0; + udata.op = op; udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ /* (by hash of name) */ - if((ret_value = H5B2_iterate(bt2, H5G__dense_iterate_bt2_cb, &udata)) < 0) + if ((ret_value = H5B2_iterate(bt2, H5G__dense_iterate_bt2_cb, &udata)) < 0) HERROR(H5E_SYM, H5E_BADITER, "link iteration failed"); /* Update the last link examined, if requested */ - if(last_lnk) + if (last_lnk) *last_lnk = udata.count; } /* end if */ else { /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_get_name_by_idx_fh_cb * @@ -1053,23 +1033,24 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Get the length of the name */ udata->name_len = (ssize_t)HDstrlen(lnk->name); /* Copy the name into the user's buffer, if given */ - if(udata->name) { + if (udata->name) { HDstrncpy(udata->name, lnk->name, MIN((size_t)(udata->name_len + 1), udata->name_size)); - if((size_t)udata->name_len >= udata->name_size) + if ((size_t)udata->name_len >= udata->name_size) udata->name[udata->name_size - 1] = '\0'; } /* end if */ @@ -1080,7 +1061,6 @@ H5G__dense_get_name_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_get_name_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_get_name_by_idx_bt2_cb * @@ -1096,21 +1076,21 @@ H5G__dense_get_name_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) 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_fh_ud_gnbi_t fh_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_fh_ud_gnbi_t fh_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Prepare user data for callback */ /* down */ - fh_udata.f = bt2_udata->f; - fh_udata.name = bt2_udata->name; + fh_udata.f = bt2_udata->f; + fh_udata.name = bt2_udata->name; fh_udata.name_size = bt2_udata->name_size; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->fheap, record->id, H5G__dense_get_name_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, record->id, H5G__dense_get_name_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link found callback failed") /* Set the name's full length to return */ @@ -1120,7 +1100,6 @@ H5G__dense_get_name_by_idx_bt2_cb(const void *_record, void *_bt2_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_get_name_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_get_name_by_idx * @@ -1135,14 +1114,14 @@ H5G__dense_get_name_by_idx_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ 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) +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 */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - 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 */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -1153,7 +1132,7 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -1175,69 +1154,68 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_gnbi_t udata; /* User data for v2 B-tree callback */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.f = f; - udata.fheap = fheap; - udata.name = name; + udata.f = f; + udata.fheap = fheap; + udata.name = name; udata.name_size = size; /* Retrieve the name according to the v2 B-tree's index order */ - if(H5B2_index(bt2, order, n, H5G__dense_get_name_by_idx_bt2_cb, &udata) < 0) + if (H5B2_index(bt2, order, n, H5G__dense_get_name_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "can't locate object in v2 B-tree") /* Set return value */ ret_value = udata.name_len; - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(ltable.lnks[n].name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, ltable.lnks[n].name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ - } /* end else */ + } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_fh_cb * @@ -1253,23 +1231,24 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode link information */ - if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Check for removing the link from the creation order index */ - if(H5F_addr_defined(udata->corder_bt2_addr)) { - H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(udata->corder_bt2_addr)) { + H5G_bt2_ud_common_t bt2_udata; /* Info for B-tree callbacks */ /* Open the creation order index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(udata->f, udata->corder_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(udata->f, udata->corder_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Set up the user data for the v2 B-tree 'record remove' callback */ @@ -1277,31 +1256,31 @@ H5G__dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) bt2_udata.corder = lnk->corder; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from creation order index v2 B-tree") + if (H5B2_remove(bt2, &bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, + "unable to remove link from creation order index v2 B-tree") } /* end if */ /* Replace open objects' names, if requested */ - if(udata->replace_names) - if(H5G__link_name_replace(udata->f, udata->grp_full_path_r, lnk) < 0) + if (udata->replace_names) + if (H5G__link_name_replace(udata->f, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link, if requested */ /* (call message "delete" callback directly: *ick* - QAK) */ - if(H5O_link_delete(udata->f, NULL, lnk) < 0) + if (H5O_link_delete(udata->f, NULL, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") - if(lnk) + if (lnk) H5O_msg_free(H5O_LINK_ID, lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_bt2_cb * @@ -1317,33 +1296,32 @@ H5G__dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) 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_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->common.f; + fh_udata.f = bt2_udata->common.f; fh_udata.corder_bt2_addr = bt2_udata->corder_bt2_addr; fh_udata.grp_full_path_r = bt2_udata->grp_full_path_r; - fh_udata.replace_names = bt2_udata->replace_names; + fh_udata.replace_names = bt2_udata->replace_names; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->common.fheap, record->id, H5G__dense_remove_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->common.fheap, record->id, H5G__dense_remove_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link removal callback failed") /* Remove record from fractal heap, if requested */ - if(bt2_udata->rem_from_fheap) - if(H5HF_remove(bt2_udata->common.fheap, record->id) < 0) + if (bt2_udata->rem_from_fheap) + if (H5HF_remove(bt2_udata->common.fheap, record->id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from fractal heap") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove * @@ -1357,13 +1335,12 @@ 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) +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 */ - H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ - H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1375,40 +1352,39 @@ H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_ HDassert(name && *name); /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the name index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = name; - udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = name; + udata.common.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.common.found_op = NULL; udata.common.found_op_data = NULL; - udata.rem_from_fheap = TRUE; - udata.corder_bt2_addr = linfo->corder_bt2_addr; - udata.grp_full_path_r = grp_full_path_r; - udata.replace_names = TRUE; + udata.rem_from_fheap = TRUE; + udata.corder_bt2_addr = linfo->corder_bt2_addr; + udata.grp_full_path_r = grp_full_path_r; + udata.replace_names = TRUE; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &udata, H5G__dense_remove_bt2_cb, &udata) < 0) + if (H5B2_remove(bt2, &udata, H5G__dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from name index v2 B-tree") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_by_idx_fh_cb * @@ -1424,13 +1400,14 @@ H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_ static herr_t H5G__dense_remove_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5G_fh_ud_rmbi_t *udata = (H5G_fh_ud_rmbi_t *)_udata; /* User data for fractal heap 'op' callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_fh_ud_rmbi_t *udata = (H5G_fh_ud_rmbi_t *)_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Decode link information */ - if(NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, (const unsigned char *)obj))) + if (NULL == (udata->lnk = (H5O_link_t *)H5O_msg_decode(udata->f, NULL, H5O_LINK_ID, obj_len, + (const unsigned char *)obj))) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5_ITER_ERROR, "can't decode link") /* Can't operate on link here because the fractal heap block is locked */ @@ -1439,7 +1416,6 @@ H5G__dense_remove_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_by_idx_bt2_cb * @@ -1455,16 +1431,16 @@ H5G__dense_remove_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) static herr_t 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; /* Set the heap ID to operate on */ @@ -1480,20 +1456,20 @@ H5G__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end else */ /* Set up the user data for fractal heap 'op' callback */ - fh_udata.f = bt2_udata->f; + fh_udata.f = bt2_udata->f; fh_udata.lnk = NULL; /* Call fractal heap 'op' routine, to perform user callback */ - if(H5HF_op(bt2_udata->fheap, heap_id, H5G__dense_remove_by_idx_fh_cb, &fh_udata) < 0) + if (H5HF_op(bt2_udata->fheap, heap_id, H5G__dense_remove_by_idx_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, "link removal callback failed") HDassert(fh_udata.lnk); /* Check for removing the link from the "other" index (creation order, when name used and vice versa) */ - if(H5F_addr_defined(bt2_udata->other_bt2_addr)) { - H5G_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ + if (H5F_addr_defined(bt2_udata->other_bt2_addr)) { + H5G_bt2_ud_common_t other_bt2_udata; /* Info for B-tree callbacks */ /* Determine the index being used */ - if(bt2_udata->idx_type == H5_INDEX_NAME) { + if (bt2_udata->idx_type == H5_INDEX_NAME) { /* Set up the user data for the v2 B-tree 'record remove' callback */ other_bt2_udata.corder = fh_udata.lnk->corder; } /* end if */ @@ -1501,50 +1477,51 @@ H5G__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set up the user data for the v2 B-tree 'record remove' callback */ - other_bt2_udata.f = bt2_udata->f; + other_bt2_udata.f = bt2_udata->f; other_bt2_udata.fheap = bt2_udata->fheap; - other_bt2_udata.name = fh_udata.lnk->name; - other_bt2_udata.name_hash = H5_checksum_lookup3(fh_udata.lnk->name, HDstrlen(fh_udata.lnk->name), 0); - other_bt2_udata.found_op = NULL; + other_bt2_udata.name = fh_udata.lnk->name; + other_bt2_udata.name_hash = + H5_checksum_lookup3(fh_udata.lnk->name, HDstrlen(fh_udata.lnk->name), 0); + other_bt2_udata.found_op = NULL; other_bt2_udata.found_op_data = NULL; } /* end else */ /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(bt2_udata->f, bt2_udata->other_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for 'other' index") /* Set the common information for the v2 B-tree remove operation */ /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from 'other' index v2 B-tree") + if (H5B2_remove(bt2, &other_bt2_udata, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, + "unable to remove link from 'other' index v2 B-tree") } /* end if */ /* Replace open objects' names */ - if(H5G__link_name_replace(bt2_udata->f, bt2_udata->grp_full_path_r, fh_udata.lnk) < 0) + if (H5G__link_name_replace(bt2_udata->f, bt2_udata->grp_full_path_r, fh_udata.lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link */ /* (call link message "delete" callback directly: *ick* - QAK) */ - if(H5O_link_delete(bt2_udata->f, NULL, fh_udata.lnk) < 0) + if (H5O_link_delete(bt2_udata->f, NULL, fh_udata.lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") /* Release the space allocated for the link */ H5O_msg_free(H5O_LINK_ID, fh_udata.lnk); /* Remove record from fractal heap */ - if(H5HF_remove(bt2_udata->fheap, heap_id) < 0) + if (H5HF_remove(bt2_udata->fheap, heap_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from fractal heap") done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for 'other' index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_remove_by_idx * @@ -1559,14 +1536,14 @@ H5G__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) *------------------------------------------------------------------------- */ 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) +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 */ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - 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 */ + 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 */ + haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1577,7 +1554,7 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5_INDEX_NAME) { + if (idx_type == H5_INDEX_NAME) { /* Since names are hashed, getting them in strictly increasing or * decreasing order requires building a table and sorting it. If * the order is native, use the B-tree for names. @@ -1599,61 +1576,60 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful * use the B-tree for names instead of building a table to speed up the * process. */ - if(order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { + if (order == H5_ITER_NATIVE && !H5F_addr_defined(bt2_addr)) { bt2_addr = linfo->name_bt2_addr; HDassert(H5F_addr_defined(bt2_addr)); } /* end if */ /* If there is an index defined for the field, use it */ - if(H5F_addr_defined(bt2_addr)) { - H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ + if (H5F_addr_defined(bt2_addr)) { + H5G_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) + if (NULL == (bt2 = H5B2_open(f, bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for index") /* Set up the user data for the v2 B-tree 'remove by index' callback */ - udata.f = f; - udata.fheap = fheap; - udata.idx_type = idx_type; - udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; + udata.f = f; + udata.fheap = fheap; + udata.idx_type = idx_type; + udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; udata.grp_full_path_r = grp_full_path_r; /* Remove the record from the name index v2 B-tree */ - if(H5B2_remove_by_idx(bt2, order, n, H5G__dense_remove_by_idx_bt2_cb, &udata) < 0) + if (H5B2_remove_by_idx(bt2, order, n, H5G__dense_remove_by_idx_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from indexed v2 B-tree") - } /* end if */ - else { /* Otherwise, we need to build a table of the links and sort it */ + } /* end if */ + else { /* Otherwise, we need to build a table of the links and sort it */ /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) + if (H5G__dense_build_table(f, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") /* Check for going out of bounds */ - if(n >= ltable.nlinks) + if (n >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Remove the appropriate link from the dense storage */ - if(H5G__dense_remove(f, linfo, grp_full_path_r, ltable.lnks[n].name) < 0) + if (H5G__dense_remove(f, linfo, grp_full_path_r, ltable.lnks[n].name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from dense storage") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__dense_delete * @@ -1669,7 +1645,7 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1682,47 +1658,47 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) /* Check if we are to adjust the ref. count for all the links */ /* (we adjust the ref. count when deleting a group and we _don't_ adjust * the ref. count when transitioning back to compact storage) - */ - if(adj_link) { - H5HF_t *fheap = NULL; /* Fractal heap handle */ - H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ + */ + if (adj_link) { + 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 */ - if(NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) + if (NULL == (fheap = H5HF_open(f, linfo->fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up the user data for the v2 B-tree 'record remove' callback */ - udata.common.f = f; - udata.common.fheap = fheap; - udata.common.name = NULL; - udata.common.name_hash = 0; - udata.common.found_op = NULL; + udata.common.f = f; + udata.common.fheap = fheap; + udata.common.name = NULL; + udata.common.name_hash = 0; + udata.common.found_op = NULL; udata.common.found_op_data = NULL; - udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ - udata.corder_bt2_addr = linfo->corder_bt2_addr; - udata.grp_full_path_r = NULL; - udata.replace_names = FALSE; + udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ + udata.corder_bt2_addr = linfo->corder_bt2_addr; + udata.grp_full_path_r = NULL; + udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ - if(H5B2_delete(f, linfo->name_bt2_addr, NULL, H5G__dense_remove_bt2_cb, &udata) < 0) + if (H5B2_delete(f, linfo->name_bt2_addr, NULL, H5G__dense_remove_bt2_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") /* Close the fractal heap */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") } /* end if */ else { /* Delete the name index, without adjusting the ref. count on the links */ - if(H5B2_delete(f, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, linfo->name_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for name index") } /* end else */ linfo->name_bt2_addr = HADDR_UNDEF; /* Check if we should delete the creation order index v2 B-tree */ - if(linfo->index_corder) { + if (linfo->index_corder) { /* Delete the creation order index, without adjusting the ref. count on the links */ HDassert(H5F_addr_defined(linfo->corder_bt2_addr)); - if(H5B2_delete(f, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) + if (H5B2_delete(f, linfo->corder_bt2_addr, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete v2 B-tree for creation order index") linfo->corder_bt2_addr = HADDR_UNDEF; } /* end if */ @@ -1730,87 +1706,10 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) HDassert(!H5F_addr_defined(linfo->corder_bt2_addr)); /* Delete the fractal heap */ - if(H5HF_delete(f, linfo->fheap_addr) < 0) + if (H5HF_delete(f, linfo->fheap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") linfo->fheap_addr = HADDR_UNDEF; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_delete() */ - -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G__dense_get_type_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. - * - * Note: This routine assumes a lookup on the link name index in - * increasing order and isn't currently set up to be as - * flexible as other routines in this code module, because - * the H5Gget_objtype_by_idx that it's supporting is - * deprecated. - * - * Return: Success: Non-negative, object type - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sep 19 2006 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__dense_get_type_by_idx(H5F_t *f, H5O_linfo_t *linfo, hsize_t idx) -{ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* - * Check arguments. - */ - HDassert(f); - HDassert(linfo); - - /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links") - - /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "index out of bound") - - /* Determine type of object */ - if(ltable.lnks[idx].type == H5L_TYPE_SOFT) - ret_value = H5G_LINK; - else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) - ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD) { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = f; - tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - - /* Map to group object type */ - if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } else { - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") - } /* end else */ - -done: - /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__dense_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 089ed8311f1..037669b1e76 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,27 +29,27 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -57,51 +57,37 @@ #ifndef H5_NO_DEPRECATED_SYMBOLS /* User data for path traversal routine for getting object info */ 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 */ + 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 */ } H5G_trav_goi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - -static herr_t H5G__link(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name, hid_t lcpl_id); -static herr_t H5G__move(hid_t src_loc_id, const char *src_name, - hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id); -static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); -static H5G_obj_t H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx); +static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5G_map_obj_type * @@ -117,13 +103,13 @@ static H5G_obj_t H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx); H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type) { - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Map object type to older "group" object type */ - switch(obj_type) { + switch (obj_type) { case H5O_TYPE_GROUP: ret_value = H5G_GROUP; break; @@ -136,6 +122,9 @@ H5G_map_obj_type(H5O_type_t obj_type) ret_value = H5G_TYPE; break; + case H5O_TYPE_MAP: + /* Maps not supported in native VOL connector */ + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -145,7 +134,6 @@ H5G_map_obj_type(H5O_type_t obj_type) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_map_obj_type() */ - /*------------------------------------------------------------------------- * Function: H5Gcreate1 * @@ -153,10 +141,10 @@ H5G_map_obj_type(H5O_type_t obj_type) * specified NAME. The group is opened for write access * and it's object ID is returned. * - * The optional SIZE_HINT specifies how much file space to - * reserve to store the names that will appear in this - * group. If a non-positive value is supplied for the SIZE_HINT - * then a default size is chosen. + * The SIZE_HINT parameter specifies how much file space to reserve + * to store the names that will appear in this group. This number + * must be less than or equal to UINT32_MAX. If zero is supplied + * for the SIZE_HINT then a default size is chosen. * * Note: Deprecated in favor of H5Gcreate2 * @@ -164,7 +152,7 @@ H5G_map_obj_type(H5O_type_t obj_type) * writing. Call H5Gclose() when finished with * the group. * - * Failure: FAIL + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Wednesday, September 24, 1997 @@ -174,72 +162,84 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ - hid_t ret_value; /* Return value */ + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name given") + if (size_hint > UINT32_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "size_hint cannot be larger than UINT32_MAX") /* Check if we need to create a non-standard GCPL */ - if(size_hint > 0) { - H5P_genplist_t *gc_plist; /* Property list created */ - H5O_ginfo_t ginfo; /* Group info property */ + if (size_hint > 0) { + H5O_ginfo_t ginfo; /* Group info property */ + H5P_genplist_t *gc_plist; /* Property list created */ /* Get the default property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Make a copy of the default property list */ - if((tmp_gcpl = H5P_copy_plist(gc_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") + if ((tmp_gcpl = H5P_copy_plist(gc_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") /* Get pointer to the copied property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Get the group info property */ - if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") + if (H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get group info") /* Set the non-default local heap size hint */ H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t); - if(H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") - } /* end if */ + if (H5P_set(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info") + } else tmp_gcpl = H5P_GROUP_CREATE_DEFAULT; /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Create the group */ + if (NULL == + (grp = H5VL_group_create(vol_obj, &loc_params, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl, + H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Get an atom for the group */ + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) - if(H5I_dec_ref(tmp_gcpl) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list") + if (H5I_INVALID_HID != tmp_gcpl && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) + if (H5I_dec_ref(tmp_gcpl) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list") - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate1() */ - /*------------------------------------------------------------------------- * Function: H5Gopen1 * @@ -250,7 +250,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) * * Return: Success: Object ID of the group. * - * Failure: FAIL + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Wednesday, December 31, 1997 @@ -260,36 +260,43 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) hid_t H5Gopen1(hid_t loc_id, const char *name) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ - hid_t ret_value; /* Return value */ + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the group */ - if(NULL == (grp = H5G__open_name(&loc, name))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + if (NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, H5P_GROUP_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") - /* Register an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Get an atom for the group */ + if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + if (H5I_INVALID_HID == ret_value) + if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ - /*------------------------------------------------------------------------- * Function: H5Glink * @@ -301,30 +308,77 @@ H5Gopen1(hid_t loc_id, const char *name) herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iLl*s*s", cur_loc_id, type, cur_name, new_name); /* Check arguments */ - if(!cur_name || !*cur_name) + if (!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!new_name || !*new_name) + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(cur_loc_id) < 0) + if (H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call internal routine to create link */ - if(H5G__link(cur_loc_id, cur_name, type, H5L_SAME_LOC, new_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "couldn't create link") + /* Create link */ + if (type == H5L_TYPE_HARD) { + 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 */ + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Construct a temporary VOL object */ + tmp_vol_obj.data = NULL; + tmp_vol_obj.connector = vol_obj->connector; + + /* Create the link through the VOL */ + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + vol_obj->data, &loc_params1) < 0) + 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_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(cur_loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the link through the VOL */ + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + cur_name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not a valid link type") done: FUNC_LEAVE_API(ret_value) } /* end H5Glink() */ - /*------------------------------------------------------------------------- * Function: H5Glink2 * @@ -334,104 +388,83 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new *------------------------------------------------------------------------- */ herr_t -H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name) +H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sLli*s", cur_loc_id, cur_name, type, new_loc_id, new_name); /* Check arguments */ - if(!cur_name || !*cur_name) + if (!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!new_name || !*new_name) + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(cur_loc_id) < 0) + if (H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call internal routine to create link */ - if(H5G__link(cur_loc_id, cur_name, type, new_loc_id, new_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "couldn't create link") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Glink2() */ - - -/*------------------------------------------------------------------------- - * Function: H5G__link - * - * Purpose: Internal routine to create a new link. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, December 18, 2017 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G__link(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name, hid_t lcpl_id) -{ - H5G_loc_t new_loc; /* Information about new link's group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - /* Create the appropriate kind of link */ - if(type == H5L_TYPE_HARD) { - H5G_loc_t cur_loc, *cur_loc_p; /* Information about current link's group */ - H5G_loc_t *new_loc_p; /* Information about new link's group */ - - /* Finish checking arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, lcpl_id) < 0) + if (type == H5L_TYPE_HARD) { + 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; + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* get the location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the link through the VOL */ + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + vol_obj1->data, &loc_params1) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ - else if(type == H5L_TYPE_SOFT) { - /* Soft links only need one location, the new_loc_id, but it's possible - * that new_loc_id is H5L_SAME_LOC - */ - if(new_loc_id == H5L_SAME_LOC) + else if (type == H5L_TYPE_SOFT) { + 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 + * new_loc_id is H5L_SAME_LOC */ + if (new_loc_id == H5L_SAME_LOC) new_loc_id = cur_loc_id; - /* Finish checking arguments */ - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(new_loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Create the link */ - if(H5L_create_soft(cur_name, &new_loc, new_name, lcpl_id) < 0) + /* Create the link through the VOL */ + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + cur_name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") - } /* end else if */ + } /* end else-if */ else - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "Not a valid link type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid link type") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__link() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Glink2() */ - /*------------------------------------------------------------------------- * Function: H5Gmove * @@ -442,24 +475,40 @@ H5G__link(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(src_loc_id) < 0) + if (H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call common routine to move the link */ - if(H5G__move(src_loc_id, src_name, H5L_SAME_LOC, dst_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Move the link */ + if (H5VL_link_move(vol_obj, &loc_params1, NULL, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") done: FUNC_LEAVE_API(ret_value) } /* end H5Gmove() */ - /*------------------------------------------------------------------------- * Function: H5Gmove2 * @@ -468,85 +517,51 @@ 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) +H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - herr_t ret_value = SUCCEED; /* Return value */ + 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_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name); - /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(dst_loc_id) < 0) + if (H5CX_set_loc(dst_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call common routine to move the link */ - if(H5G__move(src_loc_id, src_name, dst_loc_id, dst_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gmove2() */ - - -/*------------------------------------------------------------------------- - * Function: H5G__move - * - * Purpose: Renames an object within an HDF5 file and moves it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G__move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t lcpl_id) -{ - H5G_loc_t src_loc, *src_loc_p; /* Group info for source location */ - H5G_loc_t dst_loc, *dst_loc_p; /* Group info for destination location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check arguments */ - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no destination name specified") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; + /* Set location parameter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* Set location parameter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if (H5L_SAME_LOC != src_loc_id) + /* get the location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (H5L_SAME_LOC != dst_loc_id) + /* get the location object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id) < 0) + if (H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, H5P_LINK_CREATE_DEFAULT, + H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "unable to move link") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__move() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Gmove2() */ - /*------------------------------------------------------------------------- * Function: H5Gunlink * @@ -557,31 +572,39 @@ H5G__move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no name") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call H5L routine... */ - if(H5L_delete(&loc, name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Delete the link */ + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Gunlink() */ - /*------------------------------------------------------------------------- * Function: H5Gget_linkval * @@ -591,33 +614,41 @@ 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*/) +H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call the link routine which provides this capability */ - if(H5L_get_val(&loc, name, buf, size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "couldn't get link info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the link value */ + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_linkval() */ - /*------------------------------------------------------------------------- * Function: H5Gset_comment * @@ -638,30 +669,39 @@ 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) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call the common routine which provides this capability */ - if(H5G_loc_set_comment(&loc, name, comment) < 0) + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set the comment */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) } /* end H5Gset_comment() */ - /*------------------------------------------------------------------------- * Function: H5Gget_comment * @@ -688,32 +728,45 @@ 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) { - H5G_loc_t loc; /* Group's location */ - int ret_value; /* Return value */ + 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 */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(-1) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(bufsize > 0 && !buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no name specified") + if (bufsize > 0 && !buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no buffer specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, -1, "can't set collective metadata read info") + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") - /* Call the common routine which provides this capability */ - if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value") + /* Get the comment */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, buf, bufsize, &op_ret) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") + + /* Set return value */ + ret_value = (int)op_ret; done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_comment() */ - /*------------------------------------------------------------------------- * Function: H5Giterate * @@ -739,46 +792,57 @@ 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) +H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_obj; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value; /* Return value */ + 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 */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data); /* Check args */ - if(!name || !*name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no name specified") - if(idx_p && *idx_p < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "invalid index specified") - if(!op) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no operator specified") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_p && *idx_p < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Set number of objects looked at to zero */ last_obj = 0; - idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); + idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p); /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_OLD; + lnk_op.op_type = H5G_LINK_OP_OLD; lnk_op.op_func.op_old = op; - /* Call the common routine which provides this capability */ - if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object pointer */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") + + /* Call private iteration function, through VOL callback */ + if ((ret_value = H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_ITERATE_OLD, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) + HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); /* Set the index we stopped at */ - if(idx_p) + if (idx_p) *idx_p = (int)last_obj; done: FUNC_LEAVE_API(ret_value) } /* end H5Giterate() */ - /*------------------------------------------------------------------------- * Function: H5Gget_num_objs * @@ -798,36 +862,42 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { - H5G_loc_t loc; /* Location of object */ - H5G_info_t grp_info; /* Group information */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value = SUCCEED; + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", loc_id, num_objs); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") - if(!num_objs) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "bad pointer to # of objects") - - /* Retrieve information about the group */ - if(H5G__obj_info(loc.oloc, &grp_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine # of objects") - - /* Set the number of objects [sic: links] in the group */ + id_type = H5I_get_type(loc_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID") + if (!num_objs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = id_type; + + /* Get group location */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the group's information */ + if (H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, + &grp_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") + + /* Set the number of objects [i.e. links] in the group */ *num_objs = grp_info.nlinks; done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_num_objs() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objinfo * @@ -846,30 +916,43 @@ 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*/) +H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no name specified") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - /* Get info */ - if(H5G__get_objinfo(&loc, name, follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); + + /* Retrieve object info */ + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); + + /* Retrieve the object's information */ + if (H5VL_group_optional(vol_obj, H5VL_NATIVE_GROUP_GET_OBJINFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &loc_params, (unsigned)follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* end H5Gget_objinfo() */ - /*------------------------------------------------------------------------- * Function: H5G__get_objinfo_cb * @@ -884,71 +967,78 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, *------------------------------------------------------------------------- */ static herr_t -H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL && obj_loc == NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) + if (lnk == NULL && obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name); /* Only modify user's buffer if it's available */ - if(udata->statbuf) { - H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ + if (udata->statbuf) { + H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ /* Common code to retrieve the file's fileno */ - if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno") + if (H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno"); /* Info for soft and UD links is gotten by H5L_get_info. If we have * a hard link, follow it and get info on the object */ - if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { - H5O_info_t oinfo; /* Object information */ + if (udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_info2_t dm_info; /* Data model information */ + H5O_native_info_t nat_info; /* Native information */ + haddr_t obj_addr; /* Address of object */ - /* Go retrieve the object information */ + /* Go retrieve the data model & native object information */ /* (don't need index & heap info) */ HDassert(obj_loc); - if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") + if (H5O_get_info(obj_loc->oloc, &dm_info, H5O_INFO_BASIC | H5O_INFO_TIME) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get data model object info") + if (H5O_get_native_info(obj_loc->oloc, &nat_info, H5O_INFO_HDR) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get native object info") /* Get mapped object type */ - statbuf->type = H5G_map_obj_type(oinfo.type); + statbuf->type = H5G_map_obj_type(dm_info.type); + + /* Get object number (i.e. address) for object */ + if (H5VL_native_token_to_addr(obj_loc->oloc->file, H5I_FILE, dm_info.token, &obj_addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") - /* Get object number (i.e. address) for object */ - statbuf->objno[0] = (unsigned long)(oinfo.addr); + statbuf->objno[0] = (unsigned long)(obj_addr); #if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); + statbuf->objno[1] = (unsigned long)(obj_addr >> 8 * sizeof(long)); #else - statbuf->objno[1] = 0; + statbuf->objno[1] = 0; #endif /* Get # of hard links pointing to object */ - statbuf->nlink = oinfo.rc; + statbuf->nlink = dm_info.rc; /* Get modification time for object */ - statbuf->mtime = oinfo.ctime; + statbuf->mtime = dm_info.ctime; /* Retrieve the object header information */ - statbuf->ohdr.size = oinfo.hdr.space.total; - statbuf->ohdr.free = oinfo.hdr.space.free; - statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; - statbuf->ohdr.nchunks = oinfo.hdr.nchunks; + statbuf->ohdr.size = nat_info.hdr.space.total; + statbuf->ohdr.free = nat_info.hdr.space.free; + statbuf->ohdr.nmesgs = nat_info.hdr.nmesgs; + statbuf->ohdr.nchunks = nat_info.hdr.nchunks; } /* end if */ - } /* end if */ + } /* end if */ done: /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__get_objinfo * @@ -965,60 +1055,63 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c * *------------------------------------------------------------------------- */ -static herr_t -H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, - H5G_stat_t *statbuf/*out*/) +herr_t +H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5G_trav_goi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_goi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE; /* Sanity checks */ HDassert(loc); HDassert(name && *name); - /* Reset stat buffer, if one was given */ - if(statbuf) + /* Reset stat buffer */ + if (statbuf) HDmemset(statbuf, 0, sizeof(H5G_stat_t)); /* Set up user data for retrieving information */ - udata.statbuf = statbuf; + udata.statbuf = statbuf; udata.follow_link = follow_link; - udata.loc_file = loc->oloc->file; + udata.loc_file = loc->oloc->file; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : H5G_TARGET_SLINK|H5G_TARGET_UDLINK), - H5G__get_objinfo_cb, &udata) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + if (H5G_traverse(loc, name, + (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), + H5G__get_objinfo_cb, &udata) < 0) + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist"); /* If we're pointing at a soft or UD link, get the real link length and type */ - if(statbuf && follow_link == 0) { - H5L_info_t linfo; /* Link information buffer */ - herr_t ret; + if (statbuf && follow_link == 0) { + H5L_info2_t linfo; /* Link information buffer */ + herr_t ret; /* Get information about link to the object. If this fails, e.g. * because the object is ".", just treat the object as a hard link. */ - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { ret = H5L_get_info(loc, name, &linfo); - } H5E_END_TRY + } + H5E_END_TRY; - if(ret >= 0 && linfo.type != H5L_TYPE_HARD) { + if (ret >= 0 && linfo.type != H5L_TYPE_HARD) { statbuf->linklen = linfo.u.val_size; - if(linfo.type == H5L_TYPE_SOFT) + if (linfo.type == H5L_TYPE_SOFT) { statbuf->type = H5G_LINK; - else { /* UD link. H5L_get_info checked for invalid link classes */ + } + else { + /* UD link. H5L_get_info checked for invalid link classes */ HDassert(linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX); statbuf->type = H5G_UDLINK; - } /* end else */ - } /* end if */ - } /* end if */ + } + } + } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objname_by_idx * @@ -1045,30 +1138,39 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { - H5G_loc_t loc; /* Object location */ - H5O_type_t obj_type; /* Type of object at location */ - ssize_t ret_value; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "ih*sz", loc_id, idx, name, size); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group") - - /* Call common routine */ - if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object name") + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set collective metadata read info") + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Call internal function */ + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name, size, &ret_value) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get object name") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_objname_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Gget_objtype_by_idx * @@ -1087,82 +1189,37 @@ 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) { - H5G_loc_t loc; /* Object location */ - H5G_obj_t ret_value; + 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 */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE2("Go", "ih", loc_id, idx); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); - /* Call internal function*/ - if(H5G_UNKNOWN == (ret_value = H5G__obj_get_type_by_idx(loc.oloc, idx))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object type") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_objtype_by_idx() */ + /* Retrieve the object's basic information (which includes its type) */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &oinfo, H5O_INFO_BASIC) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") - -/*------------------------------------------------------------------------- - * Function: H5G__obj_get_type_by_idx - * - * Purpose: Private function for H5Gget_objtype_by_idx. - * Returns the type of objects in the group by giving index. - * - * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * - * Failure: Negative - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -static H5G_obj_t -H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx) -{ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_STATIC_TAG(oloc->addr) - - /* Sanity check */ - HDassert(oloc); - - /* Check args */ - if(H5O_obj_type(oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "not a group") - - /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't check for link info message") - if(linfo_exists) { - if(H5F_addr_defined(linfo.fheap_addr)) { - /* Get the object's name from the dense link storage */ - if((ret_value = H5G__dense_get_type_by_idx(oloc->file, &linfo, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end if */ - else { - /* Get the object's type from the link messages */ - if((ret_value = H5G__compact_get_type_by_idx(oloc, &linfo, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end else */ - } /* end if */ - else { - /* Get the object's type from the symbol table */ - if((ret_value = H5G__stab_get_type_by_idx(oloc, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end else */ + /* Map to group object type */ + if (H5G_UNKNOWN == (ret_value = H5G_map_obj_type(oinfo.type))) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5G__obj_get_type_by_idx() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_objtype_by_idx() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gent.c b/src/H5Gent.c index 632ffa0efb6..2f1a2b44c5c 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,60 +20,47 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ -/* Declare extern the PQ free list for the wrapped strings */ -H5FL_BLK_EXTERN(str_buf); - - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__ent_decode_vec * @@ -93,8 +80,8 @@ H5FL_BLK_EXTERN(str_buf); 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) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -104,10 +91,10 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5 HDassert(ent); /* decode entries */ - for(u = 0; u < n; u++) { - if(*pp > p_end) + for (u = 0; u < n; u++) { + if (*pp > p_end) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "ran off the end of the image buffer") - if(H5G_ent_decode(f, pp, ent + u) < 0) + if (H5G_ent_decode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") } @@ -115,7 +102,6 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5 FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_decode_vec() */ - /*------------------------------------------------------------------------- * Function: H5G_ent_decode * @@ -134,9 +120,9 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5 herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) { - const uint8_t *p_ret = *pp; - uint32_t tmp; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *p_ret = *pp; + uint32_t tmp; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -153,7 +139,7 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ - switch(ent->type) { + switch (ent->type) { case H5G_NOTHING_CACHED: break; @@ -179,7 +165,6 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_decode() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_encode_vec * @@ -199,8 +184,8 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -210,15 +195,14 @@ H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsign HDassert(ent); /* encode entries */ - for(u = 0; u < n; u++) - if(H5G_ent_encode(f, pp, ent + u) < 0) + for (u = 0; u < n; u++) + if (H5G_ent_encode(f, pp, ent + u) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G__ent_encode_vec() */ - /*------------------------------------------------------------------------- * Function: H5G_ent_encode * @@ -238,8 +222,8 @@ H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsign herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) { - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY_FILE(f); - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY_FILE(f); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -248,15 +232,15 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) HDassert(pp); /* Check for actual entry to encode */ - if(ent) { + if (ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); H5F_addr_encode(f, pp, ent->header); UINT32ENCODE(*pp, ent->type); - UINT32ENCODE(*pp, 0); /*reserved*/ + UINT32ENCODE(*pp, 0); /*reserved*/ /* encode scratch-pad */ - switch(ent->type) { + switch (ent->type) { case H5G_NOTHING_CACHED: break; @@ -275,16 +259,16 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) default: HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown symbol table entry cache type") } /* end switch */ - } /* end if */ + } /* end if */ else { H5F_ENCODE_LENGTH(f, *pp, 0); H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); - UINT32ENCODE(*pp, 0); /*reserved*/ - } /* end else */ + UINT32ENCODE(*pp, 0); /*reserved*/ + } /* end else */ /* fill with zero */ - if(*pp < p_ret) + if (*pp < p_ret) HDmemset(*pp, 0, (size_t)(p_ret - *pp)); *pp = p_ret; @@ -292,7 +276,6 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_encode() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_copy * @@ -330,10 +313,11 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) H5MM_memcpy(dst, src, sizeof(H5G_entry_t)); /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { + if (depth == H5_COPY_DEEP) { /* Nothing currently */ ; - } else if(depth == H5_COPY_SHALLOW) { + } + else if (depth == H5_COPY_SHALLOW) { /* Discarding 'const' qualifier OK - QAK */ H5G__ent_reset((H5G_entry_t *)src); } /* end if */ @@ -341,7 +325,6 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_copy() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_reset * @@ -370,7 +353,6 @@ H5G__ent_reset(H5G_entry_t *ent) FUNC_LEAVE_NOAPI_VOID } /* end H5G__ent_reset() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_convert * @@ -385,11 +367,11 @@ H5G__ent_reset(H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, - H5O_type_t obj_type, const void *crt_info, H5G_entry_t *ent) +H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, H5O_type_t obj_type, + const void *crt_info, H5G_entry_t *ent) { - size_t name_offset; /* Offset of name in heap */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t name_offset; /* Offset of name in heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -402,86 +384,83 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk /* Reset the new entry */ H5G__ent_reset(ent); - /* - * Add the new name to the heap. - */ - name_offset = H5HL_insert(f, heap, HDstrlen(name) + 1, name); - if(0 == name_offset || UFAIL == name_offset) + /* Add the new name to the heap */ + if (H5HL_insert(f, heap, HDstrlen(name) + 1, name, &name_offset) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert symbol name into heap") ent->name_off = name_offset; /* Build correct information for symbol table entry based on link type */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: - if(obj_type == H5O_TYPE_GROUP) { + if (obj_type == H5O_TYPE_GROUP) { const H5G_obj_create_t *gcrt_info = (const H5G_obj_create_t *)crt_info; ent->type = gcrt_info->cache_type; - if(ent->type != H5G_NOTHING_CACHED) + if (ent->type != H5G_NOTHING_CACHED) ent->cache = gcrt_info->cache; #ifndef NDEBUG else { /* Make sure there is no stab message in the target object */ - H5O_loc_t targ_oloc; /* Location of link target */ - htri_t stab_exists; /* Whether the target symbol table exists */ + H5O_loc_t targ_oloc; /* Location of link target */ + htri_t stab_exists; /* Whether the target symbol table exists */ /* Build target object location */ - if(H5O_loc_reset(&targ_oloc) < 0) + if (H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists(&targ_oloc, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(&targ_oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") HDassert(!stab_exists); } /* end else */ -#endif /* NDEBUG */ - } /* end if */ - else if(obj_type == H5O_TYPE_UNKNOWN){ +#endif /* NDEBUG */ + } /* end if */ + 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_stab_t stab; /* Link target symbol table */ - htri_t stab_exists; /* Whether the target symbol table exists */ + H5O_loc_t targ_oloc; /* Location of link target */ + 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 */ /* Build target object location */ - if(H5O_loc_reset(&targ_oloc) < 0) + if (H5O_loc_reset(&targ_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") targ_oloc.file = f; targ_oloc.addr = lnk->u.hard.addr; /* Get the object header */ - if(NULL == (oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, FAIL, "unable to protect target object header") /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) { - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if ((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) { + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to check for STAB message") } /* end if */ - if(stab_exists) { + if (stab_exists) { /* Read symbol table message */ - if(NULL == H5O_msg_read_oh(f, oh, H5O_STAB_ID, &stab)) { - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (NULL == H5O_msg_read_oh(f, oh, H5O_STAB_ID, &stab)) { + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HERROR(H5E_SYM, H5E_CANTUNPROTECT, "unable to release object header"); HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read STAB message") } /* end if */ /* Cache symbol table message */ - ent->type = H5G_CACHED_STAB; + ent->type = H5G_CACHED_STAB; ent->cache.stab.btree_addr = stab.btree_addr; - ent->cache.stab.heap_addr = stab.heap_addr; + ent->cache.stab.heap_addr = stab.heap_addr; } /* end if */ else /* No symbol table message, don't cache anything */ ent->type = H5G_NOTHING_CACHED; - if(H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") } /* end else */ else @@ -490,32 +469,28 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk ent->header = lnk->u.hard.addr; break; - case H5L_TYPE_SOFT: - { - size_t lnk_offset; /* Offset to sym-link value */ + case H5L_TYPE_SOFT: { + size_t lnk_offset; /* Offset to sym-link value */ - /* Insert link value into local heap */ - if(UFAIL == (lnk_offset = H5HL_insert(f, heap, - HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") + /* Insert link value into local heap */ + if (H5HL_insert(f, heap, HDstrlen(lnk->u.soft.name) + 1, lnk->u.soft.name, &lnk_offset) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") - ent->type = H5G_CACHED_SLINK; - ent->cache.slink.lval_offset = lnk_offset; - } /* end case */ - break; + ent->type = H5G_CACHED_SLINK; + ent->cache.slink.lval_offset = lnk_offset; + } break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: default: - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_convert() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_debug * @@ -529,10 +504,9 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk *------------------------------------------------------------------------- */ herr_t -H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, - const H5HL_t *heap) +H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, const H5HL_t *heap) { - const char *lval = NULL; + const char *lval = NULL; int nested_indent, nested_fwidth; FUNC_ENTER_PACKAGE_NOERR @@ -542,15 +516,12 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, nested_fwidth = MAX(0, fwidth - 3); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Name offset into private heap:", - (unsigned long) (ent->name_off)); + "Name offset into private heap:", (unsigned long)(ent->name_off)); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object header address:", ent->header); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Object header address:", ent->header); - HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, - "Cache info type:"); - switch(ent->type) { + HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cache info type:"); + switch (ent->type) { case H5G_NOTHING_CACHED: HDfprintf(stream, "Nothing Cached\n"); break; @@ -558,30 +529,27 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, case H5G_CACHED_STAB: HDfprintf(stream, "Symbol Table\n"); - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Cached entry information:"); - HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached entry information:"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", nested_indent, "", nested_fwidth, "B-tree address:", ent->cache.stab.btree_addr); - HDfprintf(stream, "%*s%-*s %a\n", nested_indent, "", nested_fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", nested_indent, "", nested_fwidth, "Heap address:", ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: HDfprintf(stream, "Symbolic Link\n"); - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Cached information:"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Cached information:"); HDfprintf(stream, "%*s%-*s %lu\n", nested_indent, "", nested_fwidth, - "Link value offset:", - (unsigned long)(ent->cache.slink.lval_offset)); - if(heap) { + "Link value offset:", (unsigned long)(ent->cache.slink.lval_offset)); + if (heap) { lval = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset); HDfprintf(stream, "%*s%-*s %s\n", nested_indent, "", nested_fwidth, - "Link value:", - (lval == NULL) ? "" : lval); + "Link value:", (lval == NULL) ? "" : lval); } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, "Warning: Invalid heap address given, name not displayed!"); + HDfprintf(stream, "%*s%-*s\n", nested_indent, "", nested_fwidth, + "Warning: Invalid heap address given, name not displayed!"); break; case H5G_CACHED_ERROR: @@ -593,4 +561,3 @@ H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__ent_debug() */ - diff --git a/src/H5Gint.c b/src/H5Gint.c index c24cefb840f..74883577876 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,68 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for path traversal routine for "insertion file" routine */ typedef struct { - H5G_loc_t *loc; /* Pointer to the location for insertion */ + H5G_loc_t *loc; /* Pointer to the location for insertion */ } H5G_trav_ins_t; /* User data for application-style iteration over links in a group */ typedef struct { - hid_t gid; /* The group ID for the application callback */ - H5G_link_iterate_t lnk_op; /* Application callback */ - void *op_data; /* Application's op data */ + hid_t gid; /* The group ID for the application callback */ + 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 */ } 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 */ - 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 */ - size_t curr_path_len; /* Current length of the path in the buffer */ - size_t path_buf_size; /* Size of path buffer */ - H5L_iterate_t op; /* Application callback */ - void *op_data; /* Application's op data */ + hid_t gid; /* The group ID for the 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 */ + 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 */ } H5G_iter_visit_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5G__open_oid(H5G_t *grp); - +static herr_t H5G__visit_cb(const H5O_link_t *lnk, void *_udata); /*********************/ /* Package Variables */ @@ -100,18 +96,14 @@ H5FL_DEFINE(H5G_shared_t); /* Declare the free list to manage H5_obj_t's */ H5FL_DEFINE(H5_obj_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__create_named * @@ -127,12 +119,11 @@ H5FL_DEFINE(H5_obj_t); *------------------------------------------------------------------------- */ H5G_t * -H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, - hid_t gcpl_id) +H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t gcpl_id) { - 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -143,17 +134,17 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, HDassert(gcpl_id != H5P_DEFAULT); /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; + gcrt_info.gcpl_id = gcpl_id; gcrt_info.cache_type = H5G_NOTHING_CACHED; HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_GROUP; ocrt_info.crt_info = &gcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new group and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create and link to group") HDassert(ocrt_info.new_obj); @@ -164,7 +155,6 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__create_named() */ - /*------------------------------------------------------------------------- * Function: H5G__create * @@ -185,9 +175,9 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, H5G_t * H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) { - 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 * 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 */ FUNC_ENTER_PACKAGE @@ -196,20 +186,20 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) HDassert(gcrt_info->gcpl_id != H5P_DEFAULT); /* create an open group */ - if(NULL == (grp = H5FL_CALLOC(H5G_t))) + if (NULL == (grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) + if (NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Create the group object header */ - if(H5G__obj_create(file, gcrt_info, &(grp->oloc)/*out*/) < 0) + if (H5G__obj_create(file, gcrt_info, &(grp->oloc) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group object header") - oloc_init = 1; /* Indicate that the object location information is valid */ + oloc_init = 1; /* Indicate that the object location information is valid */ /* Add group to list of open objects in file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't incr object ref. count") - if(H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, TRUE) < 0) + if (H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") /* Set the count of times the object is opened */ @@ -219,27 +209,27 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) ret_value = grp; done: - if(ret_value == NULL) { + if (ret_value == NULL) { /* Check if we need to release the file-oriented symbol table info */ - if(oloc_init) { - if(H5O_dec_rc_by_loc(&(grp->oloc)) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - if(H5O_close(&(grp->oloc), NULL) < 0) + if (oloc_init) { + if (H5O_dec_rc_by_loc(&(grp->oloc)) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(grp->oloc), NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header") - if(H5O_delete(file, grp->oloc.addr) < 0) + if (H5O_delete(file, grp->oloc.addr) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ - if(grp != NULL) { - if(grp->shared != NULL) + if (grp != NULL) { + if (grp->shared != NULL) grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); grp = H5FL_FREE(H5G_t, grp); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__create() */ - /*------------------------------------------------------------------------- * Function: H5G__open_name * @@ -256,13 +246,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_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 * 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 */ FUNC_ENTER_PACKAGE @@ -276,32 +266,31 @@ H5G__open_name(const H5G_loc_t *loc, const char *name) H5G_loc_reset(&grp_loc); /* Find the group object */ - if(H5G_loc_find(loc, name, &grp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found") loc_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&grp_oloc, &obj_type) < 0) + if (H5O_obj_type(&grp_oloc, &obj_type) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) + if (obj_type != H5O_TYPE_GROUP) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, NULL, "not a group") /* Open the group */ - if(NULL == (grp = H5G_open(&grp_loc))) + if (NULL == (grp = H5G_open(&grp_loc))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") /* Set return value */ ret_value = grp; done: - if(!ret_value) - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (!ret_value) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__open_name() */ - /*------------------------------------------------------------------------- * Function: H5G_open * @@ -320,9 +309,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_shared_t *shared_fo; /* Shared group object */ - H5G_t *ret_value = NULL; /* Return value */ + H5G_t * grp = NULL; /* Group opened */ + H5G_shared_t *shared_fo; /* Shared group object */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -330,33 +319,33 @@ H5G_open(const H5G_loc_t *loc) HDassert(loc); /* Allocate the group structure */ - if(NULL == (grp = H5FL_CALLOC(H5G_t))) + if (NULL == (grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group") /* Shallow copy (take ownership) of the group location object */ - if(H5O_loc_copy_shallow(&(grp->oloc), loc->oloc) < 0) + if (H5O_loc_copy_shallow(&(grp->oloc), loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy object location") - if(H5G_name_copy(&(grp->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(grp->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy path") /* Check if group was already open */ - if((shared_fo = (H5G_shared_t *)H5FO_opened(grp->oloc.file, grp->oloc.addr)) == NULL) { + if ((shared_fo = (H5G_shared_t *)H5FO_opened(grp->oloc.file, grp->oloc.addr)) == NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the group object */ - if(H5G__open_oid(grp) < 0) + if (H5G__open_oid(grp) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found") /* Add group to list of open objects in file */ - if(H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, FALSE) < 0) { + if (H5FO_insert(grp->oloc.file, grp->oloc.addr, grp->shared, FALSE) < 0) { grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") /* Set open object count */ @@ -370,14 +359,14 @@ H5G_open(const H5G_loc_t *loc) shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { + if (H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(grp->oloc)) < 0) + if (H5O_open(&(grp->oloc)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_incr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -385,7 +374,7 @@ H5G_open(const H5G_loc_t *loc) ret_value = grp; done: - if(!ret_value && grp) { + if (!ret_value && grp) { H5O_loc_free(&(grp->oloc)); H5G_name_free(&(grp->path)); grp = H5FL_FREE(H5G_t, grp); @@ -394,7 +383,6 @@ H5G_open(const H5G_loc_t *loc) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_open() */ - /*------------------------------------------------------------------------- * Function: H5G__open_oid * @@ -413,8 +401,8 @@ H5G_open(const H5G_loc_t *loc) static herr_t H5G__open_oid(H5G_t *grp) { - hbool_t obj_opened = FALSE; - herr_t ret_value = SUCCEED; + hbool_t obj_opened = FALSE; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -422,63 +410,29 @@ H5G__open_oid(H5G_t *grp) HDassert(grp); /* Allocate the shared information for the group */ - if(NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) + if (NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Grab the object header */ - if(H5O_open(&(grp->oloc)) < 0) + if (H5O_open(&(grp->oloc)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") obj_opened = TRUE; /* Check if this object has the right message(s) to be treated as a group */ - if((H5O_msg_exists(&(grp->oloc), H5O_STAB_ID) <= 0) - && (H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID) <= 0)) + if ((H5O_msg_exists(&(grp->oloc), H5O_STAB_ID) <= 0) && (H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID) <= 0)) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "not a group") done: - if(ret_value < 0) { - if(obj_opened) + if (ret_value < 0) { + if (obj_opened) H5O_close(&(grp->oloc), NULL); - if(grp->shared) + if (grp->shared) grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__open_oid() */ - -/*------------------------------------------------------------------------- - * Function: H5G__close_cb - * - * Purpose: Closes the specified group. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Sunday, February 18, 2018 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G__close_cb(H5G_t *grp) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check args */ - HDassert(grp && grp->shared); - HDassert(grp->shared->fo_count > 0); - - /* Call actual group close routine */ - if(H5G_close(grp) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "problem closing group") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__close_cb() */ - - /*------------------------------------------------------------------------- * Function: H5G_close * @@ -494,9 +448,9 @@ H5G__close_cb(H5G_t *grp) herr_t H5G_close(H5G_t *grp) { - hbool_t corked; /* Whether the group is corked or not */ - hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t corked; /* Whether the group is corked or not */ + hbool_t file_closed = TRUE; /* H5O_close also closed the file? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -506,61 +460,62 @@ H5G_close(H5G_t *grp) --grp->shared->fo_count; - if(0 == grp->shared->fo_count) { + if (0 == grp->shared->fo_count) { HDassert(grp != H5G_rootof(H5G_fileof(grp))); /* Uncork cache entries with object address tag */ - if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(grp->oloc.file, grp->oloc.addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Remove the group from the list of opened objects in the file */ - if(H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_delete(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects") - if(H5O_close(&(grp->oloc), &file_closed) < 0) + if (H5O_close(&(grp->oloc), &file_closed) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") /* Evict group metadata if evicting on close */ - if(!file_closed && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) { - if(H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr) < 0) + if (!file_closed && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) { + if (H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - if(H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, FALSE) < 0) + if (H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") } /* end if */ /* Free memory */ grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); - } else { + } + else { /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) + if (H5FO_top_decr(grp->oloc.file, grp->oloc.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Check reference count for this object in the top file */ - if(H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { - if(H5O_close(&(grp->oloc), NULL) < 0) + if (H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) { + if (H5O_close(&(grp->oloc), NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ 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") + if (H5O_loc_free(&(grp->oloc)) < 0) + 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 * close down the file hierarchy */ - if(grp->shared->mounted && grp->shared->fo_count == 1) { + if (grp->shared->mounted && grp->shared->fo_count == 1) { /* Attempt to close down the file hierarchy */ - if(H5F_try_close(grp->oloc.file, NULL) < 0) + if (H5F_try_close(grp->oloc.file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") } /* end if */ - } /* end else */ + } /* end else */ - if(H5G_name_free(&(grp->path)) < 0) { + if (H5G_name_free(&(grp->path)) < 0) { grp = H5FL_FREE(H5G_t, grp); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name") } /* end if */ @@ -571,7 +526,6 @@ H5G_close(H5G_t *grp) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_close() */ - /*------------------------------------------------------------------------- * Function: H5G_oloc * @@ -594,7 +548,6 @@ H5G_oloc(H5G_t *grp) FUNC_LEAVE_NOAPI(grp ? &(grp->oloc) : NULL) } /* end H5G_oloc() */ - /*------------------------------------------------------------------------- * Function: H5G_nameof * @@ -609,7 +562,7 @@ H5G_oloc(H5G_t *grp) *------------------------------------------------------------------------- */ H5G_name_t * -H5G_nameof(H5G_t *grp) +H5G_nameof(const H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -617,7 +570,6 @@ H5G_nameof(H5G_t *grp) FUNC_LEAVE_NOAPI(grp ? &(grp->path) : NULL) } /* end H5G_nameof() */ - /*------------------------------------------------------------------------- * Function: H5G_fileof * @@ -643,7 +595,6 @@ H5G_fileof(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->oloc.file) } /* end H5G_fileof() */ - /*------------------------------------------------------------------------- * Function: H5G_get_shared_count * @@ -667,7 +618,6 @@ H5G_get_shared_count(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->shared->fo_count) } /* end H5G_get_shared_count() */ - /*------------------------------------------------------------------------- * Function: H5G_mount * @@ -695,7 +645,6 @@ H5G_mount(H5G_t *grp) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_mount() */ - /*------------------------------------------------------------------------- * Function: H5G_mounted * @@ -719,7 +668,6 @@ H5G_mounted(H5G_t *grp) FUNC_LEAVE_NOAPI(grp->shared->mounted) } /* end H5G_mounted() */ - /*------------------------------------------------------------------------- * Function: H5G_unmount * @@ -747,9 +695,8 @@ H5G_unmount(H5G_t *grp) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_unmount() */ - /*------------------------------------------------------------------------- - * Function: H5G_iterate_cb + * Function: H5G__iterate_cb * * Purpose: Callback function for iterating over links in a group * @@ -762,18 +709,18 @@ H5G_unmount(H5G_t *grp) *------------------------------------------------------------------------- */ static herr_t -H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) +H5G__iterate_cb(const H5O_link_t *lnk, void *_udata) { - H5G_iter_appcall_ud_t *udata = (H5G_iter_appcall_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = H5_ITER_ERROR; /* Return value */ + H5G_iter_appcall_ud_t *udata = (H5G_iter_appcall_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = H5_ITER_ERROR; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(lnk); HDassert(udata); - switch(udata->lnk_op.op_type) { + switch (udata->lnk_op.op_type) { #ifndef H5_NO_DEPRECATED_SYMBOLS case H5G_LINK_OP_OLD: /* Make the old-type application callback */ @@ -781,18 +728,16 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - case H5G_LINK_OP_NEW: - { - H5L_info_t info; /* Link info */ + case H5G_LINK_OP_NEW: { + H5L_info2_t info; /* Link info */ - /* Retrieve the info for the link */ - if(H5G_link_to_info(lnk, &info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") + /* Retrieve the info for the link */ + if (H5G_link_to_info(udata->link_loc, lnk, &info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") - /* Make the application callback */ - ret_value = (udata->lnk_op.op_func.op_new)(udata->gid, lnk->name, &info, udata->op_data); - } - break; + /* Make the application callback */ + ret_value = (udata->lnk_op.op_func.op_new)(udata->gid, lnk->name, &info, udata->op_data); + } break; default: HDassert(0 && "Unknown link op type?!?"); @@ -800,9 +745,8 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_iterate_cb() */ +} /* end H5G__iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_iterate * @@ -816,19 +760,18 @@ H5G_iterate_cb(const H5O_link_t *lnk, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5G_iterate(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - const H5G_link_iterate_t *lnk_op, void *op_data) +H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, + hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data) { - H5G_loc_t loc; /* Location of parent for group */ - 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_iter_appcall_ud_t udata; /* User data for callback */ - herr_t ret_value = FAIL; /* Return value */ + 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_iter_appcall_ud_t udata; /* User data for callback */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(loc); HDassert(group_name); HDassert(last_lnk); HDassert(lnk_op && lnk_op->op_func.op_new); @@ -836,37 +779,36 @@ H5G_iterate(hid_t loc_id, const char *group_name, /* Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == (grp = H5G__open_name(&loc, group_name))) + if (NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if ((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Set up user data for callback */ - udata.gid = gid; - udata.lnk_op = *lnk_op; - udata.op_data = op_data; + udata.gid = gid; + udata.link_loc = &grp->oloc; + udata.lnk_op = *lnk_op; + udata.op_data = op_data; /* Call the real group iteration routine */ - if((ret_value = H5G__obj_iterate(&(grp->oloc), idx_type, order, skip, last_lnk, H5G_iterate_cb, &udata)) < 0) + if ((ret_value = + H5G__obj_iterate(&(grp->oloc), idx_type, order, skip, last_lnk, H5G__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "error iterating over links") done: /* Release the group opened */ - if(gid > 0) { - if(H5I_dec_app_ref(gid) < 0) + if (gid != H5I_INVALID_HID) { + if (H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } - else if(grp && H5G_close(grp) < 0) + else if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_iterate() */ - /*------------------------------------------------------------------------- - * Function: H5G_free_visit_visited + * Function: H5G__free_visit_visited * * Purpose: Free the key for an object visited during a group traversal * @@ -878,18 +820,17 @@ H5G_iterate(hid_t loc_id, const char *group_name, *------------------------------------------------------------------------- */ static herr_t -H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +H5G__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR item = H5FL_FREE(H5_obj_t, item); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_free_visit_visited() */ +} /* end H5G__free_visit_visited() */ - /*------------------------------------------------------------------------- - * Function: H5G_visit_cb + * Function: H5G__visit_cb * * Purpose: Callback function for recursively visiting links from a group * @@ -902,20 +843,20 @@ H5G_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static herr_t -H5G_visit_cb(const H5O_link_t *lnk, void *_udata) +H5G__visit_cb(const H5O_link_t *lnk, void *_udata) { - H5G_iter_visit_ud_t *udata = (H5G_iter_visit_ud_t *)_udata; /* User data for callback */ - H5L_info_t info; /* Link info */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ + H5G_iter_visit_ud_t *udata = (H5G_iter_visit_ud_t *)_udata; /* User data for callback */ + H5L_info2_t info; /* Link info */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ size_t old_path_len = udata->curr_path_len; /* Length of path before appending this link's name */ - size_t link_name_len; /* Length of link's name */ - size_t len_needed; /* Length of path string needed */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t link_name_len; /* Length of link's name */ + size_t len_needed; /* Length of path string needed */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(lnk); @@ -924,14 +865,14 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) /* Check if we will need more space to store this link's relative path */ /* ("+2" is for string terminator and possible '/' for group separator later) */ link_name_len = HDstrlen(lnk->name); - len_needed = udata->curr_path_len + link_name_len + 2; - if(len_needed > udata->path_buf_size) { - void *new_path; /* Pointer to new path buffer */ + len_needed = udata->curr_path_len + link_name_len + 2; + if (len_needed > udata->path_buf_size) { + void *new_path; /* Pointer to new path buffer */ /* Attempt to allocate larger buffer for path */ - if(NULL == (new_path = H5MM_realloc(udata->path, len_needed))) + if (NULL == (new_path = H5MM_realloc(udata->path, len_needed))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate path string") - udata->path = (char *)new_path; + udata->path = (char *)new_path; udata->path_buf_size = len_needed; } /* end if */ @@ -941,15 +882,15 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_path_len += link_name_len; /* Construct the link info from the link message */ - if(H5G_link_to_info(lnk, &info) < 0) + if (H5G_link_to_info(udata->curr_loc->oloc, lnk, &info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link") /* Make the application callback */ ret_value = (udata->op)(udata->gid, udata->path, &info, udata->op_data); /* Check for doing more work */ - if(ret_value == H5_ITER_CONT && lnk->type == H5L_TYPE_HARD) { - H5_obj_t obj_pos; /* Object "position" for this object */ + if (ret_value == H5_ITER_CONT && lnk->type == H5L_TYPE_HARD) { + H5_obj_t obj_pos; /* Object "position" for this object */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -958,7 +899,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) /* Find the object using the LAPL passed in */ /* (Correctly handles mounted files) */ - if(H5G_loc_find(udata->curr_loc, lnk->name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->curr_loc, lnk->name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; @@ -967,37 +908,38 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) obj_pos.addr = obj_oloc.addr; /* 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 */ + 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, &rc, &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) { - H5_obj_t *new_node; /* New object node for visited list */ + if (rc > 1) { + H5_obj_t *new_node; /* New object node for visited list */ /* Allocate new object "position" node */ - if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") /* Set node information */ *new_node = obj_pos; /* Add to list of visited objects */ - 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") + 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 */ - 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 */ + if (otype == H5O_TYPE_GROUP) { + 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 */ /* Add the path separator to the current path */ HDassert(udata->path[udata->curr_path_len] == '\0'); @@ -1005,13 +947,13 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_path_len++; /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(&obj_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(&obj_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -1020,7 +962,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -1029,27 +971,27 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) udata->curr_loc = &obj_loc; /* Iterate over links in group */ - ret_value = H5G__obj_iterate(&obj_oloc, idx_type, udata->order, (hsize_t)0, NULL, H5G_visit_cb, udata); + ret_value = H5G__obj_iterate(&obj_oloc, idx_type, udata->order, (hsize_t)0, NULL, + H5G__visit_cb, udata); /* Restore location */ udata->curr_loc = old_loc; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Reset path back to incoming path */ udata->path[old_path_len] = '\0'; - udata->curr_path_len = old_path_len; + udata->curr_path_len = old_path_len; /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_visit_cb() */ +} /* end H5G__visit_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_visit * @@ -1076,18 +1018,17 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate_t op, void *op_data) +H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data) { - H5G_iter_visit_ud_t udata; /* User data for callback */ - 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_loc_t loc; /* Location of group passed in */ - H5G_loc_t start_loc; /* Location of starting group */ - unsigned rc; /* Reference count of object */ - herr_t ret_value = FAIL; /* Return value */ + H5G_iter_visit_ud_t udata; /* User data for callback */ + 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_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) */ HDmemset(&udata, 0, sizeof(udata)); @@ -1095,50 +1036,50 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (!loc) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc parameter cannot be NULL") /* Open the group to begin visiting within */ - if(NULL == (grp = H5G__open_name(&loc, group_name))) + if (NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the starting group */ - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if ((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Get the location of the starting group */ - if(H5G_loc(gid, &start_loc) < 0) + if (H5G_loc(gid, &start_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Set up user data */ - udata.gid = gid; + udata.gid = gid; udata.curr_loc = &start_loc; udata.idx_type = idx_type; - udata.order = order; - udata.op = op; - udata.op_data = op_data; + udata.order = order; + udata.op = op; + udata.op_data = op_data; /* Allocate space for the path name */ - if(NULL == (udata.path = H5MM_strdup(""))) + if (NULL == (udata.path = H5MM_strdup(""))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate path name buffer") udata.path_buf_size = 1; udata.curr_path_len = 0; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) + 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) + 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) { - H5_obj_t *obj_pos; /* New object node for visited list */ + if (rc > 1) { + H5_obj_t *obj_pos; /* New object node for visited list */ /* Allocate new object "position" node */ - if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate object node") /* Construct unique "position" for this object */ @@ -1146,18 +1087,18 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, obj_pos->addr = grp->oloc.addr; /* Add to list of visited objects */ - if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) + 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) + if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ @@ -1166,33 +1107,33 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) /* Switch to name order for this group */ idx_type = H5_INDEX_NAME; } /* end if */ /* Call the link iteration routine */ - if((ret_value = H5G__obj_iterate(&(grp->oloc), idx_type, order, (hsize_t)0, NULL, H5G_visit_cb, &udata)) < 0) + if ((ret_value = + H5G__obj_iterate(&(grp->oloc), idx_type, order, (hsize_t)0, NULL, H5G__visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't visit links") done: /* Release user data resources */ H5MM_xfree(udata.path); - if(udata.visited) - H5SL_destroy(udata.visited, H5G_free_visit_visited, NULL); + if (udata.visited) + H5SL_destroy(udata.visited, H5G__free_visit_visited, NULL); /* Release the group opened */ - if(gid > 0) { - if(H5I_dec_app_ref(gid) < 0) + if (gid != H5I_INVALID_HID) { + if (H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } - else if(grp && H5G_close(grp) < 0) + else if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_visit() */ - /*------------------------------------------------------------------------- * Function: H5G_get_create_plist * @@ -1212,65 +1153,65 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, hid_t H5G_get_create_plist(const H5G_t *grp) { - H5O_linfo_t linfo; /* Link info message */ - htri_t ginfo_exists; - htri_t linfo_exists; - htri_t pline_exists; - H5P_genplist_t *gcpl_plist; - H5P_genplist_t *new_plist; - hid_t new_gcpl_id = H5I_INVALID_HID; - hid_t ret_value = H5I_INVALID_HID; + H5O_linfo_t linfo; /* Link info message */ + htri_t ginfo_exists; + htri_t linfo_exists; + htri_t pline_exists; + H5P_genplist_t *gcpl_plist; + H5P_genplist_t *new_plist; + hid_t new_gcpl_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Copy the default group creation property list */ - if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default group creation property list") - if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) + if (NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default group creation property list") + if ((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&grp->oloc, new_plist) < 0) + if (H5O_get_create_plist(&grp->oloc, new_plist) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") /* Check for the group having a group info message */ - if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") - if(ginfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ + if ((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") + if (ginfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ /* Read the group info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get group info") /* Set the group info for the property list */ - if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info") } /* end if */ /* Check for the group having a link info message */ - if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") - if(linfo_exists) { + if (linfo_exists) { /* Set the link info for the property list */ - if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link info") } /* end if */ /* Check for the group having a pipeline message */ - if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID)) < 0) + if ((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to read object header") - if(pline_exists) { - H5O_pline_t pline; /* Pipeline message */ + if (pline_exists) { + H5O_pline_t pline; /* Pipeline message */ /* Read the pipeline */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get link pipeline") /* Set the pipeline for the property list */ - if(H5P_poke(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link pipeline") } /* end if */ @@ -1278,16 +1219,15 @@ H5G_get_create_plist(const H5G_t *grp) ret_value = new_gcpl_id; done: - if(ret_value < 0) { - if(new_gcpl_id > 0) - if(H5I_dec_app_ref(new_gcpl_id) < 0) + if (ret_value < 0) { + if (new_gcpl_id > 0) + if (H5I_dec_app_ref(new_gcpl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't free") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5G__get_info_by_name * @@ -1303,11 +1243,11 @@ H5G_get_create_plist(const H5G_t *grp) herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_info) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1321,23 +1261,22 @@ H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_in H5G_loc_reset(&grp_loc); /* Find the group object */ - if(H5G_loc_find(loc, name, &grp_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/) < 0) + if (H5G__obj_info(grp_loc.oloc, grp_info /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: /* Clean up */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_name() */ - /*------------------------------------------------------------------------- * Function: H5G__get_info_by_idx * @@ -1351,14 +1290,14 @@ H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_in *------------------------------------------------------------------------- */ herr_t -H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info) +H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5G_info_t *grp_info) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1372,19 +1311,18 @@ H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5G_loc_reset(&grp_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &grp_loc/*out*/) < 0) + if (H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &grp_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/) < 0) + if (H5G__obj_info(grp_loc.oloc, grp_info /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: /* Clean up */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) + if (loc_found && H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_idx() */ - diff --git a/src/H5Glink.c b/src/H5Glink.c index 26747e473a9..629cb119c2d 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,65 +26,57 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); -static int H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2); -static int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2); -static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); - +static int H5G__link_cmp_name_inc(const void *lnk1, const void *lnk2); +static int H5G__link_cmp_name_dec(const void *lnk1, const void *lnk2); +static int H5G__link_cmp_corder_inc(const void *lnk1, const void *lnk2); +static int H5G__link_cmp_corder_dec(const void *lnk1, const void *lnk2); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5G_link_cmp_name_inc + * Function: H5G__link_cmp_name_inc * * Purpose: Callback routine for comparing two link names, in * increasing alphabetic order @@ -101,16 +93,15 @@ static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); *------------------------------------------------------------------------- */ static int -H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2) +H5G__link_cmp_name_inc(const void *lnk1, const void *lnk2) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk1)->name, ((const H5O_link_t *)lnk2)->name)) -} /* end H5G_link_cmp_name_inc() */ +} /* end H5G__link_cmp_name_inc() */ - /*------------------------------------------------------------------------- - * Function: H5G_link_cmp_name_dec + * Function: H5G__link_cmp_name_dec * * Purpose: Callback routine for comparing two link names, in * decreasing alphabetic order @@ -127,16 +118,15 @@ H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ static int -H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) +H5G__link_cmp_name_dec(const void *lnk1, const void *lnk2) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk2)->name, ((const H5O_link_t *)lnk1)->name)) -} /* end H5G_link_cmp_name_dec() */ +} /* end H5G__link_cmp_name_dec() */ - /*------------------------------------------------------------------------- - * Function: H5G_link_cmp_corder_inc + * Function: H5G__link_cmp_corder_inc * * Purpose: Callback routine for comparing two link creation orders, in * increasing order @@ -152,25 +142,24 @@ H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ static int -H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) +H5G__link_cmp_corder_inc(const void *lnk1, const void *lnk2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + if (((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) ret_value = -1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + else if (((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) ret_value = 1; else ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_cmp_corder_inc() */ +} /* end H5G__link_cmp_corder_inc() */ - /*------------------------------------------------------------------------- - * Function: H5G_link_cmp_corder_dec + * Function: H5G__link_cmp_corder_dec * * Purpose: Callback routine for comparing two link creation orders, in * decreasing order @@ -186,23 +175,22 @@ H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ static int -H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) +H5G__link_cmp_corder_dec(const void *lnk1, const void *lnk2) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + if (((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) ret_value = 1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + else if (((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) ret_value = -1; else ret_value = 0; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_cmp_corder_dec() */ +} /* end H5G__link_cmp_corder_dec() */ - /*------------------------------------------------------------------------- * Function: H5G__ent_to_link * @@ -216,11 +204,10 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) *------------------------------------------------------------------------- */ herr_t -H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, - const H5G_entry_t *ent, const char *name) +H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name) { - hbool_t dup_soft = FALSE; /* xstrdup the symbolic link name or not */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t dup_soft = FALSE; /* xstrdup the symbolic link name or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -231,21 +218,21 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, HDassert(name); /* Set (default) common info for link */ - lnk->cset = H5F_DEFAULT_CSET; - lnk->corder = 0; - lnk->corder_valid = FALSE; /* Creation order not valid for this link */ - if((lnk->name = H5MM_xstrdup(name)) == NULL) + lnk->cset = H5F_DEFAULT_CSET; + lnk->corder = 0; + lnk->corder_valid = FALSE; /* Creation order not valid for this link */ + if ((lnk->name = H5MM_xstrdup(name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate link name") /* Object is a symbolic or hard link */ - if(ent->type == H5G_CACHED_SLINK) { - const char *s; /* Pointer to link value */ + if (ent->type == H5G_CACHED_SLINK) { + const char *s; /* Pointer to link value */ - if((s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(heap, ent->cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get symbolic link name") /* Copy the link value */ - if((lnk->u.soft.name = H5MM_xstrdup(s)) == NULL) + if ((lnk->u.soft.name = H5MM_xstrdup(s)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to duplicate symbolic link name") dup_soft = TRUE; @@ -262,16 +249,15 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, } /* end else */ done: - if(ret_value < 0) { - if(lnk->name) + if (ret_value < 0) { + if (lnk->name) H5MM_xfree(lnk->name); - if(ent->type == H5G_CACHED_SLINK && dup_soft) + if (ent->type == H5G_CACHED_SLINK && dup_soft) H5MM_xfree(lnk->u.soft.name); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__ent_to_link() */ - /*------------------------------------------------------------------------- * Function: H5G_link_to_info * @@ -285,25 +271,29 @@ H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, *------------------------------------------------------------------------- */ herr_t -H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) +H5G_link_to_info(const H5O_loc_t *link_loc, const H5O_link_t *lnk, H5L_info2_t *info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(link_loc); HDassert(lnk); /* Get information from the link */ - if(info) { - info->cset = lnk->cset; - info->corder = lnk->corder; + if (info) { + info->cset = lnk->cset; + info->corder = lnk->corder; info->corder_valid = lnk->corder_valid; - info->type = lnk->type; + info->type = lnk->type; - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: - info->u.address = lnk->u.hard.addr; + /* Serialize the address into a VOL token */ + if (H5VL_native_addr_to_token(link_loc->file, H5I_FILE, lnk->u.hard.addr, &info->u.token) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSERIALIZE, FAIL, + "can't serialize address into object token") break; case H5L_TYPE_SOFT: @@ -313,11 +303,10 @@ H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: - default: - { - const H5L_class_t *link_class; /* User-defined link class */ + default: { + const H5L_class_t *link_class; /* User-defined link class */ - if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "unknown link class") /* User-defined link; call its query function to get the link udata size. */ @@ -327,27 +316,29 @@ H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) */ link_class = H5L_find_class(lnk->type); - if(link_class != NULL && link_class->query_func != NULL) { - ssize_t cb_ret; /* Return value from UD callback */ + if (link_class != NULL && link_class->query_func != NULL) { + ssize_t cb_ret; /* Return value from UD callback */ /* Call the link's query routine to retrieve the user-defined link's value size */ - /* (in case the query routine packs/unpacks the link value in some way that changes its size) */ - if((cb_ret = (link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, NULL, (size_t)0)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query buffer size callback returned failure") + /* (in case the query routine packs/unpacks the link value in some way that changes its + * size) */ + if ((cb_ret = (link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, NULL, + (size_t)0)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, + "query buffer size callback returned failure") info->u.val_size = (size_t)cb_ret; } /* end if */ else info->u.val_size = 0; } /* end case */ - } /* end switch */ - } /* end if */ + } /* end switch */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_link_to_info() */ - /*------------------------------------------------------------------------- * Function: H5G__link_to_loc * @@ -361,10 +352,9 @@ H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *info) *------------------------------------------------------------------------- */ herr_t -H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc) +H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -378,24 +368,23 @@ H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, */ /* Check for unknown library-internal link */ - if(lnk->type > H5L_TYPE_BUILTIN_MAX && lnk->type < H5L_TYPE_UD_MIN) + if (lnk->type > H5L_TYPE_BUILTIN_MAX && lnk->type < H5L_TYPE_UD_MIN) HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "unknown link type") /* Build object's group hier. location */ - if(H5G_name_set(grp_loc->path, obj_loc->path, lnk->name) < 0) + if (H5G_name_set(grp_loc->path, obj_loc->path, lnk->name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") /* Set the object location, if it's a hard link set the address also */ - obj_loc->oloc->file = grp_loc->oloc->file; + obj_loc->oloc->file = grp_loc->oloc->file; obj_loc->oloc->holding_file = FALSE; - if(lnk->type == H5L_TYPE_HARD) + if (lnk->type == H5L_TYPE_HARD) obj_loc->oloc->addr = lnk->u.hard.addr; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_to_loc() */ - /*------------------------------------------------------------------------- * Function: H5G__link_sort_table * @@ -409,10 +398,9 @@ H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, *------------------------------------------------------------------------- */ herr_t -H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, - H5_iter_order_t order) +H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -420,27 +408,27 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, HDassert(ltable); /* Can't sort when empty since the links table will be NULL */ - if(0 == ltable->nlinks) + if (0 == ltable->nlinks) HGOTO_DONE(ret_value); /* This should never be NULL if the number of links is non-zero */ HDassert(ltable->lnks); /* Pick appropriate sorting routine */ - if(idx_type == H5_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_dec); + if (idx_type == H5_INDEX_NAME) { + if (order == H5_ITER_INC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_inc); + else if (order == H5_ITER_DEC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_dec); else HDassert(order == H5_ITER_NATIVE); } /* end if */ else { HDassert(idx_type == H5_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); + if (order == H5_ITER_INC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_inc); + else if (order == H5_ITER_DEC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_dec); else HDassert(order == H5_ITER_NATIVE); } /* end else */ @@ -449,7 +437,6 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__link_sort_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_iterate_table * @@ -465,11 +452,11 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, *------------------------------------------------------------------------- */ herr_t -H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, - hsize_t *last_lnk, const H5G_lib_iterate_t op, void *op_data) +H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, hsize_t *last_lnk, + const H5G_lib_iterate_t op, void *op_data) { - size_t u; /* Local index variable */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -478,28 +465,27 @@ H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, HDassert(op); /* Skip over links, if requested */ - if(last_lnk) + if (last_lnk) *last_lnk += skip; /* Iterate over link messages */ H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) - for(; u < ltable->nlinks && !ret_value; u++) { + for (; u < ltable->nlinks && !ret_value; u++) { /* Make the callback */ ret_value = (op)(&(ltable->lnks[u]), op_data); /* Increment the number of entries passed through */ - if(last_lnk) + if (last_lnk) (*last_lnk)++; } /* end for */ /* Check for callback failure and pass along return value */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_iterate_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_release_table * @@ -516,8 +502,8 @@ H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, herr_t H5G__link_release_table(H5G_link_table_t *ltable) { - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -525,10 +511,10 @@ H5G__link_release_table(H5G_link_table_t *ltable) HDassert(ltable); /* Release link info, if any */ - if(ltable->nlinks > 0) { + if (ltable->nlinks > 0) { /* Free link message information */ - for(u = 0; u < ltable->nlinks; u++) - if(H5O_msg_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) + for (u = 0; u < ltable->nlinks; u++) + if (H5O_msg_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link message") /* Free table of links */ @@ -541,7 +527,6 @@ H5G__link_release_table(H5G_link_table_t *ltable) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_release_table() */ - /*------------------------------------------------------------------------- * Function: H5G__link_name_replace * @@ -558,8 +543,8 @@ H5G__link_release_table(H5G_link_table_t *ltable) herr_t H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk) { - H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ - herr_t ret_value = SUCCEED; /* Return value */ + H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -567,16 +552,15 @@ H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_ HDassert(file); /* Search the open IDs and replace names for unlinked object */ - if(grp_full_path_r) { + if (grp_full_path_r) { obj_path_r = H5G_build_fullpath_refstr_str(grp_full_path_r, lnk->name); - if(H5G_name_replace(lnk, H5G_NAME_DELETE, file, obj_path_r, NULL, NULL) < 0) + if (H5G_name_replace(lnk, H5G_NAME_DELETE, file, obj_path_r, NULL, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") } done: - if(obj_path_r) + if (obj_path_r) H5RS_decr(obj_path_r); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__link_name_replace() */ - diff --git a/src/H5Gloc.c b/src/H5Gloc.c index e672c6796bd..54c2ceede43 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,26 +26,23 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -53,39 +50,48 @@ /* User data for looking up an object in a group */ typedef struct { /* upward */ - H5G_loc_t *loc; /* Group location to set */ + H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fnd_t; /* User data for checking if an object exists */ typedef struct { /* upward */ - htri_t exists; /* Whether the object exists */ + htri_t exists; /* Whether the object exists */ } H5G_loc_exists_t; /* User data for looking up an object in a group by index */ typedef struct { /* downward */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Iteration order within index */ - hsize_t n; /* Offset within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Iteration order within index */ + hsize_t n; /* Offset within index */ /* upward */ - H5G_loc_t *loc; /* Group location to set */ + H5G_loc_t *loc; /* Group location to set */ } H5G_loc_fbi_t; -/* User data for getting an object's info in a group */ +/* User data for getting an object's data model info in a group */ typedef struct { /* downward */ - unsigned fields; /* which fields in H5O_info_t struct to fill in */ + unsigned fields; /* which fields in H5O_info2_t struct to fill in */ /* upward */ - H5O_info_t *oinfo; /* Object information to retrieve */ + H5O_info2_t *oinfo; /* Object information to retrieve */ } H5G_loc_info_t; +/* User data for getting an object's native info in a group */ +typedef struct { + /* downward */ + unsigned fields; /* which fields in H5O_native_info_t struct to fill in */ + + /* upward */ + H5O_native_info_t *oinfo; /* Object information to retrieve */ +} H5G_loc_native_info_t; + /* User data for setting an object's comment in a group */ typedef struct { /* downward */ - const char *comment; /* Object comment buffer */ + const char *comment; /* Object comment buffer */ /* upward */ } H5G_loc_sc_t; @@ -93,128 +99,110 @@ typedef struct { /* User data for getting an object's comment in a group */ typedef struct { /* downward */ - char *comment; /* Object comment buffer */ - size_t bufsize; /* Size of object comment buffer */ + char * comment; /* Object comment buffer */ + size_t bufsize; /* Size of object comment buffer */ /* upward */ - ssize_t comment_size; /* Actual size of object comment */ + ssize_t comment_size; /* Actual size of object comment */ } H5G_loc_gc_t; - /********************/ /* Local Prototypes */ /********************/ /* Group traversal callbacks */ -static herr_t H5G__loc_find_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); -static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, - H5G_own_loc_t *own_loc); - +static herr_t H5G__loc_find_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_addr_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_info_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_native_info_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); +static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5G_loc + * Function: H5G_loc_real * - * Purpose: Given an object ID return a location for the object. + * Purpose: Utility routine to get object location * * Returns: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5G_loc(hid_t loc_id, H5G_loc_t *loc) +H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - switch(H5I_get_type(loc_id)) { - case H5I_FILE: - { - H5F_t *f; - - /* Get the file struct */ - if(NULL == (f = (H5F_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file ID") + switch (type) { + case H5I_FILE: { + H5F_t *f = (H5F_t *)obj; /* Construct a group location for root group of the file */ - if(H5G_root_loc(f, loc) < 0) + if (H5G_root_loc(f, loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") break; } - case H5I_GROUP: - { - H5G_t *group; + case H5I_GROUP: { + H5G_t *group = (H5G_t *)obj; - if(NULL == (group = (H5G_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group ID") - if(NULL == (loc->oloc = H5G_oloc(group))) + if (NULL == (loc->oloc = H5G_oloc(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") - if(NULL == (loc->path = H5G_nameof(group))) + if (NULL == (loc->path = H5G_nameof(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") break; } - case H5I_DATATYPE: - { - H5T_t *dt; + case H5I_DATATYPE: { + H5T_t *dt = NULL; + + /* Get the actual datatype object if the VOL object is set */ + dt = H5T_get_actual_type((H5T_t *)obj); - if(NULL == (dt = (H5T_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid type ID") - if(NULL == (loc->oloc = H5T_oloc(dt))) + if (NULL == (loc->oloc = H5T_oloc(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") - if(NULL == (loc->path = H5T_nameof(dt))) + if (NULL == (loc->path = H5T_nameof(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") break; } - case H5I_DATASET: - { - H5D_t *dset; + case H5I_DATASET: { + H5D_t *dset = (H5D_t *)obj; - if(NULL == (dset = (H5D_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data ID") - if(NULL == (loc->oloc = H5D_oloc(dset))) + if (NULL == (loc->oloc = H5D_oloc(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") - if(NULL == (loc->path = H5D_nameof(dset))) + if (NULL == (loc->path = H5D_nameof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") break; } - case H5I_ATTR: - { - H5A_t *attr; + case H5I_ATTR: { + H5A_t *attr = (H5A_t *)obj; - if(NULL == (attr = (H5A_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid attribute ID") - if(NULL == (loc->oloc = H5A_oloc(attr))) + if (NULL == (loc->oloc = H5A_oloc(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") - if(NULL == (loc->path = H5A_nameof(attr))) + if (NULL == (loc->path = H5A_nameof(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") break; } @@ -222,6 +210,9 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maps not supported in native VOL connector") + case H5I_GENPROP_CLS: case H5I_GENPROP_LST: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of property list") @@ -229,13 +220,20 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_ERROR_CLASS: case H5I_ERROR_MSG: case H5I_ERROR_STACK: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of error class, message or stack") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of error class, message or stack") case H5I_VFL: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual file driver (VFD)") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a virtual file driver (VFD)") + + case H5I_VOL: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a virtual object layer (VOL) connector") - case H5I_REFERENCE: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of reference") + case H5I_SPACE_SEL_ITER: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get group location of a dataspace selection iterator") case H5I_UNINIT: case H5I_BADID: @@ -244,11 +242,39 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid location ID") } /* end switch */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_loc_real() */ + +/*------------------------------------------------------------------------- + * Function: H5G_loc + * + * Purpose: Given an object ID return a location for the object. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_loc(hid_t loc_id, H5G_loc_t *loc) +{ + void * obj = NULL; /* VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Get the object from the VOL */ + if (NULL == (obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Fill in the struct */ + if (H5G_loc_real(obj, H5I_get_type(loc_id), loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to fill in location struct") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_copy * @@ -264,7 +290,7 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -273,16 +299,15 @@ H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth) HDassert(src); /* Copy components of the location */ - if(H5O_loc_copy(dst->oloc, src->oloc, depth) < 0) + if (H5O_loc_copy(dst->oloc, src->oloc, depth) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") - if(H5G_name_copy(dst->path, src->path, depth) < 0) + if (H5G_name_copy(dst->path, src->path, depth) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_copy() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_reset * @@ -298,7 +323,7 @@ H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth) herr_t H5G_loc_reset(H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -306,16 +331,15 @@ H5G_loc_reset(H5G_loc_t *loc) HDassert(loc); /* Reset components of the location */ - if(H5O_loc_reset(loc->oloc) < 0) + if (H5O_loc_reset(loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset entry") - if(H5G_name_reset(loc->path) < 0) + if (H5G_name_reset(loc->path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_reset() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_free * @@ -331,7 +355,7 @@ H5G_loc_reset(H5G_loc_t *loc) herr_t H5G_loc_free(H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -339,16 +363,15 @@ H5G_loc_free(H5G_loc_t *loc) HDassert(loc); /* Reset components of the location */ - if(H5G_name_free(loc->path) < 0) + if (H5G_name_free(loc->path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free path") - if(H5O_loc_free(loc->oloc) < 0) + if (H5O_loc_free(loc->oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free object header location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_free() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_find_cb * @@ -362,17 +385,17 @@ H5G_loc_free(H5G_loc_t *loc) *------------------------------------------------------------------------- */ static herr_t -H5G__loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, - 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_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, + 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_fnd_t *udata = (H5G_loc_fnd_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fnd_t *udata = (H5G_loc_fnd_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object '%s' doesn't exist", name) /* Take ownership of the object's group location */ @@ -386,7 +409,6 @@ H5G__loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_find_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_find * @@ -400,10 +422,10 @@ H5G__loc_find_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, *------------------------------------------------------------------------- */ herr_t -H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/) +H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/) { - H5G_loc_fnd_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fnd_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -416,14 +438,13 @@ H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/) udata.loc = obj_loc; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_find_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_find_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_find() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_find_by_idx_cb * @@ -438,47 +459,47 @@ H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/) *------------------------------------------------------------------------- */ static herr_t -H5G__loc_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - 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_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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_fbi_t *udata = (H5G_loc_fbi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ - hbool_t obj_exists = FALSE; /* Whether the object exists (unused) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fbi_t *udata = (H5G_loc_fbi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ + hbool_t obj_exists = FALSE; /* Whether the object exists (unused) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Build the initial object location for the link */ - if(H5G__link_to_loc(obj_loc, &fnd_lnk, udata->loc) < 0) + if (H5G__link_to_loc(obj_loc, &fnd_lnk, udata->loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot initialize object location") obj_loc_valid = TRUE; /* Perform any special traversals that the link needs */ /* (soft links, user-defined links, file mounting, etc.) */ /* (may modify the object location) */ - if(H5G__traverse_special(obj_loc, &fnd_lnk, H5G_TARGET_NORMAL, TRUE, udata->loc, &obj_exists) < 0) + if (H5G__traverse_special(obj_loc, &fnd_lnk, H5G_TARGET_NORMAL, TRUE, udata->loc, &obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "special link traversal failed") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Release the object location if we failed after copying it */ - if(ret_value < 0 && obj_loc_valid) - if(H5G_loc_free(udata->loc) < 0) + if (ret_value < 0 && obj_loc_valid) + if (H5G_loc_free(udata->loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") /* Indicate that this callback didn't take ownership of the group * @@ -488,7 +509,6 @@ H5G__loc_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_find_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_find_by_idx * @@ -502,11 +522,11 @@ H5G__loc_find_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A *------------------------------------------------------------------------- */ herr_t -H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc/*out*/) +H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5G_loc_t *obj_loc /*out*/) { - H5G_loc_fbi_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_fbi_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -517,19 +537,18 @@ H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx /* Set up user data for locating object */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.loc = obj_loc; + udata.order = order; + udata.n = n; + udata.loc = obj_loc; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, group_name, H5G_TARGET_NORMAL, H5G__loc_find_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, group_name, H5G_TARGET_NORMAL, H5G__loc_find_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_find_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_insert * @@ -543,11 +562,11 @@ 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, const 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 */ + H5O_link_t lnk; /* Link for object to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -557,29 +576,28 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, HDassert(obj_loc); /* Create link object for the object location */ - lnk.type = H5L_TYPE_HARD; - 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) */ + lnk.type = H5L_TYPE_HARD; + 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.name = (char *)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) + if (H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert object") /* Set the name of the object location */ - if(H5G_name_set(grp_loc->path, obj_loc->path, name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") + if (H5G_name_set(grp_loc->path, obj_loc->path, name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_insert() */ - /*------------------------------------------------------------------------- - * Function: H5G_loc_exists_cb + * Function: H5G__loc_exists_cb * * Purpose: Callback for checking if an object exists * @@ -591,17 +609,17 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, *------------------------------------------------------------------------- */ static herr_t -H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - 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_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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_exists_t *udata = (H5G_loc_exists_t *)_udata; /* User data passed in */ + H5G_loc_exists_t *udata = (H5G_loc_exists_t *)_udata; /* User data passed in */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check if the name in this group resolved to a valid object */ - if(obj_loc == NULL) - if(lnk) + if (obj_loc == NULL) + if (lnk) udata->exists = FALSE; else udata->exists = FAIL; @@ -613,9 +631,8 @@ H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UN *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_loc_exists_cb() */ +} /* end H5G__loc_exists_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_exists * @@ -632,8 +649,8 @@ H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UN htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name) { - H5G_loc_exists_t udata; /* User data for traversal callback */ - htri_t ret_value = FAIL; /* Return value */ + H5G_loc_exists_t udata; /* User data for traversal callback */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -645,7 +662,7 @@ H5G_loc_exists(const H5G_loc_t *loc, const char *name) udata.exists = FALSE; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G_loc_exists_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_EXISTS, H5G__loc_exists_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't check if object exists") /* Set return value */ @@ -655,34 +672,104 @@ H5G_loc_exists(const H5G_loc_t *loc, const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_exists() */ - /*------------------------------------------------------------------------- - * Function: H5G__loc_info_cb + * Function: H5G__loc_addr_cb + * + * Purpose: Callback for retrieving the address for an object in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, December 21, 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__loc_addr_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) +{ + haddr_t *udata = (haddr_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Set address of object */ + *udata = obj_loc->oloc->addr; + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_addr_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5G__loc_addr + * + * Purpose: Retrieve the information for an object from a group location + * and path to that object * - * Purpose: Callback for retrieving object info for an object in a group + * Return: Non-negative on success/Negative on failure * - * Return: Non-negative on success/Negative on failure + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 * - * Programmer: Quincey Koziol + *------------------------------------------------------------------------- + */ +herr_t +H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args. */ + HDassert(loc); + HDassert(name && *name); + HDassert(addr); + + /* Traverse group hierarchy to locate object */ + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_addr_cb, addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_addr() */ + +/*------------------------------------------------------------------------- + * Function: H5G__loc_info_cb + * + * Purpose: Callback for retrieving data model info for an object in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol * Thursday, November 23, 2006 * *------------------------------------------------------------------------- */ static herr_t -H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, 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_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_info_t *udata = (H5G_loc_info_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object information */ - if(H5O_get_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) + if (H5O_get_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") done: @@ -693,11 +780,10 @@ H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_info * - * Purpose: Retrieve the information for an object from a group location + * Purpose: Retrieve the data model information for an object from a group location * and path to that object * * Return: Non-negative on success/Negative on failure @@ -708,10 +794,10 @@ H5G__loc_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNU *------------------------------------------------------------------------- */ herr_t -H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, unsigned fields) +H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, unsigned fields) { H5G_loc_info_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -722,17 +808,92 @@ H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, u /* Set up user data for locating object */ udata.fields = fields; - udata.oinfo = oinfo; + udata.oinfo = oinfo; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_info_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_info_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_info() */ - +/*------------------------------------------------------------------------- + * Function: H5G__loc_native_info_cb + * + * Purpose: Callback for retrieving native info for an object in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__loc_native_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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_native_info_t *udata = (H5G_loc_native_info_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if (obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") + + /* Query object information */ + if (H5O_get_native_info(obj_loc->oloc, udata->oinfo, udata->fields) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object info") + +done: + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__loc_native_info_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5G_loc_native_info + * + * Purpose: Retrieve the native information for an object from a group location + * and path to that object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, November 23, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, unsigned fields) +{ + H5G_loc_native_info_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args. */ + HDassert(loc); + HDassert(name && *name); + HDassert(oinfo); + + /* Set up user data for locating object */ + udata.fields = fields; + udata.oinfo = oinfo; + + /* Traverse group hierarchy to locate object */ + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_native_info_cb, &udata) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_loc_native_info() */ + /*------------------------------------------------------------------------- * Function: H5G__loc_set_comment_cb * @@ -746,34 +907,36 @@ H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, u *------------------------------------------------------------------------- */ static herr_t -H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, 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_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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; /* Object header "comment" message */ + htri_t exists; /* Whether a "comment" message already exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for existing comment message */ - if((exists = H5O_msg_exists(obj_loc->oloc, H5O_NAME_ID)) < 0) + if ((exists = H5O_msg_exists(obj_loc->oloc, H5O_NAME_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") /* Remove the previous comment message if any */ - if(exists) - if(H5O_msg_remove(obj_loc->oloc, H5O_NAME_ID, 0, TRUE) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete existing comment object header message") + if (exists) + if (H5O_msg_remove(obj_loc->oloc, H5O_NAME_ID, 0, TRUE) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, + "unable to delete existing comment object header message") /* Add the new message */ - if(udata->comment && *udata->comment) { + if (udata->comment && *udata->comment) { /* Casting away const OK -QAK */ comment.s = (char *)udata->comment; - if(H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0) + 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 */ @@ -785,7 +948,6 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_set_comment_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_set_comment * @@ -802,8 +964,8 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment) { - H5G_loc_sc_t udata; /* User data for traversal callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_sc_t udata; /* User data for traversal callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -815,14 +977,13 @@ H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment) udata.comment = comment; /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_set_comment_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_set_comment_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_set_comment() */ - /*------------------------------------------------------------------------- * Function: H5G__loc_get_comment_cb * @@ -836,28 +997,29 @@ H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment) *------------------------------------------------------------------------- */ static herr_t -H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, 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_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + 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_gc_t *udata = (H5G_loc_gc_t *)_udata; /* User data passed in */ - H5O_name_t comment; /* Object header "comment" message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_gc_t *udata = (H5G_loc_gc_t *)_udata; /* User data passed in */ + H5O_name_t comment; /* Object header "comment" message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Query object comment */ comment.s = NULL; - if(NULL == H5O_msg_read(obj_loc->oloc, H5O_NAME_ID, &comment)) { - if(udata->comment && udata->bufsize > 0) + if (NULL == H5O_msg_read(obj_loc->oloc, H5O_NAME_ID, &comment)) { + if (udata->comment && udata->bufsize > 0) udata->comment[0] = '\0'; udata->comment_size = 0; } else { - if(udata->comment && udata->bufsize) + if (udata->comment && udata->bufsize) HDstrncpy(udata->comment, comment.s, udata->bufsize); udata->comment_size = (ssize_t)HDstrlen(comment.s); H5O_msg_reset(H5O_NAME_ID, &comment); @@ -872,7 +1034,6 @@ H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__loc_get_comment_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_loc_get_comment * @@ -891,11 +1052,10 @@ H5G__loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A *------------------------------------------------------------------------- */ ssize_t -H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/, - size_t bufsize) +H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, size_t bufsize) { - H5G_loc_gc_t udata; /* User data for traversal callback */ - ssize_t ret_value = -1; /* Return value */ + H5G_loc_gc_t udata; /* User data for traversal callback */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -904,12 +1064,12 @@ H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/ HDassert(name && *name); /* Set up user data for locating object */ - udata.comment = comment; - udata.bufsize = bufsize; + udata.comment = comment; + udata.bufsize = bufsize; udata.comment_size = (-1); /* Traverse group hierarchy to locate object */ - if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_get_comment_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G__loc_get_comment_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object") /* Set the return value */ @@ -918,4 +1078,3 @@ H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment/*out*/ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_get_comment() */ - diff --git a/src/H5Gmodule.h b/src/H5Gmodule.h index 883aa6d7fd1..fe26bd2a14d 100644 --- a/src/H5Gmodule.h +++ b/src/H5Gmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,107 @@ * H5G package. Including this header means that the source file * is part of the H5G package. */ -#ifndef _H5Gmodule_H -#define _H5Gmodule_H +#ifndef H5Gmodule_H +#define H5Gmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5G_MODULE -#define H5_MY_PKG H5G -#define H5_MY_PKG_ERR H5E_SYM -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5G +#define H5_MY_PKG_ERR H5E_SYM +#define H5_MY_PKG_INIT YES -#endif /* _H5Gmodule_H */ +/** + * \defgroup H5G H5G + * + * \details \Bold{Groups in HDF5:} A group associates names with objects and + * provides a mechanism for mapping a name to an object. Since all + * objects appear in at least one group (with the possible exception of + * the root object) and since objects can have names in more than one + * group, the set of all objects in an HDF5 file is a directed + * graph. The internal nodes (nodes with out-degree greater than zero) + * must be groups while the leaf nodes (nodes with out-degree zero) are + * either empty groups or objects of some other type. Exactly one + * object in every non-empty file is the root object. The root object + * always has a positive in-degree because it is pointed to by the file + * super block. + * + * \Bold{Locating objects in the HDF5 file hierarchy:} An object name + * consists of one or more components separated from one another by + * slashes. An absolute name begins with a slash and the object is + * located by looking for the first component in the root object, then + * looking for the second component in the first object, etc., until + * the entire name is traversed. A relative name does not begin with a + * slash and the traversal begins at the location specified by the + * create or access function. + * + * \Bold{Group implementations in HDF5:} The original HDF5 group + * implementation provided a single indexed structure for link + * storage. A new group implementation, in HDF5 Release 1.8.0, enables + * more efficient compact storage for very small groups, improved link + * indexing for large groups, and other advanced features. + * + * \li The \Emph{original indexed} format remains the default. Links + * are stored in a B-tree in the group’s local heap. + * \li Groups created in the new \Emph{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 \Emph{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 \Emph{indexed} format will yield improved + * performance when working with large groups, e.g., groups + * 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 + * required for all link types other than hard or soft links, e.g., + * external and user-defined links (see the \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: + * \li 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.\n 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. + * \li 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: + * \li An external or user-defined link is inserted into the group. + * \li 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, i.e., 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. + * + */ +#endif /* H5Gmodule_H */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 263bc112939..cc8eaf4d339 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,68 +26,62 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory wrappers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory wrappers */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 */ + 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 */ } H5G_names_t; /* Info to pass to the iteration function when building name */ typedef struct H5G_gnba_iter_t { /* In */ - const H5O_loc_t *loc; /* The location of the object we're looking for */ + const H5O_loc_t *loc; /* The location of the object we're looking for */ /* Out */ - char *path; /* Name of the object */ + char *path; /* Name of the object */ } H5G_gnba_iter_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static htri_t 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); -#ifdef NOT_YET -static H5RS_str_t *H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); -#endif /* NOT_YET */ -static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, - const char *full_suffix, const char *src_path, const char *dst_path); -static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); - +static htri_t 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); +static herr_t H5G__name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, + const char *dst_path); +static int H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); /*********************/ /* Package Variables */ @@ -96,18 +90,14 @@ static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__component * @@ -140,7 +130,6 @@ H5G__component(const char *name, size_t *size_p) FUNC_LEAVE_NOAPI(name) } /* end H5G__component() */ - /*------------------------------------------------------------------------- * Function: H5G_normalize * @@ -158,10 +147,10 @@ H5G__component(const char *name, size_t *size_p) char * H5G_normalize(const char *name) { - 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 * 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 */ FUNC_ENTER_NOAPI_NOINIT @@ -169,22 +158,22 @@ H5G_normalize(const char *name) HDassert(name); /* Duplicate the name, to return */ - if(NULL == (norm = H5MM_strdup(name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string") + if (NULL == (norm = H5MM_strdup(name))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string") /* Walk through the characters, omitting duplicated '/'s */ - s = d = 0; + s = d = 0; last_slash = 0; - while(name[s] != '\0') { - if(name[s] == '/') - if(last_slash) + while (name[s] != '\0') { + if (name[s] == '/') + if (last_slash) ; else { - norm[d++] = name[s]; + norm[d++] = name[s]; last_slash = 1; } /* end else */ else { - norm[d++] = name[s]; + norm[d++] = name[s]; last_slash = 0; } /* end else */ s++; @@ -194,7 +183,7 @@ H5G_normalize(const char *name) norm[d] = '\0'; /* Check for final '/' on normalized name & eliminate it */ - if(d > 1 && last_slash) + if (d > 1 && last_slash) norm[d - 1] = '\0'; /* Set return value */ @@ -204,9 +193,8 @@ H5G_normalize(const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_normalize() */ - /*------------------------------------------------------------------------- - * Function: H5G_common_path + * Function: H5G__common_path * * Purpose: Determine if one path is a valid prefix of another path * @@ -220,39 +208,39 @@ H5G_normalize(const char *name) *------------------------------------------------------------------------- */ static htri_t -H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) +H5G__common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) { - const char *fullpath; /* Pointer to actual fullpath string */ - const char *prefix; /* Pointer to actual prefix string */ - size_t nchars1,nchars2; /* Number of characters in components */ - htri_t ret_value=FALSE; /* Return value */ + const char *fullpath; /* Pointer to actual fullpath string */ + const char *prefix; /* Pointer to actual prefix string */ + size_t nchars1, nchars2; /* Number of characters in components */ + htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Get component of each name */ - fullpath=H5RS_get_str(fullpath_r); + fullpath = H5RS_get_str(fullpath_r); HDassert(fullpath); - fullpath=H5G__component(fullpath,&nchars1); + fullpath = H5G__component(fullpath, &nchars1); HDassert(fullpath); - prefix=H5RS_get_str(prefix_r); + prefix = H5RS_get_str(prefix_r); HDassert(prefix); - prefix=H5G__component(prefix,&nchars2); + prefix = H5G__component(prefix, &nchars2); HDassert(prefix); /* Check if we have a real string for each component */ - while(*fullpath && *prefix) { + while (*fullpath && *prefix) { /* Check that the components we found are the same length */ - if(nchars1==nchars2) { + if (nchars1 == nchars2) { /* Check that the two components are equal */ - if(HDstrncmp(fullpath,prefix,nchars1)==0) { + if (HDstrncmp(fullpath, prefix, nchars1) == 0) { /* Advance the pointers in the names */ - fullpath+=nchars1; - prefix+=nchars2; + fullpath += nchars1; + prefix += nchars2; /* Get next component of each name */ - fullpath=H5G__component(fullpath,&nchars1); + fullpath = H5G__component(fullpath, &nchars1); HDassert(fullpath); - prefix=H5G__component(prefix,&nchars2); + prefix = H5G__component(prefix, &nchars2); HDassert(prefix); } /* end if */ else @@ -263,16 +251,15 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) } /* end while */ /* If we reached the end of the prefix path to check, it must be a valid prefix */ - if(*prefix=='\0') - ret_value=TRUE; + if (*prefix == '\0') + ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_common_path() */ +} /* end H5G__common_path() */ - /*------------------------------------------------------------------------- - * Function: H5G_build_fullpath + * Function: H5G__build_fullpath * * Purpose: Build a full path from a prefix & base pair of strings * @@ -285,16 +272,16 @@ 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) +H5G__build_fullpath(const char *prefix, const char *name) { - 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 */ - unsigned need_sep; /* Flag to indicate if separator is needed */ - H5RS_str_t *ret_value = NULL; /* Return value */ + 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 */ + unsigned need_sep; /* Flag to indicate if separator is needed */ + H5RS_str_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(prefix); @@ -304,7 +291,7 @@ H5G_build_fullpath(const char *prefix, const char *name) orig_path_len = path_len = HDstrlen(prefix); /* Determine if there is a trailing separator in the name */ - if(prefix[path_len - 1] == '/') + if (prefix[path_len - 1] == '/') need_sep = 0; else need_sep = 1; @@ -314,24 +301,23 @@ H5G_build_fullpath(const char *prefix, const char *name) path_len += name_len + need_sep; /* Allocate space for the path */ - if(NULL == (full_path = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) + if (NULL == (full_path = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build full path */ HDstrncpy(full_path, prefix, orig_path_len + 1); - if(need_sep) + if (need_sep) HDstrncat(full_path, "/", (size_t)1); HDstrncat(full_path, name, name_len); /* Create reference counted string for path */ - if(NULL == (ret_value = H5RS_own(full_path))) + if (NULL == (ret_value = H5RS_own(full_path))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_build_fullpath() */ +} /* end H5G__build_fullpath() */ - /*------------------------------------------------------------------------- * Function: H5G_build_fullpath_refstr_str * @@ -348,8 +334,8 @@ H5G_build_fullpath(const char *prefix, const char *name) H5RS_str_t * H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) { - const char *prefix; /* Pointer to raw string for path */ - H5RS_str_t *ret_value = NULL; /* Return value */ + const char *prefix; /* Pointer to raw string for path */ + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -361,50 +347,11 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) HDassert(prefix); /* Create reference counted string for path */ - ret_value = H5G_build_fullpath(prefix, name); + ret_value = H5G__build_fullpath(prefix, name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_build_fullpath_refstr_str() */ -#ifdef NOT_YET - -/*------------------------------------------------------------------------- - * Function: H5G_name_build_refstr_refstr - * - * Purpose: Build a full path from a prefix & base pair of reference counted - * strings - * - * Return: Pointer to reference counted string on success, NULL on error - * - * Programmer: Quincey Koziol - * - * Date: August 19, 2005 - * - *------------------------------------------------------------------------- - */ -static H5RS_str_t * -H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r) -{ - const char *prefix; /* Pointer to raw string of prefix */ - const char *name; /* Pointer to raw string of name */ - H5RS_str_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Get the pointer to the prefix */ - prefix = H5RS_get_str(prefix_r); - - /* Get the pointer to the raw src user path */ - name = H5RS_get_str(name_r); - - /* Create reference counted string for path */ - ret_value = H5G_build_fullpath(prefix, name); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_build_fullpath_refstr_refstr() */ -#endif /* NOT_YET */ - - /*------------------------------------------------------------------------- * Function: H5G__name_init * @@ -436,7 +383,6 @@ H5G__name_init(H5G_name_t *name, const char *path) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__name_init() */ - /*------------------------------------------------------------------------- * Function: H5G_name_set * @@ -453,7 +399,7 @@ H5G__name_init(H5G_name_t *name, const char *path) herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -465,16 +411,16 @@ H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name) H5G_name_free(obj); /* Create the object's full path, if a full path exists in the location */ - if(loc->full_path_r) { + if (loc->full_path_r) { /* Go build the new full path */ - if((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL) + if ((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") } /* end if */ /* Create the object's user path, if a user path exists in the location */ - if(loc->user_path_r) { + if (loc->user_path_r) { /* Go build the new user path */ - if((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL) + if ((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") } /* end if */ @@ -482,7 +428,6 @@ H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_set() */ - /*------------------------------------------------------------------------- * Function: H5G_name_copy * @@ -524,10 +469,11 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) H5MM_memcpy(dst, src, sizeof(H5G_name_t)); /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { + if (depth == H5_COPY_DEEP) { dst->full_path_r = H5RS_dup(src->full_path_r); dst->user_path_r = H5RS_dup(src->user_path_r); - } else { + } + else { /* Discarding 'const' qualifier OK - QAK */ H5G_name_reset((H5G_name_t *)src); } /* end if */ @@ -535,7 +481,6 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_copy() */ - /*------------------------------------------------------------------------- * Function: H5G_get_name * @@ -552,11 +497,10 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) *------------------------------------------------------------------------- */ ssize_t -H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, - hbool_t *cached) +H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached) { - ssize_t len = 0; /* Length of object's name */ - ssize_t ret_value = -1; /* Return value */ + ssize_t len = 0; /* Length of object's name */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -564,40 +508,28 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, HDassert(loc); /* If the user path is available and it's not "hidden", use it */ - if(loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) { + if (loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) { len = H5RS_len(loc->path->user_path_r); - if(name) { + if (name) { HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((size_t)(len + 1), size)); - if((size_t)len >= size) + if ((size_t)len >= size) name[size - 1] = '\0'; } /* end if */ /* Indicate that the name is cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ - if(cached) + if (cached) *cached = TRUE; } /* end if */ - else if(!loc->path->obj_hidden) { - hid_t file; - - /* Retrieve file ID for name search */ - if((file = H5F_get_id(loc->oloc->file, FALSE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get file ID") - + else if (!loc->path->obj_hidden) { /* Search for name of object */ - if((len = H5G_get_name_by_addr(file, loc->oloc, name, size)) < 0) { - H5I_dec_ref(file); + if ((len = H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") - } /* end if */ - - /* Close file ID used for search */ - if(H5I_dec_ref(file) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name") /* Indicate that the name is _not_ cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ - if(cached) + if (cached) *cached = FALSE; } /* end else */ @@ -608,7 +540,6 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name() */ - /*------------------------------------------------------------------------- * Function: H5G_name_reset * @@ -636,7 +567,6 @@ H5G_name_reset(H5G_name_t *name) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_reset() */ - /*------------------------------------------------------------------------- * Function: H5G_name_free * @@ -658,11 +588,11 @@ H5G_name_free(H5G_name_t *name) /* Check args */ HDassert(name); - if(name->full_path_r) { + if (name->full_path_r) { H5RS_decr(name->full_path_r); name->full_path_r = NULL; } /* end if */ - if(name->user_path_r) { + if (name->user_path_r) { H5RS_decr(name->user_path_r); name->user_path_r = NULL; } /* end if */ @@ -671,9 +601,8 @@ H5G_name_free(H5G_name_t *name) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_free() */ - /*------------------------------------------------------------------------- - * Function: H5G_name_move_path + * Function: H5G__name_move_path * * Purpose: Update a user or canonical path after an object moves * @@ -686,15 +615,15 @@ H5G_name_free(H5G_name_t *name) *------------------------------------------------------------------------- */ static herr_t -H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, - const char *dst_path) +H5G__name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, + const char *dst_path) { - const char *path; /* Path to update */ - size_t path_len; /* Length of path */ - size_t full_suffix_len; /* Length of full suffix */ - herr_t ret_value = SUCCEED; /* Return value */ + const char *path; /* Path to update */ + size_t path_len; /* Length of path */ + size_t full_suffix_len; /* Length of full suffix */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ HDassert(path_r_ptr && *path_r_ptr); @@ -708,31 +637,30 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char /* Check if path needs to be updated */ full_suffix_len = HDstrlen(full_suffix); - path_len = HDstrlen(path); - if(full_suffix_len < path_len) { - const char *dst_suffix; /* Destination suffix that changes */ - size_t dst_suffix_len; /* Length of destination suffix */ - const char *src_suffix; /* Source suffix that changes */ - size_t path_prefix_len; /* Length of path prefix */ - const char *path_prefix2; /* 2nd prefix for path */ - 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 */ - size_t new_path_len; /* Length of new path */ - + path_len = HDstrlen(path); + if (full_suffix_len < path_len) { + const char *dst_suffix; /* Destination suffix that changes */ + size_t dst_suffix_len; /* Length of destination suffix */ + const char *src_suffix; /* Source suffix that changes */ + size_t path_prefix_len; /* Length of path prefix */ + const char *path_prefix2; /* 2nd prefix for path */ + 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 */ + size_t new_path_len; /* Length of new path */ /* Compute path prefix before full suffix*/ path_prefix_len = path_len - full_suffix_len; /* Determine the common prefix for src & dst paths */ - common_prefix = src_path; + common_prefix = src_path; common_prefix_len = 0; /* Find first character that is different */ - while(*(src_path + common_prefix_len) == *(dst_path + common_prefix_len)) + while (*(src_path + common_prefix_len) == *(dst_path + common_prefix_len)) common_prefix_len++; /* Back up to previous '/' */ - while(*(common_prefix + common_prefix_len) != '/') + while (*(common_prefix + common_prefix_len) != '/') common_prefix_len--; /* Include '/' */ common_prefix_len++; @@ -741,26 +669,26 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char src_suffix = src_path + (common_prefix_len - 1); /* Determine destination suffix */ - dst_suffix = dst_path + (common_prefix_len - 1); + dst_suffix = dst_path + (common_prefix_len - 1); dst_suffix_len = HDstrlen(dst_suffix); /* Compute path prefix before src suffix*/ - path_prefix2 = path; + path_prefix2 = path; path_prefix2_len = path_prefix_len - HDstrlen(src_suffix); /* Allocate space for the new path */ new_path_len = path_prefix2_len + dst_suffix_len + full_suffix_len; - if(NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) + if (NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new path */ - if(path_prefix2_len > 0) { + if (path_prefix2_len > 0) { HDstrncpy(new_path, path_prefix2, path_prefix2_len + 1); HDstrncpy(new_path + path_prefix2_len, dst_suffix, dst_suffix_len + 1); } /* end if */ else HDstrncpy(new_path, dst_suffix, dst_suffix_len + 1); - if(full_suffix_len > 0) + if (full_suffix_len > 0) HDstrncat(new_path, full_suffix, full_suffix_len); /* Release previous path */ @@ -772,11 +700,10 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_name_move_path() */ +} /* end H5G__name_move_path() */ - /*------------------------------------------------------------------------- - * Function: H5G_name_replace_cb + * Function: H5G__name_replace_cb * * Purpose: H5I_iterate callback function to replace group entry names * @@ -789,52 +716,56 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *------------------------------------------------------------------------- */ static int -H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) +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. */ - 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 */ + 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. */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(obj_ptr); /* Get the symbol table entry */ - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_GROUP: - oloc = H5G_oloc((H5G_t *)obj_ptr); + oloc = H5G_oloc((H5G_t *)obj_ptr); obj_path = H5G_nameof((H5G_t *)obj_ptr); break; case H5I_DATASET: - oloc = H5D_oloc((H5D_t *)obj_ptr); + oloc = H5D_oloc((H5D_t *)obj_ptr); obj_path = H5D_nameof((H5D_t *)obj_ptr); break; case H5I_DATATYPE: /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t *)obj_ptr)) - HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ + if (!H5T_is_named((H5T_t *)obj_ptr)) + HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ - oloc = H5T_oloc((H5T_t *)obj_ptr); + oloc = H5T_oloc((H5T_t *)obj_ptr); obj_path = H5T_nameof((H5T_t *)obj_ptr); break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, 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_REFERENCE: 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_ARGS, H5E_BADTYPE, FAIL, "unknown data object") @@ -843,60 +774,60 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDassert(obj_path); /* Check if the object has a full path still */ - if(!obj_path->full_path_r) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + if (!obj_path->full_path_r) + HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ /* Find the top file in object's mount hier. */ - if(H5F_PARENT(oloc->file)) { + if (H5F_PARENT(oloc->file)) { /* Check if object is in child file (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file)) obj_in_child = TRUE; /* Find the "top" file in the chain of mounted files */ top_obj_file = H5F_PARENT(oloc->file); - while(H5F_PARENT(top_obj_file) != NULL) { + while (H5F_PARENT(top_obj_file) != NULL) { /* Check if object is in child mount hier. (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) obj_in_child = TRUE; top_obj_file = H5F_PARENT(top_obj_file); } /* end while */ - } /* end if */ + } /* end if */ else top_obj_file = oloc->file; /* Check if object is in top of child mount hier. (for mount & unmount operations) */ - if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) + if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file)) obj_in_child = TRUE; /* Check if the object is in same file mount hier. */ - if(!H5F_SAME_SHARED(top_obj_file, names->src_file)) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + if (!H5F_SAME_SHARED(top_obj_file, names->src_file)) + HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ - switch(names->op) { + switch (names->op) { /*------------------------------------------------------------------------- * H5G_NAME_MOUNT *------------------------------------------------------------------------- */ case H5G_NAME_MOUNT: /* Check if object is in child mount hier. */ - if(obj_in_child) { - 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 */ - size_t new_full_len; /* Length of new full path */ + if (obj_in_child) { + 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 */ + size_t new_full_len; /* Length of new full path */ /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); + full_path = H5RS_get_str(obj_path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); src_path_len = HDstrlen(src_path); /* Build new full path */ /* Allocate space for the new full path */ new_full_len = src_path_len + HDstrlen(full_path); - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ @@ -913,12 +844,12 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) else { /* Check if the source is along the entry's path */ /* (But not actually the entry itself) */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Hide the user path */ (obj_path->obj_hidden)++; } /* end if */ - } /* end else */ + } /* end else */ break; /*------------------------------------------------------------------------- @@ -926,25 +857,25 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) *------------------------------------------------------------------------- */ case H5G_NAME_UNMOUNT: - if(obj_in_child) { - const char *full_path; /* Full path of current object */ - 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 */ + if (obj_in_child) { + const char *full_path; /* Full path of current object */ + 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 */ /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); /* Construct full path suffix */ - full_suffix = full_path + HDstrlen(src_path); + full_suffix = full_path + HDstrlen(src_path); full_suffix_len = HDstrlen(full_suffix); /* Build new full path */ /* Create the new full path */ - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, full_suffix_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, full_suffix_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_full_path, full_suffix, full_suffix_len + 1); @@ -955,20 +886,21 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) obj_path->full_path_r = H5RS_own(new_full_path); /* Check if the object's user path should be invalidated */ - if(obj_path->user_path_r && HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) { + if (obj_path->user_path_r && + HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) { /* Free user path */ H5RS_decr(obj_path->user_path_r); obj_path->user_path_r = NULL; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check if file being unmounted was hiding the object */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Un-hide the user path */ (obj_path->obj_hidden)--; } /* end if */ - } /* end else */ + } /* end else */ break; /*------------------------------------------------------------------------- @@ -977,7 +909,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_DELETE: /* Check if the location being unlinked is in the path for the current object */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { + if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r)) { /* Free paths for object */ H5G_name_free(obj_path); } /* end if */ @@ -989,23 +921,23 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_MOVE: /* Link move case, check for relative names case */ /* Check if the src object moved is in the current object's path */ - if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { - 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 */ - 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 */ - size_t dst_path_len; /* Length of destination's full path */ + if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r)) { + 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 */ + 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 */ + size_t dst_path_len; /* Length of destination's full path */ /* Sanity check */ HDassert(names->dst_full_path_r); /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->src_full_path_r); - dst_path = H5RS_get_str(names->dst_full_path_r); + full_path = H5RS_get_str(obj_path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); + dst_path = H5RS_get_str(names->dst_full_path_r); dst_path_len = HDstrlen(dst_path); /* Make certain that the source and destination names are full (not relative) paths */ @@ -1013,19 +945,19 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDassert(*dst_path == '/'); /* Get pointer to "full suffix" */ - full_suffix = full_path + HDstrlen(src_path); + full_suffix = full_path + HDstrlen(src_path); full_suffix_len = HDstrlen(full_suffix); /* Update the user path, if one exists */ - if(obj_path->user_path_r) - if(H5G_name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0) + if (obj_path->user_path_r) + if (H5G__name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") /* Build new full path */ /* Allocate space for the new full path */ new_full_len = dst_path_len + full_suffix_len; - if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) + if (NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the new full path */ @@ -1046,9 +978,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) done: FUNC_LEAVE_NOAPI(ret_value); -} /* end H5G_name_replace_cb() */ +} /* end H5G__name_replace_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_name_replace * @@ -1068,8 +999,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) *------------------------------------------------------------------------- */ herr_t -H5G_name_replace(const 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) +H5G_name_replace(const 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) { herr_t ret_value = SUCCEED; @@ -1079,53 +1010,56 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, HDassert(src_file); /* Check if the object we are manipulating has a path */ - if(src_full_path_r) { - hbool_t search_group = FALSE; /* Flag to indicate that groups are to be searched */ - hbool_t search_dataset = FALSE; /* Flag to indicate that datasets are to be searched */ + if (src_full_path_r) { + hbool_t search_group = FALSE; /* Flag to indicate that groups are to be searched */ + hbool_t search_dataset = FALSE; /* Flag to indicate that datasets are to be searched */ hbool_t search_datatype = FALSE; /* Flag to indicate that datatypes are to be searched */ /* Check for particular link to operate on */ - if(lnk) { + if (lnk) { /* Look up the object type for each type of link */ - switch(lnk->type) { - case H5L_TYPE_HARD: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = src_file; - tmp_oloc.addr = lnk->u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - - /* Determine which type of objects to operate on */ - switch(obj_type) { - case H5O_TYPE_GROUP: - /* Search and replace names through group IDs */ - search_group = TRUE; - break; - - case H5O_TYPE_DATASET: - /* Search and replace names through dataset IDs */ - search_dataset = TRUE; - break; - - case H5O_TYPE_NAMED_DATATYPE: - /* Search and replace names through datatype IDs */ - search_datatype = TRUE; - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - /* Search and replace names through datatype IDs */ - default: - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") - } /* end switch */ - } /* end case */ - break; + switch (lnk->type) { + case H5L_TYPE_HARD: { + H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_type_t obj_type; /* Type of object at location */ + + /* Build temporary object location */ + tmp_oloc.file = src_file; + tmp_oloc.addr = lnk->u.hard.addr; + + /* Get the type of the object */ + if (H5O_obj_type(&tmp_oloc, &obj_type) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + + /* Determine which type of objects to operate on */ + switch (obj_type) { + case H5O_TYPE_GROUP: + /* Search and replace names through group IDs */ + search_group = TRUE; + break; + + case H5O_TYPE_DATASET: + /* Search and replace names through dataset IDs */ + search_dataset = TRUE; + break; + + case H5O_TYPE_NAMED_DATATYPE: + /* Search and replace names through datatype IDs */ + search_datatype = TRUE; + break; + + case H5O_TYPE_MAP: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, + "maps not supported in native VOL connector") + + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + /* Search and replace names through datatype IDs */ + default: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") + } /* end switch */ + } /* end case */ + break; case H5L_TYPE_SOFT: /* Symbolic links might resolve to any object, so we need to search all IDs */ @@ -1135,10 +1069,10 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: - default: /* User-defined link */ + default: /* User-defined link */ /* Check for unknown library-defined link type */ - if(lnk->type < H5L_TYPE_UD_MIN) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") + if (lnk->type < H5L_TYPE_UD_MIN) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") /* User-defined & external links automatically wipe out * names (because it would be too much work to track them), @@ -1146,51 +1080,50 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, */ break; } /* end switch */ - } /* end if */ + } /* end if */ else { /* We pass NULL as link pointer when we need to search all IDs */ search_group = search_dataset = search_datatype = TRUE; } /* Check if we need to operate on the objects affected */ - if(search_group || search_dataset || search_datatype) { - H5G_names_t names; /* Structure to hold operation information for callback */ + if (search_group || search_dataset || search_datatype) { + H5G_names_t names; /* Structure to hold operation information for callback */ /* Find top file in src location's mount hierarchy */ - while(H5F_PARENT(src_file)) + while (H5F_PARENT(src_file)) src_file = H5F_PARENT(src_file); /* Set up common information for callback */ - names.src_file = src_file; - names.src_full_path_r = src_full_path_r; - names.dst_file = dst_file; - names.dst_full_path_r = dst_full_path_r; - names.op = op; + names.src_file = src_file; + names.src_full_path_r = src_full_path_r; + names.dst_file = dst_file; + names.dst_full_path_r = dst_full_path_r; + names.op = op; /* Search through group IDs */ - if(search_group) - if(H5I_iterate(H5I_GROUP, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_group) + if (H5I_iterate(H5I_GROUP, H5G__name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over groups") /* Search through dataset IDs */ - if(search_dataset) - if(H5I_iterate(H5I_DATASET, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_dataset) + if (H5I_iterate(H5I_DATASET, H5G__name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datasets") /* Search through datatype IDs */ - if(search_datatype) - if(H5I_iterate(H5I_DATATYPE, H5G_name_replace_cb, &names, FALSE) < 0) + if (search_datatype) + if (H5I_iterate(H5I_DATATYPE, H5G__name_replace_cb, &names, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datatypes") } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_replace() */ - /*------------------------------------------------------------------------- - * Function: H5G_get_name_by_addr_cb + * Function: H5G__get_name_by_addr_cb * * Purpose: Callback for retrieving object's name by address * @@ -1204,17 +1137,16 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, *------------------------------------------------------------------------- */ static herr_t -H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, - void *_udata) +H5G__get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, void *_udata) { H5G_gnba_iter_t *udata = (H5G_gnba_iter_t *)_udata; /* User data for iteration */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'path' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'path' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(path); @@ -1223,42 +1155,49 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, HDassert(udata->path == NULL); /* Check for hard link with correct address */ - if(linfo->type == H5L_TYPE_HARD && udata->loc->addr == linfo->u.address) { - H5G_loc_t grp_loc; /* Location of group */ - - /* Get group's location */ - if(H5G_loc(gid, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") - - /* Set up opened object location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object */ - if(H5G_loc_find(&grp_loc, path, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") - obj_found = TRUE; - - /* Check for object in same file (handles mounted files) */ - /* (re-verify address, in case we traversed a file mount) */ - if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { - if(NULL == (udata->path = H5MM_strdup(path))) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") - - /* We found a match so we return immediately */ - HGOTO_DONE(H5_ITER_STOP) - } /* end if */ - } /* end if */ + if (linfo->type == H5L_TYPE_HARD) { + haddr_t link_addr; + + /* Retrieve hard link address from VOL token */ + if (H5VL_native_token_to_addr(udata->loc->file, H5I_FILE, linfo->u.token, &link_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + + if (udata->loc->addr == link_addr) { + H5G_loc_t grp_loc; /* Location of group */ + + /* Get group's location */ + if (H5G_loc(gid, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") + + /* Set up opened object location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object */ + if (H5G_loc_find(&grp_loc, path, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") + obj_found = TRUE; + + /* Check for object in same file (handles mounted files) */ + /* (re-verify address, in case we traversed a file mount) */ + if (udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { + if (NULL == (udata->path = H5MM_strdup(path))) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") + + /* We found a match so we return immediately */ + HGOTO_DONE(H5_ITER_STOP) + } /* end if */ + } /* end if */ + } /* end if */ done: - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_get_name_by_addr_cb() */ +} /* end H5G__get_name_by_addr_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_get_name_by_addr * @@ -1276,13 +1215,13 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, *------------------------------------------------------------------------- */ ssize_t -H5G_get_name_by_addr(hid_t file, const H5O_loc_t *loc, char *name, size_t size) +H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) { - H5G_gnba_iter_t udata; /* User data for iteration */ - H5G_loc_t root_loc; /* Root group's location */ - hbool_t found_obj = FALSE; /* If we found the object */ - herr_t status; /* Status from iteration */ - ssize_t ret_value = -1; /* Return value */ + H5G_gnba_iter_t udata; /* User data for iteration */ + H5G_loc_t root_loc; /* Root group's location */ + hbool_t found_obj = FALSE; /* If we found the object */ + herr_t status; /* Status from iteration */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -1290,44 +1229,45 @@ H5G_get_name_by_addr(hid_t file, const H5O_loc_t *loc, char *name, size_t size) FUNC_ENTER_NOAPI((-1)) /* Construct a group location for root group of the file */ - if(H5G_loc(file, &root_loc) < 0) + if (H5G_root_loc(f, &root_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get root group's location") /* Check for root group being the object looked for */ - if(root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { - if(NULL == (udata.path = H5MM_strdup(""))) + if (root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { + if (NULL == (udata.path = H5MM_strdup(""))) HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, (-1), "can't duplicate path string") found_obj = TRUE; } /* end if */ else { /* Set up user data for iterator */ - udata.loc = loc; + udata.loc = loc; udata.path = NULL; /* Visit all the links in the file */ - if((status = H5G_visit(file, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata)) < 0) + if ((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G__get_name_by_addr_cb, + &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, (-1), "group traversal failed while looking for object name") - else if(status > 0) + else if (status > 0) found_obj = TRUE; } /* end else */ /* Check for finding the object */ - if(found_obj) { + if (found_obj) { /* Set the length of the full path */ - ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ + ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ /* If there's a buffer provided, copy into it, up to the limit of its size */ - if(name) { + if (name) { /* Copy the initial path separator */ HDstrncpy(name, "/", (size_t)2); /* Append the rest of the path */ /* (less one character, for the initial path separator) */ HDstrncat(name, udata.path, (size - 2)); - if((size_t)ret_value >= size) + if ((size_t)ret_value >= size) name[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else ret_value = 0; @@ -1337,4 +1277,3 @@ H5G_get_name_by_addr(hid_t file, const H5O_loc_t *loc, char *name, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name_by_addr() */ - diff --git a/src/H5Gnode.c b/src/H5Gnode.c index c48d8dca86b..9a7da0fffa0 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,29 +29,26 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -61,37 +58,32 @@ * nodes consists of this structure... */ typedef struct H5G_node_key_t { - size_t offset; /*offset into heap for name */ + size_t offset; /*offset into heap for name */ } H5G_node_key_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* B-tree callbacks */ -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); -static int H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key); -static htri_t H5G_node_found(H5F_t *f, haddr_t addr, const void *_lt_key, - void *_udata); -static H5B_ins_t H5G__node_insert(H5F_t *f, haddr_t addr, void *_lt_key, - hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, - hbool_t *rt_key_changed, haddr_t *new_node_p/*out*/); -static H5B_ins_t H5G_node_remove(H5F_t *f, haddr_t addr, void *lt_key, - hbool_t *lt_key_changed, void *udata, void *rt_key, hbool_t *rt_key_changed); -static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); -static herr_t 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); - +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); +static int H5G__node_cmp3(void *_lt_key, void *_udata, void *_rt_key); +static htri_t H5G__node_found(H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata); +static H5B_ins_t H5G__node_insert(H5F_t *f, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node_p /*out*/); +static H5B_ins_t H5G__node_remove(H5F_t *f, haddr_t addr, void *lt_key, hbool_t *lt_key_changed, void *udata, + void *rt_key, hbool_t *rt_key_changed); +static herr_t H5G__node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key); +static herr_t 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); /*********************/ /* Package Variables */ @@ -99,21 +91,21 @@ static herr_t H5G_node_debug_key(FILE *stream, int indent, int fwidth, /* H5G inherits B-tree like properties from H5B */ H5B_class_t H5B_SNODE[1] = {{ - H5B_SNODE_ID, /*id */ - sizeof(H5G_node_key_t), /*sizeof_nkey */ - H5G_node_get_shared, /*get_shared */ - H5G__node_create, /*new */ - H5G_node_cmp2, /*cmp2 */ - H5G_node_cmp3, /*cmp3 */ - H5G_node_found, /*found */ - H5G__node_insert, /*insert */ - TRUE, /*follow min branch? */ - TRUE, /*follow max branch? */ - H5B_RIGHT, /*critical key */ - H5G_node_remove, /*remove */ - H5G_node_decode_key, /*decode */ - H5G_node_encode_key, /*encode */ - H5G_node_debug_key /*debug */ + H5B_SNODE_ID, /*id */ + sizeof(H5G_node_key_t), /*sizeof_nkey */ + H5G__node_get_shared, /*get_shared */ + H5G__node_create, /*new */ + H5G__node_cmp2, /*cmp2 */ + H5G__node_cmp3, /*cmp3 */ + H5G__node_found, /*found */ + H5G__node_insert, /*insert */ + TRUE, /*follow min branch? */ + TRUE, /*follow max branch? */ + H5B_RIGHT, /*critical key */ + H5G__node_remove, /*remove */ + H5G__node_decode_key, /*decode */ + H5G__node_encode_key, /*encode */ + H5G__node_debug_key /*debug */ }}; /* Declare a free list to manage the H5G_node_t struct */ @@ -122,19 +114,16 @@ H5FL_DEFINE(H5G_node_t); /* Declare a free list to manage sequences of H5G_entry_t's */ H5FL_SEQ_DEFINE(H5G_entry_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- - * Function: H5G_node_get_shared + * Function: H5G__node_get_shared * * Purpose: Returns the shared B-tree info for the specified UDATA. * @@ -148,19 +137,18 @@ H5FL_SEQ_DEFINE(H5G_entry_t); *------------------------------------------------------------------------- */ static H5UC_t * -H5G_node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) +H5G__node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f); /* Return the pointer to the ref-count object */ FUNC_LEAVE_NOAPI(H5F_GRP_BTREE_SHARED(f)) -} /* end H5G_node_get_shared() */ +} /* end H5G__node_get_shared() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_decode_key + * Function: H5G__node_decode_key * * Purpose: Decodes a raw key into a native key. * @@ -172,11 +160,11 @@ H5G_node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) *------------------------------------------------------------------------- */ static herr_t -H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) +H5G__node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) { - H5G_node_key_t *key = (H5G_node_key_t *) _key; + H5G_node_key_t *key = (H5G_node_key_t *)_key; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(shared); HDassert(raw); @@ -185,11 +173,10 @@ H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) H5F_DECODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_node_decode_key() */ +} /* end H5G__node_decode_key() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_encode_key + * Function: H5G__node_encode_key * * Purpose: Encodes a native key into a raw key. * @@ -201,11 +188,11 @@ H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) +H5G__node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) { - const H5G_node_key_t *key = (const H5G_node_key_t *) _key; + const H5G_node_key_t *key = (const H5G_node_key_t *)_key; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(shared); HDassert(raw); @@ -214,11 +201,10 @@ H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) H5F_ENCODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_node_encode_key() */ +} /* end H5G__node_encode_key() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_debug_key + * Function: H5G__node_debug_key * * Purpose: Prints a key. * @@ -230,34 +216,31 @@ 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) +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_bt_common_t *udata = (const H5G_bt_common_t *) _udata; + 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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(key); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", - (unsigned)key->offset); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", (unsigned)key->offset); - if(udata->heap) { + if (udata->heap) { const char *s; HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); - if((s = (const char *)H5HL_offset_into(udata->heap, key->offset)) != NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, key->offset)) != NULL) HDfprintf(stream, "%s\n", s); } /* end if */ else HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cannot get name; heap address not specified\n"); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_node_debug_key() */ +} /* end H5G__node_debug_key() */ - /*------------------------------------------------------------------------- * Function: H5G__node_free * @@ -283,14 +266,13 @@ H5G__node_free(H5G_node_t *sym) /* Verify that node is clean */ HDassert(sym->cache_info.is_dirty == FALSE); - if(sym->entry) + if (sym->entry) sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry); sym = H5FL_FREE(H5G_node_t, sym); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_free() */ - /*------------------------------------------------------------------------- * Function: H5G__node_create * @@ -310,13 +292,13 @@ H5G__node_free(H5G_node_t *sym) *------------------------------------------------------------------------- */ static herr_t -H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, - void H5_ATTR_UNUSED *_udata, void *_rt_key, haddr_t *addr_p/*out*/) +H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, void H5_ATTR_UNUSED *_udata, + void *_rt_key, haddr_t *addr_p /*out*/) { - 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; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -326,15 +308,15 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, HDassert(f); HDassert(H5B_INS_FIRST == op); - if(NULL == (sym = H5FL_CALLOC(H5G_node_t))) + if (NULL == (sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") sym->node_size = H5G_NODE_SIZE(f); - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)sym->node_size))) + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)sym->node_size))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space") - if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) + if (NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f))))) HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(H5AC_insert_entry(f, H5AC_SNODE, *addr_p, sym, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SNODE, *addr_p, sym, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to cache symbol table leaf node") /* * The left and right symbols in an empty tree are both the @@ -342,26 +324,25 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, * allows the comparison functions to work correctly without knowing * that there are no symbols. */ - if(lt_key) + if (lt_key) lt_key->offset = 0; - if(rt_key) + if (rt_key) rt_key->offset = 0; done: - if(ret_value < 0) { - if(sym != NULL) { - if(sym->entry != NULL) + if (ret_value < 0) { + if (sym != NULL) { + if (sym->entry != NULL) sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry); sym = H5FL_FREE(H5G_node_t, sym); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_create() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_cmp2 + * Function: H5G__node_cmp2 * * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY). * The UDATA pointer supplies extra data not contained in the @@ -381,15 +362,15 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, *------------------------------------------------------------------------- */ static herr_t -H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) +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; - int ret_value = SUCCEED; /* Return value */ + 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; + int ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(udata && udata->heap); @@ -397,9 +378,9 @@ H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) HDassert(rt_key); /* Get pointers to string names */ - if((s1 = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) + if ((s1 = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if((s2 = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) + if ((s2 = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") /* Set return value */ @@ -407,11 +388,10 @@ H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_node_cmp2() */ +} /* H5G__node_cmp2() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_cmp3 + * Function: H5G__node_cmp3 * * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY) * against another key (not necessarily the same type) @@ -435,15 +415,15 @@ H5G_node_cmp2(void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) +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; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(udata && udata->heap); @@ -451,25 +431,24 @@ H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) HDassert(rt_key); /* left side */ - if((s = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, lt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if(HDstrcmp(udata->name, s) <= 0) + if (HDstrcmp(udata->name, s) <= 0) ret_value = (-1); else { /* right side */ - if((s = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->heap, rt_key->offset)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get key name") - if(HDstrcmp(udata->name, s) > 0) + if (HDstrcmp(udata->name, s) > 0) ret_value = 1; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_node_cmp3() */ +} /* end H5G__node_cmp3() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_found + * Function: H5G__node_found * * Purpose: The B-tree search engine has found the symbol table node * which contains the requested symbol if the symbol exists. @@ -494,17 +473,16 @@ H5G_node_cmp3(void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static htri_t -H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, - void *_udata) +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; - unsigned lt = 0, idx = 0, rt; - int cmp = 1; - const char *s; - htri_t ret_value = TRUE; /* Return value */ + H5G_bt_lkp_t *udata = (H5G_bt_lkp_t *)_udata; + H5G_node_t * sn = NULL; + unsigned lt = 0, idx = 0, rt; + int cmp = 1; + const char * s; + htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -516,17 +494,17 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, /* * Load the symbol table node for exclusive access. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node") /* * Binary search. */ rt = sn->nsyms; - while(lt < rt && cmp) { + while (lt < rt && cmp) { idx = (lt + rt) / 2; - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name") cmp = HDstrcmp(udata->common.name, s); @@ -536,21 +514,20 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, lt = idx + 1; } /* end while */ - if(cmp) + if (cmp) HGOTO_DONE(FALSE) /* Call user's callback operator */ - if((udata->op)(&sn->entry[idx], udata->op_data) < 0) + if ((udata->op)(&sn->entry[idx], udata->op_data) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "iterator callback failed") done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_node_found() */ +} /* end H5G__node_found() */ - /*------------------------------------------------------------------------- * Function: H5G__node_insert * @@ -583,20 +560,19 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, *------------------------------------------------------------------------- */ static H5B_ins_t -H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, - hbool_t H5_ATTR_UNUSED *lt_key_changed, void *_md_key, void *_udata, - void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p) +H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, hbool_t H5_ATTR_UNUSED *lt_key_changed, + void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed, haddr_t *new_node_p) { - 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_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; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; - const char *s; - unsigned lt = 0, rt; /* Binary search cntrs */ + 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_entry_t ent; /* Entry to insert in node */ + 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; FUNC_ENTER_STATIC @@ -614,20 +590,20 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, /* * Load the symbol node. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* * Where does the new symbol get inserted? We use a binary search. */ rt = sn->nsyms; - while(lt < rt) { + while (lt < rt) { idx = (int)((lt + rt) / 2); - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") /* Check if symbol is already present */ - if(0 == (cmp = HDstrcmp(udata->common.name, s))) + if (0 == (cmp = HDstrcmp(udata->common.name, s))) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "symbol is already present in symbol table") if (cmp < 0) @@ -638,34 +614,32 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, idx += cmp > 0 ? 1 : 0; /* Convert link information & name to symbol table entry */ - if(H5G__ent_convert(f, udata->common.heap, udata->common.name, - udata->lnk, udata->obj_type, udata->crt_info, &ent) < 0) + if (H5G__ent_convert(f, udata->common.heap, udata->common.name, udata->lnk, udata->obj_type, + udata->crt_info, &ent) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5B_INS_ERROR, "unable to convert link") /* Determine where to place entry in node */ - if(sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { + if (sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the * left node is at the same address as the original node). */ - ret_value = H5B_INS_RIGHT; + ret_value = H5B_INS_RIGHT; - /* The right node */ - if(H5G__node_create(f, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p/*out*/) < 0) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") + /* The right node */ + if (H5G__node_create(f, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") - if(NULL == (snrt = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, *new_node_p, f, H5AC__NO_FLAGS_SET))) + if (NULL == (snrt = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, *new_node_p, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node") - H5MM_memcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), - H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); + H5MM_memcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); snrt->nsyms = H5F_SYM_LEAF_K(f); snrt_flags |= H5AC__DIRTIED_FLAG; /* The left node */ - HDmemset(sn->entry + H5F_SYM_LEAF_K(f), 0, - H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); + HDmemset(sn->entry + H5F_SYM_LEAF_K(f), 0, H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); sn->nsyms = H5F_SYM_LEAF_K(f); sn_flags |= H5AC__DIRTIED_FLAG; @@ -673,35 +647,35 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ - if(idx <= (int)H5F_SYM_LEAF_K(f)) { + if (idx <= (int)H5F_SYM_LEAF_K(f)) { insert_into = sn; - if(idx == (int)H5F_SYM_LEAF_K(f)) + if (idx == (int)H5F_SYM_LEAF_K(f)) md_key->offset = ent.name_off; } /* end if */ else { idx -= (int)H5F_SYM_LEAF_K(f); insert_into = snrt; - if(idx == (int)H5F_SYM_LEAF_K(f)) { - rt_key->offset = ent.name_off; + if (idx == (int)H5F_SYM_LEAF_K(f)) { + rt_key->offset = ent.name_off; *rt_key_changed = TRUE; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Where to insert the new entry? */ ret_value = H5B_INS_NOOP; sn_flags |= H5AC__DIRTIED_FLAG; insert_into = sn; - if(idx == (int)sn->nsyms) { - rt_key->offset = ent.name_off; + if (idx == (int)sn->nsyms) { + rt_key->offset = ent.name_off; *rt_key_changed = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* Move entries down to make room for new entry */ HDassert(idx >= 0); HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, - (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); + (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ H5G__ent_copy(&(insert_into->entry[idx]), &ent, H5_COPY_SHALLOW); @@ -710,17 +684,16 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, insert_into->nsyms += 1; done: - if(snrt && H5AC_unprotect(f, H5AC_SNODE, *new_node_p, snrt, snrt_flags) < 0) + if (snrt && H5AC_unprotect(f, H5AC_SNODE, *new_node_p, snrt, snrt_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_insert() */ - /*------------------------------------------------------------------------- - * Function: H5G_node_remove + * Function: H5G__node_remove * * Purpose: The B-tree removal engine has found the symbol table node * which should contain the name which is being removed. This @@ -748,68 +721,67 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, *------------------------------------------------------------------------- */ static H5B_ins_t -H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, - hbool_t H5_ATTR_UNUSED *lt_key_changed/*out*/, - void *_udata/*in,out*/, void *_rt_key/*in,out*/, - hbool_t *rt_key_changed/*out*/) +H5G__node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*in,out*/, + hbool_t H5_ATTR_UNUSED *lt_key_changed /*out*/, void *_udata /*in,out*/, + void *_rt_key /*in,out*/, hbool_t *rt_key_changed /*out*/) { - 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_bt_rm_t *udata = (H5G_bt_rm_t *)_udata; - H5G_node_t *sn = NULL; + 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; unsigned sn_flags = H5AC__NO_FLAGS_SET; unsigned lt = 0, rt, idx = 0; - int cmp = 1; + int cmp = 1; H5B_ins_t ret_value = H5B_INS_ERROR; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(lt_key); + HDassert((H5G_node_key_t *)_lt_key); HDassert(rt_key); HDassert(udata && udata->common.heap); /* Load the symbol table */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* "Normal" removal of a single entry from the symbol table node */ - if(udata->common.name != NULL) { - H5O_link_t lnk; /* Constructed link for replacement */ - size_t link_name_len; /* Length of string in local heap */ + if (udata->common.name != NULL) { + H5O_link_t lnk; /* Constructed link for replacement */ + size_t link_name_len; /* Length of string in local heap */ /* Find the name with a binary search */ rt = sn->nsyms; - while(lt < rt && cmp) { - const char *s; /* Pointer to string in local heap */ + while (lt < rt && cmp) { + const char *s; /* Pointer to string in local heap */ idx = (lt + rt) / 2; - if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + if ((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") cmp = HDstrcmp(udata->common.name, s); - if(cmp < 0) + if (cmp < 0) rt = idx; else lt = idx + 1; } /* end while */ - if(cmp) + if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "name not found") /* Get a pointer to the name of the link */ - if(NULL == (lnk.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off))) + if (NULL == (lnk.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get link name") link_name_len = HDstrlen(lnk.name) + 1; /* Set up rest of link structure */ lnk.corder_valid = FALSE; - lnk.corder = 0; - lnk.cset = H5T_CSET_ASCII; - if(sn->entry[idx].type == H5G_CACHED_SLINK) { + lnk.corder = 0; + lnk.cset = H5T_CSET_ASCII; + if (sn->entry[idx].type == H5G_CACHED_SLINK) { lnk.type = H5L_TYPE_SOFT; - if(NULL == (lnk.u.soft.name = (char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].cache.slink.lval_offset))) + if (NULL == (lnk.u.soft.name = (char *)H5HL_offset_into(udata->common.heap, + sn->entry[idx].cache.slink.lval_offset))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get link name") } /* end if */ else { @@ -819,37 +791,39 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, } /* end else */ /* Replace any object names */ - if(H5G__link_name_replace(f, udata->grp_full_path_r, &lnk) < 0) + if (H5G__link_name_replace(f, udata->grp_full_path_r, &lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get object type") /* Decrement the ref. count for hard links */ - if(lnk.type == H5L_TYPE_HARD) { - H5O_loc_t tmp_oloc; /* Temporary object location */ + if (lnk.type == H5L_TYPE_HARD) { + H5O_loc_t tmp_oloc; /* Temporary object location */ /* Build temporary object location */ tmp_oloc.file = f; tmp_oloc.addr = lnk.u.hard.addr; - if(H5O_link(&tmp_oloc, -1) < 0) + if (H5O_link(&tmp_oloc, -1) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ else { /* Remove the soft link's value from the local heap */ - if(lnk.u.soft.name) { - size_t soft_link_len; /* Length of string in local heap */ + if (lnk.u.soft.name) { + size_t soft_link_len; /* Length of string in local heap */ soft_link_len = HDstrlen(lnk.u.soft.name) + 1; - if(H5HL_remove(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, soft_link_len) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap") + if (H5HL_remove(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, + soft_link_len) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, + "unable to remove soft link from local heap") } /* end if */ - } /* end else */ + } /* end else */ /* Remove the link's name from the local heap */ - if(H5HL_remove(f, udata->common.heap, sn->entry[idx].name_off, link_name_len) < 0) + if (H5HL_remove(f, udata->common.heap, sn->entry[idx].name_off, link_name_len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove link name from local heap") /* Remove the entry from the symbol table node */ - if(1 == sn->nsyms) { + if (1 == sn->nsyms) { /* * We are about to remove the only symbol in this node. Free this * node and indicate that the pointer to this node in the B-tree @@ -859,7 +833,8 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, sn->nsyms = 0; sn_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; ret_value = H5B_INS_REMOVE; - } else if(0 == idx) { + } + else if (0 == idx) { /* * We are about to remove the left-most entry from the symbol table * node but there are other entries to the right. No key values @@ -867,10 +842,10 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, - (sn->nsyms-idx) * sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } else if (idx + 1 == sn->nsyms) { + } + else if (idx + 1 == sn->nsyms) { /* * We are about to remove the right-most entry from the symbol table * node but there are other entries to the left. The right key @@ -878,39 +853,40 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - rt_key->offset = sn->entry[sn->nsyms - 1].name_off; + rt_key->offset = sn->entry[sn->nsyms - 1].name_off; *rt_key_changed = TRUE; - ret_value = H5B_INS_NOOP; - } else { + ret_value = H5B_INS_NOOP; + } + else { /* * We are about to remove an entry from the middle of a symbol table * node. */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, - (sn->nsyms - idx) * sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } /* end else */ - } /* end if */ + } /* end if */ /* Remove all entries from node, during B-tree deletion */ else { - H5O_loc_t tmp_oloc; /* Temporary object location */ + H5O_loc_t tmp_oloc; /* Temporary object location */ /* Build temporary object location */ tmp_oloc.file = f; /* Reduce the link count for all entries in this node */ - for(idx = 0; idx < sn->nsyms; idx++) { - if(!(H5G_CACHED_SLINK == sn->entry[idx].type)) { + for (idx = 0; idx < sn->nsyms; idx++) { + if (!(H5G_CACHED_SLINK == sn->entry[idx].type)) { /* Decrement the reference count */ HDassert(H5F_addr_defined(sn->entry[idx].header)); tmp_oloc.addr = sn->entry[idx].header; - if(H5O_link(&tmp_oloc, -1) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to decrement object link count") + if (H5O_link(&tmp_oloc, -1) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, + "unable to decrement object link count") } /* end if */ - } /* end for */ + } /* end for */ /* * We are about to remove all the symbols in this node. Free this @@ -923,13 +899,12 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, } /* end else */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release symbol table node") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_node_remove() */ +} /* end H5G__node_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__node_iterate * @@ -944,12 +919,12 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, */ int 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) + 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 */ - unsigned u; /* Local index variable */ + 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 */ + unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -962,52 +937,52 @@ H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata && udata->heap); /* Protect the symbol table node & local heap while we iterate over entries */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* * Iterate over the symbol table node entries. */ - for(u = 0, ents = sn->entry; u < sn->nsyms && ret_value == H5_ITER_CONT; u++) { - if(udata->skip > 0) + for (u = 0, ents = sn->entry; u < sn->nsyms && ret_value == H5_ITER_CONT; u++) { + if (udata->skip > 0) --udata->skip; else { - H5O_link_t lnk; /* Link for entry */ - const char *name; /* Pointer to link name in heap */ + H5O_link_t lnk; /* Link for entry */ + const char *name; /* Pointer to link name in heap */ /* Get the pointer to the name of the link in the heap */ - if((name = (const char *)H5HL_offset_into(udata->heap, ents[u].name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, ents[u].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get symbol table node name") /* Convert the entry to a link */ - if(H5G__ent_to_link(&lnk, udata->heap, &ents[u], name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") + if (H5G__ent_to_link(&lnk, udata->heap, &ents[u], name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, + "unable to convert symbol table entry to link") /* Make the callback */ ret_value = (udata->op)(&lnk, udata->op_data); /* Release memory for link object */ - if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) + if (H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5_ITER_ERROR, "unable to release link message") } /* end else */ /* Increment the number of entries passed through */ /* (whether we skipped them or not) */ - if(udata->final_ent) + if (udata->final_ent) (*udata->final_ent)++; } /* end for */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); done: /* Release resources */ - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__node_sumup * @@ -1023,11 +998,11 @@ H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, */ 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) + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - hsize_t *num_objs = (hsize_t *)_udata; - H5G_node_t *sn = NULL; - int ret_value = H5_ITER_CONT; + hsize_t * num_objs = (hsize_t *)_udata; + H5G_node_t *sn = NULL; + int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1039,19 +1014,18 @@ H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(num_objs); /* Find the object node and add the number of symbol entries. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") *num_objs += sn->nsyms; done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_sumup() */ - /*------------------------------------------------------------------------- * Function: H5G__node_by_idx * @@ -1068,10 +1042,10 @@ H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, */ int 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) + 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_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata; + H5G_node_t * sn = NULL; int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1084,19 +1058,19 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata); /* Get a pointer to the symbol table node */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node"); /* Find the node, locate the object symbol table entry and retrieve the name */ - if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { - hsize_t ent_idx; /* Entry index in this node */ + if (udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { + hsize_t ent_idx; /* Entry index in this node */ /* Compute index of entry */ ent_idx = udata->idx - udata->num_objs; /* Call 'by index' callback */ HDassert(udata->op); - if((udata->op)(&sn->entry[ent_idx], udata) < 0) + if ((udata->op)(&sn->entry[ent_idx], udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "'by index' callback failed") /* Indicate that we found the entry we are interested in */ @@ -1106,13 +1080,12 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, udata->num_objs += sn->nsyms; done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__node_init * @@ -1130,9 +1103,9 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, herr_t H5G__node_init(H5F_t *f) { - H5B_shared_t *shared; /* Shared B-tree node info */ - size_t sizeof_rkey; /* Size of raw (disk) key */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B_shared_t *shared; /* Shared B-tree node info */ + size_t sizeof_rkey; /* Size of raw (disk) key */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1140,24 +1113,23 @@ H5G__node_init(H5F_t *f) HDassert(f); /* Set the raw key size */ - sizeof_rkey = H5F_SIZEOF_SIZE(f); /*name offset */ + sizeof_rkey = H5F_SIZEOF_SIZE(f); /*name offset */ /* Allocate & initialize global info for the shared structure */ - if(NULL == (shared = H5B_shared_new(f, H5B_SNODE, sizeof_rkey))) + if (NULL == (shared = H5B_shared_new(f, H5B_SNODE, sizeof_rkey))) HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "memory allocation failed for shared B-tree info") /* Set up the "local" information for this file's groups */ /* */ /* Make shared B-tree info reference counted */ - if(H5F_SET_GRP_BTREE_SHARED(f, H5UC_create(shared, H5B_shared_free)) < 0) + if (H5F_SET_GRP_BTREE_SHARED(f, H5UC_create(shared, H5B_shared_free)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_init() */ - /*------------------------------------------------------------------------- * Function: H5G_node_close * @@ -1182,13 +1154,12 @@ H5G_node_close(const H5F_t *f) HDassert(f); /* Free the raw B-tree node buffer */ - if(H5F_GRP_BTREE_SHARED(f)) + if (H5F_GRP_BTREE_SHARED(f)) H5UC_DEC(H5F_GRP_BTREE_SHARED(f)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_node_close */ - /*------------------------------------------------------------------------- * Function: H5G__node_copy * @@ -1203,16 +1174,16 @@ H5G_node_close(const H5F_t *f) *------------------------------------------------------------------------- */ int -H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, - const void H5_ATTR_UNUSED *_rt_key, void *_udata) +H5G__node_copy(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_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; - unsigned int i; /* Local index variable */ - int ret_value = H5_ITER_CONT; + 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; + unsigned int i; /* Local index variable */ + int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1222,29 +1193,30 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, HDassert(udata); /* load the symbol table into memory from the source file */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* get the base address of the heap */ - if(NULL == (heap = H5HL_protect(f, udata->src_heap_addr, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name") + if (NULL == (heap = H5HL_protect(f, udata->src_heap_addr, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name") /* copy object in this node one by one */ - for(i = 0; i < sn->nsyms; i++) { - 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 */ - 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 */ + for (i = 0; i < sn->nsyms; i++) { + 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 */ + 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 */ /* expand soft link */ - if(H5G_CACHED_SLINK == src_ent->type && cpy_info->expand_soft_link) { - H5O_info_t oinfo; /* Information about 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 */ + if (H5G_CACHED_SLINK == src_ent->type && cpy_info->expand_soft_link) { + 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 */ /* 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)); @@ -1255,23 +1227,22 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Get pointer to link value in local heap */ - if((link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset)) == NULL) + if ((link_name = (char *)H5HL_offset_into(heap, tmp_src_ent.cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") /* Check if the object pointed by the soft link exists in the source file */ - /* Only basic information is needed */ - if(H5G_loc_info(&grp_loc, link_name, &oinfo, H5O_INFO_BASIC) >= 0) { - tmp_src_ent.header = oinfo.addr; - src_ent = &tmp_src_ent; + if (H5G__loc_addr(&grp_loc, link_name, &obj_addr) >= 0) { + tmp_src_ent.header = obj_addr; + src_ent = &tmp_src_ent; } /* end if */ else H5E_clear_stack(NULL); /* discard any errors from a dangling soft link */ - } /* if ((H5G_CACHED_SLINK == src_ent->type)... */ + } /* if ((H5G_CACHED_SLINK == src_ent->type)... */ /* Check if object in source group is a hard link */ - if(H5F_addr_defined(src_ent->header)) { - H5O_loc_t new_dst_oloc; /* Copied object location in destination */ - H5O_loc_t tmp_src_oloc; /* Temporary object location for source object */ + if (H5F_addr_defined(src_ent->header)) { + H5O_loc_t new_dst_oloc; /* Copied object location in destination */ + H5O_loc_t tmp_src_oloc; /* Temporary object location for source object */ /* Set up copied object location to fill in */ H5O_loc_reset(&new_dst_oloc); @@ -1283,43 +1254,44 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, tmp_src_oloc.addr = src_ent->header; /* Copy the shared object from source to destination */ - if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, &obj_type, (void **)&cpy_udata) < 0) + if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, &obj_type, + (void **)&cpy_udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy object") /* Set up object creation info for symbol table insertion. Only * case so far is for inserting old-style groups (for caching stab * info). */ - if(obj_type == H5O_TYPE_GROUP) { - gcrt_info.gcpl_id = H5P_DEFAULT; + if (obj_type == H5O_TYPE_GROUP) { + gcrt_info.gcpl_id = H5P_DEFAULT; gcrt_info.cache_type = cpy_udata->cache_type; - gcrt_info.cache = cpy_udata->cache; + gcrt_info.cache = cpy_udata->cache; } /* end if */ /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; + lnk.type = H5L_TYPE_HARD; lnk.u.hard.addr = new_dst_oloc.addr; } /* ( H5F_addr_defined(src_ent->header)) */ - else if(H5G_CACHED_SLINK == src_ent->type) { + else if (H5G_CACHED_SLINK == src_ent->type) { /* it is a soft link */ /* Set object type to unknown */ obj_type = H5O_TYPE_UNKNOWN; /* Construct link information for eventual insertion */ lnk.type = H5L_TYPE_SOFT; - if((lnk.u.soft.name = (char *)H5HL_offset_into(heap, src_ent->cache.slink.lval_offset)) == NULL) + if ((lnk.u.soft.name = (char *)H5HL_offset_into(heap, src_ent->cache.slink.lval_offset)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get link name") } /* else if */ else HDassert(0 && "Unknown entry type"); /* Set up common link data */ - lnk.cset = H5F_DEFAULT_CSET; /* XXX: Allow user to set this */ - lnk.corder = 0; /* Creation order is not tracked for old-style links */ + lnk.cset = H5F_DEFAULT_CSET; /* XXX: Allow user to set this */ + lnk.corder = 0; /* Creation order is not tracked for old-style links */ lnk.corder_valid = FALSE; /* Creation order is not valid */ - /* lnk.name = name; */ /* This will be set in callback */ + /* lnk.name = name; */ /* This will be set in callback */ /* Determine name of source object */ - if((name = (const char *)H5HL_offset_into(heap, src_ent->name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(heap, src_ent->name_off)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get source object name") /* Set copied metadata tag */ @@ -1327,8 +1299,8 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, /* Insert the new object in the destination file's group */ /* (Don't increment the link count - that's already done above for hard links) */ - if(H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, - obj_type, (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL)) < 0) + if (H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, obj_type, + (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL)) < 0) HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") /* Reset metadata tag */ @@ -1337,16 +1309,15 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, } /* end of for (i=0; insyms; i++) */ done: - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name") - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_copy() */ - /*------------------------------------------------------------------------- * Function: H5G__node_build_table * @@ -1361,11 +1332,11 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, */ int 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) + 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 */ - unsigned u; /* Local index variable */ + H5G_bt_it_bt_t *udata = (H5G_bt_it_bt_t *)_udata; + H5G_node_t * sn = NULL; /* Symbol table node */ + unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1381,46 +1352,47 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr * Save information about the symbol table node since we can't lock it * because we're about to call an application function. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* 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 */ - H5O_link_t *x; /* Pointer to larger array of links */ + 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 */ + H5O_link_t *x; /* Pointer to larger array of links */ /* Re-allocate the link table */ - if(NULL == (x = (H5O_link_t *)H5MM_realloc(udata->ltable->lnks, sizeof(H5O_link_t) * na))) + if (NULL == (x = (H5O_link_t *)H5MM_realloc(udata->ltable->lnks, sizeof(H5O_link_t) * na))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed") udata->ltable->lnks = x; } /* end if */ /* Iterate over the symbol table node entries, adding to link table */ - for(u = 0; u < sn->nsyms; u++) { - const char *name; /* Pointer to link name in heap */ - size_t linkno; /* Link allocated */ + for (u = 0; u < sn->nsyms; u++) { + const char *name; /* Pointer to link name in heap */ + size_t linkno; /* Link allocated */ /* Get pointer to link's name in the heap */ - if((name = (const char *)H5HL_offset_into(udata->heap, sn->entry[u].name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, sn->entry[u].name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get symbol table link name") /* Determine the link to operate on in the table */ linkno = udata->ltable->nlinks++; /* Convert the entry to a link */ - if(H5G__ent_to_link(&udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") + if (H5G__ent_to_link(&udata->ltable->lnks[linkno], udata->heap, &sn->entry[u], name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, + "unable to convert symbol table entry to link") } /* end for */ done: /* Release the locked items */ - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_build_table() */ - /*------------------------------------------------------------------------- * Function: H5G__node_iterate_size * @@ -1435,10 +1407,10 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr *------------------------------------------------------------------------- */ herr_t -H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, - haddr_t H5_ATTR_UNUSED addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) +H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t H5_ATTR_UNUSED addr, + const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - hsize_t *stab_size = (hsize_t *)_udata; /* User data */ + hsize_t *stab_size = (hsize_t *)_udata; /* User data */ FUNC_ENTER_PACKAGE_NOERR @@ -1451,7 +1423,6 @@ H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_iterate_size() */ - /*------------------------------------------------------------------------- * Function: H5G_node_debug * @@ -1466,13 +1437,12 @@ H5G__node_iterate_size(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, *------------------------------------------------------------------------- */ herr_t -H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth, - haddr_t heap_addr) +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; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_node_t *sn = NULL; + H5HL_t * heap = NULL; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1486,57 +1456,55 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth, HDassert(fwidth >= 0); /* Pin the heap down in memory */ - if(heap_addr > 0 && H5F_addr_defined(heap_addr)) - if(NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) + if (heap_addr > 0 && H5F_addr_defined(heap_addr)) + if (NULL == (heap = H5HL_protect(f, heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table heap") /* * If we couldn't load the symbol table node, then try loading the * B-tree node. */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) { - H5G_bt_common_t udata; /*data to pass through B-tree */ + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) { + H5G_bt_common_t udata; /*data to pass through B-tree */ H5E_clear_stack(NULL); /* discard that error */ udata.heap = heap; - if(H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) + if (H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to debug B-tree node"); } /* end if */ else { HDfprintf(stream, "%*sSymbol Table Node...\n", indent, ""); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty:", - sn->cache_info.is_dirty ? "Yes" : "No"); + "Dirty:", sn->cache_info.is_dirty ? "Yes" : "No"); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of Node (in bytes):", (unsigned)sn->node_size); - HDfprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, - "Number of Symbols:", - sn->nsyms, (unsigned)(2 * H5F_SYM_LEAF_K(f))); + "Size of Node (in bytes):", (unsigned)sn->node_size); + HDfprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, "Number of Symbols:", sn->nsyms, + (unsigned)(2 * H5F_SYM_LEAF_K(f))); indent += 3; fwidth = MAX(0, fwidth - 3); - for(u = 0; u < sn->nsyms; u++) { + for (u = 0; u < sn->nsyms; u++) { HDfprintf(stream, "%*sSymbol %u:\n", indent - 3, "", u); - if(heap) { + if (heap) { const char *s = (const char *)H5HL_offset_into(heap, sn->entry[u].name_off); - if(s) + if (s) HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", s); } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Warning: Invalid heap address given, name not displayed!"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, + "Warning: Invalid heap address given, name not displayed!"); H5G__ent_debug(sn->entry + u, stream, indent, fwidth, heap); } /* end for */ - } /* end if */ + } /* end if */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_debug() */ - diff --git a/src/H5Gobj.c b/src/H5Gobj.c index ec90527aa61..7ebd65a8021 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,28 +26,24 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -56,57 +52,49 @@ * link storage */ typedef struct { - 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 */ + 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; /* User data for link iterator when converting dense link storage to link * messages */ typedef struct { - H5O_link_t *lnk_table; /* Array of links to convert */ - size_t nlinks; /* Number of links converted */ - size_t alloc_links; /* Size of link table */ + H5O_link_t *lnk_table; /* Array of links to convert */ + size_t nlinks; /* Number of links converted */ + size_t alloc_links; /* Size of link table */ } H5G_obj_lnk_it_ud1_t; /* User data for symbol table iterator when converting old-format group to * a new-format group */ typedef struct { - const H5O_loc_t *grp_oloc; /* Pointer to group for insertion */ + const H5O_loc_t *grp_oloc; /* Pointer to group for insertion */ } H5G_obj_stab_it_ud1_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned idx, - void *_udata); +static herr_t H5G__obj_compact_to_dense_cb(const void *_mesg, unsigned idx, void *_udata); static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__obj_create * @@ -120,13 +108,13 @@ static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *l *------------------------------------------------------------------------- */ herr_t -H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) +H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/) { - H5P_genplist_t *gc_plist; /* Group creation property list */ - H5O_ginfo_t ginfo; /* Group info */ - H5O_linfo_t linfo; /* Link info */ - H5O_pline_t pline; /* Pipeline */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *gc_plist; /* Group creation property list */ + H5O_ginfo_t ginfo; /* Group info */ + H5O_linfo_t linfo; /* Link info */ + H5O_pline_t pline; /* Pipeline */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -137,30 +125,29 @@ H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) HDassert(oloc); /* Get the property list */ - if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(gcrt_info->gcpl_id))) + if (NULL == (gc_plist = (H5P_genplist_t *)H5I_object(gcrt_info->gcpl_id))) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a property list") /* Get the group info property */ - if(H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(gc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Get the link info property */ - if(H5P_get(gc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(gc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Get the pipeline property */ - if(H5P_peek(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Call the "real" group creation routine now */ - if(H5G__obj_create_real(f, &ginfo, &linfo, &pline, gcrt_info, oloc) < 0) + if (H5G__obj_create_real(f, &ginfo, &linfo, &pline, gcrt_info, oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "unable to create group") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_create() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_create_real * @@ -174,14 +161,13 @@ H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) *------------------------------------------------------------------------- */ herr_t -H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, const H5O_pline_t *pline, - H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc/*out*/) +H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linfo, const H5O_pline_t *pline, + H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/) { - size_t hdr_size; /* Size of object header to request */ - hbool_t use_at_least_v18; /* Flag indicating the new group format should be used */ - hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t hdr_size; /* Size of object header to request */ + hbool_t use_at_least_v18; /* Flag indicating the new group format should be used */ + hid_t gcpl_id = gcrt_info->gcpl_id; /* Group creation property list ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -195,12 +181,12 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, HDassert(oloc); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") /* Check for using the latest version of the group format which is introduced in v18 */ /* (add more checks for creating "new format" groups when needed) */ - if((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) + if ((H5F_LOW_BOUND(f) >= H5F_LIBVER_V18) || linfo->track_corder || (pline && pline->nused)) use_at_least_v18 = TRUE; else use_at_least_v18 = FALSE; @@ -208,17 +194,17 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, /* Make certain that the creation order is being tracked if an index is * going to be built on it. */ - if(linfo->index_corder && !linfo->track_corder) + if (linfo->index_corder && !linfo->track_corder) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "must track creation order to create index for it") /* Check if we should be using the latest version of the group format */ - if(use_at_least_v18) { - H5O_link_t lnk; /* Temporary link message info for computing message size */ - char null_char = '\0'; /* Character for creating null string */ - size_t ginfo_size; /* Size of the group info message */ - size_t linfo_size; /* Size of the link info message */ - size_t pline_size = 0; /* Size of the pipeline message */ - size_t link_size; /* Size of a link message */ + if (use_at_least_v18) { + H5O_link_t lnk; /* Temporary link message info for computing message size */ + char null_char = '\0'; /* Character for creating null string */ + size_t ginfo_size; /* Size of the group info message */ + size_t linfo_size; /* Size of the link info message */ + size_t pline_size = 0; /* Size of the pipeline message */ + size_t link_size; /* Size of a link message */ /* Calculate message size information, for creating group's object header */ linfo_size = H5O_msg_size_f(f, gcpl_id, H5O_LINFO_ID, linfo, (size_t)0); @@ -227,24 +213,21 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, ginfo_size = H5O_msg_size_f(f, gcpl_id, H5O_GINFO_ID, ginfo, (size_t)0); HDassert(ginfo_size); - if(pline && pline->nused) { + if (pline && pline->nused) { pline_size = H5O_msg_size_f(f, gcpl_id, H5O_PLINE_ID, pline, (size_t)0); HDassert(pline_size); } /* end if */ - lnk.type = H5L_TYPE_HARD; - lnk.corder = 0; + lnk.type = H5L_TYPE_HARD; + lnk.corder = 0; lnk.corder_valid = linfo->track_corder; - lnk.cset = H5T_CSET_ASCII; - lnk.name = &null_char; - link_size = H5O_msg_size_f(f, gcpl_id, H5O_LINK_ID, &lnk, (size_t)ginfo->est_name_len); + lnk.cset = H5T_CSET_ASCII; + lnk.name = &null_char; + link_size = H5O_msg_size_f(f, gcpl_id, H5O_LINK_ID, &lnk, (size_t)ginfo->est_name_len); HDassert(link_size); /* Compute size of header to use for creation */ - hdr_size = linfo_size + - ginfo_size + - pline_size + - (ginfo->est_num_entries * link_size); + hdr_size = linfo_size + ginfo_size + pline_size + (ginfo->est_num_entries * link_size); } /* end if */ else hdr_size = (size_t)(4 + 2 * H5F_SIZEOF_ADDR(f)); @@ -254,45 +237,44 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, * since nothing refers to it yet. The link count will be * incremented if the object is added to the group directed graph. */ - if(H5O_create(f, hdr_size, (size_t)1, gcpl_id, oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") + if (H5O_create(f, hdr_size, (size_t)1, gcpl_id, oloc /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header") /* Check for format of group to create */ - if(use_at_least_v18) { + if (use_at_least_v18) { /* Insert link info message */ /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo) < 0) + if (H5O_msg_create(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, (void *)linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)ginfo) < 0) + if (H5O_msg_create(oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert pipeline message */ - if(pline && pline->nused) + if (pline && pline->nused) /* (Casting away const OK - QAK) */ - if(H5O_msg_create(oloc, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)pline) < 0) + if (H5O_msg_create(oloc, H5O_PLINE_ID, H5O_MSG_FLAG_CONSTANT, 0, (void *)pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ else { - H5O_stab_t stab; /* Symbol table message */ + H5O_stab_t stab; /* Symbol table message */ /* The group doesn't currently have a 'stab' message, go create one */ - if(H5G__stab_create(oloc, ginfo, &stab) < 0) + if (H5G__stab_create(oloc, ginfo, &stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create symbol table") /* Cache the symbol table information */ - gcrt_info->cache_type = H5G_CACHED_STAB; + gcrt_info->cache_type = H5G_CACHED_STAB; gcrt_info->cache.stab.btree_addr = stab.btree_addr; - gcrt_info->cache.stab.heap_addr = stab.heap_addr; + gcrt_info->cache.stab.heap_addr = stab.heap_addr; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_create_real() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_get_linfo * @@ -310,8 +292,8 @@ H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value = FAIL; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -320,45 +302,44 @@ H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) HDassert(linfo); /* Check for the group having a link info message */ - if((ret_value = H5O_msg_exists(grp_oloc, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(ret_value) { + if ((ret_value = H5O_msg_exists(grp_oloc, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") + if (ret_value) { /* Retrieve the "link info" structure */ - if(NULL == H5O_msg_read(grp_oloc, H5O_LINFO_ID, linfo)) + if (NULL == H5O_msg_read(grp_oloc, H5O_LINFO_ID, linfo)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "link info message not present") /* Check if we don't know how many links there are */ - if(linfo->nlinks == HSIZET_MAX) { + if (linfo->nlinks == HSIZET_MAX) { /* Check if we are using "dense" link storage */ - if(H5F_addr_defined(linfo->fheap_addr)) { + if (H5F_addr_defined(linfo->fheap_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp_oloc->file, linfo->name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(grp_oloc->file, linfo->name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in "name" B-tree */ /* (should be same # of records in all indices) */ - if(H5B2_get_nrec(bt2_name, &linfo->nlinks) < 0) + if (H5B2_get_nrec(bt2_name, &linfo->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve # of records in index") } /* end if */ else { /* Retrieve # of links from object header */ - if(H5O_get_nlinks(grp_oloc, &linfo->nlinks) < 0) + if (H5O_get_nlinks(grp_oloc, &linfo->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve # of links for object") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_get_linfo() */ - /*------------------------------------------------------------------------- - * Function: H5G_obj_compact_to_dense_cb + * Function: H5G__obj_compact_to_dense_cb * * Purpose: Callback routine for converting "compact" to "dense" * link storage form. @@ -371,29 +352,28 @@ 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) +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 */ - 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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT_TAG(udata->oh_addr) + FUNC_ENTER_STATIC /* check arguments */ HDassert(lnk); HDassert(udata); /* Insert link into dense link storage */ - if(H5G__dense_insert(udata->f, udata->linfo, lnk) < 0) + if (H5G__dense_insert(udata->f, udata->linfo, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into dense storage") done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5G_obj_compact_to_dense_cb() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__obj_compact_to_dense_cb() */ - /*------------------------------------------------------------------------- - * Function: H5G_obj_stab_to_new_cb + * Function: H5G__obj_stab_to_new_cb * * Purpose: Callback routine for converting "symbol table" link storage to * "new format" storage (either "compact" or "dense" storage). @@ -406,12 +386,12 @@ H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *------------------------------------------------------------------------- */ static herr_t -H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) +H5G__obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) { - H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check arguments */ HDassert(lnk); @@ -419,14 +399,13 @@ H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) /* Insert link into group */ /* (Casting away const OK - QAK) */ - if(H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, H5O_TYPE_UNKNOWN, NULL) < 0) + if (H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, H5O_TYPE_UNKNOWN, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert link into group") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_stab_to_new_cb() */ +} /* end H5G__obj_stab_to_new_cb() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_insert * @@ -444,16 +423,16 @@ H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) *------------------------------------------------------------------------- */ herr_t -H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, - hbool_t adj_link, H5O_type_t obj_type, const void *crt_info) +H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, hbool_t adj_link, + H5O_type_t obj_type, const void *crt_info) { - H5O_pline_t tmp_pline; /* Pipeline message */ - H5O_pline_t *pline = NULL; /* Pointer to pipeline message */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for insertions or not */ - hbool_t use_new_dense = FALSE; /* Whether to use "dense" form of 'new format' group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t tmp_pline; /* Pipeline message */ + H5O_pline_t *pline = NULL; /* Pointer to pipeline message */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for insertions or not */ + hbool_t use_new_dense = FALSE; /* Whether to use "dense" form of 'new format' group */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) @@ -464,19 +443,19 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, /* Check if we have information about the number of objects in this group */ /* (by attempting to get the link info message for this group) */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ - size_t link_msg_size; /* Size of new link message in the file */ + if (linfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ + size_t link_msg_size; /* Size of new link message in the file */ /* Using the new format for groups */ use_old_format = FALSE; /* Check for tracking creation order on this group's links */ - if(linfo.track_corder) { + if (linfo.track_corder) { /* Set the creation order for the new link & indicate that it's valid */ - obj_lnk->corder = linfo.max_corder; + obj_lnk->corder = linfo.max_corder; obj_lnk->corder_valid = TRUE; /* Increment the max. creation order used in the group */ @@ -484,90 +463,92 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, } /* end if */ /* Get the link's message size */ - if((link_msg_size = H5O_msg_raw_size(grp_oloc->file, H5O_LINK_ID, FALSE, obj_lnk)) == 0) + if ((link_msg_size = H5O_msg_raw_size(grp_oloc->file, H5O_LINK_ID, FALSE, obj_lnk)) == 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't get link size") /* Get the group info */ - if(NULL == H5O_msg_read(grp_oloc, H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(grp_oloc, H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") /* If there's still a small enough number of links, use the 'link' message */ /* (If the encoded form of the link is too large to fit into an object * header message, convert to using dense link storage instead of link messages) */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) use_new_dense = TRUE; - else if(linfo.nlinks < ginfo.max_compact && link_msg_size < H5O_MESG_MAX_SIZE) + else if (linfo.nlinks < ginfo.max_compact && link_msg_size < H5O_MESG_MAX_SIZE) use_new_dense = FALSE; else { - htri_t pline_exists; /* Whether the pipeline message exists */ - H5G_obj_oh_it_ud1_t udata; /* User data for iteration */ - H5O_mesg_operator_t op; /* Message operator */ + htri_t pline_exists; /* Whether the pipeline message exists */ + H5G_obj_oh_it_ud1_t udata; /* User data for iteration */ + H5O_mesg_operator_t op; /* Message operator */ /* Get the pipeline message, if it exists */ - if((pline_exists = H5O_msg_exists(grp_oloc, H5O_PLINE_ID)) < 0) + if ((pline_exists = H5O_msg_exists(grp_oloc, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(pline_exists) { - if(NULL == H5O_msg_read(grp_oloc, H5O_PLINE_ID, &tmp_pline)) + if (pline_exists) { + if (NULL == H5O_msg_read(grp_oloc, H5O_PLINE_ID, &tmp_pline)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") pline = &tmp_pline; } /* end if */ /* The group doesn't currently have "dense" storage for links */ - if(H5G__dense_create(grp_oloc->file, &linfo, pline) < 0) + if (H5G__dense_create(grp_oloc->file, &linfo, pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create 'dense' form of new format group") /* Set up user data for object header message iteration */ - udata.f = grp_oloc->file; + udata.f = grp_oloc->file; udata.oh_addr = grp_oloc->addr; - udata.linfo = &linfo; + udata.linfo = &linfo; /* Iterate over the 'link' messages, inserting them into the dense link storage */ - op.op_type = H5O_MESG_OP_APP; - op.u.app_op = H5G_obj_compact_to_dense_cb; - if(H5O_msg_iterate(grp_oloc, H5O_LINK_ID, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_APP; + op.u.app_op = H5G__obj_compact_to_dense_cb; + if (H5O_msg_iterate(grp_oloc, H5O_LINK_ID, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") /* Remove all the 'link' messages */ - if(H5O_msg_remove(grp_oloc, H5O_LINK_ID, H5O_ALL, FALSE) < 0) + if (H5O_msg_remove(grp_oloc, H5O_LINK_ID, H5O_ALL, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link messages") use_new_dense = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else { /* Check for new-style link information */ - if(obj_lnk->cset != H5T_CSET_ASCII || obj_lnk->type > H5L_TYPE_BUILTIN_MAX) { - H5O_linfo_t new_linfo = H5G_CRT_LINK_INFO_DEF; /* Link information */ - H5O_ginfo_t new_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Group information */ - H5G_obj_stab_it_ud1_t udata; /* User data for iteration */ + if (obj_lnk->cset != H5T_CSET_ASCII || obj_lnk->type > H5L_TYPE_BUILTIN_MAX) { + H5O_linfo_t new_linfo = H5G_CRT_LINK_INFO_DEF; /* Link information */ + H5O_ginfo_t new_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Group information */ + H5G_obj_stab_it_ud1_t udata; /* User data for iteration */ /* Convert group to "new format" group, in order to hold the information */ /* Insert link info message */ - if(H5O_msg_create(grp_oloc, H5O_LINFO_ID, 0, 0, &new_linfo) < 0) + if (H5O_msg_create(grp_oloc, H5O_LINFO_ID, 0, 0, &new_linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Insert group info message */ - if(H5O_msg_create(grp_oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, &new_ginfo) < 0) + if (H5O_msg_create(grp_oloc, H5O_GINFO_ID, H5O_MSG_FLAG_CONSTANT, H5O_UPDATE_TIME, &new_ginfo) < + 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") /* Set up user data for iteration */ udata.grp_oloc = grp_oloc; /* Iterate through all links in "old format" group and insert them into new format */ - if(H5G__stab_iterate(grp_oloc, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G_obj_stab_to_new_cb, &udata) < 0) + if (H5G__stab_iterate(grp_oloc, H5_ITER_NATIVE, (hsize_t)0, NULL, H5G__obj_stab_to_new_cb, + &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over old format links") /* Remove the symbol table message from the group */ - if(H5O_msg_remove(grp_oloc, H5O_STAB_ID, 0, FALSE) < 0) + if (H5O_msg_remove(grp_oloc, H5O_STAB_ID, 0, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete old format link storage") /* Recursively call this routine to insert the new link, since the * group is in the "new format" now and the link info should be * set up, etc. */ - if(H5G_obj_insert(grp_oloc, name, obj_lnk, adj_link, obj_type, crt_info) < 0) + if (H5G_obj_insert(grp_oloc, name, obj_lnk, adj_link, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into group") /* Done with insertion now */ @@ -578,34 +559,34 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, } /* end if */ /* Insert into symbol table or "dense" storage */ - if(use_old_format) { + if (use_old_format) { /* Insert into symbol table */ - if(H5G__stab_insert(grp_oloc, name, obj_lnk, obj_type, crt_info) < 0) + if (H5G__stab_insert(grp_oloc, name, obj_lnk, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry into symbol table") } /* end if */ else { - if(use_new_dense) { + if (use_new_dense) { /* Insert into dense link storage */ - if(H5G__dense_insert(grp_oloc->file, &linfo, obj_lnk) < 0) + if (H5G__dense_insert(grp_oloc->file, &linfo, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into dense storage") } /* end if */ else { /* Insert with link message */ - if(H5G__compact_insert(grp_oloc, obj_lnk) < 0) + if (H5G__compact_insert(grp_oloc, obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link as link message") } /* end else */ - } /* end else */ + } /* end else */ /* Increment the number of objects in this group */ - if(!use_old_format) { + if (!use_old_format) { linfo.nlinks++; - if(H5O_msg_write(grp_oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, &linfo) < 0) + if (H5O_msg_write(grp_oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, &linfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") } /* end if */ /* Increment link count on object, if requested and it's a hard link */ - if(adj_link && obj_lnk->type == H5L_TYPE_HARD) { - H5O_loc_t obj_oloc; /* Object location */ + if (adj_link && obj_lnk->type == H5L_TYPE_HARD) { + H5O_loc_t obj_oloc; /* Object location */ H5O_loc_reset(&obj_oloc); /* Create temporary object location */ @@ -613,19 +594,18 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, obj_oloc.addr = obj_lnk->u.hard.addr; /* Increment reference count for object */ - if(H5O_link(&obj_oloc, 1) < 0) + if (H5O_link(&obj_oloc, 1) < 0) HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "unable to increment hard link count") } /* end if */ done: /* Free any space used by the pipeline message */ - if(pline && H5O_msg_reset(H5O_PLINE_ID, pline) < 0) + if (pline && H5O_msg_reset(H5O_PLINE_ID, pline) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "can't release pipeline") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_iterate * @@ -642,13 +622,12 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, *------------------------------------------------------------------------- */ herr_t -H5G__obj_iterate(const H5O_loc_t *grp_oloc, 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) +H5G__obj_iterate(const H5O_loc_t *grp_oloc, 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) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = FAIL; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -657,38 +636,40 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, HDassert(op); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for going out of bounds */ - if(skip > 0 && (size_t)skip >= linfo.nlinks) + if (skip > 0 && (size_t)skip >= linfo.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Iterate over the links in the group, building a table of the link messages */ - if((ret_value = H5G__dense_iterate(grp_oloc->file, &linfo, idx_type, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__dense_iterate(grp_oloc->file, &linfo, idx_type, order, skip, last_lnk, op, + op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over dense links") } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G__compact_iterate(grp_oloc, &linfo, idx_type, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__compact_iterate(grp_oloc, &linfo, idx_type, order, skip, last_lnk, op, + op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over compact links") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Iterate over symbol table */ - if((ret_value = H5G__stab_iterate(grp_oloc, order, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__stab_iterate(grp_oloc, order, skip, last_lnk, op, op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over symbol table") } /* end else */ @@ -696,7 +677,6 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_info * @@ -712,13 +692,13 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) { - 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 */ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -732,49 +712,48 @@ H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) H5G_loc_reset(&grp_loc); /* Deep copy (duplicate) of the group location object */ - if(H5O_loc_copy_deep(&grp_oloc, (H5O_loc_t *)oloc) < 0) + if (H5O_loc_copy_deep(&grp_oloc, oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy object location") /* Open the group */ - if(NULL == (grp = H5G_open(&grp_loc))) + if (NULL == (grp = H5G_open(&grp_loc))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") /* Get information from the group */ grp_info->mounted = H5G_MOUNTED(grp); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Retrieve the information about the links */ - grp_info->nlinks = linfo.nlinks; + grp_info->nlinks = linfo.nlinks; grp_info->max_corder = linfo.max_corder; /* Check if the group is using compact or dense storage for its links */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) grp_info->storage_type = H5G_STORAGE_TYPE_DENSE; else grp_info->storage_type = H5G_STORAGE_TYPE_COMPACT; } /* end if */ else { /* Get the number of objects in this group by iterating over symbol table */ - if(H5G__stab_count(oloc, &grp_info->nlinks) < 0) + if (H5G__stab_count(oloc, &grp_info->nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't count objects") /* Set the other information about the group */ grp_info->storage_type = H5G_STORAGE_TYPE_SYMBOL_TABLE; - grp_info->max_corder = 0; + grp_info->max_corder = 0; } /* end else */ done: /* Clean up resources */ - if(grp && H5G_close(grp) < 0) + if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "unable to close queried group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_info() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_get_name_by_idx * @@ -789,12 +768,12 @@ H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) *------------------------------------------------------------------------- */ ssize_t -H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char* name, size_t size) +H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + char *name, size_t size) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - ssize_t ret_value = -1; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(oloc->addr, FAIL) @@ -802,35 +781,36 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, HDassert(oloc && oloc->file); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the object's name from the dense link storage */ - if((ret_value = H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, size)) < 0) + if ((ret_value = H5G__dense_get_name_by_idx(oloc->file, &linfo, idx_type, order, n, name, size)) < + 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, size)) < 0) + if ((ret_value = H5G__compact_get_name_by_idx(oloc, &linfo, idx_type, order, n, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's name from the symbol table */ - if((ret_value = H5G__stab_get_name_by_idx(oloc, order, n, name, size)) < 0) + if ((ret_value = H5G__stab_get_name_by_idx(oloc, order, n, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ @@ -838,7 +818,6 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_get_name_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_remove_update_linfo * @@ -855,7 +834,7 @@ H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, static herr_t H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -867,87 +846,89 @@ H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) linfo->nlinks--; /* Reset the creation order min/max if there's no more links in group */ - if(linfo->nlinks == 0) + if (linfo->nlinks == 0) linfo->max_corder = 0; /* Check for transitioning out of dense storage, if we are using it */ - if(H5F_addr_defined(linfo->fheap_addr)) { + if (H5F_addr_defined(linfo->fheap_addr)) { /* Check if there's no more links */ - if(linfo->nlinks == 0) { + if (linfo->nlinks == 0) { /* Delete the dense storage */ - if(H5G__dense_delete(oloc->file, linfo, FALSE) < 0) + if (H5G__dense_delete(oloc->file, linfo, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete dense link storage") } /* end if */ /* Check for switching back to compact storage */ else { - H5O_ginfo_t ginfo; /* Group info message */ + H5O_ginfo_t ginfo; /* Group info message */ /* Get the group info */ - if(NULL == H5O_msg_read(oloc, H5O_GINFO_ID, &ginfo)) + if (NULL == H5O_msg_read(oloc, H5O_GINFO_ID, &ginfo)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") /* 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 */ - 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 */ + if (linfo->nlinks < ginfo.min_dense) { + 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 */ /* Build the table of links for this group */ - if(H5G__dense_build_table(oloc->file, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) + if (H5G__dense_build_table(oloc->file, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Pin the object header */ - if(NULL == (oh = H5O_pin(oloc))) + if (NULL == (oh = H5O_pin(oloc))) HGOTO_ERROR(H5E_SYM, H5E_CANTPIN, FAIL, "unable to pin group object header") /* Inspect links in table for ones that can't be converted back * into link message form (currently only links which can't fit * into an object header message) */ - for(u = 0; u < linfo->nlinks; u++) - if(H5O_msg_size_oh(oloc->file, oh, H5O_LINK_ID, &(ltable.lnks[u]), (size_t)0) >= H5O_MESG_MAX_SIZE) { + for (u = 0; u < linfo->nlinks; u++) + if (H5O_msg_size_oh(oloc->file, oh, H5O_LINK_ID, &(ltable.lnks[u]), (size_t)0) >= + H5O_MESG_MAX_SIZE) { can_convert = FALSE; break; } /* end if */ /* If ok, insert links as link messages */ - if(can_convert) { + if (can_convert) { /* Insert link messages into group */ - for(u = 0; u < linfo->nlinks; u++) - if(H5O_msg_append_oh(oloc->file, oh, H5O_LINK_ID, 0, H5O_UPDATE_TIME, &(ltable.lnks[u])) < 0) { + for (u = 0; u < linfo->nlinks; u++) + if (H5O_msg_append_oh(oloc->file, oh, H5O_LINK_ID, 0, H5O_UPDATE_TIME, + &(ltable.lnks[u])) < 0) { /* Release object header */ - if(H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, "unable to unpin group object header") + if (H5O_unpin(oh) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, + "unable to unpin group object header") HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ /* Remove the dense storage */ - if(H5G__dense_delete(oloc->file, linfo, FALSE) < 0) + if (H5G__dense_delete(oloc->file, linfo, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete dense link storage") } /* end if */ /* Release object header */ - if(H5O_unpin(oh) < 0) + if (H5O_unpin(oh) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, "unable to unpin group object header") /* Free link table information */ - if(H5G__link_release_table(<able) < 0) + if (H5G__link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Update link info in the object header */ - if(H5O_msg_write(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, linfo) < 0) + if (H5O_msg_write(oloc, H5O_LINFO_ID, 0, H5O_UPDATE_TIME, linfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update link info message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_remove_update_linfo() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_remove * @@ -964,10 +945,10 @@ H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) herr_t H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(oloc->addr, FAIL) @@ -976,42 +957,41 @@ H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *n HDassert(name && *name); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Using the new format for groups */ use_old_format = FALSE; /* Check for dense or compact storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Remove object from the dense link storage */ - if(H5G__dense_remove(oloc->file, &linfo, grp_full_path_r, name) < 0) + if (H5G__dense_remove(oloc->file, &linfo, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ 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") + if (H5G__compact_remove(oloc, grp_full_path_r, name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Using the old format for groups */ use_old_format = TRUE; /* Remove object from the symbol table */ - if(H5G__stab_remove(oloc, grp_full_path_r, name) < 0) + if (H5G__stab_remove(oloc, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ /* Update link info for a new-style group */ - if(!use_old_format) - if(H5G__obj_remove_update_linfo(oloc, &linfo) < 0) + if (!use_old_format) + if (H5G__obj_remove_update_linfo(oloc, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_remove() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_remove_by_idx * @@ -1026,27 +1006,27 @@ H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *n *------------------------------------------------------------------------- */ herr_t -H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n) +H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(grp_oloc && grp_oloc->file); /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ @@ -1054,40 +1034,39 @@ H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, use_old_format = FALSE; /* Check for dense or compact storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Remove object from the dense link storage */ - if(H5G__dense_remove_by_idx(grp_oloc->file, &linfo, grp_full_path_r, idx_type, order, n) < 0) + if (H5G__dense_remove_by_idx(grp_oloc->file, &linfo, grp_full_path_r, idx_type, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Remove object from compact link storage */ - if(H5G__compact_remove_by_idx(grp_oloc, &linfo, grp_full_path_r, idx_type, order, n) < 0) + if (H5G__compact_remove_by_idx(grp_oloc, &linfo, grp_full_path_r, idx_type, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Using the old format for groups */ use_old_format = TRUE; /* Remove object from the symbol table */ - if(H5G__stab_remove_by_idx(grp_oloc, grp_full_path_r, order, n) < 0) + if (H5G__stab_remove_by_idx(grp_oloc, grp_full_path_r, order, n) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ /* Update link info for a new-style group */ - if(!use_old_format) - if(H5G__obj_remove_update_linfo(grp_oloc, &linfo) < 0) + if (!use_old_format) + if (H5G__obj_remove_update_linfo(grp_oloc, &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_obj_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__obj_lookup * @@ -1103,9 +1082,9 @@ H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - htri_t ret_value = FALSE; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -1114,31 +1093,30 @@ H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) HDassert(name && *name); /* Attempt to get the link info message for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the object's info from the dense link storage */ - if((ret_value = H5G__dense_lookup(grp_oloc->file, &linfo, name, lnk)) < 0) + if ((ret_value = H5G__dense_lookup(grp_oloc->file, &linfo, name, lnk)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end if */ else { /* Get the object's info from the link messages */ - if((ret_value = H5G__compact_lookup(grp_oloc, name, lnk)) < 0) + if ((ret_value = H5G__compact_lookup(grp_oloc, name, lnk)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ - } /* end if */ + } /* end if */ 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") + if ((ret_value = H5G__stab_lookup(grp_oloc, name, lnk)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_lookup() */ - /*------------------------------------------------------------------------- * Function: H5G_obj_lookup_by_idx * @@ -1153,12 +1131,12 @@ H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) *------------------------------------------------------------------------- */ herr_t -H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) +H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5O_link_t *lnk) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(grp_oloc->addr, FAIL) @@ -1166,39 +1144,38 @@ H5G_obj_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_index_t idx_type, HDassert(grp_oloc && grp_oloc->file); /* Attempt to get the link info message for this group */ - if((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) + if ((linfo_exists = H5G__obj_get_linfo(grp_oloc, &linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check for link info message") - if(linfo_exists) { + if (linfo_exists) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5_INDEX_CRT_ORDER) { + if (idx_type == H5_INDEX_CRT_ORDER) { /* Check if creation order is tracked */ - if(!linfo.track_corder) + if (!linfo.track_corder) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "creation order not tracked for links in group") } /* end if */ /* Check for dense link storage */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Get the link from the dense storage */ - if(H5G__dense_lookup_by_idx(grp_oloc->file, &linfo, idx_type, order, n, lnk) < 0) + if (H5G__dense_lookup_by_idx(grp_oloc->file, &linfo, idx_type, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end if */ else { /* Get the link from the link messages */ - if(H5G__compact_lookup_by_idx(grp_oloc, &linfo, idx_type, order, n, lnk) < 0) + if (H5G__compact_lookup_by_idx(grp_oloc, &linfo, idx_type, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ - } /* end if */ + } /* end if */ else { /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5_INDEX_NAME) + if (idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's info from the symbol table */ - if(H5G__stab_lookup_by_idx(grp_oloc, order, n, lnk) < 0) + if (H5G__stab_lookup_by_idx(grp_oloc, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_lookup_by_idx() */ - diff --git a/src/H5Goh.c b/src/H5Goh.c index 38570f9f63f..f6ac79179e9 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,76 +15,68 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -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 hid_t H5O__group_open(const H5G_loc_t *obj_loc, hbool_t app_ref); -static void *H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +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 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); - +static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_GROUP[1] = {{ - H5O_TYPE_GROUP, /* object type */ - "group", /* object name, for debugging */ - H5O__group_get_copy_file_udata, /* get 'copy file' user data */ + H5O_TYPE_GROUP, /* object type */ + "group", /* object name, for debugging */ + H5O__group_get_copy_file_udata, /* get 'copy file' user data */ H5O__group_free_copy_file_udata, /* free 'copy file' user data */ - H5O__group_isa, /* "isa" message */ - H5O__group_open, /* open an object of this class */ - H5O__group_create, /* create an object of this class */ - H5O__group_get_oloc, /* get an object header location for an object */ - H5O__group_bh_info, /* get the index & heap info for an object */ - NULL /* flush an opened object of this class */ + H5O__group_isa, /* "isa" message */ + H5O__group_open, /* open an object of this class */ + H5O__group_create, /* create an object of this class */ + H5O__group_get_oloc, /* get an object header location for an object */ + H5O__group_bh_info, /* get the index & heap info for an object */ + NULL /* flush an opened object of this class */ }}; /* Declare the external free list to manage the H5O_ginfo_t struct */ H5FL_DEFINE(H5G_copy_file_ud_t); - /*------------------------------------------------------------------------- * Function: H5O__group_get_copy_file_udata * @@ -103,21 +95,20 @@ H5FL_DEFINE(H5G_copy_file_ud_t); static void * H5O__group_get_copy_file_udata(void) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for the 'copy file' user data for copying groups. * Currently this is only a ginfo, so there is no specific struct type for * this operation. */ - if(NULL == (ret_value = H5FL_CALLOC(H5G_copy_file_ud_t))) + if (NULL == (ret_value = H5FL_CALLOC(H5G_copy_file_ud_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_get_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__group_free_copy_file_udata * @@ -150,7 +141,6 @@ H5O__group_free_copy_file_udata(void *_udata) FUNC_LEAVE_NOAPI_VOID } /* end H5O__group_free_copy_file_udata() */ - /*------------------------------------------------------------------------- * Function: H5O__group_isa * @@ -171,19 +161,19 @@ H5O__group_free_copy_file_udata(void *_udata) static htri_t H5O__group_isa(const H5O_t *oh) { - htri_t stab_exists; /* Whether the 'stab' message is in the object header */ - htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ - htri_t ret_value = FAIL; /* Return value */ + htri_t stab_exists; /* Whether the 'stab' message is in the object header */ + htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); /* Check for any of the messages that indicate a group */ - if((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") - if((linfo_exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if ((stab_exists = H5O_msg_exists_oh(oh, H5O_STAB_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if ((linfo_exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") ret_value = (stab_exists > 0 || linfo_exists > 0); @@ -191,47 +181,45 @@ H5O__group_isa(const H5O_t *oh) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_isa() */ - /*------------------------------------------------------------------------- - * Function: H5O__group_open + * Function: H5O__group_open * - * Purpose: Open a group at a particular location + * Purpose: Open a group at a particular location * - * Return: Success: Open object identifier - * Failure: Negative + * Return: Success: Pointer to group data + * Failure: NULL * * Programmer: Quincey Koziol * Monday, November 6, 2006 * *------------------------------------------------------------------------- */ -static hid_t -H5O__group_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5G_t *grp = NULL; /* Group opened */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5G_t *grp = NULL; /* Group opened */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_GROUP; + /* Open the group */ - if(NULL == (grp = H5G_open(obj_loc))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + if (NULL == (grp = H5G_open(obj_loc))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") - /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + ret_value = (void *)grp; done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + if (NULL == ret_value) + if (grp && H5G_close(grp) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_open() */ - /*------------------------------------------------------------------------- * Function: H5O__group_create * @@ -248,9 +236,9 @@ H5O__group_open(const H5G_loc_t *obj_loc, hbool_t app_ref) 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_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 */ FUNC_ENTER_STATIC @@ -260,27 +248,26 @@ H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Create the the group */ - if(NULL == (grp = H5G__create(f, crt_info))) + if (NULL == (grp = H5G__create(f, crt_info))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") /* Set up the new group's location */ - if(NULL == (obj_loc->oloc = H5G_oloc(grp))) + if (NULL == (obj_loc->oloc = H5G_oloc(grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of group") - if(NULL == (obj_loc->path = H5G_nameof(grp))) + if (NULL == (obj_loc->path = H5G_nameof(grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of group") /* Set the return value */ ret_value = grp; done: - if(ret_value == NULL) - if(grp && H5G_close(grp) < 0) + if (ret_value == NULL) + if (grp && H5G_close(grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_create() */ - /*------------------------------------------------------------------------- * Function: H5O__group_get_oloc * @@ -297,24 +284,23 @@ 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 */ - H5O_loc_t *ret_value = NULL; /* Return value */ + H5G_t * grp; /* Group opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the group */ - if(NULL == (grp = (H5G_t *)H5I_object(obj_id))) + if (NULL == (grp = (H5G_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the group's object header location */ - if(NULL == (ret_value = H5G_oloc(grp))) + if (NULL == (ret_value = H5G_oloc(grp))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_get_oloc() */ - /*------------------------------------------------------------------------- * Function: H5O__group_bh_info * @@ -331,13 +317,13 @@ 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) { - htri_t exists; /* Flag if header message of interest exists */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(oh->cache_info.addr) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(loc); @@ -347,69 +333,70 @@ H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Check for "new style" group info */ - if((exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") - if(exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if ((exists = H5O_msg_exists_oh(oh, H5O_LINFO_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read object header") + if (exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Get "new style" group info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_LINFO_ID, &linfo)) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't read LINFO message") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_LINFO_ID, &linfo)) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't read LINFO message") /* Check if name index available */ - if(H5F_addr_defined(linfo.name_bt2_addr)) { + if (H5F_addr_defined(linfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, linfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, linfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ - if(H5B2_size(bt2_name, &bh_info->index_size) < 0) + if (H5B2_size(bt2_name, &bh_info->index_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info for name index") } /* end if */ /* Check if creation order index available */ - if(H5F_addr_defined(linfo.corder_bt2_addr)) { + if (H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(loc->file, linfo.corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ - if(H5B2_size(bt2_corder, &bh_info->index_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info for creation order index") + if (H5B2_size(bt2_corder, &bh_info->index_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, + "can't retrieve B-tree storage info for creation order index") } /* end if */ /* Get fractal heap size, if available */ - if(H5F_addr_defined(linfo.fheap_addr)) { + if (H5F_addr_defined(linfo.fheap_addr)) { /* Open the fractal heap for links */ - if(NULL == (fheap = H5HF_open(loc->file, linfo.fheap_addr))) + if (NULL == (fheap = H5HF_open(loc->file, linfo.fheap_addr))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &bh_info->heap_size) < 0) + if (H5HF_size(fheap, &bh_info->heap_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") } /* end if */ - } /* end if */ + } /* end if */ else { - H5O_stab_t stab; /* Info about symbol table */ + H5O_stab_t stab; /* Info about symbol table */ /* Must be "old style" group, get symbol table message */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_STAB_ID, &stab)) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages") + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_STAB_ID, &stab)) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages") /* Get symbol table size info */ - if(H5G__stab_bh_size(loc->file, &stab, bh_info) < 0) + if (H5G__stab_bh_size(loc->file, &stab, bh_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve symbol table size info") } /* end else */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_bh_info() */ - diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index a9292ed0725..b0adf30f510 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,39 +23,37 @@ #error "Do not include this file outside the H5G package!" #endif -#ifndef _H5Gpkg_H -#define _H5Gpkg_H +#ifndef H5Gpkg_H +#define H5Gpkg_H /* Get package's private header */ #include "H5Gprivate.h" /* Other private headers needed by this file */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFprivate.h" /* Fractal heaps */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFprivate.h" /* Fractal heaps */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Standard length of fractal heap ID for link */ -#define H5G_DENSE_FHEAP_ID_LEN 7 +#define H5G_DENSE_FHEAP_ID_LEN 7 /* Size of a symbol table node on disk */ -#define H5G_NODE_SIZE(f) ( \ - /* General metadata fields */ \ - H5_SIZEOF_MAGIC \ - + 1 /* Version */ \ - + 1 /* Reserved */ \ - + 2 /* Number of symbols */ \ - \ - /* Entries */ \ - + ((2 * H5F_SYM_LEAF_K(f)) * (unsigned)H5G_SIZEOF_ENTRY_FILE(f)) \ - ) - +#define H5G_NODE_SIZE(f) \ + ( /* General metadata fields */ \ + H5_SIZEOF_MAGIC /*magic number */ \ + + 1 /* Version */ \ + + 1 /* Reserved */ \ + + 2 /* Number of symbols */ \ + \ + /* Entries */ \ + + ((2 * H5F_SYM_LEAF_K(f)) * (unsigned)H5G_SIZEOF_ENTRY_FILE(f))) /****************************/ /* Package Private Typedefs */ @@ -68,12 +66,12 @@ * symbol table entry. */ typedef enum H5G_cache_type_t { - H5G_CACHED_ERROR = -1, /*force enum to be signed */ - H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ - H5G_CACHED_STAB = 1, /*symbol table, `stab' */ - H5G_CACHED_SLINK = 2, /*symbolic link */ + H5G_CACHED_ERROR = -1, /*force enum to be signed */ + H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */ + H5G_CACHED_STAB = 1, /*symbol table, `stab' */ + H5G_CACHED_SLINK = 2, /*symbolic link */ - H5G_NCACHED /*THIS MUST BE LAST */ + H5G_NCACHED /*THIS MUST BE LAST */ } H5G_cache_type_t; /* @@ -85,12 +83,12 @@ typedef enum H5G_cache_type_t { */ typedef union H5G_cache_t { struct { - haddr_t btree_addr; /*file address of symbol table B-tree*/ - haddr_t heap_addr; /*file address of stab name heap */ + haddr_t btree_addr; /*file address of symbol table B-tree*/ + haddr_t heap_addr; /*file address of stab name heap */ } stab; struct { - size_t lval_offset; /*link value offset */ + size_t lval_offset; /*link value offset */ } slink; } H5G_cache_t; @@ -101,10 +99,10 @@ typedef union H5G_cache_t { * points. */ struct H5G_entry_t { - H5G_cache_type_t type; /*type of information cached */ - H5G_cache_t cache; /*cached data from object header */ - size_t name_off; /*offset of name within name heap */ - haddr_t header; /*file address of object header */ + H5G_cache_type_t type; /*type of information cached */ + H5G_cache_t cache; /*cached data from object header */ + size_t name_off; /*offset of name within name heap */ + haddr_t header; /*file address of object header */ }; /* @@ -114,19 +112,19 @@ struct H5G_entry_t { * table or group. */ typedef struct H5G_node_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - size_t node_size; /* Size of node on disk */ - unsigned nsyms; /* Number of symbols */ - H5G_entry_t *entry; /* Array of symbol table entries */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + size_t node_size; /* Size of node on disk */ + unsigned nsyms; /* Number of symbols */ + H5G_entry_t *entry; /* Array of symbol table entries */ } H5G_node_t; /* * Shared information for all open group objects */ struct H5G_shared_t { - int fo_count; /* open file object count */ - hbool_t mounted; /* Group is mount point */ + int fo_count; /* open file object count */ + hbool_t mounted; /* Group is mount point */ }; /* @@ -134,9 +132,9 @@ struct H5G_shared_t { * above the H5G layer. */ struct H5G_t { - H5G_shared_t *shared; /* Shared file object data */ - H5O_loc_t oloc; /* Object location for group */ - H5G_name_t path; /* Group hierarchy path */ + H5G_shared_t *shared; /* Shared file object data */ + H5O_loc_t oloc; /* Object location for group */ + H5G_name_t path; /* Group hierarchy path */ }; /* Link iteration operator for internal library callbacks */ @@ -144,8 +142,8 @@ typedef herr_t (*H5G_lib_iterate_t)(const H5O_link_t *lnk, void *op_data); /* Data structure to hold table of links for a group */ typedef struct { - size_t nlinks; /* # of links in table */ - H5O_link_t *lnks; /* Pointer to array of links */ + size_t nlinks; /* # of links in table */ + H5O_link_t *lnks; /* Pointer to array of links */ } H5G_link_table_t; /* @@ -158,8 +156,8 @@ typedef struct { */ typedef struct H5G_bt_common_t { /* downward */ - const char *name; /*points to temporary memory */ - H5HL_t *heap; /*symbol table heap */ + const char *name; /*points to temporary memory */ + H5HL_t * heap; /*symbol table heap */ } H5G_bt_common_t; /* @@ -168,10 +166,10 @@ typedef struct H5G_bt_common_t { */ typedef struct H5G_bt_ins_t { /* downward */ - 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 */ + 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 */ } H5G_bt_ins_t; /* @@ -180,12 +178,12 @@ 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 */ + 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 */ } H5G_bt_rm_t; /* Typedef for B-tree 'find' operation */ -typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_data/*in,out*/); +typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent /*in*/, void *operator_data /*in,out*/); /* * Data exchange structure for symbol table nodes. This structure is @@ -193,9 +191,9 @@ typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_ */ 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 */ + 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 */ /* upward */ } H5G_bt_lkp_t; @@ -206,40 +204,40 @@ typedef struct H5G_bt_lkp_t { */ typedef struct H5G_bt_it_it_t { /* downward */ - 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 */ + 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 */ /* upward */ - hsize_t *final_ent; /*final entry looked at */ + hsize_t *final_ent; /*final entry looked at */ } 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 */ - haddr_t src_heap_addr; /* Heap address of the source symbol table */ - 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 */ + 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 */ + const H5O_stab_t *dst_stab; /* Symbol table message for destination group */ + H5O_copy_t * cpy_info; /* Information for copy operation */ } H5G_bt_it_cpy_t; /* Common information for "by index" lookups in symbol tables */ typedef struct H5G_bt_it_idx_common_t { /* downward */ - hsize_t idx; /* Index of group member to be queried */ - hsize_t num_objs; /* The number of objects having been traversed */ - H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ + hsize_t idx; /* Index of group member to be queried */ + hsize_t num_objs; /* The number of objects having been traversed */ + H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ } H5G_bt_it_idx_common_t; /* Data passed through B-tree iteration for building a table of the links */ typedef struct H5G_bt_it_bt_t { /* downward */ - size_t alloc_nlinks; /* Number of links allocated in table */ - H5HL_t *heap; /* Symbol table heap */ + size_t alloc_nlinks; /* Number of links allocated in table */ + H5HL_t *heap; /* Symbol table heap */ /* upward */ - H5G_link_table_t *ltable; /* Link table to add information to */ + H5G_link_table_t *ltable; /* Link table to add information to */ } H5G_bt_it_bt_t; /* Typedefs for "new format" groups */ @@ -248,8 +246,8 @@ typedef struct H5G_bt_it_bt_t { /* Typedef for native 'name' field index records in the v2 B-tree */ /* (Keep 'id' field first so generic record handling in callbacks works) */ typedef struct H5G_dense_bt2_name_rec_t { - uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID for link */ - uint32_t hash; /* Hash of 'name' field value */ + uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID for link */ + uint32_t hash; /* Hash of 'name' field value */ } H5G_dense_bt2_name_rec_t; /* Typedef for native 'creation order' field index records in the v2 B-tree */ @@ -266,13 +264,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 */ - 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 */ + 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 */ } H5G_bt2_ud_common_t; /* @@ -281,25 +279,24 @@ typedef struct H5G_bt2_ud_common_t { */ typedef struct H5G_bt2_ud_ins_t { /* downward */ - H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ - uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID of link to insert */ + H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ + uint8_t id[H5G_DENSE_FHEAP_ID_LEN]; /* Heap ID of link to insert */ } H5G_bt2_ud_ins_t; /* Typedef for group creation operation */ -typedef struct H5G_obj_create_t{ - hid_t gcpl_id; /* Group creation property list */ +typedef struct H5G_obj_create_t { + hid_t gcpl_id; /* Group creation property list */ H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ - H5G_cache_t cache; /* Cached data for symbol table entry */ + H5G_cache_t cache; /* Cached data for symbol table entry */ } H5G_obj_create_t; /* Callback information for copying groups */ typedef struct H5G_copy_file_ud_t { - H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ - H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ - H5G_cache_t cache; /* Cached data for symbol table entry */ + H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ + H5G_cache_type_t cache_type; /* Type of symbol table entry cache */ + H5G_cache_t cache; /* Cached data for symbol table entry */ } H5G_copy_file_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -329,21 +326,17 @@ H5FL_EXTERN(H5G_shared_t); * General group routines */ H5_DLL H5G_t *H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info); -H5_DLL H5G_t *H5G__create_named(const H5G_loc_t *loc, const char *name, - hid_t lcpl_id, hid_t gcpl_id); +H5_DLL H5G_t *H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t gcpl_id); H5_DLL H5G_t *H5G__open_name(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, - H5G_info_t *grp_info); -H5_DLL herr_t H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info); -H5_DLL herr_t H5G__close_cb(H5G_t *grp); +H5_DLL herr_t H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_info); +H5_DLL herr_t H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info); /* * Group hierarchy traversal routines */ -H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, - const H5O_link_t *lnk, unsigned target, hbool_t last_comp, - H5G_loc_t *obj_loc, hbool_t *obj_exists); +H5_DLL herr_t H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned target, + hbool_t last_comp, H5G_loc_t *obj_loc, hbool_t *obj_exists); /* * Utility functions @@ -355,146 +348,112 @@ H5_DLL const char *H5G__component(const char *name, size_t *size_p); * functions that understand names are exported to the rest of * the library and appear in H5Gprivate.h. */ -H5_DLL herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, - H5O_stab_t *stab); +H5_DLL herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab); H5_DLL herr_t H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint); -H5_DLL herr_t H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info); -H5_DLL 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); +H5_DLL herr_t H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, + H5O_type_t obj_type, const void *crt_info); +H5_DLL 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); H5_DLL herr_t H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab); -H5_DLL 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); +H5_DLL 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); H5_DLL herr_t H5G__stab_count(const struct H5O_loc_t *oloc, hsize_t *num_objs); -H5_DLL herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, - H5_ih_info_t *bh_info); -H5_DLL 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); -H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, - H5RS_str_t *grp_full_path_r, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); -H5_DLL 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); +H5_DLL herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info); +H5_DLL 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); +H5_DLL herr_t H5G__stab_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__stab_remove_by_idx(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +H5_DLL 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); #ifndef H5_STRICT_FORMAT_CHECKS H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); #endif /* H5_STRICT_FORMAT_CHECKS */ -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* * 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_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); -H5_DLL herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, - const H5G_entry_t *ent, unsigned n); -H5_DLL herr_t H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, - const H5O_link_t *lnk, H5O_type_t obj_type, const void *crt_info, - H5G_entry_t *ent); -H5_DLL herr_t H5G__ent_debug(const H5G_entry_t *ent, FILE * stream, int indent, - int fwidth, const H5HL_t *heap); +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_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); +H5_DLL herr_t H5G__ent_encode_vec(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n); +H5_DLL herr_t H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk, + H5O_type_t obj_type, const void *crt_info, H5G_entry_t *ent); +H5_DLL herr_t H5G__ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, + const H5HL_t *heap); /* Functions that understand symbol table nodes */ H5_DLL herr_t H5G__node_init(H5F_t *f); -H5_DLL int H5G__node_iterate(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_sumup(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_by_idx(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_copy(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL int H5G__node_build_table(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); -H5_DLL herr_t H5G__node_iterate_size(H5F_t *f, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); +H5_DLL int H5G__node_iterate(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_sumup(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_by_idx(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_copy(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL int H5G__node_build_table(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, + void *_udata); +H5_DLL herr_t H5G__node_iterate_size(H5F_t *f, const void *_lt_key, haddr_t addr, const void *_rt_key, + void *_udata); H5_DLL herr_t H5G__node_free(H5G_node_t *sym); /* Functions that understand links in groups */ -H5_DLL herr_t H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, - const H5G_entry_t *ent, const char *name); -H5_DLL herr_t H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc); -H5_DLL herr_t H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, - H5_iter_order_t order); -H5_DLL herr_t H5G__link_iterate_table(const H5G_link_table_t *ltable, - hsize_t skip, hsize_t *last_lnk, const H5G_lib_iterate_t op, void *op_data); +H5_DLL herr_t H5G__ent_to_link(H5O_link_t *lnk, const H5HL_t *heap, const H5G_entry_t *ent, const char *name); +H5_DLL herr_t H5G__link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc); +H5_DLL herr_t H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order); +H5_DLL herr_t H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, hsize_t *last_lnk, + const H5G_lib_iterate_t op, void *op_data); H5_DLL herr_t H5G__link_release_table(H5G_link_table_t *ltable); H5_DLL herr_t H5G__link_name_replace(H5F_t *file, H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk); /* Functions that understand "compact" link storage */ -H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); -H5_DLL ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t idx, char *name, size_t size); -H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, - 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); -H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, - 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); -H5_DLL htri_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); -H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, - const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, - hsize_t n, H5O_link_t *lnk); -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__compact_get_type_by_idx(H5O_loc_t *oloc, - const H5O_linfo_t *linfo, hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +H5_DLL herr_t H5G__compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk); +H5_DLL ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, + H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, + char *name, size_t size); +H5_DLL herr_t H5G__compact_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G__compact_remove_by_idx(const H5O_loc_t *oloc, 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); +H5_DLL herr_t H5G__compact_iterate(const H5O_loc_t *oloc, 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); +H5_DLL htri_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); /* Functions that understand "dense" link storage */ -H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, - H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable); -H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, - const H5O_pline_t *pline); -H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, - const H5O_link_t *lnk); -H5_DLL htri_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, - const char *name, H5O_link_t *lnk); -H5_DLL 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); -H5_DLL 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); -H5_DLL 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); -H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, const char *name); -H5_DLL 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); -H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__dense_get_type_by_idx(H5F_t *f, H5O_linfo_t *linfo, - hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, + H5_iter_order_t order, H5G_link_table_t *ltable); +H5_DLL herr_t H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline); +H5_DLL herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk); +H5_DLL htri_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk); +H5_DLL 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); +H5_DLL 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); +H5_DLL 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); +H5_DLL herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, + const char *name); +H5_DLL 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); +H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); /* Functions that understand group objects */ -H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, - H5O_loc_t *oloc/*out*/); -H5_DLL herr_t H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, - const H5O_linfo_t *linfo, const H5O_pline_t *pline, H5G_obj_create_t *gcrt_info, - H5O_loc_t *oloc/*out*/); +H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, H5O_loc_t *oloc /*out*/); +H5_DLL herr_t H5G__obj_create_real(H5F_t *f, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linfo, + const H5O_pline_t *pline, H5G_obj_create_t *gcrt_info, + H5O_loc_t *oloc /*out*/); H5_DLL htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo); -H5_DLL herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, - 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); +H5_DLL herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, 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); H5_DLL herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info); -H5_DLL htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *lnk); +H5_DLL htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +#ifndef H5_NO_DEPRECATED_SYMBOLS +H5_DLL herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, + H5G_stat_t *statbuf /*out*/); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* * These functions operate on group hierarchy names. @@ -504,8 +463,9 @@ 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, const void *crt_info); +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, + const void *crt_info); +H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/); /* Testing functions */ #ifdef H5G_TESTING @@ -515,10 +475,10 @@ H5_DLL htri_t H5G__has_stab_test(hid_t gid); H5_DLL htri_t H5G__is_new_dense_test(hid_t gid); H5_DLL herr_t H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count); H5_DLL herr_t H5G__lheap_size_test(hid_t gid, size_t *lheap_size); -H5_DLL herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *user_path_hidden); +H5_DLL herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, + unsigned *user_path_hidden); H5_DLL herr_t H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent); H5_DLL herr_t H5G__verify_cached_stabs_test(hid_t gid); #endif /* H5G_TESTING */ -#endif /* _H5Gpkg_H */ - +#endif /* H5Gpkg_H */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index da1a5385989..409d79003de 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,45 +22,45 @@ *------------------------------------------------------------------------- */ -#ifndef _H5Gprivate_H -#define _H5Gprivate_H +#ifndef H5Gprivate_H +#define H5Gprivate_H /* Include package's public header */ #include "H5Gpublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-trees */ -#include "H5Fprivate.h" /* File access */ -#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-trees */ +#include "H5Fprivate.h" /* File access */ +#include "H5RSprivate.h" /* Reference-counted strings */ /* * The disk size for a symbol table entry... */ -#define H5G_SIZEOF_SCRATCH 16 -#define H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size) \ - ((sizeof_size) + /*offset of name into heap */ \ - (sizeof_addr) + /*address of object header */ \ - 4 + /*entry type */ \ - 4 + /*reserved */ \ - H5G_SIZEOF_SCRATCH) /*scratch pad space */ -#define H5G_SIZEOF_ENTRY_FILE(F) \ - H5G_SIZEOF_ENTRY(H5F_SIZEOF_ADDR(F), H5F_SIZEOF_SIZE(F)) +#define H5G_SIZEOF_SCRATCH 16 +#define H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size) \ + ((sizeof_size) + /*offset of name into heap */ \ + (sizeof_addr) + /*address of object header */ \ + 4 + /*entry type */ \ + 4 + /*reserved */ \ + H5G_SIZEOF_SCRATCH) /*scratch pad space */ +#define H5G_SIZEOF_ENTRY_FILE(F) H5G_SIZEOF_ENTRY(H5F_SIZEOF_ADDR(F), H5F_SIZEOF_SIZE(F)) /* ========= Group Creation properties ============ */ /* Defaults for link info values */ -#define H5G_CRT_LINFO_TRACK_CORDER FALSE -#define H5G_CRT_LINFO_INDEX_CORDER FALSE -#define H5G_CRT_LINFO_NLINKS 0 -#define H5G_CRT_LINFO_MAX_CORDER 0 -#define H5G_CRT_LINFO_LINK_FHEAP_ADDR HADDR_UNDEF -#define H5G_CRT_LINFO_NAME_BT2_ADDR HADDR_UNDEF -#define H5G_CRT_LINFO_CORDER_BT2_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_TRACK_CORDER FALSE +#define H5G_CRT_LINFO_INDEX_CORDER FALSE +#define H5G_CRT_LINFO_NLINKS 0 +#define H5G_CRT_LINFO_MAX_CORDER 0 +#define H5G_CRT_LINFO_LINK_FHEAP_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_NAME_BT2_ADDR HADDR_UNDEF +#define H5G_CRT_LINFO_CORDER_BT2_ADDR HADDR_UNDEF /* Definitions for link info settings */ -#define H5G_CRT_LINK_INFO_NAME "link info" -#define H5G_CRT_LINK_INFO_SIZE sizeof(H5O_linfo_t) +#define H5G_CRT_LINK_INFO_NAME "link info" +#define H5G_CRT_LINK_INFO_SIZE sizeof(H5O_linfo_t) +/* clang-format off */ #define H5G_CRT_LINK_INFO_DEF {H5G_CRT_LINFO_TRACK_CORDER, \ H5G_CRT_LINFO_INDEX_CORDER, \ H5G_CRT_LINFO_MAX_CORDER, \ @@ -69,19 +69,21 @@ H5G_CRT_LINFO_LINK_FHEAP_ADDR, \ H5G_CRT_LINFO_NAME_BT2_ADDR \ } +/* clang-format on */ /* Defaults for group info values */ -#define H5G_CRT_GINFO_LHEAP_SIZE_HINT 0 -#define H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE FALSE -#define H5G_CRT_GINFO_MAX_COMPACT 8 -#define H5G_CRT_GINFO_MIN_DENSE 6 -#define H5G_CRT_GINFO_STORE_EST_ENTRY_INFO FALSE -#define H5G_CRT_GINFO_EST_NUM_ENTRIES 4 -#define H5G_CRT_GINFO_EST_NAME_LEN 8 +#define H5G_CRT_GINFO_LHEAP_SIZE_HINT 0 +#define H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE FALSE +#define H5G_CRT_GINFO_MAX_COMPACT 8 +#define H5G_CRT_GINFO_MIN_DENSE 6 +#define H5G_CRT_GINFO_STORE_EST_ENTRY_INFO FALSE +#define H5G_CRT_GINFO_EST_NUM_ENTRIES 4 +#define H5G_CRT_GINFO_EST_NAME_LEN 8 /* Definitions for group info settings */ -#define H5G_CRT_GROUP_INFO_NAME "group info" -#define H5G_CRT_GROUP_INFO_SIZE sizeof(H5O_ginfo_t) +#define H5G_CRT_GROUP_INFO_NAME "group info" +#define H5G_CRT_GROUP_INFO_SIZE sizeof(H5O_ginfo_t) +/* clang-format off */ #define H5G_CRT_GROUP_INFO_DEF {H5G_CRT_GINFO_LHEAP_SIZE_HINT, \ H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE, \ H5G_CRT_GINFO_MAX_COMPACT, \ @@ -90,12 +92,13 @@ H5G_CRT_GINFO_EST_NUM_ENTRIES, \ H5G_CRT_GINFO_EST_NAME_LEN \ } +/* clang-format on */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5G_MODULE -#define H5G_MOUNTED(G) ((G)->shared->mounted) +#define H5G_MOUNTED(G) ((G)->shared->mounted) #else /* H5G_MODULE */ -#define H5G_MOUNTED(G) (H5G_mounted(G)) +#define H5G_MOUNTED(G) (H5G_mounted(G)) #endif /* H5G_MODULE */ /* @@ -103,34 +106,34 @@ * a symbolic link or a mount point. The normal operation is to follow the * symbolic link or mount point and return information about its target. */ -#define H5G_TARGET_NORMAL 0x0000 -#define H5G_TARGET_SLINK 0x0001 -#define H5G_TARGET_MOUNT 0x0002 -#define H5G_TARGET_UDLINK 0x0004 -#define H5G_TARGET_EXISTS 0x0008 -#define H5G_CRT_INTMD_GROUP 0x0010 +#define H5G_TARGET_NORMAL 0x0000 +#define H5G_TARGET_SLINK 0x0001 +#define H5G_TARGET_MOUNT 0x0002 +#define H5G_TARGET_UDLINK 0x0004 +#define H5G_TARGET_EXISTS 0x0008 +#define H5G_CRT_INTMD_GROUP 0x0010 /* Type of operation being performed for call to H5G_name_replace() */ typedef enum { - H5G_NAME_MOVE = 0, /* H5*move call */ - H5G_NAME_DELETE, /* H5Ldelete call */ - H5G_NAME_MOUNT, /* H5Fmount call */ - H5G_NAME_UNMOUNT /* H5Funmount call */ + H5G_NAME_MOVE = 0, /* H5*move call */ + H5G_NAME_DELETE, /* H5Ldelete call */ + H5G_NAME_MOUNT, /* H5Fmount call */ + H5G_NAME_UNMOUNT /* H5Funmount call */ } H5G_names_op_t; /* Status returned from traversal callbacks; whether the object location * or group location need to be closed */ -#define H5G_OWN_NONE 0 +#define H5G_OWN_NONE 0 #define H5G_OWN_OBJ_LOC 1 #define H5G_OWN_GRP_LOC 2 -#define H5G_OWN_BOTH 3 +#define H5G_OWN_BOTH 3 typedef int H5G_own_loc_t; /* Structure to store information about the name an object was opened with */ typedef struct { - H5RS_str_t *full_path_r; /* Path to object, as seen from root of current file mounting hierarchy */ - H5RS_str_t *user_path_r; /* Path to object, as opened by user */ - unsigned obj_hidden; /* Whether the object is visible in group hier. */ + H5RS_str_t *full_path_r; /* Path to object, as seen from root of current file mounting hierarchy */ + H5RS_str_t *user_path_r; /* Path to object, as opened by user */ + unsigned obj_hidden; /* Whether the object is visible in group hier. */ } H5G_name_t; /* Forward declarations (for prototypes & struct definitions) */ @@ -142,8 +145,8 @@ struct H5O_link_t; * location and a group hierarchy path for the object. */ typedef struct { - struct H5O_loc_t *oloc; /* Object header location */ - H5G_name_t *path; /* Group hierarchy path */ + struct H5O_loc_t *oloc; /* Object header location */ + H5G_name_t * path; /* Group hierarchy path */ } H5G_loc_t; /* Typedef for path traversal operations */ @@ -156,45 +159,46 @@ typedef struct { * H5G_OWN_GRP_LOC if it takes ownership of grp_loc, and H5G_OWN_NONE if obj_loc and * grp_loc need to be deleted. */ -typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc/*in*/, const char *name, - const struct H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); +typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc /*in*/, const char *name, + const struct H5O_link_t *lnk /*in*/, H5G_loc_t *obj_loc /*out*/, + void *operator_data /*in,out*/, H5G_own_loc_t *own_loc /*out*/); /* Describe kind of callback to make for each link */ typedef enum H5G_link_iterate_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_LINK_OP_OLD, /* "Old" application callback */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5G_LINK_OP_NEW /* "New" application callback */ + H5G_LINK_OP_OLD, /* "Old" application callback */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5G_LINK_OP_NEW /* "New" application callback */ } H5G_link_iterate_op_type_t; typedef struct { H5G_link_iterate_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_iterate_t op_old; /* "Old" application callback for each link */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5L_iterate_t op_new; /* "New" application callback for each link */ + H5G_iterate_t op_old; /* "Old" application callback for each link */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + H5L_iterate2_t op_new; /* "New" application callback for each link */ } op_func; } H5G_link_iterate_t; -typedef struct H5G_t H5G_t; +typedef struct H5G_t H5G_t; typedef struct H5G_shared_t H5G_shared_t; -typedef struct H5G_entry_t H5G_entry_t; +typedef struct H5G_entry_t H5G_entry_t; /* * Library prototypes... These are the ones that other packages routinely * call. */ +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(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 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 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 */ @@ -207,41 +211,38 @@ H5_DLL char *H5G_normalize(const char *name); /* * Group hierarchy traversal routines */ -H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, - unsigned target, H5G_traverse_t op, void *op_data); -H5_DLL herr_t H5G_iterate(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - const H5G_link_iterate_t *lnk_op, void *op_data); -H5_DLL herr_t H5G_visit(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data); +H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, + void *op_data); +H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t skip, hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data); +H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + H5L_iterate2_t op, void *op_data); /* * Functions that understand links in groups */ -H5_DLL herr_t H5G_link_to_info(const struct H5O_link_t *lnk, H5L_info_t *linfo); +H5_DLL herr_t H5G_link_to_info(const struct H5O_loc_t *link_loc, const struct H5O_link_t *lnk, + H5L_info2_t *linfo); /* * Functions that understand group objects */ -H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, - struct H5O_link_t *obj_lnk, hbool_t adj_link, H5O_type_t obj_type, - const void *crt_info); +H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name, struct H5O_link_t *obj_lnk, + hbool_t adj_link, H5O_type_t obj_type, const void *crt_info); H5_DLL ssize_t H5G_obj_get_name_by_idx(const struct H5O_loc_t *oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, char* name, size_t size); -H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, - const char *name); -H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); -H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); + H5_iter_order_t order, hsize_t n, char *name, size_t size); +H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name); +H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk); +H5_DLL hid_t H5G_get_create_plist(const H5G_t *grp); /* * These functions operate on symbol table nodes. */ H5_DLL herr_t H5G_node_close(const H5F_t *f); -H5_DLL herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth, haddr_t heap); +H5_DLL herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t heap); /* * These functions operate on group object locations. @@ -252,38 +253,35 @@ 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(hid_t fid, 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); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, - H5G_loc_t *obj_loc/*out*/); -H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5G_loc_t *obj_loc/*out*/); -H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, - H5O_info_t *oinfo/*out*/, unsigned fields); -H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, - const char *comment); -H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, - char *comment/*out*/, size_t bufsize); -H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); -H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc /*out*/); +H5_DLL herr_t H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc /*out*/); +H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5G_loc_info(const H5G_loc_t *loc, const char *name, H5O_info2_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_native_info(const H5G_loc_t *loc, const char *name, H5O_native_info_t *oinfo /*out*/, + unsigned fields); +H5_DLL herr_t H5G_loc_set_comment(const H5G_loc_t *loc, const char *name, const char *comment); +H5_DLL ssize_t H5G_loc_get_comment(const H5G_loc_t *loc, const char *name, char *comment /*out*/, + size_t bufsize); +H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc); +H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc); /* * These functions operate on the root group @@ -293,5 +291,4 @@ H5_DLL herr_t H5G_root_loc(H5F_t *f, H5G_loc_t *loc); H5_DLL herr_t H5G_root_free(H5G_t *grp); H5_DLL H5G_t *H5G_rootof(H5F_t *f); -#endif /* _H5Gprivate_H */ - +#endif /* H5Gprivate_H */ diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 3f74d453d63..7f1faf8e6aa 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,17 +21,17 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5Gpublic_H -#define _H5Gpublic_H +#ifndef H5Gpublic_H +#define H5Gpublic_H /* System headers needed by this file */ #include /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Lpublic.h" /* Links */ -#include "H5Opublic.h" /* Object headers */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5public.h" /* Generic Functions */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Tpublic.h" /* Datatypes */ /*****************/ /* Public Macros */ @@ -41,29 +41,36 @@ /* Public Typedefs */ /*******************/ -/* Types of link storage for groups */ +//! +/** + * Types of link storage for groups + */ typedef enum H5G_storage_type_t { - H5G_STORAGE_TYPE_UNKNOWN = -1, /* Unknown link storage type */ - H5G_STORAGE_TYPE_SYMBOL_TABLE, /* Links in group are stored with a "symbol table" */ - /* (this is sometimes called "old-style" groups) */ - H5G_STORAGE_TYPE_COMPACT, /* Links are stored in object header */ - H5G_STORAGE_TYPE_DENSE /* Links are stored in fractal heap & indexed with v2 B-tree */ + H5G_STORAGE_TYPE_UNKNOWN = -1, /**< Unknown link storage type */ + H5G_STORAGE_TYPE_SYMBOL_TABLE, /**< Links in group are stored with a "symbol table" */ + /**< (this is sometimes called "old-style" groups) */ + H5G_STORAGE_TYPE_COMPACT, /**< Links are stored in object header */ + H5G_STORAGE_TYPE_DENSE /**< Links are stored in fractal heap & indexed with v2 B-tree */ } H5G_storage_type_t; +//! -/* Information struct for group (for H5Gget_info/H5Gget_info_by_name/H5Gget_info_by_idx) */ +//! +/** + * Information struct for group for + * H5Gget_info(), H5Gget_info_by_name(), and H5Gget_info_by_idx() + */ typedef struct H5G_info_t { - H5G_storage_type_t storage_type; /* Type of storage for links in group */ - hsize_t nlinks; /* Number of links in group */ - int64_t max_corder; /* Current max. creation order value for group */ - hbool_t mounted; /* Whether group has a file mounted on it */ + H5G_storage_type_t storage_type; /**< Type of storage for links in group */ + hsize_t nlinks; /**< Number of links in group */ + int64_t max_corder; /**< Current max. creation order value for group */ + hbool_t mounted; /**< Whether group has a file mounted on it */ } H5G_info_t; - +//! /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -71,21 +78,344 @@ typedef struct H5G_info_t { extern "C" { #endif -H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, - hid_t gcpl_id, hid_t gapl_id); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Creates a new group and links it into the file + * + * \fgdta_loc_id + * \param[in] name Name of the group to create + * \lcpl_id + * \gcpl_id + * \gapl_id + * + * \return \hid_t{group} + * + * \details H5Gcreate2() creates a new group in a file. After a + * group has been created, links to datasets and to other groups + * can be added. + * + * The \p loc_id and \p name parameters specify where the group + * is located. \p loc_id may be a file, group, dataset, named + * datatype or attribute in the file. If an attribute, dataset, + * or named datatype is specified for \p loc_id then the group + * will be created at the location where the attribute, dataset, + * or named datatype is attached. \p name is the link to the group; + * \p name may be either an absolute path in the file (the links + * from the root group to the new group) or a relative path from + * \p loc_id (the link(s) from the group specified by \p loc_id + * to the new group). + * + * \p lcpl_id, \p gcpl_id, and \p gapl_id are property list + * identifiers. These property lists govern how the link to the + * group is created, how the group is created, and how the group + * can be accessed in the future, respectively. #H5P_DEFAULT can + * be passed in if the default properties are appropriate for + * these property lists. Currently, there are no APIs for the + * group access property list; use #H5P_DEFAULT. + * + * The group identifier should be closed by H5Gclose() when access + * is no longer required to prevent resource leaks. + * + * \since 1.8.0 + * + * \see H5Gopen2(), H5Gclose() + * + */ +H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Creates a new empty group without linking it into the file structure + * + * \fgdta_loc_id + * \gcpl_id + * \gapl_id + * + * \return \hid_t{group} + * + * \details H5Gcreate_anon() creates a new empty group in the file + * specified by \p loc_id. With default settings, H5Gcreate_anon() + * provides similar functionality to that provided by + * H5Gcreate1(), with the differences described in the list below. + * + * The new group’s creation and access properties are specified + * in \p gcpl_id and \p gapl_id, respectively. + * + * H5Gcreate_anon() returns a new group identifier. This identifier + * must be linked into the HDF5 file structure with H5Olink() + * or it will be deleted from the file when the file is closed. + * + * The differences between this function and H5Gcreate1() are + * as follows: + * + * \li H5Gcreate1() does not provide for the use of custom property + * lists; H5Gcreate1() always uses default properties. + * \li H5Gcreate_anon() neither provides the new group’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. + * \li H5Gcreate_anon() does not directly provide a hint mechanism + * for the group’s heap size. Comparable information can be + * included in the group creation property list \p gcpl_id through + * a H5Pset_local_heap_size_hint() call. + * + * A group created with this function should be closed with + * H5Gclose() when the group is no longer needed so that resource + * leaks will not develop. + * + * \see H5Olink(), H5Dcreate(), Using Identifiers + * + * \since 1.8.0 + * + */ H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Opens an existing group in a file + * + * \fgdta_loc_id + * \param[in] name Name of the group to open + * \gapl_id + * + * \return \hid_t{group} + * + * \details H5Gopen2() opens an existing group, \p name, at the location + * specified by \p loc_id. + * + * With default settings, H5Gopen2() provides similar functionality + * to that provided by H5Gopen(). The only difference is that + * H5Gopen2() can provide a group access property list, \p gapl_id. + * + * H5Gopen2() returns a group identifier for the group that was + * opened. This group identifier should be released by H5Gclose() + * when it is no longer needed to prevent resource leaks. + * + * \since 1.8.0 + * + * \see H5Gcreate2(), H5Gclose() + * + */ H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Gets a group creation property list identifier + * + * \group_id + * + * \return \hid_t{creation property list} + * + * \details H5Gget_create_plist() returns an identifier for the group creation + * 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. + * + * \since 1.8.0 + * + * \see H5Gcreate2(), H5Gclose() + * + */ H5_DLL hid_t H5Gget_create_plist(hid_t group_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Retrieves information about a group + * + * \fgdta_loc_id + * \param[out] ginfo Struct in which group information is returned + * + * \return \hid_t{group} + * + * \details H5Gget_info() retrieves information about the group at location + * specified by \p loc_id. The information is returned in the \p ginfo. + * + * \p ginfo is an H5G_info_t struct and is defined (in H5Gpublic.h) + * as follows: + * + * \snippet this H5G_info_t_snip + * Possible values of \p storage_type are: + * \storage_type + * + * \since 1.8.0 + * + * \see H5Gcreate2(), H5Gclose() + * + */ H5_DLL herr_t H5Gget_info(hid_t loc_id, H5G_info_t *ginfo); -H5_DLL herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *ginfo, - hid_t lapl_id); -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); -H5_DLL herr_t H5Gclose(hid_t group_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Retrieves information about a group by its name + * + * \fgdta_loc_id + * \param[in] name Name of the group to query + * \param[out] ginfo Struct in which group information is returned + * \lapl_id + * + * \return \herr_t + * + * \details H5Gget_info_by_name() retrieves information about the group \p name + * at location specified by \p loc_id. The information is returned in + * the \p ginfo struct. + * + * If \p loc_id specifies the group for which information is queried, + * then the group's \p name can be a dot (.). + * + * \p ginfo is an H5G_info_t struct and is defined (in H5Gpublic.h) + * as follows: + * + * \snippet this H5G_info_t_snip + * Possible values of \p storage_type are: + * \storage_type + * + * \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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Retrieves information about a group, according to the group’s + * position within an index + * + * \fgdta_loc_id + * \param[in] group_name Name of the group to query + * \param[in] idx_type Transient index identifying object + * \param[in] order Transient index identifying object + * \param[in] n Position in the index of the group to query + * \param[out] ginfo Struct in which group information is returned + * \lapl_id + * + * \return Returns + * \li The size of the object name if successful, or + * \li 0 if no name is associated with the group identifier, or + * \li negative value, if failure occurred + * + * \details H5Gget_info_by_idx() retrieves the same information + * about a group as retrieved by the function H5Gget_info(), + * but the means of identifying the group differs; the group is + * identified by position in an index rather than by name. + * + * \p loc_id and \p group_name specify the group containing + * the group for which information is sought. The groups in \p + * group_name are indexed by \p idx_type; the group for which + * information is retrieved is identified in that index by index + * order, \p order, and index position, \p n. + * + * If \p loc_id specifies the group containing the group for + * which information is queried, \p group_name can be a dot (.). + * + * Valid values for \p index_type are as follows: + * \indexes + * The order in which the index is to be examined, as specified + * by \p order, can be one of the following: + * \orders + * + * \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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Flushes all buffers associated with a group to disk + * + * \group_id + * + * \return \herr_t + * + * \details H5Gflush() causes all buffers associated with a group to be + * immediately flushed to disk without removing the data from + * the cache. + * + * \attention + * HDF5 does not possess full control over buffering. H5G_FLUSH + * 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. + * + * \since 1.8.0 + * + * \see H5Gcreate2(), H5Gclose() + * + */ H5_DLL herr_t H5Gflush(hid_t group_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Refreshes all buffers associated with a group + * + * \group_id + * + * \return \herr_t + * + * \details H5Grefresh() causes all buffers associated with a group to be + * cleared and immediately re-loaded with updated contents from disk. + * + * This function essentially closes the group, evicts all + * metadata associated with it from the cache, and then re-opens + * the group. The reopened group is automatically re-registered + * with the same identifier. + * + * \since 1.8.0 + * + * \see H5Gcreate2(), H5Gclose() + * + */ H5_DLL herr_t H5Grefresh(hid_t group_id); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Closes the specified group + * + * \group_id + * + * \return \herr_t + * + * \details H5Gclose() releases resources used by a group which was + * opened by H5Gcreate() or H5Gopen(). After closing a group, + * \p group_id cannot be used again until another H5Gcreate() + * or H5Gopen() is called on it. + * + * Failure to release a group with this call will result in + * resource leaks. + * + * \par Example + * \snippet H5F_examples.c mount + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Gclose(hid_t group_id); + /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -95,79 +425,661 @@ H5_DLL herr_t H5Grefresh(hid_t group_id); /* Macros */ /* Link definitions */ -#define H5G_SAME_LOC H5L_SAME_LOC +#define H5G_SAME_LOC H5L_SAME_LOC #define H5G_LINK_ERROR H5L_TYPE_ERROR -#define H5G_LINK_HARD H5L_TYPE_HARD -#define H5G_LINK_SOFT H5L_TYPE_SOFT -#define H5G_link_t H5L_type_t +#define H5G_LINK_HARD H5L_TYPE_HARD +#define H5G_LINK_SOFT H5L_TYPE_SOFT +#define H5G_link_t H5L_type_t /* Macros for types of objects in a group (see H5G_obj_t definition) */ -#define H5G_NTYPES 256 /* Max possible number of types */ -#define H5G_NLIBTYPES 8 /* Number of internal types */ -#define H5G_NUSERTYPES (H5G_NTYPES - H5G_NLIBTYPES) -#define H5G_USERTYPE(X) (8 + (X)) /* User defined types */ - +#define H5G_NTYPES 256 /* Max possible number of types */ +#define H5G_NLIBTYPES 8 /* Number of internal types */ +#define H5G_NUSERTYPES (H5G_NTYPES - H5G_NLIBTYPES) +#define H5G_USERTYPE(X) (8 + (X)) /* User defined types */ /* Typedefs */ -/* +//! +/** * An object has a certain type. The first few numbers are reserved for use * internally by HDF5. Users may add their own types with higher values. The - * values are never stored in the file -- they only exist while an - * application is running. An object may satisfy the `isa' function for more - * than one type. + * values are never stored in the file -- they only exist while an application + * is running. An object may satisfy the `isa' function for more than one type. + * + * \deprecated */ typedef enum H5G_obj_t { - H5G_UNKNOWN = -1, /* Unknown object type */ - H5G_GROUP, /* Object is a group */ - H5G_DATASET, /* Object is a dataset */ - H5G_TYPE, /* Object is a named data type */ - H5G_LINK, /* Object is a symbolic link */ - H5G_UDLINK, /* Object is a user-defined link */ - H5G_RESERVED_5, /* Reserved for future use */ - H5G_RESERVED_6, /* Reserved for future use */ - H5G_RESERVED_7 /* Reserved for future use */ + H5G_UNKNOWN = -1, /**< Unknown object type */ + H5G_GROUP, /**< Object is a group */ + H5G_DATASET, /**< Object is a dataset */ + H5G_TYPE, /**< Object is a named data type */ + H5G_LINK, /**< Object is a symbolic link */ + H5G_UDLINK, /**< Object is a user-defined link */ + H5G_RESERVED_5, /**< Reserved for future use */ + H5G_RESERVED_6, /**< Reserved for future use */ + H5G_RESERVED_7 /**< Reserved for future use */ } H5G_obj_t; +//! -/* Prototype for H5Giterate() operator */ +//! +/** + * Callback for H5Giterate() + * + * \deprecated + */ typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data); +//! -/* Information about an object */ +//! +/** + * Information about an object + * + * \deprecated + */ typedef struct H5G_stat_t { - unsigned long fileno[2]; /*file number */ - unsigned long objno[2]; /*object number */ - unsigned nlink; /*number of hard links to object*/ - H5G_obj_t type; /*basic object type */ - time_t mtime; /*modification time */ - size_t linklen; /*symbolic link value length */ - H5O_stat_t ohdr; /* Object header information */ + unsigned long fileno[2]; /**< file number */ + unsigned long objno[2]; /**< object number */ + unsigned nlink; /**< number of hard links to object*/ + H5G_obj_t type; /**< basic object type */ + time_t mtime; /**< modification time */ + size_t linklen; /**< symbolic link value length */ + H5O_stat_t ohdr; /**< Object header information */ } H5G_stat_t; - +//! /* Function prototypes */ +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Creates a new group and links it into the file + * + * \fgdta_loc_id + * \param[in] name Name of the group to create + * \param[in] size_hint The number of bytes to reserve for the names + * that will appear in the group + * + * \return \hid_t{group} + * + * \deprecated This function is deprecated in favor of H5Gcreate2(). + * + * \details H5Gcreate1() creates a new group with the specified name at the + * specified location, \p loc_id. \p loc_id may be a file, group, + * dataset, named datatype or attribute. If an attribute, dataset, or + * named datatype is specified for \p loc_id then the group will be + * created at the location where the attribute, dataset, or named + * datatype is attached. The name, name, must not already be taken by + * some other object and all parent groups must already exist. + * + * \p name can be a relative path based at \p loc_id or an absolute + * path from the root of the file. Use of this function requires that + * any intermediate groups specified in the path already exist. + * + * The length of a group name, or of the name of any object within a + * group, is not limited. + * + * \p size_hint is a hint for the number of bytes to reserve to store + * the names which will be eventually added to the new group. This + * value must be between 0 and UINT32_MAX (inclusive). If this + * parameter is zero, a default value will be used. + * + * The return value is a group identifier for the open group. This + * group identifier should be closed by calling H5Gclose() when it is + * no longer needed. + * + * See H5Gcreate_anon() for a discussion of the differences between + * H5Gcreate1() and H5Gcreate_anon(). + * + * \par Example + * \snippet H5F_examples.c mount + * + * \version 1.8.0 Function H5Gcreate() renamed to H5Gcreate1() and deprecated + * in this release. + * \since 1.0.0 + * + */ H5_DLL hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Opens an existing group for modification and returns a group + * identifier for that group + * + * \fgdta_loc_id + * \param[in] name Name of the group to open + * + * \return \hid_t{group} + * + * \deprecated This function is deprecated in favor of H5Gopen2(). + * + * \details H5Gopen1() opens an existing group, \p name, at the location + * specified by \p loc_id. + * + * H5Gopen1() returns a group identifier for the group that was + * opened. This group identifier should be released by calling + * H5Gclose() when it is no longer needed. + * + * \version 1.8.0 The function H5Gopen() was renamed to H5Gopen1() + * and deprecated in this release. + * \since 1.0.0 + * + */ H5_DLL hid_t H5Gopen1(hid_t loc_id, const char *name); -H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, - const char *new_name); -H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name); -H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, - const char *dst_name); -H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Creates a link of the specified type from \p new_name to \p + * cur_name + * + * \fg_loc_id{cur_loc_id} + * \param[in] type Link type + * \param[in] cur_name Name of the existing object + * \param[in] new_name New name for the object + * + * \return \herr_t + * + * \deprecated This function is deprecated. + * + * \details H5Glink() creates a new name for an object that has some current + * name, possibly one of many names it currently has. + * + * If \p link_type is #H5G_LINK_HARD, then \p cur_name must specify + * the name of an existing object and both names are interpreted + * relative to \p cur_loc_id, which is either a file identifier or a + * group identifier. + * + * If \p link_type is #H5G_LINK_SOFT, then \p cur_name can be anything + * and is interpreted at lookup time relative to the group which + * contains the final component of \p new_name. For instance, if \p + * cur_name is \Code{./foo}, \p new_name is \Code{./x/y/bar}, and a + * request is made for \Code{./x/y/bar}, then the actual object looked + * up is \Code{./x/y/./foo}. + + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Creates a link of the specified type from \p cur_name to \p + * new_name + * + * \fg_loc_id{cur_loc_id} + * \param[in] cur_name Name of the existing object + * \param[in] type Link type + * \fg_loc_id{new_loc_id} + * \param[in] new_name New name for the object + * + * \return \herr_t + * + * \deprecated This function is deprecated. + * + * \details H5Glink2() creates a new name for an object that has some current + * name, possibly one of many names it currently has. + * + * If \p link_type is #H5G_LINK_HARD, then \p cur_name must specify the + * name of an existing object and both names are interpreted relative + * to \p cur_loc_id and \p new_loc_id, respectively, which are either + * file identifiers or group identifiers. + * + * If \p link_type is #H5G_LINK_SOFT, then \p cur_name can be anything + * and is interpreted at lookup time relative to the group which + * contains the final component of \p new_name. For instance, if \p + * current_name is \Code{./foo}, \p new_name is \Code{./x/y/bar}, and a + * request is made for \Code{./x/y/bar}, then the actual object looked + * up is \Code{./x/y/./foo}. + + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, + const char *new_name); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Renames an object within an HDF5 file + * + * \fg_loc_id{src_loc_id} + * \param[in] src_name Object's original name + * \param[in] dst_name Object's new name + * + * \return \herr_t + * + * \deprecated This function is deprecated. + * + * \details H5Gmove() renames an object within an HDF5 file. The original name, + * \p src_name, is unlinked from the group graph and the new name, \p + * dst_name, is inserted as an atomic operation. Both names are + * interpreted relative to \p loc_id, which is either a file or a group + * identifier. + * + * \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. + * + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Renames an object within an HDF5 file + * + * \fg_loc_id{src_loc_id} + * \param[in] src_name Object's original name + * \fg_loc_id{dst_loc_id} + * \param[in] dst_name Object's new name + * + * \return \herr_t + * + * \deprecated This function is deprecated. + * + * \details H5Gmove2() renames an object within an HDF5 file. The original name, + * \p src_name, is unlinked from the group graph and the new name, \p + * dst_name, is inserted as an atomic operation. + * + * \p src_name and \p dst_name are interpreted relative to \p + * src_loc_id and \p dst_loc_id, respectively, which are either file or + * group identifiers. + * + * \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. + * + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Removes the link to an object from a group + * + * \fg_loc_id{loc_id} + * \param[in] name Name of the object to unlink + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function H5Ldelete(). + * + * \details H5Gunlink() removes the object specified by \p name from the group + * graph and decrements the link count for the object to which \p name + * points. This action eliminates any association between name and the + * object to which name pointed. + * + * Object headers keep track of how many hard links refer to an object; + * when the link count reaches zero, the object can be removed from the + * file. Objects which are open are not removed until all identifiers + * to the object are closed. + * + * If the link count reaches zero, all file space associated with the + * object will be released, i.e., identified in memory as freespace. If + * 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 + * 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. + * + * \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. + * + * \version 1.8.0 Function deprecated in this release. + * + */ H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name); -H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, - char *buf/*out*/); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Returns the name of the object that the symbolic link points to + * + * \fg_loc_id{loc_id} + * \param[in] name Symbolic link to the object whose name is to be returned + * \param[in] size Maximum number of characters of value to be returned + * \param[out] buf A buffer to hold the name of the object being sought + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function H5Lget_val(). + * + * \details H5Gget_linkval() returns up to size characters of the name of the + * object that the symbolic link name points to. + * + * The parameter \p loc_id is a file or group identifier. + * + * The parameter \p name must be a symbolic link pointing to the + * desired object and must be defined relative to \p loc_id. + * + * If size is smaller than the size of the returned object name, then + * the name stored in the buffer value will not be \c NULL terminated. + * + * This function fails if \p name is not a symbolic link. The presence + * of a symbolic link can be tested by passing zero for \p size and \p + * NULL for value. + * + * This function should be used only after H5Lget_info1() (or the + * deprecated function H5Gget_objinfo()) has been called to verify that + * name is a symbolic link. + * + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Sets comment for specified object + * + * \fgdt_loc_id + * \param[in] name Name of the object whose comment is to be set or reset + * name must be \Code{'.'} (dot) if \p loc_id fully specifies + * the object for which the comment is to be set. + * \param[in] comment The new comment + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function + * H5Oset_comment(). + * + * \details H5Gset_comment() sets the comment for the object specified by \p + * loc_id and name to comment. Any previously existing comment is + * overwritten. + * + * \p loc_id can specify any object in the file. name can be one of the + * following: + * \li The name of the object relative to \p loc_id + * \li An absolute name of the object, starting from \c /, the file’s + * root group + * \li A dot (\c .), if \p loc_id fully specifies the object + * + * If \p comment is the empty string or a null pointer, the comment + * message is removed from the object. + * + * Comments should be relatively short, null-terminated, ASCII strings. + * + * Comments can be attached to any object that has an object header, + * e.g., datasets, groups, and named datatypes, but not symbolic links. + * + * \version 1.8.0 Function deprecated in this release. + * + */ H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); -H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, - char *buf); -H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, - H5G_iterate_t op, void *op_data); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Retrieves comment for specified object + * + * \fgdt_loc_id + * \param[in] name Name of the object whose comment is to be set or reset + * name must be \Code{'.'} (dot) if \p loc_id fully specifies + * the object for which the comment is to be set. + * \param[in] bufsize Maximum number of comment characters to be returned in \p buf. + * \param[in] buf The comment + * + * \return Returns the number of characters in the comment, counting the \c NULL + * terminator, if successful; the value returned may be larger than + * \p bufsize. Otherwise returns a negative value. + * + * \deprecated This function is deprecated in favor of the function + * H5Oget_comment(). + * + * \details H5Gget_comment() retrieves the comment for the the object specified + * by \p loc_id and \p name. The comment is returned in the buffer \p + * buf. + * + * \p loc_id can specify any object in the file. name can be one of the + * following: + * \li The name of the object relative to \p loc_id + * \li An absolute name of the object, starting from \c /, the file’s + * root group + * \li A dot (\c .), if \p loc_id fully specifies the object + * + * At most bufsize characters, including a null-terminator, are + * returned in \p buf. The returned value is not null-terminated if the + * comment is longer than the supplied buffer. If the size of the + * comment is unknown, a preliminary \p H5Gget_comment() call will + * return the size of the comment, including space for the + * null-terminator. + * + * If an object does not have a comment, the empty string is returned + * in comment. + * + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Iterates over the entries of a group invoking a callback for each + * entry encountered + * + * \fg_loc_id + * \param[in] name Group over which the iteration is performed + * \param[in,out] idx Location at which to begin the iteration + * \param[in] op Operation to be performed on an object at each step of the + * iteration + * \param[in,out] op_data Data associated with the operation + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function + * H5Literate1(). + * + * \details H5Giterate() iterates over the members of name in the file or group + * specified with \p loc_id. For each object in the group, the \p + * op_data and some additional information, specified below, are passed + * to the operator 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. H5Giterate() does not + * recursively follow links into subgroups of the specified group. + * + * The prototype for \ref H5G_iterate_t is: + * \snippet this H5G_iterate_t_snip + * + * The operation receives the group identifier for the group being + * iterated over, \p group, the name of the current object within + * the group, \p name, and the pointer to the operator data + * passed in to H5Giterate(), \p op_data. + * + * The return values from an operator are: + * \li Zero causes the iterator to continue, returning zero when all + * group members have been processed. + * \li Positive causes the iterator to immediately return that positive + * value, indicating short-circuit success. The iterator can be + * restarted at the next group member. + * \li Negative causes the iterator to immediately return that value, + * indicating failure. The iterator can be restarted at the next + * group member. + * + * H5Giterate() assumes that the membership of the group identified by + * \p name remains unchanged through the iteration. If the membership + * changes during the iteration, the function's behavior is undefined. + * + * H5Giterate() is not recursive. In particular, if a member of \p name + * is found to be a group, call it \c subgroup_a, H5Giterate() does not + * examine the members of \c subgroup_a. When recursive iteration is + * required, the application must handle the recursion, explicitly + * calling H5Giterate() on discovered subgroups. + + * \version 1.8.0 Function deprecated in this release. + * + */ +H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx, H5G_iterate_t op, void *op_data); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Returns number of objects in the group specified by its identifier + * + * \fg_loc_id + * \param[out] num_objs Number of objects in the group + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the function H5Gget_info(). + * + * \details H5Gget_num_objs() returns number of objects in a group. Group is + * specified by its identifier \p loc_id. If a file identifier is + * passed in, then the number of objects in the root group is returned. + * + * \version 1.8.0 Function deprecated in this release. + * + */ H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); -H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); -H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name, - size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Returns information about an object. + * + * \fgdt_loc_id + * \param[in] name Name of the object for which status is being sought + * \param[in] follow_link Link flag + * \param[out] statbuf Buffer in which to return information about the object + * + * \return \herr_t + * + * \deprecated This function is deprecated in favor of the functions H5Oget_info() + * and H5Lget_info1(). + * + * \details H5Gget_objinfo() returns information about the specified object + * through the \p statbuf argument. + * + * A file or group identifier, \p loc_id, and an object name, \p name, + * relative to \p loc_id, are commonly used to specify the + * object. However, if the object identifier is already known to the + * application, an alternative approach is to use that identifier, \c + * obj_id, in place of \p loc_id, and a dot (\c .) in place of \p + * name. Thus, the alternative versions of the first portion of an + * H5Gget_objinfo() call would be as follows: + * \code + * H5Gget_objinfo (loc_id name ...) + * H5Gget_objinfo (obj_id . ...) + * \endcode + * + * If the object is a symbolic link and follow_link is zero (0), then + * the information returned describes the link itself; otherwise the + * link is followed and the information returned describes the object + * to which the link points. If \p follow_link is non-zero but the + * final symbolic link is dangling (does not point to anything), then + * an error is returned. The \p statbuf fields are undefined for an + * error. The existence of an object can be tested by calling this + * function with a \c NULL \p statbuf. + * + * H5Gget_objinfo() fills in the following data structure (defined in + * H5Gpublic.h): + * \snippet this H5G_stat_t_snip + * + * where \ref H5O_stat_t (defined in H5Opublic.h) is: + * \snippet H5Opublic.h H5O_stat_t_snip + * + * \attention Some systems will be able to record the time accurately but unable + * to retrieve the correct time; such systems (e.g., Irix64) will + * report an \c mtime value of 0 (zero). + * + * \version 1.8.0 Function deprecated in this release. + * \version 1.6.1 Two new fields were added to the \ref H5G_stat_t struct in + * this release. + * + */ +H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, + H5G_stat_t *statbuf /*out*/); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Returns a name of an object specified by an index + * + * \fg_loc_id + * \param[in] idx Transient index identifying object + * \param[in,out] name Pointer to user-provided buffer the object name + * \param[in] size Name length + * + * \return Returns the size of the object name if successful, or 0 if no name is + * associated with the group identifier. Otherwise returns a negative + * value. + * + * \deprecated This function is deprecated in favor of the function H5Lget_name_by_idx(). + * + * \details H5Gget_objname_by_idx() returns a name of the object specified by + * the index \p idx in the group \p loc_id. + * + * The group is specified by a group identifier \p loc_id. If + * preferred, a file identifier may be passed in \p loc_id; that file's + * root group will be assumed. + * + * \p idx is the transient index used to iterate through the objects in + * the group. The value of \p idx is any nonnegative number less than + * the total number of objects in the group, which is returned by the + * function H5Gget_num_objs(). Note that this is a transient index; an + * object may have a different index each time a group is opened. + * + * The object name is returned in the user-specified buffer \p name. + * + * If the size of the provided buffer \p name is less or equal the + * 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 + * 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 + * name. + * + * \version 1.8.0 Function deprecated in this release. + * \since 1.6.0 + * + */ +H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5G + * + * \brief Returns the type of an object specified by an index + * + * \fg_loc_id + * \param[in] idx Transient index identifying object + * + * \return Returns the type of the object if successful. Otherwise returns a + * negative value. + * + * \deprecated This function is deprecated in favor of the function H5Oget_info(). + * + * \details H5Gget_objtype_by_idx() returns the type of the object specified by + * the index \p idx in the group \p loc_id. + * + * The group is specified by a group identifier \p loc_id. If + * preferred, a file identifier may be passed in \p loc_id; that file's + * root group will be assumed. + * + * \p idx is the transient index used to iterate through the objects in + * the group. This parameter is described in more detail in the + * discussion of H5Gget_objname_by_idx(). + * + * \version 1.8.0 Function deprecated in this release. + * \version 1.6.0 The function return type changed from \c int to the enumerated + * type \ref H5G_obj_t. + * \since 1.6.0 + * + */ H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -175,5 +1087,4 @@ H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); #ifdef __cplusplus } #endif -#endif /* _H5Gpublic_H */ - +#endif /* H5Gpublic_H */ diff --git a/src/H5Groot.c b/src/H5Groot.c index 79b7075a80a..997d187cc81 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,58 +26,48 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property Lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G_rootof * @@ -106,7 +96,7 @@ H5G_rootof(H5F_t *f) HDassert(f->shared); /* Walk to top of mounted files */ - while(f->parent) + while (f->parent) f = f->parent; /* Sanity check */ @@ -115,15 +105,14 @@ H5G_rootof(H5F_t *f) HDassert(f->shared->root_grp); /* Check to see if the root group was opened through a different - * "top" file, and switch it to point at the current "top" file. - */ - if(f->shared->root_grp->oloc.file != f) + * "top" file, and switch it to point at the current "top" file. + */ + if (f->shared->root_grp->oloc.file != f) f->shared->root_grp->oloc.file = f; FUNC_LEAVE_NOAPI(f->shared->root_grp) } /* end H5G_rootof() */ - /*------------------------------------------------------------------------- * Function: H5G_mkroot * @@ -144,12 +133,12 @@ H5G_rootof(H5F_t *f) herr_t H5G_mkroot(H5F_t *f, hbool_t create_root) { - H5G_loc_t root_loc; /* Root location information */ - H5G_obj_create_t gcrt_info; /* Root group object creation info */ - htri_t stab_exists = -1; /* Whether the symbol table exists */ - hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ - hbool_t path_init = FALSE; /* Whether path was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t root_loc; /* Root location information */ + H5G_obj_create_t gcrt_info; /* Root group object creation info */ + htri_t stab_exists = -1; /* Whether the symbol table exists */ + hbool_t sblock_dirty = FALSE; /* Whether superblock was dirtied */ + hbool_t path_init = FALSE; /* Whether path was initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -159,19 +148,19 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) HDassert(f->shared->sblock); /* Check if the root group is already initialized */ - if(f->shared->root_grp) + if (f->shared->root_grp) HGOTO_DONE(SUCCEED) /* Create information needed for group nodes */ - if(H5G__node_init(f) < 0) + if (H5G__node_init(f) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info") /* * Create the group pointer */ - if(NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) + if (NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { + if (NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ @@ -186,108 +175,109 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) * If there is no root object then create one. The root group always starts * with a hard link count of one since it's pointed to by the superblock. */ - if(create_root) { + if (create_root) { /* Create root group */ /* (Pass the FCPL which is a sub-class of the group creation property class) */ - gcrt_info.gcpl_id = f->shared->fcpl_id; + gcrt_info.gcpl_id = f->shared->fcpl_id; gcrt_info.cache_type = H5G_NOTHING_CACHED; - if(H5G__obj_create(f, &gcrt_info, root_loc.oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") - if(1 != H5O_link(root_loc.oloc, 1)) - HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") + if (H5G__obj_create(f, &gcrt_info, root_loc.oloc /*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") + if (1 != H5O_link(root_loc.oloc, 1)) + HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") /* Decrement refcount on root group's object header in memory */ - if(H5O_dec_rc_by_loc(root_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on root group's object header") + if (H5O_dec_rc_by_loc(root_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, + "unable to decrement refcount on root group's object header") /* Mark superblock dirty, so root group info is flushed */ sblock_dirty = TRUE; /* Create the root group symbol table entry */ HDassert(!f->shared->sblock->root_ent); - if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { + if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { /* Allocate space for the root group symbol table entry */ - if(NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) + if (NULL == (f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") /* Initialize the root group symbol table entry */ f->shared->sblock->root_ent->type = gcrt_info.cache_type; - if(gcrt_info.cache_type != H5G_NOTHING_CACHED) + if (gcrt_info.cache_type != H5G_NOTHING_CACHED) f->shared->sblock->root_ent->cache = gcrt_info.cache; - f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ - f->shared->sblock->root_ent->header = root_loc.oloc->addr; + f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ + f->shared->sblock->root_ent->header = root_loc.oloc->addr; } /* end if */ - } /* end if */ + } /* end if */ else { /* Create root group object location from f */ root_loc.oloc->addr = f->shared->sblock->root_addr; root_loc.oloc->file = f; - /* - * Open the root object as a group. - */ - if(H5O_open(root_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") + /* + * Open the root object as a group. + */ + if (H5O_open(root_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") /* Actions to take if the symbol table information is cached */ - if(f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) { + if (f->shared->sblock->root_ent && f->shared->sblock->root_ent->type == H5G_CACHED_STAB) { /* Check for the situation where the symbol table is cached but does * not exist. This can happen if, for example, an external link is * added to the root group. */ - if((stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") /* Remove the cache if the stab does not exist */ - if(!stab_exists) + if (!stab_exists) f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; #ifndef H5_STRICT_FORMAT_CHECKS /* If symbol table information is cached, check if we should replace the - * symbol table message with the cached symbol table information */ - else if(H5F_INTENT(f) & H5F_ACC_RDWR) { - H5O_stab_t cached_stab; + * symbol table message with the cached symbol table information */ + else if (H5F_INTENT(f) & H5F_ACC_RDWR) { + H5O_stab_t cached_stab; /* Retrieve the cached symbol table information */ cached_stab.btree_addr = f->shared->sblock->root_ent->cache.stab.btree_addr; - cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr; + cached_stab.heap_addr = f->shared->sblock->root_ent->cache.stab.heap_addr; /* Check if the symbol table message is valid, and replace with the - * cached symbol table if necessary */ - if(H5G__stab_valid(root_loc.oloc, &cached_stab) < 0) + * cached symbol table if necessary */ + if (H5G__stab_valid(root_loc.oloc, &cached_stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to verify symbol table") } /* end if */ -#endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ - } /* end else */ +#endif /* H5_STRICT_FORMAT_CHECKS */ + } /* end if */ + } /* end else */ /* Cache the root group's symbol table information in the root group symbol * table entry. It will have been allocated by now if it needs to be * present, so we don't need to check the superblock version. We do this if * we have write access, the root entry has been allocated (i.e. * super_vers < 2) and the stab info is not already cached. */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent - && f->shared->sblock->root_ent->type != H5G_CACHED_STAB) { - H5O_stab_t stab; /* Symbol table */ + if ((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->sblock->root_ent && + f->shared->sblock->root_ent->type != H5G_CACHED_STAB) { + H5O_stab_t stab; /* Symbol table */ /* Check if the stab message exists. It's possible for the root group * to use the latest version while the superblock is an old version. * If stab_exists is not -1 then we have already checked. */ - if(stab_exists == -1 && (stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) + if (stab_exists == -1 && (stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") - if(stab_exists) { + if (stab_exists) { /* Read the root group's symbol table message */ - if(NULL == H5O_msg_read(root_loc.oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(root_loc.oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") /* Update the root group symbol table entry */ - f->shared->sblock->root_ent->type = H5G_CACHED_STAB; + f->shared->sblock->root_ent->type = H5G_CACHED_STAB; f->shared->sblock->root_ent->cache.stab.btree_addr = stab.btree_addr; - f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr; + f->shared->sblock->root_ent->cache.stab.heap_addr = stab.heap_addr; /* Mark superblock dirty, so root group info is flushed */ sblock_dirty = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Create the path names for the root group's entry */ H5G__name_init(root_loc.path, "/"); @@ -298,49 +288,47 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) * exists. Don't count either the superblock extension or the root group * in the number of open objects in the file. */ - HDassert((1 == f->nopen_objs) || - (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr)); + HDassert((1 == f->nopen_objs) || (2 == f->nopen_objs && HADDR_UNDEF != f->shared->sblock->ext_addr)); f->nopen_objs--; done: /* In case of error, free various memory locations that may have been * allocated */ - if(ret_value < 0) { - if(f->shared->root_grp) { - if(path_init) + if (ret_value < 0) { + if (f->shared->root_grp) { + if (path_init) H5G_name_free(root_loc.path); - if(f->shared->root_grp->shared) + if (f->shared->root_grp->shared) f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared); f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); } /* end if */ - if(f->shared->sblock) + if (f->shared->sblock) f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->sblock->root_ent); } /* end if */ /* Mark superblock dirty in cache, if necessary */ - if(sblock_dirty) - if(H5AC_mark_entry_dirty(f->shared->sblock) < 0) + if (sblock_dirty) + if (H5AC_mark_entry_dirty(f->shared->sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_mkroot() */ - /*------------------------------------------------------------------------- -* Function: H5G_root_free -* -* Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). -* Does not close the group or decrement the reference count. -* Used to free memory used by the root group. -* -* Return: Success: Non-negative -* Failure: Negative -* -* Programmer: James Laird -* Tuesday, September 7, 2004 -* -*------------------------------------------------------------------------- -*/ + * Function: H5G_root_free + * + * Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). + * Does not close the group or decrement the reference count. + * Used to free memory used by the root group. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: James Laird + * Tuesday, September 7, 2004 + * + *------------------------------------------------------------------------- + */ herr_t H5G_root_free(H5G_t *grp) { @@ -354,12 +342,11 @@ H5G_root_free(H5G_t *grp) H5G_name_free(&(grp->path)); grp->shared = H5FL_FREE(H5G_shared_t, grp->shared); - grp = H5FL_FREE(H5G_t, grp); + grp = H5FL_FREE(H5G_t, grp); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_root_free() */ - /*------------------------------------------------------------------------- * Function: H5G_root_loc * @@ -376,8 +363,8 @@ H5G_root_free(H5G_t *grp) herr_t H5G_root_loc(H5F_t *f, H5G_loc_t *loc) { - H5G_t *root_grp; /* Pointer to root group's info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_t *root_grp; /* Pointer to root group's info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -389,9 +376,9 @@ H5G_root_loc(H5F_t *f, H5G_loc_t *loc) HDassert(root_grp); /* Build the group location for the root group */ - if(NULL == (loc->oloc = H5G_oloc(root_grp))) + if (NULL == (loc->oloc = H5G_oloc(root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (loc->path = H5G_nameof(root_grp))) + if (NULL == (loc->path = H5G_nameof(root_grp))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Patch up root group's object location to reflect this file */ @@ -399,12 +386,11 @@ H5G_root_loc(H5F_t *f, H5G_loc_t *loc) * share an underlying low-level file) */ /* (but only for non-mounted files) */ - if(!H5F_is_mount(f)) { - loc->oloc->file = f; + if (!H5F_is_mount(f)) { + loc->oloc->file = f; loc->oloc->holding_file = FALSE; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_root_loc() */ - diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 51adb7302ce..54b28b53200 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,25 +20,22 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -46,21 +43,21 @@ /* User data for finding link information from B-tree */ typedef struct { /* downward */ - const char *name; /* Name to search for */ - H5HL_t *heap; /* Local heap for group */ + const char *name; /* Name to search for */ + H5HL_t * heap; /* Local heap for group */ /* upward */ - H5O_link_t *lnk; /* Caller's link location */ + H5O_link_t *lnk; /* Caller's link location */ } H5G_stab_fnd_ud_t; /* Data passed through B-tree iteration for looking up a name by index */ 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 */ + char *name; /*member name to be returned */ } H5G_bt_it_gnbi_t; #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -68,10 +65,10 @@ 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 */ + H5G_obj_t type; /*member type to be returned */ } H5G_bt_it_gtbi_t; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -79,40 +76,33 @@ 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 */ - hbool_t found; /*whether we found the link */ + H5O_link_t *lnk; /*link to be returned */ + hbool_t found; /*whether we found the link */ } H5G_bt_it_lbi_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__stab_create_components * @@ -134,9 +124,9 @@ typedef struct H5G_bt_it_lbi_t { herr_t H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) { - H5HL_t *heap = NULL; /* Pointer to local heap */ - size_t name_offset; /* Offset of "" name */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_t *heap = NULL; /* Pointer to local heap */ + size_t name_offset; /* Offset of "" name */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -148,36 +138,34 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) HDassert(size_hint > 0); /* Create the B-tree */ - if(H5B_create(f, H5B_SNODE, NULL, &(stab->btree_addr)/*out*/) < 0) + if (H5B_create(f, H5B_SNODE, NULL, &(stab->btree_addr) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree") /* Create symbol table private heap */ - if(H5HL_create(f, size_hint, &(stab->heap_addr)/*out*/) < 0) + if (H5HL_create(f, size_hint, &(stab->heap_addr) /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Insert name into the heap */ - if(UFAIL == (name_offset = H5HL_insert(f, heap, (size_t)1, ""))) + if (H5HL_insert(f, heap, (size_t)1, "", &name_offset) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert name into heap") - /* - * B-tree's won't work if the first name isn't at the beginning + /* B-trees won't work if the first name isn't at the beginning * of the heap. */ HDassert(0 == name_offset); done: /* Release resources */ - if(heap && FAIL == H5HL_unprotect(heap)) + if (heap && FAIL == H5HL_unprotect(heap)) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_create_components() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_create * @@ -200,9 +188,9 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) herr_t H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab) { - size_t heap_hint; /* Local heap size hint */ - size_t size_hint; /* Local heap size hint */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t heap_hint; /* Local heap size hint */ + size_t size_hint; /* Local heap size hint */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -213,30 +201,32 @@ H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab HDassert(stab); /* Adjust the size hint, if necessary */ - if(ginfo->lheap_size_hint == 0) - heap_hint = 8 + /* "null" name inserted for B-tree */ - (ginfo->est_num_entries * H5HL_ALIGN(ginfo->est_name_len + 1)) + /* estimated size of names for links, aligned for inserting into local heap */ - H5HL_SIZEOF_FREE(grp_oloc->file); /* Free list entry in local heap */ + if (ginfo->lheap_size_hint == 0) + heap_hint = + 8 + /* "null" name inserted for B-tree */ + (ginfo->est_num_entries * + H5HL_ALIGN(ginfo->est_name_len + + 1)) + /* estimated size of names for links, aligned for inserting into local heap */ + H5HL_SIZEOF_FREE(grp_oloc->file); /* Free list entry in local heap */ else heap_hint = ginfo->lheap_size_hint; size_hint = MAX(heap_hint, H5HL_SIZEOF_FREE(grp_oloc->file) + 2); /* Go create the B-tree & local heap */ - if(H5G__stab_create_components(grp_oloc->file, stab, size_hint) < 0) + if (H5G__stab_create_components(grp_oloc->file, stab, size_hint) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create symbol table components") /* * Insert the symbol table message into the object header and the symbol * table entry. */ - if(H5O_msg_create(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME, stab) < 0) + if (H5O_msg_create(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME, stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_create() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_insert_real * @@ -252,12 +242,12 @@ H5G__stab_create(H5O_loc_t *grp_oloc, const H5O_ginfo_t *ginfo, H5O_stab_t *stab *------------------------------------------------------------------------- */ 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) +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 */ - H5G_bt_ins_t udata; /* Data to pass through B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -268,29 +258,28 @@ H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, HDassert(obj_lnk); /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ udata.common.name = name; udata.common.heap = heap; - udata.lnk = obj_lnk; - udata.obj_type = obj_type; - udata.crt_info = crt_info; + udata.lnk = obj_lnk; + udata.obj_type = obj_type; + udata.crt_info = crt_info; /* Insert into symbol table */ - if(H5B_insert(f, H5B_SNODE, stab->btree_addr, &udata) < 0) + if (H5B_insert(f, H5B_SNODE, stab->btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_insert_real() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_insert * @@ -306,13 +295,13 @@ H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, *------------------------------------------------------------------------- */ herr_t -H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info) +H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, + const void *crt_info) { - H5O_stab_t stab; /* Symbol table message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Symbol table message */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(grp_oloc && grp_oloc->file); @@ -320,17 +309,16 @@ H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, HDassert(obj_lnk); /* Retrieve symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") - if(H5G__stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, obj_type, crt_info) < 0) + if (H5G__stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, obj_type, crt_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_insert() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_remove * @@ -344,13 +332,12 @@ H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, *------------------------------------------------------------------------- */ herr_t -H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, - const char *name) +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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -358,31 +345,30 @@ H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, HDassert(name && *name); /* Read in symbol table message */ - if(NULL == H5O_msg_read(loc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(loc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(loc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(loc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ - udata.common.name = name; - udata.common.heap = heap; + udata.common.name = name; + udata.common.heap = heap; udata.grp_full_path_r = grp_full_path_r; /* Remove from symbol table */ - if(H5B_remove(loc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) + if (H5B_remove(loc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_remove() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_remove_by_idx * @@ -396,55 +382,54 @@ H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(grp_oloc && grp_oloc->file); /* Look up name of link to remove, by index */ - if(H5G__stab_lookup_by_idx(grp_oloc, order, n, &obj_lnk) < 0) + if (H5G__stab_lookup_by_idx(grp_oloc, order, n, &obj_lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get link information") lnk_copied = TRUE; /* Read in symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Initialize data to pass through B-tree */ - udata.common.name = obj_lnk.name; - udata.common.heap = heap; + udata.common.name = obj_lnk.name; + udata.common.heap = heap; udata.grp_full_path_r = grp_full_path_r; /* Remove link from symbol table */ - if(H5B_remove(grp_oloc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) + if (H5B_remove(grp_oloc->file, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &obj_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_remove_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_delete * @@ -460,9 +445,9 @@ 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 */ - H5G_bt_rm_t udata; /*data to pass through B-tree */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -472,7 +457,7 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) HDassert(H5F_addr_defined(stab->heap_addr)); /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(f, stab->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Set up user data for B-tree deletion */ @@ -480,27 +465,26 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) udata.common.heap = heap; /* Delete entire B-tree */ - if(H5B_delete(f, H5B_SNODE, stab->btree_addr, &udata) < 0) + if (H5B_delete(f, H5B_SNODE, stab->btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table B-tree") /* Release resources */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") heap = NULL; /* Delete local heap for names */ - if(H5HL_delete(f, stab->heap_addr) < 0) + if (H5HL_delete(f, stab->heap_addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete symbol table heap") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_delete() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_iterate * @@ -514,85 +498,84 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) *------------------------------------------------------------------------- */ 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) +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 */ - H5O_stab_t stab; /* Info about symbol table */ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ - FUNC_ENTER_PACKAGE_TAG(oloc->addr) + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(oloc); HDassert(op); /* Get the B-tree info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Check on iteration order */ /* ("native" iteration order is increasing for this link storage mechanism) */ - if(order != H5_ITER_DEC) { - H5G_bt_it_it_t udata; /* User data to pass to B-tree callback */ + if (order != H5_ITER_DEC) { + H5G_bt_it_it_t udata; /* User data to pass to B-tree callback */ /* Build udata to pass through H5B_iterate() to H5G__node_iterate() */ - udata.heap = heap; - udata.skip = skip; + udata.heap = heap; + udata.skip = skip; udata.final_ent = last_lnk; - udata.op = op; - udata.op_data = op_data; + udata.op = op; + udata.op_data = op_data; /* Iterate over the group members */ - if((ret_value = H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_iterate, &udata)) < 0) + if ((ret_value = H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_iterate, &udata)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); /* Check for too high of a starting index (ex post facto :-) */ /* (Skipping exactly as many entries as are in the group is currently an error) */ - if(skip > 0 && skip >= *last_lnk) + if (skip > 0 && skip >= *last_lnk) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") } /* end if */ else { - H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */ + H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */ /* Build udata to pass through H5B_iterate() to H5G__node_build_table() */ udata.alloc_nlinks = 0; - udata.heap = heap; - udata.ltable = <able; + udata.heap = heap; + udata.ltable = <able; /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_build_table, &udata) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_build_table, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to build link table") /* Check for skipping out of bounds */ - if(skip > 0 && (size_t)skip >= ltable.nlinks) + if (skip > 0 && (size_t)skip >= ltable.nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Sort link table in correct iteration order */ - if(H5G__link_sort_table(<able, H5_INDEX_NAME, order) < 0) + if (H5G__link_sort_table(<able, H5_INDEX_NAME, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") /* Iterate over links in table */ - if((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) + if ((ret_value = H5G__link_iterate_table(<able, skip, last_lnk, op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") - if(ltable.lnks && H5G__link_release_table(<able) < 0) + if (ltable.lnks && H5G__link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_iterate() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_count * @@ -608,8 +591,8 @@ H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, herr_t H5G__stab_count(const H5O_loc_t *oloc, hsize_t *num_objs) { - H5O_stab_t stab; /* Info about symbol table */ - herr_t ret_value = SUCCEED; + H5O_stab_t stab; /* Info about symbol table */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_TAG(oloc->addr) @@ -621,18 +604,17 @@ H5G__stab_count(const H5O_loc_t *oloc, hsize_t *num_objs) *num_objs = 0; /* Get the B-tree info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, num_objs) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, num_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_count() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_bh_size * @@ -648,9 +630,9 @@ H5G__stab_count(const H5O_loc_t *oloc, hsize_t *num_objs) herr_t H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info) { - hsize_t snode_size; /* Symbol table node size */ - H5B_info_t bt_info; /* B-tree node info */ - herr_t ret_value = SUCCEED; + hsize_t snode_size; /* Symbol table node size */ + H5B_info_t bt_info; /* B-tree node info */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -663,23 +645,22 @@ H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info) snode_size = 0; /* Get the B-tree & symbol table node size info */ - if(H5B_get_info(f, H5B_SNODE, stab->btree_addr, &bt_info, H5G__node_iterate_size, &snode_size) < 0) + if (H5B_get_info(f, H5B_SNODE, stab->btree_addr, &bt_info, H5G__node_iterate_size, &snode_size) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iteration operator failed") /* Add symbol table & B-tree node sizes to index info */ bh_info->index_size += snode_size + bt_info.size; /* Get the size of the local heap for the group */ - if(H5HL_heapsize(f, stab->heap_addr, &(bh_info->heap_size)) < 0) + if (H5HL_heapsize(f, stab->heap_addr, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_bh_size() */ - /*------------------------------------------------------------------------- - * Function: H5G_stab_get_name_by_idx_cb + * Function: H5G__stab_get_name_by_idx_cb * * Purpose: Callback for B-tree iteration 'by index' info query to * retrieve the name of a link @@ -693,14 +674,14 @@ H5G__stab_bh_size(H5F_t *f, const H5O_stab_t *stab, H5_ih_info_t *bh_info) *------------------------------------------------------------------------- */ static herr_t -H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(ent); @@ -709,17 +690,16 @@ H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) /* Get name offset in heap */ name_off = ent->name_off; - if((name = (const char *)H5HL_offset_into(udata->heap, name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table link name") - if((udata->name = H5MM_strdup(name)) == NULL) + if ((udata->name = H5MM_strdup(name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to duplicate symbol table link name") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_get_name_by_idx_cb */ +} /* end H5G__stab_get_name_by_idx_cb */ - /*------------------------------------------------------------------------- * Function: H5G__stab_get_name_by_idx * @@ -734,14 +714,13 @@ 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) +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 */ - 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 */ - ssize_t ret_value = -1; /* Return value */ + 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 */ + ssize_t ret_value = -1; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); @@ -752,19 +731,19 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t HDassert(oloc); /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Remap index for decreasing iteration order */ - if(order == H5_ITER_DEC) { - hsize_t nlinks = 0; /* Number of links in group */ + if (order == H5_ITER_DEC) { + hsize_t nlinks = 0; /* Number of links in group */ /* Iterate over the symbol table nodes, to count the links */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") /* Map decreasing iteration order index to increasing iteration order index */ @@ -772,46 +751,45 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t } /* end if */ /* Set iteration information */ - udata.common.idx = n; + udata.common.idx = n; udata.common.num_objs = 0; - udata.common.op = H5G_stab_get_name_by_idx_cb; - udata.heap = heap; - udata.name = NULL; - udata_valid = TRUE; + udata.common.op = H5G__stab_get_name_by_idx_cb; + udata.heap = heap; + udata.name = NULL; + udata_valid = TRUE; /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) + if (H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed") /* If we don't know the name now, we almost certainly went out of bounds */ - if(udata.name == NULL) + if (udata.name == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound") /* Get the length of the name */ ret_value = (ssize_t)HDstrlen(udata.name); /* Copy the name into the user's buffer, if given */ - if(name) { + if (name) { HDstrncpy(name, udata.name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; + if ((size_t)ret_value >= size) + name[size - 1] = '\0'; } /* end if */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") /* Free the duplicated name */ - if(udata_valid && udata.name != NULL) + if (udata_valid && udata.name != NULL) H5MM_xfree(udata.name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_get_name_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5G_stab_lookup_cb + * Function: H5G__stab_lookup_cb * * Purpose: B-tree 'find' callback to retrieve location for an object * @@ -825,24 +803,23 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t *------------------------------------------------------------------------- */ static herr_t -H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata) +H5G__stab_lookup_cb(const H5G_entry_t *ent, void *_udata) { - H5G_stab_fnd_ud_t *udata = (H5G_stab_fnd_ud_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_stab_fnd_ud_t *udata = (H5G_stab_fnd_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check for setting link info */ - if(udata->lnk) + if (udata->lnk) /* Convert the entry to a link */ - if(H5G__ent_to_link(udata->lnk, udata->heap, ent, udata->name) < 0) + if (H5G__ent_to_link(udata->lnk, udata->heap, ent, udata->name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_lookup_cb() */ +} /* end H5G__stab_lookup_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__stab_lookup * @@ -858,11 +835,11 @@ 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 */ - H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ + 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 */ - htri_t ret_value = FAIL; /* Return value */ + H5O_stab_t stab; /* Symbol table message */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -872,39 +849,38 @@ H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) HDassert(lnk); /* Retrieve the symbol table message for the group */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Set up user data to pass to 'find' operation callback */ udata.name = name; - udata.lnk = lnk; + udata.lnk = lnk; udata.heap = heap; /* Set up the user data for actual B-tree find operation */ bt_udata.common.name = name; bt_udata.common.heap = heap; - bt_udata.op = H5G_stab_lookup_cb; - bt_udata.op_data = &udata; + bt_udata.op = H5G__stab_lookup_cb; + bt_udata.op_data = &udata; /* Search the B-tree */ - if((ret_value = H5B_find(grp_oloc->file, H5B_SNODE, stab.btree_addr, &bt_udata)) < 0) + if ((ret_value = H5B_find(grp_oloc->file, H5B_SNODE, stab.btree_addr, &bt_udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup() */ - /*------------------------------------------------------------------------- - * Function: H5G_stab_lookup_by_idx_cb + * Function: H5G__stab_lookup_by_idx_cb * * Purpose: Callback for B-tree iteration 'by index' info query to * retrieve the link @@ -918,32 +894,31 @@ H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) *------------------------------------------------------------------------- */ static herr_t -H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + const char * name; /* Pointer to name string in heap */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(ent); HDassert(udata && udata->heap); /* Get a pointer to the link name */ - if((name = (const char *)H5HL_offset_into(udata->heap, ent->name_off)) == NULL) + if ((name = (const char *)H5HL_offset_into(udata->heap, ent->name_off)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table link name") /* Convert the entry to a link */ - if(H5G__ent_to_link(udata->lnk, udata->heap, ent, name) < 0) + if (H5G__ent_to_link(udata->lnk, udata->heap, ent, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") udata->found = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_lookup_by_idx_cb */ +} /* end H5G__stab_lookup_by_idx_cb */ - /*------------------------------------------------------------------------- * Function: H5G__stab_lookup_by_idx * @@ -957,13 +932,12 @@ 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) +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 */ - H5G_bt_it_lbi_t udata; /* Iteration information */ - H5O_stab_t stab; /* Symbol table message */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -972,19 +946,19 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ HDassert(lnk); /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to protect symbol table heap") /* Remap index for decreasing iteration order */ - if(order == H5_ITER_DEC) { - hsize_t nlinks = 0; /* Number of links in group */ + if (order == H5_ITER_DEC) { + hsize_t nlinks = 0; /* Number of links in group */ /* Iterate over the symbol table nodes, to count the links */ - if(H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) + if (H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_sumup, &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") /* Map decreasing iteration order index to increasing iteration order index */ @@ -992,31 +966,31 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ } /* end if */ /* Set iteration information */ - udata.common.idx = n; + udata.common.idx = n; udata.common.num_objs = 0; - udata.common.op = H5G_stab_lookup_by_idx_cb; - udata.heap = heap; - udata.lnk = lnk; - udata.found = FALSE; + udata.common.op = H5G__stab_lookup_by_idx_cb; + udata.heap = heap; + udata.lnk = lnk; + udata.found = FALSE; /* Iterate over the group members */ - if(H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) + if (H5B_iterate(grp_oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed") /* If we didn't find the link, we almost certainly went out of bounds */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup_by_idx() */ #ifndef H5_STRICT_FORMAT_CHECKS - + /*------------------------------------------------------------------------- * Function: H5G__stab_valid * @@ -1041,173 +1015,58 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ 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 */ - hbool_t changed = FALSE; /* Whether stab has been modified */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Current symbol table */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + hbool_t changed = FALSE; /* Whether stab has been modified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) /* Read the symbol table message */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message"); /* Check if the symbol table message's b-tree address is valid */ - if(H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) { + if (H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) { /* Address is invalid, try the b-tree address in the alternate symbol * table message */ - if(!alt_stab || H5B_valid(grp_oloc->file, H5B_SNODE, alt_stab->btree_addr) < 0) + if (!alt_stab || H5B_valid(grp_oloc->file, H5B_SNODE, alt_stab->btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to locate b-tree") else { /* The alternate symbol table's b-tree address is valid. Adjust the * symbol table message in the group. */ stab.btree_addr = alt_stab->btree_addr; - changed = TRUE; + changed = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check if the symbol table message's heap address is valid */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) { + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) { /* Address is invalid, try the heap address in the alternate symbol * table message */ - if(!alt_stab || NULL == (heap = H5HL_protect(grp_oloc->file, alt_stab->heap_addr, H5AC__READ_ONLY_FLAG))) + if (!alt_stab || + NULL == (heap = H5HL_protect(grp_oloc->file, alt_stab->heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "unable to locate heap") else { /* The alternate symbol table's heap address is valid. Adjust the * symbol table message in the group. */ stab.heap_addr = alt_stab->heap_addr; - changed = TRUE; + changed = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Update the symbol table message and clear errors if necessary */ - if(changed) { + if (changed) { H5E_clear_stack(NULL); - if(H5O_msg_write(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME | H5O_UPDATE_FORCE, &stab) < 0) + if (H5O_msg_write(grp_oloc, H5O_STAB_ID, 0, H5O_UPDATE_TIME | H5O_UPDATE_FORCE, &stab) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to correct symbol table message") } /* end if */ done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_valid */ #endif /* H5_STRICT_FORMAT_CHECKS */ - -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G_stab_get_type_by_idx_cb - * - * Purpose: Callback for B-tree iteration 'by index' info query to - * retrieve the type of an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Nov 7, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata) -{ - H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Sanity check */ - HDassert(ent); - HDassert(udata); - - /* Check for a soft link */ - switch(ent->type) { - case H5G_CACHED_SLINK: - udata->type = H5G_LINK; - break; - - case H5G_CACHED_ERROR: - case H5G_NOTHING_CACHED: - case H5G_CACHED_STAB: - case H5G_NCACHED: - default: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = udata->f; - HDassert(H5F_addr_defined(ent->header)); - tmp_oloc.addr = ent->header; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - udata->type = H5G_map_obj_type(obj_type); - } - break; - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_get_type_by_idx_cb */ - - -/*------------------------------------------------------------------------- - * Function: H5G__stab_get_type_by_idx - * - * Purpose: Private function for H5Gget_objtype_by_idx. - * Returns the type of objects in the group by giving index. - * - * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * - * Failure: UNKNOWN - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx) -{ - H5O_stab_t stab; /* Info about local heap & B-tree */ - H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE_TAG(oloc->addr) - - /* Sanity check */ - HDassert(oloc); - - /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "unable to determine local heap address") - - /* Set iteration information */ - udata.common.idx = idx; - udata.common.num_objs = 0; - udata.common.op = H5G_stab_get_type_by_idx_cb; - udata.f = oloc->file; - udata.type = H5G_UNKNOWN; - - /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed") - - /* If we don't know the type now, we almost certainly went out of bounds */ - if(udata.type == H5G_UNKNOWN) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound") - - /* Set the return value */ - ret_value = udata.type; - -done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5G__stab_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gtest.c b/src/H5Gtest.c index bea77803e3c..d2f3f90e849 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,57 +21,49 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ -#define H5G_TESTING /*suppress warning about H5G testing funcs*/ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ +#define H5G_TESTING /*suppress warning about H5G testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5G__is_empty_test @@ -94,105 +86,104 @@ htri_t H5G__is_empty_test(hid_t gid) { - 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 */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* "New format" checks */ /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { + if (msg_exists > 0) { /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") HGOTO_DONE(FALSE) } /* end if */ /* Check for a link info message */ - if((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) + if ((linfo_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(linfo_exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if (linfo_exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Sanity check that new group format shouldn't have old messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(H5F_addr_defined(linfo.fheap_addr)) + if (H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE(FALSE) - if(H5F_addr_defined(linfo.name_bt2_addr)) + if (H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE(FALSE) - if(H5F_addr_defined(linfo.corder_bt2_addr)) + if (H5F_addr_defined(linfo.corder_bt2_addr)) HGOTO_DONE(FALSE) /* Check for link count */ - if(linfo.nlinks > 0) + if (linfo.nlinks > 0) HGOTO_DONE(FALSE) } /* end if */ /* "Old format" checks */ /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { - H5O_stab_t stab; /* Info about local heap & B-tree */ - hsize_t nlinks; /* Number of links in the group */ + if (msg_exists > 0) { + H5O_stab_t stab; /* Info about local heap & B-tree */ + hsize_t nlinks; /* Number of links in the group */ /* Sanity check that old group format shouldn't have new messages */ - if(linfo_exists > 0) + if (linfo_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link info messages found") - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and group info messages found") /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol table message") /* Get the count of links in the group */ - if(H5G__stab_count(&(grp->oloc), &nlinks) < 0) + if (H5G__stab_count(&(grp->oloc), &nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to count links") /* Check for link count */ - if(nlinks > 0) + if (nlinks > 0) HGOTO_DONE(FALSE) } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__is_empty_test() */ +} /* H5G__is_empty_test() */ - /*-------------------------------------------------------------------------- NAME H5G__has_links_test @@ -215,52 +206,51 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) + if (msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") /* Check if we should retrieve the number of link messages */ - if(nmsgs) { - int msg_count; /* Number of messages of a type */ + if (nmsgs) { + int msg_count; /* Number of messages of a type */ /* Check how many link messages there are */ - if((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_count = H5O_msg_count(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count link messages") *nmsgs = (unsigned)msg_count; } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__has_links_test() */ +} /* H5G__has_links_test() */ - /*-------------------------------------------------------------------------- NAME H5G__has_stab_test @@ -282,42 +272,41 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) + if (msg_exists == 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__has_stab_test() */ +} /* H5G__has_stab_test() */ - /*-------------------------------------------------------------------------- NAME H5G__is_new_dense_test @@ -341,59 +330,58 @@ H5G__has_stab_test(hid_t gid) htri_t H5G__is_new_dense_test(hid_t gid) { - 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 */ + 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 */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Check if the group has a symbol table message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has any link messages */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) + if (msg_exists > 0) HGOTO_DONE(FALSE) /* Check if the group has link info message */ - if((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) + if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) { - H5O_linfo_t linfo; /* Link info message */ + if (msg_exists > 0) { + H5O_linfo_t linfo; /* Link info message */ /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(!H5F_addr_defined(linfo.fheap_addr)) + if (!H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE(FALSE) - if(!H5F_addr_defined(linfo.name_bt2_addr)) + if (!H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE(FALSE) } /* end if */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__is_new_dense_test() */ +} /* H5G__is_new_dense_test() */ - /*-------------------------------------------------------------------------- NAME H5G__new_dense_info_test @@ -418,21 +406,21 @@ 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 */ - H5O_linfo_t linfo; /* Link info message */ - H5G_t *grp = NULL; /* Pointer to group */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -440,32 +428,34 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) H5_BEGIN_TAG(grp->oloc.addr); /* Get the link info */ - if(H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) + if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ - if(!H5F_addr_defined(linfo.fheap_addr)) + if (!H5F_addr_defined(linfo.fheap_addr)) HGOTO_DONE_TAG(FAIL) - if(!H5F_addr_defined(linfo.name_bt2_addr)) + if (!H5F_addr_defined(linfo.name_bt2_addr)) HGOTO_DONE_TAG(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(grp->oloc.file, linfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(grp->oloc.file, linfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, name_count) < 0) + if (H5B2_get_nrec(bt2_name, name_count) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ - if(H5F_addr_defined(linfo.corder_bt2_addr)) { + if (H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(grp->oloc.file, linfo.corder_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ - if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + if (H5B2_get_nrec(bt2_corder, corder_count) < 0) + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; @@ -475,17 +465,16 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__new_dense_info_test() */ +} /* H5G__new_dense_info_test() */ - /*-------------------------------------------------------------------------- NAME H5G__lheap_size_test @@ -508,38 +497,37 @@ 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 */ - H5O_stab_t stab; /* Symbol table message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Make certain the group has a symbol table message */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbol table message") /* Check the size of the local heap for the group */ - if(H5HL_get_size(grp->oloc.file, stab.heap_addr, lheap_size) < 0) + if (H5HL_get_size(grp->oloc.file, stab.heap_addr, lheap_size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't query local heap size") done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__lheap_size_test() */ +} /* H5G__lheap_size_test() */ - /*-------------------------------------------------------------------------- NAME H5G__user_path_test @@ -565,10 +553,10 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -577,16 +565,16 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_hidden); /* Get pointer to object for ID */ - if(NULL == (obj_ptr = H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") + if (NULL == (obj_ptr = H5VL_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the symbol table entry */ - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_GROUP: obj_path = H5G_nameof((H5G_t *)obj_ptr); break; @@ -597,24 +585,28 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_DATATYPE: /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t *)obj_ptr)) + if (!H5T_is_named((H5T_t *)obj_ptr)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype") obj_path = H5T_nameof((H5T_t *)obj_ptr); break; + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, 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_REFERENCE: 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_ARGS, H5E_BADTYPE, FAIL, "unknown data object type") @@ -622,11 +614,11 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_path); /* Retrieve a copy of the user path and put it into the buffer */ - if(obj_path->user_path_r) { + if (obj_path->user_path_r) { ssize_t len = H5RS_len(obj_path->user_path_r); /* Set the user path, if given */ - if(user_path) + if (user_path) HDstrncpy(user_path, H5RS_get_str(obj_path->user_path_r), (size_t)(len + 1)); /* Set the length of the path */ @@ -637,17 +629,16 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign } /* end if */ else { *user_path_len = 0; - *obj_hidden = 0; + *obj_hidden = 0; } /* end else */ done: - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5G__user_path_test() */ +} /* H5G__user_path_test() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stab_test * @@ -666,44 +657,42 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign herr_t H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) { - H5O_stab_t stab; /* Symbol table */ - H5HL_t *heap = NULL; /* Pointer to local heap */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_stab_t stab; /* Symbol table */ + H5HL_t * heap = NULL; /* Pointer to local heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) /* Verify that stab info is cached in ent */ - if(ent->type != H5G_CACHED_STAB) + if (ent->type != H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "symbol table information is not cached") /* Read the symbol table message from the group */ - if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") /* Verify that the cached symbol table info matches the symbol table message * in the object header. */ - if((ent->cache.stab.btree_addr != stab.btree_addr) - || (ent->cache.stab.heap_addr != stab.heap_addr)) + if ((ent->cache.stab.btree_addr != stab.btree_addr) || (ent->cache.stab.heap_addr != stab.heap_addr)) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "cached stab info does not match object header") /* Verify that the btree address is valid */ - if(H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) + if (H5B_valid(grp_oloc->file, H5B_SNODE, stab.btree_addr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "b-tree address is invalid") /* Verify that the heap address is valid */ - if(NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HL_protect(grp_oloc->file, stab.heap_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap address is invalid") done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__verify_cached_stab_test() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stabs_test_cb * @@ -720,16 +709,16 @@ H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) *------------------------------------------------------------------------- */ static int -H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, - haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void H5_ATTR_UNUSED *udata) +H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, + const void H5_ATTR_UNUSED *_rt_key, void H5_ATTR_UNUSED *udata) { - H5G_node_t *sn = NULL; - H5O_loc_t targ_oloc; - H5O_t *targ_oh = NULL; - htri_t stab_exists; - H5O_stab_t stab; - unsigned i; - int ret_value = H5_ITER_CONT; + H5G_node_t *sn = NULL; + H5O_loc_t targ_oloc; + H5O_t * targ_oh = NULL; + htri_t stab_exists; + H5O_stab_t stab; + unsigned i; + int ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -738,64 +727,64 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, HDassert(H5F_addr_defined(addr)); /* Load the node */ - if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) + if (NULL == (sn = (H5G_node_t *)H5AC_protect(f, H5AC_SNODE, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") /* Check each target object to see if its stab message (if present) matches * the cached stab (if present). If one exists, both must exist. */ /* Initialize constant fields in target oloc */ - targ_oloc.file = f; + targ_oloc.file = f; targ_oloc.holding_file = FALSE; /* Iterate over entries */ - for(i = 0; i < sn->nsyms; i++) { + for (i = 0; i < sn->nsyms; i++) { /* Update oloc address */ targ_oloc.addr = sn->entry[i].header; /* Load target object header */ - if(NULL == (targ_oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (targ_oh = H5O_protect(&targ_oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to protect target object header") /* Check if a symbol table message exists */ - if((stab_exists = H5O_msg_exists_oh(targ_oh, H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists_oh(targ_oh, H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to check for STAB message") - if(stab_exists) { + if (stab_exists) { /* Read symbol table message */ - if(NULL == H5O_msg_read_oh(f, targ_oh, H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read_oh(f, targ_oh, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to read STAB message") /* Check if the stab matches the cached stab info */ - if(sn->entry[i].type != H5G_CACHED_STAB) + if (sn->entry[i].type != H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "STAB message is not cached in group node") - if((sn->entry[i].cache.stab.btree_addr != stab.btree_addr) - || (sn->entry[i].cache.stab.heap_addr != stab.heap_addr)) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "cached symbol table information is incorrect") + if ((sn->entry[i].cache.stab.btree_addr != stab.btree_addr) || + (sn->entry[i].cache.stab.heap_addr != stab.heap_addr)) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, + "cached symbol table information is incorrect") } - else if(sn->entry[i].type == H5G_CACHED_STAB) + else if (sn->entry[i].type == H5G_CACHED_STAB) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "nonexistent STAB message is cached") /* Unprotect target object */ - if(H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); targ_oh = NULL; } /* end for */ done: - if(sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") - if(targ_oh) { + if (targ_oh) { HDassert(ret_value == H5_ITER_ERROR); - if(H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(&targ_oloc, targ_oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__verify_cached_stabs_test_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__verify_cached_stabs_test * @@ -816,12 +805,12 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, herr_t H5G__verify_cached_stabs_test(hid_t gid) { - 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 */ - haddr_t prev_tag = HADDR_UNDEF; /* Previous metadata tag */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + haddr_t prev_tag = HADDR_UNDEF; /* Previous metadata tag */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -829,7 +818,7 @@ H5G__verify_cached_stabs_test(hid_t gid) HDassert(gid >= 0); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if (NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set up metadata tagging */ @@ -837,20 +826,20 @@ H5G__verify_cached_stabs_test(hid_t gid) /* Check for group having a symbol table message */ /* Check for the group having a group info message */ - if((stab_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) + if ((stab_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") /* No need to check anything if the symbol table doesn't exist */ - if(!stab_exists) + if (!stab_exists) HGOTO_DONE(SUCCEED); /* Read the stab */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) + if (NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get symbol table info") /* Iterate over the b-tree, checking validity of cached information */ - if((ret_value = H5B_iterate(grp->oloc.file, H5B_SNODE, stab.btree_addr, - H5G__verify_cached_stabs_test_cb, &udata)) < 0) + if ((ret_value = H5B_iterate(grp->oloc.file, H5B_SNODE, stab.btree_addr, H5G__verify_cached_stabs_test_cb, + &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "iteration operator failed"); /* Reset metadata tagging */ @@ -859,4 +848,3 @@ H5G__verify_cached_stabs_test(hid_t gid) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__verify_cached_stabs_test() */ - diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 9058fecfcbc..6b2ae7d61ba 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,30 +26,27 @@ /* Module Setup */ /****************/ -#include "H5Gmodule.h" /* This source code file is part of the H5G module */ - +#include "H5Gmodule.h" /* This source code file is part of the H5G module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -57,49 +54,42 @@ /* User data for path traversal routine */ typedef struct { /* down */ - hbool_t chk_exists; /* Flag to indicate we are checking if object exists */ + hbool_t chk_exists; /* Flag to indicate we are checking if object exists */ /* up */ - H5G_loc_t *obj_loc; /* Object location */ - hbool_t exists; /* Indicate if object exists */ + H5G_loc_t *obj_loc; /* Object location */ + hbool_t exists; /* Indicate if object exists */ } H5G_trav_slink_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G__traverse_slink_cb(H5G_loc_t *grp_loc, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5G__traverse_ud(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists); +static herr_t H5G__traverse_slink_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5G__traverse_ud(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists); static herr_t H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists); -static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, - unsigned target, H5G_traverse_t op, void *op_data); - + H5G_loc_t *obj_loc /*in,out*/, unsigned target, hbool_t *obj_exists); +static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, + void *op_data); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5G__traverse_slink_cb * @@ -115,17 +105,17 @@ static herr_t H5G__traverse_real(const H5G_loc_t *loc, const char *name, */ static herr_t H5G__traverse_slink_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) + 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_trav_slink_t *udata = (H5G_trav_slink_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_slink_t *udata = (H5G_trav_slink_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for dangling soft link */ - if(obj_loc == NULL) { - if(udata->chk_exists) + if (obj_loc == NULL) { + if (udata->chk_exists) udata->exists = FALSE; else HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") @@ -146,7 +136,6 @@ H5G__traverse_slink_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_slink_cb() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_ud * @@ -161,18 +150,18 @@ H5G__traverse_slink_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc, const char H5_ATTR_UNU *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists) +H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists) { - const H5L_class_t *link_class; /* User-defined link class */ - hid_t cb_return = -1; /* The ID the user-defined callback returned */ - H5G_loc_t grp_loc_copy; - 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; - hid_t cur_grp = (-1); - herr_t ret_value = SUCCEED; /* Return value */ + const H5L_class_t *link_class; /* User-defined link class */ + hid_t cb_return = -1; /* The ID the user-defined callback returned */ + H5G_loc_t grp_loc_copy; + 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; + hid_t cur_grp = (-1); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -183,7 +172,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, HDassert(obj_loc); /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(lnk->type))) + if (NULL == (link_class = H5L_find_class(lnk->type))) HGOTO_ERROR(H5E_SYM, H5E_NOTREGISTERED, FAIL, "unable to get UD link class") /* Set up location for user-defined callback. Use a copy of our current @@ -191,26 +180,33 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, grp_loc_copy.path = &grp_path_copy; grp_loc_copy.oloc = &grp_oloc_copy; H5G_loc_reset(&grp_loc_copy); - if(H5G_loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0) + if (H5G_loc_copy(&grp_loc_copy, grp_loc, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object location") /* Create a group ID to pass to the user-defined callback */ - if(NULL == (grp = H5G_open(&grp_loc_copy))) + if (NULL == (grp = H5G_open(&grp_loc_copy))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((cur_grp = H5I_register(H5I_GROUP, grp, FALSE)) < 0) + if ((cur_grp = H5VL_wrap_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") - /* User-defined callback function */ + /* User-defined callback function */ +#ifndef H5_NO_DEPRECATED_SYMBOLS /* (Backwardly compatible with v0 H5L_class_t traverssal 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()); + 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()); else - cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), H5CX_get_dxpl()); + cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, + H5CX_get_lapl(), H5CX_get_dxpl()); +#else /* H5_NO_DEPRECATED_SYMBOLS */ + cb_return = (link_class->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl(), + H5CX_get_dxpl()); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Check for failing to locate the object */ - if(cb_return < 0) { + if (cb_return < 0) { /* Check if we just needed to know if the object exists */ - if(target & H5G_TARGET_EXISTS) { + if (target & H5G_TARGET_EXISTS) { /* Clear any errors from the stack */ H5E_clear_stack(NULL); @@ -226,7 +222,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, } /* end if */ /* Get the object location information from the ID the user callback returned */ - if(H5G_loc(cb_return, &new_loc) < 0) + if (H5G_loc(cb_return, &new_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to get object location from ID") /* Release any previous location information for the object */ @@ -238,28 +234,27 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, /* Hold the file open until we free this object header (otherwise the * object location will be invalidated when the file closes). */ - if(H5O_loc_hold_file(obj_loc->oloc) < 0) + if (H5O_loc_hold_file(obj_loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") /* We have a copy of the location and we're holding the file open. * Close the open ID the user passed back. */ - if(H5I_dec_ref(cb_return) < 0) + if (H5I_dec_ref(cb_return) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") cb_return = (hid_t)(-1); done: /* Close location given to callback. */ - if(cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) + if (cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location") - if(ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) + if (ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_ud() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_slink * @@ -277,17 +272,17 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, unsigned target, hbool_t *obj_exists) +H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5G_loc_t *obj_loc /*in,out*/, + unsigned target, hbool_t *obj_exists) { - H5G_trav_slink_t udata; /* User data to pass to link traversal callback */ - H5G_name_t tmp_obj_path; /* Temporary copy of object's path */ - hbool_t tmp_obj_path_set = FALSE; /* Flag to indicate that tmp object path is initialized */ - H5O_loc_t tmp_grp_oloc; /* Temporary copy of group entry */ - H5G_name_t tmp_grp_path; /* Temporary copy of group's path */ - H5G_loc_t tmp_grp_loc; /* Temporary copy of group's location */ - hbool_t tmp_grp_loc_set = FALSE; /* Flag to indicate that tmp group location is initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_trav_slink_t udata; /* User data to pass to link traversal callback */ + H5G_name_t tmp_obj_path; /* Temporary copy of object's path */ + hbool_t tmp_obj_path_set = FALSE; /* Flag to indicate that tmp object path is initialized */ + H5O_loc_t tmp_grp_oloc; /* Temporary copy of group entry */ + H5G_name_t tmp_grp_path; /* Temporary copy of group's path */ + H5G_loc_t tmp_grp_loc; /* Temporary copy of group's location */ + hbool_t tmp_grp_loc_set = FALSE; /* Flag to indicate that tmp group location is initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -318,11 +313,11 @@ H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, /* Set up user data for traversal callback */ udata.chk_exists = (target & H5G_TARGET_EXISTS) ? TRUE : FALSE; - udata.exists = FALSE; - udata.obj_loc = obj_loc; + udata.exists = FALSE; + udata.obj_loc = obj_loc; /* Traverse the link */ - if(H5G__traverse_real(&tmp_grp_loc, lnk->u.soft.name, target, H5G__traverse_slink_cb, &udata) < 0) + if (H5G__traverse_real(&tmp_grp_loc, lnk->u.soft.name, target, H5G__traverse_slink_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") /* Pass back information about whether the object exists */ @@ -330,19 +325,18 @@ H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, done: /* Restore object's group hier. path */ - if(tmp_obj_path_set) { + if (tmp_obj_path_set) { H5G_name_free(obj_loc->path); H5G_name_copy(obj_loc->path, &tmp_obj_path, H5_COPY_SHALLOW); } /* end if */ /* Release cloned copy of group location */ - if(tmp_grp_loc_set) + if (tmp_grp_loc_set) H5G_loc_free(&tmp_grp_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_slink() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_special * @@ -356,11 +350,11 @@ H5G__traverse_slink(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, *------------------------------------------------------------------------- */ herr_t -H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, - unsigned target, hbool_t last_comp, H5G_loc_t *obj_loc, hbool_t *obj_exists) +H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned target, hbool_t last_comp, + H5G_loc_t *obj_loc, hbool_t *obj_exists) { - size_t nlinks; /* # of soft / UD links left to traverse */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t nlinks; /* # of soft / UD links left to traverse */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -373,23 +367,22 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * is the last component of the name and the H5G_TARGET_SLINK bit of * TARGET is set then we don't follow it. */ - if(H5L_TYPE_SOFT == lnk->type && - (0 == (target & H5G_TARGET_SLINK) || !last_comp)) { + if (H5L_TYPE_SOFT == lnk->type && (0 == (target & H5G_TARGET_SLINK) || !last_comp)) { /* Get the # of soft / UD links left to traverse */ - if(H5CX_get_nlinks(&nlinks) < 0) + if (H5CX_get_nlinks(&nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Decrement # of links and range check */ - if((nlinks)-- <= 0) + if ((nlinks)-- <= 0) HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, "too many links") /* Update the # of links in the API context */ - if(H5CX_set_nlinks(nlinks) < 0) + if (H5CX_set_nlinks(nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't update # of soft / UD links to traverse") /* Traverse soft link */ - if(H5G__traverse_slink(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) + if (H5G__traverse_slink(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "symbolic link traversal failed") } /* end if */ @@ -398,23 +391,22 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * is the last component of the name and the H5G_TARGET_UDLINK bit of * TARGET is set then we don't follow it. */ - if(lnk->type >= H5L_TYPE_UD_MIN && - (0 == (target & H5G_TARGET_UDLINK) || !last_comp) ) { + if (lnk->type >= H5L_TYPE_UD_MIN && (0 == (target & H5G_TARGET_UDLINK) || !last_comp)) { /* Get the # of soft / UD links left to traverse */ - if(H5CX_get_nlinks(&nlinks) < 0) + if (H5CX_get_nlinks(&nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Decrement # of links and range check */ - if((nlinks)-- <= 0) + if ((nlinks)-- <= 0) HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, "too many links") /* Update the # of links in the API context */ - if(H5CX_set_nlinks(nlinks) < 0) + if (H5CX_set_nlinks(nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't update # of soft / UD links to traverse") /* Traverse user-defined link */ - if(H5G__traverse_ud(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) + if (H5G__traverse_ud(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "user-defined link traversal failed") } /* end if */ @@ -429,9 +421,8 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * the status of the object (into a hard link), so don't use an 'else' * statement here. -QAK) */ - if(H5F_addr_defined(obj_loc->oloc->addr) && - (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) { - if(H5F_traverse_mount(obj_loc->oloc/*in,out*/) < 0) + if (H5F_addr_defined(obj_loc->oloc->addr) && (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) { + if (H5F_traverse_mount(obj_loc->oloc /*in,out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "mount point traversal failed") } /* end if */ @@ -439,15 +430,14 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, * and obj_loc is in the same file, obj_loc should also hold the * file open so that closing the grp_loc doesn't close the file. */ - if(grp_loc->oloc->holding_file && grp_loc->oloc->file == obj_loc->oloc->file) - if(H5O_loc_hold_file(obj_loc->oloc) < 0) + if (grp_loc->oloc->holding_file && grp_loc->oloc->file == obj_loc->oloc->file) + if (H5O_loc_hold_file(obj_loc->oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_special() */ - /*------------------------------------------------------------------------- * Function: H5G__traverse_real * @@ -464,27 +454,26 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, *------------------------------------------------------------------------- */ static herr_t -H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, - H5G_traverse_t op, void *op_data) +H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data) { - H5G_loc_t loc; /* Location of start object */ - H5O_loc_t grp_oloc; /* Object loc. for current group */ - H5G_name_t grp_path; /* Path for current group */ - H5G_loc_t grp_loc; /* Location of group */ - H5O_loc_t obj_oloc; /* Object found */ - H5G_name_t obj_path; /* Path for object found */ - H5G_loc_t obj_loc; /* Location of object */ - size_t nchars; /* component name length */ - H5O_link_t lnk; /* Link information for object */ - hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ - hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ + H5G_loc_t loc; /* Location of start object */ + H5O_loc_t grp_oloc; /* Object loc. for current group */ + H5G_name_t grp_path; /* Path for current group */ + H5G_loc_t grp_loc; /* Location of group */ + H5O_loc_t obj_oloc; /* Object found */ + H5G_name_t obj_path; /* Path for object found */ + H5G_loc_t obj_loc; /* Location of object */ + size_t nchars; /* component name length */ + H5O_link_t lnk; /* Link information for object */ + hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ + hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC @@ -498,8 +487,8 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, * root of the file; for relative names it starts at CWG. */ /* Check if we need to get the root group's entry */ - if('/' == *name) { - H5G_t *root_grp; /* Temporary pointer to root group of file */ + if ('/' == *name) { + H5G_t *root_grp; /* Temporary pointer to root group of file */ /* Look up root group for starting location */ root_grp = H5G_rootof(_loc->oloc->file); @@ -522,72 +511,72 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear group location */ - if(H5G_loc_reset(&grp_loc) < 0) + if (H5G_loc_reset(&grp_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") #endif /* H5_USING_MEMCHECKER */ /* Deep copy of the starting location to group location */ - if(H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0) + if (H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy location") group_copy = TRUE; /* Clear object location */ - if(H5G_loc_reset(&obj_loc) < 0) + if (H5G_loc_reset(&obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") /* Wrap the local buffer for serialized header info */ - if(NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) + if (NULL == (wb = H5WB_wrap(comp_buf, sizeof(comp_buf)))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough */ - if(NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(name) + 1)))) + if (NULL == (comp = (char *)H5WB_actual(wb, (HDstrlen(name) + 1)))) HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Traverse the path */ - while((name = H5G__component(name, &nchars)) && *name) { - const char *s; /* Temporary string pointer */ - htri_t lookup_status; /* Status from object lookup */ - hbool_t obj_exists; /* Whether the object exists */ - - /* - * Copy the component name into a null-terminated buffer so - * we can pass it down to the other symbol table functions. - */ - H5MM_memcpy(comp, name, nchars); - comp[nchars] = '\0'; - - /* - * The special name `.' is a no-op. - */ - if('.' == comp[0] && !comp[1]) { - name += nchars; - continue; - } /* end if */ + while ((name = H5G__component(name, &nchars)) && *name) { + const char *s; /* Temporary string pointer */ + htri_t lookup_status; /* Status from object lookup */ + hbool_t obj_exists; /* Whether the object exists */ + + /* + * Copy the component name into a null-terminated buffer so + * we can pass it down to the other symbol table functions. + */ + H5MM_memcpy(comp, name, nchars); + comp[nchars] = '\0'; + + /* + * The special name `.' is a no-op. + */ + if ('.' == comp[0] && !comp[1]) { + name += nchars; + continue; + } /* end if */ /* Check if this is the last component of the name */ - if(!((s = H5G__component(name + nchars, NULL)) && *s)) + if (!((s = H5G__component(name + nchars, NULL)) && *s)) last_comp = TRUE; /* If there's valid information in the link, reset it */ - if(link_valid) { + if (link_valid) { H5O_msg_reset(H5O_LINK_ID, &lnk); link_valid = FALSE; } /* end if */ /* Get information for object in current group */ - if((lookup_status = H5G__obj_lookup(grp_loc.oloc, comp, &lnk/*out*/)) < 0) + if ((lookup_status = H5G__obj_lookup(grp_loc.oloc, comp, &lnk /*out*/)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't look up component") obj_exists = FALSE; /* If the lookup was OK, build object location and traverse special links, etc. */ - if(lookup_status) { + if (lookup_status) { /* Sanity check link and indicate it's valid */ HDassert(lnk.type >= H5L_TYPE_HARD); HDassert(!HDstrcmp(comp, lnk.name)); link_valid = TRUE; /* Build object location from the link */ - if(H5G__link_to_loc(&grp_loc, &lnk, &obj_loc) < 0) + if (H5G__link_to_loc(&grp_loc, &lnk, &obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot initialize object location") obj_loc_valid = TRUE; @@ -596,19 +585,19 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Perform any special traversals that the link needs */ /* (soft links, user-defined links, file mounting, etc.) */ - if(H5G__traverse_special(&grp_loc, &lnk, target, last_comp, &obj_loc, &obj_exists) < 0) + if (H5G__traverse_special(&grp_loc, &lnk, target, last_comp, &obj_loc, &obj_exists) < 0) HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, "special link traversal failed") } /* end if */ /* 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 */ + 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 */ /* Set callback parameters appropriately, based on link being found */ - if(lookup_status) { + if (lookup_status) { cb_lnk = &lnk; - if(obj_exists) + if (obj_exists) cb_loc = &obj_loc; else cb_loc = NULL; @@ -620,36 +609,36 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, } /* end else */ /* Call 'operator' routine */ - if((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) + if ((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CALLBACK, FAIL, "traversal operator failed") HGOTO_DONE(SUCCEED) } /* end if */ /* Handle lookup failures now */ - if(!lookup_status) { + if (!lookup_status) { /* If an intermediate group doesn't exist & flag is set, create the group */ - if(target & H5G_CRT_INTMD_GROUP) { - const H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ - const H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ - const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default filter pipeline settings */ - H5O_ginfo_t par_ginfo; /* Group info settings for parent group */ - H5O_linfo_t par_linfo; /* Link info settings for parent group */ - H5O_pline_t par_pline; /* Filter pipeline settings for parent group */ - H5O_linfo_t tmp_linfo; /* Temporary link info settings */ - htri_t exists; /* Whether a group or link info message exists */ - const H5O_ginfo_t *ginfo; /* Group info settings for new group */ - const H5O_linfo_t *linfo; /* Link info settings for new group */ - const H5O_pline_t *pline; /* Filter pipeline settings for new group */ - H5G_obj_create_t gcrt_info; /* Group creation info */ + if (target & H5G_CRT_INTMD_GROUP) { + const H5O_ginfo_t def_ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ + const H5O_linfo_t def_linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ + const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default filter pipeline settings */ + H5O_ginfo_t par_ginfo; /* Group info settings for parent group */ + H5O_linfo_t par_linfo; /* Link info settings for parent group */ + H5O_pline_t par_pline; /* Filter pipeline settings for parent group */ + H5O_linfo_t tmp_linfo; /* Temporary link info settings */ + htri_t exists; /* Whether a group or link info message exists */ + const H5O_ginfo_t *ginfo; /* Group info settings for new group */ + const H5O_linfo_t *linfo; /* Link info settings for new group */ + const H5O_pline_t *pline; /* Filter pipeline settings for new group */ + H5G_obj_create_t gcrt_info; /* Group creation info */ /* Check for the parent group having a group info message */ /* (OK if not found) */ - if((exists = H5O_msg_exists(grp_loc.oloc, H5O_GINFO_ID)) < 0) + if ((exists = H5O_msg_exists(grp_loc.oloc, H5O_GINFO_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Get the group info for parent group */ - if(NULL == H5O_msg_read(grp_loc.oloc, H5O_GINFO_ID, &par_ginfo)) + if (NULL == H5O_msg_read(grp_loc.oloc, H5O_GINFO_ID, &par_ginfo)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "group info message not present") /* Use parent group info settings */ @@ -662,16 +651,16 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Check for the parent group having a link info message */ /* (OK if not found) */ /* Get the link info for parent group */ - if((exists = H5G__obj_get_linfo(grp_loc.oloc, &par_linfo)) < 0) + if ((exists = H5G__obj_get_linfo(grp_loc.oloc, &par_linfo)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Only keep the creation order information from the parent * group's link info */ H5MM_memcpy(&tmp_linfo, &def_linfo, sizeof(H5O_linfo_t)); tmp_linfo.track_corder = par_linfo.track_corder; tmp_linfo.index_corder = par_linfo.index_corder; - linfo = &tmp_linfo; + linfo = &tmp_linfo; } /* end if */ else /* Use default link info settings */ @@ -679,11 +668,11 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* Check for the parent group having a filter pipeline message */ /* (OK if not found) */ - if((exists = H5O_msg_exists(grp_loc.oloc, H5O_PLINE_ID)) < 0) + if ((exists = H5O_msg_exists(grp_loc.oloc, H5O_PLINE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(exists) { + if (exists) { /* Get the filter pipeline for parent group */ - if(NULL == H5O_msg_read(grp_loc.oloc, H5O_PLINE_ID, &par_pline)) + if (NULL == H5O_msg_read(grp_loc.oloc, H5O_PLINE_ID, &par_pline)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "filter pipeline message not present") /* Use parent filter pipeline settings */ @@ -694,53 +683,55 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, pline = &def_pline; /* Create the intermediate group */ -/* XXX: Should we allow user to control the group creation params here? -QAK */ - gcrt_info.gcpl_id = H5P_GROUP_CREATE_DEFAULT; + /* XXX: Should we allow user to control the group creation params here? -QAK */ + gcrt_info.gcpl_id = H5P_GROUP_CREATE_DEFAULT; gcrt_info.cache_type = H5G_NOTHING_CACHED; HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - if(H5G__obj_create_real(grp_oloc.file, ginfo, linfo, pline, &gcrt_info, obj_loc.oloc/*out*/) < 0) + if (H5G__obj_create_real(grp_oloc.file, ginfo, linfo, pline, &gcrt_info, + obj_loc.oloc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") /* Insert new group into current group's symbol table */ - if(H5G__loc_insert(&grp_loc, comp, &obj_loc, H5O_TYPE_GROUP, &gcrt_info) < 0) + if (H5G__loc_insert(&grp_loc, comp, &obj_loc, H5O_TYPE_GROUP, &gcrt_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert intermediate group") /* Decrement refcount on intermediate group's object header in memory */ - if(H5O_dec_rc_by_loc(obj_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(obj_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, + "unable to decrement refcount on newly created object") /* Close new group */ - if(H5O_close(obj_loc.oloc, NULL) < 0) + if (H5O_close(obj_loc.oloc, NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") /* If the parent group was holding the file open, the * newly-created group should, as well. */ - if(grp_loc.oloc->holding_file) - if(H5O_loc_hold_file(obj_loc.oloc) < 0) + if (grp_loc.oloc->holding_file) + if (H5O_loc_hold_file(obj_loc.oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to hold file open") /* Reset any non-default object header messages */ - if(ginfo != &def_ginfo) + if (ginfo != &def_ginfo) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_GINFO_ID, (void *)ginfo) < 0) + if (H5O_msg_reset(H5O_GINFO_ID, (void *)ginfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset group info message") - if(linfo != &def_linfo) + if (linfo != &def_linfo) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_LINFO_ID, (void *)linfo) < 0) + if (H5O_msg_reset(H5O_LINFO_ID, (void *)linfo) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link info message") - if(pline != &def_pline) + if (pline != &def_pline) /* (Casting away const OK - QAK) */ - if(H5O_msg_reset(H5O_PLINE_ID, (void *)pline) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, (void *)pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset I/O pipeline message") } /* end if */ else HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") } /* end if */ - /* - * Advance to the next component of the path. - */ + /* + * Advance to the next component of the path. + */ /* Transfer "ownership" of the object's information to the group object */ H5G_loc_free(&grp_loc); @@ -748,8 +739,8 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G_loc_reset(&obj_loc); obj_loc_valid = FALSE; - /* Advance to next component in string */ - name += nchars; + /* Advance to next component in string */ + name += nchars; } /* end while */ /* Call 'operator' routine */ @@ -759,41 +750,40 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, * NULL. */ HDassert(group_copy); - if((op)(NULL, ".", NULL, &grp_loc, op_data, &own_loc) < 0) + if ((op)(NULL, ".", NULL, &grp_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "traversal operator failed") /* If the callback took ownership of the object location, it actually has * ownership of grp_loc. It shouldn't have tried to take ownership of * the "group location", which was NULL. */ - HDassert(!(own_loc & H5G_OWN_GRP_LOC)); - if(own_loc & H5G_OWN_OBJ_LOC) - own_loc |= H5G_OWN_GRP_LOC; + HDassert(!(own_loc & H5G_OWN_GRP_LOC)); + if (own_loc & H5G_OWN_OBJ_LOC) + own_loc |= H5G_OWN_GRP_LOC; done: /* If there's been an error, the callback doesn't really get ownership of * any location and we should close them both */ - if(ret_value < 0) + if (ret_value < 0) own_loc = H5G_OWN_NONE; /* Free all open locations. This also closes any open external files. */ - if(obj_loc_valid && !(own_loc & H5G_OWN_OBJ_LOC)) + if (obj_loc_valid && !(own_loc & H5G_OWN_OBJ_LOC)) H5G_loc_free(&obj_loc); - if(group_copy && !(own_loc & H5G_OWN_GRP_LOC)) + if (group_copy && !(own_loc & H5G_OWN_GRP_LOC)) H5G_loc_free(&grp_loc); /* If there's valid information in the link, reset it */ - if(link_valid) - if(H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) + if (link_valid) + if (H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message") /* Release temporary component buffer */ - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer") - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_real() */ - /*------------------------------------------------------------------------- * Function: H5G_traverse * @@ -810,28 +800,27 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, *------------------------------------------------------------------------- */ herr_t -H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, - void *op_data) +H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data) { - size_t orig_nlinks; /* Original value for # of soft / UD links able to traverse */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t orig_nlinks; /* Original value for # of soft / UD links able to traverse */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no name given") - if(!loc) + if (!loc) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no starting location") - if(!op) + if (!op) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no operation provided") /* Retrieve the original # of soft / UD links that are able to be traversed * (So that multiple calls to H5G_traverse don't incorrectly look - * like they've traversed too many. Nested calls, like in H5L_move(), + * like they've traversed too many. Nested calls, like in H5L__move(), * may need their own mechanism to set & reset the # of links to traverse) */ - if(H5CX_get_nlinks(&orig_nlinks) < 0) + if (H5CX_get_nlinks(&orig_nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Set up invalid tag. This is a precautionary step only. Setting an invalid @@ -844,17 +833,16 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver H5_BEGIN_TAG(H5AC__INVALID_TAG); /* Go perform "real" traversal */ - if(H5G__traverse_real(loc, name, target, op, op_data) < 0) + if (H5G__traverse_real(loc, name, target, op, op_data) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") /* Reset tag after traversal */ H5_END_TAG /* Reset the # of soft / UD links that can be traversed */ - if(H5CX_set_nlinks(orig_nlinks) < 0) + if (H5CX_set_nlinks(orig_nlinks) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_traverse() */ - diff --git a/src/H5HF.c b/src/H5HF.c index 8ac2d303726..73281a4e31b 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,40 +31,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -72,12 +66,10 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -85,10 +77,8 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the H5HF_t struct */ H5FL_DEFINE_STATIC(H5HF_t); - - /*------------------------------------------------------------------------- - * Function: H5HF_op_read + * Function: H5HF__op_read * * Purpose: Performs a 'read' operation for a heap 'op' callback * @@ -100,19 +90,18 @@ H5FL_DEFINE_STATIC(H5HF_t); *------------------------------------------------------------------------- */ herr_t -H5HF_op_read(const void *obj, size_t obj_len, void *op_data) +H5HF__op_read(const void *obj, size_t obj_len, void *op_data) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Perform "read", using memcpy() */ H5MM_memcpy(op_data, obj, obj_len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_op_read() */ +} /* end H5HF__op_read() */ - /*------------------------------------------------------------------------- - * Function: H5HF_op_write + * Function: H5HF__op_write * * Purpose: Performs a 'write' operation for a heap 'op' callback * @@ -124,17 +113,16 @@ H5HF_op_read(const void *obj, size_t obj_len, void *op_data) *------------------------------------------------------------------------- */ herr_t -H5HF_op_write(const void *obj, size_t obj_len, void *op_data) +H5HF__op_write(const void *obj, size_t obj_len, void *op_data) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Perform "write", using memcpy() */ - H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */ + H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_op_write() */ +} /* end H5HF__op_write() */ - /*------------------------------------------------------------------------- * Function: H5HF_create * @@ -151,10 +139,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_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 * 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 */ FUNC_ENTER_NOAPI(NULL) @@ -165,25 +153,25 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) HDassert(cparam); /* Create shared fractal heap header */ - if(HADDR_UNDEF == (fh_addr = H5HF_hdr_create(f, cparam))) + if (HADDR_UNDEF == (fh_addr = H5HF__hdr_create(f, cparam))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create fractal heap header") /* Allocate fractal heap wrapper */ - if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + if (NULL == (fh = H5FL_MALLOC(H5HF_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info") /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Point fractal heap wrapper at header and bump it's ref count */ fh->hdr = hdr; - if(H5HF_hdr_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") + if (H5HF__hdr_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Increment # of files using this heap header */ - if(H5HF_hdr_fuse_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") + if (H5HF__hdr_fuse_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") /* Set file pointer for this heap open context */ fh->f = f; @@ -192,16 +180,15 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) ret_value = fh; done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") - if(!ret_value && fh) - if(H5HF_close(fh) < 0) + if (!ret_value && fh) + if (H5HF_close(fh) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_create() */ - /*------------------------------------------------------------------------- * Function: H5HF_open * @@ -218,9 +205,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_hdr_t *hdr = NULL; /* The fractal heap header information */ - H5HF_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(NULL) @@ -231,25 +218,25 @@ H5HF_open(H5F_t *f, haddr_t fh_addr) HDassert(H5F_addr_defined(fh_addr)); /* Load the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Check for pending heap deletion */ - if(hdr->pending_delete) + if (hdr->pending_delete) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, NULL, "can't open fractal heap pending deletion") /* Create fractal heap info */ - if(NULL == (fh = H5FL_MALLOC(H5HF_t))) + if (NULL == (fh = H5FL_MALLOC(H5HF_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info") /* Point fractal heap wrapper at header */ fh->hdr = hdr; - if(H5HF_hdr_incr(fh->hdr) < 0) + if (H5HF__hdr_incr(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Increment # of files using this heap header */ - if(H5HF_hdr_fuse_incr(fh->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") + if (H5HF__hdr_fuse_incr(fh->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header") /* Set file pointer for this heap open context */ fh->f = f; @@ -258,16 +245,15 @@ H5HF_open(H5F_t *f, haddr_t fh_addr) ret_value = fh; done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") - if(!ret_value && fh) - if(H5HF_close(fh) < 0) + if (!ret_value && fh) + if (H5HF_close(fh) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_open() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_len * @@ -297,7 +283,6 @@ H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_get_id_len() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_heap_addr * @@ -327,7 +312,6 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_get_heap_addr() */ - /*------------------------------------------------------------------------- * Function: H5HF_insert * @@ -342,10 +326,10 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p) *------------------------------------------------------------------------- */ herr_t -H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) +H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/) { - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - herr_t ret_value = SUCCEED; + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -355,7 +339,7 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) HDassert(id); /* Check arguments */ - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "can't insert 0-sized objects") /* Set the shared heap header's file context for this operation */ @@ -365,35 +349,34 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/) hdr = fh->hdr; /* Check for 'huge' object */ - if(size > hdr->max_man_size) { + if (size > hdr->max_man_size) { /* Store 'huge' object in heap */ /* (Casting away const OK - QAK) */ - if(H5HF__huge_insert(hdr, size, (void *)obj, id) < 0) + if (H5HF__huge_insert(hdr, size, (void *)obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'huge' object in fractal heap") } /* end if */ /* Check for 'tiny' object */ - else if(size <= hdr->tiny_max_len) { + else if (size <= hdr->tiny_max_len) { /* Store 'tiny' object in heap */ - if(H5HF_tiny_insert(hdr, size, obj, id) < 0) + if (H5HF__tiny_insert(hdr, size, obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'tiny' object in fractal heap") } /* end if */ else { /* Check if we are in "append only" mode, or if there's enough room for the object */ - if(hdr->write_once) { -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet") + if (hdr->write_once) { + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet") } /* end if */ else { /* Allocate space for object in 'managed' heap */ - if(H5HF__man_insert(hdr, size, obj, id) < 0) + if (H5HF__man_insert(hdr, size, obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'managed' object in fractal heap") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_obj_len * @@ -409,9 +392,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not su herr_t H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -426,35 +409,34 @@ H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { - if(H5HF_man_get_obj_len(fh->hdr, id, obj_len_p) < 0) + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if (H5HF__man_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'managed' object's length") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { - if(H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0) + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + if (H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's length") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { - if(H5HF_tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0) + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + if (H5HF__tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'tiny' object's length") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_obj_off * @@ -470,9 +452,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -487,35 +469,34 @@ H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { H5HF__man_get_obj_off(fh->hdr, id, obj_off_p); } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Huge objects are located directly in the file */ - if(H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0) + if (H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's offset") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Tiny objects are not stored in the heap */ *obj_off_p = (hsize_t)0; } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF_read * @@ -529,11 +510,11 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") *------------------------------------------------------------------------- */ herr_t -H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/) +H5HF_read(H5HF_t *fh, const void *_id, void *obj /*out*/) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -548,38 +529,37 @@ H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Read object from managed heap blocks */ - if(H5HF__man_read(fh->hdr, id, obj) < 0) + if (H5HF__man_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Read 'huge' object from file */ - if(H5HF__huge_read(fh->hdr, id, obj) < 0) + if (H5HF__huge_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Read 'tiny' object from file */ - if(H5HF_tiny_read(fh->hdr, id, obj) < 0) + if (H5HF__tiny_read(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_read() */ - /*------------------------------------------------------------------------- * Function: H5HF_write * @@ -607,9 +587,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") herr_t H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void *obj) { - uint8_t *id = (uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *id = (uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -624,39 +604,38 @@ H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Operate on object from managed heap blocks */ /* (ID can't change and modifying object is "easy" to manage) */ - if(H5HF__man_write(fh->hdr, id, obj) < 0) + if (H5HF__man_write(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'managed' heap object") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Operate on "huge" object */ - if(H5HF__huge_write(fh->hdr, id, obj) < 0) + if (H5HF__huge_write(fh->hdr, id, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'huge' heap object") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Check for writing a 'tiny' object */ /* (which isn't supported yet - ID will change) */ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "modifying 'tiny' object not supported yet") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_write() */ - /*------------------------------------------------------------------------- * Function: H5HF_op * @@ -677,9 +656,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") herr_t H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -694,38 +673,37 @@ H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Operate on object from managed heap blocks */ - if(H5HF__man_op(fh->hdr, id, op, op_data) < 0) + if (H5HF__man_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Operate on 'huge' object from file */ - if(H5HF__huge_op(fh->hdr, id, op, op_data) < 0) + if (H5HF__huge_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Operate on 'tiny' object from file */ - if(H5HF_tiny_op(fh->hdr, id, op, op_data) < 0) + if (H5HF__tiny_op(fh->hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_op() */ - /*------------------------------------------------------------------------- * Function: H5HF_remove * @@ -741,9 +719,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") herr_t H5HF_remove(H5HF_t *fh, const void *_id) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -758,38 +736,37 @@ H5HF_remove(H5HF_t *fh, const void *_id) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { /* Remove object from managed heap blocks */ - if(H5HF__man_remove(fh->hdr, id) < 0) + if (H5HF__man_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { /* Remove 'huge' object from file & v2 B-tree tracker */ - if(H5HF__huge_remove(fh->hdr, id) < 0) + if (H5HF__huge_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'huge' object from fractal heap") } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { /* Remove 'tiny' object from heap statistics */ - if(H5HF_tiny_remove(fh->hdr, id) < 0) + if (H5HF__tiny_remove(fh->hdr, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'tiny' object from fractal heap") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF_close * @@ -805,9 +782,9 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") herr_t H5HF_close(H5HF_t *fh) { - hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */ - haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */ + haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -817,7 +794,7 @@ H5HF_close(H5HF_t *fh) HDassert(fh); /* Decrement file reference & check if this is the last open fractal heap using the shared heap header */ - if(0 == H5HF_hdr_fuse_decr(fh->hdr)) { + if (0 == H5HF__hdr_fuse_decr(fh->hdr)) { /* Set the shared heap header's file context for this operation */ fh->hdr->f = fh->f; @@ -827,7 +804,7 @@ H5HF_close(H5HF_t *fh) * a reference loop and the objects couldn't be removed from * the metadata cache - QAK) */ - if(H5HF__space_close(fh->hdr) < 0) + if (H5HF__space_close(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") /* Reset the block iterator, if necessary */ @@ -836,8 +813,8 @@ H5HF_close(H5HF_t *fh) * a reference loop and the objects couldn't be removed from * the metadata cache - QAK) */ - if(H5HF_man_iter_ready(&fh->hdr->next_block)) - if(H5HF_man_iter_reset(&fh->hdr->next_block) < 0) + if (H5HF__man_iter_ready(&fh->hdr->next_block)) + if (H5HF__man_iter_reset(&fh->hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Shut down the huge object information */ @@ -845,36 +822,36 @@ H5HF_close(H5HF_t *fh) * has the address of an object in the file, which might be * modified by the shutdown routine - QAK) */ - if(H5HF__huge_term(fh->hdr) < 0) + if (H5HF__huge_term(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release 'huge' object info") /* Check for pending heap deletion */ - if(fh->hdr->pending_delete) { + if (fh->hdr->pending_delete) { /* Set local info, so heap deletion can occur after decrementing the * header's ref count */ pending_delete = TRUE; - heap_addr = fh->hdr->heap_addr; + heap_addr = fh->hdr->heap_addr; } /* end if */ - } /* end if */ + } /* end if */ /* Decrement the reference count on the heap header */ - /* (don't put in H5HF_hdr_fuse_decr() as the heap header may be evicted + /* (don't put in H5HF__hdr_fuse_decr() as the heap header may be evicted * immediately -QAK) */ - if(H5HF_hdr_decr(fh->hdr) < 0) + if (H5HF__hdr_decr(fh->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") /* Check for pending heap deletion */ - if(pending_delete) { - H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */ + if (pending_delete) { + H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */ /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Delete heap, starting with header (unprotects header) */ - if(H5HF__hdr_delete(hdr) < 0) + if (H5HF__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") } /* end if */ @@ -885,7 +862,6 @@ H5HF_close(H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_close() */ - /*------------------------------------------------------------------------- * Function: H5HF_delete * @@ -901,8 +877,8 @@ H5HF_close(H5HF_t *fh) herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr) { - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -913,24 +889,23 @@ H5HF_delete(H5F_t *f, haddr_t fh_addr) HDassert(H5F_addr_defined(fh_addr)); /* Lock the heap header into memory */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Check for files using shared heap header */ - if(hdr->file_rc) + if (hdr->file_rc) hdr->pending_delete = TRUE; else { /* Delete heap now, starting with header (unprotects header) */ - if(H5HF__hdr_delete(hdr) < 0) + if (H5HF__hdr_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") hdr = NULL; } /* end if */ done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_delete() */ - diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index 756ddb5ed86..353d7d7c1bf 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,109 +26,97 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* v2 B-tree client callback context */ typedef struct H5HF_huge_bt2_ctx_t { - uint8_t sizeof_size; /* Size of file sizes */ - uint8_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_size; /* Size of file sizes */ + uint8_t sizeof_addr; /* Size of file addresses */ } H5HF_huge_bt2_ctx_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /* 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 */ static herr_t H5HF__huge_bt2_indir_store(void *native, const void *udata); static herr_t 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 *native, - void *ctx); -static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for filtered indirect objects */ static herr_t H5HF__huge_bt2_filt_indir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_filt_indir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for direct objects */ static herr_t H5HF__huge_bt2_dir_store(void *native, const void *udata); static herr_t 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 *native, - void *ctx); -static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /* Callbacks for filtered direct objects */ static herr_t H5HF__huge_bt2_filt_dir_store(void *native, const void *udata); static herr_t H5HF__huge_bt2_filt_dir_compare(const void *rec1, const void *rec2, int *result); -static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, - void *ctx); -static herr_t H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, - const void *record, const void *_udata); +static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, void *ctx); +static herr_t H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *record, + const void *_udata); /*********************/ /* Package Variables */ /*********************/ /* v2 B-tree class for indirectly accessed 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_indir_store, /* Record storage callback */ - H5HF__huge_bt2_indir_compare, /* Record comparison callback */ - H5HF__huge_bt2_indir_encode, /* Record encoding callback */ - H5HF__huge_bt2_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_indir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_INDIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_INDIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_indir_store, /* Record storage callback */ + H5HF__huge_bt2_indir_compare, /* Record comparison callback */ + H5HF__huge_bt2_indir_encode, /* Record encoding callback */ + H5HF__huge_bt2_indir_decode, /* Record decoding callback */ + H5HF__huge_bt2_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1] = {{ + /* B-tree class information */ H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ "H5B2_FHEAP_HUGE_FILT_INDIR_ID", /* Name of B-tree class */ sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ @@ -142,38 +130,39 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_dir_store, /* Record storage callback */ - H5HF__huge_bt2_dir_compare, /* Record comparison callback */ - H5HF__huge_bt2_dir_encode, /* Record encoding callback */ - H5HF__huge_bt2_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_DIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_dir_store, /* Record storage callback */ + H5HF__huge_bt2_dir_compare, /* Record comparison callback */ + H5HF__huge_bt2_dir_encode, /* Record encoding callback */ + H5HF__huge_bt2_dir_decode, /* Record decoding callback */ + H5HF__huge_bt2_dir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ -const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ - H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ - "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ - sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ - H5HF__huge_bt2_crt_context, /* Create client callback context */ - H5HF__huge_bt2_dst_context, /* Destroy client callback context */ - H5HF__huge_bt2_filt_dir_store, /* Record storage callback */ - H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ - H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ - H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ +const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1] = {{ + /* B-tree class information */ + H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ + "H5B2_FHEAP_HUGE_FILT_DIR_ID", /* Name of B-tree class */ + sizeof(H5HF_huge_bt2_filt_dir_rec_t), /* Size of native record */ + H5HF__huge_bt2_crt_context, /* Create client callback context */ + H5HF__huge_bt2_dst_context, /* Destroy client callback context */ + H5HF__huge_bt2_filt_dir_store, /* Record storage callback */ + H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ + H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ + H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ + H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ }}; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -181,8 +170,6 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ /* Declare a free list to manage the H5HF_huge_bt2_ctx_t struct */ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_crt_context * @@ -201,9 +188,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 */ - H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -211,7 +198,7 @@ H5HF__huge_bt2_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses & lengths in the file */ @@ -225,7 +212,6 @@ H5HF__huge_bt2_crt_context(void *_f) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dst_context * @@ -244,7 +230,7 @@ H5HF__huge_bt2_crt_context(void *_f) static herr_t H5HF__huge_bt2_dst_context(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 */ FUNC_ENTER_STATIC_NOERR @@ -257,7 +243,6 @@ H5HF__huge_bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_found * @@ -282,7 +267,6 @@ H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_remove * @@ -300,13 +284,14 @@ H5HF__huge_bt2_indir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_indir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -316,7 +301,6 @@ H5HF__huge_bt2_indir_remove(const void *nrecord, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_indir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_store * @@ -340,7 +324,6 @@ H5HF__huge_bt2_indir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_compare * @@ -366,7 +349,6 @@ H5HF__huge_bt2_indir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_encode * @@ -383,7 +365,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 @@ -399,7 +381,6 @@ H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_decode * @@ -416,7 +397,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 @@ -432,7 +413,6 @@ H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_debug * @@ -447,20 +427,19 @@ H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->id); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %" PRIuHSIZE ", %" PRIuHSIZE "}\n", indent, "", fwidth, + "Record:", nrecord->addr, nrecord->len, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_found * @@ -485,7 +464,6 @@ H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_remove * @@ -503,13 +481,15 @@ H5HF__huge_bt2_filt_indir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_filt_indir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, + ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -519,7 +499,6 @@ H5HF__huge_bt2_filt_indir_remove(const void *nrecord, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_filt_indir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_store * @@ -543,7 +522,6 @@ H5HF__huge_bt2_filt_indir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_compare * @@ -569,7 +547,6 @@ H5HF__huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2, int *res FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_encode * @@ -586,7 +563,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 @@ -604,7 +581,6 @@ H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_decode * @@ -621,7 +597,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 @@ -639,7 +615,6 @@ H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_indir_debug * @@ -654,20 +629,20 @@ H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size, nrecord->id); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %" PRIuHSIZE ", %x, %" PRIuHSIZE ", %" PRIuHSIZE "}\n", + indent, "", fwidth, "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, + nrecord->obj_size, nrecord->id); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_remove * @@ -685,13 +660,14 @@ H5HF__huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, herr_t H5HF__huge_bt2_dir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -701,7 +677,6 @@ H5HF__huge_bt2_dir_remove(const void *nrecord, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_dir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_store * @@ -725,7 +700,6 @@ H5HF__huge_bt2_dir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_compare * @@ -748,13 +722,13 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_ENTER_STATIC_NOERR - if(rec1->addr < rec2->addr) + if (rec1->addr < rec2->addr) *result = -1; - else if(rec1->addr > rec2->addr) + else if (rec1->addr > rec2->addr) *result = 1; - else if(rec1->len < rec2->len) + else if (rec1->len < rec2->len) *result = -1; - else if(rec1->len > rec2->len) + else if (rec1->len > rec2->len) *result = 1; else *result = 0; @@ -762,7 +736,6 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_encode * @@ -779,7 +752,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 @@ -794,7 +767,6 @@ H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_decode * @@ -811,7 +783,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 @@ -826,7 +798,6 @@ H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_dir_debug * @@ -841,20 +812,19 @@ H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %" PRIuHSIZE "}\n", indent, "", fwidth, + "Record:", nrecord->addr, nrecord->len); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_found * @@ -879,7 +849,6 @@ H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_found() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_remove * @@ -897,13 +866,15 @@ H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data) herr_t H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *_udata) { - H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t *udata = (H5HF_huge_remove_ud_t *)_udata; /* User callback data */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Free the space in the file for the object being removed */ - if(H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr, ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len) < 0) + if (H5MF_xfree(udata->hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, + ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->addr, + ((const H5HF_huge_bt2_filt_dir_rec_t *)nrecord)->len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free space for huge object on disk") /* Set the length of the object removed */ @@ -913,7 +884,6 @@ H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__huge_bt2_filt_dir_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_store * @@ -937,7 +907,6 @@ H5HF__huge_bt2_filt_dir_store(void *nrecord, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_store() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_compare * @@ -960,13 +929,13 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul FUNC_ENTER_STATIC_NOERR - if(rec1->addr < rec2->addr) + if (rec1->addr < rec2->addr) *result = -1; - else if(rec1->addr > rec2->addr) + else if (rec1->addr > rec2->addr) *result = 1; - else if(rec1->len < rec2->len) + else if (rec1->len < rec2->len) *result = -1; - else if(rec1->len > rec2->len) + else if (rec1->len > rec2->len) *result = 1; else *result = 0; @@ -974,7 +943,6 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_compare() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_encode * @@ -991,7 +959,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 @@ -1008,7 +976,6 @@ H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_decode * @@ -1025,7 +992,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 @@ -1042,7 +1009,6 @@ H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_filt_dir_debug * @@ -1057,16 +1023,15 @@ H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, - const void *_nrecord, const void H5_ATTR_UNUSED *_udata) +H5HF__huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR - HDfprintf(stream, "%*s%-*s {%a, %Hu, %x, %Hu}\n", indent, "", fwidth, "Record:", - nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %" PRIuHSIZE ", %x, %" PRIuHSIZE "}\n", indent, "", fwidth, + "Record:", nrecord->addr, nrecord->len, nrecord->filter_mask, nrecord->obj_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_debug() */ - diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 692b3a23ebb..fde5a4f27ba 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,42 +26,37 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* Fractal heap format version #'s */ -#define H5HF_HDR_VERSION 0 /* Header */ -#define H5HF_DBLOCK_VERSION 0 /* Direct block */ -#define H5HF_IBLOCK_VERSION 0 /* Indirect block */ - +#define H5HF_HDR_VERSION 0 /* Header */ +#define H5HF_DBLOCK_VERSION 0 /* Direct block */ +#define H5HF_IBLOCK_VERSION 0 /* Indirect block */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -73,123 +68,114 @@ static herr_t H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *d /* Metadata cache (H5AC) callbacks */ static herr_t H5HF__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); -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 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); -static herr_t H5HF__cache_hdr_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +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); +static herr_t H5HF__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); 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); -static herr_t H5HF__cache_iblock_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +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); +static herr_t H5HF__cache_iblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *thing); 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); -static herr_t H5HF__cache_dblock_serialize(const H5F_t *f, void *image, - size_t len, void *thing); +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); +static herr_t H5HF__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *thing); static herr_t H5HF__cache_dblock_free_icr(void *thing); static herr_t H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size); /* Debugging Function Prototypes */ #ifndef NDEBUG -static herr_t H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, - hbool_t *fd_clean, hbool_t *clean); -static herr_t H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, unsigned *iblock_status, - hbool_t *fd_clean, hbool_t *clean); -static herr_t H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, hbool_t *fd_clean, - hbool_t *clean, hbool_t *has_dblocks); -static herr_t H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, - haddr_t fd_parent_addr, H5HF_indirect_t *iblock, - hbool_t *fd_clean, hbool_t *clean, hbool_t *has_iblocks); +static herr_t H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_clean, + hbool_t *clean); +static herr_t H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, unsigned *iblock_status, + hbool_t *fd_clean, hbool_t *clean); +static herr_t H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, hbool_t *fd_clean, + hbool_t *clean, hbool_t *has_dblocks); +static herr_t H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, + H5HF_indirect_t *iblock, hbool_t *fd_clean, + hbool_t *clean, hbool_t *has_iblocks); #endif /* NDEBUG */ - /*********************/ /* Package Variables */ /*********************/ /* H5HF header inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_HDR[1] = {{ - H5AC_FHEAP_HDR_ID, /* Metadata client ID */ - "fractal heap header", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_HDR, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5AC_FHEAP_HDR_ID, /* Metadata client ID */ + "fractal heap header", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_HDR, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ H5HF__cache_hdr_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HF__cache_hdr_get_final_load_size, /* 'get_final_load_size' callback */ - H5HF__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_hdr_deserialize, /* 'deserialize' callback */ - H5HF__cache_hdr_image_len, /* 'image_len' callback */ - H5HF__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_hdr_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HF__cache_hdr_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5HF__cache_hdr_get_final_load_size, /* 'get_final_load_size' callback */ + H5HF__cache_hdr_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_hdr_deserialize, /* 'deserialize' callback */ + H5HF__cache_hdr_image_len, /* 'image_len' callback */ + H5HF__cache_hdr_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_hdr_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HF__cache_hdr_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5HF indirect block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_IBLOCK[1] = {{ - H5AC_FHEAP_IBLOCK_ID, /* Metadata client ID */ - "fractal heap indirect block", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_IBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HF__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5HF__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_iblock_deserialize, /* 'deserialize' callback */ - H5HF__cache_iblock_image_len, /* 'image_len' callback */ - H5HF__cache_iblock_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_iblock_serialize, /* 'serialize' callback */ - H5HF__cache_iblock_notify, /* 'notify' callback */ - H5HF__cache_iblock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_FHEAP_IBLOCK_ID, /* Metadata client ID */ + "fractal heap indirect block", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_IBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HF__cache_iblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5HF__cache_iblock_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_iblock_deserialize, /* 'deserialize' callback */ + H5HF__cache_iblock_image_len, /* 'image_len' callback */ + H5HF__cache_iblock_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_iblock_serialize, /* 'serialize' callback */ + H5HF__cache_iblock_notify, /* 'notify' callback */ + H5HF__cache_iblock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5HF direct block inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{ - H5AC_FHEAP_DBLOCK_ID, /* Metadata client ID */ - "fractal heap direct block", /* Metadata client name (for debugging) */ - H5FD_MEM_FHEAP_DBLOCK, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HF__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5HF__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ - H5HF__cache_dblock_deserialize, /* 'deserialize' callback */ - H5HF__cache_dblock_image_len, /* 'image_len' callback */ - H5HF__cache_dblock_pre_serialize, /* 'pre_serialize' callback */ - H5HF__cache_dblock_serialize, /* 'serialize' callback */ - H5HF__cache_dblock_notify, /* 'notify' callback */ - H5HF__cache_dblock_free_icr, /* 'free_icr' callback */ - H5HF__cache_dblock_fsf_size, /* 'fsf_size' callback */ + H5AC_FHEAP_DBLOCK_ID, /* Metadata client ID */ + "fractal heap direct block", /* Metadata client name (for debugging) */ + H5FD_MEM_FHEAP_DBLOCK, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HF__cache_dblock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5HF__cache_dblock_verify_chksum, /* 'verify_chksum' callback */ + H5HF__cache_dblock_deserialize, /* 'deserialize' callback */ + H5HF__cache_dblock_image_len, /* 'image_len' callback */ + H5HF__cache_dblock_pre_serialize, /* 'pre_serialize' callback */ + H5HF__cache_dblock_serialize, /* 'serialize' callback */ + H5HF__cache_dblock_notify, /* 'notify' callback */ + H5HF__cache_dblock_free_icr, /* 'free_icr' callback */ + H5HF__cache_dblock_fsf_size, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -197,8 +183,6 @@ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{ /* Declare a free list to manage heap direct block data to/from disk */ H5FL_BLK_DEFINE(direct_block); - - /*------------------------------------------------------------------------- * Function: H5HF__hdr_prefix_decode() * @@ -215,8 +199,8 @@ H5FL_BLK_DEFINE(direct_block); static herr_t H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref) { - const uint8_t *image = *image_ref; /* Pointer into into supplied image */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = *image_ref; /* Pointer into into supplied image */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -225,17 +209,17 @@ H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref) HDassert(image); /* Magic number */ - if(HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "wrong fractal heap header signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_HDR_VERSION) + if (*image++ != H5HF_HDR_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong fractal heap header version") /* General heap information */ - UINT16DECODE(image, hdr->id_len); /* Heap ID length */ - UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */ + UINT16DECODE(image, hdr->id_len); /* Heap ID length */ + UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */ /* Update the image buffer pointer */ *image_ref = image; @@ -244,7 +228,6 @@ H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_prefix_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__dtable_decode * @@ -293,7 +276,6 @@ H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_decode() */ - /*------------------------------------------------------------------------- * Function: H5HF__dtable_encode * @@ -342,7 +324,6 @@ H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_encode() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_get_initial_load_size() * @@ -351,7 +332,7 @@ H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) * * Note also that the value returned by this function presumes that * there is no I/O filtering data in the header. If there is, the - * size reported will be too small, and H5C_load_entry() + * size reported will be too small, and H5C__load_entry() * will have to make two tries to load the fractal heap header. * * Return: Success: SUCCEED @@ -366,7 +347,7 @@ static herr_t H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) { H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* Pointer to user data */ - H5HF_hdr_t dummy_hdr; /* Dummy header -- to compute size */ + H5HF_hdr_t dummy_hdr; /* Dummy header -- to compute size */ FUNC_ENTER_STATIC_NOERR @@ -375,7 +356,7 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) HDassert(image_len); /* Set the internal parameters for the heap */ - dummy_hdr.f = udata->f; + dummy_hdr.f = udata->f; dummy_hdr.sizeof_size = H5F_SIZEOF_SIZE(udata->f); dummy_hdr.sizeof_addr = H5F_SIZEOF_ADDR(udata->f); @@ -385,7 +366,6 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_hdr_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_get_final_load_size() * @@ -401,13 +381,13 @@ H5HF__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) +H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, + 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 */ - H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t hdr; /* Temporary fractal heap header */ + 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 */ FUNC_ENTER_STATIC @@ -418,21 +398,20 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UN HDassert(*actual_len == image_len); /* Deserialize the fractal heap header's prefix */ - if(H5HF__hdr_prefix_decode(&hdr, &image) < 0) + if (H5HF__hdr_prefix_decode(&hdr, &image) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode fractal heap header prefix") /* Check for I/O filter info on this heap */ - if(hdr.filter_len > 0) + if (hdr.filter_len > 0) /* Compute the extra heap header size */ - *actual_len += (size_t)(H5F_SIZEOF_SIZE(udata->f) /* Size of size for filtered root direct block */ - + (unsigned)4 /* Size of filter mask for filtered root direct block */ - + hdr.filter_len); /* Size of encoded I/O filter info */ + *actual_len += (size_t)(H5F_SIZEOF_SIZE(udata->f) /* Size of size for filtered root direct block */ + + (unsigned)4 /* Size of filter mask for filtered root direct block */ + + hdr.filter_len); /* Size of encoded I/O filter info */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_verify_chksum * @@ -449,10 +428,10 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UN static htri_t H5HF__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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -462,13 +441,12 @@ H5HF__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_deserialize * @@ -486,15 +464,14 @@ 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__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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint8_t heap_flags; /* Status flags for heap */ - void * ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -505,28 +482,29 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate space for the fractal heap data structure */ - if(NULL == (hdr = H5HF_hdr_alloc(udata->f))) + if (NULL == (hdr = H5HF__hdr_alloc(udata->f))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Deserialize the fractal heap header's prefix */ - if(H5HF__hdr_prefix_decode(hdr, &image) < 0) + if (H5HF__hdr_prefix_decode(hdr, &image) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode fractal heap header prefix") /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ /* (bit 1: checksum direct blocks) */ - heap_flags = *image++; + heap_flags = *image++; hdr->huge_ids_wrapped = heap_flags & H5HF_HDR_FLAGS_HUGE_ID_WRAPPED; hdr->checksum_dblocks = heap_flags & H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS; /* "Huge" object information */ - UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ - H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ + UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ + H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ H5F_addr_decode(udata->f, &image, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ - H5F_DECODE_LENGTH(udata->f, image, hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5F_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ + H5F_DECODE_LENGTH(udata->f, image, + hdr->total_man_free); /* Internal free space in managed direct blocks */ + H5F_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_DECODE_LENGTH(udata->f, image, hdr->man_size); @@ -539,7 +517,7 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, H5F_DECODE_LENGTH(udata->f, image, hdr->tiny_nobjs); /* Managed objects' doubling-table info */ - if(H5HF__dtable_decode(hdr->f, &image, &(hdr->man_dtable)) < 0) + if (H5HF__dtable_decode(hdr->f, &image, &(hdr->man_dtable)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, NULL, "unable to encode managed obj. doubling table info") /* Set the fractal heap header's 'base' size */ @@ -550,16 +528,16 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == (hdr->heap_size - H5HF_SIZEOF_CHKSUM)); /* Check for I/O filter information to decode */ - if(hdr->filter_len > 0) { - H5O_pline_t *pline; /* Pipeline information from the header on disk */ + if (hdr->filter_len > 0) { + H5O_pline_t *pline; /* Pipeline information from the header on disk */ /* Sanity check */ - HDassert(len > hdr->heap_size); /* A header with filter info is > than a standard header */ + HDassert(len > hdr->heap_size); /* A header with filter info is > than a standard header */ /* Compute the heap header's size */ - hdr->heap_size += (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */ - + (unsigned)4 /* Size of filter mask for filtered root direct block */ - + hdr->filter_len); /* Size of encoded I/O filter info */ + hdr->heap_size += (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */ + + (unsigned)4 /* Size of filter mask for filtered root direct block */ + + hdr->filter_len); /* Size of encoded I/O filter info */ /* Decode the size of a filtered root direct block */ H5F_DECODE_LENGTH(udata->f, image, hdr->pline_root_direct_size); @@ -568,14 +546,14 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, UINT32DECODE(image, hdr->pline_root_direct_filter_mask); /* Decode I/O filter information */ - if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, NULL, H5O_PLINE_ID, len, image))) + if (NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, NULL, H5O_PLINE_ID, len, image))) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode I/O pipeline filters") /* Advance past filter info to checksum */ image += hdr->filter_len; /* Copy the information into the header's I/O pipeline structure */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline))) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, NULL, "can't copy I/O filter pipeline") /* Release the space allocated for the I/O pipeline filters */ @@ -589,21 +567,20 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, HDassert((size_t)(image - (const uint8_t *)_image) == hdr->heap_size); /* Finish initialization of heap header */ - if(H5HF_hdr_finish_init(hdr) < 0) + if (H5HF__hdr_finish_init(hdr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't finish initializing shared fractal heap header") /* Set return value */ ret_value = (void *)hdr; done: - if(!ret_value && hdr) - if(H5HF_hdr_free(hdr) < 0) + if (!ret_value && hdr) + if (H5HF__hdr_free(hdr) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_image_len * @@ -624,7 +601,7 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, static herr_t H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) { - const H5HF_hdr_t *hdr = (const H5HF_hdr_t *)_thing; /* Fractal heap info */ + const H5HF_hdr_t *hdr = (const H5HF_hdr_t *)_thing; /* Fractal heap info */ FUNC_ENTER_STATIC_NOERR @@ -639,7 +616,6 @@ H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_hdr_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_pre_serialize * @@ -662,11 +638,11 @@ 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 H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len, - unsigned *flags) + haddr_t H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len, + unsigned *flags) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -682,46 +658,47 @@ H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, HDassert(flags); #ifndef NDEBUG -{ - hbool_t descendants_clean = TRUE; - hbool_t fd_children_clean = TRUE; + { + hbool_t descendants_clean = TRUE; + hbool_t fd_children_clean = TRUE; - /* Verify that flush dependencies are working correctly. Do this - * by verifying that either: - * - * 1) the header has a root iblock, and that the root iblock and all - * of its children are clean, or - * - * 2) The header has a root dblock, which is clean, or - * - * 3) The heap is empty, and thus the header has neither a root - * iblock no a root dblock. In this case, the flush ordering - * constraint is met by default. - * - * Do this with a call to H5HF__cache_verify_hdr_descendants_clean(). - * - * Note that descendants need not be clean if the pre_serialize call - * is made during a cache serialization instead of an entry or cache - * flush. - * - * Note also that with the recent change in the definition of flush - * dependency, not all descendants need be clean -- only direct flush - * dependency children. - * - * Finally, observe that the H5HF__cache_verify_hdr_descendants_clean() - * call still looks for dirty descendants. At present we do not check - * this value. - */ - if(H5HF__cache_verify_hdr_descendants_clean((H5F_t *)f, hdr, &fd_children_clean, &descendants_clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify hdr descendants clean.") - HDassert(fd_children_clean); -} + /* Verify that flush dependencies are working correctly. Do this + * by verifying that either: + * + * 1) the header has a root iblock, and that the root iblock and all + * of its children are clean, or + * + * 2) The header has a root dblock, which is clean, or + * + * 3) The heap is empty, and thus the header has neither a root + * iblock no a root dblock. In this case, the flush ordering + * constraint is met by default. + * + * Do this with a call to H5HF__cache_verify_hdr_descendants_clean(). + * + * Note that descendants need not be clean if the pre_serialize call + * is made during a cache serialization instead of an entry or cache + * flush. + * + * Note also that with the recent change in the definition of flush + * dependency, not all descendants need be clean -- only direct flush + * dependency children. + * + * Finally, observe that the H5HF__cache_verify_hdr_descendants_clean() + * call still looks for dirty descendants. At present we do not check + * this value. + */ + if (H5HF__cache_verify_hdr_descendants_clean((H5F_t *)f, hdr, &fd_children_clean, + &descendants_clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify hdr descendants clean.") + HDassert(fd_children_clean); + } #endif /* NDEBUG */ - if(H5F_IS_TMP_ADDR(f, addr)) + if (H5F_IS_TMP_ADDR(f, addr)) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "addr in temporary space?!?."); - if(len != hdr->heap_size) + if (len != hdr->heap_size) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "unexpected image len."); *flags = 0; @@ -730,7 +707,6 @@ H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_serialize * @@ -747,14 +723,13 @@ H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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 heap_flags; /* Status flags for heap */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + 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 */ FUNC_ENTER_STATIC @@ -777,8 +752,8 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN *image++ = H5HF_HDR_VERSION; /* General heap information */ - UINT16ENCODE(image, hdr->id_len); /* Heap ID length */ - UINT16ENCODE(image, hdr->filter_len); /* I/O filters' encoded length */ + UINT16ENCODE(image, hdr->id_len); /* Heap ID length */ + UINT16ENCODE(image, hdr->filter_len); /* I/O filters' encoded length */ /* Heap status flags */ /* (bit 0: "huge" object IDs have wrapped) */ @@ -786,16 +761,16 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN heap_flags = 0; heap_flags = (uint8_t)(heap_flags | (hdr->huge_ids_wrapped ? H5HF_HDR_FLAGS_HUGE_ID_WRAPPED : 0)); heap_flags = (uint8_t)(heap_flags | (hdr->checksum_dblocks ? H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS : 0)); - *image++ = heap_flags; + *image++ = heap_flags; /* "Huge" object information */ - UINT32ENCODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ + UINT32ENCODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ H5F_ENCODE_LENGTH(f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ H5F_addr_encode(f, &image, hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ H5F_ENCODE_LENGTH(f, image, hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5F_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ + H5F_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_ENCODE_LENGTH(f, image, hdr->man_size); @@ -808,11 +783,11 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN H5F_ENCODE_LENGTH(f, image, hdr->tiny_nobjs); /* Managed objects' doubling-table info */ - if(H5HF__dtable_encode(hdr->f, &image, &(hdr->man_dtable)) < 0) + if (H5HF__dtable_encode(hdr->f, &image, &(hdr->man_dtable)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "unable to encode managed obj. doubling table info") /* Check for I/O filter information to encode */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Encode the size of a filtered root direct block */ H5F_ENCODE_LENGTH(f, image, hdr->pline_root_direct_size); @@ -820,7 +795,7 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN UINT32ENCODE(image, hdr->pline_root_direct_filter_mask); /* Encode I/O filter information */ - if(H5O_msg_encode(hdr->f, H5O_PLINE_ID, FALSE, image, &(hdr->pline)) < 0) + 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") image += hdr->filter_len; } /* end if */ @@ -838,7 +813,6 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_hdr_free_icr * @@ -866,8 +840,8 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN static herr_t H5HF__cache_hdr_free_icr(void *_thing) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -877,14 +851,13 @@ H5HF__cache_hdr_free_icr(void *_thing) HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); HDassert(hdr->rc == 0); - if(H5HF_hdr_free(hdr) < 0) + if (H5HF__hdr_free(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "unable to release fractal heap header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_get_initial_load_size() * @@ -902,7 +875,7 @@ H5HF__cache_hdr_free_icr(void *_thing) static herr_t H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) { - H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ + H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -918,7 +891,6 @@ H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_iblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_verify_chksum * @@ -935,10 +907,10 @@ H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5HF__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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -948,14 +920,12 @@ H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_verify_chksum() */ - - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_deserialize * @@ -977,17 +947,17 @@ H5HF__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UN *------------------------------------------------------------------------- */ 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__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_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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC @@ -1002,17 +972,17 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED hdr->f = udata->f; /* Allocate space for the fractal heap indirect block */ - if(NULL == (iblock = H5FL_CALLOC(H5HF_indirect_t))) + if (NULL == (iblock = H5FL_CALLOC(H5HF_indirect_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Share common heap information */ iblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF__hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Set block's internal information */ - iblock->rc = 0; - iblock->nrows = *udata->nrows; + iblock->rc = 0; + iblock->nrows = *udata->nrows; iblock->nchildren = 0; /* Compute size of indirect block */ @@ -1022,17 +992,17 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(iblock->size == len); /* Magic number */ - if(HDmemcmp(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong fractal heap indirect block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_IBLOCK_VERSION) + if (*image++ != H5HF_IBLOCK_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block */ H5F_addr_decode(udata->f, &image, &heap_addr); - if(H5F_addr_ne(heap_addr, hdr->heap_addr)) + if (H5F_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") /* Address of parent block */ @@ -1040,15 +1010,16 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* this copy of the parent pointer is needed by the notify callback so */ /* that it can take down flush dependencies on eviction even if */ /* the parent pointer has been nulled out. JRM -- 5/18/14 */ - if(udata->par_info->iblock) + if (udata->par_info->iblock) iblock->fd_parent = udata->par_info->iblock; else iblock->fd_parent = udata->par_info->hdr; iblock->par_entry = udata->par_info->entry; - if(iblock->parent) { + if (iblock->parent) { /* Share parent block */ - if(H5HF_iblock_incr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (H5HF__iblock_incr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") /* Set max. # of rows in this block */ iblock->max_rows = iblock->nrows; @@ -1063,33 +1034,35 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Allocate & decode child block entry tables */ HDassert(iblock->nrows > 0); - if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct entries") - if(hdr->filter_len > 0) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); /* Allocate indirect block filtered entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_MALLOC(H5HF_indirect_filt_ent_t, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_MALLOC(H5HF_indirect_filt_ent_t, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block entries") } /* end if */ else iblock->filt_ents = NULL; - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Decode child block address */ H5F_addr_decode(udata->f, &image, &(iblock->ents[u].addr)); /* Check for heap with I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* Decode extra information for direct blocks */ - if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { + if (u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { /* Size of filtered direct block */ H5F_DECODE_LENGTH(udata->f, image, iblock->filt_ents[u].size); @@ -1097,23 +1070,23 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* (either both the address & size are defined or both are * not defined) */ - HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) - || (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); + HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) || + (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); /* I/O filter mask for filtered direct block */ UINT32DECODE(image, iblock->filt_ents[u].filter_mask); } /* end if */ - } /* end if */ + } /* end if */ /* Count child blocks */ - if(H5F_addr_defined(iblock->ents[u].addr)) { + if (H5F_addr_defined(iblock->ents[u].addr)) { iblock->nchildren++; iblock->max_child = u; } /* end if */ - } /* end for */ + } /* end for */ /* Sanity check */ - HDassert(iblock->nchildren); /* indirect blocks w/no children should have been deleted */ + HDassert(iblock->nchildren); /* indirect blocks w/no children should have been deleted */ /* checksum verification already done by verify_chksum cb */ @@ -1124,14 +1097,15 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert((size_t)(image - (const uint8_t *)_image) == iblock->size); /* Check if we have any indirect block children */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows;/* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of indirect rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Allocate & initialize child indirect block pointer array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC( + H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for block entries") } /* end if */ else @@ -1141,14 +1115,13 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED ret_value = (void *)iblock; done: - if(!ret_value && iblock) - if(H5HF_man_iblock_dest(iblock) < 0) + if (!ret_value && iblock) + if (H5HF__man_iblock_dest(iblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_image_len * @@ -1165,7 +1138,7 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED static herr_t H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) { - const H5HF_indirect_t *iblock = (const H5HF_indirect_t *)_thing; /* Indirect block info */ + const H5HF_indirect_t *iblock = (const H5HF_indirect_t *)_thing; /* Indirect block info */ FUNC_ENTER_STATIC_NOERR @@ -1180,7 +1153,6 @@ H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_iblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_pre_serialize * @@ -1202,13 +1174,12 @@ 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 H5_ATTR_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_UNUSED *new_len, - unsigned *flags) +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_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -1229,85 +1200,86 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); #ifndef NDEBUG -{ - hbool_t descendants_clean = TRUE; - hbool_t fd_children_clean = TRUE; - unsigned iblock_status = 0; - - /* verify that flush dependencies are working correctly. Do this - * by verifying that all immediate flush dependency children of this - * iblock are clean. - */ - if(H5AC_get_entry_status(f, iblock->addr, &iblock_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") + { + hbool_t descendants_clean = TRUE; + hbool_t fd_children_clean = TRUE; + unsigned iblock_status = 0; + + /* verify that flush dependencies are working correctly. Do this + * by verifying that all immediate flush dependency children of this + * iblock are clean. + */ + if (H5AC_get_entry_status(f, iblock->addr, &iblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") - /* since the current iblock is the guest of honor in a flush, we know - * that it is locked into the cache for the duration of the call. Hence - * there is no need to check to see if it is pinned or protected, or to - * protect it if it is not. - */ - if(H5HF__cache_verify_iblock_descendants_clean((H5F_t *)f, iblock->addr, iblock, &iblock_status, &fd_children_clean, &descendants_clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify descendants clean.") - HDassert(fd_children_clean); -} + /* since the current iblock is the guest of honor in a flush, we know + * that it is locked into the cache for the duration of the call. Hence + * there is no need to check to see if it is pinned or protected, or to + * protect it if it is not. + */ + if (H5HF__cache_verify_iblock_descendants_clean((H5F_t *)f, iblock->addr, iblock, &iblock_status, + &fd_children_clean, &descendants_clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify descendants clean.") + HDassert(fd_children_clean); + } #endif /* NDEBUG */ /* Check to see if we must re-allocate the iblock from temporary to * normal (AKA real) file space. */ - if(H5F_IS_TMP_ADDR(f, addr)) { + if (H5F_IS_TMP_ADDR(f, addr)) { haddr_t iblock_addr; /* Allocate 'normal' space for the new indirect block on disk */ - if(HADDR_UNDEF == (iblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == + (iblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") /* Sanity check */ HDassert(!H5F_addr_eq(iblock->addr, iblock_addr)); /* Let the metadata cache know the block moved */ - if(H5AC_move_entry((H5F_t *)f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock_addr) < 0) + if (H5AC_move_entry((H5F_t *)f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move indirect block") /* Update the internal address for the block */ iblock->addr = iblock_addr; /* Check for root indirect block */ - if(NULL == iblock->parent) { + if (NULL == iblock->parent) { /* Update information about indirect block's location */ hdr->man_dtable.table_addr = iblock_addr; /* Mark that heap header was modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ else { - H5HF_indirect_t *par_iblock; /* Parent indirect block */ - unsigned par_entry; /* Entry in parent indirect block */ + H5HF_indirect_t *par_iblock; /* Parent indirect block */ + unsigned par_entry; /* Entry in parent indirect block */ /* Get parent information */ par_iblock = iblock->parent; - par_entry = iblock->par_entry; + par_entry = iblock->par_entry; /* Update information about indirect block's location */ par_iblock->ents[par_entry].addr = iblock_addr; /* Mark that parent was modified */ - if(H5HF_iblock_dirty(par_iblock) < 0) + if (H5HF__iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ - *new_addr = iblock_addr; - *flags = H5AC__SERIALIZE_MOVED_FLAG; + *new_addr = iblock_addr; + *flags = H5AC__SERIALIZE_MOVED_FLAG; } /* end if */ else - *flags = 0; + *flags = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_serialize * @@ -1324,19 +1296,18 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, *------------------------------------------------------------------------- */ static herr_t -H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + 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 */ #ifndef NDEBUG - unsigned nchildren = 0; /* Track # of children */ - size_t max_child = 0; /* Track max. child entry used */ -#endif /* NDEBUG */ - uint32_t metadata_chksum; /* Computed metadata checksum value */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nchildren = 0; /* Track # of children */ + size_t max_child = 0; /* Track max. child entry used */ +#endif /* NDEBUG */ + uint32_t metadata_chksum; /* Computed metadata checksum value */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1373,23 +1344,23 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG UINT64ENCODE_VAR(image, iblock->block_off, hdr->heap_off_size); /* Encode indirect block-specific fields */ - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Encode child block address */ H5F_addr_encode(f, &image, iblock->ents[u].addr); /* Check for heap with I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* Encode extra information for direct blocks */ - if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { + if (u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) { /* Sanity check */ /* (either both the address & size are defined or both are * not defined) */ - HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) - || (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); + HDassert((H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size) || + (!H5F_addr_defined(iblock->ents[u].addr) && iblock->filt_ents[u].size == 0)); /* Size of filtered direct block */ H5F_ENCODE_LENGTH(f, image, iblock->filt_ents[u].size); @@ -1397,17 +1368,17 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG /* I/O filter mask for filtered direct block */ UINT32ENCODE(image, iblock->filt_ents[u].filter_mask); } /* end if */ - } /* end if */ + } /* end if */ #ifndef NDEBUG /* Count child blocks */ - if(H5F_addr_defined(iblock->ents[u].addr)) { + if (H5F_addr_defined(iblock->ents[u].addr)) { nchildren++; - if(u > max_child) + if (u > max_child) max_child = u; } /* end if */ -#endif /* NDEBUG */ - } /* end for */ +#endif /* NDEBUG */ + } /* end for */ /* Compute checksum */ metadata_chksum = H5_checksum_metadata((uint8_t *)_image, (size_t)(image - (uint8_t *)_image), 0); @@ -1425,7 +1396,6 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_notify * @@ -1447,8 +1417,8 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG static herr_t H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) { - H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1459,55 +1429,58 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) HDassert(iblock->hdr); /* further sanity checks */ - if(iblock->parent == NULL) { + if (iblock->parent == NULL) { /* pointer from hdr to root iblock will not be set up unless */ /* the fractal heap has already pinned the hdr. Do what */ /* sanity checking we can. */ - if((iblock->block_off == 0) && (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)) - HDassert(iblock->hdr->root_iblock == iblock); + if ((iblock->block_off == 0) && (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)) + HDassert(iblock->hdr->root_iblock == iblock); } /* end if */ else { /* if this is a child iblock, verify that the pointers are */ /* either uninitialized or set up correctly. */ H5HF_indirect_t H5_ATTR_NDEBUG_UNUSED *par_iblock = iblock->parent; - unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index in parent's child iblock pointer array */ + unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* The pointer to iblock in the parent may not be set yet -- */ /* verify that it is either NULL, or that it has been set to */ /* iblock. */ - HDassert((NULL == par_iblock->child_iblocks[indir_idx]) || (par_iblock->child_iblocks[indir_idx] == iblock)); + HDassert((NULL == par_iblock->child_iblocks[indir_idx]) || + (par_iblock->child_iblocks[indir_idx] == iblock)); } /* end else */ - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency with parent, if there is one */ - if(iblock->fd_parent) - if(H5AC_create_flush_dependency(iblock->fd_parent, iblock) < 0) + if (iblock->fd_parent) + if (H5AC_create_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(iblock->fd_parent) { + if (iblock->fd_parent) { /* Destroy flush dependency with parent */ - if(H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) + if (H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") iblock->fd_parent = NULL; } /* end if */ @@ -1522,7 +1495,6 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_iblock_free_icr * @@ -1544,8 +1516,8 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5HF__cache_iblock_free_icr(void *thing) { - H5HF_indirect_t *iblock = (H5HF_indirect_t *)thing; /* Fractal heap indirect block to free */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = (H5HF_indirect_t *)thing; /* Fractal heap indirect block to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1557,14 +1529,13 @@ H5HF__cache_iblock_free_icr(void *thing) HDassert(iblock->hdr); /* Destroy fractal heap indirect block */ - if(H5HF_man_iblock_dest(iblock) < 0) + if (H5HF__man_iblock_dest(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_get_initial_load_size() * @@ -1582,9 +1553,9 @@ H5HF__cache_iblock_free_icr(void *thing) 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_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 */ FUNC_ENTER_STATIC_NOERR @@ -1599,22 +1570,21 @@ H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) HDassert(hdr); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Check for root direct block */ - if(par_info->iblock == NULL) + if (par_info->iblock == NULL) /* filtered root direct block */ *image_len = hdr->pline_root_direct_size; else /* filtered direct block */ *image_len = par_info->iblock->filt_ents[par_info->entry].size; - } /* end if */ + } /* end if */ else *image_len = udata->dblock_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_verify_chksum * @@ -1631,16 +1601,16 @@ 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 */ - 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 */ - 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 */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + 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 */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -1653,44 +1623,45 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(hdr); /* Get out if data block is not checksummed */ - if(!(hdr->checksum_dblocks)) - HGOTO_DONE(TRUE); + if (!(hdr->checksum_dblocks)) + HGOTO_DONE(TRUE); - if(hdr->filter_len > 0) { - size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ - unsigned filter_mask; /* Excluded filters for direct block */ - H5Z_cb_t filter_cb; /* Filter callback structure */ + if (hdr->filter_len > 0) { + size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ + unsigned filter_mask; /* Excluded filters for direct block */ + H5Z_cb_t filter_cb; /* Filter callback structure */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on and copy image into * it. Must do this as H5Z_pipeline() may re-size the buffer * provided to it. */ - if(NULL == (read_buf = H5MM_malloc(len))) + if (NULL == (read_buf = H5MM_malloc(len))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") /* Set up parameters for filter pipeline */ - nbytes = len; + nbytes = len; filter_mask = udata->filter_mask; H5MM_memcpy(read_buf, image, len); /* Push direct block data through I/O filter pipeline */ - if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, + &len, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed") /* Update info about direct block */ udata->decompressed = TRUE; - len = nbytes; + len = nbytes; } /* end if */ else - read_buf = (void *)image; /* Casting away const OK - QAK */ + read_buf = (void *)image; /* Casting away const OK - QAK */ /* Decode checksum */ chk_size = (size_t)(H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) - H5HF_SIZEOF_CHKSUM); - chk_p = (uint8_t *)read_buf + chk_size; + chk_p = (uint8_t *)read_buf + chk_size; /* Metadata checksum */ UINT32DECODE(chk_p, stored_chksum); @@ -1708,32 +1679,31 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) UINT32ENCODE(chk_p, stored_chksum) /* Verify checksum */ - if(stored_chksum != computed_chksum) - HGOTO_DONE(FALSE); + if (stored_chksum != computed_chksum) + HGOTO_DONE(FALSE); /* Save the decompressed data to be used later in deserialize callback */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ - HDassert(udata->decompressed); - HDassert(len == udata->dblock_size); + HDassert(udata->decompressed); + HDassert(len == udata->dblock_size); - /* Allocate block buffer */ - if(NULL == (udata->dblk = H5FL_BLK_MALLOC(direct_block, (size_t)len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Allocate block buffer */ + if (NULL == (udata->dblk = H5FL_BLK_MALLOC(direct_block, (size_t)len))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Copy un-filtered data into block's buffer */ - H5MM_memcpy(udata->dblk, read_buf, len); + /* Copy un-filtered data into block's buffer */ + H5MM_memcpy(udata->dblk, read_buf, len); } /* end if */ done: /* Release the read buffer */ - if(read_buf && read_buf != image) - H5MM_xfree(read_buf); + if (read_buf && read_buf != image) + H5MM_xfree(read_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_deserialize * @@ -1755,17 +1725,16 @@ 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__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_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 */ - haddr_t heap_addr; /* Address of heap header in the file */ - void * ret_value = NULL; /* Return value */ + 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 */ + haddr_t heap_addr; /* Address of heap header in the file */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1781,7 +1750,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate space for the fractal heap direct block */ - if(NULL == (dblock = H5FL_CALLOC(H5HF_direct_t))) + if (NULL == (dblock = H5FL_CALLOC(H5HF_direct_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t)); @@ -1790,16 +1759,16 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Share common heap information */ dblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF__hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header") /* Set block's internal information */ dblock->size = udata->dblock_size; /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Direct block is already decompressed in verify_chksum callback */ - if(udata->decompressed) { + if (udata->decompressed) { /* Sanity check */ HDassert(udata->dblk); @@ -1808,16 +1777,16 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, udata->dblk = NULL; } /* end if */ else { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ - unsigned filter_mask; /* Excluded filters for direct block */ + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */ + unsigned filter_mask; /* Excluded filters for direct block */ /* Sanity check */ HDassert(udata->dblk == NULL); /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on and copy image into * it. Must do this as H5Z_pipeline() may resize the buffer @@ -1830,9 +1799,10 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, H5MM_memcpy(read_buf, image, len); /* Push direct block data through I/O filter pipeline */ - nbytes = len; + nbytes = len; filter_mask = udata->filter_mask; - if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, + &nbytes, &len, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed") /* Sanity check */ @@ -1841,7 +1811,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Copy un-filtered data into block's buffer */ H5MM_memcpy(dblock->blk, read_buf, dblock->size); } /* end if */ - } /* end if */ + } /* end if */ else { /* Sanity checks */ HDassert(udata->dblk == NULL); @@ -1849,7 +1819,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, /* Allocate block buffer */ /* XXX: Change to using free-list factories */ - if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size))) + if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy image to dblock->blk */ @@ -1861,38 +1831,39 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, image = dblock->blk; /* Magic number */ - if(HDmemcmp(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong fractal heap direct block signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(*image++ != H5HF_DBLOCK_VERSION) + if (*image++ != H5HF_DBLOCK_VERSION) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->f, &image, &heap_addr); - if(H5F_addr_ne(heap_addr, hdr->heap_addr)) + if (H5F_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") /* Address of parent block */ dblock->parent = par_info->iblock; - if(par_info->iblock) + if (par_info->iblock) dblock->fd_parent = par_info->iblock; else dblock->fd_parent = par_info->hdr; dblock->par_entry = par_info->entry; - if(dblock->parent) { + if (dblock->parent) { /* Share parent block */ - if(H5HF_iblock_incr(dblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (H5HF__iblock_incr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ /* Offset of heap within the heap's address space */ UINT64DECODE_VAR(image, dblock->block_off, hdr->heap_off_size); /* Decode checksum on direct block, if requested */ - if(hdr->checksum_dblocks) { - uint32_t stored_chksum; /* Metadata checksum value */ + if (hdr->checksum_dblocks) { + uint32_t stored_chksum; /* Metadata checksum value */ /* checksum verification already done in verify_chksum cb */ @@ -1908,18 +1879,17 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, done: /* Release the read buffer */ - if(read_buf) + if (read_buf) H5MM_xfree(read_buf); /* Cleanup on error */ - if(!ret_value && dblock) - if(H5HF_man_dblock_dest(dblock) < 0) + if (!ret_value && dblock) + if (H5HF__man_dblock_dest(dblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_image_len * @@ -1938,9 +1908,9 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, 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 */ - size_t size; + const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Direct block info */ + const H5HF_hdr_t * hdr; /* Shared fractal heap information */ + size_t size; FUNC_ENTER_STATIC_NOERR @@ -1955,7 +1925,7 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) HDassert(hdr); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* * If the data is available, set to the compressed * size of the direct block -- otherwise set it equal to the @@ -1981,20 +1951,20 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) * and thus looking up the parent will likely return incorrect * data. */ - if(dblock->file_size != 0) + if (dblock->file_size != 0) size = dblock->file_size; else { - const H5HF_indirect_t *par_iblock = dblock->parent; /* Parent iblock */ + const H5HF_indirect_t *par_iblock = dblock->parent; /* Parent iblock */ - if(par_iblock) + if (par_iblock) size = par_iblock->filt_ents[dblock->par_entry].size; else size = hdr->pline_root_direct_size; - if(size == 0) + if (size == 0) size = dblock->size; } /* end else */ - } /* end if */ + } /* end if */ else size = dblock->size; @@ -2005,7 +1975,6 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_pre_serialize * @@ -2069,21 +2038,21 @@ 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) +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) { - 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_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 */ - size_t write_size; /* Size of buffer to write out */ - uint8_t *image; /* Pointer into raw data buffer */ - unsigned dblock_flags = 0; - herr_t ret_value = SUCCEED; /* Return value */ + 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_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 */ + size_t write_size; /* Size of buffer to write out */ + uint8_t * image; /* Pointer into raw data buffer */ + unsigned dblock_flags = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2101,8 +2070,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(flags); /* Set up local variables */ - hdr = dblock->hdr; - dblock_addr = addr; /* will update dblock_addr if we move the block */ + hdr = dblock->hdr; + dblock_addr = addr; /* will update dblock_addr if we move the block */ /* Set the shared heap header's file context for this operation */ hdr->f = (H5F_t *)f; @@ -2111,25 +2080,25 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(hdr->cache_info.type == H5AC_FHEAP_HDR); - if(dblock->parent) { - /* this is the common case, in which the direct block is the child + if (dblock->parent) { + /* this is the common case, in which the direct block is the child * of an indirect block. Set up the convenience variables we will * need if the address and/or compressed size of the on disk image * of the direct block changes, and do some sanity checking in * passing. */ par_iblock = dblock->parent; - par_entry = dblock->par_entry; + par_entry = dblock->par_entry; - HDassert(par_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(par_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); + HDassert(par_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(par_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, addr)); } /* end if */ else { - /* the direct block is a root direct block -- just set par_iblock + /* the direct block is a root direct block -- just set par_iblock * to NULL, as the field will not be used. */ - par_iblock = NULL; + par_iblock = NULL; } /* end else */ at_tmp_addr = H5F_IS_TMP_ADDR(f, addr); @@ -2157,8 +2126,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, UINT64ENCODE_VAR(image, dblock->block_off, hdr->heap_off_size); /* Metadata checksum */ - if(hdr->checksum_dblocks) { - uint32_t metadata_chksum; /* Computed metadata checksum value */ + if (hdr->checksum_dblocks) { + uint32_t metadata_chksum; /* Computed metadata checksum value */ /* Clear the checksum field, to compute the checksum */ HDmemset(image, 0, (size_t)H5HF_SIZEOF_CHKSUM); @@ -2184,18 +2153,18 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used */ - unsigned filter_mask = 0; /* Filter mask for block */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used */ + unsigned filter_mask = 0; /* Filter mask for block */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on */ write_size = dblock->size; - if(NULL == (write_buf = H5MM_malloc(write_size))) + if (NULL == (write_buf = H5MM_malloc(write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") /* Copy the direct block's image into the buffer to compress */ @@ -2203,7 +2172,8 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, /* Push direct block data through I/O filter pipeline */ nbytes = write_size; - if(H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &write_size, &write_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &write_size, + &write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "output pipeline failed") /* Use the compressed number of bytes as the size to write */ @@ -2218,7 +2188,7 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, */ /* Check for root direct block */ - if(dblock->parent == NULL) { + if (dblock->parent == NULL) { hbool_t hdr_changed = FALSE; /* Whether the header info changed */ /* Sanity check */ @@ -2226,9 +2196,9 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(hdr->pline_root_direct_size > 0); /* Check if the filter mask changed */ - if(hdr->pline_root_direct_filter_mask != filter_mask) { + if (hdr->pline_root_direct_filter_mask != filter_mask) { hdr->pline_root_direct_filter_mask = filter_mask; - hdr_changed = TRUE; + hdr_changed = TRUE; } /* end if */ /* verify that the cache's last record of the compressed @@ -2238,27 +2208,29 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(len == hdr->pline_root_direct_size); /* Check if we need to re-size the block on disk */ - if(hdr->pline_root_direct_size != write_size || at_tmp_addr) { + if (hdr->pline_root_direct_size != write_size || at_tmp_addr) { /* Check if the direct block is NOT currently allocated * in temp. file space * * (temp. file space does not need to be freed) */ - if(!at_tmp_addr) + if (!at_tmp_addr) /* Release direct block's current disk space */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)hdr->pline_root_direct_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)hdr->pline_root_direct_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") /* Allocate space for the compressed direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Update information about compressed direct block's * location & size */ HDassert(hdr->man_dtable.table_addr == addr); HDassert(hdr->pline_root_direct_size == len); - hdr->man_dtable.table_addr = dblock_addr; + hdr->man_dtable.table_addr = dblock_addr; hdr->pline_root_direct_size = write_size; /* Note that heap header was modified */ @@ -2266,21 +2238,21 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, } /* end if */ /* Check if heap header was modified */ - if(hdr_changed) - if(H5HF_hdr_dirty(hdr) < 0) + if (hdr_changed) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") - } /* end if */ - else { /* the direct block's parent is an indirect block */ - hbool_t par_changed = FALSE; /* Whether the parent's infochanged */ + } /* end if */ + else { /* the direct block's parent is an indirect block */ + hbool_t par_changed = FALSE; /* Whether the parent's infochanged */ /* Sanity check */ HDassert(par_iblock); HDassert(par_iblock->filt_ents[par_entry].size > 0); /* Check if the filter mask changed */ - if(par_iblock->filt_ents[par_entry].filter_mask != filter_mask) { + if (par_iblock->filt_ents[par_entry].filter_mask != filter_mask) { par_iblock->filt_ents[par_entry].filter_mask = filter_mask; - par_changed = TRUE; + par_changed = TRUE; } /* end if */ /* verify that the cache's last record of the compressed @@ -2290,27 +2262,30 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, HDassert(len == par_iblock->filt_ents[par_entry].size); /* Check if we need to re-size the block on disk */ - if(par_iblock->filt_ents[par_entry].size != write_size || at_tmp_addr) { + if (par_iblock->filt_ents[par_entry].size != write_size || at_tmp_addr) { /* Check if the direct block is NOT currently allocated * in temp. file space * * (temp. file space does not need to be freed) */ - if(!at_tmp_addr) + if (!at_tmp_addr) /* Release direct block's current disk space */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, (hsize_t)par_iblock->filt_ents[par_entry].size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, addr, + (hsize_t)par_iblock->filt_ents[par_entry].size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block") /* Allocate space for the compressed direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Update information about compressed direct block's * location & size */ HDassert(par_iblock->ents[par_entry].addr == addr); HDassert(par_iblock->filt_ents[par_entry].size == len); - par_iblock->ents[par_entry].addr = dblock_addr; + par_iblock->ents[par_entry].addr = dblock_addr; par_iblock->filt_ents[par_entry].size = write_size; /* Note that parent was modified */ @@ -2318,11 +2293,11 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, } /* end if */ /* Check if parent was modified */ - if(par_changed) - if(H5HF_iblock_dirty(par_iblock) < 0) + if (par_changed) + if (H5HF__iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end else */ - } /* end if */ + } /* end if */ else { /* I/O filters are not enabled -- thus all we need to do is check to * see if the direct block is in temporary (AKA imaginary) file @@ -2334,19 +2309,21 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, * Recall that temporary file space need not be freed, which * simplifies matters slightly. */ - write_buf = dblock->blk; + write_buf = dblock->blk; write_size = dblock->size; /* Check to see if we must re-allocate direct block from 'temp.' * to 'normal' file space */ - if(at_tmp_addr) { + if (at_tmp_addr) { /* Allocate 'normal' space for the direct block */ - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == + (dblock_addr = H5MF_alloc((H5F_t *)f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)write_size))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") /* Check for root direct block */ - if(NULL == dblock->parent) { + if (NULL == dblock->parent) { /* Sanity checks */ HDassert(H5F_addr_eq(hdr->man_dtable.table_addr, addr)); HDassert(!H5F_addr_eq(hdr->man_dtable.table_addr, dblock_addr)); @@ -2355,9 +2332,9 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, hdr->man_dtable.table_addr = dblock_addr; /* Mark that heap header was modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") - } /* end if */ + } /* end if */ else { /* the direct block's parent is an indirect block */ /* Sanity checks */ HDassert(par_iblock); @@ -2369,11 +2346,11 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, par_iblock->ents[par_entry].addr = dblock_addr; /* Mark that parent was modified */ - if(H5HF_iblock_dirty(par_iblock) < 0) + if (H5HF__iblock_dirty(par_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end else */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* At this point, write_buf points to a buffer containing the image * of the direct block that is ready to copy into the image buffer, @@ -2385,16 +2362,16 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, * Now, make note of the pointer and length of the above buffer for * use by the serialize function. */ - dblock->write_buf = (uint8_t *)write_buf; + dblock->write_buf = (uint8_t *)write_buf; dblock->write_size = write_size; /* finally, pass data back to the metadata cache as appropriate */ - if(!H5F_addr_eq(addr, dblock_addr)) { + if (!H5F_addr_eq(addr, dblock_addr)) { dblock_flags |= H5AC__SERIALIZE_MOVED_FLAG; *new_addr = dblock_addr; } /* end if */ - if((hdr->filter_len > 0) && (len != write_size)) { + if ((hdr->filter_len > 0) && (len != write_size)) { dblock_flags |= H5AC__SERIALIZE_RESIZED_FLAG; *new_len = write_size; } /* end if */ @@ -2407,13 +2384,12 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, done: /* discard the write buf if we have an error */ - if(write_buf && (write_buf != dblock->blk) && (dblock->write_buf == NULL)) - H5MM_xfree(write_buf); + if (write_buf && (write_buf != dblock->blk) && (dblock->write_buf == NULL)) + H5MM_xfree(write_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_pre_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_serialize * @@ -2437,10 +2413,10 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, */ static herr_t H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, - size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2463,17 +2439,16 @@ H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, /* Free *(dblock->write_buf) if it was allocated by the * pre-serialize function */ - if(dblock->write_buf != dblock->blk) + if (dblock->write_buf != dblock->blk) H5MM_xfree(dblock->write_buf); /* Reset the write_buf and write_size fields */ - dblock->write_buf = NULL; + dblock->write_buf = NULL; dblock->write_size = 0; FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_notify * @@ -2491,8 +2466,8 @@ H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, static herr_t H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2502,29 +2477,29 @@ H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) HDassert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); HDassert(dblock->hdr); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency with parent, if there is one */ - if(dblock->fd_parent) - if(H5AC_create_flush_dependency(dblock->fd_parent, dblock) < 0) + if (dblock->fd_parent) + if (H5AC_create_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(dblock->fd_parent) { + if (dblock->fd_parent) { /* Destroy flush dependency with parent */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; } /* end if */ @@ -2539,7 +2514,6 @@ H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_free_icr * @@ -2561,8 +2535,8 @@ H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5HF__cache_dblock_free_icr(void *_thing) { - H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Fractal heap direct block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2572,14 +2546,13 @@ H5HF__cache_dblock_free_icr(void *_thing) HDassert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); /* Destroy fractal heap direct block */ - if(H5HF_man_dblock_dest(dblock) < 0) + if (H5HF__man_dblock_dest(dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HF__cache_dblock_fsf_size * @@ -2598,7 +2571,7 @@ H5HF__cache_dblock_free_icr(void *_thing) static herr_t H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) { - const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Fractal heap direct block */ + const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Fractal heap direct block */ FUNC_ENTER_STATIC_NOERR @@ -2615,7 +2588,6 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__cache_dblock_fsf_size() */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_hdr_descendants_clean * @@ -2681,13 +2653,12 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, - hbool_t *fd_clean, hbool_t *clean) +H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_clean, hbool_t *clean) { - hbool_t fd_exists = FALSE; /* whether flush dependency exists. */ - haddr_t hdr_addr; /* Address of header */ - unsigned hdr_status = 0; /* Header cache entry status */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t fd_exists = FALSE; /* whether flush dependency exists. */ + haddr_t hdr_addr; /* Address of header */ + unsigned hdr_status = 0; /* Header cache entry status */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2701,7 +2672,7 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hdr_addr = hdr->cache_info.addr; HDassert(hdr_addr == hdr->heap_addr); - if(H5AC_get_entry_status(f, hdr_addr, &hdr_status) < 0) + if (H5AC_get_entry_status(f, hdr_addr, &hdr_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get hdr status") HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -2735,52 +2706,51 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * Since the former case is far and away the most common, we don't * worry too much about efficiency in the second case. */ - if(hdr->root_iblock || - ((hdr->man_dtable.curr_root_rows > 0) && - (HADDR_UNDEF != hdr->man_dtable.table_addr))) { + if (hdr->root_iblock || + ((hdr->man_dtable.curr_root_rows > 0) && (HADDR_UNDEF != hdr->man_dtable.table_addr))) { H5HF_indirect_t *root_iblock = hdr->root_iblock; - haddr_t root_iblock_addr; - unsigned root_iblock_status = 0; - hbool_t root_iblock_in_cache; + haddr_t root_iblock_addr; + unsigned root_iblock_status = 0; + hbool_t root_iblock_in_cache; /* make note of the on disk address of the root iblock */ - if(root_iblock == NULL) - /* hdr->man_dtable.table_addr must contain address of root + if (root_iblock == NULL) + /* hdr->man_dtable.table_addr must contain address of root * iblock. Check to see if it is in cache. If it is, * protect it and put its address in root_iblock. */ - root_iblock_addr = hdr->man_dtable.table_addr; + root_iblock_addr = hdr->man_dtable.table_addr; else - root_iblock_addr = root_iblock->addr; + root_iblock_addr = root_iblock->addr; - /* get the status of the root iblock */ - HDassert(root_iblock_addr != HADDR_UNDEF); - if(H5AC_get_entry_status(f, root_iblock_addr, &root_iblock_status) < 0) + /* get the status of the root iblock */ + HDassert(root_iblock_addr != HADDR_UNDEF); + if (H5AC_get_entry_status(f, root_iblock_addr, &root_iblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get root iblock status") - root_iblock_in_cache = ( (root_iblock_status & H5AC_ES__IN_CACHE) != 0); - HDassert(root_iblock_in_cache || (root_iblock == NULL)); + root_iblock_in_cache = ((root_iblock_status & H5AC_ES__IN_CACHE) != 0); + HDassert(root_iblock_in_cache || (root_iblock == NULL)); - if(!root_iblock_in_cache) { /* we are done */ - *clean = TRUE; + if (!root_iblock_in_cache) { /* we are done */ + *clean = TRUE; *fd_clean = TRUE; } /* end if */ - else if((root_iblock_status & H5AC_ES__IS_DIRTY) && - (((root_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + else if ((root_iblock_status & H5AC_ES__IS_DIRTY) && + (((root_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; /* verify that a flush dependency exists between the header and * the root inode. */ - if(H5AC_flush_dependency_exists(f, hdr->heap_addr, root_iblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, hdr->heap_addr, root_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") HDassert(fd_exists); *fd_clean = FALSE; - } /* end else-if */ + } /* end else-if */ else { /* must examine children */ - hbool_t unprotect_root_iblock = FALSE; + hbool_t unprotect_root_iblock = FALSE; /* At this point, the root iblock may be pinned, protected, * both, or neither, and we may or may not have a pointer @@ -2791,8 +2761,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * protected or both, and that we have a pointer to it. * Do this as follows: */ - if(root_iblock == NULL) { /* we don't have ptr to root iblock */ - if(0 == (root_iblock_status & H5AC_ES__IS_PROTECTED)) { + if (root_iblock == NULL) { /* we don't have ptr to root iblock */ + if (0 == (root_iblock_status & H5AC_ES__IS_PROTECTED)) { /* just protect the root iblock -- this will give us * the pointer we need to proceed, and ensure that * it is locked into the metadata cache for the @@ -2812,7 +2782,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, */ H5_BEGIN_TAG(hdr->heap_addr) - if(NULL == (root_iblock = (H5HF_indirect_t *)H5AC_protect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == (root_iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -2855,20 +2826,20 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * that we will use this approach until it causes problems, * or we think of a better way. */ - if(H5AC_get_entry_ptr_from_addr(f, root_iblock_addr, (void **)(&root_iblock)) < 0) + if (H5AC_get_entry_ptr_from_addr(f, root_iblock_addr, (void **)(&root_iblock)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "H5AC_get_entry_ptr_from_addr() failed.") HDassert(root_iblock); - } /* end else */ - } /* end if */ - else { /* root_iblock != NULL */ - /* we have the pointer to the root iblock. Protect it - * if it is neither pinned nor protected -- otherwise we - * are ready to go. - */ - H5HF_indirect_t * iblock = NULL; - - if(((root_iblock_status & H5AC_ES__IS_PINNED) == 0) && - ((root_iblock_status & H5AC_ES__IS_PROTECTED) == 0)) { + } /* end else */ + } /* end if */ + else { /* root_iblock != NULL */ + /* we have the pointer to the root iblock. Protect it + * if it is neither pinned nor protected -- otherwise we + * are ready to go. + */ + H5HF_indirect_t *iblock = NULL; + + if (((root_iblock_status & H5AC_ES__IS_PINNED) == 0) && + ((root_iblock_status & H5AC_ES__IS_PROTECTED) == 0)) { /* the root iblock is neither pinned nor protected -- hence * we must protect it before we proceed * @@ -2886,7 +2857,8 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, */ H5_BEGIN_TAG(hdr->heap_addr) - if(NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == (iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -2894,43 +2866,44 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, unprotect_root_iblock = TRUE; HDassert(iblock == root_iblock); } /* end if */ - } /* end else */ + } /* end else */ /* at this point, one way or another, the root iblock is locked * in memory for the duration of the call. Do some sanity checks, * and then call H5HF__cache_verify_iblock_descendants_clean(). */ - HDassert(root_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(root_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); + HDassert(root_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(root_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); - if(H5HF__cache_verify_iblock_descendants_clean(f, hdr->heap_addr, root_iblock, &root_iblock_status, fd_clean, clean) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify root iblock & descendants clean.") + if (H5HF__cache_verify_iblock_descendants_clean(f, hdr->heap_addr, root_iblock, + &root_iblock_status, fd_clean, clean) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify root iblock & descendants clean.") - /* Unprotect the root indirect block if required */ - if(unprotect_root_iblock) { + /* Unprotect the root indirect block if required */ + if (unprotect_root_iblock) { HDassert(root_iblock); - if(H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, root_iblock, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, root_iblock_addr, root_iblock, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "H5AC_unprotect() failed.") } /* end if */ - } /* end else */ - } /* end if */ - else if((hdr->man_dtable.curr_root_rows == 0) && - (HADDR_UNDEF != hdr->man_dtable.table_addr)) { - haddr_t root_dblock_addr; - unsigned root_dblock_status = 0; - hbool_t in_cache; - hbool_t type_ok; - - /* this is scenario 2 -- we have a root dblock */ - root_dblock_addr = hdr->man_dtable.table_addr; - if(H5AC_get_entry_status(f, root_dblock_addr, &root_dblock_status) < 0) + } /* end else */ + } /* end if */ + else if ((hdr->man_dtable.curr_root_rows == 0) && (HADDR_UNDEF != hdr->man_dtable.table_addr)) { + haddr_t root_dblock_addr; + unsigned root_dblock_status = 0; + hbool_t in_cache; + hbool_t type_ok; + + /* this is scenario 2 -- we have a root dblock */ + root_dblock_addr = hdr->man_dtable.table_addr; + if (H5AC_get_entry_status(f, root_dblock_addr, &root_dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get root dblock status") - if(root_dblock_status & H5AC_ES__IN_CACHE) { - if(H5AC_verify_entry_type(f, root_dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) + if (root_dblock_status & H5AC_ES__IN_CACHE) { + if (H5AC_verify_entry_type(f, root_dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check dblock type") HDassert(in_cache); - if(!type_ok) + if (!type_ok) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock addr doesn't refer to a dblock?!?") /* If a root dblock is in cache, it must have a flush @@ -2942,32 +2915,31 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, * the root iblock is a child in a flush dependency * relationship with the header. */ - if(H5AC_flush_dependency_exists(f, hdr->heap_addr, root_dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, hdr->heap_addr, root_dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) + if (!fd_exists) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock is not a flush dep parent of header.") - if(0 != (root_dblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT)) + if (0 != (root_dblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT)) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "root dblock in cache and is a flush dep parent.") *clean = !((root_dblock_status & H5AC_ES__IS_DIRTY) && - (((root_dblock_status & - H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (((root_dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || (!H5AC_get_serialization_in_progress(f)))); *fd_clean = *clean; - } /* end if */ - else { /* root dblock not in cache */ + } /* end if */ + else { /* root dblock not in cache */ *fd_clean = TRUE; - *clean = TRUE; + *clean = TRUE; } /* end else */ - } /* end else-if */ + } /* end else-if */ else { /* this is scenario 3 -- the fractal heap is empty, and we * have nothing to do. */ *fd_clean = TRUE; - *clean = TRUE; + *clean = TRUE; } /* end else */ done: @@ -2975,7 +2947,6 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, } /* H5HF__cache_verify_hdr_descendants_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_iblock_descendants_clean * @@ -3046,13 +3017,12 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, unsigned *iblock_status, hbool_t * fd_clean, - hbool_t *clean) +H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + unsigned *iblock_status, hbool_t *fd_clean, hbool_t *clean) { - hbool_t has_dblocks = FALSE; - hbool_t has_iblocks = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t has_dblocks = FALSE; + hbool_t has_iblocks = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3067,26 +3037,27 @@ H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(*fd_clean); HDassert(clean); /* note that *clean need not be TRUE */ - if((*fd_clean) && H5HF__cache_verify_iblocks_dblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, &has_dblocks) < 0) + if ((*fd_clean) && H5HF__cache_verify_iblocks_dblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, + &has_dblocks) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify dblocks clean.") - if((*fd_clean) && H5HF__cache_verify_descendant_iblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, &has_iblocks) < 0) + if ((*fd_clean) && H5HF__cache_verify_descendant_iblocks_clean(f, fd_parent_addr, iblock, fd_clean, clean, + &has_iblocks) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify iblocks clean.") /* verify that flush dependency setup is plausible */ - if(0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_CHILD)) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep child.") - if(((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT))) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not a flush dep parent.") - if(((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_PINNED))) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not pinned.") + if (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_CHILD)) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep child.") + if (((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_FLUSH_DEP_PARENT))) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not a flush dep parent.") + if (((has_dblocks || has_iblocks)) && (0 == (*iblock_status & H5AC_ES__IS_PINNED))) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock has children and is not pinned.") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__cache_verify_iblock_descendants_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_iblocks_dblocks_clean * @@ -3163,15 +3134,14 @@ H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, hbool_t *fd_clean, hbool_t *clean, - hbool_t *has_dblocks) +H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + hbool_t *fd_clean, hbool_t *clean, hbool_t *has_dblocks) { - unsigned num_direct_rows; - unsigned max_dblock_index; - unsigned i; - haddr_t iblock_addr; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_direct_rows; + unsigned max_dblock_index; + unsigned i; + haddr_t iblock_addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3186,47 +3156,47 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(clean); /* note that *clean need not be true */ HDassert(has_dblocks); - i = 0; + i = 0; num_direct_rows = MIN(iblock->nrows, iblock->hdr->man_dtable.max_direct_rows); HDassert(num_direct_rows <= iblock->nrows); max_dblock_index = (num_direct_rows * iblock->hdr->man_dtable.cparam.width) - 1; - iblock_addr = iblock->addr; + iblock_addr = iblock->addr; HDassert(H5F_addr_defined(iblock_addr)); - while((*fd_clean) && (i <= max_dblock_index)) { - haddr_t dblock_addr; + while ((*fd_clean) && (i <= max_dblock_index)) { + haddr_t dblock_addr; dblock_addr = iblock->ents[i].addr; - if(H5F_addr_defined(dblock_addr)) { - hbool_t in_cache; - hbool_t type_ok; + if (H5F_addr_defined(dblock_addr)) { + hbool_t in_cache; + hbool_t type_ok; - if(H5AC_verify_entry_type(f, dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) + if (H5AC_verify_entry_type(f, dblock_addr, &H5AC_FHEAP_DBLOCK[0], &in_cache, &type_ok) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check dblock type") - if(in_cache) { /* dblock is in cache */ - hbool_t fd_exists; - unsigned dblock_status = 0; + if (in_cache) { /* dblock is in cache */ + hbool_t fd_exists; + unsigned dblock_status = 0; - if(!type_ok) + if (!type_ok) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "dblock addr doesn't refer to a dblock?!?") - if(H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) + if (H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get dblock status") HDassert(dblock_status & H5AC_ES__IN_CACHE); *has_dblocks = TRUE; - if((dblock_status & H5AC_ES__IS_DIRTY) && - (((dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + if ((dblock_status & H5AC_ES__IS_DIRTY) && + (((dblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; - if(H5AC_flush_dependency_exists(f, fd_parent_addr, dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, fd_parent_addr, dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(fd_exists) + if (fd_exists) *fd_clean = FALSE; } /* end if */ @@ -3234,13 +3204,14 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, * dependency relationship with this iblock. Test this * here. */ - if(H5AC_flush_dependency_exists(f, iblock_addr, dblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, iblock_addr, dblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "dblock in cache and not a flush dep child of iblock.") + if (!fd_exists) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, + "dblock in cache and not a flush dep child of iblock.") } /* end if */ - } /* end if */ + } /* end if */ i++; } /* end while */ @@ -3250,7 +3221,6 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, } /* H5HF__cache_verify_iblocks_dblocks_clean() */ #endif /* NDEBUG */ - /*------------------------------------------------------------------------ * Function: H5HF__cache_verify_descendant_iblocks_clean * @@ -3328,16 +3298,15 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, */ #ifndef NDEBUG static herr_t -H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, - H5HF_indirect_t *iblock, hbool_t *fd_clean, hbool_t *clean, - hbool_t *has_iblocks) +H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_indirect_t *iblock, + hbool_t *fd_clean, hbool_t *clean, hbool_t *has_iblocks) { - unsigned first_iblock_index; - unsigned last_iblock_index; - unsigned num_direct_rows; - unsigned i; - haddr_t iblock_addr; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned first_iblock_index; + unsigned last_iblock_index; + unsigned num_direct_rows; + unsigned i; + haddr_t iblock_addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3354,35 +3323,35 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, num_direct_rows = MIN(iblock->nrows, iblock->hdr->man_dtable.max_direct_rows); HDassert(num_direct_rows <= iblock->nrows); - iblock_addr = iblock->addr; + iblock_addr = iblock->addr; first_iblock_index = num_direct_rows * iblock->hdr->man_dtable.cparam.width; - last_iblock_index = (iblock->nrows * iblock->hdr->man_dtable.cparam.width) - 1; + last_iblock_index = (iblock->nrows * iblock->hdr->man_dtable.cparam.width) - 1; i = first_iblock_index; - while((*fd_clean) && (i <= last_iblock_index)) { - haddr_t child_iblock_addr = iblock->ents[i].addr; + while ((*fd_clean) && (i <= last_iblock_index)) { + haddr_t child_iblock_addr = iblock->ents[i].addr; - if(H5F_addr_defined(child_iblock_addr)) { - unsigned child_iblock_status = 0; + if (H5F_addr_defined(child_iblock_addr)) { + unsigned child_iblock_status = 0; - if(H5AC_get_entry_status(f, child_iblock_addr, &child_iblock_status) < 0) + if (H5AC_get_entry_status(f, child_iblock_addr, &child_iblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get iblock status") - if(child_iblock_status & H5AC_ES__IN_CACHE) { - hbool_t fd_exists; + if (child_iblock_status & H5AC_ES__IN_CACHE) { + hbool_t fd_exists; - *has_iblocks = TRUE; + *has_iblocks = TRUE; - if((child_iblock_status & H5AC_ES__IS_DIRTY) && - (((child_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || - (!H5AC_get_serialization_in_progress(f)))) { + if ((child_iblock_status & H5AC_ES__IS_DIRTY) && + (((child_iblock_status & H5AC_ES__IMAGE_IS_UP_TO_DATE) == 0) || + (!H5AC_get_serialization_in_progress(f)))) { *clean = FALSE; - if(H5AC_flush_dependency_exists(f, fd_parent_addr, child_iblock_addr, &fd_exists) < 0) + if (H5AC_flush_dependency_exists(f, fd_parent_addr, child_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(fd_exists) + if (fd_exists) *fd_clean = FALSE; } /* end if */ @@ -3438,13 +3407,13 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, * expect that we will use this approach until it causes * problems, or we think of a better way. */ - if(*fd_clean) { - H5HF_indirect_t *child_iblock = NULL; - hbool_t unprotect_child_iblock = FALSE; + if (*fd_clean) { + H5HF_indirect_t *child_iblock = NULL; + hbool_t unprotect_child_iblock = FALSE; - if(0 == (child_iblock_status & H5AC_ES__IS_PINNED)) { + if (0 == (child_iblock_status & H5AC_ES__IS_PINNED)) { /* child iblock is not pinned */ - if(0 == (child_iblock_status & H5AC_ES__IS_PROTECTED)) { + if (0 == (child_iblock_status & H5AC_ES__IS_PROTECTED)) { /* child iblock is unprotected, and unpinned */ /* protect it. Note that the udata is only */ /* used in the load callback. While the */ @@ -3465,7 +3434,9 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5_BEGIN_TAG(iblock->hdr->heap_addr) - if(NULL == (child_iblock = (H5HF_indirect_t *) H5AC_protect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) + if (NULL == + (child_iblock = (H5HF_indirect_t *)H5AC_protect( + f, H5AC_FHEAP_IBLOCK, child_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") H5_END_TAG @@ -3477,11 +3448,13 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, /* H5AC_get_entry_ptr_from_addr() to get a */ /* pointer to the entry. This is very slimy -- */ /* come up with a better solution. */ - if(H5AC_get_entry_ptr_from_addr(f, child_iblock_addr, (void **)(&child_iblock)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "H5AC_get_entry_ptr_from_addr() failed.") + if (H5AC_get_entry_ptr_from_addr(f, child_iblock_addr, (void **)(&child_iblock)) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "H5AC_get_entry_ptr_from_addr() failed.") HDassert(child_iblock); } /* end else */ - } /* end if */ + } /* end if */ else { /* child iblock is pinned -- look it up in the */ /* parent iblocks child_iblocks array. */ @@ -3499,29 +3472,32 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, HDassert(child_iblock->addr == child_iblock_addr); /* now make the recursive call */ - if(H5HF__cache_verify_iblock_descendants_clean(f, fd_parent_addr, child_iblock, &child_iblock_status, fd_clean, clean) < 0) + if (H5HF__cache_verify_iblock_descendants_clean( + f, fd_parent_addr, child_iblock, &child_iblock_status, fd_clean, clean) < 0) HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "can't verify child iblock clean.") /* if iblock_addr != fd_parent_addr, verify that a flush * dependency relationship exists between iblock and * the child iblock. */ - if(fd_parent_addr != iblock_addr) { - if(H5AC_flush_dependency_exists(f, iblock_addr, child_iblock_addr, &fd_exists) < 0) + if (fd_parent_addr != iblock_addr) { + if (H5AC_flush_dependency_exists(f, iblock_addr, child_iblock_addr, &fd_exists) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't check flush dependency") - if(!fd_exists) - HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, "iblock is not a flush dep parent of child_iblock.") + if (!fd_exists) + HGOTO_ERROR(H5E_HEAP, H5E_SYSTEM, FAIL, + "iblock is not a flush dep parent of child_iblock.") } /* end if */ /* if we protected the child iblock, unprotect it now */ - if(unprotect_child_iblock) { - if(H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, child_iblock, H5AC__NO_FLAGS_SET) < 0) + if (unprotect_child_iblock) { + if (H5AC_unprotect(f, H5AC_FHEAP_IBLOCK, child_iblock_addr, child_iblock, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "H5AC_unprotect() failed.") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ i++; } /* end while */ @@ -3530,4 +3506,3 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__cache_verify_descendant_iblocks_clean() */ #endif /* NDEBUG */ - diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index e841d781140..a2440357d0e 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,77 +26,69 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ -#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ +#define H5HF_DEBUGGING /* Need access to fractal heap debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for direct block debugging iterator callback */ typedef struct { - FILE *stream; /* Stream for output */ - int indent; /* Indention amount */ - int fwidth; /* Field width mount */ - haddr_t dblock_addr; /* Direct block's address */ - hsize_t dblock_size; /* Direct block's size */ - uint8_t *marker; /* 'Marker' array for free space */ - size_t sect_count; /* Number of free space sections in block */ - size_t amount_free; /* Amount of free space in block */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width mount */ + haddr_t dblock_addr; /* Direct block's address */ + hsize_t dblock_size; /* Direct block's size */ + uint8_t *marker; /* 'Marker' array for free space */ + size_t sect_count; /* Number of free space sections in block */ + size_t amount_free; /* Amount of free space in block */ } H5HF_debug_iter_ud1_t; /* 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 */ - int fwidth; /* Field width mount */ + H5FS_t *fspace; /* Free space manager */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width mount */ } H5HF_debug_iter_ud2_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF__dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, - int indent, int fwidth); - +static herr_t H5HF__dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5HF_id_print * @@ -112,12 +104,12 @@ static herr_t H5HF__dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, herr_t H5HF_id_print(H5HF_t *fh, const void *_id, FILE *stream, int indent, int fwidth) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - hsize_t obj_off; /* Offset of object */ - size_t obj_len; /* Length of object */ - char id_type; /* Character for the type of heap ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + uint8_t id_flags; /* Heap ID flag bits */ + hsize_t obj_off; /* Offset of object */ + size_t obj_len; /* Length of object */ + char id_type; /* Character for the type of heap ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -134,42 +126,40 @@ H5HF_id_print(H5HF_t *fh, const void *_id, FILE *stream, int indent, int fwidth) id_flags = *id; /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) + if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { + if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { id_type = 'M'; } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { id_type = 'H'; } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { + else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { id_type = 'T'; } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ /* Get the length of the heap object */ - if(H5HF_get_obj_len(fh, id, &obj_len) < 0) + if (H5HF_get_obj_len(fh, id, &obj_len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") /* Get the offset of the heap object */ - if(H5HF_get_obj_off(fh, id, &obj_off) < 0) + if (H5HF_get_obj_off(fh, id, &obj_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") /* Display the heap ID */ - HDfprintf(stream, "%*s%-*s (%c, %Hu, %Zu)\n", indent, "", fwidth, - "Heap ID info: (type, offset, length)", - id_type, obj_off, obj_len); + HDfprintf(stream, "%*s%-*s (%c, %" PRIuHSIZE " , %zu)\n", indent, "", fwidth, + "Heap ID info: (type, offset, length)", id_type, obj_off, obj_len); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_id_print() */ - /*------------------------------------------------------------------------- * Function: H5HF__dtable_debug * @@ -199,48 +189,35 @@ H5HF__dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fw * Print the values. */ /* Creation parameter values */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Doubling table width:", - dtable->cparam.width); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Starting block size:", - dtable->cparam.start_block_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Max. direct block size:", - dtable->cparam.max_direct_size); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Doubling table width:", dtable->cparam.width); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "Starting block size:", dtable->cparam.start_block_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, + "Max. direct block size:", dtable->cparam.max_direct_size); HDfprintf(stream, "%*s%-*s %u (bits)\n", indent, "", fwidth, - "Max. index size:", - dtable->cparam.max_index); + "Max. index size:", dtable->cparam.max_index); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Starting # of rows in root indirect block:", - dtable->cparam.start_root_rows); + "Starting # of rows in root indirect block:", dtable->cparam.start_root_rows); /* Run-time varying parameter values */ - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Table's root address:", - dtable->table_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Table's root address:", dtable->table_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Current # of rows in root indirect block:", - dtable->curr_root_rows); + "Current # of rows in root indirect block:", dtable->curr_root_rows); /* Computed values */ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of rows in root indirect block:", - dtable->max_root_rows); + "Max. # of rows in root indirect block:", dtable->max_root_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of direct rows in any indirect block:", - dtable->max_direct_rows); + "Max. # of direct rows in any indirect block:", dtable->max_direct_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of bits for IDs in first row:", - dtable->first_row_bits); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "# of IDs in first row:", - dtable->num_id_first_row); + "# of bits for IDs in first row:", dtable->first_row_bits); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "# of IDs in first row:", dtable->num_id_first_row); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_print * @@ -273,93 +250,71 @@ H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int i * Print the values. */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Heap is:", - hdr->man_dtable.curr_root_rows > 0 ? "Indirect" : "Direct"); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Objects stored in 'debugging' format:", - hdr->debug_objs); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "'Write once' flag:", - hdr->write_once); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "'Huge' object IDs have wrapped:", - hdr->huge_ids_wrapped); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Free space in managed blocks:", - hdr->total_man_free); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Managed space data block size:", - hdr->man_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Total managed space allocated:", - hdr->man_alloc_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of managed space iterator:", - hdr->man_iter_off); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of managed objects in heap:", - hdr->man_nobjs); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of free space manager for managed blocks:", - hdr->fs_addr); + "Heap is:", hdr->man_dtable.curr_root_rows > 0 ? "Indirect" : "Direct"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Objects stored in 'debugging' format:", hdr->debug_objs ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "'Write once' flag:", hdr->write_once ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "'Huge' object IDs have wrapped:", hdr->huge_ids_wrapped ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Free space in managed blocks:", hdr->total_man_free); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Managed space data block size:", hdr->man_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Total managed space allocated:", hdr->man_alloc_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Offset of managed space iterator:", hdr->man_iter_off); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Number of managed objects in heap:", hdr->man_nobjs); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Address of free space manager for managed blocks:", hdr->fs_addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Max. size of managed object:", - (unsigned long)hdr->max_man_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "'Huge' object space used:", - hdr->huge_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of 'huge' objects in heap:", - hdr->huge_nobjs); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "ID of next 'huge' object:", - hdr->huge_next_id); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of v2 B-tree for 'huge' objects:", - hdr->huge_bt2_addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "'Tiny' object space used:", - hdr->tiny_size); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of 'tiny' objects in heap:", - hdr->tiny_nobjs); + "Max. size of managed object:", (unsigned long)hdr->max_man_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "'Huge' object space used:", hdr->huge_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Number of 'huge' objects in heap:", hdr->huge_nobjs); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "ID of next 'huge' object:", hdr->huge_next_id); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Address of v2 B-tree for 'huge' objects:", hdr->huge_bt2_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "'Tiny' object space used:", hdr->tiny_size); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Number of 'tiny' objects in heap:", hdr->tiny_nobjs); HDfprintf(stream, "%*sManaged Objects Doubling-Table Info...\n", indent, ""); H5HF__dtable_debug(&hdr->man_dtable, stream, indent + 3, MAX(0, fwidth - 3)); /* Print information about I/O filters */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { HDfprintf(stream, "%*sI/O filter Info...\n", indent, ""); - if(hdr->man_dtable.curr_root_rows == 0) { - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Compressed size of root direct block:", - hdr->pline_root_direct_size); + if (hdr->man_dtable.curr_root_rows == 0) { + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(0, fwidth - 3), + "Compressed size of root direct block:", hdr->pline_root_direct_size); HDfprintf(stream, "%*s%-*s %x\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter mask for root direct block:", - hdr->pline_root_direct_filter_mask); + "Filter mask for root direct block:", hdr->pline_root_direct_filter_mask); } /* end if */ H5O_debug_id(H5O_PLINE_ID, hdr->f, &(hdr->pline), stream, indent + 3, MAX(0, fwidth - 3)); } /* end if */ /* Print internal (runtime) information, if requested */ - if(dump_internal) { + if (dump_internal) { HDfprintf(stream, "%*sFractal Heap Header Internal Information:\n", indent, ""); /* Dump root iblock, if there is one */ HDfprintf(stream, "%*s%-*s %x\n", indent + 3, "", MAX(0, fwidth - 3), - "Root indirect block flags:", - hdr->root_iblock_flags); + "Root indirect block flags:", hdr->root_iblock_flags); HDfprintf(stream, "%*s%-*s %p\n", indent + 3, "", MAX(0, fwidth - 3), - "Root indirect block pointer:", - hdr->root_iblock); - if(hdr->root_iblock) + "Root indirect block pointer:", (void *)hdr->root_iblock); + if (hdr->root_iblock) H5HF_iblock_print(hdr->root_iblock, dump_internal, stream, indent + 3, fwidth); } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5HF_hdr_print() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_debug * @@ -375,8 +330,8 @@ H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int i herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -390,20 +345,19 @@ H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Print the information about the heap's header */ H5HF_hdr_print(hdr, FALSE, stream, indent, fwidth); done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_dblock_debug_cb * @@ -419,10 +373,10 @@ 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_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 */ + 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 */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -434,27 +388,28 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) /* Set up some local variables, for convenience */ sect_start = sect->sect_info.addr; - sect_end = (sect->sect_info.addr + sect->sect_info.size) - 1; + sect_end = (sect->sect_info.addr + sect->sect_info.size) - 1; HDassert(sect_end >= sect_start); dblock_start = udata->dblock_addr; - dblock_end = (udata->dblock_addr + udata->dblock_size) - 1; + dblock_end = (udata->dblock_addr + udata->dblock_size) - 1; HDassert(dblock_end >= dblock_start); /* Check for overlap between free space section & direct block */ - if((sect_start <= dblock_end && sect_end >=dblock_start) || /* section within or overlaps w/beginning of direct block*/ - (sect_start <= dblock_end && sect_end >=dblock_end)) { /* section overlaps w/end of direct block */ - char temp_str[32]; /* Temporary string for formatting */ - size_t start, end; /* Start & end of the overlapping area */ - size_t len; /* Length of the overlapping area */ - size_t overlap; /* Track any overlaps */ - size_t u; /* Local index variable */ + if ((sect_start <= dblock_end && + sect_end >= dblock_start) || /* section within or overlaps w/beginning of direct block*/ + (sect_start <= dblock_end && sect_end >= dblock_end)) { /* section overlaps w/end of direct block */ + char temp_str[32]; /* Temporary string for formatting */ + size_t start, end; /* Start & end of the overlapping area */ + size_t len; /* Length of the overlapping area */ + size_t overlap; /* Track any overlaps */ + size_t u; /* Local index variable */ /* Calculate the starting & ending */ - if(sect_start < dblock_start) + if (sect_start < dblock_start) start = 0; else H5_CHECKED_ASSIGN(start, size_t, (sect_start - dblock_start), hsize_t) - if(sect_end > dblock_end) + if (sect_end > dblock_end) H5_CHECKED_ASSIGN(end, size_t, udata->dblock_size, hsize_t) else H5_CHECKED_ASSIGN(end, size_t, ((sect_end - dblock_start) + 1), hsize_t) @@ -463,15 +418,14 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) len = end - start; HDsnprintf(temp_str, sizeof(temp_str), "Section #%u:", (unsigned)udata->sect_count); - HDfprintf(udata->stream, "%*s%-*s %8Zu, %8Zu\n", udata->indent + 3, "", MAX(0, udata->fwidth - 9), - temp_str, - start, len); + HDfprintf(udata->stream, "%*s%-*s %8zu, %8zu\n", udata->indent + 3, "", MAX(0, udata->fwidth - 9), + temp_str, start, len); udata->sect_count++; /* Mark this node's free space & check for overlaps w/other sections */ overlap = 0; - for(u = start; u < end; u++) { - if(udata->marker[u]) + for (u = start; u < end; u++) { + if (udata->marker[u]) overlap++; udata->marker[u] = 1; } /* end for */ @@ -486,7 +440,6 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_dblock_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF_dblock_debug * @@ -500,15 +453,15 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) *------------------------------------------------------------------------- */ 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -524,13 +477,13 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(block_size > 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* * Load the heap direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, addr, block_size, NULL, 0, H5AC__READ_ONLY_FLAG))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, addr, block_size, NULL, 0, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap direct block") /* Print opening message */ @@ -539,63 +492,59 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of fractal heap that owns this block:", - hdr->heap_addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of direct block in heap:", - dblock->block_off); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Address of fractal heap that owns this block:", hdr->heap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Offset of direct block in heap:", dblock->block_off); blk_prefix_size = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of block header:", - blk_prefix_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Size of block header:", blk_prefix_size); /* Allocate space for the free space markers */ - if(NULL == (marker = (uint8_t *)H5MM_calloc(dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if (NULL == (marker = (uint8_t *)H5MM_calloc(dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the free space information for the heap */ - if(H5HF__space_start(hdr, FALSE) < 0) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* If there is a free space manager for the heap, check for sections that overlap this block */ - if(hdr->fspace) { - H5HF_debug_iter_ud1_t udata; /* User data for callbacks */ + if (hdr->fspace) { + H5HF_debug_iter_ud1_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ - udata.stream = stream; - udata.indent = indent; - udata.fwidth = fwidth; + udata.stream = stream; + udata.indent = indent; + udata.fwidth = fwidth; udata.dblock_addr = dblock->block_off; udata.dblock_size = block_size; - udata.marker = marker; - udata.sect_count = 0; + udata.marker = marker; + udata.sect_count = 0; udata.amount_free = 0; /* Print header */ HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); /* Iterate over the free space sections, to detect overlaps with this block */ - if(H5FS_sect_iterate(f, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, hdr->fspace, H5HF_dblock_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5HF__space_close(hdr) < 0) + if (H5HF__space_close(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") /* Keep the amount of space free */ amount_free = udata.amount_free; /* Check for no free space */ - if(amount_free == 0) + if (amount_free == 0) HDfprintf(stream, "%*s\n", indent + 3, ""); } /* end if */ else amount_free = 0; - HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, - "Percent of available space for data used:", - ((double)100.0f * (double)((dblock->size - blk_prefix_size) - amount_free) / (double)(dblock->size - blk_prefix_size))); + HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of available space for data used:", + (100.0 * (double)((dblock->size - blk_prefix_size) - amount_free) / + (double)(dblock->size - blk_prefix_size))); /* * Print the data in a VMS-style octal dump. @@ -603,16 +552,15 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, H5_buffer_dump(stream, indent, dblock->blk, marker, (size_t)0, dblock->size); done: - if(dblock && H5AC_unprotect(f, H5AC_FHEAP_DBLOCK, addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5AC_unprotect(f, H5AC_FHEAP_DBLOCK, addr, dblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") H5MM_xfree(marker); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_dblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_print * @@ -626,12 +574,11 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, *------------------------------------------------------------------------- */ void -H5HF_iblock_print(const H5HF_indirect_t *iblock, - hbool_t dump_internal, FILE *stream, int indent, int fwidth) +H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, FILE *stream, int indent, int fwidth) { - const H5HF_hdr_t *hdr; /* Pointer to heap's header */ - char temp_str[64]; /* Temporary string, for formatting */ - size_t u, v; /* Local index variable */ + const H5HF_hdr_t *hdr; /* Pointer to heap's header */ + char temp_str[64]; /* Temporary string, for formatting */ + size_t u, v; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -653,97 +600,80 @@ H5HF_iblock_print(const H5HF_indirect_t *iblock, /* * Print the values. */ - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of fractal heap that owns this block:", - hdr->heap_addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Offset of indirect block in heap:", - iblock->block_off); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of indirect block:", - iblock->size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Current # of rows:", - iblock->nrows); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Address of fractal heap that owns this block:", hdr->heap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " \n", indent, "", fwidth, + "Offset of indirect block in heap:", iblock->block_off); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Size of indirect block:", iblock->size); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Current # of rows:", iblock->nrows); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. # of rows:", iblock->max_rows); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. # of rows:", - iblock->max_rows); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max direct block rows:", - hdr->man_dtable.max_direct_rows); + "Max direct block rows:", hdr->man_dtable.max_direct_rows); /* Print the entry tables */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) HDfprintf(stream, "%*sDirect Block Entries: (address/compressed size/filter mask)\n", indent, ""); else HDfprintf(stream, "%*sDirect Block Entries: (address)\n", indent, ""); - for(u = 0; u < hdr->man_dtable.max_direct_rows && u < iblock->nrows; u++) { - HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (block size: %lu)", (unsigned)u, (unsigned long)hdr->man_dtable.row_block_size[u]); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); - for(v = 0; v < hdr->man_dtable.cparam.width; v++) { + for (u = 0; u < hdr->man_dtable.max_direct_rows && u < iblock->nrows; u++) { + HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (block size: %lu)", (unsigned)u, + (unsigned long)hdr->man_dtable.row_block_size[u]); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); + for (v = 0; v < hdr->man_dtable.cparam.width; v++) { size_t off = (u * hdr->man_dtable.cparam.width) + v; HDsnprintf(temp_str, sizeof(temp_str), "Col #%u:", (unsigned)v); - if(hdr->filter_len > 0) - HDfprintf(stream, "%*s%-*s %9a/%6Zu/%x\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr, - iblock->filt_ents[off].size, - iblock->filt_ents[off].filter_mask); + if (hdr->filter_len > 0) + HDfprintf(stream, "%*s%-*s %9" PRIuHADDR "/%6zu/%x\n", indent + 6, "", MAX(0, fwidth - 6), + temp_str, iblock->ents[off].addr, iblock->filt_ents[off].size, + iblock->filt_ents[off].filter_mask); else - HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr); + HDfprintf(stream, "%*s%-*s %9" PRIuHADDR "\n", indent + 6, "", MAX(0, fwidth - 6), temp_str, + iblock->ents[off].addr); } /* end for */ - } /* end for */ + } /* end for */ HDfprintf(stream, "%*sIndirect Block Entries:\n", indent, ""); - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned first_row_bits; /* Number of bits used bit addresses in first row */ - unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned first_row_bits; /* Number of bits used bit addresses in first row */ + unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ first_row_bits = H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + - H5VM_log2_of2(hdr->man_dtable.cparam.width); - for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) { + H5VM_log2_of2(hdr->man_dtable.cparam.width); + for (u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) { num_indirect_rows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1; - HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (# of rows: %u)", (unsigned)u, num_indirect_rows); - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - temp_str); - for(v = 0; v < hdr->man_dtable.cparam.width; v++) { + HDsnprintf(temp_str, sizeof(temp_str), "Row #%u: (# of rows: %u)", (unsigned)u, + num_indirect_rows); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); + for (v = 0; v < hdr->man_dtable.cparam.width; v++) { size_t off = (u * hdr->man_dtable.cparam.width) + v; HDsnprintf(temp_str, sizeof(temp_str), "Col #%u:", (unsigned)v); - HDfprintf(stream, "%*s%-*s %9a\n", indent + 6, "", MAX(0, fwidth - 6), - temp_str, - iblock->ents[off].addr); + HDfprintf(stream, "%*s%-*s %9" PRIuHADDR "\n", indent + 6, "", MAX(0, fwidth - 6), temp_str, + iblock->ents[off].addr); } /* end for */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - ""); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), ""); /* Print internal (runtime) information, if requested */ - if(dump_internal) { + if (dump_internal) { HDfprintf(stream, "%*sFractal Indirect Block Internal Information:\n", indent, ""); /* Print general information */ - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Reference count:", - iblock->rc); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(0, fwidth - 3), + "Reference count:", iblock->rc); /* Print parent's information */ HDfprintf(stream, "%*s%-*s %p\n", indent + 3, "", MAX(0, fwidth - 3), - "Parent indirect block address:", - iblock->parent); - if(iblock->parent) + "Parent indirect block address:", (void *)iblock->parent); + if (iblock->parent) H5HF_iblock_print(iblock->parent, TRUE, stream, indent + 6, fwidth); } /* end if */ FUNC_LEAVE_NOAPI_VOID } /* end H5HF_iblock_print() */ - /*------------------------------------------------------------------------- * Function: H5HF_iblock_debug * @@ -757,13 +687,13 @@ H5HF_iblock_print(const H5HF_indirect_t *iblock, *------------------------------------------------------------------------- */ herr_t -H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - haddr_t hdr_addr, unsigned nrows) +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_indirect_t *iblock = NULL; /* Fractal heap direct block info */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -779,28 +709,28 @@ H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDassert(nrows > 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, hdr_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* * Load the heap indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, addr, nrows, NULL, 0, FALSE, H5AC__READ_ONLY_FLAG, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, addr, nrows, NULL, 0, FALSE, H5AC__READ_ONLY_FLAG, + &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") /* Print the information about the heap's indirect block */ H5HF_iblock_print(iblock, FALSE, stream, indent, fwidth); done: - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_iblock_debug() */ - /*------------------------------------------------------------------------- * Function: H5HF_sects_debug_cb * @@ -816,9 +746,9 @@ 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_debug_iter_ud2_t *udata = (H5HF_debug_iter_ud2_t *)_udata; /* User data for callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_NOINIT @@ -829,27 +759,27 @@ H5HF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(udata); /* Print generic section information */ - HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section type:", - (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE ? "single" : - (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW ? "first row" : - (sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW ? "normal row" : "unknown")))); - HDfprintf(udata->stream, "%*s%-*s %a\n", udata->indent, "", udata->fwidth, - "Section address:", - sect->sect_info.addr); - HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "Section size:", - sect->sect_info.size); + HDfprintf( + udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, "Section type:", + (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE + ? "single" + : (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW + ? "first row" + : (sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW ? "normal row" : "unknown")))); + HDfprintf(udata->stream, "%*s%-*s %" PRIuHADDR "\n", udata->indent, "", udata->fwidth, + "Section address:", sect->sect_info.addr); + HDfprintf(udata->stream, "%*s%-*s %" PRIuHSIZE "\n", udata->indent, "", udata->fwidth, + "Section size:", sect->sect_info.size); /* Dump section-specific debugging information */ - if(H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < 0) + if (H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sects_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF_sects_debug * @@ -865,8 +795,8 @@ H5HF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) herr_t H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth) { - H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -880,16 +810,16 @@ H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth HDassert(fwidth >= 0); /* Load the fractal heap header */ - if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") /* Initialize the free space information for the heap */ - if(H5HF__space_start(hdr, FALSE) < 0) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* If there is a free space manager for the heap, iterate over them */ - if(hdr->fspace) { - H5HF_debug_iter_ud2_t udata; /* User data for callbacks */ + if (hdr->fspace) { + H5HF_debug_iter_ud2_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = hdr->fspace; @@ -898,18 +828,17 @@ H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth udata.fwidth = fwidth; /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, hdr->fspace, H5HF_sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5HF__space_close(hdr) < 0) + if (H5HF__space_close(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") } /* end if */ done: - if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sects_debug() */ - diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 4295f2a5258..628dcc426b7 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,39 +26,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -66,18 +61,14 @@ /* Declare a free list to manage the H5HF_direct_t struct */ H5FL_DEFINE(H5HF_direct_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_create * @@ -91,14 +82,14 @@ H5FL_DEFINE(H5HF_direct_t); *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, haddr_t *addr_p, H5HF_free_section_t **ret_sec_node) +H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, haddr_t *addr_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 */ - haddr_t dblock_addr; /* Direct block's address */ - size_t free_space; /* Free space in new block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sec_node; /* Pointer to free space section for 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 */ FUNC_ENTER_PACKAGE @@ -110,58 +101,61 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, /* * Allocate file and memory data structures. */ - if(NULL == (dblock = H5FL_MALLOC(H5HF_direct_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap direct block") + if (NULL == (dblock = H5FL_MALLOC(H5HF_direct_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap direct block") /* Reset the metadata cache info for the heap header */ HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t)); /* Share common heap information */ dblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") + if (H5HF__hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") /* Set info for direct block */ - if(par_iblock) { - unsigned par_row = par_entry / hdr->man_dtable.cparam.width; /* Row for block */ + if (par_iblock) { + unsigned par_row = par_entry / hdr->man_dtable.cparam.width; /* Row for block */ /* Compute offset & size, based on parent's information */ dblock->block_off = par_iblock->block_off; dblock->block_off += hdr->man_dtable.row_block_off[par_row]; - dblock->block_off += hdr->man_dtable.row_block_size[par_row] * (par_entry % hdr->man_dtable.cparam.width); + dblock->block_off += + hdr->man_dtable.row_block_size[par_row] * (par_entry % hdr->man_dtable.cparam.width); H5_CHECKED_ASSIGN(dblock->size, size_t, hdr->man_dtable.row_block_size[par_row], hsize_t); } /* end if */ else { /* Must be the root direct block */ dblock->block_off = 0; - dblock->size = hdr->man_dtable.cparam.start_block_size; + dblock->size = hdr->man_dtable.cparam.start_block_size; } /* end else */ dblock->file_size = 0; - free_space = dblock->size - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + free_space = dblock->size - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); /* Allocate buffer for block */ -/* XXX: Change to using free-list factories */ - if((dblock->blk = H5FL_BLK_MALLOC(direct_block, dblock->size)) == NULL) + /* XXX: Change to using free-list factories */ + if ((dblock->blk = H5FL_BLK_MALLOC(direct_block, dblock->size)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(dblock->blk, 0, dblock->size); - dblock->write_buf = NULL; + dblock->write_buf = NULL; dblock->write_size = 0; /* Allocate [temporary] space for the direct block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") } /* end if */ else { - if(HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)dblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap direct block") + if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_DBLOCK, (hsize_t)dblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap direct block") } /* end else */ /* Attach to parent indirect block, if there is one */ dblock->parent = par_iblock; - if(dblock->parent) { - if(H5HF_man_iblock_attach(dblock->parent, par_entry, dblock_addr) < 0) + if (dblock->parent) { + if (H5HF__man_iblock_attach(dblock->parent, par_entry, dblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach direct block to parent indirect block") dblock->fd_parent = par_iblock; } /* end if */ @@ -170,42 +164,41 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, dblock->par_entry = par_entry; /* Create a new 'single' section for the free space in the block */ - if(NULL == (sec_node = H5HF_sect_single_new((dblock->block_off + H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)), - free_space, dblock->parent, dblock->par_entry))) + if (NULL == (sec_node = H5HF__sect_single_new((dblock->block_off + H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)), + free_space, dblock->parent, dblock->par_entry))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create section for new direct block's free space") /* Check what to do with section node */ - if(ret_sec_node) + if (ret_sec_node) /* Pass back the pointer to the section instead of adding it to the free list */ *ret_sec_node = sec_node; else { /* Add new free space to the heap's list of space */ - if(H5HF__space_add(hdr, sec_node, 0) < 0) + if (H5HF__space_add(hdr, sec_node, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list") } /* end else */ /* Cache the new fractal heap direct block */ - if(H5AC_insert_entry(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap direct block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap direct block to cache") /* Increase the allocated heap size */ - if(H5HF_hdr_inc_alloc(hdr, dblock->size) < 0) + if (H5HF__hdr_inc_alloc(hdr, dblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size") /* Set the address of of direct block, if requested */ - if(addr_p) + if (addr_p) *addr_p = dblock_addr; done: - if(ret_value < 0) - if(dblock) - if(H5HF_man_dblock_dest(dblock) < 0) + if (ret_value < 0) + if (dblock) + if (H5HF__man_dblock_dest(dblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_destroy * @@ -223,12 +216,11 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, - haddr_t dblock_addr, hbool_t *parent_removed) +H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, haddr_t dblock_addr, hbool_t *parent_removed) { - hsize_t dblock_size; /* Size of direct block on disk */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t dblock_size; /* Size of direct block on disk */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -239,41 +231,41 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, HDassert(dblock); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Check for root direct block */ - if(dblock->parent == NULL) + if (dblock->parent == NULL) /* Get direct block's actual size */ dblock_size = (hsize_t)hdr->pline_root_direct_size; else { - H5HF_indirect_t *par_iblock; /* Parent indirect block */ - unsigned par_entry; /* Entry in parent indirect block */ + H5HF_indirect_t *par_iblock; /* Parent indirect block */ + unsigned par_entry; /* Entry in parent indirect block */ /* Get parent information */ par_iblock = dblock->parent; - par_entry = dblock->par_entry; + par_entry = dblock->par_entry; /* Get direct block's actual size */ dblock_size = (hsize_t)par_iblock->filt_ents[par_entry].size; } /* end else */ - } /* end if */ + } /* end if */ else dblock_size = (hsize_t)dblock->size; /* Reset the parent_removed flag */ - if(parent_removed) + if (parent_removed) *parent_removed = FALSE; /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Sanity check */ HDassert(hdr->man_dtable.table_addr == dblock_addr); HDassert(hdr->man_dtable.cparam.start_block_size == dblock->size); /* Sanity check block iterator */ - HDassert(!H5HF_man_iter_ready(&hdr->next_block)); + HDassert(!H5HF__man_iter_ready(&hdr->next_block)); /* Reset header information back to "empty heap" state */ - if(H5HF__hdr_empty(hdr) < 0) + if (H5HF__hdr_empty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't make heap empty") } /* end if */ else { @@ -281,30 +273,30 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, hdr->man_alloc_size -= dblock->size; /* Check for this direct block being the highest in the heap */ - if((dblock->block_off + dblock->size) == hdr->man_iter_off) + if ((dblock->block_off + dblock->size) == hdr->man_iter_off) /* Move 'next block' iterator backwards (may shrink heap) */ - if(H5HF__hdr_reverse_iter(hdr, dblock_addr) < 0) + if (H5HF__hdr_reverse_iter(hdr, dblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reverse 'next block' iterator") /* Detach from parent indirect block */ - if(dblock->parent) { + if (dblock->parent) { /* Destroy flush dependency between direct block and parent */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* If this is the last direct block for the indirect block, the * indirect block will be removed when this direct block is detached */ - if(parent_removed && 1 == dblock->parent->nchildren) + if (parent_removed && 1 == dblock->parent->nchildren) *parent_removed = TRUE; - if(H5HF__man_iblock_detach(dblock->parent, dblock->par_entry) < 0) + if (H5HF__man_iblock_detach(dblock->parent, dblock->par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block"); - dblock->parent = NULL; + dblock->parent = NULL; dblock->par_entry = 0; } /* end if */ - } /* end else */ + } /* end else */ /* Indicate that the direct block should be deleted */ dblock->file_size = dblock_size; @@ -316,13 +308,12 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, done: /* Unprotect the indirect block, with appropriate flags */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, cache_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_destroy() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_new * @@ -337,12 +328,11 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, - H5HF_free_section_t **ret_sec_node) +H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, H5HF_free_section_t **ret_sec_node) { - haddr_t dblock_addr; /* Address of new direct block */ - size_t min_dblock_size; /* Min. size of direct block to allocate */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Address of new direct block */ + size_t min_dblock_size; /* Min. size of direct block to allocate */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -353,7 +343,7 @@ H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, HDassert(request > 0); /* Compute the min. size of the direct block needed to fulfill the request */ - if(request < hdr->man_dtable.cparam.start_block_size) + if (request < hdr->man_dtable.cparam.start_block_size) min_dblock_size = hdr->man_dtable.cparam.start_block_size; else { min_dblock_size = ((size_t)1) << (1 + H5VM_log2_gen((uint64_t)request)); @@ -361,57 +351,62 @@ H5HF__man_dblock_new(H5HF_hdr_t *hdr, size_t request, } /* end else */ /* Adjust the size of block needed to fulfill request, with overhead */ - if(min_dblock_size < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) + request) + if (min_dblock_size < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) + request) min_dblock_size *= 2; /* Check if this is the first block in the heap */ - if(!H5F_addr_defined(hdr->man_dtable.table_addr) && - min_dblock_size == hdr->man_dtable.cparam.start_block_size) { + if (!H5F_addr_defined(hdr->man_dtable.table_addr) && + min_dblock_size == hdr->man_dtable.cparam.start_block_size) { /* Create new direct block at starting offset */ - if(H5HF__man_dblock_create(hdr, NULL, 0, &dblock_addr, ret_sec_node) < 0) + if (H5HF__man_dblock_create(hdr, NULL, 0, &dblock_addr, ret_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") /* Point root at new direct block */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = dblock_addr; - if(hdr->filter_len > 0) { - hdr->pline_root_direct_size = hdr->man_dtable.cparam.start_block_size; + hdr->man_dtable.table_addr = dblock_addr; + if (hdr->filter_len > 0) { + hdr->pline_root_direct_size = hdr->man_dtable.cparam.start_block_size; hdr->pline_root_direct_filter_mask = 0; } /* end if */ /* Extend heap to cover new direct block */ - if(H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) + if (H5HF__hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, + (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") } /* end if */ /* Root entry already exists, allocate direct block from root indirect block */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block to create */ - unsigned next_row; /* Iterator's next block row */ - unsigned next_entry; /* Iterator's next block entry */ - size_t next_size; /* Size of next direct block to create */ + H5HF_indirect_t *iblock; /* Pointer to indirect block to create */ + unsigned next_row; /* Iterator's next block row */ + unsigned next_entry; /* Iterator's next block entry */ + size_t next_size; /* Size of next direct block to create */ - /* Update iterator to reflect any previous increments as well as allow for requested direct block size */ - if(H5HF__hdr_update_iter(hdr, min_dblock_size) < 0) + /* Update iterator to reflect any previous increments as well as allow for requested direct block size + */ + if (H5HF__hdr_update_iter(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "unable to update block iterator") /* Retrieve information about current iterator position */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") HDassert(next_row < iblock->nrows); H5_CHECKED_ASSIGN(next_size, size_t, hdr->man_dtable.row_block_size[next_row], hsize_t); /* Check for skipping over blocks */ - if(min_dblock_size > next_size) { -HDfprintf(stderr, "%s: Skipping direct block sizes not supported, min_dblock_size = %Zu, next_size = %Zu\n", FUNC, min_dblock_size, next_size); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not supported yet") + if (min_dblock_size > next_size) { + HDfprintf( + stderr, + "%s: Skipping direct block sizes not supported, min_dblock_size = %zu, next_size = %zu\n", + FUNC, min_dblock_size, next_size); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not supported yet") } /* end if */ /* Advance "next block" iterator to next direct block entry */ - if(H5HF_hdr_inc_iter(hdr, (hsize_t)next_size, 1) < 0) + if (H5HF__hdr_inc_iter(hdr, (hsize_t)next_size, 1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment 'next block' iterator") /* Create new direct block at current location*/ - if(H5HF__man_dblock_create(hdr, iblock, next_entry, &dblock_addr, ret_sec_node) < 0) + if (H5HF__man_dblock_create(hdr, iblock, next_entry, &dblock_addr, ret_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") } /* end else */ @@ -419,7 +414,6 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not su FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_new() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_protect * @@ -434,13 +428,12 @@ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "skipping direct block sizes not su *------------------------------------------------------------------------- */ 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__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 infor for deserializing direct block */ + H5HF_direct_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -455,9 +448,9 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Set up parent info */ - udata.par_info.hdr = hdr; + udata.par_info.hdr = hdr; udata.par_info.iblock = par_iblock; - udata.par_info.entry = par_entry; + udata.par_info.entry = par_entry; /* set up the file pointer in the user data */ udata.f = hdr->f; @@ -468,31 +461,32 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, /* compute the on disk image size -- observe that odi_size and * dblock_size will be identical if there is no filtering. */ - if(hdr->filter_len > 0) { - if(par_iblock == NULL) { - udata.odi_size = hdr->pline_root_direct_size; - udata.filter_mask = hdr->pline_root_direct_filter_mask; - } /* end if */ + if (hdr->filter_len > 0) { + if (par_iblock == NULL) { + udata.odi_size = hdr->pline_root_direct_size; + udata.filter_mask = hdr->pline_root_direct_filter_mask; + } /* end if */ else { - /* Sanity check */ - HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, dblock_addr)); + /* Sanity check */ + HDassert(H5F_addr_eq(par_iblock->ents[par_entry].addr, dblock_addr)); - /* Set up parameters to read filtered direct block */ - udata.odi_size = par_iblock->filt_ents[par_entry].size; + /* Set up parameters to read filtered direct block */ + udata.odi_size = par_iblock->filt_ents[par_entry].size; udata.filter_mask = par_iblock->filt_ents[par_entry].filter_mask; - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { - udata.odi_size = dblock_size; + udata.odi_size = dblock_size; udata.filter_mask = 0; } /* end else */ /* Reset compression context info */ udata.decompressed = FALSE; - udata.dblk = NULL; + udata.dblk = NULL; /* Protect the direct block */ - if(NULL == (dblock = (H5HF_direct_t *)H5AC_protect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, &udata, flags))) + if (NULL == + (dblock = (H5HF_direct_t *)H5AC_protect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, &udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap direct block") /* Set the return value */ @@ -502,7 +496,6 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_locate * @@ -516,16 +509,15 @@ H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, *------------------------------------------------------------------------- */ herr_t -H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, - H5HF_indirect_t **ret_iblock, unsigned *ret_entry, hbool_t *ret_did_protect, - unsigned flags) +H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, H5HF_indirect_t **ret_iblock, unsigned *ret_entry, + hbool_t *ret_did_protect, unsigned flags) { - haddr_t iblock_addr; /* Indirect block's address */ - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned row, col; /* Row & column for object's block */ - unsigned entry; /* Entry of block */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t iblock_addr; /* Indirect block's address */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned row, col; /* Row & column for object's block */ + unsigned entry; /* Entry of block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -533,7 +525,7 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, * Check arguments. */ HDassert(hdr); - HDassert(hdr->man_dtable.curr_root_rows); /* Only works for heaps with indirect root block */ + HDassert(hdr->man_dtable.curr_root_rows); /* Only works for heaps with indirect root block */ HDassert(ret_iblock); HDassert(ret_did_protect); @@ -541,26 +533,27 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Look up row & column for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, obj_off, &row, &col) < 0) + if (H5HF__dtable_lookup(&hdr->man_dtable, obj_off, &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of object") /* Set initial indirect block info */ iblock_addr = hdr->man_dtable.table_addr; /* Lock root indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, FALSE, flags, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, hdr->man_dtable.curr_root_rows, NULL, 0, + FALSE, flags, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Check for indirect block row */ - while(row >= hdr->man_dtable.max_direct_rows) { - H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ - hbool_t new_did_protect; /* Whether we protected the indirect block or not */ - unsigned nrows; /* Number of rows in new indirect block */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting parent indirect block */ + while (row >= hdr->man_dtable.max_direct_rows) { + H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ + hbool_t new_did_protect; /* Whether we protected the indirect block or not */ + unsigned nrows; /* Number of rows in new indirect block */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting parent indirect block */ /* Compute # of rows in child indirect block */ nrows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[row]) - hdr->man_dtable.first_row_bits) + 1; - HDassert(nrows < iblock->nrows); /* child must be smaller than parent */ + HDassert(nrows < iblock->nrows); /* child must be smaller than parent */ /* Compute indirect block's entry */ entry = (row * hdr->man_dtable.cparam.width) + col; @@ -569,8 +562,8 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, iblock_addr = iblock->ents[entry].addr; /* Check if we need to (re-)create the child indirect block */ - if(!H5F_addr_defined(iblock_addr)) { - if(H5HF__man_iblock_create(hdr, iblock, entry, nrows, nrows, &iblock_addr) < 0) + if (!H5F_addr_defined(iblock_addr)) { + if (H5HF__man_iblock_create(hdr, iblock, entry, nrows, nrows, &iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") /* Indicate that the parent indirect block was modified */ @@ -578,34 +571,34 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, } /* end if */ /* Lock child indirect block */ - if(NULL == (new_iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, iblock, entry, FALSE, flags, &new_did_protect))) + if (NULL == (new_iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, iblock, entry, FALSE, + flags, &new_did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Release the current indirect block */ - if(H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") /* Switch variables to use new indirect block */ - iblock = new_iblock; + iblock = new_iblock; did_protect = new_did_protect; /* Look up row & column in new indirect block for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, (obj_off - iblock->block_off), &row, &col) < 0) + if (H5HF__dtable_lookup(&hdr->man_dtable, (obj_off - iblock->block_off), &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of object") - HDassert(row < iblock->nrows); /* child must be smaller than parent */ - } /* end while */ + HDassert(row < iblock->nrows); /* child must be smaller than parent */ + } /* end while */ /* Set return parameters */ - if(ret_entry) + if (ret_entry) *ret_entry = (row * hdr->man_dtable.cparam.width) + col; - *ret_iblock = iblock; + *ret_iblock = iblock; *ret_did_protect = did_protect; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_locate() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_dblock_delete * @@ -626,8 +619,8 @@ H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) { - unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -639,23 +632,23 @@ H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) HDassert(dblock_size > 0); /* Check the direct block's status in the metadata cache */ - if(H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) + if (H5AC_get_entry_status(f, dblock_addr, &dblock_status) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block") /* If the direct block is in the cache, expunge it now */ - if(dblock_status & H5AC_ES__IN_CACHE) { + if (dblock_status & H5AC_ES__IN_CACHE) { /* Sanity checks on direct block */ HDassert(!(dblock_status & H5AC_ES__IS_PINNED)); HDassert(!(dblock_status & H5AC_ES__IS_PROTECTED)); /* Evict the direct block from the metadata cache */ - if(H5AC_expunge_entry(f, H5AC_FHEAP_DBLOCK, dblock_addr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_expunge_entry(f, H5AC_FHEAP_DBLOCK, dblock_addr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "unable to remove direct block from cache") } /* end if */ /* Check if the direct block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(f, dblock_addr)) + if (!H5F_IS_TMP_ADDR(f, dblock_addr)) /* Release direct block's disk space */ /* (XXX: Under the best of circumstances, this block's space in the file * would be freed in the H5AC_expunge_entry() call above (and the @@ -667,16 +660,15 @@ H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) * that would add a bunch of unnecessary overhead to the process, * so we just release the file space here, directly. -QAK) */ - if(H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, dblock_addr, dblock_size) < 0) + if (H5MF_xfree(f, H5FD_MEM_FHEAP_DBLOCK, dblock_addr, dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap direct block file space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_delete() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_dblock_dest + * Function: H5HF__man_dblock_dest * * Purpose: Destroys a fractal heap direct block in memory. * @@ -688,11 +680,11 @@ H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size) *------------------------------------------------------------------------- */ herr_t -H5HF_man_dblock_dest(H5HF_direct_t *dblock) +H5HF__man_dblock_dest(H5HF_direct_t *dblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -701,11 +693,12 @@ H5HF_man_dblock_dest(H5HF_direct_t *dblock) /* Decrement reference count on shared fractal heap info */ HDassert(dblock->hdr != NULL); - if(H5HF_hdr_decr(dblock->hdr) < 0) + if (H5HF__hdr_decr(dblock->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(dblock->parent) - if(H5HF__iblock_decr(dblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (dblock->parent) + if (H5HF__iblock_decr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Free block's buffer */ dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); @@ -715,5 +708,4 @@ H5HF_man_dblock_dest(H5HF_direct_t *dblock) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_dblock_dest() */ - +} /* end H5HF__man_dblock_dest() */ diff --git a/src/H5HFdtable.c b/src/H5HFdtable.c index 3de396eac6a..5a1f9503a5b 100644 --- a/src/H5HFdtable.c +++ b/src/H5HFdtable.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,56 +26,47 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_init + * Function: H5HF__dtable_init * * Purpose: Initialize values for doubling table * @@ -87,14 +78,14 @@ *------------------------------------------------------------------------- */ herr_t -H5HF_dtable_init(H5HF_dtable_t *dtable) +H5HF__dtable_init(H5HF_dtable_t *dtable) { - hsize_t tmp_block_size; /* Temporary block size */ - hsize_t acc_block_off; /* Accumulated block offset */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_block_size; /* Temporary block size */ + hsize_t acc_block_off; /* Accumulated block offset */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -102,41 +93,43 @@ H5HF_dtable_init(H5HF_dtable_t *dtable) HDassert(dtable); /* Compute/cache some values */ - dtable->start_bits = H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size); - dtable->first_row_bits = dtable->start_bits + H5VM_log2_of2(dtable->cparam.width); - dtable->max_root_rows = (dtable->cparam.max_index - dtable->first_row_bits) + 1; - dtable->max_direct_bits = H5VM_log2_of2((uint32_t)dtable->cparam.max_direct_size); - dtable->max_direct_rows = (dtable->max_direct_bits - dtable->start_bits) + 2; - dtable->num_id_first_row = dtable->cparam.start_block_size * dtable->cparam.width; + dtable->start_bits = H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size); + dtable->first_row_bits = dtable->start_bits + H5VM_log2_of2(dtable->cparam.width); + dtable->max_root_rows = (dtable->cparam.max_index - dtable->first_row_bits) + 1; + dtable->max_direct_bits = H5VM_log2_of2((uint32_t)dtable->cparam.max_direct_size); + dtable->max_direct_rows = (dtable->max_direct_bits - dtable->start_bits) + 2; + dtable->num_id_first_row = dtable->cparam.start_block_size * dtable->cparam.width; dtable->max_dir_blk_off_size = H5HF_SIZEOF_OFFSET_LEN(dtable->cparam.max_direct_size); /* Build table of block sizes for each row */ - if(NULL == (dtable->row_block_size = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block size table") - if(NULL == (dtable->row_block_off = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block offset table") - if(NULL == (dtable->row_tot_dblock_free = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table total direct block free space table") - if(NULL == (dtable->row_max_dblock_free = (size_t *)H5MM_malloc(dtable->max_root_rows * sizeof(size_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table max. direct block free space table") - tmp_block_size = dtable->cparam.start_block_size; - acc_block_off = dtable->cparam.start_block_size * dtable->cparam.width; + if (NULL == (dtable->row_block_size = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block size table") + if (NULL == (dtable->row_block_off = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create doubling table block offset table") + if (NULL == + (dtable->row_tot_dblock_free = (hsize_t *)H5MM_malloc(dtable->max_root_rows * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't create doubling table total direct block free space table") + if (NULL == (dtable->row_max_dblock_free = (size_t *)H5MM_malloc(dtable->max_root_rows * sizeof(size_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't create doubling table max. direct block free space table") + tmp_block_size = dtable->cparam.start_block_size; + acc_block_off = dtable->cparam.start_block_size * dtable->cparam.width; dtable->row_block_size[0] = dtable->cparam.start_block_size; - dtable->row_block_off[0] = 0; - for(u = 1; u < dtable->max_root_rows; u++) { + dtable->row_block_off[0] = 0; + for (u = 1; u < dtable->max_root_rows; u++) { dtable->row_block_size[u] = tmp_block_size; - dtable->row_block_off[u] = acc_block_off; + dtable->row_block_off[u] = acc_block_off; tmp_block_size *= 2; acc_block_off *= 2; } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_dtable_init() */ +} /* end H5HF__dtable_init() */ - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_lookup + * Function: H5HF__dtable_lookup * * Purpose: Compute the row & col of an offset in a doubling-table * @@ -148,9 +141,9 @@ H5HF_dtable_init(H5HF_dtable_t *dtable) *------------------------------------------------------------------------- */ herr_t -H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsigned *col) +H5HF__dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsigned *col) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -160,24 +153,23 @@ H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsi HDassert(col); /* Check for offset in first row */ - if(off < dtable->num_id_first_row) { + if (off < dtable->num_id_first_row) { *row = 0; H5_CHECKED_ASSIGN(*col, unsigned, (off / dtable->cparam.start_block_size), hsize_t); } /* end if */ else { - unsigned high_bit = H5VM_log2_gen(off); /* Determine the high bit in the offset */ - hsize_t off_mask = ((hsize_t)1) << high_bit; /* Compute mask for determining column */ + unsigned high_bit = H5VM_log2_gen(off); /* Determine the high bit in the offset */ + hsize_t off_mask = ((hsize_t)1) << high_bit; /* Compute mask for determining column */ *row = (high_bit - dtable->first_row_bits) + 1; H5_CHECKED_ASSIGN(*col, unsigned, ((off - off_mask) / dtable->row_block_size[*row]), hsize_t); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_dtable_lookup() */ +} /* end H5HF__dtable_lookup() */ - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_dest + * Function: H5HF__dtable_dest * * Purpose: Release information for doubling table * @@ -189,9 +181,9 @@ H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsi *------------------------------------------------------------------------- */ herr_t -H5HF_dtable_dest(H5HF_dtable_t *dtable) +H5HF__dtable_dest(H5HF_dtable_t *dtable) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -211,11 +203,10 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable) H5MM_xfree(dtable->row_max_dblock_free); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_dtable_dest() */ +} /* end H5HF__dtable_dest() */ - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_size_to_row + * Function: H5HF__dtable_size_to_row * * Purpose: Compute row that can hold block of a certain size * @@ -227,28 +218,29 @@ H5HF_dtable_dest(H5HF_dtable_t *dtable) *------------------------------------------------------------------------- */ unsigned -H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) +H5HF__dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) { - unsigned row = 0; /* Row where block will fit */ + unsigned row = 0; /* Row where block will fit */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. */ HDassert(dtable); - if(block_size == dtable->cparam.start_block_size) + if (block_size == dtable->cparam.start_block_size) row = 0; else - row = (H5VM_log2_of2((uint32_t)block_size) - H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size)) + 1; + row = + (H5VM_log2_of2((uint32_t)block_size) - H5VM_log2_of2((uint32_t)dtable->cparam.start_block_size)) + + 1; FUNC_LEAVE_NOAPI(row) -} /* end H5HF_dtable_size_to_row() */ +} /* end H5HF__dtable_size_to_row() */ - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_size_to_rows + * Function: H5HF__dtable_size_to_rows * * Purpose: Compute # of rows of indirect block of a given size * @@ -260,11 +252,11 @@ H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size) *------------------------------------------------------------------------- */ unsigned -H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) +H5HF__dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) { - unsigned rows = 0; /* # of rows required for indirect block */ + unsigned rows = 0; /* # of rows required for indirect block */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -274,11 +266,10 @@ H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) rows = (H5VM_log2_gen(size) - dtable->first_row_bits) + 1; FUNC_LEAVE_NOAPI(rows) -} /* end H5HF_dtable_size_to_rows() */ +} /* end H5HF__dtable_size_to_rows() */ - /*------------------------------------------------------------------------- - * Function: H5HF_dtable_span_size + * Function: H5HF__dtable_span_size * * Purpose: Compute the size covered by a span of entries * @@ -290,16 +281,16 @@ H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size) *------------------------------------------------------------------------- */ hsize_t -H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, - unsigned start_col, unsigned num_entries) +H5HF__dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, unsigned start_col, + unsigned num_entries) { unsigned start_entry; /* Entry for first block covered */ unsigned end_row; /* Row for last block covered */ unsigned end_col; /* Column for last block covered */ unsigned end_entry; /* Entry for last block covered */ - hsize_t acc_span_size = 0; /* Accumulated span size */ + hsize_t acc_span_size = 0; /* Accumulated span size */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -312,8 +303,8 @@ H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, /* Compute ending entry, column & row */ end_entry = (start_entry + num_entries) - 1; - end_row = end_entry / dtable->cparam.width; - end_col = end_entry % dtable->cparam.width; + end_row = end_entry / dtable->cparam.width; + end_col = end_entry % dtable->cparam.width; /* Initialize accumulated span size */ acc_span_size = 0; @@ -321,31 +312,26 @@ H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, /* Compute span size covered */ /* Check for multi-row span */ - if(start_row != end_row) { + if (start_row != end_row) { /* Accommodate partial starting row */ - if(start_col > 0) { - acc_span_size = dtable->row_block_size[start_row] * - (dtable->cparam.width - start_col); + if (start_col > 0) { + acc_span_size = dtable->row_block_size[start_row] * (dtable->cparam.width - start_col); start_row++; } /* end if */ /* Accumulate full rows */ - while(start_row < end_row) { - acc_span_size += dtable->row_block_size[start_row] * - dtable->cparam.width; + while (start_row < end_row) { + acc_span_size += dtable->row_block_size[start_row] * dtable->cparam.width; start_row++; } /* end while */ /* Accommodate partial ending row */ - acc_span_size += dtable->row_block_size[start_row] * - (end_col + 1); + acc_span_size += dtable->row_block_size[start_row] * (end_col + 1); } /* end if */ else { /* Span is in same row */ - acc_span_size = dtable->row_block_size[start_row] * - ((end_col - start_col) + 1); + acc_span_size = dtable->row_block_size[start_row] * ((end_col - start_col) + 1); } /* end else */ FUNC_LEAVE_NOAPI(acc_span_size) -} /* end H5HF_sect_indirect_span_size() */ - +} /* end H5HF__dtable_span_size() */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 053afd02372..cd5ba2304e9 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,18 +26,17 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -58,22 +57,18 @@ #define H5HF_WIDTH_LIMIT (64 * 1024) #endif /* NDEBUG */ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -81,20 +76,16 @@ /* Declare a free list to manage the H5HF_hdr_t struct */ H5FL_DEFINE_STATIC(H5HF_hdr_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_alloc + * Function: H5HF__hdr_alloc * * Purpose: Allocate shared fractal heap header * @@ -106,12 +97,12 @@ H5FL_DEFINE_STATIC(H5HF_hdr_t); *------------------------------------------------------------------------- */ H5HF_hdr_t * -H5HF_hdr_alloc(H5F_t *f) +H5HF__hdr_alloc(H5F_t *f) { - H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */ - H5HF_hdr_t *ret_value = NULL; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */ + H5HF_hdr_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -119,11 +110,11 @@ H5HF_hdr_alloc(H5F_t *f) HDassert(f); /* Allocate space for the shared information */ - if(NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header") + if (NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header") /* Set the internal parameters for the heap */ - hdr->f = f; + hdr->f = f; hdr->sizeof_size = H5F_SIZEOF_SIZE(f); hdr->sizeof_addr = H5F_SIZEOF_ADDR(f); @@ -132,9 +123,8 @@ H5HF_hdr_alloc(H5F_t *f) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_alloc() */ +} /* end H5HF__hdr_alloc() */ - /*------------------------------------------------------------------------- * Function: H5HF_hdr_free_space * @@ -149,16 +139,16 @@ H5HF_hdr_alloc(H5F_t *f) *------------------------------------------------------------------------- */ static herr_t -H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) +H5HF__hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) { - hsize_t acc_heap_size; /* Accumumated heap space */ - hsize_t iblock_size; /* Size of indirect block to calculate for */ - hsize_t acc_dblock_free; /* Accumumated direct block free space */ - size_t max_dblock_free; /* Max. direct block free space */ - unsigned curr_row; /* Current row in block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t acc_heap_size; /* Accumumated heap space */ + hsize_t iblock_size; /* Size of indirect block to calculate for */ + hsize_t acc_dblock_free; /* Accumumated direct block free space */ + size_t max_dblock_free; /* Max. direct block free space */ + unsigned curr_row; /* Current row in block */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Check arguments. @@ -167,17 +157,15 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) HDassert(iblock_row >= hdr->man_dtable.max_direct_rows); /* Set the free space in direct blocks */ - acc_heap_size = 0; + acc_heap_size = 0; acc_dblock_free = 0; max_dblock_free = 0; - iblock_size = hdr->man_dtable.row_block_size[iblock_row]; - curr_row = 0; - while(acc_heap_size < iblock_size) { - acc_heap_size += hdr->man_dtable.row_block_size[curr_row] * - hdr->man_dtable.cparam.width; - acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[curr_row] * - hdr->man_dtable.cparam.width; - if(hdr->man_dtable.row_max_dblock_free[curr_row] > max_dblock_free) + iblock_size = hdr->man_dtable.row_block_size[iblock_row]; + curr_row = 0; + while (acc_heap_size < iblock_size) { + acc_heap_size += hdr->man_dtable.row_block_size[curr_row] * hdr->man_dtable.cparam.width; + acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[curr_row] * hdr->man_dtable.cparam.width; + if (hdr->man_dtable.row_max_dblock_free[curr_row] > max_dblock_free) max_dblock_free = hdr->man_dtable.row_max_dblock_free[curr_row]; curr_row++; } /* end while */ @@ -187,11 +175,10 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) hdr->man_dtable.row_max_dblock_free[iblock_row] = max_dblock_free; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_compute_free_space() */ +} /* end H5HF__hdr_compute_free_space() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_finish_init_phase1 + * Function: H5HF__hdr_finish_init_phase1 * * Purpose: First phase to finish initializing info in shared heap header * @@ -203,11 +190,11 @@ H5HF_hdr_compute_free_space(H5HF_hdr_t *hdr, unsigned iblock_row) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) +H5HF__hdr_finish_init_phase1(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -216,20 +203,19 @@ H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) /* Compute/cache some values */ hdr->heap_off_size = (uint8_t)H5HF_SIZEOF_OFFSET_BITS(hdr->man_dtable.cparam.max_index); - if(H5HF_dtable_init(&hdr->man_dtable) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info") + if (H5HF__dtable_init(&hdr->man_dtable) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize doubling table info") /* Set the size of heap IDs */ - hdr->heap_len_size = (uint8_t)MIN(hdr->man_dtable.max_dir_blk_off_size, - H5VM_limit_enc_size((uint64_t)hdr->max_man_size)); + hdr->heap_len_size = + (uint8_t)MIN(hdr->man_dtable.max_dir_blk_off_size, H5VM_limit_enc_size((uint64_t)hdr->max_man_size)); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_finish_init_phase1() */ +} /* end H5HF__hdr_finish_init_phase1() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_finish_init_phase2 + * Function: H5HF__hdr_finish_init_phase2 * * Purpose: Second phase to finish initializing info in shared heap header * @@ -241,12 +227,12 @@ H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) +H5HF__hdr_finish_init_phase2(H5HF_hdr_t *hdr) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -254,36 +240,36 @@ H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) HDassert(hdr); /* Set the free space in direct blocks */ - for(u = 0; u < hdr->man_dtable.max_root_rows; u++) { - if(u < hdr->man_dtable.max_direct_rows) { - hdr->man_dtable.row_tot_dblock_free[u] = hdr->man_dtable.row_block_size[u] - - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - H5_CHECKED_ASSIGN(hdr->man_dtable.row_max_dblock_free[u], size_t, hdr->man_dtable.row_tot_dblock_free[u], hsize_t); + for (u = 0; u < hdr->man_dtable.max_root_rows; u++) { + if (u < hdr->man_dtable.max_direct_rows) { + hdr->man_dtable.row_tot_dblock_free[u] = + hdr->man_dtable.row_block_size[u] - H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + H5_CHECKED_ASSIGN(hdr->man_dtable.row_max_dblock_free[u], size_t, + hdr->man_dtable.row_tot_dblock_free[u], hsize_t); } /* end if */ - else - if(H5HF_hdr_compute_free_space(hdr, u) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize direct block free space for indirect block") + else if (H5HF__hdr_compute_free_space(hdr, u) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't initialize direct block free space for indirect block") } /* end for */ /* Initialize the block iterator for searching for free space */ - if(H5HF_man_iter_init(&hdr->next_block) < 0) + if (H5HF__man_iter_init(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize space search block iterator") /* Initialize the information for tracking 'huge' objects */ - if(H5HF_huge_init(hdr) < 0) + if (H5HF__huge_init(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize info for tracking huge objects") /* Initialize the information for tracking 'tiny' objects */ - if(H5HF_tiny_init(hdr) < 0) + if (H5HF__tiny_init(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize info for tracking tiny objects") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_finish_init_phase2() */ +} /* end H5HF__hdr_finish_init_phase2() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_finish_init + * Function: H5HF__hdr_finish_init * * Purpose: Finish initializing info in shared heap header * @@ -295,11 +281,11 @@ H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_finish_init(H5HF_hdr_t *hdr) +H5HF__hdr_finish_init(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -307,20 +293,19 @@ H5HF_hdr_finish_init(H5HF_hdr_t *hdr) HDassert(hdr); /* First phase of header final initialization */ - if(H5HF_hdr_finish_init_phase1(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #1 of header final initialization") + if (H5HF__hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #1 of header final initialization") /* Second phase of header final initialization */ - if(H5HF_hdr_finish_init_phase2(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #2 of header final initialization") + if (H5HF__hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't finish phase #2 of header final initialization") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_finish_init() */ +} /* end H5HF__hdr_finish_init() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_create + * Function: H5HF__hdr_create * * Purpose: Create new fractal heap header * @@ -332,13 +317,13 @@ H5HF_hdr_finish_init(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ haddr_t -H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) +H5HF__hdr_create(H5F_t *f, const H5HF_create_t *cparam) { - H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ - size_t dblock_overhead; /* Direct block's overhead */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5HF_hdr_t *hdr = NULL; /* The new fractal heap header information */ + size_t dblock_overhead; /* Direct block's overhead */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -348,39 +333,40 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) #ifndef NDEBUG /* Check for valid parameters */ - if(cparam->managed.width == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width must be greater than zero") - if(cparam->managed.width > H5HF_WIDTH_LIMIT) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width too large") - if(!POWER_OF_TWO(cparam->managed.width)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width not power of two") - if(cparam->managed.start_block_size == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size must be greater than zero") - if(!POWER_OF_TWO(cparam->managed.start_block_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size not power of two") - if(cparam->managed.max_direct_size == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size must be greater than zero") - if(cparam->managed.max_direct_size > H5HF_MAX_DIRECT_SIZE_LIMIT) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size too large") - if(!POWER_OF_TWO(cparam->managed.max_direct_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not power of two") - if(cparam->managed.max_direct_size < cparam->max_man_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not large enough to hold all managed blocks") - if(cparam->managed.max_index == 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size must be greater than zero") + if (cparam->managed.width == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width must be greater than zero") + if (cparam->managed.width > H5HF_WIDTH_LIMIT) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width too large") + if (!POWER_OF_TWO(cparam->managed.width)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "width not power of two") + if (cparam->managed.start_block_size == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size must be greater than zero") + if (!POWER_OF_TWO(cparam->managed.start_block_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "starting block size not power of two") + if (cparam->managed.max_direct_size == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size must be greater than zero") + if (cparam->managed.max_direct_size > H5HF_MAX_DIRECT_SIZE_LIMIT) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size too large") + if (!POWER_OF_TWO(cparam->managed.max_direct_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not power of two") + if (cparam->managed.max_direct_size < cparam->max_man_size) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, + "max. direct block size not large enough to hold all managed blocks") + if (cparam->managed.max_index == 0) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size must be greater than zero") #endif /* NDEBUG */ /* Allocate & basic initialization for the shared header */ - if(NULL == (hdr = H5HF_hdr_alloc(f))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't allocate space for shared heap info") + if (NULL == (hdr = H5HF__hdr_alloc(f))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "can't allocate space for shared heap info") #ifndef NDEBUG - if(cparam->managed.max_index > (unsigned)(8 * hdr->sizeof_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size too large for file") + if (cparam->managed.max_index > (unsigned)(8 * hdr->sizeof_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. heap size too large for file") #endif /* NDEBUG */ /* Set the creation parameters for the heap */ - hdr->max_man_size = cparam->max_man_size; + hdr->max_man_size = cparam->max_man_size; hdr->checksum_dblocks = cparam->checksum_dblocks; H5MM_memcpy(&(hdr->man_dtable.cparam), &(cparam->managed), sizeof(H5HF_dtable_cparam_t)); @@ -395,44 +381,45 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) /* First phase of header final initialization */ /* (doesn't need ID length set up) */ - if(H5HF_hdr_finish_init_phase1(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #1 of header final initialization") + if (H5HF__hdr_finish_init_phase1(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "can't finish phase #1 of header final initialization") /* Copy any I/O filter pipeline */ /* (This code is not in the "finish init phase" routines because those * routines are also called from the cache 'load' callback, and the filter * length is already set in that case (its stored in the header on disk)) */ - if(cparam->pline.nused > 0) { + if (cparam->pline.nused > 0) { /* Check if the filters in the DCPL can be applied to this dataset */ - if(H5Z_can_apply_direct(&(cparam->pline)) < 0) + if (H5Z_can_apply_direct(&(cparam->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "I/O filters can't operate on this heap") /* Mark the filters as checked */ hdr->checked_filters = TRUE; /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local_direct(&(cparam->pline)) < 0) + if (H5Z_set_local_direct(&(cparam->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to set local filter parameters") /* Copy the I/O filter pipeline from the creation parameters to the header */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, HADDR_UNDEF, "can't copy I/O filter pipeline") /* Set the version for the I/O pipeline message */ - if(H5O_pline_set_version(hdr->f, &(hdr->pline)) < 0) + if (H5O_pline_set_version(hdr->f, &(hdr->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set version of I/O filter pipeline") /* Compute the I/O filters' encoded size */ - if(0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) + if (0 == (hdr->filter_len = (unsigned)H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, HADDR_UNDEF, "can't get I/O filter pipeline size") /* Compute size of header on disk */ - hdr->heap_size = H5HF_HEADER_SIZE(hdr) /* Base header size */ - + hdr->sizeof_size /* Size of size for filtered root direct block */ - + 4 /* Size of filter mask for filtered root direct block */ - + hdr->filter_len; /* Size of encoded I/O filter info */ - } /* end if */ + hdr->heap_size = H5HF_HEADER_SIZE(hdr) /* Base header size */ + + hdr->sizeof_size /* Size of size for filtered root direct block */ + + 4 /* Size of filter mask for filtered root direct block */ + + hdr->filter_len; /* Size of encoded I/O filter info */ + } /* end if */ else { /* Set size of header on disk */ hdr->heap_size = H5HF_HEADER_SIZE(hdr); @@ -446,30 +433,34 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) * routines are also called from the cache 'load' callback, and the ID * length is already set in that case (its stored in the header on disk)) */ - switch(cparam->id_len) { - case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects in the heap */ + switch (cparam->id_len) { + case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects + in the heap */ hdr->id_len = (unsigned)1 + hdr->heap_off_size + hdr->heap_len_size; break; - case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access 'huge' objects in the heap */ - if(hdr->filter_len > 0) - hdr->id_len = (unsigned)1 /* ID flags */ - + hdr->sizeof_addr /* Address of filtered object */ - + hdr->sizeof_size /* Length of filtered object */ - + 4 /* Filter mask for filtered object */ - + hdr->sizeof_size; /* Size of de-filtered object in memory */ + case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access + 'huge' objects in the heap */ + if (hdr->filter_len > 0) + hdr->id_len = (unsigned)1 /* ID flags */ + + hdr->sizeof_addr /* Address of filtered object */ + + hdr->sizeof_size /* Length of filtered object */ + + 4 /* Filter mask for filtered object */ + + hdr->sizeof_size; /* Size of de-filtered object in memory */ else - hdr->id_len = (unsigned)1 /* ID flags */ - + hdr->sizeof_addr /* Address of object */ - + hdr->sizeof_size; /* Length of object */ + hdr->id_len = (unsigned)1 /* ID flags */ + + hdr->sizeof_addr /* Address of object */ + + hdr->sizeof_size; /* Length of object */ break; - default: /* Use the requested size for the heap ID */ + default: /* Use the requested size for the heap ID */ /* Check boundaries */ - if(cparam->id_len < (1 + hdr->heap_off_size + hdr->heap_len_size)) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, "ID length not large enough to hold object IDs") - else if(cparam->id_len > H5HF_MAX_ID_LEN) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, "ID length too large to store tiny object lengths") + if (cparam->id_len < (1 + hdr->heap_off_size + hdr->heap_len_size)) + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, + "ID length not large enough to hold object IDs") + else if (cparam->id_len > H5HF_MAX_ID_LEN) + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, HADDR_UNDEF, + "ID length too large to store tiny object lengths") /* Use the requested size for the heap ID */ hdr->id_len = cparam->id_len; @@ -478,35 +469,36 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) /* Second phase of header final initialization */ /* (needs ID and filter lengths set up) */ - if(H5HF_hdr_finish_init_phase2(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't finish phase #2 of header final initialization") + if (H5HF__hdr_finish_init_phase2(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "can't finish phase #2 of header final initialization") /* Extra checking for possible gap between max. direct block size minus * overhead and "huge" object size */ dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((cparam->managed.max_direct_size - dblock_overhead) < cparam->max_man_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, "max. direct block size not large enough to hold all managed blocks") + if ((cparam->managed.max_direct_size - dblock_overhead) < cparam->max_man_size) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, HADDR_UNDEF, + "max. direct block size not large enough to hold all managed blocks") /* Allocate space for the header on disk */ - if(HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, (hsize_t)hdr->heap_size))) + if (HADDR_UNDEF == (hdr->heap_addr = H5MF_alloc(f, H5FD_MEM_FHEAP_HDR, (hsize_t)hdr->heap_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for fractal heap header") /* Cache the new fractal heap header */ - if(H5AC_insert_entry(f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, HADDR_UNDEF, "can't add fractal heap header to cache") /* Set address of heap header to return */ ret_value = hdr->heap_addr; done: - if(!H5F_addr_defined(ret_value) && hdr) - if(H5HF_hdr_free(hdr) < 0) + if (!H5F_addr_defined(ret_value) && hdr) + if (H5HF__hdr_free(hdr) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_create() */ +} /* end H5HF__hdr_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_protect * @@ -522,9 +514,9 @@ H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam) 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_cache_ud_t cache_udata; /* User-data for callback */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_hdr_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -539,7 +531,7 @@ H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) cache_udata.f = f; /* Lock the heap header into memory */ - if(NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) + if (NULL == (hdr = (H5HF_hdr_t *)H5AC_protect(f, H5AC_FHEAP_HDR, addr, &cache_udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header") /* Set the header's address */ @@ -555,9 +547,8 @@ H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_protect() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_incr + * Function: H5HF__hdr_incr * * Purpose: Increment component reference count on shared heap header * @@ -569,18 +560,18 @@ H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_incr(H5HF_hdr_t *hdr) +H5HF__hdr_incr(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Mark header as un-evictable when a block is depending on it */ - if(hdr->rc == 0) - if(H5AC_pin_protected_entry(hdr) < 0) + if (hdr->rc == 0) + if (H5AC_pin_protected_entry(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap header") /* Increment reference count on shared header */ @@ -588,11 +579,10 @@ H5HF_hdr_incr(H5HF_hdr_t *hdr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_incr() */ +} /* end H5HF__hdr_incr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_decr + * Function: H5HF__hdr_decr * * Purpose: Decrement component reference count on shared heap header * @@ -604,11 +594,11 @@ H5HF_hdr_incr(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_decr(H5HF_hdr_t *hdr) +H5HF__hdr_decr(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -618,19 +608,18 @@ H5HF_hdr_decr(H5HF_hdr_t *hdr) hdr->rc--; /* Mark header as evictable again when no child blocks depend on it */ - if(hdr->rc == 0) { + if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); - if(H5AC_unpin_entry(hdr) < 0) + if (H5AC_unpin_entry(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap header") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_decr() */ +} /* end H5HF__hdr_decr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_fuse_incr + * Function: H5HF__hdr_fuse_incr * * Purpose: Increment file reference count on shared heap header * @@ -642,9 +631,9 @@ H5HF_hdr_decr(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr) +H5HF__hdr_fuse_incr(H5HF_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -653,11 +642,10 @@ H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr) hdr->file_rc++; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_hdr_fuse_incr() */ +} /* end H5HF__hdr_fuse_incr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_fuse_decr + * Function: H5HF__hdr_fuse_decr * * Purpose: Decrement file reference count on shared heap header * @@ -669,9 +657,9 @@ H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ size_t -H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr) +H5HF__hdr_fuse_decr(H5HF_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -681,11 +669,10 @@ H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr) hdr->file_rc--; FUNC_LEAVE_NOAPI(hdr->file_rc) -} /* end H5HF_hdr_fuse_decr() */ +} /* end H5HF__hdr_fuse_decr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_dirty + * Function: H5HF__hdr_dirty * * Purpose: Mark heap header as dirty * @@ -697,32 +684,30 @@ H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_dirty(H5HF_hdr_t *hdr) +H5HF__hdr_dirty(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Resize pinned header in cache if I/O filter is present. */ - if(hdr->filter_len > 0) { - if(H5AC_resize_entry(hdr, (size_t)hdr->heap_size) < 0) + if (hdr->filter_len > 0) + if (H5AC_resize_entry(hdr, (size_t)hdr->heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap header") - } /* end if */ /* Mark header as dirty in cache */ - if(H5AC_mark_entry_dirty(hdr) < 0) + if (H5AC_mark_entry_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark fractal heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_dirty() */ +} /* end H5HF__hdr_dirty() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_adj_free + * Function: H5HF__hdr_adj_free * * Purpose: Adjust the free space for a heap * @@ -734,11 +719,11 @@ H5HF_hdr_dirty(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) +H5HF__hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -750,16 +735,15 @@ H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + amt); /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_adj_free() */ +} /* end H5HF__hdr_adj_free() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_adjust_heap + * Function: H5HF__hdr_adjust_heap * * Purpose: Adjust heap space * @@ -771,11 +755,11 @@ H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) +H5HF__hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -790,16 +774,15 @@ H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) hdr->total_man_free = (hsize_t)((hssize_t)hdr->total_man_free + extra_free); /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_adjust_heap() */ +} /* end H5HF__hdr_adjust_heap() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_inc_alloc + * Function: H5HF__hdr_inc_alloc * * Purpose: Increase allocated size of heap * @@ -811,9 +794,9 @@ H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) +H5HF__hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -825,11 +808,10 @@ H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) hdr->man_alloc_size += alloc_size; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_hdr_inc_alloc() */ +} /* end H5HF__hdr_inc_alloc() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_start_iter + * Function: H5HF__hdr_start_iter * * Purpose: Start "next block" iterator at an offset/entry in the heap * @@ -841,11 +823,11 @@ H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry) +H5HF__hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -854,7 +836,7 @@ H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, HDassert(iblock); /* Set up "next block" iterator at correct location */ - if(H5HF_man_iter_start_entry(hdr, &hdr->next_block, iblock, curr_entry) < 0) + if (H5HF__man_iter_start_entry(hdr, &hdr->next_block, iblock, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize block iterator") /* Set the offset of the iterator in the heap */ @@ -862,11 +844,10 @@ H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_start_iter() */ +} /* end H5HF__hdr_start_iter() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_reset_iter + * Function: H5HF__hdr_reset_iter * * Purpose: Reset "next block" iterator * @@ -878,11 +859,11 @@ H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) +H5HF__hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -890,7 +871,7 @@ H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) HDassert(hdr); /* Reset "next block" iterator */ - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF__man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Set the offset of the iterator in the heap */ @@ -898,9 +879,8 @@ H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_reset_iter() */ +} /* end H5HF__hdr_reset_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_skip_blocks * @@ -914,12 +894,11 @@ H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off) *------------------------------------------------------------------------- */ herr_t -H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - unsigned start_entry, unsigned nentries) +H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries) { - unsigned row, col; /* Row & column of entry */ - hsize_t sect_size; /* Size of section in heap space */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned row, col; /* Row & column of entry */ + hsize_t sect_size; /* Size of section in heap space */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -931,24 +910,24 @@ H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, HDassert(nentries); /* Compute the span within the heap to skip */ - row = start_entry / hdr->man_dtable.cparam.width; - col = start_entry % hdr->man_dtable.cparam.width; - sect_size = H5HF_dtable_span_size(&hdr->man_dtable, row, col, nentries); + row = start_entry / hdr->man_dtable.cparam.width; + col = start_entry % hdr->man_dtable.cparam.width; + sect_size = H5HF__dtable_span_size(&hdr->man_dtable, row, col, nentries); HDassert(sect_size > 0); /* Advance the new block iterator */ - if(H5HF_hdr_inc_iter(hdr, sect_size, nentries) < 0) + if (H5HF__hdr_inc_iter(hdr, sect_size, nentries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't increase allocated heap size") /* Add 'indirect' section for blocks skipped in this row */ - if(H5HF__sect_indirect_add(hdr, iblock, start_entry, nentries) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section for indirect block's free space") + if (H5HF__sect_indirect_add(hdr, iblock, start_entry, nentries) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't create indirect section for indirect block's free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_skip_blocks() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_update_iter * @@ -967,7 +946,7 @@ H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -978,49 +957,49 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) HDassert(min_dblock_size > 0); /* Check for creating first indirect block */ - if(hdr->man_dtable.curr_root_rows == 0) { - if(H5HF__man_iblock_root_create(hdr, min_dblock_size) < 0) + if (hdr->man_dtable.curr_root_rows == 0) { + if (H5HF__man_iblock_root_create(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to create root indirect block") } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t walked_up, walked_down; /* Condition variables for finding direct block location */ - unsigned next_row; /* Iterator's next block row */ - unsigned next_entry; /* Iterator's next block entry */ - unsigned min_dblock_row; /* Minimum row for direct block size request */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t walked_up, walked_down; /* Condition variables for finding direct block location */ + unsigned next_row; /* Iterator's next block row */ + unsigned next_entry; /* Iterator's next block entry */ + unsigned min_dblock_row; /* Minimum row for direct block size request */ /* Compute min. row for direct block requested */ - min_dblock_row = H5HF_dtable_size_to_row(&hdr->man_dtable, min_dblock_size); + min_dblock_row = H5HF__dtable_size_to_row(&hdr->man_dtable, min_dblock_size); /* Initialize block iterator, if necessary */ - if(!H5HF_man_iter_ready(&hdr->next_block)) { + if (!H5HF__man_iter_ready(&hdr->next_block)) { /* Start iterator with previous offset of iterator */ - if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) + if (H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") } /* end if */ /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") /* Check for skipping over blocks in the current block */ - if(min_dblock_row > next_row && next_row < iblock->nrows) { - unsigned min_entry; /* Min entry for direct block requested */ - unsigned skip_entries; /* Number of entries to skip in the current block */ + if (min_dblock_row > next_row && next_row < iblock->nrows) { + unsigned min_entry; /* Min entry for direct block requested */ + unsigned skip_entries; /* Number of entries to skip in the current block */ /* Compute the number of entries to skip in the current block */ min_entry = min_dblock_row * hdr->man_dtable.cparam.width; - if(min_dblock_row >= iblock->nrows) + if (min_dblock_row >= iblock->nrows) skip_entries = (iblock->nrows * hdr->man_dtable.cparam.width) - next_entry; else skip_entries = min_entry - next_entry; /* Add skipped direct blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, skip_entries) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, skip_entries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") } /* end if */ @@ -1030,25 +1009,27 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check for walking off end of indirect block */ /* (walk up iterator) */ - while(next_row >= iblock->nrows) { + while (next_row >= iblock->nrows) { /* Check for needing to expand root indirect block */ - if(iblock->parent == NULL) { - if(H5HF__man_iblock_root_double(hdr, min_dblock_size) < 0) + if (iblock->parent == NULL) { + if (H5HF__man_iblock_root_double(hdr, min_dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "unable to double root indirect block") } /* end if */ else { /* Move iterator up one level */ - if(H5HF_man_iter_up(&hdr->next_block) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF__man_iter_up(&hdr->next_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Increment location of next block at this level */ - if(H5HF_man_iter_next(hdr, &hdr->next_block, 1) < 0) + if (H5HF__man_iter_next(hdr, &hdr->next_block, 1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't advance fractal heap block location") } /* end else */ /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator location") /* Indicate that we walked up */ walked_up = TRUE; @@ -1056,82 +1037,95 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check for walking into child indirect block */ /* (walk down iterator) */ - if(next_row >= hdr->man_dtable.max_direct_rows) { - unsigned child_nrows; /* Number of rows in new indirect block */ + if (next_row >= hdr->man_dtable.max_direct_rows) { + unsigned child_nrows; /* Number of rows in new indirect block */ HDassert(!H5F_addr_defined(iblock->ents[next_entry].addr)); /* Compute # of rows in next child indirect block to use */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[next_row]); + child_nrows = + H5HF__dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[next_row]); /* Check for skipping over indirect blocks */ /* (that don't have direct blocks large enough to hold direct block size requested) */ - if(hdr->man_dtable.row_block_size[child_nrows - 1] < min_dblock_size) { - unsigned child_rows_needed; /* Number of rows needed to hold direct block */ - unsigned child_entry; /* Entry of child indirect block */ + if (hdr->man_dtable.row_block_size[child_nrows - 1] < min_dblock_size) { + unsigned child_rows_needed; /* Number of rows needed to hold direct block */ + unsigned child_entry; /* Entry of child indirect block */ /* Compute # of rows needed in child indirect block */ - child_rows_needed = (H5VM_log2_of2((uint32_t)min_dblock_size) - H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size)) + 2; + child_rows_needed = (H5VM_log2_of2((uint32_t)min_dblock_size) - + H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size)) + + 2; HDassert(child_rows_needed > child_nrows); - child_entry = (next_row + (child_rows_needed - child_nrows)) * hdr->man_dtable.cparam.width; - if(child_entry > (iblock->nrows * hdr->man_dtable.cparam.width)) + child_entry = + (next_row + (child_rows_needed - child_nrows)) * hdr->man_dtable.cparam.width; + if (child_entry > (iblock->nrows * hdr->man_dtable.cparam.width)) child_entry = iblock->nrows * hdr->man_dtable.cparam.width; /* Add skipped indirect blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (child_entry - next_entry)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (child_entry - next_entry)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't add skipped blocks to heap's free space") } /* end if */ else { - H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - haddr_t new_iblock_addr; /* New indirect block's address */ + H5HF_indirect_t *new_iblock; /* Pointer to new indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + haddr_t new_iblock_addr; /* New indirect block's address */ /* Allocate new indirect block */ - if(H5HF__man_iblock_create(hdr, iblock, next_entry, child_nrows, child_nrows, &new_iblock_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") + if (H5HF__man_iblock_create(hdr, iblock, next_entry, child_nrows, child_nrows, + &new_iblock_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, + "can't allocate fractal heap indirect block") /* Lock new indirect block */ - if(NULL == (new_iblock = H5HF__man_iblock_protect(hdr, new_iblock_addr, child_nrows, iblock, next_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (NULL == (new_iblock = H5HF__man_iblock_protect(hdr, new_iblock_addr, child_nrows, + iblock, next_entry, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") /* Move iterator down one level (pins indirect block) */ - if(H5HF_man_iter_down(&hdr->next_block, new_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF__man_iter_down(&hdr->next_block, new_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Check for skipping over rows and add free section for skipped rows */ - if(min_dblock_size > hdr->man_dtable.cparam.start_block_size) { - unsigned new_entry; /* Entry of direct block which is large enough */ + if (min_dblock_size > hdr->man_dtable.cparam.start_block_size) { + unsigned new_entry; /* Entry of direct block which is large enough */ /* Compute entry for direct block size requested */ new_entry = hdr->man_dtable.cparam.width * min_dblock_row; /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, new_iblock, 0, new_entry) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") + if (H5HF__hdr_skip_blocks(hdr, new_iblock, 0, new_entry) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't add skipped blocks to heap's free space") } /* end if */ /* Unprotect child indirect block */ - if(H5HF__man_iblock_unprotect(new_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(new_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") } /* end else */ /* Get information about new iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator location") /* Indicate that we walked down */ walked_down = TRUE; } /* end if */ - } while(walked_down || walked_up); + } while (walked_down || walked_up); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_update_iter() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_inc_iter + * Function: H5HF__hdr_inc_iter * * Purpose: Advance "next block" iterator * @@ -1143,11 +1137,11 @@ H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) +H5HF__hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1156,8 +1150,8 @@ H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) HDassert(nentries); /* Advance the iterator for the current location within the indirect block */ - if(hdr->next_block.curr) - if(H5HF_man_iter_next(hdr, &hdr->next_block, nentries) < 0) + if (hdr->next_block.curr) + if (H5HF__man_iter_next(hdr, &hdr->next_block, nentries) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") /* Increment the offset of the iterator in the heap */ @@ -1165,9 +1159,8 @@ H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_inc_iter() */ +} /* end H5HF__hdr_inc_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_reverse_iter * @@ -1184,11 +1177,11 @@ H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries) herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) { - H5HF_indirect_t *iblock; /* Indirect block where iterator is located */ - unsigned curr_entry; /* Current entry for iterator */ - hbool_t walked_down; /* Loop flag */ - hbool_t walked_up; /* Loop flag */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Indirect block where iterator is located */ + unsigned curr_entry; /* Current entry for iterator */ + hbool_t walked_down; /* Loop flag */ + hbool_t walked_up; /* Loop flag */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1198,15 +1191,15 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) HDassert(hdr); /* Initialize block iterator, if necessary */ - if(!H5HF_man_iter_ready(&hdr->next_block)) + if (!H5HF__man_iter_ready(&hdr->next_block)) /* Start iterator with previous offset of iterator */ - if(H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) + if (H5HF__man_iter_start_offset(hdr, &hdr->next_block, hdr->man_iter_off) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to set block iterator location") /* Walk backwards through heap, looking for direct block to place iterator after */ /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) + if (H5HF__man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator information") /* Move current iterator position backwards once */ @@ -1214,30 +1207,31 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) /* Search backwards in the heap address space for direct block to latch onto */ do { - int tmp_entry; /* Temp. entry for iterator (use signed value to detect errors) */ + int tmp_entry; /* Temp. entry for iterator (use signed value to detect errors) */ /* Reset loop flags */ walked_down = FALSE; - walked_up = FALSE; + walked_up = FALSE; /* Walk backwards through entries, until we find one that has a child */ /* (Skip direct block that will be deleted, if we find it) */ tmp_entry = (int)curr_entry; - while(tmp_entry >= 0 && - (H5F_addr_eq(iblock->ents[tmp_entry].addr, dblock_addr) || - !H5F_addr_defined(iblock->ents[tmp_entry].addr))) + while (tmp_entry >= 0 && (H5F_addr_eq(iblock->ents[tmp_entry].addr, dblock_addr) || + !H5F_addr_defined(iblock->ents[tmp_entry].addr))) tmp_entry--; /* Check for no earlier blocks in this indirect block */ - if(tmp_entry < 0) { + if (tmp_entry < 0) { /* Check for parent of current indirect block */ - if(iblock->parent) { + if (iblock->parent) { /* Move iterator to parent of current block */ - if(H5HF_man_iter_up(&hdr->next_block) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to move current block iterator location up") + if (H5HF__man_iter_up(&hdr->next_block) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to move current block iterator location up") /* Get information about current iterator location */ - if(H5HF_man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator information") + if (H5HF__man_iter_curr(&hdr->next_block, NULL, NULL, &curr_entry, &iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve current block iterator information") /* Move current iterator position backwards once */ curr_entry--; @@ -1250,69 +1244,76 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) hdr->man_iter_off = 0; /* Reset 'next block' iterator */ - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF__man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") } /* end else */ - } /* end if */ + } /* end if */ else { - unsigned row; /* Row for entry */ + unsigned row; /* Row for entry */ curr_entry = (unsigned)tmp_entry; /* Check if entry is for a direct block */ row = curr_entry / hdr->man_dtable.cparam.width; - if(row < hdr->man_dtable.max_direct_rows) { + if (row < hdr->man_dtable.max_direct_rows) { /* Increment entry to empty location */ curr_entry++; /* Set the current location of the iterator to next entry after the existing direct block */ - if(H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) + if (H5HF__man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "unable to set current block iterator location") /* Update iterator offset */ hdr->man_iter_off = iblock->block_off; hdr->man_iter_off += hdr->man_dtable.row_block_off[curr_entry / hdr->man_dtable.cparam.width]; - hdr->man_iter_off += hdr->man_dtable.row_block_size[curr_entry / hdr->man_dtable.cparam.width] * (curr_entry % hdr->man_dtable.cparam.width); + hdr->man_iter_off += + hdr->man_dtable.row_block_size[curr_entry / hdr->man_dtable.cparam.width] * + (curr_entry % hdr->man_dtable.cparam.width); } /* end if */ else { - H5HF_indirect_t *child_iblock; /* Pointer to child indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned child_nrows; /* # of rows in child block */ + H5HF_indirect_t *child_iblock; /* Pointer to child indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned child_nrows; /* # of rows in child block */ /* Compute # of rows in next child indirect block to use */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[row]); + child_nrows = + H5HF__dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[row]); /* Lock child indirect block */ - if(NULL == (child_iblock = H5HF__man_iblock_protect(hdr, iblock->ents[curr_entry].addr, child_nrows, iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (NULL == (child_iblock = H5HF__man_iblock_protect(hdr, iblock->ents[curr_entry].addr, + child_nrows, iblock, curr_entry, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") /* Set the current location of the iterator */ - if(H5HF_man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) + if (H5HF__man_iter_set_entry(hdr, &hdr->next_block, curr_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "unable to set current block iterator location") /* Walk down into child indirect block (pins child block) */ - if(H5HF_man_iter_down(&hdr->next_block, child_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, "unable to advance current block iterator location") + if (H5HF__man_iter_down(&hdr->next_block, child_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTNEXT, FAIL, + "unable to advance current block iterator location") /* Update iterator location */ - iblock = child_iblock; + iblock = child_iblock; curr_entry = (child_iblock->nrows * hdr->man_dtable.cparam.width) - 1; /* Unprotect child indirect block */ - if(H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") /* Note that we walked down */ walked_down = TRUE; } /* end else */ - } /* end else */ - } while(walked_down || walked_up); + } /* end else */ + } while (walked_down || walked_up); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_reverse_iter() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_empty * @@ -1328,7 +1329,7 @@ H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr) herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1336,18 +1337,17 @@ H5HF__hdr_empty(H5HF_hdr_t *hdr) HDassert(hdr); /* Reset block iterator, if necessary */ - if(H5HF_man_iter_ready(&hdr->next_block)) { - if(H5HF_man_iter_reset(&hdr->next_block) < 0) + if (H5HF__man_iter_ready(&hdr->next_block)) + if (H5HF__man_iter_reset(&hdr->next_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") - } /* end if */ /* Shrink managed heap size */ - hdr->man_size = 0; + hdr->man_size = 0; hdr->man_alloc_size = 0; /* Reset root pointer information */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = HADDR_UNDEF; + hdr->man_dtable.table_addr = HADDR_UNDEF; /* Reset the 'next block' iterator location */ hdr->man_iter_off = 0; @@ -1356,16 +1356,15 @@ H5HF__hdr_empty(H5HF_hdr_t *hdr) hdr->total_man_free = 0; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_empty() */ - /*------------------------------------------------------------------------- - * Function: H5HF_hdr_free + * Function: H5HF__hdr_free * * Purpose: Free shared fractal heap header * @@ -1377,11 +1376,11 @@ H5HF__hdr_empty(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_hdr_free(H5HF_hdr_t *hdr) +H5HF__hdr_free(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1389,12 +1388,12 @@ H5HF_hdr_free(H5HF_hdr_t *hdr) HDassert(hdr); /* Free the block size lookup table for the doubling table */ - if(H5HF_dtable_dest(&hdr->man_dtable) < 0) + if (H5HF__dtable_dest(&hdr->man_dtable) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap doubling table") /* Release any I/O pipeline filter information */ - if(hdr->pline.nused) - if(H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0) + if (hdr->pline.nused) + if (H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to reset I/O pipeline message") /* Free the shared info itself */ @@ -1402,9 +1401,8 @@ H5HF_hdr_free(H5HF_hdr_t *hdr) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_hdr_free() */ +} /* end H5HF__hdr_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__hdr_delete * @@ -1420,8 +1418,8 @@ H5HF_hdr_free(H5HF_hdr_t *hdr) herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1432,61 +1430,64 @@ H5HF__hdr_delete(H5HF_hdr_t *hdr) HDassert(!hdr->file_rc); #ifndef NDEBUG -{ - unsigned hdr_status = 0; /* Heap header's status in the metadata cache */ + { + unsigned hdr_status = 0; /* Heap header's status in the metadata cache */ - /* Check the heap header's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, hdr->heap_addr, &hdr_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for heap header") + /* Check the heap header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->heap_addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for heap header") - /* Sanity checks on heap header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); -} /* end block */ + /* Sanity checks on heap header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); + } /* end block */ #endif /* NDEBUG */ /* Check for free space manager for heap */ /* (must occur before attempting to delete the heap, so indirect blocks * will get unpinned) */ - if(H5F_addr_defined(hdr->fs_addr)) + if (H5F_addr_defined(hdr->fs_addr)) /* Delete free space manager for heap */ - if(H5HF__space_delete(hdr) < 0) + if (H5HF__space_delete(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap free space manager") /* Check for root direct/indirect block */ - if(H5F_addr_defined(hdr->man_dtable.table_addr)) { - if(hdr->man_dtable.curr_root_rows == 0) { - hsize_t dblock_size; /* Size of direct block on disk */ + if (H5F_addr_defined(hdr->man_dtable.table_addr)) { + if (hdr->man_dtable.curr_root_rows == 0) { + hsize_t dblock_size; /* Size of direct block on disk */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the dblock's size */ dblock_size = hdr->pline_root_direct_size; /* Reset the header's pipeline information */ - hdr->pline_root_direct_size = 0; + hdr->pline_root_direct_size = 0; hdr->pline_root_direct_filter_mask = 0; } /* end if */ else dblock_size = hdr->man_dtable.cparam.start_block_size; /* Delete root direct block */ - if(H5HF__man_dblock_delete(hdr->f, hdr->man_dtable.table_addr, dblock_size) < 0) + if (H5HF__man_dblock_delete(hdr->f, hdr->man_dtable.table_addr, dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root direct block") } /* end if */ else { /* Delete root indirect block */ - if(H5HF__man_iblock_delete(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap root indirect block") + if (H5HF__man_iblock_delete(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, + 0) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap root indirect block") } /* end else */ - } /* end if */ + } /* end if */ /* Check for 'huge' objects in heap */ - if(H5F_addr_defined(hdr->huge_bt2_addr)) { + if (H5F_addr_defined(hdr->huge_bt2_addr)) { /* Delete huge objects in heap and their tracker */ - if(H5HF__huge_delete(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap 'huge' objects and tracker") + if (H5HF__huge_delete(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap 'huge' objects and tracker") } /* end if */ /* Indicate that the heap header should be deleted & file space freed */ @@ -1494,9 +1495,8 @@ H5HF__hdr_delete(H5HF_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_delete() */ - diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 0414fc08d5e..b1043a6c1a3 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,39 +26,34 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* v2 B-tree creation macros */ -#define H5HF_HUGE_BT2_NODE_SIZE 512 -#define H5HF_HUGE_BT2_SPLIT_PERC 100 -#define H5HF_HUGE_BT2_MERGE_PERC 40 - +#define H5HF_HUGE_BT2_NODE_SIZE 512 +#define H5HF_HUGE_BT2_SPLIT_PERC 100 +#define H5HF_HUGE_BT2_MERGE_PERC 40 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -68,25 +63,21 @@ static herr_t H5HF__huge_bt2_create(H5HF_hdr_t *hdr); /* Local 'huge' object support routines */ static hsize_t H5HF__huge_new_id(H5HF_hdr_t *hdr); -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); - +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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_create * @@ -102,8 +93,8 @@ static herr_t H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, static herr_t H5HF__huge_bt2_create(H5HF_hdr_t *hdr) { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -119,55 +110,57 @@ H5HF__huge_bt2_create(H5HF_hdr_t *hdr) * difficult to write. "Waste" an extra byte or for small heaps (where * the 'huge_id_size' is < 'sizeof_size' in order to make this easier -QAK) */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + bt2_cparam.rrec_size = + (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size); /* Length of object */ - bt2_cparam.cls = H5HF_HUGE_BT2_DIR; + bt2_cparam.rrec_size = (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size); /* Length of object */ + bt2_cparam.cls = H5HF_HUGE_BT2_DIR; } /* end else */ - } /* end if */ + } /* end if */ else { - if(hdr->filter_len > 0) { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ - + (unsigned)hdr->sizeof_size /* Length of filtered object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + if (hdr->filter_len > 0) { + bt2_cparam.rrec_size = + (uint32_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ + + (unsigned)hdr->sizeof_size /* Length of filtered object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ - bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; + bt2_cparam.rrec_size = (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; } /* end else */ - } /* end else */ - bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; + } /* end else */ + bt2_cparam.node_size = (size_t)H5HF_HUGE_BT2_NODE_SIZE; bt2_cparam.split_percent = H5HF_HUGE_BT2_SPLIT_PERC; bt2_cparam.merge_percent = H5HF_HUGE_BT2_MERGE_PERC; /* Create v2 B-tree for tracking 'huge' objects */ - if(NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, &bt2_cparam, hdr->f))) + if (NULL == (hdr->huge_bt2 = H5B2_create(hdr->f, &bt2_cparam, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get v2 B-tree address for tracking 'huge' heap objects") + if (H5B2_get_addr(hdr->huge_bt2, &hdr->huge_bt2_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "can't get v2 B-tree address for tracking 'huge' heap objects") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_bt2_create() */ - /*------------------------------------------------------------------------- - * Function: H5HF_huge_init + * Function: H5HF__huge_init * * Purpose: Initialize information for tracking 'huge' objects * @@ -179,9 +172,9 @@ H5HF__huge_bt2_create(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_huge_init(H5HF_hdr_t *hdr) +H5HF__huge_init(H5HF_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -194,8 +187,8 @@ H5HF_huge_init(H5HF_hdr_t *hdr) * the file in the heap ID (which will speed up accessing it) and we don't * have any I/O pipeline filters. */ - if(hdr->filter_len > 0) { - if((hdr->id_len - 1) >= (unsigned)(hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { + if (hdr->filter_len > 0) { + if ((hdr->id_len - 1) >= (unsigned)(hdr->sizeof_addr + hdr->sizeof_size + 4 + hdr->sizeof_size)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; @@ -207,7 +200,7 @@ H5HF_huge_init(H5HF_hdr_t *hdr) hdr->huge_ids_direct = FALSE; } /* end if */ else { - if((hdr->sizeof_addr + hdr->sizeof_size) <= (hdr->id_len - 1)) { + if ((hdr->sizeof_addr + hdr->sizeof_size) <= (hdr->id_len - 1)) { /* Indicate that v2 B-tree doesn't have to be used to locate object */ hdr->huge_ids_direct = TRUE; @@ -218,23 +211,22 @@ H5HF_huge_init(H5HF_hdr_t *hdr) /* Indicate that v2 B-tree must be used to locate object */ hdr->huge_ids_direct = FALSE; } /* end else */ - if(!hdr->huge_ids_direct) { + if (!hdr->huge_ids_direct) { /* Set the size and maximum value of 'huge' object ID */ - if((hdr->id_len - 1) < sizeof(hsize_t)) { + if ((hdr->id_len - 1) < sizeof(hsize_t)) { hdr->huge_id_size = (uint8_t)(hdr->id_len - 1); - hdr->huge_max_id = ((hsize_t)1 << (hdr->huge_id_size * 8)) - 1; + hdr->huge_max_id = ((hsize_t)1 << (hdr->huge_id_size * 8)) - 1; } /*end if */ else { hdr->huge_id_size = sizeof(hsize_t); - hdr->huge_max_id = HSIZET_MAX; + hdr->huge_max_id = HSIZET_MAX; } /* end else */ - } /* end if */ + } /* end if */ hdr->huge_bt2 = NULL; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_huge_init() */ +} /* end H5HF__huge_init() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_new_id * @@ -251,8 +243,8 @@ H5HF_huge_init(H5HF_hdr_t *hdr) static hsize_t H5HF__huge_new_id(H5HF_hdr_t *hdr) { - hsize_t new_id; /* New object's ID */ - hsize_t ret_value = 0; /* Return value */ + hsize_t new_id; /* New object's ID */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC @@ -262,7 +254,7 @@ H5HF__huge_new_id(H5HF_hdr_t *hdr) HDassert(hdr); /* Check for wrapping around 'huge' object ID space */ - if(hdr->huge_ids_wrapped) + if (hdr->huge_ids_wrapped) /* Fail for now - eventually should iterate through v2 B-tree, looking for available ID */ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, 0, "wrapping 'huge' object IDs not supported yet") else { @@ -271,7 +263,7 @@ H5HF__huge_new_id(H5HF_hdr_t *hdr) new_id = ++hdr->huge_next_id; /* Check for wrapping 'huge' object IDs around */ - if(hdr->huge_next_id == hdr->huge_max_id) + if (hdr->huge_next_id == hdr->huge_max_id) hdr->huge_ids_wrapped = TRUE; } /* end else */ @@ -282,7 +274,6 @@ H5HF__huge_new_id(H5HF_hdr_t *hdr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_new_id() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_insert * @@ -298,12 +289,12 @@ H5HF__huge_new_id(H5HF_hdr_t *hdr) herr_t 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -316,78 +307,81 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) HDassert(id); /* Check if the v2 B-tree for tracking 'huge' heap objects has been created yet */ - if(!H5F_addr_defined(hdr->huge_bt2_addr)) { + if (!H5F_addr_defined(hdr->huge_bt2_addr)) { /* Go create (& open) v2 B-tree */ - if(H5HF__huge_bt2_create(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create v2 B-tree for tracking 'huge' heap objects") + if (H5HF__huge_bt2_create(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, + "can't create v2 B-tree for tracking 'huge' heap objects") } /* end if */ else { /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - } /* end else */ + } /* end else */ HDassert(hdr->huge_bt2); /* Check for I/O pipeline filter on heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t nbytes; /* Number of bytes used */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t nbytes; /* Number of bytes used */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* Allocate buffer to perform I/O filtering on */ write_size = obj_size; - if(NULL == (write_buf = H5MM_malloc(write_size))) + if (NULL == (write_buf = H5MM_malloc(write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") H5MM_memcpy(write_buf, obj, write_size); /* Push direct block data through I/O filter pipeline */ nbytes = write_size; - if(H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_NO_EDC, - filter_cb, &nbytes, &write_size, &write_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &write_size, + &write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed") /* Update size of object on disk */ write_size = nbytes; } /* end if */ else { - write_buf = obj; + write_buf = obj; write_size = obj_size; } /* end else */ /* Allocate space in the file for storing the 'huge' object */ - if(HADDR_UNDEF == (obj_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, (hsize_t)write_size))) + if (HADDR_UNDEF == (obj_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, (hsize_t)write_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap huge object") /* Write the object's data to disk */ - if(H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, write_size, write_buf) < 0) + if (H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, write_size, write_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "writing 'huge' object to file failed") /* Release buffer for writing, if we had one */ - if(write_buf != obj) { + if (write_buf != obj) { HDassert(hdr->filter_len > 0); H5MM_xfree(write_buf); } /* end if */ /* Perform different actions for directly & indirectly accessed 'huge' objects */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_dir_rec_t obj_rec; /* Record for tracking object */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_dir_rec_t obj_rec; /* Record for tracking object */ /* Initialize record for tracking object in v2 B-tree */ - obj_rec.addr = obj_addr; - obj_rec.len = write_size; + obj_rec.addr = obj_addr; + obj_rec.len = write_size; obj_rec.filter_mask = filter_mask; - obj_rec.obj_size = obj_size; + obj_rec.obj_size = obj_size; /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") + if (H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, + "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; @@ -397,39 +391,40 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)obj_size); } /* end if */ else { - H5HF_huge_bt2_dir_rec_t obj_rec; /* Record for tracking object */ + H5HF_huge_bt2_dir_rec_t obj_rec; /* Record for tracking object */ /* Initialize record for tracking object in v2 B-tree */ obj_rec.addr = obj_addr; - obj_rec.len = write_size; + obj_rec.len = write_size; /* Insert record for object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") + if (H5B2_insert(hdr->huge_bt2, &obj_rec) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, + "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; H5F_addr_encode(hdr->f, &id, obj_addr); H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)write_size); } /* end if */ - } /* end if */ + } /* end if */ 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 */ - hsize_t new_id; /* New ID for object */ + 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 */ + hsize_t new_id; /* New ID for object */ /* Get new ID for object */ - if(0 == (new_id = H5HF__huge_new_id(hdr))) + if (0 == (new_id = H5HF__huge_new_id(hdr))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't generate new ID for object") - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Initialize record for object in v2 B-tree */ - filt_indir_rec.addr = obj_addr; - filt_indir_rec.len = write_size; + filt_indir_rec.addr = obj_addr; + filt_indir_rec.len = write_size; filt_indir_rec.filter_mask = filter_mask; - filt_indir_rec.obj_size = obj_size; - filt_indir_rec.id = new_id; + filt_indir_rec.obj_size = obj_size; + filt_indir_rec.id = new_id; /* Set pointer to record to insert */ ins_rec = &filt_indir_rec; @@ -437,15 +432,15 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) else { /* Initialize record for object in v2 B-tree */ indir_rec.addr = obj_addr; - indir_rec.len = write_size; - indir_rec.id = new_id; + indir_rec.len = write_size; + indir_rec.id = new_id; /* Set pointer to record to insert */ ins_rec = &indir_rec; } /* end else */ /* Insert record for tracking object in v2 B-tree */ - if(H5B2_insert(hdr->huge_bt2, ins_rec) < 0) + if (H5B2_insert(hdr->huge_bt2, ins_rec) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "couldn't insert object tracking record in v2 B-tree") /* Encode ID for user */ @@ -458,14 +453,13 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) hdr->huge_nobjs++; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_insert() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_get_obj_len * @@ -481,7 +475,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -497,8 +491,8 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) id++; /* Check if 'huge' object ID encodes address & length directly */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { /* Skip over filtered object info */ id += hdr->sizeof_addr + hdr->sizeof_size + 4; @@ -512,16 +506,17 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) /* Retrieve the object's length */ H5F_DECODE_LENGTH(hdr->f, id, *obj_len_p); } /* end else */ - } /* end if */ + } /* end if */ else { /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -529,7 +524,7 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ @@ -543,19 +538,18 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's length */ *obj_len_p = (size_t)found_rec.len; } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_get_obj_off * @@ -571,8 +565,8 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) { - haddr_t obj_addr; /* Object's address in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t obj_addr; /* Object's address in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -588,7 +582,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) id++; /* Check if 'huge' object ID encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); } /* end if */ @@ -597,13 +591,14 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -611,7 +606,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -625,13 +620,13 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ obj_addr = found_rec.addr; } /* end else */ - } /* end else */ + } /* end else */ /* Set the value to return */ *obj_off_p = (hsize_t)obj_addr; @@ -640,7 +635,6 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_op_real * @@ -654,14 +648,13 @@ 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) +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 */ - 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) */ - herr_t ret_value = SUCCEED; /* Return value */ + 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) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -676,13 +669,13 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, id++; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); /* Retrieve extra information needed for filtered objects */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) UINT32DECODE(id, filter_mask); } /* end if */ else { @@ -690,13 +683,14 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ @@ -704,7 +698,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -720,18 +714,18 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ obj_addr = found_rec.addr; H5_CHECKED_ASSIGN(obj_size, size_t, found_rec.len, hsize_t); } /* end else */ - } /* end else */ + } /* end else */ /* Set up buffer for reading */ - if(hdr->filter_len > 0 || !is_read) { - if(NULL == (read_buf = H5MM_malloc((size_t)obj_size))) + if (hdr->filter_len > 0 || !is_read) { + if (NULL == (read_buf = H5MM_malloc((size_t)obj_size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer") } /* end if */ else @@ -739,53 +733,53 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, /* Read the object's (possibly filtered) data from the file */ /* (reads directly into application's buffer if no filters are present) */ - if(H5F_block_read(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, (size_t)obj_size, read_buf) < 0) + if (H5F_block_read(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, (size_t)obj_size, read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, FAIL, "can't read 'huge' object's data from the file") /* Check for I/O pipeline filter on heap */ - if(hdr->filter_len > 0) { - H5Z_cb_t filter_cb; /* Filter callback structure */ - size_t read_size; /* Object's size in the file */ - size_t nbytes; /* Number of bytes used */ + if (hdr->filter_len > 0) { + H5Z_cb_t filter_cb; /* Filter callback structure */ + size_t read_size; /* Object's size in the file */ + size_t nbytes; /* Number of bytes used */ /* Initialize the filter callback struct */ filter_cb.op_data = NULL; - filter_cb.func = NULL; /* no callback function when failed */ + filter_cb.func = NULL; /* no callback function when failed */ /* De-filter the object */ read_size = nbytes = obj_size; - if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &read_buf) < 0) + if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, + &read_size, &read_buf) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "input filter failed") obj_size = nbytes; } /* end if */ /* Perform correct operation on buffer read in */ - if(is_read) { + if (is_read) { /* Copy object to user's buffer if there's filters on heap data */ /* (if there's no filters, the object was read directly into the user's buffer) */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) H5MM_memcpy(op_data, read_buf, (size_t)obj_size); } /* end if */ else { /* Call the user's 'op' callback */ - if(op(read_buf, (size_t)obj_size, op_data) < 0) { + if (op(read_buf, (size_t)obj_size, op_data) < 0) { /* Release buffer */ read_buf = H5MM_xfree(read_buf); /* Indicate error */ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the buffer for reading */ - if(read_buf && read_buf != op_data) + if (read_buf && read_buf != op_data) read_buf = H5MM_xfree(read_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_op_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_write * @@ -806,9 +800,9 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) { - haddr_t obj_addr; /* Object's address in the file */ - size_t obj_size; /* Object's size in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t obj_addr; /* Object's address in the file */ + size_t obj_size; /* Object's size in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -820,14 +814,14 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) HDassert(obj); /* Check for filters on the heap */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "modifying 'huge' object with filters not supported yet") /* Skip over the flag byte */ id++; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { + if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); @@ -840,17 +834,18 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) + if (H5B2_find(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_found, &found_rec) != TRUE) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") /* Retrieve the object's address & length */ @@ -860,14 +855,13 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Write the object's data to the file */ /* (writes directly from application's buffer) */ - if(H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, obj_size, obj) < 0) + if (H5F_block_write(hdr->f, H5FD_MEM_FHEAP_HUGE_OBJ, obj_addr, obj_size, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "writing 'huge' object to file failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_write() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_read * @@ -883,7 +877,7 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) herr_t H5HF__huge_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -895,14 +889,13 @@ H5HF__huge_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine */ - if(H5HF__huge_op_real(hdr, id, TRUE, NULL, obj) < 0) + if (H5HF__huge_op_real(hdr, id, TRUE, NULL, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_read() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_op * @@ -916,10 +909,9 @@ H5HF__huge_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) *------------------------------------------------------------------------- */ herr_t -H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -931,14 +923,13 @@ H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF__huge_op_real(hdr, id, FALSE, op, op_data) < 0) + if (H5HF__huge_op_real(hdr, id, FALSE, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_op() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_remove * @@ -954,8 +945,8 @@ H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, herr_t H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -967,10 +958,11 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) HDassert(id); /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { + if (NULL == hdr->huge_bt2) { /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") + if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' heap objects") } /* end if */ /* Skip over the flag byte */ @@ -980,9 +972,9 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) udata.hdr = hdr; /* Check for 'huge' object ID that encodes address & length directly */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_dir_rec_t search_rec; /* Record for searching for object */ + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_dir_rec_t search_rec; /* Record for searching for object */ /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ @@ -991,11 +983,11 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_dir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { - H5HF_huge_bt2_dir_rec_t search_rec; /* Record for searching for object */ + H5HF_huge_bt2_dir_rec_t search_rec; /* Record for searching for object */ /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ @@ -1004,48 +996,47 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_dir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_dir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ - } /* end if */ + } /* end if */ else { - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ + if (hdr->filter_len > 0) { + H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_filt_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end if */ else { - H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ + H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ - if(H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_remove, &udata) < 0) + if (H5B2_remove(hdr->huge_bt2, &search_rec, H5HF__huge_bt2_indir_remove, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from B-tree") } /* end else */ - } /* end else */ + } /* end else */ /* Update statistics about heap */ hdr->huge_size -= udata.obj_len; hdr->huge_nobjs--; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_term * @@ -1061,7 +1052,7 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) herr_t H5HF__huge_term(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1071,12 +1062,12 @@ H5HF__huge_term(H5HF_hdr_t *hdr) HDassert(hdr); /* Check if v2 B-tree index is open */ - if(hdr->huge_bt2) { + if (hdr->huge_bt2) { /* Sanity check */ HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); /* Close v2 B-tree index */ - if(H5B2_close(hdr->huge_bt2) < 0) + if (H5B2_close(hdr->huge_bt2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree") hdr->huge_bt2 = NULL; } /* end if */ @@ -1084,22 +1075,22 @@ H5HF__huge_term(H5HF_hdr_t *hdr) /* Check if there are no more 'huge' objects in the heap and delete the * v2 B-tree that tracks them, if so */ - if(H5F_addr_defined(hdr->huge_bt2_addr) && hdr->huge_nobjs == 0) { + if (H5F_addr_defined(hdr->huge_bt2_addr) && hdr->huge_nobjs == 0) { /* Sanity check */ HDassert(hdr->huge_size == 0); /* Delete the v2 B-tree */ /* (any v2 B-tree class will work here) */ - if(H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) + if (H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, NULL, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") /* Reset the information about 'huge' objects in the file */ - hdr->huge_bt2_addr = HADDR_UNDEF; - hdr->huge_next_id = 0; + hdr->huge_bt2_addr = HADDR_UNDEF; + hdr->huge_next_id = 0; hdr->huge_ids_wrapped = FALSE; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") } /* end if */ @@ -1107,7 +1098,6 @@ H5HF__huge_term(H5HF_hdr_t *hdr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_term() */ - /*------------------------------------------------------------------------- * Function: H5HF__huge_delete * @@ -1124,9 +1114,9 @@ H5HF__huge_term(H5HF_hdr_t *hdr) herr_t H5HF__huge_delete(H5HF_hdr_t *hdr) { - H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ - H5B2_remove_t op; /* Callback for v2 B-tree removal */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_huge_remove_ud_t udata; /* User callback data for v2 B-tree remove call */ + H5B2_remove_t op; /* Callback for v2 B-tree removal */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1142,24 +1132,23 @@ H5HF__huge_delete(H5HF_hdr_t *hdr) udata.hdr = hdr; /* Set the v2 B-tree callback operator */ - if(hdr->huge_ids_direct) { - if(hdr->filter_len > 0) + if (hdr->huge_ids_direct) { + if (hdr->filter_len > 0) op = H5HF__huge_bt2_filt_dir_remove; else op = H5HF__huge_bt2_dir_remove; } /* end if */ else { - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) op = H5HF__huge_bt2_filt_indir_remove; else op = H5HF__huge_bt2_indir_remove; } /* end else */ /* Delete the v2 B-tree */ - if(H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) + if (H5B2_delete(hdr->f, hdr->huge_bt2_addr, hdr->f, op, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete v2 B-tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__huge_delete() */ - diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 160c1eb0656..9b69ec116f1 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,34 +26,30 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -62,7 +58,6 @@ static herr_t H5HF__iblock_unpin(H5HF_indirect_t *iblock); static herr_t H5HF__man_iblock_root_halve(H5HF_indirect_t *root_iblock); static herr_t H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock); - /*********************/ /* Package Variables */ /*********************/ @@ -79,18 +74,14 @@ H5FL_SEQ_DEFINE(H5HF_indirect_filt_ent_t); /* Declare a free list to manage the H5HF_indirect_t * sequence information */ H5FL_SEQ_DEFINE(H5HF_indirect_ptr_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__iblock_pin * @@ -106,7 +97,7 @@ H5FL_SEQ_DEFINE(H5HF_indirect_ptr_t); static herr_t H5HF__iblock_pin(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -114,22 +105,22 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) HDassert(iblock); /* Mark block as un-evictable */ - if(H5AC_pin_protected_entry(iblock) < 0) + if (H5AC_pin_protected_entry(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap indirect block") /* If this indirect block has a parent, update it's child iblock pointer */ - if(iblock->parent) { - H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (iblock->parent) { + H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* Set pointer to pinned indirect block in parent */ HDassert(par_iblock->child_iblocks[indir_idx] == NULL); @@ -137,12 +128,12 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) } /* end if */ else { /* Check for pinning the root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively pinning root indirect block */ HDassert(0 == (iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED)); /* Check if we should set the root iblock pointer */ - if(0 == iblock->hdr->root_iblock_flags) { + if (0 == iblock->hdr->root_iblock_flags) { HDassert(NULL == iblock->hdr->root_iblock); iblock->hdr->root_iblock = iblock; } /* end if */ @@ -150,13 +141,12 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) /* Indicate that the root indirect block is pinned */ iblock->hdr->root_iblock_flags |= H5HF_ROOT_IBLOCK_PINNED; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_pin() */ - /*------------------------------------------------------------------------- * Function: H5HF__iblock_unpin * @@ -172,7 +162,7 @@ H5HF__iblock_pin(H5HF_indirect_t *iblock) static herr_t H5HF__iblock_unpin(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -180,16 +170,15 @@ H5HF__iblock_unpin(H5HF_indirect_t *iblock) HDassert(iblock); /* Mark block as evictable again */ - if(H5AC_unpin_entry(iblock) < 0) + if (H5AC_unpin_entry(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap indirect block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_unpin() */ - /*------------------------------------------------------------------------- - * Function: H5HF_iblock_incr + * Function: H5HF__iblock_incr * * Purpose: Increment reference count on shared indirect block * @@ -201,19 +190,19 @@ H5HF__iblock_unpin(H5HF_indirect_t *iblock) *------------------------------------------------------------------------- */ herr_t -H5HF_iblock_incr(H5HF_indirect_t *iblock) +H5HF__iblock_incr(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(iblock); HDassert(iblock->block_off == 0 || iblock->parent); /* Mark block as un-evictable when a child block is depending on it */ - if(iblock->rc == 0) - if(H5HF__iblock_pin(iblock) < 0) + if (iblock->rc == 0) + if (H5HF__iblock_pin(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin fractal heap indirect block") /* Increment reference count on shared indirect block */ @@ -221,9 +210,8 @@ H5HF_iblock_incr(H5HF_indirect_t *iblock) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_iblock_incr() */ +} /* end H5HF__iblock_incr() */ - /*------------------------------------------------------------------------- * Function: H5HF__iblock_decr * @@ -239,7 +227,7 @@ H5HF_iblock_incr(H5HF_indirect_t *iblock) herr_t H5HF__iblock_decr(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -250,21 +238,21 @@ H5HF__iblock_decr(H5HF_indirect_t *iblock) iblock->rc--; /* Check for last reference to block */ - if(iblock->rc == 0) { + if (iblock->rc == 0) { /* If this indirect block has a parent, reset it's child iblock pointer */ - if(iblock->parent) { - H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (iblock->parent) { + H5HF_indirect_t *par_iblock = iblock->parent; /* Parent indirect block */ + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(iblock->par_entry >= (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width)); + HDassert(iblock->par_entry >= + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = iblock->par_entry - (iblock->hdr->man_dtable.max_direct_rows - * iblock->hdr->man_dtable.cparam.width); + indir_idx = iblock->par_entry - + (iblock->hdr->man_dtable.max_direct_rows * iblock->hdr->man_dtable.cparam.width); /* Reset pointer to pinned child indirect block in parent */ HDassert(par_iblock->child_iblocks[indir_idx]); @@ -272,41 +260,40 @@ H5HF__iblock_decr(H5HF_indirect_t *iblock) } /* end if */ else { /* Check for root indirect block */ - if(iblock->block_off == 0) { - /* Sanity check - shouldn't be recursively unpinning root indirect block */ - HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED); + if (iblock->block_off == 0) { + /* Sanity check - shouldn't be recursively unpinning root indirect block */ + HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PINNED); + + /* Check if we should reset the root iblock pointer */ + if (H5HF_ROOT_IBLOCK_PINNED == iblock->hdr->root_iblock_flags) { + HDassert(NULL != iblock->hdr->root_iblock); + iblock->hdr->root_iblock = NULL; + } /* end if */ - /* Check if we should reset the root iblock pointer */ - if(H5HF_ROOT_IBLOCK_PINNED == iblock->hdr->root_iblock_flags) { - HDassert(NULL != iblock->hdr->root_iblock); - iblock->hdr->root_iblock = NULL; + /* Indicate that the root indirect block is unpinned */ + iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PINNED)); } /* end if */ - - /* Indicate that the root indirect block is unpinned */ - iblock->hdr->root_iblock_flags &= (unsigned)(~(H5HF_ROOT_IBLOCK_PINNED)); - } /* end if */ - } /* end else */ + } /* end else */ /* Check if the block is still in the cache */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Unpin the indirect block, making it evictable again */ - if(H5HF__iblock_unpin(iblock) < 0) + if (H5HF__iblock_unpin(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin fractal heap indirect block") } /* end if */ else { /* Destroy the indirect block */ - if(H5HF_man_iblock_dest(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") + if (H5HF__man_iblock_dest(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__iblock_decr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_iblock_dirty + * Function: H5HF__iblock_dirty * * Purpose: Mark indirect block as dirty * @@ -318,24 +305,23 @@ H5HF__iblock_decr(H5HF_indirect_t *iblock) *------------------------------------------------------------------------- */ herr_t -H5HF_iblock_dirty(H5HF_indirect_t *iblock) +H5HF__iblock_dirty(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); /* Mark indirect block as dirty in cache */ - if(H5AC_mark_entry_dirty(iblock) < 0) + if (H5AC_mark_entry_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark fractal heap indirect block as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_iblock_dirty() */ +} /* end H5HF__iblock_dirty() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_create * @@ -351,19 +337,19 @@ H5HF_iblock_dirty(H5HF_indirect_t *iblock) herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size) { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - haddr_t iblock_addr; /* Indirect block's address */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hbool_t have_direct_block; /* Flag to indicate a direct block already exists */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned nrows; /* Number of rows for root indirect block */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + haddr_t iblock_addr; /* Indirect block's address */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hbool_t have_direct_block; /* Flag to indicate a direct block already exists */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned nrows; /* Number of rows for root indirect block */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Check for allocating entire root indirect block initially */ - if(hdr->man_dtable.cparam.start_root_rows == 0) + if (hdr->man_dtable.cparam.start_root_rows == 0) nrows = hdr->man_dtable.max_root_rows; else { unsigned rows_needed; /* Number of rows needed to get to direct block size */ @@ -371,113 +357,121 @@ H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size) nrows = hdr->man_dtable.cparam.start_root_rows; - block_row_off = H5VM_log2_of2((uint32_t)min_dblock_size) - H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size); - if(block_row_off > 0) - block_row_off++; /* Account for the pair of initial rows of the initial block size */ + block_row_off = H5VM_log2_of2((uint32_t)min_dblock_size) - + H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size); + if (block_row_off > 0) + block_row_off++; /* Account for the pair of initial rows of the initial block size */ rows_needed = 1 + block_row_off; - if(nrows < rows_needed) + if (nrows < rows_needed) nrows = rows_needed; } /* end else */ /* Allocate root indirect block */ - if(H5HF__man_iblock_create(hdr, NULL, 0, nrows, hdr->man_dtable.max_root_rows, &iblock_addr) < 0) + if (H5HF__man_iblock_create(hdr, NULL, 0, nrows, hdr->man_dtable.max_root_rows, &iblock_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap indirect block") /* Move current direct block (used as root) into new indirect block */ /* Lock new indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, NULL, 0, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, NULL, 0, FALSE, + H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Check if there's already a direct block as root) */ have_direct_block = H5F_addr_defined(hdr->man_dtable.table_addr); - if(have_direct_block) { - H5HF_direct_t *dblock; /* Pointer to direct block to query */ + if (have_direct_block) { + H5HF_direct_t *dblock; /* Pointer to direct block to query */ /* Lock first (root) direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, hdr->man_dtable.table_addr, hdr->man_dtable.cparam.start_block_size, NULL, 0, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, hdr->man_dtable.table_addr, + hdr->man_dtable.cparam.start_block_size, NULL, 0, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") /* Attach direct block to new root indirect block */ - dblock->parent = iblock; + dblock->parent = iblock; dblock->par_entry = 0; /* Destroy flush dependency between direct block and header */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* Create flush dependency between direct block and new root indirect block */ - if(H5AC_create_flush_dependency(iblock, dblock) < 0) + if (H5AC_create_flush_dependency(iblock, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") dblock->fd_parent = iblock; - if(H5HF_man_iblock_attach(iblock, 0, hdr->man_dtable.table_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach root direct block to parent indirect block") + if (H5HF__man_iblock_attach(iblock, 0, hdr->man_dtable.table_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, + "can't attach root direct block to parent indirect block") /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the pipeline filter information from the header */ - iblock->filt_ents[0].size = hdr->pline_root_direct_size; + iblock->filt_ents[0].size = hdr->pline_root_direct_size; iblock->filt_ents[0].filter_mask = hdr->pline_root_direct_filter_mask; /* Reset the header's pipeline information */ - hdr->pline_root_direct_size = 0; + hdr->pline_root_direct_size = 0; hdr->pline_root_direct_filter_mask = 0; } /* end if */ /* Scan free space sections to set any 'parent' pointers to new indirect block */ - if(H5HF__space_create_root(hdr, iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set free space section info to new root indirect block") + if (H5HF__space_create_root(hdr, iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, + "can't set free space section info to new root indirect block") /* Unlock first (previously the root) direct block */ - if(H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, hdr->man_dtable.table_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, hdr->man_dtable.table_addr, dblock, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") dblock = NULL; } /* end if */ /* Start iterator at correct location */ - if(H5HF_hdr_start_iter(hdr, iblock, (hsize_t)(have_direct_block ? hdr->man_dtable.cparam.start_block_size : 0), have_direct_block) < 0) + if (H5HF__hdr_start_iter(hdr, iblock, + (hsize_t)(have_direct_block ? hdr->man_dtable.cparam.start_block_size : 0), + have_direct_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize block iterator") /* Check for skipping over direct blocks, in order to get to large enough block */ - if(min_dblock_size > hdr->man_dtable.cparam.start_block_size) + if (min_dblock_size > hdr->man_dtable.cparam.start_block_size) /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, have_direct_block, - ((nrows - 1) * hdr->man_dtable.cparam.width) - have_direct_block) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, have_direct_block, + ((nrows - 1) * hdr->man_dtable.cparam.width) - have_direct_block) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF__iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Unprotect root indirect block (it's pinned by the iterator though) */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__DIRTIED_FLAG, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__DIRTIED_FLAG, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; /* Point heap header at new indirect block */ hdr->man_dtable.curr_root_rows = nrows; - hdr->man_dtable.table_addr = iblock_addr; + hdr->man_dtable.table_addr = iblock_addr; /* Compute free space in direct blocks referenced from entries in root indirect block */ acc_dblock_free = 0; - for(u = 0; u < nrows; u++) + for (u = 0; u < nrows; u++) acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[u] * hdr->man_dtable.cparam.width; /* Account for potential initial direct block */ - if(have_direct_block) + if (have_direct_block) acc_dblock_free -= hdr->man_dtable.row_tot_dblock_free[0]; /* Extend heap to cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, hdr->man_dtable.row_block_off[nrows], (hssize_t)acc_dblock_free) < 0) + if (H5HF__hdr_adjust_heap(hdr, hdr->man_dtable.row_block_off[nrows], (hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_double * @@ -493,25 +487,25 @@ H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size) herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) { - H5HF_indirect_t *iblock; /* Pointer to root indirect block */ - haddr_t new_addr; /* New address of indirect block */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hsize_t next_size; /* The previous value of the "next size" for the new block iterator */ - hsize_t old_iblock_size; /* Old size of indirect block */ - unsigned next_row; /* The next row to allocate block in */ - unsigned next_entry; /* The previous value of the "next entry" for the new block iterator */ - unsigned new_next_entry = 0;/* The new value of the "next entry" for the new block iterator */ - unsigned min_nrows = 0; /* Min. # of direct rows */ - unsigned old_nrows; /* Old # of rows */ - unsigned new_nrows; /* New # of rows */ - hbool_t skip_direct_rows = FALSE; /* Whether we are skipping direct rows */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to root indirect block */ + haddr_t new_addr; /* New address of indirect block */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hsize_t next_size; /* The previous value of the "next size" for the new block iterator */ + hsize_t old_iblock_size; /* Old size of indirect block */ + unsigned next_row; /* The next row to allocate block in */ + unsigned next_entry; /* The previous value of the "next entry" for the new block iterator */ + unsigned new_next_entry = 0; /* The new value of the "next entry" for the new block iterator */ + unsigned min_nrows = 0; /* Min. # of direct rows */ + unsigned old_nrows; /* Old # of rows */ + unsigned new_nrows; /* New # of rows */ + hbool_t skip_direct_rows = FALSE; /* Whether we are skipping direct rows */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get "new block" iterator information */ - if(H5HF_man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) + if (H5HF__man_iter_curr(&hdr->next_block, &next_row, NULL, &next_entry, &iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve current block iterator location") next_size = hdr->man_dtable.row_block_size[next_row]; @@ -523,7 +517,7 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) old_nrows = iblock->nrows; /* Check for skipping over direct block rows */ - if(iblock->nrows < hdr->man_dtable.max_direct_rows && min_dblock_size > next_size) { + if (iblock->nrows < hdr->man_dtable.max_direct_rows && min_dblock_size > next_size) { /* Sanity check */ HDassert(min_dblock_size > hdr->man_dtable.cparam.start_block_size); @@ -531,7 +525,7 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) skip_direct_rows = TRUE; /* Make certain we allocate at least the required row for the block requested */ - min_nrows = 1 + H5HF_dtable_size_to_row(&hdr->man_dtable, min_dblock_size); + min_nrows = 1 + H5HF__dtable_size_to_row(&hdr->man_dtable, min_dblock_size); /* Set the information for the next block, of the appropriate size */ new_next_entry = (min_nrows - 1) * hdr->man_dtable.cparam.width; @@ -542,117 +536,124 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") /* Compute size of buffer needed for new indirect block */ - iblock->nrows = new_nrows; + iblock->nrows = new_nrows; old_iblock_size = iblock->size; - iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); + iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate [temporary] space for the new indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end else */ /* Resize pinned indirect block in the cache, if its changed size */ - if(old_iblock_size != iblock->size) { - if(H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) + if (old_iblock_size != iblock->size) { + if (H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap indirect block") } /* end if */ /* Move object in cache, if it actually was relocated */ - if(H5F_addr_ne(iblock->addr, new_addr)) { - if(H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) + if (H5F_addr_ne(iblock->addr, new_addr)) { + if (H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move fractal heap root indirect block") iblock->addr = new_addr; } /* end if */ /* Re-allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for direct entries") /* Check for skipping over rows and add free section for skipped rows */ - if(skip_direct_rows) + if (skip_direct_rows) /* Add skipped blocks to heap's free space */ - if(H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (new_next_entry - next_entry)) < 0) + if (H5HF__hdr_skip_blocks(hdr, iblock, next_entry, (new_next_entry - next_entry)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") /* Initialize new direct block entries in rows added */ acc_dblock_free = 0; - for(u = (old_nrows * hdr->man_dtable.cparam.width); u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { - unsigned row = (unsigned)(u / hdr->man_dtable.cparam.width); /* Row for current entry */ + for (u = (old_nrows * hdr->man_dtable.cparam.width); u < (iblock->nrows * hdr->man_dtable.cparam.width); + u++) { + unsigned row = (unsigned)(u / hdr->man_dtable.cparam.width); /* Row for current entry */ iblock->ents[u].addr = HADDR_UNDEF; acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[row]; } /* end for */ /* Check for needing to re-allocate filtered entry array */ - if(hdr->filter_len > 0 && old_nrows < hdr->man_dtable.max_direct_rows) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0 && old_nrows < hdr->man_dtable.max_direct_rows) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); HDassert(dir_rows > old_nrows); /* Re-allocate filtered direct block entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") /* Initialize new entries allocated */ - for(u = (old_nrows * hdr->man_dtable.cparam.width); u < (dir_rows * hdr->man_dtable.cparam.width); u++) { - iblock->filt_ents[u].size = 0; + for (u = (old_nrows * hdr->man_dtable.cparam.width); u < (dir_rows * hdr->man_dtable.cparam.width); + u++) { + iblock->filt_ents[u].size = 0; iblock->filt_ents[u].filter_mask = 0; } /* end for */ - } /* end if */ + } /* end if */ /* Check for needing to re-allocate child iblock pointer array */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ - unsigned old_indir_rows; /* Previous number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ + unsigned old_indir_rows; /* Previous number of indirect rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Re-allocate child indirect block array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == + (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, + (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") /* Compute the previous # of indirect rows in this block */ - if(old_nrows < hdr->man_dtable.max_direct_rows) + if (old_nrows < hdr->man_dtable.max_direct_rows) old_indir_rows = 0; else old_indir_rows = old_nrows - hdr->man_dtable.max_direct_rows; /* Initialize new entries allocated */ - for(u = (old_indir_rows * hdr->man_dtable.cparam.width); u < (indir_rows * hdr->man_dtable.cparam.width); u++) + for (u = (old_indir_rows * hdr->man_dtable.cparam.width); + u < (indir_rows * hdr->man_dtable.cparam.width); u++) iblock->child_iblocks[u] = NULL; } /* end if */ /* Mark indirect block as dirty */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF__iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Update other shared header info */ hdr->man_dtable.curr_root_rows = new_nrows; - hdr->man_dtable.table_addr = new_addr; + hdr->man_dtable.table_addr = new_addr; /* Extend heap to cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], (hssize_t)acc_dblock_free) < 0) + if (H5HF__hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], + (hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_double() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_halve * @@ -668,15 +669,15 @@ H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size) static herr_t H5HF__man_iblock_root_halve(H5HF_indirect_t *iblock) { - H5HF_hdr_t *hdr = iblock->hdr; /* Pointer to heap header */ - haddr_t new_addr; /* New address of indirect block */ - hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ - hsize_t old_size; /* Old size of indirect block */ - unsigned max_child_row; /* Row for max. child entry */ - unsigned old_nrows; /* Old # of rows */ - unsigned new_nrows; /* New # of rows */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = iblock->hdr; /* Pointer to heap header */ + haddr_t new_addr; /* New address of indirect block */ + hsize_t acc_dblock_free; /* Accumulated free space in direct blocks */ + hsize_t old_size; /* Old size of indirect block */ + unsigned max_child_row; /* Row for max. child entry */ + unsigned old_nrows; /* Old # of rows */ + unsigned new_nrows; /* New # of rows */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -693,90 +694,97 @@ H5HF__man_iblock_root_halve(H5HF_indirect_t *iblock) /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if(!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") /* Compute free space in rows to delete */ acc_dblock_free = 0; - for(u = new_nrows; u < iblock->nrows; u++) + for (u = new_nrows; u < iblock->nrows; u++) acc_dblock_free += hdr->man_dtable.row_tot_dblock_free[u] * hdr->man_dtable.cparam.width; /* Compute size of buffer needed for new indirect block */ - old_nrows = iblock->nrows; + old_nrows = iblock->nrows; iblock->nrows = new_nrows; - old_size = iblock->size; - iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); + old_size = iblock->size; + iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate [temporary] space for the new indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (new_addr = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + if (HADDR_UNDEF == (new_addr = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") } /* end else */ /* Resize pinned indirect block in the cache, if it has changed size */ - if(old_size != iblock->size) { - if(H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) + if (old_size != iblock->size) { + if (H5AC_resize_entry(iblock, (size_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize fractal heap indirect block") } /* end if */ /* Move object in cache, if it actually was relocated */ - if(H5F_addr_ne(iblock->addr, new_addr)) { - if(H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) + if (H5F_addr_ne(iblock->addr, new_addr)) { + if (H5AC_move_entry(hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, new_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSPLIT, FAIL, "unable to move fractal heap root indirect block") iblock->addr = new_addr; } /* end if */ /* Re-allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->ents = H5FL_SEQ_REALLOC(H5HF_indirect_ent_t, iblock->ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct entries") /* Check for needing to re-allocate filtered entry array */ - if(hdr->filter_len > 0 && new_nrows < hdr->man_dtable.max_direct_rows) { + if (hdr->filter_len > 0 && new_nrows < hdr->man_dtable.max_direct_rows) { /* Re-allocate filtered direct block entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + if (NULL == + (iblock->filt_ents = H5FL_SEQ_REALLOC(H5HF_indirect_filt_ent_t, iblock->filt_ents, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") } /* end if */ /* Check for needing to re-allocate child iblock pointer array */ - if(old_nrows > hdr->man_dtable.max_direct_rows) { + if (old_nrows > hdr->man_dtable.max_direct_rows) { /* Check for shrinking away child iblock pointer array */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Re-allocate child indirect block array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for filtered direct entries") + if (NULL == (iblock->child_iblocks = + H5FL_SEQ_REALLOC(H5HF_indirect_ptr_t, iblock->child_iblocks, + (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, + "memory allocation failed for filtered direct entries") } /* end if */ else - iblock->child_iblocks = (H5HF_indirect_ptr_t *)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); + iblock->child_iblocks = + (H5HF_indirect_ptr_t *)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); } /* end if */ /* Mark indirect block as dirty */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF__iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Update other shared header info */ hdr->man_dtable.curr_root_rows = new_nrows; - hdr->man_dtable.table_addr = new_addr; + hdr->man_dtable.table_addr = new_addr; /* Shrink heap to only cover new root indirect block */ - if(H5HF_hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], -(hssize_t)acc_dblock_free) < 0) + if (H5HF__hdr_adjust_heap(hdr, 2 * hdr->man_dtable.row_block_off[new_nrows - 1], + -(hssize_t)acc_dblock_free) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce space to cover root direct block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_halve() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_root_revert * @@ -795,11 +803,11 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Direct block's address in the file */ + size_t dblock_size; /* Direct block's size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -809,63 +817,64 @@ H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) HDassert(root_iblock); /* Set up local convenience variables */ - hdr = root_iblock->hdr; + hdr = root_iblock->hdr; dblock_addr = root_iblock->ents[0].addr; dblock_size = hdr->man_dtable.cparam.start_block_size; /* Get pointer to last direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, root_iblock, 0, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, root_iblock, 0, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") HDassert(dblock->parent == root_iblock); HDassert(dblock->par_entry == 0); /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Set the header's pipeline information from the indirect block */ - hdr->pline_root_direct_size = root_iblock->filt_ents[0].size; + hdr->pline_root_direct_size = root_iblock->filt_ents[0].size; hdr->pline_root_direct_filter_mask = root_iblock->filt_ents[0].filter_mask; } /* end if */ /* Destroy flush dependency between old root iblock and new root direct block */ - if(H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) + if (H5AC_destroy_flush_dependency(dblock->fd_parent, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") dblock->fd_parent = NULL; /* Detach direct block from parent */ - if(H5HF__man_iblock_detach(dblock->parent, 0) < 0) + if (H5HF__man_iblock_detach(dblock->parent, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach direct block from parent indirect block") - dblock->parent = NULL; + dblock->parent = NULL; dblock->par_entry = 0; /* Create flush dependency between header and new root direct block */ - if(H5AC_create_flush_dependency(hdr, dblock) < 0) + if (H5AC_create_flush_dependency(hdr, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") dblock->fd_parent = hdr; /* Point root at direct block */ hdr->man_dtable.curr_root_rows = 0; - hdr->man_dtable.table_addr = dblock_addr; + hdr->man_dtable.table_addr = dblock_addr; /* Reset 'next block' iterator */ - if(H5HF_hdr_reset_iter(hdr, (hsize_t)dblock_size) < 0) + if (H5HF__hdr_reset_iter(hdr, (hsize_t)dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator") /* Extend heap to just cover first direct block */ - if(H5HF_hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) + if (H5HF__hdr_adjust_heap(hdr, (hsize_t)hdr->man_dtable.cparam.start_block_size, + (hssize_t)hdr->man_dtable.row_tot_dblock_free[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "can't increase space to cover root direct block") /* Scan free space sections to reset any 'parent' pointers */ - if(H5HF__space_revert_root(hdr) < 0) + if (H5HF__space_revert_root(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESET, FAIL, "can't reset free space section info") done: - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_revert() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_alloc_row * @@ -884,11 +893,11 @@ 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dblock_entry; /* Entry for direct block */ + hbool_t iblock_held = FALSE; /* Flag to indicate that indirect block is held */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -901,40 +910,40 @@ H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node) /* Check for serialized row section, or serialized / deleted indirect * section under it. */ - if(old_sec_node->sect_info.state == H5FS_SECT_SERIALIZED - || (H5FS_SECT_SERIALIZED == old_sec_node->u.row.under->sect_info.state) - || (TRUE == old_sec_node->u.row.under->u.indirect.u.iblock->removed_from_cache)) + if (old_sec_node->sect_info.state == H5FS_SECT_SERIALIZED || + (H5FS_SECT_SERIALIZED == old_sec_node->u.row.under->sect_info.state) || + (TRUE == old_sec_node->u.row.under->u.indirect.u.iblock->removed_from_cache)) /* Revive row and / or indirect section */ - if(H5HF__sect_row_revive(hdr, old_sec_node) < 0) + if (H5HF__sect_row_revive(hdr, old_sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") /* Get a pointer to the indirect block covering the section */ - if(NULL == (iblock = H5HF_sect_row_get_iblock(old_sec_node))) + if (NULL == (iblock = H5HF__sect_row_get_iblock(old_sec_node))) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve indirect block for row section") /* Hold indirect block in memory, until direct block can point to it */ - if(H5HF_iblock_incr(iblock) < 0) + if (H5HF__iblock_incr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") iblock_held = TRUE; /* Reduce (& possibly re-add) 'row' section */ - if(H5HF__sect_row_reduce(hdr, old_sec_node, &dblock_entry) < 0) + if (H5HF__sect_row_reduce(hdr, old_sec_node, &dblock_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce row section node") /* Create direct block & single section */ - if(H5HF__man_dblock_create(hdr, iblock, dblock_entry, NULL, sec_node) < 0) + if (H5HF__man_dblock_create(hdr, iblock, dblock_entry, NULL, sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate fractal heap direct block") done: /* Release hold on indirect block */ - if(iblock_held) - if(H5HF__iblock_decr(iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (iblock_held) + if (H5HF__iblock_decr(iblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_alloc_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_create * @@ -948,12 +957,12 @@ H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node) *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, unsigned nrows, unsigned max_rows, haddr_t *addr_p) +H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, unsigned nrows, + unsigned max_rows, haddr_t *addr_p) { - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -967,92 +976,100 @@ H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, /* * Allocate file and memory data structures. */ - if(NULL == (iblock = H5FL_MALLOC(H5HF_indirect_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fractal heap indirect block") + if (NULL == (iblock = H5FL_MALLOC(H5HF_indirect_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for fractal heap indirect block") /* Reset the metadata cache info for the heap header */ HDmemset(&iblock->cache_info, 0, sizeof(H5AC_info_t)); /* Share common heap information */ iblock->hdr = hdr; - if(H5HF_hdr_incr(hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") + if (H5HF__hdr_incr(hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") /* Set info for indirect block */ - iblock->rc = 0; - iblock->nrows = nrows; - iblock->max_rows = max_rows; + iblock->rc = 0; + iblock->nrows = nrows; + iblock->max_rows = max_rows; iblock->removed_from_cache = FALSE; /* Compute size of buffer needed for indirect block */ iblock->size = H5HF_MAN_INDIRECT_SIZE(hdr, iblock->nrows); /* Allocate child block entry array */ - if(NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") + if (NULL == (iblock->ents = H5FL_SEQ_MALLOC(H5HF_indirect_ent_t, + (size_t)(iblock->nrows * hdr->man_dtable.cparam.width)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") /* Initialize indirect block entry tables */ - for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) + for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) iblock->ents[u].addr = HADDR_UNDEF; /* Check for I/O filters to apply to this heap */ - if(hdr->filter_len > 0) { - unsigned dir_rows; /* Number of direct rows in this indirect block */ + if (hdr->filter_len > 0) { + unsigned dir_rows; /* Number of direct rows in this indirect block */ /* Compute the number of direct rows for this indirect block */ dir_rows = MIN(iblock->nrows, hdr->man_dtable.max_direct_rows); /* Allocate & initialize indirect block filtered entry array */ - if(NULL == (iblock->filt_ents = H5FL_SEQ_CALLOC(H5HF_indirect_filt_ent_t, (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->filt_ents = H5FL_SEQ_CALLOC(H5HF_indirect_filt_ent_t, + (size_t)(dir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") } /* end if */ else iblock->filt_ents = NULL; /* Check if we have any indirect block children */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned indir_rows; /* Number of indirect rows in this indirect block */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned indir_rows; /* Number of indirect rows in this indirect block */ /* Compute the number of indirect rows for this indirect block */ indir_rows = iblock->nrows - hdr->man_dtable.max_direct_rows; /* Allocate & initialize child indirect block pointer array */ - if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) + if (NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC( + H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block entries") } /* end if */ else iblock->child_iblocks = NULL; /* Allocate [temporary] space for the indirect block on disk */ - if(H5F_USE_TMP_SPACE(hdr->f)) { - if(HADDR_UNDEF == (*addr_p = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") + if (H5F_USE_TMP_SPACE(hdr->f)) { + if (HADDR_UNDEF == (*addr_p = H5MF_alloc_tmp(hdr->f, (hsize_t)iblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap indirect block") } /* end if */ else { - if(HADDR_UNDEF == (*addr_p = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for fractal heap indirect block") + if (HADDR_UNDEF == (*addr_p = H5MF_alloc(hdr->f, H5FD_MEM_FHEAP_IBLOCK, (hsize_t)iblock->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "file allocation failed for fractal heap indirect block") } /* end else */ iblock->addr = *addr_p; /* Attach to parent indirect block, if there is one */ - iblock->parent = par_iblock; + iblock->parent = par_iblock; iblock->par_entry = par_entry; - if(iblock->parent) { + if (iblock->parent) { /* Attach new block to parent */ - if(H5HF_man_iblock_attach(iblock->parent, par_entry, *addr_p) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't attach indirect block to parent indirect block") + if (H5HF__man_iblock_attach(iblock->parent, par_entry, *addr_p) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, + "can't attach indirect block to parent indirect block") /* Compute the indirect block's offset in the heap's address space */ /* (based on parent's block offset) */ iblock->block_off = par_iblock->block_off; iblock->block_off += hdr->man_dtable.row_block_off[par_entry / hdr->man_dtable.cparam.width]; - iblock->block_off += hdr->man_dtable.row_block_size[par_entry / hdr->man_dtable.cparam.width] * (par_entry % hdr->man_dtable.cparam.width); + iblock->block_off += hdr->man_dtable.row_block_size[par_entry / hdr->man_dtable.cparam.width] * + (par_entry % hdr->man_dtable.cparam.width); /* Set indirect block parent as flush dependency parent */ iblock->fd_parent = par_iblock; } /* end if */ else { - iblock->block_off = 0; /* Must be the root indirect block... */ + iblock->block_off = 0; /* Must be the root indirect block... */ /* Set heap header as flush dependency parent */ iblock->fd_parent = hdr; @@ -1063,19 +1080,18 @@ H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, iblock->max_child = 0; /* Cache the new indirect block */ - if(H5AC_insert_entry(hdr->f, H5AC_FHEAP_IBLOCK, *addr_p, iblock, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap indirect block to cache") + if (H5AC_insert_entry(hdr->f, H5AC_FHEAP_IBLOCK, *addr_p, iblock, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add fractal heap indirect block to cache") done: - if(ret_value < 0) - if(iblock) - if(H5HF_man_iblock_dest(iblock) < 0) + if (ret_value < 0) + if (iblock) + if (H5HF__man_iblock_dest(iblock) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_create() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_protect * @@ -1089,14 +1105,14 @@ H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, *------------------------------------------------------------------------- */ H5HF_indirect_t * -H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, - hbool_t must_protect, unsigned flags, hbool_t *did_protect) +H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, hbool_t must_protect, + unsigned flags, hbool_t *did_protect) { - H5HF_parent_t par_info; /* Parent info for loading block */ - H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ - hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ - H5HF_indirect_t *ret_value = NULL; /* Return value */ + H5HF_parent_t par_info; /* Parent info for loading block */ + H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ + hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1112,31 +1128,29 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Check if we are allowed to use existing pinned iblock pointer */ - if(!must_protect) { + if (!must_protect) { /* Check for this block already being pinned */ - if(par_iblock) { - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (par_iblock) { + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(par_iblock->child_iblocks); - HDassert(par_entry >= (hdr->man_dtable.max_direct_rows - * hdr->man_dtable.cparam.width)); + HDassert(par_entry >= (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)); /* Compute index in parent's child iblock pointer array */ - indir_idx = par_entry - (hdr->man_dtable.max_direct_rows - * hdr->man_dtable.cparam.width); + indir_idx = par_entry - (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width); /* Check for pointer to pinned indirect block in parent */ - if(par_iblock->child_iblocks[indir_idx]) + if (par_iblock->child_iblocks[indir_idx]) iblock = par_iblock->child_iblocks[indir_idx]; else should_protect = TRUE; } /* end if */ else { /* Check for root indirect block */ - if(H5F_addr_eq(iblock_addr, hdr->man_dtable.table_addr)) { + if (H5F_addr_eq(iblock_addr, hdr->man_dtable.table_addr)) { /* Check for valid pointer to pinned indirect block in root */ - if(H5HF_ROOT_IBLOCK_PINNED == hdr->root_iblock_flags) { + if (H5HF_ROOT_IBLOCK_PINNED == hdr->root_iblock_flags) { /* Sanity check */ HDassert(NULL != hdr->root_iblock); @@ -1149,40 +1163,41 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, should_protect = TRUE; } /* end else */ - } /* end if */ + } /* end if */ else should_protect = TRUE; } /* end else */ - } /* end if */ + } /* end if */ /* Check for protecting indirect block */ - if(must_protect || should_protect) { + if (must_protect || should_protect) { H5HF_iblock_cache_ud_t cache_udata; /* User-data for callback */ /* Set up parent info */ - par_info.hdr = hdr; + par_info.hdr = hdr; par_info.iblock = par_iblock; - par_info.entry = par_entry; + par_info.entry = par_entry; /* Set up user data for protect call */ - cache_udata.f = hdr->f; + cache_udata.f = hdr->f; cache_udata.par_info = &par_info; - cache_udata.nrows = &iblock_nrows; + cache_udata.nrows = &iblock_nrows; /* Protect the indirect block */ - if(NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(hdr->f, H5AC_FHEAP_IBLOCK, iblock_addr, &cache_udata, flags))) + if (NULL == (iblock = (H5HF_indirect_t *)H5AC_protect(hdr->f, H5AC_FHEAP_IBLOCK, iblock_addr, + &cache_udata, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap indirect block") /* Set the indirect block's address */ iblock->addr = iblock_addr; /* Check for root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively protecting root indirect block */ HDassert(0 == (hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PROTECTED)); /* Check if we should set the root iblock pointer */ - if(0 == hdr->root_iblock_flags) { + if (0 == hdr->root_iblock_flags) { HDassert(NULL == hdr->root_iblock); hdr->root_iblock = iblock; } /* end if */ @@ -1205,7 +1220,6 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_protect() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_unprotect * @@ -1219,10 +1233,9 @@ H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, - hbool_t did_protect) +H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, hbool_t did_protect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1233,14 +1246,14 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, /* Check if we previously protected this indirect block */ /* (as opposed to using an existing pointer to a pinned child indirect block) */ - if(did_protect) { + if (did_protect) { /* Check for root indirect block */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* Sanity check - shouldn't be recursively unprotecting root indirect block */ HDassert(iblock->hdr->root_iblock_flags & H5HF_ROOT_IBLOCK_PROTECTED); /* Check if we should reset the root iblock pointer */ - if(H5HF_ROOT_IBLOCK_PROTECTED == iblock->hdr->root_iblock_flags) { + if (H5HF_ROOT_IBLOCK_PROTECTED == iblock->hdr->root_iblock_flags) { HDassert(NULL != iblock->hdr->root_iblock); iblock->hdr->root_iblock = NULL; } /* end if */ @@ -1250,7 +1263,7 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, } /* end if */ /* Unprotect the indirect block */ - if(H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock, cache_flags) < 0) + if (H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_IBLOCK, iblock->addr, iblock, cache_flags) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") } /* end if */ @@ -1258,9 +1271,8 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_unprotect() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iblock_attach + * Function: H5HF__man_iblock_attach * * Purpose: Attach a child block (direct or indirect) to an indirect block * @@ -1272,11 +1284,11 @@ H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, *------------------------------------------------------------------------- */ herr_t -H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_addr) +H5HF__man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1286,15 +1298,15 @@ H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_ad HDassert(!H5F_addr_defined(iblock->ents[entry].addr)); /* Increment the reference count on this indirect block */ - if(H5HF_iblock_incr(iblock) < 0) + if (H5HF__iblock_incr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Point at the child block */ iblock->ents[entry].addr = child_addr; /* Check for I/O filters on this heap */ - if(iblock->hdr->filter_len > 0) { - unsigned row; /* Row for entry */ + if (iblock->hdr->filter_len > 0) { + unsigned row; /* Row for entry */ /* Sanity check */ HDassert(iblock->filt_ents); @@ -1303,26 +1315,25 @@ H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_ad row = entry / iblock->hdr->man_dtable.cparam.width; /* If this is a direct block, set its initial size */ - if(row < iblock->hdr->man_dtable.max_direct_rows) + if (row < iblock->hdr->man_dtable.max_direct_rows) iblock->filt_ents[entry].size = iblock->hdr->man_dtable.row_block_size[row]; } /* end if */ /* Check for max. entry used */ - if(entry > iblock->max_child) + if (entry > iblock->max_child) iblock->max_child = entry; /* Increment the # of child blocks */ iblock->nchildren++; /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF__iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iblock_attach() */ +} /* end H5HF__man_iblock_attach() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_detach * @@ -1338,10 +1349,10 @@ H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_ad herr_t H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) { - 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -1361,20 +1372,20 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) row = entry / hdr->man_dtable.cparam.width; /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) { + if (hdr->filter_len > 0) { /* Sanity check */ HDassert(iblock->filt_ents); /* If this is a direct block, reset its initial size */ - if(row < hdr->man_dtable.max_direct_rows) { - iblock->filt_ents[entry].size = 0; + if (row < hdr->man_dtable.max_direct_rows) { + iblock->filt_ents[entry].size = 0; iblock->filt_ents[entry].filter_mask = 0; } /* end if */ - } /* end if */ + } /* end if */ /* Check for indirect block being detached */ - if(row >= hdr->man_dtable.max_direct_rows) { - unsigned indir_idx; /* Index in parent's child iblock pointer array */ + if (row >= hdr->man_dtable.max_direct_rows) { + unsigned indir_idx; /* Index in parent's child iblock pointer array */ /* Sanity check */ HDassert(iblock->child_iblocks); @@ -1397,51 +1408,53 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) iblock->nchildren--; /* Reduce the max. entry used, if necessary */ - if(entry == iblock->max_child) { - if(iblock->nchildren > 0) - while(!H5F_addr_defined(iblock->ents[iblock->max_child].addr)) + if (entry == iblock->max_child) { + if (iblock->nchildren > 0) + while (!H5F_addr_defined(iblock->ents[iblock->max_child].addr)) iblock->max_child--; else iblock->max_child = 0; } /* end if */ /* If this is the root indirect block handle some special cases */ - if(iblock->block_off == 0) { + if (iblock->block_off == 0) { /* If the number of children drops to 1, and that child is the first * direct block in the heap, convert the heap back to using a root * direct block */ - if(iblock->nchildren == 1 && H5F_addr_defined(iblock->ents[0].addr)) - if(H5HF__man_iblock_root_revert(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't convert root indirect block back to root direct block") + if (iblock->nchildren == 1 && H5F_addr_defined(iblock->ents[0].addr)) + if (H5HF__man_iblock_root_revert(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, + "can't convert root indirect block back to root direct block") /* If the indirect block wasn't removed already (by reverting it) */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Check for reducing size of root indirect block */ - if(iblock->nchildren > 0 && hdr->man_dtable.cparam.start_root_rows != 0 - && entry > iblock->max_child) { - unsigned max_child_row; /* Row for max. child entry */ - - /* Compute information needed for determining whether to reduce size of root indirect block */ - max_child_row = iblock->max_child / hdr->man_dtable.cparam.width; - - /* Check if the root indirect block should be reduced */ - if(iblock->nrows > 1 && max_child_row <= (iblock->nrows / 2)) - if(H5HF__man_iblock_root_halve(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce size of root indirect block") + if (iblock->nchildren > 0 && hdr->man_dtable.cparam.start_root_rows != 0 && + entry > iblock->max_child) { + unsigned max_child_row; /* Row for max. child entry */ + + /* Compute information needed for determining whether to reduce size of root indirect block */ + max_child_row = iblock->max_child / hdr->man_dtable.cparam.width; + + /* Check if the root indirect block should be reduced */ + if (iblock->nrows > 1 && max_child_row <= (iblock->nrows / 2)) + if (H5HF__man_iblock_root_halve(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, + "can't reduce size of root indirect block") } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* If the indirect block wasn't removed already (by reverting it) */ - if(!iblock->removed_from_cache) { + if (!iblock->removed_from_cache) { /* Mark indirect block as modified */ - if(H5HF_iblock_dirty(iblock) < 0) + if (H5HF__iblock_dirty(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark indirect block as dirty") /* Check for last child being removed from indirect block */ - if(iblock->nchildren == 0) { - hbool_t did_protect = FALSE; /* Whether the indirect block was protected */ + if (iblock->nchildren == 0) { + hbool_t did_protect = FALSE; /* Whether the indirect block was protected */ /* If this indirect block's refcount is >1, then it's being deleted * from the fractal heap (since its nchildren == 0), but is still @@ -1454,50 +1467,52 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) * the cache's perspective). */ /* Lock indirect block for deletion */ - if(NULL == (del_iblock = H5HF__man_iblock_protect(hdr, iblock->addr, iblock->nrows, iblock->parent, iblock->par_entry, TRUE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (del_iblock = H5HF__man_iblock_protect(hdr, iblock->addr, iblock->nrows, + iblock->parent, iblock->par_entry, TRUE, + H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") HDassert(did_protect == TRUE); /* Check for deleting root indirect block (and no root direct block) */ - if(iblock->block_off == 0 && hdr->man_dtable.curr_root_rows > 0) + if (iblock->block_off == 0 && hdr->man_dtable.curr_root_rows > 0) /* Reset header information back to "empty heap" state */ - if(H5HF__hdr_empty(hdr) < 0) + if (H5HF__hdr_empty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't make heap empty") /* Detach from parent indirect block */ - if(iblock->parent) { + if (iblock->parent) { /* Destroy flush dependency between indirect block and parent */ - if(H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) + if (H5AC_destroy_flush_dependency(iblock->fd_parent, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") iblock->fd_parent = NULL; /* Detach from parent indirect block */ - if(H5HF__man_iblock_detach(iblock->parent, iblock->par_entry) < 0) + if (H5HF__man_iblock_detach(iblock->parent, iblock->par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTATTACH, FAIL, "can't detach from parent indirect block") - iblock->parent = NULL; + iblock->parent = NULL; iblock->par_entry = 0; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Decrement the reference count on this indirect block if we're not deleting it */ /* (should be after iblock needs to be modified, so that potential 'unpin' * on this indirect block doesn't invalidate the 'iblock' variable, if it's * not being deleted) */ - if(H5HF__iblock_decr(iblock) < 0) + if (H5HF__iblock_decr(iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") iblock = NULL; /* Delete indirect block from cache, if appropriate */ - if(del_iblock) { - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotect */ - hbool_t took_ownership = FALSE; /* Flag to indicate that block ownership has transitioned */ + if (del_iblock) { + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotect */ + hbool_t took_ownership = FALSE; /* Flag to indicate that block ownership has transitioned */ /* If the refcount is still >0, unpin the block and take ownership * from the cache, otherwise let the cache destroy it. */ - if(del_iblock->rc > 0) { + if (del_iblock->rc > 0) { cache_flags |= (H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG); cache_flags |= H5AC__UNPIN_ENTRY_FLAG; took_ownership = TRUE; @@ -1509,34 +1524,35 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) /* If the indirect block is in real file space, tell * the cache to free its file space as well. */ - if(!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) + if (!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) cache_flags |= H5AC__FREE_FILE_SPACE_FLAG; } /* end else */ /* Unprotect the indirect block, with appropriate flags */ - if(H5HF__man_iblock_unprotect(del_iblock, cache_flags, TRUE) < 0) + if (H5HF__man_iblock_unprotect(del_iblock, cache_flags, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") /* if took ownership, free file space & mark block as removed from cache */ - if(took_ownership) { + if (took_ownership) { /* Free indirect block disk space, if it's in real space */ - if(!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) - if(H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, del_iblock->addr, (hsize_t)del_iblock->size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") + if (!H5F_IS_TMP_ADDR(hdr->f, del_iblock->addr)) + if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, del_iblock->addr, (hsize_t)del_iblock->size) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to free fractal heap indirect block file space") del_iblock->addr = HADDR_UNDEF; /* Mark block as removed from the cache */ del_iblock->removed_from_cache = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_detach() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iblock_entry_addr + * Function: H5HF__man_iblock_entry_addr * * Purpose: Retrieve the address of an indirect block's child * @@ -1548,9 +1564,9 @@ H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) *------------------------------------------------------------------------- */ herr_t -H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *child_addr) +H5HF__man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *child_addr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -1562,9 +1578,8 @@ H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *chi *child_addr = iblock->ents[entry].addr; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iblock_entry_addr() */ +} /* end H5HF__man_iblock_entry_addr() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iblock_delete * @@ -1582,15 +1597,15 @@ H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *chi *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry) +H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry) { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - unsigned row, col; /* Current row & column in indirect block */ - unsigned entry; /* Current entry in row */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + unsigned row, col; /* Current row & column in indirect block */ + unsigned entry; /* Current entry in row */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1602,61 +1617,66 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert(iblock_nrows > 0); /* Lock indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, par_iblock, par_entry, TRUE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, par_iblock, par_entry, + TRUE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") HDassert(iblock->nchildren > 0); HDassert(did_protect == TRUE); /* Iterate over rows in this indirect block */ entry = 0; - for(row = 0; row < iblock->nrows; row++) { + for (row = 0; row < iblock->nrows; row++) { /* Iterate over entries in this row */ - for(col = 0; col < hdr->man_dtable.cparam.width; col++, entry++) { + for (col = 0; col < hdr->man_dtable.cparam.width; col++, entry++) { /* Check for child entry at this position */ - if(H5F_addr_defined(iblock->ents[entry].addr)) { + if (H5F_addr_defined(iblock->ents[entry].addr)) { /* Are we in a direct or indirect block row */ - if(row < hdr->man_dtable.max_direct_rows) { - hsize_t dblock_size; /* Size of direct block on disk */ + if (row < hdr->man_dtable.max_direct_rows) { + hsize_t dblock_size; /* Size of direct block on disk */ /* Check for I/O filters on this heap */ - if(hdr->filter_len > 0) + if (hdr->filter_len > 0) dblock_size = iblock->filt_ents[entry].size; else dblock_size = hdr->man_dtable.row_block_size[row]; /* Delete child direct block */ - if(H5HF__man_dblock_delete(hdr->f, iblock->ents[entry].addr, dblock_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child direct block") + if (H5HF__man_dblock_delete(hdr->f, iblock->ents[entry].addr, dblock_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap child direct block") } /* end if */ else { - hsize_t row_block_size; /* The size of blocks in this row */ - unsigned child_nrows; /* Number of rows in new indirect block */ + hsize_t row_block_size; /* The size of blocks in this row */ + unsigned child_nrows; /* Number of rows in new indirect block */ /* Get the row's block size */ row_block_size = (hsize_t)hdr->man_dtable.row_block_size[row]; /* Compute # of rows in next child indirect block to use */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, row_block_size); + child_nrows = H5HF__dtable_size_to_rows(&hdr->man_dtable, row_block_size); /* Delete child indirect block */ - if(H5HF__man_iblock_delete(hdr, iblock->ents[entry].addr, child_nrows, iblock, entry) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap child indirect block") + if (H5HF__man_iblock_delete(hdr, iblock->ents[entry].addr, child_nrows, iblock, entry) < + 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, + "unable to release fractal heap child indirect block") } /* end else */ - } /* end if */ - } /* end for */ - } /* end row */ + } /* end if */ + } /* end for */ + } /* end row */ #ifndef NDEBUG -{ - unsigned iblock_status = 0; /* Indirect block's status in the metadata cache */ + { + unsigned iblock_status = 0; /* Indirect block's status in the metadata cache */ - /* Check the indirect block's status in the metadata cache */ - if(H5AC_get_entry_status(hdr->f, iblock_addr, &iblock_status) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to check metadata cache status for indirect block") + /* Check the indirect block's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, iblock_addr, &iblock_status) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to check metadata cache status for indirect block") - /* Check if indirect block is pinned */ - HDassert(!(iblock_status & H5AC_ES__IS_PINNED)); -} + /* Check if indirect block is pinned */ + HDassert(!(iblock_status & H5AC_ES__IS_PINNED)); + } #endif /* NDEBUG */ /* Indicate that the indirect block should be deleted */ @@ -1670,13 +1690,12 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, done: /* Unprotect the indirect block, with appropriate flags */ - if(iblock && H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_delete() */ - /*------------------------------------------------------------------------- * * Function: H5HF__man_iblock_size @@ -1690,12 +1709,12 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size) +H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size) { - H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1708,44 +1727,47 @@ H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, HDassert(heap_size); /* Protect the indirect block */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, par_iblock, par_entry, FALSE, H5AC__READ_ONLY_FLAG, &did_protect))) + if (NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, nrows, par_iblock, par_entry, FALSE, + H5AC__READ_ONLY_FLAG, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") /* Accumulate size of this indirect block */ *heap_size += iblock->size; /* Indirect entries in this indirect block */ - if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned first_row_bits; /* Number of bits used bit addresses in first row */ - unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ - unsigned entry; /* Current entry in row */ - size_t u; /* Local index variable */ + if (iblock->nrows > hdr->man_dtable.max_direct_rows) { + unsigned first_row_bits; /* Number of bits used bit addresses in first row */ + unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + unsigned entry; /* Current entry in row */ + size_t u; /* Local index variable */ - entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; + entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; first_row_bits = H5VM_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + - H5VM_log2_of2(hdr->man_dtable.cparam.width); - num_indirect_rows = - (H5VM_log2_gen(hdr->man_dtable.row_block_size[hdr->man_dtable.max_direct_rows]) - first_row_bits) + 1; - for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { - size_t v; /* Local index variable */ - - for(v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) - if(H5F_addr_defined(iblock->ents[entry].addr)) - if(H5HF__man_iblock_size(f, hdr, iblock->ents[entry].addr, num_indirect_rows, iblock, entry, heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to get fractal heap storage info for indirect block") + H5VM_log2_of2(hdr->man_dtable.cparam.width); + num_indirect_rows = (H5VM_log2_gen(hdr->man_dtable.row_block_size[hdr->man_dtable.max_direct_rows]) - + first_row_bits) + + 1; + for (u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { + size_t v; /* Local index variable */ + + for (v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) + if (H5F_addr_defined(iblock->ents[entry].addr)) + if (H5HF__man_iblock_size(f, hdr, iblock->ents[entry].addr, num_indirect_rows, iblock, + entry, heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, + "unable to get fractal heap storage info for indirect block") } /* end for */ - } /* end if */ + } /* end if */ done: /* Release the indirect block */ - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_size() */ - /*------------------------------------------------------------------------- * * Function: H5HF_man_iblock_parent_info @@ -1762,14 +1784,14 @@ H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, *------------------------------------------------------------------------- */ herr_t -H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, - hsize_t *ret_par_block_off, unsigned *ret_entry) +H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, hsize_t *ret_par_block_off, + unsigned *ret_entry) { - hsize_t par_block_off; /* Offset of parent within heap */ - hsize_t prev_par_block_off; /* Offset of previous parent block within heap */ - unsigned row, col; /* Row & column for block */ - unsigned prev_row = 0, prev_col = 0;/* Previous row & column for block */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t par_block_off; /* Offset of parent within heap */ + hsize_t prev_par_block_off; /* Offset of previous parent block within heap */ + unsigned row, col; /* Row & column for block */ + unsigned prev_row = 0, prev_col = 0; /* Previous row & column for block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1781,7 +1803,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, HDassert(ret_entry); /* Look up row & column for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, block_off, &row, &col) < 0) + if (H5HF__dtable_lookup(&hdr->man_dtable, block_off, &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of block") /* Sanity check - first lookup must be an indirect block */ @@ -1791,7 +1813,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, * use previous (i.e. parent's) offset, row, and column. */ prev_par_block_off = par_block_off = 0; - while(row >= hdr->man_dtable.max_direct_rows) { + while (row >= hdr->man_dtable.max_direct_rows) { /* Retain previous parent block offset */ prev_par_block_off = par_block_off; @@ -1805,7 +1827,7 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, prev_col = col; /* Look up row & column in new indirect block for object */ - if(H5HF_dtable_lookup(&hdr->man_dtable, (block_off - par_block_off), &row, &col) < 0) + if (H5HF__dtable_lookup(&hdr->man_dtable, (block_off - par_block_off), &row, &col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of block") } /* end while */ @@ -1815,15 +1837,14 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, /* Set return parameters */ *ret_par_block_off = prev_par_block_off; - *ret_entry = (prev_row * hdr->man_dtable.cparam.width) + prev_col; + *ret_entry = (prev_row * hdr->man_dtable.cparam.width) + prev_col; done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_par_info() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iblock_dest + * Function: H5HF__man_iblock_dest * * Purpose: Destroys a fractal heap indirect block in memory. * @@ -1835,11 +1856,11 @@ H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, *------------------------------------------------------------------------- */ herr_t -H5HF_man_iblock_dest(H5HF_indirect_t *iblock) +H5HF__man_iblock_dest(H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -1849,18 +1870,19 @@ H5HF_man_iblock_dest(H5HF_indirect_t *iblock) /* Decrement reference count on shared info */ HDassert(iblock->hdr); - if(H5HF_hdr_decr(iblock->hdr) < 0) + if (H5HF__hdr_decr(iblock->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(iblock->parent) - if(H5HF__iblock_decr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (iblock->parent) + if (H5HF__iblock_decr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Release entry tables */ - if(iblock->ents) + if (iblock->ents) iblock->ents = H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); - if(iblock->filt_ents) + if (iblock->filt_ents) iblock->filt_ents = H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); - if(iblock->child_iblocks) + if (iblock->child_iblocks) iblock->child_iblocks = H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); /* Free fractal heap indirect block info */ @@ -1868,5 +1890,4 @@ H5HF_man_iblock_dest(H5HF_indirect_t *iblock) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iblock_dest() */ - +} /* end H5HF__man_iblock_dest() */ diff --git a/src/H5HFiter.c b/src/H5HFiter.c index c5757b77a1d..673c54398c4 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,47 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -74,10 +67,8 @@ /* Declare a free list to manage the H5HF_block_loc_t struct */ H5FL_DEFINE(H5HF_block_loc_t); - - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_init + * Function: H5HF__man_iter_init * * Purpose: Initialize a block iterator for walking over all the blocks * in a fractal heap. (initialization finishes when iterator is @@ -91,9 +82,9 @@ H5FL_DEFINE(H5HF_block_loc_t); *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_init(H5HF_block_iter_t *biter) +H5HF__man_iter_init(H5HF_block_iter_t *biter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -104,9 +95,8 @@ H5HF_man_iter_init(H5HF_block_iter_t *biter) HDmemset(biter, 0, sizeof(H5HF_block_iter_t)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iter_init() */ +} /* end H5HF__man_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_iter_start_offset * @@ -121,19 +111,18 @@ H5HF_man_iter_init(H5HF_block_iter_t *biter) *------------------------------------------------------------------------- */ herr_t -H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t offset) +H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t offset) { - H5HF_indirect_t *iblock; /* Indirect block for location context */ - haddr_t iblock_addr; /* Address of indirect block */ - unsigned iblock_nrows; /* # of rows in indirect block */ - H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */ - unsigned iblock_par_entry; /* Entry within parent indirect block */ - hsize_t curr_offset; /* Current offset, as adjusted */ - unsigned row; /* Current row we are on */ - unsigned col; /* Column in row */ - hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock; /* Indirect block for location context */ + haddr_t iblock_addr; /* Address of indirect block */ + unsigned iblock_nrows; /* # of rows in indirect block */ + H5HF_indirect_t *iblock_parent; /* Parent indirect block of location context */ + unsigned iblock_par_entry; /* Entry within parent indirect block */ + hsize_t curr_offset; /* Current offset, as adjusted */ + unsigned row; /* Current row we are on */ + unsigned col; /* Column in row */ + hbool_t root_block = TRUE; /* Flag to indicate the current block is the root indirect block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -147,30 +136,31 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, HDassert(offset >= hdr->man_dtable.cparam.start_block_size); /* Allocate level structure */ - if(NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") - -/* -1: = offset> - - - - max_direct_rows> - - - - - - -*/ + if (NULL == (biter->curr = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") + + /* + 1: = offset> + + + + max_direct_rows> + + + + + + + */ do { - hbool_t did_protect; /* Whether we protected the indirect block or not */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ /* Walk down the rows in the doubling table until we've found the correct row for the next block */ - for(row = 0; row < hdr->man_dtable.max_root_rows; row++) - if((offset >= hdr->man_dtable.row_block_off[row]) && - (offset < hdr->man_dtable.row_block_off[row] + - (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row]))) + for (row = 0; row < hdr->man_dtable.max_root_rows; row++) + if ((offset >= hdr->man_dtable.row_block_off[row]) && + (offset < hdr->man_dtable.row_block_off[row] + + (hdr->man_dtable.cparam.width * hdr->man_dtable.row_block_size[row]))) break; /* Adjust offset by row offset */ @@ -181,15 +171,15 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, col = (unsigned)(curr_offset / hdr->man_dtable.row_block_size[row]); /* Set the current level's context */ - biter->curr->row = row; - biter->curr->col = col; + biter->curr->row = row; + biter->curr->col = col; biter->curr->entry = (row * hdr->man_dtable.cparam.width) + col; /* Get the context indirect block's information */ - if(root_block) { - iblock_addr = hdr->man_dtable.table_addr; - iblock_nrows = hdr->man_dtable.curr_root_rows; - iblock_parent = NULL; + if (root_block) { + iblock_addr = hdr->man_dtable.table_addr; + iblock_nrows = hdr->man_dtable.curr_root_rows; + iblock_parent = NULL; iblock_par_entry = 0; /* The root block can't go up further... */ @@ -199,49 +189,54 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, root_block = FALSE; } /* end if */ else { - hsize_t child_size; /* Size of new indirect block to create */ + hsize_t child_size; /* Size of new indirect block to create */ /* Retrieve the parent information from the previous context location */ - iblock_parent = biter->curr->up->context; + iblock_parent = biter->curr->up->context; iblock_par_entry = biter->curr->up->entry; /* Look up the address of context indirect block */ iblock_addr = iblock_parent->ents[iblock_par_entry].addr; /* Compute # of rows in context indirect block */ - child_size = hdr->man_dtable.row_block_size[biter->curr->up->row]; + child_size = hdr->man_dtable.row_block_size[biter->curr->up->row]; iblock_nrows = (H5VM_log2_gen(child_size) - hdr->man_dtable.first_row_bits) + 1; } /* end else */ /* Load indirect block for this context location */ - if(NULL == (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent, iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + if (NULL == + (iblock = H5HF__man_iblock_protect(hdr, iblock_addr, iblock_nrows, iblock_parent, + iblock_par_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") /* Make indirect block the context for the current location */ biter->curr->context = iblock; /* Hold the indirect block with the location */ - if(H5HF_iblock_incr(biter->curr->context) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") + if (H5HF__iblock_incr(biter->curr->context) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, + "can't increment reference count on shared indirect block") /* Release the current indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; /* See if the location falls in a direct block row */ /* Or, if the offset has just filled up a direct or indirect block */ - if(curr_offset == (col * hdr->man_dtable.row_block_size[row]) || row < hdr->man_dtable.max_direct_rows) { + if (curr_offset == (col * hdr->man_dtable.row_block_size[row]) || + row < hdr->man_dtable.max_direct_rows) { HDassert(curr_offset - (col * hdr->man_dtable.row_block_size[row]) == 0); - break; /* Done now */ - } /* end if */ + break; /* Done now */ + } /* end if */ /* Indirect block row */ else { - H5HF_block_loc_t *new_loc; /* Pointer to new block location */ + H5HF_block_loc_t *new_loc; /* Pointer to new block location */ /* Allocate level structure */ - if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Link new level into iterator */ new_loc->up = biter->curr; @@ -251,8 +246,8 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, /* Make new block the current context */ biter->curr = new_loc; - } /* end else */ - } while(1); /* Breaks out in middle */ + } /* end else */ + } while (1); /* Breaks out in middle */ /* Set flag to indicate block iterator finished initializing */ biter->ready = TRUE; @@ -261,9 +256,8 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iter_start_offset() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_set_entry + * Function: H5HF__man_iter_set_entry * * Purpose: Set the current entry for the iterator * @@ -275,9 +269,9 @@ H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned entry) +H5HF__man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned entry) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -286,15 +280,14 @@ H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigne /* Set location context */ biter->curr->entry = entry; - biter->curr->row = entry / hdr->man_dtable.cparam.width; - biter->curr->col = entry % hdr->man_dtable.cparam.width; + biter->curr->row = entry / hdr->man_dtable.cparam.width; + biter->curr->col = entry % hdr->man_dtable.cparam.width; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iter_set_entry() */ +} /* end H5HF__man_iter_set_entry() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_start_entry + * Function: H5HF__man_iter_start_entry * * Purpose: Initialize a block iterator to a particular location within * an indirect block @@ -307,13 +300,13 @@ H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigne *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - H5HF_indirect_t *iblock, unsigned start_entry) +H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, H5HF_indirect_t *iblock, + unsigned start_entry) { - H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *new_loc = NULL; /* Pointer to new block location */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -324,18 +317,19 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, HDassert(iblock); /* Create new location for iterator */ - if(NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (new_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Set up location context */ - new_loc->entry = start_entry; - new_loc->row = start_entry / hdr->man_dtable.cparam.width; - new_loc->col = start_entry % hdr->man_dtable.cparam.width; + new_loc->entry = start_entry; + new_loc->row = start_entry / hdr->man_dtable.cparam.width; + new_loc->col = start_entry % hdr->man_dtable.cparam.width; new_loc->context = iblock; - new_loc->up = NULL; + new_loc->up = NULL; /* Increment reference count on indirect block */ - if(H5HF_iblock_incr(new_loc->context) < 0) + if (H5HF__iblock_incr(new_loc->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Make new location the current location */ @@ -345,15 +339,14 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, biter->ready = TRUE; done: - if(ret_value < 0 && new_loc) + if (ret_value < 0 && new_loc) new_loc = H5FL_FREE(H5HF_block_loc_t, new_loc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iter_start_entry() */ +} /* end H5HF__man_iter_start_entry() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_reset + * Function: H5HF__man_iter_reset * * Purpose: Reset a block iterator to it's initial state, freeing any * location context it currently has @@ -366,11 +359,11 @@ H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_reset(H5HF_block_iter_t *biter) +H5HF__man_iter_reset(H5HF_block_iter_t *biter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -378,20 +371,21 @@ H5HF_man_iter_reset(H5HF_block_iter_t *biter) HDassert(biter); /* Free any location contexts that exist */ - if(biter->curr) { - H5HF_block_loc_t *curr_loc; /* Pointer to current block location */ - H5HF_block_loc_t *next_loc; /* Pointer to next block location */ + if (biter->curr) { + H5HF_block_loc_t *curr_loc; /* Pointer to current block location */ + H5HF_block_loc_t *next_loc; /* Pointer to next block location */ /* Free location contexts */ curr_loc = biter->curr; - while(curr_loc) { + while (curr_loc) { /* Get pointer to next node */ next_loc = curr_loc->up; /* If this node is holding an indirect block, release the block */ - if(curr_loc->context) - if(H5HF__iblock_decr(curr_loc->context) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + if (curr_loc->context) + if (H5HF__iblock_decr(curr_loc->context) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared indirect block") /* Free the current location context */ curr_loc = H5FL_FREE(H5HF_block_loc_t, curr_loc); @@ -409,11 +403,10 @@ H5HF_man_iter_reset(H5HF_block_iter_t *biter) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iter_reset() */ +} /* end H5HF__man_iter_reset() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_next + * Function: H5HF__man_iter_next * * Purpose: Advance to the next block within the current block of the heap * @@ -425,9 +418,9 @@ H5HF_man_iter_reset(H5HF_block_iter_t *biter) *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) +H5HF__man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -441,14 +434,13 @@ H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) biter->curr->entry += nentries; biter->curr->row = biter->curr->entry / hdr->man_dtable.cparam.width; biter->curr->col = biter->curr->entry % hdr->man_dtable.cparam.width; -/* HDassert(biter->curr->row <= biter->curr->context->nrows); */ + /* HDassert(biter->curr->row <= biter->curr->context->nrows); */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iter_next() */ +} /* end H5HF__man_iter_next() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_up + * Function: H5HF__man_iter_up * * Purpose: Move iterator up one level * @@ -460,12 +452,12 @@ H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries) *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_up(H5HF_block_iter_t *biter) +H5HF__man_iter_up(H5HF_block_iter_t *biter) { - H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *up_loc; /* Pointer to 'up' block location */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -477,7 +469,7 @@ H5HF_man_iter_up(H5HF_block_iter_t *biter) HDassert(biter->curr->context); /* Release hold on current location's indirect block */ - if(H5HF__iblock_decr(biter->curr->context) < 0) + if (H5HF__iblock_decr(biter->curr->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Get pointer to location context above this one */ @@ -491,11 +483,10 @@ H5HF_man_iter_up(H5HF_block_iter_t *biter) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iter_up() */ +} /* end H5HF__man_iter_up() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_down + * Function: H5HF__man_iter_down * * Purpose: Move iterator down one level * @@ -507,12 +498,12 @@ H5HF_man_iter_up(H5HF_block_iter_t *biter) *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) +H5HF__man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) { - H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_block_loc_t *down_loc = NULL; /* Pointer to new 'down' block location */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -523,33 +514,33 @@ H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) HDassert(biter->curr->context); /* Create new location to move down to */ - if(NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for direct block free list section") + if (NULL == (down_loc = H5FL_MALLOC(H5HF_block_loc_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for direct block free list section") /* Initialize down location */ - down_loc->row = 0; - down_loc->col = 0; - down_loc->entry = 0; + down_loc->row = 0; + down_loc->col = 0; + down_loc->entry = 0; down_loc->context = iblock; - down_loc->up = biter->curr; + down_loc->up = biter->curr; /* Increment reference count on indirect block */ - if(H5HF_iblock_incr(down_loc->context) < 0) + if (H5HF__iblock_incr(down_loc->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Make down location the current location */ biter->curr = down_loc; done: - if(ret_value < 0 && down_loc) + if (ret_value < 0 && down_loc) down_loc = H5FL_FREE(H5HF_block_loc_t, down_loc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_man_iter_down() */ +} /* end H5HF__man_iter_down() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_curr + * Function: H5HF__man_iter_curr * * Purpose: Retrieve information about the current block iterator location * @@ -561,10 +552,10 @@ H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock) *------------------------------------------------------------------------- */ herr_t -H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, - unsigned *entry, H5HF_indirect_t **block) +H5HF__man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, unsigned *entry, + H5HF_indirect_t **block) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -573,60 +564,20 @@ H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, HDassert(biter->ready); /* Retrieve the information asked for */ - if(row) + if (row) *row = biter->curr->row; - if(col) + if (col) *col = biter->curr->col; - if(entry) + if (entry) *entry = biter->curr->entry; - if(block) + if (block) *block = biter->curr->context; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iter_curr() */ - - -/*------------------------------------------------------------------------- - * Function: H5HF_man_iter_offset - * - * Purpose: Retrieve offset of iterator in heap - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Apr 25 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset) -{ - hsize_t curr_offset; /* For computing offset in heap */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* - * Check arguments. - */ - HDassert(biter); - HDassert(biter->ready); - HDassert(biter->curr->context); - HDassert(offset); - - /* Compute the offset in the heap */ - curr_offset = biter->curr->context->block_off; - curr_offset += hdr->man_dtable.row_block_off[biter->curr->row]; - curr_offset += biter->curr->col * hdr->man_dtable.row_block_size[biter->curr->row]; - - /* Assign the return value */ - *offset = curr_offset; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_iter_offset() */ +} /* end H5HF__man_iter_curr() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_iter_ready + * Function: H5HF__man_iter_ready * * Purpose: Query if iterator is ready to use * @@ -638,9 +589,9 @@ H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t *offset) *------------------------------------------------------------------------- */ hbool_t -H5HF_man_iter_ready(H5HF_block_iter_t *biter) +H5HF__man_iter_ready(H5HF_block_iter_t *biter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -648,5 +599,4 @@ H5HF_man_iter_ready(H5HF_block_iter_t *biter) HDassert(biter); FUNC_LEAVE_NOAPI(biter->ready) -} /* end H5HF_man_iter_ready() */ - +} /* end H5HF__man_iter_ready() */ diff --git a/src/H5HFman.c b/src/H5HFman.c index 68c707e8bcf..427be0026a7 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,18 +26,17 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ @@ -45,50 +44,43 @@ /* Macro to check if we can apply all filters in the pipeline. Use whenever * performing a modification operation */ - #define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \ -{ \ - if(!((HDR)->checked_filters)) { \ - if((HDR)->pline.nused) \ - if(H5Z_can_apply_direct(&((HDR)->pline)) < 0) \ - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \ - \ - (HDR)->checked_filters = TRUE; \ - } /* end if */ \ -} - +#define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \ + { \ + if (!((HDR)->checked_filters)) { \ + if ((HDR)->pline.nused) \ + if (H5Z_can_apply_direct(&((HDR)->pline)) < 0) \ + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \ + \ + (HDR)->checked_filters = TRUE; \ + } /* end if */ \ + } /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data, unsigned op_flags); +static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data, + unsigned op_flags); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__man_insert * @@ -104,14 +96,14 @@ static herr_t H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, 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 */ - 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 */ - 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 */ + H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section */ + 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 */ + 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 */ FUNC_ENTER_PACKAGE @@ -127,37 +119,38 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) H5HF_MAN_WRITE_CHECK_PLINE(hdr) /* Look for free space */ - if((node_found = H5HF__space_find(hdr, (hsize_t)obj_size, &sec_node)) < 0) + if ((node_found = H5HF__space_find(hdr, (hsize_t)obj_size, &sec_node)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap") /* If we didn't find a node, go create a direct block big enough to hold the requested block */ - if(!node_found) + if (!node_found) /* Allocate direct block big enough to hold requested size */ - if(H5HF__man_dblock_new(hdr, obj_size, &sec_node) < 0) + if (H5HF__man_dblock_new(hdr, obj_size, &sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create fractal heap direct block") /* Check for row section */ - if(sec_node->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sec_node->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW) { + if (sec_node->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || + sec_node->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW) { /* Allocate 'single' selection out of 'row' selection */ - if(H5HF__man_iblock_alloc_row(hdr, &sec_node) < 0) + if (H5HF__man_iblock_alloc_row(hdr, &sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up row section") } /* end if */ HDassert(sec_node->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Check for 'single' section being serialized */ - if(sec_node->sect_info.state == H5FS_SECT_SERIALIZED) - if(H5HF__sect_single_revive(hdr, sec_node) < 0) + if (sec_node->sect_info.state == H5FS_SECT_SERIALIZED) + if (H5HF__sect_single_revive(hdr, sec_node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") HDassert(sec_node->sect_info.state == H5FS_SECT_LIVE); /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, sec_node, &dblock_addr, &dblock_size) < 0) + if (H5HF__sect_single_dblock_info(hdr, sec_node, &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sec_node->u.single.parent, sec_node->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sec_node->u.single.parent, + sec_node->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") /* Insert object into block */ @@ -170,13 +163,13 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) HDassert(sec_node->sect_info.size >= obj_size); /* Reduce (& possibly re-add) single section */ - if(H5HF__sect_single_reduce(hdr, sec_node, obj_size) < 0) + if (H5HF__sect_single_reduce(hdr, sec_node, obj_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce single section node") sec_node = NULL; /* Encode the object in the block */ { - uint8_t *p; /* Temporary pointer to obj info in block */ + uint8_t *p; /* Temporary pointer to obj info in block */ /* Point to location for object */ p = dblock->blk + blk_off; @@ -196,25 +189,24 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) hdr->man_nobjs++; /* Reduce space available in heap (marks header dirty) */ - if(H5HF_hdr_adj_free(hdr, -(ssize_t)obj_size) < 0) + if (H5HF__hdr_adj_free(hdr, -(ssize_t)obj_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap") done: /* Release section node on error */ - if(ret_value < 0) - if(sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) + if (ret_value < 0) + if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") /* Release the direct block (marked as dirty) */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_insert() */ - /*------------------------------------------------------------------------- - * Function: H5HF_man_get_obj_len + * Function: H5HF__man_get_obj_len * * Purpose: Get the size of a managed heap object * @@ -226,10 +218,10 @@ H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) *------------------------------------------------------------------------- */ herr_t -H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) +H5HF__man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -248,9 +240,8 @@ H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) UINT64DECODE_VAR(id, *obj_len_p, hdr->heap_len_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_man_get_obj_len() */ +} /* end H5HF__man_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_get_obj_off * @@ -284,7 +275,6 @@ H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off FUNC_LEAVE_NOAPI_VOID } /* end H5HF__man_get_obj_off() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_op_real * @@ -299,23 +289,22 @@ H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off *------------------------------------------------------------------------- */ static herr_t -H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data, unsigned op_flags) +H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data, unsigned op_flags) { H5HF_direct_t *dblock = NULL; /* Pointer to direct block to query */ - unsigned dblock_access_flags; /* Access method for direct block */ + unsigned dblock_access_flags; /* Access method for direct block */ /* must equal either * H5AC__NO_FLAGS_SET or * H5AC__READ_ONLY_FLAG */ - haddr_t dblock_addr; /* Direct block address */ - size_t dblock_size; /* Direct block size */ - unsigned dblock_cache_flags; /* Flags for unprotecting direct block */ - hsize_t obj_off; /* Object's offset in heap */ - size_t obj_len; /* Object's length in heap */ - size_t blk_off; /* Offset of object in block */ + haddr_t dblock_addr = HADDR_UNDEF; /* Direct block address */ + size_t dblock_size; /* Direct block size */ + unsigned dblock_cache_flags = 0; /* Flags for unprotecting direct block */ + hsize_t obj_off; /* Object's offset in heap */ + size_t obj_len; /* Object's length in heap */ + size_t blk_off; /* Offset of object in block */ uint8_t *p; /* Temporary pointer to obj info in block */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -327,16 +316,16 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, HDassert(op); /* Set the access mode for the direct block */ - if(op_flags & H5HF_OP_MODIFY) { + if (op_flags & H5HF_OP_MODIFY) { /* Check pipeline */ H5HF_MAN_WRITE_CHECK_PLINE(hdr) dblock_access_flags = H5AC__NO_FLAGS_SET; - dblock_cache_flags = H5AC__DIRTIED_FLAG; + dblock_cache_flags = H5AC__DIRTIED_FLAG; } /* end if */ else { dblock_access_flags = H5AC__READ_ONLY_FLAG; - dblock_cache_flags = H5AC__NO_FLAGS_SET; + dblock_cache_flags = H5AC__NO_FLAGS_SET; } /* end else */ /* Skip over the flag byte */ @@ -347,61 +336,66 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size); /* Check for bad offset or length */ - if(obj_off == 0) + if (obj_off == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap offset") - if(obj_off > hdr->man_size) + if (obj_off > hdr->man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large") - if(obj_len == 0) + if (obj_len == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap object size") - if(obj_len > hdr->man_dtable.cparam.max_direct_size) + if (obj_len > hdr->man_dtable.cparam.max_direct_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block") - if(obj_len > hdr->max_man_size) + if (obj_len > hdr->max_man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone") /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set direct block info */ dblock_addr = hdr->man_dtable.table_addr; dblock_size = hdr->man_dtable.cparam.start_block_size; /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, NULL, 0, dblock_access_flags))) + if (NULL == + (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, NULL, 0, dblock_access_flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - unsigned entry; /* Entry of block */ + H5HF_indirect_t *iblock; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + unsigned entry; /* Entry of block */ /* Look up indirect block containing direct block */ - if(H5HF__man_dblock_locate(hdr, obj_off, &iblock, &entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, obj_off, &iblock, &entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Set direct block info */ - dblock_addr = iblock->ents[entry].addr; - H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); - dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; + dblock_addr = iblock->ents[entry].addr; + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, + size_t); + dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; /* Check for offset of invalid direct block */ - if(!H5F_addr_defined(dblock_addr)) { + if (!H5F_addr_defined(dblock_addr)) { /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block") } /* end if */ /* Lock direct block */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, iblock, entry, dblock_access_flags))) { + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, iblock, entry, + dblock_access_flags))) { /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block") } /* end if */ /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; } /* end else */ @@ -411,29 +405,28 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, blk_off = (size_t)(obj_off - dblock->block_off); /* Check for object's offset in the direct block prefix information */ - if(blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) + if (blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block") /* Check for object's length overrunning the end of the direct block */ - if((blk_off + obj_len) > dblock_size) + if ((blk_off + obj_len) > dblock_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block") /* Point to location for object */ p = dblock->blk + blk_off; /* Call the user's 'op' callback */ - if(op(p, obj_len, op_data) < 0) + if (op(p, obj_len, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") done: /* Unlock direct block */ - if(dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0) + if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_op_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_read * @@ -449,7 +442,7 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, herr_t H5HF__man_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -461,14 +454,13 @@ H5HF__man_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine routine */ - if(H5HF__man_op_real(hdr, id, H5HF_op_read, obj, 0) < 0) + if (H5HF__man_op_real(hdr, id, H5HF__op_read, obj, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_read() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_write * @@ -484,7 +476,7 @@ H5HF__man_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) herr_t H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -497,14 +489,13 @@ H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Call the internal 'op' routine routine */ /* (Casting away const OK - QAK) */ - if(H5HF__man_op_real(hdr, id, H5HF_op_write, (void *)obj, H5HF_OP_MODIFY) < 0) + if (H5HF__man_op_real(hdr, id, H5HF__op_write, (void *)obj, H5HF_OP_MODIFY) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_write() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_op * @@ -520,7 +511,7 @@ H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -532,14 +523,13 @@ H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_da HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF__man_op_real(hdr, id, op, op_data, 0) < 0) + if (H5HF__man_op_real(hdr, id, op, op_data, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_op() */ - /*------------------------------------------------------------------------- * Function: H5HF__man_remove * @@ -555,16 +545,16 @@ H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_da 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 */ - hbool_t did_protect; /* 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 */ - size_t dblock_size; /* Direct block size */ - hsize_t dblock_block_off; /* Offset of the direct block within the heap's address space */ - unsigned dblock_entry; /* Entry of direct block in parent indirect block */ - size_t blk_off; /* Offset of object in block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section for 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 */ + size_t dblock_size; /* Direct block size */ + hsize_t dblock_block_off; /* Offset of the direct block within the heap's address space */ + unsigned dblock_entry; /* Entry of direct block in parent indirect block */ + size_t blk_off; /* Offset of object in block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -585,42 +575,45 @@ H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size); /* Check for bad offset or length */ - if(obj_off == 0) + if (obj_off == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap offset") - if(obj_off > hdr->man_size) + if (obj_off > hdr->man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large") - if(obj_len == 0) + if (obj_len == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "invalid fractal heap object size") - if(obj_len > hdr->man_dtable.cparam.max_direct_size) + if (obj_len > hdr->man_dtable.cparam.max_direct_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block") - if(obj_len > hdr->max_man_size) + if (obj_len > hdr->max_man_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone") /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set direct block info */ - dblock_size = hdr->man_dtable.cparam.start_block_size; + dblock_size = hdr->man_dtable.cparam.start_block_size; dblock_block_off = 0; - dblock_entry = 0; + dblock_entry = 0; } /* end if */ else { /* Look up indirect block containing direct block */ - if(H5HF__man_dblock_locate(hdr, obj_off, &iblock, &dblock_entry, &did_protect, H5AC__NO_FLAGS_SET) < 0) + if (H5HF__man_dblock_locate(hdr, obj_off, &iblock, &dblock_entry, &did_protect, H5AC__NO_FLAGS_SET) < + 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Check for offset of invalid direct block */ - if(!H5F_addr_defined(iblock->ents[dblock_entry].addr)) + if (!H5F_addr_defined(iblock->ents[dblock_entry].addr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block") /* Set direct block info */ - H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); - dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]); + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), + hsize_t, size_t); + dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]); /* Compute the direct block's offset in the heap's address space */ /* (based on parent indirect block's block offset) */ dblock_block_off = iblock->block_off; dblock_block_off += hdr->man_dtable.row_block_off[dblock_entry / hdr->man_dtable.cparam.width]; - dblock_block_off += hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width] * (dblock_entry % hdr->man_dtable.cparam.width); + dblock_block_off += hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width] * + (dblock_entry % hdr->man_dtable.cparam.width); } /* end else */ /* Compute offset of object within block */ @@ -628,47 +621,46 @@ H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) blk_off = (size_t)(obj_off - dblock_block_off); /* Check for object's offset in the direct block prefix information */ - if(blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) + if (blk_off < (size_t)H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr)) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block") /* Check for object's length overrunning the end of the direct block */ - if((blk_off + obj_len) > dblock_size) + if ((blk_off + obj_len) > dblock_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block") /* Create free space section node */ - if(NULL == (sec_node = H5HF_sect_single_new(obj_off, obj_len, iblock, dblock_entry))) + if (NULL == (sec_node = H5HF__sect_single_new(obj_off, obj_len, iblock, dblock_entry))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create section for direct block's free space") /* Unlock indirect block */ - if(iblock) { - if(H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock) { + if (H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") iblock = NULL; } /* end if */ /* Increase space available in heap (marks header dirty) */ - if(H5HF_hdr_adj_free(hdr, (ssize_t)obj_len) < 0) + if (H5HF__hdr_adj_free(hdr, (ssize_t)obj_len) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap") /* Update statistics about heap */ hdr->man_nobjs--; /* Return free space to the heap's list of space */ - if(H5HF__space_add(hdr, sec_node, H5FS_ADD_RETURNED_SPACE) < 0) + if (H5HF__space_add(hdr, sec_node, H5FS_ADD_RETURNED_SPACE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list") sec_node = NULL; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Release section node */ - if(sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) + if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") } /* end if */ /* Unlock indirect block */ - if(iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_remove() */ - diff --git a/src/H5HFmodule.h b/src/H5HFmodule.h index 03346732ccc..7fab61185f3 100644 --- a/src/H5HFmodule.h +++ b/src/H5HFmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5HF package. Including this header means that the source file * is part of the H5HF package. */ -#ifndef _H5HFmodule_H -#define _H5HFmodule_H +#ifndef H5HFmodule_H +#define H5HFmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5HF_MODULE -#define H5_MY_PKG H5HF -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO - -#endif /* _H5HFmodule_H */ +#define H5_MY_PKG H5HF +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO +#endif /* H5HFmodule_H */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 7e6529f3add..893a65d4f15 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,159 +23,160 @@ #error "Do not include this file outside the H5HF package!" #endif -#ifndef _H5HFpkg_H -#define _H5HFpkg_H +#ifndef H5HFpkg_H +#define H5HFpkg_H /* Get package's private header */ #include "H5HFprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5B2private.h" /* v2 B-trees */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FSprivate.h" /* Free space manager */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FSprivate.h" /* Free space manager */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ /* Size of checksum information (on disk) */ -#define H5HF_SIZEOF_CHKSUM 4 +#define H5HF_SIZEOF_CHKSUM 4 /* "Standard" size of prefix information for fractal heap metadata */ -#define H5HF_METADATA_PREFIX_SIZE(c) ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + (unsigned)1 /* Version */ \ - + ((c) ? (unsigned)H5HF_SIZEOF_CHKSUM : (unsigned)0) /* Metadata checksum */ \ +#define H5HF_METADATA_PREFIX_SIZE(c) \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + (unsigned)1 /* Version */ \ + + ((c) ? (unsigned)H5HF_SIZEOF_CHKSUM : (unsigned)0) /* Metadata checksum */ \ ) /* Size of doubling-table information */ -#define H5HF_DTABLE_INFO_SIZE(h) ( \ - (unsigned)2 /* Width of table (i.e. # of columns) */ \ - + (unsigned)(h)->sizeof_size /* Starting block size */ \ - + (unsigned)(h)->sizeof_size /* Maximum direct block size */ \ - + (unsigned)2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \ - + (unsigned)2 /* Starting # of rows in root indirect block */ \ - + (unsigned)(h)->sizeof_addr /* File address of table managed */ \ - + (unsigned)2 /* Current # of rows in root indirect block */ \ +#define H5HF_DTABLE_INFO_SIZE(h) \ + ((unsigned)2 /* Width of table (i.e. # of columns) */ \ + + (unsigned)(h)->sizeof_size /* Starting block size */ \ + + (unsigned)(h)->sizeof_size /* Maximum direct block size */ \ + + (unsigned)2 /* Max. size of heap (log2 of actual value - i.e. the # of bits) */ \ + + (unsigned)2 /* Starting # of rows in root indirect block */ \ + + (unsigned)(h)->sizeof_addr /* File address of table managed */ \ + + (unsigned)2 /* Current # of rows in root indirect block */ \ ) /* Flags for status byte */ -#define H5HF_HDR_FLAGS_HUGE_ID_WRAPPED 0x01 /* "huge" object IDs have wrapped */ -#define H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS 0x02 /* checksum direct blocks */ +#define H5HF_HDR_FLAGS_HUGE_ID_WRAPPED 0x01 /* "huge" object IDs have wrapped */ +#define H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS 0x02 /* checksum direct blocks */ /* Size of the fractal heap header on disk */ /* (this is the fixed-len portion, the variable-len I/O filter information * follows this information, if there are I/O filters for the heap) */ -#define H5HF_HEADER_SIZE(h) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Fractal Heap Header specific fields */ \ - \ - /* General heap information */ \ - + (unsigned)2 /* Heap ID len */ \ - + (unsigned)2 /* I/O filters' encoded len */ \ - + (unsigned)1 /* Status flags */ \ - \ - /* "Huge" object fields */ \ - + (unsigned)4 /* Max. size of "managed" object */ \ - + (unsigned)(h)->sizeof_size /* Next ID for "huge" object */ \ - + (unsigned)(h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \ - \ - /* "Managed" object free space fields */ \ - + (unsigned)(h)->sizeof_size /* Total man. free space */ \ - + (unsigned)(h)->sizeof_addr /* File address of free section header */ \ - \ - /* Statistics fields */ \ - + (unsigned)(h)->sizeof_size /* Size of man. space in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of man. space iterator offset in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of alloacted man. space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of man. objects in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of huge space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of huge objects in heap */ \ - + (unsigned)(h)->sizeof_size /* Size of tiny space in heap */ \ - + (unsigned)(h)->sizeof_size /* Number of tiny objects in heap */ \ - \ - /* "Managed" object doubling table info */ \ - + H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \ +#define H5HF_HEADER_SIZE(h) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Fractal Heap Header specific fields */ \ + \ + /* General heap information */ \ + + (unsigned)2 /* Heap ID len */ \ + + (unsigned)2 /* I/O filters' encoded len */ \ + + (unsigned)1 /* Status flags */ \ + \ + /* "Huge" object fields */ \ + + (unsigned)4 /* Max. size of "managed" object */ \ + + (unsigned)(h)->sizeof_size /* Next ID for "huge" object */ \ + + (unsigned)(h)->sizeof_addr /* File address of "huge" object tracker B-tree */ \ + \ + /* "Managed" object free space fields */ \ + + (unsigned)(h)->sizeof_size /* Total man. free space */ \ + + (unsigned)(h)->sizeof_addr /* File address of free section header */ \ + \ + /* Statistics fields */ \ + + (unsigned)(h)->sizeof_size /* Size of man. space in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of man. space iterator offset in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of alloacted man. space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of man. objects in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of huge space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of huge objects in heap */ \ + + (unsigned)(h)->sizeof_size /* Size of tiny space in heap */ \ + + (unsigned)(h)->sizeof_size /* Number of tiny objects in heap */ \ + \ + /* "Managed" object doubling table info */ \ + + H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \ ) /* Size of overhead for a direct block */ -#define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks) \ - \ - /* Fractal heap managed, absolutely mapped direct block specific fields */ \ - + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ - + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ +#define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(h->checksum_dblocks) \ + \ + /* Fractal heap managed, absolutely mapped direct block specific fields */ \ + + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ + + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ ) /* Size of managed indirect block entry for a child direct block */ -#define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) ( \ - ((h)->filter_len > 0 ? \ - ((unsigned)(h)->sizeof_addr + (unsigned)(h)->sizeof_size + (unsigned)4) : /* Size of entries for filtered direct blocks */ \ - (unsigned)(h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \ +#define H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h) \ + (((h)->filter_len > 0 ? ((unsigned)(h)->sizeof_addr + (unsigned)(h)->sizeof_size + (unsigned)4) \ + : /* Size of entries for filtered direct blocks */ \ + (unsigned)(h)->sizeof_addr) /* Size of entries for un-filtered direct blocks */ \ ) /* Size of managed indirect block */ -#define H5HF_MAN_INDIRECT_SIZE(h, r) ( \ - /* General metadata fields */ \ - H5HF_METADATA_PREFIX_SIZE(TRUE) \ - \ - /* Fractal heap managed, absolutely mapped indirect block specific fields */ \ - + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ - + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ - + (MIN(r, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \ - + (((r > (h)->man_dtable.max_direct_rows) ? (r - (h)->man_dtable.max_direct_rows) : 0) * (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \ +#define H5HF_MAN_INDIRECT_SIZE(h, r) \ + (/* General metadata fields */ \ + H5HF_METADATA_PREFIX_SIZE(TRUE) \ + \ + /* Fractal heap managed, absolutely mapped indirect block specific fields */ \ + + (unsigned)(h)->sizeof_addr /* File address of heap owning the block */ \ + + (unsigned)(h)->heap_off_size /* Offset of the block in the heap */ \ + + (MIN(r, (h)->man_dtable.max_direct_rows) * (h)->man_dtable.cparam.width * \ + H5HF_MAN_INDIRECT_CHILD_DIR_ENTRY_SIZE(h)) /* Size of entries for direct blocks */ \ + + (((r > (h)->man_dtable.max_direct_rows) ? (r - (h)->man_dtable.max_direct_rows) : 0) * \ + (h)->man_dtable.cparam.width * (h)->sizeof_addr) /* Size of entries for indirect blocks */ \ ) /* Compute the # of bytes required to store an offset into a given buffer size */ -#define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) -#define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5VM_log2_of2((unsigned)(l))) +#define H5HF_SIZEOF_OFFSET_BITS(b) (((b) + 7) / 8) +#define H5HF_SIZEOF_OFFSET_LEN(l) H5HF_SIZEOF_OFFSET_BITS(H5VM_log2_of2((unsigned)(l))) /* Heap ID bit flags */ /* Heap ID version (2 bits: 6-7) */ -#define H5HF_ID_VERS_CURR 0x00 /* Current version of ID format */ -#define H5HF_ID_VERS_MASK 0xC0 /* Mask for getting the ID version from flags */ +#define H5HF_ID_VERS_CURR 0x00 /* Current version of ID format */ +#define H5HF_ID_VERS_MASK 0xC0 /* Mask for getting the ID version from flags */ /* Heap ID type (2 bits: 4-5) */ -#define H5HF_ID_TYPE_MAN 0x00 /* "Managed" object - stored in fractal heap blocks */ -#define H5HF_ID_TYPE_HUGE 0x10 /* "Huge" object - stored in file directly */ -#define H5HF_ID_TYPE_TINY 0x20 /* "Tiny" object - stored in heap ID directly */ -#define H5HF_ID_TYPE_RESERVED 0x30 /* "?" object - reserved for future use */ -#define H5HF_ID_TYPE_MASK 0x30 /* Mask for getting the ID type from flags */ +#define H5HF_ID_TYPE_MAN 0x00 /* "Managed" object - stored in fractal heap blocks */ +#define H5HF_ID_TYPE_HUGE 0x10 /* "Huge" object - stored in file directly */ +#define H5HF_ID_TYPE_TINY 0x20 /* "Tiny" object - stored in heap ID directly */ +#define H5HF_ID_TYPE_RESERVED 0x30 /* "?" object - reserved for future use */ +#define H5HF_ID_TYPE_MASK 0x30 /* Mask for getting the ID type from flags */ /* Heap ID bits 0-3 reserved for future use */ /* Encode a "managed" heap ID */ -#define H5HF_MAN_ID_ENCODE(i, h, o, l) \ - *(i) = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; \ - (i)++; \ - UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \ +#define H5HF_MAN_ID_ENCODE(i, h, o, l) \ + *(i) = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_MAN; \ + (i)++; \ + UINT64ENCODE_VAR((i), (o), (h)->heap_off_size); \ UINT64ENCODE_VAR((i), (l), (h)->heap_len_size) /* Decode a "managed" heap ID */ -#define H5HF_MAN_ID_DECODE(i, h, f, o, l) \ - f = *(uint8_t *)i++; \ - UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ +#define H5HF_MAN_ID_DECODE(i, h, f, o, l) \ + f = *(uint8_t *)i++; \ + UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ UINT64DECODE_VAR((i), (l), (h)->heap_len_size) /* Free space section types for fractal heap */ /* (values stored in free space data structures in file) */ -#define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ -#define H5HF_FSPACE_SECT_FIRST_ROW 1 /* Section is first range of blocks in an indirect block row */ -#define H5HF_FSPACE_SECT_NORMAL_ROW 2 /* Section is a range of blocks in an indirect block row */ -#define H5HF_FSPACE_SECT_INDIRECT 3 /* Section is a span of blocks in an indirect block */ +#define H5HF_FSPACE_SECT_SINGLE 0 /* Section is a range of actual bytes in a direct block */ +#define H5HF_FSPACE_SECT_FIRST_ROW 1 /* Section is first range of blocks in an indirect block row */ +#define H5HF_FSPACE_SECT_NORMAL_ROW 2 /* Section is a range of blocks in an indirect block row */ +#define H5HF_FSPACE_SECT_INDIRECT 3 /* Section is a span of blocks in an indirect block */ /* Flags for 'op' operations */ -#define H5HF_OP_MODIFY 0x0001 /* Operation will modify object */ -#define H5HF_OP_FLAGS (H5HF_OP_MODIFY) /* Bit-wise OR of all op flags */ +#define H5HF_OP_MODIFY 0x0001 /* Operation will modify object */ +#define H5HF_OP_FLAGS (H5HF_OP_MODIFY) /* Bit-wise OR of all op flags */ /* Flags for 'root_iblock_flags' field in header */ -#define H5HF_ROOT_IBLOCK_PINNED 0x01 -#define H5HF_ROOT_IBLOCK_PROTECTED 0x02 - +#define H5HF_ROOT_IBLOCK_PINNED 0x01 +#define H5HF_ROOT_IBLOCK_PROTECTED 0x02 /****************************/ /* Package Private Typedefs */ @@ -184,81 +185,79 @@ /* Doubling-table info */ typedef struct H5HF_dtable_t { /* Immutable, pre-set information for table */ - H5HF_dtable_cparam_t cparam; /* Creation parameters for table */ + H5HF_dtable_cparam_t cparam; /* Creation parameters for table */ /* Derived information (stored, varies during lifetime of table) */ - haddr_t table_addr; /* Address of first block for table */ - /* Undefined if no space allocated for table */ - unsigned curr_root_rows; /* Current number of rows in the root indirect block */ - /* 0 indicates that the TABLE_ADDR field points - * to direct block (of START_BLOCK_SIZE) instead - * of indirect root block. - */ + haddr_t table_addr; /* Address of first block for table */ + /* Undefined if no space allocated for table */ + unsigned curr_root_rows; /* Current number of rows in the root indirect block */ + /* 0 indicates that the TABLE_ADDR field points + * to direct block (of START_BLOCK_SIZE) instead + * of indirect root block. + */ /* Computed information (not stored) */ - unsigned max_root_rows; /* Maximum # of rows in root indirect block */ - unsigned max_direct_rows; /* Maximum # of direct rows in any indirect block */ - unsigned start_bits; /* # of bits for starting block size (i.e. log2(start_block_size)) */ - unsigned max_direct_bits; /* # of bits for max. direct block size (i.e. log2(max_direct_size)) */ - unsigned max_dir_blk_off_size; /* Max. size of offsets in direct blocks */ - unsigned first_row_bits; /* # of bits in address of first row */ - hsize_t num_id_first_row; /* Number of IDs in first row of table */ - hsize_t *row_block_size; /* Block size per row of indirect block */ - hsize_t *row_block_off; /* Cumulative offset per row of indirect block */ - hsize_t *row_tot_dblock_free; /* Total free space in dblocks for this row */ - /* (For indirect block rows, it's the total - * free space in all direct blocks referenced - * from the indirect block) - */ - size_t *row_max_dblock_free; /* Max. free space in dblocks for this row */ - /* (For indirect block rows, it's the maximum - * free space in a direct block referenced - * from the indirect block) - */ + unsigned max_root_rows; /* Maximum # of rows in root indirect block */ + unsigned max_direct_rows; /* Maximum # of direct rows in any indirect block */ + unsigned start_bits; /* # of bits for starting block size (i.e. log2(start_block_size)) */ + unsigned max_direct_bits; /* # of bits for max. direct block size (i.e. log2(max_direct_size)) */ + unsigned max_dir_blk_off_size; /* Max. size of offsets in direct blocks */ + unsigned first_row_bits; /* # of bits in address of first row */ + hsize_t num_id_first_row; /* Number of IDs in first row of table */ + hsize_t *row_block_size; /* Block size per row of indirect block */ + hsize_t *row_block_off; /* Cumulative offset per row of indirect block */ + hsize_t *row_tot_dblock_free; /* Total free space in dblocks for this row */ + /* (For indirect block rows, it's the total + * free space in all direct blocks referenced + * from the indirect block) + */ + size_t *row_max_dblock_free; /* Max. free space in dblocks for this row */ + /* (For indirect block rows, it's the maximum + * free space in a direct block referenced + * from the indirect block) + */ } H5HF_dtable_t; /* Fractal heap free list info (forward decl - defined in H5HFflist.c) */ typedef struct H5HF_freelist_t H5HF_freelist_t; -/* Forward decl indirect block info */ -typedef struct H5HF_indirect_t H5HF_indirect_t; - /* Fractal heap block location */ typedef struct H5HF_block_loc_t { /* Necessary table fields */ - unsigned row; /* Row of block in doubling table */ - unsigned col; /* Column of block in doubling table */ + unsigned row; /* Row of block in doubling table */ + unsigned col; /* Column of block in doubling table */ /* Derived/computed/cached table fields */ - unsigned entry; /* Entry of block in doubling table */ + unsigned entry; /* Entry of block in doubling table */ /* Infrastructure */ - 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_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; /* Fractal heap block iterator info */ typedef struct H5HF_block_iter_t { - hbool_t ready; /* Set if iterator is finished initializing */ - H5HF_block_loc_t *curr; /* Pointer to the current level information for iterator */ + hbool_t ready; /* Set if iterator is finished initializing */ + H5HF_block_loc_t *curr; /* Pointer to the current level information for iterator */ } H5HF_block_iter_t; /* Fractal heap free space section info */ typedef struct H5HF_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ union { struct { - H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ - unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ + H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ + unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ } single; struct { - struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space manager */ + hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space + manager */ } row; struct { /* Holds either a pointer to an indirect block (if its "live") or @@ -268,23 +267,24 @@ typedef struct H5HF_free_section_t { * or not) */ union { - H5HF_indirect_t *iblock; /* Indirect block for free section */ - hsize_t iblock_off; /* Indirect block offset in "heap space" */ + H5HF_indirect_t *iblock; /* Indirect block for free section */ + hsize_t iblock_off; /* Indirect block offset in "heap space" */ } u; - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ - unsigned par_entry; /* Entry within parent indirect section */ - hsize_t span_size; /* Size of space tracked, in "heap space" */ - unsigned iblock_entries; /* Number of entries in indirect block where section is located */ - unsigned rc; /* Reference count of outstanding row & child indirect sections */ - unsigned dir_nrows; /* Number of direct rows in section */ - struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ - unsigned indir_nents; /* Number of indirect entries in section */ - struct H5HF_free_section_t **indir_ents; /* Array of pointers to outstanding child indirect sections */ + struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ + unsigned par_entry; /* Entry within parent indirect section */ + hsize_t span_size; /* Size of space tracked, in "heap space" */ + unsigned iblock_entries; /* Number of entries in indirect block where section is located */ + unsigned rc; /* Reference count of outstanding row & child indirect sections */ + unsigned dir_nrows; /* Number of direct rows in section */ + struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ + unsigned indir_nents; /* Number of indirect entries in section */ + struct H5HF_free_section_t * + *indir_ents; /* Array of pointers to outstanding child indirect sections */ } indirect; } u; } H5HF_free_section_t; @@ -293,84 +293,86 @@ typedef struct H5HF_free_section_t { /* (Each fractal heap header has certain information that is shared across all * the instances of blocks in that fractal heap) */ -typedef struct H5HF_hdr_t { +struct H5HF_hdr_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; /* General header information (stored in header) */ - unsigned id_len; /* Size of heap IDs (in bytes) */ - unsigned filter_len; /* Size of I/O filter information (in bytes) */ + unsigned id_len; /* Size of heap IDs (in bytes) */ + unsigned filter_len; /* Size of I/O filter information (in bytes) */ /* Flags for heap settings (stored in status byte in header) */ - hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */ - hbool_t write_once; /* Is heap being written in "write once" mode? */ - hbool_t huge_ids_wrapped; /* Have "huge" object IDs wrapped around? */ - hbool_t checksum_dblocks; /* Should the direct blocks in the heap be checksummed? */ + hbool_t debug_objs; /* Is the heap storing objects in 'debug' format */ + hbool_t write_once; /* Is heap being written in "write once" mode? */ + hbool_t huge_ids_wrapped; /* Have "huge" object IDs wrapped around? */ + hbool_t checksum_dblocks; /* Should the direct blocks in the heap be checksummed? */ /* Doubling table information (partially stored in header) */ /* (Partially set by user, partially derived/updated internally) */ - H5HF_dtable_t man_dtable; /* Doubling-table info for managed objects */ + H5HF_dtable_t man_dtable; /* Doubling-table info for managed objects */ /* Free space information for managed objects (stored in header) */ - hsize_t total_man_free; /* Total amount of free space in managed blocks */ - haddr_t fs_addr; /* Address of free space header on disk */ + hsize_t total_man_free; /* Total amount of free space in managed blocks */ + haddr_t fs_addr; /* Address of free space header on disk */ /* "Huge" object support (stored in header) */ - uint32_t max_man_size; /* Max. size of object to manage in doubling table */ - hsize_t huge_next_id; /* Next ID to use for indirectly tracked 'huge' object */ - haddr_t huge_bt2_addr; /* Address of v2 B-tree for tracking "huge" object info */ + uint32_t max_man_size; /* Max. size of object to manage in doubling table */ + hsize_t huge_next_id; /* Next ID to use for indirectly tracked 'huge' object */ + haddr_t huge_bt2_addr; /* Address of v2 B-tree for tracking "huge" object info */ /* I/O filter support (stored in header, if any are used) */ - H5O_pline_t pline; /* I/O filter pipeline for heap objects */ - size_t pline_root_direct_size; /* Size of filtered root direct block */ + H5O_pline_t pline; /* I/O filter pipeline for heap objects */ + size_t pline_root_direct_size; /* Size of filtered root direct block */ unsigned pline_root_direct_filter_mask; /* I/O filter mask for filtered root direct block */ /* Statistics for heap (stored in header) */ - hsize_t man_size; /* Total amount of 'managed' space in heap */ - hsize_t man_alloc_size; /* Total amount of allocated 'managed' space in heap */ - hsize_t man_iter_off; /* Offset of iterator in 'managed' heap space */ - hsize_t man_nobjs; /* Number of 'managed' objects in heap */ - hsize_t huge_size; /* Total size of 'huge' objects in heap */ - hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ - hsize_t tiny_size; /* Total size of 'tiny' objects in heap */ - hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ + hsize_t man_size; /* Total amount of 'managed' space in heap */ + hsize_t man_alloc_size; /* Total amount of allocated 'managed' space in heap */ + hsize_t man_iter_off; /* Offset of iterator in 'managed' heap space */ + hsize_t man_nobjs; /* Number of 'managed' objects in heap */ + hsize_t huge_size; /* Total size of 'huge' objects in heap */ + hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ + hsize_t tiny_size; /* Total size of 'tiny' objects in heap */ + hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ /* Cached/computed values (not stored in header) */ - size_t rc; /* Reference count of heap's components using heap header */ - 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 */ - 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 */ + size_t rc; /* Reference count of heap's components using heap header */ + 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 */ + 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 */ + unsigned root_iblock_flags; /* Flags to indicate whether root indirect block is pinned/protected */ + 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 */ - 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 heap ID */ - size_t tiny_max_len; /* Max. size of tiny objects for this heap */ - hbool_t tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form (i.e. w/extra byte) */ - uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ - uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ - hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ -} H5HF_hdr_t; + 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 + heap ID */ + size_t tiny_max_len; /* Max. size of tiny objects for this heap */ + hbool_t tiny_len_extended; /* Flag to indicate that 'tiny' object's length is stored in extended form + (i.e. w/extra byte) */ + uint8_t heap_off_size; /* Size of heap offsets (in bytes) */ + uint8_t heap_len_size; /* Size of heap ID lengths (in bytes) */ + hbool_t checked_filters; /* TRUE if pipeline passes can_apply checks */ +}; /* Common indirect block doubling table entry */ /* (common between entries pointing to direct & indirect child blocks) */ typedef struct H5HF_indirect_ent_t { - haddr_t addr; /* Direct block's address */ + haddr_t addr; /* Direct block's address */ } H5HF_indirect_ent_t; /* Extern indirect block doubling table entry for compressed direct blocks */ /* (only exists for indirect blocks in heaps that have I/O filters) */ typedef struct H5HF_indirect_filt_ent_t { - size_t size; /* Size of child direct block, after passing though I/O filters */ - unsigned filter_mask; /* Excluded filters for child direct block */ + size_t size; /* Size of child direct block, after passing though I/O filters */ + unsigned filter_mask; /* Excluded filters for child direct block */ } H5HF_indirect_filt_ent_t; /* Fractal heap indirect block */ @@ -379,32 +381,32 @@ struct H5HF_indirect_t { H5AC_info_t cache_info; /* Internal heap information (not stored) */ - size_t rc; /* Reference count of objects using this block */ - 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 */ - /* necessary as the parent field is sometimes */ - /* nulled out before the eviction notify call */ - /* is made from the metadata cache. Since */ - /* this call cancels flush dependencies, it */ - /* needs this information. */ - unsigned par_entry; /* Entry in parent's table */ - haddr_t addr; /* Address of this indirect block on disk */ - size_t size; /* Size of indirect block on disk */ - unsigned nrows; /* Total # of rows in indirect block */ - unsigned max_rows; /* Max. # of rows in indirect block */ - unsigned nchildren; /* Number of child blocks */ - unsigned max_child; /* Max. offset used in child entries */ - struct H5HF_indirect_t **child_iblocks; /* Array of pointers to pinned child indirect blocks */ - hbool_t removed_from_cache; /* Flag that indicates the block has */ - /* been removed from the metadata cache, but */ - /* is still 'live' due to a refcount (rc) > 0 */ - /* (usually from free space sections) */ + size_t rc; /* Reference count of objects using this block */ + 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 */ + /* necessary as the parent field is sometimes */ + /* nulled out before the eviction notify call */ + /* is made from the metadata cache. Since */ + /* this call cancels flush dependencies, it */ + /* needs this information. */ + unsigned par_entry; /* Entry in parent's table */ + haddr_t addr; /* Address of this indirect block on disk */ + size_t size; /* Size of indirect block on disk */ + unsigned nrows; /* Total # of rows in indirect block */ + unsigned max_rows; /* Max. # of rows in indirect block */ + unsigned nchildren; /* Number of child blocks */ + unsigned max_child; /* Max. offset used in child entries */ + struct H5HF_indirect_t **child_iblocks; /* Array of pointers to pinned child indirect blocks */ + hbool_t removed_from_cache; /* Flag that indicates the block has */ + /* been removed from the metadata cache, but */ + /* is still 'live' due to a refcount (rc) > 0 */ + /* (usually from free space sections) */ /* 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_filt_ent_t *filt_ents; /* Pointer to filtered information for direct blocks */ + 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_filt_ent_t *filt_ents; /* Pointer to filtered information for direct blocks */ }; /* A fractal heap direct block */ @@ -413,146 +415,145 @@ typedef struct H5HF_direct_t { H5AC_info_t cache_info; /* Internal heap information */ - 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 */ - /* necessary as the parent field is sometimes */ - /* nulled out before the eviction notify call */ - /* is made from the metadata cache. Since */ - /* this call cancels flush dependencies, it */ - /* needs this information. */ - unsigned par_entry; /* Entry in parent's table */ - size_t size; /* Size of direct block */ - hsize_t file_size; /* Size of direct block in file (only valid when block's space is being freed) */ - uint8_t *blk; /* Pointer to buffer containing block data */ - uint8_t *write_buf; /* Pointer to buffer containing the block data */ - /* in form ready to copy to the metadata */ - /* cache's image buffer. */ - /* */ - /* This field is used by */ - /* H5HF_cache_dblock_pre_serialize() to pass */ - /* the serialized image of the direct block to */ - /* H5HF_cache_dblock_serialize(). It should */ - /* NULL at all other times. */ - /* */ - /* If I/O filters are enabled, the pre- */ - /* the pre-serialize function will allocate */ - /* a buffer, copy the filtered version of the */ - /* direct block image into it, and place the */ - /* base address of the buffer in this field. */ - /* The serialize function must discard this */ - /* buffer after it copies the contents into */ - /* the image buffer provided by the metadata */ - /* cache. */ - /* */ - /* If I/O filters are not enabled, the */ - /* write_buf field is simply set equal to the */ - /* blk field by the pre-serialize function, */ - /* and back to NULL by the serialize function. */ - size_t write_size; /* size of the buffer pointed to by write_buf. */ + 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 */ + /* necessary as the parent field is sometimes */ + /* nulled out before the eviction notify call */ + /* is made from the metadata cache. Since */ + /* this call cancels flush dependencies, it */ + /* needs this information. */ + unsigned par_entry; /* Entry in parent's table */ + size_t size; /* Size of direct block */ + hsize_t file_size; /* Size of direct block in file (only valid when block's space is being freed) */ + uint8_t *blk; /* Pointer to buffer containing block data */ + uint8_t *write_buf; /* Pointer to buffer containing the block data */ + /* in form ready to copy to the metadata */ + /* cache's image buffer. */ + /* */ + /* This field is used by */ + /* H5HF_cache_dblock_pre_serialize() to pass */ + /* the serialized image of the direct block to */ + /* H5HF_cache_dblock_serialize(). It should */ + /* NULL at all other times. */ + /* */ + /* If I/O filters are enabled, the pre- */ + /* the pre-serialize function will allocate */ + /* a buffer, copy the filtered version of the */ + /* direct block image into it, and place the */ + /* base address of the buffer in this field. */ + /* The serialize function must discard this */ + /* buffer after it copies the contents into */ + /* the image buffer provided by the metadata */ + /* cache. */ + /* */ + /* If I/O filters are not enabled, the */ + /* write_buf field is simply set equal to the */ + /* blk field by the pre-serialize function, */ + /* and back to NULL by the serialize function. */ + size_t write_size; /* size of the buffer pointed to by write_buf. */ /* Stored values */ - hsize_t block_off; /* Offset of the block within the heap's address space */ + hsize_t block_off; /* Offset of the block within the heap's address space */ } 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 */ + H5HF_hdr_t *hdr; /* Pointer to internal fractal heap header info */ + 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_indirect_t *iblock; /* Pointer to parent indirect block */ - unsigned entry; /* Location of block in parent's entry table */ + 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; /* Typedef for indirectly accessed 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_indir_rec_t { - haddr_t addr; /* Address of the object in the file */ - hsize_t len; /* Length of the object in the file */ - hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ + haddr_t addr; /* Address of the object in the file */ + hsize_t len; /* Length of the object in the file */ + hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ } H5HF_huge_bt2_indir_rec_t; /* Typedef for indirectly accessed, filtered 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_filt_indir_rec_t { - haddr_t addr; /* Address of the filtered object in the file */ - hsize_t len; /* Length of the filtered object in the file */ - unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ - hsize_t obj_size; /* Size of the de-filtered object in memory */ - hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ + haddr_t addr; /* Address of the filtered object in the file */ + hsize_t len; /* Length of the filtered object in the file */ + unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ + hsize_t obj_size; /* Size of the de-filtered object in memory */ + hsize_t id; /* ID used for object (not used for 'huge' objects directly accessed) */ } H5HF_huge_bt2_filt_indir_rec_t; /* Typedef for directly accessed 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_dir_rec_t { - haddr_t addr; /* Address of the object in the file */ - hsize_t len; /* Length of the object in the file */ + haddr_t addr; /* Address of the object in the file */ + hsize_t len; /* Length of the object in the file */ } H5HF_huge_bt2_dir_rec_t; /* Typedef for directly accessed, filtered 'huge' object's records in the v2 B-tree */ typedef struct H5HF_huge_bt2_filt_dir_rec_t { - haddr_t addr; /* Address of the filtered object in the file */ - hsize_t len; /* Length of the filtered object in the file */ - unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ - hsize_t obj_size; /* Size of the de-filtered object in memory */ + haddr_t addr; /* Address of the filtered object in the file */ + hsize_t len; /* Length of the filtered object in the file */ + unsigned filter_mask; /* I/O pipeline filter mask for filtered object in the file */ + hsize_t obj_size; /* Size of the de-filtered object in memory */ } H5HF_huge_bt2_filt_dir_rec_t; /* User data for free space section 'add' callback */ typedef struct { - H5HF_hdr_t *hdr; /* Fractal heap header */ + H5HF_hdr_t *hdr; /* Fractal heap header */ } H5HF_sect_add_ud_t; /* User data for v2 B-tree 'remove' callback on 'huge' objects */ typedef struct { - H5HF_hdr_t *hdr; /* Fractal heap header (in) */ - hsize_t obj_len; /* Length of object removed (out) */ + H5HF_hdr_t *hdr; /* Fractal heap header (in) */ + hsize_t obj_len; /* Length of object removed (out) */ } H5HF_huge_remove_ud_t; /* User data for fractal heap header cache client callback */ typedef struct H5HF_hdr_cache_ud_t { - H5F_t *f; /* File pointer */ + H5F_t *f; /* File pointer */ } 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 */ - const unsigned *nrows; /* Number of rows */ + 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 */ - 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 - * direct block size, as conpression may - * reduce the size of the on disk image, - * and check sums may increase it. - */ - size_t dblock_size; /* size of the direct block, which bears - * no necessary relation to the block - * odi_size -- the size of the on disk - * image of the block. Note that the - * metadata cache is only interested - * in the odi_size, and thus it is this - * value that is passed to the cache in - * calls to it. - */ - unsigned filter_mask; /* Excluded filters for direct block */ - uint8_t *dblk; /* Pointer to the buffer containing the decompressed - * direct block data obtained in verify_chksum callback. - * It will be used later in deserialize callback. - */ + H5HF_parent_t par_info; /* Parent info */ + 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 + * direct block size, as conpression may + * reduce the size of the on disk image, + * and check sums may increase it. + */ + size_t dblock_size; /* size of the direct block, which bears + * no necessary relation to the block + * odi_size -- the size of the on disk + * image of the block. Note that the + * metadata cache is only interested + * in the odi_size, and thus it is this + * value that is passed to the cache in + * calls to it. + */ + unsigned filter_mask; /* Excluded filters for direct block */ + uint8_t *dblk; /* Pointer to the buffer containing the decompressed + * direct block data obtained in verify_chksum callback. + * It will be used later in deserialize callback. + */ htri_t decompressed; /* Indicate that the direct block has been * decompressed in verify_chksum callback. * It will be used later in deserialize callback. */ } H5HF_dblock_cache_ud_t; - /*****************************/ /* Package Private Variables */ /*****************************/ @@ -600,123 +601,102 @@ H5FL_EXTERN(H5HF_direct_t); /* Declare a free list to manage heap direct block data to/from disk */ H5FL_BLK_EXTERN(direct_block); - /******************************/ /* Package Private Prototypes */ /******************************/ /* Doubling table routines */ -H5_DLL herr_t H5HF_dtable_init(H5HF_dtable_t *dtable); -H5_DLL herr_t H5HF_dtable_dest(H5HF_dtable_t *dtable); -H5_DLL herr_t H5HF_dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, - unsigned *row, unsigned *col); -H5_DLL unsigned H5HF_dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size); -H5_DLL unsigned H5HF_dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size); -H5_DLL hsize_t H5HF_dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, - unsigned start_col, unsigned num_entries); +H5_DLL herr_t H5HF__dtable_init(H5HF_dtable_t *dtable); +H5_DLL herr_t H5HF__dtable_dest(H5HF_dtable_t *dtable); +H5_DLL herr_t H5HF__dtable_lookup(const H5HF_dtable_t *dtable, hsize_t off, unsigned *row, unsigned *col); +H5_DLL unsigned H5HF__dtable_size_to_row(const H5HF_dtable_t *dtable, size_t block_size); +H5_DLL unsigned H5HF__dtable_size_to_rows(const H5HF_dtable_t *dtable, hsize_t size); +H5_DLL hsize_t H5HF__dtable_span_size(const H5HF_dtable_t *dtable, unsigned start_row, unsigned start_col, + unsigned num_entries); /* Heap header routines */ -H5_DLL H5HF_hdr_t * H5HF_hdr_alloc(H5F_t *f); -H5_DLL haddr_t H5HF_hdr_create(H5F_t *f, const H5HF_create_t *cparam); +H5_DLL H5HF_hdr_t *H5HF__hdr_alloc(H5F_t *f); +H5_DLL haddr_t H5HF__hdr_create(H5F_t *f, const H5HF_create_t *cparam); H5_DLL H5HF_hdr_t *H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags); -H5_DLL herr_t H5HF_hdr_finish_init_phase1(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_finish_init_phase2(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_finish_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_incr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_decr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_fuse_incr(H5HF_hdr_t *hdr); -H5_DLL size_t H5HF_hdr_fuse_decr(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_dirty(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt); -H5_DLL herr_t H5HF_hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free); -H5_DLL herr_t H5HF_hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size); -H5_DLL herr_t H5HF_hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, unsigned curr_entry); -H5_DLL herr_t H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - unsigned start_entry, unsigned nentries); -H5_DLL herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size); -H5_DLL herr_t H5HF_hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries); -H5_DLL herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr); -H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); -H5_DLL herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_free(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_finish_init_phase1(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_finish_init_phase2(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_finish_init(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_incr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_decr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_fuse_incr(H5HF_hdr_t *hdr); +H5_DLL size_t H5HF__hdr_fuse_decr(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_dirty(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_adj_free(H5HF_hdr_t *hdr, ssize_t amt); +H5_DLL herr_t H5HF__hdr_adjust_heap(H5HF_hdr_t *hdr, hsize_t new_size, hssize_t extra_free); +H5_DLL herr_t H5HF__hdr_inc_alloc(H5HF_hdr_t *hdr, size_t alloc_size); +H5_DLL herr_t H5HF__hdr_start_iter(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, hsize_t curr_off, + unsigned curr_entry); +H5_DLL herr_t H5HF__hdr_skip_blocks(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, + unsigned nentries); +H5_DLL herr_t H5HF__hdr_update_iter(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF__hdr_inc_iter(H5HF_hdr_t *hdr, hsize_t adv_size, unsigned nentries); +H5_DLL herr_t H5HF__hdr_reverse_iter(H5HF_hdr_t *hdr, haddr_t dblock_addr); +H5_DLL herr_t H5HF__hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); +H5_DLL herr_t H5HF__hdr_empty(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_free(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__hdr_delete(H5HF_hdr_t *hdr); /* Indirect block routines */ -H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock); +H5_DLL herr_t H5HF__iblock_incr(H5HF_indirect_t *iblock); H5_DLL herr_t H5HF__iblock_decr(H5HF_indirect_t *iblock); -H5_DLL herr_t H5HF_iblock_dirty(H5HF_indirect_t *iblock); -H5_DLL herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, - size_t min_dblock_size); -H5_DLL herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, - size_t min_dblock_size); -H5_DLL herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, - H5HF_free_section_t **sec_node); -H5_DLL herr_t H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, - unsigned par_entry, unsigned nrows, unsigned max_rows, haddr_t *addr_p); -H5_DLL H5HF_indirect_t *H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, - hbool_t must_protect, unsigned flags, hbool_t *did_protect); -H5_DLL herr_t H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, - hbool_t did_protect); -H5_DLL herr_t H5HF_man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, - haddr_t dblock_addr); +H5_DLL herr_t H5HF__iblock_dirty(H5HF_indirect_t *iblock); +H5_DLL herr_t H5HF__man_iblock_root_create(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF__man_iblock_root_double(H5HF_hdr_t *hdr, size_t min_dblock_size); +H5_DLL herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node); +H5_DLL herr_t H5HF__man_iblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, + unsigned nrows, unsigned max_rows, haddr_t *addr_p); +H5_DLL H5HF_indirect_t *H5HF__man_iblock_protect(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, + hbool_t must_protect, unsigned flags, hbool_t *did_protect); +H5_DLL herr_t H5HF__man_iblock_unprotect(H5HF_indirect_t *iblock, unsigned cache_flags, hbool_t did_protect); +H5_DLL herr_t H5HF__man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t dblock_addr); H5_DLL herr_t H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry); -H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, - haddr_t *child_addr); -H5_DLL herr_t H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, - unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry); -H5_DLL herr_t H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, - haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/); -H5_DLL herr_t H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, - hsize_t block_off, hsize_t *ret_par_block_off, unsigned *ret_entry); -H5_DLL herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock); +H5_DLL herr_t H5HF__man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry, haddr_t *child_addr); +H5_DLL herr_t H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry); +H5_DLL herr_t H5HF__man_iblock_size(H5F_t *f, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, + H5HF_indirect_t *par_iblock, unsigned par_entry, + hsize_t *heap_size /*out*/); +H5_DLL herr_t H5HF__man_iblock_parent_info(const H5HF_hdr_t *hdr, hsize_t block_off, + hsize_t *ret_par_block_off, unsigned *ret_entry); +H5_DLL herr_t H5HF__man_iblock_dest(H5HF_indirect_t *iblock); /* Direct block routines */ -H5_DLL herr_t H5HF__man_dblock_new(H5HF_hdr_t *fh, size_t request, - H5HF_free_section_t **ret_sec_node); -H5_DLL herr_t H5HF__man_dblock_create(H5HF_hdr_t *hdr, - H5HF_indirect_t *par_iblock, unsigned par_entry, haddr_t *addr_p, - H5HF_free_section_t **ret_sec_node); -H5_DLL herr_t H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, - haddr_t dblock_addr, hbool_t *parent_removed); -H5_DLL 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); -H5_DLL herr_t H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, - H5HF_indirect_t **par_iblock, unsigned *par_entry, hbool_t *par_did_protect, - unsigned flags); -H5_DLL herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, - hsize_t dblock_size); -H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock); +H5_DLL herr_t H5HF__man_dblock_new(H5HF_hdr_t *fh, size_t request, H5HF_free_section_t **ret_sec_node); +H5_DLL herr_t H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned par_entry, + haddr_t *addr_p, H5HF_free_section_t **ret_sec_node); +H5_DLL herr_t H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, haddr_t dblock_addr, + hbool_t *parent_removed); +H5_DLL 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); +H5_DLL herr_t H5HF__man_dblock_locate(H5HF_hdr_t *hdr, hsize_t obj_off, H5HF_indirect_t **par_iblock, + unsigned *par_entry, hbool_t *par_did_protect, unsigned flags); +H5_DLL herr_t H5HF__man_dblock_delete(H5F_t *f, haddr_t dblock_addr, hsize_t dblock_size); +H5_DLL herr_t H5HF__man_dblock_dest(H5HF_direct_t *dblock); /* Managed object routines */ -H5_DLL herr_t H5HF__man_insert(H5HF_hdr_t *fh, size_t obj_size, - const void *obj, void *id); -H5_DLL herr_t H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); -H5_DLL void H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, - hsize_t *obj_off_p); +H5_DLL herr_t H5HF__man_insert(H5HF_hdr_t *fh, size_t obj_size, const void *obj, void *id); +H5_DLL herr_t H5HF__man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); +H5_DLL void H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p); H5_DLL herr_t H5HF__man_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); H5_DLL herr_t H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj); -H5_DLL herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data); +H5_DLL herr_t H5HF__man_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id); /* 'Huge' object routines */ -H5_DLL herr_t H5HF_huge_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, - void *obj, void *id); -H5_DLL herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); -H5_DLL herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, - hsize_t *obj_off_p); -H5_DLL herr_t H5HF__huge_read(H5HF_hdr_t *fh, const uint8_t *id, - void *obj); -H5_DLL herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, - const void *obj); -H5_DLL herr_t H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF__huge_init(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *id); +H5_DLL herr_t H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); +H5_DLL herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p); +H5_DLL herr_t H5HF__huge_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); +H5_DLL herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj); +H5_DLL herr_t H5HF__huge_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF__huge_remove(H5HF_hdr_t *fh, const uint8_t *id); H5_DLL herr_t H5HF__huge_term(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF__huge_delete(H5HF_hdr_t *hdr); @@ -731,100 +711,71 @@ H5_DLL herr_t H5HF__huge_bt2_filt_dir_found(const void *nrecord, void *op_data); H5_DLL herr_t H5HF__huge_bt2_filt_dir_remove(const void *nrecord, void *op_data); /* 'Tiny' object routines */ -H5_DLL herr_t H5HF_tiny_init(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, - void *id); -H5_DLL herr_t H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, - size_t *obj_len_p); -H5_DLL herr_t H5HF_tiny_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); -H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); -H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); - -/* Debugging routines for dumping file structures */ -H5_DLL void H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, haddr_t hdr_addr, size_t nrec); -H5_DLL void H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, - FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, haddr_t addr, - FILE *stream, int indent, int fwidth, haddr_t hdr_addr, unsigned nrows); +H5_DLL herr_t H5HF__tiny_init(H5HF_hdr_t *hdr); +H5_DLL herr_t H5HF__tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *id); +H5_DLL herr_t H5HF__tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); +H5_DLL herr_t H5HF__tiny_read(H5HF_hdr_t *fh, const uint8_t *id, void *obj); +H5_DLL herr_t H5HF__tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF__tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); /* Block iteration routines */ -H5_DLL herr_t H5HF_man_iter_init(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t offset); -H5_DLL herr_t H5HF_man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - H5HF_indirect_t *iblock, unsigned start_entry); -H5_DLL herr_t H5HF_man_iter_set_entry(const H5HF_hdr_t *hdr, - H5HF_block_iter_t *biter, unsigned entry); -H5_DLL herr_t H5HF_man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - unsigned nentries); -H5_DLL herr_t H5HF_man_iter_up(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF_man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock); -H5_DLL herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter); -H5_DLL herr_t H5HF_man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, - unsigned *entry, H5HF_indirect_t **block); -H5_DLL herr_t H5HF_man_iter_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, - hsize_t *offset); -H5_DLL hbool_t H5HF_man_iter_ready(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF__man_iter_init(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF__man_iter_start_offset(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, hsize_t offset); +H5_DLL herr_t H5HF__man_iter_start_entry(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, H5HF_indirect_t *iblock, + unsigned start_entry); +H5_DLL herr_t H5HF__man_iter_set_entry(const H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned entry); +H5_DLL herr_t H5HF__man_iter_next(H5HF_hdr_t *hdr, H5HF_block_iter_t *biter, unsigned nentries); +H5_DLL herr_t H5HF__man_iter_up(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF__man_iter_down(H5HF_block_iter_t *biter, H5HF_indirect_t *iblock); +H5_DLL herr_t H5HF__man_iter_reset(H5HF_block_iter_t *biter); +H5_DLL herr_t H5HF__man_iter_curr(H5HF_block_iter_t *biter, unsigned *row, unsigned *col, unsigned *entry, + H5HF_indirect_t **block); +H5_DLL hbool_t H5HF__man_iter_ready(H5HF_block_iter_t *biter); /* Free space manipulation routines */ H5_DLL herr_t H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create); -H5_DLL herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, - unsigned flags); -H5_DLL htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, - H5HF_free_section_t **node); +H5_DLL herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags); +H5_DLL htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node); H5_DLL herr_t H5HF__space_revert_root(const H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, - H5HF_indirect_t *root_iblock); +H5_DLL herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock); H5_DLL herr_t H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size); H5_DLL herr_t H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node); H5_DLL herr_t H5HF__space_close(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF__space_delete(H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, uint16_t new_class); +H5_DLL herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16_t new_class); /* Free space section routines */ -H5_DLL H5HF_free_section_t *H5HF_sect_single_new(hsize_t sect_off, - size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry); -H5_DLL herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -H5_DLL herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect, 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 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); +H5_DLL H5HF_free_section_t *H5HF__sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, + unsigned par_entry); +H5_DLL herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +H5_DLL herr_t H5HF__sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, + 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 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); H5_DLL herr_t H5HF__sect_single_free(H5FS_section_info_t *sect); /* Internal operator callbacks */ -H5_DLL herr_t H5HF_op_read(const void *obj, size_t obj_len, void *op_data); -H5_DLL herr_t H5HF_op_write(const void *obj, size_t obj_len, void *op_data); +H5_DLL herr_t H5HF__op_read(const void *obj, size_t obj_len, void *op_data); +H5_DLL herr_t H5HF__op_write(const void *obj, size_t obj_len, void *op_data); /* Testing routines */ #ifdef H5HF_TESTING -H5_DLL herr_t H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam); -H5_DLL int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2); +H5_DLL herr_t H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam); +H5_DLL int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2); H5_DLL unsigned H5HF_get_max_root_rows(const H5HF_t *fh); H5_DLL unsigned H5HF_get_dtable_width_test(const H5HF_t *fh); H5_DLL unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh); H5_DLL unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos); -H5_DLL hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row); -H5_DLL hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row); -H5_DLL herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *id, hsize_t *obj_off); -H5_DLL herr_t H5HF_get_id_type_test(const void *id, unsigned char *obj_type); -H5_DLL herr_t H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, - hbool_t *len_extended); -H5_DLL herr_t H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, - hbool_t *ids_direct); +H5_DLL hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row); +H5_DLL hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row); +H5_DLL herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *id, hsize_t *obj_off); +H5_DLL herr_t H5HF_get_id_type_test(const void *id, unsigned char *obj_type); +H5_DLL herr_t H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, hbool_t *len_extended); +H5_DLL herr_t H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, hbool_t *ids_direct); #endif /* H5HF_TESTING */ -#endif /* _H5HFpkg_H */ - +#endif /* H5HFpkg_H */ diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index ae0ffada5d0..3263b4efa70 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,12 +22,12 @@ *------------------------------------------------------------------------- */ -#ifndef _H5HFprivate_H -#define _H5HFprivate_H +#ifndef H5HFprivate_H +#define H5HFprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Fprivate.h" /* File access */ +#include "H5Oprivate.h" /* Object headers */ /**************************/ /* Library Private Macros */ @@ -36,8 +36,7 @@ /* Limit heap ID length to 4096 + 1, due to # of bits required to store * length of 'tiny' objects (12 bits) */ -#define H5HF_MAX_ID_LEN (4096 + 1) - +#define H5HF_MAX_ID_LEN (4096 + 1) /****************************/ /* Library Private Typedefs */ @@ -45,59 +44,60 @@ /* Creation parameters for doubling-tables */ typedef struct H5HF_dtable_cparam_t { - unsigned width; /* Number of columns in the table (must be power of 2) */ - size_t start_block_size; /* Starting block size for table (must be power of 2) */ - size_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */ - unsigned max_index; /* Maximum ID/offset for table (integer log2 of actual value, ie. the # of bits required) */ - unsigned start_root_rows; /* Starting number of rows for root indirect block */ - /* 0 indicates to create the full indirect block for the root, - * right from the start. Doesn't have to be power of 2 - */ + unsigned width; /* Number of columns in the table (must be power of 2) */ + size_t start_block_size; /* Starting block size for table (must be power of 2) */ + size_t max_direct_size; /* Maximum size of a direct block (must be power of 2) */ + unsigned max_index; /* Maximum ID/offset for table (integer log2 of actual value, ie. the # of bits + required) */ + unsigned start_root_rows; /* Starting number of rows for root indirect block */ + /* 0 indicates to create the full indirect block for the root, + * right from the start. Doesn't have to be power of 2 + */ } H5HF_dtable_cparam_t; /* Fractal heap creation parameters */ typedef struct H5HF_create_t { - H5HF_dtable_cparam_t managed;/* Mapped object doubling-table creation parameters */ - hbool_t checksum_dblocks; /* Whether the direct blocks should be checksummed */ - uint32_t max_man_size; /* Max. size of object to manage in doubling table */ - /* (i.e. min. size of object to store standalone) */ - uint16_t id_len; /* Length of IDs to use for heap objects */ - /* (0 - make ID just large enough to hold length & offset of object in the heap) */ - /* (1 - make ID just large enough to allow 'huge' objects to be accessed directly) */ - /* (n - make ID 'n' bytes in size) */ - H5O_pline_t pline; /* I/O filter pipeline to apply to direct blocks & 'huge' objects */ + H5HF_dtable_cparam_t managed; /* Mapped object doubling-table creation parameters */ + hbool_t checksum_dblocks; /* Whether the direct blocks should be checksummed */ + uint32_t max_man_size; /* Max. size of object to manage in doubling table */ + /* (i.e. min. size of object to store standalone) */ + uint16_t id_len; /* Length of IDs to use for heap objects */ + /* (0 - make ID just large enough to hold length & offset of object in the heap) */ + /* (1 - make ID just large enough to allow 'huge' objects to be accessed directly) */ + /* (n - make ID 'n' bytes in size) */ + H5O_pline_t pline; /* I/O filter pipeline to apply to direct blocks & 'huge' objects */ } H5HF_create_t; /* Fractal heap metadata statistics info */ typedef struct H5HF_stat_t { /* 'Managed' object info */ - hsize_t man_size; /* Size of 'managed' space in heap */ - hsize_t man_alloc_size; /* Size of 'managed' space allocated in heap */ - hsize_t man_iter_off; /* Offset of "new block" iterator in 'managed' heap space */ - hsize_t man_free_space; /* Free space within 'managed' heap blocks */ - hsize_t man_nobjs; /* Number of 'managed' objects in heap */ + hsize_t man_size; /* Size of 'managed' space in heap */ + hsize_t man_alloc_size; /* Size of 'managed' space allocated in heap */ + hsize_t man_iter_off; /* Offset of "new block" iterator in 'managed' heap space */ + hsize_t man_free_space; /* Free space within 'managed' heap blocks */ + hsize_t man_nobjs; /* Number of 'managed' objects in heap */ /* 'Huge' object info */ - hsize_t huge_size; /* Size of 'huge' objects in heap */ - hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ + hsize_t huge_size; /* Size of 'huge' objects in heap */ + hsize_t huge_nobjs; /* Number of 'huge' objects in heap */ /* 'Tiny' object info */ - hsize_t tiny_size; /* Size of 'tiny' objects in heap */ - hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ + hsize_t tiny_size; /* Size of 'tiny' objects in heap */ + hsize_t tiny_nobjs; /* Number of 'tiny' objects in heap */ } H5HF_stat_t; -/* Fractal heap info (forward decl - defined in H5HFpkg.h) */ -typedef struct H5HF_t H5HF_t; +/* Fractal heap info (forward decls - defined in H5HFpkg.h) */ +typedef struct H5HF_t H5HF_t; +typedef struct H5HF_hdr_t H5HF_hdr_t; +typedef struct H5HF_indirect_t H5HF_indirect_t; /* Typedef for 'op' operations */ -typedef herr_t (*H5HF_operator_t)(const void *obj/*in*/, size_t obj_len, - void *op_data/*in,out*/); +typedef herr_t (*H5HF_operator_t)(const void *obj /*in*/, size_t obj_len, void *op_data /*in,out*/); /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -105,22 +105,21 @@ typedef herr_t (*H5HF_operator_t)(const void *obj/*in*/, size_t obj_len, /* General routines for fractal heap operations */ H5_DLL H5HF_t *H5HF_create(H5F_t *f, const H5HF_create_t *cparam); H5_DLL H5HF_t *H5HF_open(H5F_t *f, haddr_t fh_addr); -H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p/*out*/); -H5_DLL herr_t H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr/*out*/); -H5_DLL herr_t H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/); -H5_DLL herr_t H5HF_get_obj_len(H5HF_t *fh, const void *id, size_t *obj_len_p/*out*/); -H5_DLL herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p/*out*/); -H5_DLL herr_t H5HF_read(H5HF_t *fh, const void *id, void *obj/*out*/); -H5_DLL herr_t H5HF_write(H5HF_t *fh, void *id, hbool_t *id_changed, - const void *obj); -H5_DLL herr_t H5HF_op(H5HF_t *fh, const void *id, H5HF_operator_t op, void *op_data); -H5_DLL herr_t H5HF_remove(H5HF_t *fh, const void *id); -H5_DLL herr_t H5HF_close(H5HF_t *fh); -H5_DLL herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr); +H5_DLL herr_t H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p /*out*/); +H5_DLL herr_t H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr /*out*/); +H5_DLL herr_t H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/); +H5_DLL herr_t H5HF_get_obj_len(H5HF_t *fh, const void *id, size_t *obj_len_p /*out*/); +H5_DLL herr_t H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p /*out*/); +H5_DLL herr_t H5HF_read(H5HF_t *fh, const void *id, void *obj /*out*/); +H5_DLL herr_t H5HF_write(H5HF_t *fh, void *id, hbool_t *id_changed, const void *obj); +H5_DLL herr_t H5HF_op(H5HF_t *fh, const void *id, H5HF_operator_t op, void *op_data); +H5_DLL herr_t H5HF_remove(H5HF_t *fh, const void *id); +H5_DLL herr_t H5HF_close(H5HF_t *fh); +H5_DLL herr_t H5HF_delete(H5F_t *f, haddr_t fh_addr); /* Statistics routines */ H5_DLL herr_t H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats); -H5_DLL herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size/*out*/); +H5_DLL herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size /*out*/); /* Debugging routines */ H5_DLL herr_t H5HF_id_print(H5HF_t *fh, const void *id, FILE *stream, int indent, int fwidth); @@ -128,5 +127,15 @@ H5_DLL herr_t H5HF_id_print(H5HF_t *fh, const void *id, FILE *stream, int indent H5_DLL herr_t H5HF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); #endif /* H5HF_DEBUGGING */ -#endif /* _H5HFprivate_H */ - +/* Debugging routines for dumping file structures */ +H5_DLL void H5HF_hdr_print(const H5HF_hdr_t *hdr, hbool_t dump_internal, FILE *stream, int indent, + int fwidth); +H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); +H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + haddr_t hdr_addr, size_t nrec); +H5_DLL void H5HF_iblock_print(const H5HF_indirect_t *iblock, hbool_t dump_internal, FILE *stream, int indent, + int fwidth); +H5_DLL herr_t H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, + haddr_t hdr_addr, unsigned nrows); + +#endif /* H5HFprivate_H */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index b9c95e21b67..eec41a48ad0 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,158 +23,133 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ /* Size of serialized indirect section information */ -#define H5HF_SECT_INDIRECT_SERIAL_SIZE(h) ( \ - (unsigned)(h)->heap_off_size /* Indirect block's offset in "heap space" */ \ - + (unsigned)2 /* Row */ \ - + (unsigned)2 /* Column */ \ - + (unsigned)2 /* # of entries */ \ +#define H5HF_SECT_INDIRECT_SERIAL_SIZE(h) \ + ((unsigned)(h)->heap_off_size /* Indirect block's offset in "heap space" */ \ + + (unsigned)2 /* Row */ \ + + (unsigned)2 /* Column */ \ + + (unsigned)2 /* # of entries */ \ ) - /******************/ /* Local Typedefs */ /******************/ /* Typedef for "class private" information for sections */ typedef struct { - H5HF_hdr_t *hdr; /* Pointer to fractal heap header */ + H5HF_hdr_t *hdr; /* Pointer to fractal heap header */ } H5HF_sect_private_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Shared routines */ -static herr_t H5HF_sect_init_cls(H5FS_section_class_t *cls, - H5HF_hdr_t *hdr); -static herr_t H5HF_sect_term_cls(H5FS_section_class_t *cls); -static H5HF_free_section_t *H5HF_sect_node_new(unsigned sect_type, - haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t state); -static herr_t H5HF_sect_node_free(H5HF_free_section_t *sect, - H5HF_indirect_t *parent); +static herr_t H5FS__sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr); +static herr_t H5FS__sect_term_cls(H5FS_section_class_t *cls); +static H5HF_free_section_t *H5FS__sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, + H5FS_section_state_t state); +static herr_t H5HF__sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *parent); /* 'single' section routines */ -static herr_t H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, - H5HF_free_section_t *sect); +static herr_t H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, H5HF_free_section_t *sect); static herr_t H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); /* 'single' section callbacks */ -static herr_t H5HF__sect_single_add(H5FS_section_info_t **sect, unsigned *flags, - void *udata); -static H5FS_section_info_t *H5HF__sect_single_deserialize(const H5FS_section_class_t *cls, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, - unsigned *des_flags); -static htri_t H5HF__sect_single_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF__sect_single_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *sect, - void *udata); -static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, - void *udata); -static herr_t H5HF__sect_single_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); +static herr_t H5HF__sect_single_add(H5FS_section_info_t **sect, unsigned *flags, void *udata); +static H5FS_section_info_t *H5HF__sect_single_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags); +static htri_t H5HF__sect_single_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5HF__sect_single_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *sect, void *udata); +static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *udata); +static herr_t H5HF__sect_single_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); /* 'row' section routines */ -static H5HF_free_section_t *H5HF_sect_row_create(haddr_t sect_off, - hsize_t sect_size, hbool_t is_first, unsigned row, unsigned col, - unsigned nentries, H5HF_free_section_t *under_sect); -static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect); -static herr_t H5HF_sect_row_from_single(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, H5HF_direct_t *dblock); +static H5HF_free_section_t *H5HF__sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, + unsigned row, unsigned col, unsigned nentries, + H5HF_free_section_t *under_sect); +static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect); +static herr_t H5HF__sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_direct_t *dblock); static herr_t H5HF__sect_row_free_real(H5HF_free_section_t *sect); /* 'row' section callbacks */ static herr_t H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *udata); static herr_t 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); -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); -static htri_t H5HF__sect_row_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5HF__sect_row_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *sect, - void *udata); -static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **sect, - void *udata); +static herr_t H5HF__sect_row_serialize(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect, + uint8_t *buf); +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); +static htri_t H5HF__sect_row_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5HF__sect_row_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *sect, void *udata); +static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **sect, void *udata); static herr_t 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); -static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *sect, - FILE *stream, int indent, int fwidth); +static herr_t H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); +static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth); /* 'indirect' section routines */ -static H5HF_free_section_t *H5HF_sect_indirect_new(H5HF_hdr_t *hdr, - haddr_t sect_off, hsize_t sect_size, - H5HF_indirect_t *iblock, hsize_t iblock_off, - unsigned row, unsigned col, unsigned nentries); -static herr_t H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - hbool_t first_child, H5HF_free_section_t **first_row_sect, - unsigned space_flags, unsigned start_row, unsigned start_col, - unsigned end_row, unsigned end_col); -static H5HF_free_section_t *H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, - H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect); -static herr_t H5HF_sect_indirect_decr(H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect, H5HF_indirect_t *sect_iblock); -static herr_t H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, - H5HF_free_section_t *row_sect, hbool_t *alloc_from_start); -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 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, H5HF_free_section_t *sect2); -static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, - H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect, uint8_t *buf); -static H5FS_section_info_t *H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); -static herr_t H5HF_sect_indirect_free(H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, - const H5HF_free_section_t *sect); -static herr_t H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, - FILE *stream, int indent, int fwidth); +static H5HF_free_section_t *H5HF__sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, + H5HF_indirect_t *iblock, hsize_t iblock_off, unsigned row, + unsigned col, unsigned nentries); +static herr_t H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_t first_child, + H5HF_free_section_t **first_row_sect, unsigned space_flags, + unsigned start_row, unsigned start_col, unsigned end_row, + unsigned end_col); +static H5HF_free_section_t *H5HF__sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, + H5HF_free_section_t *row_sect); +static herr_t H5HF__sect_indirect_decr(H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, + H5HF_indirect_t *sect_iblock); +static herr_t H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, + hbool_t *alloc_from_start); +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 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, + H5HF_free_section_t *sect2); +static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, uint8_t *buf); +static H5FS_section_info_t *H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags); +static herr_t H5HF__sect_indirect_free(H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect); +static herr_t H5HF__sect_indirect_debug(const H5HF_free_section_t *sect, FILE *stream, int indent, + int fwidth); /* 'indirect' section callbacks */ -static herr_t H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *udata); -static herr_t H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls); - +static herr_t H5HF__sect_indirect_init_cls(H5FS_section_class_t *cls, void *udata); +static herr_t H5HF__sect_indirect_term_cls(H5FS_section_class_t *cls); /*********************/ /* Package Variables */ @@ -183,27 +158,27 @@ static herr_t H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls); /* Class info for "single" free space sections */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_SINGLE, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_SINGLE, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - H5HF__sect_single_add, /* Add section */ - NULL, /* Serialize section */ - H5HF__sect_single_deserialize, /* Deserialize section */ - H5HF__sect_single_can_merge, /* Can sections merge? */ - H5HF__sect_single_merge, /* Merge sections */ - H5HF__sect_single_can_shrink, /* Can section shrink container?*/ - H5HF__sect_single_shrink, /* Shrink container w/section */ - H5HF__sect_single_free, /* Free section */ - H5HF__sect_single_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + H5HF__sect_single_add, /* Add section */ + NULL, /* Serialize section */ + H5HF__sect_single_deserialize, /* Deserialize section */ + H5HF__sect_single_can_merge, /* Can sections merge? */ + H5HF__sect_single_merge, /* Merge sections */ + H5HF__sect_single_can_shrink, /* Can section shrink container?*/ + H5HF__sect_single_shrink, /* Shrink container w/section */ + H5HF__sect_single_free, /* Free section */ + H5HF__sect_single_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Class info for "first row" free space sections */ @@ -212,53 +187,53 @@ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1] = {{ */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_FIRST_ROW[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_FIRST_ROW, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_FIRST_ROW, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF__sect_row_init_cls, /* Initialize section class */ - H5HF__sect_row_term_cls, /* Terminate section class */ + H5HF__sect_row_init_cls, /* Initialize section class */ + H5HF__sect_row_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - H5HF__sect_row_serialize, /* Serialize section */ - H5HF__sect_row_deserialize, /* Deserialize section */ - H5HF__sect_row_can_merge, /* Can sections merge? */ - H5HF__sect_row_merge, /* Merge sections */ - H5HF__sect_row_can_shrink, /* Can section shrink container?*/ - H5HF__sect_row_shrink, /* Shrink container w/section */ - H5HF__sect_row_free, /* Free section */ - H5HF__sect_row_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - H5HF__sect_row_debug, /* Dump debugging for section */ + NULL, /* Add section */ + H5HF__sect_row_serialize, /* Serialize section */ + H5HF__sect_row_deserialize, /* Deserialize section */ + H5HF__sect_row_can_merge, /* Can sections merge? */ + H5HF__sect_row_merge, /* Merge sections */ + H5HF__sect_row_can_shrink, /* Can section shrink container?*/ + H5HF__sect_row_shrink, /* Shrink container w/section */ + H5HF__sect_row_free, /* Free section */ + H5HF__sect_row_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + H5HF__sect_row_debug, /* Dump debugging for section */ }}; /* Class info for "normal row" free space sections */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_NORMAL_ROW, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM|H5FS_CLS_SEPAR_OBJ|H5FS_CLS_GHOST_OBJ, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_NORMAL_ROW, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_SEPAR_OBJ | H5FS_CLS_GHOST_OBJ, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF__sect_row_init_cls, /* Initialize section class */ - H5HF__sect_row_term_cls, /* Terminate section class */ + H5HF__sect_row_init_cls, /* Initialize section class */ + H5HF__sect_row_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - NULL, /* Can sections merge? */ - NULL, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - H5HF__sect_row_free, /* Free section */ - H5HF__sect_row_valid, /* Check validity of section */ - NULL, /* Split section node for alignment */ - H5HF__sect_row_debug, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + NULL, /* Can sections merge? */ + NULL, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + H5HF__sect_row_free, /* Free section */ + H5HF__sect_row_valid, /* Check validity of section */ + NULL, /* Split section node for alignment */ + H5HF__sect_row_debug, /* Dump debugging for section */ }}; /* Class info for "indirect" free space sections */ @@ -267,46 +242,42 @@ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1] = {{ */ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1] = {{ /* Class variables */ - H5HF_FSPACE_SECT_INDIRECT, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM|H5FS_CLS_GHOST_OBJ, /* Class flags */ - NULL, /* Class private info */ + H5HF_FSPACE_SECT_INDIRECT, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_GHOST_OBJ, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - H5HF_sect_indirect_init_cls, /* Initialize section class */ - H5HF_sect_indirect_term_cls, /* Terminate section class */ + H5HF__sect_indirect_init_cls, /* Initialize section class */ + H5HF__sect_indirect_term_cls, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - NULL, /* Deserialize section */ - NULL, /* Can sections merge? */ - NULL, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - NULL, /* Free section */ - NULL, /* Check validity of section */ - NULL, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + NULL, /* Deserialize section */ + NULL, /* Can sections merge? */ + NULL, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + NULL, /* Free section */ + NULL, /* Check validity of section */ + NULL, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Declare a free list to manage the H5HF_free_section_t struct */ H5FL_DEFINE(H5HF_free_section_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5HF_sect_init_cls + * Function: H5FS__sect_init_cls * * Purpose: Initialize the common class structure * @@ -319,12 +290,12 @@ H5FL_DEFINE(H5HF_free_section_t); *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) +H5FS__sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) { - H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(cls); @@ -333,22 +304,21 @@ H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) /* Allocate & initialize the class-private (i.e. private shared) information * for this type of section */ - if(NULL == (cls_prvt = (H5HF_sect_private_t *)H5MM_malloc(sizeof(H5HF_sect_private_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - cls_prvt->hdr = hdr; + if (NULL == (cls_prvt = (H5HF_sect_private_t *)H5MM_malloc(sizeof(H5HF_sect_private_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + cls_prvt->hdr = hdr; cls->cls_private = cls_prvt; /* Increment reference count on heap header */ - if(H5HF_hdr_incr(hdr) < 0) + if (H5HF__hdr_incr(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared heap header") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_init_cls() */ +} /* H5FS__sect_init_cls() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_term_cls + * Function: H5FS__sect_term_cls * * Purpose: Terminate the common class structure * @@ -361,12 +331,12 @@ H5HF_sect_init_cls(H5FS_section_class_t *cls, H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_term_cls(H5FS_section_class_t *cls) +H5FS__sect_term_cls(H5FS_section_class_t *cls) { - H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(cls); @@ -375,7 +345,7 @@ H5HF_sect_term_cls(H5FS_section_class_t *cls) cls_prvt = (H5HF_sect_private_t *)cls->cls_private; /* Decrement reference count on heap header */ - if(H5HF_hdr_decr(cls_prvt->hdr) < 0) + if (H5HF__hdr_decr(cls_prvt->hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") /* Free the class private information */ @@ -383,11 +353,10 @@ H5HF_sect_term_cls(H5FS_section_class_t *cls) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_term_cls() */ +} /* H5FS__sect_term_cls() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_node_new + * Function: H5FS__sect_node_new * * Purpose: Allocate a free space section node of a particular type * @@ -401,27 +370,27 @@ H5HF_sect_term_cls(H5FS_section_class_t *cls) *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, - H5FS_section_state_t sect_state) +H5FS__sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t sect_state) { - H5HF_free_section_t *new_sect; /* New section */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New section */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(H5F_addr_defined(sect_addr)); /* Create free list section node */ - if(NULL == (new_sect = H5FL_MALLOC(H5HF_free_section_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct block free list section") + if (NULL == (new_sect = H5FL_MALLOC(H5HF_free_section_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for direct block free list section") /* Set the information passed in */ new_sect->sect_info.addr = sect_addr; new_sect->sect_info.size = sect_size; /* Set the section's class & state */ - new_sect->sect_info.type = sect_type; + new_sect->sect_info.type = sect_type; new_sect->sect_info.state = sect_state; /* Set return value */ @@ -429,11 +398,10 @@ H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_node_new() */ +} /* H5FS__sect_node_new() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_node_free + * Function: H5HF__sect_node_free * * Purpose: Free a section node * @@ -447,29 +415,29 @@ H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size, *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *iblock) +H5HF__sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(sect); /* Release indirect block, if there was one */ - if(iblock) - if(H5HF__iblock_decr(iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (iblock) + if (H5HF__iblock_decr(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_node_free() */ +} /* H5HF__sect_node_free() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_single_new + * Function: H5HF__sect_single_new * * Purpose: Create a new 'single' section and return it to the caller * @@ -481,13 +449,12 @@ H5HF_sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *iblock) *------------------------------------------------------------------------- */ H5HF_free_section_t * -H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, - H5HF_indirect_t *parent, unsigned par_entry) +H5HF__sect_single_new(hsize_t sect_off, size_t sect_size, H5HF_indirect_t *parent, unsigned par_entry) { - H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Single' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -495,14 +462,16 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, HDassert(sect_size); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_off, (hsize_t)sect_size, H5FS_SECT_LIVE))) + if (NULL == + (sect = H5FS__sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_off, (hsize_t)sect_size, H5FS_SECT_LIVE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for single section") /* Set the 'single' specific fields */ sect->u.single.parent = parent; - if(sect->u.single.parent) { - if(H5HF_iblock_incr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (sect->u.single.parent) { + if (H5HF__iblock_incr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ sect->u.single.par_entry = par_entry; @@ -510,15 +479,14 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, ret_value = sect; done: - if(!ret_value && sect) { + if (!ret_value && sect) { /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_single_new() */ +} /* end H5HF__sect_single_new() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_locate_parent * @@ -532,13 +500,12 @@ H5HF_sect_single_new(hsize_t sect_off, size_t sect_size, *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, - H5HF_free_section_t *sect) +H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, H5HF_free_section_t *sect) { - H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ - unsigned sec_entry; /* Entry within section indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ + unsigned sec_entry; /* Entry within section indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -550,28 +517,30 @@ H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, HDassert(sect); /* Look up indirect block containing direct blocks for range */ - if(H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, &sec_entry, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, &sec_entry, &did_protect, + H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Increment reference count on indirect block that free section is in */ - if(H5HF_iblock_incr(sec_iblock) < 0) + if (H5HF__iblock_incr(sec_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block") /* Check for refreshing existing parent information */ - if(refresh) { - if(sect->u.single.parent) { + if (refresh) { + if (sect->u.single.parent) { /* Release hold on previous parent indirect block */ - if(H5HF__iblock_decr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (H5HF__iblock_decr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") } /* end if */ - } /* end if */ + } /* end if */ /* Set the information for the section */ - sect->u.single.parent = sec_iblock; + sect->u.single.parent = sec_iblock; sect->u.single.par_entry = sec_entry; /* Unlock indirect block */ - if(H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") sec_iblock = NULL; @@ -579,7 +548,6 @@ H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_locate_parent() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_revive * @@ -595,7 +563,7 @@ H5HF__sect_single_locate_parent(H5HF_hdr_t *hdr, hbool_t refresh, herr_t H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -607,15 +575,15 @@ H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED); /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Set the information for the section */ HDassert(H5F_addr_defined(hdr->man_dtable.table_addr)); - sect->u.single.parent = NULL; + sect->u.single.parent = NULL; sect->u.single.par_entry = 0; } /* end if */ else { /* Look up indirect block information for section */ - if(H5HF__sect_single_locate_parent(hdr, FALSE, sect) < 0) + if (H5HF__sect_single_locate_parent(hdr, FALSE, sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get section's parent info") } /* end else */ @@ -626,9 +594,8 @@ H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_revive() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_single_dblock_info + * Function: H5HF__sect_single_dblock_info * * Purpose: Retrieve the direct block information for a single section * @@ -640,10 +607,10 @@ H5HF__sect_single_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ herr_t -H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, - haddr_t *dblock_addr, size_t *dblock_size) +H5HF__sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, haddr_t *dblock_addr, + size_t *dblock_size) { - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -656,22 +623,22 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, HDassert(dblock_size); /* Check for root direct block */ - if(hdr->man_dtable.curr_root_rows == 0) { + if (hdr->man_dtable.curr_root_rows == 0) { /* Retrieve direct block info from heap header */ HDassert(H5F_addr_defined(hdr->man_dtable.table_addr)); - *dblock_addr = hdr->man_dtable.table_addr; - *dblock_size = hdr->man_dtable.cparam.start_block_size; + *dblock_addr = hdr->man_dtable.table_addr; + *dblock_size = hdr->man_dtable.cparam.start_block_size; } /* end if */ else { /* Retrieve direct block info from parent indirect block */ - *dblock_addr = sect->u.single.parent->ents[sect->u.single.par_entry].addr; - *dblock_size = hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; + *dblock_addr = sect->u.single.parent->ents[sect->u.single.par_entry].addr; + *dblock_size = + hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_sect_single_dblock_info() */ +} /* end H5HF__sect_single_dblock_info() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_reduce * @@ -689,7 +656,7 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, herr_t H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -702,9 +669,9 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) HDassert(sect->sect_info.state == H5FS_SECT_LIVE); /* Check for eliminating the section */ - if(sect->sect_info.size == amt) { + if (sect->sect_info.size == amt) { /* Free single section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)sect) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free single section node") } /* end if */ else { @@ -713,7 +680,7 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) sect->sect_info.size -= amt; /* Re-insert section node into heap's free space */ - if(H5HF__space_add(hdr, sect, 0) < 0) + if (H5HF__space_add(hdr, sect, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add single section to free space manager") } /* end else */ @@ -721,7 +688,6 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_single_reduce() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_full_dblock * @@ -742,12 +708,12 @@ H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt) static herr_t H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - haddr_t dblock_addr; /* Section's direct block's address */ - size_t dblock_size; /* Section's direct block's size */ - size_t dblock_overhead; /* Direct block's overhead */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t dblock_addr; /* Section's direct block's address */ + size_t dblock_size; /* Section's direct block's size */ + size_t dblock_overhead; /* Direct block's overhead */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect); @@ -755,35 +721,35 @@ H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(hdr); /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, sect, &dblock_addr, &dblock_size) < 0) + if (H5HF__sect_single_dblock_info(hdr, sect, &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Check for section occupying entire direct block */ /* (and not the root direct block) */ dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((dblock_size - dblock_overhead) == sect->sect_info.size && - hdr->man_dtable.curr_root_rows > 0) { - H5HF_direct_t *dblock; /* Pointer to direct block for section */ - hbool_t parent_removed; /* Whether the direct block parent was removed from the file */ + if ((dblock_size - dblock_overhead) == sect->sect_info.size && hdr->man_dtable.curr_root_rows > 0) { + H5HF_direct_t *dblock; /* Pointer to direct block for section */ + hbool_t parent_removed; /* Whether the direct block parent was removed from the file */ - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sect->u.single.parent, sect->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, sect->u.single.parent, + sect->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") HDassert(H5F_addr_eq(dblock->block_off + dblock_overhead, sect->sect_info.addr)); /* Convert 'single' section into 'row' section */ - if(H5HF_sect_row_from_single(hdr, sect, dblock) < 0) + if (H5HF__sect_row_from_single(hdr, sect, dblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't convert single section into row section") /* Destroy direct block */ - if(H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, &parent_removed) < 0) + if (H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, &parent_removed) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block") dblock = NULL; /* If the parent for this direct block was removed and the indirect * section is still "live", switch it to the "serialized" state. */ - if(parent_removed && H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) - if(H5HF__sect_row_parent_removed(sect) < 0) + if (parent_removed && H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) + if (H5HF__sect_row_parent_removed(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "can't update section info") } /* end if */ @@ -791,7 +757,6 @@ H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_full_dblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_add * @@ -809,17 +774,17 @@ H5HF__sect_single_full_dblock(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) static herr_t H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Don't need to check section if we are deserializing, because it should * have already been checked when it was first added */ - 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 */ + 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 */ /* Sanity check */ HDassert(sect); @@ -827,14 +792,14 @@ H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF__sect_single_full_dblock(hdr, (*sect)) < 0) + if (H5HF__sect_single_full_dblock(hdr, (*sect)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") /* Set the "returned space" flag if the single section was changed * into a row section, so the "merging & shrinking" algorithm * gets executed in the free space manager */ - if((*sect)->sect_info.type != H5HF_FSPACE_SECT_SINGLE) + if ((*sect)->sect_info.type != H5HF_FSPACE_SECT_SINGLE) *flags |= H5FS_ADD_RETURNED_SPACE; } /* end if */ @@ -842,7 +807,6 @@ H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_add() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_deserialize * @@ -858,11 +822,11 @@ H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata */ static H5FS_section_info_t * H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, - const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, - hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) + const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, hsize_t sect_size, + unsigned H5_ATTR_UNUSED *des_flags) { - H5HF_free_section_t *new_sect; /* New section */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New section */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -871,7 +835,8 @@ H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, HDassert(sect_size); /* Create free list section node */ - if(NULL == (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_addr, sect_size, H5FS_SECT_SERIALIZED))) + if (NULL == + (new_sect = H5FS__sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_addr, sect_size, H5FS_SECT_SERIALIZED))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "allocation failed for direct block free list section") /* Set return value */ @@ -881,7 +846,6 @@ H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_can_merge * @@ -899,19 +863,19 @@ H5HF__sect_single_deserialize(const H5FS_section_class_t H5_ATTR_UNUSED *cls, *------------------------------------------------------------------------- */ static htri_t -H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -919,14 +883,13 @@ H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, * overhead at the beginning of a block, so no need to check if sections * are actually within the same direct block) */ - if(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)) + if (H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_merge * @@ -944,14 +907,13 @@ H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -966,24 +928,23 @@ H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)sect2) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") /* Check to see if we should revive first section */ - if((*sect1)->sect_info.state != H5FS_SECT_LIVE) - if(H5HF__sect_single_revive(hdr, (*sect1)) < 0) + if ((*sect1)->sect_info.state != H5FS_SECT_LIVE) + if (H5HF__sect_single_revive(hdr, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Check if single section covers entire direct block it's in */ /* (converts to row section possibly) */ - if(H5HF__sect_single_full_dblock(hdr, (*sect1)) < 0) + if (H5HF__sect_single_full_dblock(hdr, (*sect1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't check/convert single section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_can_shrink * @@ -1005,10 +966,10 @@ H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1021,13 +982,13 @@ H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) * would have been converted into a row section, if there was an * indirect block that covered it) */ - if(hdr->man_dtable.curr_root_rows == 0) { - size_t dblock_size; /* Section's direct block's size */ - size_t dblock_overhead; /* Direct block's overhead */ + if (hdr->man_dtable.curr_root_rows == 0) { + size_t dblock_size; /* Section's direct block's size */ + size_t dblock_overhead; /* Direct block's overhead */ - dblock_size = hdr->man_dtable.cparam.start_block_size; + dblock_size = hdr->man_dtable.cparam.start_block_size; dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - if((dblock_size - dblock_overhead) == sect->sect_info.size) + if ((dblock_size - dblock_overhead) == sect->sect_info.size) HGOTO_DONE(TRUE) } /* end if */ else { @@ -1042,7 +1003,6 @@ H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_shrink * @@ -1060,13 +1020,13 @@ H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC @@ -1076,27 +1036,28 @@ H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert((*sect)->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Check to see if we should revive section */ - if((*sect)->sect_info.state != H5FS_SECT_LIVE) - if(H5HF__sect_single_revive(hdr, (*sect)) < 0) + if ((*sect)->sect_info.state != H5FS_SECT_LIVE) + if (H5HF__sect_single_revive(hdr, (*sect)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section") /* Retrieve direct block address from section */ - if(H5HF_sect_single_dblock_info(hdr, (*sect), &dblock_addr, &dblock_size) < 0) + if (H5HF__sect_single_dblock_info(hdr, (*sect), &dblock_addr, &dblock_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information") /* Protect the direct block for the section */ /* (should be a root direct block) */ HDassert(dblock_addr == hdr->man_dtable.table_addr); - if(NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, (*sect)->u.single.parent, (*sect)->u.single.par_entry, H5AC__NO_FLAGS_SET))) + if (NULL == (dblock = H5HF__man_dblock_protect(hdr, dblock_addr, dblock_size, (*sect)->u.single.parent, + (*sect)->u.single.par_entry, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block") HDassert(H5F_addr_eq(dblock->block_off + dblock_size, (*sect)->sect_info.addr + (*sect)->sect_info.size)); /* Get rid of section */ - if(H5HF__sect_single_free((H5FS_section_info_t *)*sect) < 0) + if (H5HF__sect_single_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") /* Destroy direct block */ - if(H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, NULL) < 0) + if (H5HF__man_dblock_destroy(hdr, dblock, dblock_addr, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block") dblock = NULL; @@ -1107,7 +1068,6 @@ H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_single_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_free * @@ -1125,9 +1085,9 @@ H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1135,20 +1095,19 @@ H5HF__sect_single_free(H5FS_section_info_t *_sect) HDassert(sect); /* Check for live reference to an indirect block */ - if(sect->sect_info.state == H5FS_SECT_LIVE) + if (sect->sect_info.state == H5FS_SECT_LIVE) /* Get parent indirect block, if there was one */ - if(sect->u.single.parent) + if (sect->u.single.parent) parent = sect->u.single.parent; /* Release the section */ - if(H5HF_sect_node_free(sect, parent) < 0) + if (H5HF__sect_node_free(sect, parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_single_free() */ +} /* H5HF__sect_single_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_single_valid * @@ -1165,30 +1124,31 @@ H5HF__sect_single_free(H5FS_section_info_t *_sect) static herr_t H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t *_sect) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect); - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { /* 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 */ - 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 */ - size_t H5_ATTR_NDEBUG_UNUSED dblock_overhead; /* Direct block's overhead */ - herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic status value */ + if (sect->u.single.parent != NULL) { + 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 */ + size_t H5_ATTR_NDEBUG_UNUSED dblock_overhead; /* Direct block's overhead */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic status value */ /* Sanity check settings for section's direct block's parent */ iblock = sect->u.single.parent; HDassert(H5F_addr_defined(iblock->ents[sect->u.single.par_entry].addr)); /* Retrieve direct block address from section */ - status = H5HF_sect_single_dblock_info(iblock->hdr, (const H5HF_free_section_t *)sect, &dblock_addr, &dblock_size); + status = H5HF__sect_single_dblock_info(iblock->hdr, (const H5HF_free_section_t *)sect, + &dblock_addr, &dblock_size); HDassert(status >= 0); HDassert(H5F_addr_eq(iblock->ents[sect->u.single.par_entry].addr, dblock_addr)); HDassert(dblock_size > 0); @@ -1208,32 +1168,34 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 * protect it here in order to check single section's sanity * against it. */ - if(!(dblock_status & H5AC_ES__IS_PROTECTED)) { - H5HF_direct_t *dblock; /* Direct block for section */ + if (!(dblock_status & H5AC_ES__IS_PROTECTED)) { + H5HF_direct_t *dblock; /* Direct block for section */ /* Protect the direct block for the section */ - dblock = H5HF__man_dblock_protect(iblock->hdr, dblock_addr, dblock_size, iblock, sect->u.single.par_entry, H5AC__READ_ONLY_FLAG); + dblock = H5HF__man_dblock_protect(iblock->hdr, dblock_addr, dblock_size, iblock, + sect->u.single.par_entry, H5AC__READ_ONLY_FLAG); HDassert(dblock); /* Sanity check settings for section */ HDassert(dblock_size == dblock->size); HDassert(dblock->size > sect->sect_info.size); HDassert(H5F_addr_lt(dblock->block_off, sect->sect_info.addr)); - HDassert(H5F_addr_ge((dblock->block_off + dblock->size), (sect->sect_info.addr + sect->sect_info.size))); + HDassert(H5F_addr_ge((dblock->block_off + dblock->size), + (sect->sect_info.addr + sect->sect_info.size))); /* Release direct block */ - status = H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET); + status = H5AC_unprotect(iblock->hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, + H5AC__NO_FLAGS_SET); HDassert(status >= 0); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF__sect_single_valid() */ +} /* H5HF__sect_single_valid() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_row_create + * Function: H5HF__sect_row_create * * Purpose: Create a new 'row' section * @@ -1247,13 +1209,13 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, - unsigned row, unsigned col, unsigned nentries, H5HF_free_section_t *under_sect) +H5HF__sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, unsigned row, unsigned col, + unsigned nentries, H5HF_free_section_t *under_sect) { - H5HF_free_section_t *sect = NULL; /* 'Row' section created */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Row' section created */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(sect_size); @@ -1262,13 +1224,15 @@ H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, /* Create 'row' free space section node */ /* ("inherits" underlying indirect section's state) */ - if(NULL == (sect = H5HF_sect_node_new((unsigned)(is_first ? H5HF_FSPACE_SECT_FIRST_ROW : H5HF_FSPACE_SECT_NORMAL_ROW), sect_off, sect_size, under_sect->sect_info.state))) + if (NULL == (sect = H5FS__sect_node_new( + (unsigned)(is_first ? H5HF_FSPACE_SECT_FIRST_ROW : H5HF_FSPACE_SECT_NORMAL_ROW), + sect_off, sect_size, under_sect->sect_info.state))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for row section") /* Set the 'row' specific fields */ - sect->u.row.under = under_sect; - sect->u.row.row = row; - sect->u.row.col = col; + sect->u.row.under = under_sect; + sect->u.row.row = row; + sect->u.row.col = col; sect->u.row.num_entries = nentries; sect->u.row.checked_out = FALSE; @@ -1277,11 +1241,10 @@ H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_row_create() */ +} /* H5HF__sect_row_create() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_row_from_single + * Function: H5HF__sect_row_from_single * * Purpose: Convert a 'single' section into a 'row' section * @@ -1293,12 +1256,11 @@ H5HF_sect_row_create(haddr_t sect_off, hsize_t sect_size, hbool_t is_first, *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - H5HF_direct_t *dblock) +H5HF__sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_direct_t *dblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -1308,26 +1270,25 @@ H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(dblock); /* Convert 'single' section information to 'row' section info */ - sect->sect_info.addr = dblock->block_off; - sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; - sect->u.row.row = dblock->par_entry / hdr->man_dtable.cparam.width; - sect->u.row.col = dblock->par_entry % hdr->man_dtable.cparam.width; + sect->sect_info.addr = dblock->block_off; + sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; + sect->u.row.row = dblock->par_entry / hdr->man_dtable.cparam.width; + sect->u.row.col = dblock->par_entry % hdr->man_dtable.cparam.width; sect->u.row.num_entries = 1; sect->u.row.checked_out = FALSE; /* Create indirect section that underlies the row section */ - if(NULL == (sect->u.row.under = H5HF_sect_indirect_for_row(hdr, dblock->parent, sect))) + if (NULL == (sect->u.row.under = H5HF__sect_indirect_for_row(hdr, dblock->parent, sect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "serializing row section not supported yet") /* Release single section's hold on underlying indirect block */ - if(H5HF__iblock_decr(dblock->parent) < 0) + if (H5HF__iblock_decr(dblock->parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_row_from_single() */ +} /* end H5HF__sect_row_from_single() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_revive * @@ -1343,7 +1304,7 @@ H5HF_sect_row_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, herr_t H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1357,14 +1318,14 @@ H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) /* If the indirect section's iblock has been removed from the cache, but the * section is still marked as "live", switch it to the "serialized" state. */ - if((H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) - && (TRUE == sect->u.row.under->u.indirect.u.iblock->removed_from_cache)) - if(H5HF__sect_row_parent_removed(sect) < 0) + if ((H5FS_SECT_LIVE == sect->u.row.under->sect_info.state) && + (TRUE == sect->u.row.under->u.indirect.u.iblock->removed_from_cache)) + if (H5HF__sect_row_parent_removed(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUPDATE, FAIL, "can't update section info") /* Pass along "revive" request to underlying indirect section */ /* (which will mark this section as "live") */ - if(H5HF__sect_indirect_revive_row(hdr, sect->u.row.under) < 0) + if (H5HF__sect_indirect_revive_row(hdr, sect->u.row.under) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") HDassert(sect->sect_info.state == H5FS_SECT_LIVE); @@ -1372,7 +1333,6 @@ H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_revive() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_reduce * @@ -1388,11 +1348,10 @@ H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ herr_t -H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - unsigned *entry_p) +H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned *entry_p) { - hbool_t alloc_from_start; /* Whether to allocate from the end of the row */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t alloc_from_start; /* Whether to allocate from the end of the row */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1402,7 +1361,7 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(hdr); HDassert(sect); HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(sect->sect_info.state == H5FS_SECT_LIVE); HDassert(entry_p); @@ -1412,23 +1371,23 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Forward row section to indirect routines, to handle reducing underlying indirect section */ alloc_from_start = FALSE; - if(H5HF__sect_indirect_reduce_row(hdr, sect, &alloc_from_start) < 0) + if (H5HF__sect_indirect_reduce_row(hdr, sect, &alloc_from_start) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce underlying section") /* Determine entry allocated */ *entry_p = (sect->u.row.row * hdr->man_dtable.cparam.width) + sect->u.row.col; - if(!alloc_from_start) + if (!alloc_from_start) *entry_p += (sect->u.row.num_entries - 1); /* Check for eliminating the section */ - if(sect->u.row.num_entries == 1) { + if (sect->u.row.num_entries == 1) { /* Free row section */ - if(H5HF__sect_row_free((H5FS_section_info_t *)sect) < 0) + if (H5HF__sect_row_free((H5FS_section_info_t *)sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free row section node") } /* end if */ else { /* Check whether to allocate from the beginning or end of the row */ - if(alloc_from_start) { + if (alloc_from_start) { /* Adjust section start */ sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.row.row]; sect->u.row.col++; @@ -1441,7 +1400,7 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.row.checked_out = FALSE; /* Add 'row' section back to free space list */ - if(H5HF__space_add(hdr, sect, 0) < 0) + if (H5HF__space_add(hdr, sect, 0) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add indirect section to free space manager") } /* end else */ @@ -1449,7 +1408,6 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_reduce() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_first * @@ -1465,7 +1423,7 @@ H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, static herr_t H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1478,20 +1436,19 @@ H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) * change it's class directly and the free space manager will adjust when * it is checked back in. */ - if(sect->u.row.checked_out) + if (sect->u.row.checked_out) sect->sect_info.type = H5HF_FSPACE_SECT_FIRST_ROW; 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") + 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") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_first() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_row_get_iblock + * Function: H5HF__sect_row_get_iblock * * Purpose: Retrieve the indirect block for a row section * @@ -1503,26 +1460,25 @@ H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ H5HF_indirect_t * -H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) +H5HF__sect_row_get_iblock(H5HF_free_section_t *sect) { - H5HF_indirect_t *ret_value = NULL; /* Return value */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. */ HDassert(sect); HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || - sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(sect->sect_info.state == H5FS_SECT_LIVE); - ret_value = H5HF_sect_indirect_get_iblock(sect->u.row.under); + ret_value = H5HF__sect_indirect_get_iblock(sect->u.row.under); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_row_get_iblock() */ +} /* end H5HF__sect_row_get_iblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_parent_removed * @@ -1539,9 +1495,9 @@ H5HF_sect_row_get_iblock(H5HF_free_section_t *sect) static herr_t H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) { - hsize_t tmp_iblock_off; /* Indirect block offset for row */ - unsigned u; /* Local index value */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_iblock_off; /* Indirect block offset for row */ + unsigned u; /* Local index value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1552,16 +1508,16 @@ H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) tmp_iblock_off = sect->u.row.under->u.indirect.u.iblock->block_off; /* Decrement the refcount on the indirect block, since serialized sections don't hold a reference */ - if(H5HF__iblock_decr(sect->u.row.under->u.indirect.u.iblock) < 0) + if (H5HF__iblock_decr(sect->u.row.under->u.indirect.u.iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Switch indirect block info to serialized form */ /* (Overwrites iblock pointer in the indirect section) */ - sect->u.row.under->u.indirect.u.iblock_off = tmp_iblock_off; + sect->u.row.under->u.indirect.u.iblock_off = tmp_iblock_off; sect->u.row.under->u.indirect.iblock_entries = 0; /* Loop over derived row sections and mark them all as 'live' now */ - for(u = 0; u < sect->u.row.under->u.indirect.dir_nrows; u++) + for (u = 0; u < sect->u.row.under->u.indirect.dir_nrows; u++) sect->u.row.under->u.indirect.dir_rows[u]->sect_info.state = H5FS_SECT_SERIALIZED; /* Mark the indirect section as serialized now */ @@ -1574,7 +1530,6 @@ H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_row_parent_removed() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_init_cls * @@ -1595,8 +1550,8 @@ H5HF__sect_row_parent_removed(H5HF_free_section_t *sect) static herr_t H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1605,11 +1560,11 @@ H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) HDassert(hdr); /* Call common class initialization */ - if(H5HF_sect_init_cls(cls, hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") + if (H5FS__sect_init_cls(cls, hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") /* First row sections actually are proxies for indirection sections on disk */ - if(cls->type == H5HF_FSPACE_SECT_FIRST_ROW) + if (cls->type == H5HF_FSPACE_SECT_FIRST_ROW) cls->serial_size = H5HF_SECT_INDIRECT_SERIAL_SIZE(hdr); else cls->serial_size = 0; @@ -1618,7 +1573,6 @@ H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_init_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_term_cls * @@ -1639,7 +1593,7 @@ H5HF__sect_row_init_cls(H5FS_section_class_t *cls, void *_udata) static herr_t H5HF__sect_row_term_cls(H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1647,14 +1601,13 @@ H5HF__sect_row_term_cls(H5FS_section_class_t *cls) HDassert(cls); /* Call common class termination */ - if(H5HF_sect_term_cls(cls) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") + if (H5FS__sect_term_cls(cls) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_term_cls() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_serialize * @@ -1670,12 +1623,11 @@ 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__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 */ - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -1688,14 +1640,14 @@ H5HF__sect_row_serialize(const H5FS_section_class_t *cls, /* Forward to indirect routine to serialize underlying section */ hdr = ((H5HF_sect_private_t *)(cls->cls_private))->hdr; - if(H5HF_sect_indirect_serialize(hdr, sect->u.row.under, buf) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, "can't serialize row section's underlying indirect section") + if (H5HF__sect_indirect_serialize(hdr, sect->u.row.under, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, + "can't serialize row section's underlying indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_deserialize * @@ -1714,11 +1666,11 @@ H5HF__sect_row_serialize(const H5FS_section_class_t *cls, *------------------------------------------------------------------------- */ 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__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 */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_hdr_t * hdr; /* Fractal heap header */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1730,14 +1682,14 @@ H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, /* Forward to indirect routine to deserialize underlying section */ hdr = ((H5HF_sect_private_t *)(cls->cls_private))->hdr; - if(NULL == (ret_value = H5HF__sect_indirect_deserialize(hdr, buf, sect_addr, sect_size, des_flags))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't deserialize row section's underlying indirect section") + if (NULL == (ret_value = H5HF__sect_indirect_deserialize(hdr, buf, sect_addr, sect_size, des_flags))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, + "can't deserialize row section's underlying indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_can_merge * @@ -1755,13 +1707,13 @@ H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, *------------------------------------------------------------------------- */ static htri_t -H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1769,30 +1721,31 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, HDassert(sect1); HDassert(sect1->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Get the top indirect section underlying each row */ - top_indir_sect1 = H5HF_sect_indirect_top(sect1->u.row.under); + top_indir_sect1 = H5HF__sect_indirect_top(sect1->u.row.under); HDassert(top_indir_sect1); - top_indir_sect2 = H5HF_sect_indirect_top(sect2->u.row.under); + top_indir_sect2 = H5HF__sect_indirect_top(sect2->u.row.under); HDassert(top_indir_sect2); /* Check if second section shares the same underlying indirect block as * the first section, but doesn't already have same underlying indirect * section. */ - if(top_indir_sect1 != top_indir_sect2) - if(H5HF_sect_indirect_iblock_off(sect1->u.row.under) == H5HF_sect_indirect_iblock_off(sect2->u.row.under)) + if (top_indir_sect1 != top_indir_sect2) + if (H5HF__sect_indirect_iblock_off(sect1->u.row.under) == + H5HF__sect_indirect_iblock_off(sect2->u.row.under)) /* Check if second section adjoins first section */ - if(H5F_addr_eq((top_indir_sect1->sect_info.addr + top_indir_sect1->u.indirect.span_size), top_indir_sect2->sect_info.addr)) + if (H5F_addr_eq((top_indir_sect1->sect_info.addr + top_indir_sect1->u.indirect.span_size), + top_indir_sect2->sect_info.addr)) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_merge * @@ -1810,14 +1763,13 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1828,26 +1780,25 @@ H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, HDassert(sect2->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Check if second section is past end of "next block" iterator */ - if(sect2->sect_info.addr >= hdr->man_iter_off) { - H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ + if (sect2->sect_info.addr >= hdr->man_iter_off) { + H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ /* Get the top indirect section underlying second row section */ - top_indir_sect = H5HF_sect_indirect_top(sect2->u.row.under); + top_indir_sect = H5HF__sect_indirect_top(sect2->u.row.under); /* Shrink away underlying indirect section */ - if(H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) + if (H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't shrink underlying indirect section") } /* end if */ 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") + if (H5HF__sect_indirect_merge_row(hdr, (*sect1), sect2) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_merge() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_can_shrink * @@ -1869,10 +1820,10 @@ H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1881,14 +1832,13 @@ H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Check if section is past end of "next block" iterator */ - if(sect->sect_info.addr >= hdr->man_iter_off) + if (sect->sect_info.addr >= hdr->man_iter_off) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_shrink * @@ -1906,11 +1856,11 @@ H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1920,10 +1870,10 @@ H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert((*sect)->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Get the top indirect section underlying each row */ - top_indir_sect = H5HF_sect_indirect_top((*sect)->u.row.under); + top_indir_sect = H5HF__sect_indirect_top((*sect)->u.row.under); /* Shrink away underlying indirect section */ - if(H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) + if (H5HF__sect_indirect_shrink(hdr, top_indir_sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't shrink underlying indirect section") /* Indicate that the section has been released */ @@ -1933,7 +1883,6 @@ H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_row_shrink() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_free_real * @@ -1951,21 +1900,20 @@ H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) static herr_t H5HF__sect_row_free_real(H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(sect); /* Release the section */ - if(H5HF_sect_node_free(sect, NULL) < 0) + if (H5HF__sect_node_free(sect, NULL) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_row_free_real() */ +} /* H5HF__sect_row_free_real() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_free * @@ -1983,8 +1931,8 @@ H5HF__sect_row_free_real(H5HF_free_section_t *sect) static herr_t H5HF__sect_row_free(H5FS_section_info_t *_sect) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1992,18 +1940,17 @@ H5HF__sect_row_free(H5FS_section_info_t *_sect) HDassert(sect->u.row.under); /* Decrement the ref. count on the row section's underlying indirect section */ - if(H5HF_sect_indirect_decr(sect->u.row.under) < 0) + if (H5HF__sect_indirect_decr(sect->u.row.under) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't detach section node") /* Release the section */ - if(H5HF__sect_row_free_real(sect) < 0) + if (H5HF__sect_row_free_real(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__sect_row_free() */ +} /* H5HF__sect_row_free() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_valid * @@ -2020,10 +1967,10 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -2034,37 +1981,36 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t /* Retrieve class private information */ cls_prvt = (H5HF_sect_private_t *)cls->cls_private; - hdr = cls_prvt->hdr; + hdr = cls_prvt->hdr; /* Sanity checking on the row */ HDassert(sect->u.row.under); HDassert(sect->u.row.num_entries); HDassert(sect->u.row.checked_out == FALSE); indir_sect = sect->u.row.under; - indir_idx = sect->u.row.row - indir_sect->u.indirect.row; + indir_idx = sect->u.row.row - indir_sect->u.indirect.row; HDassert(indir_sect->u.indirect.dir_rows[indir_idx] == sect); /* Check if the section is actually within the heap */ HDassert(sect->sect_info.addr < hdr->man_iter_off); /* Different checking for different kinds of rows */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { - H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ + if (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { + H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ /* Some extra sanity checks on the row */ HDassert(sect->u.row.row == indir_sect->u.indirect.row); /* Get the top indirect section underlying row */ - top_indir_sect = H5HF_sect_indirect_top(sect->u.row.under); + top_indir_sect = H5HF__sect_indirect_top(sect->u.row.under); /* Check that the row's underlying indirect section is valid */ - H5HF_sect_indirect_valid(hdr, top_indir_sect); + H5HF__sect_indirect_valid(hdr, top_indir_sect); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF__sect_row_valid() */ +} /* H5HF__sect_row_valid() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_row_debug * @@ -2081,7 +2027,7 @@ H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t static herr_t H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, int fwidth) { - const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Section to dump info */ + const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Section to dump info */ FUNC_ENTER_STATIC_NOERR @@ -2089,31 +2035,23 @@ H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, HDassert(sect); /* Print indirect section information */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Row:", - sect->u.row.row); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Column:", - sect->u.row.col); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of entries:", - sect->u.row.num_entries); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Row:", sect->u.row.row); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Column:", sect->u.row.col); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of entries:", sect->u.row.num_entries); /* If this is a first row section display information about underlying indirect section */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { + if (sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) { /* Print indirect section header */ - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Underlying indirect section:"); + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Underlying indirect section:"); - H5HF_sect_indirect_debug(sect->u.row.under, stream, indent + 3, MAX(0, fwidth - 3)); + H5HF__sect_indirect_debug(sect->u.row.under, stream, indent + 3, MAX(0, fwidth - 3)); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__sect_row_debug() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_iblock_off + * Function: H5HF__sect_indirect_iblock_off * * Purpose: Get the offset of the indirect block for the section * @@ -2125,25 +2063,25 @@ H5HF__sect_row_debug(const H5FS_section_info_t *_sect, FILE *stream, int indent, *------------------------------------------------------------------------- */ static hsize_t -H5HF_sect_indirect_iblock_off(const H5HF_free_section_t *sect) +H5HF__sect_indirect_iblock_off(const H5HF_free_section_t *sect) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Check arguments. */ HDassert(sect); - ret_value = sect->sect_info.state == H5FS_SECT_LIVE ? sect->u.indirect.u.iblock->block_off : sect->u.indirect.u.iblock_off; + ret_value = sect->sect_info.state == H5FS_SECT_LIVE ? sect->u.indirect.u.iblock->block_off + : sect->u.indirect.u.iblock_off; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_iblock_off() */ +} /* end H5HF__sect_indirect_iblock_off() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_top + * Function: H5HF__sect_indirect_top * * Purpose: Get the "top" indirect section * @@ -2155,28 +2093,27 @@ 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) +H5HF__sect_indirect_top(H5HF_free_section_t *sect) { - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Check arguments. */ HDassert(sect); - if(sect->u.indirect.parent) - ret_value = H5HF_sect_indirect_top(sect->u.indirect.parent); + if (sect->u.indirect.parent) + ret_value = H5HF__sect_indirect_top(sect->u.indirect.parent); else ret_value = sect; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_top() */ +} /* end H5HF__sect_indirect_top() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_init_cls + * Function: H5HF__sect_indirect_init_cls * * Purpose: Initialize the "indirect" class structure * @@ -2190,31 +2127,30 @@ H5HF_sect_indirect_top(H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *_udata) +H5HF__sect_indirect_init_cls(H5FS_section_class_t *cls, void *_udata) { - H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr = (H5HF_hdr_t *)_udata; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(cls); HDassert(hdr); /* Call to common class initialization */ - if(H5HF_sect_init_cls(cls, hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") + if (H5FS__sect_init_cls(cls, hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize common section class") /* Set the size of all serialized objects of this class of sections */ cls->serial_size = H5HF_SECT_INDIRECT_SERIAL_SIZE(hdr); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_indirect_init_cls() */ +} /* H5HF__sect_indirect_init_cls() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_term_cls + * Function: H5HF__sect_indirect_term_cls * * Purpose: Terminate the "indirect" class structure * @@ -2228,26 +2164,25 @@ H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls) +H5HF__sect_indirect_term_cls(H5FS_section_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(cls); /* Call common class termination */ - if(H5HF_sect_term_cls(cls) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") + if (H5FS__sect_term_cls(cls) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't terminate common section class") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_indirect_term_cls() */ +} /* H5HF__sect_indirect_term_cls() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_new + * Function: H5HF__sect_indirect_new * * Purpose: Create a new 'indirect' section for other routines to finish * initializing. @@ -2260,14 +2195,13 @@ H5HF_sect_indirect_term_cls(H5FS_section_class_t *cls) *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, - H5HF_indirect_t *iblock, hsize_t iblock_off, unsigned row, unsigned col, - unsigned nentries) +H5HF__sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, H5HF_indirect_t *iblock, + hsize_t iblock_off, unsigned row, unsigned col, unsigned nentries) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -2276,50 +2210,48 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, HDassert(nentries); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_off, - sect_size, (iblock ? H5FS_SECT_LIVE : H5FS_SECT_SERIALIZED)))) + if (NULL == (sect = H5FS__sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_off, sect_size, + (iblock ? H5FS_SECT_LIVE : H5FS_SECT_SERIALIZED)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for indirect section") /* Set the 'indirect' specific fields */ - if(iblock) { - sect->u.indirect.u.iblock = iblock; - sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * - sect->u.indirect.u.iblock->max_rows; - if(H5HF_iblock_incr(sect->u.indirect.u.iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block") + if (iblock) { + sect->u.indirect.u.iblock = iblock; + sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * sect->u.indirect.u.iblock->max_rows; + if (H5HF__iblock_incr(sect->u.indirect.u.iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, + "can't increment reference count on shared indirect block") } /* end if */ else { - sect->u.indirect.u.iblock_off = iblock_off; + sect->u.indirect.u.iblock_off = iblock_off; sect->u.indirect.iblock_entries = 0; } /* end else */ - sect->u.indirect.row = row; - sect->u.indirect.col = col; + sect->u.indirect.row = row; + sect->u.indirect.col = col; sect->u.indirect.num_entries = nentries; /* Compute span size of indirect section */ - sect->u.indirect.span_size = H5HF_dtable_span_size(&hdr->man_dtable, - row, col, nentries); + sect->u.indirect.span_size = H5HF__dtable_span_size(&hdr->man_dtable, row, col, nentries); HDassert(sect->u.indirect.span_size > 0); /* This indirect section doesn't (currently) have a parent */ - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* Set return value */ ret_value = sect; done: - if(!ret_value && sect) { + if (!ret_value && sect) { /* Release the section */ sect = H5FL_FREE(H5HF_free_section_t, sect); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_new() */ +} /* end H5HF__sect_indirect_new() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_for_row + * Function: H5HF__sect_indirect_for_row * * Purpose: Create the underlying indirect section for a new row section * @@ -2331,13 +2263,12 @@ H5HF_sect_indirect_new(H5HF_hdr_t *hdr, haddr_t sect_off, hsize_t sect_size, *------------------------------------------------------------------------- */ static H5HF_free_section_t * -H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, - H5HF_free_section_t *row_sect) +H5HF__sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -2348,38 +2279,38 @@ H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, HDassert(row_sect->u.row.row < hdr->man_dtable.max_direct_rows); /* Create free space section node */ - if(NULL == (sect = H5HF_sect_indirect_new(hdr, row_sect->sect_info.addr, - row_sect->sect_info.size, iblock, iblock->block_off, - row_sect->u.row.row, row_sect->u.row.col, row_sect->u.row.num_entries))) + if (NULL == (sect = H5HF__sect_indirect_new(hdr, row_sect->sect_info.addr, row_sect->sect_info.size, + iblock, iblock->block_off, row_sect->u.row.row, + row_sect->u.row.col, row_sect->u.row.num_entries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create indirect section") /* Set # of direct rows covered */ sect->u.indirect.dir_nrows = 1; /* Allocate space for the derived row sections */ - if(NULL == (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) + if (NULL == + (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 */ sect->u.indirect.dir_rows[0] = row_sect; - sect->u.indirect.rc = 1; + sect->u.indirect.rc = 1; /* No indirect rows in current section */ sect->u.indirect.indir_nents = 0; - sect->u.indirect.indir_ents = NULL; + sect->u.indirect.indir_ents = NULL; /* Set return value */ ret_value = sect; done: - if(!ret_value && sect) - if(H5HF_sect_indirect_free(sect) < 0) + if (!ret_value && sect) + if (H5HF__sect_indirect_free(sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_for_row() */ +} /* end H5HF__sect_indirect_for_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_init_rows * @@ -2394,21 +2325,20 @@ H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - hbool_t first_child, H5HF_free_section_t **first_row_sect, - unsigned space_flags, unsigned start_row, unsigned start_col, - unsigned end_row, unsigned end_col) +H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_t first_child, + H5HF_free_section_t **first_row_sect, unsigned space_flags, unsigned start_row, + unsigned start_col, unsigned end_row, unsigned end_col) { - hsize_t curr_off; /* Offset of new section in "heap space" */ - size_t dblock_overhead; /* Direct block's overhead */ - unsigned row_entries; /* # of entries in row */ - unsigned row_col; /* Column within current row */ - unsigned curr_entry; /* Current entry within indirect section */ - unsigned curr_indir_entry; /* Current indirect entry within indirect section */ - unsigned curr_row; /* Current row within indirect section */ - unsigned dir_nrows; /* # of direct rows in indirect section */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t curr_off; /* Offset of new section in "heap space" */ + size_t dblock_overhead; /* Direct block's overhead */ + unsigned row_entries; /* # of entries in row */ + unsigned row_col; /* Column within current row */ + unsigned curr_entry; /* Current entry within indirect section */ + unsigned curr_indir_entry; /* Current indirect entry within indirect section */ + unsigned curr_row; /* Current row within indirect section */ + unsigned dir_nrows; /* # of direct rows in indirect section */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2420,13 +2350,13 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Reset reference count for indirect section */ /* (Also reset the direct & indirect row pointers */ - sect->u.indirect.rc = 0; - sect->u.indirect.dir_rows = NULL; + sect->u.indirect.rc = 0; + sect->u.indirect.dir_rows = NULL; sect->u.indirect.indir_ents = NULL; /* Set up direct block information, if necessary */ - if(start_row < hdr->man_dtable.max_direct_rows) { - unsigned max_direct_row; /* Max. direct row covered */ + if (start_row < hdr->man_dtable.max_direct_rows) { + unsigned max_direct_row; /* Max. direct row covered */ /* Compute max. direct row covered by indirect section */ max_direct_row = MIN(end_row, (hdr->man_dtable.max_direct_rows - 1)); @@ -2441,24 +2371,25 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.dir_nrows = 0; /* Allocate space for the derived row sections */ - if(NULL == (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * dir_nrows))) + if (NULL == (sect->u.indirect.dir_rows = + (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * dir_nrows))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") } /* end if */ else { /* No rows of direct blocks covered, reset direct row information */ - dir_nrows = 0; + dir_nrows = 0; sect->u.indirect.dir_nrows = 0; } /* end else */ /* Set up indirect block information, if necessary */ - if(end_row >= hdr->man_dtable.max_direct_rows) { - unsigned indirect_start_row; /* Row to start indirect entries on */ - unsigned indirect_start_col; /* Column to start indirect entries on */ - unsigned indirect_start_entry; /* Index of starting indirect entry */ - unsigned indirect_end_entry; /* Index of ending indirect entry */ + if (end_row >= hdr->man_dtable.max_direct_rows) { + unsigned indirect_start_row; /* Row to start indirect entries on */ + unsigned indirect_start_col; /* Column to start indirect entries on */ + unsigned indirect_start_entry; /* Index of starting indirect entry */ + unsigned indirect_end_entry; /* Index of ending indirect entry */ /* Compute starting indirect entry */ - if(start_row < hdr->man_dtable.max_direct_rows) { + if (start_row < hdr->man_dtable.max_direct_rows) { indirect_start_row = hdr->man_dtable.max_direct_rows; indirect_start_col = 0; } /* end if */ @@ -2466,8 +2397,7 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, indirect_start_row = start_row; indirect_start_col = start_col; } /* end else */ - indirect_start_entry = (indirect_start_row * hdr->man_dtable.cparam.width) - + indirect_start_col; + indirect_start_entry = (indirect_start_row * hdr->man_dtable.cparam.width) + indirect_start_col; /* Compute ending indirect entry */ indirect_end_entry = (end_row * hdr->man_dtable.cparam.width) + end_col; @@ -2476,7 +2406,8 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.indir_nents = (indirect_end_entry - indirect_start_entry) + 1; /* Allocate space for the child indirect sections */ - if(NULL == (sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * sect->u.indirect.indir_nents))) + if (NULL == (sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * sect->u.indirect.indir_nents))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for indirect section pointer array") } /* end if */ else { @@ -2485,38 +2416,38 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, } /* end else */ /* Set up initial row information */ - if(start_row == end_row) + if (start_row == end_row) row_entries = (end_col - start_col) + 1; else row_entries = hdr->man_dtable.cparam.width - start_col; row_col = start_col; /* Loop over creating the sections covered by this indirect section */ - curr_off = sect->sect_info.addr; - curr_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - curr_row = 0; + curr_off = sect->sect_info.addr; + curr_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; + curr_row = 0; curr_indir_entry = 0; - dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); - for(u = start_row; u <= end_row; u++, curr_row++) { - if(u < hdr->man_dtable.max_direct_rows) { - H5HF_free_section_t *row_sect = NULL; /* 'Row' free space section to add */ + dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); + for (u = start_row; u <= end_row; u++, curr_row++) { + if (u < hdr->man_dtable.max_direct_rows) { + H5HF_free_section_t *row_sect = NULL; /* 'Row' free space section to add */ /* Create 'row' free space section node */ - if(NULL == (row_sect = H5HF_sect_row_create(curr_off, - (hdr->man_dtable.row_block_size[u] - dblock_overhead), first_child, u, row_col, - row_entries, sect))) + if (NULL == (row_sect = H5HF__sect_row_create( + curr_off, (hdr->man_dtable.row_block_size[u] - dblock_overhead), first_child, u, + row_col, row_entries, sect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "creation failed for child row section") /* Add new row section to array for indirect section */ sect->u.indirect.dir_rows[curr_row] = row_sect; /* Check to see if we should grab the first row section instead of adding it immediately */ - if(first_row_sect) + if (first_row_sect) *first_row_sect = row_sect; 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") + 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") /* Increment reference count for underlying indirect section */ sect->u.indirect.rc++; @@ -2528,36 +2459,41 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, curr_entry += row_entries; /* Reset the 'first child' parameters */ - first_child = FALSE; + first_child = FALSE; first_row_sect = NULL; } /* end if */ else { - 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 */ - unsigned v; /* Local index variable */ + 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 */ + unsigned v; /* Local index variable */ /* Compute info about row's indirect blocks for child section */ - child_nrows = H5HF_dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[u]); + child_nrows = H5HF__dtable_size_to_rows(&hdr->man_dtable, hdr->man_dtable.row_block_size[u]); child_nentries = child_nrows * hdr->man_dtable.cparam.width; /* Add an indirect section for each indirect block in the row */ - for(v = 0; v < row_entries; v++) { - hbool_t did_protect; /* Whether we protected the indirect block or not */ + for (v = 0; v < row_entries; v++) { + hbool_t did_protect = FALSE; /* Whether we protected the indirect block or not */ /* Try to get the child section's indirect block, if it's available */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - haddr_t child_iblock_addr; /* Child indirect block's address on disk */ + if (sect->sect_info.state == H5FS_SECT_LIVE) { + haddr_t child_iblock_addr; /* Child indirect block's address on disk */ /* Get the address of the child indirect block */ - if(H5HF_man_iblock_entry_addr(sect->u.indirect.u.iblock, curr_entry, &child_iblock_addr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to retrieve child indirect block's address") + if (H5HF__man_iblock_entry_addr(sect->u.indirect.u.iblock, curr_entry, + &child_iblock_addr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to retrieve child indirect block's address") /* If the child indirect block's address is defined, protect it */ - if(H5F_addr_defined(child_iblock_addr)) { - if(NULL == (child_iblock = H5HF__man_iblock_protect(hdr, child_iblock_addr, child_nrows, sect->u.indirect.u.iblock, curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap indirect block") + if (H5F_addr_defined(child_iblock_addr)) { + if (NULL == (child_iblock = H5HF__man_iblock_protect( + hdr, child_iblock_addr, child_nrows, sect->u.indirect.u.iblock, + curr_entry, FALSE, H5AC__NO_FLAGS_SET, &did_protect))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, + "unable to protect fractal heap indirect block") } /* end if */ else child_iblock = NULL; @@ -2566,25 +2502,26 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, child_iblock = NULL; /* Create free space section node */ - if(NULL == (child_sect = H5HF_sect_indirect_new(hdr, curr_off, (hsize_t)0, - child_iblock, curr_off, 0, 0, child_nentries))) + if (NULL == (child_sect = H5HF__sect_indirect_new(hdr, curr_off, (hsize_t)0, child_iblock, + curr_off, 0, 0, child_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, child_sect, - first_child, first_row_sect, space_flags, 0, 0, - (child_nrows - 1), (hdr->man_dtable.cparam.width - 1)) < 0) + if (H5HF__sect_indirect_init_rows(hdr, child_sect, first_child, first_row_sect, space_flags, + 0, 0, (child_nrows - 1), + (hdr->man_dtable.cparam.width - 1)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize indirect section") /* If we have a valid child indirect block, release it now */ /* (will be pinned, if rows reference it) */ - if(child_iblock) - if(H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + if (child_iblock) + if (H5HF__man_iblock_unprotect(child_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, + "unable to release fractal heap indirect block") /* Attach child section to this section */ - child_sect->u.indirect.parent = sect; - child_sect->u.indirect.par_entry = curr_entry; + child_sect->u.indirect.parent = sect; + child_sect->u.indirect.par_entry = curr_entry; sect->u.indirect.indir_ents[curr_indir_entry] = child_sect; sect->u.indirect.rc++; @@ -2596,13 +2533,13 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, curr_indir_entry++; /* Reset the 'first child' parameters */ - first_child = FALSE; + first_child = FALSE; first_row_sect = NULL; } /* end for */ - } /* end else */ + } /* end else */ /* Compute the # of entries for the next row */ - if(u < (end_row - 1)) + if (u < (end_row - 1)) row_entries = hdr->man_dtable.cparam.width; else row_entries = end_col + 1; @@ -2615,21 +2552,19 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, sect->u.indirect.dir_nrows = dir_nrows; /* Make certain we've tracked the section's dependents correctly */ - HDassert(sect->u.indirect.rc == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + HDassert(sect->u.indirect.rc == (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); done: - if(ret_value < 0) { - if(sect->u.indirect.indir_ents) + if (ret_value < 0) { + if (sect->u.indirect.indir_ents) H5MM_xfree(sect->u.indirect.indir_ents); - if(sect->u.indirect.dir_rows) + if (sect->u.indirect.dir_rows) H5MM_xfree(sect->u.indirect.dir_rows); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_init_rows() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_add * @@ -2646,16 +2581,16 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, herr_t H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *first_row_sect = NULL; /* First row section in new indirect section */ - hsize_t sect_off; /* Offset of section in heap space */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* End entry in indirect block */ - unsigned end_row; /* End row in indirect block */ - unsigned end_col; /* End column in indirect block */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *first_row_sect = NULL; /* First row section in new indirect section */ + hsize_t sect_off; /* Offset of section in heap space */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* End entry in indirect block */ + unsigned end_row; /* End row in indirect block */ + unsigned end_col; /* End column in indirect block */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2672,43 +2607,42 @@ H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start /* Compute end column & row */ end_entry = (start_entry + nentries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; - end_col = end_entry % hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; + end_col = end_entry % hdr->man_dtable.cparam.width; /* Initialize information for rows skipped over */ sect_off = iblock->block_off; - for(u = 0; u < start_row; u++) + for (u = 0; u < start_row; u++) sect_off += hdr->man_dtable.row_block_size[u] * hdr->man_dtable.cparam.width; sect_off += hdr->man_dtable.row_block_size[start_row] * start_col; /* Create free space section node */ - if(NULL == (sect = H5HF_sect_indirect_new(hdr, sect_off, (hsize_t)0, iblock, - iblock->block_off, start_row, start_col, nentries))) + if (NULL == (sect = H5HF__sect_indirect_new(hdr, sect_off, (hsize_t)0, iblock, iblock->block_off, + start_row, start_col, nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, sect, TRUE, &first_row_sect, - H5FS_ADD_SKIP_VALID, start_row, start_col, end_row, end_col) < 0) + if (H5HF__sect_indirect_init_rows(hdr, sect, TRUE, &first_row_sect, H5FS_ADD_SKIP_VALID, start_row, + start_col, end_row, end_col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize indirect section") HDassert(first_row_sect); /* Now that underlying indirect section is consistent, add first row * section to free space manager for the heap */ - if(H5HF__space_add(hdr, first_row_sect, H5FS_ADD_RETURNED_SPACE) < 0) + if (H5HF__space_add(hdr, first_row_sect, H5FS_ADD_RETURNED_SPACE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") done: - if(ret_value < 0 && sect) - if(H5HF_sect_indirect_free(sect) < 0) + if (ret_value < 0 && sect) + if (H5HF__sect_indirect_free(sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_add() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_decr + * Function: H5HF__sect_indirect_decr * * Purpose: Decrement ref. count on indirect section * @@ -2720,11 +2654,11 @@ H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_decr(H5HF_free_section_t *sect) +H5HF__sect_indirect_decr(H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -2736,27 +2670,27 @@ H5HF_sect_indirect_decr(H5HF_free_section_t *sect) sect->u.indirect.rc--; /* If the indirect section's ref. count drops to zero, free the section */ - if(sect->u.indirect.rc == 0) { - H5HF_free_section_t *par_sect; /* Parent indirect section */ + if (sect->u.indirect.rc == 0) { + H5HF_free_section_t *par_sect; /* Parent indirect section */ /* Preserve pointer to parent indirect section when freeing this section */ par_sect = sect->u.indirect.parent; /* Free indirect section */ - if(H5HF_sect_indirect_free(sect) < 0) + if (H5HF__sect_indirect_free(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") /* Decrement ref. count on indirect section's parent */ - if(par_sect) - if(H5HF_sect_indirect_decr(par_sect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement ref. count on parent indirect section") + if (par_sect) + if (H5HF__sect_indirect_decr(par_sect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, + "can't decrement ref. count on parent indirect section") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_decr() */ +} /* end H5HF__sect_indirect_decr() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_revive_row * @@ -2772,9 +2706,9 @@ H5HF_sect_indirect_decr(H5HF_free_section_t *sect) static herr_t H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ - hbool_t did_protect; /* Whether we protected the indirect block or not */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *sec_iblock; /* Pointer to section indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2786,22 +2720,22 @@ H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED); /* Look up indirect block containing indirect blocks for section */ - if(H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, NULL, &did_protect, H5AC__READ_ONLY_FLAG) < 0) + if (H5HF__man_dblock_locate(hdr, sect->sect_info.addr, &sec_iblock, NULL, &did_protect, + H5AC__READ_ONLY_FLAG) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section") /* Review the section */ - if(H5HF__sect_indirect_revive(hdr, sect, sec_iblock) < 0) + if (H5HF__sect_indirect_revive(hdr, sect, sec_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") done: /* Unlock indirect block */ - if(sec_iblock && H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) + if (sec_iblock && H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_revive_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_revive * @@ -2817,8 +2751,8 @@ H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) static herr_t H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_indirect_t *sect_iblock) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2831,33 +2765,31 @@ H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_indi HDassert(sect_iblock); /* Increment reference count on indirect block that free section is in */ - if(H5HF_iblock_incr(sect_iblock) < 0) + if (H5HF__iblock_incr(sect_iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Set the pointer to the section's indirect block */ sect->u.indirect.u.iblock = sect_iblock; /* Set the number of entries in the indirect block */ - sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * - sect->u.indirect.u.iblock->max_rows; + sect->u.indirect.iblock_entries = hdr->man_dtable.cparam.width * sect->u.indirect.u.iblock->max_rows; /* Section is "live" now */ sect->sect_info.state = H5FS_SECT_LIVE; /* Loop over derived row sections and mark them all as 'live' now */ - for(u = 0; u < sect->u.indirect.dir_nrows; u++) + for (u = 0; u < sect->u.indirect.dir_nrows; u++) sect->u.indirect.dir_rows[u]->sect_info.state = H5FS_SECT_LIVE; /* Revive parent indirect section, if there is one */ - if(sect->u.indirect.parent && sect->u.indirect.parent->sect_info.state == H5FS_SECT_SERIALIZED) - if(H5HF__sect_indirect_revive(hdr, sect->u.indirect.parent, sect->u.indirect.u.iblock->parent) < 0) + if (sect->u.indirect.parent && sect->u.indirect.parent->sect_info.state == H5FS_SECT_SERIALIZED) + if (H5HF__sect_indirect_revive(hdr, sect->u.indirect.parent, sect->u.indirect.u.iblock->parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREVIVE, FAIL, "can't revive indirect section") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_revive() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_reduce_row * @@ -2873,20 +2805,19 @@ H5HF__sect_indirect_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, H5HF_indi *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, - hbool_t *alloc_from_start) +H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, hbool_t *alloc_from_start) { - H5HF_free_section_t *sect; /* Indirect section underlying row section */ - unsigned row_start_entry; /* Entry for first block covered in row section */ - unsigned row_end_entry; /* Entry for last block covered in row section */ - unsigned row_entry; /* Entry to allocate in row section */ - unsigned start_entry; /* Entry for first block covered */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* Entry for last block covered */ - unsigned end_row; /* End row in indirect block */ - H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect; /* Indirect section underlying row section */ + unsigned row_start_entry; /* Entry for first block covered in row section */ + unsigned row_end_entry; /* Entry for last block covered in row section */ + unsigned row_entry; /* Entry to allocate in row section */ + unsigned start_entry; /* Entry for first block covered */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* Entry for last block covered */ + unsigned end_row; /* End row in indirect block */ + H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2898,15 +2829,15 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Compute starting & ending information for row section */ row_start_entry = (row_sect->u.row.row * hdr->man_dtable.cparam.width) + row_sect->u.row.col; - row_end_entry = (row_start_entry + row_sect->u.row.num_entries) - 1; + row_end_entry = (row_start_entry + row_sect->u.row.num_entries) - 1; /* Compute starting & ending information for indirect section */ - sect = row_sect->u.row.under; - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + sect = row_sect->u.row.under; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_entry = (start_entry + sect->u.indirect.num_entries) - 1; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Additional sanity check */ HDassert(sect->u.indirect.span_size > 0); @@ -2916,31 +2847,31 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, HDassert(sect->u.indirect.dir_rows[(row_sect->u.row.row - start_row)] == row_sect); /* Check if we should allocate from end of indirect section */ - if(row_end_entry == end_entry && start_row != end_row) { + if (row_end_entry == end_entry && start_row != end_row) { *alloc_from_start = FALSE; - row_entry = row_end_entry; + row_entry = row_end_entry; } /* end if */ else { *alloc_from_start = TRUE; - row_entry = row_start_entry; + row_entry = row_start_entry; } /* end else */ /* Check if we have a parent section to be detached from */ - if(sect->u.indirect.parent) { - hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ + if (sect->u.indirect.parent) { + hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ /* Check if this section is the first section */ - is_first = H5HF_sect_indirect_is_first(sect); + is_first = H5HF__sect_indirect_is_first(sect); /* Remove this indirect section from parent indirect section */ - if(H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) + if (H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce parent indirect section") - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* If we weren't the first section, set "first row" for this indirect section */ - if(!is_first) - if(H5HF__sect_indirect_first(hdr, sect) < 0) + if (!is_first) + if (H5HF__sect_indirect_first(hdr, sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") } /* end if */ @@ -2948,14 +2879,14 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.span_size -= row_sect->sect_info.size; /* Check how to adjust section for allocated entry */ - if(sect->u.indirect.num_entries > 1) { - if(row_entry == start_entry) { + if (sect->u.indirect.num_entries > 1) { + if (row_entry == start_entry) { /* Adjust section start */ sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.indirect.row]; /* Adjust block coordinates of span */ sect->u.indirect.col++; - if(sect->u.indirect.col == hdr->man_dtable.cparam.width) { + if (sect->u.indirect.col == hdr->man_dtable.cparam.width) { HDassert(row_sect->u.row.num_entries == 1); /* Adjust section's span information */ @@ -2966,17 +2897,17 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.dir_nrows--; /* Adjust direct row sections for indirect section */ - if(sect->u.indirect.dir_nrows > 0) { + if (sect->u.indirect.dir_nrows > 0) { HDassert(sect->u.indirect.dir_rows); - HDmemmove(§->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[1], - sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); + HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[1], + sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); HDassert(sect->u.indirect.dir_rows[0]); /* Make new "first row" in indirect section */ - if(row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) - if(H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") + if (row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) + if (H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for indirect section") } /* end if */ else { /* Sanity check */ @@ -2987,17 +2918,18 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.dir_rows); /* Make new "first row" in indirect section */ - if(row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for child indirect section") + if (row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW) + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for child indirect section") } /* end else */ - } /* end if */ + } /* end if */ /* Adjust number of entries covered */ sect->u.indirect.num_entries--; } /* end if */ - else if(row_entry == end_entry) { - unsigned new_end_row; /* New end row for entries */ + else if (row_entry == end_entry) { + unsigned new_end_row; /* New end row for entries */ /* Sanity check */ HDassert(sect->u.indirect.indir_nents == 0); @@ -3009,18 +2941,18 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Check for eliminating a direct row */ new_end_row = ((start_entry + sect->u.indirect.num_entries) - 1) / hdr->man_dtable.cparam.width; HDassert(new_end_row <= end_row); - if(new_end_row < end_row) { + if (new_end_row < end_row) { HDassert(new_end_row == (end_row - 1)); sect->u.indirect.dir_nrows--; } /* end if */ - } /* end if */ + } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ - hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ - unsigned peer_nentries; /* Number of entries in new peer indirect section */ - unsigned peer_dir_nrows; /* Number of direct rows in new peer indirect section */ - unsigned new_start_row; /* New starting row for current indirect section */ - unsigned u; /* Local index variable */ + H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ + hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ + unsigned peer_nentries; /* Number of entries in new peer indirect section */ + unsigned peer_dir_nrows; /* Number of direct rows in new peer indirect section */ + unsigned new_start_row; /* New starting row for current indirect section */ + unsigned u; /* Local index variable */ /* Sanity checks */ HDassert(row_sect->u.row.col == 0); @@ -3030,45 +2962,44 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, HDassert(row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); /* Compute basic information about peer & current indirect sections */ - new_start_row = row_sect->u.row.row; - peer_nentries = row_entry - start_entry; + new_start_row = row_sect->u.row.row; + peer_nentries = row_entry - start_entry; peer_dir_nrows = new_start_row - start_row; /* Get indirect block information for peer */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - iblock = sect->u.indirect.u.iblock; + if (sect->sect_info.state == H5FS_SECT_LIVE) { + iblock = sect->u.indirect.u.iblock; iblock_off = sect->u.indirect.u.iblock->block_off; } /* end if */ else { - iblock = NULL; + iblock = NULL; iblock_off = sect->u.indirect.u.iblock_off; } /* end else */ /* Create peer indirect section */ - if(NULL == (peer_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, - sect->sect_info.size, iblock, iblock_off, start_row, start_col, - peer_nentries))) + if (NULL == + (peer_sect = H5HF__sect_indirect_new(hdr, sect->sect_info.addr, sect->sect_info.size, iblock, + iblock_off, start_row, start_col, peer_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Set up direct row & indirect entry information for peer section */ peer_sect->u.indirect.indir_nents = 0; - peer_sect->u.indirect.indir_ents = NULL; - peer_sect->u.indirect.dir_nrows = peer_dir_nrows; - if(NULL == (peer_sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * peer_dir_nrows))) + peer_sect->u.indirect.indir_ents = NULL; + peer_sect->u.indirect.dir_nrows = peer_dir_nrows; + if (NULL == (peer_sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * peer_dir_nrows))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for row section pointer array") /* Transfer row sections between current & peer sections */ - H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[0], - (sizeof(H5HF_free_section_t *) * peer_dir_nrows)); - HDmemmove(§->u.indirect.dir_rows[0], - §->u.indirect.dir_rows[peer_dir_nrows], - (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); + H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0], §->u.indirect.dir_rows[0], + (sizeof(H5HF_free_section_t *) * peer_dir_nrows)); + HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[peer_dir_nrows], + (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); sect->u.indirect.dir_nrows -= peer_dir_nrows; HDassert(row_sect == sect->u.indirect.dir_rows[0]); /* Re-target transferred row sections to point to new underlying indirect section */ - for(u = 0; u < peer_dir_nrows; u++) + for (u = 0; u < peer_dir_nrows; u++) peer_sect->u.indirect.dir_rows[u]->u.row.under = peer_sect; /* Change first row section in indirect section to be the "first row" */ @@ -3084,25 +3015,27 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, /* Transfer/update cached information about indirect block */ peer_sect->u.indirect.iblock_entries = sect->u.indirect.iblock_entries; - peer_sect->u.indirect.span_size = row_sect->sect_info.addr - peer_sect->sect_info.addr; + peer_sect->u.indirect.span_size = row_sect->sect_info.addr - peer_sect->sect_info.addr; /* Update information for current section */ sect->sect_info.addr = row_sect->sect_info.addr + hdr->man_dtable.row_block_size[new_start_row]; - sect->u.indirect.span_size -= peer_sect->u.indirect.span_size; /* (span for row section has already been removed) */ + sect->u.indirect.span_size -= + peer_sect->u.indirect.span_size; /* (span for row section has already been removed) */ sect->u.indirect.row = new_start_row; sect->u.indirect.col = row_sect->u.row.col + 1; - sect->u.indirect.num_entries -= (peer_nentries + 1); /* Transferred entries, plus the entry allocated out of the row */ + sect->u.indirect.num_entries -= + (peer_nentries + 1); /* Transferred entries, plus the entry allocated out of the row */ /* Make certain we've tracked the sections' dependents correctly */ - HDassert(sect->u.indirect.rc == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + HDassert(sect->u.indirect.rc == (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); HDassert(peer_sect->u.indirect.rc == - (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); + (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); - /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures correctly and shouldn't be freed */ + /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures + * correctly and shouldn't be freed */ peer_sect = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Decrement count of entries & rows */ sect->u.indirect.num_entries--; @@ -3116,18 +3049,17 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, done: /* Free allocated peer_sect. Note that this is necessary for all failures until peer_sect is linked * into the main free space structures (via the direct blocks), and the reference count is updated. */ - if(peer_sect) { + if (peer_sect) { /* Sanity check - we should only be here if an error occurred */ HDassert(ret_value < 0); - if(H5HF_sect_indirect_free(peer_sect) < 0) + if (H5HF__sect_indirect_free(peer_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_reduce_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_reduce * @@ -3143,16 +3075,15 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, - unsigned child_entry) +H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned child_entry) { - unsigned start_entry; /* Entry for first block covered */ - unsigned start_row; /* Start row in indirect block */ - unsigned start_col; /* Start column in indirect block */ - unsigned end_entry; /* Entry for last block covered */ - unsigned end_row; /* End row in indirect block */ - H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned start_entry; /* Entry for first block covered */ + unsigned start_row; /* Start row in indirect block */ + unsigned start_col; /* Start column in indirect block */ + unsigned end_entry; /* Entry for last block covered */ + unsigned end_row; /* End row in indirect block */ + H5HF_free_section_t *peer_sect = NULL; /* Peer indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3165,35 +3096,36 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, HDassert(sect->u.indirect.iblock_entries > 0); /* Compute starting & ending information for indirect section */ - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; - end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_entry = (start_entry + sect->u.indirect.num_entries) - 1; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Check how to adjust section for allocated entry */ - if(sect->u.indirect.num_entries > 1) { + if (sect->u.indirect.num_entries > 1) { /* Check if we have a parent section to be detached from */ - if(sect->u.indirect.parent) { - hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ + if (sect->u.indirect.parent) { + hbool_t is_first; /* Flag to indicate that this section is the first section in hierarchy */ /* Check if this section is the first section */ - is_first = H5HF_sect_indirect_is_first(sect); + is_first = H5HF__sect_indirect_is_first(sect); /* Reduce parent indirect section */ - if(H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) + if (H5HF__sect_indirect_reduce(hdr, sect->u.indirect.parent, sect->u.indirect.par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce parent indirect section") - sect->u.indirect.parent = NULL; + sect->u.indirect.parent = NULL; sect->u.indirect.par_entry = 0; /* If we weren't the first section, set "first row" for this indirect section */ - if(!is_first) - if(H5HF__sect_indirect_first(hdr, sect) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for indirect section") + if (!is_first) + if (H5HF__sect_indirect_first(hdr, sect) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for indirect section") } /* end if */ /* Check if we can allocate from start of indirect section */ - if(child_entry == start_entry) { + if (child_entry == start_entry) { /* Sanity check */ HDassert(sect->u.indirect.dir_nrows == 0); HDassert(sect->u.indirect.dir_rows == NULL); @@ -3205,7 +3137,7 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust span of blocks covered */ sect->u.indirect.col++; - if(sect->u.indirect.col == hdr->man_dtable.cparam.width) { + if (sect->u.indirect.col == hdr->man_dtable.cparam.width) { sect->u.indirect.row++; sect->u.indirect.col = 0; } /* end if */ @@ -3214,16 +3146,16 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust indirect entry information */ sect->u.indirect.indir_nents--; - HDmemmove(§->u.indirect.indir_ents[0], - §->u.indirect.indir_ents[1], - sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); + HDmemmove(§->u.indirect.indir_ents[0], §->u.indirect.indir_ents[1], + sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); HDassert(sect->u.indirect.indir_ents[0]); /* Make new "first row" in new first indirect child section */ - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for child indirect section") + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for child indirect section") } /* end if */ - else if(child_entry == end_entry) { + else if (child_entry == end_entry) { /* Sanity check */ HDassert(sect->u.indirect.indir_nents > 0); HDassert(sect->u.indirect.indir_ents); @@ -3234,47 +3166,47 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Adjust indirect entry information */ sect->u.indirect.indir_nents--; - if(sect->u.indirect.indir_nents == 0) + if (sect->u.indirect.indir_nents == 0) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); } /* end if */ else { - H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ - hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ - haddr_t peer_sect_addr; /* Address of new peer section in "heap space" */ - unsigned peer_nentries; /* Number of entries in new peer indirect section */ - unsigned peer_start_row; /* Starting row for new peer indirect section */ - unsigned peer_start_col; /* Starting column for new peer indirect section */ - unsigned child_row; /* Row where child entry is located */ - unsigned new_nentries; /* New number of entries for current indirect section */ - unsigned u; /* Local index variable */ + H5HF_indirect_t *iblock; /* Pointer to indirect block for this section */ + hsize_t iblock_off; /* Section's indirect block's offset in "heap space" */ + haddr_t peer_sect_addr; /* Address of new peer section in "heap space" */ + unsigned peer_nentries; /* Number of entries in new peer indirect section */ + unsigned peer_start_row; /* Starting row for new peer indirect section */ + unsigned peer_start_col; /* Starting column for new peer indirect section */ + unsigned child_row; /* Row where child entry is located */ + unsigned new_nentries; /* New number of entries for current indirect section */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(sect->u.indirect.indir_nents > 0); HDassert(sect->u.indirect.indir_ents); /* Compute basic information about peer & current indirect sections */ - peer_nentries = end_entry - child_entry; + peer_nentries = end_entry - child_entry; peer_start_row = (child_entry + 1) / hdr->man_dtable.cparam.width; peer_start_col = (child_entry + 1) % hdr->man_dtable.cparam.width; - child_row = child_entry / hdr->man_dtable.cparam.width; - new_nentries = sect->u.indirect.num_entries - (peer_nentries + 1); + child_row = child_entry / hdr->man_dtable.cparam.width; + new_nentries = sect->u.indirect.num_entries - (peer_nentries + 1); HDassert(child_row >= hdr->man_dtable.max_direct_rows); /* Get indirect block information for peer */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { - iblock = sect->u.indirect.u.iblock; + if (sect->sect_info.state == H5FS_SECT_LIVE) { + iblock = sect->u.indirect.u.iblock; iblock_off = sect->u.indirect.u.iblock->block_off; } /* end if */ else { - iblock = NULL; + iblock = NULL; iblock_off = sect->u.indirect.u.iblock_off; } /* end else */ /* Update the number of entries in current section & calculate it's span size */ /* (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.span_size = H5HF__dtable_span_size(&hdr->man_dtable, sect->u.indirect.row, + sect->u.indirect.col, new_nentries); HDassert(sect->u.indirect.span_size > 0); /* Compute address of peer indirect section */ @@ -3283,30 +3215,32 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, peer_sect_addr += hdr->man_dtable.row_block_size[child_row]; /* Create peer indirect section */ - if(NULL == (peer_sect = H5HF_sect_indirect_new(hdr, peer_sect_addr, - sect->sect_info.size, iblock, iblock_off, peer_start_row, - peer_start_col, peer_nentries))) + if (NULL == (peer_sect = H5HF__sect_indirect_new(hdr, peer_sect_addr, sect->sect_info.size, + iblock, iblock_off, peer_start_row, + peer_start_col, peer_nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* Set up direct row & indirect entry information for peer section */ - peer_sect->u.indirect.dir_nrows = 0; - peer_sect->u.indirect.dir_rows = NULL; + peer_sect->u.indirect.dir_nrows = 0; + peer_sect->u.indirect.dir_rows = NULL; peer_sect->u.indirect.indir_nents = peer_nentries; - if(NULL == (peer_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *) * peer_nentries))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "allocation failed for indirect section pointer array") + if (NULL == (peer_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc( + sizeof(H5HF_free_section_t *) * peer_nentries))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, + "allocation failed for indirect section pointer array") /* Transfer child indirect sections between current & peer sections */ H5MM_memcpy(&peer_sect->u.indirect.indir_ents[0], - §->u.indirect.indir_ents[sect->u.indirect.indir_nents - peer_nentries], - (sizeof(H5HF_free_section_t *) * peer_nentries)); + §->u.indirect.indir_ents[sect->u.indirect.indir_nents - peer_nentries], + (sizeof(H5HF_free_section_t *) * peer_nentries)); sect->u.indirect.indir_nents -= (peer_nentries + 1); /* Transferred blocks, plus child entry */ /* Eliminate indirect entries for this section, if appropriate */ - if(sect->u.indirect.indir_nents == 0) + if (sect->u.indirect.indir_nents == 0) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); /* Re-target transferred row sections to point to new underlying indirect section */ - for(u = 0; u < peer_nentries; u++) + for (u = 0; u < peer_nentries; u++) peer_sect->u.indirect.indir_ents[u]->u.indirect.parent = peer_sect; /* Adjust reference counts for current & peer sections */ @@ -3321,18 +3255,20 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, * detached the child section yet) */ HDassert((sect->u.indirect.rc - 1) == - (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); + (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); HDassert(peer_sect->u.indirect.rc == - (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); + (peer_sect->u.indirect.indir_nents + peer_sect->u.indirect.dir_nrows)); /* Make new "first row" in peer section */ - if(H5HF__sect_indirect_first(hdr, peer_sect->u.indirect.indir_ents[0]) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't make new 'first row' for peer indirect section") + if (H5HF__sect_indirect_first(hdr, peer_sect->u.indirect.indir_ents[0]) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, + "can't make new 'first row' for peer indirect section") - /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures correctly and shouldn't be freed */ + /* Reset the peer_sect variable, to indicate that it has been hooked into the data structures + * correctly and shouldn't be freed */ peer_sect = NULL; } /* end else */ - } /* end if */ + } /* end if */ else { /* Decrement count of entries & indirect entries */ sect->u.indirect.num_entries--; @@ -3345,26 +3281,25 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, /* Decrement # of sections which depend on this row */ /* (Must be last as section can be freed) */ - if(H5HF_sect_indirect_decr(sect) < 0) + if (H5HF__sect_indirect_decr(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement section's ref. count ") done: /* Free allocated peer_sect. Note that this is necessary for all failures until peer_sect is linked * into the main free space structures (via the direct blocks), and the reference count is updated. */ - if(peer_sect) { + if (peer_sect) { /* Sanity check - we should only be here if an error occurred */ HDassert(ret_value < 0); - if(H5HF_sect_indirect_free(peer_sect) < 0) + if (H5HF__sect_indirect_free(peer_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_reduce() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_is_first + * Function: H5HF__sect_indirect_is_first * * Purpose: Check if indirect section is first in all parents * @@ -3376,27 +3311,26 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, *------------------------------------------------------------------------- */ static hbool_t -H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) +H5HF__sect_indirect_is_first(H5HF_free_section_t *sect) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(sect); /* Recurse to parent */ - if(sect->u.indirect.parent) { - if(sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) - ret_value = H5HF_sect_indirect_is_first(sect->u.indirect.parent); + if (sect->u.indirect.parent) { + if (sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) + ret_value = H5HF__sect_indirect_is_first(sect->u.indirect.parent); } /* end if */ else ret_value = TRUE; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_sect_indirect_is_first() */ +} /* end H5HF__sect_indirect_is_first() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_first * @@ -3412,7 +3346,7 @@ H5HF_sect_indirect_is_first(H5HF_free_section_t *sect) static herr_t H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3421,7 +3355,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect); /* Check if this indirect section has direct block rows */ - if(sect->u.indirect.dir_nrows > 0) { + if (sect->u.indirect.dir_nrows > 0) { /* Sanity checks */ HDassert(sect->u.indirect.row == 0); HDassert(sect->u.indirect.col == 0); @@ -3429,7 +3363,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.dir_rows[0]); /* Change first row section in indirect section to be the "first row" */ - if(H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) + if (H5HF__sect_row_first(hdr, sect->u.indirect.dir_rows[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") } /* end if */ else { @@ -3439,7 +3373,7 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.indir_ents[0]); /* Forward to first child indirect section */ - if(H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) + if (H5HF__sect_indirect_first(hdr, sect->u.indirect.indir_ents[0]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set child indirect section to be first row") } /* end else */ @@ -3447,9 +3381,8 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_first() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_get_iblock + * Function: H5HF__sect_indirect_get_iblock * * Purpose: Retrieve the indirect block for a indirect section * @@ -3461,9 +3394,9 @@ H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static H5HF_indirect_t * -H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect) +H5HF__sect_indirect_get_iblock(H5HF_free_section_t *sect) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Check arguments. @@ -3473,9 +3406,8 @@ H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect) HDassert(sect->sect_info.state == H5FS_SECT_LIVE); FUNC_LEAVE_NOAPI(sect->u.indirect.u.iblock) -} /* end H5HF_sect_indirect_get_iblock() */ +} /* end H5HF__sect_indirect_get_iblock() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_merge_row * @@ -3493,18 +3425,17 @@ H5HF_sect_indirect_get_iblock(H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, - H5HF_free_section_t *row_sect2) +H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, H5HF_free_section_t *row_sect2) { - H5HF_free_section_t *sect1, *sect2; /* Indirect sections underlying row sections */ - unsigned start_entry1; /* Start entry for section #1 */ - unsigned start_row1, start_col1; /* Starting row & column for section #1 */ - unsigned end_entry1; /* End entry for section #1 */ - unsigned end_row1; /* Ending row for section #1 */ - unsigned start_row2; /* Starting row for section #2 */ - hbool_t merged_rows; /* Flag to indicate that rows was merged together */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect1, *sect2; /* Indirect sections underlying row sections */ + unsigned start_entry1; /* Start entry for section #1 */ + unsigned start_row1, start_col1; /* Starting row & column for section #1 */ + unsigned end_entry1; /* End entry for section #1 */ + unsigned end_row1; /* Ending row for section #1 */ + unsigned start_row2; /* Starting row for section #2 */ + hbool_t merged_rows; /* Flag to indicate that rows was merged together */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3517,9 +3448,9 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, HDassert(row_sect2->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW); /* Set up indirect section information */ - sect1 = H5HF_sect_indirect_top(row_sect1->u.row.under); + sect1 = H5HF__sect_indirect_top(row_sect1->u.row.under); HDassert(sect1); - sect2 = H5HF_sect_indirect_top(row_sect2->u.row.under); + sect2 = H5HF__sect_indirect_top(row_sect2->u.row.under); HDassert(sect2); /* Sanity check some assumptions about the indirect sections */ @@ -3527,22 +3458,22 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, HDassert(sect2->u.indirect.span_size > 0); /* Set up span information */ - start_row1 = sect1->u.indirect.row; - start_col1 = sect1->u.indirect.col; + start_row1 = sect1->u.indirect.row; + start_col1 = sect1->u.indirect.col; start_entry1 = (start_row1 * hdr->man_dtable.cparam.width) + start_col1; - end_entry1 = (start_entry1 + sect1->u.indirect.num_entries) - 1; - end_row1 = end_entry1 / hdr->man_dtable.cparam.width; - start_row2 = sect2->u.indirect.row; + end_entry1 = (start_entry1 + sect1->u.indirect.num_entries) - 1; + end_row1 = end_entry1 / hdr->man_dtable.cparam.width; + start_row2 = sect2->u.indirect.row; /* Check for direct sections in second section */ /* (second indirect section can be parent of indirect section for second * row, and thus have no row sections of it's own) */ - if(sect2->u.indirect.dir_nrows > 0) { - hsize_t sect1_iblock_off, sect2_iblock_off; /* Offset of indirect block underlying row section */ - unsigned new_dir_nrows1; /* New value for number of direct rows in first section */ - unsigned src_row2; /* Source row for copying from second section */ - unsigned nrows_moved2; /* Number of rows to move from second section to first */ + if (sect2->u.indirect.dir_nrows > 0) { + hsize_t sect1_iblock_off, sect2_iblock_off; /* Offset of indirect block underlying row section */ + unsigned new_dir_nrows1; /* New value for number of direct rows in first section */ + unsigned src_row2; /* Source row for copying from second section */ + unsigned nrows_moved2; /* Number of rows to move from second section to first */ /* Sanity check child row assumptions */ /* (second indirect section should be at top of equal or deeper @@ -3554,21 +3485,21 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, HDassert(sect1->u.indirect.dir_rows); /* Get the offsets for the indirect blocks under the rows */ - if(H5FS_SECT_LIVE == row_sect1->u.row.under->sect_info.state) + if (H5FS_SECT_LIVE == row_sect1->u.row.under->sect_info.state) sect1_iblock_off = row_sect1->u.row.under->u.indirect.u.iblock->block_off; else sect1_iblock_off = row_sect1->u.row.under->u.indirect.u.iblock_off; - if(H5FS_SECT_LIVE == row_sect2->u.row.under->sect_info.state) + if (H5FS_SECT_LIVE == row_sect2->u.row.under->sect_info.state) sect2_iblock_off = row_sect2->u.row.under->u.indirect.u.iblock->block_off; else sect2_iblock_off = row_sect2->u.row.under->u.indirect.u.iblock_off; /* Check for sections sharing a row in the same underlying indirect block */ - if(sect1_iblock_off == sect2_iblock_off && end_row1 == start_row2) { - H5HF_free_section_t *last_row_sect1; /* Last row in first indirect section */ + if (sect1_iblock_off == sect2_iblock_off && end_row1 == start_row2) { + H5HF_free_section_t *last_row_sect1; /* Last row in first indirect section */ /* Locate the last row section in first indirect section, if we don't already have it */ - if(row_sect1->u.row.row != end_row1) + if (row_sect1->u.row.row != end_row1) last_row_sect1 = sect1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows - 1]; else last_row_sect1 = row_sect1; @@ -3580,8 +3511,8 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, last_row_sect1->u.row.num_entries += row_sect2->u.row.num_entries; /* Set up parameters for transfer of rows */ - src_row2 = 1; - nrows_moved2 = sect2->u.indirect.dir_nrows - 1; + src_row2 = 1; + nrows_moved2 = sect2->u.indirect.dir_nrows - 1; new_dir_nrows1 = (sect1->u.indirect.dir_nrows + sect2->u.indirect.dir_nrows) - 1; /* Indicate that the rows were merged */ @@ -3590,8 +3521,8 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, else { /* Set up parameters for transfer of rows */ - src_row2 = 0; - nrows_moved2 = sect2->u.indirect.dir_nrows; + src_row2 = 0; + nrows_moved2 = sect2->u.indirect.dir_nrows; new_dir_nrows1 = sect1->u.indirect.dir_nrows + sect2->u.indirect.dir_nrows; /* Indicate that the rows were _not_ merged */ @@ -3599,21 +3530,22 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, } /* end else */ /* Check if we need to move additional rows */ - if(nrows_moved2 > 0) { - H5HF_free_section_t **new_dir_rows; /* Pointer to new array of direct row pointers */ + if (nrows_moved2 > 0) { + H5HF_free_section_t **new_dir_rows; /* Pointer to new array of direct row pointers */ /* Extend the first section's row array */ - if(NULL == (new_dir_rows = (H5HF_free_section_t **)H5MM_realloc(sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1))) + if (NULL == (new_dir_rows = (H5HF_free_section_t **)H5MM_realloc( + sect1->u.indirect.dir_rows, sizeof(H5HF_free_section_t *) * new_dir_nrows1))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") sect1->u.indirect.dir_rows = new_dir_rows; /* Transfer the second section's rows to first section */ H5MM_memcpy(§1->u.indirect.dir_rows[sect1->u.indirect.dir_nrows], - §2->u.indirect.dir_rows[src_row2], - (sizeof(H5HF_free_section_t *) * nrows_moved2)); + §2->u.indirect.dir_rows[src_row2], + (sizeof(H5HF_free_section_t *) * nrows_moved2)); /* Re-target the row sections moved from second section */ - for(u = sect1->u.indirect.dir_nrows; u < new_dir_nrows1; u++) + for (u = sect1->u.indirect.dir_nrows; u < new_dir_nrows1; u++) sect1->u.indirect.dir_rows[u]->u.row.under = sect1; /* Adjust reference counts to account for transferred rows */ @@ -3623,14 +3555,14 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, /* Update information for first section */ sect1->u.indirect.dir_nrows = new_dir_nrows1; } /* end if */ - } /* end if */ + } /* end if */ else /* Indicate that the rows were _not_ merged */ merged_rows = FALSE; /* Check for indirect sections in second section */ - if(sect2->u.indirect.indir_nents > 0) { - unsigned new_indir_nents1; /* New value for number of indirect entries in first section */ + if (sect2->u.indirect.indir_nents > 0) { + unsigned new_indir_nents1; /* New value for number of indirect entries in first section */ /* Some sanity checks on second indirect section */ HDassert(sect2->u.indirect.rc > 0); @@ -3641,26 +3573,27 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, new_indir_nents1 = sect1->u.indirect.indir_nents + sect2->u.indirect.indir_nents; /* Check if first section can just take over second section's memory buffer */ - if(sect1->u.indirect.indir_ents == NULL) { + if (sect1->u.indirect.indir_ents == NULL) { sect1->u.indirect.indir_ents = sect2->u.indirect.indir_ents; sect2->u.indirect.indir_ents = NULL; } /* end if */ else { - H5HF_free_section_t **new_indir_ents; /* Pointer to new array of indirect entries */ + H5HF_free_section_t **new_indir_ents; /* Pointer to new array of indirect entries */ /* Extend the first section's entry array */ - if(NULL == (new_indir_ents = (H5HF_free_section_t **)H5MM_realloc(sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1))) + if (NULL == (new_indir_ents = (H5HF_free_section_t **)H5MM_realloc( + sect1->u.indirect.indir_ents, sizeof(H5HF_free_section_t *) * new_indir_nents1))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for row section pointer array") sect1->u.indirect.indir_ents = new_indir_ents; /* Transfer the second section's entries to first section */ H5MM_memcpy(§1->u.indirect.indir_ents[sect1->u.indirect.indir_nents], - §2->u.indirect.indir_ents[0], - (sizeof(H5HF_free_section_t *) * sect2->u.indirect.indir_nents)); + §2->u.indirect.indir_ents[0], + (sizeof(H5HF_free_section_t *) * sect2->u.indirect.indir_nents)); } /* end else */ /* Re-target the child indirect sections moved from second section */ - for(u = sect1->u.indirect.indir_nents; u < new_indir_nents1; u++) + for (u = sect1->u.indirect.indir_nents; u < new_indir_nents1; u++) sect1->u.indirect.indir_ents[u]->u.indirect.parent = sect1; /* Adjust reference counts for transferred child indirect sections */ @@ -3676,46 +3609,46 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, sect1->u.indirect.span_size += sect2->u.indirect.span_size; /* Make certain we've tracked the first section's dependents correctly */ - HDassert(sect1->u.indirect.rc == - (sect1->u.indirect.indir_nents + sect1->u.indirect.dir_nrows)); + HDassert(sect1->u.indirect.rc == (sect1->u.indirect.indir_nents + sect1->u.indirect.dir_nrows)); /* Wrap up, freeing or re-inserting second row section */ /* (want this to be after the first indirect section is consistent again) */ - if(merged_rows) { + if (merged_rows) { /* Release second row section */ /* (indirectly releases second indirect section, since all of it's * other dependents are gone) */ HDassert(sect2->u.indirect.rc == 1); - if(H5HF__sect_row_free((H5FS_section_info_t *)row_sect2) < 0) + if (H5HF__sect_row_free((H5FS_section_info_t *)row_sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free row section") } /* end if */ else { /* Decrement ref. count on second indirect section's parent */ HDassert(sect2->u.indirect.rc == 0); - if(sect2->u.indirect.parent) - if(H5HF_sect_indirect_decr(sect2->u.indirect.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't decrement ref. count on parent indirect section") + if (sect2->u.indirect.parent) + if (H5HF__sect_indirect_decr(sect2->u.indirect.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, + "can't decrement ref. count on parent indirect section") /* Free second indirect section */ - if(H5HF_sect_indirect_free(sect2) < 0) + if (H5HF__sect_indirect_free(sect2) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") /* Re-add the second section's first row */ /* (it's already been added to first indirect section, but it's been removed * from the free space manager and needs to be re-added) - */ + */ row_sect2->sect_info.type = H5HF_FSPACE_SECT_NORMAL_ROW; - if(H5HF__space_add(hdr, row_sect2, H5FS_ADD_SKIP_VALID) < 0) + if (H5HF__space_add(hdr, row_sect2, H5FS_ADD_SKIP_VALID) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add second row section to free space") } /* end else */ /* Check if we can create parent indirect section for first section */ /* (i.e. merged indirect sections cover an entire indirect block) */ - if(sect1->u.indirect.iblock_entries == sect1->u.indirect.num_entries) { + if (sect1->u.indirect.iblock_entries == sect1->u.indirect.num_entries) { /* Build parent section for fully populated indirect section */ HDassert(sect1->u.indirect.parent == NULL); - if(H5HF__sect_indirect_build_parent(hdr, sect1) < 0) + if (H5HF__sect_indirect_build_parent(hdr, sect1) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create parent for full indirect section") } /* end if */ @@ -3723,7 +3656,6 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_merge_row() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_build_parent * @@ -3740,12 +3672,12 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, 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_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 */ - unsigned par_entry; /* Entry within parent indirect section */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned par_entry; /* Entry within parent indirect section */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3760,14 +3692,14 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.parent == NULL); /* Get information for creating parent indirect section */ - if(sect->u.indirect.u.iblock->parent) { - par_entry = sect->u.indirect.u.iblock->par_entry; - par_iblock = sect->u.indirect.u.iblock->parent; + if (sect->u.indirect.u.iblock->parent) { + par_entry = sect->u.indirect.u.iblock->par_entry; + par_iblock = sect->u.indirect.u.iblock->parent; par_block_off = par_iblock->block_off; } /* end if */ else { /* Retrieve the information for the parent block */ - if(H5HF__man_iblock_parent_info(hdr, sect->sect_info.addr, &par_block_off, &par_entry) < 0) + if (H5HF__man_iblock_parent_info(hdr, sect->sect_info.addr, &par_block_off, &par_entry) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get block entry") par_iblock = NULL; } /* end else */ @@ -3778,35 +3710,34 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(par_row >= hdr->man_dtable.max_direct_rows); /* Create parent indirect section */ - if(NULL == (par_sect = H5HF_sect_indirect_new(hdr, sect->sect_info.addr, - sect->sect_info.size, par_iblock, par_block_off, - par_row, par_col, 1))) + if (NULL == (par_sect = H5HF__sect_indirect_new(hdr, sect->sect_info.addr, sect->sect_info.size, + par_iblock, par_block_off, par_row, par_col, 1))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create indirect section") /* No rows of direct blocks covered in parent, reset direct row information */ par_sect->u.indirect.dir_nrows = 0; - par_sect->u.indirect.dir_rows = NULL; + par_sect->u.indirect.dir_rows = NULL; /* Allocate space for the child indirect sections */ par_sect->u.indirect.indir_nents = 1; - if(NULL == (par_sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) + if (NULL == (par_sect->u.indirect.indir_ents = + (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "allocation failed for indirect section pointer array") /* Attach sections together */ - sect->u.indirect.parent = par_sect; - sect->u.indirect.par_entry = par_entry; + sect->u.indirect.parent = par_sect; + sect->u.indirect.par_entry = par_entry; par_sect->u.indirect.indir_ents[0] = sect; - par_sect->u.indirect.rc = 1; + par_sect->u.indirect.rc = 1; done: - if(ret_value < 0) - if(par_sect && H5HF_sect_indirect_free(par_sect) < 0) + if (ret_value < 0) + if (par_sect && H5HF__sect_indirect_free(par_sect) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_build_parent() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_shrink * @@ -3823,8 +3754,8 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) static herr_t H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3836,35 +3767,34 @@ H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) HDassert(sect->u.indirect.dir_nrows > 0 || sect->u.indirect.indir_nents > 0); /* Walk through direct rows, freeing them */ - for(u = 0; u < sect->u.indirect.dir_nrows; u++) { + for (u = 0; u < sect->u.indirect.dir_nrows; u++) { /* Remove the normal rows from free space manager */ - if(sect->u.indirect.dir_rows[u]->sect_info.type != H5HF_FSPACE_SECT_FIRST_ROW) { + if (sect->u.indirect.dir_rows[u]->sect_info.type != H5HF_FSPACE_SECT_FIRST_ROW) { HDassert(sect->u.indirect.dir_rows[u]->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); - if(H5HF__space_remove(hdr, sect->u.indirect.dir_rows[u]) < 0) + if (H5HF__space_remove(hdr, sect->u.indirect.dir_rows[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space") } /* end if */ /* Release the row section */ - if(H5HF__sect_row_free_real(sect->u.indirect.dir_rows[u]) < 0) + if (H5HF__sect_row_free_real(sect->u.indirect.dir_rows[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free child section node") } /* end for */ /* Walk through indirect entries, freeing them (recursively) */ - for(u = 0; u < sect->u.indirect.indir_nents; u++) - if(H5HF__sect_indirect_shrink(hdr, sect->u.indirect.indir_ents[u]) < 0) + for (u = 0; u < sect->u.indirect.indir_nents; u++) + if (H5HF__sect_indirect_shrink(hdr, sect->u.indirect.indir_ents[u]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free child section node") /* Free the indirect section itself */ - if(H5HF_sect_indirect_free(sect) < 0) + if (H5HF__sect_indirect_free(sect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_shrink() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_serialize + * Function: H5HF__sect_indirect_serialize * * Purpose: Serialize a "live" indirect section into a buffer * @@ -3878,12 +3808,11 @@ H5HF__sect_indirect_shrink(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, - uint8_t *buf) +H5HF__sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, uint8_t *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(hdr); @@ -3891,14 +3820,15 @@ H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, HDassert(buf); /* Check if this indirect section has a parent & forward if this section is first */ - if(sect->u.indirect.parent) { - if(sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) - if(H5HF_sect_indirect_serialize(hdr, sect->u.indirect.parent, buf) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, "can't serialize indirect section's parent indirect section") + if (sect->u.indirect.parent) { + if (sect->sect_info.addr == sect->u.indirect.parent->sect_info.addr) + if (H5HF__sect_indirect_serialize(hdr, sect->u.indirect.parent, buf) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSERIALIZE, FAIL, + "can't serialize indirect section's parent indirect section") } /* end if */ else { /* Indirect range's indirect block's block offset */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { HDassert(sect->u.indirect.u.iblock); UINT64ENCODE_VAR(buf, sect->u.indirect.u.iblock->block_off, hdr->heap_off_size); } /* end if */ @@ -3917,9 +3847,8 @@ H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_indirect_serialize() */ +} /* H5HF__sect_indirect_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HF__sect_indirect_deserialize * @@ -3934,19 +3863,19 @@ H5HF_sect_indirect_serialize(H5HF_hdr_t *hdr, const H5HF_free_section_t *sect, *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, - haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags) +H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, + unsigned *des_flags) { - H5HF_free_section_t *new_sect; /* New indirect section */ - hsize_t iblock_off; /* Indirect block's offset */ - unsigned start_row; /* Indirect section's start row */ - unsigned start_col; /* Indirect section's start column */ - unsigned nentries; /* Indirect section's number of entries */ - unsigned start_entry; /* Start entry in indirect block */ - unsigned end_entry; /* End entry in indirect block */ - unsigned end_row; /* End row in indirect block */ - unsigned end_col; /* End column in indirect block */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5HF_free_section_t *new_sect; /* New indirect section */ + hsize_t iblock_off; /* Indirect block's offset */ + unsigned start_row; /* Indirect section's start row */ + unsigned start_col; /* Indirect section's start column */ + unsigned nentries; /* Indirect section's number of entries */ + unsigned start_entry; /* Start entry in indirect block */ + unsigned end_entry; /* End entry in indirect block */ + unsigned end_row; /* End row in indirect block */ + unsigned end_col; /* End column in indirect block */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -3969,8 +3898,8 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, UINT16DECODE(buf, nentries); /* Create free space section node */ - if(NULL == (new_sect = H5HF_sect_indirect_new(hdr, sect_addr, sect_size, - NULL, iblock_off, start_row, start_col, nentries))) + if (NULL == (new_sect = H5HF__sect_indirect_new(hdr, sect_addr, sect_size, NULL, iblock_off, start_row, + start_col, nentries))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create indirect section") /* Compute start entry */ @@ -3978,13 +3907,13 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, /* Compute end column & row */ end_entry = (start_entry + nentries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; - end_col = end_entry % hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; + end_col = end_entry % hdr->man_dtable.cparam.width; /* Initialize rows for new indirect section */ - if(H5HF__sect_indirect_init_rows(hdr, new_sect, TRUE, NULL, - H5FS_ADD_DESERIALIZING, new_sect->u.indirect.row, new_sect->u.indirect.col, - end_row, end_col) < 0) + if (H5HF__sect_indirect_init_rows(hdr, new_sect, TRUE, NULL, H5FS_ADD_DESERIALIZING, + new_sect->u.indirect.row, new_sect->u.indirect.col, end_row, + end_col) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize indirect section") /* Indicate that this section shouldn't be added to free space manager's list */ @@ -3997,9 +3926,8 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, FUNC_LEAVE_NOAPI(ret_value) } /* H5HF__sect_indirect_deserialize() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_free + * Function: H5HF__sect_indirect_free * * Purpose: Free a 'indirect' section node * @@ -4013,12 +3941,12 @@ H5HF__sect_indirect_deserialize(H5HF_hdr_t *hdr, const uint8_t *buf, *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_free(H5HF_free_section_t *sect) +H5HF__sect_indirect_free(H5HF_free_section_t *sect) { - H5HF_indirect_t *iblock = NULL; /* Indirect block for section */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_indirect_t *iblock = NULL; /* Indirect block for section */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(sect); @@ -4029,22 +3957,21 @@ H5HF_sect_indirect_free(H5HF_free_section_t *sect) sect->u.indirect.indir_ents = (H5HF_free_section_t **)H5MM_xfree(sect->u.indirect.indir_ents); /* Check for live reference to an indirect block */ - if(sect->sect_info.state == H5FS_SECT_LIVE) + if (sect->sect_info.state == H5FS_SECT_LIVE) /* Get indirect block, if there was one */ - if(sect->u.indirect.u.iblock) + if (sect->u.indirect.u.iblock) iblock = sect->u.indirect.u.iblock; /* Release the sections */ - if(H5HF_sect_node_free(sect, iblock) < 0) + if (H5HF__sect_node_free(sect, iblock) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF_sect_indirect_free() */ +} /* H5HF__sect_indirect_free() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_valid + * Function: H5HF__sect_indirect_valid * * Purpose: Check the validity of a section * @@ -4057,37 +3984,37 @@ H5HF_sect_indirect_free(H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) +H5HF__sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) { - unsigned start_row; /* Row for first block covered */ - unsigned start_col; /* Column for first block covered */ - unsigned start_entry; /* Entry for first block covered */ - unsigned end_row; /* Row for last block covered */ - unsigned end_entry; /* Entry for last block covered */ - unsigned u; /* Local index variable */ + unsigned start_row; /* Row for first block covered */ + unsigned start_col; /* Column for first block covered */ + unsigned start_entry; /* Entry for first block covered */ + unsigned end_row; /* Row for last block covered */ + unsigned end_entry; /* Entry for last block covered */ + unsigned u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check arguments */ HDassert(hdr); HDassert(sect); /* Compute starting entry, column & row */ - start_row = sect->u.indirect.row; - start_col = sect->u.indirect.col; + start_row = sect->u.indirect.row; + start_col = sect->u.indirect.col; start_entry = (start_row * hdr->man_dtable.cparam.width) + start_col; /* Compute ending entry, column & row */ end_entry = (start_entry + sect->u.indirect.num_entries) - 1; - end_row = end_entry / hdr->man_dtable.cparam.width; + end_row = end_entry / hdr->man_dtable.cparam.width; /* Sanity check any direct rows */ - if(sect->u.indirect.dir_nrows > 0) { - unsigned dir_nrows; /* Number of direct rows in section */ - unsigned max_dir_row; /* Maximum direct row in section */ + if (sect->u.indirect.dir_nrows > 0) { + unsigned dir_nrows; /* Number of direct rows in section */ + unsigned max_dir_row; /* Maximum direct row in section */ /* Check for indirect rows in section */ - if(end_row >= hdr->man_dtable.max_direct_rows) + if (end_row >= hdr->man_dtable.max_direct_rows) max_dir_row = hdr->man_dtable.max_direct_rows - 1; else max_dir_row = end_row; @@ -4095,59 +4022,59 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) /* Iterate over direct rows, checking pointer references */ dir_nrows = (max_dir_row - start_row) + 1; HDassert(dir_nrows == sect->u.indirect.dir_nrows); - for(u = 0; u < dir_nrows; u++) { - const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect; /* Pointer to row section */ + for (u = 0; u < dir_nrows; u++) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect; /* Pointer to row section */ tmp_row_sect = sect->u.indirect.dir_rows[u]; - HDassert(tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW - || tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); + HDassert(tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW || + tmp_row_sect->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW); HDassert(tmp_row_sect->u.row.under == sect); HDassert(tmp_row_sect->u.row.row == (start_row + u)); - if(u > 0) { - const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect2; /* Pointer to row section */ + if (u > 0) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED *tmp_row_sect2; /* Pointer to row section */ tmp_row_sect2 = sect->u.indirect.dir_rows[u - 1]; HDassert(tmp_row_sect2->u.row.row < tmp_row_sect->u.row.row); HDassert(H5F_addr_lt(tmp_row_sect2->sect_info.addr, tmp_row_sect->sect_info.addr)); HDassert(tmp_row_sect2->sect_info.size <= tmp_row_sect->sect_info.size); } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Sanity check any indirect entries */ - if(sect->u.indirect.indir_nents > 0) { + if (sect->u.indirect.indir_nents > 0) { /* Basic sanity checks */ - if(sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.state == H5FS_SECT_LIVE) { HDassert(sect->u.indirect.iblock_entries); HDassert(sect->u.indirect.indir_nents <= sect->u.indirect.iblock_entries); } /* end if */ HDassert(sect->u.indirect.indir_ents); /* Sanity check each child indirect section */ - for(u = 0; u < sect->u.indirect.indir_nents; u++) { - const H5HF_free_section_t *tmp_child_sect; /* Pointer to child indirect section */ + for (u = 0; u < sect->u.indirect.indir_nents; u++) { + const H5HF_free_section_t *tmp_child_sect; /* Pointer to child indirect section */ tmp_child_sect = sect->u.indirect.indir_ents[u]; HDassert(tmp_child_sect->sect_info.type == H5HF_FSPACE_SECT_INDIRECT); 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 */ + if (u > 0) { + const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED + * 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)); } /* end if */ /* Recursively check child indirect section */ - H5HF_sect_indirect_valid(hdr, tmp_child_sect); + H5HF__sect_indirect_valid(hdr, tmp_child_sect); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_sect_indirect_valid() */ +} /* H5HF__sect_indirect_valid() */ - /*------------------------------------------------------------------------- - * Function: H5HF_sect_indirect_debug + * Function: H5HF__sect_indirect_debug * * Purpose: Dump debugging information about an indirect free space section * @@ -4161,25 +4088,17 @@ H5HF_sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect) *------------------------------------------------------------------------- */ static herr_t -H5HF_sect_indirect_debug(const H5HF_free_section_t *sect, - FILE *stream, int indent, int fwidth) +H5HF__sect_indirect_debug(const H5HF_free_section_t *sect, FILE *stream, int indent, int fwidth) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect); /* Print indirect section information */ - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Row:", - sect->u.indirect.row); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Column:", - sect->u.indirect.col); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of entries:", - sect->u.indirect.num_entries); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Row:", sect->u.indirect.row); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Column:", sect->u.indirect.col); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of entries:", sect->u.indirect.num_entries); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_sect_indirect_debug() */ - +} /* H5HF__sect_indirect_debug() */ diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 65bdb896a4d..d62267cd0e4 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,57 +26,48 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ /****************/ /* Local Macros */ /****************/ -#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ -#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ -#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ -#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */ +#define H5HF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ +#define H5HF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ +#define H5HF_FSPACE_THRHD_DEF 1 /* Default: no alignment threshold */ +#define H5HF_FSPACE_ALIGN_DEF 1 /* Default: no alignment */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF__space_start * @@ -96,12 +87,10 @@ herr_t H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */ - H5HF_FSPACE_SECT_CLS_SINGLE, - H5HF_FSPACE_SECT_CLS_FIRST_ROW, - H5HF_FSPACE_SECT_CLS_NORMAL_ROW, - H5HF_FSPACE_SECT_CLS_INDIRECT}; - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for fractal heap */ + H5HF_FSPACE_SECT_CLS_SINGLE, H5HF_FSPACE_SECT_CLS_FIRST_ROW, + H5HF_FSPACE_SECT_CLS_NORMAL_ROW, H5HF_FSPACE_SECT_CLS_INDIRECT}; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -111,37 +100,37 @@ H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) HDassert(hdr); /* Check for creating free space info for the heap */ - if(H5F_addr_defined(hdr->fs_addr)) { + if (H5F_addr_defined(hdr->fs_addr)) { /* Open an existing free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, - NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) + if (NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, NELMTS(classes), classes, hdr, + (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") } /* end if */ else { /* Check if we are allowed to create the free space manager */ - if(may_create) { - H5FS_create_t fs_create; /* Free space creation parameters */ + if (may_create) { + H5FS_create_t fs_create; /* Free space creation parameters */ /* Set the free space creation parameters */ - fs_create.client = H5FS_CLIENT_FHEAP_ID; + fs_create.client = H5FS_CLIENT_FHEAP_ID; fs_create.shrink_percent = H5HF_FSPACE_SHRINK; fs_create.expand_percent = H5HF_FSPACE_EXPAND; - fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size; - fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index; + fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size; + fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index; /* Create the free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, - &fs_create, NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) + if (NULL == + (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, &fs_create, NELMTS(classes), classes, hdr, + (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") HDassert(H5F_addr_defined(hdr->fs_addr)); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_start() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_add * @@ -159,8 +148,8 @@ H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) herr_t H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) { - H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -171,22 +160,21 @@ H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) HDassert(node); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, TRUE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Construct user data */ udata.hdr = hdr; /* Add to the free space for the heap */ - if(H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) + if (H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't add section to heap free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_add() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_find * @@ -203,8 +191,8 @@ H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) htri_t H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) { - htri_t node_found = FALSE; /* Whether an existing free list node was found */ - htri_t ret_value = FAIL; /* Return value */ + htri_t node_found = FALSE; /* Whether an existing free list node was found */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -216,13 +204,13 @@ H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) HDassert(node); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, FALSE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Search for free space in the heap */ - if(hdr->fspace) - if((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) + if (hdr->fspace) + if ((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap") /* Set return value */ @@ -232,9 +220,8 @@ H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_find() */ - /*------------------------------------------------------------------------- - * Function: H5HF_space_revert_root_cb + * Function: H5HF__space_revert_root_cb * * Purpose: Callback routine from iterator, to reset 'parent' pointers in * sections, when the heap is changing from having a root indirect @@ -249,12 +236,12 @@ H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) *------------------------------------------------------------------------- */ static herr_t -H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata) +H5HF__space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata) { - H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -262,22 +249,22 @@ H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udat HDassert(sect); /* Only modify "live" single blocks... */ - if(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) { + if (sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) { /* Release hold on previous indirect block (we must have one) */ HDassert(sect->u.single.parent); - if(H5HF__iblock_decr(sect->u.single.parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") + if (H5HF__iblock_decr(sect->u.single.parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, + "can't decrement reference count on section's indirect block") /* Reset parent information */ - sect->u.single.parent = NULL; + sect->u.single.parent = NULL; sect->u.single.par_entry = 0; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_revert_root_cb() */ +} /* end H5HF__space_revert_root_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_revert_root * @@ -295,7 +282,7 @@ H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udat herr_t H5HF__space_revert_root(const H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -305,18 +292,17 @@ H5HF__space_revert_root(const H5HF_hdr_t *hdr) HDassert(hdr); /* Only need to scan the sections if the free space has been initialized */ - if(hdr->fspace) + if (hdr->fspace) /* Iterate over all sections, resetting the parent pointers in 'single' sections */ - if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) + if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_revert_root_cb, NULL) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to reset parent pointers") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_revert_root() */ - /*------------------------------------------------------------------------- - * Function: H5HF_space_create_root_cb + * Function: H5HF__space_create_root_cb * * Purpose: Callback routine from iterator, to set 'parent' pointers in * sections to newly created root indirect block, when the heap @@ -331,13 +317,13 @@ H5HF__space_revert_root(const H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ static herr_t -H5HF_space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -351,22 +337,22 @@ H5HF_space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE); /* Increment ref. count on new root indirect block */ - if(H5HF_iblock_incr(root_iblock) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on section's indirect block") + if (H5HF__iblock_incr(root_iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, + "can't increment reference count on section's indirect block") /* Set parent info ("live" section must _NOT_ have a parent right now) */ - if(sect->sect_info.state == H5FS_SECT_SERIALIZED) - sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */ + if (sect->sect_info.state == H5FS_SECT_SERIALIZED) + sect->sect_info.state = H5FS_SECT_LIVE; /* Mark "live" now */ else - HDassert(!sect->u.single.parent); - sect->u.single.parent = root_iblock; + HDassert(!sect->u.single.parent); + sect->u.single.parent = root_iblock; sect->u.single.par_entry = 0; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_create_root_cb() */ +} /* end H5HF__space_create_root_cb() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_create_root * @@ -385,7 +371,7 @@ H5HF_space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) herr_t H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -396,16 +382,16 @@ H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) HDassert(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 block */ - if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) + if (hdr->fspace) + /* Iterate over all sections, seting 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") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_create_root() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_size * @@ -422,7 +408,7 @@ H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) herr_t H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -433,13 +419,13 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) HDassert(fs_size); /* Check if the free space for the heap has been initialized */ - if(!hdr->fspace) - if(H5HF__space_start(hdr, FALSE) < 0) + if (!hdr->fspace) + if (H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Get free space metadata size */ - if(hdr->fspace) { - if(H5FS_size(hdr->fspace, fs_size) < 0) + if (hdr->fspace) { + if (H5FS_size(hdr->fspace, fs_size) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") } /* end if */ else @@ -449,7 +435,6 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_size() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_remove * @@ -466,7 +451,7 @@ H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) herr_t H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -478,14 +463,13 @@ H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) HDassert(node); /* Remove from the free space for the heap */ - if(H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0) + if (H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_remove() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_close * @@ -503,7 +487,7 @@ H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) herr_t H5HF__space_close(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -513,31 +497,30 @@ H5HF__space_close(H5HF_hdr_t *hdr) HDassert(hdr); /* Check if the free space was ever opened */ - if(hdr->fspace) { - hsize_t nsects; /* Number of sections for this heap */ + if (hdr->fspace) { + hsize_t nsects; /* Number of sections for this heap */ /* Retrieve the number of sections for this heap */ - if(H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0) + if (H5FS_sect_stats(hdr->fspace, NULL, &nsects) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOUNT, FAIL, "can't query free space section count") /* Close the free space for the heap */ - if(H5FS_close(hdr->f, hdr->fspace) < 0) + if (H5FS_close(hdr->f, hdr->fspace) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") hdr->fspace = NULL; /* Check if we can delete the free space manager for this heap */ - if(!nsects) { - if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) + if (!nsects) { + if (H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete free space info") hdr->fs_addr = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_close() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_delete * @@ -554,7 +537,7 @@ H5HF__space_close(H5HF_hdr_t *hdr) herr_t H5HF__space_delete(H5HF_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -564,14 +547,13 @@ H5HF__space_delete(H5HF_hdr_t *hdr) HDassert(hdr); /* Delete the free space manager */ - if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) + if (H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete to free space manager") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_delete() */ - /*------------------------------------------------------------------------- * Function: H5HF__space_sect_change_class * @@ -589,7 +571,7 @@ H5HF__space_delete(H5HF_hdr_t *hdr) herr_t H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16_t new_class) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -601,10 +583,9 @@ H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, uint16 HDassert(sect); /* Notify the free space manager that a section has changed class */ - if(H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) + if (H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't modify class of free space section") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__space_sect_change_class() */ - diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 456fd607e9b..5e5d06ad630 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,52 +22,43 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ /****************/ /* Local Macros */ /****************/ - /********************/ /* Package Typedefs */ /********************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_stat_info * @@ -92,21 +83,20 @@ H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats) HDassert(stats); /* Report statistics for fractal heap */ - stats->man_size = fh->hdr->man_size; + stats->man_size = fh->hdr->man_size; stats->man_alloc_size = fh->hdr->man_alloc_size; - stats->man_iter_off = fh->hdr->man_iter_off; - stats->man_nobjs = fh->hdr->man_nobjs; + stats->man_iter_off = fh->hdr->man_iter_off; + stats->man_nobjs = fh->hdr->man_nobjs; stats->man_free_space = fh->hdr->total_man_free; - stats->huge_size = fh->hdr->huge_size; - stats->huge_nobjs = fh->hdr->huge_nobjs; - stats->tiny_size = fh->hdr->tiny_size; - stats->tiny_nobjs = fh->hdr->tiny_nobjs; -/* XXX: Add more metadata statistics for the heap */ + stats->huge_size = fh->hdr->huge_size; + stats->huge_nobjs = fh->hdr->huge_nobjs; + stats->tiny_size = fh->hdr->tiny_size; + stats->tiny_nobjs = fh->hdr->tiny_nobjs; + /* XXX: Add more metadata statistics for the heap */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_stat_info() */ - /*------------------------------------------------------------------------- * Function: H5HF_size * @@ -125,10 +115,10 @@ H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats) 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 */ - hsize_t meta_size = 0; /* free space storage size */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HF_hdr_t *hdr; /* Fractal heap header */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -142,38 +132,40 @@ H5HF_size(const H5HF_t *fh, hsize_t *heap_size) hdr = fh->hdr; /* Add in values already known */ - *heap_size += hdr->heap_size; /* Heap header */ - *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */ - *heap_size += hdr->huge_size; /* "huge" object storage */ + *heap_size += hdr->heap_size; /* Heap header */ + *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */ + *heap_size += hdr->huge_size; /* "huge" object storage */ /* Check for indirect blocks for managed objects */ - if(H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) - if(H5HF__man_iblock_size(hdr->f, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, NULL, 0, heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block") + if (H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) + if (H5HF__man_iblock_size(hdr->f, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, + NULL, 0, heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, + "unable to get fractal heap storage info for indirect block") /* Check for B-tree storage of huge objects in fractal heap */ - if(H5F_addr_defined(hdr->huge_bt2_addr)) { + if (H5F_addr_defined(hdr->huge_bt2_addr)) { /* Open the huge object index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' objects") + if (NULL == (bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for tracking 'huge' objects") /* Get the B-tree storage */ - if(H5B2_size(bt2, heap_size) < 0) + if (H5B2_size(bt2, heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Get storage for free-space tracking info */ - if(H5F_addr_defined(hdr->fs_addr)) { - if(H5HF__space_size(hdr, &meta_size) < 0) + if (H5F_addr_defined(hdr->fs_addr)) { + if (H5HF__space_size(hdr, &meta_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") - *heap_size += meta_size; + *heap_size += meta_size; } /* end if */ done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_size() */ - diff --git a/src/H5HFtest.c b/src/H5HFtest.c index 14b20eb8293..84734d2a430 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,55 +22,45 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ -#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ +#define H5HF_TESTING /*suppress warning about H5HF testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HF_get_cparam_test * @@ -95,9 +85,9 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) HDassert(cparam); /* Get fractal heap creation parameters */ - if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->heap_off_size + fh->hdr->heap_len_size)) + if (fh->hdr->id_len == (unsigned)(1 + fh->hdr->heap_off_size + fh->hdr->heap_len_size)) cparam->id_len = 0; - else if(fh->hdr->id_len == (unsigned)(1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr)) + else if (fh->hdr->id_len == (unsigned)(1 + fh->hdr->sizeof_size + fh->hdr->sizeof_addr)) cparam->id_len = 1; else H5_CHECKED_ASSIGN(cparam->id_len, uint16_t, fh->hdr->id_len, unsigned); @@ -108,7 +98,6 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_cmp_cparam_test * @@ -125,7 +114,7 @@ H5HF_get_cparam_test(const H5HF_t *fh, H5HF_create_t *cparam) int H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -134,57 +123,57 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) HDassert(cparam2); /* Compare doubling table parameters */ - if(cparam1->managed.width < cparam2->managed.width) + if (cparam1->managed.width < cparam2->managed.width) HGOTO_DONE(-1) - else if(cparam1->managed.width > cparam2->managed.width) + else if (cparam1->managed.width > cparam2->managed.width) HGOTO_DONE(1) - if(cparam1->managed.start_block_size < cparam2->managed.start_block_size) + if (cparam1->managed.start_block_size < cparam2->managed.start_block_size) HGOTO_DONE(-1) - else if(cparam1->managed.start_block_size > cparam2->managed.start_block_size) + else if (cparam1->managed.start_block_size > cparam2->managed.start_block_size) HGOTO_DONE(1) - if(cparam1->managed.max_direct_size < cparam2->managed.max_direct_size) + if (cparam1->managed.max_direct_size < cparam2->managed.max_direct_size) HGOTO_DONE(-1) - else if(cparam1->managed.max_direct_size > cparam2->managed.max_direct_size) + else if (cparam1->managed.max_direct_size > cparam2->managed.max_direct_size) HGOTO_DONE(1) - if(cparam1->managed.max_index < cparam2->managed.max_index) + if (cparam1->managed.max_index < cparam2->managed.max_index) HGOTO_DONE(-1) - else if(cparam1->managed.max_index > cparam2->managed.max_index) + else if (cparam1->managed.max_index > cparam2->managed.max_index) HGOTO_DONE(1) - if(cparam1->managed.start_root_rows < cparam2->managed.start_root_rows) + if (cparam1->managed.start_root_rows < cparam2->managed.start_root_rows) HGOTO_DONE(-1) - else if(cparam1->managed.start_root_rows > cparam2->managed.start_root_rows) + else if (cparam1->managed.start_root_rows > cparam2->managed.start_root_rows) HGOTO_DONE(1) /* Compare other general parameters for heap */ - if(cparam1->max_man_size < cparam2->max_man_size) + if (cparam1->max_man_size < cparam2->max_man_size) HGOTO_DONE(-1) - else if(cparam1->max_man_size > cparam2->max_man_size) + else if (cparam1->max_man_size > cparam2->max_man_size) HGOTO_DONE(1) - if(cparam1->id_len < cparam2->id_len) + if (cparam1->id_len < cparam2->id_len) HGOTO_DONE(-1) - else if(cparam1->id_len > cparam2->id_len) + else if (cparam1->id_len > cparam2->id_len) HGOTO_DONE(1) /* Compare "important" parameters for any I/O pipeline filters */ - if(cparam1->pline.nused < cparam2->pline.nused) + if (cparam1->pline.nused < cparam2->pline.nused) HGOTO_DONE(-1) - else if(cparam1->pline.nused > cparam2->pline.nused) + else if (cparam1->pline.nused > cparam2->pline.nused) HGOTO_DONE(1) else { - size_t u, v; /* Local index variables */ + size_t u, v; /* Local index variables */ /* Compare each filter */ - for(u = 0; u < cparam1->pline.nused; u++) { + for (u = 0; u < cparam1->pline.nused; u++) { /* Check filter ID */ - if(cparam1->pline.filter[u].id < cparam2->pline.filter[u].id) + if (cparam1->pline.filter[u].id < cparam2->pline.filter[u].id) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].id > cparam2->pline.filter[u].id) + else if (cparam1->pline.filter[u].id > cparam2->pline.filter[u].id) HGOTO_DONE(1) /* Check filter flags */ - if(cparam1->pline.filter[u].flags < cparam2->pline.filter[u].flags) + if (cparam1->pline.filter[u].flags < cparam2->pline.filter[u].flags) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].flags > cparam2->pline.filter[u].flags) + else if (cparam1->pline.filter[u].flags > cparam2->pline.filter[u].flags) HGOTO_DONE(1) /* Don't worry about comparing the filter names right now... */ @@ -204,27 +193,26 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) #endif /* Check # of filter parameters */ - if(cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) + if (cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].cd_nelmts > cparam2->pline.filter[u].cd_nelmts) + else if (cparam1->pline.filter[u].cd_nelmts > cparam2->pline.filter[u].cd_nelmts) HGOTO_DONE(1) /* Check filter parameters */ - for(v = 0; v < cparam1->pline.filter[u].cd_nelmts; v++) { - if(cparam1->pline.filter[u].cd_values[v] < cparam2->pline.filter[u].cd_values[v]) + for (v = 0; v < cparam1->pline.filter[u].cd_nelmts; v++) { + if (cparam1->pline.filter[u].cd_values[v] < cparam2->pline.filter[u].cd_values[v]) HGOTO_DONE(-1) - else if(cparam1->pline.filter[u].cd_values[v] > cparam2->pline.filter[u].cd_values[v]) + else if (cparam1->pline.filter[u].cd_values[v] > cparam2->pline.filter[u].cd_values[v]) HGOTO_DONE(1) } /* end for */ } /* end for */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_cmp_cparam_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_max_root_rows * @@ -242,7 +230,7 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) unsigned H5HF_get_max_root_rows(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -255,7 +243,6 @@ H5HF_get_max_root_rows(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_max_root_rows() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dtable_width_test * @@ -273,7 +260,7 @@ H5HF_get_max_root_rows(const H5HF_t *fh) unsigned H5HF_get_dtable_width_test(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -286,7 +273,6 @@ H5HF_get_dtable_width_test(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dtable_width_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dtable_max_drows_test * @@ -304,7 +290,7 @@ H5HF_get_dtable_width_test(const H5HF_t *fh) unsigned H5HF_get_dtable_max_drows_test(const H5HF_t *fh) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -317,7 +303,6 @@ H5HF_get_dtable_max_drows_test(const H5HF_t *fh) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dtable_max_drows_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_iblock_max_drows_test * @@ -339,7 +324,7 @@ H5HF_get_dtable_max_drows_test(const H5HF_t *fh) unsigned H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) { - unsigned ret_value = 0; /* Return value */ + unsigned ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -348,13 +333,11 @@ H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) HDassert(pos); /* Return max. # of direct blocks in this indirect block row */ - ret_value = pos + (fh->hdr->man_dtable.max_direct_bits - - fh->hdr->man_dtable.first_row_bits) + 1; + ret_value = pos + (fh->hdr->man_dtable.max_direct_bits - fh->hdr->man_dtable.first_row_bits) + 1; FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_iblock_max_drows_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dblock_size_test * @@ -372,7 +355,7 @@ H5HF_get_iblock_max_drows_test(const H5HF_t *fh, unsigned pos) hsize_t H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -385,7 +368,6 @@ H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dblock_size_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_dblock_free_test * @@ -404,7 +386,7 @@ H5HF_get_dblock_size_test(const H5HF_t *fh, unsigned row) hsize_t H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -417,7 +399,6 @@ H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) FUNC_LEAVE_NOAPI(ret_value) } /* H5HF_get_dblock_free_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_off_test * @@ -435,7 +416,7 @@ H5HF_get_dblock_free_test(const H5HF_t *fh, unsigned row) herr_t H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -452,7 +433,6 @@ H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_id_off_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_id_type_test * @@ -469,7 +449,7 @@ H5HF_get_id_off_test(const H5HF_t *fh, const void *_id, hsize_t *obj_off) herr_t H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) { - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ + const uint8_t *id = (const uint8_t *)_id; /* Object ID */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -483,7 +463,6 @@ H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_id_type_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_tiny_info_test * @@ -498,8 +477,7 @@ H5HF_get_id_type_test(const void *_id, unsigned char *obj_type) *------------------------------------------------------------------------- */ herr_t -H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, - hbool_t *len_extended) +H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, hbool_t *len_extended) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -510,13 +488,12 @@ H5HF_get_tiny_info_test(const H5HF_t *fh, size_t *max_len, HDassert(len_extended); /* Retrieve information about tiny object's ID encoding in a heap */ - *max_len = fh->hdr->tiny_max_len; + *max_len = fh->hdr->tiny_max_len; *len_extended = fh->hdr->tiny_len_extended; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_tiny_info_test() */ - /*------------------------------------------------------------------------- * Function: H5HF_get_huge_info_test * @@ -541,10 +518,9 @@ H5HF_get_huge_info_test(const H5HF_t *fh, hsize_t *next_id, hbool_t *ids_direct) HDassert(ids_direct); /* Retrieve information about tiny object's ID encoding in a heap */ - if(next_id) + if (next_id) *next_id = fh->hdr->huge_next_id; *ids_direct = fh->hdr->huge_ids_direct; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_get_huge_info_test() */ - diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index f9cb7e39dca..eca177c1752 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,64 +26,54 @@ /* Module Setup */ /****************/ -#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ - +#include "H5HFmodule.h" /* This source code file is part of the H5HF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ /* Tiny object length information */ -#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */ -#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ -#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ - +#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */ +#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ +#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, - H5HF_operator_t op, void *op_data); - +static herr_t H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_init + * Function: H5HF__tiny_init * * Purpose: Initialize information for tracking 'tiny' objects * @@ -95,9 +85,9 @@ static herr_t H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_init(H5HF_hdr_t *hdr) +H5HF__tiny_init(H5HF_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -111,25 +101,24 @@ H5HF_tiny_init(H5HF_hdr_t *hdr) * extra byte, but using that byte means that the extra length byte is * unnecessary) */ - if((hdr->id_len - 1) <= H5HF_TINY_LEN_SHORT) { - hdr->tiny_max_len = hdr->id_len - 1; + if ((hdr->id_len - 1) <= H5HF_TINY_LEN_SHORT) { + hdr->tiny_max_len = hdr->id_len - 1; hdr->tiny_len_extended = FALSE; } /* end if */ - else if((hdr->id_len - 1) == (H5HF_TINY_LEN_SHORT + 1)) { - hdr->tiny_max_len = H5HF_TINY_LEN_SHORT; + else if ((hdr->id_len - 1) == (H5HF_TINY_LEN_SHORT + 1)) { + hdr->tiny_max_len = H5HF_TINY_LEN_SHORT; hdr->tiny_len_extended = FALSE; } /* end if */ else { - hdr->tiny_max_len = hdr->id_len - 2; + hdr->tiny_max_len = hdr->id_len - 2; hdr->tiny_len_extended = TRUE; } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_tiny_init() */ +} /* end H5HF__tiny_init() */ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_insert + * Function: H5HF__tiny_insert * * Purpose: Pack a 'tiny' object in a heap ID * @@ -141,13 +130,13 @@ H5HF_tiny_init(H5HF_hdr_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) +H5HF__tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) { - uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -162,13 +151,12 @@ H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) enc_obj_size = obj_size - 1; /* Encode object into ID */ - if(!hdr->tiny_len_extended) { - *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | - (enc_obj_size & H5HF_TINY_MASK_SHORT)); + if (!hdr->tiny_len_extended) { + *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | (enc_obj_size & H5HF_TINY_MASK_SHORT)); } /* end if */ else { - *id++ = (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | - ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8)); + *id++ = + (uint8_t)(H5HF_ID_VERS_CURR | H5HF_ID_TYPE_TINY | ((enc_obj_size & H5HF_TINY_MASK_EXT_1) >> 8)); *id++ = enc_obj_size & H5HF_TINY_MASK_EXT_2; } /* end else */ @@ -180,16 +168,15 @@ H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) hdr->tiny_nobjs++; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_tiny_insert() */ +} /* end H5HF__tiny_insert() */ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_get_obj_len + * Function: H5HF__tiny_get_obj_len * * Purpose: Get the size of a 'tiny' object in a fractal heap * @@ -201,11 +188,11 @@ H5HF_tiny_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) +H5HF__tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) { - size_t enc_obj_size; /* Encoded object size */ + size_t enc_obj_size; /* Encoded object size */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* * Check arguments. @@ -215,21 +202,20 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) HDassert(obj_len_p); /* Check if 'tiny' object ID is in extended form, and retrieve encoded size */ - if(!hdr->tiny_len_extended) + if (!hdr->tiny_len_extended) enc_obj_size = *id & H5HF_TINY_MASK_SHORT; else /* (performed in this odd way to avoid compiler bug on tg-login3 with * gcc 3.2.2 - QAK) */ - enc_obj_size = (size_t)*(id + 1) | ((size_t)(*id & H5HF_TINY_MASK_EXT_1) << 8); + enc_obj_size = (size_t) * (id + 1) | ((size_t)(*id & H5HF_TINY_MASK_EXT_1) << 8); /* Set the object's length */ *obj_len_p = enc_obj_size + 1; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HF_tiny_get_obj_len() */ +} /* end H5HF__tiny_get_obj_len() */ - /*------------------------------------------------------------------------- * Function: H5HF__tiny_op_real * @@ -243,11 +229,10 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) *------------------------------------------------------------------------- */ static herr_t -H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -259,30 +244,30 @@ H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, HDassert(op); /* Get the object's encoded length */ - /* H5HF_tiny_obj_len can't fail */ - ret_value = H5HF_tiny_get_obj_len(hdr, id, &enc_obj_size); + /* H5HF__tiny_obj_len can't fail */ + ret_value = H5HF__tiny_get_obj_len(hdr, id, &enc_obj_size); /* Advance past flag byte(s) */ - if(!hdr->tiny_len_extended) + if (!hdr->tiny_len_extended) id++; else { /* (performed in two steps to avoid compiler bug on tg-login3 with * gcc 3.2.2 - QAK) */ - id++; id++; + id++; + id++; } /* Call the user's 'op' callback */ - if(op(id, enc_obj_size, op_data) < 0) + if (op(id, enc_obj_size, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__tiny_op_real() */ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_read + * Function: H5HF__tiny_read * * Purpose: Read a 'tiny' object from the heap * @@ -294,11 +279,11 @@ H5HF__tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) +H5HF__tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -308,16 +293,15 @@ H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) HDassert(obj); /* Call the internal 'op' routine */ - if(H5HF__tiny_op_real(hdr, id, H5HF_op_read, obj) < 0) + if (H5HF__tiny_op_real(hdr, id, H5HF__op_read, obj) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_tiny_read() */ +} /* end H5HF__tiny_read() */ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_op + * Function: H5HF__tiny_op * * Purpose: Operate directly on a 'tiny' object * @@ -329,12 +313,11 @@ H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj) *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, - void *op_data) +H5HF__tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -344,16 +327,15 @@ H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, HDassert(op); /* Call the internal 'op' routine routine */ - if(H5HF__tiny_op_real(hdr, id, op, op_data) < 0) + if (H5HF__tiny_op_real(hdr, id, op, op_data) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_tiny_op() */ +} /* end H5HF__tiny_op() */ - /*------------------------------------------------------------------------- - * Function: H5HF_tiny_remove + * Function: H5HF__tiny_remove * * Purpose: Remove a 'tiny' object from the heap statistics * @@ -365,12 +347,12 @@ H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, *------------------------------------------------------------------------- */ herr_t -H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) +H5HF__tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - size_t enc_obj_size; /* Encoded object size */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t enc_obj_size; /* Encoded object size */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -379,17 +361,17 @@ H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) HDassert(id); /* Get the object's encoded length */ - /* H5HF_tiny_obj_len can't fail */ - ret_value = H5HF_tiny_get_obj_len(hdr, id, &enc_obj_size); + /* H5HF__tiny_obj_len can't fail */ + ret_value = H5HF__tiny_get_obj_len(hdr, id, &enc_obj_size); /* Update statistics about heap */ hdr->tiny_size -= enc_obj_size; hdr->tiny_nobjs--; /* Mark heap header as modified */ - if(H5HF_hdr_dirty(hdr) < 0) + if (H5HF__hdr_dirty(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDIRTY, FAIL, "can't mark heap header as dirty") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_tiny_remove() */ +} /* end H5HF__tiny_remove() */ diff --git a/src/H5HG.c b/src/H5HG.c index dc945e0df71..cae23a77240 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -39,19 +39,17 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -60,30 +58,27 @@ /* * The maximum number of links allowed to a global heap object. */ -#define H5HG_MAXLINK 65535 +#define H5HG_MAXLINK 65535 /* * The maximum number of indices allowed in a global heap object. */ -#define H5HG_MAXIDX 65535 - +#define H5HG_MAXIDX 65535 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static haddr_t H5HG__create(H5F_t *f, size_t size); -static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr); +static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr); /*********************/ /* Package Variables */ @@ -101,18 +96,14 @@ H5FL_SEQ_DEFINE(H5HG_obj_t); /* Declare a PQ free list to manage heap chunks */ H5FL_BLK_DEFINE(gheap_chunk); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG__create * @@ -135,41 +126,41 @@ H5FL_BLK_DEFINE(gheap_chunk); static haddr_t H5HG__create(H5F_t *f, size_t size) { - H5HG_heap_t *heap = NULL; - uint8_t *p = NULL; - haddr_t addr = HADDR_UNDEF; - size_t n; - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5HG_heap_t *heap = NULL; + uint8_t * p = NULL; + haddr_t addr = HADDR_UNDEF; + size_t n; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__GLOBALHEAP_TAG) + FUNC_ENTER_STATIC /* Check args */ HDassert(f); - if(size < H5HG_MINSIZE) + if (size < H5HG_MINSIZE) size = H5HG_MINSIZE; size = H5HG_ALIGN(size); /* Create it */ H5_CHECK_OVERFLOW(size, size_t, hsize_t); - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap") - if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) + if (NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") - heap->addr = addr; - heap->size = size; + heap->addr = addr; + heap->size = size; heap->shared = H5F_SHARED(f); - if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, size))) + if (NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") HDmemset(heap->chunk, 0, size); heap->nalloc = H5HG_NOBJS(f, size); - heap->nused = 1; /* account for index 0, which is used for the free object */ - if(NULL == (heap->obj = H5FL_SEQ_MALLOC(H5HG_obj_t, heap->nalloc))) + heap->nused = 1; /* account for index 0, which is used for the free object */ + if (NULL == (heap->obj = H5FL_SEQ_MALLOC(H5HG_obj_t, heap->nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") /* Initialize the header */ H5MM_memcpy(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC); - p = heap->chunk + H5_SIZEOF_MAGIC; + p = heap->chunk + H5_SIZEOF_MAGIC; *p++ = H5HG_VERSION; *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ @@ -183,7 +174,7 @@ H5HG__create(H5F_t *f, size_t size) */ n = (size_t)H5HG_ALIGN(p - heap->chunk) - (size_t)(p - heap->chunk); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ + /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(p, 0, n); #endif /* OLD_WAY */ p += n; @@ -193,45 +184,46 @@ H5HG__create(H5F_t *f, size_t size) HDassert(H5HG_ISALIGNED(heap->obj[0].size)); heap->obj[0].nrefs = 0; heap->obj[0].begin = p; - UINT16ENCODE(p, 0); /*object ID*/ - UINT16ENCODE(p, 0); /*reference count*/ + UINT16ENCODE(p, 0); /*object ID*/ + UINT16ENCODE(p, 0); /*reference count*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ - HDmemset (p, 0, (size_t)((heap->chunk+heap->size) - p)); + /* Don't bother zeroing out the rest of the info in the heap -QAK */ + HDmemset(p, 0, (size_t)((heap->chunk + heap->size) - p)); #endif /* OLD_WAY */ /* Add this heap to the beginning of the CWFS list */ - if(H5F_cwfs_add(f, heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to add global heap collection to file's CWFS") + if (H5F_cwfs_add(f, heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, + "unable to add global heap collection to file's CWFS") /* Add the heap to the cache */ - if(H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection") ret_value = addr; done: /* Cleanup on error */ - if(!H5F_addr_defined(ret_value)) { - if(H5F_addr_defined(addr)) { + if (!H5F_addr_defined(ret_value)) { + if (H5F_addr_defined(addr)) { /* Release the space on disk */ - if(H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0) + if (H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap") /* Check if the heap object was allocated */ - if(heap) + if (heap) /* Destroy the heap object */ - if(H5HG__free(heap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection") + if (H5HG__free(heap) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy global heap collection") } /* end if */ - } /* end if */ + } /* end if */ - FUNC_LEAVE_NOAPI_TAG(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__create() */ - /*------------------------------------------------------------------------- * Function: H5HG__protect * @@ -247,8 +239,8 @@ H5HG__create(H5F_t *f, size_t size) H5HG_heap_t * H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) { - H5HG_heap_t *heap; /* Global heap */ - H5HG_heap_t *ret_value = NULL; /* Return value */ + H5HG_heap_t *heap; /* Global heap */ + H5HG_heap_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -260,7 +252,7 @@ H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Lock the heap into memory */ - if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags))) + if (NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap") /* Set the heap's address */ @@ -273,7 +265,6 @@ H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__protect() */ - /*------------------------------------------------------------------------- * Function: H5HG__alloc * @@ -295,36 +286,36 @@ H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags) static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) { - size_t idx; - uint8_t *p; - size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); - size_t ret_value = 0; /* Return value */ + size_t idx; + uint8_t *p; + size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size); + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(heap); - HDassert(heap->obj[0].size>=need); + HDassert(heap->obj[0].size >= need); HDassert(heap_flags_ptr); /* * Find an ID for the new object. ID zero is reserved for the free space * object. */ - if(heap->nused <= H5HG_MAXIDX) + if (heap->nused <= H5HG_MAXIDX) idx = heap->nused++; else { - for(idx = 1; idx < heap->nused; idx++) - if(NULL == heap->obj[idx].begin) + for (idx = 1; idx < heap->nused; idx++) + if (NULL == heap->obj[idx].begin) break; } /* end else */ HDassert(idx < heap->nused); /* Check if we need more room to store heap objects */ - if(idx >= heap->nalloc) { - size_t new_alloc; /* New allocation number */ - H5HG_obj_t *new_obj; /* New array of object descriptions */ + if (idx >= heap->nalloc) { + size_t new_alloc; /* New allocation number */ + H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ /* nalloc is *not* guaranteed to be a power of 2! - NAF 10/26/09 */ @@ -332,7 +323,7 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) HDassert(idx < new_alloc); /* Reallocate array of objects */ - if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) + if (NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, 0, "memory allocation failed") /* Clear newly allocated space */ @@ -340,29 +331,29 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) /* Update heap information */ heap->nalloc = new_alloc; - heap->obj = new_obj; + heap->obj = new_obj; HDassert(heap->nalloc > heap->nused); } /* end if */ /* Initialize the new object */ heap->obj[idx].nrefs = 0; - heap->obj[idx].size = size; + heap->obj[idx].size = size; heap->obj[idx].begin = heap->obj[0].begin; - p = heap->obj[idx].begin; + p = heap->obj[idx].begin; UINT16ENCODE(p, idx); UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, size); + H5F_ENCODE_LENGTH(f, p, size); /* Fix the free space object */ - if(need == heap->obj[0].size) { + if (need == heap->obj[0].size) { /* * All free space has been exhausted from this collection. */ - heap->obj[0].size = 0; + heap->obj[0].size = 0; heap->obj[0].begin = NULL; } /* end if */ - else if(heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) { + else if (heap->obj[0].size - need >= H5HG_SIZEOF_OBJHDR(f)) { /* * Some free space remains and it's larger than a heap object header, * so write the new free heap object header to the heap. @@ -370,10 +361,10 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) heap->obj[0].size -= need; heap->obj[0].begin += need; p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ + H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); } /* end else-if */ else { @@ -396,7 +387,6 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG__alloc() */ - /*------------------------------------------------------------------------- * Function: H5HG_extend * @@ -417,13 +407,13 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) herr_t 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 */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -432,11 +422,11 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) HDassert(H5F_addr_defined(addr)); /* Protect the heap */ - if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") /* Re-allocate the heap information in memory */ - if(NULL == (new_chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, (heap->size + need)))) + if (NULL == (new_chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, (heap->size + need)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "new heap allocation failed") HDmemset(new_chunk + heap->size, 0, need); @@ -449,8 +439,8 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) H5F_ENCODE_LENGTH(f, p, heap->size); /* Move the pointers to the existing objects to their new locations */ - for(u = 0; u < heap->nused; u++) - if(heap->obj[u].begin) + for (u = 0; u < heap->nused; u++) + if (heap->obj[u].begin) heap->obj[u].begin = new_chunk + (heap->obj[u].begin - heap->chunk); /* Update the heap chunk pointer now */ @@ -458,30 +448,29 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) /* Update the free space information for the heap */ heap->obj[0].size += need; - if(heap->obj[0].begin == NULL) - heap->obj[0].begin = heap->chunk+old_size; + if (heap->obj[0].begin == NULL) + heap->obj[0].begin = heap->chunk + old_size; p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); /* Resize the heap in the cache */ - if(H5AC_resize_entry(heap, heap->size) < 0) + if (H5AC_resize_entry(heap, heap->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize global heap in cache") /* Mark the heap as dirty */ heap_flags |= H5AC__DIRTIED_FLAG; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG_extend() */ - /*------------------------------------------------------------------------- * Function: H5HG_insert * @@ -505,14 +494,14 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) *------------------------------------------------------------------------- */ herr_t -H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) +H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/) { - size_t need; /*total space needed for object */ - size_t idx; - haddr_t addr; /* Address of heap to add object within */ - H5HG_heap_t *heap = NULL; - unsigned heap_flags = H5AC__NO_FLAGS_SET; - herr_t ret_value = SUCCEED; /* Return value */ + size_t need; /*total space needed for object */ + size_t idx; + haddr_t addr; /* Address of heap to add object within */ + H5HG_heap_t *heap = NULL; + unsigned heap_flags = H5AC__NO_FLAGS_SET; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) @@ -521,7 +510,7 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) HDassert(0 == size || obj); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Find a large enough collection on the CWFS list */ @@ -529,51 +518,50 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) /* Look for a heap in the file's CWFS that has enough space for the object */ addr = HADDR_UNDEF; - if(H5F_cwfs_find_free_heap(f, need, &addr) < 0) + if (H5F_cwfs_find_free_heap(f, need, &addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "error trying to locate heap") /* * If we didn't find any collection with enough free space then allocate a * new collection large enough for the message plus the collection header. */ - if(!H5F_addr_defined(addr)) { + if (!H5F_addr_defined(addr)) { addr = H5HG__create(f, need + H5HG_SIZEOF_HDR(f)); - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection") + if (!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection") } /* end if */ HDassert(H5F_addr_defined(addr)); - if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") /* Split the free space to make room for the new object */ - if(0 == (idx = H5HG__alloc(f, heap, size, &heap_flags))) + if (0 == (idx = H5HG__alloc(f, heap, size, &heap_flags))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate global heap object") /* Copy data into the heap */ - if(size > 0) { + if (size > 0) { H5MM_memcpy(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f), obj, size); #ifdef OLD_WAY -/* Don't bother zeroing out the rest of the info in the heap -QAK */ + /* Don't bother zeroing out the rest of the info in the heap -QAK */ HDmemset(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f) + size, 0, need - (H5HG_SIZEOF_OBJHDR(f) + size)); #endif /* OLD_WAY */ - } /* end if */ + } /* end if */ heap_flags |= H5AC__DIRTIED_FLAG; /* Return value */ hobj->addr = heap->addr; - hobj->idx = idx; + hobj->idx = idx; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5HG_insert() */ - /*------------------------------------------------------------------------- * Function: H5HG_read * @@ -592,13 +580,13 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj/*out*/) *------------------------------------------------------------------------- */ void * -H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) +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 */ + 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 */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, NULL) @@ -607,16 +595,16 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) HDassert(hobj); /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); HDassert(heap->obj[hobj->idx].begin); size = heap->obj[hobj->idx].size; - p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f); + p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f); /* Allocate a buffer for the object read in, if the user didn't give one */ - if(!object && NULL == (object = H5MM_malloc(size))) + if (!object && NULL == (object = H5MM_malloc(size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(object, p, size); @@ -624,29 +612,28 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) * Advance the heap in the CWFS list. We might have done this already * with the H5AC_protect(), but it won't hurt to do it twice. */ - if(heap->obj[0].begin) { - if(H5F_cwfs_advance_heap(f, heap, FALSE) < 0) + if (heap->obj[0].begin) { + if (H5F_cwfs_advance_heap(f, heap, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, NULL, "can't adjust file's CWFS") } /* end if */ /* If the caller would like to know the heap object's size, set that */ - if(buf_size) + if (buf_size) *buf_size = size; /* Set return value */ ret_value = object; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header") - if(NULL == ret_value && NULL == orig_object && object) + if (NULL == ret_value && NULL == orig_object && object) H5MM_free(object); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_read() */ - /*------------------------------------------------------------------------- * Function: H5HG_link * @@ -668,28 +655,28 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) { - H5HG_heap_t *heap = NULL; - unsigned heap_flags = H5AC__NO_FLAGS_SET; - int ret_value = -1; /* Return value */ + H5HG_heap_t *heap = NULL; + unsigned heap_flags = H5AC__NO_FLAGS_SET; + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) /* Check args */ HDassert(f); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") - if(adjust != 0) { + if (adjust != 0) { HDassert(hobj->idx < heap->nused); HDassert(heap->obj[hobj->idx].begin); - if((heap->obj[hobj->idx].nrefs + adjust) < 0) + if ((heap->obj[hobj->idx].nrefs + adjust) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range") - if((heap->obj[hobj->idx].nrefs + adjust) > H5HG_MAXLINK) + if ((heap->obj[hobj->idx].nrefs + adjust) > H5HG_MAXLINK) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range") heap->obj[hobj->idx].nrefs += adjust; heap_flags |= H5AC__DIRTIED_FLAG; @@ -699,13 +686,12 @@ H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) ret_value = heap->obj[hobj->idx].nrefs; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_link() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_obj_size * @@ -722,8 +708,8 @@ H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) herr_t H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) { - H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) @@ -733,7 +719,7 @@ H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) HDassert(obj_size); /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); @@ -743,13 +729,12 @@ H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) *obj_size = heap->obj[hobj->idx].size; done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_get_obj_size() */ - /*------------------------------------------------------------------------- * Function: H5HG_remove * @@ -766,22 +751,22 @@ herr_t H5HG_remove(H5F_t *f, H5HG_t *hobj) { H5HG_heap_t *heap = NULL; - uint8_t *p = NULL, *obj_start = NULL; - size_t need; - unsigned u; - unsigned flags = H5AC__NO_FLAGS_SET;/* Whether the heap gets deleted */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * p = NULL, *obj_start = NULL; + size_t need; + unsigned u; + unsigned flags = H5AC__NO_FLAGS_SET; /* Whether the heap gets deleted */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL) /* Check args */ HDassert(f); HDassert(hobj); - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") /* Load the heap */ - if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); @@ -790,7 +775,7 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) * it can happen that the entry has been removed by first rewrite. Here we simply skip the removal of * the entry and let the second rewrite happen (see HDFFV-10635). In the future, it'd be nice to handle * this situation in H5T_conv_vlen in H5Tconv.c instead of this level (HDFFV-10648). */ - if(heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) + if (heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) HGOTO_DONE(ret_value) obj_start = heap->obj[hobj->idx].begin; @@ -798,53 +783,53 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) need = H5HG_ALIGN(heap->obj[hobj->idx].size) + H5HG_SIZEOF_OBJHDR(f); /* Move the new free space to the end of the heap */ - for(u = 0; u < heap->nused; u++) - if(heap->obj[u].begin > heap->obj[hobj->idx].begin) + for (u = 0; u < heap->nused; u++) + if (heap->obj[u].begin > heap->obj[hobj->idx].begin) heap->obj[u].begin -= need; - if(NULL == heap->obj[0].begin) { + if (NULL == heap->obj[0].begin) { heap->obj[0].begin = heap->chunk + (heap->size - need); - heap->obj[0].size = need; + heap->obj[0].size = need; heap->obj[0].nrefs = 0; } /* end if */ else heap->obj[0].size += need; - HDmemmove(obj_start, obj_start + need, - heap->size - (size_t)((obj_start + need) - heap->chunk)); - if(heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) { + HDmemmove(obj_start, obj_start + need, heap->size - (size_t)((obj_start + need) - heap->chunk)); + if (heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) { p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ UINT16ENCODE(p, 0); /*nrefs*/ UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, heap->obj[0].size); + H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); } /* end if */ HDmemset(heap->obj + hobj->idx, 0, sizeof(H5HG_obj_t)); flags |= H5AC__DIRTIED_FLAG; - if((heap->obj[0].size + H5HG_SIZEOF_HDR(f)) == heap->size) { + if ((heap->obj[0].size + H5HG_SIZEOF_HDR(f)) == heap->size) { /* * The collection is empty. Remove it from the CWFS list and return it * to the file free list. */ - flags |= H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Indicate that the object was deleted, for the unprotect call */ - } /* end if */ + flags |= + H5AC__DELETED_FLAG | + H5AC__FREE_FILE_SPACE_FLAG; /* Indicate that the object was deleted, for the unprotect call */ + } /* end if */ else { /* * If the heap is in the CWFS list then advance it one position. The * H5AC_protect() might have done that too, but that's okay. If the * heap isn't on the CWFS list then add it to the end. */ - if(H5F_cwfs_advance_heap(f, heap, TRUE) < 0) + if (H5F_cwfs_advance_heap(f, heap, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't adjust file's CWFS") } /* end else */ done: - if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0) + if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value); } /* end H5HG_remove() */ - /*------------------------------------------------------------------------- * Function: H5HG__free * @@ -860,7 +845,7 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) herr_t H5HG__free(H5HG_heap_t *heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -868,16 +853,15 @@ H5HG__free(H5HG_heap_t *heap) HDassert(heap); /* Remove the heap from the CWFS list */ - if(H5F_cwfs_remove_heap(heap->shared, heap) < 0) + if (H5F_cwfs_remove_heap(heap->shared, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove heap from file's CWFS") - if(heap->chunk) + if (heap->chunk) heap->chunk = H5FL_BLK_FREE(gheap_chunk, heap->chunk); - if(heap->obj) + if (heap->obj) heap->obj = H5FL_SEQ_FREE(H5HG_obj_t, heap->obj); heap = H5FL_FREE(H5HG_heap_t, heap); done: FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__free() */ - diff --git a/src/H5HGcache.c b/src/H5HGcache.c index f85df336a24..379e6f66c16 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,54 +26,45 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache callbacks */ 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 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 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_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HG__cache_heap_free_icr(void *thing); /* Prefix deserialization */ -static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, - const H5F_t *f); - +static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f); /*********************/ /* Package Variables */ @@ -81,34 +72,30 @@ static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, /* H5HG inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_GHEAP[1] = {{ - H5AC_GHEAP_ID, /* Metadata client ID */ - "global heap", /* Metadata client name (for debugging) */ - H5FD_MEM_GHEAP, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5HG__cache_heap_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HG__cache_heap_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HG__cache_heap_deserialize, /* 'deserialize' callback */ - H5HG__cache_heap_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HG__cache_heap_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HG__cache_heap_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_GHEAP_ID, /* Metadata client ID */ + "global heap", /* Metadata client name (for debugging) */ + H5FD_MEM_GHEAP, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5HG__cache_heap_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5HG__cache_heap_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HG__cache_heap_deserialize, /* 'deserialize' callback */ + H5HG__cache_heap_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HG__cache_heap_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HG__cache_heap_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG__hdr_deserialize() * @@ -125,7 +112,7 @@ const H5AC_class_t H5AC_GHEAP[1] = {{ static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -135,12 +122,12 @@ H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) HDassert(f); /* Magic number */ - if(HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad global heap collection signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(H5HG_VERSION != *image++) + if (H5HG_VERSION != *image++) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in global heap") /* Reserved */ @@ -154,7 +141,6 @@ H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_get_initial_load_size() * @@ -186,7 +172,6 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_get_initial_load_size() * @@ -202,11 +187,11 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *udata, size_t *actual_len) +H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *udata, + size_t *actual_len) { - H5HG_heap_t heap; /* Global heap */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t heap; /* Global heap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -218,7 +203,7 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UN HDassert(image_len == H5HG_MINSIZE); /* Deserialize the heap's header */ - if(H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0) + if (H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode global heap prefix") /* Set the final size for the cache image */ @@ -228,7 +213,6 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UN FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_deserialize * @@ -245,15 +229,14 @@ 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) +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 */ - H5HG_heap_t *heap = NULL; /* New global heap */ - 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 */ + 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 */ + size_t max_idx = 0; /* Maximum heap object index seen */ + size_t nalloc; /* Number of objects allocated */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -264,59 +247,59 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, HDassert(dirty); /* Allocate a new global heap */ - if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) + if (NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->shared = H5F_SHARED(f); - if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, len))) + if (NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the image buffer into the newly allocate chunk */ H5MM_memcpy(heap->chunk, _image, len); /* Deserialize the heap's header */ - if(H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0) + if (H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode global heap header") /* Decode each object */ - image = heap->chunk + H5HG_SIZEOF_HDR(f); + image = heap->chunk + H5HG_SIZEOF_HDR(f); nalloc = H5HG_NOBJS(f, heap->size); /* Calloc the obj array because the file format spec makes no guarantee * about the order of the objects, and unused slots must be set to zero. */ - if(NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) + if (NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->nalloc = nalloc; - while(image < (heap->chunk + heap->size)) { - if((image + H5HG_SIZEOF_OBJHDR(f)) > (heap->chunk + heap->size)) { + while (image < (heap->chunk + heap->size)) { + if ((image + H5HG_SIZEOF_OBJHDR(f)) > (heap->chunk + heap->size)) { /* * The last bit of space is too tiny for an object header, so * we assume that it's free space. */ HDassert(NULL == heap->obj[0].begin); - heap->obj[0].size = (size_t)(((const uint8_t *)heap->chunk + heap->size) - image); + heap->obj[0].size = (size_t)(((const uint8_t *)heap->chunk + heap->size) - image); heap->obj[0].begin = image; image += heap->obj[0].size; } /* end if */ else { - size_t need = 0; + size_t need = 0; unsigned idx; uint8_t *begin = image; UINT16DECODE(image, idx); /* Check if we need more room to store heap objects */ - if(idx >= heap->nalloc) { - size_t new_alloc; /* New allocation number */ - H5HG_obj_t *new_obj; /* New array of object descriptions */ + if (idx >= heap->nalloc) { + size_t new_alloc; /* New allocation number */ + H5HG_obj_t *new_obj; /* New array of object descriptions */ /* Determine the new number of objects to index */ new_alloc = MAX(heap->nalloc * 2, (idx + 1)); HDassert(idx < new_alloc); /* Reallocate array of objects */ - if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) + if (NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear newly allocated space */ @@ -324,7 +307,7 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, /* Update heap information */ heap->nalloc = new_alloc; - heap->obj = new_obj; + heap->obj = new_obj; HDassert(heap->nalloc > heap->nused); } /* end if */ @@ -341,9 +324,9 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, * is the free space object whose size is never padded and * already includes the object header. */ - if(idx > 0) { + if (idx > 0) { need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size); - if(idx > max_idx) + if (idx > max_idx) max_idx = idx; } /* end if */ else @@ -351,14 +334,14 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, image = begin + need; } /* end else */ - } /* end while */ + } /* end while */ /* Sanity checks */ HDassert(image == heap->chunk + heap->size); HDassert(H5HG_ISALIGNED(heap->obj[0].size)); /* Set the next index value to use */ - if(max_idx > 0) + if (max_idx > 0) heap->nused = max_idx + 1; else heap->nused = 1; @@ -367,20 +350,19 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, HDassert(max_idx < heap->nused); /* Add the new heap to the CWFS list for the file */ - if(H5F_cwfs_add(f, heap) < 0) + if (H5F_cwfs_add(f, heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "unable to add global heap collection to file's CWFS") ret_value = heap; done: - if(!ret_value && heap) - if(H5HG__free(heap) < 0) + if (!ret_value && heap) + if (H5HG__free(heap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_image_len * @@ -414,7 +396,6 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_serialize * @@ -432,8 +413,7 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t len, - void *_thing) +H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t len, void *_thing) { H5HG_heap_t *heap = (H5HG_heap_t *)_thing; @@ -453,7 +433,6 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HG__cache_heap_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HG__cache_heap_free_icr * @@ -474,8 +453,8 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si static herr_t H5HG__cache_heap_free_icr(void *_thing) { - H5HG_heap_t *heap = (H5HG_heap_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_heap_t *heap = (H5HG_heap_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -485,10 +464,9 @@ H5HG__cache_heap_free_icr(void *_thing) HDassert(heap->cache_info.type == H5AC_GHEAP); /* Destroy global heap collection */ - if(H5HG__free(heap) < 0) + if (H5HG__free(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap collection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_free_icr() */ - diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index a0697aa6f89..51a74ec4b04 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,54 +21,45 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGpkg.h" /* Global heaps */ -#include "H5Iprivate.h" /* ID Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGpkg.h" /* Global heaps */ +#include "H5Iprivate.h" /* ID Functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG_debug * @@ -84,87 +75,76 @@ herr_t 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; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u, nused, maxobj; + unsigned j, k; + H5HG_heap_t *h = NULL; + uint8_t * p = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); - HDassert(H5F_addr_defined (addr)); + HDassert(H5F_addr_defined(addr)); HDassert(stream); HDassert(indent >= 0); HDassert(fwidth >= 0); - if(NULL == (h = H5HG__protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (h = H5HG__protect(f, addr, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap collection"); HDfprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Dirty:", - (int)(h->cache_info.is_dirty)); + HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Dirty:", (int)(h->cache_info.is_dirty)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Total collection size in file:", - (unsigned long)(h->size)); + "Total collection size in file:", (unsigned long)(h->size)); - for(u = 1, nused = 0, maxobj = 0; u < h->nused; u++) - if(h->obj[u].begin) { - nused++; - if (u>maxobj) + for (u = 1, nused = 0, maxobj = 0; u < h->nused; u++) + if (h->obj[u].begin) { + nused++; + if (u > maxobj) maxobj = u; - } - HDfprintf(stream, "%*s%-*s %u/%lu/", indent, "", fwidth, - "Objects defined/allocated/max:", - nused, - (unsigned long)h->nalloc); - if(nused) + } + HDfprintf(stream, "%*s%-*s %u/%lu/", indent, "", fwidth, "Objects defined/allocated/max:", nused, + (unsigned long)h->nalloc); + if (nused) HDfprintf(stream, "%u\n", maxobj); else HDfprintf(stream, "NA\n"); - HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Free space:", - (unsigned long)(h->obj[0].size)); + HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Free space:", (unsigned long)(h->obj[0].size)); - for(u = 1; u < h->nused; u++) - if(h->obj[u].begin) { + for (u = 1; u < h->nused; u++) + if (h->obj[u].begin) { char buf[64]; - HDsnprintf(buf, sizeof(buf), "Object %u", u); - HDfprintf(stream, "%*s%s\n", indent, "", buf); - HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MIN(fwidth - 3, 0), - "Obffset in block:", - (unsigned long)(h->obj[u].begin - h->chunk)); - HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MIN(fwidth - 3, 0), - "Reference count:", - h->obj[u].nrefs); - HDfprintf(stream, "%*s%-*s %lu/%lu\n", indent + 3, "", - MIN(fwidth - 3, 0), - "Size of object body:", - (unsigned long)(h->obj[u].size), - (unsigned long)H5HG_ALIGN(h->obj[u].size)); - p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR(f); - for(j = 0; j < h->obj[u].size; j += 16) { - HDfprintf(stream, "%*s%04u: ", indent + 6, "", j); - for(k = 0; k < 16; k++) { - if(8 == k) + HDsnprintf(buf, sizeof(buf), "Object %u", u); + HDfprintf(stream, "%*s%s\n", indent, "", buf); + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MIN(fwidth - 3, 0), + "Obffset in block:", (unsigned long)(h->obj[u].begin - h->chunk)); + HDfprintf(stream, "%*s%-*s %d\n", indent + 3, "", MIN(fwidth - 3, 0), + "Reference count:", h->obj[u].nrefs); + HDfprintf(stream, "%*s%-*s %lu/%lu\n", indent + 3, "", MIN(fwidth - 3, 0), + "Size of object body:", (unsigned long)(h->obj[u].size), + (unsigned long)H5HG_ALIGN(h->obj[u].size)); + p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR(f); + for (j = 0; j < h->obj[u].size; j += 16) { + HDfprintf(stream, "%*s%04u: ", indent + 6, "", j); + for (k = 0; k < 16; k++) { + if (8 == k) HDfprintf(stream, " "); - if(j + k < h->obj[u].size) - HDfprintf(stream, "%02x ", p[j + k]); - else - HDfputs(" ", stream); - } - for(k = 0; k < 16 && j + k < h->obj[u].size; k++) { - if(8 == k) + if (j + k < h->obj[u].size) + HDfprintf(stream, "%02x ", p[j + k]); + else + HDfputs(" ", stream); + } + for (k = 0; k < 16 && j + k < h->obj[u].size; k++) { + if (8 == k) HDfprintf(stream, " "); - HDfputc(p[j + k]>' ' && p[j + k] <= '~' ? p[j + k] : '.', stream); - } - HDfprintf(stream, "\n"); - } - } + HDfputc(p[j + k] > ' ' && p[j + k] <= '~' ? p[j + k] : '.', stream); + } + HDfprintf(stream, "\n"); + } + } done: if (h && H5AC_unprotect(f, H5AC_GHEAP, addr, h, H5AC__NO_FLAGS_SET) < 0) @@ -172,4 +152,3 @@ H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG_debug() */ - diff --git a/src/H5HGmodule.h b/src/H5HGmodule.h index e6613282662..a75dea5a411 100644 --- a/src/H5HGmodule.h +++ b/src/H5HGmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5HG package. Including this header means that the source file * is part of the H5HG package. */ -#ifndef _H5HGmodule_H -#define _H5HGmodule_H +#ifndef H5HGmodule_H +#define H5HGmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5HG_MODULE -#define H5_MY_PKG H5HG -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO - -#endif /* _H5HGmodule_H */ +#define H5_MY_PKG H5HG +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO +#endif /* H5HGmodule_H */ diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 735b4fb05e2..5c0fbe8686b 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,16 +23,15 @@ #error "Do not include this file outside the H5HG package!" #endif -#ifndef _H5HGpkg_H -#define _H5HGpkg_H +#ifndef H5HGpkg_H +#define H5HGpkg_H /* Get package's private header */ #include "H5HGprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free lists */ /*****************************/ /* Package Private Variables */ @@ -47,7 +46,6 @@ H5FL_SEQ_EXTERN(H5HG_obj_t); /* Declare extern the PQ free list to manage heap chunks */ H5FL_BLK_EXTERN(gheap_chunk); - /**************************/ /* Package Private Macros */ /**************************/ @@ -55,7 +53,7 @@ H5FL_BLK_EXTERN(gheap_chunk); /* * Global heap collection version. */ -#define H5HG_VERSION 1 +#define H5HG_VERSION 1 /* * All global heap collections are at least this big. This allows us to read @@ -63,7 +61,7 @@ H5FL_BLK_EXTERN(gheap_chunk); * bytes of header to figure out the size. If the heap is larger than this * then a second read gets the rest after we've decoded the header. */ -#define H5HG_MINSIZE 4096 +#define H5HG_MINSIZE 4096 /* * Pad all global heap messages to a multiple of eight bytes so we can load @@ -71,29 +69,29 @@ H5FL_BLK_EXTERN(gheap_chunk); * be sufficient for machines that have alignment constraints because our * largest data type is eight bytes. */ -#define H5HG_ALIGNMENT 8 -#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/H5HG_ALIGNMENT)) -#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X)) +#define H5HG_ALIGNMENT 8 +#define H5HG_ALIGN(X) (H5HG_ALIGNMENT * (((X) + H5HG_ALIGNMENT - 1) / H5HG_ALIGNMENT)) +#define H5HG_ISALIGNED(X) ((X) == H5HG_ALIGN(X)) /* * The size of the collection header, always a multiple of the alignment so * that the stuff that follows the header is aligned. */ -#define H5HG_SIZEOF_HDR(f) \ - (size_t)H5HG_ALIGN(4 + /*magic number */ \ - 1 + /*version number */ \ - 3 + /*reserved */ \ - H5F_SIZEOF_SIZE(f)) /*collection size */ +#define H5HG_SIZEOF_HDR(f) \ + (size_t) H5HG_ALIGN(4 + /*magic number */ \ + 1 + /*version number */ \ + 3 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*collection size */ /* * The overhead associated with each object in the heap, always a multiple of * the alignment so that the stuff that follows the header is aligned. */ -#define H5HG_SIZEOF_OBJHDR(f) \ - (size_t)H5HG_ALIGN(2 + /*object id number */ \ - 2 + /*reference count */ \ - 4 + /*reserved */ \ - H5F_SIZEOF_SIZE(f)) /*object data size */ +#define H5HG_SIZEOF_OBJHDR(f) \ + (size_t) H5HG_ALIGN(2 + /*object id number */ \ + 2 + /*reference count */ \ + 4 + /*reserved */ \ + H5F_SIZEOF_SIZE(f)) /*object data size */ /* * The initial guess for the number of messages in a collection. We assume @@ -102,36 +100,34 @@ H5FL_BLK_EXTERN(gheap_chunk); * some overhead and each message has some overhead. The `+2' accounts for * rounding and for the free space object. */ -#define H5HG_NOBJS(f,z) ((((z)-H5HG_SIZEOF_HDR(f))/ \ - H5HG_SIZEOF_OBJHDR(f)+2)) - +#define H5HG_NOBJS(f, z) ((((z)-H5HG_SIZEOF_HDR(f)) / H5HG_SIZEOF_OBJHDR(f) + 2)) /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HG_obj_t { - int nrefs; /* reference count */ - size_t size; /* total size of object */ - uint8_t *begin; /* ptr to object into heap->chunk */ + int nrefs; /* reference count */ + size_t size; /* total size of object */ + uint8_t *begin; /* ptr to object into heap->chunk */ } H5HG_obj_t; /* Forward declarations for fields */ struct H5F_shared_t; struct H5HG_heap_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - haddr_t addr; /*collection address */ - size_t size; /*total size of collection */ - uint8_t *chunk; /*the collection, incl. header */ - size_t nalloc; /*numb object slots allocated */ - size_t nused; /*number of slots used */ - /* If this value is >65535 then all indices */ - /* 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 */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + haddr_t addr; /*collection address */ + size_t size; /*total size of collection */ + uint8_t *chunk; /*the collection, incl. header */ + size_t nalloc; /*numb object slots allocated */ + size_t nused; /*number of slots used */ + /* If this value is >65535 then all indices */ + /* 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 */ }; /******************************/ @@ -140,5 +136,4 @@ struct H5HG_heap_t { 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 */ - +#endif /* H5HGpkg_H */ diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index e7c1149016f..d8e6b4665eb 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,45 +15,47 @@ * Programmer: Robb Matzke * Friday, March 27, 1998 */ -#ifndef _H5HGprivate_H -#define _H5HGprivate_H +#ifndef H5HGprivate_H +#define H5HGprivate_H /* Private headers needed by this file. */ -#include "H5Fprivate.h" /* File access */ +#include "H5Fprivate.h" /* File access */ /* Information to locate object in global heap */ typedef struct H5HG_t { - haddr_t addr; /*address of collection */ - size_t idx; /*object ID within collection */ + haddr_t addr; /*address of collection */ + size_t idx; /*object ID within collection */ } H5HG_t; /* Typedef for heap in memory (defined in H5HGpkg.h) */ typedef struct H5HG_heap_t H5HG_heap_t; - /* * Limit global heap collections to the some reasonable size. This is * fairly arbitrary, but needs to be small enough that no more than H5HG_MAXIDX * objects will be allocated from a single heap. */ -#define H5HG_MAXSIZE 65536 +#define H5HG_MAXSIZE 65536 /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5HG_MODULE -#define H5HG_ADDR(H) ((H)->addr) -#define H5HG_SIZE(H) ((H)->size) -#define H5HG_FREE_SIZE(H) ((H)->obj[0].size) +#define H5HG_ADDR(H) ((H)->addr) +#define H5HG_SIZE(H) ((H)->size) +#define H5HG_FREE_SIZE(H) ((H)->obj[0].size) #else /* H5HG_MODULE */ -#define H5HG_ADDR(H) (H5HG_get_addr(H)) -#define H5HG_SIZE(H) (H5HG_get_size(H)) -#define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H)) +#define H5HG_ADDR(H) (H5HG_get_addr(H)) +#define H5HG_SIZE(H) (H5HG_get_size(H)) +#define H5HG_FREE_SIZE(H) (H5HG_get_free_size(H)) #endif /* H5HG_MODULE */ +/* 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) /* 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 int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust); +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 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); @@ -62,12 +64,10 @@ H5_DLL herr_t H5HG_extend(H5F_t *f, haddr_t addr, size_t need); /* Query routines */ H5_DLL haddr_t H5HG_get_addr(const H5HG_heap_t *h); -H5_DLL size_t H5HG_get_size(const H5HG_heap_t *h); -H5_DLL size_t H5HG_get_free_size(const H5HG_heap_t *h); +H5_DLL size_t H5HG_get_size(const H5HG_heap_t *h); +H5_DLL size_t H5HG_get_free_size(const H5HG_heap_t *h); /* Debugging functions */ -H5_DLL herr_t H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); - -#endif /* _H5HGprivate_H */ +H5_DLL herr_t H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); +#endif /* H5HGprivate_H */ diff --git a/src/H5HGquery.c b/src/H5HGquery.c index 005235c025f..c24a414c43a 100644 --- a/src/H5HGquery.c +++ b/src/H5HGquery.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,53 +23,43 @@ /* Module Setup */ /****************/ -#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ - +#include "H5HGmodule.h" /* This source code file is part of the H5HG module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGpkg.h" /* Global heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGpkg.h" /* Global heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HG_get_addr * @@ -93,7 +83,6 @@ H5HG_get_addr(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->addr) } /* H5HG_get_addr() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_size * @@ -117,7 +106,6 @@ H5HG_get_size(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->size) } /* H5HG_get_size() */ - /*------------------------------------------------------------------------- * Function: H5HG_get_free_size * @@ -140,4 +128,3 @@ H5HG_get_free_size(const H5HG_heap_t *heap) FUNC_LEAVE_NOAPI(heap->obj[0].size) } /* H5HG_get_free_size() */ - diff --git a/src/H5HL.c b/src/H5HL.c index f628e93a981..ca8344526e4 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,44 +27,38 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ -#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */ - +#define H5HL_MIN_HEAP 128 /* Minimum size to reduce heap buffer to */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static H5HL_free_t *H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl); -static herr_t H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap); -static herr_t H5HL__dirty(H5HL_t *heap); - +static herr_t H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap); +static herr_t H5HL__dirty(H5HL_t *heap); /*********************/ /* Package Variables */ @@ -79,18 +73,14 @@ H5FL_DEFINE(H5HL_free_t); /* Declare a PQ free list to manage the heap chunk information */ H5FL_BLK_DEFINE(lheap_chunk); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HL_create * @@ -108,86 +98,83 @@ 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*/)) +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 */ - H5HL_prfx_t *prfx = NULL; /* Heap prefix */ - hsize_t total_size = 0; /* Total heap size on disk */ + H5HL_t * heap = NULL; /* Heap created */ + H5HL_prfx_t *prfx = NULL; /* Heap prefix */ + hsize_t total_size = 0; /* Total heap size on disk */ /* check arguments */ HDassert(f); HDassert(addr_p); /* Adjust size hint as necessary */ - if(size_hint && size_hint < H5HL_SIZEOF_FREE(f)) + if (size_hint && size_hint < H5HL_SIZEOF_FREE(f)) size_hint = H5HL_SIZEOF_FREE(f); size_hint = H5HL_ALIGN(size_hint); /* Allocate new heap structure */ - if(NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) + 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"); /* Allocate file space */ total_size = heap->prfx_size + size_hint; - if(HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) + if (HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory"); /* Initialize info */ heap->single_cache_obj = TRUE; - heap->dblk_addr = heap->prfx_addr + (hsize_t)heap->prfx_size; - heap->dblk_size = size_hint; - if(size_hint) - if(NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) + heap->dblk_addr = heap->prfx_addr + (hsize_t)heap->prfx_size; + 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"); /* free list */ - if(size_hint) { - if(NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) + if (size_hint) { + if (NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); heap->freelist->offset = 0; - heap->freelist->size = size_hint; + heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; - heap->free_block = 0; + heap->free_block = 0; } /* end if */ else { - heap->freelist = NULL; + heap->freelist = NULL; heap->free_block = H5HL_FREE_NULL; } /* end else */ /* Allocate the heap prefix */ - if(NULL == (prfx = H5HL__prfx_new(heap))) + if (NULL == (prfx = H5HL__prfx_new(heap))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Add to cache */ - if(FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + 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"); /* Set address to return */ *addr_p = heap->prfx_addr; -CATCH - if(ret_value < 0) { + CATCH + if (ret_value < 0) { *addr_p = HADDR_UNDEF; - if(prfx) { - if(FAIL == H5HL__prfx_dest(prfx)) + if (prfx) { + if (FAIL == H5HL__prfx_dest(prfx)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix"); } /* end if */ else { - if(heap) { - if(H5F_addr_defined(heap->prfx_addr)) - if(FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) + 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?"); - if(FAIL == H5HL__dest(heap)) + if (FAIL == H5HL__dest(heap)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ END_FUNC(PRIV) /* end H5HL_create() */ - /*------------------------------------------------------------------------- * Function: H5HL__minimize_heap_space * @@ -201,11 +188,9 @@ END_FUNC(PRIV) /* end H5HL_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) - size_t new_heap_size = heap->dblk_size; /* New size of heap */ + size_t new_heap_size = heap->dblk_size; /* New size of heap */ /* check args */ HDassert(f); @@ -216,14 +201,14 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ - if(heap->freelist) { - H5HL_free_t *tmp_fl; - H5HL_free_t *last_fl = NULL; + if (heap->freelist) { + H5HL_free_t *tmp_fl; + H5HL_free_t *last_fl = NULL; /* Search for a free block at the end of the buffer */ - for(tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) + for (tmp_fl = heap->freelist; tmp_fl; tmp_fl = tmp_fl->next) /* Check if the end of this free block is at the end of the buffer */ - if(tmp_fl->offset + tmp_fl->size == heap->dblk_size) { + if (tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; } /* end if */ @@ -232,28 +217,28 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) * Found free block at the end of the buffer, decide what to do * about it */ - if(last_fl) { + if (last_fl) { /* * 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) { + 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 * eliminate the free block */ - while(new_heap_size > H5HL_MIN_HEAP && - new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) + 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 * eliminate the free block */ - if(new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { + if (new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { /* Check if this is the only block on the free list */ - if(last_fl->prev == NULL && last_fl->next == NULL) { + if (last_fl->prev == NULL && last_fl->next == NULL) { /* Double the new memory size */ new_heap_size *= 2; @@ -272,7 +257,7 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) /* Eliminate the free block from the list */ last_fl = H5HL__remove_free(heap, last_fl); } /* end else */ - } /* end if */ + } /* end if */ else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); @@ -280,33 +265,32 @@ H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) 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 */ + } /* end if */ + } /* end if */ + } /* end if */ /* * If the heap grew smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ - if(new_heap_size != heap->dblk_size) { + if (new_heap_size != heap->dblk_size) { HDassert(new_heap_size < heap->dblk_size); /* Resize the memory buffer */ - if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Reallocate data block in file */ - if(FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) + if (FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); } /* end if */ -CATCH + CATCH /* No special processing on errors */ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ - /*------------------------------------------------------------------------- * Function: H5HL_protect * @@ -320,16 +304,14 @@ 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)) +BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, 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 */ - 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_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 */ + 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 */ /* check arguments */ HDassert(f); @@ -341,11 +323,11 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) + 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"); /* Get the pointer to the heap */ @@ -353,20 +335,21 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Check if the heap is already pinned in memory */ /* (for re-entrant situation) */ - if(heap->prots == 0) { + if (heap->prots == 0) { /* Check if heap has separate data block */ - if(heap->single_cache_obj) + if (heap->single_cache_obj) /* Set the flag for pinning the prefix when unprotecting it */ prfx_cache_flags |= H5AC__PIN_ENTRY_FLAG; else { /* Protect the local heap data block */ - if(NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) + 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"); /* Set the flag for pinning the data block when unprotecting it */ dblk_cache_flags |= H5AC__PIN_ENTRY_FLAG; } /* end if */ - } /* end if */ + } /* end if */ /* Increment # of times heap is protected */ heap->prots++; @@ -374,18 +357,17 @@ H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) /* Set return value */ ret_value = heap; -CATCH + CATCH /* 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) + 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"); /* 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) + 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"); END_FUNC(PRIV) /* end H5HL_protect() */ - /*------------------------------------------------------------------------- * Function: H5HL_offset_into * @@ -400,21 +382,19 @@ END_FUNC(PRIV) /* end H5HL_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -void *, NULL, NULL, -H5HL_offset_into(const H5HL_t *heap, size_t offset)) +BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, size_t offset)) /* Sanity check */ HDassert(heap); - if(offset >= heap->dblk_size) - H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); + if (offset >= heap->dblk_size) + H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); ret_value = heap->dblk_image + offset; -CATCH - /* No special processing on errors */ + CATCH +/* No special processing on errors */ END_FUNC(PRIV) /* end H5HL_offset_into() */ - + /*------------------------------------------------------------------------- * Function: H5HL_unprotect * @@ -427,9 +407,7 @@ END_FUNC(PRIV) /* end H5HL_offset_into() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_unprotect(H5HL_t *heap)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -438,11 +416,11 @@ H5HL_unprotect(H5HL_t *heap)) heap->prots--; /* Check for last unprotection of heap */ - if(heap->prots == 0) { + if (heap->prots == 0) { /* Check for separate heap data block */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Mark local heap prefix as evictable again */ - if(FAIL == H5AC_unpin_entry(heap->prfx)) + if (FAIL == H5AC_unpin_entry(heap->prfx)) H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); } /* end if */ else { @@ -451,17 +429,16 @@ 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)) + if (FAIL == H5AC_unpin_entry(heap->dblk)) H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); } /* end else */ - } /* end if */ + } /* end if */ -CATCH + CATCH /* No special processing on errors */ END_FUNC(PRIV) /* end H5HL_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5HL__remove_free * @@ -475,16 +452,14 @@ END_FUNC(PRIV) /* end H5HL_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -H5HL_free_t *, NULL, -, -H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) +BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) - if(fl->prev) + if (fl->prev) fl->prev->next = fl->next; - if(fl->next) + if (fl->next) fl->next->prev = fl->prev; - if(!fl->prev) + if (!fl->prev) heap->freelist = fl->next; /* H5FL_FREE always returns NULL so we can't check for errors */ @@ -492,7 +467,6 @@ H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) END_FUNC(STATIC) /* end H5HL__remove_free() */ - /*------------------------------------------------------------------------- * Function: H5HL__dirty * @@ -505,60 +479,60 @@ END_FUNC(STATIC) /* end H5HL__remove_free() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dirty(H5HL_t *heap)) +BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) /* check arguments */ HDassert(heap); HDassert(heap->prfx); /* Mark heap data block as dirty, if there is one */ - if(!heap->single_cache_obj) { + if (!heap->single_cache_obj) { /* Sanity check */ HDassert(heap->dblk); - if(FAIL == H5AC_mark_entry_dirty(heap->dblk)) + if (FAIL == H5AC_mark_entry_dirty(heap->dblk)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty"); } /* end if */ /* Mark heap prefix as dirty */ - if(FAIL == H5AC_mark_entry_dirty(heap->prfx)) + if (FAIL == H5AC_mark_entry_dirty(heap->prfx)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty"); -CATCH + CATCH /* No special processing on errors */ END_FUNC(STATIC) /* end H5HL__dirty() */ - /*------------------------------------------------------------------------- * Function: H5HL_insert * * Purpose: Inserts a new item into the heap. * - * Return: Success: Offset of new item within heap. - * Failure: UFAIL + * Return: Success: SUCCEED + * Offset set to location of new item within heap + * + * Failure: FAIL + * Offset set to SIZE_MAX * * Programmer: Robb Matzke * Jul 17 1997 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -size_t, UFAIL, UFAIL, -H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) +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)) - H5HL_free_t *fl = NULL, *last_fl = NULL; - size_t offset = 0; - size_t need_size; - hbool_t found; + H5HL_free_t *fl = NULL, *last_fl = NULL; + size_t need_size; + size_t offset = 0; + hbool_t found; - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(heap); HDassert(buf_size > 0); HDassert(buf); + HDassert(offset_out); /* Mark heap as dirty in cache */ /* (A bit early in the process, but it's difficult to determine in the @@ -566,23 +540,21 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(FAIL == H5HL__dirty(heap)) + if (FAIL == H5HL__dirty(heap)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); - /* - * In order to keep the free list descriptors aligned on word boundaries, + /* 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 * a word. */ need_size = H5HL_ALIGN(buf_size); - /* - * Look for a free slot large enough for this object and which would + /* Look for a free slot large enough for this object and which would * leave zero or at least H5G_SIZEOF_FREE bytes left over. */ - for(fl = heap->freelist, found = FALSE; fl; fl = fl->next) { - if(fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { - /* a big enough free block was found */ + for (fl = heap->freelist, found = FALSE; fl; fl = fl->next) { + if (fl->size > need_size && fl->size - need_size >= H5HL_SIZEOF_FREE(f)) { + /* A big enough free block was found */ offset = fl->offset; fl->offset += need_size; fl->size -= need_size; @@ -590,32 +562,34 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) HDassert(fl->size == H5HL_ALIGN(fl->size)); found = TRUE; break; - } else if(fl->size == need_size) { - /* free block of exact size found */ + } + else if (fl->size == need_size) { + /* Free block of exact size found */ offset = fl->offset; - fl = H5HL__remove_free(heap, fl); - found = TRUE; + fl = H5HL__remove_free(heap, fl); + found = TRUE; break; - } else if(!last_fl || last_fl->offset < fl->offset) { - /* track free space that's closest to end of heap */ + } + else if (!last_fl || last_fl->offset < fl->offset) { + /* 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 + /* 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 * can extend that free chunk. Otherwise we'll have to make another * free chunk. If the heap must expand, we double its size. */ - if(found == FALSE) { - size_t need_more; /* How much more space we need */ - size_t new_dblk_size; /* Final size of space allocated for heap data block */ - size_t old_dblk_size; /* Previous size of space allocated for heap data block */ - htri_t was_extended; /* Whether the local heap's data segment on disk was extended */ + if (found == FALSE) { + size_t need_more; /* How much more space we need */ + size_t new_dblk_size; /* Final size of space allocated for heap data block */ + size_t old_dblk_size; /* Previous size of space allocated for heap data block */ + htri_t was_extended; /* Whether the local heap's data segment on disk was extended */ /* At least double the heap's size, making certain there's enough room - * for the new object */ + * for the new object + */ need_more = MAX(need_size, heap->dblk_size); /* If there is no last free block or it's not at the end of the heap, @@ -624,8 +598,8 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) * space requested to just the amount of space needed. (Generally * speaking, this only occurs when the heap is small -QAK) */ - if(!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size) - && (need_more < (need_size + H5HL_SIZEOF_FREE(f)))) + if (!(last_fl && last_fl->offset + last_fl->size == heap->dblk_size) && + (need_more < (need_size + H5HL_SIZEOF_FREE(f)))) need_more = need_size; new_dblk_size = heap->dblk_size + need_more; @@ -635,35 +609,36 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) H5_CHECK_OVERFLOW(new_dblk_size, size_t, hsize_t); /* Extend current heap if possible */ - 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) + 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"); /* Check if we extended the heap data block in file */ - if(was_extended == TRUE) { + if (was_extended == TRUE) { /* Check for prefix & data block contiguous */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Resize prefix+data block */ - if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size))) + 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 */ else { /* Resize 'standalone' data block */ - if(FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size)) + 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 */ /* Note new size */ heap->dblk_size = new_dblk_size; - } /* end if */ + } /* 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)) + if (FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); } /* end if */ /* 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) { + if (last_fl && last_fl->offset + last_fl->size == old_dblk_size) { /* * Increase the size of the last free block. */ @@ -677,34 +652,34 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) #ifdef H5HL_DEBUG if (H5DEBUG(HL) && last_fl->size) { HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes at line %d\n", - (unsigned long)(last_fl->size), __LINE__); + (unsigned long)(last_fl->size), __LINE__); } #endif last_fl = H5HL__remove_free(heap, last_fl); } } /* end if */ else { - /* - * Create a new free list element large enough that we can + /* Create a new free list element large enough that we can * take some space out of it right away. */ offset = old_dblk_size; - if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) { - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) { + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); fl->offset = old_dblk_size + need_size; - fl->size = need_more - need_size; + fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl->prev = NULL; fl->next = heap->freelist; - if(heap->freelist) + if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; #ifdef H5HL_DEBUG - } else if (H5DEBUG(HL) && need_more > need_size) { + } + else if (H5DEBUG(HL) && need_more > need_size) { HDfprintf(H5DEBUG(HL), "H5HL_insert: lost %lu bytes at line %d\n", - (unsigned long)(need_more - need_size), __LINE__); + (unsigned long)(need_more - need_size), __LINE__); #endif } } /* end else */ @@ -712,11 +687,10 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { HDfprintf(H5DEBUG(HL), "H5HL: resize mem buf from %lu to %lu bytes\n", - (unsigned long)(old_dblk_size), - (unsigned long)(old_dblk_size + need_more)); + (unsigned long)(old_dblk_size), (unsigned long)(old_dblk_size + need_more)); } #endif - if(NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Clear new section so junk doesn't appear in the file */ @@ -727,15 +701,13 @@ H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf)) /* Copy the data into the heap */ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size); - /* Set return value */ - ret_value = offset; + *offset_out = offset; -CATCH - /* No special processing on errors */ + CATCH + /* No special processing on exit */ END_FUNC(PRIV) /* H5HL_insert() */ - /*------------------------------------------------------------------------- * Function: H5HL_remove * @@ -759,9 +731,7 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) H5HL_free_t *fl = NULL; @@ -782,7 +752,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ - if(FAIL == H5HL__dirty(heap)) + if (FAIL == H5HL__dirty(heap)) H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); /* @@ -791,58 +761,55 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * that all three chunks can be combined into one. */ fl = heap->freelist; - while(fl) { + while (fl) { H5HL_free_t *fl2 = NULL; - if((offset + size) == fl->offset) { + if ((offset + size) == fl->offset) { fl->offset = offset; fl->size += size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl2 = fl->next; - while(fl2) { - if((fl2->offset + fl2->size) == fl->offset) { + while (fl2) { + if ((fl2->offset + fl2->size) == fl->offset) { fl->offset = fl2->offset; fl->size += fl2->size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); 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)) + 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"); } H5_LEAVE(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)) + 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"); } H5_LEAVE(SUCCEED); - } else if(fl->offset + fl->size == offset) { + } + else if (fl->offset + fl->size == offset) { fl->size += size; fl2 = fl->next; HDassert(fl->size == H5HL_ALIGN(fl->size)); - while(fl2) { - if(fl->offset + fl->size == fl2->offset) { + while (fl2) { + if (fl->offset + fl->size == fl2->offset) { fl->size += fl2->size; HDassert(fl->size == H5HL_ALIGN(fl->size)); 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)) + 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 */ 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)) + 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); @@ -855,10 +822,10 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) * hold the free list data. If not, the freed chunk is forever * lost. */ - if(size < H5HL_SIZEOF_FREE(f)) { + if (size < H5HL_SIZEOF_FREE(f)) { #ifdef H5HL_DEBUG - if(H5DEBUG(HL)) { - HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long) size); + if (H5DEBUG(HL)) { + HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif H5_LEAVE(SUCCEED); @@ -867,28 +834,27 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) /* * Add an entry to the free list. */ - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); fl->offset = offset; - fl->size = size; + fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); HDassert(fl->size == H5HL_ALIGN(fl->size)); fl->prev = NULL; fl->next = heap->freelist; - if(heap->freelist) + if (heap->freelist) heap->freelist->prev = fl; heap->freelist = fl; - if(((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) - if(FAIL == H5HL__minimize_heap_space(f, 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 + CATCH /* No special processing on exit */ END_FUNC(PRIV) /* end H5HL_remove() */ - /*------------------------------------------------------------------------- * Function: H5HL_delete * @@ -901,15 +867,13 @@ END_FUNC(PRIV) /* end H5HL_remove() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_delete(H5F_t *f, haddr_t addr)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, 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 */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + 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 */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ /* check arguments */ HDassert(f); @@ -918,37 +882,38 @@ H5HL_delete(H5F_t *f, haddr_t addr)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) + 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"); /* Get the pointer to the heap */ heap = prfx->heap; /* Check if heap has separate data block */ - if(!heap->single_cache_obj) + if (!heap->single_cache_obj) /* 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))) + 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"); /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; -CATCH + CATCH /* 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) + 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"); /* Release the prefix from the cache, now deleted */ - if(prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) + 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"); END_FUNC(PRIV) /* end H5HL_delete() */ - /*------------------------------------------------------------------------- * Function: H5HL_get_size * @@ -961,13 +926,11 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, 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; /* Heap data structure */ + 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 */ /* check arguments */ HDassert(f); @@ -977,11 +940,12 @@ H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) + 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"); /* Get the pointer to the heap */ @@ -990,13 +954,12 @@ H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) /* Set the size to return */ *size = heap->dblk_size; -CATCH - if(prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + CATCH + 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"); END_FUNC(PRIV) /* end H5HL_get_size() */ - /*------------------------------------------------------------------------- * Function: H5HL_heapsize * @@ -1010,13 +973,11 @@ 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)) +BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, 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; /* Heap data structure */ + 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 */ /* check arguments */ HDassert(f); @@ -1026,11 +987,12 @@ H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) /* Construct the user data for protect callback */ prfx_udata.sizeof_size = H5F_SIZEOF_SIZE(f); prfx_udata.sizeof_addr = H5F_SIZEOF_ADDR(f); - prfx_udata.prfx_addr = addr; + prfx_udata.prfx_addr = addr; prfx_udata.sizeof_prfx = H5HL_SIZEOF_HDR(f); /* Protect the local heap prefix */ - if(NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) + 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"); /* Get the pointer to the heap */ @@ -1039,9 +1001,8 @@ H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) /* Accumulate the size of the local heap */ *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); -CATCH - if(prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) + CATCH + 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"); END_FUNC(PRIV) /* end H5HL_heapsize() */ - diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 006ddc0f51e..b46280ef79b 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,44 +26,39 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ -#define H5HL_VERSION 0 /* Local heap collection version */ +#define H5HL_VERSION 0 /* Local heap collection version */ /* Set the local heap size to speculatively read in * (needs to be more than the local heap prefix size to work at all and * should be larger than the default local heap size to save the * extra I/O operations) */ -#define H5HL_SPEC_READ_SIZE 512 - +#define H5HL_SPEC_READ_SIZE 512 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -71,32 +66,27 @@ /* Metadata cache callbacks */ /* Local heap prefix */ 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 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 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_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_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, H5HL_cache_prfx_ud_t *udata); /* Free list de/serialization */ static herr_t H5HL__fl_deserialize(H5HL_t *heap); -static void H5HL__fl_serialize(const H5HL_t *heap); +static void H5HL__fl_serialize(const H5HL_t *heap); /*********************/ /* Package Variables */ @@ -104,51 +94,47 @@ static void H5HL__fl_serialize(const H5HL_t *heap); /* H5HL inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_LHEAP_PRFX[1] = {{ - H5AC_LHEAP_PRFX_ID, /* Metadata client ID */ - "local heap prefix", /* Metadata client name (for debugging) */ - H5FD_MEM_LHEAP, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5HL__cache_prefix_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5HL__cache_prefix_get_final_load_size, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HL__cache_prefix_deserialize, /* 'deserialize' callback */ - H5HL__cache_prefix_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HL__cache_prefix_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5HL__cache_prefix_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_LHEAP_PRFX_ID, /* Metadata client ID */ + "local heap prefix", /* Metadata client name (for debugging) */ + H5FD_MEM_LHEAP, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5HL__cache_prefix_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5HL__cache_prefix_get_final_load_size, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HL__cache_prefix_deserialize, /* 'deserialize' callback */ + H5HL__cache_prefix_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HL__cache_prefix_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5HL__cache_prefix_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ - H5AC_LHEAP_DBLK_ID, /* Metadata client ID */ - "local heap datablock", /* Metadata client name (for debugging) */ - H5FD_MEM_LHEAP, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5HL__cache_datablock_get_initial_load_size,/* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - NULL, /* 'verify_chksum' callback */ - H5HL__cache_datablock_deserialize, /* 'deserialize' callback */ - H5HL__cache_datablock_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5HL__cache_datablock_serialize, /* 'serialize' callback */ - H5HL__cache_datablock_notify, /* 'notify' callback */ - H5HL__cache_datablock_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_LHEAP_DBLK_ID, /* Metadata client ID */ + "local heap datablock", /* Metadata client name (for debugging) */ + H5FD_MEM_LHEAP, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5HL__cache_datablock_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + NULL, /* 'verify_chksum' callback */ + H5HL__cache_datablock_deserialize, /* 'deserialize' callback */ + H5HL__cache_datablock_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5HL__cache_datablock_serialize, /* 'serialize' callback */ + H5HL__cache_datablock_notify, /* 'notify' callback */ + H5HL__cache_datablock_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5HL__hdr_deserialize() * @@ -163,8 +149,7 @@ 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, H5HL_cache_prfx_ud_t *udata) { herr_t ret_value = SUCCEED; /* Return value */ @@ -176,12 +161,12 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, HDassert(udata); /* Check magic number */ - if(HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature") image += H5_SIZEOF_MAGIC; /* Version */ - if(H5HL_VERSION != *image++) + if (H5HL_VERSION != *image++) HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap") /* Reserved */ @@ -196,7 +181,7 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, /* Free list head */ H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size); - if(heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_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") /* Heap data address */ @@ -206,7 +191,6 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__hdr_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__fl_deserialize * @@ -222,9 +206,9 @@ H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image, static herr_t H5HL__fl_deserialize(H5HL_t *heap) { - H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */ - hsize_t free_block; /* Offset of free block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_free_t *fl = NULL, *tail = NULL; /* Heap free block nodes */ + hsize_t free_block; /* Offset of free block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -234,50 +218,49 @@ H5HL__fl_deserialize(H5HL_t *heap) /* Build free list */ free_block = heap->free_block; - while(H5HL_FREE_NULL != free_block) { - const uint8_t *image; /* Pointer into image buffer */ + while (H5HL_FREE_NULL != free_block) { + const uint8_t *image; /* Pointer into image buffer */ /* Sanity check */ - if(free_block >= heap->dblk_size) + if (free_block >= heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") /* Allocate & initialize free list node */ - if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) + if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") fl->offset = (size_t)free_block; - fl->prev = tail; - fl->next = NULL; + fl->prev = tail; + fl->next = NULL; /* Decode offset of next free block */ image = heap->dblk_image + free_block; H5F_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size); - if(0 == free_block) + if (0 == free_block) 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) + if ((fl->offset + fl->size) > heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") /* Append node onto list */ - if(tail) + if (tail) tail->next = fl; else heap->freelist = fl; tail = fl; - fl = NULL; + fl = NULL; } /* end while */ done: - if(ret_value < 0) - if(fl) + if (ret_value < 0) + if (fl) /* H5FL_FREE always returns NULL so we can't check for errors */ fl = H5FL_FREE(H5HL_free_t, fl); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__fl_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__fl_serialize * @@ -293,7 +276,7 @@ H5HL__fl_deserialize(H5HL_t *heap) static void H5HL__fl_serialize(const H5HL_t *heap) { - H5HL_free_t *fl; /* Pointer to heap free list node */ + H5HL_free_t *fl; /* Pointer to heap free list node */ FUNC_ENTER_STATIC_NOERR @@ -301,13 +284,13 @@ H5HL__fl_serialize(const H5HL_t *heap) HDassert(heap); /* Serialize the free list into the heap data's image */ - for(fl = heap->freelist; fl; fl = fl->next) { - uint8_t *image; /* Pointer into raw data buffer */ + for (fl = heap->freelist; fl; fl = fl->next) { + uint8_t *image; /* Pointer into raw data buffer */ HDassert(fl->offset == H5HL_ALIGN(fl->offset)); image = heap->dblk_image + fl->offset; - if(fl->next) + if (fl->next) H5F_ENCODE_LENGTH_LEN(image, fl->next->offset, heap->sizeof_size) else H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) @@ -319,7 +302,6 @@ H5HL__fl_serialize(const H5HL_t *heap) } /* end H5HL__fl_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_get_initial_load_size() * @@ -348,7 +330,6 @@ H5HL__cache_prefix_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *im FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_get_final_load_size() * @@ -365,12 +346,12 @@ 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) + void *_udata, size_t *actual_len) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -381,16 +362,16 @@ 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) + if (H5HL__hdr_deserialize(&heap, (const uint8_t *)image, 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; /* Check if heap block exists */ - if(heap.dblk_size) + if (heap.dblk_size) /* Check if heap data block is contiguous with header */ - if(H5F_addr_eq((heap.prfx_addr + heap.prfx_size), heap.dblk_addr)) + if (H5F_addr_eq((heap.prfx_addr + heap.prfx_size), heap.dblk_addr)) /* Note that the heap should be a single object in the cache */ *actual_len += heap.dblk_size; @@ -398,7 +379,6 @@ H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_deserialize * @@ -415,14 +395,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 H5_ATTR_NDEBUG_UNUSED 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_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ - void *ret_value = NULL; /* Return value */ + 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_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -437,26 +417,26 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HDassert(dirty); /* Allocate space in memory for the heap */ - if(NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx))) + if (NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx))) 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) + if (H5HL__hdr_deserialize(heap, (const uint8_t *)image, 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))) + if (NULL == (prfx = H5HL__prfx_new(heap))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix"); /* Check if heap block exists */ - if(heap->dblk_size) { + if (heap->dblk_size) { /* Check if heap data block is contiguous with header */ - if(H5F_addr_eq((heap->prfx_addr + heap->prfx_size), heap->dblk_addr)) { + if (H5F_addr_eq((heap->prfx_addr + heap->prfx_size), heap->dblk_addr)) { /* Note that the heap should be a single object in the cache */ heap->single_cache_obj = TRUE; /* Allocate space for the heap data image */ - if(NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Set image to the start of the data block. This is necessary @@ -468,7 +448,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED H5MM_memcpy(heap->dblk_image, image, heap->dblk_size); /* Build free list */ - if(H5HL__fl_deserialize(heap) < 0) + if (H5HL__fl_deserialize(heap) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") } /* end if */ else @@ -483,21 +463,20 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED done: /* Release the [possibly partially initialized] local heap on errors */ - if(!ret_value) { - if(prfx) { - if(FAIL == H5HL__prfx_dest(prfx)) + if (!ret_value) { + 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)) + if (heap && FAIL == H5HL__dest(heap)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_image_len * @@ -515,7 +494,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED static herr_t H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) { - const H5HL_prfx_t *prfx = (const H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ + const H5HL_prfx_t *prfx = (const H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ FUNC_ENTER_STATIC_NOERR @@ -531,13 +510,12 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) /* If the heap is stored as a single object, add in the * data block size also */ - if(prfx->heap->single_cache_obj) + if (prfx->heap->single_cache_obj) *image_len += prfx->heap->dblk_size; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_serialize * @@ -555,13 +533,13 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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_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 */ FUNC_ENTER_STATIC_NOERR @@ -580,7 +558,7 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, /* Compute the buffer size */ buf_size = heap->prfx_size; - if(heap->single_cache_obj) + if (heap->single_cache_obj) buf_size += heap->dblk_size; HDassert(len == buf_size); @@ -591,17 +569,17 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, H5MM_memcpy(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC); image += H5_SIZEOF_MAGIC; *image++ = H5HL_VERSION; - *image++ = 0; /*reserved*/ - *image++ = 0; /*reserved*/ - *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ + *image++ = 0; /*reserved*/ H5F_ENCODE_LENGTH_LEN(image, heap->dblk_size, heap->sizeof_size); H5F_ENCODE_LENGTH_LEN(image, heap->free_block, heap->sizeof_size); H5F_addr_encode_len(heap->sizeof_addr, &image, heap->dblk_addr); /* Check if the local heap is a single object in cache */ - if(heap->single_cache_obj) { - if((size_t)(image - (uint8_t *)_image) < heap->prfx_size) { - size_t gap; /* Size of gap between prefix and data block */ + if (heap->single_cache_obj) { + if ((size_t)(image - (uint8_t *)_image) < heap->prfx_size) { + size_t gap; /* Size of gap between prefix and data block */ /* Set image to the start of the data block. This is necessary * because there may be a gap between the used portion of @@ -632,7 +610,6 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_prefix_free_icr * @@ -658,8 +635,8 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, static herr_t H5HL__cache_prefix_free_icr(void *_thing) { - H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -670,14 +647,13 @@ H5HL__cache_prefix_free_icr(void *_thing) HDassert(H5F_addr_eq(prfx->cache_info.addr, prfx->heap->prfx_addr)); /* Destroy local heap prefix */ - if(H5HL__prfx_dest(prfx) < 0) + if (H5HL__prfx_dest(prfx) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_get_initial_load_size() * @@ -696,7 +672,7 @@ H5HL__cache_prefix_free_icr(void *_thing) static herr_t H5HL__cache_datablock_get_initial_load_size(void *_udata, size_t *image_len) { - H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ + H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -711,7 +687,6 @@ H5HL__cache_datablock_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_deserialize * @@ -728,12 +703,11 @@ 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 H5_ATTR_UNUSED *dirty) +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_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 */ FUNC_ENTER_STATIC @@ -747,20 +721,20 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, HDassert(dirty); /* Allocate space in memory for the heap data block */ - if(NULL == (dblk = H5HL__dblk_new(heap))) + if (NULL == (dblk = H5HL__dblk_new(heap))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed"); /* Check for heap still retaining image */ - if(NULL == heap->dblk_image) { + if (NULL == heap->dblk_image) { /* Allocate space for the heap data image */ - if(NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) + if (NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate data block image buffer"); /* copy the datablock from the read buffer */ H5MM_memcpy(heap->dblk_image, image, len); /* Build free list */ - if(FAIL == H5HL__fl_deserialize(heap)) + if (FAIL == H5HL__fl_deserialize(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); } /* end if */ @@ -769,14 +743,13 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, done: /* Release the [possibly partially initialized] local heap on errors */ - if(!ret_value && dblk) - if(FAIL == H5HL__dblk_dest(dblk)) + if (!ret_value && dblk) + if (FAIL == H5HL__dblk_dest(dblk)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_image_len * @@ -793,7 +766,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, static herr_t H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) { - const H5HL_dblk_t *dblk = (const H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + const H5HL_dblk_t *dblk = (const H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ FUNC_ENTER_STATIC_NOERR @@ -810,7 +783,6 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_image_len() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_serialize * @@ -827,10 +799,10 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) */ 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) + size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HL_t *heap; /* Pointer to the local heap */ - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + 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 @@ -857,7 +829,6 @@ H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *imag FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_datablock_serialize() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_notify * @@ -875,18 +846,18 @@ H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *imag static herr_t H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) { - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Sanity checks */ @@ -894,19 +865,19 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) HDassert(dblk->heap->prfx); /* Pin the heap's prefix */ - if(FAIL == H5AC_pin_protected_entry(dblk->heap->prfx)) + if (FAIL == H5AC_pin_protected_entry(dblk->heap->prfx)) HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix") break; - case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ - break; + /* do nothing */ + break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Sanity checks */ @@ -914,7 +885,7 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) HDassert(dblk->heap->prfx); /* Unpin the local heap prefix */ - if(FAIL == H5AC_unpin_entry(dblk->heap->prfx)) + if (FAIL == H5AC_unpin_entry(dblk->heap->prfx)) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap prefix") break; @@ -927,7 +898,6 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_notify() */ - /*------------------------------------------------------------------------- * Function: H5HL__cache_datablock_free_icr * @@ -948,8 +918,8 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) static herr_t H5HL__cache_datablock_free_icr(void *_thing) { - H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -959,10 +929,9 @@ H5HL__cache_datablock_free_icr(void *_thing) HDassert(dblk->cache_info.type == H5AC_LHEAP_DBLK); /* Destroy the data block */ - if(H5HL__dblk_dest(dblk) < 0) + if (H5HL__dblk_dest(dblk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_datablock_free_icr() */ - diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index c0ec68b2e03..76e4ec09cbb 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,18 +21,17 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local heaps */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local heaps */ +#include "H5MMprivate.h" /* Memory management */ - /*------------------------------------------------------------------------- * Function: H5HL_debug * @@ -45,15 +44,14 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, -H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)) +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; - int free_block; - H5HL_free_t *freelist; - uint8_t *marker = NULL; - size_t amount_free = 0; + H5HL_t * h = NULL; + int free_block; + H5HL_free_t *freelist; + uint8_t * marker = NULL; + size_t amount_free = 0; /* check arguments */ HDassert(f); @@ -62,64 +60,58 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)) HDassert(indent >= 0); HDassert(fwidth >= 0); - if(NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) + if (NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap"); HDfprintf(stream, "%*sLocal Heap...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Header size (in bytes):", - (unsigned long)h->prfx_size); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of heap data:", - h->dblk_addr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data bytes allocated for heap:", - h->dblk_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size (in bytes):", h->prfx_size); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Address of heap data:", h->dblk_addr); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Data bytes allocated for heap:", h->dblk_size); /* Traverse the free list and check that all free blocks fall within * the heap and that no two free blocks point to the same region of * the heap. */ - if(NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) + if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); - for(free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { + for (free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { char temp_str[32]; HDsnprintf(temp_str, sizeof(temp_str), "Block #%d:", free_block); - HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9), temp_str, freelist->offset, freelist->size); - if((freelist->offset + freelist->size) > h->dblk_size) + HDfprintf(stream, "%*s%-*s %8zu, %8zu\n", indent + 3, "", MAX(0, fwidth - 9), temp_str, + freelist->offset, freelist->size); + if ((freelist->offset + freelist->size) > h->dblk_size) HDfprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n"); else { - int overlap = 0; + int overlap = 0; size_t i; - for(i = 0; i < freelist->size; i++) { - if(marker[freelist->offset + i]) + for (i = 0; i < freelist->size; i++) { + if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; } /* end for */ - if(overlap) + if (overlap) HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ - if(h->dblk_size) + if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", - ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); + (100.0 * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); /* 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 - if(h && FAIL == H5HL_unprotect(h)) + CATCH + if (h && FAIL == H5HL_unprotect(h)) H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap"); - if(marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) + if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) H5E_THROW(H5E_CANTFREE, "can't free marker buffer"); END_FUNC(PRIV) /* end H5HL_debug() */ - diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index 88348a0924e..f771de522c5 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,49 +26,41 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -76,8 +68,6 @@ /* Declare a free list to manage the H5HL_dblk_t struct */ H5FL_DEFINE_STATIC(H5HL_dblk_t); - - /*------------------------------------------------------------------------- * Function: H5HL__dblk_new * @@ -91,21 +81,19 @@ H5FL_DEFINE_STATIC(H5HL_dblk_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5HL_dblk_t *, NULL, NULL, -H5HL__dblk_new(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) - H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + H5HL_dblk_t *dblk = NULL; /* New local heap data block */ /* check arguments */ HDassert(heap); /* Allocate new local heap data block */ - if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) + if (NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap data block") /* Increment ref. count on heap data structure */ - if(FAIL == H5HL__inc_rc(heap)) + if (FAIL == H5HL__inc_rc(heap)) H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") /* Link the heap & the data block */ @@ -115,15 +103,14 @@ H5HL__dblk_new(H5HL_t *heap)) /* Set the return value */ ret_value = dblk; -CATCH + CATCH /* Ensure that the data block memory is deallocated on errors */ - if(!ret_value && dblk != NULL) + 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() */ - /*------------------------------------------------------------------------- * Function: H5HL__dblk_dest * @@ -136,34 +123,31 @@ END_FUNC(PKG) /* end H5HL__dblk_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dblk_dest(H5HL_dblk_t *dblk)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) /* check arguments */ HDassert(dblk); /* Check if data block was initialized */ - if(dblk->heap) { + if (dblk->heap) { /* Unlink data block from heap */ dblk->heap->dblk = NULL; /* Decrement ref. count on heap data structure */ - if(FAIL == H5HL__dec_rc(dblk->heap)) + if (FAIL == H5HL__dec_rc(dblk->heap)) H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") /* Unlink heap from data block */ dblk->heap = NULL; } /* end if */ -CATCH + CATCH /* 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() */ - /*------------------------------------------------------------------------- * Function: H5HL__dblk_realloc * @@ -176,29 +160,27 @@ 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)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, 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 */ + 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 */ /* check arguments */ HDassert(heap); HDassert(new_heap_size > 0); /* Release old space on disk */ - old_addr = heap->dblk_addr; + old_addr = heap->dblk_addr; 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)) + 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"); /* 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))) + 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"); /* Update heap info*/ @@ -206,15 +188,15 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) heap->dblk_size = new_heap_size; /* Check if heap data block actually moved in the file */ - if(H5F_addr_eq(old_addr, new_addr)) { + if (H5F_addr_eq(old_addr, new_addr)) { /* Check if heap data block is contiguous w/prefix */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Sanity check */ HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, old_addr)); HDassert(heap->prfx); /* Resize the heap prefix in the cache */ - if(FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size))) + 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 */ else { @@ -223,24 +205,24 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) HDassert(heap->dblk); /* Resize the heap data block in the cache */ - if(H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0) + 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 */ + } /* end if */ else { /* Check if heap data block was contiguous w/prefix previously */ - if(heap->single_cache_obj) { + if (heap->single_cache_obj) { /* Create new heap data block */ - if(NULL == (dblk = H5HL__dblk_new(heap))) + if (NULL == (dblk = H5HL__dblk_new(heap))) H5E_THROW(H5E_CANTALLOC, "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)) + if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) H5E_THROW(H5E_CANTRESIZE, "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)) + 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"); dblk = NULL; @@ -253,22 +235,21 @@ H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) /* (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)) + if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) H5E_THROW(H5E_CANTRESIZE, "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)) + 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 */ + } /* end else */ -CATCH + CATCH /* Restore old heap address & size on errors */ - if(FAIL == ret_value) { + if (FAIL == ret_value) { heap->dblk_addr = old_addr; heap->dblk_size = old_heap_size; } /* end if */ END_FUNC(PKG) /* end H5HL__dblk_realloc() */ - diff --git a/src/H5HLint.c b/src/H5HLint.c index 17527c19c75..069bad80761 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,48 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -75,8 +67,6 @@ /* Declare a free list to manage the H5HL_t struct */ H5FL_DEFINE_STATIC(H5HL_t); - - /*------------------------------------------------------------------------- * Function: H5HL__new * @@ -90,11 +80,10 @@ 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)) +BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, + H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) - H5HL_t *heap = NULL; /* New local heap */ + H5HL_t *heap = NULL; /* New local heap */ /* check arguments */ HDassert(sizeof_size > 0); @@ -102,25 +91,24 @@ H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) HDassert(prfx_size > 0); /* Allocate new local heap structure */ - if(NULL == (heap = H5FL_CALLOC(H5HL_t))) + if (NULL == (heap = H5FL_CALLOC(H5HL_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); /* Initialize non-zero fields */ heap->sizeof_size = sizeof_size; heap->sizeof_addr = sizeof_addr; - heap->prfx_size = prfx_size; + heap->prfx_size = prfx_size; /* Set the return value */ ret_value = heap; -CATCH - if(!ret_value && heap != NULL) + CATCH + if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) H5E_THROW(H5E_CANTFREE, "can't free heap memory"); END_FUNC(PKG) /* end H5HL__new() */ - /*------------------------------------------------------------------------- * Function: H5HL__inc_rc * @@ -133,9 +121,7 @@ END_FUNC(PKG) /* end H5HL__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, -herr_t, SUCCEED, -, -H5HL__inc_rc(H5HL_t *heap)) +BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -145,7 +131,6 @@ H5HL__inc_rc(H5HL_t *heap)) END_FUNC(PKG) /* end H5HL__inc_rc() */ - /*------------------------------------------------------------------------- * Function: H5HL__dec_rc * @@ -158,9 +143,7 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dec_rc(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -168,14 +151,13 @@ H5HL__dec_rc(H5HL_t *heap)) /* Decrement heap's ref. count */ heap->rc--; -CATCH + CATCH /* Check if we should destroy the heap */ - if(heap->rc == 0 && FAIL == H5HL__dest(heap)) + if (heap->rc == 0 && FAIL == H5HL__dest(heap)) H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); END_FUNC(PKG) /* end H5HL__dec_rc() */ - /*------------------------------------------------------------------------- * Function: H5HL__dest * @@ -188,9 +170,7 @@ END_FUNC(PKG) /* end H5HL__dec_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__dest(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) /* check arguments */ HDassert(heap); @@ -201,20 +181,20 @@ H5HL__dest(H5HL_t *heap)) HDassert(heap->prfx == NULL); HDassert(heap->dblk == NULL); -CATCH - if(heap->dblk_image) - if(NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image))) + CATCH + 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"); - while(heap->freelist) { - H5HL_free_t *fl; + while (heap->freelist) { + H5HL_free_t *fl; - fl = heap->freelist; + fl = heap->freelist; heap->freelist = fl->next; - if(NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) + if (NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) H5E_THROW(H5E_CANTFREE, "unable to free local heap free list"); } /* end while */ - if(NULL != (heap = H5FL_FREE(H5HL_t, heap))) + if (NULL != (heap = H5FL_FREE(H5HL_t, heap))) H5E_THROW(H5E_CANTFREE, "unable to free local heap"); END_FUNC(PKG) /* end H5HL__dest() */ diff --git a/src/H5HLmodule.h b/src/H5HLmodule.h index 712c7c12d2d..3004809e3bb 100644 --- a/src/H5HLmodule.h +++ b/src/H5HLmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5HL package. Including this header means that the source file * is part of the H5HL package. */ -#ifndef _H5HLmodule_H -#define _H5HLmodule_H +#ifndef H5HLmodule_H +#define H5HLmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5HL_MODULE -#define H5_MY_PKG H5HL -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO - -#endif /* _H5HLmodule_H */ +#define H5_MY_PKG H5HL +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO +#endif /* H5HLmodule_H */ diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 9891e10ffc3..dbac1b9f3fd 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,15 +23,14 @@ #error "Do not include this file outside the H5HL package!" #endif -#ifndef _H5HLpkg_H -#define _H5HLpkg_H +#ifndef H5HLpkg_H +#define H5HLpkg_H /* Get package's private header */ #include "H5HLprivate.h" /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free lists */ - +#include "H5FLprivate.h" /* Free lists */ /*****************************/ /* Package Private Variables */ @@ -43,7 +42,6 @@ H5FL_EXTERN(H5HL_free_t); /* Declare extern the PQ free list to manage the heap chunk information */ H5FL_BLK_EXTERN(lheap_chunk); - /**************************/ /* Package Private Macros */ /**************************/ @@ -53,32 +51,31 @@ H5FL_BLK_EXTERN(lheap_chunk); * error reporting macros. */ #ifdef H5HL_PACKAGE -#define H5_MY_PKG H5HL -#define H5_MY_PKG_ERR H5E_HEAP -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5HL +#define H5_MY_PKG_ERR H5E_HEAP +#define H5_MY_PKG_INIT NO #endif /* H5HL_PACKAGE */ -#define H5HL_SIZEOF_HDR(F) \ - H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ - 1 + /* version */ \ - 3 + /* reserved */ \ - H5F_SIZEOF_SIZE(F) + /* data size */ \ - H5F_SIZEOF_SIZE(F) + /* free list head */ \ - H5F_SIZEOF_ADDR(F)) /* data address */ +#define H5HL_SIZEOF_HDR(F) \ + H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ + 1 + /* version */ \ + 3 + /* reserved */ \ + H5F_SIZEOF_SIZE(F) + /* data size */ \ + H5F_SIZEOF_SIZE(F) + /* free list head */ \ + H5F_SIZEOF_ADDR(F)) /* data address */ /* Value indicating end of free list on disk */ -#define H5HL_FREE_NULL 1 - +#define H5HL_FREE_NULL 1 /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5HL_free_t { - size_t offset; /* offset of free block */ - size_t size; /* size of free block */ - struct H5HL_free_t *prev; /* previous entry in free list */ - struct H5HL_free_t *next; /* next entry in free list */ + size_t offset; /* offset of free block */ + size_t size; /* size of free block */ + struct H5HL_free_t *prev; /* previous entry in free list */ + struct H5HL_free_t *next; /* next entry in free list */ } H5HL_free_t; /* Forward declarations */ @@ -87,66 +84,65 @@ typedef struct H5HL_prfx_t H5HL_prfx_t; struct H5HL_t { /* General heap-management fields */ - size_t rc; /* Ref. count for prefix & data block using this struct */ - size_t prots; /* # of times the heap has been protected */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ - H5HL_free_t *freelist; /* the free list */ + size_t rc; /* Ref. count for prefix & data block using this struct */ + size_t prots; /* # of times the heap has been protected */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + hbool_t single_cache_obj; /* Indicate if the heap is a single object in the cache */ + H5HL_free_t *freelist; /* the free list */ /* Prefix-specific fields */ - H5HL_prfx_t *prfx; /* The prefix object for the heap */ - haddr_t prfx_addr; /* address of heap prefix */ - size_t prfx_size; /* size of heap prefix */ - hsize_t free_block; /* Address of first free block */ + H5HL_prfx_t *prfx; /* The prefix object for the heap */ + haddr_t prfx_addr; /* address of heap prefix */ + size_t prfx_size; /* size of heap prefix */ + hsize_t free_block; /* Address of first free block */ /* Data block-specific fields */ - 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 */ + 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 */ }; /* Struct for heap data block */ struct H5HL_dblk_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - H5HL_t *heap; /* Pointer to heap for data block */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for data block */ }; /* Struct for heap prefix */ struct H5HL_prfx_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - H5HL_t *heap; /* Pointer to heap for prefix */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + H5HL_t *heap; /* Pointer to heap for prefix */ }; /* Callback information for loading local heap prefix from disk */ typedef struct H5HL_cache_prfx_ud_t { - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - haddr_t prfx_addr; /* Address of prefix */ - size_t sizeof_prfx; /* Size of heap prefix */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + haddr_t prfx_addr; /* Address of prefix */ + size_t sizeof_prfx; /* Size of heap prefix */ } H5HL_cache_prfx_ud_t; - /******************************/ /* Package Private Prototypes */ /******************************/ /* Heap routines */ H5_DLL H5HL_t *H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size); -H5_DLL herr_t H5HL__dest(H5HL_t *heap); -H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap); -H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap); +H5_DLL herr_t H5HL__dest(H5HL_t *heap); +H5_DLL herr_t H5HL__inc_rc(H5HL_t *heap); +H5_DLL herr_t H5HL__dec_rc(H5HL_t *heap); /* Heap prefix routines */ H5_DLL H5HL_prfx_t *H5HL__prfx_new(H5HL_t *heap); -H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx); +H5_DLL herr_t H5HL__prfx_dest(H5HL_prfx_t *prfx); /* Heap data block routines */ H5_DLL H5HL_dblk_t *H5HL__dblk_new(H5HL_t *heap); -H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk); -H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size); +H5_DLL herr_t H5HL__dblk_dest(H5HL_dblk_t *dblk); +H5_DLL herr_t H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size); -#endif /* _H5HLpkg_H */ +#endif /* H5HLpkg_H */ diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 8c4ffadd692..90f6c741c0a 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,48 +26,40 @@ /* Module Setup */ /****************/ -#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ - +#include "H5HLmodule.h" /* This source code file is part of the H5HL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5HLpkg.h" /* Local Heaps */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5HLpkg.h" /* Local Heaps */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -75,8 +67,6 @@ /* Declare a free list to manage the H5HL_prfx_t struct */ H5FL_DEFINE_STATIC(H5HL_prfx_t); - - /*------------------------------------------------------------------------- * Function: H5HL__prfx_new * @@ -90,21 +80,19 @@ H5FL_DEFINE_STATIC(H5HL_prfx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -H5HL_prfx_t *, NULL, NULL, -H5HL__prfx_new(H5HL_t *heap)) +BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) - H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ /* check arguments */ HDassert(heap); /* Allocate new local heap prefix */ - if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) + if (NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap prefix") /* Increment ref. count on heap data structure */ - if(FAIL == H5HL__inc_rc(heap)) + if (FAIL == H5HL__inc_rc(heap)) H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") /* Link the heap & the prefix */ @@ -114,15 +102,14 @@ H5HL__prfx_new(H5HL_t *heap)) /* Set the return value */ ret_value = prfx; -CATCH + CATCH /* Ensure that the prefix memory is deallocated on errors */ - if(!ret_value && prfx != NULL) + 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() */ - /*------------------------------------------------------------------------- * Function: H5HL__prfx_dest * @@ -135,30 +122,27 @@ END_FUNC(PKG) /* end H5HL__prfx_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, -herr_t, SUCCEED, FAIL, -H5HL__prfx_dest(H5HL_prfx_t *prfx)) +BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) /* check arguments */ HDassert(prfx); /* Check if prefix was initialized */ - if(prfx->heap) { + if (prfx->heap) { /* Unlink prefix from heap */ prfx->heap->prfx = NULL; /* Decrement ref. count on heap data structure */ - if(FAIL == H5HL__dec_rc(prfx->heap)) + if (FAIL == H5HL__dec_rc(prfx->heap)) H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") /* Unlink heap from prefix */ prfx->heap = NULL; } /* end if */ -CATCH + CATCH /* 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() */ - diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 60505ee468c..5c9884629db 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,27 +21,27 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5HLprivate_H -#define _H5HLprivate_H +#ifndef H5HLprivate_H +#define H5HLprivate_H /* Private headers needed by this file. */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /* * Feature: Define H5HL_DEBUG on the compiler command line if you want to * enable diagnostic messages from this layer. */ #ifdef NDEBUG -# undef H5HL_DEBUG +#undef H5HL_DEBUG #endif -#define H5HL_ALIGN(X) ((((unsigned)X)+7)&(unsigned)(~0x07)) /* align on 8-byte boundary */ +#define H5HL_ALIGN(X) ((((unsigned)X) + 7) & (unsigned)(~0x07)) /* align on 8-byte boundary */ -#define H5HL_SIZEOF_FREE(F) \ - H5HL_ALIGN(H5F_SIZEOF_SIZE (F) + /* ptr to next free block */ \ - H5F_SIZEOF_SIZE (F)) /* size of this free block */ +#define H5HL_SIZEOF_FREE(F) \ + H5HL_ALIGN(H5F_SIZEOF_SIZE(F) + /* ptr to next free block */ \ + H5F_SIZEOF_SIZE(F)) /* size of this free block */ /****************************/ /* Library Private Typedefs */ @@ -53,19 +53,17 @@ 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_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 size_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf); -H5_DLL void *H5HL_offset_into(const H5HL_t *heap, size_t offset); +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); +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); /* Debugging routines for dumping file structures */ -H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth); +H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); #endif - diff --git a/src/H5HP.c b/src/H5HP.c index 4ef5662d1b0..d1642237eda 100644 --- a/src/H5HP.c +++ b/src/H5HP.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,37 +19,36 @@ * */ - /* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HPprivate.h" /* Heap routines */ -#include "H5FLprivate.h" /* Memory management functions */ +#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 */ +#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; + 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 */ + 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); +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); @@ -57,14 +56,13 @@ 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 + H5HP__swim_max PURPOSE Restore heap condition by moving an object upward USAGE - herr_t H5HP_swim_max(heap, loc) + 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 @@ -80,49 +78,48 @@ H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_swim_max(H5HP_t *heap, size_t loc) +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 */ + 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_NOAPI_NOINIT_NOERR + 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; + 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) { + 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; + 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; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "above" current location */ - loc=loc/2; + loc = loc / 2; } /* end while */ /* Put object into heap at correct location */ - heap->heap[loc].val=val; - heap->heap[loc].obj=obj; + heap->heap[loc].val = val; + heap->heap[loc].obj = obj; /* Update heap location for object */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_swim_max() */ +} /* end H5HP__swim_max() */ - /*-------------------------------------------------------------------------- NAME - H5HP_swim_min + H5HP__swim_min PURPOSE Restore heap condition by moving an object upward USAGE - herr_t H5HP_swim_min(heap, loc) + 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 @@ -138,49 +135,48 @@ H5HP_swim_max(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_swim_min(H5HP_t *heap, size_t loc) +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 */ + 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_NOAPI_NOINIT_NOERR + 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; + 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) { + 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; + 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; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "above" current location */ - loc=loc/2; + loc = loc / 2; } /* end while */ /* Put object into heap at correct location */ - heap->heap[loc].val=val; - heap->heap[loc].obj=obj; + heap->heap[loc].val = val; + heap->heap[loc].obj = obj; /* Update heap location for object */ - heap->heap[loc].obj->heap_loc=loc; + heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_swim_min() */ +} /* end H5HP__swim_min() */ - /*-------------------------------------------------------------------------- NAME - H5HP_sink_max + H5HP__sink_max PURPOSE Restore heap condition by moving an object downward USAGE - herr_t H5HP_sink_max(heap, loc) + 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 @@ -196,40 +192,40 @@ H5HP_swim_min(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_sink_max(H5HP_t *heap, size_t loc) +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 */ + 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_NOAPI_NOINIT_NOERR + 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; + 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 */ + 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_locnobjs && (heap->heap[new_loc].val < heap->heap[new_loc+1].val)) + 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) + 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; + 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; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "below" current location */ - loc=new_loc; + loc = new_loc; } /* end while */ /* Put object into heap at correct location */ @@ -240,16 +236,15 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_sink_max() */ +} /* end H5HP__sink_max() */ - /*-------------------------------------------------------------------------- NAME - H5HP_sink_min + H5HP__sink_min PURPOSE Restore heap condition by moving an object downward USAGE - herr_t H5HP_sink_min(heap, loc) + 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 @@ -265,40 +260,40 @@ H5HP_sink_max(H5HP_t *heap, size_t loc) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5HP_sink_min(H5HP_t *heap, size_t loc) +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 */ + 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_NOAPI_NOINIT_NOERR + 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; + 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 */ + 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_locnobjs && (heap->heap[new_loc].val > heap->heap[new_loc+1].val)) + 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) + 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; + 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; + heap->heap[loc].obj->heap_loc = loc; /* Move to location "below" current location */ - loc=new_loc; + loc = new_loc; } /* end while */ /* Put object into heap at correct location */ @@ -309,9 +304,8 @@ H5HP_sink_min(H5HP_t *heap, size_t loc) heap->heap[loc].obj->heap_loc = loc; FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_sink_min() */ +} /* end H5HP__sink_min() */ - /*-------------------------------------------------------------------------- NAME H5HP_create @@ -334,60 +328,59 @@ H5HP_sink_min(H5HP_t *heap, size_t loc) 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 */ + 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); + 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"); + 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"); + 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; + 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) { + 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; + 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; + new_heap->heap[0].val = INT_MAX; + new_heap->heap[0].obj = NULL; } /* end else */ /* Set the return value */ - ret_value=new_heap; + ret_value = new_heap; done: /* Error cleanup */ - if(NULL ==ret_value) { - if(NULL != new_heap) { - if(NULL != new_heap->heap) + 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 */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value); } /* end H5HP_create() */ - /*-------------------------------------------------------------------------- NAME H5HP_count @@ -409,7 +402,7 @@ H5HP_create(H5HP_type_t heap_type) ssize_t H5HP_count(const H5HP_t *heap) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -418,21 +411,20 @@ H5HP_count(const H5HP_t *heap) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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; + 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 @@ -456,7 +448,7 @@ H5HP_count(const H5HP_t *heap) herr_t H5HP_insert(H5HP_t *heap, int val, void *obj) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -466,38 +458,38 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 (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->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].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) + 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) + if (H5HP__swim_min(heap, heap->nobjs) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); } /* end else */ @@ -505,16 +497,15 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 @@ -545,20 +536,19 @@ H5HP_top(const H5HP_t *heap, int *val) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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; + *val = heap->heap[1].val; /* No post-condition check necessary, since heap is constant */ FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5HP_top() */ - /*-------------------------------------------------------------------------- NAME H5HP_remove @@ -582,7 +572,7 @@ H5HP_top(const H5HP_t *heap, int *val) herr_t H5HP_remove(H5HP_t *heap, int *val, void **obj) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -593,55 +583,54 @@ H5HP_remove(H5HP_t *heap, int *val, void **obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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) + 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; + 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; + 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) + 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) + 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 */ + } /* end if */ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 @@ -665,10 +654,10 @@ H5HP_remove(H5HP_t *heap, int *val, void **obj) 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 */ + 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) @@ -678,56 +667,55 @@ H5HP_change(H5HP_t *heap, int val, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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); + 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; + old_val = heap->heap[obj_loc].val; + heap->heap[obj_loc].val = val; /* Restore heap condition */ - if(valtype==H5HP_MAX_HEAP) { - if(H5HP_sink_max(heap,obj_loc)<0) + 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) + if (H5HP__swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ - } /* end if */ + } /* end if */ else { - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_swim_max(heap,obj_loc)<0) + 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) + if (H5HP__sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ - } /* end else */ + } /* end else */ done: /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 @@ -751,9 +739,9 @@ H5HP_change(H5HP_t *heap, int val, void *_obj) 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 */ + 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) @@ -763,11 +751,11 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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; @@ -777,12 +765,12 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) heap->heap[obj_loc].val += (int)amt; /* Restore heap condition */ - if(H5HP_MAX_HEAP == heap->type) { - if(H5HP_swim_max(heap, obj_loc) < 0) + 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) + if (H5HP__sink_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") } /* end else */ @@ -790,16 +778,15 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 @@ -823,9 +810,9 @@ H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) 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 */ + 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) @@ -835,27 +822,27 @@ H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Pre-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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); + 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; + heap->heap[obj_loc].val -= (int)amt; /* Restore heap condition */ - if(heap->type==H5HP_MAX_HEAP) { - if(H5HP_sink_max(heap,obj_loc)<0) + 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) + if (H5HP__swim_min(heap, obj_loc) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); } /* end else */ @@ -863,16 +850,15 @@ H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) /* Check internal consistency */ /* (Post-condition) */ - HDassert(heap->nobjsnalloc); + 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); + 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 @@ -905,7 +891,7 @@ H5HP_close(H5HP_t *heap) 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)); + (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); HDassert(NULL == heap->heap[0].obj); /* Free internal structures for heap */ @@ -916,4 +902,3 @@ H5HP_close(H5HP_t *heap) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HP_close() */ - diff --git a/src/H5HPprivate.h b/src/H5HPprivate.h index 041c2b977f3..50020bc0d6d 100644 --- a/src/H5HPprivate.h +++ b/src/H5HPprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains private information about the H5HP module */ -#ifndef _H5HPprivate_H -#define _H5HPprivate_H +#ifndef H5HPprivate_H +#define H5HPprivate_H /**************************************/ /* Public headers needed by this file */ @@ -39,13 +39,13 @@ 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; + 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_MIN_HEAP, /* Minimum values in heap are at the "top" */ + H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ } H5HP_type_t; /**********/ @@ -56,14 +56,13 @@ typedef enum { /* 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 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 */ +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 6a519cc0078..efb4fd5ba11 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -6,178 +6,73 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * FILE: H5I.c - Internal storage routines for handling "IDs" - * - * REMARKS: IDs which allow objects (void * currently) to be bundled - * into "types" for more general storage. - * - * DESIGN: The types are stored in an array of pointers to store each - * type in an element. Each "type" node contains a link to a - * hash table to manage the IDs in each type. Allowed types are - * values within the range 1 to H5I_MAX_NUM_TYPES and are given out - * at run-time. Types used by the library are stored in global - * variables defined in H5Ipublic.h. + * H5I.c - Public routines for handling IDs */ -#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ +/****************/ +/* Module Setup */ +/****************/ +#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip Lists */ -#include "H5Tpkg.h" /* Datatypes */ - +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +/****************/ /* Local Macros */ +/****************/ -/* Combine a Type number and an atom index into an atom */ -#define H5I_MAKE(g,i) ((((hid_t)(g) & TYPE_MASK) << ID_BITS) | \ - ((hid_t)(i) & ID_MASK)) - -/* Local typedefs */ - -/* Atom information structure used */ -typedef struct H5I_id_info_t { - hid_t id; /* ID for this info */ - unsigned count; /* ref. count for this atom */ - unsigned app_count; /* ref. count of application visible atoms */ - const void *obj_ptr; /* pointer associated with the atom */ -} H5I_id_info_t; - -/* ID type structure used */ -typedef struct { - const H5I_class_t *cls; /* Pointer to ID class */ - 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 atom */ - H5SL_t *ids; /* Pointer to skip list that stores IDs */ -} H5I_id_type_t; +/******************/ +/* Local Typedefs */ +/******************/ 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 */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void * app_key; /* Application's "key" (user data) */ + void * ret_obj; /* Object to return */ } H5I_search_ud_t; -/* 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 */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ -} H5I_iterate_ud_t; + H5I_iterate_func_t op; /* Application's callback routine */ + void * op_data; /* Application's user data */ +} H5I_iterate_pub_ud_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ -/* User data for H5I__clear_type_cb */ -typedef struct { - H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ - hbool_t force; /* Whether to always remove the id */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ -} H5I_clear_type_ud_t; - -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - -/*-------------------- Locally scoped variables -----------------------------*/ - -/* Array of pointers to atomic types */ -static H5I_id_type_t *H5I_id_type_list_g[H5I_MAX_NUM_TYPES]; - -/* Variable to keep track of the number of types allocated. Its value is the */ -/* next type ID to be handed out, so it is always one greater than the number */ -/* of types. */ -/* Starts at 1 instead of 0 because it makes trace output look nicer. If more */ -/* types (or IDs within a type) are needed, adjust TYPE_BITS in H5Ipkg.h */ -/* and/or increase size of hid_t */ -static int H5I_next_type = (int)H5I_NTYPES; - -/* Declare a free list to manage the H5I_id_info_t struct */ -H5FL_DEFINE_STATIC(H5I_id_info_t); - -/* Declare a free list to manage the H5I_id_type_t struct */ -H5FL_DEFINE_STATIC(H5I_id_type_t); - -/* Declare a free list to manage the H5I_class_t struct */ -H5FL_DEFINE_STATIC(H5I_class_t); - -/*--------------------- Local function prototypes ---------------------------*/ -static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); -static int H5I__destroy_type(H5I_type_t type); -static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); -static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); -static int H5I__inc_type_ref(H5I_type_t type); -static int H5I__get_type_ref(H5I_type_t type); static int H5I__search_cb(void *obj, hid_t id, void *_udata); -static H5I_id_info_t *H5I__find_id(hid_t id); -static int H5I__debug_cb(void *_item, void *_key, void *_udata); -static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); +static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ - -/*------------------------------------------------------------------------- - * Function: H5I_term_package - * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. - * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -int -H5I_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if(H5_PKG_INIT_VAR) { - H5I_id_type_t *type_ptr; /* Pointer to ID type */ - int type; /* Type of ID */ - - /* How many types are still being used? */ - for(type = 0; type < H5I_next_type; type++) - if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) - n++; - - /* If no types are used then clean up */ - if(0 == n) { - for(type = 0; type < H5I_next_type; type++) { - type_ptr = H5I_id_type_list_g[type]; - if(type_ptr) { - HDassert(NULL == type_ptr->ids); - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); - H5I_id_type_list_g[type] = NULL; - n++; - } /* end if */ - } /* end for */ - - /* Mark interface closed */ - if(0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* end H5I_term_package() */ - - /*------------------------------------------------------------------------- * Function: H5Iregister_type * @@ -196,12 +91,11 @@ H5I_term_package(void) *------------------------------------------------------------------------- */ H5I_type_t -H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, - H5I_free_t free_func) +H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I_free_t free_func) { - H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type; /* New ID type value */ - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_class_t *cls = NULL; /* New ID class */ + H5I_type_t new_type = H5I_BADID; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE3("It", "zIux", hash_size, reserved, free_func); @@ -209,41 +103,41 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, /* Generate a new H5I_type_t value */ /* Increment the number of types */ - if(H5I_next_type < H5I_MAX_NUM_TYPES) { - new_type = (H5I_type_t)H5I_next_type; - H5I_next_type++; - } /* end if */ + if (H5I_next_type_g < H5I_MAX_NUM_TYPES) { + new_type = (H5I_type_t)H5I_next_type_g; + H5I_next_type_g++; + } else { - hbool_t done; /* Indicate that search was successful */ - int i; /* Local index variable */ + hbool_t done; /* Indicate that search was successful */ + int i; /* Look for a free type to give out */ done = FALSE; - for(i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { - if(NULL == H5I_id_type_list_g[i]) { + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { + if (NULL == H5I_type_info_array_g[i]) { /* Found a free type ID */ new_type = (H5I_type_t)i; - done = TRUE; - } /* end if */ - } /* end for */ + done = TRUE; + } + } /* Verify that we found a type to give out */ - if(done == FALSE) + if (done == FALSE) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded") - } /* end else */ + } /* Allocate new ID class */ - if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) + if (NULL == (cls = H5MM_calloc(sizeof(H5I_class_t)))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ - cls->type_id = new_type; - cls->flags = H5I_CLASS_IS_APPLICATION; - cls->reserved = reserved; + cls->type = new_type; + cls->flags = H5I_CLASS_IS_APPLICATION; + cls->reserved = reserved; cls->free_func = free_func; /* Register the new ID class */ - if(H5I_register_type(cls) < 0) + if (H5I_register_type(cls) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, H5I_BADID, "can't initialize ID class") /* Set return value */ @@ -251,74 +145,13 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, done: /* Clean up on error */ - if(ret_value < 0) - if(cls) - cls = H5FL_FREE(H5I_class_t, cls); + if (ret_value < 0) + if (cls) + cls = H5MM_xfree(cls); FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type() */ - -/*------------------------------------------------------------------------- - * Function: H5I_register_type - * - * Purpose: Creates a new type of ID's to give out. - * The class is initialized or its reference count is incremented - * (if it is already initialized). - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_register_type(const H5I_class_t *cls) -{ - H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(cls); - HDassert(cls->type_id > 0 && (int)cls->type_id < H5I_MAX_NUM_TYPES); - - /* Initialize the type */ - if(NULL == H5I_id_type_list_g[cls->type_id]) { - /* Allocate the type information for new type */ - if(NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") - H5I_id_type_list_g[cls->type_id] = type_ptr; - } /* end if */ - else { - /* Get the pointer to the existing type */ - type_ptr = H5I_id_type_list_g[cls->type_id]; - } /* end else */ - - /* Initialize the ID type structure for new types */ - if(type_ptr->init_count == 0) { - type_ptr->cls = cls; - type_ptr->id_count = 0; - type_ptr->nextid = cls->reserved; - if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed") - } /* end if */ - - /* Increment the count of the times this type has been initialized */ - type_ptr->init_count++; - -done: - if(ret_value < 0) { /* Clean up on error */ - if(type_ptr) { - if(type_ptr->ids) - H5SL_close(type_ptr->ids); - (void)H5FL_FREE(H5I_id_type_t, type_ptr); - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register_type() */ - - /*------------------------------------------------------------------------- * Function: H5Itype_exists * @@ -332,25 +165,24 @@ H5I_register_type(const H5I_class_t *cls) htri_t H5Itype_exists(H5I_type_t type) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "It", type); /* Validate parameter */ - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_type_info_array_g[type]) ret_value = FALSE; done: FUNC_LEAVE_API(ret_value) } /* end H5Itype_exists() */ - /*------------------------------------------------------------------------- * Function: H5Inmembers * @@ -361,8 +193,8 @@ H5Itype_exists(H5I_type_t type) * * Return: SUCCEED/FAIL * - * Programmer: James Laird - * Nathaniel Furrer + * Programmer: James Laird + * Nathaniel Furrer * Friday, April 23, 2004 * *------------------------------------------------------------------------- @@ -370,74 +202,36 @@ H5Itype_exists(H5I_type_t type) herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members) { - int ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "It*h", type, num_members); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") /* Validate parameters. This needs to be done here, instead of letting * the private interface handle it, because the public interface throws * an error when the supplied type does not exist. */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_type_info_array_g[type]) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") - if(num_members) { + if (num_members) { int64_t members; - if((members = H5I_nmembers(type)) < 0) + if ((members = H5I_nmembers(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCOUNT, FAIL, "can't compute number of members") H5_CHECKED_ASSIGN(*num_members, hsize_t, members, int64_t); - } /* end if */ + } done: FUNC_LEAVE_API(ret_value) } /* end H5Inmembers() */ - -/*------------------------------------------------------------------------- - * Function: H5I_nmembers - * - * Purpose: Returns the number of members in a type. - * - * Return: Success: Number of members; zero if the type is empty - * or has been deleted. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Wednesday, March 24, 1999 - * - *------------------------------------------------------------------------- - */ -int64_t -H5I_nmembers(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - int64_t ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) - HGOTO_DONE(0); - - /* Set return value */ - H5_CHECKED_ASSIGN(ret_value, int64_t, type_ptr->id_count, uint64_t); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_nmembers() */ - - /*------------------------------------------------------------------------- * Function: H5Iclear_type * @@ -456,12 +250,12 @@ H5I_nmembers(H5I_type_t type) herr_t H5Iclear_type(H5I_type_t type, hbool_t force) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "Itb", type, force); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_clear_type(type, force, TRUE); @@ -470,119 +264,10 @@ H5Iclear_type(H5I_type_t type, hbool_t force) FUNC_LEAVE_API(ret_value) } /* end H5Iclear_type() */ - -/*------------------------------------------------------------------------- - * Function: H5I_clear_type - * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. - * - * Return: SUCCEED/FAIL - * - * Programmer: Robb Matzke - * Wednesday, March 24, 1999 - * - *------------------------------------------------------------------------- - */ -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 */ - int ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Validate parameters */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - udata.type_ptr = H5I_id_type_list_g[type]; - if(udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Finish constructing udata */ - udata.force = force; - udata.app_ref = app_ref; - - /* Attempt to free all ids in the type */ - if(H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't free ids in type") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_clear_type() */ - - -/*------------------------------------------------------------------------- - * Function: H5I__clear_type_cb - * - * Purpose: Attempts to free the specified ID, calling the free - * function for the object. - * - * Return: TRUE/FALSE/FAIL - * - * Programmer: Neil Fortner - * Friday, July 10, 2015 - * - *------------------------------------------------------------------------- - */ -static htri_t -H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) -{ - H5I_id_info_t *id = (H5I_id_info_t *)_id; /* Current ID being worked with */ - H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Sanity checks */ - HDassert(id); - HDassert(udata); - HDassert(udata->type_ptr); - - /* Do nothing to the object if the reference count is larger than - * one and forcing is off. - */ - if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { - /* Check for a 'free' function and call it, if it exists */ - if(udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ - if(udata->force) { -#ifdef H5I_DEBUG - if(H5DEBUG(I)) { - HDfprintf(H5DEBUG(I), "H5I: free type=%d obj=0x%08lx " - "failure ignored\n", - (int)udata->type_ptr->cls->type_id, - (unsigned long)(id->obj_ptr)); - } /* end if */ -#endif /*H5I_DEBUG*/ - - /* Indicate node should be removed from list */ - ret_value = TRUE; - } /* end if */ - } /* end if */ - else { - /* Indicate node should be removed from list */ - ret_value = TRUE; - } /* end else */ - - /* Remove ID if requested */ - if(ret_value) { - /* Free ID info */ - id = H5FL_FREE(H5I_id_info_t, id); - - /* Decrement the number of IDs in the type */ - udata->type_ptr->id_count--; - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__clear_type_cb() */ - - /*------------------------------------------------------------------------- * Function: H5Idestroy_type * - * Purpose: Destroys a type along with all atoms in that type + * Purpose: Destroys a type along with all IDs in that type * regardless of their reference counts. Destroying IDs * involves calling the free-func for each ID's object and * then adding the ID struct to the ID free list. Public @@ -598,12 +283,12 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) herr_t H5Idestroy_type(H5I_type_t type) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "It", type); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I__destroy_type(type); @@ -612,63 +297,10 @@ H5Idestroy_type(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Idestroy_type() */ - -/*------------------------------------------------------------------------- - * Function: H5I__destroy_type - * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. - * - * Return: SUCCEED/FAIL - * - * Programmer: Nathaniel Furrer - * James Laird - * - *------------------------------------------------------------------------- - */ -static herr_t -H5I__destroy_type(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* ptr to the atomic type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Close/clear/destroy all IDs for this type */ - H5E_BEGIN_TRY { - H5I_clear_type(type, TRUE, FALSE); - } H5E_END_TRY /*don't care about errors*/ - - /* Check if we should release the ID class */ - if(type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) - type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); - - if(H5SL_close(type_ptr->ids) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") - type_ptr->ids = NULL; - - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); - H5I_id_type_list_g[type] = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__destroy_type() */ - - /*------------------------------------------------------------------------- * Function: H5Iregister * - * Purpose: Public interface to H5I_register. + * Purpose: Register an object. * * Return: Success: New object ID * Failure: H5I_INVALID_HID @@ -678,13 +310,13 @@ H5I__destroy_type(H5I_type_t type) hid_t H5Iregister(H5I_type_t type, const void *object) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "It*x", type, object); - if(H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + if (H5I_IS_LIB_TYPE(type)) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "cannot call public function on library type") ret_value = H5I_register(type, object, TRUE); @@ -692,201 +324,6 @@ H5Iregister(H5I_type_t type, const void *object) FUNC_LEAVE_API(ret_value) } /* end H5Iregister() */ - -/*------------------------------------------------------------------------- - * Function: H5I_register - * - * Purpose: Registers an OBJECT in a TYPE and returns an ID for it. - * This routine does _not_ check for unique-ness of the objects, - * if you register an object twice, you will get two different - * IDs for it. This routine does make certain that each ID in a - * type is unique. IDs are created by getting a unique number - * for the type the ID is in and incorporating the type into - * the ID which is returned to the user. - * - * Return: Success: New object ID - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -hid_t -H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) -{ - H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ - H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ - hid_t new_id = -1; /* new ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - if ((NULL == type_ptr) || (type_ptr->init_count <= 0)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type") - if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) - HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") - - /* Create the struct & its ID */ - new_id = H5I_MAKE(type, type_ptr->nextid); - id_ptr->id = new_id; - id_ptr->count = 1; /* initial reference count */ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; - - /* Insert into the type */ - if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert ID node into skip list") - type_ptr->id_count++; - type_ptr->nextid++; - - /* Sanity check for the 'nextid' getting too large and wrapping around */ - HDassert(type_ptr->nextid <= ID_MASK); - - /* Set return value */ - ret_value = new_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_register_using_existing_id - * - * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. - * This routine will check to ensure the supplied ID is not already - * in use, and ensure that it is a valid ID for the given type, - * but will NOT check to ensure the OBJECT is not already - * registered (thus, it is possible to register one object under - * multiple IDs). - * - * NOTE: Intended for use in refresh calls, where we have to close - * and re-open the underlying data, then hook the object back - * up to the original ID. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) -{ - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - HDassert(object); - - /* Make sure ID is not already in use */ - if(NULL != (id_ptr = H5I__find_id(existing_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") - - /* Make sure type number is valid */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - /* Get type pointer from list of types */ - type_ptr = H5I_id_type_list_g[type]; - - if(NULL == type_ptr || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Make sure requested ID belongs to object's type */ - if(H5I_TYPE(existing_id) != type) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") - - /* Allocate new structure to house this ID */ - if(NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) - HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Create the struct & insert requested ID */ - id_ptr->id = existing_id; - id_ptr->count = 1; /* initial reference count*/ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; - - /* Insert into the type */ - if(H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list") - type_ptr->id_count++; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_register_using_existing_id() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_subst - * - * Purpose: Substitute a new object pointer for the specified ID. - * - * Return: Success: Non-NULL previous object pointer associated - * with the specified ID. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Saturday, February 27, 2010 - * - *------------------------------------------------------------------------- - */ -void * -H5I_subst(hid_t id, const void *new_object) -{ - H5I_id_info_t *id_ptr; /* Pointer to the atom */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") - - /* Get the old object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - - /* Set the new object pointer for the ID */ - id_ptr->obj_ptr = new_object; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_subst() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_object - * - * Purpose: Find an object pointer for the specified ID. - * - * Return: Success: Non-NULL object pointer associated with the - * specified ID - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5I_object(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - /* General lookup of the ID */ - if(NULL != (id_ptr = H5I__find_id(id))) { - /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_object() */ - - /*------------------------------------------------------------------------- * Function: H5Iobject_verify * @@ -901,95 +338,25 @@ H5I_object(hid_t id) *------------------------------------------------------------------------- */ void * -H5Iobject_verify(hid_t id, H5I_type_t id_type) +H5Iobject_verify(hid_t id, H5I_type_t type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) - H5TRACE2("*x", "iIt", id, id_type); + H5TRACE2("*x", "iIt", id, type); /* Validate parameters */ - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - if(id_type < 1 || (int)id_type >= H5I_next_type) + if (type < 1 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "identifier has invalid type") - ret_value = H5I_object_verify(id, id_type); + ret_value = H5I_object_verify(id, type); done: FUNC_LEAVE_API(ret_value) } /* end H5Iobject_verify() */ - -/*------------------------------------------------------------------------- - * Function: H5I_object_verify - * - * Purpose: Find an object pointer for the specified ID, verifying that - * its in a particular type. - * - * Return: Success: Non-NULL object pointer associated with the - * specified ID. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Wednesday, July 31, 2002 - * - *------------------------------------------------------------------------- - */ -void * -H5I_object_verify(hid_t id, H5I_type_t id_type) -{ - H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - HDassert(id_type >= 1 && (int)id_type < H5I_next_type); - - /* Verify that the type of the ID is correct & lookup the ID */ - if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { - /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5I_object_verify() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_get_type - * - * Purpose: Given an object ID return the type to which it - * belongs. The ID need not be the ID of an object which - * currently exists because the type number is encoded - * in the object ID. - * - * Return: Success: A positive integer (corresponding to an H5I_type_t - * enum value for library ID types, but not for user - * ID types). - * Failure: H5I_BADID - * - * Programmer: Robb Matzke - * Friday, February 19, 1999 - * - *------------------------------------------------------------------------- - */ -H5I_type_t -H5I_get_type(hid_t id) -{ - H5I_type_t ret_value = H5I_BADID; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - - if(id > 0) - ret_value = H5I_TYPE(id); - - HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_type() */ - - /*------------------------------------------------------------------------- * Function: H5Iget_type * @@ -1008,21 +375,20 @@ H5I_get_type(hid_t id) H5I_type_t H5Iget_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE1("It", "i", id); ret_value = H5I_get_type(id); - if(ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) + if (ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type_g || NULL == H5I_object(id)) HGOTO_DONE(H5I_BADID); done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_type() */ - /*------------------------------------------------------------------------- * Function: H5Iremove_verify * @@ -1041,136 +407,23 @@ H5Iget_type(hid_t id) *------------------------------------------------------------------------- */ void * -H5Iremove_verify(hid_t id, H5I_type_t id_type) +H5Iremove_verify(hid_t id, H5I_type_t type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) - H5TRACE2("*x", "iIt", id, id_type); + H5TRACE2("*x", "iIt", id, type); - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Remove the id */ - ret_value = H5I__remove_verify(id, id_type); + ret_value = H5I__remove_verify(id, type); done: FUNC_LEAVE_API(ret_value) } /* end H5Iremove_verify() */ - -/*------------------------------------------------------------------------- - * Function: H5I__remove_verify - * - * Purpose: Removes the specified ID from its type, first checking that - * the ID's type is the same as the ID type supplied as an argument - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - * Programmer: James Laird - * Nat Furrer - * - *------------------------------------------------------------------------- - */ -static void * -H5I__remove_verify(hid_t id, H5I_type_t id_type) -{ - void * ret_value = NULL; /*return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Argument checking will be performed by H5I_remove() */ - - /* Verify that the type of the ID is correct */ - if(id_type == H5I_TYPE(id)) - ret_value = H5I_remove(id); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__remove_verify() */ - - -/*------------------------------------------------------------------------- - * Function: H5I__remove_common - * - * Purpose: Common code to remove a specified ID from its type. - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - * Programmer: Quincey Koziol - * October 3, 2013 - * - *------------------------------------------------------------------------- - */ -static void * -H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) -{ - H5I_id_info_t *curr_id; /* Pointer to the current atom */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type_ptr); - - /* Get the ID node for the ID */ - if(NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from skip list") - - ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ - curr_id = H5FL_FREE(H5I_id_info_t, curr_id); - - /* Decrement the number of IDs in the type */ - (type_ptr->id_count)--; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__remove_common() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_remove - * - * Purpose: Removes the specified ID from its type. - * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5I_remove(hid_t id) -{ - H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ - H5I_type_t type; /* Atom's atomic type */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Check arguments */ - type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") - - /* Remove the node from the type */ - if(NULL == (ret_value = H5I__remove_common(type_ptr, id))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_remove() */ - - /*------------------------------------------------------------------------- * Function: H5Idec_ref * @@ -1189,184 +442,23 @@ H5I_remove(hid_t id) int H5Idec_ref(hid_t id) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ - if(id < 0) + if (id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") - /* Do actual decrement operation */ - if((ret_value = H5I_dec_app_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Idec_ref() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_dec_ref - * - * Purpose: Decrements the number of references outstanding for an ID. - * This will fail if the type is not a reference counted type. - * The ID type's 'free' function will be called for the ID - * if the reference count for the ID reaches 0 and a free - * function has been defined at type creation time. - * - * Return: Success: New reference count - * - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_ref(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* If this is the last reference to the object then invoke the type's - * free method on the object. If the free method is undefined or - * successful then remove the object from the type; otherwise leave - * the object in the type without decrementing the reference - * count. If the reference count is more than one then decrement the - * reference count without calling the free method. - * - * Beware: the free method may call other H5I functions. - * - * If an object is closing, we can remove the ID even though the free - * method might fail. This can happen when a mandatory filter fails to - * write when a dataset is closed and the chunk cache is flushed to the - * file. We have to close the dataset anyway. (SLU - 2010/9/7) - */ - if(1 == id_ptr->count) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - - /* Get the ID's type */ - type_ptr = H5I_id_type_list_g[H5I_TYPE(id)]; - - /* (Casting away const OK -QAK) */ - if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { - /* Remove the node from the type */ - if(NULL == H5I__remove_common(type_ptr, id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") - ret_value = 0; - } /* end if */ - else - ret_value = -1; - } /* end if */ - else { - --(id_ptr->count); - ret_value = (int)id_ptr->count; - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_ref() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref - * - * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. - * count for an ID as well as normal reference count. - * - * Return: Success: New app. reference count - * Failure: -1 - * - * Programmer: Quincey Koziol - * Sept 16, 2010 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_app_ref(hid_t id) -{ - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* Call regular decrement reference count routine */ - if((ret_value = H5I_dec_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") - - /* Check if the ID still exists */ - if(ret_value > 0) { - /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Adjust app_ref */ - --(id_ptr->app_count); - HDassert(id_ptr->count >= id_ptr->app_count); - - /* Set return value */ - ret_value = (int)id_ptr->app_count; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_app_ref() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref_always_close - * - * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, - * even when the free routine fails - * - * Return: Success: New app. reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_app_ref_always_close(hid_t id) -{ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* Call application decrement reference count routine */ - ret_value = H5I_dec_app_ref(id); - - /* Check for failure */ - if (ret_value < 0) { - /* - * If an object is closing, we can remove the ID even though the free - * method might fail. This can happen when a mandatory filter fails to - * write when a dataset is closed and the chunk cache is flushed to the - * file. We have to close the dataset anyway. (SLU - 2010/9/7) - */ - H5I_remove(id); - + /* Do actual decrement operation */ + if ((ret_value = H5I_dec_app_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") - } done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_app_ref_always_close() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Idec_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_ref * @@ -1380,7 +472,7 @@ H5I_dec_app_ref_always_close(hid_t id) int H5Iinc_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1397,45 +489,6 @@ H5Iinc_ref(hid_t id) FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_inc_ref - * - * Purpose: Increment the reference count for an object. - * - * Return: Success: The new reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_inc_ref(hid_t id, hbool_t app_ref) -{ - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Adjust reference counts */ - ++(id_ptr->count); - if (app_ref) - ++(id_ptr->app_count); - - /* Set return value */ - ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_ref() */ - - /*------------------------------------------------------------------------- * Function: H5Iget_ref * @@ -1449,7 +502,7 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) int H5Iget_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1466,40 +519,6 @@ H5Iget_ref(hid_t id) FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_get_ref - * - * Purpose: Retrieve the reference count for an object. - * - * Return: Success: The reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_get_ref(hid_t id, hbool_t app_ref) -{ - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - /* Sanity check */ - HDassert(id >= 0); - - /* General lookup of the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - - /* Set return value */ - ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_ref() */ - - /*------------------------------------------------------------------------- * Function: H5Iinc_type_ref * @@ -1513,67 +532,32 @@ H5I_get_ref(hid_t id, hbool_t app_ref) int H5Iinc_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ - if((ret_value = H5I__inc_type_ref(type)) < 0) + if ((ret_value = H5I__inc_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I__inc_type_ref - * - * Purpose: Increment the reference count for an ID type. - * - * Return: Success: The new reference count - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static int -H5I__inc_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type > 0 && (int)type < H5I_next_type); - - /* Check arguments */ - type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") - - /* Set return value */ - ret_value = (int)(++(type_ptr->init_count)); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__inc_type_ref() */ - - /*------------------------------------------------------------------------- * Function: H5Idec_type_ref * * Purpose: Decrements the reference count on an entire type of IDs. * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling + * destroyed along with all IDs in that type regardless of + * their reference counts. Destroying IDs involves calling * the free-func for each ID's object and then adding the ID * struct to the ID free list. Public interface to * H5I_dec_type_ref. @@ -1594,7 +578,7 @@ H5I__inc_type_ref(H5I_type_t type) herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value = 0; /* Return value */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); @@ -1608,60 +592,6 @@ H5Idec_type_ref(H5I_type_t type) FUNC_LEAVE_API(ret_value) } /* end H5Idec_type_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I_dec_type_ref - * - * Purpose: Decrements the reference count on an entire type of IDs. - * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling - * the free-func for each ID's object and then adding the ID - * struct to the ID free list. - * Returns the number of references to the type on success; a - * return value of 0 means that the type will have to be - * re-initialized before it can be used again (and should probably - * be set to H5I_UNINIT). - * - * Return: Success: Number of references to type - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -int -H5I_dec_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI((-1)) - - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") - - type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") - - /* Decrement the number of users of the atomic type. If this is the - * last user of the type then release all atoms from the type and - * free all memory it used. The free function is invoked for each atom - * being freed. - */ - if(1 == type_ptr->init_count) { - H5I__destroy_type(type); - ret_value = 0; - } - else { - --(type_ptr->init_count); - ret_value = (herr_t)type_ptr->init_count; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_dec_type_ref() */ - - /*------------------------------------------------------------------------- * Function: H5Iget_type_ref * @@ -1675,61 +605,25 @@ H5I_dec_type_ref(H5I_type_t type) int H5Iget_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type_g) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ - if((ret_value = H5I__get_type_ref(type)) < 0) + if ((ret_value = H5I__get_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - -/*------------------------------------------------------------------------- - * Function: H5I__get_type_ref - * - * Purpose: Retrieve the reference count for an ID type. - * - * Return: Success: The reference count - * - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static int -H5I__get_type_ref(H5I_type_t type) -{ - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(type >= 0); - - /* Check arguments */ - type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Set return value */ - ret_value = (int)type_ptr->init_count; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__get_type_ref() */ - - /*------------------------------------------------------------------------- * Function: H5Iis_valid * @@ -1743,23 +637,22 @@ H5I__get_type_ref(H5I_type_t type) htri_t H5Iis_valid(hid_t id) { - H5I_id_info_t *id_ptr; /* ptr to the ID */ - htri_t ret_value = TRUE; /* Return value */ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", id); /* Find the ID */ - if (NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (info = H5I__find_id(id))) ret_value = FALSE; - else if (!id_ptr->app_count) /* Check if the found id is an internal id */ + else if (!info->app_count) /* Check if the found id is an internal id */ ret_value = FALSE; done: FUNC_LEAVE_API(ret_value) } /* end H5Iis_valid() */ - /*------------------------------------------------------------------------- * Function: H5I__search_cb * @@ -1775,26 +668,25 @@ H5Iis_valid(hid_t id) static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - herr_t cb_ret_val; /* User callback return value */ - int ret_value = H5_ITER_ERROR; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) { - ret_value = H5_ITER_STOP; /* terminate iteration early */ - udata->ret_obj = obj; /* also set out parameter */ + if (cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ } - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ - /*------------------------------------------------------------------------- * Function: H5Isearch * @@ -1818,8 +710,8 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) void * H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) { - H5I_search_ud_t udata; /* Context for iteration */ - void *ret_value; /* Return value */ + H5I_search_ud_t udata; /* Context for iteration */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("*x", "Itx*x", type, func, key); @@ -1829,7 +721,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Set up udata struct */ - udata.app_cb = func; + udata.app_cb = func; udata.app_key = key; udata.ret_obj = NULL; @@ -1845,186 +737,91 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) FUNC_LEAVE_API(ret_value) } /* end H5Isearch() */ - /*------------------------------------------------------------------------- - * Function: H5I__iterate_cb + * Function: H5I__iterate_pub_cb * - * Purpose: Callback routine for H5I_iterate, invokes "user" callback - * function, and then sets return value, based on the result of - * that callback. + * Purpose: Callback routine for H5Iiterate, when it calls + * H5I_iterate. Calls "user" callback search function, and + * then sets return value, based on the result of that + * callback. * * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) * Failure: H5_ITER_ERROR (-1) * + * Programmer: Neil Fortner + * Friday, October 11, 2013 + * *------------------------------------------------------------------------- */ static int -H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val = FAIL; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR - /* Only invoke the callback function if this ID is visible externally and - * its reference count is positive. - */ - if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; - - /* Invoke callback function */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ + /* Invoke the callback */ + cb_ret_val = (*udata->op)(id, udata->op_data); - /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } + /* Set the return value based on the callback's return value */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + else + ret_value = H5_ITER_CONT; /* continue iteration */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__iterate_cb() */ +} /* end H5I__iterate_pub_cb() */ - /*------------------------------------------------------------------------- - * Function: H5I_iterate - * - * Purpose: Apply function FUNC to each member of type TYPE (with - * non-zero application reference count if app_ref is TRUE). - * Stop if FUNC returns a non zero value (i.e. anything - * other than H5_ITER_CONT). + * Function: H5Iiterate * - * If FUNC returns a positive value (i.e. H5_ITER_STOP), - * return SUCCEED. + * Purpose: Call the callback funciton 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 + * H5Iiterate will return the value returned by op. A + * negative return from op will cause the iteration to stop + * and H5Iiterate will return failure. A zero return from op + * will allow iteration to continue, as long as there are + * other ids remaining in type. * - * If FUNC returns a negative value (i.e. H5_ITER_ERROR), - * return FAIL. - * - * The FUNC should take a pointer to the object and the - * udata as arguments and return non-zero to terminate - * siteration, and zero to continue. + * Limitation: Currently there is no way to start searching from where a + * previous search left off. * - * Limitation: Currently there is no way to start the iteration from - * where a previous iteration left off. + * Return: The last value returned by op * - * Return: SUCCEED/FAIL + * Programmer: Neil Fortner + * Friday, October 11, 2013 * *------------------------------------------------------------------------- */ herr_t -H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) -{ - H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - - /* Only iterate through ID list if it is initialized and there are IDs in type */ - if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { - H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - herr_t iter_status; /* Iteration status */ - - /* Set up iterator user data */ - iter_udata.user_func = func; - iter_udata.user_udata = udata; - iter_udata.app_ref = app_ref; - - /* Iterate over IDs */ - if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_iterate() */ - - -/*------------------------------------------------------------------------- - * Function: H5I__find_id - * - * Purpose: Given an object ID find the info struct that describes the - * object. - * - * Return: Success: A pointer to the object's info struct. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static H5I_id_info_t * -H5I__find_id(hid_t id) -{ - H5I_type_t type; /*ID's type */ - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Check arguments */ - type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) - HGOTO_DONE(NULL) - type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr || type_ptr->init_count <= 0) - HGOTO_DONE(NULL) - - /* Locate the ID node for the ID */ - ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__find_id() */ - - -/*------------------------------------------------------------------------- - * Function: H5Iget_name - * - * Purpose: Gets a name of an object from its ID. - * - * Return: Success: The length of the name - * - * Failure: -1 - * - * Comments: Public function - * If 'name' is non-NULL then write up to 'size' bytes into that - * buffer and always return the length of the entry name. - * Otherwise 'size' is ignored and the function does not store the name, - * just returning the number of characters required to store the name. - * If an error occurs then the buffer pointed to by 'name' (NULL or non-NULL) - * is unchanged and the function returns a negative value. - * If a zero is returned for the name's length, then there is no name - * associated with the ID. - * - *------------------------------------------------------------------------- - */ -ssize_t -H5Iget_name(hid_t id, char *name/*out*/, size_t size) +H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data) { - H5G_loc_t loc; /* Object location */ - ssize_t ret_value; /* Return value */ + H5I_iterate_pub_ud_t int_udata; /* Internal user data */ + herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_API((-1)) - H5TRACE3("Zs", "ixz", id, name, size); + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "Itx*x", type, op, op_data); - /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") + /* Set up udata struct */ + int_udata.op = op; + int_udata.op_data = op_data; - /* Retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, NULL)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") + /* Note that H5I_iterate returns an error code. We ignore it + * here, as we can't do anything with it without revising the API. + */ + if ((ret_value = H5I_iterate(type, H5I__iterate_pub_cb, &int_udata, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "can't iterate over ids") done: FUNC_LEAVE_API(ret_value) -} /* end H5Iget_name() */ +} /* end H5Iiterate() */ - /*------------------------------------------------------------------------- * Function: H5Iget_file_id * @@ -2040,8 +837,8 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size) hid_t H5Iget_file_id(hid_t obj_id) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); @@ -2050,8 +847,16 @@ H5Iget_file_id(hid_t obj_id) type = H5I_TYPE(obj_id); /* Call internal function */ - if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - if((ret_value = H5I_get_file_id(obj_id, type)) < 0) + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || + H5I_ATTR == type) { + H5VL_object_t *vol_obj; /* Object of obj_id */ + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get the file ID */ + if ((ret_value = H5F_get_file_id(vol_obj, type, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") } else @@ -2061,154 +866,50 @@ H5Iget_file_id(hid_t obj_id) FUNC_LEAVE_API(ret_value) } /* end H5Iget_file_id() */ - -/*------------------------------------------------------------------------- - * Function: H5I_get_file_id - * - * Purpose: The private version of H5Iget_file_id(), obtains the file - * ID given an object ID. - * - * Return: Success: The file ID associated with the object - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -hid_t -H5I_get_file_id(hid_t obj_id, H5I_type_t type) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Process based on object type */ - if (type == H5I_FILE) { - /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") - - /* Set return value */ - ret_value = obj_id; - } - else { - H5G_loc_t loc; /* Location of object */ - - /* Get the object location information */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") - - /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_file_id() */ - - /*------------------------------------------------------------------------- - * Function: H5I__id_dump_cb - * - * Purpose: Dump the contents of an ID to stderr for debugging. + * Function: H5Iget_name * - * Return: H5_ITER_CONT (always) + * Purpose: Gets a name of an object from its ID. * - *------------------------------------------------------------------------- - */ -static int -H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) -{ - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; /* Path to file object */ - - FUNC_ENTER_STATIC_NOERR - - HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); - HDfprintf(stderr, " count = %u\n", item->count); - HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); - - /* Get the group location, so we get get the name */ - switch (type) { - case H5I_GROUP: - { - path = H5G_nameof((const H5G_t *)item->obj_ptr); - break; - } - case H5I_DATASET: - { - path = H5D_nameof((const H5D_t *)item->obj_ptr); - break; - } - case H5I_DATATYPE: - { - path = H5T_nameof((const H5T_t *)item->obj_ptr); - break; - } - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - break; /* Other types of IDs are not stored in files */ - } - - if (path) { - if (path->user_path_r) - HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); - if (path->full_path_r) - HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); - } - - FUNC_LEAVE_NOAPI(H5_ITER_CONT) -} /* end H5I__id_dump_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5I_dump_ids_for_type + * Return: Success: The length of the name * - * Purpose: Dump the contents of a type to stderr for debugging. + * Failure: -1 * - * Return: SUCCEED/FAIL + * Notes: + * If 'name' is non-NULL then write up to 'size' bytes into that + * buffer and always return the length of the entry name. + * Otherwise 'size' is ignored and the function does not store the name, + * just returning the number of characters required to store the name. + * If an error occurs then the buffer pointed to by 'name' (NULL or non-NULL) + * is unchanged and the function returns a negative value. + * If a zero is returned for the name's length, then there is no name + * associated with the ID. * *------------------------------------------------------------------------- */ -herr_t -H5I_dump_ids_for_type(H5I_type_t type) +ssize_t +H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5I_id_type_t *type_ptr = NULL; + H5VL_object_t * vol_obj = NULL; /* Object stored in ID */ + H5VL_loc_params_t loc_params; + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOERR - - HDfprintf(stderr, "Dumping ID type %d\n", (int)type); - type_ptr = H5I_id_type_list_g[type]; - - if(type_ptr) { + FUNC_ENTER_API((-1)) + H5TRACE3("Zs", "ixz", id, name, size); - /* Header */ - HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); - HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); - HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); + /* Get the object pointer */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") - /* List */ - if(type_ptr->id_count > 0) { - HDfprintf(stderr, " List:\n"); - H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); - } - } - else - HDfprintf(stderr, "Global type info/tracking pointer for that type is NULL\n"); + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5I_dump_ids_for_type() */ + /* Retrieve object's name */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, name, size) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Iget_name() */ diff --git a/src/H5Idbg.c b/src/H5Idbg.c new file mode 100644 index 00000000000..71937e85de5 --- /dev/null +++ b/src/H5Idbg.c @@ -0,0 +1,204 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * H5Idbg.c - Debugging routines for handling IDs + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5I__id_dump_cb + * + * Purpose: Dump the contents of an ID to stderr for debugging. + * + * Return: H5_ITER_CONT (always) + * + *------------------------------------------------------------------------- + */ +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_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 */ + + FUNC_ENTER_STATIC_NOERR + + HDfprintf(stderr, " id = %" PRIdHID "\n", info->id); + HDfprintf(stderr, " count = %u\n", info->count); + HDfprintf(stderr, " obj = 0x%8p\n", info->object); + HDfprintf(stderr, " marked = %d\n", info->marked); + + /* Get the group location, so we get get the name */ + switch (type) { + case H5I_GROUP: { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object; + + object = H5VL_object_data(vol_obj); + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5G_nameof((const H5G_t *)object); + break; + } + + case H5I_DATASET: { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object; + + object = H5VL_object_data(vol_obj); + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5D_nameof((const H5D_t *)object); + break; + } + + case H5I_DATATYPE: { + 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 */ + H5_GCC_DIAG_ON("cast-qual") + + path = H5T_nameof((const H5T_t *)object); + break; + } + + /* TODO: Maps will have to be added when they are supported in the + * native VOL connector. + */ + case H5I_MAP: + + 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: + break; /* Other types of IDs are not stored in files */ + } + + if (path) { + if (path->user_path_r) + HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); + if (path->full_path_r) + HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); + } + + FUNC_LEAVE_NOAPI(H5_ITER_CONT) +} /* end H5I__id_dump_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dump_ids_for_type + * + * Purpose: Dump the contents of a type to stderr for debugging. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_dump_ids_for_type(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; + + FUNC_ENTER_NOAPI_NOERR + + HDfprintf(stderr, "Dumping ID type %d\n", (int)type); + type_info = H5I_type_info_array_g[type]; + + if (type_info) { + + H5I_id_info_t *item = NULL; + H5I_id_info_t *tmp = NULL; + + /* Header */ + HDfprintf(stderr, " init_count = %u\n", type_info->init_count); + HDfprintf(stderr, " reserved = %u\n", type_info->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_info->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_info->nextid); + + /* List */ + if (type_info->id_count > 0) { + HDfprintf(stderr, " List:\n"); + /* Normally we care about the callback's return value + * (H5I_ITER_CONT, etc.), but this is an iteration over all + * the IDs so we don't care. + * + * XXX: Update this to emit an error message on errors? + */ + HDfprintf(stderr, " (HASH TABLE)\n"); + HASH_ITER(hh, type_info->hash_table, item, tmp) + { + H5I__id_dump_cb((void *)item, NULL, (void *)&type); + } + } + } + else + HDfprintf(stderr, "Global type info/tracking pointer for that type is NULL\n"); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5I_dump_ids_for_type() */ diff --git a/src/H5Iint.c b/src/H5Iint.c new file mode 100644 index 00000000000..e512d4b613c --- /dev/null +++ b/src/H5Iint.c @@ -0,0 +1,1524 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * H5Iint.c - Private routines for handling IDs + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/* Combine a Type number and an ID index into an ID */ +#define H5I_MAKE(g, i) ((((hid_t)(g)&TYPE_MASK) << ID_BITS) | ((hid_t)(i)&ID_MASK)) + +/******************/ +/* Local Typedefs */ +/******************/ + +/* User data for iterator callback for retrieving an ID corresponding to an object pointer */ +typedef struct { + const void *object; /* object pointer to search for */ + H5I_type_t obj_type; /* type of object we are searching for */ + hid_t ret_id; /* ID returned */ +} H5I_get_id_ud_t; + +/* 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 */ + 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; + +/* User data for H5I__clear_type_cb */ +typedef struct { + H5I_type_info_t *type_info; /* Pointer to the type's info to be cleared */ + hbool_t force; /* Whether to always remove the ID */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ +} H5I_clear_type_ud_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +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 int H5I__find_id_cb(void *_item, void *_key, void *_udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/* Declared extern in H5Ipkg.h and documented there */ +H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; +int H5I_next_type_g = (int)H5I_NTYPES; + +/* Declare a free list to manage the H5I_id_info_t struct */ +H5FL_DEFINE_STATIC(H5I_id_info_t); + +/* Whether deletes are actually marks (for mark-and-sweep) */ +hbool_t H5I_marking_g = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5I_term_package + * + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. + * + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +int +H5I_term_package(void) +{ + int in_use = 0; /* Number of ID types still in use */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ + int i; + + /* Count the number of types still in use */ + for (i = 0; i < H5I_next_type_g; i++) + if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + in_use++; + + /* If no types are still being used then clean up */ + if (0 == in_use) { + for (i = 0; i < H5I_next_type_g; i++) { + type_info = H5I_type_info_array_g[i]; + if (type_info) { + HDassert(NULL == type_info->hash_table); + type_info = H5MM_xfree(type_info); + H5I_type_info_array_g[i] = NULL; + in_use++; + } + } + + /* Mark interface closed */ + if (0 == in_use) + H5_PKG_INIT_VAR = FALSE; + } + } + + FUNC_LEAVE_NOAPI(in_use) +} /* end H5I_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register_type + * + * Purpose: Creates a new type of ID's to give out. + * The class is initialized or its reference count is incremented + * (if it is already initialized). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_register_type(const H5I_class_t *cls) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type*/ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(cls); + HDassert(cls->type > 0 && (int)cls->type < H5I_MAX_NUM_TYPES); + + /* Initialize the type */ + if (NULL == H5I_type_info_array_g[cls->type]) { + /* Allocate the type information for new type */ + if (NULL == (type_info = (H5I_type_info_t *)H5MM_calloc(sizeof(H5I_type_info_t)))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") + H5I_type_info_array_g[cls->type] = type_info; + } + else { + /* Get the pointer to the existing type */ + type_info = H5I_type_info_array_g[cls->type]; + } + + /* Initialize the ID type structure for new types */ + if (type_info->init_count == 0) { + type_info->cls = cls; + type_info->id_count = 0; + type_info->nextid = cls->reserved; + type_info->last_id_info = NULL; + type_info->hash_table = NULL; + } + + /* Increment the count of the times this type has been initialized */ + type_info->init_count++; + +done: + /* Clean up on error */ + if (ret_value < 0) + if (type_info) + H5MM_free(type_info); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I_nmembers + * + * Purpose: Returns the number of members in a type. + * + * Return: Success: Number of members; zero if the type is empty + * or has been deleted. + * + * Failure: Negative + * + * Programmer: Robb Matzke + * Wednesday, March 24, 1999 + * + *------------------------------------------------------------------------- + */ +int64_t +H5I_nmembers(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + int64_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Validate parameter */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + if (NULL == (type_info = H5I_type_info_array_g[type]) || type_info->init_count <= 0) + HGOTO_DONE(0); + + /* Set return value */ + H5_CHECKED_ASSIGN(ret_value, int64_t, type_info->id_count, uint64_t); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_nmembers() */ + +/*------------------------------------------------------------------------- + * Function: H5I__unwrap + * + * Purpose: Unwraps the object pointer for the 'item' that corresponds + * to an ID. + * + * Return: Pointer to the unwrapped pointer (can't fail) + * + * Programmer: Quincey Koziol + * Friday, October 19, 2018 + * + *------------------------------------------------------------------------- + */ +static void * +H5I__unwrap(void *object, H5I_type_t type) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(object); + + /* The stored object pointer might be an H5VL_object_t, in which + * case we'll need to get the wrapped object struct (H5F_t *, etc.). + */ + if (H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *vol_obj; + + vol_obj = (const H5VL_object_t *)object; + ret_value = H5VL_object_data(vol_obj); + } + else if (H5I_DATATYPE == type) { + H5T_t *dt = (H5T_t *)object; + + ret_value = (void *)H5T_get_actual_type(dt); + } + else + ret_value = object; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__unwrap() */ + +/*------------------------------------------------------------------------- + * Function: H5I_clear_type + * + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. + * + * Return: SUCCEED/FAIL + * + * Programmer: Robb Matzke + * Wednesday, March 24, 1999 + * + *------------------------------------------------------------------------- + */ +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; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Validate parameters */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + udata.type_info = H5I_type_info_array_g[type]; + if (udata.type_info == NULL || udata.type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Finish constructing udata */ + udata.force = force; + udata.app_ref = app_ref; + + /* Clearing a type is done in two phases (mark-and-sweep). This is because + * the type's free callback can free other IDs, potentially corrupting + * the data structure during the traversal. + */ + + /* Set marking flag */ + H5I_marking_g = TRUE; + + /* Mark nodes for deletion */ + HASH_ITER(hh, udata.type_info->hash_table, item, tmp) + { + if (!item->marked) + if (H5I__mark_node((void *)item, NULL, (void *)&udata) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed while clearing the ID type") + } + + /* Unset marking flag */ + H5I_marking_g = FALSE; + + /* Perform sweep */ + HASH_ITER(hh, udata.type_info->hash_table, item, tmp) + { + if (item->marked) { + HASH_DELETE(hh, udata.type_info->hash_table, item); + item = H5FL_FREE(H5I_id_info_t, item); + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_clear_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I__mark_node + * + * Purpose: Attempts to mark the node for freeing and calls the free + * function for the object, if any + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * Friday, July 10, 2015 + * + *------------------------------------------------------------------------- + */ +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_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ + hbool_t mark = FALSE; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(info); + HDassert(udata); + HDassert(udata->type_info); + + /* Do nothing to the object if the reference count is larger than + * one and forcing is off. + */ + if (udata->force || (info->count - (!udata->app_ref * info->app_count)) <= 1) { + /* Check for a 'free' function and call it, if it exists */ + H5_GCC_DIAG_OFF("cast-qual") + if (udata->type_info->cls->free_func && + (udata->type_info->cls->free_func)((void *)info->object) < 0) { + if (udata->force) { +#ifdef H5I_DEBUG + if (H5DEBUG(I)) { + HDfprintf(H5DEBUG(I), + "H5I: free type=%d obj=0x%08lx " + "failure ignored\n", + (int)udata->type_info->cls->type, (unsigned long)(info->object)); + } +#endif /* H5I_DEBUG */ + + /* Indicate node should be removed from list */ + mark = TRUE; + } + } + else { + /* Indicate node should be removed from list */ + mark = TRUE; + } + H5_GCC_DIAG_ON("cast-qual") + + /* Remove ID if requested */ + if (mark) { + /* Mark ID for deletion */ + info->marked = TRUE; + + /* Decrement the number of IDs in the type */ + udata->type_info->id_count--; + } + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5I__mark_node() */ + +/*------------------------------------------------------------------------- + * Function: H5I__destroy_type + * + * Purpose: Destroys a type along with all IDs in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. + * + * Return: SUCCEED/FAIL + * + * Programmer: Nathaniel Furrer + * James Laird + * + *------------------------------------------------------------------------- + */ +herr_t +H5I__destroy_type(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Validate parameter */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Close/clear/destroy all IDs for this type */ + H5E_BEGIN_TRY + { + H5I_clear_type(type, TRUE, FALSE); + } + H5E_END_TRY /* don't care about errors */ + + /* Check if we should release the ID class */ + if (type_info->cls->flags & H5I_CLASS_IS_APPLICATION) + type_info->cls = H5MM_xfree_const(type_info->cls); + + HASH_CLEAR(hh, type_info->hash_table); + type_info->hash_table = NULL; + + type_info = H5MM_xfree(type_info); + + H5I_type_info_array_g[type] = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__destroy_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register + * + * Purpose: Registers an OBJECT in a TYPE and returns an ID for it. + * This routine does _not_ check for unique-ness of the objects, + * if you register an object twice, you will get two different + * IDs for it. This routine does make certain that each ID in a + * type is unique. IDs are created by getting a unique number + * for the type the ID is in and incorporating the type into + * the ID which is returned to the user. + * + * Return: Success: New object ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + hid_t new_id = H5I_INVALID_HID; /* New ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check arguments */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + type_info = H5I_type_info_array_g[type]; + if ((NULL == type_info) || (type_info->init_count <= 0)) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type") + if (NULL == (info = H5FL_CALLOC(H5I_id_info_t))) + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") + + /* Create the struct & its ID */ + new_id = H5I_MAKE(type, type_info->nextid); + info->id = new_id; + info->count = 1; /* initial reference count */ + info->app_count = !!app_ref; + info->object = object; + info->marked = FALSE; + + /* Insert into the type */ + HASH_ADD(hh, type_info->hash_table, id, sizeof(hid_t), info); + type_info->id_count++; + type_info->nextid++; + + /* Sanity check for the 'nextid' getting too large and wrapping around */ + HDassert(type_info->nextid <= ID_MASK); + + /* Set the most recent ID to this object */ + type_info->last_id_info = info; + + /* Set return value */ + ret_value = new_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register() */ + +/*------------------------------------------------------------------------- + * Function: H5I_register_using_existing_id + * + * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. + * This routine will check to ensure the supplied ID is not already + * in use, and ensure that it is a valid ID for the given type, + * but will NOT check to ensure the OBJECT is not already + * registered (thus, it is possible to register one object under + * multiple IDs). + * + * NOTE: Intended for use in refresh calls, where we have to close + * and re-open the underlying data, then hook the object back + * up to the original ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(object); + + /* Make sure ID is not already in use */ + if (NULL != (info = H5I__find_id(existing_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") + + /* Make sure type number is valid */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + + /* Get type pointer from list of types */ + type_info = H5I_type_info_array_g[type]; + + if (NULL == type_info || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Make sure requested ID belongs to object's type */ + if (H5I_TYPE(existing_id) != type) + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") + + /* Allocate new structure to house this ID */ + if (NULL == (info = H5FL_CALLOC(H5I_id_info_t))) + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Create the struct & insert requested ID */ + info->id = existing_id; + info->count = 1; /* initial reference count*/ + info->app_count = !!app_ref; + info->object = object; + info->marked = FALSE; + + /* Insert into the type */ + HASH_ADD(hh, type_info->hash_table, id, sizeof(hid_t), info); + type_info->id_count++; + + /* Set the most recent ID to this object */ + type_info->last_id_info = info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_register_using_existing_id() */ + +/*------------------------------------------------------------------------- + * Function: H5I_subst + * + * Purpose: Substitute a new object pointer for the specified ID. + * + * Return: Success: Non-NULL previous object pointer associated + * with the specified ID. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Saturday, February 27, 2010 + * + *------------------------------------------------------------------------- + */ +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 */ + + FUNC_ENTER_NOAPI(NULL) + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") + + /* Get the old object pointer to return */ + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + H5_GCC_DIAG_ON("cast-qual") + + /* Set the new object pointer for the ID */ + info->object = new_object; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_subst() */ + +/*------------------------------------------------------------------------- + * Function: H5I_object + * + * Purpose: Find an object pointer for the specified ID. + * + * Return: Success: Non-NULL object pointer associated with the + * specified ID + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5I_object(hid_t id) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR + + /* General lookup of the 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) */ + H5_GCC_DIAG_ON("cast-qual") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_object() */ + +/*------------------------------------------------------------------------- + * Function: H5I_object_verify + * + * Purpose: Find an object pointer for the specified ID, verifying that + * its in a particular type. + * + * Return: Success: Non-NULL object pointer associated with the + * specified ID. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Wednesday, July 31, 2002 + * + *------------------------------------------------------------------------- + */ +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 */ + + FUNC_ENTER_NOAPI_NOERR + + HDassert(type >= 1 && (int)type < H5I_next_type_g); + + /* Verify that the type of the ID is correct & lookup the ID */ + 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) */ + H5_GCC_DIAG_ON("cast-qual") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5I_object_verify() */ + +/*------------------------------------------------------------------------- + * Function: H5I_get_type + * + * Purpose: Given an object ID return the type to which it + * belongs. The ID need not be the ID of an object which + * currently exists because the type number is encoded + * in the object ID. + * + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID + * + * Programmer: Robb Matzke + * Friday, February 19, 1999 + * + *------------------------------------------------------------------------- + */ +H5I_type_t +H5I_get_type(hid_t id) +{ + H5I_type_t ret_value = H5I_BADID; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR + + if (id > 0) + ret_value = H5I_TYPE(id); + + HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type_g); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_type() */ + +/*------------------------------------------------------------------------- + * Function: H5I_is_file_object + * + * Purpose: Convenience function to determine if an ID represents + * a file object. + * + * In H5O calls, you can't use object_verify to ensure + * the ID was of the correct class since there's no + * H5I_OBJECT ID class. + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5I_is_file_object(hid_t id) +{ + H5I_type_t type = H5I_get_type(id); + htri_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL); + + /* Fail if the ID type is out of range */ + if (type < 1 || type >= H5I_NTYPES) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID type out of range"); + + /* Return TRUE if the ID is a file object (dataset, group, map, or committed + * datatype), FALSE otherwise. + */ + if (H5I_DATASET == type || H5I_GROUP == type || H5I_MAP == type) + ret_value = TRUE; + else if (H5I_DATATYPE == type) { + + H5T_t *dt = NULL; + + if (NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct"); + + ret_value = H5T_is_named(dt); + } + else + ret_value = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5I_is_file_object() */ + +/*------------------------------------------------------------------------- + * Function: H5I__remove_verify + * + * Purpose: Removes the specified ID from its type, first checking that + * the ID's type is the same as the ID type supplied as an argument + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + * Programmer: James Laird + * Nat Furrer + * + *------------------------------------------------------------------------- + */ +void * +H5I__remove_verify(hid_t id, H5I_type_t type) +{ + void *ret_value = NULL; /*return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Argument checking will be performed by H5I_remove() */ + + /* Verify that the type of the ID is correct */ + if (type == H5I_TYPE(id)) + ret_value = H5I_remove(id); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__remove_verify() */ + +/*------------------------------------------------------------------------- + * Function: H5I__remove_common + * + * Purpose: Common code to remove a specified ID from its type. + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + * Programmer: Quincey Koziol + * October 3, 2013 + * + *------------------------------------------------------------------------- + */ +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 */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(type_info); + + /* Delete or mark the node */ + HASH_FIND(hh, type_info->hash_table, &id, sizeof(hid_t), info); + if (info) { + HDassert(!info->marked); + if (!H5I_marking_g) + HASH_DELETE(hh, type_info->hash_table, info); + else + info->marked = TRUE; + } + else + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from hash table") + + /* Check if this ID was the last one accessed */ + if (type_info->last_id_info == info) + type_info->last_id_info = NULL; + + H5_GCC_DIAG_OFF("cast-qual") + ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + H5_GCC_DIAG_ON("cast-qual") + + if (!H5I_marking_g) + info = H5FL_FREE(H5I_id_info_t, info); + + /* Decrement the number of IDs in the type */ + (type_info->id_count)--; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__remove_common() */ + +/*------------------------------------------------------------------------- + * Function: H5I_remove + * + * Purpose: Removes the specified ID from its type. + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +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 */ + + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ + type = H5I_TYPE(id); + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") + + /* Remove the node from the type */ + if (NULL == (ret_value = H5I__remove_common(type_info, id))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_remove() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_ref + * + * Purpose: Decrements the number of references outstanding for an ID. + * This will fail if the type is not a reference counted type. + * The ID type's 'free' function will be called for the ID + * if the reference count for the ID reaches 0 and a free + * function has been defined at type creation time. + * + * Return: Success: New reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_ref(hid_t id) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* If this is the last reference to the object then invoke the type's + * free method on the object. If the free method is undefined or + * successful then remove the object from the type; otherwise leave + * the object in the type without decrementing the reference + * count. If the reference count is more than one then decrement the + * reference count without calling the free method. + * + * Beware: the free method may call other H5I functions. + * + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) + */ + if (1 == info->count) { + H5I_type_info_t *type_info; /*ptr to the type */ + + /* Get the ID's type */ + type_info = H5I_type_info_array_g[H5I_TYPE(id)]; + + H5_GCC_DIAG_OFF("cast-qual") + /* (Casting away const OK -QAK) */ + if (!type_info->cls->free_func || (type_info->cls->free_func)((void *)info->object) >= 0) { + /* Remove the node from the type */ + if (NULL == H5I__remove_common(type_info, id)) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") + ret_value = 0; + } /* end if */ + else + ret_value = -1; + H5_GCC_DIAG_ON("cast-qual") + } /* end if */ + else { + --(info->count); + ret_value = (int)info->count; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref + * + * Purpose: Wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. + * + * Return: Success: New app. reference count + * Failure: -1 + * + * Programmer: Quincey Koziol + * Sept 16, 2010 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref(hid_t id) +{ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call regular decrement reference count routine */ + if ((ret_value = H5I_dec_ref(id)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") + + /* Check if the ID still exists */ + if (ret_value > 0) { + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Adjust app_ref */ + --(info->app_count); + HDassert(info->count >= info->app_count); + + /* Set return value */ + ret_value = (int)info->app_count; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref_always_close + * + * Purpose: Wrapper for case of always closing the ID, even when the free + * routine fails + * + * Return: Success: New app. reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref_always_close(hid_t id) +{ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call application decrement reference count routine */ + ret_value = H5I_dec_app_ref(id); + + /* Check for failure */ + if (ret_value < 0) { + /* + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) + */ + H5I_remove(id); + + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref_always_close() */ + +/*------------------------------------------------------------------------- + * Function: H5I_inc_ref + * + * Purpose: Increment the reference count for an object. + * + * Return: Success: The new reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_inc_ref(hid_t id, hbool_t app_ref) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID info */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Adjust reference counts */ + ++(info->count); + if (app_ref) + ++(info->app_count); + + /* Set return value */ + ret_value = (int)(app_ref ? info->app_count : info->count); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_inc_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_get_ref + * + * Purpose: Retrieve the reference count for an object. + * + * Return: Success: The reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_get_ref(hid_t id, hbool_t app_ref) +{ + H5I_id_info_t *info = NULL; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + /* Sanity check */ + HDassert(id >= 0); + + /* General lookup of the ID */ + if (NULL == (info = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") + + /* Set return value */ + ret_value = (int)(app_ref ? info->app_count : info->count); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__inc_type_ref + * + * Purpose: Increment the reference count for an ID type. + * + * Return: Success: The new reference count + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +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 + + /* Sanity check */ + HDassert(type > 0 && (int)type < H5I_next_type_g); + + /* Check arguments */ + type_info = H5I_type_info_array_g[type]; + if (NULL == type_info) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Set return value */ + ret_value = (int)(++(type_info->init_count)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__inc_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dec_type_ref + * + * Purpose: Decrements the reference count on an entire type of IDs. + * If the type reference count becomes zero then the type is + * destroyed along with all IDs in that type regardless of + * their reference counts. Destroying IDs involves calling + * the free-func for each ID's object and then adding the ID + * struct to the ID free list. + * Returns the number of references to the type on success; a + * return value of 0 means that the type will have to be + * re-initialized before it can be used again (and should probably + * be set to H5I_UNINIT). + * + * Return: Success: Number of references to type + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_type_ref(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI((-1)) + + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") + + type_info = H5I_type_info_array_g[type]; + if (type_info == NULL || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Decrement the number of users of the ID type. If this is the + * last user of the type then release all IDs from the type and + * free all memory it used. The free function is invoked for each ID + * being freed. + */ + if (1 == type_info->init_count) { + H5I__destroy_type(type); + ret_value = 0; + } + else { + --(type_info->init_count); + ret_value = (herr_t)type_info->init_count; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__get_type_ref + * + * Purpose: Retrieve the reference count for an ID type. + * + * Return: Success: The reference count + * + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +int +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 + + /* Sanity check */ + HDassert(type >= 0); + + /* Check arguments */ + type_info = H5I_type_info_array_g[type]; + if (!type_info) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") + + /* Set return value */ + ret_value = (int)type_info->init_count; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__get_type_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5I__iterate_cb + * + * Purpose: Callback routine for H5I_iterate, invokes "user" callback + * function, and then sets return value, based on the result of + * that callback. + * + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) + * + *------------------------------------------------------------------------- + */ +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_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Only invoke the callback function if this ID is visible externally and + * its reference count is positive. + */ + if ((!udata->app_ref) || (info->app_count > 0)) { + H5I_type_t type = udata->obj_type; + void * object; + herr_t cb_ret_val; + + /* The stored object pointer might be an H5VL_object_t, in which + * case we'll need to get the wrapped object struct (H5F_t *, etc.). + */ + H5_GCC_DIAG_OFF("cast-qual") + object = H5I__unwrap((void *)info->object, type); /* Casting away const OK */ + H5_GCC_DIAG_ON("cast-qual") + + /* Invoke callback function */ + cb_ret_val = (*udata->user_func)((void *)object, info->id, udata->user_udata); + + /* Set the return value based on the callback's return value */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__iterate_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_iterate + * + * Purpose: Apply function FUNC to each member of type TYPE (with + * non-zero application reference count if app_ref is TRUE). + * Stop if FUNC returns a non zero value (i.e. anything + * other than H5_ITER_CONT). + * + * If FUNC returns a positive value (i.e. H5_ITER_STOP), + * return SUCCEED. + * + * If FUNC returns a negative value (i.e. H5_ITER_ERROR), + * return FAIL. + * + * The FUNC should take a pointer to the object and the + * udata as arguments and return non-zero to terminate + * siteration, and zero to continue. + * + * Limitation: Currently there is no way to start the iteration from + * where a previous iteration left off. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + type_info = H5I_type_info_array_g[type]; + + /* 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; + + /* Set up iterator user data */ + iter_udata.user_func = func; + iter_udata.user_udata = udata; + iter_udata.app_ref = app_ref; + iter_udata.obj_type = type; + + /* Iterate over IDs */ + HASH_ITER(hh, type_info->hash_table, item, tmp) + { + if (!item->marked) { + int ret = H5I__iterate_cb((void *)item, NULL, (void *)&iter_udata); + if (H5_ITER_ERROR == ret) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + if (H5_ITER_STOP == ret) + break; + } + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_iterate() */ + +/*------------------------------------------------------------------------- + * Function: H5I__find_id + * + * Purpose: Given an object ID find the info struct that describes the + * object. + * + * Return: Success: A pointer to the object's info struct. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5I_id_info_t * +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 */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ + type = H5I_TYPE(id); + if (type <= H5I_BADID || (int)type >= H5I_next_type_g) + HGOTO_DONE(NULL) + type_info = H5I_type_info_array_g[type]; + if (!type_info || type_info->init_count <= 0) + HGOTO_DONE(NULL) + + /* Check for same ID as we have looked up last time */ + if (type_info->last_id_info && type_info->last_id_info->id == id) + id_info = type_info->last_id_info; + else { + HASH_FIND(hh, type_info->hash_table, &id, sizeof(hid_t), id_info); + + /* Remember this ID */ + type_info->last_id_info = id_info; + } + + /* Set return value */ + ret_value = id_info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__find_id() */ + +/*------------------------------------------------------------------------- + * Function: H5I__find_id_cb + * + * Purpose: Callback for searching for an ID with a specific pointer + * + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) + * + *------------------------------------------------------------------------- + */ +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_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; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(info); + HDassert(udata); + + /* Get a pointer to the VOL connector's data */ + H5_GCC_DIAG_OFF("cast-qual") + object = H5I__unwrap((void *)info->object, type); /* Casting away const OK */ + H5_GCC_DIAG_ON("cast-qual") + + /* Check for a match */ + if (object == udata->object) { + udata->ret_id = info->id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__find_id_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_find_id + * + * Purpose: Return the ID of an object by searching through the ID list + * for the type. + * + * Return: SUCCEED/FAIL + * (id will be set to H5I_INVALID_HID on errors or not found) + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_find_id(const void *object, H5I_type_t type, hid_t *id) +{ + H5I_type_info_t *type_info = NULL; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(id); + + *id = H5I_INVALID_HID; + + type_info = H5I_type_info_array_g[type]; + if (!type_info || type_info->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* 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; + + /* Set up iterator user data */ + udata.object = object; + udata.obj_type = type; + udata.ret_id = H5I_INVALID_HID; + + /* Iterate over IDs for the ID type */ + HASH_ITER(hh, type_info->hash_table, item, tmp) + { + int ret = H5I__find_id_cb((void *)item, NULL, (void *)&udata); + if (H5_ITER_ERROR == ret) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + if (H5_ITER_STOP == ret) + break; + } + + *id = udata.ret_id; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_find_id() */ diff --git a/src/H5Imodule.h b/src/H5Imodule.h index 9c56842d080..a2174d735d0 100644 --- a/src/H5Imodule.h +++ b/src/H5Imodule.h @@ -5,29 +5,33 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 + * Programmer: Quincey Koziol + * Saturday, September 12, 2015 * - * Purpose: This file contains declarations which define macros for the - * H5I package. Including this header means that the source file - * is part of the H5I package. + * Purpose: This file contains declarations which define macros for the + * H5I package. Including this header means that the source file + * is part of the H5I package. */ -#ifndef _H5Imodule_H -#define _H5Imodule_H +#ifndef H5Imodule_H +#define H5Imodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error - * reporting macros. + * reporting macros. */ #define H5I_MODULE -#define H5_MY_PKG H5I -#define H5_MY_PKG_ERR H5E_ATOM -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5I +#define H5_MY_PKG_ERR H5E_ATOM +#define H5_MY_PKG_INIT NO -#endif /* _H5Imodule_H */ +/**\defgroup H5I H5I + * \brief Identifier Interface + * \todo Describe concisely what the functions in this module are about. + */ +#endif /* H5Imodule_H */ diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 54b7b433e01..1bcea26cb51 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,52 +23,101 @@ #error "Do not include this file outside the H5I package!" #endif -#ifndef _H5Ipkg_H -#define _H5Ipkg_H +#ifndef H5Ipkg_H +#define H5Ipkg_H /* Get package's private header */ #include "H5Iprivate.h" -/* Other private headers needed by this file */ +/* 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 */ /**************************/ /* - * Number of bits to use for ID Type in each atom. Increase if more types + * Number of bits to use for ID Type in each ID. Increase if more types * are needed (though this will decrease the number of available IDs per * type). This is the only number that must be changed since all other bit * field sizes and masks are calculated from TYPE_BITS. */ -#define TYPE_BITS 7 -#define TYPE_MASK (((hid_t)1 << TYPE_BITS) - 1) +#define TYPE_BITS 7 +#define TYPE_MASK (((hid_t)1 << TYPE_BITS) - 1) #define H5I_MAX_NUM_TYPES TYPE_MASK /* - * Number of bits to use for the Atom index in each atom (assumes 8-bit + * Number of bits to use for the ID index in each ID (assumes 8-bit * bytes). We don't use the sign bit. */ -#define ID_BITS ((sizeof(hid_t) * 8) - (TYPE_BITS + 1)) -#define ID_MASK (((hid_t)1 << ID_BITS) - 1) - -/* Map an atom to an ID type number */ -#define H5I_TYPE(a) ((H5I_type_t)(((hid_t)(a) >> ID_BITS) & TYPE_MASK)) +#define ID_BITS ((sizeof(hid_t) * 8) - (TYPE_BITS + 1)) +#define ID_MASK (((hid_t)1 << ID_BITS) - 1) +/* Map an ID to an ID type number */ +#define H5I_TYPE(a) ((H5I_type_t)(((hid_t)(a) >> ID_BITS) & TYPE_MASK)) /****************************/ /* Package Private Typedefs */ /****************************/ +/* ID information structure used */ +typedef struct H5I_id_info_t { + hid_t id; /* ID for this info */ + unsigned count; /* Ref. count for this ID */ + unsigned app_count; /* Ref. count of application visible IDs */ + const void *object; /* Pointer associated with the ID */ + + /* Hash table ID fields */ + hbool_t marked; /* Marked for deletion */ + UT_hash_handle hh; /* Hash table handle (must be LAST) */ +} H5I_id_info_t; + +/* Type information structure used */ +typedef struct H5I_type_info_t { + const H5I_class_t *cls; /* Pointer to ID class */ + 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_type_info_t; + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/* Array of pointers to ID types */ +H5_DLLVAR H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; + +/* Variable to keep track of the number of types allocated. Its value is the + * next type ID to be handed out, so it is always one greater than the number + * of types. + * Starts at 1 instead of 0 because it makes trace output look nicer. If more + * types (or IDs within a type) are needed, adjust TYPE_BITS in H5Ipkg.h + * and/or increase size of hid_t + */ +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 H5I_id_info_t *H5I__find_id(hid_t id); + /* Testing functions */ #ifdef H5I_TESTING -H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, - hbool_t *cached); +H5_DLL ssize_t H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached); #endif /* H5I_TESTING */ -#endif /*_H5Ipkg_H*/ +#endif /*H5Ipkg_H*/ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 579d21c51ee..dd7485d95e4 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,77 +17,86 @@ *---------------------------------------------------------------------------*/ /* avoid re-inclusion */ -#ifndef _H5Iprivate_H -#define _H5Iprivate_H +#ifndef H5Iprivate_H +#define H5Iprivate_H /* Include package's public header */ #include "H5Ipublic.h" /* Private headers needed by this file */ #include "H5private.h" +#include "H5VLprivate.h" /**************************/ /* Library Private Macros */ /**************************/ /* Macro to determine if a H5I_type_t is a "library type" */ -#define H5I_IS_LIB_TYPE( type ) (type > 0 && type < H5I_NTYPES) +#define H5I_IS_LIB_TYPE(type) (type > 0 && type < H5I_NTYPES) /* Flags for ID class */ -#define H5I_CLASS_IS_APPLICATION 0x01 - +#define H5I_CLASS_IS_APPLICATION 0x01 /****************************/ /* Library Private Typedefs */ /****************************/ typedef struct H5I_class_t { - H5I_type_t type_id; /* Class ID for the type */ - unsigned flags; /* Class behavior flags */ - unsigned reserved; /* Number of reserved IDs for this type */ - /* [A specific number of type entries may be - * reserved to enable "constant" values to be - * handed out which are valid IDs in the type, - * but which do not map to any data structures - * and are not allocated dynamically later.] - */ - H5I_free_t free_func; /* Free function for object's of this type */ + H5I_type_t type; /* Class "value" for the type */ + unsigned flags; /* Class behavior flags */ + unsigned reserved; /* Number of reserved IDs for this type */ + /* [A specific number of type entries may be + * reserved to enable "constant" values to be + * handed out which are valid IDs in the type, + * but which do not map to any data structures + * and are not allocated dynamically later.] + */ + H5I_free_t free_func; /* Free function for object's of this type */ } H5I_class_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); -H5_DLL int64_t H5I_nmembers(H5I_type_t type); -H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); +H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); +H5_DLL int64_t H5I_nmembers(H5I_type_t type); +H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); H5_DLL H5I_type_t H5I_get_type(hid_t id); -H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); -H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); -H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); -H5_DLL int H5I_dec_ref(hid_t id); -H5_DLL int H5I_dec_app_ref(hid_t id); -H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL int H5I_dec_type_ref(H5I_type_t type); -H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t id_type); +H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); +H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); +H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); +H5_DLL int H5I_dec_ref(hid_t id); +H5_DLL int H5I_dec_app_ref(hid_t id); +H5_DLL int H5I_dec_app_ref_always_close(hid_t id); +H5_DLL int H5I_dec_type_ref(H5I_type_t type); +H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*out*/); + +/* NOTE: The object and ID functions below deal in non-VOL objects (i.e.; + * H5S_t, etc.). Similar VOL calls exist in H5VLprivate.h. Use + * the H5VL calls with objects that go through the VOL, such as + * datasets and groups, and the H5I calls with objects + * that do not, such as property lists and dataspaces. Datatypes + * are can be either named, where they will use the VOL, or not, + * and thus require special treatment. See the datatype docs for + * how to handle this. + */ /* Functions that manipulate objects */ -H5_DLL void *H5I_object(hid_t id); -H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_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 */ -H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); -H5_DLL herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id); +H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); +H5_DLL herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, + hid_t existing_id); /* Debugging functions */ H5_DLL herr_t H5I_dump_ids_for_type(H5I_type_t type); -#endif /* _H5Iprivate_H */ - +#endif /* H5Iprivate_H */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 7acca3acfde..6442a0df628 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,52 +15,68 @@ * This file contains function prototypes for each exported function in * the H5I module. */ -#ifndef _H5Ipublic_H -#define _H5Ipublic_H +#ifndef H5Ipublic_H +#define H5Ipublic_H /* Public headers needed by this file */ #include "H5public.h" -/* - * Library type values. Start with `1' instead of `0' because it makes the - * tracing output look better when hid_t values are large numbers. Change the - * TYPE_BITS in H5I.c if the MAXID gets larger than 32 (an assertion will - * fail otherwise). - * - * When adding types here, add a section to the 'misc19' test in test/tmisc.c - * to verify that the H5I{inc|dec|get}_ref() routines work correctly with it. +/** + * Library type values. + * \internal Library type values. Start with `1' instead of `0' because it + * makes the tracing output look better when hid_t values are large + * numbers. Change the TYPE_BITS in H5I.c if the MAXID gets larger + * than 32 (an assertion will fail otherwise). * - * NOTE: H5I_REFERENCE is not used by the library and was removed - * in HDF5 1.12.0. + * When adding types here, add a section to the 'misc19' test in + * test/tmisc.c to verify that the H5I{inc|dec|get}_ref() routines + * work correctly with it. \endinternal */ +//! typedef enum H5I_type_t { - H5I_UNINIT = (-2), /* uninitialized type */ - H5I_BADID = (-1), /* invalid Type */ - H5I_FILE = 1, /* type ID for File objects */ - H5I_GROUP, /* type ID for Group objects */ - H5I_DATATYPE, /* type ID for Datatype objects */ - H5I_DATASPACE, /* type ID for Dataspace objects */ - H5I_DATASET, /* type ID for Dataset objects */ - H5I_ATTR, /* type ID for Attribute objects */ - H5I_REFERENCE, /* *DEPRECATED* type ID for Reference objects */ - H5I_VFL, /* type ID for virtual file layer */ - H5I_GENPROP_CLS, /* type ID for generic property list classes */ - H5I_GENPROP_LST, /* type ID for generic property lists */ - H5I_ERROR_CLASS, /* type ID for error classes */ - H5I_ERROR_MSG, /* type ID for error messages */ - H5I_ERROR_STACK, /* type ID for error stacks */ - H5I_NTYPES /* number of library types, MUST BE LAST! */ + H5I_UNINIT = (-2), /**< uninitialized type */ + H5I_BADID = (-1), /**< invalid Type */ + H5I_FILE = 1, /**< type ID for File objects */ + H5I_GROUP, /**< type ID for Group objects */ + H5I_DATATYPE, /**< type ID for Datatype objects */ + H5I_DATASPACE, /**< type ID for Dataspace objects */ + H5I_DATASET, /**< type ID for Dataset objects */ + H5I_MAP, /**< type ID for Map objects */ + H5I_ATTR, /**< type ID for Attribute objects */ + H5I_VFL, /**< type ID for virtual file layer */ + H5I_VOL, /**< type ID for virtual object layer */ + H5I_GENPROP_CLS, /**< type ID for generic property list classes */ + H5I_GENPROP_LST, /**< type ID for generic property lists */ + H5I_ERROR_CLASS, /**< type ID for error classes */ + H5I_ERROR_MSG, /**< type ID for error messages */ + H5I_ERROR_STACK, /**< type ID for error stacks */ + H5I_SPACE_SEL_ITER, /**< type ID for dataspace selection iterator */ + H5I_NTYPES /**< number of library types, MUST BE LAST! */ } H5I_type_t; +//! -/* Type of atoms to return to users */ +/** + * Type of IDs to return to users + */ typedef int64_t hid_t; -#define H5_SIZEOF_HID_T H5_SIZEOF_INT64_T -/* An invalid object ID. This is also negative for error return. */ -#define H5I_INVALID_HID (-1) +#define PRIdHID PRId64 +#define PRIxHID PRIx64 +#define PRIXHID PRIX64 +#define PRIoHID PRIo64 -/* - * Function for freeing objects. This function will be called with an object +/** + * The size of identifiers + */ +#define H5_SIZEOF_HID_T H5_SIZEOF_INT64_T + +/** + * An invalid object ID. This is also negative for error return. + */ +#define H5I_INVALID_HID (-1) + +/** + * A function for freeing objects. This function will be called with an object * ID type number and a pointer to the object. The function should free the * object and return non-negative to indicate that the object * can be removed from the ID type. If the function returns negative @@ -68,8 +84,19 @@ typedef int64_t hid_t; */ typedef herr_t (*H5I_free_t)(void *); -/* Type of the function to compare objects & keys */ +/** + * The type of a function to compare objects & keys + */ +//! typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); +//! + +/** + * The type of H5Iiterate() callback functions + */ +//! +typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); +//! #ifdef __cplusplus extern "C" { @@ -77,28 +104,564 @@ extern "C" { /* Public API functions */ +/** + * \ingroup H5I + * + * \brief Registers an object under a type and returns an ID for it + * + * \param[in] type The identifier of the type of the new ID + * \param[in] object Pointer to object for which a new ID is created + * + * \return \hid_t{object} + * + * \details H5Iregister() creates and returns a new ID for an object. + * + * \details The \p type parameter is the identifier for the ID type to which + * this new ID will belong. This identifier must have been created by + * a call to H5Iregister_type(). + * + * \details The \p object parameter is a pointer to the memory which the new ID + * will be a reference to. This pointer will be stored by the library + * and returned via a call to H5Iobject_verify(). + * + */ H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); -H5_DLL void *H5Iobject_verify(hid_t id, H5I_type_t id_type); -H5_DLL void *H5Iremove_verify(hid_t id, H5I_type_t id_type); +/** + * \ingroup H5I + * + * \brief Returns the object referenced by an ID + * + * \param[in] id ID to be dereferenced + * \param[in] type The identifier type + + * + * \return Pointer to the object referenced by \p id on success, NULL on failure. + * + * \details H5Iobject_verify() returns a pointer to the memory referenced by id + * after verifying that \p id is of type \p type. This function is + * analogous to dereferencing a pointer in C with type checking. + * + * \note H5Iobject_verify() does not change the ID it is called on in any way + * (as opposed to H5Iremove_verify(), which removes the ID from its + * type’s hash table). + * + * \see H5Iregister() + * + */ +H5_DLL void *H5Iobject_verify(hid_t id, H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Removes an ID from its type + * + * \param[in] id The ID to be removed from its type + * \param[in] type The identifier type + + * + * \return Returns a pointer to the memory referred to by \p id on success, + * NULL on failure. + * + * \details H5Iremove_verify() first ensures that \p id belongs to \p type. + * If so, it removes \p id from its type and returns the pointer + * to the memory it referred to. This pointer is the same pointer that + * was placed in storage by H5Iregister(). If id does not belong to + * \p type, then NULL is returned. + * + * The \p id parameter is the ID which is to be removed from its type. + * + * The \p type parameter is the identifier for the ID type which \p id + * is supposed to belong to. This identifier must have been created by + * a call to H5Iregister_type(). + * + * \note This function does NOT deallocate the memory that \p id refers to. + * The pointer returned by H5Iregister() must be deallocated by the user + * to avoid memory leaks. + * + */ +H5_DLL void *H5Iremove_verify(hid_t id, H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Retrieves the type of an object + * + * \obj_id{id} + * + * \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 + * invalid, the function returns #H5I_BADID. + * + * This function is of particular use in determining the type of + * object closing function (H5Dclose(), H5Gclose(), etc.) to call + * after a call to H5Rdereference(). + * + * \note Note that this function returns only the type of object that \p id + * would identify if it were valid; it does not determine whether \p id + * is valid identifier. Validity can be determined with a call to + * H5Iis_valid(). + * + */ H5_DLL H5I_type_t H5Iget_type(hid_t id); +/** + * \ingroup H5I + * + * \brief Retrieves an identifier for the file containing the specified object + * + * \obj_id{id} + * + * \return \hid_t{file} + * + * \details H5Iget_file_id() returns the identifier of the file associated with + * the object referenced by \p id. + * + * \note Note that the HDF5 library permits an application to close a file + * while objects within the file remain open. If the file containing the + * object \p id is still open, H5Iget_file_id() will retrieve the + * existing file identifier. If there is no existing file identifier for + * the file, i.e., the file has been closed, H5Iget_file_id() will reopen + * the file and return a new file identifier. In either case, the file + * identifier must eventually be released using H5Fclose(). + * + * \since 1.6.3 + * + */ H5_DLL hid_t H5Iget_file_id(hid_t id); -H5_DLL ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size); +/** + * \ingroup H5I + * + * \brief Retrieves a name of an object based on the object identifier + * + * \obj_id{id} + * \param[out] name A buffer for thename associated with the identifier + * \param[in] size The size of the \p name buffer; usually the size of + * the name in bytes plus 1 for a NULL terminator + * + * \return ssize_t + * + * \details H5Iget_name() retrieves a name for the object identified by \p id. + * + * \details Up to size characters of the 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 H5Iget_name() call can be made. + * The return value of this call will be the size in bytes of the + * object name. That value, plus 1 for a NULL terminator, is then + * assigned to size for a second H5Iget_name() call, which will + * retrieve the actual name. + * + * If the object identified by \p id is an attribute, as determined + * via H5Iget_type(), H5Iget_name() retrieves the name of the object + * to which that attribute is attached. To retrieve the name of the + * attribute itself, use H5Aget_name(). + * + * If there is no name associated with the object identifier or if the + * name is NULL, H5Iget_name() returns 0 (zero). + * + * \note Note that an object in an HDF5 file may have multiple paths if there + * are multiple links pointing to it. This function may return any one of + * these paths. When possible, H5Iget_name() returns the path with which + * the object was opened. + * + * \since 1.6.0 + * + */ +H5_DLL ssize_t H5Iget_name(hid_t id, char *name /*out*/, size_t size); +/** + * \ingroup H5I + * + * \brief Increments the reference count for an object + * + * \obj_id{id} + * + * \return Returns a non-negative reference count of the object ID after + * incrementing it if successful; otherwise a negative value is + * returned. + * + * \details H5Iinc_ref() increments the reference count of the object + * identified by \p id. + * + * The reference count for an object ID is attached to the information + * about an object in memory and has no relation to the number of + * links to an object on disk. + * + * The reference count for a newly created object will be 1. Reference + * counts for objects may be explicitly modified with this function or + * with H5Idec_ref(). When an object ID's reference count reaches + * zero, the object will be closed. Calling an object ID's \c close + * function decrements the reference count for the ID which normally + * closes the object, but if the reference count for the ID has been + * incremented with this function, the object will only be closed when + * the reference count reaches zero with further calls to H5Idec_ref() + * or the object ID's \c close function. + * + * If the object ID was created by a collective parallel call (such as + * H5Dcreate(), H5Gopen(), etc.), the reference count should be + * modified by all the processes which have copies of the ID. + * Generally this means that group, dataset, attribute, file and named + * datatype IDs should be modified by all the processes and that all + * other types of IDs are safe to modify by individual processes. + * + * This function is of particular value when an application is + * maintaining multiple copies of an object ID. The object ID can be + * incremented when a copy is made. Each copy of the ID can then be + * safely closed or decremented and the HDF5 object will be closed + * when the reference count for that that object drops to zero. + * + * \since 1.6.2 + * + */ H5_DLL int H5Iinc_ref(hid_t id); +/** + * \ingroup H5I + * + * \brief Decrements the reference count for an object + * + * \obj_id{id} + * + * \return Returns a non-negative reference count of the object ID after + * decrementing it, if successful; otherwise a negative value is + * returned. + * + * \details H5Idec_ref() decrements the reference count of the object + * identified by \p id. + * + * The reference count for an object ID is attached to the information + * about an object in memory and has no relation to the number of + * links to an object on disk. + * + * The reference count for a newly created object will be 1. Reference + * counts for objects may be explicitly modified with this function or + * with H5Iinc_ref(). When an object identifier’s reference count + * reaches zero, the object will be closed. Calling an object + * identifier’s \c close function decrements the reference count for + * the identifier which normally closes the object, but if the + * reference count for the identifier has been incremented with + * H5Iinc_ref(), the object will only be closed when the reference + * count reaches zero with further calls to this function or the + * object identifier’s \c close function. + * + * If the object ID was created by a collective parallel call (such as + * H5Dcreate(), H5Gopen(), etc.), the reference count should be + * modified by all the processes which have copies of the ID. + * Generally this means that group, dataset, attribute, file and named + * datatype IDs should be modified by all the processes and that all + * other types of IDs are safe to modify by individual processes. + * + * This function is of particular value when an application is + * maintaining multiple copies of an object ID. The object ID can be + * incremented when a copy is made. Each copy of the ID can then be + * safely closed or decremented and the HDF5 object will be closed + * when the reference count for that that object drops to zero. + * + * \since 1.6.2 + * + */ H5_DLL int H5Idec_ref(hid_t id); +/** + * \ingroup H5I + * + * \brief Retrieves the reference count for an object + * + * \obj_id{id} + * + * \return Returns a non-negative current reference count of the object + * identifier if successful; otherwise a negative value is returned. + * + * \details H5Iget_ref() retrieves the reference count of the object identified + * by \p id. + * + * The reference count for an object identifier is attached to the + * information about an object in memory and has no relation to the + * number of links to an object on disk. + * + * The function H5Iis_valid() is used to determine whether a specific + * object identifier is valid. + * + * \since 1.6.2 + * + */ H5_DLL int H5Iget_ref(hid_t id); +/** + * \ingroup H5I + * + * \brief Creates and returns a new ID type + * + * \param[in] hash_size Minimum hash table size (in entries) used to store IDs + * for the new type + * \param[in] reserved Number of reserved IDs for the new type + * \param[in] free_func Function used to deallocate space for a single ID + * + * \return Returns the type identifier on success, negative on failure. + * + * \details H5Iregister_type() allocates space for a new ID type and returns an + * identifier for it. + * + * The \p hash_size parameter indicates the minimum size of the hash + * table used to store IDs in the new type. + * + * The \p reserved parameter indicates the number of IDs in this new + * type to be reserved. Reserved IDs are valid IDs which are not + * associated with any storage within the library. + * + * The \p free_func parameter is a function pointer to a function + * which returns an herr_t and accepts a \c void*. The purpose of this + * function is to deallocate memory for a single ID. It will be called + * by H5Iclear_type() and H5Idestroy_type() on each ID. This function + * is NOT called by H5Iremove_verify(). The \c void* will be the same + * pointer which was passed in to the H5Iregister() function. The \p + * free_func function should return 0 on success and -1 on failure. + * + */ H5_DLL H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); +/** + * \ingroup H5I + * + * \brief Deletes all identifiers of the given type + * + * \param[in] type Identifier of identifier type which is to be cleared of identifiers + * \param[in] force Whether or not to force deletion of all identifiers + * + * \return \herr_t + * + * \details H5Iclear_type() deletes all identifiers of the type identified by + * the argument \p type. + * + * The identifier type's free function is first called on all of these + * identifiers to free their memory, then they are removed from the + * type. + * + * If the \p force flag is set to false, only those identifiers whose + * reference counts are equal to 1 will be deleted, and all other + * identifiers will be entirely unchanged. If the force flag is true, + * all identifiers of this type will be deleted. + * + */ H5_DLL herr_t H5Iclear_type(H5I_type_t type, hbool_t force); +/** + * \ingroup H5I + * + * \brief Removes an identifier type and all identifiers within that type + * + * \param[in] type Identifier of identifier type which is to be destroyed + * + * \return \herr_t + * + * \details H5Idestroy_type deletes an entire identifier type \p type. All + * identifiers of this type are destroyed and no new identifiers of + * this type can be registered. + * + * The type’s free function is called on all of the identifiers which + * are deleted by this function, freeing their memory. In addition, + * all memory used by this type’s hash table is freed. + * + * Since the H5I_type_t values of destroyed identifier types are + * reused when new types are registered, it is a good idea to set the + * variable holding the value of the destroyed type to #H5I_UNINIT. + * + */ H5_DLL herr_t H5Idestroy_type(H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Increments the reference count on an ID type + * + * \param[in] type The identifier of the type whose reference count is to be incremented + * + * \return Returns the current reference count on success, negative on failure. + * + * \details H5Iinc_type_ref() increments the reference count on an ID type. The + * reference count is used by the library to indicate when an ID type + * can be destroyed. + * + * The type parameter is the identifier for the ID type whose + * reference count is to be incremented. This identifier must have + * been created by a call to H5Iregister_type(). + * + */ H5_DLL int H5Iinc_type_ref(H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Decrements the reference count on an identifier type + * + * \param[in] type The identifier of the type whose reference count is to be decremented + * + * \return Returns the current reference count on success, negative on failure. + * + * \details H5Idec_type_ref() decrements the reference count on an identifier + * type. The reference count is used by the library to indicate when + * an identifier type can be destroyed. If the reference count reaches + * zero, this function will destroy it. + * + * The type parameter is the identifier for the identifier type whose + * reference count is to be decremented. This identifier must have + * been created by a call to H5Iregister_type(). + * + */ H5_DLL int H5Idec_type_ref(H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Retrieves the reference count on an ID type + * + * \param[in] type The identifier of the type whose reference count is to be retieved + * + * \return Returns the current reference count on success, negative on failure. + * + * \details H5Iget_type_ref() retrieves the reference count on an ID type. The + * reference count is used by the library to indicate when an ID type + * can be destroyed. + * + * The type parameter is the identifier for the ID type whose + * reference count is to be retrieved. This identifier must have been + * created by a call to H5Iregister_type(). + * + */ H5_DLL int H5Iget_type_ref(H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Finds the memory referred to by an ID within the given ID type such + * that some criterion is satisfied + * + * \param[in] type The identifier of the type to be searched + * \param[in] func The function defining the search criteria + * \param[in] key A key for the search function + * + * \return Returns a pointer to the object which satisfies the search function + * on success, NULL on failure. + * + * \details H5Isearch() searches through a given ID type to find an object that + * satisfies the criteria defined by \p func. If such an object is + * found, the pointer to the memory containing this object is + * returned. Otherwise, NULL is returned. To do this, \p func is + * called on every member of type \p type. The first member to satisfy + * \p func is returned. + * + * The \p type parameter is the identifier for the ID type which is to + * be searched. This identifier must have been created by a call to + * H5Iregister_type(). + * + * The parameter \p func is a function pointer to a function which + * takes three parameters. The first parameter is a \c void* and will + * be a pointer to the object to be tested. This is the same object + * that was placed in storage using H5Iregister(). The second + * parameter is a hid_t and is the ID of the object to be tested. The + * last parameter is a \c void*. This is the \p key parameter and can + * be used however the user finds helpful, or it can be ignored if it + * is not needed. \p func returns 0 if the object it is testing does + * not pass its criteria. A non-zero value should be returned if the + * object does pass its criteria. H5I_search_func_t is defined in + * H5Ipublic.h and is shown below. + * \snippet this H5I_search_func_t_snip + * The \p key parameter will be passed to the search function as a + * parameter. It can be used to further define the search at run-time. + * + */ H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); +/** + * \ingroup H5I + * + * \brief Calls a callback for each member of the identifier type specified + * + * \param[in] type The identifier type + * \param[in] op The callback function + * \param[in,out] op_data The data for the callback function + * + * \return The last value returned by \p op + * + * \details H5Iiterate() calls the callback function \p op for each member of + * the identifier type \p type. The callback function type for \p op, + * H5I_iterate_func_t, is defined in H5Ipublic.h as: + * \snippet this H5I_iterate_func_t_snip + * \p op takes as parameters the identifier and a pass through of + * \p op_data, and returns an herr_t. + * + * A positive return from op will cause the iteration to stop and + * H5Iiterate() will return the value returned by \p op. A negative + * return from \p op will cause the iteration to stop and H5Iiterate() + * will return failure. A zero return from \p op will allow iteration + * to continue, as long as there are other identifiers remaining in + * type. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); +/** + * \ingroup H5I + * + * \brief Returns the number of identifiers in a given identifier type + * + * \param[in] type The identifier type + * \param[out] num_members Number of identifiers of the specified identifier type + * + * \return \herr_t + * + * \details H5Inmembers() returns the number of identifiers of the identifier + * type specified in \p type. + * + * The number of identifiers is returned in \p num_members. If no + * identifiers of this type have been registered, the type does not + * exist, or it has been destroyed, \p num_members is returned with + * the value 0. + * + */ H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); +/** + * \ingroup H5I + * + * \brief Determines whether an identifier type is registered + * + * \param[in] type Identifier type + * + * \return \htri_t + * + * \details H5Itype_exists() determines whether the given identifier type, + * \p type, is registered with the library. + * + * \since 1.8.0 + * + */ H5_DLL htri_t H5Itype_exists(H5I_type_t type); +/** + * \ingroup H5I + * + * \brief Determines whether an identifier is valid + * + * \obj_id{id} + * + * \return \htri_t + * + * \details H5Iis_valid() determines whether the identifier \p id is valid. + * + * \details Valid identifiers are those that have been obtained by an + * application and can still be used to access the original target. + * Examples of invalid identifiers include: + * \li Out of range values: negative, for example + * \li Previously-valid identifiers that have been released: + * for example, a dataset identifier for which the dataset has + * been closed + * + * H5Iis_valid() can be used with any type of identifier: object + * identifier, property list identifier, attribute identifier, error + * message identifier, etc. When necessary, a call to H5Iget_type() + * can determine the type of the object that \p id identifies. + * + * \since 1.8.3 + * + */ H5_DLL htri_t H5Iis_valid(hid_t id); #ifdef __cplusplus } #endif -#endif /* _H5Ipublic_H */ - +#endif /* H5Ipublic_H */ diff --git a/src/H5Itest.c b/src/H5Itest.c index eb32a598802..7f4ca7ad447 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -6,62 +6,51 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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, July 27, 2010 - * - * Purpose: ID testing functions. +/* + * H5Itest.c - ID testing functions */ /****************/ /* Module Setup */ /****************/ -#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5I_TESTING /*suppress warning about H5I testing funcs*/ - +#include "H5Imodule.h" /* This source code file is part of the H5I module */ +#define H5I_TESTING /*suppress warning about H5I testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5I__get_name_test * @@ -76,31 +65,45 @@ *------------------------------------------------------------------------- */ ssize_t -H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) +H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) { - H5G_loc_t loc; /* Object location */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t *vol_obj; /* Object of id */ + H5G_loc_t loc; /* Object location */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE - /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") - /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set API context") api_ctx_pushed = TRUE; + /* Get the object pointer */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Get object location */ + if (H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") + /* Call internal group routine to retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) + if ((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: - if(api_ctx_pushed && H5CX_pop() < 0) + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_name_test() */ - diff --git a/src/H5L.c b/src/H5L.c index 1db28736520..b7f27524954 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,7 @@ /* Module Setup */ /****************/ -#include "H5Lmodule.h" /* This source code file is part of the H5L module */ - +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ /***********/ /* Headers */ @@ -33,6 +32,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL */ /****************/ /* Local Macros */ @@ -40,118 +41,94 @@ #define H5L_MIN_TABLE_SIZE 32 /* Minimum size of the user-defined link type table if it is allocated */ - /******************/ /* Local Typedefs */ /******************/ /* User data for path traversal routine for getting link info by name */ typedef struct { - H5L_info_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gi_t; /* 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 */ - H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ - H5O_link_t *lnk; /* Pointer to link information to insert */ + 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 */ } 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 */ - 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 */ - hbool_t copy; /* TRUE if this is a copy operation */ - size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ + 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 */ + hbool_t copy; /* TRUE if this is a copy operation */ + size_t orig_nlinks; /* The original value for the # of soft / UD links that can be traversed */ } H5L_trav_mv_t; /* User data for path traversal routine for moving and renaming an object */ typedef struct { - 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 */ + 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; /* User data for path traversal routine for checking if a link exists */ typedef struct { /* Down */ - char *sep; /* Pointer to next separator in the string */ + char *sep; /* Pointer to next separator in the string */ /* Up */ - hbool_t exists; /* Whether the link exists or not */ + hbool_t exists; /* Whether the link exists or not */ } H5L_trav_le_t; /* User data for path traversal routine for getting link value */ typedef struct { - size_t size; /* Size of user buffer */ - void *buf; /* User buffer */ + size_t size; /* Size of user buffer */ + void * buf; /* User buffer */ } H5L_trav_gv_t; - /********************/ /* Local Prototypes */ /********************/ -static int H5L_find_class_idx(H5L_type_t id); -static herr_t H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -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); +static int H5L__find_class_idx(H5L_type_t id); +static herr_t H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +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); static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size); -static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - void *buf/*out*/, size_t size); -static herr_t H5L__delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -static herr_t H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static htri_t H5L__exists(const H5G_loc_t *loc, const char *name); -static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/); -static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/, - const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/); -static ssize_t H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - char *name /*out*/, size_t size); -static herr_t H5L__iterate(hid_t grp_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate_t op, void *op_data); +static herr_t H5L__get_val_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_val_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__delete_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_info_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); +static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/); /*********************/ /* Package Variables */ @@ -160,32 +137,29 @@ static herr_t H5L__iterate(hid_t grp_id, const char *group_name, /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Information about user-defined links */ -static size_t H5L_table_alloc_g = 0; -static size_t H5L_table_used_g = 0; -static H5L_class_t *H5L_table_g = NULL; +static size_t H5L_table_alloc_g = 0; +static size_t H5L_table_used_g = 0; +static H5L_class_t *H5L_table_g = NULL; - /*------------------------------------------------------------------------- - * Function: H5L_init + * Function: H5L_init * - * Purpose: Initialize the interface from some other package. + * Purpose: Initialize the interface from some other package. * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: James Laird + * Programmer: James Laird * Thursday, July 13, 2006 * *------------------------------------------------------------------------- @@ -193,7 +167,7 @@ static H5L_class_t *H5L_table_g = NULL; herr_t H5L_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -202,15 +176,14 @@ H5L_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_init() */ - /*------------------------------------------------------------------------- - * Function: H5L__init_package + * Function: H5L__init_package * - * Purpose: Initialize information specific to H5L interface. + * Purpose: Initialize information specific to H5L interface. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Tuesday, January 24, 2006 * *------------------------------------------------------------------------- @@ -218,27 +191,26 @@ H5L_init(void) herr_t H5L__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize user-defined link classes */ - if(H5L_register_external() < 0) + if (H5L_register_external() < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_init_package() */ - /*------------------------------------------------------------------------- - * Function: H5L_term_package + * Function: H5L_term_package * - * Purpose: Terminate any resources allocated in H5L__init_package. + * Purpose: Terminate any resources allocated in H5L__init_package. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Tuesday, January 24, 2006 * *------------------------------------------------------------------------- @@ -246,27 +218,26 @@ H5L__init_package(void) int H5L_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Free the table of link types */ - if(H5L_table_g) { - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); + if (H5L_table_g) { + H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); H5L_table_used_g = H5L_table_alloc_g = 0; n++; } /* end if */ /* Mark the interface as uninitialized */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5L_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Lmove * @@ -279,66 +250,87 @@ H5L_term_package(void) * * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Wednesday, March 29, 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + 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_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, - lapl_id); + H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id); /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) + if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) + if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) + if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, - ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; + /* Set location parameter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* Set location parameter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if (H5L_SAME_LOC != src_loc_id) + /* Get the location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (H5L_SAME_LOC != dst_loc_id) + /* Get the location object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL connectors are the same */ + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") + + /* Construct a temporary source VOL object */ + tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); + tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id) < 0) + if (H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lmove() */ - /*------------------------------------------------------------------------- * Function: H5Lcopy * @@ -348,66 +340,87 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, * * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Wednesday, March 29, 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + 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_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, - lapl_id); + H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id, lapl_id); /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) + if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) + if (!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) + if (!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, - ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; + /* Set location parameter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* Set location parameter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if (H5L_SAME_LOC != src_loc_id) + /* Get the location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (H5L_SAME_LOC != dst_loc_id) + /* Get the location object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL connectors are the same */ + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") + + /* Construct a temporary source VOL object */ + tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); + tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); /* Copy the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id) < 0) + if (H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcopy() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_soft * @@ -421,55 +434,66 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, * * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 6, 1998 * *------------------------------------------------------------------------- */ 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) +H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, + hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location for new link */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*si*sii", link_target, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!link_target) + if (link_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link location id should not be H5L_SAME_LOC") + if (!link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be NULL") - if(!*link_target) + if (!*link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be an empty string") - if(!link_name) + if (!link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_name parameter cannot be NULL") - if(!*link_name) + if (!*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_name parameter cannot be an empty string") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Create the link */ - if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, link_target) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_soft() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_hard * @@ -481,71 +505,90 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name * * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 6, 1998 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t cur_loc, *cur_loc_p; - H5G_loc_t new_loc, *new_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, - lapl_id); + H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) + if (cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!cur_name) + if (!cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be NULL") - if(!*cur_name) + if (!*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be an empty string") - if(!new_name) + if (!new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be NULL") - if(!*new_name) + if (!*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new_name parameter cannot be an empty string") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Check the link create property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + /* Set up current & new location structs */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + + if (H5L_SAME_LOC != cur_loc_id) + /* Get the current location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5VL_vol_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (H5L_SAME_LOC != new_loc_id) + /* Get the new location object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5VL_vol_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL connectors are the same */ + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") + + /* Construct a temporary VOL object */ + tmp_vol_obj.data = (vol_obj2 ? (vol_obj2->data) : NULL); + tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create link") + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (vol_obj1 ? vol_obj1->data : NULL), + &loc_params1) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_hard() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_ud * @@ -565,50 +608,59 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, * * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Tuesday, December 13, 2005 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t link_loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, - udata_size, lcpl_id, lapl_id); + H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, udata_size, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!link_name || !*link_name) + if (!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") - if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) + if (link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + if (!udata && udata_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Create external link */ - if(H5L__create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, udata, udata_size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_ud() */ - /*------------------------------------------------------------------------- * Function: H5Ldelete * @@ -621,7 +673,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, * * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 6, 1998 * *------------------------------------------------------------------------- @@ -629,184 +681,220 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in the location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Unlink */ - if(H5L_delete(&loc, name) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Ldelete() */ - /*------------------------------------------------------------------------- - * Function: H5Ldelete_by_idx + * Function: H5Ldelete_by_idx * - * Purpose: Removes the specified link from the group graph and - * decrements the link count for the object to which it - * points, according to the order within an index. + * Purpose: Removes the specified link from the group graph and + * decrements the link count for the object to which it + * points, according to the order within an index. * - * If the link count reaches zero then all file-space - * associated with the object will be reclaimed (but if the - * object is open, then the reclamation of the file space is - * delayed until all handles to the object are closed). + * If the link count reaches zero then all file-space + * associated with the object will be reclaimed (but if the + * object is open, then the reclamation of the file space is + * delayed until all handles to the object are closed). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 13, 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Delete the link */ - if(H5L__delete_by_idx(&loc, group_name, idx_type, order, n) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) } /* end H5Ldelete_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5Lget_val + * Function: H5Lget_val * - * Purpose: Returns the link value of a link whose name is NAME. For + * Purpose: Returns the link value of a link whose name is NAME. For * symbolic links, this is the path to which the link points, * including the null terminator. For user-defined links, it * is the link buffer. * * At most SIZE bytes are copied to the BUF result buffer. * - * Return: Success: Non-negative with the link value in BUF. + * Return: Success: Non-negative with the link value in BUF. * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 13, 1998 * *------------------------------------------------------------------------- */ herr_t -H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, - hid_t lapl_id) +H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for location to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link value */ - if(H5L_get_val(&loc, name, buf, size) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_val() */ - /*------------------------------------------------------------------------- - * Function: H5Lget_val_by_idx + * Function: H5Lget_val_by_idx * - * Purpose: Returns the link value of a link, according to the order of + * Purpose: Returns the link value of a link, according to the order of * an index. For symbolic links, this is the path to which the * link points, including the null terminator. For user-defined * links, it is the link buffer. * * At most SIZE bytes are copied to the BUF result buffer. * - * Return: Success: Non-negative with the link value in BUF. - * Failure: Negative + * Return: Success: Non-negative with the link value in BUF. + * Failure: Negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 13, 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Group location for location to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, buf, size, - lapl_id); + H5TRACE8("e", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, buf, size, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link value */ - if(H5L__get_val_by_idx(&loc, group_name, idx_type, order, n, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for") + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, + size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_val_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Lexists * @@ -814,7 +902,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, * * Return: Success: TRUE/FALSE/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, March 16, 2007 * *------------------------------------------------------------------------- @@ -822,77 +910,93 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; - htri_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Check for the existence of the link */ - if((ret_value = H5L__exists(&loc, name)) < 0) + if (H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Lexists() */ - /*------------------------------------------------------------------------- - * Function: H5Lget_info + * Function: H5Lget_info2 * * Purpose: Gets metadata for a link. * * Return: Success: Non-negative with information in LINFO * Failure: Negative * - * Programmer: James Laird + * Programmer: James Laird * Wednesday, June 21, 2006 * *------------------------------------------------------------------------- */ herr_t -H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, - hid_t lapl_id) +H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link information */ - if(H5L_get_info(&loc, name, linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lget_info() */ +} /* end H5Lget_info2() */ - /*------------------------------------------------------------------------- - * Function: H5Lget_info_by_idx + * Function: H5Lget_info_by_idx2 * * Purpose: Gets metadata for a link, according to the order within an * index. @@ -900,50 +1004,59 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, * Return: Success: Non-negative with information in LINFO * Failure: Negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 6, 2006 * *------------------------------------------------------------------------- */ herr_t -H5Lget_info_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/, hid_t lapl_id) +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) { - H5G_loc_t loc; /* Group location for group to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, - lapl_id); + H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link information */ - if(H5L__get_info_by_idx(&loc, group_name, idx_type, order, n, linfo) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lget_info_by_idx() */ +} /* end H5Lget_info_by_idx2() */ - /*------------------------------------------------------------------------- - * Function: H5Lregister + * Function: H5Lregister * - * Purpose: Registers a class of user-defined links, or changes the + * Purpose: Registers a class of user-defined links, or changes the * behavior of an existing class. * * The link class passed in will override any existing link @@ -952,9 +1065,9 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, * H5L_LINK_CLASS_T_VERS), a link class ID, and a traversal * function. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -962,14 +1075,14 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, herr_t H5Lregister(const H5L_class_t *cls) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", cls); /* Check args */ - if(cls == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + if (cls == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") /* Check H5L_class_t version number; this is where a function to convert * from an outdated version should be called. @@ -978,34 +1091,40 @@ H5Lregister(const H5L_class_t *cls) * traversal callback, which is handled in H5G_traverse_ud() * (in src/H5Gtraverse.c), so it's allowed to to pass through here. - QAK, 2018/02/06 */ - if(cls->version > H5L_LINK_CLASS_T_VERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number") - - if(cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX) + if (cls->version > H5L_LINK_CLASS_T_VERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5L_class_t version number") +#ifdef H5_NO_DEPRECATED_SYMBOLS + if (cls->version < H5L_LINK_CLASS_T_VERS) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "deprecated H5L_class_t version number (%d) and library built without deprecated symbol support", + cls->version) +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + if (cls->id < H5L_TYPE_UD_MIN || cls->id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link identification number") - if(cls->trav_func == NULL) + if (cls->trav_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no traversal function specified") /* Do it */ - if(H5L_register(cls) < 0) + if (H5L_register(cls) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register link type") done: FUNC_LEAVE_API(ret_value) } /* end H5Lregister() */ - /*------------------------------------------------------------------------- - * Function: H5Lunregister + * Function: H5Lunregister * - * Purpose: Unregisters a class of user-defined links, preventing them + * Purpose: Unregisters a class of user-defined links, preventing them * from being traversed, queried, moved, etc. * * A link class can be re-registered using H5Lregister(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -1013,24 +1132,23 @@ H5Lregister(const H5L_class_t *cls) herr_t H5Lunregister(H5L_type_t id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Ll", id); /* Check args */ - if(id < 0 || id > H5L_TYPE_MAX) + if (id < 0 || id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type") /* Do it */ - if(H5L_unregister(id) < 0) + if (H5L_unregister(id) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to unregister link type") done: FUNC_LEAVE_API(ret_value) } /* end H5Lunregister() */ - /*------------------------------------------------------------------------- * Function: H5Lis_registered * @@ -1041,7 +1159,7 @@ H5Lunregister(H5L_type_t id) * FALSE if it is unregistered * FAIL on error (if the class is not a valid UD class ID) * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -1049,19 +1167,19 @@ H5Lunregister(H5L_type_t id) htri_t H5Lis_registered(H5L_type_t id) { - size_t i; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + size_t i; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Ll", id); /* Check args */ - if(id < 0 || id > H5L_TYPE_MAX) + if (id < 0 || id > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link type id number") /* Is the link class already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) { + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) { ret_value = TRUE; break; } /* end if */ @@ -1070,7 +1188,6 @@ H5Lis_registered(H5L_type_t id) FUNC_LEAVE_API(ret_value) } /* end H5Lis_registered() */ - /*------------------------------------------------------------------------- * Function: H5Lget_name_by_idx * @@ -1084,48 +1201,58 @@ H5Lis_registered(H5L_type_t id) * * Failure: -1 * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 11, 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Location of group */ - ssize_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) - H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, - lapl_id); + H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, (-1), "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Get the link information */ - if((ret_value = H5L__get_name_by_idx(&loc, group_name, idx_type, order, n, name, size)) < 0) + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + name, size, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name") done: FUNC_LEAVE_API(ret_value) } /* end H5Lget_name_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5Literate + * Function: H5Literate2 * * Purpose: Iterates over links in a group, with user callback routine, * according to the order within an index. @@ -1143,17 +1270,19 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, *------------------------------------------------------------------------- */ herr_t -H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx_p, H5L_iterate_t op, void *op_data) +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) { - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, op_data); + H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); /* Check arguments */ - id_type = H5I_get_type(grp_id); + id_type = H5I_get_type(group_id); if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1163,17 +1292,26 @@ H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + /* Iterate over the links */ - if((ret_value = H5L__iterate(grp_id, ".", idx_type, order, idx_p, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Literate() */ +} /* end H5Literate2() */ - /*------------------------------------------------------------------------- - * Function: H5Literate_by_name + * Function: H5Literate_by_name2 * * Purpose: Iterates over links in a group, with user callback routine, * according to the order within an index. @@ -1195,43 +1333,53 @@ H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, *------------------------------------------------------------------------- */ herr_t -H5Literate_by_name(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, - H5L_iterate_t op, void *op_data, hid_t lapl_id) +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) { - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, - op_data, lapl_id); + H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); /* Check arguments */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Iterate over the links */ - if((ret_value = H5L__iterate(loc_id, group_name, idx_type, order, idx_p, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Literate_by_name() */ - /*------------------------------------------------------------------------- - * Function: H5Lvisit + * Function: H5Lvisit2 * * Purpose: Recursively visit all the links in a group and all * the groups that are linked to from that group. Links within @@ -1253,43 +1401,52 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, * library, or the negative value returned by one * of the operators. * - * Programmer: Quincey Koziol - * November 24 2007 + * Programmer: Quincey Koziol + * November 24 2007 * *------------------------------------------------------------------------- */ herr_t -H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate_t op, void *op_data) +H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data) { - H5I_type_t id_type; /* Type of ID */ - herr_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "iIiIox*x", grp_id, idx_type, order, op, op_data); + H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); /* Check args */ - id_type = H5I_get_type(grp_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + id_type = H5I_get_type(group_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over the links */ - if((ret_value = H5G_visit(grp_id, ".", idx_type, order, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lvisit() */ +} /* end H5Lvisit2() */ - /*------------------------------------------------------------------------- - * Function: H5Lvisit_by_name + * Function: H5Lvisit_by_name2 * * Purpose: Recursively visit all the links in a group and all * the groups that are linked to from that group. Links within @@ -1317,38 +1474,50 @@ H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, *------------------------------------------------------------------------- */ herr_t -H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id) +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) { - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, - lapl_id); + H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if(!group_name) + if (!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") - if(!*group_name) + if (!*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Visit the links */ - if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data)) < 0) + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Lvisit_by_name() */ +} /* end H5Lvisit_by_name2() */ /* *------------------------------------------------------------------------- @@ -1358,49 +1527,47 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- - * Function: H5L_find_class_idx + * Function: H5L__find_class_idx * - * Purpose: Given a link class ID, return the offset in the global array + * Purpose: Given a link class ID, return the offset in the global array * that holds all the registered link classes. * - * Return: Success: Non-negative index of entry in global + * Return: Success: Non-negative index of entry in global * link class table. - * Failure: Negative + * Failure: Negative * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- */ static int -H5L_find_class_idx(H5L_type_t id) +H5L__find_class_idx(H5L_type_t id) { - size_t i; /* Local index variable */ - int ret_value = FAIL; /* Return value */ + size_t i; /* Local index variable */ + int ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) - HGOTO_DONE((int)i) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) + HGOTO_DONE((int)i) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_find_class_idx */ +} /* end H5L__find_class_idx */ - /*------------------------------------------------------------------------- - * Function: H5L_find_class + * Function: H5L_find_class * - * Purpose: Given a link class ID return a pointer to a global struct that - * defines the link class. + * Purpose: Given a link class ID return a pointer to a global struct that + * defines the link class. * - * Return: Success: Ptr to entry in global link class table. - * Failure: NULL + * Return: Success: Ptr to entry in global link class table. + * Failure: NULL * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -1408,34 +1575,33 @@ H5L_find_class_idx(H5L_type_t id) const H5L_class_t * H5L_find_class(H5L_type_t id) { - int idx; /* Filter index in global table */ - H5L_class_t *ret_value = NULL; /* Return value */ + int idx; /* Filter index in global table */ + H5L_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the index in the global table */ - if((idx = H5L_find_class_idx(id)) < 0) + if ((idx = H5L__find_class_idx(id)) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, NULL, "unable to find link class") /* Set return value */ - ret_value = H5L_table_g+idx; + ret_value = H5L_table_g + idx; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_find_class */ - /*------------------------------------------------------------------------- - * Function: H5L_register + * Function: H5L_register * - * Purpose: Registers a class of user-defined links, or changes the + * Purpose: Registers a class of user-defined links, or changes the * behavior of an existing class. * * See H5Lregister for full documentation. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -1443,8 +1609,8 @@ H5L_find_class(H5L_type_t id) herr_t H5L_register(const H5L_class_t *cls) { - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1452,23 +1618,23 @@ H5L_register(const H5L_class_t *cls) HDassert(cls->id >= 0 && cls->id <= H5L_TYPE_MAX); /* Is the link type already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == cls->id) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == cls->id) break; /* Filter not already registered */ - if(i >= H5L_table_used_g) { - if(H5L_table_used_g >= H5L_table_alloc_g) { - size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); - H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); - if(!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") - H5L_table_g = table; + if (i >= H5L_table_used_g) { + if (H5L_table_used_g >= H5L_table_alloc_g) { + size_t n = MAX(H5L_MIN_TABLE_SIZE, (2 * H5L_table_alloc_g)); + H5L_class_t *table = (H5L_class_t *)H5MM_realloc(H5L_table_g, (n * sizeof(H5L_class_t))); + if (!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend link type table") + H5L_table_g = table; H5L_table_alloc_g = n; - } /* end if */ + } /* end if */ - /* Initialize */ - i = H5L_table_used_g++; + /* Initialize */ + i = H5L_table_used_g++; } /* end if */ /* Copy link class info into table */ @@ -1478,17 +1644,16 @@ H5L_register(const H5L_class_t *cls) FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_register */ - /*------------------------------------------------------------------------- - * Function: H5L_unregister + * Function: H5L_unregister * - * Purpose: Unregisters a class of user-defined links. + * Purpose: Unregisters a class of user-defined links. * * See H5Lunregister for full documentation. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -1496,20 +1661,20 @@ H5L_register(const H5L_class_t *cls) herr_t H5L_unregister(H5L_type_t id) { - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(id >= 0 && id <= H5L_TYPE_MAX); /* Is the filter already registered? */ - for(i = 0; i < H5L_table_used_g; i++) - if(H5L_table_g[i].id == id) + for (i = 0; i < H5L_table_used_g; i++) + if (H5L_table_g[i].id == id) break; /* Fail if filter not found */ - if(i >= H5L_table_used_g) + if (i >= H5L_table_used_g) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") /* Remove filter from table */ @@ -1521,16 +1686,15 @@ H5L_unregister(H5L_type_t id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_unregister() */ - /*------------------------------------------------------------------------- - * Function: H5L_link + * Function: H5L_link * - * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Olink() for - * full documentation. + * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Olink() for + * full documentation. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Tuesday, December 13, 2005 * *------------------------------------------------------------------------- @@ -1538,8 +1702,8 @@ H5L_unregister(H5L_type_t id) herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1554,36 +1718,34 @@ H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid */ /* Construct link information for eventual insertion */ - lnk.type = H5L_TYPE_HARD; + lnk.type = H5L_TYPE_HARD; lnk.u.hard.addr = obj_loc->oloc->addr; /* Create the link */ - if(H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(new_loc, new_name, obj_loc->path, obj_loc->oloc->file, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_link() */ - /*------------------------------------------------------------------------- - * Function: H5L_link_object + * Function: H5L_link_object * - * Purpose: Creates a new object and a link to it. + * Purpose: Creates a new object and a link to it. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, April 9, 2007 * *------------------------------------------------------------------------- */ herr_t -H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, - H5O_obj_create_t *ocrt_info, hid_t lcpl_id) +H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1601,54 +1763,55 @@ H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, lnk.type = H5L_TYPE_HARD; /* Create the link */ - if(H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) + if (H5L__create_real(new_loc, new_name, NULL, NULL, &lnk, ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_link_object() */ - /*------------------------------------------------------------------------- - * Function: H5L__link_cb + * Function: H5L__link_cb * - * Purpose: Callback for creating a link to an object. + * Purpose: Callback for creating a link to an object. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, September 19, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + 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 */ - 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 */ - hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid location */ /* (which is not what we want) */ - if(obj_loc != NULL) + if (obj_loc != NULL) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name already exists") /* Check for crossing file boundaries with a new hard link */ - if(udata->lnk->type == H5L_TYPE_HARD) { + if (udata->lnk->type == H5L_TYPE_HARD) { /* Check for creating an object */ /* (only for hard links) */ - if(udata->ocrt_info) { - H5G_loc_t new_loc; /* Group location for new object */ + if (udata->ocrt_info) { + H5G_loc_t new_loc; /* Group location for new object */ /* Create new object at this location */ - if(NULL == (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, udata->ocrt_info->crt_info, &new_loc))) + if (NULL == + (udata->ocrt_info->new_obj = H5O_obj_create(grp_loc->oloc->file, udata->ocrt_info->obj_type, + udata->ocrt_info->crt_info, &new_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create object") /* Set address for hard link */ @@ -1662,56 +1825,57 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT } /* end if */ else { /* Check that both objects are in same file */ - if(!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "interfile hard links are not allowed") } /* end else */ - } /* end if */ + } /* end if */ /* Set 'standard' aspects of link */ - udata->lnk->corder = 0; /* Will be re-written during group insertion, if the group is tracking creation order */ - udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ + udata->lnk->corder = + 0; /* Will be re-written during group insertion, if the group is tracking creation order */ + udata->lnk->corder_valid = FALSE; /* Creation order not valid (yet) */ /* Check for non-default link creation properties */ - if(udata->lc_plist) { + if (udata->lc_plist) { /* Get character encoding property */ - if(H5CX_get_encoding(&udata->lnk->cset) < 0) + if (H5CX_get_encoding(&udata->lnk->cset) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'character set' property") } /* end if */ else - udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ + udata->lnk->cset = H5F_DEFAULT_CSET; /* Default character encoding for link */ /* Set the link's name correctly */ /* Casting away const OK -QAK */ udata->lnk->name = (char *)name; /* Insert link into group */ - if(H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, - udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, - udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, + udata->ocrt_info ? udata->ocrt_info->obj_type : H5O_TYPE_UNKNOWN, + udata->ocrt_info ? udata->ocrt_info->crt_info : NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link for object") /* Set object's path if it has been passed in and is not set */ - if(udata->path != NULL && udata->path->user_path_r == NULL) - if(H5G_name_set(grp_loc->path, udata->path, name) < 0) + if (udata->path != NULL && udata->path->user_path_r == NULL) + if (H5G_name_set(grp_loc->path, udata->path, name) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "cannot set name") /* If link is a user-defined link, trigger its creation callback if it has one */ - if(udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(udata->lnk->type))) + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to get class of UD link") - if(link_class->create_func != NULL) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; + if (link_class->create_func != NULL) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; /* Create a temporary location (or else H5G_open will do a shallow * copy and wipe out grp_loc) */ H5G_name_reset(&temp_path); - if(H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") temp_loc.oloc = &temp_oloc; @@ -1719,21 +1883,22 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT temp_loc_init = TRUE; /* Set up location for user-defined callback */ - if(NULL == (grp = H5G_open(&temp_loc))) + if (NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") /* Make callback */ - if((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, H5P_DEFAULT) < 0) + if ((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, + H5P_DEFAULT) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "link creation callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: /* Check if an object was created */ - if(obj_created) { - H5O_loc_t oloc; /* Object location for created object */ + if (obj_created) { + H5O_loc_t oloc; /* Object location for created object */ /* Set up object location */ HDmemset(&oloc, 0, sizeof(oloc)); @@ -1741,20 +1906,20 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT oloc.addr = udata->lnk->u.hard.addr; /* Decrement refcount on new object's object header in memory */ - if(H5O_dec_rc_by_loc(&oloc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(&oloc) < 0) + HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") } /* end if */ /* Close the location given to the user callback if it was created */ - if(grp_id >= 0) { - if(H5I_dec_app_ref(grp_id) < 0) + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ - else if(grp != NULL) { - if(H5G_close(grp) < 0) + else if (grp != NULL) { + if (H5G_close(grp) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") } /* end if */ - else if(temp_loc_init) + else if (temp_loc_init) H5G_loc_free(&temp_loc); /* Indicate that this callback didn't take ownership of the group * @@ -1764,7 +1929,6 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__link_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__create_real * @@ -1785,15 +1949,14 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1804,22 +1967,22 @@ H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, HDassert(lnk->type >= H5L_TYPE_HARD && lnk->type <= H5L_TYPE_MAX); /* Get normalized link name */ - if((norm_link_name = H5G_normalize(link_name)) == NULL) + if ((norm_link_name = H5G_normalize(link_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT && lcpl_id != H5P_LINK_CREATE_DEFAULT) { + if (lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; /* Get link creation property list */ - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get intermediate group creation property */ - if(H5CX_get_intermediate_group(&crt_intmd_group) < 0) + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get 'create intermediate group' property") - if(crt_intmd_group > 0) + if (crt_intmd_group > 0) target_flags |= H5G_CRT_INTMD_GROUP; } /* end if */ @@ -1835,51 +1998,50 @@ H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, * of its fields should be populated except for name, which is set when * inserting it in the callback. */ - udata.file = obj_file; - udata.lc_plist = lc_plist; - udata.path = obj_path; + udata.file = obj_file; + udata.lc_plist = lc_plist; + udata.path = obj_path; udata.ocrt_info = ocrt_info; - udata.lnk = lnk; + udata.lnk = lnk; /* Traverse the destination path & create new link */ - if(H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) + if (H5G_traverse(link_loc, link_name, target_flags, H5L__link_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert link") done: /* Free the normalized path name */ - if(norm_link_name) + if (norm_link_name) H5MM_xfree(norm_link_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__create_real() */ - /*------------------------------------------------------------------------- - * Function: H5L_create_hard + * Function: H5L__create_hard * - * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. + * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 6, 1998 * *------------------------------------------------------------------------- */ 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) +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 */ - 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*/ - H5O_loc_t oloc; /* obj_loc's oloc */ - hbool_t loc_valid = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + 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*/ + H5O_loc_t oloc; /* obj_loc's oloc */ + hbool_t loc_valid = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Check args */ HDassert(cur_loc); @@ -1888,7 +2050,7 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, HDassert(link_name && *link_name); /* Get normalized copy of the current name */ - if((norm_cur_name = H5G_normalize(cur_name)) == NULL) + if ((norm_cur_name = H5G_normalize(cur_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up link data specific to hard links */ @@ -1898,7 +2060,7 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, obj_loc.path = &path; obj_loc.oloc = &oloc; H5G_loc_reset(&obj_loc); - if(H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) + if (H5G_loc_find(cur_loc, norm_cur_name, &obj_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "source object not found") loc_valid = TRUE; @@ -1910,44 +2072,42 @@ H5L_create_hard(H5G_loc_t *cur_loc, const char *cur_name, /* Create actual link to the object. Pass in NULL for the path, since this * function shouldn't change an object's user path. */ - if(H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, link_file, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: /* Free the object header location */ - if(loc_valid) - if(H5G_loc_free(&obj_loc) < 0) + if (loc_valid) + if (H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location") /* Free the normalized path name */ - if(norm_cur_name) + if (norm_cur_name) H5MM_xfree(norm_cur_name); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_create_hard() */ +} /* end H5L__create_hard() */ - /*------------------------------------------------------------------------- - * Function: H5L_create_soft + * Function: H5L__create_soft * * Purpose: Creates a soft link from LINK_NAME to TARGET_PATH. * * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 6, 1998 * *------------------------------------------------------------------------- */ herr_t -H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc, - const char *link_name, hid_t lcpl_id) +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 */ - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_target = NULL; /* Pointer to normalized current name */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Check args */ HDassert(link_loc); @@ -1955,45 +2115,44 @@ H5L_create_soft(const char *target_path, const H5G_loc_t *link_loc, HDassert(link_name && *link_name); /* Get normalized copy of the link target */ - if((norm_target = H5G_normalize(target_path)) == NULL) + if ((norm_target = H5G_normalize(target_path)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up link data specific to soft links */ - lnk.type = H5L_TYPE_SOFT; + lnk.type = H5L_TYPE_SOFT; lnk.u.soft.name = norm_target; /* Create actual link to the object */ - if(H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") done: /* Free the normalized target name */ - if(norm_target) + if (norm_target) H5MM_xfree(norm_target); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_create_soft() */ +} /* end H5L__create_soft() */ - /*------------------------------------------------------------------------- - * Function: H5L__create_ud + * Function: H5L__create_ud * - * Purpose: Creates a user-defined link. See H5Lcreate_ud for + * Purpose: Creates a user-defined link. See H5Lcreate_ud for * full documentation. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Friday, May 19, 2006 * *------------------------------------------------------------------------- */ herr_t -H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, - const void *ud_data, size_t ud_data_size, H5L_type_t type, hid_t lcpl_id) +H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, size_t ud_data_size, + H5L_type_t type, hid_t lcpl_id) { - H5O_link_t lnk; /* Link to insert */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t lnk; /* Link to insert */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2007,22 +2166,22 @@ H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, lnk.u.ud.udata = NULL; /* Make sure that this link class is registered */ - if(H5L_find_class_idx(type) < 0) + if (H5L__find_class_idx(type) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "link class has not been registered with library") /* Fill in UD link-specific information in the link struct*/ - if(ud_data_size > 0) { + if (ud_data_size > 0) { lnk.u.ud.udata = H5MM_malloc((size_t)ud_data_size); - H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t) ud_data_size); + H5MM_memcpy(lnk.u.ud.udata, ud_data, (size_t)ud_data_size); } /* end if */ else lnk.u.ud.udata = NULL; lnk.u.ud.size = ud_data_size; - lnk.type = type; + lnk.type = type; /* Create actual link to the object */ - if(H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) + if (H5L__create_real(link_loc, link_name, NULL, NULL, &lnk, NULL, lcpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to register new name for object") done: @@ -2032,15 +2191,14 @@ H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__create_ud() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_val_real + * Function: H5L__get_val_real * - * Purpose: Retrieve link value from a link object + * Purpose: Retrieve link value from a link object * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 13 2006 * *------------------------------------------------------------------------- @@ -2048,7 +2206,7 @@ H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, static herr_t H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2056,17 +2214,17 @@ H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) HDassert(lnk); /* Check for soft link */ - if(H5L_TYPE_SOFT == lnk->type) { + if (H5L_TYPE_SOFT == lnk->type) { /* Copy to output buffer */ - if(size > 0 && buf) { + if (size > 0 && buf) { HDstrncpy((char *)buf, lnk->u.soft.name, size); - if(HDstrlen(lnk->u.soft.name) >= size) + if (HDstrlen(lnk->u.soft.name) >= size) ((char *)buf)[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Check for user-defined link */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + else if (lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. It's okay if the class * isn't registered, though--we just can't give any more information @@ -2074,11 +2232,11 @@ H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) */ link_class = H5L_find_class(lnk->type); - if(link_class != NULL && link_class->query_func != NULL) { - if((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) + if (link_class != NULL && link_class->query_func != NULL) { + if ((link_class->query_func)(lnk->name, lnk->u.ud.udata, lnk->u.ud.size, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "query callback returned failure") } /* end if */ - else if(buf && size > 0) + else if (buf && size > 0) ((char *)buf)[0] = '\0'; } /* end if */ else @@ -2088,34 +2246,33 @@ H5L__get_val_real(const H5O_link_t *lnk, void *buf, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_real() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_val_cb + * Function: H5L__get_val_cb * - * Purpose: Callback for retrieving link value or udata. + * Purpose: Callback for retrieving link value or udata. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, September 20, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gv_t *udata = (H5L_trav_gv_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) /* Retrieve the value for the link */ - if(H5L__get_val_real(lnk, udata->buf, udata->size) < 0) + if (H5L__get_val_real(lnk, udata->buf, udata->size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") done: @@ -2126,33 +2283,32 @@ H5L__get_val_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, const FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L_get_val + * Function: H5L__get_val * - * Purpose: Returns the value of a symbolic link or the udata for a + * Purpose: Returns the value of a symbolic link or the udata for a * user-defined link. * - * Return: Success: Non-negative, with at most SIZE bytes of the - * link value copied into the BUF buffer. If the - * link value is larger than SIZE characters - * counting the null terminator then the BUF - * result will not be null terminated. + * Return: Success: Non-negative, with at most SIZE bytes of the + * link value copied into the BUF buffer. If the + * link value is larger than SIZE characters + * counting the null terminator then the BUF + * result will not be null terminated. * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 13, 1998 * *------------------------------------------------------------------------- */ herr_t -H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, size_t size) +H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size) { - H5L_trav_gv_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gv_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(loc); @@ -2160,58 +2316,57 @@ H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, size_t siz /* Set up user data for retrieving information */ udata.size = size; - udata.buf = buf; + udata.buf = buf; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_get_val() */ +} /* H5L__get_val() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_val_by_idx_cb + * Function: H5L__get_val_by_idx_cb * - * Purpose: Callback for retrieving a link's value according to an + * Purpose: Callback for retrieving a link's value according to an * index's order. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 13 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Retrieve the value for the link */ - if(H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) + if (H5L__get_val_real(&fnd_lnk, udata->buf, udata->size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't retrieve link value") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Indicate that this callback didn't take ownership of the group * @@ -2221,7 +2376,6 @@ H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_AT FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__get_val_by_idx * @@ -2235,14 +2389,14 @@ H5L__get_val_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_AT * *------------------------------------------------------------------------- */ -static herr_t -H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size) +herr_t +H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, void *buf /*out*/, size_t size) { - H5L_trav_gvbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(loc); @@ -2250,58 +2404,58 @@ H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Set up user data for retrieving information */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.buf = buf; - udata.size = size; + udata.order = order; + udata.n = n; + udata.buf = buf; + udata.size = size; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_val_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info for index: %llu", (unsigned long long)n) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_val_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5L__delete_cb + * Function: H5L__delete_cb * - * Purpose: Callback for deleting a link. This routine + * Purpose: Callback for deleting a link. This routine * actually deletes the link * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, September 19, 2005 * *------------------------------------------------------------------------- */ static herr_t -H5L__delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void H5_ATTR_UNUSED *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Check if the group resolved to a valid link */ - if(grp_loc == NULL) + if (grp_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Check if the name in this group resolved to a valid link */ - if(name == NULL) + if (name == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for non-existent (NULL) link. * Note that this can also occur when attempting to remove '.' */ - if(lnk == NULL) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "callback link pointer is NULL (specified link may be '.' or not exist)") + if (lnk == NULL) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, + "callback link pointer is NULL (specified link may be '.' or not exist)") /* Remove the link from the group */ - if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to remove link from group") done: @@ -2312,76 +2466,76 @@ H5L__delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__delete_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L_delete + * Function: H5L__delete * - * Purpose: Delete a link from a group. + * Purpose: Delete a link from a group. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, September 17, 1998 * *------------------------------------------------------------------------- */ herr_t -H5L_delete(const H5G_loc_t *loc, const char *name) +H5L__delete(const H5G_loc_t *loc, const char *name) { - char *norm_name = NULL; /* Pointer to normalized name */ - herr_t ret_value = SUCCEED; /* Return value */ + char * norm_name = NULL; /* Pointer to normalized name */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(loc); HDassert(name && *name); /* Get normalized copy of the name */ - if((norm_name = H5G_normalize(name)) == NULL) + if ((norm_name = H5G_normalize(name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Set up user data for unlink operation */ - if(H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, NULL) < 0) + if (H5G_traverse(loc, norm_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_cb, + NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREMOVE, FAIL, "can't unlink object") done: /* Free the normalized path name */ - if(norm_name) + if (norm_name) H5MM_xfree(norm_name); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_delete() */ +} /* end H5L__delete() */ - /*------------------------------------------------------------------------- - * Function: H5L__delete_by_idx_cb + * Function: H5L__delete_by_idx_cb * - * Purpose: Callback for removing a link according to an index's order. + * Purpose: Callback for removing a link according to an index's order. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 13 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gvbi_t *udata = (H5L_trav_gvbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG((obj_loc) ? (obj_loc->oloc->addr) : HADDR_UNDEF) /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Delete link */ - if(H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, udata->n) < 0) + if (H5G_obj_remove_by_idx(obj_loc->oloc, obj_loc->path->full_path_r, udata->idx_type, udata->order, + udata->n) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") done: @@ -2392,7 +2546,6 @@ H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATT FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5L__delete_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__delete_by_idx * @@ -2406,14 +2559,14 @@ H5L__delete_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATT * *------------------------------------------------------------------------- */ -static herr_t -H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +herr_t +H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n) { - H5L_trav_rmbi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_rmbi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(loc); @@ -2421,54 +2574,53 @@ H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Set up user data for unlink operation */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; + udata.order = order; + udata.n = n; /* Traverse the group hierarchy to remove the link */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, H5L__delete_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK | H5G_TARGET_MOUNT, + H5L__delete_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "link doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__delete_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5L__move_dest_cb + * Function: H5L__move_dest_cb * - * Purpose: Second callback for moving and renaming an object. This routine + * Purpose: Second callback for moving and renaming an object. This routine * inserts a new link into the group returned by the traversal. * It is called by H5L__move_cb. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, April 3, 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_ATTR_UNUSED *lnk, + 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 */ - 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; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make sure an object with this name doesn't already exist */ - if(obj_loc != NULL) + if (obj_loc != NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "an object with that name already exists") /* Check for crossing file boundaries with a new hard link */ - if(udata->lnk->type == H5L_TYPE_HARD) + if (udata->lnk->type == H5L_TYPE_HARD) /* Check that both objects are in same file */ - if(!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) + if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "moving a link across files is not allowed") /* Give the object its new name */ @@ -2477,26 +2629,26 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, udata->lnk->name = (char *)name; /* Insert the link into the group */ - if(H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) + if (H5G_obj_insert(grp_loc->oloc, name, udata->lnk, TRUE, H5O_TYPE_UNKNOWN, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create new link to object") /* If the link was a user-defined link, call its move callback if it has one */ - if(udata->lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + if (udata->lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(udata->lnk->type))) + if (NULL == (link_class = H5L_find_class(udata->lnk->type))) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class is not registered") - if((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { - H5O_loc_t temp_oloc; - H5G_name_t temp_path; + if ((!udata->copy && link_class->move_func) || (udata->copy && link_class->copy_func)) { + H5O_loc_t temp_oloc; + H5G_name_t temp_path; /* Create a temporary location (or else H5G_open will do a shallow * copy and wipe out grp_loc) */ H5G_name_reset(&temp_path); - if(H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) + if (H5O_loc_copy_deep(&temp_oloc, grp_loc->oloc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object location") temp_loc.oloc = &temp_oloc; @@ -2504,33 +2656,35 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, temp_loc_init = TRUE; /* Set up location for user-defined callback */ - if(NULL == (grp = H5G_open(&temp_loc))) + if (NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if ((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") - if(udata->copy) { - if((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size) < 0) + if (udata->copy) { + if ((link_class->copy_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD copy callback returned error") } /* end if */ else { - if((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size) < 0) + if ((link_class->move_func)(udata->lnk->name, grp_id, udata->lnk->u.ud.udata, + udata->lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "UD move callback returned error") } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: /* Close the location given to the user callback if it was created */ - if(grp_id >= 0) { - if(H5I_dec_app_ref(grp_id) < 0) + if (grp_id >= 0) { + if (H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ - else if(grp != NULL) { - if(H5G_close(grp) < 0) + else if (grp != NULL) { + if (H5G_close(grp) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") } /* end if */ - else if(temp_loc_init) + else if (temp_loc_init) H5G_loc_free(&temp_loc); /* Indicate that this callback didn't take ownership of the group * @@ -2544,54 +2698,53 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__move_dest_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L__move_cb + * Function: H5L__move_cb * - * Purpose: Callback for moving and renaming an object. This routine + * Purpose: Callback for moving and renaming an object. This routine * replaces the names of open objects with the moved object * in the path * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Friday, April 3, 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, + void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - 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 */ - hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for operations on '.' */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "the name of a link must be supplied to move or copy") /* Set up user data for move_dest_cb */ - if(NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) + if (NULL == (udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL))) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link to be moved") /* In this special case, the link's name is going to be replaced at its * destination, so we should free it here. */ udata_out.lnk->name = (char *)H5MM_xfree(udata_out.lnk->name); - link_copied = TRUE; + link_copied = TRUE; udata_out.lnk->cset = udata->cset; - udata_out.file = grp_loc->oloc->file; - udata_out.copy = udata->copy; + udata_out.file = grp_loc->oloc->file; + udata_out.copy = udata->copy; /* Keep a copy of link's name (it's "owned" by the H5G_traverse() routine) */ orig_name = H5MM_xstrdup(name); @@ -2599,24 +2752,25 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, /* Reset the # of soft / UD links that can be traversed, so that the second * (destination) traversal has the correct value */ - if(H5CX_set_nlinks(udata->orig_nlinks) < 0) + if (H5CX_set_nlinks(udata->orig_nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't reset # of soft / UD links to traverse") /* Insert the link into its new location */ - if(H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, &udata_out) < 0) + if (H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, H5L__move_dest_cb, + &udata_out) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") /* If this is a move and not a copy operation, change the object's name and remove the old link */ - if(!udata->copy) { - H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ + if (!udata->copy) { + H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ /* Make certain that the destination name is a full (not relative) path */ - if(*(udata->dst_name) != '/') { + if (*(udata->dst_name) != '/') { HDassert(udata->dst_loc->path->full_path_r); /* Create reference counted string for full dst path */ - if((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, - udata->dst_name)) == NULL) + if ((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, + udata->dst_name)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_PATH, FAIL, "can't build destination path name") } /* end if */ else @@ -2624,14 +2778,14 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, HDassert(dst_name_r); /* Fix names up */ - if(H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, - udata->dst_loc->oloc->file, dst_name_r) < 0) { + if (H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, + udata->dst_loc->oloc->file, dst_name_r) < 0) { H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to replace name") } /* end if */ /* Remove the old link */ - if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { + if (H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name) < 0) { H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to remove old name") } /* end if */ @@ -2641,14 +2795,14 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, done: /* Cleanup */ - if(orig_name) + if (orig_name) H5MM_xfree(orig_name); /* If udata_out.lnk was copied, free any memory allocated * In this special case, the H5L__move_dest_cb callback resets the name * so H5O_msg_free shouldn't try to free it */ - if(link_copied) + if (link_copied) H5O_msg_free(H5O_LINK_ID, udata_out.lnk); /* Indicate that this callback didn't take ownership of the group * @@ -2658,11 +2812,10 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__move_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L_move + * Function: H5L__move * - * Purpose: Atomically move or copy a link. + * Purpose: Atomically move or copy a link. * * Creates a copy of a link in a new destination with a new name. * SRC_LOC and SRC_NAME together define the link's original @@ -2672,24 +2825,24 @@ H5L__move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, * If copy_flag is FALSE, the original link is removed * (effectively moving the link). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, May 1, 2006 * *------------------------------------------------------------------------- */ herr_t -H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, - const char *dst_name, hbool_t copy_flag, hid_t lcpl_id) +H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, const char *dst_name, + hbool_t copy_flag, hid_t lcpl_id) { - unsigned dst_target_flags = H5G_TARGET_NORMAL; - H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ - H5P_genplist_t* lc_plist; /* Link creation property list */ - H5L_trav_mv_t udata; /* User data for traversal */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned dst_target_flags = H5G_TARGET_NORMAL; + H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5L_trav_mv_t udata; /* User data for traversal */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(src_loc); @@ -2698,66 +2851,66 @@ H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_lo HDassert(dst_name && *dst_name); /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT && lcpl_id != H5P_LINK_CREATE_DEFAULT) { + if (lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; - if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + if (NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get intermediate group creation property */ - if(H5CX_get_intermediate_group(&crt_intmd_group) < 0) + if (H5CX_get_intermediate_group(&crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") /* Set target flags for source and destination */ - if(crt_intmd_group > 0) + if (crt_intmd_group > 0) dst_target_flags |= H5G_CRT_INTMD_GROUP; /* Get character encoding property */ - if(H5CX_get_encoding(&char_encoding) < 0) + if (H5CX_get_encoding(&char_encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for character encoding") } /* end if */ /* Set up user data */ - udata.dst_loc = dst_loc; - udata.dst_name= dst_name; + udata.dst_loc = dst_loc; + udata.dst_name = dst_name; udata.dst_target_flags = dst_target_flags; - udata.cset = char_encoding; - udata.copy = copy_flag; + udata.cset = char_encoding; + udata.copy = copy_flag; /* Retrieve the original # of soft / UD links that can be traversed, so * that the countdown can be reset after the first path is traversed. */ - if(H5CX_get_nlinks(&udata.orig_nlinks) < 0) + if (H5CX_get_nlinks(&udata.orig_nlinks) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve # of soft / UD links to traverse") /* Do the move */ - if(H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, &udata) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to find link") + if (H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__move_cb, + &udata) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to find link") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_move() */ +} /* end H5L__move() */ - /*------------------------------------------------------------------------- - * Function: H5L__exists_final_cb + * Function: H5L__exists_final_cb * - * Purpose: Callback for checking whether a link exists, as the final + * Purpose: Callback for checking whether a link exists, as the final * component of a path * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, March 16 2007 * *------------------------------------------------------------------------- */ static herr_t -H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ FUNC_ENTER_STATIC_NOERR @@ -2771,50 +2924,49 @@ H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5L__exists_final_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L__exists_inter_cb + * Function: H5L__exists_inter_cb * - * Purpose: Callback for checking whether a link exists, as an intermediate + * Purpose: Callback for checking whether a link exists, as an intermediate * component of a path * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, December 31 2015 * *------------------------------------------------------------------------- */ static herr_t -H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk != NULL) { + 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 */ + if (udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char * next; /* Pointer to next component name */ /* Look for another separator */ next = udata->sep; - if(NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + if (NULL == (udata->sep = HDstrchr(udata->sep, '/'))) cb_func = H5L__exists_final_cb; else { /* Chew through adjacent separators, if present */ do { *udata->sep = '\0'; udata->sep++; - } while('/' == *udata->sep); + } while ('/' == *udata->sep); cb_func = H5L__exists_inter_cb; } /* end else */ - if(H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) + if (H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") } /* end if */ else @@ -2831,18 +2983,17 @@ H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__exists_inter_cb() */ - /*------------------------------------------------------------------------- - * Function: H5L_exists_tolerant + * Function: H5L_exists_tolerant * - * Purpose: Returns whether a link exists in a group + * Purpose: Returns whether a link exists in a group * - * Note: Same as H5L_exists, except that missing links are reported - * as 'FALSE' instead of causing failures + * Note: Same as H5L__exists, except that missing links are reported + * as 'FALSE' instead of causing failures * - * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, December 31 2015 * *------------------------------------------------------------------------- @@ -2850,11 +3001,11 @@ H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR 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 */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2864,28 +3015,28 @@ H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) /* Copy the name and skip leading '/'s */ name_trav = name_copy = H5MM_strdup(name); - while('/' == *name_trav) + while ('/' == *name_trav) name_trav++; /* A path of "/" will always exist in a file */ - if('\0' == *name_trav) + if ('\0' == *name_trav) HGOTO_DONE(TRUE) /* Set up user data & correct callback */ udata.exists = FALSE; - if(NULL == (udata.sep = HDstrchr(name_trav, '/'))) + if (NULL == (udata.sep = HDstrchr(name_trav, '/'))) cb_func = H5L__exists_final_cb; else { /* Chew through adjacent separators, if present */ do { *udata.sep = '\0'; udata.sep++; - } while('/' == *udata.sep); + } while ('/' == *udata.sep); cb_func = H5L__exists_inter_cb; } /* end else */ /* Traverse the group hierarchy to locate the link to check */ - if(H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) + if (H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if link exists") /* Set return value */ @@ -2898,18 +3049,17 @@ H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* H5L_exists_tolerant() */ - /*------------------------------------------------------------------------- - * Function: H5L__exists + * Function: H5L__exists * - * Purpose: Returns whether a link exists in a group + * Purpose: Returns whether a link exists in a group * - * Note: Same as H5L_exists_tolerant, except that missing links are reported - * as failures + * Note: Same as H5L_exists_tolerant, except that missing links are reported + * as failures * - * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, March 16 2007 * *------------------------------------------------------------------------- @@ -2917,18 +3067,18 @@ H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) htri_t H5L__exists(const H5G_loc_t *loc, const char *name) { - H5L_trav_le_t udata; /* User data for traversal */ - htri_t ret_value = FAIL; /* Return value */ + H5L_trav_le_t udata; /* User data for traversal */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* A path of "/" will always exist in a file */ - if(0 == HDstrcmp(name, "/")) + if (0 == HDstrcmp(name, "/")) HGOTO_DONE(TRUE) /* Traverse the group hierarchy to locate the object to get info about */ udata.exists = FALSE; - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ @@ -2938,35 +3088,33 @@ H5L__exists(const H5G_loc_t *loc, const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* H5L__exists() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_info_cb + * Function: H5L__get_info_cb * - * Purpose: Callback for retrieving a link's metadata + * Purpose: Callback for retrieving a link's metadata * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, April 17 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__get_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_info_cb(H5G_loc_t *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, + H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gi_t *udata = (H5L_trav_gi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL) + if (lnk == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Get information from the link */ - if(H5G_link_to_info(lnk, udata->linfo) < 0) + if (H5G_link_to_info(grp_loc->oloc, lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: @@ -2977,7 +3125,6 @@ H5L__get_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_info_cb() */ - /*------------------------------------------------------------------------- * Function: H5L_get_info * @@ -2985,71 +3132,70 @@ H5L__get_info_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNU * * Return: SUCCEED/FAIL * - * Programmer: James Laird + * Programmer: James Laird * Monday, April 17 2006 * *------------------------------------------------------------------------- */ herr_t -H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linfo/*out*/) +H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linfo /*out*/) { H5L_trav_gi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) udata.linfo = linfo; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name doesn't exist") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L_get_info() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_info_by_idx_cb + * Function: H5L__get_info_by_idx_cb * - * Purpose: Callback for retrieving a link's metadata according to an + * Purpose: Callback for retrieving a link's metadata according to an * index's order. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, November 6 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ - H5O_link_t fnd_lnk; /* Link within group */ - hbool_t lnk_copied = FALSE; /* Whether the link was copied */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gibi_t *udata = (H5L_trav_gibi_t *)_udata; /* User data passed in */ + H5O_link_t fnd_lnk; /* Link within group */ + hbool_t lnk_copied = FALSE; /* Whether the link was copied */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if(H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) + if (H5G_obj_lookup_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, &fnd_lnk) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") lnk_copied = TRUE; /* Get information from the link */ - if(H5G_link_to_info(&fnd_lnk, udata->linfo) < 0) + if (H5G_link_to_info(obj_loc->oloc, &fnd_lnk, udata->linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get link info") done: /* Reset the link information, if we have a copy */ - if(lnk_copied) + if (lnk_copied) H5O_msg_reset(H5O_LINK_ID, &fnd_lnk); /* Indicate that this callback didn't take ownership of the group * @@ -3059,7 +3205,6 @@ H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_info_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__get_info_by_idx * @@ -3070,14 +3215,14 @@ H5L__get_info_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A * *------------------------------------------------------------------------- */ -static herr_t -H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5L_info_t *linfo /*out*/) +herr_t +H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, H5L_info2_t *linfo /*out*/) { - H5L_trav_gibi_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gibi_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(loc); @@ -3086,48 +3231,48 @@ H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type /* Set up user data for callback */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.linfo = linfo; + udata.order = order; + udata.n = n; + udata.linfo = linfo; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_info_by_idx_cb, &udata) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_info_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5L__get_name_by_idx_cb + * Function: H5L__get_name_by_idx_cb * - * Purpose: Callback for retrieving a link's name according to an + * Purpose: Callback for retrieving a link's name according to an * index's order. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 11 2006 * *------------------------------------------------------------------------- */ static herr_t -H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, - const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, - H5G_own_loc_t *own_loc/*out*/) +H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, + H5G_own_loc_t *own_loc /*out*/) { - H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ + H5L_trav_gnbi_t *udata = (H5L_trav_gnbi_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if the name of the group resolved to a valid object */ - if(obj_loc == NULL) + if (obj_loc == NULL) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "group doesn't exist") /* Query link */ - if((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, udata->name, udata->size)) < 0) + if ((udata->name_len = H5G_obj_get_name_by_idx(obj_loc->oloc, udata->idx_type, udata->order, udata->n, + udata->name, udata->size)) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "link not found") done: @@ -3138,7 +3283,6 @@ H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_name_by_idx_cb() */ - /*------------------------------------------------------------------------- * Function: H5L__get_name_by_idx * @@ -3149,15 +3293,14 @@ H5L__get_name_by_idx_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_A * *------------------------------------------------------------------------- */ -static ssize_t -H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, - size_t size) +ssize_t +H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, char *name /*out*/, size_t size) { - H5L_trav_gnbi_t udata; /* User data for callback */ - ssize_t ret_value = FAIL; /* Return value */ + H5L_trav_gnbi_t udata; /* User data for callback */ + ssize_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(loc); @@ -3165,14 +3308,15 @@ H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, /* Set up user data for callback */ udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.name = name; - udata.size = size; + udata.order = order; + udata.n = n; + udata.name = name; + udata.size = size; udata.name_len = -1; /* Traverse the group hierarchy to locate the link to get name of */ - if(H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < 0) + if (H5G_traverse(loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__get_name_by_idx_cb, &udata) < + 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get name") /* Set the return value */ @@ -3182,32 +3326,31 @@ H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__get_name_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5L__link_copy_file + * Function: H5L__link_copy_file * * Purpose: Copy a link and the object it points to from one file to * another. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Sep 29 2006 + * Programmer: Quincey Koziol + * Sep 29 2006 * *------------------------------------------------------------------------- */ herr_t -H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, - const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) +H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info) { - H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ - const H5O_link_t *src_lnk = _src_lnk; /* Source link */ - hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ - hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ - H5G_loc_t tmp_src_loc; /* Group location holding target object */ - H5G_name_t tmp_src_path; /* Path for target object */ - H5O_loc_t tmp_src_oloc; /* Object location for target object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t tmp_src_lnk; /* Temporary copy of src link, when needed */ + const H5O_link_t *src_lnk = _src_lnk; /* Source link */ + hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ + hbool_t expanded_link_open = FALSE; /* Whether the target location has been opened */ + H5G_loc_t tmp_src_loc; /* Group location holding target object */ + H5G_name_t tmp_src_path; /* Path for target object */ + H5O_loc_t tmp_src_oloc; /* Object location for target object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3218,66 +3361,64 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, HDassert(cpy_info); /* Expand soft or external link, if requested */ - if((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) - || (H5L_TYPE_EXTERNAL == src_lnk->type - && cpy_info->expand_ext_link)) { - H5G_loc_t lnk_grp_loc; /* Group location holding link */ - H5G_name_t lnk_grp_path; /* Path for link */ - htri_t tar_exists; /* Whether the target object exists */ + if ((H5L_TYPE_SOFT == src_lnk->type && cpy_info->expand_soft_link) || + (H5L_TYPE_EXTERNAL == src_lnk->type && cpy_info->expand_ext_link)) { + H5G_loc_t lnk_grp_loc; /* Group location holding link */ + H5G_name_t lnk_grp_path; /* Path for link */ + htri_t tar_exists; /* Whether the target object exists */ /* Set up group location for link */ H5G_name_reset(&lnk_grp_path); lnk_grp_loc.path = &lnk_grp_path; - lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ + lnk_grp_loc.oloc = (H5O_loc_t *)src_oloc; /* Casting away const OK -QAK */ /* Check if the target object exists */ - if((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) + if ((tar_exists = H5G_loc_exists(&lnk_grp_loc, src_lnk->name)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to check if target object exists") - if(tar_exists) { + if (tar_exists) { /* Make a temporary copy of the link, so that it will not change the * info in the cache when we change it to a hard link */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") /* Set up group location for target object. Let H5G_traverse expand * the link. */ tmp_src_loc.path = &tmp_src_path; tmp_src_loc.oloc = &tmp_src_oloc; - if(H5G_loc_reset(&tmp_src_loc) < 0) + if (H5G_loc_reset(&tmp_src_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to reset location") /* Find the target object */ - if(H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) + if (H5G_loc_find(&lnk_grp_loc, src_lnk->name, &tmp_src_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to find target object") expanded_link_open = TRUE; /* Convert symbolic link to hard link */ - if(tmp_src_lnk.type == H5L_TYPE_SOFT) - tmp_src_lnk.u.soft.name = - (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); - else if(tmp_src_lnk.u.ud.size > 0) + if (tmp_src_lnk.type == H5L_TYPE_SOFT) + tmp_src_lnk.u.soft.name = (char *)H5MM_xfree(tmp_src_lnk.u.soft.name); + else if (tmp_src_lnk.u.ud.size > 0) tmp_src_lnk.u.ud.udata = H5MM_xfree(tmp_src_lnk.u.ud.udata); - tmp_src_lnk.type = H5L_TYPE_HARD; + tmp_src_lnk.type = H5L_TYPE_HARD; tmp_src_lnk.u.hard.addr = tmp_src_oloc.addr; - src_lnk = &tmp_src_lnk; + src_lnk = &tmp_src_lnk; } /* end if */ - } /* end if */ + } /* end if */ /* Copy src link information to dst link information */ - if(NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) + if (NULL == H5O_msg_copy(H5O_LINK_ID, src_lnk, dst_lnk)) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy message") dst_lnk_init = TRUE; /* Check if object in source group is a hard link & copy it */ - if(H5L_TYPE_HARD == src_lnk->type) { - H5O_loc_t new_dst_oloc; /* Copied object location in destination */ + if (H5L_TYPE_HARD == src_lnk->type) { + H5O_loc_t new_dst_oloc; /* Copied object location in destination */ /* Set up copied object location to fill in */ H5O_loc_reset(&new_dst_oloc); new_dst_oloc.file = dst_file; - if(!expanded_link_open) { + if (!expanded_link_open) { /* Build temporary object location for source */ H5O_loc_reset(&tmp_src_oloc); tmp_src_oloc.file = src_oloc->file; @@ -3288,7 +3429,7 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, /* Copy the shared object from source to destination */ /* Don't care about obj_type or udata because those are only important * for old style groups */ - if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) + if (H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, cpy_info, TRUE, NULL, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy object") /* Copy new destination object's information for eventual insertion */ @@ -3297,24 +3438,23 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, done: /* Check if we used a temporary src link */ - if(src_lnk != _src_lnk) { + if (src_lnk != _src_lnk) { HDassert(src_lnk == &tmp_src_lnk); H5O_msg_reset(H5O_LINK_ID, &tmp_src_lnk); } /* end if */ - if(ret_value < 0) - if(dst_lnk_init) + if (ret_value < 0) + if (dst_lnk_init) H5O_msg_reset(H5O_LINK_ID, dst_lnk); /* Check if we need to free the temp source oloc */ - if(expanded_link_open) - if(H5G_loc_free(&tmp_src_loc) < 0) + if (expanded_link_open) + if (H5G_loc_free(&tmp_src_loc) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__link_copy_file() */ - /*------------------------------------------------------------------------- - * Function: H5L__iterate + * Function: H5L_iterate * * Purpose: Iterates through links in a group * @@ -3322,38 +3462,38 @@ H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, * *------------------------------------------------------------------------- */ -static herr_t -H5L__iterate(hid_t grp_id, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) +herr_t +H5L_iterate(H5G_loc_t *loc, 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) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value = FAIL; /* Return value */ + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI_NOINIT /* Sanity checks */ + HDassert(loc); HDassert(group_name); HDassert(op); /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); + idx = (idx_p == NULL ? 0 : *idx_p); last_lnk = 0; /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; + lnk_op.op_type = H5G_LINK_OP_NEW; + lnk_op.op_func.op_new = op; /* Iterate over the links */ - if((ret_value = H5G_iterate(grp_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) + if ((ret_value = H5G_iterate(loc, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ - if(idx_p) + if (idx_p) *idx_p = last_lnk; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L__iterate() */ - +} /* end H5L_iterate() */ diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c new file mode 100644 index 00000000000..3568696399f --- /dev/null +++ b/src/H5Ldeprec.c @@ -0,0 +1,622 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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: Deprecated functions from the H5L interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ + +#include "H5VLnative_private.h" + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* 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; +} H5L_shim_data_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5L__iterate2_shim + * + * Purpose: Shim function for translating between H5L_info2_t and + * H5L_info1_t structures, as used by H5Literate2/H5Lvisit2 + * and H5Literate1/H5Lvisit1, respectively. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * Failure: H5_ITER_ERROR + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__iterate2_shim(hid_t group_id, const char *name, const H5L_info2_t *linfo2, void *op_data) +{ + H5L_shim_data_t *shim_data = (H5L_shim_data_t *)op_data; + H5L_info1_t linfo; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + /* Copy the new-style members into the old-style struct */ + if (linfo2) { + linfo.type = linfo2->type; + linfo.corder_valid = linfo2->corder_valid; + linfo.corder = linfo2->corder; + linfo.cset = linfo2->cset; + if (H5L_TYPE_HARD == linfo2->type) { + if (H5VLnative_token_to_addr(group_id, linfo2->u.token, &linfo.u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, H5_ITER_ERROR, + "can't deserialize object token into address") + } + else + linfo.u.val_size = linfo2->u.val_size; + } + + /* Invoke the real callback */ + ret_value = shim_data->real_op(group_id, name, &linfo, shim_data->real_op_data); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__iterate2_shim() */ + +/*------------------------------------------------------------------------- + * Function: H5Literate1 + * + * Purpose: Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * Same pattern of behavior as H5Giterate. + * + * Note: Deprecated in favor of H5Literate2 + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + *------------------------------------------------------------------------- + */ +herr_t +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_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); + + /* Check arguments */ + id_type = H5I_get_type(group_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Literate1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, + H5L__iterate2_shim, (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Literate1() */ + +/*------------------------------------------------------------------------- + * Function: H5Literate_by_name1 + * + * Purpose: Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * Same pattern of behavior as H5Giterate. + * + * Note: Deprecated in favor of H5Literate_by_name2 + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * + * Programmer: Quincey Koziol + * Thursday, November 16, 2006 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); + + /* Check arguments */ + if (!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if (!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Literate_by_name1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, H5L__iterate2_shim, + (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Literate_by_name1() */ + +/*------------------------------------------------------------------------- + * Function: H5Lget_info1 + * + * Purpose: Gets metadata for a link. + * + * Note: Deprecated in favor of H5Lget_info2 + * + * Return: Success: Non-negative with information in LINFO + * Failure: Negative + * + * Programmer: James Laird + * Wednesday, June 21, 2006 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); + + /* Check arguments */ + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lget_info1 is only meant to be used with the native VOL connector") + + /* Get the link information */ + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") + + /* Copy the new-style members into the old-style struct */ + if (linfo) { + linfo->type = linfo2.type; + linfo->corder_valid = linfo2.corder_valid; + linfo->corder = linfo2.corder; + linfo->cset = linfo2.cset; + if (H5L_TYPE_HARD == linfo2.type) { + void *vol_obj_data; + + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + if (H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, + &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + } /* end if */ + else + linfo->u.val_size = linfo2.u.val_size; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lget_info1() */ + +/*------------------------------------------------------------------------- + * Function: H5Lget_info_by_idx1 + * + * Purpose: Gets metadata for a link, according to the order within an + * index. + * + * Note: Deprecated in favor of H5Lget_info_by_idx2 + * + * Return: Success: Non-negative with information in LINFO + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5L_info2_t linfo2; /* New-style link info */ + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIohxi", loc_id, group_name, idx_type, order, n, linfo, lapl_id); + + /* Check arguments */ + if (!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lget_info_by_idx1 is only meant to be used with the native VOL connector") + + /* Get the link information */ + if (H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") + + /* Copy the new-style members into the old-style struct */ + if (linfo) { + linfo->type = linfo2.type; + linfo->corder_valid = linfo2.corder_valid; + linfo->corder = linfo2.corder; + linfo->cset = linfo2.cset; + if (H5L_TYPE_HARD == linfo2.type) { + void *vol_obj_data; + + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + if (H5VL_native_token_to_addr(vol_obj_data, loc_params.obj_type, linfo2.u.token, + &linfo->u.address) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + } /* end if */ + else + linfo->u.val_size = linfo2.u.val_size; + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lget_info_by_idx1() */ + +/*------------------------------------------------------------------------- + * Function: H5Lvisit1 + * + * Purpose: Recursively visit all the links in a group and all + * the groups that are linked to from that group. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Each _link_ reachable from the initial group will only be + * visited once. However, because an object may be reached from + * more than one link, the visitation may call the application's + * callback with more than one link that points to a particular + * _object_. + * + * Note: Deprecated in favor of H5Lvisit2 + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 24 2007 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5I_type_t id_type; /* Type of ID */ + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); + + /* Check args */ + id_type = H5I_get_type(group_id); + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lvisit1 is only meant to be used with the native VOL connector") + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Iterate over the links */ + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, + (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lvisit1() */ + +/*------------------------------------------------------------------------- + * Function: H5Lvisit_by_name1 + * + * Purpose: Recursively visit all the links in a group and all + * the groups that are linked to from that group. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Each _link_ reachable from the initial group will only be + * visited once. However, because an object may be reached from + * more than one link, the visitation may call the application's + * callback with more than one link that points to a particular + * _object_. + * + * Note: Deprecated in favor of H5Lvisit_by_name2 + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 3 2007 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5L_shim_data_t shim_data; + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); + + /* Check args */ + if (!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if (!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, + "H5Lvisit_by_name1 is only meant to be used with the native VOL connector") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Set up shim */ + shim_data.real_op = op; + shim_data.real_op_data = op_data; + + /* Visit the links */ + if ((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, TRUE, idx_type, order, NULL, H5L__iterate2_shim, + (void *)&shim_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lvisit_by_name1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 140c4cb67c7..22d100e555c 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,79 +15,73 @@ /* Module Setup */ /****************/ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#include "H5Lmodule.h" /* This source code file is part of the H5L module */ - +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Lmodule.h" /* This source code file is part of the H5L module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opublic.h" /* File objects */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opublic.h" /* File objects */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ /* Version of external link format */ -#define H5L_EXT_VERSION 0 +#define H5L_EXT_VERSION 0 /* Valid flags for external links */ -#define H5L_EXT_FLAGS_ALL 0 +#define H5L_EXT_FLAGS_ALL 0 /* Size of local link name buffer for traversing external links */ -#define H5L_EXT_TRAVERSE_BUF_SIZE 256 - +#define H5L_EXT_TRAVERSE_BUF_SIZE 256 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static hid_t H5L__extern_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); -static ssize_t H5L__extern_query(const char *link_name, const void *udata, - size_t udata_size, void * buf /*out*/, size_t buf_size); - +static hid_t H5L__extern_traverse(const char *link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static ssize_t H5L__extern_query(const char *link_name, const void *udata, size_t udata_size, + void *buf /*out*/, size_t buf_size); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Default External Link link class */ static const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - H5L_TYPE_EXTERNAL, /* Link type id number */ - "external", /* Link name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move callback */ - NULL, /* Copy callback */ - H5L__extern_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - H5L__extern_query /* Query callback */ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + H5L_TYPE_EXTERNAL, /* Link type id number */ + "external", /* Link name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move callback */ + NULL, /* Copy callback */ + H5L__extern_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + H5L__extern_query /* Query callback */ }}; /*------------------------------------------------------------------------- @@ -110,28 +104,29 @@ static const H5L_class_t H5L_EXTERN_LINK_CLASS[1] = {{ *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ - 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 */ - hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ - 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 */ - H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ - char *elink_prefix = NULL; /* Pointer to elink prefix */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + 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 */ + 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 local_group_name[H5L_EXT_TRAVERSE_BUF_SIZE]; /* Local buffer to hold group name */ + 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 */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -139,126 +134,136 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HDassert(p); /* Check external link version & flags */ - if(((*p >> 4) & 0x0F) > H5L_EXT_VERSION) + if (((*p >> 4) & 0x0F) > H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad version number for external link") - if((*p & 0x0F) & ~H5L_EXT_FLAGS_ALL) + if ((*p & 0x0F) & ~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad flags for external link") p++; /* Gather some information from the external link's user data */ file_name = (const char *)p; fname_len = HDstrlen(file_name); - obj_name = (const char *)p + fname_len + 1; + obj_name = (const char *)p + fname_len + 1; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Get the fapl_id set for lapl_id if any */ - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get fapl for links") /* Get the location for the group holding the external link */ - if(H5G_loc(cur_group, &loc) < 0) + if (H5G_loc(cur_group, &loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* get the access flags set for lapl_id if any */ - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, &intent) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, &intent) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink file access flags") /* get the file access mode flags for the parent file, if they were not set * on lapl_id */ - if(intent == H5F_ACC_DEFAULT) + if (intent == H5F_ACC_DEFAULT) intent = H5F_INTENT(loc.oloc->file); - if((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)) + if ((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get parent's file access property list") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink callback info") /* Get file access property list */ - if(NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Make callback if it exists */ - if(cb_info.func) { - const char *parent_file_name; /* Parent file name */ - ssize_t group_name_len; /* Length of parent group name */ + if (cb_info.func) { + const char *parent_file_name; /* Parent file name */ + ssize_t group_name_len; /* Length of parent group name */ /* Get parent file name */ parent_file_name = H5F_OPEN_NAME(loc.oloc->file); /* Query length of parent group name */ - if((group_name_len = H5G_get_name(&loc, NULL, (size_t) 0, NULL)) < 0) + if ((group_name_len = H5G_get_name(&loc, NULL, (size_t)0, NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve length of group name") /* Account for null terminator */ group_name_len++; /* Check if we need to allocate larger buffer */ - if((size_t)group_name_len > sizeof(local_group_name)) { - if(NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) - HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) + if ((size_t)group_name_len > sizeof(local_group_name)) { + if (NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, + "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) } /* end if */ else parent_group_name = local_group_name; /* Get parent group name */ - if(H5G_get_name(&loc, parent_group_name, (size_t) group_name_len, NULL) < 0) + if (H5G_get_name(&loc, parent_group_name, (size_t)group_name_len, NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve group name") /* Make callback */ - if((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, cb_info.user_data) < 0) + if ((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, + cb_info.user_data) < 0) HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, H5I_INVALID_HID, "traversal operator failed") /* Check access flags */ - if((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) + if ((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") } /* end if */ /* Set file close degree for new file to "weak" */ - if(H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) + if (H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") /* Get the current elink prefix */ - if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &elink_prefix) < 0) + if (H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &elink_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get external link prefix") /* Search for the target file */ - if(NULL == (ext_file = H5F_prefix_open_file(loc.oloc->file, H5F_PREFIX_ELINK, elink_prefix, file_name, intent, fapl_id))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open external file, external link file name = '%s'", file_name) + if (NULL == (ext_file = H5F_prefix_open_file(loc.oloc->file, H5F_PREFIX_ELINK, elink_prefix, file_name, + intent, fapl_id))) + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, + "unable to open external file, external link file name = '%s'", file_name) /* Retrieve the "group location" for the file's root group */ - if(H5G_root_loc(ext_file, &root_loc) < 0) + if (H5G_root_loc(ext_file, &root_loc) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, H5I_INVALID_HID, "unable to create location for file") /* Open the object referenced in the external file */ - if((ext_obj_id = H5O_open_name(&root_loc, obj_name, FALSE)) < 0) + if (NULL == (ext_obj = H5O_open_name(&root_loc, obj_name, &opened_type))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + /* Get an ID for the external link's object */ + if ((ext_obj_id = H5VL_wrap_register(opened_type, ext_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register external link object") + /* Set return value */ ret_value = ext_obj_id; done: + /* XXX (VOL MERGE): Probably also want to consider closing ext_obj here on failures */ /* Release resources */ - if(fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for file access property list") - if(ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) + if (fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for file access property list") + if (ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problem closing external file") - if(parent_group_name && parent_group_name != local_group_name) + if (parent_group_name && parent_group_name != local_group_name) parent_group_name = (char *)H5MM_xfree(parent_group_name); - if(ret_value < 0) { + if (ret_value < 0) { /* Close object if it's open and something failed */ - if(ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for external object") + if (ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for external object") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__extern_traverse() */ - /*------------------------------------------------------------------------- * Function: H5L__extern_query * @@ -277,24 +282,24 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, *------------------------------------------------------------------------- */ static ssize_t -H5L__extern_query(const char H5_ATTR_UNUSED * link_name, const void *_udata, size_t udata_size, - void *buf /*out*/, size_t buf_size) +H5L__extern_query(const char H5_ATTR_UNUSED *link_name, const void *_udata, size_t udata_size, + void *buf /*out*/, size_t buf_size) { - const uint8_t *udata = (const uint8_t *)_udata; /* Pointer to external link buffer */ - ssize_t ret_value = SUCCEED; /* Return value */ + const uint8_t *udata = (const uint8_t *)_udata; /* Pointer to external link buffer */ + ssize_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check external link version & flags */ - if(((*udata >> 4) & 0x0F) != H5L_EXT_VERSION) + if (((*udata >> 4) & 0x0F) != H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") - if((*udata & 0x0F) & ~H5L_EXT_FLAGS_ALL) + if ((*udata & 0x0F) & ~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") /* If the buffer is NULL, skip writing anything in it and just return * the size needed */ - if(buf) { - if(udata_size < buf_size) + if (buf) { + if (udata_size < buf_size) buf_size = udata_size; /* Copy the udata verbatim up to buf_size */ @@ -308,7 +313,6 @@ H5L__extern_query(const char H5_ATTR_UNUSED * link_name, const void *_udata, siz FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__extern_query() */ - /*------------------------------------------------------------------------- * Function: H5Lcreate_external * @@ -330,63 +334,73 @@ H5L__extern_query(const char H5_ATTR_UNUSED * link_name, const void *_udata, siz *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t link_loc; /* Group location to create 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + H5L_type_t link_type = H5L_TYPE_EXTERNAL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, - lcpl_id, lapl_id); + H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(!file_name || !*file_name) + if (!file_name || !*file_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified") - if(!obj_name || !*obj_name) + if (!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified") - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!link_name || !*link_name) + if (!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get normalized copy of the link target */ - if(NULL == (norm_obj_name = H5G_normalize(obj_name))) + if (NULL == (norm_obj_name = H5G_normalize(obj_name))) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize object name") /* Combine the filename and link name into a single buffer to give to the UD link */ - file_name_len = HDstrlen(file_name) + 1; + file_name_len = HDstrlen(file_name) + 1; norm_obj_name_len = HDstrlen(norm_obj_name) + 1; - buf_size = 1 + file_name_len + norm_obj_name_len; - if(NULL == (ext_link_buf = H5MM_malloc(buf_size))) + buf_size = 1 + file_name_len + norm_obj_name_len; + if (NULL == (ext_link_buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer") /* Encode the external link information */ - p = (uint8_t *)ext_link_buf; - *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ - HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ + p = (uint8_t *)ext_link_buf; + *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ + HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ p += file_name_len; - HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ + HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Create an external link */ - if(H5L__create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, + buf_size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") done: @@ -396,7 +410,6 @@ H5Lcreate_external(const char *file_name, const char *obj_name, FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_external() */ - /*------------------------------------------------------------------------- * Function: H5L_register_external * @@ -414,18 +427,17 @@ H5Lcreate_external(const char *file_name, const char *obj_name, herr_t H5L_register_external(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(H5L_register(H5L_EXTERN_LINK_CLASS) < 0) + if (H5L_register(H5L_EXTERN_LINK_CLASS) < 0) HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "unable to register external link class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_register_external() */ - /*------------------------------------------------------------------------- * Function: H5Lunpack_elink_val * @@ -450,35 +462,34 @@ H5L_register_external(void) *------------------------------------------------------------------------- */ herr_t -H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, - unsigned *flags, const char **filename, const char **obj_path) +H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, const char **filename, + const char **obj_path) { const uint8_t *ext_linkval = (const uint8_t *)_ext_linkval; /* Pointer to the link value */ - unsigned lnk_version; /* External link format version */ - unsigned lnk_flags; /* External link flags */ - size_t len; /* Length of the filename in the linkval*/ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned lnk_version; /* External link format version */ + unsigned lnk_flags; /* External link flags */ + size_t len; /* Length of the filename in the linkval*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, - obj_path); + H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, obj_path); /* Sanity check external link buffer */ - if(ext_linkval == NULL ) + if (ext_linkval == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an external link linkval buffer") lnk_version = (*ext_linkval >> 4) & 0x0F; - lnk_flags = *ext_linkval & 0x0F; - if(lnk_version > H5L_EXT_VERSION) + lnk_flags = *ext_linkval & 0x0F; + if (lnk_version > H5L_EXT_VERSION) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") - if(lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) + if (lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") - if(link_size <= 2) + if (link_size <= 2) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid external link buffer") /* Try to do some error checking. If the last character in the linkval * (the last character of obj_path) isn't NULL, then something's wrong. */ - if(ext_linkval[link_size - 1] != '\0') + if (ext_linkval[link_size - 1] != '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer is not NULL-terminated") /* We're now guaranteed that HDstrlen won't segfault, since the buffer has @@ -489,23 +500,22 @@ H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, /* If the first NULL we found was at the very end of the buffer, then * this external link value has no object name and is invalid. */ - if((len + 1) >= (link_size - 1)) + if ((len + 1) >= (link_size - 1)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer doesn't contain an object path") /* If we got here then the buffer contains (at least) two strings packed * in the correct way. Assume it's correct and return pointers to the * filename and object path. */ - if(filename) + if (filename) *filename = (const char *)ext_linkval + 1; - if(obj_path) - *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ + if (obj_path) + *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ /* Set the flags to return */ - if(flags) + if (flags) *flags = lnk_flags; done: FUNC_LEAVE_API(ret_value) } /* end H5Lunpack_elink_val() */ - diff --git a/src/H5Lmodule.h b/src/H5Lmodule.h index d80126d6fd5..54b94a4c43a 100644 --- a/src/H5Lmodule.h +++ b/src/H5Lmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,17 +18,23 @@ * H5L package. Including this header means that the source file * is part of the H5L package. */ -#ifndef _H5Lmodule_H -#define _H5Lmodule_H +#ifndef H5Lmodule_H +#define H5Lmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5L_MODULE -#define H5_MY_PKG H5L -#define H5_MY_PKG_ERR H5E_LINK -#define H5_MY_PKG_INIT YES - -#endif /* _H5Lmodule_H */ +#define H5_MY_PKG H5L +#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. + * + * \defgroup TRAV Link Traversal + * \ingroup H5L + */ +#endif /* H5Lmodule_H */ diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index b35373da544..e37eb107d68 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,39 +23,50 @@ #error "Do not include this file outside the H5L package!" #endif -#ifndef _H5Lpkg_H -#define _H5Lpkg_H +#ifndef H5Lpkg_H +#define H5Lpkg_H /* Get package's private header */ #include "H5Lprivate.h" /* Other private headers needed by this file */ - /**************************/ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, - const void * ud_data, size_t ud_data_size, H5L_type_t type, - hid_t lcpl_id); -H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, - const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); - -#endif /* _H5Lpkg_H */ +H5_DLL 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); +H5_DLL herr_t H5L__create_soft(const char *target_path, const H5G_loc_t *cur_loc, const char *cur_name, + hid_t lcpl_id); +H5_DLL herr_t H5L__create_ud(const H5G_loc_t *link_loc, const char *link_name, const void *ud_data, + size_t ud_data_size, H5L_type_t type, hid_t lcpl_id); +H5_DLL htri_t H5L__exists(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5L__get_info_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/); +H5_DLL ssize_t H5L__get_name_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size); +H5_DLL herr_t H5L__get_val(const H5G_loc_t *loc, const char *name, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L__get_val_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size); +H5_DLL herr_t H5L__move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_loc, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id); +H5_DLL herr_t H5L__delete(const H5G_loc_t *loc, const char *name); +H5_DLL herr_t H5L__delete_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n); +H5_DLL herr_t H5L__link_copy_file(H5F_t *dst_file, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, + H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); +#endif /* H5Lpkg_H */ diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index cdd65310ede..e339d46a1d3 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,34 +15,37 @@ * This file contains private information about the H5L module * for dealing with links in an HDF5 file. */ -#ifndef _H5Lprivate_H -#define _H5Lprivate_H +#ifndef H5Lprivate_H +#define H5Lprivate_H /* Include package's public header */ #include "H5Lpublic.h" /* Private headers needed by this file */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ - +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ /**************************/ /* Library Private Macros */ /**************************/ /* Default number of soft links to traverse */ -#define H5L_NUM_LINKS 16 +#define H5L_NUM_LINKS 16 /* ======== Link creation property names ======== */ -#define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */ +#define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */ /* ======== Link access property names ======== */ -#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */ -#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */ -#define H5L_ACS_ELINK_FAPL_NAME "external link fapl" /* file access property list for external link access */ -#define H5L_ACS_ELINK_FLAGS_NAME "external link flags" /* file access flags for external link traversal */ -#define H5L_ACS_ELINK_CB_NAME "external link callback" /* callback function for external link traversal */ - +/* Number of soft links to traverse */ +#define H5L_ACS_NLINKS_NAME "max soft links" +/* External link prefix */ +#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" +/* file access property list for external link access */ +#define H5L_ACS_ELINK_FAPL_NAME "external link fapl" +/* file access flags for external link traversal */ +#define H5L_ACS_ELINK_FLAGS_NAME "external link flags" +/* callback function for external link traversal */ +#define H5L_ACS_ELINK_CB_NAME "external link callback" /****************************/ /* Library Private Typedefs */ @@ -51,87 +54,75 @@ /* User data for path traversal routine for getting link value by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of user buffer */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of user buffer */ /* Out */ - void *buf; /* User buffer */ + void *buf; /* User buffer */ } H5L_trav_gvbi_t; /* User data for path traversal routine for getting link info by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ /* Out */ - H5L_info_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gibi_t; /* User data for path traversal routine for getting name by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of name buffer */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of name buffer */ /* Out */ - char *name; /* Buffer to return name to user */ - ssize_t name_len; /* Length of full name */ + char * name; /* Buffer to return name to user */ + ssize_t name_len; /* Length of full name */ } H5L_trav_gnbi_t; /* User data for path traversal routine for removing link by index */ typedef struct { /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ } H5L_trav_rmbi_t; /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { - H5L_elink_traverse_t func; - void *user_data; + H5L_elink_traverse_t func; + void * user_data; } H5L_elink_cb_t; /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ /* General operations on links */ H5_DLL herr_t H5L_init(void); -H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, - H5G_loc_t *obj_loc, hid_t lcpl_id); -H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, - H5O_obj_create_t *ocrt_info, hid_t lcpl_id); -H5_DLL 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); -H5_DLL herr_t H5L_create_soft(const char *target_path, const H5G_loc_t *cur_loc, - const char *cur_name, hid_t lcpl_id); -H5_DLL herr_t H5L_move(const H5G_loc_t *src_loc, const char *src_name, - const H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, - hid_t lcpl_id); +H5_DLL herr_t H5L_link(const H5G_loc_t *new_loc, const char *new_name, H5G_loc_t *obj_loc, hid_t lcpl_id); +H5_DLL herr_t H5L_link_object(const H5G_loc_t *new_loc, const char *new_name, H5O_obj_create_t *ocrt_info, + hid_t lcpl_id); H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, - H5L_info_t *linkbuf/*out*/); -H5_DLL herr_t H5L_delete(const H5G_loc_t *loc, const char *name); -H5_DLL herr_t H5L_get_val(const H5G_loc_t *loc, const char *name, void *buf/*out*/, - size_t size); +H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info2_t *linkbuf /*out*/); H5_DLL herr_t H5L_register_external(void); +H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, 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); /* 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 const H5L_class_t *H5L_find_class(H5L_type_t id); -#endif /* _H5Lprivate_H */ - +#endif /* H5Lprivate_H */ diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index d25a95503be..bf1de8684ca 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,30 +21,35 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5Lpublic_H -#define _H5Lpublic_H +#ifndef H5Lpublic_H +#define H5Lpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Tpublic.h" /* Datatypes */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Opublic.h" /* Object Headers */ +#include "H5Tpublic.h" /* Datatypes */ /*****************/ /* Public Macros */ /*****************/ -/* Maximum length of a link's name */ -/* (encoded in a 32-bit unsigned integer) */ -#define H5L_MAX_LINK_NAME_LEN ((uint32_t)(-1)) /* (4GB - 1) */ +/** + * \brief Maximum length of a link's name + * + * The maximum length of a link's name is encoded in a 32-bit unsigned integer. + */ +#define H5L_MAX_LINK_NAME_LEN ((uint32_t)(-1)) /* (4GB - 1) */ -/* Macro to indicate operation occurs on same location */ +/** + * \brief Macro to indicate operation occurs on same location + */ #define H5L_SAME_LOC (hid_t)0 -/* Current version of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS 1 - -/* Previous versions of the H5L_class_t struct */ -#define H5L_LINK_CLASS_T_VERS_0 0 +/** + * \brief Current version of the H5L_class_t struct + */ +#define H5L_LINK_CLASS_T_VERS 1 #ifdef __cplusplus extern "C" { @@ -54,164 +59,2039 @@ extern "C" { /* Public Typedefs */ /*******************/ -/* Link class types. - * Values less than 64 are reserved for the HDF5 library's internal use. - * Values 64 to 255 are for "user-defined" link class types; these types are - * defined by HDF5 but their behavior can be overridden by users. - * Users who want to create new classes of links should contact the HDF5 - * development team at help@hdfgroup.org. - * These values can never change because they appear in HDF5 files. +/** + * \brief Link class types. + * + * Values less than 64 are reserved for the HDF5 library's internal use. Values + * 64 to 255 are for "user-defined" link class types; these types are defined + * by HDF5 but their behavior can be overridden by users. Users who want to + * create new classes of links should contact the HDF5 development team at + * mailto:help@hdfgroup.org. These values can never change because they appear + * in HDF5 files. */ typedef enum { - H5L_TYPE_ERROR = (-1), /* Invalid link type id */ - H5L_TYPE_HARD = 0, /* Hard link id */ - H5L_TYPE_SOFT = 1, /* Soft link id */ - H5L_TYPE_EXTERNAL = 64, /* External link id */ - H5L_TYPE_MAX = 255 /* Maximum link type id */ + H5L_TYPE_ERROR = (-1), /**< Invalid link type id */ + H5L_TYPE_HARD = 0, /**< Hard link id */ + H5L_TYPE_SOFT = 1, /**< Soft link id */ + H5L_TYPE_EXTERNAL = 64, /**< External link id */ + H5L_TYPE_MAX = 255 /**< Maximum link type id */ } H5L_type_t; -#define H5L_TYPE_BUILTIN_MAX H5L_TYPE_SOFT /* Maximum value link value for "built-in" link types */ -#define H5L_TYPE_UD_MIN H5L_TYPE_EXTERNAL /* Link ids at or above this value are "user-defined" link types. */ +/** + * \brief Maximum value link value for "built-in" link types + */ +#define H5L_TYPE_BUILTIN_MAX H5L_TYPE_SOFT +/** + * \brief Link ids at or above this value are "user-defined" link types. + */ +#define H5L_TYPE_UD_MIN H5L_TYPE_EXTERNAL +/** + * \brief Maximum link id value for "user-defined" link types. + */ +#define H5L_TYPE_UD_MAX H5L_TYPE_MAX -/* Information struct for link (for H5Lget_info/H5Lget_info_by_idx) */ +/** + * \brief Information struct for links + */ +//! typedef struct { - H5L_type_t type; /* Type of link */ - hbool_t corder_valid; /* Indicate if creation order is valid */ - int64_t corder; /* Creation order */ - H5T_cset_t cset; /* Character set of link name */ + H5L_type_t type; /**< Type of link */ + hbool_t corder_valid; /**< Indicate if creation order is valid */ + int64_t corder; /**< Creation order */ + H5T_cset_t cset; /**< Character set of link name */ union { - haddr_t address; /* Address hard link points to */ - size_t val_size; /* Size of a soft link or UD link value */ + H5O_token_t token; /**< Token of location that hard link points to */ + size_t val_size; /**< Size of a soft link or user-defined link value */ } u; -} H5L_info_t; +} H5L_info2_t; +//! /* The H5L_class_t struct can be used to override the behavior of a * "user-defined" link class. Users should populate the struct with callback * functions defined below. */ /* Callback prototypes for user-defined links */ -/* Link creation callback */ -typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, - const void *lnkdata, size_t lnkdata_size, hid_t lcpl_id); - -/* Callback for when the link is moved */ -typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, - const void *lnkdata, size_t lnkdata_size); - -/* Callback for when the link is copied */ -typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, - const void *lnkdata, size_t lnkdata_size); - -/* Callback during link traversal */ -typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, - const void *lnkdata, size_t lnkdata_size, hid_t lapl_id); -typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, - const void *lnkdata, size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); - -/* Callback for when the link is deleted */ -typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, - const void *lnkdata, size_t lnkdata_size); - -/* Callback for querying the link */ -/* Returns the size of the buffer needed */ -typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, - size_t lnkdata_size, void *buf /*out*/, size_t buf_size); - -/* User-defined link types */ -typedef struct { - int version; /* Version number of this struct */ - H5L_type_t id; /* Link type ID */ - 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 */ - H5L_traverse_0_func_t trav_func; /* Callback during link traversal */ - H5L_delete_func_t del_func; /* Callback for link deletion */ - H5L_query_func_t query_func; /* Callback for queries */ -} H5L_class_0_t; +/** + * \brief Link creation callback + */ +typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, const void *lnkdata, + size_t lnkdata_size, hid_t lcpl_id); +/** + * \brief Callback for link move + */ +typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback for link copy + */ +typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback during link traversal + */ +typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id); +/** + * \brief Callback for link deletion + */ +typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, const void *lnkdata, + size_t lnkdata_size); +/** + * \brief Callback for querying the link. + * + * Returns the size of the buffer needed. + */ +typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size, + void *buf /*out*/, size_t buf_size); +/** + * \brief Link prototype + * + * The H5L_class_t struct can be used to override the behavior of a + * "user-defined" link class. Users should populate the struct with callback + * functions defined elsewhere. + */ +//! typedef struct { - int version; /* Version number of this struct */ - H5L_type_t id; /* Link type ID */ - 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 */ - H5L_traverse_func_t trav_func; /* Callback during link traversal */ - H5L_delete_func_t del_func; /* Callback for link deletion */ - H5L_query_func_t query_func; /* Callback for queries */ + int version; /**< Version number of this struct */ + H5L_type_t id; /**< Link type ID */ + 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 */ + H5L_traverse_func_t trav_func; /**< Callback during link traversal */ + H5L_delete_func_t del_func; /**< Callback for link deletion */ + H5L_query_func_t query_func; /**< Callback for queries */ } H5L_class_t; +//! -/* Prototype for H5Literate/H5Literate_by_name() operator */ -typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, - void *op_data); - -/* Callback for external link traversal */ -typedef herr_t (*H5L_elink_traverse_t)(const char *parent_file_name, - const char *parent_group_name, const char *child_file_name, - const char *child_object_name, unsigned *acc_flags, hid_t fapl_id, - void *op_data); +/** + * \brief Prototype for H5Literate2(), H5Literate_by_name2() operator + * + * The H5O_token_t version is used in the VOL layer and future public API calls. + */ +//! +typedef herr_t (*H5L_iterate2_t)(hid_t group, const char *name, const H5L_info2_t *info, void *op_data); +//! +/** + * \brief Callback for external link traversal + */ +typedef herr_t (*H5L_elink_traverse_t)(const char *parent_file_name, const char *parent_group_name, + const char *child_file_name, const char *child_object_name, + unsigned *acc_flags, hid_t fapl_id, void *op_data); /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ -H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc, - const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Lcreate_hard(hid_t cur_loc, const char *cur_name, - hid_t dst_loc, const char *dst_name, hid_t lcpl_id, hid_t lapl_id); -H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Moves a link within an HDF5 file + * + * \fgdta_loc_id{src_loc} + * \param[in] src_name Original link name + * \fgdta_loc_id{dst_loc} + * \param[in] dst_name New link name + * \lcpl_id + * \lapl_id + * + * \return \herr_t + * + * \details H5Lmove() moves a link within an HDF5 file. The original link, + * \p src_name, is removed from \p src_loc and the new link, + * \p dst_name, is inserted at dst_loc. This change is + * accomplished as an atomic operation. + * + * \p src_loc and \p src_name identify the original link. + * \p src_loc is the original location identifier; \p src_name is + * the path to the link and is interpreted relative to \p src_loc. + * + * \p dst_loc and \p dst_name identify the new link. \p dst_loc is + * either a file or group identifier; \p dst_name is the path to + * the link and is interpreted relative to \p dst_loc. + * + * \p lcpl_id and \p lapl_id are the link creation and link access + * property lists, respectively, associated with the new link, + * \p dst_name. + * + * Through these property lists, several properties are available to + * govern the behavior of H5Lmove(). The property controlling creation + * of missing intermediate groups is set in the link creation property + * list with H5Pset_create_intermediate_group(); H5Lmove() ignores any + * other properties in the link creation property list. Properties + * controlling character encoding, link traversals, and external link + * prefixes are set in the link access property list with + * H5Pset_char_encoding(), H5Pset_nlinks(), and H5Pset_elink_prefix(), + * respectively. + * + * \note Note that H5Lmove() does not modify the value of the link; the new + * link points to the same object as the original link pointed to. + * Furthermore, if the object pointed to by the original link was already + * open with a valid object identifier, that identifier will remain valid + * after the call to H5Lmove(). + * + * \attention Exercise care in moving links as it is possible to render data in + * a file inaccessible with H5Lmove(). If the link being moved is on + * the only path leading to an HDF5 object, that object may become + * permanently inaccessible in the file. + * + * \since 1.8.0 + * + *------------------------------------------------------------------------- + */ +H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Creates an identical copy of a link with the same creation time and + * target. The new link can have a different name and be in a different + * location than the original. + * + * \fgdt_loc_id{src_loc} + * \param[in] src_name Name of the link to be copied + * \fgdt_loc_id{dst_loc} + * \param[in] dst_name Name to be assigned to the new copy + * \lcpl_id + * \lapl_id + * \return \herr_t + * + * \details H5Lcopy() copies the link specified by \p src_name from the location + * specified by \p src_loc_id to the location specified by + * \p dst_loc_id. The new copy of the link is created with the name + * \p dst_name. + * + * If \p dst_loc_id is a file identifier, \p dst_name will be + * interpreted relative to that file’s root group. + * + * The new link is created with the creation and access property lists + * specified by \p lcpl_id and \p lapl_id. The interpretation of + * \p lcpl_id is limited in the manner described in the next paragraph. + * + * H5Lcopy() retains the creation time and the target of the original + * link. However, since the link may be renamed, the character + * encoding is that specified in \p lcpl_id rather than that of the + * original link. Other link creation properties are ignored. + * + * If the link is a soft link, also known as a symbolic link, its + * target is interpreted relative to the location of the copy. + * + * Several properties are available to govern the behavior of + * H5Lcopy(). These properties are set in the link creation and access + * property lists, \p lcpl_id and \p lapl_id, respectively. The + * property controlling creation of missing intermediate groups is set + * in the link creation property list with + * H5Pset_create_intermediate_group(); this function ignores any + * other properties in the link creation property list. Properties + * controlling character encoding, link traversals, and external link + * prefixes are set in the link access property list with + * H5Pset_char_encoding(), H5Pset_nlinks(), and + * H5Pset_elink_prefix(). + * + * \note H5Lcopy() does not affect the object that the link points to. + * + * \attention H5Lcopy() cannot copy hard links across files as a hard link is + * not valid without a target object; to copy objects from one file + * to another, see H5Ocopy(). + * + * \see H5Ocopy() + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc, const char *dst_name, hid_t lcpl_id, + hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Creates a hard link to an object + * + * \fgdta_loc_id{cur_loc} + * \param[in] cur_name Name of the target object, which must already exist + * \fgdta_loc_id{dst_loc} + * \param[in] dst_name The name of the new link + * \lcpl_id + * \lapl_id + * + * \return \herr_t + * + * \details H5Lcreate_hard() creates a new hard link to a pre-existing object + * in an HDF5 file. + * + * \p cur_loc and \p cur_name specify the location + * and name, respectively, of the target object, i.e., the object that + * the new hard link points to. \p dst_loc and \p dst_name specify the + * location and name, respectively, of the new hard link. + * + * \p cur_name and \p dst_name are interpreted relative to \p cur_loc + * and \p dst_loc, respectively. If \p cur_loc and \p dst_loc are the + * same location, the HDF5 macro #H5L_SAME_LOC can be used for either + * parameter (but not both). + * + * \p lcpl_id and \p lapl_id are the link creation and access property + * lists associated with the new link. + * + * \note Hard and soft links are for use only if the target object is in the + * current file. If the desired target object is in a different file from + * the new link, an external link may be created with + * H5Lcreate_external(). + * + * \note The HDF5 library keeps a count of all hard links pointing to an + * object; if the hard link count reaches zero (0), the object will be + * deleted from the file. Creating new hard links to an object will + * prevent it from being deleted if other links are removed. The + * library maintains no similar count for soft links and they can dangle. + * + * \note The new link may be one of many that point to that object. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lcreate_hard(hid_t cur_loc, const char *cur_name, hid_t dst_loc, const char *dst_name, + hid_t lcpl_id, hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Creates a soft link + * + * \param[in] link_target An HDF5 path name + * \fgdta_loc_id{link_loc_id} + * \param[in] link_name The name of the new link + * \lcpl_id + * \lapl_id + * + * \return \herr_t + * + * \details H5Lcreate_soft() creates a new soft link to an object in an HDF5 + * file. + * + * \p link_target specifies the HDF5 path name the soft link contains. + * \p link_target can be an arbitrary HDF5 path name and is + * interpreted only at lookup time. This path may be absolute in the + * file or relative to \p link_loc_id. + * + * \p link_loc_id and \p link_name specify the location and name, + * respectively, of the new soft link. \p link_name is interpreted + * relative to \p link_loc_id and must contain only the name of the soft + * link; \p link_name may not contain any additional path elements. + * + * If \p link_loc_id is a group identifier, the object pointed to by + * \p link_name will be accessed as a member of that group. If + * \p link_loc_id is a file identifier, the object will be accessed as a + * member of the file's root group. + * + * \p lcpl_id and \p lapl_id are the link creation and access property + * lists associated with the new link. + * + * For instance, if target_path is \c ./foo, \p link_loc_id specifies + * \c ./x/y/bar, and the name of the new link is \c new_link, then a + * subsequent request for \c ./x/y/bar/new_link will return same the + * object as would be found at \c ./foo. + * + * \note H5Lcreate_soft() is for use only if the target object is in the + * current file. If the desired target object is in a different file from + * the new link, use H5Lcreate_external() to create an external link. + * + * \note Soft links and external links are also known as symbolic links as they + * use a name to point to an object; hard links employ an object’s + * address in the file. + * + * \note Unlike hard links, a soft link in an HDF5 file is allowed to dangle, + * meaning that the target object need not exist at the time that the + * link is created. + * + * \note The HDF5 library does not keep a count of soft links as it does of + * hard links. + * + * \note The new link may be one of many that point to that object. + * + * \see H5Lcreate_hard(), H5Lcreate_external() + * + * \since 1.8.0 + * + + */ +H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Removes a link from a group + * + * \fgdta_loc_id + * \param[in] name Name of the link to delete + * \lapl_id + * + * \return \herr_t + * + * \details H5Ldelete() removes the link specified by \p name from the location + * \p loc_id. + * + * If the link being removed is a hard link, H5Ldelete() also + * decrements the link count for the object to which name points. + * Unless there is a duplicate hard link in that group, this action + * removes the object to which name points from the group that + * previously contained it. + * + * Object headers keep track of how many hard links refer to an + * object; when the hard link count, also referred to as the reference + * count, reaches zero, the object can be removed from the file. The + * file space associated will then be released, i.e., identified in + * memory as freespace. Objects which are open are not removed until + * all identifiers to the object are closed. + * + * \attention Exercise caution in the use of H5Ldelete(); if the link being + * removed is on the only path leading to an HDF5 object, that + * object may become permanently inaccessible in the file. + * + * \see H5Lcreate_hard(), H5Lcreate_soft(), H5Lcreate_external() + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL 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); -H5_DLL herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, - size_t size, hid_t lapl_id); -H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Removes the \Emph{n}-th link in a group + * + * \fgdta_loc_id + * \param[in] group_name Name of subject group + * \param[in] idx_type Index or field which determines the order + * \param[in] order Order within field or index + * \param[in] n Link for which to retrieve information + * \lapl_id + * + * \return \herr_t + * + * \details H5Ldelete_by_idx() removes the \Emph{n}-th link in a group + * according to the specified order, \p order, in the specified index, + * \p index. + * + * If \p loc_id specifies the group in which the link resides, + * \p group_name can be a dot (\c .). + * + * \see H5Ldelete() + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Returns the value of a link + * + * \fgdta_loc_id + * \param[in] name Link name + * \param[out] buf The buffer to hold the link value + * \param[in] size Maximum number of bytes of link value to be returned + * \lapl_id + * + * \return \herr_t + * + * \details H5Lget_val() returns tha 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. + * + * \p size is the size of \p buf and should be the size of the link + * value being returned. This size value can be determined through a + * call to H5Lget_info(); it is returned in the \c val_size field of + * the \ref H5L_info_t \c struct. + * + * If \p size is smaller than the size of the returned value, then the + * string stored in \p buf will be truncated to \p size bytes. For + * soft links, this means that the value will not be null terminated. + * + * In the case of external links, the target file and object names are + * extracted from \p buf by calling H5Lunpack_elink_val(). + * + * The link class of link \p name can be determined with a call to + * H5Lget_info(). + * + * \p lapl_id specifies the link access property list associated with + * the link \p name. In the general case, when default link access + * properties are acceptable, this can be passed in as #H5P_DEFAULT. An + * example of a situation that requires a non-default link access + * property list is when the link is an external link; an external + * link may require that a link prefix be set in a link access + * property list (see H5Pset_elink_prefix()). + * + * 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 + * \c struct. + * + * \note This function will fail if called on a hard link. + * + * \see H5Lget_val_by_idx() + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Retrieves value of the \Emph{n}-th link in a group, according to the order within an index + * + * \fgdta_loc_id + * \param[in] group_name Group name + * \param[in] idx_type Type of index + * \param[in] order Order within field or index + * \param[in] n Link position for which to retrieve information + * \param[out] buf The buffer to hold the link value + * \param[in] size Maximum number of bytes of link value to be returned + * \lapl_id + * + * \return \herr_t + * + * \details H5Lget_val_by_idx() retrieves the value of the \Emph{n}-th link in + * a group, according to the specified order, \p order, within an + * index, \p index. + * + * For soft links, the value is an HDF5 path name. + * + * For external links, this is a compound value containing file and + * path name information; to use this external link information, it + * must first be decoded with H5Lunpack_elink_val() + * + * For user-defined links, this value will be described in the + * definition of the user-defined link type. + * + * \p loc_id specifies the location identifier of the group specified + * by \p group_name. + * + * \p group_name specifies the group in which the link exists. If + * \p loc_id already specifies the group in which the link exists, + * \p group_name must be a dot (\c .). + * + * The size in bytes of link_val is specified in \p size. The size + * value can be determined through a call to H5Lget_info_by_idx(); it + * is returned in the \c val_size field of the \ref H5L_info_t + * \c struct. If + * size is smaller than the size of the returned value, then the + * string stored in link_val will be truncated to size bytes. For soft + * links, this means that the value will not be null terminated. + * + * If the type of the link is unknown or uncertain, H5Lget_val_by_idx() + * should be called only after the type has been determined via a call + * to H5Lget_info_by_idx(). + * + * \note This function will fail if called on a hard link. + * + * \see H5Lget_val() + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Determines whether a link with the specified name exists in a group + * + * \fgdta_loc_id + * \param[in] name Link name + * \lapl_id + * + * \return \herr_t + * + * \details H5Lexists() allows an application to determine whether the link \p + * name exists in the location specified by \p loc_id. The link may be + * of any type; only the presence of a link with that name is checked. + * + * Note that H5Lexists() verifies only that the target link exists. If + * 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 + * 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. + * + * \Bold{Example:} Use the following steps to verify the existence of + * the link \c datasetD in the \c group group1/group2/softlink_to_group3/, + * where \c group1 is a member of the group specified by \c loc_id: + * + * 1. First use H5Lexists() to verify that \c group1 exists. + * 2. If \c group1 exists, use H5Lexists() again, this time with name + * set to \c group1/group2, to verify that \c group2 exists. + * 3. If \c group2 exists, use H5Lexists() with name set to + * \c group1/group2/softlink_to_group3 to verify that + * \c softlink_to_group3 exists. + * 4. If \c softlink_to_group3 exists, you can now safely use + * H5Lexists() with \c name set to + * \c group1/group2/softlink_to_group3/datasetD to verify that the + * target link, \c datasetD, exists. + * + * If the link to be verified is specified with an absolute path, the + * same approach should be used, but starting with the first link in + * the file’s root group. For instance, if \c datasetD were in + * \c /group1/group2/softlink_to_group3, the first call to H5Lexists() + * would have name set to \c /group1. + * + * Note that this is an outline and does not include all necessary + * details. Depending on circumstances, for example, you may need to + * verify that an intermediate link points to a group and that a soft + * link points to an existing target. + * + * \note The behavior of H5Lexists() was changed in the 1.10 release in the + * case where the root group, \c "/", is the name of the link. This + * change is described below: + *
    + *
  1. Let \c file denote a valid HDF5 file identifier, and let \c lapl + * denote a valid link access property list identifier. A call to + * 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.
  2. + *
  3. 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.
  4. + *
+ * Note that the function accepts link names and path names. This is + * potentially misleading to callers, and we plan to separate the + * functionality for link names and path names in a future release. + * + * \attention H5Lexists() checks the existence of only the final element in a + * relative or absolute path; it does not check any other path + * elements. The function will therefore fail when both of the + * following conditions exist: + * - \c name is not local to the group specified by \c loc_id or, + * if \c loc_id is something other than a group identifier, \c name + * is not local to the root group. + * - Any element of the relative path or absolute path in name, + * except the target link, does not exist. + * + * \version 1.10.0 Function behavior changed in this release. (See the note.) + * \since 1.8.0 + * + */ H5_DLL htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Lget_info(hid_t loc_id, const char *name, - H5L_info_t *linfo /*out*/, hid_t lapl_id); -H5_DLL herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5L_info_t *linfo /*out*/, hid_t lapl_id); -H5_DLL 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); -H5_DLL herr_t H5Literate(hid_t grp_id, H5_index_t idx_type, - H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data); -H5_DLL herr_t H5Literate_by_name(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, - H5L_iterate_t op, void *op_data, hid_t lapl_id); -H5_DLL herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, - H5L_iterate_t op, void *op_data); -H5_DLL herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, - void *op_data, hid_t lapl_id); - +/** + * \ingroup H5L + * + * \brief Returns information about a link + * + * \fgdta_loc_id + * \param[in] name Link name + * \param[out] linfo Buffer in which link information is returned + * \lapl_id + * + * \return \herr_t + * + * \details H5Lget_info2() returns information about the specified link through + * the \p linfo argument. + * + * The location identifier, \p loc_id, specifies the location of the + * link. A link name, \p name, interpreted relative to \p loc_id, + * specifies the link being queried. + * + * \p lapl_id is the link access property list associated with the + * link name. In the general case, when default link access properties + * are acceptable, this can be passed in as #H5P_DEFAULT. An example + * of a situation that requires a non-default link access property + * list is when the link is an external link; an external link may + * require that a link prefix be set in a link access property list + * (see H5Pset_elink_prefix()). + * + * H5Lget_info2() returns information about name in the data structure + * H5L_info2_t, which is described below and defined in H5Lpublic.h. + * This structure is returned in the buffer \p linfo. + * \snippet this H5L_info2_t_snip + * In the above struct, \c type specifies the link class. Valid values + * include the following: + * \link_types + * There will be additional valid values if user-defined links have + * been registered. + * + * \p corder specifies the link’s creation order position while + * \p corder_valid indicates whether the value in corder is valid. + * + * If \p corder_valid is \c TRUE, the value in \p corder is known to + * be valid; if \p corder_valid is \c FALSE, the value in \p corder is + * presumed to be invalid; \p corder starts at zero (0) and is + * incremented by one (1) as new links are created. But + * higher-numbered entries are not adjusted when a lower-numbered link + * is deleted; the deleted link's creation order position is simply + * left vacant. In such situations, the value of \p corder for the + * last link created will be larger than the number of links remaining + * in the group. + * + * \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(). + * + * \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. + * H5O_token_t is used in the VOL layer. It is defined in H5public.h + * as: + * \snippet H5public.h H5O_token_t_snip + * + * If the link is a symbolic link, \c val_size will be the length of + * the link value, e.g., the length of the HDF5 path name with a null + * terminator. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo, hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Retrieves metadata for a link in a group, according to the order + * within a field or index + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \param[in] n Link position for which to retrieve information + * \param[out] linfo Buffer in which link information is returned + * \lapl_id + * + * \return \herr_t + * + * \details H5get_info_by_idx2() returns the metadata for a link in a group + * according to a specified field or index and a specified order. The + * link for which information is to be returned is specified by \p + * idx_type, \p order, and \p n as follows: + * + * - \p idx_type specifies the field by which the links in \p + * group_name are ordered. The links may be indexed on this field, + * in which case operations seeking specific links are likely to + * complete more quickly. + * - \p order specifies the order in which + * the links are to be referenced for the purposes of this function. + * - \p n specifies the position of the subject link. Note that this + * count is zero-based; 0 (zero) indicates that the function will + * return the value of the first link; if \p n is 5, the function + * will return the value of the sixth link; etc. + * + * For example, assume that \p idx_type, \p order, and \p n are + * #H5_INDEX_NAME, #H5_ITER_DEC, and 5, respectively. #H5_INDEX_NAME + * indicates that the links are accessed in lexicographic order by + * their names. #H5_ITER_DEC specifies that the list be traversed in + * reverse order, or in decremented order. And 5 specifies that this + * call to the function will return the metadata for the 6th link + * (\c n + 1) from the end. + * + * See H5Literate2() for a list of valid values and further discussion + * regarding \p idx_type and \p order. + * + * If \p loc_id specifies the group in which the link resides, + * \p group_name can be a dot (\c .). + * + * \since 1.12.0 + * + * \see H5Lget_info2() + * + */ +H5_DLL 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, hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Retrieves name of the \Emph{n}-th link in a group, according to the + * order within a specified field or index + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \param[in] n Link position for which to retrieve information + * \param[out] name Buffer in which link name is returned + * \param[in] size Size in bytes of \p name + * \lapl_id + * + * \return Returns the size of the link name if successful; otherwise returns a + * negative value. + * + * \details H5get_name_by_idx() retrieves the name of the \Emph{n}-th link in a + * group, according to the specified order, \p order, within a specified + * field or index, \p idx_type. + * + * \p idx_type specifies the index that is used. Valid values include + * the following: + * \indexes + * + * \p order specifies the order in which objects are inspected along + * the index specified in \p idx_type. Valid values include the + * following: + * \orders + * + * If \p loc_id specifies the group in which the link resides, + * \p group_name can be a dot (\c .). + * + * The size in bytes of name is specified in \p size. If \p size is + * unknown, it can be determined via an initial H5Lget_name_by_idx() + * call with name set to NULL; the function's return value will be the + * size of the name. + * + * \note Please note that in order for the specified index to correspond to the + * creation order index, \p order must be set to #H5_ITER_INC or + * #H5_ITER_DEC when calling H5Lget_name_by_idx(). \note The index \p n + * passed to H5Lget_name_by_idx() is the index of the link within the + * link table, sorted according to \p order and \p idx_type. If order is + * #H5_ITER_NATIVE, then the link table is not sorted, and it does not + * matter what \p idx_type is. Specifying #H5_ITER_NATIVE does not + * guarantee any particular order, only that it remains consistent. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * \ingroup TRAV + * + * \brief Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * \group_id{grp_id} + * \idx_type + * \order + * \param[in,out] idx Pointer to an iteration index to allow + * continuing a previous iteration + * \op + * \op_data + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \details H5Literate2() iterates through the links in a file or + * group, \p group_id, in the order of the specified + * index, \p idx_type, using a user-defined callback routine + * \p op. H5Literate2() does not recursively follow links into + * subgroups of the specified group. + * + * Three parameters are used to manage progress of the iteration: + * \p idx_type, \p order, and \p idx_p. + * + * \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 unnecessary, so the iteration + * may begin more quickly. + * + * \p order specifies the order in which objects are to be inspected + * along the index \p idx_type. + * + * \p idx_p tracks the iteration and allows an iteration to be + * resumed if it was stopped before all members were processed. It is + * passed in by the application with a starting point and returned by + * the library with the point at which the iteration stopped. + * + * \p op_data is a user-defined pointer to the data required to + * process links in the course of the iteration. This pointer is + * passed back to each step of the iteration in the \p op callback + * function's \p op_data parameter. \p op is invoked for each link + * encounter. + * + * \p op_data is passed to and from each iteration and can be used to + * supply or aggregate information across iterations. + * + * \remark Same pattern of behavior as H5Giterate(). + * + * \note This function is also available through the H5Literate() macro. + * + * \warning The behavior of H5Literate2() is undefined if the link + * membership of \p group_id changes during the iteration. + * This does not limit the ability to change link destinations + * while iterating, but caution is advised. + * + * + * \since 1.12.0 + * + * \see H5Literate_by_name2(), H5Lvisit2(), H5Lvisit_by_name2() + * + */ +H5_DLL herr_t H5Literate2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate2_t op, void *op_data); +/** + * \ingroup TRAV + * + * \brief Iterates through links in a group + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \param[in,out] idx iteration position at which to start (\Emph{IN}) or + * position at which an interrupted iteration may be restarted + * (\Emph{OUT}) + * \op + * \op_data + * \lapl_id + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \details H5Literate_by_name2() iterates through the links in a group + * specified by \p loc_id and \p group_name, in the order of the + * specified index, \p idx_type, using a user-defined callback routine + * \p op. H5Literate_by_name2() does not recursively follow links into + * subgroups of the specified group. + * + * \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 unnecessary, so the iteration 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 specified in \p idx_type. Valid values include the + * following: + * \orders + * + * \p idx_p allows an interrupted iteration to be resumed; it is + * passed in by the application with a starting point and returned by + * the library with the point at which the iteration stopped. + * + * \note H5Literate_by_name2() is not recursive. In particular, if a member of + * \p group_name is found to be a group, call it \c subgroup_a, + * H5Literate_by_name2() does not examine the members of \c subgroup_a. + * When recursive iteration is required, the application must handle the + * recursion, explicitly calling H5Literate_by_name2() on discovered + * subgroups. + * + * \note H5Literate_by_name2() assumes that the membership of the group being + * iterated over remains unchanged through the iteration; if any of the + * links in the group change during the iteration, the function’s + * behavior is undefined. Note, however, that objects pointed to by the + * links can be modified. + * + * \note H5Literate_by_name2() is the same as H5Literate2(), except that + * H5Literate2() always proceeds in alphanumeric order. + * + * \since 1.12.0 + * + * \see H5Literate(), H5Lvisit() + * + */ +H5_DLL 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, H5L_iterate2_t op, void *op_data, + hid_t lapl_id); +/** + * \ingroup TRAV + * + * \brief Recursively visits all links starting from a specified group + * + * \group_id{grp_id} + * \idx_type + * \order + * \op + * \op_data + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \details H5Lvisit2() is a recursive iteration function to visit all links in + * and below a group in an HDF5 file, thus providing a mechanism for + * an application to perform a common set of operations across all of + * those links or a dynamically selected subset. For non-recursive + * iteration across the members of a group, see H5Literate2(). + * + * The group serving as the root of the iteration is specified by its + * group or file identifier, \p group_id. + * + * Two parameters are used to establish the iteration: \p idx_type and + * \p 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 unnecessary, so the iteration may + * begin more quickly. Valid values include the following: + * \indexes + * + * 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 + * lexicographic 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 + * + * \p op is a callback function of type \ref H5L_iterate2_t that is invoked + * for each link encountered. + * \snippet this H5L_iterate2_t_snip + * + * The \ref H5L_info2_t struct is defined (in H5Lpublic.h) as follows: + * \snippet this H5L_info2_t_snip + * + * The possible return values from the callback function, and the + * effect of each, are as follows: + * \li Zero causes the visit iterator to continue, returning zero when + * all group members have been processed. + * \li A positive value causes the visit iterator to immediately + * return that positive value, indicating short-circuit success. + * \li A negative value causes the visit iterator to immediately + * return that value, indicating failure. + * + * The H5Lvisit2() \p op_data parameter is a user-defined pointer to + * the data required to process links in the course of the iteration. + * This pointer is passed back to each step of the iteration in the + * \p op callback function's \p op_data parameter. + * + * H5Lvisit2() and H5Ovisit2() are companion functions: one for + * examining and operating on links; the other for examining and + * operating on the objects that those links point to. Both functions + * ensure that by the time the function completes successfully, every + * link or object below the specified point in the file has been + * presented to the application for whatever processing the + * application requires. + * + * \since 1.12.0 + * + * \see H5Literate() + * + */ +H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, + void *op_data); +/** + * \ingroup TRAV + * + * \brief Recursively visits all links starting from a specified group + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \op + * \op_data + * \lapl_id + * + * \return \herr_t + * + * \details H5Lvisit_by_name2() is a recursive iteration function to visit all + * links in and below a group in an HDF5 file, thus providing a + * mechanism for an application to perform a common set of operations + * across all of those links or a dynamically selected subset. For + * non-recursive iteration across the members of a group, see + * H5Literate2(). + * + * The group serving as the root of the iteration is specified by the + * \p loc_id / \p group_name parameter pair. \p loc_id specifies a + * file or group; group_name specifies either a group in the file + * (with an absolute name based in the file’s root group) or a group + * relative to \p loc_id. If \p loc_id fully specifies the group that + * is to serve as the root of the iteration, group_name should be '.' + * (a dot). (Note that when \p loc_id fully specifies the the group + * that is to serve as the root of the iteration, the user may wish to + * consider using H5Lvisit2() instead of H5Lvisit_by_name2().) + * + * Two parameters are used to establish the iteration: \p idx_type and + * \p 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 + * begin more quickly. Valid values include the following: + * \indexes + * + * 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 + * lexicographic 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 \p op callback function, the related \ref H5L_info2_t + * \c struct, and the effect that the callback function's return value + * has on the application are described in H5Lvisit2(). + * + * The H5Lvisit_by_name2() \p op_data parameter is a user-defined + * pointer to the data required to process links 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. + * + * \p lapl_id is a link access property list. In the general case, + * when default link access properties are acceptable, this can be + * passed in as #H5P_DEFAULT. An example of a situation that requires + * a non-default link access property list is when the link is an + * external link; an external link may require that a link prefix be + * set in a link access property list (see H5Pset_elink_prefix()). + * + * H5Lvisit_by_name2() and H5Ovisit_by_name2() are companion + * functions: one for examining and operating on links; the other for + * examining and operating on the objects that those links point to. + * Both functions ensure that by the time the function completes + * successfully, every link or object below the specified point in the + * file has been presented to the application for whatever processing + * the application requires. + * + * \since 1.12.0 + * + */ +H5_DLL 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); /* UD link functions */ -H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Creates a link of a user-defined type + * + * \loc_id{link_loc_id} + * \param[in] link_name Link name + * \param[in] link_type User-defined link class + * \param[in] udata User-supplied link information + * \param[in] udata_size Size of udata buffer + * \lcpl_id + * \lapl_id + * + * \return \herr_t + * + * \details H5Lcreate_ud() creates a link of user-defined type \p link_type + * named \p link_name at the location specified in \p link_loc_id with + * user-specified data \p udata. + * + * \p link_name is interpreted relative to \p link_loc_id. + * + * Valid values for the link class of the new link, \p link_type, + * include #H5L_TYPE_EXTERNAL and any user-defined link classes that + * have been registered with the library. See H5Lregister() for + * further information. + * + * The format of the information pointed to by \p udata is defined by + * the user. \p udata_size specifies the size of the \p udata buffer. + * \p udata may be NULL if \p udata_size is zero (0). + * + * The property lists specified by \p lcpl_id and \p lapl_id specify + * properties used to create and access the link. + * + * \note The external link type, #H5L_TYPE_EXTERNAL, included in the HDF5 + * library distribution, is implemented as a user-defined link type. This + * was done, in part, to provide a model for the implementation of other + * user-defined links. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * \ingroup H5LA + * + * \brief Registers a user-defined link class or changes behavior of an + * existing class + * + * \param[in] cls Pointer to a buffer containing the struct describing the + * user-defined link class + * + * \return \herr_t + * + * \details H5Lregister() registers a class of user-defined links, or changes + * the behavior of an existing class. + * + * \p cls is a pointer to a buffer containing a copy of the + * H5L_class_t struct. This struct is defined in H5Lpublic.h as + * follows: + * \snippet this H5L_class_t_snip + * + * The class definition passed with \p cls must include at least the + * following: + * \li An H5L_class_t version (which should be #H5L_LINK_CLASS_T_VERS) + * \li A link class identifier, \c class_id + * \li A traversal function, \c trav_func + * + * Remaining \c struct members are optional and may be passed as NULL. + * + * The link class passed in \c class_id must be in the user-definable + * range between #H5L_TYPE_UD_MIN and #H5L_TYPE_UD_MAX + * (see the table below) and will override + * any existing link class with that identifier. + * + * As distributed, valid values of \c class_id used in HDF5 include + * the following (defined in H5Lpublic.h): + * \link_types + * + * The hard and soft link class identifiers cannot be modified or + * reassigned, but the external link class is implemented as an + * example in the user-definable link class identifier range. + * H5Lregister() is used to register additional link classes. It could + * also be used to modify the behavior of the external link class, + * though that is not recommended. + * + * The following table summarizes existing link types and values and + * the reserved and user-definable link class identifier value ranges. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Link class identifier or Value rangeDescriptionLink class or label
0 to 63Reserved range
64 to 255User-definable range
64Minimum user-defined value#H5L_TYPE_UD_MIN
64External link#H5L_TYPE_EXTERNAL
255Maximum user-defined value#H5L_TYPE_UD_MAX
255Maximum value#H5L_TYPE_MAX
-1Error#H5L_TYPE_ERROR
+ * + * Note that HDF5 internally registers user-defined link classes only + * by the numeric value of the link class identifier. An application, + * on the other hand, will generally use a name for a user-defined + * class, if for no other purpose than as a variable name. Assume, + * for example, that a complex link type is registered with the link + * class identifier 73 and that the code includes the following + * assignment: + * \code + * H5L_TYPE_COMPLEX_A = 73 + * \endcode + * The application can refer to the link class with a term, + * \c H5L_TYPE_COMPLEX_A, that conveys meaning to a human reviewing + * the code, while HDF5 recognizes it by the more cryptic numeric + * identifier, 73. + * + * \attention Important details and considerations include the following: + * \li If you plan to distribute files or software with a + * user-defined link class, please contact the Help Desk at + * The HDF Group to help prevent collisions between \c class_id + * values. See below. + * \li As distributed with HDF5, the external link class is + * implemented as an example of a user-defined link class with + * #H5L_TYPE_EXTERNAL equal to #H5L_TYPE_UD_MIN. \c class_id in + * the H5L_class_t \c struct must not equal #H5L_TYPE_UD_MIN + * unless you intend to overwrite or modify the behavior of + * external links. + * \li H5Lregister() can be used only with link class identifiers + * in the user-definable range (see table above). + * \li The hard and soft links defined by the HDF5 library, + * #H5L_TYPE_HARD and #H5L_TYPE_SOFT, reside in the reserved + * range below #H5L_TYPE_UD_MIN and cannot be redefined or + * modified. + * \li H5Lis_registered() can be used to determine whether a desired + * link class identifier is available. \Emph{Note that this + * function will tell you only whether the link class identifier + * has been registered with the installed copy of HDF5; it + * cannot tell you whether the link class has been registered + * with The HDF Group.} + * \li #H5L_TYPE_MAX is the maximum allowed value for a link type + * identifier. + * \li #H5L_TYPE_UD_MIN equals #H5L_TYPE_EXTERNAL. + * \li #H5L_TYPE_UD_MAX equals #H5L_TYPE_MAX. + * \li #H5L_TYPE_ERROR indicates that an error has occurred. + * + * \note \Bold{Registration with The HDF Group:}\n + * There are sometimes reasons to take a broader approach to registering + * a user-defined link class than just invoking H5Lregister(). For + * example: + * \li A user-defined link class is intended for use across an + * organization, among collaborators, or across a community of users. + * \li An application or library overlying HDF5 invokes a user-defined + * link class that must be shipped with the software. + * \li Files are distributed that make use of a user-defined link class. + * \li Or simply, a specific user-defined link class is thought to be + * widely useful. + * + * In such cases, you are encouraged to register that link class with + * The HDF Group's Helpdesk. The HDF Group maintains a registry of known + * user-defined link classes and tracks the selected link class + * identifiers. This registry is intended to reduce the risk of + * collisions between \c class_id values and to help coordinate the use + * of specialized link classes. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Lregister(const H5L_class_t *cls); +/** + * \ingroup H5LA + * + * \brief Unregisters a class of user-defined links + * + * \param[in] id User-defined link class identifier + * + * \return \herr_t + * + * \details H5Lunregister() unregisters a class of user-defined links, + * preventing them from being traversed, queried, moved, etc. + * + * \note A link class can be re-registered using H5Lregister(). + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Lunregister(H5L_type_t id); +/** + * \ingroup H5LA + * + * \brief Determines whether a class of user-defined links is registered + * + * \param[in] id User-defined link class identifier + * + * \return \htri_t + * + * \details H5Lis_registered() tests whether a user-defined link class is + * currently registered, either by the HDF5 library or by the user + * through the use of H5Lregister(). + * + * \note A link class must be registered to create new links of that type or to + * traverse existing links of that type. + * + * \since 1.8.0 + * + */ H5_DLL htri_t H5Lis_registered(H5L_type_t id); /* External link functions */ -H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval/*in*/, size_t link_size, - unsigned *flags, const char **filename/*out*/, const char **obj_path /*out*/); -H5_DLL 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); +/** + * \ingroup H5L + * + * \brief Decodes external link information + * + * \param[in] ext_linkval Buffer containing external link information + * \param[in] link_size Size, in bytes, of the \p ext_linkval buffer + * \param[out] flags External link flags, packed as a bitmap (\Emph{Reserved as + * a bitmap for flags; no flags are currently defined, so the + * only valid value * is 0.}) + * \param[out] filename Returned filename \param[out] obj_path Returned + * object path, relative to \p filename + * + * \return \herr_t + * + * \details H5Lunpack_elink_val() decodes the external link information + * returned by H5Lget_val() in the \p ext_linkval buffer. + * + * \p ext_linkval should be the buffer set by H5Lget_val() and will + * consist of two NULL-terminated strings, the filename and object + * path, one after the other. + * + * Given this buffer, H5Lunpack_elink_val() creates pointers to the + * filename and object path within the buffer and returns them in + * \p filename and \p obj_path, unless they are passed in as NULL. + * + * H5Lunpack_elink_val() requires that \p ext_linkval contain a + * concatenated pair of null-terminated strings, so use of this + * function on a string that is not an external link \p udata buffer + * may result in a segmentation fault. This failure can be avoided by + * adhering to the following procedure: + *
    + *
  1. Call H5Lget_info() to get the link type and the size of the + * link value.
  2. + *
  3. Verify that the link is an external link, i.e., that its link + * type is #H5L_TYPE_EXTERNAL.
  4. + *
  5. Call H5Lget_val() to get the link value.
  6. + *
  7. Call H5Lunpack_elink_val() to unpack that value.
  8. + *
+ * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval /*in*/, size_t link_size, unsigned *flags, + const char **filename /*out*/, const char **obj_path /*out*/); +/** + * \ingroup H5L + * + * \brief Creates an external link, a soft link to an object in a different file. + * + * \param[in] file_name Name of the target file containing the target object. + * \param[in] obj_name Path within the target file to the target object + * \fgdt_loc_id{link_loc_id} + * \param[in] link_name Name of the new link, relative to \p link_loc_id + * \lcpl_id + * \lapl_id + * \return \herr_t + * + * \details H5Lcreate_external() creates a new external link. An external link + * is a soft link to an object in a different HDF5 file from the + * location of the link, i.e., to an external object. + * + * \p file_name identifies the target file containing the target + * object; \p obj_name specifies the path of the target object within + * that file. \p obj_name must be an absolute pathname in + * \p file_name, i.e., it must start at the target file’s root group, + * but it is not interpreted until an application attempts to traverse + * it. + * + * \p link_loc_id and \p link_name specify the location and name, + * respectively, of the new link. \p link_name is interpreted relative + * to \p link_loc_id. + * + * \p lcpl_id is the link creation property list used in creating the + * new link. + * + * \p lapl_id is the link access property list used in traversing the + * new link. Note that an external file opened by the traversal of an + * external link is always opened with the weak file close degree + * property setting, #H5F_CLOSE_WEAK (see H5Pset_fclose_degree()); + * any file close degree property setting in \p lapl_id is ignored. + * + * An external link behaves similarly to a soft link, and like a soft + * link in an HDF5 file, it may dangle: the target file and object + * need not exist at the time that the external link is created. + * + * When the external link \p link_name is accessed, the library will + * search for the target file \p file_name as described below: + * + * - If \p file_name is a relative pathname, the following steps are + * performed: + * - The library will get the prefix(es) set in the environment + * variable \c HDF5_EXT_PREFIX and will try to prepend each prefix + * to \p file_name to form a new \p file_name. + * - If the new \p file_name does not exist or if \c HDF5_EXT_PREFIX + * is not set, the library will get the prefix set via + * H5Pset_elink_prefix() and prepend it to \p file_name to form a + * new \p file_name. + * - If the new \p file_name does not exist or no prefix is being + * set by H5Pset_elink_prefix(), then the path of the file + * associated with \p link_loc_id is obtained. This path can be + * the absolute path or the current working directory plus the + * relative path of that file when it is created/opened. The + * library will prepend this path to \p file_name to form a new + * \p file_name. + * - If the new \p file_name does not exist, then the library will + * look for \p file_name and will return failure/success + * accordingly. + * - If \p file_name is an absolute pathname, the library will first + * try to find \p file_name. If \p file_name does not exist, + * \p file_name is stripped of directory paths to form a new + * \p file_name. The search for the new \p file_name then follows + * the same steps as described above for a relative pathname. See + * examples below illustrating how target_file_name is stripped to + * form a new \p file_name. + * + * Note that \p file_name is considered to be an absolute pathname + * when the following condition is true: + * + * - For Unix, the first character of \p file_name is a slash (\c /). + * For example, consider a \p file_name of \c /tmp/A.h5. + * If that target file does not exist, the new \p file_name after + * stripping will be \c A.h5. + * - For Windows, there are 6 cases: + * -# \p file_name is an absolute drive with absolute pathname. + * For example, consider a \p file_name of \c /tmp/A.h5. If that + * target file does not exist, the new \p file_name after + * stripping will be \c A.h5. + * -# \p file_name is an absolute pathname without specifying drive + * name. For example, consider a \p file_name of \c /tmp/A.h5. + * If that target file does not exist, the new \p file_name after + * stripping will be \c A.h5. + * -# \p file_name is an absolute drive with relative pathname. + * For example, consider a \p file_name of \c /tmp/A.h5. If that + * target file does not exist, the new \p file_name after + * stripping will be \c tmp\A.h5. + * -# \p file_name is in UNC (Uniform Naming Convention) format with + * server name, share name, and pathname. For example, consider + * a \p file_name of \c /tmp/A.h5. If that target file does not + * exist, the new \p file_name after stripping will be \c A.h5. + * -# \p file_name is in Long UNC (Uniform Naming Convention) format + * with server name, share name, and pathname. For example, + * consider a \p file_name of \c /tmp/A.h5. If that target file + * does not exist, the new \p file_name after stripping will be + * \c A.h5. + * -# \p file_name is in Long UNC (Uniform Naming Convention) format + * with an absolute drive and an absolute pathname. For example, + * consider a \p file_name of \c /tmp/A.h5. If that target file + * does not exist, the new \p file_name after stripping will be + * \c A.h5. + * + * The library opens target file \p file_name with the file access + * property list that is set via H5Pset_elink_fapl() when the external + * link link_name is accessed. If no such property list is set, the + * library uses the file access property list associated with the file + * of \p link_loc_id to open the target file. + * + * If an application requires additional control over file access + * flags or the file access property list, see H5Pset_elink_cb(); this + * function enables the use of an external link callback function as + * described in H5L_elink_traverse_t(). + * + * \attention A file close degree property setting (H5Pset_fclose_degree()) in + * the external link file access property list or in the external + * link callback function will be ignored. A file opened by means of + * traversing an external link is always opened with the weak file + * close degree property setting, #H5F_CLOSE_WEAK . + * + * \see H5Lcreate_hard(), H5Lcreate_soft(), H5Lcreate_ud() + * + * \since 1.8.0 + */ +H5_DLL 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); + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* Macros */ + +/* Previous versions of the H5L_class_t struct */ +#define H5L_LINK_CLASS_T_VERS_0 0 + +/* Typedefs */ + +//! +/** + * Information struct for link (for H5Lget_info1() and H5Lget_info_by_idx1()) + */ +typedef struct { + H5L_type_t type; /**< Type of link */ + hbool_t corder_valid; /**< Indicate if creation order is valid */ + int64_t corder; /**< Creation order */ + H5T_cset_t cset; /**< Character set of link name */ + union { + haddr_t address; /**< Address hard link points to */ + size_t val_size; /**< Size of a soft link or UD link value */ + } u; +} H5L_info1_t; +//! + +/** Callback during link traversal */ +typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata, + size_t lnkdata_size, hid_t lapl_id); + +/** User-defined link types */ +typedef struct { + int version; /**< Version number of this struct */ + H5L_type_t id; /**< Link type ID */ + 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 */ + H5L_traverse_0_func_t trav_func; /**< Callback during link traversal */ + H5L_delete_func_t del_func; /**< Callback for link deletion */ + H5L_query_func_t query_func; /**< Callback for queries */ +} H5L_class_0_t; + +/** Prototype for H5Literate1() / H5Literate_by_name1() operator */ +//! +typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, void *op_data); +//! + +/* Function prototypes */ +/** + * \ingroup H5L + * + * \brief Returns information about a link + * + * \fgdta_loc_id + * \param[in] name Link name + * \param[out] linfo Buffer in which link information is returned + * \lapl_id + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Lget_info2() or the macro H5Lget_info(). + * + * \details H5Lget_info1() returns information about the specified link through + * the \p linfo argument. + * + * The location identifier, \p loc_id, specifies the location of the + * link. A link name, \p name, interpreted relative to \p loc_id, + * specifies the link being queried. + * + * \p lapl_id is the link access property list associated with the + * link \p name. In the general case, when default link access + * properties are acceptable, this can be passed in as #H5P_DEFAULT. + * An example of a situation that requires a non-default link access + * property list is when the link is an external link; an external + * link may require that a link prefix be set in a link access + * property list (see H5Pset_elink_prefix()). + * + * H5Lget_info1() returns information about name in the data structure + * \ref H5L_info1_t, which is described below and defined in + * H5Lpublic.h. This structure is returned in the buffer \p linfo. + * \snippet this H5L_info1_t_snip + * In the above struct, type specifies the link class. Valid values + * include the following: + * \link_types + * There will be additional valid values if user-defined links have + * been registered. + * + * \c corder specifies the link’s creation order position while + * \c corder_valid indicates whether the value in \c corder is valid. + * + * If \c corder_valid is \c TRUE, the value in \c corder is known to + * be valid; if \c corder_valid is \c FALSE, the value in \c corder is + * presumed to be invalid; + * + * \c corder starts at zero (0) and is incremented by one (1) as new + * links are created. But higher-numbered entries are not adjusted + * when a lower-numbered link is deleted; the deleted link’s creation + * order position is simply left vacant. In such situations, the value + * of \c corder for the last link created will be larger than the + * number of links remaining in the group. + * + * \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(). + * + * \c address and \c val_size are returned for hard and symbolic + * links, respectively. Symbolic links include soft and external links + * and some user-defined links. + * + * If the link is a hard link, \c address specifies the file address + * that the link points to. + * + * If the link is a symbolic link, \c val_size will be the length of + * the link value, e.g., the length of the HDF5 path name with a null + * terminator. + * + * \version 1.12.0 Function was deprecated. + * \version 1.8.2 Fortran subroutine added in this release. + * \version 1.8.4 Fortran subroutine syntax changed in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t lapl_id); +/** + * \ingroup H5L + * + * \brief Retrieves metadata for a link in a group, according to the order + * within a field or index + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \param[in] n Link position for which to retrieve information + * \param[out] linfo Buffer in which link information is returned + * \lapl_id + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Lget_info_by_idx2() and the macro + * H5Lget_info_by_idx(). + * + * \details H5get_info_by_idx1() returns the metadata for a link in a group + * according to a specified field or index and a specified order. + * + * The link for which information is to be returned is specified by \p + * idx_type, \p order, and \p n as follows: + * + * - \p idx_type specifies the field by which the links in \p + * group_name are ordered. The links may be indexed on this field, + * in which case operations seeking specific links are likely to + * complete more quickly. + * - \p order specifies the order in which + * the links are to be referenced for the purposes of this function. + * - \p n specifies the position of the subject link. Note that this + * count is zero-based; 0 (zero) indicates that the function will + * return the value of the first link; if \p n is 5, the function + * will return the value of the sixth link; etc. + * + * For example, assume that \p idx_type, \p order, and \p n are + * #H5_INDEX_NAME, #H5_ITER_DEC, and 5, respectively. #H5_INDEX_NAME + * indicates that the links are accessed in lexicographic order by + * their names. #H5_ITER_DEC specifies that the list be traversed in + * reverse order, or in decremented order. And 5 specifies that this + * call to the function will return the metadata for the 6th link + * (\c n + 1) from the end. + * + * See H5Literate1() for a list of valid values and further discussion + * regarding \p idx_type and \p order. + * + * If \p loc_id specifies the group in which the link resides, + * \p group_name can be a dot (\c .). + * + * \version 1.12.0 Function was renamed to H5Lget_index_by_idx1() and deprecated. + * \version 1.8.4 Fortran subroutine syntax changed in this release. + * \version 1.8.2 Fortran subroutine added in this release. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * \ingroup TRAV + * + * \brief Iterates over links in a group, with user callback routine, + * according to the order within an index. + * + * \group_id{grp_id} + * \idx_type + * \order + * \param[in,out] idx Pointer to an iteration index to allow + * continuing a previous iteration + * \op + * \op_data + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \deprecated Deprecated in favor of H5Literate2(). + * + * \details H5Literate1() iterates through the links in a file or + * group, \p group_id, in the order of the specified + * index, \p idx_type, using a user-defined callback routine + * \p op. H5Literate1() does not recursively follow links into + * subgroups of the specified group. + * + * Three parameters are used to manage progress of the iteration: + * \p idx_type, \p order, and \p idx_p. + * + * \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 unnecessary, so the iteration + * may begin more quickly. + * + * \p order specifies the order in which objects are to be inspected + * along the index \p idx_type. + * + * \p idx_p tracks the iteration and allows an iteration to be + * resumed if it was stopped before all members were processed. It is + * passed in by the application with a starting point and returned by + * the library with the point at which the iteration stopped. + * + * \p op_data is a user-defined pointer to the data required to + * process links in the course of the iteration. This pointer is + * passed back to each step of the iteration in the \p op callback + * function's \p op_data parameter. \p op is invoked for each link + * encounter. + * + * \p op_data is passed to and from each iteration and can be used to + * supply or aggregate information across iterations. + * + * \remark Same pattern of behavior as H5Giterate(). + * + * \note This function is also available through the H5Literate() macro. + * + * \warning The behavior of H5Literate1() is undefined if the link + * membership of \p group_id changes during the iteration. + * This does not limit the ability to change link destinations + * while iterating, but caution is advised. + * + * + * \version 1.12.0 Function was deprecated in this release. + * \since 1.8.0 + * + * \see H5Literate_by_name2(), H5Lvisit2(), H5Lvisit_by_name2() + * + */ +H5_DLL herr_t H5Literate1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5L_iterate1_t op, void *op_data); +/** + * \ingroup TRAV + * + * \brief Iterates through links in a group by its name + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \param[in,out] idx iteration position at which to start (\Emph{IN}) or + * position at which an interrupted iteration may be restarted + * (\Emph{OUT}) + * \op + * \op_data + * \lapl_id + * + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Literate_by_name2() or the macro + * H5Literate_by_name(). + * + * \details H5Literate_by_name1() iterates through the links in a group + * specified by \p loc_id and \p group_name, in the order of the + * specified index, \p idx_type, using a user-defined callback routine + * \p op. H5Literate_by_name1() does not recursively follow links into + * subgroups of the specified group. + * + * \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 unnecessary, so the iteration 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 specified in \p idx_type. Valid values include the + * following: + * \orders + * + * \p idx allows an interrupted iteration to be resumed; it is + * passed in by the application with a starting point and returned by + * the library with the point at which the iteration stopped. + * + * \note H5Literate_by_name1() is not recursive. In particular, if a member of + * \p group_name is found to be a group, call it \c subgroup_a, + * H5Literate_by_name1() does not examine the members of \c subgroup_a. + * When recursive iteration is required, the application must handle the + * recursion, explicitly calling H5Literate_by_name1() on discovered + * subgroups. + * + * \note H5Literate_by_name1() assumes that the membership of the group being + * iterated over remains unchanged through the iteration; if any of the + * links in the group change during the iteration, the function’s + * behavior is undefined. Note, however, that objects pointed to by the + * links can be modified. + * + * \note H5Literate_by_name1() is the same as H5Giterate(), except that + * H5Giterate() always proceeds in lexicographic order. + * + * \version 1.12.0 Function H5Literate_by_name() was renamed to + * H5Literate_by_name1() and deprecated. + * \version 1.8.8 Fortran subroutine added. + * + * \since 1.8.0 + * + */ +H5_DLL 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, H5L_iterate1_t op, void *op_data, + hid_t lapl_id); +/** + * \ingroup TRAV + * + * \brief Recursively visits all links starting from a specified group + * + * \group_id{grp_id} + * \idx_type + * \order + * \op + * \op_data + * + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Lvisit2() or the macro H5Lvisit(). + * + * \details H5Lvisit1() is a recursive iteration function to visit all links in + * and below a group in an HDF5 file, thus providing a mechanism for + * an application to perform a common set of operations across all of + * those links or a dynamically selected subset. For non-recursive + * iteration across the members of a group, see H5Literate1(). + * + * The group serving as the root of the iteration is specified by its + * group or file identifier, \p group_id. + * + * Two parameters are used to establish the iteration: \p idx_type and + * \p 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 unnecessary, so the iteration may + * begin more quickly. Valid values include the following: + * \indexes + * + * 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 + * lexicographic 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 + * + * \p op is a callback function of type \ref H5L_iterate1_t that is invoked + * for each link encountered. + * \snippet this H5L_iterate1_t_snip + * + * The \ref H5L_info1_t struct is defined (in H5Lpublic.h) as follows: + * \snippet this H5L_info1_t_snip + * + * The possible return values from the callback function, and the + * effect of each, are as follows: + * \li Zero causes the visit iterator to continue, returning zero when + * all group members have been processed. + * \li A positive value causes the visit iterator to immediately + * return that positive value, indicating short-circuit success. + * \li A negative value causes the visit iterator to immediately + * return that value, indicating failure. + * + * The H5Lvisit1() \p op_data parameter is a user-defined pointer to + * the data required to process links in the course of the iteration. + * This pointer is passed back to each step of the iteration in the + * \p op callback function's \p op_data parameter. + * + * H5Lvisit1() and H5Ovisit1() are companion functions: one for + * examining and operating on links; the other for examining and + * operating on the objects that those links point to. Both functions + * ensure that by the time the function completes successfully, every + * link or object below the specified point in the file has been + * presented to the application for whatever processing the + * application requires. + * + * \version 1.12.0 Function was renamed from H5Lvisit() to H5Lvisit1() and + * deprecated. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, + void *op_data); +/** + * \ingroup TRAV + * + * \brief Recursively visits all links starting from a specified group + * + * \loc_id + * \param[in] group_name Group name + * \idx_type + * \order + * \op + * \op_data + * \lapl_id + * + * \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.} + * \return \failure{Negative if an error occurs in the library, or the negative + * value returned by one of the operators.} + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Lvisit_by_name2() or the macro H5Lvisit_by_name(). + * + * \details H5Lvisit_by_name1() is a recursive iteration function to visit all + * links in and below a group in an HDF5 file, thus providing a + * mechanism for an application to perform a common set of operations + * across all of those links or a dynamically selected subset. For + * non-recursive iteration across the members of a group, see + * H5Literate1(). + * + * The group serving as the root of the iteration is specified by the + * \p loc_id / \p group_name parameter pair. \p loc_id specifies a + * file or group; group_name specifies either a group in the file + * (with an absolute name based in the file’s root group) or a group + * relative to \p loc_id. If \p loc_id fully specifies the group that + * is to serve as the root of the iteration, group_name should be '.' + * (a dot). (Note that when \p loc_id fully specifies the the group + * that is to serve as the root of the iteration, the user may wish to + * consider using H5Lvisit1() instead of H5Lvisit_by_name1().) + * + * Two parameters are used to establish the iteration: \p idx_type and + * \p 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 + * begin more quickly. Valid values include the following: + * \indexes + * + * 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 + * lexicographic 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 \p op callback function, the related \ref H5L_info1_t + * \c struct, and the effect that the callback function's return value + * has on the application are described in H5Lvisit1(). + * + * The H5Lvisit_by_name1() \p op_data parameter is a user-defined + * pointer to the data required to process links 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. + * + * \p lapl_id is a link access property list. In the general case, + * when default link access properties are acceptable, this can be + * passed in as #H5P_DEFAULT. An example of a situation that requires + * a non-default link access property list is when the link is an + * external link; an external link may require that a link prefix be + * set in a link access property list (see H5Pset_elink_prefix()). + * + * H5Lvisit_by_name1() and H5Ovisit_by_name1() are companion + * functions: one for examining and operating on links; the other for + * examining and operating on the objects that those links point to. + * Both functions ensure that by the time the function completes + * successfully, every link or object below the specified point in the + * file has been presented to the application for whatever processing + * the application requires. + * + * \version 1.12.0 Function renamed from H5Lvisit_by_name() to + * H5Lvisit_by_name1() and deprecated. + * + * \since 1.8.0 + * + */ +H5_DLL 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); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif -#endif /* _H5Lpublic_H */ - +#endif /* H5Lpublic_H */ diff --git a/src/H5M.c b/src/H5M.c new file mode 100644 index 00000000000..e810e6dbad3 --- /dev/null +++ b/src/H5M.c @@ -0,0 +1,1016 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Mmodule.h" /* This source code file is part of the H5M module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Mpkg.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Map ID class */ +static const H5I_class_t H5I_MAP_CLS[1] = {{ + H5I_MAP, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ +}}; + +/* Flag indicating "top" of interface has been initialized */ +static hbool_t H5M_top_package_initialize_s = FALSE; + +/*------------------------------------------------------------------------- + * Function: H5M_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * + * Failure: negative + *------------------------------------------------------------------------- + */ +herr_t +H5M_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5M_init() */ + +/*------------------------------------------------------------------------- +NAME + H5M__init_package -- Initialize interface-specific information +USAGE + herr_t H5M__init_package() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. +--------------------------------------------------------------------------- +*/ +herr_t +H5M__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Initialize the atom group for the map IDs */ + if (H5I_register_type(H5I_MAP_CLS) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") + + /* Mark "top" of interface as initialized, too */ + H5M_top_package_initialize_s = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5M__init_package() */ + +/*------------------------------------------------------------------------- + * Function: H5M_top_term_package + * + * Purpose: Close the "top" of the interface, releasing IDs, etc. + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + *------------------------------------------------------------------------- + */ +int +H5M_top_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5M_top_package_initialize_s) { + if (H5I_nmembers(H5I_MAP) > 0) { + (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + + /* Mark closed */ + if (0 == n) + H5M_top_package_initialize_s = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5M_top_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5M_term_package + * + * Purpose: Terminate this interface. + * + * Note: Finishes shutting down the interface, after + * H5M_top_term_package() is called + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. + *------------------------------------------------------------------------- + */ +int +H5M_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_MAP)); + HDassert(FALSE == H5M_top_package_initialize_s); + + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_MAP) > 0); + + /* Mark closed */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5M_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5M__close_cb + * + * Purpose: Called when the ref count reaches zero on the map's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5M__close_cb(H5VL_object_t *map_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(map_vol_obj); + + /* Close the map */ + if (H5VL_optional(map_vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CLOSEERROR, FAIL, "unable to close map"); + + /* Free the VOL object */ + if (H5VL_free_object(map_vol_obj) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "unable to free VOL object"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5M__close_cb() */ + +#ifdef H5_HAVE_MAP_API + +/*------------------------------------------------------------------------- + * Function: H5Mcreate + * + * Purpose: Creates a new map object for storing key-value pairs. The + * in-file datatype for keys is defined by KEY_TYPE_ID and + * the in-file datatype for values is defined by VAL_TYPE_ID. + * LOC_ID specifies the location to create the map object and + * NAME specifies the name of the link to the object + * (relative to LOC_ID). Other options can be specified + * through the property lists LCPL_ID, MCPL_ID, and MAPL_ID. + * + * Return: Success: The object ID of the new map. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE7("i", "i*siiiii", loc_id, name, key_type_id, val_type_id, lcpl_id, mcpl_id, mapl_id); + + /* Check arguments */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") + + /* Get link creation property list */ + if (H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") + + /* Get map creation property list */ + if (H5P_DEFAULT == mcpl_id) + mcpl_id = H5P_MAP_CREATE_DEFAULT; + else if (TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "mcpl_id is not a map create property list ID") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the map */ + if (H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, name, + lcpl_id, 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 */ + if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize map handle") + +done: + /* Cleanup on failure */ + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mcreate() */ + +/*------------------------------------------------------------------------- + * Function: H5Mcreate_anon + * + * Purpose: Creates a new map object for storing key-value pairs. The + * in-file datatype for keys is defined by KEY_TYPE_ID and + * the in-file datatype for values is defined by VAL_TYPE_ID. + * LOC_ID specifies the file to create the map object, but no + * link to the object is created. Other options can be + * specified through the property lists LCPL_ID, MCPL_ID, and + * MAPL_ID. + * + * The resulting ID should be linked into the file with + * H5Olink or it will be deleted when closed. + * + * Return: Success: The object ID of the new map. The map should + * be linked into the group hierarchy before being closed or + * it will be deleted. The dataset should be + * closed when the caller is no longer interested + * in it. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE5("i", "iiiii", loc_id, key_type_id, val_type_id, mcpl_id, mapl_id); + + /* Check arguments */ + if (H5P_DEFAULT == mcpl_id) + mcpl_id = H5P_MAP_CREATE_DEFAULT; + else if (TRUE != H5P_isa_class(mcpl_id, H5P_MAP_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not map create property list ID") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the map */ + if (H5VL_optional(vol_obj, H5VL_MAP_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, NULL, + 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 */ + 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") + +done: + /* Cleanup on failure */ + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mcreate_anon() */ + +/*------------------------------------------------------------------------ + * Function: H5Mopen + * + * Purpose: Finds a map named NAME at LOC_ID, opens it, and returns + * its ID. The map should be close when the caller is no + * longer interested in it. + * + * Takes a map access property list + * + * Return: Success: Object ID of the map + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "i*si", loc_id, name, mapl_id); + + /* Check args */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&mapl_id, H5P_CLS_MACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Open the map */ + if (H5VL_optional(vol_obj, H5VL_MAP_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, name, + mapl_id, &map) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") + + /* Register an atom 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") + +done: + /* Cleanup on failure */ + if (H5I_INVALID_HID == ret_value) + if (map && H5VL_optional(vol_obj, H5VL_MAP_CLOSE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + + FUNC_LEAVE_API(ret_value) +} /* end H5Mopen() */ + +/*------------------------------------------------------------------------- + * Function: H5Mclose + * + * Purpose: Closes access to a map and releases resources used by it. + * It is illegal to subsequently use that same map ID in + * calls to other map functions. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mclose(hid_t map_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", map_id); + + /* Check args */ + if (H5I_MAP != H5I_get_type(map_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a map ID") + + /* Decrement the counter on the map. It will be freed if the count + * reaches zero. + */ + if (H5I_dec_app_ref_always_close(map_id) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "can't decrement count on map ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mclose() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget_key_type + * + * Purpose: Returns a copy of the key datatype for a map. + * + * Return: Success: ID for a copy of the datatype. The data + * type should be released by calling + * H5Tclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_key_type(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* get the datatype */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_KEY_TYPE, + &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_key_type() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget_val_type + * + * Purpose: Returns a copy of the value datatype for a map. + * + * Return: Success: ID for a copy of the datatype. The data + * type should be released by calling + * H5Tclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_val_type(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* get the datatype */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_VAL_TYPE, + &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_val_type() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget_create_plist + * + * Purpose: Returns a copy of the map creation property list. + * + * Return: Success: ID for a copy of the map creation + * property list. The template should be + * released by calling H5P_close(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_create_plist(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* Get the map creation property list */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MCPL, + &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map creation properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_create_plist() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget_access_plist + * + * Purpose: Returns a copy of the map access property list. + * + * Description: H5Mget_access_plist returns the map access property + * list identifier of the specified map. + * + * Return: Success: ID for a copy of the map access + * property list. The template should be + * released by calling H5Pclose(). + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5Mget_access_plist(hid_t map_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", map_id); + + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* Get the map access property list */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_MAP_GET_MAPL, + &ret_value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_access_plist() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget_count + * + * Purpose: Returns the number of key-value pairs stored in the map. + * + * Description: H5Mget_count returns the number of key-value pairs stored + * in the specified map. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj; /* Map structure */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("e", "i*hi", map_id, count, dxpl_id); + + /* Check args */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Get the number of key-value pairs stored in the map */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET, dxpl_id, H5_REQUEST_NULL, H5VL_MAP_GET_COUNT, count) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, H5I_INVALID_HID, "unable to get map access properties") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget_count() */ + +/*------------------------------------------------------------------------- + * Function: H5Mput + * + * Purpose: H5Mput adds a key-value pair to the Map specified by + * MAP_ID, or updates the value for the specified key if one + * was set previously. KEY_MEM_TYPE_ID and VAL_MEM_TYPE_ID + * specify the datatypes for the provided KEY and VALUE + * buffers, and if different from those used to create the + * map object, the key and value will be internally converted + * to the datatypes for the map object. Any further options + * can be specified through the property list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, const void *value, + hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (val_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set the key/value pair */ + if (H5VL_optional(vol_obj, H5VL_MAP_PUT, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, val_mem_type_id, + value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to put key/value pair") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mput() */ + +/*------------------------------------------------------------------------- + * Function: H5Mget + * + * Purpose: H5Mget retrieves, from the Map specified by MAP_ID, the + * value associated with the provided key. KEY_MEM_TYPE_ID + * and VAL_MEM_TYPE_ID specify the datatypes for the provided + * KEY and VALUE buffers. If KEY_MEM_TYPE_ID is different + * from that used to create the map object, the key will be + * internally converted to the datatype for the map object + * for the query, and if VAL_MEM_TYPE_ID is different from + * that used to create the map object, the returned value + * will be converted to VAL_MEM_TYPE_ID before the function + * returns. Any further options can be specified through the + * property list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, void *value, + hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "ii*xi*xi", map_id, key_mem_type_id, key, val_mem_type_id, value, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (val_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Get the value for the key */ + if (H5VL_optional(vol_obj, H5VL_MAP_GET_VAL, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, + val_mem_type_id, value) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, FAIL, "unable to get value from map") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mget() */ + +/*------------------------------------------------------------------------- + * Function: H5Mexists + * + * Purpose: H5Mexists checks if the provided key is stored in the map + * specified by MAP_ID. If KEY_MEM_TYPE_ID is different from + * that used to create the map object the key will be + * internally converted to the datatype for the map object + * for the query. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, hid_t dxpl_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "ii*x*bi", map_id, key_mem_type_id, key, exists, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Check if key exists */ + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_EXISTS, dxpl_id, H5_REQUEST_NULL, key_mem_type_id, key, + exists)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTGET, ret_value, "unable to check if key exists") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mexists() */ + +/*------------------------------------------------------------------------- + * Function: H5Miterate + * + * Purpose: H5Miterate iterates over all key-value pairs stored in the + * map specified by MAP_ID, making the callback specified by + * OP for each. The IDX parameter is an in/out parameter that + * may be used to restart a previously interrupted iteration. + * At the start of iteration IDX should be set to 0, and to + * restart iteration at the same location on a subsequent + * call to H5Miterate, IDX should be the same value as + * returned by the previous call. + * + * H5M_iterate_t is defined as: + * herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, + * void *ctx) + * + * The KEY parameter is the buffer for the key for this + * iteration, converted to the datatype specified by + * KEY_MEM_TYPE_ID. The OP_DATA parameter is a simple pass + * through of the value passed to H5Miterate, which can be + * used to store application-defined data for iteration. A + * negative return value from this function will cause + * H5Miterate to issue an error, while a positive return + * value will cause H5Miterate to stop iterating and return + * this value without issuing an error. A return value of + * zero allows iteration to continue. + * + * Return: Last value returned by op + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "i*hix*xi", map_id, idx, key_mem_type_id, op, op_data, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(map_id); + + /* Iterate over keys */ + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, + H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to iterate over keys") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Miterate() */ + +/*------------------------------------------------------------------------- + * Function: H5Miterate_by_name + * + * Purpose: H5Miterate_by_name iterates over all key-value pairs + * stored in the map specified by MAP_ID, making the callback + * specified by OP for each. The IDX parameter is an in/out + * parameter that may be used to restart a previously + * interrupted iteration. At the start of iteration IDX + * should be set to 0, and to restart iteration at the same + * location on a subsequent call to H5Miterate, IDX should be + * the same value as returned by the previous call. + * + * H5M_iterate_t is defined as: + * herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, + * void *ctx) + * + * The KEY parameter is the buffer for the key for this + * iteration, converted to the datatype specified by + * KEY_MEM_TYPE_ID. The OP_DATA parameter is a simple pass + * through of the value passed to H5Miterate, which can be + * used to store application-defined data for iteration. A + * negative return value from this function will cause + * H5Miterate to issue an error, while a positive return + * value will cause H5Miterate to stop iterating and return + * this value without issuing an error. A return value of + * zero allows iteration to continue. + * + * Return: Last value returned by op + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*s*hix*xii", loc_id, map_name, idx, key_mem_type_id, op, op_data, dxpl_id, lapl_id); + + /* Check arguments */ + if (!map_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be NULL") + if (!*map_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "map_name parameter cannot be an empty string") + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = map_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Iterate over keys */ + if ((ret_value = H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, + H5VL_MAP_ITER, idx, key_mem_type_id, op, op_data)) < 0) + HGOTO_ERROR(H5E_MAP, H5E_BADITER, ret_value, "unable to ierate over keys") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Miterate_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5Mdelete + * + * Purpose: H5Mdelete deletes a key-value pair from the Map + * specified by MAP_ID. KEY_MEM_TYPE_ID specifies the + * datatype for the provided key buffers, and if different + * from that used to create the Map object, the key will be + * internally converted to the datatype for the map object. + * Any further options can be specified through the property + * list DXPL_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "ii*xi", map_id, key_mem_type_id, key, dxpl_id); + + /* Check arguments */ + if (key_mem_type_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID") + + /* Get map pointer */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(map_id); + + /* Delete the key/value pair */ + if (H5VL_optional(vol_obj, H5VL_MAP_SPECIFIC, dxpl_id, H5_REQUEST_NULL, &loc_params, H5VL_MAP_DELETE, + key_mem_type_id, key) < 0) + HGOTO_ERROR(H5E_MAP, H5E_CANTSET, FAIL, "unable to delete key/value pair") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Mdelete() */ + +#endif /* H5_HAVE_MAP_API */ diff --git a/src/H5MF.c b/src/H5MF.c index 6f1217fc6f9..b7004c14a62 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,34 +26,39 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#define H5FS_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5FS_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FSpkg.h" /* File free space */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFpkg.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FSpkg.h" /* File free space */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFpkg.h" /* File memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ /****************/ -#define H5MF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ -#define H5MF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ +#define H5MF_FSPACE_SHRINK 80 /* Percent of "normal" size to shrink serialized free space size */ +#define H5MF_FSPACE_EXPAND 120 /* Percent of "normal" size to expand serialized free space size */ + +#define H5MF_CHECK_FSM(FSM, CF) \ + do { \ + HDassert(*CF == FALSE); \ + if (!H5F_addr_defined(FSM->addr) || !H5F_addr_defined(FSM->sect_addr)) \ + *CF = TRUE; \ + } while (0) /* For non-paged aggregation: map allocation request type to tracked free-space type */ -/* F -- pointer to H5F_t; T -- H5FD_mem_t */ -#define H5MF_ALLOC_TO_FS_AGGR_TYPE(F, T) \ - ((H5FD_MEM_DEFAULT == (F)->shared->fs_type_map[T]) ? (T) : (F)->shared->fs_type_map[T]) +/* F_SH -- pointer to H5F_shared_t; T -- H5FD_mem_t */ +#define H5MF_ALLOC_TO_FS_AGGR_TYPE(F_SH, T) \ + ((H5FD_MEM_DEFAULT == (F_SH)->fs_type_map[T]) ? (T) : (F_SH)->fs_type_map[T]) /******************/ /* Local Typedefs */ @@ -61,24 +66,22 @@ /* Enum for kind of free space section+aggregator merging allowed for a file */ typedef enum { - H5MF_AGGR_MERGE_SEPARATE, /* Everything in separate free list */ - H5MF_AGGR_MERGE_DICHOTOMY, /* Metadata in one free list and raw data in another */ - H5MF_AGGR_MERGE_TOGETHER /* Metadata & raw data in one free list */ + H5MF_AGGR_MERGE_SEPARATE, /* Everything in separate free list */ + H5MF_AGGR_MERGE_DICHOTOMY, /* Metadata in one free list and raw data in another */ + H5MF_AGGR_MERGE_TOGETHER /* Metadata & raw data in one free list */ } H5MF_aggr_merge_t; /* User data for section info iterator callback for iterating over free space sections */ typedef struct { - H5F_sect_info_t *sects; /* section info to be retrieved */ - size_t sect_count; /* # of sections requested */ - size_t sect_idx; /* the current count of sections */ + H5F_sect_info_t *sects; /* section info to be retrieved */ + size_t sect_count; /* # of sections requested */ + size_t sect_idx; /* the current count of sections */ } H5MF_sect_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -92,9 +95,12 @@ static herr_t H5MF__close_pagefs(H5F_t *f); static herr_t H5MF__close_shrink_eoa(H5F_t *f); /* General routines */ -static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); -static hbool_t H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type); -static hbool_t H5MF__fsm_is_self_referential(H5F_t *f, H5FS_t *fspace); +static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); +static hbool_t H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type); +static hbool_t H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace); +static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, + H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, + hbool_t *continue_alloc_fsm); /* Free-space type manager routines */ static herr_t H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type); @@ -105,7 +111,6 @@ static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type); /* Callbacks */ static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); - /*********************/ /* Package Variables */ /*********************/ @@ -113,25 +118,21 @@ static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5MF_init_merge_flags * * Purpose: Initialize the free space section+aggregator merge flags * for the file. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, February 1, 2008 @@ -139,95 +140,95 @@ hbool_t H5_PKG_INIT_VAR = FALSE; *------------------------------------------------------------------------- */ herr_t -H5MF_init_merge_flags(H5F_t *f) +H5MF_init_merge_flags(H5F_shared_t *f_sh) { - H5MF_aggr_merge_t mapping_type; /* Type of free list mapping */ - H5FD_mem_t type; /* Memory type for iteration */ - hbool_t all_same; /* Whether all the types map to the same value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5MF_aggr_merge_t mapping_type; /* Type of free list mapping */ + H5FD_mem_t type; /* Memory type for iteration */ + hbool_t all_same; /* Whether all the types map to the same value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); + HDassert(f_sh); + HDassert(f_sh->lf); /* Iterate over all the free space types to determine if sections of that type * can merge with the metadata or small 'raw' data aggregator */ all_same = TRUE; - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) /* Check for any different type mappings */ - if(f->shared->fs_type_map[type] != f->shared->fs_type_map[H5FD_MEM_DEFAULT]) { + if (f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_DEFAULT]) { all_same = FALSE; break; } /* end if */ /* Check for all allocation types mapping to the same free list type */ - if(all_same) { - if(f->shared->fs_type_map[H5FD_MEM_DEFAULT] == H5FD_MEM_DEFAULT) + if (all_same) { + if (f_sh->fs_type_map[H5FD_MEM_DEFAULT] == H5FD_MEM_DEFAULT) mapping_type = H5MF_AGGR_MERGE_SEPARATE; else mapping_type = H5MF_AGGR_MERGE_TOGETHER; } /* end if */ else { /* Check for raw data mapping into same list as metadata */ - if(f->shared->fs_type_map[H5FD_MEM_DRAW] == f->shared->fs_type_map[H5FD_MEM_SUPER]) + if (f_sh->fs_type_map[H5FD_MEM_DRAW] == f_sh->fs_type_map[H5FD_MEM_SUPER]) mapping_type = H5MF_AGGR_MERGE_SEPARATE; else { - hbool_t all_metadata_same; /* Whether all metadata go in same free list */ + hbool_t all_metadata_same; /* Whether all metadata go in same free list */ /* One or more allocation type don't map to the same free list type */ /* Check if all the metadata allocation types map to the same type */ all_metadata_same = TRUE; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) /* Skip checking raw data free list mapping */ /* (global heap is treated as raw data) */ - if(type != H5FD_MEM_DRAW && type != H5FD_MEM_GHEAP) { + if (type != H5FD_MEM_DRAW && type != H5FD_MEM_GHEAP) { /* Check for any different type mappings */ - if(f->shared->fs_type_map[type] != f->shared->fs_type_map[H5FD_MEM_SUPER]) { + if (f_sh->fs_type_map[type] != f_sh->fs_type_map[H5FD_MEM_SUPER]) { all_metadata_same = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ /* Check for all metadata on same free list */ - if(all_metadata_same) + if (all_metadata_same) mapping_type = H5MF_AGGR_MERGE_DICHOTOMY; else mapping_type = H5MF_AGGR_MERGE_SEPARATE; } /* end else */ - } /* end else */ + } /* end else */ /* Based on mapping type, initialize merging flags for each free list type */ - switch(mapping_type) { + switch (mapping_type) { case H5MF_AGGR_MERGE_SEPARATE: /* Don't merge any metadata together */ - HDmemset(f->shared->fs_aggr_merge, 0, sizeof(f->shared->fs_aggr_merge)); + HDmemset(f_sh->fs_aggr_merge, 0, sizeof(f_sh->fs_aggr_merge)); /* Check if merging raw data should be allowed */ /* (treat global heaps as raw data) */ - if(H5FD_MEM_DRAW == f->shared->fs_type_map[H5FD_MEM_DRAW] || - H5FD_MEM_DEFAULT == f->shared->fs_type_map[H5FD_MEM_DRAW]) { - f->shared->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; - f->shared->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; - } /* end if */ + if (H5FD_MEM_DRAW == f_sh->fs_type_map[H5FD_MEM_DRAW] || + H5FD_MEM_DEFAULT == f_sh->fs_type_map[H5FD_MEM_DRAW]) { + f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + f_sh->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; + } /* end if */ break; case H5MF_AGGR_MERGE_DICHOTOMY: /* Merge all metadata together (but not raw data) */ - HDmemset(f->shared->fs_aggr_merge, H5F_FS_MERGE_METADATA, sizeof(f->shared->fs_aggr_merge)); + HDmemset(f_sh->fs_aggr_merge, H5F_FS_MERGE_METADATA, sizeof(f_sh->fs_aggr_merge)); /* Allow merging raw data allocations together */ /* (treat global heaps as raw data) */ - f->shared->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; - f->shared->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; + f_sh->fs_aggr_merge[H5FD_MEM_DRAW] = H5F_FS_MERGE_RAWDATA; + f_sh->fs_aggr_merge[H5FD_MEM_GHEAP] = H5F_FS_MERGE_RAWDATA; break; case H5MF_AGGR_MERGE_TOGETHER: /* Merge all allocation types together */ - HDmemset(f->shared->fs_aggr_merge, (H5F_FS_MERGE_METADATA | H5F_FS_MERGE_RAWDATA), sizeof(f->shared->fs_aggr_merge)); + HDmemset(f_sh->fs_aggr_merge, (H5F_FS_MERGE_METADATA | H5F_FS_MERGE_RAWDATA), + sizeof(f_sh->fs_aggr_merge)); break; default: @@ -238,7 +239,6 @@ H5MF_init_merge_flags(H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_init_merge_flags() */ - /*------------------------------------------------------------------------- * Function: H5MF__alloc_to_fs_type * @@ -252,63 +252,63 @@ H5MF_init_merge_flags(H5F_t *f) *------------------------------------------------------------------------- */ void -H5MF__alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type) +H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, H5F_mem_page_t *fs_type) { FUNC_ENTER_PACKAGE_NOERR - HDassert(f); + /* Check arguments */ + HDassert(f_sh); HDassert(fs_type); - if(H5F_PAGED_AGGR(f)) { /* paged aggregation */ - if(size >= f->shared->fs_page_size) { - if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) { /* multi or split driver */ - /* For non-contiguous address space, map to large size free-space manager for each alloc_type */ - if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[alloc_type]) - *fs_type = (H5F_mem_page_t) (alloc_type + (H5FD_MEM_NTYPES - 1)); + if (H5F_SHARED_PAGED_AGGR(f_sh)) { /* paged aggregation */ + if (size >= f_sh->fs_page_size) { + if (H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_PAGED_AGGR)) { /* multi or split driver */ + /* For non-contiguous address space, map to large size free-space manager for each alloc_type + */ + if (H5FD_MEM_DEFAULT == f_sh->fs_type_map[alloc_type]) + *fs_type = (H5F_mem_page_t)(alloc_type + (H5FD_MEM_NTYPES - 1)); else - *fs_type = (H5F_mem_page_t) (f->shared->fs_type_map[alloc_type] + (H5FD_MEM_NTYPES - 1)); + *fs_type = (H5F_mem_page_t)(f_sh->fs_type_map[alloc_type] + (H5FD_MEM_NTYPES - 1)); } /* end if */ else /* For contiguous address space, map to generic large size free-space manager */ *fs_type = H5F_MEM_PAGE_GENERIC; /* H5F_MEM_PAGE_SUPER */ - } /* end if */ + } /* end if */ else - *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f, alloc_type); - } /* end if */ + *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f_sh, alloc_type); + } /* end if */ else /* non-paged aggregation */ - *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f, alloc_type); + *fs_type = (H5F_mem_page_t)H5MF_ALLOC_TO_FS_AGGR_TYPE(f_sh, alloc_type); FUNC_LEAVE_NOAPI_VOID } /* end H5MF__alloc_to_fs_type() */ - /*------------------------------------------------------------------------- - * Function: H5MF__open_fstype + * Function: H5MF__open_fstype * - * Purpose: Open an existing free space manager of TYPE for file by + * Purpose: Open an existing free space manager of TYPE for file by * creating a free-space structure. * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * Jan 8 2008 + * Programmer: Quincey Koziol + * Jan 8 2008 * *------------------------------------------------------------------------- */ herr_t H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE, - H5MF_FSPACE_SECT_CLS_SMALL, - H5MF_FSPACE_SECT_CLS_LARGE }; - hsize_t alignment; /* Alignment to use */ - hsize_t threshold; /* Threshold to use */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for file */ + H5MF_FSPACE_SECT_CLS_SIMPLE, H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE}; + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) @@ -316,7 +316,7 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -327,7 +327,7 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); /* Set up the alignment and threshold to use depending on the manager type */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; threshold = H5F_ALIGN_THRHD_DEF; } /* end if */ @@ -337,66 +337,64 @@ H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Open an existing free space structure for the file */ - if(NULL == (f->shared->fs_man[type] = H5FS_open(f, f->shared->fs_addr[type], - NELMTS(classes), classes, f, alignment, threshold))) + if (NULL == (f->shared->fs_man[type] = H5FS_open(f, f->shared->fs_addr[type], NELMTS(classes), classes, f, + alignment, threshold))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ - if(f->shared->fs_man[type]) + if (f->shared->fs_man[type]) f->shared->fs_state[type] = H5F_FS_STATE_OPEN; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__open_fstype() */ - /*------------------------------------------------------------------------- - * Function: H5MF__create_fstype + * Function: H5MF__create_fstype * - * Purpose: Create free space manager of TYPE for the file by creating + * Purpose: Create free space manager of TYPE for the file by creating * a free-space structure * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * Jan 8 2008 + * Programmer: Quincey Koziol + * Jan 8 2008 * *------------------------------------------------------------------------- */ static herr_t H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) { - const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for file */ - H5MF_FSPACE_SECT_CLS_SIMPLE, - H5MF_FSPACE_SECT_CLS_SMALL, - H5MF_FSPACE_SECT_CLS_LARGE }; - H5FS_create_t fs_create; /* Free space creation parameters */ - hsize_t alignment; /* Alignment to use */ - hsize_t threshold; /* Threshold to use */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + const H5FS_section_class_t *classes[] = {/* Free space section classes implemented for file */ + H5MF_FSPACE_SECT_CLS_SIMPLE, H5MF_FSPACE_SECT_CLS_SMALL, + H5MF_FSPACE_SECT_CLS_LARGE}; + H5FS_create_t fs_create; /* Free space creation parameters */ + hsize_t alignment; /* Alignment to use */ + hsize_t threshold; /* Threshold to use */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC /* * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -407,14 +405,14 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); /* Set the free space creation parameters */ - fs_create.client = H5FS_CLIENT_FILE_ID; + fs_create.client = H5FS_CLIENT_FILE_ID; fs_create.shrink_percent = H5MF_FSPACE_SHRINK; fs_create.expand_percent = H5MF_FSPACE_EXPAND; - fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)f->shared->maxaddr); - fs_create.max_sect_size = f->shared->maxaddr; + fs_create.max_sect_addr = 1 + H5VM_log2_gen((uint64_t)f->shared->maxaddr); + fs_create.max_sect_size = f->shared->maxaddr; /* Set up alignment and threshold to use depending on TYPE */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { alignment = (type == H5F_MEM_PAGE_GENERIC) ? f->shared->fs_page_size : (hsize_t)H5F_ALIGN_DEF; threshold = H5F_ALIGN_THRHD_DEF; } /* end if */ @@ -424,56 +422,55 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); - if(NULL == (f->shared->fs_man[type] = H5FS_create(f, NULL, - &fs_create, NELMTS(classes), classes, f, alignment, threshold))) + if (NULL == (f->shared->fs_man[type] = + H5FS_create(f, NULL, &fs_create, NELMTS(classes), classes, f, alignment, threshold))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space info") /* Set the state for the free space manager to "open", if it is now */ - if(f->shared->fs_man[type]) + if (f->shared->fs_man[type]) f->shared->fs_state[type] = H5F_FS_STATE_OPEN; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__create_fstype() */ - /*------------------------------------------------------------------------- - * Function: H5MF__start_fstype + * Function: H5MF__start_fstype * - * Purpose: Open or create a free space manager of a given TYPE. + * Purpose: Open or create a free space manager of a given TYPE. * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * Jan 8 2008 + * Programmer: Quincey Koziol + * Jan 8 2008 * *------------------------------------------------------------------------- */ herr_t H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE /* * Check arguments. */ HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else { HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -481,22 +478,21 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ /* Check if the free space manager exists already */ - if(H5F_addr_defined(f->shared->fs_addr[type])) { + if (H5F_addr_defined(f->shared->fs_addr[type])) { /* Open existing free space manager */ - if(H5MF__open_fstype(f, type) < 0) + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, FAIL, "can't initialize file free space") } /* end if */ else { /* Create new free space manager */ - if(H5MF__create_fstype(f, type) < 0) + if (H5MF__create_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCREATE, FAIL, "can't initialize file free space") } /* end else */ done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__start_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__delete_fstype * @@ -506,23 +502,23 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) * Return: Success: non-negative * Failure: negative * - * Programmer: Vailin Choi; April 2013 + * Programmer: Vailin Choi; April 2013 * *------------------------------------------------------------------------- */ static herr_t H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* check args */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -530,7 +526,7 @@ H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) /* Put address into temporary variable and reset it */ /* (Avoids loopback in file space freeing routine) */ - tmp_fs_addr = f->shared->fs_addr[type]; + tmp_fs_addr = f->shared->fs_addr[type]; f->shared->fs_addr[type] = HADDR_UNDEF; /* Shift to "deleting" state, to make certain we don't track any @@ -539,18 +535,18 @@ H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) f->shared->fs_state[type] = H5F_FS_STATE_DELETING; /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, type)) + if (H5MF__fsm_type_is_self_referential(f->shared, type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); + HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Delete free space manager for this type */ - if(H5FS_delete(f, tmp_fs_addr) < 0) + if (H5FS_delete(f, tmp_fs_addr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't delete free space manager") /* Shift [back] to closed state */ @@ -562,13 +558,12 @@ HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__delete_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_fstype * @@ -585,15 +580,15 @@ HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC); static herr_t H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* * Check arguments. */ HDassert(f); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); @@ -602,24 +597,23 @@ H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) HDassert(f->shared->fs_state[type] != H5F_FS_STATE_CLOSED); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); + HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Close an existing free space structure for the file */ - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free space info") - f->shared->fs_man[type] = NULL; + f->shared->fs_man[type] = NULL; f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_fstype() */ - /*------------------------------------------------------------------------- * Function: H5MF__add_sect * - * Purpose: To add a section to the specified free-space manager. + * Purpose: To add a section to the specified free-space manager. * * Return: Success: non-negative * Failure: negative @@ -631,108 +625,107 @@ HDfprintf(stderr, "%s: Before closing free space manager\n", FUNC); herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5MF_sect_ud_t udata; /* User data for callback */ - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5MF_sect_ud_t udata; /* User data for callback */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE HDassert(f); HDassert(fspace); HDassert(node); - H5MF__alloc_to_fs_type(f, alloc_type, node->sect_info.size, &fs_type); + H5MF__alloc_to_fs_type(f->shared, alloc_type, node->sect_info.size, &fs_type); /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; udata.allow_eoa_shrink_only = FALSE; /* Set the ring type in the API context */ - if(H5MF__fsm_is_self_referential(f, fspace)) + if (H5MF__fsm_is_self_referential(f->shared, fspace)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; 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 = %a, node->sect_info.size = %Hu\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) + if (H5FS_sect_add(f, fspace, (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__add_sect() */ - /*------------------------------------------------------------------------- * Function: H5MF__find_sect * - * Purpose: To find a section from the specified free-space manager to fulfill the request. - * If found, re-add the left-over space back to the manager. + * Purpose: To find a section from the specified free-space manager to fulfill the request. + * If found, re-add the left-over space back to the manager. * - * Return: TRUE if a section is found to fulfill the request - * FALSE if not + * Return: TRUE if a section is found to fulfill the request + * FALSE if not * * Programmer: Vailin Choi; April 2013 * *------------------------------------------------------------------------- */ htri_t -H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, - haddr_t *addr) +H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5MF_free_section_t *node; /* Free space section pointer */ - htri_t ret_value = FAIL; /* Whether an existing free list node was found */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5MF_free_section_t *node; /* Free space section pointer */ + htri_t ret_value = FAIL; /* Whether an existing free list node was found */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE HDassert(f); HDassert(fspace); /* Set the ring type in the API context */ - if(H5MF__fsm_is_self_referential(f, fspace)) + if (H5MF__fsm_is_self_referential(f->shared, fspace)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Try to get a section from the free space manager */ - if((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) + if ((ret_value = H5FS_sect_find(f, fspace, size, (H5FS_section_info_t **)&node)) < 0) 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 = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Check for actually finding section */ - if(ret_value) { + if (ret_value) { /* Sanity check */ HDassert(node); /* Retrieve return value */ - if(addr) + if (addr) *addr = node->sect_info.addr; /* Check for eliminating the section */ - if(node->sect_info.size == size) { + if (node->sect_info.size == size) { #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: freeing node\n", FUNC); + HDfprintf(stderr, "%s: freeing node\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Free section node */ - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") } /* end if */ else { @@ -741,31 +734,30 @@ HDfprintf(stderr, "%s: freeing node\n", FUNC); 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 = %Hu\n", FUNC, node->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Re-add the section to the free-space manager */ - if(H5MF__add_sect(f, alloc_type, fspace, node) < 0) + if (H5MF__add_sect(f, alloc_type, fspace, node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") } /* end else */ - } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__find_sect() */ - /*------------------------------------------------------------------------- * Function: H5MF_alloc * * Purpose: Allocate SIZE bytes of file memory and return the relative - * address where that contiguous chunk of file memory exists. - * The TYPE argument describes the purpose for which the storage - * is being requested. + * address where that contiguous chunk of file memory exists. + * The TYPE argument describes the purpose for which the storage + * is being requested. * * Return: Success: The file address of new chunk. * Failure: HADDR_UNDEF @@ -778,14 +770,14 @@ HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %Hu\n", FUNC, node haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* free space manager ring */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ 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 = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ @@ -794,84 +786,79 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(f->shared->lf); HDassert(size > 0); - if(f->shared->first_alloc_dealloc) { - HDassert(! H5AC_cache_image_pending(f)); - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "tidy of self referential fsm hack failed") - } /* end if */ - - H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 1.0\n", FUNC); + HDfprintf(stderr, "%s: Check 1.0\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Check if we are using the free space manager for this file */ - if(H5F_HAVE_FREE_SPACE_MANAGER(f)) { + if (H5F_HAVE_FREE_SPACE_MANAGER(f)) { /* We are about to change the contents of the free space manager -- * notify metadata cache that the associated fsm ring is * unsettled */ - if(H5AC_unsettle_ring(f, fsm_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, HADDR_UNDEF, "attempt to notify cache that ring is unsettled failed") + if (H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, HADDR_UNDEF, + "attempt to notify cache that ring is unsettled failed") /* Check if the free space manager for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) { + if (!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) { /* Open the free-space manager */ - if(H5MF__open_fstype(f, fs_type) < 0) + if (H5MF__open_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTOPENOBJ, HADDR_UNDEF, "can't initialize file free space") HDassert(f->shared->fs_man[fs_type]); } /* end if */ /* Search for large enough space in the free space manager */ - if(f->shared->fs_man[fs_type]) - if(H5MF__find_sect(f, alloc_type, size, f->shared->fs_man[fs_type], &ret_value) < 0) + if (f->shared->fs_man[fs_type]) + if (H5MF__find_sect(f, alloc_type, size, f->shared->fs_man[fs_type], &ret_value) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "error locating a node") } /* end if */ /* If no space is found from the free-space manager, continue further action */ - if(!H5F_addr_defined(ret_value)) { + if (!H5F_addr_defined(ret_value)) { #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 2.0\n", FUNC); + HDfprintf(stderr, "%s: Check 2.0\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { + if (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE) { HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); - if(HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from paged aggregation") - } /* end if */ + if (HADDR_UNDEF == (ret_value = H5MF__alloc_pagefs(f, alloc_type, size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, + "allocation failed from paged aggregation") + } /* end if */ else { /* For non-paged aggregation, continue further action */ - if(HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, size))) + if (HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from aggr/vfd") } /* end else */ - } /* end if */ + } /* end if */ HDassert(H5F_addr_defined(ret_value)); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Check 3.0\n", FUNC); + HDfprintf(stderr, "%s: Check 3.0\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) 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 = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_alloc() */ - /*------------------------------------------------------------------------- * Function: H5MF__alloc_pagefs * @@ -896,136 +883,138 @@ H5MF__sects_dump(f, stderr); static haddr_t H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - H5F_mem_page_t ptype; /* Free-space manager type */ - H5MF_free_section_t *node = NULL; /* Free space section pointer */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5F_mem_page_t ptype; /* Free-space manager type */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + 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 = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ - H5MF__alloc_to_fs_type(f, alloc_type, size, &ptype); + H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &ptype); - switch(ptype) { + switch (ptype) { case H5F_MEM_PAGE_GENERIC: case H5F_MEM_PAGE_LARGE_BTREE: case H5F_MEM_PAGE_LARGE_DRAW: case H5F_MEM_PAGE_LARGE_GHEAP: case H5F_MEM_PAGE_LARGE_LHEAP: - case H5F_MEM_PAGE_LARGE_OHDR: - { - haddr_t eoa; /* EOA for the file */ - hsize_t frag_size = 0; /* Fragment size */ + case H5F_MEM_PAGE_LARGE_OHDR: { + haddr_t eoa; /* EOA for the file */ + hsize_t frag_size = 0; /* Fragment size */ /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") HDassert(!(eoa % f->shared->fs_page_size)); - H5MF_EOA_MISALIGN(f, (eoa+size), f->shared->fs_page_size, frag_size); + H5MF_EOA_MISALIGN(f, (eoa + size), f->shared->fs_page_size, frag_size); /* Allocate from VFD */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size + frag_size, NULL, NULL))) + if (HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size + frag_size, NULL, NULL))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* If there is a mis-aligned fragment at EOA */ - if(frag_size) { + if (frag_size) { /* Start up the free-space manager */ - if(!(f->shared->fs_man[ptype])) - if(H5MF__start_fstype(f, ptype) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") + if (!(f->shared->fs_man[ptype])) + if (H5MF__start_fstype(f, ptype) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, + "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, ret_value + size, frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, + "can't initialize free space section") /* Add the fragment to the large free-space manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't re-add section to file free space") node = NULL; } /* end if */ - } - break; + } break; case H5F_MEM_PAGE_META: case H5F_MEM_PAGE_DRAW: case H5F_MEM_PAGE_BTREE: case H5F_MEM_PAGE_GHEAP: case H5F_MEM_PAGE_LHEAP: - case H5F_MEM_PAGE_OHDR: - { - haddr_t new_page; /* The address for the new file size page */ + case H5F_MEM_PAGE_OHDR: { + haddr_t new_page; /* The address for the new file size page */ /* Allocate one file space page */ - if(HADDR_UNDEF == (new_page = H5MF_alloc(f, alloc_type, f->shared->fs_page_size))) + if (HADDR_UNDEF == (new_page = H5MF_alloc(f, alloc_type, f->shared->fs_page_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") /* Start up the free-space manager */ - if(!(f->shared->fs_man[ptype])) - if(H5MF__start_fstype(f, ptype) < 0) + if (!(f->shared->fs_man[ptype])) + if (H5MF__start_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize file free space") HDassert(f->shared->fs_man[ptype]); - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), (f->shared->fs_page_size - size)))) + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_SMALL, (new_page + size), + (f->shared->fs_page_size - size)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "can't initialize free space section") /* Add the remaining space in the page to the manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't re-add section to file free space") + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[ptype], node) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't re-add section to file free space") node = NULL; /* Insert the new page into the Page Buffer list of new pages so we don't read an empty page from disk */ - if(f->shared->page_buf != NULL && H5PB_add_new_page(f->shared, alloc_type, new_page) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, "can't add new page to Page Buffer new page list") + if (f->shared->page_buf != NULL && H5PB_add_new_page(f->shared, alloc_type, new_page) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, HADDR_UNDEF, + "can't add new page to Page Buffer new page list") ret_value = new_page; - } - break; + } break; case H5F_MEM_PAGE_NTYPES: case H5F_MEM_PAGE_DEFAULT: default: - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space: unrecognized type") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, + "can't allocate file space: unrecognized type") break; } /* end switch */ 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 = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ /* Release section node, if allocated and not added to section list or merged */ - if(node) - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__alloc_pagefs() */ - /*------------------------------------------------------------------------- * Function: H5MF_alloc_tmp * * Purpose: Allocate temporary space in the file * - * Note: The address returned is non-overlapping with any other address - * in the file and suitable for insertion into the metadata - * cache. + * Note: The address returned is non-overlapping with any other address + * in the file and suitable for insertion into the metadata + * cache. * - * The address is _not_ suitable for actual file I/O and will - * cause an error if it is so used. + * The address is _not_ suitable for actual file I/O and will + * cause an error if it is so used. * - * The space allocated with this routine should _not_ be freed, - * it should just be abandoned. Calling H5MF_xfree() with space + * The space allocated with this routine should _not_ be freed, + * it should just be abandoned. Calling H5MF_xfree() with space * from this routine will cause an error. * * Return: Success: Temporary file address @@ -1039,12 +1028,12 @@ H5MF__sects_dump(f, stderr); haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size) { - haddr_t eoa; /* End of allocated space in the file */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa; /* End of allocated space in the file */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); + HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1054,15 +1043,15 @@ HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); HDassert(size > 0); /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") /* Compute value to return */ ret_value = f->shared->tmp_addr - size; /* Check for overlap into the actual allocated space in the file */ - if(H5F_addr_le(ret_value, eoa)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + if (H5F_addr_le(ret_value, eoa)) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") /* Adjust temporary address allocator in the file */ f->shared->tmp_addr = ret_value; @@ -1071,7 +1060,6 @@ HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_alloc_tmp() */ - /*------------------------------------------------------------------------- * Function: H5MF_xfree * @@ -1088,34 +1076,29 @@ HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ - H5MF_free_section_t *node = NULL; /* Free space section pointer */ - unsigned ctype; /* section class type */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ + unsigned ctype; /* section class type */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + herr_t ret_value = SUCCEED; /* Return value */ 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 = %a, size = %Hu\n", FUNC, (unsigned)alloc_type, + addr, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ HDassert(f); - if(!H5F_addr_defined(addr) || 0 == size) + if (!H5F_addr_defined(addr) || 0 == size) HGOTO_DONE(SUCCEED) - HDassert(addr != 0); /* Can't deallocate the superblock :-) */ - - if(f->shared->first_alloc_dealloc) { - HDassert(!H5AC_cache_image_pending(f)); - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") - } /* end if */ + HDassert(addr != 0); /* Can't deallocate the superblock :-) */ - H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; @@ -1126,51 +1109,53 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN * unsettled */ /* Only do so for strategies that use free-space managers */ - if(H5F_HAVE_FREE_SPACE_MANAGER(f)) - if(H5AC_unsettle_ring(f, fsm_ring) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, FAIL, "attempt to notify cache that ring is unsettled failed") + if (H5F_HAVE_FREE_SPACE_MANAGER(f)) + if (H5AC_unsettle_ring(f, fsm_ring) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_SYSTEM, FAIL, + "attempt to notify cache that ring is unsettled failed") /* Check for attempting to free space that's a 'temporary' file address */ - if(H5F_addr_le(f->shared->tmp_addr, addr)) + if (H5F_addr_le(f->shared->tmp_addr, addr)) HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") /* If it's metadata, check if the space to free intersects with the file's * metadata accumulator */ - if(H5FD_MEM_DRAW != alloc_type) { + if (H5FD_MEM_DRAW != alloc_type) { /* Check if the space to free intersects with the file's metadata accumulator */ - if(H5F__accum_free(f->shared, alloc_type, addr, size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator") + if (H5F__accum_free(f->shared, alloc_type, addr, size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, + "can't check free space intersection w/metadata accumulator") } /* end if */ /* Check if the free space manager for the file has been initialized */ - if(!f->shared->fs_man[fs_type]) { + if (!f->shared->fs_man[fs_type]) { /* If there's no free space manager for objects of this type, * see if we can avoid creating one by checking if the freed * 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 = %a\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 */ + if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) { + htri_t status; /* "can absorb" status for section into */ #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Trying to avoid starting up free space manager\n", FUNC); + HDfprintf(stderr, "%s: Trying to avoid starting up free space manager\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Try to shrink the file or absorb the block into a block aggregator */ - if((status = H5MF_try_shrink(f, alloc_type, addr, size)) < 0) + if ((status = H5MF_try_shrink(f, alloc_type, addr, size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") - else if(status > 0) + else if (status > 0) /* Indicate success */ HGOTO_DONE(SUCCEED) - else if(size < f->shared->fs_threshold) { + 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 = %a, size = %Hu, on the floor!\n", FUNC, addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ - HGOTO_DONE(SUCCEED) - } /* end else-if */ - } /* end if */ + HGOTO_DONE(SUCCEED) + } /* end else-if */ + } /* end if */ /* If we are deleting the free space manager, leave now, to avoid * [re-]starting it. @@ -1181,10 +1166,9 @@ HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, a * Note: this drops the space to free on the floor... * */ - if(f->shared->fs_state[fs_type] == H5F_FS_STATE_DELETING || - !H5F_HAVE_FREE_SPACE_MANAGER(f)) { + 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 = %a, size = %Hu, on the floor!\n", FUNC, addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ HGOTO_DONE(SUCCEED) } /* end if */ @@ -1193,74 +1177,74 @@ HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, a * space isn't at the end of the file, so start up (or create) * the file space manager */ - if(H5MF__start_fstype(f, fs_type) < 0) + if (H5MF__start_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") } /* end if */ /* Create the free-space section for the freed section */ ctype = H5MF_SECT_CLASS_TYPE(f, size); - if(NULL == (node = H5MF__sect_new(ctype, addr, size))) + if (NULL == (node = H5MF__sect_new(ctype, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* If size of the freed section is larger than threshold, add it to the free space manager */ - if(size >= f->shared->fs_threshold) { - HDassert(f->shared->fs_man[fs_type]); + if (size >= f->shared->fs_threshold) { + HDassert(f->shared->fs_man[fs_type]); #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: Before H5FS_sect_add()\n", FUNC); + HDfprintf(stderr, "%s: Before H5FS_sect_add()\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Add to the free space for the file */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space") node = NULL; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: After H5FS_sect_add()\n", FUNC); + HDfprintf(stderr, "%s: After H5FS_sect_add()\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ + } /* end if */ else { - htri_t merged; /* Whether node was merged */ - H5MF_sect_ud_t udata; /* User data for callback */ + htri_t merged; /* Whether node was merged */ + H5MF_sect_ud_t udata; /* User data for callback */ /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = TRUE; + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = TRUE; udata.allow_eoa_shrink_only = FALSE; /* Try to merge the section that is smaller than threshold */ - if((merged = H5FS_sect_try_merge(f, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't merge section to file free space") - else if(merged == TRUE) /* successfully merged */ - /* Indicate that the node was used */ + if ((merged = H5FS_sect_try_merge(f, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, + H5FS_ADD_RETURNED_SPACE, &udata)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't merge section to file free space") + else if (merged == TRUE) /* successfully merged */ + /* Indicate that the node was used */ node = NULL; } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release section node, if allocated and not added to section list or merged */ - if(node) - if(H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node) + if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\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); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_xfree() */ - /*------------------------------------------------------------------------- - * Function: H5MF_try_extend + * Function: H5MF_try_extend * - * Purpose: Extend a block in the file if possible. + * Purpose: Extend a block in the file if possible. * For non-paged aggregation: * --try to extend at EOA * --try to extend into the aggregators @@ -1270,43 +1254,37 @@ H5MF__sects_dump(f, stderr); * --try to extend into a free-space section if adjoined * --try to extend into the page end threshold if a metadata block * - * Return: Success: TRUE(1) - Block was extended + * Return: Success: TRUE(1) - Block was extended * FALSE(0) - Block could not be extended - * Failure: FAIL + * Failure: FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, June 11, 2004 * *------------------------------------------------------------------------- */ htri_t -H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, - hsize_t extra_requested) +H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsize_t extra_requested) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring; /* Ring of FSM */ - haddr_t end; /* End of block to extend */ - H5FD_mem_t map_type; /* Mapped type */ - H5F_mem_page_t fs_type; /* free space type */ - htri_t allow_extend = TRUE; /* Possible to extend the block */ - hsize_t frag_size = 0; /* Size of mis-aligned fragment */ - htri_t ret_value = FALSE; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t fsm_ring; /* Ring of FSM */ + haddr_t end; /* End of block to extend */ + H5FD_mem_t map_type; /* Mapped type */ + H5F_mem_page_t fs_type; /* free space type */ + htri_t allow_extend = TRUE; /* Possible to extend the block */ + hsize_t frag_size = 0; /* Size of mis-aligned fragment */ + htri_t ret_value = FALSE; /* Return value */ 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 = %a, size = %Hu, extra_requested = %Hu\n", FUNC, + (unsigned)alloc_type, addr, size, extra_requested); #endif /* H5MF_ALLOC_DEBUG */ /* Sanity check */ HDassert(f); HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); - if(f->shared->first_alloc_dealloc) { - HDassert(! H5AC_cache_image_pending(f)); - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") - } /* end if */ - /* Set mapped type, treating global heap as raw data */ map_type = (alloc_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : alloc_type; @@ -1315,136 +1293,139 @@ HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_r /* For paged aggregation: * To extend a small block: can only extend if not crossing page boundary - * To extend a large block at EOA: calculate in advance mis-aligned fragment so EOA will still end at page boundary + * To extend a large block at EOA: calculate in advance mis-aligned fragment so EOA will still end at + * page boundary */ - if(H5F_PAGED_AGGR(f)) { - if(size < f->shared->fs_page_size) { + if (H5F_PAGED_AGGR(f)) { + if (size < f->shared->fs_page_size) { /* To extend a small block: cannot cross page boundary */ - if((addr / f->shared->fs_page_size) != (((end + extra_requested) - 1) / f->shared->fs_page_size)) + if ((addr / f->shared->fs_page_size) != (((end + extra_requested) - 1) / f->shared->fs_page_size)) allow_extend = FALSE; } /* end if */ else { - haddr_t eoa; /* EOA for the file */ + haddr_t eoa; /* EOA for the file */ - /* To extend a large block: calculate in advance the mis-aligned fragment so EOA will end at page boundary if extended */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) + /* To extend a large block: calculate in advance the mis-aligned fragment so EOA will end at + * page boundary if extended */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") HDassert(!(eoa % f->shared->fs_page_size)); - H5MF_EOA_MISALIGN(f, (eoa+extra_requested), f->shared->fs_page_size, frag_size); + H5MF_EOA_MISALIGN(f, (eoa + extra_requested), f->shared->fs_page_size, frag_size); } /* end else */ - } /* end if */ + } /* end if */ /* Get free space type from allocation type */ - H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); - if(allow_extend) { + if (allow_extend) { /* Try extending the block at EOA */ - if((ret_value = H5F__try_extend(f, map_type, end, extra_requested + frag_size)) < 0) + 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 = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If extending at EOA succeeds: */ /* for paged aggregation, put the fragment into the large-sized free-space manager */ - if(ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { - H5MF_free_section_t *node = NULL; /* Free space section pointer */ + if (ret_value == TRUE && H5F_PAGED_AGGR(f) && frag_size) { + H5MF_free_section_t *node = NULL; /* Free space section pointer */ /* Should be large-sized block */ HDassert(size >= f->shared->fs_page_size); /* Start up the free-space manager */ - if(!(f->shared->fs_man[fs_type])) - if(H5MF__start_fstype(f, fs_type) < 0) + if (!(f->shared->fs_man[fs_type])) + if (H5MF__start_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") /* Create free space section for the fragment */ - if(NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) + if (NULL == (node = H5MF__sect_new(H5MF_FSPACE_SECT_LARGE, end + extra_requested, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Add the fragment to the large-sized free-space manager */ - if(H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) + if (H5MF__add_sect(f, alloc_type, f->shared->fs_man[fs_type], node) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't re-add section to file free space") node = NULL; } /* end if */ /* For non-paged aggregation: try to extend into the aggregators */ - if(ret_value == FALSE && (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || - f->shared->fs_strategy == H5F_FSPACE_STRATEGY_AGGR) ) { - H5F_blk_aggr_t *aggr; /* Aggregator to use */ + if (ret_value == FALSE && (f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || + f->shared->fs_strategy == H5F_FSPACE_STRATEGY_AGGR)) { + H5F_blk_aggr_t *aggr; /* Aggregator to use */ /* Check if the block is able to extend into aggregation block */ - aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); - if((ret_value = H5MF__aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) + aggr = (map_type == H5FD_MEM_DRAW) ? &(f->shared->sdata_aggr) : &(f->shared->meta_aggr); + if ((ret_value = H5MF__aggr_try_extend(f, aggr, map_type, end, extra_requested)) < 0) 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); -#endif /* H5MF_ALLOC_DEBUG_MORE */ + HDfprintf(stderr, "%s: H5MF__aggr_try_extend = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ /* If no extension so far, try to extend into a free-space section */ - if(ret_value == FALSE && ((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || - (H5F_PAGED_AGGR(f))) ) { - H5MF_sect_ud_t udata; /* User data */ + if (ret_value == FALSE && + ((f->shared->fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) || (H5F_PAGED_AGGR(f)))) { + H5MF_sect_ud_t udata; /* User data */ /* Construct user data for callbacks */ - udata.f = f; + udata.f = f; udata.alloc_type = alloc_type; /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) + if (!f->shared->fs_man[fs_type] && H5F_addr_defined(f->shared->fs_addr[fs_type])) /* Open the free-space manager */ - if(H5MF__open_fstype(f, fs_type) < 0) + if (H5MF__open_fstype(f, fs_type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") /* Try to extend the block into a free-space section */ - if(f->shared->fs_man[fs_type]) { - if((ret_value = H5FS_sect_try_extend(f, f->shared->fs_man[fs_type], addr, size, extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") + if (f->shared->fs_man[fs_type]) { + if ((ret_value = H5FS_sect_try_extend(f, f->shared->fs_man[fs_type], addr, size, + extra_requested, H5FS_ADD_RETURNED_SPACE, &udata)) < 0) + 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); -#endif /* H5MF_ALLOC_DEBUG_MORE */ + HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ /* For paged aggregation and a metadata block: try to extend into page end threshold */ - if(ret_value == FALSE && H5F_PAGED_AGGR(f) && map_type != H5FD_MEM_DRAW) { + if (ret_value == FALSE && H5F_PAGED_AGGR(f) && map_type != H5FD_MEM_DRAW) { H5MF_EOA_MISALIGN(f, end, f->shared->fs_page_size, frag_size); - if(frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) + 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); -#endif /* H5MF_ALLOC_DEBUG_MORE */ + HDfprintf(stderr, "%s: Try to extend into the page end threshold = %t\n", FUNC, ret_value); +#endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ - } /* end if */ - } /* allow_extend */ + } /* end if */ + } /* allow_extend */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) 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 = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP -H5MF__sects_dump(f, stderr); + H5MF__sects_dump(f, stderr); #endif /* H5MF_ALLOC_DEBUG_DUMP */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_try_extend() */ - /*------------------------------------------------------------------------- * Function: H5MF_try_shrink * @@ -1461,17 +1442,18 @@ H5MF__sects_dump(f, stderr); 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_sect_ud_t udata; /* User data for callback */ - H5FS_section_class_t *sect_cls; /* Section class */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ - H5F_mem_page_t fs_type; /* Free space type */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + H5AC_ring_t fsm_ring = H5AC_RING_INV; /* Ring of FSM */ + H5F_mem_page_t fs_type; /* Free space type */ + htri_t ret_value = FALSE; /* Return value */ 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 = %a, size = %Hu\n", FUNC, (unsigned)alloc_type, + addr, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ @@ -1486,60 +1468,59 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HDassert(sect_cls); /* Get free space type from allocation type */ - H5MF__alloc_to_fs_type(f, alloc_type, size, &fs_type); + H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); /* Set the ring type in the API context */ - if(H5MF__fsm_type_is_self_referential(f, fs_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fs_type)) fsm_ring = H5AC_RING_MDFSM; else fsm_ring = H5AC_RING_RDFSM; H5AC_set_ring(fsm_ring, &orig_ring); /* Create free-space section for block */ - if(NULL == (node = H5MF__sect_new(sect_cls->type, addr, size))) + if (NULL == (node = H5MF__sect_new(sect_cls->type, addr, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize free space section") /* Construct user data for callbacks */ - udata.f = f; - udata.alloc_type = alloc_type; - udata.allow_sect_absorb = FALSE; /* Force section to be absorbed into aggregator */ + udata.f = f; + udata.alloc_type = alloc_type; + udata.allow_sect_absorb = FALSE; /* Force section to be absorbed into aggregator */ udata.allow_eoa_shrink_only = FALSE; /* Check if the block can shrink the container */ - if(sect_cls->can_shrink) { - if((ret_value = (*sect_cls->can_shrink)((const H5FS_section_info_t *)node, &udata)) < 0) + if (sect_cls->can_shrink) { + if ((ret_value = (*sect_cls->can_shrink)((const H5FS_section_info_t *)node, &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check if section can shrink container") - if(ret_value > 0) { + if (ret_value > 0) { HDassert(sect_cls->shrink); - if((*sect_cls->shrink)((H5FS_section_info_t **)&node, &udata) < 0) + if ((*sect_cls->shrink)((H5FS_section_info_t **)&node, &udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink container") } /* end if */ - } /* end if */ + } /* end if */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Free section node allocated */ - if(node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) + if (node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_try_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF_close * * Purpose: Close the free space tracker(s) for a file: * paged or non-paged aggregation * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi; Dec 2012 * @@ -1548,34 +1529,33 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); herr_t H5MF_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) { - if((ret_value = H5MF__close_pagefs(f)) < 0) + if (H5F_PAGED_AGGR(f)) { + if ((ret_value = H5MF__close_pagefs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'page' file space") } else { - if((ret_value = H5MF__close_aggrfs(f)) < 0) + if ((ret_value = H5MF__close_aggrfs(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close free-space managers for 'aggr' file space") } done: #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_close() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_delete_fstype * @@ -1583,9 +1563,9 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); * of TYPE for file. * Note that TYPE can be H5F_mem_page_t or H5FD_mem_t enum types. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Jan 2016 * *------------------------------------------------------------------------- @@ -1593,47 +1573,48 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ HDassert(f); HDassert(f->shared); - if(H5F_PAGED_AGGR(f)) + if (H5F_PAGED_AGGR(f)) HDassert(type < H5F_MEM_PAGE_NTYPES); else 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] = %a\n", FUNC, + (unsigned)type, 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 */ - if(f->shared->fs_man[type]) - if(H5MF__close_fstype(f, type) < 0) + if (f->shared->fs_man[type]) + if (H5MF__close_fstype(f, type) < 0) 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] = %a\n", FUNC, + (unsigned)type, 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 */ - if(H5F_addr_defined(f->shared->fs_addr[type])) - if(H5MF__delete_fstype(f, type) < 0) + if (H5F_addr_defined(f->shared->fs_addr[type])) + if (H5MF__delete_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't delete the free space manager") done: #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__close_delete() */ - /*------------------------------------------------------------------------- * Function: H5MF_try_close * @@ -1641,9 +1622,9 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); * free-space managers when downgrading persistent free-space * to non-persistent. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Jan 2016 * *------------------------------------------------------------------------- @@ -1651,14 +1632,14 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); herr_t H5MF_try_close(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1678,16 +1659,6 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * H5MF_tidy_self_referential_fsm_hack() to discard the cache image * block. */ - if(f->shared->first_alloc_dealloc) { - if(H5AC_cache_image_pending(f)) { - if(H5AC_force_cache_image_load(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "forced cache image load failed") - } /* end if */ - else { - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") - } /* end else */ - } /* end if */ /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initially set the ring in @@ -1696,63 +1667,62 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); H5AC_set_ring(H5AC_RING_RDFSM, &orig_ring); curr_ring = H5AC_RING_RDFSM; - if(H5F_PAGED_AGGR(f)) { - H5F_mem_page_t ptype; /* Memory type for iteration */ + if (H5F_PAGED_AGGR(f)) { + H5F_mem_page_t ptype; /* Memory type for iteration */ /* Iterate over all the free space types that have managers and * get each free list's space */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring ) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ - if(H5MF__close_delete_fstype(f, ptype) < 0) + if (H5MF__close_delete_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") } /* end for */ - } /* end if */ + } /* end if */ else { - H5FD_mem_t type; /* Memory type for iteration */ + H5FD_mem_t type; /* Memory type for iteration */ /* Iterate over all the free space types that have managers and * get each free list's space */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ - if(H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) + if (H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") } /* end for */ - } /* end else */ + } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_try_close() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_aggrfs * @@ -1768,15 +1738,15 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_aggrfs(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5FD_mem_t type; /* Memory type for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5FD_mem_t type; /* Memory type for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1794,19 +1764,18 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Free the space in aggregators */ /* (for space not at EOA, it may be put into free space managers) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* Making free-space managers persistent for superblock version >= 2 */ - if(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 - && f->shared->fs_persist) { - H5O_fsinfo_t fsinfo; /* File space info message */ - haddr_t final_eoa; /* Final eoa -- for sanity check */ - H5F_mem_page_t ptype; /* Memory type for iteration */ + if (f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2 && f->shared->fs_persist) { + H5O_fsinfo_t fsinfo; /* File space info message */ + haddr_t final_eoa; /* Final eoa -- for sanity check */ + H5F_mem_page_t ptype; /* Memory type for iteration */ /* superblock extension and free space manager message should * exist at this point -- verify at least the former. @@ -1823,41 +1792,42 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * * In passing, verify that all the free space managers are closed. */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) - fsinfo.fs_addr[type-1] = f->shared->fs_addr[type]; - 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 = f->shared->eoa_pre_fsm_fsalloc; - fsinfo.version = f->shared->fs_version; + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + fsinfo.fs_addr[type - 1] = f->shared->fs_addr[type]; + 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 = f->shared->eoa_fsm_fsalloc; + fsinfo.version = f->shared->fs_version; /* Write the free space manager message -- message must already exist */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") /* Close the free space managers */ - for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { - if(f->shared->fs_man[type]) { + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { + if (f->shared->fs_man[type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ HDassert(f->shared->fs_state[type] == H5F_FS_STATE_OPEN); - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") - f->shared->fs_man[type] = NULL; + f->shared->fs_man[type] = NULL; f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; } /* end if */ f->shared->fs_addr[type] = HADDR_UNDEF; @@ -1879,47 +1849,46 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* get the eoa, and verify that it has the expected value */ - if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* f->shared->eoa_post_fsm_fsalloc is undefined if there has * been no file space allocation or deallocation since file * open. */ - HDassert((f->shared->first_alloc_dealloc) || (final_eoa == f->shared->eoa_post_fsm_fsalloc)); - } /* end if */ - else { /* super_vers can be 0, 1, 2 */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) - if(H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) + HDassert(H5F_NULL_FSM_ADDR(f) || final_eoa == f->shared->eoa_fsm_fsalloc); + } /* end if */ + else { /* super_vers can be 0, 1, 2 */ + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) + if (H5MF__close_delete_fstype(f, (H5F_mem_page_t)type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") } /* end else */ /* Free the space in aggregators (again) */ /* (in case any free space information re-started them) */ - if(H5MF_free_aggrs(f) < 0) + if (H5MF_free_aggrs(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_aggrfs() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_pagefs * @@ -1934,16 +1903,16 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_pagefs(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5F_mem_page_t ptype; /* Memory type for iteration */ - H5O_fsinfo_t fsinfo; /* File space info message */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + H5O_fsinfo_t fsinfo; /* File space info message */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Entering\n", FUNC); + HDfprintf(stderr, "%s: Entering\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1962,23 +1931,23 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); curr_ring = H5AC_RING_RDFSM; /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* Set up file space info message */ - 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.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; - fsinfo.version = f->shared->fs_version; + fsinfo.version = f->shared->fs_version; - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if(f->shared->fs_persist) { - haddr_t final_eoa; /* final eoa -- for sanity check */ + if (f->shared->fs_persist) { + haddr_t final_eoa; /* final eoa -- for sanity check */ /* superblock extension and free space manager message should * exist at this point -- verify at least the former. @@ -1996,34 +1965,35 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * file space for the self referential free space managers. Other * data was gathered above. */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - fsinfo.fs_addr[ptype-1] = f->shared->fs_addr[ptype]; - fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_pre_fsm_fsalloc; + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + fsinfo.fs_addr[ptype - 1] = f->shared->fs_addr[ptype]; + fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_fsm_fsalloc; /* Write the free space manager message -- message must already exist */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") /* Close the free space managers */ /* use H5MF__close_fstype() for this? */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { - if(f->shared->fs_man[ptype]) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + if (f->shared->fs_man[ptype]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ HDassert(f->shared->fs_state[ptype] == H5F_FS_STATE_OPEN); - if(H5FS_close(f, f->shared->fs_man[ptype]) < 0) + if (H5FS_close(f, f->shared->fs_man[ptype]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close free space manager") - f->shared->fs_man[ptype] = NULL; + f->shared->fs_man[ptype] = NULL; f->shared->fs_state[ptype] = H5F_FS_STATE_CLOSED; } /* end if */ f->shared->fs_addr[ptype] = HADDR_UNDEF; @@ -2036,11 +2006,11 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") /* get the eoa, and verify that it has the expected value */ - if(HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT)) ) + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") /* f->shared->eoa_post_fsm_fsalloc is undefined if there has @@ -2059,8 +2029,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); * the file driver layer. However, as this possibility seems remote, * it is ignored in the following assert. */ - HDassert((f->shared->first_alloc_dealloc) || - (final_eoa == f->shared->eoa_post_fsm_fsalloc) || + HDassert((H5F_NULL_FSM_ADDR(f)) || (final_eoa == f->shared->eoa_fsm_fsalloc) || ((H5F_addr_defined(f->shared->eoa_post_mdci_fsalloc)) && (final_eoa == f->shared->eoa_post_mdci_fsalloc))); } /* end if */ @@ -2068,39 +2037,39 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Iterate over all the free space types that have managers * and get each free list's space */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - if(H5MF__close_delete_fstype(f, ptype) < 0) + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + if (H5MF__close_delete_fstype(f, ptype) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") /* Write file space info message to superblock extension object header */ /* Create the superblock extension object header in advance if needed */ - if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension") } /* end else */ /* Trying shrinking the EOA for the file */ /* (in case any free space is now at the EOA) */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Leaving\n", FUNC); + HDfprintf(stderr, "%s: Leaving\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_pagefs() */ - /*------------------------------------------------------------------------- * Function: H5MF__close_shrink_eoa * * Purpose: Shrink the EOA while closing * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Saturday, July 7, 2012 @@ -2110,25 +2079,25 @@ HDfprintf(stderr, "%s: Leaving\n", FUNC); static herr_t H5MF__close_shrink_eoa(H5F_t *f) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - H5F_mem_t type; - H5F_mem_page_t ptype; /* Memory type for iteration */ - hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ - htri_t status; /* Status value */ - H5MF_sect_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + H5F_mem_t type; + H5F_mem_page_t ptype; /* Memory type for iteration */ + hbool_t eoa_shrank; /* Whether an EOA shrink occurs */ + htri_t status; /* Status value */ + H5MF_sect_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* check args */ HDassert(f); HDassert(f->shared); /* Construct user data for callbacks */ - udata.f = f; - udata.allow_sect_absorb = FALSE; + udata.f = f; + udata.allow_sect_absorb = FALSE; udata.allow_eoa_shrink_only = TRUE; /* Set the ring type in the API context */ @@ -2137,73 +2106,73 @@ H5MF__close_shrink_eoa(H5F_t *f) /* Iterate until no more EOA shrinking occurs */ do { - eoa_shrank = FALSE; + eoa_shrank = FALSE; - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { /* Check the last section of each free-space manager */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { - if(f->shared->fs_man[ptype]) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + if (f->shared->fs_man[ptype]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, ptype)) + if (H5MF__fsm_type_is_self_referential(f->shared, ptype)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); 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) + 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") - else if(status > 0) + else if (status > 0) eoa_shrank = TRUE; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* Check the last section of each free-space manager */ - for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { - if(f->shared->fs_man[type]) { + for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) { + if (f->shared->fs_man[type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ udata.alloc_type = type; - if((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[type], &udata)) < 0) + if ((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[type], &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) - eoa_shrank = TRUE; + else if (status > 0) + eoa_shrank = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* check the two aggregators */ - if((status = H5MF_aggrs_try_shrink_eoa(f)) < 0) + if ((status = H5MF__aggrs_try_shrink_eoa(f)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - else if(status > 0) + else if (status > 0) eoa_shrank = TRUE; } /* end else */ - } while(eoa_shrank); + } while (eoa_shrank); done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_shrink_eoa() */ - /*------------------------------------------------------------------------- * Function: H5MF_get_freespace * @@ -2220,22 +2189,22 @@ H5MF__close_shrink_eoa(H5F_t *f) herr_t H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) { - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - hsize_t tot_fs_size = 0; /* Amount of all free space managed */ - hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ - H5FD_mem_t tt; /* Memory type for iteration */ - H5F_mem_page_t type; /* Memory type for iteration */ - H5F_mem_page_t start_type; /* Memory type for iteration */ - H5F_mem_page_t end_type; /* Memory type for iteration */ - htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ - haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + hsize_t tot_fs_size = 0; /* Amount of all free space managed */ + hsize_t tot_meta_size = 0; /* Amount of metadata for free space managers */ + H5FD_mem_t tt; /* Memory type for iteration */ + H5F_mem_page_t type; /* Memory type for iteration */ + H5F_mem_page_t start_type; /* Memory type for iteration */ + H5F_mem_page_t end_type; /* Memory type for iteration */ + htri_t fs_started[H5F_MEM_PAGE_NTYPES]; /* Indicate whether the free-space manager has been started */ + haddr_t fs_eoa[H5FD_MEM_NTYPES]; /* EAO for each free-space manager */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2252,107 +2221,106 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) curr_ring = H5AC_RING_RDFSM; /* Determine start/end points for loop */ - if(H5F_PAGED_AGGR(f)) { + if (H5F_PAGED_AGGR(f)) { start_type = H5F_MEM_PAGE_META; - end_type = H5F_MEM_PAGE_NTYPES; + end_type = H5F_MEM_PAGE_NTYPES; } /* end if */ else { start_type = (H5F_mem_page_t)H5FD_MEM_SUPER; - end_type = (H5F_mem_page_t)H5FD_MEM_NTYPES; + end_type = (H5F_mem_page_t)H5FD_MEM_NTYPES; } /* end else */ - for(tt = H5FD_MEM_SUPER; tt < H5FD_MEM_NTYPES; tt++) - if(HADDR_UNDEF == (fs_eoa[tt] = H5F_get_eoa(f, tt))) + for (tt = H5FD_MEM_SUPER; tt < H5FD_MEM_NTYPES; tt++) + if (HADDR_UNDEF == (fs_eoa[tt] = H5F_get_eoa(f, tt))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - if(!H5F_PAGED_AGGR(f)) { + if (!H5F_PAGED_AGGR(f)) { /* Retrieve metadata aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + if (H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") /* Retrieve 'small data' aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + if (H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") } /* end if */ /* Iterate over all the free space types that have managers and get each free list's space */ - for(type = start_type; type < end_type; type++) { + for (type = start_type; type < end_type; type++) { fs_started[type] = FALSE; /* Check if the free space for the file has been initialized */ - if(!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { - if(H5MF__open_fstype(f, type) < 0) + if (!f->shared->fs_man[type] && H5F_addr_defined(f->shared->fs_addr[type])) { + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") HDassert(f->shared->fs_man[type]); fs_started[type] = TRUE; } /* end if */ /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ /* Check if there's free space of this type */ - if(f->shared->fs_man[type]) { - hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ - hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ + if (f->shared->fs_man[type]) { + hsize_t type_fs_size = 0; /* Amount of free space managed for each type */ + hsize_t type_meta_size = 0; /* Amount of free space metadata for each type */ /* Retrieve free space size from free space manager */ - if(H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) + if (H5FS_sect_stats(f->shared->fs_man[type], &type_fs_size, NULL) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") - if(H5FS_size(f->shared->fs_man[type], &type_meta_size) < 0) + if (H5FS_size(f->shared->fs_man[type], &type_meta_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space metadata stats") /* Increment total free space for types */ tot_fs_size += type_fs_size; tot_meta_size += type_meta_size; } /* end if */ - } /* end for */ + } /* end for */ /* Close the free-space managers if they were opened earlier in this routine */ - for(type = start_type; type < end_type; type++) { + for (type = start_type; type < end_type; type++) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, (H5F_mem_page_t)type)) + if (H5MF__fsm_type_is_self_referential(f->shared, (H5F_mem_page_t)type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, &curr_ring); curr_ring = needed_ring; } /* end if */ - if(fs_started[type]) - if(H5MF__close_fstype(f, type) < 0) + if (fs_started[type]) + if (H5MF__close_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space") } /* end for */ /* Set the value(s) to return */ /* (The metadata & small data aggregators count as free space now, since they aren't at EOA) */ - if(tot_space) + if (tot_space) *tot_space = tot_fs_size + ma_size + sda_size; - if(meta_size) + if (meta_size) *meta_size = tot_meta_size; done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF_get_freespace() */ - /*------------------------------------------------------------------------- * Function: H5MF_get_free_sections() * - * Purpose: To retrieve free-space section information for + * Purpose: To retrieve free-space section information for * paged or non-paged aggregation * * Return: Success: Number of free sections @@ -2365,14 +2333,14 @@ H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size) ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info) { - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ - size_t total_sects = 0; /* Total number of sections */ - H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ - H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ - H5F_mem_page_t ty; /* Memory type for iteration */ - ssize_t ret_value = -1; /* Return value */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration. */ + size_t total_sects = 0; /* Total number of sections */ + H5MF_sect_iter_ud_t sect_udata; /* User data for callback */ + H5F_mem_page_t start_type, end_type; /* Memory types to iterate over */ + H5F_mem_page_t ty; /* Memory type for iteration */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, (-1)) @@ -2393,33 +2361,23 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t * H5MF_tidy_self_referential_fsm_hack() to discard the cache image * block. */ - if(f->shared->first_alloc_dealloc) { - if(H5AC_cache_image_pending(f)) { - if(H5AC_force_cache_image_load(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, (-1), "forced cache image load failed") - } /* end if */ - else { - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, (-1), "tidy of self referential fsm hack failed") - } /* end else */ - } /* end if */ - if(type == H5FD_MEM_DEFAULT) { + if (type == H5FD_MEM_DEFAULT) { start_type = H5F_MEM_PAGE_SUPER; - end_type = H5F_MEM_PAGE_NTYPES; + end_type = H5F_MEM_PAGE_NTYPES; } /* end if */ else { start_type = end_type = (H5F_mem_page_t)type; - if(H5F_PAGED_AGGR(f)) /* set to the corresponding LARGE free-space manager */ + if (H5F_PAGED_AGGR(f)) /* set to the corresponding LARGE free-space manager */ end_type = (H5F_mem_page_t)(end_type + H5FD_MEM_NTYPES); else end_type++; } /* end else */ /* Set up user data for section iteration */ - sect_udata.sects = sect_info; + sect_udata.sects = sect_info; sect_udata.sect_count = nsects; - sect_udata.sect_idx = 0; + sect_udata.sect_idx = 0; /* Set the ring type in the API context. In most cases, we will * need H5AC_RING_RDFSM, so initially set the ring in @@ -2429,41 +2387,42 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t curr_ring = H5AC_RING_RDFSM; /* Iterate over memory types, retrieving the number of sections of each type */ - for(ty = start_type; ty < end_type; ty++) { - hbool_t fs_started = FALSE; /* The free-space manager is opened or not */ - size_t nums = 0; /* The number of free-space sections */ + for (ty = start_type; ty < end_type; ty++) { + hbool_t fs_started = FALSE; /* The free-space manager is opened or not */ + size_t nums = 0; /* The number of free-space sections */ /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, ty)) + if (H5MF__fsm_type_is_self_referential(f->shared, ty)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, &curr_ring); curr_ring = needed_ring; } /* end if */ - if(!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { - if(H5MF__open_fstype(f, ty) < 0) + if (!f->shared->fs_man[ty] && H5F_addr_defined(f->shared->fs_addr[ty])) { + if (H5MF__open_fstype(f, ty) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't open the free space manager") HDassert(f->shared->fs_man[ty]); fs_started = TRUE; } /* end if */ /* Check if there's free space sections of this type */ - if(f->shared->fs_man[ty]) - if(H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), "can't get section info for the free space manager") + if (f->shared->fs_man[ty]) + if (H5MF__get_free_sects(f, f->shared->fs_man[ty], §_udata, &nums) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, (-1), + "can't get section info for the free space manager") /* Increment total # of sections */ total_sects += nums; /* Close the free space manager of this type, if we started it here */ - if(fs_started) - if(H5MF__close_fstype(f, ty) < 0) + if (fs_started) + if (H5MF__close_fstype(f, ty) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCLOSEOBJ, (-1), "can't close file free space") - if((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) + if ((H5F_PAGED_AGGR(f)) && (type != H5FD_MEM_DEFAULT)) ty = (H5F_mem_page_t)(ty + H5FD_MEM_NTYPES - 2); } /* end for */ @@ -2472,20 +2431,19 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_get_free_sections() */ - /*------------------------------------------------------------------------- * Function: H5MF__sects_cb() * - * Purpose: Iterator callback for each free-space section + * Purpose: Iterator callback for each free-space section * Retrieve address and size into user data * - * Return: Always succeed + * Return: Always succeed * * Programmer: Vailin Choi * July 1st, 2009 @@ -2495,25 +2453,24 @@ H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; H5MF_sect_iter_ud_t *udata = (H5MF_sect_iter_ud_t *)_udata; FUNC_ENTER_STATIC_NOERR - if(udata->sect_idx < udata->sect_count) { + if (udata->sect_idx < udata->sect_count) { udata->sects[udata->sect_idx].addr = sect->sect_info.addr; - udata->sects[udata->sect_idx].size = sect->sect_info.size; + udata->sects[udata->sect_idx].size = sect->sect_info.size; udata->sect_idx++; } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MF__sects_cb() */ - /*------------------------------------------------------------------------- * Function: H5MF__get_free_sects * - * Purpose: Retrieve section information for the specified free-space manager. + * Purpose: Retrieve section information for the specified free-space manager. * * Return: Success: non-negative * Failure: negative @@ -2525,10 +2482,10 @@ H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata) static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums) { - hsize_t hnums = 0; /* # of sections */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t hnums = 0; /* # of sections */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -2537,28 +2494,27 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, HDassert(fspace); /* Query how many sections of this type */ - if(H5FS_sect_stats(fspace, NULL, &hnums) < 0) + if (H5FS_sect_stats(fspace, NULL, &hnums) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query free space stats") H5_CHECKED_ASSIGN(*nums, size_t, hnums, hsize_t); /* Check if we should retrieve the section info */ - if(sect_udata->sects && *nums > 0) + if (sect_udata->sects && *nums > 0) /* Iterate over all the free space sections of this type, adding them to the user's section info */ - if(H5FS_sect_iterate(f, fspace, H5MF__sects_cb, sect_udata) < 0) + if (H5FS_sect_iterate(f, fspace, H5MF__sects_cb, sect_udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't iterate over sections") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__get_free_sects() */ - /*------------------------------------------------------------------------- * Function: H5MF_settle_raw_data_fsm() * - * Purpose: Handle any tasks required before the metadata cache - * can serialize or flush the raw data free space manager - * and any metadata free space managers that reside in the - * raw data free space manager ring. + * Purpose: Handle any tasks required before the metadata cache + * can serialize or flush the raw data free space manager + * and any metadata free space managers that reside in the + * raw data free space manager ring. * * Specifically, this means any metadata managers that DON'T * handle space allocation for free space manager header or @@ -2566,25 +2522,25 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, * ring. * * In the absence of page allocation, there is at most one - * free space manager per memory type defined in H5F_mem_t. - * Of these, the one that allocates H5FD_MEM_DRAW will - * always reside in the raw data free space manager ring. - * If there is more than one metadata free space manager, - * all that don't handle H5FD_MEM_FSPACE_HDR or + * free space manager per memory type defined in H5F_mem_t. + * Of these, the one that allocates H5FD_MEM_DRAW will + * always reside in the raw data free space manager ring. + * If there is more than one metadata free space manager, + * all that don't handle H5FD_MEM_FSPACE_HDR or * H5FD_MEM_FSPACE_SINFO (which map to H5FD_MEM_OHDR and * H5FD_MEM_LHEAP respectively) will reside in the raw - * data free space manager ring as well + * data free space manager ring as well * - * With page allocation, the situation is conceptually - * identical, but more complex in practice. + * With page allocation, the situation is conceptually + * identical, but more complex in practice. * * In the worst case (multi file driver) page allocation - * can result in two free space managers for each memory - * type -- one for small (less than on equal to one page) + * can result in two free space managers for each memory + * type -- one for small (less than on equal to one page) * allocations, and one for large (greater than one page) * allocations. * - * In the more common one file case, page allocation will + * In the more common one file case, page allocation will * result in a total of three free space managers -- one for * small (<= one page) raw data allocations, one for small * metadata allocations (i.e, all memory types other than @@ -2592,80 +2548,80 @@ H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, * allocations. * * Despite these complications, the solution is the same in - * the page allocation case -- free space managers (be they + * the page allocation case -- free space managers (be they * small data or large) are assigned to the raw data free * space manager ring if they don't allocate file space for * free space managers. Note that in the one file case, the - * large free space manager must be assigned to the metadata - * free space manager ring, as it both allocates pages for - * the metadata free space manager, and allocates space for - * large (> 1 page) metadata cache entries. + * large free space manager must be assigned to the metadata + * free space manager ring, as it both allocates pages for + * the metadata free space manager, and allocates space for + * large (> 1 page) metadata cache entries. * * At present, the task list for this routine is: * - * 1) Reduce the EOA to the extent possible. To do this: + * 1) Reduce the EOA to the extent possible. To do this: * - * a) Free both aggregators. Space not at EOA will be - * added to the appropriate free space manager. + * a) Free both aggregators. Space not at EOA will be + * added to the appropriate free space manager. * - * The raw data aggregator should not be restarted - * after this point. It is possible that the metadata - * aggregator will be. + * The raw data aggregator should not be restarted + * after this point. It is possible that the metadata + * aggregator will be. * - * b) Free all file space currently allocated to free - * space managers. + * b) Free all file space currently allocated to free + * space managers. * - * c) Delete the free space manager superblock - * extension message if allocated. + * c) Delete the free space manager superblock + * extension message if allocated. * - * This done, reduce the EOA by moving it to just before - * the last piece of free memory in the file. + * This done, reduce the EOA by moving it to just before + * the last piece of free memory in the file. * - * 2) Ensure that space is allocated for the free space + * 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. - * - * 3) Scan all free space managers not involved in allocating - * space for free space managers. For each such free space - * manager, test to see if it contains free space. If - * it does, allocate file space for its header and section - * data. If it contains no free space, leave it without - * allocated file space as there is no need to save it to - * file. - * - * Note that all free space managers in this class should - * see no further space allocations / deallocations as - * at this point, all raw data allocations should be - * finalized, as should all metadata allocations not - * involving free space managers. - * - * We will allocate space for free space managers involved - * in the allocation of file space for free space managers - * in H5MF_settle_meta_data_fsm() - * - * Return: SUCCEED/FAIL + * 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. + * + * 3) Scan all free space managers not involved in allocating + * space for free space managers. For each such free space + * manager, test to see if it contains free space. If + * it does, allocate file space for its header and section + * data. If it contains no free space, leave it without + * allocated file space as there is no need to save it to + * file. + * + * Note that all free space managers in this class should + * see no further space allocations / deallocations as + * at this point, all raw data allocations should be + * finalized, as should all metadata allocations not + * involving free space managers. + * + * We will allocate space for free space managers involved + * in the allocation of file space for free space managers + * in H5MF_settle_meta_data_fsm() + * + * Return: SUCCEED/FAIL * * Programmer: John Mainzer - * 5/25/16 + * 5/25/16 * *------------------------------------------------------------------------- */ herr_t H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) { - int pass_count; - hsize_t alloc_size; - H5F_mem_t mem_type; /* Memory type for iteration */ - H5F_mem_page_t fsm_type; /* FSM type for iteration */ - H5O_fsinfo_t fsinfo; /* Free space manager info message */ - H5FS_stat_t fs_stat; /* Information for free-space manager */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ - H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + int pass_count; + hsize_t alloc_size; + H5F_mem_t mem_type; /* Memory type for iteration */ + H5F_mem_page_t fsm_type; /* FSM type for iteration */ + H5O_fsinfo_t fsinfo; /* Free space manager info message */ + H5FS_stat_t fs_stat; /* Information for free-space manager */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + H5AC_ring_t curr_ring = H5AC_RING_INV; /* Current ring value */ + H5AC_ring_t needed_ring = H5AC_RING_INV; /* Ring value needed for this iteration */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -2678,12 +2634,13 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDmemset(&fsinfo, 0, sizeof(fsinfo)); HDmemset(&fs_stat, 0, sizeof(fs_stat)); - /* Only need to settle things if we are persisting the free space info - * and allocation/deallocation has occurred. + /* + * Only need to settle things if we are persisting free space and + * the private property in f->shared->null_fsm_addr is not enabled. */ - if(f->shared->fs_persist && !f->shared->first_alloc_dealloc) { - hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ - hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ + if (f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { + 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); @@ -2716,7 +2673,7 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * is enabled -- skip this if so. */ /* Vailin -- is this correct? */ - if(!H5F_PAGED_AGGR(f) && (H5MF_free_aggrs(f) < 0)) + if (!H5F_PAGED_AGGR(f) && (H5MF_free_aggrs(f) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Set the ring type in the DXPL. In most cases, we will @@ -2754,81 +2711,82 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * setting the allocation size accordingly if paged allocation is * enabled. */ - for(pass_count = 0; pass_count <= 1; pass_count++) { - if(pass_count == 0) + for (pass_count = 0; pass_count <= 1; pass_count++) { + if (pass_count == 0) alloc_size = 1; - else if ( H5F_PAGED_AGGR(f) ) + else if (H5F_PAGED_AGGR(f)) alloc_size = f->shared->fs_page_size + 1; else /* no need for a second pass */ break; - for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { - H5MF__alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + for (mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { + H5MF__alloc_to_fs_type(f->shared, mem_type, alloc_size, &fsm_type); - if(pass_count == 0) { /* this is the first pass */ + if (pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); - } /* end if */ - else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + } /* end if */ + else if (H5F_PAGED_AGGR(f)) { /* page alloc active */ HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - } /* end else-if */ - else /* paged allocation disabled -- should be unreachable */ + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ HDassert(FALSE); - if(!fsm_visited[fsm_type]) { + if (!fsm_visited[fsm_type]) { fsm_visited[fsm_type] = TRUE; /* If there is no active FSM for this type, but such a FSM has * space allocated in file, open it so that we can free its file * space. */ - if(NULL == f->shared->fs_man[fsm_type]) { - if(H5F_addr_defined(f->shared->fs_addr[fsm_type])) { + if (NULL == f->shared->fs_man[fsm_type]) { + if (H5F_addr_defined(f->shared->fs_addr[fsm_type])) { /* Sanity check */ HDassert(fsm_opened[fsm_type] == FALSE); - if(H5MF__open_fstype(f, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") + if (H5MF__open_fstype(f, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't initialize file free space manager") fsm_opened[fsm_type] = TRUE; } /* end if */ - } /* end if */ + } /* end if */ - if(f->shared->fs_man[fsm_type]) { + if (f->shared->fs_man[fsm_type]) { /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, fsm_type)) - needed_ring = H5AC_RING_MDFSM; + if (H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) + needed_ring = H5AC_RING_MDFSM; else - needed_ring = H5AC_RING_RDFSM; + needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") /* Check if the free space manager has space in the file */ - if(H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { + if (H5F_addr_defined(fs_stat.addr) || H5F_addr_defined(fs_stat.sect_addr)) { /* Delete the free space manager in the file. Will * reallocate later if the free space manager contains * any free space. */ - if(H5FS_free(f, f->shared->fs_man[fsm_type], TRUE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") + if (H5FS_free(f, f->shared->fs_man[fsm_type], TRUE) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't release free-space headers") f->shared->fs_addr[fsm_type] = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ /* note that we are tracking opened FSM -- we will close them * at the end of the function. */ } /* end if */ - } /* end for */ - } /* end for */ - + } /* end for */ + } /* end for */ /* c) Delete the free space manager superblock extension message * if allocated. @@ -2841,15 +2799,15 @@ 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 (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) + 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 @@ -2863,18 +2821,18 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * 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++) + 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.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 (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 @@ -2896,38 +2854,38 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) */ /* Reinitialize fsm_visited */ - for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) fsm_visited[fsm_type] = FALSE; - for(pass_count = 0; pass_count <= 1; pass_count++) { - if(pass_count == 0) + for (pass_count = 0; pass_count <= 1; pass_count++) { + if (pass_count == 0) alloc_size = 1; - else if(H5F_PAGED_AGGR(f)) + else if (H5F_PAGED_AGGR(f)) alloc_size = f->shared->fs_page_size + 1; else /* no need for a second pass */ break; - for(mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { - H5MF__alloc_to_fs_type(f, mem_type, alloc_size, &fsm_type); + for (mem_type = H5FD_MEM_SUPER; mem_type < H5FD_MEM_NTYPES; mem_type++) { + H5MF__alloc_to_fs_type(f->shared, mem_type, alloc_size, &fsm_type); - if(pass_count == 0) { /* this is the first pass */ + if (pass_count == 0) { /* this is the first pass */ HDassert(fsm_type > H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_LARGE_SUPER); - } /* end if */ - else if(H5F_PAGED_AGGR(f)) { /* page alloc active */ + } /* end if */ + else if (H5F_PAGED_AGGR(f)) { /* page alloc active */ HDassert(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - } /* end else-if */ - else /* paged allocation disabled -- should be unreachable */ + } /* end else-if */ + else /* paged allocation disabled -- should be unreachable */ HDassert(FALSE); /* Test to see if we need to switch rings -- do so if required */ - if(H5MF__fsm_type_is_self_referential(f, fsm_type)) + if (H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) needed_ring = H5AC_RING_MDFSM; else needed_ring = H5AC_RING_RDFSM; - if(needed_ring != curr_ring) { + if (needed_ring != curr_ring) { H5AC_set_ring(needed_ring, NULL); curr_ring = needed_ring; } /* end if */ @@ -2936,21 +2894,21 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * to free space managers, ensure that we don't visit any FSM * more than once. */ - if(!fsm_visited[fsm_type]) { + if (!fsm_visited[fsm_type]) { fsm_visited[fsm_type] = TRUE; - if(f->shared->fs_man[fsm_type]) { + if (f->shared->fs_man[fsm_type]) { /* Only allocate file space if the target free space manager * doesn't allocate file space for free space managers. Note * that this is also the deciding factor as to whether a FSM * in in the raw data FSM ring. */ - if(!H5MF__fsm_type_is_self_referential(f, fsm_type)) { + if (!H5MF__fsm_type_is_self_referential(f->shared, fsm_type)) { /* The current ring should be H5AC_RING_RDFSM */ HDassert(curr_ring == H5AC_RING_RDFSM); /* Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0 ) + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") /* If the free space manager contains section info, @@ -2958,31 +2916,35 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * space must not be allocated at present -- verify * verify this with assertions). */ - if(fs_stat.serial_sect_count > 0) { + if (fs_stat.serial_sect_count > 0) { /* Sanity check */ HDassert(!H5F_addr_defined(fs_stat.addr)); /* Allocate FSM header */ - if(H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], &f->shared->fs_addr[fsm_type]) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocated free-space header") + if (H5FS_alloc_hdr(f, f->shared->fs_man[fsm_type], + &f->shared->fs_addr[fsm_type]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't allocated free-space header") /* Allocate FSM section info */ HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); - if(H5FS_alloc_sect(f, f->shared->fs_man[fsm_type]) < 0 ) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate free-space section info") + if (H5FS_alloc_sect(f, f->shared->fs_man[fsm_type]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't allocate free-space section info") #ifndef NDEBUG /* Re-Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") + if (H5FS_stat_info(f, f->shared->fs_man[fsm_type], &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "can't get free-space info") HDassert(H5F_addr_defined(fs_stat.addr)); HDassert(H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.serial_sect_count > 0); HDassert(fs_stat.alloc_sect_size > 0); HDassert(fs_stat.alloc_sect_size == fs_stat.sect_size); -#endif /* NDEBUG */ +#endif /* NDEBUG */ } /* end if */ else { HDassert(!H5F_addr_defined(fs_stat.addr)); @@ -2990,21 +2952,22 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(fs_stat.serial_sect_count == 0); HDassert(fs_stat.alloc_sect_size == 0); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Close any opened FSMs */ - if(fsm_opened[fsm_type]) { - if(H5MF__close_fstype(f, fsm_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't close file free space manager") + if (fsm_opened[fsm_type]) { + if (H5MF__close_fstype(f, fsm_type) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, + "can't close file free space manager") fsm_opened[fsm_type] = FALSE; } /* end if */ - } /* end if */ - } /* end for */ - } /* end for */ + } /* end if */ + } /* end for */ + } /* end for */ /* verify that all opened FSMs were closed */ - for(fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) HDassert(!fsm_opened[fsm_type]); /* Indicate that the FSM was settled successfully */ @@ -3013,132 +2976,124 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_settle_raw_data_fsm() */ - /*------------------------------------------------------------------------- * Function: H5MF_settle_meta_data_fsm() * - * Purpose: If the free space manager is persistent, handle any tasks - * required before the metadata cache can serialize or flush - * the metadata free space manager(s) that handle file space - * allocation for free space managers. - * - * In most cases, there will be only one manager assigned - * to this role. However, since for reasons unknown, - * free space manager headers and section info blocks are - * different classes of memory, it is possible that two free - * space managers will be involved. + * Purpose: If the free space manager is persistent, handle any tasks + * required before the metadata cache can serialize or flush + * the metadata free space manager(s) that handle file space + * allocation for free space managers. * - * On entry to this function, the raw data settle routine - * (H5MF_settle_raw_data_fsm()) should have: + * In most cases, there will be only one manager assigned + * to this role. However, since for reasons unknown, + * free space manager headers and section info blocks are + * different classes of memory, it is possible that two free + * space managers will be involved. * - * 1) Freed the aggregators. + * On entry to this function, the raw data settle routine + * (H5MF_settle_raw_data_fsm()) should have: * - * 2) Freed all file space allocated to the free space managers. + * 1) Freed the aggregators. * - * 3) Deleted the free space manager superblock extension message + * 2) Freed all file space allocated to the free space managers. * - * 4) Reduced the EOA to the extent possible. + * 3) Deleted the free space manager superblock extension message * - * 5) Re-created the free space manager superblock extension - * message. + * 4) Reduced the EOA to the extent possible. * - * 6) Reallocated file space for all non-empty free space - * managers NOT involved in allocation of space for free - * space managers. + * 5) Re-created the free space manager superblock extension + * message. * - * Note that these free space managers (if not empty) should - * have been written to file by this point, and that no - * further space allocations involving them should take - * place during file close. + * 6) Reallocated file space for all non-empty free space + * managers NOT involved in allocation of space for free + * space managers. * - * On entry to this routine, the free space manager(s) involved - * in allocation of file space for free space managers should - * still be floating. (i.e. should not have any file space - * allocated to them.) + * Note that these free space managers (if not empty) should + * have been written to file by this point, and that no + * further space allocations involving them should take + * place during file close. * - * Similarly, the raw data aggregator should not have been - * restarted. Note that it is probable that reallocation of - * space in 5) and 6) above will have re-started the metadata - * aggregator. + * On entry to this routine, the free space manager(s) involved + * in allocation of file space for free space managers should + * still be floating. (i.e. should not have any file space + * allocated to them.) * + * Similarly, the raw data aggregator should not have been + * restarted. Note that it is probable that reallocation of + * space in 5) and 6) above will have re-started the metadata + * aggregator. * - * In this routine, we proceed as follows: * - * 1) Verify that the free space manager(s) involved in file - * space allocation for free space managers are still floating. + * In this routine, we proceed as follows: * - * 2) Free the aggregators. + * 1) Verify that the free space manager(s) involved in file + * space allocation for free space managers are still floating. * - * 3) Reduce the EOA to the extent possible, and make note - * of the resulting value. This value will be stored - * in the fsinfo superblock extension message and be used - * in the subsequent file open. + * 2) Free the aggregators. * - * 4) Re-allocate space for any free space manager(s) that: + * 3) Reduce the EOA to the extent possible, and make note + * of the resulting value. This value will be stored + * in the fsinfo superblock extension message and be used + * in the subsequent file open. * - * a) are involved in allocation of space for free space - * managers, and + * 4) Re-allocate space for any free space manager(s) that: * - * b) contain free space. + * a) are involved in allocation of space for free space + * managers, and * - * It is possible that we could allocate space for one - * of these free space manager(s) only to have the allocation - * result in the free space manager being empty and thus - * obliging us to free the space again. Thus there is the - * potential for an infinite loop if we want to avoid saving - * empty free space managers. + * b) contain free space. * - * Similarly, it is possible that we could allocate space - * for a section info block, only to discover that this - * allocation has changed the size of the section info -- - * forcing us to deallocate and start the loop over again. + * It is possible that we could allocate space for one + * of these free space manager(s) only to have the allocation + * result in the free space manager being empty and thus + * obliging us to free the space again. Thus there is the + * potential for an infinite loop if we want to avoid saving + * empty free space managers. * - * To avoid this, simply allocate file space for these - * FSM(s) directly from the VFD layer if allocation is - * indicated. This avoids the issue by bypassing the FSMs - * in this case. + * Similarly, it is possible that we could allocate space + * for a section info block, only to discover that this + * allocation has changed the size of the section info -- + * forcing us to deallocate and start the loop over again. * - * Note that this may increase the size of the file needlessly. - * A better solution would be to modify the FSM code to - * save empty FSMs to file, and to allow section info blocks - * to be oversized. However, given that the FSM code is - * also used by the fractal heaps, and that we are under - * severe time pressure at the moment, the above brute - * force solution is attractive. + * The solution is to modify the FSM code to + * save empty FSMs to file, and to allow section info blocks + * to be oversized. That is, only allow section info to increase + * in size, not shrink. The solution is now implemented. * - * 5) Make note of the EOA -- used for sanity checking on - * FSM shutdown. + * 5) Make note of the EOA -- used for sanity checking on + * FSM shutdown. This is saved as eoa_pre_fsm_fsalloc in + * the free-space info message for backward compatibility + * with the 1.10 library that has the hack. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: John Mainzer - * 5/25/16 + * 5/25/16 * *------------------------------------------------------------------------- */ herr_t H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) { - H5F_mem_page_t sm_fshdr_fs_type; /* small fs hdr fsm */ - H5F_mem_page_t sm_fssinfo_fs_type; /* small fs sinfo fsm */ - H5F_mem_page_t lg_fshdr_fs_type; /* large fs hdr fsm */ - H5F_mem_page_t lg_fssinfo_fs_type; /* 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 */ - haddr_t eoa_pre_fsm_fsalloc; /* eoa pre file space allocation */ - /* for self referential FSMs */ - haddr_t eoa_post_fsm_fsalloc; /* eoa post file space allocation */ - /* for self referential FSMs */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_mem_page_t sm_fshdr_fs_type; /* small fs hdr fsm */ + 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 */ + 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 */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -3147,18 +3102,19 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(f->shared); HDassert(fsm_settled); - /* Only need to settle things if we are persisting the free space info - * and allocation/deallocation has occurred. + /* + * Only need to settle things if we are persisting free space and + * the private property in f->shared->null_fsm_addr is not enabled. */ - if(f->shared->fs_persist && !f->shared->first_alloc_dealloc) { + if (f->shared->fs_persist && !H5F_NULL_FSM_ADDR(f)) { /* Sanity check */ HDassert(f->shared->lf); /* should only be called if file is opened R/W */ HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); @@ -3170,12 +3126,14 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(!H5F_addr_defined(f->shared->fs_addr[sm_fssinfo_fs_type])); /* Note that in most cases, sm_hdr_fspace will equal sm_sinfo_fspace. */ - sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; + sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; - if(H5F_PAGED_AGGR(f)) { - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); + if (H5F_PAGED_AGGR(f)) { + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, + &lg_fshdr_fs_type); + H5MF__alloc_to_fs_type(f->shared, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, + &lg_fssinfo_fs_type); HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); @@ -3187,7 +3145,7 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) HDassert(!H5F_addr_defined(f->shared->fs_addr[lg_fssinfo_fs_type])); /* Note that in most cases, lg_hdr_fspace will equal lg_sinfo_fspace. */ - lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; + lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; lg_sinfo_fspace = f->shared->fs_man[lg_fssinfo_fs_type]; } /* end if */ @@ -3195,57 +3153,56 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) H5AC_set_ring(H5AC_RING_MDFSM, &orig_ring); #ifndef NDEBUG -{ - H5FS_stat_t fs_stat; /* Information for hdr FSM */ - - /* Verify that sm_hdr_fspace is floating if it exists */ - if(sm_hdr_fspace) { - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, sm_hdr_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(!H5F_addr_defined(fs_stat.addr)); - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.alloc_sect_size == 0); - } /* end if */ - - /* Verify that sm_sinfo_fspace is floating if it exists and is distinct */ - if((sm_sinfo_fspace) && (sm_hdr_fspace != sm_sinfo_fspace)) { - /* Query free space manager info for this type */ - if(H5FS_stat_info(f, sm_sinfo_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(!H5F_addr_defined(fs_stat.addr)); - HDassert(!H5F_addr_defined(fs_stat.sect_addr)); - HDassert(fs_stat.alloc_sect_size == 0); - } /* end if */ + { + H5FS_stat_t fs_stat; /* Information for hdr FSM */ - if(H5F_PAGED_AGGR(f)) { - /* Verify that lg_hdr_fspace is floating if it exists */ - if(lg_hdr_fspace) { + if (sm_hdr_fspace) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, lg_hdr_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (3)") + if (H5FS_stat_info(f, sm_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ - /* Verify that lg_sinfo_fspace is floating if it - * exists and is distinct - */ - if((lg_sinfo_fspace) && (lg_hdr_fspace != lg_sinfo_fspace)) { + /* Verify that sm_sinfo_fspace is floating if it exists and is distinct */ + if ((sm_sinfo_fspace) && (sm_hdr_fspace != sm_sinfo_fspace)) { /* Query free space manager info for this type */ - if(H5FS_stat_info(f, lg_sinfo_fspace, &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (4)") + if (H5FS_stat_info(f, sm_sinfo_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") HDassert(!H5F_addr_defined(fs_stat.addr)); HDassert(!H5F_addr_defined(fs_stat.sect_addr)); HDassert(fs_stat.alloc_sect_size == 0); } /* end if */ - } /* end if */ -} + + if (H5F_PAGED_AGGR(f)) { + /* Verify that lg_hdr_fspace is floating if it exists */ + if (lg_hdr_fspace) { + /* Query free space manager info for this type */ + if (H5FS_stat_info(f, lg_hdr_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (3)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + + /* Verify that lg_sinfo_fspace is floating if it + * exists and is distinct + */ + if ((lg_sinfo_fspace) && (lg_hdr_fspace != lg_sinfo_fspace)) { + /* Query free space manager info for this type */ + if (H5FS_stat_info(f, lg_sinfo_fspace, &fs_stat) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info (4)") + + HDassert(!H5F_addr_defined(fs_stat.addr)); + HDassert(!H5F_addr_defined(fs_stat.sect_addr)); + HDassert(fs_stat.alloc_sect_size == 0); + } /* end if */ + } /* end if */ + } #endif /* NDEBUG */ /* Free the space in the metadata aggregator. Do this via the @@ -3255,30 +3212,15 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * Note that the aggregators will not exist if paged aggregation * is enabled -- don't attempt to free if this is the case. */ - /* Vailin -- is this correct? */ /* (for space not at EOF, it may be put into free space managers) */ - if((!H5F_PAGED_AGGR(f)) && (H5MF_free_aggrs(f) < 0)) + if ((!H5F_PAGED_AGGR(f)) && (H5MF_free_aggrs(f) < 0)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregators") /* Trying shrinking the EOA for the file */ - if(H5MF__close_shrink_eoa(f) < 0) + if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") - /* At this point, the EOA should be set to a value that contains - * the allocation for all user data, all non self referential FSMs, - * the superblock and all superblock extension messages. - * - * Make note of the current EOA. We will store this value in the - * free space manager superblock extension message. Since space for - * everything other than the self referential FSMs (and possibly the - * cache image) has been allocated at this point, this allows us to - * to float the self referential FSMs on the first file space allocation / - * deallocation and then set the EOA to this value before we handle - * the allocation / deallocation. (If a cache image exists, the - * first allocation / deallocation will be the deallocation of space - * for the cache image). - * - * WARNING: This approach settling the self referential free space + /* WARNING: This approach settling the self referential free space * managers and allocating space for them in the file will * not work as currently implemented with the split and * multi file drivers, as the self referential free space @@ -3297,92 +3239,67 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * We should be able to support the split file driver * without a file format change. However, the code to * do so does not exist at present. + * NOTE: not sure whether to remove or keep the above comments */ - if(HADDR_UNDEF == (eoa_pre_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") - - /* ******************* PROBLEM: ******************** - * - * If the file has an alignment other than 1, and if - * the EOA is not a multiple of this alignment, allocating space - * for the section via the VFD info has the potential of generating - * a fragment that will be added to the free space manager. This - * of course undoes everything we have been doing here. - * - * Need a way around this. Obvious solution is to force the EOA to - * be a multiple of the alignment. - * - * Fortunately, alignment is typically 1, so this is a non-issue in - * most cases. In cases where the alignment is not 1, for now we - * have decided to drop the fragment on the floor. - * - * Eventually, we should fix this by modifying the on disk representations - * of free space managers to allow for empty space, so as to bypass the - * issues created by self-referential free space managers, and make - * this issue moot. + /* + * Continue allocating file space for the header and section info until + * they are all settled, */ - /* HDassert(f->shared->alignment == 1); */ + do { + continue_alloc_fsm = FALSE; + if (sm_hdr_fspace) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, sm_hdr_fspace, &(f->shared->fs_addr[sm_fshdr_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm hdr FSM file space") + + if (sm_sinfo_fspace && (sm_sinfo_fspace != sm_hdr_fspace)) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, sm_sinfo_fspace, &(f->shared->fs_addr[sm_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate sm sinfo FSM file space") + + if (H5F_PAGED_AGGR(f)) { + if (lg_hdr_fspace) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, lg_hdr_fspace, &(f->shared->fs_addr[lg_fshdr_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate lg hdr FSM file space") + + if (lg_sinfo_fspace && (lg_sinfo_fspace != lg_hdr_fspace)) + if (H5FS_vfd_alloc_hdr_and_section_info_if_needed( + f, lg_sinfo_fspace, &(f->shared->fs_addr[lg_fssinfo_fs_type])) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "can't vfd allocate lg sinfo FSM file space") + } /* end if */ + sm_hdr_fspace = f->shared->fs_man[sm_fshdr_fs_type]; + sm_sinfo_fspace = f->shared->fs_man[sm_fssinfo_fs_type]; + if (H5F_PAGED_AGGR(f)) { + lg_hdr_fspace = f->shared->fs_man[lg_fshdr_fs_type]; + lg_sinfo_fspace = f->shared->fs_man[lg_fssinfo_fs_type]; + } - /* The free space manager(s) that handle space allocations for free - * space managers should be settled now, albeit without file space - * allocated to them. To avoid the possibility of changing the sizes - * of their section info blocks, allocate space for them now at the - * end of file via H5FD_alloc(). - * - * In the past, this issue of allocating space without touching the - * free space managers has been dealt with by calling - * H5MF_aggr_vfd_alloc(), which in turn calls H5MF_aggr_alloc(). - * This is problematic since (if I read the code correctly) it will - * re-constitute the metadata aggregator, which will add any leftover - * space to one of the free space managers when freed. - * - * This is a non-starter, since the entire objective is to settle the - * free space managers. - * - * Hence the decision to call H5FD_alloc() directly. - * - * As discussed in PROBLEM above, if f->shared->alignment is not 1, - * this has the possibility of generating a fragment of file space - * that would typically be inserted into one of the free space managers. - * - * This is isn't good, but due to schedule pressure, we will just drop - * the fragment on the floor for now. - */ - if(sm_hdr_fspace) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, sm_hdr_fspace, &(f->shared->fs_addr[sm_fshdr_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm hdr FSM file space") - - if(sm_sinfo_fspace && (sm_sinfo_fspace != sm_hdr_fspace)) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, sm_sinfo_fspace, &(f->shared->fs_addr[sm_fssinfo_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate sm sinfo FSM file space") - - if(H5F_PAGED_AGGR(f)) { - if(lg_hdr_fspace) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, lg_hdr_fspace, &(f->shared->fs_addr[lg_fshdr_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg hdr FSM file space") - - if(lg_sinfo_fspace && (lg_sinfo_fspace != lg_hdr_fspace)) - if(H5FS_vfd_alloc_hdr_and_section_info_if_needed(f, lg_sinfo_fspace, &(f->shared->fs_addr[lg_fssinfo_fs_type])) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg sinfo FSM file space") - } /* end if */ + if (H5MF__continue_alloc_fsm(f->shared, sm_hdr_fspace, sm_sinfo_fspace, lg_hdr_fspace, + lg_sinfo_fspace, &continue_alloc_fsm) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't vfd allocate lg sinfo FSM file space") + } while (continue_alloc_fsm); + /* All free space managers should have file space allocated for them + * now, and should see no further allocations / deallocations. + * For backward compatibility, store the eoa in f->shared->eoa_fsm_fsalloc + * which will be set to fsinfo.eoa_pre_fsm_fsalloc when we actually write + * the free-space info message to the superblock extension. + * This will allow the 1.10 library with the hack to open the file with + * the new solution. + */ /* Get the eoa after allocation of file space for the self referential * free space managers. Assuming no cache image, this should be the * final EOA of the file. */ - if(HADDR_UNDEF == (eoa_post_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa_fsm_fsalloc = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - - /* All free space managers should have file space allocated for them - * now, and should see no further allocations / deallocations. Store - * the pre and post file space allocation for self referential FSMs EOA - * for use when we actually write the free space manager superblock - * extension message. - */ - f->shared->eoa_pre_fsm_fsalloc = eoa_pre_fsm_fsalloc; - f->shared->eoa_post_fsm_fsalloc = eoa_post_fsm_fsalloc; + f->shared->eoa_fsm_fsalloc = eoa_fsm_fsalloc; /* Indicate that the FSM was settled successfully */ *fsm_settled = TRUE; @@ -3390,18 +3307,64 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5MF_settle_meta_data_fsm() */ - +/*------------------------------------------------------------------------- + * Function: H5MF__continue_alloc_fsm + * + * Purpose: To determine whether any of the input FSMs has allocated + * its "addr" and "sect_addr". + * Return TRUE or FALSE in *continue_alloc_fsm. + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi + * 6/24/2019 + *------------------------------------------------------------------------- + */ +static herr_t +H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, + H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, hbool_t *continue_alloc_fsm) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(f_sh); + HDassert(continue_alloc_fsm); + + /* Check sm_hdr_fspace */ + if (sm_hdr_fspace && sm_hdr_fspace->serial_sect_count > 0 && sm_hdr_fspace->sinfo) + H5MF_CHECK_FSM(sm_hdr_fspace, continue_alloc_fsm); + + if (!(*continue_alloc_fsm)) + if (sm_sinfo_fspace && sm_sinfo_fspace != sm_hdr_fspace && sm_sinfo_fspace->serial_sect_count > 0 && + sm_sinfo_fspace->sinfo) + H5MF_CHECK_FSM(sm_hdr_fspace, continue_alloc_fsm); + + if (H5F_SHARED_PAGED_AGGR(f_sh) && !(*continue_alloc_fsm)) { + /* Check lg_hdr_fspace */ + if (lg_hdr_fspace && lg_hdr_fspace->serial_sect_count > 0 && lg_hdr_fspace->sinfo) + H5MF_CHECK_FSM(lg_hdr_fspace, continue_alloc_fsm); + + /* Check lg_sinfo_fspace */ + if (!(*continue_alloc_fsm)) + if (lg_sinfo_fspace && lg_sinfo_fspace != lg_hdr_fspace && + lg_sinfo_fspace->serial_sect_count > 0 && lg_sinfo_fspace->sinfo) + H5MF_CHECK_FSM(lg_sinfo_fspace, continue_alloc_fsm); + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5MF__continue_alloc_fsm() */ + /*------------------------------------------------------------------------- * Function: H5MF__fsm_type_is_self_referential() * * Purpose: Return TRUE if the indicated free space manager allocates - * file space for free space managers. Return FALSE otherwise. + * file space for free space managers. Return FALSE otherwise. * * Return: TRUE/FALSE * @@ -3410,32 +3373,31 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * *------------------------------------------------------------------------- */ -hbool_t -H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) +static hbool_t +H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type) { H5F_mem_page_t sm_fshdr_fsm; H5F_mem_page_t sm_fssinfo_fsm; H5F_mem_page_t lg_fshdr_fsm; H5F_mem_page_t lg_fssinfo_fsm; - hbool_t result = FALSE; + hbool_t result = FALSE; - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ - HDassert(f); - HDassert(f->shared); + HDassert(f_sh); HDassert(fsm_type >= H5F_MEM_PAGE_DEFAULT); HDassert(fsm_type < H5F_MEM_PAGE_NTYPES); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); - if(H5F_PAGED_AGGR(f)) { - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); + if (H5F_SHARED_PAGED_AGGR(f_sh)) { + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, f_sh->fs_page_size + 1, &lg_fshdr_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, f_sh->fs_page_size + 1, &lg_fssinfo_fsm); - result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) - || (fsm_type == lg_fshdr_fsm) || (fsm_type == lg_fssinfo_fsm); + result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm) || (fsm_type == lg_fshdr_fsm) || + (fsm_type == lg_fssinfo_fsm); } /* end if */ else { /* In principle, fsm_type should always be less than @@ -3444,7 +3406,7 @@ H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) * not observe this principle, force the result to FALSE if * fsm_type is greater than or equal to H5F_MEM_PAGE_LARGE_SUPER. */ - if(fsm_type >= H5F_MEM_PAGE_LARGE_SUPER) + if (fsm_type >= H5F_MEM_PAGE_LARGE_SUPER) result = FALSE; else result = (fsm_type == sm_fshdr_fsm) || (fsm_type == sm_fssinfo_fsm); @@ -3453,12 +3415,11 @@ H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) FUNC_LEAVE_NOAPI(result) } /* H5MF__fsm_type_is_self_referential() */ - /*------------------------------------------------------------------------- * Function: H5MF__fsm_is_self_referential() * * Purpose: Return TRUE if the indicated free space manager allocates - * file space for free space managers. Return FALSE otherwise. + * file space for free space managers. Return FALSE otherwise. * * Return: TRUE/FALSE * @@ -3468,337 +3429,33 @@ H5MF__fsm_type_is_self_referential(H5F_t *f, H5F_mem_page_t fsm_type) *------------------------------------------------------------------------- */ static hbool_t -H5MF__fsm_is_self_referential(H5F_t *f, H5FS_t *fspace) +H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace) { H5F_mem_page_t sm_fshdr_fsm; H5F_mem_page_t sm_fssinfo_fsm; - hbool_t result = FALSE; + hbool_t result = FALSE; FUNC_ENTER_STATIC_NOERR /* Sanity check */ - HDassert(f); - HDassert(f->shared); + HDassert(f_sh); HDassert(fspace); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fsm); - if(H5F_PAGED_AGGR(f)) { + if (H5F_SHARED_PAGED_AGGR(f_sh)) { H5F_mem_page_t lg_fshdr_fsm; H5F_mem_page_t lg_fssinfo_fsm; - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fsm); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_HDR, f_sh->fs_page_size + 1, &lg_fshdr_fsm); + H5MF__alloc_to_fs_type(f_sh, H5FD_MEM_FSPACE_SINFO, f_sh->fs_page_size + 1, &lg_fssinfo_fsm); - result = (fspace == f->shared->fs_man[sm_fshdr_fsm]) || - (fspace == f->shared->fs_man[sm_fssinfo_fsm]) || - (fspace == f->shared->fs_man[lg_fshdr_fsm]) || - (fspace == f->shared->fs_man[lg_fssinfo_fsm]); + result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || (fspace == f_sh->fs_man[sm_fssinfo_fsm]) || + (fspace == f_sh->fs_man[lg_fshdr_fsm]) || (fspace == f_sh->fs_man[lg_fssinfo_fsm]); } /* end if */ else - result = (fspace == f->shared->fs_man[sm_fshdr_fsm]) || - (fspace == f->shared->fs_man[sm_fssinfo_fsm]); + result = (fspace == f_sh->fs_man[sm_fshdr_fsm]) || (fspace == f_sh->fs_man[sm_fssinfo_fsm]); FUNC_LEAVE_NOAPI(result) } /* H5MF__fsm_is_self_referential() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_tidy_self_referential_fsm_hack - * - * Purpose: As discussed in the comments of the settle routines above, - * the existence of self referential free space managers - * as currently implemented creates the possibility of - * infinite loops at file close. - * - * As a hack to avoid this, we have added code to settle - * self referential free space managers, and then allocate - * space for them directly from the file driver. - * - * To avoid dropping ever increasing amounts of file space - * on the floor with each subsequent file close/open cycle, - * we need to clean this up on file open. To avoid this, - * this function is called on the first file space allocation - * or deallocation after file open to float the self referential - * free space managers and reduce the EOA to the value it - * had before the direct allocation of space for the self - * referential free space managers. - * - * The function proceeds as follows: - * - * 1) Verify that f->shared->first_alloc_dealloc is TRUE, - * and then set it to FALSE. - * - * 2) Get the current EOA. Verify that it is greater than - * or equal to f->shared->eoa_pre_fsm_fsalloc. If the - * current eoa is equal to f->shared->eoa_pre_fsm_fsalloc, - * no self referential FSMs were stored, and we are done. - * - * NOTE: This will have to be reworked somewhat for - * cache image. - * - * 3) Load the self referential FSMs. In passing verify that - * the lowest address of a FSM header is equal to - * f->shared->eoa_pre_fsm_fsalloc. - * - * Note that we don't have to use any special I/O for - * this -- we can use the regular I/O methods even if - * paged aggregation and page buffering is enabled. - * - * 4) Float the FSMs. Ensure that the file space is NOT - * released. - * - * 5) Set EOA equal to f->shared->eoa_pre_fsm_fsalloc, - * and then set f->shared->eoa_pre_fsm_fsalloc to - * HADDR_UNDEF. - * - * If page buffering, verify that the new EOA is - * on a page boundary, and expunge any pages in the - * page buffer after the new EOA. - * - * Note that this function is also called from test code - * when it is necessary to startup a self referential - * free space manager prior to the first file space - * allocation / deallocation. Failure to do so will - * result in assertion failures in this function on - * the first file space allocation / deallocation. - * - * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer - * 12/11/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF_tidy_self_referential_fsm_hack(H5F_t *f) -{ - haddr_t eoa; /* EOA of file */ - hsize_t tail_size = 0; /* Size of chunk to free */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - haddr_t first_srfsm_hdr = HADDR_UNDEF; /* Addr of first self referential */ - /* fsm header in file */ - H5FS_stat_t fs_stat; /* Information for hdr FSM */ - H5F_mem_page_t sm_fshdr_fs_type; /* Small fs hdr fsm */ - H5F_mem_page_t sm_fssinfo_fs_type; /* Small fs sinfo fsm */ - H5F_mem_page_t lg_fshdr_fs_type; /* Large fs hdr fsm */ - H5F_mem_page_t lg_fssinfo_fs_type; /* Large fs sinfo fsm */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) - - /* check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->fs_persist); - HDassert(f->shared->first_alloc_dealloc); - - /* Set the ring type in the API context. Since we are only dealing with - * self referential FSMs, we will only need H5AC_RING_MDFSM. - */ - H5AC_set_ring(H5AC_RING_MDFSM, &orig_ring); - - /* 1) Verify that f->shared->first_alloc_dealloc is TRUE, - * and then set it to FALSE. - */ - HDassert(f->shared->first_alloc_dealloc); - f->shared->first_alloc_dealloc = FALSE; - - - /* 2) Get the current EOA. Verify that it is greater than - * or equal to f->shared->eoa_pre_fsm_fsalloc. If the - * current eoa is equal to f->shared->eoa_pre_fsm_fsalloc, - * no self referential FSMs were stored, and we are done. - * - * NOTE: This will have to be reworked somewhat for - * cache image. - */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") - HDassert(H5F_addr_le(f->shared->eoa_pre_fsm_fsalloc, eoa)); - - if(H5F_addr_eq(f->shared->eoa_pre_fsm_fsalloc, eoa)) - HGOTO_DONE(SUCCEED) - - - /* 3) Load the self referential FSMs. In passing verify that - * the lowest address of a FSM header is equal to - * f->shared->eoa_pre_fsm_fsalloc.' - * - * Note that we don't have to use any special I/O for - * this -- we can use the regular I/O methods even if - * paged aggregation and page buffering is enabled. - */ - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, (size_t)1, &sm_fshdr_fs_type); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, (size_t)1, &sm_fssinfo_fs_type); - HDassert(sm_fshdr_fs_type > H5F_MEM_PAGE_DEFAULT); - HDassert(sm_fshdr_fs_type < H5F_MEM_PAGE_LARGE_SUPER); - - HDassert(sm_fssinfo_fs_type > H5F_MEM_PAGE_DEFAULT); - HDassert(sm_fssinfo_fs_type < H5F_MEM_PAGE_LARGE_SUPER); - - HDassert(NULL == f->shared->fs_man[sm_fshdr_fs_type]); - HDassert(NULL == f->shared->fs_man[sm_fssinfo_fs_type]); - - if(H5F_addr_defined(f->shared->fs_addr[sm_fshdr_fs_type])) { - first_srfsm_hdr = f->shared->fs_addr[sm_fshdr_fs_type]; - - /* open the FSM */ - if(H5MF__open_fstype(f, sm_fshdr_fs_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - - HDassert(f->shared->fs_man[sm_fshdr_fs_type]); - } /* end if */ - - if((sm_fshdr_fs_type != sm_fssinfo_fs_type) && - (H5F_addr_defined(f->shared->fs_addr[sm_fssinfo_fs_type]))) { - - if(!H5F_addr_defined(first_srfsm_hdr) || - (H5F_addr_defined(first_srfsm_hdr) && - H5F_addr_lt(f->shared->fs_addr[sm_fssinfo_fs_type], first_srfsm_hdr))) - first_srfsm_hdr = f->shared->fs_addr[sm_fssinfo_fs_type]; - - HDassert(NULL == f->shared->fs_man[sm_fssinfo_fs_type]); - - /* open the FSM */ - if(H5MF__open_fstype(f, sm_fssinfo_fs_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - - HDassert(f->shared->fs_man[sm_fssinfo_fs_type]); - } /* end if */ - - if(H5F_PAGED_AGGR(f)) { - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_HDR, f->shared->fs_page_size + 1, &lg_fshdr_fs_type); - H5MF__alloc_to_fs_type(f, H5FD_MEM_FSPACE_SINFO, f->shared->fs_page_size + 1, &lg_fssinfo_fs_type); - - HDassert(lg_fshdr_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); - HDassert(lg_fshdr_fs_type < H5F_MEM_PAGE_NTYPES); - - HDassert(lg_fssinfo_fs_type >= H5F_MEM_PAGE_LARGE_SUPER); - HDassert(lg_fssinfo_fs_type < H5F_MEM_PAGE_NTYPES); - - HDassert(NULL == f->shared->fs_man[lg_fshdr_fs_type]); - HDassert(NULL == f->shared->fs_man[lg_fssinfo_fs_type]); - - if(H5F_addr_defined(f->shared->fs_addr[lg_fshdr_fs_type])) { - if(!H5F_addr_defined(first_srfsm_hdr) || - (H5F_addr_defined(first_srfsm_hdr) && - H5F_addr_lt(f->shared->fs_addr[lg_fshdr_fs_type], first_srfsm_hdr))) - first_srfsm_hdr = f->shared->fs_addr[lg_fshdr_fs_type]; - - HDassert(NULL == f->shared->fs_man[lg_fshdr_fs_type]); - - /* open the FSM */ - if(H5MF__open_fstype(f, lg_fshdr_fs_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - HDassert(f->shared->fs_man[lg_fshdr_fs_type]); - } /* end if */ - - if(lg_fshdr_fs_type != lg_fssinfo_fs_type && H5F_addr_defined(f->shared->fs_addr[lg_fssinfo_fs_type])) { - if(!H5F_addr_defined(first_srfsm_hdr) || - (H5F_addr_defined(first_srfsm_hdr) && - H5F_addr_lt(f->shared->fs_addr[lg_fssinfo_fs_type], first_srfsm_hdr))) - first_srfsm_hdr = f->shared->fs_addr[lg_fssinfo_fs_type]; - - HDassert(NULL == f->shared->fs_man[lg_fssinfo_fs_type]); - - /* open the FSM */ - if(H5MF__open_fstype(f, lg_fssinfo_fs_type) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space manager") - HDassert(f->shared->fs_man[lg_fssinfo_fs_type]); - } /* end if */ - } /* end if */ - HDassert(H5F_addr_eq(first_srfsm_hdr, f->shared->eoa_pre_fsm_fsalloc)); - - /* 4) Float the FSMs. Ensure that the file space is NOT released. */ - if(f->shared->fs_man[sm_fshdr_fs_type]) { - /* Sanity check: Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[sm_fshdr_fs_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") - - HDassert(H5F_addr_defined(fs_stat.addr)); - HDassert(H5F_addr_defined(fs_stat.sect_addr)); - if(H5FS_free(f, f->shared->fs_man[sm_fshdr_fs_type], FALSE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") - f->shared->fs_addr[sm_fshdr_fs_type] = HADDR_UNDEF; - } /* end if */ - - if(sm_fshdr_fs_type != sm_fssinfo_fs_type && f->shared->fs_man[sm_fssinfo_fs_type]) { - /* Sanity check: Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[sm_fssinfo_fs_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't get free-space info") - - HDassert(H5F_addr_defined(fs_stat.addr)); - HDassert(H5F_addr_defined(fs_stat.sect_addr)); - if(H5FS_free(f, f->shared->fs_man[sm_fssinfo_fs_type], FALSE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't release free-space headers") - f->shared->fs_addr[sm_fssinfo_fs_type] = HADDR_UNDEF; - } /* end if */ - - if(H5F_PAGED_AGGR(f)) { - if(f->shared->fs_man[lg_fshdr_fs_type]) { - /* Sanity check: Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[lg_fshdr_fs_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(H5F_addr_defined(fs_stat.addr)); - HDassert(H5F_addr_defined(fs_stat.sect_addr)); - if(H5FS_free(f, f->shared->fs_man[lg_fshdr_fs_type], FALSE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't float free-space headers") - f->shared->fs_addr[lg_fshdr_fs_type] = HADDR_UNDEF; - } /* end if */ - - if(lg_fshdr_fs_type != lg_fssinfo_fs_type && f->shared->fs_man[lg_fssinfo_fs_type]) { - /* Sanity check: Query free space manager info for this type */ - if(H5FS_stat_info(f, f->shared->fs_man[lg_fssinfo_fs_type], &fs_stat) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get free-space info") - - HDassert(H5F_addr_defined(fs_stat.addr)); - HDassert(H5F_addr_defined(fs_stat.sect_addr)); - if(H5FS_free(f, f->shared->fs_man[lg_fssinfo_fs_type], FALSE) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't float free-space headers") - f->shared->fs_addr[lg_fssinfo_fs_type] = HADDR_UNDEF; - } /* end if */ - } /* end if */ - - /* 5) Set EOA equal to f->shared->eoa_pre_fsm_fsalloc, - * and then set f->shared->eoa_pre_fsm_fsalloc to - * HADDR_UNDEF. - * - * If page buffering, verify that the new EOA is - * on a page boundary, and expunge any pages in the - * page buffer after the new EOA. - */ - if(!H5F_PAGED_AGGR(f)) { - /* Verify that the aggregators are still shutdown. */ - HDassert(f->shared->sdata_aggr.tot_size == 0); - HDassert(f->shared->sdata_aggr.addr == 0); - HDassert(f->shared->sdata_aggr.size == 0); - - HDassert(f->shared->meta_aggr.tot_size == 0); - HDassert(f->shared->meta_aggr.addr == 0); - HDassert(f->shared->meta_aggr.size == 0); - } /* end if */ - - tail_size = (hsize_t)(eoa - f->shared->eoa_pre_fsm_fsalloc); - - /* Release file space allocated to self referential FSMs */ - if(H5F__free(f, H5FD_MEM_DEFAULT, f->shared->eoa_pre_fsm_fsalloc, tail_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") - HDassert(H5F_addr_eq(f->shared->eoa_pre_fsm_fsalloc, eoa)); - - f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; - - HDassert((!H5F_PAGED_AGGR(f)) || (0 == (eoa % f->shared->fs_page_size))); - -done: - /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) - H5AC_set_ring(orig_ring, NULL); - - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* H5MF_tidy_self_referential_fsm_hack() */ - diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index b5be1da9740..68cd26329c1 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,62 +23,51 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ #define EXTEND_THRESHOLD 0.10F - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, - H5F_blk_aggr_t *aggr); -static haddr_t H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, - H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size); -static herr_t H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr); -static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); - +static herr_t H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); +static haddr_t H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, + hsize_t size); +static herr_t H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr); +static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5MF_aggr_vfd_alloc * @@ -99,11 +88,11 @@ static htri_t H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_ haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ 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 = %Hu\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_AGGR_DEBUG */ /* check arguments */ @@ -113,14 +102,16 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ HDassert(size > 0); /* Couldn't find anything from the free space manager, go allocate some */ - if(alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { + if (alloc_type != H5FD_MEM_DRAW && alloc_type != H5FD_MEM_GHEAP) { /* Handle metadata differently from "raw" data */ - if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) + if (HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), + alloc_type, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") } /* end if */ else { /* Allocate "raw" data: H5FD_MEM_DRAW and H5FD_MEM_GHEAP */ - if(HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), H5FD_MEM_DRAW, size))) + if (HADDR_UNDEF == (ret_value = H5MF__aggr_alloc(f, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), + H5FD_MEM_DRAW, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") } /* end else */ @@ -129,13 +120,12 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ 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 = %a, size = %Hu\n", FUNC, ret_value, size); #endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_vfd_alloc() */ - /*------------------------------------------------------------------------- * Function: H5MF__aggr_alloc * @@ -151,31 +141,32 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, *------------------------------------------------------------------------- */ static haddr_t -H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, - H5FD_mem_t type, hsize_t size) +H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { - haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ - hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ - haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ + hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ 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 = %Hu\n", FUNC, (unsigned)type, size); #endif /* H5MF_AGGR_DEBUG */ /* check args */ HDassert(f); HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); HDassert(other_aggr); - HDassert(other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); HDassert(other_aggr->feature_flag != aggr->feature_flag); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(size > 0); /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") /* @@ -183,723 +174,759 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); * allocate "generic" space and sub-allocate out of that, if possible. * Otherwise just allocate through H5F__alloc(). */ - if((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE) { - haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator 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 */ - H5FD_mem_t alloc_type, other_alloc_type;/* Current aggregator & 'other' aggregator types */ + + /* + * Replace the following line with the line in #ifdef REPLACE/#endif. + * The line in #ifdef REPLACE triggers the following problem: + * test/objcopy.c: test_copy_group_deep() test fails with the family driver + * + * When closing the destination file after H5Ocopy, the library flushes the fractal + * heap direct block via H5HF__cache_dblock_pre_serialize(). While doing so, + * the cache eventually adjusts/evicts ageout entries and ends up flushing out the + * same entry that is being serialized (flush_in_progress). + */ + if ((f->shared->feature_flags & aggr->feature_flag) && + f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && + (!f->shared->closing || !f->shared->fs_persist)) { +#ifdef REPLACE + 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 */ + 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 */ + 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 = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size); #endif /* H5MF_AGGR_DEBUG */ - /* Turn off alignment if allocation < threshold */ - alignment = H5F_ALIGNMENT(f); - if(!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) - alignment = 0; /* no alignment */ + /* Turn off alignment if allocation < threshold */ + alignment = H5F_ALIGNMENT(f); + if (!((alignment > 1) && (size >= H5F_THRESHOLD(f)))) + alignment = 0; /* no alignment */ - /* Generate fragment if aggregator is mis-aligned */ - if(alignment && H5F_addr_gt(aggr->addr, 0) && (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { - aggr_frag_addr = aggr->addr; - aggr_frag_size = alignment - aggr_mis_align; - } /* end if */ + /* Generate fragment if aggregator is mis-aligned */ + if (alignment && H5F_addr_gt(aggr->addr, 0) && + (aggr_mis_align = (aggr->addr + H5F_BASE_ADDR(f)) % alignment)) { + aggr_frag_addr = aggr->addr; + aggr_frag_size = alignment - aggr_mis_align; + } /* end if */ - alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; - other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; - - /* Check if the space requested is larger than the space left in the block */ - if((size + aggr_frag_size) > aggr->size) { - htri_t extended = FALSE; /* Whether the file was extended */ - - /* Check if the block asked for is too large for 'normal' aggregator block */ - if(size >= aggr->alloc_size) { - hsize_t ext_size = size + aggr_frag_size; - - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(extended) { - /* aggr->size is unchanged */ - ret_value = aggr->addr + aggr_frag_size; - aggr->addr += ext_size; - aggr->tot_size += ext_size; - } + alloc_type = + aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + other_alloc_type = + other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; + + /* Check if the space requested is larger than the space left in the block */ + if ((size + aggr_frag_size) > aggr->size) { + htri_t extended = FALSE; /* Whether the file was extended */ + + /* Check if the block asked for is too large for 'normal' aggregator block */ + if (size >= aggr->alloc_size) { + hsize_t ext_size = size + aggr_frag_size; + + /* Check for overlapping into file's temporary allocation space */ + if (H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR( + H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") + + if ((aggr->addr > 0) && + (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if (extended) { + /* aggr->size is unchanged */ + ret_value = aggr->addr + aggr_frag_size; + aggr->addr += ext_size; + aggr->tot_size += ext_size; + } + else { + /* Release "other" aggregator, if it exists, is at the end of the allocated space, + * has allocated more than one block and the unallocated space is greater than its + * allocation block size. + */ + if ((other_aggr->size > 0) && + (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && + ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if (H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + } /* end if */ + + /* Allocate space from the VFD (i.e. at the end of the file) */ + if (HADDR_UNDEF == + (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + } /* end else */ + } /* end if */ else { - /* Release "other" aggregator, if it exists, is at the end of the allocated space, - * has allocated more than one block and the unallocated space is greater than its - * allocation block size. - */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ - - /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, alloc_type, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - } /* end else */ - } /* end if */ - else { - hsize_t ext_size = aggr->alloc_size; + hsize_t ext_size = aggr->alloc_size; - /* Allocate another block */ + /* Allocate another block */ #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: Allocating block\n", FUNC); + HDfprintf(stderr, "%s: Allocating block\n", FUNC); #endif /* H5MF_AGGR_DEBUG */ - if(aggr_frag_size > (ext_size - size)) - ext_size += (aggr_frag_size - (ext_size - size)); - - /* Check for overlapping into file's temporary allocation space */ - if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) - HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") - - if((aggr->addr > 0) && (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") - else if(extended) { - aggr->addr += aggr_frag_size; - aggr->size += (ext_size - aggr_frag_size); - aggr->tot_size += ext_size; - } /* end else-if */ - else { - haddr_t new_space; /* Address of new space allocated */ - - /* Release "other" aggregator, if it exists, is at the end of the allocated space, - * has allocated more than one block and the unallocated space is greater than its - * allocation block size. - */ - if((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && - (other_aggr->tot_size > other_aggr->size) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { - if(H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - } /* end if */ - - /* Allocate space from the VFD (i.e. at the end of the file) */ - if(HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - - /* Return the unused portion of the block to a free list */ - if(aggr->size > 0) - if(H5MF_xfree(f, alloc_type, aggr->addr, aggr->size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation block") - - /* If the block is not to be aligned, fold the eoa fragment - * into the newly allocated aggregator, as it could have - * been allocated in an aligned manner if the aggregator - * block is larger than the threshold */ - if(eoa_frag_size && !alignment) { - HDassert(eoa_frag_addr + eoa_frag_size == new_space); - aggr->addr = eoa_frag_addr; - aggr->size = aggr->alloc_size + eoa_frag_size; - aggr->tot_size = aggr->size; - - /* Reset EOA fragment */ - eoa_frag_addr = HADDR_UNDEF; - eoa_frag_size = 0; - } /* end if */ + if (aggr_frag_size > (ext_size - size)) + ext_size += (aggr_frag_size - (ext_size - size)); + + /* Check for overlapping into file's temporary allocation space */ + if (H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR( + H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, + "'normal' file space allocation request will overlap into 'temporary' file space") + + if ((aggr->addr > 0) && + (extended = H5F__try_extend(f, alloc_type, (aggr->addr + aggr->size), ext_size)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") + else if (extended) { + aggr->addr += aggr_frag_size; + aggr->size += (ext_size - aggr_frag_size); + aggr->tot_size += ext_size; + } /* end else-if */ else { - /* Point the aggregator at the newly allocated block */ - aggr->addr = new_space; - aggr->size = aggr->alloc_size; - aggr->tot_size = aggr->alloc_size; - } /* end else */ - } /* end else */ + haddr_t new_space; /* Address of new space allocated */ - /* Allocate space out of the metadata block */ - ret_value = aggr->addr; - aggr->size -= size; - aggr->addr += size; - } /* end else */ + /* Release "other" aggregator, if it exists, is at the end of the allocated space, + * has allocated more than one block and the unallocated space is greater than its + * allocation block size. + */ + if ((other_aggr->size > 0) && + (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && + (other_aggr->tot_size > other_aggr->size) && + ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { + if (H5MF__aggr_free(f, other_alloc_type, other_aggr) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + } /* end if */ + + /* Allocate space from the VFD (i.e. at the end of the file) */ + if (HADDR_UNDEF == (new_space = H5F__alloc(f, alloc_type, aggr->alloc_size, + &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Return the unused portion of the block to a free list */ + if (aggr->size > 0) + if (H5MF_xfree(f, alloc_type, aggr->addr, aggr->size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation block") + + /* If the block is not to be aligned, fold the eoa fragment + * into the newly allocated aggregator, as it could have + * been allocated in an aligned manner if the aggregator + * block is larger than the threshold */ + if (eoa_frag_size && !alignment) { + HDassert(eoa_frag_addr + eoa_frag_size == new_space); + aggr->addr = eoa_frag_addr; + aggr->size = aggr->alloc_size + eoa_frag_size; + aggr->tot_size = aggr->size; + + /* Reset EOA fragment */ + eoa_frag_addr = HADDR_UNDEF; + eoa_frag_size = 0; + } /* end if */ + else { + /* Point the aggregator at the newly allocated block */ + aggr->addr = new_space; + aggr->size = aggr->alloc_size; + aggr->tot_size = aggr->alloc_size; + } /* end else */ + } /* end else */ + + /* Allocate space out of the metadata block */ + ret_value = aggr->addr; + aggr->size -= size; + aggr->addr += size; + } /* end else */ - /* Freeing any possible fragment due to file allocation */ - if(eoa_frag_size) - if(H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") + /* Freeing any possible fragment due to file allocation */ + if (eoa_frag_size) + if (H5MF_xfree(f, alloc_type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - /* Freeing any possible fragment due to alignment in the block after extension */ - if(extended && aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") - } /* end if */ + /* Freeing any possible fragment due to alignment in the block after extension */ + if (extended && aggr_frag_size) + if (H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation fragment") + } /* end if */ + else { + /* Allocate space out of the block */ + ret_value = aggr->addr + aggr_frag_size; + aggr->size -= (size + aggr_frag_size); + aggr->addr += (size + aggr_frag_size); + + /* free any possible fragment */ + if (aggr_frag_size) + if (H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, + "can't free aggregation fragment") + } /* end else */ + } /* end if */ else { - /* Allocate space out of the block */ - ret_value = aggr->addr + aggr_frag_size; - aggr->size -= (size + aggr_frag_size); - aggr->addr += (size + aggr_frag_size); - - /* free any possible fragment */ - if(aggr_frag_size) - if(H5MF_xfree(f, alloc_type, aggr_frag_addr, aggr_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") + /* Allocate data from the file */ + if (HADDR_UNDEF == (ret_value = H5F__alloc(f, type, size, &eoa_frag_addr, &eoa_frag_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + + /* Check if fragment was generated */ + if (eoa_frag_size) + /* Put fragment on the free list */ + if (H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ - } /* end if */ - else { - /* Allocate data from the file */ - if(HADDR_UNDEF == (ret_value = H5F__alloc(f, type, size, &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") - - /* Check if fragment was generated */ - if(eoa_frag_size) - /* Put fragment on the free list */ - if(H5MF_xfree(f, type, eoa_frag_addr, eoa_frag_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - } /* end else */ - /* Sanity check for overlapping into file's temporary allocation space */ - HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); + /* Sanity check for overlapping into file's temporary allocation space */ + HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); - /* Post-condition sanity check */ - if(H5F_ALIGNMENT(f) && size >= H5F_THRESHOLD(f)) - HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % H5F_ALIGNMENT(f))); + /* Post-condition sanity check */ + if (H5F_ALIGNMENT(f) && size >= H5F_THRESHOLD(f)) + HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % H5F_ALIGNMENT(f))); done: #ifdef H5MF_AGGR_DEBUG -HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_alloc() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_try_extend - * - * Purpose: Check if a block is inside an aggregator block and extend it - * if possible. - * - * Note: - * When the block to be extended adjoins the aggregator-- - * 1) When the aggregator is at end of file: - * A) If the request is below the threshold, extend the block into the aggregator - * B) If the request is above the threshold, - * a) extend the aggregator by aggr->alloc_size or the extended amount - * b) extend the block into the aggregator - * 2) When the aggregator is not at end of file: - * Extended the block into the aggregator if it has enough space to satisfy the request - * - * Return: Success: TRUE(1) - Block was extended - * FALSE(0) - Block could not be extended - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, - H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested) -{ - htri_t ret_value = FALSE; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_alloc() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_try_extend + * + * Purpose: Check if a block is inside an aggregator block and extend it + * if possible. + * + * Note: + * When the block to be extended adjoins the aggregator-- + * 1) When the aggregator is at end of file: + * A) If the request is below the threshold, extend the block into the aggregator + * B) If the request is above the threshold, + * a) extend the aggregator by aggr->alloc_size or the extended amount + * b) extend the block into the aggregator + * 2) When the aggregator is not at end of file: + * Extended the block into the aggregator if it has enough space to satisfy the request + * + * Return: Success: TRUE(1) - Block was extended + * FALSE(0) - Block could not be extended + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + htri_t H5MF__aggr_try_extend(H5F_t * f, H5F_blk_aggr_t * aggr, H5FD_mem_t type, haddr_t blk_end, + hsize_t extra_requested) + { + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + /* + * If the block being tested adjoins the beginning of the aggregator + * block, check if the aggregator can accommodate the extension. + */ + if (H5F_addr_eq(blk_end, aggr->addr)) { + haddr_t eoa; /* EOA for the file */ - FUNC_ENTER_PACKAGE + /* Get the EOA for the file */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + /* If the aggregator is at the end of file: */ + if (H5F_addr_eq(eoa, aggr->addr + aggr->size)) { + /* If extra_requested is below percentage threshold, extend block into the aggregator. */ + if (extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { + aggr->size -= extra_requested; + aggr->addr += extra_requested; - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - /* - * If the block being tested adjoins the beginning of the aggregator - * block, check if the aggregator can accommodate the extension. - */ - if(H5F_addr_eq(blk_end, aggr->addr)) { - haddr_t eoa; /* EOA for the file */ - - /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - - /* If the aggregator is at the end of file: */ - if(H5F_addr_eq(eoa, aggr->addr + aggr->size)) { - /* If extra_requested is below percentage threshold, extend block into the aggregator. */ - if(extra_requested <= (hsize_t)(EXTEND_THRESHOLD * (float)aggr->size)) { - aggr->size -= extra_requested; - aggr->addr += extra_requested; - - /* Indicate success */ - HGOTO_DONE(TRUE); - } /* end if */ - /* - * If extra_requested is above percentage threshold: - * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested - * 2) extend the block into the aggregator - */ + /* Indicate success */ + HGOTO_DONE(TRUE); + } /* end if */ + /* + * If extra_requested is above percentage threshold: + * 1) "bubble" up the aggregator by aggr->alloc_size or extra_requested + * 2) extend the block into the aggregator + */ + else { + hsize_t extra = + (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; + + if ((ret_value = H5F__try_extend(f, type, (aggr->addr + aggr->size), extra)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") + else if (ret_value == TRUE) { + /* Shift the aggregator block by the extra requested */ + /* (allocates the space for the extra_requested) */ + aggr->addr += extra_requested; + + /* Add extra to the aggregator's total allocated amount */ + aggr->tot_size += extra; + + /* Account for any space added to the aggregator */ + /* (either 0 (if extra_requested > aggr->alloc_size) or + * (aggr->alloc_size - extra_requested) -QAK + */ + aggr->size += extra; + aggr->size -= extra_requested; + } /* end else-if */ + } /* end else */ + } /* end if */ else { - hsize_t extra = (extra_requested < aggr->alloc_size) ? aggr->alloc_size : extra_requested; - - if((ret_value = H5F__try_extend(f, type, (aggr->addr + aggr->size), extra)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") - else if(ret_value == TRUE) { - /* Shift the aggregator block by the extra requested */ - /* (allocates the space for the extra_requested) */ + /* The aggreator 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 */ + aggr->size -= extra_requested; aggr->addr += extra_requested; - /* Add extra to the aggregator's total allocated amount */ - aggr->tot_size += extra; - - /* Account for any space added to the aggregator */ - /* (either 0 (if extra_requested > aggr->alloc_size) or - * (aggr->alloc_size - extra_requested) -QAK - */ - aggr->size += extra; - aggr->size -= extra_requested; - } /* end else-if */ - } /* end else */ - } /* end if */ - else { - /* The aggreator 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 */ - aggr->size -= extra_requested; - aggr->addr += extra_requested; - - /* Indicate success */ - HGOTO_DONE(TRUE); - } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ + /* Indicate success */ + HGOTO_DONE(TRUE); + } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_try_extend() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_can_absorb - * - * Purpose: Check if a section adjoins an aggregator block and one can - * absorb the other. - * - * Return: Success: TRUE(1) - Section or aggregator can be absorbed - * FALSE(0) - Section and aggregator can not be absorbed - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Friday, February 1, 2008 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, - const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink) -{ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(sect); - HDassert(shrink); - - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - /* Check if the block adjoins the beginning or end of the aggregator */ - 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)) { + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_try_extend() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_can_absorb + * + * Purpose: Check if a section adjoins an aggregator block and one can + * absorb the other. + * + * Return: Success: TRUE(1) - Section or aggregator can be absorbed + * FALSE(0) - Section and aggregator can not be absorbed + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, February 1, 2008 + * + *------------------------------------------------------------------------- + */ + htri_t H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, const H5MF_free_section_t *sect, + H5MF_shrink_type_t *shrink) + { + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(sect); + HDassert(shrink); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + /* Check if the block adjoins the beginning or end of the aggregator */ + 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 {%a, %Hu} adjoins aggr = {%a, %Hu}\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) - *shrink = H5MF_SHRINK_SECT_ABSORB_AGGR; - else - *shrink = H5MF_SHRINK_AGGR_ABSORB_SECT; - - /* Indicate success */ - HGOTO_DONE(TRUE) - } /* end if */ - } /* end if */ + /* Check if aggregator would get too large and should be absorbed into section */ + if ((aggr->size + sect->sect_info.size) >= aggr->alloc_size) + *shrink = H5MF_SHRINK_SECT_ABSORB_AGGR; + else + *shrink = H5MF_SHRINK_AGGR_ABSORB_SECT; + + /* Indicate success */ + HGOTO_DONE(TRUE) + } /* end if */ + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_can_absorb() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_absorb - * - * Purpose: Absorb a free space section into an aggregator block or - * vice versa. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, February 1, 2008 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF__aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, - hbool_t allow_sect_absorb) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(f->shared->feature_flags & aggr->feature_flag); - HDassert(sect); - - /* Check if aggregator would get too large and should be absorbed into section */ - if((aggr->size + sect->sect_info.size) >= aggr->alloc_size && allow_sect_absorb) { - /* 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", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); -#endif /* H5MF_AGGR_DEBUG */ - /* Absorb aggregator onto end of section */ - sect->sect_info.size += aggr->size; - } /* end if */ - else { - /* Sanity check */ - HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_can_absorb() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_absorb + * + * Purpose: Absorb a free space section into an aggregator block or + * vice versa. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, February 1, 2008 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF__aggr_absorb(const H5F_t H5_ATTR_UNUSED *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, + hbool_t allow_sect_absorb) + { + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(f->shared->feature_flags & aggr->feature_flag); + HDassert(sect); + + /* Check if aggregator would get too large and should be absorbed into section */ + if ((aggr->size + sect->sect_info.size) >= aggr->alloc_size && allow_sect_absorb) { + /* 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 end of section = {%a, %Hu}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", + "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, + sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb aggregator onto beginning of section */ - sect->sect_info.addr -= aggr->size; - sect->sect_info.size += aggr->size; - } /* end if */ + /* Absorb aggregator onto end of section */ + sect->sect_info.size += aggr->size; + } /* end if */ + else { + /* Sanity check */ + HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - /* Reset aggregator */ - aggr->tot_size = 0; - aggr->addr = 0; - aggr->size = 0; - } /* end if */ - else { - /* 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", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", + "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, + sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb section onto front of aggregator */ - aggr->addr -= sect->sect_info.size; - aggr->size += sect->sect_info.size; + /* Absorb aggregator onto beginning of section */ + sect->sect_info.addr -= aggr->size; + sect->sect_info.size += aggr->size; + } /* end if */ - /* Sections absorbed onto front of aggregator count against the total - * amount of space aggregated together. - */ - aggr->tot_size -= MIN(aggr->tot_size, sect->sect_info.size); + /* Reset aggregator */ + aggr->tot_size = 0; + aggr->addr = 0; + aggr->size = 0; } /* end if */ else { - /* Sanity check */ - HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - + /* 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 end of aggr = {%a, %Hu}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", + "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, + aggr->size); #endif /* H5MF_AGGR_DEBUG */ - /* Absorb section onto end of aggregator */ - aggr->size += sect->sect_info.size; - } /* end if */ - /* Sanity check */ - HDassert(!allow_sect_absorb || (aggr->size < aggr->alloc_size)); - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF__aggr_absorb() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_query - * - * Purpose: Query a block aggregator's current address & size info - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, - hsize_t *size) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - if(addr) - *addr = aggr->addr; - if(size) - *size = aggr->size; - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MF__aggr_query() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_reset - * - * Purpose: Reset a block aggregator, returning any space back to file - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, December 13, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF__aggr_reset(H5F_t *f, H5F_blk_aggr_t *aggr) -{ - H5FD_mem_t alloc_type; /* Type of file memory to work with */ - herr_t ret_value = SUCCEED; /* Return value */ + /* Absorb section onto front of aggregator */ + aggr->addr -= sect->sect_info.size; + aggr->size += sect->sect_info.size; - FUNC_ENTER_STATIC - - /* Check args */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + /* Sections absorbed onto front of aggregator count against the total + * amount of space aggregated together. + */ + aggr->tot_size -= MIN(aggr->tot_size, sect->sect_info.size); + } /* end if */ + else { + /* Sanity check */ + HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); - /* Set the type of memory in the file */ - alloc_type = (aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW); /* Type of file memory to work with */ +#ifdef H5MF_AGGR_DEBUG + HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", + "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, + aggr->size); +#endif /* H5MF_AGGR_DEBUG */ + /* Absorb section onto end of aggregator */ + aggr->size += sect->sect_info.size; + } /* end if */ + /* Sanity check */ + HDassert(!allow_sect_absorb || (aggr->size < aggr->alloc_size)); + } /* end else */ - /* Check if this aggregator is active */ - if(f->shared->feature_flags & aggr->feature_flag) { - haddr_t tmp_addr; /* Temporary holder for aggregator address */ - hsize_t tmp_size; /* Temporary holder for aggregator size */ + FUNC_LEAVE_NOAPI(SUCCEED) + } /* end H5MF__aggr_absorb() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_query + * + * Purpose: Query a block aggregator's current address & size info + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size) + { + FUNC_ENTER_PACKAGE_NOERR + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + if (addr) + *addr = aggr->addr; + if (size) + *size = aggr->size; + } /* end if */ - /* Retain aggregator info */ - tmp_addr = aggr->addr; - tmp_size = aggr->size; + FUNC_LEAVE_NOAPI(SUCCEED) + } /* end H5MF__aggr_query() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_reset + * + * Purpose: Reset a block aggregator, returning any space back to file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, December 13, 2007 + * + *------------------------------------------------------------------------- + */ + static herr_t H5MF__aggr_reset(H5F_t * f, H5F_blk_aggr_t * aggr) + { + H5FD_mem_t alloc_type; /* Type of file memory to work with */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check args */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + + /* Set the type of memory in the file */ + alloc_type = (aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA + ? H5FD_MEM_DEFAULT + : H5FD_MEM_DRAW); /* Type of file memory to work with */ + + /* Check if this aggregator is active */ + if (f->shared->feature_flags & aggr->feature_flag) { + haddr_t tmp_addr; /* Temporary holder for aggregator address */ + hsize_t tmp_size; /* Temporary holder for aggregator size */ + + /* Retain aggregator info */ + 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 = %a, tmp_size = %Hu\n", FUNC, tmp_addr, tmp_size); #endif /* H5MF_AGGR_DEBUG */ - /* Reset aggregator block information */ - aggr->tot_size = 0; - aggr->addr = 0; - aggr->size = 0; + /* Reset aggregator block information */ + aggr->tot_size = 0; + aggr->addr = 0; + aggr->size = 0; - /* Return the unused portion of the metadata block to the file */ - if(tmp_size > 0 && (H5F_INTENT(f) & H5F_ACC_RDWR)) - if(H5MF_xfree(f, alloc_type, tmp_addr, tmp_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't release aggregator's free space") - } /* end if */ + /* Return the unused portion of the metadata block to the file */ + if (tmp_size > 0 && (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (H5MF_xfree(f, alloc_type, tmp_addr, tmp_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't release aggregator's free space") + } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF__aggr_reset() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_free_aggrs - * - * Purpose: Reset a metadata & small block aggregators, returning any space - * back to file - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * July 1st, 2009 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MF_free_aggrs(H5F_t *f) -{ - H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */ - H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->lf); - - /* Retrieve metadata aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") - - /* Retrieve 'small data' aggregator info, if available */ - if(H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") - - /* Make certain we release the aggregator that's later in the file first */ - /* (so the file shrinks properly) */ - if(H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) { - if(H5F_addr_lt(ma_addr, sda_addr)) { - first_aggr = &(f->shared->sdata_aggr); - second_aggr = &(f->shared->meta_aggr); - } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggr_reset() */ + + /*------------------------------------------------------------------------- + * Function: H5MF_free_aggrs + * + * Purpose: Reset a metadata & small block aggregators, returning any space + * back to file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * July 1st, 2009 + * + *------------------------------------------------------------------------- + */ + herr_t H5MF_free_aggrs(H5F_t * f) + { + H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */ + H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + + /* Retrieve metadata aggregator info, if available */ + if (H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + + /* Retrieve 'small data' aggregator info, if available */ + if (H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + + /* Make certain we release the aggregator that's later in the file first */ + /* (so the file shrinks properly) */ + if (H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) { + if (H5F_addr_lt(ma_addr, sda_addr)) { + first_aggr = &(f->shared->sdata_aggr); + second_aggr = &(f->shared->meta_aggr); + } /* end if */ + else { + first_aggr = &(f->shared->meta_aggr); + second_aggr = &(f->shared->sdata_aggr); + } /* end else */ + } /* end if */ else { - first_aggr = &(f->shared->meta_aggr); + first_aggr = &(f->shared->meta_aggr); second_aggr = &(f->shared->sdata_aggr); } /* end else */ - } /* end if */ - else { - first_aggr = &(f->shared->meta_aggr); - second_aggr = &(f->shared->sdata_aggr); - } /* end else */ - /* Release the unused portion of the metadata and "small data" blocks back - * to the free lists in the file. - */ - if(H5MF__aggr_reset(f, first_aggr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block") - if(H5MF__aggr_reset(f, second_aggr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block") + /* Release the unused portion of the metadata and "small data" blocks back + * to the free lists in the file. + */ + if (H5MF__aggr_reset(f, first_aggr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block") + if (H5MF__aggr_reset(f, second_aggr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_free_aggrs() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_can_shrink_eoa - * - * Purpose: Check if the remaining space in the aggregator is at EOA - * - * Return: Success: non-negative (TRUE/FALSE) - * Failure: negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -static htri_t -H5MF__aggr_can_shrink_eoa(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) -{ - haddr_t eoa = HADDR_UNDEF; /* EOA for the file */ - htri_t ret_value = FALSE; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF_free_aggrs() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_can_shrink_eoa + * + * Purpose: Check if the remaining space in the aggregator is at EOA + * + * Return: Success: non-negative (TRUE/FALSE) + * Failure: negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + static htri_t H5MF__aggr_can_shrink_eoa(H5F_t * f, H5FD_mem_t type, H5F_blk_aggr_t * aggr) + { + haddr_t eoa = HADDR_UNDEF; /* EOA for the file */ + htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - /* Sanity check */ - HDassert(f); - HDassert(aggr); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + /* Sanity check */ + HDassert(f); + HDassert(aggr); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - /* Get the EOA for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") + /* Get the EOA for the file */ + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "Unable to get eoa") - /* Check if the aggregator is at EOA */ - if(aggr->size > 0 && H5F_addr_defined(aggr->addr)) - ret_value = H5F_addr_eq(eoa, aggr->addr + aggr->size); + /* Check if the aggregator is at EOA */ + if (aggr->size > 0 && H5F_addr_defined(aggr->addr)) + ret_value = H5F_addr_eq(eoa, aggr->addr + aggr->size); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF__aggr_can_shrink_eoa() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF__aggr_free - * - * Purpose: Free the aggregator's space in the file. - * - * Note: Does _not_ put the space on a free list - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -static herr_t -H5MF__aggr_free(H5F_t *f, H5FD_mem_t type, H5F_blk_aggr_t *aggr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - HDassert(f->shared->lf); - HDassert(aggr); - HDassert(H5F_addr_defined(aggr->addr)); - HDassert(aggr->size > 0); - HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); - HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); - HDassert(f->shared->feature_flags & aggr->feature_flag); + FUNC_LEAVE_NOAPI(ret_value) + } /* H5MF__aggr_can_shrink_eoa() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggr_free + * + * Purpose: Free the aggregator's space in the file. + * + * Note: Does _not_ put the space on a free list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + static herr_t H5MF__aggr_free(H5F_t * f, H5FD_mem_t type, H5F_blk_aggr_t * aggr) + { + herr_t ret_value = SUCCEED; /* Return value */ - /* Free the remaining space at EOA in the aggregator */ - if(H5F__free(f, type, aggr->addr, aggr->size) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregation block") + FUNC_ENTER_STATIC - /* Reset the aggregator */ - aggr->tot_size = 0; - aggr->addr = HADDR_UNDEF; - aggr->size = 0; + /* Sanity check */ + HDassert(f); + HDassert(f->shared->lf); + HDassert(aggr); + HDassert(H5F_addr_defined(aggr->addr)); + HDassert(aggr->size > 0); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); + HDassert(aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA || + aggr->feature_flag == H5FD_FEAT_AGGREGATE_SMALLDATA); + HDassert(f->shared->feature_flags & aggr->feature_flag); + + /* Free the remaining space at EOA in the aggregator */ + if (H5F__free(f, type, aggr->addr, aggr->size) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free aggregation block") + + /* Reset the aggregator */ + aggr->tot_size = 0; + aggr->addr = HADDR_UNDEF; + aggr->size = 0; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MF__aggr_free() */ - - -/*------------------------------------------------------------------------- - * Function: H5MF_aggrs_try_shrink_eoa - * - * Purpose: Check the metadata & small block aggregators to see if - * EOA shrink is possible; if so, shrink each aggregator - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * - *------------------------------------------------------------------------- - */ -htri_t -H5MF_aggrs_try_shrink_eoa(H5F_t *f) -{ - htri_t ma_status; /* Whether the metadata aggregator can shrink the EOA */ - htri_t sda_status; /* Whether the small data aggregator can shrink the EOA */ - htri_t ret_value = FAIL; /* Return value */ + FUNC_LEAVE_NOAPI(ret_value) + } /* H5MF__aggr_free() */ + + /*------------------------------------------------------------------------- + * Function: H5MF__aggrs_try_shrink_eoa + * + * Purpose: Check the metadata & small block aggregators to see if + * EOA shrink is possible; if so, shrink each aggregator + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ + htri_t H5MF__aggrs_try_shrink_eoa(H5F_t * f) + { + htri_t ma_status; /* Whether the metadata aggregator can shrink the EOA */ + htri_t sda_status; /* Whether the small data aggregator can shrink the EOA */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE - /* Check args */ - HDassert(f); - HDassert(f->shared); + /* Check args */ + HDassert(f); + HDassert(f->shared); - if((ma_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") - if(ma_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if ((ma_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr))) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats") + if (ma_status > 0) + if (H5MF__aggr_free(f, H5FD_MEM_DEFAULT, &(f->shared->meta_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - if((sda_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") - if(sda_status > 0) - if(H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") + if ((sda_status = H5MF__aggr_can_shrink_eoa(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr))) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats") + if (sda_status > 0) + if (H5MF__aggr_free(f, H5FD_MEM_DRAW, &(f->shared->sdata_aggr)) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") - ret_value = (ma_status || sda_status); + ret_value = (ma_status || sda_status); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MF_aggrs_try_shrink_eoa() */ - + FUNC_LEAVE_NOAPI(ret_value) + } /* end H5MF__aggrs_try_shrink_eoa() */ diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index c4c418a59c4..7b89fd89c8a 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,43 +26,38 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ -#define H5MF_DEBUGGING /* Need access to file space debugging routines */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ +#define H5MF_DEBUGGING /* Need access to file space debugging routines */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 */ - int fwidth; /* Field width amount */ + H5FS_t *fspace; /* Free space manager */ + FILE * stream; /* Stream for output */ + int indent; /* Indention amount */ + int fwidth; /* Field width amount */ } H5MF_debug_iter_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -73,17 +68,14 @@ static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata); /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5MF__sects_debug_cb * @@ -99,9 +91,9 @@ 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_debug_iter_ud_t *udata = (H5MF_debug_iter_ud_t *)_udata; /* User data for callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -112,33 +104,30 @@ H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) HDassert(udata); /* Print generic section information */ + HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, "Section type:", + (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE + ? "simple" + : (sect->sect_info.type == H5MF_FSPACE_SECT_SMALL + ? "small" + : (sect->sect_info.type == H5MF_FSPACE_SECT_LARGE ? "large" : "unknown")))); + HDfprintf(udata->stream, "%*s%-*s %" PRIuHADDR "\n", udata->indent, "", udata->fwidth, + "Section address:", sect->sect_info.addr); + HDfprintf(udata->stream, "%*s%-*s %" PRIuHSIZE "\n", udata->indent, "", udata->fwidth, + "Section size:", sect->sect_info.size); + HDfprintf(udata->stream, "%*s%-*s %" PRIuHADDR "\n", udata->indent, "", udata->fwidth, + "End of section:", (haddr_t)((sect->sect_info.addr + sect->sect_info.size) - 1)); HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section type:", - (sect->sect_info.type == H5MF_FSPACE_SECT_SIMPLE ? "simple" : - (sect->sect_info.type == H5MF_FSPACE_SECT_SMALL ? "small" : - (sect->sect_info.type == H5MF_FSPACE_SECT_LARGE ? "large" : "unknown")))); - HDfprintf(udata->stream, "%*s%-*s %a\n", udata->indent, "", udata->fwidth, - "Section address:", - sect->sect_info.addr); - HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "Section size:", - sect->sect_info.size); - HDfprintf(udata->stream, "%*s%-*s %Hu\n", udata->indent, "", udata->fwidth, - "End of section:", - (haddr_t)((sect->sect_info.addr + sect->sect_info.size) - 1)); - HDfprintf(udata->stream, "%*s%-*s %s\n", udata->indent, "", udata->fwidth, - "Section state:", - (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); + "Section state:", (sect->sect_info.state == H5FS_SECT_LIVE ? "live" : "serialized")); /* Dump section-specific debugging information */ - if(H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < 0) + if (H5FS_sect_debug(udata->fspace, _sect, udata->stream, udata->indent + 3, MAX(0, udata->fwidth - 3)) < + 0) HGOTO_ERROR(H5E_RESOURCE, H5E_BADITER, FAIL, "can't dump section's debugging info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__sects_debug_cb() */ - /*------------------------------------------------------------------------- * Function: H5MF_sects_debug * @@ -155,7 +144,7 @@ herr_t H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth) { H5F_mem_page_t type; /* Memory type for iteration */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) @@ -167,14 +156,14 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth HDassert(indent >= 0); HDassert(fwidth >= 0); - for(type = H5F_MEM_PAGE_DEFAULT; type < H5F_MEM_PAGE_NTYPES; type++) - if(H5F_addr_eq(f->shared->fs_addr[type], fs_addr)) { - if(!f->shared->fs_man[type]) - if(H5MF__open_fstype(f, type) < 0) + for (type = H5F_MEM_PAGE_DEFAULT; type < H5F_MEM_PAGE_NTYPES; type++) + if (H5F_addr_eq(f->shared->fs_addr[type], fs_addr)) { + if (!f->shared->fs_man[type]) + if (H5MF__open_fstype(f, type) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't initialize file free space") - if(f->shared->fs_man[type]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[type]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[type]; @@ -183,11 +172,11 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth udata.fwidth = fwidth; /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF__sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[type], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") /* Close the free space information */ - if(H5FS_close(f, f->shared->fs_man[type]) < 0) + if (H5FS_close(f, f->shared->fs_man[type]) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") } /* end if */ break; @@ -198,7 +187,7 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth } /* H5MF_sects_debug() */ #ifdef H5MF_ALLOC_DEBUG_DUMP - + /*------------------------------------------------------------------------- * Function: H5MF__sects_dump * @@ -212,16 +201,16 @@ H5MF_sects_debug(H5F_t *f, haddr_t fs_addr, FILE *stream, int indent, int fwidth *------------------------------------------------------------------------- */ herr_t -H5MF_sects_dump(H5F_t *f, FILE *stream) +H5MF__sects_dump(H5F_t *f, FILE *stream) { - haddr_t eoa; /* End of allocated space in the file */ - int indent = 0; /* Amount to indent */ - int fwidth = 50; /* Field width */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t eoa; /* End of allocated space in the file */ + int indent = 0; /* Amount to indent */ + int fwidth = 50; /* Field width */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG, FAIL) + FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); + HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); #endif /* H5MF_ALLOC_DEBUG */ /* @@ -231,16 +220,16 @@ HDfprintf(stderr, "%s: Dumping file free space sections\n", FUNC); HDassert(stream); /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); + HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %" PRIuHADDR "\n", FUNC, eoa); #endif /* H5MF_ALLOC_DEBUG */ - if(H5F_PAGED_AGGR(f)) { /* File space paging */ - H5F_mem_page_t ptype; /* Memory type for iteration -- page fs */ + if (H5F_PAGED_AGGR(f)) { /* File space paging */ + H5F_mem_page_t ptype; /* Memory type for iteration -- page fs */ - for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { + for (ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { /* Print header for type */ HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)ptype); @@ -248,8 +237,8 @@ HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs_man[ptype]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[ptype]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[ptype]; @@ -258,51 +247,56 @@ HDfprintf(stderr, "%s: for type = H5FD_MEM_DEFAULT, eoa = %a\n", FUNC, eoa); udata.fwidth = MAX(0, fwidth - 6); /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[ptype], H5MF_sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[ptype], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") } /* end if */ else /* No sections of this type */ HDfprintf(stream, "%*s\n", indent + 6, ""); - } /* end for */ - } /* end if */ - else { /* not file space paging */ - H5FD_mem_t atype; /* Memory type for iteration -- aggr fs */ - haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ - hsize_t ma_size = 0; /* Size of "metadata aggregator" */ - haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ - hsize_t sda_size = 0; /* Size of "small data aggregator" */ + } /* end for */ + } /* end if */ + else { /* not file space paging */ + H5FD_mem_t atype; /* Memory type for iteration -- aggr fs */ + haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */ + hsize_t ma_size = 0; /* Size of "metadata aggregator" */ + haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */ + hsize_t sda_size = 0; /* Size of "small data aggregator" */ /* Retrieve metadata aggregator info, if available */ H5MF__aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); + HDfprintf(stderr, + "%s: ma_addr = %" PRIuHADDR ", ma_size = %" PRIuHSIZE ", end of ma = %" PRIuHADDR "\n", + FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ /* Retrieve 'small data' aggregator info, if available */ H5MF__aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size); #ifdef H5MF_ALLOC_DEBUG -HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); + HDfprintf(stderr, + "%s: sda_addr = %" PRIuHADDR ", sda_size = %" PRIuHSIZE ", end of sda = %" PRIuHADDR "\n", + FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1)); #endif /* H5MF_ALLOC_DEBUG */ /* Iterate over all the free space types that have managers and dump each free list's space */ - for(atype = H5FD_MEM_DEFAULT; atype < H5FD_MEM_NTYPES; atype++) { + for (atype = H5FD_MEM_DEFAULT; atype < H5FD_MEM_NTYPES; atype++) { /* Print header for type */ HDfprintf(stream, "%*sFile Free Space Info for type = %u:\n", indent, "", (unsigned)atype); /* Check for this type being mapped to another type */ - if(H5FD_MEM_DEFAULT == f->shared->fs_type_map[atype] || atype == f->shared->fs_type_map[atype]) { + if (H5FD_MEM_DEFAULT == f->shared->fs_type_map[atype] || atype == f->shared->fs_type_map[atype]) { /* Retrieve the 'eoa' for this file memory type */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, atype))) + if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, atype))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "eoa:", eoa); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(0, fwidth - 3), + "eoa:", eoa); /* Print header for sections */ HDfprintf(stream, "%*sSections:\n", indent + 3, ""); /* If there is a free space manager for this type, iterate over them */ - if(f->shared->fs_man[atype]) { - H5MF_debug_iter_ud_t udata; /* User data for callbacks */ + if (f->shared->fs_man[atype]) { + H5MF_debug_iter_ud_t udata; /* User data for callbacks */ /* Prepare user data for section iteration callback */ udata.fspace = f->shared->fs_man[atype]; @@ -311,20 +305,20 @@ HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, udata.fwidth = MAX(0, fwidth - 6); /* Iterate over all the free space sections */ - if(H5FS_sect_iterate(f, f->shared->fs_man[atype], H5MF_sects_debug_cb, &udata) < 0) + if (H5FS_sect_iterate(f, f->shared->fs_man[atype], H5MF__sects_debug_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_BADITER, FAIL, "can't iterate over heap's free space") - } /* end if */ + } /* end if */ else /* No sections of this type */ HDfprintf(stream, "%*s\n", indent + 6, ""); } /* end if */ else - HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", (unsigned)f->shared->fs_type_map[atype]); + HDfprintf(stream, "%*sMapped to type = %u\n", indent, "", + (unsigned)f->shared->fs_type_map[atype]); } /* end for */ - } /* end else */ + } /* end else */ done: -HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); + HDfprintf(stderr, "%s: Done dumping file free space sections\n", FUNC); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5MF__sects_dump() */ #endif /* H5MF_ALLOC_DEBUG_DUMP */ - diff --git a/src/H5MFmodule.h b/src/H5MFmodule.h index 6b3aba5f6e4..9726cec6559 100644 --- a/src/H5MFmodule.h +++ b/src/H5MFmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5MF package. Including this header means that the source file * is part of the H5MF package. */ -#ifndef _H5MFmodule_H -#define _H5MFmodule_H +#ifndef H5MFmodule_H +#define H5MFmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5MF_MODULE -#define H5_MY_PKG H5MF -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO - -#endif /* _H5MFmodule_H */ +#define H5_MY_PKG H5MF +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO +#endif /* H5MFmodule_H */ diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 3d4d5601b85..f34c73e1764 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,15 +23,14 @@ #error "Do not include this file outside the H5MF package!" #endif -#ifndef _H5MFpkg_H -#define _H5MFpkg_H +#ifndef H5MFpkg_H +#define H5MFpkg_H /* Get package's private header */ #include "H5MFprivate.h" /* Other private headers needed by this file */ -#include "H5FSprivate.h" /* File free space */ - +#include "H5FSprivate.h" /* File free space */ /**************************/ /* Package Private Macros */ @@ -51,32 +50,35 @@ /* Free-space section types for file */ /* (values stored in free space data structures in file) */ -#define H5MF_FSPACE_SECT_SIMPLE 0 /* For non-paged aggregation: section is a range of actual bytes in file */ -#define H5MF_FSPACE_SECT_SMALL 1 /* For paged aggregation: "small" meta/raw data section which is < fsp_size) */ -#define H5MF_FSPACE_SECT_LARGE 2 /* For paged aggregation: "large" Section which is >= fsp_size) */ +/* For non-paged aggregation: section is a range of actual bytes in file */ +#define H5MF_FSPACE_SECT_SIMPLE 0 +/* For paged aggregation: "small" meta/raw data section which is < fsp_size) */ +#define H5MF_FSPACE_SECT_SMALL 1 +/* For paged aggregation: "large" Section which is >= fsp_size) */ +#define H5MF_FSPACE_SECT_LARGE 2 /* Get section class type based on size */ -#define H5MF_SECT_CLASS_TYPE(F, S) \ - ((H5F_PAGED_AGGR(F)) ? \ - ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_LARGE : H5MF_FSPACE_SECT_SMALL) : H5MF_FSPACE_SECT_SIMPLE) +#define H5MF_SECT_CLASS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) \ + ? ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_LARGE : H5MF_FSPACE_SECT_SMALL) \ + : H5MF_FSPACE_SECT_SIMPLE) /* Get section class cls */ -#define H5MF_SECT_CLS_TYPE(F, S) \ - ((H5F_PAGED_AGGR(F)) ? \ - ((S >= (F)->shared->fs_page_size) ? \ - H5MF_FSPACE_SECT_CLS_LARGE : H5MF_FSPACE_SECT_CLS_SMALL) : H5MF_FSPACE_SECT_CLS_SIMPLE) +#define H5MF_SECT_CLS_TYPE(F, S) \ + ((H5F_PAGED_AGGR(F)) \ + ? ((S >= (F)->shared->fs_page_size) ? H5MF_FSPACE_SECT_CLS_LARGE : H5MF_FSPACE_SECT_CLS_SMALL) \ + : H5MF_FSPACE_SECT_CLS_SIMPLE) /* Calculate the mis-aligned fragment */ -#define H5MF_EOA_MISALIGN(F, E, A, FR) \ -{ \ - hsize_t m; \ - \ - if(H5F_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ - (FR) = (A) - m; \ - else \ - (FR) = 0; \ -} - +#define H5MF_EOA_MISALIGN(F, E, A, FR) \ + { \ + hsize_t m; \ + \ + if (H5F_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ + (FR) = (A)-m; \ + else \ + (FR) = 0; \ + } /****************************/ /* Package Private Typedefs */ @@ -84,21 +86,22 @@ /* File free space section info */ typedef struct H5MF_free_section_t { - H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ + H5FS_section_info_t sect_info; /* Free space section information (must be first in struct) */ #ifdef NOT_YET union { struct { - H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ - unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ + H5HF_indirect_t *parent; /* Indirect block parent for free section's direct block */ + unsigned par_entry; /* Entry of free section's direct block in parent indirect block */ } single; struct { - struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + struct H5HF_free_section_t *under; /* Pointer to indirect block underlying row section */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space manager */ + hbool_t checked_out; /* Flag to indicate that a row section is temporarily out of the free space + manager */ } row; struct { /* Holds either a pointer to an indirect block (if its "live") or @@ -108,23 +111,24 @@ typedef struct H5MF_free_section_t { * or not) */ union { - H5HF_indirect_t *iblock; /* Indirect block for free section */ - hsize_t iblock_off; /* Indirect block offset in "heap space" */ + H5HF_indirect_t *iblock; /* Indirect block for free section */ + hsize_t iblock_off; /* Indirect block offset in "heap space" */ } u; - unsigned row; /* Row for range of blocks */ - unsigned col; /* Column for range of blocks */ - unsigned num_entries; /* Number of entries covered */ + unsigned row; /* Row for range of blocks */ + unsigned col; /* Column for range of blocks */ + unsigned num_entries; /* Number of entries covered */ /* Fields that aren't stored */ - struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ - unsigned par_entry; /* Entry within parent indirect section */ - hsize_t span_size; /* Size of space tracked, in "heap space" */ - unsigned iblock_entries; /* Number of entries in indirect block where section is located */ - unsigned rc; /* Reference count of outstanding row & child indirect sections */ - unsigned dir_nrows; /* Number of direct rows in section */ - struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ - unsigned indir_nents; /* Number of indirect entries in section */ - struct H5HF_free_section_t **indir_ents; /* Array of pointers to outstanding child indirect sections */ + struct H5HF_free_section_t *parent; /* Pointer to "parent" indirect section */ + unsigned par_entry; /* Entry within parent indirect section */ + hsize_t span_size; /* Size of space tracked, in "heap space" */ + unsigned iblock_entries; /* Number of entries in indirect block where section is located */ + unsigned rc; /* Reference count of outstanding row & child indirect sections */ + unsigned dir_nrows; /* Number of direct rows in section */ + struct H5HF_free_section_t **dir_rows; /* Array of pointers to outstanding row sections */ + unsigned indir_nents; /* Number of indirect entries in section */ + struct H5HF_free_section_t * + *indir_ents; /* Array of pointers to outstanding child indirect sections */ } indirect; } u; #endif /* NOT_YET */ @@ -132,43 +136,41 @@ typedef struct H5MF_free_section_t { /* Type of "container shrink" operation to perform */ typedef enum { - H5MF_SHRINK_EOA, /* Section should shrink the EOA value */ - H5MF_SHRINK_AGGR_ABSORB_SECT, /* Section should merge into the aggregator block */ - H5MF_SHRINK_SECT_ABSORB_AGGR /* Aggregator block should merge into the section */ + H5MF_SHRINK_EOA, /* Section should shrink the EOA value */ + H5MF_SHRINK_AGGR_ABSORB_SECT, /* Section should merge into the aggregator block */ + H5MF_SHRINK_SECT_ABSORB_AGGR /* Aggregator block should merge into the section */ } H5MF_shrink_type_t; /* User data for free space manager section callbacks */ typedef struct H5MF_sect_ud_t { /* Down */ - 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 */ + 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 */ + H5MF_shrink_type_t shrink; /* Type of shrink operation to perform */ + 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; - hsize_t align_thres; /* Threshold for alignment */ - hsize_t alignment; /* Alignment */ + haddr_t * fs_addr; + H5FS_t ** fs_man; + hsize_t align_thres; /* Threshold for alignment */ + hsize_t alignment; /* Alignment */ } H5MF_fs_t; - /*****************************/ /* Package Private Variables */ /*****************************/ /* H5MF single section inherits serializable properties from H5FS_section_class_t */ -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; -H5_DLLVAR H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; - +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1]; +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1]; +H5_DLLVAR const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1]; /******************************/ /* Package Private Prototypes */ @@ -179,29 +181,30 @@ H5_DLL herr_t H5MF__open_fstype(H5F_t *f, H5F_mem_page_t type); H5_DLL herr_t H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type); H5_DLL htri_t H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, haddr_t *addr); H5_DLL herr_t H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_section_t *node); -H5_DLL herr_t H5MF__sects_dump(H5F_t *f, FILE *stream); -H5_DLL void H5MF__alloc_to_fs_type(H5F_t *f, H5FD_mem_t alloc_type, - hsize_t size, H5F_mem_page_t *fs_type); +H5_DLL void H5MF__alloc_to_fs_type(H5F_shared_t *f_sh, H5FD_mem_t alloc_type, hsize_t size, + H5F_mem_page_t *fs_type); /* 'simple/small/large' section routines */ -H5_DLL H5MF_free_section_t *H5MF__sect_new(unsigned ctype, haddr_t sect_off, - hsize_t sect_size); -H5_DLL herr_t H5MF__sect_free(H5FS_section_info_t *sect); - +H5_DLL H5MF_free_section_t *H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size); +H5_DLL herr_t H5MF__sect_free(H5FS_section_info_t *sect); /* Block aggregator routines */ -H5_DLL htri_t H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, - H5FD_mem_t type, haddr_t abs_blk_end, hsize_t extra_requested); +H5_DLL htri_t H5MF__aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t abs_blk_end, + hsize_t extra_requested); +H5_DLL htri_t H5MF__aggrs_try_shrink_eoa(H5F_t *f); H5_DLL htri_t H5MF__aggr_can_absorb(const H5F_t *f, const H5F_blk_aggr_t *aggr, - const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink); -H5_DLL herr_t H5MF__aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, - H5MF_free_section_t *sect, hbool_t allow_sect_absorb); -H5_DLL herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, - haddr_t *addr, hsize_t *size); + const H5MF_free_section_t *sect, H5MF_shrink_type_t *shrink); +H5_DLL herr_t H5MF__aggr_absorb(const H5F_t *f, H5F_blk_aggr_t *aggr, H5MF_free_section_t *sect, + hbool_t allow_sect_absorb); +H5_DLL herr_t H5MF__aggr_query(const H5F_t *f, const H5F_blk_aggr_t *aggr, haddr_t *addr, hsize_t *size); + +/* Debugging routines */ +#ifdef H5MF_ALLOC_DEBUG_DUMP +H5_DLL herr_t H5MF__sects_dump(H5F_t *f, FILE *stream); +#endif /* H5MF_ALLOC_DEBUG_DUMP */ /* Testing routines */ #ifdef H5MF_TESTING #endif /* H5MF_TESTING */ -#endif /* _H5MFpkg_H */ - +#endif /* H5MFpkg_H */ diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index f0b63cda037..292e85c5f88 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,34 +21,31 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5MFprivate_H -#define _H5MFprivate_H +#ifndef H5MFprivate_H +#define H5MFprivate_H /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File Drivers */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File Drivers */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* File space manager routines */ -H5_DLL herr_t H5MF_init_merge_flags(H5F_t *f); +H5_DLL herr_t H5MF_init_merge_flags(H5F_shared_t *f_sh); H5_DLL herr_t H5MF_get_freespace(H5F_t *f, hsize_t *tot_space, hsize_t *meta_size); H5_DLL herr_t H5MF_close(H5F_t *f); H5_DLL herr_t H5MF_try_close(H5F_t *f); @@ -56,21 +53,16 @@ H5_DLL herr_t H5MF_try_close(H5F_t *f); /* File space allocation routines */ H5_DLL haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size); H5_DLL haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size); -H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size); -H5_DLL herr_t H5MF_try_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size, hsize_t extra_requested); -H5_DLL htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, - hsize_t size); -H5_DLL ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, - H5F_sect_info_t *sect_info); +H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); +H5_DLL herr_t H5MF_try_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested); +H5_DLL htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size); +H5_DLL ssize_t H5MF_get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); /* File 'temporary' space allocation routines */ H5_DLL haddr_t H5MF_alloc_tmp(H5F_t *f, hsize_t size); /* 'block aggregator' routines */ H5_DLL herr_t H5MF_free_aggrs(H5F_t *f); -H5_DLL htri_t H5MF_aggrs_try_shrink_eoa(H5F_t *f); /* Free space manager settling routines */ H5_DLL herr_t H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled); @@ -86,9 +78,7 @@ H5_DLL herr_t H5MF_tidy_self_referential_fsm_hack(H5F_t *f); /* Debugging routines */ #ifdef H5MF_DEBUGGING -H5_DLL herr_t H5MF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, - int fwidth); +H5_DLL herr_t H5MF_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); #endif /* H5MF_DEBUGGING */ -#endif /* end _H5MFprivate_H */ - +#endif /* end H5MFprivate_H */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index 11df025cae5..bf5b88892cb 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,162 +23,145 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ - +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5MFmodule.h" /* This source code file is part of the H5MF module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5MFpkg.h" /* File memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5MFpkg.h" /* File memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* 'simple/small/large' section callbacks */ -static H5FS_section_info_t *H5MF__sect_deserialize(const H5FS_section_class_t *cls, - const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); -static herr_t H5MF__sect_valid(const H5FS_section_class_t *cls, - const H5FS_section_info_t *sect); -static H5FS_section_info_t *H5MF__sect_split(H5FS_section_info_t *sect, - hsize_t frag_size); - +static H5FS_section_info_t *H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, + haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags); +static herr_t H5MF__sect_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *sect); +static H5FS_section_info_t *H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size); /* 'simple' section callbacks */ -static htri_t H5MF__sect_simple_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, - void *udata); - +static htri_t H5MF__sect_simple_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *udata); +static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *udata); /* 'small' section callbacks */ static herr_t H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata); -static htri_t H5MF__sect_small_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_small_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_small_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_small_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); /* 'large' section callbacks */ -static htri_t H5MF__sect_large_can_merge(const H5FS_section_info_t *sect1, - const H5FS_section_info_t *sect2, void *udata); -static herr_t H5MF__sect_large_merge(H5FS_section_info_t **sect1, - H5FS_section_info_t *sect2, void *udata); -static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, - void *udata); -static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, - void *udata); +static htri_t H5MF__sect_large_can_merge(const H5FS_section_info_t *sect1, const H5FS_section_info_t *sect2, + void *udata); +static herr_t H5MF__sect_large_merge(H5FS_section_info_t **sect1, H5FS_section_info_t *sect2, void *udata); +static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *udata); +static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *udata); /*********************/ /* Package Variables */ /*********************/ /* Class info for "simple" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SIMPLE[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_SIMPLE, /* Section type */ - 0, /* Extra serialized size */ + H5MF_FSPACE_SECT_SIMPLE, /* Section type */ + 0, /* Extra serialized size */ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_simple_can_merge, /* Can sections merge? */ - H5MF__sect_simple_merge, /* Merge sections */ - H5MF__sect_simple_can_shrink, /* Can section shrink container?*/ - H5MF__sect_simple_shrink, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_simple_can_merge, /* Can sections merge? */ + H5MF__sect_simple_merge, /* Merge sections */ + H5MF__sect_simple_can_shrink, /* Can section shrink container?*/ + H5MF__sect_simple_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /* Class info for "small" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_SMALL[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_SMALL, /* Section type */ - 0, /* Extra serialized size */ - H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + H5MF_FSPACE_SECT_SMALL, /* Section type */ + 0, /* Extra serialized size */ + H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - H5MF__sect_small_add, /* Add section */ + H5MF__sect_small_add, /* Add section */ NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_small_can_merge, /* Can sections merge? */ - H5MF__sect_small_merge, /* Merge sections */ - NULL, /* Can section shrink container?*/ - NULL, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_small_can_merge, /* Can sections merge? */ + H5MF__sect_small_merge, /* Merge sections */ + NULL, /* Can section shrink container?*/ + NULL, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ NULL, /* Dump debugging for section */ }}; /* Class info for "large" free space sections */ -H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ +const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ /* Class variables */ - H5MF_FSPACE_SECT_LARGE, /* Section type */ - 0, /* Extra serialized size */ + H5MF_FSPACE_SECT_LARGE, /* Section type */ + 0, /* Extra serialized size */ H5FS_CLS_MERGE_SYM | H5FS_CLS_ADJUST_OK, /* Class flags */ - NULL, /* Class private info */ + NULL, /* Class private info */ /* Class methods */ - NULL, /* Initialize section class */ - NULL, /* Terminate section class */ + NULL, /* Initialize section class */ + NULL, /* Terminate section class */ /* Object methods */ - NULL, /* Add section */ - NULL, /* Serialize section */ - H5MF__sect_deserialize, /* Deserialize section */ - H5MF__sect_large_can_merge, /* Can sections merge? */ - H5MF__sect_large_merge, /* Merge sections */ - H5MF__sect_large_can_shrink, /* Can section shrink container?*/ - H5MF__sect_large_shrink, /* Shrink container w/section */ - H5MF__sect_free, /* Free section */ - H5MF__sect_valid, /* Check validity of section */ - H5MF__sect_split, /* Split section node for alignment */ - NULL, /* Dump debugging for section */ + NULL, /* Add section */ + NULL, /* Serialize section */ + H5MF__sect_deserialize, /* Deserialize section */ + H5MF__sect_large_can_merge, /* Can sections merge? */ + H5MF__sect_large_merge, /* Merge sections */ + H5MF__sect_large_can_shrink, /* Can section shrink container?*/ + H5MF__sect_large_shrink, /* Shrink container w/section */ + H5MF__sect_free, /* Free section */ + H5MF__sect_valid, /* Check validity of section */ + H5MF__sect_split, /* Split section node for alignment */ + NULL, /* Dump debugging for section */ }}; /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -190,7 +173,6 @@ H5FL_DEFINE(H5MF_free_section_t); * "simple/small/large" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_new * @@ -206,8 +188,8 @@ H5FL_DEFINE(H5MF_free_section_t); H5MF_free_section_t * H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) { - H5MF_free_section_t *sect; /* 'Simple' free space section to add */ - H5MF_free_section_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *sect; /* 'Simple' free space section to add */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -215,15 +197,16 @@ H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) HDassert(sect_size); /* Create free space section node */ - if(NULL == (sect = H5FL_MALLOC(H5MF_free_section_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct block free list section") + if (NULL == (sect = H5FL_MALLOC(H5MF_free_section_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for direct block free list section") /* Set the information passed in */ sect->sect_info.addr = sect_off; sect->sect_info.size = sect_size; /* Set the section's class & state */ - sect->sect_info.type = ctype; + sect->sect_info.type = ctype; sect->sect_info.state = H5FS_SECT_LIVE; /* Set return value */ @@ -233,7 +216,6 @@ H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__sect_new() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_free * @@ -250,7 +232,7 @@ H5MF__sect_new(unsigned ctype, haddr_t sect_off, hsize_t sect_size) herr_t H5MF__sect_free(H5FS_section_info_t *_sect) { - H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* File free section */ FUNC_ENTER_PACKAGE_NOERR @@ -261,9 +243,8 @@ H5MF__sect_free(H5FS_section_info_t *_sect) sect = H5FL_FREE(H5MF_free_section_t, sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF__sect_free() */ +} /* H5MF__sect_free() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_deserialize * @@ -278,12 +259,11 @@ H5MF__sect_free(H5FS_section_info_t *_sect) *------------------------------------------------------------------------- */ static H5FS_section_info_t * -H5MF__sect_deserialize(const H5FS_section_class_t *cls, - const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, - hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) +H5MF__sect_deserialize(const H5FS_section_class_t *cls, const uint8_t H5_ATTR_UNUSED *buf, haddr_t sect_addr, + hsize_t sect_size, unsigned H5_ATTR_UNUSED *des_flags) { - H5MF_free_section_t *sect; /* New section */ - H5FS_section_info_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *sect; /* New section */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -293,7 +273,7 @@ H5MF__sect_deserialize(const H5FS_section_class_t *cls, HDassert(sect_size); /* Create free space section for block */ - if(NULL == (sect = H5MF__sect_new(cls->type, sect_addr, sect_size))) + if (NULL == (sect = H5MF__sect_new(cls->type, sect_addr, sect_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set return value */ @@ -303,7 +283,6 @@ H5MF__sect_deserialize(const H5FS_section_class_t *cls, FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_valid * @@ -318,16 +297,15 @@ H5MF__sect_deserialize(const H5FS_section_class_t *cls, *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, - const H5FS_section_info_t +H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5FS_section_info_t #ifdef NDEBUG - H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* NDEBUG */ - *_sect) + *_sect) { #ifndef NDEBUG - const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ -#endif /* NDEBUG */ + const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ +#endif /* NDEBUG */ FUNC_ENTER_STATIC_NOERR @@ -335,8 +313,7 @@ H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, HDassert(sect); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MF__sect_valid() */ - +} /* H5MF__sect_valid() */ /*------------------------------------------------------------------------- * Function: H5MF__sect_split @@ -354,12 +331,12 @@ H5MF__sect_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, static H5FS_section_info_t * H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) { - H5MF_free_section_t *ret_value = NULL; /* Return value */ + H5MF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space for new section */ - if(NULL == (ret_value = H5MF__sect_new(sect->type, sect->addr, frag_size))) + if (NULL == (ret_value = H5MF__sect_new(sect->type, sect->addr, frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't initialize free space section") /* Set new section's info */ @@ -373,7 +350,7 @@ H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) /* * "simple" section callbacks */ - + /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_can_merge * @@ -390,19 +367,19 @@ H5MF__sect_split(H5FS_section_info_t *sect, hsize_t frag_size) *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - 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 */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ @@ -411,7 +388,6 @@ H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_merge * @@ -429,11 +405,11 @@ H5MF__sect_simple_can_merge(const H5FS_section_info_t *_sect1, */ static herr_t H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) + 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -448,14 +424,13 @@ H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_can_shrink * @@ -472,11 +447,11 @@ H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC @@ -486,18 +461,19 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) HDassert(udata->f); /* Retrieve the end of the file's address space */ - if(HADDR_UNDEF == (eoa = H5F_get_eoa(udata->f, udata->alloc_type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") + if (HADDR_UNDEF == (eoa = H5F_get_eoa(udata->f, udata->alloc_type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Compute address of end of section to check */ end = sect->sect_info.addr + sect->sect_info.size; /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa)) { + if (H5F_addr_eq(end, eoa)) { /* 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 {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, + sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -505,47 +481,51 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- } /* end if */ else { /* Shrinking can't occur if the 'eoa_shrink_only' flag is set and we're not shrinking the EOA */ - if(udata->allow_eoa_shrink_only) + if (udata->allow_eoa_shrink_only) HGOTO_DONE(FALSE) /* Check if this section is allowed to merge with metadata aggregation block */ - if(udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_METADATA) { - htri_t status; /* Status from aggregator adjoin */ + if (udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_METADATA) { + htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, &(udata->shrink))) < 0) + if ((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->meta_aggr), sect, + &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") - else if(status > 0) { + else if (status > 0) { /* 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, sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins metadata aggregator\n", FUNC, + sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ + } /* end if */ /* Check if this section is allowed to merge with small 'raw' aggregation block */ - if(udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_RAWDATA) { - htri_t status; /* Status from aggregator adjoin */ + if (udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_RAWDATA) { + htri_t status; /* Status from aggregator adjoin */ /* See if section can absorb the aggregator & vice versa */ - if((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, &(udata->shrink))) < 0) + if ((status = H5MF__aggr_can_absorb(udata->f, &(udata->f->shared->sdata_aggr), sect, + &(udata->shrink))) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "error merging section with aggregation block") - else if(status > 0) { + else if (status > 0) { /* 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 {%a, %Hu}, adjoins small data aggregator\n", FUNC, + sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Set return value */ ret_value = FALSE; @@ -554,7 +534,6 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_simple_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_simple_shrink * @@ -571,9 +550,9 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -583,12 +562,12 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(udata->f); /* Check for shrinking file */ - if(H5MF_SHRINK_EOA == udata->shrink) { + if (H5MF_SHRINK_EOA == udata->shrink) { /* Sanity check */ HDassert(H5F_INTENT(udata->f) & H5F_ACC_RDWR); /* Release section's space at EOA */ - if(H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) + if (H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr, (*sect)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") } /* end if */ else { @@ -596,14 +575,15 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) HDassert(udata->aggr); /* Absorb the section into the aggregator or vice versa */ - if(H5MF__aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't absorb section into aggregator or vice versa") + if (H5MF__aggr_absorb(udata->f, udata->aggr, *sect, udata->allow_sect_absorb) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, + "can't absorb section into aggregator or vice versa") } /* end else */ /* Check for freeing section */ - if(udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { + if (udata->shrink != H5MF_SHRINK_SECT_ABSORB_AGGR) { /* Free section */ - if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -618,7 +598,6 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) * "small" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_add * @@ -637,51 +616,52 @@ H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) 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 */ - haddr_t sect_end; - hsize_t rem, prem; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + haddr_t sect_end; + hsize_t rem, prem; + herr_t ret_value = SUCCEED; /* Return value */ 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 {%a, %Hu}\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 */ - if(udata->alloc_type == H5FD_MEM_DRAW || udata->alloc_type == H5FD_MEM_GHEAP) + if (udata->alloc_type == H5FD_MEM_DRAW || udata->alloc_type == H5FD_MEM_GHEAP) HGOTO_DONE(ret_value); sect_end = (*sect)->sect_info.addr + (*sect)->sect_info.size; - rem = sect_end % udata->f->shared->fs_page_size; - prem = udata->f->shared->fs_page_size - rem; + rem = sect_end % udata->f->shared->fs_page_size; + prem = udata->f->shared->fs_page_size - rem; /* Drop the section if it is at page end and its size is <= pgend threshold */ - if(!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && (*flags & H5FS_ADD_RETURNED_SPACE)) { - if(H5MF__sect_free((H5FS_section_info_t *)(*sect)) < 0) + if (!rem && (*sect)->sect_info.size <= H5F_PGEND_META_THRES(udata->f) && + (*flags & H5FS_ADD_RETURNED_SPACE)) { + if (H5MF__sect_free((H5FS_section_info_t *)(*sect)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect = NULL; *flags &= (unsigned)~H5FS_ADD_RETURNED_SPACE; *flags |= H5FS_PAGE_END_NO_ADD; #ifdef H5MF_ALLOC_DEBUG_MORE -HDfprintf(stderr, "%s: section is dropped\n", FUNC); + HDfprintf(stderr, "%s: section is dropped\n", FUNC); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ + } /* end if */ /* Adjust the section if it is not at page end but its size + prem is at page end */ - else - if(prem <= H5F_PGEND_META_THRES(udata->f)) { - (*sect)->sect_info.size += prem; + 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 {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, + (*sect)->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_small_add() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_can_merge * @@ -698,37 +678,36 @@ HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_inf *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void *_udata) +H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, void *_udata) { - 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); /* Check if second section adjoins first section */ ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); - if(ret_value > 0) + if (ret_value > 0) /* If they are on different pages, couldn't merge */ - if((sect1->sect_info.addr / udata->f->shared->fs_page_size) != (((sect2->sect_info.addr + sect2->sect_info.size - 1) / udata->f->shared->fs_page_size))) - ret_value = FALSE; + if ((sect1->sect_info.addr / udata->f->shared->fs_page_size) != + (((sect2->sect_info.addr + sect2->sect_info.size - 1) / udata->f->shared->fs_page_size))) + 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 = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_small_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_small_merge * @@ -746,13 +725,12 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -766,25 +744,25 @@ H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 /* Add second section's size to first section */ (*sect1)->sect_info.size += sect2->sect_info.size; - if((*sect1)->sect_info.size == udata->f->shared->fs_page_size) { - if(H5MF_xfree(udata->f, udata->alloc_type, (*sect1)->sect_info.addr, (*sect1)->sect_info.size) < 0) + if ((*sect1)->sect_info.size == udata->f->shared->fs_page_size) { + if (H5MF_xfree(udata->f, udata->alloc_type, (*sect1)->sect_info.addr, (*sect1)->sect_info.size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") /* Need to free possible metadata page in the PB cache */ /* This is in response to the data corruption bug from fheap.c with page buffering + page strategy */ /* Note: Large metadata page bypasses the PB cache */ /* Note: Update of raw data page (large or small sized) is handled by the PB cache */ - if(udata->f->shared->page_buf != NULL && udata->alloc_type != H5FD_MEM_DRAW) - if(H5PB_remove_entry(udata->f->shared, (*sect1)->sect_info.addr) < 0) + if (udata->f->shared->page_buf != NULL && udata->alloc_type != H5FD_MEM_DRAW) + if (H5PB_remove_entry(udata->f->shared, (*sect1)->sect_info.addr) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't free merged section") - if(H5MF__sect_free((H5FS_section_info_t *)(*sect1)) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)(*sect1)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") *sect1 = NULL; } /* end if */ /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: @@ -795,7 +773,6 @@ H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 * "Large" section callbacks */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_can_merge (same as H5MF__sect_simple_can_merge) * @@ -811,31 +788,30 @@ H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 *------------------------------------------------------------------------- */ static htri_t -H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, - const H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) +H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_info_t *_sect2, + void H5_ATTR_UNUSED *_udata) { - 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 */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments. */ HDassert(sect1); HDassert(sect2); - HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ + HDassert(sect1->sect_info.type == sect2->sect_info.type); /* Checks "MERGE_SYM" flag */ HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr)); 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 = %t\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_can_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_merge (same as H5MF__sect_simple_merge) * @@ -851,12 +827,11 @@ HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); *------------------------------------------------------------------------- */ static herr_t -H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, - void H5_ATTR_UNUSED *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -871,14 +846,13 @@ H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 (*sect1)->sect_info.size += sect2->sect_info.size; /* Get rid of second section */ - if(H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)sect2) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free section node") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_merge() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_can_shrink * @@ -894,11 +868,11 @@ H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_STATIC @@ -909,18 +883,19 @@ H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) HDassert(udata->f); /* Retrieve the end of the file's address space */ - if(HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) + if (HADDR_UNDEF == (eoa = H5FD_get_eoa(udata->f->shared->lf, udata->alloc_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* Compute address of end of section to check */ end = sect->sect_info.addr + sect->sect_info.size; /* Check if the section is exactly at the end of the allocated space in the file */ - if(H5F_addr_eq(end, eoa) && sect->sect_info.size >= udata->f->shared->fs_page_size) { + if (H5F_addr_eq(end, eoa) && sect->sect_info.size >= udata->f->shared->fs_page_size) { /* 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 {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, + sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -931,7 +906,6 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_can_shrink() */ - /*------------------------------------------------------------------------- * Function: H5MF__sect_large_shrink * @@ -947,10 +921,10 @@ HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect- 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 */ - hsize_t frag_size = 0; /* Fragment size */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hsize_t frag_size = 0; /* Fragment size */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -968,14 +942,15 @@ H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) /* Free full pages from EOA */ /* Retain partial page in the free-space manager so as to keep EOA at page boundary */ - if(H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr+frag_size, (*sect)->sect_info.size-frag_size) < 0) + if (H5F__free(udata->f, udata->alloc_type, (*sect)->sect_info.addr + frag_size, + (*sect)->sect_info.size - frag_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "driver free request failed") - if(frag_size) /* Adjust section size for the partial page */ + if (frag_size) /* Adjust section size for the partial page */ (*sect)->sect_info.size = frag_size; else { /* Free section */ - if(H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) + if (H5MF__sect_free((H5FS_section_info_t *)*sect) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") /* Mark section as freed, for free space manager */ @@ -985,4 +960,3 @@ H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__sect_large_shrink() */ - diff --git a/src/H5MM.c b/src/H5MM.c index efe955af483..b4447f61e77 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,81 +22,75 @@ *------------------------------------------------------------------------- */ - /****************/ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK -#define H5MM_SIG_SIZE 4 -#define H5MM_HEAD_GUARD_SIZE 8 -#define H5MM_TAIL_GUARD_SIZE 8 -#define H5MM_BLOCK_FROM_BUF(mem) ((H5MM_block_t *)((void *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE)))) +#define H5MM_SIG_SIZE 4 +#define H5MM_HEAD_GUARD_SIZE 8 +#define H5MM_TAIL_GUARD_SIZE 8 +#define H5MM_BLOCK_FROM_BUF(mem) \ + ((H5MM_block_t *)((void *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE)))) #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /******************/ /* Local Typedefs */ /******************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Memory allocation "block", wrapped around each allocation */ -struct H5MM_block_t; /* Forward declaration for typedef */ +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 */ - 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 */ + unsigned char + 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 { struct { - size_t size; /* Size of allocated block */ - hbool_t in_use; /* Whether the block is in use or is free */ + size_t size; /* Size of allocated block */ + hbool_t in_use; /* Whether the block is in use or is free */ } info; - double _align; /* Align following buffer (b) to double boundary (unused) */ + double _align; /* Align following buffer (b) to double boundary (unused) */ } u; - unsigned char b[]; /* Buffer for caller (includes header and footer) */ + unsigned char b[]; /* Buffer for caller (includes header and footer) */ } H5MM_block_t; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /********************/ /* Local Prototypes */ /********************/ -#if defined H5_MEMORY_ALLOC_SANITY_CHECK +#if defined H5_MEMORY_ALLOC_SANITY_CHECK static hbool_t H5MM__is_our_block(void *mem); -static void H5MM__sanity_check_block(const H5MM_block_t *block); -static void H5MM__sanity_check(void *mem); +static void H5MM__sanity_check_block(const H5MM_block_t *block); +static void H5MM__sanity_check(void *mem); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Constant strings for block signature, head & tail guards */ -static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; +static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; static const char H5MM_block_head_guard_s[H5MM_HEAD_GUARD_SIZE] = {'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F'}; static const char H5MM_block_tail_guard_s[H5MM_TAIL_GUARD_SIZE] = {'B', 'E', 'E', 'F', 'D', 'E', 'A', 'D'}; @@ -107,18 +101,17 @@ static hbool_t H5MM_init_s = FALSE; static H5MM_block_t H5MM_block_head_s; /* Statistics about block allocations */ -static unsigned long long H5MM_total_alloc_bytes_s = 0; -static size_t H5MM_curr_alloc_bytes_s = 0; -static size_t H5MM_peak_alloc_bytes_s = 0; -static size_t H5MM_max_block_size_s = 0; -static size_t H5MM_total_alloc_blocks_count_s = 0; -static size_t H5MM_curr_alloc_blocks_count_s = 0; -static size_t H5MM_peak_alloc_blocks_count_s = 0; +static unsigned long long H5MM_total_alloc_bytes_s = 0; +static size_t H5MM_curr_alloc_bytes_s = 0; +static size_t H5MM_peak_alloc_bytes_s = 0; +static size_t H5MM_max_block_size_s = 0; +static size_t H5MM_total_alloc_blocks_count_s = 0; +static size_t H5MM_curr_alloc_blocks_count_s = 0; +static size_t H5MM_peak_alloc_blocks_count_s = 0; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - #if defined H5_MEMORY_ALLOC_SANITY_CHECK - + /*------------------------------------------------------------------------- * Function: H5MM__is_our_block * @@ -138,10 +131,9 @@ H5MM__is_our_block(void *mem) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - return(0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); + return (0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); } - /*------------------------------------------------------------------------- * Function: H5MM__sanity_check_block * @@ -160,13 +152,13 @@ H5MM__sanity_check_block(const H5MM_block_t *block) HDassert(block->u.info.size > 0); HDassert(block->u.info.in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->u.info.size != SIZET_MAX) { + if (block->u.info.size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); - HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, + H5MM_TAIL_GUARD_SIZE)); } } - /*------------------------------------------------------------------------- * Function: H5MM__sanity_check * @@ -188,7 +180,6 @@ H5MM__sanity_check(void *mem) H5MM__sanity_check_block(block); } - /*------------------------------------------------------------------------- * Function: H5MM_sanity_check_all * @@ -207,13 +198,12 @@ H5MM_sanity_check_all(void) H5MM_block_t *curr = NULL; curr = H5MM_block_head_s.next; - while(curr != &H5MM_block_head_s) { + while (curr != &H5MM_block_head_s) { H5MM__sanity_check_block(curr); curr = curr->next; } /* end while */ } /* end H5MM_sanity_check_all() */ - /*------------------------------------------------------------------------- * Function: H5MM_final_sanity_check * @@ -237,13 +227,13 @@ H5MM_final_sanity_check(void) HDfprintf(stderr, "%s: H5MM_total_alloc_bytes_s = %llu\n", __func__, H5MM_total_alloc_bytes_s); HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %zu\n", __func__, H5MM_peak_alloc_bytes_s); HDfprintf(stderr, "%s: H5MM_max_block_size_s = %zu\n", __func__, H5MM_max_block_size_s); - HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, H5MM_total_alloc_blocks_count_s); + HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, + H5MM_total_alloc_blocks_count_s); HDfprintf(stderr, "%s: H5MM_peak_alloc_blocks_count_s = %zu\n", __func__, H5MM_peak_alloc_blocks_count_s); #endif /* H5MM_PRINT_MEMORY_STATS */ } #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - /*------------------------------------------------------------------------- * Function: H5MM_malloc * @@ -273,44 +263,45 @@ H5MM_malloc(size_t size) #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* Initialize block list head singleton */ - if(!H5MM_init_s) { + if (!H5MM_init_s) { H5MM_memcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); - H5MM_block_head_s.next = &H5MM_block_head_s; - H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.u.info.size = SIZET_MAX; + H5MM_block_head_s.next = &H5MM_block_head_s; + H5MM_block_head_s.prev = &H5MM_block_head_s; + H5MM_block_head_s.u.info.size = SIZET_MAX; H5MM_block_head_s.u.info.in_use = TRUE; H5MM_init_s = TRUE; - } /* end if */ + } /* end if */ #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(size) { + if (size) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK H5MM_block_t *block; - size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; + size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; - if(NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { + if (NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { /* Set up block */ H5MM_memcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE); - block->next = H5MM_block_head_s.next; + block->next = H5MM_block_head_s.next; H5MM_block_head_s.next = block; - block->next->prev = block; - block->prev = &H5MM_block_head_s; - block->u.info.size = size; - block->u.info.in_use = TRUE; + block->next->prev = block; + block->prev = &H5MM_block_head_s; + block->u.info.size = size; + block->u.info.in_use = TRUE; H5MM_memcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); - H5MM_memcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); + H5MM_memcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, + H5MM_TAIL_GUARD_SIZE); /* Update statistics */ H5MM_total_alloc_bytes_s += size; H5MM_curr_alloc_bytes_s += size; - if(H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) + if (H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) H5MM_peak_alloc_bytes_s = H5MM_curr_alloc_bytes_s; - if(size > H5MM_max_block_size_s) + if (size > H5MM_max_block_size_s) H5MM_max_block_size_s = size; H5MM_total_alloc_blocks_count_s++; H5MM_curr_alloc_blocks_count_s++; - if(H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) + if (H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) H5MM_peak_alloc_blocks_count_s = H5MM_curr_alloc_blocks_count_s; /* Set buffer to return */ @@ -318,17 +309,16 @@ H5MM_malloc(size_t size) } /* end if */ else ret_value = NULL; -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDmalloc(size); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ else ret_value = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_malloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_calloc * @@ -358,21 +348,20 @@ H5MM_calloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) { + if (size) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(NULL != (ret_value = H5MM_malloc(size))) + if (NULL != (ret_value = H5MM_malloc(size))) HDmemset(ret_value, 0, size); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDcalloc((size_t)1, size); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ else ret_value = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_calloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_realloc * @@ -403,16 +392,16 @@ H5MM_realloc(void *mem, size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(NULL == mem && 0 == size) + if (NULL == mem && 0 == size) /* Not defined in the standard, return NULL */ ret_value = NULL; else { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(size > 0) { - if(mem) { - if(H5MM__is_our_block(mem)) { - H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - size_t old_size = block->u.info.size; + if (size > 0) { + if (mem) { + if (H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + size_t old_size = block->u.info.size; H5MM__sanity_check(mem); @@ -428,19 +417,18 @@ H5MM_realloc(void *mem, size_t size) } else ret_value = H5MM_xfree(mem); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDrealloc(mem, size); /* Some platforms do not return NULL if size is zero. */ - if(0 == size) + if (0 == size) ret_value = NULL; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_realloc() */ - /*------------------------------------------------------------------------- * Function: H5MM_xstrdup * @@ -457,21 +445,26 @@ H5MM_realloc(void *mem, size_t size) char * H5MM_xstrdup(const char *s) { - char *ret_value = NULL; + char *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - if(s) { - if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if (s) { + if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); - } /* end if */ + } +#else + if (s) + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_xstrdup() */ - /*------------------------------------------------------------------------- * Function: H5MM_strdup * @@ -495,17 +488,21 @@ H5MM_strdup(const char *s) FUNC_ENTER_NOAPI(NULL) - if(!s) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string") - if(NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) + if (!s) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "NULL string not allowed") +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); +#else + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_strdup() */ - /*------------------------------------------------------------------------- * Function: H5MM_xfree * @@ -529,9 +526,9 @@ H5MM_xfree(void *mem) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(mem) { + if (mem) { #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(H5MM__is_our_block(mem)) { + if (H5MM__is_our_block(mem)) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); /* Run sanity checks on this block and its neighbors */ @@ -545,10 +542,10 @@ H5MM_xfree(void *mem) /* Reset block info */ HDmemset(block->sig, 0, H5MM_SIG_SIZE); - block->next->prev = block->prev; - block->prev->next = block->next; - block->next = NULL; - block->prev = NULL; + block->next->prev = block->prev; + block->prev->next = block->next; + block->next = NULL; + block->prev = NULL; block->u.info.in_use = FALSE; /* Free the block (finally!) */ @@ -556,15 +553,14 @@ H5MM_xfree(void *mem) } else HDfree(mem); -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ HDfree(mem); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree() */ - /*------------------------------------------------------------------------- * Function: H5MM_xfree_const * @@ -589,7 +585,6 @@ H5MM_xfree_const(const void *mem) FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree_const() */ - /*------------------------------------------------------------------------- * Function: H5MM_memcpy * @@ -625,7 +620,6 @@ H5MM_memcpy(void *dest, const void *src, size_t n) } /* end H5MM_memcpy() */ - /*------------------------------------------------------------------------- * Function: H5MM_get_alloc_stats * @@ -651,20 +645,19 @@ H5MM_get_alloc_stats(H5_alloc_stats_t *stats) FUNC_ENTER_NOAPI_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(stats) { - stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; - stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; - stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; - stats->max_block_size = H5MM_max_block_size_s; + if (stats) { + stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; + stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; + stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; + stats->max_block_size = H5MM_max_block_size_s; stats->total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; - stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; - stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; - } /* end if */ -#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(stats) + stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; + stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + } /* end if */ +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ + if (stats) HDmemset(stats, 0, sizeof(H5_alloc_stats_t)); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5MM_get_alloc_stats() */ - +} /* end H5MM_get_alloc_stats() */ diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index b6c1002de2f..bb846f408a8 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,8 +21,8 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5MMprivate_H -#define _H5MMprivate_H +#ifndef H5MMprivate_H +#define H5MMprivate_H #include "H5MMpublic.h" @@ -31,27 +31,26 @@ #if defined H5_MEMORY_ALLOC_SANITY_CHECK /*#define H5MM_PRINT_MEMORY_STATS */ -#define H5MM_free(Z) H5MM_xfree(Z) +#define H5MM_free(Z) H5MM_xfree(Z) #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ -#define H5MM_free(Z) HDfree(Z) +#define H5MM_free(Z) HDfree(Z) #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* * 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); -H5_DLL void H5MM_final_sanity_check(void); +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_sanity_check_all(void); +H5_DLL void H5MM_final_sanity_check(void); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ -#endif /* _H5MMprivate_H */ - +#endif /* H5MMprivate_H */ diff --git a/src/H5MMpublic.h b/src/H5MMpublic.h index faa30322bd5..70ac6445ea5 100644 --- a/src/H5MMpublic.h +++ b/src/H5MMpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,15 +22,20 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5MMpublic_H -#define _H5MMpublic_H +#ifndef H5MMpublic_H +#define H5MMpublic_H /* Public headers needed by this file */ #include "H5public.h" /* These typedefs are currently used for VL datatype allocation/freeing */ +//! typedef void *(*H5MM_allocate_t)(size_t size, void *alloc_info); +//! + +//! typedef void (*H5MM_free_t)(void *mem, void *free_info); +//! #ifdef __cplusplus extern "C" { @@ -39,5 +44,4 @@ extern "C" { #ifdef __cplusplus } #endif -#endif /* _H5MMpublic_H */ - +#endif /* H5MMpublic_H */ diff --git a/src/H5MP.c b/src/H5MP.c index e7736553996..474a99526d5 100644 --- a/src/H5MP.c +++ b/src/H5MP.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,36 +27,33 @@ *------------------------------------------------------------------------- */ -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ +#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 */ +#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) +#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) \ +#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 */ /********************************/ @@ -64,7 +61,6 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /********************/ /* Static Variables */ /********************/ @@ -72,8 +68,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Declare a free list to manage the H5MP_pool_t struct */ H5FL_DEFINE(H5MP_pool_t); - - /*------------------------------------------------------------------------- * Function: H5MP_create * @@ -89,40 +83,39 @@ H5FL_DEFINE(H5MP_pool_t); 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 */ + 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") + 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; + 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)); + 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") + 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) + 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 * @@ -138,9 +131,9 @@ H5MP_create(size_t page_size, unsigned flags) 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 */ + 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 @@ -149,31 +142,31 @@ H5MP__new_page(H5MP_pool_t *mp, size_t page_size) 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))) + 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))) + 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 = 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; + first_blk->prev = NULL; + first_blk->next = NULL; /* Insert into page list */ new_page->prev = NULL; new_page->next = mp->first; - if(mp->first) + if (mp->first) mp->first->prev = new_page; mp->first = new_page; @@ -188,7 +181,6 @@ H5MP__new_page(H5MP_pool_t *mp, size_t page_size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP__new_page() */ - /*------------------------------------------------------------------------- * Function: H5MP_malloc * @@ -202,12 +194,12 @@ H5MP__new_page(H5MP_pool_t *mp, size_t page_size) *------------------------------------------------------------------------- */ void * -H5MP_malloc (H5MP_pool_t *mp, size_t request) +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 */ + 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) @@ -219,26 +211,26 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) 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 */ + 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; + alloc_page = mp->first; pool_free_avail = mp->free_size; - while(alloc_page && pool_free_avail >= needed) { + 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 */ + 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; + 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) { + 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 */ + 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; @@ -247,7 +239,7 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) /* Go to next block */ alloc_free = alloc_free->next; } /* end while */ - } /* end if */ + } /* end if */ /* Decrement amount of potential space left */ pool_free_avail -= alloc_page->free_size; @@ -255,17 +247,17 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) /* Go to next page */ alloc_page = alloc_page->next; } /* end while */ - } /* end if */ + } /* end if */ { - size_t page_size; /* Size of page needed */ + 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; + 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))) + 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 */ @@ -280,24 +272,24 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) 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 */ + 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) + if (alloc_free->next) alloc_free->next->prev = new_free; - new_free->prev = alloc_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; + 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 { @@ -307,7 +299,7 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) /* Update page & pool's free size information */ alloc_page->free_size -= alloc_free->size; - if(alloc_page->free_blk == alloc_free) + if (alloc_page->free_blk == alloc_free) alloc_page->free_blk = alloc_free->next; mp->free_size -= alloc_free->size; @@ -318,7 +310,6 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_malloc() */ - /*------------------------------------------------------------------------- * Function: H5MP_free * @@ -336,9 +327,9 @@ H5MP_malloc (H5MP_pool_t *mp, size_t request) 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 */ + 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 @@ -347,7 +338,8 @@ H5MP_free(H5MP_pool_t *mp, void *spc) 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)))); + 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); @@ -359,51 +351,50 @@ H5MP_free(H5MP_pool_t *mp, void *spc) 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) { + if (spc_page != mp->first) { /* Remove page from list */ spc_page->prev->next = spc_page->next; - if(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; + spc_page->prev = NULL; + spc_page->next = mp->first; mp->first->prev = spc_page; - mp->first = 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 */ + 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) { + if (next_blk->is_free) { spc_blk->size += next_blk->size; spc_blk->next = next_blk->next; } /* end if */ - } /* 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 */ + 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) { + if (prev_blk->is_free) { prev_blk->size += spc_blk->size; prev_blk->next = spc_blk->next; } /* end if */ - } /* 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) + 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 * @@ -419,32 +410,32 @@ H5MP_free(H5MP_pool_t *mp, void *spc) herr_t H5MP_close(H5MP_pool_t *mp) { - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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) { + while (page) { next_page = page->next; /* Free the page appropriately */ - if(page->fac_alloc) + 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 */ + } /* end if */ /* Release page factory */ - if(mp->page_fac) - if(H5FL_fac_term(mp->page_fac) < 0) + 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: @@ -453,4 +444,3 @@ H5MP_close(H5MP_pool_t *mp) FUNC_LEAVE_NOAPI(ret_value) } /* end H5MP_close() */ - diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h index 19b137fdf1e..8e34598a20d 100644 --- a/src/H5MPmodule.h +++ b/src/H5MPmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5MP package. Including this header means that the source file * is part of the H5MP package. */ -#ifndef _H5MPmodule_H -#define _H5MPmodule_H +#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 */ +#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 index ee2eb345dbf..64c5293ff03 100644 --- a/src/H5MPpkg.h +++ b/src/H5MPpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,14 +23,14 @@ #error "Do not include this file outside the H5MP package!" #endif -#ifndef _H5MPpkg_H -#define _H5MPpkg_H +#ifndef H5MPpkg_H +#define H5MPpkg_H /* Get package's private header */ -#include "H5MPprivate.h" /* Memory Pools */ +#include "H5MPprivate.h" /* Memory Pools */ /* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Package Private Macros */ @@ -40,65 +40,60 @@ /* (Ideas from Apache APR :-) */ /* Default alignment necessary */ -#define H5MP_BLOCK_ALIGNMENT 8 +#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)) +#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 */ + 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 */ + 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 */ + 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 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 */ - +#endif /* H5MPpkg_H */ diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h index be97e5de8d3..2b066502018 100644 --- a/src/H5MPprivate.h +++ b/src/H5MPprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,24 +22,22 @@ *------------------------------------------------------------------------- */ -#ifndef _H5MPprivate_H -#define _H5MPprivate_H +#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) */ - +#define H5MP_FLG_DEFAULT 0 +#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */ /****************************/ /* Library Private Typedefs */ @@ -48,13 +46,12 @@ /* 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); +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 */ +#endif /* H5MPprivate_H */ diff --git a/src/H5MPtest.c b/src/H5MPtest.c index fa5b165b662..27e7bbe0541 100644 --- a/src/H5MPtest.c +++ b/src/H5MPtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,19 +17,18 @@ * 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*/ +#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 */ +#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 * @@ -59,7 +58,6 @@ H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_pool_free_size() */ - /*------------------------------------------------------------------------- * Function: H5MP_get_pool_first_page * @@ -89,7 +87,6 @@ H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_pool_first_page() */ - /*------------------------------------------------------------------------- * Function: H5MP_pool_is_free_size_correct * @@ -110,9 +107,9 @@ H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) 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 */ + 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 @@ -121,25 +118,25 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Iterate through pages, checking the free size & accumulating the * free space for all the pages */ - page = mp->first; + 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 */ + 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) + 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) + if (page_free != page->free_size) + HGOTO_DONE(FALSE) /* Increment the amount of free space in pool */ pool_free += page->free_size; @@ -150,14 +147,13 @@ H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) /* Check that the free space from the pages * corresponds to free space in pool */ - if(pool_free != mp->free_size) - HGOTO_DONE (FALSE) + 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 * @@ -187,7 +183,6 @@ H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_page_free_size() */ - /*------------------------------------------------------------------------- * Function: H5MP_get_page_next_page * @@ -216,4 +211,3 @@ H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5MP_get_page_next_page() */ - diff --git a/src/H5Mmodule.h b/src/H5Mmodule.h new file mode 100644 index 00000000000..3dae3e26682 --- /dev/null +++ b/src/H5Mmodule.h @@ -0,0 +1,74 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which define macros for the + * H5M package. Including this header means that the source file + * is part of the H5M package. + */ +#ifndef H5Mmodule_H +#define H5Mmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5M_MODULE +#define H5_MY_PKG H5M +#define H5_MY_PKG_ERR H5E_MAP +#define H5_MY_PKG_INIT YES + +/** + * \defgroup H5M H5M + * \brief Map Interface + * + * \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 + * feature. + * + * While the HDF5 data model is a flexible way to store data, some + * applications require a more general way to index information. HDF5 + * effectively uses key-value stores internally for a variety of + * purposes, but it does not expose a generic key-value store to the + * API. The Map APIs provide this capability to the HDF5 applications + * in the form of HDF5 map objects. These Map objects contain + * application-defined key-value stores, to which key-value pairs can + * be added, and from which values can be retrieved by key. + * + * HDF5 VOL connectors with support for map objects: + * - DAOS + * + * \par Example: + * \code + * hid_t file_id, fapl_id, map_id, vls_type_id; + * const char *names[2] = ["Alice", "Bob"]; + * uint64_t IDs[2] = [25385486, 34873275]; + * uint64_t val_out; + * + * + * + * vls_type_id = H5Tcopy(H5T_C_S1); + * H5Tset_size(vls_type_id, H5T_VARIABLE); + * file_id = H5Fcreate("file.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + * map_id = H5Mcreate(file_id, "map", vls_type_id, H5T_NATIVE_UINT64, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5Mput(map_id, vls_type_id, &names[0], H5T_NATIVE_UINT64, &IDs[0], H5P_DEFAULT); + * H5Mput(map_id, vls_type_id, &names[1], H5T_NATIVE_UINT64, &IDs[1], H5P_DEFAULT); + * H5Mget(map_id, vls_type_id, &names[0], H5T_NATIVE_UINT64, &val_out, H5P_DEFAULT); + * if(val_out != IDs[0]) + * ERROR; + * H5Mclose(map_id); + * H5Tclose(vls_type_id); + * H5Fclose(file_id); + * \endcode + * + */ + +#endif /* H5Dmodule_H */ diff --git a/src/H5Mpkg.h b/src/H5Mpkg.h new file mode 100644 index 00000000000..be6749b1853 --- /dev/null +++ b/src/H5Mpkg.h @@ -0,0 +1,47 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which are visible only within + * the H5M package. Source files outside the H5M package should + * include H5Mprivate.h instead. + */ +#if !(defined H5M_FRIEND || defined H5M_MODULE) +#error "Do not include this file outside the H5M package!" +#endif + +#ifndef H5Mpkg_H +#define H5Mpkg_H + +/* Get package's private header */ +#include "H5Mprivate.h" + +/* Other private headers needed by this file */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + +#endif /*H5Dpkg_H*/ diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h new file mode 100644 index 00000000000..1a2524e2425 --- /dev/null +++ b/src/H5Mprivate.h @@ -0,0 +1,78 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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 H5M module + */ +#ifndef H5Mprivate_H +#define H5Mprivate_H + +/* Include package's public header */ +#include "H5Mpublic.h" + +/* Private headers needed by this file */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/* + * Feature: Define H5M_DEBUG on the compiler command line if you want to + * debug maps. NDEBUG must not be defined in order for this + * to have any effect. + */ +#ifdef NDEBUG +#undef H5M_DEBUG +#endif + +/* ======== Map creation property names ======== */ + +/* ======== Map access property names ======== */ +#define H5M_ACS_KEY_PREFETCH_SIZE_NAME \ + "key_prefetch_size" /* Number of keys to prefetch during map iteration */ +#define H5M_ACS_KEY_ALLOC_SIZE_NAME \ + "key_alloc_size" /* Initial allocation size for keys prefetched during map iteration */ + +/* Default temporary buffer size */ +#define H5D_TEMP_BUF_SIZE (1024 * 1024) + +/* Default I/O vector size */ +#define H5D_IO_VECTOR_SIZE 1024 + +/* Default VL allocation & free info */ +#define H5D_VLEN_ALLOC NULL +#define H5D_VLEN_ALLOC_INFO NULL +#define H5D_VLEN_FREE NULL +#define H5D_VLEN_FREE_INFO NULL + +/* Default virtual dataset list size */ +#define H5D_VIRTUAL_DEF_LIST_SIZE 8 + +/****************************/ +/* Library Private Typedefs */ +/****************************/ +H5_DLL herr_t H5M_init(void); + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +#endif /* H5Mprivate_H */ diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h new file mode 100644 index 00000000000..f645bc9aacf --- /dev/null +++ b/src/H5Mpublic.h @@ -0,0 +1,456 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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 public declarations for the H5M module. + * + * NOTE: This is an experimental API. Everything in the H5M package + * is subject to revision in a future release. + */ +#ifndef H5Mpublic_H +#define H5Mpublic_H + +/* System headers needed by this file */ + +/* Public headers needed by this file */ +#include "H5public.h" +#include "H5Ipublic.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Macros defining operation IDs for map VOL callbacks (implemented using the + * "optional" VOL callback) */ +#define H5VL_MAP_CREATE 1 +#define H5VL_MAP_OPEN 2 +#define H5VL_MAP_GET_VAL 3 +#define H5VL_MAP_EXISTS 4 +#define H5VL_MAP_PUT 5 +#define H5VL_MAP_GET 6 +#define H5VL_MAP_SPECIFIC 7 +#define H5VL_MAP_OPTIONAL 8 +#define H5VL_MAP_CLOSE 9 + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* types for map GET callback */ +typedef enum H5VL_map_get_t { + H5VL_MAP_GET_MAPL, /* map access property list */ + H5VL_MAP_GET_MCPL, /* map creation property list */ + H5VL_MAP_GET_KEY_TYPE, /* key type */ + H5VL_MAP_GET_VAL_TYPE, /* value type */ + H5VL_MAP_GET_COUNT /* key count */ +} H5VL_map_get_t; + +/* types for map SPECIFIC callback */ +typedef enum H5VL_map_specific_t { + H5VL_MAP_ITER, /* H5Miterate */ + H5VL_MAP_DELETE /* H5Mdelete */ +} H5VL_map_specific_t; + +//! +/** + * Callback for H5Miterate() + */ +typedef herr_t (*H5M_iterate_t)(hid_t map_id, const void *key, void *op_data); +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + +/* The map API is only built when requested since there's no support in + * the native file format at this time. It's only supported in a few VOL + * connectors. + */ +#ifdef H5_HAVE_MAP_API + +/** + * \ingroup H5M + * + * \brief Creates a map object + * + * \fgdta_loc_id + * \param[in] name Map object name + * \type_id{key_type_id} + * \type_id{val_type_id} + * \lcpl_id + * \mcpl_id + * \mapl_id + * \returns \hid_t{map object} + * + * \details H5Mcreate() creates a new map object for storing key-value + * pairs. The in-file datatype for keys is defined by \p key_type_id + * and the in-file datatype for values is defined by \p val_type_id. \p + * loc_id specifies the location to create the the map object and \p + * name specifies the name of the link to the map object relative to + * \p loc_id. + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + * \ingroup H5M + * + * \brief + * + * \details + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + * \ingroup H5M + * + * \brief Opens a map object + * + * \fgdta_loc_id{loc_id} + * \param[in] name Map object name relative to \p loc_id + * \mapl_id + * \returns \hid_t{map object} + * + * \details H5Mopen() finds a map object specified by \p name under the location + * specified by \p loc_id. The map object should be close with + * H5Mclose() when the application is not longer interested in + * accessing it. + * + * \since 1.13.0 + * + */ +H5_DLL hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id); + +/** + * \ingroup H5M + * + * \brief Terminates access to a map object + * + * \map_id + * \returns \herr_t + * + * \details H5Mclose() closes access to a map object specified by \p map_id and + * releases resources used by it. + * + * It is illegal to subsequently use that same map identifier in calls + * to other map functions. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mclose(hid_t map_id); + +/** + * \ingroup H5M + * + * \brief Gets key datatype for a map object + * + * \map_id + * \returns \hid_t{datatype} + * + * \details H5Mget_key_type() retrieves key datatype as stored in the file for a + * map object specified by \p map_id and returns identifier for the + * datatype. + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5Mget_key_type(hid_t map_id); + +/** + * \ingroup H5M + * + * \brief Gets value datatype for a map object + * + * \map_id + * \returns \hid_t{datatype} + * + * \details H5Mget_val_type() retrieves value datatype as stored in the file for + * a map object specified by \p map_id and returns identifier for the + * datatype . + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5Mget_val_type(hid_t map_id); + +/** + * \ingroup H5M + * + * \brief Gets creation property list for a map object + * + * \map_id + * \returns \hid_t{map creation property list} + * + * \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 + * + */ +H5_DLL hid_t H5Mget_create_plist(hid_t map_id); + +/** + * \ingroup H5M + * + * \brief Gets access property list for a map object + * + * \map_id + * \returns \hid_t{map access property list} + * + * \details H5Mget_access_plist() returns an identifier for a copy of the access + * property list for a map object specified by \p map_id. + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5Mget_access_plist(hid_t map_id); + +/** + * \ingroup H5M + * + * \brief Retrieves the number of key-value pairs in a map object + * + * \map_id + * \param[out] count The number of key-value pairs stored in the map object + * \dxpl_id + * \returns \herr_t + * + * \details H5Mget_count() retrieves the number of key-value pairs stored in a + * map specified by map_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mget_count(hid_t map_id, hsize_t *count, hid_t dxpl_id); + +/** + * \ingroup H5M + * + * \brief Adds a key-value pair to a map object + * + * \map_id + * \type_id{key_mem_type_id} + * \param[in] key Pointer to key buffer + * \type_id{val_mem_type_id} + * \param[in] value Pointer to value buffer + * \dxpl_id + * \returns \herr_t + * + * \details H5Mput() adds a key-value pair to a map object specified by \p + * map_id, or updates the value for the specified key if one was set + * previously. + * + * \p key_mem_type_id and \p val_mem_type_id specify the datatypes for + * the provided key and value buffers, and if different from those used + * to create the map object, the key and value will be internally + * converted to the datatypes for the map object. + * + * Any further options can be specified through the property list + * \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mput(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, + const void *value, hid_t dxpl_id); + +/** + * \ingroup H5M + * + * \brief Retrieves a key-value pair from a map object + * + * \map_id + * \type_id{key_mem_type_id} + * \param[in] key Pointer to key buffer + * \type_id{val_mem_type_id} + * \param[out] value Pointer to value buffer + * \dxpl_id + * \returns \herr_t + * + * \details H5Mget() retrieves from a map object specified by \p map_id, the + * value associated with the provided key \p key. \p key_mem_type_id + * and \p val_mem_type_id specify the datatypes for the provided key + * and value buffers. If if the datatype specified by \p + * key_mem_type_id is different from that used to create the map object + * the key will be internally converted to the datatype for the map + * object for the query, and if the datatype specified by \p + * val_mem_type_id is different from that used to create the map object + * the returned value will be converted to have a datatype as specified + * by \p val_mem_type_id before the function returns. + * + * Any further options can be specified through the property list + * \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mget(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t val_mem_type_id, void *value, + hid_t dxpl_id); + +/** + * \ingroup H5M + * + * \brief Checks if provided key exists in a map object + * + * \map_id + * \type_id{key_mem_type_id} + * \param[in] key Pointer to key buffer + * \param[out] exists Pointer to a buffer to return the existence status + * \dxpl_id + * \returns \herr_t + * + * \details H5Mexists() checks if the provided key is stored in the map object + * specified by \p map_id. If \p key_mem_type_id is different from that + * used to create the map object the key will be internally converted + * to the datatype for the map object for the query. + * + * Any further options can be specified through the property list + * \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, hid_t dxpl_id); + +/** + * \ingroup H5M + * + * \brief Iterates over all key-value pairs in a map object + * + * \map_id + * \param[in,out] idx iteration index + * \type_id{key_mem_type_id} + * \param[in] op User-defined iterator function + * \op_data + * \dxpl_id + * \returns \herr_t + * + * \details H5Miterate() iterates over all key-value pairs stored in the map + * object specified by \p map_id, making the callback specified by \p + * op for each. The \p idx parameter is an in/out parameter that may be + * used to restart a previously interrupted iteration. At the start of + * iteration \p idx should be set to 0, and to restart iteration at the + * same location on a subsequent call to H5Miterate(), \p idx should be + * the same value as returned by the previous call. Iterate callback is + * defined as: + * \snippet this H5M_iterate_t_snip + * The \p key parameter is the buffer for the key for this iteration, + * converted to the datatype specified by \p key_mem_type_id. The \p + * op_data parameter is a simple pass through of the value passed to + * H5Miterate(), which can be used to store application-defined data for + * iteration. A negative return value from this function will cause + * H5Miterate() to issue an error, while a positive return value will + * cause H5Miterate() to stop iterating and return this value without + * issuing an error. A return value of zero allows iteration to continue. + * + * Any further options can be specified through the property list \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + * \ingroup H5M + * + * \brief Iterates over all key-value pairs in a map object + * + * \loc_id + * \param[in] map_name Map object name relative to the location specified by \p loc_id + * \param[in,out] idx Iteration index + * \type_id{key_mem_type_id} + * \param[in] op User-defined iterator function + * \op_data + * \dxpl_id + * \lapl_id + * \returns \herr_t + * + * \details H5Miterate_by_name() iterates over all key-value pairs stored in the + * map object specified by \p map_id, making the callback specified by + * \p op for each. The \p idx parameter is an in/out parameter that may + * be used to restart a previously interrupted iteration. At the start + * of iteration \p idx should be set to 0, and to restart iteration at + * the same location on a subsequent call to H5Miterate(), \p idx + * should be the same value as returned by the previous call. Iterate + * callback is defined as: + * \snippet this H5M_iterate_t_snip + * The\p key parameter is the buffer for the key for this iteration, + * converted to the datatype specified by \p key_mem_type_id. The \p + * op_data parameter is a simple pass through of the value passed to + * H5Miterate(), which can be used to store application-defined data + * for iteration. A negative return value from this function will cause + * H5Miterate() to issue an error, while a positive return value will cause + * H5Miterate() to stop iterating and return this value without issuing an + * error. A return value of zero allows iteration to continue. + * + * Any further options can be specified through the property list \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + * \ingroup H5M + * + * \brief Deletes a key-value pair from a map object + * + * \map_id + * \type_id{key_mem_type_id} + * \param[in] key Pointer to key buffer + * \dxpl_id + * \returns \herr_t + * + * \details H5Mdelete() deletes a key-value pair from the map object specified + * by \p map_id. \p key_mem_type_id specifies the datatype for the + * provided key buffer key, and if different from that used to create + * the map object, the key will be internally converted to the datatype + * for the map object. + * + * Any further options can be specified through the property list \p dxpl_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id); + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#endif /* H5_HAVE_MAP_API */ + +#ifdef __cplusplus +} +#endif + +#endif /* H5Mpublic_H */ diff --git a/src/H5O.c b/src/H5O.c index 699e22b30ae..72f9d420514 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,56 +24,49 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*------------------------------------------------------------------------- * Function: H5Oopen * @@ -89,47 +82,63 @@ * or H5Gclose, H5Tclose, or H5Dclose. * * Return: Success: An open object identifier + * * Failure: H5I_INVALID_HID * - * Programmer: James Laird - * July 14 2006 + * Programmer: James Laird + * July 14 2006 * *------------------------------------------------------------------------- */ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t opened_type; + void * opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Open the object */ - if((ret_value = H5O_open_name(&loc, name, TRUE)) < 0) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + /* Get an atom for the object */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ - /*------------------------------------------------------------------------- - * Function: H5Oopen_by_idx + * Function: H5Oopen_by_idx * - * Purpose: Opens an object within an HDF5 file, according to the offset + * Purpose: Opens an object within an HDF5 file, according to the offset * within an index. * * This function opens an object in the same way that H5Gopen, @@ -141,179 +150,217 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) * The opened object should be closed again with H5Oclose * or H5Gclose, H5Tclose, or H5Dclose. * - * Return: Success: An open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: An open object identifier + * Failure: H5I_INVALID_HID * - * Programmer: Quincey Koziol - * November 20 2006 + * Programmer: Quincey Koziol + * November 20 2006 * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Location of group */ - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5I_type_t opened_type; + void * opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the object */ - if((ret_value = H5O__open_by_idx(&loc, group_name, idx_type, order, n)) < 0) + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5Oopen_by_addr + * Function: H5Oopen_by_token * - * Purpose: Warning! This function is EXTREMELY DANGEROUS! - * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, - * and other VERY BAD THINGS! - * - * This function opens an object using its address within the - * HDF5 file, similar to an HDF5 hard link. The open object - * is identical to an object opened with H5Oopen() and should - * be closed with H5Oclose() or a type-specific closing - * function (such as H5Gclose() ). - * - * This function is very dangerous if called on an invalid - * address. For this reason, H5Oincr_refcount() should be - * used to prevent HDF5 from deleting any object that is - * referenced by address (e.g. by a user-defined link). - * H5Odecr_refcount() should be used when the object is - * no longer being referenced by address (e.g. when the UD link - * is deleted). - * - * The address of the HDF5 file on disk has no effect on - * H5Oopen_by_addr(), nor does the use of any unusual file - * drivers. The "address" is really the offset within the - * HDF5 file, and HDF5's file drivers will transparently - * map this to an address on disk for the filesystem. + * Purpose: Same as H5Oopen_by_addr, but uses VOL-independent tokens. * * Return: Success: An open object identifier * Failure: H5I_INVALID_HID * - * Programmer: James Laird - * July 14 2006 + * Programmer: Dana Robinson + * Winter 2019 * *------------------------------------------------------------------------- */ hid_t -H5Oopen_by_addr(hid_t loc_id, haddr_t addr) +H5Oopen_by_token(hid_t loc_id, H5O_token_t token) { - H5G_loc_t loc; /* Location within file */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + H5VL_loc_params_t loc_params; /* Location parameters */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) - H5TRACE2("i", "ia", loc_id, addr); + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "ik", loc_id, token); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no address supplied") + if (H5O_IS_TOKEN_UNDEF(token)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "can't open H5O_TOKEN_UNDEF") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &token; + loc_params.obj_type = vol_obj_type; /* Open the object */ - if((ret_value = H5O__open_by_addr(&loc, addr)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + + /* Register the object's ID */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oopen_by_addr() */ +} /* end H5Oopen_by_token() */ - /*------------------------------------------------------------------------- - * Function: H5Olink + * Function: H5Olink * - * Purpose: Creates a hard link from NEW_NAME to the object specified - * by OBJ_ID using properties defined in the Link Creation + * Purpose: Creates a hard link from NEW_NAME to the object specified + * by OBJ_ID using properties defined in the Link Creation * Property List LCPL. * - * This function should be used to link objects that have just + * This function should be used to link objects that have just * been created. * - * NEW_NAME is interpreted relative to - * NEW_LOC_ID, which is either a file ID or a - * group ID. + * NEW_NAME is interpreted relative to + * NEW_LOC_ID, which is either a file ID or a + * group ID. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Tuesday, December 13, 2005 * *------------------------------------------------------------------------- */ herr_t -H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, - hid_t lapl_id) +H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t new_loc; /* Location of group to link from */ - H5G_loc_t obj_loc; /* Location of object to link to */ - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(obj_id, &obj_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!new_name || !*new_name) + if (new_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "cannot use H5L_SAME_LOC when only one location is specified") + if (!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Avoid compiler warning on 32-bit machines */ #if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T - if(HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) + if (HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "name too long") #endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + if (lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Get the link creation property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(obj_id); + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + + if (H5L_SAME_LOC != obj_id) + /* get the location object */ + if (NULL == (vol_obj1 = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (H5L_SAME_LOC != new_loc_id) + /* get the location object */ + if (NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL connectors are the same */ + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "Objects are accessed through different VOL connectors and can't be linked") + + /* Construct a temporary VOL object */ + tmp_vol_obj.data = vol_obj2->data; + tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); + /* Create a link to the object */ - if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id) < 0) + if (H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, vol_obj1->data, &loc_params1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) } /* end H5Olink() */ - /*------------------------------------------------------------------------- - * Function: H5Oincr_refcount + * Function: H5Oincr_refcount * - * Purpose: Warning! This function is EXTREMELY DANGEROUS! + * Purpose: Warning! This function is EXTREMELY DANGEROUS! * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, * and other VERY BAD THINGS! * @@ -322,44 +369,48 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, * that references an object by address is created. When the * link is deleted, H5Odecr_refcount should be used. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: James Laird - * July 14 2006 + * Programmer: James Laird + * July 14 2006 * *------------------------------------------------------------------------- */ herr_t H5Oincr_refcount(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + /* Get the location object */ - if((oloc = H5O_get_loc(object_id)) == NULL) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(object_id) < 0) + if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5O_link(oloc, 1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) } /* end H5O_incr_refcount() */ - /*------------------------------------------------------------------------- - * Function: H5Odecr_refcount + * Function: H5Odecr_refcount * - * Purpose: Warning! This function is EXTREMELY DANGEROUS! + * Purpose: Warning! This function is EXTREMELY DANGEROUS! * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, * and other VERY BAD THINGS! * @@ -368,223 +419,421 @@ H5Oincr_refcount(hid_t object_id) * that reference an object by address are deleted, and only * after H5Oincr_refcount has already been used. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: James Laird - * July 14 2006 + * Programmer: James Laird + * July 14 2006 * *------------------------------------------------------------------------- */ herr_t H5Odecr_refcount(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + /* Get the location object */ - if((oloc = H5O_get_loc(object_id)) == NULL) + if (NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(object_id) < 0) + if (H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5O_link(oloc, -1) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Odecr_refcount() */ - /*------------------------------------------------------------------------- * Function: H5Oexists_by_name * * Purpose: Determine if a linked-to object exists * * Return: Success: TRUE/FALSE - * Failure: Negative + * Failure: FAIL * - * Programmer: Quincey Koziol - * February 2 2010 + * Programmer: Quincey Koziol + * February 2 2010 * *------------------------------------------------------------------------- */ htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Location info */ - htri_t ret_value = FAIL; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set the location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Check if the object exists */ - if((ret_value = H5G_loc_exists(&loc, name)) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_EXISTS, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oexists_by_name() */ - /*------------------------------------------------------------------------- - * Function: H5Oget_info2 + * Function: H5Oget_info3 * * Purpose: Retrieve information about an object. * - * NOTE: Add a parameter "fields" to indicate selection of object info. + * Return: SUCCEED/FAIL * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Neil Fortner - * July 7 2010 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) +H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_INFO_ALL) + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo/*out*/, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info2() */ +} /* end H5Oget_info3() */ - /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_name2 + * Function: H5Oget_info_by_name3 * * Purpose: Retrieve information about an object * - * NOTE: Adds a parameter "fields" to indicate selection of object info. + * Return: SUCCEED/FAIL * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Neil Fortner - * July 7 2010 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!oinfo) + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_name3() */ + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_idx3 + * + * Purpose: Retrieve information about an object, according to + * the order of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); + + /* Check args */ + if (!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_name2() */ +} /* end H5Oget_info_by_idx3() */ - /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_idx2 + * Function: H5Oget_native_info * - * Purpose: Retrieve information about an object, according to the order - * of an index. + * Purpose: Retrieve native file format information about an object. * - * NOTE: Add a parameter "fields" to indicate selection of object info. + * Return: SUCCEED/FAIL * - * Return: Success: Non-negative - * Failure: Negative + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); + + /* Check args */ + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_NATIVE_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_native_info() */ + +/*------------------------------------------------------------------------- + * Function: H5Oget_native_info_by_name + * + * Purpose: Retrieve native file format information about an object + * + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * November 26 2006 + * Programmer: Dana Robinson + * Fall 2019 * *------------------------------------------------------------------------- */ 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_info_t *oinfo, unsigned fields, hid_t lapl_id) +H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, unsigned fields, + hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, - fields, lapl_id); + H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_NATIVE_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object: '%s'", name) + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_native_info_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5Oget_native_info_by_idx + * + * Purpose: Retrieve native file format information about an object, + * according to the order of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Dana Robinson + * Fall 2019 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); + + /* Check args */ + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_NATIVE_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native file format info for object") done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_idx2() */ +} /* end H5Oget_native_info_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5Oset_comment * @@ -595,39 +844,44 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, * * Note: Deprecated in favor of using attributes on objects * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * August 30 2007 + * Programmer: Quincey Koziol + * August 30 2007 * *------------------------------------------------------------------------- */ herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); /* Get the location object */ - if(H5G_loc(obj_id, &loc) < 0) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(obj_id) < 0) + if (H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oset_comment() */ - /*------------------------------------------------------------------------- * Function: H5Oset_comment_by_name * @@ -638,42 +892,50 @@ H5Oset_comment(hid_t obj_id, const char *comment) * * Note: Deprecated in favor of using attributes on objects * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * August 30 2007 + * Programmer: Quincey Koziol + * August 30 2007 * *------------------------------------------------------------------------- */ herr_t -H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, - hid_t lapl_id) +H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, name, comment) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_SET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oset_comment_by_name() */ - /*------------------------------------------------------------------------- * Function: H5Oget_comment * @@ -685,33 +947,38 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, * * Failure: -1 * - * Programmer: Quincey Koziol - * August 30 2007 + * Programmer: Quincey Koziol + * August 30 2007 * *------------------------------------------------------------------------- */ ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5G_loc_t loc; /* Location of group */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") + /* Get the object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Set fields in the location struct */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment() */ - /*------------------------------------------------------------------------- * Function: H5Oget_comment_by_name * @@ -723,42 +990,50 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) * * Failure: -1 * - * Programmer: Quincey Koziol - * August 30 2007 + * Programmer: Quincey Koziol + * August 30 2007 * *------------------------------------------------------------------------- */ ssize_t -H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, - hid_t lapl_id) +H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - ssize_t ret_value = -1; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, (-1), "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize)) < 0) + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_COMMENT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment_by_name() */ - /*------------------------------------------------------------------------- - * Function: H5Ovisit2 + * Function: H5Ovisit3 * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -787,41 +1062,52 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf * library, or the negative value returned by one * of the operators. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * November 25 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data, unsigned fields) +H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, + unsigned fields) { - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Visit the objects */ - if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit2() */ +} /* end H5Ovisit3() */ - /*------------------------------------------------------------------------- - * Function: H5Ovisit_by_name2 + * Function: H5Ovisit_by_name3 * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -850,48 +1136,60 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, * library, or the negative value returned by one * of the operators. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * November 24 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields, hid_t lapl_id) +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) { - herr_t ret_value; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, - fields, lapl_id); + H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); /* Check args */ - if(!obj_name) + if (!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") - if(!*obj_name) + if (!*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(fields & ~H5O_INFO_ALL) + if (fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location 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; + loc_params.obj_type = H5I_get_type(loc_id); + /* Visit the objects */ - if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data, fields)) < 0) + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit_by_name2() */ +} /* end H5Ovisit_by_name3() */ - /*------------------------------------------------------------------------- * Function: H5Oclose * @@ -902,30 +1200,30 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, * objects, such as property lists and dataspaces). It has * the same effect as calling H5Gclose, H5Dclose, or H5Tclose. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: James Laird - * July 14 2006 + * Programmer: James Laird + * July 14 2006 * *------------------------------------------------------------------------- */ herr_t H5Oclose(hid_t object_id) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); /* Get the type of the object and close it in the correct way */ - switch(H5I_get_type(object_id)) { + switch (H5I_get_type(object_id)) { case H5I_GROUP: case H5I_DATATYPE: case H5I_DATASET: - if(H5I_object(object_id) == NULL) + case H5I_MAP: + if (H5I_object(object_id) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") - if(H5I_dec_app_ref(object_id) < 0) + if (H5I_dec_app_ref(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") break; @@ -934,24 +1232,48 @@ H5Oclose(hid_t object_id) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: 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_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)") - break; + HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, + "not a valid file object ID (dataset, group, or datatype)") + break; } /* end switch */ done: FUNC_LEAVE_API(ret_value) } /* end H5Oclose() */ - +/*------------------------------------------------------------------------- + * Function: H5O_disable_mdc_flushes + * + * Purpose: Private version of the metadata cache cork function. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_disable_mdc_flushes(H5O_loc_t *oloc) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + if (H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O_disable_mdc_flushes() */ + /*------------------------------------------------------------------------- * Function: H5Odisable_mdc_flushes * @@ -969,68 +1291,62 @@ H5Oclose(hid_t object_id) herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); /* Cork the object */ - if(H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object") + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* H5Odisable_mdc_flushes() */ - /*------------------------------------------------------------------------- - * Function: H5Oenable_mdc_flushes - * - * Purpose: "Uncork" an object, allowing dirty entries associated with - * the object to be flushed. + * Function: H5O_enable_mdc_flushes * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Private version of the metadata cache uncork function. * - * Programmer: Vailin Choi - * January 2014 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5Oenable_mdc_flushes(hid_t object_id) +H5O_enable_mdc_flushes(H5O_loc_t *oloc) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", object_id); - - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + FUNC_ENTER_NOAPI(FAIL); - /* Set the value */ - if(H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") + if (H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: - FUNC_LEAVE_API(ret_value) -} /* H5Oenable_mdc_flushes() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O_enable_mdc_flushes() */ - /*------------------------------------------------------------------------- - * Function: H5Oare_mdc_flushes_disabled + * Function: H5Oenable_mdc_flushes * - * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled": - * TRUE if mdc flushes for the object is disabled - * FALSE if mdc flushes for the object is not disabled - * Return error if the parameter "are_disabled" is not supplied + * Purpose: "Uncork" an object, allowing dirty entries associated with + * the object to be flushed. * * Return: Success: Non-negative * Failure: Negative @@ -1041,292 +1357,227 @@ H5Oenable_mdc_flushes(hid_t object_id) *------------------------------------------------------------------------- */ herr_t -H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) +H5Oenable_mdc_flushes(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*b", object_id, are_disabled); + FUNC_ENTER_API(FAIL); + H5TRACE1("e", "i", object_id); - /* Check args */ + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") - if(!are_disabled) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); - /* Get the cork status */ - if(H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); -done: - FUNC_LEAVE_API(ret_value) -} /* H5Oare_mdc_flushes_disabled() */ + /* Uncork the object */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); -/* Future function prototypes to be deprecated in next major version - * see HDFFV-10552 -#ifndef H5_NO_DEPRECATED_SYMBOLS - */ +done: + FUNC_LEAVE_API(ret_value); +} /* H5Oenable_mdc_flushes() */ - /*------------------------------------------------------------------------- - * Function: H5Oget_info + * Function: H5O_are_mdc_flushes_disabled * - * Purpose: Retrieve information about an object. + * Purpose: Private version of cork status getter. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) +H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", loc_id, oinfo); + FUNC_ENTER_NOAPI(FAIL); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + HDassert(are_disabled); - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo/*out*/, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + if (H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); done: - FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O_are_mdc_flushes_disabled() */ - /*------------------------------------------------------------------------- - * Function: H5Oget_info_by_name + * Function: H5Oare_mdc_flushes_disabled * - * Purpose: Retrieve information about an object. + * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled": + * TRUE if mdc flushes for the object is disabled + * FALSE if mdc flushes for the object is not disabled + * + * Return error if the parameter "are_disabled" is not supplied * * Return: Success: Non-negative * Failure: Negative * + * Programmer: Vailin Choi + * January 2014 + * *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); + FUNC_ENTER_API(FAIL); + H5TRACE2("e", "i*b", object_id, are_disabled); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + /* Sanity check */ + if (!are_disabled) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID"); - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + + /* Get the cork status */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); done: FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_name() */ +} /* H5Oare_mdc_flushes_disabled() */ - -/*------------------------------------------------------------------------- - * Function: H5Oget_info_by_idx +/*--------------------------------------------------------------------------- + * Function: H5Otoken_cmp * - * Purpose: Retrieve information about an object, according to the order - * of an index. + * Purpose: Compares two VOL connector object tokens * - * Return: Success: Non-negative - * Failure: Negative + * Note: Both object tokens must be from the same VOL connector class * - * Programmer: Quincey Koziol - * November 26 2006 + * Return: Success: Non-negative, with *cmp_value set to positive if + * token1 is greater than token2, negative if token2 + * is greater than token1 and zero if token1 and + * token2 are equal. + * Failure: Negative * - *------------------------------------------------------------------------- + *--------------------------------------------------------------------------- */ herr_t -H5Oget_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_info_t *oinfo, hid_t lapl_id) +H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) { - H5G_loc_t loc; /* Location of group */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* VOL object for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, - lapl_id); + H5TRACE4("e", "i*k*k*Is", loc_id, token1, token2, cmp_value); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (NULL == cmp_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") - /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + /* Compare the two tokens */ + if (H5VL_token_cmp(vol_obj, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) -} /* end H5Oget_info_by_idx() */ +} /* end H5Otoken_cmp() */ - -/*------------------------------------------------------------------------- - * Function: H5Ovisit - * - * Purpose: Recursively visit an object and all the objects reachable - * from it. If the starting object is a group, all the objects - * linked to from that group will be visited. Links within - * each group are visited according to the order within the - * specified index (unless the specified index does not exist for - * a particular group, then the "name" index is used). - * - * NOTE: Soft links and user-defined links are ignored during - * this operation. +/*--------------------------------------------------------------------------- + * Function: H5Otoken_to_str * - * NOTE: Each _object_ reachable from the initial group will only - * be visited once. If multiple hard links point to the same - * object, the first link to the object's path (according to the - * iteration index and iteration order given) will be used to in - * the callback about the object. - * - * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. - * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * Purpose: Serialize a connector's object token into a string * - * Programmer: Quincey Koziol - * November 25 2007 + * Return: Success: Non-negative + * Failure: Negative * - *------------------------------------------------------------------------- + *--------------------------------------------------------------------------- */ herr_t -H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data) +H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str) { - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* VOL object for ID */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); + H5TRACE3("e", "i*k**s", loc_id, token, token_str); - /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if (NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") - /* Call internal object visitation routine */ - if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") + + /* Serialize the token */ + if (H5VL_token_to_str(vol_obj, vol_obj_type, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token serialization failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit() */ +} /* end H5Otoken_to_str() */ - -/*------------------------------------------------------------------------- - * Function: H5Ovisit_by_name +/*--------------------------------------------------------------------------- + * Function: H5Otoken_from_str * - * Purpose: Recursively visit an object and all the objects reachable - * from it. If the starting object is a group, all the objects - * linked to from that group will be visited. Links within - * each group are visited according to the order within the - * specified index (unless the specified index does not exist for - * a particular group, then the "name" index is used). - * - * NOTE: Soft links and user-defined links are ignored during - * this operation. - * - * NOTE: Each _object_ reachable from the initial group will only - * be visited once. If multiple hard links point to the same - * object, the first link to the object's path (according to the - * iteration index and iteration order given) will be used to in - * the callback about the object. - * - * 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. + * Purpose: Deserialize a string into a connector object token * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - * Programmer: Quincey Koziol - * November 24 2007 + * Return: Success: Non-negative + * Failure: Negative * - *------------------------------------------------------------------------- + *--------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) +H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token) { - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* VOL object for ID */ + H5I_type_t vol_obj_type; /* VOL object's type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, - lapl_id); + H5TRACE3("e", "i*s*k", loc_id, token_str, token); - /* Check args */ - if(!obj_name || !*obj_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if (NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if (NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token string pointer") - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object type") - /* Call internal object visitation routine */ - if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + /* Deserialize the token */ + if (H5VL_token_from_str(vol_obj, vol_obj_type, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token deserialization failed") done: FUNC_LEAVE_API(ret_value) -} /* end H5Ovisit_by_name() */ - -/* Future function prototypes to be deprecated in next major version - * see HDFFV-10552 -#endif (* H5_NO_DEPRECATED_SYMBOLS *) - */ - +} /* end H5Otoken_from_str() */ diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index e72051ab2e5..10c9edefb1d 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,72 +22,66 @@ *------------------------------------------------------------------------- */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_ainfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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, 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); -static herr_t H5O__ainfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +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, + 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); +static herr_t H5O__ainfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__ainfo_decode, /*decode message */ - H5O_ainfo_encode, /*encode message */ - H5O_ainfo_copy, /*copy the native value */ - H5O_ainfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__ainfo_free, /* free method */ - H5O__ainfo_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_ainfo_pre_copy_file, /* pre copy native value to file */ - H5O__ainfo_copy_file, /* copy native value to file */ - H5O__ainfo_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__ainfo_debug /*debug the message */ + H5O_AINFO_ID, /*message id number */ + "ainfo", /*message name for debugging */ + sizeof(H5O_ainfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__ainfo_decode, /*decode message */ + H5O__ainfo_encode, /*encode message */ + H5O__ainfo_copy, /*copy the native value */ + H5O__ainfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__ainfo_free, /* free method */ + H5O__ainfo_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O__ainfo_pre_copy_file, /* pre copy native value to file */ + H5O__ainfo_copy_file, /* copy native value to file */ + H5O__ainfo_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__ainfo_debug /*debug the message */ }}; /* Current version of attribute info information */ -#define H5O_AINFO_VERSION 0 +#define H5O_AINFO_VERSION 0 /* Flags for attribute info flag encoding */ -#define H5O_AINFO_TRACK_CORDER 0x01 -#define H5O_AINFO_INDEX_CORDER 0x02 -#define H5O_AINFO_ALL_FLAGS (H5O_AINFO_TRACK_CORDER | H5O_AINFO_INDEX_CORDER) +#define H5O_AINFO_TRACK_CORDER 0x01 +#define H5O_AINFO_INDEX_CORDER 0x02 +#define H5O_AINFO_ALL_FLAGS (H5O_AINFO_TRACK_CORDER | H5O_AINFO_INDEX_CORDER) /* Declare a free list to manage the H5O_ainfo_t struct */ H5FL_DEFINE_STATIC(H5O_ainfo_t); - /*------------------------------------------------------------------------- * Function: H5O__ainfo_decode * @@ -102,13 +96,12 @@ H5FL_DEFINE_STATIC(H5O_ainfo_t); *------------------------------------------------------------------------- */ 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_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 */ - unsigned char flags; /* Flags for encoding attribute info */ - void *ret_value = NULL; /* Return value */ + H5O_ainfo_t * ainfo = NULL; /* Attribute info */ + unsigned char flags; /* Flags for encoding attribute info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -117,16 +110,16 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_AINFO_VERSION) + if (*p++ != H5O_AINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (ainfo = H5FL_MALLOC(H5O_ainfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ainfo = H5FL_MALLOC(H5O_ainfo_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the message */ flags = *p++; - if(flags & ~H5O_AINFO_ALL_FLAGS) + if (flags & ~H5O_AINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") ainfo->track_corder = (flags & H5O_AINFO_TRACK_CORDER) ? TRUE : FALSE; ainfo->index_corder = (flags & H5O_AINFO_INDEX_CORDER) ? TRUE : FALSE; @@ -135,7 +128,7 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ainfo->nattrs = HSIZET_MAX; /* Max. creation order value for the object */ - if(ainfo->track_corder) + if (ainfo->track_corder) UINT16DECODE(p, ainfo->max_crt_idx) else ainfo->max_crt_idx = H5O_MAX_CRT_ORDER_IDX; @@ -147,7 +140,7 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, H5F_addr_decode(f, &p, &(ainfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ - if(ainfo->index_corder) + if (ainfo->index_corder) H5F_addr_decode(f, &p, &(ainfo->corder_bt2_addr)); else ainfo->corder_bt2_addr = HADDR_UNDEF; @@ -156,15 +149,14 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = ainfo; done: - if(ret_value == NULL && ainfo != NULL) + if (ret_value == NULL && ainfo != NULL) ainfo = H5FL_FREE(H5O_ainfo_t, ainfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__ainfo_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_ainfo_encode + * Function: H5O__ainfo_encode * * Purpose: Encodes a message. * @@ -176,12 +168,12 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - unsigned char flags; /* Flags for encoding attribute info */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + unsigned char flags; /* Flags for encoding attribute info */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -194,10 +186,10 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* The flags for the attribute indices */ flags = (unsigned char)(ainfo->track_corder ? H5O_AINFO_TRACK_CORDER : 0); flags = (unsigned char)(flags | (ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0)); - *p++ = flags; + *p++ = flags; /* Max. creation order value for the object */ - if(ainfo->track_corder) + if (ainfo->track_corder) UINT16ENCODE(p, ainfo->max_crt_idx); /* Address of fractal heap to store "dense" attributes */ @@ -207,17 +199,16 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co H5F_addr_encode(f, &p, ainfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of attributes, if they are indexed */ - if(ainfo->index_corder) + if (ainfo->index_corder) H5F_addr_encode(f, &p, ainfo->corder_bt2_addr); else HDassert(!H5F_addr_defined(ainfo->corder_bt2_addr)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_ainfo_encode() */ +} /* end H5O__ainfo_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_ainfo_copy + * Function: H5O__ainfo_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -231,18 +222,18 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co *------------------------------------------------------------------------- */ static void * -H5O_ainfo_copy(const void *_mesg, void *_dest) +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 */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + H5O_ainfo_t * dest = (H5O_ainfo_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(ainfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_ainfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_ainfo_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *ainfo; @@ -252,11 +243,10 @@ H5O_ainfo_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_ainfo_copy() */ +} /* end H5O__ainfo_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_ainfo_size + * Function: H5O__ainfo_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -271,25 +261,27 @@ H5O_ainfo_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_ainfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__ainfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)(1 /* Version */ - + 1 /* Index flags */ - + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ - + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ - + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ - + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ + ret_value = + (size_t)(1 /* Version */ + + 1 /* Index flags */ + + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ + + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ + + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ + + (ainfo->index_corder + ? H5F_SIZEOF_ADDR(f) + : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_ainfo_size() */ +} /* end H5O__ainfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_free * @@ -314,7 +306,6 @@ H5O__ainfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ainfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_delete * @@ -330,10 +321,10 @@ H5O__ainfo_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) +H5O__ainfo_delete(H5F_t *f, H5O_t H5_ATTR_NDEBUG_UNUSED *open_oh, void *_mesg) { - H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_ainfo_t *ainfo = (H5O_ainfo_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -343,18 +334,17 @@ H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) HDassert(open_oh); /* If the object is using "dense" attribute storage, delete it */ - if(H5F_addr_defined(ainfo->fheap_addr)) + if (H5F_addr_defined(ainfo->fheap_addr)) /* Delete the attribute */ - if(H5A__dense_delete(f, ainfo) < 0) + if (H5A__dense_delete(f, ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense attribute storage") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__ainfo_delete() */ - /*------------------------------------------------------------------------- - * Function: H5O_ainfo_pre_copy_file + * Function: H5O__ainfo_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files. @@ -368,10 +358,10 @@ H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, + hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(deleted); @@ -380,13 +370,12 @@ H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSE /* If we are not copying attributes into the destination file, indicate * that this message should be deleted. */ - if(cpy_info->copy_without_attr) + if (cpy_info->copy_without_attr) *deleted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_ainfo_pre_copy_file() */ +} /* end H5O__ainfo_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_copy_file * @@ -401,13 +390,13 @@ H5O_ainfo_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static void * -H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_t *file_dst, + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { 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 @@ -419,19 +408,19 @@ H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, HDassert(!cpy_info->copy_without_attr); /* Allocate space for the destination message */ - if(NULL == (ainfo_dst = H5FL_MALLOC(H5O_ainfo_t))) + if (NULL == (ainfo_dst = H5FL_MALLOC(H5O_ainfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the top level of the information */ *ainfo_dst = *ainfo_src; - if(H5F_addr_defined(ainfo_src->fheap_addr)) { + if (H5F_addr_defined(ainfo_src->fheap_addr)) { /* Prepare to copy dense attributes - actual copy in post_copy */ /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); - if(H5A__dense_create(file_dst, ainfo_dst) < 0) + if (H5A__dense_create(file_dst, ainfo_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ @@ -443,13 +432,12 @@ H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, done: /* Release destination attribute information on failure */ - if(!ret_value && ainfo_dst) + if (!ret_value && ainfo_dst) ainfo_dst = H5FL_FREE(H5O_ainfo_t, ainfo_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__ainfo_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_post_copy_file * @@ -467,26 +455,25 @@ H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, *------------------------------------------------------------------------- */ 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 H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { const H5O_ainfo_t *ainfo_src = (const H5O_ainfo_t *)mesg_src; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(ainfo_src); - if(H5F_addr_defined(ainfo_src->fheap_addr)) - if(H5A__dense_post_copy_file_all(src_oloc, ainfo_src, dst_oloc, (H5O_ainfo_t *)mesg_dst, cpy_info) < 0) + if (H5F_addr_defined(ainfo_src->fheap_addr)) + if (H5A__dense_post_copy_file_all(src_oloc, ainfo_src, dst_oloc, (H5O_ainfo_t *)mesg_dst, cpy_info) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__ainfo_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__ainfo_debug * @@ -500,10 +487,9 @@ H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *) _mesg; + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -514,22 +500,19 @@ H5O__ainfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of attributes:", ainfo->nattrs); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Track creation order of attributes:", ainfo->track_corder); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Index creation order of attributes:", ainfo->index_corder); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Number of attributes:", ainfo->nattrs); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Track creation order of attributes:", ainfo->track_corder ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index creation order of attributes:", ainfo->index_corder ? "TRUE" : "FALSE"); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. creation index value:", (unsigned)ainfo->max_crt_idx); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage fractal heap address:", ainfo->fheap_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage name index v2 B-tree address:", ainfo->name_bt2_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' attribute storage creation order index v2 B-tree address:", ainfo->corder_bt2_addr); - + "Max. creation index value:", (unsigned)ainfo->max_crt_idx); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' attribute storage fractal heap address:", ainfo->fheap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' attribute storage name index v2 B-tree address:", ainfo->name_bt2_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' attribute storage creation order index v2 B-tree address:", ainfo->corder_bt2_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ainfo_debug() */ - diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 9f024b8a63d..bad89ae51cb 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,58 +26,51 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, - hbool_t *chk_dirtied, size_t idx, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, - H5O_mesg_t *mesg, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, - const H5O_msg_class_t *new_type, void *new_native, size_t new_size); -static htri_t H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, - unsigned chunkno, size_t size, size_t *msg_idx); +static herr_t H5O__add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, size_t idx, + uint8_t *new_gap_loc, size_t new_gap_size); +static herr_t H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *new_gap_loc, + size_t new_gap_size); +static herr_t H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, + void *new_native, size_t new_size); +static htri_t H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size_t *msg_idx); static herr_t H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, - H5O_msg_alloc_info_t *found_msg); -static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, - size_t *new_idx); + H5O_msg_alloc_info_t *found_msg); +static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx); static herr_t H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx); -static htri_t H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u); -static htri_t H5O_move_msgs_forward(H5F_t *f, H5O_t *oh); -static htri_t H5O_merge_null(H5F_t *f, H5O_t *oh); -static htri_t H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh); +static htri_t H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u); +static htri_t H5O__move_msgs_forward(H5F_t *f, H5O_t *oh); +static htri_t H5O__merge_null(H5F_t *f, H5O_t *oh); +static htri_t H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh); static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno); - /*********************/ /* Package Variables */ /*********************/ @@ -85,20 +78,16 @@ static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno); /* Declare extern the free list for H5O_cont_t's */ H5FL_EXTERN(H5O_cont_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5O_add_gap + * Function: H5O__add_gap * * Purpose: Add a gap to a chunk * @@ -110,14 +99,14 @@ H5FL_EXTERN(H5O_cont_t); *------------------------------------------------------------------------- */ static herr_t -H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, - size_t idx, uint8_t *new_gap_loc, size_t new_gap_size) +H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, size_t idx, + uint8_t *new_gap_loc, size_t new_gap_size) { - hbool_t merged_with_null; /* Whether the gap was merged with a null message */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t merged_with_null; /* Whether the gap was merged with a null message */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -127,74 +116,75 @@ H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, HDassert(new_gap_size); #ifndef NDEBUG -if(chunkno > 0) { - unsigned chk_proxy_status = 0; /* Object header chunk proxy entry cache status */ + if (chunkno > 0) { + unsigned chk_proxy_status = 0; /* Object header chunk proxy entry cache status */ - /* Check the object header chunk proxy's status in the metadata cache */ - if(H5AC_get_entry_status(f, oh->chunk[chunkno].addr, &chk_proxy_status) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check metadata cache status for object header chunk proxy") + /* Check the object header chunk proxy's status in the metadata cache */ + if (H5AC_get_entry_status(f, oh->chunk[chunkno].addr, &chk_proxy_status) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, + "unable to check metadata cache status for object header chunk proxy") - /* Make certain that object header is protected */ - HDassert(chk_proxy_status & H5AC_ES__IS_PROTECTED); -} /* end if */ + /* Make certain that object header is protected */ + HDassert(chk_proxy_status & H5AC_ES__IS_PROTECTED); + } /* end if */ #endif /* NDEBUG */ /* Check for existing null message in chunk */ merged_with_null = FALSE; - for(u = 0; u < oh->nmesgs && !merged_with_null; u++) { + for (u = 0; u < oh->nmesgs && !merged_with_null; u++) { /* Find a null message in the chunk with the new gap */ /* (a null message that's not the one we are eliminating) */ - if(H5O_NULL_ID == oh->mesg[u].type->id && oh->mesg[u].chunkno == chunkno - && u != idx) { + if (H5O_NULL_ID == oh->mesg[u].type->id && oh->mesg[u].chunkno == chunkno && u != idx) { /* Sanity check - chunks with null messages shouldn't have a gap */ HDassert(oh->chunk[chunkno].gap == 0); /* Eliminate the gap in the chunk */ - if(H5O_eliminate_gap(oh, chk_dirtied, &oh->mesg[u], new_gap_loc, new_gap_size) < 0) + if (H5O__eliminate_gap(oh, chk_dirtied, &oh->mesg[u], new_gap_loc, new_gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't eliminate gap in chunk") /* Set flag to indicate that the gap was handled */ merged_with_null = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* If we couldn't find a null message in the chunk, move the gap to the end */ - if(!merged_with_null) { + if (!merged_with_null) { /* Adjust message offsets after new gap forward in chunk */ - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].chunkno == chunkno && oh->mesg[u].raw > new_gap_loc) + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].chunkno == chunkno && oh->mesg[u].raw > new_gap_loc) oh->mesg[u].raw -= new_gap_size; /* Slide raw message info forward in chunk image */ HDmemmove(new_gap_loc, new_gap_loc + new_gap_size, - (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - (new_gap_loc + new_gap_size))); + (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - + (new_gap_loc + new_gap_size))); /* Add existing gap size to new gap size */ new_gap_size += oh->chunk[chunkno].gap; /* Merging with existing gap will allow for a new null message */ - if(new_gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - H5O_mesg_t *null_msg; /* Pointer to new null message */ + if (new_gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Check if we need to extend message table to hold the new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O_alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Increment new gap size */ oh->chunk[chunkno].gap += new_gap_size; /* Create new null message, with the tail of the previous null message */ - null_msg = &(oh->mesg[oh->nmesgs++]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; + null_msg = &(oh->mesg[oh->nmesgs++]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; null_msg->raw_size = new_gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - null_msg->raw = (oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM_OH(oh) + null_msg->raw_size); + null_msg->raw = (oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + null_msg->raw_size); null_msg->chunkno = chunkno; /* Zero out new null message's raw data */ - if(null_msg->raw_size) + if (null_msg->raw_size) HDmemset(null_msg->raw, 0, null_msg->raw_size); /* Mark message as dirty */ @@ -212,11 +202,10 @@ if(chunkno > 0) { done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_add_gap() */ +} /* H5O__add_gap() */ - /*------------------------------------------------------------------------- - * Function: H5O_eliminate_gap + * Function: H5O__eliminate_gap * * Purpose: Eliminate a gap in a chunk with a null message. * @@ -235,13 +224,12 @@ if(chunkno > 0) { *------------------------------------------------------------------------- */ static herr_t -H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, - uint8_t *gap_loc, size_t gap_size) +H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *gap_loc, size_t gap_size) { - uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ - hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */ + uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ + hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(oh); @@ -255,37 +243,36 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, null_before_gap = (hbool_t)(mesg->raw < gap_loc); /* Set up information about region of messages to move */ - if(null_before_gap) { + if (null_before_gap) { move_start = mesg->raw + mesg->raw_size; - move_end = gap_loc; + move_end = gap_loc; } /* end if */ else { move_start = gap_loc + gap_size; - move_end = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + move_end = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); } /* end else */ /* Check for messages between null message and gap */ - if(move_end > move_start) { - unsigned u; /* Local index variable */ + if (move_end > move_start) { + unsigned u; /* Local index variable */ /* Look for messages that need to move, to adjust raw pointers in chunk */ /* (this doesn't change the moved messages 'dirty' state) */ - for(u = 0; u < oh->nmesgs; u++) { - uint8_t *msg_start; /* Start of encoded message in chunk */ + for (u = 0; u < oh->nmesgs; u++) { + uint8_t *msg_start; /* Start of encoded message in chunk */ msg_start = oh->mesg[u].raw - H5O_SIZEOF_MSGHDR_OH(oh); - if(oh->mesg[u].chunkno == mesg->chunkno - && (msg_start >= move_start && msg_start < move_end)) { + if (oh->mesg[u].chunkno == mesg->chunkno && (msg_start >= move_start && msg_start < move_end)) { /* Move message's raw pointer in appropriate direction */ - if(null_before_gap) + if (null_before_gap) oh->mesg[u].raw += gap_size; else oh->mesg[u].raw -= gap_size; } /* end if */ - } /* end for */ + } /* end for */ /* Slide raw message info in chunk image */ - if(null_before_gap) + if (null_before_gap) /* Slide messages down */ HDmemmove(move_start + gap_size, move_start, (size_t)(move_end - move_start)); else { @@ -296,12 +283,12 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, mesg->raw -= gap_size; } /* end else */ } - else if(move_end == move_start && !null_before_gap) { - /* Slide null message up */ - HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + else if (move_end == move_start && !null_before_gap) { + /* Slide null message up */ + HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); - /* Adjust start of null message */ - mesg->raw -= gap_size; + /* Adjust start of null message */ + mesg->raw -= gap_size; } /* end if */ /* Zero out addition to null message */ @@ -314,13 +301,12 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, oh->chunk[mesg->chunkno].gap = 0; /* Mark null message as dirty */ - mesg->dirty = TRUE; + mesg->dirty = TRUE; *chk_dirtied = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5O_eliminate_gap() */ +} /* H5O__eliminate_gap() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_null @@ -335,13 +321,13 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, *------------------------------------------------------------------------- */ static herr_t -H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, - const H5O_msg_class_t *new_type, void *new_native, size_t new_size) +H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, + size_t new_size) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -354,29 +340,31 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, alloc_msg = &oh->mesg[null_idx]; /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, alloc_msg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, alloc_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Check if there's a need to split the null message */ - if(alloc_msg->raw_size > new_size) { + if (alloc_msg->raw_size > new_size) { /* Check for producing a gap in the chunk */ - if((alloc_msg->raw_size - new_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - size_t gap_size = alloc_msg->raw_size - new_size; /* Size of gap produced */ + if ((alloc_msg->raw_size - new_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + size_t gap_size = alloc_msg->raw_size - new_size; /* Size of gap produced */ /* Adjust the size of the null message being eliminated */ alloc_msg->raw_size = new_size; /* Add the gap to the chunk */ - if(H5O_add_gap(f, oh, alloc_msg->chunkno, &chk_dirtied, null_idx, alloc_msg->raw + alloc_msg->raw_size, gap_size) < 0) + if (H5O__add_gap(f, oh, alloc_msg->chunkno, &chk_dirtied, null_idx, + alloc_msg->raw + alloc_msg->raw_size, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") } /* end if */ else { - size_t new_mesg_size = new_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Total size of newly allocated message */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + size_t new_mesg_size = + new_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Total size of newly allocated message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Check if we need to extend message table to hold the new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) { - if(H5O_alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) { + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* "Retarget" 'alloc_msg' pointer into newly re-allocated array of messages */ @@ -384,53 +372,53 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, } /* end if */ /* Create new null message, with the tail of the previous null message */ - null_msg = &(oh->mesg[oh->nmesgs++]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; - null_msg->raw = alloc_msg->raw + new_mesg_size; + null_msg = &(oh->mesg[oh->nmesgs++]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; + null_msg->raw = alloc_msg->raw + new_mesg_size; null_msg->raw_size = alloc_msg->raw_size - new_mesg_size; - null_msg->chunkno = alloc_msg->chunkno; + null_msg->chunkno = alloc_msg->chunkno; /* Mark the message as dirty */ null_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Check for gap in new null message's chunk */ - if(oh->chunk[null_msg->chunkno].gap > 0) { - unsigned null_chunkno = null_msg->chunkno; /* Chunk w/gap */ + if (oh->chunk[null_msg->chunkno].gap > 0) { + unsigned null_chunkno = null_msg->chunkno; /* Chunk w/gap */ /* Eliminate the gap in the chunk */ - if(H5O_eliminate_gap(oh, &chk_dirtied, null_msg, - ((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[null_chunkno].gap)), - oh->chunk[null_chunkno].gap) < 0) + if (H5O__eliminate_gap(oh, &chk_dirtied, null_msg, + ((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[null_chunkno].gap)), + oh->chunk[null_chunkno].gap) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") } /* end if */ /* Set the size of the new "real" message */ alloc_msg->raw_size = new_size; } /* end else */ - } /* end if */ + } /* end if */ /* Initialize the new message */ - alloc_msg->type = new_type; + alloc_msg->type = new_type; alloc_msg->native = new_native; /* Mark the new message as dirty */ alloc_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_null() */ - /*------------------------------------------------------------------------- * - * Function: H5O_alloc_msgs + * Function: H5O__alloc_msgs * * Purpose: Allocate more messages for a header * @@ -442,38 +430,37 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, *------------------------------------------------------------------------- */ herr_t -H5O_alloc_msgs(H5O_t *oh, size_t min_alloc) +H5O__alloc_msgs(H5O_t *oh, size_t min_alloc) { - size_t old_alloc; /* Old number of messages allocated */ - size_t na; /* New number of messages allocated */ - H5O_mesg_t *new_mesg; /* Pointer to new message array */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t old_alloc; /* Old number of messages allocated */ + size_t na; /* New number of messages allocated */ + H5O_mesg_t *new_mesg; /* Pointer to new message array */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* check args */ HDassert(oh); /* Initialize number of messages information */ old_alloc = oh->alloc_nmesgs; - na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ + na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ /* Attempt to allocate more memory */ - if(NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) + if (NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update ohdr information */ oh->alloc_nmesgs = na; - oh->mesg = new_mesg; + oh->mesg = new_mesg; /* Set new object header info to zeros */ HDmemset(&oh->mesg[old_alloc], 0, (oh->alloc_nmesgs - old_alloc) * sizeof(H5O_mesg_t)); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_alloc_msgs() */ +} /* H5O__alloc_msgs() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_extend_chunk @@ -503,23 +490,22 @@ H5O_alloc_msgs(H5O_t *oh, size_t min_alloc) *------------------------------------------------------------------------- */ static htri_t -H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, - size_t *msg_idx) +H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size_t *msg_idx) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - 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 */ - 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 */ - hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ - uint8_t new_size_flags = 0; /* New chunk #0 size flags */ - hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ - size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ - size_t u; /* Local index variable */ - htri_t ret_value = TRUE; /* return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + 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 */ + 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 */ + hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ + uint8_t new_size_flags = 0; /* New chunk #0 size flags */ + hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ + size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ + size_t u; /* Local index variable */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC @@ -534,22 +520,22 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, /* Test to see if the specified chunk ends with a null messages. * If successful, set the index of the the null message in extend_msg. */ - for(u = 0; u < oh->nmesgs; u++) { + for (u = 0; u < oh->nmesgs; u++) { /* Check for null message at end of proper chunk */ /* (account for possible checksum at end of chunk) */ - if(oh->mesg[u].chunkno == chunkno && H5O_NULL_ID == oh->mesg[u].type->id && - ((oh->mesg[u].raw + oh->mesg[u].raw_size) - == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { + if (oh->mesg[u].chunkno == chunkno && H5O_NULL_ID == oh->mesg[u].type->id && + ((oh->mesg[u].raw + oh->mesg[u].raw_size) == + ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { - extend_msg = u; + extend_msg = u; extended_msg = TRUE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we can extend an existing null message, adjust the delta appropriately */ - if(extended_msg) { + if (extended_msg) { HDassert(oh->chunk[chunkno].gap == 0); delta = aligned_size - oh->mesg[extend_msg].raw_size; } /* end if */ @@ -558,89 +544,90 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, delta = H5O_ALIGN_OH(oh, delta); /* Check for changing the chunk #0 data size enough to need adjusting the flags */ - if(oh->version > H5O_VERSION_1 && chunkno == 0) { - uint64_t chunk0_size; /* Size of chunk 0's data */ + if (oh->version > H5O_VERSION_1 && chunkno == 0) { + uint64_t chunk0_size; /* Size of chunk 0's data */ size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size */ HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); /* Check for moving to a 8-byte size encoding */ - if(orig_prfx_size < 8 && (chunk0_size + delta) > 4294967295) { - extra_prfx_size = 8 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_8; + if (orig_prfx_size < 8 && (chunk0_size + delta) > 4294967295) { + extra_prfx_size = 8 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_8; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 4-byte size encoding */ - else if(orig_prfx_size < 4 && (chunk0_size + delta) > 65535) { - extra_prfx_size = 4 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_4; + else if (orig_prfx_size < 4 && (chunk0_size + delta) > 65535) { + extra_prfx_size = 4 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_4; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 2-byte size encoding */ - else if(orig_prfx_size < 2 && (chunk0_size + delta) > 255) { - extra_prfx_size = 2 - orig_prfx_size; - new_size_flags = H5O_HDR_CHUNK0_2; + else if (orig_prfx_size < 2 && (chunk0_size + delta) > 255) { + extra_prfx_size = 2 - orig_prfx_size; + new_size_flags = H5O_HDR_CHUNK0_2; adjust_size_flags = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Determine whether the chunk can be extended */ - was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, oh->chunk[chunkno].addr, (hsize_t)(oh->chunk[chunkno].size), (hsize_t)(delta + extra_prfx_size)); - if(was_extended < 0) /* error */ + was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, oh->chunk[chunkno].addr, + (hsize_t)(oh->chunk[chunkno].size), (hsize_t)(delta + extra_prfx_size)); + if (was_extended < 0) /* error */ HGOTO_ERROR(H5E_OHDR, H5E_CANTEXTEND, FAIL, "can't tell if we can extend chunk") - else if(was_extended == FALSE) /* can't extend -- we are done */ + else if (was_extended == FALSE) /* can't extend -- we are done */ HGOTO_DONE(FALSE) /* Adjust object header prefix flags */ - if(adjust_size_flags) { + if (adjust_size_flags) { oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end if */ /* If we can extend an existing null message, take care of that */ - if(extended_msg) { + if (extended_msg) { /* Adjust message size of existing null message */ oh->mesg[extend_msg].raw_size += delta; } /* end if */ /* Create new null message for end of chunk */ else { /* Create a new null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O_alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Set extension message */ extend_msg = oh->nmesgs++; /* Initialize new null message */ - oh->mesg[extend_msg].type = H5O_MSG_NULL; + oh->mesg[extend_msg].type = H5O_MSG_NULL; oh->mesg[extend_msg].native = NULL; - oh->mesg[extend_msg].raw = ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[chunkno].gap)) - + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[extend_msg].raw = ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[chunkno].gap)) + + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[extend_msg].raw_size = (delta + oh->chunk[chunkno].gap) - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[extend_msg].chunkno = chunkno; + oh->mesg[extend_msg].chunkno = chunkno; } /* end else */ /* Mark the extended message as dirty */ oh->mesg[extend_msg].dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Allocate more memory space for chunk's image */ old_image = oh->chunk[chunkno].image; - old_size = oh->chunk[chunkno].size; + old_size = oh->chunk[chunkno].size; oh->chunk[chunkno].size += delta + extra_prfx_size; oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image, old_image, oh->chunk[chunkno].size); - if(NULL == oh->chunk[chunkno].image) + if (NULL == oh->chunk[chunkno].image) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't reallocate extended object header chunk") oh->chunk[chunkno].gap = 0; @@ -648,28 +635,28 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, HDmemset(oh->chunk[chunkno].image + old_size, 0, oh->chunk[chunkno].size - old_size); /* Move chunk 0 data up if the size flags changed */ - if(adjust_size_flags) + if (adjust_size_flags) HDmemmove(oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh), - oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, - old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); + oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, + old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); /* Spin through existing messages, adjusting them */ - for(u = 0; u < oh->nmesgs; u++) { + for (u = 0; u < oh->nmesgs; u++) { /* Adjust raw addresses for messages in this chunk to reflect new 'image' address */ - if(oh->mesg[u].chunkno == chunkno) + if (oh->mesg[u].chunkno == chunkno) oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); /* Find continuation message which points to this chunk and adjust chunk's size */ /* (Chunk 0 doesn't have a continuation message that points to it, * its size is directly encoded in the object header) */ - if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && - (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { - H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */ - hbool_t chk_dirtied2 = FALSE; /* Flag for unprotecting chunk */ - unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */ + if (chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && + (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { + H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */ + hbool_t chk_dirtied2 = FALSE; /* Flag for unprotecting chunk */ + unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */ /* Protect chunk containing continuation message */ - if(NULL == (chk_proxy2 = H5O__chunk_protect(f, oh, cont_chunkno))) + if (NULL == (chk_proxy2 = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Adjust size in continuation message */ @@ -678,16 +665,16 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, /* Flag continuation message as dirty */ oh->mesg[u].dirty = TRUE; - chk_dirtied2 = TRUE; + chk_dirtied2 = TRUE; /* Release chunk containing continuation message */ - if(H5O__chunk_unprotect(f, chk_proxy2, chk_dirtied2) < 0) + if (H5O__chunk_unprotect(f, chk_proxy2, chk_dirtied2) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end for */ + } /* end for */ /* Resize the chunk in the cache */ - if(H5O__chunk_resize(oh, chk_proxy) < 0) + if (H5O__chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") /* Set new message index */ @@ -695,13 +682,12 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_extend_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_find_best_nonnull * @@ -730,13 +716,12 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, *------------------------------------------------------------------------- */ static herr_t -H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, - H5O_msg_alloc_info_t *found_msg) +H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, H5O_msg_alloc_info_t *found_msg) { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - size_t cont_size; /* Continuation message size */ - size_t multi_size; /* Size of all the messages in the last chunk */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + size_t cont_size; /* Continuation message size */ + size_t multi_size; /* Size of all the messages in the last chunk */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -757,89 +742,92 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, * ordering (although ordering is *not* guaranteed!). * */ - cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); + cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); multi_size = 0; - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Don't consider continuation messages (for now) */ - if(H5O_CONT_ID != curr_msg->type->id) { - unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ - 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 */ - size_t gap_size = 0; /* Size of gap after current message */ - size_t null_size = 0; /* Size of NULL message after current message */ - unsigned null_msgno = 0; /* Index of NULL message after current message */ - size_t total_size; /* Total size of available space "around" current message */ + if (H5O_CONT_ID != curr_msg->type->id) { + unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ + 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 */ + size_t gap_size = 0; /* Size of gap after current message */ + size_t null_size = 0; /* Size of NULL message after current message */ + unsigned null_msgno = 0; /* Index of NULL message after current message */ + size_t total_size; /* Total size of available space "around" current message */ /* Check if the message is the last one in the chunk */ - if(end_msg == end_chunk_data) + if (end_msg == end_chunk_data) gap_size = oh->chunk[msg_chunkno].gap; else { - H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ - unsigned v; /* Local index variable */ + H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ + unsigned v; /* Local index variable */ /* Check for null message after this message, in same chunk */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(tmp_msg->type->id == H5O_NULL_ID && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (tmp_msg->type->id == H5O_NULL_ID && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { null_msgno = v; - null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; + null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; break; } /* end if */ /* XXX: Should also check for NULL message in front of current message... */ } /* end for */ - } /* end else */ + } /* end else */ /* Add up current message's total available space */ total_size = curr_msg->raw_size + gap_size + null_size; /* Check if message is large enough to hold continuation info */ - if(total_size >= cont_size) { - hbool_t better = FALSE; /* Whether the current message is better than a previous one */ + if (total_size >= cont_size) { + hbool_t better = FALSE; /* Whether the current message is better than a previous one */ /* Check for first message that can be moved */ - if(found_msg->msgno < 0) + if (found_msg->msgno < 0) better = TRUE; else { /* Prioritize moving non-attributes above attributes */ /* (Even attributes with an otherwise better fit */ - if(found_msg->id == H5O_ATTR_ID && curr_msg->type->id != H5O_ATTR_ID) + if (found_msg->id == H5O_ATTR_ID && curr_msg->type->id != H5O_ATTR_ID) better = TRUE; /* Either two attributes, or two non-attributes */ else { /* Take a smaller one */ - if(total_size < found_msg->total_size) + if (total_size < found_msg->total_size) better = TRUE; /* If they are the same size, choose the earliest one * in the chunk array */ /* (Could also bias toward message earlier / later * chunk in, but shouldn't be a big deal - QAK, 2016/10/21) */ - else if(total_size == found_msg->total_size) { - if(msg_chunkno < found_msg->chunkno) + else if (total_size == found_msg->total_size) { + if (msg_chunkno < found_msg->chunkno) better = TRUE; } /* end else-if */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* If we found a better message, keep its info */ - if(better) { - found_msg->msgno = (int)u; - found_msg->id = curr_msg->type->id; - found_msg->chunkno = msg_chunkno; - found_msg->gap_size = gap_size; - found_msg->null_size = null_size; + if (better) { + found_msg->msgno = (int)u; + found_msg->id = curr_msg->type->id; + found_msg->chunkno = msg_chunkno; + found_msg->gap_size = gap_size; + found_msg->null_size = null_size; found_msg->total_size = total_size; found_msg->null_msgno = null_msgno; } /* end if */ - } /* end if */ - else if(found_msg->msgno < 0 && msg_chunkno == oh->nchunks - 1) + } /* end if */ + else if (found_msg->msgno < 0 && msg_chunkno == oh->nchunks - 1) /* Keep track of the total size of smaller messages in the last * chunk, in case we need to move more than 1 message. */ multi_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); } /* end if */ - } /* end for */ + } /* end for */ /* * If we must move some other message to make room for the null @@ -851,7 +839,7 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, * If all else fails, move every message in the last chunk. * */ - if(found_msg->msgno < 0) + if (found_msg->msgno < 0) *size += multi_size; else *size += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; @@ -859,7 +847,6 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, FUNC_LEAVE_NOAPI(SUCCEED) } /* H5O__alloc_find_best_nonnull() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_chunk * @@ -878,19 +865,19 @@ H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, *------------------------------------------------------------------------- */ 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__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_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 */ - unsigned chunkno; /* Chunk allocated */ - haddr_t new_chunk_addr; /* Address of new chunk in file */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned chunkno; /* Chunk allocated */ + haddr_t new_chunk_addr; /* Address of new chunk in file */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -913,37 +900,37 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, * on the chunk and the continuation chunk magic #. (which are only present * in later versions of the object header) */ - size += H5O_SIZEOF_CHKHDR_OH(oh); + size += H5O_SIZEOF_CHKHDR_OH(oh); /* Allocate space in file to hold the new chunk */ new_chunk_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)size); - if(!H5F_addr_defined(new_chunk_addr)) + if (!H5F_addr_defined(new_chunk_addr)) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "unable to allocate space for new chunk") /* Create the new chunk giving it a file address. */ - if(oh->nchunks >= oh->alloc_nchunks) { - size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ + if (oh->nchunks >= oh->alloc_nchunks) { + size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ H5O_chunk_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate larger chunk array, na = %zu", na) oh->alloc_nchunks = na; - oh->chunk = x; + oh->chunk = x; } /* end if */ H5_CHECKED_ASSIGN(chunkno, unsigned, oh->nchunks, size_t); oh->nchunks++; oh->chunk[chunkno].addr = new_chunk_addr; oh->chunk[chunkno].size = size; - oh->chunk[chunkno].gap = 0; - if(NULL == (oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image, size))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate image for chunk, size = %zu", size) + oh->chunk[chunkno].gap = 0; + if (NULL == (oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image, size))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate image for chunk, size = %zu", size) oh->chunk[chunkno].chunk_proxy = NULL; /* If this is a later version of the object header format, put the magic * # at the beginning of the chunk image. */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { H5MM_memcpy(p, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC); p += H5_SIZEOF_MAGIC; } /* end if */ @@ -952,30 +939,30 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, * Make sure we have enough space for all possible new messages * that could be generated below. */ - if(oh->nmesgs + 3 > oh->alloc_nmesgs) - if(H5O_alloc_msgs(oh, (size_t)3) < 0) + if (oh->nmesgs + 3 > oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)3) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Check if we need to move multiple messages, in order to make room for the new message */ cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); - if(found_null >= oh->nmesgs) { - if(found_msg->msgno < 0) { + if (found_null >= oh->nmesgs) { + if (found_msg->msgno < 0) { /* Move all non-null messages in the last chunk to the new chunk. This * should be extremely rare so we don't care too much about minimizing * the space used. */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Protect last chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno - 1))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno - 1))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Copy each message to the new location */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->chunkno == chunkno - 1) { - if(curr_msg->type->id == H5O_NULL_ID) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->chunkno == chunkno - 1) { + if (curr_msg->type->id == H5O_NULL_ID) { /* Delete the null message */ - if(u < oh->nmesgs - 1) + if (u < oh->nmesgs - 1) HDmemmove(curr_msg, curr_msg + 1, ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ @@ -984,30 +971,31 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, /* Copy the raw data */ H5MM_memcpy(p, curr_msg->raw - (size_t)H5O_SIZEOF_MSGHDR_OH(oh), - curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Update the message info */ curr_msg->chunkno = chunkno; - curr_msg->raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = p + H5O_SIZEOF_MSGHDR_OH(oh); /* Account for copied message in new chunk */ p += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; } /* end else */ - } /* end if */ + } /* end if */ /* Create a null message spanning the entire last chunk */ - found_null = oh->nmesgs++; - null_msg = &(oh->mesg[found_null]); - null_msg->type = H5O_MSG_NULL; - null_msg->dirty = TRUE; + found_null = oh->nmesgs++; + null_msg = &(oh->mesg[found_null]); + null_msg->type = H5O_MSG_NULL; + null_msg->dirty = TRUE; null_msg->native = NULL; - null_msg->raw = oh->chunk[chunkno - 1].image - + ((chunkno == 1) ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)) - - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); - null_msg->raw_size = oh->chunk[chunkno - 1].size - - ((chunkno == 1) ? (size_t)H5O_SIZEOF_HDR(oh) : (size_t)H5O_SIZEOF_CHKHDR_OH(oh)) - - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); + null_msg->raw = oh->chunk[chunkno - 1].image + + ((chunkno == 1) ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)) - + H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); + null_msg->raw_size = + oh->chunk[chunkno - 1].size - + ((chunkno == 1) ? (size_t)H5O_SIZEOF_HDR(oh) : (size_t)H5O_SIZEOF_CHKHDR_OH(oh)) - + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); null_msg->chunkno = chunkno - 1; HDassert(null_msg->raw_size >= cont_size); @@ -1016,34 +1004,34 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, oh->chunk[chunkno - 1].gap = 0; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ else { /* Move message (that will be replaced with continuation message) * to new chunk, if necessary. */ - H5O_mesg_t *null_msg; /* Pointer to new null message */ + H5O_mesg_t *null_msg; /* Pointer to new null message */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[found_msg->msgno].chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[found_msg->msgno].chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Create null message for space that message to copy currently occupies */ - found_null = oh->nmesgs++; - null_msg = &(oh->mesg[found_null]); - null_msg->type = H5O_MSG_NULL; - null_msg->native = NULL; - null_msg->raw = oh->mesg[found_msg->msgno].raw; + found_null = oh->nmesgs++; + null_msg = &(oh->mesg[found_null]); + null_msg->type = H5O_MSG_NULL; + null_msg->native = NULL; + null_msg->raw = oh->mesg[found_msg->msgno].raw; null_msg->raw_size = oh->mesg[found_msg->msgno].raw_size; - null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno; + null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno; /* Copy the message to move (& its prefix) to its new location */ H5MM_memcpy(p, oh->mesg[found_msg->msgno].raw - H5O_SIZEOF_MSGHDR_OH(oh), - oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Switch moved message to point to new location */ - oh->mesg[found_msg->msgno].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[found_msg->msgno].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[found_msg->msgno].chunkno = chunkno; /* Account for copied message in new chunk */ @@ -1051,25 +1039,28 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; /* Add any available space after the message to move to the new null message */ - if(found_msg->gap_size > 0) { + if (found_msg->gap_size > 0) { /* Absorb a gap after the moved message */ HDassert(oh->chunk[null_msg->chunkno].gap == found_msg->gap_size); null_msg->raw_size += found_msg->gap_size; oh->chunk[null_msg->chunkno].gap = 0; } /* end if */ - else if(found_msg->null_size > 0) { - H5O_mesg_t *old_null_msg = &oh->mesg[found_msg->null_msgno]; /* Pointer to NULL message to eliminate */ + else if (found_msg->null_size > 0) { + H5O_mesg_t *old_null_msg = + &oh->mesg[found_msg->null_msgno]; /* Pointer to NULL message to eliminate */ /* Absorb a null message after the moved message */ - HDassert((null_msg->raw + null_msg->raw_size) == (old_null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh))); + HDassert((null_msg->raw + null_msg->raw_size) == + (old_null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh))); null_msg->raw_size += found_msg->null_size; /* Release any information/memory for message */ H5O__msg_free_mesg(old_null_msg); /* Remove null message from list of messages */ - if(found_msg->null_msgno < (oh->nmesgs - 1)) - HDmemmove(old_null_msg, old_null_msg + 1, ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); + if (found_msg->null_msgno < (oh->nmesgs - 1)) + HDmemmove(old_null_msg, old_null_msg + 1, + ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ @@ -1083,34 +1074,34 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, null_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end if */ + } /* end if */ /* Create null message for [rest of] space in new chunk */ /* (account for chunk's magic # & checksum) */ - idx = oh->nmesgs++; - oh->mesg[idx].type = H5O_MSG_NULL; - oh->mesg[idx].dirty = TRUE; - oh->mesg[idx].native = NULL; - oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); + idx = oh->nmesgs++; + oh->mesg[idx].type = H5O_MSG_NULL; + oh->mesg[idx].dirty = TRUE; + oh->mesg[idx].native = NULL; + oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[idx].raw_size = size - (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh)); - oh->mesg[idx].chunkno = chunkno; + oh->mesg[idx].chunkno = chunkno; /* Insert the new chunk into the cache */ - if(H5O__chunk_add(f, oh, chunkno, oh->mesg[found_null].chunkno) < 0) + if (H5O__chunk_add(f, oh, chunkno, oh->mesg[found_null].chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't add new chunk to cache") /* Initialize the continuation information */ - if(NULL == (cont = H5FL_MALLOC(H5O_cont_t))) + if (NULL == (cont = H5FL_MALLOC(H5O_cont_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - cont->addr = oh->chunk[chunkno].addr; - cont->size = oh->chunk[chunkno].size; + cont->addr = oh->chunk[chunkno].addr; + cont->size = oh->chunk[chunkno].size; cont->chunkno = chunkno; /* Split the null message and point at continuation message */ - if(H5O__alloc_null(f, oh, found_null, H5O_MSG_CONT, cont, cont_size) < 0) + if (H5O__alloc_null(f, oh, found_null, H5O_MSG_CONT, cont, cont_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Set new message index value */ @@ -1120,7 +1111,6 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_new_chunk * @@ -1158,10 +1148,10 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) { - size_t cont_size; /*continuation message size */ - size_t idx; /* Message number */ - H5O_msg_alloc_info_t found_msg; /* Best fit non-null message */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t cont_size; /*continuation message size */ + size_t idx; /* Message number */ + H5O_msg_alloc_info_t found_msg; /* Best fit non-null message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1171,27 +1161,26 @@ H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) size = H5O_ALIGN_OH(oh, size); /* Find the smallest null message that could hold a continuation message */ - idx = oh->nmesgs; + idx = oh->nmesgs; cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); - if(H5O__alloc_find_best_null(oh, cont_size, &idx) < 0) + if (H5O__alloc_find_best_null(oh, cont_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best null header message") /* If we couldn't find a null message, locate the best message to move to new chunk */ - if(idx >= oh->nmesgs) { + if (idx >= oh->nmesgs) { found_msg.msgno = -1; - if(H5O__alloc_find_best_nonnull(f, oh, &size, &found_msg) < 0) + if (H5O__alloc_find_best_nonnull(f, oh, &size, &found_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best non-null header message") } /* end if */ /* Allocate and initialize new chunk in the file */ - if(H5O__alloc_chunk(f, oh, size, idx, &found_msg, new_idx) < 0) + if (H5O__alloc_chunk(f, oh, size, idx, &found_msg, new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate new object header chunk") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_new_chunk() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc_find_best_null * @@ -1208,8 +1197,8 @@ H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) static herr_t H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) { - size_t idx; /* Index of message which fits allocation */ - ssize_t found_null; /* Best fit null message */ + size_t idx; /* Index of message which fits allocation */ + ssize_t found_null; /* Best fit null message */ FUNC_ENTER_STATIC_NOERR @@ -1220,53 +1209,52 @@ H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) /* Find the smallest null message that could hold the new object header message */ found_null = -1; - for(idx = 0; idx < oh->nmesgs; idx++) { - if(H5O_NULL_ID == oh->mesg[idx].type->id) { + for (idx = 0; idx < oh->nmesgs; idx++) { + if (H5O_NULL_ID == oh->mesg[idx].type->id) { /* If we found an exact fit, use it */ - if(oh->mesg[idx].raw_size == size) { + if (oh->mesg[idx].raw_size == size) { /* Keep first exact fit */ - if(found_null < 0) + if (found_null < 0) found_null = (ssize_t)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; + if (oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) { + 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) { + else if (oh->mesg[idx].raw_size > size) { /* Keep first one found */ - if(found_null < 0) + if (found_null < 0) found_null = (ssize_t)idx; - else - /* Check for better fit */ - if(oh->mesg[idx].raw_size < oh->mesg[found_null].raw_size) - found_null = (ssize_t)idx; - else { - /* If they are the same size, choose the one in the earliest chunk */ - if(oh->mesg[idx].raw_size == oh->mesg[found_null].raw_size) { - if(oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) - found_null = (ssize_t)idx; - } /* end if */ - } /* end else */ - } /* end else-if */ + /* Check for better fit */ + else if (oh->mesg[idx].raw_size < oh->mesg[found_null].raw_size) { + found_null = (ssize_t)idx; + } + else { + /* If they are the same size, choose the one in the earliest chunk */ + if (oh->mesg[idx].raw_size == oh->mesg[found_null].raw_size) { + if (oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) + found_null = (ssize_t)idx; + } /* end if */ + } /* end else */ + } /* end else-if */ /* else: Ignore too-small null messages */ } /* end if */ - } /* end for */ - if(found_null >= 0) + } /* end for */ + if (found_null >= 0) *mesg_idx = (size_t)found_null; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5O__alloc_find_best_null() */ - /*------------------------------------------------------------------------- * Function: H5O__alloc * @@ -1280,8 +1268,7 @@ H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) *------------------------------------------------------------------------- */ herr_t -H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg, size_t *mesg_idx) +H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const void *mesg, size_t *mesg_idx) { size_t raw_size; /* Raw size of message */ size_t aligned_size; /* Size of message including alignment */ @@ -1298,20 +1285,20 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, /* Compute the size needed to store the message in the object header */ raw_size = (type->raw_size)(f, FALSE, mesg); - if(0 == raw_size) + if (0 == raw_size) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "can't compute object header message size") - if(raw_size >= H5O_MESG_MAX_SIZE) + if (raw_size >= H5O_MESG_MAX_SIZE) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "object header message is too large") aligned_size = H5O_ALIGN_OH(oh, raw_size); /* Find the smallest null message that could hold the new object header message */ idx = oh->nmesgs; - if(H5O__alloc_find_best_null(oh, aligned_size, &idx) < 0) + if (H5O__alloc_find_best_null(oh, aligned_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error while locating best null header message") /* if we didn't find one, then allocate more header space */ - if(idx >= oh->nmesgs) { - unsigned chunkno; + if (idx >= oh->nmesgs) { + unsigned chunkno; /* check to see if we can extend one of the chunks. If we can, * do so. Otherwise, we will have to allocate a new chunk. @@ -1319,28 +1306,28 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * Note that in this new version of this function, all chunks * must have file space allocated to them. */ - for(chunkno = 0; chunkno < oh->nchunks; chunkno++) { - htri_t tri_result; /* Status from attempting to extend chunk */ + for (chunkno = 0; chunkno < oh->nchunks; chunkno++) { + htri_t tri_result; /* Status from attempting to extend chunk */ - if((tri_result = H5O__alloc_extend_chunk(f, oh, chunkno, raw_size, &idx)) < 0) + if ((tri_result = H5O__alloc_extend_chunk(f, oh, chunkno, raw_size, &idx)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTEXTEND, FAIL, "can't extend existing chunk") - if(tri_result == TRUE) - break; + if (tri_result == TRUE) + break; } /* end for */ /* If we were not able to extend a chunk, create a new one */ - if(idx >= oh->nmesgs) - if(H5O__alloc_new_chunk(f, oh, raw_size, &idx) < 0) + if (idx >= oh->nmesgs) + if (H5O__alloc_new_chunk(f, oh, raw_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create a new object header data chunk") } /* end if */ HDassert(idx < oh->nmesgs); /* Split the null message and point at continuation message */ - if(H5O__alloc_null(f, oh, idx, type, NULL, aligned_size) < 0) + if (H5O__alloc_null(f, oh, idx, type, NULL, aligned_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") /* Set message index value */ @@ -1350,10 +1337,9 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc() */ - /*------------------------------------------------------------------------- * - * Function: H5O_release_mesg + * Function: H5O__release_mesg * * Purpose: Convert a message into a null message * @@ -1365,13 +1351,13 @@ H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ herr_t -H5O_release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) +H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) { - 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 = SUCCEED; /* Return value */ + 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 = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check args */ HDassert(f); @@ -1379,21 +1365,23 @@ H5O_release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) HDassert(mesg); /* Check if we should operate on the message */ - if(adj_link) + if (adj_link) /* Free any space referred to in the file from this message */ - if(H5O__delete_mesg(f, oh, mesg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if (H5O__delete_mesg(f, oh, mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, mesg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, mesg->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Free any native information */ H5O__msg_free_mesg(mesg); /* Change message type to nil and zero it */ mesg->type = H5O_MSG_NULL; - HDassert(mesg->raw + mesg->raw_size <= (oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)); + HDassert(mesg->raw + mesg->raw_size <= (oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)); HDmemset(mesg->raw, 0, mesg->raw_size); /* Clear message flags */ @@ -1404,25 +1392,25 @@ H5O_release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) chk_dirtied = TRUE; /* Check if chunk has a gap currently */ - if(oh->chunk[mesg->chunkno].gap) { + if (oh->chunk[mesg->chunkno].gap) { /* Eliminate the gap in the chunk */ - if(H5O_eliminate_gap(oh, &chk_dirtied, mesg, - ((oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)), - oh->chunk[mesg->chunkno].gap) < 0) + if (H5O__eliminate_gap(oh, &chk_dirtied, mesg, + ((oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[mesg->chunkno].gap)), + oh->chunk[mesg->chunkno].gap) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") } /* end if */ done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_release_mesg() */ +} /* H5O__release_mesg() */ - /*------------------------------------------------------------------------- - * Function: H5O_move_cont + * Function: H5O__move_cont * * Purpose: Check and move message(s) forward into a continuation message * @@ -1435,15 +1423,15 @@ H5O_release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) *------------------------------------------------------------------------- */ static htri_t -H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) +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 */ - unsigned deleted_chunkno; /* Chunk # to delete */ - hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ - htri_t ret_value = TRUE; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that continuation message is in */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments. */ HDassert(f); @@ -1455,23 +1443,23 @@ H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) deleted_chunkno = ((H5O_cont_t *)(cont_msg->native))->chunkno; /* Check if continuation message is pointing to the last chunk */ - if(deleted_chunkno == (oh->nchunks - 1)) { - size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ - H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ - size_t gap_size; /* Size of gap produced */ - size_t v; /* Local index variable */ + if (deleted_chunkno == (oh->nchunks - 1)) { + size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ + H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ + size_t gap_size; /* Size of gap produced */ + size_t v; /* Local index variable */ /* Spin through messages */ nonnull_size = 0; - for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) { - if(curr_msg->chunkno == deleted_chunkno) { + for (v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) { + if (curr_msg->chunkno == deleted_chunkno) { /* Find size of all non-null messages in the chunk pointed to by the continuation message */ - if(curr_msg->type->id != H5O_NULL_ID) { + if (curr_msg->type->id != H5O_NULL_ID) { HDassert(curr_msg->type->id != H5O_CONT_ID); nonnull_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Size of gap in chunk w/continuation message */ gap_size = oh->chunk[cont_msg->chunkno].gap; @@ -1480,48 +1468,49 @@ H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* (Could count any null messages in the chunk w/the continuation * message also, but that is pretty complex. -QAK) */ - if(nonnull_size && nonnull_size <= (gap_size + cont_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh))) { - uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ - unsigned cont_chunkno; /* Chunk number for continuation message */ + if (nonnull_size && + nonnull_size <= (gap_size + cont_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh))) { + uint8_t *move_start, *move_end; /* Pointers to area of messages to move */ + unsigned cont_chunkno; /* Chunk number for continuation message */ /* Get continuation info */ - move_start = cont_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); - move_end = cont_msg->raw + cont_msg->raw_size; + move_start = cont_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + move_end = cont_msg->raw + cont_msg->raw_size; cont_chunkno = cont_msg->chunkno; /* Convert continuation message into a null message. Do not delete * the target chunk yet, so we can still copy messages from it. */ - if(H5O_release_mesg(f, oh, cont_msg, FALSE) < 0) + if (H5O__release_mesg(f, oh, cont_msg, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to convert into null message") /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Move message(s) forward into continuation message */ - for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) + for (v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) /* Look for messages in chunk to delete */ - if(curr_msg->chunkno == deleted_chunkno) { + if (curr_msg->chunkno == deleted_chunkno) { /* Move messages out of chunk to delete */ - if(curr_msg->type->id != H5O_NULL_ID) { - size_t move_size; /* Size of the message to be moved */ + if (curr_msg->type->id != H5O_NULL_ID) { + size_t move_size; /* Size of the message to be moved */ /* Compute size of message to move */ move_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Move message out of deleted chunk */ H5MM_memcpy(move_start, curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), move_size); - curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); curr_msg->chunkno = cont_chunkno; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Adjust location to move messages to */ move_start += move_size; } /* end else */ - } /* end if */ + } /* end if */ /* Delete the target chunk */ - if(H5O__chunk_delete(f, oh, deleted_chunkno) < 0) + if (H5O__chunk_delete(f, oh, deleted_chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove chunk from cache") HDassert(move_start <= (move_end + gap_size)); @@ -1529,68 +1518,69 @@ H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* Check if there is space remaining in the continuation message */ /* (The remaining space can be gap or a null message) */ gap_size += (size_t)(move_end - move_start); - if(gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + if (gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { /* Adjust size of null (was continuation) message */ cont_msg->raw_size = gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - cont_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); - cont_msg->dirty = TRUE; - chk_dirtied = TRUE; + cont_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); + cont_msg->dirty = TRUE; + chk_dirtied = TRUE; } /* end if */ else { /* Check if there is space that should be a gap */ - if(gap_size > 0) { + if (gap_size > 0) { /* Convert remnant into gap in chunk */ - if(H5O_add_gap(f, oh, cont_chunkno, &chk_dirtied, cont_u, move_start, gap_size) < 0) + if (H5O__add_gap(f, oh, cont_chunkno, &chk_dirtied, cont_u, move_start, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") } /* end if */ /* Release any information/memory for continuation message */ H5O__msg_free_mesg(cont_msg); - if(cont_u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); + if (cont_u < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], + ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end else */ /* Move message(s) forward into continuation message */ /* Note: unsigned v wrapping around at the end */ - for(v = oh->nmesgs - 1, curr_msg = &oh->mesg[v]; v < oh->nmesgs; v--, curr_msg--) + for (v = oh->nmesgs - 1, curr_msg = &oh->mesg[v]; v < oh->nmesgs; v--, curr_msg--) /* Look for messages in chunk to delete */ - if(curr_msg->chunkno == deleted_chunkno) { + if (curr_msg->chunkno == deleted_chunkno) { /* Remove all null messages in deleted chunk from list of messages */ - if(curr_msg->type->id == H5O_NULL_ID) { + if (curr_msg->type->id == H5O_NULL_ID) { /* Release any information/memory for message */ H5O__msg_free_mesg(curr_msg); chk_dirtied = TRUE; /* Remove from message list */ - if(v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + if (v < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ - } /* end if */ + } /* end if */ /* Remove chunk from list of chunks */ oh->chunk[deleted_chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[deleted_chunkno].image); oh->nchunks--; - } /* end if */ + } /* end if */ else ret_value = FALSE; - } /* end if */ + } /* end if */ else ret_value = FALSE; done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_move_cont() */ +} /* H5O__move_cont() */ - /*------------------------------------------------------------------------- * - * Function: H5O_move_msgs_forward + * Function: H5O__move_msgs_forward * * Purpose: Move messages toward first chunk * @@ -1602,18 +1592,18 @@ H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) *------------------------------------------------------------------------- */ static htri_t -H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) +H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) { - H5O_chunk_proxy_t *null_chk_proxy = NULL; /* Chunk that null message is in */ - H5O_chunk_proxy_t *curr_chk_proxy = NULL; /* Chunk that message is in */ - H5O_chunk_proxy_t *cont_targ_chk_proxy = NULL; /* Chunk that continuation message points to */ - hbool_t null_chk_dirtied = FALSE; /* Flags for unprotecting null chunk */ - hbool_t curr_chk_dirtied = FALSE; /* Flags for unprotecting curr chunk */ - hbool_t packed_msg; /* Flag to indicate that messages were packed */ - hbool_t did_packing = FALSE; /* Whether any messages were packed */ - htri_t ret_value = FAIL; /* Return value */ + H5O_chunk_proxy_t *null_chk_proxy = NULL; /* Chunk that null message is in */ + H5O_chunk_proxy_t *curr_chk_proxy = NULL; /* Chunk that message is in */ + H5O_chunk_proxy_t *cont_targ_chk_proxy = NULL; /* Chunk that continuation message points to */ + hbool_t null_chk_dirtied = FALSE; /* Flags for unprotecting null chunk */ + hbool_t curr_chk_dirtied = FALSE; /* Flags for unprotecting curr chunk */ + hbool_t packed_msg; /* Flag to indicate that messages were packed */ + hbool_t did_packing = FALSE; /* Whether any messages were packed */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -1623,54 +1613,59 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) * add a list of messages to each chunk -QAK) */ do { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned u; /* Local index variable */ /* Reset packed messages flag */ packed_msg = FALSE; /* Scan through messages for messages that can be moved earlier in chunks */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(H5O_NULL_ID == curr_msg->type->id) { - H5O_chunk_t *chunk; /* Pointer to chunk that null message is in */ + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (H5O_NULL_ID == curr_msg->type->id) { + H5O_chunk_t *chunk; /* Pointer to chunk that null message is in */ /* Check if null message is not last in chunk */ chunk = &(oh->chunk[curr_msg->chunkno]); - if((curr_msg->raw + curr_msg->raw_size) - != ((chunk->image + chunk->size) - (H5O_SIZEOF_CHKSUM_OH(oh) + chunk->gap))) { - H5O_mesg_t *nonnull_msg; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ - - /* Loop over messages again, looking for the message in the chunk after the null message */ - for(v = 0, nonnull_msg = &oh->mesg[0]; v < oh->nmesgs; v++, nonnull_msg++) { + if ((curr_msg->raw + curr_msg->raw_size) != + ((chunk->image + chunk->size) - (H5O_SIZEOF_CHKSUM_OH(oh) + chunk->gap))) { + H5O_mesg_t *nonnull_msg; /* Pointer to current message to operate on */ + unsigned v; /* Local index variable */ + + /* Loop over messages again, looking for the message in the chunk after the null message + */ + for (v = 0, nonnull_msg = &oh->mesg[0]; v < oh->nmesgs; v++, nonnull_msg++) { /* Locate message that is immediately after the null message */ - if((curr_msg->chunkno == nonnull_msg->chunkno) && - ((curr_msg->raw + curr_msg->raw_size) == (nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)))) { + if ((curr_msg->chunkno == nonnull_msg->chunkno) && + ((curr_msg->raw + curr_msg->raw_size) == + (nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)))) { /* Don't swap messages if the second message is also a null message */ /* (We'll merge them together later, in another routine) */ - if(H5O_NULL_ID != nonnull_msg->type->id) { + if (H5O_NULL_ID != nonnull_msg->type->id) { /* Protect chunk */ - if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Copy raw data for non-null message to new location */ HDmemmove(curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), - nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Adjust non-null message's offset in chunk */ nonnull_msg->raw = curr_msg->raw; /* Adjust null message's offset in chunk */ - curr_msg->raw = nonnull_msg->raw + - nonnull_msg->raw_size + H5O_SIZEOF_MSGHDR_OH(oh); + curr_msg->raw = + nonnull_msg->raw + nonnull_msg->raw_size + H5O_SIZEOF_MSGHDR_OH(oh); /* Mark null message dirty */ /* (since we need to re-encode its message header) */ curr_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, null_chk_proxy, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") null_chk_proxy = NULL; /* Set the flag to indicate that the null message @@ -1683,56 +1678,55 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) /* Break out of loop */ break; } /* end if */ - } /* end for */ + } /* end for */ /* Should have been message after null message */ HDassert(v < oh->nmesgs); } /* end if */ - } /* end if */ + } /* end if */ else { - H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ - size_t v; /* Local index variable */ + H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ + size_t v; /* Local index variable */ /* Check if messages in chunk pointed to can replace continuation message */ - if(H5O_CONT_ID == curr_msg->type->id) { - htri_t status; /* Status from moving messages */ + if (H5O_CONT_ID == curr_msg->type->id) { + htri_t status; /* Status from moving messages */ - if((status = H5O_move_cont(f, oh, u)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "Error in moving messages into cont message") - else if(status > 0) { /* Message(s) got moved into "continuation" message */ + if ((status = H5O__move_cont(f, oh, u)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "Error in moving messages into cont message") + else if (status > 0) { /* Message(s) got moved into "continuation" message */ packed_msg = TRUE; break; } /* end else-if */ - } /* end if */ + } /* end if */ /* Loop over messages again, looking for large enough null message in earlier chunk */ - for(v = 0, null_msg = &oh->mesg[0]; v < oh->nmesgs; v++, null_msg++) { - if(H5O_NULL_ID == null_msg->type->id && curr_msg->chunkno > null_msg->chunkno - && curr_msg->raw_size <= null_msg->raw_size) { - unsigned old_chunkno; /* Old message information */ + for (v = 0, null_msg = &oh->mesg[0]; v < oh->nmesgs; v++, null_msg++) { + if (H5O_NULL_ID == null_msg->type->id && curr_msg->chunkno > null_msg->chunkno && + curr_msg->raw_size <= null_msg->raw_size) { + unsigned old_chunkno; /* Old message information */ uint8_t *old_raw; /* Keep old information about non-null message */ old_chunkno = curr_msg->chunkno; - old_raw = curr_msg->raw; + old_raw = curr_msg->raw; /* Protect chunks */ - if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, null_msg->chunkno))) + if (NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, null_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") - if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + if (NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* If the message being moved is a continuation * message and we are doing SWMR writes, we must * update the flush dependencies */ - if(oh->swmr_write && (H5O_CONT_ID == curr_msg->type->id)) { - void *null_chk_mdc_obj; /* The metadata cache object for the null_msg chunk */ + if (oh->swmr_write && (H5O_CONT_ID == curr_msg->type->id)) { + void *null_chk_mdc_obj; /* The metadata cache object for the null_msg chunk */ /* Point to the metadata cache object for the * null message chunk, oh if in chunk 0 or the * proxy otherwise */ - null_chk_mdc_obj = (null_msg->chunkno == 0 - ? (void *)oh - : (void *)null_chk_proxy); + null_chk_mdc_obj = (null_msg->chunkno == 0 ? (void *)oh : (void *)null_chk_proxy); /* The other chunks involved should never be * chunk 0 */ @@ -1740,102 +1734,119 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) HDassert(((H5O_cont_t *)(curr_msg->native))->chunkno > 0); /* Protect continuation message target chunk */ - if(NULL == (cont_targ_chk_proxy = H5O__chunk_protect(f, oh, ((H5O_cont_t *)(curr_msg->native))->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (cont_targ_chk_proxy = H5O__chunk_protect( + f, oh, ((H5O_cont_t *)(curr_msg->native))->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Check for flush dependency on previous continuation chunk */ /* (As opposed to chunk 0) */ - if(cont_targ_chk_proxy->fd_parent) { + if (cont_targ_chk_proxy->fd_parent) { /* Remove flush dependency on old continuation * message chunk */ HDassert(cont_targ_chk_proxy); HDassert(curr_chk_proxy); HDassert((void *)curr_chk_proxy == cont_targ_chk_proxy->fd_parent); - if(H5AC_destroy_flush_dependency(curr_chk_proxy, cont_targ_chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + if (H5AC_destroy_flush_dependency(curr_chk_proxy, cont_targ_chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency") cont_targ_chk_proxy->fd_parent = NULL; } /* end if */ /* Avoid (another) flush dependency on chunk 0 */ - if(0 != null_msg->chunkno) { + if (0 != null_msg->chunkno) { /* Sanity checks */ HDassert(null_chk_mdc_obj); - HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type); - HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type->id == H5AC_OHDR_CHK_ID); + HDassert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type->id == + H5AC_OHDR_CHK_ID); /* Create flush dependency on new continuation * message chunk */ - if(H5AC_create_flush_dependency(null_chk_mdc_obj, cont_targ_chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + if (H5AC_create_flush_dependency(null_chk_mdc_obj, cont_targ_chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency") cont_targ_chk_proxy->fd_parent = null_chk_mdc_obj; } /* end if */ /* Unprotect continuation message target chunk */ - if(H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") cont_targ_chk_proxy = NULL; } /* end if */ /* Copy raw data for non-null message to new chunk */ - H5MM_memcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + H5MM_memcpy(null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Point non-null message at null message's space */ curr_msg->chunkno = null_msg->chunkno; - curr_msg->raw = null_msg->raw; - curr_chk_dirtied = TRUE; + curr_msg->raw = null_msg->raw; + curr_chk_dirtied = TRUE; /* Change information for null message */ - if(curr_msg->raw_size == null_msg->raw_size) { + if (curr_msg->raw_size == null_msg->raw_size) { /* Point null message at old non-null space */ /* (Instead of freeing it and allocating new message) */ null_msg->chunkno = old_chunkno; - null_msg->raw = old_raw; + null_msg->raw = old_raw; /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Release current chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - curr_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + curr_chk_proxy = NULL; curr_chk_dirtied = FALSE; /* Check for gap in null message's chunk */ - if(oh->chunk[old_chunkno].gap > 0) { + if (oh->chunk[old_chunkno].gap > 0) { /* Eliminate the gap in the chunk */ - if(H5O_eliminate_gap(oh, &null_chk_dirtied, null_msg, - ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), + if (H5O__eliminate_gap( + oh, &null_chk_dirtied, null_msg, + ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), oh->chunk[old_chunkno].gap) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, + "can't eliminate gap in chunk") } /* end if */ /* Release null chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - null_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + null_chk_proxy = NULL; null_chk_dirtied = FALSE; } /* end if */ else { - size_t new_null_msg; /* Message index for new null message */ + size_t new_null_msg; /* Message index for new null message */ /* Check if null message is large enough to still exist */ - if((null_msg->raw_size - curr_msg->raw_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { - size_t gap_size = null_msg->raw_size - curr_msg->raw_size; /* Size of gap produced */ + if ((null_msg->raw_size - curr_msg->raw_size) < + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { + size_t gap_size = + null_msg->raw_size - curr_msg->raw_size; /* Size of gap produced */ /* Adjust the size of the null message being eliminated */ null_msg->raw_size = curr_msg->raw_size; /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Add the gap to the chunk */ - if(H5O_add_gap(f, oh, null_msg->chunkno, &null_chk_dirtied, v, null_msg->raw + null_msg->raw_size, gap_size) < 0) + if (H5O__add_gap(f, oh, null_msg->chunkno, &null_chk_dirtied, v, + 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 */ @@ -1847,15 +1858,17 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) null_msg->raw_size -= curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Mark null message dirty */ - null_msg->dirty = TRUE; + null_msg->dirty = TRUE; null_chk_dirtied = TRUE; /* Create new null message for previous location of non-null message */ - if(oh->nmesgs >= oh->alloc_nmesgs) { - if(H5O_alloc_msgs(oh, (size_t)1) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") + if (oh->nmesgs >= oh->alloc_nmesgs) { + if (H5O__alloc_msgs(oh, (size_t)1) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "can't allocate more space for messages") - /* "Retarget" 'curr_msg' pointer into newly re-allocated array of messages */ + /* "Retarget" 'curr_msg' pointer into newly re-allocated array of messages + */ curr_msg = &oh->mesg[u]; } /* end if */ @@ -1864,35 +1877,40 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) } /* end else */ /* Release null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - null_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + null_chk_proxy = NULL; null_chk_dirtied = FALSE; /* Initialize new null message to take over non-null message's location */ - oh->mesg[new_null_msg].type = H5O_MSG_NULL; - oh->mesg[new_null_msg].native = NULL; - oh->mesg[new_null_msg].raw = old_raw; + oh->mesg[new_null_msg].type = H5O_MSG_NULL; + oh->mesg[new_null_msg].native = NULL; + oh->mesg[new_null_msg].raw = old_raw; oh->mesg[new_null_msg].raw_size = curr_msg->raw_size; - oh->mesg[new_null_msg].chunkno = old_chunkno; + oh->mesg[new_null_msg].chunkno = old_chunkno; /* Mark new null message dirty */ oh->mesg[new_null_msg].dirty = TRUE; - curr_chk_dirtied = TRUE; + curr_chk_dirtied = TRUE; /* Check for gap in new null message's chunk */ - if(oh->chunk[old_chunkno].gap > 0) { + if (oh->chunk[old_chunkno].gap > 0) { /* Eliminate the gap in the chunk */ - if(H5O_eliminate_gap(oh, &curr_chk_dirtied, &oh->mesg[new_null_msg], - ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), + if (H5O__eliminate_gap( + oh, &curr_chk_dirtied, &oh->mesg[new_null_msg], + ((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[old_chunkno].gap)), oh->chunk[old_chunkno].gap) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, "can't eliminate gap in chunk") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREMOVE, FAIL, + "can't eliminate gap in chunk") } /* end if */ /* Release new null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - curr_chk_proxy = NULL; + if (H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") + curr_chk_proxy = NULL; curr_chk_dirtied = FALSE; } /* end else */ @@ -1905,42 +1923,42 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) */ break; } /* end if */ - } /* end for */ + } /* end for */ /* If we packed messages, get out of loop and start over */ /* (Don't know if this has any benefit one way or the other -QAK) */ - if(packed_msg) + if (packed_msg) break; } /* end else */ - } /* end for */ + } /* end for */ /* If we did any packing, remember that */ - if(packed_msg) + if (packed_msg) did_packing = TRUE; - } while(packed_msg); + } while (packed_msg); /* Set return value */ ret_value = (htri_t)did_packing; done: - if(ret_value < 0) { - if(null_chk_proxy && H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) + if (ret_value < 0) { + if (null_chk_proxy && H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect null object header chunk") - if(curr_chk_proxy && H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) + if (curr_chk_proxy && H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect current object header chunk") - if(cont_targ_chk_proxy && H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect continuation message target object header chunk") + if (cont_targ_chk_proxy && H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect continuation message target object header chunk") } /* end if */ else HDassert(!null_chk_proxy && !curr_chk_proxy && !cont_targ_chk_proxy); FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_move_msgs_forward() */ +} /* H5O__move_msgs_forward() */ - /*------------------------------------------------------------------------- * - * Function: H5O_merge_null + * Function: H5O__merge_null * * Purpose: Merge neighboring null messages in an object header * @@ -1952,13 +1970,13 @@ H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) *------------------------------------------------------------------------- */ static htri_t -H5O_merge_null(H5F_t *f, H5O_t *oh) +H5O__merge_null(H5F_t *f, H5O_t *oh) { - hbool_t merged_msg; /* Flag to indicate that messages were merged */ - hbool_t did_merging = FALSE; /* Whether any messages were merged */ - htri_t ret_value = FAIL; /* Return value */ + hbool_t merged_msg; /* Flag to indicate that messages were merged */ + hbool_t did_merging = FALSE; /* Whether any messages were merged */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh != NULL); @@ -1968,38 +1986,41 @@ H5O_merge_null(H5F_t *f, H5O_t *oh) * a list of messages to each chunk -QAK) */ do { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned u; /* Local index variable */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned u; /* Local index variable */ /* Reset merged messages flag */ merged_msg = FALSE; /* Scan messages for adjacent null messages & merge them */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(H5O_NULL_ID == curr_msg->type->id) { - H5O_mesg_t *curr_msg2; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (H5O_NULL_ID == curr_msg->type->id) { + H5O_mesg_t *curr_msg2; /* Pointer to current message to operate on */ + unsigned v; /* Local index variable */ /* Should be no gaps in chunk with null message */ HDassert(oh->chunk[curr_msg->chunkno].gap == 0); /* Loop over messages again, looking for null message in same chunk */ - for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) { - if(u != v && H5O_NULL_ID == curr_msg2->type->id && curr_msg->chunkno == curr_msg2->chunkno) { - ssize_t adj_raw; /* Amount to adjust raw message pointer */ - size_t adj_raw_size; /* Amount to adjust raw message size */ + for (v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) { + if (u != v && H5O_NULL_ID == curr_msg2->type->id && + curr_msg->chunkno == curr_msg2->chunkno) { + ssize_t adj_raw = 0; /* Amount to adjust raw message pointer */ + size_t adj_raw_size = 0; /* Amount to adjust raw message size */ /* Check for second message after first message */ - if((curr_msg->raw + curr_msg->raw_size) == (curr_msg2->raw - H5O_SIZEOF_MSGHDR_OH(oh))) { + if ((curr_msg->raw + curr_msg->raw_size) == + (curr_msg2->raw - H5O_SIZEOF_MSGHDR_OH(oh))) { /* Extend first null message length to cover second null message */ - adj_raw = 0; + adj_raw = 0; adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; /* Message has been merged */ merged_msg = TRUE; } /* end if */ /* Check for second message before first message */ - else if((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == (curr_msg2->raw + curr_msg2->raw_size)) { + else if ((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == + (curr_msg2->raw + curr_msg2->raw_size)) { /* Adjust first message address and extend length to cover second message */ adj_raw = -((ssize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size)); adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; @@ -2009,16 +2030,17 @@ H5O_merge_null(H5F_t *f, H5O_t *oh) } /* end if */ /* Second message has been merged, delete it */ - if(merged_msg) { - H5O_chunk_proxy_t *curr_chk_proxy; /* Chunk that message is in */ - htri_t result; + if (merged_msg) { + H5O_chunk_proxy_t *curr_chk_proxy; /* Chunk that message is in */ + htri_t result; /* Release any information/memory for second message */ H5O__msg_free_mesg(curr_msg2); /* Protect chunk */ - if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + if (NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, + "unable to load object header chunk") /* Adjust first message address and extend length to cover second message */ curr_msg->raw += adj_raw; @@ -2028,57 +2050,59 @@ H5O_merge_null(H5F_t *f, H5O_t *oh) curr_msg->dirty = TRUE; /* Release new null message's chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, curr_chk_proxy, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + if (H5O__chunk_unprotect(f, curr_chk_proxy, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect object header chunk") /* Remove second message from list of messages */ - if(v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + if (v < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ oh->nmesgs--; - /* The merge null message might span the entire chunk: scan for empty chunk to remove */ - if((result = H5O_remove_empty_chunks(f, oh)) < 0) + /* The merge null message might span the entire chunk: scan for empty chunk to + * remove */ + if ((result = H5O__remove_empty_chunks(f, oh)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") - else if(result > 0) + else if (result > 0) /* Get out of loop */ break; /* If the merged message is too large, shrink the chunk */ - if(curr_msg->raw_size >= H5O_MESG_MAX_SIZE) - if(H5O__alloc_shrink_chunk(f, oh, curr_msg->chunkno) < 0) + if (curr_msg->raw_size >= H5O_MESG_MAX_SIZE) + if (H5O__alloc_shrink_chunk(f, oh, curr_msg->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "unable to shrink chunk") /* Get out of loop */ break; } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Get out of loop if we merged messages */ - if(merged_msg) + if (merged_msg) break; } /* end if */ - } /* end for */ + } /* end for */ /* If we did any merging, remember that */ - if(merged_msg) + if (merged_msg) did_merging = TRUE; - } while(merged_msg); + } while (merged_msg); /* Set return value */ ret_value = (htri_t)did_merging; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_merge_null() */ +} /* H5O__merge_null() */ - /*------------------------------------------------------------------------- * - * Function: H5O_remove_empty_chunks + * Function: H5O__remove_empty_chunks * * Purpose: Attempt to eliminate empty chunks from object header. * @@ -2094,52 +2118,52 @@ H5O_merge_null(H5F_t *f, H5O_t *oh) *------------------------------------------------------------------------- */ static htri_t -H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) +H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) { - hbool_t deleted_chunk; /* Whether to a chunk was deleted */ - hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ - htri_t ret_value = FAIL; /* Return value */ + hbool_t deleted_chunk; /* Whether to a chunk was deleted */ + hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh != NULL); /* Loop until no chunks are freed */ do { - H5O_mesg_t *null_msg; /* Pointer to null message found */ - H5O_mesg_t *cont_msg; /* Pointer to continuation message found */ - unsigned u, v; /* Local index variables */ + H5O_mesg_t *null_msg; /* Pointer to null message found */ + H5O_mesg_t *cont_msg; /* Pointer to continuation message found */ + unsigned u, v; /* Local index variables */ /* Reset 'chunk deleted' flag */ deleted_chunk = FALSE; /* Scan messages for null messages that fill an entire chunk */ - for(u = 0, null_msg = &oh->mesg[0]; u < oh->nmesgs; u++, null_msg++) { + for (u = 0, null_msg = &oh->mesg[0]; u < oh->nmesgs; u++, null_msg++) { /* If a null message takes up an entire object header chunk (and * its not the "base" chunk), delete that chunk from object header */ - if(H5O_NULL_ID == null_msg->type->id && null_msg->chunkno > 0 && - ((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + null_msg->raw_size) - == (oh->chunk[null_msg->chunkno].size - H5O_SIZEOF_CHKHDR_OH(oh))) { - H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ - unsigned null_msg_no; /* Message # for null message */ - unsigned deleted_chunkno; /* Chunk # to delete */ + if (H5O_NULL_ID == null_msg->type->id && null_msg->chunkno > 0 && + ((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + null_msg->raw_size) == + (oh->chunk[null_msg->chunkno].size - H5O_SIZEOF_CHKHDR_OH(oh))) { + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ + unsigned null_msg_no; /* Message # for null message */ + unsigned deleted_chunkno; /* Chunk # to delete */ /* Locate continuation message that points to chunk */ - for(v = 0, cont_msg = &oh->mesg[0]; v < oh->nmesgs; v++, cont_msg++) { - if(H5O_CONT_ID == cont_msg->type->id) { + for (v = 0, cont_msg = &oh->mesg[0]; v < oh->nmesgs; v++, cont_msg++) { + if (H5O_CONT_ID == cont_msg->type->id) { /* Decode current continuation message if necessary */ H5O_LOAD_NATIVE(f, 0, oh, cont_msg, FAIL) /* Check if the chunkno needs to be set */ /* (should only occur when the continuation message is first decoded) */ - if(0 == ((H5O_cont_t *)(cont_msg->native))->chunkno) { - unsigned w; /* Local index variable */ + if (0 == ((H5O_cont_t *)(cont_msg->native))->chunkno) { + unsigned w; /* Local index variable */ /* Find chunk that this continuation message points to */ - for(w = 0; w < oh->nchunks; w++) - if(oh->chunk[w].addr == ((H5O_cont_t *)(cont_msg->native))->addr) { + for (w = 0; w < oh->nchunks; w++) + if (oh->chunk[w].addr == ((H5O_cont_t *)(cont_msg->native))->addr) { ((H5O_cont_t *)(cont_msg->native))->chunkno = w; break; } /* end if */ @@ -2147,21 +2171,21 @@ H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) } /* end if */ /* Check for correct chunk to delete */ - if(oh->chunk[null_msg->chunkno].addr == ((H5O_cont_t *)(cont_msg->native))->addr) + if (oh->chunk[null_msg->chunkno].addr == ((H5O_cont_t *)(cont_msg->native))->addr) break; } /* end if */ - } /* end for */ + } /* end for */ /* Must be a continuation message that points to chunk containing null message */ HDassert(v < oh->nmesgs); HDassert(cont_msg); HDassert(((H5O_cont_t *)(cont_msg->native))->chunkno == null_msg->chunkno); /* Initialize information about null message */ - null_msg_no = u; + null_msg_no = u; deleted_chunkno = null_msg->chunkno; /* Convert continuation message into a null message */ - if(H5O_release_mesg(f, oh, cont_msg, TRUE) < 0) + if (H5O__release_mesg(f, oh, cont_msg, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to convert into null message") /* @@ -2169,27 +2193,31 @@ H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) */ /* Free memory for chunk image */ - oh->chunk[null_msg->chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); + oh->chunk[null_msg->chunkno].image = + H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image); /* Remove chunk from list of chunks */ - if(null_msg->chunkno < (oh->nchunks - 1)) { - HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); + if (null_msg->chunkno < (oh->nchunks - 1)) { + HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], + ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); /* Adjust chunk number for any chunk proxies that are in the cache */ - for(u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { - unsigned chk_proxy_status = 0; /* Metadata cache status of chunk proxy for chunk */ + for (u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { + unsigned chk_proxy_status = 0; /* Metadata cache status of chunk proxy for chunk */ /* Check the chunk proxy's status in the metadata cache */ - if(H5AC_get_entry_status(f, oh->chunk[u].addr, &chk_proxy_status) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check metadata cache status for chunk proxy") + if (H5AC_get_entry_status(f, oh->chunk[u].addr, &chk_proxy_status) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, + "unable to check metadata cache status for chunk proxy") /* If the entry is in the cache, update its chunk index */ - if(chk_proxy_status & H5AC_ES__IN_CACHE) { - if(H5O__chunk_update_idx(f, oh, u) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update index for chunk proxy") + if (chk_proxy_status & H5AC_ES__IN_CACHE) { + if (H5O__chunk_update_idx(f, oh, u) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "unable to update index for chunk proxy") } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Decrement # of chunks */ /* (Don't bother reducing size of chunk array for now -QAK) */ @@ -2203,35 +2231,36 @@ H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) H5O__msg_free_mesg(null_msg); /* Remove null message from list of messages */ - if(null_msg_no < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); + if (null_msg_no < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], + ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ oh->nmesgs--; /* Adjust chunk # for messages in chunks after deleted chunk */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Sanity check - there should be no messages in deleted chunk */ HDassert(curr_msg->chunkno != deleted_chunkno); /* Adjust chunk index for messages in later chunks */ - if(curr_msg->chunkno > deleted_chunkno) + if (curr_msg->chunkno > deleted_chunkno) curr_msg->chunkno--; /* Check for continuation message */ - if(H5O_CONT_ID == curr_msg->type->id) { + if (H5O_CONT_ID == curr_msg->type->id) { /* Decode current continuation message if necessary */ H5O_LOAD_NATIVE(f, 0, oh, curr_msg, FAIL) /* Check if the chunkno needs to be set */ /* (should only occur when the continuation message is first decoded) */ - if(0 == ((H5O_cont_t *)(curr_msg->native))->chunkno) { - unsigned w; /* Local index variable */ + if (0 == ((H5O_cont_t *)(curr_msg->native))->chunkno) { + unsigned w; /* Local index variable */ /* Find chunk that this continuation message points to */ - for(w = 0; w < oh->nchunks; w++) - if(oh->chunk[w].addr == ((H5O_cont_t *)(curr_msg->native))->addr) { + for (w = 0; w < oh->nchunks; w++) + if (oh->chunk[w].addr == ((H5O_cont_t *)(curr_msg->native))->addr) { ((H5O_cont_t *)(curr_msg->native))->chunkno = w; break; } /* end if */ @@ -2239,34 +2268,33 @@ H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) } /* end if */ else { /* Check for pointer to chunk after deleted chunk */ - if(((H5O_cont_t *)(curr_msg->native))->chunkno > deleted_chunkno) + if (((H5O_cont_t *)(curr_msg->native))->chunkno > deleted_chunkno) ((H5O_cont_t *)(curr_msg->native))->chunkno--; } /* end else */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Found chunk to delete */ deleted_chunk = TRUE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we deleted any chunks, remember that */ - if(deleted_chunk) + if (deleted_chunk) did_deleting = TRUE; - } while(deleted_chunk); + } while (deleted_chunk); /* Set return value */ ret_value = (htri_t)did_deleting; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_remove_empty_chunks() */ +} /* H5O__remove_empty_chunks() */ - /*------------------------------------------------------------------------- * - * Function: H5O_condense_header + * Function: H5O__condense_header * * Purpose: Attempt to eliminate empty chunks from object header. * @@ -2278,13 +2306,13 @@ H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) *------------------------------------------------------------------------- */ herr_t -H5O_condense_header(H5F_t *f, H5O_t *oh) +H5O__condense_header(H5F_t *f, H5O_t *oh) { - hbool_t rescan_header; /* Whether to rescan header */ - htri_t result; /* Result from packing/merging/etc */ - herr_t ret_value = SUCCEED; /* return value */ + hbool_t rescan_header; /* Whether to rescan header */ + htri_t result; /* Result from packing/merging/etc */ + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check args */ HDassert(oh != NULL); @@ -2295,35 +2323,34 @@ H5O_condense_header(H5F_t *f, H5O_t *oh) rescan_header = FALSE; /* Scan for messages that can be moved earlier in chunks */ - result = H5O_move_msgs_forward(f, oh); - if(result < 0) + result = H5O__move_msgs_forward(f, oh); + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't move header messages forward") - if(result > 0) + if (result > 0) rescan_header = TRUE; /* Scan for adjacent null messages & merge them */ - result = H5O_merge_null(f, oh); - if(result < 0) + result = H5O__merge_null(f, oh); + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack null header messages") - if(result > 0) + if (result > 0) rescan_header = TRUE; /* Scan for empty chunks to remove */ - result = H5O_remove_empty_chunks(f, oh); - if(result < 0) + result = H5O__remove_empty_chunks(f, oh); + if (result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") - if(result > 0) + if (result > 0) rescan_header = TRUE; - } while(rescan_header); + } while (rescan_header); #ifdef H5O_DEBUG -H5O_assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_condense_header() */ +} /* H5O__condense_header() */ - /*------------------------------------------------------------------------- * * Function: H5O__alloc_shrink_chunk @@ -2340,21 +2367,21 @@ H5O_assert(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_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 */ - 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 */ - size_t min_chunk_size = H5O_ALIGN_OH(oh, H5O_MIN_SIZE); /* Minimum chunk size */ - size_t sizeof_chksum = H5O_SIZEOF_CHKSUM_OH(oh); /* Size of chunk checksum */ - size_t sizeof_msghdr = H5O_SIZEOF_MSGHDR_OH(oh); /* Size of message header */ - uint8_t new_size_flags = 0; /* New chunk #0 size flags */ - hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ - size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ - size_t u; /* Index */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + size_t min_chunk_size = H5O_ALIGN_OH(oh, H5O_MIN_SIZE); /* Minimum chunk size */ + size_t sizeof_chksum = H5O_SIZEOF_CHKSUM_OH(oh); /* Size of chunk checksum */ + size_t sizeof_msghdr = H5O_SIZEOF_MSGHDR_OH(oh); /* Size of message header */ + uint8_t new_size_flags = 0; /* New chunk #0 size flags */ + hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ + size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ + size_t u; /* Index */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2363,33 +2390,32 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) HDassert(oh); /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Loop backwards to increase the chance of seeing more null messages at the * end of the chunk. Note that we rely on unsigned u wrapping around at the * end. */ - for(u = oh->nmesgs - 1, curr_msg = &oh->mesg[u]; u < oh->nmesgs; u--, curr_msg--) { - if((H5O_NULL_ID == curr_msg->type->id) && (chunkno == curr_msg->chunkno)) { + for (u = oh->nmesgs - 1, curr_msg = &oh->mesg[u]; u < oh->nmesgs; u--, curr_msg--) { + if ((H5O_NULL_ID == curr_msg->type->id) && (chunkno == curr_msg->chunkno)) { size_t shrink_size = curr_msg->raw_size + sizeof_msghdr; /* Amount to shrink the chunk by */ /* If the current message is not at the end of the chunk, copy the - * data after it (except the checksum). - */ - 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 */ + * data after it (except the checksum). + */ + 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 */ /* Slide down the raw data */ HDmemmove(curr_msg->raw - sizeof_msghdr, src, - (size_t)(old_image + new_size - sizeof_chksum - src)); + (size_t)(old_image + new_size - sizeof_chksum - src)); /* Update the raw data pointers for messages after this one */ - for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) - if((chunkno == curr_msg2->chunkno) && (curr_msg2->raw > curr_msg->raw)) + for (v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) + if ((chunkno == curr_msg2->chunkno) && (curr_msg2->raw > curr_msg->raw)) curr_msg2->raw -= shrink_size; } /* end if */ @@ -2400,29 +2426,29 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) H5O__msg_free_mesg(curr_msg); /* Remove the deleted null message from list of messages */ - if(u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[u], &oh->mesg[u+1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); + if (u < (oh->nmesgs - 1)) + HDmemmove(&oh->mesg[u], &oh->mesg[u + 1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now) */ oh->nmesgs--; } /* end if */ - } /* end for */ + } /* end for */ /* Check if the chunk is too small, extend if necessary */ total_msg_size = new_size - (size_t)(chunkno == 0 ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)); - if(total_msg_size < min_chunk_size) { + if (total_msg_size < min_chunk_size) { HDassert(oh->alloc_nmesgs > oh->nmesgs); oh->nmesgs++; /* Initialize new null message to make the chunk large enough */ - curr_msg = &oh->mesg[oh->nmesgs - 1]; - curr_msg->type = H5O_MSG_NULL; - curr_msg->dirty = TRUE; + curr_msg = &oh->mesg[oh->nmesgs - 1]; + curr_msg->type = H5O_MSG_NULL; + curr_msg->dirty = TRUE; curr_msg->native = NULL; - curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; - curr_msg->raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), - sizeof_msghdr) - sizeof_msghdr; + curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; + curr_msg->raw_size = + MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), sizeof_msghdr) - sizeof_msghdr; curr_msg->chunkno = chunkno; /* update the new chunk size */ @@ -2430,67 +2456,67 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) } /* end if */ /* Check for changing the chunk #0 data size enough to need adjusting the flags */ - if(oh->version > H5O_VERSION_1 && chunkno == 0) { - uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh); /* New size of chunk 0's data */ + if (oh->version > H5O_VERSION_1 && chunkno == 0) { + uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh); /* New size of chunk 0's data */ size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size */ /* Check for moving to a 1-byte size encoding */ - if(orig_prfx_size > 1 && chunk0_newsize <= 255) { - less_prfx_size = orig_prfx_size - 1; - new_size_flags = H5O_HDR_CHUNK0_1; + if (orig_prfx_size > 1 && chunk0_newsize <= 255) { + less_prfx_size = orig_prfx_size - 1; + new_size_flags = H5O_HDR_CHUNK0_1; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 2-byte size encoding */ - else if(orig_prfx_size > 2 && chunk0_newsize <= 65535) { - less_prfx_size = orig_prfx_size - 2; - new_size_flags = H5O_HDR_CHUNK0_2; + else if (orig_prfx_size > 2 && chunk0_newsize <= 65535) { + less_prfx_size = orig_prfx_size - 2; + new_size_flags = H5O_HDR_CHUNK0_2; adjust_size_flags = TRUE; } /* end if */ /* Check for moving to a 4-byte size encoding */ - else if(orig_prfx_size > 4 && chunk0_newsize <= 4294967295) { - less_prfx_size = orig_prfx_size - 4; - new_size_flags = H5O_HDR_CHUNK0_4; + else if (orig_prfx_size > 4 && chunk0_newsize <= 4294967295) { + less_prfx_size = orig_prfx_size - 4; + new_size_flags = H5O_HDR_CHUNK0_4; adjust_size_flags = TRUE; } /* end if */ - } /* end if */ + } /* end if */ - if(adjust_size_flags) { + if (adjust_size_flags) { /* Adjust object header prefix flags */ oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Slide chunk 0 data down */ HDmemmove(chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum, - chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, - new_size - (size_t)H5O_SIZEOF_HDR(oh)); + chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, + new_size - (size_t)H5O_SIZEOF_HDR(oh)); /* Adjust chunk size */ new_size -= less_prfx_size; } /* end if */ /* Allocate less memory space for chunk's image */ - chunk->size = new_size; + chunk->size = new_size; chunk->image = H5FL_BLK_REALLOC(chunk_image, old_image, chunk->size); - chunk->gap = 0; - if(NULL == oh->chunk[chunkno].image) + chunk->gap = 0; + if (NULL == oh->chunk[chunkno].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Spin through existing messages, adjusting them */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - if(adjust_size_flags || (chunk->image != old_image)) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + if (adjust_size_flags || (chunk->image != old_image)) /* Adjust raw addresses for messages in this chunk to reflect new 'image' address */ - if(curr_msg->chunkno == chunkno) + if (curr_msg->chunkno == chunkno) curr_msg->raw = chunk->image - less_prfx_size + (curr_msg->raw - old_image); /* Find continuation message which points to this chunk and adjust chunk's size */ /* (Chunk 0 doesn't have a continuation message that points to it and * its size is directly encoded in the object header) */ - if(chunkno > 0 && (H5O_CONT_ID == curr_msg->type->id) && - (((H5O_cont_t *)(curr_msg->native))->chunkno == chunkno)) { - H5O_chunk_proxy_t *cont_chk_proxy; /* Chunk that message is in */ + if (chunkno > 0 && (H5O_CONT_ID == curr_msg->type->id) && + (((H5O_cont_t *)(curr_msg->native))->chunkno == chunkno)) { + H5O_chunk_proxy_t *cont_chk_proxy; /* Chunk that message is in */ /* Protect chunk */ - if(NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) + if (NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Adjust size of continuation message */ @@ -2501,26 +2527,25 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) curr_msg->dirty = TRUE; /* Release chunk, marking it dirty */ - if(H5O__chunk_unprotect(f, cont_chk_proxy, TRUE) < 0) + if (H5O__chunk_unprotect(f, cont_chk_proxy, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") } /* end if */ - } /* end for */ + } /* end for */ HDassert(new_size <= old_size); /* Resize the chunk in the cache */ - if(H5O__chunk_resize(oh, chk_proxy) < 0) + if (H5O__chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") /* Free the unused space in the file */ - if(H5MF_xfree(f, H5FD_MEM_OHDR, chunk->addr + new_size, (hsize_t)(old_size - new_size)) < 0) + if (H5MF_xfree(f, H5FD_MEM_OHDR, chunk->addr + new_size, (hsize_t)(old_size - new_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to shrink object header chunk") done: /* Release chunk, marking it dirty */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_shrink_chunk() */ - diff --git a/src/H5Oattr.c b/src/H5Oattr.c index c8dd822e2f7..db53eafb6a9 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -6,92 +6,88 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5S_FRIEND /*suppress error about including H5Spkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ -static herr_t H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void *H5O_attr_decode(H5F_t *f, H5O_t *open_oh, - unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); -static void *H5O_attr_copy(const void *_mesg, void *_dest); -static size_t H5O_attr_size(const H5F_t *f, const void *_mesg); +static herr_t H5O__attr_encode(H5F_t *f, uint8_t *p, const void *mesg); +static void *H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p); +static void *H5O__attr_copy(const void *_mesg, void *_dest); +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, 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); -static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx); -static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx); -static herr_t H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +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, + 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); +static herr_t H5O__attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx); +static herr_t H5O__attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx); +static herr_t H5O__attr_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_ATTR -#define H5O_SHARED_DECODE H5O_attr_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_attr_decode -#define H5O_SHARED_ENCODE H5O_attr_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_attr_encode -#define H5O_SHARED_SIZE H5O_attr_shared_size -#define H5O_SHARED_SIZE_REAL H5O_attr_size -#define H5O_SHARED_DELETE H5O__attr_shared_delete -#define H5O_SHARED_DELETE_REAL H5O__attr_delete -#define H5O_SHARED_LINK H5O__attr_shared_link -#define H5O_SHARED_LINK_REAL H5O__attr_link -#define H5O_SHARED_COPY_FILE H5O__attr_shared_copy_file -#define H5O_SHARED_COPY_FILE_REAL H5O__attr_copy_file -#define H5O_SHARED_POST_COPY_FILE H5O_attr_shared_post_copy_file -#define H5O_SHARED_POST_COPY_FILE_REAL H5O__attr_post_copy_file -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_attr_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__attr_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#define H5O_SHARED_TYPE H5O_MSG_ATTR +#define H5O_SHARED_DECODE H5O__attr_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__attr_decode +#define H5O_SHARED_ENCODE H5O__attr_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O__attr_encode +#define H5O_SHARED_SIZE H5O__attr_shared_size +#define H5O_SHARED_SIZE_REAL H5O__attr_size +#define H5O_SHARED_DELETE H5O__attr_shared_delete +#define H5O_SHARED_DELETE_REAL H5O__attr_delete +#define H5O_SHARED_LINK H5O__attr_shared_link +#define H5O_SHARED_LINK_REAL H5O__attr_link +#define H5O_SHARED_COPY_FILE H5O__attr_shared_copy_file +#define H5O_SHARED_COPY_FILE_REAL H5O__attr_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__attr_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE_REAL H5O__attr_post_copy_file +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O__attr_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__attr_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ 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_attr_shared_decode, /* decode message */ - H5O_attr_shared_encode, /* encode message */ - H5O_attr_copy, /* copy the native value */ - H5O_attr_shared_size, /* size of raw message */ - H5O__attr_reset, /* reset method */ - H5O__attr_free, /* free method */ - H5O__attr_shared_delete, /* file delete method */ - H5O__attr_shared_link, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_attr_pre_copy_file, /* pre copy native value to file */ - H5O__attr_shared_copy_file, /* copy native value to file */ - H5O_attr_shared_post_copy_file, /* post copy native value to file */ - H5O_attr_get_crt_index, /* get creation index */ - H5O_attr_set_crt_index, /* set creation index */ - H5O_attr_shared_debug /* debug the message */ + 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__attr_shared_decode, /* decode message */ + H5O__attr_shared_encode, /* encode message */ + H5O__attr_copy, /* copy the native value */ + H5O__attr_shared_size, /* size of raw message */ + H5O__attr_reset, /* reset method */ + H5O__attr_free, /* free method */ + H5O__attr_shared_delete, /* file delete method */ + H5O__attr_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + H5O__attr_pre_copy_file, /* pre copy native value to file */ + H5O__attr_shared_copy_file, /* copy native value to file */ + H5O__attr_shared_post_copy_file, /* post copy native value to file */ + H5O__attr_get_crt_index, /* get creation index */ + H5O__attr_set_crt_index, /* set creation index */ + H5O__attr_shared_debug /* debug the message */ }}; /* Flags for attribute flag encoding */ -#define H5O_ATTR_FLAG_TYPE_SHARED 0x01 -#define H5O_ATTR_FLAG_SPACE_SHARED 0x02 -#define H5O_ATTR_FLAG_ALL 0x03 +#define H5O_ATTR_FLAG_TYPE_SHARED 0x01 +#define H5O_ATTR_FLAG_SPACE_SHARED 0x02 +#define H5O_ATTR_FLAG_ALL 0x03 /* Declare external the free list for H5S_t's */ H5FL_EXTERN(H5S_t); @@ -99,19 +95,18 @@ H5FL_EXTERN(H5S_t); /* Declare external the free list for H5S_extent_t's */ H5FL_EXTERN(H5S_extent_t); - /*-------------------------------------------------------------------------- NAME - H5O_attr_decode + H5O__attr_decode PURPOSE Decode a attribute message and return a pointer to a memory struct with the decoded information USAGE - void *H5O_attr_decode(f, mesg_flags, p) - H5F_t *f; IN: pointer to the HDF5 file struct + void *H5O__attr_decode(f, mesg_flags, p) + H5F_t *f; IN: pointer to the HDF5 file struct H5O_t *open_oh; IN: pointer to the object header unsigned mesg_flags; IN: message flags to influence decoding - unsigned *ioflags; IN: flags for decoding + unsigned *ioflags; IN/OUT: flags for decoding size_t p_size; IN: size of buffer *p const uint8_t *p; IN: the raw information buffer RETURNS @@ -122,45 +117,45 @@ H5FL_EXTERN(H5S_extent_t); function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ 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) +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; - 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 * 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); HDassert(p); - if(NULL == (attr = H5FL_CALLOC(H5A_t))) + if (NULL == (attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) + if (NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure") /* Version number */ attr->shared->version = *p++; - if(attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST) + if (attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST) HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message") /* Get the flags byte if we have a later version of the attribute */ - if(attr->shared->version >= H5O_ATTR_VERSION_2) { + if (attr->shared->version >= H5O_ATTR_VERSION_2) { flags = *p++; /* Check for unknown flag */ - if(flags & (unsigned)~H5O_ATTR_FLAG_ALL) + if (flags & (unsigned)~H5O_ATTR_FLAG_ALL) HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "unknown flag for attribute message") } /* end if */ else - p++; /* Byte is unused when version<2 */ + p++; /* Byte is unused when version<2 */ /* * Decode the sizes of the parts of the attribute. The sizes stored in @@ -174,27 +169,28 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, * Decode the character encoding for the name for versions 3 or later, * as well as some reserved bytes. */ - if(attr->shared->version >= H5O_ATTR_VERSION_3) + if (attr->shared->version >= H5O_ATTR_VERSION_3) attr->shared->encoding = (H5T_cset_t)*p++; /* Decode and store the name */ - if(NULL == (attr->shared->name = H5MM_strdup((const char *)p))) + if (NULL == (attr->shared->name = H5MM_strdup((const char *)p))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make an attempt to detect corrupted name or name length - HDFFV-10588 */ - if(name_len != (HDstrlen(attr->shared->name) + 1)) + if (name_len != (HDstrlen(attr->shared->name) + 1)) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "attribute name has different length than stored length") - if(attr->shared->version < H5O_ATTR_VERSION_2) - p += H5O_ALIGN_OLD(name_len); /* advance the memory pointer */ + if (attr->shared->version < H5O_ATTR_VERSION_2) + p += H5O_ALIGN_OLD(name_len); /* advance the memory pointer */ else - p += name_len; /* advance the memory pointer */ + p += name_len; /* advance the memory pointer */ /* Decode the attribute's datatype */ - if(NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)(f, open_oh, - ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->dt_size, p))) + if (NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)( + f, open_oh, ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, + attr->shared->dt_size, p))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype") - if(attr->shared->version < H5O_ATTR_VERSION_2) + if (attr->shared->version < H5O_ATTR_VERSION_2) p += H5O_ALIGN_OLD(attr->shared->dt_size); else p += attr->shared->dt_size; @@ -202,12 +198,13 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, /* decode the attribute dataspace. It can be shared in versions >= 3 * What's actually shared, though, is only the extent. */ - if(NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t))) + if (NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Decode attribute's dataspace extent */ - if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, open_oh, - ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->ds_size, p)) == NULL) + if ((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)( + f, open_oh, ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, + attr->shared->ds_size, p)) == NULL) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace") /* Copy the extent information to the dataspace */ @@ -217,22 +214,22 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, extent = H5FL_FREE(H5S_extent_t, extent); /* Default to entire dataspace being selected */ - if(H5S_select_all(attr->shared->ds, FALSE) < 0) + if (H5S_select_all(attr->shared->ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") - if(attr->shared->version < H5O_ATTR_VERSION_2) + if (attr->shared->version < H5O_ATTR_VERSION_2) p += H5O_ALIGN_OLD(attr->shared->ds_size); else p += attr->shared->ds_size; /* Get the datatype's size */ - if(0 == (dt_size = H5T_get_size(attr->shared->dt))) + 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))) + if (0 == (dt_size = H5T_get_size(attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") - if((sds_size = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) + if ((sds_size = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get dataspace size") ds_size = (hsize_t)sds_size; @@ -240,13 +237,13 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, ds_size * (hsize_t)dt_size, hsize_t); /* Go get the data */ - if(attr->shared->data_size) { + if (attr->shared->data_size) { /* Ensure that data size doesn't exceed buffer size, in case of it's being corrupted in the file */ - if(attr->shared->data_size > p_size) + if (attr->shared->data_size > p_size) HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds buffer size") - if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) + if (NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(attr->shared->data, p, attr->shared->data_size); } /* end if */ @@ -259,31 +256,26 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, ret_value = attr; done: - if(NULL == ret_value) - if(attr) { - if(attr->shared) { - /* Free any dynamically allocated items */ - if(H5A__free(attr) < 0) + if (NULL == ret_value) + if (attr) { + /* Free any dynamically allocated items */ + if (attr->shared) + if (H5A__shared_free(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info") - /* Destroy shared attribute struct */ - attr->shared = H5FL_FREE(H5A_shared_t, attr->shared); - } /* end if */ - attr = H5FL_FREE(H5A_t, attr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_decode() */ +} /* end H5O__attr_decode() */ - /*-------------------------------------------------------------------------- NAME - H5O_attr_encode + H5O__attr_encode PURPOSE Encode a simple attribute message USAGE - herr_t H5O_attr_encode(f, p, mesg) + herr_t H5O__attr_encode(f, p, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple datatype struct @@ -294,16 +286,16 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t -H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) +H5O__attr_encode(H5F_t *f, uint8_t *p, const void *mesg) { - const H5A_t *attr = (const H5A_t *) mesg; - size_t name_len; /* Attribute name length */ - htri_t is_type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ - htri_t is_space_shared; /* Flag to indicate that a shared dataspace is used for this attribute */ - unsigned flags = 0; /* Attribute flags */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_t *attr = (const H5A_t *)mesg; + size_t name_len; /* Attribute name length */ + htri_t is_type_shared; /* Flag to indicate that a shared datatype is used for this attribute */ + htri_t is_space_shared; /* Flag to indicate that a shared dataspace is used for this attribute */ + unsigned flags = 0; /* Attribute flags */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -311,21 +303,21 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) HDassert(attr); /* Check whether datatype and dataspace are shared */ - if((is_type_shared = H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt)) < 0) + if ((is_type_shared = H5O_msg_is_shared(H5O_DTYPE_ID, attr->shared->dt)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't determine if datatype is shared") - if((is_space_shared = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds)) < 0) + if ((is_space_shared = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->shared->ds)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't determine if dataspace is shared") /* Encode Version */ *p++ = attr->shared->version; /* Set attribute flags if version >1 */ - if(attr->shared->version >= H5O_ATTR_VERSION_2) { - flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 ); + if (attr->shared->version >= H5O_ATTR_VERSION_2) { + flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0); flags |= (is_space_shared ? H5O_ATTR_FLAG_SPACE_SHARED : 0); - *p++ = (uint8_t)flags; /* Set flags for attribute */ - } /* end if */ + *p++ = (uint8_t)flags; /* Set flags for attribute */ + } /* end if */ else *p++ = 0; /* Reserved, for version <2 */ @@ -340,12 +332,12 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) UINT16ENCODE(p, attr->shared->ds_size); /* The character encoding for the attribute's name, in later versions */ - if(attr->shared->version >= H5O_ATTR_VERSION_3) + if (attr->shared->version >= H5O_ATTR_VERSION_3) *p++ = (uint8_t)attr->shared->encoding; /* Write the name including null terminator */ H5MM_memcpy(p, attr->shared->name, name_len); - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { /* Pad to the correct number of bytes */ HDmemset(p + name_len, 0, H5O_ALIGN_OLD(name_len) - name_len); p += H5O_ALIGN_OLD(name_len); @@ -354,10 +346,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += name_len; /* encode the attribute datatype */ - if((H5O_MSG_DTYPE->encode)(f, FALSE, p, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->encode)(f, FALSE, p, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype") - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { HDmemset(p + attr->shared->dt_size, 0, H5O_ALIGN_OLD(attr->shared->dt_size) - attr->shared->dt_size); p += H5O_ALIGN_OLD(attr->shared->dt_size); } /* end if */ @@ -365,10 +357,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += attr->shared->dt_size; /* encode the attribute dataspace */ - if((H5O_MSG_SDSPACE->encode)(f, FALSE, p, &(attr->shared->ds->extent)) < 0) + if ((H5O_MSG_SDSPACE->encode)(f, FALSE, p, &(attr->shared->ds->extent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace") - if(attr->shared->version < H5O_ATTR_VERSION_2) { + if (attr->shared->version < H5O_ATTR_VERSION_2) { HDmemset(p + attr->shared->ds_size, 0, H5O_ALIGN_OLD(attr->shared->ds_size) - attr->shared->ds_size); p += H5O_ALIGN_OLD(attr->shared->ds_size); } /* end if */ @@ -376,23 +368,22 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) p += attr->shared->ds_size; /* Store attribute data. If there's no data, store 0 as fill value. */ - if(attr->shared->data) + if (attr->shared->data) H5MM_memcpy(p, attr->shared->data, attr->shared->data_size); else HDmemset(p, 0, attr->shared->data_size); done: FUNC_LEAVE_NOAPI(ret_value); -} /* end H5O_attr_encode() */ +} /* end H5O__attr_encode() */ - /*-------------------------------------------------------------------------- NAME - H5O_attr_copy + H5O__attr_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE - void *H5O_attr_copy(mesg, dest) + void *H5O__attr_copy(mesg, dest) const void *mesg; IN: Pointer to the source attribute struct const void *dest; IN: Pointer to the destination attribute struct RETURNS @@ -402,31 +393,30 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * -H5O_attr_copy(const void *_src, void *_dst) +H5O__attr_copy(const void *_src, void *_dst) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(_src); /* copy */ - if(NULL == (ret_value = (H5A_t *)H5A__copy((H5A_t *)_dst, (const H5A_t *)_src))) + if (NULL == (ret_value = (H5A_t *)H5A__copy((H5A_t *)_dst, (const H5A_t *)_src))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_copy() */ +} /* end H5O__attr_copy() */ - /*-------------------------------------------------------------------------- NAME - H5O_attr_size + H5O__attr_size PURPOSE Return the raw message size in bytes USAGE - size_t H5O_attr_size(f, mesg) + size_t H5O__attr_size(f, mesg) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source attribute struct RETURNS @@ -437,57 +427,56 @@ H5O_attr_copy(const void *_src, void *_dst) portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_attr_size(const H5F_t H5_ATTR_UNUSED *f, const void *_mesg) +H5O__attr_size(const H5F_t H5_ATTR_UNUSED *f, const void *_mesg) { - const H5A_t *attr = (const H5A_t *)_mesg; - size_t name_len; - size_t ret_value = 0; + const H5A_t *attr = (const H5A_t *)_mesg; + size_t name_len; + size_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(attr); /* Common size information */ - ret_value = 1 + /*version */ - 1 + /*reserved/flags */ - 2 + /*name size inc. null */ - 2 + /*type size */ - 2; /*space size */ + ret_value = 1 + /*version */ + 1 + /*reserved/flags */ + 2 + /*name size inc. null */ + 2 + /*type size */ + 2; /*space size */ /* Length of attribute name */ name_len = HDstrlen(attr->shared->name) + 1; /* Version-specific size information */ - if(attr->shared->version == H5O_ATTR_VERSION_1) - ret_value += H5O_ALIGN_OLD(name_len) + /*attribute name */ - H5O_ALIGN_OLD(attr->shared->dt_size) + /*datatype */ - H5O_ALIGN_OLD(attr->shared->ds_size) + /*dataspace */ - attr->shared->data_size; /*the data itself */ - else if(attr->shared->version == H5O_ATTR_VERSION_2) - ret_value += name_len + /*attribute name */ - attr->shared->dt_size + /*datatype */ - attr->shared->ds_size + /*dataspace */ - attr->shared->data_size; /*the data itself */ - else if(attr->shared->version == H5O_ATTR_VERSION_3) - ret_value += 1 + /*character encoding */ - name_len + /*attribute name */ - attr->shared->dt_size + /*datatype */ - attr->shared->ds_size + /*dataspace */ - attr->shared->data_size; /*the data itself */ + if (attr->shared->version == H5O_ATTR_VERSION_1) + ret_value += H5O_ALIGN_OLD(name_len) + /*attribute name */ + H5O_ALIGN_OLD(attr->shared->dt_size) + /*datatype */ + H5O_ALIGN_OLD(attr->shared->ds_size) + /*dataspace */ + attr->shared->data_size; /*the data itself */ + else if (attr->shared->version == H5O_ATTR_VERSION_2) + ret_value += name_len + /*attribute name */ + attr->shared->dt_size + /*datatype */ + attr->shared->ds_size + /*dataspace */ + attr->shared->data_size; /*the data itself */ + else if (attr->shared->version == H5O_ATTR_VERSION_3) + ret_value += 1 + /*character encoding */ + name_len + /*attribute name */ + attr->shared->dt_size + /*datatype */ + attr->shared->ds_size + /*dataspace */ + attr->shared->data_size; /*the data itself */ else HDassert(0 && "Bad attribute version"); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_size() */ +} /* end H5O__attr_size() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_reset * * Purpose: Frees resources within a attribute message, but doesn't free * the message itself. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Tuesday, December 9, 1997 @@ -502,13 +491,12 @@ H5O__attr_reset(void H5_ATTR_UNUSED *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__attr_reset() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_free + * Function: H5O__attr_free * - * Purpose: Frees the message + * Purpose: Frees the message * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, November 18, 2004 @@ -518,27 +506,26 @@ H5O__attr_reset(void H5_ATTR_UNUSED *_mesg) static herr_t H5O__attr_free(void *mesg) { - H5A_t *attr = (H5A_t *)mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(mesg); - if(H5A__close(attr) < 0) + if (H5A__close(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_free() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_delete * * Purpose: Free file space referenced by message * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, September 26, 2003 @@ -548,8 +535,8 @@ H5O__attr_free(void *mesg) herr_t H5O__attr_delete(H5F_t *f, H5O_t *oh, void *_mesg) { - H5A_t *attr = (H5A_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -558,25 +545,24 @@ H5O__attr_delete(H5F_t *f, H5O_t *oh, void *_mesg) HDassert(attr); /* Decrement reference count on datatype in file */ - if((H5O_MSG_DTYPE->del)(f, oh, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->del)(f, oh, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust datatype link count") /* Decrement reference count on dataspace in file */ - if((H5O_MSG_SDSPACE->del)(f, oh, attr->shared->ds) < 0) + if ((H5O_MSG_SDSPACE->del)(f, oh, attr->shared->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust dataspace link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_link * * Purpose: Increment reference count on any objects referenced by * message * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, September 26, 2003 @@ -586,8 +572,8 @@ H5O__attr_delete(H5F_t *f, H5O_t *oh, void *_mesg) herr_t H5O__attr_link(H5F_t *f, H5O_t *oh, void *_mesg) { - H5A_t *attr = (H5A_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5A_t *attr = (H5A_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -601,25 +587,22 @@ H5O__attr_link(H5F_t *f, H5O_t *oh, void *_mesg) * message is deleted. */ /* Increment reference count on datatype & dataspace in file */ - if((H5O_MSG_DTYPE->link)(f, oh, attr->shared->dt) < 0) + if ((H5O_MSG_DTYPE->link)(f, oh, attr->shared->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust datatype link count") - if((H5O_MSG_SDSPACE->link)(f, oh, attr->shared->ds) < 0) + if ((H5O_MSG_SDSPACE->link)(f, oh, attr->shared->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust dataspace link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_link() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_pre_copy_file + * Function: H5O__attr_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files for attribute messages. * - * Return: Success: Non-negative - * - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, June 26, 2006 @@ -627,13 +610,13 @@ H5O__attr_link(H5F_t *f, H5O_t *oh, void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { - const H5A_t *attr_src = (const H5A_t *)native_src; /* Source attribute */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5A_t *attr_src = (const H5A_t *)native_src; /* Source attribute */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(deleted); @@ -641,28 +624,27 @@ H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, HDassert(cpy_info->file_dst); /* Check to ensure that the version of the message to be copied does not exceed - the message version allowed by the destination file's high bound */ - if(attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + * the message version allowed by the destination file's high bound. + */ + if (attr_src->shared->version > H5O_attr_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "attribute message version out of bounds") /* If we are not copying attributes into the destination file, indicate * that this message should be deleted. */ - if(cpy_info->copy_without_attr) + if (cpy_info->copy_without_attr) *deleted = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_pre_copy_file() */ +} /* end H5O__attr_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_copy_file * * Purpose: Copies a message from _MESG to _DEST in file * * Return: Success: Ptr to _DEST - * * Failure: NULL * * Programmer: Quincey Koziol @@ -671,11 +653,11 @@ H5O_attr_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *native_src, *------------------------------------------------------------------------- */ static void * -H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, + void H5_ATTR_UNUSED *udata) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -688,17 +670,16 @@ H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_ /* Mark datatype as being on disk now. This step used to be done in a lower level * by H5O_dtype_decode. But it has been moved up. Not an ideal place, but no better * place than here. */ - if(H5T_set_loc(((H5A_t *)native_src)->shared->dt, file_src, H5T_LOC_DISK) < 0) + if (H5T_set_loc(((H5A_t *)native_src)->shared->dt, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") - if(NULL == (ret_value = H5A__attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info))) + if (NULL == (ret_value = H5A__attr_copy_file((H5A_t *)native_src, file_dst, recompute_size, cpy_info))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_post_copy_file * @@ -708,7 +689,7 @@ H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_ * an object may have a reference attribute that points to the * object itself. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Peter Cao * March 6, 2005 @@ -716,28 +697,27 @@ H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t H5_ATTR_UNUSED *mesg_ *------------------------------------------------------------------------- */ 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) +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) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(H5A__attr_post_copy_file(src_oloc, (const H5A_t *)mesg_src, dst_oloc, (H5A_t *)mesg_dst, cpy_info) < 0) + if (H5A__attr_post_copy_file(src_oloc, (const H5A_t *)mesg_src, dst_oloc, (H5A_t *)mesg_dst, cpy_info) < + 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_post_copy_file() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_get_crt_index + * Function: H5O__attr_get_crt_index * - * Purpose: Get creation index from the message + * Purpose: Get creation index from the message * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, January 18, 2007 @@ -745,11 +725,11 @@ H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) +H5O__attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) { - const H5A_t *attr = (const H5A_t *)_mesg; + const H5A_t *attr = (const H5A_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(attr); HDassert(crt_idx); @@ -758,16 +738,14 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) *crt_idx = attr->shared->crt_idx; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_attr_get_crt_index() */ +} /* end H5O__attr_get_crt_index() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_set_crt_index + * Function: H5O__attr_set_crt_index * - * Purpose: Set creation index from the message + * Purpose: Set creation index from the message * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, January 18, 2007 @@ -775,11 +753,11 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) +H5O__attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) { - H5A_t *attr = (H5A_t *)_mesg; + H5A_t *attr = (H5A_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(attr); @@ -787,9 +765,8 @@ H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) attr->shared->crt_idx = crt_idx; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_attr_set_crt_index() */ +} /* end H5O__attr_set_crt_index() */ - /*-------------------------------------------------------------------------- NAME H5O__attr_debug @@ -809,12 +786,12 @@ H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwidth) +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 */ - char buf[128]; /* Temporary string buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + const char * s; /* Temporary string pointer */ + char buf[128]; /* Temporary string buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -824,10 +801,8 @@ H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwid HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, - "Name:", - mesg->shared->name); - switch(mesg->shared->encoding) { + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Name:", mesg->shared->name); + switch (mesg->shared->encoding) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -860,37 +835,28 @@ H5O__attr_debug(H5F_t *f, const void *_mesg, FILE * stream, int indent, int fwid s = buf; break; } /* end switch */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set of Name:", s); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set of Name:", - s); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Object opened:", - mesg->obj_opened); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object:", - mesg->oloc.addr); + "Object opened:", mesg->obj_opened ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Object:", mesg->oloc.addr); /* Check for attribute creation order index on the attribute */ - if(mesg->shared->crt_idx != H5O_MAX_CRT_ORDER_IDX) + if (mesg->shared->crt_idx != H5O_MAX_CRT_ORDER_IDX) HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Creation Index:", - (unsigned)mesg->shared->crt_idx); + "Creation Index:", (unsigned)mesg->shared->crt_idx); HDfprintf(stream, "%*sDatatype...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0,fwidth - 3), - "Encoded Size:", - (unsigned long)(mesg->shared->dt_size)); - if((H5O_MSG_DTYPE->debug)(f, mesg->shared->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), + "Encoded Size:", (unsigned long)(mesg->shared->dt_size)); + if ((H5O_MSG_DTYPE->debug)(f, mesg->shared->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display datatype message info") HDfprintf(stream, "%*sDataspace...\n", indent, ""); HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), - "Encoded Size:", - (unsigned long)(mesg->shared->ds_size)); - if(H5S_debug(f, mesg->shared->ds, stream, indent + 3, MAX(0, fwidth - 3)) < 0) + "Encoded Size:", (unsigned long)(mesg->shared->ds_size)); + if (H5S_debug(f, mesg->shared->ds, stream, indent + 3, MAX(0, fwidth - 3)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display dataspace message info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_debug() */ - diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index da8f9c58f95..b21a6549c0e 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,135 +24,121 @@ /* Module Setup */ /****************/ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#define H5A_FRIEND /* Suppress error about including H5Apkg.h */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Fprivate.h" /* File */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Fprivate.h" /* File */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for iteration when converting attributes to dense storage */ typedef struct { - H5F_t *f; /* Pointer to file for insertion */ - H5O_ainfo_t *ainfo; /* Attribute info struct */ + H5F_t * f; /* Pointer to file for insertion */ + H5O_ainfo_t *ainfo; /* Attribute info struct */ } H5O_iter_cvt_t; /* User data for iteration when opening an attribute */ typedef struct { /* down */ - const char *name; /* Name of attribute to open */ + const char *name; /* Name of attribute to open */ /* up */ - H5A_t *attr; /* Attribute data to update object header with */ + H5A_t *attr; /* Attribute data to update object header with */ } H5O_iter_opn_t; /* User data for iteration when updating an attribute */ typedef struct { /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - H5A_t *attr; /* Attribute data to update object header with */ + H5F_t *f; /* Pointer to file attribute is in */ + H5A_t *attr; /* Attribute data to update object header with */ /* up */ - hbool_t found; /* Whether the attribute was found */ + hbool_t found; /* Whether the attribute was found */ } H5O_iter_wrt_t; /* User data for iteration when renaming an attribute */ typedef struct { /* down */ - 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 */ + 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 */ /* up */ - hbool_t found; /* Whether the attribute was found */ + hbool_t found; /* Whether the attribute was found */ } H5O_iter_ren_t; -/* User data for iteration when iterating over attributes */ -typedef struct { - /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - hid_t loc_id; /* ID of object being iterated over */ - unsigned skip; /* # of attributes to skip over */ - H5A_operator_t op; /* Callback routine for each attribute */ - void *op_data; /* User data for callback */ - - /* up */ - unsigned count; /* Count of attributes examined */ -} H5O_iter_itr_t; - /* User data for iteration when removing an attribute */ typedef struct { /* down */ - H5F_t *f; /* Pointer to file attribute is in */ - const char *name; /* Name of attribute to open */ + H5F_t * f; /* Pointer to file attribute is in */ + const char *name; /* Name of attribute to open */ /* up */ - hbool_t found; /* Found attribute to delete */ + hbool_t found; /* Found attribute to delete */ } H5O_iter_rm_t; -/* User data for iteration when checking if an attribute exists */ -typedef struct { - /* down */ - const char *name; /* Name of attribute to open */ - - /* up */ - hbool_t found; /* Found attribute */ -} H5O_iter_xst_t; - - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static htri_t H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, - const char* name_to_open); +static herr_t H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); +static htri_t H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char *name_to_open); +static herr_t H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata); +static herr_t H5O__attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr); +static herr_t H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); +static herr_t H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg, + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata); +static herr_t H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); +static herr_t H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo); +static herr_t H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata); +static herr_t H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg, + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5O_attr_to_dense_cb + * Function: H5O__attr_to_dense_cb * - * Purpose: Object header iterator callback routine to convert compact + * Purpose: Object header iterator callback routine to convert compact * attributes to dense attributes * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 4 2006 @@ -160,14 +146,14 @@ static htri_t H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, *------------------------------------------------------------------------- */ static herr_t -H5O_attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + 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 */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + 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 */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -178,12 +164,12 @@ H5O_attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(attr); /* Insert attribute into dense storage */ - if(H5A__dense_insert(udata->f, udata->ainfo, attr) < 0) + if (H5A__dense_insert(udata->f, udata->ainfo, attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Convert message into a null message in the header */ /* (don't delete attribute's space in the file though) */ - if(H5O_release_mesg(udata->f, oh, mesg, FALSE) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") /* Indicate that the object header was modified */ @@ -191,15 +177,14 @@ H5O_attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_to_dense_cb() */ +} /* end H5O__attr_to_dense_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_create + * Function: H5O__attr_create * - * Purpose: Create a new attribute in the object header. + * Purpose: Create a new attribute in the object header. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, December 8, 2006 @@ -209,10 +194,10 @@ H5O_attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, herr_t H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) { - 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 */ + 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 */ FUNC_ENTER_NOAPI_NOINIT @@ -221,26 +206,26 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) HDassert(attr); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check if this object already has attribute information */ - if(oh->version > H5O_VERSION_1) { - hbool_t new_ainfo = FALSE; /* Flag to indicate that the attribute information is new */ - htri_t ainfo_exists; /* Whether the attribute info was retrieved */ + if (oh->version > H5O_VERSION_1) { + hbool_t new_ainfo = FALSE; /* Flag to indicate that the attribute information is new */ + htri_t ainfo_exists; /* Whether the attribute info was retrieved */ /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - if(!ainfo_exists) { + if (!ainfo_exists) { /* Initialize attribute information */ - ainfo.track_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? TRUE : FALSE); - ainfo.index_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? TRUE : FALSE); - ainfo.max_crt_idx = 0; + ainfo.track_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? TRUE : FALSE); + ainfo.index_corder = (hbool_t)((oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? TRUE : FALSE); + ainfo.max_crt_idx = 0; ainfo.corder_bt2_addr = HADDR_UNDEF; - ainfo.nattrs = 0; - ainfo.fheap_addr = HADDR_UNDEF; - ainfo.name_bt2_addr = HADDR_UNDEF; + ainfo.nattrs = 0; + ainfo.fheap_addr = HADDR_UNDEF; + ainfo.name_bt2_addr = HADDR_UNDEF; /* Set flag to add attribute information to object header */ new_ainfo = TRUE; @@ -253,46 +238,47 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) } /* end else */ /* 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 */ - size_t raw_size = 0; /* Raw size of message */ + if (!H5F_addr_defined(ainfo.fheap_addr)) { + htri_t sharable; /* 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) + if ((sharable = 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 (sharable == 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)) { - H5O_iter_cvt_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + if (ainfo.nattrs == oh->max_compact || (!sharable && raw_size >= H5O_MESG_MAX_SIZE)) { + H5O_iter_cvt_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Create dense storage for attributes */ - if(H5A__dense_create(loc->file, &ainfo) < 0) + if (H5A__dense_create(loc->file, &ainfo) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create dense storage for attributes") /* Set up user data for callback */ - udata.f = loc->file; + udata.f = loc->file; udata.ainfo = &ainfo; /* Iterate over existing attributes, moving them to dense storage */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_to_dense_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, "error converting attributes to dense storage") + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_to_dense_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, + "error converting attributes to dense storage") } /* end if */ - } /* end if */ + } /* end if */ /* Increment attribute count on object */ ainfo.nattrs++; /* Check whether we're tracking the creation index on attributes */ - if(ainfo.track_corder) { + if (ainfo.track_corder) { /* Check for attribute creation order index on the object wrapping around */ - if(ainfo.max_crt_idx == H5O_MAX_CRT_ORDER_IDX) + if (ainfo.max_crt_idx == H5O_MAX_CRT_ORDER_IDX) HGOTO_ERROR(H5E_ATTR, H5E_CANTINC, FAIL, "attribute creation index can't be incremented") /* Set the creation order index on the attribute & incr. creation order index */ @@ -303,14 +289,13 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) attr->shared->crt_idx = H5O_MAX_CRT_ORDER_IDX; /* Add the attribute information message, if one is needed */ - if(new_ainfo) { - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) + if (new_ainfo) { + if (H5O__msg_append_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute info message") } /* end if */ /* Otherwise, update existing message */ - else - if(H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") + else if (H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, &ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") } /* end if */ else { /* Set "bogus" creation index for attribute */ @@ -321,28 +306,29 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) } /* end else */ /* Check for storing attribute with dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Insert attribute into dense storage */ - if(H5A__dense_insert(loc->file, &ainfo, attr) < 0) + if (H5A__dense_insert(loc->file, &ainfo, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage") } /* end if */ 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") + 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") /* Increment reference count for shared attribute object for the * object handle created by the caller function H5A__create. The count * for the cached object header has been incremented in the step above - * (in H5O__msg_append_real). The dense storage doesn't need a count. */ + * (in H5O__msg_append_real). The dense storage doesn't need a count. + */ attr->shared->nrefs += 1; /* Was new attribute shared? */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) { - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, attr)) > 0) { + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ /* Retrieve ref count for shared attribute */ - if(H5SM_get_refcount(loc->file, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(loc->file, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If this is not the first copy of the attribute in the shared message @@ -368,33 +354,32 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) * * *ick* -QAK, 2007/01/08 */ - if(attr_rc > 1) { - if(H5O__attr_delete(loc->file, oh, attr) < 0) + if (attr_rc > 1) { + if (H5O__attr_delete(loc->file, oh, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end if */ - } /* end if */ - else if(shared_mesg < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") + } /* end if */ + else if (shared_mesg < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_create() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_open_cb + * Function: H5O__attr_open_cb * - * Purpose: Object header iterator callback routine to open an + * Purpose: Object header iterator callback routine to open an * attribute stored compactly. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 @@ -402,13 +387,13 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5O_iter_opn_t *udata = (H5O_iter_opn_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_opn_t *udata = (H5O_iter_opn_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -416,15 +401,14 @@ H5O_attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(!udata->attr); /* Check for correct attribute message to modify */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Make a copy of the attribute to return */ - if(NULL == (udata->attr = H5A__copy(NULL, (H5A_t *)mesg->native))) + if (NULL == (udata->attr = H5A__copy(NULL, (H5A_t *)mesg->native))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy attribute") /* Assign [somewhat arbitrary] creation order value, for older versions * of the format or if creation order is not tracked */ - if(oh->version == H5O_VERSION_1 - || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + if (oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) udata->attr->shared->crt_idx = sequence; /* Stop iterating */ @@ -433,15 +417,14 @@ H5O_attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_open_cb() */ +} /* end H5O__attr_open_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_open_by_name + * Function: H5O__attr_open_by_name * - * Purpose: Open an existing attribute in an object header. + * Purpose: Open an existing attribute in an object header. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, December 11, 2006 @@ -451,12 +434,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_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 */ - htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value = NULL; /* Return value */ + 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 */ + htri_t found_open_attr = FALSE; /* Whether opened object is found */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -465,49 +448,49 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) HDassert(name); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, NULL, "unable to load object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't check for attribute info message") } /* end if */ /* If found the attribute is already opened, make a copy of it to share the * object information. If not, open attribute as a new object */ - if((found_open_attr = H5O_attr_find_opened_attr(loc, &exist_attr, name)) < 0) + if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute") - else if(found_open_attr == TRUE) { - if(NULL == (opened_attr = H5A__copy(NULL, exist_attr))) + else if (found_open_attr == TRUE) { + if (NULL == (opened_attr = H5A__copy(NULL, exist_attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute") } /* end else if */ else { /* Check for attributes in dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Open attribute with dense storage */ - if(NULL == (opened_attr = H5A__dense_open(loc->file, &ainfo, name))) + if (NULL == (opened_attr = H5A__dense_open(loc->file, &ainfo, name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") } /* end if */ else { - H5O_iter_opn_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_opn_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ udata.name = name; udata.attr = NULL; /* Iterate over attributes, to locate correct one to open */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_open_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_open_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "error updating attribute") /* Check that we found the attribute */ - if(!udata.attr) + if (!udata.attr) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute: '%s'", name) /* Get attribute opened from object header */ @@ -516,7 +499,7 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) } /* end else */ /* Mark datatype as being on disk now */ - if(H5T_set_loc(opened_attr->shared->dt, loc->file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") } /* end else */ @@ -524,25 +507,23 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) ret_value = opened_attr; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, NULL, "unable to release object header") /* Release any resources, on error */ - if(NULL == ret_value && opened_attr) - if(H5A__close(opened_attr) < 0) + if (NULL == ret_value && opened_attr) + if (H5A__close(opened_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_open_by_name() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_open_by_idx_cb + * Function: H5O__attr_open_by_idx_cb * - * Purpose: Callback routine opening an attribute by index + * Purpose: Callback routine opening an attribute by index * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 18 2006 @@ -550,33 +531,32 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr) +H5O__attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr) { - H5A_t **ret_attr = (H5A_t **)_ret_attr; /* 'User data' passed in */ - herr_t ret_value = H5_ITER_STOP; /* Return value */ + H5A_t **ret_attr = (H5A_t **)_ret_attr; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_STOP; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check arguments */ HDassert(attr); HDassert(ret_attr); /* Copy attribute information. Shared some attribute information. */ - if(NULL == (*ret_attr = H5A__copy(NULL, attr))) + if (NULL == (*ret_attr = H5A__copy(NULL, attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_open_by_idx_cb() */ +} /* end H5O__attr_open_by_idx_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_open_by_idx + * Function: H5O__attr_open_by_idx * - * Purpose: Open an existing attribute in an object header according to + * Purpose: Open an existing attribute in an object header according to * an index. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, December 18, 2006 @@ -584,14 +564,13 @@ H5O_attr_open_by_idx_cb(const H5A_t *attr, void *_ret_attr) *------------------------------------------------------------------------- */ 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) +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 */ - htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t *ret_value = NULL; /* Return value */ + 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 */ + htri_t found_open_attr = FALSE; /* Whether opened object is found */ + H5A_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -599,55 +578,55 @@ H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, HDassert(loc); /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_LIB; - attr_op.u.lib_op = H5O_attr_open_by_idx_cb; + attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.u.lib_op = H5O__attr_open_by_idx_cb; /* Iterate over attributes to locate correct one */ - if(H5O_attr_iterate_real((hid_t)-1, loc, idx_type, order, n, NULL, &attr_op, &opened_attr) < 0) + if (H5O_attr_iterate_real((hid_t)-1, loc, idx_type, order, n, NULL, &attr_op, &opened_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, NULL, "can't locate attribute") /* Find out whether it has already been opened. If it has, close the object * and make a copy of the already opened object to share the object info. */ - if(opened_attr) { - if((found_open_attr = H5O_attr_find_opened_attr(loc, &exist_attr, opened_attr->shared->name)) < 0) + if (opened_attr) { + if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, opened_attr->shared->name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute") /* If found that the attribute is already opened, make a copy of it * and close the object just opened. */ - if(found_open_attr && exist_attr) { - if(H5A__close(opened_attr) < 0) + if (found_open_attr && exist_attr) { + if (H5A__close(opened_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") - if(NULL == (opened_attr = H5A__copy(NULL, exist_attr))) + if (NULL == (opened_attr = H5A__copy(NULL, exist_attr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute") - } else { + } + else { /* Mark datatype as being on disk now */ - if(H5T_set_loc(opened_attr->shared->dt, loc->file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location") } /* end if */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = opened_attr; done: /* Release any resources, on error */ - if(NULL == ret_value && opened_attr) - if(H5A__close(opened_attr) < 0) + if (NULL == ret_value && opened_attr) + if (H5A__close(opened_attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_open_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_find_opened_attr + * Function: H5O__attr_find_opened_attr * - * Purpose: Find out whether an attribute has been opened by giving + * Purpose: Find out whether an attribute has been opened by giving * the name. Return the pointer to the object if found. * - * Return: TRUE: found the already opened object + * Return: TRUE: found the already opened object * FALSE: didn't find the opened object * FAIL: function failed. * @@ -657,77 +636,76 @@ H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, *------------------------------------------------------------------------- */ static htri_t -H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* name_to_open) +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 */ - unsigned long loc_fnum; /* File serial # for object */ - size_t num_open_attr; /* Number of opened attributes */ - htri_t ret_value = FALSE; /* Return value */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get file serial number for the location of attribute */ - if(H5F_get_fileno(loc->file, &loc_fnum) < 0) + if (H5F_get_fileno(loc->file, &loc_fnum) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "can't get file serial number") /* Count all opened attributes */ - if(H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, FALSE, &num_open_attr) < 0) + if (H5F_get_obj_count(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, FALSE, &num_open_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't count opened attributes") /* Find out whether the attribute has been opened */ - if(num_open_attr) { - size_t check_num_attr; /* Number of open attribute IDs */ - size_t u; /* Local index variable */ + if (num_open_attr) { + size_t check_num_attr; /* Number of open attribute IDs */ + size_t u; /* Local index variable */ /* Allocate space for the attribute ID list */ - if(NULL == (attr_id_list = (hid_t *)H5MM_malloc(num_open_attr * sizeof(hid_t)))) + if (NULL == (attr_id_list = (hid_t *)H5MM_malloc(num_open_attr * sizeof(hid_t)))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "unable to allocate memory for attribute ID list") /* Retrieve the IDs of all opened attributes */ - if(H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list, FALSE, &check_num_attr) < 0) + if (H5F_get_obj_ids(loc->file, H5F_OBJ_ATTR | H5F_OBJ_LOCAL, num_open_attr, attr_id_list, FALSE, + &check_num_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get IDs of opened attributes") - if(check_num_attr != num_open_attr) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "open attribute count mismatch") + if (check_num_attr != num_open_attr) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "open attribute count mismatch") /* Iterate over the attributes */ - for(u = 0; u < num_open_attr; u++) { - unsigned long attr_fnum; /* Attributes file serial number */ + for (u = 0; u < num_open_attr; u++) { + unsigned long attr_fnum; /* Attributes file serial number */ /* Get pointer to attribute */ - if(NULL == (*attr = (H5A_t *)H5I_object_verify(attr_id_list[u], H5I_ATTR))) + if (NULL == (*attr = (H5A_t *)H5VL_object_verify(attr_id_list[u], H5I_ATTR))) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "not an attribute") /* Get file serial number for attribute */ - if(H5F_get_fileno((*attr)->oloc.file, &attr_fnum) < 0) + if (H5F_get_fileno((*attr)->oloc.file, &attr_fnum) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "can't get file serial number") /* Verify whether it's the right object. The attribute name, object * address to which the attribute is attached, and file serial * number should all match. */ - if(!HDstrcmp(name_to_open, (*attr)->shared->name) && - loc->addr == (*attr)->oloc.addr && - loc_fnum == attr_fnum) { + if (!HDstrcmp(name_to_open, (*attr)->shared->name) && loc->addr == (*attr)->oloc.addr && + loc_fnum == attr_fnum) { ret_value = TRUE; break; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ done: - if(attr_id_list) + if (attr_id_list) H5MM_free(attr_id_list); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_find_opened_attr */ +} /* end H5O__attr_find_opened_attr() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_update_shared + * Function: H5O__attr_update_shared * - * Purpose: Update a shared attribute. + * Purpose: Update a shared attribute. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Jan 2 2007 @@ -737,10 +715,10 @@ H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* name_t herr_t H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_sh_mesg) { - H5O_shared_t sh_mesg; /* Shared object header message */ - hsize_t attr_rc; /* Attribute's ref count in shared message storage */ - htri_t shared_mesg; /* Whether the message should be shared */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t sh_mesg; /* Shared object header message */ + hsize_t attr_rc; /* Attribute's ref count in shared message storage */ + htri_t shared_mesg; /* Whether the message should be shared */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -749,22 +727,22 @@ H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_s HDassert(attr); /* Extract shared message info from current attribute (for later use) */ - if(H5O_set_shared(&sh_mesg, &(attr->sh_loc)) < 0) + if (H5O_set_shared(&sh_mesg, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message") /* Reset existing sharing information */ - if(H5O_msg_reset_share(H5O_ATTR_ID, attr) < 0) + if (H5O_msg_reset_share(H5O_ATTR_ID, attr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset attribute sharing") /* Store new version of message as a SOHM */ /* (should always work, since we're not changing the size of the attribute) */ - if((shared_mesg = H5SM_try_share(f, oh, 0, H5O_ATTR_ID, attr, NULL)) == 0) + if ((shared_mesg = H5SM_try_share(f, oh, 0, H5O_ATTR_ID, attr, NULL)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "attribute changed sharing status") - else if(shared_mesg < 0) + else if (shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't share attribute") /* Retrieve shared message storage ref count for new shared attribute */ - if(H5SM_get_refcount(f, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) + if (H5SM_get_refcount(f, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") /* If the newly shared attribute needs to share "ownership" of the shared @@ -776,52 +754,47 @@ H5O__attr_update_shared(H5F_t *f, H5O_t *oh, H5A_t *attr, H5O_shared_t *update_s * * *ick* -QAK, 2007/01/08 */ - if(attr_rc == 1) + if (attr_rc == 1) /* Increment reference count on attribute components */ - if(H5O__attr_link(f, oh, attr) < 0) + if (H5O__attr_link(f, oh, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") /* Remove the old attribute from the SOHM storage */ - if(H5SM_delete(f, oh, &sh_mesg) < 0) + if (H5SM_delete(f, oh, &sh_mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to delete shared attribute in shared storage") /* Extract updated shared message info from modified attribute, if requested */ - if(update_sh_mesg) - if(H5O_set_shared(update_sh_mesg, &(attr->sh_loc)) < 0) + if (update_sh_mesg) + if (H5O_set_shared(update_sh_mesg, &(attr->sh_loc)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't get shared message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_update_shared() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_write_cb + * Function: H5O__attr_write_cb * - * Purpose: Object header iterator callback routine to update an + * Purpose: Object header iterator callback routine to update an * attribute stored compactly. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 4 2006 * - * Modification:Raymond Lu - * 4 June 2008 - * Took out the data copying part because the attribute data - * is shared between attribute handle and object header. *------------------------------------------------------------------------- */ 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__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_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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -829,15 +802,15 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for correct attribute message to modify */ - if(0 == HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->attr->shared->name)) { + if (0 == HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->attr->shared->name)) { /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load object header chunk") /* Because the attribute structure is shared now. The only situation that requires * copying the data is when the metadata cache evicts and reloads this attribute. * The shared attribute structure will be different in that situation. SLU-2010/7/29 */ - if(((H5A_t *)mesg->native)->shared != udata->attr->shared) { + if (((H5A_t *)mesg->native)->shared != udata->attr->shared) { /* Sanity check */ HDassert(((H5A_t *)mesg->native)->shared->data); HDassert(udata->attr->shared->data); @@ -845,7 +818,8 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, /* (Needs to occur before updating the shared message, or the hash * value on the old & new messages will be the same) */ - H5MM_memcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, udata->attr->shared->data_size); + H5MM_memcpy(((H5A_t *)mesg->native)->shared->data, udata->attr->shared->data, + udata->attr->shared->data_size); } /* end if */ /* Mark the message as modified */ @@ -853,14 +827,15 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") chk_proxy = NULL; /* Update the shared attribute in the SOHM storage */ - if(mesg->flags & H5O_MSG_FLAG_SHARED) - if(H5O__attr_update_shared(udata->f, oh, udata->attr, (H5O_shared_t *)mesg->native) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, "unable to update attribute in shared storage") + if (mesg->flags & H5O_MSG_FLAG_SHARED) + if (H5O__attr_update_shared(udata->f, oh, udata->attr, (H5O_shared_t *)mesg->native) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, + "unable to update attribute in shared storage") /* Indicate that the object header was modified */ *oh_modified = H5O_MODIFY; @@ -874,19 +849,18 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_write_cb() */ +} /* end H5O__attr_write_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_write + * Function: H5O__attr_write * - * Purpose: Write a new value to an attribute. + * Purpose: Write a new value to an attribute. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, December 4, 2006 @@ -896,9 +870,9 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, herr_t H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -907,62 +881,61 @@ H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) HDassert(attr); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Modify the attribute data in dense storage */ - if(H5A__dense_write(loc->file, &ainfo, attr) < 0) + if (H5A__dense_write(loc->file, &ainfo, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { - H5O_iter_wrt_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_wrt_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.attr = attr; + udata.f = loc->file; + udata.attr = attr; udata.found = FALSE; /* Iterate over attributes, to locate correct one to update */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_write_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_write_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate open attribute?") } /* end else */ /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_write */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_rename_chk_cb + * Function: H5O__attr_rename_chk_cb * - * Purpose: Object header iterator callback routine to check for + * Purpose: Object header iterator callback routine to check for * duplicate name during rename * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 5 2006 @@ -970,13 +943,14 @@ H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, + unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, + void *_udata /*in,out*/) { - H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(oh); @@ -984,7 +958,7 @@ H5O_attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for existing attribute with new name */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->new_name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->new_name) == 0) { /* Indicate that we found an existing attribute with the new name*/ udata->found = TRUE; @@ -993,21 +967,20 @@ H5O_attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_rename_chk_cb() */ +} /* end H5O__attr_rename_chk_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_rename_mod_cb + * Function: H5O__attr_rename_mod_cb * - * Purpose: Object header iterator callback routine to change name of + * Purpose: Object header iterator callback routine to change name of * attribute during rename * - * Note: This routine doesn't currently allow an attribute to change + * Note: This routine doesn't currently allow an attribute to change * its "shared" status, if the name change would cause a size * difference that would put it into a different category. * Something for later... * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 5 2006 @@ -1015,15 +988,15 @@ H5O_attr_rename_chk_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, *------------------------------------------------------------------------- */ 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__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_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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -1031,11 +1004,11 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Find correct attribute message to rename */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->old_name) == 0) { - unsigned old_version = ((H5A_t *)mesg->native)->shared->version; /* Old version of the attribute */ + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->old_name) == 0) { + unsigned old_version = ((H5A_t *)mesg->native)->shared->version; /* Old version of the attribute */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(udata->f, oh, mesg->chunkno))) HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load object header chunk") /* Change the name for the attribute */ @@ -1043,7 +1016,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, ((H5A_t *)mesg->native)->shared->name = H5MM_xstrdup(udata->new_name); /* Recompute the version to encode the attribute with */ - if(H5A__set_version(udata->f, ((H5A_t *)mesg->native)) < 0) + if (H5A__set_version(udata->f, ((H5A_t *)mesg->native)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5_ITER_ERROR, "unable to update attribute version") /* Mark the message as modified */ @@ -1051,24 +1024,25 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") chk_proxy = NULL; /* Check for shared message */ - if(mesg->flags & H5O_MSG_FLAG_SHARED) { + if (mesg->flags & H5O_MSG_FLAG_SHARED) { /* Update the shared attribute in the SOHM storage */ - if(H5O__attr_update_shared(udata->f, oh, (H5A_t *)mesg->native, NULL) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, "unable to update attribute in shared storage") + if (H5O__attr_update_shared(udata->f, oh, (H5A_t *)mesg->native, NULL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, H5_ITER_ERROR, + "unable to update attribute in shared storage") } /* end if */ else { /* Sanity check */ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, (H5A_t *)mesg->native) == FALSE); /* Check for attribute message changing size */ - if(HDstrlen(udata->new_name) != HDstrlen(udata->old_name) || - old_version != ((H5A_t *)mesg->native)->shared->version) { - H5A_t *attr; /* Attribute to re-add */ + if (HDstrlen(udata->new_name) != HDstrlen(udata->old_name) || + old_version != ((H5A_t *)mesg->native)->shared->version) { + H5A_t *attr; /* Attribute to re-add */ /* Take ownership of the message's native info (the attribute) * so any shared objects in the file aren't adjusted (and @@ -1080,22 +1054,25 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, * list of messages during the "add the modified attribute" * step, invalidating the message pointer we have here - QAK) */ - attr = (H5A_t *)mesg->native; + attr = (H5A_t *)mesg->native; mesg->native = NULL; /* Delete old attribute */ /* (doesn't decrement the link count on shared components because * the "native" pointer has been reset) */ - if(H5O_release_mesg(udata->f, oh, mesg, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to release previous attribute") + if (H5O__release_mesg(udata->f, oh, mesg, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, + "unable to release previous attribute") - *oh_modified = H5O_MODIFY_CONDENSE; + *oh_modified = H5O_MODIFY_CONDENSE; /* Append renamed attribute to object header */ /* (Don't let it become shared) */ - if(H5O__msg_append_real(udata->f, oh, H5O_MSG_ATTR, (mesg->flags | H5O_MSG_FLAG_DONTSHARE), 0, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to relocate renamed attribute in header") + if (H5O__msg_append_real(udata->f, oh, H5O_MSG_ATTR, (mesg->flags | H5O_MSG_FLAG_DONTSHARE), + 0, attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, + "unable to relocate renamed attribute in header") /* Sanity check */ HDassert(H5O_msg_is_shared(H5O_ATTR_ID, attr) == FALSE); @@ -1103,7 +1080,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, /* Close the local copy of the attribute */ H5A__close(attr); } /* end if */ - } /* end else */ + } /* end else */ /* Indicate that the object header was modified */ *oh_modified |= H5O_MODIFY; @@ -1117,19 +1094,18 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: /* Release chunk, if not already done */ - if(chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_rename_mod_cb() */ +} /* end H5O__attr_rename_mod_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_rename + * Function: H5O__attr_rename * - * Purpose: Rename an attribute. + * Purpose: Rename an attribute. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, December 5, 2006 @@ -1137,12 +1113,11 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, *------------------------------------------------------------------------- */ herr_t -H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, - const char *new_name) +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_ainfo_t ainfo; /* Attribute information for object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1152,72 +1127,71 @@ H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, HDassert(new_name); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Rename the attribute data in dense storage */ - if(H5A__dense_rename(loc->file, &ainfo, old_name, new_name) < 0) + if (H5A__dense_rename(loc->file, &ainfo, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") } /* end if */ else { - H5O_iter_ren_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_ren_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; + udata.f = loc->file; udata.old_name = old_name; udata.new_name = new_name; - udata.found = FALSE; + udata.found = FALSE; /* Iterate over attributes, to check if "new name" exists already */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_rename_chk_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_rename_chk_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* If the new name was found, indicate an error */ - if(udata.found) + if (udata.found) HGOTO_ERROR(H5E_ATTR, H5E_EXISTS, FAIL, "attribute with new name already exists") /* Iterate over attributes again, to actually rename attribute with old name */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_rename_mod_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_rename_mod_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "error updating attribute") /* Check that we found the attribute to rename */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute with old name") } /* end else */ /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5O__attr_rename */ +} /* end H5O__attr_rename() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_iterate_real + * Function: H5O_attr_iterate_real * - * Purpose: Internal routine to iterate over attributes for an object. + * Purpose: Internal routine to iterate over attributes for an object. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, December 5, 2006 @@ -1225,14 +1199,13 @@ H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, *------------------------------------------------------------------------- */ 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_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_ainfo_t ainfo; /* Attribute information for object */ - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_NOINIT_TAG(loc->addr) @@ -1243,68 +1216,68 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, HDassert(attr_op); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for skipping too many attributes */ - if(skip > 0 && skip >= ainfo.nattrs) + if (skip > 0 && skip >= ainfo.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") oh = NULL; /* Iterate over attributes in dense storage */ - if((ret_value = H5A__dense_iterate(loc->file, loc_id, &ainfo, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) + if ((ret_value = H5A__dense_iterate(loc->file, loc_id, &ainfo, idx_type, order, skip, last_attr, + attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); } /* end if */ else { /* Build table of attributes for compact storage */ - if(H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) + if (H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") oh = NULL; /* Check for skipping too many attributes */ - if(skip > 0 && skip >= atable.nattrs) + if (skip > 0 && skip >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Iterate over attributes in table */ - if((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); + if ((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "iteration operator failed"); } /* end else */ done: /* Release resources */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_attr_iterate_real() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_iterate + * Function: H5O__attr_iterate * - * Purpose: Iterate over attributes for an object. + * Purpose: Iterate over attributes for an object. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, December 5, 2006 @@ -1312,12 +1285,11 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, *------------------------------------------------------------------------- */ herr_t -H5O__attr_iterate(hid_t loc_id, 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__attr_iterate(hid_t loc_id, 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) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = FAIL; /* Return value */ + H5G_loc_t loc; /* Object location */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1325,24 +1297,24 @@ H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, HDassert(attr_op); /* Look up location for location ID */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Iterate over attributes to locate correct one */ - if((ret_value = H5O_attr_iterate_real(loc_id, loc.oloc, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) + if ((ret_value = + H5O_attr_iterate_real(loc_id, loc.oloc, idx_type, order, skip, last_attr, attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_iterate() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_remove_update + * Function: H5O__attr_remove_update * - * Purpose: Check for reverting from dense to compact attribute storage + * Purpose: Check for reverting from dense to compact attribute storage * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Wednesday, February 14, 2007 @@ -1358,12 +1330,12 @@ H5O__attr_iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, *------------------------------------------------------------------------- */ static herr_t -H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) +H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) { - H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - herr_t ret_value = SUCCEED; /* Return value */ + H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ HDassert(loc); @@ -1374,40 +1346,41 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) ainfo->nattrs--; /* Check for shifting from dense storage back to compact storage */ - if(H5F_addr_defined(ainfo->fheap_addr) && ainfo->nattrs < oh->min_dense) { - hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ - size_t u; /* Local index */ + if (H5F_addr_defined(ainfo->fheap_addr) && ainfo->nattrs < oh->min_dense) { + hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ + size_t u; /* Local index */ /* Build the table of attributes for this object */ - if(H5A__dense_build_table(loc->file, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) + if (H5A__dense_build_table(loc->file, ainfo, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Inspect attributes in table for ones that can't be converted back * into attribute message form (currently only attributes which * can't fit into an object header message) */ - for(u = 0; u < ainfo->nattrs; u++) - if(H5O_msg_size_oh(loc->file, oh, H5O_ATTR_ID, (atable.attrs[u]), (size_t)0) >= H5O_MESG_MAX_SIZE) { + for (u = 0; u < ainfo->nattrs; u++) + if (H5O_msg_size_oh(loc->file, oh, H5O_ATTR_ID, (atable.attrs[u]), (size_t)0) >= + H5O_MESG_MAX_SIZE) { can_convert = FALSE; break; } /* end if */ /* If ok, insert attributes as object header messages */ - if(can_convert) { - H5A_t *exist_attr = NULL; + if (can_convert) { + H5A_t *exist_attr = NULL; htri_t found_open_attr = FALSE; /* Iterate over attributes, to put them into header */ - for(u = 0; u < ainfo->nattrs; u++) { - htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ + for (u = 0; u < ainfo->nattrs; u++) { + htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ /* Check if attribute is shared */ - if((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, (atable.attrs[u]))) < 0) + if ((shared_mesg = H5O_msg_is_shared(H5O_ATTR_ID, (atable.attrs[u]))) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg == 0) { + else if (shared_mesg == 0) { /* Increment reference count on attribute components */ /* (so that they aren't deleted when the dense attribute storage is deleted) */ - if(H5O__attr_link(loc->file, oh, (atable.attrs[u])) < 0) + if (H5O__attr_link(loc->file, oh, (atable.attrs[u])) < 0) HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count") } /* end if */ else { @@ -1418,57 +1391,57 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) /* Insert attribute message into object header (Will increment reference count on shared attributes) */ /* Find out whether the attribute has been opened */ - if((found_open_attr = H5O_attr_find_opened_attr(loc, &exist_attr, (atable.attrs[u])->shared->name)) < 0) + if ((found_open_attr = + H5O__attr_find_opened_attr(loc, &exist_attr, (atable.attrs[u])->shared->name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "failed in finding opened attribute") /* If found the attribute is already opened, use the opened message to insert. If not, still use the message in the attribute table. */ - if(found_open_attr && exist_attr) { - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, exist_attr) < 0) + if (found_open_attr && exist_attr) { + if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, exist_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ - else - if(H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, (atable.attrs[u])) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") + else if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, (atable.attrs[u])) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") } /* end for */ /* Remove the dense storage */ - if(H5A__dense_delete(loc->file, ainfo) < 0) + if (H5A__dense_delete(loc->file, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") } /* end if */ - } /* end if */ + } /* end if */ /* Update the message after removing the attribute */ /* This is particularly needed when removing the last attribute that is - accessed via fractal heap/v2 B-tree (HDFFV-9277) */ - if(H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, ainfo) < 0) + * accessed via fractal heap/v2 B-tree (HDFFV-9277) + */ + if (H5O__msg_write_real(loc->file, oh, H5O_MSG_AINFO, H5O_MSG_FLAG_DONTSHARE, 0, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info message") /* Check if we have deleted all the attributes and the attribute info * message should be deleted itself. */ - if(ainfo->nattrs == 0) { - if(H5O__msg_remove_real(loc->file, oh, H5O_MSG_AINFO, H5O_ALL, NULL, NULL, TRUE) < 0) + if (ainfo->nattrs == 0) { + if (H5O__msg_remove_real(loc->file, oh, H5O_MSG_AINFO, H5O_ALL, NULL, NULL, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute info") } /* end if */ done: /* Release resources */ - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_remove_update() */ +} /* end H5O__attr_remove_update() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_remove_cb + * Function: H5O__attr_remove_cb * - * Purpose: Object header iterator callback routine to remove an + * Purpose: Object header iterator callback routine to remove an * attribute stored compactly. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 @@ -1476,13 +1449,13 @@ H5O_attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata/*in,out*/) +H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(oh); @@ -1490,9 +1463,9 @@ H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, HDassert(!udata->found); /* Check for correct attribute message to modify */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Convert message into a null message (i.e. delete it) */ - if(H5O_release_mesg(udata->f, oh, mesg, TRUE) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") /* Indicate that the object header was modified */ @@ -1507,15 +1480,14 @@ H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_remove_cb() */ +} /* end H5O__attr_remove_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_remove + * Function: H5O__attr_remove * - * Purpose: Delete an attribute on an object. + * Purpose: Delete an attribute on an object. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, December 11, 2006 @@ -1525,10 +1497,10 @@ H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, 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 */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1537,67 +1509,66 @@ H5O__attr_remove(const H5O_loc_t *loc, const char *name) HDassert(name); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Delete attribute from dense storage */ - if(H5A__dense_remove(loc->file, &ainfo, name) < 0) + if (H5A__dense_remove(loc->file, &ainfo, name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.name = name; + udata.f = loc->file; + udata.name = name; udata.found = FALSE; /* Iterate over attributes, to locate correct one to delete */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_remove_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_remove_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute") } /* end else */ /* Update the attribute information after removing an attribute */ - if(ainfo_exists) - if(H5O_attr_remove_update(loc, oh, &ainfo) < 0) + if (ainfo_exists) + if (H5O__attr_remove_update(loc, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_remove_by_idx + * Function: H5O__attr_remove_by_idx * - * Purpose: Delete an attribute on an object, according to an order within - * an index. + * Purpose: Delete an attribute on an object, according to an order within + * an index. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Wednesday, February 14, 2007 @@ -1605,14 +1576,13 @@ 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__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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1620,76 +1590,75 @@ H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, HDassert(loc); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") + if (NULL == (oh = H5O_pin(loc))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Delete attribute from dense storage */ - if(H5A__dense_remove_by_idx(loc->file, &ainfo, idx_type, order, n) < 0) + if (H5A__dense_remove_by_idx(loc->file, &ainfo, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Build table of attributes for compact storage */ - if(H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) + if (H5A__compact_build_table(loc->file, oh, idx_type, order, &atable) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "error building attribute table") /* Check for skipping too many attributes */ - if(n >= atable.nattrs) + if (n >= atable.nattrs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") /* Set up user data for callback, to remove the attribute by name */ - udata.f = loc->file; - udata.name = ((atable.attrs[n])->shared)->name; + udata.f = loc->file; + udata.name = ((atable.attrs[n])->shared)->name; udata.found = FALSE; /* Iterate over attributes, to locate correct one to delete */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_remove_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_remove_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") /* Check that we found the attribute */ - if(!udata.found) + if (!udata.found) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute") } /* end else */ /* Update the attribute information after removing an attribute */ - if(ainfo_exists) - if(H5O_attr_remove_update(loc, oh, &ainfo) < 0) + if (ainfo_exists) + if (H5O__attr_remove_update(loc, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update attribute info") /* Update the modification time, if any */ - if(H5O_touch_oh(loc->file, oh, FALSE) < 0) + if (H5O_touch_oh(loc->file, oh, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - if(atable.attrs && H5A__attr_release_table(&atable) < 0) + if (atable.attrs && H5A__attr_release_table(&atable) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove_by_idx() */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_count_real + * Function: H5O__attr_count_real * - * Purpose: Determine the # of attributes on an object + * Purpose: Determine the # of attributes on an object * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, March 9, 2007 @@ -1697,11 +1666,11 @@ H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, *------------------------------------------------------------------------- */ herr_t -H5O_attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) +H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_TAG(oh->cache_info.addr) + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -1709,42 +1678,41 @@ H5O_attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) HDassert(nattrs); /* Check for attributes stored densely */ - if(oh->version > H5O_VERSION_1) { - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5O_ainfo_t ainfo; /* Attribute information for object */ + if (oh->version > H5O_VERSION_1) { + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + H5O_ainfo_t ainfo; /* Attribute information for object */ /* Attempt to get the attribute information from the object header */ - if((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - else if(ainfo_exists > 0) + else if (ainfo_exists > 0) *nattrs = ainfo.nattrs; else *nattrs = 0; } /* end if */ else { - hsize_t attr_count; /* Number of attributes found */ - unsigned u; /* Local index variable */ + hsize_t attr_count; /* Number of attributes found */ + unsigned u; /* Local index variable */ /* Loop over all messages, counting the attributes */ attr_count = 0; - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].type == H5O_MSG_ATTR) + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].type == H5O_MSG_ATTR) attr_count++; *nattrs = attr_count; } /* end else */ done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5O_attr_count_real */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__attr_count_real */ - /*------------------------------------------------------------------------- - * Function: H5O_attr_exists_cb + * Function: H5O__attr_exists_cb * - * Purpose: Object header iterator callback routine to check for an + * Purpose: Object header iterator callback routine to check for an * attribute stored compactly, by name. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 11 2006 @@ -1752,20 +1720,20 @@ H5O_attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) *------------------------------------------------------------------------- */ static herr_t -H5O_attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned H5_ATTR_UNUSED sequence, unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(mesg); HDassert(!udata->found); /* Check for correct attribute message */ - if(HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { + if (HDstrcmp(((H5A_t *)mesg->native)->shared->name, udata->name) == 0) { /* Indicate that this message is the attribute sought */ udata->found = TRUE; @@ -1774,15 +1742,14 @@ H5O_attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_exists_cb() */ +} /* end H5O__attr_exists_cb() */ - /*------------------------------------------------------------------------- - * Function: H5O__attr_exists + * Function: H5O__attr_exists * - * Purpose: Determine if an attribute with a particular name exists on an object + * Purpose: Determine if an attribute with a particular name exists on an object * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, December 11, 2006 @@ -1792,9 +1759,9 @@ H5O_attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg/*in,out*/, htri_t H5O__attr_exists(const H5O_loc_t *loc, const char *name) { - H5O_t *oh = NULL; /* Pointer to actual object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -1803,36 +1770,36 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name) HDassert(name); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for attributes stored densely */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check if attribute exists in dense storage */ - if((ret_value = H5A__dense_exists(loc->file, &ainfo, name)) < 0) + if ((ret_value = H5A__dense_exists(loc->file, &ainfo, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") } /* end if */ else { - H5O_iter_rm_t udata; /* User data for callback */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ /* Set up user data for callback */ - udata.f = loc->file; - udata.name = name; + udata.f = loc->file; + udata.name = name; udata.found = FALSE; /* Iterate over existing attributes, checking for attribute with same name */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5O_attr_exists_cb; - if(H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5O__attr_exists_cb; + if (H5O__msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, &op, &udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error checking for existence of attribute") /* Check that we found the attribute */ @@ -1840,19 +1807,18 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name) } /* end else */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_exists() */ - /*------------------------------------------------------------------------- * Function: H5O__attr_bh_info * * Purpose: For 1.8 attribute, returns storage amount for btree and fractal heap * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi * June 19, 2007 @@ -1862,10 +1828,10 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name) herr_t H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info) { - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1874,103 +1840,58 @@ H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info) HDassert(bh_info); /* Attributes are only stored in fractal heap & indexed w/v2 B-tree in later versions */ - if(oh->version > H5O_VERSION_1) { - H5O_ainfo_t ainfo; /* Attribute information for object */ - htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ + if (oh->version > H5O_VERSION_1) { + H5O_ainfo_t ainfo; /* Attribute information for object */ + htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(f, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") - else if(ainfo_exists > 0) { + else if (ainfo_exists > 0) { /* Check if name index available */ - if(H5F_addr_defined(ainfo.name_bt2_addr)) { + if (H5F_addr_defined(ainfo.name_bt2_addr)) { /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(f, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(f, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Get name index B-tree size */ - if(H5B2_size(bt2_name, &(bh_info->index_size)) < 0) + if (H5B2_size(bt2_name, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Check if creation order index available */ - if(H5F_addr_defined(ainfo.corder_bt2_addr)) { + if (H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(f, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(f, ainfo.corder_bt2_addr, NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Get creation order index B-tree size */ - if(H5B2_size(bt2_corder, &(bh_info->index_size)) < 0) + if (H5B2_size(bt2_corder, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ /* Get storage size of fractal heap, if it's used */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Open the fractal heap for attributes */ - if(NULL == (fheap = H5HF_open(f, ainfo.fheap_addr))) + if (NULL == (fheap = H5HF_open(f, ainfo.fheap_addr))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &(bh_info->heap_size)) < 0) + if (H5HF_size(fheap, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__attr_bh_info() */ - -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5O__attr_count - * - * Purpose: Determine the # of attributes on an object - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, December 11, 2006 - * - *------------------------------------------------------------------------- - */ -int -H5O__attr_count(const H5O_loc_t *loc) -{ - H5O_t *oh = NULL; /* Pointer to actual object header */ - hsize_t nattrs; /* Number of attributes */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Check arguments */ - HDassert(loc); - - /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Retrieve # of attributes on object */ - if(H5O_attr_count_real(loc->file, oh, &nattrs) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve attribute count") - - /* Set return value */ - ret_value = (int)nattrs; - -done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__attr_count */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - +} /* H5O__attr_bh_info() */ diff --git a/src/H5Obogus.c b/src/H5Obogus.c index 08b03b31b77..c7fcdb901de 100644 --- a/src/H5Obogus.c +++ b/src/H5Obogus.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,73 +26,70 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ #ifdef H5O_ENABLE_BOGUS /* PRIVATE PROTOTYPES */ -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 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); -static herr_t H5O__bogus_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__bogus_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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__bogus_decode, /*decode message */ - H5O__bogus_encode, /*encode message */ - NULL, /*copy the native value */ - H5O__bogus_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /*free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__bogus_debug /*debug the message */ + 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__bogus_decode, /*decode message */ + H5O__bogus_encode, /*encode message */ + NULL, /*copy the native value */ + H5O__bogus_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /*free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__bogus_debug /*debug the message */ }}; /* This message derives from H5O message class */ 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__bogus_decode, /*decode message */ - H5O__bogus_encode, /*encode message */ - NULL, /*copy the native value */ - H5O__bogus_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /*free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__bogus_debug /*debug the message */ + 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__bogus_decode, /*decode message */ + H5O__bogus_encode, /*encode message */ + NULL, /*copy the native value */ + H5O__bogus_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /*free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__bogus_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__bogus_decode * @@ -109,12 +106,11 @@ const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__bogus_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__bogus_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_bogus_t *mesg = NULL; - void *ret_value; /* Return value */ + void * ret_value; /* Return value */ FUNC_ENTER_STATIC @@ -123,27 +119,26 @@ H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate the bogus message */ - if(NULL == (mesg = (H5O_bogus_t *)H5MM_calloc(sizeof(H5O_bogus_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (mesg = (H5O_bogus_t *)H5MM_calloc(sizeof(H5O_bogus_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* decode */ UINT32DECODE(p, mesg->u); /* Validate the bogus info */ - if(mesg->u != H5O_BOGUS_VALUE) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)") + if (mesg->u != H5O_BOGUS_VALUE) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)") /* Set return value */ ret_value = mesg; done: - if(ret_value == NULL && mesg != NULL) + if (ret_value == NULL && mesg != NULL) H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__bogus_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__bogus_encode * @@ -157,7 +152,8 @@ H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void H5_ATTR_UNUSED *mesg) +H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_STATIC_NOERR @@ -172,7 +168,6 @@ H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__bogus_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__bogus_size * @@ -191,14 +186,14 @@ H5O__bogus_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared *------------------------------------------------------------------------- */ static size_t -H5O__bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *mesg) +H5O__bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { FUNC_ENTER_STATIC_NOERR FUNC_LEAVE_NOAPI(4) } /* end H5O__bogus_size() */ - /*------------------------------------------------------------------------- * Function: H5O__bogus_debug * @@ -212,10 +207,9 @@ H5O__bogus_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sh *------------------------------------------------------------------------- */ static herr_t -H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg; + const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -226,10 +220,8 @@ H5O__bogus_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth, - "Bogus Value:", mesg->u); + HDfprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth, "Bogus Value:", mesg->u); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__bogus_debug() */ #endif /* H5O_ENABLE_BOGUS */ - diff --git a/src/H5Obtreek.c b/src/H5Obtreek.c index 1f9a5251e09..a78336673ec 100644 --- a/src/H5Obtreek.c +++ b/src/H5Obtreek.c @@ -6,12 +6,11 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 * Thursday, March 1, 2007 * @@ -19,52 +18,49 @@ * information in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#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, 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 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); +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 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); /* This message derives from H5O message class */ 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? */ - H5O_btreek_decode, /*decode message */ - H5O_btreek_encode, /*encode message */ - H5O_btreek_copy, /*copy the native value */ - H5O_btreek_size, /*raw message size */ - NULL, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__btreek_debug /*debug the message */ + 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? */ + H5O__btreek_decode, /*decode message */ + H5O__btreek_encode, /*encode message */ + H5O__btreek_copy, /*copy the native value */ + H5O__btreek_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__btreek_debug /*debug the message */ }}; /* Current version of v1 B-tree 'K' value information */ -#define H5O_BTREEK_VERSION 0 +#define H5O_BTREEK_VERSION 0 - /*------------------------------------------------------------------------- - * Function: H5O_btreek_decode + * Function: H5O__btreek_decode * * Purpose: Decode a shared message table message and return a pointer * to a newly allocated H5O_btreek_t struct. @@ -78,26 +74,25 @@ const H5O_msg_class_t H5O_MSG_BTREEK[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O_btreek_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__btreek_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_btreek_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_btreek_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); HDassert(p); /* Version of message */ - if(*p++ != H5O_BTREEK_VERSION) + if (*p++ != H5O_BTREEK_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_btreek_t *)H5MM_calloc(sizeof(H5O_btreek_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for v1 B-tree 'K' message") + if (NULL == (mesg = (H5O_btreek_t *)H5MM_calloc(sizeof(H5O_btreek_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for v1 B-tree 'K' message") /* Retrieve non-default B-tree 'K' values */ UINT16DECODE(p, mesg->btree_k[H5B_CHUNK_ID]); @@ -109,11 +104,10 @@ H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_btreek_decode() */ +} /* end H5O__btreek_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_btreek_encode + * Function: H5O__btreek_encode * * Purpose: Encode a v1 B-tree 'K' value message. * @@ -125,11 +119,12 @@ H5O_btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -143,11 +138,10 @@ H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared UINT16ENCODE(p, mesg->sym_leaf_k); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_btreek_encode() */ +} /* end H5O__btreek_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_btreek_copy + * Function: H5O__btreek_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -161,19 +155,20 @@ H5O_btreek_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared *------------------------------------------------------------------------- */ static void * -H5O_btreek_copy(const void *_mesg, void *_dest) +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 */ + const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; + H5O_btreek_t * dest = (H5O_btreek_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_btreek_t *)H5MM_malloc(sizeof(H5O_btreek_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_btreek_t *)H5MM_malloc(sizeof(H5O_btreek_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* All this message requires is a shallow copy */ *dest = *mesg; @@ -183,11 +178,10 @@ H5O_btreek_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_btreek_copy() */ +} /* end H5O__btreek_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_btreek_size + * Function: H5O__btreek_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. @@ -201,24 +195,24 @@ H5O_btreek_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) +H5O__btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; + size_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); - ret_value = 1 + /* Version number */ - 2 + /* Chunked storage internal B-tree 'K' value */ - 2 + /* Symbol table node internal B-tree 'K' value */ - 2; /* Symbol table node leaf 'K' value */ + ret_value = 1 + /* Version number */ + 2 + /* Chunked storage internal B-tree 'K' value */ + 2 + /* Symbol table node internal B-tree 'K' value */ + 2; /* Symbol table node leaf 'K' value */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_btreek_size() */ +} /* end H5O__btreek_size() */ - /*------------------------------------------------------------------------- * Function: H5O__btreek_debug * @@ -232,8 +226,7 @@ H5O_btreek_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sh *------------------------------------------------------------------------- */ static herr_t -H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; @@ -247,12 +240,11 @@ H5O__btreek_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Chunked storage internal B-tree 'K' value:", mesg->btree_k[H5B_CHUNK_ID]); + "Chunked storage internal B-tree 'K' value:", mesg->btree_k[H5B_CHUNK_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table node internal B-tree 'K' value:", mesg->btree_k[H5B_SNODE_ID]); + "Symbol table node internal B-tree 'K' value:", mesg->btree_k[H5B_SNODE_ID]); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table node leaf 'K' value:", mesg->sym_leaf_k); + "Symbol table node leaf 'K' value:", mesg->sym_leaf_k); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__btreek_debug() */ - diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 5aaa1db2846..62dc2f24803 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,76 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Metadata cache callbacks */ 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 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_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); 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_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); static herr_t H5O__cache_chk_free_icr(void *thing); /* Prefix routines */ -static herr_t H5O__prefix_deserialize(const uint8_t *image, - H5O_cache_ud_t *udata); +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 len, const uint8_t *image, + 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 */ -static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, - const H5O_cont_t *cont); - +static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont); /*********************/ /* Package Variables */ @@ -103,38 +91,38 @@ static herr_t H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, /* H5O object header prefix inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_OHDR[1] = {{ - H5AC_OHDR_ID, /* Metadata client ID */ - "object header", /* Metadata client name (for debugging) */ - H5FD_MEM_OHDR, /* File space memory type for client */ - H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ - H5O__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ - H5O__cache_get_final_load_size, /* 'get_final_load_size' callback */ - H5O__cache_verify_chksum, /* 'verify_chksum' callback */ - H5O__cache_deserialize, /* 'deserialize' callback */ - H5O__cache_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5O__cache_serialize, /* 'serialize' callback */ - H5O__cache_notify, /* 'notify' callback */ - H5O__cache_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_OHDR_ID, /* Metadata client ID */ + "object header", /* Metadata client name (for debugging) */ + H5FD_MEM_OHDR, /* File space memory type for client */ + H5AC__CLASS_SPECULATIVE_LOAD_FLAG, /* Client class behavior flags */ + H5O__cache_get_initial_load_size, /* 'get_initial_load_size' callback */ + H5O__cache_get_final_load_size, /* 'get_final_load_size' callback */ + H5O__cache_verify_chksum, /* 'verify_chksum' callback */ + H5O__cache_deserialize, /* 'deserialize' callback */ + H5O__cache_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5O__cache_serialize, /* 'serialize' callback */ + H5O__cache_notify, /* 'notify' callback */ + H5O__cache_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* H5O object header chunk inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_OHDR_CHK[1] = {{ - H5AC_OHDR_CHK_ID, /* Metadata client ID */ - "object header continuation chunk", /* Metadata client name (for debugging) */ - H5FD_MEM_OHDR, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5AC_OHDR_CHK_ID, /* Metadata client ID */ + "object header continuation chunk", /* Metadata client name (for debugging) */ + H5FD_MEM_OHDR, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ H5O__cache_chk_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5O__cache_chk_verify_chksum, /* 'verify_chksum' callback */ - H5O__cache_chk_deserialize, /* 'deserialize' callback */ - H5O__cache_chk_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5O__cache_chk_serialize, /* 'serialize' callback */ - H5O__cache_chk_notify, /* 'notify' callback */ - H5O__cache_chk_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5O__cache_chk_verify_chksum, /* 'verify_chksum' callback */ + H5O__cache_chk_deserialize, /* 'deserialize' callback */ + H5O__cache_chk_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5O__cache_chk_serialize, /* 'serialize' callback */ + H5O__cache_chk_notify, /* 'notify' callback */ + H5O__cache_chk_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; /* Declare external the free list for H5O_unknown_t's */ @@ -146,18 +134,14 @@ H5FL_EXTERN(H5O_chunk_proxy_t); /* Declare the free list for H5O_cont_t sequences */ H5FL_SEQ_DEFINE(H5O_cont_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__cache_get_initial_load_size() * @@ -186,7 +170,6 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_get_final_load_size() * @@ -201,11 +184,11 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len) *------------------------------------------------------------------------- */ static herr_t -H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) +H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, + size_t *actual_len) { - H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -216,7 +199,7 @@ H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED i HDassert(*actual_len == image_len); /* Deserialize the object header prefix */ - if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) + if (H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't deserialize object header prefix") /* Sanity check */ @@ -229,7 +212,6 @@ H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED i FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_get_final_load_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_verify_chksum * @@ -247,9 +229,9 @@ 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 */ - H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -259,14 +241,14 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(udata->oh); /* There is no checksum for version 1 */ - if(udata->oh->version != H5O_VERSION_1) { - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + if (udata->oh->version != H5O_VERSION_1) { + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) { + if (stored_chksum != computed_chksum) { /* These fields are not deserialized yet in H5O__prefix_deserialize() */ HDassert(udata->oh->chunk == NULL); HDassert(udata->oh->mesg == NULL); @@ -275,16 +257,15 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) /* Indicate that udata->oh is to be freed later in H5O__prefix_deserialize() */ udata->free_oh = TRUE; - ret_value = FALSE; + ret_value = FALSE; } /* end if */ - } /* end if */ + } /* end if */ else HDassert(!(udata->common.file_intent & H5F_ACC_SWMR_WRITE)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_deserialize * @@ -294,7 +275,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 discrepency * and retry the deserialize operation with the correct size read. * * Return: Success: Pointer to in core representation @@ -306,12 +287,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 H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -328,9 +308,9 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void * through the 'get_final_load_size' callback and not deserialized if * the object header is coming from a cache image - QAK, 2016/12/14) */ - if(NULL == udata->oh) { + if (NULL == udata->oh) { /* Deserialize the object header prefix */ - if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) + if (H5O__prefix_deserialize((const uint8_t *)image, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't deserialize object header prefix") /* Sanity check */ @@ -344,16 +324,17 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void oh->swmr_write = !!(H5F_INTENT(udata->common.f) & H5F_ACC_SWMR_WRITE); /* Create object header proxy if doing SWMR writes */ - if(oh->swmr_write) { + if (oh->swmr_write) { /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + if (NULL == (oh->proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, NULL, "can't create object header proxy") } /* end if */ else oh->proxy = NULL; /* Parse the first chunk */ - if(H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, &(udata->common), dirty) < 0) + if (H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, + &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize first object header chunk") /* Note that we've loaded the object header from the file */ @@ -364,14 +345,13 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void done: /* Release the [possibly partially initialized] object header on errors */ - if(!ret_value && oh) - if(H5O__free(oh) < 0) + if (!ret_value && oh) + if (H5O__free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_image_len * @@ -390,7 +370,7 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void static herr_t H5O__cache_image_len(const void *_thing, size_t *image_len) { - const H5O_t *oh = (const H5O_t *)_thing; /* Object header to query */ + const H5O_t *oh = (const H5O_t *)_thing; /* Object header to query */ FUNC_ENTER_STATIC_NOERR @@ -406,7 +386,6 @@ H5O__cache_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_image_len() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_serialize * @@ -424,9 +403,9 @@ 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 */ - uint8_t *chunk_image; /* Pointer to object header prefix buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -438,7 +417,7 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) HDassert(oh->cache_info.type == H5AC_OHDR); HDassert(oh->chunk[0].size == len); #ifdef H5O_DEBUG - H5O_assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ /* Point to raw data 'image' for first chunk, which @@ -451,8 +430,8 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) * on the entire block of memory needs to be updated if anything is * modified */ - if(oh->version > H5O_VERSION_1) { - uint64_t chunk0_size; /* Size of chunk 0's data */ + if (oh->version > H5O_VERSION_1) { + uint64_t chunk0_size; /* Size of chunk 0's data */ HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); @@ -468,7 +447,7 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) *chunk_image++ = oh->flags; /* Time fields */ - if(oh->flags & H5O_HDR_STORE_TIMES) { + if (oh->flags & H5O_HDR_STORE_TIMES) { UINT32ENCODE(chunk_image, oh->atime); UINT32ENCODE(chunk_image, oh->mtime); UINT32ENCODE(chunk_image, oh->ctime); @@ -476,37 +455,37 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) } /* end if */ /* Attribute fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { UINT16ENCODE(chunk_image, oh->max_compact); UINT16ENCODE(chunk_image, oh->min_dense); } /* end if */ /* First chunk size */ - switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { - case 0: /* 1 byte size */ + switch (oh->flags & H5O_HDR_CHUNK0_SIZE) { + case 0: /* 1 byte size */ HDassert(chunk0_size < 256); *chunk_image++ = (uint8_t)chunk0_size; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ HDassert(chunk0_size < 65536); UINT16ENCODE(chunk_image, chunk0_size); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ /* use <= 2**32 -1 to stay within 4 bytes integer range */ HDassert(chunk0_size <= 4294967295UL); UINT32ENCODE(chunk_image, chunk0_size); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64ENCODE(chunk_image, chunk0_size); break; default: HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0") } /* end switch */ - } /* end if */ + } /* end if */ else { /* Version */ *chunk_image++ = oh->version; @@ -516,8 +495,8 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) /* Number of messages */ #ifdef H5O_ENABLE_BAD_MESG_COUNT - if(oh->store_bad_mesg_count) - UINT16ENCODE(chunk_image, (oh->nmesgs - 1)) + if (oh->store_bad_mesg_count) + UINT16ENCODE(chunk_image, (oh->nmesgs - 1)) else #endif /* H5O_ENABLE_BAD_MESG_COUNT */ UINT16ENCODE(chunk_image, oh->nmesgs); @@ -533,10 +512,11 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) chunk_image += (size_t)(H5O_SIZEOF_HDR(oh) - 12); } /* end else */ - HDassert((size_t)(chunk_image - oh->chunk[0].image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert((size_t)(chunk_image - oh->chunk[0].image) == + (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); /* Serialize messages for this chunk */ - if(H5O__chunk_serialize(f, oh, (unsigned)0) < 0) + if (H5O__chunk_serialize(f, oh, (unsigned)0) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize first object header chunk") /* copy the chunk into the image -- this is potentially expensive. @@ -549,7 +529,6 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_serialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_notify * @@ -565,8 +544,8 @@ 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) { - H5O_t *oh = (H5O_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = (H5O_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -575,15 +554,15 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) */ HDassert(oh); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: - if(oh->swmr_write) { + if (oh->swmr_write) { /* Sanity check */ HDassert(oh->proxy); /* Register the object header as a parent of the virtual entry */ - if(H5AC_proxy_entry_add_parent(oh->proxy, oh) < 0) + if (H5AC_proxy_entry_add_parent(oh->proxy, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add object header as parent of proxy") } /* end if */ break; @@ -593,32 +572,30 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) /* do nothing */ break; - case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: - { - unsigned u; /* Local index variable */ + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: { + unsigned u; /* Local index variable */ - /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].chunkno == 0) - oh->mesg[u].dirty = FALSE; + /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ + for (u = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].chunkno == 0) + oh->mesg[u].dirty = FALSE; #ifndef NDEBUG - /* Reset the number of messages dirtied by decoding */ - oh->ndecode_dirtied = 0; + /* Reset the number of messages dirtied by decoding */ + oh->ndecode_dirtied = 0; #endif /* NDEBUG */ - } - break; + } break; case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: - case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: - case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(oh->swmr_write) { + if (oh->swmr_write) { /* Unregister the object header as a parent of the virtual entry */ - if(H5AC_proxy_entry_remove_parent(oh->proxy, oh) < 0) + if (H5AC_proxy_entry_remove_parent(oh->proxy, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't remove object header as parent of proxy") } /* end if */ break; @@ -631,7 +608,6 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_notify() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_free_icr * @@ -652,8 +628,8 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5O__cache_free_icr(void *_thing) { - H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -663,14 +639,13 @@ H5O__cache_free_icr(void *_thing) HDassert(oh->cache_info.type == H5AC_OHDR); /* Destroy object header */ - if(H5O__free(oh) < 0) + if (H5O__free(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_get_initial_load_size() * @@ -704,7 +679,6 @@ H5O__cache_chk_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_chk_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5B2__cache_chk_verify_chksum * @@ -722,9 +696,9 @@ 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 */ - H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -732,21 +706,20 @@ H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) HDassert(image); /* There is no checksum for version 1 */ - if(udata->oh->version != H5O_VERSION_1) { - uint32_t stored_chksum; /* Stored metadata checksum value */ - uint32_t computed_chksum; /* Computed metadata checksum value */ + if (udata->oh->version != H5O_VERSION_1) { + uint32_t stored_chksum; /* Stored metadata checksum value */ + uint32_t computed_chksum; /* Computed metadata checksum value */ - /* Get stored and computed checksums */ - H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); + /* Get stored and computed checksums */ + H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_deserialize * @@ -763,12 +736,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 H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) { - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -780,18 +752,19 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, HDassert(dirty); /* Allocate space for the object header data structure */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Check if we are still decoding the object header */ /* (as opposed to bringing a piece of it back from the file) */ - if(udata->decoding) { + if (udata->decoding) { /* Sanity check */ HDassert(udata->common.f); HDassert(udata->common.cont_msg_info); /* Parse the chunk */ - if(H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, &(udata->common), dirty) < 0) + if (H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, + &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize object header chunk") /* Set the chunk number for the chunk proxy */ @@ -807,11 +780,12 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, /* Sanity check that the chunk representation we have in memory is * the same as the one being brought in from disk. */ - HDassert(0 == HDmemcmp(image, udata->oh->chunk[chk_proxy->chunkno].image, udata->oh->chunk[chk_proxy->chunkno].size)); + HDassert(0 == HDmemcmp(image, udata->oh->chunk[chk_proxy->chunkno].image, + udata->oh->chunk[chk_proxy->chunkno].size)); } /* end else */ /* Increment reference count of object header */ - if(H5O__inc_rc(udata->oh) < 0) + if (H5O__inc_rc(udata->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") chk_proxy->oh = udata->oh; @@ -819,14 +793,13 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, ret_value = chk_proxy; done: - if(NULL == ret_value) - if(chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (NULL == ret_value) + if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_image_len * @@ -844,7 +817,7 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, static herr_t H5O__cache_chk_image_len(const void *_thing, size_t *image_len) { - const H5O_chunk_proxy_t * chk_proxy = (const H5O_chunk_proxy_t *)_thing; /* Chunk proxy to query */ + const H5O_chunk_proxy_t *chk_proxy = (const H5O_chunk_proxy_t *)_thing; /* Chunk proxy to query */ FUNC_ENTER_STATIC_NOERR @@ -860,7 +833,6 @@ H5O__cache_chk_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cache_chk_image_len() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_serialize * @@ -880,8 +852,8 @@ 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) { - H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk to serialize */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk to serialize */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -895,7 +867,7 @@ H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing) HDassert(chk_proxy->oh->chunk[chk_proxy->chunkno].size == len); /* Serialize messages for this chunk */ - if(H5O__chunk_serialize(f, chk_proxy->oh, chk_proxy->chunkno) < 0) + if (H5O__chunk_serialize(f, chk_proxy->oh, chk_proxy->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize object header continuation chunk") /* copy the chunk into the image -- this is potentially expensive. @@ -907,7 +879,6 @@ H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_serialize() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_notify * @@ -924,7 +895,7 @@ static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) { H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -934,28 +905,29 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) HDassert(chk_proxy); HDassert(chk_proxy->oh); - switch(action) { + switch (action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: case H5AC_NOTIFY_ACTION_AFTER_LOAD: - if(chk_proxy->oh->swmr_write) { + if (chk_proxy->oh->swmr_write) { /* Add flush dependency on chunk with continuation, if one exists */ - if(chk_proxy->fd_parent) { + if (chk_proxy->fd_parent) { /* Sanity checks */ - HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); - HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) - || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); + HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || + (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); /* Add flush dependency from chunk containing the continuation message * that points to this chunk (either oh or another chunk proxy object) */ - if(H5AC_create_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) + if (H5AC_create_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ /* Add flush dependency on object header */ { - if(H5AC_create_flush_dependency(chk_proxy->oh, chk_proxy) < 0) + if (H5AC_create_flush_dependency(chk_proxy->oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -965,8 +937,9 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) HDassert(chk_proxy->oh->proxy); /* Register the object header chunk as a parent of the virtual entry */ - if(H5AC_proxy_entry_add_parent(chk_proxy->oh->proxy, chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add object header chunk as parent of proxy") + if (H5AC_proxy_entry_add_parent(chk_proxy->oh->proxy, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't add object header chunk as parent of proxy") } } /* end if */ break; @@ -976,61 +949,61 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) /* do nothing */ break; - case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: - { - unsigned u; /* Local index variable */ + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: { + unsigned u; /* Local index variable */ - /* Mark messages in chunk as clean */ - for(u = 0; u < chk_proxy->oh->nmesgs; u++) - if(chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) - chk_proxy->oh->mesg[u].dirty = FALSE; - } - break; + /* Mark messages in chunk as clean */ + for (u = 0; u < chk_proxy->oh->nmesgs; u++) + if (chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) + chk_proxy->oh->mesg[u].dirty = FALSE; + } break; case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: case H5AC_NOTIFY_ACTION_CHILD_CLEANED: - case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: - case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: + case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: - if(chk_proxy->oh->swmr_write) { + if (chk_proxy->oh->swmr_write) { /* Remove flush dependency on parent object header chunk, if one is set */ - if(chk_proxy->fd_parent) { + if (chk_proxy->fd_parent) { /* Sanity checks */ - HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == + H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); - HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); + HDassert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || + (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); - if(H5AC_destroy_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) + if (H5AC_destroy_flush_dependency(chk_proxy->fd_parent, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") chk_proxy->fd_parent = NULL; } /* end if */ /* Unregister the object header as a parent of the virtual entry */ - if(H5AC_destroy_flush_dependency(chk_proxy->oh, chk_proxy) < 0) + if (H5AC_destroy_flush_dependency(chk_proxy->oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Unregister the object header chunk as a parent of the virtual entry */ - if(H5AC_proxy_entry_remove_parent(chk_proxy->oh->proxy, chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't remove object header chunk as parent of proxy") + if (H5AC_proxy_entry_remove_parent(chk_proxy->oh->proxy, chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't remove object header chunk as parent of proxy") } /* end if */ break; default: #ifdef NDEBUG HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") -#else /* NDEBUG */ +#else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_notify() */ - /*------------------------------------------------------------------------- * Function: H5O__cache_chk_free_icr * @@ -1052,8 +1025,8 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) static herr_t H5O__cache_chk_free_icr(void *_thing) { - H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1063,14 +1036,13 @@ H5O__cache_chk_free_icr(void *_thing) HDassert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); /* Destroy object header chunk proxy */ - if(H5O__chunk_dest(chk_proxy) < 0) + if (H5O__chunk_dest(chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk proxy") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5O__add_cont_msg * @@ -1098,27 +1070,26 @@ H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont) HDassert(cont); /* Increase chunk array size, if necessary */ - if(cont_msg_info->nmsgs >= cont_msg_info->alloc_nmsgs) { - size_t na = MAX(H5O_NCHUNKS, cont_msg_info->alloc_nmsgs * 2); /* Double # of messages allocated */ + if (cont_msg_info->nmsgs >= cont_msg_info->alloc_nmsgs) { + size_t na = MAX(H5O_NCHUNKS, cont_msg_info->alloc_nmsgs * 2); /* Double # of messages allocated */ H5O_cont_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_cont_t, cont_msg_info->msgs, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_cont_t, cont_msg_info->msgs, na))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "memory allocation failed") cont_msg_info->alloc_nmsgs = na; - cont_msg_info->msgs = x; + cont_msg_info->msgs = x; } /* end if */ /* Init the continuation message info */ - contno = cont_msg_info->nmsgs++; - cont_msg_info->msgs[contno].addr = cont->addr; - cont_msg_info->msgs[contno].size = cont->size; + contno = cont_msg_info->nmsgs++; + cont_msg_info->msgs[contno].addr = cont->addr; + cont_msg_info->msgs[contno].size = cont->size; cont_msg_info->msgs[contno].chunkno = cont->chunkno; done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__add_cont_msg() */ - /*------------------------------------------------------------------------- * Function: H5O__prefix_deserialize() * @@ -1135,9 +1106,9 @@ H5O__add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont) 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5O_t * oh = NULL; /* Object header read in */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1146,7 +1117,7 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) HDassert(udata); /* Allocate space for the new object header data structure */ - if(NULL == (oh = H5FL_CALLOC(H5O_t))) + if (NULL == (oh = H5FL_CALLOC(H5O_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* File-specific, non-stored information */ @@ -1155,26 +1126,26 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* Check for presence of magic number */ /* (indicates version 2 or later) */ - if(!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { + if (!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* Magic number */ image += H5_SIZEOF_MAGIC; /* Version */ oh->version = *image++; - if(H5O_VERSION_2 != oh->version) + if (H5O_VERSION_2 != oh->version) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number") /* Flags */ oh->flags = *image++; - if(oh->flags & ~H5O_HDR_ALL_FLAGS) + if (oh->flags & ~H5O_HDR_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown object header status flag(s)") /* Number of links to object (unless overridden by refcount message) */ oh->nlink = 1; /* Time fields */ - if(oh->flags & H5O_HDR_STORE_TIMES) { - uint32_t tmp; /* Temporary value */ + if (oh->flags & H5O_HDR_STORE_TIMES) { + uint32_t tmp; /* Temporary value */ UINT32DECODE(image, tmp); oh->atime = (time_t)tmp; @@ -1189,45 +1160,45 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) oh->atime = oh->mtime = oh->ctime = oh->btime = 0; /* Attribute fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { UINT16DECODE(image, oh->max_compact); UINT16DECODE(image, oh->min_dense); - if(oh->max_compact < oh->min_dense) + if (oh->max_compact < oh->min_dense) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header attribute phase change values") } /* end if */ else { oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF; - oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; + oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF; } /* end else */ /* First chunk size */ - switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { - case 0: /* 1 byte size */ + switch (oh->flags & H5O_HDR_CHUNK0_SIZE) { + case 0: /* 1 byte size */ udata->chunk0_size = *image++; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16DECODE(image, udata->chunk0_size); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32DECODE(image, udata->chunk0_size); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64DECODE(image, udata->chunk0_size); break; default: HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0") } /* end switch */ - if(udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) + if (udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size") } /* end if */ else { /* Version */ oh->version = *image++; - if(H5O_VERSION_1 != oh->version) + if (H5O_VERSION_1 != oh->version) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number") /* Flags */ @@ -1247,12 +1218,12 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* Reset unused attribute fields */ oh->max_compact = 0; - oh->min_dense = 0; + oh->min_dense = 0; /* First chunk size */ UINT32DECODE(image, udata->chunk0_size); - if((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) || - (udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0)) + if ((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) || + (udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size") /* Reserved, in version 1 (for 8-byte alignment padding) */ @@ -1265,16 +1236,17 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* If udata->oh is to be freed (see H5O__cache_verify_chksum), save the pointer to udata->oh and free it later after setting udata->oh with the new object header */ - if(udata->free_oh) { + if (udata->free_oh) { H5O_t *saved_oh = udata->oh; HDassert(udata->oh); /* Save the object header for later use in 'deserialize' callback */ udata->oh = oh; - if(H5O__free(saved_oh) < 0) + if (H5O__free(saved_oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") udata->free_oh = FALSE; - } else + } + else /* Save the object header for later use in 'deserialize' callback */ udata->oh = oh; @@ -1282,14 +1254,13 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) done: /* Release the [possibly partially initialized] object header on errors */ - if(ret_value < 0 && oh) - if(H5O__free(oh) < 0) + if (ret_value < 0 && oh) + if (H5O__free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__prefix_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_deserialize * @@ -1305,16 +1276,17 @@ 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_common_cache_ud_t *udata, hbool_t *dirty) + 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 */ - unsigned merged_null_msgs = 0; /* Number of null messages merged together */ - unsigned chunkno; /* Current chunk's index */ + const uint8_t *chunk_image; /* Pointer into buffer to decode */ + 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 - unsigned nullcnt; /* Count of null messages (for sanity checking gaps in chunks) */ -#endif /* NDEBUG */ - hbool_t mesgs_modified = FALSE; /* Whether any messages were modified when the object header was deserialized */ + unsigned nullcnt; /* Count of null messages (for sanity checking gaps in chunks) */ +#endif /* NDEBUG */ + hbool_t mesgs_modified = + FALSE; /* Whether any messages were modified when the object header was deserialized */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1327,26 +1299,26 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image HDassert(udata->cont_msg_info); /* Increase chunk array size, if necessary */ - if(oh->nchunks >= oh->alloc_nchunks) { - size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ + if (oh->nchunks >= oh->alloc_nchunks) { + size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ H5O_chunk_t *x; - if(NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) + if (NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") oh->alloc_nchunks = na; - oh->chunk = x; + oh->chunk = x; } /* end if */ /* Init the chunk data info */ - chunkno = (unsigned)oh->nchunks++; - oh->chunk[chunkno].gap = 0; + chunkno = (unsigned)oh->nchunks++; + oh->chunk[chunkno].gap = 0; oh->chunk[chunkno].addr = addr; - if(chunkno == 0) + 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); else oh->chunk[chunkno].size = len; - if(NULL == (oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image, oh->chunk[chunkno].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; @@ -1357,13 +1329,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image chunk_image = oh->chunk[chunkno].image; /* Handle chunk 0 as special case */ - if(chunkno == 0) + if (chunkno == 0) /* Skip over [already decoded] prefix */ chunk_image += (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)); /* Check for magic # on chunks > 0 in later versions of the format */ - else if(chunkno > 0 && oh->version > H5O_VERSION_1) { + else if (chunkno > 0 && oh->version > H5O_VERSION_1) { /* Magic number */ - if(HDmemcmp(chunk_image, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(chunk_image, H5O_CHK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "wrong object header chunk signature") chunk_image += H5_SIZEOF_MAGIC; } /* end if */ @@ -1373,67 +1345,65 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image #ifndef NDEBUG nullcnt = 0; #endif /* NDEBUG */ - while(chunk_image < eom_ptr) { - size_t mesg_size; /* Size of message read in */ - unsigned id; /* ID (type) of current message */ - uint8_t flags; /* Flags for current message */ - H5O_msg_crt_idx_t crt_idx = 0; /* Creation index for current message */ + while (chunk_image < eom_ptr) { + size_t mesg_size; /* Size of message read in */ + unsigned id; /* ID (type) of current message */ + uint8_t flags; /* Flags for current message */ + H5O_msg_crt_idx_t crt_idx = 0; /* Creation index for current message */ /* Decode message prefix info */ /* Version # */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) UINT16DECODE(chunk_image, id) else id = *chunk_image++; /* Message size */ UINT16DECODE(chunk_image, mesg_size); - if(mesg_size != H5O_ALIGN_OH(oh, mesg_size)) + if (mesg_size != H5O_ALIGN_OH(oh, mesg_size)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message not aligned") /* Message flags */ flags = *chunk_image++; - if(flags & ~H5O_MSG_FLAG_BITS) + if (flags & ~H5O_MSG_FLAG_BITS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unknown flag for message") - if((flags & H5O_MSG_FLAG_SHARED) && (flags & H5O_MSG_FLAG_DONTSHARE)) + if ((flags & H5O_MSG_FLAG_SHARED) && (flags & H5O_MSG_FLAG_DONTSHARE)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") - if((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) + if ((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") - if((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && !(flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN)) + if ((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && !(flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN)) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message") /* Delay checking the "shareable" flag until we've made sure id * references a valid message class that this version of the library * knows about */ /* Reserved bytes/creation index */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) chunk_image += 3; /*reserved*/ else { /* Only decode creation index if they are being tracked */ - if(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) + if (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) UINT16DECODE(chunk_image, crt_idx); } /* end else */ /* Try to detect invalidly formatted object header message that * extends past end of chunk. */ - if(chunk_image + mesg_size > eom_ptr) + if (chunk_image + mesg_size > eom_ptr) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "corrupt object header") #ifndef NDEBUG /* Increment count of null messages */ - if(H5O_NULL_ID == id) + if (H5O_NULL_ID == id) nullcnt++; #endif /* NDEBUG */ /* Check for combining two adjacent 'null' messages */ - if((udata->file_intent & H5F_ACC_RDWR) && - H5O_NULL_ID == id && oh->nmesgs > 0 && - H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id && - oh->mesg[oh->nmesgs - 1].chunkno == chunkno) { + if ((udata->file_intent & H5F_ACC_RDWR) && H5O_NULL_ID == id && oh->nmesgs > 0 && + H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id && oh->mesg[oh->nmesgs - 1].chunkno == chunkno) { - size_t mesgno; /* Current message to operate on */ + size_t mesgno; /* Current message to operate on */ /* Combine adjacent null messages */ mesgno = oh->nmesgs - 1; @@ -1442,12 +1412,12 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image merged_null_msgs++; } /* end if */ else { - H5O_mesg_t *mesg; /* Pointer to new message */ - unsigned ioflags = 0; /* Flags for decode routine */ + H5O_mesg_t *mesg; /* Pointer to new message */ + unsigned ioflags = 0; /* Flags for decode routine */ /* Check if we need to extend message table to hold the new message */ - if(oh->nmesgs >= oh->alloc_nmesgs) - if(H5O_alloc_msgs(oh, (size_t)1) < 0) + if (oh->nmesgs >= oh->alloc_nmesgs) + if (H5O__alloc_msgs(oh, (size_t)1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate more space for messages") /* Get pointer to message to set up */ @@ -1457,26 +1427,26 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image oh->nmesgs++; /* Initialize information about message */ - mesg->dirty = FALSE; - mesg->flags = flags; - mesg->crt_idx = crt_idx; - mesg->native = NULL; - mesg->raw = (uint8_t *)chunk_image; /* Casting away const OK - QAK */ + mesg->dirty = FALSE; + mesg->flags = flags; + mesg->crt_idx = crt_idx; + mesg->native = NULL; + mesg->raw = (uint8_t *)chunk_image; /* Casting away const OK - QAK */ mesg->raw_size = mesg_size; - mesg->chunkno = chunkno; + mesg->chunkno = chunkno; /* Point unknown messages at 'unknown' message class */ /* (Usually from future versions of the library) */ - if(id >= H5O_UNKNOWN_ID || + if (id >= H5O_UNKNOWN_ID || #ifdef H5O_ENABLE_BOGUS - id == H5O_BOGUS_VALID_ID || + id == H5O_BOGUS_VALID_ID || #endif - NULL == H5O_msg_class_g[id]) { + NULL == H5O_msg_class_g[id]) { - H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ + H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ /* Allocate "unknown" message info */ - if(NULL == (unknown = H5FL_MALLOC(H5O_unknown_t))) + if (NULL == (unknown = H5FL_MALLOC(H5O_unknown_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Save the original message type ID */ @@ -1489,14 +1459,14 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image mesg->type = H5O_msg_class_g[H5O_UNKNOWN_ID]; /* Check for "fail if unknown" message flags */ - if(((udata->file_intent & H5F_ACC_RDWR) && - (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) - || (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "unknown message with 'fail if unknown' flag found") + if (((udata->file_intent & H5F_ACC_RDWR) && + (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE)) || + (flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, + "unknown message with 'fail if unknown' flag found") /* Check for "mark if unknown" message flag, etc. */ - else if((flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) && - !(flags & H5O_MSG_FLAG_WAS_UNKNOWN) && - (udata->file_intent & H5F_ACC_RDWR)) { + else if ((flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) && !(flags & H5O_MSG_FLAG_WAS_UNKNOWN) && + (udata->file_intent & H5F_ACC_RDWR)) { /* Mark the message as "unknown" */ /* This is a bit aggressive, since the application may @@ -1512,17 +1482,17 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image mesg->flags |= H5O_MSG_FLAG_WAS_UNKNOWN; /* Mark the message and chunk as dirty */ - mesg->dirty = TRUE; + mesg->dirty = TRUE; mesgs_modified = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Check for message of unshareable class marked as "shareable" */ - if((flags & H5O_MSG_FLAG_SHAREABLE) - && H5O_msg_class_g[id] - && !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message of unshareable class flagged as shareable") + if ((flags & H5O_MSG_FLAG_SHAREABLE) && H5O_msg_class_g[id] && + !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, + "message of unshareable class flagged as shareable") /* Set message class for "known" messages */ mesg->type = H5O_msg_class_g[id]; @@ -1532,61 +1502,65 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image /* (detect continuation messages, ref. count messages, etc.) */ /* Check if message is a continuation message */ - if(H5O_CONT_ID == id) { + if (H5O_CONT_ID == id) { H5O_cont_t *cont; /* Decode continuation message */ - cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, mesg->raw); - H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, size_t); /* the next continuation message/chunk */ + cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, + mesg->raw); + H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, + size_t); /* the next continuation message/chunk */ /* Save 'native' form of continuation message */ mesg->native = cont; /* Add to continuation messages left to interpret */ - if(H5O__add_cont_msg(udata->cont_msg_info, cont) < 0) + if (H5O__add_cont_msg(udata->cont_msg_info, cont) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't add continuation message") } /* end if */ /* Check if message is a ref. count message */ - else if(H5O_REFCOUNT_ID == id) { + else if (H5O_REFCOUNT_ID == id) { H5O_refcount_t *refcount; /* Decode ref. count message */ - if(oh->version <= H5O_VERSION_1) - HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "object header version does not support reference count message") - refcount = (H5O_refcount_t *)(H5O_MSG_REFCOUNT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, mesg->raw); + if (oh->version <= H5O_VERSION_1) + HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, + "object header version does not support reference count message") + refcount = (H5O_refcount_t *)(H5O_MSG_REFCOUNT->decode)(udata->f, NULL, 0, &ioflags, + mesg->raw_size, mesg->raw); /* Save 'native' form of ref. count message */ mesg->native = refcount; /* Set object header values */ oh->has_refcount_msg = TRUE; - if(!refcount) + if (!refcount) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't decode refcount") oh->nlink = *refcount; } /* end if */ /* Check if message is a link message */ - else if(H5O_LINK_ID == id) { + else if (H5O_LINK_ID == id) { /* Increment the count of link messages */ oh->link_msgs_seen++; } /* end if */ /* Check if message is an attribute message */ - else if(H5O_ATTR_ID == id) { + else if (H5O_ATTR_ID == id) { /* Increment the count of attribute messages */ oh->attr_msgs_seen++; } /* end if */ /* Mark the message & chunk as dirty if the message was changed by decoding */ - if((ioflags & H5O_DECODEIO_DIRTY) && (udata->file_intent & H5F_ACC_RDWR)) { - mesg->dirty = TRUE; + if ((ioflags & H5O_DECODEIO_DIRTY) && (udata->file_intent & H5F_ACC_RDWR)) { + mesg->dirty = TRUE; mesgs_modified = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* Advance decode pointer past message */ chunk_image += mesg_size; /* Check for 'gap' at end of chunk */ - if((eom_ptr - chunk_image) > 0 && (eom_ptr - chunk_image) < H5O_SIZEOF_MSGHDR_OH(oh)) { + if ((eom_ptr - chunk_image) > 0 && (eom_ptr - chunk_image) < H5O_SIZEOF_MSGHDR_OH(oh)) { /* Gaps can only occur in later versions of the format */ HDassert(oh->version > H5O_VERSION_1); @@ -1599,13 +1573,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image /* Increment location in chunk */ chunk_image += oh->chunk[chunkno].gap; } /* end if */ - } /* end while */ + } /* end while */ /* Check for correct checksum on chunks, in later versions of the format */ - if(oh->version > H5O_VERSION_1) { - uint32_t stored_chksum; /* Checksum from file */ + if (oh->version > H5O_VERSION_1) { + uint32_t stored_chksum; /* Checksum from file */ - /* checksum verification already done in verify_chksum cb */ + /* checksum verification already done in verify_chksum cb */ /* Metadata checksum */ UINT32DECODE(chunk_image, stored_chksum); @@ -1615,24 +1589,23 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image HDassert(chunk_image == oh->chunk[chunkno].image + oh->chunk[chunkno].size); /* Mark the chunk dirty if we've modified messages */ - if(mesgs_modified) - *dirty = TRUE; + if (mesgs_modified) + *dirty = TRUE; /* Mark the chunk dirty if we've merged null messages */ - if(merged_null_msgs > 0) { + if (merged_null_msgs > 0) { udata->merged_null_msgs += merged_null_msgs; - *dirty = TRUE; + *dirty = TRUE; } /* end if */ done: - if(ret_value < 0 && udata->cont_msg_info->msgs) { - udata->cont_msg_info->msgs = H5FL_SEQ_FREE(H5O_cont_t, udata->cont_msg_info->msgs); + if (ret_value < 0 && udata->cont_msg_info->msgs) { + udata->cont_msg_info->msgs = H5FL_SEQ_FREE(H5O_cont_t, udata->cont_msg_info->msgs); udata->cont_msg_info->alloc_nmsgs = 0; } FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_serialize * @@ -1649,9 +1622,9 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image static herr_t H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1660,32 +1633,35 @@ H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) HDassert(oh); /* Encode any dirty messages in this chunk */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->dirty && curr_msg->chunkno == chunkno) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->dirty && curr_msg->chunkno == chunkno) /* Casting away const OK -QAK */ - if(H5O_msg_flush((H5F_t *)f, oh, curr_msg) < 0) + if (H5O_msg_flush((H5F_t *)f, oh, curr_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") /* Sanity checks */ - if(oh->version > H5O_VERSION_1) + if (oh->version > H5O_VERSION_1) /* Make certain the magic # is present */ - HDassert(!HDmemcmp(oh->chunk[chunkno].image, (chunkno == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); + HDassert(!HDmemcmp(oh->chunk[chunkno].image, (chunkno == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), + H5_SIZEOF_MAGIC)); else /* Gaps should never occur in version 1 of the format */ HDassert(oh->chunk[chunkno].gap == 0); /* Extra work, for later versions of the format */ - if(oh->version > H5O_VERSION_1) { - uint32_t metadata_chksum; /* Computed metadata checksum value */ - uint8_t *chunk_image; /* Pointer into object header chunk */ + if (oh->version > H5O_VERSION_1) { + uint32_t metadata_chksum; /* Computed metadata checksum value */ + uint8_t *chunk_image; /* Pointer into object header chunk */ /* Check for gap in chunk & zero it out */ - if(oh->chunk[chunkno].gap) + if (oh->chunk[chunkno].gap) HDmemset((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - - (H5O_SIZEOF_CHKSUM + oh->chunk[chunkno].gap), 0, oh->chunk[chunkno].gap); + (H5O_SIZEOF_CHKSUM + oh->chunk[chunkno].gap), + 0, oh->chunk[chunkno].gap); /* Compute metadata checksum */ - metadata_chksum = H5_checksum_metadata(oh->chunk[chunkno].image, (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM), 0); + metadata_chksum = + H5_checksum_metadata(oh->chunk[chunkno].image, (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM), 0); /* Metadata checksum */ chunk_image = oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM); @@ -1695,4 +1671,3 @@ H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_serialize() */ - diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index d9b926fa96c..2603f7171ce 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,61 +26,56 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MFprivate.h" /* File space management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Opkg.h" /* Object headers */ +#include "H5MFprivate.h" /* File space management */ /* Callbacks for message class */ -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 size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, - const void *_mesg); +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 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); -static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__mdci_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__mdci_decode, /* decode message */ - H5O__mdci_encode, /* encode message */ - H5O__mdci_copy, /* copy method */ - H5O__mdci_size, /* size of mdc image message */ - NULL, /* reset method */ - H5O__mdci_free, /* free method */ - H5O__mdci_delete, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mdci_debug /* debugging */ + H5O_MDCI_MSG_ID, /* message id number */ + "mdci", /* message name for debugging */ + sizeof(H5O_mdci_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__mdci_decode, /* decode message */ + H5O__mdci_encode, /* encode message */ + H5O__mdci_copy, /* copy method */ + H5O__mdci_size, /* size of mdc image message */ + NULL, /* reset method */ + H5O__mdci_free, /* free method */ + H5O__mdci_delete, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mdci_debug /* debugging */ }}; /* Only one version of the metadata cache image message at present */ -#define H5O_MDCI_VERSION_0 0 +#define H5O_MDCI_VERSION_0 0 /* Declare the free list for H5O_mdci_t's */ H5FL_DEFINE(H5O_mdci_t); - - /*------------------------------------------------------------------------- * Function: H5O__mdci_decode * @@ -96,12 +91,11 @@ H5FL_DEFINE(H5O_mdci_t); *------------------------------------------------------------------------- */ static void * -H5O__mdci_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__mdci_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_mdci_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_mdci_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -110,12 +104,13 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_MDCI_VERSION_0) + if (*p++ != H5O_MDCI_VERSION_0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for metadata cache image message") + if (NULL == (mesg = (H5O_mdci_t *)H5FL_MALLOC(H5O_mdci_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for metadata cache image message") /* Decode */ H5F_addr_decode(f, &p, &(mesg->addr)); @@ -128,7 +123,6 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_encode * @@ -142,8 +136,7 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - uint8_t *p, const void *_mesg) +H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; @@ -162,7 +155,6 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_copy * @@ -180,15 +172,15 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, 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 */ + const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; + H5O_mdci_t * dest = (H5O_mdci_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_mdci_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -201,7 +193,6 @@ H5O__mdci_copy(const void *_mesg, void *_dest) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_mdci__copy() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_size * @@ -219,24 +210,22 @@ H5O__mdci_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, - const void H5_ATTR_UNUSED *_mesg) +H5O__mdci_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)( 1 + /* Version number */ - H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ - /* image block */ - H5F_SIZEOF_SIZE(f) ); /* length of metadata cache */ - /* image block */ + ret_value = (size_t)(1 + /* Version number */ + H5F_SIZEOF_ADDR(f) + /* addr of metadata cache */ + /* image block */ + H5F_SIZEOF_SIZE(f)); /* length of metadata cache */ + /* image block */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_size() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_free * @@ -261,7 +250,6 @@ H5O__mdci_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_free() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_delete * @@ -275,69 +263,43 @@ H5O__mdci_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) +H5O__mdci_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { H5O_mdci_t *mesg = (H5O_mdci_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t final_eoa; /* For sanity check */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(f); - HDassert(open_oh); HDassert(mesg); /* Free file space for cache image */ - if(H5F_addr_defined(mesg->addr)) { + if (H5F_addr_defined(mesg->addr)) { /* The space for the cache image block was allocated directly * from the VFD layer at the end of file. As this was the * last file space allocation before shutdown, the cache image * should still be the last item in the file. - * - * If the hack to work around the self referential free space - * manager issue is in use, file space for the non-empty self - * referential free space managers was also allocated from VFD - * layer at the end of file. Since these allocations directly - * preceeded the cache image allocation they should be directly - * adjacent to the cache image block at the end of file. - * - * In this case, just call H5MF_tidy_self_referential_fsm_hack(). - * - * That routine will float the self referential free space - * managers, and reduce the eoa to its value just prior to - * allocation of space for same. Since the cache image appears - * just after the self referential free space managers, this - * will release the file space for the cache image as well. - * - * Note that in this case, there must not have been any file - * space allocations / deallocations prior to the free of the - * cache image. Verify this to the extent possible. - * - * If the hack to work around the persistent self referential - * free space manager issue is NOT in use, just call H5MF_xfree() - * to release the cache iamge. In principle, we should be able - * to just reduce the EOA to the base address of the cache - * image block, as there shouldn't be any file space allocation - * before the first metadata cache access. However, given - * time constraints, I don't want to go there now. */ - if(H5F_FIRST_ALLOC_DEALLOC(f)) { - HDassert(HADDR_UNDEF != H5F_EOA_PRE_FSM_FSALLOC(f)); - HDassert(H5F_addr_ge(mesg->addr, H5F_EOA_PRE_FSM_FSALLOC(f))); - if(H5MF_tidy_self_referential_fsm_hack(f) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "tidy of self referential fsm hack failed") - } /* end if */ - else { - if(H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") - } /* end else */ + if (f->shared->closing) { + /* Get the eoa, and verify that it has the expected value */ + if (HADDR_UNDEF == (final_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get file size") + + HDassert(H5F_addr_eq(final_eoa, mesg->addr + mesg->size)); + + if (H5FD_free(f->shared->lf, H5FD_MEM_SUPER, f, mesg->addr, mesg->size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't free MDC image") + } + else if (H5MF_xfree(f, H5FD_MEM_SUPER, mesg->addr, mesg->size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free file space for cache image block") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mdci_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__mdci_debug * @@ -351,10 +313,9 @@ H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_mdci_t *mdci = (const H5O_mdci_t *) _mesg; + const H5O_mdci_t *mdci = (const H5O_mdci_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -365,12 +326,11 @@ H5O__mdci_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Metadata Cache Image Block address:", mdci->addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Metadata Cache Image Block size in bytes:", mdci->size); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mdci_debug() */ - diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index cb31cec4aa2..66e11c8216b 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,37 +26,31 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -64,18 +58,14 @@ /* Declare the free list for H5O_chunk_proxy_t's */ H5FL_DEFINE(H5O_chunk_proxy_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O__chunk_add * @@ -91,9 +81,10 @@ H5FL_DEFINE(H5O_chunk_proxy_t); herr_t H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ - H5O_chunk_proxy_t *cont_chk_proxy = NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + H5O_chunk_proxy_t *cont_chk_proxy = + NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -104,46 +95,45 @@ H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno) HDassert(idx > 0); /* Allocate space for the object header data structure */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Increment reference count on object header */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "can't increment reference count on object header") /* Set the values in the chunk proxy */ - chk_proxy->f = f; - chk_proxy->oh = oh; + chk_proxy->f = f; + chk_proxy->oh = oh; chk_proxy->chunkno = idx; /* Determine the parent of the chunk */ - if(cont_chunkno != 0) { - if(NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) + if (cont_chunkno != 0) { + if (NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") chk_proxy->fd_parent = cont_chk_proxy; } /* end else */ /* Insert the chunk proxy into the cache */ - if(H5AC_insert_entry(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header chunk") chk_proxy = NULL; done: /* Cleanup on failure */ - if(ret_value < 0) - if(chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (ret_value < 0) + if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk") /* Release resources */ - if(cont_chk_proxy) - if(H5O__chunk_unprotect(f, cont_chk_proxy, FALSE) < 0) + if (cont_chk_proxy) + if (H5O__chunk_unprotect(f, cont_chk_proxy, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_add() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_protect * @@ -159,8 +149,8 @@ H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno) H5O_chunk_proxy_t * H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ - H5O_chunk_proxy_t *ret_value = NULL; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ + H5O_chunk_proxy_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -170,33 +160,34 @@ H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) HDassert(idx < oh->nchunks); /* Check for protecting first chunk */ - if(0 == idx) { + if (0 == idx) { /* Create new "fake" chunk proxy for first chunk */ /* (since the first chunk is already handled by the H5O_t object) */ - if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) + if (NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment reference count on object header */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") /* Set chunk proxy fields */ - chk_proxy->f = f; - chk_proxy->oh = oh; + chk_proxy->f = f; + chk_proxy->oh = oh; chk_proxy->chunkno = idx; } /* end if */ else { - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ /* Construct the user data for protecting chunk proxy */ /* (and _not_ decoding it) */ HDmemset(&chk_udata, 0, sizeof(chk_udata)); - chk_udata.oh = oh; + chk_udata.oh = oh; chk_udata.chunkno = idx; - chk_udata.size = oh->chunk[idx].size; + chk_udata.size = oh->chunk[idx].size; /* Get the chunk proxy */ - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, &chk_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, + &chk_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") /* Sanity check */ @@ -209,14 +200,13 @@ H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) done: /* Cleanup on error */ - if(!ret_value) - if(0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0) + if (!ret_value) + if (0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_protect() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_unprotect * @@ -232,7 +222,7 @@ H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx) herr_t H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -241,16 +231,16 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) HDassert(chk_proxy); /* Check for releasing first chunk */ - if(0 == chk_proxy->chunkno) { + if (0 == chk_proxy->chunkno) { /* Check for dirtying the first chunk */ - if(dirtied) { + if (dirtied) { /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(chk_proxy->oh) < 0) + if (H5AC_mark_entry_dirty(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else/if */ /* Decrement reference count of object header */ - if(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") /* Free fake chunk proxy */ @@ -258,7 +248,8 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) } /* end if */ else { /* Release the chunk proxy from the cache, possibly marking it dirty */ - if(H5AC_unprotect(f, H5AC_OHDR_CHK, chk_proxy->oh->chunk[chk_proxy->chunkno].addr, chk_proxy, (dirtied ? H5AC__DIRTIED_FLAG : H5AC__NO_FLAGS_SET)) < 0) + if (H5AC_unprotect(f, H5AC_OHDR_CHK, chk_proxy->oh->chunk[chk_proxy->chunkno].addr, chk_proxy, + (dirtied ? H5AC__DIRTIED_FLAG : H5AC__NO_FLAGS_SET)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") } /* end else */ @@ -266,7 +257,6 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__chunk_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_resize * @@ -282,7 +272,7 @@ H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t dirtied) herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -291,14 +281,14 @@ H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) HDassert(chk_proxy); /* Check for resizing first chunk */ - if(0 == chk_proxy->chunkno) { + if (0 == chk_proxy->chunkno) { /* Resize object header in cache */ - if(H5AC_resize_entry(oh, oh->chunk[0].size) < 0) + if (H5AC_resize_entry(oh, oh->chunk[0].size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache") } /* end if */ else { /* Resize chunk in cache */ - if(H5AC_resize_entry(chk_proxy, oh->chunk[chk_proxy->chunkno].size) < 0) + if (H5AC_resize_entry(chk_proxy, oh->chunk[chk_proxy->chunkno].size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache") } /* end else */ @@ -306,7 +296,6 @@ H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__chunk_resize() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_update_idx * @@ -322,9 +311,9 @@ H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy) herr_t H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL;/* Proxy for chunk, to mark it dirty in the cache */ - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -337,26 +326,26 @@ H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) /* Construct the user data for protecting chunk proxy */ /* (and _not_ decoding it) */ HDmemset(&chk_udata, 0, sizeof(chk_udata)); - chk_udata.oh = oh; + chk_udata.oh = oh; chk_udata.chunkno = idx; - chk_udata.size = oh->chunk[idx].size; + chk_udata.size = oh->chunk[idx].size; /* Get the chunk proxy */ - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, &chk_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, + &chk_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Update index for chunk proxy in cache */ chk_proxy->chunkno = idx; /* Release the chunk proxy from the cache, marking it deleted */ - if(H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__DIRTIED_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_update_idx() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_delete * @@ -372,9 +361,9 @@ H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx) { - H5O_chunk_proxy_t *chk_proxy = NULL;/* Proxy for chunk, to mark it dirty in the cache */ - unsigned cache_flags = H5AC__DELETED_FLAG; /* Flags for unprotecting proxy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ + unsigned cache_flags = H5AC__DELETED_FLAG; /* Flags for unprotecting proxy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) @@ -385,22 +374,21 @@ H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx) HDassert(idx > 0); /* Get the chunk proxy */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Only free file space if not doing SWMR writes */ - if(!oh->swmr_write) + if (!oh->swmr_write) cache_flags |= H5AC__DIRTIED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; done: /* Release the chunk proxy from the cache, marking it deleted */ - if(chk_proxy && H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) + if (chk_proxy && H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__chunk_dest * @@ -424,7 +412,7 @@ 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 (chk_proxy->oh && H5O__dec_rc(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") /* Release the chunk proxy object */ @@ -433,4 +421,3 @@ H5O__chunk_dest(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 68a88e2d90a..080225a08c0 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,54 +25,50 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void *H5O__cont_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p); +static void *H5O__cont_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__cont_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O__cont_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__cont_free(void *mesg); static herr_t H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static herr_t H5O__cont_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__cont_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__cont_decode, /*decode message */ - H5O__cont_encode, /*encode message */ - NULL, /*no copy method */ - H5O__cont_size, /*size of header continuation */ - NULL, /*reset method */ - H5O__cont_free, /* free method */ - H5O__cont_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__cont_debug /*debugging */ + H5O_CONT_ID, /*message id number */ + "hdr continuation", /*message name for debugging */ + sizeof(H5O_cont_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__cont_decode, /*decode message */ + H5O__cont_encode, /*encode message */ + NULL, /*no copy method */ + H5O__cont_size, /*size of header continuation */ + NULL, /*reset method */ + H5O__cont_free, /* free method */ + H5O__cont_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__cont_debug /*debugging */ }}; /* Declare the free list for H5O_cont_t's */ H5FL_DEFINE(H5O_cont_t); - /*------------------------------------------------------------------------- * Function: H5O__cont_decode * @@ -88,12 +84,11 @@ H5FL_DEFINE(H5O_cont_t); *------------------------------------------------------------------------- */ static void * -H5O__cont_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__cont_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_cont_t *cont = NULL; - void *ret_value = NULL; /* Return value */ + H5O_cont_t *cont = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -102,8 +97,8 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate space for the message */ - if(NULL == (cont = H5FL_MALLOC(H5O_cont_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL == (cont = H5FL_MALLOC(H5O_cont_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Decode */ H5F_addr_decode(f, &p, &(cont->addr)); @@ -117,7 +112,6 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_encode * @@ -133,7 +127,7 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, static herr_t H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; + const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -151,7 +145,6 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_size * @@ -171,18 +164,17 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static size_t H5O__cont_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ - H5F_SIZEOF_SIZE(f)); /* Continuation header length */ + ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ + H5F_SIZEOF_SIZE(f)); /* Continuation header length */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_size() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_free * @@ -207,7 +199,6 @@ H5O__cont_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_free() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_delete * @@ -223,8 +214,8 @@ H5O__cont_free(void *mesg) static herr_t H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_cont_t *mesg = (H5O_cont_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_cont_t *mesg = (H5O_cont_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -234,14 +225,13 @@ H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) /* Notify the cache that the chunk has been deleted */ /* (releases the space for the chunk) */ - if(H5O__chunk_delete(f, open_oh, mesg->chunkno) < 0) + if (H5O__chunk_delete(f, open_oh, mesg->chunkno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove chunk from cache") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__cont_debug * @@ -255,10 +245,9 @@ H5O__cont_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_cont_t *cont = (const H5O_cont_t *) _mesg; + const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -269,15 +258,11 @@ H5O__cont_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Continuation address:", cont->addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Continuation address:", cont->addr); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Continuation size in bytes:", - (unsigned long) (cont->size)); - HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, - "Points to chunk number:", - (int) (cont->chunkno)); + "Continuation size in bytes:", (unsigned long)(cont->size)); + HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Points to chunk number:", (int)(cont->chunkno)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__cont_debug() */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index bb92ec90f30..6cf402ba8b3 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -6,18 +6,16 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: H5Ocopy.c - * Nov 6 2006 - * Quincey Koziol + * Created: H5Ocopy.c * - * Purpose: Object copying routines. + * Purpose: Object copying routines. * *------------------------------------------------------------------------- */ @@ -26,79 +24,70 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Key object for skiplist of committed datatypes */ typedef struct H5O_copy_search_comm_dt_key_t { - H5T_t *dt; /* Datatype */ - unsigned long fileno; /* File number */ + 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 */ - H5G_loc_t *dst_root_loc; /* Starting location for iteration */ - H5O_loc_t obj_oloc; /* Object location (for attribute iteration callback) */ + 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; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O__copy(const H5G_loc_t *loc, const char *src_name, - H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); static herr_t H5O__copy_free_addrmap_cb(void *item, void *key, void *op_data); static herr_t H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata); -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); -static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); -static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info); + H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata); +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); +static herr_t H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, + hid_t lcpl_id); static herr_t H5O__copy_free_comm_dt_cb(void *item, void *key, void *op_data); -static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2); -static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name, - const H5L_info_t *linfo, void *udata); -static htri_t H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, - H5O_loc_t *oloc_dst/*in, out*/, H5O_copy_t *cpy_info); -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); - +static int H5O__copy_comm_dt_cmp(const void *dt1, const void *dt2); +static herr_t H5O__copy_search_comm_dt_cb(hid_t group, const char *name, const H5L_info2_t *linfo, + void *udata); +static htri_t H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*in, out*/, + H5O_copy_t *cpy_info); +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); /*********************/ /* Package Variables */ @@ -113,18 +102,14 @@ H5FL_DEFINE(H5O_copy_search_comm_dt_key_t); /* Declare a free list to manage haddr_t variables */ H5FL_DEFINE(haddr_t); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Ocopy * @@ -195,74 +180,94 @@ H5FL_DEFINE(haddr_t); * hid_t lcpl_id IN: Properties which apply to the new hard link * * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Peter Cao - * June 4, 2005 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ 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) +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) { - H5G_loc_t loc; /* Source group group location */ - H5G_loc_t dst_loc; /* Destination group location */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, - ocpypl_id, lcpl_id); + H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id); /* Check arguments */ - if(H5G_loc(src_loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") + if (!src_name || !*src_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") + if (!dst_name || !*dst_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") + + /* Get correct property lists */ + if (H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + + /* Get object copy property list */ + if (H5P_DEFAULT == ocpypl_id) + ocpypl_id = H5P_OBJECT_COPY_DEFAULT; + else if (TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") + + /* Set the LCPL for the API context */ + H5CX_set_lcpl(lcpl_id); /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(src_loc_id) < 0) + if (H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call internal routine to copy object */ - if(H5O__copy(&loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) + /* get the object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* get the object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params2.type = H5VL_OBJECT_BY_SELF; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + /* Copy the object */ + if (H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, dst_name, ocpypl_id, + lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: FUNC_LEAVE_API(ret_value) } /* end H5Ocopy() */ - /*------------------------------------------------------------------------- * Function: H5O__copy * - * Purpose: Internal routine to copy an object + * Purpose: Private version of H5Ocopy * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * December 29, 2017 * *------------------------------------------------------------------------- */ -static herr_t -H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) +herr_t +H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id) { - H5G_loc_t src_loc; /* Source object group location */ - H5G_name_t src_path; /* Opened source object hier. path */ - H5O_loc_t src_oloc; /* Opened source object object location */ - htri_t dst_exists; /* Does destination name exist already? */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - hbool_t obj_open = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t src_loc; /* Source object group location */ + H5G_name_t src_path; /* Opened source object hier. path */ + H5O_loc_t src_oloc; /* Opened source object object location */ + htri_t dst_exists; /* Does destination name exist already? */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + hbool_t obj_open = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(loc); @@ -271,9 +276,9 @@ H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, HDassert(dst_name && *dst_name); /* Check if destination name already exists */ - if((dst_exists = H5L_exists_tolerant(dst_loc, dst_name)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") - if(TRUE == dst_exists) + if ((dst_exists = H5L_exists_tolerant(dst_loc, dst_name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") + if (TRUE == dst_exists) HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") /* Set up opened group location to fill in */ @@ -282,50 +287,28 @@ H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, H5G_loc_reset(&src_loc); /* Find the source object to copy */ - if(H5G_loc_find(loc, src_name, &src_loc/*out*/) < 0) + if (H5G_loc_find(loc, src_name, &src_loc /*out*/) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found") loc_found = TRUE; /* Open source object's object header */ - if(H5O_open(&src_oloc) < 0) + if (H5O_open(&src_oloc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") obj_open = TRUE; - /* Get correct property lists */ - if(H5P_DEFAULT == lcpl_id) { - if((lcpl_id = H5P_get_default(H5P_CLS_LCRT)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default lcpl") - } /* end if */ - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") - - /* Get object copy property list */ - if(H5P_DEFAULT == ocpypl_id) { - if((ocpypl_id = H5P_get_default(H5P_CLS_OCPY)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default ocpypl") - } /* end if */ - else - if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") - - /* Set the LCPL for the API context */ - H5CX_set_lcpl(lcpl_id); - /* Do the actual copying of the object */ - if(H5O__copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) + if (H5O__copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: - if(loc_found && H5G_loc_free(&src_loc) < 0) + if (loc_found && H5G_loc_free(&src_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - if(obj_open && H5O_close(&src_oloc, NULL) < 0) + if (obj_open && H5O_close(&src_oloc, NULL) < 0) HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_header_real * @@ -347,27 +330,27 @@ H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, *------------------------------------------------------------------------- */ static herr_t -H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, H5O_type_t *obj_type, void **udata /*out*/) +H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5O_copy_t *cpy_info, + 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 */ - unsigned mesgno = 0; - haddr_t addr_new = HADDR_UNDEF; - 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 */ - H5O_mesg_t *mesg_src; /* Message in source object header */ - 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 */ - 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 */ + 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 */ + unsigned mesgno = 0; + haddr_t addr_new = HADDR_UNDEF; + 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 */ + H5O_mesg_t *mesg_src; /* Message in source object header */ + 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 */ + 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 */ size_t msghdr_size; herr_t ret_value = SUCCEED; @@ -380,88 +363,88 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, HDassert(cpy_info); /* Get pointer to object class for this object */ - if(NULL == (obj_class = H5O__obj_class(oloc_src))) + if (NULL == (obj_class = H5O__obj_class(oloc_src))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") /* Set the pointer to the shared struct for the object if opened in the file */ cpy_info->shared_fo = H5FO_opened(oloc_src->file, oloc_src->addr); /* Get source object header */ - if(NULL == (oh_src = H5O_protect(oloc_src, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh_src = H5O_protect(oloc_src, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve user data for particular type of object to copy */ - if(obj_class->get_copy_file_udata && (NULL == (cpy_udata = (obj_class->get_copy_file_udata)()))) + if (obj_class->get_copy_file_udata && (NULL == (cpy_udata = (obj_class->get_copy_file_udata)()))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to retrieve copy user data") /* If we are merging committed datatypes, check for a match in the destination * file now */ - if(cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) { + if (cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) { unsigned long fileno_src; /* fileno for source file */ unsigned long fileno_dst; /* fileno for destination file */ - htri_t merge; /* Whether we found a match in the destination file */ + htri_t merge; /* Whether we found a match in the destination file */ /* Check if the source and dest file are the same. If so, just return * the source object address */ H5F_GET_FILENO(oloc_src->file, fileno_src); H5F_GET_FILENO(oloc_dst->file, fileno_dst); - if(fileno_src == fileno_dst) { - merge = TRUE; + if (fileno_src == fileno_dst) { + merge = TRUE; oloc_dst->addr = oloc_src->addr; } /* end if */ else /* 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") + 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") - if(merge) { + if (merge) { /* Found a match, add to skip list and exit */ /* Allocate space for the address mapping of the object copied */ - if(NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) + if (NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Insert the address mapping for the found object into the copied * list */ addr_map->src_obj_pos.fileno = fileno_src; - addr_map->src_obj_pos.addr = oloc_src->addr; - addr_map->dst_addr = oloc_dst->addr; - addr_map->is_locked = TRUE; /* We've locked the object currently */ - addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ - addr_map->obj_class = obj_class; - addr_map->udata = cpy_udata; + addr_map->src_obj_pos.addr = oloc_src->addr; + addr_map->dst_addr = oloc_dst->addr; + addr_map->is_locked = TRUE; /* We've locked the object currently */ + addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ + addr_map->obj_class = obj_class; + addr_map->udata = cpy_udata; /* Insert into skip list */ - if(H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { + if (H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { addr_map = H5FL_FREE(H5O_addr_map_t, addr_map); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") } /* end if */ HGOTO_DONE(SUCCEED) } /* end if */ - } /* end if */ + } /* end if */ /* Flush any dirty messages in source object header to update the header chunks */ - if(H5O_flush_msgs(oloc_src->file, oh_src) < 0) + if (H5O__flush_msgs(oloc_src->file, oh_src) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object header messages") /* Allocate the destination object header and fill in header fields */ - if(NULL == (oh_dst = H5FL_CALLOC(H5O_t))) + if (NULL == (oh_dst = H5FL_CALLOC(H5O_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize header information */ oh_dst->version = oh_src->version; /* Version bounds check for destination object header */ - if(oh_dst->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(oloc_dst->file)]) + if (oh_dst->version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(oloc_dst->file)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "destination object header version out of bounds") - oh_dst->flags = oh_src->flags; + oh_dst->flags = oh_src->flags; oh_dst->link_msgs_seen = oh_src->link_msgs_seen; oh_dst->attr_msgs_seen = oh_src->attr_msgs_seen; - oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file); - oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file); - oh_dst->swmr_write = !!(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE); + oh_dst->sizeof_size = H5F_SIZEOF_SIZE(oloc_dst->file); + oh_dst->sizeof_addr = H5F_SIZEOF_ADDR(oloc_dst->file); + oh_dst->swmr_write = !!(H5F_INTENT(oloc_dst->file) & H5F_ACC_SWMR_WRITE); /* Copy time fields */ oh_dst->atime = oh_src->atime; @@ -471,12 +454,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Copy attribute storage information */ oh_dst->max_compact = oh_src->max_compact; - oh_dst->min_dense = oh_src->min_dense; + oh_dst->min_dense = oh_src->min_dense; /* Create object header proxy if doing SWMR writes */ - if(oh_dst->swmr_write) { + if (oh_dst->swmr_write) { /* Create virtual entry, for use as proxy */ - if(NULL == (oh_dst->proxy = H5AC_proxy_entry_create())) + if (NULL == (oh_dst->proxy = H5AC_proxy_entry_create())) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") } /* end if */ else @@ -489,7 +472,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oh_dst->alloc_nchunks = oh_dst->nchunks = 0; /* Allocate memory for the chunk array - always start with 1 chunk */ - if(NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)1))) + if (NULL == (oh_dst->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Update number of allocated chunks. There are still no chunks used. */ @@ -498,7 +481,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Allocate memory for "deleted" array. This array marks the message in * the source that shouldn't be copied to the destination. */ - if(NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) + if (NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); @@ -507,12 +490,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * Keep track of how many NULL or deleted messages we find (or create) */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_src->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_src->nmesgs; mesgno++) { /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno]); /* Sanity check */ - HDassert(!mesg_src->dirty); /* Should be cleared by earlier call to flush messages */ + HDassert(!mesg_src->dirty); /* Should be cleared by earlier call to flush messages */ /* Get message class to operate on */ copy_type = mesg_src->type; @@ -520,14 +503,14 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Check for continuation message; these are converted to NULL * messages because the destination OH will have only one chunk */ - if(H5O_CONT_ID == mesg_src->type->id || H5O_NULL_ID == mesg_src->type->id) { + if (H5O_CONT_ID == mesg_src->type->id || H5O_NULL_ID == mesg_src->type->id) { deleted[mesgno] = TRUE; ++null_msgs; copy_type = H5O_MSG_NULL; } /* end if */ HDassert(copy_type); - if(copy_type->pre_copy_file) { + if (copy_type->pre_copy_file) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(oloc_src->file, 0, oh_src, mesg_src, FAIL) @@ -538,58 +521,58 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, cpy_info->file_dst = oloc_dst->file; /* Perform "pre copy" operation on message */ - if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, - &(deleted[mesgno]), cpy_info, cpy_udata) < 0) + if ((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, &(deleted[mesgno]), cpy_info, + cpy_udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message") /* Check if the message should be deleted in the destination */ - if(deleted[mesgno]) + if (deleted[mesgno]) /* Mark message as deleted */ ++null_msgs; } /* end if(copy_type->pre_copy_file) */ - } /* end for */ + } /* end for */ /* Initialize size of message list. It may or may not include the NULL messages * detected above. */ - if(cpy_info->preserve_null) + if (cpy_info->preserve_null) oh_dst->alloc_nmesgs = oh_dst->nmesgs = oh_src->nmesgs; else oh_dst->alloc_nmesgs = oh_dst->nmesgs = (oh_src->nmesgs - null_msgs); /* Allocate memory for destination message array */ - if(oh_dst->alloc_nmesgs > 0) - if(NULL == (oh_dst->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh_dst->alloc_nmesgs))) + if (oh_dst->alloc_nmesgs > 0) + if (NULL == (oh_dst->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh_dst->alloc_nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* "copy" pass over messages, to perform main message copying */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); mesg_dst = &(oh_dst->mesg[mesgno]); /* Initialize non-zero components of destination message */ - mesg_dst->crt_idx = mesg_src->crt_idx; - mesg_dst->flags = mesg_src->flags; + mesg_dst->crt_idx = mesg_src->crt_idx; + mesg_dst->flags = mesg_src->flags; mesg_dst->raw_size = mesg_src->raw_size; - mesg_dst->type = mesg_src->type; + mesg_dst->type = mesg_src->type; /* If we're preserving deleted messages, set their types to 'NULL' * in the destination. */ - if(cpy_info->preserve_null && deleted[mesgno]) { - mesg_dst->type = H5O_MSG_NULL; + if (cpy_info->preserve_null && deleted[mesgno]) { + mesg_dst->type = H5O_MSG_NULL; mesg_dst->flags = 0; mesg_dst->dirty = TRUE; } /* end if */ @@ -602,9 +585,9 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, HDassert(copy_type); /* copy this message into destination file */ - if(copy_type->copy_file) { - hbool_t recompute_size; /* Whether copy_file callback created a shared message */ - unsigned mesg_flags; /* Message flags */ + if (copy_type->copy_file) { + hbool_t recompute_size; /* Whether copy_file callback created a shared message */ + unsigned mesg_flags; /* Message flags */ /* Decode the message if necessary. */ H5O_LOAD_NATIVE(oloc_src->file, 0, oh_src, mesg_src, FAIL) @@ -612,20 +595,18 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Get destination message flags, and unset shared and shareable * flags. mesg_dst->flags will contain the original flags for now. */ - mesg_flags = (unsigned)mesg_dst->flags & ~H5O_MSG_FLAG_SHARED - & ~H5O_MSG_FLAG_SHAREABLE; + mesg_flags = (unsigned)mesg_dst->flags & ~H5O_MSG_FLAG_SHARED & ~H5O_MSG_FLAG_SHAREABLE; /* Copy the source message */ recompute_size = FALSE; - if(NULL == (mesg_dst->native = H5O__msg_copy_file(copy_type, oloc_src->file, - mesg_src->native, oloc_dst->file, &recompute_size, - &mesg_flags, cpy_info, cpy_udata))) + if (NULL == (mesg_dst->native = + H5O__msg_copy_file(copy_type, oloc_src->file, mesg_src->native, oloc_dst->file, + &recompute_size, &mesg_flags, cpy_info, cpy_udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message") /* Check if the sharing state changed, and recompute the size if so */ - if(!(mesg_flags & H5O_MSG_FLAG_SHARED) - != !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) + if (!(mesg_flags & H5O_MSG_FLAG_SHARED) != !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) recompute_size = TRUE; /* Set destination message flags */ @@ -635,15 +616,15 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* (its sharing status or one of its components (for attributes) * could have changed) */ - if(recompute_size) - mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst, - H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native)); + if (recompute_size) + mesg_dst->raw_size = H5O_ALIGN_OH( + oh_dst, H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native)); - /* Mark the message in the destination as dirty, so it'll get encoded when the object header is flushed */ + /* Mark the message in the destination as dirty, so it'll get encoded when the object header is + * flushed */ mesg_dst->dirty = TRUE; } /* end if (mesg_src->type->copy_file) */ - } /* end of mesgno loop */ - + } /* end of mesgno loop */ /* Allocate the destination header and copy any messages that didn't have * copy callbacks. They get copied directly from the source image to the @@ -656,35 +637,35 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Compute space for messages. */ dst_oh_size = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { dst_oh_size += (uint64_t)H5O_SIZEOF_MSGHDR_OH(oh_dst); dst_oh_size += oh_dst->mesg[mesgno].raw_size; } /* end for */ /* Check if we need to determine correct value for chunk #0 size bits */ - if(oh_dst->version > H5O_VERSION_1) { + if (oh_dst->version > H5O_VERSION_1) { /* Reset destination object header's "chunk 0 size" flags */ oh_dst->flags = (uint8_t)(oh_dst->flags & ~H5O_HDR_CHUNK0_SIZE); /* Determine correct value for chunk #0 size bits */ - if(dst_oh_size > 4294967295) + if (dst_oh_size > 4294967295) oh_dst->flags |= H5O_HDR_CHUNK0_8; - else if(dst_oh_size > 65535) + else if (dst_oh_size > 65535) oh_dst->flags |= H5O_HDR_CHUNK0_4; - else if(dst_oh_size > 255) + else if (dst_oh_size > 255) oh_dst->flags |= H5O_HDR_CHUNK0_2; } /* end if */ /* Check if the chunk's data portion is too small */ dst_oh_gap = dst_oh_null = 0; - if(dst_oh_size < H5O_MIN_SIZE) { - size_t delta = (size_t)(H5O_MIN_SIZE - dst_oh_size); /* Delta in chunk size needed */ + if (dst_oh_size < H5O_MIN_SIZE) { + size_t delta = (size_t)(H5O_MIN_SIZE - dst_oh_size); /* Delta in chunk size needed */ /* Sanity check */ 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 (delta < H5O_SIZEOF_MSGHDR_OH(oh_dst)) dst_oh_gap = delta; else dst_oh_null = delta; @@ -700,7 +681,8 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, dst_oh_size += (uint64_t)H5O_SIZEOF_HDR(oh_dst); /* Allocate space for chunk in destination file */ - if(HADDR_UNDEF == (oh_dst->chunk[0].addr = H5MF_alloc(oloc_dst->file, H5FD_MEM_OHDR, (hsize_t)dst_oh_size))) + if (HADDR_UNDEF == + (oh_dst->chunk[0].addr = H5MF_alloc(oloc_dst->file, H5FD_MEM_OHDR, (hsize_t)dst_oh_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") addr_new = oh_dst->chunk[0].addr; @@ -713,12 +695,12 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * clear to zero bytes, so we just set the buffer to zero's here. * (QAK - 2010/08/17) */ - if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, (size_t)dst_oh_size))) + if (NULL == (oh_dst->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, (size_t)dst_oh_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set dest. chunk information */ oh_dst->chunk[0].size = (size_t)dst_oh_size; - oh_dst->chunk[0].gap = dst_oh_gap; + oh_dst->chunk[0].gap = dst_oh_gap; /* Update size of chunk array. The destination now has one chunk. */ oh_dst->nchunks = 1; @@ -735,29 +717,29 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Write the magic number for versions > 1 and skip the rest of the * header. This will be written when the header is flushed to disk. */ - if(oh_dst->version > H5O_VERSION_1) + if (oh_dst->version > H5O_VERSION_1) H5MM_memcpy(current_pos, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst); /* Loop through destination messages, updating their "raw" info */ null_msgs = 0; - for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { + for (mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set. */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); mesg_dst = &(oh_dst->mesg[mesgno]); /* Copy each message that wasn't dirtied above */ - if(!mesg_dst->dirty) + if (!mesg_dst->dirty) /* Copy the message header plus the message's raw data. */ H5MM_memcpy(current_pos, mesg_src->raw - msghdr_size, msghdr_size + mesg_src->raw_size); @@ -772,56 +754,56 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, orig_dst_msgs = oh_dst->nmesgs; /* Check if we need to add a NULL message to this header */ - if(dst_oh_null > 0) { - size_t null_idx; /* Index of new NULL message */ + if (dst_oh_null > 0) { + size_t null_idx; /* Index of new NULL message */ /* Make sure we have enough space for new NULL message */ - if(oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) - if(H5O_alloc_msgs(oh_dst, (size_t)1) < 0) + if (oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) + if (H5O__alloc_msgs(oh_dst, (size_t)1) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Create null message for [rest of] space in new chunk */ /* (account for chunk's magic # & checksum) */ - null_idx = oh_dst->nmesgs++; - oh_dst->mesg[null_idx].type = H5O_MSG_NULL; - oh_dst->mesg[null_idx].dirty = TRUE; - oh_dst->mesg[null_idx].native = NULL; - oh_dst->mesg[null_idx].raw = current_pos + msghdr_size; - oh_dst->mesg[null_idx].raw_size = dst_oh_null - msghdr_size; - oh_dst->mesg[null_idx].chunkno = 0; + null_idx = oh_dst->nmesgs++; + oh_dst->mesg[null_idx].type = H5O_MSG_NULL; + oh_dst->mesg[null_idx].dirty = TRUE; + oh_dst->mesg[null_idx].native = NULL; + oh_dst->mesg[null_idx].raw = current_pos + msghdr_size; + oh_dst->mesg[null_idx].raw_size = dst_oh_null - msghdr_size; + oh_dst->mesg[null_idx].chunkno = 0; } /* end if */ /* Make sure we filled the chunk, except for room at the end for a checksum */ - HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == (size_t)dst_oh_size + oh_dst->chunk[0].image); + HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == + (size_t)dst_oh_size + oh_dst->chunk[0].image); /* Set the dest. object location to the first chunk address */ HDassert(H5F_addr_defined(addr_new)); oloc_dst->addr = addr_new; - /* If we are merging committed datatypes and this is a committed datatype, insert * the copied datatype into the list of committed datatypes in the target file. */ - if(cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) - if(H5O__copy_insert_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info) < 0) + if (cpy_info->merge_comm_dt && obj_class->type == H5O_TYPE_NAMED_DATATYPE) + if (H5O__copy_insert_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't insert committed datatype into destination list") /* Allocate space for the address mapping of the object copied */ - if(NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) + if (NULL == (addr_map = H5FL_MALLOC(H5O_addr_map_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Insert the address mapping for the new object into the copied list */ /* (Do this here, because "post copy" possibly checks it) */ H5F_GET_FILENO(oloc_src->file, addr_map->src_obj_pos.fileno); addr_map->src_obj_pos.addr = oloc_src->addr; - addr_map->dst_addr = oloc_dst->addr; - addr_map->is_locked = TRUE; /* We've locked the object currently */ - addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ - addr_map->obj_class = obj_class; - addr_map->udata = cpy_udata; + addr_map->dst_addr = oloc_dst->addr; + addr_map->is_locked = TRUE; /* We've locked the object currently */ + addr_map->inc_ref_count = 0; /* Start with no additional ref counts to add */ + addr_map->obj_class = obj_class; + addr_map->udata = cpy_udata; /* Insert into skip list */ - if(H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { + if (H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) { addr_map = H5FL_FREE(H5O_addr_map_t, addr_map); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") } /* end if */ @@ -830,16 +812,16 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * object header for destination object */ null_msgs = 0; - for(mesgno = 0; mesgno < orig_dst_msgs; mesgno++) { + for (mesgno = 0; mesgno < orig_dst_msgs; mesgno++) { /* Skip any deleted or NULL messages in the source unless the * preserve_null flag is set */ - if(FALSE == cpy_info->preserve_null) { - while(deleted[mesgno + null_msgs]) { + if (FALSE == cpy_info->preserve_null) { + while (deleted[mesgno + null_msgs]) { ++null_msgs; HDassert(mesgno + null_msgs < oh_src->nmesgs); } /* end while */ - } /* end if */ + } /* end if */ /* Set up convenience variables */ mesg_src = &(oh_src->mesg[mesgno + null_msgs]); @@ -852,8 +834,8 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, copy_type = mesg_dst->type; HDassert(copy_type); - if(copy_type->post_copy_file && mesg_src->native) { - unsigned mesg_flags; /* Message flags */ + if (copy_type->post_copy_file && mesg_src->native) { + unsigned mesg_flags; /* Message flags */ /* Sanity check destination message */ HDassert(mesg_dst->type == mesg_src->type); @@ -867,67 +849,68 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, cpy_info->oh_dst = oh_dst; /* Perform "post copy" operation on message */ - if((copy_type->post_copy_file)(oloc_src, mesg_src->native, oloc_dst, - mesg_dst->native, &mesg_flags, cpy_info) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'post copy' operation on message") + if ((copy_type->post_copy_file)(oloc_src, mesg_src->native, oloc_dst, mesg_dst->native, + &mesg_flags, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "unable to perform 'post copy' operation on message") /* Verify that the flags did not change */ - HDassert(mesg_flags == (unsigned) mesg_dst->flags); + HDassert(mesg_flags == (unsigned)mesg_dst->flags); } /* end if */ - } /* end for */ + } /* end for */ /* Indicate that the destination address will no longer be locked */ addr_map->is_locked = FALSE; /* Increment object header's reference count, if any descendents have created links to this object */ - if(addr_map->inc_ref_count) { + if (addr_map->inc_ref_count) { H5_CHECK_OVERFLOW(addr_map->inc_ref_count, hsize_t, unsigned); oh_dst->nlink += (unsigned)addr_map->inc_ref_count; } /* end if */ /* Retag all copied metadata to apply the destination object's tag */ - if(H5AC_retag_copied_metadata(oloc_dst->file, oloc_dst->addr) < 0) + if (H5AC_retag_copied_metadata(oloc_dst->file, oloc_dst->addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "unable to re-tag metadata entries") /* Set metadata tag for destination object's object header */ H5_BEGIN_TAG(oloc_dst->addr); /* Insert destination object header in cache */ - if(H5AC_insert_entry(oloc_dst->file, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(oloc_dst->file, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") - oh_dst = NULL; + oh_dst = NULL; inserted = TRUE; /* Reset metadat tag */ H5_END_TAG /* Set obj_type and udata, if requested */ - if(obj_type) { + if (obj_type) { HDassert(udata); *obj_type = obj_class->type; - *udata = cpy_udata; + *udata = cpy_udata; } /* end if */ done: /* Free deleted array */ - if(deleted) + if (deleted) H5MM_free(deleted); /* Release pointer to source object header and its derived objects */ - if(oh_src && H5O_unprotect(oloc_src, oh_src, H5AC__NO_FLAGS_SET) < 0) + if (oh_src && H5O_unprotect(oloc_src, oh_src, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Free destination object header on failure */ - if(ret_value < 0) { - if(oh_dst && !inserted) { - if(H5O__free(oh_dst) < 0) + if (ret_value < 0) { + if (oh_dst && !inserted) { + if (H5O__free(oh_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - if(H5O_loc_reset(oloc_dst) < 0) + if (H5O_loc_reset(oloc_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") } /* end if */ - if(addr_map == NULL && cpy_udata) { - if(obj_class && obj_class->free_copy_file_udata) + if (addr_map == NULL && cpy_udata) { + if (obj_class && obj_class->free_copy_file_udata) obj_class->free_copy_file_udata(cpy_udata); } /* end if */ } @@ -935,7 +918,6 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__copy_header_real() */ - /*------------------------------------------------------------------------- * Function: H5O_copy_header_map * @@ -950,14 +932,13 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, *------------------------------------------------------------------------- */ herr_t -H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, - H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type, - void **udata /*out*/) +H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5O_copy_t *cpy_info, + hbool_t inc_depth, H5O_type_t *obj_type, void **udata /*out*/) { - H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ - H5_obj_t src_obj_pos; /* Position of source object */ - hbool_t inc_link; /* Whether to increment the link count for the object */ - herr_t ret_value = SUCCEED; + H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ + H5_obj_t src_obj_pos; /* Position of source object */ + hbool_t inc_link; /* Whether to increment the link count for the object */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -973,24 +954,23 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, src_obj_pos.addr = oloc_src->addr; /* Search for the object in the skip list of copied objects */ - addr_map = (H5O_addr_map_t *)H5SL_search(cpy_info->map_list, - &src_obj_pos); + addr_map = (H5O_addr_map_t *)H5SL_search(cpy_info->map_list, &src_obj_pos); /* Check if address is already in list of objects copied */ - if(addr_map == NULL) { + if (addr_map == NULL) { /* Copy object for the first time */ /* Check for incrementing the depth of copy */ /* (Can't do this for all copies, since committed datatypes should always be copied) */ - if(inc_depth) + if (inc_depth) cpy_info->curr_depth++; /* Copy object referred to */ - if(H5O__copy_header_real(oloc_src, oloc_dst, cpy_info, obj_type, udata) < 0) + if (H5O__copy_header_real(oloc_src, oloc_dst, cpy_info, obj_type, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Check for incrementing the depth of copy */ - if(inc_depth) + if (inc_depth) cpy_info->curr_depth--; /* When an object is copied for the first time, increment it's link */ @@ -1004,10 +984,10 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, oloc_dst->addr = addr_map->dst_addr; /* Return saved obj_type and udata, if requested */ - if(obj_type) { + if (obj_type) { HDassert(udata); *obj_type = addr_map->obj_class->type; - *udata = addr_map->udata; + *udata = addr_map->udata; } /* end if */ /* If the object is locked currently (because we are copying a group @@ -1015,7 +995,7 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, * increment it's deferred reference count instead of incrementing the * reference count now. */ - if(addr_map->is_locked) { + if (addr_map->is_locked) { addr_map->inc_ref_count++; inc_link = FALSE; } /* end if */ @@ -1024,15 +1004,14 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, } /* end else */ /* Increment destination object's link count, if allowed */ - if(inc_link) - if(H5O_link(oloc_dst, 1) < 0) + if (inc_link) + if (H5O_link(oloc_dst, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to increment object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_copy_header_map() */ - /*-------------------------------------------------------------------------- NAME H5O__copy_free_addrmap_cb @@ -1062,7 +1041,7 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN HDassert(item); /* Release user data for particular type of object */ - if(item->udata) { + if (item->udata) { HDassert(item->obj_class); HDassert(item->obj_class->free_copy_file_udata); (item->obj_class->free_copy_file_udata)(item->udata); @@ -1072,9 +1051,8 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN item = H5FL_FREE(H5O_addr_map_t, item); FUNC_LEAVE_NOAPI(0) -} /* H5O__copy_free_addrmap_cb() */ +} /* H5O__copy_free_addrmap_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_header * @@ -1088,15 +1066,14 @@ H5O__copy_free_addrmap_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UN *------------------------------------------------------------------------- */ 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_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 */ + H5O_copy_t cpy_info; /* Information for copying object */ + 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 */ - herr_t ret_value = SUCCEED; + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + unsigned cpy_option = 0; /* Copy options */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1110,40 +1087,40 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, HDmemset(&cpy_info, 0, sizeof(H5O_copy_t)); /* Get the copy property list */ - if(NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id))) + if (NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve the copy parameters */ - if(H5P_get(ocpy_plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) + 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 */ - if(H5P_peek(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + 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") /* Get callback info */ - if(H5P_get(ocpy_plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_get(ocpy_plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") /* Convert copy flags into copy struct */ - if((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) { + if ((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) { cpy_info.copy_shallow = TRUE; - cpy_info.max_depth = 1; + cpy_info.max_depth = 1; } /* end if */ else - cpy_info.max_depth = -1; /* Current default is for full, recursive hier. copy */ + cpy_info.max_depth = -1; /* Current default is for full, recursive hier. copy */ cpy_info.curr_depth = 0; - if((cpy_option & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) cpy_info.expand_soft_link = TRUE; - if((cpy_option & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) cpy_info.expand_ext_link = TRUE; - if((cpy_option & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) + if ((cpy_option & H5O_COPY_EXPAND_REFERENCE_FLAG) > 0) cpy_info.expand_ref = TRUE; - if((cpy_option & H5O_COPY_WITHOUT_ATTR_FLAG) > 0) + if ((cpy_option & H5O_COPY_WITHOUT_ATTR_FLAG) > 0) cpy_info.copy_without_attr = TRUE; - if((cpy_option & H5O_COPY_PRESERVE_NULL_FLAG) > 0) + if ((cpy_option & H5O_COPY_PRESERVE_NULL_FLAG) > 0) cpy_info.preserve_null = TRUE; - if((cpy_option & H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) > 0) + if ((cpy_option & H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG) > 0) cpy_info.merge_comm_dt = TRUE; /* Add dt_list to copy struct */ @@ -1157,23 +1134,22 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, cpy_info.lcpl_id = lcpl_id; /* Create a skip list to keep track of which objects are copied */ - if(NULL == (cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ, NULL))) + if (NULL == (cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list") /* copy the object from the source file to the destination file */ - if(H5O__copy_header_real(oloc_src, oloc_dst, &cpy_info, NULL, NULL) < 0) + if (H5O__copy_header_real(oloc_src, oloc_dst, &cpy_info, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: - if(cpy_info.map_list) + if (cpy_info.map_list) H5SL_destroy(cpy_info.map_list, H5O__copy_free_addrmap_cb, NULL); - if(cpy_info.dst_dt_list) + if (cpy_info.dst_dt_list) H5SL_destroy(cpy_info.dst_dt_list, H5O__copy_free_comm_dt_cb, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_header() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_obj * @@ -1187,15 +1163,14 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, *------------------------------------------------------------------------- */ static herr_t -H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id) +H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - 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 */ - hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1217,7 +1192,7 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, cached_dst_file = dst_loc->oloc->file; /* Copy the object from the source file to the destination file */ - if(H5O__copy_header(src_loc->oloc, &new_oloc, ocpypl_id, lcpl_id) < 0) + if (H5O__copy_header(src_loc->oloc, &new_oloc, ocpypl_id, lcpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Patch dst_loc. Again, this can be removed once oloc's point to shared @@ -1225,214 +1200,18 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, dst_loc->oloc->file = cached_dst_file; /* Insert the new object in the destination file's group */ - if(H5L_link(dst_loc, dst_name, &new_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") + if (H5L_link(dst_loc, dst_name, &new_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") entry_inserted = TRUE; done: /* Free the ID to name buffers */ - if(entry_inserted) + if (entry_inserted) H5G_loc_free(&new_loc); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_obj() */ - -/*------------------------------------------------------------------------- - * Function: H5O__copy_obj_by_ref - * - * Purpose: Copy the object pointed by _src_ref. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Peter Cao - * Aug 7 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, - H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - HDassert(src_oloc); - HDassert(dst_oloc); - - /* Perform the copy, or look up existing copy */ - if((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") - - /* Check if a new valid object is copied to the destination */ - if(H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) { - char tmp_obj_name[80]; - H5G_name_t new_path; - H5O_loc_t new_oloc; - H5G_loc_t new_loc; - - /* Set up group location for new object */ - new_loc.oloc = &new_oloc; - new_loc.path = &new_path; - H5G_loc_reset(&new_loc); - new_oloc.file = dst_oloc->file; - new_oloc.addr = dst_oloc->addr; - - /* Pick a default name for the new object */ - HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", (unsigned long long)dst_oloc->addr); - - /* Create a link to the newly copied object */ - /* Note: since H5O_copy_header_map actually copied the target object, it - * must exist either in cache or on disk, therefore it is is safe to not - * pass the obj_type and udata fields returned by H5O_copy_header_map. - * This could be changed in the future to slightly improve performance - * --NAF */ - if(H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") - - H5G_loc_free(&new_loc); - } /* if (H5F_addr_defined(dst_oloc.addr)) */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__copy_obj_by_ref() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_copy_expand_ref - * - * Purpose: Copy the object pointed by _src_ref. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Peter Cao - * Aug 7 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, H5F_t *file_dst, - void *_dst_ref, size_t ref_count, H5R_type_t ref_type, H5O_copy_t *cpy_info) -{ - H5O_loc_t dst_oloc; /* Copied object object location */ - H5O_loc_t src_oloc; /* Temporary object location for source object */ - H5G_loc_t dst_root_loc; /* The location of root group of the destination file */ - const uint8_t *q; /* Pointer to source OID to store */ - uint8_t *p; /* Pointer to destination OID to store */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(file_src); - HDassert(_src_ref); - HDassert(file_dst); - HDassert(_dst_ref); - HDassert(ref_count); - HDassert(cpy_info); - - /* Initialize object locations */ - H5O_loc_reset(&src_oloc); - H5O_loc_reset(&dst_oloc); - src_oloc.file = file_src; - dst_oloc.file = file_dst; - - /* Set up the root group in the destination file */ - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") - - /* Copy object references */ - if(H5R_OBJECT == ref_type) { - hobj_ref_t *src_ref = (hobj_ref_t *)_src_ref; - hobj_ref_t *dst_ref = (hobj_ref_t *)_dst_ref; - - /* Making equivalent references in the destination file */ - for(i = 0; i < ref_count; i++) { - /* Set up for the object copy for the reference */ - q = (uint8_t *)(&src_ref[i]); - H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr)); - dst_oloc.addr = HADDR_UNDEF; - - /* Attempt to copy object from source to destination file */ - if(src_oloc.addr != (haddr_t)0) { - if(H5O__copy_obj_by_ref(&src_oloc, &dst_oloc, &dst_root_loc, cpy_info) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") - } /* end if */ - else - /* Set parameters so the reference is written as all 0's */ - HDmemset(&dst_oloc.addr, 0, sizeof(dst_oloc.addr)); - - /* Set the object reference info for the destination file */ - p = (uint8_t *)(&dst_ref[i]); - H5F_addr_encode(dst_oloc.file, &p, dst_oloc.addr); - } /* end for */ - } /* end if */ - /* Copy region references */ - else if(H5R_DATASET_REGION == ref_type) { - hdset_reg_ref_t *src_ref = (hdset_reg_ref_t *)_src_ref; - hdset_reg_ref_t *dst_ref = (hdset_reg_ref_t *)_dst_ref; - uint8_t *buf = NULL; /* Buffer to store serialized selection in */ - H5HG_t hobjid; /* Heap object ID */ - size_t buf_size; /* Length of object in heap */ - - /* Making equivalent references in the destination file */ - for(i = 0; i < ref_count; i++) { - /* Get the heap ID for the dataset region */ - q = (const uint8_t *)(&src_ref[i]); - H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(hobjid.addr)); - UINT32DECODE(q, hobjid.idx); - - if(hobjid.addr != (haddr_t)0) { - /* Get the dataset region from the heap (allocate inside routine) */ - if((buf = (uint8_t *)H5HG_read(src_oloc.file, &hobjid, NULL, &buf_size)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") - - /* Get the object oid for the dataset */ - q = (const uint8_t *)buf; - H5F_addr_decode(src_oloc.file, (const uint8_t **)&q, &(src_oloc.addr)); - dst_oloc.addr = HADDR_UNDEF; - - /* copy the object pointed by the ref to the destination */ - if(H5O__copy_obj_by_ref(&src_oloc, &dst_oloc, &dst_root_loc, cpy_info) < 0) { - H5MM_xfree(buf); - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") - } /* end if */ - - /* Serialize object ID */ - p = (uint8_t *)buf; - H5F_addr_encode(dst_oloc.file, &p, dst_oloc.addr); - - /* Save the serialized buffer to the destination */ - if(H5HG_insert(dst_oloc.file, buf_size, buf, &hobjid) < 0) { - H5MM_xfree(buf); - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "Unable to write dataset region information") - } /* end if */ - } /* end if */ - else - /* Set parameters so the reference is written as all 0's */ - HDmemset(&hobjid, 0, sizeof(hobjid)); - - /* Set the dataset region reference info for the destination file */ - p = (uint8_t *)(&dst_ref[i]); - H5F_addr_encode(dst_oloc.file, &p, hobjid.addr); - UINT32ENCODE(p, hobjid.idx); - - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); - } /* end for */ - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_copy_expand_ref() */ - - /*------------------------------------------------------------------------- * Function: H5O__copy_free_comm_dt_cb * @@ -1448,8 +1227,8 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, H5F_t *file_dst, 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; - H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; + 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 @@ -1458,13 +1237,12 @@ H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) HDassert(key->dt); key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); - key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); - addr = H5FL_FREE(haddr_t, addr); + key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); + addr = H5FL_FREE(haddr_t, addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__copy_free_comm_dt_cb */ - /*------------------------------------------------------------------------- * Function: H5O__copy_comm_dt_cmp * @@ -1483,18 +1261,18 @@ H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) static int H5O__copy_comm_dt_cmp(const void *_key1, const void *_key2) { - const H5O_copy_search_comm_dt_key_t *key1 = (const H5O_copy_search_comm_dt_key_t *)_key1; - const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; - int ret_value = 0; + const H5O_copy_search_comm_dt_key_t *key1 = (const H5O_copy_search_comm_dt_key_t *)_key1; + const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR /* Check fileno. It is unlikely to be different so check if they are equal * first so only one comparison needs to be made. */ - if(key1->fileno != key2->fileno) { - if(key1->fileno < key2->fileno) + if (key1->fileno != key2->fileno) { + if (key1->fileno < key2->fileno) HGOTO_DONE(-1) - if(key1->fileno > key2->fileno) + if (key1->fileno > key2->fileno) HGOTO_DONE(1) } /* end if */ @@ -1504,12 +1282,11 @@ H5O__copy_comm_dt_cmp(const void *_key1, const void *_key2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_comm_dt_cmp */ - /*------------------------------------------------------------------------- - * Function: H5O_copy_search_comm_dt_attr_cb + * Function: H5O__copy_search_comm_dt_attr_cb * * Purpose: Callback for H5O_attr_iterate_real from - * H5O_copy_search_comm_dt_check. Checks if the attribute's + * H5O__copy_search_comm_dt_check. Checks if the attribute's * datatype is committed. If it is, adds it to the merge * committed dt skiplist present in udata if it does not match * any already present. @@ -1522,16 +1299,16 @@ 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_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_key_t *key = NULL; /* Skiplist key */ - haddr_t *addr = NULL; /* Destination address */ - hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(attr); @@ -1540,55 +1317,54 @@ H5O_copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) HDassert(H5F_addr_defined(udata->obj_oloc.addr)); /* Get attribute datatype */ - if(NULL == (dt = H5A_type(attr))) + if (NULL == (dt = H5A_type(attr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get attribute datatype") /* Check if the datatype is committed and search the skip list if so */ - if(H5T_committed(dt)) { + if (H5T_is_named(dt)) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy datatype into key */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_copy(H5O_DTYPE_ID, dt, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_copy(H5O_DTYPE_ID, dt, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy datatype message") /* Get datatype object fileno */ H5F_GET_FILENO(udata->obj_oloc.file, key->fileno); - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = ((H5O_shared_t *)(key->dt))->u.loc.oh_addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: /* Release resources */ - if(!obj_inserted) { - if(key) { - if(key->dt) + if (!obj_inserted) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) { + if (addr) { HDassert(ret_value < 0); addr = H5FL_FREE(haddr_t, addr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_copy_search_comm_dt_attr_cb */ +} /* end H5O__copy_search_comm_dt_attr_cb */ - /*------------------------------------------------------------------------- - * Function: H5O_copy_search_comm_dt_check + * Function: H5O__copy_search_comm_dt_check * * Purpose: Check if the object at obj_oloc is or contains a reference * to a committed datatype. If it does, adds it to the merge @@ -1603,17 +1379,16 @@ H5O_copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) *------------------------------------------------------------------------- */ 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_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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(obj_oloc); @@ -1622,97 +1397,96 @@ H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, HDassert(udata->dst_root_loc); /* Get pointer to object class for this object */ - if((obj_class = H5O__obj_class(obj_oloc)) == NULL) + if ((obj_class = H5O__obj_class(obj_oloc)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") /* Check if the object is a datatype, a dataset using a committed * datatype, or contains an attribute using a committed datatype */ - if(obj_class->type == H5O_TYPE_NAMED_DATATYPE) { + if (obj_class->type == H5O_TYPE_NAMED_DATATYPE) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the destination datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(obj_oloc->file, key->fileno); /* Check if the datatype is already present in the skip list */ - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = obj_oloc->addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ - else if(obj_class->type == H5O_TYPE_DATASET) { + } /* end if */ + else if (obj_class->type == H5O_TYPE_DATASET) { /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the destination datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read(obj_oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") - /* Check if the datatype is committed and search the skip list if so - */ - if(H5T_committed(key->dt)) { + /* Check if the datatype is committed and search the skip list if so */ + if (H5T_is_named(key->dt)) { /* Get datatype object fileno */ H5F_GET_FILENO(obj_oloc->file, key->fileno); - if(!H5SL_search(udata->dst_dt_list, key)) { + if (!H5SL_search(udata->dst_dt_list, key)) { /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = ((H5O_shared_t *)(key->dt))->u.loc.oh_addr; - if(H5SL_insert(udata->dst_dt_list, addr, key) < 0) + if (H5SL_insert(udata->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") obj_inserted = TRUE; } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Search within attributes */ - attr_op.op_type = H5A_ATTR_OP_LIB; - attr_op.u.lib_op = H5O_copy_search_comm_dt_attr_cb; + attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.u.lib_op = H5O__copy_search_comm_dt_attr_cb; udata->obj_oloc.file = obj_oloc->file; udata->obj_oloc.addr = obj_oloc->addr; - if(H5O_attr_iterate_real((hid_t)-1, obj_oloc, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, udata) < 0) + if (H5O_attr_iterate_real((hid_t)-1, obj_oloc, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, &attr_op, + udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "error iterating over attributes"); done: /* Release resources */ - if(!obj_inserted) { - if(key) { - if(key->dt) + if (!obj_inserted) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) { + if (addr) { HDassert(ret_value < 0); addr = H5FL_FREE(haddr_t, addr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_copy_search_comm_dt_check */ +} /* end H5O__copy_search_comm_dt_check */ - /*------------------------------------------------------------------------- * Function: H5O__copy_search_comm_dt_cb * * Purpose: H5G_visit callback to add committed datatypes to the merge * committed dt skiplist. Mostly a wrapper for - * H5O_copy_search_comm_dt_check. + * H5O__copy_search_comm_dt_check. * * Return: Non-negative on success/Negative on failure * @@ -1722,15 +1496,16 @@ H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, *------------------------------------------------------------------------- */ static herr_t -H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, - const H5L_info_t *linfo, void *_udata) +H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, + void *_udata) { - H5O_copy_search_comm_dt_ud_t *udata = (H5O_copy_search_comm_dt_ud_t *)_udata; /* Skip list of dtypes in dest file */ - H5G_loc_t obj_loc; /* Location of object */ - H5O_loc_t obj_oloc; /* Object's object location */ - H5G_name_t obj_path; /* Object's group hier. path */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_copy_search_comm_dt_ud_t *udata = + (H5O_copy_search_comm_dt_ud_t *)_udata; /* Skip list of dtypes in dest file */ + H5G_loc_t obj_loc; /* Location of object */ + H5O_loc_t obj_oloc; /* Object's object location */ + H5G_name_t obj_path; /* Object's group hier. path */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1742,31 +1517,30 @@ H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, HDassert(udata->dst_root_loc); /* Check if this is a hard link */ - if(linfo->type == H5L_TYPE_HARD) { + if (linfo->type == H5L_TYPE_HARD) { /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; obj_loc.path = &obj_path; H5G_loc_reset(&obj_loc); /* Find the object */ - if(H5G_loc_find(udata->dst_root_loc, name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->dst_root_loc, name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; /* Check object and add to skip list if appropriate */ - if(H5O_copy_search_comm_dt_check(&obj_oloc, udata) < 0) + if (H5O__copy_search_comm_dt_check(&obj_oloc, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "can't check object") } /* end if */ done: /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_search_comm_dt_cb */ - /*------------------------------------------------------------------------- * Function: H5O__copy_search_comm_dt * @@ -1785,14 +1559,14 @@ H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, *------------------------------------------------------------------------- */ static htri_t -H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, - H5O_loc_t *oloc_dst/*in, out*/, H5O_copy_t *cpy_info) +H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*in, out*/, + H5O_copy_t *cpy_info) { - H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - 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 */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + 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 */ FUNC_ENTER_STATIC @@ -1800,37 +1574,37 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, HDassert(oh_src); HDassert(oloc_dst); HDassert(oloc_dst->file); - HDassert(H5F_FILE_ID(oloc_dst->file) >= 0); + HDassert(H5F_ID_EXISTS(oloc_dst->file)); HDassert(cpy_info); /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the source datatype */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(oloc_dst->file, key->fileno); /* Check if the destination dtype list exists, create it if it does not */ - if(!cpy_info->dst_dt_list) { + if (!cpy_info->dst_dt_list) { /* Create the skip list */ - if(NULL == (cpy_info->dst_dt_list = H5SL_create(H5SL_TYPE_GENERIC, H5O__copy_comm_dt_cmp))) + if (NULL == (cpy_info->dst_dt_list = H5SL_create(H5SL_TYPE_GENERIC, H5O__copy_comm_dt_cmp))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for committed datatypes") /* Add suggested types to list, if they are present */ - if(cpy_info->dst_dt_suggestion_list) { + if (cpy_info->dst_dt_suggestion_list) { H5O_copy_dtype_merge_list_t *suggestion = cpy_info->dst_dt_suggestion_list; - H5G_loc_t obj_loc; /* Location of object */ - H5O_loc_t obj_oloc; /* Object's object location */ - H5G_name_t obj_path; /* Object's group hier. path */ + H5G_loc_t obj_loc; /* Location of object */ + H5O_loc_t obj_oloc; /* Object's object location */ + H5G_name_t obj_path; /* Object's group hier. path */ /* Set up the root group in the destination file */ - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Set up opened group location to fill in */ @@ -1839,99 +1613,99 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5G_loc_reset(&obj_loc); /* Build udata */ - udata.dst_dt_list = cpy_info->dst_dt_list; - udata.dst_root_loc = &dst_root_loc; + udata.dst_dt_list = cpy_info->dst_dt_list; + udata.dst_root_loc = &dst_root_loc; udata.obj_oloc.file = NULL; udata.obj_oloc.addr = HADDR_UNDEF; /* Walk through the list of datatype suggestions */ - while(suggestion) { + while (suggestion) { /* Find the object */ - if(H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc/*out*/) < 0) + if (H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc /*out*/) < 0) /* Ignore errors - i.e. suggestions not present in * destination file */ H5E_clear_stack(NULL); 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 (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 */ /* Free location */ - if(H5G_loc_free(&obj_loc) < 0) + if (H5G_loc_free(&obj_loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); /* Advance the suggestion pointer */ suggestion = suggestion->next; } /* end while */ - } /* end if */ + } /* end if */ } - if(!cpy_info->dst_dt_list_complete) { + if (!cpy_info->dst_dt_list_complete) { /* Search for the type in the destination file, and return its address * if found, but only if the list is populated with and only with * suggested types. We will search complete lists later. */ - if(cpy_info->dst_dt_suggestion_list - && NULL != (dst_addr = (haddr_t *)H5SL_search( - cpy_info->dst_dt_list, key))) { + if (cpy_info->dst_dt_suggestion_list && + NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { oloc_dst->addr = *dst_addr; - ret_value = TRUE; + ret_value = TRUE; } /* end if */ else { H5O_mcdt_search_ret_t search_cb_ret = H5O_MCDT_SEARCH_CONT; /* Make callback to see if we should search destination file */ - if(cpy_info->mcdt_cb) - if((search_cb_ret = cpy_info->mcdt_cb(cpy_info->mcdt_ud)) == H5O_MCDT_SEARCH_ERROR) + if (cpy_info->mcdt_cb) + if ((search_cb_ret = cpy_info->mcdt_cb(cpy_info->mcdt_ud)) == H5O_MCDT_SEARCH_ERROR) HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "callback returned error") - if(search_cb_ret == H5O_MCDT_SEARCH_CONT) { + if (search_cb_ret == H5O_MCDT_SEARCH_CONT) { /* Build the complete dst dt list */ /* Set up the root group in the destination file, if necessary */ - if(!dst_root_loc.oloc) { + if (!dst_root_loc.oloc) { HDassert(!dst_root_loc.path); - if(NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") - if(NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(oloc_dst->file)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to get object location for root group") + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(oloc_dst->file)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") } /* end if */ else HDassert(dst_root_loc.path); /* Build udata. Note that this may be done twice in some cases, but - * it should be rare and should be cheaper on average than trying to - * keep track of whether it was done before. */ - udata.dst_dt_list = cpy_info->dst_dt_list; - udata.dst_root_loc = &dst_root_loc; + * it should be rare and should be cheaper on average than trying to + * keep track of whether it was done before. */ + udata.dst_dt_list = cpy_info->dst_dt_list; + udata.dst_root_loc = &dst_root_loc; udata.obj_oloc.file = NULL; udata.obj_oloc.addr = HADDR_UNDEF; /* Traverse the destination file, adding committed datatypes to the skip - * list */ - if(H5G_visit(H5F_FILE_ID(oloc_dst->file), "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O__copy_search_comm_dt_cb, &udata) < 0) + * list */ + if (H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O__copy_search_comm_dt_cb, + &udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") cpy_info->dst_dt_list_complete = TRUE; } /* end if */ - else - if(search_cb_ret != H5O_MCDT_SEARCH_STOP) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown return value for callback") + else if (search_cb_ret != H5O_MCDT_SEARCH_STOP) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown return value for callback") } /* end if */ - } /* end if */ + } /* end if */ /* Search for the type in the destination file, and return its address if * found, but only if the list is complete */ - if(cpy_info->dst_dt_list_complete) { - if(NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { + if (cpy_info->dst_dt_list_complete) { + if (NULL != (dst_addr = (haddr_t *)H5SL_search(cpy_info->dst_dt_list, key))) { oloc_dst->addr = *dst_addr; - ret_value = TRUE; + ret_value = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: - if(key) { - if(key->dt) + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ @@ -1939,7 +1713,6 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_search_comm_dt */ - /*------------------------------------------------------------------------- * Function: H5O__copy_insert_comm_dt * @@ -1954,12 +1727,11 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, *------------------------------------------------------------------------- */ 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ + haddr_t * addr = NULL; /* Destination object address */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1972,37 +1744,36 @@ H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, HDassert(cpy_info->dst_dt_list); /* Allocate key */ - if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) + if (NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Read the datatype. Read from the source file because the destination * object could be changed in the post-copy. */ - if(NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) + if (NULL == (key->dt = (H5T_t *)H5O_msg_read_oh(file_src, oh_src, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read DTYPE message") /* Get destination object fileno */ H5F_GET_FILENO(oloc_dst->file, key->fileno); /* Allocate destination address */ - if(NULL == (addr = H5FL_MALLOC(haddr_t))) + if (NULL == (addr = H5FL_MALLOC(haddr_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Add the destination datatype to the skip list */ *addr = oloc_dst->addr; - if(H5SL_insert(cpy_info->dst_dt_list, addr, key) < 0) + if (H5SL_insert(cpy_info->dst_dt_list, addr, key) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") done: - if(ret_value < 0) { - if(key) { - if(key->dt) + if (ret_value < 0) { + if (key) { + if (key->dt) key->dt = (H5T_t *)H5O_msg_free(H5O_DTYPE_ID, key->dt); key = H5FL_FREE(H5O_copy_search_comm_dt_key_t, key); } /* end if */ - if(addr) + if (addr) addr = H5FL_FREE(haddr_t, addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_insert_comm_dt */ - diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c new file mode 100644 index 00000000000..f2372c1ace8 --- /dev/null +++ b/src/H5Ocopy_ref.c @@ -0,0 +1,488 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Ocopy_ref.c + * + * Purpose: Object with references copying routines. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, + H5O_copy_t *cpy_info); +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); +static herr_t H5O__copy_expand_ref_region1(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); +static herr_t H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, + const void *buf_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); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Declare extern the free list to manage blocks of type conversion data */ +H5FL_BLK_EXTERN(type_conv); + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5O__copy_obj_by_ref + * + * Purpose: Copy the object pointed to by src_oloc. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__copy_obj_by_ref(H5O_loc_t *src_oloc, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, H5O_copy_t *cpy_info) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(src_oloc); + HDassert(dst_oloc); + + /* Perform the copy, or look up existing copy */ + if ((ret_value = H5O_copy_header_map(src_oloc, dst_oloc, cpy_info, FALSE, NULL, NULL)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") + + /* Check if a new valid object is copied to the destination */ + if (H5F_addr_defined(dst_oloc->addr) && (ret_value > SUCCEED)) { + char tmp_obj_name[80]; + H5G_name_t new_path; + H5O_loc_t new_oloc; + H5G_loc_t new_loc; + + /* Set up group location for new object */ + new_loc.oloc = &new_oloc; + new_loc.path = &new_path; + H5G_loc_reset(&new_loc); + new_oloc.file = dst_oloc->file; + new_oloc.addr = dst_oloc->addr; + + /* Pick a default name for the new object */ + HDsnprintf(tmp_obj_name, sizeof(tmp_obj_name), "~obj_pointed_by_%llu", + (unsigned long long)dst_oloc->addr); + + /* Create a link to the newly copied object */ + /* Note: since H5O_copy_header_map actually copied the target object, it + * must exist either in cache or on disk, therefore it is is safe to not + * pass the obj_type and udata fields returned by H5O_copy_header_map. + * This could be changed in the future to slightly improve performance + * --NAF */ + if (H5L_link(dst_root_loc, tmp_obj_name, &new_loc, cpy_info->lcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link") + + H5G_loc_free(&new_loc); + } /* if (H5F_addr_defined(dst_oloc.addr)) */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__copy_obj_by_ref() */ + +/*------------------------------------------------------------------------- + * Function: H5O__copy_expand_ref_object1 + * + * Purpose: Copy the object pointed by a deprecated object reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +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 unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = {0}; + size_t buf_size = H5R_OBJ_REF_BUF_SIZE; + size_t i; /* Local index variable */ + size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* 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]; + H5O_token_t tmp_token = {0}; + + /* If data is not initialized, copy zeros and skip */ + if (0 == HDmemcmp(src_buf, zeros, buf_size)) + HDmemset(dst_buf, 0, buf_size); + else { + /* Set up for the object copy for the reference */ + if (H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address") + if (H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + if (!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") + dst_oloc->addr = HADDR_UNDEF; + + /* Attempt to copy object from source to destination file */ + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") + + /* Set the object reference info for the destination file */ + if (H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") + if (H5R__encode_token_obj_compat((const H5O_token_t *)&tmp_token, token_size, dst_buf, + &buf_size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address") + } /* end else */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__copy_expand_ref_object1() */ + +/*------------------------------------------------------------------------- + * Function: H5O__copy_expand_ref_region1 + * + * Purpose: Copy the object pointed by a deprecated region reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__copy_expand_ref_region1(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 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; + 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 */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* 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; + size_t data_size; + const uint8_t * p; + uint8_t * q; + + /* If data is not initialized, copy zeros and skip */ + if (0 == HDmemcmp(src_buf, zeros, buf_size)) + HDmemset(dst_buf, 0, buf_size); + else { + /* Read from heap */ + if (H5R__decode_heap(src_oloc->file, src_buf, &buf_size, &data, &data_size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode dataset region information") + + /* Get object address */ + p = (const uint8_t *)data; + H5F_addr_decode(src_oloc->file, &p, &src_oloc->addr); + if (!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0) { + H5MM_free(data); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") + } + dst_oloc->addr = HADDR_UNDEF; + + /* Attempt to copy object from source to destination file */ + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) { + H5MM_free(data); + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") + } /* end if */ + + /* Serialize object addr */ + q = (uint8_t *)data; + H5F_addr_encode(dst_oloc->file, &q, dst_oloc->addr); + + /* Write to heap */ + if (H5R__encode_heap(dst_oloc->file, dst_buf, &buf_size, data, (size_t)data_size) < 0) { + H5MM_free(data); + HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode dataset region information") + } + + /* Free the buffer allocated in H5R__decode_heap() */ + H5MM_free(data); + } /* end else */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__copy_expand_ref_region1() */ + +/*------------------------------------------------------------------------- + * Function: H5O__copy_expand_ref_object2 + * + * Purpose: Copy the object pointed by a reference (object, region, attribute). + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, const void *buf_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 */ + 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 */ + size_t conv_buf_size = 0; /* Buffer size */ + 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; + + FUNC_ENTER_STATIC + + /* Create datatype ID for src datatype. */ + if ((tid_src == H5I_INVALID_HID) && (tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") + + /* create a memory copy of the reference datatype */ + if (NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy") + if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) { + (void)H5T_close_real(dt_mem); + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") + } /* end if */ + + /* create reference datatype at the destinaton 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) { + (void)H5T_close_real(dt_dst); + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") + } /* end if */ + if ((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) { + (void)H5T_close_real(dt_dst); + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype") + } /* end if */ + + /* Set up the conversion functions */ + if (NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes") + if (NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes") + + /* Use extra conversion buffer (TODO we should avoid using an extra buffer once the H5Ocopy code has been + * reworked) */ + conv_buf_size = MAX(H5T_get_size(dt_src), H5T_get_size(dt_mem)) * ref_count; + if (NULL == (conv_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") + H5MM_memcpy(conv_buf, buf_src, nbytes_src); + + /* Convert from source file to memory */ + if (H5T_convert(tpath_src_mem, tid_src, tid_mem, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + + /* Retrieve loc ID */ + if ((dst_loc_id = H5F_get_id(dst_oloc->file)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* 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_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i]; + H5O_token_t tmp_token = {0}; + + /* Get src object address */ + if (H5R__get_obj_token(ref, &tmp_token, &token_size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token") + if (H5VL_native_token_to_addr(src_oloc->file, H5I_FILE, tmp_token, &src_oloc->addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address") + + /* Attempt to copy object from source to destination file */ + if (H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") + + /* Set dst object address */ + if (H5VL_native_addr_to_token(dst_oloc->file, H5I_FILE, dst_oloc->addr, &tmp_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") + if (H5R__set_obj_token(ref, (const H5O_token_t *)&tmp_token, token_size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token") + /* Do not set app_ref since references are released once the copy is done */ + if (H5R__set_loc_id(ref, dst_loc_id, TRUE, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id") + } /* end for */ + + /* Copy into another buffer, to reclaim memory later */ + if (NULL == (reclaim_buf = H5FL_BLK_MALLOC(type_conv, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") + H5MM_memcpy(reclaim_buf, conv_buf, conv_buf_size); + if (NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create simple dataspace") + + /* Convert from memory to destination file */ + if (H5T_convert(tpath_mem_dst, tid_mem, tid_dst, ref_count, (size_t)0, (size_t)0, conv_buf, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + H5MM_memcpy(buf_dst, conv_buf, nbytes_src); + + /* Reclaim space from reference data */ + if (H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim reference data") + +done: + if (buf_space && (H5S_close(buf_space) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't close dataspace") + /* Don't decrement ID, we want to keep underlying datatype */ + if (reg_tid_src && (tid_src > 0) && (NULL == H5I_remove(tid_src))) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if ((tid_mem > 0) && H5I_dec_ref(tid_mem) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if ((tid_dst > 0) && H5I_dec_ref(tid_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if (reclaim_buf) + reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); + if (conv_buf) + conv_buf = H5FL_BLK_FREE(type_conv, conv_buf); + if ((dst_loc_id != H5I_INVALID_HID) && (H5I_dec_ref(dst_loc_id) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__copy_expand_ref_object2() */ + +/*------------------------------------------------------------------------- + * Function: H5O_copy_expand_ref + * + * Purpose: Copy the object pointed by a reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src, size_t nbytes_src, + H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info) +{ + H5O_loc_t dst_oloc; /* Copied object object location */ + H5O_loc_t src_oloc; /* Temporary object location for source object */ + H5G_loc_t dst_root_loc; /* The location of root group of the destination file */ + size_t ref_count; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(file_src); + HDassert(buf_src); + HDassert(file_dst); + HDassert(buf_dst); + HDassert(nbytes_src); + HDassert(cpy_info); + + /* Initialize object locations */ + H5O_loc_reset(&src_oloc); + H5O_loc_reset(&dst_oloc); + src_oloc.file = file_src; + dst_oloc.file = file_dst; + + /* Set up the root group in the destination file */ + if (NULL == (dst_root_loc.oloc = H5G_oloc(H5G_rootof(file_dst)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group") + if (NULL == (dst_root_loc.path = H5G_nameof(H5G_rootof(file_dst)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") + + /* Determine # of reference elements to copy */ + ref_count = nbytes_src / H5T_get_size(dt_src); + + /* Copy object references */ + switch (H5T_get_ref_type(dt_src)) { + case H5R_OBJECT1: + if (H5O__copy_expand_ref_object1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, + cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_OBJECT1 reference") + break; + case H5R_DATASET_REGION1: + if (H5O__copy_expand_ref_region1(&src_oloc, buf_src, &dst_oloc, &dst_root_loc, buf_dst, ref_count, + cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand H5R_DATASET_REGION1 reference") + break; + case H5R_DATASET_REGION2: + case H5R_ATTR: + case H5R_OBJECT2: + if (H5O__copy_expand_ref_object2(&src_oloc, tid_src, dt_src, buf_src, nbytes_src, &dst_oloc, + &dst_root_loc, buf_dst, ref_count, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to expand reference") + break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + break; + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_copy_expand_ref() */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index b9ac1b68e55..2826bcdcecd 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,62 +26,54 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Ppublic.h" /* Property Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Ppublic.h" /* Property Lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifdef H5O_DEBUG - + /*------------------------------------------------------------------------- - * Function: H5O_assert + * Function: H5O__assert * - * Purpose: Sanity check the information for an object header data + * Purpose: Sanity check the information for an object header data * structure. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED (Doesn't fail, just crashes) * * Programmer: Quincey Koziol * Oct 17 2006 @@ -89,27 +81,27 @@ *------------------------------------------------------------------------- */ herr_t -H5O_assert(const H5O_t *oh) +H5O__assert(const H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message to examine */ - H5O_mesg_t *tmp_msg; /* Pointer to temporary message to examine */ - unsigned cont_msgs_found = 0; /* # of continuation messages for object */ - size_t meta_space; /* Size of header metadata */ - size_t mesg_space; /* Size of message raw data */ - size_t free_space; /* Size of free space in header */ - size_t hdr_size; /* Size of header's chunks */ - unsigned u, v; /* Local index variables */ + H5O_mesg_t *curr_msg; /* Pointer to current message to examine */ + H5O_mesg_t *tmp_msg; /* Pointer to temporary message to examine */ + unsigned cont_msgs_found = 0; /* # of continuation messages for object */ + size_t meta_space; /* Size of header metadata */ + size_t mesg_space; /* Size of message raw data */ + size_t free_space; /* Size of free space in header */ + size_t hdr_size; /* Size of header's chunks */ + unsigned u, v; /* Local index variables */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Initialize the tracking variables */ - hdr_size = 0; + hdr_size = 0; meta_space = (size_t)H5O_SIZEOF_HDR(oh) + (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); mesg_space = 0; free_space = 0; /* Loop over all chunks in object header */ - for(u = 0; u < oh->nchunks; u++) { + for (u = 0; u < oh->nchunks; u++) { /* Accumulate the size of the header on header */ hdr_size += oh->chunk[u].size; @@ -124,9 +116,10 @@ H5O_assert(const H5O_t *oh) HDassert(H5F_addr_defined(oh->chunk[u].addr)); /* Version specific checks */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Make certain that the magic number is correct for each chunk */ - HDassert(!HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); + HDassert( + !HDmemcmp(oh->chunk[u].image, (u == 0 ? H5O_HDR_MAGIC : H5O_CHK_MAGIC), H5_SIZEOF_MAGIC)); /* Check for valid gap size */ HDassert(oh->chunk[u].gap < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); @@ -137,33 +130,33 @@ H5O_assert(const H5O_t *oh) } /* end for */ /* Check for correct chunk #0 size flags */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { uint64_t chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); - if(chunk0_size <= 255) + if (chunk0_size <= 255) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_1); - else if(chunk0_size <= 65535) + else if (chunk0_size <= 65535) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_2); - else if(chunk0_size <= 4294967295) + else if (chunk0_size <= 4294967295) HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_4); else HDassert((oh->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_8); } /* end if */ /* Loop over all messages in object header */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { uint8_t H5_ATTR_NDEBUG_UNUSED *curr_hdr; /* Start of current message header */ - size_t curr_tot_size; /* Total size of current message (including header) */ + size_t curr_tot_size; /* Total size of current message (including header) */ - curr_hdr = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); + curr_hdr = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); curr_tot_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Accumulate information, based on the type of message */ - if(H5O_NULL_ID == curr_msg->type->id) + 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; - hbool_t H5_ATTR_NDEBUG_UNUSED found_chunk = FALSE; /* Found a chunk that matches */ + else if (H5O_CONT_ID == curr_msg->type->id) { + 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); @@ -172,13 +165,13 @@ H5O_assert(const H5O_t *oh) /* Sanity check that every continuation message has a matching chunk */ /* (and only one) */ - for(v = 0; v < oh->nchunks; v++) { - if(H5F_addr_eq(cont->addr, oh->chunk[v].addr) && cont->size == oh->chunk[v].size) { + for (v = 0; v < oh->nchunks; v++) { + if (H5F_addr_eq(cont->addr, oh->chunk[v].addr) && cont->size == oh->chunk[v].size) { HDassert(cont->chunkno == v); HDassert(!found_chunk); found_chunk = TRUE; } /* end if */ - } /* end for */ + } /* end for */ HDassert(found_chunk); meta_space += curr_tot_size; @@ -195,25 +188,29 @@ H5O_assert(const H5O_t *oh) HDassert(curr_msg->chunkno < oh->nchunks); /* Make certain null messages aren't in chunks with gaps */ - if(H5O_NULL_ID == curr_msg->type->id) + if (H5O_NULL_ID == curr_msg->type->id) HDassert(oh->chunk[curr_msg->chunkno].gap == 0); /* Make certain that the message is completely in a chunk message area */ - HDassert(curr_tot_size <= (oh->chunk[curr_msg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); - if(curr_msg->chunkno == 0) - HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert(curr_tot_size <= (oh->chunk[curr_msg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); + if (curr_msg->chunkno == 0) + HDassert(curr_hdr >= + oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); else - HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + (H5O_SIZEOF_CHKHDR_OH(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); - HDassert(curr_msg->raw + curr_msg->raw_size <= (oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); + HDassert(curr_hdr >= oh->chunk[curr_msg->chunkno].image + + (H5O_SIZEOF_CHKHDR_OH(oh) - H5O_SIZEOF_CHKSUM_OH(oh))); + HDassert(curr_msg->raw + curr_msg->raw_size <= + (oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size) - + (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[curr_msg->chunkno].gap)); /* Make certain that no other messages overlap this message */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(u != v) - HDassert(!((tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) >= curr_hdr - && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) - < (curr_hdr + curr_tot_size))); + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (u != v) + HDassert(!((tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) >= curr_hdr && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) < (curr_hdr + curr_tot_size))); } /* end for */ - } /* end for */ + } /* end for */ /* Sanity check that the # of cont. messages is correct for the # of chunks */ HDassert(oh->nchunks == (cont_msgs_found + 1)); @@ -222,10 +219,9 @@ H5O_assert(const H5O_t *oh) HDassert(hdr_size == (free_space + meta_space + mesg_space)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_assert() */ +} /* end H5O__assert() */ #endif /* H5O_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5O_debug_id * @@ -242,14 +238,14 @@ H5O_assert(const H5O_t *oh) herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->debug); HDassert(f); @@ -259,20 +255,19 @@ H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int ind HDassert(fwidth >= 0); /* Call the debug method in the class */ - if((ret_value = (type->debug)(f, mesg, stream, indent, fwidth)) < 0) + if ((ret_value = (type->debug)(f, mesg, stream, indent, fwidth)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "unable to debug message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_debug_id() */ - /*------------------------------------------------------------------------- - * Function: H5O_debug_real + * Function: H5O__debug_real * - * Purpose: Prints debugging info about an object header. + * Purpose: Prints debugging info about an object header. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Aug 6 1997 @@ -280,14 +275,14 @@ H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int ind *------------------------------------------------------------------------- */ herr_t -H5O_debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth) +H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth) { - size_t mesg_total = 0, chunk_total = 0, gap_total = 0; - unsigned *sequence = NULL; - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; + size_t mesg_total = 0, chunk_total = 0, gap_total = 0; + unsigned *sequence = NULL; + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check args */ HDassert(f); @@ -300,93 +295,73 @@ H5O_debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int /* debug */ HDfprintf(stream, "%*sObject Header...\n", indent, ""); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Dirty:", - oh->cache_info.is_dirty); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", - oh->version); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Header size (in bytes):", - (unsigned)H5O_SIZEOF_HDR(oh)); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Dirty:", oh->cache_info.is_dirty ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", oh->version); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of links:", - oh->nlink); + "Header size (in bytes):", (unsigned)H5O_SIZEOF_HDR(oh)); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of links:", oh->nlink); /* Extra information for later versions */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Display object's status flags */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute creation order tracked:", + (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? "Yes" : "No"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute creation order indexed:", + (oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? "Yes" : "No"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Attribute storage phase change values:", + (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? "Non-default" : "Default"); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute creation order tracked:", - (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) ? "Yes" : "No"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute creation order indexed:", - (oh->flags & H5O_HDR_ATTR_CRT_ORDER_INDEXED) ? "Yes" : "No"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Attribute storage phase change values:", - (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? "Non-default" : "Default"); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Timestamps:", - (oh->flags & H5O_HDR_STORE_TIMES) ? "Enabled" : "Disabled"); - if(oh->flags & ~H5O_HDR_ALL_FLAGS) - HDfprintf(stream, "*** UNKNOWN OBJECT HEADER STATUS FLAG: %02x!\n", - (unsigned)oh->flags); + "Timestamps:", (oh->flags & H5O_HDR_STORE_TIMES) ? "Enabled" : "Disabled"); + if (oh->flags & ~H5O_HDR_ALL_FLAGS) + HDfprintf(stream, "*** UNKNOWN OBJECT HEADER STATUS FLAG: %02x!\n", (unsigned)oh->flags); /* Only dump times, if they are tracked */ - if(oh->flags & H5O_HDR_STORE_TIMES) { - struct tm *tm; /* Time structure */ - char buf[128]; /* Buffer for formatting time info */ + if (oh->flags & H5O_HDR_STORE_TIMES) { + struct tm *tm; /* Time structure */ + char buf[128]; /* Buffer for formatting time info */ /* Time fields */ tm = HDlocaltime(&oh->atime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Access Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Access Time:", buf); tm = HDlocaltime(&oh->mtime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Modification Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Modification Time:", buf); tm = HDlocaltime(&oh->ctime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Change Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Change Time:", buf); tm = HDlocaltime(&oh->btime); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Birth Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Birth Time:", buf); } /* end if */ /* Attribute tracking fields */ - if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { + if (oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) { HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. compact attributes:", - (unsigned)oh->max_compact); + "Max. compact attributes:", (unsigned)oh->max_compact); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. dense attributes:", - (unsigned)oh->min_dense); + "Min. dense attributes:", (unsigned)oh->min_dense); } /* end if */ - } /* end if */ + } /* end if */ - HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, - "Number of messages (allocated):", - oh->nmesgs, oh->alloc_nmesgs); - HDfprintf(stream, "%*s%-*s %Zu (%Zu)\n", indent, "", fwidth, - "Number of chunks (allocated):", - oh->nchunks, oh->alloc_nchunks); + HDfprintf(stream, "%*s%-*s %zu (%zu)\n", indent, "", fwidth, + "Number of messages (allocated):", oh->nmesgs, oh->alloc_nmesgs); + HDfprintf(stream, "%*s%-*s %zu (%zu)\n", indent, "", fwidth, "Number of chunks (allocated):", oh->nchunks, + oh->alloc_nchunks); /* debug each chunk */ - for(i = 0, chunk_total = 0; i < oh->nchunks; i++) { + for (i = 0, chunk_total = 0; i < oh->nchunks; i++) { size_t chunk_size; HDfprintf(stream, "%*sChunk %d...\n", indent, "", i); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", - oh->chunk[i].addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(0, fwidth - 3), + "Address:", oh->chunk[i].addr); /* Decrement chunk 0's size by the object header prefix size */ - if(0 == i) { - if(H5F_addr_ne(oh->chunk[i].addr, addr)) + if (0 == i) { + if (H5F_addr_ne(oh->chunk[i].addr, addr)) HDfprintf(stream, "*** WRONG ADDRESS FOR CHUNK #0!\n"); chunk_size = oh->chunk[i].size - (size_t)H5O_SIZEOF_HDR(oh); } /* end if */ @@ -397,142 +372,131 @@ H5O_debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int chunk_total += chunk_size; gap_total += oh->chunk[i].gap; - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Size in bytes:", - chunk_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(0, fwidth - 3), "Size in bytes:", chunk_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Gap:", - oh->chunk[i].gap); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(0, fwidth - 3), "Gap:", oh->chunk[i].gap); } /* end for */ /* debug each message */ - if(NULL == (sequence = (unsigned *)H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(unsigned)))) + if (NULL == (sequence = (unsigned *)H5MM_calloc(NELMTS(H5O_msg_class_g) * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0, mesg_total = 0; i < oh->nmesgs; i++) { - const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */ - unsigned chunkno; /* Chunk for message */ + for (i = 0, mesg_total = 0; i < oh->nmesgs; i++) { + const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */ + unsigned chunkno; /* Chunk for message */ /* Accumulate message's size to total */ mesg_total += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; /* For version 2 object header, add size of "OCHK" for continuation chunk */ - if(oh->mesg[i].type->id == H5O_CONT_ID) + if (oh->mesg[i].type->id == H5O_CONT_ID) mesg_total += H5O_SIZEOF_CHKHDR_OH(oh); HDfprintf(stream, "%*sMessage %d...\n", indent, "", i); /* check for bad message id */ - if(oh->mesg[i].type->id >= (int)NELMTS(H5O_msg_class_g)) { + if (oh->mesg[i].type->id >= (int)NELMTS(H5O_msg_class_g)) { HDfprintf(stream, "*** BAD MESSAGE ID 0x%04x\n", oh->mesg[i].type->id); continue; } /* end if */ /* message name and size */ - HDfprintf(stream, "%*s%-*s 0x%04x `%s' (%d)\n", - indent + 3, "", MAX(0, fwidth - 3), - "Message ID (sequence number):", - (unsigned) (oh->mesg[i].type->id), - oh->mesg[i].type->name, - sequence[oh->mesg[i].type->id]++); - HDfprintf(stream, "%*s%-*s %t\n", indent + 3, "", MAX (0, fwidth - 3), - "Dirty:", - oh->mesg[i].dirty); - HDfprintf(stream, "%*s%-*s ", indent + 3, "", MAX (0, fwidth - 3), - "Message flags:"); - if(oh->mesg[i].flags) { + HDfprintf(stream, "%*s%-*s 0x%04x `%s' (%d)\n", indent + 3, "", MAX(0, fwidth - 3), + "Message ID (sequence number):", (unsigned)(oh->mesg[i].type->id), oh->mesg[i].type->name, + sequence[oh->mesg[i].type->id]++); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", MAX(0, fwidth - 3), + "Dirty:", oh->mesg[i].dirty ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s ", indent + 3, "", MAX(0, fwidth - 3), "Message flags:"); + if (oh->mesg[i].flags) { hbool_t flag_printed = FALSE; /* Sanity check that all flags in format are covered below */ - HDcompile_assert(H5O_MSG_FLAG_BITS == (H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_DONTSHARE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE|H5O_MSG_FLAG_MARK_IF_UNKNOWN|H5O_MSG_FLAG_WAS_UNKNOWN|H5O_MSG_FLAG_SHAREABLE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)); + HDcompile_assert(H5O_MSG_FLAG_BITS == + (H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED | H5O_MSG_FLAG_DONTSHARE | + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE | H5O_MSG_FLAG_MARK_IF_UNKNOWN | + H5O_MSG_FLAG_WAS_UNKNOWN | H5O_MSG_FLAG_SHAREABLE | + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)); - if(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { HDfprintf(stream, "%sC", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) { HDfprintf(stream, "%sS", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) { HDfprintf(stream, "%sDS", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE) { HDfprintf(stream, "%sFIUW", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) { HDfprintf(stream, "%sMIU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_WAS_UNKNOWN) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_WAS_UNKNOWN) { HDassert(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN); HDfprintf(stream, "%sWU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_SHAREABLE) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_SHAREABLE) { HDfprintf(stream, "%sSA", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) { + if (oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) { HDfprintf(stream, "%sFIUA", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(!flag_printed) + if (!flag_printed) HDfprintf(stream, "-"); HDfprintf(stream, ">\n"); - if(oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS) - HDfprintf(stream, "%*s%-*s 0x%02x\n", indent + 3,"", MAX(0, fwidth - 3), - "*** ADDITIONAL UNKNOWN FLAGS --->", - oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS); + if (oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS) + HDfprintf(stream, "%*s%-*s 0x%02x\n", indent + 3, "", MAX(0, fwidth - 3), + "*** ADDITIONAL UNKNOWN FLAGS --->", oh->mesg[i].flags & ~H5O_MSG_FLAG_BITS); } /* end if */ else HDfprintf(stream, "\n"); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", MAX(0, fwidth - 3), - "Chunk number:", - oh->mesg[i].chunkno); + "Chunk number:", oh->mesg[i].chunkno); chunkno = oh->mesg[i].chunkno; - if(chunkno >= oh->nchunks) + if (chunkno >= oh->nchunks) HDfprintf(stream, "*** BAD CHUNK NUMBER\n"); - HDfprintf(stream, "%*s%-*s (%Zu, %Zu) bytes\n", indent + 3, "", MAX(0, fwidth - 3), - "Raw message data (offset, size) in chunk:", - (size_t)(oh->mesg[i].raw - oh->chunk[chunkno].image), - oh->mesg[i].raw_size); + HDfprintf(stream, "%*s%-*s (%zu, %zu) bytes\n", indent + 3, "", MAX(0, fwidth - 3), + "Raw message data (offset, size) in chunk:", + (size_t)(oh->mesg[i].raw - oh->chunk[chunkno].image), oh->mesg[i].raw_size); /* check the size */ - if((oh->mesg[i].raw + oh->mesg[i].raw_size > - oh->chunk[chunkno].image + oh->chunk[chunkno].size) || - (oh->mesg[i].raw < oh->chunk[chunkno].image)) + if ((oh->mesg[i].raw + oh->mesg[i].raw_size > oh->chunk[chunkno].image + oh->chunk[chunkno].size) || + (oh->mesg[i].raw < oh->chunk[chunkno].image)) HDfprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n"); /* decode the message */ debug_type = oh->mesg[i].type; - if(NULL == oh->mesg[i].native && debug_type->decode) + if (NULL == oh->mesg[i].native && debug_type->decode) H5O_LOAD_NATIVE(f, H5O_DECODEIO_NOCHANGE, oh, &oh->mesg[i], FAIL) /* print the message */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), - "Message Information:"); - if(debug_type->debug && oh->mesg[i].native != NULL) + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Message Information:"); + if (debug_type->debug && oh->mesg[i].native != NULL) (debug_type->debug)(f, oh->mesg[i].native, stream, indent + 6, MAX(0, fwidth - 6)); else HDfprintf(stream, "%*s\n", indent + 6, ""); } /* end for */ - if((mesg_total + gap_total) != chunk_total) + if ((mesg_total + gap_total) != chunk_total) HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n"); done: /* Release resources */ - if(sequence) + if (sequence) sequence = (unsigned *)H5MM_xfree(sequence); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_debug_real() */ +} /* end H5O__debug_real() */ - /*------------------------------------------------------------------------- * Function: H5O_debug * @@ -548,9 +512,9 @@ 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_loc_t loc; /* Object location for object to delete */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -562,21 +526,20 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) HDassert(fwidth >= 0); /* Set up the object location */ - loc.file = f; - loc.addr = addr; + loc.file = f; + loc.addr = addr; loc.holding_file = FALSE; - if(NULL == (oh = H5O_protect(&loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* debug */ - if(H5O_debug_real(f, oh, addr, stream, indent, fwidth) < 0) + if (H5O__debug_real(f, oh, addr, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "debug dump call failed") done: - if(oh && H5O_unprotect(&loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(&loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_debug() */ - diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 56c3f761a13..2a0a32157f7 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,57 +25,354 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ + +#include "H5VLnative_private.h" /* Native VOL connector */ +#ifndef H5_NO_DEPRECATED_SYMBOLS /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ +/* Adapter for using deprecated H5Ovisit1 callbacks with the VOL */ +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 */ +} H5O_visit1_adapter_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - +static herr_t H5O__reset_info1(H5O_info1_t *oinfo); +static herr_t H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, void *op_data); +static herr_t H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_info1_t *oinfo, + unsigned fields); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/*------------------------------------------------------------------------- + * Function: H5O__reset_info1 + * + * Purpose: Resets/initializes an H5O_info1_t struct. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__reset_info1(H5O_info1_t *oinfo) +{ + FUNC_ENTER_STATIC_NOERR; + + /* Reset the passed-in info struct */ + HDmemset(oinfo, 0, sizeof(H5O_info1_t)); + oinfo->type = H5O_TYPE_UNKNOWN; + oinfo->addr = HADDR_UNDEF; -/* Compatibility function prototypes to replace non-versioned function for use by macro in next version - * see HDFFV-10552 -#ifndef H5_NO_DEPRECATED_SYMBOLS + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5O__reset_info1() */ + +/*------------------------------------------------------------------------- + * Function: H5O__iterate1_adapter + * + * Purpose: Retrieve information about an object, according to the order + * of an index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 26 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, void *op_data) +{ + H5O_visit1_adapter_t *shim_data = (H5O_visit1_adapter_t *)op_data; + 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_loc_params_t loc_params; /* Location parameters for VOL callback */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(oinfo2); + HDassert(op_data); + + /* Reset the legacy info struct */ + if (H5O__reset_info1(&oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") + + /* Check for retrieving data model information */ + dm_fields = shim_data->fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); + if (dm_fields) { + /* Set the data model fields */ + if (shim_data->fields & H5O_INFO_BASIC) { + oinfo.fileno = oinfo2->fileno; + oinfo.type = oinfo2->type; + oinfo.rc = oinfo2->rc; + + /* Deserialize VOL object token into object address */ + if (H5VLnative_token_to_addr(obj_id, oinfo2->token, &oinfo.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + } + if (shim_data->fields & H5O_INFO_TIME) { + oinfo.atime = oinfo2->atime; + oinfo.mtime = oinfo2->mtime; + oinfo.ctime = oinfo2->ctime; + oinfo.btime = oinfo2->btime; + } + if (shim_data->fields & H5O_INFO_NUM_ATTRS) + oinfo.num_attrs = oinfo2->num_attrs; + } + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") + + /* Check for retrieving native information */ + nat_fields = shim_data->fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); + if (nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ + + /* Retrieve the object's native information */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &loc_params, &nat_info, nat_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") + + /* Set the native fields */ + if (shim_data->fields & H5O_INFO_HDR) + H5MM_memcpy(&(oinfo.hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + if (shim_data->fields & H5O_INFO_META_SIZE) { + H5MM_memcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo.meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + } + } + + /* Invoke the application callback */ + ret_value = (shim_data->real_op)(obj_id, name, &oinfo, shim_data->real_op_data); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5O__iterate1_adapter() */ + +/*------------------------------------------------------------------------- + * Function: H5O__get_info_old + * + * Purpose: Retrieve deprecated info about an object. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 21 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_info1_t *oinfo, unsigned fields) +{ + unsigned dm_fields; /* Fields for data model query */ + unsigned nat_fields; /* Fields for native query */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(vol_obj); + HDassert(loc_params); + + /* Reset the passed-in info struct */ + if (H5O__reset_info1(oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") + + /* Check for retrieving data model information */ + dm_fields = fields & (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS); + if (dm_fields) { + H5O_info2_t dm_info; /* Data model object info */ + + /* Retrieve the object's data model information */ + if (H5VL_object_get(vol_obj, loc_params, H5VL_OBJECT_GET_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &dm_info, dm_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get data model info for object") + + /* Set the data model fields */ + if (fields & H5O_INFO_BASIC) { + void *vol_obj_data; + + if (NULL == (vol_obj_data = H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + + oinfo->fileno = dm_info.fileno; + oinfo->type = dm_info.type; + oinfo->rc = dm_info.rc; + + /* Deserialize VOL object token into object address */ + if (H5VL_native_token_to_addr(vol_obj_data, loc_params->obj_type, dm_info.token, &oinfo->addr) < + 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + } /* end if */ + if (fields & H5O_INFO_TIME) { + oinfo->atime = dm_info.atime; + oinfo->mtime = dm_info.mtime; + oinfo->ctime = dm_info.ctime; + oinfo->btime = dm_info.btime; + } /* end if */ + if (fields & H5O_INFO_NUM_ATTRS) + oinfo->num_attrs = dm_info.num_attrs; + } /* end if */ + + /* Check for retrieving native information */ + nat_fields = fields & (H5O_INFO_HDR | H5O_INFO_META_SIZE); + if (nat_fields) { + H5O_native_info_t nat_info; /* Native object info */ + + /* Retrieve the object's native information */ + if (H5VL_object_optional(vol_obj, H5VL_NATIVE_OBJECT_GET_NATIVE_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, loc_params, &nat_info, nat_fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get native info for object") + + /* Set the native fields */ + if (fields & H5O_INFO_HDR) + H5MM_memcpy(&(oinfo->hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + if (fields & H5O_INFO_META_SIZE) { + H5MM_memcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo->meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__get_info_old() */ + +/*------------------------------------------------------------------------- + * Function: H5Oopen_by_addr + * + * Purpose: Warning! This function is EXTREMELY DANGEROUS! + * Improper use can lead to FILE CORRUPTION, INACCESSIBLE DATA, + * and other VERY BAD THINGS! + * + * This function opens an object using its address within the + * HDF5 file, similar to an HDF5 hard link. The open object + * is identical to an object opened with H5Oopen() and should + * be closed with H5Oclose() or a type-specific closing + * function (such as H5Gclose() ). + * + * This function is very dangerous if called on an invalid + * address. For this reason, H5Oincr_refcount() should be + * used to prevent HDF5 from deleting any object that is + * referenced by address (e.g. by a user-defined link). + * H5Odecr_refcount() should be used when the object is + * no longer being referenced by address (e.g. when the UD link + * is deleted). + * + * The address of the HDF5 file on disk has no effect on + * H5Oopen_by_addr(), nor does the use of any unusual file + * drivers. The "address" is really the offset within the + * HDF5 file, and HDF5's file drivers will transparently + * map this to an address on disk for the filesystem. + * + * Return: Success: An open object identifier + * Failure: H5I_INVALID_HID + * + * Programmer: James Laird + * July 14 2006 + * + *------------------------------------------------------------------------- */ +hid_t +H5Oopen_by_addr(hid_t loc_id, haddr_t addr) +{ + 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 */ + H5VL_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + hbool_t is_native_vol_obj; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "ia", loc_id, addr); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (is_native_vol_obj) { + /* This is a native-specific routine that requires serialization of the token */ + if (H5VLnative_addr_to_token(loc_id, addr, &obj_token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, H5I_INVALID_HID, + "can't serialize address into object token") + } /* end if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oopen_by_addr is only meant to be used with the native VOL connector") + + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Open the object */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + + /* Register the object's ID */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oopen_by_addr() */ /*------------------------------------------------------------------------- * Function: H5Oget_info1 @@ -88,29 +385,35 @@ *------------------------------------------------------------------------- */ herr_t -H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) +H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, oinfo); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo/*out*/, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info1() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_name1 * @@ -122,35 +425,45 @@ H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) +H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!oinfo) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name1() */ - /*------------------------------------------------------------------------- * Function: H5Oget_info_by_idx1 * @@ -166,51 +479,244 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t la *------------------------------------------------------------------------- */ 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_info_t *oinfo, hid_t lapl_id) +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) { - H5G_loc_t loc; /* Location of group */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, - lapl_id); + H5TRACE7("e", "i*sIiIoh*xi", loc_id, group_name, idx_type, order, n, oinfo, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!group_name || !*group_name) + if (!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!oinfo) + if (!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, H5O_INFO_ALL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx1() */ +/*------------------------------------------------------------------------- + * Function: H5Oget_info2 + * + * Purpose: Retrieve information about an object. + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * July 7 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields) +{ + 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 */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); + + /* Check args */ + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info2() */ + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_name2 + * + * Purpose: Retrieve information about an object + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: SUCCEED/FAIL + * + * Programmer: Neil Fortner + * July 7 2010 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); + + /* Check args */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info_by_name2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_name2() */ + +/*------------------------------------------------------------------------- + * Function: H5Oget_info_by_idx2 + * + * Purpose: Retrieve information about an object, according to the order + * of an index. + * + * NOTE: Add a parameter "fields" to indicate selection of object info. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 26 2006 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + hbool_t is_native_vol_obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIoh*xIui", loc_id, group_name, idx_type, order, n, oinfo, fields, lapl_id); + + /* Check args */ + if (!group_name || !*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!oinfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Oget_info_by_idx2 is only meant to be used with the native VOL connector") + + /* Retrieve deprecated info struct */ + if (H5O__get_info_old(vol_obj, &loc_params, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get deprecated info for object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Oget_info_by_idx2() */ /*------------------------------------------------------------------------- - * Function: H5Ovisit1 + * Function: H5Ovisit1 * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -229,44 +735,60 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, * the callback about the object. * * 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. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * November 25 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data) +H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data) { - herr_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); /* Check args */ - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - /* Call internal object visitation routine */ - if((ret_value = H5O__visit(obj_id, ".", idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit1() */ - /*------------------------------------------------------------------------- * Function: H5Ovisit_by_name1 * @@ -287,51 +809,257 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, * the callback about the object. * * 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. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * November 24 2007 * *------------------------------------------------------------------------- */ herr_t -H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) +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) { - herr_t ret_value; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, - lapl_id); + H5TRACE7("e", "i*sIiIox*xi", loc_id, obj_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if(!obj_name || !*obj_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + if (!obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") + if (!*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") - if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(!op) + if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Call internal object visitation routine */ - if((ret_value = H5O__visit(loc_id, obj_name, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = H5O_INFO_ALL; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Ovisit_by_name1() */ -/* Compatibility function prototypes to replace non-versioned function for use by macro in next version - * see HDFFV-10552 -#endif (* H5_NO_DEPRECATED_SYMBOLS *) +/*------------------------------------------------------------------------- + * Function: H5Ovisit2 + * + * Purpose: Recursively visit an object and all the objects reachable + * from it. If the starting object is a group, all the objects + * linked to from that group will be visited. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Soft links and user-defined links are ignored during + * this operation. + * + * NOTE: Each _object_ reachable from the initial group will only + * be visited once. If multiple hard links point to the same + * object, the first link to the object's path (according to the + * iteration index and iteration order given) will be used to in + * the callback about the object. + * + * NOTE: Add a a parameter "fields" to indicate selection of + * object info to be retrieved to the callback "op". + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 25 2007 + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); + + /* Check args */ + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Ovisit2 is only meant to be used with the native VOL connector") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = fields; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit2() */ + +/*------------------------------------------------------------------------- + * Function: H5Ovisit_by_name2 + * + * Purpose: Recursively visit an object and all the objects reachable + * from it. If the starting object is a group, all the objects + * linked to from that group will be visited. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Soft links and user-defined links are ignored during + * this operation. + * + * NOTE: Each _object_ reachable from the initial group will only + * be visited once. If multiple hard links point to the same + * object, the first link to the object's path (according to the + * iteration index and iteration order given) will be used to in + * the callback about the object. + * + * NOTE: Add a a parameter "fields" to indicate selection of + * object info to be retrieved to the callback "op". + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 24 2007 + * + *------------------------------------------------------------------------- */ +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_loc_params_t loc_params; + H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ + hbool_t is_native_vol_obj; + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "i*sIiIox*xIui", loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id); + + /* Check args */ + if (!obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") + if (!*obj_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be an empty string") + if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + if (fields & ~H5O_INFO_ALL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Check if the VOL object is a native VOL connector object */ + if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, + "can't determine if VOL object is native connector object") + if (!is_native_vol_obj) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, H5I_INVALID_HID, + "H5Ovisit_by_name2 is only meant to be used with the native VOL connector") + + /* Set location 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; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Set up adapter */ + shim_data.real_op = op; + shim_data.fields = fields; + shim_data.real_op_data = op_data; + + /* Visit the objects */ + if ((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, (int)idx_type, (int)order, H5O__iterate1_adapter, + (void *)&shim_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ovisit_by_name2() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Odrvinfo.c b/src/H5Odrvinfo.c index 80fbe0feb31..8bebc6d3cd7 100644 --- a/src/H5Odrvinfo.c +++ b/src/H5Odrvinfo.c @@ -6,12 +6,11 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 * Thursday, March 1, 2007 * @@ -19,53 +18,50 @@ * in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#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, 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 size_t H5O_drvinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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); +static herr_t H5O__drvinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O_drvinfo_decode, /*decode message */ - H5O_drvinfo_encode, /*encode message */ - H5O_drvinfo_copy, /*copy the native value */ - H5O_drvinfo_size, /*raw message size */ - H5O__drvinfo_reset, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__drvinfo_debug /*debug the message */ + H5O_DRVINFO_ID, /*message id number */ + "driver info", /*message name for debugging */ + sizeof(H5O_drvinfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__drvinfo_decode, /*decode message */ + H5O__drvinfo_encode, /*encode message */ + H5O__drvinfo_copy, /*copy the native value */ + H5O__drvinfo_size, /*raw message size */ + H5O__drvinfo_reset, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__drvinfo_debug /*debug the message */ }}; /* Current version of driver info information */ -#define H5O_DRVINFO_VERSION 0 +#define H5O_DRVINFO_VERSION 0 - /*------------------------------------------------------------------------- - * Function: H5O_drvinfo_decode + * Function: H5O__drvinfo_decode * * Purpose: Decode a shared message table message and return a pointer * to a newly allocated H5O_drvinfo_t struct. @@ -79,26 +75,26 @@ const H5O_msg_class_t H5O_MSG_DRVINFO[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O_drvinfo_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__drvinfo_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_drvinfo_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_drvinfo_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); HDassert(p); /* Version of message */ - if(*p++ != H5O_DRVINFO_VERSION) + if (*p++ != H5O_DRVINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (mesg = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message") + if (NULL == (mesg = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message") /* Retrieve driver name */ H5MM_memcpy(mesg->name, p, 8); @@ -110,9 +106,9 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(mesg->len); /* Allocate space for buffer */ - if(NULL == (mesg->buf = (uint8_t *)H5MM_malloc(mesg->len))) { + if (NULL == (mesg->buf = (uint8_t *)H5MM_malloc(mesg->len))) { mesg = (H5O_drvinfo_t *)H5MM_xfree(mesg); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info buffer") } /* end if */ /* Copy encoded driver info into buffer */ @@ -123,11 +119,10 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_drvinfo_decode() */ +} /* end H5O__drvinfo_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_drvinfo_encode + * Function: H5O__drvinfo_encode * * Purpose: Encode a v1 B-tree 'K' value message. * @@ -139,11 +134,12 @@ H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -159,11 +155,10 @@ H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_share H5MM_memcpy(p, mesg->buf, mesg->len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_drvinfo_encode() */ +} /* end H5O__drvinfo_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_drvinfo_copy + * Function: H5O__drvinfo_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -177,28 +172,29 @@ H5O_drvinfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_share *------------------------------------------------------------------------- */ static void * -H5O_drvinfo_copy(const void *_mesg, void *_dest) +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 */ + const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; + H5O_drvinfo_t * dest = (H5O_drvinfo_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_drvinfo_t *)H5MM_malloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_drvinfo_t *)H5MM_malloc(sizeof(H5O_drvinfo_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* Shallow copy the fields */ *dest = *mesg; /* Copy the buffer */ - if(NULL == (dest->buf = (uint8_t *)H5MM_malloc(mesg->len))) { - if(dest != _dest) + if (NULL == (dest->buf = (uint8_t *)H5MM_malloc(mesg->len))) { + if (dest != _dest) dest = (H5O_drvinfo_t *)H5MM_xfree(dest); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ H5MM_memcpy(dest->buf, mesg->buf, mesg->len); @@ -207,11 +203,10 @@ H5O_drvinfo_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_drvinfo_copy() */ +} /* end H5O__drvinfo_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_drvinfo_size + * Function: H5O__drvinfo_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. @@ -225,26 +220,25 @@ H5O_drvinfo_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); HDassert(mesg); - ret_value = 1 + /* Version number */ - 8 + /* Driver name */ - 2 + /* Buffer length */ - mesg->len; /* Buffer */ + ret_value = 1 + /* Version number */ + 8 + /* Driver name */ + 2 + /* Buffer length */ + mesg->len; /* Buffer */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_drvinfo_size() */ +} /* end H5O__drvinfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__drvinfo_reset * @@ -261,7 +255,7 @@ H5O_drvinfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_s static herr_t H5O__drvinfo_reset(void *_mesg) { - H5O_drvinfo_t *mesg = (H5O_drvinfo_t *) _mesg; + H5O_drvinfo_t *mesg = (H5O_drvinfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -274,7 +268,6 @@ H5O__drvinfo_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__drvinfo_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__drvinfo_debug * @@ -288,8 +281,7 @@ H5O__drvinfo_reset(void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; @@ -302,12 +294,8 @@ H5O__drvinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Driver name:", mesg->name); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Buffer size:", mesg->len); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Driver name:", mesg->name); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Buffer size:", mesg->len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__drvinfo_debug() */ - - diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 61fa32adbef..1be9522beb1 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -6,115 +6,110 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5T_FRIEND /*prevent warning from including H5Tpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /*prevent warning from including H5Tpkg */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ /* 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, size_t p_size, const uint8_t *p); -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_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, + size_t p_size, const uint8_t *p); +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); -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, 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, H5O_loc_t *dst_oloc, void *mesg_dst, - H5O_copy_t *cpy_info); -static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +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, + 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, + H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info); +static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_DTYPE -#define H5O_SHARED_DECODE H5O_dtype_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_dtype_decode -#define H5O_SHARED_ENCODE H5O_dtype_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_dtype_encode -#define H5O_SHARED_SIZE H5O_dtype_shared_size -#define H5O_SHARED_SIZE_REAL H5O_dtype_size -#define H5O_SHARED_DELETE H5O__dtype_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_DTYPE +#define H5O_SHARED_DECODE H5O__dtype_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__dtype_decode +#define H5O_SHARED_ENCODE H5O__dtype_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O__dtype_encode +#define H5O_SHARED_SIZE H5O__dtype_shared_size +#define H5O_SHARED_SIZE_REAL H5O__dtype_size +#define H5O_SHARED_DELETE H5O__dtype_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__dtype_shared_link +#define H5O_SHARED_LINK H5O__dtype_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file -#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file -#define H5O_SHARED_POST_COPY_FILE H5O_dtype_shared_post_copy_file -#undef H5O_SHARED_POST_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd -#define H5O_SHARED_DEBUG H5O_dtype_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file +#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__dtype_shared_post_copy_file +#undef H5O_SHARED_POST_COPY_FILE_REAL +#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd +#define H5O_SHARED_DEBUG H5O__dtype_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* Macros to check for the proper version of a datatype */ #ifdef H5_STRICT_FORMAT_CHECKS /* If the version is too low, give an error. No error if nochange is set * because in that case we are either debugging or deleting the object header */ -#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ - if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) \ +#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ + if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) \ HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, ERR, "incorrect " CLASS " datatype version") #else /* H5_STRICT_FORMAT_CHECKS */ /* If the version is too low and we are allowed to change the message, upgrade * it and mark the object header as dirty */ -#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ - if(((VERS) < (MIN_VERS)) && !(*(IOF) & H5O_DECODEIO_NOCHANGE)) { \ - (VERS) = (MIN_VERS); \ - if(H5T__upgrade_version((DT), (VERS)) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \ - *(IOF) |= H5O_DECODEIO_DIRTY; \ - } /* end if */ +#define H5O_DTYPE_CHECK_VERSION(DT, VERS, MIN_VERS, IOF, CLASS, ERR) \ + if (((VERS) < (MIN_VERS)) && !(*(IOF)&H5O_DECODEIO_NOCHANGE)) { \ + (VERS) = (MIN_VERS); \ + if (H5T__upgrade_version((DT), (VERS)) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade " CLASS " encoding version") \ + *(IOF) |= H5O_DECODEIO_DIRTY; \ + } /* end if */ #endif /* H5_STRICT_FORMAT_CHECKS */ /* This message derives from H5O message class */ 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_dtype_shared_decode, /* decode message */ - H5O_dtype_shared_encode, /* encode message */ - H5O_dtype_copy, /* copy the native value */ - H5O_dtype_shared_size, /* size of raw message */ - H5O__dtype_reset, /* reset method */ - H5O__dtype_free, /* free method */ - H5O__dtype_shared_delete, /* file delete method */ - H5O__dtype_shared_link, /* link method */ - H5O_dtype_set_share, /* set share method */ - H5O_dtype_can_share, /* can share method */ - H5O_dtype_pre_copy_file, /* pre copy native value to file */ - H5O__dtype_shared_copy_file, /* copy native value to file */ - H5O_dtype_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_dtype_shared_debug /* debug the message */ + 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__dtype_shared_decode, /* decode message */ + H5O__dtype_shared_encode, /* encode message */ + H5O__dtype_copy, /* copy the native value */ + H5O__dtype_shared_size, /* size of raw message */ + H5O__dtype_reset, /* reset method */ + H5O__dtype_free, /* free method */ + H5O__dtype_shared_delete, /* file delete method */ + H5O__dtype_shared_link, /* link method */ + H5O__dtype_set_share, /* set share method */ + H5O__dtype_can_share, /* can share method */ + H5O__dtype_pre_copy_file, /* pre copy native value to file */ + H5O__dtype_shared_copy_file, /* copy native value to file */ + H5O__dtype_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__dtype_shared_debug /* debug the message */ }}; - /*------------------------------------------------------------------------- - * Function: H5O_dtype_decode_helper + * Function: H5O__dtype_decode_helper * * Purpose: Decodes a datatype * @@ -129,14 +124,14 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ *------------------------------------------------------------------------- */ static htri_t -H5O_dtype_decode_helper(H5F_t *f, 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) { - unsigned flags, version; - unsigned i; - size_t z; - htri_t ret_value = FALSE; /* Return value */ + unsigned flags, version; + unsigned i; + size_t z; + htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(pp && *pp); @@ -144,24 +139,24 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p /* Version, class & flags */ UINT32DECODE(*pp, flags); - version = (flags>>4) & 0x0f; - if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_3) + version = (flags >> 4) & 0x0f; + if (version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message") dt->shared->version = version; - dt->shared->type = (H5T_class_t)(flags & 0x0f); + dt->shared->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; /* Size */ UINT32DECODE(*pp, dt->shared->size); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer types... */ - 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; + 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; dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); @@ -172,19 +167,19 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p * Floating-point types... */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - if(version >= H5O_DTYPE_VERSION_3) { + if (version >= H5O_DTYPE_VERSION_3) { /* Unsupported byte order*/ - if((flags & 0x40) && !(flags & 0x1)) + if ((flags & 0x40) && !(flags & 0x1)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message") /* VAX order if both 1st and 6th bits are turned on*/ - if(flags & 0x40) + 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; - switch((flags >> 4) & 0x03) { + switch ((flags >> 4) & 0x03) { case 0: dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE; break; @@ -203,16 +198,16 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff; UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); - dt->shared->u.atomic.u.f.epos = *(*pp)++; + 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); - dt->shared->u.atomic.u.f.mpos = *(*pp)++; + 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); 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; UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; @@ -221,13 +216,13 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p /* * Character string types... */ - dt->shared->u.atomic.order = H5T_ORDER_NONE; - dt->shared->u.atomic.prec = 8 * dt->shared->size; - dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; - dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); + dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags >> 4) & 0x0f); break; @@ -235,7 +230,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p /* * Bit fields... */ - dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + 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; UINT16DECODE(*pp, dt->shared->u.atomic.offset); @@ -248,206 +243,223 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p */ z = flags & (H5T_OPAQUE_TAG_MAX - 1); HDassert(0 == (z & 0x7)); /*must be aligned*/ - if(NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1))) + if (NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5MM_memcpy(dt->shared->u.opaque.tag, *pp, z); dt->shared->u.opaque.tag[z] = '\0'; *pp += z; break; - case H5T_COMPOUND: - { - 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; + case H5T_COMPOUND: { + 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); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* - * 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) - 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 */ - - /* Decode the field name */ - dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); - - /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ - if(version >= H5O_DTYPE_VERSION_3) - /* Advance past name, including null terminator */ - *pp += HDstrlen((const char *)*pp) + 1; - else - /* Advance multiple of 8 w/ null terminator */ - *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; + /* + * 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) + 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 */ + + /* Decode the field name */ + dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); - /* 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) - - /* 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 */ - ndims = *(*pp)++; - - /* Check that ndims is valid */ - if(ndims > 4) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") - - *pp += 3; /*reserved bytes */ - - /* Skip dimension permutation */ - *pp += 4; - - /* Skip reserved bytes */ - *pp += 4; - - /* Decode array dimension sizes */ - for(j = 0; j < 4; j++) - UINT32DECODE(*pp, dim[j]); - } /* end if */ - - /* Allocate space for the field's datatype */ - if(NULL == (temp_type = H5T__alloc())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Decode the field's datatype information */ - if((can_upgrade = H5O_dtype_decode_helper(f, 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); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") - } /* end if */ - - /* Upgrade the version if we can and it is necessary */ - if(can_upgrade && temp_type->shared->version > version) { - upgrade_to = temp_type->shared->version; - - /* 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) { - /* Check if this member is an array field */ - 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); - 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); - - /* Make the array type the type that is set for the field */ - temp_type = array_dt; - - /* Reset array version if NOCHANGE is specified (i.e. h5debug) */ - if(*ioflags & H5O_DECODEIO_NOCHANGE) - temp_type->shared->version = H5O_DTYPE_VERSION_1; - else { - /* Otherwise upgrade the compound version */ - if(upgrade_to < temp_type->shared->version) - upgrade_to = temp_type->shared->version; - - /* Set the return value to indicate that we should freely - * upgrade parent types */ - ret_value = TRUE; - } /* end else */ + /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ + if (version >= H5O_DTYPE_VERSION_3) + /* Advance past name, including null terminator */ + *pp += HDstrlen((const char *)*pp) + 1; + else + /* Advance multiple of 8 w/ null terminator */ + *pp += ((HDstrlen((const char *)*pp) + 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) + + /* 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 */ + ndims = *(*pp)++; + + /* Check that ndims is valid */ + if (ndims > 4) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") + + *pp += 3; /*reserved bytes */ + + /* Skip dimension permutation */ + *pp += 4; + + /* Skip reserved bytes */ + *pp += 4; + + /* Decode array dimension sizes */ + for (j = 0; j < 4; j++) + UINT32DECODE(*pp, dim[j]); + } /* end if */ + + /* Allocate space for the field's datatype */ + if (NULL == (temp_type = H5T__alloc())) + 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); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") + } /* end if */ + + /* Upgrade the version if we can and it is necessary */ + if (can_upgrade && temp_type->shared->version > version) { + upgrade_to = temp_type->shared->version; + + /* 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) { + /* Check if this member is an array field */ + 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); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, + "unable to create array datatype") } /* 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 - * 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_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)) - 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 */ - /* Check if the compound type is packed */ - H5T__update_packed(dt); - - /* Upgrade the compound if requested */ - if(version < upgrade_to) { - version = upgrade_to; - if(H5T__upgrade_version(dt, upgrade_to) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version") - /* We won't mark the message dirty since there were no - * errors in the file, simply type versions that we will no - * longer encode. */ + /* Close the base type for the array */ + (void)H5T_close_real(temp_type); + + /* Make the array type the type that is set for the field */ + temp_type = array_dt; + + /* Reset array version if NOCHANGE is specified (i.e. h5debug) */ + if (*ioflags & H5O_DECODEIO_NOCHANGE) + temp_type->shared->version = H5O_DTYPE_VERSION_1; + else { + /* Otherwise upgrade the compound version */ + if (upgrade_to < temp_type->shared->version) + upgrade_to = temp_type->shared->version; + + /* 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 + * 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_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)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, + "member overlaps with previous member") } /* 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; + /* 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 */ + + /* Check if the compound type is packed */ + H5T__update_packed(dt); + + /* Upgrade the compound if requested */ + if (version < upgrade_to) { + version = upgrade_to; + if (H5T__upgrade_version(dt, upgrade_to) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade compound encoding version") + /* 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... */ - dt->shared->u.atomic.order = H5T_ORDER_NONE; - dt->shared->u.atomic.prec = 8 * dt->shared->size; - dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; /* Set reference type */ dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); + if (dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE || + dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "invalid reference type"); + + /* Set generic flag */ + if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2 || + dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2 || + dt->shared->u.atomic.u.r.rtype == H5R_ATTR) { + dt->shared->u.atomic.u.r.opaque = TRUE; + dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f); + if (dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "reference version does not match"); + } + else + dt->shared->u.atomic.u.r.opaque = FALSE; - /* Set extra information for object references, so the hobj_ref_t gets swizzled correctly */ - if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) { - /* Mark location this type as undefined for now. The caller function should - * decide the location. */ - dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; + /* This type needs conversion */ + dt->shared->force_conv = TRUE; - /* This type needs conversion */ - dt->shared->force_conv = TRUE; - } /* end if */ + /* Mark location of this type as undefined for now. The caller + * function should decide the location. */ + if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; case H5T_ENUM: @@ -455,26 +467,27 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p * Enumeration datatypes... */ dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; - if(NULL == (dt->shared->parent = H5T__alloc())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0) + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype") /* 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) + 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))) + 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") /* Names */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { - dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { + dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char *)*pp); /* 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 @@ -484,79 +497,76 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p /* Values */ H5MM_memcpy(dt->shared->u.enumer.value, *pp, - dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.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) { + 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())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0) + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 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 * vlen itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, - ioflags, "vlen", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "vlen", FAIL) - dt->shared->force_conv=TRUE; + dt->shared->force_conv = TRUE; /* Mark location this type as undefined for now. The caller function should * decide the location. */ - if(H5T_set_loc(dt, f, H5T_LOC_BADLOC) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0) 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 */ dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ - if(dt->shared->u.array.ndims > H5S_MAX_RANK) + if (dt->shared->u.array.ndims > H5S_MAX_RANK) 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) *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++) { + 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 */ /* Skip array dimension permutations, if version has them */ - if(version < H5O_DTYPE_VERSION_3) + if (version < H5O_DTYPE_VERSION_3) *pp += dt->shared->u.array.ndims * 4; /* Decode base type of array */ - if(NULL == (dt->shared->parent = H5T__alloc())) + if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(H5O_dtype_decode_helper(f, ioflags, pp, dt->shared->parent) < 0) + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 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 * array itself. */ - H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, - ioflags, "array", FAIL) + H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "array", FAIL) /* There should be no array datatypes with version < 2. */ - H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags, - "array", FAIL) + 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 * or if any components of the base datatype are VL types. */ - if(dt->shared->parent->shared->force_conv == TRUE) + if (dt->shared->parent->shared->force_conv == TRUE) dt->shared->force_conv = TRUE; break; @@ -567,20 +577,20 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p } /* end switch */ done: - if(ret_value < 0) { - if(dt != NULL) { - if(dt->shared != NULL) + 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 */ - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_decode_helper() */ +} /* end H5O__dtype_decode_helper() */ - /*------------------------------------------------------------------------- - * Function: H5O_dtype_encode_helper + * Function: H5O__dtype_encode_helper * * Purpose: Encodes a datatype. * @@ -596,15 +606,15 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) +H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt) { - unsigned flags = 0; - uint8_t *hdr = (uint8_t *)*pp; - unsigned i; - size_t n, z; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned flags = 0; + uint8_t *hdr = (uint8_t *)*pp; + unsigned i; + size_t n, z; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(pp && *pp); @@ -614,14 +624,14 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) *pp += 4; UINT32ENCODE(*pp, dt->shared->size); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -632,12 +642,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_MIXED: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -647,12 +658,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ERROR: case H5T_PAD_BACKGROUND: @@ -662,12 +674,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) break; default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: - break; /*nothing */ + break; /*nothing */ case H5T_SGN_2: flags |= 0x08; @@ -676,7 +689,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_SGN_ERROR: case H5T_NSGN: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "sign scheme is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.offset); @@ -689,13 +703,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing*/ + break; /*nothing*/ case H5T_ORDER_BE: flags |= 0x01; break; - case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/ + case H5T_ORDER_VAX: /*turn on 1st and 6th (reserved before adding VAX) bits*/ flags |= 0x41; HDassert(dt->shared->version >= H5O_DTYPE_VERSION_3); break; @@ -704,12 +718,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -719,12 +734,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; @@ -734,12 +750,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x08; @@ -749,12 +766,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_NONE: - break; /*nothing */ + break; /*nothing */ case H5T_NORM_MSBSET: flags |= 0x10; @@ -766,7 +784,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_NORM_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "normalization scheme is not supported in file format yet") } /* end switch */ flags = (unsigned)(flags | ((dt->shared->u.atomic.u.f.sign << 8) & 0xff00)); @@ -783,10 +802,10 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) UINT32ENCODE(*pp, dt->shared->u.atomic.u.f.ebias); break; - case H5T_TIME: /* Time datatypes... */ + case H5T_TIME: /* Time datatypes... */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -797,7 +816,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; @@ -822,7 +842,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) */ switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: - break; /*nothing */ + break; /*nothing */ case H5T_ORDER_BE: flags |= 0x01; @@ -833,12 +853,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x02; @@ -848,12 +869,13 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - break; /*nothing */ + break; /*nothing */ case H5T_PAD_ONE: flags |= 0x04; @@ -863,7 +885,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_PAD_BACKGROUND: case H5T_NPAD: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet") } /* end switch */ UINT16ENCODE(*pp, dt->shared->u.atomic.offset); @@ -877,93 +900,94 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) * null terminated). */ { - size_t aligned; + size_t aligned; - z = HDstrlen(dt->shared->u.opaque.tag); + z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8); - flags = (unsigned)(flags | aligned); - H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); - for(n = MIN(z, aligned); n < aligned; n++) + flags = (unsigned)(flags | aligned); + H5MM_memcpy(*pp, dt->shared->u.opaque.tag, MIN(z, aligned)); + for (n = MIN(z, aligned); n < aligned; n++) (*pp)[n] = 0; *pp += aligned; } break; - case H5T_COMPOUND: - { - unsigned offset_nbytes; /* Size needed to encode member offsets */ + case H5T_COMPOUND: { + unsigned offset_nbytes; /* Size needed to encode member offsets */ - /* Compute the # of bytes required to store a member offset */ - offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* - * Compound datatypes... + /* + * Compound datatypes... + */ + flags = dt->shared->u.compnd.nmembs & 0xffff; + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + /* Sanity check */ + /* (compound datatypes w/array members must be encoded w/version >= 2) */ + HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY || + dt->shared->version >= H5O_DTYPE_VERSION_2); + + /* Check that the version is at least as great as the member */ + HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version); + + /* Name */ + HDstrcpy((char *)(*pp), dt->shared->u.compnd.memb[i].name); + + /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ + n = HDstrlen(dt->shared->u.compnd.memb[i].name); + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + *pp += n + 1; + else { + /* Pad name to multiple of 8 bytes */ + for (z = n + 1; z % 8; z++) + (*pp)[z] = '\0'; + *pp += z; + } /* end if */ + + /* Member offset */ + /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) + else + UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) + + /* If we don't have any array fields, write out the old style + * member information, for better backward compatibility + * Write out all zeros for the array information, though... */ - flags = dt->shared->u.compnd.nmembs & 0xffff; - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - /* Sanity check */ - /* (compound datatypes w/array members must be encoded w/version >= 2) */ - HDassert(dt->shared->u.compnd.memb[i].type->shared->type != H5T_ARRAY || dt->shared->version >= H5O_DTYPE_VERSION_2); - - /* Check that the version is at least as great as the member */ - HDassert(dt->shared->version >= dt->shared->u.compnd.memb[i].type->shared->version); - - /* Name */ - HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name); - - /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ - n = HDstrlen(dt->shared->u.compnd.memb[i].name); - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - *pp += n + 1; - else { - /* Pad name to multiple of 8 bytes */ - for(z = n + 1; z % 8; z++) - (*pp)[z] = '\0'; - *pp += z; - } /* end if */ - - /* Member offset */ - /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) - else - UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) + if (dt->shared->version == H5O_DTYPE_VERSION_1) { + unsigned j; - /* If we don't have any array fields, write out the old style - * member information, for better backward compatibility - * Write out all zeros for the array information, though... - */ - if(dt->shared->version == H5O_DTYPE_VERSION_1) { - unsigned j; + /* Dimensionality */ + *(*pp)++ = 0; - /* Dimensionality */ - *(*pp)++ = 0; + /* Reserved */ + *(*pp)++ = 0; + *(*pp)++ = 0; + *(*pp)++ = 0; - /* Reserved */ - *(*pp)++ = 0; - *(*pp)++ = 0; - *(*pp)++ = 0; + /* Dimension permutation */ + UINT32ENCODE(*pp, 0); - /* Dimension permutation */ - UINT32ENCODE(*pp, 0); + /* Reserved */ + UINT32ENCODE(*pp, 0); - /* Reserved */ + /* Dimensions */ + for (j = 0; j < 4; j++) UINT32ENCODE(*pp, 0); + } /* end if */ - /* Dimensions */ - for(j = 0; j < 4; j++) - UINT32ENCODE(*pp, 0); - } /* end if */ - - /* Subtype */ - if(H5O_dtype_encode_helper(f, pp, dt->shared->u.compnd.memb[i].type) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type") - } /* end for */ - } - break; + /* Subtype */ + if (H5O__dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type") + } /* end for */ + } break; case H5T_REFERENCE: flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f); + if (dt->shared->u.atomic.u.r.opaque) + flags = (unsigned)(flags | (((unsigned)dt->shared->u.atomic.u.r.version & 0x0f) << 4)); break; case H5T_ENUM: @@ -976,47 +1000,48 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags = dt->shared->u.enumer.nmembs & 0xffff; /* Parent type */ - if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0) + if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype") /* Names, each a multiple of eight bytes */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { /* Name */ - HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]); + HDstrcpy((char *)(*pp), dt->shared->u.enumer.name[i]); /* Version 3 of the datatype message removed the padding to multiple of 8 bytes */ n = HDstrlen(dt->shared->u.enumer.name[i]); - if(dt->shared->version >= H5O_DTYPE_VERSION_3) + if (dt->shared->version >= H5O_DTYPE_VERSION_3) *pp += n + 1; else { /* Pad to multiple of 8 bytes */ - for(z = n + 1; z % 8; z++) + for (z = n + 1; z % 8; z++) (*pp)[z] = '\0'; *pp += z; } /* end for */ - } /* end for */ + } /* end for */ /* Values */ - H5MM_memcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + H5MM_memcpy(*pp, dt->shared->u.enumer.value, + dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; - case H5T_VLEN: /* Variable length datatypes... */ + case H5T_VLEN: /* Variable length datatypes... */ /* Check that the version is at least as great as the parent */ HDassert(dt->shared->version >= dt->shared->parent->shared->version); flags |= (dt->shared->u.vlen.type & 0x0f); - if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); - flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); + if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); } /* end if */ /* Encode base type of VL information */ - if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0) + if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type") break; - case H5T_ARRAY: /* Array datatypes */ + case H5T_ARRAY: /* Array datatypes */ /* Double-check the number of dimensions */ HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK); @@ -1031,7 +1056,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) *(*pp)++ = (uint8_t)dt->shared->u.array.ndims; /* Drop this information for Version 3 of the format */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) { + if (dt->shared->version < H5O_DTYPE_VERSION_3) { /* Reserved */ *(*pp)++ = '\0'; *(*pp)++ = '\0'; @@ -1039,18 +1064,18 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) } /* end if */ /* Encode array dimensions */ - for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) + for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) UINT32ENCODE(*pp, dt->shared->u.array.dim[i]); /* Drop this information for Version 3 of the format */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) { + if (dt->shared->version < H5O_DTYPE_VERSION_3) { /* Encode 'fake' array dimension permutations */ - for(i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) + for (i = 0; i < (unsigned)dt->shared->u.array.ndims; i++) UINT32ENCODE(*pp, i); } /* end if */ /* Encode base type of array's information */ - if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0) + if (H5O__dtype_encode_helper(pp, dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type") break; @@ -1069,45 +1094,47 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_encode_helper() */ +} /* end H5O__dtype_encode_helper() */ - /*-------------------------------------------------------------------------- NAME - H5O_dtype_decode + H5O__dtype_decode PURPOSE Decode a message and return a pointer to a memory struct - with the decoded information + with the decoded information USAGE - void *H5O_dtype_decode(f, mesg_flags, p) - H5F_t *f; IN: pointer to the HDF5 file struct + void *H5O__dtype_decode(f, mesg_flags, p) + H5F_t *f; IN: pointer to the HDF5 file struct + H5O_t *open_oh; IN: pointer to the object header unsigned mesg_flags; IN: Message flags to influence decoding - const uint8 *p; IN: the raw information buffer + unsigned *ioflags; IN/OUT: flags for decoding + size_t p_size; IN: size of buffer *p + const uint8_t *p; IN: the raw information buffer RETURNS 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 + 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. --------------------------------------------------------------------------*/ static void * -H5O_dtype_decode(H5F_t *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) +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) { - H5T_t *dt = NULL; - void *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(p); /* Allocate datatype message */ - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Perform actual decode of message */ - if(H5O_dtype_decode_helper(f, ioflags, &p, dt) < 0) + if (H5O__dtype_decode_helper(ioflags, &p, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type") /* Set return value */ @@ -1115,33 +1142,32 @@ H5O_dtype_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_decode() */ +} /* end H5O__dtype_decode() */ - /*-------------------------------------------------------------------------- NAME - H5O_dtype_encode + H5O__dtype_encode PURPOSE Encode a simple datatype message USAGE - herr_t H5O_dtype_encode(f, raw_size, p, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - size_t raw_size; IN: size of the raw information buffer - const uint8 *p; IN: the raw information buffer - const void *mesg; IN: Pointer to the simple datatype struct + herr_t H5O__dtype_encode(f, raw_size, p, mesg) + H5F_t *f; IN: pointer to the HDF5 file struct + size_t raw_size; IN: size of the raw information buffer + const uint8 *p; IN: the raw information buffer + const void *mesg; IN: Pointer to the simple datatype struct RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function encodes the native memory form of the simple datatype + This function encodes the native memory form of the simple datatype message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t -H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg) +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 */ + const H5T_t *dt = (const H5T_t *)mesg; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -1149,52 +1175,51 @@ H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg) HDassert(dt); /* encode */ - if(H5O_dtype_encode_helper(f, &p, dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type") + if (H5O__dtype_encode_helper(&p, dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_encode() */ +} /* end H5O__dtype_encode() */ - /*-------------------------------------------------------------------------- NAME - H5O_dtype_copy + H5O__dtype_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE - void *H5O_dtype_copy(mesg, dest) - const void *mesg; IN: Pointer to the source simple datatype - struct - const void *dest; IN: Pointer to the destination simple - datatype struct + void *H5O__dtype_copy(mesg, dest) + const void *mesg; IN: Pointer to the source simple datatype + struct + const void *dest; IN: Pointer to the destination simple + datatype struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION - This function copies a native (memory) simple datatype message, + This function copies a native (memory) simple datatype message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * -H5O_dtype_copy(const void *_src, void *_dst) +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 */ + const H5T_t *src = (const H5T_t *)_src; + H5T_t * dst; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(src); /* Copy */ - if(NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) + if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type") /* Was result already allocated? */ - if(_dst) { - *((H5T_t *) _dst) = *dst; - dst = H5FL_FREE(H5T_t, dst); - dst = (H5T_t *) _dst; + if (_dst) { + *((H5T_t *)_dst) = *dst; + dst = H5FL_FREE(H5T_t, dst); + dst = (H5T_t *)_dst; } /* end if */ /* Set return value */ @@ -1202,43 +1227,42 @@ H5O_dtype_copy(const void *_src, void *_dst) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_copy() */ +} /* end H5O__dtype_copy() */ - /*-------------------------------------------------------------------------- NAME - H5O_dtype_size + H5O__dtype_size PURPOSE Return the raw message size in bytes USAGE - void *H5O_dtype_size(f, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source simple datatype struct + void *H5O__dtype_size(f, mesg) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source simple datatype struct RETURNS Size of message on success, 0 on failure DESCRIPTION - This function returns the size of the raw simple datatype message on + This function returns the size of the raw simple datatype message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_dtype_size(const H5F_t *f, const void *_mesg) +H5O__dtype_size(const H5F_t *f, const void *_mesg) { - const H5T_t *dt = (const H5T_t *)_mesg; - unsigned u; /* Local index variable */ - size_t ret_value = 0; /* Return value */ + const H5T_t *dt = (const H5T_t *)_mesg; + unsigned u; /* Local index variable */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f); HDassert(dt); /* Set the common size information */ - ret_value = 4 + /* Type, class & flags */ - 4; /* Size of datatype */ + ret_value = 4 + /* Type, class & flags */ + 4; /* Size of datatype */ /* Add in the property field length for each datatype class */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: ret_value += 4; break; @@ -1259,54 +1283,52 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) ret_value += (HDstrlen(dt->shared->u.opaque.tag) + 7) & (H5T_OPAQUE_TAG_MAX - 8); break; - case H5T_COMPOUND: - { - unsigned offset_nbytes; /* Size needed to encode member offsets */ + case H5T_COMPOUND: { + unsigned offset_nbytes; /* Size needed to encode member offsets */ - /* Compute the # of bytes required to store a member offset */ - offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); + /* Compute the # of bytes required to store a member offset */ + offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); - /* Compute the total size needed to encode compound datatype */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { - size_t name_len; /* Length of field's name */ + /* Compute the total size needed to encode compound datatype */ + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) { + size_t name_len; /* Length of field's name */ - /* Get length of field's name */ - name_len = HDstrlen(dt->shared->u.compnd.memb[u].name); + /* Get length of field's name */ + name_len = HDstrlen(dt->shared->u.compnd.memb[u].name); - /* Versions of the format >= 3 don't pad out the name */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - ret_value += name_len + 1; - else - ret_value += ((name_len + 8) / 8) * 8; - - /* Check for encoding array datatype or using the latest file format */ - /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) - ret_value += offset_nbytes; /*member offset*/ - else if(dt->shared->version == H5O_DTYPE_VERSION_2) - ret_value += 4; /*member offset*/ - else - ret_value += 4 + /*member offset*/ - 1 + /*dimensionality*/ - 3 + /*reserved*/ - 4 + /*permutation*/ - 4 + /*reserved*/ - 16; /*dimensions*/ - ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[u].type); - } /* end for */ - } - break; + /* Versions of the format >= 3 don't pad out the name */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + ret_value += name_len + 1; + else + ret_value += ((name_len + 8) / 8) * 8; + + /* Check for encoding array datatype or using the latest file format */ + /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ + if (dt->shared->version >= H5O_DTYPE_VERSION_3) + ret_value += offset_nbytes; /*member offset*/ + else if (dt->shared->version == H5O_DTYPE_VERSION_2) + ret_value += 4; /*member offset*/ + else + ret_value += 4 + /*member offset*/ + 1 + /*dimensionality*/ + 3 + /*reserved*/ + 4 + /*permutation*/ + 4 + /*reserved*/ + 16; /*dimensions*/ + ret_value += H5O__dtype_size(f, dt->shared->u.compnd.memb[u].type); + } /* end for */ + } break; case H5T_ENUM: - ret_value += H5O_dtype_size(f, dt->shared->parent); - for(u = 0; u < dt->shared->u.enumer.nmembs; u++) { - size_t name_len; /* Length of field's name */ + ret_value += H5O__dtype_size(f, dt->shared->parent); + for (u = 0; u < dt->shared->u.enumer.nmembs; u++) { + size_t name_len; /* Length of field's name */ /* Get length of field's name */ name_len = HDstrlen(dt->shared->u.enumer.name[u]); /* Versions of the format >= 3 don't pad out the name */ - if(dt->shared->version >= H5O_DTYPE_VERSION_3) + if (dt->shared->version >= H5O_DTYPE_VERSION_3) ret_value += name_len + 1; else ret_value += ((name_len + 8) / 8) * 8; @@ -1315,17 +1337,17 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) break; case H5T_VLEN: - ret_value += H5O_dtype_size(f, dt->shared->parent); + ret_value += H5O__dtype_size(f, dt->shared->parent); break; case H5T_ARRAY: ret_value += 1; /* ndims */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) - ret_value += 3; /* reserved bytes*/ + if (dt->shared->version < H5O_DTYPE_VERSION_3) + ret_value += 3; /* reserved bytes*/ ret_value += 4 * dt->shared->u.array.ndims; /* dimensions */ - if(dt->shared->version < H5O_DTYPE_VERSION_3) + if (dt->shared->version < H5O_DTYPE_VERSION_3) ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */ - ret_value += H5O_dtype_size(f, dt->shared->parent); + ret_value += H5O__dtype_size(f, dt->shared->parent); break; case H5T_NO_CLASS: @@ -1338,9 +1360,8 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) } /* end switch */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_dtype_size() */ +} /* H5O__dtype_size() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_reset * @@ -1357,17 +1378,16 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) static herr_t H5O__dtype_reset(void *_mesg) { - H5T_t *dt = (H5T_t *) _mesg; + H5T_t *dt = (H5T_t *)_mesg; FUNC_ENTER_STATIC_NOERR - if(dt) + if (dt) H5T__free(dt); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__dtype_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_free * @@ -1383,7 +1403,7 @@ H5O__dtype_reset(void *_mesg) static herr_t H5O__dtype_free(void *mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1391,16 +1411,15 @@ H5O__dtype_free(void *mesg) HDassert(mesg); /* Release the datatype */ - if(H5T_close_real((H5T_t *)mesg) < 0) + if (H5T_close_real((H5T_t *)mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_free() */ - /*------------------------------------------------------------------------- - * Function: H5O_dtype_set_share + * Function: H5O__dtype_set_share * * Purpose: Copies sharing information from SH into the message. * @@ -1412,12 +1431,12 @@ H5O__dtype_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) +H5O__dtype_set_share(void *_mesg /*in,out*/, const H5O_shared_t *sh) { - H5T_t *dt = (H5T_t *)_mesg; + H5T_t *dt = (H5T_t *)_mesg; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(dt); HDassert(sh); @@ -1429,18 +1448,18 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) /* Make sure we're not sharing a committed type in the heap */ HDassert(sh->type == H5O_SHARE_TYPE_COMMITTED || - (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED)); + (dt->shared->state != H5T_STATE_OPEN && dt->shared->state != H5T_STATE_NAMED)); /* Copy the shared information */ - if(H5O_set_shared(&(dt->sh_loc), sh) < 0) + if (H5O_set_shared(&(dt->sh_loc), sh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy shared message info") /* If this is now a committed datatype, set its state properly. */ - if(sh->type == H5O_SHARE_TYPE_COMMITTED) { + if (sh->type == H5O_SHARE_TYPE_COMMITTED) { dt->shared->state = H5T_STATE_NAMED; /* Set up the object location for the datatype also */ - if(H5O_loc_reset(&(dt->oloc)) < 0) + if (H5O_loc_reset(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location") dt->oloc.file = sh->file; dt->oloc.addr = sh->u.loc.oh_addr; @@ -1448,11 +1467,10 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_set_share() */ +} /* end H5O__dtype_set_share() */ - /*------------------------------------------------------------------------- - * Function: H5O_dtype_can_share + * Function: H5O__dtype_can_share * * Purpose: Determines if this datatype is allowed to be shared or * not. Immutable datatypes or datatypes that are already @@ -1468,35 +1486,34 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh) *------------------------------------------------------------------------- */ static htri_t -H5O_dtype_can_share(const void *_mesg) +H5O__dtype_can_share(const void *_mesg) { - const H5T_t *mesg = (const H5T_t *)_mesg; - htri_t tri_ret; - htri_t ret_value = TRUE; + const H5T_t *mesg = (const H5T_t *)_mesg; + htri_t tri_ret; + htri_t ret_value = TRUE; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(mesg); /* Don't share immutable datatypes */ - if((tri_ret = H5T_is_immutable(mesg)) > 0) + if ((tri_ret = H5T_is_immutable(mesg)) > 0) HGOTO_DONE(FALSE) - else if(tri_ret < 0) + else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable") /* Don't share committed datatypes */ - if((tri_ret = H5T_committed(mesg)) > 0) + if ((tri_ret = H5T_is_named(mesg)) > 0) HGOTO_DONE(FALSE) - else if(tri_ret < 0) + else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is shared") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_can_share() */ +} /* end H5O__dtype_can_share() */ - /*------------------------------------------------------------------------- - * Function: H5O_dtype_pre_copy_file + * Function: H5O__dtype_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files @@ -1511,15 +1528,14 @@ 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 H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, - void *_udata) +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 */ - H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(file_src); @@ -1529,7 +1545,7 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version as indicated by the destination file's high bound */ - if(dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "datatype message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset @@ -1539,21 +1555,20 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, * message is an early version, but since the layout information isn't * available here, we just make a copy in all situations) */ - if(udata) { + if (udata) { /* Create a memory copy of the variable-length datatype */ - if(NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) + if (NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") /* Set the location of the source datatype to describe the disk form of the data */ - if(H5T_set_loc(udata->src_dtype, file_src, H5T_LOC_DISK) < 0) + if (H5T_set_loc(udata->src_dtype, H5F_VOL_OBJ(file_src), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_pre_copy_file() */ +} /* end H5O__dtype_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_copy_file * @@ -1568,33 +1583,32 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, *------------------------------------------------------------------------- */ static void * -H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, - void *native_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, void *native_src, + H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, + 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 */ + H5T_t *dst_mesg; /* Destination datatype */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Perform a normal copy of the object header message */ - if(NULL == (dst_mesg = (H5T_t *)H5O_dtype_copy(native_src, NULL))) + if (NULL == (dst_mesg = (H5T_t *)H5O__dtype_copy(native_src, NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") /* The datatype will be in the new file; set its location. */ - if(H5T_set_loc(dst_mesg, file_dst, H5T_LOC_DISK) < 0) + if (H5T_set_loc(dst_mesg, H5F_VOL_OBJ(file_dst), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set location") ret_value = dst_mesg; done: - if(NULL == ret_value) + if (NULL == ret_value) H5O_msg_free(mesg_type->id, dst_mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_shared_post_copy_upd * @@ -1609,30 +1623,29 @@ H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg *------------------------------------------------------------------------- */ static herr_t -H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, - const void H5_ATTR_UNUSED *mesg_src, H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst, - H5O_copy_t H5_ATTR_UNUSED *cpy_info) +H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, const void H5_ATTR_UNUSED *mesg_src, + H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst, + H5O_copy_t H5_ATTR_UNUSED *cpy_info) { - H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { - HDassert(H5T_committed(dt_dst)); - if(H5O_loc_reset(&(dt_dst->oloc)) < 0) + if (dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + HDassert(H5T_is_named(dt_dst)); + if (H5O_loc_reset(&(dt_dst->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to reset location") dt_dst->oloc.file = dt_dst->sh_loc.file; dt_dst->oloc.addr = dt_dst->sh_loc.u.loc.oh_addr; } /* end if */ else - HDassert(!H5T_committed(dt_dst)); + HDassert(!H5T_is_named(dt_dst)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_shared_post_copy_upd */ - /*-------------------------------------------------------------------------- NAME H5O__dtype_debug @@ -1640,27 +1653,26 @@ H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, Prints debugging information for a message USAGE void *H5O__dtype_debug(f, mesg, stream, indent, fwidth) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source simple datatype - struct - FILE *stream; IN: Pointer to the stream for output data - int indent; IN: Amount to indent information by - int fwidth; IN: Field width (?) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source simple datatype + struct + FILE *stream; IN: Pointer to the stream for output data + int indent; IN: Amount to indent information by + int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function prints debugging output to the stream passed as a + This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, - int fwidth) +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; - char buf[256]; - unsigned i; - size_t k; + const H5T_t *dt = (const H5T_t *)mesg; + const char * s; + char buf[256]; + unsigned i; + size_t k; FUNC_ENTER_STATIC_NOERR @@ -1723,61 +1735,48 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type class:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type class:", s); - HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, - "Size:", - (unsigned long)(dt->shared->size), 1 == dt->shared->size ? "" : "s"); + HDfprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, "Size:", (unsigned long)(dt->shared->size), + 1 == dt->shared->size ? "" : "s"); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", dt->shared->version); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", dt->shared->version); if (H5T_COMPOUND == dt->shared->type) { 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++) { + "Number of members:", dt->shared->u.compnd.nmembs); + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { HDsprintf(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)); - H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, - indent + 3, MAX(0, fwidth - 3)); + 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)); + H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, indent + 3, MAX(0, fwidth - 3)); } /* end for */ - } /* end if */ - else if(H5T_ENUM == dt->shared->type) { + } /* end if */ + else if (H5T_ENUM == dt->shared->type) { HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O__dtype_debug(f, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); + H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); 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++) { + "Number of members:", dt->shared->u.enumer.nmembs); + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { HDsprintf(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++) - HDfprintf(stream, "%02x", dt->shared->u.enumer.value[i*dt->shared->parent->shared->size + k]); + 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++) + HDfprintf(stream, "%02x", + (unsigned)*((uint8_t *)dt->shared->u.enumer.value + + (i * dt->shared->parent->shared->size) + k)); HDfprintf(stream, "\n"); } /* end for */ + } /* end else if */ + else if (H5T_OPAQUE == dt->shared->type) { + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, "Tag:", dt->shared->u.opaque.tag); } /* end else if */ - else if(H5T_OPAQUE == dt->shared->type) { - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, - "Tag:", dt->shared->u.opaque.tag); - } /* end else if */ - else if(H5T_REFERENCE == dt->shared->type) { - HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, - "Fix dumping reference types!"); + else if (H5T_REFERENCE == dt->shared->type) { + HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Fix dumping reference types!"); } /* end else if */ - else if(H5T_STRING == dt->shared->type) { - switch(dt->shared->u.atomic.u.s.cset) { + else if (H5T_STRING == dt->shared->type) { + switch (dt->shared->u.atomic.u.s.cset) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -1810,11 +1809,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s); - switch(dt->shared->u.atomic.u.s.pad) { + switch (dt->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: s = "NULL Terminated"; break; @@ -1850,12 +1847,10 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "String Padding:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s); } /* end else if */ - else if(H5T_VLEN == dt->shared->type) { - switch(dt->shared->u.vlen.type) { + else if (H5T_VLEN == dt->shared->type) { + switch (dt->shared->u.vlen.type) { case H5T_VLEN_SEQUENCE: s = "sequence"; break; @@ -1871,10 +1866,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Vlen type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Vlen type:", s); - switch(dt->shared->u.vlen.loc) { + switch (dt->shared->u.vlen.loc) { case H5T_LOC_MEMORY: s = "memory"; break; @@ -1890,12 +1884,11 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Location:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Location:", s); /* Extra information for VL-strings */ - if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - switch(dt->shared->u.vlen.cset) { + if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { + switch (dt->shared->u.vlen.cset) { case H5T_CSET_ASCII: s = "ASCII"; break; @@ -1928,11 +1921,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Character Set:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Character Set:", s); - switch(dt->shared->u.vlen.pad) { + switch (dt->shared->u.vlen.pad) { case H5T_STR_NULLTERM: s = "NULL Terminated"; break; @@ -1968,17 +1959,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "String Padding:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "String Padding:", s); } /* end if */ - } /* end else if */ - else if(H5T_ARRAY == dt->shared->type) { - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Rank:", - dt->shared->u.array.ndims); + } /* end else if */ + else if (H5T_ARRAY == dt->shared->type) { + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Rank:", dt->shared->u.array.ndims); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); - for(i = 0; i < dt->shared->u.array.ndims; i++) + for (i = 0; i < dt->shared->u.array.ndims; i++) HDfprintf(stream, "%s%u", (i ? ", " : ""), (unsigned)dt->shared->u.array.dim[i]); HDfprintf(stream, "}\n"); HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); @@ -2012,19 +1999,15 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Byte order:", - s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Byte order:", s); HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, - "Precision:", - (unsigned long)(dt->shared->u.atomic.prec), - 1==dt->shared->u.atomic.prec?"":"s"); + "Precision:", (unsigned long)(dt->shared->u.atomic.prec), + 1 == dt->shared->u.atomic.prec ? "" : "s"); HDfprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, - "Offset:", - (unsigned long)(dt->shared->u.atomic.offset), - 1==dt->shared->u.atomic.offset?"":"s"); + "Offset:", (unsigned long)(dt->shared->u.atomic.offset), + 1 == dt->shared->u.atomic.offset ? "" : "s"); switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: @@ -2045,8 +2028,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = "pad?"; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Low pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Low pad type:", s); switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: @@ -2067,8 +2049,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = "pad?"; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "High pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "High pad type:", s); if (H5T_FLOAT == dt->shared->type) { switch (dt->shared->u.atomic.u.f.pad) { @@ -2094,8 +2075,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Internal pad type:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Internal pad type:", s); switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: @@ -2112,35 +2092,28 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, case H5T_NORM_ERROR: default: - HDsprintf(buf, "H5T_NORM_%d", (int) (dt->shared->u.atomic.u.f.norm)); + HDsprintf(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); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Sign bit location:", - (unsigned long) (dt->shared->u.atomic.u.f.sign)); + "Sign bit location:", (unsigned long)(dt->shared->u.atomic.u.f.sign)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Exponent location:", - (unsigned long) (dt->shared->u.atomic.u.f.epos)); + "Exponent location:", (unsigned long)(dt->shared->u.atomic.u.f.epos)); HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, - "Exponent bias:", - (unsigned long) (dt->shared->u.atomic.u.f.ebias)); + "Exponent bias:", (unsigned long)(dt->shared->u.atomic.u.f.ebias)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Exponent size:", - (unsigned long) (dt->shared->u.atomic.u.f.esize)); + "Exponent size:", (unsigned long)(dt->shared->u.atomic.u.f.esize)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Mantissa location:", - (unsigned long) (dt->shared->u.atomic.u.f.mpos)); + "Mantissa location:", (unsigned long)(dt->shared->u.atomic.u.f.mpos)); HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Mantissa size:", - (unsigned long) (dt->shared->u.atomic.u.f.msize)); + "Mantissa size:", (unsigned long)(dt->shared->u.atomic.u.f.msize)); } /* end if */ else if (H5T_INTEGER == dt->shared->type) { @@ -2156,15 +2129,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, case H5T_SGN_ERROR: case H5T_NSGN: default: - HDsprintf(buf, "H5T_SGN_%d", (int) (dt->shared->u.atomic.u.i.sign)); + HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); s = buf; break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Sign scheme:", s); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Sign scheme:", s); } /* end else if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__dtype_debug() */ - diff --git a/src/H5Oefl.c b/src/H5Oefl.c index b2eb269b657..d950249cbdb 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,58 +16,54 @@ * Tuesday, November 25, 1997 */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory management */ +#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, 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 size_t H5O_efl_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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, 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); +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); /* This message derives from H5O message class */ 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? */ - H5O_efl_decode, /*decode message */ - H5O_efl_encode, /*encode message */ - H5O_efl_copy, /*copy native value */ - H5O_efl_size, /*size of message on disk */ - H5O__efl_reset, /*reset method */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__efl_copy_file, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__efl_debug /*debug the message */ + H5O_EFL_ID, /*message id number */ + "external file list", /*message name for debugging */ + sizeof(H5O_efl_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__efl_decode, /*decode message */ + H5O__efl_encode, /*encode message */ + H5O__efl_copy, /*copy native value */ + H5O__efl_size, /*size of message on disk */ + H5O__efl_reset, /*reset method */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__efl_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__efl_debug /*debug the message */ }}; -#define H5O_EFL_VERSION 1 +#define H5O_EFL_VERSION 1 - /*------------------------------------------------------------------------- - * Function: H5O_efl_decode + * Function: H5O__efl_decode * * Purpose: Decode an external file list message and return a pointer to * the message (and some other data). @@ -87,29 +83,28 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ *------------------------------------------------------------------------- */ 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) +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) { - H5O_efl_t *mesg = NULL; + 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 */ + const char *s = NULL; + H5HL_t * heap; + size_t u; /* Local index variable */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(f); HDassert(p); - if(NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ version = *p++; - if(version != H5O_EFL_VERSION) + if (version != H5O_EFL_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message") /* Reserved */ @@ -117,7 +112,7 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Number of slots */ UINT16DECODE(p, mesg->nalloc); - HDassert(mesg->nalloc>0); + HDassert(mesg->nalloc > 0); UINT16DECODE(p, mesg->nused); HDassert(mesg->nused <= mesg->nalloc); @@ -127,44 +122,44 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, #ifndef NDEBUG HDassert(H5F_addr_defined(mesg->heap_addr)); - if(NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) + 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") s = (const char *)H5HL_offset_into(heap, 0); HDassert(s && !*s); - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; #endif /* Decode the file list */ mesg->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); - if(NULL == mesg->slot) + 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))) + 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 (u = 0; u < mesg->nused; u++) { /* Name */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].name_offset); - if((s = (const char *)H5HL_offset_into(heap, mesg->slot[u].name_offset)) == NULL) + 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') + if (*s == (char)'\0') HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "invalid external file name") - mesg->slot[u].name = H5MM_xstrdup (s); + mesg->slot[u].name = H5MM_xstrdup(s); HDassert(mesg->slot[u].name); /* File offset */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].offset); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].offset); /* Size */ - H5F_DECODE_LENGTH (f, p, mesg->slot[u].size); + H5F_DECODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ - if(H5HL_unprotect(heap) < 0) + if (H5HL_unprotect(heap) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") heap = NULL; @@ -172,16 +167,15 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = mesg; done: - if(ret_value == NULL) - if(mesg != NULL) + if (ret_value == NULL) + if (mesg != NULL) H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_efl_decode() */ +} /* end H5O__efl_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_efl_encode + * Function: H5O__efl_encode * * Purpose: Encodes a message. * @@ -193,12 +187,12 @@ H5O_efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; - size_t u; /* Local index variable */ + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -224,23 +218,22 @@ H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, cons H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ - for(u = 0; u < mesg->nused; u++) { - /* - * The name should have been added to the heap when the dataset was - * created. - */ - HDassert(mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); + for (u = 0; u < mesg->nused; u++) { + /* + * The name should have been added to the heap when the dataset was + * created. + */ + HDassert(mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); + H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_efl_encode() */ +} /* end H5O__efl_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_efl_copy + * Function: H5O__efl_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -255,59 +248,58 @@ H5O_efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, cons *------------------------------------------------------------------------- */ static void * -H5O_efl_copy(const void *_mesg, void *_dest) +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; - 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 */ + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(mesg); /* Allocate destination message, if necessary */ - if(!dest && NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (!dest && NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message") /* copy */ *dest = *mesg; /* Deep copy allocated information */ - if(dest->nalloc > 0) { - if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(dest->nalloc * sizeof(H5O_efl_entry_t)))) + if (dest->nalloc > 0) { + if (NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(dest->nalloc * sizeof(H5O_efl_entry_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") slot_allocated = TRUE; - for(u = 0; u < mesg->nused; u++) { + for (u = 0; u < mesg->nused; u++) { dest->slot[u] = mesg->slot[u]; - if(NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) + if (NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slot name") } /* end for */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) { - if(slot_allocated) { - for(u = 0; u < dest->nused; u++) - if(dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) + if (NULL == ret_value) { + if (slot_allocated) { + for (u = 0; u < dest->nused; u++) + if (dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot); } /* end if */ - if(NULL == _dest) + if (NULL == _dest) dest = (H5O_efl_t *)H5MM_xfree(dest); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_efl_copy() */ +} /* end H5O__efl_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_efl_size + * Function: H5O__efl_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This @@ -324,29 +316,28 @@ H5O_efl_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - size_t ret_value = 0; + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); HDassert(mesg); - ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ - 2 + /*slots allocated*/ - 2 + /*num slots used*/ - 4 + /*reserved */ - mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ - (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ - (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ + ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ + 2 + /*slots allocated*/ + 2 + /*num slots used*/ + 4 + /*reserved */ + mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ + (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ + (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_efl_size() */ +} /* end H5O__efl_size() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_reset * @@ -363,8 +354,8 @@ H5O_efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void * static herr_t H5O__efl_reset(void *_mesg) { - H5O_efl_t *mesg = (H5O_efl_t *) _mesg; - size_t u; /* Local index variable */ + H5O_efl_t *mesg = (H5O_efl_t *)_mesg; + size_t u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -372,9 +363,9 @@ H5O__efl_reset(void *_mesg) HDassert(mesg); /* reset */ - if(mesg->slot) { - for(u = 0; u < mesg->nused; u++) { - mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name); + if (mesg->slot) { + for (u = 0; u < mesg->nused; u++) { + mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name); mesg->slot[u].name_offset = 0; } /* end for */ mesg->slot = (H5O_efl_entry_t *)H5MM_xfree(mesg->slot); @@ -385,7 +376,6 @@ H5O__efl_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__efl_reset() */ - /*------------------------------------------------------------------------- * Function: H5O_efl_total_size * @@ -402,29 +392,28 @@ H5O__efl_reset(void *_mesg) *------------------------------------------------------------------------- */ hsize_t -H5O_efl_total_size (H5O_efl_t *efl) +H5O_efl_total_size(H5O_efl_t *efl) { - hsize_t ret_value = 0, tmp; + hsize_t ret_value = 0, tmp; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(0) - if(efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size) - ret_value = H5O_EFL_UNLIMITED; + if (efl->nused > 0 && H5O_EFL_UNLIMITED == efl->slot[efl->nused - 1].size) + ret_value = H5O_EFL_UNLIMITED; else { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ - for(u = 0; u < efl->nused; u++, ret_value = tmp) { - tmp = ret_value + efl->slot[u].size; - if(tmp <= ret_value) - HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); - } /* end for */ - } /* end else */ + for (u = 0; u < efl->nused; u++, ret_value = tmp) { + tmp = ret_value + efl->slot[u].size; + if (tmp <= ret_value) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); + } /* end for */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_total_size() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_copy_file * @@ -441,14 +430,14 @@ H5O_efl_total_size (H5O_efl_t *efl) */ static void * H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_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 H5_ATTR_UNUSED *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *_udata) { - 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 */ - size_t idx, size, name_offset, heap_size; - void *ret_value = NULL; /* Return value */ + 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 */ + size_t idx, size, name_offset, heap_size; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -457,34 +446,34 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d HDassert(file_dst); /* Allocate space for the destination efl */ - if(NULL == (efl_dst = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + if (NULL == (efl_dst = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the "top level" information */ H5MM_memcpy(efl_dst, efl_src, sizeof(H5O_efl_t)); /* Determine size needed for destination heap */ - heap_size = H5HL_ALIGN(1); /* "empty" name */ - for(idx = 0; idx < efl_src->nused; idx++) + heap_size = H5HL_ALIGN(1); /* "empty" name */ + for (idx = 0; idx < efl_src->nused; idx++) heap_size += H5HL_ALIGN(HDstrlen(efl_src->slot[idx].name) + 1); /* Create name heap */ - if(H5HL_create(file_dst, heap_size, &efl_dst->heap_addr/*out*/) < 0) + if (H5HL_create(file_dst, heap_size, &efl_dst->heap_addr /*out*/) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL, "can't create heap") /* Pin the heap down in memory */ - if(NULL == (heap = H5HL_protect(file_dst, efl_dst->heap_addr, H5AC__NO_FLAGS_SET))) + if (NULL == (heap = H5HL_protect(file_dst, efl_dst->heap_addr, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to protect EFL file name heap") /* Insert "empty" name first */ - if(UFAIL == (name_offset = H5HL_insert(file_dst, heap, (size_t)1, ""))) + if (H5HL_insert(file_dst, heap, (size_t)1, "", &name_offset) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") HDassert(0 == name_offset); /* allocate array of external file entries */ - if(efl_src->nalloc > 0) { + if (efl_src->nalloc > 0) { size = efl_src->nalloc * sizeof(H5O_efl_entry_t); - if((efl_dst->slot = (H5O_efl_entry_t *)H5MM_calloc(size)) == NULL) + if ((efl_dst->slot = (H5O_efl_entry_t *)H5MM_calloc(size)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy content from the source. Need to update later */ @@ -492,28 +481,27 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d } /* end if */ /* copy the name from the source */ - for(idx = 0; idx < efl_src->nused; idx++) { + for (idx = 0; idx < efl_src->nused; idx++) { efl_dst->slot[idx].name = H5MM_xstrdup(efl_src->slot[idx].name); - if(UFAIL == (efl_dst->slot[idx].name_offset = H5HL_insert(file_dst, heap, - HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name))) + if (H5HL_insert(file_dst, heap, HDstrlen(efl_dst->slot[idx].name) + 1, efl_dst->slot[idx].name, + &(efl_dst->slot[idx].name_offset)) < 0) HGOTO_ERROR(H5E_EFL, H5E_CANTINSERT, NULL, "can't insert file name into heap") - } /* end for */ + } /* Set return value */ ret_value = efl_dst; done: /* Release resources */ - if(heap && H5HL_unprotect(heap) < 0) + if (heap && H5HL_unprotect(heap) < 0) HDONE_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to unprotect EFL file name heap") - if(!ret_value) - if(efl_dst) + if (!ret_value) + if (efl_dst) H5MM_xfree(efl_dst); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__efl_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__efl_debug * @@ -527,11 +515,10 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d *------------------------------------------------------------------------- */ static herr_t -H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; - size_t u; + const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; + size_t u; FUNC_ENTER_STATIC_NOERR @@ -542,36 +529,29 @@ H5O__efl_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Heap address:", mesg->heap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Heap address:", mesg->heap_addr); - HDfprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth, - "Slots used/allocated:", - mesg->nused, mesg->nalloc); + HDfprintf(stream, "%*s%-*s %zu/%zu\n", indent, "", fwidth, "Slots used/allocated:", mesg->nused, + mesg->nalloc); - for(u = 0; u < mesg->nused; u++) { - char buf[64]; + for (u = 0; u < mesg->nused; u++) { + char buf[64]; - HDsnprintf(buf, sizeof(buf), "File %u", (unsigned)u); - HDfprintf(stream, "%*s%s:\n", indent, "", buf); + HDsnprintf(buf, sizeof(buf), "File %zu", u); + HDfprintf(stream, "%*s%s:\n", indent, "", buf); - HDfprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0), - "Name:", - mesg->slot[u].name); + HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(fwidth - 3, 0), + "Name:", mesg->slot[u].name); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Name offset:", - (unsigned long)(mesg->slot[u].name_offset)); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(fwidth - 3, 0), + "Name offset:", mesg->slot[u].name_offset); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Offset of data in file:", - (unsigned long)(mesg->slot[u].offset)); + HDfprintf(stream, "%*s%-*s %" PRIdMAX "\n", indent + 3, "", MAX(fwidth - 3, 0), + "Offset of data in file:", (intmax_t)(mesg->slot[u].offset)); - HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), - "Bytes reserved for data:", - (unsigned long)(mesg->slot[u].size)); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent + 3, "", MAX(fwidth - 3, 0), + "Bytes reserved for data:", (mesg->slot[u].size)); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__efl_debug() */ - diff --git a/src/H5Ofill.c b/src/H5Ofill.c index b0a8631bfb5..2314a84f5a3 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,156 +18,156 @@ * uninitialized data points of a dataset. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#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, 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, 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); +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#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, + 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, + 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 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, const H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__fill_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +static herr_t H5O__fill_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__fill_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_FILL -#define H5O_SHARED_DECODE H5O_fill_shared_decode -#define H5O_SHARED_DECODE_REAL H5O_fill_old_decode -#define H5O_SHARED_ENCODE H5O_fill_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_fill_old_encode -#define H5O_SHARED_SIZE H5O_fill_shared_size -#define H5O_SHARED_SIZE_REAL H5O_fill_old_size -#define H5O_SHARED_DELETE H5O__fill_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_FILL +#define H5O_SHARED_DECODE H5O__fill_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__fill_old_decode +#define H5O_SHARED_ENCODE H5O__fill_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O__fill_old_encode +#define H5O_SHARED_SIZE H5O__fill_shared_size +#define H5O_SHARED_SIZE_REAL H5O__fill_old_size +#define H5O_SHARED_DELETE H5O__fill_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__fill_shared_link +#define H5O_SHARED_LINK H5O__fill_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__fill_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__fill_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_fill_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__fill_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_fill_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__fill_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O__fill_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__fill_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* Set up & include shared message "interface" info */ /* (Kludgy 'undef's in order to re-include the H5Oshared.h header) */ #undef H5O_SHARED_TYPE -#define H5O_SHARED_TYPE H5O_MSG_FILL_NEW +#define H5O_SHARED_TYPE H5O_MSG_FILL_NEW #undef H5O_SHARED_DECODE -#define H5O_SHARED_DECODE H5O_fill_new_shared_decode +#define H5O_SHARED_DECODE H5O__fill_new_shared_decode #undef H5O_SHARED_DECODE_REAL -#define H5O_SHARED_DECODE_REAL H5O_fill_new_decode +#define H5O_SHARED_DECODE_REAL H5O__fill_new_decode #undef H5O_SHARED_ENCODE -#define H5O_SHARED_ENCODE H5O_fill_new_shared_encode +#define H5O_SHARED_ENCODE H5O__fill_new_shared_encode #undef H5O_SHARED_ENCODE_REAL -#define H5O_SHARED_ENCODE_REAL H5O_fill_new_encode +#define H5O_SHARED_ENCODE_REAL H5O__fill_new_encode #undef H5O_SHARED_SIZE -#define H5O_SHARED_SIZE H5O_fill_new_shared_size +#define H5O_SHARED_SIZE H5O__fill_new_shared_size #undef H5O_SHARED_SIZE_REAL -#define H5O_SHARED_SIZE_REAL H5O_fill_new_size +#define H5O_SHARED_SIZE_REAL H5O__fill_new_size #undef H5O_SHARED_DELETE -#define H5O_SHARED_DELETE H5O__fill_new_shared_delete +#define H5O_SHARED_DELETE H5O__fill_new_shared_delete #undef H5O_SHARED_DELETE_REAL #undef H5O_SHARED_LINK -#define H5O_SHARED_LINK H5O__fill_new_shared_link +#define H5O_SHARED_LINK H5O__fill_new_shared_link #undef H5O_SHARED_LINK_REAL #undef H5O_SHARED_COPY_FILE -#define H5O_SHARED_COPY_FILE H5O__fill_new_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__fill_new_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL #undef H5O_SHARED_POST_COPY_FILE -#define H5O_SHARED_POST_COPY_FILE H5O_fill_new_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__fill_new_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD +#undef H5O_SHARED_POST_COPY_FILE_UPD #undef H5O_SHARED_DEBUG -#define H5O_SHARED_DEBUG H5O_fill_new_shared_debug +#define H5O_SHARED_DEBUG H5O__fill_new_shared_debug #undef H5O_SHARED_DEBUG_REAL -#define H5O_SHARED_DEBUG_REAL H5O__fill_debug +#define H5O_SHARED_DEBUG_REAL H5O__fill_debug #undef H5Oshared_H -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class, for old fill value before version 1.5 */ 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_fill_shared_decode, /*decode message */ - H5O_fill_shared_encode, /*encode message */ - H5O_fill_copy, /*copy the native value */ - H5O_fill_shared_size, /*raw message size */ - H5O__fill_reset, /*free internal memory */ - H5O__fill_free, /* free method */ - H5O__fill_shared_delete, /* file delete method */ - H5O__fill_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O__fill_pre_copy_file, /* pre copy native value to file */ - H5O__fill_shared_copy_file, /* copy native value to file */ - H5O_fill_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_fill_shared_debug /*debug the message */ + 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__fill_shared_decode, /*decode message */ + H5O__fill_shared_encode, /*encode message */ + H5O__fill_copy, /*copy the native value */ + H5O__fill_shared_size, /*raw message size */ + H5O__fill_reset, /*free internal memory */ + H5O__fill_free, /* free method */ + H5O__fill_shared_delete, /* file delete method */ + H5O__fill_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__fill_pre_copy_file, /* pre copy native value to file */ + H5O__fill_shared_copy_file, /* copy native value to file */ + H5O__fill_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__fill_shared_debug /*debug the message */ }}; /* This message derives from H5O message class, for new fill value after version 1.4 */ 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_fill_new_shared_decode, /*decode message */ - H5O_fill_new_shared_encode, /*encode message */ - H5O_fill_copy, /*copy the native value */ - H5O_fill_new_shared_size, /*raw message size */ - H5O__fill_reset, /*free internal memory */ - H5O__fill_free, /* free method */ - H5O__fill_new_shared_delete, /* file delete method */ - H5O__fill_new_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O__fill_pre_copy_file, /* pre copy native value to file */ - H5O__fill_new_shared_copy_file, /* copy native value to file */ - H5O_fill_new_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_fill_new_shared_debug /*debug the message */ + 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__fill_new_shared_decode, /*decode message */ + H5O__fill_new_shared_encode, /*encode message */ + H5O__fill_copy, /*copy the native value */ + H5O__fill_new_shared_size, /*raw message size */ + H5O__fill_reset, /*free internal memory */ + H5O__fill_free, /* free method */ + H5O__fill_new_shared_delete, /* file delete method */ + H5O__fill_new_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__fill_pre_copy_file, /* pre copy native value to file */ + H5O__fill_new_shared_copy_file, /* copy native value to file */ + H5O__fill_new_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__fill_new_shared_debug /*debug the message */ }}; /* Format version bounds for fill value */ const unsigned H5O_fill_ver_bounds[] = { H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */ H5O_FILL_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_FILL_VERSION_3, /* H5F_LIBVER_V110 */ H5O_FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Masks, shift values & flags for fill value message */ -#define H5O_FILL_MASK_ALLOC_TIME 0x03 -#define H5O_FILL_SHIFT_ALLOC_TIME 0 -#define H5O_FILL_MASK_FILL_TIME 0x03 -#define H5O_FILL_SHIFT_FILL_TIME 2 -#define H5O_FILL_FLAG_UNDEFINED_VALUE 0x10 -#define H5O_FILL_FLAG_HAVE_VALUE 0x20 -#define H5O_FILL_FLAGS_ALL (H5O_FILL_MASK_ALLOC_TIME | (H5O_FILL_MASK_FILL_TIME << H5O_FILL_SHIFT_FILL_TIME) | H5O_FILL_FLAG_UNDEFINED_VALUE | H5O_FILL_FLAG_HAVE_VALUE) +#define H5O_FILL_MASK_ALLOC_TIME 0x03 +#define H5O_FILL_SHIFT_ALLOC_TIME 0 +#define H5O_FILL_MASK_FILL_TIME 0x03 +#define H5O_FILL_SHIFT_FILL_TIME 2 +#define H5O_FILL_FLAG_UNDEFINED_VALUE 0x10 +#define H5O_FILL_FLAG_HAVE_VALUE 0x20 +#define H5O_FILL_FLAGS_ALL \ + (H5O_FILL_MASK_ALLOC_TIME | (H5O_FILL_MASK_FILL_TIME << H5O_FILL_SHIFT_FILL_TIME) | \ + H5O_FILL_FLAG_UNDEFINED_VALUE | H5O_FILL_FLAG_HAVE_VALUE) /* Declare a free list to manage the H5O_fill_t struct */ H5FL_DEFINE(H5O_fill_t); @@ -175,9 +175,8 @@ H5FL_DEFINE(H5O_fill_t); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /*------------------------------------------------------------------------- - * Function: H5O_fill_new_decode + * Function: H5O__fill_new_decode * * Purpose: Decode a new fill value message. The new fill value * message is fill value plus space allocation time and @@ -192,28 +191,29 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ static void * -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_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; - void *ret_value = NULL; /* Return value */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(f); HDassert(p); - if(NULL == (fill = H5FL_CALLOC(H5O_fill_t))) + if (NULL == (fill = H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message") /* Version */ fill->version = *p++; - if(fill->version < H5O_FILL_VERSION_1 || fill->version > H5O_FILL_VERSION_LATEST) + if (fill->version < H5O_FILL_VERSION_1 || fill->version > H5O_FILL_VERSION_LATEST) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for fill value message") /* Decode each version */ - if(fill->version < H5O_FILL_VERSION_3) { + if (fill->version < H5O_FILL_VERSION_3) { /* Space allocation time */ fill->alloc_time = (H5D_alloc_time_t)*p++; @@ -224,79 +224,81 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, fill->fill_defined = *p++; /* Only decode fill value information if one is defined */ - if(fill->fill_defined) { + if (fill->fill_defined) { INT32DECODE(p, fill->size); - if(fill->size > 0) { + if (fill->size > 0) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if((size_t)fill->size > p_size) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "destination buffer too small") - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + + /* Ensure that fill size doesn't exceed buffer size, due to possible data corruption */ + if (p + fill->size - 1 > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "fill size exceeds buffer size") + + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); } /* end if */ - } /* end if */ + } /* end if */ else fill->size = (-1); } /* end if */ else { - unsigned flags; /* Status flags */ + unsigned flags; /* Status flags */ /* Flags */ flags = *p++; /* Check for unknown flags */ - if(flags & (unsigned)~H5O_FILL_FLAGS_ALL) + if (flags & (unsigned)~H5O_FILL_FLAGS_ALL) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown flag for fill value message") /* Space allocation time */ - fill->alloc_time = (H5D_alloc_time_t)((flags >> H5O_FILL_SHIFT_ALLOC_TIME) & H5O_FILL_MASK_ALLOC_TIME); + fill->alloc_time = + (H5D_alloc_time_t)((flags >> H5O_FILL_SHIFT_ALLOC_TIME) & H5O_FILL_MASK_ALLOC_TIME); /* Fill value write time */ fill->fill_time = (H5D_fill_time_t)((flags >> H5O_FILL_SHIFT_FILL_TIME) & H5O_FILL_MASK_FILL_TIME); /* Check for undefined fill value */ - if(flags & H5O_FILL_FLAG_UNDEFINED_VALUE) { + if (flags & H5O_FILL_FLAG_UNDEFINED_VALUE) { /* Sanity check */ HDassert(!(flags & H5O_FILL_FLAG_HAVE_VALUE)); /* Set value for "undefined" fill value */ fill->size = (-1); } /* end if */ - else if(flags & H5O_FILL_FLAG_HAVE_VALUE) { + else if (flags & H5O_FILL_FLAG_HAVE_VALUE) { /* Fill value size */ UINT32DECODE(p, fill->size); /* Fill value */ H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); /* Set the "defined" flag */ fill->fill_defined = TRUE; } /* end else */ - else { + else /* Set the "defined" flag */ fill->fill_defined = TRUE; - } /* end else */ } /* end else */ /* Set return value */ ret_value = (void *)fill; done: - if(!ret_value && fill) { - if(fill->buf) + if (!ret_value && fill) { + if (fill->buf) H5MM_xfree(fill->buf); fill = H5FL_FREE(H5O_fill_t, fill); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fill_new_decode() */ - +} /* end H5O__fill_new_decode() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_old_decode + * Function: H5O__fill_old_decode * * Purpose: Decode an old fill value message. * @@ -309,49 +311,51 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ 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_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 */ - htri_t exists = FALSE; - H5T_t *dt = NULL; - void *ret_value = NULL; /* Return value */ + H5O_fill_t * fill = NULL; /* Decoded fill value message */ + htri_t exists = FALSE; + H5T_t * dt = NULL; + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(f); HDassert(p); - if(NULL == (fill = H5FL_CALLOC(H5O_fill_t))) + if (NULL == (fill = H5FL_CALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message") /* Set non-zero default fields */ - fill->version = H5O_FILL_VERSION_2; + fill->version = H5O_FILL_VERSION_2; fill->alloc_time = H5D_ALLOC_TIME_LATE; - fill->fill_time = H5D_FILL_TIME_IFSET; + fill->fill_time = H5D_FILL_TIME_IFSET; /* Fill value size */ UINT32DECODE(p, fill->size); /* Only decode the fill value itself if there is one */ - if(fill->size > 0) { + if (fill->size > 0) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); - if((size_t)fill->size > p_size) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "destination buffer too small") + + /* Ensure that fill size doesn't exceed buffer size, due to possible data corruption */ + if (p + fill->size - 1 > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "fill size exceeds buffer size") /* Get the datatype message */ - if((exists = H5O_msg_exists_oh(open_oh, H5O_DTYPE_ID)) < 0) + if ((exists = H5O_msg_exists_oh(open_oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read object header") - if(exists) { - if((dt = H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL)) < 0) + if (exists) { + if (NULL == (dt = (H5T_t *)H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't read DTYPE message") /* Verify size */ - if(fill->size != H5T_GET_SIZE(dt)) + if (fill->size != (ssize_t)H5T_GET_SIZE(dt)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "inconsistent fill value size") - } + } /* end if */ - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(fill->buf, p, (size_t)fill->size); fill->fill_defined = TRUE; @@ -360,24 +364,23 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, fill->size = (-1); /* Set return value */ - ret_value = (void*)fill; + ret_value = (void *)fill; done: - if(dt) + if (dt) H5O_msg_free(H5O_DTYPE_ID, dt); - if(!ret_value && fill) { - if(fill->buf) + if (!ret_value && fill) { + if (fill->buf) H5MM_xfree(fill->buf); fill = H5FL_FREE(H5O_fill_t, fill); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fill_old_decode() */ - +} /* end H5O__fill_old_decode() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_new_encode + * Function: H5O__fill_new_encode * * Purpose: Encode a new fill value message. The new fill value * message is fill value plus space allocation time and @@ -391,11 +394,11 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) +H5O__fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) { - const H5O_fill_t *fill = (const H5O_fill_t *)_fill; + const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f); HDassert(p); @@ -404,7 +407,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Version */ *p++ = (uint8_t)fill->version; - if(fill->version < H5O_FILL_VERSION_3) { + if (fill->version < H5O_FILL_VERSION_3) { /* Space allocation time */ *p++ = (uint8_t)fill->alloc_time; @@ -415,28 +418,29 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) *p++ = (uint8_t)fill->fill_defined; /* Only write out the size and fill value if it is defined */ - if(fill->fill_defined) { + if (fill->fill_defined) { UINT32ENCODE(p, fill->size); - if(fill->size > 0) - if(fill->buf) { + if (fill->size > 0) + if (fill->buf) { H5_CHECK_OVERFLOW(fill->size, ssize_t, size_t); H5MM_memcpy(p, fill->buf, (size_t)fill->size); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - uint8_t flags = 0; /* Fill value setting flags */ + uint8_t flags = 0; /* Fill value setting flags */ /* Encode space allocation time */ HDassert(fill->alloc_time == (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time)); - flags = (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); + flags = + (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); /* Encode fill value writing time */ HDassert(fill->fill_time == (H5O_FILL_MASK_FILL_TIME & fill->fill_time)); flags = (uint8_t)(flags | ((H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME)); /* Check if we need to encode a fill value size */ - if(fill->size < 0) { + if (fill->size < 0) { /* Indicate that the fill value has been "undefined" by the user */ flags |= H5O_FILL_FLAG_UNDEFINED_VALUE; @@ -446,7 +450,7 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Sanity check */ HDassert(!fill->buf); } /* end if */ - else if(fill->size > 0) { + else if (fill->size > 0) { /* Indicate that a fill value size is present */ flags |= H5O_FILL_FLAG_HAVE_VALUE; @@ -468,14 +472,13 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) /* Sanity check */ HDassert(!fill->buf); } /* end else */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_fill_new_encode() */ - +} /* end H5O__fill_new_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_old_encode + * Function: H5O__fill_old_encode * * Purpose: Encode an old fill value message. * @@ -487,26 +490,25 @@ H5O_fill_new_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) *------------------------------------------------------------------------- */ static herr_t -H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) +H5O__fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f); HDassert(p); HDassert(fill && NULL == fill->type); UINT32ENCODE(p, fill->size); - if(fill->buf) + if (fill->buf) H5MM_memcpy(p, fill->buf, (size_t)fill->size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_fill_old_encode() */ - +} /* end H5O__fill_old_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_copy + * Function: H5O__fill_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. The new fill value message is fill value plus @@ -522,74 +524,76 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill) *------------------------------------------------------------------------- */ static void * -H5O_fill_copy(const void *_src, void *_dst) +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 */ + const H5O_fill_t *src = (const H5O_fill_t *)_src; + H5O_fill_t * dst = (H5O_fill_t *)_dst; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(src); - if(!dst && NULL == (dst = H5FL_MALLOC(H5O_fill_t))) + if (!dst && NULL == (dst = H5FL_MALLOC(H5O_fill_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message") /* Shallow copy basic fields */ *dst = *src; /* Copy data type of fill value */ - if(src->type) { - if(NULL == (dst->type = H5T_copy(src->type, H5T_COPY_TRANSIENT))) + if (src->type) { + if (NULL == (dst->type = H5T_copy(src->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "can't copy datatype") } /* end if */ else dst->type = NULL; /* Copy fill value and its size */ - if(src->buf) { + if (src->buf) { H5_CHECK_OVERFLOW(src->size, ssize_t, size_t); - if(NULL == (dst->buf = H5MM_malloc((size_t)src->size))) + if (NULL == (dst->buf = H5MM_malloc((size_t)src->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") H5MM_memcpy(dst->buf, src->buf, (size_t)src->size); /* Check for needing to convert/copy fill value */ - if(src->type) { - H5T_path_t *tpath; /* Conversion information */ + if (src->type) { + H5T_path_t *tpath; /* Conversion information */ /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(src->type, dst->type))) - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types") + if (NULL == (tpath = H5T_path_find(src->type, dst->type))) + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, + "unable to convert between src and dst data types") /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(!H5T_path_noop(tpath)) { - hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ - size_t bkg_size; /* Size of background buffer */ + if (!H5T_path_noop(tpath)) { + hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */ + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + size_t bkg_size; /* Size of background buffer */ /* Wrap copies of types to convert */ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->type, H5T_COPY_TRANSIENT), FALSE); - if(dst_id < 0) + if (dst_id < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(src->type, H5T_COPY_ALL), FALSE); - if(src_id < 0) { + if (src_id < 0) { H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_get_size(dst->type), H5T_get_size(src->type)); - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ /* Convert fill value */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf) < 0) { + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf) < + 0) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, NULL, "datatype conversion failed") } /* end if */ @@ -597,11 +601,11 @@ H5O_fill_copy(const void *_src, void *_dst) /* Release the background buffer */ H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else dst->buf = NULL; @@ -609,21 +613,20 @@ H5O_fill_copy(const void *_src, void *_dst) ret_value = dst; done: - if(!ret_value && dst) { - if(dst->buf) + if (!ret_value && dst) { + if (dst->buf) H5MM_xfree(dst->buf); - if(dst->type) + if (dst->type) (void)H5T_close_real(dst->type); - if(!_dst) + if (!_dst) dst = H5FL_FREE(H5O_fill_t, dst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fill_copy() */ - +} /* end H5O__fill_copy() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_new_size + * Function: H5O__fill_new_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This @@ -640,40 +643,39 @@ H5O_fill_copy(const void *_src, void *_dst) *------------------------------------------------------------------------- */ static size_t -H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) +H5O__fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) { - const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - size_t ret_value = 0; /* Return value */ + const H5O_fill_t *fill = (const H5O_fill_t *)_fill; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(f); HDassert(fill); /* Determine size for different versions */ - if(fill->version < H5O_FILL_VERSION_3) { - ret_value = 1 + /* Version number */ - 1 + /* Space allocation time */ - 1 + /* Fill value write time */ - 1; /* Fill value defined */ - if(fill->fill_defined) - ret_value += 4 + /* Fill value size */ - (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ - } /* end if */ + if (fill->version < H5O_FILL_VERSION_3) { + ret_value = 1 + /* Version number */ + 1 + /* Space allocation time */ + 1 + /* Fill value write time */ + 1; /* Fill value defined */ + if (fill->fill_defined) + ret_value += 4 + /* Fill value size */ + (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ + } /* end if */ else { - ret_value = 1 + /* Version number */ - 1; /* Status flags */ - if(fill->size > 0) - ret_value += 4 + /* Fill value size */ - (size_t)fill->size; /* Size of fill value */ - } /* end else */ + ret_value = 1 + /* Version number */ + 1; /* Status flags */ + if (fill->size > 0) + ret_value += 4 + /* Fill value size */ + (size_t)fill->size; /* Size of fill value */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fill_new_size() */ - +} /* end H5O__fill_new_size() */ /*------------------------------------------------------------------------- - * Function: H5O_fill_old_size + * Function: H5O__fill_old_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. This @@ -688,17 +690,16 @@ H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) *------------------------------------------------------------------------- */ static size_t -H5O_fill_old_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) +H5O__fill_old_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(fill); FUNC_LEAVE_NOAPI(4 + (size_t)fill->size) -} /* end H5O_fill_old_size() */ - +} /* end H5O__fill_old_size() */ /*------------------------------------------------------------------------- * Function: H5O_fill_reset_dyn @@ -715,32 +716,32 @@ H5O_fill_old_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill) herr_t H5O_fill_reset_dyn(H5O_fill_t *fill) { - hid_t fill_type_id = -1; /* Datatype ID for fill value datatype when reclaiming VL fill values */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t fill_type_id = -1; /* Datatype ID for fill value datatype when reclaiming VL fill values */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(fill); - if(fill->buf) { - if(fill->type && H5T_detect_class(fill->type, H5T_VLEN, FALSE) > 0) { - H5T_t *fill_type; /* Copy of fill value datatype */ - H5S_t *fill_space; /* Scalar dataspace for fill value element */ + if (fill->buf) { + if (fill->type && H5T_detect_class(fill->type, H5T_VLEN, FALSE) > 0) { + H5T_t *fill_type; /* Copy of fill value datatype */ + H5S_t *fill_space; /* Scalar dataspace for fill value element */ /* Copy the fill value datatype and get an ID for it */ - if(NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT))) + if (NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy fill value datatype") - if((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) { + if ((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) { (void)H5T_close_real(fill_type); HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype") } /* end if */ /* Create a scalar dataspace for the fill value element */ - if(NULL == (fill_space = H5S_create(H5S_SCALAR))) + if (NULL == (fill_space = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create scalar dataspace") /* Reclaim any variable length components of the fill value */ - if(H5D_vlen_reclaim(fill_type_id, fill_space, fill->buf) < 0) { + if (H5T_reclaim(fill_type_id, fill_space, fill->buf) < 0) { H5S_close(fill_space); HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data") } /* end if */ @@ -753,19 +754,18 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) fill->buf = H5MM_xfree(fill->buf); } /* end if */ fill->size = 0; - if(fill->type) { - (void)H5T_close_real(fill->type); - fill->type = NULL; + if (fill->type) { + (void)H5T_close_real(fill->type); + fill->type = NULL; } /* end if */ done: - if(fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) + if (fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_reset_dyn() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_reset * @@ -781,7 +781,7 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) static herr_t H5O__fill_reset(void *_fill) { - H5O_fill_t *fill = (H5O_fill_t *)_fill; + H5O_fill_t *fill = (H5O_fill_t *)_fill; FUNC_ENTER_STATIC_NOERR @@ -798,7 +798,6 @@ H5O__fill_reset(void *_fill) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_free * @@ -823,7 +822,6 @@ H5O__fill_free(void *fill) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_free() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_pre_copy_file * @@ -838,11 +836,11 @@ H5O__fill_free(void *fill) *------------------------------------------------------------------------- */ static herr_t -H5O__fill_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 H5_ATTR_UNUSED *udata) +H5O__fill_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 H5_ATTR_UNUSED *udata) { - const H5O_fill_t *fill_src = (const H5O_fill_t *)mesg_src; /* Source fill value */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_fill_t *fill_src = (const H5O_fill_t *)mesg_src; /* Source fill value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -852,14 +850,13 @@ H5O__fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "fill value message version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__fill_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__fill_debug * @@ -873,11 +870,10 @@ H5O__fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, - int indent, int fwidth) +H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, int indent, int fwidth) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; - H5D_fill_value_t fill_status; /* Whether the fill value is defined */ + H5D_fill_value_t fill_status; /* Whether the fill value is defined */ FUNC_ENTER_STATIC_NOERR @@ -888,70 +884,69 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Space Allocation Time:"); - switch(fill->alloc_time) { + switch (fill->alloc_time) { case H5D_ALLOC_TIME_EARLY: - HDfprintf(stream,"Early\n"); + HDfprintf(stream, "Early\n"); break; case H5D_ALLOC_TIME_LATE: - HDfprintf(stream,"Late\n"); + HDfprintf(stream, "Late\n"); break; case H5D_ALLOC_TIME_INCR: - HDfprintf(stream,"Incremental\n"); + HDfprintf(stream, "Incremental\n"); break; case H5D_ALLOC_TIME_DEFAULT: case H5D_ALLOC_TIME_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:"); - switch(fill->fill_time) { + switch (fill->fill_time) { case H5D_FILL_TIME_ALLOC: - HDfprintf(stream,"On Allocation\n"); + HDfprintf(stream, "On Allocation\n"); break; case H5D_FILL_TIME_NEVER: - HDfprintf(stream,"Never\n"); + HDfprintf(stream, "Never\n"); break; case H5D_FILL_TIME_IFSET: - HDfprintf(stream,"If Set\n"); + HDfprintf(stream, "If Set\n"); break; case H5D_FILL_TIME_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Value Defined:"); H5P_is_fill_value_defined((const H5O_fill_t *)fill, &fill_status); - switch(fill_status) { + switch (fill_status) { case H5D_FILL_VALUE_UNDEFINED: - HDfprintf(stream,"Undefined\n"); + HDfprintf(stream, "Undefined\n"); break; case H5D_FILL_VALUE_DEFAULT: - HDfprintf(stream,"Default\n"); + HDfprintf(stream, "Default\n"); break; case H5D_FILL_VALUE_USER_DEFINED: - HDfprintf(stream,"User Defined\n"); + HDfprintf(stream, "User Defined\n"); break; case H5D_FILL_VALUE_ERROR: default: - HDfprintf(stream,"Unknown!\n"); + HDfprintf(stream, "Unknown!\n"); break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %Zd\n", indent, "", fwidth, - "Size:", fill->size); + HDfprintf(stream, "%*s%-*s %zd\n", indent, "", fwidth, "Size:", fill->size); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:"); - if(fill->type) { + if (fill->type) { H5T_debug(fill->type, stream); HDfprintf(stream, "\n"); } /* end if */ @@ -961,7 +956,6 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fill_debug() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_convert * @@ -980,21 +974,21 @@ H5O__fill_debug(H5F_t H5_ATTR_UNUSED *f, const void *_fill, FILE *stream, 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 */ - hid_t src_id = -1, dst_id = -1; /* Datatype identifiers */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_path_t *tpath; /* Type conversion info */ + void * buf = NULL, *bkg = NULL; /* Conversion buffers */ + hid_t src_id = -1, dst_id = -1; /* Datatype identifiers */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) HDassert(fill); HDassert(dset_type); HDassert(fill_changed); /* No-op cases */ - if(!fill->buf || !fill->type || 0 == H5T_cmp(fill->type, dset_type, FALSE)) { + if (!fill->buf || !fill->type || 0 == H5T_cmp(fill->type, dset_type, FALSE)) { /* Don't need datatype for fill value */ - if(fill->type) + if (fill->type) (void)H5T_close_real(fill->type); fill->type = NULL; @@ -1007,38 +1001,38 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) /* * Can we convert between source and destination data types? */ - if(NULL == (tpath = H5T_path_find(fill->type, dset_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + if (NULL == (tpath = H5T_path_find(fill->type, dset_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") /* Don't bother doing anything if there will be no actual conversion */ - if(!H5T_path_noop(tpath)) { - 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) + if (!H5T_path_noop(tpath)) { + 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") /* * 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)) + 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)))) + 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 */ /* Use CALLOC here to clear the buffer in case later the library thinks there's * data in the background. */ - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(dset_type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(dset_type)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") /* Do the conversion */ - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Update the fill message */ - if(buf != fill->buf) { + if (buf != fill->buf) { H5T_vlen_reclaim_elmt(fill->buf, fill->type); H5MM_xfree(fill->buf); fill->buf = buf; @@ -1052,19 +1046,18 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) } /* end if */ done: - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) 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) + 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) + if (buf != fill->buf) H5MM_xfree(buf); - if(bkg) + if (bkg) H5MM_xfree(bkg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_convert() */ - /*------------------------------------------------------------------------- * Function: H5O_fill_set_version * @@ -1079,8 +1072,8 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) herr_t H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1092,7 +1085,7 @@ H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) version = MAX(fill->version, H5O_fill_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") /* Set the message version */ @@ -1101,4 +1094,3 @@ H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_set_version() */ - diff --git a/src/H5Oflush.c b/src/H5Oflush.c index b7bbdbe9e81..eeba5259621 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,37 +26,33 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Errors */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Objects */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Errors */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Objects */ +#include "H5Tpkg.h" /* Datatypes */ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5O__flush(hid_t obj_id); static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag); -static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, - H5G_loc_t *obj_loc); - +static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc); /*************/ /* Functions */ /*************/ - - /*------------------------------------------------------------------------- * Function: H5Oflush * @@ -72,109 +68,112 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, herr_t H5Oflush(hid_t obj_id) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of obj_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", obj_id); + /* Check args */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(obj_id) < 0) + if (H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Flush the object */ - if(H5O__flush(obj_id) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oflush() */ - /*------------------------------------------------------------------------- - * Function: H5O_flush_common + * Function: H5O_flush * - * Purpose: Flushes the object's metadata - * Invokes the user-defined callback if there is one. + * Purpose: Internal routine to flush an object * - * Return: Non-negative on success, negative on failure + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Vailin Choi; Dec 2013 + * Programmer: Quincey Koziol + * December 29, 2017 * *------------------------------------------------------------------------- */ herr_t -H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id) +H5O_flush(H5O_loc_t *oloc, hid_t obj_id) { - haddr_t tag = 0; - herr_t ret_value = SUCCEED; /* Return value */ + void * obj_ptr; /* Pointer to object */ + const H5O_obj_class_t *obj_class; /* Class of object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Retrieve tag for object */ - if(H5O__oh_tag(oloc, &tag) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object metadata") + /* Get the object pointer */ + if (NULL == (obj_ptr = H5VL_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Flush metadata based on tag value of the object */ - if(H5F_flush_tagged_metadata(oloc->file, tag) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") + /* Get the object class */ + if (NULL == (obj_class = H5O__obj_class(oloc))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class") - /* Check to invoke callback */ - if(H5F_object_flush_cb(oloc->file, obj_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to do object flush callback") + /* Flush the object of this class */ + if (obj_class->flush && obj_class->flush(obj_ptr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + /* Flush the object metadata and invoke flush callback */ + if (H5O_flush_common(oloc, obj_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_flush_common() */ +} /* end H5O_flush() */ - /*------------------------------------------------------------------------- - * Function: H5O__flush + * Function: H5O_flush_common * - * Purpose: Internal routine to flush an object + * Purpose: Flushes the object's metadata + * Invokes the user-defined callback if there is one. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol - * December 29, 2017 + * Programmer: Vailin Choi; Dec 2013 * *------------------------------------------------------------------------- */ -static herr_t -H5O__flush(hid_t obj_id) +herr_t +H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id) { - H5O_loc_t *oloc; /* Object location */ - void *obj_ptr; /* Pointer to object */ - const H5O_obj_class_t *obj_class; /* Class of object */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag = 0; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC - - /* Check args */ - if(NULL == (oloc = H5O_get_loc(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object") - - /* Get the object pointer */ - if(NULL == (obj_ptr = H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + FUNC_ENTER_NOAPI(FAIL) - /* Get the object class */ - if(NULL == (obj_class = H5O__obj_class(oloc))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class") + /* Retrieve tag for object */ + if (H5O__oh_tag(oloc, &tag) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object metadata") - /* Flush the object of this class */ - if(obj_class->flush && obj_class->flush(obj_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + /* Flush metadata based on tag value of the object */ + if (H5F_flush_tagged_metadata(oloc->file, tag) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - /* Flush the object metadata and invoke flush callback */ - if(H5O_flush_common(oloc, obj_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback") + /* Check to invoke callback */ + if (H5F_object_flush_cb(oloc->file, obj_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to do object flush callback") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__flush() */ +} /* end H5O_flush_common() */ - /*------------------------------------------------------------------------- * Function: H5O__oh_tag * @@ -191,8 +190,8 @@ H5O__flush(hid_t obj_id) static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -200,22 +199,21 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) HDassert(oloc); /* Get object header for object */ - if(NULL == (oh = H5O_protect(oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object's object header") /* Get object header's address (i.e. the tag value for this object) */ - if(HADDR_UNDEF == (*tag = H5O_OH_GET_ADDR(oh))) + if (HADDR_UNDEF == (*tag = H5O_OH_GET_ADDR(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get address of object header") done: /* Unprotect object header on failure */ - if(oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__oh_tag() */ - /*------------------------------------------------------------------------- * Function: H5Orefresh * @@ -231,29 +229,34 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) herr_t H5Orefresh(hid_t oid) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t * vol_obj = NULL; /* Object of oid */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", oid); /* Check args */ - if(NULL == (oloc = H5O_get_loc(oid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object") + if (NULL == (vol_obj = H5VL_vol_object(oid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(oid) < 0) + if (H5CX_set_loc(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(oid); + /* Refresh the object */ - if(H5O_refresh_metadata(oid, *oloc) < 0) + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: FUNC_LEAVE_API(ret_value) } /* end H5Orefresh() */ - /*------------------------------------------------------------------------- * Function: H5O_refresh_metadata * @@ -277,16 +280,19 @@ H5Orefresh(hid_t oid) herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) { - hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* If the file is opened with write access, no need to perform refresh actions. */ - if(!(H5F_INTENT(oloc.file) & H5F_ACC_RDWR)) { - H5G_loc_t obj_loc; - H5O_loc_t obj_oloc; - H5G_name_t obj_path; + if (!(H5F_INTENT(oloc.file) & H5F_ACC_RDWR)) { + H5G_loc_t obj_loc; + H5O_loc_t obj_oloc; + H5G_name_t obj_path; + H5O_shared_t cached_H5O_shared; + H5VL_t * connector = NULL; /* Create empty object location */ obj_loc.oloc = &obj_oloc; @@ -299,23 +305,49 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) H5F_incr_nopen_objs(oloc.file); objs_incr = TRUE; + /* Save important datatype state */ + if (H5I_get_type(oid) == H5I_DATATYPE) + if (H5T_save_refresh_state(oid, &cached_H5O_shared) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state") + + /* Get the VOL object from the ID and cache a pointer to the connector. + * The vol_obj will disappear when the underlying object is closed, so + * we can't use that directly. + */ + if (NULL == (vol_obj = H5VL_vol_object(oid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + connector = vol_obj->connector; + + /* Bump the number of references on the VOL connector. + * If you don't do this, VDS refreshes can accidentally close the connector. + */ + connector->nrefs++; + /* Close object & evict its metadata */ - if((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) + if ((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) 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, FALSE)) < 0) + if ((H5O_refresh_metadata_reopen(oid, &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 */ + connector->nrefs--; + + /* Restore important datatype state */ + if (H5I_get_type(oid) == H5I_DATATYPE) + if (H5T_restore_refresh_state(oid, &cached_H5O_shared) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to restore datatype state") + } /* end if */ done: - if(objs_incr) + if (objs_incr) H5F_decr_nopen_objs(oloc.file); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata() */ - /*------------------------------------------------------------------------- * Function: H5O__refresh_metadata_close * @@ -338,14 +370,14 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) { - haddr_t tag = 0; /* Tag for object */ - hbool_t corked = FALSE; /* Whether object's metadata is corked */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t tag = 0; /* Tag for object */ + hbool_t corked = FALSE; /* Whether object's metadata is corked */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make deep local copy of object's location information */ - if(obj_loc) { + if (obj_loc) { H5G_loc_t tmp_loc; H5G_loc(oid, &tmp_loc); @@ -353,40 +385,39 @@ H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) } /* end if */ /* Handle close for multiple dataset opens */ - if(H5I_get_type(oid) == H5I_DATASET) - if(H5D_mult_refresh_close(oid) < 0) + if (H5I_get_type(oid) == H5I_DATASET) + if (H5D_mult_refresh_close(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset") /* Retrieve tag for object */ - if(H5O__oh_tag(&oloc, &tag) < 0) + if (H5O__oh_tag(&oloc, &tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to get object header address") /* Get cork status of the object with tag */ - if(H5AC_cork(oloc.file, tag, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(oloc.file, tag, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status") /* Close the object */ - if(H5I_dec_ref(oid) < 0) + if (H5I_dec_ref(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to close object") /* Flush metadata based on tag value of the object */ - if(H5F_flush_tagged_metadata(oloc.file, tag) < 0) + if (H5F_flush_tagged_metadata(oloc.file, tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Evict the object's tagged metadata */ - if(H5F_evict_tagged_metadata(oloc.file, tag) < 0) + if (H5F_evict_tagged_metadata(oloc.file, tag) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to evict metadata") /* Re-cork object with tag */ - if(corked) - if(H5AC_cork(oloc.file, tag, H5AC__SET_CORK, &corked) < 0) + if (corked) + if (H5AC_cork(oloc.file, tag, H5AC__SET_CORK, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to cork the object") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O__refresh_metadata_close() */ - /*------------------------------------------------------------------------- * Function: H5O_refresh_metadata_reopen * @@ -402,65 +433,70 @@ 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, hbool_t start_swmr) +H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector, hbool_t start_swmr) { - void *object = NULL; /* Object for this operation */ - H5I_type_t type; /* Type of object for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + void * object = NULL; /* Object for this operation */ + H5I_type_t type; /* Type of object for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(obj_loc); + HDassert(vol_connector); /* Get object's type */ type = H5I_get_type(oid); - switch(type) { + switch (type) { case H5I_GROUP: /* Re-open the group */ - if(NULL == (object = H5G_open(obj_loc))) + if (NULL == (object = H5G_open(obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open group") break; case H5I_DATATYPE: /* Re-open the named datatype */ - if(NULL == (object = H5T_open(obj_loc))) + if (NULL == (object = H5T_open(obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") break; case H5I_DATASET: /* Re-open the dataset */ - if(NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT))) + if (NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT))) 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) + if (!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */ + if (H5D_mult_refresh_reopen((H5D_t *)object) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") break; + case H5I_MAP: + HGOTO_ERROR(H5E_OHDR, 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_REFERENCE: 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_OHDR, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)") - break; + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, + "not a valid file object ID (dataset, group, or datatype)") + break; } /* end switch */ /* Re-register ID for the object */ - if((H5I_register_using_existing_id(type, object, TRUE, oid)) < 0) + if ((H5VL_register_using_existing_id(type, object, vol_connector, TRUE, oid)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata_reopen() */ - diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index 39ec56e9119..b9dc4fea835 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,56 +21,63 @@ * *------------------------------------------------------------------------- */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_fsinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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); +static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O_fsinfo_decode, /* decode message */ - H5O_fsinfo_encode, /* encode message */ - H5O_fsinfo_copy, /* copy the native value */ - H5O_fsinfo_size, /* size of free-space manager info message */ - NULL, /* default reset method */ - H5O__fsinfo_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__fsinfo_debug /* debug the message */ + H5O_FSINFO_ID, /* message id number */ + "fsinfo", /* message name for debugging */ + sizeof(H5O_fsinfo_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__fsinfo_decode, /* decode message */ + H5O__fsinfo_encode, /* encode message */ + H5O__fsinfo_copy, /* copy the native value */ + H5O__fsinfo_size, /* size of free-space manager info message */ + NULL, /* default reset method */ + H5O__fsinfo_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__fsinfo_debug /* debug the message */ }}; +/* Format version bounds for fsinfo message */ +/* This message exists starting library release v1.10 */ +static const unsigned H5O_fsinfo_ver_bounds[] = { + H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ + H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ + H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ + H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ +}; +#define N_FSINFO_VERSION_BOUNDS H5F_LIBVER_NBOUNDS + /* Declare a free list to manage the H5O_fsinfo_t struct */ H5FL_DEFINE_STATIC(H5O_fsinfo_t); - /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_decode + * Function: H5O__fsinfo_decode * * Purpose: Decode a message and return a pointer to a newly allocated one. * @@ -82,60 +89,58 @@ 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) +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) { - 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 */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); HDassert(p); /* Allocate space for message */ - if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) + if (NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; /* Version of message */ vers = *p++; - if(vers == H5O_FSINFO_VERSION_0) { - H5F_file_space_type_t strategy; /* Strategy */ - hsize_t threshold; /* Threshold */ - H5FD_mem_t type; /* Memory type for iteration */ + if (vers == H5O_FSINFO_VERSION_0) { + H5F_file_space_type_t strategy; /* Strategy */ + hsize_t threshold; /* Threshold */ + H5FD_mem_t type; /* Memory type for iteration */ - fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; - fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; - fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; - fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; + fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; + fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; + fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; + fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; fsinfo->eoa_pre_fsm_fsalloc = HADDR_UNDEF; strategy = (H5F_file_space_type_t)*p++; /* File space strategy */ H5F_DECODE_LENGTH(f, p, threshold); /* Free-space section threshold */ /* Map version 0 (deprecated) to version 1 message */ - switch(strategy) { - + switch (strategy) { case H5F_FILE_SPACE_ALL_PERSIST: - fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - fsinfo->persist = TRUE; + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->persist = TRUE; fsinfo->threshold = threshold; - if(HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT)) ) + 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++) - H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type-1])); + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); break; case H5F_FILE_SPACE_ALL: - fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; fsinfo->threshold = threshold; break; @@ -154,25 +159,25 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end switch */ fsinfo->version = H5O_FSINFO_VERSION_1; - fsinfo->mapped = TRUE; - - } else { + fsinfo->mapped = TRUE; + } + else { HDassert(vers >= H5O_FSINFO_VERSION_1); - fsinfo->version = vers; + fsinfo->version = vers; fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ - fsinfo->persist = *p++; /* Free-space persist or not */ + fsinfo->persist = *p++; /* Free-space persist or not */ 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 */ - H5F_addr_decode(f, &p, &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ + H5F_addr_decode(f, &p, + &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ /* Decode addresses of free space managers, if persisting */ - if(fsinfo->persist) { - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + if (fsinfo->persist) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); - } /* end if */ fsinfo->mapped = FALSE; } @@ -181,15 +186,14 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = fsinfo; done: - if(ret_value == NULL && fsinfo != NULL) + if (ret_value == NULL && fsinfo != NULL) fsinfo = H5FL_FREE(H5O_fsinfo_t, fsinfo); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_decode() */ - +} /* end H5O__fsinfo_decode() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_encode + * Function: H5O__fsinfo_encode * * Purpose: Encodes a message. * @@ -200,40 +204,38 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5F_mem_page_t ptype; /* Memory type for iteration */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5F_mem_page_t ptype; /* Memory type for iteration */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); HDassert(p); HDassert(fsinfo); - *p++ = (uint8_t)fsinfo->version; /* message version */ - *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ - *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ + *p++ = (uint8_t)fsinfo->version; /* message version */ + *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ + *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ - H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ - UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ - H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ + H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ + UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ + H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ /* Store addresses of free-space managers, if persisting */ - if(fsinfo->persist) { + if (fsinfo->persist) /* Addresses of free-space managers */ - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); - } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_fsinfo_encode() */ - +} /* end H5O__fsinfo_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_copy + * Function: H5O__fsinfo_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -246,17 +248,17 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c *------------------------------------------------------------------------- */ static void * -H5O_fsinfo_copy(const void *_mesg, void *_dest) +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 */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5O_fsinfo_t * dest = (H5O_fsinfo_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(fsinfo); - if(!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) + if (!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -267,11 +269,10 @@ H5O_fsinfo_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_copy() */ - +} /* end H5O__fsinfo_copy() */ /*------------------------------------------------------------------------- - * Function: H5O_fsinfo_size + * Function: H5O__fsinfo_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -285,26 +286,25 @@ H5O_fsinfo_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__fsinfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - ret_value = 3 /* Version, strategy & persist */ - + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ - + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ - + 2 /* Page end meta threshold */ - + (size_t)H5F_SIZEOF_ADDR(f); + ret_value = 3 /* Version, strategy & persist */ + + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ + + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ + + 2 /* Page end meta threshold */ + + (size_t)H5F_SIZEOF_ADDR(f); /* Free-space manager addresses */ - if(fsinfo->persist) + if (fsinfo->persist) ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_fsinfo_size() */ - +} /* end H5O__fsinfo_size() */ /*------------------------------------------------------------------------- * Function: H5O__fsinfo_free @@ -329,7 +329,6 @@ H5O__fsinfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__fsinfo_debug * @@ -342,11 +341,10 @@ H5O__fsinfo_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *) _mesg; - H5F_mem_page_t ptype; /* Free-space types for iteration */ + const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; + H5F_mem_page_t ptype; /* Free-space types for iteration */ FUNC_ENTER_STATIC_NOERR @@ -358,7 +356,7 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(fwidth >= 0); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "File space strategy:"); - switch(fsinfo->strategy) { + switch (fsinfo->strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: HDfprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; @@ -380,27 +378,97 @@ H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDfprintf(stream, "%s\n", "unknown"); } /* end switch */ - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Free-space persist:", fsinfo->persist); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Free-space persist:", fsinfo->persist ? "TRUE" : "FALSE"); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Free-space section threshold:", fsinfo->threshold); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "File space page size:", fsinfo->page_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Page end metadata threshold:", fsinfo->pgend_meta_thres); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "eoa_pre_fsm_fsalloc:", fsinfo->eoa_pre_fsm_fsalloc); - if(fsinfo->persist) { - for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Free space manager address:", fsinfo->fs_addr[ptype-1]); + if (fsinfo->persist) { + for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Free space manager address:", fsinfo->fs_addr[ptype - 1]); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_debug() */ +/*------------------------------------------------------------------------- + * Function: H5O_fsinfo_set_version + * + * Purpose: Set the version to encode the fsinfo message with. + * + * Return: SUCCEED/FAIL + * + * Programmer: Vailin Choi; June 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) +{ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); + HDassert(fsinfo); + + version = H5O_FSINFO_VERSION_1; + + /* Upgrade to the version indicated by the file's low bound if higher */ + if (H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) + version = MAX(version, H5O_fsinfo_ver_bounds[low]); + + /* Version bounds check */ + if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + + /* Set the message version */ + fsinfo->version = version; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_fsinfo_set_version() */ + +/*------------------------------------------------------------------------- + * Function: H5O_fsinfo_check_version + * + * Purpose: Validate the fsinfo message version + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Summer 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); + HDassert(fsinfo); + + /* Check the version */ + if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_fsinfo_check_version() */ diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index ec34435f8c3..8540cc4817a 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,63 +22,59 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_ginfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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); +static herr_t H5O__ginfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O_ginfo_decode, /*decode message */ - H5O_ginfo_encode, /*encode message */ - H5O_ginfo_copy, /*copy the native value */ - H5O_ginfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__ginfo_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__ginfo_debug /*debug the message */ + H5O_GINFO_ID, /*message id number */ + "ginfo", /*message name for debugging */ + sizeof(H5O_ginfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__ginfo_decode, /*decode message */ + H5O__ginfo_encode, /*encode message */ + H5O__ginfo_copy, /*copy the native value */ + H5O__ginfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__ginfo_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__ginfo_debug /*debug the message */ }}; /* Current version of group info information */ -#define H5O_GINFO_VERSION 0 +#define H5O_GINFO_VERSION 0 /* Flags for group info flag encoding */ -#define H5O_GINFO_STORE_PHASE_CHANGE 0x01 -#define H5O_GINFO_STORE_EST_ENTRY_INFO 0x02 -#define H5O_GINFO_ALL_FLAGS (H5O_GINFO_STORE_PHASE_CHANGE | H5O_GINFO_STORE_EST_ENTRY_INFO) +#define H5O_GINFO_STORE_PHASE_CHANGE 0x01 +#define H5O_GINFO_STORE_EST_ENTRY_INFO 0x02 +#define H5O_GINFO_ALL_FLAGS (H5O_GINFO_STORE_PHASE_CHANGE | H5O_GINFO_STORE_EST_ENTRY_INFO) /* Declare a free list to manage the H5O_ginfo_t struct */ H5FL_DEFINE_STATIC(H5O_ginfo_t); - /*------------------------------------------------------------------------- - * Function: H5O_ginfo_decode + * Function: H5O__ginfo_decode * * Purpose: Decode a message and return a pointer to * a newly allocated one. @@ -93,68 +89,66 @@ H5FL_DEFINE_STATIC(H5O_ginfo_t); *------------------------------------------------------------------------- */ 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_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 */ - unsigned char flags; /* Flags for encoding group info */ - void *ret_value = NULL; /* Return value */ + H5O_ginfo_t * ginfo = NULL; /* Pointer to group information message */ + unsigned char flags; /* Flags for encoding group info */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(p); /* Version of message */ - if(*p++ != H5O_GINFO_VERSION) + if (*p++ != H5O_GINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (ginfo = H5FL_CALLOC(H5O_ginfo_t))) + if (NULL == (ginfo = H5FL_CALLOC(H5O_ginfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the group */ flags = *p++; - if(flags & ~H5O_GINFO_ALL_FLAGS) + if (flags & ~H5O_GINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") ginfo->store_link_phase_change = (flags & H5O_GINFO_STORE_PHASE_CHANGE) ? TRUE : FALSE; - ginfo->store_est_entry_info = (flags & H5O_GINFO_STORE_EST_ENTRY_INFO) ? TRUE : FALSE; + ginfo->store_est_entry_info = (flags & H5O_GINFO_STORE_EST_ENTRY_INFO) ? TRUE : FALSE; /* Get the max. # of links to store compactly & the min. # of links to store densely */ - if(ginfo->store_link_phase_change) { + if (ginfo->store_link_phase_change) { UINT16DECODE(p, ginfo->max_compact) UINT16DECODE(p, ginfo->min_dense) } /* end if */ else { ginfo->max_compact = H5G_CRT_GINFO_MAX_COMPACT; - ginfo->min_dense = H5G_CRT_GINFO_MIN_DENSE; + ginfo->min_dense = H5G_CRT_GINFO_MIN_DENSE; } /* end else */ /* Get the estimated # of entries & name lengths */ - if(ginfo->store_est_entry_info) { + if (ginfo->store_est_entry_info) { UINT16DECODE(p, ginfo->est_num_entries) UINT16DECODE(p, ginfo->est_name_len) } /* end if */ else { ginfo->est_num_entries = H5G_CRT_GINFO_EST_NUM_ENTRIES; - ginfo->est_name_len = H5G_CRT_GINFO_EST_NAME_LEN; + ginfo->est_name_len = H5G_CRT_GINFO_EST_NAME_LEN; } /* end if */ /* Set return value */ ret_value = ginfo; done: - if(ret_value == NULL) - if(ginfo != NULL) + if (ret_value == NULL) + if (ginfo != NULL) ginfo = H5FL_FREE(H5O_ginfo_t, ginfo); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_ginfo_decode() */ +} /* end H5O__ginfo_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_ginfo_encode + * Function: H5O__ginfo_encode * * Purpose: Encodes a message. * @@ -166,12 +160,13 @@ H5O_ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg; - unsigned char flags = 0; /* Flags for encoding group info */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + unsigned char flags = 0; /* Flags for encoding group info */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(p); @@ -181,28 +176,27 @@ H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *p++ = H5O_GINFO_VERSION; /* The flags for the group info */ - flags = (unsigned char)(ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0); - flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); - *p++ = flags; + flags = (unsigned char)(ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0); + flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); + *p++ = flags; /* Store the max. # of links to store compactly & the min. # of links to store densely */ - if(ginfo->store_link_phase_change) { + if (ginfo->store_link_phase_change) { UINT16ENCODE(p, ginfo->max_compact) UINT16ENCODE(p, ginfo->min_dense) } /* end if */ /* Estimated # of entries & name lengths */ - if(ginfo->store_est_entry_info) { + if (ginfo->store_est_entry_info) { UINT16ENCODE(p, ginfo->est_num_entries) UINT16ENCODE(p, ginfo->est_name_len) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_ginfo_encode() */ +} /* end H5O__ginfo_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_ginfo_copy + * Function: H5O__ginfo_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -217,17 +211,17 @@ H5O_ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *------------------------------------------------------------------------- */ static void * -H5O_ginfo_copy(const void *_mesg, void *_dest) +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 */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + H5O_ginfo_t * dest = (H5O_ginfo_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(ginfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_ginfo_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_ginfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -238,11 +232,10 @@ H5O_ginfo_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_ginfo_copy() */ +} /* end H5O__ginfo_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_ginfo_size + * Function: H5O__ginfo_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -258,29 +251,28 @@ H5O_ginfo_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_ginfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__ginfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = 1 + /* Version */ - 1 + /* Flags */ - (ginfo->store_link_phase_change ? ( - (size_t)(2 + /* "Max compact" links */ - 2) /* "Min dense" links */ - ) : 0) + /* "Min dense" links */ - (ginfo->store_est_entry_info ? ( - (size_t)(2 + /* Estimated # of entries in group */ - 2) /* Estimated length of name of entry in group */ - ) : 0); + ret_value = 1 + /* Version */ + 1 + /* Flags */ + (ginfo->store_link_phase_change ? ((size_t)(2 + /* "Max compact" links */ + 2) /* "Min dense" links */ + ) + : 0) + /* "Min dense" links */ + (ginfo->store_est_entry_info ? ((size_t)(2 + /* Estimated # of entries in group */ + 2) /* Estimated length of name of entry in group */ + ) + : 0); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_ginfo_size() */ +} /* end H5O__ginfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__ginfo_free * @@ -296,7 +288,7 @@ H5O_ginfo_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha static herr_t H5O__ginfo_free(void *mesg) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(mesg); @@ -305,7 +297,6 @@ H5O__ginfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ginfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__ginfo_debug * @@ -319,10 +310,9 @@ H5O__ginfo_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *) _mesg; + const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -333,15 +323,12 @@ H5O__ginfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Max. compact links:", ginfo->max_compact); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Min. dense links:", ginfo->min_dense); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Max. compact links:", ginfo->max_compact); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. dense links:", ginfo->min_dense); + "Estimated # of objects in group:", ginfo->est_num_entries); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Estimated # of objects in group:", ginfo->est_num_entries); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Estimated length of object in group's name:", ginfo->est_name_len); + "Estimated length of object in group's name:", ginfo->est_name_len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__ginfo_debug() */ - diff --git a/src/H5Oint.c b/src/H5Oint.c index 187cacf9c55..18b2db05f3a 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,50 +24,48 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 */ - H5O_iterate_t op; /* Application callback */ - void *op_data; /* Application's op data */ - unsigned fields; /* Selection of object info */ + 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 */ + H5O_iterate2_t op; /* Application callback */ + void * op_data; /* Application's op data */ + unsigned fields; /* Selection of object info */ } H5O_iter_visit_ud_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -75,12 +73,10 @@ typedef struct { static herr_t H5O__delete_oh(H5F_t *f, H5O_t *oh); static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type); static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); -static herr_t H5O__free_visit_visited(void *item, void *key, - void *operator_data/*in,out*/); -static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo, - void *_udata); +static herr_t H5O__free_visit_visited(void *item, void *key, void *operator_data /*in,out*/); +static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *_udata); static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); - +static herr_t H5O__reset_info2(H5O_info2_t *oinfo); /*********************/ /* Package Variables */ @@ -95,43 +91,44 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * message. */ const H5O_msg_class_t *const H5O_msg_class_g[] = { - H5O_MSG_NULL, /*0x0000 Null */ - H5O_MSG_SDSPACE, /*0x0001 Dataspace */ - H5O_MSG_LINFO, /*0x0002 Link information */ - H5O_MSG_DTYPE, /*0x0003 Datatype */ - H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ - H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ - H5O_MSG_LINK, /*0x0006 Link */ - H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ - H5O_MSG_LAYOUT, /*0x0008 Data Layout */ + H5O_MSG_NULL, /*0x0000 Null */ + H5O_MSG_SDSPACE, /*0x0001 Dataspace */ + H5O_MSG_LINFO, /*0x0002 Link information */ + H5O_MSG_DTYPE, /*0x0003 Datatype */ + H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ + H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ + H5O_MSG_LINK, /*0x0006 Link */ + H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ + H5O_MSG_LAYOUT, /*0x0008 Data Layout */ #ifdef H5O_ENABLE_BOGUS - H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ -#else /* H5O_ENABLE_BOGUS */ - NULL, /*0x0009 "Bogus valid" (for testing) */ -#endif /* H5O_ENABLE_BOGUS */ - H5O_MSG_GINFO, /*0x000A Group information */ - H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ - H5O_MSG_ATTR, /*0x000C Attribute */ - H5O_MSG_NAME, /*0x000D Object name */ - H5O_MSG_MTIME, /*0x000E Object modification date and time */ - H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ - H5O_MSG_CONT, /*0x0010 Object header continuation */ - H5O_MSG_STAB, /*0x0011 Symbol table */ - H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ - H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ - H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ - H5O_MSG_AINFO, /*0x0015 Attribute information */ - H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ - H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ - H5O_MSG_MDCI, /*0x0018 Metadata cache image */ - H5O_MSG_UNKNOWN /*0x0019 Placeholder for unknown message */ + H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ +#else /* H5O_ENABLE_BOGUS */ + NULL, /*0x0009 "Bogus valid" (for testing) */ +#endif /* H5O_ENABLE_BOGUS */ + H5O_MSG_GINFO, /*0x000A Group information */ + H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ + H5O_MSG_ATTR, /*0x000C Attribute */ + H5O_MSG_NAME, /*0x000D Object name */ + H5O_MSG_MTIME, /*0x000E Object modification date and time */ + H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ + H5O_MSG_CONT, /*0x0010 Object header continuation */ + H5O_MSG_STAB, /*0x0011 Symbol table */ + H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ + H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ + H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ + H5O_MSG_AINFO, /*0x0015 Attribute information */ + H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ + H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ + H5O_MSG_MDCI, /*0x0018 Metadata cache image */ + H5O_MSG_UNKNOWN /*0x0019 Placeholder for unknown message */ }; /* Format version bounds for object header */ const unsigned H5O_obj_ver_bounds[] = { - H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5O_t struct */ @@ -149,6 +146,9 @@ H5FL_BLK_DEFINE(chunk_image); /* Declare external the free list for H5O_cont_t sequences */ H5FL_SEQ_EXTERN(H5O_cont_t); +/* The canonical 'undefined' token */ +const H5O_token_t H5O_TOKEN_UNDEF_g = { + {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}}; /*****************************/ /* Library Private Variables */ @@ -160,7 +160,6 @@ H5FL_EXTERN(time_t); /* Declare external the free list for H5_obj_t's */ H5FL_EXTERN(H5_obj_t); - /*******************/ /* Local Variables */ /*******************/ @@ -172,12 +171,11 @@ H5FL_EXTERN(H5_obj_t); * datatype message is a datatype but only some of them are datasets. */ static const H5O_obj_class_t *const H5O_obj_class_g[] = { - H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ - H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ - H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ + H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ + H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ + H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ }; - /*------------------------------------------------------------------------- * Function: H5O__init_package * @@ -204,9 +202,8 @@ H5O__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__init_package() */ - /*------------------------------------------------------------------------- - * Function: H5O_set_version + * Function: H5O__set_version * * Purpose: Sets the correct version to encode the object header. * Chooses the oldest version possible, unless the file's @@ -220,19 +217,19 @@ H5O__init_package(void) *------------------------------------------------------------------------- */ static herr_t -H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx) +H5O__set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx) { - uint8_t version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); HDassert(oh); /* Set the correct version to encode object header with */ - if(store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + if (store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) version = H5O_VERSION_LATEST; else version = H5O_VERSION_1; @@ -241,7 +238,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx version = (uint8_t)MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "object header version out of bounds") /* Set the message version */ @@ -249,8 +246,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_set_version() */ - +} /* end H5O__set_version() */ /*------------------------------------------------------------------------- * Function: H5O_create @@ -272,17 +268,10 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx *------------------------------------------------------------------------- */ herr_t -H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, - H5O_loc_t *loc/*out*/) +H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc /*out*/) { - H5P_genplist_t *oc_plist; /* Object creation property list */ - H5O_t *oh = NULL; /* Object header created */ - herr_t ret_value = SUCCEED; /* return value */ - haddr_t oh_addr; /* Address of initial object header */ - size_t oh_size; /* Size of initial object header */ - uint8_t oh_flags; /* Object header's initial status flags */ - unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting objec t header into cache */ - hbool_t store_msg_crt_idx; /* Whether to always store message crea tion indices for this file */ + H5O_t *oh = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -293,25 +282,24 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, /* create object header in freelist * header version is set internally */ - oh = H5O__create_ohdr(f, ocpl_id); - if(NULL == oh) + oh = H5O_create_ohdr(f, ocpl_id); + if (NULL == oh) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't instantiate object header") /* apply object header information to file */ - if(H5O__apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) + if (H5O_apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't apply object header to file") done: - if((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_create() */ - /*----------------------------------------------------------------------------- - * Function: H5O__create_ohdr + * Function: H5O_create_ohdr * * Purpose: Create the object header, set version and flags. * @@ -324,12 +312,12 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, *----------------------------------------------------------------------------- */ H5O_t * -H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) +H5O_create_ohdr(H5F_t *f, hid_t ocpl_id) { H5P_genplist_t *oc_plist; - H5O_t *oh = NULL; /* Object header in Freelist */ - uint8_t oh_flags; /* Initial status flags */ - H5O_t *ret_value = NULL; + H5O_t * oh = NULL; /* Object header in Freelist */ + uint8_t oh_flags; /* Initial status flags */ + H5O_t * ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -337,30 +325,30 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") oh = H5FL_CALLOC(H5O_t); - if(NULL == oh) + if (NULL == oh) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); - if(NULL == oc_plist) + if (NULL == oc_plist) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list") /* Get any object header status flags set by properties */ - if(H5P_DATASET_CREATE_DEFAULT == ocpl_id) { + if (H5P_DATASET_CREATE_DEFAULT == ocpl_id) { /* If the OCPL is the default DCPL, we can get the header flags from the * API context. Otherwise we have to call H5P_get */ - if(H5CX_get_ohdr_flags(&oh_flags) < 0) + if (H5CX_get_ohdr_flags(&oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") } else { - if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + if (H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") } - if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) + if (H5O__set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header") oh->flags = oh_flags; @@ -368,15 +356,14 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) ret_value = oh; done: - if((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__create_ohdr() */ - +} /* H5O_create_ohdr() */ /*----------------------------------------------------------------------------- - * Function: H5O__apply_ohdr + * Function: H5O_apply_ohdr * * Purpose: Initialize and set the object header in the file. * Record some information at `loc_out`. @@ -390,7 +377,7 @@ H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) *----------------------------------------------------------------------------- */ 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) +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) { haddr_t oh_addr; size_t oh_size; @@ -410,109 +397,123 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); - oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* strange casting for proper type */ + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* funky cast */ + #ifdef H5O_ENABLE_BAD_MESG_COUNT /* Check whether the "bad message count" property is set */ - if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) - /* Get bad message count flag from property list */ - if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) + if (0 < H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME)) + /* Get bad message count flag -- from property list */ + if (H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Create object header proxy if doing SWMR writes */ - if(oh->swmr_write) { - /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + if (oh->swmr_write) { + oh->proxy = H5AC_proxy_entry_create(); + if (NULL == oh->proxy) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") - } else { + } + else { oh->proxy = NULL; } oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); - if(NULL == oc_plist) + if (NULL == oc_plist) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") /* Initialize version-specific fields */ - if(oh->version > H5O_VERSION_1) { - /* Initialize all time fields with current time, if we are storing them */ - if(oh->flags & H5O_HDR_STORE_TIMES) + if (oh->version > H5O_VERSION_1) { + /* Initialize all time fields */ + if (oh->flags & H5O_HDR_STORE_TIMES) oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); else oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - if(H5F_STORE_MSG_CRT_IDX(f)) /* flag to record message creation indices */ + if (H5F_STORE_MSG_CRT_IDX(f)) + /* flag to record message creation indices */ oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; - /* Retrieve attribute storage phase change values from property list */ - if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + /* Get attribute storage phase change values -- from property list */ + if (H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") - if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + if (H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") /* Check for non-default attribute storage phase change values */ - if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF) + if (H5O_CRT_ATTR_MAX_COMPACT_DEF != oh->max_compact || H5O_CRT_ATTR_MIN_DENSE_DEF != oh->min_dense) oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; - /* Determine correct value for chunk #0 size bits */ + /* Determine correct value for chunk #0 size bits */ /* Avoid compiler warning on 32-bit machines */ #if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T - if(size_hint > 4294967295UL) + if (size_hint > 4294967295UL) oh->flags |= H5O_HDR_CHUNK0_8; - else -#endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ - if(size_hint > 65535) + else if (size_hint > 65535) + oh->flags |= H5O_HDR_CHUNK0_4; + else if (size_hint > 255) + oh->flags |= H5O_HDR_CHUNK0_2; +#else + if (size_hint > 65535) oh->flags |= H5O_HDR_CHUNK0_4; - else if(size_hint > 255) + else if (size_hint > 255) oh->flags |= H5O_HDR_CHUNK0_2; - } else { +#endif + } + else { /* Reset unused time fields */ oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - } /* end if/else header version > 1 */ + } /* end if/else header version >1 */ /* Compute total size of initial object header */ /* (i.e. object header prefix and first chunk) */ oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; /* Allocate disk space for header and first chunk */ - if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size))) + oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size); + if (HADDR_UNDEF == oh_addr) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") /* Create the chunk list */ - oh->nchunks = oh->alloc_nchunks = 1; - if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) + oh->nchunks = 1; + oh->alloc_nchunks = 1; + oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks); + if (NULL == oh->chunk) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the first chunk */ oh->chunk[0].addr = oh_addr; oh->chunk[0].size = oh_size; - oh->chunk[0].gap = 0; + oh->chunk[0].gap = 0; /* Allocate enough space for the first chunk */ /* (including space for serializing the object header prefix */ - if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size))) + oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size); + if (NULL == oh->chunk[0].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") oh->chunk[0].chunk_proxy = NULL; /* Put magic # for object header in first chunk */ - if(oh->version > H5O_VERSION_1) + if (H5O_VERSION_1 < oh->version) H5MM_memcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); /* Create the message list */ - oh->nmesgs = 1; + oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) + oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs); + if (NULL == oh->mesg) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Initialize the initial "null" message, covering the entire first chunk */ - oh->mesg[0].type = H5O_MSG_NULL; - oh->mesg[0].dirty = TRUE; + /* Initialize the initial "null" message; covers the entire first chunk */ + oh->mesg[0].type = H5O_MSG_NULL; + oh->mesg[0].dirty = TRUE; oh->mesg[0].native = NULL; - oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].raw = + oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[0].chunkno = 0; + oh->mesg[0].chunkno = 0; /* Check for non-zero initial refcount on the object header */ - if(initial_rc > 0) { + if (initial_rc > 0) { /* Set the initial refcount & pin the header when its inserted */ oh->rc = initial_rc; insert_flags |= H5AC__PIN_ENTRY_FLAG; @@ -522,7 +523,7 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini H5_BEGIN_TAG(oh_addr); /* Cache object header */ - if(H5AC_insert_entry(f, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) + if (H5AC_insert_entry(f, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") /* Reset object header pointer, now that it's been inserted into the cache */ @@ -535,13 +536,12 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini loc_out->file = f; loc_out->addr = oh_addr; - if(H5O_open(loc_out) < 0) + if (H5O_open(loc_out) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") done: FUNC_LEAVE_NOAPI(ret_value); -} /* end H5O__apply_ohdr() */ - +} /* H5O_apply_ohdr() */ /*------------------------------------------------------------------------- * Function: H5O_open @@ -564,7 +564,7 @@ H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t ini herr_t H5O_open(H5O_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -573,12 +573,12 @@ H5O_open(H5O_loc_t *loc) HDassert(loc->file); #ifdef H5O_DEBUG - if(H5DEBUG(O)) - HDfprintf(H5DEBUG(O), "> %a\n", loc->addr); + if (H5DEBUG(O)) + HDfprintf(H5DEBUG(O), "> %" PRIuHADDR "\n", loc->addr); #endif /* Turn off the variable for holding file or increment open-lock counters */ - if(loc->holding_file) + if (loc->holding_file) loc->holding_file = FALSE; else H5F_INCR_NOPEN_OBJS(loc->file); @@ -587,30 +587,29 @@ H5O_open(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open() */ - /*------------------------------------------------------------------------- * Function: H5O_open_name * - * Purpose: Opens an object within an HDF5 file. + * Purpose: Opens an object by name * - * Return: Success: An open object identifier - * Failure: Negative + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * March 5 2007 * *------------------------------------------------------------------------- */ -hid_t -H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref) +void * +H5O_open_name(const H5G_loc_t *loc, const char *name, 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = H5I_INVALID_HID; + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI(NULL) /* Check args */ HDassert(loc); @@ -622,45 +621,44 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref) H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(loc, name, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5I_INVALID_HID, "object not found") + if (H5G_loc_find(loc, name, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") + if (NULL == ret_value) + if (loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_name() */ - /*------------------------------------------------------------------------- * Function: H5O__open_by_idx * * Purpose: Internal routine to open an object by index within group * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * December 28, 2017 * *------------------------------------------------------------------------- */ -hid_t -H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) +void * +H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -673,44 +671,43 @@ H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, name, idx_type, order, n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5I_INVALID_HID, "group not found") + if (H5G_loc_find_by_idx(loc, name, idx_type, order, n, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "group not found") loc_found = TRUE; /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: /* Release the object location if we failed after copying it */ - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") + if (NULL == ret_value) + if (loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__open_by_idx() */ - /*------------------------------------------------------------------------- * Function: H5O__open_by_addr * * Purpose: Internal routine to open an object by its address * - * Return: Success: Valid object identifier - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * December 28, 2017 * *------------------------------------------------------------------------- */ -hid_t -H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr) +void * +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 */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -723,53 +720,51 @@ H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr) H5G_loc_reset(&obj_loc); obj_loc.oloc->addr = addr; obj_loc.oloc->file = loc->oloc->file; - H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if (NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__open_by_addr() */ - /*------------------------------------------------------------------------- - * Function: H5O__open_by_loc + * Function: H5O_open_by_loc * - * Purpose: Opens an object and returns an ID given its group loction. + * Purpose: Opens an object * - * Return: Success: Open object identifier - * Failure: Negative + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: James Laird * July 25 2006 * *------------------------------------------------------------------------- */ -hid_t -H5O__open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) +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 */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for location */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(NULL) HDassert(obj_loc); /* Get the object class for this location */ - if(NULL == (obj_class = H5O__obj_class(obj_loc->oloc))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "unable to determine object class") + if (NULL == (obj_class = H5O__obj_class(obj_loc->oloc))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object class") /* Call the object class's 'open' routine */ HDassert(obj_class->open); - if((ret_value = obj_class->open(obj_loc, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if (NULL == (ret_value = obj_class->open(obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__open_by_loc() */ - +} /* end H5O_open_by_loc() */ /*------------------------------------------------------------------------- * Function: H5O_close @@ -786,7 +781,7 @@ H5O__open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -801,18 +796,19 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) * It's needed by the evict-on-close code. Clients can ignore * this value by passing in NULL. */ - if(file_closed) + if (file_closed) *file_closed = FALSE; /* Decrement open-lock counters */ H5F_DECR_NOPEN_OBJS(loc->file); #ifdef H5O_DEBUG - if(H5DEBUG(O)) { - if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) - HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); + if (H5DEBUG(O)) { + if (FALSE == H5F_ID_EXISTS(loc->file) && 1 == H5F_NREFS(loc->file)) + HDfprintf(H5DEBUG(O), "< %" PRIuHADDR " auto %lu remaining\n", loc->addr, + (unsigned long)H5F_NOPEN_OBJS(loc->file)); else - HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); + HDfprintf(H5DEBUG(O), "< %" PRIuHADDR "\n", loc->addr); } #endif @@ -820,20 +816,19 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) * If the file open object count has reached the number of open mount points * (each of which has a group open in the file) attempt to close the file. */ - if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) + if (H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) /* Attempt to close down the file hierarchy */ - if(H5F_try_close(loc->file, file_closed) < 0) + if (H5F_try_close(loc->file, file_closed) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") /* Release location information */ - if(H5O_loc_free(loc) < 0) + if (H5O_loc_free(loc) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_close() */ - /*------------------------------------------------------------------------- * Function: H5O__link_oh * @@ -852,8 +847,8 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) { - haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ - int ret_value = -1; /* Return value */ + haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ + int ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -863,59 +858,59 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) HDassert(deleted); /* Check for adjusting link count */ - if(adjust) { - if(adjust < 0) { + if (adjust) { + if (adjust < 0) { /* Check for too large of an adjustment */ - if((unsigned)(-adjust) > oh->nlink) + if ((unsigned)(-adjust) > oh->nlink) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, (-1), "link count would be negative") /* Adjust the link count for the object header */ oh->nlink = (unsigned)((int)oh->nlink + adjust); /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") /* Check if the object should be deleted */ - if(oh->nlink == 0) { + if (oh->nlink == 0) { /* Check if the object is still open by the user */ - if(H5FO_opened(f, addr) != NULL) { + if (H5FO_opened(f, addr) != NULL) { /* Flag the object to be deleted when it's closed */ - if(H5FO_mark(f, addr, TRUE) < 0) + if (H5FO_mark(f, addr, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ else { /* Mark the object header for deletion */ *deleted = TRUE; } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* A new object, or one that will be deleted */ - if(0 == oh->nlink) { + if (0 == oh->nlink) { /* Check if the object is currently open, but marked for deletion */ - if(H5FO_marked(f, addr)) { + if (H5FO_marked(f, addr)) { /* Remove "delete me" flag on the object */ - if(H5FO_mark(f, addr, FALSE) < 0) + if (H5FO_mark(f, addr, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ - } /* end if */ + } /* end if */ /* Adjust the link count for the object header */ oh->nlink = (unsigned)((int)oh->nlink + adjust); /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") } /* end if */ /* Check for operations on refcount message */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check if the object has a refcount message already */ - if(oh->has_refcount_msg) { + if (oh->has_refcount_msg) { /* Check for removing refcount message */ - if(oh->nlink <= 1) { - if(H5O__msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE) < 0) + if (oh->nlink <= 1) { + if (H5O__msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "unable to delete refcount message") oh->has_refcount_msg = FALSE; } /* end if */ @@ -923,22 +918,24 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) else { H5O_refcount_t refcount = oh->nlink; - if(H5O__msg_write_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + if (H5O__msg_write_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, (-1), "unable to update refcount message") } /* end else */ - } /* end if */ + } /* end if */ else { /* Check for adding refcount message to object */ - if(oh->nlink > 1) { + if (oh->nlink > 1) { H5O_refcount_t refcount = oh->nlink; - if(H5O__msg_append_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + if (H5O__msg_append_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < + 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, (-1), "unable to create new refcount message") oh->has_refcount_msg = TRUE; } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ /* Set return value */ ret_value = (int)oh->nlink; @@ -947,7 +944,6 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_link * @@ -966,9 +962,9 @@ 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; - hbool_t deleted = FALSE; /* Whether the object was deleted */ - int ret_value = -1; /* Return value */ + H5O_t * oh = NULL; + hbool_t deleted = FALSE; /* Whether the object was deleted */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -978,23 +974,22 @@ H5O_link(const H5O_loc_t *loc, int adjust) HDassert(H5F_addr_defined(loc->addr)); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" link routine */ - if((ret_value = H5O__link_oh(loc->file, adjust, oh, &deleted)) < 0) + if ((ret_value = H5O__link_oh(loc->file, adjust, oh, &deleted)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - if(ret_value >= 0 && deleted && H5O_delete(loc->file, loc->addr) < 0) + if (ret_value >= 0 && deleted && H5O_delete(loc->file, loc->addr) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_link() */ - /*------------------------------------------------------------------------- * Function: H5O_protect * @@ -1014,11 +1009,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_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 * 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 */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -1030,35 +1025,35 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Check for valid address */ - if(!H5F_addr_defined(loc->addr)) + if (!H5F_addr_defined(loc->addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined") /* Check for write access on the file */ file_intent = H5F_INTENT(loc->file); - if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) + if ((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") /* Construct the user data for protect callback */ - udata.made_attempt = FALSE; - udata.v1_pfx_nmesgs = 0; - udata.chunk0_size = 0; - udata.oh = NULL; - udata.free_oh = FALSE; - udata.common.f = loc->file; - udata.common.file_intent = file_intent; + udata.made_attempt = FALSE; + udata.v1_pfx_nmesgs = 0; + udata.chunk0_size = 0; + udata.oh = NULL; + udata.free_oh = FALSE; + udata.common.f = loc->file; + udata.common.file_intent = file_intent; udata.common.merged_null_msgs = 0; HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info)); udata.common.cont_msg_info = &cont_msg_info; - udata.common.addr = loc->addr; + udata.common.addr = loc->addr; /* Lock the object header into the cache */ - if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, H5AC_OHDR, loc->addr, &udata, prot_flags))) + if (NULL == (oh = (H5O_t *)H5AC_protect(loc->file, H5AC_OHDR, loc->addr, &udata, prot_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Check if there are any continuation messages to process */ - if(cont_msg_info.nmsgs > 0) { - size_t curr_msg; /* Current continuation message to process */ - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + if (cont_msg_info.nmsgs > 0) { + size_t curr_msg; /* Current continuation message to process */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ /* Sanity check - we should only have continuation messages to process * when the object header is actually loaded from the file. @@ -1067,30 +1062,32 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert(cont_msg_info.msgs); /* Construct the user data for protecting chunks */ - chk_udata.decoding = TRUE; - chk_udata.oh = oh; - chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ - chk_udata.common.f = loc->file; - chk_udata.common.file_intent = file_intent; + chk_udata.decoding = TRUE; + chk_udata.oh = oh; + chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ + chk_udata.common.f = loc->file; + chk_udata.common.file_intent = file_intent; chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs; - chk_udata.common.cont_msg_info = &cont_msg_info; + chk_udata.common.cont_msg_info = &cont_msg_info; /* Read in continuation messages, until there are no more */ /* (Note that loading chunks could increase the # of continuation * messages if new ones are found - QAK, 19/11/2016) */ curr_msg = 0; - while(curr_msg < cont_msg_info.nmsgs) { - H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ + while (curr_msg < cont_msg_info.nmsgs) { + H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ #ifndef NDEBUG - size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ -#endif /* NDEBUG */ + size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ +#endif /* NDEBUG */ /* Bring the chunk into the cache */ /* (which adds to the object header) */ chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr; - chk_udata.size = cont_msg_info.msgs[curr_msg].size; - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags))) + chk_udata.size = cont_msg_info.msgs[curr_msg].size; + if (NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, H5AC_OHDR_CHK, + cont_msg_info.msgs[curr_msg].addr, + &chk_udata, prot_flags))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") /* Sanity check */ @@ -1099,7 +1096,8 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) HDassert(oh->nchunks == (chkcnt + 1)); /* Release the chunk from the cache */ - if(H5AC_unprotect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_unprotect(loc->file, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk") /* Advance to next continuation message */ @@ -1116,7 +1114,7 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) /* Check for incorrect # of object header messages, if we've just loaded * this object header from the file */ - if(udata.made_attempt) { + if (udata.made_attempt) { /* Don't enforce the error on an incorrect # of object header messages bug * unless strict format checking is enabled. This allows for older * files, created with a version of the library that had a bug in tracking @@ -1125,39 +1123,39 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) */ #ifdef H5_STRICT_FORMAT_CHECKS /* Check for incorrect # of messages in v1 object header */ - if(oh->version == H5O_VERSION_1 && - (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) + if (oh->version == H5O_VERSION_1 && + (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages") #endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ + } /* end if */ #ifdef H5O_DEBUG -H5O_assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ /* Pin the other chunks also when requested, so that the object header * proxy can be set up. */ - if(pin_all_chunks && oh->nchunks > 1) { - unsigned u; /* Local index variable */ + if (pin_all_chunks && oh->nchunks > 1) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(oh->swmr_write); /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ + for (u = 1; u < oh->nchunks; u++) { + H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(loc->file, oh, u))) + if (NULL == (chk_proxy = H5O__chunk_protect(loc->file, oh, u))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk") /* Pin chunk proxy*/ - if(H5AC_pin_protected_entry(chk_proxy) < 0 ) + if (H5AC_pin_protected_entry(chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk") /* Unprotect chunk */ - if(H5O__chunk_unprotect(loc->file, chk_proxy, FALSE) < 0) + if (H5O__chunk_unprotect(loc->file, chk_proxy, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk") /* Preserve chunk proxy pointer for later */ @@ -1172,14 +1170,13 @@ H5O_assert(oh); ret_value = oh; done: - if(ret_value == NULL && oh) - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (ret_value == NULL && oh) + 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() */ - /*------------------------------------------------------------------------- * Function: H5O_pin * @@ -1199,8 +1196,8 @@ H5O_assert(oh); H5O_t * H5O_pin(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header */ - H5O_t *ret_value = NULL; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1208,12 +1205,12 @@ H5O_pin(const H5O_loc_t *loc) HDassert(loc); /* Get header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") /* Increment the reference count on the object header */ /* (which will pin it, if appropriate) */ - if(H5O__inc_rc(oh) < 0) + if (H5O__inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header") /* Set the return value */ @@ -1221,13 +1218,12 @@ H5O_pin(const H5O_loc_t *loc) done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pin() */ - /*------------------------------------------------------------------------- * Function: H5O_unpin * @@ -1245,7 +1241,7 @@ H5O_pin(const H5O_loc_t *loc) herr_t H5O_unpin(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1254,14 +1250,13 @@ H5O_unpin(H5O_t *oh) /* Decrement the reference count on the object header */ /* (which will unpin it, if appropriate) */ - if(H5O__dec_rc(oh) < 0) + if (H5O__dec_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_unpin() */ - /*------------------------------------------------------------------------- * Function: H5O_unprotect * @@ -1280,7 +1275,7 @@ H5O_unpin(H5O_t *oh) herr_t H5O_unprotect(const H5O_loc_t *loc, H5O_t *oh, unsigned oh_flags) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1289,35 +1284,34 @@ H5O_unprotect(const H5O_loc_t *loc, H5O_t *oh, unsigned oh_flags) HDassert(oh); /* Unpin the other chunks */ - if(oh->chunks_pinned && oh->nchunks > 1) { - unsigned u; /* Local index variable */ + if (oh->chunks_pinned && oh->nchunks > 1) { + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(oh->swmr_write); /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - if(NULL != oh->chunk[u].chunk_proxy) { + for (u = 1; u < oh->nchunks; u++) { + if (NULL != oh->chunk[u].chunk_proxy) { /* Release chunk proxy */ - if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) + if (H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk") oh->chunk[u].chunk_proxy = NULL; } /* end if */ - } /* end for */ + } /* end for */ /* Reet the flag from the unprotect */ oh->chunks_pinned = FALSE; } /* end if */ /* Unprotect the object header */ - if(H5AC_unprotect(loc->file, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) + if (H5AC_unprotect(loc->file, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_unprotect() */ - /*------------------------------------------------------------------------- * Function: H5O_touch_oh * @@ -1335,10 +1329,10 @@ H5O_unprotect(const H5O_loc_t *loc, H5O_t *oh, unsigned oh_flags) herr_t H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) { - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - time_t now; /* Current time */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + time_t now; /* Current time */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1346,43 +1340,45 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) HDassert(oh); /* Check if this object header is tracking times */ - if(oh->flags & H5O_HDR_STORE_TIMES) { + if (oh->flags & H5O_HDR_STORE_TIMES) { /* Get current time */ now = H5_now(); /* Check version, to determine how to store time information */ - if(oh->version == H5O_VERSION_1) { - size_t idx; /* Index of modification time message to update */ + if (oh->version == H5O_VERSION_1) { + size_t idx; /* Index of modification time message to update */ /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) break; /* Create a new message, if necessary */ - if(idx == oh->nmesgs) { - unsigned mesg_flags = 0; /* Flags for message in object header */ + if (idx == oh->nmesgs) { + unsigned mesg_flags = 0; /* Flags for message in object header */ /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ - if(!force) - HGOTO_DONE(SUCCEED); /*nothing to do*/ + if (!force) + HGOTO_DONE(SUCCEED); /*nothing to do*/ /* Allocate space for the modification time message */ - if(H5O__msg_alloc(f, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") + if (H5O__msg_alloc(f, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "unable to allocate space for modification time message") /* Set the message's flags if appropriate */ oh->mesg[idx].flags = (uint8_t)mesg_flags; } /* end if */ /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[idx].chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[idx].chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") /* Allocate 'native' space, if necessary */ - if(NULL == oh->mesg[idx].native) { - if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message") + if (NULL == oh->mesg[idx].native) { + if (NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "memory allocation failed for modification time message") } /* end if */ /* Update the message */ @@ -1390,7 +1386,7 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) /* Mark the message as dirty */ oh->mesg[idx].dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; } /* end if */ else { /* XXX: For now, update access time & change fields in the object header @@ -1399,20 +1395,19 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) oh->atime = oh->ctime = now; /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else */ - } /* end if */ + } /* end if */ done: /* Release chunk */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_touch_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_touch * @@ -1431,9 +1426,9 @@ 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 */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -1441,18 +1436,18 @@ H5O_touch(const H5O_loc_t *loc, hbool_t force) HDassert(loc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Create/Update the modification time message */ - if(H5O_touch_oh(loc->file, oh, force) < 0) + if (H5O_touch_oh(loc->file, oh, force) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time") /* Mark object header as changed */ oh_flags |= H5AC__DIRTIED_FLAG; done: - if(oh && H5O_unprotect(loc, oh, oh_flags) < 0) + if (oh && H5O_unprotect(loc, oh, oh_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) @@ -1475,9 +1470,9 @@ H5O_touch(const H5O_loc_t *loc, hbool_t force) herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) { - size_t idx; /* Local index variable */ - H5O_msg_class_t *type; /* Message class type */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Local index variable */ + H5O_msg_class_t *type; /* Message class type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1485,40 +1480,40 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) HDassert(oh); /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) break; /* Create a new message */ - if(idx == oh->nmesgs) { - H5O_bogus_t *bogus; /* Pointer to the bogus information */ + if (idx == oh->nmesgs) { + H5O_bogus_t *bogus; /* Pointer to the bogus information */ /* Allocate the native message in memory */ - if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") + if (NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") /* Update the native value */ bogus->u = H5O_BOGUS_VALUE; - if(bogus_id == H5O_BOGUS_VALID_ID) - type = H5O_MSG_BOGUS_VALID; - else if(bogus_id == H5O_BOGUS_INVALID_ID) - type = H5O_MSG_BOGUS_INVALID; - else - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") + if (bogus_id == H5O_BOGUS_VALID_ID) + type = H5O_MSG_BOGUS_VALID; + else if (bogus_id == H5O_BOGUS_INVALID_ID) + type = H5O_MSG_BOGUS_INVALID; + else + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") /* Allocate space in the object header for bogus message */ - if(H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") + if (H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ - oh->mesg[idx].native = bogus; + oh->mesg[idx].native = bogus; /* Set the appropriate flags for the message */ oh->mesg[idx].flags = mesg_flags; /* Mark the message and object header as dirty */ - oh->mesg[idx].dirty = TRUE; + oh->mesg[idx].dirty = TRUE; oh->cache_info.is_dirty = TRUE; } /* end if */ @@ -1527,7 +1522,6 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) } /* end H5O_bogus_oh() */ #endif /* H5O_ENABLE_BOGUS */ - /*------------------------------------------------------------------------- * Function: H5O_delete * @@ -1546,11 +1540,11 @@ 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_loc_t loc; /* Object location for object to delete */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - hbool_t corked; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(addr, FAIL) @@ -1559,36 +1553,35 @@ H5O_delete(H5F_t *f, haddr_t addr) HDassert(H5F_addr_defined(addr)); /* Set up the object location */ - loc.file = f; - loc.addr = addr; + loc.file = f; + loc.addr = addr; loc.holding_file = FALSE; /* Get the object header information */ - if(NULL == (oh = H5O_protect(&loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(&loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Delete object */ - if(H5O__delete_oh(f, oh) < 0) + if (H5O__delete_oh(f, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") /* Uncork cache entries with tag: addr */ - if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Mark object header as deleted */ oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; done: - if(oh && H5O_unprotect(&loc, oh, oh_flags) < 0) + if (oh && H5O_unprotect(&loc, oh, oh_flags) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__delete_oh * @@ -1608,9 +1601,9 @@ H5O_delete(H5F_t *f, haddr_t addr) static herr_t H5O__delete_oh(H5F_t *f, H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1621,17 +1614,17 @@ H5O__delete_oh(H5F_t *f, H5O_t *oh) /* Walk through the list of object header messages, asking each one to * delete any file space used */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { /* Free any space referred to in the file from this message */ - if(H5O__delete_mesg(f, oh, curr_msg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if (H5O__delete_mesg(f, oh, curr_msg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__delete_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_obj_type * @@ -1648,27 +1641,26 @@ H5O__delete_oh(H5F_t *f, H5O_t *oh) herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type) { - H5O_t *oh = NULL; /* Object header for location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header for location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve the type of the object */ - if(H5O__obj_type_real(oh, obj_type) < 0) + if (H5O__obj_type_real(oh, obj_type) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_obj_type() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_type_real * @@ -1685,7 +1677,7 @@ H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type) static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) { - const H5O_obj_class_t *obj_class; /* Class of object for header */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ FUNC_ENTER_STATIC_NOERR @@ -1694,7 +1686,7 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) HDassert(obj_type); /* Look up class for object header */ - if(NULL == (obj_class = H5O__obj_class_real(oh))) { + if (NULL == (obj_class = H5O__obj_class_real(oh))) { /* Clear error stack from "failed" class lookup */ H5E_clear_stack(NULL); @@ -1708,7 +1700,6 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__obj_type_real() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_class * @@ -1725,27 +1716,26 @@ 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 */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ + H5O_t * oh = NULL; /* Object header for location */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Test whether entry qualifies as a particular type of object */ - if(NULL == (ret_value = H5O__obj_class_real(oh))) + if (NULL == (ret_value = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && 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__obj_class() */ - /*------------------------------------------------------------------------- * Function: H5O__obj_class_real * @@ -1762,8 +1752,8 @@ H5O__obj_class(const H5O_loc_t *loc) static const H5O_obj_class_t * H5O__obj_class_real(const H5O_t *oh) { - size_t i; /* Local index variable */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ + size_t i; /* Local index variable */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1772,23 +1762,22 @@ H5O__obj_class_real(const H5O_t *oh) /* Test whether entry qualifies as a particular type of object */ /* (Note: loop is in reverse order, to test specific objects first) */ - for(i = NELMTS(H5O_obj_class_g); i > 0; --i) { - htri_t isa; /* Is entry a particular type? */ + for (i = NELMTS(H5O_obj_class_g); i > 0; --i) { + htri_t isa; /* Is entry a particular type? */ - if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) + if ((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") - else if(isa) + else if (isa) HGOTO_DONE(H5O_obj_class_g[i - 1]) } - if(0 == i) + if (0 == i) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__obj_class_real() */ - /*------------------------------------------------------------------------- * Function: H5O_get_loc * @@ -1805,38 +1794,42 @@ H5O__obj_class_real(const H5O_t *oh) H5O_loc_t * H5O_get_loc(hid_t object_id) { - H5O_loc_t *ret_value = NULL; /* Return value */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - switch(H5I_get_type(object_id)) { + switch (H5I_get_type(object_id)) { case H5I_GROUP: - if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID") break; case H5I_DATASET: - if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID") break; case H5I_DATATYPE: - if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) + if (NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID") break; + case H5I_MAP: + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "maps not supported in native VOL connector") + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: 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_OHDR, H5E_BADTYPE, NULL, "invalid object type") @@ -1846,7 +1839,6 @@ H5O_get_loc(hid_t object_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_loc() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_reset * @@ -1875,7 +1867,6 @@ H5O_loc_reset(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_reset() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy * @@ -1900,7 +1891,7 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); /* Invoke correct routine */ - if(depth == H5_COPY_SHALLOW) + if (depth == H5_COPY_SHALLOW) H5O_loc_copy_shallow(dst, src); else H5O_loc_copy_deep(dst, src); @@ -1908,7 +1899,6 @@ H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy_shallow * @@ -1943,7 +1933,6 @@ H5O_loc_copy_shallow(H5O_loc_t *dst, H5O_loc_t *src) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy_shallow() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_copy_deep * @@ -1974,13 +1963,12 @@ H5O_loc_copy_deep(H5O_loc_t *dst, const H5O_loc_t *src) /* If the original entry was holding open the file, this one should * hold it open, too. */ - if(src->holding_file) + if (src->holding_file) H5F_INCR_NOPEN_OBJS(dst->file); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_copy_deep() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_hold_file * @@ -2005,7 +1993,7 @@ H5O_loc_hold_file(H5O_loc_t *loc) HDassert(loc->file); /* If this location is not already holding its file open, do so. */ - if(!loc->holding_file) { + if (!loc->holding_file) { H5F_INCR_NOPEN_OBJS(loc->file); loc->holding_file = TRUE; } @@ -2013,7 +2001,6 @@ H5O_loc_hold_file(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_loc_hold_file() */ - /*------------------------------------------------------------------------- * Function: H5O_loc_free * @@ -2040,11 +2027,11 @@ H5O_loc_free(H5O_loc_t *loc) HDassert(loc); /* If this location is holding its file open try to close the file. */ - if(loc->holding_file) { + if (loc->holding_file) { H5F_DECR_NOPEN_OBJS(loc->file); loc->holding_file = FALSE; - if(H5F_NOPEN_OBJS(loc->file) <= 0) { - if(H5F_try_close(loc->file, NULL) < 0) + if (H5F_NOPEN_OBJS(loc->file) <= 0) { + if (H5F_try_close(loc->file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") } } @@ -2053,7 +2040,6 @@ H5O_loc_free(H5O_loc_t *loc) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_loc_free() */ - /*------------------------------------------------------------------------- * Function: H5O_get_hdr_info * @@ -2070,8 +2056,8 @@ H5O_loc_free(H5O_loc_t *loc) herr_t H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2083,21 +2069,20 @@ H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) HDmemset(hdr, 0, sizeof(*hdr)); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") /* Get the information for the object header */ - if(H5O__get_hdr_info_real(oh, hdr) < 0) + if (H5O__get_hdr_info_real(oh, hdr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_hdr_info() */ - /*------------------------------------------------------------------------- * Function: H5O__get_hdr_info_real * @@ -2114,9 +2099,9 @@ 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_chunk_t *curr_chunk; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -2135,18 +2120,18 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->flags = oh->flags; /* Iterate over all the messages, accumulating message size & type information */ - hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); - hdr->space.mesg = 0; - hdr->space.free = 0; + hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); + hdr->space.mesg = 0; + hdr->space.free = 0; hdr->mesg.present = 0; - hdr->mesg.shared = 0; - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - uint64_t type_flag; /* Flag for message type */ + hdr->mesg.shared = 0; + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + uint64_t type_flag; /* Flag for message type */ /* Accumulate space usage information, based on the type of message */ - if(H5O_NULL_ID == curr_msg->type->id) + if (H5O_NULL_ID == curr_msg->type->id) hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); - else if(H5O_CONT_ID == curr_msg->type->id) + else if (H5O_CONT_ID == curr_msg->type->id) hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); else { hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh); @@ -2158,13 +2143,13 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->mesg.present |= type_flag; /* Set flag if the message is shared in some way */ - if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \ + if (curr_msg->flags & H5O_MSG_FLAG_SHARED) hdr->mesg.shared |= type_flag; } /* end for */ /* Iterate over all the chunks, adding any gaps to the free space */ hdr->space.total = 0; - for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { + for (u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { /* Accumulate the size of the header on disk */ hdr->space.total += curr_chunk->size; @@ -2178,11 +2163,10 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__get_hdr_info_real() */ - /*------------------------------------------------------------------------- * Function: H5O_get_info * - * Purpose: Retrieve the information for an object + * Purpose: Retrieve the data model information for an object * * Return: Success: Non-negative * Failure: Negative @@ -2193,11 +2177,11 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) *------------------------------------------------------------------------- */ herr_t -H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t * oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -2206,23 +2190,25 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) HDassert(oinfo); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Get class for object */ - if(NULL == (obj_class = H5O__obj_class_real(oh))) + if (NULL == (obj_class = H5O__obj_class_real(oh))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") /* Reset the object info structure */ - HDmemset(oinfo, 0, sizeof(*oinfo)); + if (H5O__reset_info2(oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct") /* Get basic information, if requested */ - if(fields & H5O_INFO_BASIC) { + if (fields & H5O_INFO_BASIC) { /* Retrieve the file's fileno */ H5F_GET_FILENO(loc->file, oinfo->fileno); - /* Set the object's address */ - oinfo->addr = loc->addr; + /* Set the object's address into the token */ + if (H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token") /* Retrieve the type of the object */ oinfo->type = obj_class->type; @@ -2232,15 +2218,15 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) } /* Get time information, if requested */ - if(fields & H5O_INFO_TIME) { - if(oh->version > H5O_VERSION_1) { + if (fields & H5O_INFO_TIME) { + if (oh->version > H5O_VERSION_1) { oinfo->atime = oh->atime; oinfo->mtime = oh->mtime; oinfo->ctime = oh->ctime; oinfo->btime = oh->btime; } /* end if */ else { - htri_t exists; /* Flag if header message of interest exists */ + htri_t exists; /* Flag if header message of interest exists */ /* No information for access & modification fields */ /* (we stopped updating the "modification time" header message for @@ -2252,117 +2238,101 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) oinfo->btime = 0; /* Might be information for modification time */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") - if(exists > 0) { + if (exists > 0) { /* Get "old style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_ID, &oinfo->ctime)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") } /* end if */ else { /* Check for "new style" modification time info */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) + if ((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") - if(exists > 0) { + if (exists > 0) { /* Get "new style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) + if (NULL == H5O_msg_read_oh(loc->file, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") } /* end if */ else oinfo->ctime = 0; } /* end else */ - } /* end else */ - } /* end if */ - - /* Get the information for the object header, if requested */ - if(fields & H5O_INFO_HDR) - if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") + } /* end else */ + } /* end if */ /* Retrieve # of attributes */ - if(fields & H5O_INFO_NUM_ATTRS) - if(H5O_attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) + if (fields & H5O_INFO_NUM_ATTRS) + if (H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") - /* Get B-tree & heap metadata storage size, if requested */ - if(fields & H5O_INFO_META_SIZE) { - /* Check for 'bh_info' callback for this type of object */ - if(obj_class->bh_info) - /* Call the object's class 'bh_info' routine */ - if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") - - /* Get B-tree & heap info for any attributes */ - if(!(fields & H5O_INFO_NUM_ATTRS) || oinfo->num_attrs > 0) { - if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") - } /* end if */ - } /* end if */ - done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_get_info() */ - /*------------------------------------------------------------------------- - * Function: H5O__get_info_by_idx - * - * Purpose: Internal routine to retrieve an object's info according to - * an index within a group. + * Function: H5O_get_native_info * - * - * Note: Add a parameter "fields" to indicate selection of object info. + * Purpose: Retrieve the native file-format information for an object * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol - * December 28, 2017 + * November 21 2006 * *------------------------------------------------------------------------- */ herr_t -H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields) +H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields) { - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t * oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) - /* Check arguments */ + /* Check args */ HDassert(loc); - HDassert(group_name && *group_name); HDassert(oinfo); - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + /* Get the object header */ + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; + /* Get class for object */ + if (NULL == (obj_class = H5O__obj_class_real(oh))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + /* Reset the object info structure */ + HDmemset(oinfo, 0, sizeof(*oinfo)); -done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + /* Get the information for the object header, if requested */ + if (fields & H5O_NATIVE_INFO_HDR) + if (H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__get_info_by_idx() */ + /* Get B-tree & heap metadata storage size, if requested */ + if (fields & H5O_NATIVE_INFO_META_SIZE) { + /* Check for 'bh_info' callback for this type of object */ + if (obj_class->bh_info) + /* Call the object's class 'bh_info' routine */ + if ((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") + + /* Get B-tree & heap info for any attributes */ + if (H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") + } /* end if */ + +done: + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + FUNC_LEAVE_NOAPI_TAG(ret_value) +} /* end H5O_get_native_info() */ /*------------------------------------------------------------------------- * Function: H5O_get_create_plist @@ -2380,8 +2350,8 @@ H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t id herr_t H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2390,35 +2360,38 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) HDassert(oc_plist); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Set property values, if they were used for the object */ - if(oh->version > H5O_VERSION_1) { - uint8_t ohdr_flags; /* "User-visible" object header status flags */ + if (oh->version > H5O_VERSION_1) { + uint8_t ohdr_flags; /* "User-visible" object header status flags */ /* Set attribute storage values */ - if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") - if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + if (H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, + "can't set max. # of compact attributes in property list") + if (H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") /* Mask off non-"user visible" flags */ - H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES), int); + H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, + oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | + H5O_HDR_STORE_TIMES), + int); /* Set object header flags */ - if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") } /* end if */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5O_get_nlinks * @@ -2435,8 +2408,8 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2445,20 +2418,19 @@ H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) HDassert(nlinks); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve the # of link messages seen when the object header was loaded */ *nlinks = oh->link_msgs_seen; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_nlinks() */ - /*------------------------------------------------------------------------- * Function: H5O_obj_create * @@ -2475,8 +2447,8 @@ H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) 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 */ + size_t u; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2487,25 +2459,24 @@ H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc HDassert(obj_loc); /* Iterate through the object classes */ - for(u = 0; u < NELMTS(H5O_obj_class_g); u++) { + for (u = 0; u < NELMTS(H5O_obj_class_g); u++) { /* Check for correct type of object to create */ - if(H5O_obj_class_g[u]->type == obj_type) { + if (H5O_obj_class_g[u]->type == obj_type) { /* Call the object class's 'create' routine */ HDassert(H5O_obj_class_g[u]->create); - if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc))) + if (NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") /* Break out of loop */ break; } /* end if */ - } /* end for */ + } /* end for */ HDassert(ret_value); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_obj_create() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_addr * @@ -2535,7 +2506,6 @@ H5O_get_oh_addr(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->chunk[0].addr) } /* end H5O_get_oh_addr() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_flags * @@ -2552,7 +2522,6 @@ H5O_get_oh_flags(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->flags); /* flags can be 0 */ } /* H5O_get_oh_flags() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_mtime * @@ -2574,7 +2543,6 @@ H5O_get_oh_mtime(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->mtime); } /* H5O_get_oh_mtime() */ - /*------------------------------------------------------------------------- * Function: H5O_get_oh_version * @@ -2592,7 +2560,6 @@ H5O_get_oh_version(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->version); } /* H5O_get_oh_version() */ - /*------------------------------------------------------------------------- * Function: H5O_get_rc_and_type * @@ -2609,8 +2576,8 @@ H5O_get_oh_version(const H5O_t *oh) herr_t H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2618,26 +2585,25 @@ H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) HDassert(loc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Set the object's reference count */ - if(rc) + if (rc) *rc = oh->nlink; /* Retrieve the type of the object */ - if(otype) - if(H5O__obj_type_real(oh, otype) < 0) + if (otype) + if (H5O__obj_type_real(oh, otype) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_rc_and_type() */ - /*------------------------------------------------------------------------- * Function: H5O__free_visit_visited * @@ -2651,7 +2617,7 @@ H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) *------------------------------------------------------------------------- */ static herr_t -H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/) { FUNC_ENTER_STATIC_NOERR @@ -2660,7 +2626,6 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__free_visit_visited() */ - /*------------------------------------------------------------------------- * Function: H5O__visit_cb * @@ -2675,15 +2640,14 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static herr_t -H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo, - void *_udata) +H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo, void *_udata) { - H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2693,8 +2657,8 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li HDassert(udata); /* Check if this is a hard link */ - if(linfo->type == H5L_TYPE_HARD) { - H5_obj_t obj_pos; /* Object "position" for this object */ + if (linfo->type == H5L_TYPE_HARD) { + H5_obj_t obj_pos; /* Object "position" for this object */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -2703,7 +2667,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li /* Find the object using the LAPL passed in */ /* (Correctly handles mounted files) */ - if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(udata->start_loc, name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") obj_found = TRUE; @@ -2712,47 +2676,47 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li obj_pos.addr = obj_oloc.addr; /* Check if we've seen the object the link references before */ - if(NULL == H5SL_search(udata->visited, &obj_pos)) { - H5O_info_t oinfo; /* Object info */ + if (NULL == H5SL_search(udata->visited, &obj_pos)) { + H5O_info2_t oinfo; /* Object info */ /* Get the object's info */ - if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) + if (H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") /* Make the application callback */ ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data); /* Check for continuing to visit objects */ - if(ret_value == H5_ITER_CONT) { + if (ret_value == H5_ITER_CONT) { /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *new_node; /* New object node for visited list */ + if (oinfo.rc > 1) { + H5_obj_t *new_node; /* New object node for visited list */ /* Allocate new object "position" node */ - if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") /* Set node information */ *new_node = obj_pos; /* Add to list of visited objects */ - if(H5SL_insert(udata->visited, new_node, new_node) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") + if (H5SL_insert(udata->visited, new_node, new_node) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, + "can't insert object node into visited list") } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ done: /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) + if (obj_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__visit_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__visit * @@ -2788,18 +2752,19 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li *------------------------------------------------------------------------- */ herr_t -H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) +H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields) { - H5O_iter_visit_ud_t udata; /* User data for callback */ - H5G_loc_t loc; /* Location of reference object */ - H5G_loc_t obj_loc; /* Location used to open object */ - 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 */ - H5O_info_t oinfo; /* Object info struct */ - hid_t obj_id = H5I_INVALID_HID; /* ID of object */ - herr_t ret_value = FAIL; /* Return value */ + H5O_iter_visit_ud_t udata; /* User data for callback */ + H5G_loc_t obj_loc; /* Location used to open object */ + 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 */ + H5O_info2_t oinfo; /* Object info struct */ + 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 */ FUNC_ENTER_PACKAGE @@ -2807,8 +2772,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HDmemset(&udata, 0, sizeof(udata)); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HDassert(loc); /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -2816,84 +2780,97 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) + if (H5G_loc_find(loc, obj_name, &obj_loc /*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Get the object's info */ - if(H5O_get_info(&obj_oloc, &oinfo, fields) < 0) + if (H5O_get_info(&obj_oloc, &oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") /* Open the object */ /* (Takes ownership of the obj_loc information) */ - if((obj_id = H5O__open_by_loc(&obj_loc, TRUE)) < 0) + if (NULL == (obj = H5O_open_by_loc(&obj_loc, &opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an ID for the visited object */ + if ((obj_id = H5VL_wrap_register(opened_type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register visited object") + /* Make callback for starting object */ - if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) + if ((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") /* Check return value of first callback */ - if(ret_value != H5_ITER_CONT) + if (ret_value != H5_ITER_CONT) HGOTO_DONE(ret_value); /* Check for object being a group */ - if(oinfo.type == H5O_TYPE_GROUP) { - H5G_loc_t start_loc; /* Location of starting group */ + if (oinfo.type == H5O_TYPE_GROUP) { + H5G_loc_t start_loc; /* Location of starting group */ + H5G_loc_t vis_loc; /* Location of visited group */ /* Get the location of the starting group */ - if(H5G_loc(obj_id, &start_loc) < 0) + if (H5G_loc(obj_id, &start_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Set up user data for visiting links */ - udata.obj_id = obj_id; + udata.obj_id = obj_id; udata.start_loc = &start_loc; - udata.op = op; - udata.op_data = op_data; - udata.fields = fields; + udata.op = op; + udata.op_data = op_data; + udata.fields = fields; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) + if ((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") /* If its ref count is > 1, we add it to the list of visited objects */ /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *obj_pos; /* New object node for visited list */ + if (oinfo.rc > 1) { + H5_obj_t *obj_pos; /* New object node for visited list */ /* Allocate new object "position" node */ - if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) + if ((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node") /* Construct unique "position" for this object */ obj_pos->fileno = oinfo.fileno; - obj_pos->addr = oinfo.addr; + + /* De-serialize object token into an object address */ + if (H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") /* Add to list of visited objects */ - if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) + if (H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") } + /* Get the location of the visited group */ + if (H5G_loc(obj_id, &vis_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + /* Call internal group visitation routine */ - if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) + if ((ret_value = H5G_visit(&vis_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ done: - if(obj_id > 0) { - if(H5I_dec_app_ref(obj_id) < 0) + /* XXX (VOL MERGE): Probably also want to consider closing obj here on failures */ + if (obj_id != H5I_INVALID_HID) { + if (H5I_dec_app_ref(obj_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") } - else if(loc_found && H5G_loc_free(&obj_loc) < 0) + else if (loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - if(udata.visited) + if (udata.visited) H5SL_destroy(udata.visited, H5O__free_visit_visited, NULL); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__visit() */ - /*------------------------------------------------------------------------- * Function: H5O__inc_rc * @@ -2909,7 +2886,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, herr_t H5O__inc_rc(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2917,8 +2894,8 @@ H5O__inc_rc(H5O_t *oh) HDassert(oh); /* Pin the object header when the reference count goes above 0 */ - if(oh->rc == 0) - if(H5AC_pin_protected_entry(oh) < 0) + if (oh->rc == 0) + if (H5AC_pin_protected_entry(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Increment reference count */ @@ -2928,7 +2905,6 @@ H5O__inc_rc(H5O_t *oh) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__inc_rc() */ - /*------------------------------------------------------------------------- * Function: H5O__dec_rc * @@ -2944,7 +2920,7 @@ H5O__inc_rc(H5O_t *oh) herr_t H5O__dec_rc(H5O_t *oh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2955,15 +2931,14 @@ H5O__dec_rc(H5O_t *oh) oh->rc--; /* Unpin the object header when the reference count goes back to 0 */ - if(oh->rc == 0) - if(H5AC_unpin_entry(oh) < 0) + if (oh->rc == 0) + if (H5AC_unpin_entry(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dec_rc() */ - /*------------------------------------------------------------------------- * Function: H5O_dec_rc_by_loc * @@ -2980,8 +2955,8 @@ H5O__dec_rc(H5O_t *oh) herr_t H5O_dec_rc_by_loc(const H5O_loc_t *loc) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2989,23 +2964,22 @@ H5O_dec_rc_by_loc(const H5O_loc_t *loc) HDassert(loc); /* Get header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Decrement the reference count on the object header */ /* (which will unpin it, if appropriate) */ - if(H5O__dec_rc(oh) < 0) + if (H5O__dec_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") done: /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dec_rc_by_loc() */ - /*------------------------------------------------------------------------- * Function: H5O_get_proxy * @@ -3029,7 +3003,6 @@ H5O_get_proxy(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->proxy) } /* end H5O_get_proxy() */ - /*------------------------------------------------------------------------- * Function: H5O__free * @@ -3045,8 +3018,8 @@ H5O_get_proxy(const H5O_t *oh) herr_t H5O__free(H5O_t *oh) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3055,20 +3028,20 @@ H5O__free(H5O_t *oh) HDassert(0 == oh->rc); /* Destroy chunks */ - if(oh->chunk) { - for(u = 0; u < oh->nchunks; u++) + if (oh->chunk) { + for (u = 0; u < oh->nchunks; u++) oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); } /* end if */ /* Destroy messages */ - if(oh->mesg) { - for(u = 0; u < oh->nmesgs; u++) { + if (oh->mesg) { + for (u = 0; u < oh->nmesgs; u++) { #ifndef NDEBUG /* Verify that message is clean, unless it could have been marked * dirty by decoding */ - if(oh->ndecode_dirtied && oh->mesg[u].dirty) + if (oh->ndecode_dirtied && oh->mesg[u].dirty) oh->ndecode_dirtied--; else HDassert(oh->mesg[u].dirty == 0); @@ -3084,8 +3057,8 @@ H5O__free(H5O_t *oh) } /* end if */ /* Destroy the proxy */ - if(oh->proxy) - if(H5AC_proxy_entry_dest(oh->proxy) < 0) + if (oh->proxy) + if (H5AC_proxy_entry_dest(oh->proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy") /* destroy object header */ @@ -3095,3 +3068,24 @@ H5O__free(H5O_t *oh) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__free() */ +/*------------------------------------------------------------------------- + * Function: H5O__reset_info2 + * + * Purpose: Resets/initializes an H5O_info2_t struct. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__reset_info2(H5O_info2_t *oinfo) +{ + FUNC_ENTER_STATIC_NOERR; + + /* Reset the passed-in info struct */ + HDmemset(oinfo, 0, sizeof(H5O_info2_t)); + oinfo->type = H5O_TYPE_UNKNOWN; + oinfo->token = H5O_TOKEN_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5O__reset_info2() */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 99e646d2fe6..651e317a2c9 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,69 +17,62 @@ * Purpose: Messages related to data layout. */ -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ +#define H5D_FRIEND /*suppress error about including H5Dpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ /* Local macros */ - /* PRIVATE PROTOTYPES */ -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 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, 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); +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, + 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); /* This message derives from H5O message class */ 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? */ - H5O__layout_decode, /* decode message */ - H5O__layout_encode, /* encode message */ - H5O__layout_copy, /* copy the native value */ - H5O__layout_size, /* size of message on disk */ - H5O__layout_reset, /* reset method */ - H5O__layout_free, /* free the struct */ - H5O__layout_delete, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /* can share method */ - H5O__layout_pre_copy_file, /* pre copy native value to file */ - H5O__layout_copy_file, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__layout_debug /* debug the message */ + H5O_LAYOUT_ID, /* message id number */ + "layout", /* message name for debugging */ + sizeof(H5O_layout_t), /* native message size */ + 0, /* messages are sharable? */ + H5O__layout_decode, /* decode message */ + H5O__layout_encode, /* encode message */ + H5O__layout_copy, /* copy the native value */ + H5O__layout_size, /* size of message on disk */ + H5O__layout_reset, /* reset method */ + H5O__layout_free, /* free the struct */ + H5O__layout_delete, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /* can share method */ + H5O__layout_pre_copy_file, /* pre copy native value to file */ + H5O__layout_copy_file, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__layout_debug /* debug the message */ }}; - /* Declare a free list to manage the H5O_layout_t struct */ H5FL_DEFINE(H5O_layout_t); - /*------------------------------------------------------------------------- * Function: H5O__layout_decode * @@ -96,14 +89,14 @@ H5FL_DEFINE(H5O_layout_t); *------------------------------------------------------------------------- */ 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 H5_ATTR_UNUSED p_size, const uint8_t *p) +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; - unsigned u; - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -112,20 +105,20 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (mesg = H5FL_CALLOC(H5O_layout_t))) + if (NULL == (mesg = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") mesg->storage.type = H5D_LAYOUT_ERROR; mesg->version = *p++; - if(mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4) + 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") - if(mesg->version < H5O_LAYOUT_VERSION_3) { - unsigned ndims; /* Num dimensions in chunk */ + if (mesg->version < H5O_LAYOUT_VERSION_3) { + unsigned ndims; /* Num dimensions in chunk */ /* Dimensionality */ ndims = *p++; - if(!ndims || ndims > H5O_LAYOUT_NDIMS) + if (!ndims || ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is out of range") /* Layout class */ @@ -139,13 +132,13 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, p += 5; /* Address */ - if(mesg->type == H5D_CONTIGUOUS) { + if (mesg->type == H5D_CONTIGUOUS) { 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) { + else if (mesg->type == H5D_CHUNKED) { H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Set the layout operations */ @@ -154,7 +147,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Set the chunk operations */ /* (Only "btree" indexing type currently supported in this version) */ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - mesg->storage.u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; } /* end if */ else { /* Sanity check */ @@ -165,49 +158,59 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end else */ /* Read the size */ - if(mesg->type != H5D_CHUNKED) { + if (mesg->type != H5D_CHUNKED) { /* Don't compute size of contiguous storage here, due to possible * truncation of the dimension sizes when they were stored in this * version of the layout message. Compute the contiguous storage * 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 */ + p += ndims * 4; /* Skip over dimension sizes (32-bit quantities) */ + } /* end if */ else { - mesg->u.chunk.ndims=ndims; - for(u = 0; u < ndims; u++) + mesg->u.chunk.ndims = ndims; + for (u = 0; u < ndims; u++) UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < ndims; u++) + 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 (mesg->type == H5D_COMPACT) { UINT32DECODE(p, mesg->storage.u.compact.size); - if(mesg->storage.u.compact.size > 0) { - if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer") + 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 (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 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; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Layout & storage class */ mesg->type = mesg->storage.type = (H5D_layout_t)*p++; /* Interpret the rest of the message according to the layout class */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Compact data size */ UINT16DECODE(p, mesg->storage.u.compact.size); - if(mesg->storage.u.compact.size > 0) { + 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") + /* Allocate space for compact data */ - if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed for compact data buffer") + if (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, + "memory allocation failed for compact data buffer") /* Compact data */ H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); @@ -230,36 +233,37 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, break; case H5D_CHUNKED: - if(mesg->version < H5O_LAYOUT_VERSION_4) { + if (mesg->version < H5O_LAYOUT_VERSION_4) { /* Set the chunked layout flags */ mesg->u.chunk.flags = (uint8_t)0; /* Dimensionality */ mesg->u.chunk.ndims = *p++; - if(mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) + if (mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large") /* B-tree address */ H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Chunk dimensions */ - for(u = 0; u < mesg->u.chunk.ndims; u++) { + 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]) + 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]) } /* end for */ /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) + 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]; /* Set the chunk operations */ /* (Only "btree" indexing type supported with v3 of message format) */ mesg->storage.u.chunk.idx_type = H5D_CHUNK_IDX_BTREE; - mesg->storage.u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; } /* end if */ else { /* Get the chunked layout flags */ @@ -269,44 +273,45 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, /* (Currently issues an error for all non-zero values, * until features are added for the flags) */ - if(mesg->u.chunk.flags & ~H5O_LAYOUT_ALL_CHUNK_FLAGS) + if (mesg->u.chunk.flags & ~H5O_LAYOUT_ALL_CHUNK_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad flag value for message") /* Dimensionality */ mesg->u.chunk.ndims = *p++; - if(mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) + 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 */ 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) + 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") /* 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); /* Compute chunk size */ - for(u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) + 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 */ mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; - if(mesg->u.chunk.idx_type >= H5D_CHUNK_IDX_NTYPES) + 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; - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "v1 B-tree index type should never be in a v4 layout message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "v1 B-tree index type should never be in a v4 layout message") break; - case H5D_CHUNK_IDX_NONE: /* Implicit Index */ + case H5D_CHUNK_IDX_NONE: /* Implicit Index */ mesg->storage.u.chunk.ops = H5D_COPS_NONE; break; - case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ - if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ + if (mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { H5F_DECODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32DECODE(p, mesg->storage.u.chunk.u.single.filter_mask); } /* end if */ @@ -318,8 +323,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ 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, "invalid fixed array creation parameter") + if (0 == mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid fixed array creation parameter") /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_FARRAY; @@ -328,26 +334,31 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_CHUNK_IDX_EARRAY: /* Extensible array creation parameters */ 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, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.max_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") 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, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.idx_blk_elmts) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") 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, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") 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, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.data_blk_min_elmts) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") 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, "invalid extensible array creation parameter") + if (0 == mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "invalid extensible array creation parameter") /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_EARRAY; break; - case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ UINT32DECODE(p, mesg->u.chunk.u.btree2.cparam.node_size); mesg->u.chunk.u.btree2.cparam.split_percent = *p++; mesg->u.chunk.u.btree2.cparam.merge_percent = *p++; @@ -371,7 +382,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5D_VIRTUAL: /* Check version */ - if(mesg->version < H5O_LAYOUT_VERSION_4) + if (mesg->version < H5O_LAYOUT_VERSION_4) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "invalid layout version with virtual layout") /* Heap information */ @@ -379,115 +390,145 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, UINT32DECODE(p, mesg->storage.u.virt.serial_list_hobjid.idx); /* Initialize other fields */ - mesg->storage.u.virt.list_nused = 0; - mesg->storage.u.virt.list = NULL; + mesg->storage.u.virt.list_nused = 0; + mesg->storage.u.virt.list = NULL; mesg->storage.u.virt.list_nalloc = 0; - mesg->storage.u.virt.view = H5D_VDS_ERROR; - mesg->storage.u.virt.printf_gap = HSIZE_UNDEF; + mesg->storage.u.virt.view = H5D_VDS_ERROR; + mesg->storage.u.virt.printf_gap = HSIZE_UNDEF; mesg->storage.u.virt.source_fapl = -1; mesg->storage.u.virt.source_dapl = -1; - mesg->storage.u.virt.init = FALSE; + mesg->storage.u.virt.init = FALSE; /* Decode heap block if it exists */ - if(mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { + if (mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { const uint8_t *heap_block_p; - 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; + 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))) + 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; /* Decode the version number of the heap block encoding */ 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) + 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 */ 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)))) + 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") mesg->storage.u.virt.list_nalloc = (size_t)tmp_hsize; - mesg->storage.u.virt.list_nused = (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 (i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source file name") + if (NULL == + (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, 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; /* Source dataset name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source dataset name") + if (NULL == + (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, 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) + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_select, + &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode source space selection") /* Virtual selection */ - if(H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode virtual space selection") + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_dset.virtual_select, + &heap_block_p) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, + "can't decode virtual space selection") /* Parse source file and dataset names for "printf" * style format specifiers */ - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) + if (H5D_virtual_parse_source_name( + mesg->storage.u.virt.list[i].source_file_name, + &mesg->storage.u.virt.list[i].parsed_source_file_name, + &mesg->storage.u.virt.list[i].psfn_static_strlen, + &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source file name") - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) + if (H5D_virtual_parse_source_name( + mesg->storage.u.virt.list[i].source_dset_name, + &mesg->storage.u.virt.list[i].parsed_source_dset_name, + &mesg->storage.u.virt.list[i].psdn_static_strlen, + &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source dataset name") /* Set source names in source_dset struct */ - if((mesg->storage.u.virt.list[i].psfn_nsubs == 0) - && (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { - if(mesg->storage.u.virt.list[i].parsed_source_file_name) - mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; + if ((mesg->storage.u.virt.list[i].psfn_nsubs == 0) && + (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { + if (mesg->storage.u.virt.list[i].parsed_source_file_name) + mesg->storage.u.virt.list[i].source_dset.file_name = + mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; else - mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].source_file_name; - if(mesg->storage.u.virt.list[i].parsed_source_dset_name) - mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + mesg->storage.u.virt.list[i].source_dset.file_name = + mesg->storage.u.virt.list[i].source_file_name; + if (mesg->storage.u.virt.list[i].parsed_source_dset_name) + mesg->storage.u.virt.list[i].source_dset.dset_name = + mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; else - mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].source_dset_name; + mesg->storage.u.virt.list[i].source_dset.dset_name = + mesg->storage.u.virt.list[i].source_dset_name; } /* end if */ /* unlim_dim fields */ - mesg->storage.u.virt.list[i].unlim_dim_source = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); - mesg->storage.u.virt.list[i].unlim_dim_virtual = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); - mesg->storage.u.virt.list[i].unlim_extent_source = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].unlim_dim_source = + H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); + mesg->storage.u.virt.list[i].unlim_dim_virtual = + H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); + mesg->storage.u.virt.list[i].unlim_extent_source = HSIZE_UNDEF; mesg->storage.u.virt.list[i].unlim_extent_virtual = HSIZE_UNDEF; - mesg->storage.u.virt.list[i].clip_size_source = HSIZE_UNDEF; - mesg->storage.u.virt.list[i].clip_size_virtual = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].clip_size_source = HSIZE_UNDEF; + mesg->storage.u.virt.list[i].clip_size_virtual = HSIZE_UNDEF; /* Clipped selections */ - if(mesg->storage.u.virt.list[i].unlim_dim_virtual < 0) { - mesg->storage.u.virt.list[i].source_dset.clipped_source_select = mesg->storage.u.virt.list[i].source_select; - mesg->storage.u.virt.list[i].source_dset.clipped_virtual_select = mesg->storage.u.virt.list[i].source_dset.virtual_select; + if (mesg->storage.u.virt.list[i].unlim_dim_virtual < 0) { + mesg->storage.u.virt.list[i].source_dset.clipped_source_select = + mesg->storage.u.virt.list[i].source_select; + mesg->storage.u.virt.list[i].source_dset.clipped_virtual_select = + mesg->storage.u.virt.list[i].source_dset.virtual_select; } /* end if */ /* Check mapping for validity (do both pre and post * checks here, since we had to allocate the entry list * before decoding the selections anyways) */ - if(H5D_virtual_check_mapping_pre(mesg->storage.u.virt.list[i].source_dset.virtual_select, mesg->storage.u.virt.list[i].source_select, H5O_VIRTUAL_STATUS_INVALID) < 0) + if (H5D_virtual_check_mapping_pre( + mesg->storage.u.virt.list[i].source_dset.virtual_select, + mesg->storage.u.virt.list[i].source_select, H5O_VIRTUAL_STATUS_INVALID) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid mapping selections") - if(H5D_virtual_check_mapping_post(&mesg->storage.u.virt.list[i]) < 0) + if (H5D_virtual_check_mapping_post(&mesg->storage.u.virt.list[i]) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid mapping entry") /* Update min_dims */ - if(H5D_virtual_update_min_dims(mesg, i) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to update virtual dataset minimum dimensions") + if (H5D_virtual_update_min_dims(mesg, i) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, + "unable to update virtual dataset minimum dimensions") } /* end for */ /* Read stored checksum */ @@ -497,11 +538,12 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, computed_chksum = H5_checksum_metadata(heap_block, block_size - (size_t)4, 0); /* Verify checksum */ - if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect metadata checksum for global heap block") + if (stored_chksum != computed_chksum) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "incorrect metadata checksum for global heap block") /* Verify that the heap block size is correct */ - if((size_t)(heap_block_p - heap_block) != block_size) + if ((size_t)(heap_block_p - heap_block) != block_size) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect heap block size") } /* end if */ @@ -515,16 +557,16 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, default: HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") } /* end switch */ - } /* end else */ + } /* end else */ /* Set return value */ ret_value = mesg; done: - if(ret_value == NULL) - if(mesg) { - if(mesg->type == H5D_VIRTUAL) - if(H5D__virtual_reset_layout(mesg) < 0) + if (ret_value == NULL) + if (mesg) { + if (mesg->type == H5D_VIRTUAL) + if (H5D__virtual_reset_layout(mesg) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to reset virtual layout") mesg = H5FL_FREE(H5O_layout_t, mesg); } /* end if */ @@ -534,7 +576,6 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_encode * @@ -554,9 +595,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, static herr_t H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -566,21 +607,20 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, HDassert(p); /* Message version */ - *p++ = (uint8_t)((mesg->version < H5O_LAYOUT_VERSION_3) ? - H5O_LAYOUT_VERSION_3 : mesg->version); + *p++ = (uint8_t)((mesg->version < H5O_LAYOUT_VERSION_3) ? H5O_LAYOUT_VERSION_3 : mesg->version); /* Layout class */ *p++ = (uint8_t)mesg->type; /* Write out layout class specific information */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Size of raw data */ UINT16ENCODE(p, mesg->storage.u.compact.size); /* Raw data */ - if(mesg->storage.u.compact.size > 0) { - if(mesg->storage.u.compact.buf) + if (mesg->storage.u.compact.size > 0) { + if (mesg->storage.u.compact.buf) H5MM_memcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size); else HDmemset(p, 0, mesg->storage.u.compact.size); @@ -597,7 +637,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, break; case H5D_CHUNKED: - if(mesg->version < H5O_LAYOUT_VERSION_4) { + if (mesg->version < H5O_LAYOUT_VERSION_4) { /* Number of dimensions */ HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); *p++ = (uint8_t)mesg->u.chunk.ndims; @@ -606,7 +646,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); /* Dimension sizes */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) UINT32ENCODE(p, mesg->u.chunk.dim[u]); } /* end if */ else { @@ -622,23 +662,24 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = (uint8_t)mesg->u.chunk.enc_bytes_per_dim; /* Dimension sizes */ - for(u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) UINT64ENCODE_VAR(p, mesg->u.chunk.dim[u], mesg->u.chunk.enc_bytes_per_dim); /* Chunk index type */ *p++ = (uint8_t)mesg->u.chunk.idx_type; - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "v1 B-tree index type should never be in a v4 layout message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, + "v1 B-tree index type should never be in a v4 layout message") break; - case H5D_CHUNK_IDX_NONE: /* Implicit */ + case H5D_CHUNK_IDX_NONE: /* Implicit */ break; - case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ + case H5D_CHUNK_IDX_SINGLE: /* Single Chunk */ /* Filter information */ - if(mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + if (mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { H5F_ENCODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32ENCODE(p, mesg->storage.u.chunk.u.single.filter_mask); } /* end if */ @@ -658,7 +699,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits; break; - case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ UINT32ENCODE(p, mesg->u.chunk.u.btree2.cparam.node_size); *p++ = mesg->u.chunk.u.btree2.cparam.split_percent; *p++ = mesg->u.chunk.u.btree2.cparam.merge_percent; @@ -694,7 +735,6 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_copy * @@ -713,9 +753,9 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, 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 */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + H5O_layout_t * dest = (H5O_layout_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -723,26 +763,27 @@ H5O__layout_copy(const void *_mesg, void *_dest) HDassert(mesg); /* Allocate destination message, if necessary */ - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "layout message allocation failed") /* copy */ *dest = *mesg; /* Special actions for each type of layout */ - switch(mesg->type) { + switch (mesg->type) { case H5D_COMPACT: /* Deep copy the buffer for compact datasets also */ - if(mesg->storage.u.compact.size > 0) { + if (mesg->storage.u.compact.size > 0) { /* Sanity check */ HDassert(mesg->storage.u.compact.buf); /* Allocate memory for the raw data */ - if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) + if (NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") /* Copy over the raw data */ - H5MM_memcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size); + H5MM_memcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, + dest->storage.u.compact.size); } /* end if */ else HDassert(dest->storage.u.compact.buf == NULL); @@ -754,12 +795,12 @@ H5O__layout_copy(const void *_mesg, void *_dest) case H5D_CHUNKED: /* Reset the pointer of the chunked storage index but not the address */ - if(dest->storage.u.chunk.ops) + if (dest->storage.u.chunk.ops) H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE); break; case H5D_VIRTUAL: - if(H5D__virtual_copy_layout(dest) < 0) + if (H5D__virtual_copy_layout(dest) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual layout") break; @@ -773,14 +814,13 @@ H5O__layout_copy(const void *_mesg, void *_dest) ret_value = dest; done: - if(ret_value == NULL) - if(NULL == _dest) + if (ret_value == NULL) + if (NULL == _dest) dest = H5FL_FREE(H5O_layout_t, dest); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_size * @@ -800,8 +840,8 @@ H5O__layout_copy(const void *_mesg, void *_dest) static size_t H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t ret_value = 0; /* Return value */ + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -816,7 +856,6 @@ H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const vo FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_size() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_reset * @@ -833,22 +872,22 @@ H5O__layout_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const vo static herr_t H5O__layout_reset(void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(mesg) { + if (mesg) { /* Free the compact storage buffer */ - if(H5D_COMPACT == mesg->type) + if (H5D_COMPACT == mesg->type) mesg->storage.u.compact.buf = H5MM_xfree(mesg->storage.u.compact.buf); - else if(H5D_VIRTUAL == mesg->type) + else if (H5D_VIRTUAL == mesg->type) /* Free the virtual entry list */ - if(H5D__virtual_reset_layout(mesg) < 0) + if (H5D__virtual_reset_layout(mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to reset virtual layout") /* Reset the message */ - mesg->type = H5D_CONTIGUOUS; + mesg->type = H5D_CONTIGUOUS; mesg->version = H5O_LAYOUT_VERSION_DEFAULT; } /* end if */ @@ -856,15 +895,14 @@ H5O__layout_reset(void *_mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_reset() */ - /*------------------------------------------------------------------------- - * Function: H5O__layout_free + * Function: H5O__layout_free * - * Purpose: Free's the message + * Purpose: Free's the message * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, March 11, 2000 * *------------------------------------------------------------------------- @@ -872,7 +910,7 @@ H5O__layout_reset(void *_mesg) static herr_t H5O__layout_free(void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *) _mesg; + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -886,7 +924,6 @@ H5O__layout_free(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__layout_free() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_delete * @@ -902,8 +939,8 @@ H5O__layout_free(void *_mesg) static herr_t H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_layout_t *mesg = (H5O_layout_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *mesg = (H5O_layout_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -913,26 +950,26 @@ H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) HDassert(mesg); /* Perform different actions, depending on the type of storage */ - switch(mesg->type) { - case H5D_COMPACT: /* Compact data storage */ + switch (mesg->type) { + case H5D_COMPACT: /* Compact data storage */ /* Nothing required */ break; - case H5D_CONTIGUOUS: /* Contiguous block on disk */ + case H5D_CONTIGUOUS: /* Contiguous block on disk */ /* Free the file space for the raw data */ - if(H5D__contig_delete(f, &mesg->storage) < 0) + if (H5D__contig_delete(f, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; - case H5D_CHUNKED: /* Chunked blocks on disk */ + case H5D_CHUNKED: /* Chunked blocks on disk */ /* Free the file space for the index & chunk raw data */ - if(H5D__chunk_delete(f, open_oh, &mesg->storage) < 0) + if (H5D__chunk_delete(f, open_oh, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; - case H5D_VIRTUAL: /* Virtual dataset */ + case H5D_VIRTUAL: /* Virtual dataset */ /* Free the file space virtual dataset */ - if(H5D__virtual_delete(f, &mesg->storage) < 0) + if (H5D__virtual_delete(f, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; @@ -946,7 +983,6 @@ H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_pre_copy_file * @@ -962,10 +998,11 @@ H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg) */ static herr_t H5O__layout_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 H5_ATTR_UNUSED *udata) + hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, + void H5_ATTR_UNUSED *udata) { - const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -975,14 +1012,13 @@ H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "layout message version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_copy_file * @@ -999,14 +1035,14 @@ H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, */ static void * H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info, void *_udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + 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; - hbool_t copied = FALSE; /* Whether the data was copied */ - void *ret_value = NULL; /* Return value */ + 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; + hbool_t copied = FALSE; /* Whether the data was copied */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1016,15 +1052,16 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, HDassert(file_dst); /* Copy the layout information */ - if(NULL == (layout_dst = (H5O_layout_t *)H5O__layout_copy(layout_src, NULL))) + if (NULL == (layout_dst = (H5O_layout_t *)H5O__layout_copy(layout_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy layout") /* Copy the layout type specific information */ - switch(layout_src->type) { + switch (layout_src->type) { case H5D_COMPACT: - if(layout_src->storage.u.compact.buf) { + if (layout_src->storage.u.compact.buf) { /* copy compact raw data */ - if(H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info) < 0) + if (H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, + &layout_dst->storage.u.compact, udata->src_dtype, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") copied = TRUE; } /* end if */ @@ -1035,24 +1072,29 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(layout_src->version < H5O_LAYOUT_VERSION_3) - layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) * - H5T_get_size(udata->src_dtype); + if (layout_src->version < H5O_LAYOUT_VERSION_3) + layout_dst->storage.u.contig.size = + H5S_extent_nelem(udata->src_space_extent) * H5T_get_size(udata->src_dtype); - if(H5D__contig_is_space_alloc(&layout_src->storage) - || (cpy_info->shared_fo && H5D__contig_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { + if (H5D__contig_is_space_alloc(&layout_src->storage) || + (cpy_info->shared_fo && + H5D__contig_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { /* copy contiguous raw data */ - if(H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0) + if (H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, + &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage") copied = TRUE; } /* end if */ break; case H5D_CHUNKED: - if(H5D__chunk_is_space_alloc(&layout_src->storage) - || (cpy_info->shared_fo && H5D__chunk_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { + if (H5D__chunk_is_space_alloc(&layout_src->storage) || + (cpy_info->shared_fo && + H5D__chunk_is_data_cached((const H5D_shared_t *)cpy_info->shared_fo))) { /* Create chunked layout */ - if(H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info) < 0) + if (H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, + &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, + udata->common.src_pline, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") copied = TRUE; } /* end if */ @@ -1061,7 +1103,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, case H5D_VIRTUAL: /* Copy virtual layout. Always copy so the memory fields get copied * properly. */ - if(H5D__virtual_copy(file_dst, layout_dst) < 0) + if (H5D__virtual_copy(file_dst, layout_dst) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual storage") break; @@ -1072,21 +1114,20 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, } /* end switch */ /* Check if copy routine was invoked (which frees the source datatype) */ - if(copied) + if (copied) udata->src_dtype = NULL; /* Set return value */ ret_value = layout_dst; done: - if(!ret_value) - if(layout_dst) - layout_dst = H5FL_FREE(H5O_layout_t, layout_dst); + if (!ret_value) + if (layout_dst) + layout_dst = H5FL_FREE(H5O_layout_t, layout_dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__layout_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__layout_debug * @@ -1100,11 +1141,10 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, *------------------------------------------------------------------------- */ static herr_t -H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - size_t u; + const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; + size_t u; FUNC_ENTER_STATIC_NOERR @@ -1115,111 +1155,98 @@ H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", mesg->version); - switch(mesg->type) { + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", mesg->version); + switch (mesg->type) { case H5D_CHUNKED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Chunked"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Chunked"); /* Chunk # of dims & size */ HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Number of dimensions:", - (unsigned long)(mesg->u.chunk.ndims)); + "Number of dimensions:", (unsigned long)(mesg->u.chunk.ndims)); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Size:"); - for(u = 0; u < (size_t)mesg->u.chunk.ndims; u++) + for (u = 0; u < (size_t)mesg->u.chunk.ndims; u++) HDfprintf(stream, "%s%lu", u ? ", " : "", (unsigned long)(mesg->u.chunk.dim[u])); HDfprintf(stream, "}\n"); /* Index information */ - switch(mesg->u.chunk.idx_type) { + switch (mesg->u.chunk.idx_type) { case H5D_CHUNK_IDX_BTREE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "v1 B-tree"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "v1 B-tree"); break; case H5D_CHUNK_IDX_NONE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Implicit"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Implicit"); break; case H5D_CHUNK_IDX_SINGLE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Single Chunk"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Single Chunk"); break; case H5D_CHUNK_IDX_FARRAY: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Fixed Array"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Fixed Array"); /* (Should print the fixed array creation parameters) */ break; case H5D_CHUNK_IDX_EARRAY: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "Extensible Array"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "Extensible Array"); /* (Should print the extensible array creation parameters) */ break; case H5D_CHUNK_IDX_BT2: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Index Type:", "v2 B-tree"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "v2 B-tree"); /* (Should print the v2-Btree creation parameters) */ break; case H5D_CHUNK_IDX_NTYPES: default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Index Type:", "Unknown", + (unsigned)mesg->u.chunk.idx_type); break; } /* end switch */ - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Index address:", mesg->storage.u.chunk.idx_addr); break; case H5D_CONTIGUOUS: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Contiguous"); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Contiguous"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Data address:", mesg->storage.u.contig.addr); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Data Size:", mesg->storage.u.contig.size); break; case H5D_COMPACT: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Compact"); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Compact"); + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Data Size:", mesg->storage.u.compact.size); break; case H5D_VIRTUAL: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Type:", "Virtual"); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Virtual"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Global heap address:", mesg->storage.u.virt.serial_list_hobjid.addr); - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Global heap index:", mesg->storage.u.virt.serial_list_hobjid.idx); - for(u = 0; u < mesg->storage.u.virt.list_nused; u++) { - HDfprintf(stream, "%*sMapping %u:\n", indent, "", u); + for (u = 0; u < mesg->storage.u.virt.list_nused; u++) { + HDfprintf(stream, "%*sMapping %zu:\n", indent, "", u); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Virtual selection:", ""); + "Virtual selection:", ""); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source file name:", mesg->storage.u.virt.list[u].source_file_name); + "Source file name:", mesg->storage.u.virt.list[u].source_file_name); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source dataset name:", mesg->storage.u.virt.list[u].source_dset_name); + "Source dataset name:", mesg->storage.u.virt.list[u].source_dset_name); HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth - 3, - "Source selection:", ""); + "Source selection:", ""); } /* end for */ break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Type:", "Unknown", (unsigned)mesg->type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Type:", "Unknown", + (unsigned)mesg->type); break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__layout_debug() */ - diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index ebb34dc675b..711f199c077 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,80 +22,75 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5L_FRIEND /*suppress error about including H5Lpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Lpkg.h" /* Links */ -#include "H5Opkg.h" /* Object headers */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Lpkg.h" /* Links */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 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); -static void *H5O__linfo_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__linfo_post_copy_file(const H5O_loc_t *parent_src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info); -static herr_t H5O__linfo_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static void *H5O__linfo_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__linfo_post_copy_file(const H5O_loc_t *parent_src_oloc, const void *mesg_src, + H5O_loc_t *dst_oloc, void *mesg_dst, unsigned *mesg_flags, + H5O_copy_t *cpy_info); +static herr_t H5O__linfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__linfo_decode, /*decode message */ - H5O__linfo_encode, /*encode message */ - H5O__linfo_copy, /*copy the native value */ - H5O__linfo_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__linfo_free, /* free method */ - H5O__linfo_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__linfo_copy_file, /* copy native value to file */ - H5O__linfo_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__linfo_debug /*debug the message */ + H5O_LINFO_ID, /*message id number */ + "linfo", /*message name for debugging */ + sizeof(H5O_linfo_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__linfo_decode, /*decode message */ + H5O__linfo_encode, /*encode message */ + H5O__linfo_copy, /*copy the native value */ + H5O__linfo_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__linfo_free, /* free method */ + H5O__linfo_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__linfo_copy_file, /* copy native value to file */ + H5O__linfo_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__linfo_debug /*debug the message */ }}; /* Current version of link info information */ -#define H5O_LINFO_VERSION 0 +#define H5O_LINFO_VERSION 0 /* Flags for link info index flag encoding */ -#define H5O_LINFO_TRACK_CORDER 0x01 -#define H5O_LINFO_INDEX_CORDER 0x02 -#define H5O_LINFO_ALL_FLAGS (H5O_LINFO_TRACK_CORDER | H5O_LINFO_INDEX_CORDER) +#define H5O_LINFO_TRACK_CORDER 0x01 +#define H5O_LINFO_INDEX_CORDER 0x02 +#define H5O_LINFO_ALL_FLAGS (H5O_LINFO_TRACK_CORDER | H5O_LINFO_INDEX_CORDER) /* 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 */ + 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_linfo_postcopy_ud_t; /* Declare a free list to manage the H5O_linfo_t struct */ H5FL_DEFINE_STATIC(H5O_linfo_t); - /*------------------------------------------------------------------------- * Function: H5O__linfo_decode * @@ -110,13 +105,12 @@ 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) +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) { - H5O_linfo_t *linfo = NULL; /* Link info */ - unsigned char index_flags; /* Flags for encoding link index info */ - void *ret_value = NULL; /* Return value */ + H5O_linfo_t * linfo = NULL; /* Link info */ + unsigned char index_flags; /* Flags for encoding link index info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -125,16 +119,16 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_LINFO_VERSION) + 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))) + if (NULL == (linfo = H5FL_MALLOC(H5O_linfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the index flags for the group */ index_flags = *p++; - if(index_flags & ~H5O_LINFO_ALL_FLAGS) + if (index_flags & ~H5O_LINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") linfo->track_corder = (index_flags & H5O_LINFO_TRACK_CORDER) ? TRUE : FALSE; linfo->index_corder = (index_flags & H5O_LINFO_INDEX_CORDER) ? TRUE : FALSE; @@ -143,7 +137,7 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, linfo->nlinks = HSIZET_MAX; /* Max. link creation order value for the group, if tracked */ - if(linfo->track_corder) + if (linfo->track_corder) INT64DECODE(p, linfo->max_corder) else linfo->max_corder = 0; @@ -155,7 +149,7 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, 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) H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr)); else linfo->corder_bt2_addr = HADDR_UNDEF; @@ -164,14 +158,13 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = linfo; done: - if(ret_value == NULL) - if(linfo != NULL) + if (ret_value == NULL) + if (linfo != NULL) linfo = H5FL_FREE(H5O_linfo_t, linfo); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_encode * @@ -187,8 +180,8 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, static herr_t H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - unsigned char index_flags; /* Flags for encoding link index info */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + unsigned char index_flags; /* Flags for encoding link index info */ FUNC_ENTER_STATIC_NOERR @@ -203,10 +196,10 @@ H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* The flags for the link indices */ index_flags = (uint8_t)(linfo->track_corder ? H5O_LINFO_TRACK_CORDER : 0); index_flags = (uint8_t)(index_flags | (linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0)); - *p++ = index_flags; + *p++ = index_flags; /* Max. link creation order value for the group, if tracked */ - if(linfo->track_corder) + if (linfo->track_corder) INT64ENCODE(p, linfo->max_corder) /* Address of fractal heap to store "dense" links */ @@ -216,7 +209,7 @@ H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c H5F_addr_encode(f, &p, linfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of links, if they are indexed */ - if(linfo->index_corder) + if (linfo->index_corder) H5F_addr_encode(f, &p, linfo->corder_bt2_addr); else HDassert(!H5F_addr_defined(linfo->corder_bt2_addr)); @@ -224,7 +217,6 @@ H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__linfo_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_copy * @@ -242,15 +234,15 @@ H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c 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 */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + H5O_linfo_t * dest = (H5O_linfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(linfo); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_linfo_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_linfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ @@ -263,7 +255,6 @@ H5O__linfo_copy(const void *_mesg, void *_dest) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_size * @@ -282,23 +273,24 @@ H5O__linfo_copy(const void *_mesg, void *_dest) static size_t H5O__linfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = 1 /* Version */ - + 1 /* Index flags */ - + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ - + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ - + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ - + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ + ret_value = + 1 /* Version */ + + 1 /* Index flags */ + + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ + + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) + : 0); /* Address of v2 B-tree for indexing creation order values of links */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_size() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_free * @@ -323,7 +315,6 @@ H5O__linfo_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__linfo_free() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_delete * @@ -339,8 +330,8 @@ H5O__linfo_free(void *mesg) static herr_t H5O__linfo_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { - H5O_linfo_t *linfo = (H5O_linfo_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_linfo_t *linfo = (H5O_linfo_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -349,15 +340,14 @@ H5O__linfo_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) HDassert(linfo); /* If the group is using "dense" link storage, delete it */ - if(H5F_addr_defined(linfo->fheap_addr)) - if(H5G__dense_delete(f, linfo, TRUE) < 0) + if (H5F_addr_defined(linfo->fheap_addr)) + if (H5G__dense_delete(f, linfo, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free dense link storage") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_copy_file * @@ -374,13 +364,13 @@ H5O__linfo_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) */ static void * H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *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 *cpy_info, void *_udata) + 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; - H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *) _udata; - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -389,18 +379,18 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi HDassert(cpy_info); /* Copy the source message */ - if(NULL == (linfo_dst = (H5O_linfo_t *)H5O__linfo_copy(linfo_src, NULL))) + if (NULL == (linfo_dst = (H5O_linfo_t *)H5O__linfo_copy(linfo_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "memory allocation failed") /* If we are performing a 'shallow hierarchy' copy, and the links in this * group won't be included in the destination, reset the link info for * this group. */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) { - linfo_dst->nlinks = 0; - linfo_dst->max_corder = 0; - linfo_dst->fheap_addr = HADDR_UNDEF; - linfo_dst->name_bt2_addr = HADDR_UNDEF; + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) { + linfo_dst->nlinks = 0; + linfo_dst->max_corder = 0; + linfo_dst->fheap_addr = HADDR_UNDEF; + linfo_dst->name_bt2_addr = HADDR_UNDEF; linfo_dst->corder_bt2_addr = HADDR_UNDEF; } /* end if */ else { @@ -408,25 +398,24 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi /* (XXX: should probably get the "creation" parameters for the source group's * dense link storage components and use those - QAK) */ - if(H5F_addr_defined(linfo_src->fheap_addr)) { + if (H5F_addr_defined(linfo_src->fheap_addr)) { /* Create the dense link storage */ - if(H5G__dense_create(file_dst, linfo_dst, udata->common.src_pline) < 0) + if (H5G__dense_create(file_dst, linfo_dst, udata->common.src_pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create 'dense' form of new format group") } /* end if */ - } /* end else */ + } /* end else */ /* Set return value */ ret_value = linfo_dst; done: - if(!ret_value) - if(linfo_dst) + if (!ret_value) + if (linfo_dst) linfo_dst = H5FL_FREE(H5O_linfo_t, linfo_dst); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5O__linfo_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_post_copy_file_cb * @@ -444,10 +433,10 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi static herr_t H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) { - H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */ - H5O_link_t dst_lnk; /* Destination link to insert */ - hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */ + H5O_link_t dst_lnk; /* Destination link to insert */ + hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -456,7 +445,7 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) HDassert(udata); /* Copy the link (and the object it points to) */ - if(H5L__link_copy_file(udata->dst_oloc->file, src_lnk, udata->src_oloc, &dst_lnk, udata->cpy_info) < 0) + if (H5L__link_copy_file(udata->dst_oloc->file, src_lnk, udata->src_oloc, &dst_lnk, udata->cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy link") dst_lnk_init = TRUE; @@ -465,7 +454,7 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) /* Insert the new object in the destination file's group */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */ - if(H5G__dense_insert(udata->dst_oloc->file, udata->dst_linfo, &dst_lnk) < 0) + if (H5G__dense_insert(udata->dst_oloc->file, udata->dst_linfo, &dst_lnk) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") /* Reset metadata tag in API context */ @@ -473,13 +462,12 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) done: /* Check if the destination link has been initialized */ - if(dst_lnk_init) + if (dst_lnk_init) H5O_msg_reset(H5O_LINK_ID, &dst_lnk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__linfo_post_copy_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_post_copy_file * @@ -493,13 +481,12 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, - H5O_loc_t *dst_oloc, void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, + 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; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_linfo_t *linfo_src = (const H5O_linfo_t *)mesg_src; + H5O_linfo_t * linfo_dst = (H5O_linfo_t *)mesg_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -512,21 +499,22 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info); /* If we are performing a 'shallow hierarchy' copy, get out now */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) HGOTO_DONE(SUCCEED) /* Check for copying dense link storage */ - if(H5F_addr_defined(linfo_src->fheap_addr)) { - H5O_linfo_postcopy_ud_t udata; /* User data for iteration callback */ + if (H5F_addr_defined(linfo_src->fheap_addr)) { + H5O_linfo_postcopy_ud_t udata; /* User data for iteration callback */ /* Set up dense link iteration user data */ - udata.src_oloc = src_oloc; - udata.dst_oloc = dst_oloc; + udata.src_oloc = src_oloc; + udata.dst_oloc = dst_oloc; udata.dst_linfo = linfo_dst; - udata.cpy_info = cpy_info; + udata.cpy_info = cpy_info; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G__dense_iterate(src_oloc->file, linfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, H5O__linfo_post_copy_file_cb, &udata) < 0) + if (H5G__dense_iterate(src_oloc->file, linfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, + H5O__linfo_post_copy_file_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") } /* end if */ @@ -534,7 +522,6 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, FUNC_LEAVE_NOAPI(ret_value) } /* H5O__linfo_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__linfo_debug * @@ -548,10 +535,9 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_linfo_t *linfo = (const H5O_linfo_t *) _mesg; + const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -562,22 +548,19 @@ H5O__linfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Track creation order of links:", linfo->track_corder); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Index creation order of links:", linfo->index_corder); - HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of links:", linfo->nlinks); - HDfprintf(stream, "%*s%-*s %Hd\n", indent, "", fwidth, - "Max. creation order value:", linfo->max_corder); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage fractal heap address:", linfo->fheap_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage name index v2 B-tree address:", linfo->name_bt2_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "'Dense' link storage creation order index v2 B-tree address:", linfo->corder_bt2_addr); - + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Track creation order of links:", linfo->track_corder ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Index creation order of links:", linfo->index_corder ? "TRUE" : "FALSE"); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, "Number of links:", linfo->nlinks); + HDfprintf(stream, "%*s%-*s %" PRId64 "\n", indent, "", fwidth, + "Max. creation order value:", linfo->max_corder); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' link storage fractal heap address:", linfo->fheap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' link storage name index v2 B-tree address:", linfo->name_bt2_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "'Dense' link storage creation order index v2 B-tree address:", linfo->corder_bt2_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__linfo_debug() */ - diff --git a/src/H5Olink.c b/src/H5Olink.c index d2a034d37c5..75456f4449f 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,84 +22,79 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#define H5L_FRIEND /*suppress error about including H5Lpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#define H5L_FRIEND /*suppress error about including H5Lpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_link_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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, 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); -static herr_t H5O__link_debug(H5F_t *f, const void *_mesg, FILE *stream, - int indent, int fwidth); +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, + 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); +static herr_t H5O__link_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__link_decode, /*decode message */ - H5O_link_encode, /*encode message */ - H5O_link_copy, /*copy the native value */ - H5O_link_size, /*size of symbol table entry */ - H5O__link_reset, /* reset method */ - H5O__link_free, /* free method */ - H5O_link_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_link_pre_copy_file, /* pre copy native value to file */ - H5O__link_copy_file, /* copy native value to file */ - H5O__link_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__link_debug /*debug the message */ + H5O_LINK_ID, /*message id number */ + "link", /*message name for debugging */ + sizeof(H5O_link_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__link_decode, /*decode message */ + H5O__link_encode, /*encode message */ + H5O__link_copy, /*copy the native value */ + H5O__link_size, /*size of symbol table entry */ + H5O__link_reset, /* reset method */ + H5O__link_free, /* free method */ + H5O_link_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O__link_pre_copy_file, /* pre copy native value to file */ + H5O__link_copy_file, /* copy native value to file */ + H5O__link_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__link_debug /*debug the message */ }}; /* Current version of link information */ -#define H5O_LINK_VERSION 1 +#define H5O_LINK_VERSION 1 /* Flags for link flag encoding */ -#define H5O_LINK_NAME_SIZE 0x03 /* 2-bit field for size of name length */ -#define H5O_LINK_STORE_CORDER 0x04 /* Whether to store creation index */ -#define H5O_LINK_STORE_LINK_TYPE 0x08 /* Whether to store non-default link type */ -#define H5O_LINK_STORE_NAME_CSET 0x10 /* Whether to store non-default name character set */ -#define H5O_LINK_ALL_FLAGS (H5O_LINK_NAME_SIZE | H5O_LINK_STORE_CORDER | H5O_LINK_STORE_LINK_TYPE | H5O_LINK_STORE_NAME_CSET) +#define H5O_LINK_NAME_SIZE 0x03 /* 2-bit field for size of name length */ +#define H5O_LINK_STORE_CORDER 0x04 /* Whether to store creation index */ +#define H5O_LINK_STORE_LINK_TYPE 0x08 /* Whether to store non-default link type */ +#define H5O_LINK_STORE_NAME_CSET 0x10 /* Whether to store non-default name character set */ +#define H5O_LINK_ALL_FLAGS \ + (H5O_LINK_NAME_SIZE | H5O_LINK_STORE_CORDER | H5O_LINK_STORE_LINK_TYPE | H5O_LINK_STORE_NAME_CSET) /* Individual definitions of name size values */ -#define H5O_LINK_NAME_1 0x00 /* Use 1-byte value for name length */ -#define H5O_LINK_NAME_2 0x01 /* Use 2-byte value for name length */ -#define H5O_LINK_NAME_4 0x02 /* Use 4-byte value for name length */ -#define H5O_LINK_NAME_8 0x03 /* Use 8-byte value for name length */ +#define H5O_LINK_NAME_1 0x00 /* Use 1-byte value for name length */ +#define H5O_LINK_NAME_2 0x01 /* Use 2-byte value for name length */ +#define H5O_LINK_NAME_4 0x02 /* Use 4-byte value for name length */ +#define H5O_LINK_NAME_8 0x03 /* Use 8-byte value for name length */ /* Declare a free list to manage the H5O_link_t struct */ H5FL_DEFINE_STATIC(H5O_link_t); - /*------------------------------------------------------------------------- * Function: H5O__link_decode * @@ -116,15 +111,14 @@ H5FL_DEFINE_STATIC(H5O_link_t); *------------------------------------------------------------------------- */ 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_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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -133,86 +127,86 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(*p++ != H5O_LINK_VERSION) + if (*p++ != H5O_LINK_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (lnk = H5FL_CALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (lnk = H5FL_CALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the encoding flags for the link */ link_flags = *p++; - if(link_flags & ~H5O_LINK_ALL_FLAGS) + if (link_flags & ~H5O_LINK_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") /* Check for non-default link type */ - if(link_flags & H5O_LINK_STORE_LINK_TYPE) { + if (link_flags & H5O_LINK_STORE_LINK_TYPE) { /* Get the type of the link */ lnk->type = (H5L_type_t)*p++; - if(lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad link type") } /* end if */ else lnk->type = H5L_TYPE_HARD; /* Get the link creation time from the file */ - if(link_flags & H5O_LINK_STORE_CORDER) { + if (link_flags & H5O_LINK_STORE_CORDER) { INT64DECODE(p, lnk->corder) lnk->corder_valid = TRUE; } /* end if */ else { - lnk->corder = 0; + lnk->corder = 0; lnk->corder_valid = FALSE; } /* end else */ /* Check for non-default name character set */ - if(link_flags & H5O_LINK_STORE_NAME_CSET) { + if (link_flags & H5O_LINK_STORE_NAME_CSET) { /* Get the link name's character set */ lnk->cset = (H5T_cset_t)*p++; - if(lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) + if (lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad cset type") } /* end if */ else lnk->cset = H5T_CSET_ASCII; /* Get the length of the link's name */ - switch(link_flags & H5O_LINK_NAME_SIZE) { - case 0: /* 1 byte size */ + switch (link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ len = *p++; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16DECODE(p, len); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32DECODE(p, len); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64DECODE(p, len); break; default: HDassert(0 && "bad size for name"); } /* end switch */ - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid name length") /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") /* Get the link's name */ - if(NULL == (lnk->name = (char *)H5MM_malloc(len + 1))) + if (NULL == (lnk->name = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->name, p, len); lnk->name[len] = '\0'; p += len; /* Get the appropriate information for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: /* Get the address of the object the link points to */ H5F_addr_decode(f, &p, &(lnk->u.hard.addr)); @@ -221,15 +215,15 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5L_TYPE_SOFT: /* Get the link value */ UINT16DECODE(p, len) - if(len == 0) + if (len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid link length") /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") - if(NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1))) + if (NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.soft.name, p, len); lnk->u.soft.name[len] = '\0'; @@ -241,20 +235,19 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, case H5L_TYPE_ERROR: case H5L_TYPE_MAX: default: - if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) + if (lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown link type") /* A UD link. Get the user-supplied data */ UINT16DECODE(p, len) lnk->u.ud.size = len; - if(len > 0) - { + if (len > 0) { /* Make sure that length doesn't exceed buffer size, which could occur when the file is corrupted */ - if(p + len > p_end) + if (p + len > p_end) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") - if(NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len))) + if (NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.ud.udata, p, len); p += len; @@ -267,13 +260,13 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = lnk; done: - if(ret_value == NULL) - if(lnk != NULL) { - if(lnk->name != NULL) + if (ret_value == NULL) + if (lnk != NULL) { + if (lnk->name != NULL) H5MM_xfree(lnk->name); - if(lnk->type == H5L_TYPE_SOFT && lnk->u.soft.name != NULL) + if (lnk->type == H5L_TYPE_SOFT && lnk->u.soft.name != NULL) H5MM_xfree(lnk->u.soft.name); - if(lnk->type >= H5L_TYPE_UD_MIN && lnk->u.ud.size > 0 && lnk->u.ud.udata != NULL) + if (lnk->type >= H5L_TYPE_UD_MIN && lnk->u.ud.size > 0 && lnk->u.ud.udata != NULL) H5MM_xfree(lnk->u.ud.udata); lnk = H5FL_FREE(H5O_link_t, lnk); } /* end if */ @@ -281,9 +274,8 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_link_encode + * Function: H5O__link_encode * * Purpose: Encodes a link message. * @@ -295,13 +287,13 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - uint64_t len; /* Length of a string in the message */ - unsigned char link_flags; /* Flags for encoding link info */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + uint64_t len; /* Length of a string in the message */ + unsigned char link_flags; /* Flags for encoding link info */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -316,46 +308,46 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con *p++ = H5O_LINK_VERSION; /* The encoding flags for the link */ - if(len > 4294967295) + if (len > 4294967295) link_flags = H5O_LINK_NAME_8; - else if(len > 65535) + else if (len > 65535) link_flags = H5O_LINK_NAME_4; - else if(len > 255) + else if (len > 255) link_flags = H5O_LINK_NAME_2; else link_flags = H5O_LINK_NAME_1; link_flags = (unsigned char)(link_flags | (lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0)); link_flags = (unsigned char)(link_flags | ((lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0)); link_flags = (unsigned char)(link_flags | ((lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0)); - *p++ = link_flags; + *p++ = link_flags; /* Store the type of a non-default link */ - if(link_flags & H5O_LINK_STORE_LINK_TYPE) + if (link_flags & H5O_LINK_STORE_LINK_TYPE) *p++ = (uint8_t)lnk->type; /* Store the link creation order in the file, if its valid */ - if(lnk->corder_valid) + if (lnk->corder_valid) INT64ENCODE(p, lnk->corder) /* Store a non-default link name character set */ - if(link_flags & H5O_LINK_STORE_NAME_CSET) + if (link_flags & H5O_LINK_STORE_NAME_CSET) *p++ = (uint8_t)lnk->cset; /* Store the link name's length */ - switch(link_flags & H5O_LINK_NAME_SIZE) { - case 0: /* 1 byte size */ + switch (link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ *p++ = (uint8_t)len; break; - case 1: /* 2 byte size */ + case 1: /* 2 byte size */ UINT16ENCODE(p, len); break; - case 2: /* 4 byte size */ + case 2: /* 4 byte size */ UINT32ENCODE(p, len); break; - case 3: /* 8 byte size */ + case 3: /* 8 byte size */ UINT64ENCODE(p, len); break; @@ -368,7 +360,7 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con p += len; /* Store the appropriate information for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: /* Store the address of the object the link points to */ H5F_addr_encode(f, &p, lnk->u.hard.addr); @@ -393,20 +385,18 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con /* Store the user-supplied data, however long it is */ len = (uint16_t)lnk->u.ud.size; UINT16ENCODE(p, len) - if(len > 0) - { + if (len > 0) { H5MM_memcpy(p, lnk->u.ud.udata, (size_t)len); - p+=len; + p += len; } break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_link_encode() */ +} /* end H5O__link_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_link_copy + * Function: H5O__link_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -421,58 +411,57 @@ H5O_link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con *------------------------------------------------------------------------- */ static void * -H5O_link_copy(const void *_mesg, void *_dest) +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 */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + H5O_link_t * dest = (H5O_link_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(lnk); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy static information */ *dest = *lnk; /* Duplicate the link's name */ HDassert(lnk->name); - if(NULL == (dest->name = H5MM_xstrdup(lnk->name))) + if (NULL == (dest->name = H5MM_xstrdup(lnk->name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't duplicate link name") /* Copy other information needed for different link types */ - if(lnk->type == H5L_TYPE_SOFT) { - if(NULL == (dest->u.soft.name = H5MM_xstrdup(lnk->u.soft.name))) + if (lnk->type == H5L_TYPE_SOFT) { + if (NULL == (dest->u.soft.name = H5MM_xstrdup(lnk->u.soft.name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't duplicate soft link value") } /* end if */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->u.ud.size > 0) { - if(NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size))) + else if (lnk->type >= H5L_TYPE_UD_MIN) { + if (lnk->u.ud.size > 0) { + if (NULL == (dest->u.ud.udata = H5MM_malloc(lnk->u.ud.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(dest->u.ud.udata, lnk->u.ud.udata, lnk->u.ud.size); } /* end if */ - } /* end if */ + } /* end if */ /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest) { - if(dest->name && dest->name != lnk->name) + if (NULL == ret_value) + if (dest) { + if (dest->name && dest->name != lnk->name) dest->name = (char *)H5MM_xfree(dest->name); - if(NULL == _dest) - dest = H5FL_FREE(H5O_link_t ,dest); + if (NULL == _dest) + dest = H5FL_FREE(H5O_link_t, dest); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_link_copy() */ +} /* end H5O__link_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_link_size + * Function: H5O__link_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -488,14 +477,14 @@ H5O_link_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; - uint64_t name_len; /* Length of name */ - size_t name_size; /* Size of encoded name length */ - size_t ret_value = 0; /* Return value */ + uint64_t name_len; /* Length of name */ + size_t name_size; /* Size of encoded name length */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDcompile_assert(sizeof(uint64_t) >= sizeof(size_t)); @@ -504,33 +493,33 @@ H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void name_len = (uint64_t)HDstrlen(lnk->name); /* Determine correct value for name size bits */ - if(name_len > 4294967295) + if (name_len > 4294967295) name_size = 8; - else if(name_len > 65535) + else if (name_len > 65535) name_size = 4; - else if(name_len > 255) + else if (name_len > 255) name_size = 2; else name_size = 1; /* Set return value */ - ret_value = 1 + /* Version */ - 1 + /* Link encoding flags */ + ret_value = 1 + /* Version */ + 1 + /* Link encoding flags */ (lnk->type != H5L_TYPE_HARD ? (size_t)1 : 0) + /* Link type */ - (lnk->corder_valid ? 8 : 0) + /* Creation order */ - (lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */ - name_size + /* Name length */ - name_len; /* Name */ + (lnk->corder_valid ? 8 : 0) + /* Creation order */ + (lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */ + name_size + /* Name length */ + name_len; /* Name */ /* Add the appropriate length for each type of link */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: ret_value += H5F_SIZEOF_ADDR(f); break; case H5L_TYPE_SOFT: - ret_value += 2 + /* Link value length */ - HDstrlen(lnk->u.soft.name); /* Link value */ + ret_value += 2 + /* Link value length */ + HDstrlen(lnk->u.soft.name); /* Link value */ break; case H5L_TYPE_ERROR: @@ -538,15 +527,14 @@ H5O_link_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void case H5L_TYPE_MAX: default: /* Default is user-defined link type */ HDassert(lnk->type >= H5L_TYPE_UD_MIN); - ret_value += 2 + /* User-defined data size */ - lnk->u.ud.size; /* User-defined data */ + ret_value += 2 + /* User-defined data size */ + lnk->u.ud.size; /* User-defined data */ break; } /* end switch */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_link_size() */ +} /* end H5O__link_size() */ - /*------------------------------------------------------------------------- * Function: H5O__link_reset * @@ -567,12 +555,12 @@ H5O__link_reset(void *_mesg) FUNC_ENTER_STATIC_NOERR - if(lnk) { + if (lnk) { /* Free information for link (but don't free link pointer) */ - if(lnk->type == H5L_TYPE_SOFT) + if (lnk->type == H5L_TYPE_SOFT) lnk->u.soft.name = (char *)H5MM_xfree(lnk->u.soft.name); else if (lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->u.ud.size > 0) + if (lnk->u.ud.size > 0) lnk->u.ud.udata = H5MM_xfree(lnk->u.ud.udata); } /* end if */ lnk->name = (char *)H5MM_xfree(lnk->name); @@ -581,7 +569,6 @@ H5O__link_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__link_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__link_free * @@ -608,7 +595,6 @@ H5O__link_free(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__link_free() */ - /*------------------------------------------------------------------------- * Function: H5O_link_delete * @@ -624,8 +610,9 @@ H5O__link_free(void *_mesg) herr_t H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { - H5O_link_t *lnk = (H5O_link_t *)_mesg; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t *lnk = (H5O_link_t *)_mesg; + hid_t file_id = -1; /* ID for the file the link is located in (passed to user callback) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -635,7 +622,7 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) /* Check for adjusting the link count when the link is removed */ /* Adjust the reference count of the object when a hard link is removed */ - if(lnk->type == H5L_TYPE_HARD) { + if (lnk->type == H5L_TYPE_HARD) { H5O_loc_t oloc; /* Construct object location for object, in order to decrement it's ref count */ @@ -645,44 +632,39 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) oloc.addr = lnk->u.hard.addr; /* Decrement the ref count for the object */ - if(H5O_link(&oloc, -1) < 0) + if (H5O_link(&oloc, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to decrement object link count") } /* end if */ /* Perform the "delete" callback when a user-defined link is removed */ - else if(lnk->type >= H5L_TYPE_UD_MIN) { - const H5L_class_t *link_class; /* User-defined link class */ + else if (lnk->type >= H5L_TYPE_UD_MIN) { + const H5L_class_t *link_class; /* User-defined link class */ /* Get the link class for this type of link. */ - if(NULL == (link_class = H5L_find_class(lnk->type))) + if (NULL == (link_class = H5L_find_class(lnk->type))) HGOTO_ERROR(H5E_OHDR, H5E_NOTREGISTERED, FAIL, "link class not registered") /* Check for delete callback */ - if(link_class->del_func) { - hid_t file_id; /* ID for the file the link is located in (passed to user callback) */ - + if (link_class->del_func) { /* Get a file ID for the file the link is in */ - if((file_id = H5F_get_id(f, FALSE)) < 0) + if ((file_id = H5F_get_id(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get file ID") /* Call user-defined link's 'delete' callback */ - if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) { - H5I_dec_ref(file_id); + if ((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure") - } /* end if */ - - /* Release the file ID */ - if(H5I_dec_ref(file_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") } /* end if */ - } /* end if */ + } /* end if */ done: + /* Release the file ID */ + if (file_id > 0 && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_delete() */ - /*------------------------------------------------------------------------- - * Function: H5O_link_pre_copy_file + * Function: H5O__link_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files for link messages. @@ -697,10 +679,10 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, + hbool_t *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(deleted); @@ -711,13 +693,12 @@ H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED * in the destination object header before performing any other actions * on it. */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) *deleted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_link_pre_copy_file() */ +} /* end H5O__link_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_copy_file * @@ -734,11 +715,11 @@ H5O_link_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED */ static void * H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_ATTR_UNUSED *file_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, + 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 */ + H5O_link_t *link_src = (H5O_link_t *)native_src; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -748,19 +729,18 @@ H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_A HDassert(cpy_info->max_depth < 0 || cpy_info->curr_depth < cpy_info->max_depth); /* Sanity check source link type */ - if(link_src->type > H5L_TYPE_SOFT && link_src->type < H5L_TYPE_UD_MIN) + if (link_src->type > H5L_TYPE_SOFT && link_src->type < H5L_TYPE_UD_MIN) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "unrecognized built-in link type") /* Allocate "blank" link for destination */ /* (values will be filled in during 'post copy' operation) */ - if(NULL == (ret_value = H5FL_CALLOC(H5O_link_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (ret_value = H5FL_CALLOC(H5O_link_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__link_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_post_copy_file * @@ -774,13 +754,12 @@ H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_A *------------------------------------------------------------------------- */ 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 H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, + 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; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_link_t *link_src = (const H5O_link_t *)mesg_src; + H5O_link_t * link_dst = (H5O_link_t *)mesg_dst; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -794,14 +773,13 @@ H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info->max_depth < 0 || cpy_info->curr_depth < cpy_info->max_depth); /* Copy the link (and the object it points to) */ - if(H5L__link_copy_file(dst_oloc->file, link_src, src_oloc, link_dst, cpy_info) < 0) + if (H5L__link_copy_file(dst_oloc->file, link_src, src_oloc, link_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy link") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__link_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__link_debug * @@ -815,11 +793,10 @@ H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -830,52 +807,51 @@ H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Link Type:", (lnk->type == H5L_TYPE_HARD ? "Hard" : - (lnk->type == H5L_TYPE_SOFT ? "Soft" : - (lnk->type == H5L_TYPE_EXTERNAL ? "External" : - (lnk->type >= H5L_TYPE_UD_MIN ? "User-defined" : "Unknown"))))); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Type:", + (lnk->type == H5L_TYPE_HARD + ? "Hard" + : (lnk->type == H5L_TYPE_SOFT + ? "Soft" + : (lnk->type == H5L_TYPE_EXTERNAL + ? "External" + : (lnk->type >= H5L_TYPE_UD_MIN ? "User-defined" : "Unknown"))))); - if(lnk->corder_valid) - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Creation Order:", lnk->corder); + if (lnk->corder_valid) + HDfprintf(stream, "%*s%-*s %" PRId64 "\n", indent, "", fwidth, "Creation Order:", lnk->corder); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Link Name Character Set:", (lnk->cset == H5T_CSET_ASCII ? - "ASCII" : (lnk->cset == H5T_CSET_UTF8 ? "UTF-8" : "Unknown"))); - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, - "Link Name:", lnk->name); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Name Character Set:", + (lnk->cset == H5T_CSET_ASCII ? "ASCII" : (lnk->cset == H5T_CSET_UTF8 ? "UTF-8" : "Unknown"))); + HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, "Link Name:", lnk->name); /* Display link-specific information */ - switch(lnk->type) { + switch (lnk->type) { case H5L_TYPE_HARD: - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Object address:", lnk->u.hard.addr); break; case H5L_TYPE_SOFT: - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, - "Link Value:", lnk->u.soft.name); + HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, "Link Value:", lnk->u.soft.name); break; case H5L_TYPE_ERROR: case H5L_TYPE_EXTERNAL: case H5L_TYPE_MAX: default: - if(lnk->type >= H5L_TYPE_UD_MIN) { - if(lnk->type == H5L_TYPE_EXTERNAL) { - const char *objname = (const char *)lnk->u.ud.udata + (HDstrlen((const char *)lnk->u.ud.udata) + 1); + if (lnk->type >= H5L_TYPE_UD_MIN) { + if (lnk->type == H5L_TYPE_EXTERNAL) { + const char *objname = + (const char *)lnk->u.ud.udata + (HDstrlen((const char *)lnk->u.ud.udata) + 1); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "External File Name:", lnk->u.ud.udata); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "External Object Name:", objname); + "External File Name:", (const char *)lnk->u.ud.udata); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "External Object Name:", objname); } /* end if */ else { - HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "User-Defined Link Size:", lnk->u.ud.size); } /* end else */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") break; @@ -884,4 +860,3 @@ H5O__link_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__link_debug() */ - diff --git a/src/H5Omessage.c b/src/H5Omessage.c index ef9332f4355..15edf1e2bc8 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,75 +26,64 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* User data for iteration while removing a message */ typedef struct { - 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 */ - hbool_t adj_link; /* Whether to adjust links when removing messages */ + 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 */ + hbool_t adj_link; /* Whether to adjust links when removing messages */ } H5O_iter_rm_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5O__msg_reset_real(const H5O_msg_class_t *type, void *native); -static herr_t H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_modified, void *_udata/*in,out*/); -static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, - const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, - unsigned update_flags); - +static herr_t H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_modified, void *_udata /*in,out*/); +static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, + unsigned mesg_flags, unsigned update_flags); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5O_msg_create * @@ -110,11 +99,10 @@ static herr_t H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, *------------------------------------------------------------------------- */ herr_t -H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsigned update_flags, void *mesg) { - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -125,21 +113,20 @@ H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, HDassert(mesg); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Go append message to object header */ - if(H5O_msg_append_oh(loc->file, oh, type_id, mesg_flags, update_flags, mesg) < 0) + if (H5O_msg_append_oh(loc->file, oh, type_id, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to append to object header") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_create() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_append_oh * @@ -157,33 +144,32 @@ H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, *------------------------------------------------------------------------- */ herr_t -H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, unsigned update_flags, + void *mesg) { - const H5O_msg_class_t *type; /* Original H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Original H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(oh); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); HDassert(mesg); /* Append new message to object header */ - if(H5O__msg_append_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_append_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new message in header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_append_oh() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_append_real * @@ -199,11 +185,11 @@ H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, *------------------------------------------------------------------------- */ herr_t -H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg) { - size_t idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -215,21 +201,20 @@ H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(mesg); /* Allocate space for a new message */ - if(H5O__msg_alloc(f, oh, type, &mesg_flags, mesg, &idx) < 0) + if (H5O__msg_alloc(f, oh, type, &mesg_flags, mesg, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create new message") /* Copy the information for the message */ - if(H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) + if (H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to write message") #ifdef H5O_DEBUG -H5O_assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_append_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_write * @@ -250,12 +235,11 @@ H5O_assert(oh); *------------------------------------------------------------------------- */ herr_t -H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -263,29 +247,28 @@ H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" modify routine */ - if(H5O__msg_write_real(loc->file, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_write_real(loc->file, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_write() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_write_oh * @@ -305,33 +288,32 @@ H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, *------------------------------------------------------------------------- */ herr_t -H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg) +H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, unsigned update_flags, + void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(oh->cache_info.addr, FAIL) /* check args */ HDassert(f); HDassert(oh); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Call the "real" modify routine */ - if(H5O__msg_write_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) + if (H5O__msg_write_real(f, oh, type, mesg_flags, update_flags, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_write_oh() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_write_real * @@ -352,12 +334,12 @@ H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, *------------------------------------------------------------------------- */ herr_t -H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg) +H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg) { - H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - size_t idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *idx_msg; /* Pointer to message to modify */ + size_t idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -370,22 +352,22 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); /* Locate message of correct type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(type == idx_msg->type) + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (type == idx_msg->type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Check for modifying a constant message */ - if(!(update_flags & H5O_UPDATE_FORCE) && (idx_msg->flags & H5O_MSG_FLAG_CONSTANT)) + if (!(update_flags & H5O_UPDATE_FORCE) && (idx_msg->flags & H5O_MSG_FLAG_CONSTANT)) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message") /* This message is shared, but it's being modified. */ - else if((idx_msg->flags & H5O_MSG_FLAG_SHARED) || (idx_msg->flags & H5O_MSG_FLAG_SHAREABLE)) { - htri_t status; /* Status of "try share" call */ + else if ((idx_msg->flags & H5O_MSG_FLAG_SHARED) || (idx_msg->flags & H5O_MSG_FLAG_SHAREABLE)) { + htri_t status; /* Status of "try share" call */ - /* First, sanity check to make sure it's not a committed message; - * these can't ever be modified. - */ + /* First, sanity check to make sure it's not a committed message; + * these can't ever be modified. + */ HDassert(((H5O_shared_t *)idx_msg->native)->type != H5O_SHARE_TYPE_COMMITTED); /* Also, sanity check that a message doesn't switch status from being @@ -401,7 +383,7 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * the location of the object changes (from in another object's * header to the SOHM heap), so just delete it first -QAK) */ - if(H5SM_delete(f, oh, (H5O_shared_t *)idx_msg->native) < 0) + if (H5SM_delete(f, oh, (H5O_shared_t *)idx_msg->native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete message from SOHM index") /* If we're replacing a shared message, the new message must be shared @@ -411,24 +393,24 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, * XXX: This doesn't handle freeing extra space in object header from * a message shrinking. */ - if((status = H5SM_try_share(f, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), 0, idx_msg->type->id, mesg, &mesg_flags)) < 0) + if ((status = H5SM_try_share(f, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), 0, + idx_msg->type->id, mesg, &mesg_flags)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message") - if(status == FALSE && (mesg_flags & H5O_MSG_FLAG_SHARED)) + if (status == FALSE && (mesg_flags & H5O_MSG_FLAG_SHARED)) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "message changed sharing status") } /* end if */ /* Copy the information for the message */ - if(H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) + if (H5O__copy_mesg(f, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") #ifdef H5O_DEBUG -H5O_assert(oh); + H5O__assert(oh); #endif /* H5O_DEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_write_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_read * @@ -454,8 +436,8 @@ H5O_assert(oh); 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 */ + H5O_t *oh = NULL; /* Object header to use */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -466,21 +448,20 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) HDassert(type_id < NELMTS(H5O_msg_class_g)); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") /* Call the "real" read routine */ - if(NULL == (ret_value = H5O_msg_read_oh(loc->file, oh, type_id, mesg))) + if (NULL == (ret_value = H5O_msg_read_oh(loc->file, oh, type_id, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header message") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && 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_msg_read() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_read_oh * @@ -506,9 +487,9 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) void * 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; + 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; FUNC_ENTER_NOAPI_NOINIT @@ -516,14 +497,14 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) HDassert(f); HDassert(oh); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Scan through the messages looking for the right one */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(type == oh->mesg[idx].type) + for (idx = 0; idx < oh->nmesgs; idx++) + if (type == oh->mesg[idx].type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "message type not found") /* @@ -537,14 +518,13 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) * the raw message) so we must copy the native message before * returning. */ - if(NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg))) + if (NULL == (ret_value = (type->copy)(oh->mesg[idx].native, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_read_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_reset * @@ -562,25 +542,24 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) herr_t H5O_msg_reset(unsigned type_id, void *native) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" reset routine */ - if(H5O__msg_reset_real(type, native) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "unable to reset object header") + if (H5O__msg_reset_real(type, native) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "unable to reset object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_reset_real * @@ -598,16 +577,16 @@ H5O_msg_reset(unsigned type_id, void *native) static herr_t H5O__msg_reset_real(const H5O_msg_class_t *type, void *native) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(type); - if(native) { - if(type->reset) { - if((type->reset)(native) < 0) + if (native) { + if (type->reset) { + if ((type->reset)(native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "reset method failed") } /* end if */ else @@ -618,7 +597,6 @@ H5O__msg_reset_real(const H5O_msg_class_t *type, void *native) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_reset_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_free * @@ -637,27 +615,26 @@ H5O__msg_reset_real(const H5O_msg_class_t *type, void *native) 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 */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the "real" free routine */ - ret_value = H5O__msg_free_real(type, mesg); + ret_value = H5O_msg_free_real(type, mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_free() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_free_mesg * - * Purpose: Call H5O__msg_free_real() on a message. + * Purpose: Call H5O_msg_free_real() on a message. * * Return: Non-negative on success/Negative on failure * @@ -675,14 +652,13 @@ H5O__msg_free_mesg(H5O_mesg_t *mesg) HDassert(mesg); /* Free any native information */ - mesg->native = H5O__msg_free_real(mesg->type, mesg->native); + mesg->native = H5O_msg_free_real(mesg->type, mesg->native); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__msg_free_mesg() */ - /*------------------------------------------------------------------------- - * Function: H5O__msg_free_real + * Function: H5O_msg_free_real * * Purpose: Similar to H5O_msg_reset() except it also frees the message * pointer. @@ -696,25 +672,24 @@ H5O__msg_free_mesg(H5O_mesg_t *mesg) *------------------------------------------------------------------------- */ void * -H5O__msg_free_real(const H5O_msg_class_t *type, void *msg_native) +H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) { - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_NOAPI_NOINIT_NOERR /* check args */ HDassert(type); - if(msg_native) { + if (msg_native) { H5O__msg_reset_real(type, msg_native); - if(NULL != (type->free)) + if (NULL != (type->free)) (type->free)(msg_native); else H5MM_xfree(msg_native); } /* end if */ FUNC_LEAVE_NOAPI(NULL) -} /* end H5O__msg_free_real() */ +} /* end H5O_msg_free_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_copy * @@ -733,26 +708,25 @@ H5O__msg_free_real(const H5O_msg_class_t *type, void *msg_native) 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 */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(mesg); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Call the message class's copy routine */ - if(NULL == (ret_value = (type->copy)(mesg, dst))) + if (NULL == (ret_value = (type->copy)(mesg, dst))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_copy() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_count * @@ -771,10 +745,10 @@ 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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned msg_count; /* Message count */ - int ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -783,27 +757,26 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Count the messages of the correct type */ - msg_count = H5O_msg_count_real(oh, type); + msg_count = H5O__msg_count_real(oh, type); H5_CHECKED_ASSIGN(ret_value, int, msg_count, unsigned); done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_count() */ - /*------------------------------------------------------------------------- - * Function: H5O_msg_count_real + * Function: H5O__msg_count_real * * Purpose: Counts the number of messages in an object header which are a * certain type. @@ -818,26 +791,25 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) *------------------------------------------------------------------------- */ unsigned -H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) +H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) { - unsigned u; /* Local index variable */ - unsigned ret_value = 0; /* Return value */ + unsigned u; /* Local index variable */ + unsigned ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(oh); HDassert(type); /* Loop over all messages, counting the ones of the type looked for */ - for(u = ret_value = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].type == type) + for (u = ret_value = 0; u < oh->nmesgs; u++) + if (oh->mesg[u].type == type) ret_value++; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_msg_count_real() */ +} /* end H5O__msg_count_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_exists * @@ -859,8 +831,8 @@ H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type) htri_t H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) { - H5O_t *oh = NULL; /* Object header for location */ - htri_t ret_value = FAIL; /* Return value */ + H5O_t *oh = NULL; /* Object header for location */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -869,21 +841,20 @@ H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) HDassert(type_id < NELMTS(H5O_msg_class_g)); /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Call the "real" exists routine */ - if((ret_value = H5O_msg_exists_oh(oh, type_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message") + if ((ret_value = H5O_msg_exists_oh(oh, type_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_exists() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_exists_oh * @@ -905,27 +876,26 @@ H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) htri_t H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned u; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(oh); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Scan through the messages looking for the right one */ - for(u = 0; u < oh->nmesgs; u++) - if(type == oh->mesg[u].type) + for (u = 0; u < oh->nmesgs; u++) + if (type == oh->mesg[u].type) HGOTO_DONE(TRUE) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_exists_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_remove * @@ -948,9 +918,9 @@ 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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -958,27 +928,26 @@ H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" remove routine */ - if((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, NULL, NULL, adj_link)) < 0) + if ((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, NULL, NULL, adj_link)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_remove_op * @@ -996,12 +965,12 @@ H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj *------------------------------------------------------------------------- */ 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_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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -1009,27 +978,26 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); - HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc))) + if (NULL == (oh = H5O_pin(loc))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") /* Call the "real" remove routine */ - if((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, op, op_data, adj_link)) < 0) + if ((ret_value = H5O__msg_remove_real(loc->file, oh, type, sequence, op, op_data, adj_link)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to remove object header message") done: - if(oh && H5O_unpin(oh) < 0) + if (oh && H5O_unpin(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove_op() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_remove_cb * @@ -1045,12 +1013,12 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, *------------------------------------------------------------------------- */ static herr_t -H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned *oh_modified, void *_udata/*in,out*/) +H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, unsigned *oh_modified, + void *_udata /*in,out*/) { - H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ - htri_t try_remove = FALSE; /* Whether to try removing a message */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + htri_t try_remove = FALSE; /* Whether to try removing a message */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -1058,33 +1026,34 @@ H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(mesg); /* Check for callback routine */ - if(udata->op) { + if (udata->op) { /* Call the iterator callback */ - if((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "object header message deletion callback failed") + if ((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, + "object header message deletion callback failed") } /* end if */ else { /* If there's no callback routine, does the sequence # match? */ - if((int)sequence == udata->sequence || H5O_ALL == udata->sequence) + if ((int)sequence == udata->sequence || H5O_ALL == udata->sequence) try_remove = TRUE; } /* end else */ /* Try removing the message, if indicated */ - if(try_remove) { + if (try_remove) { /* * Keep track of how many times we failed trying to remove constant * messages. * (OK to remove constant messages - QAK) */ /* Convert message into a null message */ - if(H5O_release_mesg(udata->f, oh, mesg, udata->adj_link) < 0) + if (H5O__release_mesg(udata->f, oh, mesg, udata->adj_link) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to release message") /* Indicate that the object header was modified */ *oh_modified = H5O_MODIFY_CONDENSE; /* Break out now, if we've found the correct message */ - if(udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) + if (udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) HGOTO_DONE(H5_ITER_STOP) } /* end if */ @@ -1092,7 +1061,6 @@ H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_remove_cb() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_remove_real * @@ -1110,12 +1078,12 @@ H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, *------------------------------------------------------------------------- */ herr_t -H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - int sequence, H5O_operator_t app_op, void *op_data, hbool_t adj_link) +H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int sequence, H5O_operator_t app_op, + void *op_data, hbool_t adj_link) { - H5O_iter_rm_t udata; /* User data for iterator */ - H5O_mesg_operator_t op; /* Wrapper for operator */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_iter_rm_t udata; /* User data for iterator */ + H5O_mesg_operator_t op; /* Wrapper for operator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1125,32 +1093,31 @@ H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(type); /* Make certain we are allowed to modify the file */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") + if (0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") /* Set up iterator operator data */ - udata.f = f; + udata.f = f; udata.sequence = sequence; - udata.nfailed = 0; - udata.op = app_op; - udata.op_data = op_data; + udata.nfailed = 0; + udata.op = app_op; + udata.op_data = op_data; udata.adj_link = adj_link; /* Iterate over the messages, deleting appropriate one(s) */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5O__msg_remove_cb; - if(H5O__msg_iterate_real(f, oh, type, &op, &udata) < 0) + if (H5O__msg_iterate_real(f, oh, type, &op, &udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "error iterating over messages") /* Fail if we tried to remove any constant messages */ - if(udata.nfailed) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)") + if (udata.nfailed) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_remove_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_iterate * @@ -1182,12 +1149,11 @@ H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ herr_t -H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, - const H5O_mesg_operator_t *op, void *op_data) +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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = FAIL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -1196,26 +1162,25 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(op); /* Protect the object header to iterate over */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Call the "real" iterate routine */ - if((ret_value = H5O__msg_iterate_real(loc->file, oh, type, op, op_data)) < 0) + if ((ret_value = H5O__msg_iterate_real(loc->file, oh, type, op, op_data)) < 0) HERROR(H5E_OHDR, H5E_BADITER, "unable to iterate over object header messages"); done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_iterate() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_iterate_real * @@ -1247,14 +1212,14 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, *------------------------------------------------------------------------- */ herr_t -H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const H5O_mesg_operator_t *op, void *op_data) +H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const H5O_mesg_operator_t *op, + void *op_data) { - H5O_mesg_t *idx_msg; /* Pointer to current message */ - unsigned idx; /* Absolute index of current message in all messages */ - unsigned sequence; /* Relative index of current message for messages of type */ - unsigned oh_modified = 0; /* Whether the callback modified the object header */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ + H5O_mesg_t *idx_msg; /* Pointer to current message */ + unsigned idx; /* Absolute index of current message in all messages */ + unsigned sequence; /* Relative index of current message for messages of type */ + unsigned oh_modified = 0; /* Whether the callback modified the object header */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_PACKAGE @@ -1266,55 +1231,54 @@ H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(op->u.app_op); /* Iterate over messages */ - for(sequence = 0, idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs && !ret_value; idx++, idx_msg++) { - if(type == idx_msg->type) { + for (sequence = 0, idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs && !ret_value; idx++, idx_msg++) { + if (type == idx_msg->type) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(f, 0, oh, idx_msg, FAIL) /* Check for making an "internal" (i.e. within the H5O package) callback */ - if(op->op_type == H5O_MESG_OP_LIB) + if (op->op_type == H5O_MESG_OP_LIB) ret_value = (op->u.lib_op)(oh, idx_msg, sequence, &oh_modified, op_data); else ret_value = (op->u.app_op)(idx_msg->native, sequence, op_data); /* Check for iterator callback indicating to get out of loop */ - if(ret_value != 0) + if (ret_value != 0) break; /* Increment sequence value for message type */ sequence++; } /* end if */ - } /* end for */ + } /* end for */ /* Check for error from iterator */ - if(ret_value < 0) + if (ret_value < 0) HERROR(H5E_OHDR, H5E_CANTLIST, "iterator function failed"); done: /* Check if object message was modified */ - if(oh_modified) { + if (oh_modified) { /* Try to condense object header info */ /* (Since this routine is used to remove messages from an * object header, the header will be condensed after each * message removal) */ - if(oh_modified & H5O_MODIFY_CONDENSE) - if(H5O_condense_header(f, oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") + if (oh_modified & H5O_MODIFY_CONDENSE) + if (H5O__condense_header(f, oh) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") /* Mark object header as changed */ - if(H5O_touch_oh(f, oh, FALSE) < 0) + if (H5O_touch_oh(f, oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) + if (H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_iterate_real() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_raw_size * @@ -1329,31 +1293,29 @@ H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ size_t -H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, - const void *mesg) +H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ - if(0 == (ret_value = (type->raw_size)(f, disable_shared, mesg))) + if (0 == (ret_value = (type->raw_size)(f, disable_shared, mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_raw_size() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_size_f * @@ -1371,35 +1333,33 @@ H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, *------------------------------------------------------------------------- */ size_t -H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, - const void *mesg, size_t extra_raw) +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 */ - uint8_t oh_flags; /* Object header status flags */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + H5P_genplist_t * ocpl; /* Object Creation Property list */ + uint8_t oh_flags; /* Object header status flags */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Get the property list */ - if(NULL == (ocpl = (H5P_genplist_t *)H5I_object(ocpl_id))) + if (NULL == (ocpl = (H5P_genplist_t *)H5I_object(ocpl_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, 0, "not a property list") /* Get any object header status flags set by properties */ - if(H5P_get(ocpl, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + if (H5P_get(ocpl, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get object header flags") - /* Compute the raw data size for the mesg */ - if((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) + if ((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") /* Add in "extra" raw space */ @@ -1409,14 +1369,13 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, ret_value = (size_t)H5O_ALIGN_F(f, ret_value); /* Add space for message header */ - ret_value += (size_t)H5O_SIZEOF_MSGHDR_F(f, - (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); + ret_value += (size_t)H5O_SIZEOF_MSGHDR_F( + f, (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_size_f() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_size_oh * @@ -1434,24 +1393,23 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, *------------------------------------------------------------------------- */ size_t -H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, - const void *mesg, size_t extra_raw) +H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, const void *mesg, size_t extra_raw) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - size_t ret_value = 0; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->raw_size); HDassert(f); HDassert(mesg); /* Compute the raw data size for the mesg */ - if((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) + if ((ret_value = (type->raw_size)(f, FALSE, mesg)) == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, 0, "unable to determine size of message") /* Add in "extra" raw space */ @@ -1467,7 +1425,6 @@ H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_size_oh() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_can_share * @@ -1488,19 +1445,19 @@ H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, htri_t H5O_msg_can_share(unsigned type_id, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); /* If there is a can_share callback, use it */ - if(type->can_share) + if (type->can_share) ret_value = (type->can_share)(mesg); else { /* Otherwise, the message can be shared if messages of this type are @@ -1517,7 +1474,6 @@ H5O_msg_can_share(unsigned type_id, const void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_can_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_can_share_in_ohdr * @@ -1535,14 +1491,14 @@ H5O_msg_can_share(unsigned type_id, const void *mesg) htri_t H5O_msg_can_share_in_ohdr(unsigned type_id) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Otherwise, the message can be shared if messages of this type are @@ -1554,7 +1510,6 @@ H5O_msg_can_share_in_ohdr(unsigned type_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_can_share_in_ohdr() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_is_shared * @@ -1572,25 +1527,25 @@ H5O_msg_can_share_in_ohdr(unsigned type_id) htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - htri_t ret_value = FAIL; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ #ifdef H5O_ENABLE_BOGUS - if(type_id >= NELMTS(H5O_msg_class_g)) + if (type_id >= NELMTS(H5O_msg_class_g)) ret_value = FALSE; else #endif /* H5O_ENABLE_BOGUS */ { HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); /* If messages in a class aren't sharable, then obviously this message isn't shared! :-) */ - if(type->share_flags & H5O_SHARE_IS_SHARABLE) + if (type->share_flags & H5O_SHARE_IS_SHARABLE) ret_value = H5O_IS_STORED_SHARED(((const H5O_shared_t *)mesg)->type); else ret_value = FALSE; @@ -1599,7 +1554,6 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_is_shared() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_set_share * @@ -1616,14 +1570,14 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg) herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(type->share_flags & H5O_SHARE_IS_SHARABLE); HDassert(mesg); @@ -1633,15 +1587,15 @@ H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) /* If there's a special action for this class that needs to be performed * when setting the shared component, do that */ - if(type->set_share) { - if((type->set_share)(mesg, share) < 0) + if (type->set_share) { + if ((type->set_share)(mesg, share) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set shared message information") } /* end if */ else { /* Set this message as the shared component for the message, wiping out * any information that was there before */ - if(H5O_set_shared((H5O_shared_t *)mesg, share) < 0) + if (H5O_set_shared((H5O_shared_t *)mesg, share) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set shared message information") } /* end else */ @@ -1649,7 +1603,6 @@ H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_set_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_reset_share * @@ -1666,15 +1619,12 @@ H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg) herr_t H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ - HDassert(type); - HDassert(type->share_flags & H5O_SHARE_IS_SHARABLE); + HDassert(H5O_msg_class_g[type_id]); /* map the type ID to the actual type object */ + HDassert(H5O_msg_class_g[type_id]->share_flags & H5O_SHARE_IS_SHARABLE); HDassert(mesg); /* Reset the shared component in the message to zero. */ @@ -1683,7 +1633,6 @@ H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_msg_reset_share() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_get_crt_index * @@ -1700,22 +1649,22 @@ H5O_msg_reset_share(unsigned H5_ATTR_NDEBUG_UNUSED type_id, void *mesg) herr_t H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt_idx) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); HDassert(mesg); HDassert(crt_idx); /* If there is a "get_crt_index callback, use it */ - if(type->get_crt_index) { + if (type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(mesg, crt_idx) < 0) + if ((type->get_crt_index)(mesg, crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ else @@ -1725,7 +1674,6 @@ H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_get_crt_index() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_encode * @@ -1742,29 +1690,27 @@ H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt *------------------------------------------------------------------------- */ herr_t -H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, - unsigned char *buf, const void *mesg) +H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, unsigned char *buf, const void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Encode */ - if((type->encode)(f, disable_shared, buf, mesg) < 0) + if ((type->encode)(f, disable_shared, buf, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_encode() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_decode * @@ -1781,30 +1727,28 @@ H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, *------------------------------------------------------------------------- */ void * -H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, - const unsigned char *buf) +H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, const unsigned char *buf) { - 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 */ + 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 */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* decode */ - if(NULL == (ret_value = (type->decode)(f, open_oh, 0, &ioflags, buf_size, buf))) + if (NULL == (ret_value = (type->decode)(f, open_oh, 0, &ioflags, buf_size, buf))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_copy_file * @@ -1824,11 +1768,10 @@ H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, *------------------------------------------------------------------------- */ void * -H5O__msg_copy_file(const H5O_msg_class_t *type, 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) +H5O__msg_copy_file(const H5O_msg_class_t *type, 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) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1844,14 +1787,14 @@ H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, /* The copy_file callback will return an H5O_shared_t only if the message * to be copied is a committed datatype. */ - if(NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, recompute_size, mesg_flags, cpy_info, udata))) + if (NULL == (ret_value = (type->copy_file)(file_src, native_src, file_dst, recompute_size, mesg_flags, + cpy_info, udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object header message to file") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__msg_alloc * @@ -1866,8 +1809,8 @@ H5O__msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, *------------------------------------------------------------------------- */ herr_t -H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *native, size_t *mesg_idx) +H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned *mesg_flags, void *native, + size_t *mesg_idx) { size_t new_idx; /* New index for message */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ @@ -1885,28 +1828,28 @@ H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, HDassert(mesg_idx); /* Check if message is already shared */ - if((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) + if ((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "error determining if message is shared") - else if(shared_mesg > 0) { + else if (shared_mesg > 0) { /* Increment message's reference count */ - if(type->link && (type->link)(f, oh, native) < 0) + if (type->link && (type->link)(f, oh, native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared message ref count") *mesg_flags |= H5O_MSG_FLAG_SHARED; } /* end if */ else { /* Attempt to share message */ - if(H5SM_try_share(f, oh, 0, type->id, native, mesg_flags) < 0) + if (H5SM_try_share(f, oh, 0, type->id, native, mesg_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") } /* end else */ /* Allocate space in the object header for the message */ - if(H5O__alloc(f, oh, type, native, &new_idx) < 0) + if (H5O__alloc(f, oh, type, native, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for message") /* Get the message's "creation index", if it has one */ - if(type->get_crt_index) { + if (type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) + if ((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ @@ -1917,7 +1860,6 @@ H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__msg_alloc() */ - /*------------------------------------------------------------------------- * Function: H5O__copy_mesg * @@ -1932,13 +1874,13 @@ H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ static herr_t -H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, - const void *mesg, unsigned mesg_flags, unsigned update_flags) +H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, + 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 */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1950,14 +1892,14 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, HDassert(mesg); /* Protect chunk */ - if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx_msg->chunkno))) + if (NULL == (chk_proxy = H5O__chunk_protect(f, oh, idx_msg->chunkno))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header chunk") /* Reset existing native information for the header's message */ H5O__msg_reset_real(type, idx_msg->native); /* Copy the native object for the message */ - if(NULL == (idx_msg->native = (type->copy)(mesg, idx_msg->native))) + if (NULL == (idx_msg->native = (type->copy)(mesg, idx_msg->native))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy message to object header") /* Update the message flags */ @@ -1965,27 +1907,26 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, /* Mark the message as modified */ idx_msg->dirty = TRUE; - chk_dirtied = TRUE; + chk_dirtied = TRUE; /* Release chunk */ - if(H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") chk_proxy = NULL; /* Update the modification time, if requested */ - if(update_flags & H5O_UPDATE_TIME) - if(H5O_touch_oh(f, oh, FALSE) < 0) + if (update_flags & H5O_UPDATE_TIME) + if (H5O_touch_oh(f, oh, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") done: /* Release chunk, if not already released */ - if(chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) + if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_delete * @@ -2011,26 +1952,25 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, herr_t H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, void *mesg) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(f); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* delete */ - if((type->del) && (type->del)(f, open_oh, mesg) < 0) + if ((type->del) && (type->del)(f, open_oh, mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__delete_mesg * @@ -2048,8 +1988,8 @@ H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, void *mesg) herr_t H5O__delete_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) { - const H5O_msg_class_t *type = mesg->type; /* Type of object to free */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_msg_class_t *type = mesg->type; /* Type of object to free */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2059,19 +1999,19 @@ H5O__delete_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) HDassert(oh); /* Check if there is a file space deletion callback for this type of message */ - if(type->del) { + if (type->del) { /* Decode the message if necessary. */ H5O_LOAD_NATIVE(f, H5O_DECODEIO_NOCHANGE, oh, mesg, FAIL) - if((type->del)(f, oh, mesg->native) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + if ((type->del)(f, oh, mesg->native) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, + "unable to delete file space for object header message") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__delete_mesg() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_flush * @@ -2087,9 +2027,9 @@ H5O__delete_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) { - uint8_t *p; /* Temporary pointer to encode with */ - unsigned msg_id; /* ID for message */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p; /* Temporary pointer to encode with */ + unsigned msg_id; /* ID for message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2101,13 +2041,13 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) p = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); /* Retrieve actual message ID, for unknown messages */ - if(mesg->type == H5O_MSG_UNKNOWN) + if (mesg->type == H5O_MSG_UNKNOWN) msg_id = *(H5O_unknown_t *)(mesg->native); else msg_id = (uint8_t)mesg->type->id; /* Encode the message prefix */ - if(oh->version == H5O_VERSION_1) + if (oh->version == H5O_VERSION_1) UINT16ENCODE(p, msg_id) else *p++ = (uint8_t)msg_id; @@ -2116,22 +2056,22 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) *p++ = mesg->flags; /* Only encode reserved bytes for version 1 of format */ - if(oh->version == H5O_VERSION_1) { + if (oh->version == H5O_VERSION_1) { *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ - } /* end for */ + } /* end for */ /* Only encode creation index for version 2+ of format */ else { /* Only encode creation index if they are being tracked */ - if(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) + if (oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) UINT16ENCODE(p, mesg->crt_idx); } /* end else */ HDassert(p == mesg->raw); #ifndef NDEBUG /* Make certain that null messages aren't in chunks w/gaps */ - if(H5O_NULL_ID == msg_id) + if (H5O_NULL_ID == msg_id) HDassert(oh->chunk[mesg->chunkno].gap == 0); else /* Non-null messages should always have a native pointer */ @@ -2139,7 +2079,7 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) #endif /* NDEBUG */ /* Encode the message itself, if it's not an "unknown" message */ - if(mesg->native && mesg->type != H5O_MSG_UNKNOWN) { + if (mesg->native && mesg->type != H5O_MSG_UNKNOWN) { /* * Encode the message. If the message is shared then we * encode a Shared Object message instead of the object @@ -2148,19 +2088,19 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) HDassert(mesg->raw >= oh->chunk[mesg->chunkno].image); HDassert(mesg->raw_size == H5O_ALIGN_OH(oh, mesg->raw_size)); HDassert(mesg->raw + mesg->raw_size <= - oh->chunk[mesg->chunkno].image + (oh->chunk[mesg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))); + oh->chunk[mesg->chunkno].image + (oh->chunk[mesg->chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))); #ifndef NDEBUG -/* Sanity check that the message won't overwrite past it's allocated space */ -{ - size_t msg_size; - - msg_size = mesg->type->raw_size(f, FALSE, mesg->native); - msg_size = H5O_ALIGN_OH(oh, msg_size); - HDassert(msg_size <= mesg->raw_size); -} + /* Sanity check that the message won't overwrite past it's allocated space */ + { + size_t msg_size; + + msg_size = mesg->type->raw_size(f, FALSE, mesg->native); + msg_size = H5O_ALIGN_OH(oh, msg_size); + HDassert(msg_size <= mesg->raw_size); + } #endif /* NDEBUG */ HDassert(mesg->type->encode); - if((mesg->type->encode)(f, FALSE, mesg->raw, mesg->native) < 0) + if ((mesg->type->encode)(f, FALSE, mesg->raw, mesg->native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") } /* end if */ @@ -2171,9 +2111,8 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_flush() */ - /*------------------------------------------------------------------------- - * Function: H5O_flush_msgs + * Function: H5O__flush_msgs * * Purpose: Flushes messages for object header. * @@ -2185,39 +2124,38 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) *------------------------------------------------------------------------- */ herr_t -H5O_flush_msgs(H5F_t *f, H5O_t *oh) +H5O__flush_msgs(H5F_t *f, H5O_t *oh) { - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* check args */ HDassert(f); HDassert(oh); /* Encode any dirty messages */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) - if(curr_msg->dirty) - if(H5O_msg_flush(f, oh, curr_msg) < 0) + for (u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) + if (curr_msg->dirty) + if (H5O_msg_flush(f, oh, curr_msg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message") /* Sanity check for the correct # of messages in object header */ - if(oh->nmesgs != u) + if (oh->nmesgs != u) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages") #ifndef NDEBUG - /* Reset the number of messages dirtied by decoding, as they have all - * been flushed */ - oh->ndecode_dirtied = 0; + /* Reset the number of messages dirtied by decoding, as they have all + * been flushed */ + oh->ndecode_dirtied = 0; #endif /* NDEBUG */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_flush_msgs() */ +} /* end H5O__flush_msgs() */ - /*------------------------------------------------------------------------- * Function: H5O_msg_get_flags * @@ -2232,11 +2170,11 @@ 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 */ - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - unsigned idx; /* Index of message to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned idx; /* Index of message to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2245,26 +2183,26 @@ H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags) HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(type_id < NELMTS(H5O_msg_class_g)); - type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Locate message of correct type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(type == idx_msg->type) + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (type == idx_msg->type) break; - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Set return value */ *flags = idx_msg->flags; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Omodule.h b/src/H5Omodule.h index 6f00fcc1089..134aa920528 100644 --- a/src/H5Omodule.h +++ b/src/H5Omodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,21 @@ * H5O package. Including this header means that the source file * is part of the H5O package. */ -#ifndef _H5Omodule_H -#define _H5Omodule_H +#ifndef H5Omodule_H +#define H5Omodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5O_MODULE -#define H5_MY_PKG H5O -#define H5_MY_PKG_ERR H5E_OHDR -#define H5_MY_PKG_INIT YES - -#endif /* _H5Omodule_H */ +#define H5_MY_PKG H5O +#define H5_MY_PKG_ERR H5E_OHDR +#define H5_MY_PKG_INIT YES +/**\defgroup H5O H5O + * \brief Object Interface + * + * \todo Describe concisely what the functions in this module are about. + * + */ +#endif /* H5Omodule_H */ diff --git a/src/H5Omtime.c b/src/H5Omtime.c index edaf6d947ed..d48d226242e 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,86 +17,82 @@ * Purpose: The object modification time message. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#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, + 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_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, 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 size_t H5O_mtime_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, + 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 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); +static herr_t H5O__mtime_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__mtime_decode, /*decode message */ - H5O_mtime_encode, /*encode message */ - H5O_mtime_copy, /*copy the native value */ - H5O_mtime_size, /*raw message size */ - NULL, /* reset method */ - H5O__mtime_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mtime_debug /*debug the message */ + H5O_MTIME_ID, /*message id number */ + "mtime", /*message name for debugging */ + sizeof(time_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__mtime_decode, /*decode message */ + H5O__mtime_encode, /*encode message */ + H5O__mtime_copy, /*copy the native value */ + H5O__mtime_size, /*raw message size */ + NULL, /* reset method */ + H5O__mtime_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mtime_debug /*debug the message */ }}; /* This message derives from H5O message class */ /* (Only encode, decode & size routines are different from old mtime routines) */ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{ - H5O_MTIME_NEW_ID, /*message id number */ - "mtime_new", /*message name for debugging */ + H5O_MTIME_NEW_ID, /*message id number */ + "mtime_new", /*message name for debugging */ sizeof(time_t), /*native message size */ - 0, /* messages are sharable? */ - H5O__mtime_new_decode, /*decode message */ - H5O_mtime_new_encode, /*encode message */ - H5O_mtime_copy, /*copy the native value */ - H5O_mtime_new_size, /*raw message size */ - NULL, /* reset method */ - H5O__mtime_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__mtime_debug /*debug the message */ + 0, /* messages are sharable? */ + H5O__mtime_new_decode, /*decode message */ + H5O__mtime_new_encode, /*encode message */ + H5O__mtime_copy, /*copy the native value */ + H5O__mtime_new_size, /*raw message size */ + NULL, /* reset method */ + H5O__mtime_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__mtime_debug /*debug the message */ }}; /* Current version of new mtime information */ -#define H5O_MTIME_VERSION 1 +#define H5O_MTIME_VERSION 1 /* Declare a free list to manage the time_t struct */ H5FL_DEFINE(time_t); - /*------------------------------------------------------------------------- * Function: H5O__mtime_new_decode * @@ -117,12 +113,12 @@ H5FL_DEFINE(time_t); */ static void * 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) + 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; - uint32_t tmp_time; /* Temporary copy of the time */ - void *ret_value = NULL; /* Return value */ + time_t * mesg; + uint32_t tmp_time; /* Temporary copy of the time */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -131,28 +127,27 @@ H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(*p++ != H5O_MTIME_VERSION) + if (*p++ != H5O_MTIME_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for mtime message"); /* Skip reserved bytes */ - p+=3; + p += 3; /* Get the time_t from the file */ UINT32DECODE(p, tmp_time); /* The return value */ - if (NULL==(mesg = H5FL_MALLOC(time_t))) + if (NULL == (mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *mesg = (time_t)tmp_time; /* Set return value */ - ret_value=mesg; + ret_value = mesg; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mtime_new_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__mtime_decode * @@ -172,14 +167,13 @@ H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ 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) +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; - struct tm tm; - int i; /* Local index variable */ - void *ret_value = NULL; /* Return value */ + time_t * mesg, the_time; + struct tm tm; + int i; /* Local index variable */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -188,24 +182,24 @@ H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - for(i = 0; i < 14; i++) - if(!HDisdigit(p[i])) + for (i = 0; i < 14; i++) + if (!HDisdigit(p[i])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") /* Convert YYYYMMDDhhmmss UTC to a time_t. */ HDmemset(&tm, 0, sizeof tm); - tm.tm_year = (p[0]-'0')*1000 + (p[1]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0') - 1900; - tm.tm_mon = (p[4]-'0')*10 + (p[5]-'0') - 1; - tm.tm_mday = (p[6]-'0')*10 + (p[7]-'0'); - tm.tm_hour = (p[8]-'0')*10 + (p[9]-'0'); - tm.tm_min = (p[10]-'0')*10 + (p[11]-'0'); - tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0'); + tm.tm_year = (p[0] - '0') * 1000 + (p[1] - '0') * 100 + (p[2] - '0') * 10 + (p[3] - '0') - 1900; + tm.tm_mon = (p[4] - '0') * 10 + (p[5] - '0') - 1; + tm.tm_mday = (p[6] - '0') * 10 + (p[7] - '0'); + tm.tm_hour = (p[8] - '0') * 10 + (p[9] - '0'); + tm.tm_min = (p[10] - '0') * 10 + (p[11] - '0'); + tm.tm_sec = (p[12] - '0') * 10 + (p[13] - '0'); tm.tm_isdst = -1; /* (figure it out) */ - if((time_t)-1 == (the_time = H5_make_time(&tm))) + if ((time_t)-1 == (the_time = H5_make_time(&tm))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't construct time info") /* The return value */ - if(NULL == (mesg = H5FL_MALLOC(time_t))) + if (NULL == (mesg = H5FL_MALLOC(time_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") *mesg = the_time; @@ -216,9 +210,8 @@ H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__mtime_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_mtime_new_encode + * Function: H5O__mtime_new_encode * * Purpose: Encodes a new modification time message. * @@ -230,11 +223,12 @@ H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const time_t *mesg = (const time_t *) _mesg; + const time_t *mesg = (const time_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -253,11 +247,10 @@ H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha UINT32ENCODE(p, *mesg); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_mtime_new_encode() */ - +} /* end H5O__mtime_new_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_mtime_encode + * Function: H5O__mtime_encode * * Purpose: Encodes a modification time message. * @@ -269,12 +262,13 @@ H5O_mtime_new_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_sha *------------------------------------------------------------------------- */ static herr_t -H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const time_t *mesg = (const time_t *) _mesg; - struct tm *tm; + const time_t *mesg = (const time_t *)_mesg; + struct tm * tm; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -283,16 +277,14 @@ H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, /* encode */ tm = HDgmtime(mesg); - HDsprintf((char*)p, "%04d%02d%02d%02d%02d%02d", - 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + HDsprintf((char *)p, "%04d%02d%02d%02d%02d%02d", 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); FUNC_LEAVE_NOAPI(SUCCEED) -} - +} /* end H5O__mtime_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_mtime_copy + * Function: H5O__mtime_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -307,32 +299,31 @@ H5O_mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *------------------------------------------------------------------------- */ static void * -H5O_mtime_copy(const void *_mesg, void *_dest) +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 */ + const time_t *mesg = (const time_t *)_mesg; + time_t * dest = (time_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if (!dest && NULL==(dest = H5FL_MALLOC(time_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (!dest && NULL == (dest = H5FL_MALLOC(time_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ *dest = *mesg; /* Set return value */ - ret_value=dest; + ret_value = dest; done: FUNC_LEAVE_NOAPI(ret_value) -} - +} /* end H5O__mtime_copy() */ /*------------------------------------------------------------------------- - * Function: H5O_mtime_new_size + * Function: H5O__mtime_new_size * * Purpose: Returns the size of the raw message in bytes not * counting the message type or size fields, but only the data @@ -349,20 +340,20 @@ H5O_mtime_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED * mesg) +H5O__mtime_new_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); HDassert(mesg); FUNC_LEAVE_NOAPI(8) -} /* end H5O_mtime_new_size() */ - +} /* end H5O__mtime_new_size() */ /*------------------------------------------------------------------------- - * Function: H5O_mtime_size + * Function: H5O__mtime_size * * Purpose: Returns the size of the raw message in bytes not * counting the message type or size fields, but only the data @@ -379,20 +370,20 @@ H5O_mtime_new_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disabl *------------------------------------------------------------------------- */ static size_t -H5O_mtime_size(const H5F_t H5_ATTR_UNUSED * f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED * mesg) +H5O__mtime_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *mesg) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); HDassert(mesg); FUNC_LEAVE_NOAPI(16) -} - +} /* end H5O__mtime_size() */ /*------------------------------------------------------------------------- - * Function: H5O__mtime_free + * Function: H5O__mtime_free * * Purpose: Frees the message * @@ -415,9 +406,8 @@ H5O__mtime_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mtime_free() */ - /*------------------------------------------------------------------------- - * Function: H5O__mtime_debug + * Function: H5O__mtime_debug * * Purpose: Prints debugging info for the message. * @@ -429,14 +419,13 @@ H5O__mtime_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +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; - char buf[128]; + const time_t *mesg = (const time_t *)_mesg; + struct tm * tm; + char buf[128]; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -449,9 +438,7 @@ H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, tm = HDlocaltime(mesg); HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Time:", buf); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Time:", buf); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__mtime_debug() */ - diff --git a/src/H5Oname.c b/src/H5Oname.c index 528bf363065..979b2404bb6 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,50 +22,46 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_name_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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); +static herr_t H5O__name_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__name_decode, /*decode message */ - H5O_name_encode, /*encode message */ - H5O_name_copy, /*copy the native value */ - H5O_name_size, /*raw message size */ - H5O__name_reset, /*free internal memory */ - NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__name_debug /*debug the message */ + H5O_NAME_ID, /*message id number */ + "name", /*message name for debugging */ + sizeof(H5O_name_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__name_decode, /*decode message */ + H5O__name_encode, /*encode message */ + H5O__name_copy, /*copy the native value */ + H5O__name_size, /*raw message size */ + H5O__name_reset, /*free internal memory */ + NULL, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__name_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__name_decode * @@ -82,12 +78,11 @@ const H5O_msg_class_t H5O_MSG_NAME[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__name_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__name_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_name_t *mesg; - void *ret_value = NULL; /* Return value */ + H5O_name_t *mesg; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -96,25 +91,24 @@ H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (mesg = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) + if (NULL == (mesg = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == (mesg->s = (char *)H5MM_strdup((const char *)p))) + if (NULL == (mesg->s = (char *)H5MM_strdup((const char *)p))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = mesg; done: - if(NULL == ret_value) - if(mesg) + if (NULL == ret_value) + if (mesg) mesg = (H5O_name_t *)H5MM_xfree(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__name_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_name_encode + * Function: H5O__name_encode * * Purpose: Encodes a name message. * @@ -126,11 +120,12 @@ H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -138,14 +133,13 @@ H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, HDassert(mesg && mesg->s); /* encode */ - HDstrcpy((char*)p, mesg->s); + HDstrcpy((char *)p, mesg->s); FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5O__name_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_name_copy + * Function: H5O__name_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -160,39 +154,38 @@ H5O_name_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, *------------------------------------------------------------------------- */ static void * -H5O_name_copy(const void *_mesg, void *_dest) +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 */ + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + H5O_name_t * dest = (H5O_name_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) + if (!dest && NULL == (dest = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *mesg; - if(NULL == (dest->s = H5MM_xstrdup(mesg->s))) + if (NULL == (dest->s = H5MM_xstrdup(mesg->s))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest && NULL == _dest) + if (NULL == ret_value) + if (dest && NULL == _dest) dest = (H5O_name_t *)H5MM_xfree(dest); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_name_copy() */ +} /* end H5O__name_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_name_size + * Function: H5O__name_size * * Purpose: Returns the size of the raw message in bytes not * counting the message typ or size fields, but only the data @@ -209,12 +202,12 @@ H5O_name_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) +H5O__name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_name_t *mesg = (const H5O_name_t *) _mesg; - size_t ret_value = 0; /* Return value */ + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -223,9 +216,8 @@ H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar ret_value = mesg->s ? HDstrlen(mesg->s) + 1 : 0; FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5O__name_size() */ - /*------------------------------------------------------------------------- * Function: H5O__name_reset * @@ -242,7 +234,7 @@ H5O_name_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar static herr_t H5O__name_reset(void *_mesg) { - H5O_name_t *mesg = (H5O_name_t *) _mesg; + H5O_name_t *mesg = (H5O_name_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -255,7 +247,6 @@ H5O__name_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__name_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__name_debug * @@ -269,12 +260,11 @@ H5O__name_reset(void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_name_t *mesg = (const H5O_name_t *)_mesg; + const H5O_name_t *mesg = (const H5O_name_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -283,10 +273,7 @@ H5O__name_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, - "Name:", - mesg->s); + HDfprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", mesg->s); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__name_debug() */ - diff --git a/src/H5Onull.c b/src/H5Onull.c index 43c555fb5e2..9b377fbb871 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,34 +21,31 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Opkg.h" /* Object headers */ /* This message derives from H5O message class */ 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? */ - NULL, /*no decode method */ - NULL, /*no encode method */ - NULL, /*no copy method */ - NULL, /*no size method */ - NULL, /*no reset method */ - NULL, /*no free method */ - NULL, /*no file delete method */ - NULL, /*no link method */ - NULL, /*no set share method */ - NULL, /*no can share method */ - NULL, /*no pre copy native value to file */ - NULL, /*no copy native value to file */ - NULL, /*no post copy native value to file */ - NULL, /*no get creation index */ - NULL, /*no set creation index */ - NULL /*no debug method */ + H5O_NULL_ID, /*message id number */ + "null", /*message name for debugging */ + 0, /*native message size */ + 0, /* messages are sharable? */ + NULL, /*no decode method */ + NULL, /*no encode method */ + NULL, /*no copy method */ + NULL, /*no size method */ + NULL, /*no reset method */ + NULL, /*no free method */ + NULL, /*no file delete method */ + NULL, /*no link method */ + NULL, /*no set share method */ + NULL, /*no can share method */ + NULL, /*no pre copy native value to file */ + NULL, /*no copy native value to file */ + NULL, /*no post copy native value to file */ + NULL, /*no get creation index */ + NULL, /*no set creation index */ + NULL /*no debug method */ }}; - diff --git a/src/H5Opkg.h b/src/H5Opkg.h index d77bd549a39..6e203bb48fd 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,36 +15,37 @@ #error "Do not include this file outside the H5O package!" #endif -#ifndef _H5Opkg_H -#define _H5Opkg_H +#ifndef H5Opkg_H +#define H5Opkg_H /* Get package's private header */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Oprivate.h" /* Object headers */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ /* Object header macros */ -#define H5O_NMESGS 8 /*initial number of messages */ -#define H5O_NCHUNKS 2 /*initial number of chunks */ -#define H5O_MIN_SIZE 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */ -#define H5O_MSG_TYPES 26 /* # of types of messages */ -#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */ +#define H5O_NMESGS 8 /*initial number of messages */ +#define H5O_NCHUNKS 2 /*initial number of chunks */ +#define H5O_MIN_SIZE \ + 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */ +#define H5O_MSG_TYPES 26 /* # of types of messages */ +#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */ /* Versions of object header structure */ /* Initial version of the object header format */ -#define H5O_VERSION_1 1 +#define H5O_VERSION_1 1 /* Revised version - leaves out reserved bytes and alignment padding, and adds * magic number as prefix and checksum as suffix for all chunks. */ -#define H5O_VERSION_2 2 +#define H5O_VERSION_2 2 /* The latest version of the format. Look through the 'flush' * and 'size' callback for places to change when updating this. */ -#define H5O_VERSION_LATEST H5O_VERSION_2 +#define H5O_VERSION_LATEST H5O_VERSION_2 /* * Align messages on 8-byte boundaries because we would like to copy the @@ -54,20 +55,13 @@ * * Note: We no longer attempt to do this. - QAK, 10/16/06 */ -#define H5O_ALIGN_OLD(X) (8 * (((X) + 7) / 8)) -#define H5O_ALIGN_VERS(V, X) \ - (((V) == H5O_VERSION_1) ? \ - H5O_ALIGN_OLD(X) \ - : \ - (X) \ - ) -#define H5O_ALIGN_OH(O, X) \ - H5O_ALIGN_VERS((O)->version, X) -#define H5O_ALIGN_F(F, X) \ - H5O_ALIGN_VERS(MAX(H5O_VERSION_1, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), X) +#define H5O_ALIGN_OLD(X) (8 * (((X) + 7) / 8)) +#define H5O_ALIGN_VERS(V, X) (((V) == H5O_VERSION_1) ? H5O_ALIGN_OLD(X) : (X)) +#define H5O_ALIGN_OH(O, X) H5O_ALIGN_VERS((O)->version, X) +#define H5O_ALIGN_F(F, X) H5O_ALIGN_VERS(MAX(H5O_VERSION_1, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), X) /* Size of checksum (on disk) */ -#define H5O_SIZEOF_CHKSUM 4 +#define H5O_SIZEOF_CHKSUM 4 /* ========= Object Creation properties ============ */ /* Default values for some of the object creation properties */ @@ -76,99 +70,87 @@ * default attribute phase change storage are handled correctly if they * are changed. */ -#define H5O_CRT_ATTR_MAX_COMPACT_DEF 8 -#define H5O_CRT_ATTR_MIN_DENSE_DEF 6 -#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES +#define H5O_CRT_ATTR_MAX_COMPACT_DEF 8 +#define H5O_CRT_ATTR_MIN_DENSE_DEF 6 +#define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES /* Object header status flag definitions */ -#define H5O_HDR_CHUNK0_1 0x00 /* Use 1-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_2 0x01 /* Use 2-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_4 0x02 /* Use 4-byte value for chunk #0 size */ -#define H5O_HDR_CHUNK0_8 0x03 /* Use 8-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_1 0x00 /* Use 1-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_2 0x01 /* Use 2-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_4 0x02 /* Use 4-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_8 0x03 /* Use 8-byte value for chunk #0 size */ /* * Size of object header prefix. */ -#define H5O_SIZEOF_HDR(O) \ - (((O)->version == H5O_VERSION_1) \ - ? \ - H5O_ALIGN_OLD(1 + /*version number */ \ - 1 + /*reserved */ \ - 2 + /*number of messages */ \ - 4 + /*reference count */ \ - 4) /*chunk data size */ \ - : \ - (H5_SIZEOF_MAGIC + /*magic number */ \ - 1 + /*version number */ \ - 1 + /*flags */ \ - (((O)->flags & H5O_HDR_STORE_TIMES) ? ( \ - 4 + /*access time */ \ - 4 + /*modification time */ \ - 4 + /*change time */ \ - 4 /*birth time */ \ - ) : 0) + \ - (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? ( \ - 2 + /*max compact attributes */ \ - 2 /*min dense attributes */ \ - ) : 0) + \ - (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \ - H5O_SIZEOF_CHKSUM) /*checksum size */ \ +#define H5O_SIZEOF_HDR(O) \ + (((O)->version == H5O_VERSION_1) \ + ? H5O_ALIGN_OLD(1 + /*version number */ \ + 1 + /*reserved */ \ + 2 + /*number of messages */ \ + 4 + /*reference count */ \ + 4) /*chunk data size */ \ + : (H5_SIZEOF_MAGIC + /*magic number */ \ + 1 + /*version number */ \ + 1 + /*flags */ \ + (((O)->flags & H5O_HDR_STORE_TIMES) ? (4 + /*access time */ \ + 4 + /*modification time */ \ + 4 + /*change time */ \ + 4 /*birth time */ \ + ) \ + : 0) + \ + (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? (2 + /*max compact attributes */ \ + 2 /*min dense attributes */ \ + ) \ + : 0) + \ + (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + /*chunk 0 data size */ \ + H5O_SIZEOF_CHKSUM) /*checksum size */ \ ) /* * Size of object header message prefix */ -#define H5O_SIZEOF_MSGHDR_VERS(V,C) \ - (((V) == H5O_VERSION_1) \ - ? \ - H5O_ALIGN_OLD(2 + /*message type */ \ - 2 + /*sizeof message data */ \ - 1 + /*flags */ \ - 3) /*reserved */ \ - : \ - (1 + /*message type */ \ - 2 + /*sizeof message data */ \ - 1 + /*flags */ \ - ((C) ? ( \ - 2 /*creation index */ \ - ) : 0)) \ - ) -#define H5O_SIZEOF_MSGHDR_OH(O) \ - (unsigned)H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED) -#define H5O_SIZEOF_MSGHDR_F(F, C) \ - (unsigned)H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), (C)) +#define H5O_SIZEOF_MSGHDR_VERS(V, C) \ + (((V) == H5O_VERSION_1) ? H5O_ALIGN_OLD(2 + /*message type */ \ + 2 + /*sizeof message data */ \ + 1 + /*flags */ \ + 3) /*reserved */ \ + : (1 + /*message type */ \ + 2 + /*sizeof message data */ \ + 1 + /*flags */ \ + ((C) ? (2 /*creation index */ \ + ) \ + : 0))) +#define H5O_SIZEOF_MSGHDR_OH(O) \ + (unsigned)H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags &H5O_HDR_ATTR_CRT_ORDER_TRACKED) +#define H5O_SIZEOF_MSGHDR_F(F, C) \ + (unsigned)H5O_SIZEOF_MSGHDR_VERS(MAX((H5F_STORE_MSG_CRT_IDX(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), \ + (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(F)]), \ + (C)) /* * Size of chunk "header" for each chunk */ -#define H5O_SIZEOF_CHKHDR_VERS(V) \ - (((V) == H5O_VERSION_1) \ - ? \ - 0 + /*no magic # */ \ - 0 /*no checksum */ \ - : \ - H5_SIZEOF_MAGIC + /*magic # */ \ - H5O_SIZEOF_CHKSUM /*checksum */ \ +#define H5O_SIZEOF_CHKHDR_VERS(V) \ + (((V) == H5O_VERSION_1) ? 0 + /*no magic # */ \ + 0 /*no checksum */ \ + : H5_SIZEOF_MAGIC + /*magic # */ \ + H5O_SIZEOF_CHKSUM /*checksum */ \ ) -#define H5O_SIZEOF_CHKHDR_OH(O) \ - H5O_SIZEOF_CHKHDR_VERS((O)->version) +#define H5O_SIZEOF_CHKHDR_OH(O) H5O_SIZEOF_CHKHDR_VERS((O)->version) /* * Size of checksum for each chunk */ -#define H5O_SIZEOF_CHKSUM_VERS(V) \ - (((V) == H5O_VERSION_1) \ - ? \ - 0 /*no checksum */ \ - : \ - H5O_SIZEOF_CHKSUM /*checksum */ \ +#define H5O_SIZEOF_CHKSUM_VERS(V) \ + (((V) == H5O_VERSION_1) ? 0 /*no checksum */ \ + : H5O_SIZEOF_CHKSUM /*checksum */ \ ) -#define H5O_SIZEOF_CHKSUM_OH(O) \ - H5O_SIZEOF_CHKSUM_VERS((O)->version) +#define H5O_SIZEOF_CHKSUM_OH(O) H5O_SIZEOF_CHKSUM_VERS((O)->version) /* Input/output flags for decode functions */ -#define H5O_DECODEIO_NOCHANGE 0x01u /* IN: do not modify values */ -#define H5O_DECODEIO_DIRTY 0x02u /* OUT: message has been changed */ +#define H5O_DECODEIO_NOCHANGE 0x01u /* IN: do not modify values */ +#define H5O_DECODEIO_DIRTY 0x02u /* OUT: message has been changed */ /* Macro to incremend ndecode_dirtied (only if we are debugging) */ #ifndef NDEBUG @@ -179,41 +161,43 @@ /* Load native information for a message, if it's not already present */ /* (Only works for messages with decode callback) */ -#define H5O_LOAD_NATIVE(F, IOF, OH, MSG, ERR) \ - if(NULL == (MSG)->native) { \ - const H5O_msg_class_t *msg_type = (MSG)->type; \ - unsigned ioflags = (IOF); \ - \ - /* Decode the message */ \ - HDassert(msg_type->decode); \ - if(NULL == ((MSG)->native = (msg_type->decode)((F), (OH), (MSG)->flags, &ioflags, (MSG)->raw_size, (MSG)->raw))) \ - HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \ - \ - /* Mark the message dirty if it was changed by decoding */ \ - if((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \ - (MSG)->dirty = TRUE; \ - /* Increment the count of messages dirtied by decoding, but */ \ - /* only ifndef NDEBUG */ \ - INCR_NDECODE_DIRTIED(OH) \ - } \ - \ - /* Set the message's "shared info", if it's shareable */ \ - if((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \ - HDassert(msg_type->share_flags & H5O_SHARE_IS_SHARABLE); \ - H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, (MSG)->crt_idx, (OH)->chunk[0].addr) \ - } /* end if */ \ - \ - /* Set the message's "creation index", if it has one */ \ - if(msg_type->set_crt_index) { \ - /* Set the creation index for the message */ \ - if((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \ - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \ - } /* end if */ \ - } /* end if */ +#define H5O_LOAD_NATIVE(F, IOF, OH, MSG, ERR) \ + if (NULL == (MSG)->native) { \ + const H5O_msg_class_t *msg_type = (MSG)->type; \ + unsigned ioflags = (IOF); \ + \ + /* Decode the message */ \ + HDassert(msg_type->decode); \ + if (NULL == ((MSG)->native = (msg_type->decode)((F), (OH), (MSG)->flags, &ioflags, (MSG)->raw_size, \ + (MSG)->raw))) \ + HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \ + \ + /* Mark the message dirty if it was changed by decoding */ \ + if ((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \ + (MSG)->dirty = TRUE; \ + /* Increment the count of messages dirtied by decoding, but */ \ + /* only ifndef NDEBUG */ \ + INCR_NDECODE_DIRTIED(OH) \ + } \ + \ + /* Set the message's "shared info", if it's shareable */ \ + if ((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \ + HDassert(msg_type->share_flags &H5O_SHARE_IS_SHARABLE); \ + H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, \ + (MSG)->crt_idx, (OH)->chunk[0].addr) \ + } /* end if */ \ + \ + /* Set the message's "creation index", if it has one */ \ + if (msg_type->set_crt_index) { \ + /* Set the creation index for the message */ \ + if ((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \ + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \ + } /* end if */ \ + } /* end if */ /* Flags for a message class's "sharability" */ -#define H5O_SHARE_IS_SHARABLE 0x01 -#define H5O_SHARE_IN_OHDR 0x02 +#define H5O_SHARE_IS_SHARABLE 0x01 +#define H5O_SHARE_IN_OHDR 0x02 /* Set the object header size to speculatively read in */ /* (needs to be more than the object header prefix size to work at all and @@ -221,59 +205,61 @@ * size to save the extra I/O operations) */ #define H5O_SPEC_READ_SIZE 512 - /* The "message class" type */ struct H5O_msg_class_t { - unsigned id; /*message type ID on disk */ - const char *name; /*for debugging */ - size_t native_size; /*size of native message */ - unsigned share_flags; /* Message sharing settings */ - void *(*decode)(H5F_t *, H5O_t *, unsigned, unsigned *, size_t, const uint8_t *); - herr_t (*encode)(H5F_t *, hbool_t, uint8_t *, const void *); - void *(*copy)(const void *, void *); /*copy native value */ - size_t (*raw_size)(const H5F_t *, hbool_t, const void *);/*sizeof encoded message */ - herr_t (*reset)(void *); /*free nested data structs */ - herr_t (*free)(void *); /*free main data struct */ - herr_t (*del)(H5F_t *, H5O_t *, void *); /* Delete space in file referenced by this message */ - herr_t (*link)(H5F_t *, H5O_t *, void *); /* Increment any links in file reference by this message */ - herr_t (*set_share)(void*, const H5O_shared_t*); /* Set shared information */ - htri_t (*can_share)(const void *); /* Is message allowed to be shared? */ - herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */ - void *(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, unsigned *, H5O_copy_t *, void *); /*copy native value to file */ - herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, unsigned *, H5O_copy_t *); /*"post copy" action when copying native value to file */ - herr_t (*get_crt_index)(const void *, H5O_msg_crt_idx_t *); /* Get message's creation index */ - herr_t (*set_crt_index)(void *, H5O_msg_crt_idx_t); /* Set message's creation index */ - herr_t (*debug)(H5F_t*, const void*, FILE*, int, int); + unsigned id; /*message type ID on disk */ + const char *name; /*for debugging */ + size_t native_size; /*size of native message */ + unsigned share_flags; /* Message sharing settings */ + void *(*decode)(H5F_t *, H5O_t *, unsigned, unsigned *, size_t, const uint8_t *); + herr_t (*encode)(H5F_t *, hbool_t, uint8_t *, const void *); + void *(*copy)(const void *, void *); /*copy native value */ + size_t (*raw_size)(const H5F_t *, hbool_t, const void *); /*sizeof encoded message */ + herr_t (*reset)(void *); /*free nested data structs */ + herr_t (*free)(void *); /*free main data struct */ + herr_t (*del)(H5F_t *, H5O_t *, void *); /* Delete space in file referenced by this message */ + herr_t (*link)(H5F_t *, H5O_t *, void *); /* Increment any links in file reference by this message */ + herr_t (*set_share)(void *, const H5O_shared_t *); /* Set shared information */ + htri_t (*can_share)(const void *); /* Is message allowed to be shared? */ + herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, + void *); /*"pre copy" action when copying native value to file */ + void *(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, unsigned *, H5O_copy_t *, + void *); /*copy native value to file */ + herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, unsigned *, + H5O_copy_t *); /*"post copy" action when copying native value to file */ + herr_t (*get_crt_index)(const void *, H5O_msg_crt_idx_t *); /* Get message's creation index */ + herr_t (*set_crt_index)(void *, H5O_msg_crt_idx_t); /* Set message's creation index */ + herr_t (*debug)(H5F_t *, const void *, FILE *, int, int); }; struct H5O_mesg_t { - const H5O_msg_class_t *type; /* type of message */ - hbool_t dirty; /* raw out of date wrt native */ - 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 */ - size_t raw_size; /* size with alignment */ + const H5O_msg_class_t *type; /* type of message */ + hbool_t dirty; /* raw out of date wrt native */ + 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 */ + size_t raw_size; /* size with alignment */ }; /* Struct for storing information about "best" message to move to new chunk */ typedef struct H5O_msg_alloc_info_t { - int msgno; /* Index in message array */ - unsigned id; /* Message type ID on disk */ - unsigned chunkno; /* Index in chunk array */ - size_t gap_size; /* Size of any "gap" in the chunk immediately after message */ - size_t null_size; /* Size of any null message in the chunk immediately after message */ - size_t total_size; /* Total size of "available" space around message */ - unsigned null_msgno; /* Message index of null message immediately after message */ + int msgno; /* Index in message array */ + unsigned id; /* Message type ID on disk */ + unsigned chunkno; /* Index in chunk array */ + size_t gap_size; /* Size of any "gap" in the chunk immediately after message */ + size_t null_size; /* Size of any null message in the chunk immediately after message */ + size_t total_size; /* Total size of "available" space around message */ + unsigned null_msgno; /* Message index of null message immediately after message */ } H5O_msg_alloc_info_t; 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 */ - struct H5O_chunk_proxy_t *chunk_proxy; /* Pointer to a chunk's proxy when chunk protected */ + 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 */ + struct H5O_chunk_proxy_t *chunk_proxy; /* Pointer to a chunk's proxy when chunk protected */ } H5O_chunk_t; struct H5O_t { @@ -281,115 +267,116 @@ struct H5O_t { /* first field in structure */ /* File-specific information (not stored) */ - size_t sizeof_size; /* Size of file sizes */ - size_t sizeof_addr; /* Size of file addresses */ - hbool_t swmr_write; /* Whether we are doing SWMR writes */ + size_t sizeof_size; /* Size of file sizes */ + size_t sizeof_addr; /* Size of file addresses */ + hbool_t swmr_write; /* Whether we are doing SWMR writes */ /* Debugging information (not stored) */ #ifdef H5O_ENABLE_BAD_MESG_COUNT - hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ - /* (This is to simulate a bug in earlier - * versions of the library) - */ -#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ + /* (This is to simulate a bug in earlier + * versions of the library) + */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ #ifndef NDEBUG - size_t ndecode_dirtied; /* Number of messages dirtied by decoding */ -#endif /* NDEBUG */ + size_t ndecode_dirtied; /* Number of messages dirtied by decoding */ +#endif /* NDEBUG */ /* Chunk management information (not stored) */ - size_t rc; /* Reference count of [continuation] chunks using this structure */ + size_t rc; /* Reference count of [continuation] chunks using this structure */ /* Object information (stored) */ - hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ - unsigned nlink; /*link count */ - uint8_t version; /*version number */ - uint8_t flags; /*flags */ + hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ + unsigned nlink; /*link count */ + uint8_t version; /*version number */ + uint8_t flags; /*flags */ /* Time information (stored, for versions > 1 & H5O_HDR_STORE_TIMES flag set) */ - time_t atime; /*access time */ - time_t mtime; /*modification time */ - time_t ctime; /*change time */ - time_t btime; /*birth time */ + time_t atime; /*access time */ + time_t mtime; /*modification time */ + time_t ctime; /*change time */ + time_t btime; /*birth time */ /* Attribute information (stored, for versions > 1) */ - unsigned max_compact; /* Maximum # of compact attributes */ - unsigned min_dense; /* Minimum # of "dense" attributes */ + unsigned max_compact; /* Maximum # of compact attributes */ + unsigned min_dense; /* Minimum # of "dense" attributes */ /* Message management (stored, encoded in chunks) */ - size_t nmesgs; /*number of messages */ - size_t alloc_nmesgs; /*number of message slots */ - H5O_mesg_t *mesg; /*array of messages */ - size_t link_msgs_seen; /* # of link messages seen when loading header */ - size_t attr_msgs_seen; /* # of attribute messages seen when loading header */ + size_t nmesgs; /*number of messages */ + size_t alloc_nmesgs; /*number of message slots */ + H5O_mesg_t *mesg; /*array of messages */ + size_t link_msgs_seen; /* # of link messages seen when loading header */ + size_t attr_msgs_seen; /* # of attribute messages seen when loading header */ /* Chunk management (not stored) */ - size_t nchunks; /*number of chunks */ - size_t alloc_nchunks; /*chunks allocated */ - H5O_chunk_t *chunk; /*array of chunks */ - hbool_t chunks_pinned; /* Whether chunks are pinned from ohdr protect */ + size_t nchunks; /*number of chunks */ + size_t alloc_nchunks; /*chunks allocated */ + H5O_chunk_t *chunk; /*array of chunks */ + hbool_t chunks_pinned; /* Whether chunks are pinned from ohdr protect */ /* Object header proxy information (not stored) */ - H5AC_proxy_entry_t *proxy; /* Proxy cache entry for all ohdr entries */ + H5AC_proxy_entry_t *proxy; /* Proxy cache entry for all ohdr entries */ }; /* Class for types of objects in file */ typedef struct H5O_obj_class_t { - H5O_type_t type; /*object type on disk */ - const char *name; /*for debugging */ - void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ - void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ - htri_t (*isa)(const H5O_t *); /*if a header matches an object class */ - hid_t (*open)(const H5G_loc_t *, hbool_t ); /*open an object of this class */ - void *(*create)(H5F_t *, void *, H5G_loc_t *); /*create an object of this class */ - H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */ - herr_t (*bh_info)(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */ - herr_t (*flush)(void *obj_ptr); /*flush an opened object of this class */ + H5O_type_t type; /*object type on disk */ + const char *name; /*for debugging */ + void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ + void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ + htri_t (*isa)(const H5O_t *); /*if a header matches an object class */ + void *(*open)(const H5G_loc_t *, H5I_type_t *); /*open an object of this class */ + void *(*create)(H5F_t *, void *, H5G_loc_t *); /*create an object of this class */ + H5O_loc_t *(*get_oloc)(hid_t); /*get the object header location for an object */ + herr_t (*bh_info)(const H5O_loc_t *loc, H5O_t *oh, + H5_ih_info_t *bh_info); /*get the index & heap info for an object */ + herr_t (*flush)(void *obj_ptr); /*flush an opened object of this class */ } H5O_obj_class_t; /* Node in skip list to map addresses from one file to another during object header copy */ typedef struct H5O_addr_map_t { - H5_obj_t src_obj_pos; /* Location of source object */ - haddr_t dst_addr; /* Address of object in destination file */ - 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 */ + H5_obj_t src_obj_pos; /* Location of source object */ + haddr_t dst_addr; /* Address of object in destination file */ + 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 */ } H5O_addr_map_t; /* Stack of continuation messages to interpret */ typedef struct H5O_cont_msgs_t { - size_t nmsgs; /* Number of continuation messages found so far */ - size_t alloc_nmsgs; /* Continuation messages allocated */ - H5O_cont_t *msgs; /* Array of continuation messages */ + size_t nmsgs; /* Number of continuation messages found so far */ + size_t alloc_nmsgs; /* Continuation messages allocated */ + H5O_cont_t *msgs; /* Array of continuation messages */ } 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 */ - 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 */ - haddr_t addr; /* Address of the prefix or 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 */ + haddr_t addr; /* Address of the prefix or chunk */ } H5O_common_cache_ud_t; /* Callback information for loading object header prefix from disk */ 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 */ - hbool_t free_oh; /* Whether to free the object header or not */ - H5O_common_cache_ud_t common; /* Common object header cache callback info */ + 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 */ + 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; /* Structure representing each chunk in the cache */ typedef struct H5O_chunk_proxy_t { - H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ - /* first field in structure */ + 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 */ - unsigned chunkno; /* Chunk number 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) * @@ -402,16 +389,16 @@ typedef struct H5O_chunk_proxy_t { * parent of the chunk proxy will be either its object header * or the chunk with the continuation message that references this chunk. */ - void *fd_parent; /* Pointer to flush dependency parent */ + void *fd_parent; /* Pointer to flush dependency parent */ } 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 */ - 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 */ + hbool_t decoding; /* Whether the object header is being decoded */ + 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 */ } H5O_chk_cache_ud_t; /* Header message ID to class mapping */ @@ -539,7 +526,6 @@ H5_DLLVAR const H5O_msg_class_t H5O_MSG_MDCI[1]; /* Placeholder for unknown message. (0x0019) */ H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1]; - /* * Object header "object" types */ @@ -554,87 +540,81 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATASET[1]; H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; /* Package-local function prototypes */ -H5_DLL hid_t H5O__open_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL hid_t H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr); -H5_DLL hid_t H5O__open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref); +H5_DLL void *H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type /*out*/); +H5_DLL void *H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type /*out*/); H5_DLL const H5O_obj_class_t *H5O__obj_class(const H5O_loc_t *loc); -H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); -H5_DLL herr_t H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields); -H5_DLL herr_t H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields); +H5_DLL herr_t H5O__copy(const H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, + const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id); +H5_DLL int H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted); +H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + H5O_iterate2_t op, void *op_data, unsigned fields); H5_DLL herr_t H5O__inc_rc(H5O_t *oh); H5_DLL herr_t H5O__dec_rc(H5O_t *oh); H5_DLL herr_t H5O__free(H5O_t *oh); /* Object header message routines */ -H5_DLL herr_t H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *mesg, size_t *mesg_idx); -H5_DLL herr_t H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL void *H5O__msg_free_real(const H5O_msg_class_t *type, void *mesg); -H5_DLL herr_t H5O__msg_free_mesg(H5O_mesg_t *mesg); -H5_DLL unsigned H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type); -H5_DLL herr_t H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link); -H5_DLL void *H5O__msg_copy_file(const H5O_msg_class_t *type, 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); +H5_DLL herr_t H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned *mesg_flags, + void *mesg, size_t *mesg_idx); +H5_DLL herr_t H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O__msg_free_mesg(H5O_mesg_t *mesg); +H5_DLL unsigned H5O__msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type); +H5_DLL herr_t H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int sequence, + H5O_operator_t op, void *op_data, hbool_t adj_link); +H5_DLL void *H5O__msg_copy_file(const H5O_msg_class_t *type, 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); H5_DLL herr_t H5O__msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const H5O_mesg_operator_t *op, void *op_data); -H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg); -H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh); + const H5O_mesg_operator_t *op, void *op_data); +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 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); -H5_DLL herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy); -H5_DLL herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx); -H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy); +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); +H5_DLL herr_t H5O__chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy); +H5_DLL herr_t H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx); +H5_DLL herr_t H5O__chunk_dest(H5O_chunk_proxy_t *chunk_proxy); /* Collect storage info for btree and heap */ H5_DLL herr_t H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info); /* Object header allocation routines */ -H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); -H5_DLL 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); -H5_DLL herr_t H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg, size_t *mesg_idx); -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); +H5_DLL herr_t H5O__alloc_msgs(H5O_t *oh, size_t min_alloc); +H5_DLL 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); +H5_DLL herr_t H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const void *mesg, + size_t *mesg_idx); +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, 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); -H5_DLL herr_t H5O__shared_delete(H5F_t *f, H5O_t *open_oh, - const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg); -H5_DLL herr_t H5O__shared_link(H5F_t *f, H5O_t *open_oh, - const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg); -H5_DLL herr_t H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, - const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, - hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, - void *udata); -H5_DLL herr_t H5O__shared_post_copy_file (H5F_t *f, - const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src, - H5O_shared_t *shared_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); -H5_DLL herr_t H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream, - int indent, int fwidth); +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); +H5_DLL herr_t H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *mesg_type, + H5O_shared_t *sh_mesg); +H5_DLL herr_t H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *mesg_type, + H5O_shared_t *sh_mesg); +H5_DLL herr_t H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, const H5O_msg_class_t *mesg_type, + const void *_native_src, void *_native_dst, hbool_t *recompute_size, + unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); +H5_DLL herr_t H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, + const H5O_shared_t *shared_src, H5O_shared_t *shared_dst, + unsigned *mesg_flags, H5O_copy_t *cpy_info); +H5_DLL herr_t H5O__shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth); /* Attribute message operators */ H5_DLL herr_t H5O__attr_reset(void *_mesg); H5_DLL herr_t H5O__attr_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); H5_DLL herr_t H5O__attr_link(H5F_t *f, H5O_t *open_oh, void *_mesg); -H5_DLL herr_t H5O_attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs); +H5_DLL herr_t H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs); /* Arrays of versions for: * Object header, Attribute/Fill value/Filter pipeline messages @@ -660,9 +640,8 @@ H5_DLL herr_t H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type); /* Object header debugging routines */ #ifdef H5O_DEBUG -H5_DLL herr_t H5O_assert(const H5O_t *oh); +H5_DLL herr_t H5O__assert(const H5O_t *oh); #endif /* H5O_DEBUG */ -H5_DLL herr_t H5O_debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth); - -#endif /* _H5Opkg_H */ +H5_DLL herr_t H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth); +#endif /* H5Opkg_H */ diff --git a/src/H5Opline.c b/src/H5Opline.c index 90e962628f7..4b76da9443c 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,88 +18,85 @@ * Purpose: Data filter pipeline message. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5Z_FRIEND /*suppress error about including H5Zpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5Z_FRIEND /*suppress error about including H5Zpkg */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Zpkg.h" /* Data filters */ /* 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, size_t p_size, const uint8_t *p); -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_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, + size_t p_size, const uint8_t *p); +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); -static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, - const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static herr_t H5O__pline_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__pline_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *_udata); +static herr_t H5O__pline_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_PLINE -#define H5O_SHARED_DECODE H5O_pline_shared_decode -#define H5O_SHARED_DECODE_REAL H5O__pline_decode -#define H5O_SHARED_ENCODE H5O_pline_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_pline_encode -#define H5O_SHARED_SIZE H5O_pline_shared_size -#define H5O_SHARED_SIZE_REAL H5O_pline_size -#define H5O_SHARED_DELETE H5O__pline_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_PLINE +#define H5O_SHARED_DECODE H5O__pline_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__pline_decode +#define H5O_SHARED_ENCODE H5O__pline_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O__pline_encode +#define H5O_SHARED_SIZE H5O__pline_shared_size +#define H5O_SHARED_SIZE_REAL H5O__pline_size +#define H5O_SHARED_DELETE H5O__pline_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__pline_shared_link +#define H5O_SHARED_LINK H5O__pline_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__pline_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__pline_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_pline_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__pline_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_pline_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__pline_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O__pline_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__pline_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ 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_pline_shared_decode, /* decode message */ - H5O_pline_shared_encode, /* encode message */ - H5O_pline_copy, /* copy the native value */ - H5O_pline_shared_size, /* size of raw message */ - H5O__pline_reset, /* reset method */ - H5O__pline_free, /* free method */ - H5O__pline_shared_delete, /* file delete method */ - H5O__pline_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O_pline_pre_copy_file, /* pre copy native value to file */ - H5O__pline_shared_copy_file, /* copy native value to file */ - H5O_pline_shared_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_pline_shared_debug /* debug the message */ + 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__pline_shared_decode, /* decode message */ + H5O__pline_shared_encode, /* encode message */ + H5O__pline_copy, /* copy the native value */ + H5O__pline_shared_size, /* size of raw message */ + H5O__pline_reset, /* reset method */ + H5O__pline_free, /* free method */ + H5O__pline_shared_delete, /* file delete method */ + H5O__pline_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__pline_pre_copy_file, /* pre copy native value to file */ + H5O__pline_shared_copy_file, /* copy native value to file */ + H5O__pline_shared_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__pline_shared_debug /* debug the message */ }}; /* Format version bounds for filter pipleline */ const unsigned H5O_pline_ver_bounds[] = { - H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_PLINE_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_PLINE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5O_pline_t struct */ H5FL_DEFINE(H5O_pline_t); - /*------------------------------------------------------------------------- * Function: H5O__pline_decode * @@ -114,16 +111,15 @@ 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_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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -131,17 +127,17 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Allocate space for I/O pipeline message */ - if(NULL == (pline = H5FL_CALLOC(H5O_pline_t))) + if (NULL == (pline = H5FL_CALLOC(H5O_pline_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ pline->version = *p++; - if(pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST) + 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") /* Number of filters */ pline->nused = *p++; - if(pline->nused > H5Z_MAX_NFILTERS) { + if (pline->nused > H5Z_MAX_NFILTERS) { /* Reset the number of filters used to avoid array traversal in error * handling code. @@ -152,25 +148,25 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* Reserved */ - if(pline->version == H5O_PLINE_VERSION_1) + if (pline->version == H5O_PLINE_VERSION_1) p += 6; /* Allocate array for filters */ pline->nalloc = pline->nused; - if(NULL == (pline->filter = (H5Z_filter_info_t *)H5MM_calloc(pline->nalloc * sizeof(pline->filter[0])))) + if (NULL == (pline->filter = (H5Z_filter_info_t *)H5MM_calloc(pline->nalloc * sizeof(pline->filter[0])))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Decode filters */ - for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { + for (i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { /* Filter ID */ UINT16DECODE(p, filter->id); /* Length of filter name */ - if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) + if (pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) name_length = 0; else { UINT16DECODE(p, name_length); - if(pline->version == H5O_PLINE_VERSION_1 && name_length % 8) + 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") } /* end if */ @@ -181,17 +177,17 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, UINT16DECODE(p, filter->cd_nelmts); /* Filter name, if there is one */ - if(name_length) { - size_t actual_name_length; /* Actual length of name */ + if (name_length) { + size_t actual_name_length; /* Actual length of name */ /* Determine actual name length (without padding, but with null terminator) */ actual_name_length = HDstrlen((const char *)p) + 1; HDassert(actual_name_length <= name_length); /* Allocate space for the filter name, or use the internal buffer */ - if(actual_name_length > H5Z_COMMON_NAME_LEN) { + if (actual_name_length > H5Z_COMMON_NAME_LEN) { filter->name = (char *)H5MM_malloc(actual_name_length); - if(NULL == filter->name) + if (NULL == filter->name) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name") } /* end if */ else @@ -202,13 +198,13 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, } /* end if */ /* Filter parameters */ - if(filter->cd_nelmts) { - size_t j; /* Local index variable */ + if (filter->cd_nelmts) { + size_t j; /* Local index variable */ /* Allocate space for the client data elements, or use the internal buffer */ - if(filter->cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (filter->cd_nelmts > H5Z_COMMON_CD_VALUES) { filter->cd_values = (unsigned *)H5MM_malloc(filter->cd_nelmts * sizeof(unsigned)); - if(NULL == filter->cd_values) + if (NULL == filter->cd_values) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for client data") } /* end if */ else @@ -221,20 +217,22 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, if (p + 4 - 1 <= p_end) UINT32DECODE(p, filter->cd_values[j]) else - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "ran off the end of the buffer: current p = %p, p_size = %zu, p_end = %p", p, p_size, p_end) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "ran off the end of the buffer: current p = %p, p_size = %zu, p_end = %p", + (const void *)p, p_size, (const void *)p_end) } - if(pline->version == H5O_PLINE_VERSION_1) - if(filter->cd_nelmts % 2) + if (pline->version == H5O_PLINE_VERSION_1) + if (filter->cd_nelmts % 2) p += 4; /*padding*/ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Set return value */ ret_value = pline; done: - if(NULL == ret_value && pline) { + if (NULL == ret_value && pline) { H5O__pline_reset(pline); H5O__pline_free(pline); } /* end if */ @@ -242,9 +240,8 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__pline_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_pline_encode + * Function: H5O__pline_encode * * Purpose: Encodes message MESG into buffer P. * @@ -256,13 +253,13 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) +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 H5Z_filter_info_t *filter; /* Filter to encode */ - size_t i, j; /* Local index variables */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(p); @@ -271,37 +268,37 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) /* Message header */ *p++ = (uint8_t)pline->version; *p++ = (uint8_t)(pline->nused); - if(pline->version == H5O_PLINE_VERSION_1) { - *p++ = 0; /*reserved 1*/ - *p++ = 0; /*reserved 2*/ - *p++ = 0; /*reserved 3*/ - *p++ = 0; /*reserved 4*/ - *p++ = 0; /*reserved 5*/ - *p++ = 0; /*reserved 6*/ - } /* end if */ + if (pline->version == H5O_PLINE_VERSION_1) { + *p++ = 0; /*reserved 1*/ + *p++ = 0; /*reserved 2*/ + *p++ = 0; /*reserved 3*/ + *p++ = 0; /*reserved 4*/ + *p++ = 0; /*reserved 5*/ + *p++ = 0; /*reserved 6*/ + } /* end if */ /* Encode filters */ - for(i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { - const char *name; /* Filter name */ - size_t name_length; /* Length of filter name */ + for (i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { + const char *name; /* Filter name */ + size_t name_length; /* Length of filter name */ /* Filter ID */ UINT16ENCODE(p, filter->id); /* Skip writing the name length & name if the filter is an internal filter */ - if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { + if (pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { name_length = 0; - name = NULL; + name = NULL; } /* end if */ else { - H5Z_class2_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ /* * Get the filter name. If the pipeline message has a name in it then * use that one. Otherwise try to look up the filter and get the name * as it was registered. */ - if(NULL == (name = filter->name) && (cls = H5Z_find(filter->id))) + if (NULL == (name = filter->name) && (cls = H5Z_find(filter->id))) name = cls->name; name_length = name ? HDstrlen(name) + 1 : 0; @@ -316,33 +313,32 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) UINT16ENCODE(p, filter->cd_nelmts); /* Encode name, if there is one to encode */ - if(name_length > 0) { + if (name_length > 0) { /* Store name, with null terminator */ H5MM_memcpy(p, name, name_length); p += name_length; /* Pad out name to alignment, in older versions */ - if(pline->version == H5O_PLINE_VERSION_1) - while(name_length++ % 8) + if (pline->version == H5O_PLINE_VERSION_1) + while (name_length++ % 8) *p++ = 0; } /* end if */ /* Filter parameters */ - for(j = 0; j < filter->cd_nelmts; j++) + for (j = 0; j < filter->cd_nelmts; j++) UINT32ENCODE(p, filter->cd_values[j]); /* Align the parameters for older versions of the format */ - if(pline->version == H5O_PLINE_VERSION_1) - if(filter->cd_nelmts % 2) + if (pline->version == H5O_PLINE_VERSION_1) + if (filter->cd_nelmts % 2) UINT32ENCODE(p, 0); } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_pline_encode() */ - +} /* end H5O__pline_encode() */ /*------------------------------------------------------------------------- - * Function: H5O_pline_copy + * Function: H5O__pline_copy * * Purpose: Copies a filter pipeline message from SRC to DST allocating * DST if necessary. If DST is already allocated then we assume @@ -358,17 +354,17 @@ H5O_pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p/*out*/, const void *mesg) *------------------------------------------------------------------------- */ static void * -H5O_pline_copy(const void *_src, void *_dst/*out*/) +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 */ - size_t i; /* Local index variable */ - H5O_pline_t *ret_value = NULL; /* Return value */ + const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Allocate pipeline message, if not provided */ - if(!dst && NULL == (dst = H5FL_MALLOC(H5O_pline_t))) + if (!dst && NULL == (dst = H5FL_MALLOC(H5O_pline_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy basic fields */ @@ -376,66 +372,67 @@ H5O_pline_copy(const void *_src, void *_dst/*out*/) /* Copy over filters, if any */ dst->nalloc = dst->nused; - if(dst->nalloc) { + if (dst->nalloc) { /* Allocate array to hold filters */ - if(NULL == (dst->filter = (H5Z_filter_info_t *)H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (dst->filter = (H5Z_filter_info_t *)H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Deep-copy filters */ - for(i = 0; i < src->nused; i++) { + for (i = 0; i < src->nused; i++) { /* Basic filter information */ dst->filter[i] = src->filter[i]; /* Filter name */ - if(src->filter[i].name) { - size_t namelen; /* Length of source filter name, including null terminator */ + if (src->filter[i].name) { + size_t namelen; /* Length of source filter name, including null terminator */ namelen = HDstrlen(src->filter[i].name) + 1; /* Allocate space for the filter name, or use the internal buffer */ - if(namelen > H5Z_COMMON_NAME_LEN) { + if (namelen > H5Z_COMMON_NAME_LEN) { dst->filter[i].name = (char *)H5MM_strdup(src->filter[i].name); - if(NULL == dst->filter[i].name) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name") + if (NULL == dst->filter[i].name) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for filter name") } /* end if */ else dst->filter[i].name = dst->filter[i]._name; } /* end if */ /* Filter parameters */ - if(src->filter[i].cd_nelmts > 0) { + if (src->filter[i].cd_nelmts > 0) { /* Allocate space for the client data elements, or use the internal buffer */ - if(src->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES) { - if(NULL == (dst->filter[i].cd_values = (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts* sizeof(unsigned)))) + if (src->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (NULL == (dst->filter[i].cd_values = + (unsigned *)H5MM_malloc(src->filter[i].cd_nelmts * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(dst->filter[i].cd_values, src->filter[i].cd_values, - src->filter[i].cd_nelmts * sizeof(unsigned)); + src->filter[i].cd_nelmts * sizeof(unsigned)); } /* end if */ else dst->filter[i].cd_values = dst->filter[i]._cd_values; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else - dst->filter = NULL; + dst->filter = NULL; /* Set return value */ ret_value = dst; done: - if(!ret_value && dst) { + if (!ret_value && dst) { H5O__pline_reset(dst); - if(!_dst) + if (!_dst) H5O__pline_free(dst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_pline_copy() */ - +} /* end H5O__pline_copy() */ /*------------------------------------------------------------------------- - * Function: H5O_pline_size + * Function: H5O__pline_size * * Purpose: Determines the size of a raw filter pipeline message. * @@ -449,51 +446,54 @@ H5O_pline_copy(const void *_src, void *_dst/*out*/) *------------------------------------------------------------------------- */ static size_t -H5O_pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) +H5O__pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) { - const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message */ - size_t i; /* Local index variable */ - size_t ret_value = 0; /* Return value */ + const H5O_pline_t *pline = (const H5O_pline_t *)mesg; /* Pipeline message */ + size_t i; /* Local index variable */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Message header */ - ret_value = (size_t)(1 + /*version */ - 1 + /*number of filters */ - (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0)); /*reserved */ + ret_value = (size_t)(1 + /*version */ + 1 + /*number of filters */ + (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0)); /*reserved */ /* Calculate size of each filter in pipeline */ - for(i = 0; i < pline->nused; i++) { - size_t name_len; /* Length of filter name */ - const char *name; /* Filter name */ + for (i = 0; i < pline->nused; i++) { + size_t name_len; /* Length of filter name */ + const char *name; /* Filter name */ /* Don't write the name length & name if the filter is an internal filter */ - if(pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) + if (pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) name_len = 0; else { - H5Z_class2_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ - /* Get the name of the filter, same as done with H5O_pline_encode() */ - if(NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id))) + /* Get the name of the filter, same as done with H5O__pline_encode() */ + if (NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id))) name = cls->name; name_len = name ? HDstrlen(name) + 1 : 0; } /* end else */ - ret_value += 2 + /*filter identification number */ - (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ - 2 + /*flags */ - 2 + /*number of client data values */ - (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ + ret_value += + 2 + /*filter identification number */ + (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) + ? 2 + : 0) + /*name length */ + 2 + /*flags */ + 2 + /*number of client data values */ + (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) + : name_len); /*length of the filter name */ ret_value += pline->filter[i].cd_nelmts * 4; - if(pline->version == H5O_PLINE_VERSION_1) - if(pline->filter[i].cd_nelmts % 2) + if (pline->version == H5O_PLINE_VERSION_1) + if (pline->filter[i].cd_nelmts % 2) ret_value += 4; } /* end for */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_pline_size() */ - +} /* end H5O__pline_size() */ /*------------------------------------------------------------------------- * Function: H5O__pline_reset @@ -511,8 +511,8 @@ H5O_pline_size(const H5F_t H5_ATTR_UNUSED *f, const void *mesg) static herr_t H5O__pline_reset(void *mesg) { - H5O_pline_t *pline = (H5O_pline_t*)mesg; /* Pipeline message */ - size_t i; /* Local index variable */ + H5O_pline_t *pline = (H5O_pline_t *)mesg; /* Pipeline message */ + size_t i; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -523,16 +523,16 @@ H5O__pline_reset(void *mesg) HDassert(pline); /* Free the filter information and array */ - if(pline->filter) { + if (pline->filter) { /* Free information for each filter */ - for(i = 0; i < pline->nused; i++) { - if(pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) + for (i = 0; i < pline->nused; i++) { + if (pline->filter[i].name && pline->filter[i].name != pline->filter[i]._name) HDassert((HDstrlen(pline->filter[i].name) + 1) > H5Z_COMMON_NAME_LEN); - if(pline->filter[i].name != pline->filter[i]._name) + if (pline->filter[i].name != pline->filter[i]._name) pline->filter[i].name = (char *)H5MM_xfree(pline->filter[i].name); - if(pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) + if (pline->filter[i].cd_values && pline->filter[i].cd_values != pline->filter[i]._cd_values) HDassert(pline->filter[i].cd_nelmts > H5Z_COMMON_CD_VALUES); - if(pline->filter[i].cd_values != pline->filter[i]._cd_values) + if (pline->filter[i].cd_values != pline->filter[i]._cd_values) pline->filter[i].cd_values = (unsigned *)H5MM_xfree(pline->filter[i].cd_values); } /* end for */ @@ -549,7 +549,6 @@ H5O__pline_reset(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__pline_free * @@ -574,9 +573,8 @@ H5O__pline_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_free() */ - /*------------------------------------------------------------------------- - * Function: H5O_pline_pre_copy_file + * Function: H5O__pline_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files @@ -591,14 +589,14 @@ H5O__pline_free(void *mesg) *------------------------------------------------------------------------- */ 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) +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 */ - 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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(pline_src); @@ -607,21 +605,20 @@ H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(pline_src->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (pline_src->version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "pline message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset or group * and make a copy of the filter pipeline for later in * the object copying process. */ - if(udata) - if(NULL == (udata->src_pline = (H5O_pline_t *)H5O_pline_copy(pline_src, NULL))) + if (udata) + if (NULL == (udata->src_pline = (H5O_pline_t *)H5O__pline_copy(pline_src, NULL))) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to copy") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_pline_pre_copy_file() */ - +} /* end H5O__pline_pre_copy_file() */ /*------------------------------------------------------------------------- * Function: H5O__pline_debug @@ -638,11 +635,10 @@ H5O_pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, - int indent, int fwidth) +H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5O_pline_t *pline = (const H5O_pline_t *)mesg; - size_t i, j; + const H5O_pline_t *pline = (const H5O_pline_t *)mesg; + size_t i, j; FUNC_ENTER_STATIC_NOERR @@ -653,49 +649,40 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %Zu/%Zu\n", indent, "", fwidth, - "Number of filters:", - pline->nused, - pline->nalloc); + HDfprintf(stream, "%*s%-*s %zu/%zu\n", indent, "", fwidth, "Number of filters:", pline->nused, + pline->nalloc); /* Loop over all the filters */ - for(i = 0; i < pline->nused; i++) { - char name[32]; + for (i = 0; i < pline->nused; i++) { + char name[32]; - HDsnprintf(name, sizeof(name), "Filter at position %u", (unsigned)i); + HDsnprintf(name, sizeof(name), "Filter at position %zu", i); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter identification:", - (unsigned)(pline->filter[i].id)); - if(pline->filter[i].name) + "Filter identification:", (unsigned)(pline->filter[i].id)); + if (pline->filter[i].name) HDfprintf(stream, "%*s%-*s \"%s\"\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter name:", - pline->filter[i].name); + "Filter name:", pline->filter[i].name); else - HDfprintf(stream, "%*s%-*s NONE\n", indent + 3, "", MAX(0, fwidth - 3), - "Filter name:"); + HDfprintf(stream, "%*s%-*s NONE\n", indent + 3, "", MAX(0, fwidth - 3), "Filter name:"); HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), - "Flags:", - pline->filter[i].flags); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", MAX(0, fwidth - 3), - "Num CD values:", - pline->filter[i].cd_nelmts); + "Flags:", pline->filter[i].flags); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", MAX(0, fwidth - 3), + "Num CD values:", pline->filter[i].cd_nelmts); - /* Filter parameters */ - for(j = 0; j < pline->filter[i].cd_nelmts; j++) { - char field_name[32]; + /* Filter parameters */ + for (j = 0; j < pline->filter[i].cd_nelmts; j++) { + char field_name[32]; HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j); - HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), - field_name, - pline->filter[i].cd_values[j]); + HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), field_name, + pline->filter[i].cd_values[j]); } /* end for */ - } /* end for */ + } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__pline_debug() */ - /*------------------------------------------------------------------------- * Function: H5O_pline_set_version * @@ -710,8 +697,8 @@ H5O__pline_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -723,7 +710,7 @@ H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline) version = MAX(pline->version, H5O_pline_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_pline_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_PLINE, H5E_BADRANGE, FAIL, "Filter pipeline version out of bounds") /* Set the message version */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 4768ab08eb9..6d901b38e2b 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,33 +21,34 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5Oprivate_H -#define _H5Oprivate_H +#ifndef H5Oprivate_H +#define H5Oprivate_H /* Early typedefs to avoid circular dependencies */ -typedef struct H5O_t H5O_t; +typedef struct H5O_t H5O_t; typedef struct H5O_fill_t H5O_fill_t; /* Include the public header file for this API */ -#include "H5Opublic.h" /* Object header functions */ +#include "H5Opublic.h" /* Object header functions */ /* Public headers needed by this file */ -#include "H5Dpublic.h" /* Dataset functions */ -#include "H5Lpublic.h" /* Link functions */ -#include "H5Spublic.h" /* Dataspace functions */ +#include "H5Dpublic.h" /* Dataset functions */ +#include "H5Lpublic.h" /* Link functions */ +#include "H5Spublic.h" /* Dataspace functions */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Fprivate.h" /* File access */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatype functions */ -#include "H5Zprivate.h" /* I/O pipeline filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatype functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5Zprivate.h" /* I/O pipeline filters */ /* Forward references of package typedefs */ typedef struct H5O_msg_class_t H5O_msg_class_t; -typedef struct H5O_mesg_t H5O_mesg_t; +typedef struct H5O_mesg_t H5O_mesg_t; /* Values used to create the shared message & attribute heaps */ /* (Note that these parameters have been tuned so that the resulting heap ID @@ -55,35 +56,38 @@ typedef struct H5O_mesg_t H5O_mesg_t; * directly in an 8 byte integer in memory, think carefully before changing it. * -QAK) */ -#define H5O_FHEAP_MAN_WIDTH 4 -#define H5O_FHEAP_MAN_START_BLOCK_SIZE 1024 -#define H5O_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) -#define H5O_FHEAP_MAN_MAX_INDEX 40 -#define H5O_FHEAP_MAN_START_ROOT_ROWS 1 -#define H5O_FHEAP_CHECKSUM_DBLOCKS TRUE -#define H5O_FHEAP_MAX_MAN_SIZE (4 * 1024) -#define H5O_FHEAP_ID_LEN 8 +#define H5O_FHEAP_MAN_WIDTH 4 +#define H5O_FHEAP_MAN_START_BLOCK_SIZE 1024 +#define H5O_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024) +#define H5O_FHEAP_MAN_MAX_INDEX 40 +#define H5O_FHEAP_MAN_START_ROOT_ROWS 1 +#define H5O_FHEAP_CHECKSUM_DBLOCKS TRUE +#define H5O_FHEAP_MAX_MAN_SIZE (4 * 1024) +#define H5O_FHEAP_ID_LEN 8 /* Object header macros */ -#define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ -#define H5O_ALL (-1) /* Operate on all messages of type */ -#define H5O_FIRST (-2) /* Operate on first message of type */ +#define H5O_MESG_MAX_SIZE 65536 /*max obj header message size */ +#define H5O_ALL (-1) /* Operate on all messages of type */ +#define H5O_FIRST (-2) /* Operate on first message of type */ /* Flags needed when encoding messages */ -#define H5O_MSG_NO_FLAGS_SET 0x00u -#define H5O_MSG_FLAG_CONSTANT 0x01u -#define H5O_MSG_FLAG_SHARED 0x02u -#define H5O_MSG_FLAG_DONTSHARE 0x04u +#define H5O_MSG_NO_FLAGS_SET 0x00u +#define H5O_MSG_FLAG_CONSTANT 0x01u +#define H5O_MSG_FLAG_SHARED 0x02u +#define H5O_MSG_FLAG_DONTSHARE 0x04u #define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE 0x08u -#define H5O_MSG_FLAG_MARK_IF_UNKNOWN 0x10u -#define H5O_MSG_FLAG_WAS_UNKNOWN 0x20u -#define H5O_MSG_FLAG_SHAREABLE 0x40u -#define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS 0x80u -#define H5O_MSG_FLAG_BITS (H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_DONTSHARE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE|H5O_MSG_FLAG_MARK_IF_UNKNOWN|H5O_MSG_FLAG_WAS_UNKNOWN|H5O_MSG_FLAG_SHAREABLE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) +#define H5O_MSG_FLAG_MARK_IF_UNKNOWN 0x10u +#define H5O_MSG_FLAG_WAS_UNKNOWN 0x20u +#define H5O_MSG_FLAG_SHAREABLE 0x40u +#define H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS 0x80u +#define H5O_MSG_FLAG_BITS \ + (H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_SHARED | H5O_MSG_FLAG_DONTSHARE | \ + H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE | H5O_MSG_FLAG_MARK_IF_UNKNOWN | \ + H5O_MSG_FLAG_WAS_UNKNOWN | H5O_MSG_FLAG_SHAREABLE | H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) /* Flags for updating messages */ -#define H5O_UPDATE_TIME 0x01u -#define H5O_UPDATE_FORCE 0x02u /* Force updating the message */ +#define H5O_UPDATE_TIME 0x01u +#define H5O_UPDATE_FORCE 0x02u /* Force updating the message */ /* Hash value constants */ #define H5O_HASH_SIZE 32 @@ -92,30 +96,36 @@ typedef struct H5O_mesg_t H5O_mesg_t; /* #define H5O_ENABLE_BOGUS */ /* ========= Object Creation properties ============ */ -#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */ -#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */ -#define H5O_CRT_OHDR_FLAGS_NAME "object header flags" /* Object header flags */ -#define H5O_CRT_PIPELINE_NAME "pline" /* Filter pipeline */ -#define H5O_CRT_PIPELINE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_PLINE_VERSION_1, 0, 0, NULL} +#define H5O_CRT_ATTR_MAX_COMPACT_NAME "max compact attr" /* Max. # of attributes to store compactly */ +#define H5O_CRT_ATTR_MIN_DENSE_NAME "min dense attr" /* Min. # of attributes to store densely */ +#define H5O_CRT_OHDR_FLAGS_NAME "object header flags" /* Object header flags */ +#define H5O_CRT_PIPELINE_NAME "pline" /* Filter pipeline */ +#define H5O_CRT_PIPELINE_DEF \ + { \ + {0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_PLINE_VERSION_1, 0, 0, NULL \ + } #ifdef H5O_ENABLE_BOGUS -#define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ -#define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) +#define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ +#define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) /* bogus ID can be either (a) H5O_BOGUS_VALID_ID or (b) H5O_BOGUS_INVALID_ID */ -#define H5O_BOGUS_MSG_ID_NAME "bogus msg id" /* ID for 'bogus' message */ -#define H5O_BOGUS_MSG_ID_SIZE sizeof(unsigned) +#define H5O_BOGUS_MSG_ID_NAME "bogus msg id" /* ID for 'bogus' message */ +#define H5O_BOGUS_MSG_ID_SIZE sizeof(unsigned) #endif /* H5O_ENABLE_BOGUS */ #ifdef H5O_ENABLE_BAD_MESG_COUNT -#define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ -#define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) +#define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ +#define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* ========= Object Copy properties ============ */ -#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ -#define H5O_CPY_MERGE_COMM_DT_LIST_NAME "merge committed dtype list" /* List of datatype paths to search in the dest file for merging */ -#define H5O_CPY_MCDT_SEARCH_CB_NAME "committed dtype list search" /* Callback function when the search for a matching committed datatype is complete */ +#define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ +#define H5O_CPY_MERGE_COMM_DT_LIST_NAME \ + "merge committed dtype list" /* List of datatype paths to search in the dest file for merging */ +#define H5O_CPY_MCDT_SEARCH_CB_NAME \ + "committed dtype list search" /* Callback function when the search for a matching committed datatype is \ + complete */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5O_MODULE @@ -131,97 +141,98 @@ typedef struct H5O_mesg_t H5O_mesg_t; #endif /* H5O_MODULE */ /* Set the fields in a shared message structure */ -#define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ - { \ - (SH_MESG)->type = (SH_TYPE); \ - (SH_MESG)->file = (F); \ - (SH_MESG)->msg_type_id = (MSG_TYPE); \ - (SH_MESG)->u.loc.index = (CRT_IDX); \ - (SH_MESG)->u.loc.oh_addr = (OH_ADDR); \ +#define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ + { \ + (SH_MESG)->type = (SH_TYPE); \ + (SH_MESG)->file = (F); \ + (SH_MESG)->msg_type_id = (MSG_TYPE); \ + (SH_MESG)->u.loc.index = (CRT_IDX); \ + (SH_MESG)->u.loc.oh_addr = (OH_ADDR); \ } /* end block */ - /* Fractal heap ID type for shared message & attribute heap IDs. */ typedef union { - uint8_t id[H5O_FHEAP_ID_LEN]; /* Buffer to hold ID, for encoding/decoding */ - uint64_t val; /* Value, for quick comparisons */ + uint8_t id[H5O_FHEAP_ID_LEN]; /* Buffer to hold ID, for encoding/decoding */ + uint64_t val; /* Value, for quick comparisons */ } H5O_fheap_id_t; /* The object location information for an object */ typedef struct H5O_loc_t { - 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. */ + 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. */ } 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; + H5O_mcdt_search_cb_t func; + void * user_data; } H5O_mcdt_cb_info_t; /* Settings/flags for copying an object */ typedef struct H5O_copy_t { - hbool_t copy_shallow; /* Flag to perform shallow hierarchy copy */ - hbool_t expand_soft_link; /* Flag to expand soft links */ - hbool_t expand_ext_link; /* Flag to expand external links */ - hbool_t expand_ref; /* Flag to expand object references */ - hbool_t copy_without_attr; /* Flag to not copy attributes */ - hbool_t preserve_null; /* Flag to not delete NULL messages */ - hbool_t merge_comm_dt; /* Flag to merge committed datatypes in dest file */ + hbool_t copy_shallow; /* Flag to perform shallow hierarchy copy */ + hbool_t expand_soft_link; /* Flag to expand soft links */ + hbool_t expand_ext_link; /* Flag to expand external links */ + hbool_t expand_ref; /* Flag to expand object references */ + hbool_t copy_without_attr; /* Flag to not copy attributes */ + hbool_t preserve_null; /* Flag to not delete NULL messages */ + hbool_t merge_comm_dt; /* Flag to merge committed datatypes in dest file */ 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 */ - 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 */ - H5F_t *file_dst; /* The destination file pointer */ - /* This is used in the pre_copy_file callback to obtain - 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 */ - 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 */ - hid_t lcpl_id; /* LCPL for callbacks' use */ + 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 */ + 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 */ + H5F_t *file_dst; /* The destination file pointer */ + /* This is used in the pre_copy_file callback to obtain + 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 */ + 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 */ + hid_t lcpl_id; /* LCPL for callbacks' use */ } H5O_copy_t; /* Header message IDs */ -#define H5O_NULL_ID 0x0000 /* Null Message. */ -#define H5O_SDSPACE_ID 0x0001 /* Dataspace Message. */ -#define H5O_LINFO_ID 0x0002 /* Link info Message. */ -#define H5O_DTYPE_ID 0x0003 /* Datatype Message. */ -#define H5O_FILL_ID 0x0004 /* Fill Value Message. (Old) */ -#define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */ -#define H5O_LINK_ID 0x0006 /* Link Message. */ -#define H5O_EFL_ID 0x0007 /* External File List Message */ -#define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */ -#define H5O_BOGUS_VALID_ID 0x0009 /* "Bogus valid" Message. */ -#define H5O_GINFO_ID 0x000a /* Group info Message. */ -#define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ -#define H5O_ATTR_ID 0x000c /* Attribute Message. */ -#define H5O_NAME_ID 0x000d /* Object name message. */ -#define H5O_MTIME_ID 0x000e /* Modification time message. (Old) */ -#define H5O_SHMESG_ID 0x000f /* Shared message "SOHM" table. */ -#define H5O_CONT_ID 0x0010 /* Object header continuation message. */ -#define H5O_STAB_ID 0x0011 /* Symbol table message. */ -#define H5O_MTIME_NEW_ID 0x0012 /* Modification time message. (New) */ -#define H5O_BTREEK_ID 0x0013 /* v1 B-tree 'K' values message. */ -#define H5O_DRVINFO_ID 0x0014 /* Driver info message. */ -#define H5O_AINFO_ID 0x0015 /* Attribute info message. */ -#define H5O_REFCOUNT_ID 0x0016 /* Reference count message. */ -#define H5O_FSINFO_ID 0x0017 /* File space info message. */ -#define H5O_MDCI_MSG_ID 0x0018 /* Metadata Cache Image Message */ -#define H5O_UNKNOWN_ID 0x0019 /* Placeholder message ID for unknown message. */ - /* (this should never exist in a file) */ +#define H5O_NULL_ID 0x0000 /* Null Message. */ +#define H5O_SDSPACE_ID 0x0001 /* Dataspace Message. */ +#define H5O_LINFO_ID 0x0002 /* Link info Message. */ +#define H5O_DTYPE_ID 0x0003 /* Datatype Message. */ +#define H5O_FILL_ID 0x0004 /* Fill Value Message. (Old) */ +#define H5O_FILL_NEW_ID 0x0005 /* Fill Value Message. (New) */ +#define H5O_LINK_ID 0x0006 /* Link Message. */ +#define H5O_EFL_ID 0x0007 /* External File List Message */ +#define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */ +#define H5O_BOGUS_VALID_ID 0x0009 /* "Bogus valid" Message. */ +#define H5O_GINFO_ID 0x000a /* Group info Message. */ +#define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ +#define H5O_ATTR_ID 0x000c /* Attribute Message. */ +#define H5O_NAME_ID 0x000d /* Object name message. */ +#define H5O_MTIME_ID 0x000e /* Modification time message. (Old) */ +#define H5O_SHMESG_ID 0x000f /* Shared message "SOHM" table. */ +#define H5O_CONT_ID 0x0010 /* Object header continuation message. */ +#define H5O_STAB_ID 0x0011 /* Symbol table message. */ +#define H5O_MTIME_NEW_ID 0x0012 /* Modification time message. (New) */ +#define H5O_BTREEK_ID 0x0013 /* v1 B-tree 'K' values message. */ +#define H5O_DRVINFO_ID 0x0014 /* Driver info message. */ +#define H5O_AINFO_ID 0x0015 /* Attribute info message. */ +#define H5O_REFCOUNT_ID 0x0016 /* Reference count message. */ +#define H5O_FSINFO_ID 0x0017 /* File space info message. */ +#define H5O_MDCI_MSG_ID 0x0018 /* Metadata Cache Image Message */ +#define H5O_UNKNOWN_ID 0x0019 /* Placeholder message ID for unknown message. */ +/* (this should never exist in a file) */ /* * Note: Must increment H5O_MSG_TYPES in H5Opkg.h and update H5O_msg_class_g * in H5O.c when creating a new message type. Also bump the value of @@ -230,34 +241,33 @@ typedef struct H5O_copy_t { * * (this should never exist in a file) */ -#define H5O_BOGUS_INVALID_ID 0x001a /* "Bogus invalid" Message. */ +#define H5O_BOGUS_INVALID_ID 0x001a /* "Bogus invalid" Message. */ /* Shared object message types. * Shared objects can be committed, in which case the shared message contains * the location of the object header that holds the message, or shared in the * heap, in which case the shared message holds their heap ID. */ -#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_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 */ /* Detect messages that aren't stored in message's object header */ -#define H5O_IS_STORED_SHARED(T) ((((T) == H5O_SHARE_TYPE_SOHM) || ((T) == H5O_SHARE_TYPE_COMMITTED)) ? TRUE : FALSE) +#define H5O_IS_STORED_SHARED(T) \ + ((((T) == H5O_SHARE_TYPE_SOHM) || ((T) == H5O_SHARE_TYPE_COMMITTED)) ? TRUE : FALSE) /* Detect shared messages that are "tracked" in some other location */ #define H5O_IS_TRACKED_SHARED(T) ((T) > 0) - /* Specify the object header address and index needed * to locate a message in another object header. */ typedef struct H5O_mesg_loc_t { - H5O_msg_crt_idx_t index; /* index within object header */ - haddr_t oh_addr; /* address of object header */ + H5O_msg_crt_idx_t index; /* index within object header */ + haddr_t oh_addr; /* address of object header */ } H5O_mesg_loc_t; - /* * Shared object header message info. * @@ -265,16 +275,15 @@ typedef struct H5O_mesg_loc_t { * include a H5O_shared_t struct as the first field in their "native" type) */ typedef struct H5O_shared_t { - unsigned type; /* Type describing how message is shared */ - H5F_t *file; /* File that message is located within */ - unsigned msg_type_id; /* Message's type ID */ + unsigned type; /* Type describing how message is shared */ + 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 */ - H5O_fheap_id_t heap_id; /* ID within the SOHM heap */ + H5O_mesg_loc_t loc; /* Object location info */ + H5O_fheap_id_t heap_id; /* ID within the SOHM heap */ } u; } H5O_shared_t; - /* * Link Info Message. * (Contains dynamic information about links in a group) @@ -289,24 +298,24 @@ typedef struct H5O_shared_t { */ typedef struct H5O_linfo_t { /* Creation order info */ - hbool_t track_corder; /* Are creation order values tracked on links? */ - hbool_t index_corder; /* Are creation order values indexed on links? */ - int64_t max_corder; /* Current max. creation order value for group */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of links */ + hbool_t track_corder; /* Are creation order values tracked on links? */ + hbool_t index_corder; /* Are creation order values indexed on links? */ + int64_t max_corder; /* Current max. creation order value for group */ + haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of links */ /* Storage management info */ - hsize_t nlinks; /* Number of links in the group */ - haddr_t fheap_addr; /* Address of fractal heap for storing "dense" links */ - haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */ + hsize_t nlinks; /* Number of links in the group */ + haddr_t fheap_addr; /* Address of fractal heap for storing "dense" links */ + haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of links */ } H5O_linfo_t; /* Initial version of the "old" fill value information */ /* (It doesn't look like this value was ever used in the file -QAK) */ -#define H5O_FILL_VERSION_1 1 +#define H5O_FILL_VERSION_1 1 /* Revised version of the "new" fill value information */ -#define H5O_FILL_VERSION_2 2 +#define H5O_FILL_VERSION_2 2 /* Version of the "new" fill value information with smaller default format */ -#define H5O_FILL_VERSION_3 3 +#define H5O_FILL_VERSION_3 3 /* The latest version of the format. Look through the 'encode', 'decode' * and 'size' callback for places to change when updating this. */ @@ -322,15 +331,15 @@ typedef struct H5O_linfo_t { */ 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 */ - ssize_t size; /*number of bytes in 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 */ + 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 */ + ssize_t size; /*number of bytes in 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 */ }; /* @@ -338,28 +347,28 @@ struct H5O_fill_t { * (Data structure in memory) */ typedef struct H5O_link_hard_t { - haddr_t addr; /* Object header address */ + haddr_t addr; /* Object header address */ } H5O_link_hard_t; typedef struct H5O_link_soft_t { - char *name; /* Destination name */ + char *name; /* Destination name */ } H5O_link_soft_t; typedef struct H5O_link_ud_t { - void *udata; /* Opaque data supplied by the user */ - size_t size; /* Size of udata */ + void * udata; /* Opaque data supplied by the user */ + size_t size; /* Size of udata */ } H5O_link_ud_t; typedef struct H5O_link_t { - H5L_type_t type; /* Type of link */ - 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 */ + H5L_type_t type; /* Type of link */ + 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 */ union { - H5O_link_hard_t hard; /* Information for hard links */ - H5O_link_soft_t soft; /* Information for soft links */ - H5O_link_ud_t ud; /* Information for user-defined links */ + H5O_link_hard_t hard; /* Information for hard links */ + H5O_link_soft_t soft; /* Information for soft links */ + H5O_link_ud_t ud; /* Information for user-defined links */ } u; } H5O_link_t; @@ -367,53 +376,50 @@ typedef struct H5O_link_t { * External File List Message * (Data structure in memory) */ -#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ -#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ +#define H5O_EFL_ALLOC 16 /*number of slots to alloc at once */ +#define H5O_EFL_UNLIMITED H5F_UNLIMITED /*max possible file size */ typedef struct H5O_efl_entry_t { - size_t name_offset; /*offset of name within heap */ - char *name; /*malloc'd name */ - HDoff_t offset; /*offset of data within file */ - hsize_t size; /*size allocated within file */ + size_t name_offset; /*offset of name within heap */ + char * name; /*malloc'd name */ + HDoff_t offset; /*offset of data within file */ + hsize_t size; /*size allocated within file */ } H5O_efl_entry_t; typedef struct H5O_efl_t { - haddr_t heap_addr; /*address of name heap */ - size_t nalloc; /*number of slots allocated */ - size_t nused; /*number of slots used */ - H5O_efl_entry_t *slot; /*array of external file entries */ + haddr_t heap_addr; /*address of name heap */ + size_t nalloc; /*number of slots allocated */ + size_t nused; /*number of slots used */ + H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; - /* * Data Layout Message. * (Data structure in file) */ -#define H5O_LAYOUT_NDIMS (H5S_MAX_RANK+1) +#define H5O_LAYOUT_NDIMS (H5S_MAX_RANK + 1) /* Flags for chunked layout feature encoding */ -#define H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS 0x01 -#define H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER 0x02 -#define H5O_LAYOUT_ALL_CHUNK_FLAGS ( \ - H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS \ - | H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER \ - ) +#define H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS 0x01 +#define H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER 0x02 +#define H5O_LAYOUT_ALL_CHUNK_FLAGS \ + (H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS | H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) /* Version # of encoded virtual dataset global heap blocks */ -#define H5O_LAYOUT_VDS_GH_ENC_VERS 0 +#define H5O_LAYOUT_VDS_GH_ENC_VERS 0 /* Initial version of the layout information. Used when space is allocated */ -#define H5O_LAYOUT_VERSION_1 1 +#define H5O_LAYOUT_VERSION_1 1 /* This version added support for delaying allocation */ -#define H5O_LAYOUT_VERSION_2 2 +#define H5O_LAYOUT_VERSION_2 2 /* This version is revised to store just the information needed for each * storage type, and to straighten out problems with contiguous layout's * sizes (was encoding them as 4-byte values when they were really n-byte * values (where n usually is 8)). */ -#define H5O_LAYOUT_VERSION_3 3 +#define H5O_LAYOUT_VERSION_3 3 /* This version adds different types of indices to chunked datasets, allows * for larger chunk dimensions, stores chunk indices into their own @@ -422,7 +428,7 @@ typedef struct H5O_efl_t { * the storage used for partial chunks on boundaries, adds the virtual * layout type, etc. */ -#define H5O_LAYOUT_VERSION_4 4 +#define H5O_LAYOUT_VERSION_4 4 /* The default version of the format. (Earlier versions had bugs) */ #define H5O_LAYOUT_VERSION_DEFAULT H5O_LAYOUT_VERSION_3 @@ -432,215 +438,229 @@ typedef struct H5O_efl_t { #define H5O_LAYOUT_VERSION_LATEST H5O_LAYOUT_VERSION_4 /* Forward declaration of structs used below */ -struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ -struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ +struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ +struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ typedef struct H5O_storage_contig_t { - haddr_t addr; /* File address of data */ - hsize_t size; /* Size of data in bytes */ + haddr_t addr; /* File address of data */ + hsize_t size; /* Size of data in bytes */ } H5O_storage_contig_t; typedef struct H5O_storage_chunk_btree_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - H5UC_t *shared; /* Ref-counted shared info for B-tree nodes */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + H5UC_t *shared; /* Ref-counted shared info for B-tree nodes */ } H5O_storage_chunk_btree_t; /* Forward declaration of structs used below */ -struct H5FA_t; /* Defined in H5FAprivate.h */ +struct H5FA_t; /* Defined in H5FAprivate.h */ typedef struct H5O_storage_chunk_farray_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5FA_t *fa; /* Pointer to fixed index array struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5FA_t *fa; /* Pointer to fixed index array struct */ } H5O_storage_chunk_farray_t; /* Forward declaration of structs used below */ -struct H5EA_t; /* Defined in H5EAprivate.h */ +struct H5EA_t; /* Defined in H5EAprivate.h */ typedef struct H5O_storage_chunk_earray_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5EA_t *ea; /* Pointer to extensible index array struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5EA_t *ea; /* Pointer to extensible index array struct */ } H5O_storage_chunk_earray_t; /* Filtered info for single chunk index */ typedef struct H5O_storage_chunk_single_filt_t { - uint32_t nbytes; /* Size of chunk (in file) */ - uint32_t filter_mask; /* Excluded filters for chunk */ + uint32_t nbytes; /* Size of chunk (in file) */ + uint32_t filter_mask; /* Excluded filters for chunk */ } H5O_storage_chunk_single_filt_t; /* Forward declaration of structs used below */ -struct H5B2_t; /* Defined in H5B2pkg.h */ +struct H5B2_t; /* Defined in H5B2pkg.h */ typedef struct H5O_storage_chunk_bt2_t { - haddr_t dset_ohdr_addr; /* File address dataset's object header */ - struct H5B2_t *bt2; /* Pointer to b-tree 2 struct */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ + struct H5B2_t *bt2; /* Pointer to b-tree 2 struct */ } H5O_storage_chunk_bt2_t; typedef struct H5O_storage_chunk_t { - H5D_chunk_index_t idx_type; /* Type of chunk index */ - haddr_t idx_addr; /* File address of chunk index */ - const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */ + H5D_chunk_index_t idx_type; /* Type of chunk index */ + haddr_t idx_addr; /* File address of chunk index */ + const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */ union { - H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */ - H5O_storage_chunk_bt2_t btree2; /* Information for v2 B-tree index */ - H5O_storage_chunk_earray_t earray; /* Information for extensible array index */ - H5O_storage_chunk_farray_t farray; /* Information for fixed array index */ + H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */ + H5O_storage_chunk_bt2_t btree2; /* Information for v2 B-tree index */ + H5O_storage_chunk_earray_t earray; /* Information for extensible array index */ + H5O_storage_chunk_farray_t farray; /* Information for fixed array index */ H5O_storage_chunk_single_filt_t single; /* Information for single chunk w/ filters index */ } u; } 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 */ + hbool_t dirty; /* Dirty flag for compact dataset */ + size_t size; /* Size of buffer in bytes */ + void * buf; /* Buffer for compact dataset */ } H5O_storage_compact_t; typedef struct H5O_storage_virtual_srcdset_t { /* Stored */ - struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ + 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 */ - struct H5S_t *clipped_source_select; /* Clipped version of source_select */ + 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 */ - hbool_t dset_exists; /* Whether the dataset exists (was opened successfully) */ + struct H5D_t *dset; /* Source dataset */ + hbool_t dset_exists; /* Whether the dataset exists (was opened successfully) */ /* Temporary - only used during I/O operation, NULL at all other times */ - struct H5S_t *projected_mem_space; /* Selection within mem_space for this mapping */ + struct H5S_t *projected_mem_space; /* Selection within mem_space for this mapping */ } H5O_storage_virtual_srcdset_t; typedef struct H5O_storage_virtual_name_seg_t { - char *name_segment; /* String for this name segment */ - struct H5O_storage_virtual_name_seg_t *next; /* Next 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; typedef enum H5O_virtual_space_status_t { - H5O_VIRTUAL_STATUS_INVALID = 0, /* Space extent is invalid */ - H5O_VIRTUAL_STATUS_SEL_BOUNDS, /* Space extent set to bounds of selection */ - H5O_VIRTUAL_STATUS_USER, /* Space extent provided by application */ - H5O_VIRTUAL_STATUS_CORRECT /* Space extent matches dataset */ + H5O_VIRTUAL_STATUS_INVALID = 0, /* Space extent is invalid */ + H5O_VIRTUAL_STATUS_SEL_BOUNDS, /* Space extent set to bounds of selection */ + H5O_VIRTUAL_STATUS_USER, /* Space extent provided by application */ + H5O_VIRTUAL_STATUS_CORRECT /* Space extent matches dataset */ } 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 */ + 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 */ /* Not stored */ - H5O_storage_virtual_srcdset_t *sub_dset; /* Array of sub-source dataset info structs */ - size_t sub_dset_nalloc; /* Number of slots allocated in sub_dset */ - size_t sub_dset_nused; /* Number of slots "used" in sub_dset - essentially the farthest sub dataset in the extent */ - size_t sub_dset_io_start; /* First element in sub_dset involved in current I/O op. Field has no meaning and may be uninitialized at all other times */ - size_t sub_dset_io_end; /* First element in sub_dset outside of current I/O op. Field has no meaning and may be uninitialized at all other times */ + H5O_storage_virtual_srcdset_t *sub_dset; /* Array of sub-source dataset info structs */ + size_t sub_dset_nalloc; /* Number of slots allocated in sub_dset */ + size_t sub_dset_nused; /* Number of slots "used" in sub_dset - essentially the farthest sub dataset in the + extent */ + size_t sub_dset_io_start; /* First element in sub_dset involved in current I/O op. Field has no meaning + and may be uninitialized at all other times */ + size_t sub_dset_io_end; /* First element in sub_dset outside of current I/O op. Field has no meaning and + may be uninitialized at all other times */ H5O_storage_virtual_name_seg_t *parsed_source_file_name; /* Parsed version of source_dset.file_name */ - size_t psfn_static_strlen; /* Length of parsed_source_file_name without block number substitutions */ - size_t psfn_nsubs; /* Number of block number substitutions in parsed_source_file_name */ + size_t psfn_static_strlen; /* Length of parsed_source_file_name without block number substitutions */ + size_t psfn_nsubs; /* Number of block number substitutions in parsed_source_file_name */ H5O_storage_virtual_name_seg_t *parsed_source_dset_name; /* Parsed version of source_dset.dset_name */ - size_t psdn_static_strlen; /* Length of parsed_source_dset_name without block number substitutions */ - size_t psdn_nsubs; /* Number of block number substitutions in parsed_source_dset_name */ - int unlim_dim_source; /* Unlimited dimension in source_select */ - int unlim_dim_virtual; /* Unlimited dimension in virtual_select */ - hsize_t unlim_extent_source; /* Extent of unlimited dimension in source dset last time virtual_select was patched to match selection */ - hsize_t unlim_extent_virtual; /* Extent of unlimited dimension in virtual dset last time source_select was patched to match selection */ - hsize_t clip_size_virtual; /* Size selection would be clipped to in virtual selection, ignoring other mappings, when source extent == unlim_extent_source */ - hsize_t clip_size_source; /* Size selection would be clipped to in source selection when virtual extent == unlim_extent_virtual */ - H5O_virtual_space_status_t source_space_status; /* Extent patching status of source_select */ + size_t psdn_static_strlen; /* Length of parsed_source_dset_name without block number substitutions */ + size_t psdn_nsubs; /* Number of block number substitutions in parsed_source_dset_name */ + int unlim_dim_source; /* Unlimited dimension in source_select */ + int unlim_dim_virtual; /* Unlimited dimension in virtual_select */ + hsize_t unlim_extent_source; /* Extent of unlimited dimension in source dset last time virtual_select was + patched to match selection */ + hsize_t unlim_extent_virtual; /* Extent of unlimited dimension in virtual dset last time source_select was + patched to match selection */ + hsize_t clip_size_virtual; /* Size selection would be clipped to in virtual selection, ignoring other + mappings, when source extent == unlim_extent_source */ + hsize_t clip_size_source; /* Size selection would be clipped to in source selection when virtual extent == + unlim_extent_virtual */ + H5O_virtual_space_status_t source_space_status; /* Extent patching status of source_select */ H5O_virtual_space_status_t virtual_space_status; /* Extent patching status of virtual_select */ } H5O_storage_virtual_ent_t; typedef struct H5O_storage_virtual_t { /* Stored in message */ - H5HG_t serial_list_hobjid; /* Global heap ID for the list of virtual mapping entries stored on disk */ + H5HG_t serial_list_hobjid; /* Global heap ID for the list of virtual mapping entries stored on disk */ /* Stored in heap */ - size_t list_nused; /* Number of array elements used in list */ - H5O_storage_virtual_ent_t *list; /* Array of virtual dataset mapping entries */ + size_t list_nused; /* Number of array elements used in list */ + H5O_storage_virtual_ent_t *list; /* Array of virtual dataset mapping entries */ /* Not stored */ - size_t list_nalloc; /* Number of slots allocated */ - hsize_t min_dims[H5S_MAX_RANK]; /* Minimum extent of VDS (maximum of all non-unlimited selection bounds) */ - H5D_vds_view_t view; /* Method for calculating the extent of the virtual dataset with unlimited selections */ - hsize_t printf_gap; /* Maximum number of sequential missing source datasets before terminating the search for more */ - hid_t source_fapl; /* FAPL to use to open source files */ - hid_t source_dapl; /* DAPL to use to open source datasets */ - hbool_t init; /* Whether all information has been completely initialized */ + size_t list_nalloc; /* Number of slots allocated */ + hsize_t + min_dims[H5S_MAX_RANK]; /* Minimum extent of VDS (maximum of all non-unlimited selection bounds) */ + H5D_vds_view_t + view; /* Method for calculating the extent of the virtual dataset with unlimited selections */ + hsize_t printf_gap; /* Maximum number of sequential missing source datasets before terminating the search + for more */ + hid_t source_fapl; /* FAPL to use to open source files */ + hid_t source_dapl; /* DAPL to use to open source datasets */ + hbool_t init; /* Whether all information has been completely initialized */ } H5O_storage_virtual_t; typedef struct H5O_storage_t { - H5D_layout_t type; /* Type of layout */ + H5D_layout_t type; /* Type of layout */ union { - H5O_storage_contig_t contig; /* Information for contiguous storage */ - H5O_storage_chunk_t chunk; /* Information for chunked storage */ - H5O_storage_compact_t compact; /* Information for compact storage */ - H5O_storage_virtual_t virt; /* Information for virtual storage */ + H5O_storage_contig_t contig; /* Information for contiguous storage */ + H5O_storage_chunk_t chunk; /* Information for chunked storage */ + H5O_storage_compact_t compact; /* Information for compact storage */ + H5O_storage_virtual_t virt; /* Information for virtual storage */ } u; } H5O_storage_t; typedef struct H5O_layout_chunk_farray_t { /* Creation parameters for fixed array data structure */ struct { - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - - i.e. # of bits needed to store max. # of elements - in a data block page */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in a data block page) - + i.e. # of bits needed to store max. # of elements + in a data block page */ } cparam; } H5O_layout_chunk_farray_t; typedef struct H5O_layout_chunk_earray_t { /* Creation parameters for extensible array data structure */ struct { - uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # of elements */ - uint8_t idx_blk_elmts; /* # of elements to store in index block */ - uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ - uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ - uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ + uint8_t max_nelmts_bits; /* Log2(Max. # of elements in array) - i.e. # of bits needed to store max. # + of elements */ + uint8_t idx_blk_elmts; /* # of elements to store in index block */ + uint8_t data_blk_min_elmts; /* Min. # of elements per data block */ + uint8_t sup_blk_min_data_ptrs; /* Min. # of data block pointers for a super block */ + uint8_t max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits + needed to store max. # of elements in data block page */ } cparam; - unsigned unlim_dim; /* Rank of unlimited dimension for dataset */ - uint32_t swizzled_dim[H5O_LAYOUT_NDIMS]; /* swizzled chunk dimensions */ - hsize_t swizzled_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled "down" size of number of chunks in each dimension */ - hsize_t swizzled_max_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled max "down" size of number of chunks in each dimension */ + unsigned unlim_dim; /* Rank of unlimited dimension for dataset */ + uint32_t swizzled_dim[H5O_LAYOUT_NDIMS]; /* swizzled chunk dimensions */ + hsize_t swizzled_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled "down" size of number of chunks in each + dimension */ + hsize_t swizzled_max_down_chunks[H5O_LAYOUT_NDIMS]; /* swizzled max "down" size of number of chunks in + each dimension */ } H5O_layout_chunk_earray_t; typedef struct H5O_layout_chunk_bt2_t { /* Creation parameters for v2 B-tree data structure */ struct { - uint32_t node_size; /* Size of each node (in bytes) */ - uint8_t split_percent; /* % full to split nodes */ - uint8_t merge_percent; /* % full to merge nodes */ + uint32_t node_size; /* Size of each node (in bytes) */ + uint8_t split_percent; /* % full to split nodes */ + uint8_t merge_percent; /* % full to merge nodes */ } cparam; } H5O_layout_chunk_bt2_t; typedef struct H5O_layout_chunk_t { - H5D_chunk_index_t idx_type; /* Type of chunk index */ - uint8_t flags; /* Chunk layout flags */ - unsigned ndims; /* Num dimensions in chunk */ - uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ - unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ - uint32_t size; /* Size of chunk in bytes */ - hsize_t nchunks; /* Number of chunks in dataset */ - hsize_t max_nchunks; /* Max. number of chunks in dataset */ - hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ - hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ - hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ - hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ + H5D_chunk_index_t idx_type; /* Type of chunk index */ + uint8_t flags; /* Chunk layout flags */ + unsigned ndims; /* Num dimensions in chunk */ + uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ + unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ + uint32_t size; /* Size of chunk in bytes */ + hsize_t nchunks; /* Number of chunks in dataset */ + hsize_t max_nchunks; /* Max. number of chunks in dataset */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ + hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ + hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ union { H5O_layout_chunk_farray_t farray; /* Information for fixed array index */ H5O_layout_chunk_earray_t earray; /* Information for extensible array index */ - H5O_layout_chunk_bt2_t btree2; /* Information for v2 B-tree index */ + H5O_layout_chunk_bt2_t btree2; /* Information for v2 B-tree index */ } u; } H5O_layout_chunk_t; typedef struct H5O_layout_t { - H5D_layout_t type; /* Type of layout */ - unsigned version; /* Version of message */ - const struct H5D_layout_ops_t *ops; /* Pointer to data layout I/O operations */ + H5D_layout_t type; /* Type of layout */ + unsigned version; /* Version of message */ + const struct H5D_layout_ops_t *ops; /* Pointer to data layout I/O operations */ union { - H5O_layout_chunk_t chunk; /* Information for chunked layout */ + H5O_layout_chunk_t chunk; /* Information for chunked layout */ } u; - H5O_storage_t storage; /* Information for storing dataset elements */ + H5O_storage_t storage; /* Information for storing dataset elements */ } H5O_layout_t; #ifdef H5O_ENABLE_BOGUS @@ -648,10 +668,10 @@ typedef struct H5O_layout_t { * "Bogus" Message. * (Data structure in memory) */ -#define H5O_BOGUS_VALUE 0xdeadbeef +#define H5O_BOGUS_VALUE 0xdeadbeef typedef struct H5O_bogus_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ - unsigned u; /* Hold the bogus info */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ + unsigned u; /* Hold the bogus info */ } H5O_bogus_t; #endif /* H5O_ENABLE_BOGUS */ @@ -664,19 +684,19 @@ typedef struct H5O_bogus_t { */ typedef struct H5O_ginfo_t { /* "Old" format group info (not stored) */ - uint32_t lheap_size_hint; /* Local heap size hint */ + uint32_t lheap_size_hint; /* Local heap size hint */ /* "New" format group info (stored) */ /* (storage management info) */ - hbool_t store_link_phase_change;/* Whether to store the link phase change values */ - uint16_t max_compact; /* Maximum # of compact links */ - uint16_t min_dense; /* Minimum # of "dense" links */ + hbool_t store_link_phase_change; /* Whether to store the link phase change values */ + uint16_t max_compact; /* Maximum # of compact links */ + uint16_t min_dense; /* Minimum # of "dense" links */ /* (initial object header size info) */ - hbool_t store_est_entry_info; /* Whether to store the est. entry values */ - uint16_t est_num_entries; /* Estimated # of entries in group */ - uint16_t est_name_len; /* Estimated length of entry name */ + hbool_t store_est_entry_info; /* Whether to store the est. entry values */ + uint16_t est_num_entries; /* Estimated # of entries in group */ + uint16_t est_name_len; /* Estimated length of entry name */ } H5O_ginfo_t; /* @@ -685,25 +705,25 @@ typedef struct H5O_ginfo_t { */ /* The initial version of the format */ -#define H5O_PLINE_VERSION_1 1 +#define H5O_PLINE_VERSION_1 1 /* This version encodes the message fields more efficiently */ /* (Drops the reserved bytes, doesn't align the name and doesn't encode the * filter name at all if it's a filter provided by the library) */ -#define H5O_PLINE_VERSION_2 2 +#define H5O_PLINE_VERSION_2 2 /* The latest version of the format. Look through the 'encode' and 'size' * callbacks for places to change when updating this. */ #define H5O_PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 typedef struct H5O_pline_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - unsigned version; /* Encoding version number */ - size_t nalloc; /*num elements in `filter' array */ - size_t nused; /*num filters defined */ - H5Z_filter_info_t *filter; /*array of filters */ + unsigned version; /* Encoding version number */ + size_t nalloc; /*num elements in `filter' array */ + size_t nused; /*num filters defined */ + H5Z_filter_info_t *filter; /*array of filters */ } H5O_pline_t; /* @@ -712,7 +732,7 @@ typedef struct H5O_pline_t { */ typedef struct H5O_name_t { - char *s; /*ptr to malloc'd memory */ + char *s; /*ptr to malloc'd memory */ } H5O_name_t; /* @@ -722,9 +742,9 @@ typedef struct H5O_name_t { * (Data structure in memory) */ typedef struct H5O_shmesg_table_t { - haddr_t addr; /*file address of SOHM table */ - unsigned version; /*SOHM table version number */ - unsigned nindexes; /*number of indexes in the table */ + haddr_t addr; /*file address of SOHM table */ + unsigned version; /*SOHM table version number */ + unsigned nindexes; /*number of indexes in the table */ } H5O_shmesg_table_t; /* @@ -733,11 +753,11 @@ typedef struct H5O_shmesg_table_t { */ typedef struct H5O_cont_t { - haddr_t addr; /*address of continuation block */ - size_t size; /*size of continuation block */ + haddr_t addr; /*address of continuation block */ + size_t size; /*size of continuation block */ /* the following field(s) do not appear on disk */ - unsigned chunkno; /*chunk this mesg refers to */ + unsigned chunkno; /*chunk this mesg refers to */ } H5O_cont_t; /* @@ -745,8 +765,8 @@ typedef struct H5O_cont_t { * (Data structure in memory) */ typedef struct H5O_stab_t { - haddr_t btree_addr; /*address of B-tree */ - haddr_t heap_addr; /*address of name heap */ + haddr_t btree_addr; /*address of B-tree */ + haddr_t heap_addr; /*address of name heap */ } H5O_stab_t; /* @@ -756,8 +776,8 @@ typedef struct H5O_stab_t { * (Data structure in memory) */ typedef struct H5O_btreek_t { - unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ - unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree internal node 'K' values */ + unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ } H5O_btreek_t; /* @@ -766,11 +786,11 @@ typedef struct H5O_btreek_t { * (Data structure in memory) */ typedef struct H5O_drvinfo_t { -/* Information for H5AC cache functions, _must_ be first field in structure */ - H5AC_info_t cache_info; - char name[9]; /* Driver name */ - size_t len; /* Length of encoded buffer */ - uint8_t *buf; /* Buffer for encoded info */ + /* Information for H5AC cache functions, _must_ be first field in structure */ + H5AC_info_t cache_info; + char name[9]; /* Driver name */ + size_t len; /* Length of encoded buffer */ + uint8_t * buf; /* Buffer for encoded info */ } H5O_drvinfo_t; /* @@ -780,40 +800,41 @@ typedef struct H5O_drvinfo_t { */ typedef struct H5O_ainfo_t { /* Creation order info */ - hbool_t track_corder; /* Are creation order values tracked on attributes? */ - hbool_t index_corder; /* Are creation order values indexed on attributes? */ - H5O_msg_crt_idx_t max_crt_idx; /* Maximum attribute creation index used */ - haddr_t corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of "dense" attributes */ + hbool_t track_corder; /* Are creation order values tracked on attributes? */ + hbool_t index_corder; /* Are creation order values indexed on attributes? */ + H5O_msg_crt_idx_t max_crt_idx; /* Maximum attribute creation index used */ + haddr_t + corder_bt2_addr; /* Address of v2 B-tree for indexing creation order values of "dense" attributes */ /* Storage management info */ - hsize_t nattrs; /* Number of attributes on the object */ - haddr_t fheap_addr; /* Address of fractal heap for storing "dense" attributes */ - haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of "dense" attributes */ + hsize_t nattrs; /* Number of attributes on the object */ + haddr_t fheap_addr; /* Address of fractal heap for storing "dense" attributes */ + haddr_t name_bt2_addr; /* Address of v2 B-tree for indexing names of "dense" attributes */ } H5O_ainfo_t; /* * Reference Count Message. * (Data structure in memory) */ -typedef uint32_t H5O_refcount_t; /* Contains # of links to object, if >1 */ +typedef uint32_t H5O_refcount_t; /* Contains # of links to object, if >1 */ /* * "Unknown" Message. * (Data structure in memory) */ -typedef unsigned H5O_unknown_t; /* Original message type ID */ +typedef unsigned H5O_unknown_t; /* Original message type ID */ /* To indicate an invalid version for a message that does not exist yet for the release */ /* Message version is 1 byte so the value can be 0 to 255 */ -#define H5O_INVALID_VERSION 256 +#define H5O_INVALID_VERSION 256 /* The initial version of the fsinfo message: deprecated */ /* This version is mapped to version 1 from release 1.10.1 onwards */ -#define H5O_FSINFO_VERSION_0 0 +#define H5O_FSINFO_VERSION_0 0 /* The latest version for fsinfo message */ -#define H5O_FSINFO_VERSION_1 1 -#define H5O_FSINFO_VERSION_LATEST H5O_FSINFO_VERSION_1 +#define H5O_FSINFO_VERSION_1 1 +#define H5O_FSINFO_VERSION_LATEST H5O_FSINFO_VERSION_1 /* * File space info Message. * Contains file space management info and @@ -821,17 +842,17 @@ typedef unsigned H5O_unknown_t; /* Original message type ID */ * (Data structure in memory) */ typedef struct H5O_fsinfo_t { - unsigned version; /* Version number */ - H5F_fspace_strategy_t strategy; /* File space strategy */ - hbool_t persist; /* Persisting free-space or not */ - hsize_t threshold; /* Free-space section threshold */ - hsize_t page_size; /* For paged aggregation: file space page size */ - size_t pgend_meta_thres; /* For paged aggregation: page end metadata threshold */ - haddr_t eoa_pre_fsm_fsalloc; /* For paged aggregation: the eoa before free-space headers & sinfo */ - haddr_t fs_addr[H5F_MEM_PAGE_NTYPES - 1]; /* 13 addresses of free-space managers */ - /* For non-paged aggregation: only 6 addresses are used */ - hbool_t mapped; /* Not stored */ - /* Indicate the message is mapped from version 0 to version 1 */ + unsigned version; /* Version number */ + H5F_fspace_strategy_t strategy; /* File space strategy */ + hbool_t persist; /* Persisting free-space or not */ + hsize_t threshold; /* Free-space section threshold */ + hsize_t page_size; /* For paged aggregation: file space page size */ + size_t pgend_meta_thres; /* For paged aggregation: page end metadata threshold */ + haddr_t eoa_pre_fsm_fsalloc; /* For paged aggregation: the eoa before free-space headers & sinfo */ + haddr_t fs_addr[H5F_MEM_PAGE_NTYPES - 1]; /* 13 addresses of free-space managers */ + /* For non-paged aggregation: only 6 addresses are used */ + hbool_t mapped; /* Not stored */ + /* Indicate the message is mapped from version 0 to version 1 */ } H5O_fsinfo_t; /* @@ -840,58 +861,56 @@ typedef struct H5O_fsinfo_t { * (Data structure in memory) */ typedef struct H5O_mdci_t { - haddr_t addr; /* address of MDC image block */ - hsize_t size; /* size of MDC image block */ + haddr_t addr; /* address of MDC image block */ + hsize_t size; /* size of MDC image block */ } H5O_mdci_t; /* Typedef for "application" iteration operations */ -typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, - void *operator_data/*in,out*/); +typedef herr_t (*H5O_operator_t)(const void *mesg /*in*/, unsigned idx, void *operator_data /*in,out*/); /* Typedef for "internal library" iteration operations */ -typedef herr_t (*H5O_lib_operator_t)(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, - unsigned sequence, unsigned *oh_modified/*out*/, void *operator_data/*in,out*/); +typedef herr_t (*H5O_lib_operator_t)(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned *oh_modified /*out*/, void *operator_data /*in,out*/); /* Some syntactic sugar to make the compiler happy with two different kinds of iterator callbacks */ typedef enum H5O_mesg_operator_type_t { - H5O_MESG_OP_APP, /* Application callback */ - H5O_MESG_OP_LIB /* Library internal callback */ + H5O_MESG_OP_APP, /* Application callback */ + H5O_MESG_OP_LIB /* Library internal callback */ } H5O_mesg_operator_type_t; -#define H5O_MODIFY_CONDENSE 0x01 -#define H5O_MODIFY 0x02 +#define H5O_MODIFY_CONDENSE 0x01 +#define H5O_MODIFY 0x02 typedef struct { H5O_mesg_operator_type_t op_type; union { - H5O_operator_t app_op; /* Application callback for each message */ - H5O_lib_operator_t lib_op; /* Library internal callback for each message */ + H5O_operator_t app_op; /* Application callback for each message */ + H5O_lib_operator_t lib_op; /* Library internal callback for each message */ } u; } H5O_mesg_operator_t; /* 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 */ + 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 */ } H5O_obj_create_t; - /* Forward declarations for prototype arguments */ struct H5P_genplist_t; /* Object header routines */ H5_DLL herr_t H5O_init(void); -H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, - hid_t ocpl_id, H5O_loc_t *loc/*out*/); -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_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, + H5O_loc_t *loc /*out*/); +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 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); +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); H5_DLL H5O_t *H5O_pin(const H5O_loc_t *loc); H5_DLL herr_t H5O_unpin(H5O_t *oh); H5_DLL herr_t H5O_dec_rc_by_loc(const H5O_loc_t *loc); @@ -901,83 +920,87 @@ H5_DLL herr_t H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS H5_DLL herr_t H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned mesg_id, unsigned mesg_flags); #endif /* H5O_ENABLE_BOGUS */ -H5_DLL herr_t H5O_delete(H5F_t *f, haddr_t addr); -H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); -H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_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 hid_t H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref); -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 herr_t H5O_delete(H5F_t *f, haddr_t addr); +H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); +H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info2_t *oinfo, unsigned fields); +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 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 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); +H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); H5_DLL uint8_t H5O_get_oh_version(const H5O_t *oh); -H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); +H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh); /* Object header message routines */ H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg); -H5_DLL herr_t H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg); -H5_DLL herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, - unsigned mesg_flags, unsigned update_flags, void *mesg); -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 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); + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O_msg_append_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg); +H5_DLL herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, + unsigned update_flags, void *mesg); +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 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_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 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); -H5_DLL herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, - hbool_t adj_link); -H5_DLL 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); -H5_DLL herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, - const H5O_mesg_operator_t *op, void *op_data); -H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id, - hbool_t disable_shared, const void *mesg); -H5_DLL size_t H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, - const void *mesg, size_t extra_raw); -H5_DLL size_t H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, - const void *mesg, size_t extra_raw); +H5_DLL herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link); +H5_DLL 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); +H5_DLL herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_t *op, + void *op_data); +H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id, hbool_t disable_shared, const void *mesg); +H5_DLL size_t H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, const void *mesg, + size_t extra_raw); +H5_DLL size_t H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, const void *mesg, + size_t extra_raw); H5_DLL htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg); H5_DLL htri_t H5O_msg_can_share(unsigned type_id, const void *mesg); H5_DLL htri_t H5O_msg_can_share_in_ohdr(unsigned type_id); -H5_DLL herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, - void *mesg); +H5_DLL herr_t H5O_msg_set_share(unsigned type_id, const H5O_shared_t *share, void *mesg); 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, 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_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, + 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); /* Object metadata flush/refresh routines */ +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, hbool_t start_swmr); +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, + hbool_t start_swmr); + +/* Cache corking functions */ +H5_DLL herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O_enable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled); /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, - H5O_copy_t *cpy_info, hbool_t inc_depth, - H5O_type_t *obj_type, void **udata); -H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, - H5F_t *file_dst, void *_dst_ref, size_t ref_count, H5R_type_t ref_type, - H5O_copy_t *cpy_info); + H5O_copy_t *cpy_info, hbool_t inc_depth, H5O_type_t *obj_type, + void **udata); +H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, hid_t tid_src, H5T_t *dt_src, void *buf_src, + size_t nbytes_src, H5F_t *file_dst, void *buf_dst, H5O_copy_t *cpy_info); /* Debugging routines */ -H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth); -H5_DLL herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, - int fwidth); +H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *stream, int indent, + int fwidth); +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); @@ -991,10 +1014,14 @@ H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); /* EFL operators */ H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl); +/* File space info routines */ +H5_DLL herr_t H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo); +H5_DLL herr_t H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo); + /* Fill value operators */ H5_DLL herr_t H5O_fill_reset_dyn(H5O_fill_t *fill); H5_DLL herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *type, hbool_t *fill_changed); -H5_DLL herr_t H5O_fill_set_version(H5F_t * f, H5O_fill_t *fill); +H5_DLL herr_t H5O_fill_set_version(H5F_t *f, H5O_fill_t *fill); /* Link operators */ H5_DLL herr_t H5O_link_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); @@ -1005,5 +1032,4 @@ H5_DLL herr_t H5O_pline_set_version(H5F_t *f, H5O_pline_t *pline); /* Shared message operators */ H5_DLL herr_t H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src); -#endif /* _H5Oprivate_H */ - +#endif /* H5Oprivate_H */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 2ef0c0de4e4..3c444215456 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,27 +22,27 @@ * *------------------------------------------------------------------------- */ -#ifndef _H5Opublic_H -#define _H5Opublic_H +#ifndef H5Opublic_H +#define H5Opublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ -#include "H5Ipublic.h" /* IDs */ -#include "H5Lpublic.h" /* Links */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Lpublic.h" /* Links */ /*****************/ /* Public Macros */ /*****************/ /* 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,110 +51,162 @@ * 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_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) +#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) /* 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_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) +#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) /* Maximum shared message values. Number of indexes is 8 to allow room to add * new types of messages. */ -#define H5O_SHMESG_MAX_NINDEXES 8 +#define H5O_SHMESG_MAX_NINDEXES 8 #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 * 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_HDR 0x0008u /* Fill in the hdr field */ -#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ -#define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) +#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. + */ +#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) +//! + +/* Convenience macro to check if the token is the 'undefined' token value */ +#define H5O_IS_TOKEN_UNDEF(token) (!HDmemcmp(&(token), &(H5O_TOKEN_UNDEF), sizeof(H5O_token_t))) /*******************/ /* Public Typedefs */ /*******************/ -/* Types of objects in file */ +//! +/** + * Types of objects in file + */ typedef enum H5O_type_t { - H5O_TYPE_UNKNOWN = -1, /* Unknown object type */ - H5O_TYPE_GROUP, /* Object is a group */ - H5O_TYPE_DATASET, /* Object is a dataset */ - H5O_TYPE_NAMED_DATATYPE, /* Object is a named data type */ - H5O_TYPE_NTYPES /* Number of different object types (must be last!) */ + H5O_TYPE_UNKNOWN = -1, /**< Unknown object type */ + H5O_TYPE_GROUP, /**< Object is a group */ + H5O_TYPE_DATASET, /**< Object is a dataset */ + H5O_TYPE_NAMED_DATATYPE, /**< Object is a named data type */ + H5O_TYPE_MAP, /**< Object is a map */ + H5O_TYPE_NTYPES /**< Number of different object types (must be last!) */ } H5O_type_t; +//! -/* Information struct for object header metadata (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */ +//! +/** + * Information struct for object header metadata (for + * H5Oget_info(), H5Oget_info_by_name(), H5Oget_info_by_idx()) + */ typedef struct H5O_hdr_info_t { - unsigned version; /* Version number of header format in file */ - unsigned nmesgs; /* Number of object header messages */ - unsigned nchunks; /* Number of object header chunks */ - unsigned flags; /* Object header status flags */ + unsigned version; /**< Version number of header format in file */ + unsigned nmesgs; /**< Number of object header messages */ + unsigned nchunks; /**< Number of object header chunks */ + unsigned flags; /**< Object header status flags */ struct { - hsize_t total; /* Total space for storing object header in file */ - hsize_t meta; /* Space within header for object header metadata information */ - hsize_t mesg; /* Space within header for actual message information */ - hsize_t free; /* Free space within object header */ + hsize_t total; /**< Total space for storing object header in file */ + hsize_t meta; /**< Space within header for object header metadata information */ + hsize_t mesg; /**< Space within header for actual message information */ + hsize_t free; /**< Free space within object header */ } space; struct { - uint64_t present; /* Flags to indicate presence of message type in header */ - uint64_t shared; /* Flags to indicate message type is shared in header */ + uint64_t present; /**< Flags to indicate presence of message type in header */ + uint64_t shared; /**< Flags to indicate message type is shared in header */ } mesg; } H5O_hdr_info_t; +//! + +//! +/** + * Data model information struct for objects + * (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 */ +} H5O_info2_t; +//! -/* Information struct for object (for H5Oget_info/H5Oget_info_by_name/H5Oget_info_by_idx) */ -typedef struct H5O_info_t { - unsigned long fileno; /* File number that object is located in */ - haddr_t addr; /* Object address in file */ - 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 */ - H5O_hdr_info_t hdr; /* Object header information */ +//! +/** + * Native file format information struct for objects. + * (For H5Oget_native_info(), H5Oget_native_info_by_name(), H5Oget_native_info_by_idx()) + */ +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 */ + 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; -} H5O_info_t; +} H5O_native_info_t; +//! -/* Typedef for message creation indexes */ +/** + * Typedef for message creation indexes + */ typedef uint32_t H5O_msg_crt_idx_t; -/* Prototype for H5Ovisit/H5Ovisit_by_name() operator */ -typedef herr_t (*H5O_iterate_t)(hid_t obj, const char *name, const H5O_info_t *info, - void *op_data); +//! +/** + * Prototype for H5Ovisit(), H5Ovisit_by_name() operator (version 3) + */ +typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, void *op_data); +//! +//! typedef enum H5O_mcdt_search_ret_t { - H5O_MCDT_SEARCH_ERROR = -1, /* Abort H5Ocopy */ - H5O_MCDT_SEARCH_CONT, /* Continue the global search of all committed datatypes in the destination file */ - H5O_MCDT_SEARCH_STOP /* Stop the search, but continue copying. The committed datatype will be copied but not merged. */ + H5O_MCDT_SEARCH_ERROR = -1, /**< Abort H5Ocopy */ + H5O_MCDT_SEARCH_CONT, /**< Continue the global search of all committed datatypes in the destination file + */ + H5O_MCDT_SEARCH_STOP /**< Stop the search, but continue copying. The committed datatype will be copied + but not merged. */ } H5O_mcdt_search_ret_t; +//! -/* Callback to invoke when completing the search for a matching committed datatype from the committed dtype list */ +//! +/** + * Callback to invoke when completing the search for a matching committed + * datatype from the committed dtype list + */ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); +//! /********************/ /* Public Variables */ /********************/ - /*********************/ /* Public Prototypes */ /*********************/ @@ -162,92 +214,2611 @@ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); extern "C" { #endif +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Opens an object in an HDF5 file by location identifier and path name. + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Path to the object; relative to \p loc_id + * \lapl_id + * + * \return \hid_tv{object} + * + * \details H5Oopen() opens a group, dataset, or committed (named) datatype + * specified by a location, \p loc_id, and a path name, \p name, in an HDF5 file. + * + * This function opens the object in the same manner as H5Gopen(), H5Topen(), and H5Dopen(). + * However, H5Oopen() does not require the type of object to be known beforehand. + * This can be useful with user-defined links, for instance, when only a path may be known. + * + * H5Oopen() cannot be used to open a dataspace, attribute, property list, or file. + * + * Once an object of unknown type has been opened with H5Oopen(), + * the type of that object can be determined by means of an H5Iget_type() call. + * + * \p loc_id may be a file, group, dataset, named datatype, or attribute. + * If an attribute is specified for \p loc_id then the object where the + * attribute is attached will be accessed. + * + * \p name must be the path to that object relative to \p loc_id. + * + * \p lapl_id is the link access property list associated with the link pointing to + * the object. If default link access properties are appropriate, this can be + * passed in as #H5P_DEFAULT. + * + * When it is no longer needed, the opened object should be closed with + * H5Oclose(), H5Gclose(), H5Tclose(), or H5Dclose(). + * + * \version 1.8.1 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); -H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Opens an object in an HDF5 file using its VOL independent token + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] token Object token + * + * \return \hid_ti{object} + * + * \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 + * + */ +H5_DLL hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Opens the nth object in a group + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] group_name Name of group, relative to \p loc_id, in which object is located + * \idx_type + * \order + * \param[in] n Object to open + * \lapl_id + * + * \return \hid_tv{object} + * + * \details H5Open_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. + * \p group_name specifies the group relative to \p loc_id in which the object can be found. + * If \p loc_id fully specifies the group in which the object resides, + * \p group_name can be a dot (.). + * + * The specific object to be opened within the group is specified by the three parameters: + * \p idx_type, \p order and \p n. + * + * \p idx_type specifies the type of index by which objects are ordered. + * Valid index types include the following: + * + * \indexes + * + * \p order specifies the order in which the objects are to be referenced for the purposes + * of this function. Valid orders include the following: + * + * \orders + * + * Note that for #H5_ITER_NATIVE, rather than implying a particular order, + * it instructs the HDF5 library to iterate through the objects in the fastest + * available order, i.e., in a natural order. + * + * \p n specifies the position of the object within the index. Note that this count is + * zero-based; 0 (zero) indicates that the function will return the value of the first object; + * if \p n is 5, the function will return the value of the sixth object; etc. + * + * \p lapl_id specifies the link access property list to be used in accessing the object. + * + * An object opened with this function should be closed when it is no longer needed so that + * resource leaks will not develop. H5Oclose() can be used to close groups, datasets, + * or committed datatypes. + * + * \version 1.8.1 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Determines whether a link resolves to an actual object. + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name The name of the link to check + * \lapl_id + * + * \return Returns a positive value if the object pointed to by + * the \p loc_id and \p name combination exists. + * \return Returns 0 if the object pointed to by + * the \p loc_id and \p name combination does not exist. + * \return Returns a negatvie value when the function fails. + * + * \details H5Oexists_by_name() allows an application to determine whether + * the link \p name in the group or file specified with \p loc_id + * resolves to an HDF5 object to open or if the link dangles. The + * link may be of any type, but hard links will always resolve + * to objects and do not need to be verified. + * + * Note that H5Oexists_by_name() verifies only that the target + * object exists. If \p 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 does not + * exist, H5Oexists_by_name() 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. + * + * \par Example + * Use the following steps to verify the existence of + * the link \c datasetD in the \c group group1/group2/softlink_to_group3/, + * where \c group1 is a member of the group specified by \c loc_id: + * + * \par + * - First use H5Lexists() to verify that a link named \c group1 exists. + * - If \c group1 exists, use H5Oexists_by_name() to verify that the + * link \c group1 resolves to an object. + * - If \c group1 exists, use H5Lexists() again, this time with name + * set to \c group1/group2, to verify that the link \c group2 exists + * in \c group1. + * - If the \c group2 link exists, use H5Oexists_by_name() to verify + * that \c group1/group2 resolves to an object. + * - If \c group2 exists, use H5Lexists() again, this time with name + * set to \c group1/group2/softlink_to_group3, to verify that the + * link \c softlink_to_group3 exists in \c group2. + * - If the \c softlink_to_group3 link exists, use H5Oexists_by_name() + * to verify that \c group1/group2/softlink_to_group3 resolves to + * an object. + * - If \c softlink_to_group3 exists, you can now safely use H5Lexists + * with name set to \c group1/group2/softlink_to_group3/datasetD to + * verify that the target link, \c datasetD, exists. + * - And finally, if the link \c datasetD exists, use H5Oexists_by_name + * to verify that \c group1/group2/softlink_to_group3/datasetD + * resolves to an object. + * + * \par + * If the link to be verified is specified with an absolute path, + * the same approach should be used, but starting with the first + * link in the file’s root group. For instance, if \c datasetD + * were in \c /group1/group2/softlink_to_group3, the first call to + * H5Lexists() would have name set to \c /group1. + * + * \par + * Note that this is an outline and does not include all necessary + * details. Depending on circumstances, for example, an application + * may need to verify the type of an object also. + * + * \warning \Bold{Failure Modes:} + * \warning If \p loc_id and \p name both exist but the combination does not + * resolve to an object, the function will return 0 (zero); + * the function does not fail in this case. + * \warning If either the location or the link specified by the \p loc_id + * and \p name combination does not exist, the function will fail, + * returning a negative value. + * \warning Note that verifying the existence of an object within an HDF5 + * file is a multistep process. An application can be certain the + * object does not exist only if H5Lexists() and H5Oexists_by_name() + * have been used to verify the existence of the links and groups + * in the hierarchy above that object. The example above, in the + * function description, provides a step-by-step description of + * that verification process. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.5 + * + */ H5_DLL htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id); -H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields); -H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL 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_info_t *oinfo, - unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, - hid_t lcpl_id, hid_t lapl_id); -H5_DLL herr_t H5Oincr_refcount(hid_t object_id); -H5_DLL herr_t H5Odecr_refcount(hid_t object_id); -H5_DLL 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); -H5_DLL herr_t H5Oset_comment(hid_t obj_id, const char *comment); -H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, - const char *comment, hid_t lapl_id); -H5_DLL ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize); -H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, - char *comment, size_t bufsize, hid_t lapl_id); -H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data, unsigned fields); -H5_DLL herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, - void *op_data, unsigned fields, hid_t lapl_id); -H5_DLL herr_t H5Oclose(hid_t object_id); -H5_DLL herr_t H5Oflush(hid_t obj_id); -H5_DLL herr_t H5Orefresh(hid_t oid); -H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); -H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); -H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); -/* Future function prototypes to be deprecated in next version */ -H5_DLL herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo); -H5_DLL herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, - hid_t lapl_id); -H5_DLL herr_t H5Oget_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_info_t *oinfo, - hid_t lapl_id); - -H5_DLL herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data); -H5_DLL herr_t H5Ovisit_by_name(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, - void *op_data, hid_t lapl_id); - -/* Compatibility function prototypes to replace non-versioned function for use by macro in next version */ -H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo); -H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, - hid_t lapl_id); -H5_DLL 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_info_t *oinfo, - hid_t lapl_id); - -H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, - H5O_iterate_t op, void *op_data); -H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, - void *op_data, hid_t lapl_id); +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object specified by an identifier + * + * \fgdta_loc_obj_id{loc_id} + * \param[out] oinfo Buffer in which to return object information + * \param[in] fields Flags specifying the fields to include in \p oinfo + * + * \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. + * + * 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: + * + * \obj_info_fields + * + * \par Example + * An example snippet from examples/h5_attribute.c: + * \par + * \snippet h5_attribute.c H5Oget_info3_snip + * + * \note If you are iterating through a lot of different objects to + * retrieve information via the H5Oget_info() family of routines, + * you may see memory building up. This can be due to memory + * allocation for metadata such as object headers and messages + * when the iterated objects are put into the metadata cache. + * \note + * If the memory buildup is not desirable, you can configure a + * smaller cache via H5Fset_mdc_config() or set the file access + * property list via H5Pset_mdc_config(). A smaller sized cache + * will force metadata entries to be evicted from the cache, + * thus freeing the memory associated with the entries. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields); -/* Symbols defined for compatibility with previous versions of the HDF5 API. +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object by + * location and relative name + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of group, 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 + * + * \return \herr_t + * + * \details H5Oget_info_by_name3() specifies an object’s location and name, + * \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: + * + * \obj_info_fields + * + * The link access property list, \c lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \par Example + * An example snippet from test/vol.c: + * \snippet vol.c H5Oget_info_by_name3_snip + * + * \since 1.12.0 * - * Use of these symbols is deprecated. */ -#ifndef H5_NO_DEPRECATED_SYMBOLS +H5_DLL herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, unsigned fields, + hid_t lapl_id); -/* Macros */ +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object + * by an index position + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] group_name Name of group in which object is located + * \idx_type + * \order + * \param[in] n Position within the index + * \param[out] oinfo Buffer in which to return object information + * \param[in] fields Flags specifying the fields to include in \p oinfo + * \lapl_id + * + * \return \herr_t + * + * \details H5Oget_info_by_idx3() retrieves the metadata describing an + * object in the \c struct \p oinfo, as specified by the location, + * \p loc_id, group name, \p group_name, the index by which objects + * in that 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. + * + * 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: + * \obj_info_fields + * + * The link access property list, \c lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \par Example + * An example snippet from test/titerate.c: + * \snippet titerate.c H5Oget_info_by_idx3_snip + * + * \since 1.12.0 + * + */ +H5_DLL 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); -/* Typedefs */ +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieve native file format information about an object + * + * \fgdta_loc_obj_id{loc_id} + * \param[out] oinfo Buffer in which to return native object information + * \param[in] fields Flags to determine which fields in \p oinfo are filled in + * + * \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 + * + * The \p fields parameter indicates which fields to fill in + * H5O_native_info_t. Possible values defined in H5Opublic.h are: + * + * \snippet this H5O_native_info_fields_snip + * + * \par Example + * An example snippet from test/tfile.c: + * \par + * \snippet tfile.c H5Oget_native_info_snip + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields); -/* A struct that's part of the H5G_stat_t structure (deprecated) */ -typedef struct H5O_stat_t { - hsize_t size; /* Total size of object header in file */ - hsize_t free; /* Free space within object header */ - unsigned nmesgs; /* Number of object header messages */ - unsigned nchunks; /* Number of object header chunks */ -} H5O_stat_t; +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieve native file format information about an object given its name + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of object + * \param[out] oinfo Buffer in which to return native object information + * \param[in] fields Flags to determine which fields in \p oinfo are filled in + * \lapl_id + * + * \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 + * + * The \p fields parameter which fields to fill in H5O_native_info_t. + * Possible values defined in H5Opublic.h are: + * + * \snippet this H5O_native_info_fields_snip + * + * \par Example + * An example snippet from test/tfile.c: + * \snippet tfile.c H5Oget_native_info_by_name_snip + * + * \since 1.12.0 + * + */ +H5_DLL 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); -/* Function prototypes */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieve native file format information about an object + * according to the order of an index + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] group_name Name of group in which object is located + * \idx_type + * \order + * \param[in] n Position within the index + * \param[out] oinfo Buffer in which to return native object information + * \param[in] fields Flags to determine which fields in \p oinfo are filled in + * \lapl_id + * + * \return \herr_t + * + * \details H5Oget_native_info_by_idx() retrieves the native file format information for an object + * 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 + * + * The \p fields parameter indicates which fields to fill in H5O_native_info_t. + * Possible values defined in H5Opublic.h are: + * \snippet this H5O_native_info_fields_snip + * + * The link access property list, \c lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \since 1.12.0 + * + */ +H5_DLL 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); -#ifdef __cplusplus -} -#endif -#endif /* _H5Opublic_H */ +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Creates a hard link to an object in an HDF5 file + * + * \param[in] obj_id Object to be linked + * \param[in] new_loc_id Location identifier at which object is to be linked; + * may be a file, group, dataset, named datatype or attribute identifier. + * \param[in] new_name Name of link to be created, relative to \p new_loc_id. + * \lcpl_id + * \lapl_id + * + * \return \herr_t + * + * \details H5Olink() creates a new hard link to an object in an HDF5 file. + * \p new_loc_id and \p \p new_link_name specify the location and name of the + * new link while \p object_id identifies the object that the link + * points to. + * + * H5Olink() is designed for two purposes: + * - To create the first hard link to an object that has just + * been created with H5Dcreate_anon(), H5Gcreate_anon(), or + * H5Tcommit_anon(). + * - To add additional structure to an existing + * file so that, for example, an object can be shared among + * multiple groups. + * + * \p lcpl and \p lapl are the link creation and access property lists + * associated with the new link. + * + * \par Example: + * To create a new link to an object while simultaneously creating + * missing intermediate groups: Suppose that an application must + * create the group C with the path /A/B01/C but may not know + * at run time whether the groups A and B01 exist. The following + * code ensures that those groups are created if they are missing: + * \par + * \code + * + * // Creates a link creation property list (LCPL). + * hid_t lcpl_id = H5Pcreate(H5P_LINK_CREATE); + * + * // Sets "create missing intermediate groups" property in that LCPL. + * int status = H5Pset_create_intermediate_group(lcpl_id, TRUE); + * + * // Creates a group without linking it into the file structure. + * hid_t gid = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); + * + * // Links group into file structure. + * status = H5Olink(gid, file_id, "/A/B01/C", lcpl_id, H5P_DEFAULT); + * + * \endcode + * + * \par + * Note that unless the object is intended to be temporary, + * the H5O_LINK call is mandatory if an object created with one + * of the H5*_CREATE_ANON functions (or with H5T_COMMIT_ANON) + * is to be retained in the file; without an H5O_LINK call, + * the object will not be linked into the HDF5 file structure + * and will be deleted when the file is closed. + * + * \version 1.8.1 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Increments an object reference count + * + * \fgdta_loc_obj_id{object_id} + * + * \return \herr_t + * + * \details H5Oincr_refcount() increments the hard link reference count for an object. + * It should be used any time a user-defined link that references + * an object by address is added. When the link is deleted, + * H5Odecr_refcount() should be used. + * + * 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 + * for a more complete discussion of reference counts. + * + * If a user application needs to determine an object’s reference + * count, an H5Oget_info() call is required; the reference count + * is returned in the \c rc field of the #H5O_info_t \c struct. + * + * \warning This function must be used with care! + * \warning Improper use can lead to inaccessible data, wasted space in the file, + * or file corruption. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oincr_refcount(hid_t object_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Decrements an object reference count + * + * \fgdta_loc_obj_id{object_id} + * + * \return \herr_t + * + * \details H5Odecr_refcount() decrements the hard link reference count for an object. + * It should be used any time a user-defined link that references + * an object by address is deleted. In general, H5Oincr_refcount() will have + * been used previously, when the link was created. + * + * 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 + * for a more complete discussion of reference counts. + * + * If a user application needs to determine an object’s reference + * count, an H5Oget_info() call is required; the reference count + * is returned in the \c rc field of the #H5O_info_t \c struct. + * + * \warning This function must be used with care! + * \warning Improper use can lead to inaccessible data, wasted space in the file, + * or file corruption. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Odecr_refcount(hid_t object_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Copies an object in an HDF5 file + * + * \param[in] src_loc_id Object identifier indicating the location of the + * source object to be copied + * \param[in] src_name Name of the source object to be copied + * \param[in] dst_loc_id Location identifier specifying the destination + * \param[in] dst_name Name to be assigned to the new copy + * \param[in] ocpypl_id Object copy property list + * \lcpl_id + * + * \return \herr_t + * + * \details H5Ocopy() copies the group, dataset or committed datatype + * specified by \p src_name from the file or group specified by + * \p src_loc_id to the destination location \p dst_loc_id. + * + * The destination location, as specified in dst_loc_id, may + * be a group in the current file or a location in a different + * file. If dst_loc_id is a file identifier, the copy will be + * placed in that file’s root group. + * + * The copy will be created with the path specified in \p dst_name, + * which must not pre-exist in the destination location. If + * \p dst_name already exists at the location \p dst_loc_id, + * H5Ocopy() will fail. If \p dst_name is an absolute path, + * the copy will be created relative to the file’s root group. + * + * The copy of the object is created with the property lists + * specified by \p ocpypl_id and \p lcpl_id. #H5P_DEFAULT can be passed + * in for these property lists. The default behavior: + * + * - of the link creation property list is to NOT create + * intermediate groups. + * - of the flags specified by the object creation property list + * is described in H5Pset_copy_object(). + * + * These property lists or flags can be modified to govern the + * behavior of H5Ocopy() as follows: + * + * - A flag controlling the creation of intermediate groups that + * may not yet exist is set in the link creation property list + * \p lcpl_id with H5Pset_create_intermediate_group(). + * + * - Copying of committed datatypes can be tuned through the use + * of H5Pset_copy_object(), H5Padd_merge_committed_dtype_path(), + * H5Pset_mcdt_search_cb(), and related functions. + * + * - Flags controlling other aspects of object copying are set in the + * object copy property list \p ocpypl_id with H5Pset_copy_object(). + * + * H5Ocopy() will always try to make a copy of the object specified + * in \p src_name. + * + * - If the object specified by \p src_name is a group containing a + * soft or external link, the default is that the new copy will + * contain a soft or external link with the same value as the + * original. See H5Pset_copy_object() for optional settings. + * + * - If the path specified in \p src_name is or contains a soft link + * or an external link, H5Ocopy() will copy the target object. + * Use H5Lcopy() if the intent is to create a new soft or external + * link with the same value as the original link. + * + * H5Ocopy() can be used to copy an object in an HDF5 file. If + * an object has been changed since it was opened, it should be + * written back to the file before using H5Ocopy(). The object + * can be written back either by closing the object (H5Gclose(), + * H5Oclose(), H5Dclose(), or H5Tclose()) or by flushing + * the HDF5 file (H5Fflush()). + * + * \par See Also: + * - Functions to modify the behavior of H5Ocopy(): + * - H5Padd_merge_committed_dtype_path() + * - H5Pset_copy_object() + * - H5Pset_create_intermediate_group() + * - H5Pset_mcdt_search_cb() + * - Copying Committed Datatypes with #H5Ocopy - A comprehensive + * discussion of copying committed datatypes (PDF) in + * Advanced Topics in HDF5 + * + * \version 1.8.9 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Sets comment for specified object + * + * \fgdta_loc_obj_id{obj_id} + * \param[in] comment The new comment + * + * \return \herr_t + * + * \details H5Oset_comment() sets the comment for the specified object + * to the contents of \p comment. Any previously existing comment + * is overwritten. + * + * The target object is specified by an identifier, \p obj_id. + * If \p comment is the empty string or a null pointer, any existing + * comment message is removed from the object. + * + * Comments should be relatively short, null-terminated, ASCII strings. + * + * Comments can be attached to any object that has an object + * header. Datasets, groups, and committed (named) datatypes have + * object headers. Symbolic links do not have object headers. + * + * If a comment is being added to an object attribute, this comment + * will be attached to the object to which the attribute belongs + * and not to the attribute itself. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oset_comment(hid_t obj_id, const char *comment); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Sets comment for specified object + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of the object whose comment is to be set or reset + * \param[in] comment The new comment + * \lapl_id + * + * \return \herr_t + * + * \details H5Oset_comment_by_name() sets the comment for the specified object + * to the contents of \p comment. Any previously existing comment + * is overwritten. + * + * The target object is specified by \p loc_id and \p name. + * \p loc_id can specify any object in the file. + * \p name can be one of the following: + * + * - The name of the object specified as a path relative to \p loc_id + * - An absolute name of the object, starting from \c /, the file’s root group + * - A dot (\c .), if \p loc_id fully specifies the object + * + * If \p comment is the empty string or a null pointer, any existing + * comment message is removed from the object. + * + * Comments should be relatively short, null-terminated, ASCII strings. + * + * Comments can be attached to any object that has an object + * header. Datasets, groups, and committed (named) datatypes have + * object headers. Symbolic links do not have object headers. + * + * If a comment is being added to an object attribute, this comment + * will be attached to the object to which the attribute belongs + * and not to the attribute itself. + * + * \p lapl_id contains a link access property list identifier. A + * link access property list can come into play when traversing + * links to access an object. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves comment for specified object + * + * \fgdta_loc_obj_id{obj_id} + * \param[out] comment The comment + * \param[in] bufsize Anticipated required size of the comment buffer + * + * \return Upon success, returns the number of characters in the + * comment, not including the \c NULL terminator, or zero (\c 0) if + * the object has no comment. The value returned may be larger + * than \p bufsize. Otherwise returns a negative value. + * + * \details H5Oget_comment() retrieves the comment for the specified object in + * the buffer \p comment. + * + * The target object is specified by an identifier, \p object_id. + * + * The size in bytes of the buffer \p comment, including the \c NULL + * terminator, is specified in \p bufsize. If \p bufsize is unknown, + * a preliminary H5Oget_comment() call with the pointer \p comment + * set to \c NULL will return the size of the comment without + * the \c NULL terminator. + * + * If \p bufsize is set to a smaller value than described above, + * only \p bufsize bytes of the comment, without a \c NULL terminator, + * are returned in \p comment. + * + * If an object does not have a comment, the empty string is + * returned in \p comment. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves comment for specified object + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of the object whose comment is to be retrieved + * \param[out] comment The comment + * \param[in] bufsize Anticipated required size of the \p comment buffer + * \lapl_id + * + * \return Upon success, returns the number of characters in the comment, + * not including the \c NULL terminator, or zero (\c 0) if the object + * has no comment. The value returned may be larger than \c bufsize. + * Otherwise returns a negative value. + * + * \details H5Oget_comment_by_name() retrieves the comment for an object + * in the buffer \p comment. + * + * The target object is specified by \p loc_id and \p name. + * \p loc_id can specify any object in the file. + * \p name can be one of the following: + * + * - The name of the object relative to \p loc_id + * - An absolute name of the object, starting from \c /, the file’s root group + * - A dot (\c .), if \p loc_id fully specifies the object + * + * The size in bytes of the comment, including the \c NULL terminator, + * is specified in \p bufsize. If \p bufsize is unknown, a preliminary + * H5Oget_comment_by_name() call with the pointer \p comment set + * to \c NULL will return the size of the comment without + * the \c NULL terminator. + * + * If \p bufsize is set to a smaller value than described above, + * only \p bufsize bytes of the comment, without a \c NULL terminator, + * are returned in \p comment. + * + * If an object does not have a comment, the empty string is + * returned in \p comment. + * + * \p lapl_id contains a link access property list identifier. A + * link access property list can come into play when traversing + * links to access an object. + * + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, + hid_t lapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects accessible from a specified object + * + * \fgdta_loc_obj_id{obj_id} + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * \param[in] fields Flags specifying the fields to be retrieved to the + * callback \p op + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \details H5Ovisit3() is a recursive iteration function to visit the + * object \p obj_id and, if \p obj_id is a group, all objects in + * and below it in an HDF5 file, thus providing a mechanism for + * an application to perform a common set of operations across + * all of those objects or a dynamically selected subset. + * For non-recursive iteration across the members of a group, + * see H5Literate2(). + * + * If \p obj_id is a group identifier, that group serves as the + * root of a recursive iteration. If \p obj_id is a file identifier, + * that file’s root group serves as the root of the recursive + * iteration. If \p obj_id is an attribute identifier, + * then the object where the attribute is attached will be iterated. + * If \p obj_id is any other type of object, such as a dataset or + * named datatype, there is no iteration. + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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. + * + * 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 + * is passed back to each step of the iteration in the callback + * function’s \p op_data parameter. + * + * The \p fields parameter contains flags to determine which fields will + * be retrieved by the \p op callback function. These flags are defined + * in the H5Opublic.h file: + * \obj_info_fields + * + * H5Lvisit2() and H5Ovisit3() are companion functions: one for + * examining and operating on links; the other for examining + * and operating on the objects that those links point to. Both + * functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * in the file has been presented to the application for whatever + * processing the application requires. These functions assume + * that the membership of the group being iterated over remains + * unchanged through the iteration; if any of the links in the + * 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 + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects accessible from a specified object + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] obj_name Name of the object, generally relative to + * \p loc_id, that will serve as root of the iteration + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * \param[in] fields Flags specifying the fields to be retrieved to the + * callback function \p op + * \lapl_id + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \details H5Ovisit_by_name3() is a recursive iteration function to visit + * the object specified by the \p loc_id / \p obj_name parameter + * pair and, if that object is a group, all objects in and below it + * in an HDF5 file, thus providing a mechanism for an application to + * perform a common set of operations across all of those objects or + * a dynamically selected subset. For non-recursive iteration across + * the members of a group, see H5Literate2(). + * + * The object serving as the root of the iteration is specified + * by the \p loc_id / \p obj_name parameter pair. \p loc_id specifies + * a file or an object in a file; if \p loc_id is an attribute identifier, + * the object where the attribute is attached will be used. + * \p obj_name specifies either an object in the file (with an absolute + * name based in the file’s root group) or an object name relative + * to \p loc_id. If \p loc_id fully specifies the object that is to serve + * as the root of the iteration, \p obj_name should be '\c .' (a dot). + * (Note that when \p loc_id fully specifies the object that is to serve + * as the root of the iteration, the user may wish to consider + * using H5Ovisit3() instead of H5Ovisit_by_name3().) + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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 + * + * The H5Ovisit_by_name3() \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. + * + * \p lapl_id is a link access property list. In the general case, + * when default link access properties are acceptable, this can + * be passed in as #H5P_DEFAULT. An example of a situation that + * requires a non-default link access property list is when + * the link is an external link; an external link may require + * that a link prefix be set in a link access property list + * (see H5Pset_elink_prefix()). + * + * The \p fields parameter contains flags to determine which fields will + * be retrieved by the \p op callback function. These flags are defined + * in the H5Opublic.h file: + * \obj_info_fields + * + * H5Lvisit_by_name2() and H5Ovisit_by_name3() are companion + * functions: one for examining and operating on links; the other + * for examining and operating on the objects that those links point to. + * Both functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * 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 + * + * \since 1.12.0 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Closes an object in an HDF5 file + * + * \obj_id{object_id} + * + * \return \herr_t + * + * \details H5Oclose() closes the group, dataset, or named datatype specified by + * object_id. + * + * This function is the companion to H5Oopen(), and has the same + * effect as calling H5Gclose(), H5Dclose(), or H5Tclose(). + * + * H5Oclose() is not used to close a dataspace, attribute, property + * list, or file. + * + * \version 1.8.8 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oclose(hid_t object_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Flushes all buffers associated with an HDF5 object to disk + * + * \fgdta_loc_obj_id{obj_id} + * + * \return \herr_t + * + * \details H5Oflush() causes all buffers associated with an object to be immediately + * flushed to disk without removing the data from the cache. + * + * The object associated with \p object_id can be any named object in an + * HDF5 file including a dataset, a group, or a committed datatype. + * + * \note HDF5 does not possess full control over buffering. H5Oflush() + * 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. + * + * \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() + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Oflush(hid_t obj_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Refreshes all buffers associated with an HDF5 object + * + * \fgdta_loc_obj_id{oid} + * + * \return \herr_t + * + * \details H5Orefresh() causes all buffers associated with an object to be cleared + * and immediately re-loaded with updated contents from disk. + * + * This function essentially closes the object, evicts all + * metadata associated with it from the cache, and then re-opens + * the object. The reopened object is automatically re-registered + * with the same identifier. + * + * The object associated with \p oid can be any named object in an + * HDF5 file including a dataset, a group, or a committed datatype. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Orefresh(hid_t oid); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Prevents metadata entries for an HDF5 object from being flushed + * from the metadata cache to storage + * + * \param[in] object_id Identifier of the object that will have flushes disabled; + * may be a group, named datatype, or dataset identifier + * + * \return \herr_t + * + * \details H5Odisable_mdc_flushes(), H5Oenable_mdc_flushes() and associated flush + * functions can be used to control the flushing of entries from + * a file’s metadata cache. + * + * This function prevents an object’s or cache’s dirty metadata + * entries from being flushed from the cache by the usual cache + * eviction/flush policy. Instead, users must manually flush the + * cache or entries for individual objects via the appropriate + * H5Fflush(), H5Dflush(), H5Gflush(), H5Tflush(), and H5Oflush() calls. + * + * Metadata cache entries can be controlled at both the individual + * 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. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Enables flushing of dirty metadata entries from a file’s metadata cache + * + * \param[in] object_id Identifier of the object that will have flushes re-enabled; + * may be a group, named datatype, or dataset identifier + * + * \return \herr_t + * + * \details H5Oenable_mdc_flushes(), H5Odisable_mdc_flushes() + * and associated flush functions can be used to control the flushing + * of entries from a file’s metadata cache. + * + * This function allows an object or cache’s dirty metadata entries to be + * flushed from the cache by the usual cache eviction/flush policy. + * + * Metadata cache entries can be controlled at both the individual 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 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. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves comment for specified object + * + * \param[in] object_id Identifier of an object in the cache; + * may be a group, named datatype, or dataset identifier + * \param[out] are_disabled Flushes enabled/disabled + * + * \return \p are_disabled will be set to \c 1 if an object has had flushes disabled + * and \c 0 if it has not had flushes disabled. + * \return \herr_t + * + * \details H5Oare_mdc_flushes_disabled() determines if an HDF5 object (dataset, group, committed + * datatype) has had flushes of metadata entries disabled. + * + * The H5Oenable_mdc_flushes(), H5Odisable_mdc_flushes() and + * associated flush functions can be used to control the flushing of + * entries from a file’s metadata cache. Metadata cache entries can be controlled + * at both the individual 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. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Compares two VOL connector object tokens + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] token1 First object token + * \param[in] token2 Second object token + * \param[out] cmp_value Comparison value + * + * \return \herr_t + * + * \details H5Otoken_cmp() compares two VOL connector object tokens, \p token1 + * and \p token2 for the file or group identifier specified by \p loc_id. + * Both object tokens must be from the same VOL connector class. + * + * H5O_token_t is defined in H5public.h as follows: + * \snippet H5public.h H5O_token_t_snip + * + * A comparison value, \p cmp_value, is returned, which indicates the + * result of the comparison: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
cmp_valueResult
> 0 \p token1 > \p token2
< 0\p token1 < \p token2
0\p token1 = \p token2
+ * + * \par Example + * An example snippet from test/links.c: + * \snippet links.c H5Otoken_cmp_snip + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Otoken_cmp(hid_t loc_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Serializes a connector's object token into a string + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] token Connector object token + * \param[out] token_str String for connector object token \p token + * + * \return \herr_t + * + * \details H5Otoken_to_str() serializes a connector's object token specified by + * \p token and the location identifier for the object, \p loc_id, + * into a string, \p token_str. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Otoken_to_str(hid_t loc_id, const H5O_token_t *token, char **token_str); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Deserializes a string into a connector object token + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] token_str Object token string + * \param[out] token Connector object token + * + * \return \herr_t + * + * \details H5Otoken_from_str() deserializes a string, \p token_str, into a + * connector object token, \p token, for the object specified by the + * location identifier, \p loc_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Otoken_from_str(hid_t loc_id, const char *token_str, H5O_token_t *token); + +/* The canonical 'undefined' token value */ +#define H5O_TOKEN_UNDEF (H5OPEN H5O_TOKEN_UNDEF_g) +H5_DLLVAR const H5O_token_t H5O_TOKEN_UNDEF_g; + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* 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 */ +#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) + +/* Typedefs */ + +//! +/** + * A struct that's part of the \ref H5G_stat_t structure + * \deprecated + */ +typedef struct H5O_stat_t { + hsize_t size; /**< Total size of object header in file */ + hsize_t free; /**< Free space within object header */ + unsigned nmesgs; /**< Number of object header messages */ + unsigned nchunks; /**< Number of object header chunks */ +} H5O_stat_t; +//! + +//! +/** + * Information struct for object (For H5Oget_info(), H5Oget_info_by_name(), + * H5Oget_info_by_idx() versions 1 & 2.) + */ +typedef struct H5O_info1_t { + unsigned long fileno; /**< File number that object is located in */ + haddr_t addr; /**< Object address in file */ + 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 */ + 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; +} H5O_info1_t; +//! + +//! +/** + * Prototype for H5Ovisit(), H5Ovisit_by_name() operator (versions 1 & 2) + */ +typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t *info, void *op_data); +//! + +/* Function prototypes */ + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Opens an object using its address within an HDF5 file. + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] addr Object's address in the file + * + * \return \hid_tv{object} + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Oopen_by_token(). + * + * \details H5Oopen_by_addr() opens a group, dataset, or committed (named) datatype using its + * address within an HDF5 file, \p addr. The resulting opened object is identical to + * an object opened with H5Oopen() and should be closed with H5Oclose() or an + * object-type-specific closing function (such as H5Gclose()) when no longer needed. + * + * \p loc_id is a location identifier in the file. + * + * The object’s address within the file, \p addr, is the byte offset of the first byte + * of the object header from the beginning of the HDF5 file space, i.e., from the + * beginning of the super block (see the “HDF5 Storage Model” section of the The + * HDF5 Data Model and File Structure chapter of the HDF5 User's Guide.) + * + * \p addr can be obtained via either of two function calls. H5Gget_objinfo() returns + * the object’s address in the \c objno field of the H5G_stat_t \c struct; + * H5Lget_info() returns the address in the \c address field of the #H5L_info_t \c struct. + * + * The address of the HDF5 file on a physical device has no effect on H5Oopen_by_addr(), + * nor does the use of any file driver. As stated above, the object address is its + * offset within the HDF5 file; HDF5’s file drivers will transparently map this to an + * address on a storage device. + * + * \warning This function must be used with care! + * \warning Improper use can lead to inaccessible data, wasted space in the file, + * or file corruption. + * \warning This function is dangerous if called on an invalid address. The risk can be safely + * overcome by retrieving the object address with H5Gget_objinfo() or H5Lget_info() + * immediately before calling H5Oopen_by_addr(). The immediacy of the operation can be + * important; if time has elapsed and the object has been deleted from the file, + * the address will be invalid and file corruption can result. + * + * \version 1.8.4 Fortran subroutine added in this release. + * + * \since 1.8.0 + * + */ +H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object specified by an identifier + * + * \fgdta_loc_obj_id{loc_id} + * \param[out] oinfo Buffer in which to return object information + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * 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. + * + * \note If you are iterating through a lot of different objects to + * retrieve information via the H5Oget_info() family of routines, + * you may see memory building up. This can be due to memory + * allocation for metadata such as object headers and messages + * when the iterated objects are put into the metadata cache. + * \note + * If the memory buildup is not desirable, you can configure a + * smaller cache via H5Fset_mdc_config() or set the file access + * property list via H5Pset_mdc_config(). A smaller sized cache + * will force metadata entries to be evicted from the cache, + * thus freeing the memory associated with the entries. + * + * \version 1.10.5 The macro #H5Oget_info was removed and the function + * H5Oget_info1() was copied to H5Oget_info(). + * \version 1.10.3 Function H5Oget_info() was copied to H5Oget_info1(), + * and the macro #H5Oget_info was created. + * \version 1.8.15 Added a note about the valid values for the \c version + * field in the H5O_hdr_info_t structure. + * \version 1.8.11 Fortran subroutine introduced in this release. + * \version 1.8.10 Added #H5O_type_t structure to the Description section. \n + * Separated H5O_hdr_info_t structure from #H5O_info_t in the + * Description section. \n + * Clarified the definition and implementation of the time fields. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object + * by location and relative name + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of group, relative to \p loc_id + * \param[out] oinfo Buffer in which to return object information + * \lapl_id + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Oget_info_by_name2() or the macro #H5Oget_info_by_name. + * + * \details H5Oget_info_by_name1() specifies an object’s location and name, \p loc_id + * and \p name, respectively, and retrieves the metadata describing that object + * in \p oinfo, an H5O_info1_t \c struct. + * + * The \c struct H5O_info1_t is defined in H5Opublic.h and described + * in the H5Oget_info1() function entry. + * + * The link access property list, \p lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \version 1.10.5 The macro #H5Oget_info_by_name was removed and the function + * H5Oget_info_by_name1() was copied to H5Oget_info_by_name(). + * \version 1.10.3 Function H5Oget_info_by_name() was copied to H5Oget_info_by_name1() + * and the macro #H5Oget_info_by_name was created. + * \version 1.8.8 Fortran 2003 subroutine and \c h5o_info_t derived type introduced + * in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object + * by an index position + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] group_name Name of group in which object is located + * \idx_type + * \order + * \param[in] n Position within the index + * \param[out] oinfo Buffer in which to return object information + * \lapl_id + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Oget_info_by_idx3() or the macro H5Oget_info_by_idx(). + * + * \details H5Oget_info_by_idx1() retrieves the metadata describing an + * object in the \c struct \p oinfo, as specified by the location, + * \p loc_id, group name, \p group_name, the index by which objects + * in that 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. + * + * 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. + * + * \version 1.10.5 The macro #H5Oget_info_by_idx was removed and the function + * H5Oget_info_by_idx() was copied to H5Oget_info_by_idx1(). + * \version 1.10.3 Function H5Oget_info_by_idx() was copied to H5Oget_info_by_idx1() + * and the macro #H5Oget_info_by_idx was created. + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object specified by an identifier + * + * \fgdta_loc_obj_id{loc_id} + * \param[out] oinfo Buffer in which to return object information + * \param[in] fields Flags specifying the fields to include in \p oinfo + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Oget_info3() or the macro H5Oget_info(). + * + * \details H5Oget_info2() specifies an object by its identifier, \p loc_id , and + * retrieves the metadata describing that object in \p oinfo , an H5O_info1_t \c struct. + * This \c struct type is described in H5Oget_info1(). + * + * The \p fields parameter contains flags to determine which fields 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 + * + * \note If you are iterating through a lot of different objects to + * retrieve information via the H5Oget_info() family of routines, + * you may see memory building up. This can be due to memory + * allocation for metadata such as object headers and messages + * when the iterated objects are put into the metadata cache. + * \note + * If the memory buildup is not desirable, you can configure a + * smaller cache via H5Fset_mdc_config() or set the file access + * property list via H5Pset_mdc_config(). A smaller sized cache + * will force metadata entries to be evicted from the cache, + * thus freeing the memory associated with the entries. + * + * \since 1.10.3 + * + */ +H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object + * by location and relative name + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] name Name of group, 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 + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Oget_info_by_name3() or the macro H5Oget_info_by_name(). + * + * \details H5Oget_info_by_name2() specifies an object’s location and name, \p loc_id and + * \p name, respectively, and retrieves the metadata describing + * that object in \p oinfo, an H5O_info1_t \c struct. + * + * The \c struct H5O_info1_t is defined in H5Opublic.h and described + * 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 + * \p oinfo. These flags are defined in the H5Opublic.h file: + * + * \obj_info_fields + * + * The link access property list, \p lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \since 1.10.3 + * + */ +H5_DLL herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, unsigned fields, + hid_t lapl_id); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Retrieves the metadata for an object, identifying the object + * by an index position + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] group_name Name of group in which object is located + * \idx_type + * \order + * \param[in] n Position within the index + * \param[out] oinfo Buffer in which to return object information + * \param[in] fields Flags specifying the fields to include in \p oinfo + * \lapl_id + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function is deprecated in favor of + * the function H5Oget_info_by_idx3() or the macro #H5Oget_info_by_idx. + * + * \details H5Oget_info_by_idx2() retrieves the metadata describing an + * object in the \c struct \p oinfo, as specified by the location, + * \p loc_id, group name, \p group_name, the index by which objects + * in that 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. + * + * \p oinfo, in which the object information is returned, is a \c struct of + * type H5O_info1_t. This and other \c struct types used + * by H5Oget_info_by_idx2() are described in H5Oget_info_by_idx1(). + * + * If \p loc_id fully specifies the group in which the object resides, + * i\p group_name can be a dot (\c .). + * + * The \p fields parameter contains flags to determine which fields 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 + * + * The link access property list, \c lapl_id, is not currently used; + * it should be passed in as #H5P_DEFAULT. + * + * \since 1.10.3 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects accessible from a specified object + * + * \fgdta_loc_obj_id{obj_id} + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Ovisit3() or the macro #H5Ovisit. + * + * \details H5Ovisit1() is a recursive iteration function to visit the + * object \p obj_id and, if \p obj_id is a group, all objects in + * and below it in an HDF5 file, thus providing a mechanism for + * an application to perform a common set of operations across all + * of those objects or a dynamically selected subset. For + * non-recursive iteration across the members of a group, + * see H5Literate1(). + * + * If \p obj_id is a group identifier, that group serves as the + * root of a recursive iteration. If \p obj_id is a file identifier, + * that file’s root group serves as the root of the recursive + * iteration. If \p obj_id is an attribute identifier, + * then the object where the attribute is attached will be iterated. + * If \p obj_id is any other type of object, such as a dataset or + * named datatype, there is no iteration. + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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. + * + * H5Lvisit1() and H5Ovisit1() are companion functions: one for + * examining and operating on links; the other for examining + * and operating on the objects that those links point to. Both + * functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * in the file has been presented to the application for whatever + * processing the application requires. These functions assume + * that the membership of the group being iterated over remains + * unchanged through the iteration; if any of the links in the + * 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(), + * and the macro #H5Ovisit was created. + * \version 1.8.8 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, + void *op_data); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects starting from a specified object + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] obj_name Name of the object, generally relative to + * \p loc_id, that will serve as root of the iteration + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * \lapl_id + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Ovisit_by_name3() or the macro #H5Ovisit_by_name. + * + * \details H5Ovisit_by_name1() is a recursive iteration function to visit + * the object specified by the \p loc_id / \p obj_name parameter + * pair and, if that object is a group, all objects in and below it + * in an HDF5 file, thus providing a mechanism for an application to + * perform a common set of operations across all of those objects or + * a dynamically selected subset. For non-recursive iteration across + * the members of a group, see H5Literate1(). + * + * The object serving as the root of the iteration is specified + * by the \p loc_id / \p obj_name parameter pair. \p loc_id specifies + * a file or an object in a file; if \p loc_id is an attribute identifier, + * the object where the attribute is attached will be used. + * \p obj_name specifies either an object in the file (with an absolute + * name based in the file’s root group) or an object name relative + * to \p loc_id. If \p loc_id fully specifies the object that is to serve + * as the root of the iteration, \p obj_name should be '\c .' (a dot). + * (Note that when \p loc_id fully specifies the object that is to serve + * as the root of the iteration, the user may wish to consider + * using H5Ovisit1() instead of H5Ovisit_by_name1().) + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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 \p op callback function and the effect of the callback + * function’s return value on the application are described + * in H5Ovisit1(). + * + * The H5O_info1_t \c struct is defined in H5Opublic.h + * and described in the H5Oget_info1() function entry. + * + * The H5Ovisit_by_name1() \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. + * + * \p lapl_id is a link access property list. In the general case, + * when default link access properties are acceptable, this can + * be passed in as #H5P_DEFAULT. An example of a situation that + * requires a non-default link access property list is when + * the link is an external link; an external link may require + * that a link prefix be set in a link access property list + * (see H5Pset_elink_prefix()). + * + * H5Lvisit_by_name1() and H5Ovisit_by_name1() are companion + * functions: one for examining and operating on links; the other + * for examining and operating on the objects that those links point to. + * Both functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * 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(), + * and the macro #H5Ovisit_by_name was created. + * \version 1.8.11 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects accessible from a specified object + * + * \fgdta_loc_obj_id{obj_id} + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * \param[in] fields Flags specifying the fields to be retrieved to the + * callback \p op + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Ovisit3() or the macro #H5Ovisit. + * + * \details H5Ovisit2() is a recursive iteration function to visit the + * object \p obj_id and, if \p obj_id is a group, all objects in + * and below it in an HDF5 file, thus providing a mechanism for + * an application to perform a common set of operations across all + * of those objects or a dynamically selected subset. For + * non-recursive iteration across the members of a group, + * see H5Literate1(). + * + * If \p obj_id is a group identifier, that group serves as the + * root of a recursive iteration. If \p obj_id is a file identifier, + * that file’s root group serves as the root of the recursive + * iteration. If \p obj_id is an attribute identifier, + * then the object where the attribute is attached will be iterated. + * If \p obj_id is any other type of object, such as a dataset or + * named datatype, there is no iteration. + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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. + * + * The \p fields parameter contains flags to determine which fields will + * be retrieved by the \p op callback function. These flags are defined + * in the H5Opublic.h file: + * \obj_info_fields + * + * H5Lvisit() and H5Ovisit() are companion functions: one for + * examining and operating on links; the other for examining + * and operating on the objects that those links point to. Both + * functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * in the file has been presented to the application for whatever + * processing the application requires. These functions assume + * that the membership of the group being iterated over remains + * unchanged through the iteration; if any of the links in the + * 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 + * + */ +H5_DLL 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); + +/** + *------------------------------------------------------------------------- + * \ingroup H5O + * + * \brief Recursively visits all objects starting from a specified object + * + * \fgdta_loc_obj_id{loc_id} + * \param[in] obj_name Name of the object, generally relative to + * \p loc_id, that will serve as root of the iteration + * \idx_type + * \order + * \param[in] op Callback function passing data regarding the object + * to the calling application + * \param[in] op_data User-defined pointer to data required by the application + * for its processing of the object + * \param[in] fields Flags specifying the fields to be retrieved to the + * callback function \p op + * \lapl_id + * + * \return On success, returns the return value of the first operator + * that returns a positive value, or zero if all members were + * processed with no operator returning non-zero. + * + * \return On failure, returns a negative value if something goes wrong + * within the library, or the first negative value returned by + * an operator. + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * the function H5Ovisit_by_name3() or the macro #H5Ovisit_by_name. + * + * \details H5Ovisit_by_name2() is a recursive iteration function to visit + * the object specified by the \p loc_id / \p obj_name parameter + * pair and, if that object is a group, all objects in and below it + * in an HDF5 file, thus providing a mechanism for an application to + * perform a common set of operations across all of those objects or + * a dynamically selected subset. For non-recursive iteration across + * the members of a group, see #H5Literate. + * + * The object serving as the root of the iteration is specified + * by the \p loc_id / \p obj_name parameter pair. \p loc_id specifies + * a file or an object in a file; if \p loc_id is an attribute identifier, + * the object where the attribute is attached will be used. + * \p obj_name specifies either an object in the file (with an absolute + * name based in the file’s root group) or an object name relative + * to \p loc_id. If \p loc_id fully specifies the object that is to serve + * as the root of the iteration, \p obj_name should be '\c .' (a dot). + * (Note that when \p loc_id fully specifies the object that is to serve + * as the root of the iteration, the user may wish to consider + * using H5Ovisit2() instead of #H5Ovisit_by_name.) + * + * Two parameters are used to establish the iteration: \p idx_type + * and \p order. + * + * \p idx_type specifies the index to be used. If the links in + * 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 + * + * 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 + * 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 \p op callback function and the effect of the callback + * function’s return value on the application are described + * in H5Ovisit2(). + * + * The H5O_info1_t \c struct is defined in H5Opublic.h + * and described in the H5Oget_info1() function entry. + * + * The H5Ovisit_by_name2() \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. + * + * \p lapl_id is a link access property list. In the general case, + * when default link access properties are acceptable, this can + * be passed in as #H5P_DEFAULT. An example of a situation that + * requires a non-default link access property list is when + * the link is an external link; an external link may require + * that a link prefix be set in a link access property list + * (see H5Pset_elink_prefix()). + * + * The \p fields parameter contains flags to determine which fields will + * be retrieved by the \p op callback function. These flags are defined + * in the H5Opublic.h file: + * \obj_info_fields + * + * #H5Lvisit_by_name and #H5Ovisit_by_name are companion + * functions: one for examining and operating on links; the other + * for examining and operating on the objects that those links point to. + * Both functions ensure that by the time the function completes + * successfully, every link or object below the specified point + * 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 + * + */ +H5_DLL 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); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +#ifdef __cplusplus +} +#endif +#endif /* H5Opublic_H */ diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c index 1377951ffb6..52eee1415a2 100644 --- a/src/H5Orefcount.c +++ b/src/H5Orefcount.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,58 +22,54 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_refcount_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); +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 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, const H5O_copy_t *cpy_info, void *udata); -static herr_t H5O__refcount_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__refcount_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__refcount_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__refcount_decode, /*decode message */ - H5O_refcount_encode, /*encode message */ - H5O_refcount_copy, /*copy the native value */ - H5O_refcount_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__refcount_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - H5O_refcount_pre_copy_file, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__refcount_debug /*debug the message */ + H5O_REFCOUNT_ID, /*message id number */ + "refcount", /*message name for debugging */ + sizeof(H5O_refcount_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__refcount_decode, /*decode message */ + H5O__refcount_encode, /*encode message */ + H5O__refcount_copy, /*copy the native value */ + H5O__refcount_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__refcount_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + H5O__refcount_pre_copy_file, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__refcount_debug /*debug the message */ }}; /* Current version of ref. count information */ -#define H5O_REFCOUNT_VERSION 0 +#define H5O_REFCOUNT_VERSION 0 /* Declare a free list to manage the H5O_refcount_t struct */ H5FL_DEFINE_STATIC(H5O_refcount_t); - /*------------------------------------------------------------------------- * Function: H5O__refcount_decode * @@ -89,11 +85,11 @@ H5FL_DEFINE_STATIC(H5O_refcount_t); */ static void * H5O__refcount_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) + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, + size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_refcount_t *refcount = NULL; /* Reference count */ - void *ret_value = NULL; /* Return value */ + H5O_refcount_t *refcount = NULL; /* Reference count */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -102,12 +98,12 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* Version of message */ - if(*p++ != H5O_REFCOUNT_VERSION) + if (*p++ != H5O_REFCOUNT_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ - if(NULL == (refcount = H5FL_MALLOC(H5O_refcount_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (refcount = H5FL_MALLOC(H5O_refcount_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get ref. count for object */ UINT32DECODE(p, *refcount) @@ -116,15 +112,14 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = refcount; done: - if(ret_value == NULL && refcount != NULL) + if (ret_value == NULL && refcount != NULL) refcount = H5FL_FREE(H5O_refcount_t, refcount); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__refcount_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_refcount_encode + * Function: H5O__refcount_encode * * Purpose: Encodes a message. * @@ -136,11 +131,12 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, + const void *_mesg) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -154,11 +150,10 @@ H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar UINT32ENCODE(p, *refcount); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_refcount_encode() */ +} /* end H5O__refcount_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_refcount_copy + * Function: H5O__refcount_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -172,18 +167,18 @@ H5O_refcount_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shar *------------------------------------------------------------------------- */ static void * -H5O_refcount_copy(const void *_mesg, void *_dest) +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 */ + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; + H5O_refcount_t * dest = (H5O_refcount_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(refcount); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_refcount_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_refcount_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *refcount; @@ -193,11 +188,10 @@ H5O_refcount_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_refcount_copy() */ +} /* end H5O__refcount_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_refcount_size + * Function: H5O__refcount_size * * Purpose: Returns the size of the raw message in bytes not counting * the message type or size fields, but only the data fields. @@ -212,21 +206,20 @@ H5O_refcount_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_refcount_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, - const void H5_ATTR_UNUSED *_mesg) +H5O__refcount_size(const H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared, + const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value; /* Return value */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Set return value */ - ret_value = 1 /* Version */ - + 4; /* Ref. count */ + ret_value = 1 /* Version */ + + 4; /* Ref. count */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_refcount_size() */ +} /* end H5O__refcount_size() */ - /*------------------------------------------------------------------------- * Function: H5O__refcount_free * @@ -251,9 +244,8 @@ H5O__refcount_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__refcount_free() */ - /*------------------------------------------------------------------------- - * Function: H5O_refcount_pre_copy_file + * Function: H5O__refcount_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files. @@ -267,10 +259,11 @@ H5O__refcount_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, - hbool_t *deleted, const H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) +H5O__refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UNUSED *native_src, + hbool_t *deleted, const H5O_copy_t H5_ATTR_UNUSED *cpy_info, + void H5_ATTR_UNUSED *udata) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(deleted); @@ -282,9 +275,8 @@ H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UN *deleted = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_refcount_pre_copy_file() */ +} /* end H5O__refcount_pre_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__refcount_debug * @@ -298,10 +290,9 @@ H5O_refcount_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_refcount_t *refcount = (const H5O_refcount_t *) _mesg; + const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -312,9 +303,7 @@ H5O__refcount_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of links:", (unsigned)*refcount); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of links:", (unsigned)*refcount); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__refcount_debug() */ - diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 33310dcdcce..dab989f4d87 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -6,80 +6,78 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5S_FRIEND /*prevent warning from including H5Spkg.h */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5S_FRIEND /*prevent warning from including H5Spkg.h */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ -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 size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg); +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 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); -static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static herr_t H5O__sdspace_debug(H5F_t *f, const void *_mesg, FILE * stream, - int indent, int fwidth); +static herr_t H5O__sdspace_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, + const H5O_copy_t *cpy_info, void *_udata); +static herr_t H5O__sdspace_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Set up & include shared message "interface" info */ -#define H5O_SHARED_TYPE H5O_MSG_SDSPACE -#define H5O_SHARED_DECODE H5O_sdspace_shared_decode -#define H5O_SHARED_DECODE_REAL H5O__sdspace_decode -#define H5O_SHARED_ENCODE H5O_sdspace_shared_encode -#define H5O_SHARED_ENCODE_REAL H5O_sdspace_encode -#define H5O_SHARED_SIZE H5O_sdspace_shared_size -#define H5O_SHARED_SIZE_REAL H5O_sdspace_size -#define H5O_SHARED_DELETE H5O__sdspace_shared_delete +#define H5O_SHARED_TYPE H5O_MSG_SDSPACE +#define H5O_SHARED_DECODE H5O__sdspace_shared_decode +#define H5O_SHARED_DECODE_REAL H5O__sdspace_decode +#define H5O_SHARED_ENCODE H5O__sdspace_shared_encode +#define H5O_SHARED_ENCODE_REAL H5O__sdspace_encode +#define H5O_SHARED_SIZE H5O__sdspace_shared_size +#define H5O_SHARED_SIZE_REAL H5O__sdspace_size +#define H5O_SHARED_DELETE H5O__sdspace_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O__sdspace_shared_link +#define H5O_SHARED_LINK H5O__sdspace_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O__sdspace_shared_copy_file +#define H5O_SHARED_COPY_FILE H5O__sdspace_shared_copy_file #undef H5O_SHARED_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE H5O_sdspace_shared_post_copy_file +#define H5O_SHARED_POST_COPY_FILE H5O__sdspace_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#undef H5O_SHARED_POST_COPY_FILE_UPD -#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O__sdspace_debug -#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ +#undef H5O_SHARED_POST_COPY_FILE_UPD +#define H5O_SHARED_DEBUG H5O__sdspace_shared_debug +#define H5O_SHARED_DEBUG_REAL H5O__sdspace_debug +#include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* This message derives from H5O message class */ 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_sdspace_shared_decode, /* decode message */ - H5O_sdspace_shared_encode, /* encode message */ - H5O_sdspace_copy, /* copy the native value */ - H5O_sdspace_shared_size, /* size of symbol table entry */ - H5O__sdspace_reset, /* default reset method */ - H5O__sdspace_free, /* free method */ - H5O__sdspace_shared_delete, /* file delete method */ - H5O__sdspace_shared_link, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - H5O_sdspace_pre_copy_file, /* pre copy native value to file */ - H5O__sdspace_shared_copy_file,/* copy native value to file */ - H5O_sdspace_shared_post_copy_file,/* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O_sdspace_shared_debug /* debug the message */ + 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__sdspace_shared_decode, /* decode message */ + H5O__sdspace_shared_encode, /* encode message */ + H5O__sdspace_copy, /* copy the native value */ + H5O__sdspace_shared_size, /* size of symbol table entry */ + H5O__sdspace_reset, /* default reset method */ + H5O__sdspace_free, /* free method */ + H5O__sdspace_shared_delete, /* file delete method */ + H5O__sdspace_shared_link, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + H5O__sdspace_pre_copy_file, /* pre copy native value to file */ + H5O__sdspace_shared_copy_file, /* copy native value to file */ + H5O__sdspace_shared_post_copy_file, /* post copy native value to file*/ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__sdspace_shared_debug /* debug the message */ }}; /* Declare external the free list for H5S_extent_t's */ @@ -88,34 +86,33 @@ H5FL_EXTERN(H5S_extent_t); /* Declare external the free list for hsize_t arrays */ H5FL_ARR_EXTERN(hsize_t); - /*-------------------------------------------------------------------------- NAME H5O__sdspace_decode PURPOSE Decode a simple dimensionality message and return a pointer to a memory - struct with the decoded information + struct with the decoded information USAGE void *H5O__sdspace_decode(f, mesg_flags, p) - H5F_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct unsigned mesg_flags; IN: Message flags to influence decoding - const uint8 *p; IN: the raw information buffer + const uint8 *p; IN: the raw information buffer RETURNS Pointer to the new message in native order on success, NULL on failure DESCRIPTION - This function decodes the "raw" disk form of a simple dimensionality + This function decodes the "raw" disk form of a simple dimensionality message 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__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 H5_ATTR_UNUSED p_size, const uint8_t *p) +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 */ - unsigned flags, version; - unsigned i; /* Local counting variable */ - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -124,29 +121,32 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (sdim = H5FL_CALLOC(H5S_extent_t))) + if (NULL == (sdim = H5FL_CALLOC(H5S_extent_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, NULL, "dataspace structure allocation failed") /* Check version */ version = *p++; - if(version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) + if (version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message") sdim->version = version; /* Get rank */ sdim->rank = *p++; - if(sdim->rank > H5S_MAX_RANK) + if (sdim->rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple dataspace dimensionality is too large") /* Get dataspace flags for later */ flags = *p++; /* Get or determine the type of the extent */ - if(version >= H5O_SDSPACE_VERSION_2) + if (version >= H5O_SDSPACE_VERSION_2) { 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 */ else { /* Set the dataspace type to be simple or scalar as appropriate */ - if(sdim->rank > 0) + if (sdim->rank > 0) sdim->type = H5S_SIMPLE; else sdim->type = H5S_SCALAR; @@ -157,38 +157,50 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, 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) p += 4; /*reserved*/ /* Decode dimension sizes */ - if(sdim->rank > 0) { - if(NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) + 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") + } + + 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") - for(i = 0; i < sdim->rank; i++) + 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))) + 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") - for(i = 0; i < sdim->rank; i++) - H5F_DECODE_LENGTH (f, p, sdim->max[i]); + + /* 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") + + for (i = 0; i < sdim->rank; i++) + H5F_DECODE_LENGTH(f, p, sdim->max[i]); } /* end if */ - } /* end if */ + } /* end if */ /* Compute the number of elements in the extent */ - if(sdim->type == H5S_NULL) + if (sdim->type == H5S_NULL) sdim->nelem = 0; else { - for(i = 0, sdim->nelem = 1; i < sdim->rank; i++) + for (i = 0, sdim->nelem = 1; i < sdim->rank; i++) sdim->nelem *= sdim->size[i]; } /* end else */ /* Set return value */ - ret_value = (void*)sdim; /*success*/ + ret_value = (void *)sdim; /*success*/ done: - if(!ret_value && sdim) { + if (!ret_value && sdim) { H5S__extent_release(sdim); sdim = H5FL_FREE(H5S_extent_t, sdim); } /* end if */ @@ -196,46 +208,32 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__sdspace_decode() */ - /*-------------------------------------------------------------------------- NAME - H5O_sdspace_encode + H5O__sdspace_encode PURPOSE Encode a simple dimensionality message USAGE - herr_t H5O_sdspace_encode(f, raw_size, p, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - size_t raw_size; IN: size of the raw information buffer - const uint8 *p; IN: the raw information buffer - const void *mesg; IN: Pointer to the extent dimensionality struct + herr_t H5O__sdspace_encode(f, raw_size, p, mesg) + H5F_t *f; IN: pointer to the HDF5 file struct + size_t raw_size; IN: size of the raw information buffer + const uint8 *p; IN: the raw information buffer + const void *mesg; IN: Pointer to the extent dimensionality struct RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function encodes the native memory form of the simple + This function encodes the native memory form of the simple dimensionality message in the "raw" disk form. - MODIFICATIONS - Robb Matzke, 1998-04-09 - The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes - instead of just four bytes. - - Robb Matzke, 1998-07-20 - Added a version number and reformatted the message for aligment. - - Raymond Lu - April 8, 2004 - Added the type of dataspace into this header message using a reserved - byte. - --------------------------------------------------------------------------*/ static herr_t -H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) +H5O__sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) { - const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg; - unsigned flags = 0; - unsigned u; /* Local counting variable */ + const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg; + unsigned flags = 0; + unsigned u; /* Local counting variable */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -251,12 +249,12 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = (uint8_t)sdim->rank; /* Flags */ - if(sdim->max) + if (sdim->max) flags |= H5S_VALID_MAX; *p++ = (uint8_t)flags; /* Dataspace type */ - if(sdim->version > H5O_SDSPACE_VERSION_1) + if (sdim->version > H5O_SDSPACE_VERSION_1) *p++ = (uint8_t)sdim->type; else { *p++ = 0; /*reserved*/ @@ -264,102 +262,98 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ *p++ = 0; /*reserved*/ - } /* end else */ - - /* Current & maximum dimensions */ - if(sdim->rank > 0) { - for(u = 0; u < sdim->rank; u++) - H5F_ENCODE_LENGTH(f, p, sdim->size[u]); - if(flags & H5S_VALID_MAX) { - for(u = 0; u < sdim->rank; u++) - H5F_ENCODE_LENGTH(f, p, sdim->max[u]); + } /* end else */ + + /* Encode dataspace dimensions for simple dataspaces */ + if (H5S_SIMPLE == sdim->type) { + /* Encode current & maximum dimensions */ + if (sdim->rank > 0) { + for (u = 0; u < sdim->rank; u++) + H5F_ENCODE_LENGTH(f, p, sdim->size[u]); + if (flags & H5S_VALID_MAX) + for (u = 0; u < sdim->rank; u++) + H5F_ENCODE_LENGTH(f, p, sdim->max[u]); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_sdspace_encode() */ +} /* end H5O__sdspace_encode() */ - /*-------------------------------------------------------------------------- NAME - H5O_sdspace_copy + H5O__sdspace_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE - void *H5O_sdspace_copy(_mesg, _dest) - const void *_mesg; IN: Pointer to the source extent dimensionality struct - const void *_dest; IN: Pointer to the destination extent dimensionality struct + void *H5O__sdspace_copy(_mesg, _dest) + const void *_mesg; IN: Pointer to the source extent dimensionality struct + const void *_dest; IN: Pointer to the destination extent dimensionality struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION - This function copies a native (memory) simple dimensionality message, + This function copies a native (memory) simple dimensionality message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * -H5O_sdspace_copy(const void *_mesg, void *_dest) +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 */ + const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg; + H5S_extent_t * dest = (H5S_extent_t *)_dest; + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(mesg); - if(!dest && NULL == (dest = H5FL_CALLOC(H5S_extent_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (!dest && NULL == (dest = H5FL_CALLOC(H5S_extent_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy extent information */ - if(H5S__extent_copy_real(dest, mesg, TRUE) < 0) + if (H5S__extent_copy_real(dest, mesg, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Set return value */ ret_value = dest; done: - if(NULL == ret_value) - if(dest && NULL == _dest) + if (NULL == ret_value) + if (dest && NULL == _dest) dest = H5FL_FREE(H5S_extent_t, dest); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_sdspace_copy() */ +} /* end H5O__sdspace_copy() */ - /*-------------------------------------------------------------------------- NAME - H5O_sdspace_size + H5O__sdspace_size PURPOSE Return the raw message size in bytes USAGE - void *H5O_sdspace_size(f, mesg) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source extent dimensionality struct + void *H5O__sdspace_size(f, mesg) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source extent dimensionality struct RETURNS Size of message on success, zero on failure DESCRIPTION - This function returns the size of the raw simple dimensionality message on + This function returns the size of the raw simple dimensionality message on success. (Not counting the message type or size fields, only the data portion of the message). It doesn't take into account alignment. - MODIFICATIONS - Robb Matzke, 1998-04-09 - The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes - instead of just four bytes. --------------------------------------------------------------------------*/ static size_t -H5O_sdspace_size(const H5F_t *f, const void *_mesg) +H5O__sdspace_size(const H5F_t *f, const void *_mesg) { - const H5S_extent_t *space = (const H5S_extent_t *)_mesg; - size_t ret_value = 0; /* Return value */ + const H5S_extent_t *space = (const H5S_extent_t *)_mesg; + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Basic information for all dataspace messages */ - ret_value = (size_t)(1 + /* Version */ - 1 + /* Rank */ - 1 + /* Flags */ - 1 + /* Dataspace type/reserved */ - ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4)); /* Eliminated/reserved */ + ret_value = (size_t)(1 + /* Version */ + 1 + /* Rank */ + 1 + /* Flags */ + 1 + /* Dataspace type/reserved */ + ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4)); /* Eliminated/reserved */ /* Add in the dimension sizes */ ret_value += space->rank * H5F_SIZEOF_SIZE(f); @@ -368,9 +362,8 @@ H5O_sdspace_size(const H5F_t *f, const void *_mesg) ret_value += space->max ? (space->rank * H5F_SIZEOF_SIZE(f)) : 0; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_sdspace_size() */ +} /* end H5O__sdspace_size() */ - /*------------------------------------------------------------------------- * Function: H5O__sdspace_reset * @@ -387,7 +380,7 @@ H5O_sdspace_size(const H5F_t *f, const void *_mesg) static herr_t H5O__sdspace_reset(void *_mesg) { - H5S_extent_t *mesg = (H5S_extent_t*)_mesg; + H5S_extent_t *mesg = (H5S_extent_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -396,7 +389,6 @@ H5O__sdspace_reset(void *_mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_reset() */ - /*------------------------------------------------------------------------- * Function: H5O__sdsdpace_free * @@ -421,9 +413,8 @@ H5O__sdspace_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_free() */ - /*------------------------------------------------------------------------- - * Function: H5O_sdspace_pre_copy_file + * Function: H5O__sdspace_pre_copy_file * * Purpose: Perform any necessary actions before copying message between * files @@ -438,14 +429,14 @@ H5O__sdspace_free(void *mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_sdspace_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) +H5O__sdspace_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 H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */ - H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */ + 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_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(file_src); @@ -455,7 +446,7 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, /* Check to ensure that the version of the message to be copied does not exceed the message version allowed by the destination file's high bound */ - if(src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + if (src_space_extent->version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "dataspace message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset @@ -464,13 +455,13 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, * if the layout is an early version, but that information isn't * available here, so we just make a copy of it in all cases) */ - if(udata) { + if (udata) { /* Allocate copy of dataspace extent */ - if(NULL == (udata->src_space_extent = H5FL_CALLOC(H5S_extent_t))) + if (NULL == (udata->src_space_extent = H5FL_CALLOC(H5S_extent_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed") /* Create a copy of the dataspace extent */ - if(H5S__extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0) + if (H5S__extent_copy_real(udata->src_space_extent, src_space_extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") } /* end if */ @@ -478,7 +469,6 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dspace_pre_copy_file() */ - /*-------------------------------------------------------------------------- NAME H5O__sdspace_debug @@ -486,22 +476,21 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, Prints debugging information for a simple dimensionality message USAGE void *H5O__sdspace_debug(f, mesg, stream, indent, fwidth) - H5F_t *f; IN: pointer to the HDF5 file struct - const void *mesg; IN: Pointer to the source extent dimensionality struct - FILE *stream; IN: Pointer to the stream for output data - int indent; IN: Amount to indent information by - int fwidth; IN: Field width (?) + H5F_t *f; IN: pointer to the HDF5 file struct + const void *mesg; IN: Pointer to the source extent dimensionality struct + FILE *stream; IN: Pointer to the stream for output data + int indent; IN: Amount to indent information by + int fwidth; IN: Field width (?) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function prints debugging output to the stream passed as a + This function prints debugging output to the stream passed as a parameter. --------------------------------------------------------------------------*/ static herr_t -H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE * stream, - int indent, int fwidth) +H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE *stream, int indent, int fwidth) { - const H5S_extent_t *sdim = (const H5S_extent_t *)mesg; + const H5S_extent_t *sdim = (const H5S_extent_t *)mesg; FUNC_ENTER_STATIC_NOERR @@ -512,33 +501,30 @@ H5O__sdspace_debug(H5F_t H5_ATTR_UNUSED *f, const void *mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, - "Rank:", - (unsigned long) (sdim->rank)); + HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Rank:", (unsigned long)(sdim->rank)); - if(sdim->rank > 0) { - unsigned u; /* local counting variable */ + if (sdim->rank > 0) { + unsigned u; /* local counting variable */ HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); - for(u = 0; u < sdim->rank; u++) - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]); - HDfprintf (stream, "}\n"); + for (u = 0; u < sdim->rank; u++) + HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", sdim->size[u]); + HDfprintf(stream, "}\n"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:"); - if(sdim->max) { - HDfprintf (stream, "{"); - for(u = 0; u < sdim->rank; u++) { - if(H5S_UNLIMITED==sdim->max[u]) - HDfprintf (stream, "%sUNLIM", u?", ":""); + if (sdim->max) { + HDfprintf(stream, "{"); + for (u = 0; u < sdim->rank; u++) { + if (H5S_UNLIMITED == sdim->max[u]) + HDfprintf(stream, "%sUNLIM", u ? ", " : ""); else - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); + HDfprintf(stream, "%s%" PRIuHSIZE, u ? ", " : "", sdim->max[u]); } /* end for */ - HDfprintf (stream, "}\n"); + HDfprintf(stream, "}\n"); } /* end if */ else - HDfprintf (stream, "CONSTANT\n"); + HDfprintf(stream, "CONSTANT\n"); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_debug() */ - diff --git a/src/H5Oshared.c b/src/H5Oshared.c index dee15f5adc6..51ea145d1f9 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,75 +28,71 @@ /* Module Setup */ /****************/ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HFprivate.h" /* Fractal heap */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HFprivate.h" /* Fractal heap */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ /* First version, with full symbol table entry as link for object header sharing */ -#define H5O_SHARED_VERSION_1 1 +#define H5O_SHARED_VERSION_1 1 /* Older version, with just address of object as link for object header sharing */ -#define H5O_SHARED_VERSION_2 2 +#define H5O_SHARED_VERSION_2 2 /* Newest version, which recognizes messages that are stored in the SOHM heap */ -#define H5O_SHARED_VERSION_3 3 -#define H5O_SHARED_VERSION_LATEST H5O_SHARED_VERSION_3 +#define H5O_SHARED_VERSION_3 3 +#define H5O_SHARED_VERSION_LATEST H5O_SHARED_VERSION_3 /* Size of stack buffer for serialized messages */ -#define H5O_MESG_BUF_SIZE 128 - +#define H5O_MESG_BUF_SIZE 128 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - +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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5O_shared_read + * Function: H5O__shared_read * - * Purpose: Reads a message referred to by a shared message. + * Purpose: Reads a message referred to by a shared message. * - * Return: Success: Ptr to message in native format. The message - * should be freed by calling H5O_msg_reset(). + * Return: Success: Ptr to message in native format. The message + * should be freed by calling H5O_msg_reset(). * - * Failure: NULL + * Failure: NULL * * Programmer: Quincey Koziol * Sep 24 2003 @@ -104,15 +100,15 @@ *------------------------------------------------------------------------- */ 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) +H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, + const H5O_msg_class_t *type) { H5HF_t *fheap = NULL; - H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ + 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_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -126,81 +122,81 @@ H5O_shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, HDassert(H5O_IS_STORED_SHARED(shared->type)); /* Check for implicit shared object header message */ - if(shared->type == H5O_SHARE_TYPE_SOHM) { - haddr_t fheap_addr; /* Address of SOHM heap */ - uint8_t *mesg_ptr; /* Pointer to raw message in heap */ - size_t mesg_size; /* Size of message */ + if (shared->type == H5O_SHARE_TYPE_SOHM) { + haddr_t fheap_addr; /* Address of SOHM heap */ + uint8_t *mesg_ptr; /* Pointer to raw message in heap */ + size_t mesg_size; /* Size of message */ /* Retrieve the fractal heap address for shared messages */ - if(H5SM_get_fheap_addr(f, type->id, &fheap_addr) < 0) + if (H5SM_get_fheap_addr(f, type->id, &fheap_addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get fheap address for shared messages") /* Open the fractal heap */ - if(NULL == (fheap = H5HF_open(f, fheap_addr))) + if (NULL == (fheap = H5HF_open(f, fheap_addr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Get the size of the message in the heap */ - if(H5HF_get_obj_len(fheap, &(shared->u.heap_id), &mesg_size) < 0) + if (H5HF_get_obj_len(fheap, &(shared->u.heap_id), &mesg_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get message size from fractal heap.") /* Wrap the local buffer for serialized message */ - if(NULL == (wb = H5WB_wrap(mesg_buf, sizeof(mesg_buf)))) + if (NULL == (wb = H5WB_wrap(mesg_buf, sizeof(mesg_buf)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for message */ - if(NULL == (mesg_ptr = (uint8_t *)H5WB_actual(wb, mesg_size))) + if (NULL == (mesg_ptr = (uint8_t *)H5WB_actual(wb, mesg_size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't get actual buffer") /* Retrieve the message from the heap */ - if(H5HF_read(fheap, &(shared->u.heap_id), mesg_ptr) < 0) + if (H5HF_read(fheap, &(shared->u.heap_id), mesg_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "can't read message from fractal heap.") /* Decode the message */ - if(NULL == (ret_value = (type->decode)(f, open_oh, 0, ioflags, mesg_size, mesg_ptr))) + if (NULL == (ret_value = (type->decode)(f, open_oh, 0, ioflags, mesg_size, mesg_ptr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.") } /* end if */ else { - H5O_loc_t oloc; /* Location for object header where message is stored */ + H5O_loc_t oloc; /* Location for object header where message is stored */ HDassert(shared->type == H5O_SHARE_TYPE_COMMITTED); /* Build the object location for the shared message's object header */ - oloc.file = f; - oloc.addr = shared->u.loc.oh_addr; + oloc.file = f; + oloc.addr = shared->u.loc.oh_addr; oloc.holding_file = FALSE; - if(open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { + if (open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { /* The shared message is in the already opened object header. This * is possible, for example, if an attribute's datatype is shared in * the same object header the attribute is in. Read the message * directly. */ - if(NULL == (ret_value = H5O_msg_read_oh(f, open_oh, type->id, NULL))) + if (NULL == (ret_value = H5O_msg_read_oh(f, open_oh, type->id, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") - } else + } + 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") + if (NULL == (ret_value = H5O_msg_read(&oloc, type->id, NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") } /* end else */ /* Mark the message as shared */ - if(H5O_msg_set_share(type->id, shared, ret_value) < 0) + if (H5O_msg_set_share(type->id, shared, ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information") done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap") - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shared_read() */ +} /* end H5O__shared_read() */ - /*------------------------------------------------------------------------- - * Function: H5O__shared_link_adj + * Function: H5O__shared_link_adj * - * Purpose: Changes the link count for the object referenced by a shared + * Purpose: Changes the link count for the object referenced by a shared * message. * * This function changes the object header link count and is @@ -209,8 +205,7 @@ H5O_shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, * reference count is stored in the file-wide shared message * index and is changed in a different place in the code. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Sep 26 2003 @@ -218,10 +213,9 @@ H5O_shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, *------------------------------------------------------------------------- */ 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) +H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *shared, int adjust) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -230,8 +224,8 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, HDassert(shared); /* Check for type of shared message */ - if(shared->type == H5O_SHARE_TYPE_COMMITTED) { - H5O_loc_t oloc; /* Location for object header where message is stored */ + if (shared->type == H5O_SHARE_TYPE_COMMITTED) { + H5O_loc_t oloc; /* Location for object header where message is stored */ /* * The shared message is stored in some object header. @@ -252,52 +246,53 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")*/ /* Build the object location for the shared message's object header */ - oloc.file = f; - oloc.addr = shared->u.loc.oh_addr; + oloc.file = f; + oloc.addr = shared->u.loc.oh_addr; oloc.holding_file = FALSE; - if(open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { + if (open_oh && oloc.addr == H5O_OH_GET_ADDR(open_oh)) { /* The shared message is in the already opened object header. This * is possible, for example, if an attribute's datatype is shared in * the same object header the attribute is in. Adjust the link * count directly. */ hbool_t deleted = FALSE; /* This is used only to satisfy H5O__link_oh */ - if(H5O__link_oh(f, adjust, open_oh, &deleted) < 0) + if (H5O__link_oh(f, adjust, open_oh, &deleted) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") HDassert(!deleted); - } else + } + 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") + if (H5O_link(&oloc, adjust) < 0) + 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); /* Check for decrementing reference count on shared message */ - if(adjust < 0) { - if(H5SM_delete(f, open_oh, shared) < 0) + if (adjust < 0) { + if (H5SM_delete(f, open_oh, shared) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to delete message from SOHM table") } /* end if */ /* Check for incrementing reference count on message */ - else if(adjust > 0) { - if(H5SM_try_share(f, open_oh, 0, type->id, shared, NULL) < 0) + else if (adjust > 0) { + if (H5SM_try_share(f, open_oh, 0, type->id, shared, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "error trying to share message") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_link_adj() */ - /*------------------------------------------------------------------------- - * Function: H5O_shared_decode + * Function: H5O__shared_decode * - * Purpose: Decodes a shared object message + * Purpose: Decodes a shared object message * - * Return: Non-negative on success/Negative on failure + * Return: Success: A buffer containing the decoded shared object + * Failure: NULL * * Programmer: Quincey Koziol * Monday, January 22, 2007 @@ -305,14 +300,14 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ void * -H5O_shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, - const H5O_msg_class_t *type) +H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, + const H5O_msg_class_t *type) { - H5O_shared_t sh_mesg; /* Shared message info */ - unsigned version; /* Shared message version */ - void *ret_value = NULL; /* Return value */ + H5O_shared_t sh_mesg; /* Shared message info */ + unsigned version; /* Shared message version */ + void * ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Check args */ HDassert(f); @@ -321,13 +316,13 @@ H5O_shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *bu /* Version */ version = *buf++; - if(version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST) + if (version < H5O_SHARED_VERSION_1 || version > H5O_SHARED_VERSION_LATEST) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message") /* Get the shared information type * Flags are unused before version 3. */ - if(version >= H5O_SHARED_VERSION_2) + if (version >= H5O_SHARED_VERSION_2) sh_mesg.type = *buf++; else { sh_mesg.type = H5O_SHARE_TYPE_COMMITTED; @@ -335,23 +330,23 @@ H5O_shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *bu } /* end else */ /* Skip reserved bytes (for version 1) */ - if(version == H5O_SHARED_VERSION_1) + if (version == H5O_SHARED_VERSION_1) buf += 6; /* Body */ - if(version == H5O_SHARED_VERSION_1) { + if (version == H5O_SHARED_VERSION_1) { /* Initialize other location fields */ sh_mesg.u.loc.index = 0; /* Decode stored "symbol table entry" into message location */ - buf += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ + buf += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ H5F_addr_decode(f, &buf, &(sh_mesg.u.loc.oh_addr)); } /* end if */ else if (version >= H5O_SHARED_VERSION_2) { /* If this message is in the heap, copy a heap ID. * Otherwise, it is a named datatype, so copy an H5O_loc_t. */ - if(sh_mesg.type == H5O_SHARE_TYPE_SOHM) { + if (sh_mesg.type == H5O_SHARE_TYPE_SOHM) { HDassert(version >= H5O_SHARED_VERSION_3); H5MM_memcpy(&sh_mesg.u.heap_id, buf, sizeof(sh_mesg.u.heap_id)); } /* end if */ @@ -359,33 +354,32 @@ H5O_shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *bu /* The H5O_COMMITTED_FLAG should be set if this message * is from an older version before the flag existed. */ - if(version < H5O_SHARED_VERSION_3) + if (version < H5O_SHARED_VERSION_3) sh_mesg.type = H5O_SHARE_TYPE_COMMITTED; sh_mesg.u.loc.index = 0; H5F_addr_decode(f, &buf, &sh_mesg.u.loc.oh_addr); } /* end else */ - } /* end else if */ + } /* end else if */ /* Set file pointer & message type for all types of shared messages */ - sh_mesg.file = f; + sh_mesg.file = f; sh_mesg.msg_type_id = type->id; /* Retrieve actual message, through decoded shared message info */ - if(NULL == (ret_value = H5O_shared_read(f, open_oh, ioflags, &sh_mesg, type))) + if (NULL == (ret_value = H5O__shared_read(f, open_oh, ioflags, &sh_mesg, type))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to retrieve native message") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shared_decode() */ +} /* end H5O__shared_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_shared_encode + * Function: H5O__shared_encode * - * Purpose: Encodes message _MESG into buffer BUF. + * Purpose: Encodes message _MESG into buffer BUF. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Thursday, April 2, 1998 @@ -393,11 +387,11 @@ H5O_shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *bu *------------------------------------------------------------------------- */ herr_t -H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_mesg) +H5O__shared_encode(const H5F_t *f, uint8_t *buf /*out*/, const H5O_shared_t *sh_mesg) { - unsigned version; + unsigned version; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(f); @@ -407,12 +401,12 @@ H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_me /* If this message is shared in the heap, we need to use version 3 of the * encoding and encode the SHARED_IN_HEAP flag. */ - if(sh_mesg->type == H5O_SHARE_TYPE_SOHM) + if (sh_mesg->type == H5O_SHARE_TYPE_SOHM) version = H5O_SHARED_VERSION_LATEST; else { HDassert(sh_mesg->type == H5O_SHARE_TYPE_COMMITTED); version = H5O_SHARED_VERSION_2; /* version 1 is no longer used */ - } /* end else */ + } /* end else */ *buf++ = (uint8_t)version; *buf++ = (uint8_t)sh_mesg->type; @@ -420,21 +414,20 @@ H5O_shared_encode(const H5F_t *f, uint8_t *buf/*out*/, const H5O_shared_t *sh_me /* Encode either the heap ID of the message or the address of the * object header that holds it. */ - if(sh_mesg->type == H5O_SHARE_TYPE_SOHM) + if (sh_mesg->type == H5O_SHARE_TYPE_SOHM) H5MM_memcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id)); else H5F_addr_encode(f, &buf, sh_mesg->u.loc.oh_addr); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_shared_encode() */ +} /* end H5O__shared_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_set_shared + * Function: H5O_set_shared * - * Purpose: Sets the shared component for a message. + * Purpose: Sets the shared component for a message. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Sep 26 2003 @@ -456,14 +449,13 @@ H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_set_shared() */ - /*------------------------------------------------------------------------- - * Function: H5O_shared_size + * Function: H5O__shared_size * - * Purpose: Returns the length of a shared object message. + * Purpose: Returns the length of a shared object message. * - * Return: Success: Length - * Failure: 0 + * Return: Success: Length + * Failure: 0 * * Programmer: Robb Matzke * Thursday, April 2, 1998 @@ -471,34 +463,33 @@ H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src) *------------------------------------------------------------------------- */ size_t -H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) +H5O__shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR - if(sh_mesg->type == H5O_SHARE_TYPE_COMMITTED) { - ret_value = (size_t)1 + /*version */ - (size_t)1 + /*the type field */ - (size_t)H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */ - } /* end if */ + if (sh_mesg->type == H5O_SHARE_TYPE_COMMITTED) { + ret_value = (size_t)1 + /* Version */ + (size_t)1 + /* Type field */ + (size_t)H5F_SIZEOF_ADDR(f); /* Sharing by another obj hdr */ + } /* end if */ else { HDassert(sh_mesg->type == H5O_SHARE_TYPE_SOHM); - ret_value = 1 + /*version */ - 1 + /*the type field */ - H5O_FHEAP_ID_LEN; /* Shared in the heap */ - } /* end else */ + ret_value = 1 + /* Version */ + 1 + /* Type field */ + H5O_FHEAP_ID_LEN; /* Shared in the heap */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shared_size() */ +} /* end H5O__shared_size() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_delete * * Purpose: Free file space referenced by message * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, September 26, 2003 @@ -506,10 +497,9 @@ H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) *------------------------------------------------------------------------- */ herr_t -H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, - H5O_shared_t *sh_mesg) +H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *sh_mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -519,7 +509,7 @@ H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, /* * Committed datatypes increment the OH of the original message when they - * are written (in H5O__shared_link) and decrement it here. + * are written (in H5O_shared_link) and decrement it here. * SOHMs in the heap behave differently; their refcount is incremented * during H5SM_share when they are going to be written (in H5O_msg_append * or H5O_msg_write). Their refcount in the SOHM indexes still needs to @@ -527,21 +517,20 @@ H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, */ /* Decrement the reference count on the shared object */ - if(H5O__shared_link_adj(f, open_oh, type, sh_mesg, -1) < 0) + if (H5O__shared_link_adj(f, open_oh, type, sh_mesg, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_link * * Purpose: Increment reference count on any objects referenced by * message * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, September 26, 2003 @@ -549,26 +538,24 @@ H5O__shared_delete(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ herr_t -H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, - H5O_shared_t *sh_mesg) +H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *sh_mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - /* check args */ + /* Check args */ HDassert(f); HDassert(sh_mesg); /* Increment the reference count on the shared object */ - if(H5O__shared_link_adj(f, open_oh, type, sh_mesg, 1) < 0) + if (H5O__shared_link_adj(f, open_oh, type, sh_mesg, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_link() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_copy_file * @@ -582,14 +569,16 @@ H5O__shared_link(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, *------------------------------------------------------------------------- */ herr_t -H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, - const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, - hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, - void H5_ATTR_UNUSED *udata) +H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, + const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, + hbool_t H5_ATTR_UNUSED *recompute_size, unsigned *mesg_flags, + H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { - const H5O_shared_t *shared_src = (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */ - H5O_shared_t *shared_dst = (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *shared_src = + (const H5O_shared_t *)_native_src; /* Alias to shared info in native source */ + H5O_shared_t *shared_dst = + (H5O_shared_t *)_native_dst; /* Alias to shared info in native destination message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -611,12 +600,12 @@ H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, * be updated (to allow calculation of the final size) but the message is * not actually shared. */ - if(shared_src->type != H5O_SHARE_TYPE_COMMITTED) { + if (shared_src->type != H5O_SHARE_TYPE_COMMITTED) { /* Simulate trying to share new message in the destination file. */ /* Set copied metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); - if(H5SM_try_share(file_dst, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) + if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") /* Reset metadata tag */ @@ -633,7 +622,6 @@ H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, FUNC_LEAVE_NOAPI(ret_value) } /* H5O__shared_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__shared_post_copy_file * @@ -652,11 +640,10 @@ H5O__shared_copy_file(H5F_t *file_src, H5F_t *file_dst, *------------------------------------------------------------------------- */ herr_t -H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, - const H5O_shared_t *shared_src, H5O_shared_t *shared_dst, - unsigned *mesg_flags, H5O_copy_t *cpy_info) +H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src, + H5O_shared_t *shared_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -666,7 +653,7 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, HDassert(shared_dst); /* Copy the target of committed messages, try to share others */ - if(shared_src->type == H5O_SHARE_TYPE_COMMITTED) { + if (shared_src->type == H5O_SHARE_TYPE_COMMITTED) { H5O_loc_t dst_oloc; H5O_loc_t src_oloc; @@ -675,7 +662,7 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, dst_oloc.file = f; src_oloc.file = shared_src->file; src_oloc.addr = shared_src->u.loc.oh_addr; - if(H5O_copy_header_map(&src_oloc, &dst_oloc, cpy_info, FALSE, NULL, NULL) < 0) + if (H5O_copy_header_map(&src_oloc, &dst_oloc, cpy_info, FALSE, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") /* Set up destination message's shared info */ @@ -683,16 +670,15 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, } /* end if */ 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") + 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") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_post_copy_file() */ - /*------------------------------------------------------------------------- - * Function: H5O_shared_debug + * Function: H5O__shared_debug * * Purpose: Prints debugging info for the message * @@ -704,9 +690,9 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, *------------------------------------------------------------------------- */ herr_t -H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth) +H5O__shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(mesg); @@ -714,43 +700,31 @@ H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth) HDassert(indent >= 0); HDassert(fwidth >= 0); - switch(mesg->type) { + switch (mesg->type) { case H5O_SHARE_TYPE_UNSHARED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Unshared"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Unshared"); break; case H5O_SHARE_TYPE_COMMITTED: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Obj Hdr"); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Object address:", - mesg->u.loc.oh_addr); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Obj Hdr"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, + "Object address:", mesg->u.loc.oh_addr); break; case H5O_SHARE_TYPE_SOHM: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "SOHM"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "SOHM"); HDfprintf(stream, "%*s%-*s %016llx\n", indent, "", fwidth, - "Heap ID:", - (unsigned long long)mesg->u.heap_id.val); + "Heap ID:", (unsigned long long)mesg->u.heap_id.val); break; case H5O_SHARE_TYPE_HERE: - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Shared Message type:", - "Here"); + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Shared Message type:", "Here"); break; default: - HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Shared Message type:", - "Unknown", (unsigned)mesg->type); + HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Shared Message type:", "Unknown", + (unsigned)mesg->type); } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_shared_debug() */ - +} /* end H5O__shared_debug() */ diff --git a/src/H5Oshared.h b/src/H5Oshared.h index f29acc58b6a..f164db3ff44 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,7 +27,6 @@ #ifndef H5Oshared_H #define H5Oshared_H - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DECODE * @@ -45,11 +44,11 @@ * *------------------------------------------------------------------------- */ -static H5_INLINE void * -H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, - unsigned *ioflags, size_t p_size, const uint8_t *p) +static inline void * +H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, + const uint8_t *p) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -64,22 +63,22 @@ H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, #endif /* H5O_SHARED_DECODE_REAL */ /* Check for shared message */ - if(mesg_flags & H5O_MSG_FLAG_SHARED) { + if (mesg_flags & H5O_MSG_FLAG_SHARED) { /* Retrieve native message info indirectly through shared message */ - if(NULL == (ret_value = H5O_shared_decode(f, open_oh, ioflags, p, H5O_SHARED_TYPE))) + if (NULL == (ret_value = H5O__shared_decode(f, open_oh, ioflags, p, H5O_SHARED_TYPE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message") - /* We currently do not support automatically fixing shared messages */ + /* We currently do not support automatically fixing shared messages */ #ifdef H5_STRICT_FORMAT_CHECKS - if(*ioflags & H5O_DECODEIO_DIRTY) + if (*ioflags & H5O_DECODEIO_DIRTY) HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to mark shared message dirty") -#else /* H5_STRICT_FORMAT_CHECKS */ +#else /* H5_STRICT_FORMAT_CHECKS */ *ioflags &= ~H5O_DECODEIO_DIRTY; #endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ + } /* end if */ else { /* Decode native message directly */ - if(NULL == (ret_value = H5O_SHARED_DECODE_REAL(f, open_oh, mesg_flags, ioflags, p_size, p))) + if (NULL == (ret_value = H5O_SHARED_DECODE_REAL(f, open_oh, mesg_flags, ioflags, p_size, p))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode native message") } /* end else */ @@ -87,7 +86,6 @@ H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_DECODE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_ENCODE * @@ -105,11 +103,12 @@ H5O_SHARED_DECODE(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, * *------------------------------------------------------------------------- */ -static H5_INLINE herr_t +static inline herr_t H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -127,14 +126,14 @@ H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mes HDassert(sh_mesg->type == H5O_SHARE_TYPE_UNSHARED || sh_mesg->msg_type_id == H5O_SHARED_TYPE->id); /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { + if (H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { /* Encode shared message into buffer */ - if(H5O_shared_encode(f, p, sh_mesg) < 0) + if (H5O__shared_encode(f, p, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode shared message") } /* end if */ else { /* Encode native message directly */ - if(H5O_SHARED_ENCODE_REAL(f, p, _mesg) < 0) + if (H5O_SHARED_ENCODE_REAL(f, p, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode native message") } /* end else */ @@ -142,7 +141,6 @@ H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mes FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_ENCODE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_SIZE * @@ -160,11 +158,12 @@ H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mes * *------------------------------------------------------------------------- */ -static H5_INLINE size_t +static inline size_t H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - size_t ret_value = 0; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -179,14 +178,14 @@ H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) #endif /* H5O_SHARED_SIZE_REAL */ /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { + if (H5O_IS_STORED_SHARED(sh_mesg->type) && !disable_shared) { /* Retrieve encoded size of shared message */ - if(0 == (ret_value = H5O_shared_size(f, sh_mesg))) + if (0 == (ret_value = H5O__shared_size(f, sh_mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of shared message") } /* end if */ else { /* Retrieve size of native message directly */ - if(0 == (ret_value = H5O_SHARED_SIZE_REAL(f, _mesg))) + if (0 == (ret_value = H5O_SHARED_SIZE_REAL(f, _mesg))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, 0, "unable to retrieve encoded size of native message") } /* end else */ @@ -194,7 +193,6 @@ H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_SIZE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DELETE * @@ -213,11 +211,11 @@ H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) * *------------------------------------------------------------------------- */ -static H5_INLINE herr_t +static inline herr_t H5O_SHARED_DELETE(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -229,24 +227,23 @@ H5O_SHARED_DELETE(H5F_t *f, H5O_t *open_oh, void *_mesg) #endif /* H5O_SHARED_DELETE */ /* Check for message tracked elsewhere */ - if(H5O_IS_TRACKED_SHARED(sh_mesg->type)) { + if (H5O_IS_TRACKED_SHARED(sh_mesg->type)) { /* Decrement the reference count on the shared message/object */ - if(H5O__shared_delete(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) + if (H5O__shared_delete(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for shared message") } /* end if */ #ifdef H5O_SHARED_DELETE_REAL else { /* Decrement the reference count on the native message directly */ - if(H5O_SHARED_DELETE_REAL(f, open_oh, _mesg) < 0) + if (H5O_SHARED_DELETE_REAL(f, open_oh, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for native message") - } /* end else */ + } /* end else */ #endif /* H5O_SHARED_DELETE_REAL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_DELETE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_LINK * @@ -265,11 +262,11 @@ H5O_SHARED_DELETE(H5F_t *f, H5O_t *open_oh, void *_mesg) * *------------------------------------------------------------------------- */ -static H5_INLINE herr_t +static inline herr_t H5O_SHARED_LINK(H5F_t *f, H5O_t *open_oh, void *_mesg) { - H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -281,24 +278,23 @@ H5O_SHARED_LINK(H5F_t *f, H5O_t *open_oh, void *_mesg) #endif /* H5O_SHARED_LINK */ /* Check for message tracked elsewhere */ - if(H5O_IS_TRACKED_SHARED(sh_mesg->type)) { + if (H5O_IS_TRACKED_SHARED(sh_mesg->type)) { /* Increment the reference count on the shared message/object */ - if(H5O__shared_link(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) + if (H5O__shared_link(f, open_oh, H5O_SHARED_TYPE, sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for shared message") } /* end if */ #ifdef H5O_SHARED_LINK_REAL else { /* Increment the reference count on the native message directly */ - if(H5O_SHARED_LINK_REAL(f, open_oh, _mesg) < 0) + if (H5O_SHARED_LINK_REAL(f, open_oh, _mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "unable to increment ref count for native message") - } /* end else */ + } /* end else */ #endif /* H5O_SHARED_LINK_REAL */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_LINK() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_COPY_FILE * @@ -316,13 +312,12 @@ H5O_SHARED_LINK(H5F_t *f, H5O_t *open_oh, void *_mesg) * *------------------------------------------------------------------------- */ -static H5_INLINE void * -H5O_SHARED_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 inline void * +H5O_SHARED_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) { - void *dst_mesg = NULL; /* Destination message */ - void *ret_value = NULL; /* Return value */ + void *dst_mesg = NULL; /* Destination message */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -335,11 +330,12 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, #ifdef H5O_SHARED_COPY_FILE_REAL /* Call native message's copy file callback to copy the message */ - if(NULL == (dst_mesg = H5O_SHARED_COPY_FILE_REAL(file_src, H5O_SHARED_TYPE, _native_src, file_dst, recompute_size, cpy_info, udata))) + if (NULL == (dst_mesg = H5O_SHARED_COPY_FILE_REAL(file_src, H5O_SHARED_TYPE, _native_src, file_dst, + recompute_size, cpy_info, udata))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message to another file") -#else /* H5O_SHARED_COPY_FILE_REAL */ +#else /* H5O_SHARED_COPY_FILE_REAL */ /* No copy file callback defined, just copy the message itself */ - if(NULL == (dst_mesg = (H5O_SHARED_TYPE->copy)(_native_src, NULL))) + if (NULL == (dst_mesg = (H5O_SHARED_TYPE->copy)(_native_src, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy native message") #endif /* H5O_SHARED_COPY_FILE_REAL */ @@ -347,22 +343,21 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, HDmemset(dst_mesg, 0, sizeof(H5O_shared_t)); /* Handle sharing destination message */ - if(H5O__shared_copy_file(file_src, file_dst, H5O_SHARED_TYPE, _native_src, - dst_mesg, recompute_size, mesg_flags, cpy_info, udata) < 0) + if (H5O__shared_copy_file(file_src, file_dst, H5O_SHARED_TYPE, _native_src, dst_mesg, recompute_size, + mesg_flags, cpy_info, udata) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "unable to determine if message should be shared") /* Set return value */ ret_value = dst_mesg; done: - if(!ret_value) - if(dst_mesg) + if (!ret_value) + if (dst_mesg) H5O_msg_free(H5O_SHARED_TYPE->id, dst_mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_COPY_FILE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_POST_COPY_FILE * @@ -380,14 +375,14 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, * *------------------------------------------------------------------------- */ -static H5_INLINE herr_t +static inline herr_t H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const void *mesg_src, - H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, - H5O_copy_t *cpy_info) + H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info) { - const H5O_shared_t *shared_src = (const H5O_shared_t *)mesg_src; /* Alias to shared info in native source */ - H5O_shared_t *shared_dst = (H5O_shared_t *)mesg_dst; /* Alias to shared info in native destination */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *shared_src = + (const H5O_shared_t *)mesg_src; /* Alias to shared info in native source */ + H5O_shared_t *shared_dst = (H5O_shared_t *)mesg_dst; /* Alias to shared info in native destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -406,34 +401,33 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const #ifdef H5O_SHARED_POST_COPY_FILE_REAL /* Call native message's post copy file callback to copy the message */ - if(H5O_SHARED_POST_COPY_FILE_REAL(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) <0 ) + if (H5O_SHARED_POST_COPY_FILE_REAL(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy native message to another file") #endif /* H5O_SHARED_POST_COPY_FILE_REAL */ /* Update shared message after the post copy - will short circuit in * production if the DEFER pass determined it will not be shared; debug mode * verifies that it is indeed the case */ - if(H5O__shared_post_copy_file(oloc_dst->file, H5O_SHARED_TYPE, - shared_src, shared_dst, mesg_flags, cpy_info) < 0) + if (H5O__shared_post_copy_file(oloc_dst->file, H5O_SHARED_TYPE, shared_src, shared_dst, mesg_flags, + cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to fix shared message in post copy") #ifdef H5O_SHARED_POST_COPY_FILE_UPD /* Call native message's post copy file update callback to update the * message */ - if(H5O_SHARED_POST_COPY_FILE_UPD(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) + if (H5O_SHARED_POST_COPY_FILE_UPD(oloc_src, mesg_src, oloc_dst, mesg_dst, cpy_info) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to update native message") #endif /* H5O_SHARED_POST_COPY_FILE_UPD */ /* Make sure that if the the source or destination is committed, both are * committed */ - HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) - == (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); + HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) == + (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_SHARED_POST_COPY_FILE() */ - /*------------------------------------------------------------------------- * Function: H5O_SHARED_DEBUG * @@ -451,12 +445,12 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const * *------------------------------------------------------------------------- */ -static H5_INLINE herr_t -H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, - int fwidth) +static inline herr_t +H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *sh_mesg = + (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -471,14 +465,14 @@ H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, #endif /* H5O_SHARED_DEBUG_REAL */ /* Check for message stored elsewhere */ - if(H5O_IS_STORED_SHARED(sh_mesg->type)) { + if (H5O_IS_STORED_SHARED(sh_mesg->type)) { /* Print shared message information */ - if(H5O_shared_debug(sh_mesg, stream, indent, fwidth) < 0) + if (H5O__shared_debug(sh_mesg, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display shared message info") } /* end if */ /* Call native message's debug callback */ - if(H5O_SHARED_DEBUG_REAL(f, _mesg, stream, indent, fwidth) < 0) + if (H5O_SHARED_DEBUG_REAL(f, _mesg, stream, indent, fwidth) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display native message info") done: @@ -486,4 +480,3 @@ H5O_SHARED_DEBUG(H5F_t *f, const void *_mesg, FILE *stream, int indent, } /* end H5O_SHARED_DEBUG() */ #endif /* H5Oshared_H */ - diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index 136268a7100..1c894a54d3c 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -6,60 +6,56 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: James Laird +/* Programmer: James Laird * Monday, January 29, 2007 * * Purpose: A message holding "implicitly shared object header message" * information in the superblock extension. */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - +#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Opkg.h" /* Object headers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#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, 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 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); +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 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); /* This message derives from H5O message class */ 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? */ - H5O__shmesg_decode, /*decode message */ - H5O_shmesg_encode, /*encode message */ - H5O_shmesg_copy, /*copy the native value */ - H5O_shmesg_size, /*raw message size */ + sizeof(H5O_shmesg_table_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__shmesg_decode, /*decode message */ + H5O__shmesg_encode, /*encode message */ + H5O__shmesg_copy, /*copy the native value */ + H5O__shmesg_size, /*raw message size */ NULL, /*free internal memory */ NULL, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /* set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /* set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ H5O__shmesg_debug /*debug the message */ }}; - /*------------------------------------------------------------------------- * Function: H5O__shmesg_decode * @@ -75,12 +71,11 @@ const H5O_msg_class_t H5O_MSG_SHMESG[1] = {{ *------------------------------------------------------------------------- */ static void * -H5O__shmesg_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__shmesg_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_shmesg_table_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + H5O_shmesg_table_t *mesg; /* Native message */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -88,8 +83,9 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(f); HDassert(p); - if(NULL == (mesg = (H5O_shmesg_table_t *)H5MM_calloc(sizeof(H5O_shmesg_table_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (NULL == (mesg = (H5O_shmesg_table_t *)H5MM_calloc(sizeof(H5O_shmesg_table_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* Retrieve version, table address, and number of indexes */ mesg->version = *p++; @@ -103,9 +99,8 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shmesg_decode() */ - /*------------------------------------------------------------------------- - * Function: H5O_shmesg_encode + * Function: H5O__shmesg_encode * * Purpose: Encode a shared message table message. * @@ -117,11 +112,11 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, *------------------------------------------------------------------------- */ static herr_t -H5O_shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) +H5O__shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -134,11 +129,10 @@ H5O_shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c *p++ = (uint8_t)mesg->nindexes; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_shmesg_encode() */ +} /* end H5O__shmesg_encode() */ - /*------------------------------------------------------------------------- - * Function: H5O_shmesg_copy + * Function: H5O__shmesg_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. @@ -152,19 +146,20 @@ H5O_shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c *------------------------------------------------------------------------- */ static void * -H5O_shmesg_copy(const void *_mesg, void *_dest) +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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(mesg); - if(!dest && NULL == (dest = (H5O_shmesg_table_t *)H5MM_malloc(sizeof(H5O_shmesg_table_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message") + if (!dest && NULL == (dest = (H5O_shmesg_table_t *)H5MM_malloc(sizeof(H5O_shmesg_table_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for shared message table message") /* All this message requires is a shallow copy */ *dest = *mesg; @@ -174,11 +169,10 @@ H5O_shmesg_copy(const void *_mesg, void *_dest) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shmesg_copy() */ +} /* end H5O__shmesg_copy() */ - /*------------------------------------------------------------------------- - * Function: H5O_shmesg_size + * Function: H5O__shmesg_size * * Purpose: Returns the size of the raw message in bytes not counting the * message type or size fields, but only the data fields. @@ -192,23 +186,22 @@ H5O_shmesg_copy(const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) +H5O__shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); - ret_value = (size_t)(1 + /* Version number */ - H5F_SIZEOF_ADDR(f) + /* Table address */ - 1); /* Number of indexes */ + ret_value = (size_t)(1 + /* Version number */ + H5F_SIZEOF_ADDR(f) + /* Table address */ + 1); /* Number of indexes */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shmesg_size() */ +} /* end H5O__shmesg_size() */ - /*------------------------------------------------------------------------- * Function: H5O__shmesg_debug * @@ -222,8 +215,7 @@ H5O_shmesg_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const voi *------------------------------------------------------------------------- */ static herr_t -H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, - int indent, int fwidth) +H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; @@ -236,13 +228,10 @@ H5O__shmesg_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Version:", mesg->version); - HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, - "Shared message table address:", mesg->addr); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Number of indexes:", mesg->nindexes); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Version:", mesg->version); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth, + "Shared message table address:", mesg->addr); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of indexes:", mesg->nindexes); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__shmesg_debug() */ - diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 18f32b3e1dd..fa030bd193e 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,63 +22,57 @@ *------------------------------------------------------------------------- */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Opkg.h" /* Object headers */ +#define H5G_FRIEND /*suppress error about including H5Gpkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -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 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, 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); -static herr_t H5O__stab_debug(H5F_t *f, const void *_mesg, - FILE * stream, int indent, int fwidth); +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); +static herr_t H5O__stab_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* This message derives from H5O message class */ 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? */ - H5O__stab_decode, /*decode message */ - H5O__stab_encode, /*encode message */ - H5O__stab_copy, /*copy the native value */ - H5O__stab_size, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__stab_free, /* free method */ - H5O__stab_delete, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - H5O__stab_copy_file, /* copy native value to file */ - H5O__stab_post_copy_file, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - H5O__stab_debug /*debug the message */ + H5O_STAB_ID, /*message id number */ + "stab", /*message name for debugging */ + sizeof(H5O_stab_t), /*native message size */ + 0, /* messages are sharable? */ + H5O__stab_decode, /*decode message */ + H5O__stab_encode, /*encode message */ + H5O__stab_copy, /*copy the native value */ + H5O__stab_size, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__stab_free, /* free method */ + H5O__stab_delete, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + H5O__stab_copy_file, /* copy native value to file */ + H5O__stab_post_copy_file, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O__stab_debug /*debug the message */ }}; /* Declare a free list to manage the H5O_stab_t struct */ H5FL_DEFINE_STATIC(H5O_stab_t); - /*------------------------------------------------------------------------- * Function: H5O__stab_decode * @@ -95,12 +89,11 @@ H5FL_DEFINE_STATIC(H5O_stab_t); *------------------------------------------------------------------------- */ static void * -H5O__stab_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__stab_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_stab_t *stab = NULL; - void *ret_value = NULL; /* Return value */ + H5O_stab_t *stab = NULL; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -109,7 +102,7 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HDassert(p); /* decode */ - if(NULL == (stab = H5FL_CALLOC(H5O_stab_t))) + if (NULL == (stab = H5FL_CALLOC(H5O_stab_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5F_addr_decode(f, &p, &(stab->btree_addr)); H5F_addr_decode(f, &p, &(stab->heap_addr)); @@ -118,14 +111,13 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, ret_value = stab; done: - if(ret_value == NULL) - if(stab != NULL) + if (ret_value == NULL) + if (stab != NULL) stab = H5FL_FREE(H5O_stab_t, stab); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_decode() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_encode * @@ -141,7 +133,7 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, static herr_t H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -157,7 +149,6 @@ H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_encode() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_copy * @@ -176,15 +167,15 @@ H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co 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 */ + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; + H5O_stab_t * dest = (H5O_stab_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* check args */ HDassert(stab); - if(!dest && NULL == (dest = H5FL_MALLOC(H5O_stab_t))) + if (!dest && NULL == (dest = H5FL_MALLOC(H5O_stab_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* copy */ @@ -197,7 +188,6 @@ H5O__stab_copy(const void *_mesg, void *_dest) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_copy() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_size * @@ -217,7 +207,7 @@ H5O__stab_copy(const void *_mesg, void *_dest) static size_t H5O__stab_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void H5_ATTR_UNUSED *_mesg) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -227,7 +217,6 @@ H5O__stab_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_size() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_free * @@ -252,7 +241,6 @@ H5O__stab_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_free() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_delete * @@ -268,7 +256,7 @@ H5O__stab_free(void *mesg) static herr_t H5O__stab_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *mesg) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -277,14 +265,13 @@ H5O__stab_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *mesg) HDassert(mesg); /* Free the file space for the symbol table */ - if(H5G__stab_delete(f, (const H5O_stab_t *)mesg) < 0) + if (H5G__stab_delete(f, (const H5O_stab_t *)mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free symbol table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__stab_delete() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_copy_file * @@ -301,14 +288,14 @@ H5O__stab_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *mesg) */ static void * 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) + 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; - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -317,40 +304,39 @@ H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, HDassert(file_dst); /* Allocate space for the destination stab */ - if(NULL == (stab_dst = H5FL_MALLOC(H5O_stab_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL == (stab_dst = H5FL_MALLOC(H5O_stab_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the old local heap's size and use that as the hint for the new heap */ - if(H5HL_get_size(file_src, stab_src->heap_addr, &size_hint) < 0) + if (H5HL_get_size(file_src, stab_src->heap_addr, &size_hint) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, NULL, "can't query local heap size") /* Set copy metadata tag */ H5_BEGIN_TAG(H5AC__COPIED_TAG); /* Create components of symbol table message */ - if(H5G__stab_create_components(file_dst, stab_dst, size_hint) < 0) + if (H5G__stab_create_components(file_dst, stab_dst, size_hint) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") /* Reset metadata tag */ H5_END_TAG /* Cache stab in udata */ - udata->cache_type = H5G_CACHED_STAB; + udata->cache_type = H5G_CACHED_STAB; udata->cache.stab.btree_addr = stab_dst->btree_addr; - udata->cache.stab.heap_addr = stab_dst->heap_addr; + udata->cache.stab.heap_addr = stab_dst->heap_addr; /* Set return value */ ret_value = stab_dst; done: - if(!ret_value) - if(stab_dst) + if (!ret_value) + if (stab_dst) stab_dst = H5FL_FREE(H5O_stab_t, stab_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__stab_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_post_copy_file * @@ -364,14 +350,13 @@ H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, *------------------------------------------------------------------------- */ 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 H5_ATTR_UNUSED *mesg_flags, - H5O_copy_t *cpy_info) +H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, + 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; - H5G_bt_it_cpy_t udata; /* B-tree user data */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_stab_t *stab_src = (const H5O_stab_t *)mesg_src; + 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 */ FUNC_ENTER_STATIC @@ -383,25 +368,24 @@ H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, HDassert(cpy_info); /* If we are performing a 'shallow hierarchy' copy, get out now */ - if(cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) + if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) HGOTO_DONE(SUCCEED) /* Set up B-tree iteration user data */ - udata.src_oloc = src_oloc; + udata.src_oloc = src_oloc; udata.src_heap_addr = stab_src->heap_addr; - udata.dst_file = dst_oloc->file; - udata.dst_stab = stab_dst; - udata.cpy_info = cpy_info; + udata.dst_file = dst_oloc->file; + udata.dst_stab = stab_dst; + udata.cpy_info = cpy_info; /* Iterate over objects in group, copying them */ - if((H5B_iterate(src_oloc->file, H5B_SNODE, stab_src->btree_addr, H5G__node_copy, &udata)) < 0) + if ((H5B_iterate(src_oloc->file, H5B_SNODE, stab_src->btree_addr, H5G__node_copy, &udata)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "iteration operator failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__stab_post_copy_file() */ - /*------------------------------------------------------------------------- * Function: H5O__stab_debug * @@ -415,10 +399,9 @@ H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, *------------------------------------------------------------------------- */ static herr_t -H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, - int indent, int fwidth) +H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5O_stab_t *stab = (const H5O_stab_t *) _mesg; + const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; FUNC_ENTER_STATIC_NOERR @@ -429,12 +412,9 @@ H5O__stab_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE * stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "B-tree address:", stab->btree_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "B-tree address:", stab->btree_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Name heap address:", stab->heap_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Name heap address:", stab->heap_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_debug() */ - diff --git a/src/H5Otest.c b/src/H5Otest.c index 6c07e2a04e5..cdbc5eebeba 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,58 +21,49 @@ /* Module Setup */ /****************/ -#define H5A_FRIEND /*suppress error about including H5Apkg */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ -#define H5O_TESTING /*suppress warning about H5O testing funcs*/ - +#define H5A_FRIEND /*suppress error about including H5Apkg */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5O_TESTING /*suppress warning about H5O testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5O__is_attr_dense_test @@ -95,39 +86,39 @@ htri_t H5O__is_attr_dense_test(hid_t oid) { - H5O_t *oh = NULL; /* Object header */ - H5O_ainfo_t ainfo; /* Attribute information for object */ - 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 */ + H5O_t * oh = NULL; /* Object header */ + H5O_ainfo_t ainfo; /* Attribute information for object */ + 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 */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check if dense storage is being used */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ - HDassert(H5O_msg_count_real(oh, H5O_MSG_ATTR) == 0); + HDassert(H5O__msg_count_real(oh, H5O_MSG_ATTR) == 0); ret_value = TRUE; } /* end if */ @@ -135,15 +126,14 @@ H5O__is_attr_dense_test(hid_t oid) ret_value = FALSE; done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__is_attr_dense_test() */ +} /* H5O__is_attr_dense_test() */ - /*-------------------------------------------------------------------------- NAME H5O__is_attr_empty_test @@ -165,45 +155,45 @@ 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_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 */ - hsize_t nattrs; /* Number of attributes */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - htri_t ret_value = FAIL; /* Return value */ + 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 */ + hsize_t nattrs; /* Number of attributes */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) + if ((ainfo_exists = H5A__get_ainfo(loc->file, oh, &ainfo)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Retrieve the number of attribute messages in header */ - nattrs = H5O_msg_count_real(oh, H5O_MSG_ATTR); + nattrs = H5O__msg_count_real(oh, H5O_MSG_ATTR); /* Check for later version of object header format & attribute info available */ - if(oh->version > H5O_VERSION_1) { - if(ainfo_exists) { + if (oh->version > H5O_VERSION_1) { + if (ainfo_exists) { /* Check for using dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(nattrs == 0); @@ -211,15 +201,17 @@ H5O__is_attr_empty_test(hid_t oid) H5_BEGIN_TAG(loc->addr); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for name index") /* Reset metadata tag in API context */ H5_END_TAG /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, &nattrs) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + if (H5B2_get_nrec(bt2_name, &nattrs) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from name index") } /* end if */ /* Verify that attribute count in object header is correct */ @@ -234,17 +226,16 @@ H5O__is_attr_empty_test(hid_t oid) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__is_attr_empty_test() */ +} /* H5O__is_attr_empty_test() */ - /*-------------------------------------------------------------------------- NAME H5O__num_attrs_test @@ -267,44 +258,44 @@ 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_ainfo_t ainfo; /* Attribute information for object */ - 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 */ + 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 */ + hsize_t obj_nattrs; /* Number of attributes */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Retrieve the number of attribute messages in header */ - obj_nattrs = H5O_msg_count_real(oh, H5O_MSG_ATTR); + obj_nattrs = H5O__msg_count_real(oh, H5O_MSG_ATTR); /* Check for later version of object header format */ - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for using dense storage */ - if(H5F_addr_defined(ainfo.fheap_addr)) { + if (H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(obj_nattrs == 0); @@ -312,14 +303,14 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) H5_BEGIN_TAG(loc->addr); /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in API context */ H5_END_TAG /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, &obj_nattrs) < 0) + if (H5B2_get_nrec(bt2_name, &obj_nattrs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") } /* end if */ @@ -332,17 +323,16 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__num_attrs_test() */ +} /* H5O__num_attrs_test() */ - /*-------------------------------------------------------------------------- NAME H5O__attr_dense_info_test @@ -367,22 +357,22 @@ 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_ainfo_t ainfo; /* Attribute information for object */ - 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 */ + 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 */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; @@ -390,40 +380,42 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) H5_BEGIN_TAG(loc->addr); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1) { + if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ - if(H5A__get_ainfo(loc->file, oh, &ainfo) < 0) + if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for 'dense' attribute storage file addresses being defined */ - if(!H5F_addr_defined(ainfo.fheap_addr)) + if (!H5F_addr_defined(ainfo.fheap_addr)) HGOTO_DONE_TAG(FAIL) - if(!H5F_addr_defined(ainfo.name_bt2_addr)) + if (!H5F_addr_defined(ainfo.name_bt2_addr)) HGOTO_DONE_TAG(FAIL) /* Open the name index v2 B-tree */ - if(NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) + if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ - if(H5B2_get_nrec(bt2_name, name_count) < 0) + if (H5B2_get_nrec(bt2_name, name_count) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ - if(H5F_addr_defined(ainfo.corder_bt2_addr)) { + if (H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ - if(NULL == (bt2_corder = H5B2_open(loc->file, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + if (NULL == (bt2_corder = H5B2_open(loc->file, ainfo.corder_bt2_addr, NULL))) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ - if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + if (H5B2_get_nrec(bt2_corder, corder_count) < 0) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, + "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; @@ -433,19 +425,18 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ - if(bt2_name && H5B2_close(bt2_name) < 0) + if (bt2_name && H5B2_close(bt2_name) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") - if(bt2_corder && H5B2_close(bt2_corder) < 0) + if (bt2_corder && H5B2_close(bt2_corder) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__attr_dense_info_test() */ +} /* H5O__attr_dense_info_test() */ - /*-------------------------------------------------------------------------- NAME H5O__check_msg_marked_test @@ -470,45 +461,45 @@ 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_mesg_t *idx_msg; /* Pointer to message */ - unsigned idx; /* Index of message */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate "unknown" message */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(idx_msg->type->id == H5O_UNKNOWN_ID) { + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (idx_msg->type->id == H5O_UNKNOWN_ID) { /* Check for "unknown" message having the correct flags */ - if(((idx_msg->flags & H5O_MSG_FLAG_WAS_UNKNOWN) > 0) != flag_val) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "'unknown' message has incorrect 'was unknown' flag value") + if (((idx_msg->flags & H5O_MSG_FLAG_WAS_UNKNOWN) > 0) != flag_val) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, + "'unknown' message has incorrect 'was unknown' flag value") /* Break out of loop, to indicate that the "unknown" message was found */ break; } /* end if */ /* Check for not finding an "unknown" message */ - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "'unknown' message type not found") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__check_msg_marked_test() */ +} /* H5O__check_msg_marked_test() */ - /*-------------------------------------------------------------------------- NAME H5O__expunge_chunks_test @@ -531,16 +522,16 @@ 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 */ - haddr_t chk_addr[16]; /* Array of chunk addresses */ - size_t nchunks; /* Number of chunks in object header */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Safety check */ @@ -548,24 +539,24 @@ H5O__expunge_chunks_test(const H5O_loc_t *loc) HDassert(0 < nchunks && nchunks < NELMTS(chk_addr)); /* Iterate over all the chunks, saving the chunk addresses */ - for(u = 0; u < oh->nchunks; u++) + for (u = 0; u < oh->nchunks; u++) chk_addr[u] = oh->chunk[u].addr; /* Release the object header */ - if(H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header") /* Iterate over all the saved chunk addresses, evicting them from the cache */ /* (in reverse order, so that chunk #0 is unpinned) */ - for(u = nchunks - 1; u < nchunks; u--) - if(H5AC_expunge_entry(loc->file, (u == 0 ? H5AC_OHDR : H5AC_OHDR_CHK), chk_addr[u], H5AC__NO_FLAGS_SET) < 0) + for (u = nchunks - 1; u < nchunks; u--) + if (H5AC_expunge_entry(loc->file, (u == 0 ? H5AC_OHDR : H5AC_OHDR_CHK), chk_addr[u], + H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTEXPUNGE, FAIL, "unable to expunge object header chunk") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__expunge_chunks_test() */ +} /* H5O__expunge_chunks_test() */ - /*-------------------------------------------------------------------------- NAME H5O__get_rc_test @@ -589,7 +580,7 @@ H5O__expunge_chunks_test(const H5O_loc_t *loc) herr_t H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) { - H5O_t *oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -599,7 +590,7 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) HDassert(rc); /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Save the refcount for the object header */ @@ -607,13 +598,12 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) done: /* Release the object header */ - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__get_rc_test() */ +} /* H5O__get_rc_test() */ - /*-------------------------------------------------------------------------- NAME H5O__msg_get_chunkno_test @@ -638,31 +628,31 @@ 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_mesg_t *idx_msg; /* Pointer to message */ - unsigned idx; /* Index of message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate first message of given type */ - for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) - if(idx_msg->type->id == msg_type) { + for (idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) + if (idx_msg->type->id == msg_type) { /* Set the chunk number for the message */ *chunk_num = idx_msg->chunkno; @@ -671,19 +661,18 @@ H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) } /* end if */ /* Check for not finding a message of the given type*/ - if(idx == oh->nmesgs) + if (idx == oh->nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message of type not found") done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__msg_get_chunkno_test() */ +} /* H5O__msg_get_chunkno_test() */ - /*-------------------------------------------------------------------------- NAME H5O__msg_move_to_new_chunk_test @@ -706,76 +695,80 @@ 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_mesg_t *curr_msg; /* Pointer to current message */ - unsigned idx; /* Index of message */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Get object location for object */ - if(NULL == (loc = H5O_get_loc(oid))) + if (NULL == (loc = H5O_get_loc(oid))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") /* Set API context */ - if(H5CX_push() < 0) + if (H5CX_push() < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set API context") api_ctx_pushed = TRUE; /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) + if (NULL == (oh = H5O_protect(loc, H5AC__NO_FLAGS_SET, FALSE))) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Locate first message of given type */ - for(idx = 0, curr_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, curr_msg++) - 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 = (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 */ - size_t gap_size = 0; /* Size of gap after current message */ - size_t null_size = 0; /* Size of NULL message after current message */ - unsigned null_msgno = 0; /* Index of NULL message after current message */ - size_t total_size; /* Total size of available space "around" current message */ - size_t new_idx; /* Index of new null message */ + for (idx = 0, curr_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, curr_msg++) + 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 = + (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 */ + size_t gap_size = 0; /* Size of gap after current message */ + size_t null_size = 0; /* Size of NULL message after current message */ + unsigned null_msgno = 0; /* Index of NULL message after current message */ + size_t total_size; /* Total size of available space "around" current message */ + size_t new_idx; /* Index of new null message */ /* Check if the message is the last one in the chunk */ - if(end_msg == end_chunk_data) + if (end_msg == end_chunk_data) gap_size = oh->chunk[msg_chunkno].gap; else { - H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ - unsigned v; /* Local index variable */ + H5O_mesg_t *tmp_msg; /* Temp. pointer to message to operate on */ + unsigned v; /* Local index variable */ /* Check for null message after this message, in same chunk */ - for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { - if(tmp_msg->type->id == H5O_NULL_ID && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { + for (v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { + if (tmp_msg->type->id == H5O_NULL_ID && + (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { null_msgno = v; - null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; + null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; break; } /* end if */ /* XXX: Should also check for NULL message in front of current message... */ } /* end for */ - } /* end else */ + } /* end else */ /* Add up current message's total available space */ total_size = curr_msg->raw_size + gap_size + null_size; /* Set up "found message" info for moving the message */ - found_msg.msgno = (int)idx; - found_msg.id = curr_msg->type->id; - found_msg.chunkno = msg_chunkno; - found_msg.gap_size = gap_size; - found_msg.null_size = null_size; + found_msg.msgno = (int)idx; + found_msg.id = curr_msg->type->id; + found_msg.chunkno = msg_chunkno; + found_msg.gap_size = gap_size; + found_msg.null_size = null_size; found_msg.total_size = total_size; found_msg.null_msgno = null_msgno; /* Allocate and initialize new chunk in the file, moving the found message */ /* (*new_idx returned from this routine is unused here) */ - if(H5O__alloc_chunk(loc->file, oh, (curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)), oh->nmesgs, &found_msg, &new_idx) < 0) + if (H5O__alloc_chunk(loc->file, oh, (curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)), + oh->nmesgs, &found_msg, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "can't allocate new object header chunk") /* Break out of loop, the message was found */ @@ -783,11 +776,10 @@ H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) } /* end if */ done: - if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(api_ctx_pushed && H5CX_pop() < 0) + if (api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_NOAPI(ret_value) -} /* H5O__msg_get_chunkno_test() */ - +} /* H5O__msg_move_to_new_chunk_test() */ diff --git a/src/H5Ounknown.c b/src/H5Ounknown.c index a7116c82f9a..2b8a7bbcd92 100644 --- a/src/H5Ounknown.c +++ b/src/H5Ounknown.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,46 +22,43 @@ *------------------------------------------------------------------------- */ -#include "H5Omodule.h" /* This source code file is part of the H5O module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Opkg.h" /* Object headers */ +#include "H5Omodule.h" /* This source code file is part of the H5O module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ static herr_t H5O__unknown_free(void *_mesg); /* This message derives from H5O message class */ 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? */ - NULL, /*decode message */ - NULL, /*encode message */ - NULL, /*copy the native value */ - NULL, /*size of symbol table entry */ - NULL, /*default reset method */ - H5O__unknown_free, /* free method */ - NULL, /* file delete method */ - NULL, /* link method */ - NULL, /*set share method */ - NULL, /*can share method */ - NULL, /* pre copy native value to file */ - NULL, /* copy native value to file */ - NULL, /* post copy native value to file */ - NULL, /* get creation index */ - NULL, /* set creation index */ - NULL /*debug the message */ + H5O_UNKNOWN_ID, /*message id number */ + "unknown", /*message name for debugging */ + 0, /*native message size */ + 0, /* messages are sharable? */ + NULL, /*decode message */ + NULL, /*encode message */ + NULL, /*copy the native value */ + NULL, /*size of symbol table entry */ + NULL, /*default reset method */ + H5O__unknown_free, /* free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + NULL /*debug the message */ }}; /* Declare a free list to manage the H5O_unknown_t struct */ H5FL_DEFINE(H5O_unknown_t); - /*------------------------------------------------------------------------- * Function: H5O__unknown_free * @@ -85,4 +82,3 @@ H5O__unknown_free(void *mesg) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__unknown_free() */ - diff --git a/src/H5P.c b/src/H5P.c index 6d7f4d0f390..45a9267471e 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,40 +20,36 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* Typedef for property iterator callback */ typedef struct { - H5P_iterate_t iter_func; /* Iterator callback */ - hid_t id; /* Property list or class ID */ - void *iter_data; /* Iterator callback pointer */ + H5P_iterate_t iter_func; /* Iterator callback */ + hid_t id; /* Property list or class ID */ + void * iter_data; /* Iterator callback pointer */ } H5P_iter_ud_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -61,17 +57,14 @@ typedef struct { /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - /*-------------------------------------------------------------------------- NAME H5Pcopy @@ -96,46 +89,46 @@ hbool_t H5_PKG_INIT_VAR = FALSE; hid_t H5Pcopy(hid_t id) { - void *obj; /* Property object to copy */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + void *obj; /* Property object to copy */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", id); - if(H5P_DEFAULT == id) + if (H5P_DEFAULT == id) HGOTO_DONE(H5P_DEFAULT); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not property object"); - if(NULL == (obj = H5I_object(id))) + if (NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "property object doesn't exist"); /* Compare property lists */ - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if((ret_value = H5P_copy_plist((H5P_genplist_t *)obj, TRUE)) < 0) + if (H5I_GENPROP_LST == H5I_get_type(id)) { + if ((ret_value = H5P_copy_plist((H5P_genplist_t *)obj, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property list"); } /* end if */ /* Must be property classes */ else { - H5P_genclass_t *copy_class; /* Copy of class */ + H5P_genclass_t *copy_class; /* Copy of class */ /* Copy the class */ - if((copy_class = H5P__copy_pclass((H5P_genclass_t *)obj)) == NULL) + if ((copy_class = H5P__copy_pclass((H5P_genclass_t *)obj)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property class"); /* Get an atom for the copied class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class, TRUE)) < 0) { + if ((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class, TRUE)) < 0) { H5P__close_class(copy_class); - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, + "unable to atomize property list class"); } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pcopy() */ +} /* H5Pcopy() */ - /*-------------------------------------------------------------------------- NAME H5Pcreate_class @@ -171,52 +164,49 @@ H5Pcopy(hid_t id) REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Pcreate_class(hid_t parent, const char *name, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data - ) +H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data, + H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close, + void *close_data) { - H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */ - H5P_genclass_t *pclass = NULL; /* Property list class created */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */ + H5P_genclass_t *pclass = NULL; /* Property list class created */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE8("i", "i*sx*xx*xx*x", parent, name, cls_create, create_data, cls_copy, - copy_data, cls_close, close_data); + H5TRACE8("i", "i*sx*xx*xx*x", parent, name, cls_create, create_data, cls_copy, copy_data, cls_close, + close_data); /* Check arguments. */ - if(H5P_DEFAULT!=parent && (H5I_GENPROP_CLS!=H5I_get_type(parent))) + if (H5P_DEFAULT != parent && (H5I_GENPROP_CLS != H5I_get_type(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid class name") - if((create_data != NULL && cls_create == NULL) - || (copy_data != NULL && cls_copy == NULL) - || (close_data != NULL && cls_close == NULL)) + if ((create_data != NULL && cls_create == NULL) || (copy_data != NULL && cls_copy == NULL) || + (close_data != NULL && cls_close == NULL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "data specified, but no callback provided") /* Get the pointer to the parent class */ - if(parent == H5P_DEFAULT) + if (parent == H5P_DEFAULT) par_class = NULL; - else if(NULL == (par_class = (H5P_genclass_t *)H5I_object(parent))) + else if (NULL == (par_class = (H5P_genclass_t *)H5I_object(parent))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't retrieve parent class") /* Create the new property list class */ - if(NULL == (pclass = H5P__create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy, copy_data, cls_close, close_data))) + if (NULL == (pclass = H5P__create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy, + copy_data, cls_close, close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list class") /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class") done: - if(H5I_INVALID_HID == ret_value && pclass) + if (H5I_INVALID_HID == ret_value && pclass) H5P__close_class(pclass); FUNC_LEAVE_API(ret_value) -} /* H5Pcreate_class() */ +} /* H5Pcreate_class() */ - /*-------------------------------------------------------------------------- NAME H5Pcreate @@ -242,25 +232,24 @@ H5Pcreate_class(hid_t parent, const char *name, hid_t H5Pcreate(hid_t cls_id) { - H5P_genclass_t *pclass; /* Property list class to modify */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", cls_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class"); /* Create the new property list */ - if((ret_value = H5P_create_id(pclass, TRUE)) < 0) + if ((ret_value = H5P_create_id(pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pcreate() */ +} /* H5Pcreate() */ - /*-------------------------------------------------------------------------- NAME H5Pregister2 @@ -416,52 +405,51 @@ H5Pcreate(hid_t cls_id) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, - H5P_prp_create_func_t prp_create, 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_compare_func_t prp_cmp, - H5P_prp_close_func_t prp_close) +H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, + 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_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genclass_t *pclass; /* Property list class to modify */ + H5P_genclass_t *pclass; /* Property list class to modify */ H5P_genclass_t *orig_pclass; /* Original property class */ - herr_t ret_value; /* Return value */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE11("e", "i*sz*xxxxxxxx", cls_id, name, size, def_value, prp_create, - prp_set, prp_get, prp_delete, prp_copy, prp_cmp, prp_close); + H5TRACE11("e", "i*sz*xxxxxxxx", cls_id, name, size, def_value, prp_create, prp_set, prp_get, prp_delete, + prp_copy, prp_cmp, prp_close); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name") - if(size > 0 && def_value == NULL) + if (size > 0 && def_value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ orig_pclass = pclass; - if((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, prp_cmp, prp_close)) < 0) + if ((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, + prp_delete, prp_copy, prp_cmp, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class") /* Check if the property class changed and needs to be substituted in the ID */ - if(pclass != orig_pclass) { - H5P_genclass_t *old_pclass; /* Old property class */ + if (pclass != orig_pclass) { + H5P_genclass_t *old_pclass; /* Old property class */ /* Substitute the new property class in the ID */ - if(NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) + if (NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_pclass == orig_pclass); /* Close the previous class */ - if(H5P__close_class(old_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(old_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pregister2() */ +} /* H5Pregister2() */ - /*-------------------------------------------------------------------------- NAME H5Pinsert2 @@ -602,36 +590,34 @@ H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pinsert2(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_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) +H5Pinsert2(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_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE10("e", "i*sz*xxxxxxx", plist_id, name, size, value, prp_set, prp_get, - prp_delete, prp_copy, prp_cmp, prp_close); + H5TRACE10("e", "i*sz*xxxxxxx", plist_id, name, size, value, prp_set, prp_get, prp_delete, prp_copy, + prp_cmp, prp_close); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name") - if(size > 0 && value == NULL) + if (size > 0 && value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ - if((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, - NULL, NULL, prp_delete, prp_copy, prp_cmp, prp_close)) < 0) + if ((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, + prp_cmp, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist") done: FUNC_LEAVE_API(ret_value) -} /* H5Pinsert2() */ +} /* H5Pinsert2() */ - /*-------------------------------------------------------------------------- NAME H5Pset @@ -666,29 +652,28 @@ H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, herr_t H5Pset(hid_t plist_id, const char *name, const void *value) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", plist_id, name, value); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(value == NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go set the value */ - if(H5P_set(plist, name, value) < 0) + if (H5P_set(plist, name, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value in plist"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pset() */ +} /* H5Pset() */ - /*-------------------------------------------------------------------------- NAME H5Pexist @@ -714,41 +699,39 @@ H5Pset(hid_t plist_id, const char *name, const void *value) htri_t H5Pexist(hid_t id, const char *name) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property class to query */ - htri_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property class to query */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "i*s", id, name); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(!name || !*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 */ - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + 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"); - if((ret_value = H5P_exist_plist(plist, name)) < 0) + if ((ret_value = H5P_exist_plist(plist, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in list"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); + if ((ret_value = H5P__exist_pclass(pclass, name)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); - if((ret_value = H5P__exist_pclass(pclass, name)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pexist() */ +} /* H5Pexist() */ - /*-------------------------------------------------------------------------- NAME H5Pget_size @@ -775,56 +758,57 @@ H5Pexist(hid_t id, const char *name) herr_t H5Pget_size(hid_t id, const char *name, size_t *size) { - H5P_genclass_t *pclass; /* Property class to query */ - H5P_genplist_t *plist; /* Property list to query */ - herr_t ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*z", id, name, size); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(size==NULL) + if (size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property size"); - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + 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"); /* Check the property size */ - if((ret_value = H5P__get_size_plist(plist, name, size)) < 0) + if ((ret_value = H5P__get_size_plist(plist, name, size)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); } /* end if */ - else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - /* Check the property size */ - if((ret_value = H5P__get_size_pclass(pclass, name, size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + /* Check the property size */ + if ((ret_value = H5P__get_size_pclass(pclass, name, size)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist"); + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_size() */ +} /* H5Pget_size() */ - /*-------------------------------------------------------------------------- NAME - H5Pencode + H5Pencode2 PURPOSE - Routine to convert the property values in a property list into a binary buffer + Routine to convert the property values in a property list into a binary buffer. + The encoding of property values will be done according to the file format + setting in fapl_id. USAGE - herr_t H5Pencode(plist_id, buf, nalloc) + herr_t H5Pencode(plist_id, buf, nalloc, fapl_id) hid_t plist_id; IN: Identifier to property list to encode void *buf: OUT: buffer to gold the encoded plist size_t *nalloc; IN/OUT: size of buffer needed to encode plist + hid_t fapl_id; IN: File access property list ID RETURNS Returns non-negative on success, negative on failure. DESCRIPTION @@ -837,32 +821,30 @@ H5Pget_size(hid_t id, const char *name, size_t *size) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pencode(hid_t plist_id, void *buf, size_t *nalloc) +H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list to query */ - hid_t temp_fapl_id = H5P_DEFAULT; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*x*z", plist_id, buf, nalloc); + H5TRACE4("e", "i*x*zi", plist_id, buf, nalloc, fapl_id); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Call the internal encode routine */ - if((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) + if ((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pencode() */ +} /* H5Pencode2() */ - /*-------------------------------------------------------------------------- NAME H5Pdecode @@ -889,20 +871,19 @@ H5Pencode(hid_t plist_id, void *buf, size_t *nalloc) hid_t H5Pdecode(const void *buf) { - hid_t ret_value = H5I_INVALID_HID; /* return value */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", buf); /* Call the internal decode routine */ - if((ret_value = H5P__decode(buf)) < 0) + if ((ret_value = H5P__decode(buf)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, H5I_INVALID_HID, "unable to decode property list"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pdecode() */ +} /* H5Pdecode() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class @@ -926,37 +907,36 @@ H5Pdecode(const void *buf) hid_t H5Pget_class(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass=NULL; /* Property list class */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass = NULL; /* Property list class */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", plist_id); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list"); /* Retrieve the property list class */ - if((pclass = H5P_get_class(plist)) == NULL) + if ((pclass = H5P_get_class(plist)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list"); /* Increment the outstanding references to the class object */ - if(H5P__access_class(pclass, H5P_MOD_INC_REF) < 0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID,"Can't increment class ID ref count"); + if (H5P__access_class(pclass, H5P_MOD_INC_REF) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count"); /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class"); done: - if(H5I_INVALID_HID == ret_value && pclass) + if (H5I_INVALID_HID == ret_value && pclass) H5P__close_class(pclass); FUNC_LEAVE_API(ret_value) -} /* H5Pget_class() */ +} /* H5Pget_class() */ - /*-------------------------------------------------------------------------- NAME H5Pget_nprops @@ -983,40 +963,38 @@ H5Pget_class(hid_t plist_id) herr_t H5Pget_nprops(hid_t id, size_t *nprops) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property class to query */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property class to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*z", id, nprops); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(nprops==NULL) + if (nprops == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property nprops pointer"); - if(H5I_GENPROP_LST == H5I_get_type(id)) { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(id))) + 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"); - if(H5P__get_nprops_plist(plist, nprops) < 0) + if (H5P__get_nprops_plist(plist, nprops) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in plist"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); + if (H5P_get_nprops_pclass(pclass, nprops, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); - if(H5P_get_nprops_pclass(pclass, nprops, FALSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_nprops() */ +} /* H5Pget_nprops() */ - /*-------------------------------------------------------------------------- NAME H5Pequal @@ -1040,26 +1018,26 @@ H5Pget_nprops(hid_t id, size_t *nprops) htri_t H5Pequal(hid_t id1, hid_t id2) { - void *obj1, *obj2; /* Property objects to compare */ - htri_t ret_value = FALSE; /* return value */ + void * obj1, *obj2; /* Property objects to compare */ + htri_t ret_value = FALSE; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", id1, id2); /* Check arguments. */ - if((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) - || (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2))) + if ((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) || + (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects") - if(H5I_get_type(id1) != H5I_get_type(id2)) + if (H5I_get_type(id1) != H5I_get_type(id2)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects") - if(NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2))) + if (NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist") /* Compare property lists */ - if(H5I_GENPROP_LST == H5I_get_type(id1)) { + if (H5I_GENPROP_LST == H5I_get_type(id1)) { int cmp_ret = 0; - if(H5P__cmp_plist((const H5P_genplist_t *)obj1, (const H5P_genplist_t *)obj2, &cmp_ret) < 0) + if (H5P__cmp_plist((const H5P_genplist_t *)obj1, (const H5P_genplist_t *)obj2, &cmp_ret) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOMPARE, FAIL, "can't compare property lists") /* Set return value */ @@ -1067,15 +1045,14 @@ H5Pequal(hid_t id1, hid_t id2) } /* end if */ /* Must be property classes */ else { - if(H5P__cmp_class((const H5P_genclass_t *)obj1, (const H5P_genclass_t *)obj2) == 0) + if (H5P__cmp_class((const H5P_genclass_t *)obj1, (const H5P_genclass_t *)obj2) == 0) ret_value = TRUE; } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pequal() */ +} /* H5Pequal() */ - /*-------------------------------------------------------------------------- NAME H5Pisa_class @@ -1102,26 +1079,25 @@ H5Pequal(hid_t id1, hid_t id2) htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id) { - htri_t ret_value; /* return value */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", plist_id, pclass_id); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id)) + if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(H5I_GENPROP_CLS != H5I_get_type(pclass_id)) + if (H5I_GENPROP_CLS != H5I_get_type(pclass_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ - if((ret_value = H5P_isa_class(plist_id, pclass_id)) < 0) + if ((ret_value = H5P_isa_class(plist_id, pclass_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pisa_class() */ +} /* H5Pisa_class() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_cb @@ -1146,8 +1122,8 @@ property list or class. static int H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) { - H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ - int ret_value = 0; /* Return value */ + H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1161,7 +1137,6 @@ H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_cb() */ - /*-------------------------------------------------------------------------- NAME H5Piterate @@ -1218,46 +1193,46 @@ iteration, the function's behavior is undefined. int 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 */ - int ret_value; /* return value */ + 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 */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Is", "i*Isx*x", id, idx, iter_func, iter_data); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) + if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); - if(NULL == (obj = H5I_object(id))) + if (NULL == (obj = H5I_object(id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); - if(iter_func == NULL) + if (iter_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); /* Set up user data */ udata.iter_func = iter_func; - udata.id = id; + udata.id = id; udata.iter_data = iter_data; - if(H5I_GENPROP_LST == H5I_get_type(id)) { + if (H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ - if((ret_value = H5P__iterate_plist((H5P_genplist_t *)obj, TRUE, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) + if ((ret_value = H5P__iterate_plist((H5P_genplist_t *)obj, TRUE, (idx ? idx : &fake_idx), + H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ + else if (H5I_GENPROP_CLS == H5I_get_type(id)) { + /* Iterate over a property class */ + if ((ret_value = H5P__iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb, + &udata)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); + } /* end if */ else - if(H5I_GENPROP_CLS == H5I_get_type(id)) { - /* Iterate over a property class */ - if((ret_value = H5P__iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object"); done: FUNC_LEAVE_API(ret_value) -} /* H5Piterate() */ +} /* H5Piterate() */ - /*-------------------------------------------------------------------------- NAME H5Pget @@ -1289,29 +1264,28 @@ H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) herr_t H5Pget(hid_t plist_id, const char *name, void *value) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", plist_id, name, value); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - if(value==NULL) + if (value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); /* Go get the value */ - if(H5P_get(plist,name,value) < 0) + if (H5P_get(plist, name, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget() */ +} /* H5Pget() */ - /*-------------------------------------------------------------------------- NAME H5Premove @@ -1341,27 +1315,26 @@ H5Pget(hid_t plist_id, const char *name, void *value) herr_t H5Premove(hid_t plist_id, const char *name) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, name); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Create the new property list class */ - if((ret_value = H5P_remove(plist, name)) < 0) + if ((ret_value = H5P_remove(plist, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); done: FUNC_LEAVE_API(ret_value) -} /* H5Premove() */ +} /* H5Premove() */ - /*-------------------------------------------------------------------------- NAME H5Pcopy_prop @@ -1403,41 +1376,40 @@ H5Premove(hid_t plist_id, const char *name) herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name) { - H5I_type_t src_id_type, dst_id_type; /* ID types */ - herr_t ret_value = SUCCEED; /* return value */ + H5I_type_t src_id_type, dst_id_type; /* ID types */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*s", dst_id, src_id, name); /* Check arguments. */ - if((src_id_type = H5I_get_type(src_id)) < 0) + if ((src_id_type = H5I_get_type(src_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid source ID") - if((dst_id_type = H5I_get_type(dst_id)) < 0) + if ((dst_id_type = H5I_get_type(dst_id)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid destination ID") - if((H5I_GENPROP_LST != src_id_type && H5I_GENPROP_CLS != src_id_type) - || (H5I_GENPROP_LST != dst_id_type && H5I_GENPROP_CLS != dst_id_type)) + if ((H5I_GENPROP_LST != src_id_type && H5I_GENPROP_CLS != src_id_type) || + (H5I_GENPROP_LST != dst_id_type && H5I_GENPROP_CLS != dst_id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects") - if(src_id_type != dst_id_type) + if (src_id_type != dst_id_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects") - if(!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") /* Compare property lists */ - if(H5I_GENPROP_LST == src_id_type) { - if(H5P__copy_prop_plist(dst_id, src_id, name) < 0) + if (H5I_GENPROP_LST == src_id_type) { + if (H5P__copy_prop_plist(dst_id, src_id, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between lists") } /* end if */ /* Must be property classes */ else { - if(H5P__copy_prop_pclass(dst_id, src_id, name) < 0) + if (H5P__copy_prop_pclass(dst_id, src_id, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between classes") } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pcopy_prop() */ +} /* H5Pcopy_prop() */ - /*-------------------------------------------------------------------------- NAME H5Punregister @@ -1462,27 +1434,26 @@ H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name) herr_t H5Punregister(hid_t pclass_id, const char *name) { - H5P_genclass_t *pclass; /* Property list class to modify */ - herr_t ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", pclass_id, name); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Remove the property list from class */ - if((ret_value = H5P__unregister(pclass, name)) < 0) + if ((ret_value = H5P__unregister(pclass, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to remove property from class"); done: FUNC_LEAVE_API(ret_value) -} /* H5Punregister() */ +} /* H5Punregister() */ - /*-------------------------------------------------------------------------- NAME H5Pclose @@ -1507,27 +1478,26 @@ H5Punregister(hid_t pclass_id, const char *name) herr_t H5Pclose(hid_t plist_id) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Allow default property lists to pass through without throwing an error */ - if(H5P_DEFAULT != plist_id) { + if (H5P_DEFAULT != plist_id) { /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id)) + if (H5I_GENPROP_LST != H5I_get_type(plist_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Close the property list */ - if(H5I_dec_app_ref(plist_id) < 0) + if (H5I_dec_app_ref(plist_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pclose() */ +} /* H5Pclose() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class_name @@ -1551,25 +1521,24 @@ H5Pclose(hid_t plist_id) char * H5Pget_class_name(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - char *ret_value; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + char * ret_value; /* return value */ FUNC_ENTER_API(NULL) H5TRACE1("*s", "i", pclass_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class name */ - if((ret_value = H5P_get_class_name(pclass)) == NULL) + if ((ret_value = H5P_get_class_name(pclass)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query name of class"); done: FUNC_LEAVE_API(ret_value) -} /* H5Pget_class_name() */ +} /* H5Pget_class_name() */ - /*-------------------------------------------------------------------------- NAME H5Pget_class_parent @@ -1592,37 +1561,36 @@ H5Pget_class_name(hid_t pclass_id) hid_t H5Pget_class_parent(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - H5P_genclass_t *parent = NULL; /* Parent's property class */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *pclass; /* Property class to query */ + H5P_genclass_t *parent = NULL; /* Parent's property class */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", pclass_id); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property class") /* Retrieve the property class's parent */ - if(NULL == (parent = H5P__get_class_parent(pclass))) + if (NULL == (parent = H5P__get_class_parent(pclass))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list") /* Increment the outstanding references to the class object */ - if(H5P__access_class(parent, H5P_MOD_INC_REF) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID,"Can't increment class ID ref count") + if (H5P__access_class(parent, H5P_MOD_INC_REF) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count") /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, parent, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, parent, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class") done: - if(H5I_INVALID_HID == ret_value && parent) + if (H5I_INVALID_HID == ret_value && parent) H5P__close_class(parent); FUNC_LEAVE_API(ret_value) -} /* H5Pget_class_parent() */ +} /* H5Pget_class_parent() */ - /*-------------------------------------------------------------------------- NAME H5Pclose_class @@ -1644,20 +1612,19 @@ H5Pget_class_parent(hid_t pclass_id) herr_t H5Pclose_class(hid_t cls_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", cls_id); /* Check arguments */ - if(H5I_GENPROP_CLS != H5I_get_type(cls_id)) + if (H5I_GENPROP_CLS != H5I_get_type(cls_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Close the property list class */ - if(H5I_dec_app_ref(cls_id) < 0) + if (H5I_dec_app_ref(cls_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") done: FUNC_LEAVE_API(ret_value) -} /* H5Pclose_class() */ - +} /* H5Pclose_class() */ diff --git a/src/H5PB.c b/src/H5PB.c index 907fe820c22..efaf1f9806b 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,85 +24,87 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#include "H5PBmodule.h" /* This source code file is part of the H5PB module */ - +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#include "H5PBmodule.h" /* This source code file is part of the H5PB module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PBpkg.h" /* File access */ -#include "H5SLprivate.h" /* Skip List */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PBpkg.h" /* File access */ +#include "H5SLprivate.h" /* Skip List */ /****************/ /* Local Macros */ /****************/ -#define H5PB__PREPEND(page_ptr, head_ptr, tail_ptr, len) { \ - if((head_ptr) == NULL) { \ - (head_ptr) = (page_ptr); \ - (tail_ptr) = (page_ptr); \ - } /* end if */ \ - else { \ - (head_ptr)->prev = (page_ptr); \ - (page_ptr)->next = (head_ptr); \ - (head_ptr) = (page_ptr); \ - } /* end else */ \ - (len)++; \ -} /* H5PB__PREPEND() */ - -#define H5PB__REMOVE(page_ptr, head_ptr, tail_ptr, len) { \ - if((head_ptr) == (page_ptr)) { \ - (head_ptr) = (page_ptr)->next; \ - if((head_ptr) != NULL) \ - (head_ptr)->prev = NULL; \ - } /* end if */ \ - else \ - (page_ptr)->prev->next = (page_ptr)->next; \ - if((tail_ptr) == (page_ptr)) { \ - (tail_ptr) = (page_ptr)->prev; \ - if((tail_ptr) != NULL) \ - (tail_ptr)->next = NULL; \ - } /* end if */ \ - else \ - (page_ptr)->next->prev = (page_ptr)->prev; \ - page_ptr->next = NULL; \ - page_ptr->prev = NULL; \ - (len)--; \ -} - -#define H5PB__INSERT_LRU(page_buf, page_ptr) { \ - HDassert(page_buf); \ - HDassert(page_ptr); \ - /* insert the entry at the head of the list. */ \ - H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, \ - (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ -} - -#define H5PB__REMOVE_LRU(page_buf, page_ptr) { \ - HDassert(page_buf); \ - HDassert(page_ptr); \ - /* remove the entry from the list. */ \ - H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, \ - (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ -} - -#define H5PB__MOVE_TO_TOP_LRU(page_buf, page_ptr) { \ - HDassert(page_buf); \ - HDassert(page_ptr); \ - /* Remove entry and insert at the head of the list. */ \ - H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, \ - (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ - H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, \ - (page_buf)->LRU_tail_ptr, (page_buf)->LRU_list_len) \ -} - +#define H5PB__PREPEND(page_ptr, head_ptr, tail_ptr, len) \ + { \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (page_ptr); \ + (tail_ptr) = (page_ptr); \ + } /* end if */ \ + else { \ + (head_ptr)->prev = (page_ptr); \ + (page_ptr)->next = (head_ptr); \ + (head_ptr) = (page_ptr); \ + } /* end else */ \ + (len)++; \ + } /* H5PB__PREPEND() */ + +#define H5PB__REMOVE(page_ptr, head_ptr, tail_ptr, len) \ + { \ + if ((head_ptr) == (page_ptr)) { \ + (head_ptr) = (page_ptr)->next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->prev = NULL; \ + } /* end if */ \ + else \ + (page_ptr)->prev->next = (page_ptr)->next; \ + if ((tail_ptr) == (page_ptr)) { \ + (tail_ptr) = (page_ptr)->prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->next = NULL; \ + } /* end if */ \ + else \ + (page_ptr)->next->prev = (page_ptr)->prev; \ + page_ptr->next = NULL; \ + page_ptr->prev = NULL; \ + (len)--; \ + } + +#define H5PB__INSERT_LRU(page_buf, page_ptr) \ + { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* insert the entry at the head of the list. */ \ + H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, (page_buf)->LRU_tail_ptr, \ + (page_buf)->LRU_list_len) \ + } + +#define H5PB__REMOVE_LRU(page_buf, page_ptr) \ + { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* remove the entry from the list. */ \ + H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, (page_buf)->LRU_tail_ptr, \ + (page_buf)->LRU_list_len) \ + } + +#define H5PB__MOVE_TO_TOP_LRU(page_buf, page_ptr) \ + { \ + HDassert(page_buf); \ + HDassert(page_ptr); \ + /* Remove entry and insert at the head of the list. */ \ + H5PB__REMOVE((page_ptr), (page_buf)->LRU_head_ptr, (page_buf)->LRU_tail_ptr, \ + (page_buf)->LRU_list_len) \ + H5PB__PREPEND((page_ptr), (page_buf)->LRU_head_ptr, (page_buf)->LRU_tail_ptr, \ + (page_buf)->LRU_list_len) \ + } /******************/ /* Local Typedefs */ @@ -114,12 +116,10 @@ typedef struct { hbool_t actual_slist; } H5PB_ud1_t; - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -127,7 +127,6 @@ static herr_t H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry); static htri_t H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type); static herr_t H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry); - /*********************/ /* Package Variables */ /*********************/ @@ -135,12 +134,10 @@ static herr_t H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -150,8 +147,6 @@ H5FL_DEFINE_STATIC(H5PB_t); /* Declare a free list to manage the H5PB_entry_t struct */ H5FL_DEFINE_STATIC(H5PB_entry_t); - - /*------------------------------------------------------------------------- * Function: H5PB_reset_stats * @@ -174,21 +169,20 @@ H5PB_reset_stats(H5PB_t *page_buf) /* Sanity checks */ HDassert(page_buf); - page_buf->accesses[0] = 0; - page_buf->accesses[1] = 0; - page_buf->hits[0] = 0; - page_buf->hits[1] = 0; - page_buf->misses[0] = 0; - page_buf->misses[1] = 0; + page_buf->accesses[0] = 0; + page_buf->accesses[1] = 0; + page_buf->hits[0] = 0; + page_buf->hits[1] = 0; + page_buf->misses[0] = 0; + page_buf->misses[1] = 0; page_buf->evictions[0] = 0; page_buf->evictions[1] = 0; - page_buf->bypasses[0] = 0; - page_buf->bypasses[1] = 0; + page_buf->bypasses[0] = 0; + page_buf->bypasses[1] = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5PB_reset_stats() */ +} /* H5PB_reset_stats() */ - /*------------------------------------------------------------------------- * Function: H5PB_get_stats * @@ -209,29 +203,28 @@ H5PB_reset_stats(H5PB_t *page_buf) *------------------------------------------------------------------------- */ herr_t -H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], - unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) +H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], unsigned misses[2], + unsigned evictions[2], unsigned bypasses[2]) { FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(page_buf); - accesses[0] = page_buf->accesses[0]; - accesses[1] = page_buf->accesses[1]; - hits[0] = page_buf->hits[0]; - hits[1] = page_buf->hits[1]; - misses[0] = page_buf->misses[0]; - misses[1] = page_buf->misses[1]; + accesses[0] = page_buf->accesses[0]; + accesses[1] = page_buf->accesses[1]; + hits[0] = page_buf->hits[0]; + hits[1] = page_buf->hits[1]; + misses[0] = page_buf->misses[0]; + misses[1] = page_buf->misses[1]; evictions[0] = page_buf->evictions[0]; evictions[1] = page_buf->evictions[1]; - bypasses[0] = page_buf->bypasses[0]; - bypasses[1] = page_buf->bypasses[1]; + bypasses[0] = page_buf->bypasses[0]; + bypasses[1] = page_buf->bypasses[1]; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5PB_get_stats */ +} /* H5PB_get_stats */ - /*------------------------------------------------------------------------- * Function: H5PB_print_stats() * @@ -261,7 +254,8 @@ H5PB_print_stats(const H5PB_t *page_buf) HDprintf("\t Misses: %u\n", page_buf->misses[0]); HDprintf("\t Evictions: %u\n", page_buf->evictions[0]); HDprintf("\t Bypasses: %u\n", page_buf->bypasses[0]); - HDprintf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[0]/(page_buf->accesses[0] - page_buf->bypasses[0]))*100); + HDprintf("\t Hit Rate = %f%%\n", + ((double)page_buf->hits[0] / (page_buf->accesses[0] - page_buf->bypasses[0])) * 100); HDprintf("*****************\n\n"); HDprintf("******* RAWDATA\n"); @@ -270,13 +264,13 @@ H5PB_print_stats(const H5PB_t *page_buf) HDprintf("\t Misses: %u\n", page_buf->misses[1]); HDprintf("\t Evictions: %u\n", page_buf->evictions[1]); HDprintf("\t Bypasses: %u\n", page_buf->bypasses[1]); - HDprintf("\t Hit Rate = %f%%\n", ((double)page_buf->hits[1]/(page_buf->accesses[1]-page_buf->bypasses[0]))*100); + HDprintf("\t Hit Rate = %f%%\n", + ((double)page_buf->hits[1] / (page_buf->accesses[1] - page_buf->bypasses[0])) * 100); HDprintf("*****************\n\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5PB_print_stats */ - /*------------------------------------------------------------------------- * Function: H5PB_create * @@ -291,8 +285,8 @@ H5PB_print_stats(const H5PB_t *page_buf) herr_t H5PB_create(H5F_shared_t *f_sh, size_t size, unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc) { - H5PB_t *page_buf = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_t *page_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -300,60 +294,59 @@ H5PB_create(H5F_shared_t *f_sh, size_t size, unsigned page_buf_min_meta_perc, un HDassert(f_sh); /* Check args */ - if(f_sh->fs_strategy != H5F_FSPACE_STRATEGY_PAGE) + if (f_sh->fs_strategy != H5F_FSPACE_STRATEGY_PAGE) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "Enabling Page Buffering requires PAGE file space strategy") /* round down the size if it is larger than the page size */ - else if(size > f_sh->fs_page_size) { + else if (size > f_sh->fs_page_size) { hsize_t temp_size; temp_size = (size / f_sh->fs_page_size) * f_sh->fs_page_size; H5_CHECKED_ASSIGN(size, size_t, temp_size, hsize_t); } /* end if */ - else if(0 != size % f_sh->fs_page_size) + else if (0 != size % f_sh->fs_page_size) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, "Page Buffer size must be >= to the page size") /* Allocate the new page buffering structure */ - if(NULL == (page_buf = H5FL_CALLOC(H5PB_t))) + if (NULL == (page_buf = H5FL_CALLOC(H5PB_t))) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") page_buf->max_size = size; H5_CHECKED_ASSIGN(page_buf->page_size, size_t, f_sh->fs_page_size, hsize_t); page_buf->min_meta_perc = page_buf_min_meta_perc; - page_buf->min_raw_perc = page_buf_min_raw_perc; + page_buf->min_raw_perc = page_buf_min_raw_perc; /* Calculate the minimum page count for metadata and raw data * based on the fractions provided */ page_buf->min_meta_count = (unsigned)((size * page_buf_min_meta_perc) / (f_sh->fs_page_size * 100)); - page_buf->min_raw_count = (unsigned)((size * page_buf_min_raw_perc) / (f_sh->fs_page_size * 100)); + page_buf->min_raw_count = (unsigned)((size * page_buf_min_raw_perc) / (f_sh->fs_page_size * 100)); - if(NULL == (page_buf->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (page_buf->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCREATE, FAIL, "can't create skip list") - if(NULL == (page_buf->mf_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) + if (NULL == (page_buf->mf_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCREATE, FAIL, "can't create skip list") - if(NULL == (page_buf->page_fac = H5FL_fac_init(page_buf->page_size))) + if (NULL == (page_buf->page_fac = H5FL_fac_init(page_buf->page_size))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINIT, FAIL, "can't create page factory") f_sh->page_buf = page_buf; done: - if(ret_value < 0) { - if(page_buf != NULL) { - if(page_buf->slist_ptr != NULL) + if (ret_value < 0) { + if (page_buf != NULL) { + if (page_buf->slist_ptr != NULL) H5SL_close(page_buf->slist_ptr); - if(page_buf->mf_slist_ptr != NULL) + if (page_buf->mf_slist_ptr != NULL) H5SL_close(page_buf->mf_slist_ptr); - if(page_buf->page_fac != NULL) + if (page_buf->page_fac != NULL) H5FL_fac_term(page_buf->page_fac); page_buf = H5FL_FREE(H5PB_t, page_buf); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_create */ - /*------------------------------------------------------------------------- * Function: H5PB__flush_cb * @@ -368,9 +361,9 @@ H5PB_create(H5F_shared_t *f_sh, size_t size, unsigned page_buf_min_meta_perc, un static herr_t H5PB__flush_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 */ - H5F_shared_t *f_sh = (H5F_shared_t *)_op_data; - herr_t ret_value = SUCCEED; /* Return value */ + H5PB_entry_t *page_entry = (H5PB_entry_t *)item; /* Pointer to page entry node */ + H5F_shared_t *f_sh = (H5F_shared_t *)_op_data; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -379,15 +372,14 @@ H5PB__flush_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) HDassert(f_sh); /* Flush the page if it's dirty */ - if(page_entry->is_dirty) - if(H5PB__write_entry(f_sh, page_entry) < 0) + if (page_entry->is_dirty) + if (H5PB__write_entry(f_sh, page_entry) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5PB__flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5PB_flush * @@ -402,7 +394,7 @@ H5PB__flush_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) herr_t H5PB_flush(H5F_shared_t *f_sh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -410,11 +402,11 @@ H5PB_flush(H5F_shared_t *f_sh) HDassert(f_sh); /* Flush all the entries in the PB skiplist, if we have write access on the file */ - if(f_sh->page_buf && (H5F_ACC_RDWR & H5F_SHARED_INTENT(f_sh))) { + if (f_sh->page_buf && (H5F_ACC_RDWR & H5F_SHARED_INTENT(f_sh))) { H5PB_t *page_buf = f_sh->page_buf; /* Iterate over all entries in page buffer skip list */ - if(H5SL_iterate(page_buf->slist_ptr, H5PB__flush_cb, f_sh)) + if (H5SL_iterate(page_buf->slist_ptr, H5PB__flush_cb, f_sh)) HGOTO_ERROR(H5E_PAGEBUF, H5E_BADITER, FAIL, "can't flush page buffer skip list") } /* end if */ @@ -422,7 +414,6 @@ H5PB_flush(H5F_shared_t *f_sh) FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_flush */ - /*------------------------------------------------------------------------- * Function: H5PB__dest_cb * @@ -437,8 +428,8 @@ H5PB_flush(H5F_shared_t *f_sh) 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_entry_t *page_entry = (H5PB_entry_t *)item; /* Pointer to page entry node */ + H5PB_ud1_t * op_data = (H5PB_ud1_t *)_op_data; FUNC_ENTER_STATIC_NOERR @@ -448,7 +439,7 @@ H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) HDassert(op_data->page_buf); /* Remove entry from LRU list */ - if(op_data->actual_slist) { + if (op_data->actual_slist) { H5PB__REMOVE_LRU(op_data->page_buf, page_entry) page_entry->page_buf_ptr = H5FL_FAC_FREE(op_data->page_buf->page_fac, page_entry->page_buf_ptr); } /* end if */ @@ -459,7 +450,6 @@ H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5PB__dest_cb() */ - /*------------------------------------------------------------------------- * Function: H5PB_dest * @@ -474,7 +464,7 @@ H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) herr_t H5PB_dest(H5F_shared_t *f_sh) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -482,11 +472,11 @@ H5PB_dest(H5F_shared_t *f_sh) HDassert(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_ud1_t op_data; /* Iteration context */ + if (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) + if (H5PB_flush(f_sh) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTFLUSH, FAIL, "can't flush page buffer") /* Set up context info */ @@ -494,16 +484,16 @@ H5PB_dest(H5F_shared_t *f_sh) /* Destroy the skip list containing all the entries in the PB */ op_data.actual_slist = TRUE; - if(H5SL_destroy(page_buf->slist_ptr, H5PB__dest_cb, &op_data)) + if (H5SL_destroy(page_buf->slist_ptr, H5PB__dest_cb, &op_data)) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCLOSEOBJ, FAIL, "can't destroy page buffer skip list") /* Destroy the skip list containing the new entries */ op_data.actual_slist = FALSE; - if(H5SL_destroy(page_buf->mf_slist_ptr, H5PB__dest_cb, &op_data)) + if (H5SL_destroy(page_buf->mf_slist_ptr, H5PB__dest_cb, &op_data)) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTCLOSEOBJ, FAIL, "can't destroy page buffer skip list") /* Destroy the page factory */ - if(H5FL_fac_term(page_buf->page_fac) < 0) + if (H5FL_fac_term(page_buf->page_fac) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTRELEASE, FAIL, "can't destroy page buffer page factory") f_sh->page_buf = H5FL_FREE(H5PB_t, page_buf); @@ -513,7 +503,6 @@ H5PB_dest(H5F_shared_t *f_sh) FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_dest */ - /*------------------------------------------------------------------------- * Function: H5PB_add_new_page * @@ -531,9 +520,9 @@ 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -550,30 +539,29 @@ H5PB_add_new_page(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t page_addr) * the page when it is freed from this list if it still exists and * remove this check */ - if(NULL == H5SL_search(page_buf->mf_slist_ptr, &(page_addr))) { + if (NULL == H5SL_search(page_buf->mf_slist_ptr, &(page_addr))) { /* Create the new PB entry */ - if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + if (NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize page fields */ - page_entry->addr = page_addr; - page_entry->type = (H5F_mem_page_t)type; + page_entry->addr = page_addr; + page_entry->type = (H5F_mem_page_t)type; page_entry->is_dirty = FALSE; /* Insert entry in skip list */ - if(H5SL_insert(page_buf->mf_slist_ptr, page_entry, &(page_entry->addr)) < 0) + if (H5SL_insert(page_buf->mf_slist_ptr, page_entry, &(page_entry->addr)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "Can't insert entry in skip list") } /* end if */ done: - if(ret_value < 0) - if(page_entry) + if (ret_value < 0) + if (page_entry) page_entry = H5FL_FREE(H5PB_entry_t, page_entry); FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_add_new_page */ - /*------------------------------------------------------------------------- * Function: H5PB_update_entry * @@ -591,8 +579,8 @@ H5PB_add_new_page(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t page_addr) herr_t H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) { - H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ - haddr_t page_addr; + H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ + haddr_t page_addr; FUNC_ENTER_NOAPI_NOERR @@ -606,7 +594,7 @@ H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) /* search for the page and update if found */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&page_addr)); - if(page_entry) { + if (page_entry) { haddr_t offset; HDassert(addr + size <= page_addr + page_buf->page_size); @@ -620,7 +608,6 @@ H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5PB_update_entry */ - /*------------------------------------------------------------------------- * Function: H5PB_remove_entry * @@ -639,9 +626,9 @@ 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -654,9 +641,9 @@ H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr) page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&addr)); /* If found, remove the entry from the PB cache */ - if(page_entry) { + if (page_entry) { HDassert(page_entry->type != H5F_MEM_PAGE_DRAW); - if(NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) + if (NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Page Entry is not in skip list") /* Remove from LRU list */ @@ -666,14 +653,13 @@ H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr) page_buf->meta_count--; page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); - page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5PB_remove_entry */ - /*------------------------------------------------------------------------- * Function: H5PB_read * @@ -687,19 +673,19 @@ 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_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_entry_t *page_entry; /* Pointer to the corresponding page entry */ - 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 */ - hsize_t num_touched_pages; /* Number of pages accessed */ - size_t access_size; - hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ - hsize_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + hsize_t num_touched_pages; /* Number of pages accessed */ + size_t access_size = 0; + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hsize_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -711,16 +697,16 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * page_buf = f_sh->page_buf; #ifdef H5_HAVE_PARALLEL - if(H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) { + if (H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) { #if 1 bypass_pb = TRUE; #else /* MSC - why this stopped working ? */ int mpi_size; - if((mpi_size = H5F_shared_mpi_get_size(f_sh)) < 0) + if ((mpi_size = H5F_shared_mpi_get_size(f_sh)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") - if(1 != mpi_size) + if (1 != mpi_size) bypass_pb = TRUE; #endif } /* end if */ @@ -730,30 +716,29 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * * single page, or if this is a parallel raw data access, bypass page * buffering. */ - if(NULL == page_buf || size >= page_buf->page_size || - (bypass_pb && H5FD_MEM_DRAW == type)) { - if(H5F__accum_read(f_sh, type, addr, size, buf) < 0) + if (NULL == page_buf || size >= page_buf->page_size || (bypass_pb && H5FD_MEM_DRAW == type)) { + if (H5F__accum_read(f_sh, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "read through metadata accumulator failed") /* Update statistics */ - if(page_buf) { - if(type == H5FD_MEM_DRAW) - page_buf->bypasses[1] ++; + if (page_buf) { + if (type == H5FD_MEM_DRAW) + page_buf->bypasses[1]++; else - page_buf->bypasses[0] ++; + page_buf->bypasses[0]++; } /* end if */ /* If page buffering is disabled, or if this is a large metadata access, * or if this is parallel raw data access, we are done here */ - if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || - (bypass_pb && H5FD_MEM_DRAW == type)) + if (NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || + (bypass_pb && H5FD_MEM_DRAW == type)) HGOTO_DONE(SUCCEED) } /* end if */ /* Update statistics */ - if(page_buf) { - if(type == H5FD_MEM_DRAW) + if (page_buf) { + if (type == H5FD_MEM_DRAW) page_buf->accesses[1]++; else page_buf->accesses[0]++; @@ -765,21 +750,21 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * /* For Raw data calculate the aligned address of the last page and * the number of pages accessed if more than 1 page is accessed */ - if(H5FD_MEM_DRAW == type) { + if (H5FD_MEM_DRAW == type) { last_page_addr = ((addr + size - 1) / page_buf->page_size) * page_buf->page_size; /* How many pages does this write span */ - num_touched_pages = (last_page_addr / page_buf->page_size + 1) - - (first_page_addr / page_buf->page_size); - if(first_page_addr == last_page_addr) { + num_touched_pages = + (last_page_addr / page_buf->page_size + 1) - (first_page_addr / page_buf->page_size); + if (first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); last_page_addr = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ /* Otherwise set last page addr to HADDR_UNDEF */ else { num_touched_pages = 1; - last_page_addr = HADDR_UNDEF; + last_page_addr = HADDR_UNDEF; } /* end else */ /* Translate to file driver I/O info object */ @@ -787,7 +772,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * /* Copy raw data from dirty pages into the read buffer if the read request spans pages in the page buffer*/ - if(H5FD_MEM_DRAW == type && size >= page_buf->page_size) { + if (H5FD_MEM_DRAW == type && size >= page_buf->page_size) { H5SL_node_t *node; /* For each touched page in the page buffer, check if it @@ -796,180 +781,185 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * * to date data into the buffer after the big read from the file. */ node = H5SL_find(page_buf->slist_ptr, (void *)(&first_page_addr)); - for(i = 0; i < num_touched_pages; i++) { - search_addr = i*page_buf->page_size + first_page_addr; + for (i = 0; i < num_touched_pages; i++) { + search_addr = i * page_buf->page_size + first_page_addr; /* if we still haven't located a starting page, search again */ - if(!node && i!=0) + if (!node && i != 0) node = H5SL_find(page_buf->slist_ptr, (void *)(&search_addr)); /* if the current page is in the Page Buffer, do the updates */ - if(node) { + if (node) { page_entry = (H5PB_entry_t *)H5SL_item(node); HDassert(page_entry); /* If the current page address falls out of the access block, then there are no more pages to go over */ - if(page_entry->addr >= addr + size) + if (page_entry->addr >= addr + size) break; HDassert(page_entry->addr == search_addr); - if(page_entry->is_dirty) { + if (page_entry->is_dirty) { /* special handling for the first page if it is not a full page access */ - if(i == 0 && first_page_addr != addr) { + if (i == 0 && first_page_addr != addr) { offset = addr - first_page_addr; HDassert(page_buf->page_size > offset); H5MM_memcpy(buf, (uint8_t *)page_entry->page_buf_ptr + offset, - page_buf->page_size - (size_t)offset); + page_buf->page_size - (size_t)offset); /* move to top of LRU list */ H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) } /* end if */ /* special handling for the last page if it is not a full page access */ - else if(num_touched_pages > 1 && i == num_touched_pages-1 && search_addr < addr+size) { - offset = (num_touched_pages-2)*page_buf->page_size + - (page_buf->page_size - (addr - first_page_addr)); + else if (num_touched_pages > 1 && i == num_touched_pages - 1 && + search_addr < addr + size) { + offset = (num_touched_pages - 2) * page_buf->page_size + + (page_buf->page_size - (addr - first_page_addr)); H5MM_memcpy((uint8_t *)buf + offset, page_entry->page_buf_ptr, - (size_t)((addr + size) - last_page_addr)); + (size_t)((addr + size) - last_page_addr)); /* move to top of LRU list */ H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) } /* end else-if */ /* copy the entire fully accessed pages */ else { - offset = i*page_buf->page_size; + offset = i * page_buf->page_size; - H5MM_memcpy((uint8_t *)buf+(i*page_buf->page_size) , page_entry->page_buf_ptr, - page_buf->page_size); + H5MM_memcpy((uint8_t *)buf + (i * page_buf->page_size), page_entry->page_buf_ptr, + page_buf->page_size); } /* end else */ - } /* end if */ + } /* end if */ node = H5SL_next(node); } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* A raw data access could span 1 or 2 PB entries at this point so we need to handle that */ HDassert(1 == num_touched_pages || 2 == num_touched_pages); - for(i = 0 ; i < num_touched_pages; i++) { + for (i = 0; i < num_touched_pages; i++) { haddr_t buf_offset; /* Calculate the aligned address of the page to search for it in the skip list */ - search_addr = (0==i ? first_page_addr : last_page_addr); + search_addr = (0 == i ? first_page_addr : last_page_addr); /* Calculate the access size if the access spans more than 1 page */ - if(1 == num_touched_pages) + if (1 == num_touched_pages) access_size = size; else - access_size = (0 == i ? (size_t)((first_page_addr + page_buf->page_size) - addr) : (size - access_size)); + access_size = (0 == i ? (size_t)((first_page_addr + page_buf->page_size) - addr) + : (size - access_size)); /* Lookup the page in the skip list */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); /* if found */ - if(page_entry) { - offset = (0 == i ? addr - page_entry->addr : 0); + if (page_entry) { + offset = (0 == i ? addr - page_entry->addr : 0); buf_offset = (0 == i ? 0 : size - access_size); /* copy the requested data from the page into the input buffer */ - H5MM_memcpy((uint8_t *)buf + buf_offset, (uint8_t *)page_entry->page_buf_ptr + offset, access_size); + H5MM_memcpy((uint8_t *)buf + buf_offset, (uint8_t *)page_entry->page_buf_ptr + offset, + access_size); /* Update LRU */ H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) /* Update statistics */ - if(type == H5FD_MEM_DRAW) + if (type == H5FD_MEM_DRAW) page_buf->hits[1]++; else page_buf->hits[0]++; } /* end if */ /* if not found */ else { - void *new_page_buf = NULL; - size_t page_size = page_buf->page_size; + void * new_page_buf = NULL; + size_t page_size = page_buf->page_size; haddr_t eoa; /* make space for new entry */ - if((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { + if ((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { htri_t can_make_space; /* check if we can make space in page buffer */ - if((can_make_space = H5PB__make_space(f_sh, page_buf, type)) < 0) + if ((can_make_space = H5PB__make_space(f_sh, page_buf, type)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "make space in Page buffer Failed") /* if make_space returns 0, then we can't use the page buffer for this I/O and we need to bypass */ - if(0 == can_make_space) { - /* make space can't return FALSE on second touched page since the first is of the same type */ + if (0 == can_make_space) { + /* make space can't return FALSE on second touched page since the first is of the same + * type */ HDassert(0 == i); /* read entire block from VFD and return */ - if(H5FD_read(file, type, addr, size, buf) < 0) + if (H5FD_read(file, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") /* Break out of loop */ break; } /* end if */ - } /* end if */ + } /* end if */ /* Read page from VFD */ - if(NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + if (NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, + "memory allocation failed for page buffer entry") /* Read page through the VFD layer, but make sure we don't read past the EOA. */ /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, type))) + if (HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, type))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* If the entire page falls outside the EOA, then fail */ - if(search_addr > eoa) - HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "reading an entire page that is outside the file EOA") + if (search_addr > eoa) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, + "reading an entire page that is outside the file EOA") /* Adjust the read size to not go beyond the EOA */ - if(search_addr + page_size > eoa) + if (search_addr + page_size > eoa) page_size = (size_t)(eoa - search_addr); /* Read page from VFD */ - if(H5FD_read(file, type, search_addr, page_size, new_page_buf) < 0) + if (H5FD_read(file, type, search_addr, page_size, new_page_buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") /* Copy the requested data from the page into the input buffer */ - offset = (0 == i ? addr - search_addr : 0); + offset = (0 == i ? addr - search_addr : 0); buf_offset = (0 == i ? 0 : size - access_size); H5MM_memcpy((uint8_t *)buf + buf_offset, (uint8_t *)new_page_buf + offset, access_size); /* Create the new PB entry */ - if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + if (NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") page_entry->page_buf_ptr = new_page_buf; - page_entry->addr = search_addr; - page_entry->type = (H5F_mem_page_t)type; - page_entry->is_dirty = FALSE; + page_entry->addr = search_addr; + page_entry->type = (H5F_mem_page_t)type; + page_entry->is_dirty = FALSE; /* Insert page into PB */ - if(H5PB__insert_entry(page_buf, page_entry) < 0) + if (H5PB__insert_entry(page_buf, page_entry) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTSET, FAIL, "error inserting new page in page buffer") /* Update statistics */ - if(type == H5FD_MEM_DRAW) + if (type == H5FD_MEM_DRAW) page_buf->misses[1]++; else page_buf->misses[0]++; } /* end else */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB_read() */ - /*------------------------------------------------------------------------- * Function: H5PB_write * @@ -984,20 +974,19 @@ 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_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_entry_t *page_entry; /* Pointer to the corresponding page entry */ - 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 */ - hsize_t num_touched_pages; /* Number of pages accessed */ - size_t access_size; - hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ - hsize_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + hsize_t num_touched_pages; /* Number of pages accessed */ + size_t access_size = 0; + hbool_t bypass_pb = FALSE; /* Whether to bypass page buffering */ + hsize_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1008,16 +997,16 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, page_buf = f_sh->page_buf; #ifdef H5_HAVE_PARALLEL - if(H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) { + if (H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) { #if 1 bypass_pb = TRUE; #else /* MSC - why this stopped working ? */ int mpi_size; - if((mpi_size = H5F_shared_mpi_get_size(f_sh)) < 0) + if ((mpi_size = H5F_shared_mpi_get_size(f_sh)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "can't retrieve MPI communicator size") - if(1 != mpi_size) + if (1 != mpi_size) bypass_pb = TRUE; #endif } /* end if */ @@ -1027,13 +1016,13 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, * single page, or if this is a parallel raw data access, bypass page * buffering. */ - if(NULL == page_buf || size >= page_buf->page_size || bypass_pb) { - if(H5F__accum_write(f_sh, type, addr, size, buf) < 0) + if (NULL == page_buf || size >= page_buf->page_size || bypass_pb) { + if (H5F__accum_write(f_sh, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "write through metadata accumulator failed") /* Update statistics */ - if(page_buf) { - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + if (page_buf) { + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) page_buf->bypasses[1]++; else page_buf->bypasses[0]++; @@ -1042,13 +1031,13 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, /* If page buffering is disabled, or if this is a large metadata access, * or if this is a parallel raw data access, we are done here */ - if(NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || - (bypass_pb && H5FD_MEM_DRAW == type)) + if (NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || + (bypass_pb && H5FD_MEM_DRAW == type)) HGOTO_DONE(SUCCEED) #ifdef H5_HAVE_PARALLEL - if(bypass_pb) { - if(H5PB_update_entry(page_buf, addr, size, buf) > 0) + if (bypass_pb) { + if (H5PB_update_entry(page_buf, addr, size, buf) > 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTUPDATE, FAIL, "failed to update PB with metadata cache") HGOTO_DONE(SUCCEED) } /* end if */ @@ -1056,8 +1045,8 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, } /* end if */ /* Update statistics */ - if(page_buf) { - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + if (page_buf) { + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) page_buf->accesses[1]++; else page_buf->accesses[0]++; @@ -1069,177 +1058,182 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, /* For raw data calculate the aligned address of the last page and * the number of pages accessed if more than 1 page is accessed */ - if(H5FD_MEM_DRAW == type) { + if (H5FD_MEM_DRAW == type) { last_page_addr = (addr + size - 1) / page_buf->page_size * page_buf->page_size; /* how many pages does this write span */ - num_touched_pages = (last_page_addr/page_buf->page_size + 1) - - (first_page_addr / page_buf->page_size); - if(first_page_addr == last_page_addr) { + num_touched_pages = + (last_page_addr / page_buf->page_size + 1) - (first_page_addr / page_buf->page_size); + if (first_page_addr == last_page_addr) { HDassert(1 == num_touched_pages); last_page_addr = HADDR_UNDEF; } /* end if */ - } /* end if */ + } /* end if */ /* Otherwise set last page addr to HADDR_UNDEF */ else { num_touched_pages = 1; - last_page_addr = HADDR_UNDEF; + last_page_addr = HADDR_UNDEF; } /* end else */ /* Translate to file driver I/O info object */ file = f_sh->lf; /* Check if existing pages for raw data need to be updated since raw data access is not atomic */ - if(H5FD_MEM_DRAW == type && size >= page_buf->page_size) { + if (H5FD_MEM_DRAW == type && size >= page_buf->page_size) { /* For each touched page, check if it exists in the page buffer, and * update it with the data in the buffer to keep it up to date */ - for(i = 0; i < num_touched_pages; i++) { + for (i = 0; i < num_touched_pages; i++) { search_addr = i * page_buf->page_size + first_page_addr; /* Special handling for the first page if it is not a full page update */ - if(i == 0 && first_page_addr != addr) { + if (i == 0 && first_page_addr != addr) { /* Lookup the page in the skip list */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); - if(page_entry) { + if (page_entry) { offset = addr - first_page_addr; HDassert(page_buf->page_size > offset); /* Update page's data */ - H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, page_buf->page_size - (size_t)offset); + H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, buf, + page_buf->page_size - (size_t)offset); /* Mark page dirty and push to top of LRU */ page_entry->is_dirty = TRUE; H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) } /* end if */ - } /* end if */ + } /* end if */ /* Special handling for the last page if it is not a full page update */ - else if(num_touched_pages > 1 && i == (num_touched_pages - 1) && - (search_addr + page_buf->page_size) != (addr + size)) { - HDassert(search_addr+page_buf->page_size > addr+size); + else if (num_touched_pages > 1 && i == (num_touched_pages - 1) && + (search_addr + page_buf->page_size) != (addr + size)) { + HDassert(search_addr + page_buf->page_size > addr + size); /* Lookup the page in the skip list */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); - if(page_entry) { + if (page_entry) { offset = (num_touched_pages - 2) * page_buf->page_size + - (page_buf->page_size - (addr - first_page_addr)); + (page_buf->page_size - (addr - first_page_addr)); /* Update page's data */ H5MM_memcpy(page_entry->page_buf_ptr, (const uint8_t *)buf + offset, - (size_t)((addr + size) - last_page_addr)); + (size_t)((addr + size) - last_page_addr)); /* Mark page dirty and push to top of LRU */ page_entry->is_dirty = TRUE; H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) } /* end if */ - } /* end else-if */ + } /* end else-if */ /* Discard all fully written pages from the page buffer */ else { page_entry = (H5PB_entry_t *)H5SL_remove(page_buf->slist_ptr, (void *)(&search_addr)); - if(page_entry) { + if (page_entry) { /* Remove from LRU list */ H5PB__REMOVE_LRU(page_buf, page_entry) /* Decrement page count of appropriate type */ - if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + if (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) page_buf->raw_count--; else page_buf->meta_count--; /* Free page info */ page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); - page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); } /* end if */ - } /* end else */ - } /* end for */ - } /* end if */ + } /* end else */ + } /* end for */ + } /* end if */ else { /* An access could span 1 or 2 PBs at this point so we need to handle that */ HDassert(1 == num_touched_pages || 2 == num_touched_pages); - for(i = 0; i < num_touched_pages; i++) { + for (i = 0; i < num_touched_pages; i++) { haddr_t buf_offset; /* Calculate the aligned address of the page to search for it in the skip list */ search_addr = (0 == i ? first_page_addr : last_page_addr); /* Calculate the access size if the access spans more than 1 page */ - if(1 == num_touched_pages) + if (1 == num_touched_pages) access_size = size; else - access_size = (0 == i ? (size_t)(first_page_addr + page_buf->page_size - addr) : (size - access_size)); + access_size = + (0 == i ? (size_t)(first_page_addr + page_buf->page_size - addr) : (size - access_size)); /* Lookup the page in the skip list */ page_entry = (H5PB_entry_t *)H5SL_search(page_buf->slist_ptr, (void *)(&search_addr)); /* If found */ - if(page_entry) { - offset = (0 == i ? addr - page_entry->addr : 0); + if (page_entry) { + offset = (0 == i ? addr - page_entry->addr : 0); buf_offset = (0 == i ? 0 : size - access_size); /* Copy the requested data from the input buffer into the page */ - H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, (const uint8_t *)buf + buf_offset, access_size); + H5MM_memcpy((uint8_t *)page_entry->page_buf_ptr + offset, (const uint8_t *)buf + buf_offset, + access_size); /* Mark page dirty and push to top of LRU */ page_entry->is_dirty = TRUE; H5PB__MOVE_TO_TOP_LRU(page_buf, page_entry) /* Update statistics */ - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) page_buf->hits[1]++; else page_buf->hits[0]++; } /* 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 */ - if((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { + if ((H5SL_count(page_buf->slist_ptr) * page_buf->page_size) >= page_buf->max_size) { htri_t can_make_space; /* Check if we can make space in page buffer */ - if((can_make_space = H5PB__make_space(f_sh, page_buf, type)) < 0) + if ((can_make_space = H5PB__make_space(f_sh, page_buf, type)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "make space in Page buffer Failed") /* If make_space returns 0, then we can't use the page * buffer for this I/O and we need to bypass */ - if(0 == can_make_space) { + if (0 == can_make_space) { HDassert(0 == i); /* Write to VFD and return */ - if(H5FD_write(file, type, addr, size, buf) < 0) + if (H5FD_write(file, type, addr, size, buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "driver write request failed") /* Break out of loop */ break; } /* end if */ - } /* end if */ + } /* end if */ /* Don't bother searching if there is no write access */ - if(H5F_ACC_RDWR & H5F_SHARED_INTENT(f_sh)) + if (H5F_ACC_RDWR & H5F_SHARED_INTENT(f_sh)) /* Lookup & remove the page from the new skip list page if * it exists to see if this is a new page from the MF layer */ page_entry = (H5PB_entry_t *)H5SL_remove(page_buf->mf_slist_ptr, (void *)(&search_addr)); /* Calculate offset into the buffer of the page and the user buffer */ - offset = (0 == i ? addr - search_addr : 0); + offset = (0 == i ? addr - search_addr : 0); buf_offset = (0 == i ? 0 : size - access_size); /* If found, then just update the buffer pointer to the newly allocate buffer */ - if(page_entry) { + if (page_entry) { /* Allocate space for the page buffer */ - if(NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + if (NULL == (new_page_buf = H5FL_FAC_MALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, + "memory allocation failed for page buffer entry") HDmemset(new_page_buf, 0, (size_t)offset); - HDmemset((uint8_t *)new_page_buf + offset + access_size, 0, page_size - ((size_t)offset + access_size)); + HDmemset((uint8_t *)new_page_buf + offset + access_size, 0, + page_size - ((size_t)offset + access_size)); page_entry->page_buf_ptr = new_page_buf; /* Update statistics */ - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) page_buf->hits[1]++; else page_buf->hits[0]++; @@ -1249,67 +1243,68 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, haddr_t eoa, eof = HADDR_UNDEF; /* Allocate space for the page buffer */ - if(NULL == (new_page_buf = H5FL_FAC_CALLOC(page_buf->page_fac))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed for page buffer entry") + if (NULL == (new_page_buf = H5FL_FAC_CALLOC(page_buf->page_fac))) + HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, + "memory allocation failed for page buffer entry") /* Create the new loaded PB entry */ - if(NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) + if (NULL == (page_entry = H5FL_CALLOC(H5PB_entry_t))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTALLOC, FAIL, "memory allocation failed") page_entry->page_buf_ptr = new_page_buf; - page_entry->addr = search_addr; - page_entry->type = (H5F_mem_page_t)type; + page_entry->addr = search_addr; + page_entry->type = (H5F_mem_page_t)type; /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, type))) + if (HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, type))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* If the entire page falls outside the EOA, then fail */ - if(search_addr > eoa) - HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "writing to a page that is outside the file EOA") + if (search_addr > eoa) + HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, + "writing to a page that is outside the file EOA") /* Retrieve the 'eof' for the file - The MPI-VFD EOF * returned will most likely be HADDR_UNDEF, so skip * that check. */ - if(!H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) - if(HADDR_UNDEF == (eof = H5FD_get_eof(f_sh->lf, H5FD_MEM_DEFAULT))) + if (!H5F_SHARED_HAS_FEATURE(f_sh, H5FD_FEAT_HAS_MPI)) + if (HADDR_UNDEF == (eof = H5FD_get_eof(f_sh->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eof request failed") /* Adjust the read size to not go beyond the EOA */ - if(search_addr + page_size > eoa) + if (search_addr + page_size > eoa) page_size = (size_t)(eoa - search_addr); - if(search_addr < eof) { - if(H5FD_read(file, type, search_addr, page_size, new_page_buf) < 0) + if (search_addr < eof) { + if (H5FD_read(file, type, search_addr, page_size, new_page_buf) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_READERROR, FAIL, "driver read request failed") /* Update statistics */ - if(type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) + if (type == H5FD_MEM_DRAW || type == H5FD_MEM_GHEAP) page_buf->misses[1]++; else page_buf->misses[0]++; } /* end if */ - } /* end else */ + } /* end else */ /* Copy the requested data from the page into the input buffer */ - H5MM_memcpy((uint8_t *)new_page_buf + offset, (const uint8_t *)buf+buf_offset, access_size); + H5MM_memcpy((uint8_t *)new_page_buf + offset, (const uint8_t *)buf + buf_offset, access_size); /* Page is dirty now */ page_entry->is_dirty = TRUE; /* Insert page into PB, evicting other pages as necessary */ - if(H5PB__insert_entry(page_buf, page_entry) < 0) + if (H5PB__insert_entry(page_buf, page_entry) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTSET, FAIL, "error inserting new page in page buffer") } /* end else */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB_write() */ - /*------------------------------------------------------------------------- * Function: H5PB__insert_entry() * @@ -1335,17 +1330,17 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, static herr_t H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Insert entry in skip list */ - if(H5SL_insert(page_buf->slist_ptr, page_entry, &(page_entry->addr)) < 0) + if (H5SL_insert(page_buf->slist_ptr, page_entry, &(page_entry->addr)) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTINSERT, FAIL, "can't insert entry in skip list") HDassert(H5SL_count(page_buf->slist_ptr) * page_buf->page_size <= page_buf->max_size); /* Increment appropriate page count */ - if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + if (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) page_buf->raw_count++; else page_buf->meta_count++; @@ -1357,7 +1352,6 @@ H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB__insert_entry() */ - /*------------------------------------------------------------------------- * Function: H5PB__make_space() * @@ -1380,8 +1374,8 @@ H5PB__insert_entry(H5PB_t *page_buf, H5PB_entry_t *page_entry) static htri_t H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) { - H5PB_entry_t *page_entry; /* Pointer to page eviction candidate */ - htri_t ret_value = TRUE; /* Return value */ + H5PB_entry_t *page_entry; /* Pointer to page eviction candidate */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -1392,43 +1386,44 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) /* Get oldest entry */ page_entry = page_buf->LRU_tail_ptr; - if(H5FD_MEM_DRAW == inserted_type) { + if (H5FD_MEM_DRAW == inserted_type) { /* If threshould is 100% metadata and page buffer is full of metadata, then we can't make space for raw data */ - if(0 == page_buf->raw_count && page_buf->min_meta_count == page_buf->meta_count) { + if (0 == page_buf->raw_count && page_buf->min_meta_count == page_buf->meta_count) { HDassert(page_buf->meta_count * page_buf->page_size == page_buf->max_size); HGOTO_DONE(FALSE) } /* end if */ /* check the metadata threshold before evicting metadata items */ - while(1) { - if(page_entry->prev && H5F_MEM_PAGE_META == page_entry->type && - page_buf->min_meta_count >= page_buf->meta_count) + while (1) { + if (page_entry->prev && H5F_MEM_PAGE_META == page_entry->type && + page_buf->min_meta_count >= page_buf->meta_count) page_entry = page_entry->prev; else break; } /* end while */ - } /* end if */ + } /* end if */ else { /* If threshould is 100% raw data and page buffer is full of raw data, then we can't make space for meta data */ - if(0 == page_buf->meta_count && page_buf->min_raw_count == page_buf->raw_count) { + if (0 == page_buf->meta_count && page_buf->min_raw_count == page_buf->raw_count) { HDassert(page_buf->raw_count * page_buf->page_size == page_buf->max_size); HGOTO_DONE(FALSE) } /* end if */ /* check the raw data threshold before evicting raw data items */ - while(1) { - if(page_entry->prev && (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) && - page_buf->min_raw_count >= page_buf->raw_count) + while (1) { + if (page_entry->prev && + (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) && + page_buf->min_raw_count >= page_buf->raw_count) page_entry = page_entry->prev; else break; } /* end while */ - } /* end else */ + } /* end else */ /* Remove from page index */ - if(NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) + if (NULL == H5SL_remove(page_buf->slist_ptr, &(page_entry->addr))) HGOTO_ERROR(H5E_PAGEBUF, H5E_BADVALUE, FAIL, "Tail Page Entry is not in skip list") /* Remove entry from LRU list */ @@ -1436,31 +1431,30 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) HDassert(H5SL_count(page_buf->slist_ptr) == page_buf->LRU_list_len); /* Decrement appropriate page type counter */ - if(H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) + if (H5F_MEM_PAGE_DRAW == page_entry->type || H5F_MEM_PAGE_GHEAP == page_entry->type) page_buf->raw_count--; else page_buf->meta_count--; /* Flush page if dirty */ - if(page_entry->is_dirty) - if(H5PB__write_entry(f_sh, page_entry) < 0) + if (page_entry->is_dirty) + if (H5PB__write_entry(f_sh, page_entry) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") /* Update statistics */ - if(page_entry->type == H5F_MEM_PAGE_DRAW || H5F_MEM_PAGE_GHEAP == page_entry->type) + if (page_entry->type == H5F_MEM_PAGE_DRAW || H5F_MEM_PAGE_GHEAP == page_entry->type) page_buf->evictions[1]++; else page_buf->evictions[0]++; /* Release page */ page_entry->page_buf_ptr = H5FL_FAC_FREE(page_buf->page_fac, page_entry->page_buf_ptr); - page_entry = H5FL_FREE(H5PB_entry_t, page_entry); + page_entry = H5FL_FREE(H5PB_entry_t, page_entry); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB__make_space() */ - /*------------------------------------------------------------------------- * Function: H5PB__write_entry() * @@ -1478,8 +1472,8 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) static herr_t H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry) { - haddr_t eoa; /* Current EOA for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t eoa; /* Current EOA for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1488,24 +1482,25 @@ H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry) HDassert(page_entry); /* Retrieve the 'eoa' for the file */ - if(HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, (H5FD_mem_t)page_entry->type))) + if (HADDR_UNDEF == (eoa = H5F_shared_get_eoa(f_sh, (H5FD_mem_t)page_entry->type))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eoa request failed") /* If the starting address of the page is larger than * the EOA, then the entire page is discarded without writing. */ - if(page_entry->addr <= eoa) { - H5FD_t *file; /* File driver I/O info */ - size_t page_size = f_sh->page_buf->page_size; + if (page_entry->addr <= eoa) { + H5FD_t *file; /* File driver I/O info */ + size_t page_size = f_sh->page_buf->page_size; /* Adjust the page length if it exceeds the EOA */ - if((page_entry->addr + page_size) > eoa) + if ((page_entry->addr + page_size) > eoa) page_size = (size_t)(eoa - page_entry->addr); /* Translate to file driver I/O info object */ file = f_sh->lf; - if(H5FD_write(file, (H5FD_mem_t)page_entry->type, page_entry->addr, page_size, page_entry->page_buf_ptr) < 0) + if (H5FD_write(file, (H5FD_mem_t)page_entry->type, page_entry->addr, page_size, + page_entry->page_buf_ptr) < 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_WRITEERROR, FAIL, "file write failed") } /* end if */ @@ -1514,4 +1509,3 @@ H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PB__write_entry() */ - diff --git a/src/H5PBmodule.h b/src/H5PBmodule.h index 571d2be4eda..21294c876b0 100644 --- a/src/H5PBmodule.h +++ b/src/H5PBmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,15 +18,15 @@ * H5PB package. Including this header means that the source file * is part of the H5PB package. */ -#ifndef _H5PBmodule_H -#define _H5PBmodule_H +#ifndef H5PBmodule_H +#define H5PBmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5PB_MODULE -#define H5_MY_PKG H5PB -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO +#define H5_MY_PKG H5PB +#define H5_MY_PKG_ERR H5E_RESOURCE +#define H5_MY_PKG_INIT NO -#endif /* _H5PBmodule_H */ +#endif /* H5PBmodule_H */ diff --git a/src/H5PBpkg.h b/src/H5PBpkg.h index 6b9168b84df..2656588f32a 100644 --- a/src/H5PBpkg.h +++ b/src/H5PBpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ #error "Do not include this file outside the H5PB package!" #endif -#ifndef _H5PBpkg_H -#define _H5PBpkg_H +#ifndef H5PBpkg_H +#define H5PBpkg_H /* Get package's private header */ #include "H5PBprivate.h" @@ -27,32 +27,27 @@ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ typedef struct H5PB_entry_t { - 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 */ + 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 */ /* Fields supporting replacement policies */ - struct H5PB_entry_t *next; /* next pointer in the LRU list */ - struct H5PB_entry_t *prev; /* previous pointer in the LRU list */ + struct H5PB_entry_t *next; /* next pointer in the LRU list */ + struct H5PB_entry_t *prev; /* previous pointer in the LRU list */ } H5PB_entry_t; - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ - -#endif /* _H5PBpkg_H */ - +#endif /* H5PBpkg_H */ diff --git a/src/H5PBprivate.h b/src/H5PBprivate.h index 82d010d9c1e..e0197bfed27 100644 --- a/src/H5PBprivate.h +++ b/src/H5PBprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,8 +20,8 @@ *------------------------------------------------------------------------- */ -#ifndef _H5PBprivate_H -#define _H5PBprivate_H +#ifndef H5PBprivate_H +#define H5PBprivate_H /* Include package's public header */ #ifdef NOT_YET @@ -29,17 +29,15 @@ #endif /* NOT_YET */ /* Private headers needed by this header */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5SLprivate.h" /* Skip List */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5SLprivate.h" /* Skip List */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -49,56 +47,55 @@ struct H5PB_entry_t; /* Typedef for the main structure for the page buffer */ typedef struct H5PB_t { - size_t max_size; /* The total page buffer size */ - size_t page_size; /* Size of a single page */ - unsigned min_meta_perc; /* Minimum ratio of metadata entries required before evicting meta entries */ - unsigned min_raw_perc; /* Minimum ratio of raw data entries required before evicting raw entries */ - unsigned meta_count; /* Number of entries for metadata */ - unsigned raw_count; /* Number of entries for raw data */ - unsigned min_meta_count; /* Minimum # of entries for metadata */ - unsigned min_raw_count; /* Minimum # of entries for raw data */ + size_t max_size; /* The total page buffer size */ + size_t page_size; /* Size of a single page */ + unsigned min_meta_perc; /* Minimum ratio of metadata entries required before evicting meta entries */ + unsigned min_raw_perc; /* Minimum ratio of raw data entries required before evicting raw entries */ + unsigned meta_count; /* Number of entries for metadata */ + unsigned raw_count; /* Number of entries for raw data */ + unsigned min_meta_count; /* Minimum # of entries for metadata */ + unsigned min_raw_count; /* Minimum # of entries for raw data */ - H5SL_t *slist_ptr; /* Skip list with all the active page entries */ - H5SL_t *mf_slist_ptr; /* Skip list containing newly allocated page entries inserted from the MF layer */ + H5SL_t *slist_ptr; /* Skip list with all the active page entries */ + H5SL_t *mf_slist_ptr; /* Skip list containing newly allocated page entries inserted from the MF layer */ - size_t LRU_list_len; /* Number of entries in the LRU (identical to slist_ptr count) */ - struct H5PB_entry_t *LRU_head_ptr; /* Head pointer of the LRU */ - struct H5PB_entry_t *LRU_tail_ptr; /* Tail pointer of the LRU */ + size_t LRU_list_len; /* Number of entries in the LRU (identical to slist_ptr count) */ + struct H5PB_entry_t *LRU_head_ptr; /* Head pointer of the LRU */ + struct H5PB_entry_t *LRU_tail_ptr; /* Tail pointer of the LRU */ - H5FL_fac_head_t *page_fac; /* Factory for allocating pages */ + H5FL_fac_head_t *page_fac; /* Factory for allocating pages */ /* Statistics */ - unsigned accesses[2]; - unsigned hits[2]; - unsigned misses[2]; - unsigned evictions[2]; - unsigned bypasses[2]; + unsigned accesses[2]; + unsigned hits[2]; + unsigned misses[2]; + unsigned evictions[2]; + unsigned bypasses[2]; } H5PB_t; /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines */ -H5_DLL herr_t H5PB_create(H5F_shared_t *f_sh, size_t page_buffer_size, unsigned page_buf_min_meta_perc, unsigned page_buf_min_raw_perc); +H5_DLL herr_t H5PB_create(H5F_shared_t *f_sh, size_t page_buffer_size, unsigned page_buf_min_meta_perc, + unsigned page_buf_min_raw_perc); H5_DLL herr_t H5PB_flush(H5F_shared_t *f_sh); H5_DLL herr_t H5PB_dest(H5F_shared_t *f_sh); H5_DLL herr_t H5PB_add_new_page(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t page_addr); H5_DLL herr_t H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf); H5_DLL herr_t H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr); -H5_DLL herr_t H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/); H5_DLL herr_t H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Statistics routines */ H5_DLL herr_t H5PB_reset_stats(H5PB_t *page_buf); -H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], - unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); +H5_DLL herr_t H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], + unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); H5_DLL herr_t H5PB_print_stats(const H5PB_t *page_buf); -#endif /* !_H5PBprivate_H */ - +#endif /* H5PBprivate_H */ diff --git a/src/H5PL.c b/src/H5PL.c index a79dd2009c9..4556885c250 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,56 +14,47 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5PLpkg.h" /* Plugin */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5PLpkg.h" /* Plugin */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5PLset_loading_state * * Purpose: Control the loading of dynamic plugin types. * * The plugin_control_mask parameter is a bitfield that controls - * whether certain classes of plugins (e.g.: filters) - * will be loaded by the library. + * whether certain classes of plugins (e.g.: filters, + * VOL drivers) will be loaded by the library. * * plugin bit = 0, will prevent the use of that dynamic plugin type. * plugin bit = 1, will allow the use of that dynamic plugin type. @@ -83,25 +74,25 @@ herr_t H5PLset_loading_state(unsigned int plugin_control_mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", plugin_control_mask); /* Set the plugin control mask */ - if(H5PL__set_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__set_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "error setting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLset_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLget_loading_state * * Purpose: Get the bitmask that controls whether certain classes - * of plugins (e.g.: filters) will be loaded by the library. + * of plugins (e.g.: filters, VOL drivers) will be loaded + * by the library. * * Zero if all plugin types are disabled * Negative if all plugin types are enabled @@ -115,7 +106,7 @@ H5PLset_loading_state(unsigned int plugin_control_mask) herr_t H5PLget_loading_state(unsigned int *plugin_control_mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*Iu", plugin_control_mask); @@ -124,14 +115,13 @@ H5PLget_loading_state(unsigned int *plugin_control_mask) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plugin_control_mask parameter cannot be NULL") /* Set the plugin control mask */ - if(H5PL__get_plugin_control_mask(plugin_control_mask) < 0) + if (H5PL__get_plugin_control_mask(plugin_control_mask) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error getting plugin control mask") done: FUNC_LEAVE_API(ret_value) } /* end H5PLget_loading_state() */ - /*------------------------------------------------------------------------- * Function: H5PLappend * @@ -164,7 +154,6 @@ H5PLappend(const char *search_path) FUNC_LEAVE_API(ret_value) } /* end H5PLappend() */ - /*------------------------------------------------------------------------- * Function: H5PLprepend * @@ -197,7 +186,6 @@ H5PLprepend(const char *search_path) FUNC_LEAVE_API(ret_value) } /* end H5PLprepend() */ - /*------------------------------------------------------------------------- * Function: H5PLreplace * @@ -211,8 +199,8 @@ H5PLprepend(const char *search_path) herr_t H5PLreplace(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*sIu", search_path, idx); @@ -228,7 +216,8 @@ H5PLreplace(const char *search_path, unsigned int idx) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ if (H5PL__replace_path(search_path, idx) < 0) @@ -238,7 +227,6 @@ H5PLreplace(const char *search_path, unsigned int idx) FUNC_LEAVE_API(ret_value) } /* end H5PLreplace() */ - /*------------------------------------------------------------------------- * Function: H5PLinsert * @@ -253,8 +241,8 @@ H5PLreplace(const char *search_path, unsigned int idx) herr_t H5PLinsert(const char *search_path, unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "*sIu", search_path, idx); @@ -268,7 +256,8 @@ H5PLinsert(const char *search_path, unsigned int idx) /* Check index */ num_paths = H5PL__get_num_paths(); if ((0 != num_paths) && (idx >= num_paths)) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Insert the search path into the path table */ if (H5PL__insert_path(search_path, idx) < 0) @@ -278,7 +267,6 @@ H5PLinsert(const char *search_path, unsigned int idx) FUNC_LEAVE_API(ret_value) } /* end H5PLinsert() */ - /*------------------------------------------------------------------------- * Function: H5PLremove * @@ -295,8 +283,8 @@ H5PLinsert(const char *search_path, unsigned int idx) herr_t H5PLremove(unsigned int idx) { - unsigned num_paths; /* Current number of stored paths */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Iu", idx); @@ -306,7 +294,8 @@ H5PLremove(unsigned int idx) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Delete the search path from the path table */ if (H5PL__remove_path(idx) < 0) @@ -316,7 +305,6 @@ H5PLremove(unsigned int idx) FUNC_LEAVE_API(ret_value) } /* end H5PLremove() */ - /*------------------------------------------------------------------------- * Function: H5PLget * @@ -344,10 +332,10 @@ H5PLremove(unsigned int idx) ssize_t H5PLget(unsigned int idx, char *path_buf, size_t buf_size) { - unsigned num_paths; /* Current number of stored paths */ - const char *path = NULL; /* path from table */ - size_t path_len = 0; /* Length of path */ - ssize_t ret_value = 0; /* Return value */ + unsigned num_paths; /* Current number of stored paths */ + const char *path = NULL; /* path from table */ + size_t path_len = 0; /* Length of path */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "Iu*sz", idx, path_buf, buf_size); @@ -357,7 +345,8 @@ H5PLget(unsigned int idx, char *path_buf, size_t buf_size) if (0 == num_paths) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "path table is empty") else if (idx >= num_paths) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index path out of bounds for table - can't be more than %u", (num_paths - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index path out of bounds for table - can't be more than %u", (num_paths - 1)) /* Check if the search table is empty */ if (H5PL__get_num_paths() == 0) @@ -382,7 +371,6 @@ H5PLget(unsigned int idx, char *path_buf, size_t buf_size) FUNC_LEAVE_API(ret_value) } /* end H5PLget() */ - /*------------------------------------------------------------------------- * Function: H5PLsize * @@ -411,4 +399,3 @@ H5PLsize(unsigned int *num_paths) done: FUNC_LEAVE_API(ret_value) } /* end H5PLsize() */ - diff --git a/src/H5PLextern.h b/src/H5PLextern.h index cd5464d1015..7f3df5e2f92 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,19 +14,19 @@ * Purpose: Header file for writing external HDF5 plugins. */ -#ifndef _H5PLextern_H -#define _H5PLextern_H +#ifndef H5PLextern_H +#define H5PLextern_H /* Include HDF5 header */ #include "hdf5.h" /* plugins always export */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5PLUGIN_DLL __declspec(dllexport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5PLUGIN_DLL __attribute__ ((visibility("default"))) +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5PLUGIN_DLL __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5PLUGIN_DLL __attribute__((visibility("default"))) #else - #define H5PLUGIN_DLL +#define H5PLUGIN_DLL #endif #ifdef __cplusplus @@ -40,5 +40,4 @@ H5PLUGIN_DLL const void *H5PLget_plugin_info(void); } #endif -#endif /* _H5PLextern_H */ - +#endif /* H5PLextern_H */ diff --git a/src/H5PLint.c b/src/H5PLint.c index 4aa04e17b6c..cf6135da9fe 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,39 +15,33 @@ * */ - /****************/ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -55,29 +49,25 @@ /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Bitmask that controls whether classes of plugins - * (e.g.: filters) can be loaded. + * (e.g.: filters, VOL drivers) can be loaded. */ -static unsigned int H5PL_plugin_control_mask_g = H5PL_ALL_PLUGIN; +static unsigned int H5PL_plugin_control_mask_g = H5PL_ALL_PLUGIN; /* This flag will be set to FALSE if the HDF5_PLUGIN_PRELOAD * environment variable was set to H5PL_NO_PLUGIN at * package initialization. */ -static hbool_t H5PL_allow_plugins_g = TRUE; - +static hbool_t H5PL_allow_plugins_g = TRUE; - /*------------------------------------------------------------------------- * Function: H5PL__get_plugin_control_mask * @@ -90,7 +80,7 @@ static hbool_t H5PL_allow_plugins_g = TRUE; herr_t H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -104,7 +94,6 @@ H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) } /* end H5PL__get_plugin_control_mask() */ - /*------------------------------------------------------------------------- * Function: H5PL__set_plugin_control_mask * @@ -117,7 +106,7 @@ H5PL__get_plugin_control_mask(unsigned int *mask /*out*/) herr_t H5PL__set_plugin_control_mask(unsigned int mask) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -133,7 +122,6 @@ H5PL__set_plugin_control_mask(unsigned int mask) } /* end H5PL__set_plugin_control_mask() */ - /*------------------------------------------------------------------------- * Function: H5PL__init_package * @@ -147,8 +135,8 @@ H5PL__set_plugin_control_mask(unsigned int mask) herr_t H5PL__init_package(void) { - char *env_var = NULL; - herr_t ret_value = SUCCEED; + char * env_var = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -159,7 +147,7 @@ H5PL__init_package(void) if (NULL != (env_var = HDgetenv("HDF5_PLUGIN_PRELOAD"))) if (!HDstrcmp(env_var, H5PL_NO_PLUGIN)) { H5PL_plugin_control_mask_g = 0; - H5PL_allow_plugins_g = FALSE; + H5PL_allow_plugins_g = FALSE; } /* Create the table of previously-loaded plugins */ @@ -174,7 +162,6 @@ H5PL__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__init_package() */ - /*------------------------------------------------------------------------- * Function: H5PL_term_package * @@ -192,7 +179,7 @@ int H5PL_term_package(void) { hbool_t already_closed = FALSE; - int ret_value = 0; + int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT @@ -219,7 +206,6 @@ H5PL_term_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_term_package() */ - /*------------------------------------------------------------------------- * Function: H5PL_load * @@ -235,12 +221,12 @@ H5PL_term_package(void) *------------------------------------------------------------------------- */ const void * -H5PL_load(H5PL_type_t type, H5PL_key_t key) +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; + 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; FUNC_ENTER_NOAPI(NULL) @@ -250,6 +236,11 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) if ((H5PL_plugin_control_mask_g & H5PL_FILTER_PLUGIN) == 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "filter plugins disabled") break; + case H5PL_TYPE_VOL: + if ((H5PL_plugin_control_mask_g & H5PL_VOL_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, + "Virtual Object Layer (VOL) driver plugins disabled") + break; case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: @@ -258,11 +249,11 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) /* Set up the search parameters */ search_params.type = type; - search_params.key.id = key.id; + search_params.key = key; /* Search in the table of already loaded plugin libraries */ - if(H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in plugin cache failed") + if (H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in plugin cache failed") /* If not found, try iterating through the path table to find an appropriate plugin */ if (!found) @@ -277,7 +268,6 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_load() */ - /*------------------------------------------------------------------------- * Function: H5PL__open * @@ -300,13 +290,17 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) * get_plugin_info function pointer, but early (4.4.7, at least) gcc * only allows diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(pedantic) +H5_GCC_DIAG_OFF("pedantic") herr_t -H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, const void **plugin_info) +H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *success, + H5PL_type_t *plugin_type, const void **plugin_info) { - H5PL_HANDLE handle = NULL; - H5PL_get_plugin_info_t get_plugin_info = NULL; - herr_t ret_value = SUCCEED; + H5PL_HANDLE handle = NULL; + H5PL_get_plugin_type_t get_plugin_type = NULL; + H5PL_get_plugin_info_t get_plugin_info = NULL; + H5PL_type_t loaded_plugin_type; + H5PL_key_t tmp_key; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -316,8 +310,10 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, HDassert(plugin_info); /* Initialize out parameters */ - *success = FALSE; + *success = FALSE; *plugin_info = NULL; + if (plugin_type) + *plugin_type = H5PL_TYPE_ERROR; /* There are different reasons why a library can't be open, e.g. wrong architecture. * If we can't open the library, just return. @@ -327,30 +323,77 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, HGOTO_DONE(SUCCEED) } + /* Return a handle for the function H5PLget_plugin_type in the dynamic library. + * The plugin library is supposed to define this function. + */ + if (NULL == (get_plugin_type = (H5PL_get_plugin_type_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_type"))) + HGOTO_DONE(SUCCEED) + /* Return a handle for the function H5PLget_plugin_info in the dynamic library. * The plugin library is supposed to define this function. */ if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) HGOTO_DONE(SUCCEED) + /* Check the plugin type and return if it doesn't match the one passed in */ + loaded_plugin_type = (H5PL_type_t)(*get_plugin_type)(); + if ((type != H5PL_TYPE_NONE) && (type != loaded_plugin_type)) + HGOTO_DONE(SUCCEED) + /* Get the plugin information */ - switch (type) { - case H5PL_TYPE_FILTER: - { + switch (loaded_plugin_type) { + case H5PL_TYPE_FILTER: { const H5Z_class2_t *filter_info; /* Get the plugin info */ if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info)())) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get filter info from plugin") + /* Setup temporary plugin key if one wasn't supplied */ + if (!key) { + tmp_key.id = filter_info->id; + key = &tmp_key; + } + /* If the filter IDs match, we're done. Set the output parameters. */ - if (filter_info->id == key.id) { + if (filter_info->id == key->id) { + if (plugin_type) + *plugin_type = H5PL_TYPE_FILTER; *plugin_info = (const void *)filter_info; - *success = TRUE; + *success = TRUE; + } + + break; + } + + case H5PL_TYPE_VOL: { + const void *cls; + + /* Get the plugin info */ + if (NULL == (cls = (const void *)(*get_plugin_info)())) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL connector info from plugin") + + /* Setup temporary plugin key if one wasn't supplied */ + if (!key) { + tmp_key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + tmp_key.vol.u.name = ((const H5VL_class_t *)cls)->name; + key = &tmp_key; + } + + /* Ask VOL interface if this class is the one we are looking for and is compatible, etc */ + if (H5VL_check_plugin_load(cls, key, success) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL, "VOL connector compatibility check failed") + + /* Check for finding the correct plugin */ + if (*success) { + if (plugin_type) + *plugin_type = H5PL_TYPE_VOL; + *plugin_info = cls; } break; } + case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: @@ -359,7 +402,7 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, /* If we found the correct plugin, store it in the cache */ if (*success) - if (H5PL__add_plugin(type, key, handle)) + if (H5PL__add_plugin(loaded_plugin_type, key, handle)) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache") done: @@ -369,9 +412,8 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__open() */ -H5_GCC_DIAG_ON(pedantic) +H5_GCC_DIAG_ON("pedantic") - /*------------------------------------------------------------------------- * Function: H5PL__close * @@ -391,3 +433,28 @@ H5PL__close(H5PL_HANDLE handle) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5PL__close() */ +/*------------------------------------------------------------------------- + * Function: H5PL_iterate + * + * Purpose: Iterates over all the available plugins and calls the + * specified callback function on each plugin. + * + * Return: H5_ITER_CONT if all plugins are processed successfully + * H5_ITER_STOP if short-circuit success occurs while + * processing plugins + * H5_ITER_ERROR if an error occurs while processing plugins + * + *------------------------------------------------------------------------- + */ +herr_t +H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data) +{ + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI(H5_ITER_ERROR) + + ret_value = H5PL__path_table_iterate(iter_type, iter_op, op_data); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PL_iterate() */ diff --git a/src/H5PLmodule.h b/src/H5PLmodule.h index 945441ead0d..ab9f1d5ff89 100644 --- a/src/H5PLmodule.h +++ b/src/H5PLmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,17 +16,20 @@ * is part of the H5PL package. */ -#ifndef _H5PLmodule_H -#define _H5PLmodule_H +#ifndef H5PLmodule_H +#define H5PLmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5PL_MODULE -#define H5_MY_PKG H5PL -#define H5_MY_PKG_ERR H5E_PLUGIN -#define H5_MY_PKG_INIT YES - -#endif /* _H5PLmodule_H */ +#define H5_MY_PKG H5PL +#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 + */ +#endif /* H5PLmodule_H */ diff --git a/src/H5PLpath.c b/src/H5PLpath.c index ba23fd3a309..39a7d0dc11d 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -30,34 +30,30 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ /****************/ /* Local Macros */ /****************/ /* Initial capacity of the path table */ -#define H5PL_INITIAL_PATH_CAPACITY 16 +#define H5PL_INITIAL_PATH_CAPACITY 16 /* The amount to add to the capacity when the table is full */ -#define H5PL_PATH_CAPACITY_ADD 16 - +#define H5PL_PATH_CAPACITY_ADD 16 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,33 +62,32 @@ static herr_t H5PL__insert_at(const char *path, unsigned int idx); static herr_t H5PL__make_space_at(unsigned int idx); static herr_t H5PL__replace_at(const char *path, unsigned int idx); static herr_t H5PL__expand_path_table(void); -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); +static herr_t H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type_t iter_type, + H5PL_iterate_t iter_op, void *op_data); +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); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Stored plugin paths to search */ -static char **H5PL_paths_g = NULL; +static char **H5PL_paths_g = NULL; /* The number of stored paths */ -static unsigned H5PL_num_paths_g = 0; +static unsigned H5PL_num_paths_g = 0; /* The capacity of the path table */ -static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; +static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; - - /*------------------------------------------------------------------------- * Function: H5PL__insert_at() * @@ -107,8 +102,8 @@ 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) */ - herr_t ret_value = SUCCEED; /* Return value */ + char * path_copy = NULL; /* copy of path string (for storing) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -127,7 +122,7 @@ H5PL__insert_at(const char *path, unsigned int idx) #ifdef H5_HAVE_WIN32_API /* Clean up Microsoft Windows environment variables in the path string */ - if(H5_expand_windows_env_vars(&path_copy)) + if (H5_expand_windows_env_vars(&path_copy)) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") #endif /* H5_HAVE_WIN32_API */ @@ -144,7 +139,6 @@ H5PL__insert_at(const char *path, unsigned int idx) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__insert_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__make_space_at() * @@ -158,8 +152,8 @@ H5PL__insert_at(const char *path, unsigned int idx) static herr_t H5PL__make_space_at(unsigned int idx) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -168,14 +162,13 @@ H5PL__make_space_at(unsigned int idx) /* Copy the paths back to make a space */ for (u = H5PL_num_paths_g; u > idx; u--) - H5PL_paths_g[u] = H5PL_paths_g[u-1]; + H5PL_paths_g[u] = H5PL_paths_g[u - 1]; H5PL_paths_g[idx] = NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__make_space_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__replace_at() * @@ -190,8 +183,8 @@ 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) */ - herr_t ret_value = SUCCEED; /* Return value */ + char * path_copy = NULL; /* copy of path string (for storing) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -208,9 +201,9 @@ H5PL__replace_at(const char *path, unsigned int idx) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't make internal copy of path") #ifdef H5_HAVE_WIN32_API - /* Clean up Microsoft Windows environment variables in the path string */ - if (H5_expand_windows_env_vars(&path_copy)) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") + /* Clean up Microsoft Windows environment variables in the path string */ + if (H5_expand_windows_env_vars(&path_copy)) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTCONVERT, FAIL, "can't expand environment variable string") #endif /* H5_HAVE_WIN32_API */ /* Free the existing path entry */ @@ -223,7 +216,6 @@ H5PL__replace_at(const char *path, unsigned int idx) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__replace_at() */ - /*------------------------------------------------------------------------- * Function: H5PL__create_path_table * @@ -237,18 +229,18 @@ H5PL__replace_at(const char *path, unsigned int idx) herr_t H5PL__create_path_table(void) { - char *env_var= NULL; /* Path string from environment variable */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + char *env_var = NULL; /* Path string from environment variable */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Allocate memory for the path table */ - H5PL_num_paths_g = 0; + H5PL_num_paths_g = 0; H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; if (NULL == (H5PL_paths_g = (char **)H5MM_calloc((size_t)H5PL_path_capacity_g * sizeof(char *)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path table") @@ -291,7 +283,6 @@ H5PL__create_path_table(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__create_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__close_path_table * @@ -305,8 +296,8 @@ H5PL__create_path_table(void) herr_t H5PL__close_path_table(void) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -325,7 +316,6 @@ H5PL__close_path_table(void) } /* end H5PL__close_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__get_num_paths * @@ -344,7 +334,6 @@ H5PL__get_num_paths(void) } /* end H5PL__get_num_paths() */ - /*------------------------------------------------------------------------- * Function: H5PL__expand_path_table * @@ -357,7 +346,7 @@ H5PL__get_num_paths(void) static herr_t H5PL__expand_path_table(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -365,7 +354,8 @@ H5PL__expand_path_table(void) H5PL_path_capacity_g += H5PL_PATH_CAPACITY_ADD; /* Resize the array */ - if(NULL == (H5PL_paths_g = (char **)H5MM_realloc(H5PL_paths_g, (size_t)H5PL_path_capacity_g * sizeof(char *)))) + if (NULL == + (H5PL_paths_g = (char **)H5MM_realloc(H5PL_paths_g, (size_t)H5PL_path_capacity_g * sizeof(char *)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "allocating additional memory for path table failed") /* Initialize the new memory */ @@ -379,7 +369,6 @@ H5PL__expand_path_table(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__expand_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__append_path * @@ -392,7 +381,7 @@ H5PL__expand_path_table(void) herr_t H5PL__append_path(const char *path) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -408,7 +397,6 @@ H5PL__append_path(const char *path) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__append_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__prepend_path * @@ -421,7 +409,7 @@ H5PL__append_path(const char *path) herr_t H5PL__prepend_path(const char *path) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -437,7 +425,6 @@ H5PL__prepend_path(const char *path) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__prepend_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__replace_path * @@ -450,7 +437,7 @@ H5PL__prepend_path(const char *path) herr_t H5PL__replace_path(const char *path, unsigned int idx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -467,7 +454,6 @@ H5PL__replace_path(const char *path, unsigned int idx) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__replace_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__insert_path * @@ -481,7 +467,7 @@ H5PL__replace_path(const char *path, unsigned int idx) herr_t H5PL__insert_path(const char *path, unsigned int idx) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -498,7 +484,6 @@ H5PL__insert_path(const char *path, unsigned int idx) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__insert_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__remove_path * @@ -512,8 +497,8 @@ H5PL__insert_path(const char *path, unsigned int idx) herr_t H5PL__remove_path(unsigned int idx) { - unsigned u; /* iterator */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* iterator */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -530,7 +515,7 @@ H5PL__remove_path(unsigned int idx) /* Shift the paths down to close the gap */ for (u = idx; u < H5PL_num_paths_g; u++) - H5PL_paths_g[u] = H5PL_paths_g[u+1]; + H5PL_paths_g[u] = H5PL_paths_g[u + 1]; /* Set the (former) last path to NULL */ H5PL_paths_g[H5PL_num_paths_g] = NULL; @@ -539,7 +524,6 @@ H5PL__remove_path(unsigned int idx) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__remove_path() */ - /*------------------------------------------------------------------------- * Function: H5PL__get_path * @@ -553,7 +537,7 @@ H5PL__remove_path(unsigned int idx) const char * H5PL__get_path(unsigned int idx) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -564,9 +548,221 @@ H5PL__get_path(unsigned int idx) return H5PL_paths_g[idx]; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5PL__replace_path() */ +} /* end H5PL__get_path() */ + +/*------------------------------------------------------------------------- + * Function: H5PL__path_table_iterate + * + * Purpose: Iterates over all the plugins in the plugin path table and + * calls the specified callback function on each plugin found. + * + * Return: H5_ITER_CONT if all plugins are processed successfully + * H5_ITER_STOP if short-circuit success occurs while + * processing plugins + * H5_ITER_ERROR if an error occurs while processing plugins + * + *------------------------------------------------------------------------- + */ +herr_t +H5PL__path_table_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data) +{ + unsigned int u; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_PACKAGE + + for (u = 0; (u < H5PL_num_paths_g) && (ret_value == H5_ITER_CONT); u++) + ret_value = H5PL__path_table_iterate_process_path(H5PL_paths_g[u], iter_type, iter_op, op_data); + + if (ret_value < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_BADITER, H5_ITER_ERROR, "can't iterate over plugins in plugin path '%s'", + H5PL_paths_g[u]); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5PL__path_table_iterate() */ + +/*------------------------------------------------------------------------- + * Function: H5PL__path_table_iterate_process_path + * + * Purpose: Iterates over all the plugins within a single plugin path + * entry in the plugin path table and calls the specified + * callback function on each plugin found. Two function + * definitions are for Unix and Windows. + * + * Return: H5_ITER_CONT if all plugins are processed successfully + * H5_ITER_STOP if short-circuit success occurs while + * processing plugins + * H5_ITER_ERROR if an error occurs while processing plugins + * + *------------------------------------------------------------------------- + */ +#ifndef H5_HAVE_WIN32_API +static herr_t +H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type_t iter_type, + H5PL_iterate_t iter_op, void *op_data) +{ + H5PL_type_t plugin_type; + const void * plugin_info = NULL; + hbool_t plugin_loaded; + char * path = NULL; + DIR * dirp = NULL; /* Directory stream */ + struct dirent *dp = NULL; /* Directory entry */ + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + HDassert(plugin_path); + HDassert(iter_op); + + /* Open the directory */ + if (!(dirp = HDopendir(plugin_path))) + HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory: %s", plugin_path) + + /* Iterate through all entries in the directory */ + while (NULL != (dp = HDreaddir(dirp))) { + /* The library we are looking for should be called libxxx.so... on Unix + * or libxxx.xxx.dylib on Mac. + */ +#ifndef __CYGWIN__ + if (!HDstrncmp(dp->d_name, "lib", (size_t)3) && + (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) { +#else + if (!HDstrncmp(dp->d_name, "cyg", (size_t)3) && HDstrstr(dp->d_name, ".dll")) { +#endif + + hbool_t plugin_matches; + h5_stat_t my_stat; + size_t len; + + /* Allocate & initialize the path name */ + len = HDstrlen(plugin_path) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(dp->d_name) + 1 /*\0*/ + + 4; /* Extra "+4" to quiet GCC warning - 2019/07/05, QAK */ + + if (NULL == (path = (char *)H5MM_calloc(len))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, H5_ITER_ERROR, "can't allocate memory for path") + + HDsnprintf(path, len, "%s/%s", plugin_path, dp->d_name); + + /* Get info for directory entry */ + if (HDstat(path, &my_stat) == -1) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5_ITER_ERROR, "can't stat file %s -- error was: %s", path, + HDstrerror(errno)) + + /* If it is a directory, skip it */ + if (S_ISDIR(my_stat.st_mode)) + continue; + + /* Attempt to open the dynamic library */ + plugin_type = H5PL_TYPE_ERROR; + plugin_info = NULL; + plugin_loaded = FALSE; + if (H5PL__open(path, H5PL_TYPE_NONE, NULL, &plugin_loaded, &plugin_type, &plugin_info) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, H5_ITER_ERROR, "failed to open plugin '%s'", path); + + /* Determine if we should process this plugin */ + plugin_matches = (iter_type == H5PL_ITER_TYPE_ALL) || + ((iter_type == H5PL_ITER_TYPE_FILTER) && (plugin_type == H5PL_TYPE_FILTER)) || + ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)); + + /* If the plugin was successfully loaded, call supplied callback function on plugin */ + if (plugin_loaded && plugin_matches && (ret_value = iter_op(plugin_type, plugin_info, op_data))) + break; + + path = (char *)H5MM_xfree(path); + } /* end if */ + } /* end while */ + + if (ret_value < 0) + HERROR(H5E_PLUGIN, H5E_CALLBACK, "callback operator function returned failure"); + +done: + if (dirp) + if (HDclosedir(dirp) < 0) + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, H5_ITER_ERROR, "can't close directory: %s", + HDstrerror(errno)) + + path = (char *)H5MM_xfree(path); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PL__path_table_iterate_process_path() */ +#else /* H5_HAVE_WIN32_API */ +static herr_t +H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type_t iter_type, + H5PL_iterate_t iter_op, void *op_data) +{ + WIN32_FIND_DATAA fdFile; + HANDLE hFind = INVALID_HANDLE_VALUE; + H5PL_type_t plugin_type; + const void * plugin_info = NULL; + hbool_t plugin_loaded; + char * path = NULL; + char service[2048]; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + /* Check args - Just assert on package functions */ + HDassert(plugin_path); + HDassert(iter_op); + + /* Specify a file mask. *.* = We want everything! */ + HDsprintf(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") + + /* Loop over all the files */ + do { + /* Ignore '.' and '..' */ + if (HDstrcmp(fdFile.cFileName, ".") != 0 && HDstrcmp(fdFile.cFileName, "..") != 0) { + hbool_t plugin_matches; + size_t len; + + /* Allocate & initialize the path name */ + len = HDstrlen(plugin_path) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(fdFile.cFileName) + 1; + + if (NULL == (path = (char *)H5MM_calloc(len))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, H5_ITER_ERROR, "can't allocate memory for path") + + HDsnprintf(path, len, "%s\\%s", plugin_path, fdFile.cFileName); + + /* Ignore directories */ + if (fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + continue; + + /* Attempt to open the dynamic library */ + plugin_type = H5PL_TYPE_ERROR; + plugin_info = NULL; + plugin_loaded = FALSE; + if (H5PL__open(path, H5PL_TYPE_NONE, NULL, &plugin_loaded, &plugin_type, &plugin_info) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, H5_ITER_ERROR, "failed to open plugin '%s'", path); + + /* Determine if we should process this plugin */ + plugin_matches = (iter_type == H5PL_ITER_TYPE_ALL) || + ((iter_type == H5PL_ITER_TYPE_FILTER) && (plugin_type == H5PL_TYPE_FILTER)) || + ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)); + + /* If the plugin was successfully loaded, call supplied callback function on plugin */ + if (plugin_loaded && plugin_matches && (ret_value = iter_op(plugin_type, plugin_info, op_data))) + break; + + path = (char *)H5MM_xfree(path); + } + } while (FindNextFileA(hFind, &fdFile)); + + if (ret_value < 0) + HERROR(H5E_PLUGIN, H5E_CALLBACK, "callback operator function returned failure"); + +done: + if (hFind != INVALID_HANDLE_VALUE) + FindClose(hFind); + + path = (char *)H5MM_xfree(path); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5PL__path_table_iterate_process_path() */ +#endif /* H5_HAVE_WIN32_API */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_path_table * @@ -580,10 +776,11 @@ H5PL__get_path(unsigned int idx) *------------------------------------------------------------------------- */ herr_t -H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found, const void **plugin_info) +H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found, + const void **plugin_info) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -593,7 +790,7 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool HDassert(plugin_info); /* Initialize output parameters */ - *found = FALSE; + *found = FALSE; *plugin_info = NULL; /* Loop over the paths in the table, checking for an appropriate plugin */ @@ -601,7 +798,8 @@ 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]) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in path %s encountered an error", + H5PL_paths_g[u]) /* Break out if found */ if (*found) { @@ -615,7 +813,6 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path_table() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_path * @@ -633,11 +830,12 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool */ #ifndef H5_HAVE_WIN32_API 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) +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 */ - struct dirent *dp = NULL; /* Directory entry */ + char * path = NULL; + DIR * dirp = NULL; /* Directory stream */ + struct dirent *dp = NULL; /* Directory entry */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -663,17 +861,17 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo */ #ifndef __CYGWIN__ if (!HDstrncmp(dp->d_name, "lib", (size_t)3) && - (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) { + (HDstrstr(dp->d_name, ".so") || HDstrstr(dp->d_name, ".dylib"))) { #else - if (!HDstrncmp(dp->d_name, "cyg", (size_t)3) && - HDstrstr(dp->d_name, ".dll") ) { + if (!HDstrncmp(dp->d_name, "cyg", (size_t)3) && HDstrstr(dp->d_name, ".dll")) { #endif - h5_stat_t my_stat; - size_t len; + h5_stat_t my_stat; + size_t len; /* Allocate & initialize the path name */ - len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(dp->d_name) + 1 /*\0*/ + 4; /* Extra "+4" to quiet GCC warning - 2019/07/05, QAK */ + len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(dp->d_name) + 1 /*\0*/ + + 4; /* Extra "+4" to quiet GCC warning - 2019/07/05, QAK */ if (NULL == (path = (char *)H5MM_calloc(len))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") @@ -682,21 +880,24 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* Get info for directory entry */ if (HDstat(path, &my_stat) == -1) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file %s -- error was: %s", path, HDstrerror(errno)) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't stat file %s -- error was: %s", path, + HDstrerror(errno)) /* If it is a directory, skip it */ - if (S_ISDIR(my_stat.st_mode)) + if (S_ISDIR(my_stat.st_mode)) { + path = (char *)H5MM_xfree(path); continue; + } - /* attempt to open the dynamic library as a filter library */ - if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0) + /* attempt to open the dynamic library */ + if (H5PL__open(path, search_params->type, search_params->key, found, NULL, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) HGOTO_DONE(SUCCEED) path = (char *)H5MM_xfree(path); } /* end if */ - } /* end while */ + } /* end while */ done: if (dirp) @@ -707,15 +908,16 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path() */ -#else /* H5_HAVE_WIN32_API */ +#else /* H5_HAVE_WIN32_API */ 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) +H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, + const void **plugin_info) { - WIN32_FIND_DATAA fdFile; - HANDLE hFind = INVALID_HANDLE_VALUE; - char *path = NULL; - char service[2048]; - herr_t ret_value = SUCCEED; + WIN32_FIND_DATAA fdFile; + HANDLE hFind = INVALID_HANDLE_VALUE; + char * path = NULL; + char service[2048]; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -740,7 +942,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* XXX: Probably just continue here and move the code below over one tab */ - size_t len; + size_t len; /* Allocate & initialize the path name */ len = HDstrlen(dir) + HDstrlen(H5PL_PATH_SEPARATOR) + HDstrlen(fdFile.cFileName) + 1; @@ -754,8 +956,8 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo if (fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - /* attempt to open the dynamic library as a filter library */ - if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0) + /* attempt to open the dynamic library */ + if (H5PL__open(path, search_params->type, search_params->key, found, NULL, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) HGOTO_DONE(SUCCEED) @@ -773,4 +975,3 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_path() */ #endif /* H5_HAVE_WIN32_API */ - diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index 6b1b6dae5ce..cffc358ae0e 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,11 +21,11 @@ #error "Do not include this file outside the H5PL package!" #endif -#ifndef _H5PLpkg_H -#define _H5PLpkg_H +#ifndef H5PLpkg_H +#define H5PLpkg_H /* Include private header file */ -#include "H5PLprivate.h" /* Filter functions */ +#include "H5PLprivate.h" /* Filter functions */ /* Other private headers needed by this file */ @@ -34,8 +34,7 @@ /**************************/ /* Whether to pre-load pathnames for plugin libraries */ -#define H5PL_DEFAULT_PATH H5_DEFAULT_PLUGINDIR - +#define H5PL_DEFAULT_PATH H5_DEFAULT_PLUGINDIR /****************************/ /* Macros for supporting */ @@ -58,73 +57,72 @@ */ #ifdef H5_HAVE_WIN32_API - /* The path separator on this platform */ -# define H5PL_PATH_SEPARATOR ";" +/* The path separator on this platform */ +#define H5PL_PATH_SEPARATOR ";" - /* Handle for dynamic library */ -# define H5PL_HANDLE HINSTANCE +/* Handle for dynamic library */ +#define H5PL_HANDLE HINSTANCE - /* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ -# define H5PL_OPEN_DLIB(S) LoadLibraryExA(S, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) +/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ +#define H5PL_OPEN_DLIB(S) LoadLibraryExA(S, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) - /* Get the address of a symbol in dynamic library */ -# define H5PL_GET_LIB_FUNC(H,N) GetProcAddress(H,N) +/* Get the address of a symbol in dynamic library */ +#define H5PL_GET_LIB_FUNC(H, N) GetProcAddress(H, N) - /* Close dynamic library */ -# define H5PL_CLOSE_LIB(H) FreeLibrary(H) +/* Close dynamic library */ +#define H5PL_CLOSE_LIB(H) FreeLibrary(H) - /* Clear error - nothing to do */ -# define H5PL_CLR_ERROR +/* Clear error - nothing to do */ +#define H5PL_CLR_ERROR - /* maximum size for expanding env vars */ -# define H5PL_EXPAND_BUFFER_SIZE 32767 +/* maximum size for expanding env vars */ +#define H5PL_EXPAND_BUFFER_SIZE 32767 - typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); +typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void); +typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); #else /* H5_HAVE_WIN32_API */ - /*****************/ - /* POSIX support */ - /*****************/ +/*****************/ +/* POSIX support */ +/*****************/ - /* The path separator on this platform */ -# define H5PL_PATH_SEPARATOR ":" +/* The path separator on this platform */ +#define H5PL_PATH_SEPARATOR ":" - /* Handle for dynamic library */ -# define H5PL_HANDLE void * +/* Handle for dynamic library */ +#define H5PL_HANDLE void * - /* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ -# define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY | RTLD_LOCAL) +/* Get a handle to a plugin library. Windows: TEXT macro handles Unicode strings */ +#define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY | RTLD_LOCAL) - /* Get the address of a symbol in dynamic library */ -# define H5PL_GET_LIB_FUNC(H,N) dlsym(H,N) +/* Get the address of a symbol in dynamic library */ +#define H5PL_GET_LIB_FUNC(H, N) dlsym(H, N) - /* Close dynamic library */ -# define H5PL_CLOSE_LIB(H) dlclose(H) +/* Close dynamic library */ +#define H5PL_CLOSE_LIB(H) dlclose(H) - /* Clear error */ -# define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) +/* Clear error */ +#define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) - typedef const void *(*H5PL_get_plugin_info_t)(void); +typedef H5PL_type_t (*H5PL_get_plugin_type_t)(void); +typedef const void *(*H5PL_get_plugin_info_t)(void); #endif /* H5_HAVE_WIN32_API */ - /****************************/ /* Package Private Typedefs */ /****************************/ /* Data used to search for plugins */ typedef struct H5PL_search_params_t { - H5PL_type_t type; - H5PL_key_t key; + H5PL_type_t type; + const H5PL_key_t *key; } H5PL_search_params_t; - /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ @@ -134,28 +132,30 @@ H5_DLL herr_t H5PL__get_plugin_control_mask(unsigned int *mask /*out*/); H5_DLL herr_t H5PL__set_plugin_control_mask(unsigned int mask); /* Plugin search and manipulation */ -H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, H5PL_key_t key, - hbool_t *success /*out*/, const void **plugin_info /*out*/); +H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, const H5PL_key_t *key, + hbool_t *success /*out*/, H5PL_type_t *plugin_type /*out*/, + const void **plugin_info /*out*/); H5_DLL herr_t H5PL__close(H5PL_HANDLE handle); /* Plugin cache calls */ H5_DLL herr_t H5PL__create_plugin_cache(void); H5_DLL herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/); -H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, - H5PL_HANDLE handle); -H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/); +H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle); +H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, + const void **plugin_info /*out*/); /* Plugin search path calls */ -H5_DLL herr_t H5PL__create_path_table(void); -H5_DLL herr_t H5PL__close_path_table(void); -H5_DLL unsigned H5PL__get_num_paths(void); -H5_DLL herr_t H5PL__append_path(const char *path); -H5_DLL herr_t H5PL__prepend_path(const char *path); -H5_DLL herr_t H5PL__replace_path(const char *path, unsigned int index); -H5_DLL herr_t H5PL__insert_path(const char *path, unsigned int index); -H5_DLL herr_t H5PL__remove_path(unsigned int index); +H5_DLL herr_t H5PL__create_path_table(void); +H5_DLL herr_t H5PL__close_path_table(void); +H5_DLL unsigned H5PL__get_num_paths(void); +H5_DLL herr_t H5PL__append_path(const char *path); +H5_DLL herr_t H5PL__prepend_path(const char *path); +H5_DLL herr_t H5PL__replace_path(const char *path, unsigned int index); +H5_DLL herr_t H5PL__insert_path(const char *path, unsigned int index); +H5_DLL herr_t H5PL__remove_path(unsigned int index); H5_DLL const char *H5PL__get_path(unsigned int index); -H5_DLL herr_t H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/); - -#endif /* _H5PLpkg_H */ +H5_DLL herr_t H5PL__path_table_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data); +H5_DLL herr_t H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, + hbool_t *found /*out*/, const void **plugin_info /*out*/); +#endif /* H5PLpkg_H */ diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index 504905c1bf2..2ec08450012 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,29 +26,26 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ /****************/ /* Initial capacity of the plugin cache */ -#define H5PL_INITIAL_CACHE_CAPACITY 16 +#define H5PL_INITIAL_CACHE_CAPACITY 16 /* The amount to add to the capacity when the cache is full */ -#define H5PL_CACHE_CAPACITY_ADD 16 - +#define H5PL_CACHE_CAPACITY_ADD 16 /******************/ /* Local Typedefs */ @@ -56,44 +53,38 @@ /* Type for the list of info for opened plugin libraries */ typedef struct H5PL_plugin_t { - H5PL_type_t type; /* Plugin type */ - H5PL_key_t key; /* Unique key to identify the plugin */ - H5PL_HANDLE handle; /* Plugin handle */ + H5PL_type_t type; /* Plugin type */ + H5PL_key_t key; /* Unique key to identify the plugin */ + H5PL_HANDLE handle; /* Plugin handle */ } H5PL_plugin_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5PL__expand_cache(void); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Cache for storing opened plugin libraries */ -static H5PL_plugin_t *H5PL_cache_g = NULL; +static H5PL_plugin_t *H5PL_cache_g = NULL; /* The number of stored plugins */ -static unsigned int H5PL_num_plugins_g = 0; +static unsigned int H5PL_num_plugins_g = 0; /* The capacity of the plugin cache */ -static unsigned int H5PL_cache_capacity_g = 0; +static unsigned int H5PL_cache_capacity_g = 0; - - /*------------------------------------------------------------------------- * Function: H5PL__create_plugin_cache * @@ -107,7 +98,7 @@ static unsigned int H5PL_cache_capacity_g = 0; herr_t H5PL__create_plugin_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -116,7 +107,8 @@ H5PL__create_plugin_cache(void) H5PL_cache_capacity_g = H5PL_INITIAL_CACHE_CAPACITY; - if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == + (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin cache") done: @@ -130,7 +122,6 @@ H5PL__create_plugin_cache(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__create_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__close_plugin_cache * @@ -144,8 +135,8 @@ H5PL__create_plugin_cache(void) herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -157,8 +148,8 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) H5PL__close((H5PL_cache_g[u]).handle); /* Free the cache array */ - H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); - H5PL_num_plugins_g = 0; + H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); + H5PL_num_plugins_g = 0; H5PL_cache_capacity_g = 0; /* Note that actually closed the table (needed by package close call) */ @@ -170,7 +161,6 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__close_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__expand_cache * @@ -183,7 +173,7 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) static herr_t H5PL__expand_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -191,7 +181,8 @@ H5PL__expand_cache(void) H5PL_cache_capacity_g += H5PL_CACHE_CAPACITY_ADD; /* Resize the array */ - if(NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * + sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "allocating additional memory for plugin cache failed") /* Initialize the new memory */ @@ -205,7 +196,6 @@ H5PL__expand_cache(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__expand_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__add_plugin * @@ -216,9 +206,9 @@ H5PL__expand_cache(void) *------------------------------------------------------------------------- */ herr_t -H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) +H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -228,9 +218,9 @@ H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't expand plugin cache") /* Store the plugin info and bump the # of plugins */ - H5PL_cache_g[H5PL_num_plugins_g].type = type; - H5PL_cache_g[H5PL_num_plugins_g].key = key; - H5PL_cache_g[H5PL_num_plugins_g].handle = handle; + H5PL_cache_g[H5PL_num_plugins_g].type = type; + H5PL_cache_g[H5PL_num_plugins_g].key = *key; + H5PL_cache_g[H5PL_num_plugins_g].handle = handle; H5PL_num_plugins_g++; @@ -238,7 +228,6 @@ H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__add_plugin() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_cache * @@ -253,12 +242,13 @@ H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) /* See the other use of H5PL_GET_LIB_FUNC() for an explanation * for why we disable -Wpedantic here. */ -H5_GCC_DIAG_OFF(pedantic) +H5_GCC_DIAG_OFF("pedantic") herr_t -H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, const void **plugin_info) +H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, + const void **plugin_info) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -268,29 +258,31 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f HDassert(plugin_info); /* Initialize output parameters */ - *found = FALSE; + *found = FALSE; *plugin_info = NULL; /* Loop over all the plugins, looking for one that matches */ for (u = 0; u < H5PL_num_plugins_g; u++) { - /* If the plugin type (filter, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key.id == (H5PL_cache_g[u]).key.id)) { + /* If the plugin type (filter, VOL connector, etc.) and ID match, query the plugin for its info */ + if ((search_params->type == (H5PL_cache_g[u]).type) && + (search_params->key->id == (H5PL_cache_g[u]).key.id)) { - H5PL_get_plugin_info_t get_plugin_info_function; - const H5Z_class2_t *filter_info; + H5PL_get_plugin_info_t get_plugin_info_function; + 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"))) + if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( + (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 */ - if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info_function)())) + if (NULL == (info = (*get_plugin_info_function)())) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") /* Set output parameters */ - *found = TRUE; - *plugin_info = filter_info; + *found = TRUE; + *plugin_info = info; /* No need to continue processing */ break; @@ -302,5 +294,4 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_cache() */ -H5_GCC_DIAG_ON(pedantic) - +H5_GCC_DIAG_ON("pedantic") diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index cc2e25863ed..7eae513d36f 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,42 +14,58 @@ * This file contains private information about the H5PL module */ -#ifndef _H5PLprivate_H -#define _H5PLprivate_H +#ifndef H5PLprivate_H +#define H5PLprivate_H /* Include package's public header */ #include "H5PLpublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ /* The key that will be used to find the plugin */ typedef union H5PL_key_t { - int id; /* filters */ + int id; /* I/O filters */ + struct { + 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 */ + } u; + } vol; } H5PL_key_t; +/* Enum dictating the type of plugins to process + * when iterating through available plugins + */ +typedef enum { + H5PL_ITER_TYPE_FILTER, + H5PL_ITER_TYPE_VOL, + H5PL_ITER_TYPE_ALL, +} H5PL_iterate_type_t; + +/* Callback function for iterating through the available plugins */ +typedef herr_t (*H5PL_iterate_t)(H5PL_type_t plugin_type, const void *plugin_info, void *op_data); /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* Internal API routines */ -H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, H5PL_key_t key); - -#endif /* _H5PLprivate_H */ +H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, const H5PL_key_t *key); +H5_DLL herr_t H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data); +#endif /* H5PLprivate_H */ diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index fe5bdfb00f8..55ff59485f1 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,11 +14,11 @@ * This file contains public declarations for the H5PL module. */ -#ifndef _H5PLpublic_H -#define _H5PLpublic_H +#ifndef H5PLpublic_H +#define H5PLpublic_H /* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ +#include "H5public.h" /* Generic Functions */ /*******************/ /* Public Typedefs */ @@ -26,37 +26,202 @@ /* Special string to indicate no plugin loading. */ -#define H5PL_NO_PLUGIN "::" +#define H5PL_NO_PLUGIN "::" -/* Plugin type used by the plugin library */ +//! +/** + * Plugin type (bit-position) used by the plugin library + */ typedef enum H5PL_type_t { - H5PL_TYPE_ERROR = -1, /* Error */ - H5PL_TYPE_FILTER = 0, /* Filter */ - H5PL_TYPE_NONE = 1 /* This must be last! */ + H5PL_TYPE_ERROR = -1, /**< Error */ + H5PL_TYPE_FILTER = 0, /**< Filter */ + H5PL_TYPE_VOL = 1, /**< VOL driver */ + H5PL_TYPE_NONE = 2 /**< Sentinel: This must be last! */ } H5PL_type_t; +//! /* Common dynamic plugin type flags used by the set/get_loading_state functions */ -#define H5PL_FILTER_PLUGIN 0x0001 -#define H5PL_ALL_PLUGIN 0xFFFF +#define H5PL_FILTER_PLUGIN 0x0001 +#define H5PL_VOL_PLUGIN 0x0002 +#define H5PL_ALL_PLUGIN 0xFFFF #ifdef __cplusplus extern "C" { #endif /* plugin state */ +/** + * \ingroup H5PL + * \brief Controls the loadability of dynamic plugin types + * + * \param[in] plugin_control_mask The list of dynamic plugin types to enable or disable.\n + * A plugin bit set to 0 (zero) prevents use of that dynamic plugin.\n + * A plugin bit set to 1 (one) enables use of that dynamic plugin.\n + * Setting \p plugin_control_mask to a negative value enables all dynamic + * plugin types.\n + * Setting \p plugin_control_mask to 0 (zero) disables all dynamic plugin\n + * types. + * \return \herr_t + * + * \details H5PLset_loading_state() uses one argument to enable or disable individual plugin types. + * + * \details The \p plugin_control_mask parameter is an encoded integer in which each bit controls a specific + * plugin type. Bit positions allocated to date are specified in \ref H5PL_type_t as follows: + * \snippet this H5PL_type_t_snip + * + * A plugin bit set to 0 (zero) prevents the use of the dynamic plugin type corresponding to that bit + * position. A plugin bit set to 1 (one) allows the use of that dynamic plugin type. + * + * All dynamic plugin types can be enabled by setting \p plugin_control_mask to a negative value. A + * value of 0 (zero) will disable all dynamic plugin types. + * + * The loading of external dynamic plugins can be controlled during runtime with an environment + * variable, \c HDF5_PLUGIN_PRELOAD. H5PLset_loading_state() inspects the \c HDF5_PLUGIN_PRELOAD + * environment variable every time it is called. If the environment variable is set to the special + * \c :: string, all dynamic plugins are disabled. + * + * \warning The environment variable \c HDF5_PLUGIN_PRELOAD controls the loading of dynamic plugin types at + * runtime. If it is set to disable all plugin types, then it will disable them for \Emph{all} + * running programs that access the same variable instance. + * + * \since 1.8.15 + * + */ H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); +/** + * \ingroup H5PL + * \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 + * disabled.\n + * A plugin bit set to 1 (one) indicates that 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 + * If the value of \p plugin_control_mask is 0 (zero), all dynamic plugins + * are disabled. + * \return \herr_t + * + * \details H5PLget_loading_state() retrieves the bitmask that controls whether a certain type of plugins + * (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: + * \snippet this H5PL_type_t_snip + * + * \since 1.8.15 + * + */ H5_DLL herr_t H5PLget_loading_state(unsigned int *plugin_control_mask /*out*/); +/** + * \ingroup H5PL + * \brief Inserts a plugin path at the end of the plugin search path list + * + * \param[in] search_path A plugin path + * \return \herr_t + * + * \details H5PLappend() inserts a plugin path at the end of the plugin search path list. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLappend(const char *search_path); +/** + * \ingroup H5PL + * \brief Inserts a plugin path at the beginning of the plugin search path list + * + * \param[in] search_path A plugin path + * \return \herr_t + * + * \details H5PLprepend() inserts a plugin path at the end of the plugin search path list. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLprepend(const char *search_path); +/** + * \ingroup H5PL + * \brief Replaces the path at the specified index in the plugin search path list + * + * \param[in] search_path A plugin path + * \param[in] index Index + * \return \herr_t + * + * \details H5PLreplace() replaces a plugin path at the specified index in the plugin search path list. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLreplace(const char *search_path, unsigned int index); +/** + * \ingroup H5PL + * \brief Inserts a path at the specified index in the plugin search path list + * + * \param[in] search_path A plugin path + * \param[in] index Index + * \return \herr_t + * + * \details H5PLinsert() inserts a plugin path at the specified index in the plugin search path list, + * moving other paths after \p index. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLinsert(const char *search_path, unsigned int index); +/** + * \ingroup H5PL + * \brief Removes a plugin path at a specified index from the plugin search path list + * + * \param[in] index Index + * \return \herr_t + * + * \details H5PLremove() removes a plugin path at the specified \p index and compacts the plugin search path + * list. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLremove(unsigned int index); +/** + * \ingroup H5PL + * \brief Queries the plugin search path list at the specified index + * + * \param[in] index Index + * \param[out] path_buf Pathname + * \param[in] buf_size Size of \p path_buf + * \return Returns the length of the path, a non-negative value, if successful; otherwise returns a negative + * value. + * + * \details H5PLget() queries the plugin path at a specified index. If \p path_buf is non-NULL then it writes + * up to \p buf_size bytes into that buffer and always returns the length of the path name. + * + * If \p path_buf is NULL, this function will simply return the number of characters required to + * store the path name, ignoring \p path_buf and \p buf_size. + * + * If an error occurs then the buffer pointed to by \p path_buf (NULL or non-NULL) is unchanged and + * the function returns a negative value. If a zero is returned for the name's length, then there is + * no path name associated with the index. and the \p path_buf buffer will be unchanged. + * + * \since 1.10.1 + * + */ H5_DLL ssize_t H5PLget(unsigned int index, char *path_buf /*out*/, size_t buf_size); +/** + * \ingroup H5PL + * \brief Retrieves the number of stored plugin paths + * + * \param[out] num_paths Current length of the plugin search path list + * \return \herr_t + * + * \details H5PLsize() retrieves the number of paths stored in the plugin search path list. + * + * \since 1.10.1 + * + */ H5_DLL herr_t H5PLsize(unsigned int *num_paths /*out*/); #ifdef __cplusplus } #endif -#endif /* _H5PLpublic_H */ - +#endif /* H5PLpublic_H */ diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 166a35ff753..65fd54ace77 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,45 +24,39 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ /* Attribute creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ - "attribute create", /* Class name for debugging */ - H5P_TYPE_ATTRIBUTE_CREATE, /* Class type */ + "attribute create", /* Class name for debugging */ + H5P_TYPE_ATTRIBUTE_CREATE, /* Class type */ &H5P_CLS_STRING_CREATE_g, /* Parent class */ &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */ @@ -70,16 +64,14 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ &H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */ NULL, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index c3cb81d5227..3b14959aded 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -47,101 +45,100 @@ /* ========= Dataset Access properties ============ */ /* Definitions for size of raw data chunk cache(slots) */ -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF H5D_CHUNK_CACHE_NSLOTS_DEFAULT -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_chunk_cache_nslots -#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_chunk_cache_nslots +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF H5D_CHUNK_CACHE_NSLOTS_DEFAULT +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_chunk_cache_nslots +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_chunk_cache_nslots /* Definition for size of raw data chunk cache(bytes) */ -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF H5D_CHUNK_CACHE_NBYTES_DEFAULT -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_chunk_cache_nbytes -#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_chunk_cache_nbytes +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF H5D_CHUNK_CACHE_NBYTES_DEFAULT +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_chunk_cache_nbytes +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_chunk_cache_nbytes /* Definition for preemption read chunks first */ -#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) -#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT -#define H5D_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double -#define H5D_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double +#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) +#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT +#define H5D_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double +#define H5D_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definitions for VDS view option */ -#define H5D_ACS_VDS_VIEW_SIZE sizeof(H5D_vds_view_t) -#define H5D_ACS_VDS_VIEW_DEF H5D_VDS_LAST_AVAILABLE -#define H5D_ACS_VDS_VIEW_ENC H5P__dacc_vds_view_enc -#define H5D_ACS_VDS_VIEW_DEC H5P__dacc_vds_view_dec +#define H5D_ACS_VDS_VIEW_SIZE sizeof(H5D_vds_view_t) +#define H5D_ACS_VDS_VIEW_DEF H5D_VDS_LAST_AVAILABLE +#define H5D_ACS_VDS_VIEW_ENC H5P__dacc_vds_view_enc +#define H5D_ACS_VDS_VIEW_DEC H5P__dacc_vds_view_dec /* Definitions for VDS printf gap */ -#define H5D_ACS_VDS_PRINTF_GAP_SIZE sizeof(hsize_t) -#define H5D_ACS_VDS_PRINTF_GAP_DEF (hsize_t)0 -#define H5D_ACS_VDS_PRINTF_GAP_ENC H5P__encode_hsize_t -#define H5D_ACS_VDS_PRINTF_GAP_DEC H5P__decode_hsize_t +#define H5D_ACS_VDS_PRINTF_GAP_SIZE sizeof(hsize_t) +#define H5D_ACS_VDS_PRINTF_GAP_DEF (hsize_t)0 +#define H5D_ACS_VDS_PRINTF_GAP_ENC H5P__encode_hsize_t +#define H5D_ACS_VDS_PRINTF_GAP_DEC H5P__decode_hsize_t /* Definitions for VDS file prefix */ -#define H5D_ACS_VDS_PREFIX_SIZE sizeof(char *) -#define H5D_ACS_VDS_PREFIX_DEF NULL /*default is no prefix */ -#define H5D_ACS_VDS_PREFIX_SET H5P__dapl_vds_file_pref_set -#define H5D_ACS_VDS_PREFIX_GET H5P__dapl_vds_file_pref_get -#define H5D_ACS_VDS_PREFIX_ENC H5P__dapl_vds_file_pref_enc -#define H5D_ACS_VDS_PREFIX_DEC H5P__dapl_vds_file_pref_dec -#define H5D_ACS_VDS_PREFIX_DEL H5P__dapl_vds_file_pref_del -#define H5D_ACS_VDS_PREFIX_COPY H5P__dapl_vds_file_pref_copy -#define H5D_ACS_VDS_PREFIX_CMP H5P__dapl_vds_file_pref_cmp -#define H5D_ACS_VDS_PREFIX_CLOSE H5P__dapl_vds_file_pref_close +#define H5D_ACS_VDS_PREFIX_SIZE sizeof(char *) +#define H5D_ACS_VDS_PREFIX_DEF NULL /*default is no prefix */ +#define H5D_ACS_VDS_PREFIX_SET H5P__dapl_vds_file_pref_set +#define H5D_ACS_VDS_PREFIX_GET H5P__dapl_vds_file_pref_get +#define H5D_ACS_VDS_PREFIX_ENC H5P__dapl_vds_file_pref_enc +#define H5D_ACS_VDS_PREFIX_DEC H5P__dapl_vds_file_pref_dec +#define H5D_ACS_VDS_PREFIX_DEL H5P__dapl_vds_file_pref_del +#define H5D_ACS_VDS_PREFIX_COPY H5P__dapl_vds_file_pref_copy +#define H5D_ACS_VDS_PREFIX_CMP H5P__dapl_vds_file_pref_cmp +#define H5D_ACS_VDS_PREFIX_CLOSE H5P__dapl_vds_file_pref_close /* Definition for append flush */ -#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) -#define H5D_ACS_APPEND_FLUSH_DEF {0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},NULL,NULL} +#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) +#define H5D_ACS_APPEND_FLUSH_DEF \ + { \ + 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + NULL, NULL \ + } /* Definitions for external file prefix */ -#define H5D_ACS_EFILE_PREFIX_SIZE sizeof(char *) -#define H5D_ACS_EFILE_PREFIX_DEF NULL /*default is no prefix */ -#define H5D_ACS_EFILE_PREFIX_SET H5P__dapl_efile_pref_set -#define H5D_ACS_EFILE_PREFIX_GET H5P__dapl_efile_pref_get -#define H5D_ACS_EFILE_PREFIX_ENC H5P__dapl_efile_pref_enc -#define H5D_ACS_EFILE_PREFIX_DEC H5P__dapl_efile_pref_dec -#define H5D_ACS_EFILE_PREFIX_DEL H5P__dapl_efile_pref_del -#define H5D_ACS_EFILE_PREFIX_COPY H5P__dapl_efile_pref_copy -#define H5D_ACS_EFILE_PREFIX_CMP H5P__dapl_efile_pref_cmp -#define H5D_ACS_EFILE_PREFIX_CLOSE H5P__dapl_efile_pref_close +#define H5D_ACS_EFILE_PREFIX_SIZE sizeof(char *) +#define H5D_ACS_EFILE_PREFIX_DEF NULL /*default is no prefix */ +#define H5D_ACS_EFILE_PREFIX_SET H5P__dapl_efile_pref_set +#define H5D_ACS_EFILE_PREFIX_GET H5P__dapl_efile_pref_get +#define H5D_ACS_EFILE_PREFIX_ENC H5P__dapl_efile_pref_enc +#define H5D_ACS_EFILE_PREFIX_DEC H5P__dapl_efile_pref_dec +#define H5D_ACS_EFILE_PREFIX_DEL H5P__dapl_efile_pref_del +#define H5D_ACS_EFILE_PREFIX_COPY H5P__dapl_efile_pref_copy +#define H5D_ACS_EFILE_PREFIX_CMP H5P__dapl_efile_pref_cmp +#define H5D_ACS_EFILE_PREFIX_CLOSE H5P__dapl_efile_pref_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Property class callbacks */ static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P__encode_chunk_cache_nslots(const void *value, void **_pp, - size_t *size); +static herr_t 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); -static herr_t H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, - size_t *size); +static herr_t 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); /* Property list callbacks */ static herr_t H5P__dacc_vds_view_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dacc_vds_view_dec(const void **pp, void *value); -static herr_t H5P__dapl_vds_file_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_vds_file_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dapl_vds_file_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_vds_file_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t 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); -static herr_t H5P__dapl_vds_file_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_vds_file_pref_copy(const char* name, size_t size, void* value); -static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dapl_vds_file_pref_close(const char* name, size_t size, void* value); +static herr_t H5P__dapl_vds_file_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_vds_file_pref_copy(const char *name, size_t size, void *value); +static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dapl_vds_file_pref_close(const char *name, size_t size, void *value); /* Property list callbacks */ -static herr_t H5P__dapl_efile_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_efile_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dapl_efile_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_efile_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t 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); -static herr_t H5P__dapl_efile_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dapl_efile_pref_copy(const char* name, size_t size, void* value); -static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* value); - +static herr_t H5P__dapl_efile_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dapl_efile_pref_copy(const char *name, size_t size, void *value); +static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dapl_efile_pref_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -149,39 +146,38 @@ static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* va /* Dataset access property list class library initialization object */ const H5P_libclass_t H5P_CLS_DACC[1] = {{ - "dataset access", /* Class name for debugging */ - H5P_TYPE_DATASET_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ - &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__dacc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "dataset access", /* Class name for debugging */ + H5P_TYPE_DATASET_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__dacc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5D_append_flush_t H5D_def_append_flush_g = H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ -static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ -static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; /* Default vds prefix string */ +static const H5D_append_flush_t H5D_def_append_flush_g = + H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ +static const char *H5D_def_efile_prefix_g = + H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ +static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; /* Default vds prefix string */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_reg_prop * @@ -194,65 +190,69 @@ static const char *H5D_def_vds_prefix_g = H5D_ACS_VDS_PREFIX_DEF; static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass) { - size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ - size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ - double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ - H5D_vds_view_t virtual_view = H5D_ACS_VDS_VIEW_DEF; /* Default VDS view option */ - hsize_t printf_gap = H5D_ACS_VDS_PRINTF_GAP_DEF; /* Default VDS printf gap */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ + size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ + double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ + H5D_vds_view_t virtual_view = H5D_ACS_VDS_VIEW_DEF; /* Default VDS view option */ + hsize_t printf_gap = H5D_ACS_VDS_PRINTF_GAP_DEF; /* Default VDS printf gap */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the size of raw data chunk cache (elements) */ - if(H5P__register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, - NULL, NULL, NULL, H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC, H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, + &rdcc_nslots, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC, + H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ - if(H5P__register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, - NULL, NULL, NULL, H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC, H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, + &rdcc_nbytes, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC, + H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ - if(H5P__register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, - NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, + &rdcc_w0, NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, + H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the VDS view option */ - if(H5P__register_real(pclass, H5D_ACS_VDS_VIEW_NAME, H5D_ACS_VDS_VIEW_SIZE, &virtual_view, - NULL, NULL, NULL, H5D_ACS_VDS_VIEW_ENC, H5D_ACS_VDS_VIEW_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_ACS_VDS_VIEW_NAME, H5D_ACS_VDS_VIEW_SIZE, &virtual_view, NULL, NULL, + NULL, H5D_ACS_VDS_VIEW_ENC, H5D_ACS_VDS_VIEW_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the VDS printf gap */ - if(H5P__register_real(pclass, H5D_ACS_VDS_PRINTF_GAP_NAME, H5D_ACS_VDS_PRINTF_GAP_SIZE, &printf_gap, - NULL, NULL, NULL, H5D_ACS_VDS_PRINTF_GAP_ENC, H5D_ACS_VDS_PRINTF_GAP_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_ACS_VDS_PRINTF_GAP_NAME, H5D_ACS_VDS_PRINTF_GAP_SIZE, &printf_gap, + NULL, NULL, NULL, H5D_ACS_VDS_PRINTF_GAP_ENC, H5D_ACS_VDS_PRINTF_GAP_DEC, NULL, + NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for vds prefix */ - if(H5P__register_real(pclass, H5D_ACS_VDS_PREFIX_NAME, H5D_ACS_VDS_PREFIX_SIZE, &H5D_def_vds_prefix_g, - NULL, H5D_ACS_VDS_PREFIX_SET, H5D_ACS_VDS_PREFIX_GET, H5D_ACS_VDS_PREFIX_ENC, H5D_ACS_VDS_PREFIX_DEC, - H5D_ACS_VDS_PREFIX_DEL, H5D_ACS_VDS_PREFIX_COPY, H5D_ACS_VDS_PREFIX_CMP, H5D_ACS_VDS_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_VDS_PREFIX_NAME, H5D_ACS_VDS_PREFIX_SIZE, &H5D_def_vds_prefix_g, + NULL, H5D_ACS_VDS_PREFIX_SET, H5D_ACS_VDS_PREFIX_GET, H5D_ACS_VDS_PREFIX_ENC, + H5D_ACS_VDS_PREFIX_DEC, H5D_ACS_VDS_PREFIX_DEL, H5D_ACS_VDS_PREFIX_COPY, + H5D_ACS_VDS_PREFIX_CMP, H5D_ACS_VDS_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register info for append flush */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, &H5D_def_append_flush_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, + &H5D_def_append_flush_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external file prefix */ - if(H5P__register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, &H5D_def_efile_prefix_g, - NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET, H5D_ACS_EFILE_PREFIX_ENC, H5D_ACS_EFILE_PREFIX_DEC, - H5D_ACS_EFILE_PREFIX_DEL, H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, H5D_ACS_EFILE_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, + &H5D_def_efile_prefix_g, NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET, + H5D_ACS_EFILE_PREFIX_ENC, H5D_ACS_EFILE_PREFIX_DEC, H5D_ACS_EFILE_PREFIX_DEL, + H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, + H5D_ACS_EFILE_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dacc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_set * @@ -264,7 +264,7 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) */ static herr_t H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -277,7 +277,6 @@ H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_get * @@ -289,7 +288,7 @@ H5P__dapl_vds_file_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU */ static herr_t H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -302,7 +301,6 @@ H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_enc * @@ -316,44 +314,43 @@ H5P__dapl_vds_file_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU 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; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *vds_file_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != vds_file_pref) + if (NULL != vds_file_pref) len = HDstrlen(vds_file_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != vds_file_pref) { + if (NULL != vds_file_pref) { H5MM_memcpy(*(char **)pp, vds_file_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != vds_file_pref) + if (NULL != vds_file_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_dec * @@ -367,12 +364,12 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** vds_file_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -389,9 +386,9 @@ H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*vds_file_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*vds_file_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*vds_file_pref, *(const char **)pp, len); (*vds_file_pref)[len] = '\0'; @@ -405,7 +402,6 @@ H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_vds_file_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_del * @@ -416,7 +412,7 @@ H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) */ static herr_t H5P__dapl_vds_file_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -427,7 +423,6 @@ H5P__dapl_vds_file_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_copy * @@ -448,7 +443,6 @@ H5P__dapl_vds_file_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_cmp * @@ -462,24 +456,23 @@ H5P__dapl_vds_file_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU static int H5P__dapl_vds_file_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_vds_file_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_vds_file_pref_close * @@ -500,7 +493,6 @@ H5P__dapl_vds_file_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_vds_file_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_set * @@ -512,7 +504,7 @@ H5P__dapl_vds_file_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN */ static herr_t H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -525,7 +517,6 @@ H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_get * @@ -537,7 +528,7 @@ H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -550,7 +541,6 @@ H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_enc * @@ -564,44 +554,43 @@ H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED 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; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *efile_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != efile_pref) + if (NULL != efile_pref) len = HDstrlen(efile_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != efile_pref) { + if (NULL != efile_pref) { H5MM_memcpy(*(char **)pp, efile_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != efile_pref) + if (NULL != efile_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_dec * @@ -615,12 +604,12 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** efile_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -637,9 +626,9 @@ H5P__dapl_efile_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*efile_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*efile_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*efile_pref, *(const char **)pp, len); (*efile_pref)[len] = '\0'; @@ -653,7 +642,6 @@ H5P__dapl_efile_pref_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_efile_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_del * @@ -664,7 +652,7 @@ H5P__dapl_efile_pref_dec(const void **_pp, void *_value) */ static herr_t H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -675,7 +663,6 @@ H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_copy * @@ -696,7 +683,6 @@ H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_cmp * @@ -710,24 +696,23 @@ H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dapl_efile_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dapl_efile_pref_close * @@ -748,7 +733,6 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dapl_efile_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk_cache * @@ -776,34 +760,35 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "izzd", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if(rdcc_w0 > (double)1.0f) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); + if (rdcc_w0 > 1.0) + HGOTO_ERROR( + H5E_ARGS, H5E_BADVALUE, FAIL, + "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if(H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks"); - if(H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); - if(H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); + if (H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of chunks"); + if (H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size"); + if (H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk_cache * @@ -821,9 +806,9 @@ H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double herr_t H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - H5P_genplist_t *def_plist; /* Default file access property list */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *def_plist; /* Default file access property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*z*z*d", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0); @@ -840,31 +825,30 @@ H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, doub * from the default fapl is used. */ if (rdcc_nslots) { if (H5P_get(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots"); if (*rdcc_nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache number of slots"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default data cache number of slots"); } /* end if */ if (rdcc_nbytes) { if (H5P_get(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size"); if (*rdcc_nbytes == H5D_CHUNK_CACHE_NBYTES_DEFAULT) if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache byte size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default data cache byte size"); } /* end if */ if (rdcc_w0) { if (H5P_get(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks"); if (*rdcc_w0 < 0) if (H5P_get(def_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default preempt read chunks"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get default preempt read chunks"); } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk_cache() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_chunk_cache_nslots * @@ -881,9 +865,9 @@ H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, doub static herr_t H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) { - uint64_t enc_value; /* Property value to encode */ - uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ + uint64_t enc_value = 0; /* Property value to encode */ + uint8_t **pp = (uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_STATIC_NOERR @@ -893,33 +877,32 @@ H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) /* Determine if this is the default value, in which case only encode * enc_size (as 255). Also set size needed for encoding. */ - if(*(const size_t *)value == H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF) { + if (*(const size_t *)value == H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF) { enc_size = 0; *size += 1; } /* end if */ else { - enc_value = (uint64_t)*(const size_t *)value; - enc_size = H5VM_limit_enc_size(enc_value); + enc_value = (uint64_t) * (const size_t *)value; + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size > 0); *size += (1 + enc_size); } /* end else */ HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; /* Encode the value if necessary */ - if(enc_size != 0) { + if (enc_size != 0) { UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_chunk_cache_nslots() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_chunk_cache_nslots * @@ -936,10 +919,10 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -955,7 +938,7 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) /* Determine if enc_size indicates that this is the default value, in which * case set value to H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF and return */ - if(enc_size == 0) + if (enc_size == 0) *value = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; else { /* Decode the value */ @@ -966,7 +949,6 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_chunk_cache_nslots() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_chunk_cache_nbytes * @@ -983,9 +965,9 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) static herr_t H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) { - uint64_t enc_value; /* Property value to encode */ - uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ + uint64_t enc_value = 0; /* Property value to encode */ + uint8_t **pp = (uint8_t **)_pp; + unsigned enc_size; /* Size of encoded property */ FUNC_ENTER_STATIC_NOERR @@ -995,33 +977,32 @@ H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) /* Determine if this is the default value, in which case only encode * enc_size (as 255). Also set size needed for encoding. */ - if(*(const size_t *)value == H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF) { + if (*(const size_t *)value == H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF) { enc_size = 0; *size += 1; } /* end if */ else { - enc_value = (uint64_t)*(const size_t *)value; - enc_size = H5VM_limit_enc_size(enc_value); + enc_value = (uint64_t) * (const size_t *)value; + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size > 0); *size += (1 + enc_size); } /* end else */ HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; /* Encode the value if necessary */ - if(enc_size != 0) { + if (enc_size != 0) { UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_chunk_cache_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_chunk_cache_nbytes * @@ -1038,10 +1019,10 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -1057,7 +1038,7 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) /* Determine if enc_size indicates that this is the default value, in which * case set value to H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF and return */ - if(enc_size == 0) + if (enc_size == 0) *value = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; else { /* Decode the value */ @@ -1068,7 +1049,6 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_chunk_cache_nbytes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_view * @@ -1089,29 +1069,28 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) herr_t H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDv", plist_id, view); /* Check argument */ - if((view != H5D_VDS_FIRST_MISSING) && (view != H5D_VDS_LAST_AVAILABLE)) + if ((view != H5D_VDS_FIRST_MISSING) && (view != H5D_VDS_LAST_AVAILABLE)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid bounds option") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_ACS_VDS_VIEW_NAME, &view) < 0) + if (H5P_set(plist, H5D_ACS_VDS_VIEW_NAME, &view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_view() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_view * @@ -1126,26 +1105,25 @@ H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view) herr_t H5Pget_virtual_view(hid_t plist_id, H5D_vds_view_t *view) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Dv", plist_id, view); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value from property list */ - if(view) - if(H5P_get(plist, H5D_ACS_VDS_VIEW_NAME, view) < 0) + if (view) + if (H5P_get(plist, H5D_ACS_VDS_VIEW_NAME, view) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_view() */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_vds_view_enc * @@ -1160,7 +1138,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 @@ -1168,7 +1146,7 @@ H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) HDassert(view); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode EDC property */ *(*pp)++ = (uint8_t)*view; @@ -1178,7 +1156,6 @@ H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dacc_vds_view_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dacc_vds_view_dec * @@ -1193,7 +1170,7 @@ static herr_t H5P__dacc_vds_view_dec(const void **_pp, void *_value) { H5D_vds_view_t *view = (H5D_vds_view_t *)_value; - const uint8_t **pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1203,12 +1180,11 @@ H5P__dacc_vds_view_dec(const void **_pp, void *_value) HDassert(view); /* Decode EDC property */ - *view = (H5D_vds_view_t)*(*pp)++; + *view = (H5D_vds_view_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dacc_vds_view_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_printf_gap * @@ -1235,29 +1211,28 @@ H5P__dacc_vds_view_dec(const void **_pp, void *_value) herr_t H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, gap_size); /* Check argument */ - if(gap_size == HSIZE_UNDEF) + if (gap_size == HSIZE_UNDEF) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid printf gap size") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &gap_size) < 0) + if (H5P_set(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &gap_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_printf_gap() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_printf_gap * @@ -1273,26 +1248,25 @@ H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size) herr_t H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, gap_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value from property list */ - if(gap_size) - if(H5P_get(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, gap_size) < 0) + if (gap_size) + if (H5P_get(plist, H5D_ACS_VDS_PRINTF_GAP_NAME, gap_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_printf_gap() */ - /*------------------------------------------------------------------------- * Function: H5Pset_append_flush * @@ -1309,55 +1283,55 @@ H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size) *------------------------------------------------------------------------- */ herr_t -H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D_append_cb_t func, void *udata) +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 */ - H5D_append_flush_t info; /* Property for append flush parameters */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIu*hx*x", plist_id, ndims, boundary, func, udata); /* Check arguments */ - if(0 == ndims) + if (0 == ndims) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be zero") - if(ndims > H5S_MAX_RANK) + if (ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large") - if(!boundary) + if (!boundary) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no boundary dimensions specified") /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && udata) + if (!func && udata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set up values */ info.ndims = ndims; - info.func = func; + info.func = func; info.udata = udata; HDmemset(info.boundary, 0, sizeof(info.boundary)); /* boundary can be 0 to indicate no boundary is set */ - for(u = 0; u < ndims; u++) { - if(boundary[u] != (boundary[u] & 0xffffffff)) /* negative value (including H5S_UNLIMITED) */ + for (u = 0; u < ndims; u++) { + if (boundary[u] != (boundary[u] & 0xffffffff)) /* negative value (including H5S_UNLIMITED) */ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all boundary dimensions must be less than 2^32") info.boundary[u] = boundary[u]; /* Store user's boundary dimensions */ - } /* end for */ + } /* end for */ /* Set values */ - if(H5P_set(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_set(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set append flush") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_append_flush() */ - /*------------------------------------------------------------------------- * Function: H5Pget_append_flush() * @@ -1373,39 +1347,38 @@ 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 */ - H5D_append_flush_t info; - unsigned u; /* local index variable */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t * plist; /* property list pointer */ + H5D_append_flush_t info; + unsigned u; /* local index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIu*h*x**x", plist_id, ndims, boundary, func, udata); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve info for append flush */ - if(H5P_get(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + if (H5P_get(plist, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback") /* Assign return values */ - if(boundary) { + if (boundary) { HDmemset(boundary, 0, ndims * sizeof(hsize_t)); - if(info.ndims > 0) - for(u = 0; u < info.ndims && u < ndims; u++) + if (info.ndims > 0) + for (u = 0; u < info.ndims && u < ndims; u++) boundary[u] = info.boundary[u]; } /* end if */ - if(func) + if (func) *func = info.func; - if(udata) + if (udata) *udata = info.udata; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_append_flush() */ - /*------------------------------------------------------------------------- * Function: H5Pset_efile_prefix * @@ -1426,25 +1399,24 @@ H5Pget_append_flush(hid_t plist_id, unsigned ndims, hsize_t boundary[], H5D_appe herr_t H5Pset_efile_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5D_ACS_EFILE_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5D_ACS_EFILE_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_efile_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_efile_prefix * @@ -1458,32 +1430,32 @@ H5Pset_efile_prefix(hid_t plist_id, const char *prefix) 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 */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5D_ACS_EFILE_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5D_ACS_EFILE_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1494,13 +1466,12 @@ H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) FUNC_LEAVE_API(ret_value) } /* end H5Pget_efile_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual_prefix * * Purpose: Set a prefix to be applied to the path of any vds files * traversed. - * + * * If the prefix starts with ${ORIGIN}, this will be replaced by * the absolute path of the directory of the HDF5 file containing * the dataset. @@ -1516,25 +1487,24 @@ H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) herr_t H5Pset_virtual_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5D_ACS_VDS_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5D_ACS_VDS_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_prefix * @@ -1550,32 +1520,32 @@ H5Pset_virtual_prefix(hid_t plist_id, const char *prefix) 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 */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5D_ACS_VDS_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5D_ACS_VDS_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vds file prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1585,4 +1555,3 @@ H5Pget_virtual_prefix(hid_t plist_id, char *prefix, size_t size) done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_prefix() */ - diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index fc307296124..59a41ed6d02 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,98 +24,206 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5Zprivate.h" /* Data filters */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5Zprivate.h" /* Data filters */ /****************/ /* Local Macros */ /****************/ /* Define default layout information */ -#define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} -#define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, {{HADDR_UNDEF, NULL}}} -#define H5D_DEF_LAYOUT_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, (uint8_t)0, (unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {{{(uint8_t)0}}}} -#define H5D_DEF_STORAGE_VIRTUAL_INIT {{HADDR_UNDEF, 0}, 0, NULL, 0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE} +#define H5D_DEF_STORAGE_COMPACT_INIT \ + { \ + (hbool_t) FALSE, (size_t)0, NULL \ + } +#define H5D_DEF_STORAGE_CONTIG_INIT \ + { \ + HADDR_UNDEF, (hsize_t)0 \ + } +#define H5D_DEF_STORAGE_CHUNK_INIT \ + { \ + H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, \ + { \ + { \ + HADDR_UNDEF, NULL \ + } \ + } \ + } +#define H5D_DEF_LAYOUT_CHUNK_INIT \ + { \ + H5D_CHUNK_IDX_BTREE, (uint8_t)0, (unsigned)0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + { \ + { \ + { \ + (uint8_t)0 \ + } \ + } \ + } \ + } +#define H5D_DEF_STORAGE_VIRTUAL_INIT \ + { \ + {HADDR_UNDEF, 0}, 0, NULL, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ + H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE \ + } #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER -#define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} -#define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} -#define H5D_DEF_STORAGE_CHUNK {H5D_CHUNKED, { .chunk = H5D_DEF_STORAGE_CHUNK_INIT }} -#define H5D_DEF_STORAGE_VIRTUAL {H5D_VIRTUAL, { .virt = H5D_DEF_STORAGE_VIRTUAL_INIT }} -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} +#define H5D_DEF_STORAGE_COMPACT \ + { \ + H5D_COMPACT, \ + { \ + .compact = H5D_DEF_STORAGE_COMPACT_INIT \ + } \ + } +#define H5D_DEF_STORAGE_CONTIG \ + { \ + H5D_CONTIGUOUS, \ + { \ + .contig = H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_STORAGE_CHUNK \ + { \ + H5D_CHUNKED, \ + { \ + .chunk = H5D_DEF_STORAGE_CHUNK_INIT \ + } \ + } +#define H5D_DEF_STORAGE_VIRTUAL \ + { \ + H5D_VIRTUAL, \ + { \ + .virt = H5D_DEF_STORAGE_VIRTUAL_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_COMPACT \ + { \ + H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_COMPACT \ + } +#define H5D_DEF_LAYOUT_CONTIG \ + { \ + H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_CONTIG \ + } +#define H5D_DEF_LAYOUT_CHUNK \ + { \ + H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_CHUNK \ + } +#define H5D_DEF_LAYOUT_VIRTUAL \ + { \ + H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + H5D_DEF_STORAGE_VIRTUAL \ + } #else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the * H5P__init_def_layout() routine. -QAK */ -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_COMPACT \ + { \ + H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_CONTIG \ + { \ + H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_CHUNK \ + { \ + H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } +#define H5D_DEF_LAYOUT_VIRTUAL \ + { \ + H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ + { \ + H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ + } \ + } #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ -#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) -#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG -#define H5D_CRT_LAYOUT_SET H5P__dcrt_layout_set -#define H5D_CRT_LAYOUT_GET H5P__dcrt_layout_get -#define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc -#define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec -#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del -#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy -#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp -#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close +#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) +#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG +#define H5D_CRT_LAYOUT_SET H5P__dcrt_layout_set +#define H5D_CRT_LAYOUT_GET H5P__dcrt_layout_get +#define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc +#define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec +#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del +#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy +#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp +#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ -#define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) -#define H5D_CRT_FILL_VALUE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_FILL_VERSION_2, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_IFSET, FALSE} -#define H5D_CRT_FILL_VALUE_SET H5P__dcrt_fill_value_set -#define H5D_CRT_FILL_VALUE_GET H5P__dcrt_fill_value_get -#define H5D_CRT_FILL_VALUE_ENC H5P__dcrt_fill_value_enc -#define H5D_CRT_FILL_VALUE_DEC H5P__dcrt_fill_value_dec -#define H5D_CRT_FILL_VALUE_DEL H5P__dcrt_fill_value_del -#define H5D_CRT_FILL_VALUE_COPY H5P__dcrt_fill_value_copy -#define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp -#define H5D_CRT_FILL_VALUE_CLOSE H5P__dcrt_fill_value_close +#define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) +#define H5D_CRT_FILL_VALUE_DEF \ + { \ + {0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_FILL_VERSION_2, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, \ + H5D_FILL_TIME_IFSET, FALSE \ + } +#define H5D_CRT_FILL_VALUE_SET H5P__dcrt_fill_value_set +#define H5D_CRT_FILL_VALUE_GET H5P__dcrt_fill_value_get +#define H5D_CRT_FILL_VALUE_ENC H5P__dcrt_fill_value_enc +#define H5D_CRT_FILL_VALUE_DEC H5P__dcrt_fill_value_dec +#define H5D_CRT_FILL_VALUE_DEL H5P__dcrt_fill_value_del +#define H5D_CRT_FILL_VALUE_COPY H5P__dcrt_fill_value_copy +#define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp +#define H5D_CRT_FILL_VALUE_CLOSE H5P__dcrt_fill_value_close /* Definitions for space allocation time state */ -#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) -#define H5D_CRT_ALLOC_TIME_STATE_DEF 1 -#define H5D_CRT_ALLOC_TIME_STATE_ENC H5P__encode_unsigned -#define H5D_CRT_ALLOC_TIME_STATE_DEC H5P__decode_unsigned +#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) +#define H5D_CRT_ALLOC_TIME_STATE_DEF 1 +#define H5D_CRT_ALLOC_TIME_STATE_ENC H5P__encode_unsigned +#define H5D_CRT_ALLOC_TIME_STATE_DEC H5P__decode_unsigned /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) -#define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} -#define H5D_CRT_EXT_FILE_LIST_SET H5P__dcrt_ext_file_list_set -#define H5D_CRT_EXT_FILE_LIST_GET H5P__dcrt_ext_file_list_get -#define H5D_CRT_EXT_FILE_LIST_ENC H5P__dcrt_ext_file_list_enc -#define H5D_CRT_EXT_FILE_LIST_DEC H5P__dcrt_ext_file_list_dec -#define H5D_CRT_EXT_FILE_LIST_DEL H5P__dcrt_ext_file_list_del -#define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy -#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_DEF \ + { \ + HADDR_UNDEF, 0, 0, NULL \ + } +#define H5D_CRT_EXT_FILE_LIST_SET H5P__dcrt_ext_file_list_set +#define H5D_CRT_EXT_FILE_LIST_GET H5P__dcrt_ext_file_list_get +#define H5D_CRT_EXT_FILE_LIST_ENC H5P__dcrt_ext_file_list_enc +#define H5D_CRT_EXT_FILE_LIST_DEC H5P__dcrt_ext_file_list_dec +#define H5D_CRT_EXT_FILE_LIST_DEL H5P__dcrt_ext_file_list_del +#define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy +#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp #define H5D_CRT_EXT_FILE_LIST_CLOSE H5P__dcrt_ext_file_list_close /* Definitions for dataset object header minimization */ #define H5D_CRT_MIN_DSET_HDR_SIZE_SIZE sizeof(hbool_t) @@ -123,17 +231,14 @@ #define H5D_CRT_MIN_DSET_HDR_SIZE_ENC H5P__encode_hbool_t #define H5D_CRT_MIN_DSET_HDR_SIZE_DEC H5P__decode_hbool_t - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -154,7 +259,7 @@ static herr_t H5P__dcrt_layout_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dcrt_layout_dec(const void **pp, void *value); static herr_t H5P__dcrt_layout_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_layout_copy(const char *name, size_t size, void *value); -static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dcrt_layout_close(const char *name, size_t size, void *value); static herr_t H5P__dcrt_fill_value_set(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_fill_value_get(hid_t prop_id, const char *name, size_t size, void *value); @@ -169,34 +274,32 @@ static herr_t H5P__dcrt_ext_file_list_enc(const void *value, void **pp, size_t * static herr_t H5P__dcrt_ext_file_list_dec(const void **pp, void *value); static herr_t H5P__dcrt_ext_file_list_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_ext_file_list_copy(const char *name, size_t size, void *value); -static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__dcrt_ext_file_list_close(const char *name, size_t size, void *value); - /*********************/ /* Package Variables */ /*********************/ /* Dataset creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ - "dataset create", /* Class name for debugging */ - H5P_TYPE_DATASET_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_DATASET_CREATE_g, /* Pointer to class */ - &H5P_CLS_DATASET_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__dcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "dataset create", /* Class name for debugging */ + H5P_TYPE_DATASET_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATASET_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATASET_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__dcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -204,34 +307,32 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); - /***************************/ /* Local Private Variables */ /***************************/ /* Property value defaults */ -static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ -static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ -static const unsigned H5D_def_alloc_time_state_g = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ -static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ +static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ +static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ +static const unsigned H5D_def_alloc_time_state_g = + H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ +static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */ /* Defaults for each type of layout */ #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; -static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; -static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; +static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; static const H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ -static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; -static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; -static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; -static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -static hbool_t H5P_dcrt_def_layout_init_g = FALSE; +#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ +static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; +static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; +static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; +static hbool_t H5P_dcrt_def_layout_init_g = FALSE; #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - - /*------------------------------------------------------------------------- * Function: H5P__dcrt_reg_prop * @@ -246,45 +347,48 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the storage layout property */ - if(H5P__register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g, - NULL, H5D_CRT_LAYOUT_SET, H5D_CRT_LAYOUT_GET, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, - H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, H5D_CRT_LAYOUT_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g, NULL, + H5D_CRT_LAYOUT_SET, H5D_CRT_LAYOUT_GET, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, + H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, + H5D_CRT_LAYOUT_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ - if(H5P__register_real(pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &H5D_def_fill_g, - NULL, H5D_CRT_FILL_VALUE_SET, H5D_CRT_FILL_VALUE_GET, H5D_CRT_FILL_VALUE_ENC, H5D_CRT_FILL_VALUE_DEC, - H5D_CRT_FILL_VALUE_DEL, H5D_CRT_FILL_VALUE_COPY, H5D_CRT_FILL_VALUE_CMP, H5D_CRT_FILL_VALUE_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &H5D_def_fill_g, NULL, + H5D_CRT_FILL_VALUE_SET, H5D_CRT_FILL_VALUE_GET, H5D_CRT_FILL_VALUE_ENC, + H5D_CRT_FILL_VALUE_DEC, H5D_CRT_FILL_VALUE_DEL, H5D_CRT_FILL_VALUE_COPY, + H5D_CRT_FILL_VALUE_CMP, H5D_CRT_FILL_VALUE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time state property */ - if(H5P__register_real(pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, &H5D_def_alloc_time_state_g, - NULL, NULL, NULL, H5D_CRT_ALLOC_TIME_STATE_ENC, H5D_CRT_ALLOC_TIME_STATE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, + &H5D_def_alloc_time_state_g, NULL, NULL, NULL, H5D_CRT_ALLOC_TIME_STATE_ENC, + H5D_CRT_ALLOC_TIME_STATE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file list property */ - if(H5P__register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &H5D_def_efl_g, - NULL, H5D_CRT_EXT_FILE_LIST_SET, H5D_CRT_EXT_FILE_LIST_GET, H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, - H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &H5D_def_efl_g, + NULL, H5D_CRT_EXT_FILE_LIST_SET, H5D_CRT_EXT_FILE_LIST_GET, + H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, H5D_CRT_EXT_FILE_LIST_DEL, + H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, + H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the object header minimization property */ - if(H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, &H5O_ohdr_min_g, - NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, H5D_CRT_MIN_DSET_HDR_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, + &H5O_ohdr_min_g, NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, + H5D_CRT_MIN_DSET_HDR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_set * @@ -300,11 +404,11 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) */ static herr_t H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -312,7 +416,7 @@ H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Copy new layout message over old one */ @@ -322,7 +426,6 @@ H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_get * @@ -338,11 +441,11 @@ H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na */ static herr_t H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -350,7 +453,7 @@ H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Copy new layout message over old one */ @@ -360,7 +463,6 @@ H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_enc * @@ -380,11 +482,11 @@ 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; - size_t tmp_size; - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -392,25 +494,25 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) HDassert(layout); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode layout type */ *(*pp)++ = (uint8_t)layout->type; *size += sizeof(uint8_t); /* If layout is chunked, encode chunking structure */ - if(H5D_CHUNKED == layout->type) { + if (H5D_CHUNKED == layout->type) { /* Encode rank */ *(*pp)++ = (uint8_t)layout->u.chunk.ndims; *size += sizeof(uint8_t); /* Encode chunk dims */ HDcompile_assert(sizeof(uint32_t) == sizeof(layout->u.chunk.dim[0])); - for(u = 0; u < (size_t)layout->u.chunk.ndims; u++) { + for (u = 0; u < (size_t)layout->u.chunk.ndims; u++) { UINT32ENCODE(*pp, layout->u.chunk.dim[u]) *size += sizeof(uint32_t); } /* end for */ - } /* end if */ - else if(H5D_VIRTUAL == layout->type) { + } /* end if */ + else if (H5D_VIRTUAL == layout->type) { uint64_t nentries = (uint64_t)layout->storage.u.virt.list_nused; /* Encode number of entries */ @@ -418,7 +520,7 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) *size += (size_t)8; /* Iterate over entries */ - for(u = 0; u < layout->storage.u.virt.list_nused; u++) { + for (u = 0; u < layout->storage.u.virt.list_nused; u++) { /* Source file name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1; H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size); @@ -436,36 +538,36 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) * have verified that the buffer is large enough for the entire * list before we get here. */ tmp_size = (size_t)-1; - tmp_p = *pp; - if(H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size) < 0) + tmp_p = *pp; + if (H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection") *size += (size_t)(*pp - tmp_p); /* Virtual dataset selection. Same notes as above apply. */ tmp_size = (size_t)-1; - tmp_p = *pp; - if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size) < 0) + tmp_p = *pp; + if (H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection") *size += (size_t)(*pp - tmp_p); } /* end for */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { /* Size of layout type */ *size += sizeof(uint8_t); /* If layout is chunked, calculate chunking structure */ - if(H5D_CHUNKED == layout->type) { + if (H5D_CHUNKED == layout->type) { *size += sizeof(uint8_t); *size += layout->u.chunk.ndims * sizeof(uint32_t); } /* end if */ - else if(H5D_VIRTUAL == layout->type) { + else if (H5D_VIRTUAL == layout->type) { /* Calculate size of virtual layout info */ /* number of entries */ *size += (size_t)8; /* Iterate over entries */ - for(u = 0; u < layout->storage.u.virt.list_nused; u++) { + for (u = 0; u < layout->storage.u.virt.list_nused; u++) { /* Source file name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1; *size += tmp_size; @@ -476,26 +578,26 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) /* Source selection */ tmp_size = (size_t)0; - tmp_p = NULL; - if(H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size) < 0) + tmp_p = NULL; + if (H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection") *size += tmp_size; /* Virtual dataset selection */ tmp_size = (size_t)0; - tmp_p = NULL; - if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size) < 0) + tmp_p = NULL; + if (H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size) < + 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection") *size += tmp_size; } /* end for */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_dec * @@ -514,11 +616,11 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) static herr_t 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; - herr_t ret_value = SUCCEED; /* Return 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -528,11 +630,11 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) HDassert(value); /* Decode layout type */ - type = (H5D_layout_t)*(*pp)++; + type = (H5D_layout_t) * (*pp)++; /* set default layout in case the type is compact or contiguous, otherwise * decode the chunked structure and set chunked layout */ - switch(type) { + switch (type) { case H5D_COMPACT: layout = &H5D_def_layout_compact_g; break; @@ -541,126 +643,146 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) layout = &H5D_def_layout_contig_g; break; - case H5D_CHUNKED: - { - unsigned ndims; /* Number of chunk dimensions */ - - /* Decode the number of chunk dimensions */ - ndims = *(*pp)++; - - /* default chunk layout */ - if(0 == ndims) - layout = &H5D_def_layout_chunk_g; - else { /* chunk layout structure is encoded*/ - unsigned u; /* Local index variable */ - - /* Initialize to default values */ - tmp_layout = H5D_def_layout_chunk_g; - - /* Set rank & dimensions */ - tmp_layout.u.chunk.ndims = (unsigned)ndims; - for(u = 0; u < ndims; u++) - UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]) - - /* Point at the newly set up struct */ - layout = &tmp_layout; - } /* end else */ - } - break; + case H5D_CHUNKED: { + unsigned ndims; /* Number of chunk dimensions */ + + /* Decode the number of chunk dimensions */ + ndims = *(*pp)++; + + /* default chunk layout */ + if (0 == ndims) + layout = &H5D_def_layout_chunk_g; + else { /* chunk layout structure is encoded*/ + unsigned u; /* Local index variable */ + + /* Initialize to default values */ + tmp_layout = H5D_def_layout_chunk_g; + + /* Set rank & dimensions */ + tmp_layout.u.chunk.ndims = (unsigned)ndims; + for (u = 0; u < ndims; u++) + UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]) + + /* Point at the newly set up struct */ + layout = &tmp_layout; + } /* end else */ + } break; + + case H5D_VIRTUAL: { + uint64_t nentries; /* Number of VDS mappings */ + + /* Decode number of entries */ + UINT64DECODE(*pp, nentries) + + if (nentries == (uint64_t)0) + /* Just use the default struct */ + layout = &H5D_def_layout_virtual_g; + else { + size_t tmp_size; + size_t u; /* Local index variable */ + + /* Initialize to default values */ + tmp_layout = H5D_def_layout_virtual_g; + + /* Allocate entry list */ + if (NULL == (tmp_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc( + (size_t)nentries * sizeof(H5O_storage_virtual_ent_t)))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate heap block") + tmp_layout.storage.u.virt.list_nalloc = (size_t)nentries; + tmp_layout.storage.u.virt.list_nused = (size_t)nentries; + + /* Decode each entry */ + for (u = 0; u < (size_t)nentries; u++) { + /* Source file name */ + tmp_size = HDstrlen((const char *)*pp) + 1; + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "unable to allocate memory for source file name") + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); + *pp += tmp_size; + + /* Source dataset name */ + tmp_size = HDstrlen((const char *)*pp) + 1; + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "unable to allocate memory for source dataset name") + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); + *pp += tmp_size; + + /* Source selection */ + if (NULL == (tmp_layout.storage.u.virt.list[u].source_select = H5S_decode(pp))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode source space selection") + tmp_layout.storage.u.virt.list[u].source_space_status = H5O_VIRTUAL_STATUS_USER; + + /* Virtual selection */ + if (NULL == + (tmp_layout.storage.u.virt.list[u].source_dset.virtual_select = H5S_decode(pp))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode virtual space selection") + tmp_layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_USER; + + /* Parse source file and dataset names for "printf" + * style format specifiers */ + if (H5D_virtual_parse_source_name( + tmp_layout.storage.u.virt.list[u].source_file_name, + &tmp_layout.storage.u.virt.list[u].parsed_source_file_name, + &tmp_layout.storage.u.virt.list[u].psfn_static_strlen, + &tmp_layout.storage.u.virt.list[u].psfn_nsubs) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") + if (H5D_virtual_parse_source_name( + tmp_layout.storage.u.virt.list[u].source_dset_name, + &tmp_layout.storage.u.virt.list[u].parsed_source_dset_name, + &tmp_layout.storage.u.virt.list[u].psdn_static_strlen, + &tmp_layout.storage.u.virt.list[u].psdn_nsubs) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") + + /* Set source names in source_dset struct */ + if ((tmp_layout.storage.u.virt.list[u].psfn_nsubs == 0) && + (tmp_layout.storage.u.virt.list[u].psdn_nsubs == 0)) { + if (tmp_layout.storage.u.virt.list[u].parsed_source_file_name) + tmp_layout.storage.u.virt.list[u].source_dset.file_name = + tmp_layout.storage.u.virt.list[u].parsed_source_file_name->name_segment; + else + tmp_layout.storage.u.virt.list[u].source_dset.file_name = + tmp_layout.storage.u.virt.list[u].source_file_name; + if (tmp_layout.storage.u.virt.list[u].parsed_source_dset_name) + tmp_layout.storage.u.virt.list[u].source_dset.dset_name = + tmp_layout.storage.u.virt.list[u].parsed_source_dset_name->name_segment; + else + tmp_layout.storage.u.virt.list[u].source_dset.dset_name = + tmp_layout.storage.u.virt.list[u].source_dset_name; + } /* end if */ + + /* unlim_dim fields */ + tmp_layout.storage.u.virt.list[u].unlim_dim_source = + H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_select); + tmp_layout.storage.u.virt.list[u].unlim_dim_virtual = H5S_get_select_unlim_dim( + tmp_layout.storage.u.virt.list[u].source_dset.virtual_select); + tmp_layout.storage.u.virt.list[u].unlim_extent_source = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].unlim_extent_virtual = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].clip_size_source = HSIZE_UNDEF; + tmp_layout.storage.u.virt.list[u].clip_size_virtual = HSIZE_UNDEF; + + /* Clipped selections */ + if (tmp_layout.storage.u.virt.list[u].unlim_dim_virtual < 0) { + tmp_layout.storage.u.virt.list[u].source_dset.clipped_source_select = + tmp_layout.storage.u.virt.list[u].source_select; + tmp_layout.storage.u.virt.list[u].source_dset.clipped_virtual_select = + tmp_layout.storage.u.virt.list[u].source_dset.virtual_select; + } /* end if */ + + /* Update min_dims */ + if (H5D_virtual_update_min_dims(&tmp_layout, u) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, + "unable to update virtual dataset minimum dimensions") + } /* end for */ - case H5D_VIRTUAL: - { - uint64_t nentries; /* Number of VDS mappings */ - - /* Decode number of entries */ - UINT64DECODE(*pp, nentries) - - if(nentries == (uint64_t)0) - /* Just use the default struct */ - layout = &H5D_def_layout_virtual_g; - else { - size_t tmp_size; - size_t u; /* Local index variable */ - - /* Initialize to default values */ - tmp_layout = H5D_def_layout_virtual_g; - - /* Allocate entry list */ - if(NULL == (tmp_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc((size_t)nentries * sizeof(H5O_storage_virtual_ent_t)))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate heap block") - tmp_layout.storage.u.virt.list_nalloc = (size_t)nentries; - tmp_layout.storage.u.virt.list_nused = (size_t)nentries; - - /* Decode each entry */ - for(u = 0; u < (size_t)nentries; u++) { - /* Source file name */ - tmp_size = HDstrlen((const char *)*pp) + 1; - if(NULL == (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source file name") - H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); - *pp += tmp_size; - - /* Source dataset name */ - tmp_size = HDstrlen((const char *)*pp) + 1; - if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source dataset name") - H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); - *pp += tmp_size; - - /* Source selection */ - if(NULL == (tmp_layout.storage.u.virt.list[u].source_select = H5S_decode(pp))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode source space selection") - tmp_layout.storage.u.virt.list[u].source_space_status = H5O_VIRTUAL_STATUS_USER; - - /* Virtual selection */ - if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset.virtual_select = H5S_decode(pp))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode virtual space selection") - tmp_layout.storage.u.virt.list[u].virtual_space_status = H5O_VIRTUAL_STATUS_USER; - - /* Parse source file and dataset names for "printf" - * style format specifiers */ - if(H5D_virtual_parse_source_name(tmp_layout.storage.u.virt.list[u].source_file_name, &tmp_layout.storage.u.virt.list[u].parsed_source_file_name, &tmp_layout.storage.u.virt.list[u].psfn_static_strlen, &tmp_layout.storage.u.virt.list[u].psfn_nsubs) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(tmp_layout.storage.u.virt.list[u].source_dset_name, &tmp_layout.storage.u.virt.list[u].parsed_source_dset_name, &tmp_layout.storage.u.virt.list[u].psdn_static_strlen, &tmp_layout.storage.u.virt.list[u].psdn_nsubs) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") - - /* Set source names in source_dset struct */ - if((tmp_layout.storage.u.virt.list[u].psfn_nsubs == 0) - && (tmp_layout.storage.u.virt.list[u].psdn_nsubs == 0)) { - if(tmp_layout.storage.u.virt.list[u].parsed_source_file_name) - tmp_layout.storage.u.virt.list[u].source_dset.file_name = tmp_layout.storage.u.virt.list[u].parsed_source_file_name->name_segment; - else - tmp_layout.storage.u.virt.list[u].source_dset.file_name = tmp_layout.storage.u.virt.list[u].source_file_name; - if(tmp_layout.storage.u.virt.list[u].parsed_source_dset_name) - tmp_layout.storage.u.virt.list[u].source_dset.dset_name = tmp_layout.storage.u.virt.list[u].parsed_source_dset_name->name_segment; - else - tmp_layout.storage.u.virt.list[u].source_dset.dset_name = tmp_layout.storage.u.virt.list[u].source_dset_name; - } /* end if */ - - /* unlim_dim fields */ - tmp_layout.storage.u.virt.list[u].unlim_dim_source = H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_select); - tmp_layout.storage.u.virt.list[u].unlim_dim_virtual = H5S_get_select_unlim_dim(tmp_layout.storage.u.virt.list[u].source_dset.virtual_select); - tmp_layout.storage.u.virt.list[u].unlim_extent_source = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].unlim_extent_virtual = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].clip_size_source = HSIZE_UNDEF; - tmp_layout.storage.u.virt.list[u].clip_size_virtual = HSIZE_UNDEF; - - /* Clipped selections */ - if(tmp_layout.storage.u.virt.list[u].unlim_dim_virtual < 0) { - tmp_layout.storage.u.virt.list[u].source_dset.clipped_source_select = tmp_layout.storage.u.virt.list[u].source_select; - tmp_layout.storage.u.virt.list[u].source_dset.clipped_virtual_select = tmp_layout.storage.u.virt.list[u].source_dset.virtual_select; - } /* end if */ - - /* Update min_dims */ - if(H5D_virtual_update_min_dims(&tmp_layout, u) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to update virtual dataset minimum dimensions") - } /* end for */ - - /* Point at the newly set up struct */ - layout = &tmp_layout; - } /* end else */ - } /* end block */ - break; + /* Point at the newly set up struct */ + layout = &tmp_layout; + } /* end else */ + } /* end block */ + break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: @@ -675,7 +797,6 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_del * @@ -691,9 +812,9 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) */ static herr_t H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -701,14 +822,13 @@ H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na HDassert(value); /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_layout_copy * @@ -723,19 +843,18 @@ H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *na *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ - H5O_layout_t new_layout; - herr_t ret_value = SUCCEED; + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(layout); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + if (NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") /* Set new layout message directly into property list */ @@ -745,7 +864,6 @@ H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED siz FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_cmp * @@ -763,12 +881,11 @@ H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED siz *------------------------------------------------------------------------- */ static int -H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, - size_t H5_ATTR_UNUSED size) +H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_UNUSED size) { - const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ - *layout2 = (const H5O_layout_t *)_layout2; - herr_t ret_value = 0; /* Return value */ + const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ + *layout2 = (const H5O_layout_t *)_layout2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -778,81 +895,97 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, HDassert(size == sizeof(H5O_layout_t)); /* Check for different layout type */ - if(layout1->type < layout2->type) + if (layout1->type < layout2->type) HGOTO_DONE(-1) - if(layout1->type > layout2->type) + if (layout1->type > layout2->type) HGOTO_DONE(1) /* Compare non-dataset-specific fields in layout info */ - switch(layout1->type) { + switch (layout1->type) { case H5D_COMPACT: case H5D_CONTIGUOUS: break; - case H5D_CHUNKED: - { - unsigned u; /* Local index variable */ + case H5D_CHUNKED: { + unsigned u; /* Local index variable */ + + /* Check the number of dimensions */ + if (layout1->u.chunk.ndims < layout2->u.chunk.ndims) + HGOTO_DONE(-1) + if (layout1->u.chunk.ndims > layout2->u.chunk.ndims) + HGOTO_DONE(1) - /* Check the number of dimensions */ - if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) + /* Compare the chunk dims */ + for (u = 0; u < layout1->u.chunk.ndims - 1; u++) { + if (layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1) - if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) + if (layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) + HGOTO_DONE(1) + } /* end for */ + } /* end case */ + break; + + case H5D_VIRTUAL: { + htri_t equal; + int strcmp_ret; + size_t u; /* Local index variable */ + + /* Compare number of mappings */ + if (layout1->storage.u.virt.list_nused < layout2->storage.u.virt.list_nused) + HGOTO_DONE(-1) + if (layout1->storage.u.virt.list_nused > layout2->storage.u.virt.list_nused) + HGOTO_DONE(1) + + /* Iterate over mappings */ + for (u = 0; u < layout1->storage.u.virt.list_nused; u++) { + /* Compare virtual spaces. Note we cannot tell which is + * "greater", so just return 1 if different, -1 on failure. + */ + if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, + layout2->storage.u.virt.list[u].source_dset.virtual_select)) < + 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + if ((equal = H5S_SELECT_SHAPE_SAME( + layout1->storage.u.virt.list[u].source_dset.virtual_select, + layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) + HGOTO_DONE(-1) + if (!equal) HGOTO_DONE(1) - /* Compare the chunk dims */ - for(u = 0; u < layout1->u.chunk.ndims - 1; u++) { - if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) - HGOTO_DONE(-1) - if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) - HGOTO_DONE(1) - } /* end for */ - } /* end case */ - break; + /* Compare source file names */ + strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_file_name, + layout2->storage.u.virt.list[u].source_file_name); + if (strcmp_ret < 0) + HGOTO_DONE(-1) + if (strcmp_ret > 0) + HGOTO_DONE(1) - case H5D_VIRTUAL: - { - htri_t equal; - int strcmp_ret; - size_t u; /* Local index variable */ - - /* Compare number of mappings */ - if(layout1->storage.u.virt.list_nused < layout2->storage.u.virt.list_nused) HGOTO_DONE(-1) - if(layout1->storage.u.virt.list_nused > layout2->storage.u.virt.list_nused) HGOTO_DONE(1) - - /* Iterate over mappings */ - for(u = 0; u < layout1->storage.u.virt.list_nused; u++) { - /* Compare virtual spaces. Note we cannot tell which is - * "greater", so just return 1 if different, -1 on failure. - */ - if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - - /* Compare source file names */ - strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_file_name, layout2->storage.u.virt.list[u].source_file_name); - if(strcmp_ret < 0) HGOTO_DONE(-1) - if(strcmp_ret > 0) HGOTO_DONE(1) - - /* Compare source dataset names */ - strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_dset_name, layout2->storage.u.virt.list[u].source_dset_name); - if(strcmp_ret < 0) HGOTO_DONE(-1) - if(strcmp_ret > 0) HGOTO_DONE(1) - - /* Compare source spaces. Note we cannot tell which is - * "greater", so just return 1 if different, -1 on failure. - */ - if((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - if((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) HGOTO_DONE(-1) - if(!equal) - HGOTO_DONE(1) - } /* end for */ - } /* end block */ - break; + /* Compare source dataset names */ + strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_dset_name, + layout2->storage.u.virt.list[u].source_dset_name); + if (strcmp_ret < 0) + HGOTO_DONE(-1) + if (strcmp_ret > 0) + HGOTO_DONE(1) + + /* Compare source spaces. Note we cannot tell which is + * "greater", so just return 1 if different, -1 on failure. + */ + if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, + layout2->storage.u.virt.list[u].source_select)) < 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + if ((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, + layout2->storage.u.virt.list[u].source_select)) < 0) + HGOTO_DONE(-1) + if (!equal) + HGOTO_DONE(1) + } /* end for */ + } /* end block */ + break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: @@ -864,7 +997,6 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_close * @@ -879,10 +1011,9 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -890,14 +1021,13 @@ H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED si HDassert(value); /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_layout_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_set * @@ -913,11 +1043,11 @@ H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED si */ static herr_t H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -925,7 +1055,7 @@ H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Make copy of fill value */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Copy new fill value message over old one */ @@ -935,7 +1065,6 @@ H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_get * @@ -951,11 +1080,11 @@ H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -963,7 +1092,7 @@ H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Make copy of fill value */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Copy new fill value message over old one */ @@ -973,7 +1102,6 @@ H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_enc * @@ -992,12 +1120,12 @@ H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED static herr_t 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; - uint64_t enc_value; - unsigned enc_size = 0; + 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; + uint64_t enc_value; + unsigned enc_size = 0; FUNC_ENTER_STATIC @@ -1007,7 +1135,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) HDassert(fill); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode alloc and fill time */ *(*pp)++ = (uint8_t)fill->alloc_time; *(*pp)++ = (uint8_t)fill->fill_time; @@ -1016,7 +1144,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) INT64ENCODE(*pp, fill->size) /* Encode the fill value & datatype */ - if(fill->size > 0) { + if (fill->size > 0) { /* Encode the fill value itself */ H5MM_memcpy(*pp, (uint8_t *)fill->buf, (size_t)fill->size); *pp += fill->size; @@ -1024,12 +1152,12 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) /* Encode fill value datatype */ HDassert(fill->type); - if(H5T_encode(fill->type, NULL, &dt_size) < 0) + if (H5T_encode(fill->type, NULL, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") /* Encode the size of a size_t */ enc_value = (uint64_t)dt_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); /* Encode the size */ @@ -1038,27 +1166,27 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) /* Encode the size of the encoded datatype */ UINT64ENCODE_VAR(*pp, enc_value, enc_size); - if(H5T_encode(fill->type, *pp, &dt_size) < 0) + if (H5T_encode(fill->type, *pp, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") *pp += dt_size; } /* end if */ - } /* end if */ + } /* end if */ /* Calculate size needed for encoding */ *size += 2; *size += sizeof(int64_t); - if(fill->size > 0) { + if (fill->size > 0) { /* The size of the fill value buffer */ *size += (size_t)fill->size; /* calculate those if they were not calculated earlier */ - if(NULL == *pp) { + if (NULL == *pp) { /* Get the size of the encoded datatype */ HDassert(fill->type); - if(H5T_encode(fill->type, NULL, &dt_size) < 0) + if (H5T_encode(fill->type, NULL, &dt_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") enc_value = (uint64_t)dt_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); } *size += (1 + enc_size); *size += dt_size; @@ -1068,7 +1196,6 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_dec * @@ -1087,9 +1214,9 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return 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 */ FUNC_ENTER_STATIC @@ -1100,20 +1227,20 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) *fill = H5D_def_fill_g; /* Decode alloc and fill time */ - fill->alloc_time = (H5D_alloc_time_t)*(*pp)++; - fill->fill_time = (H5D_fill_time_t)*(*pp)++; + fill->alloc_time = (H5D_alloc_time_t) * (*pp)++; + fill->fill_time = (H5D_fill_time_t) * (*pp)++; /* Decode fill size */ INT64DECODE(*pp, fill->size) /* Check if there's a fill value */ - if(fill->size > 0) { - size_t dt_size = 0; + if (fill->size > 0) { + size_t dt_size = 0; uint64_t enc_value; unsigned enc_size; /* Allocate fill buffer and copy the contents in it */ - if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) + if (NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for fill value buffer") H5MM_memcpy((uint8_t *)fill->buf, *pp, (size_t)fill->size); *pp += fill->size; @@ -1126,7 +1253,7 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) dt_size = (size_t)enc_value; /* Decode type */ - if(NULL == (fill->type = H5T_decode(dt_size, *pp))) + if (NULL == (fill->type = H5T_decode(dt_size, *pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode fill value datatype") *pp += dt_size; } /* end if */ @@ -1135,7 +1262,6 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_del * @@ -1151,9 +1277,9 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) */ static herr_t H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1161,14 +1287,13 @@ H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED HDassert(value); /* Reset the old fill value message */ - if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + if (H5O_msg_reset(H5O_FILL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_copy * @@ -1183,19 +1308,18 @@ H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ - H5O_fill_t new_fill; - herr_t ret_value = SUCCEED; + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(fill); /* Make copy of fill value message */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + if (NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") /* Set new fill value message directly into property list */ @@ -1205,7 +1329,6 @@ H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_copy() */ - /*------------------------------------------------------------------------- * Function: H5P_fill_value_cmp * @@ -1222,13 +1345,12 @@ H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED *------------------------------------------------------------------------- */ int -H5P_fill_value_cmp(const void *_fill1, const void *_fill2, - size_t H5_ATTR_UNUSED size) +H5P_fill_value_cmp(const void *_fill1, const void *_fill2, size_t H5_ATTR_UNUSED size) { - const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */ - *fill2 = (const H5O_fill_t *)_fill2; - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */ + *fill2 = (const H5O_fill_t *)_fill2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1238,36 +1360,45 @@ H5P_fill_value_cmp(const void *_fill1, const void *_fill2, HDassert(size == sizeof(H5O_fill_t)); /* Check the size of fill values */ - if(fill1->size < fill2->size) HGOTO_DONE(-1); - if(fill1->size > fill2->size) HGOTO_DONE(1); + if (fill1->size < fill2->size) + HGOTO_DONE(-1); + if (fill1->size > fill2->size) + HGOTO_DONE(1); /* Check the types of the fill values */ - if(fill1->type == NULL && fill2->type != NULL) HGOTO_DONE(-1); - if(fill1->type != NULL && fill2->type == NULL) HGOTO_DONE(1); - if(fill1->type != NULL) - if((cmp_value = H5T_cmp(fill1->type, fill2->type, FALSE)) != 0) + if (fill1->type == NULL && fill2->type != NULL) + HGOTO_DONE(-1); + if (fill1->type != NULL && fill2->type == NULL) + HGOTO_DONE(1); + if (fill1->type != NULL) + if ((cmp_value = H5T_cmp(fill1->type, fill2->type, FALSE)) != 0) HGOTO_DONE(cmp_value); /* Check the fill values in the buffers */ - if(fill1->buf == NULL && fill2->buf != NULL) HGOTO_DONE(-1); - if(fill1->buf != NULL && fill2->buf == NULL) HGOTO_DONE(1); - if(fill1->buf != NULL) - if((cmp_value = HDmemcmp(fill1->buf, fill2->buf, (size_t)fill1->size)) != 0) + if (fill1->buf == NULL && fill2->buf != NULL) + HGOTO_DONE(-1); + if (fill1->buf != NULL && fill2->buf == NULL) + HGOTO_DONE(1); + if (fill1->buf != NULL) + if ((cmp_value = HDmemcmp(fill1->buf, fill2->buf, (size_t)fill1->size)) != 0) HGOTO_DONE(cmp_value); /* Check the allocation time for the fill values */ - if(fill1->alloc_time < fill2->alloc_time) HGOTO_DONE(-1); - if(fill1->alloc_time > fill2->alloc_time) HGOTO_DONE(1); + if (fill1->alloc_time < fill2->alloc_time) + HGOTO_DONE(-1); + if (fill1->alloc_time > fill2->alloc_time) + HGOTO_DONE(1); /* Check the fill time for the fill values */ - if(fill1->fill_time < fill2->fill_time) HGOTO_DONE(-1); - if(fill1->fill_time > fill2->fill_time) HGOTO_DONE(1); + if (fill1->fill_time < fill2->fill_time) + HGOTO_DONE(-1); + if (fill1->fill_time > fill2->fill_time) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fill_value_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_fill_value_close * @@ -1282,10 +1413,9 @@ H5P_fill_value_cmp(const void *_fill1, const void *_fill2, *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1293,14 +1423,13 @@ H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE HDassert(value); /* Reset the old fill value message */ - if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + if (H5O_msg_reset(H5O_FILL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_fill_value_close() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_set * @@ -1316,11 +1445,11 @@ H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE */ static herr_t H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1328,7 +1457,7 @@ H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Make copy of external file list */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Copy new external file list message over old one */ @@ -1338,7 +1467,6 @@ H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_get * @@ -1354,11 +1482,11 @@ H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU */ static herr_t H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1366,7 +1494,7 @@ H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Make copy of external file list */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Copy new external file list message over old one */ @@ -1376,7 +1504,6 @@ H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_enc * @@ -1396,11 +1523,11 @@ static herr_t 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; - unsigned enc_size; - uint64_t enc_value; + size_t len = 0; /* String length of slot name */ + size_t u; /* Local index variable */ + uint8_t ** pp = (uint8_t **)_pp; + unsigned enc_size; + uint64_t enc_value; FUNC_ENTER_STATIC_NOERR @@ -1411,20 +1538,20 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) HDcompile_assert(sizeof(hsize_t) <= sizeof(uint64_t)); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode number of slots used */ enc_value = (uint64_t)efl->nused; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* Encode file list */ - for(u = 0; u < efl->nused; u++) { + for (u = 0; u < efl->nused; u++) { /* Calculate length of slot name and encode it */ - len = HDstrlen(efl->slot[u].name) + 1; + len = HDstrlen(efl->slot[u].name) + 1; enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -1435,23 +1562,23 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) /* Encode offset */ enc_value = (uint64_t)efl->slot[u].offset; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode size */ enc_value = (uint64_t)efl->slot[u].size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); } /* end for */ - } /* end if */ + } /* end if */ /* Calculate size needed for encoding */ *size += (1 + H5VM_limit_enc_size((uint64_t)efl->nused)); - for(u = 0; u < efl->nused; u++) { + for (u = 0; u < efl->nused; u++) { len = HDstrlen(efl->slot[u].name) + 1; *size += (1 + H5VM_limit_enc_size((uint64_t)len)); *size += len; @@ -1462,7 +1589,6 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dcrt_ext_file_list_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_dec * @@ -1481,12 +1607,12 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - size_t u, nused; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1508,17 +1634,16 @@ H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) nused = (size_t)enc_value; /* Decode information for each slot */ - for(u = 0; u < nused; u++) { + for (u = 0; u < nused; u++) { size_t len; - if(efl->nused >= efl->nalloc) { - size_t na = efl->nalloc + H5O_EFL_ALLOC; - H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl->slot, - na * sizeof(H5O_efl_entry_t)); - if(!x) + if (efl->nused >= efl->nalloc) { + size_t na = efl->nalloc + H5O_EFL_ALLOC; + H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl->slot, na * sizeof(H5O_efl_entry_t)); + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl->nalloc = na; - efl->slot = x; + efl->slot = x; } /* end if */ /* Decode length of slot name */ @@ -1551,7 +1676,6 @@ H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_del * @@ -1567,9 +1691,9 @@ H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) */ static herr_t H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1577,14 +1701,13 @@ H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU HDassert(value); /* Reset the old efl message */ - if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + if (H5O_msg_reset(H5O_EFL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_copy * @@ -1599,19 +1722,18 @@ H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU *-------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ - H5O_efl_t new_efl; - herr_t ret_value = SUCCEED; + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC HDassert(efl); /* Make copy of efl message */ - if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + if (NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") /* Set new efl message directly into property list */ @@ -1621,7 +1743,6 @@ H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_cmp * @@ -1639,13 +1760,12 @@ H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU *------------------------------------------------------------------------- */ static int -H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, - size_t H5_ATTR_UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t H5_ATTR_UNUSED size) { - const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ - *efl2 = (const H5O_efl_t *)_efl2; - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ + *efl2 = (const H5O_efl_t *)_efl2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1655,47 +1775,60 @@ H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, HDassert(size == sizeof(H5O_efl_t)); /* Check the number of allocated efl entries */ - if(efl1->nalloc < efl2->nalloc) HGOTO_DONE(-1); - if(efl1->nalloc > efl2->nalloc) HGOTO_DONE(1); + if (efl1->nalloc < efl2->nalloc) + HGOTO_DONE(-1); + if (efl1->nalloc > efl2->nalloc) + HGOTO_DONE(1); /* Check the number of used efl entries */ - if(efl1->nused < efl2->nused) HGOTO_DONE(-1); - if(efl1->nused > efl2->nused) HGOTO_DONE(1); + if (efl1->nused < efl2->nused) + HGOTO_DONE(-1); + if (efl1->nused > efl2->nused) + HGOTO_DONE(1); /* Check the efl entry information */ - if(efl1->slot == NULL && efl2->slot != NULL) HGOTO_DONE(-1); - if(efl1->slot != NULL && efl2->slot == NULL) HGOTO_DONE(1); - if(efl1->slot != NULL && efl1->nused > 0) { - size_t u; /* Local index variable */ + if (efl1->slot == NULL && efl2->slot != NULL) + HGOTO_DONE(-1); + if (efl1->slot != NULL && efl2->slot == NULL) + HGOTO_DONE(1); + if (efl1->slot != NULL && efl1->nused > 0) { + size_t u; /* Local index variable */ /* Loop through all entries, comparing them */ - for(u = 0; u < efl1->nused; u++) { + for (u = 0; u < efl1->nused; u++) { /* Check the name offset of the efl entry */ - if(efl1->slot[u].name_offset < efl2->slot[u].name_offset) HGOTO_DONE(-1); - if(efl1->slot[u].name_offset > efl2->slot[u].name_offset) HGOTO_DONE(1); + if (efl1->slot[u].name_offset < efl2->slot[u].name_offset) + HGOTO_DONE(-1); + if (efl1->slot[u].name_offset > efl2->slot[u].name_offset) + HGOTO_DONE(1); /* Check the name of the efl entry */ - if(efl1->slot[u].name == NULL && efl2->slot[u].name != NULL) HGOTO_DONE(-1); - if(efl1->slot[u].name != NULL && efl2->slot[u].name == NULL) HGOTO_DONE(1); - if(efl1->slot[u].name != NULL) - if((cmp_value = HDstrcmp(efl1->slot[u].name, efl2->slot[u].name)) != 0) + if (efl1->slot[u].name == NULL && efl2->slot[u].name != NULL) + HGOTO_DONE(-1); + if (efl1->slot[u].name != NULL && efl2->slot[u].name == NULL) + HGOTO_DONE(1); + if (efl1->slot[u].name != NULL) + if ((cmp_value = HDstrcmp(efl1->slot[u].name, efl2->slot[u].name)) != 0) HGOTO_DONE(cmp_value); /* Check the file offset of the efl entry */ - if(efl1->slot[u].offset < efl2->slot[u].offset) HGOTO_DONE(-1); - if(efl1->slot[u].offset > efl2->slot[u].offset) HGOTO_DONE(1); + if (efl1->slot[u].offset < efl2->slot[u].offset) + HGOTO_DONE(-1); + if (efl1->slot[u].offset > efl2->slot[u].offset) + HGOTO_DONE(1); /* Check the file size of the efl entry */ - if(efl1->slot[u].size < efl2->slot[u].size) HGOTO_DONE(-1); - if(efl1->slot[u].size > efl2->slot[u].size) HGOTO_DONE(1); + if (efl1->slot[u].size < efl2->slot[u].size) + HGOTO_DONE(-1); + if (efl1->slot[u].size > efl2->slot[u].size) + HGOTO_DONE(1); } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_close * @@ -1710,10 +1843,9 @@ H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, *------------------------------------------------------------------------- */ static herr_t -H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1721,14 +1853,13 @@ H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN HDassert(value); /* Reset the old efl message */ - if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + if (H5O_msg_reset(H5O_EFL_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_ext_file_list_close() */ - /*------------------------------------------------------------------------- * Function: H5P__set_layout * @@ -1744,25 +1875,25 @@ H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UN static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { - unsigned alloc_time_state; /* State of allocation time property */ - herr_t ret_value = SUCCEED; /* return value */ + unsigned alloc_time_state; /* State of allocation time property */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC /* Get the allocation time state */ - if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get space allocation time state") /* If we still have the "default" allocation time, change it according to the new layout */ - if(alloc_time_state) { - H5O_fill_t fill; /* Fill value */ + if (alloc_time_state) { + H5O_fill_t fill; /* Fill value */ /* Get current fill value info */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set the default based on layout */ - switch(layout->type) { + switch (layout->type) { case H5D_COMPACT: fill.alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -1783,12 +1914,12 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) } /* end switch */ /* Set updated fill value info */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") } /* end if */ /* Set layout value */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) + if (H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -1796,7 +1927,7 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) } /* end H5P__set_layout() */ #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - + /*------------------------------------------------------------------------- * Function: H5P__init_def_layout * @@ -1813,21 +1944,21 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) static herr_t H5P__init_def_layout(void) { - const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; + const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; - const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; + const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; const H5O_storage_virtual_t def_store_virtual = H5D_DEF_STORAGE_VIRTUAL_INIT; FUNC_ENTER_STATIC_NOERR /* Initialize the default layout info for non-contigous layouts */ - H5D_def_layout_compact_g.storage.type = H5D_COMPACT; + H5D_def_layout_compact_g.storage.type = H5D_COMPACT; H5D_def_layout_compact_g.storage.u.compact = def_store_compact; - H5D_def_layout_chunk_g.u.chunk = def_layout_chunk; - H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED; - H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; - H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL; - H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual; + H5D_def_layout_chunk_g.u.chunk = def_layout_chunk; + H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED; + H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; + H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL; + H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual; /* Note that we've initialized the default values */ H5P_dcrt_def_layout_init_g = TRUE; @@ -1836,7 +1967,6 @@ H5P__init_def_layout(void) } /* end H5P__init_def_layout() */ #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /*------------------------------------------------------------------------- * Function: H5Pset_layout * @@ -1852,32 +1982,32 @@ 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 */ - const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDl", plist_id, layout_type); /* Check arguments */ - if(layout_type < 0 || layout_type >= H5D_NLAYOUTS) + if (layout_type < 0 || layout_type >= H5D_NLAYOUTS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get pointer to correct default layout */ - switch(layout_type) { + switch (layout_type) { case H5D_COMPACT: layout = &H5D_def_layout_compact_g; break; @@ -1901,14 +2031,13 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) } /* end switch */ /* Set value */ - if(H5P__set_layout(plist, layout) < 0) + if (H5P__set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_layout() */ - /*------------------------------------------------------------------------- * Function: H5Pget_layout * @@ -1926,19 +2055,19 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) H5D_layout_t H5Pget_layout(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout property */ - H5D_layout_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout property */ + H5D_layout_t ret_value; /* Return value */ FUNC_ENTER_API(H5D_LAYOUT_ERROR) H5TRACE1("Dl", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID") /* Peek at layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout") /* Set return value */ @@ -1948,7 +2077,6 @@ H5Pget_layout(hid_t plist_id) FUNC_LEAVE_API(ret_value) } /* ed H5Pget_layout() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk * @@ -1969,29 +2097,29 @@ H5Pget_layout(hid_t plist_id) herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ - uint64_t chunk_nelmts; /* Number of elements in chunk */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ + uint64_t chunk_nelmts; /* Number of elements in chunk */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIs*[a1]h", plist_id, ndims, dim); /* Check arguments */ - if(ndims <= 0) + if (ndims <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality must be positive") - if(ndims > H5S_MAX_RANK) + if (ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk dimensionality is too large") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -1999,31 +2127,30 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) H5MM_memcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; - for(u = 0; u < (unsigned)ndims; u++) { - if(dim[u] == 0) + for (u = 0; u < (unsigned)ndims; u++) { + if (dim[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive") - if(dim[u] != (dim[u] & 0xffffffff)) + if (dim[u] != (dim[u] & 0xffffffff)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be less than 2^32") chunk_nelmts *= dim[u]; - if(chunk_nelmts > (uint64_t)0xffffffff) + if (chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ - } /* end for */ + } /* end for */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set chunk information in property list */ chunk_layout.u.chunk.ndims = (unsigned)ndims; - if(H5P__set_layout(plist, &chunk_layout) < 0) + if (H5P__set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk * @@ -2042,30 +2169,30 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) *------------------------------------------------------------------------- */ int -H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) +H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[] /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - int ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Is", "iIsx", plist_id, max_ndims, dim); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Peek at the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(dim) { - unsigned u; /* Local index variable */ + if (dim) { + unsigned u; /* Local index variable */ /* Get the dimension sizes */ - for(u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) + for (u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) dim[u] = layout.u.chunk.dim[u]; } /* end if */ @@ -2076,7 +2203,6 @@ H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk() */ - /*------------------------------------------------------------------------- * Function: H5Pset_virtual * @@ -2098,63 +2224,62 @@ H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) *------------------------------------------------------------------------- */ 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) +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; /* 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 */ - 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 */ - hbool_t free_list = FALSE; /* Whether to free the list of virtual entries */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + hbool_t free_list = FALSE; /* Whether to free the list of virtual entries */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "ii*s*si", dcpl_id, vspace_id, src_file_name, src_dset_name, - src_space_id); + H5TRACE5("e", "ii*s*si", dcpl_id, vspace_id, src_file_name, src_dset_name, src_space_id); /* Check arguments */ - if(!src_file_name) + if (!src_file_name) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "source file name not provided") - if(!src_dset_name) + if (!src_dset_name) HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "source dataset name not provided") - if(NULL == (vspace = (H5S_t *)H5I_object_verify(vspace_id, H5I_DATASPACE))) + if (NULL == (vspace = (H5S_t *)H5I_object_verify(vspace_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace") /* Check selections for validity */ - if(H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0) + if (H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "invalid mapping selections") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current layout */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") retrieved_layout = TRUE; /* If the layout was not already virtual, Start with default virtual layout. * Otherwise, add the mapping to the current list. */ - if(virtual_layout.type == H5D_VIRTUAL) + if (virtual_layout.type == H5D_VIRTUAL) /* Save old list pointer for error recovery */ old_list = virtual_layout.storage.u.virt.list; else { /* Reset the old layout */ - if(H5O_msg_reset(H5O_LAYOUT_ID, &virtual_layout) < 0) + if (H5O_msg_reset(H5O_LAYOUT_ID, &virtual_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") /* Copy the default virtual layout */ @@ -2165,61 +2290,64 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, } /* end else */ /* Expand list if necessary */ - if(virtual_layout.storage.u.virt.list_nused == virtual_layout.storage.u.virt.list_nalloc) { - H5O_storage_virtual_ent_t *x; /* Pointer to the new list */ + if (virtual_layout.storage.u.virt.list_nused == virtual_layout.storage.u.virt.list_nalloc) { + H5O_storage_virtual_ent_t *x; /* Pointer to the new list */ size_t new_alloc = MAX(H5D_VIRTUAL_DEF_LIST_SIZE, virtual_layout.storage.u.virt.list_nalloc * 2); /* Expand size of entry list */ - if(NULL == (x = (H5O_storage_virtual_ent_t *)H5MM_realloc(virtual_layout.storage.u.virt.list, new_alloc * sizeof(H5O_storage_virtual_ent_t)))) + if (NULL == (x = (H5O_storage_virtual_ent_t *)H5MM_realloc( + virtual_layout.storage.u.virt.list, new_alloc * sizeof(H5O_storage_virtual_ent_t)))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't reallocate virtual dataset mapping list") - virtual_layout.storage.u.virt.list = x; + virtual_layout.storage.u.virt.list = x; virtual_layout.storage.u.virt.list_nalloc = new_alloc; } /* end if */ /* Add virtual dataset mapping entry */ ent = &virtual_layout.storage.u.virt.list[virtual_layout.storage.u.virt.list_nused]; - HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ - if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) + HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ + if (NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") - if(NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) + if (NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) + if (NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) + if (NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") - if(H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) + if (H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, + &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) + if (H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, + &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") - if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { - if(ent->parsed_source_file_name) + if ((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { + if (ent->parsed_source_file_name) ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; else ent->source_dset.file_name = ent->source_file_name; - if(ent->parsed_source_dset_name) + if (ent->parsed_source_dset_name) ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; else ent->source_dset.dset_name = ent->source_dset_name; } /* end if */ - ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); + ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); ent->unlim_dim_virtual = H5S_get_select_unlim_dim(vspace); - if(ent->unlim_dim_virtual < 0) { - ent->source_dset.clipped_source_select = ent->source_select; + if (ent->unlim_dim_virtual < 0) { + ent->source_dset.clipped_source_select = ent->source_select; ent->source_dset.clipped_virtual_select = ent->source_dset.virtual_select; } /* end if */ - ent->unlim_extent_source = HSIZE_UNDEF; + ent->unlim_extent_source = HSIZE_UNDEF; ent->unlim_extent_virtual = HSIZE_UNDEF; - ent->clip_size_source = HSIZE_UNDEF; - ent->clip_size_virtual = HSIZE_UNDEF; - ent->source_space_status = H5O_VIRTUAL_STATUS_USER; + ent->clip_size_source = HSIZE_UNDEF; + ent->clip_size_virtual = HSIZE_UNDEF; + ent->source_space_status = H5O_VIRTUAL_STATUS_USER; ent->virtual_space_status = H5O_VIRTUAL_STATUS_USER; /* Check entry for validity */ - if(H5D_virtual_check_mapping_post(ent) < 0) + if (H5D_virtual_check_mapping_post(ent) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid mapping entry") /* Update min_dims */ - if(H5D_virtual_update_min_dims(&virtual_layout, virtual_layout.storage.u.virt.list_nused) < 0) + if (H5D_virtual_update_min_dims(&virtual_layout, virtual_layout.storage.u.virt.list_nused) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to update virtual dataset minimum dimensions") /* Finish adding entry */ @@ -2228,25 +2356,25 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, done: /* Set VDS layout information in property list */ /* (Even on failure, so there's not a mangled layout struct in the list) */ - if(retrieved_layout) { - if(H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) { + if (retrieved_layout) { + if (H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) { HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - if(old_list != virtual_layout.storage.u.virt.list) + if (old_list != virtual_layout.storage.u.virt.list) free_list = TRUE; } /* end if */ - } /* end if */ + } /* end if */ /* Check if the entry has been partly allocated but not added to the * property list or not included in list_nused */ - if(ret_value < 0) { + if (ret_value < 0) { /* Free incomplete entry if present */ - if(ent) { + if (ent) { ent->source_file_name = (char *)H5MM_xfree(ent->source_file_name); ent->source_dset_name = (char *)H5MM_xfree(ent->source_dset_name); - if(ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) + if (ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") ent->source_dset.virtual_select = NULL; - if(ent->source_select && H5S_close(ent->source_select) < 0) + if (ent->source_select && H5S_close(ent->source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") ent->source_select = NULL; H5D_virtual_free_parsed_name(ent->parsed_source_file_name); @@ -2256,14 +2384,14 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, } /* end if */ /* Free list if necessary */ - if(free_list) - virtual_layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_xfree(virtual_layout.storage.u.virt.list); + if (free_list) + virtual_layout.storage.u.virt.list = + (H5O_storage_virtual_ent_t *)H5MM_xfree(virtual_layout.storage.u.virt.list); } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Pset_virtual() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_count * @@ -2279,24 +2407,24 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, *------------------------------------------------------------------------- */ herr_t -H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/) +H5Pget_virtual_count(hid_t dcpl_id, size_t *count /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", dcpl_id, count); - if(count) { + if (count) { /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Return the number of mappings */ @@ -2307,7 +2435,6 @@ H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_count() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_vspace * @@ -2327,45 +2454,44 @@ H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/) hid_t 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 */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + H5S_t * space = NULL; /* Dataspace pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "iz", dcpl_id, idx); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual space */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - if(NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_dset.virtual_select, FALSE, TRUE))) + if (NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Register ID */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: /* Free space on failure */ - if((ret_value < 0) && space) - if(H5S_close(space) < 0) + if ((ret_value < 0) && space) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_vspace() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_srcspace * @@ -2385,26 +2511,26 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t idx) hid_t 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 */ - hid_t ret_value = FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + H5S_t * space = NULL; /* Dataspace pointer */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "iz", dcpl_id, idx); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Check index */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); @@ -2412,27 +2538,28 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) * H5O_VIRTUAL_STATUS_CORRECT? -NAF */ /* If source space status is H5O_VIRTUAL_STATUS_INVALID, patch with bounds * of selection */ - if((H5O_VIRTUAL_STATUS_INVALID == layout.storage.u.virt.list[idx].source_space_status) - && (layout.storage.u.virt.list[idx].unlim_dim_source < 0)) { + if ((H5O_VIRTUAL_STATUS_INVALID == layout.storage.u.virt.list[idx].source_space_status) && + (layout.storage.u.virt.list[idx].unlim_dim_source < 0)) { hsize_t bounds_start[H5S_MAX_RANK]; hsize_t bounds_end[H5S_MAX_RANK]; - int rank; - int i; + int rank; + int i; /* Get rank of source space */ - if((rank = H5S_GET_EXTENT_NDIMS(layout.storage.u.virt.list[idx].source_select)) < 0) + if ((rank = H5S_GET_EXTENT_NDIMS(layout.storage.u.virt.list[idx].source_select)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get source space rank") /* Get bounds of selection */ - if(H5S_SELECT_BOUNDS(layout.storage.u.virt.list[idx].source_select, bounds_start, bounds_end) < 0) + if (H5S_SELECT_BOUNDS(layout.storage.u.virt.list[idx].source_select, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection bounds") /* Adjust bounds to extent */ - for(i = 0; i < rank; i++) + for (i = 0; i < rank; i++) bounds_end[i]++; /* Set extent */ - if(H5S_set_extent_simple(layout.storage.u.virt.list[idx].source_select, (unsigned)rank, bounds_end, NULL) < 0) + if (H5S_set_extent_simple(layout.storage.u.virt.list[idx].source_select, (unsigned)rank, bounds_end, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set source space extent") /* Update source space status */ @@ -2440,23 +2567,22 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) } /* end if */ /* Get the source space */ - if(NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_select, FALSE, TRUE))) + if (NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Register ID */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") done: /* Free space on failure */ - if((ret_value < 0) && space) - if(H5S_close(space) < 0) + if ((ret_value < 0) && space) + if (H5S_close(space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_srcspace() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_filename * @@ -2487,32 +2613,31 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) *------------------------------------------------------------------------- */ ssize_t -H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name/*out*/, - size_t size) +H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name /*out*/, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "izxz", dcpl_id, idx, name, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual filename */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_file_name); - if(name && (size > 0)) + if (name && (size > 0)) (void)HDstrncpy(name, layout.storage.u.virt.list[idx].source_file_name, size); ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[idx].source_file_name); @@ -2520,7 +2645,6 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name/*out*/, FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_filename() */ - /*------------------------------------------------------------------------- * Function: H5Pget_virtual_dsetname * @@ -2550,32 +2674,31 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name/*out*/, *------------------------------------------------------------------------- */ ssize_t -H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name/*out*/, - size_t size) +H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name /*out*/, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "izxz", dcpl_id, idx, name, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_VIRTUAL != layout.type) + if (H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") /* Get the virtual filename */ - if(idx >= layout.storage.u.virt.list_nused) + if (idx >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_dset_name); - if(name && (size > 0)) + if (name && (size > 0)) (void)HDstrncpy(name, layout.storage.u.virt.list[idx].source_dset_name, size); ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[idx].source_dset_name); @@ -2583,7 +2706,6 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name/*out*/, FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_dsetname() */ - /*------------------------------------------------------------------------- * Function: H5Pset_chunk_opts * @@ -2600,57 +2722,56 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name/*out*/, herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned options) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information for setting chunk info */ - uint8_t layout_flags = 0; /* "options" translated into layout message flags format */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information for setting chunk info */ + uint8_t layout_flags = 0; /* "options" translated into layout message flags format */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, options); /* Check arguments */ - if(options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)) + if (options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unknown chunk options") #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") /* Translate options into flags that can be used with the layout message */ - if(options & H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) + if (options & H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) layout_flags |= H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS; /* Update the layout message, including the version (if necessary) */ /* This probably isn't the right way to do this, and should be changed once * this branch gets the "real" way to set the layout version */ layout.u.chunk.flags = layout_flags; - if(layout.version < H5O_LAYOUT_VERSION_4) + if (layout.version < H5O_LAYOUT_VERSION_4) layout.version = H5O_LAYOUT_VERSION_4; /* Set layout value */ - if(H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_chunk_opts() */ - /*------------------------------------------------------------------------- * Function: H5Pget_chunk_opts * @@ -2666,9 +2787,9 @@ H5Pset_chunk_opts(hid_t plist_id, unsigned options) herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *options) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_layout_t layout; /* Layout information for setting chunk info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_layout_t layout; /* Layout information for setting chunk info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, options); @@ -2677,26 +2798,26 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options) /* If the compiler doesn't support C99 designated initializers, check if * the default layout structs have been initialized yet or not. *ick* -QAK */ - if(!H5P_dcrt_def_layout_init_g) - if(H5P__init_def_layout() < 0) + if (!H5P_dcrt_def_layout_init_g) + if (H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the layout property */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout.type) + if (H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(options) { + if (options) { /* Translate options from flags that can be used with the layout message * to those known to the public */ *options = 0; - if(layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) + if (layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) *options |= H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS; } /* end if */ @@ -2704,7 +2825,6 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options) FUNC_LEAVE_API(ret_value) } /* end H5Pget_chunk_opts() */ - /*------------------------------------------------------------------------- * Function: H5Pset_external * @@ -2731,63 +2851,62 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options) herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) { - size_t idx; - hsize_t total, tmp; - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; + hsize_t total, tmp; + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*soh", plist_id, name, offset, size); /* Check arguments */ - if(!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(offset < 0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (offset < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) + if (efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") - if(H5O_EFL_UNLIMITED != size) { - for(idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { + if (H5O_EFL_UNLIMITED != size) { + for (idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { tmp = total + efl.slot[idx].size; - if(tmp <= total) + if (tmp <= total) HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") } /* end for */ - } /* end if */ + } /* end if */ /* Add to the list */ - if(efl.nused >= efl.nalloc) { - size_t na = efl.nalloc + H5O_EFL_ALLOC; - H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); + if (efl.nused >= efl.nalloc) { + size_t na = efl.nalloc + H5O_EFL_ALLOC; + H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); - if(!x) + if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl.nalloc = na; - efl.slot = x; + efl.slot = x; } /* end if */ - idx = efl.nused; + idx = efl.nused; efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ - efl.slot[idx].name = H5MM_xstrdup(name); - efl.slot[idx].offset = offset; - efl.slot[idx].size = size; + efl.slot[idx].name = H5MM_xstrdup(name); + efl.slot[idx].offset = offset; + efl.slot[idx].size = size; efl.nused++; - if(H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_external() */ - /*------------------------------------------------------------------------- * Function: H5Pget_external_count * @@ -2805,19 +2924,19 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) int H5Pget_external_count(hid_t plist_id) { - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; /* return value */ + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") /* Set return value */ @@ -2827,7 +2946,6 @@ H5Pget_external_count(hid_t plist_id) FUNC_LEAVE_API(ret_value) } /* end H5Pget_external_count() */ - /*------------------------------------------------------------------------- * Function: H5Pget_external * @@ -2853,40 +2971,39 @@ H5Pget_external_count(hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out*/, - off_t *offset/*out*/, hsize_t *size/*out*/) +H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, off_t *offset /*out*/, + hsize_t *size /*out*/) { - H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5O_efl_t efl; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIuzxxx", plist_id, idx, name_size, name, offset, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if (H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(idx >= efl.nused) + if (idx >= efl.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "external file index is out of range") /* Return values */ - if(name_size>0 && name) + if (name_size > 0 && name) HDstrncpy(name, efl.slot[idx].name, name_size); - if(offset) + if (offset) *offset = efl.slot[idx].offset; - if(size) + if (size) *size = efl.slot[idx].size; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_external() */ - /*------------------------------------------------------------------------- * Function: H5Pset_szip * @@ -2906,29 +3023,29 @@ H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out* herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - unsigned cd_values[2]; /* Filter parameters */ - unsigned int config_flags; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + unsigned cd_values[2]; /* Filter parameters */ + unsigned int config_flags; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, options_mask, pixels_per_block); - if(H5Z_get_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) + if (H5Z_get_filter_info(H5Z_FILTER_SZIP, &config_flags) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't get filter info") - if(!(config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) + if (!(config_flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED)) HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.") /* Check arguments */ - if((pixels_per_block % 2) == 1) + if ((pixels_per_block % 2) == 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is not even") - if(pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) + if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels_per_block is too large") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Always set K13 compression (and un-set CHIP compression) */ @@ -2943,22 +3060,21 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) options_mask &= (unsigned)(~(H5_SZIP_LSB_OPTION_MASK | H5_SZIP_MSB_OPTION_MASK)); /* Set the parameters for the filter */ - cd_values[0]=options_mask; - cd_values[1]=pixels_per_block; + cd_values[0] = options_mask; + cd_values[1] = pixels_per_block; /* Add the filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add szip filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_szip() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shuffle * @@ -2976,34 +3092,33 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) herr_t H5Pset_shuffle(hid_t plist_id) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shuffle() */ - /*------------------------------------------------------------------------- * Function: H5Pset_nbit * @@ -3019,34 +3134,33 @@ H5Pset_shuffle(hid_t plist_id) herr_t H5Pset_nbit(hid_t plist_id) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the nbit filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add nbit filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Pset_scaleoffset * @@ -3078,25 +3192,25 @@ H5Pset_nbit(hid_t plist_id) herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor) { - H5O_pline_t pline; - H5P_genplist_t *plist; /* Property list pointer */ - unsigned cd_values[2]; /* Filter parameters */ - herr_t ret_value=SUCCEED; /* return value */ + H5O_pline_t pline; + H5P_genplist_t *plist; /* Property list pointer */ + unsigned cd_values[2]; /* Filter parameters */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iZaIs", plist_id, scale_type, scale_factor); /* Check arguments */ - if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if (TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - if(scale_factor < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be >= 0") - if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") + if (scale_factor < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be >= 0") + if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set parameters for the filter @@ -3111,18 +3225,17 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac cd_values[1] = (unsigned)scale_factor; /* Add the scaleoffset filter */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - if(H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) + if (H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add scaleoffset filter to pipeline") - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fill_value * @@ -3143,76 +3256,77 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", plist_id, type_id, value); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current fill value */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Release the dynamic fill value components */ H5O_fill_reset_dyn(&fill); - if(value) { - H5T_t *type; /* Datatype for fill value */ - H5T_path_t *tpath; /* Conversion information */ + if (value) { + H5T_t * type; /* Datatype for fill value */ + H5T_path_t *tpath; /* Conversion information */ /* Retrieve pointer to datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set the fill value */ - if(NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) + if (NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy datatype") fill.size = (ssize_t)H5T_get_size(type); - if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) + if (NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value") H5MM_memcpy(fill.buf, value, (size_t)fill.size); /* Set up type conversion function */ - if(NULL == (tpath = H5T_path_find(type, type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") + if (NULL == (tpath = H5T_path_find(type, type))) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest data types") /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ - if(!H5T_path_noop(tpath)) { - uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + if (!H5T_path_noop(tpath)) { + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ /* Allocate a background buffer */ - if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)fill.size))) + if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Convert the fill value */ - if(H5T_convert(tpath, type_id, type_id, (size_t)1, (size_t)0, (size_t)0, fill.buf, bkg_buf) < 0) { - if(bkg_buf) + if (H5T_convert(tpath, type_id, type_id, (size_t)1, (size_t)0, (size_t)0, fill.buf, bkg_buf) < + 0) { + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ /* Release the background buffer */ - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ - } /* end if */ + } /* end if */ else fill.size = (-1); /* Update fill value in property list */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5P_get_fill_value * @@ -3230,15 +3344,15 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) *------------------------------------------------------------------------- */ herr_t -H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) +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 */ - hid_t src_id = -1; /*source datatype id */ - hid_t dst_id = -1; /*destination datatype id */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hid_t src_id = -1; /*source datatype id */ + hid_t dst_id = -1; /*destination datatype id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3248,23 +3362,23 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) * datatype conversion might not have resulted in zero. If fill value * is undefined, also return error. */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") - if(fill.size == -1) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined") + if (fill.size == -1) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined") /* Check for "default" fill value */ - if(fill.size == 0) { - HDmemset(value, 0, H5T_get_size(type)); - HGOTO_DONE(SUCCEED); + if (fill.size == 0) { + HDmemset(value, 0, H5T_get_size(type)); + HGOTO_DONE(SUCCEED); } /* end if */ - /* - * Can we convert between the source and destination datatypes? - */ - if(NULL == (tpath = H5T_path_find(fill.type, type))) + /* + * Can we convert between the source and destination datatypes? + */ + if (NULL == (tpath = H5T_path_find(fill.type, type))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") /* @@ -3272,41 +3386,40 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) * other than the fill value buffer that is large enough for both source * and destination. The app-supplied buffer might do okay. */ - if(H5T_get_size(type) >= H5T_get_size(fill.type)) { + if (H5T_get_size(type) >= H5T_get_size(fill.type)) { buf = value; - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end if */ else { - if(NULL == (buf = H5MM_calloc(H5T_get_size(fill.type)))) + if (NULL == (buf = H5MM_calloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") - if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(fill.type)))) + if (H5T_path_bkg(tpath) && NULL == (bkg = H5MM_calloc(H5T_get_size(fill.type)))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end else */ H5MM_memcpy(buf, fill.buf, H5T_get_size(fill.type)); /* Do the conversion */ - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_TRANSIENT), FALSE)) < 0) + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") - if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) + if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "datatype conversion failed") - if(buf != value) + if (buf != value) H5MM_memcpy(value, buf, H5T_get_size(type)); done: - if(buf != value) + if (buf != value) H5MM_xfree(buf); - if(bkg != value) + if (bkg != value) H5MM_xfree(bkg); - if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + if (src_id >= 0 && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") - if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fill_value * @@ -3324,34 +3437,33 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_t * type; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iix", plist_id, type_id, value); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,"no fill value output buffer") + if (!value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no fill value output buffer") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the fill value */ - if(H5P_get_fill_value(plist, type, value) < 0) + if (H5P_get_fill_value(plist, type, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_value() */ - /*------------------------------------------------------------------------- * Function: H5P_is_fill_value_defined * @@ -3375,16 +3487,16 @@ H5P_is_fill_value_defined(const H5O_fill_t *fill, H5D_fill_value_t *status) HDassert(status); /* Check if the fill value was "unset" */ - if(fill->size == -1 && !fill->buf) - *status = H5D_FILL_VALUE_UNDEFINED; + if (fill->size == -1 && !fill->buf) + *status = H5D_FILL_VALUE_UNDEFINED; /* Check if the fill value was set to the default fill value by the library */ - else if(fill->size == 0 && !fill->buf) - *status = H5D_FILL_VALUE_DEFAULT; + else if (fill->size == 0 && !fill->buf) + *status = H5D_FILL_VALUE_DEFAULT; /* Check if the fill value was set by the application */ - else if(fill->size > 0 && fill->buf) - *status = H5D_FILL_VALUE_USER_DEFINED; + else if (fill->size > 0 && fill->buf) + *status = H5D_FILL_VALUE_USER_DEFINED; else { - *status = H5D_FILL_VALUE_ERROR; + *status = H5D_FILL_VALUE_ERROR; HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "invalid combination of fill-value info") } /* end else */ @@ -3392,7 +3504,6 @@ H5P_is_fill_value_defined(const H5O_fill_t *fill, H5D_fill_value_t *status) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_is_fill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5P_fill_value_defined * @@ -3408,26 +3519,25 @@ H5P_is_fill_value_defined(const H5O_fill_t *fill, H5D_fill_value_t *status) herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status) { - H5O_fill_t fill; /* Fill value to query */ - herr_t ret_value = SUCCEED; + H5O_fill_t fill; /* Fill value to query */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) HDassert(status); /* Get the fill value struct */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Get the fill-value status */ - if(H5P_is_fill_value_defined(&fill, status) < 0) + if (H5P_is_fill_value_defined(&fill, status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_fill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5Pfill_value_defined * @@ -3443,8 +3553,8 @@ H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status) herr_t H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) { - H5P_genplist_t *plist; /* Property list to query */ - herr_t ret_value = SUCCEED; + H5P_genplist_t *plist; /* Property list to query */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*DF", plist_id, status); @@ -3452,18 +3562,17 @@ H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) HDassert(status); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the fill-value status */ - if(H5P_fill_value_defined(plist, status) < 0) + if (H5P_fill_value_defined(plist, status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't check fill value status") done: FUNC_LEAVE_API(ret_value) } /* end H5Pfill_value_defined() */ - /*------------------------------------------------------------------------- * Function: H5Pset_alloc_time * @@ -3481,32 +3590,32 @@ H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status) herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to modify */ - unsigned alloc_time_state; /* State of allocation time property */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to modify */ + unsigned alloc_time_state; /* State of allocation time property */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDa", plist_id, alloc_time); /* Check arguments */ - if(alloc_time < H5D_ALLOC_TIME_DEFAULT || alloc_time > H5D_ALLOC_TIME_INCR) + if (alloc_time < H5D_ALLOC_TIME_DEFAULT || alloc_time > H5D_ALLOC_TIME_INCR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid allocation time setting") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Check for resetting to default for layout type */ - if(alloc_time == H5D_ALLOC_TIME_DEFAULT) { - H5O_layout_t layout; /* Type of storage layout */ + if (alloc_time == H5D_ALLOC_TIME_DEFAULT) { + H5O_layout_t layout; /* Type of storage layout */ /* Peek at the storage layout */ - if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if (H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Set the default based on layout */ - switch(layout.type) { + switch (layout.type) { case H5D_COMPACT: alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -3537,23 +3646,22 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) alloc_time_state = 0; /* Retrieve previous fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.alloc_time = alloc_time; /* Set values */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") - if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + if (H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_alloc_time() */ - /*------------------------------------------------------------------------- * Function: H5Pget_alloc_time * @@ -3569,7 +3677,7 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) *------------------------------------------------------------------------- */ herr_t -H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) +H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time /*out*/) { herr_t ret_value = SUCCEED; /* return value */ @@ -3577,16 +3685,16 @@ H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) H5TRACE2("e", "ix", plist_id, alloc_time); /* Get values */ - if(alloc_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to query */ + if (alloc_time) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to query */ /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ @@ -3597,7 +3705,6 @@ H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_alloc_time() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fill_time * @@ -3614,37 +3721,36 @@ H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to modify */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to modify */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iDf", plist_id, fill_time); /* Check arguments */ - if(fill_time < H5D_FILL_TIME_ALLOC || fill_time > H5D_FILL_TIME_IFSET) + if (fill_time < H5D_FILL_TIME_ALLOC || fill_time > H5D_FILL_TIME_IFSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fill time setting") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve previous fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.fill_time = fill_time; /* Set values */ - if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fill_time() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fill_time * @@ -3659,7 +3765,7 @@ H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time) *------------------------------------------------------------------------- */ herr_t -H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) +H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time /*out*/) { herr_t ret_value = SUCCEED; /* return value */ @@ -3667,16 +3773,16 @@ H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) H5TRACE2("e", "ix", plist_id, fill_time); /* Set values */ - if(fill_time) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_fill_t fill; /* Fill value property to query */ + if (fill_time) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_fill_t fill; /* Fill value property to query */ /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if (H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ @@ -3687,7 +3793,6 @@ H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_time() */ - /*----------------------------------------------------------------------------- * Function: H5Pget_dset_no_attrs_hint * @@ -3716,14 +3821,14 @@ H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", dcpl_id, minimize); - if(NULL == minimize) + if (NULL == minimize) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "receiving pointer cannot be NULL") plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) + if (H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset oh minimize flag value") *minimize = setting; @@ -3732,7 +3837,6 @@ H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize) FUNC_LEAVE_API(ret_value) } /* H5Pget_dset_no_attrs_hint() */ - /*----------------------------------------------------------------------------- * Function: H5Pset_dset_no_attrs_hint * @@ -3762,16 +3866,15 @@ H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize) H5TRACE2("e", "ib", dcpl_id, minimize); plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); - if(NULL == plist) + if (NULL == plist) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) + if (H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get extant dset oh minimize flag value") - if(H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) + if (H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get dset oh minimize flag value") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_dset_no_attrs_hint() */ - diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index bcfc92299d2..bb705e2e605 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,56 +29,48 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*-------------------------------------------------------------------------- NAME H5Pregister1 @@ -219,51 +211,51 @@ REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, - H5P_prp_create_func_t prp_create, 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) +H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create, + 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) { - H5P_genclass_t *pclass; /* Property list class to modify */ - H5P_genclass_t *orig_pclass; /* Original property class */ - herr_t ret_value; /* Return value */ + H5P_genclass_t *pclass; /* Property list class to modify */ + H5P_genclass_t *orig_pclass; /* Original property class */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE10("e", "i*sz*xxxxxxx", cls_id, name, size, def_value, prp_create, - prp_set, prp_get, prp_delete, prp_copy, prp_close); + H5TRACE10("e", "i*sz*xxxxxxx", cls_id, name, size, def_value, prp_create, prp_set, prp_get, prp_delete, + prp_copy, prp_close); /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name"); - if(size > 0 && def_value == NULL) + if (size > 0 && def_value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default"); /* Create the new property list class */ orig_pclass = pclass; - if((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, NULL, prp_close)) < 0) + if ((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL, + prp_delete, prp_copy, NULL, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class"); /* Check if the property class changed and needs to be substituted in the ID */ - if(pclass != orig_pclass) { - H5P_genclass_t *old_pclass; /* Old property class */ + if (pclass != orig_pclass) { + H5P_genclass_t *old_pclass; /* Old property class */ /* Substitute the new property class in the ID */ - if(NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) + if (NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_pclass == orig_pclass); /* Close the previous class */ - if(H5P__close_class(orig_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(orig_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* H5Pregister1() */ +} /* H5Pregister1() */ - /*-------------------------------------------------------------------------- NAME H5Pinsert1 @@ -404,36 +396,34 @@ H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, REVISION LOG --------------------------------------------------------------------------*/ 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) +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) { - H5P_genplist_t *plist; /* Property list to modify */ - herr_t ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list to modify */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE9("e", "i*sz*xxxxxx", plist_id, name, size, value, prp_set, prp_get, - prp_delete, prp_copy, prp_close); + H5TRACE9("e", "i*sz*xxxxxx", plist_id, name, size, value, prp_set, prp_get, prp_delete, prp_copy, + prp_close); /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name") - if(size > 0 && value == NULL) + if (size > 0 && value == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default") /* Create the new property list class */ - if((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, - NULL, NULL, prp_delete, prp_copy, NULL, prp_close)) < 0) + if ((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy, + NULL, prp_close)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist") done: FUNC_LEAVE_API(ret_value) -} /* H5Pinsert1() */ +} /* H5Pinsert1() */ - /*------------------------------------------------------------------------- * Function: H5Pget_version * @@ -458,34 +448,81 @@ H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, *------------------------------------------------------------------------- */ herr_t -H5Pget_version(hid_t plist_id, unsigned *super/*out*/, unsigned *freelist/*out*/, - unsigned *stab/*out*/, unsigned *shhdr/*out*/) +H5Pget_version(hid_t plist_id, unsigned *super /*out*/, unsigned *freelist /*out*/, unsigned *stab /*out*/, + unsigned *shhdr /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ixxxx", plist_id, super, freelist, stab, shhdr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(super) - if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) + if (super) + if (H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version") - if(freelist) - *freelist = HDF5_FREESPACE_VERSION; /* (hard-wired) */ - if(stab) - *stab = HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ - if(shhdr) - *shhdr = HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ + if (freelist) + *freelist = HDF5_FREESPACE_VERSION; /* (hard-wired) */ + if (stab) + *stab = HDF5_OBJECTDIR_VERSION; /* (hard-wired) */ + if (shhdr) + *shhdr = HDF5_SHAREDHEADER_VERSION; /* (hard-wired) */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_version() */ +/*-------------------------------------------------------------------------- + NAME + H5Pencode1 + PURPOSE + Routine to convert the property values in a property list into a binary buffer + USAGE + herr_t H5Pencode1(plist_id, buf, nalloc) + hid_t plist_id; IN: Identifier to property list to encode + void *buf: OUT: buffer to gold the encoded plist + size_t *nalloc; IN/OUT: size of buffer needed to encode plist + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Encodes a property list into a binary buffer. If the buffer is NULL, then + the call will set the size needed to encode the plist in nalloc. Otherwise + the routine will encode the plist in buf. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc) +{ + H5P_genplist_t *plist; /* Property list to query */ + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*x*z", plist_id, buf, nalloc); + + /* Check arguments. */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Call the internal encode routine */ + if ((ret_value = H5P__encode(plist, TRUE, buf, nalloc)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list"); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pencode1() */ + /*------------------------------------------------------------------------- * Function: H5Pset_file_space * @@ -500,17 +537,17 @@ herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold) { - H5F_fspace_strategy_t new_strategy; /* File space strategy type */ - hbool_t new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */ - hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */ - H5F_file_space_type_t in_strategy = strategy; /* Input strategy */ - hsize_t in_threshold = threshold; /* Input threshold */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist = H5F_FREE_SPACE_PERSIST_DEF; /* Persisting free-space or not */ + hsize_t new_threshold = H5F_FREE_SPACE_THRESHOLD_DEF; /* Free-space section threshold */ + H5F_file_space_type_t in_strategy = strategy; /* Input strategy */ + hsize_t in_threshold = threshold; /* Input threshold */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFfh", plist_id, strategy, threshold); - if((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES) + if ((unsigned)in_strategy >= H5F_FILE_SPACE_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") /* * For 1.10.0 H5Pset_file_space: @@ -519,20 +556,20 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh * If threshold is zero, the property is not changed; * the existing threshold is retained. */ - if(!in_strategy) + if (!in_strategy) H5Pget_file_space(plist_id, &in_strategy, NULL); - if(!in_threshold) + if (!in_threshold) H5Pget_file_space(plist_id, NULL, &in_threshold); - switch(in_strategy) { + switch (in_strategy) { case H5F_FILE_SPACE_ALL_PERSIST: - new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - new_persist = TRUE; + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_persist = TRUE; new_threshold = in_threshold; break; case H5F_FILE_SPACE_ALL: - new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; + new_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; new_threshold = in_threshold; break; @@ -550,14 +587,13 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file space strategy") } - if(H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0) + if (H5Pset_file_space_strategy(plist_id, new_strategy, new_persist, new_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space * @@ -572,28 +608,28 @@ H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t thresh herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold) { - H5F_fspace_strategy_t new_strategy; /* File space strategy type */ - hbool_t new_persist; /* Persisting free-space or not */ - hsize_t new_threshold; /* Free-space section threshold */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_fspace_strategy_t new_strategy; /* File space strategy type */ + hbool_t new_persist; /* Persisting free-space or not */ + hsize_t new_threshold; /* Free-space section threshold */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Ff*h", plist_id, strategy, threshold); /* Get current file space info */ - if(H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0) + if (H5Pget_file_space_strategy(plist_id, &new_strategy, &new_persist, &new_threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") /* Get value(s) */ - if(strategy) { - switch(new_strategy) { + if (strategy) { + switch (new_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: - if(new_persist) + if (new_persist) *strategy = H5F_FILE_SPACE_ALL_PERSIST; else *strategy = H5F_FILE_SPACE_ALL; - break; + break; case H5F_FSPACE_STRATEGY_AGGR: *strategy = H5F_FILE_SPACE_AGGR_VFD; @@ -610,11 +646,10 @@ H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *thre } } - if(threshold) + if (threshold) *threshold = new_threshold; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index c5dac23f32a..2d6b313b1f2 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,21 +26,19 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -48,41 +46,44 @@ /* ======== Data transfer properties ======== */ /* Definitions for maximum temp buffer size property */ -#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t) -#define H5D_XFER_MAX_TEMP_BUF_DEF H5D_TEMP_BUF_SIZE -#define H5D_XFER_MAX_TEMP_BUF_ENC H5P__encode_size_t -#define H5D_XFER_MAX_TEMP_BUF_DEC H5P__decode_size_t +#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t) +#define H5D_XFER_MAX_TEMP_BUF_DEF H5D_TEMP_BUF_SIZE +#define H5D_XFER_MAX_TEMP_BUF_ENC H5P__encode_size_t +#define H5D_XFER_MAX_TEMP_BUF_DEC H5P__decode_size_t /* Definitions for type conversion buffer property */ -#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *) -#define H5D_XFER_TCONV_BUF_DEF NULL +#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *) +#define H5D_XFER_TCONV_BUF_DEF NULL /* Definitions for background buffer property */ -#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *) -#define H5D_XFER_BKGR_BUF_DEF NULL +#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *) +#define H5D_XFER_BKGR_BUF_DEF NULL /* Definitions for background buffer type property */ -#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) -#define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO -#define H5D_XFER_BKGR_BUF_TYPE_ENC H5P__dxfr_bkgr_buf_type_enc -#define H5D_XFER_BKGR_BUF_TYPE_DEC H5P__dxfr_bkgr_buf_type_dec +#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t) +#define H5D_XFER_BKGR_BUF_TYPE_DEF H5T_BKG_NO +#define H5D_XFER_BKGR_BUF_TYPE_ENC H5P__dxfr_bkgr_buf_type_enc +#define H5D_XFER_BKGR_BUF_TYPE_DEC H5P__dxfr_bkgr_buf_type_dec /* Definitions for B-tree node splitting ratio property */ /* (These default B-tree node splitting ratios are also used for splitting * group's B-trees as well as chunked dataset's B-trees - QAK) */ #define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3]) -#define H5D_XFER_BTREE_SPLIT_RATIO_DEF {0.1f, 0.5f, 0.9f} -#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc -#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec +#define H5D_XFER_BTREE_SPLIT_RATIO_DEF \ + { \ + 0.1f, 0.5f, 0.9f \ + } +#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc +#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec /* Definitions for vlen allocation function property */ -#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t) -#define H5D_XFER_VLEN_ALLOC_DEF H5D_VLEN_ALLOC +#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t) +#define H5D_XFER_VLEN_ALLOC_DEF H5D_VLEN_ALLOC /* Definitions for vlen allocation info property */ -#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *) -#define H5D_XFER_VLEN_ALLOC_INFO_DEF H5D_VLEN_ALLOC_INFO +#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *) +#define H5D_XFER_VLEN_ALLOC_INFO_DEF H5D_VLEN_ALLOC_INFO /* Definitions for vlen free function property */ -#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t) -#define H5D_XFER_VLEN_FREE_DEF H5D_VLEN_FREE +#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t) +#define H5D_XFER_VLEN_FREE_DEF H5D_VLEN_FREE /* Definitions for vlen free info property */ -#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *) -#define H5D_XFER_VLEN_FREE_INFO_DEF H5D_VLEN_FREE_INFO +#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *) +#define H5D_XFER_VLEN_FREE_INFO_DEF H5D_VLEN_FREE_INFO /* Definitions for hyperslab vector size property */ /* (Be cautious about increasing the default size, there are arrays allocated * on the stack which depend on it - QAK) @@ -99,71 +100,74 @@ */ /* Definitions for I/O transfer mode property */ -#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) -#define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT -#define H5D_XFER_IO_XFER_MODE_ENC H5P__dxfr_io_xfer_mode_enc -#define H5D_XFER_IO_XFER_MODE_DEC H5P__dxfr_io_xfer_mode_dec +#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t) +#define H5D_XFER_IO_XFER_MODE_DEF H5FD_MPIO_INDEPENDENT +#define H5D_XFER_IO_XFER_MODE_ENC H5P__dxfr_io_xfer_mode_enc +#define H5D_XFER_IO_XFER_MODE_DEC H5P__dxfr_io_xfer_mode_dec /* Definitions for optimization of MPI-IO transfer mode property */ -#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE sizeof(H5FD_mpio_collective_opt_t) -#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF H5FD_MPIO_COLLECTIVE_IO -#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC H5P__dxfr_mpio_collective_opt_enc -#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC H5P__dxfr_mpio_collective_opt_dec -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE sizeof(H5FD_mpio_chunk_opt_t) -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF H5FD_MPIO_CHUNK_DEFAULT -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC H5P__dxfr_mpio_chunk_opt_hard_enc -#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC H5P__dxfr_mpio_chunk_opt_hard_dec -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE sizeof(unsigned) -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF H5D_ONE_LINK_CHUNK_IO_THRESHOLD -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC H5P__encode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC H5P__decode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned) -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF H5D_MULTI_CHUNK_IO_COL_THRESHOLD -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC H5P__encode_unsigned -#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC H5P__decode_unsigned +#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE sizeof(H5FD_mpio_collective_opt_t) +#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF H5FD_MPIO_COLLECTIVE_IO +#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC H5P__dxfr_mpio_collective_opt_enc +#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC H5P__dxfr_mpio_collective_opt_dec +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE sizeof(H5FD_mpio_chunk_opt_t) +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF H5FD_MPIO_CHUNK_DEFAULT +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC H5P__dxfr_mpio_chunk_opt_hard_enc +#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC H5P__dxfr_mpio_chunk_opt_hard_dec +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE sizeof(unsigned) +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF H5D_ONE_LINK_CHUNK_IO_THRESHOLD +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC H5P__encode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC H5P__decode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned) +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF H5D_MULTI_CHUNK_IO_COL_THRESHOLD +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC H5P__encode_unsigned +#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC H5P__decode_unsigned /* Definitions for chunk opt mode property. */ -#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t) -#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF H5D_MPIO_NO_CHUNK_OPTIMIZATION +#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t) +#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF H5D_MPIO_NO_CHUNK_OPTIMIZATION /* Definitions for chunk io mode property. */ -#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t) -#define H5D_MPIO_ACTUAL_IO_MODE_DEF H5D_MPIO_NO_COLLECTIVE +#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t) +#define H5D_MPIO_ACTUAL_IO_MODE_DEF H5D_MPIO_NO_COLLECTIVE /* Definitions for cause of broken collective io property */ -#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t) -#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF H5D_MPIO_COLLECTIVE +#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t) +#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF H5D_MPIO_COLLECTIVE /* Definitions for EDC property */ -#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) -#define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC -#define H5D_XFER_EDC_ENC H5P__dxfr_edc_enc -#define H5D_XFER_EDC_DEC H5P__dxfr_edc_dec +#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t) +#define H5D_XFER_EDC_DEF H5Z_ENABLE_EDC +#define H5D_XFER_EDC_ENC H5P__dxfr_edc_enc +#define H5D_XFER_EDC_DEC H5P__dxfr_edc_dec /* Definitions for filter callback function property */ -#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t) -#define H5D_XFER_FILTER_CB_DEF {NULL,NULL} +#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t) +#define H5D_XFER_FILTER_CB_DEF \ + { \ + NULL, NULL \ + } /* Definitions for type conversion callback function property */ -#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t) -#define H5D_XFER_CONV_CB_DEF {NULL,NULL} +#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t) +#define H5D_XFER_CONV_CB_DEF \ + { \ + NULL, NULL \ + } /* Definitions for data transform property */ -#define H5D_XFER_XFORM_SIZE sizeof(void *) -#define H5D_XFER_XFORM_DEF NULL -#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set -#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get -#define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc -#define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec -#define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del -#define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy -#define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp -#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close - +#define H5D_XFER_XFORM_SIZE sizeof(void *) +#define H5D_XFER_XFORM_DEF NULL +#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set +#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get +#define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc +#define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec +#define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del +#define H5D_XFER_XFORM_COPY H5P__dxfr_xform_copy +#define H5D_XFER_XFORM_CMP H5P__dxfr_xform_cmp +#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -184,15 +188,14 @@ static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **pp, si static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **pp, void *value); static herr_t H5P__dxfr_edc_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_edc_dec(const void **pp, void *value); -static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dxfr_xform_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_xform_dec(const void **pp, void *value); -static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__dxfr_xform_copy(const char* name, size_t size, void* value); -static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__dxfr_xform_close(const char* name, size_t size, void* value); - +static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value); +static int H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -200,58 +203,67 @@ static herr_t H5P__dxfr_xform_close(const char* name, size_t size, void* value); /* Data transfer property list class library initialization object */ const H5P_libclass_t H5P_CLS_DXFR[1] = {{ - "data transfer", /* Class name for debugging */ - H5P_TYPE_DATASET_XFER, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_DATASET_XFER_g, /* Pointer to class */ - &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */ - H5P__dxfr_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "data transfer", /* Class name for debugging */ + H5P_TYPE_DATASET_XFER, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_DATASET_XFER_g, /* Pointer to class */ + &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */ + H5P__dxfr_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /***************************/ /* Local Private Variables */ /***************************/ /* Property value defaults */ -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 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 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 */ -static const H5MM_allocate_t H5D_def_vlen_alloc_g = H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */ -static const void *H5D_def_vlen_alloc_info_g = H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */ -static const H5MM_free_t H5D_def_vlen_free_g = H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */ -static const void *H5D_def_vlen_free_info_g = H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */ -static const size_t H5D_def_hyp_vec_size_g = H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */ -static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g = H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */ -static const H5FD_mpio_chunk_opt_t H5D_def_mpio_chunk_opt_mode_g = H5D_XFER_MPIO_CHUNK_OPT_HARD_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 */ +static const H5MM_allocate_t H5D_def_vlen_alloc_g = + H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */ +static const void *H5D_def_vlen_alloc_info_g = + H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */ +static const H5MM_free_t H5D_def_vlen_free_g = + H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */ +static const void *H5D_def_vlen_free_info_g = + H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */ +static const size_t H5D_def_hyp_vec_size_g = + H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */ +static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g = + H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */ +static const H5FD_mpio_chunk_opt_t H5D_def_mpio_chunk_opt_mode_g = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF; static const H5FD_mpio_collective_opt_t H5D_def_mpio_collective_opt_mode_g = H5D_XFER_MPIO_COLLECTIVE_OPT_DEF; -static const unsigned H5D_def_mpio_chunk_opt_num_g = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF; -static const unsigned H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF; -static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g = H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF; -static const H5D_mpio_actual_io_mode_t H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF; -static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g = H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF; -static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default value for EDC property */ -static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ -static const H5T_conv_cb_t H5D_def_conv_cb_g = H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ -static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ - - +static const unsigned H5D_def_mpio_chunk_opt_num_g = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF; +static const unsigned H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF; +static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g = + H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF; +static const H5D_mpio_actual_io_mode_t H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF; +static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g = + H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF; +static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF; /* Default value for EDC property */ +static const H5Z_cb_t H5D_def_filter_cb_g = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */ +static const H5T_conv_cb_t H5D_def_conv_cb_g = + H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */ +static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ + /*------------------------------------------------------------------------- * Function: H5P__dxfr_reg_prop * @@ -266,145 +278,152 @@ static const void *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Defaul static herr_t H5P__dxfr_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the max. temp buffer size property */ - if(H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE, &H5D_def_max_temp_buf_g, - NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC, H5D_XFER_MAX_TEMP_BUF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE, + &H5D_def_max_temp_buf_g, NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC, + H5D_XFER_MAX_TEMP_BUF_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion buffer property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer type property */ - if(H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE, &H5D_def_bkgr_buf_type_g, - NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC, H5D_XFER_BKGR_BUF_TYPE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE, + &H5D_def_bkgr_buf_type_g, NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC, + H5D_XFER_BKGR_BUF_TYPE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the B-Tree node splitting ratios property */ - if(H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE, H5D_def_btree_split_ratio_g, - NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC, H5D_XFER_BTREE_SPLIT_RATIO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE, + H5D_def_btree_split_ratio_g, NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC, + H5D_XFER_BTREE_SPLIT_RATIO_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation function property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation information property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE, &H5D_def_vlen_alloc_info_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE, + &H5D_def_vlen_alloc_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free function property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free information property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE, &H5D_def_vlen_free_info_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE, + &H5D_def_vlen_free_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vector size property */ - if(H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE, &H5D_def_hyp_vec_size_g, - NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC, H5D_XFER_HYPER_VECTOR_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE, + &H5D_def_hyp_vec_size_g, NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC, + H5D_XFER_HYPER_VECTOR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the I/O transfer mode properties */ - if(H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE, &H5D_def_io_xfer_mode_g, - NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC, H5D_XFER_IO_XFER_MODE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE, + &H5D_def_io_xfer_mode_g, NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC, + H5D_XFER_IO_XFER_MODE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE, &H5D_def_mpio_collective_opt_mode_g, - NULL, NULL, NULL, H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE, + &H5D_def_mpio_collective_opt_mode_g, NULL, NULL, NULL, + H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE, &H5D_def_mpio_chunk_opt_mode_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC, H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE, + &H5D_def_mpio_chunk_opt_mode_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC, + H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE, &H5D_def_mpio_chunk_opt_num_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC, H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE, + &H5D_def_mpio_chunk_opt_num_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC, + H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE, &H5D_def_mpio_chunk_opt_ratio_g, - NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE, + &H5D_def_mpio_chunk_opt_ratio_g, NULL, NULL, NULL, + H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunk optimization mode property. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE, &H5D_def_mpio_actual_chunk_opt_mode_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE, + &H5D_def_mpio_actual_chunk_opt_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the actual I/O mode property. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE, &H5D_def_mpio_actual_io_mode_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE, + &H5D_def_mpio_actual_io_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the local cause of broken collective I/O */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, + &H5D_def_mpio_no_collective_cause_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the global cause of broken collective I/O */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, + H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the EDC property */ - if(H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, - NULL, NULL, NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, NULL, NULL, + NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the filter callback property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion callback property */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data transform property */ - if(H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, - NULL, H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, - H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, H5D_XFER_XFORM_CLOSE) < 0) + if (H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, NULL, + H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, + H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, + H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_bkgr_buf_type_enc * @@ -424,7 +443,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 @@ -432,7 +451,7 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) HDassert(bkgr_buf_type); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode background buffer type */ *(*pp)++ = (uint8_t)*bkgr_buf_type; @@ -442,7 +461,6 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_bkgr_buf_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_bkgr_buf_type_dec * @@ -461,8 +479,8 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; + 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 @@ -472,12 +490,11 @@ H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value) HDassert(bkgr_buf_type); /* Decode background buffer type */ - *bkgr_buf_type = (H5T_bkg_t)*(*pp)++; + *bkgr_buf_type = (H5T_bkg_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_bkgr_buf_type_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_btree_split_ratio_enc * @@ -497,7 +514,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 @@ -505,7 +522,7 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) HDassert(btree_split_ratio); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(double); @@ -527,7 +544,6 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_btree_split_ratio_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_btree_split_ratio_dec * @@ -546,10 +562,10 @@ 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 */ - unsigned enc_size; /* Size of encoded property */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -560,7 +576,7 @@ H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") /* Decode the left, middle & left B-tree split ratios */ @@ -572,7 +588,6 @@ H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_btree_split_ratio_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_set * @@ -587,10 +602,10 @@ H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -598,14 +613,13 @@ H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_set() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_get * @@ -620,10 +634,10 @@ H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -631,14 +645,13 @@ H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_get() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_enc * @@ -657,11 +670,12 @@ H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam static herr_t H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) { - const H5Z_data_xform_t *data_xform_prop = *(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; - herr_t ret_value = SUCCEED; /* Return value */ + const H5Z_data_xform_t *data_xform_prop = + *(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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -670,27 +684,27 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) HDassert(size); /* Check for data transform set */ - if(NULL != data_xform_prop) { + if (NULL != data_xform_prop) { /* Get the transform expression */ - if(NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) + if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") /* Get the transform string expression size */ len = HDstrlen(pexp) + 1; } /* end if */ - if(NULL != *pp) { + if (NULL != *pp) { uint64_t enc_value; unsigned enc_size; /* encode the length of the prefix */ enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); - if(NULL != data_xform_prop) { + if (NULL != data_xform_prop) { /* Sanity check */ HDassert(pexp); @@ -699,18 +713,17 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) *pp += len; *pp[0] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Size of encoded data transform */ *size += (1 + H5VM_limit_enc_size((uint64_t)len)); - if(NULL != pexp) + if (NULL != pexp) *size += len; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_dec * @@ -729,12 +742,12 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) static herr_t 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; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return 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; + unsigned enc_size; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -750,8 +763,8 @@ H5P__dxfr_xform_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { - if(NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp))) + if (0 != len) { + if (NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create data transform info") *pp += len; } /* end if */ @@ -762,7 +775,6 @@ H5P__dxfr_xform_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_del * @@ -777,22 +789,22 @@ H5P__dxfr_xform_dec(const void **_pp, void *_value) *------------------------------------------------------------------------- */ static herr_t -H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(value); - if(H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_del() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_copy * @@ -810,7 +822,7 @@ H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *nam static herr_t H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -818,14 +830,13 @@ H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size HDassert(value); /* Make copy of data transform */ - if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_cmp * @@ -842,10 +853,12 @@ H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size static int H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNUSED size) { - const H5Z_data_xform_t * const *xform1 = (const H5Z_data_xform_t * const *)_xform1; /* Create local aliases for values */ - const H5Z_data_xform_t * const *xform2 = (const H5Z_data_xform_t * const *)_xform2; /* Create local aliases for values */ - const char *pexp1, *pexp2; /* Pointers to transform expressions */ - herr_t ret_value = 0; /* Return value */ + const H5Z_data_xform_t *const *xform1 = + (const H5Z_data_xform_t *const *)_xform1; /* Create local aliases for values */ + const H5Z_data_xform_t *const *xform2 = + (const H5Z_data_xform_t *const *)_xform2; /* Create local aliases for values */ + const char *pexp1, *pexp2; /* Pointers to transform expressions */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -855,10 +868,12 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU HDassert(size == sizeof(H5Z_data_xform_t *)); /* Check for a property being set */ - if(*xform1 == NULL && *xform2 != NULL) HGOTO_DONE(-1); - if(*xform1 != NULL && *xform2 == NULL) HGOTO_DONE(1); + if (*xform1 == NULL && *xform2 != NULL) + HGOTO_DONE(-1); + if (*xform1 != NULL && *xform2 == NULL) + HGOTO_DONE(1); - if(*xform1) { + if (*xform1) { HDassert(*xform2); /* Get the transform expressions */ @@ -866,20 +881,21 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU pexp2 = H5Z_xform_extract_xform_str(*xform2); /* Check for property expressions */ - if(pexp1 == NULL && pexp2 != NULL) HGOTO_DONE(-1); - if(pexp1 != NULL && pexp2 == NULL) HGOTO_DONE(1); + if (pexp1 == NULL && pexp2 != NULL) + HGOTO_DONE(-1); + if (pexp1 != NULL && pexp2 == NULL) + HGOTO_DONE(1); - if(pexp1) { + if (pexp1) { HDassert(pexp2); ret_value = HDstrcmp(pexp1, pexp2); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_close * @@ -896,20 +912,19 @@ H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNU static herr_t H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(value); - if(H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) + if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_xform_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_data_transform * @@ -925,46 +940,45 @@ 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, expression); /* Check arguments */ - if(expression == NULL) + if (expression == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "expression cannot be NULL") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* See if a data transform is already set, and free it if it is */ - if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") /* Destroy previous data transform property */ - if(H5Z_xform_destroy(data_xform_prop) < 0) + if (H5Z_xform_destroy(data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") /* Create data transform info from expression */ - if(NULL == (data_xform_prop = H5Z_xform_create(expression))) + if (NULL == (data_xform_prop = H5Z_xform_create(expression))) HGOTO_ERROR(H5E_PLINE, H5E_NOSPACE, FAIL, "unable to create data transform info") /* Update property list (takes ownership of transform) */ - if(H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression") done: - if(ret_value < 0) - if(data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) + if (ret_value < 0) + if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5Pget_data_transform * @@ -990,34 +1004,34 @@ 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 */ - H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ - size_t len; - const char* pexp; - ssize_t ret_value; /* return value */ + 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; + ssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", plist_id, expression, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") - if(NULL == data_xform_prop) + if (NULL == data_xform_prop) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "data transform has not been set") /* Get the data transform string */ - if(NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") + if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") /* Copy into application buffer */ len = HDstrlen(pexp); - if(expression) { - HDstrncpy(expression, pexp, MIN(len + 1, size)); - if(len >= size) + if (expression) { + HDstrncpy(expression, pexp, MIN(len + 1, size)); + if (len >= size) expression[size - 1] = '\0'; } /* end if */ @@ -1027,7 +1041,6 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) FUNC_LEAVE_API(ret_value) } /* end H5Pget_data_transform() */ - /*------------------------------------------------------------------------- * Function: H5Pset_buffer * @@ -1052,33 +1065,32 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iz*x*x", plist_id, size, tconv, bkg); /* Check arguments */ - if(size == 0) + if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size must not be zero") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) + if (H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer buffer size") - if(H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv) < 0) + if (H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer type conversion buffer") - if(H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg) < 0) + if (H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set background type conversion buffer") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_buffer() */ - /*------------------------------------------------------------------------- * Function: H5Pget_buffer * @@ -1094,29 +1106,29 @@ H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) *------------------------------------------------------------------------- */ size_t -H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) +H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - size_t size; /* Type conversion buffer size */ - size_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + size_t size; /* Type conversion buffer size */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE3("z", "ixx", plist_id, tconv, bkg); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, 0, "can't find object for ID") /* Return values */ - if(tconv) - if(H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv) < 0) + if (tconv) + if (H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get transfer type conversion buffer") - if(bkg) - if(H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg) < 0) + if (bkg) + if (H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get background type conversion buffer") /* Get the size */ - if(H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) + if (H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, 0, "Can't set transfer buffer size") /* Set the return value */ @@ -1126,7 +1138,6 @@ H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_buffer() */ - /*------------------------------------------------------------------------- * Function: H5Pset_preserve * @@ -1146,27 +1157,26 @@ H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) herr_t H5Pset_preserve(hid_t plist_id, hbool_t status) { - H5P_genplist_t *plist; /* Property list pointer */ - H5T_bkg_t need_bkg; /* Value for background buffer type */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_bkg_t need_bkg; /* Value for background buffer type */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, status); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO; - if(H5P_set(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) + if (H5P_set(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_preserve() */ - /*------------------------------------------------------------------------- * Function: H5Pget_preserve * @@ -1184,19 +1194,19 @@ H5Pset_preserve(hid_t plist_id, hbool_t status) int H5Pget_preserve(hid_t plist_id) { - H5T_bkg_t need_bkg; /* Background value */ - H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; /* return value */ + H5T_bkg_t need_bkg; /* Background value */ + H5P_genplist_t *plist; /* Property list pointer */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) + if (H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") /* Set return value */ @@ -1206,7 +1216,6 @@ H5Pget_preserve(hid_t plist_id) FUNC_LEAVE_API(ret_value) } /* end H5Pget_preserve() */ - /*------------------------------------------------------------------------- * Function: H5Pset_edc_check * @@ -1225,29 +1234,28 @@ H5Pget_preserve(hid_t plist_id) herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iZe", plist_id, check); /* Check argument */ - if(check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) + if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_EDC_NAME, &check) < 0) + if (H5P_set(plist, H5D_XFER_EDC_NAME, &check) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_edc_check() */ - /*------------------------------------------------------------------------- * Function: H5Pget_edc_check * @@ -1266,25 +1274,24 @@ H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) H5Z_EDC_t H5Pget_edc_check(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - H5Z_EDC_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5Z_EDC_t ret_value; /* Return value */ FUNC_ENTER_API(H5Z_ERROR_EDC) H5TRACE1("Ze", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_ERROR_EDC, "can't find object for ID") /* Update property list */ - if(H5P_get(plist, H5D_XFER_EDC_NAME, &ret_value) < 0) + if (H5P_get(plist, H5D_XFER_EDC_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5Z_ERROR_EDC, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_edc_check() */ - /*------------------------------------------------------------------------- * Function: H5Pset_filter_callback * @@ -1302,29 +1309,28 @@ H5Pget_edc_check(hid_t plist_id) herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ - H5Z_cb_t cb_struct; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + H5Z_cb_t cb_struct; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - cb_struct.func = func; + cb_struct.func = func; cb_struct.op_data = op_data; - if (H5P_set(plist,H5D_XFER_FILTER_CB_NAME,&cb_struct)<0) + if (H5P_set(plist, H5D_XFER_FILTER_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_type_conv_cb * @@ -1342,29 +1348,28 @@ H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data) herr_t H5Pset_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t op, void *operate_data) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ - H5T_conv_cb_t cb_struct; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + H5T_conv_cb_t cb_struct; FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, op, operate_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - cb_struct.func = op; + cb_struct.func = op; cb_struct.user_data = operate_data; - if (H5P_set(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) + if (H5P_set(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_type_conv_cb * @@ -1382,30 +1387,29 @@ H5Pset_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t op, void *operate_dat herr_t H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op, void **operate_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5T_conv_cb_t cb_struct; - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5T_conv_cb_t cb_struct; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, op, operate_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get property */ - if (H5P_get(plist,H5D_XFER_CONV_CB_NAME,&cb_struct)<0) + if (H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") /* Assign return value */ - *op = cb_struct.func; + *op = cb_struct.func; *operate_data = cb_struct.user_data; done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_btree_ratios * @@ -1422,37 +1426,35 @@ H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op, void **operate_d *------------------------------------------------------------------------- */ herr_t -H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/, - double *right/*out*/) +H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, double *right /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - double btree_split_ratio[3]; /* B-tree node split ratios */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + double btree_split_ratio[3]; /* B-tree node split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ixxx", plist_id, left, middle, right); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the split ratios */ - if(H5P_get(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &btree_split_ratio) < 0) + if (H5P_get(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &btree_split_ratio) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") /* Get values */ - if(left) + if (left) *left = btree_split_ratio[0]; - if(middle) + if (middle) *middle = btree_split_ratio[1]; - if(right) + if (right) *right = btree_split_ratio[2]; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_btree_ratios() */ - /*------------------------------------------------------------------------- * Function: H5Pset_btree_ratios * @@ -1474,24 +1476,21 @@ H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, double *middle/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pset_btree_ratios(hid_t plist_id, double left, double middle, - double right) +H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right) { - H5P_genplist_t *plist; /* Property list pointer */ - double split_ratio[3]; /* B-tree node split ratios */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + double split_ratio[3]; /* B-tree node split ratios */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iddd", plist_id, left, middle, right); /* Check arguments */ - if(left < (double)0.0f || left > (double)1.0f - || middle < (double)0.0f || middle > (double)1.0f - || right < (double)0.0f || right > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0<=X<=1.0") + if (left < 0.0 || left > 1.0 || middle < 0.0 || middle > 1.0 || right < 0.0 || right > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0 <= X <= 1.0") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ @@ -1500,20 +1499,19 @@ H5Pset_btree_ratios(hid_t plist_id, double left, double middle, split_ratio[2] = right; /* Set the split ratios */ - if(H5P_set(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratio) < 0) + if (H5P_set(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratio) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_btree_ratios() */ - /*------------------------------------------------------------------------- * Function: H5P_set_vlen_mem_manager * * Purpose: Sets the memory allocate/free pair for VL datatypes. The * allocation routine is called when data is read into a new - * array and the free routine is called when H5Dvlen_reclaim is + * array and the free routine is called when H5Treclaim is * called. The alloc_info and free_info are user parameters * which are passed to the allocation and freeing functions * respectively. To reset the allocate/free functions to the @@ -1528,36 +1526,35 @@ H5Pset_btree_ratios(hid_t plist_id, double left, double middle, *------------------------------------------------------------------------- */ herr_t -H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, - void *alloc_info, H5MM_free_t free_func, void *free_info) +H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, + H5MM_free_t free_func, void *free_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(plist); /* Update property list */ - if(H5P_set(plist, H5D_XFER_VLEN_ALLOC_NAME, &alloc_func) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_NAME, &alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &alloc_info) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_FREE_NAME, &free_func) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_FREE_NAME, &free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") - if(H5P_set(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &free_info) < 0) + if (H5P_set(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pset_vlen_mem_manager * * Purpose: Sets the memory allocate/free pair for VL datatypes. The * allocation routine is called when data is read into a new - * array and the free routine is called when H5Dvlen_reclaim is + * array and the free routine is called when H5Treclaim is * called. The alloc_info and free_info are user parameters * which are passed to the allocation and freeing functions * respectively. To reset the allocate/free functions to the @@ -1572,29 +1569,27 @@ H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, *------------------------------------------------------------------------- */ 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) +H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, + void *free_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "ix*xx*x", plist_id, alloc_func, alloc_info, free_func, - free_info); + H5TRACE5("e", "ix*xx*x", plist_id, alloc_func, alloc_info, free_func, free_info); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Update property list */ - if(H5P_set_vlen_mem_manager(plist, alloc_func, alloc_info, free_func, free_info) < 0) + if (H5P_set_vlen_mem_manager(plist, alloc_func, alloc_info, free_func, free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set values") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pget_vlen_mem_manager * @@ -1608,37 +1603,36 @@ H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, *------------------------------------------------------------------------- */ herr_t -H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func/*out*/, - void **alloc_info/*out*/, H5MM_free_t *free_func/*out*/, void **free_info/*out*/) +H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func /*out*/, void **alloc_info /*out*/, + H5MM_free_t *free_func /*out*/, void **free_info /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ixxxx", plist_id, alloc_func, alloc_info, free_func, free_info); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(alloc_func) - if(H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, alloc_func) < 0) + if (alloc_func) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(alloc_info) - if(H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, alloc_info) < 0) + if (alloc_info) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(free_func) - if(H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, free_func) < 0) + if (free_func) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if(free_info) - if(H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, free_info) < 0) + if (free_info) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_vlen_mem_manager() */ - /*------------------------------------------------------------------------- * Function: H5Pset_hyper_vector_size * @@ -1663,29 +1657,28 @@ H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func/*out*/, herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, vector_size); /* Check arguments */ - if(vector_size < 1) + if (vector_size < 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - if(H5P_set(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &vector_size) < 0) + if (H5P_set(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &vector_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_hyper_vector_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_hyper_vector_size * @@ -1699,28 +1692,27 @@ H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size) *------------------------------------------------------------------------- */ herr_t -H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size/*out*/) +H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, vector_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(vector_size) - if(H5P_get(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, vector_size) < 0) + if (vector_size) + if (H5P_get(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, vector_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_hyper_vector_size() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_io_xfer_mode_enc * @@ -1740,7 +1732,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 @@ -1748,7 +1740,7 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) HDassert(xfer_mode); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode I/O transfer mode */ *(*pp)++ = (uint8_t)*xfer_mode; @@ -1758,7 +1750,6 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_io_xfer_mode_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_io_xfer_mode_dec * @@ -1777,8 +1768,8 @@ H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) 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; + H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1788,12 +1779,11 @@ H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) HDassert(xfer_mode); /* Decode I/O transfer mode */ - *xfer_mode = (H5FD_mpio_xfer_t)*(*pp)++; + *xfer_mode = (H5FD_mpio_xfer_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_io_xfer_mode_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_collective_opt_enc * @@ -1812,7 +1802,8 @@ H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) static herr_t H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) { - const H5FD_mpio_collective_opt_t *coll_opt = (const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */ + const H5FD_mpio_collective_opt_t *coll_opt = + (const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1821,7 +1812,7 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) HDassert(coll_opt); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode MPI-I/O collective optimization property */ *(*pp)++ = (uint8_t)*coll_opt; @@ -1831,7 +1822,6 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_collective_opt_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_collective_opt_dec * @@ -1850,7 +1840,8 @@ H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) { - H5FD_mpio_collective_opt_t *coll_opt = (H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */ + H5FD_mpio_collective_opt_t *coll_opt = + (H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1861,12 +1852,11 @@ H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) HDassert(coll_opt); /* Decode MPI-I/O collective optimization mode */ - *coll_opt = (H5FD_mpio_collective_opt_t)*(*pp)++; + *coll_opt = (H5FD_mpio_collective_opt_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_collective_opt_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_chunk_opt_hard_enc * @@ -1885,7 +1875,8 @@ H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value) static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) { - const H5FD_mpio_chunk_opt_t *chunk_opt = (const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */ + const H5FD_mpio_chunk_opt_t *chunk_opt = + (const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1894,7 +1885,7 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) HDassert(chunk_opt); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode MPI-I/O chunk optimization property */ *(*pp)++ = (uint8_t)*chunk_opt; @@ -1904,7 +1895,6 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_chunk_opt_hard_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_mpio_chunk_opt_hard_enc * @@ -1923,8 +1913,8 @@ H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size) 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; + 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; FUNC_ENTER_STATIC_NOERR @@ -1934,13 +1924,13 @@ H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) HDassert(chunk_opt); /* Decode MPI-I/O chunk optimization mode */ - *chunk_opt = (H5FD_mpio_chunk_opt_t)*(*pp)++; + *chunk_opt = (H5FD_mpio_chunk_opt_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_mpio_chunk_opt_hard_dec() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5Pget_mpio_actual_chunk_opt_mode * @@ -1956,26 +1946,25 @@ H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Do", plist_id, actual_chunk_opt_mode); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(actual_chunk_opt_mode) - if(H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0) + if (actual_chunk_opt_mode) + if (H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mpio_actual_chunk_opt_mode() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mpio_actual_io_mode * @@ -1992,26 +1981,25 @@ H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Di", plist_id, actual_io_mode); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(actual_io_mode) - if(H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0) + if (actual_io_mode) + if (H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mpio_actual_io_mode() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mpio_no_collective_cause * @@ -2024,25 +2012,25 @@ H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_ *------------------------------------------------------------------------- */ herr_t -H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause) +H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, + uint32_t *global_no_collective_cause) { - H5P_genplist_t *plist; - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*Iu*Iu", plist_id, local_no_collective_cause, - global_no_collective_cause); + H5TRACE3("e", "i*Iu*Iu", plist_id, local_no_collective_cause, global_no_collective_cause); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Return values */ - if(local_no_collective_cause) - if(H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0) + if (local_no_collective_cause) + if (H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get local value") - if(global_no_collective_cause) - if(H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0) + if (global_no_collective_cause) + if (H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get global value") done: @@ -2050,7 +2038,6 @@ H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_ca } /* end H5Pget_mpio_no_collective_cause() */ #endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_edc_enc * @@ -2070,7 +2057,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 @@ -2078,7 +2065,7 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) HDassert(check); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode EDC property */ *(*pp)++ = (uint8_t)*check; @@ -2088,7 +2075,6 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__dxfr_edc_dec * @@ -2107,8 +2093,8 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; + H5Z_EDC_t * check = (H5Z_EDC_t *)_value; /* EDC property */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -2118,8 +2104,7 @@ H5P__dxfr_edc_dec(const void **_pp, void *_value) HDassert(check); /* Decode EDC property */ - *check = (H5Z_EDC_t)*(*pp)++; + *check = (H5Z_EDC_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__dxfr_edc_dec() */ - diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 5f35a7eeed4..5b0ecb6f8aa 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,28 +20,25 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ /* Version # of encoded property lists */ -#define H5P_ENCODE_VERS 0 - +#define H5P_ENCODE_VERS 0 /******************/ /* Local Typedefs */ @@ -49,33 +46,27 @@ /* Typedef for iterator when encoding a property list */ 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 */ + 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 */ } H5P_enc_iter_ud_t; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5P__encode_size_t * @@ -92,9 +83,9 @@ typedef struct { herr_t H5P__encode_size_t(const void *value, void **_pp, size_t *size) { - uint64_t enc_value = (uint64_t)*(const size_t *)value; /* Property value to encode */ - uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ + uint64_t enc_value = (uint64_t) * (const size_t *)value; /* Property value to encode */ + uint8_t **pp = (uint8_t **)_pp; + unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ FUNC_ENTER_PACKAGE_NOERR @@ -103,7 +94,7 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) HDassert(enc_size < 256); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)enc_size; @@ -117,7 +108,6 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_size_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_hsize_t * @@ -134,9 +124,9 @@ H5P__encode_size_t(const void *value, void **_pp, size_t *size) herr_t H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) { - uint64_t enc_value = (uint64_t)*(const hsize_t *)value; /* Property value to encode */ - unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ - uint8_t **pp = (uint8_t **)_pp; + uint64_t enc_value = (uint64_t) * (const hsize_t *)value; /* Property value to encode */ + unsigned enc_size = H5VM_limit_enc_size(enc_value); /* Size of encoded property */ + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_PACKAGE_NOERR @@ -145,7 +135,7 @@ H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) HDassert(enc_size < 256); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { *(*pp)++ = (uint8_t)enc_size; /* Encode the value */ @@ -158,7 +148,6 @@ H5P__encode_hsize_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_hsize_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_unsigned * @@ -183,7 +172,7 @@ H5P__encode_unsigned(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)sizeof(unsigned); @@ -197,7 +186,6 @@ H5P__encode_unsigned(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_unsigned() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_uint8_t * @@ -222,7 +210,7 @@ H5P__encode_uint8_t(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the value */ *(*pp)++ = *(const uint8_t *)value; } /* end if */ @@ -233,7 +221,6 @@ H5P__encode_uint8_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_uint8_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_hbool_t * @@ -258,9 +245,9 @@ H5P__encode_hbool_t(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode the value */ - *(*pp)++ = (uint8_t)*(const hbool_t *)value; + *(*pp)++ = (uint8_t) * (const hbool_t *)value; /* Set size needed for encoding */ *size += 1; @@ -268,7 +255,6 @@ H5P__encode_hbool_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_hbool_t() */ - /*------------------------------------------------------------------------- * Function: H5P__encode_double * @@ -293,7 +279,7 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) HDassert(value); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the size */ *(*pp)++ = (uint8_t)sizeof(double); @@ -307,7 +293,6 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_double() */ - /*-------------------------------------------------------------------------- NAME H5P__encode_cb @@ -331,8 +316,8 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) static int H5P__encode_cb(H5P_genprop_t *prop, void *_udata) { - H5P_enc_iter_ud_t *udata = (H5P_enc_iter_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_enc_iter_ud_t *udata = (H5P_enc_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -341,13 +326,13 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) HDassert(udata); /* Check if this property can be encoded */ - if(prop->encode) { - size_t prop_name_len; /* Length of property's name */ - size_t prop_value_len; /* Encoded size of property's value */ + if (prop->encode) { + size_t prop_name_len; /* Length of property's name */ + size_t prop_value_len; /* Encoded size of property's value */ /* Encode (or not, if the 'encode' flag is off) the property's name */ prop_name_len = HDstrlen(prop->name) + 1; - if(udata->encode) { + if (udata->encode) { HDstrncpy((char *)*(udata->pp), prop->name, prop_name_len); *(uint8_t **)(udata->pp) += prop_name_len; } /* end if */ @@ -355,7 +340,7 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) /* Encode (or not, if *(udata->pp) is NULL) the property value */ prop_value_len = 0; - if((prop->encode)(prop->value, udata->pp, &prop_value_len) < 0) + if ((prop->encode)(prop->value, udata->pp, &prop_value_len) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, H5_ITER_ERROR, "property encoding routine failed") *(udata->enc_size_ptr) += prop_value_len; } /* end if */ @@ -364,7 +349,6 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__encode_cb() */ - /*------------------------------------------------------------------------- NAME H5P__encode @@ -389,30 +373,29 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, - size_t *nalloc) +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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_enc_iter_ud_t udata; /* User data for property iteration callback */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - if(NULL == nalloc) + if (NULL == nalloc) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad allocation size pointer") /* If the buffer is NULL, then this call to H5P__encode will return how much * space is needed to encode a property. */ - if(NULL == p) + if (NULL == p) encode = FALSE; /* Encode property list description info */ - if(encode) { + if (encode) { /* Version # of property list encoding */ *p++ = (uint8_t)H5P_ENCODE_VERS; @@ -422,17 +405,17 @@ H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, encode_size += 2; /* Initialize user data for iteration callback */ - udata.encode = encode; + udata.encode = encode; udata.enc_size_ptr = &encode_size; - udata.pp = (void **)&p; + udata.pp = (void **)&p; /* Iterate over all properties in property list, encoding them */ idx = 0; - if(H5P__iterate_plist(plist, enc_all_prop, &idx, H5P__encode_cb, &udata) < 0) + if (H5P__iterate_plist(plist, enc_all_prop, &idx, H5P__encode_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, FAIL, "can't iterate over properties") /* Encode a terminator for list of properties */ - if(encode) + if (encode) *p++ = 0; encode_size++; @@ -443,7 +426,6 @@ H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__encode() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_size_t * @@ -460,10 +442,10 @@ H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, herr_t H5P__decode_size_t(const void **_pp, void *_value) { - 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 */ + 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 */ FUNC_ENTER_PACKAGE_NOERR @@ -484,7 +466,6 @@ H5P__decode_size_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_size_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_hsize_t * @@ -501,10 +482,10 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ + 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 */ FUNC_ENTER_PACKAGE_NOERR @@ -525,7 +506,6 @@ H5P__decode_hsize_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_hsize_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_unsigned * @@ -542,10 +522,10 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -556,7 +536,7 @@ H5P__decode_unsigned(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") H5_DECODE_UNSIGNED(*pp, *value) @@ -565,7 +545,6 @@ H5P__decode_unsigned(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_unsigned() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_uint8_t * @@ -582,9 +561,9 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE_NOERR @@ -599,7 +578,6 @@ H5P__decode_uint8_t(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_uint8_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_hbool_t * @@ -616,9 +594,9 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE_NOERR @@ -628,12 +606,11 @@ H5P__decode_hbool_t(const void **_pp, void *_value) HDassert(value); /* Decode the value */ - *value = (hbool_t)*(*pp)++; + *value = (hbool_t) * (*pp)++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_hbool_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_double * @@ -650,10 +627,10 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -664,7 +641,7 @@ H5P__decode_double(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") H5_DECODE_DOUBLE(*pp, *value) @@ -673,7 +650,6 @@ H5P__decode_double(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode_double() */ - /*------------------------------------------------------------------------- NAME H5P__decode @@ -700,46 +676,47 @@ 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_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 */ - uint8_t vers; /* Version of encoded property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + uint8_t vers; /* Version of encoded property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - if(NULL == p) + if (NULL == p) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "decode buffer is NULL") /* Get the version number of the encoded property list */ vers = (uint8_t)*p++; - if((uint8_t)H5P_ENCODE_VERS != vers) - HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "bad version # of encoded information, expected %u, got %u", (unsigned)H5P_ENCODE_VERS, (unsigned)vers) + if ((uint8_t)H5P_ENCODE_VERS != vers) + HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "bad version # of encoded information, expected %u, got %u", + (unsigned)H5P_ENCODE_VERS, (unsigned)vers) /* Get the type of the property list */ type = (H5P_plist_type_t)*p++; - if(type <= H5P_TYPE_USER || type >= H5P_TYPE_MAX_TYPE) + if (type <= H5P_TYPE_USER || type >= H5P_TYPE_MAX_TYPE) HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "bad type of encoded information: %u", (unsigned)type) /* Create new property list of the specified type */ - if((plist_id = H5P__new_plist_of_type(type)) < 0) + if ((plist_id = H5P__new_plist_of_type(type)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_VERSION, FAIL, "can't create property list of type: %u\n", (unsigned)type); /* Get the property list object */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property class") /* 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 */ + while (p) { + H5P_genprop_t *prop; /* Pointer to property with same name */ + const char * name; /* Pointer to property list name */ /* Check for end of serialized list of properties */ - if(0 == *p) + if (0 == *p) break; /* Get property list name */ @@ -747,26 +724,27 @@ H5P__decode(const void *buf) p += HDstrlen(name) + 1; /* Find property with name */ - if(NULL == (prop = H5P__find_prop_plist(plist, name))) + if (NULL == (prop = H5P__find_prop_plist(plist, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist: '%s'", name) /* Check if we should increase the size of the value buffer */ - if(prop->size > value_buf_size) { - if(NULL == (value_buf = H5MM_realloc(value_buf, prop->size))) + if (prop->size > value_buf_size) { + if (NULL == (value_buf = H5MM_realloc(value_buf, prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "decoding buffer allocation failed") value_buf_size = prop->size; } /* end if */ /* Decode serialized value */ - if(prop->decode) { - if((prop->decode)((const void **)&p, value_buf) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "property decoding routine failed, property: '%s'", name) + if (prop->decode) { + if ((prop->decode)((const void **)&p, value_buf) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, + "property decoding routine failed, property: '%s'", name) } /* end if */ else HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "no decode callback for property: '%s'", name) /* Set the value for the property */ - if(H5P_poke(plist, name, value_buf) < 0) + if (H5P_poke(plist, name, value_buf) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value for property: '%s'", name) } /* end while */ @@ -775,15 +753,15 @@ H5P__decode(const void *buf) done: /* Release resources */ - if(value_buf) + if (value_buf) value_buf = H5MM_xfree(value_buf); /* Cleanup on error */ - if(ret_value < 0) { - if(plist_id > 0 && H5I_dec_ref(plist_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close partially initialized property list") + if (ret_value < 0) { + if (plist_id > 0 && H5I_dec_ref(plist_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close partially initialized property list") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__decode() */ - diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index dc3418084db..a7f84fbe1fb 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,29 +24,31 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory Management */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory Management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vector Functions */ /* Includes needed to set default file driver */ -#include "H5FDsec2.h" /* POSIX unbuffered I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered I/O */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Win32 I/O */ +#include "H5FDwindows.h" /* Win32 I/O */ #endif +/* Includes needed to set default VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ @@ -54,189 +56,203 @@ /* ========= File Access properties ============ */ /* Definitions for the initial metadata cache resize configuration */ -#define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t) -#define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG -#define H5F_ACS_META_CACHE_INIT_CONFIG_ENC H5P__facc_cache_config_enc -#define H5F_ACS_META_CACHE_INIT_CONFIG_DEC H5P__facc_cache_config_dec -#define H5F_ACS_META_CACHE_INIT_CONFIG_CMP H5P__facc_cache_config_cmp +#define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t) +#define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG +#define H5F_ACS_META_CACHE_INIT_CONFIG_ENC H5P__facc_cache_config_enc +#define H5F_ACS_META_CACHE_INIT_CONFIG_DEC H5P__facc_cache_config_dec +#define H5F_ACS_META_CACHE_INIT_CONFIG_CMP H5P__facc_cache_config_cmp /* Definitions for size of raw data chunk cache(slots) */ -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521 -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_size_t -#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_size_t +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521 +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_size_t +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_size_t /* Definition for size of raw data chunk cache(bytes) */ -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024*1024) -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024 * 1024) +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t /* Definition for preemption read chunks first */ -#define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) -#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f -#define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double -#define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double +#define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) +#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f +#define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double +#define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definition for threshold for alignment */ -#define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF -#define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t -#define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t +#define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t) +#define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF +#define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t +#define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t /* Definition for alignment */ -#define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) -#define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF -#define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t -#define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t +#define H5F_ACS_ALIGN_SIZE sizeof(hsize_t) +#define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF +#define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t +#define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t /* Definition for minimum metadata allocation block size (when aggregating metadata allocations. */ -#define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF -#define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t -#define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t +#define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF +#define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t +#define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for maximum sieve buffer size (when data sieving is allowed by file driver */ -#define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_SIEVE_BUF_SIZE_DEF (64*1024) -#define H5F_ACS_SIEVE_BUF_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_SIEVE_BUF_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_SIEVE_BUF_SIZE_DEF (64 * 1024) +#define H5F_ACS_SIEVE_BUF_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_SIEVE_BUF_SIZE_DEC H5P__decode_size_t /* Definition for minimum "small data" allocation block size (when aggregating "small" raw data allocations. */ -#define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF -#define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t -#define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t +#define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF +#define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t +#define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t /* Definition for garbage-collect references */ -#define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned) -#define H5F_ACS_GARBG_COLCT_REF_DEF 0 -#define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned -#define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned +#define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned) +#define H5F_ACS_GARBG_COLCT_REF_DEF 0 +#define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned +#define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned /* Definition for file driver ID & info */ -#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) -#define H5F_ACS_FILE_DRV_DEF {H5_DEFAULT_VFD, NULL} -#define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create -#define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set -#define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get -#define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del -#define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy -#define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp -#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close +#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) +#define H5F_ACS_FILE_DRV_DEF \ + { \ + H5_DEFAULT_VFD, NULL \ + } +#define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create +#define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set +#define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get +#define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del +#define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy +#define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp +#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close /* Definition for file close degree */ -#define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) -#define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT -#define H5F_CLOSE_DEGREE_ENC H5P__facc_fclose_degree_enc -#define H5F_CLOSE_DEGREE_DEC H5P__facc_fclose_degree_dec +#define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) +#define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT +#define H5F_CLOSE_DEGREE_ENC H5P__facc_fclose_degree_enc +#define H5F_CLOSE_DEGREE_DEC H5P__facc_fclose_degree_dec /* Definition for offset position in file for family file driver */ -#define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t) -#define H5F_ACS_FAMILY_OFFSET_DEF 0 -#define H5F_ACS_FAMILY_OFFSET_ENC H5P__encode_hsize_t -#define H5F_ACS_FAMILY_OFFSET_DEC H5P__decode_hsize_t +#define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t) +#define H5F_ACS_FAMILY_OFFSET_DEF 0 +#define H5F_ACS_FAMILY_OFFSET_ENC H5P__encode_hsize_t +#define H5F_ACS_FAMILY_OFFSET_DEC H5P__decode_hsize_t /* Definition for new member size of family driver. It's private * property only used by h5repart */ -#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t) -#define H5F_ACS_FAMILY_NEWSIZE_DEF 0 +#define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t) +#define H5F_ACS_FAMILY_NEWSIZE_DEF 0 /* Definition for whether to convert family to a single-file driver. * It's a private property only used by h5repart. */ -#define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(hbool_t) -#define H5F_ACS_FAMILY_TO_SINGLE_DEF FALSE +#define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(hbool_t) +#define H5F_ACS_FAMILY_TO_SINGLE_DEF FALSE /* Definition for data type in multi file driver */ -#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t) -#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT -#define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc -#define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec +#define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t) +#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT +#define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc +#define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec /* Definition for "low" bound of library format versions */ -#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST -#define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST +#define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec /* Definition for "high" bound of library format versions */ -#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t) -#define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST -#define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc -#define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec +#define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t) +#define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST +#define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc +#define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec /* Definition for whether to query the file descriptor from the core VFD * instead of the memory address. (Private to library) */ -#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t) -#define H5F_ACS_WANT_POSIX_FD_DEF FALSE +#define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t) +#define H5F_ACS_WANT_POSIX_FD_DEF FALSE /* Definition for external file cache size */ -#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) -#define H5F_ACS_EFC_SIZE_DEF 0 -#define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned -#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned +#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) +#define H5F_ACS_EFC_SIZE_DEF 0 +#define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned +#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned /* Definition of pointer to initial file image info */ -#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) -#define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO -#define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set -#define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get -#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del -#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy -#define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp -#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close -/* Definition of core VFD write tracking flag */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC H5P__decode_hbool_t -/* Definition of core VFD write tracking page size */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF 524288 -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) +#define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO +#define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set +#define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get +#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del +#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy +#define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp +#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close /* Definition for # of metadata read attempts */ -#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) -#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 -#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned -#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned +#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) +#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 +#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned +#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned /* Definition for object flush callback */ -#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t) -#define H5F_ACS_OBJECT_FLUSH_CB_DEF {NULL, NULL} +#define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t) +#define H5F_ACS_OBJECT_FLUSH_CB_DEF \ + { \ + NULL, NULL \ + } /* Definition for status_flags in the superblock */ -#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t) -#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE +#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t) +#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE /* Definition for dropping free-space to the floor when reading in the superblock */ -#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t) -#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE +#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t) +#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE /* Definition for skipping EOF check when reading in the superblock */ -#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t) -#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE +#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t) +#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE /* Definition for 'use metadata cache logging' flag */ -#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t) -#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE -#define H5F_ACS_USE_MDC_LOGGING_ENC H5P__encode_hbool_t -#define H5F_ACS_USE_MDC_LOGGING_DEC H5P__decode_hbool_t +#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t) +#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE +#define H5F_ACS_USE_MDC_LOGGING_ENC H5P__encode_hbool_t +#define H5F_ACS_USE_MDC_LOGGING_DEC H5P__decode_hbool_t /* Definition for 'mdc log location' flag */ -#define H5F_ACS_MDC_LOG_LOCATION_SIZE sizeof(char *) -#define H5F_ACS_MDC_LOG_LOCATION_DEF NULL /* default is no log location */ -#define H5F_ACS_MDC_LOG_LOCATION_ENC H5P_facc_mdc_log_location_enc -#define H5F_ACS_MDC_LOG_LOCATION_DEC H5P_facc_mdc_log_location_dec -#define H5F_ACS_MDC_LOG_LOCATION_DEL H5P_facc_mdc_log_location_del -#define H5F_ACS_MDC_LOG_LOCATION_COPY H5P_facc_mdc_log_location_copy -#define H5F_ACS_MDC_LOG_LOCATION_CMP H5P_facc_mdc_log_location_cmp -#define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P_facc_mdc_log_location_close +#define H5F_ACS_MDC_LOG_LOCATION_SIZE sizeof(char *) +#define H5F_ACS_MDC_LOG_LOCATION_DEF NULL /* default is no log location */ +#define H5F_ACS_MDC_LOG_LOCATION_ENC H5P__facc_mdc_log_location_enc +#define H5F_ACS_MDC_LOG_LOCATION_DEC H5P__facc_mdc_log_location_dec +#define H5F_ACS_MDC_LOG_LOCATION_DEL H5P__facc_mdc_log_location_del +#define H5F_ACS_MDC_LOG_LOCATION_COPY H5P__facc_mdc_log_location_copy +#define H5F_ACS_MDC_LOG_LOCATION_CMP H5P__facc_mdc_log_location_cmp +#define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P__facc_mdc_log_location_close /* Definition for 'start metadata cache logging on access' flag */ -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(hbool_t) -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF FALSE -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC H5P__encode_hbool_t -#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC H5P__decode_hbool_t +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(hbool_t) +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF FALSE +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC H5P__encode_hbool_t +#define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC H5P__decode_hbool_t /* Definition for evict on close property */ -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t) +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t +#define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t #ifdef H5_HAVE_PARALLEL /* Definition of collective metadata read mode flag */ -#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t) -#define H5F_ACS_COLL_MD_READ_FLAG_DEF H5P_USER_FALSE -#define H5F_ACS_COLL_MD_READ_FLAG_ENC H5P__encode_coll_md_read_flag_t -#define H5F_ACS_COLL_MD_READ_FLAG_DEC H5P__decode_coll_md_read_flag_t +#define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t) +#define H5F_ACS_COLL_MD_READ_FLAG_DEF H5P_USER_FALSE +#define H5F_ACS_COLL_MD_READ_FLAG_ENC H5P__encode_coll_md_read_flag_t +#define H5F_ACS_COLL_MD_READ_FLAG_DEC H5P__decode_coll_md_read_flag_t /* Definition of collective metadata write mode flag */ -#define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_COLL_MD_WRITE_FLAG_DEF FALSE -#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t +#define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(hbool_t) +#define H5F_ACS_COLL_MD_WRITE_FLAG_DEF FALSE +#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t +#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t +/* Definition for the file's MPI communicator */ +#define H5F_ACS_MPI_PARAMS_COMM_SIZE sizeof(MPI_Comm) +#define H5F_ACS_MPI_PARAMS_COMM_DEF MPI_COMM_NULL +#define H5F_ACS_MPI_PARAMS_COMM_SET H5P__facc_mpi_comm_set +#define H5F_ACS_MPI_PARAMS_COMM_GET H5P__facc_mpi_comm_get +#define H5F_ACS_MPI_PARAMS_COMM_DEL H5P__facc_mpi_comm_del +#define H5F_ACS_MPI_PARAMS_COMM_COPY H5P__facc_mpi_comm_copy +#define H5F_ACS_MPI_PARAMS_COMM_CMP H5P__facc_mpi_comm_cmp +#define H5F_ACS_MPI_PARAMS_COMM_CLOSE H5P__facc_mpi_comm_close +/* Definition for the file's MPI info */ +#define H5F_ACS_MPI_PARAMS_INFO_SIZE sizeof(MPI_Info) +#define H5F_ACS_MPI_PARAMS_INFO_DEF MPI_INFO_NULL +#define H5F_ACS_MPI_PARAMS_INFO_SET H5P__facc_mpi_info_set +#define H5F_ACS_MPI_PARAMS_INFO_GET H5P__facc_mpi_info_get +#define H5F_ACS_MPI_PARAMS_INFO_DEL H5P__facc_mpi_info_del +#define H5F_ACS_MPI_PARAMS_INFO_COPY H5P__facc_mpi_info_copy +#define H5F_ACS_MPI_PARAMS_INFO_CMP H5P__facc_mpi_info_cmp +#define H5F_ACS_MPI_PARAMS_INFO_CLOSE H5P__facc_mpi_info_close #endif /* H5_HAVE_PARALLEL */ /* Definitions for the initial metadata cache image configuration */ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE sizeof(H5AC_cache_image_config_t) @@ -245,55 +261,65 @@ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC H5P__facc_cache_image_config_dec #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP H5P__facc_cache_image_config_cmp /* Definition for total size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0 -#define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t +#define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t) +#define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0 +#define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t +#define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t /* Definition for minimum metadata size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned) -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0 -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned -#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned /* Definition for minimum raw data size of page buffer(bytes) */ -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned) -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned -#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned) +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned +#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned +/* Definition for file VOL connector properties (ID, etc.) */ +#define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t) +#define H5F_ACS_VOL_CONN_DEF \ + { \ + H5_DEFAULT_VOL, NULL \ + } +#define H5F_ACS_VOL_CONN_CRT H5P__facc_vol_create +#define H5F_ACS_VOL_CONN_SET H5P__facc_vol_set +#define H5F_ACS_VOL_CONN_GET H5P__facc_vol_get +#define H5F_ACS_VOL_CONN_DEL H5P__facc_vol_del +#define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy +#define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp +#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close /* Definition for using file locking or not. The default is set * via the configure step. */ -#define H5F_ACS_USE_FILE_LOCKING_SIZE sizeof(hbool_t) +#define H5F_ACS_USE_FILE_LOCKING_SIZE sizeof(hbool_t) #if defined H5_USE_FILE_LOCKING && H5_USE_FILE_LOCKING -#define H5F_ACS_USE_FILE_LOCKING_DEF TRUE +#define H5F_ACS_USE_FILE_LOCKING_DEF TRUE #else -#define H5F_ACS_USE_FILE_LOCKING_DEF FALSE +#define H5F_ACS_USE_FILE_LOCKING_DEF FALSE #endif -#define H5F_ACS_USE_FILE_LOCKING_ENC H5P__encode_hbool_t -#define H5F_ACS_USE_FILE_LOCKING_DEC H5P__decode_hbool_t +#define H5F_ACS_USE_FILE_LOCKING_ENC H5P__encode_hbool_t +#define H5F_ACS_USE_FILE_LOCKING_DEC H5P__decode_hbool_t /* Definition for whether we ignore file locking errors when we can * tell that file locking has been disabled on the file system. * The default is set via the configure step. */ -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE sizeof(hbool_t) +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE sizeof(hbool_t) #if defined H5_IGNORE_DISABLED_FILE_LOCKS && H5_IGNORE_DISABLED_FILE_LOCKS -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF TRUE +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF TRUE #else -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF FALSE +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF FALSE #endif -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC H5P__encode_hbool_t -#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC H5P__decode_hbool_t - +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC H5P__encode_hbool_t +#define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC H5P__decode_hbool_t /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -307,7 +333,7 @@ static herr_t H5P__facc_file_driver_set(hid_t prop_id, const char *name, size_t static herr_t H5P__facc_file_driver_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_driver_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *value); -static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value); /* File image info property callbacks */ @@ -317,13 +343,13 @@ static herr_t H5P__facc_file_image_info_set(hid_t prop_id, const char *name, siz static herr_t H5P__facc_file_image_info_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_file_image_info_copy(const char *name, size_t size, void *value); -static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_file_image_info_close(const char *name, size_t size, void *value); /* encode & decode callbacks */ static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_config_dec(const void **_pp, void *value); -static int H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size); +static int H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value); static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size); @@ -332,18 +358,45 @@ static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *s static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value); /* Metadata cache log location property callbacks */ -static herr_t 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); -static herr_t H5P_facc_mdc_log_location_del(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P_facc_mdc_log_location_copy(const char *name, size_t size, void *value); -static int H5P_facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P_facc_mdc_log_location_close(const char *name, size_t size, void *value); +static herr_t 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); +static herr_t H5P__facc_mdc_log_location_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mdc_log_location_copy(const char *name, size_t size, void *value); +static int H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_mdc_log_location_close(const char *name, size_t size, void *value); /* Metadata cache image property callbacks */ -static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size); +static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, + size_t H5_ATTR_UNUSED size); static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value); +/* VOL connector callbacks */ +static herr_t H5P__facc_vol_create(const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_copy(const char *name, size_t size, void *value); +static int H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_vol_close(const char *name, size_t size, void *value); + +#ifdef H5_HAVE_PARALLEL +/* MPI communicator callbacks */ +static herr_t H5P__facc_mpi_comm_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_comm_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_comm_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_comm_copy(const char *name, size_t size, void *value); +static int H5P__facc_mpi_comm_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_mpi_comm_close(const char *name, size_t size, void *value); + +/* MPI info callbacks */ +static herr_t H5P__facc_mpi_info_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_info_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_info_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_mpi_info_copy(const char *name, size_t size, void *value); +static int H5P__facc_mpi_info_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *value); +#endif /* H5_HAVE_PARALLEL */ /*********************/ /* Package Variables */ @@ -352,79 +405,107 @@ static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value); /* File access property list class library initialization object */ const H5P_libclass_t H5P_CLS_FACC[1] = {{ "file access", /* Class name for debugging */ - H5P_TYPE_FILE_ACCESS, /* Class type */ + H5P_TYPE_FILE_ACCESS, /* Class type */ - &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_ROOT_g, /* Parent class */ &H5P_CLS_FILE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ + &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ H5P__facc_reg_prop, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g = H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ -static const size_t H5F_def_rdcc_nslots_g = H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ -static const size_t H5F_def_rdcc_nbytes_g = H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ -static const double H5F_def_rdcc_w0_g = H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ -static const hsize_t H5F_def_threshold_g = H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */ -static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */ -static const hsize_t H5F_def_meta_block_size_g = H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */ -static const size_t H5F_def_sieve_buf_size_g = H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */ -static const hsize_t H5F_def_sdata_block_size_g = H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */ -static const unsigned H5F_def_gc_ref_g = H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */ -static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */ -static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */ -static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ -static const hbool_t H5F_def_family_to_single_g = H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */ -static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ - -static const H5F_libver_t H5F_def_libver_low_bound_g = H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ -static const H5F_libver_t H5F_def_libver_high_bound_g = H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ - -static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ -static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ -static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ -static const hbool_t H5F_def_core_write_tracking_flag_g = H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF; /* Default setting for core VFD write tracking */ -static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF; /* Default core VFD write tracking page size */ -static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ -static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ -static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ -static const hbool_t H5F_def_skip_eof_check_g = H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */ -static const hbool_t H5F_def_null_fsm_addr_g = H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */ - -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 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 = H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */ +static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g = + H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ +static const size_t H5F_def_rdcc_nslots_g = + H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ +static const size_t H5F_def_rdcc_nbytes_g = + H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ +static const double H5F_def_rdcc_w0_g = + H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ +static const hsize_t H5F_def_threshold_g = + H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */ +static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */ +static const hsize_t H5F_def_meta_block_size_g = + H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */ +static const size_t H5F_def_sieve_buf_size_g = + H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */ +static const hsize_t H5F_def_sdata_block_size_g = + H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */ +static const unsigned H5F_def_gc_ref_g = + H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */ +static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */ +static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */ +static const hsize_t H5F_def_family_newsize_g = + H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ +static const hbool_t H5F_def_family_to_single_g = + H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */ +static const H5FD_mem_t H5F_def_mem_type_g = + H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */ + +static const H5F_libver_t H5F_def_libver_low_bound_g = + H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */ +static const H5F_libver_t H5F_def_libver_high_bound_g = + H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */ + +static const hbool_t H5F_def_want_posix_fd_g = + H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ +static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ +static const H5FD_file_image_info_t H5F_def_file_image_info_g = + H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ +static const unsigned H5F_def_metadata_read_attempts_g = + H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ +static const H5F_object_flush_t H5F_def_object_flush_cb_g = + H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ +static const hbool_t H5F_def_clear_status_flags_g = + H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ +static const hbool_t H5F_def_skip_eof_check_g = + H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */ +static const hbool_t H5F_def_null_fsm_addr_g = + H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */ + +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 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 = + H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */ #ifdef H5_HAVE_PARALLEL -static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */ -static const hbool_t H5F_def_coll_md_write_flag_g = H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */ -#endif /* H5_HAVE_PARALLEL */ -static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */ -static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */ -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 */ -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 = H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */ - - +static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = + H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */ +static const hbool_t H5F_def_coll_md_write_flag_g = + H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */ +static const MPI_Comm H5F_def_mpi_params_comm_g = H5F_ACS_MPI_PARAMS_COMM_DEF; /* Default MPI communicator */ +static const MPI_Info H5F_def_mpi_params_info_g = H5F_ACS_MPI_PARAMS_INFO_DEF; /* Default MPI info struct */ +#endif /* H5_HAVE_PARALLEL */ +static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */ +static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */ +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 */ +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 = + H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */ + /*------------------------------------------------------------------------- * Function: H5P__facc_reg_prop * @@ -439,254 +520,294 @@ static const hbool_t H5F_def_ignore_disabled_file_locks_g = H5F_ACS_IGNORE_DISAB static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass) { - const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FD_driver_prop_t def_driver_prop = + H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ + const H5VL_connector_prop_t def_vol_prop = + H5F_ACS_VOL_CONN_DEF; /* Default VOL connector ID & info (initialized from a variable) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the initial metadata cache resize configuration */ - if(H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE, &H5F_def_mdc_initCacheCfg_g, - NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC, H5F_ACS_META_CACHE_INIT_CONFIG_DEC, - NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE, + &H5F_def_mdc_initCacheCfg_g, NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC, + H5F_ACS_META_CACHE_INIT_CONFIG_DEC, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache (elements) */ - if(H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &H5F_def_rdcc_nslots_g, - NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC, H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE, + &H5F_def_rdcc_nslots_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC, + H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ - if(H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &H5F_def_rdcc_nbytes_g, - NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC, H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, + &H5F_def_rdcc_nbytes_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC, + H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ - if(H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, &H5F_def_rdcc_w0_g, - NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC, H5F_ACS_PREEMPT_READ_CHUNKS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, + &H5F_def_rdcc_w0_g, NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC, + H5F_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the threshold for alignment */ - if(H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g, - NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g, + NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the alignment */ - if(H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, - NULL, NULL, NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, NULL, NULL, + NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum metadata allocation block size */ - if(H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE, &H5F_def_meta_block_size_g, - NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC, H5F_ACS_META_BLOCK_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE, + &H5F_def_meta_block_size_g, NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC, + H5F_ACS_META_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the maximum sieve buffer size */ - if(H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE, &H5F_def_sieve_buf_size_g, - NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC, H5F_ACS_SIEVE_BUF_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE, + &H5F_def_sieve_buf_size_g, NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC, + H5F_ACS_SIEVE_BUF_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum "small data" allocation block size */ - if(H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE, &H5F_def_sdata_block_size_g, - NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC, H5F_ACS_SDATA_BLOCK_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE, + &H5F_def_sdata_block_size_g, NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC, + H5F_ACS_SDATA_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the garbage collection reference */ - if(H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE, &H5F_def_gc_ref_g, - NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC, H5F_ACS_GARBG_COLCT_REF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE, + &H5F_def_gc_ref_g, NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC, + H5F_ACS_GARBG_COLCT_REF_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID & info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop, - H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL, - H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP, H5F_ACS_FILE_DRV_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop, + H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL, + H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP, + H5F_ACS_FILE_DRV_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file close degree */ - if(H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g, - NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g, + NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the offset of family driver info */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE, &H5F_def_family_offset_g, - NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC, H5F_ACS_FAMILY_OFFSET_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE, + &H5F_def_family_offset_g, NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC, + H5F_ACS_FAMILY_OFFSET_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of new family file size. It's used by h5repart only. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE, &H5F_def_family_newsize_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE, + &H5F_def_family_newsize_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the private property of whether convert family to a single-file driver. It's used by h5repart only. */ + /* Register the private property of whether convert family to a single-file driver. It's used by h5repart + * only. */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE, &H5F_def_family_to_single_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE, + &H5F_def_family_to_single_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data type of multi driver info */ - if(H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g, - NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g, + NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'low' bound of library format versions */ - if(H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE, &H5F_def_libver_low_bound_g, - NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC, H5F_ACS_LIBVER_LOW_BOUND_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE, + &H5F_def_libver_low_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC, + H5F_ACS_LIBVER_LOW_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 'high' bound of library format versions */ - if(H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE, &H5F_def_libver_high_bound_g, - NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC, H5F_ACS_LIBVER_HIGH_BOUND_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE, + &H5F_def_libver_high_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC, + H5F_ACS_LIBVER_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to retrieve the file descriptor from the core VFD */ /* (used internally to the library only) */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE, &H5F_def_want_posix_fd_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE, + &H5F_def_want_posix_fd_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file cache size */ - if(H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, - NULL, NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, NULL, + NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the initial file image info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &H5F_def_file_image_info_g, - NULL, H5F_ACS_FILE_IMAGE_INFO_SET, H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, - H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the core VFD backing store write tracking flag */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC, H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the size of the core VFD backing store page size */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, + &H5F_def_file_image_info_g, NULL, H5F_ACS_FILE_IMAGE_INFO_SET, + H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, H5F_ACS_FILE_IMAGE_INFO_DEL, + H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, + H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the # of read attempts */ - if(H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, &H5F_def_metadata_read_attempts_g, - NULL, NULL, NULL, H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, + &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL, + H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register object flush callback */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE, &H5F_def_object_flush_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE, + &H5F_def_object_flush_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE, &H5F_def_clear_status_flags_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear + * only. */ + if (H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE, + &H5F_def_clear_status_flags_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to skip EOF check. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, &H5F_def_skip_eof_check_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, + &H5F_def_skip_eof_check_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */ - if(H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, &H5F_def_null_fsm_addr_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, + &H5F_def_null_fsm_addr_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata cache logging flag. */ - if(H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, &H5F_def_use_mdc_logging_g, - NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, + &H5F_def_use_mdc_logging_g, NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, + H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata cache log location. */ - if(H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE, &H5F_def_mdc_log_location_g, - NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC, H5F_ACS_MDC_LOG_LOCATION_DEC, - H5F_ACS_MDC_LOG_LOCATION_DEL, H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP, H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0) + if (H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE, + &H5F_def_mdc_log_location_g, NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC, + H5F_ACS_MDC_LOG_LOCATION_DEC, H5F_ACS_MDC_LOG_LOCATION_DEL, + H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP, + H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the flag that indicates whether mdc logging starts on file access. */ - if(H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE, &H5F_def_start_mdc_log_on_access_g, - NULL, NULL, NULL, H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE, + &H5F_def_start_mdc_log_on_access_g, NULL, NULL, NULL, + H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL, + NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the evict on close flag */ - if(H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE, &H5F_def_evict_on_close_flag_g, - NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC, H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE, + &H5F_def_evict_on_close_flag_g, NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC, + H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_HAVE_PARALLEL /* Register the metadata collective read flag */ - if(H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE, &H5F_def_coll_md_read_flag_g, - NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC, H5F_ACS_COLL_MD_READ_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE, + &H5F_def_coll_md_read_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC, + H5F_ACS_COLL_MD_READ_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the metadata collective write flag */ - if(H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE, &H5F_def_coll_md_write_flag_g, - NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC, H5F_ACS_COLL_MD_WRITE_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE, + &H5F_def_coll_md_write_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC, + H5F_ACS_COLL_MD_WRITE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the MPI communicator */ + if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_COMM_NAME, H5F_ACS_MPI_PARAMS_COMM_SIZE, + &H5F_def_mpi_params_comm_g, NULL, H5F_ACS_MPI_PARAMS_COMM_SET, + H5F_ACS_MPI_PARAMS_COMM_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_COMM_DEL, + H5F_ACS_MPI_PARAMS_COMM_COPY, H5F_ACS_MPI_PARAMS_COMM_CMP, + H5F_ACS_MPI_PARAMS_COMM_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the MPI info struct */ + if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_INFO_NAME, H5F_ACS_MPI_PARAMS_INFO_SIZE, + &H5F_def_mpi_params_info_g, NULL, H5F_ACS_MPI_PARAMS_INFO_SET, + H5F_ACS_MPI_PARAMS_INFO_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_INFO_DEL, + H5F_ACS_MPI_PARAMS_INFO_COPY, H5F_ACS_MPI_PARAMS_INFO_CMP, + H5F_ACS_MPI_PARAMS_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + #endif /* H5_HAVE_PARALLEL */ /* Register the initial metadata cache image configuration */ - if(H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, - NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, - NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, NULL, + NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, NULL, NULL, + H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE, &H5F_def_page_buf_size_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC, H5F_ACS_PAGE_BUFFER_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE, + &H5F_def_page_buf_size_g, NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC, + H5F_ACS_PAGE_BUFFER_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer minimum metadata size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, + H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, NULL, + NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC, + H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the page buffer minimum raw data size */ - if(H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, - NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, NULL, + NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC, + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the file VOL connector ID & info */ + /* (Note: this property should not have an encode/decode callback -QAK) */ + if (H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop, + H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL, + H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP, + H5F_ACS_VOL_CONN_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the use file locking flag */ - if(H5P__register_real(pclass, H5F_ACS_USE_FILE_LOCKING_NAME, H5F_ACS_USE_FILE_LOCKING_SIZE, &H5F_def_use_file_locking_g, - NULL, NULL, NULL, H5F_ACS_USE_FILE_LOCKING_ENC, H5F_ACS_USE_FILE_LOCKING_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_USE_FILE_LOCKING_NAME, H5F_ACS_USE_FILE_LOCKING_SIZE, + &H5F_def_use_file_locking_g, NULL, NULL, NULL, H5F_ACS_USE_FILE_LOCKING_ENC, + H5F_ACS_USE_FILE_LOCKING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the ignore disabled file locks flag */ - if(H5P__register_real(pclass, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE, &H5F_def_ignore_disabled_file_locks_g, - NULL, NULL, NULL, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, + H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE, &H5F_def_ignore_disabled_file_locks_g, + NULL, NULL, NULL, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC, + H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_alignment * @@ -714,31 +835,30 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihh", fapl_id, threshold, alignment); /* Check args */ - if(alignment < 1) + if (alignment < 1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "alignment must be positive") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) + if (H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set threshold") - if(H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) + if (H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_alignment * @@ -754,32 +874,30 @@ H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment) *------------------------------------------------------------------------- */ herr_t -H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, - hsize_t *alignment/*out*/) +H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, threshold, alignment); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(threshold) - if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0) + if (threshold) + if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get threshold") - if(alignment) - if(H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0) + if (alignment) + if (H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_alignment() */ - /*------------------------------------------------------------------------- * Function: H5P_set_driver * @@ -802,22 +920,22 @@ H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == H5I_object_verify(new_driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ /* Prepare the driver property */ - driver_prop.driver_id = new_driver_id; + driver_prop.driver_id = new_driver_id; driver_prop.driver_info = new_driver_info; /* Set the driver ID & info property */ - if(H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info") } /* end if */ else @@ -827,7 +945,6 @@ H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_drive FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_driver() */ - /*------------------------------------------------------------------------- * Function: H5Pset_driver * @@ -850,27 +967,26 @@ H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_drive herr_t H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", plist_id, new_driver_id, new_driver_info); /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == H5I_object_verify(new_driver_id, H5I_VFL)) + if (NULL == H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") /* Set the driver */ - if(H5P_set_driver(plist, new_driver_id, new_driver_info) < 0) + if (H5P_set_driver(plist, new_driver_id, new_driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_driver() */ - /*------------------------------------------------------------------------- * Function: H5P_peek_driver * @@ -892,29 +1008,28 @@ H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) hid_t H5P_peek_driver(H5P_genplist_t *plist) { - hid_t ret_value = FAIL; /* Return value */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the current driver ID */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") ret_value = driver_prop.driver_id; } /* end if */ else HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_VFD_DEFAULT == ret_value) + if (H5FD_VFD_DEFAULT == ret_value) ret_value = H5_DEFAULT_VFD; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_peek_driver() */ - /*------------------------------------------------------------------------- * Function: H5Pget_driver * @@ -938,24 +1053,23 @@ H5P_peek_driver(H5P_genplist_t *plist) hid_t H5Pget_driver(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", plist_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get the driver */ - if((ret_value = H5P_peek_driver(plist)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver") + if ((ret_value = H5P_peek_driver(plist)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_driver() */ - /*------------------------------------------------------------------------- * Function: H5P_peek_driver_info * @@ -978,15 +1092,15 @@ H5Pget_driver(hid_t plist_id) const void * H5P_peek_driver_info(H5P_genplist_t *plist) { - const void *ret_value = NULL; /* Return value */ + const void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Get the current driver info */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") ret_value = driver_prop.driver_info; } /* end if */ @@ -997,7 +1111,6 @@ H5P_peek_driver_info(H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_peek_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5Pget_driver_info * @@ -1020,24 +1133,23 @@ H5P_peek_driver_info(H5P_genplist_t *plist) const void * H5Pget_driver_info(hid_t plist_id) { - H5P_genplist_t *plist = NULL; /* Property list pointer */ - const void *ret_value = NULL; /* Return value */ + H5P_genplist_t *plist = NULL; /* Property list pointer */ + const void * ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE1("*x", "i", plist_id); - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") /* Get the driver info */ - if(NULL == (ret_value = (const void *)H5P_peek_driver_info(plist))) + if (NULL == (ret_value = (const void *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_driver_info() */ - /*------------------------------------------------------------------------- * Function: H5P__file_driver_copy * @@ -1058,35 +1170,35 @@ H5Pget_driver_info(hid_t plist_id) static herr_t H5P__file_driver_copy(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { + if (value) { H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ /* Copy the driver & info, if there is one */ - if(info->driver_id > 0) { + if (info->driver_id > 0) { /* Increment the reference count on driver and copy driver info */ - if(H5I_inc_ref(info->driver_id, FALSE) < 0) + if (H5I_inc_ref(info->driver_id, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") /* Copy driver info, if it exists */ - if(info->driver_info) { - H5FD_class_t *driver; /* Pointer to driver */ - void *new_pl; /* Copy of driver info */ + if (info->driver_info) { + H5FD_class_t *driver; /* Pointer to driver */ + void * new_pl; /* Copy of driver info */ /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) + if (NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") /* Allow the driver to copy or do it ourselves */ - if(driver->fapl_copy) { - if(NULL == (new_pl = (driver->fapl_copy)(info->driver_info))) + if (driver->fapl_copy) { + if (NULL == (new_pl = (driver->fapl_copy)(info->driver_info))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed") } /* end if */ - else if(driver->fapl_size > 0) { - if(NULL == (new_pl = H5MM_malloc(driver->fapl_size))) + else if (driver->fapl_size > 0) { + if (NULL == (new_pl = H5MM_malloc(driver->fapl_size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed") H5MM_memcpy(new_pl, info->driver_info, driver->fapl_size); } /* end else-if */ @@ -1096,14 +1208,13 @@ H5P__file_driver_copy(void *value) /* Set the driver info for the copy */ info->driver_info = new_pl; } /* end if */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_driver_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__file_driver_free * @@ -1120,33 +1231,23 @@ H5P__file_driver_copy(void *value) static herr_t H5P__file_driver_free(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { + if (value) { H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ /* Copy the driver & info, if there is one */ - if(info->driver_id > 0) { - if(info->driver_info) { - H5FD_class_t *driver; /* Pointer to driver */ - - /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") + if (info->driver_id > 0) { - /* Allow driver to free info or do it ourselves */ - if(driver->fapl_free) { - if((driver->fapl_free)((void *)info->driver_info) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") - } /* end if */ - else - H5MM_xfree((void *)info->driver_info); /* Casting away const OK -QAK */ - } /* end if */ + /* Free the driver info, if it exists */ + if (info->driver_info) + if (H5FD_free_driver_info(info->driver_id, info->driver_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") /* Decrement reference count for driver */ - if(H5I_dec_ref(info->driver_id) < 0) + if (H5I_dec_ref(info->driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") } } @@ -1155,7 +1256,6 @@ H5P__file_driver_free(void *value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_driver_free() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_create * @@ -1172,19 +1272,18 @@ H5P__file_driver_free(void *value) static herr_t H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_create() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_set * @@ -1200,9 +1299,9 @@ H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNU */ static herr_t H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1210,14 +1309,13 @@ H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE HDassert(value); /* Make copy of file driver ID & info */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_get * @@ -1233,9 +1331,9 @@ H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE */ static herr_t H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1243,14 +1341,13 @@ H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE HDassert(value); /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_del * @@ -1265,21 +1362,21 @@ H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static herr_t -H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file driver ID & info */ - if(H5P__file_driver_free(value) < 0) + if (H5P__file_driver_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_copy * @@ -1296,19 +1393,18 @@ H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSE static herr_t H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file driver */ - if(H5P__file_driver_copy(value) < 0) + if (H5P__file_driver_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_cmp * @@ -1325,14 +1421,14 @@ H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static int -H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, - size_t H5_ATTR_UNUSED size) +H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5FD_driver_prop_t *info1 = (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */ + const H5FD_driver_prop_t *info1 = + (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */ *info2 = (const H5FD_driver_prop_t *)_info2; - H5FD_class_t *cls1, *cls2; /* Driver class for each property */ - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + H5FD_class_t *cls1, *cls2; /* Driver class for each property */ + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1342,24 +1438,30 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, HDassert(size == sizeof(H5FD_driver_prop_t)); /* Compare drivers */ - if(NULL == (cls1 = H5FD_get_class(info1->driver_id))) + if (NULL == (cls1 = H5FD_get_class(info1->driver_id))) HGOTO_DONE(-1) - if(NULL == (cls2 = H5FD_get_class(info2->driver_id))) + if (NULL == (cls2 = H5FD_get_class(info2->driver_id))) HGOTO_DONE(1) - if(cls1->name == NULL && cls2->name != NULL) HGOTO_DONE(-1); - if(cls1->name != NULL && cls2->name == NULL) HGOTO_DONE(1); - if(0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) + if (cls1->name == NULL && cls2->name != NULL) + HGOTO_DONE(-1); + if (cls1->name != NULL && cls2->name == NULL) + HGOTO_DONE(1); + if (0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) HGOTO_DONE(cmp_value); /* Compare driver infos */ - if(cls1->fapl_size < cls2->fapl_size) HGOTO_DONE(-1) - if(cls1->fapl_size > cls2->fapl_size) HGOTO_DONE(1) + if (cls1->fapl_size < cls2->fapl_size) + HGOTO_DONE(-1) + if (cls1->fapl_size > cls2->fapl_size) + HGOTO_DONE(1) HDassert(cls1->fapl_size == cls2->fapl_size); - if(info1->driver_info == NULL && info2->driver_info != NULL) HGOTO_DONE(-1); - if(info1->driver_info != NULL && info2->driver_info == NULL) HGOTO_DONE(1); - if(info1->driver_info) { + if (info1->driver_info == NULL && info2->driver_info != NULL) + HGOTO_DONE(-1); + if (info1->driver_info != NULL && info2->driver_info == NULL) + HGOTO_DONE(1); + if (info1->driver_info) { HDassert(cls1->fapl_size > 0); - if(0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) + if (0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) HGOTO_DONE(cmp_value); } /* end if */ @@ -1367,7 +1469,6 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_driver_close * @@ -1384,19 +1485,18 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, static herr_t H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file driver */ - if(H5P__file_driver_free(value) < 0) + if (H5P__file_driver_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_family_offset * @@ -1411,31 +1511,30 @@ H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUS * Sep 17, 2002 * *------------------------------------------------------------------------- -*/ + */ herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", fapl_id, offset); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) + if (H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set offset for family file") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_family_offset() */ - /*------------------------------------------------------------------------- * Function: H5Pget_family_offset * @@ -1454,21 +1553,21 @@ H5Pset_family_offset(hid_t fapl_id, hsize_t offset) herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", fapl_id, offset); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(offset) { - if(H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0) + if (offset) { + if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set offset for family file") } /* end if */ @@ -1476,7 +1575,6 @@ H5Pget_family_offset(hid_t fapl_id, hsize_t *offset) FUNC_LEAVE_API(ret_value) } /* end H5Pget_family_offset() */ - /*------------------------------------------------------------------------- * Function: H5Pset_multi_type * @@ -1495,27 +1593,26 @@ H5Pget_family_offset(hid_t fapl_id, hsize_t *offset) herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iMt", fapl_id, type); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) + if (H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type for multi driver") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_multi_type() */ - /*------------------------------------------------------------------------- * Function: H5Pget_multi_type * @@ -1534,21 +1631,21 @@ H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type) herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Mt", fapl_id, type); /* Get the plist structure */ - if(H5P_DEFAULT == fapl_id) + if (H5P_DEFAULT == fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(type) { - if(H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0) + if (type) { + if (H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get type for multi driver") } /* end if */ @@ -1556,7 +1653,6 @@ H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type) FUNC_LEAVE_API(ret_value) } /* end H5Pget_multi_type() */ - /*------------------------------------------------------------------------- * Function: H5Pset_cache * @@ -1580,37 +1676,36 @@ H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type) *------------------------------------------------------------------------- */ herr_t -H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, - size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) +H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes, + double rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, - rdcc_w0); + H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments */ - if(rdcc_w0 < (double)0.0f || rdcc_w0 > (double)1.0f) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive") + if (rdcc_w0 < 0.0 || rdcc_w0 > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "raw data cache w0 value must be between 0.0 and 1.0 inclusive") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set sizes */ - if(H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of slots") - if(H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size") - if(H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks") + if (H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") + if (H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") + if (H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pget_cache * @@ -1628,41 +1723,38 @@ H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, *------------------------------------------------------------------------- */ herr_t -H5Pget_cache(hid_t plist_id, int *mdc_nelmts, - size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) +H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, - rdcc_w0); + H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get sizes */ /* the mdc_nelmts FAPL entry no longer exists, so just return a constant */ - if(mdc_nelmts) + if (mdc_nelmts) *mdc_nelmts = 0; - if(rdcc_nslots) - if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots") - if(rdcc_nbytes) - if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size") - if(rdcc_w0) - if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks") + if (rdcc_nslots) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots") + if (rdcc_nbytes) + if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size") + if (rdcc_w0) + if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_cache() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_image_config * @@ -1679,18 +1771,18 @@ H5Pget_cache(hid_t plist_id, int *mdc_nelmts, herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the new configuration */ - if(H5AC_validate_cache_image_config(config_ptr) < 0) + if (H5AC_validate_cache_image_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache image configuration") /* set the modified metadata cache image config */ @@ -1699,14 +1791,13 @@ H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) * will have to test the version and do translation here. */ - if(H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) + if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache image initial config") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_mdc_image_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_image_config * @@ -1725,23 +1816,22 @@ H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) *------------------------------------------------------------------------- */ herr_t -H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) +H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", plist_id, config_ptr); + H5TRACE2("e", "i*x", plist_id, config); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* validate the config_ptr */ - if(config_ptr == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - - if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) + /* validate the config ptr */ + if (config == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.") + if (config->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown image config version.") /* If we ever support multiple versions of H5AC_cache_config_t, we @@ -1750,14 +1840,13 @@ H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) */ /* Get the current initial metadata cache resize configuration */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get metadata cache initial image config") + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial image config") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_mdc_image_config() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_config * @@ -1774,18 +1863,18 @@ H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr) herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", plist_id, config_ptr); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* validate the new configuration */ - if(H5AC_validate_config(config_ptr) < 0) + if (H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache configuration") /* set the modified config */ @@ -1794,21 +1883,20 @@ H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) * will have to test the version and do translation here. */ - if(H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) + if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_config * * Purpose: Retrieve the metadata cache initial resize configuration * from the target FAPL. * - * Observe that the function will fail if config_ptr is + * Observe that the function will fail if config is * NULL, or if config_ptr->version specifies an unknown * version of H5AC_cache_config_t. * @@ -1820,23 +1908,22 @@ H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) *------------------------------------------------------------------------- */ herr_t -H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) +H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", plist_id, config_ptr); + H5TRACE2("e", "i*x", plist_id, config); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* validate the config_ptr */ - if(config_ptr == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - - if(config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION) + /* validate the config ptr */ + if (config == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.") + if (config->version != H5AC__CURR_CACHE_CONFIG_VERSION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.") /* If we ever support multiple versions of H5AC_cache_config_t, we @@ -1845,14 +1932,13 @@ H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) */ /* Get the current initial metadata cache resize configuration */ - if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get metadata cache initial resize config") + if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial resize config") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_mdc_config() */ - /*------------------------------------------------------------------------- * Function: H5Pset_gc_references * @@ -1880,25 +1966,24 @@ H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr) herr_t H5Pset_gc_references(hid_t plist_id, unsigned gc_ref) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, gc_ref); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0) + if (H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_gc_references * @@ -1913,28 +1998,27 @@ H5Pset_gc_references(hid_t plist_id, unsigned gc_ref) *------------------------------------------------------------------------- */ herr_t -H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref/*out*/) +H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, gc_ref); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(gc_ref) - if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0) + if (gc_ref) + if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_fclose_degree * @@ -1950,25 +2034,24 @@ H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref/*out*/) herr_t H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFd", plist_id, degree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, °ree) < 0) + if (H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, °ree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fclose_degree() */ - /*------------------------------------------------------------------------- * Function: H5Pget_fclose_degree * @@ -1984,24 +2067,23 @@ H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree) herr_t H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Fd", plist_id, degree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0) + if (degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fclose_degree() */ - /*------------------------------------------------------------------------- * Function: H5Pset_meta_block_size * @@ -2027,25 +2109,24 @@ H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree) herr_t H5Pset_meta_block_size(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data block size") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_meta_block_size * @@ -2060,21 +2141,21 @@ H5Pset_meta_block_size(hid_t plist_id, hsize_t size) *------------------------------------------------------------------------- */ herr_t -H5Pget_meta_block_size(hid_t plist_id, hsize_t *size/*out*/) +H5Pget_meta_block_size(hid_t plist_id, hsize_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) { - if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) + if (size) { + if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get meta data block size") } /* end if */ @@ -2082,7 +2163,6 @@ H5Pget_meta_block_size(hid_t plist_id, hsize_t *size/*out*/) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_sieve_buf_size * @@ -2108,25 +2188,24 @@ H5Pget_meta_block_size(hid_t plist_id, hsize_t *size/*out*/) herr_t H5Pset_sieve_buf_size(hid_t plist_id, size_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_sieve_buf_size * @@ -2141,28 +2220,27 @@ H5Pset_sieve_buf_size(hid_t plist_id, size_t size) *------------------------------------------------------------------------- */ herr_t -H5Pget_sieve_buf_size(hid_t plist_id, size_t *size/*out*/) +H5Pget_sieve_buf_size(hid_t plist_id, size_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) - if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0) + if (size) + if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_sieve_buf_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_small_data_block_size * @@ -2188,25 +2266,24 @@ H5Pget_sieve_buf_size(hid_t plist_id, size_t *size/*out*/) herr_t H5Pset_small_data_block_size(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0) + if (H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' block size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_small_data_block_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_small_data_block_size * @@ -2221,21 +2298,21 @@ H5Pset_small_data_block_size(hid_t plist_id, hsize_t size) *------------------------------------------------------------------------- */ herr_t -H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size/*out*/) +H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(size) { - if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0) + if (size) { + if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get 'small data' block size") } /* end if */ @@ -2243,7 +2320,6 @@ H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_small_data_block_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_libver_bounds * @@ -2351,41 +2427,39 @@ H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size/*out*/) herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iFvFv", plist_id, low, high); /* Check args */ - if(low < 0 || low > H5F_LIBVER_LATEST) + if (low < 0 || low > H5F_LIBVER_LATEST) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid") - - if(high < 0 || high > H5F_LIBVER_LATEST) + if (high < 0 || high > H5F_LIBVER_LATEST) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid") /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */ - if(high == H5F_LIBVER_EARLIEST) + if (high == H5F_LIBVER_EARLIEST) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") /* (latest, v18) is not valid combination */ - if(high < low) + if (high < low) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0) + if (H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions") - if(H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0) + if (H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Pget_libver_bounds * @@ -2400,35 +2474,31 @@ H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high) *------------------------------------------------------------------------- */ herr_t -H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, - H5F_libver_t *high/*out*/) +H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low /*out*/, H5F_libver_t *high /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, low, high); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get values */ - if(low) { - if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0) + /* Get values */ + if (low) + if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions") - } - if(high) { - if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0) + if (high) + if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions") - } done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_file_cache_size * @@ -2448,25 +2518,24 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/, herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, efc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) + if (H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set elink file cache size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_file_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_file_cache_size * @@ -2486,26 +2555,25 @@ H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size) herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, efc_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(efc_size) - if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0) + if (efc_size) + if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink file cache size") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_file_cache_size() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_image * @@ -2522,29 +2590,31 @@ H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size) herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t image_info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t image_info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xz", fapl_id, buf_ptr, buf_len); /* validate parameters */ - if(!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0)))) + if (!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0)))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "inconsistent buf_ptr and buf_len") /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old image info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image pointer") /* Release previous buffer, if it exists */ - if(image_info.buffer != NULL) { - if(image_info.callbacks.image_free) { - if(SUCCEED != image_info.callbacks.image_free(image_info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata)) + if (image_info.buffer != NULL) { + if (image_info.callbacks.image_free) { + if (SUCCEED != image_info.callbacks.image_free(image_info.buffer, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, + image_info.callbacks.udata)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else @@ -2552,25 +2622,24 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) } /* end if */ /* Update struct */ - if(buf_ptr) { + if (buf_ptr) { /* Allocate memory */ - if(image_info.callbacks.image_malloc) { - if(NULL == (image_info.buffer = image_info.callbacks.image_malloc(buf_len, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata))) + if (image_info.callbacks.image_malloc) { + if (NULL == (image_info.buffer = image_info.callbacks.image_malloc( + buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed") - } /* end if */ - else - if(NULL == (image_info.buffer = H5MM_malloc(buf_len))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") + } /* end if */ + else if (NULL == (image_info.buffer = H5MM_malloc(buf_len))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") /* Copy data */ - if(image_info.callbacks.image_memcpy) { - if(image_info.buffer != image_info.callbacks.image_memcpy(image_info.buffer, - buf_ptr, buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, - image_info.callbacks.udata)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") + if (image_info.callbacks.image_memcpy) { + if (image_info.buffer != image_info.callbacks.image_memcpy(image_info.buffer, buf_ptr, buf_len, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, + image_info.callbacks.udata)) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(image_info.buffer, buf_ptr, buf_len); } /* end if */ else @@ -2579,33 +2648,32 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) image_info.size = buf_len; /* Set values */ - if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_file_image() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_image * - * Purpose: If the file image exists and buf_ptr_ptr is not NULL, + * Purpose: If the file image exists and buf is not NULL, * allocate a buffer of the correct size, copy the image into * the new buffer, and return the buffer to the caller in - * *buf_ptr_ptr. Do this using the file image callbacks + * *buf. Do this using the file image callbacks * if defined. * * NB: It is the responsibility of the caller to free the - * buffer whose address is returned in *buf_ptr_ptr. Do + * buffer whose address is returned in *buf. Do * this using free if the file image callbacks are not * defined, or with whatever method is appropriate if * the callbacks are defined. * - * If buf_ptr_ptr is not NULL, and no image exists, set - * *buf_ptr_ptr to NULL. + * If buf is not NULL, and no image exists, set + * *buf to NULL. * - * If buf_len_ptr is not NULL, set *buf_len_ptr equal + * If buf_len is not NULL, set *buf_len equal * to the length of the file image if it exists, and * to 0 if it does not. * @@ -2617,21 +2685,21 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) *------------------------------------------------------------------------- */ herr_t -H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) +H5Pget_file_image(hid_t fapl_id, void **buf, size_t *buf_len) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t image_info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t image_info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i**x*z", fapl_id, buf_ptr_ptr, buf_len_ptr); + H5TRACE3("e", "i**x*z", fapl_id, buf, buf_len); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistency */ @@ -2639,43 +2707,42 @@ H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) ((image_info.buffer == NULL) && (image_info.size == 0))); /* Set output size */ - if(buf_len_ptr != NULL) - *buf_len_ptr = image_info.size; + if (buf_len != NULL) + *buf_len = image_info.size; /* Duplicate the image if desired, using callbacks if available */ - if(buf_ptr_ptr != NULL) { - void * copy_ptr = NULL; /* Copy of memory image */ + if (buf != NULL) { + void *copy_ptr = NULL; /* Copy of memory image */ - if(image_info.buffer != NULL) { + if (image_info.buffer != NULL) { /* Allocate memory */ - if(image_info.callbacks.image_malloc) { - if(NULL == (copy_ptr = image_info.callbacks.image_malloc(image_info.size, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata))) + if (image_info.callbacks.image_malloc) { + if (NULL == + (copy_ptr = image_info.callbacks.image_malloc( + image_info.size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed") } /* end if */ - else - if(NULL == (copy_ptr = H5MM_malloc(image_info.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate copy") + else if (NULL == (copy_ptr = H5MM_malloc(image_info.size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate copy") /* Copy data */ - if(image_info.callbacks.image_memcpy) { - if(copy_ptr != image_info.callbacks.image_memcpy(copy_ptr, image_info.buffer, - image_info.size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, - image_info.callbacks.udata)) + if (image_info.callbacks.image_memcpy) { + if (copy_ptr != image_info.callbacks.image_memcpy( + copy_ptr, image_info.buffer, image_info.size, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata)) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(copy_ptr, image_info.buffer, image_info.size); } /* end if */ - *buf_ptr_ptr = copy_ptr; + *buf = copy_ptr; } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_file_image */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_image_callbacks * @@ -2695,66 +2762,66 @@ H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, callbacks_ptr); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image info") /* verify file image field consistency */ - HDassert(((info.buffer != NULL) && (info.size > 0)) || - ((info.buffer == NULL) && (info.size == 0))); + HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0))); /* Make sure a file image hasn't already been set */ - if(info.buffer != NULL || info.size > 0) - HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "setting callbacks when an image is already set is forbidden. It could cause memory leaks.") + if (info.buffer != NULL || info.size > 0) + HGOTO_ERROR( + H5E_PLIST, H5E_SETDISALLOWED, FAIL, + "setting callbacks when an image is already set is forbidden. It could cause memory leaks.") /* verify that callbacks_ptr is not NULL */ - if(NULL == callbacks_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") + if (NULL == callbacks_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") /* Make sure udata callbacks are going to be set if udata is going to be set */ - if(callbacks_ptr->udata) - if(callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL) + if (callbacks_ptr->udata) + if (callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL) HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "udata callbacks must be set if udata is set") /* Release old udata if it exists */ - if(info.callbacks.udata != NULL) { + if (info.callbacks.udata != NULL) { HDassert(info.callbacks.udata_free); - if(info.callbacks.udata_free(info.callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") + if (info.callbacks.udata_free(info.callbacks.udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") } /* end if */ /* Update struct */ info.callbacks = *callbacks_ptr; - if(callbacks_ptr->udata) { + if (callbacks_ptr->udata) { HDassert(callbacks_ptr->udata_copy); HDassert(callbacks_ptr->udata_free); - if((info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata)) == NULL) + 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") } /* end if */ /* Set values */ - if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_file_image_callbacks() */ - /*------------------------------------------------------------------------- - * Function: H5Pget_file_image_callbacks + * Function: H5Pget_file_image_callbacks * * Purpose: Sets the callbacks for file images. Some file drivers allow * the use of user-defined callbacks for allocating, freeing and @@ -2769,46 +2836,44 @@ H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback *------------------------------------------------------------------------- */ herr_t -H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr) +H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks) { - H5P_genplist_t *fapl; /* Property list pointer */ - H5FD_file_image_info_t info; /* File image info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * fapl; /* Property list pointer */ + H5FD_file_image_info_t info; /* File image info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", fapl_id, callbacks_ptr); + H5TRACE2("e", "i*x", fapl_id, callbacks); /* Get the plist structure */ - if(NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistency */ - HDassert(((info.buffer != NULL) && (info.size > 0)) || - ((info.buffer == NULL) && (info.size == 0))); + HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0))); - /* verify that callbacks_ptr is not NULL */ - if(NULL == callbacks_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr") + /* verify that callbacks is not NULL */ + if (NULL == callbacks) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks ptr") /* Transfer values to parameters */ - *callbacks_ptr = info.callbacks; + *callbacks = info.callbacks; /* Copy udata if it exists */ - if(info.callbacks.udata != NULL) { + if (info.callbacks.udata != NULL) { HDassert(info.callbacks.udata_copy); - if((callbacks_ptr->udata = info.callbacks.udata_copy(info.callbacks.udata)) == 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata") + if ((callbacks->udata = info.callbacks.udata_copy(info.callbacks.udata)) == 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata") } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_file_image_callbacks() */ - /*------------------------------------------------------------------------- * Function: H5P__file_image_info_copy * @@ -2831,12 +2896,12 @@ H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback static herr_t H5P__file_image_info_copy(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { - H5FD_file_image_info_t *info; /* Image info struct */ + if (value) { + H5FD_file_image_info_t *info; /* Image info struct */ info = (H5FD_file_image_info_t *)value; @@ -2844,49 +2909,49 @@ H5P__file_image_info_copy(void *value) HDassert(((info->buffer != NULL) && (info->size > 0)) || ((info->buffer == NULL) && (info->size == 0))); - if(info->buffer && info->size > 0) { - void *old_buffer; /* Pointer to old image buffer */ + if (info->buffer && info->size > 0) { + void *old_buffer; /* Pointer to old image buffer */ /* Store the old buffer */ old_buffer = info->buffer; /* Allocate new buffer */ - if(info->callbacks.image_malloc) { - if(NULL == (info->buffer = info->callbacks.image_malloc(info->size, - H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata))) + if (info->callbacks.image_malloc) { + if (NULL == (info->buffer = info->callbacks.image_malloc( + info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed") } /* end if */ else { - if(NULL == (info->buffer = H5MM_malloc(info->size))) + if (NULL == (info->buffer = H5MM_malloc(info->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block") } /* end else */ /* Copy data to new buffer */ - if(info->callbacks.image_memcpy) { - if(info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, - info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") + if (info->callbacks.image_memcpy) { + if (info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, info->size, + H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, + info->callbacks.udata)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ - else + else H5MM_memcpy(info->buffer, old_buffer, info->size); } /* end if */ /* Copy udata if it exists */ - if(info->callbacks.udata) { + if (info->callbacks.udata) { void *old_udata = info->callbacks.udata; - if(NULL == info->callbacks.udata_copy) + if (NULL == info->callbacks.udata_copy) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_copy not defined") info->callbacks.udata = info->callbacks.udata_copy(old_udata); } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_image_info_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__file_image_info_free * @@ -2905,12 +2970,12 @@ H5P__file_image_info_copy(void *value) static herr_t H5P__file_image_info_free(void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(value) { - H5FD_file_image_info_t *info; /* Image info struct */ + if (value) { + H5FD_file_image_info_t *info; /* Image info struct */ info = (H5FD_file_image_info_t *)value; @@ -2919,29 +2984,29 @@ H5P__file_image_info_free(void *value) ((info->buffer == NULL) && (info->size == 0))); /* Free buffer */ - if(info->buffer != NULL && info->size > 0) { - if(info->callbacks.image_free) { - if((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, info->callbacks.udata) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed") + if (info->buffer != NULL && info->size > 0) { + if (info->callbacks.image_free) { + if ((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, + info->callbacks.udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else H5MM_xfree(info->buffer); } /* end if */ /* Free udata if it exists */ - if(info->callbacks.udata) { - if(NULL == info->callbacks.udata_free) + if (info->callbacks.udata) { + if (NULL == info->callbacks.udata_free) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_free not defined") - if((*info->callbacks.udata_free)(info->callbacks.udata) < 0) + if ((*info->callbacks.udata_free)(info->callbacks.udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed") } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__file_image_info_free() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_cmp * @@ -2958,33 +3023,44 @@ H5P__file_image_info_free(void *value) static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size) { - const H5AC_cache_image_config_t *config1 = (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */ - const H5AC_cache_image_config_t *config2 = (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */ - int ret_value = 0; /* Return value */ + const H5AC_cache_image_config_t *config1 = + (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */ + const H5AC_cache_image_config_t *config2 = + (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for a property being set */ - if(config1 == NULL && config2 != NULL) HGOTO_DONE(-1); - if(config1 != NULL && config2 == NULL) HGOTO_DONE(1); + if (config1 == NULL && config2 != NULL) + HGOTO_DONE(-1); + if (config1 != NULL && config2 == NULL) + HGOTO_DONE(1); - if(config1->version < config2->version) HGOTO_DONE(-1); - if(config1->version > config2->version) HGOTO_DONE(1); + if (config1->version < config2->version) + HGOTO_DONE(-1); + if (config1->version > config2->version) + HGOTO_DONE(1); - if(config1->generate_image < config2->generate_image) HGOTO_DONE(-1); - if(config1->generate_image > config2->generate_image) HGOTO_DONE(1); + if (config1->generate_image < config2->generate_image) + HGOTO_DONE(-1); + if (config1->generate_image > config2->generate_image) + HGOTO_DONE(1); - if(config1->save_resize_status < config2->save_resize_status) HGOTO_DONE(-1); - if(config1->save_resize_status > config2->save_resize_status) HGOTO_DONE(1); + if (config1->save_resize_status < config2->save_resize_status) + HGOTO_DONE(-1); + if (config1->save_resize_status > config2->save_resize_status) + HGOTO_DONE(1); - if(config1->entry_ageout < config2->entry_ageout) HGOTO_DONE(-1); - if(config1->entry_ageout > config2->entry_ageout) HGOTO_DONE(1); + if (config1->entry_ageout < config2->entry_ageout) + HGOTO_DONE(-1); + if (config1->entry_ageout > config2->entry_ageout) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_image_config_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_enc * @@ -3003,7 +3079,8 @@ H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, siz static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) { - const H5AC_cache_image_config_t *config = (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */ + const H5AC_cache_image_config_t *config = + (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3011,7 +3088,7 @@ H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) /* Sanity check */ HDassert(value); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode type sizes (as a safety check) */ *(*pp)++ = (uint8_t)sizeof(unsigned); @@ -3030,7 +3107,6 @@ H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_cache_image_config_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_image_config_dec * @@ -3050,9 +3126,9 @@ 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; - unsigned enc_size; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t ** pp = (const uint8_t **)_pp; + unsigned enc_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3067,7 +3143,7 @@ H5P__facc_cache_image_config_dec(const void **_pp, void *_value) /* Decode type sizes */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") INT32DECODE(*pp, config->version); @@ -3082,7 +3158,6 @@ H5P__facc_cache_image_config_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_image_config_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_set * @@ -3098,9 +3173,9 @@ H5P__facc_cache_image_config_dec(const void **_pp, void *_value) */ static herr_t H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3108,14 +3183,13 @@ H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U HDassert(value); /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_set() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_get * @@ -3131,9 +3205,9 @@ H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U */ static herr_t H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3141,14 +3215,13 @@ H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U HDassert(value); /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_get() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_del * @@ -3165,21 +3238,21 @@ H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file image info */ - if(H5P__file_image_info_free(value) < 0) + if (H5P__file_image_info_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_del() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_copy * @@ -3197,19 +3270,18 @@ H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U static herr_t H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Make copy of file image info */ - if(H5P__file_image_info_copy(value) < 0) + if (H5P__file_image_info_copy(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_cmp * @@ -3226,12 +3298,12 @@ H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_U *------------------------------------------------------------------------- */ static int -H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, - size_t H5_ATTR_UNUSED size) +H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *)_info1, /* Create local aliases for values */ - *info2 = (const H5FD_file_image_info_t *)_info2; - herr_t ret_value = 0; /* Return value */ + const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *) + _info1, /* Create local aliases for values */ + *info2 = (const H5FD_file_image_info_t *)_info2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3241,34 +3313,45 @@ H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, HDassert(size == sizeof(H5FD_file_image_info_t)); /* Check for different buffer sizes */ - if(info1->size < info2->size) HGOTO_DONE(-1) - if(info1->size > info2->size) HGOTO_DONE(1) + if (info1->size < info2->size) + HGOTO_DONE(-1) + if (info1->size > info2->size) + HGOTO_DONE(1) /* Check for different callbacks */ /* (Order in memory is fairly meaningless, so just check for equality) */ - if(info1->callbacks.image_malloc != info2->callbacks.image_malloc) HGOTO_DONE(1) - if(info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) HGOTO_DONE(-1) - if(info1->callbacks.image_realloc != info2->callbacks.image_realloc) HGOTO_DONE(1) - if(info1->callbacks.image_free != info2->callbacks.image_free) HGOTO_DONE(-1) - if(info1->callbacks.udata_copy != info2->callbacks.udata_copy) HGOTO_DONE(1) - if(info1->callbacks.udata_free != info2->callbacks.udata_free) HGOTO_DONE(-1) + if (info1->callbacks.image_malloc != info2->callbacks.image_malloc) + HGOTO_DONE(1) + if (info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) + HGOTO_DONE(-1) + if (info1->callbacks.image_realloc != info2->callbacks.image_realloc) + HGOTO_DONE(1) + if (info1->callbacks.image_free != info2->callbacks.image_free) + HGOTO_DONE(-1) + if (info1->callbacks.udata_copy != info2->callbacks.udata_copy) + HGOTO_DONE(1) + if (info1->callbacks.udata_free != info2->callbacks.udata_free) + HGOTO_DONE(-1) /* Check for different udata */ /* (Don't know how big it is, so can't check contents) */ - if(info1->callbacks.udata < info2->callbacks.udata) HGOTO_DONE(-1) - if(info1->callbacks.udata > info2->callbacks.udata) HGOTO_DONE(1) + if (info1->callbacks.udata < info2->callbacks.udata) + HGOTO_DONE(-1) + if (info1->callbacks.udata > info2->callbacks.udata) + HGOTO_DONE(1) /* Check buffer contents (instead of buffer pointers) */ - if(info1->buffer != NULL && info2->buffer == NULL) HGOTO_DONE(-1) - if(info1->buffer == NULL && info2->buffer != NULL) HGOTO_DONE(1) - if(info1->buffer != NULL && info2->buffer != NULL) + if (info1->buffer != NULL && info2->buffer == NULL) + HGOTO_DONE(-1) + if (info1->buffer == NULL && info2->buffer != NULL) + HGOTO_DONE(1) + if (info1->buffer != NULL && info2->buffer != NULL) ret_value = HDmemcmp(info1->buffer, info2->buffer, size); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_file_image_info_close * @@ -3286,19 +3369,18 @@ H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, static herr_t H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Free the file image info */ - if(H5P__file_image_info_free(value) < 0) + if (H5P__file_image_info_free(value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_image_info_close() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_cmp * @@ -3315,102 +3397,159 @@ H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_ static int H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size) { - const H5AC_cache_config_t *config1 = (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */ - const H5AC_cache_config_t *config2 = (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */ - int ret_value = 0; /* Return value */ + const H5AC_cache_config_t *config1 = + (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */ + const H5AC_cache_config_t *config2 = + (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for a property being set */ - if(config1 == NULL && config2 != NULL) HGOTO_DONE(-1); - if(config1 != NULL && config2 == NULL) HGOTO_DONE(1); + if (config1 == NULL && config2 != NULL) + HGOTO_DONE(-1); + if (config1 != NULL && config2 == NULL) + HGOTO_DONE(1); - if(config1->version < config2->version) HGOTO_DONE(-1); - if(config1->version > config2->version) HGOTO_DONE(1); + if (config1->version < config2->version) + HGOTO_DONE(-1); + if (config1->version > config2->version) + HGOTO_DONE(1); - if(config1->rpt_fcn_enabled < config2->rpt_fcn_enabled) HGOTO_DONE(-1); - if(config1->rpt_fcn_enabled > config2->rpt_fcn_enabled) HGOTO_DONE(1); + if (config1->rpt_fcn_enabled < config2->rpt_fcn_enabled) + HGOTO_DONE(-1); + if (config1->rpt_fcn_enabled > config2->rpt_fcn_enabled) + HGOTO_DONE(1); - if(config1->evictions_enabled < config2->evictions_enabled) HGOTO_DONE(-1); - if(config1->evictions_enabled > config2->evictions_enabled) HGOTO_DONE(1); + if (config1->evictions_enabled < config2->evictions_enabled) + HGOTO_DONE(-1); + if (config1->evictions_enabled > config2->evictions_enabled) + HGOTO_DONE(1); - if(config1->set_initial_size < config2->set_initial_size) HGOTO_DONE(-1); - if(config1->set_initial_size > config2->set_initial_size) HGOTO_DONE(1); + if (config1->set_initial_size < config2->set_initial_size) + HGOTO_DONE(-1); + if (config1->set_initial_size > config2->set_initial_size) + HGOTO_DONE(1); - if(config1->initial_size < config2->initial_size) HGOTO_DONE(-1); - if(config1->initial_size > config2->initial_size) HGOTO_DONE(1); + if (config1->initial_size < config2->initial_size) + HGOTO_DONE(-1); + if (config1->initial_size > config2->initial_size) + HGOTO_DONE(1); - if(config1->min_clean_fraction < config2->min_clean_fraction) HGOTO_DONE(-1); - if(config1->min_clean_fraction > config2->min_clean_fraction) HGOTO_DONE(1); + if (config1->min_clean_fraction < config2->min_clean_fraction) + HGOTO_DONE(-1); + if (config1->min_clean_fraction > config2->min_clean_fraction) + HGOTO_DONE(1); - if(config1->max_size < config2->max_size) HGOTO_DONE(-1); - if(config1->max_size > config2->max_size) HGOTO_DONE(1); + if (config1->max_size < config2->max_size) + HGOTO_DONE(-1); + if (config1->max_size > config2->max_size) + HGOTO_DONE(1); - if(config1->min_size < config2->min_size) HGOTO_DONE(-1); - if(config1->min_size > config2->min_size) HGOTO_DONE(1); + if (config1->min_size < config2->min_size) + HGOTO_DONE(-1); + if (config1->min_size > config2->min_size) + HGOTO_DONE(1); - if(config1->epoch_length < config2->epoch_length) HGOTO_DONE(-1); - if(config1->epoch_length > config2->epoch_length) HGOTO_DONE(1); + if (config1->epoch_length < config2->epoch_length) + HGOTO_DONE(-1); + if (config1->epoch_length > config2->epoch_length) + HGOTO_DONE(1); - if(config1->incr_mode < config2->incr_mode) HGOTO_DONE(-1); - if(config1->incr_mode > config2->incr_mode) HGOTO_DONE(1); + if (config1->incr_mode < config2->incr_mode) + HGOTO_DONE(-1); + if (config1->incr_mode > config2->incr_mode) + HGOTO_DONE(1); - if(config1->lower_hr_threshold < config2->lower_hr_threshold) HGOTO_DONE(-1); - if(config1->lower_hr_threshold > config2->lower_hr_threshold) HGOTO_DONE(1); + if (config1->lower_hr_threshold < config2->lower_hr_threshold) + HGOTO_DONE(-1); + if (config1->lower_hr_threshold > config2->lower_hr_threshold) + HGOTO_DONE(1); - if(config1->increment < config2->increment) HGOTO_DONE(-1); - if(config1->increment > config2->increment) HGOTO_DONE(1); + if (config1->increment < config2->increment) + HGOTO_DONE(-1); + if (config1->increment > config2->increment) + HGOTO_DONE(1); - if(config1->apply_max_increment < config2->apply_max_increment) HGOTO_DONE(-1); - if(config1->apply_max_increment > config2->apply_max_increment) HGOTO_DONE(1); + if (config1->apply_max_increment < config2->apply_max_increment) + HGOTO_DONE(-1); + if (config1->apply_max_increment > config2->apply_max_increment) + HGOTO_DONE(1); - if(config1->max_increment < config2->max_increment) HGOTO_DONE(-1); - if(config1->max_increment > config2->max_increment) HGOTO_DONE(1); + if (config1->max_increment < config2->max_increment) + HGOTO_DONE(-1); + if (config1->max_increment > config2->max_increment) + HGOTO_DONE(1); - if(config1->flash_incr_mode < config2->flash_incr_mode) HGOTO_DONE(-1); - if(config1->flash_incr_mode > config2->flash_incr_mode) HGOTO_DONE(1); + if (config1->flash_incr_mode < config2->flash_incr_mode) + HGOTO_DONE(-1); + if (config1->flash_incr_mode > config2->flash_incr_mode) + HGOTO_DONE(1); - if(config1->flash_multiple < config2->flash_multiple) HGOTO_DONE(-1); - if(config1->flash_multiple > config2->flash_multiple) HGOTO_DONE(1); + if (config1->flash_multiple < config2->flash_multiple) + HGOTO_DONE(-1); + if (config1->flash_multiple > config2->flash_multiple) + HGOTO_DONE(1); - if(config1->flash_threshold < config2->flash_threshold) HGOTO_DONE(-1); - if(config1->flash_threshold > config2->flash_threshold) HGOTO_DONE(1); + if (config1->flash_threshold < config2->flash_threshold) + HGOTO_DONE(-1); + if (config1->flash_threshold > config2->flash_threshold) + HGOTO_DONE(1); - if(config1->decr_mode < config2->decr_mode) HGOTO_DONE(-1); - if(config1->decr_mode > config2->decr_mode) HGOTO_DONE(1); + if (config1->decr_mode < config2->decr_mode) + HGOTO_DONE(-1); + if (config1->decr_mode > config2->decr_mode) + HGOTO_DONE(1); - if(config1->upper_hr_threshold < config2->upper_hr_threshold) HGOTO_DONE(-1); - if(config1->upper_hr_threshold > config2->upper_hr_threshold) HGOTO_DONE(1); + if (config1->upper_hr_threshold < config2->upper_hr_threshold) + HGOTO_DONE(-1); + if (config1->upper_hr_threshold > config2->upper_hr_threshold) + HGOTO_DONE(1); - if(config1->decrement < config2->decrement) HGOTO_DONE(-1); - if(config1->decrement > config2->decrement) HGOTO_DONE(1); + if (config1->decrement < config2->decrement) + HGOTO_DONE(-1); + if (config1->decrement > config2->decrement) + HGOTO_DONE(1); - if(config1->apply_max_decrement < config2->apply_max_decrement) HGOTO_DONE(-1); - if(config1->apply_max_decrement > config2->apply_max_decrement) HGOTO_DONE(1); + if (config1->apply_max_decrement < config2->apply_max_decrement) + HGOTO_DONE(-1); + if (config1->apply_max_decrement > config2->apply_max_decrement) + HGOTO_DONE(1); - if(config1->max_decrement < config2->max_decrement) HGOTO_DONE(-1); - if(config1->max_decrement > config2->max_decrement) HGOTO_DONE(1); + if (config1->max_decrement < config2->max_decrement) + HGOTO_DONE(-1); + if (config1->max_decrement > config2->max_decrement) + HGOTO_DONE(1); - if(config1->epochs_before_eviction < config2->epochs_before_eviction) HGOTO_DONE(-1); - if(config1->epochs_before_eviction > config2->epochs_before_eviction) HGOTO_DONE(1); + if (config1->epochs_before_eviction < config2->epochs_before_eviction) + HGOTO_DONE(-1); + if (config1->epochs_before_eviction > config2->epochs_before_eviction) + HGOTO_DONE(1); - if(config1->apply_empty_reserve < config2->apply_empty_reserve) HGOTO_DONE(-1); - if(config1->apply_empty_reserve > config2->apply_empty_reserve) HGOTO_DONE(1); + if (config1->apply_empty_reserve < config2->apply_empty_reserve) + HGOTO_DONE(-1); + if (config1->apply_empty_reserve > config2->apply_empty_reserve) + HGOTO_DONE(1); - if(config1->empty_reserve < config2->empty_reserve) HGOTO_DONE(-1); - if(config1->empty_reserve > config2->empty_reserve) HGOTO_DONE(1); + if (config1->empty_reserve < config2->empty_reserve) + HGOTO_DONE(-1); + if (config1->empty_reserve > config2->empty_reserve) + HGOTO_DONE(1); - if(config1->dirty_bytes_threshold < config2->dirty_bytes_threshold) HGOTO_DONE(-1); - if(config1->dirty_bytes_threshold > config2->dirty_bytes_threshold) HGOTO_DONE(1); + if (config1->dirty_bytes_threshold < config2->dirty_bytes_threshold) + HGOTO_DONE(-1); + if (config1->dirty_bytes_threshold > config2->dirty_bytes_threshold) + HGOTO_DONE(1); - if(config1->metadata_write_strategy < config2->metadata_write_strategy) HGOTO_DONE(-1); - if(config1->metadata_write_strategy > config2->metadata_write_strategy) HGOTO_DONE(1); + if (config1->metadata_write_strategy < config2->metadata_write_strategy) + HGOTO_DONE(-1); + if (config1->metadata_write_strategy > config2->metadata_write_strategy) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_config_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_enc * @@ -3429,10 +3568,11 @@ H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t H5 static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) { - const H5AC_cache_config_t *config = (const H5AC_cache_config_t *)value; /* Create local aliases for values */ + const H5AC_cache_config_t *config = + (const H5AC_cache_config_t *)value; /* Create local aliases for values */ uint8_t **pp = (uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - uint64_t enc_value; /* Property to encode */ + unsigned enc_size; /* Size of encoded property */ + uint64_t enc_value; /* Property to encode */ FUNC_ENTER_STATIC_NOERR @@ -3440,7 +3580,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) HDassert(value); HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode type sizes (as a safety check) */ *(*pp)++ = (uint8_t)sizeof(unsigned); *(*pp)++ = (uint8_t)sizeof(double); @@ -3454,7 +3594,8 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->close_trace_file); - H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name), (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1)); + H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name), + (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1)); *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1; H5_ENCODE_UNSIGNED(*pp, config->evictions_enabled); @@ -3462,7 +3603,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->set_initial_size); enc_value = (uint64_t)config->initial_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3470,13 +3611,13 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_DOUBLE(*pp, config->min_clean_fraction); enc_value = (uint64_t)config->max_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); enc_value = (uint64_t)config->min_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3494,7 +3635,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->apply_max_increment); enc_value = (uint64_t)config->max_increment; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3516,7 +3657,7 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, config->apply_max_decrement); enc_value = (uint64_t)config->max_decrement; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); @@ -3548,14 +3689,12 @@ H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size) *size += 1 + H5VM_limit_enc_size(enc_value); /* Compute encoded size of fixed-size values */ - *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + - (sizeof(int32_t) * 4) + sizeof(int64_t) + - H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + (sizeof(int32_t) * 4) + sizeof(int64_t) + + H5AC__MAX_TRACE_FILE_NAME_LEN + 1); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_cache_config_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_cache_config_dec * @@ -3575,10 +3714,10 @@ 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; - unsigned enc_size; - uint64_t enc_value; - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t ** pp = (const uint8_t **)_pp; + unsigned enc_size; + uint64_t enc_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3593,10 +3732,10 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) /* Decode type sizes */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") enc_size = *(*pp)++; - if(enc_size != sizeof(double)) + if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") /* int */ @@ -3639,7 +3778,7 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) config->epoch_length = (long int)temp; } /* enum */ - config->incr_mode = (enum H5C_cache_incr_mode)*(*pp)++; + config->incr_mode = (enum H5C_cache_incr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->lower_hr_threshold); @@ -3653,14 +3792,14 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) config->max_increment = (size_t)enc_value; /* enum */ - config->flash_incr_mode = (enum H5C_cache_flash_incr_mode)*(*pp)++; + config->flash_incr_mode = (enum H5C_cache_flash_incr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->flash_multiple); H5_DECODE_DOUBLE(*pp, config->flash_threshold); /* enum */ - config->decr_mode = (enum H5C_cache_decr_mode)*(*pp)++; + config->decr_mode = (enum H5C_cache_decr_mode) * (*pp)++; H5_DECODE_DOUBLE(*pp, config->upper_hr_threshold); @@ -3690,7 +3829,6 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_cache_config_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_fclose_degree_enc * @@ -3709,7 +3847,8 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value) static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) { - const H5F_close_degree_t *fclose_degree = (const H5F_close_degree_t *)value; /* Create local alias for values */ + const H5F_close_degree_t *fclose_degree = + (const H5F_close_degree_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3718,7 +3857,7 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) HDassert(fclose_degree); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode file close degree */ *(*pp)++ = (uint8_t)*fclose_degree; @@ -3728,7 +3867,6 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_fclose_degree_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_fclose_degree_dec * @@ -3747,8 +3885,8 @@ H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size) 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; + H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3758,12 +3896,11 @@ H5P__facc_fclose_degree_dec(const void **_pp, void *_value) HDassert(fclose_degree); /* Decode file close degree */ - *fclose_degree = (H5F_close_degree_t)*(*pp)++; + *fclose_degree = (H5F_close_degree_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_fclose_degree_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_multi_type_enc * @@ -3783,7 +3920,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 @@ -3791,7 +3928,7 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) HDassert(type); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode file close degree */ *(*pp)++ = (uint8_t)*type; @@ -3801,7 +3938,6 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_multi_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_multi_type_dec * @@ -3820,8 +3956,8 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; + H5FD_mem_t * type = (H5FD_mem_t *)_value; /* File close degree */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3831,12 +3967,11 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) HDassert(type); /* Decode multi VFD memory type */ - *type = (H5FD_mem_t)*(*pp)++; + *type = (H5FD_mem_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_multi_type_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_libver_type_enc * @@ -3855,7 +3990,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 @@ -3864,7 +3999,7 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) HDassert(size); /* Encode */ - if(NULL != *pp) + if (NULL != *pp) *(*pp)++ = (uint8_t)*type; /* Size */ @@ -3873,7 +4008,6 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__facc_libver_type_dec * @@ -3891,8 +4025,8 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; + H5F_libver_t * type = (H5F_libver_t *)_value; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3902,95 +4036,11 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value) HDassert(type); /* Decode */ - *type = (H5F_libver_t)*(*pp)++; + *type = (H5F_libver_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_dec() */ - -/*------------------------------------------------------------------------- - * Function: H5Pset_core_write_tracking - * - * Purpose: Enables/disables core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -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 */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); - - /* The page size cannot be zero */ - if(page_size == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Set values */ - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking flag") - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking page size") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_core_write_tracking() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_core_write_tracking - * - * Purpose: Gets information about core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -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 */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Get values */ - if(is_enabled) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking flag") - } /* end if */ - - if(page_size) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking page size") - } /* end if */ - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_core_write_tracking() */ - - /*------------------------------------------------------------------------- * Function: H5Pset_metadata_read_attempts * @@ -4011,29 +4061,29 @@ H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_siz herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, attempts); /* Cannot set the # of attempts to 0 */ - if(attempts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of metadatata read attempts must be greater than 0"); + if (attempts == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "number of metadatata read attempts must be greater than 0"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0) + if (H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of metadata read attempts") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_metadata_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5Pget_metadata_read_attempts * @@ -4046,27 +4096,27 @@ H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts) *------------------------------------------------------------------------- */ herr_t -H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts/*out*/) +H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, attempts); /* Get values */ - if(attempts) { - H5P_genplist_t *plist; /* Property list pointer */ + if (attempts) { + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the # of read attempts set */ - if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0) + if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get the number of metadata read attempts") /* If not set, return the default value */ - if(*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */ + if (*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */ *attempts = H5F_METADATA_READ_ATTEMPTS; } /* end if */ @@ -4074,7 +4124,6 @@ H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts/*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_metadata_read_attempts() */ - /*------------------------------------------------------------------------- * Function: H5Pset_obj_flush_cb * @@ -4090,35 +4139,34 @@ 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, udata); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && udata) + if (!func && udata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Update property list */ - flush_info.func = func; + flush_info.func = func; flush_info.udata = udata; /* Set values */ - if(H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) + if (H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_obj_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pget_obj_flush_cb * @@ -4134,32 +4182,31 @@ 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, func, udata); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve the callback function and user data */ - if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) + if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback") /* Assign return value */ - if(func) + if (func) *func = flush_info.func; - if(udata) + if (udata) *udata = flush_info.udata; done: FUNC_LEAVE_API(ret_value) } /* H5Pget_obj_flush_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mdc_log_options * @@ -4170,48 +4217,41 @@ H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata) *------------------------------------------------------------------------- */ herr_t -H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, - hbool_t start_on_access) +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 * tmp_location; /* Working location pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * new_location; /* Working location pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ib*sb", plist_id, is_enabled, location, start_on_access); /* Check arguments */ - if(H5P_DEFAULT == plist_id) + if (H5P_DEFAULT == plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list") - if(!location) + if (!location) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "location cannot be NULL") /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list") - /* Get the current location string and free it */ - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current log location") - H5MM_xfree(tmp_location); - /* Make a copy of the passed-in location */ - if(NULL == (tmp_location = H5MM_xstrdup(location))) + if (NULL == (new_location = H5MM_xstrdup(location))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location") /* Set values */ - if(H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0) + if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag") - if(H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0) + if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location") - if(H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0) + if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_mdc_log_options() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mdc_log_options * @@ -4222,53 +4262,51 @@ H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, *------------------------------------------------------------------------- */ herr_t -H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, - size_t *location_size, hbool_t *start_on_access) +H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size, + hbool_t *start_on_access) { - H5P_genplist_t *plist; /* Property list pointer */ - char *location_ptr; /* Pointer to location string */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * location_ptr = NULL; /* Pointer to location string */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*b*s*z*b", plist_id, is_enabled, location, location_size, - start_on_access); + H5TRACE5("e", "i*b*s*z*b", plist_id, is_enabled, location, location_size, start_on_access); /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list") /* Get simple values */ - if(is_enabled) - if(H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0) + if (is_enabled) + if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location") - if(start_on_access) - if(H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0) + if (start_on_access) + if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get start_on_access flag") /* Get the location */ - if(location || location_size) - if(H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0) + if (location || location_size) + if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location") /* Copy log location to output buffer */ - if(location_ptr && location) + if (location_ptr && location) H5MM_memcpy(location, location_ptr, *location_size); /* Get location size, including terminating NULL */ - if(location_size) { - if(location_ptr) + if (location_size) { + if (location_ptr) *location_size = HDstrlen(location_ptr) + 1; else *location_size = 0; - } + } /* end if */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mdc_log_options() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_enc + * Function: H5P__facc_mdc_log_location_enc * * Purpose: Callback routine which is called whenever the metadata * cache log location property in the file access property @@ -4280,48 +4318,47 @@ H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, *------------------------------------------------------------------------- */ static herr_t -H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size) +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; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *log_location = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != log_location) + if (NULL != log_location) len = HDstrlen(log_location); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != log_location) { + if (NULL != log_location) { H5MM_memcpy(*(char **)pp, log_location, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != log_location) + if (NULL != log_location) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_facc_mdc_log_location_enc() */ +} /* end H5P__facc_mdc_log_location_enc() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_dec + * Function: H5P__facc_mdc_log_location_dec * * Purpose: Callback routine which is called whenever the metadata * cache log location property in the file access property @@ -4333,16 +4370,16 @@ 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) +H5P__facc_mdc_log_location_dec(const void **_pp, void *_value) { - char **log_location = (char **)_value; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** log_location = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(pp); HDassert(*pp); @@ -4357,9 +4394,9 @@ H5P_facc_mdc_log_location_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*log_location = (char *)H5MM_malloc(len + 1))) + if (NULL == (*log_location = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*log_location, *(const char **)pp, len); (*log_location)[len] = '\0'; @@ -4371,11 +4408,10 @@ H5P_facc_mdc_log_location_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_mdc_log_location_dec() */ +} /* end H5P__facc_mdc_log_location_dec() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_del + * Function: H5P__facc_mdc_log_location_del * * Purpose: Frees memory used to store the metadata cache log location. * @@ -4384,21 +4420,20 @@ H5P_facc_mdc_log_location_dec(const void **_pp, void *_value) *------------------------------------------------------------------------- */ static herr_t -H5P_facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_facc_mdc_log_location_del() */ +} /* end H5P__facc_mdc_log_location_del() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_copy + * Function: H5P__facc_mdc_log_location_copy * * Purpose: Creates a copy of the metadata cache log location string. * @@ -4407,20 +4442,19 @@ H5P_facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5P_facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); *(char **)value = H5MM_xstrdup(*(const char **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_facc_mdc_log_location_copy() */ +} /* end H5P__facc_mdc_log_location_copy() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_cmp + * Function: H5P__facc_mdc_log_location_cmp * * Purpose: Callback routine which is called whenever the metadata * cache log location property in the file creation property @@ -4430,29 +4464,28 @@ H5P_facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_U * *------------------------------------------------------------------------- */ -static int -H5P_facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) +static H5_ATTR_PURE int +H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_mdc_log_location_cmp() */ +} /* end H5P__facc_mdc_log_location_cmp() */ - /*------------------------------------------------------------------------- - * Function: H5P_facc_mdc_log_location_close + * Function: H5P__facc_mdc_log_location_close * * Purpose: Frees memory used to store the metadata cache log location * string @@ -4462,18 +4495,17 @@ H5P_facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ *------------------------------------------------------------------------- */ static herr_t -H5P_facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_facc_mdc_log_location_close() */ +} /* end H5P__facc_mdc_log_location_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_evict_on_close * @@ -4493,36 +4525,35 @@ H5P_facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_ *------------------------------------------------------------------------- */ herr_t -H5Pset_evict_on_close(hid_t fapl_id, - hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close) +H5Pset_evict_on_close(hid_t fapl_id, hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", fapl_id, evict_on_close); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") #ifndef H5_HAVE_PARALLEL /* Set value */ - if(H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) + if (H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set evict on close property") #else - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "evict on close is currently not supported in parallel HDF5") + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, + "evict on close is currently not supported in parallel HDF5") #endif /* H5_HAVE_PARALLEL */ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_evict_on_close() */ - /*------------------------------------------------------------------------- * Function: H5Pget_evict_on_close * @@ -4544,28 +4575,27 @@ H5Pset_evict_on_close(hid_t fapl_id, herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", fapl_id, evict_on_close); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0) + if (H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get evict on close property") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_evict_on_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_locking * @@ -4590,31 +4620,30 @@ H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close) herr_t H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ibb", fapl_id, use_file_locking, ignore_when_disabled); /* Make sure this is a fapl */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_USE_FILE_LOCKING_NAME, &use_file_locking) < 0) + if (H5P_set(plist, H5F_ACS_USE_FILE_LOCKING_NAME, &use_file_locking) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set use file locking property") - if(H5P_set(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &ignore_when_disabled) < 0) + if (H5P_set(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &ignore_when_disabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set ignore disabled file locks property") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_file_locking() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_locking * @@ -4633,24 +4662,24 @@ H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when herr_t H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled) { - H5P_genplist_t *plist; /* property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*b", fapl_id, use_file_locking, ignore_when_disabled); /* Make sure this is a fapl */ - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(H5P_get(plist, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0) + if (H5P_get(plist, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get use file locking property") - if(H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, ignore_when_disabled) < 0) + if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, ignore_when_disabled) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get ignore disabled file locks property") done: @@ -4658,7 +4687,7 @@ H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_wh } /* end H5Pget_file_locking() */ #ifdef H5_HAVE_PARALLEL - + /*------------------------------------------------------------------------- * Function: H5P__encode_coll_md_read_flag_t * @@ -4676,7 +4705,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 @@ -4684,7 +4713,7 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) HDassert(coll_md_read_flag); HDassert(size); - if(NULL != *pp) { + if (NULL != *pp) { /* Encode the value */ H5MM_memcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t)); *pp += sizeof(H5P_coll_md_read_flag_t); @@ -4696,7 +4725,6 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__encode_coll_md_read_flag_t() */ - /*------------------------------------------------------------------------- * Function: H5P__decode_coll_md_read_flag_t * @@ -4713,8 +4741,8 @@ H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) 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; + 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; FUNC_ENTER_STATIC_NOERR @@ -4724,13 +4752,12 @@ H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) HDassert(coll_md_read_flag); /* Decode file close degree */ - *coll_md_read_flag = (H5P_coll_md_read_flag_t)*(*pp); + *coll_md_read_flag = (H5P_coll_md_read_flag_t) * (*pp); *pp += sizeof(H5P_coll_md_read_flag_t); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__decode_coll_md_read_flag_t() */ - /*------------------------------------------------------------------------- * Function: H5Pset_all_coll_metadata_ops * @@ -4755,9 +4782,9 @@ 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_coll_md_read_flag_t coll_meta_read; /* Property value */ - herr_t ret_value = SUCCEED; /* return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, is_collective); @@ -4766,30 +4793,28 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if(TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && + TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* set property to either TRUE if > 0, or FALSE otherwise */ - if(is_collective) + if (is_collective) coll_meta_read = H5P_USER_TRUE; else coll_meta_read = H5P_USER_FALSE; /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0) + if (H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata read flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_all_coll_metadata_ops() */ - /*------------------------------------------------------------------------- * Function: H5Pget_all_coll_metadata_ops * @@ -4811,7 +4836,7 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", plist_id, is_collective); @@ -4820,24 +4845,24 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if(TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && + TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get value */ - if(is_collective) { - H5P_coll_md_read_flag_t internal_flag; /* property setting. we need to convert to either TRUE or FALSE */ - H5P_genplist_t *plist; /* Property list pointer */ + if (is_collective) { + H5P_coll_md_read_flag_t + internal_flag; /* property setting. we need to convert to either TRUE or FALSE */ + H5P_genplist_t *plist; /* Property list pointer */ /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0) + if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core collective metadata read flag") - if(internal_flag < 0) + if (internal_flag < 0) *is_collective = FALSE; else *is_collective = (hbool_t)internal_flag; @@ -4847,7 +4872,6 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) FUNC_LEAVE_API(ret_value) } /* H5Pget_all_coll_metadata_ops */ - /*------------------------------------------------------------------------- * Function: H5Pset_coll_metadata_write * @@ -4864,115 +4888,565 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) herr_t H5Pset_coll_metadata_write(hid_t plist_id, hbool_t is_collective) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, is_collective); /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - if(H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0) + if (H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata write flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_coll_metadata_write() */ - /*------------------------------------------------------------------------- - * Function: H5Pget_coll_metadata_write + * Function: H5Pget_mpi_params * - * Purpose: Gets information about collective metadata write mode. + * Purpose: Gets the MPI communicator and info stored in the fapl. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi - * Sunday, June 21, 2015 + * Programmer: Dana Robinson + * August 2019 * *------------------------------------------------------------------------- */ herr_t -H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective) +H5Pget_mpi_params(hid_t plist_id, MPI_Comm *comm, MPI_Info *info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*b", plist_id, is_collective); + H5TRACE3("e", "i*Mc*Mi", plist_id, comm, info); - /* Compare the property list's class against the other class */ - if(TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") + /* Make sure that the property list is a fapl */ + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get collective metadata write flag") + /* Get the properties */ + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator from plist") + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info from plist") done: FUNC_LEAVE_API(ret_value) -} /* end H5Pget_coll_metadata_write() */ -#endif /* H5_HAVE_PARALLEL */ +} /* end H5Pget_mpi_params() */ - /*------------------------------------------------------------------------- - * Function: H5Pset_page_buffer_size + * Function: H5Pset_mpi_params * - * Purpose: Set the maximum page buffering size. This has to be a - * multiple of the page allocation size which must be enabled; - * otherwise file create/open will fail. + * Purpose: Set the MPI communicator and info * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi - * June 2015 + * Programmer: Dana Robinson + * August 2019 * *------------------------------------------------------------------------- */ herr_t -H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc) +H5Pset_mpi_params(hid_t plist_id, MPI_Comm comm, MPI_Info info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "izIuIu", plist_id, buf_size, min_meta_perc, min_raw_perc); + H5TRACE3("e", "iMcMi", plist_id, comm, info); - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Make sure the MPI communicator is valid */ + if (MPI_COMM_NULL == comm) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "not a valid argument") - if(min_meta_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum metadata fractions must be between 0 and 100 inclusive") - if(min_raw_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Minimum rawdata fractions must be between 0 and 100 inclusive") + /* Make sure that the property list is a fapl */ + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist") + + /* Get the plist structure */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Set values */ + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator") + if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_mpi_params() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_set + * + * Purpose: Copies an MPI comminicator property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_comm_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI communicator */ + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") + +done: + /* Copy the communicator to the in/out parameter */ + if (ret_value != SUCCEED) + *comm = MPI_COMM_NULL; + else + *comm = comm_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_set() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_get + * + * Purpose: Copies an MPI comminicator property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_comm_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI communicator */ + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") + +done: + /* Copy the communicator to the out parameter */ + if (ret_value != SUCCEED) + *comm = MPI_COMM_NULL; + else + *comm = comm_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_get() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_del + * + * Purpose: Frees an MPI communicator property + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Comm *comm = (MPI_Comm *)value; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Free the MPI communicator */ + if (H5_mpi_comm_free(comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_del() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_copy + * + * Purpose: Copy callback for the MPI communicator property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_comm_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Comm *comm = (MPI_Comm *)value; + MPI_Comm comm_tmp = MPI_COMM_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI communicator */ + if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator") + +done: + /* Copy the communicator to the in/out parameter */ + if (ret_value != SUCCEED) + *comm = MPI_COMM_NULL; + else + *comm = comm_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_cmp + * + * Purpose: Callback routine which is called whenever the MPI + * communicator property in the file access property list + * is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_mpi_comm_cmp(const void *_comm1, const void *_comm2, size_t H5_ATTR_UNUSED size) +{ + const MPI_Comm *comm1 = (const MPI_Comm *)_comm1; + const MPI_Comm *comm2 = (const MPI_Comm *)_comm2; + int ret_value = 0; + + FUNC_ENTER_STATIC + + /* Compare the MPI communicators */ + if (H5_mpi_comm_cmp(*comm1, *comm2, &ret_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI communicator") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_comm_close + * + * Purpose: Close callback for the MPI communicator property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_comm_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Comm *comm = (MPI_Comm *)value; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Free the MPI communicator */ + if (H5_mpi_comm_free(comm) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_comm_close() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_set + * + * Purpose: Copies an MPI info object property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI info object */ + if (H5_mpi_info_dup(*info, &info_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") + +done: + /* Copy the info object to the in/out parameter */ + if (ret_value != SUCCEED) + *info = MPI_INFO_NULL; + else + *info = info_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_set() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_get + * + * Purpose: Copies an MPI comminicator property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI communicator */ + if (H5_mpi_info_dup(*info, &info_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") + +done: + /* Copy the info object to the out parameter */ + if (ret_value != SUCCEED) + *info = MPI_INFO_NULL; + else + *info = info_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_get() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_del + * + * Purpose: Frees an MPI info object property + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Info *info = (MPI_Info *)value; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Free the MPI info object */ + if (H5_mpi_info_free(info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_del() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_copy + * + * Purpose: Copy callback for the MPI info object property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Info *info = (MPI_Info *)value; + MPI_Info info_tmp = MPI_INFO_NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Make a copy of the MPI info object */ + if (H5_mpi_info_dup(*info, &info_tmp) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object") + +done: + /* Copy the info object to the in/out parameter */ + if (ret_value != SUCCEED) + *info = MPI_INFO_NULL; + else + *info = info_tmp; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_cmp + * + * Purpose: Callback routine which is called whenever the MPI + * info object property in the file access property list + * is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_mpi_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) +{ + const MPI_Info *info1 = (const MPI_Info *)_info1; + const MPI_Info *info2 = (const MPI_Info *)_info2; + int ret_value = 0; + + FUNC_ENTER_STATIC + + /* Compare the MPI info objects */ + if (H5_mpi_info_cmp(*info1, *info2, &ret_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI info objects") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_mpi_info_close + * + * Purpose: Close callback for the MPI info object property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_mpi_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + MPI_Info *info = (MPI_Info *)value; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Free the MPI info object */ + if (H5_mpi_info_free(info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_mpi_info_close() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_coll_metadata_write + * + * Purpose: Gets information about collective metadata write mode. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * Sunday, June 21, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", plist_id, is_collective); + + /* Compare the property list's class against the other class */ + if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") + + /* Get the plist structure */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get collective metadata write flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_coll_metadata_write() */ +#endif /* H5_HAVE_PARALLEL */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_page_buffer_size + * + * Purpose: Set the maximum page buffering size. This has to be a + * multiple of the page allocation size which must be enabled; + * otherwise file create/open will fail. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * June 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "izIuIu", plist_id, buf_size, min_meta_perc, min_raw_perc); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if (min_meta_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Minimum metadata fractions must be between 0 and 100 inclusive") + if (min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Minimum rawdata fractions must be between 0 and 100 inclusive") - if(min_meta_perc + min_raw_perc > 100) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Sum of minimum metadata and raw data fractions can't be bigger than 100"); + if (min_meta_perc + min_raw_perc > 100) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "Sum of minimum metadata and raw data fractions can't be bigger than 100"); /* Set size */ - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set page buffer size") - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min metadata entries") - if(H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set percentage of min rawdata entries") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set page buffer size") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min metadata entries") + if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min rawdata entries") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_page_buffer_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_page_buffer_size * @@ -4988,29 +5462,458 @@ H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*z*Iu*Iu", plist_id, buf_size, min_meta_perc, min_raw_perc); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get size */ - if(buf_size) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer size") - if(min_meta_perc) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum metadata percent") - if(min_raw_perc) - if(H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get page buffer minimum raw data percent") + if (buf_size) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer size") + if (min_meta_perc) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum metadata percent") + if (min_raw_perc) + if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum raw data percent") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_page_buffer_size() */ +/*------------------------------------------------------------------------- + * Function: H5P_set_vol + * + * Purpose: Set the VOL connector for a file access property list + * (PLIST_ID). The VOL properties will + * be copied into the property list and the reference count on + * the VOL will be incremented. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */ + + /* Prepare the VOL connector property */ + vol_prop.connector_id = vol_id; + vol_prop.connector_info = vol_info; + + /* Set the connector ID & info property */ + if (H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info") + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_vol() */ + +/*------------------------------------------------------------------------- + * Function: H5P_reset_vol_class + * + * Purpose: Change the VOL connector for a file access property class. + * + * Note: The VOL property will be copied into the property list and + * the reference count on the previous VOL will _NOT_ be decremented. + * The reference count on the new VOL will _NOT_ be incremented. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * March 8, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *vol_prop) +{ + H5VL_connector_prop_t old_vol_prop; /* Previous VOL connector property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Get the connector ID & info property */ + if (H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector ID & info") + + /* Set the new connector ID & info property */ + if (H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_vol_class() */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_vol + * + * Purpose: Set the file VOL connector (VOL_ID) for a file access + * property list (PLIST_ID) + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info); + + /* Check arguments */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if (NULL == H5I_object_verify(new_vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID") + + /* Set the VOL */ + if (H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_vol() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_vol_id + * + * Purpose: Returns the ID of the current VOL connector. + * This ID should be closed with H5VLclose(). + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_vol_id(hid_t plist_id, hid_t *vol_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*i", plist_id, vol_id); + + /* Get property list for ID */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get the current VOL ID */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + + /* Get the connector property */ + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info") + + /* Increment the VOL ID's ref count */ + if (H5I_inc_ref(connector_prop.connector_id, TRUE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") + + /* Set the connector ID to return */ + *vol_id = connector_prop.connector_id; + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_id() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_vol_info + * + * Purpose: Returns a copy of the VOL info for a connector. + * This information should be freed with H5VLfree_connector_info. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_vol_info(hid_t plist_id, void **vol_info) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i**x", plist_id, vol_info); + + /* Get property list for ID */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* 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 */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + + /* Get the connector property */ + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property") + + /* Copy connector info, if it exists */ + if (connector_prop.connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + + /* Retrieve the connector for the ID */ + if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") + } /* end if */ + + /* Set the connector info */ + *vol_info = new_connector_info; + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_info() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_create + * + connectorose: Create callback for the VOL connector ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of the VOL connector */ + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_create() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_set + * + * Purpose: Copies a VOL connector property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of VOL connector ID & info */ + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_set() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_get + * + * Purpose: Copies a VOL connector property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of VOL connector */ + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_get() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_del + * + * Purpose: Frees memory used to store the VOL connector ID & info property + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the VOL connector ID & info */ + if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_del() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_copy + * + * Purpose: Copy callback for the VOL connector ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of VOL connector */ + if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_cmp + * + * Purpose: Callback routine which is called whenever the VOL connector + * ID & info property in the file access property list + * is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) +{ + 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 */ + int cmp_value = 0; /* Value from comparison */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(info1); + HDassert(info2); + HDassert(size == sizeof(H5VL_connector_prop_t)); + + /* Compare connectors */ + if (NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) + HGOTO_DONE(-1) + if (NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) + HGOTO_DONE(1) + status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2); + HDassert(status >= 0); + if (cmp_value != 0) + HGOTO_DONE(cmp_value); + + /* At this point, we should be able to assume that we are dealing with + * the same connector class struct (or a copies of the same class struct) + */ + + /* Use one of the classes (cls1) info comparison routines to compare the + * info objects + */ + HDassert(cls1->info_cls.cmp == cls2->info_cls.cmp); + status = H5VL_cmp_connector_info(cls1, &cmp_value, info1->connector_info, info2->connector_info); + HDassert(status >= 0); + + /* Set return value */ + ret_value = cmp_value; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_close + * + * Purpose: Close callback for the VOL connector ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the VOL connector */ + if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_close() */ diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index db80f19fb67..5006b9abd40 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bprivate.h" /* B-tree subclass names */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Bprivate.h" /* B-tree subclass names */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,84 +43,90 @@ /* ========= File Creation properties ============ */ /* Definitions for the size of the file user block in bytes */ -#define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) -#define H5F_CRT_USER_BLOCK_DEF 0 -#define H5F_CRT_USER_BLOCK_ENC H5P__encode_hsize_t -#define H5F_CRT_USER_BLOCK_DEC H5P__decode_hsize_t +#define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) +#define H5F_CRT_USER_BLOCK_DEF 0 +#define H5F_CRT_USER_BLOCK_ENC H5P__encode_hsize_t +#define H5F_CRT_USER_BLOCK_DEC H5P__decode_hsize_t /* Definitions for the 1/2 rank for symbol table leaf nodes */ -#define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) -#define H5F_CRT_SYM_LEAF_ENC H5P__encode_unsigned -#define H5F_CRT_SYM_LEAF_DEC H5P__decode_unsigned +#define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) +#define H5F_CRT_SYM_LEAF_ENC H5P__encode_unsigned +#define H5F_CRT_SYM_LEAF_DEC H5P__decode_unsigned /* Definitions for the 1/2 rank for btree internal nodes */ -#define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) -#define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_CHUNK_IK_DEF} -#define H5F_CRT_BTREE_RANK_ENC H5P__fcrt_btree_rank_enc -#define H5F_CRT_BTREE_RANK_DEC H5P__fcrt_btree_rank_dec +#define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) +#define H5F_CRT_BTREE_RANK_DEF \ + { \ + HDF5_BTREE_SNODE_IK_DEF, HDF5_BTREE_CHUNK_IK_DEF \ + } +#define H5F_CRT_BTREE_RANK_ENC H5P__fcrt_btree_rank_enc +#define H5F_CRT_BTREE_RANK_DEC H5P__fcrt_btree_rank_dec /* Definitions for byte number in an address */ -#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) -#define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE -#define H5F_CRT_ADDR_BYTE_NUM_ENC H5P__encode_uint8_t -#define H5F_CRT_ADDR_BYTE_NUM_DEC H5P__decode_uint8_t +#define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) +#define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE +#define H5F_CRT_ADDR_BYTE_NUM_ENC H5P__encode_uint8_t +#define H5F_CRT_ADDR_BYTE_NUM_DEC H5P__decode_uint8_t /* Definitions for byte number for object size */ -#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) -#define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE -#define H5F_CRT_OBJ_BYTE_NUM_ENC H5P__encode_uint8_t -#define H5F_CRT_OBJ_BYTE_NUM_DEC H5P__decode_uint8_t +#define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) +#define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE +#define H5F_CRT_OBJ_BYTE_NUM_ENC H5P__encode_uint8_t +#define H5F_CRT_OBJ_BYTE_NUM_DEC H5P__decode_uint8_t /* Definitions for version number of the superblock */ -#define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) -#define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF +#define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) +#define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF /* Definitions for shared object header messages */ #define H5F_CRT_SHMSG_NINDEXES_SIZE sizeof(unsigned) #define H5F_CRT_SHMSG_NINDEXES_DEF (0) #define H5F_CRT_SHMSG_NINDEXES_ENC H5P__encode_unsigned #define H5F_CRT_SHMSG_NINDEXES_DEC H5P__decode_unsigned #define H5F_CRT_SHMSG_INDEX_TYPES_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) -#define H5F_CRT_SHMSG_INDEX_TYPES_DEF {0,0,0,0,0,0} -#define H5F_CRT_SHMSG_INDEX_TYPES_ENC H5P__fcrt_shmsg_index_types_enc -#define H5F_CRT_SHMSG_INDEX_TYPES_DEC H5P__fcrt_shmsg_index_types_dec +#define H5F_CRT_SHMSG_INDEX_TYPES_DEF \ + { \ + 0, 0, 0, 0, 0, 0 \ + } +#define H5F_CRT_SHMSG_INDEX_TYPES_ENC H5P__fcrt_shmsg_index_types_enc +#define H5F_CRT_SHMSG_INDEX_TYPES_DEC H5P__fcrt_shmsg_index_types_dec #define H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) -#define H5F_CRT_SHMSG_INDEX_MINSIZE_DEF {250,250,250,250,250,250} +#define H5F_CRT_SHMSG_INDEX_MINSIZE_DEF \ + { \ + 250, 250, 250, 250, 250, 250 \ + } #define H5F_CRT_SHMSG_INDEX_MINSIZE_ENC H5P__fcrt_shmsg_index_minsize_enc #define H5F_CRT_SHMSG_INDEX_MINSIZE_DEC H5P__fcrt_shmsg_index_minsize_dec /* Definitions for shared object header list/btree phase change cutoffs */ -#define H5F_CRT_SHMSG_LIST_MAX_SIZE sizeof(unsigned) -#define H5F_CRT_SHMSG_LIST_MAX_DEF (50) -#define H5F_CRT_SHMSG_LIST_MAX_ENC H5P__encode_unsigned -#define H5F_CRT_SHMSG_LIST_MAX_DEC H5P__decode_unsigned -#define H5F_CRT_SHMSG_BTREE_MIN_SIZE sizeof(unsigned) -#define H5F_CRT_SHMSG_BTREE_MIN_DEF (40) -#define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned -#define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned +#define H5F_CRT_SHMSG_LIST_MAX_SIZE sizeof(unsigned) +#define H5F_CRT_SHMSG_LIST_MAX_DEF (50) +#define H5F_CRT_SHMSG_LIST_MAX_ENC H5P__encode_unsigned +#define H5F_CRT_SHMSG_LIST_MAX_DEC H5P__decode_unsigned +#define H5F_CRT_SHMSG_BTREE_MIN_SIZE sizeof(unsigned) +#define H5F_CRT_SHMSG_BTREE_MIN_DEF (40) +#define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned +#define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned /* Definitions for file space handling strategy */ -#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) -#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF -#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc -#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec -#define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(hbool_t) -#define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF -#define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_hbool_t -#define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_hbool_t -#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF -#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t -#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t +#define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) +#define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF +#define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc +#define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec +#define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(hbool_t) +#define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF +#define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_hbool_t +#define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_hbool_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF +#define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t +#define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t /* Definitions for file space page size in support of level-2 page caching */ -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t -#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t - +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t +#define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -140,59 +144,58 @@ static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *value); static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value); - /*********************/ /* Package Variables */ /*********************/ /* File creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_FCRT[1] = {{ - "file create", /* Class name for debugging */ - H5P_TYPE_FILE_CREATE, /* Class type */ - - &H5P_CLS_GROUP_CREATE_g, /* Parent class */ - &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ - &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__fcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "file create", /* Class name for debugging */ + H5P_TYPE_FILE_CREATE, /* Class type */ + + &H5P_CLS_GROUP_CREATE_g, /* Parent class */ + &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ + &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__fcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const hsize_t H5F_def_userblock_size_g = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ -static const unsigned H5F_def_sym_leaf_k_g = H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ -static const unsigned H5F_def_btree_k_g[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ -static const uint8_t H5F_def_sizeof_addr_g = H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ -static const uint8_t H5F_def_sizeof_size_g = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ -static const unsigned H5F_def_superblock_ver_g = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ -static const unsigned H5F_def_num_sohm_indexes_g = H5F_CRT_SHMSG_NINDEXES_DEF; -static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; -static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; -static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; -static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; -static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; -static const hbool_t H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; -static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; -static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; - - - +static const hsize_t H5F_def_userblock_size_g = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ +static const unsigned H5F_def_sym_leaf_k_g = + H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ +static const unsigned H5F_def_btree_k_g[H5B_NUM_BTREE_ID] = + H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ +static const uint8_t H5F_def_sizeof_addr_g = + H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ +static const uint8_t H5F_def_sizeof_size_g = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ +static const unsigned H5F_def_superblock_ver_g = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ +static const unsigned H5F_def_num_sohm_indexes_g = H5F_CRT_SHMSG_NINDEXES_DEF; +static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; +static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = + H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; +static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; +static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; +static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; +static const hbool_t H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; +static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; +static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; + /*------------------------------------------------------------------------- * Function: H5P__fcrt_reg_prop * @@ -207,99 +210,101 @@ static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SI static herr_t H5P__fcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register the user block size */ - if(H5P__register_real(pclass, H5F_CRT_USER_BLOCK_NAME, H5F_CRT_USER_BLOCK_SIZE, &H5F_def_userblock_size_g, - NULL, NULL, NULL, H5F_CRT_USER_BLOCK_ENC, H5F_CRT_USER_BLOCK_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_USER_BLOCK_NAME, H5F_CRT_USER_BLOCK_SIZE, + &H5F_def_userblock_size_g, NULL, NULL, NULL, H5F_CRT_USER_BLOCK_ENC, + H5F_CRT_USER_BLOCK_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for symbol table leaf nodes */ - if(H5P__register_real(pclass, H5F_CRT_SYM_LEAF_NAME, H5F_CRT_SYM_LEAF_SIZE, &H5F_def_sym_leaf_k_g, - NULL, NULL, NULL, H5F_CRT_SYM_LEAF_ENC, H5F_CRT_SYM_LEAF_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SYM_LEAF_NAME, H5F_CRT_SYM_LEAF_SIZE, &H5F_def_sym_leaf_k_g, NULL, + NULL, NULL, H5F_CRT_SYM_LEAF_ENC, H5F_CRT_SYM_LEAF_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for btree internal nodes */ - if(H5P__register_real(pclass, H5F_CRT_BTREE_RANK_NAME, H5F_CRT_BTREE_RANK_SIZE, H5F_def_btree_k_g, - NULL, NULL, NULL, H5F_CRT_BTREE_RANK_ENC, H5F_CRT_BTREE_RANK_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_BTREE_RANK_NAME, H5F_CRT_BTREE_RANK_SIZE, H5F_def_btree_k_g, NULL, + NULL, NULL, H5F_CRT_BTREE_RANK_ENC, H5F_CRT_BTREE_RANK_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for an address */ - if(H5P__register_real(pclass, H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, &H5F_def_sizeof_addr_g, - NULL, NULL, NULL, H5F_CRT_ADDR_BYTE_NUM_ENC, H5F_CRT_ADDR_BYTE_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, + &H5F_def_sizeof_addr_g, NULL, NULL, NULL, H5F_CRT_ADDR_BYTE_NUM_ENC, + H5F_CRT_ADDR_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for object size */ - if(H5P__register_real(pclass, H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE, &H5F_def_sizeof_size_g, - NULL, NULL, NULL, H5F_CRT_OBJ_BYTE_NUM_ENC, H5F_CRT_OBJ_BYTE_NUM_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE, + &H5F_def_sizeof_size_g, NULL, NULL, NULL, H5F_CRT_OBJ_BYTE_NUM_ENC, + H5F_CRT_OBJ_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the superblock version number */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_CRT_SUPER_VERS_NAME, H5F_CRT_SUPER_VERS_SIZE, &H5F_def_superblock_ver_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SUPER_VERS_NAME, H5F_CRT_SUPER_VERS_SIZE, + &H5F_def_superblock_ver_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared OH message information */ - if(H5P__register_real(pclass, H5F_CRT_SHMSG_NINDEXES_NAME, H5F_CRT_SHMSG_NINDEXES_SIZE, &H5F_def_num_sohm_indexes_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_NINDEXES_ENC, H5F_CRT_SHMSG_NINDEXES_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_NINDEXES_NAME, H5F_CRT_SHMSG_NINDEXES_SIZE, + &H5F_def_num_sohm_indexes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_NINDEXES_ENC, + H5F_CRT_SHMSG_NINDEXES_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_TYPES_NAME, H5F_CRT_SHMSG_INDEX_TYPES_SIZE, &H5F_def_sohm_index_flags_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_TYPES_ENC, H5F_CRT_SHMSG_INDEX_TYPES_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_TYPES_NAME, H5F_CRT_SHMSG_INDEX_TYPES_SIZE, + &H5F_def_sohm_index_flags_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_TYPES_ENC, + H5F_CRT_SHMSG_INDEX_TYPES_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE, &H5F_def_sohm_index_minsizes_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_MINSIZE_ENC, H5F_CRT_SHMSG_INDEX_MINSIZE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE, + &H5F_def_sohm_index_minsizes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_MINSIZE_ENC, + H5F_CRT_SHMSG_INDEX_MINSIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared OH cutoff size information */ - if(H5P__register_real(pclass, H5F_CRT_SHMSG_LIST_MAX_NAME, H5F_CRT_SHMSG_LIST_MAX_SIZE, &H5F_def_sohm_list_max_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_LIST_MAX_ENC, H5F_CRT_SHMSG_LIST_MAX_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_LIST_MAX_NAME, H5F_CRT_SHMSG_LIST_MAX_SIZE, + &H5F_def_sohm_list_max_g, NULL, NULL, NULL, H5F_CRT_SHMSG_LIST_MAX_ENC, + H5F_CRT_SHMSG_LIST_MAX_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if(H5P__register_real(pclass, H5F_CRT_SHMSG_BTREE_MIN_NAME, H5F_CRT_SHMSG_BTREE_MIN_SIZE, &H5F_def_sohm_btree_min_g, - NULL, NULL, NULL, H5F_CRT_SHMSG_BTREE_MIN_ENC, H5F_CRT_SHMSG_BTREE_MIN_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_SHMSG_BTREE_MIN_NAME, H5F_CRT_SHMSG_BTREE_MIN_SIZE, + &H5F_def_sohm_btree_min_g, NULL, NULL, NULL, H5F_CRT_SHMSG_BTREE_MIN_ENC, + H5F_CRT_SHMSG_BTREE_MIN_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file space handling strategy */ - if(H5P__register_real(pclass, H5F_CRT_FILE_SPACE_STRATEGY_NAME, H5F_CRT_FILE_SPACE_STRATEGY_SIZE, &H5F_def_file_space_strategy_g, - NULL, NULL, NULL, H5F_CRT_FILE_SPACE_STRATEGY_ENC, H5F_CRT_FILE_SPACE_STRATEGY_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_STRATEGY_NAME, H5F_CRT_FILE_SPACE_STRATEGY_SIZE, + &H5F_def_file_space_strategy_g, NULL, NULL, NULL, H5F_CRT_FILE_SPACE_STRATEGY_ENC, + H5F_CRT_FILE_SPACE_STRATEGY_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free-space persist flag */ - if(H5P__register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, &H5F_def_free_space_persist_g, - NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, H5F_CRT_FREE_SPACE_PERSIST_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, + &H5F_def_free_space_persist_g, NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, + H5F_CRT_FREE_SPACE_PERSIST_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free space section threshold */ - if(H5P__register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, &H5F_def_free_space_threshold_g, - NULL, NULL, NULL, H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, + &H5F_def_free_space_threshold_g, NULL, NULL, NULL, + H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, NULL, NULL, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file space page size */ - if(H5P__register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, &H5F_def_file_space_page_size_g, - NULL, NULL, NULL, H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, + &H5F_def_file_space_page_size_g, NULL, NULL, NULL, + H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, NULL, NULL, + NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_userblock * @@ -316,36 +321,35 @@ H5P__fcrt_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_userblock(hid_t plist_id, hsize_t size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, size); /* Sanity check non-zero userblock sizes */ - if(size > 0) { + if (size > 0) { /* Check that the userblock size is >=512 */ - if(size < 512) + if (size < 512) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and less than 512") /* Check that the userblock size is a power of two */ - if(!POWER_OF_TWO(size)) + if (!POWER_OF_TWO(size)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and not a power of two") } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) + if (H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_userblock() */ - /*------------------------------------------------------------------------- * Function: H5Pget_userblock * @@ -364,26 +368,25 @@ H5Pset_userblock(hid_t plist_id, hsize_t size) herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (size) - if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,"can't get user block"); + if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_sizes * @@ -401,37 +404,37 @@ H5Pget_userblock(hid_t plist_id, hsize_t *size) herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izz", plist_id, sizeof_addr, sizeof_size); /* Check arguments */ - if(sizeof_addr) { - if(sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) + if (sizeof_addr) { + if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid") } /* end if */ - if(sizeof_size) { - if(sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) + if (sizeof_size) { + if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid") } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(sizeof_addr) { + if (sizeof_addr) { uint8_t tmp_sizeof_addr = (uint8_t)sizeof_addr; - if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + if (H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address") } /* end if */ - if(sizeof_size) { + if (sizeof_size) { uint8_t tmp_sizeof_size = (uint8_t)sizeof_size; - if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + if (H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object ") } /* end if */ @@ -439,7 +442,6 @@ H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) FUNC_LEAVE_API(ret_value) } /* end H5Pset_sizes() */ - /*------------------------------------------------------------------------- * Function: H5Pget_sizes * @@ -458,28 +460,28 @@ H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr, size_t *sizeof_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*z*z", plist_id, sizeof_addr, sizeof_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(sizeof_addr) { + if (sizeof_addr) { uint8_t tmp_sizeof_addr; - if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) + if (H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address") *sizeof_addr = tmp_sizeof_addr; } /* end if */ - if(sizeof_size) { + if (sizeof_size) { uint8_t tmp_sizeof_size; - if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) + if (H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object ") *sizeof_size = tmp_sizeof_size; } /* end if */ @@ -488,7 +490,6 @@ H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr, size_t *sizeof_size) FUNC_LEAVE_API(ret_value) } /* end H5Pget_sizes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_sym_k * @@ -517,37 +518,36 @@ H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr, size_t *sizeof_size) herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, ik, lk); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set values */ if (ik > 0) { - if((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); + if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); btree_k[H5B_SNODE_ID] = ik; - if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree nodes"); } if (lk > 0) - if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) + if (H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_sym_k * @@ -564,34 +564,33 @@ H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk) *------------------------------------------------------------------------- */ herr_t -H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out */ , unsigned *lk /*out */ ) +H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out*/, unsigned *lk /*out*/) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, ik, lk); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get values */ if (ik) { - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); *ik = btree_k[H5B_SNODE_ID]; } if (lk) - if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) + if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_istore_k * @@ -609,9 +608,9 @@ H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out */ , unsigned *lk /*out */ ) herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, ik); @@ -620,25 +619,24 @@ H5Pset_istore_k(hid_t plist_id, unsigned ik) if (ik == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value must be positive"); - if((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) + if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); btree_k[H5B_CHUNK_ID] = ik; - if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree internal nodes"); done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pget_istore_k * @@ -656,22 +654,22 @@ H5Pset_istore_k(hid_t plist_id, unsigned ik) *------------------------------------------------------------------------- */ herr_t -H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) +H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out*/) { - unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned btree_k[H5B_NUM_BTREE_ID]; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, ik); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ - if(ik) { - if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) + if (ik) { + if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); *ik = btree_k[H5B_CHUNK_ID]; } /* end if */ @@ -680,7 +678,6 @@ H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) FUNC_LEAVE_API(ret_value) } /* end H5Pget_istore_k() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_btree_rank_enc * @@ -699,7 +696,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 @@ -707,19 +704,19 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) HDassert(btree_k); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of an unsigned*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the btree */ - for(u = 0 ; u < H5B_NUM_BTREE_ID; u++) { + for (u = 0; u < H5B_NUM_BTREE_ID; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)btree_k) btree_k++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5B_NUM_BTREE_ID * sizeof(unsigned)); @@ -727,7 +724,6 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_btree_rank_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_btree_rank_dec * @@ -745,11 +741,11 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -760,18 +756,17 @@ H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the type flags */ - for(u = 0 ; u < H5B_NUM_BTREE_ID; u++) + for (u = 0; u < H5B_NUM_BTREE_ID; u++) H5_DECODE_UNSIGNED(*pp, btree_k[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_btree_rank_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_nindexes * @@ -794,28 +789,28 @@ H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, nindexes); /* Check argument */ if (nindexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set number of indexes"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_nindexes * @@ -832,24 +827,23 @@ H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes) herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, nindexes); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_shared_mesg_nindexes() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_index * @@ -870,52 +864,51 @@ H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes) herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size) { - H5P_genplist_t *plist; /* Property list pointer */ - unsigned nindexes; /* Number of SOHM indexes */ - unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + unsigned nindexes; /* Number of SOHM indexes */ + unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iIuIuIu", plist_id, index_num, mesg_type_flags, min_mesg_size); /* Check arguments */ - if(mesg_type_flags > H5O_SHMESG_ALL_FLAG) + if (mesg_type_flags > H5O_SHMESG_ALL_FLAG) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unrecognized flags in mesg_type_flags") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Read the current number of indexes */ - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") /* Range check */ - if(index_num >= nindexes) + if (index_num >= nindexes) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is too large; no such index"); /* Get arrays of type flags and message sizes */ - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags") - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes") /* Set values in arrays */ type_flags[index_num] = mesg_type_flags; - minsizes[index_num] = min_mesg_size; + minsizes[index_num] = min_mesg_size; /* Write arrays back to plist */ - if(H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set index type flags") - if(H5P_set(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min mesg sizes") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_index() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_index * @@ -931,46 +924,46 @@ H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_ *------------------------------------------------------------------------- */ herr_t -H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, unsigned *min_mesg_size) +H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, + unsigned *min_mesg_size) { - H5P_genplist_t *plist; /* Property list pointer */ - unsigned nindexes; /* Number of SOHM indexes */ - unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + unsigned nindexes; /* Number of SOHM indexes */ + unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "iIu*Iu*Iu", plist_id, index_num, mesg_type_flags, - min_mesg_size); + H5TRACE4("e", "iIu*Iu*Iu", plist_id, index_num, mesg_type_flags, min_mesg_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Read the current number of indexes */ - if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") - if(index_num >= nindexes) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is greater than number of indexes in property list") + if (index_num >= nindexes) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "index_num is greater than number of indexes in property list") /* Get arrays of type flags and message sizes */ - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags") - if(H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes") /* Get values from arrays */ - if(mesg_type_flags) + if (mesg_type_flags) *mesg_type_flags = type_flags[index_num]; - if(min_mesg_size) + if (min_mesg_size) *min_mesg_size = minsizes[index_num]; done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_index() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_types_enc * @@ -990,7 +983,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 @@ -998,19 +991,19 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) HDassert(type_flags); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the type flags */ - for(u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)type_flags) type_flags++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); @@ -1018,7 +1011,6 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_shmsg_index_types_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_types_dec * @@ -1037,11 +1029,11 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1052,18 +1044,17 @@ H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the type flags */ - for(u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) H5_DECODE_UNSIGNED(*pp, type_flags[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_shmsg_index_types_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_minsize_enc * @@ -1083,7 +1074,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 @@ -1091,19 +1082,19 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) HDassert(minsizes); HDassert(size); - if(NULL != *pp) { - unsigned u; /* Local index variable */ + if (NULL != *pp) { + unsigned u; /* Local index variable */ /* Encode the size of a double*/ *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode all the minsize values */ - for(u = 0 ; u < H5O_SHMESG_MAX_NINDEXES; u++) { + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)minsizes) minsizes++; } /* end for */ - } /* end if */ + } /* end if */ /* Size of type flags values */ *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); @@ -1111,7 +1102,6 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_shmsg_index_minsize_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_shmsg_index_minsize_dec * @@ -1130,11 +1120,11 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - unsigned enc_size; /* Size of encoded property */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1145,18 +1135,17 @@ H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) /* Decode the size */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Decode all the minsize values */ - for(u = 0 ; u < H5O_SHMESG_MAX_NINDEXES; u++) + for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) H5_DECODE_UNSIGNED(*pp, minsizes[u]) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fcrt_shmsg_index_minsize_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_shared_mesg_phase_change * @@ -1179,8 +1168,8 @@ H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_list, min_btree); @@ -1190,33 +1179,32 @@ H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_ * * Range check to make certain they will fit into encoded form. */ - if(max_list + 1 < min_btree) + if (max_list + 1 < min_btree) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "minimum B-tree value is greater than maximum list value") - if(max_list > H5O_SHMESG_MAX_LIST_SIZE) + if (max_list > H5O_SHMESG_MAX_LIST_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max list value is larger than H5O_SHMESG_MAX_LIST_SIZE") - if(min_btree > H5O_SHMESG_MAX_LIST_SIZE) + if (min_btree > H5O_SHMESG_MAX_LIST_SIZE) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE") /* Avoid the strange case where max_list == 0 and min_btree == 1, so deleting the * last message in a B-tree makes it become an empty list. */ - if(max_list == 0) + if (max_list == 0) min_btree = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - if(H5P_set(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &max_list) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &max_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set list maximum in property list"); - if(H5P_set(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &min_btree) < 0) + if (H5P_set(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &min_btree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set B-tree minimum in property list"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_shared_mesg_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_phase_change * @@ -1233,36 +1221,35 @@ H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_ herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Iu*Iu", plist_id, max_list, min_btree); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value(s) */ - if(max_list) - if(H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) + if (max_list) + if (H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get list maximum"); - if(min_btree) - if(H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) + if (min_btree) + if (H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get SOHM information"); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_shared_mesg_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_space_strategy * * Purpose: Sets the "strategy" that the library employs in managing file space * Sets the "persist" value as to persist free-space or not - * Sets the "threshold" value that the free space manager(s) will use to track free space sections. - * Ignore "persist" and "threshold" for strategies that do not use free-space managers + * Sets the "threshold" value that the free space manager(s) will use to track free space + *sections. Ignore "persist" and "threshold" for strategies that do not use free-space managers * * Return: Non-negative on success/Negative on failure * @@ -1273,30 +1260,30 @@ H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *mi herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iFfbh", plist_id, strategy, persist, threshold); /* Check arguments */ - if(strategy >= H5F_FSPACE_STRATEGY_NTYPES) + if (strategy >= H5F_FSPACE_STRATEGY_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value(s), if non-zero */ - if(H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) + if (H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy") /* Ignore persist and threshold settings for strategies that do not use FSM */ - if(strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { - if(H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) + if (strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { + if (H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space persisting status") - if(H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) + if (H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space threshold") } /* end if */ @@ -1304,7 +1291,6 @@ H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space_strategy() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space_strategy * @@ -1318,34 +1304,34 @@ H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool *------------------------------------------------------------------------- */ herr_t -H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold) +H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, + hsize_t *threshold) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*Ff*b*h", plist_id, strategy, persist, threshold); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value(s) */ - if(strategy) - if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) + if (strategy) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy") - if(persist) - if(H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) + if (persist) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space persisting status") - if(threshold) - if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) + if (threshold) + if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space_strategy() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_fspace_strategy_enc * @@ -1364,7 +1350,8 @@ H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hboo static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) { - const H5F_fspace_strategy_t *strategy = (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ + const H5F_fspace_strategy_t *strategy = + (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1373,7 +1360,7 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) HDassert(strategy); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode free-space strategy */ *(*pp)++ = (uint8_t)*strategy; @@ -1383,7 +1370,6 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_fspace_strategy_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__fcrt_fspace_strategy_dec * @@ -1402,8 +1388,8 @@ H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) 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; + H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ + const uint8_t ** pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1413,12 +1399,11 @@ H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) HDassert(strategy); /* Decode free-space strategy */ - *strategy = (H5F_fspace_strategy_t)*(*pp)++; + *strategy = (H5F_fspace_strategy_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__fcrt_fspace_strategy_dec() */ - /*------------------------------------------------------------------------- * Function: H5Pset_file_space_page_size * @@ -1433,31 +1418,30 @@ H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", plist_id, fsp_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) + if (fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "cannot set file space page size to less than 512") - if(fsp_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) + if (fsp_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "cannot set file space page size to more than 1GB") /* Set the value*/ - if(H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) + if (H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set file space page size") done: FUNC_LEAVE_API(ret_value) } /* H5Pset_file_space_page_size() */ - /*------------------------------------------------------------------------- * Function: H5Pget_file_space_page_size * @@ -1473,22 +1457,21 @@ H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size) herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", plist_id, fsp_size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(fsp_size) - if(H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) + if (fsp_size) + if (H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space page size") done: FUNC_LEAVE_API(ret_value) } /* H5Pget_file_space_page_size() */ - diff --git a/src/H5Pfmpl.c b/src/H5Pfmpl.c index a0a6d35e2bc..b8dab907bc6 100644 --- a/src/H5Pfmpl.c +++ b/src/H5Pfmpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,20 +43,17 @@ /* ======================== File Mount properties ====================*/ /* Definition for whether absolute symlinks local to file. */ -#define H5F_MNT_SYM_LOCAL_SIZE sizeof(hbool_t) -#define H5F_MNT_SYM_LOCAL_DEF FALSE - +#define H5F_MNT_SYM_LOCAL_SIZE sizeof(hbool_t) +#define H5F_MNT_SYM_LOCAL_DEF FALSE /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,45 +61,40 @@ /* Property class callbacks */ static herr_t H5P__fmnt_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* File mount property list class library initialization object */ const H5P_libclass_t H5P_CLS_FMNT[1] = {{ - "file mount", /* Class name for debugging */ - H5P_TYPE_FILE_MOUNT, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_FILE_MOUNT_g, /* Pointer to class */ - &H5P_CLS_FILE_MOUNT_ID_g, /* Pointer to class ID */ - &H5P_LST_FILE_MOUNT_ID_g, /* Pointer to default property list ID */ - H5P__fmnt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "file mount", /* Class name for debugging */ + H5P_TYPE_FILE_MOUNT, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_FILE_MOUNT_g, /* Pointer to class */ + &H5P_CLS_FILE_MOUNT_ID_g, /* Pointer to class ID */ + &H5P_LST_FILE_MOUNT_ID_g, /* Pointer to default property list ID */ + H5P__fmnt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether symlinks are local to file */ +static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether symlinks are local to file */ - - /*------------------------------------------------------------------------- * Function: H5P__fmnt_reg_prop * @@ -119,16 +109,15 @@ static const hbool_t H5F_def_local_g = H5F_MNT_SYM_LOCAL_DEF; /* Whether sy static herr_t H5P__fmnt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register property of whether symlinks is local to file */ - if(H5P__register_real(pclass, H5F_MNT_SYM_LOCAL_NAME, H5F_MNT_SYM_LOCAL_SIZE, &H5F_def_local_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5F_MNT_SYM_LOCAL_NAME, H5F_MNT_SYM_LOCAL_SIZE, &H5F_def_local_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__fmnt_reg_prop() */ - diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 107ca1570c0..5df73a146c0 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,41 +26,36 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ /* ========= Group Creation properties ============ */ -#define H5G_CRT_GROUP_INFO_ENC H5P__gcrt_group_info_enc -#define H5G_CRT_GROUP_INFO_DEC H5P__gcrt_group_info_dec -#define H5G_CRT_LINK_INFO_ENC H5P__gcrt_link_info_enc -#define H5G_CRT_LINK_INFO_DEC H5P__gcrt_link_info_dec - +#define H5G_CRT_GROUP_INFO_ENC H5P__gcrt_group_info_enc +#define H5G_CRT_GROUP_INFO_DEC H5P__gcrt_group_info_dec +#define H5G_CRT_LINK_INFO_ENC H5P__gcrt_link_info_enc +#define H5G_CRT_LINK_INFO_DEC H5P__gcrt_link_info_dec /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -74,46 +69,41 @@ static herr_t H5P__gcrt_group_info_dec(const void **_pp, void *value); static herr_t 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); - /*********************/ /* Package Variables */ /*********************/ /* Group creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_GCRT[1] = {{ - "group create", /* Class name for debugging */ - H5P_TYPE_GROUP_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_GROUP_CREATE_g, /* Pointer to class */ - &H5P_CLS_GROUP_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_GROUP_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__gcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "group create", /* Class name for debugging */ + H5P_TYPE_GROUP_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_GROUP_CREATE_g, /* Pointer to class */ + &H5P_CLS_GROUP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__gcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ -static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ +static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ +static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ - - /*------------------------------------------------------------------------- * Function: H5P__gcrt_reg_prop * @@ -128,27 +118,26 @@ static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Defaul static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register group info property */ - if(H5P__register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g, - NULL, NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g, NULL, + NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register link info property */ - if(H5P__register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g, - NULL, NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g, NULL, + NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_local_heap_size_hint * @@ -163,33 +152,32 @@ H5P__gcrt_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, size_hint); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update field */ H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t); /* Set value */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_local_heap_size_hint() */ - /*------------------------------------------------------------------------- * Function: H5Pget_local_heap_size_hint * @@ -205,21 +193,21 @@ H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint) herr_t H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, size_hint); - if(size_hint) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (size_hint) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update field */ @@ -230,7 +218,6 @@ H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_local_heap_size_hint() */ - /*------------------------------------------------------------------------- * Function: H5Pset_link_phase_change * @@ -251,46 +238,45 @@ H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/) herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense); /* Range check values */ - if(max_compact < min_dense) + if (max_compact < min_dense) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value") - if(max_compact > 65535) + if (max_compact > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536") - if(min_dense > 65535) + if (min_dense > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update fields */ - if(max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE) + if (max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE) ginfo.store_link_phase_change = TRUE; else ginfo.store_link_phase_change = FALSE; ginfo.max_compact = (uint16_t)max_compact; - ginfo.min_dense = (uint16_t)min_dense; + ginfo.min_dense = (uint16_t)min_dense; /* Set group info */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_link_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pget_link_phase_change * @@ -306,27 +292,27 @@ H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dens herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, max_compact, min_dense); /* Get values */ - if(max_compact || min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (max_compact || min_dense) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - if(max_compact) + if (max_compact) *max_compact = ginfo.max_compact; - if(min_dense) + if (min_dense) *min_dense = ginfo.min_dense; } /* end if */ @@ -334,7 +320,6 @@ H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned FUNC_LEAVE_API(ret_value) } /* end H5Pget_link_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_est_link_info * @@ -357,44 +342,43 @@ H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned herr_t H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, est_num_entries, est_name_len); /* Range check values */ - if(est_num_entries > 65535) + if (est_num_entries > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. number of entries must be < 65536") - if(est_name_len > 65535) + if (est_name_len > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. name length must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") /* Update fields */ - if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + if (est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) ginfo.store_est_entry_info = TRUE; else ginfo.store_est_entry_info = FALSE; ginfo.est_num_entries = (uint16_t)est_num_entries; - ginfo.est_name_len = (uint16_t)est_name_len; + ginfo.est_name_len = (uint16_t)est_name_len; /* Set group info */ - if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_est_link_info() */ - /*------------------------------------------------------------------------- * Function: H5Pget_est_link_info * @@ -410,27 +394,27 @@ H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned *est_name_len /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", plist_id, est_num_entries, est_name_len); /* Get values */ - if(est_num_entries || est_name_len) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_ginfo_t ginfo; /* Group information structure */ + if (est_num_entries || est_name_len) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_ginfo_t ginfo; /* Group information structure */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get group info */ - if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + if (H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - if(est_num_entries) + if (est_num_entries) *est_num_entries = ginfo.est_num_entries; - if(est_name_len) + if (est_name_len) *est_name_len = ginfo.est_name_len; } /* end if */ @@ -438,7 +422,6 @@ H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned FUNC_LEAVE_API(ret_value) } /* end H5Pget_est_link_info() */ - /*------------------------------------------------------------------------- * Function: H5Pset_link_creation_order * @@ -453,23 +436,23 @@ H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_linfo_t linfo; /* Link information structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5O_linfo_t linfo; /* Link information structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_order_flags); - /* Check for bad combination of flags */ - if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) + /* Check for bad combination of flags */ + if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get link info */ - if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") /* Update fields */ @@ -477,14 +460,13 @@ H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) linfo.index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE); /* Set link info */ - if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_link_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pget_link_creation_order * @@ -500,25 +482,25 @@ H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags) herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, crt_order_flags); /* Get values */ - if(crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_linfo_t linfo; /* Link information structure */ + if (crt_order_flags) { + H5P_genplist_t *plist; /* Property list pointer */ + H5O_linfo_t linfo; /* Link information structure */ /* Reset the value to return */ *crt_order_flags = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get link info */ - if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + if (H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") *crt_order_flags |= linfo.track_corder ? H5P_CRT_ORDER_TRACKED : 0; @@ -529,7 +511,6 @@ H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/) FUNC_LEAVE_API(ret_value) } /* end H5Pget_link_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_group_info_enc * @@ -549,11 +530,11 @@ 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 - if(NULL != *pp) { + if (NULL != *pp) { UINT32ENCODE(*pp, ginfo->lheap_size_hint) UINT16ENCODE(*pp, ginfo->max_compact) UINT16ENCODE(*pp, ginfo->min_dense) @@ -566,7 +547,6 @@ H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__gcrt_group_info_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_group_info_dec * @@ -585,9 +565,9 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -602,14 +582,13 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value) UINT16DECODE(*pp, ginfo->est_name_len) /* Update fields */ - if(ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT || - ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE) + if (ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT || ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE) ginfo->store_link_phase_change = TRUE; else ginfo->store_link_phase_change = FALSE; - if(ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || - ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) + if (ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || + ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) ginfo->store_est_entry_info = TRUE; else ginfo->store_est_entry_info = FALSE; @@ -617,7 +596,6 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_group_info_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_link_info_enc * @@ -637,11 +615,11 @@ 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 - if(NULL != *pp) { + if (NULL != *pp) { unsigned crt_order_flags = 0; crt_order_flags |= linfo->track_corder ? H5P_CRT_ORDER_TRACKED : 0; @@ -659,7 +637,6 @@ H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__gcrt_link_info_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__gcrt_link_info_dec * @@ -678,16 +655,16 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; - unsigned crt_order_flags; - unsigned enc_size; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* Set property to default value */ @@ -703,4 +680,3 @@ H5P__gcrt_link_info_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_link_info_dec() */ - diff --git a/src/H5Pint.c b/src/H5Pint.c index a7c0efd0a95..f66e2b99ec4 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,92 +20,98 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_PARALLEL -#include "H5ACprivate.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5ACprivate.h" /* Metadata cache */ +#endif /* H5_HAVE_PARALLEL */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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 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 */ } 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 */ - 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 */ - int prev_idx; /* Previous iteration index */ + H5P_iterate_int_t cb_func; /* Iterator callback */ + 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 */ + 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 */ - int prev_idx; /* Previous iteration index */ + H5P_iterate_int_t cb_func; /* Iterator callback */ + 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; /* Typedef for property list comparison callback */ typedef struct { - const H5P_genplist_t *plist2; /* Pointer to second property list */ - int cmp_value; /* Value from property comparison */ + const H5P_genplist_t *plist2; /* Pointer to second property list */ + int cmp_value; /* Value from property comparison */ } H5P_plist_cmp_ud_t; /* Typedef for property list set/poke callbacks */ typedef struct { - const void *value; /* Pointer to value to set */ + const void *value; /* Pointer to value to set */ } H5P_prop_set_ud_t; /* Typedef for property list get/peek callbacks */ typedef struct { - void *value; /* Pointer for retrieved value */ + void *value; /* Pointer for retrieved value */ } H5P_prop_get_ud_t; /* Typedef for H5P__do_prop() callbacks */ typedef herr_t (*H5P_do_plist_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *udata); + void *udata); typedef herr_t (*H5P_do_pclass_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *udata); - + void *udata); /********************/ /* Local Prototypes */ /********************/ /* General helper routines */ -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 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, + 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 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 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); /*********************/ /* Package Variables */ @@ -115,211 +121,265 @@ static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist * Predefined property list classes. These are initialized at runtime by * H5P__init_package() in this source file. */ -hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ROOT_g = NULL; -hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; -hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; -hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; -hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; -hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; -hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; -hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; -hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; -hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; -hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; -hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; -hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; -hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; -hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; -hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; +hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ROOT_g = NULL; +hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; +hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; +hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; +hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; +hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; +hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; +hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; +hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; +hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; +hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; +hid_t H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_ACCESS_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; +hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; +hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; +hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; +hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; +hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL; +hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; /* * Predefined property lists for each predefined class. These are initialized * at runtime by H5P__init_package() in this source file. */ -hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ - "root", /* Class name for debugging */ - H5P_TYPE_ROOT, /* Class type */ - - NULL, /* Parent class */ - &H5P_CLS_ROOT_g, /* Pointer to class */ - &H5P_CLS_ROOT_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "root", /* Class name for debugging */ + H5P_TYPE_ROOT, /* Class type */ + + NULL, /* Parent class */ + &H5P_CLS_ROOT_g, /* Pointer to class */ + &H5P_CLS_ROOT_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Attribute access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_AACC[1] = {{ - "attribute access", /* Class name for debugging */ - H5P_TYPE_ATTRIBUTE_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_ATTRIBUTE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_ATTRIBUTE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_ATTRIBUTE_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "attribute access", /* Class name for debugging */ + H5P_TYPE_ATTRIBUTE_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_ATTRIBUTE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_ATTRIBUTE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_ATTRIBUTE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Group access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_GACC[1] = {{ - "group access", /* Class name for debugging */ - H5P_TYPE_GROUP_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class */ - &H5P_CLS_GROUP_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_GROUP_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "group access", /* Class name for debugging */ + H5P_TYPE_GROUP_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_GROUP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_GROUP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_GROUP_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Datatype creation property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_TCRT[1] = {{ - "datatype create", /* Class name for debugging */ - H5P_TYPE_DATATYPE_CREATE, /* Class type */ - - &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ - &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class */ - &H5P_CLS_DATATYPE_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_CREATE_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "datatype create", /* Class name for debugging */ + H5P_TYPE_DATATYPE_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_DATATYPE_CREATE_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_CREATE_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; /* Datatype access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_TACC[1] = {{ - "datatype access", /* Class name for debugging */ - H5P_TYPE_DATATYPE_ACCESS, /* Class type */ - - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class */ - &H5P_CLS_DATATYPE_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_DATATYPE_ACCESS_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "datatype access", /* Class name for debugging */ + H5P_TYPE_DATATYPE_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATATYPE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATATYPE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATATYPE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; +/* VOL initialization property list class library initialization object */ +/* (move to proper source code file when used for real) */ +const H5P_libclass_t H5P_CLS_VINI[1] = {{ + "VOL initialization", /* Class name for debugging */ + H5P_TYPE_VOL_INITIALIZE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_VOL_INITIALIZE_g, /* Pointer to class */ + &H5P_CLS_VOL_INITIALIZE_ID_g, /* Pointer to class ID */ + &H5P_LST_VOL_INITIALIZE_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/* Reference access property list class library initialization object */ +/* (move to proper source code file when used for real) */ +const H5P_libclass_t H5P_CLS_RACC[1] = {{ + "reference access", /* Class name for debugging */ + H5P_TYPE_REFERENCE_ACCESS, /* Class type */ + + &H5P_CLS_FILE_ACCESS_g, /* Parent class */ + &H5P_CLS_REFERENCE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_REFERENCE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_REFERENCE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine*/ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; /* Library property list classes defined in other code modules */ /* (And not present in src/H5Pprivate.h) */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ -H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ - +H5_DLLVAR const H5P_libclass_t H5P_CLS_OCRT[1]; /* Object creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_STRCRT[1]; /* String create */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_GCRT[1]; /* Group create */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_MCRT[1]; /* Map creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Track the revision count of a class, to make comparisons faster */ static unsigned H5P_next_rev = 0; -#define H5P_GET_NEXT_REV (H5P_next_rev++) +#define H5P_GET_NEXT_REV (H5P_next_rev++) /* List of all property list classes in the library */ /* (order here is not important, they will be initialized in the proper * order according to their parent class dependencies) */ -static H5P_libclass_t const * const init_class[] = { - H5P_CLS_ROOT, /* Root */ - H5P_CLS_OCRT, /* Object create */ - H5P_CLS_STRCRT, /* String create */ - H5P_CLS_LACC, /* Link access */ - H5P_CLS_GCRT, /* Group create */ - H5P_CLS_OCPY, /* Object copy */ - H5P_CLS_GACC, /* Group access */ - H5P_CLS_FCRT, /* File creation */ - H5P_CLS_FACC, /* File access */ - H5P_CLS_DCRT, /* Dataset creation */ - H5P_CLS_DACC, /* Dataset access */ - H5P_CLS_DXFR, /* Data transfer */ - H5P_CLS_FMNT, /* File mount */ - H5P_CLS_TCRT, /* Datatype creation */ - H5P_CLS_TACC, /* Datatype access */ - H5P_CLS_ACRT, /* Attribute creation */ - H5P_CLS_AACC, /* Attribute access */ - H5P_CLS_LCRT /* Link creation */ +static H5P_libclass_t const *const init_class[] = { + H5P_CLS_ROOT, /* Root */ + H5P_CLS_OCRT, /* Object create */ + H5P_CLS_STRCRT, /* String create */ + H5P_CLS_LACC, /* Link access */ + H5P_CLS_GCRT, /* Group create */ + H5P_CLS_OCPY, /* Object copy */ + H5P_CLS_GACC, /* Group access */ + H5P_CLS_FCRT, /* File creation */ + H5P_CLS_FACC, /* File access */ + H5P_CLS_DCRT, /* Dataset creation */ + H5P_CLS_DACC, /* Dataset access */ + H5P_CLS_DXFR, /* Data transfer */ + H5P_CLS_FMNT, /* File mount */ + H5P_CLS_TCRT, /* Datatype creation */ + H5P_CLS_TACC, /* Datatype access */ + H5P_CLS_MCRT, /* Map creation */ + H5P_CLS_MACC, /* Map access */ + H5P_CLS_ACRT, /* Attribute creation */ + H5P_CLS_AACC, /* Attribute access */ + H5P_CLS_LCRT, /* Link creation */ + H5P_CLS_VINI, /* VOL initialization */ + H5P_CLS_RACC /* Reference access */ }; /* Declare a free list to manage the H5P_genclass_t struct */ @@ -333,22 +393,20 @@ H5FL_DEFINE_STATIC(H5P_genplist_t); /* Generic Property Class ID class */ static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{ - H5I_GENPROP_CLS, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P__close_class /* Callback routine for closing objects of this class */ + H5I_GENPROP_CLS, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5P__close_class /* Callback routine for closing objects of this class */ }}; /* Generic Property List ID class */ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ - H5I_GENPROP_LST, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ + H5I_GENPROP_LST, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ }}; - - /*------------------------------------------------------------------------- * Function: H5P_init * @@ -365,7 +423,7 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ herr_t H5P_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -374,7 +432,6 @@ H5P_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_init() */ - /*-------------------------------------------------------------------------- NAME H5P__init_package -- Initialize interface-specific information @@ -388,18 +445,21 @@ DESCRIPTION herr_t H5P__init_package(void) { - size_t tot_init; /* Total # of classes initialized */ - size_t pass_init; /* # of classes initialized in each pass */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t tot_init; /* Total # of classes initialized */ + size_t pass_init; /* # of classes initialized in each pass */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE + /* Sanity check */ + HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); + /* * Initialize the Generic Property class & object groups. */ - if(H5I_register_type(H5I_GENPROPCLS_CLS) < 0) + if (H5I_register_type(H5I_GENPROPCLS_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") - if(H5I_register_type(H5I_GENPROPLST_CLS) < 0) + if (H5I_register_type(H5I_GENPROPLST_CLS) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") /* Repeatedly pass over the list of property list classes for the library, @@ -408,47 +468,52 @@ H5P__init_package(void) */ tot_init = 0; do { - size_t u; /* Local index variable */ + size_t u; /* Local index variable */ /* Reset pass initialization counter */ pass_init = 0; /* Make a pass over all the library's property list classes */ - for(u = 0; u < NELMTS(init_class); u++) { + for (u = 0; u < NELMTS(init_class); u++) { H5P_libclass_t const *lib_class = init_class[u]; /* Current class to operate on */ /* Check if the current class hasn't been initialized and can be now */ HDassert(lib_class->class_id); - if(*lib_class->class_id == (-1) && (lib_class->par_pclass == NULL - || *lib_class->par_pclass != NULL)) { + if (*lib_class->class_id == (-1) && + (lib_class->par_pclass == NULL || *lib_class->par_pclass != NULL)) { /* Sanity check - only the root class is not allowed to have a parent class */ HDassert(lib_class->par_pclass || lib_class == H5P_CLS_ROOT); /* Allocate the new class */ - if(NULL == (*lib_class->pclass = H5P__create_class(lib_class->par_pclass ? *lib_class->par_pclass : NULL, lib_class->name, lib_class->type, lib_class->create_func, lib_class->create_data, lib_class->copy_func, lib_class->copy_data, lib_class->close_func, lib_class->close_data))) + if (NULL == (*lib_class->pclass = H5P__create_class( + lib_class->par_pclass ? *lib_class->par_pclass : NULL, lib_class->name, + lib_class->type, lib_class->create_func, lib_class->create_data, + lib_class->copy_func, lib_class->copy_data, lib_class->close_func, + lib_class->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed") /* Call routine to register properties for class */ - if(lib_class->reg_prop_func && (*lib_class->reg_prop_func)(*lib_class->pclass) < 0) + if (lib_class->reg_prop_func && (*lib_class->reg_prop_func)(*lib_class->pclass) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register properties") /* Register the new class */ - if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, *lib_class->pclass, FALSE)) < 0) + if ((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, *lib_class->pclass, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class") /* Only register the default property list if it hasn't been created yet */ - if(lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) { + if (lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) { /* Register the default property list for the new class*/ - if((*lib_class->def_plist_id = H5P_create_id(*lib_class->pclass, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list for class") + if ((*lib_class->def_plist_id = H5P_create_id(*lib_class->pclass, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, + "can't register default property list for class") } /* end if */ /* Increment class initialization counters */ pass_init++; tot_init++; } /* end if */ - } /* end for */ - } while(pass_init > 0); + } /* end for */ + } while (pass_init > 0); /* Verify that all classes were initialized */ HDassert(tot_init == NELMTS(init_class)); @@ -457,7 +522,6 @@ H5P__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__init_package() */ - /*-------------------------------------------------------------------------- NAME H5P_term_package @@ -478,107 +542,85 @@ H5P__init_package(void) int H5P_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - int64_t nlist, nclass; + if (H5_PKG_INIT_VAR) { + int64_t nlist, nclass; /* Destroy HDF5 library property classes & lists */ /* Check if there are any open property list classes or lists */ nclass = H5I_nmembers(H5I_GENPROP_CLS); - nlist = H5I_nmembers(H5I_GENPROP_LST); + nlist = H5I_nmembers(H5I_GENPROP_LST); /* If there are any open classes or groups, attempt to get rid of them. */ - if((nclass + nlist) > 0) { + if ((nclass + nlist) > 0) { /* Clear the lists */ - if(nlist > 0) { + if (nlist > 0) { (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); /* Reset the default property lists, if they've been closed */ - if(H5I_nmembers(H5I_GENPROP_LST) == 0) { - H5P_LST_FILE_CREATE_ID_g = - H5P_LST_FILE_ACCESS_ID_g = - H5P_LST_DATASET_CREATE_ID_g = - H5P_LST_DATASET_ACCESS_ID_g = - H5P_LST_DATASET_XFER_ID_g = - H5P_LST_GROUP_CREATE_ID_g = - H5P_LST_GROUP_ACCESS_ID_g = - H5P_LST_DATATYPE_CREATE_ID_g = - H5P_LST_DATATYPE_ACCESS_ID_g = - H5P_LST_ATTRIBUTE_CREATE_ID_g = - H5P_LST_ATTRIBUTE_ACCESS_ID_g = - H5P_LST_OBJECT_COPY_ID_g = - H5P_LST_LINK_CREATE_ID_g = - H5P_LST_LINK_ACCESS_ID_g = - H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; + if (H5I_nmembers(H5I_GENPROP_LST) == 0) { + H5P_LST_FILE_CREATE_ID_g = H5P_LST_FILE_ACCESS_ID_g = H5P_LST_DATASET_CREATE_ID_g = + H5P_LST_DATASET_ACCESS_ID_g = H5P_LST_DATASET_XFER_ID_g = H5P_LST_GROUP_CREATE_ID_g = + H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = + H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_MAP_CREATE_ID_g = + H5P_LST_MAP_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = + H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = + H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = + H5P_LST_VOL_INITIALIZE_ID_g = H5P_LST_REFERENCE_ACCESS_ID_g = + H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; } /* end if */ - } /* end if */ + } /* end if */ /* Only attempt to close the classes after all the lists are closed */ - if(nlist == 0 && nclass > 0) { + if (nlist == 0 && nclass > 0) { (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); /* Reset the default property classes, if they've been closed */ - if(H5I_nmembers(H5I_GENPROP_CLS) == 0) { - H5P_CLS_ROOT_g = - H5P_CLS_OBJECT_CREATE_g = - H5P_CLS_FILE_CREATE_g = - H5P_CLS_FILE_ACCESS_g = - H5P_CLS_DATASET_CREATE_g = - H5P_CLS_DATASET_ACCESS_g = - H5P_CLS_DATASET_XFER_g = - H5P_CLS_GROUP_CREATE_g = - H5P_CLS_GROUP_ACCESS_g = - H5P_CLS_DATATYPE_CREATE_g = - H5P_CLS_DATATYPE_ACCESS_g = - H5P_CLS_STRING_CREATE_g = - H5P_CLS_ATTRIBUTE_CREATE_g = - H5P_CLS_ATTRIBUTE_ACCESS_g = - H5P_CLS_OBJECT_COPY_g = - H5P_CLS_LINK_CREATE_g = - H5P_CLS_LINK_ACCESS_g = - H5P_CLS_FILE_MOUNT_g = NULL; - - H5P_CLS_ROOT_ID_g = - H5P_CLS_OBJECT_CREATE_ID_g = - H5P_CLS_FILE_CREATE_ID_g = - H5P_CLS_FILE_ACCESS_ID_g = - H5P_CLS_DATASET_CREATE_ID_g = - H5P_CLS_DATASET_ACCESS_ID_g = - H5P_CLS_DATASET_XFER_ID_g = - H5P_CLS_GROUP_CREATE_ID_g = - H5P_CLS_GROUP_ACCESS_ID_g = - H5P_CLS_DATATYPE_CREATE_ID_g = - H5P_CLS_DATATYPE_ACCESS_ID_g = - H5P_CLS_STRING_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_ACCESS_ID_g = - H5P_CLS_OBJECT_COPY_ID_g = - H5P_CLS_LINK_CREATE_ID_g = - H5P_CLS_LINK_ACCESS_ID_g = - H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; + if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { + H5P_CLS_ROOT_g = H5P_CLS_OBJECT_CREATE_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = + H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_ACCESS_g = H5P_CLS_DATASET_XFER_g = + H5P_CLS_GROUP_CREATE_g = H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = + H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_MAP_CREATE_g = H5P_CLS_MAP_ACCESS_g = + H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = + H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = + H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = + H5P_CLS_VOL_INITIALIZE_g = H5P_CLS_REFERENCE_ACCESS_g = + H5P_CLS_FILE_MOUNT_g = NULL; + + H5P_CLS_ROOT_ID_g = H5P_CLS_OBJECT_CREATE_ID_g = H5P_CLS_FILE_CREATE_ID_g = + H5P_CLS_FILE_ACCESS_ID_g = H5P_CLS_DATASET_CREATE_ID_g = H5P_CLS_DATASET_ACCESS_ID_g = + H5P_CLS_DATASET_XFER_ID_g = H5P_CLS_GROUP_CREATE_ID_g = + H5P_CLS_GROUP_ACCESS_ID_g = H5P_CLS_DATATYPE_CREATE_ID_g = + H5P_CLS_DATATYPE_ACCESS_ID_g = H5P_CLS_MAP_CREATE_ID_g = + H5P_CLS_MAP_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = + H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5P_CLS_ATTRIBUTE_ACCESS_ID_g = + H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = + H5P_CLS_LINK_ACCESS_ID_g = H5P_CLS_VOL_INITIALIZE_ID_g = + H5P_CLS_REFERENCE_ACCESS_ID_g = + H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; } /* end if */ - } /* end if */ + } /* end if */ n++; /*H5I*/ - } else { + } + else { /* Destroy the property list and class id groups */ n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); /* Mark closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end else */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5P_term_package() */ - /*-------------------------------------------------------------------------- NAME H5P__do_prop_cb1 @@ -604,9 +646,9 @@ 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 */ - H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -617,39 +659,38 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) HDassert(cb); /* Allocate space for a temporary copy of the property value */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call "type 1" callback ('create', 'copy' or 'close') */ - if(cb(prop->name, prop->size, tmp_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed") + if (cb(prop->name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Property callback failed") /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Copy the changed value into the new property */ H5MM_memcpy(pcopy->value, tmp_value, prop->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(slist, pcopy) < 0) + if (H5P__add_prop(slist, pcopy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into skip list") done: /* Release the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__do_prop_cb1() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_pclass @@ -673,9 +714,9 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) 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_genclass_t *ret_value=NULL; /* return value */ + H5P_genclass_t *new_pclass = NULL; /* Property list class copied */ + H5P_genprop_t * pcopy; /* Copy of property to insert into class */ + H5P_genclass_t *ret_value = NULL; /* return value */ FUNC_ENTER_PACKAGE @@ -686,43 +727,44 @@ H5P__copy_pclass(H5P_genclass_t *pclass) */ /* Create the new property list class */ - if(NULL == (new_pclass = H5P__create_class(pclass->parent, pclass->name, pclass->type, pclass->create_func, pclass->create_data, pclass->copy_func, pclass->copy_data, pclass->close_func, pclass->close_data))) + if (NULL == (new_pclass = H5P__create_class(pclass->parent, pclass->name, pclass->type, + pclass->create_func, pclass->create_data, pclass->copy_func, + pclass->copy_data, pclass->close_func, pclass->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "unable to create property list class") /* Copy the properties registered for this class */ - if(pclass->nprops > 0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + if (pclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ - curr_node=H5SL_first(pclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(pclass->props); + while (curr_node != NULL) { /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't copy property") + if (NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "Can't copy property") /* Insert the initialized property into the property list */ - if(H5P__add_prop(new_pclass->props,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL,"Can't insert property into class") + if (H5P__add_prop(new_pclass->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL, "Can't insert property into class") /* Increment property count for class */ new_pclass->nprops++; /* Get the next property node in the list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Set the return value */ - ret_value=new_pclass; + ret_value = new_pclass; done: - if(NULL == ret_value && new_pclass) + if (NULL == ret_value && new_pclass) H5P__close_class(new_pclass); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_pclass() */ +} /* H5P__copy_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P_copy_plist @@ -747,16 +789,16 @@ H5P__copy_pclass(H5P_genclass_t *pclass) hid_t 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 */ - 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 */ - 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 */ + 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 */ + 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 */ + 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 */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -767,83 +809,88 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) */ /* Allocate room for the property list */ - if(NULL==(new_plist = H5FL_CALLOC(H5P_genplist_t))) + if (NULL == (new_plist = H5FL_CALLOC(H5P_genplist_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Set class state */ - new_plist->pclass = old_plist->pclass; - new_plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ - new_plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ + new_plist->pclass = old_plist->pclass; + new_plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ + new_plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ /* Initialize the skip list to hold the changed properties */ - if((new_plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for changed properties") + if ((new_plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, + "can't create skip list for changed properties") /* Create the skip list for deleted properties */ - if((new_plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for deleted properties") + if ((new_plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, + "can't create skip list for deleted properties") /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "can't create skip list for seen properties") nseen = 0; /* Cycle through the deleted properties & copy them into the new list's deleted section */ - if(H5SL_count(old_plist->del) > 0) { + if (H5SL_count(old_plist->del) > 0) { curr_node = H5SL_first(old_plist->del); - while(curr_node) { - char *new_name; /* Pointer to new name */ + while (curr_node) { + char *new_name; /* Pointer to new name */ /* Duplicate string for insertion into new deleted property skip list */ - if((new_name = H5MM_xstrdup((char *)H5SL_item(curr_node))) == NULL) + if ((new_name = H5MM_xstrdup((char *)H5SL_item(curr_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(new_plist->del,new_name,new_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into deleted skip list") + if (H5SL_insert(new_plist->del, new_name, new_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into deleted skip list") /* Add property name to "seen" list */ - if(H5SL_insert(seen,new_name,new_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (H5SL_insert(seen, new_name, new_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Cycle through the properties and copy them also */ - if(H5SL_count(old_plist->props) > 0) { + if (H5SL_count(old_plist->props) > 0) { curr_node = H5SL_first(old_plist->props); - while(curr_node) { + while (curr_node) { /* Get a pointer to the node's property */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Make a copy of the list's property */ - if(NULL == (new_prop = H5P__dup_prop(tmp, H5P_PROP_WITHIN_LIST))) + if (NULL == (new_prop = H5P__dup_prop(tmp, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't copy property") /* Call property copy callback, if it exists */ - if(new_prop->copy) { - if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value) < 0) { + if (new_prop->copy) { + if ((new_prop->copy)(new_prop->name, new_prop->size, new_prop->value) < 0) { H5P__free_prop(new_prop); HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't copy property") } /* end if */ - } /* end if */ + } /* end if */ /* Insert the initialized property into the property list */ - if(H5P__add_prop(new_plist->props,new_prop) < 0) { + if (H5P__add_prop(new_plist->props, new_prop) < 0) { H5P__free_prop(new_prop); HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "Can't insert property into list") } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,new_prop->name,new_prop->name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (H5SL_insert(seen, new_prop->name, new_prop->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; /* Increment the number of properties in list */ @@ -852,35 +899,36 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* * Check for copying class properties (up through list of parent classes also), * initialize each with default value & make property 'copy' callback. */ - tclass=old_plist->pclass; + tclass = old_plist->pclass; has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); - while(tclass != NULL) { - if(tclass->nprops>0) { + while (tclass != NULL) { + if (tclass->nprops > 0) { /* Walk through the properties in the old class */ curr_node = H5SL_first(tclass->props); - while(curr_node!=NULL) { + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "copy" properties we haven't seen before */ - if(nseen == 0 || H5SL_search(seen,tmp->name) == NULL) { + if (nseen == 0 || H5SL_search(seen, tmp->name) == NULL) { /* Call property copy callback, if it exists */ - if(tmp->copy) { + if (tmp->copy) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0) + if (H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "Can't create property") } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ - if(has_parent_class) { - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert property into seen skip list") + if (has_parent_class) { + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5I_INVALID_HID, + "can't insert property into seen skip list") nseen++; } /* end if */ @@ -891,35 +939,36 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ - if(H5P__access_class(new_plist->pclass, H5P_MOD_INC_LST) < 0) + if (H5P__access_class(new_plist->pclass, H5P_MOD_INC_LST) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ref count") /* Get an atom for the property list */ - if((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist, app_ref)) < 0) + if ((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist, app_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list") - /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ + /* Save the property list ID in the property list struct, for use in the property class's 'close' callback + */ new_plist->plist_id = new_plist_id; /* Call the class callback (if it exists) now that we have the property list ID * (up through chain of parent classes also) */ tclass = new_plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->copy_func) { - if((tclass->copy_func)(new_plist_id, old_plist->plist_id, old_plist->pclass->copy_data) < 0) { + while (NULL != tclass) { + if (NULL != tclass->copy_func) { + if ((tclass->copy_func)(new_plist_id, old_plist->plist_id, old_plist->pclass->copy_data) < 0) { /* Delete ID, ignore return value */ H5I_remove(new_plist_id); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't initialize property") } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -929,20 +978,19 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) new_plist->class_init = TRUE; /* Set the return value */ - ret_value=new_plist_id; + ret_value = new_plist_id; done: /* Release the list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); - if(H5I_INVALID_HID == ret_value && new_plist) + if (H5I_INVALID_HID == ret_value && new_plist) H5P_close(new_plist); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_copy_plist() */ +} /* H5P_copy_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__dup_prop @@ -965,7 +1013,7 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) static H5P_genprop_t * H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) { - H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -974,7 +1022,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) + if (NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy basic property information */ @@ -983,7 +1031,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Check if we should duplicate the name or share it */ /* Duplicating property for a class */ - if(type == H5P_PROP_WITHIN_CLASS) { + if (type == H5P_PROP_WITHIN_CLASS) { HDassert(oprop->type == H5P_PROP_WITHIN_CLASS); HDassert(oprop->shared_name == FALSE); @@ -995,9 +1043,9 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Check if we are duplicating a property from a list or a class */ /* Duplicating a property from a list */ - if(oprop->type == H5P_PROP_WITHIN_LIST) { + if (oprop->type == H5P_PROP_WITHIN_LIST) { /* If the old property's name wasn't shared, we have to copy it here also */ - if(!oprop->shared_name) + if (!oprop->shared_name) prop->name = H5MM_xstrdup(oprop->name); } /* end if */ /* Duplicating a property from a class */ @@ -1011,12 +1059,12 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) /* Set the type */ prop->type = type; } /* end else */ - } /* end else */ + } /* end else */ /* Duplicate current value, if it exists */ - if(oprop->value != NULL) { + if (oprop->value != NULL) { HDassert(prop->size > 0); - if(NULL == (prop->value = H5MM_malloc(prop->size))) + if (NULL == (prop->value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(prop->value, oprop->value, prop->size); } /* end if */ @@ -1026,20 +1074,19 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) done: /* Free any resources allocated */ - if(ret_value == NULL) { - if(prop != NULL) { - if(prop->name != NULL) + if (ret_value == NULL) { + if (prop != NULL) { + if (prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value != NULL) + if (prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__dup_prop() */ +} /* H5P__dup_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__create_prop @@ -1074,15 +1121,13 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) REVISION LOG --------------------------------------------------------------------------*/ 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) +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) { - H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1092,18 +1137,18 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) + if (NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the property initial values */ - prop->name = H5MM_xstrdup(name); /* Duplicate name */ + prop->name = H5MM_xstrdup(name); /* Duplicate name */ prop->shared_name = FALSE; - prop->size = size; - prop->type = type; + prop->size = size; + prop->type = type; /* Duplicate value, if it exists */ - if(value != NULL) { - if(NULL == (prop->value = H5MM_malloc (prop->size))) + if (value != NULL) { + if (NULL == (prop->value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(prop->value, value, prop->size); } /* end if */ @@ -1112,14 +1157,14 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, /* Set the function pointers */ prop->create = prp_create; - prop->set = prp_set; - prop->get = prp_get; + prop->set = prp_set; + prop->get = prp_get; prop->encode = prp_encode; prop->decode = prp_decode; - prop->del = prp_delete; - prop->copy = prp_copy; + prop->del = prp_delete; + prop->copy = prp_copy; /* Use custom comparison routine if available, otherwise default to memcmp() */ - if(prp_cmp != NULL) + if (prp_cmp != NULL) prop->cmp = prp_cmp; else prop->cmp = &memcmp; @@ -1130,20 +1175,19 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, done: /* Free any resources allocated */ - if(ret_value == NULL) { - if(prop != NULL) { - if(prop->name != NULL) + if (ret_value == NULL) { + if (prop != NULL) { + if (prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value != NULL) + if (prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create_prop() */ +} /* H5P__create_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__add_prop @@ -1165,7 +1209,7 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, herr_t H5P__add_prop(H5SL_t *slist, H5P_genprop_t *prop) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1174,14 +1218,13 @@ H5P__add_prop(H5SL_t *slist, H5P_genprop_t *prop) HDassert(prop->type != H5P_PROP_WITHIN_UNKNOWN); /* Insert property into skip list */ - if(H5SL_insert(slist, prop, prop->name) < 0) + if (H5SL_insert(slist, prop, prop->name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P__add_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__find_prop_plist @@ -1203,7 +1246,7 @@ H5P__add_prop(H5SL_t *slist, H5P_genprop_t *prop) H5P_genprop_t * H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) { - H5P_genprop_t *ret_value = NULL; /* Return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1211,19 +1254,19 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) HDassert(name); /* Check if the property has been deleted from list */ - if(H5SL_search(plist->del,name) != NULL) { + if (H5SL_search(plist->del, name) != NULL) { HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "property deleted from skip list") } /* end if */ else { /* Get the property data from the skip list */ - if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(plist->props, name))) { - H5P_genclass_t *tclass; /* Temporary class pointer */ + if (NULL == (ret_value = (H5P_genprop_t *)H5SL_search(plist->props, name))) { + H5P_genclass_t *tclass; /* Temporary class pointer */ /* Couldn't find property in list itself, start searching through class info */ tclass = plist->pclass; - while(tclass != NULL) { + while (tclass != NULL) { /* Find the property in the class */ - if(NULL != (ret_value = (H5P_genprop_t *)H5SL_search(tclass->props, name))) + if (NULL != (ret_value = (H5P_genprop_t *)H5SL_search(tclass->props, name))) /* Got pointer to property - leave now */ break; @@ -1232,16 +1275,15 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) } /* end while */ /* Check if we haven't found the property */ - if(ret_value == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list") + if (ret_value == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__find_prop_plist() */ +} /* H5P__find_prop_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__find_prop_pclass @@ -1263,7 +1305,7 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) static H5P_genprop_t * H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name) { - H5P_genprop_t *ret_value = NULL; /* Return value */ + H5P_genprop_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1271,14 +1313,13 @@ H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Get the property from the skip list */ - if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(pclass->props, name))) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list") + if (NULL == (ret_value = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__find_prop_pclass() */ +} /* H5P__find_prop_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__free_prop @@ -1305,19 +1346,18 @@ H5P__free_prop(H5P_genprop_t *prop) HDassert(prop); /* Release the property value if it exists */ - if(prop->value) + if (prop->value) H5MM_xfree(prop->value); /* Only free the name if we own it */ - if(!prop->shared_name) + if (!prop->shared_name) H5MM_xfree(prop->name); prop = H5FL_FREE(H5P_genprop_t, prop); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__free_prop() */ +} /* H5P__free_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__free_prop_cb @@ -1341,24 +1381,23 @@ H5P__free_prop(H5P_genprop_t *prop) static herr_t H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data) { - H5P_genprop_t *tprop=(H5P_genprop_t *)item; /* Temporary pointer to property */ - hbool_t make_cb = *(hbool_t *)op_data; /* Whether to make property 'close' callback */ + H5P_genprop_t *tprop = (H5P_genprop_t *)item; /* Temporary pointer to property */ + hbool_t make_cb = *(hbool_t *)op_data; /* Whether to make property 'close' callback */ FUNC_ENTER_STATIC_NOERR HDassert(tprop); /* Call the close callback and ignore the return value, there's nothing we can do about it */ - if(make_cb && tprop->close != NULL) + if (make_cb && tprop->close != NULL) (tprop->close)(tprop->name, tprop->size, tprop->value); /* Free the property, ignoring return value, nothing we can do */ H5P__free_prop(tprop); FUNC_LEAVE_NOAPI(0) -} /* H5P__free_prop_cb() */ +} /* H5P__free_prop_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__free_del_name_cb @@ -1381,7 +1420,7 @@ 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) { - char *del_name=(char *)item; /* Temporary pointer to deleted name */ + char *del_name = (char *)item; /* Temporary pointer to deleted name */ FUNC_ENTER_STATIC_NOERR @@ -1391,9 +1430,8 @@ H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(0) -} /* H5P__free_del_name_cb() */ +} /* H5P__free_del_name_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__access_class @@ -1424,35 +1462,35 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) HDassert(pclass); HDassert(mod > H5P_MOD_ERR && mod < H5P_MOD_MAX); - switch(mod) { - case H5P_MOD_INC_CLS: /* Increment the dependent class count*/ + switch (mod) { + case H5P_MOD_INC_CLS: /* Increment the dependent class count*/ pclass->classes++; break; - case H5P_MOD_DEC_CLS: /* Decrement the dependent class count*/ + case H5P_MOD_DEC_CLS: /* Decrement the dependent class count*/ pclass->classes--; break; - case H5P_MOD_INC_LST: /* Increment the dependent list count*/ + case H5P_MOD_INC_LST: /* Increment the dependent list count*/ pclass->plists++; break; - case H5P_MOD_DEC_LST: /* Decrement the dependent list count*/ + case H5P_MOD_DEC_LST: /* Decrement the dependent list count*/ pclass->plists--; break; - case H5P_MOD_INC_REF: /* Increment the ID reference count*/ + case H5P_MOD_INC_REF: /* Increment the ID reference count*/ /* Reset the deleted flag if incrementing the reference count */ - if(pclass->deleted) + if (pclass->deleted) pclass->deleted = FALSE; pclass->ref_count++; break; - case H5P_MOD_DEC_REF: /* Decrement the ID reference count*/ + case H5P_MOD_DEC_REF: /* Decrement the ID reference count*/ pclass->ref_count--; /* Mark the class object as deleted if reference count drops to zero */ - if(pclass->ref_count == 0) + if (pclass->ref_count == 0) pclass->deleted = TRUE; break; @@ -1463,14 +1501,14 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) } /* end switch */ /* Check if we can release the class information now */ - if(pclass->deleted && pclass->plists == 0 && pclass->classes == 0) { - H5P_genclass_t *par_class = pclass->parent; /* Pointer to class's parent */ + if (pclass->deleted && pclass->plists == 0 && pclass->classes == 0) { + H5P_genclass_t *par_class = pclass->parent; /* Pointer to class's parent */ HDassert(pclass->name); H5MM_xfree(pclass->name); /* Free the class properties without making callbacks */ - if(pclass->props) { + if (pclass->props) { hbool_t make_cb = FALSE; H5SL_destroy(pclass->props, H5P__free_prop_cb, &make_cb); @@ -1479,14 +1517,13 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) pclass = H5FL_FREE(H5P_genclass_t, pclass); /* Reduce the number of dependent classes on parent class also */ - if(par_class != NULL) + if (par_class != NULL) H5P__access_class(par_class, H5P_MOD_DEC_CLS); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__access_class() */ +} /* H5P__access_class() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path_cb @@ -1511,9 +1548,9 @@ 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_check_class_t *key = (H5P_check_class_t *)_key; /* Pointer to key information for comparison */ - int ret_value = 0; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -1522,18 +1559,17 @@ H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) HDassert(key); /* Check if the class object has the same parent as the new class */ - if(obj->parent == key->parent) { + if (obj->parent == key->parent) { /* Check if they have the same name */ - if(HDstrcmp(obj->name, key->name) == 0) { + if (HDstrcmp(obj->name, key->name) == 0) { key->new_class = obj; - ret_value = 1; /* Indicate a match */ - } /* end if */ - } /* end if */ + ret_value = 1; /* Indicate a match */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__open_class_path_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__create_class @@ -1569,52 +1605,51 @@ H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) --------------------------------------------------------------------------*/ H5P_genclass_t * H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data) + H5P_cls_create_func_t cls_create, void *create_data, H5P_cls_copy_func_t cls_copy, + void *copy_data, H5P_cls_close_func_t cls_close, void *close_data) { - H5P_genclass_t *pclass = NULL; /* Property list class created */ - H5P_genclass_t *ret_value = NULL; /* Return value */ + H5P_genclass_t *pclass = NULL; /* Property list class created */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE HDassert(name); /* Allow internal classes to break some rules */ /* (This allows the root of the tree to be created with this routine -QAK) */ - if(type == H5P_TYPE_USER) + if (type == H5P_TYPE_USER) HDassert(par_class); /* Allocate room for the class */ - if(NULL == (pclass = H5FL_CALLOC(H5P_genclass_t))) + if (NULL == (pclass = H5FL_CALLOC(H5P_genclass_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, NULL, "property list class allocation failed") /* Set class state */ pclass->parent = par_class; - if(NULL == (pclass->name = H5MM_xstrdup(name))) + if (NULL == (pclass->name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, NULL, "property list class name allocation failed") - pclass->type = type; - pclass->nprops = 0; /* Classes are created without properties initially */ - pclass->plists = 0; /* No properties lists of this class yet */ - pclass->classes = 0; /* No classes derived from this class yet */ - pclass->ref_count = 1; /* This is the first reference to the new class */ - pclass->deleted = FALSE; /* Not deleted yet... :-) */ - pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ + pclass->type = type; + pclass->nprops = 0; /* Classes are created without properties initially */ + pclass->plists = 0; /* No properties lists of this class yet */ + pclass->classes = 0; /* No classes derived from this class yet */ + pclass->ref_count = 1; /* This is the first reference to the new class */ + pclass->deleted = FALSE; /* Not deleted yet... :-) */ + pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ /* Create the skip list for properties */ - if(NULL == (pclass->props = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (pclass->props = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for properties") /* Set callback functions and pass-along data */ pclass->create_func = cls_create; pclass->create_data = create_data; - pclass->copy_func = cls_copy; - pclass->copy_data = copy_data; - pclass->close_func = cls_close; - pclass->close_data = close_data; + pclass->copy_func = cls_copy; + pclass->copy_data = copy_data; + pclass->close_func = cls_close; + pclass->close_data = close_data; /* Increment parent class's derived class value */ - if(par_class != NULL) { - if(H5P__access_class(par_class, H5P_MOD_INC_CLS) < 0) + if (par_class != NULL) { + if (H5P__access_class(par_class, H5P_MOD_INC_CLS) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL, "Can't increment parent class ref count") } /* end if */ @@ -1623,11 +1658,11 @@ H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t done: /* Free any resources allocated */ - if(ret_value == NULL) - if(pclass) { - if(pclass->name) + if (ret_value == NULL) + if (pclass) { + if (pclass->name) H5MM_xfree(pclass->name); - if(pclass->props) { + if (pclass->props) { hbool_t make_cb = FALSE; H5SL_destroy(pclass->props, H5P__free_prop_cb, &make_cb); @@ -1636,9 +1671,8 @@ H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create_class() */ +} /* H5P__create_class() */ - /*-------------------------------------------------------------------------- NAME H5P__create @@ -1667,11 +1701,11 @@ H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t static H5P_genplist_t * 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_genplist_t *ret_value = NULL; /* Return value */ + 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_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1682,106 +1716,106 @@ H5P__create(H5P_genclass_t *pclass) */ /* Allocate room for the property list */ - if(NULL==(plist = H5FL_CALLOC(H5P_genplist_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,"memory allocation failed") + if (NULL == (plist = H5FL_CALLOC(H5P_genplist_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set class state */ - plist->pclass = pclass; - plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ - plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ + plist->pclass = pclass; + plist->nprops = 0; /* Initially the plist has the same number of properties as the class */ + plist->class_init = FALSE; /* Initially, wait until the class callback finishes to set */ /* Create the skip list for changed properties */ - if((plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for changed properties") + if ((plist->props = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for changed properties") /* Create the skip list for deleted properties */ - if((plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for deleted properties") + if ((plist->del = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for deleted properties") /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for seen properties") + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, NULL, "can't create skip list for seen properties") /* * Check if we should copy class properties (up through list of parent classes also), * initialize each with default value & make property 'create' callback. */ - tclass=pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + tclass = pclass; + while (tclass != NULL) { + if (tclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(tclass->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "create" properties we haven't seen before */ - if(H5SL_search(seen,tmp->name) == NULL) { + if (H5SL_search(seen, tmp->name) == NULL) { /* Call property creation callback, if it exists */ - if(tmp->create) { + if (tmp->create) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't create property") + if (H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "Can't create property") } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,NULL,"can't insert property into seen skip list") + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, NULL, + "can't insert property into seen skip list") /* Increment the number of properties in list */ plist->nprops++; } /* end if */ /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ /* Increment the number of property lists derived from class */ - if(H5P__access_class(plist->pclass,H5P_MOD_INC_LST) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL,"Can't increment class ref count") + if (H5P__access_class(plist->pclass, H5P_MOD_INC_LST) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, NULL, "Can't increment class ref count") /* Set return value */ - ret_value=plist; + ret_value = plist; done: /* Release the skip list of 'seen' properties */ - if(seen!=NULL) + if (seen != NULL) H5SL_close(seen); /* Release resources allocated on failure */ - if(ret_value==NULL) { - if(plist!=NULL) { + if (ret_value == NULL) { + if (plist != NULL) { /* Close & free any changed properties */ - if(plist->props) { - unsigned make_cb=1; + if (plist->props) { + unsigned make_cb = 1; H5SL_destroy(plist->props, H5P__free_prop_cb, &make_cb); } /* end if */ /* Close the deleted property skip list */ - if(plist->del) + if (plist->del) H5SL_close(plist->del); /* Release the property list itself */ plist = H5FL_FREE(H5P_genplist_t, plist); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__create() */ +} /* H5P__create() */ - /*-------------------------------------------------------------------------- NAME H5P_create_id @@ -1807,38 +1841,39 @@ H5P__create(H5P_genclass_t *pclass) hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genplist_t *plist = NULL; /* Property list created */ - hid_t plist_id = FAIL; /* Property list ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genplist_t *plist = NULL; /* Property list created */ + hid_t plist_id = FAIL; /* Property list ID */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) HDassert(pclass); /* Create the new property list */ - if((plist = H5P__create(pclass)) == NULL) + if ((plist = H5P__create(pclass)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list") /* Get an atom for the property list */ - if((plist_id = H5I_register(H5I_GENPROP_LST, plist, app_ref)) < 0) + if ((plist_id = H5I_register(H5I_GENPROP_LST, plist, app_ref)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list") - /* Save the property list ID in the property list struct, for use in the property class's 'close' callback */ + /* Save the property list ID in the property list struct, for use in the property class's 'close' callback + */ plist->plist_id = plist_id; /* Call the class callback (if it exists) now that we have the property list ID * (up through chain of parent classes also) */ tclass = plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->create_func) { - if((tclass->create_func)(plist_id, tclass->create_data) < 0) { + while (NULL != tclass) { + if (NULL != tclass->create_func) { + if ((tclass->create_func)(plist_id, tclass->create_data) < 0) { /* Delete ID, ignore return value */ H5I_remove(plist_id); HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't initialize property") } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -1851,13 +1886,12 @@ H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) ret_value = plist_id; done: - if(H5I_INVALID_HID == ret_value && plist) + if (H5I_INVALID_HID == ret_value && plist) H5P_close(plist); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_create_id() */ +} /* H5P_create_id() */ - /*-------------------------------------------------------------------------- NAME H5P__register_real @@ -2043,16 +2077,14 @@ H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, - const void *def_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) +H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, const void *def_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) { - H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2063,18 +2095,18 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, HDassert((size > 0 && def_value != NULL) || (size == 0)); /* Check for duplicate named properties */ - if(NULL != H5SL_search(pclass->props, name)) + if (NULL != H5SL_search(pclass->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_CLASS, - def_value, prp_create, prp_set, prp_get, prp_encode, prp_decode, - prp_delete, prp_copy, prp_cmp, prp_close))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") + if (NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_CLASS, def_value, prp_create, + prp_set, prp_get, prp_encode, prp_decode, prp_delete, prp_copy, + prp_cmp, prp_close))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Insert property into property list class */ - if(H5P__add_prop(pclass->props, new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(pclass->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ pclass->nprops++; @@ -2083,14 +2115,13 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, pclass->revision = H5P_GET_NEXT_REV; done: - if(ret_value < 0) - if(new_prop && H5P__free_prop(new_prop) < 0) + if (ret_value < 0) + if (new_prop && H5P__free_prop(new_prop) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__register_real() */ +} /* H5P__register_real() */ - /*-------------------------------------------------------------------------- NAME H5P__register @@ -2275,17 +2306,15 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, - const void *def_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) +H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, const void *def_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) { - H5P_genclass_t *pclass = *ppclass; /* Pointer to class to modify */ - H5P_genclass_t *new_class = NULL; /* New class pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *pclass = *ppclass; /* Pointer to class to modify */ + H5P_genclass_t *new_class = NULL; /* New class pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2296,29 +2325,29 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, /* Check if class needs to be split because property lists or classes have * been created since the last modification was made to the class. */ - if(pclass->plists > 0 || pclass->classes > 0) { - if(NULL == (new_class = H5P__create_class(pclass->parent, pclass->name, - pclass->type, pclass->create_func, pclass->create_data, - pclass->copy_func, pclass->copy_data, - pclass->close_func, pclass->close_data))) + if (pclass->plists > 0 || pclass->classes > 0) { + if (NULL == (new_class = H5P__create_class( + pclass->parent, pclass->name, pclass->type, pclass->create_func, pclass->create_data, + pclass->copy_func, pclass->copy_data, pclass->close_func, pclass->close_data))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy class") /* Walk through the skip list of the old class and copy properties */ - if(pclass->nprops > 0) { - H5SL_node_t *curr_node; /* Current node in skip list */ + if (pclass->nprops > 0) { + H5SL_node_t *curr_node; /* Current node in skip list */ /* Walk through the properties in the old class */ curr_node = H5SL_first(pclass->props); - while(curr_node != NULL) { - H5P_genprop_t *pcopy; /* Property copy */ + while (curr_node != NULL) { + H5P_genprop_t *pcopy; /* Property copy */ /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) + if (NULL == + (pcopy = H5P__dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Insert the initialized property into the property class */ - if(H5P__add_prop(new_class->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(new_class->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ new_class->nprops++; @@ -2326,30 +2355,29 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, /* Get the next property node in the skip list */ curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Use the new class instead of the old one */ pclass = new_class; } /* end if */ /* Really register the property in the class */ - if(H5P__register_real(pclass, name, size, def_value, prp_create, prp_set, prp_get, - prp_encode, prp_decode, prp_delete, prp_copy, prp_cmp, prp_close) < 0) + if (H5P__register_real(pclass, name, size, def_value, prp_create, prp_set, prp_get, prp_encode, + prp_decode, prp_delete, prp_copy, prp_cmp, prp_close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't register property") /* Update pointer to pointer to class, if a new one was generated */ - if(new_class) + if (new_class) *ppclass = pclass; done: - if(ret_value < 0) - if(new_class && H5P__close_class(new_class) < 0) + if (ret_value < 0) + if (new_class && H5P__close_class(new_class) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close new property class") FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__register() */ +} /* H5P__register() */ - /*-------------------------------------------------------------------------- NAME H5P_insert @@ -2520,14 +2548,13 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, - void *value, 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) +H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, 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) { - H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genprop_t *new_prop = NULL; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2536,61 +2563,60 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, HDassert((size > 0 && value != NULL) || (size == 0)); /* Check for duplicate named properties */ - if(NULL != H5SL_search(plist->props, name)) + if (NULL != H5SL_search(plist->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") /* Check if the property has been deleted */ - if(NULL != H5SL_search(plist->del, name)) { + if (NULL != H5SL_search(plist->del, name)) { char *temp_name = NULL; /* Remove the property name from the deleted property skip list */ - if(NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) - HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from deleted skip list") + if (NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from deleted skip list") /* free the name of the removed property */ H5MM_xfree(temp_name); } /* end if */ else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ /* Check if the property is already in the class hierarchy */ tclass = plist->pclass; - while(tclass) { - if(tclass->nprops > 0) { + while (tclass) { + if (tclass->nprops > 0) { /* Find the property in the class */ - if(NULL != H5SL_search(tclass->props, name)) + if (NULL != H5SL_search(tclass->props, name)) HGOTO_ERROR(H5E_PLIST, H5E_EXISTS, FAIL, "property already exists") } /* end if */ /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end else */ + } /* end else */ /* Ok to add to property list */ /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_LIST, value, NULL, - prp_set, prp_get, prp_encode, prp_decode, prp_delete, prp_copy, - prp_cmp, prp_close))) + if (NULL == + (new_prop = H5P__create_prop(name, size, H5P_PROP_WITHIN_LIST, value, NULL, prp_set, prp_get, + prp_encode, prp_decode, prp_delete, prp_copy, prp_cmp, prp_close))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Insert property into property list class */ - if(H5P__add_prop(plist->props, new_prop) < 0) + if (H5P__add_prop(plist->props, new_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ plist->nprops++; done: - if(ret_value < 0) - if(new_prop && H5P__free_prop(new_prop) < 0) + if (ret_value < 0) + if (new_prop && H5P__free_prop(new_prop) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") FUNC_LEAVE_NOAPI(ret_value) } /* H5P_insert() */ - /*-------------------------------------------------------------------------- NAME H5P__do_prop @@ -2616,11 +2642,11 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, --------------------------------------------------------------------------*/ 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) + H5P_do_pclass_op_t pclass_op, void *udata) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genprop_t * prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2631,13 +2657,13 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op HDassert(pclass_op); /* Check if the property has been deleted */ - if(NULL != H5SL_search(plist->del, name)) + if (NULL != H5SL_search(plist->del, name)) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Find property in changed list */ - if(NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) { + if (NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) { /* Call the 'found in property list' callback */ - if((*plist_op)(plist, name, prop, udata) < 0) + if ((*plist_op)(plist, name, prop, udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") } /* end if */ else { @@ -2646,18 +2672,18 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op * & make property 'set' callback. */ tclass = plist->pclass; - while(NULL != tclass) { - if(tclass->nprops > 0) { + while (NULL != tclass) { + if (tclass->nprops > 0) { /* Find the property in the class */ - if(NULL != (prop = (H5P_genprop_t *)H5SL_search(tclass->props, name))) { + if (NULL != (prop = (H5P_genprop_t *)H5SL_search(tclass->props, name))) { /* Call the 'found in class' callback */ - if((*pclass_op)(plist, name, prop, udata) < 0) + if ((*pclass_op)(plist, name, prop, udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") /* Leave */ break; } /* end if */ - } /* end if */ + } /* end if */ /* Go up to parent class */ tclass = tclass->parent; @@ -2666,15 +2692,14 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ - if(NULL == tclass) + if (NULL == tclass) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't find property in skip list") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__do_prop() */ +} /* H5P__do_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__poke_plist_cb @@ -2698,10 +2723,10 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op --------------------------------------------------------------------------*/ static herr_t H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, - H5P_genprop_t *prop, void *_udata) + H5P_genprop_t *prop, void *_udata) { - H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2711,7 +2736,7 @@ H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_AT HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Overwrite value in property */ @@ -2719,9 +2744,8 @@ H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_AT done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__poke_plist_cb() */ +} /* H5P__poke_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__poke_pclass_cb @@ -2745,11 +2769,11 @@ H5P__poke_plist_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_AT --------------------------------------------------------------------------*/ static herr_t H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *name, H5P_genprop_t *prop, - void *_udata) + 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2760,29 +2784,28 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *nam HDassert(prop->cmp); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") H5MM_memcpy(pcopy->value, udata->value, pcopy->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(plist->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") + if (H5P__add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert changed property into skip list") done: /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__poke_pclass_cb() */ +} /* H5P__poke_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_poke @@ -2810,8 +2833,8 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *nam herr_t H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) { - H5P_prop_set_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2822,14 +2845,13 @@ H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) /* Find the property and set the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__poke_plist_cb, H5P__poke_pclass_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__poke_plist_cb, H5P__poke_pclass_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to overwrite value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_poke() */ +} /* H5P_poke() */ - /*-------------------------------------------------------------------------- NAME H5P__set_plist_cb @@ -2852,13 +2874,12 @@ H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2868,31 +2889,31 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the value and pass to 'set' callback */ - if(NULL != prop->set) { + if (NULL != prop->set) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ - if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - /* Set the pointer for copying */ - prp_value = tmp_value; + /* Set the pointer for copying */ + prp_value = tmp_value; } /* end if */ /* No 'set' callback, just copy value */ else prp_value = udata->value; /* Free any previous value for the property */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Call user's 'delete' callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") } /* end if */ @@ -2901,13 +2922,12 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value != NULL) + if (tmp_value != NULL) H5MM_xfree(tmp_value); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__set_plist_cb() */ +} /* H5P__set_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__set_pclass_cb @@ -2930,14 +2950,13 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2948,51 +2967,50 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop->cmp); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a copy of the value and pass to 'set' callback */ - if(NULL != prop->set) { + if (NULL != prop->set) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ - if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - /* Set the pointer for copying */ - prp_value = tmp_value; + /* Set the pointer for copying */ + prp_value = tmp_value; } /* end if */ /* No 'set' callback, just copy value */ else prp_value = udata->value; /* Make a copy of the class's property */ - if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) + if (NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") H5MM_memcpy(pcopy->value, prp_value, pcopy->size); /* Insert the changed property into the property list */ - if(H5P__add_prop(plist->props, pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") + if (H5P__add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert changed property into skip list") done: /* Free the temporary value buffer */ - if(tmp_value != NULL) + if (tmp_value != NULL) H5MM_xfree(tmp_value); /* Cleanup on failure */ - if(ret_value < 0) - if(pcopy) + if (ret_value < 0) + if (pcopy) H5P__free_prop(pcopy); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__set_pclass_cb() */ +} /* H5P__set_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_set @@ -3027,8 +3045,8 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value) { - H5P_prop_set_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3039,14 +3057,121 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value) /* Find the property and set the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__set_plist_cb, H5P__set_pclass_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__set_plist_cb, H5P__set_pclass_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to set value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_set() */ +} /* H5P_set() */ + +/*-------------------------------------------------------------------------- + NAME + H5P__class_get + PURPOSE + Internal routine to get a property's value from a property class. + USAGE + herr_t H5P__class_get(pclass, name, value) + const H5P_genclass_t *pclass; IN: Property class to find property in + const char *name; IN: Name of property to get + void *value; IN: Pointer to the value for the property + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Gets the current value for a property in a property class. The property + name must exist or this routine will fail. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + The 'get' callback routine registered for this property will _NOT_ be + called, this routine is designed for internal library use only! + + This routine may not be called for zero-sized properties and will + return an error in that case. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value) +{ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(pclass); + HDassert(name); + HDassert(value); + + /* Find property in list */ + if (NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") + + /* Check for property size >0 */ + if (0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Copy the property value */ + H5MM_memcpy(value, prop->value, prop->size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__class_get() */ + +/*-------------------------------------------------------------------------- + NAME + H5P__class_set + PURPOSE + Internal routine to set a property's value in a property class. + USAGE + herr_t H5P__class_set(pclass, name, value) + const H5P_genclass_t *pclass; IN: Property class to find property in + const char *name; IN: Name of property to set + const void *value; IN: Pointer to the value for the property + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Sets a new value for a property in a property class. The property name + must exist or this routine will fail. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + The 'set' callback routine registered for this property will _NOT_ be + called, this routine is designed for internal library use only! + + This routine may not be called for zero-sized properties and will + return an error in that case. + + The previous value is overwritten, not released in any way. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value) +{ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(pclass); + HDassert(name); + HDassert(value); + + /* Find property in list */ + if (NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") + + /* Check for property size >0 */ + if (0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Copy the property value */ + H5MM_memcpy(prop->value, value, prop->size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__class_set() */ - /*-------------------------------------------------------------------------- NAME H5P_exist_plist @@ -3071,7 +3196,7 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value) htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -3079,18 +3204,18 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) HDassert(name); /* Check for property in deleted property list */ - if(H5SL_search(plist->del, name) != NULL) + if (H5SL_search(plist->del, name) != NULL) ret_value = FALSE; else { /* Check for property in changed property list */ - if(H5SL_search(plist->props, name) != NULL) + if (H5SL_search(plist->props, name) != NULL) ret_value = TRUE; else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ tclass = plist->pclass; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) + while (tclass != NULL) { + if (H5SL_search(tclass->props, name) != NULL) HGOTO_DONE(TRUE) /* Go up to parent class */ @@ -3100,13 +3225,12 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) /* If we've reached here, we couldn't find the property */ ret_value = FALSE; } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_exist_plist() */ +} /* H5P_exist_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__exist_pclass @@ -3131,7 +3255,7 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) htri_t H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_PACKAGE_NOERR @@ -3139,14 +3263,14 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Check for property in property list */ - if(H5SL_search(pclass->props, name) != NULL) + if (H5SL_search(pclass->props, name) != NULL) ret_value = TRUE; else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ tclass = pclass->parent; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) + while (tclass != NULL) { + if (H5SL_search(tclass->props, name) != NULL) HGOTO_DONE(TRUE) /* Go up to parent class */ @@ -3159,9 +3283,8 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__exist_pclass() */ +} /* H5P__exist_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__get_size_plist @@ -3187,8 +3310,8 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -3197,7 +3320,7 @@ H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) HDassert(size); /* Find property */ - if(NULL == (prop = H5P__find_prop_plist(plist, name))) + if (NULL == (prop = H5P__find_prop_plist(plist, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Get property size */ @@ -3205,9 +3328,8 @@ H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_size_plist() */ +} /* H5P__get_size_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__get_size_pclass @@ -3233,8 +3355,8 @@ H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -3243,7 +3365,7 @@ H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) HDassert(size); /* Find property */ - if((prop = H5P__find_prop_pclass(pclass,name)) == NULL) + if ((prop = H5P__find_prop_pclass(pclass, name)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Get property size */ @@ -3251,9 +3373,8 @@ H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_size_pclass() */ +} /* H5P__get_size_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__get_nprops_plist @@ -3286,9 +3407,8 @@ H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops) *nprops = plist->nprops; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5P__get_nprops_plist() */ +} /* H5P__get_nprops_plist() */ - /*-------------------------------------------------------------------------- NAME H5P_get_nprops_pclass @@ -3313,7 +3433,7 @@ H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops) herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3324,17 +3444,16 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu *nprops = pclass->nprops; /* Check if the class is derived, and walk up the chain, if so */ - if(recurse) - while(pclass->parent != NULL) { - pclass = pclass->parent; - *nprops += pclass->nprops; - } /* end while */ + if (recurse) + while (pclass->parent != NULL) { + pclass = pclass->parent; + *nprops += pclass->nprops; + } /* end while */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get_nprops_pclass() */ +} /* H5P_get_nprops_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_prop @@ -3360,8 +3479,8 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu static int H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2) { - int cmp_value; /* Value from comparison */ - int ret_value = 0; /* return value */ + int cmp_value; /* Value from comparison */ + int ret_value = 0; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -3369,72 +3488,102 @@ H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2) HDassert(prop2); /* Check the name */ - if((cmp_value = HDstrcmp(prop1->name, prop2->name)) != 0) + if ((cmp_value = HDstrcmp(prop1->name, prop2->name)) != 0) HGOTO_DONE(cmp_value); /* Check the size of properties */ - if(prop1->size < prop2->size) HGOTO_DONE(-1); - if(prop1->size > prop2->size) HGOTO_DONE(1); + if (prop1->size < prop2->size) + HGOTO_DONE(-1); + if (prop1->size > prop2->size) + HGOTO_DONE(1); /* Check if they both have the same 'create' callback */ - if(prop1->create == NULL && prop2->create != NULL) HGOTO_DONE(-1); - if(prop1->create != NULL && prop2->create == NULL) HGOTO_DONE(1); - if(prop1->create != prop2->create) HGOTO_DONE(-1); + if (prop1->create == NULL && prop2->create != NULL) + HGOTO_DONE(-1); + if (prop1->create != NULL && prop2->create == NULL) + HGOTO_DONE(1); + if (prop1->create != prop2->create) + HGOTO_DONE(-1); /* Check if they both have the same 'set' callback */ - if(prop1->set == NULL && prop2->set != NULL) HGOTO_DONE(-1); - if(prop1->set != NULL && prop2->set == NULL) HGOTO_DONE(1); - if(prop1->set != prop2->set) HGOTO_DONE(-1); + if (prop1->set == NULL && prop2->set != NULL) + HGOTO_DONE(-1); + if (prop1->set != NULL && prop2->set == NULL) + HGOTO_DONE(1); + if (prop1->set != prop2->set) + HGOTO_DONE(-1); /* Check if they both have the same 'get' callback */ - if(prop1->get == NULL && prop2->get != NULL) HGOTO_DONE(-1); - if(prop1->get != NULL && prop2->get == NULL) HGOTO_DONE(1); - if(prop1->get != prop2->get) HGOTO_DONE(-1); + if (prop1->get == NULL && prop2->get != NULL) + HGOTO_DONE(-1); + if (prop1->get != NULL && prop2->get == NULL) + HGOTO_DONE(1); + if (prop1->get != prop2->get) + HGOTO_DONE(-1); /* Check if they both have the same 'encode' callback */ - if(prop1->encode == NULL && prop2->encode != NULL) HGOTO_DONE(-1); - if(prop1->encode != NULL && prop2->encode == NULL) HGOTO_DONE(1); - if(prop1->encode != prop2->encode) HGOTO_DONE(-1); + if (prop1->encode == NULL && prop2->encode != NULL) + HGOTO_DONE(-1); + if (prop1->encode != NULL && prop2->encode == NULL) + HGOTO_DONE(1); + if (prop1->encode != prop2->encode) + HGOTO_DONE(-1); /* Check if they both have the same 'decode' callback */ - if(prop1->decode == NULL && prop2->decode != NULL) HGOTO_DONE(-1); - if(prop1->decode != NULL && prop2->decode == NULL) HGOTO_DONE(1); - if(prop1->decode != prop2->decode) HGOTO_DONE(-1); + if (prop1->decode == NULL && prop2->decode != NULL) + HGOTO_DONE(-1); + if (prop1->decode != NULL && prop2->decode == NULL) + HGOTO_DONE(1); + if (prop1->decode != prop2->decode) + HGOTO_DONE(-1); /* Check if they both have the same 'delete' callback */ - if(prop1->del == NULL && prop2->del != NULL) HGOTO_DONE(-1); - if(prop1->del != NULL && prop2->del == NULL) HGOTO_DONE(1); - if(prop1->del != prop2->del) HGOTO_DONE(-1); + if (prop1->del == NULL && prop2->del != NULL) + HGOTO_DONE(-1); + if (prop1->del != NULL && prop2->del == NULL) + HGOTO_DONE(1); + if (prop1->del != prop2->del) + HGOTO_DONE(-1); /* Check if they both have the same 'copy' callback */ - if(prop1->copy == NULL && prop2->copy != NULL) HGOTO_DONE(-1); - if(prop1->copy != NULL && prop2->copy == NULL) HGOTO_DONE(1); - if(prop1->copy != prop2->copy) HGOTO_DONE(-1); + if (prop1->copy == NULL && prop2->copy != NULL) + HGOTO_DONE(-1); + if (prop1->copy != NULL && prop2->copy == NULL) + HGOTO_DONE(1); + if (prop1->copy != prop2->copy) + HGOTO_DONE(-1); /* Check if they both have the same 'compare' callback */ - if(prop1->cmp == NULL && prop2->cmp != NULL) HGOTO_DONE(-1); - if(prop1->cmp != NULL && prop2->cmp == NULL) HGOTO_DONE(1); - if(prop1->cmp != prop2->cmp) HGOTO_DONE(-1); + if (prop1->cmp == NULL && prop2->cmp != NULL) + HGOTO_DONE(-1); + if (prop1->cmp != NULL && prop2->cmp == NULL) + HGOTO_DONE(1); + if (prop1->cmp != prop2->cmp) + HGOTO_DONE(-1); /* Check if they both have the same 'close' callback */ - if(prop1->close == NULL && prop2->close != NULL) HGOTO_DONE(-1); - if(prop1->close != NULL && prop2->close == NULL) HGOTO_DONE(1); - if(prop1->close != prop2->close) HGOTO_DONE(-1); + if (prop1->close == NULL && prop2->close != NULL) + HGOTO_DONE(-1); + if (prop1->close != NULL && prop2->close == NULL) + HGOTO_DONE(1); + if (prop1->close != prop2->close) + HGOTO_DONE(-1); /* Check if they both have values allocated (or not allocated) */ - if(prop1->value == NULL && prop2->value != NULL) HGOTO_DONE(-1); - if(prop1->value != NULL && prop2->value == NULL) HGOTO_DONE(1); - if(prop1->value != NULL) { + if (prop1->value == NULL && prop2->value != NULL) + HGOTO_DONE(-1); + if (prop1->value != NULL && prop2->value == NULL) + HGOTO_DONE(1); + if (prop1->value != NULL) { /* Call comparison routine */ - if((cmp_value = prop1->cmp(prop1->value, prop2->value, prop1->size)) != 0) + if ((cmp_value = prop1->cmp(prop1->value, prop2->value, prop1->size)) != 0) HGOTO_DONE(cmp_value); } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_prop() */ +} /* H5P__cmp_prop() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_class @@ -3460,9 +3609,9 @@ H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2) int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { - H5SL_node_t *tnode1, *tnode2; /* Temporary pointer to property nodes */ - int cmp_value; /* Value from comparison */ - int ret_value = 0; /* Return value */ + H5SL_node_t *tnode1, *tnode2; /* Temporary pointer to property nodes */ + int cmp_value; /* Value from comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -3470,65 +3619,89 @@ H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) HDassert(pclass2); /* Use the revision number to quickly check for identical classes */ - if(pclass1->revision == pclass2->revision) + if (pclass1->revision == pclass2->revision) HGOTO_DONE(0); /* Check the name */ - if((cmp_value = HDstrcmp(pclass1->name, pclass2->name)) != 0) + if ((cmp_value = HDstrcmp(pclass1->name, pclass2->name)) != 0) HGOTO_DONE(cmp_value); /* Check the number of properties */ - if(pclass1->nprops < pclass2->nprops) HGOTO_DONE(-1); - if(pclass1->nprops > pclass2->nprops) HGOTO_DONE(1); + if (pclass1->nprops < pclass2->nprops) + HGOTO_DONE(-1); + if (pclass1->nprops > pclass2->nprops) + HGOTO_DONE(1); /* Check the number of property lists created from the class */ - if(pclass1->plists < pclass2->plists) HGOTO_DONE(-1); - if(pclass1->plists > pclass2->plists) HGOTO_DONE(1); + if (pclass1->plists < pclass2->plists) + HGOTO_DONE(-1); + if (pclass1->plists > pclass2->plists) + HGOTO_DONE(1); /* Check the number of classes derived from the class */ - if(pclass1->classes < pclass2->classes) HGOTO_DONE(-1); - if(pclass1->classes > pclass2->classes) HGOTO_DONE(1); + if (pclass1->classes < pclass2->classes) + HGOTO_DONE(-1); + if (pclass1->classes > pclass2->classes) + HGOTO_DONE(1); /* Check the number of ID references open on the class */ - if(pclass1->ref_count < pclass2->ref_count) HGOTO_DONE(-1); - if(pclass1->ref_count > pclass2->ref_count) HGOTO_DONE(1); + if (pclass1->ref_count < pclass2->ref_count) + HGOTO_DONE(-1); + if (pclass1->ref_count > pclass2->ref_count) + HGOTO_DONE(1); /* Check the property list types */ - if(pclass1->type < pclass2->type) HGOTO_DONE(-1); - if(pclass1->type > pclass2->type) HGOTO_DONE(1); + if (pclass1->type < pclass2->type) + HGOTO_DONE(-1); + if (pclass1->type > pclass2->type) + HGOTO_DONE(1); /* Check whether they are deleted or not */ - if(pclass1->deleted < pclass2->deleted) HGOTO_DONE(-1); - if(pclass1->deleted > pclass2->deleted) HGOTO_DONE(1); + if (pclass1->deleted < pclass2->deleted) + HGOTO_DONE(-1); + if (pclass1->deleted > pclass2->deleted) + HGOTO_DONE(1); /* Check whether they have creation callback functions & data */ - if(pclass1->create_func == NULL && pclass2->create_func != NULL) HGOTO_DONE(-1); - if(pclass1->create_func != NULL && pclass2->create_func == NULL) HGOTO_DONE(1); - if(pclass1->create_func != pclass2->create_func) HGOTO_DONE(-1); - if(pclass1->create_data < pclass2->create_data) HGOTO_DONE(-1); - if(pclass1->create_data > pclass2->create_data) HGOTO_DONE(1); + if (pclass1->create_func == NULL && pclass2->create_func != NULL) + HGOTO_DONE(-1); + if (pclass1->create_func != NULL && pclass2->create_func == NULL) + HGOTO_DONE(1); + if (pclass1->create_func != pclass2->create_func) + HGOTO_DONE(-1); + if (pclass1->create_data < pclass2->create_data) + HGOTO_DONE(-1); + if (pclass1->create_data > pclass2->create_data) + HGOTO_DONE(1); /* Check whether they have close callback functions & data */ - if(pclass1->close_func == NULL && pclass2->close_func != NULL) HGOTO_DONE(-1); - if(pclass1->close_func != NULL && pclass2->close_func == NULL) HGOTO_DONE(1); - if(pclass1->close_func != pclass2->close_func) HGOTO_DONE(-1); - if(pclass1->close_data < pclass2->close_data) HGOTO_DONE(-1); - if(pclass1->close_data > pclass2->close_data) HGOTO_DONE(1); + if (pclass1->close_func == NULL && pclass2->close_func != NULL) + HGOTO_DONE(-1); + if (pclass1->close_func != NULL && pclass2->close_func == NULL) + HGOTO_DONE(1); + if (pclass1->close_func != pclass2->close_func) + HGOTO_DONE(-1); + if (pclass1->close_data < pclass2->close_data) + HGOTO_DONE(-1); + if (pclass1->close_data > pclass2->close_data) + HGOTO_DONE(1); /* Cycle through the properties and compare them also */ tnode1 = H5SL_first(pclass1->props); tnode2 = H5SL_first(pclass2->props); - while(tnode1 || tnode2) { - H5P_genprop_t *prop1, *prop2; /* Property for node */ + while (tnode1 || tnode2) { + H5P_genprop_t *prop1, *prop2; /* Property for node */ /* Check if they both have properties in this skip list node */ - if(tnode1 == NULL && tnode2 != NULL) HGOTO_DONE(-1); - if(tnode1 != NULL && tnode2 == NULL) HGOTO_DONE(1); + if (tnode1 == NULL && tnode2 != NULL) + HGOTO_DONE(-1); + if (tnode1 != NULL && tnode2 == NULL) + HGOTO_DONE(1); /* Compare the two properties */ prop1 = (H5P_genprop_t *)H5SL_item(tnode1); prop2 = (H5P_genprop_t *)H5SL_item(tnode2); - if((cmp_value = H5P__cmp_prop(prop1, prop2)) != 0) + if ((cmp_value = H5P__cmp_prop(prop1, prop2)) != 0) HGOTO_DONE(cmp_value); /* Advance the pointers */ @@ -3538,9 +3711,8 @@ H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_class() */ +} /* H5P__cmp_class() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_plist_cb @@ -3567,9 +3739,9 @@ H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) static int H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) { - H5P_plist_cmp_ud_t *udata = (H5P_plist_cmp_ud_t *)_udata; /* Pointer to user data */ - htri_t prop2_exist; /* Whether the property exists in the second property list */ - int ret_value = H5_ITER_CONT; /* Return value */ + H5P_plist_cmp_ud_t *udata = (H5P_plist_cmp_ud_t *)_udata; /* Pointer to user data */ + htri_t prop2_exist; /* Whether the property exists in the second property list */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -3578,17 +3750,17 @@ H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) HDassert(udata); /* Check if the property exists in the second property list */ - if((prop2_exist = H5P_exist_plist(udata->plist2, prop->name)) < 0) + 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?") - if(prop2_exist) { - const H5P_genprop_t *prop2; /* Pointer to property in second plist */ + if (prop2_exist) { + const H5P_genprop_t *prop2; /* Pointer to property in second plist */ /* Look up same property in second property list */ - if(NULL == (prop2 = H5P__find_prop_plist(udata->plist2, prop->name))) + if (NULL == (prop2 = H5P__find_prop_plist(udata->plist2, prop->name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5_ITER_ERROR, "property doesn't exist") /* Compare the two properties */ - if((udata->cmp_value = H5P__cmp_prop(prop, prop2)) != 0) + if ((udata->cmp_value = H5P__cmp_prop(prop, prop2)) != 0) HGOTO_DONE(H5_ITER_STOP); } /* end if */ else { @@ -3601,7 +3773,6 @@ H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__cmp_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__cmp_plist @@ -3627,12 +3798,11 @@ H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, - int *cmp_ret) +H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, int *cmp_ret) { - H5P_plist_cmp_ud_t udata; /* User data for callback */ - int idx = 0; /* Index of property to begin with */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_plist_cmp_ud_t udata; /* User data for callback */ + int idx = 0; /* Index of property to begin with */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3641,39 +3811,39 @@ H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, HDassert(cmp_ret); /* Check the number of properties */ - if(plist1->nprops < plist2->nprops) { + if (plist1->nprops < plist2->nprops) { *cmp_ret = -1; HGOTO_DONE(SUCCEED); } /* end if */ - if(plist1->nprops > plist2->nprops) { + if (plist1->nprops > plist2->nprops) { *cmp_ret = 1; HGOTO_DONE(SUCCEED); } /* end if */ /* Check whether they've been initialized */ - if(plist1->class_init < plist2->class_init) { + if (plist1->class_init < plist2->class_init) { *cmp_ret = -1; HGOTO_DONE(SUCCEED); } /* end if */ - if(plist1->class_init > plist2->class_init) { + if (plist1->class_init > plist2->class_init) { *cmp_ret = 1; HGOTO_DONE(SUCCEED); } /* end if */ /* Set up iterator callback info */ udata.cmp_value = 0; - udata.plist2 = plist2; + udata.plist2 = plist2; /* Iterate over properties in first property list */ - if((ret_value = H5P__iterate_plist(plist1, TRUE, &idx, H5P__cmp_plist_cb, &udata)) < 0) + if ((ret_value = H5P__iterate_plist(plist1, TRUE, &idx, H5P__cmp_plist_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list") - if(ret_value != 0) { + if (ret_value != 0) { *cmp_ret = udata.cmp_value; HGOTO_DONE(SUCCEED); } /* end if */ /* Check the parent classes */ - if((*cmp_ret = H5P__cmp_class(plist1->pclass, plist2->pclass)) != 0) + if ((*cmp_ret = H5P__cmp_class(plist1->pclass, plist2->pclass)) != 0) HGOTO_DONE(SUCCEED); /* Property lists must be equal, set comparison value to 0 */ @@ -3681,9 +3851,8 @@ H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__cmp_plist() */ +} /* H5P__cmp_plist() */ - /*-------------------------------------------------------------------------- NAME H5P_class_isa @@ -3710,7 +3879,7 @@ H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3718,11 +3887,12 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) HDassert(pclass2); /* Compare property classes */ - if(H5P__cmp_class(pclass1, pclass2) == 0) { + if (H5P__cmp_class(pclass1, pclass2) == 0) { HGOTO_DONE(TRUE); - } else { + } + else { /* Check if the class is derived, and walk up the chain, if so */ - if(pclass1->parent != NULL) + if (pclass1->parent != NULL) ret_value = H5P_class_isa(pclass1->parent, pclass2); else HGOTO_DONE(FALSE); @@ -3730,9 +3900,8 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_class_isa() */ +} /* H5P_class_isa() */ - /*-------------------------------------------------------------------------- NAME H5P_isa_class @@ -3761,27 +3930,26 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id) { - H5P_genplist_t *plist; /* Property list to query */ - H5P_genclass_t *pclass; /* Property list class */ - htri_t ret_value = FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list to query */ + H5P_genclass_t *pclass; /* Property list class */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments. */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class") /* Compare the property list's class against the other class */ - if((ret_value = H5P_class_isa(plist->pclass, pclass)) < 0) + if ((ret_value = H5P_class_isa(plist->pclass, pclass)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_isa_class() */ +} /* H5P_isa_class() */ - /*-------------------------------------------------------------------------- NAME H5P_object_verify @@ -3813,23 +3981,22 @@ H5P_isa_class(hid_t plist_id, hid_t pclass_id) H5P_genplist_t * H5P_object_verify(hid_t plist_id, hid_t pclass_id) { - H5P_genplist_t *ret_value = NULL; /* Return value */ + H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Compare the property list's class against the other class */ - if(H5P_isa_class(plist_id, pclass_id) != TRUE) + if (H5P_isa_class(plist_id, pclass_id) != TRUE) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, NULL, "property list is not a member of the class") /* Get the plist structure */ - if(NULL == (ret_value = (H5P_genplist_t *)H5I_object(plist_id))) + if (NULL == (ret_value = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_object_verify() */ +} /* H5P_object_verify() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist_cb @@ -3853,10 +4020,10 @@ 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_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -3865,10 +4032,10 @@ H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) HDassert(key); /* Check if we've found the correctly indexed property */ - if(*udata->curr_idx_ptr >= udata->prev_idx) { + if (*udata->curr_idx_ptr >= udata->prev_idx) { /* Call the callback function */ ret_value = (*udata->cb_func)(item, udata->udata); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); } /* end if */ @@ -3876,14 +4043,13 @@ H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) (*udata->curr_idx_ptr)++; /* Add property name to 'seen' list */ - if(H5SL_insert(udata->seen, key, key) < 0) + if (H5SL_insert(udata->seen, key, key) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert property into 'seen' skip list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist_pclass_cb @@ -3907,10 +4073,10 @@ 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_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ - int ret_value = H5_ITER_CONT; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -3921,14 +4087,12 @@ H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) /* Only call iterator callback for properties we haven't seen * before and that haven't been deleted. */ - if(NULL == H5SL_search(udata->seen, key) && - NULL == H5SL_search(udata->plist->del, key)) + if (NULL == H5SL_search(udata->seen, key) && NULL == H5SL_search(udata->plist->del, key)) ret_value = H5P__iterate_plist_cb(item, key, udata); FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_plist_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_plist @@ -3984,14 +4148,14 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ 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__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 */ - int curr_idx = 0; /* Current iteration index */ - int ret_value = 0; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -4001,50 +4165,49 @@ H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, HDassert(cb_func); /* Create the skip list to hold names of properties already seen */ - if(NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) + if (NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") /* Set up iterator callback info */ - udata_int.plist = plist; - udata_int.cb_func = cb_func; - udata_int.udata = udata; - udata_int.seen = seen; + udata_int.plist = plist; + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.seen = seen; udata_int.curr_idx_ptr = &curr_idx; - udata_int.prev_idx = *idx; + udata_int.prev_idx = *idx; /* Iterate over properties in property list proper */ /* (Will be only the non-default (i.e. changed) properties) */ ret_value = H5SL_iterate(plist->props, H5P__iterate_plist_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); /* Check for iterating over all properties, or just non-default ones */ - if(iter_all_prop) { + if (iter_all_prop) { /* Walk up the class hierarchy */ tclass = plist->pclass; - while(tclass != NULL) { + while (tclass != NULL) { /* Iterate over properties in property list class */ ret_value = H5SL_iterate(tclass->props, H5P__iterate_plist_pclass_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end if */ + } /* end if */ done: /* Set the index we stopped at */ *idx = curr_idx; /* Release the skip list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__iterate_plist() */ +} /* H5P__iterate_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_pclass_cb @@ -4069,9 +4232,9 @@ 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_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ - int ret_value = 0; /* Return value */ + 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 */ FUNC_ENTER_STATIC_NOERR @@ -4080,10 +4243,10 @@ H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_uda HDassert((char *)_key); /* Check if we've found the correctly indexed property */ - if(*udata->curr_idx_ptr >= udata->prev_idx) { + if (*udata->curr_idx_ptr >= udata->prev_idx) { /* Call the callback function */ ret_value = (*udata->cb_func)(item, udata->udata); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); } /* end if */ @@ -4094,7 +4257,6 @@ H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_uda FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__iterate_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__iterate_pclass @@ -4147,12 +4309,11 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, - H5P_iterate_int_t cb_func, void *udata) +H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, H5P_iterate_int_t cb_func, void *udata) { - H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ - int curr_idx = 0; /* Current iteration index */ - int ret_value = 0; /* Return value */ + H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ + int curr_idx = 0; /* Current iteration index */ + int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -4162,14 +4323,14 @@ H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, HDassert(cb_func); /* Set up iterator callback info */ - udata_int.cb_func = cb_func; - udata_int.udata = udata; + udata_int.cb_func = cb_func; + udata_int.udata = udata; udata_int.curr_idx_ptr = &curr_idx; - udata_int.prev_idx = *idx; + udata_int.prev_idx = *idx; /* Iterate over properties in property list class proper */ ret_value = H5SL_iterate(pclass->props, H5P__iterate_pclass_cb, &udata_int); - if(ret_value != 0) + if (ret_value != 0) HGOTO_DONE(ret_value); done: @@ -4177,9 +4338,8 @@ H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, *idx = curr_idx; FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__iterate_pclass() */ +} /* H5P__iterate_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__peek_cb @@ -4204,10 +4364,10 @@ H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, --------------------------------------------------------------------------*/ static herr_t H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDEBUG_UNUSED *name, - H5P_genprop_t *prop, void *_udata) + H5P_genprop_t *prop, void *_udata) { - H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4217,7 +4377,7 @@ H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDE HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a (shallow) copy of the value */ @@ -4225,9 +4385,8 @@ H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDE done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__peek_cb() */ +} /* H5P__peek_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_peek @@ -4255,8 +4414,8 @@ H5P__peek_cb(H5P_genplist_t H5_ATTR_NDEBUG_UNUSED *plist, const char H5_ATTR_NDE herr_t H5P_peek(H5P_genplist_t *plist, const char *name, void *value) { - H5P_prop_get_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4267,14 +4426,13 @@ H5P_peek(H5P_genplist_t *plist, const char *name, void *value) /* Find the property and peek at the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__peek_cb, H5P__peek_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__peek_cb, H5P__peek_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to peek at value") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_peek() */ - /*-------------------------------------------------------------------------- NAME H5P__get_cb @@ -4298,12 +4456,11 @@ H5P_peek(H5P_genplist_t *plist, const char *name, void *value) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void *_udata) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + void * tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4313,18 +4470,18 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Check for property size >0 */ - if(0 == prop->size) + if (0 == prop->size) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Call the 'get' callback, if there is one */ - if(NULL != prop->get) { + if (NULL != prop->get) { /* Make a copy of the current value, in case the callback fails */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) + if (NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ - if((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") /* Copy new [possibly unchanged] value into return value */ @@ -4336,13 +4493,12 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_cb() */ +} /* H5P__get_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_get @@ -4374,8 +4530,8 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value) { - H5P_prop_get_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4386,14 +4542,13 @@ H5P_get(H5P_genplist_t *plist, const char *name, void *value) /* Find the property and get the value */ udata.value = value; - if(H5P__do_prop(plist, name, H5P__get_cb, H5P__get_cb, &udata) < 0) + if (H5P__do_prop(plist, name, H5P__get_cb, H5P__get_cb, &udata) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to get value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get() */ +} /* H5P_get() */ - /*-------------------------------------------------------------------------- NAME H5P__del_plist_cb @@ -4416,10 +4571,9 @@ H5P_get(H5P_genplist_t *plist, const char *name, void *value) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void H5_ATTR_UNUSED *_udata) +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 @@ -4430,22 +4584,22 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Pass value to 'close' callback, if it exists */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Call user's callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ - if(NULL == (del_name = H5MM_xstrdup(name))) + if (NULL == (del_name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(plist->del, del_name, del_name) < 0) + if (H5SL_insert(plist->del, del_name, del_name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") /* Remove the property from the skip list */ - if(NULL == H5SL_remove(plist->props, prop->name)) + if (NULL == H5SL_remove(plist->props, prop->name)) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from skip list") /* Free the property, ignoring return value, nothing we can do */ @@ -4456,14 +4610,13 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Error cleanup */ - if(ret_value < 0) - if(del_name) + if (ret_value < 0) + if (del_name) H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__del_plist_cb() */ +} /* H5P__del_plist_cb() */ - /*-------------------------------------------------------------------------- NAME H5P__del_pclass_cb @@ -4486,11 +4639,10 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, - void H5_ATTR_UNUSED *_udata) +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 @@ -4501,23 +4653,24 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HDassert(prop); /* Pass value to 'del' callback, if it exists */ - if(NULL != prop->del) { + if (NULL != prop->del) { /* Allocate space for a temporary copy of the property value */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") + if (NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, + "memory allocation failed for temporary property value") H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ - if((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) + if ((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value") } /* end if */ /* Duplicate string for insertion into new deleted property skip list */ - if(NULL == (del_name = H5MM_xstrdup(name))) + if (NULL == (del_name = H5MM_xstrdup(name))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Insert property name into deleted list */ - if(H5SL_insert(plist->del, del_name, del_name) < 0) + if (H5SL_insert(plist->del, del_name, del_name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") /* Decrement the number of properties in list */ @@ -4525,18 +4678,17 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, done: /* Free the temporary value buffer */ - if(tmp_value) + if (tmp_value) H5MM_xfree(tmp_value); /* Error cleanup */ - if(ret_value < 0) - if(del_name) + if (ret_value < 0) + if (del_name) H5MM_xfree(del_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__del_pclass_cb() */ +} /* H5P__del_pclass_cb() */ - /*-------------------------------------------------------------------------- NAME H5P_remove @@ -4566,7 +4718,7 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, herr_t H5P_remove(H5P_genplist_t *plist, const char *name) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4575,14 +4727,13 @@ H5P_remove(H5P_genplist_t *plist, const char *name) HDassert(name); /* Find the property and get the value */ - if(H5P__do_prop(plist, name, H5P__del_plist_cb, H5P__del_pclass_cb, NULL) < 0) + if (H5P__do_prop(plist, name, H5P__del_plist_cb, H5P__del_pclass_cb, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to remove value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_remove() */ +} /* H5P_remove() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_prop_plist @@ -4617,42 +4768,43 @@ H5P_remove(H5P_genplist_t *plist, const char *name) herr_t 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 */ - herr_t ret_value=SUCCEED; /* return value */ + 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE HDassert(name); /* Get the objects to operate on */ - if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_id)) || NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_id))) + if (NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_id)) || + 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(NULL != H5P__find_prop_plist(dst_plist, name)) { + 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) + if (H5P_remove(dst_plist, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Get the pointer to the source property */ prop = H5P__find_prop_plist(src_plist, name); /* Make a copy of the source property */ - if((new_prop = H5P__dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property") + if ((new_prop = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Call property copy callback, if it exists */ - if(new_prop->copy) { - if((new_prop->copy)(new_prop->name,new_prop->size,new_prop->value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property") + if (new_prop->copy) { + if ((new_prop->copy)(new_prop->name, new_prop->size, new_prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") } /* end if */ /* Insert the initialized property into the property list */ - if(H5P__add_prop(dst_plist->props,new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into list") + if (H5P__add_prop(dst_plist->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into list") /* Increment the number of properties in list */ dst_plist->nprops++; @@ -4663,20 +4815,21 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) prop = H5P__find_prop_plist(src_plist, name); /* Create property object from parameters */ - if(NULL == (new_prop = H5P__create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, - prop->create, prop->set, prop->get, prop->encode, prop->decode, - prop->del, prop->copy, prop->cmp, prop->close))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") + if (NULL == + (new_prop = H5P__create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, + prop->create, prop->set, prop->get, prop->encode, prop->decode, + prop->del, prop->copy, prop->cmp, prop->close))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "Can't create property") /* Call property creation callback, if it exists */ - if(new_prop->create) { - if((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property") + if (new_prop->create) { + if ((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Can't initialize property") } /* end if */ /* Insert property into property list class */ - if(H5P__add_prop(dst_plist->props, new_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") + if (H5P__add_prop(dst_plist->props, new_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into class") /* Increment property count for class */ dst_plist->nprops++; @@ -4684,15 +4837,14 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) done: /* Cleanup, if necessary */ - if(ret_value < 0) { - if(new_prop != NULL) + if (ret_value < 0) { + if (new_prop != NULL) H5P__free_prop(new_prop); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_prop_plist() */ +} /* H5P__copy_prop_plist() */ - /*-------------------------------------------------------------------------- NAME H5P__copy_prop_pclass @@ -4725,11 +4877,11 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) herr_t 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 */ - herr_t ret_value = SUCCEED; /* return value */ + 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -4737,49 +4889,49 @@ H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) HDassert(name); /* Get property list classes */ - if(NULL == (src_pclass = (H5P_genclass_t *)H5I_object(src_id))) + if (NULL == (src_pclass = (H5P_genclass_t *)H5I_object(src_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "source property class object doesn't exist") - if(NULL == (dst_pclass = (H5P_genclass_t *)H5I_object(dst_id))) + if (NULL == (dst_pclass = (H5P_genclass_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "destination property class object doesn't exist") /* Get the property from the source */ - if(NULL == (prop = H5P__find_prop_pclass(src_pclass, name))) + if (NULL == (prop = H5P__find_prop_pclass(src_pclass, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to locate property") /* If the property exists in the destination already */ - if(H5P__exist_pclass(dst_pclass, name)) { + if (H5P__exist_pclass(dst_pclass, name)) { /* Delete the old property from the destination class */ - if(H5P__unregister(dst_pclass, name) < 0) + if (H5P__unregister(dst_pclass, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") } /* end if */ /* Register the property into the destination */ orig_dst_pclass = dst_pclass; - if(H5P__register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, - prop->encode, prop->decode, prop->del, prop->copy, prop->cmp, prop->close) < 0) + if (H5P__register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, + prop->encode, prop->decode, prop->del, prop->copy, prop->cmp, prop->close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Check if the property class changed and needs to be substituted in the ID */ - if(dst_pclass != orig_dst_pclass) { - H5P_genclass_t *old_dst_pclass; /* Old destination property class */ + if (dst_pclass != orig_dst_pclass) { + H5P_genclass_t *old_dst_pclass; /* Old destination property class */ /* Substitute the new destination property class in the ID */ - if(NULL == (old_dst_pclass = (H5P_genclass_t *)H5I_subst(dst_id, dst_pclass))) + if (NULL == (old_dst_pclass = (H5P_genclass_t *)H5I_subst(dst_id, dst_pclass))) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID") HDassert(old_dst_pclass == orig_dst_pclass); /* Close the previous class */ - if(H5P__close_class(old_dst_pclass) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "unable to close original property class after substitution") + if (H5P__close_class(old_dst_pclass) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, + "unable to close original property class after substitution") } /* end if */ done: /* Cleanup, if necessary */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__copy_prop_pclass() */ +} /* H5P__copy_prop_pclass() */ - /*-------------------------------------------------------------------------- NAME H5P__unregister @@ -4804,8 +4956,8 @@ H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) herr_t H5P__unregister(H5P_genclass_t *pclass, const char *name) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4813,12 +4965,12 @@ H5P__unregister(H5P_genclass_t *pclass, const char *name) HDassert(name); /* Get the property node from the skip list */ - if((prop = (H5P_genprop_t *)H5SL_search(pclass->props,name)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") + if ((prop = (H5P_genprop_t *)H5SL_search(pclass->props, name)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't find property in skip list") /* Remove the property from the skip list */ - if(H5SL_remove(pclass->props,prop->name) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from skip list") + if (H5SL_remove(pclass->props, prop->name) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from skip list") /* Free the property, ignoring return value, nothing we can do */ H5P__free_prop(prop); @@ -4831,9 +4983,8 @@ H5P__unregister(H5P_genclass_t *pclass, const char *name) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__unregister() */ +} /* H5P__unregister() */ - /*-------------------------------------------------------------------------- NAME H5P_close @@ -4861,16 +5012,16 @@ H5P__unregister(H5P_genclass_t *pclass, const char *name) herr_t 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 */ - 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 */ - unsigned make_cb=0; /* Operator data for property free callback */ - herr_t ret_value=SUCCEED; /* return value */ + 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 */ + 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 */ + unsigned make_cb = 0; /* Operator data for property free callback */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -4879,10 +5030,10 @@ H5P_close(void *_plist) /* Make call to property list class close callback, if needed * (up through chain of parent classes also) */ - if(plist->class_init) { + if (plist->class_init) { tclass = plist->pclass; - while(NULL != tclass) { - if(NULL != tclass->close_func) { + while (NULL != tclass) { + if (NULL != tclass->close_func) { /* Call user's "close" callback function, ignoring return value */ (tclass->close_func)(plist->plist_id, tclass->close_data); } /* end if */ @@ -4890,98 +5041,100 @@ H5P_close(void *_plist) /* Go up to parent class */ tclass = tclass->parent; } /* end while */ - } /* end if */ + } /* end if */ /* Create the skip list to hold names of properties already seen * (This prevents a property in the class hierarchy from having it's * 'close' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties") + if ((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") nseen = 0; /* Walk through the changed properties in the list */ - if(H5SL_count(plist->props)>0) { - curr_node=H5SL_first(plist->props); - while(curr_node!=NULL) { + if (H5SL_count(plist->props) > 0) { + curr_node = H5SL_first(plist->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Call property close callback, if it exists */ - if(tmp->close) { + if (tmp->close) { /* Call the 'close' callback */ - (tmp->close)(tmp->name,tmp->size,tmp->value); + (tmp->close)(tmp->name, tmp->size, tmp->value); } /* end if */ /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into seen skip list") nseen++; /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Determine number of deleted items from property list */ - ndel=H5SL_count(plist->del); + ndel = H5SL_count(plist->del); /* * Check if we should remove class properties (up through list of parent classes also), * initialize each with default value & make property 'remove' callback. */ - tclass=plist->pclass; + tclass = plist->pclass; has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0); - while(tclass!=NULL) { - if(tclass->nprops>0) { + while (tclass != NULL) { + if (tclass->nprops > 0) { /* Walk through the properties in the class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { + curr_node = H5SL_first(tclass->props); + while (curr_node != NULL) { /* Get pointer to property from node */ tmp = (H5P_genprop_t *)H5SL_item(curr_node); /* Only "delete" properties we haven't seen before * and that haven't already been deleted */ - if((nseen==0 || H5SL_search(seen,tmp->name) == NULL) && - (ndel==0 || H5SL_search(plist->del,tmp->name) == NULL)) { + if ((nseen == 0 || H5SL_search(seen, tmp->name) == NULL) && + (ndel == 0 || H5SL_search(plist->del, tmp->name) == NULL)) { /* Call property close callback, if it exists */ - if(tmp->close) { - void *tmp_value; /* Temporary value buffer */ + if (tmp->close) { + void *tmp_value; /* Temporary value buffer */ /* Allocate space for a temporary copy of the property value */ - if(NULL==(tmp_value=H5MM_malloc(tmp->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value") - H5MM_memcpy(tmp_value,tmp->value,tmp->size); + if (NULL == (tmp_value = H5MM_malloc(tmp->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for temporary property value") + H5MM_memcpy(tmp_value, tmp->value, tmp->size); /* Call the 'close' callback */ - (tmp->close)(tmp->name,tmp->size,tmp_value); + (tmp->close)(tmp->name, tmp->size, tmp_value); /* Release the temporary value buffer */ H5MM_xfree(tmp_value); } /* end if */ /* Add property name to "seen" list, if we have other classes to work on */ - if(has_parent_class) { - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") + if (has_parent_class) { + if (H5SL_insert(seen, tmp->name, tmp->name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, + "can't insert property into seen skip list") nseen++; } /* end if */ - } /* end if */ + } /* end if */ /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ - } /* end if */ + } /* end if */ /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ /* Decrement class's dependent property list value! */ - if(H5P__access_class(plist->pclass,H5P_MOD_DEC_LST) < 0) + if (H5P__access_class(plist->pclass, H5P_MOD_DEC_LST) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "Can't decrement class ref count") /* Free the list of 'seen' properties */ @@ -4999,13 +5152,12 @@ H5P_close(void *_plist) done: /* Release the skip list of 'seen' properties */ - if(seen != NULL) + if (seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_close() */ +} /* H5P_close() */ - /*-------------------------------------------------------------------------- NAME H5P_get_class_name @@ -5029,20 +5181,19 @@ H5P_close(void *_plist) char * H5P_get_class_name(H5P_genclass_t *pclass) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(pclass); /* Get class name */ - ret_value=H5MM_xstrdup(pclass->name); + ret_value = H5MM_xstrdup(pclass->name); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get_class_name() */ +} /* H5P_get_class_name() */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_path @@ -5067,26 +5218,27 @@ H5P_get_class_name(H5P_genclass_t *pclass) char * H5P__get_class_path(H5P_genclass_t *pclass) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE HDassert(pclass); /* Recursively build the full path */ - if(pclass->parent != NULL) { - char *par_path; /* Parent class's full path */ + if (pclass->parent != NULL) { + char *par_path; /* Parent class's full path */ /* Get the parent class's path */ par_path = H5P__get_class_path(pclass->parent); - if(par_path != NULL) { + if (par_path != NULL) { size_t ret_str_len; /* Allocate enough space for the parent class's path, plus the '/' * separator, this class's name and the string terminator */ - ret_str_len = HDstrlen(par_path) + HDstrlen(pclass->name) + 1 + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ - if(NULL == (ret_value = (char *)H5MM_malloc(ret_str_len))) + ret_str_len = HDstrlen(par_path) + HDstrlen(pclass->name) + 1 + + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == (ret_value = (char *)H5MM_malloc(ret_str_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name") /* Build the full path for this class */ @@ -5103,9 +5255,8 @@ H5P__get_class_path(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_path() */ +} /* H5P__get_class_path() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path @@ -5128,12 +5279,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 */ - H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ - H5P_genclass_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_PACKAGE @@ -5144,43 +5295,43 @@ H5P__open_class_path(const char *path) HDassert(tmp_path); /* Find the generic property class with this full path */ - curr_name = tmp_path; + curr_name = tmp_path; curr_class = NULL; - while(NULL != (delimit = HDstrchr(curr_name, '/'))) { + while (NULL != (delimit = HDstrchr(curr_name, '/'))) { /* Change the delimiter to terminate the string */ *delimit = '\0'; /* Set up the search structure */ - check_info.parent = curr_class; - check_info.name = curr_name; + check_info.parent = curr_class; + check_info.name = curr_name; check_info.new_class = NULL; /* Find the class with this name & parent by iterating over the open classes */ - if(H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) + if (H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, NULL, "can't iterate over classes") - else if(NULL == check_info.new_class) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") + else if (NULL == check_info.new_class) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") /* Advance the pointer in the path to the start of the next component */ curr_class = check_info.new_class; - curr_name = delimit + 1; + curr_name = delimit + 1; } /* end while */ /* Should be pointing to the last component in the path name now... */ /* Set up the search structure */ - check_info.parent = curr_class; - check_info.name = curr_name; + check_info.parent = curr_class; + check_info.name = curr_name; check_info.new_class = NULL; /* Find the class with this name & parent by iterating over the open classes */ - if(H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) + if (H5I_iterate(H5I_GENPROP_CLS, H5P__open_class_path_cb, &check_info, FALSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADITER, NULL, "can't iterate over classes") - else if(NULL == check_info.new_class) + else if (NULL == check_info.new_class) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class") /* Copy it */ - if(NULL == (ret_value = H5P__copy_pclass(check_info.new_class))) + if (NULL == (ret_value = H5P__copy_pclass(check_info.new_class))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "can't copy property class") done: @@ -5190,7 +5341,6 @@ H5P__open_class_path(const char *path) FUNC_LEAVE_NOAPI(ret_value) } /* H5P__open_class_path() */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_parent @@ -5213,7 +5363,7 @@ H5P__open_class_path(const char *path) H5P_genclass_t * H5P__get_class_parent(const H5P_genclass_t *pclass) { - H5P_genclass_t *ret_value = NULL; /* Return value */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -5223,9 +5373,8 @@ H5P__get_class_parent(const H5P_genclass_t *pclass) ret_value = pclass->parent; FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_parent() */ +} /* H5P__get_class_parent() */ - /*-------------------------------------------------------------------------- NAME H5P__close_class @@ -5246,22 +5395,21 @@ H5P__get_class_parent(const H5P_genclass_t *pclass) herr_t H5P__close_class(void *_pclass) { - H5P_genclass_t *pclass = (H5P_genclass_t *)_pclass; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genclass_t *pclass = (H5P_genclass_t *)_pclass; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(pclass); /* Decrement the reference count & check if the object should go away */ - if(H5P__access_class(pclass, H5P_MOD_DEC_REF) < 0) + if (H5P__access_class(pclass, H5P_MOD_DEC_REF) < 0) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't decrement ID ref count") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__close_class() */ +} /* H5P__close_class() */ - /*------------------------------------------------------------------------- * Function: H5P__new_plist_of_type * @@ -5278,24 +5426,25 @@ H5P__close_class(void *_pclass) hid_t H5P__new_plist_of_type(H5P_plist_type_t type) { - H5P_genclass_t *pclass; /* Class of property list to create */ - hid_t class_id; /* ID of class to create */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *pclass; /* Class of property list to create */ + hid_t class_id; /* ID of class to create */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity checks */ - HDcompile_assert(H5P_TYPE_ATTRIBUTE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); - HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_LINK_ACCESS); + HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); + HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_REFERENCE_ACCESS); /* Check arguments */ - if(type == H5P_TYPE_USER) + if (type == H5P_TYPE_USER) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, "can't create user property list"); - if(type == H5P_TYPE_ROOT) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, "shouldn't be creating root class property list"); + if (type == H5P_TYPE_ROOT) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, H5I_INVALID_HID, + "shouldn't be creating root class property list"); /* Instantiate a property list of the proper type */ - switch(type) { + switch (type) { case H5P_TYPE_OBJECT_CREATE: class_id = H5P_CLS_OBJECT_CREATE_ID_g; break; @@ -5340,6 +5489,14 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_DATATYPE_ACCESS_ID_g; break; + case H5P_TYPE_MAP_CREATE: + class_id = H5P_CLS_MAP_CREATE_ID_g; + break; + + case H5P_TYPE_MAP_ACCESS: + class_id = H5P_CLS_MAP_ACCESS_ID_g; + break; + case H5P_TYPE_STRING_CREATE: class_id = H5P_CLS_STRING_CREATE_ID_g; break; @@ -5364,7 +5521,15 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_LINK_ACCESS_ID_g; break; - case H5P_TYPE_USER: /* shut compiler warnings up */ + case H5P_TYPE_VOL_INITIALIZE: + class_id = H5P_CLS_VOL_INITIALIZE_ID_g; + break; + + case H5P_TYPE_REFERENCE_ACCESS: + class_id = H5P_CLS_REFERENCE_ACCESS_ID_g; + break; + + case H5P_TYPE_USER: /* shut compiler warnings up */ case H5P_TYPE_ROOT: case H5P_TYPE_MAX_TYPE: default: @@ -5372,18 +5537,17 @@ H5P__new_plist_of_type(H5P_plist_type_t type) } /* end switch */ /* Get the class object */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object(class_id))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object(class_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, H5I_INVALID_HID, "not a property class") /* Create the new property list */ - if((ret_value = H5P_create_id(pclass, TRUE)) < 0) + if ((ret_value = H5P_create_id(pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__new_plist_of_type() */ - /*------------------------------------------------------------------------- * Function: H5P_get_plist_id * @@ -5411,7 +5575,6 @@ H5P_get_plist_id(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->plist_id) } /* end H5P_get_plist_id() */ - /*------------------------------------------------------------------------- * Function: H5P_get_class * @@ -5439,32 +5602,19 @@ H5P_get_class(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->pclass) } /* end H5P_get_class() */ - /*------------------------------------------------------------------------- - * Function: H5P_get_default + * Function: H5P_ignore_cmp * - * Purpose: Get the default property list ID, for a property class. + * Purpose: Callback routine to ignore comparing property values. * - * Return: Success: Non-negative ID of property list. - * Failure: negative. - * - * Programmer: Quincey Koziol - * December 29, 2017 + * Return: zero * *------------------------------------------------------------------------- */ -hid_t -H5P_get_default(const H5P_libclass_t *libclass) +int +H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, size_t H5_ATTR_UNUSED size) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_NOAPI(H5I_INVALID_HID) - - HDassert(libclass); - - ret_value = *libclass->def_plist_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_get_default() */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_LEAVE_NOAPI(0) +} /* end H5P_ignore_cmp() */ diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 8a0848cc734..75fea42787a 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,19 +26,17 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -46,64 +44,64 @@ /* ======== Link access properties ======== */ /* Definitions for number of soft links to traverse */ -#define H5L_ACS_NLINKS_SIZE sizeof(size_t) -#define H5L_ACS_NLINKS_DEF H5L_NUM_LINKS /*max symlinks to follow per lookup */ -#define H5L_ACS_NLINKS_ENC H5P__encode_size_t -#define H5L_ACS_NLINKS_DEC H5P__decode_size_t - +#define H5L_ACS_NLINKS_SIZE sizeof(size_t) +#define H5L_ACS_NLINKS_DEF H5L_NUM_LINKS /*max symlinks to follow per lookup */ +#define H5L_ACS_NLINKS_ENC H5P__encode_size_t +#define H5L_ACS_NLINKS_DEC H5P__decode_size_t /* Definitions for external link prefix */ -#define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) -#define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ -#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set -#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get -#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc -#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec -#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del -#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy -#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp -#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close +#define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) +#define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ +#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set +#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get +#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc +#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec +#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del +#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy +#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp +#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close /* Definitions for setting fapl of external link access */ -#define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) -#define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT -#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set -#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get -#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc -#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec -#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del -#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy -#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp -#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close +#define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) +#define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT +#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set +#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get +#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc +#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec +#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del +#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy +#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp +#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close /* Definitions for file access flags for external link traversal */ -#define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) -#define H5L_ACS_ELINK_FLAGS_DEF H5F_ACC_DEFAULT -#define H5L_ACS_ELINK_FLAGS_ENC H5P__encode_unsigned -#define H5L_ACS_ELINK_FLAGS_DEC H5P__decode_unsigned +#define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) +#define H5L_ACS_ELINK_FLAGS_DEF H5F_ACC_DEFAULT +#define H5L_ACS_ELINK_FLAGS_ENC H5P__encode_unsigned +#define H5L_ACS_ELINK_FLAGS_DEC H5P__decode_unsigned /* Definitions for callback function for external link traversal */ -#define H5L_ACS_ELINK_CB_SIZE sizeof(H5L_elink_cb_t) -#define H5L_ACS_ELINK_CB_DEF {NULL,NULL} +#define H5L_ACS_ELINK_CB_SIZE sizeof(H5L_elink_cb_t) +#define H5L_ACS_ELINK_CB_DEF \ + { \ + NULL, NULL \ + } #ifdef H5_HAVE_PARALLEL /* Definition for reading metadata collectively */ -#define H5L_ACS_COLL_MD_READ_SIZE sizeof(H5P_coll_md_read_flag_t) -#define H5L_ACS_COLL_MD_READ_DEF H5P_USER_FALSE -#define H5L_ACS_COLL_MD_READ_ENC H5P__encode_coll_md_read_flag_t -#define H5L_ACS_COLL_MD_READ_DEC H5P__decode_coll_md_read_flag_t +#define H5L_ACS_COLL_MD_READ_SIZE sizeof(H5P_coll_md_read_flag_t) +#define H5L_ACS_COLL_MD_READ_DEF H5P_USER_FALSE +#define H5L_ACS_COLL_MD_READ_ENC H5P__encode_coll_md_read_flag_t +#define H5L_ACS_COLL_MD_READ_DEC H5P__decode_coll_md_read_flag_t #endif /* H5_HAVE_PARALLEL */ /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -112,23 +110,22 @@ static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass); /* Property list callbacks */ -static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t 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); -static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_pref_copy(const char* name, size_t size, void* value); -static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__lacc_elink_pref_close(const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_pref_copy(const char *name, size_t size, void *value); +static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_pref_close(const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t 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); -static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P__lacc_elink_fapl_copy(const char* name, size_t size, void* value); -static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* value); - +static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__lacc_elink_fapl_copy(const char *name, size_t size, void *value); +static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_fapl_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -136,44 +133,45 @@ static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* va /* Dataset creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_LACC[1] = {{ - "link access", /* Class name for debugging */ - H5P_TYPE_LINK_ACCESS, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ - &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__lacc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "link access", /* Class name for debugging */ + H5P_TYPE_LINK_ACCESS, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ + &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__lacc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* 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 = 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 = H5L_ACS_ELINK_FLAGS_DEF; /* Default file access flags for external link traversal */ -static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Default external link traversal callback */ +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 = + 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 = + H5L_ACS_ELINK_FLAGS_DEF; /* Default file access flags for external link traversal */ +static const H5L_elink_cb_t H5L_def_elink_cb_g = + H5L_ACS_ELINK_CB_DEF; /* Default external link traversal callback */ #ifdef H5_HAVE_PARALLEL -static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = H5L_ACS_COLL_MD_READ_DEF; /* Default setting for the collective metedata read flag */ -#endif /* H5_HAVE_PARALLEL */ +static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = + H5L_ACS_COLL_MD_READ_DEF; /* Default setting for the collective metedata read flag */ +#endif /* H5_HAVE_PARALLEL */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_reg_prop * @@ -189,45 +187,47 @@ static const H5P_coll_md_read_flag_t H5L_def_coll_md_read_g = H5L_ACS_COLL_MD_RE static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register property for number of links traversed */ - if(H5P__register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, - NULL, NULL, NULL, H5L_ACS_NLINKS_ENC, H5L_ACS_NLINKS_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, NULL, NULL, + NULL, H5L_ACS_NLINKS_ENC, H5L_ACS_NLINKS_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link prefix */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, &H5L_def_elink_prefix_g, - NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, - H5L_ACS_ELINK_PREFIX_DEL, H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, H5L_ACS_ELINK_PREFIX_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, + &H5L_def_elink_prefix_g, NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, + H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, H5L_ACS_ELINK_PREFIX_DEL, + H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, + H5L_ACS_ELINK_PREFIX_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register fapl for link access */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, - NULL, H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, - H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, NULL, + H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, + H5L_ACS_ELINK_FAPL_DEC, H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, + H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link file access flags */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_FLAGS_NAME, H5L_ACS_ELINK_FLAGS_SIZE, &H5L_def_elink_flags_g, - NULL, NULL, NULL, H5L_ACS_ELINK_FLAGS_ENC, H5L_ACS_ELINK_FLAGS_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_FLAGS_NAME, H5L_ACS_ELINK_FLAGS_SIZE, &H5L_def_elink_flags_g, + NULL, NULL, NULL, H5L_ACS_ELINK_FLAGS_ENC, H5L_ACS_ELINK_FLAGS_DEC, NULL, NULL, + NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external link file traversal callback */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5L_ACS_ELINK_CB_NAME, H5L_ACS_ELINK_CB_SIZE, &H5L_def_elink_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if (H5P__register_real(pclass, H5L_ACS_ELINK_CB_NAME, H5L_ACS_ELINK_CB_SIZE, &H5L_def_elink_cb_g, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_HAVE_PARALLEL /* Register the metadata collective read flag */ - if(H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5L_ACS_COLL_MD_READ_SIZE, &H5L_def_coll_md_read_g, - NULL, NULL, NULL, H5L_ACS_COLL_MD_READ_ENC, H5L_ACS_COLL_MD_READ_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5L_ACS_COLL_MD_READ_SIZE, + &H5L_def_coll_md_read_g, NULL, NULL, NULL, H5L_ACS_COLL_MD_READ_ENC, + H5L_ACS_COLL_MD_READ_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_HAVE_PARALLEL */ @@ -235,7 +235,6 @@ H5P__lacc_reg_prop(H5P_genclass_t *pclass) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_set * @@ -251,10 +250,10 @@ H5P__lacc_reg_prop(H5P_genclass_t *pclass) */ static herr_t H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -265,12 +264,12 @@ H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = *(const hid_t *)value; /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -278,7 +277,6 @@ H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_set() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_get * @@ -294,10 +292,10 @@ H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -308,12 +306,12 @@ H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = *(const hid_t *)value; /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -321,7 +319,6 @@ H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_get() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_enc * @@ -340,46 +337,46 @@ 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; - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for non-default FAPL */ - if(*elink_fapl != H5P_DEFAULT) { - if(NULL == (fapl_plist = (H5P_genplist_t *)H5P_object_verify(*elink_fapl, H5P_FILE_ACCESS))) + if (*elink_fapl != H5P_DEFAULT) { + if (NULL == (fapl_plist = (H5P_genplist_t *)H5P_object_verify(*elink_fapl, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property list") non_default_fapl = TRUE; } /* end if */ - if(NULL != *pp) { + if (NULL != *pp) { /* Store whether the FAPL is non-default */ *(*pp)++ = (uint8_t)non_default_fapl; } /* end if */ /* Encode the property list, if non-default */ /* (if *pp == NULL, will only compute the size) */ - if(non_default_fapl) { - if(H5P__encode(fapl_plist, TRUE, NULL, &fapl_size) < 0) + if (non_default_fapl) { + if (H5P__encode(fapl_plist, TRUE, NULL, &fapl_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "can't encode property list") - if(*pp) { + if (*pp) { uint64_t enc_value; unsigned enc_size; /* encode the length of the plist */ enc_value = (uint64_t)fapl_size; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the plist */ - if(H5P__encode(fapl_plist, TRUE, *pp, &fapl_size) < 0) + if (H5P__encode(fapl_plist, TRUE, *pp, &fapl_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "can't encode property list") *pp += fapl_size; @@ -387,13 +384,12 @@ H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) fapl_size += (1 + H5VM_limit_enc_size((uint64_t)fapl_size)); } /* end if */ - *size += (1 + fapl_size); /* Non-default flag, plus encoded property list size */ + *size += (1 + fapl_size); /* Non-default flag, plus encoded property list size */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_dec * @@ -412,10 +408,10 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -426,10 +422,10 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* Determine if the FAPL is non-default */ - non_default_fapl = (hbool_t)*(*pp)++; + non_default_fapl = (hbool_t) * (*pp)++; - if(non_default_fapl) { - size_t fapl_size = 0; /* Encoded size of property list */ + if (non_default_fapl) { + size_t fapl_size = 0; /* Encoded size of property list */ unsigned enc_size; uint64_t enc_value; @@ -440,7 +436,7 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) fapl_size = (size_t)enc_value; /* Decode the property list */ - if((*elink_fapl = H5P__decode(*pp)) < 0) + if ((*elink_fapl = H5P__decode(*pp)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, FAIL, "can't decode property") *pp += fapl_size; @@ -452,7 +448,6 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_dec() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_del * @@ -467,10 +462,11 @@ H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) *-------------------------------------------------------------------------- */ static herr_t -H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -481,14 +477,13 @@ H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED l_fapl_id = (*(const hid_t *)value); /* Close the FAPL */ - if(l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) + if (l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_copy * @@ -505,8 +500,8 @@ H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED static herr_t H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -517,12 +512,12 @@ H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED l_fapl_id = (*(const hid_t *)value); /* Duplicate the FAPL, if it's non-default */ - if(l_fapl_id != H5P_DEFAULT) { + if (l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; - if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + if (NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") - if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + if (((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ @@ -530,7 +525,6 @@ H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_cmp * @@ -548,25 +542,29 @@ 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; - H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ - int ret_value = 0; + 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; FUNC_ENTER_STATIC_NOERR /* Check for comparison with default value */ - if(*fapl1 == 0 && *fapl2 > 0) HGOTO_DONE(1); - if(*fapl1 > 0 && *fapl2 == 0) HGOTO_DONE(-1); + if (*fapl1 == 0 && *fapl2 > 0) + HGOTO_DONE(1); + if (*fapl1 > 0 && *fapl2 == 0) + HGOTO_DONE(-1); /* Get the property list objects */ obj1 = (H5P_genplist_t *)H5I_object(*fapl1); obj2 = (H5P_genplist_t *)H5I_object(*fapl2); /* Check for NULL property lists */ - if(obj1 == NULL && obj2 != NULL) HGOTO_DONE(1); - if(obj1 != NULL && obj2 == NULL) HGOTO_DONE(-1); - if(obj1 && obj2) { + if (obj1 == NULL && obj2 != NULL) + HGOTO_DONE(1); + if (obj1 != NULL && obj2 == NULL) + HGOTO_DONE(-1); + if (obj1 && obj2) { herr_t H5_ATTR_NDEBUG_UNUSED status; status = H5P__cmp_plist(obj1, obj2, &ret_value); @@ -577,7 +575,6 @@ H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_cmp() */ - /*-------------------------------------------------------------------------- * Function: H5P__lacc_elink_fapl_close * @@ -594,8 +591,8 @@ H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_ static herr_t H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -606,14 +603,13 @@ H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE l_fapl_id = (*(const hid_t *)value); /* Close the FAPL */ - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + if ((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_fapl_close() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_set * @@ -629,7 +625,7 @@ H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE */ static herr_t H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -642,7 +638,6 @@ H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_set() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_get * @@ -658,7 +653,7 @@ H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ static herr_t H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -671,7 +666,6 @@ H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_get() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_enc * @@ -690,44 +684,43 @@ H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED 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; - size_t len = 0; - uint64_t enc_value; - unsigned enc_size; + const char *elink_pref = *(const char *const *)value; + uint8_t ** pp = (uint8_t **)_pp; + size_t len = 0; + uint64_t enc_value; + unsigned enc_size; FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); /* calculate prefix length */ - if(NULL != elink_pref) + if (NULL != elink_pref) len = HDstrlen(elink_pref); enc_value = (uint64_t)len; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); - if(NULL != *pp) { + if (NULL != *pp) { /* encode the length of the prefix */ *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode the prefix */ - if(NULL != elink_pref) { + if (NULL != elink_pref) { H5MM_memcpy(*(char **)pp, elink_pref, len); *pp += len; } /* end if */ - } /* end if */ + } /* end if */ *size += (1 + enc_size); - if(NULL != elink_pref) + if (NULL != elink_pref) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_dec * @@ -746,12 +739,12 @@ 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; - const uint8_t **pp = (const uint8_t **)_pp; - size_t len; - uint64_t enc_value; /* Decoded property value */ - unsigned enc_size; /* Size of encoded property */ - herr_t ret_value = SUCCEED; + char ** elink_pref = (char **)_value; + const uint8_t **pp = (const uint8_t **)_pp; + size_t len; + uint64_t enc_value; /* Decoded property value */ + unsigned enc_size; /* Size of encoded property */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -768,9 +761,9 @@ H5P__lacc_elink_pref_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); len = (size_t)enc_value; - if(0 != len) { + if (0 != len) { /* Make a copy of the user's prefix string */ - if(NULL == (*elink_pref = (char *)H5MM_malloc(len + 1))) + if (NULL == (*elink_pref = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix") HDstrncpy(*elink_pref, *(const char **)pp, len); (*elink_pref)[len] = '\0'; @@ -784,7 +777,6 @@ H5P__lacc_elink_pref_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_pref_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_del * @@ -799,7 +791,7 @@ H5P__lacc_elink_pref_dec(const void **_pp, void *_value) */ static herr_t H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -810,7 +802,6 @@ H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_del() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_copy * @@ -835,7 +826,6 @@ H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_cmp * @@ -853,24 +843,23 @@ H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const char *pref1 = *(const char * const *)value1; - const char *pref2 = *(const char * const *)value2; - int ret_value = 0; + const char *pref1 = *(const char *const *)value1; + const char *pref2 = *(const char *const *)value2; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - if(NULL == pref1 && NULL != pref2) + if (NULL == pref1 && NULL != pref2) HGOTO_DONE(1); - if(NULL != pref1 && NULL == pref2) + if (NULL != pref1 && NULL == pref2) HGOTO_DONE(-1); - if(NULL != pref1 && NULL != pref2) + if (NULL != pref1 && NULL != pref2) ret_value = HDstrcmp(pref1, pref2); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lacc_elink_pref_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__lacc_elink_pref_close * @@ -895,7 +884,6 @@ H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__lacc_elink_pref_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_nlinks * @@ -920,28 +908,27 @@ H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", plist_id, nlinks); - if(nlinks <= 0) + if (nlinks <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of links must be positive"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set number of links */ - if(H5P_set(plist, H5L_ACS_NLINKS_NAME, &nlinks) < 0) + if (H5P_set(plist, H5L_ACS_NLINKS_NAME, &nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set nlink info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_nlinks() */ - /*------------------------------------------------------------------------- * Function: H5Pget_nlinks * @@ -961,28 +948,27 @@ H5Pset_nlinks(hid_t plist_id, size_t nlinks) herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*z", plist_id, nlinks); - if(!nlinks) + if (!nlinks) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer passed in"); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current number of links */ - if(H5P_get(plist, H5L_ACS_NLINKS_NAME, nlinks) < 0) + if (H5P_get(plist, H5L_ACS_NLINKS_NAME, nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of links") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Pset_elink_prefix * @@ -1000,25 +986,24 @@ H5Pget_nlinks(hid_t plist_id, size_t *nlinks) herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, prefix); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set prefix */ - if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_prefix() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_prefix * @@ -1038,32 +1023,32 @@ H5Pset_elink_prefix(hid_t plist_id, const char *prefix) 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 */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + char * my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if (H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") /* Check for prefix being set */ - if(my_prefix) { + if (my_prefix) { /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); - if(prefix) { + if (prefix) { HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); - if(len >= size) + if (len >= size) prefix[size - 1] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ else len = 0; @@ -1089,25 +1074,24 @@ H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", lapl_id, fapl_id); /* Check arguments */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link access property list"); /* Set the file access property list for the link access */ - if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fapl for link") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_fapl() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_fapl * @@ -1124,24 +1108,23 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) hid_t H5Pget_elink_fapl(hid_t lapl_id) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", lapl_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_elink_fapl() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_acc_flags * @@ -1159,31 +1142,30 @@ H5Pget_elink_fapl(hid_t lapl_id) herr_t H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", lapl_id, flags); /* Check that flags are valid */ - if(( flags != H5F_ACC_RDWR) && (flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) - && (flags != H5F_ACC_RDONLY) && (flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) - && (flags != H5F_ACC_DEFAULT)) + if ((flags != H5F_ACC_RDWR) && (flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) && + (flags != H5F_ACC_RDONLY) && (flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) && + (flags != H5F_ACC_DEFAULT)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set flags */ - if(H5P_set(plist, H5L_ACS_ELINK_FLAGS_NAME, &flags) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_FLAGS_NAME, &flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set access flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_acc_flags * @@ -1200,26 +1182,25 @@ H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags) herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", lapl_id, flags); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get flags */ - if(flags) - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) + if (flags) + if (H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get access flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pset_elink_cb * @@ -1237,35 +1218,34 @@ H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) herr_t H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5L_elink_cb_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5L_elink_cb_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", lapl_id, func, op_data); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && op_data) + if (!func && op_data) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Populate the callback info struct */ - cb_info.func = func; + cb_info.func = func; cb_info.user_data = op_data; /* Set callback info */ - if(H5P_set(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_set(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set callback info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_elink_acc_flags() */ - /*------------------------------------------------------------------------- * Function: H5Pget_elink_cb * @@ -1282,27 +1262,26 @@ H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data) herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) { - H5P_genplist_t *plist; /* Property list pointer */ - H5L_elink_cb_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5L_elink_cb_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", lapl_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) + if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") - if(func) + if (func) *func = cb_info.func; - if(op_data) + if (op_data) *op_data = cb_info.user_data; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_cb() */ - diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 2c8e364234f..2d7d5f5200b 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,18 +24,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -43,22 +41,19 @@ /* ======== Link creation properties ======== */ /* Definitions for create intermediate groups flag */ -#define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned) -#define H5L_CRT_INTERMEDIATE_GROUP_DEF 0 -#define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned -#define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned - +#define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned) +#define H5L_CRT_INTERMEDIATE_GROUP_DEF 0 +#define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned +#define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -66,45 +61,41 @@ /* Property class callbacks */ static herr_t H5P__lcrt_reg_prop(H5P_genclass_t *pclass); - /*********************/ /* Package Variables */ /*********************/ /* Link creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_LCRT[1] = {{ - "link create", /* Class name for debugging */ - H5P_TYPE_LINK_CREATE, /* Class type */ - - &H5P_CLS_STRING_CREATE_g, /* Parent class */ - &H5P_CLS_LINK_CREATE_g, /* Pointer to class */ - &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */ - &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */ - H5P__lcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "link create", /* Class name for debugging */ + H5P_TYPE_LINK_CREATE, /* Class type */ + + &H5P_CLS_STRING_CREATE_g, /* Parent class */ + &H5P_CLS_LINK_CREATE_g, /* Pointer to class */ + &H5P_CLS_LINK_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_LINK_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__lcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */ - +static const unsigned H5L_def_intmd_group_g = + H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */ - /*------------------------------------------------------------------------- * Function: H5P__lcrt_reg_prop * @@ -119,21 +110,20 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; static herr_t H5P__lcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register create intermediate groups property */ - if(H5P__register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, &H5L_def_intmd_group_g, - NULL, NULL, NULL, H5L_CRT_INTERMEDIATE_GROUP_ENC, H5L_CRT_INTERMEDIATE_GROUP_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, + &H5L_def_intmd_group_g, NULL, NULL, NULL, H5L_CRT_INTERMEDIATE_GROUP_ENC, + H5L_CRT_INTERMEDIATE_GROUP_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__lcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_create_intermediate_group * @@ -151,26 +141,25 @@ H5P__lcrt_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd_group) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_intmd_group); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ crt_intmd_group = (unsigned)(crt_intmd_group > 0 ? 1 : 0); - if(H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) + if (H5P_set(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set intermediate group creation flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_create_intermediate_group() */ - /*------------------------------------------------------------------------- * Function: H5Pget_create_intermediate_group * @@ -186,22 +175,21 @@ H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd_group) herr_t H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_intmd_group /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, crt_intmd_group); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(crt_intmd_group) - if(H5P_get(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, crt_intmd_group) < 0) + if (crt_intmd_group) + if (H5P_get(plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get intermediate group creation flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_create_intermediate_group() */ - diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c new file mode 100644 index 00000000000..8fdf610eb52 --- /dev/null +++ b/src/H5Pmapl.c @@ -0,0 +1,210 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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: Map access property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Map Access properties ============ */ +/* Definitions for key prefetch size */ +#define H5M_ACS_KEY_PREFETCH_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_PREFETCH_SIZE_DEF (size_t)(16 * 1024) +#define H5M_ACS_KEY_PREFETCH_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_PREFETCH_SIZE_DEC H5P__decode_size_t +/* Definition for key prefetch buffer size */ +#define H5M_ACS_KEY_ALLOC_SIZE_SIZE sizeof(size_t) +#define H5M_ACS_KEY_ALLOC_SIZE_DEF (size_t)(1024 * 1024) +#define H5M_ACS_KEY_ALLOC_SIZE_ENC H5P__encode_size_t +#define H5M_ACS_KEY_ALLOC_SIZE_DEC H5P__decode_size_t + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__macc_reg_prop(H5P_genclass_t *pclass); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Map access property list class library initialization object */ +const H5P_libclass_t H5P_CLS_MACC[1] = {{ + "map access", /* Class name for debugging */ + H5P_TYPE_MAP_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_MAP_ACCESS_g, /* Pointer to class */ + &H5P_CLS_MAP_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__macc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5P__macc_reg_prop + * + * Purpose: Register the map access property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__macc_reg_prop(H5P_genclass_t *pclass) +{ + size_t key_prefetch_size = H5M_ACS_KEY_PREFETCH_SIZE_DEF; /* Default key prefetch size for iteration */ + size_t key_alloc_size = + H5M_ACS_KEY_ALLOC_SIZE_DEF; /* Default key prefetch allocation size for iteration */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Register the key prefetch size for iteration */ + if (H5P__register_real(pclass, H5M_ACS_KEY_PREFETCH_SIZE_NAME, H5M_ACS_KEY_PREFETCH_SIZE_SIZE, + &key_prefetch_size, NULL, NULL, NULL, H5M_ACS_KEY_PREFETCH_SIZE_ENC, + H5M_ACS_KEY_PREFETCH_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the key prefetch allocation size for iteration */ + if (H5P__register_real(pclass, H5M_ACS_KEY_ALLOC_SIZE_NAME, H5M_ACS_KEY_ALLOC_SIZE_SIZE, &key_alloc_size, + NULL, NULL, NULL, H5M_ACS_KEY_ALLOC_SIZE_ENC, H5M_ACS_KEY_ALLOC_SIZE_DEC, NULL, + NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__macc_reg_prop() */ + +#ifdef H5_HAVE_MAP_API + +/*------------------------------------------------------------------------- + * Function: H5Pset_map_iterate_hints + * + * Purpose: H5Pset_map_iterate_hints adjusts the behavior of + * H5Miterate when prefetching keys for iteration. The + * KEY_PREFETCH_SIZE parameter specifies the number of keys + * to prefetch at a time during iteration. The KEY_ALLOC_SIZE + * parameter specifies the initial size of the buffer + * allocated to hold these prefetched keys. If this buffer is + * too small it will be reallocated to a larger size, though + * this may result in an additional I/O. + * + * Move to DAOS VOL code? DSINC + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "izz", mapl_id, key_prefetch_size, key_alloc_size); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Set sizes */ + if (H5P_set(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, &key_prefetch_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set key prefetch size"); + if (H5P_set(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, &key_alloc_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set key allocation size"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_map_iterate_hints() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_map_iterate_hints + * + * Purpose: Returns the map iterate hints, KEY_PREFETCH_SIZE and + * KEY_ALLOC_SIZE, as set by H5Pset_map_iterate_hints. + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size, size_t *key_alloc_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*z*z", mapl_id, key_prefetch_size, key_alloc_size); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(mapl_id, H5P_MAP_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Get the properties */ + if (key_prefetch_size) { + if (H5P_get(plist, H5M_ACS_KEY_PREFETCH_SIZE_NAME, key_prefetch_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key prefetch size"); + } /* end if */ + if (key_alloc_size) { + if (H5P_get(plist, H5M_ACS_KEY_ALLOC_SIZE_NAME, key_alloc_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get key allocation size"); + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_map_iterate_hints() */ +#endif diff --git a/src/H5Pmcpl.c b/src/H5Pmcpl.c new file mode 100644 index 00000000000..c88d0bb59b5 --- /dev/null +++ b/src/H5Pmcpl.c @@ -0,0 +1,104 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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: H5Pmcpl.c + * + * Purpose: Map creation property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Mprivate.h" /* Maps */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P__mcrt_reg_prop(H5P_genclass_t *pclass); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Map create property list class library initialization object */ +const H5P_libclass_t H5P_CLS_MCRT[1] = {{ + "map create", /* Class name for debugging */ + H5P_TYPE_MAP_CREATE, /* Class type */ + + &H5P_CLS_OBJECT_CREATE_g, /* Parent class */ + &H5P_CLS_MAP_CREATE_g, /* Pointer to class */ + &H5P_CLS_MAP_CREATE_ID_g, /* Pointer to class ID */ + &H5P_LST_MAP_CREATE_ID_g, /* Pointer to default property list ID */ + H5P__mcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/***************************/ +/* Local Private Variables */ +/***************************/ + +/*------------------------------------------------------------------------- + * Function: H5P__mcrt_reg_prop + * + * Purpose: Register the map creation property list class's properties + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5P__mcrt_reg_prop(H5P_genclass_t H5_ATTR_UNUSED *pclass) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__mcrt_reg_prop() */ diff --git a/src/H5Pmodule.h b/src/H5Pmodule.h index 11df06d0a8d..18f30c682ed 100644 --- a/src/H5Pmodule.h +++ b/src/H5Pmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,61 @@ * H5P package. Including this header means that the source file * is part of the H5P package. */ -#ifndef _H5Pmodule_H -#define _H5Pmodule_H +#ifndef H5Pmodule_H +#define H5Pmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5P_MODULE -#define H5_MY_PKG H5P -#define H5_MY_PKG_ERR H5E_PLIST -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5P +#define H5_MY_PKG_ERR H5E_PLIST +#define H5_MY_PKG_INIT YES -#endif /* _H5Pmodule_H */ +/**\defgroup H5P H5P + * \brief Property List Interface + * + * \details The HDF5 Property List Interface provides a mechanism to take + * advantage of more powerful or unusual features 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. + * + * \todo Describe concisely what the functions in this module are about. + * + * \defgroup GPLO General Property List Operations + * \ingroup H5P + * \defgroup GPLOA General Property List Operations (Advanced) + * \ingroup H5P + * \defgroup FCPL File Creation Properties + * \ingroup H5P + * \defgroup FAPL File Access Properties + * \ingroup H5P + * \defgroup GCPL Group Creation Properties + * \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 + * \ingroup H5P + * \defgroup OCPL Object Creation Properties + * \ingroup H5P + * \defgroup OCPPL Object Copy Properties + * \ingroup H5P + * \defgroup GACPL General Access Properties + * \ingroup H5P + * \defgroup MAPL Map Access Properties + * \ingroup H5P + */ +#endif /* H5Pmodule_H */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index b576aec1f01..cc325823313 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,22 +26,20 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5PLprivate.h" /* Dynamic plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5PLprivate.h" /* Dynamic plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ @@ -49,39 +47,36 @@ /* ========= Object Creation properties ============ */ /* Definitions for the max. # of attributes to store compactly */ -#define H5O_CRT_ATTR_MAX_COMPACT_SIZE sizeof(unsigned) -#define H5O_CRT_ATTR_MAX_COMPACT_ENC H5P__encode_unsigned -#define H5O_CRT_ATTR_MAX_COMPACT_DEC H5P__decode_unsigned +#define H5O_CRT_ATTR_MAX_COMPACT_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MAX_COMPACT_ENC H5P__encode_unsigned +#define H5O_CRT_ATTR_MAX_COMPACT_DEC H5P__decode_unsigned /* Definitions for the min. # of attributes to store densely */ -#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned) -#define H5O_CRT_ATTR_MIN_DENSE_ENC H5P__encode_unsigned -#define H5O_CRT_ATTR_MIN_DENSE_DEC H5P__decode_unsigned +#define H5O_CRT_ATTR_MIN_DENSE_SIZE sizeof(unsigned) +#define H5O_CRT_ATTR_MIN_DENSE_ENC H5P__encode_unsigned +#define H5O_CRT_ATTR_MIN_DENSE_DEC H5P__decode_unsigned /* Definitions for object header flags */ -#define H5O_CRT_OHDR_FLAGS_SIZE sizeof(uint8_t) -#define H5O_CRT_OHDR_FLAGS_ENC H5P__encode_uint8_t -#define H5O_CRT_OHDR_FLAGS_DEC H5P__decode_uint8_t +#define H5O_CRT_OHDR_FLAGS_SIZE sizeof(uint8_t) +#define H5O_CRT_OHDR_FLAGS_ENC H5P__encode_uint8_t +#define H5O_CRT_OHDR_FLAGS_DEC H5P__decode_uint8_t /* Definitions for filter pipeline */ -#define H5O_CRT_PIPELINE_SIZE sizeof(H5O_pline_t) -#define H5O_CRT_PIPELINE_SET H5P__ocrt_pipeline_set -#define H5O_CRT_PIPELINE_GET H5P__ocrt_pipeline_get -#define H5O_CRT_PIPELINE_ENC H5P__ocrt_pipeline_enc -#define H5O_CRT_PIPELINE_DEC H5P__ocrt_pipeline_dec -#define H5O_CRT_PIPELINE_DEL H5P__ocrt_pipeline_del -#define H5O_CRT_PIPELINE_COPY H5P__ocrt_pipeline_copy -#define H5O_CRT_PIPELINE_CMP H5P__ocrt_pipeline_cmp -#define H5O_CRT_PIPELINE_CLOSE H5P__ocrt_pipeline_close - +#define H5O_CRT_PIPELINE_SIZE sizeof(H5O_pline_t) +#define H5O_CRT_PIPELINE_SET H5P__ocrt_pipeline_set +#define H5O_CRT_PIPELINE_GET H5P__ocrt_pipeline_get +#define H5O_CRT_PIPELINE_ENC H5P__ocrt_pipeline_enc +#define H5O_CRT_PIPELINE_DEC H5P__ocrt_pipeline_dec +#define H5O_CRT_PIPELINE_DEL H5P__ocrt_pipeline_del +#define H5O_CRT_PIPELINE_COPY H5P__ocrt_pipeline_copy +#define H5O_CRT_PIPELINE_CMP H5P__ocrt_pipeline_cmp +#define H5O_CRT_PIPELINE_CLOSE H5P__ocrt_pipeline_close /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -96,12 +91,12 @@ static herr_t H5P__ocrt_pipeline_set(hid_t prop_id, const char *name, size_t siz static herr_t H5P__ocrt_pipeline_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocrt_pipeline_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocrt_pipeline_copy(const char *name, size_t size, void *value); -static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size); +static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__ocrt_pipeline_close(const char *name, size_t size, void *value); /* Local routines */ -static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]); +static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, + size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]); /*********************/ /* Package Variables */ @@ -109,42 +104,39 @@ static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, /* Object creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_OCRT[1] = {{ - "object create", /* Class name for debugging */ - H5P_TYPE_OBJECT_CREATE, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */ - &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - H5P__ocrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "object create", /* Class name for debugging */ + H5P_TYPE_OBJECT_CREATE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_CREATE_g, /* Pointer to class */ + &H5P_CLS_OBJECT_CREATE_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + H5P__ocrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5O_def_attr_max_compact_g = H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */ -static const unsigned H5O_def_attr_min_dense_g = H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */ -static const uint8_t H5O_def_ohdr_flags_g = H5O_CRT_OHDR_FLAGS_DEF; /* Default object header flag settings */ -static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* Default I/O pipeline setting */ - +static const unsigned H5O_def_attr_max_compact_g = + H5O_CRT_ATTR_MAX_COMPACT_DEF; /* Default max. compact attribute storage settings */ +static const unsigned H5O_def_attr_min_dense_g = + H5O_CRT_ATTR_MIN_DENSE_DEF; /* Default min. dense attribute storage settings */ +static const uint8_t H5O_def_ohdr_flags_g = H5O_CRT_OHDR_FLAGS_DEF; /* Default object header flag settings */ +static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* Default I/O pipeline setting */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_reg_prop * @@ -160,39 +152,39 @@ static const H5O_pline_t H5O_def_pline_g = H5O_CRT_PIPELINE_DEF; /* De static herr_t H5P__ocrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register max. compact attribute storage property */ - if(H5P__register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, &H5O_def_attr_max_compact_g, - NULL, NULL, NULL, H5O_CRT_ATTR_MAX_COMPACT_ENC, H5O_CRT_ATTR_MAX_COMPACT_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_ATTR_MAX_COMPACT_NAME, H5O_CRT_ATTR_MAX_COMPACT_SIZE, + &H5O_def_attr_max_compact_g, NULL, NULL, NULL, H5O_CRT_ATTR_MAX_COMPACT_ENC, + H5O_CRT_ATTR_MAX_COMPACT_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register min. dense attribute storage property */ - if(H5P__register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, &H5O_def_attr_min_dense_g, - NULL, NULL, NULL, H5O_CRT_ATTR_MIN_DENSE_ENC, H5O_CRT_ATTR_MIN_DENSE_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_ATTR_MIN_DENSE_NAME, H5O_CRT_ATTR_MIN_DENSE_SIZE, + &H5O_def_attr_min_dense_g, NULL, NULL, NULL, H5O_CRT_ATTR_MIN_DENSE_ENC, + H5O_CRT_ATTR_MIN_DENSE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register object header flags property */ - if(H5P__register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g, - NULL, NULL, NULL, H5O_CRT_OHDR_FLAGS_ENC, H5O_CRT_OHDR_FLAGS_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CRT_OHDR_FLAGS_NAME, H5O_CRT_OHDR_FLAGS_SIZE, &H5O_def_ohdr_flags_g, + NULL, NULL, NULL, H5O_CRT_OHDR_FLAGS_ENC, H5O_CRT_OHDR_FLAGS_DEC, NULL, NULL, NULL, + NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the pipeline property */ - if(H5P__register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g, - NULL, H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, H5O_CRT_PIPELINE_DEC, - H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0) + if (H5P__register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g, NULL, + H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, + H5O_CRT_PIPELINE_DEC, H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, + H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_attr_phase_change * @@ -218,35 +210,34 @@ H5P__ocrt_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense); /* Range check values */ - if(max_compact < min_dense) + if (max_compact < min_dense) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value") - if(max_compact > 65535) + if (max_compact > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536") - if(min_dense > 65535) + if (min_dense > 65535) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set property values */ - if(H5P_set(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) + if (H5P_set(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") - if(H5P_set(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) + if (H5P_set(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_attr_phase_change */ - /*------------------------------------------------------------------------- * Function: H5Pget_attr_phase_change * @@ -262,23 +253,23 @@ H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dens herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*Iu*Iu", plist_id, max_compact, min_dense); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(max_compact) { - if(H5P_get(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, max_compact) < 0) + if (max_compact) { + if (H5P_get(plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") } /* end if */ - if(min_dense) { - if(H5P_get(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, min_dense) < 0) + if (min_dense) { + if (H5P_get(plist, H5O_CRT_ATTR_MIN_DENSE_NAME, min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") } /* end if */ @@ -286,7 +277,6 @@ H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_de FUNC_LEAVE_API(ret_value) } /* end H5Pget_attr_phase_change() */ - /*------------------------------------------------------------------------- * Function: H5Pset_attr_creation_order * @@ -302,41 +292,42 @@ H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_de herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) { - H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + uint8_t ohdr_flags; /* Object header flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, crt_order_flags); /* Check for bad combination of flags */ - if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) + if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous attribute creation order flag settings */ - ohdr_flags &= (uint8_t)~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); + ohdr_flags &= (uint8_t) ~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); /* Update with new attribute creation order flags */ - ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); - ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | + ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | + ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); /* Set object header flags */ - if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_attr_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pget_attr_creation_order * @@ -353,25 +344,25 @@ H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Iu", plist_id, crt_order_flags); /* Get values */ - if(crt_order_flags) { + if (crt_order_flags) { H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ + uint8_t ohdr_flags; /* Object header flags */ /* Reset the value to return */ *crt_order_flags = 0; /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Set creation order flags to return */ @@ -383,7 +374,6 @@ H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags) FUNC_LEAVE_API(ret_value) } /* end H5Pget_attr_creation_order() */ - /*------------------------------------------------------------------------- * Function: H5Pset_obj_track_times * @@ -413,19 +403,19 @@ H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags) herr_t H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) { - H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + uint8_t ohdr_flags; /* Object header flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", plist_id, track_times); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Mask off previous time tracking flag settings */ @@ -435,14 +425,13 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) ohdr_flags = (uint8_t)(ohdr_flags | (track_times ? H5O_HDR_STORE_TIMES : 0)); /* Set object header flags */ - if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_obj_track_times() */ - /*------------------------------------------------------------------------- * Function: H5Pget_obj_track_times * @@ -458,22 +447,22 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) herr_t H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", plist_id, track_times); /* Get values */ - if(track_times) { + if (track_times) { H5P_genplist_t *plist; /* Property list pointer */ - uint8_t ohdr_flags; /* Object header flags */ + uint8_t ohdr_flags; /* Object header flags */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get object header flags */ - if(H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + if (H5P_get(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") /* Set track times flag to return */ @@ -484,7 +473,6 @@ H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) FUNC_LEAVE_API(ret_value) } /* end H5Pget_obj_track_times() */ - /*------------------------------------------------------------------------- * Function: H5P_modify_filter * @@ -522,31 +510,30 @@ H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) *------------------------------------------------------------------------- */ herr_t -H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned cd_values[/*cd_nelmts*/]) +H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned cd_values[/*cd_nelmts*/]) { - H5O_pline_t pline; - herr_t ret_value = SUCCEED; /* return value */ + H5O_pline_t pline; + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) /* Get the pipeline property to modify */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Modify the filter parameters of the I/O pipeline */ - if(H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0) + if (H5Z_modify(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_modify_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pmodify_filter * @@ -584,37 +571,35 @@ H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, *------------------------------------------------------------------------- */ herr_t -H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values); /* Check args */ - if (filter<0 || filter>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") + if (filter < 0 || filter > H5Z_FILTER_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") - if (cd_nelmts>0 && !cd_values) + if (cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Modify the filter parameters of the I/O pipeline */ - if(H5P_modify_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) + if (H5P_modify_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't modify filter") done: FUNC_LEAVE_API(ret_value) } /* end H5Pmodify_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pset_filter * @@ -648,36 +633,35 @@ H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, *------------------------------------------------------------------------- */ herr_t -H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values); /* Check args */ - if (filter<0 || filter>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") + if (filter < 0 || filter > H5Z_FILTER_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier") if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") - if (cd_nelmts>0 && !cd_values) + if (cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no client data values supplied") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Call the private function */ - if(H5P__set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) + if (H5P__set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "failed to call private function") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_filter() */ - /*------------------------------------------------------------------------- * Function: H5P__set_filter * @@ -714,36 +698,35 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, *------------------------------------------------------------------------- */ static herr_t -H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - H5O_pline_t pline; /* Filter pipeline */ - htri_t filter_avail; /* Filter availability */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t filter_avail; /* Filter availability */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check if filter is already available */ - if((filter_avail = H5Z_filter_avail(filter)) < 0) + if ((filter_avail = H5Z_filter_avail(filter)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't check filter availability") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter to the I/O pipeline */ - if(H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0) + if (H5Z_append(&pline, filter, flags, cd_nelmts, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__set_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pget_nfilters * @@ -767,29 +750,28 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, int H5Pget_nfilters(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - int ret_value; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Set return value */ - ret_value=(int)(pline.nused); + ret_value = (int)(pline.nused); done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_nfilters */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter2 * @@ -815,58 +797,57 @@ H5Pget_nfilters(hid_t plist_id) *------------------------------------------------------------------------- */ H5Z_filter_t -H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, +H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/, unsigned *filter_config /*out*/) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ + 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 */ + H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Z_FILTER_ERROR) - H5TRACE8("Zf", "iIux*zxzxx", plist_id, idx, flags, cd_nelmts, cd_values, - namelen, name, filter_config); + H5TRACE8("Zf", "iIux*zxzxx", plist_id, idx, flags, cd_nelmts, cd_values, namelen, name, filter_config); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, + "probable uninitialized *cd_nelmts argument") + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check index */ - if(idx >= pline.nused) + if (idx >= pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid") /* Set pointer to particular filter to query */ filter = &pline.filter[idx]; /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get filter info") /* Set return value */ @@ -876,7 +857,6 @@ H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter2() */ - /*------------------------------------------------------------------------- * Function: H5P_get_filter_by_id * @@ -900,33 +880,32 @@ H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, *------------------------------------------------------------------------- */ herr_t -H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, unsigned *filter_config) +H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config) { - H5O_pline_t pline; /* Filter pipeline */ - H5Z_filter_info_t *filter; /* Pointer to filter information */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + H5Z_filter_info_t *filter; /* Pointer to filter information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Get pointer to filter in pipeline */ - if(NULL == (filter = H5Z_filter_info(&pline, id))) + if (NULL == (filter = H5Z_filter_info(&pline, id))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filter ID is invalid") /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_filter_by_id() */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter_by_id2 * @@ -950,52 +929,49 @@ H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags *------------------------------------------------------------------------- */ herr_t -H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, unsigned *filter_config) +H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config) { - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE8("e", "iZfx*zxzx*Iu", plist_id, id, flags, cd_nelmts, cd_values, - namelen, name, filter_config); + H5TRACE8("e", "iZfx*zxzx*Iu", plist_id, id, flags, cd_nelmts, cd_values, namelen, name, filter_config); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) + if (cd_nelmts && *cd_nelmts > 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get filter information */ - if(H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, - name, filter_config) < 0) + if (H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, filter_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter_by_id2() */ - /*------------------------------------------------------------------------- * Function: H5Pall_filters_avail * @@ -1014,30 +990,29 @@ H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/ htri_t H5Pall_filters_avail(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - htri_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if all filters are available */ - if((ret_value = H5Z_all_filters_avail(&pline)) < 0) + if ((ret_value = H5Z_all_filters_avail(&pline)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't check pipeline information") done: FUNC_LEAVE_API(ret_value) } /* end H5Pall_filters_avail() */ - /*------------------------------------------------------------------------- * Function: H5P_filter_in_pline * @@ -1056,24 +1031,23 @@ H5Pall_filters_avail(hid_t plist_id) htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id) { - H5O_pline_t pline; /* Filter pipeline */ - htri_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if the file is in the pipeline */ - if((ret_value = H5Z_filter_in_pline(&pline, id)) < 0) + if ((ret_value = H5Z_filter_in_pline(&pline, id)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTCOMPARE, FAIL, "can't find filter") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_filter_in_pline() */ - /*------------------------------------------------------------------------- * Function: H5Premove_filter * @@ -1090,29 +1064,29 @@ H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id) herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iZf", plist_id, filter); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to modify */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if there are any filters */ if (pline.filter) { /* Delete filter */ - if(H5Z_delete(&pline, filter) < 0) + if (H5Z_delete(&pline, filter) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't delete filter") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ @@ -1120,7 +1094,6 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) FUNC_LEAVE_API(ret_value) } /* end H5Premove_filter() */ - /*------------------------------------------------------------------------- * Function: H5Pset_deflate * @@ -1142,38 +1115,37 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) herr_t H5Pset_deflate(hid_t plist_id, unsigned level) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, level); /* Check arguments */ - if(level > 9) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level") + if (level > 9) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid deflate level") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter */ - if(H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &level) < 0) + if (H5Z_append(&pline, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, (size_t)1, &level) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_deflate() */ - /*------------------------------------------------------------------------- * Function: H5Pset_fletcher32 * @@ -1190,34 +1162,33 @@ H5Pset_deflate(hid_t plist_id, unsigned level) herr_t H5Pset_fletcher32(hid_t plist_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the Fletcher32 checksum as a filter */ - if(H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) + if (H5Z_append(&pline, H5Z_FILTER_FLETCHER32, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add fletcher32 filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fletcher32() */ - /*------------------------------------------------------------------------- * Function: H5P__get_filter * @@ -1231,10 +1202,9 @@ H5Pset_fletcher32(hid_t plist_id) *------------------------------------------------------------------------- */ herr_t -H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/, - unsigned *filter_config /*out*/) +H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/, + unsigned *filter_config /*out*/) { FUNC_ENTER_PACKAGE_NOERR @@ -1242,58 +1212,57 @@ H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, HDassert(filter); /* Filter flags */ - if(flags) + if (flags) *flags = filter->flags; /* Filter parameters */ - if(cd_values) { - size_t i; /* Local index variable */ + if (cd_values) { + size_t i; /* Local index variable */ - for(i = 0; i < filter->cd_nelmts && i < *cd_nelmts; i++) + for (i = 0; i < filter->cd_nelmts && i < *cd_nelmts; i++) cd_values[i] = filter->cd_values[i]; } /* end if */ /* Number of filter parameters */ - if(cd_nelmts) + if (cd_nelmts) *cd_nelmts = filter->cd_nelmts; /* Filter name */ - if(namelen > 0 && name) { + if (namelen > 0 && name) { const char *s = filter->name; /* If there's no name on the filter, use the class's filter name */ - if(!s) { + if (!s) { H5Z_class2_t *cls = H5Z_find(filter->id); - if(cls) + if (cls) s = cls->name; } /* end if */ /* Check for actual name */ - if(s) { + if (s) { HDstrncpy(name, s, namelen); name[namelen - 1] = '\0'; } /* end if */ else { /* Check for unknown library filter */ /* (probably from a future version of the library) */ - if(filter->id < 256) { + if (filter->id < 256) { HDstrncpy(name, "Unknown library filter", namelen); name[namelen - 1] = '\0'; } /* end if */ else name[0] = '\0'; } /* end if */ - } /* end if */ + } /* end if */ /* Filter configuration (assume filter ID has already been checked) */ - if(filter_config) + if (filter_config) H5Z_get_filter_info(filter->id, filter_config); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__get_filter() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_set * @@ -1309,11 +1278,11 @@ H5P__get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, */ static herr_t H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1321,7 +1290,7 @@ H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1331,7 +1300,6 @@ H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_set() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_get * @@ -1347,11 +1315,11 @@ H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * */ static herr_t H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; /* Return value */ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1359,7 +1327,7 @@ H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1369,7 +1337,6 @@ H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_get() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_enc * @@ -1389,8 +1356,8 @@ 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; - size_t u; /* Local index variable */ + uint8_t ** pp = (uint8_t **)_pp; + size_t u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1398,7 +1365,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) HDassert(size); HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); - if(NULL != *pp) { + if (NULL != *pp) { unsigned enc_size; uint64_t enc_value; @@ -1407,14 +1374,14 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) /* encode nused value */ enc_value = (uint64_t)pline->nused; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode each pipeline */ - for(u = 0; u < pline->nused; u++) { - unsigned v; /* Local index variable */ + for (u = 0; u < pline->nused; u++) { + unsigned v; /* Local index variable */ /* encode filter ID */ INT32ENCODE(*pp, pline->filter[u].id) @@ -1423,7 +1390,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) H5_ENCODE_UNSIGNED(*pp, pline->filter[u].flags) /* encode filter name if it exists */ - if(NULL != pline->filter[u].name) { + if (NULL != pline->filter[u].name) { /* encode TRUE indicating that it exits */ *(*pp)++ = (uint8_t)TRUE; @@ -1437,23 +1404,23 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) /* encode cd_nelmts */ enc_value = (uint64_t)pline->filter[u].cd_nelmts; - enc_size = H5VM_limit_enc_size(enc_value); + enc_size = H5VM_limit_enc_size(enc_value); HDassert(enc_size < 256); *(*pp)++ = (uint8_t)enc_size; UINT64ENCODE_VAR(*pp, enc_value, enc_size); /* encode all values */ - for(v = 0; v < pline->filter[u].cd_nelmts; v++) + for (v = 0; v < pline->filter[u].cd_nelmts; v++) H5_ENCODE_UNSIGNED(*pp, pline->filter[u].cd_values[v]) } /* end for */ - } /* end if */ + } /* end if */ /* calculate size required for encoding */ *size += 1; *size += (1 + H5VM_limit_enc_size((uint64_t)pline->nused)); - for(u = 0; u < pline->nused; u++) { + for (u = 0; u < pline->nused; u++) { *size += (sizeof(int32_t) + sizeof(unsigned) + 1); - if(NULL != pline->filter[u].name) + if (NULL != pline->filter[u].name) *size += H5Z_COMMON_NAME_LEN; *size += (1 + H5VM_limit_enc_size((uint64_t)pline->filter[u].cd_nelmts)); *size += pline->filter[u].cd_nelmts * sizeof(unsigned); @@ -1462,7 +1429,6 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocrt_pipeline_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_dec * @@ -1481,13 +1447,13 @@ 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 */ - 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) */ - uint64_t enc_value; /* Value to encode */ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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) */ + uint64_t enc_value; /* Value to encode */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1495,7 +1461,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* Decode the size of size_t */ enc_size = *(*pp)++; - if(enc_size != sizeof(unsigned)) + if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") /* decode nused */ @@ -1508,10 +1474,10 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) HDmemset(pline, 0, sizeof(H5O_pline_t)); *pline = H5O_def_pline_g; - for(u = 0; u < nused; u++) { - H5Z_filter_info_t filter; /* Filter info, for pipeline */ - uint8_t has_name; /* Flag to indicate whether filter has a name */ - unsigned v; /* Local index variable */ + for (u = 0; u < nused; u++) { + H5Z_filter_info_t filter; /* Filter info, for pipeline */ + uint8_t has_name; /* Flag to indicate whether filter has a name */ + unsigned v; /* Local index variable */ /* decode filter id */ INT32DECODE(*pp, filter.id) @@ -1521,7 +1487,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* decode value indicating if the name is encoded */ has_name = *(*pp)++; - if(has_name) { + if (has_name) { /* decode name */ filter.name = H5MM_xstrdup((const char *)(*pp)); *pp += H5Z_COMMON_NAME_LEN; @@ -1535,19 +1501,19 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) UINT64DECODE_VAR(*pp, enc_value, enc_size); filter.cd_nelmts = (size_t)enc_value; - if(filter.cd_nelmts) { - if(NULL == (filter.cd_values = (unsigned *)H5MM_malloc(sizeof(unsigned) * filter.cd_nelmts))) + if (filter.cd_nelmts) { + if (NULL == (filter.cd_values = (unsigned *)H5MM_malloc(sizeof(unsigned) * filter.cd_nelmts))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for cd_values") } /* end if */ else filter.cd_values = NULL; /* decode values */ - for(v = 0; v < filter.cd_nelmts; v++) + for (v = 0; v < filter.cd_nelmts; v++) H5_DECODE_UNSIGNED(*pp, filter.cd_values[v]) /* Add the filter to the I/O pipeline */ - if(H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) + if (H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Free cd_values, if it was allocated */ @@ -1558,7 +1524,6 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(ret_value) } /* H5P__ocrt_pipeline_dec() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_del * @@ -1574,9 +1539,9 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) */ static herr_t H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1584,14 +1549,13 @@ H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * HDassert(value); /* Reset the old I/O pipeline */ - if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_copy * @@ -1606,12 +1570,11 @@ H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * *-------------------------------------------------------------------------- */ static herr_t -H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ - H5O_pline_t new_pline; - herr_t ret_value = SUCCEED; + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1619,7 +1582,7 @@ H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED s HDassert(pline); /* Make copy of I/O pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + if (NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") /* Copy new I/O pipeline message over old one */ @@ -1629,7 +1592,6 @@ H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED s FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_cmp * @@ -1648,9 +1610,9 @@ H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED s static int H5P__ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t H5_ATTR_UNUSED size) { - const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ - *pline2 = (const H5O_pline_t *)_pline2; - int cmp_value; /* Value from comparison */ + const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ + *pline2 = (const H5O_pline_t *)_pline2; + int cmp_value; /* Value from comparison */ herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1661,57 +1623,72 @@ H5P__ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t H5_ATTR_ HDassert(size == sizeof(H5O_pline_t)); /* Check the number of used pipeline entries */ - if(pline1->nused < pline2->nused) HGOTO_DONE(-1); - if(pline1->nused > pline2->nused) HGOTO_DONE(1); + if (pline1->nused < pline2->nused) + HGOTO_DONE(-1); + if (pline1->nused > pline2->nused) + HGOTO_DONE(1); /* Check the filter entry information */ - if(pline1->filter == NULL && pline2->filter != NULL) HGOTO_DONE(-1); - if(pline1->filter != NULL && pline2->filter == NULL) HGOTO_DONE(1); - if(pline1->filter != NULL && pline1->nused > 0) { - size_t u; /* Local index variable */ + if (pline1->filter == NULL && pline2->filter != NULL) + HGOTO_DONE(-1); + if (pline1->filter != NULL && pline2->filter == NULL) + HGOTO_DONE(1); + if (pline1->filter != NULL && pline1->nused > 0) { + size_t u; /* Local index variable */ /* Loop through all filters, comparing them */ - for(u = 0; u < pline1->nused; u++) { + for (u = 0; u < pline1->nused; u++) { /* Check the ID of the filter */ - if(pline1->filter[u].id < pline2->filter[u].id) HGOTO_DONE(-1); - if(pline1->filter[u].id > pline2->filter[u].id) HGOTO_DONE(1); + if (pline1->filter[u].id < pline2->filter[u].id) + HGOTO_DONE(-1); + if (pline1->filter[u].id > pline2->filter[u].id) + HGOTO_DONE(1); /* Check the flags for the filter */ - if(pline1->filter[u].flags < pline2->filter[u].flags) HGOTO_DONE(-1); - if(pline1->filter[u].flags > pline2->filter[u].flags) HGOTO_DONE(1); + if (pline1->filter[u].flags < pline2->filter[u].flags) + HGOTO_DONE(-1); + if (pline1->filter[u].flags > pline2->filter[u].flags) + HGOTO_DONE(1); /* Check the name of the filter */ - if(pline1->filter[u].name == NULL && pline2->filter[u].name != NULL) HGOTO_DONE(-1); - if(pline1->filter[u].name != NULL && pline2->filter[u].name == NULL) HGOTO_DONE(1); - if(pline1->filter[u].name != NULL) - if((cmp_value = HDstrcmp(pline1->filter[u].name, pline2->filter[u].name)) != 0) + if (pline1->filter[u].name == NULL && pline2->filter[u].name != NULL) + HGOTO_DONE(-1); + if (pline1->filter[u].name != NULL && pline2->filter[u].name == NULL) + HGOTO_DONE(1); + if (pline1->filter[u].name != NULL) + if ((cmp_value = HDstrcmp(pline1->filter[u].name, pline2->filter[u].name)) != 0) HGOTO_DONE(cmp_value); /* Check the number of parameters for the filter */ - if(pline1->filter[u].cd_nelmts < pline2->filter[u].cd_nelmts) HGOTO_DONE(-1); - if(pline1->filter[u].cd_nelmts > pline2->filter[u].cd_nelmts) HGOTO_DONE(1); + if (pline1->filter[u].cd_nelmts < pline2->filter[u].cd_nelmts) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_nelmts > pline2->filter[u].cd_nelmts) + HGOTO_DONE(1); /* Check the filter parameter information */ - if(pline1->filter[u].cd_values == NULL && pline2->filter[u].cd_values != NULL) HGOTO_DONE(-1); - if(pline1->filter[u].cd_values != NULL && pline2->filter[u].cd_values == NULL) HGOTO_DONE(1); - if(pline1->filter[u].cd_values != NULL && pline1->filter[u].cd_nelmts > 0) { - size_t v; /* Local index variable */ + if (pline1->filter[u].cd_values == NULL && pline2->filter[u].cd_values != NULL) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_values != NULL && pline2->filter[u].cd_values == NULL) + HGOTO_DONE(1); + if (pline1->filter[u].cd_values != NULL && pline1->filter[u].cd_nelmts > 0) { + size_t v; /* Local index variable */ /* Loop through all parameters, comparing them */ - for(v = 0; v < pline1->filter[u].cd_nelmts; v++) { + for (v = 0; v < pline1->filter[u].cd_nelmts; v++) { /* Check each parameter for the filter */ - if(pline1->filter[u].cd_values[v] < pline2->filter[u].cd_values[v]) HGOTO_DONE(-1); - if(pline1->filter[u].cd_values[v] > pline2->filter[u].cd_values[v]) HGOTO_DONE(1); + if (pline1->filter[u].cd_values[v] < pline2->filter[u].cd_values[v]) + HGOTO_DONE(-1); + if (pline1->filter[u].cd_values[v] > pline2->filter[u].cd_values[v]) + HGOTO_DONE(1); } /* end for */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_cmp() */ - /*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_close * @@ -1726,10 +1703,9 @@ H5P__ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t H5_ATTR_ *------------------------------------------------------------------------- */ static herr_t -H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1737,7 +1713,7 @@ H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED HDassert(value); /* Reset the old I/O pipeline */ - if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + if (H5O_msg_reset(H5O_PLINE_ID, value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") done: @@ -1745,7 +1721,7 @@ H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED } /* end H5P__ocrt_pipeline_close() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Pget_filter1 * @@ -1770,57 +1746,56 @@ H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED *------------------------------------------------------------------------- */ H5Z_filter_t -H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/) +H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t *cd_nelmts /*in_out*/, + unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/) { - H5O_pline_t pline; /* Filter pipeline */ - const H5Z_filter_info_t *filter; /* Pointer to filter information */ - H5P_genplist_t *plist; /* Property list pointer */ - H5Z_filter_t ret_value; /* return value */ + H5O_pline_t pline; /* Filter pipeline */ + const H5Z_filter_info_t *filter; /* Pointer to filter information */ + H5P_genplist_t * plist; /* Property list pointer */ + H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Z_FILTER_ERROR) - H5TRACE7("Zf", "iIux*zxzx", plist_id, idx, flags, cd_nelmts, cd_values, namelen, - name); + H5TRACE7("Zf", "iIux*zxzx", plist_id, idx, flags, cd_nelmts, cd_values, namelen, name); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 256) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, + "probable uninitialized *cd_nelmts argument") + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get pipeline info */ - if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if (H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check more args */ - if(idx >= pline.nused) + if (idx >= pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid") /* Set pointer to particular filter to query */ filter = &pline.filter[idx]; /* Get filter information */ - if(H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) + if (H5P__get_filter(filter, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get filter info") /* Set return value */ @@ -1830,7 +1805,6 @@ H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter1() */ - /*------------------------------------------------------------------------- * Function: H5Pget_filter_by_id1 * @@ -1853,48 +1827,46 @@ H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, *------------------------------------------------------------------------- */ herr_t -H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, - size_t *cd_nelmts/*in_out*/, unsigned cd_values[]/*out*/, - size_t namelen, char name[]/*out*/) +H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*in_out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "iZfx*zxzx", plist_id, id, flags, cd_nelmts, cd_values, namelen, - name); + H5TRACE7("e", "iZfx*zxzx", plist_id, id, flags, cd_nelmts, cd_values, namelen, name); /* Check args */ - if(cd_nelmts || cd_values) { + if (cd_nelmts || cd_values) { /* * It's likely that users forget to initialize this on input, so * we'll check that it has a reasonable value. The actual number * is unimportant because the H5O layer will detect when a message * is too large. */ - if(cd_nelmts && *cd_nelmts > 256) + if (cd_nelmts && *cd_nelmts > 256) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "probable uninitialized *cd_nelmts argument") - if(cd_nelmts && *cd_nelmts > 0 && !cd_values) + if (cd_nelmts && *cd_nelmts > 0 && !cd_values) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "client data values not supplied") /* * If cd_nelmts is null but cd_values is non-null then just ignore * cd_values */ - if(!cd_nelmts) + if (!cd_nelmts) cd_values = NULL; } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get filter info */ - if(H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) + if (H5P_get_filter_by_id(plist, id, flags, cd_nelmts, cd_values, namelen, name, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get filter info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_filter_by_id1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index d23585ce839..ff959d2fb54 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,20 +26,18 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -47,43 +45,44 @@ /* ========= Object Copy properties ============ */ /* Definitions for copy options */ -#define H5O_CPY_OPTION_SIZE sizeof(unsigned) -#define H5O_CPY_OPTION_DEF 0 -#define H5O_CPY_OPTION_ENC H5P__encode_unsigned -#define H5O_CPY_OPTION_DEC H5P__decode_unsigned +#define H5O_CPY_OPTION_SIZE sizeof(unsigned) +#define H5O_CPY_OPTION_DEF 0 +#define H5O_CPY_OPTION_ENC H5P__encode_unsigned +#define H5O_CPY_OPTION_DEC H5P__decode_unsigned /* Definitions for merge committed dtype list */ -#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(H5O_copy_dtype_merge_list_t *) -#define H5O_CPY_MERGE_COMM_DT_LIST_DEF NULL -#define H5O_CPY_MERGE_COMM_DT_LIST_SET H5P__ocpy_merge_comm_dt_list_set -#define H5O_CPY_MERGE_COMM_DT_LIST_GET H5P__ocpy_merge_comm_dt_list_get -#define H5O_CPY_MERGE_COMM_DT_LIST_ENC H5P__ocpy_merge_comm_dt_list_enc -#define H5O_CPY_MERGE_COMM_DT_LIST_DEC H5P__ocpy_merge_comm_dt_list_dec -#define H5O_CPY_MERGE_COMM_DT_LIST_DEL H5P__ocpy_merge_comm_dt_list_del -#define H5O_CPY_MERGE_COMM_DT_LIST_COPY H5P__ocpy_merge_comm_dt_list_copy -#define H5O_CPY_MERGE_COMM_DT_LIST_CMP H5P__ocpy_merge_comm_dt_list_cmp -#define H5O_CPY_MERGE_COMM_DT_LIST_CLOSE H5P__ocpy_merge_comm_dt_list_close -/* Definitions for callback function when completing the search for a matching committed datatype from the committed dtype list */ -#define H5O_CPY_MCDT_SEARCH_CB_SIZE sizeof(H5O_mcdt_cb_info_t) -#define H5O_CPY_MCDT_SEARCH_CB_DEF {NULL,NULL} - +#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(H5O_copy_dtype_merge_list_t *) +#define H5O_CPY_MERGE_COMM_DT_LIST_DEF NULL +#define H5O_CPY_MERGE_COMM_DT_LIST_SET H5P__ocpy_merge_comm_dt_list_set +#define H5O_CPY_MERGE_COMM_DT_LIST_GET H5P__ocpy_merge_comm_dt_list_get +#define H5O_CPY_MERGE_COMM_DT_LIST_ENC H5P__ocpy_merge_comm_dt_list_enc +#define H5O_CPY_MERGE_COMM_DT_LIST_DEC H5P__ocpy_merge_comm_dt_list_dec +#define H5O_CPY_MERGE_COMM_DT_LIST_DEL H5P__ocpy_merge_comm_dt_list_del +#define H5O_CPY_MERGE_COMM_DT_LIST_COPY H5P__ocpy_merge_comm_dt_list_copy +#define H5O_CPY_MERGE_COMM_DT_LIST_CMP H5P__ocpy_merge_comm_dt_list_cmp +#define H5O_CPY_MERGE_COMM_DT_LIST_CLOSE H5P__ocpy_merge_comm_dt_list_close +/* Definitions for callback function when completing the search for a matching committed datatype from the + * committed dtype list */ +#define H5O_CPY_MCDT_SEARCH_CB_SIZE sizeof(H5O_mcdt_cb_info_t) +#define H5O_CPY_MCDT_SEARCH_CB_DEF \ + { \ + NULL, NULL \ + } /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* General routines */ static H5O_copy_dtype_merge_list_t *H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list); -static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value); +static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value); /* Property class callbacks */ static herr_t H5P__ocpy_reg_prop(H5P_genclass_t *pclass); @@ -94,10 +93,9 @@ static herr_t H5P__ocpy_merge_comm_dt_list_get(hid_t prop_id, const char *name, static herr_t H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *value); static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char* name, size_t size, void* value); -static int H5P__ocpy_merge_comm_dt_list_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, void* value); - +static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char *name, size_t size, void *value); +static int H5P__ocpy_merge_comm_dt_list_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__ocpy_merge_comm_dt_list_close(const char *name, size_t size, void *value); /*********************/ /* Package Variables */ @@ -105,43 +103,42 @@ static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, /* Object copy property list class library initialization object */ const H5P_libclass_t H5P_CLS_OCPY[1] = {{ - "object copy", /* Class name for debugging */ - H5P_TYPE_OBJECT_COPY, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_OBJECT_COPY_g, /* Pointer to class */ - &H5P_CLS_OBJECT_COPY_ID_g, /* Pointer to class ID */ - &H5P_LST_OBJECT_COPY_ID_g, /* Pointer to default property list ID */ - H5P__ocpy_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "object copy", /* Class name for debugging */ + H5P_TYPE_OBJECT_COPY, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_OBJECT_COPY_g, /* Pointer to class */ + &H5P_CLS_OBJECT_COPY_ID_g, /* Pointer to class ID */ + &H5P_LST_OBJECT_COPY_ID_g, /* Pointer to default property list ID */ + H5P__ocpy_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const unsigned H5O_def_ocpy_option_g = H5O_CPY_OPTION_DEF; /* Default object copy flags */ -static const H5O_copy_dtype_merge_list_t *H5O_def_merge_comm_dtype_list_g = H5O_CPY_MERGE_COMM_DT_LIST_DEF; /* Default merge committed dtype list */ -static const H5O_mcdt_cb_info_t H5O_def_mcdt_cb_g = H5O_CPY_MCDT_SEARCH_CB_DEF; /* Default callback before searching the global list of committed datatypes at destination */ +static const unsigned H5O_def_ocpy_option_g = H5O_CPY_OPTION_DEF; /* Default object copy flags */ +static const H5O_copy_dtype_merge_list_t *H5O_def_merge_comm_dtype_list_g = + H5O_CPY_MERGE_COMM_DT_LIST_DEF; /* Default merge committed dtype list */ +static const H5O_mcdt_cb_info_t H5O_def_mcdt_cb_g = + H5O_CPY_MCDT_SEARCH_CB_DEF; /* Default callback before searching the global list of committed datatypes at + destination */ /* Declare a free list to manage the H5O_copy_dtype_merge_list_t struct */ H5FL_DEFINE(H5O_copy_dtype_merge_list_t); - - /*------------------------------------------------------------------------- * Function: H5P__ocpy_reg_prop * @@ -156,33 +153,35 @@ H5FL_DEFINE(H5O_copy_dtype_merge_list_t); static herr_t H5P__ocpy_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register copy options property */ - if(H5P__register_real(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, &H5O_def_ocpy_option_g, - NULL, NULL, NULL, H5O_CPY_OPTION_ENC, H5O_CPY_OPTION_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CPY_OPTION_NAME, H5O_CPY_OPTION_SIZE, &H5O_def_ocpy_option_g, NULL, + NULL, NULL, H5O_CPY_OPTION_ENC, H5O_CPY_OPTION_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register merge named dtype list property */ - if(H5P__register_real(pclass, H5O_CPY_MERGE_COMM_DT_LIST_NAME, H5O_CPY_MERGE_COMM_DT_LIST_SIZE, &H5O_def_merge_comm_dtype_list_g, - NULL, H5O_CPY_MERGE_COMM_DT_LIST_SET, H5O_CPY_MERGE_COMM_DT_LIST_GET, H5O_CPY_MERGE_COMM_DT_LIST_ENC, H5O_CPY_MERGE_COMM_DT_LIST_DEC, - H5O_CPY_MERGE_COMM_DT_LIST_DEL, H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) + if (H5P__register_real(pclass, H5O_CPY_MERGE_COMM_DT_LIST_NAME, H5O_CPY_MERGE_COMM_DT_LIST_SIZE, + &H5O_def_merge_comm_dtype_list_g, NULL, H5O_CPY_MERGE_COMM_DT_LIST_SET, + H5O_CPY_MERGE_COMM_DT_LIST_GET, H5O_CPY_MERGE_COMM_DT_LIST_ENC, + H5O_CPY_MERGE_COMM_DT_LIST_DEC, H5O_CPY_MERGE_COMM_DT_LIST_DEL, + H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, + H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register property for callback when completing the search for a matching named datatype from the named dtype list */ + /* Register property for callback when completing the search for a matching named datatype from the named + * dtype list */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5O_CPY_MCDT_SEARCH_CB_NAME, H5O_CPY_MCDT_SEARCH_CB_SIZE, &H5O_def_mcdt_cb_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5O_CPY_MCDT_SEARCH_CB_NAME, H5O_CPY_MCDT_SEARCH_CB_SIZE, + &H5O_def_mcdt_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5P__free_merge_comm_dtype_list * @@ -201,7 +200,7 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) FUNC_ENTER_STATIC_NOERR /* Free the list */ - while(dt_list) { + while (dt_list) { H5O_copy_dtype_merge_list_t *tmp_node; tmp_node = dt_list->next; @@ -215,7 +214,6 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) FUNC_LEAVE_NOAPI(NULL); } /* H5P__free_merge_comm_dtype_list */ - /*-------------------------------------------------------------------------- * Function: H5P__copy_merge_comm_dt_list * @@ -232,10 +230,11 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) 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, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ - herr_t ret_value = SUCCEED; + 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, + *tmp_dt_list = NULL; /* temporary merge named datatype lists */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -244,20 +243,20 @@ H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) /* Make copy of merge committed dtype list */ src_dt_list = *value; - while(src_dt_list) { + while (src_dt_list) { /* Copy src_dt_list */ - if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) + if (NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Add copied node to dest dtype list */ - if(dst_dt_list_tail) { + if (dst_dt_list_tail) { dst_dt_list_tail->next = tmp_dt_list; - dst_dt_list_tail = tmp_dt_list; + dst_dt_list_tail = tmp_dt_list; } /* end if */ else { - dst_dt_list = tmp_dt_list; + dst_dt_list = tmp_dt_list; dst_dt_list_tail = tmp_dt_list; } /* end else */ tmp_dt_list = NULL; @@ -270,18 +269,17 @@ H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) *value = dst_dt_list; done: - if(ret_value < 0) { + if (ret_value < 0) { dst_dt_list = H5P__free_merge_comm_dtype_list(dst_dt_list); - if(tmp_dt_list) { + if (tmp_dt_list) { tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); - tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); + tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__copy_merge_comm_dt_list() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_set * @@ -297,9 +295,9 @@ H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) */ static herr_t H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -307,14 +305,13 @@ H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_set() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_get * @@ -330,9 +327,9 @@ H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT */ static herr_t H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -340,14 +337,13 @@ H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_get() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_enc * @@ -366,10 +362,10 @@ H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT 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 */ - size_t len; /* Length of path component */ + 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 */ + size_t len; /* Length of path component */ FUNC_ENTER_STATIC_NOERR @@ -378,12 +374,12 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) /* Iterate over merge committed dtype list */ dt_list = *dt_list_ptr; - while(dt_list) { + while (dt_list) { /* Get length of encoded path */ len = HDstrlen(dt_list->path) + 1; /* Encode merge committed dtype list */ - if(*pp) { + if (*pp) { H5MM_memcpy(*(char **)pp, dt_list->path, len); *pp += len; } /* end if */ @@ -396,7 +392,7 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) } /* end while */ /* Encode the terminator for the string sequence */ - if(*pp) + if (*pp) *(*pp)++ = (uint8_t)'\0'; /* Account for the string sequence terminator */ @@ -405,7 +401,6 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_dec * @@ -424,11 +419,13 @@ H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) static herr_t 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; - 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 */ - herr_t ret_value = SUCCEED; /* Return 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; + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -442,22 +439,22 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) /* Decode the string sequence */ len = HDstrlen(*(const char **)pp); - while(len > 0) { + while (len > 0) { /* Create new node & duplicate string */ - if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - if(NULL == (tmp_dt_list->path = H5MM_strdup(*(const char **)pp))) + if (NULL == (tmp_dt_list->path = H5MM_strdup(*(const char **)pp))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") *pp += len + 1; HDassert(len == HDstrlen(tmp_dt_list->path)); /* Add copied node to dtype list */ - if(dt_list_tail) { + if (dt_list_tail) { dt_list_tail->next = tmp_dt_list; - dt_list_tail = tmp_dt_list; + dt_list_tail = tmp_dt_list; } /* end if */ else { - *dt_list = tmp_dt_list; + *dt_list = tmp_dt_list; dt_list_tail = tmp_dt_list; } /* end else */ tmp_dt_list = NULL; @@ -470,18 +467,17 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) *pp += 1; done: - if(ret_value < 0) { + if (ret_value < 0) { *dt_list = H5P__free_merge_comm_dtype_list(*dt_list); - if(tmp_dt_list) { + if (tmp_dt_list) { tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); - tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); + tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5P__ocpy_merge_comm_dt_list_dec() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_del * @@ -497,7 +493,7 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) */ static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) + size_t H5_ATTR_UNUSED size, void *value) { FUNC_ENTER_STATIC_NOERR @@ -510,7 +506,6 @@ H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_del() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_copy * @@ -525,10 +520,9 @@ H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATT *-------------------------------------------------------------------------- */ static herr_t -H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, - void *value) +H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -536,14 +530,13 @@ H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATT HDassert(value); /* Make copy of merge committed dtype list */ - if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + if (H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_copy() */ - /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_cmp * @@ -561,12 +554,12 @@ H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATT *------------------------------------------------------------------------- */ static int -H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, - size_t H5_ATTR_UNUSED size) +H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, size_t H5_ATTR_UNUSED size) { - const H5O_copy_dtype_merge_list_t *dt_list1 = *(H5O_copy_dtype_merge_list_t * const *)_dt_list1, /* Create local aliases for values */ - *dt_list2 = *(H5O_copy_dtype_merge_list_t * const *)_dt_list2; - herr_t ret_value = 0; /* Return value */ + const H5O_copy_dtype_merge_list_t *dt_list1 = *(H5O_copy_dtype_merge_list_t *const *) + _dt_list1, /* Create local aliases for values */ + *dt_list2 = *(H5O_copy_dtype_merge_list_t *const *)_dt_list2; + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -577,13 +570,14 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, /* Walk through the lists, comparing each path. For the lists to be the * same, the paths must be in the same order. */ - while(dt_list1 && dt_list2) { + while (dt_list1 && dt_list2) { HDassert(dt_list1->path); HDassert(dt_list2->path); /* Compare paths */ ret_value = HDstrcmp(dt_list1->path, dt_list2->path); - if(ret_value != 0) HGOTO_DONE(ret_value) + if (ret_value != 0) + HGOTO_DONE(ret_value) /* Advance to next node */ dt_list1 = dt_list1->next; @@ -591,14 +585,15 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, } /* end while */ /* Check if one list is longer than the other */ - if(dt_list1) HGOTO_DONE(1) - if(dt_list2) HGOTO_DONE(-1) + if (dt_list1) + HGOTO_DONE(1) + if (dt_list2) + HGOTO_DONE(-1) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_cmp() */ - /*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_close * @@ -625,7 +620,6 @@ H5P__ocpy_merge_comm_dt_list_close(const char H5_ATTR_UNUSED *name, size_t H5_AT FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__ocpy_merge_comm_dt_list_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_copy_object * @@ -650,29 +644,28 @@ H5P__ocpy_merge_comm_dt_list_close(const char H5_ATTR_UNUSED *name, size_t H5_AT herr_t H5Pset_copy_object(hid_t plist_id, unsigned cpy_option) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iIu", plist_id, cpy_option); /* Check parameters */ - if(cpy_option & ~H5O_COPY_ALL) + if (cpy_option & ~H5O_COPY_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown option specified") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ - if(H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) + if (H5P_set(plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set copy object flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_copy_object() */ - /*------------------------------------------------------------------------- * Function: H5Pget_copy_object * @@ -688,26 +681,25 @@ H5Pset_copy_object(hid_t plist_id, unsigned cpy_option) herr_t H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, cpy_option); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(cpy_option) - if(H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) + if (cpy_option) + if (H5P_get(plist, H5O_CPY_OPTION_NAME, cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_copy_object() */ - /*------------------------------------------------------------------------- * Function: H5Padd_merge_committed_dtype_path * @@ -731,50 +723,49 @@ 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 */ - 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 */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", plist_id, path); /* Check parameters */ - if(!path) + if (!path) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no path specified") - if(path[0] == '\0') + if (path[0] == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "path is empty string") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) + if (H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge named dtype list") /* Add the new path to the list */ - if(NULL == (new_obj = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + if (NULL == (new_obj = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (new_obj->path = H5MM_strdup(path))) + if (NULL == (new_obj->path = H5MM_strdup(path))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") new_obj->next = old_list; /* Update the list stored in the property list */ - if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) + if (H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge named dtype list") done: - if(ret_value < 0) - if(new_obj) { + if (ret_value < 0) + if (new_obj) { new_obj->path = (char *)H5MM_xfree(new_obj->path); - new_obj = H5FL_FREE(H5O_copy_dtype_merge_list_t, new_obj); + new_obj = H5FL_FREE(H5O_copy_dtype_merge_list_t, new_obj); } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Padd_merge_committed_dtype_path() */ - /*------------------------------------------------------------------------- * Function: H5Pfree_merge_committed_dtype_paths * @@ -794,33 +785,32 @@ 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 */ - H5O_copy_dtype_merge_list_t *dt_list; /* Merge committed dtype list currently present */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if (H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed dtype list") /* Free dtype list */ dt_list = H5P__free_merge_comm_dtype_list(dt_list); /* Update the list stored in the property list (to NULL) */ - if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if (H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge committed dtype list") done: FUNC_LEAVE_API(ret_value) } /* end H5Pfree_merge_committed_dtype_paths() */ - /*------------------------------------------------------------------------- * Function: H5Pset_mcdt_search_cb * @@ -842,35 +832,34 @@ 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 */ - H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ix*x", plist_id, func, op_data); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ - if(!func && op_data) + if (!func && op_data) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Populate the callback info struct */ - cb_info.func = func; + /* Populate the callback info struct */ + cb_info.func = func; cb_info.user_data = op_data; /* Set callback info */ - if(H5P_set(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_set(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set callback info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_mcdt_search_cb() */ - /*------------------------------------------------------------------------- * Function: H5Pget_mcdt_search_cb * @@ -891,28 +880,27 @@ 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 */ - H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * plist; /* Property list pointer */ + H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x**x", plist_id, func, op_data); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_COPY))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback info */ - if(H5P_get(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) + if (H5P_get(plist, H5O_CPY_MCDT_SEARCH_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") - if(func) - *func = cb_info.func; + if (func) + *func = cb_info.func; - if(op_data) - *op_data = cb_info.user_data; + if (op_data) + *op_data = cb_info.user_data; done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_mcdt_search_cb() */ - diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index fa272874624..699d5f3e5d7 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,34 +23,33 @@ #error "Do not include this file outside the H5P package!" #endif -#ifndef _H5Ppkg_H -#define _H5Ppkg_H +#ifndef H5Ppkg_H +#define H5Ppkg_H /* Get package's private header */ #include "H5Pprivate.h" /* Other private headers needed by this file */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5SLprivate.h" /* Skip lists */ /**************************/ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ /* Define enum for type of object that property is within */ typedef enum { - H5P_PROP_WITHIN_UNKNOWN=0, /* Property container is unknown */ - H5P_PROP_WITHIN_LIST, /* Property is within a list */ - H5P_PROP_WITHIN_CLASS /* Property is within a class */ + H5P_PROP_WITHIN_UNKNOWN = 0, /* Property container is unknown */ + H5P_PROP_WITHIN_LIST, /* Property is within a list */ + H5P_PROP_WITHIN_CLASS /* Property is within a class */ } H5P_prop_within_t; /* Define enum for modifications to class */ typedef enum { - H5P_MOD_ERR=(-1), /* Indicate an error */ + H5P_MOD_ERR = (-1), /* Indicate an error */ H5P_MOD_INC_CLS, /* Increment the dependent class count*/ H5P_MOD_DEC_CLS, /* Decrement the dependent class count*/ H5P_MOD_INC_LST, /* Increment the dependent list count*/ @@ -63,54 +62,56 @@ typedef enum { /* Define structure to hold property information */ typedef struct H5P_genprop_t { /* Values for this property */ - char *name; /* Name of property */ - size_t size; /* Size of 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 */ + char * name; /* Name of property */ + size_t size; /* Size of 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 */ /* Callback function pointers & info */ - H5P_prp_create_func_t create; /* Function to call when a property is created */ - H5P_prp_set_func_t set; /* Function to call when a property value is set */ - H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */ - H5P_prp_encode_func_t encode; /* Function to call when a property is encoded */ - H5P_prp_decode_func_t decode; /* Function to call when a property is decoded */ - H5P_prp_delete_func_t del; /* Function to call when a property is deleted */ - H5P_prp_copy_func_t copy; /* Function to call when a property is copied */ - H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */ - H5P_prp_close_func_t close; /* Function to call when a property is closed */ + H5P_prp_create_func_t create; /* Function to call when a property is created */ + H5P_prp_set_func_t set; /* Function to call when a property value is set */ + H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */ + H5P_prp_encode_func_t encode; /* Function to call when a property is encoded */ + H5P_prp_decode_func_t decode; /* Function to call when a property is decoded */ + H5P_prp_delete_func_t del; /* Function to call when a property is deleted */ + H5P_prp_copy_func_t copy; /* Function to call when a property is copied */ + H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */ + H5P_prp_close_func_t close; /* Function to call when a property is closed */ } 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 */ - 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 */ - 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 */ + struct H5P_genclass_t *parent; /* Pointer to parent 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 */ + 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 */ /* 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 */ - 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 */ - 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 */ + 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 */ + 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 */ + 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 */ }; /* Define structure to hold property list information */ struct H5P_genplist_t { - H5P_genclass_t *pclass; /* Pointer to class info */ - 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 */ + H5P_genclass_t *pclass; /* Pointer to class info */ + 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 */ }; /* Property list/class iterator callback function pointer */ @@ -123,61 +124,55 @@ struct H5Z_filter_info_t; /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ /* Private functions, not part of the publicly documented API */ -H5_DLL H5P_genclass_t *H5P__create_class(H5P_genclass_t *par_class, - const char *name, H5P_plist_type_t type, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data); +H5_DLL H5P_genclass_t *H5P__create_class(H5P_genclass_t *par_class, const char *name, H5P_plist_type_t type, + H5P_cls_create_func_t cls_create, void *create_data, + H5P_cls_copy_func_t cls_copy, void *copy_data, + H5P_cls_close_func_t cls_close, void *close_data); H5_DLL H5P_genclass_t *H5P__copy_pclass(H5P_genclass_t *pclass); -H5_DLL herr_t H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, - const void *def_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); -H5_DLL herr_t H5P__register(H5P_genclass_t **pclass, const char *name, size_t size, - const void *def_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); +H5_DLL herr_t H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, const void *def_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); +H5_DLL herr_t H5P__register(H5P_genclass_t **pclass, const char *name, size_t size, const void *def_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); H5_DLL herr_t H5P__add_prop(H5SL_t *props, H5P_genprop_t *prop); H5_DLL herr_t H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod); +H5_DLL herr_t H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value); +H5_DLL herr_t H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value); H5_DLL htri_t H5P__exist_pclass(H5P_genclass_t *pclass, const char *name); -H5_DLL herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, - size_t *size); -H5_DLL herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, - size_t *size); +H5_DLL herr_t H5P__get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size); +H5_DLL herr_t H5P__get_size_pclass(H5P_genclass_t *pclass, const char *name, size_t *size); H5_DLL herr_t H5P__get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops); -H5_DLL int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); -H5_DLL herr_t H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, - int *cmp_ret); -H5_DLL int H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, - int *idx, H5P_iterate_int_t iter_func, void *iter_data); -H5_DLL int H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, - H5P_iterate_int_t iter_func, void *iter_data); +H5_DLL int H5P__cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); +H5_DLL herr_t H5P__cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2, int *cmp_ret); +H5_DLL int H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, + H5P_iterate_int_t iter_func, void *iter_data); +H5_DLL int H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, H5P_iterate_int_t iter_func, + void *iter_data); 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 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 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); -H5_DLL hid_t H5P__decode(const void *buf); +H5_DLL herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t *nalloc); +H5_DLL hid_t H5P__decode(const void *buf); H5_DLL herr_t H5P__encode_hsize_t(const void *value, void **_pp, size_t *size); H5_DLL herr_t H5P__encode_size_t(const void *value, void **_pp, size_t *size); H5_DLL herr_t H5P__encode_unsigned(const void *value, void **_pp, size_t *size); @@ -194,9 +189,8 @@ H5_DLL herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, siz H5_DLL herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *value); /* Private OCPL routines */ -H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, - unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], - size_t namelen, char name[], unsigned *filter_config); +H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, unsigned int *flags, size_t *cd_nelmts, + unsigned cd_values[], size_t namelen, char name[], unsigned *filter_config); /* Testing functions */ #ifdef H5P_TESTING @@ -204,5 +198,4 @@ H5_DLL char *H5P__get_class_path_test(hid_t pclass_id); H5_DLL hid_t H5P__open_class_path_test(const char *path); #endif /* H5P_TESTING */ -#endif /* _H5Ppkg_H */ - +#endif /* H5Ppkg_H */ diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 460e16b88c6..862c74f3180 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains private information about the H5P module */ -#ifndef _H5Pprivate_H -#define _H5Pprivate_H +#ifndef H5Pprivate_H +#define H5Pprivate_H /* Early typedefs to avoid circular dependencies */ typedef struct H5P_genplist_t H5P_genplist_t; @@ -24,92 +24,90 @@ typedef struct H5P_genplist_t H5P_genplist_t; #include "H5Ppublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ /**************************/ /* Library Private Macros */ /**************************/ /* ======== String creation property names ======== */ -#define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ +#define H5P_STRCRT_CHAR_ENCODING_NAME "character_encoding" /* Character set encoding for string */ /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5P_MODULE -#define H5P_PLIST_ID(P) ((P)->plist_id) -#define H5P_CLASS(P) ((P)->pclass) +#define H5P_PLIST_ID(P) ((P)->plist_id) +#define H5P_CLASS(P) ((P)->pclass) #else /* H5P_MODULE */ -#define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) -#define H5P_CLASS(P) (H5P_get_class(P)) +#define H5P_PLIST_ID(P) (H5P_get_plist_id(P)) +#define H5P_CLASS(P) (H5P_get_class(P)) #endif /* H5P_MODULE */ #define H5_COLL_MD_READ_FLAG_NAME "collective_metadata_read" - /****************************/ /* Library Private Typedefs */ /****************************/ typedef enum H5P_coll_md_read_flag_t { - H5P_FORCE_FALSE = -1, - H5P_USER_FALSE = 0, - H5P_USER_TRUE = 1 + H5P_FORCE_FALSE = -1, + H5P_USER_FALSE = 0, + H5P_USER_TRUE = 1 } H5P_coll_md_read_flag_t; /* Forward declarations for anonymous H5P objects */ typedef struct H5P_genclass_t H5P_genclass_t; typedef enum H5P_plist_type_t { - H5P_TYPE_USER = 0, - H5P_TYPE_ROOT = 1, - H5P_TYPE_OBJECT_CREATE = 2, - H5P_TYPE_FILE_CREATE = 3, - H5P_TYPE_FILE_ACCESS = 4, - H5P_TYPE_DATASET_CREATE = 5, - H5P_TYPE_DATASET_ACCESS = 6, - H5P_TYPE_DATASET_XFER = 7, - H5P_TYPE_FILE_MOUNT = 8, - H5P_TYPE_GROUP_CREATE = 9, - H5P_TYPE_GROUP_ACCESS = 10, - H5P_TYPE_DATATYPE_CREATE = 11, - H5P_TYPE_DATATYPE_ACCESS = 12, - H5P_TYPE_STRING_CREATE = 13, - H5P_TYPE_ATTRIBUTE_CREATE = 14, - H5P_TYPE_OBJECT_COPY = 15, - H5P_TYPE_LINK_CREATE = 16, - H5P_TYPE_LINK_ACCESS = 17, - H5P_TYPE_ATTRIBUTE_ACCESS = 18, + H5P_TYPE_USER = 0, + H5P_TYPE_ROOT = 1, + H5P_TYPE_OBJECT_CREATE = 2, + H5P_TYPE_FILE_CREATE = 3, + H5P_TYPE_FILE_ACCESS = 4, + H5P_TYPE_DATASET_CREATE = 5, + H5P_TYPE_DATASET_ACCESS = 6, + H5P_TYPE_DATASET_XFER = 7, + H5P_TYPE_FILE_MOUNT = 8, + H5P_TYPE_GROUP_CREATE = 9, + H5P_TYPE_GROUP_ACCESS = 10, + H5P_TYPE_DATATYPE_CREATE = 11, + H5P_TYPE_DATATYPE_ACCESS = 12, + H5P_TYPE_STRING_CREATE = 13, + H5P_TYPE_ATTRIBUTE_CREATE = 14, + H5P_TYPE_OBJECT_COPY = 15, + H5P_TYPE_LINK_CREATE = 16, + H5P_TYPE_LINK_ACCESS = 17, + H5P_TYPE_ATTRIBUTE_ACCESS = 18, + H5P_TYPE_VOL_INITIALIZE = 19, + H5P_TYPE_MAP_CREATE = 20, + H5P_TYPE_MAP_ACCESS = 21, + H5P_TYPE_REFERENCE_ACCESS = 22, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; /* Function pointer for library classes with properties to register */ typedef herr_t (*H5P_reg_prop_func_t)(H5P_genclass_t *pclass); -/* Move encode/decode callback typedefs from H5Ppublic.h: not exposed to user */ -/* Add a parameter to encode callback */ -typedef herr_t (*H5P_prp_encode_func_t)(const void *value, void **buf, size_t *size); -typedef herr_t (*H5P_prp_decode_func_t)(const void **buf, void *value); - /* * Each library property list class has a variable of this type that contains * class variables and methods used to initialize the class. */ typedef struct H5P_libclass_t { - const char *name; /* Class name */ - H5P_plist_type_t type; /* Class type */ + 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 */ - 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 */ + 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 */ - 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 */ - 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 */ + 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 */ + 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 */ + 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 */ } H5P_libclass_t; /*****************************/ @@ -129,6 +127,8 @@ H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_MAP_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_MAP_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_OBJECT_COPY_g; @@ -137,14 +137,15 @@ H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_STRING_CREATE_g; /* Internal property list classes */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ -H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LCRT[1]; /* Link creation */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_MACC[1]; /* Map access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ /******************************/ /* Library Private Prototypes */ @@ -153,49 +154,46 @@ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ /* Forward declaration of structs used below */ struct H5O_fill_t; struct H5T_t; +struct H5VL_connector_prop_t; /* Package initialization routine */ H5_DLL herr_t H5P_init(void); /* Internal versions of API routines */ H5_DLL herr_t H5P_close(void *_plist); -H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref); -H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref); +H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref); +H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref); H5_DLL herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value); H5_DLL herr_t H5P_peek(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_poke(H5P_genplist_t *plist, const char *name, const void *value); -H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, - void *value, 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); +H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, + 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); 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); -H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); +H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); +H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); -H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, - const void *new_driver_info); -H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, - H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, - void *free_info); -H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, - H5D_fill_value_t *status); -H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2, - size_t size); -H5_DLL herr_t H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned cd_values[]); -H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, - unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], - size_t namelen, char name[], unsigned *filter_config); +H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, const struct H5VL_connector_prop_t *vol_prop); +H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, + H5MM_free_t free_func, void *free_info); +H5_DLL herr_t H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *status); +H5_DLL int H5P_fill_value_cmp(const void *value1, const void *value2, size_t size); +H5_DLL herr_t H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned cd_values[]); +H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags, + size_t *cd_nelmts, unsigned cd_values[], size_t namelen, char name[], + unsigned *filter_config); H5_DLL htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id); -H5_DLL hid_t H5P_get_default(const H5P_libclass_t *pclass); /* Query internal fields of the property list struct */ H5_DLL hid_t H5P_get_plist_id(const H5P_genplist_t *plist); @@ -206,10 +204,9 @@ 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 */ -H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, - H5D_fill_value_t *status); -H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, - void *value); - -#endif /* _H5Pprivate_H */ +H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status); +H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, void *value); +H5_DLL int H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, + size_t H5_ATTR_UNUSED size); +#endif /* H5Pprivate_H */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index dbd07248154..5adb05e3f2b 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ * This file contains function prototypes for each exported function in the * H5P module. */ -#ifndef _H5Ppublic_H -#define _H5Ppublic_H +#ifndef H5Ppublic_H +#define H5Ppublic_H /* System headers needed by this file */ @@ -33,67 +33,74 @@ #include "H5Tpublic.h" #include "H5Zpublic.h" - /*****************/ /* Public Macros */ /*****************/ /* When this header is included from a private HDF5 header, don't make calls to H5open() */ #undef H5OPEN -#ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* H5private_H */ /* * The library's property list classes */ -#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) -#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) -#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) -#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) -#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) -#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) +#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) +#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) +#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE (H5OPEN H5P_CLS_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS (H5OPEN H5P_CLS_MAP_ACCESS_ID_g) +#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) +#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) +#define H5P_VOL_INITIALIZE (H5OPEN H5P_CLS_VOL_INITIALIZE_ID_g) +#define H5P_REFERENCE_ACCESS (H5OPEN H5P_CLS_REFERENCE_ACCESS_ID_g) /* * The library's default property lists */ -#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) -#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) -#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) +#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) +#define H5P_MAP_CREATE_DEFAULT (H5OPEN H5P_LST_MAP_CREATE_ID_g) +#define H5P_MAP_ACCESS_DEFAULT (H5OPEN H5P_LST_MAP_ACCESS_ID_g) +#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) +#define H5P_VOL_INITIALIZE_DEFAULT (H5OPEN H5P_LST_VOL_INITIALIZE_ID_g) +#define H5P_REFERENCE_ACCESS_DEFAULT (H5OPEN H5P_LST_REFERENCE_ACCESS_ID_g) /* Common creation order flags (for links in groups and attributes on objects) */ -#define H5P_CRT_ORDER_TRACKED 0x0001 -#define H5P_CRT_ORDER_INDEXED 0x0002 +#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 +#define H5P_DEFAULT (hid_t)0 #ifdef __cplusplus extern "C" { @@ -103,71 +110,145 @@ extern "C" { /* Public Typedefs */ /*******************/ - /* Define property list class callback function pointer types */ +//! typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); -typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, - void *copy_data); +//! + +//! +typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); +//! + +//! typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); +//! /* Define property list callback function pointer types */ +//! +/** + * \brief Callback function for H5Pregister2(),H5Pregister1(),H5Pinsert2(),H5Pinsert1() + * + * \param[in] name The name of the property + * \param[in] size The size of the property in bytes + * \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. + */ typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); +//! + +//! +/** + * \brief Callback function for H5Pregister2(),H5Pregister1(),H5Pinsert2(),H5Pinsert1() + * + * \plist_id{prop_id} + * \param[in] name The name of the property + * \param[in] size The size of the property in bytes + * \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. + */ typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, void *value); +//! + 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; +typedef herr_t (*H5P_prp_encode_func_t)(const void *value, void **buf, size_t *size); +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; + +//! typedef int (*H5P_prp_compare_func_t)(const void *value1, const void *value2, size_t size); +//! + typedef H5P_prp_cb1_t H5P_prp_close_func_t; /* Define property list iteration function type */ +//! typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); +//! -/* Actual IO mode property */ +//! +/** + * Actual IO mode property + * + * \details The default value, #H5D_MPIO_NO_CHUNK_OPTIMIZATION, is used for all + * I/O operations that do not use chunk optimizations, including + * non-collective I/O and contiguous collective I/O. + */ typedef enum H5D_mpio_actual_chunk_opt_mode_t { - /* The default value, H5D_MPIO_NO_CHUNK_OPTIMIZATION, is used for all I/O - * operations that do not use chunk optimizations, including non-collective - * I/O and contiguous collective I/O. - */ H5D_MPIO_NO_CHUNK_OPTIMIZATION = 0, + /**< No chunk optimization was performed. Either no collective I/O was + attempted or the dataset wasn't chunked. */ H5D_MPIO_LINK_CHUNK, + /**< Collective I/O is performed on all chunks simultaneously. */ H5D_MPIO_MULTI_CHUNK -} H5D_mpio_actual_chunk_opt_mode_t; + /**< Each chunk was individually assigned collective or independent I/O based + on what fraction of processes access the chunk. If the fraction is greater + than the multi chunk ratio threshold, collective I/O is performed on that + chunk. The multi chunk ratio threshold can be set using + H5Pset_dxpl_mpio_chunk_opt_ratio(). The default value is 60%. */ +} H5D_mpio_actual_chunk_opt_mode_t; +//! +//! +/** + * The following values are conveniently defined as a bit field so that + * we can switch from the default to independent or collective and then to + * mixed without having to check the original value. + */ typedef enum H5D_mpio_actual_io_mode_t { - /* The following four values are conveniently defined as a bit field so that - * we can switch from the default to independent or collective and then to - * mixed without having to check the original value. - * - * NO_COLLECTIVE means that either collective I/O wasn't requested or that - * no I/O took place. - * - * CHUNK_INDEPENDENT means that collective I/O was requested, but the - * chunk optimization scheme chose independent I/O for each chunk. - */ H5D_MPIO_NO_COLLECTIVE = 0x0, + /**< No collective I/O was performed. Collective I/O was not requested or + collective I/O isn't possible on this dataset */ H5D_MPIO_CHUNK_INDEPENDENT = 0x1, + /**< HDF5 performed one the chunk collective optimization schemes and each + chunk was accessed independently */ H5D_MPIO_CHUNK_COLLECTIVE = 0x2, + /**< HDF5 performed one the chunk collective optimization schemes and each + chunk was accessed collectively */ H5D_MPIO_CHUNK_MIXED = 0x1 | 0x2, - - /* The contiguous case is separate from the bit field. */ + /**< HDF5 performed one the chunk collective optimization schemes and some + chunks were accessed independently, some collectively. */ + /** \internal The contiguous case is separate from the bit field. */ H5D_MPIO_CONTIGUOUS_COLLECTIVE = 0x4 + /**< Collective I/O was performed on a contiguous dataset */ } H5D_mpio_actual_io_mode_t; +//! -/* Broken collective IO property */ +//! +/** + * Broken collective IO property + */ typedef enum H5D_mpio_no_collective_cause_t { H5D_MPIO_COLLECTIVE = 0x00, + /**< Collective I/O was performed successfully */ H5D_MPIO_SET_INDEPENDENT = 0x01, + /**< Collective I/O was not performed because independent I/O was requested */ H5D_MPIO_DATATYPE_CONVERSION = 0x02, + /**< Collective I/O was not performed because datatype conversions were required */ 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! */ 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! */ H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE = 0x80, + /**< \todo FIXME! */ H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE = 0x100 + /**< Sentinel */ } H5D_mpio_no_collective_cause_t; +//! /********************/ /* Public Variables */ @@ -187,12 +268,16 @@ H5_DLLVAR hid_t H5P_CLS_GROUP_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_GROUP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_CLS_MAP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_MAP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_STRING_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g; 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 */ /* (Internal to library, do not use! Use macros above) */ @@ -206,307 +291,8967 @@ H5_DLLVAR hid_t H5P_LST_GROUP_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_MAP_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_MAP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g; +H5_DLLVAR hid_t H5P_LST_VOL_INITIALIZE_ID_g; +H5_DLLVAR hid_t H5P_LST_REFERENCE_ACCESS_ID_g; /*********************/ /* Public Prototypes */ /*********************/ /* Generic property list routines */ -H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, - H5P_cls_create_func_t cls_create, void *create_data, - H5P_cls_copy_func_t cls_copy, void *copy_data, - H5P_cls_close_func_t cls_close, void *close_data); -H5_DLL char *H5Pget_class_name(hid_t pclass_id); + +/** + * \ingroup GPLO + * + * \brief Terminates access to a property list + * + * \plist_id + * + * \return \herr_t + * + * \details H5Pclose() terminates access to a property list. All property + * lists should be closed when the application is finished + * accessing them. This frees resources used by the property + * list. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pclose(hid_t plist_id); +/** + * \ingroup GPLOA + * + * \brief Closes an existing property list class + * + * \plistcls_id{plist_id} + * + * \return \herr_t + * + * \details H5Pclose_class() removes a property list class from the library. + * Existing property lists of this class will continue to exist, + * but new ones are not able to be created. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pclose_class(hid_t plist_id); +/** + * \ingroup GPLO + * + * \brief Copies an existing property list to create a new property list + * + * \plist_id + * + * \return \hid_t{property list} + * + * \details H5Pcopy() copies an existing property list to create a new + * property list. The new property list has the same properties + * and values as the original property list. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Pcopy(hid_t plist_id); +/** + * \ingroup GPLOA + * + * \brief Copies a property from one list or class to another + * + * \param[in] dst_id Identifier of the destination property list or class + * \param[in] src_id Identifier of the source property list or class + * \param[in] name Name of the property to copy + * + * \return \herr_t + * + * \details H5Pcopy_prop() copies a property from one property list or + * class to another. + * + * If a property is copied from one class to another, all the + * property information will be first deleted from the destination + * class and then the property information will be copied from the + * source class into the destination class. + * + * If a property is copied from one list to another, the property + * will be first deleted from the destination list (generating a + * call to the close callback for the property, if one exists) + * and then the property is copied from the source list to the + * destination list (generating a call to the copy callback for + * the property, if one exists). + * + * If the property does not exist in the class or list, this + * call is equivalent to calling H5Pregister() or H5Pinsert() (for + * a class or list, as appropriate) and the create callback will + * be called in the case of the property being copied into a list + * (if such a callback exists for the property). + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); +/** + * \ingroup GPLO + * + * \brief Creates a new property list as an instance of a property list class + * + * \plistcls_id{cls_id} + * + * \return \hid_t{property list} + * + * \details H5Pcreate() creates a new property list as an instance of + * some property list class. The new property list is initialized + * with default values for the specified class. The classes are as + * follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Class IdentifierClass NameComments
#H5P_ATTRIBUTE_CREATEattribute createProperties for attribute creation
#H5P_DATASET_ACCESSdataset accessProperties for dataset access
#H5P_DATASET_CREATEdataset createProperties for dataset creation
#H5P_DATASET_XFERdata transferProperties for raw data transfer
#H5P_DATATYPE_ACCESSdatatype accessProperties for datatype access
#H5P_DATATYPE_CREATEdatatype createProperties for datatype creation
#H5P_FILE_ACCESSfile accessProperties for file access
#H5P_FILE_CREATEfile createProperties for file creation
#H5P_FILE_MOUNTfile mountProperties for file mounting
#H5P_GROUP_ACCESSgroup accessProperties for group access
#H5P_GROUP_CREATEgroup createProperties for group creation
#H5P_LINK_ACCESSlink accessProperties governing link traversal when accessing objects
#H5P_LINK_CREATElink createProperties governing link creation
#H5P_OBJECT_COPYobject copyProperties governing the object copying process
#H5P_OBJECT_CREATEobject createProperties for object creation
#H5P_STRING_CREATEstring createProperties for character encoding when encoding strings or + * object names
#H5P_VOL_INITIALIZEvol initializeProperties for VOL initialization
+ * + * This property list must eventually be closed with H5Pclose(); + * otherwise, errors are likely to occur. + * + * \version 1.12.0 The #H5P_VOL_INITIALIZE property list class was added + * \version 1.8.15 For each class, the class name returned by + * H5Pget_class_name() was added. + * The list of possible Fortran values was updated. + * \version 1.8.0 The following property list classes were added at this + * release: #H5P_DATASET_ACCESS, #H5P_GROUP_CREATE, + * #H5P_GROUP_ACCESS, #H5P_DATATYPE_CREATE, + * #H5P_DATATYPE_ACCESS, #H5P_ATTRIBUTE_CREATE + * + * \since 1.0.0 + * + */ H5_DLL hid_t H5Pcreate(hid_t cls_id); -H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, - void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, - H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t prp_copy, - H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5Pinsert2(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_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); +/** + * \ingroup GPLOA + * + * \brief Creates a new property list class + * + * \plistcls_id{parent} + * \param[in] name Name of property list class to register + * \param[in] create Callback routine called when a property list is + * created + * \param[in] create_data Pointer to user-defined class create data, to be + * passed along to class create callback + * \param[in] copy Callback routine called when a property list is + * copied + * \param[in] copy_data Pointer to user-defined class copy data, to be + * passed along to class copy callback + * \param[in] close Callback routine called when a property list is + * being closed + * \param[in] close_data Pointer to user-defined class close data, to be + * passed along to class close callback + * + * \return \hid_t{property list class} + * + * \details H5Pcreate_class() registers a new property list class with the + * library. The new property list class can inherit from an + * existing property list class, \p parent, or may be derived + * from the default “empty” class, NULL. New classes with + * inherited properties from existing classes may not remove + * 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. + * + * 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. + * + * \since 1.4.0 + * + */ +H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t create, void *create_data, + H5P_cls_copy_func_t copy, void *copy_data, H5P_cls_close_func_t close, + void *close_data); +/** + * \ingroup GPLO + * + * \brief Decodes property list received in a binary object buffer and + * returns a new property list identifier + * + * \param[in] buf Buffer holding the encoded property list + * + * \return \hid_tv{object} + * + * \details Given a binary property list description in a buffer, H5Pdecode() + * reconstructs the HDF5 property list and returns an identifier + * for the new property list. The binary description of the property + * list is encoded by H5Pencode(). + * + * The user is responsible for passing in the correct buffer. + * + * The property list identifier returned by this function should be + * released with H5Pclose() when the identifier is no longer needed + * so that resource leaks will not develop. + * + * \note Some properties cannot be encoded and therefore will not be available + * in the decoded property list. These properties are discussed in + * H5Pencode(). + * + * \since 1.10.0 + * + */ +H5_DLL hid_t H5Pdecode(const void *buf); +/** + * \ingroup GPLO + * + * \brief Encodes the property values in a property list into a binary + * buffer + * + * \plist_id + * \param[out] buf Buffer into which the property list will be encoded. + * If the provided buffer is NULL, the size of the + * buffer required is returned through \p nalloc; the + * function does nothing more. + * \param[out] nalloc The size of the required buffer + * \fapl_id + * + * \return \herr_t + * + * \details H5Pencode2() encodes the property list \p plist_id into the + * binary buffer \p buf, according to the file format setting + * specified by the file access property list \p fapl_id. + * + * If the required buffer size is unknown, \p buf can be passed + * in as NULL and the function will set the required buffer size + * in \p nalloc. The buffer can then be created and the property + * list encoded with a subsequent H5Pencode2() call. + * + * If the buffer passed in is not big enough to hold the encoded + * properties, the H5Pencode2() call can be expected to fail with + * a segmentation fault. + * + * The file access property list \p fapl_id is used to + * control the encoding via the \a libver_bounds property + * (see H5Pset_libver_bounds()). If the \a libver_bounds + * property is missing, H5Pencode2() proceeds as if the \a + * libver_bounds property were set to (#H5F_LIBVER_EARLIEST, + * #H5F_LIBVER_LATEST). (Functionally, H5Pencode1() is identical to + * H5Pencode2() with \a libver_bounds set to (#H5F_LIBVER_EARLIEST, + * #H5F_LIBVER_LATEST).) + * Properties that do not have encode callbacks will be skipped. + * There is currently no mechanism to register an encode callback for + * a user-defined property, so user-defined properties cannot currently + * be encoded. + * + * Some properties cannot be encoded, particularly properties that are + * reliant on local context. + * + * \b Motivation: + * This function was introduced in HDF5-1.12 as part of the \a H5Sencode + * format change to enable 64-bit selection encodings and a dataspace + * selection that is tied to a file. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id); +/** + * \ingroup GPLOA + * + * \brief Compares two property lists or classes for equality + * + * \param[in] id1 First property object to be compared + * \param[in] id2 Second property object to be compared + * + * \return \htri_t + * + * \details H5Pequal() compares two property lists or classes to determine + * whether they are equal to one another. + * + * Either both \p id1 and \p id2 must be property lists or both + * must be classes; comparing a list to a class is an error. + * + * \since 1.4.0 + * + */ +H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); +/** + * \ingroup GPLOA + * + * \brief Queries whether a property name exists in a property list or + * class + * + * \param[in] plist_id Identifier for the property list or class to query + * \param[in] name Name of property to check for + * + * \return \htri_t + * + * \details H5Pexist() determines whether a property exists within a + * property list or class. + * + * \since 1.4.0 + * + */ H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); -H5_DLL herr_t H5Pencode(hid_t plist_id, void *buf, size_t *nalloc); -H5_DLL hid_t H5Pdecode(const void *buf); -H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); -H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); +/** + * \ingroup GPLOA + * + * \brief Queries the value of a property + * + * \plist_id + * \param[in] name Name of property to query + * \param[out] value Pointer to a location to which to copy the value of + * the property + * + * \return \herr_t + * + * \details H5Pget() retrieves a copy of the value for a property in a + * property list. If there is a \p get callback routine registered + * for this property, the copy of the value of the property will + * first be passed to that routine and any changes to the copy of + * the value will be used when returning the property value from + * this routine. + * + * This routine may be called for zero-sized properties with the + * \p value set to NULL. The \p get routine will be called with + * a NULL value if the callback exists. + * + * The property name must exist or this routine will fail. + * + * If the \p get callback routine returns an error, \ value will + * not be modified. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void *value); +/** + *\ingroup GPLO + * + * \brief Returns the property list class identifier for a property list + * + * \plist_id + * + * \return \hid_t{property list class} + * + * \details H5Pget_class() returns the property list class identifier for + * the property list identified by the \p plist_id parameter. + * + * Note that H5Pget_class() returns a value of #hid_t type, an + * internal HDF5 identifier, rather than directly returning a + * property list class. That identifier can then be used with + * either H5Pequal() or H5Pget_class_name() to determine which + * predefined HDF5 property list class H5Pget_class() has returned. + * + * A full list of valid predefined property list classes appears + * in the description of H5Pcreate(). + * + * Determining the HDF5 property list class name with H5Pequal() + * requires a series of H5Pequal() calls in an if-else sequence. + * An iterative sequence of H5Pequal() calls can compare the + * identifier returned by H5Pget_class() to members of the list of + * valid property list class names. A pseudo-code snippet might + * read as follows: + * + * \code + * plist_class_id = H5Pget_class (dsetA_plist); + * + * if H5Pequal (plist_class_id, H5P_OBJECT_CREATE) = TRUE; + * [ H5P_OBJECT_CREATE is the property list class ] + * [ returned by H5Pget_class. ] + * + * else if H5Pequal (plist_class_id, H5P_DATASET_CREATE) = TRUE; + * [ H5P_DATASET_CREATE is the property list class. ] + * + * else if H5Pequal (plist_class_id, H5P_DATASET_XFER) = TRUE; + * [ H5P_DATASET_XFER is the property list class. ] + * + * . + * . [ Continuing the iteration until a match is found. ] + * . + * \endcode + * + * H5Pget_class_name() returns the property list class name directly + * as a string: + * + * \code + * plist_class_id = H5Pget_class (dsetA_plist); + * plist_class_name = H5Pget_class_name (plist_class_id) + * \endcode + * + * Note that frequent use of H5Pget_class_name() can become a + * performance problem in a high-performance environment. The + * H5Pequal() approach is generally much faster. + * + * \version 1.6.0 Return type changed in this release. + * \since 1.0.0 + * + */ H5_DLL hid_t H5Pget_class(hid_t plist_id); +/** + * \ingroup GPLOA + * + * \brief Retrieves the name of a class + * + * \plistcls_id{pclass_id} + * + * \return Returns a pointer to an allocated string containing the class + * name if successful, and NULL if not successful. + * + * \details H5Pget_class_name() retrieves the name of a generic property + * list class. The pointer to the name must be freed by the user + * with a call to H5free_memory() after each successful call. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Class Name (class identifier) ReturnedProperty List ClassExpanded Name of the Property List ClassThe Class Identifier Used with H5PcreateComments
attribute createacplAttribute Creation Property ListH5P_ATTRIBUTE_CREATE
dataset accessdaplDataset Access Property ListH5P_DATASET_ACCESS
dataset createdcplDataset Creation Property ListH5P_DATASET_CREATE
data transferdxplData Transfer Property ListH5P_DATASET_XFER
datatype access H5P_DATATYPE_ACCESSThis class can be created, but there are no properties + * in the class currently. + *
datatype create H5P_DATATYPE_CREATEThis class can be created, but there + * are no properties in the class currently.
file accessfaplFile Access Property ListH5P_FILE_ACCESS
file createfcplFile Creation Property ListH5P_FILE_CREATE
file mountfmplFile Mount Property ListH5P_FILE_MOUNT
group access H5P_GROUP_ACCESSThis class can be created, but there + * are no properties in the class currently.
group creategcplGroup Creation Property ListH5P_GROUP_CREATE
link accesslaplLink Access Property ListH5P_LINK_ACCESS
link createlcplLink Creation Property ListH5P_LINK_CREATE
object copyocpyplObject Copy Property ListH5P_OBJECT_COPY
object createocplObject Creation Property ListH5P_OBJECT_CREATE
string createstrcplString Creation Property ListH5P_STRING_CREATE
+ * + * \since 1.4.0 + * + */ +H5_DLL char *H5Pget_class_name(hid_t pclass_id); +/** + * \ingroup GPLOA + * + * \brief Retrieves the parent class of a property class + * + * \plistcls_id{pclass_id} + * + * \return \hid_t{parent class object} + * + * \details H5Pget_class_parent() retrieves an identifier for the parent + * class of a property class. + * + * \since 1.4.0 + * + */ H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); -H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void * value); -H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); +/** + * \ingroup GPLOA + * + * \brief Queries the number of properties in a property list or class + * + * \param[in] id Identifier for property object to query + * \param[out] nprops Number of properties in object + * + * \return \herr_t + * + * \details H5Pget_nprops() retrieves the number of properties in a + * property list or property list class. + * + * If \p id is a property list identifier, the current number of + * properties in the list is returned in \p nprops. + * + * If \p id is a property list class identifier, the number of + * registered properties in the class is returned in \p nprops. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); +/** + * \ingroup GPLOA + * + * \brief Queries the size of a property value in bytes + * + * \param[in] id Identifier of property object to query + * \param[in] name Name of property to query + * \param[out] size Size of property in bytes + * + * \return \herr_t + * + * \details H5Pget_size() retrieves the size of a property's value in + * bytes. This function operates on both property lists and + * property classes. + * + * Zero-sized properties are allowed and return 0. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); +/** + * \ingroup GPLOA + * + * \brief Registers a temporary property with a property list + * + * \plist_id + * \param[in] name Name of property to create + * \param[in] size Size of property in bytes + * \param[in] value Initial value for the property + * \param[in] set Callback routine called before a new value is copied + * into the property's value + * \param[in] get Callback routine called when a property value is + * retrieved from the property + * \param[in] prp_del Callback routine called when a property is deleted + * from a property list + * \param[in] copy Callback routine called when a property is copied + * from an existing property list + * \param[in] compare Callback routine called when a property is compared + * with another property list + * \param[in] close Callback routine called when a property list is + * being closed and the property value will be disposed + * of + * + * \return \herr_t + * + * \details H5Pinsert2() creates a new property in a property + * list. The property will exist only in this property list and + * copies made from it. + * + * The initial property value must be provided in \p value and + * the property value will be set accordingly. + * + * The name of the property must not already exist in this list, + * or this routine will fail. + * + * The \p set and \p get callback routines may be set to NULL + * if they are not needed. + * + * Zero-sized properties are allowed and do not store any data + * in the property list. The default value of a zero-size + * property may be set to NULL. They may be used to indicate the + * presence or absence of a particular piece of information. + * + * The \p set routine is called before a new value is copied + * into the property. The #H5P_prp_set_func_t callback function + * is defined as follows: + * \snippet this H5P_prp_cb2_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\ref hid_t \c prop_idIN: The identifier of the property list being + * modified
\Code{const char * name}IN: The name of the property being modified
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: Pointer to new value pointer for the property + * being modified
+ * + * The \p set routine may modify the value pointer to be set and + * those changes will be used when setting the property's value. + * If the \p set routine returns a negative value, the new property + * value is not copied into the property and the \p set routine + * returns an error value. The \p set routine will be called for + * the initial value. + * + * \b Note: The \p set callback function may be useful to range + * check the value being set for the property or may perform some + * transformation or translation of the value set. The \p get + * callback would then reverse the transformation or translation. + * A single \p get or \p set callback could handle multiple + * properties by performing different actions based on the + * property name or other properties in the property list. + * + * The \p get routine is called when a value is retrieved from + * a property value. The #H5P_prp_get_func_t callback function + * is defined as follows: + * + * \snippet this H5P_prp_cb2_t_snip + * + * The parameters to the above callback function are: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\ref hid_t \c prop_idIN: The identifier of the property list being queried
\Code{const char * name}IN: The name of the property being queried
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: The value of the property being returned
+ * + * The \p get routine may modify the value to be returned from + * the query and those changes will be preserved. If the \p get + * routine returns a negative value, the query routine returns + * an error value. + * + * The \p prp_del routine is called when a property is being + * deleted from a property list. The #H5P_prp_delete_func_t + * callback function is defined as follows: + * + * \snippet this H5P_prp_cb2_t_snip + * + * The parameters to the above callback function are: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\ref hid_t \c prop_idIN: The identifier of the property list the property is + * being deleted from
\Code{const char * name}IN: The name of the property in the list
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: The value for the property being deleted
+ * + * The \p prp_del routine may modify the value passed in, but the + * value is not used by the library when the \p prp_del routine + * returns. If the \p prp_del routine returns a negative value, + * the property list \p prp_del routine returns an error value but + * the property is still deleted. + * + * The \p copy routine is called when a new property list with + * this property is being created through a \p copy operation. + * + * The #H5P_prp_copy_func_t callback function is defined as follows: + * + * \snippet this H5P_prp_cb1_t_snip + * + * The parameters to the above callback function are: + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const char * name}IN: The name of the property being copied
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN/OUT: The value for the property being copied
+ * + * The \p copy routine may modify the value to be set and those + * changes will be stored as the new value of the property. If the + * \p copy routine returns a negative value, the new property value + * is not copied into the property and the copy routine returns an + * error value. + * + * The \p compare routine is called when a property list with this + * property is compared to another property list with the same + * property. + * + * The #H5P_prp_compare_func_t callback function is defined as + * follows: + * + * \snippet this H5P_prp_compare_func_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const void * value1}IN: The value of the first property to compare
\Code{const void * value2}IN: The value of the second property to compare
\Code{size_t size}IN: The size of the property in bytes
+ * + * The \p compare routine may not modify the values. The \p compare + * routine should return a positive value if \p value1 is greater + * than \p value2, a negative value if \p value2 is greater than + * \p value1 and zero if \p value1 and \p value2 are equal. + * + * The \p close routine is called when a property list with this + * property is being closed. + * + * The #H5P_prp_close_func_t callback function is defined as follows: + * \snippet this H5P_prp_cb1_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const char * name}IN: The name of the property in the list
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: The value for the property being closed
+ * + * The \p close routine may modify the value passed in, the + * value is not used by the library when the close routine + * returns. If the \p close routine returns a negative value, + * the property list \p close routine returns an error value + * but the property list is still closed. + * + * \b Note: There is no \p create callback routine for temporary + * property list objects; the initial value is assumed to + * have any necessary setup already performed on it. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t set, + 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 + * + * \brief Determines whether a property list is a member of a class + * + * \plist_id + * \plistcls_id{pclass_id} + * + * \return \htri_t + * + * \details H5Pisa_class() checks to determine whether the property list + * \p plist_id is a member of the property list class + * \p pclass_id. + * + * \see H5Pcreate() + * + * \since 1.6.0 + * + */ 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); -H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); -H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); -H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); -H5_DLL herr_t H5Pclose_class(hid_t plist_id); -H5_DLL herr_t H5Pclose(hid_t plist_id); -H5_DLL hid_t H5Pcopy(hid_t plist_id); - -/* Object creation property list (OCPL) routines */ -H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); -H5_DLL herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense); -H5_DLL herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags); -H5_DLL herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags); -H5_DLL herr_t H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times); -H5_DLL herr_t H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times); -H5_DLL herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[/*cd_nelmts*/]); -H5_DLL herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, - unsigned int flags, size_t cd_nelmts, - const unsigned int c_values[]); -H5_DLL int H5Pget_nfilters(hid_t plist_id); -H5_DLL H5Z_filter_t H5Pget_filter2(hid_t plist_id, unsigned filter, - unsigned int *flags/*out*/, - size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, - size_t namelen, char name[], - unsigned *filter_config /*out*/); -H5_DLL herr_t H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t id, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/, - unsigned *filter_config/*out*/); -H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); -H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); -H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned aggression); -H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); +/** + * \ingroup GPLOA + * + * \brief Iterates over properties in a property class or list + * + * \param[in] id Identifier of property object to iterate over + * \param[in,out] idx Index of the property to begin with + * \param[in] iter_func Function pointer to function to be called + * with each property iterated over + * \param[in,out] iter_data Pointer to iteration data from user + * + * \return On success: the return value of the last call to \p iter_func if + * it was non-zero; zero if all properties have been processed. + * On Failure, a negative value + * + * \details H5Piterate() iterates over the properties in the property + * object specified in \p id, which may be either a property + * list or a property class, performing a specified operation + * on each property in turn. + * + * For each property in the object, \p iter_func and the + * additional information specified below are passed to the + * #H5P_iterate_t operator function. + * + * The iteration begins with the \p idx-th property in the + * object; the next element to be processed by the operator + * is returned in \p idx. If \p idx is NULL, the iterator + * starts at the first property; 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 the #H5P_iterate_t operator is as follows: + * \snippet this H5P_iterate_t_snip + * + * The operation 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: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
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 + * behavior is undefined. + * + * \since 1.4.0 + * + */ +H5_DLL int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data); +/** + * \ingroup GPLOA + * + * \brief Registers a permanent property with a property list class + * + * \plistcls_id{cls_id} + * \param[in] name Name of property to register + * \param[in] size Size of property in bytes + * \param[in] def_value Default value for property in newly created + * property lists + * \param[in] create Callback routine called when a property list is + * being created and the property value will be + * initialized + * \param[in] set Callback routine called before a new value is + * copied into the property's value + * \param[in] get Callback routine called when a property value is + * retrieved from the property + * \param[in] prp_del Callback routine called when a property is deleted + * from a property list + * \param[in] copy Callback routine called when a property is copied + * from a property list + * \param[in] compare Callback routine called when a property is compared + * with another property list + * \param[in] close Callback routine called when a property list is + * being closed and the property value will be + * disposed of + * + * \return \herr_t + * + * \details H5Pregister2() registers a new property with a property list + * class. The \p cls_id identifier can be obtained by calling + * H5Pcreate_class(). The property will exist in all property + * list objects of \p cl_id created after this routine finishes. The + * name of the property must not already exist, or this routine + * will fail. The default property value must be provided and all + * new property lists created with this property will have the + * property value set to the default value. Any of the callback + * routines may be set to NULL if they are not needed. + * + * Zero-sized properties are allowed and do not store any data in + * the property list. These may be used as flags to indicate the + * presence or absence of a particular piece of information. The + * default pointer for a zero-sized property may be set to NULL. + * The property \p create and \p close callbacks are called for + * zero-sized properties, but the \p set and \p get callbacks are + * never called. + * + * The \p create routine is called when a new property list with + * this property is being created. The #H5P_prp_create_func_t + * callback function is defined as follows: + * + * \snippet this H5P_prp_cb1_t_snip + * + * The parameters to this callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const char * name}IN: The name of the property being modified
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN/OUT: The default value for the property being created, + * which will be passed to H5Pregister2()
+ * + * The \p create routine may modify the value to be set and those + * changes will be stored as the initial value of the property. + * If the \p create routine returns a negative value, the new + * property value is not copied into the property and the + * \p create routine returns an error value. + * + * The \p set routine is called before a new value is copied into + * the property. The #H5P_prp_set_func_t callback function is defined + * as follows: + * + * \snippet this H5P_prp_cb2_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 modified
\Code{const char * name}IN: The name of the property being modified
\Code{size_t size}IN: The size of the property in bytes
\Code{void *value}IN/OUT: Pointer to new value pointer for the property + * being modified
+ * + * The \p set routine may modify the value pointer to be set and + * those changes will be used when setting the property's value. + * If the \p set routine returns a negative value, the new property + * value is not copied into the property and the \p set routine + * returns an error value. The \p set routine will not be called + * for the initial value; only the \p create routine will be called. + * + * \b Note: The \p set callback function may be useful to range + * check the value being set for the property or may perform some + * transformation or translation of the value set. The \p get + * callback would then reverse the transformation or translation. + * A single \p get or \p set callback could handle multiple + * properties by performing different actions based on the property + * name or other properties in the property list. + * + * The \p get routine is called when a value is retrieved from a + * property value. The #H5P_prp_get_func_t callback function is + * defined as follows: + * + * \snippet this H5P_prp_cb2_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\ref hid_t \c prop_idIN: The identifier of the property list being + * queried
\Code{const char * name}IN: The name of the property being queried
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN/OUT: The value of the property being returned
+ * + * The \p get routine may modify the value to be returned from the + * query and those changes will be returned to the calling routine. + * If the \p set routine returns a negative value, the query + * routine returns an error value. + * + * The \p prp_del routine is called when a property is being + * deleted from a property list. The #H5P_prp_delete_func_t + * callback function is defined as follows: + * + * \snippet this H5P_prp_cb2_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\ref hid_t \c prop_idIN: The identifier of the property list the property is + * being deleted from
\Code{const char * name}IN: The name of the property in the list
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: The value for the property being deleted
+ * + * The \p prp_del routine may modify the value passed in, but the + * value is not used by the library when the \p prp_del routine + * returns. If the \p prp_del routine returns a negative value, + * the property list delete routine returns an error value but + * the property is still deleted. + * + * The \p copy routine is called when a new property list with + * this property is being created through a \p copy operation. + * The #H5P_prp_copy_func_t callback function is defined as follows: + * + * \snippet this H5P_prp_cb1_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const char * name}IN: The name of the property being copied
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN/OUT: The value for the property being copied
+ * + * The \p copy routine may modify the value to be set and those + * changes will be stored as the new value of the property. If + * the \p copy routine returns a negative value, the new + * property value is not copied into the property and the \p copy + * routine returns an error value. + * + * The \p compare routine is called when a property list with this + * property is compared to another property list with the same + * property. The #H5P_prp_compare_func_t callback function is + * defined as follows: + * + * \snippet this H5P_prp_compare_func_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const void * value1}IN: The value of the first property to compare
\Code{const void * value2}IN: The value of the second property to compare
\Code{size_t size}IN: The size of the property in bytes
+ * + * The \p compare routine may not modify the values. The \p compare + * routine should return a positive value if \p value1 is greater + * than \p value2, a negative value if \p value2 is greater than + * \p value1 and zero if \p value1 and \p value2 are equal. + * + * The \p close routine is called when a property list with this + * property is being closed. The #H5P_prp_close_func_t callback + * function is defined as follows: + * + * \snippet this H5P_prp_cb1_t_snip + * + * The parameters to the callback function are defined as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\Code{const char * name}IN: The name of the property in the list
\Code{size_t size}IN: The size of the property in bytes
\Code{void * value}IN: The value for the property being closed
+ * + * The \p close routine may modify the value passed in, but the + * value is not used by the library when the \p close routine returns. + * 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. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, + H5P_prp_create_func_t create, H5P_prp_set_func_t set, 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 + * + * \brief Removes a property from a property list + * + * \plist_id + * \param[in] name Name of property to remove + * + * \return \herr_t + * + * \details H5Premove() removes a property from a property list. Both + * properties which were in existence when the property list was + * created (i.e. properties registered with H5Pregister()) and + * properties added to the list after it was created (i.e. added + * with H5Pinsert1() may be removed from a property list. + * Properties do not need to be removed from a property list + * before the list itself is closed; they will be released + * automatically when H5Pclose() is called. + * + * If a \p close callback exists for the removed property, it + * will be called before the property is released. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); +/** + * \ingroup GPLOA + * + * \brief Sets a property list value + * + * \plist_id + * \param[in] name Name of property to modify + * \param[in] value Pointer to value to set the property to + * + * \return \herr_t + * + * \details H5Pset() sets a new value for a property in a property list. + * If there is a \p set callback routine registered for this + * property, the \p value will be passed to that routine and any + * changes to the \p value will be used when setting the property + * value. The information pointed to by the \p value pointer + * (possibly modified by the \p set callback) is copied into the + * property list value and may be changed by the application + * making the H5Pset() call without affecting the property value. + * + * The property name must exist or this routine will fail. + * + * If the \p set callback routine returns an error, the property + * value will not be modified. + * + * This routine may not be called for zero-sized properties and + * will return an error in that case. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); +/** + * \ingroup GPLOA + * + * \brief Removes a property from a property list class + * + * \plistcls_id{pclass_id} + * \param[in] name Name of property to remove + * + * \return \herr_t + * + * \details H5Punregister() removes a property from a property list class. + * Future property lists created of that class will not contain + * this property; existing property lists containing this property + * are not affected. + * + * \since 1.4.0 + * + */ +H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); + +/* Object creation property list (OCPL) routines */ + +/** + * \ingroup DCPL + * + * \brief Verifies that all required filters are available + * + * \plist_id + * + * \return \htri_t + * + * \details H5Pall_filters_avail() verifies that all of the filters set in + * the dataset or group creation property list \p plist_id are + * currently available. + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \since 1.6.0 + * + */ +H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); +/** + * \ingroup OCPL + * + * \brief Retrieves tracking and indexing settings for attribute creation + * order + * + * \plist_id + * \param[out] crt_order_flags Flags specifying whether to track and + * index attribute creation order + * + * \return \herr_t + * + * \details H5Pget_attr_creation_order() retrieves the settings for + * tracking and indexing attribute creation order on an object. + * + * \p plist_id is an object creation property list (\p ocpl), + * as it can be a dataset or group creation property list + * identifier. The term \p ocpl is used when different types + * of objects may be involved. + * + * \p crt_order_flags returns flags with the following meanings: + * + * + * + * + * + * + * + * + * + * + *
#H5P_CRT_ORDER_TRACKEDAttribute creation order is tracked but not necessarily + * indexed.
#H5P_CRT_ORDER_INDEXED Attribute creation order is indexed (requires + * #H5P_CRT_ORDER_TRACKED).
+ * + * If \p crt_order_flags is returned with a value of 0 (zero), + * attribute creation order is neither tracked nor indexed. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_attr_creation_order(hid_t plist_id, unsigned *crt_order_flags); +/** + * \ingroup OCPL + * + * \brief Retrieves attribute storage phase change thresholds + * + * \plist_id + * \param[out] max_compact Maximum number of attributes to be stored in + * compact storage (Default: 8) + * \param[out] min_dense Minimum number of attributes to be stored in + * dense storage (Default: 6) + * + * \return \herr_t + * + * \details H5Pget_attr_phase_change() retrieves threshold values for + * attribute storage on an object. These thresholds determine the + * point at which attribute storage changes from compact storage + * (i.e., storage in the object header) to dense storage (i.e., + * storage in a heap and indexed with a B-tree). + * + * In the general case, attributes are initially kept in compact + * storage. When the number of attributes exceeds \p max_compact, + * attribute storage switches to dense storage. If the number of + * attributes subsequently falls below \p min_dense, the + * attributes are returned to compact storage. + * + * If \p max_compact is set to 0 (zero), dense storage always used. + * + * \p plist_id is an object creation property list (\p ocpl), as it + * can be a dataset or group creation property list identifier. + * The term \p ocpl is used when different types of objects may be + * involved. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, unsigned *min_dense); +/** + * \ingroup OCPL + * + * \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 + * \param[out] flags Bit vector specifying certain general properties of the + * filter + * \param[in,out] cd_nelmts Number of elements in \p cd_values + * \param[out] cd_values Auxiliary data for the filter + * \param[in] namelen Anticipated number of characters in \p name + * \param[out] name Name of the filter + * \param[out] filter_config Bit field, as described in H5Zget_filter_info() + * + * \return Returns a negative value on failure, and the filter identifier + * if successful (see #H5Z_filter_t): + * - #H5Z_FILTER_DEFLATE Data compression filter, + * employing the gzip algorithm + * - #H5Z_FILTER_SHUFFLE Data shuffling filter + * - #H5Z_FILTER_FLETCHER32 Error detection filter, employing the + * Fletcher32 checksum algorithm + * - #H5Z_FILTER_SZIP Data compression filter, employing the + * SZIP algorithm + * - #H5Z_FILTER_NBIT Data compression filter, employing the + * N-bit algorithm + * - #H5Z_FILTER_SCALEOFFSET Data compression filter, employing the + * scale-offset algorithm + * + * \details H5Pget_filter2() returns information about a filter specified by + * its filter number, in a filter pipeline specified by the property + * list with which it is associated. + * + * \p plist_id must be a dataset or group creation property list. + * + * \p idx is a value between zero and N-1, as described in + * H5Pget_nfilters(). The function will return a negative value if + * the filter number is out of range. + * + * The structure of the \p flags argument is discussed in + * H5Pset_filter(). + * + * On input, \p cd_nelmts indicates the number of entries in the + * \p cd_values array, as allocated by the caller; on return, + * \p cd_nelmts contains the number of values defined by the filter. + * + * If \p name is a pointer to an array of at least \p namelen bytes, + * the filter name will be copied into that array. The name will be + * null terminated if \p namelen is large enough. The filter name + * returned will be the name appearing in the file, the name + * registered for the filter, or an empty string. + * + * \p filter_config is the bit field described in + * H5Zget_filter_info(). + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \since 1.8.0 + * + */ +H5_DLL H5Z_filter_t H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[], unsigned *filter_config /*out*/); +/** + * \ingroup OCPL + * + * \brief Returns information about the specified filter + * + * \ocpl_id{plist_id} + * \param[in] filter_id Filter identifier + * \param[out] flags Bit vector specifying certain general + * properties of the filter + * \param[in,out] cd_nelmts Number of elements in \p cd_values + * \param[out] cd_values[] Auxiliary data for the filter + * \param[in] namelen Length of filter name and number of + * elements in \p name + * \param[out] name[] Name of filter + * \param[out] filter_config Bit field, as described in + * H5Zget_filter_info() + * + * \return \herr_t + * + * \details H5Pget_filter_by_id2() returns information about the filter + * specified in \p filter_id, a filter identifier. + * + * \p plist_id must be a dataset or group creation property list + * and \p filter_id must be in the associated filter pipeline. + * + * The \p filter_id and \p flags parameters are used in the same + * manner as described in the discussion of H5Pset_filter(). + * + * Aside from the fact that they are used for output, the + * parameters \p cd_nelmts and \p cd_values[] are used in the same + * manner as described in the discussion of H5Pset_filter(). On + * input, the \p cd_nelmts parameter indicates the number of + * entries in the \p cd_values[] array allocated by the calling + * program; on exit it contains the number of values defined by + * the filter. + * + * On input, the \p namelen parameter indicates the number of + * characters allocated for the filter name by the calling program + * in the array \p name[]. On exit \p name[] contains the name of the + * filter with one character of the name in each element of the + * array. + * + * \p filter_config is the bit field described in + * H5Zget_filter_info(). + * + * If the filter specified in \p filter_id is not set for the + * property list, an error will be returned and + * H5Pget_filter_by_id2() will fail. + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_filter_by_id2(hid_t plist_id, H5Z_filter_t filter_id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/, unsigned *filter_config /*out*/); +/** + * \ingroup OCPL + * + * \brief Returns the number of filters in the pipeline + * + * \ocpl_id{plist_id} + * + * \return Returns the number of filters in the pipeline if successful; + * otherwise returns a negative value. + * + * \details H5Pget_nfilters() returns the number of filters defined in the + * filter pipeline associated with the property list \p plist_id. + * + * In each pipeline, the filters are numbered from 0 through \Code{N-1}, + * where \c N is the value returned by this function. During output to + * the file, the filters are applied in increasing order; during + * input from the file, they are applied in decreasing order. + * + * H5Pget_nfilters() returns the number of filters in the pipeline, + * including zero (0) if there are none. + * + * \since 1.0.0 + * + */ +H5_DLL int H5Pget_nfilters(hid_t plist_id); +/** + * \ingroup OCPL + * + * \brief Determines whether times associated with an object + * are being recorded + * + * \plist_id + * \param[out] track_times Boolean value, 1 (TRUE) or 0 (FALSE), + * specifying whether object times are being recorded + * + * \return \herr_t + * + * \details H5Pget_obj_track_times() queries the object creation property + * list, \p plist_id, to determine whether object times are being + * recorded. + * + * If \p track_times is returned as 1, times are being recorded; + * if \p track_times is returned as 0, times are not being + * recorded. + * + * Time data can be retrieved with H5Oget_info(), which will return + * it in the #H5O_info_t struct. + * + * If times are not tracked, they will be reported as follows + * when queried: 12:00 AM UDT, Jan. 1, 1970 + * + * See H5Pset_obj_track_times() for further discussion. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times); +/** + * \ingroup OCPL + * + * \brief Modifies a filter in the filter pipeline + * + * \ocpl_id{plist_id} + * \param[in] filter Filter to be modified + * \param[in] flags Bit vector specifying certain general properties + * of the filter + * \param[in] cd_nelmts Number of elements in \p cd_values + * \param[in] cd_values[] Auxiliary data for the filter + * + * \return \herr_t + * + * \details H5Pmodify_filter() modifies the specified \p filter in the + * filter pipeline. \p plist_id must be a dataset or group + * creation property list. + * + * The \p filter, \p flags \p cd_nelmts[], and \p cd_values + * parameters are used in the same manner and accept the same + * values as described in the discussion of H5Pset_filter(). + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]); +/** + * \ingroup OCPL + * + * \brief Delete one or more filters in the filter pipeline + * + * \ocpl_id{plist_id} + * \param[in] filter Filter to be deleted + * + * \return \herr_t + * + * \details H5Premove_filter() removes the specified \p filter from the + * filter pipeline in the dataset or group creation property + * list \p plist_id. + * + * The \p filter parameter specifies the filter to be removed. + * Valid values for use in \p filter are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5Z_FILTER_ALLRemoves all filters from the filter pipeline
#H5Z_FILTER_DEFLATEData compression filter, employing the gzip + * algorithm
#H5Z_FILTER_SHUFFLEData shuffling filter
#H5Z_FILTER_FLETCHER32Error detection filter, employing the Fletcher32 + * checksum algorithm
#H5Z_FILTER_SZIPData compression filter, employing the SZIP + * algorithm
#H5Z_FILTER_NBITData compression filter, employing the N-Bit + * algorithm
#H5Z_FILTER_SCALEOFFSETData compression filter, employing the scale-offset + * algorithm
+ * + * Additionally, user-defined filters can be removed with this + * routine by passing the filter identifier with which they were + * registered with the HDF5 library. + * + * Attempting to remove a filter that is not in the filter + * pipeline is an error. + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \since 1.6.3 + * + */ +H5_DLL herr_t H5Premove_filter(hid_t plist_id, H5Z_filter_t filter); +/** + * \ingroup OCPL + * + * \brief Sets tracking and indexing of attribute creation order + * + * \plist_id + * \param[in] crt_order_flags Flags specifying whether to track and index + * attribute creation order. \em Default: No + * flag set; attribute creation order is neither + * tracked not indexed + * + * \return \herr_t + * + * \details H5Pset_attr_creation_order() sets flags for tracking and + * indexing attribute creation order on an object. + * + * \p plist_id is a dataset or group creation property list + * identifier. + * + * \p crt_order_flags contains flags with the following meanings: + * + * + * + * + * + * + * + * + * + * + *
#H5P_CRT_ORDER_TRACKEDAttribute creation order is tracked but not necessarily + * indexed.
#H5P_CRT_ORDER_INDEXED Attribute creation order is indexed (requires + * #H5P_CRT_ORDER_TRACKED).
+ * + * Default behavior is that attribute creation order is neither + * tracked nor indexed. + * + * H5Pset_attr_creation_order() can be used to set attribute + * creation order tracking, or to set attribute creation order + * tracking and indexing. + * + * \note If a creation order index is to be built, it must be specified in + * the object creation property list. HDF5 currently provides no + * mechanism to turn on attribute creation order tracking at object + * creation time and to build the index later. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags); +/** + * \ingroup OCPL + * + * \brief Sets attribute storage phase change thresholds + * + * \plist_id + * \param[in] max_compact Maximum number of attributes to be stored in + * compact storage (\em Default: 8); must be greater + * than or equal to \p min_dense + * + * \param[in] min_dense Minimum number of attributes to be stored in + * dense storage (\em Default: 6) + * + * \return \herr_t + * + * \details H5Pset_attr_phase_change() sets threshold values for attribute + * storage on an object. These thresholds determine the point at + * which attribute storage changes from compact storage (i.e., + * storage in the object header) to dense storage (i.e., storage + * in a heap and indexed with a B-tree). + * + * In the general case, attributes are initially kept in compact + * storage. When the number of attributes exceeds \p max_compact, + * attribute storage switches to dense storage. If the number of + * attributes subsequently falls below \p min_dense, the attributes + * are returned to compact storage. + * + * If \p max_compact is set to 0 (zero), dense storage is always + * used. \p min_dense must be set to 0 (zero) when \p max_compact + * is 0 (zero). + * + * \p plist_id is a dataset or group creation property list + * identifier. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); +/** + * \ingroup OCPL + * + * \brief Sets deflate (GNU gzip) compression method and compression level + * + * \ocpl_id{plist_id} + * \param[in] level Compression level + * + * \return \herr_t + * + * \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. + * + * The filter identifier set in the property list is + * #H5Z_FILTER_DEFLATE. + * + * The compression level, \p level, is a value from zero to nine, + * inclusive. A compression level of 0 (zero) indicates no + * compression; compression improves but speed slows progressively + * from levels 1 through 9: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Compression LevelGzip Action
0No compression
1Best compression speed; least compression
2 through 8Compression improves; speed degrades
9Best compression ratio; slowest speed
+ * + * Note that setting the compression level to 0 (zero) does not turn + * off use of the gzip filter; it simply sets the filter to perform + * no compression as it processes the data. + * + * HDF5 relies on GNU gzip for this compression. + * + * \version 1.8.5 Function extended to work with group creation property lists. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned level); +/** + * \ingroup OCPL + * + * \brief Adds a filter to the filter pipeline + * + * \ocpl_id{plist_id} + * \param[in] filter Filter identifier for the filter to be added to the + * pipeline + * \param[in] flags Bit vector specifying certain general properties of + * the filter + * \param[in] cd_nelmts Number of elements in \p c_values + * \param[in] c_values Auxiliary data for the filter + * + * \return \herr_t + * + * \details H5Pset_filter() adds the specified \p filter identifier and + * corresponding properties to the end of an output filter + * pipeline. + * + * \p plist_id must be either a dataset creation property list or + * group creation property list identifier. If \p plist_id is a + * dataset creation property list identifier, the filter is added + * to the raw data filter pipeline. + * + * If \p plist_id is a group creation property list identifier, + * the filter is added to the link filter pipeline, which filters + * the fractal heap used to store most of the link metadata in + * certain types of groups. The only predefined filters that can + * be set in a group creation property list are the gzip filter + * (#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 \p flags argument is a bit vector with the following + * fields specifying certain general properties of the filter: + * + * + * + * + * + * + * + * + * + * + *
#H5Z_FLAG_OPTIONALIf this bit is set then the filter is optional. If the + * filter fails (see below) during an H5Dwrite() operation + * then the filter is just excluded from the pipeline for + * the chunk for which it failed; the filter will not + * participate in the pipeline during an H5Dread() of the + * chunk. This is commonly used for compression filters: + * if the filter result would be larger than the input, + * then the compression filter returns failure and the + * uncompressed data is stored in the file.

+ * This flag should not be set for the Fletcher32 checksum + * filter as it will bypass the checksum filter without + * reporting checksum errors to an application.
#H5Z_FLAG_MANDATORYIf the filter is required, that is, set to mandatory, + * and the filter fails, the library’s behavior depends + * on whether the chunk cache is in use: + * \li If the chunk cache is enabled, data chunks will + * be flushed to the file during H5Dclose() and the + * library will return the failure in H5Dclose(). + * \li When the chunk cache is disabled or not big enough, + * or the chunk is being evicted from the cache, the + * failure will happen during H5Dwrite(). + * + * In each case, the library will still write to the file + * all data chunks that were processed by the filter + * before the failure occurred.

+ * For example, assume that an application creates a + * dataset of four chunks, the chunk cache is enabled and + * is big enough to hold all four chunks, and the filter + * fails when it tries to write the fourth chunk. The + * actual flush of the chunks will happen during + * H5Dclose(), not H5Dwrite(). By the time H5Dclose() + * fails, the first three chunks will have been written + * to the file. Even though H5Dclose() fails, all the + * resources will be released and the file can be closed + * properly.

+ * If, however, the filter fails on the second chunk, only + * the first chunk will be written to the file as nothing + * further can be written once the filter fails.
+ * The \p filter parameter specifies the filter to be set. Valid + * pre-defined filter identifiers are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5Z_FILTER_DEFLATEData compression filter, employing the gzip + * algorithm
#H5Z_FILTER_SHUFFLEData shuffling filter
#H5Z_FILTER_FLETCHER32Error detection filter, employing the Fletcher32 + * checksum algorithm
#H5Z_FILTER_SZIPData compression filter, employing the SZIP + * algorithm
#H5Z_FILTER_NBITData compression filter, employing the N-Bit + * algorithm
#H5Z_FILTER_SCALEOFFSETData compression filter, employing the scale-offset + * algorithm
+ * Also see H5Pset_edc_check() and H5Pset_filter_callback(). + * + * \note When a non-empty filter pipeline is used with a group creation + * property list, the group will be created with the new group file + * format. The filters will come into play only when dense storage + * is used (see H5Pset_link_phase_change()) and will be applied to + * the group’s fractal heap. The fractal heap will contain most of + * the the group’s link metadata, including link names. + * + * \note When working with group creation property lists, if you are + * adding a filter that is not in HDF5’s set of predefined filters, + * i.e., a user-defined or third-party filter, you must first + * determine that the filter will work for a group. See the + * discussion of the set local and can apply callback functions + * in H5Zregister(). + * + * \note If multiple filters are set for a property list, they will be + * applied to each chunk of raw data for datasets or each block + * of the fractal heap for groups in the order in which they were + * set. + * + * \note Filters can be applied only to chunked datasets; they cannot be + * used with other dataset storage methods, such as contiguous, + * compact, or external datasets. + * + * \note Dataset elements of variable-length and dataset region + * reference datatypes are stored in separate structures in the + * file called heaps. Filters cannot currently be applied to + * these heaps. + * + * \note Filter Behavior in HDF5:
+ * Filters can be inserted into the HDF5 pipeline to perform + * functions such as compression and conversion. As such, they are + * a very flexible aspect of HDF5; for example, a user-defined + * filter could provide encryption for an HDF5 dataset. + * + * \note A filter can be declared as either required or optional. + * Required is the default status; optional status must be + * explicitly declared. + * + * \note A required filter that fails or is not defined causes an + * entire output operation to fail; if it was applied when the + * data was written, such a filter will cause an input operation + * to fail. + * + * \note The following table summarizes required filter behavior. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Required FILTER_X not availableFILTER_X available
H5Pset_Will fail.Will succeed.
H5Dwrite with FILTER_X setWill fail.Will succeed; FILTER_X will be applied to + * the data.
H5Dread with FILTER_X setWill fail.Will succeed.
+ * \note An optional filter can be set for an HDF5 dataset even when + * the filter is not available. Such a filter can then be + * applied to the dataset when it becomes available on the + * original system or when the file containing the dataset is + * processed on a system on which it is available. + * + * \note A filter can be declared as optional through the use of the + * #H5Z_FLAG_OPTIONAL flag with H5Pset_filter(). + * + * \note Consider a situation where one is creating files that will + * normally be used only on systems where the optional (and + * fictional) filter FILTER_Z is routinely available. One can + * create those files on system A, which lacks FILTER_Z, create + * chunked datasets in the files with FILTER_Z defined in the + * dataset creation property list, and even write data to those + * datasets. The dataset object header will indicate that FILTER_Z + * has been associated with this dataset. But since system A does + * not have FILTER_Z, dataset chunks will be written without it + * being applied. + * + * \note HDF5 has a mechanism for determining whether chunks are + * actually written with the filters specified in the object + * header, so while the filter remains unavailable, system A will + * be able to read the data. Once the file is moved to system B, + * where FILTER_Z is available, HDF5 will apply FILTER_Z to any + * data rewritten or new data written in these datasets. Dataset + * chunks that have been written on system B will then be + * unreadable on system A; chunks that have not been re-written + * since being written on system A will remain readable on system + * A. All chunks will be readable on system B. + * + * \note The following table summarizes optional filter behavior. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
FILTER_Z not availableFILTER_Z available
with encode and decode
FILTER_Z available decode only
H5Pset_Will succeed.Will succeed.Will succeed.
H5Dread with FILTER_Z setWill succeed if FILTER_Z has not actually
+ * been applied to data.
Will succeed.Will succeed.
H5Dwrite with FILTER_Z setWill succeed;
+ * FILTER_Z will not be applied to the data.
Will succeed;
+ * FILTER_Z will be applied to the data.
Will succeed;
+ * FILTER_Z will not be applied to the data.
+ * \note The above principles apply generally in the use of HDF5 + * optional filters insofar as HDF5 does as much as possible to + * complete an operation when an optional filter is unavailable. + * (The SZIP filter is an exception to this rule; see H5Pset_szip() + * for details.) + * + * \see \ref_filter_pipe, \ref_group_impls + * + * \version 1.8.5 Function applied to group creation property lists. + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, + const unsigned int c_values[]); +/** + * \ingroup OCPL + * + * \brief Sets up use of the Fletcher32 checksum filter + * + * \ocpl_id{plist_id} + * + * \return \herr_t + * + * \details H5Pset_fletcher32() sets the Fletcher32 checksum filter in the + * dataset or group creation property list \p plist_id. + * + * \attention The Fletcher32 EDC checksum filter was added in HDF5 Release + * 1.6.0. In the original implementation, however, the checksum + * value was calculated incorrectly on little-endian systems. + * The error was fixed in HDF5 Release 1.6.3. + * + * \attention As a result of this fix, an HDF5 library of Release 1.6.0 + * through Release 1.6.2 cannot read a dataset created or written + * with Release 1.6.3 or later if the dataset was created with + * the checksum filter and the filter is enabled in the reading + * library. (Libraries of Release 1.6.3 and later understand the + * earlier error and compensate appropriately.) + * + * \attention \b Work-around: An HDF5 library of Release 1.6.2 or earlier + * will be able to read a dataset created or written with the + * checksum filter by an HDF5 library of Release 1.6.3 or later + * if the checksum filter is disabled for the read operation. + * This can be accomplished via a call to H5Pset_edc_check() + * with the value #H5Z_DISABLE_EDC in the second parameter. + * This has the obvious drawback that the application will be + * unable to verify the checksum, but the data does remain + * accessible. + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \version 1.6.3 Error in checksum calculation on little-endian systems + * corrected in this release. + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_fletcher32(hid_t plist_id); +/** + * \ingroup OCPL + * + * \brief Sets the recording of times associated with an object + * + * \param[in] plist_id Object creation property list identifier + * \param[in] track_times Boolean value, 1 or 0, specifying whether object + * times are to be tracked + * + * \return \herr_t + * + * \details H5Pset_obj_track_times() sets a property in the object creation + * property list, \p plist_id, that governs the recording of times + * associated with an object. + * + * If \p track_times is set to 1, time data will be recorded. If + * \p track_times is set to 0, time data will not be recorded. + * + * Time data can be retrieved with H5Oget_info(), which will + * return it in the #H5O_info_t struct. + * + * If times are not tracked, they will be reported as follows when queried: + * \Code{ 12:00 AM UDT, Jan. 1, 1970} + * + * That date and time are commonly used to represent the beginning of the UNIX epoch. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times); + +/* File creation property list (FCPL) routines */ +/** + * \ingroup FCPL + * + * \brief Retrieves the file space page size for a file creation property + * list + * + * \fcpl_id{plist_id} + * \param[out] fsp_size File space page size + * + * \return \herr_t + * + * \details H5Pget_file_space_page_size() retrieves the file space page + * size for paged aggregation in the parameter \p fsp_size. + * + * The library default is 4KB (4096) if \p fsp_size is not + * previously set via a call to H5Pset_file_space_page_size(). + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size); +/** + * \ingroup FCPL + * + * \brief Retrieves the file space handling strategy, persisting free-space + * condition and threshold value for a file creation property list + * + * \fcpl_id{plist_id} + * \param[out] strategy The file space handling strategy + * \param[out] persist The boolean value indicating whether free space is + * persistent or not + * \param[out] threshold The free-space section size threshold value + * + * \return \herr_t + * + * \details H5Pget_file_space_strategy() retrieves the file space handling + * strategy, the persisting free-space condition and the threshold + * value in the parameters \p strategy, \p persist and + * \p threshold respectively. + * + * The library default values returned when + * H5Pset_file_space_strategy() has not been called are: + * + * \li \p strategy - #H5F_FSPACE_STRATEGY_FSM_AGGR + * \li \p persist - 0 + * \li \p threshold - 1 + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, + hsize_t *threshold); +/** + * \ingroup FCPL + * + * \brief Queries the 1/2 rank of an indexed storage B-tree + * + * \fcpl_id{plist_id} + * \param[out] ik Pointer to location to return the chunked storage B-tree + * 1/2 rank (Default value of B-tree 1/2 rank: 32) + * + * \return \herr_t + * + * \details H5Pget_istore_k() queries the 1/2 rank of an indexed storage + * B-tree. + * + * The argument \p ik may be the null pointer (NULL). + * This function is valid only for file creation property lists. + * + * \see H5Pset_istore_k() + * + * \version 1.6.4 \p ik parameter type changed to \em unsigned. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out*/); +/** + * \ingroup FCPL + * + * \brief Retrieves the configuration settings for a shared message index + * + * \fcpl_id{plist_id} + * \param[in] index_num Index being configured + * \param[out] mesg_type_flags Types of messages that may be stored in + * this index + * \param[out] min_mesg_size Minimum message size + * + * \return \herr_t + * + * \details H5Pget_shared_mesg_index() retrieves the message type and + * minimum message size settings from the file creation property + * list \p plist_id for the shared object header message index + * specified by \p index_num. + * + * \p index_num specifies the index. \p index_num is zero-indexed, + * so in a file with three indexes, they will be numbered 0, 1, + * and 2. + * + * \p mesg_type_flags and \p min_mesg_size will contain, + * respectively, the types of messages and the minimum size, in + * bytes, of messages that can be stored in this index. + * + * Valid message types are described in H5Pset_shared_mesg_index(). + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, + unsigned *min_mesg_size); +/** + * \ingroup FCPL + * + * \brief Retrieves the number of shared object header message indexes in file + * creation property list + * + * \fcpl_id{plist_id} + * \param[out] nindexes Number of shared object header message indexes + * available in files created with this property list + * + * \return \herr_t + * + * \details H5Pget_shared_mesg_nindexes() retrieves the number of shared + * object header message indexes in the specified file creation + * property list \p plist_id. + * + * If the value of \p nindexes is 0 (zero), shared object header + * messages are disabled in files created with this property list. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes); +/** + * \ingroup FCPL + * + * \brief Retrieves shared object header message phase change information + * + * \fcpl_id{plist_id} + * \param[out] max_list Threshold above which storage of a shared object + * header message index shifts from list to B-tree + * \param[out] min_btree Threshold below which storage of a shared object + * header message index reverts to list format + * + * \return \herr_t + * + * \details H5Pget_shared_mesg_phase_change() retrieves the threshold values + * for storage of shared object header message indexes in a file. + * These phase change thresholds determine the point at which the + * index storage mechanism changes from a more compact list format + * to a more performance-oriented B-tree format, and vice-versa. + * + * By default, a shared object header message index is initially + * stored as a compact list. When the number of messages in an + * index exceeds the specified \p max_list threshold, storage + * switches to a B-tree format for improved performance. If the + * number of messages subsequently falls below the \p min_btree + * threshold, the index will revert to the list format. + * + * If \p max_list is set to 0 (zero), shared object header message + * indexes in the file will always be stored as B-trees. + * + * \p plist_id specifies the file creation property list. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree); +/** + * \ingroup FCPL + * + * \brief Retrieves the size of the offsets and lengths used in an HDF5 + * file + * + * \fcpl_id{plist_id} + * \param[out] sizeof_addr Pointer to location to return offset size in + * bytes + * \param[out] sizeof_size Pointer to location to return length size in + * bytes + * + * \return \herr_t + * + * \details H5Pget_sizes() retrieves the size of the offsets and lengths + * used in an HDF5 file. This function is only valid for file + * creation property lists. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr /*out*/, size_t *sizeof_size /*out*/); +/** + * \ingroup FCPL + * + * \brief Retrieves the size of the symbol table B-tree 1/2 rank and the + * symbol table leaf node 1/2 size + * + * \fcpl_id{plist_id} + * \param[out] ik Pointer to location to return the symbol table's B-tree + * 1/2 rank (Default value of B-tree 1/2 rank: 16) + * \param[out] lk Pointer to location to return the symbol table's leaf + * node 1/2 size (Default value of leaf node 1/2 + * size: 4) + * + * \return \herr_t + * + * \details H5Pget_sym_k() retrieves the size of the symbol table B-tree + * 1/2 rank and the symbol table leaf node 1/2 size. + * + * This function is valid only for file creation property lists. + * + * If a parameter value is set to NULL, that parameter is not + * retrieved. + * + * \see H5Pset_sym_k() + * + * \version 1.6.4 \p ik parameter type changed to \em unsigned + * \version 1.6.0 The \p ik parameter has changed from type int to + * \em unsigned + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out*/, unsigned *lk /*out*/); +/** + * \ingroup FCPL + * + * \brief Retrieves the size of a user block + * + * \fcpl_id{plist_id} + * \param[out] size Pointer to location to return user-block size + * + * \return \herr_t + * + * \details H5Pget_userblock() retrieves the size of a user block in a + * file creation property list. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size); +/** + * \ingroup FCPL + * + * \brief Sets the file space page size for a file creation property list + * + * \fcpl_id{plist_id} + * \param[in] fsp_size File space page size + * + * \return \herr_t + * + * \details H5Pset_file_space_page_size() sets the file space page size + * \p fsp_size used in paged aggregation and paged buffering. + * + * \p fsp_size has a minimum size of 512. Setting a value less + * than 512 will return an error. The library default size for + * the file space page size when not set is 4096. + * + * The size set via this routine may not be changed for the life + * of the file. + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size); +/** + * \ingroup FCPL + * + * \brief Sets the file space handling strategy and persisting free-space + * values for a file creation property list + * + * \fcpl_id{plist_id} + * \param[in] strategy The file space handling strategy to be used. See: + * #H5F_fspace_strategy_t + * \param[in] persist A boolean value to indicate whether free space + * should be persistent or not + * \param[in] threshold The smallest free-space section size that the free + * space manager will track + * + * \return \herr_t + * + * \details H5Pset_file_space_strategy() sets the file space handling + * \p strategy, specifies persisting free-space or not (\p persist), + * and sets the free-space section size \p threshold in the file + * creation property list \p plist_id. + * + * #H5F_fspace_strategy_t is a struct defined in H5Fpublic.h as + * follows: + * + * \snippet H5Fpublic.h H5F_fspace_strategy_t_snip + * + * This setting cannot be changed for the life of the file. + * + * As the #H5F_FSPACE_STRATEGY_AGGR and #H5F_FSPACE_STRATEGY_NONE + * strategies do not use the free-space managers, the \p persist + * and \p threshold settings will be ignored for those strategies. + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, + hsize_t threshold); +/** + * \ingroup FCPL + * + * \brief Sets the size of the parameter used to control the B-trees for + * indexing chunked datasets + * + * \fcpl_id{plist_id} + * \param[in] ik 1/2 rank of chunked storage B-tree + * + * \return \herr_t + * + * \details H5Pset_istore_k() sets the size of the parameter used to + * control the B-trees for indexing chunked datasets. This + * function is valid only for file creation property lists. + * + * \p ik is one half the rank of a tree that stores chunked + * raw data. On average, such a tree will be 75% full, or have + * an average rank of 1.5 times the value of \p ik. + * + * The HDF5 library uses (\p ik*2) as the maximum # of entries + * before splitting a B-tree node. Since only 2 bytes are used + * in storing # of entries for a B-tree node in an HDF5 file, + * (\p ik*2) cannot exceed 65536. The default value for + * \p ik is 32. + * + * \version 1.6.4 \p ik parameter type changed to \p unsigned. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik); +/** + * \ingroup FCPL + * + * \brief Configures the specified shared object header message index + * + * \fcpl_id{plist_id} + * \param[in] index_num Index being configured + * \param[in] mesg_type_flags Types of messages that should be stored in + * this index + * \param[in] min_mesg_size Minimum message size + * + * \return \herr_t + * + * \details H5Pset_shared_mesg_index() is used to configure the specified + * shared object header message index, setting the types of + * messages that may be stored in the index and the minimum size + * of each message. + * + * \p plist_id specifies the file creation property list. + * + * \p index_num specifies the index to be configured. + * \p index_num is zero-indexed, so in a file with three indexes, + * they will be numbered 0, 1, and 2. + * + * \p mesg_type_flags and \p min_mesg_size specify, respectively, + * the types and minimum size of messages that can be stored in + * this index. + * + * Valid message types are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5O_SHMESG_NONE_FLAGNo shared messages
#H5O_SHMESG_SDSPACE_FLAGSimple dataspace message
#H5O_SHMESG_DTYPE_FLAGDatatype message
#H5O_SHMESG_FILL_FLAGFill value message
#H5O_SHMESG_PLINE_FLAGFilter pipeline message
#H5O_SHMESG_ATTR_FLAGAttribute message
#H5O_SHMESG_ALL_FLAGAll message types; i.e., equivalent to the following: + * (#H5O_SHMESG_SDSPACE_FLAG | #H5O_SHMESG_DTYPE_FLAG | + * #H5O_SHMESG_FILL_FLAG | #H5O_SHMESG_PLINE_FLAG | + * #H5O_SHMESG_ATTR_FLAG)
+ * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, + unsigned min_mesg_size); +/** + * \ingroup FCPL + * + * \brief Sets number of shared object header message indexes + * + * \fcpl_id{plist_id} + * \param[in] nindexes Number of shared object header message indexes to be + * available in files created with this property list + * (\p nindexes must be <= #H5O_SHMESG_MAX_NINDEXES (8)) + * + * \return \herr_t + * + * \details H5Pset_shared_mesg_nindexes() sets the number of shared object + * header message indexes in the specified file creation property + * list. + * + * This setting determines the number of shared object header + * message indexes, \p nindexes, that will be available in files + * created with this property list. These indexes can then be + * configured with H5Pset_shared_mesg_index(). + * + * If \p nindexes is set to 0 (zero), shared object header messages + * are disabled in files created with this property list. + * + * There is a limit of #H5O_SHMESG_MAX_NINDEXES (8) that can be set + * with H5Pset_shared_mesg_nindexes(). An error will occur if + * specifying a value of \p nindexes that is greater than this value. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes); +/** + * \ingroup FCPL + * + * \brief Sets shared object header message storage phase change thresholds + * + * \fcpl_id{plist_id} + * \param[in] max_list Threshold above which storage of a shared object + * header message index shifts from list to B-tree + * \param[in] min_btree Threshold below which storage of a shared object + * header message index reverts to list format + * + * \return \herr_t + * + * \details H5Pset_shared_mesg_phase_change() sets threshold values for + * storage of shared object header message indexes in a file. + * These phase change thresholds determine the point at which the + * index storage mechanism changes from a more compact list format + * to a more performance-oriented B-tree format, and vice-versa. + * + * By default, a shared object header message index is initially + * stored as a compact list. When the number of messages in an + * index exceeds the threshold value of \p max_list, storage + * switches to a B-tree for improved performance. If the number + * of messages subsequently falls below the \p min_btree threshold, + * the index will revert to the list format. + * + * If \p max_list is set to 0 (zero), shared object header message + * indexes in the file will be created as B-trees and will never + * revert to lists. + * + * \p plist_id specifies the file creation property list. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree); +/** + * \ingroup FCPL + * + * \brief Sets the byte size of the offsets and lengths used to address + * objects in an HDF5 file + * + * \fcpl_id{plist_id} + * \param[in] sizeof_addr Size of an object offset in bytes + * \param[in] sizeof_size Size of an object length in bytes + * + * \return \herr_t + * + * \details H5Pset_sizes() sets the byte size of the offsets and lengths + * used to address objects in an HDF5 file. This function is only + * valid for file creation property lists. Passing in a value + * of 0 for one of the parameters retains the current value. The + * default value for both values is the same as sizeof(hsize_t) + * in the library (normally 8 bytes). Valid values currently + * are 2, 4, 8 and 16. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size); +/** + * \ingroup FCPL + * + * \brief + * + * \fcpl_id{plist_id} + * \param[in] ik Symbol table tree rank + * \param[in] lk Symbol table node size + * + * \return \herr_t + * + * \details H5Pset_sym_k() sets the size of parameters used to control the + * symbol table nodes. + * + * This function is valid only for file creation property lists. + * Passing in a value of zero (0) for one of the parameters retains + * the current value. + * + * \p ik is one half the rank of a B-tree that stores a symbol + * table for a group. Internal nodes of the symbol table are on + * average 75% full. That is, the average rank of the tree is + * 1.5 times the value of \p ik. The HDF5 library uses (\p ik*2) as + * the maximum # of entries before splitting a B-tree node. Since + * only 2 bytes are used in storing # of entries for a B-tree node + * in an HDF5 file, (\p ik*2) cannot exceed 65536. The default value + * for \p ik is 16. + * + * \p lk is one half of the number of symbols that can be stored in + * a symbol table node. A symbol table node is the leaf of a symbol + * table tree which is used to store a group. When symbols are + * inserted randomly into a group, the group's symbol table nodes are + * 75% full on average. That is, they contain 1.5 times the number of + * symbols specified by \p lk. The default value for \p lk is 4. + * + * \version 1.6.4 \p ik parameter type changed to \em unsigned. + * \version 1.6.0 The \p ik parameter has changed from type int to + * \em unsigned. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk); +/** + * \ingroup FCPL + * + * \brief Sets user block size + * + * \fcpl_id{plist_id} + * \param[in] size Size of the user-block in bytes + * + * \return \herr_t + * + * \details H5Pset_userblock() sets the user block size of a file creation + * property list. The default user block size is 0; it may be set + * to any power of 2 equal to 512 or greater (512, 1024, 2048, etc.). + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_userblock(hid_t plist_id, hsize_t size); + +/* File access property list (FAPL) routines */ +/** + * \ingroup FAPL + * + * \brief Retrieves the current settings for alignment properties from a + * file access property list + * + * \fapl_id + * \param[out] threshold Pointer to location of return threshold value + * \param[out] alignment Pointer to location of return alignment value + * + * \return \herr_t + * + * \details H5Pget_alignment() retrieves the current settings for + * alignment properties from a file access property list. The + * \p threshold and/or \p alignment pointers may be null + * pointers (NULL). + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/); +/** + * \ingroup FAPL + * + * \brief Queries the raw data chunk cache parameters + * + * \fapl_id{plist_id} + * \param[in,out] mdc_nelmts No longer used + * \param[in,out] rdcc_nslots Number of elements (objects) in the raw data + * chunk cache + * \param[in,out] rdcc_nbytes Total size of the raw data chunk cache, in + * bytes + * \param[in,out] rdcc_w0 Preemption policy + * + * \return \herr_t + * + * \details H5Pget_cache() retrieves the maximum possible number of + * elements in the raw data chunk cache, the maximum possible + * number of bytes in the raw data chunk cache, and the + * preemption policy value. + * + * Any (or all) arguments may be null pointers, in which case + * the corresponding datum is not returned. + * + * Note that the \p mdc_nelmts parameter is no longer used. + * + * \version 1.8.0 Use of the \p mdc_nelmts parameter discontinued. + * Metadata cache configuration is managed with + * H5Pset_mdc_config() and H5Pget_mdc_config() + * \version 1.6.0 The \p rdcc_nbytes and \p rdcc_nslots parameters changed + * from type int to size_t. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, /* out */ + size_t *rdcc_nslots /*out*/, size_t *rdcc_nbytes /*out*/, double *rdcc_w0); +/** + * \ingroup FAPL + * + * \brief Gets information about the write tracking feature used by + * the core VFD + * + * \fapl_id + * \param[out] is_enabled Whether the feature is enabled + * \param[out] page_size Size, in bytes, of write aggregation pages + * + * \return \herr_t + * + * \details H5Pget_core_write_tracking() retrieves information about the + * write tracking feature used by the core VFD. + * + * When a file is created or opened for writing using the core + * virtual file driver (VFD) with the backing store option turned + * on, the VFD can be configured to track changes to the file + * and only write out the modified bytes. To avoid a large number + * of small writes, the changes can be aggregated into pages of + * a user-specified size. The core VFD is also known as the + * memory VFD. The driver identifier is #H5FD_CORE. + * + * \note This function is only for use with the core VFD and must be used + * after the call to H5Pset_fapl_core(). It is an error to use this + * function with any other VFD. + * + * \note This function only applies to the backing store write operation + * which typically occurs when the file is flushed or closed. This + * function has no relationship to the increment parameter passed + * to H5Pset_fapl_core(). + * + * \note For optimum performance, the \p page_size parameter should be + * a power of two. + * + * \since 1.8.13 + * + */ +H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); +/** + * \ingroup FAPL + * + * \brief Returns low-lever driver identifier + * + * \plist_id + * + * \return \hid_t{low level driver} + * + * \details H5Pget_driver() returns the identifier of the low-level file + * driver associated with the file access property list or + * data transfer property list \p plist_id. + * + * Valid driver identifiers distributed with HDF5 are listed and + * described in the following table. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Driver NameDriver IdentifierDescriptionRelated Function
POSIX#H5FD_SEC2This driver uses POSIX file-system functions like read and + * write to perform I/O to a single, permanent file on local disk + * with no system buffering. This driver is POSIX-compliant and + * is the default file driver for all systems.H5Pset_fapl_sec2()
Direct#H5FD_DIRECTThis is the #H5FD_SEC2 driver except data is written to or + * read from the file synchronously without being cached by the + * system.H5Pset_fapl_direct()
Log#H5FD_LOGThis is the #H5FD_SEC2 driver with logging capabilities.H5Pset_fapl_log()
Windows#H5FD_WINDOWSThis driver was modified in HDF5-1.8.8 to be a wrapper of the + * POSIX driver, #H5FD_SEC2. This change should not affect user + * applications.H5Pset_fapl_windows()
STDIO#H5FD_STDIOThis driver uses functions from the standard C stdio.h to + * perform I/O to a single, permanent file on local disk with + * additional system buffering.H5Pset_fapl_stdio()
Memory#H5FD_COREWith this driver, an application can work with a file in + * memory for faster reads and writes. File contents are kept in + * memory until the file is closed. At closing, the memory + * version of the file can be written back to disk or abandoned. + * H5Pset_fapl_core()
Family#H5FD_FAMILYWith this driver, the HDF5 file’s address space is partitioned + * into pieces and sent to separate storage files using an + * underlying driver of the user’s choice. This driver is for + * systems that do not support files larger than 2 gigabytes. + * H5Pset_fapl_family()
Multi#H5FD_MULTIWith this driver, data can be stored in multiple files + * according to the type of the data. I/O might work better if + * data is stored in separate files based on the type of data. + * The Split driver is a special case of this driver.H5Pset_fapl_multi()
Parallel#H5FD_MPIOThis is the standard HDF5 file driver for parallel file + * systems. This driver uses the MPI standard for both + * communication and file I/O.H5Pset_fapl_mpio()
Parallel POSIXH5FD_MPIPOSIXThis driver is no longer available.
StreamH5FD_STREAMThis driver is no longer available.
+ * + * This list does not include custom drivers that might be + * defined and registered by a user. + * + * The returned driver identifier is only valid as long as the + * file driver remains registered. + * + * + * \since 1.4.0 + * + */ +H5_DLL hid_t H5Pget_driver(hid_t plist_id); +/** + * \ingroup FAPL + * + * \brief Returns a pointer to file driver information + * + * \param[in] plist_id File access or data transfer property list + * identifier + * + * \return Returns a pointer to a struct containing low-level driver + * information. Otherwise returns NULL. NULL is also returned if + * no driver-specific properties have been registered. No error + * is pushed on the stack in this case. + * + * \details H5Pget_driver_info() returns a pointer to file driver-specific + * information for the low-level driver associated with the file + * access or data transfer property list \p plist_id. + * + * The pointer returned by this function points to an “uncopied” + * struct. Driver-specific versions of that struct are defined + * for each low-level driver in the relevant source code file + * H5FD*.c. For example, the struct used for the MULTI driver is + * \c H5FD_multi_fapl_t defined in H5FDmulti.c. + * + * If no driver-specific properties have been registered, + * H5Pget_driver_info() returns NULL. + * + * \note H5Pget_driver_info() and H5Pset_driver() are used only when + * creating a virtual file driver (VFD) in the virtual file + * layer (VFL). + * + * \version 1.10.1 Return value was changed from \em void * to + * \em const \em void *. + * \version 1.8.2 Function publicized in this release; previous releases + * described this function only in the virtual file driver + * documentation. + * + */ +H5_DLL const void *H5Pget_driver_info(hid_t plist_id); +/** + * \ingroup FAPL + * + * \brief Retrieves the size of the external link open file cache + * + * \fapl_id{plist_id} + * \param[out] efc_size External link open file cache size in number of files + * + * \return \herr_t + * + * \details H5Pget_elink_file_cache_size() retrieves the number of files that + * can be held open in an external link open file cache. + * + * \since 1.8.7 + * + */ +H5_DLL herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size); +/** + * \ingroup FAPL + * + * \brief Retrieves the file access property list setting that determines + * whether an HDF5 object will be evicted from the library's metadata + * cache when it is closed + * + * \fapl_id + * \param[out] evict_on_close Pointer to a variable that will indicate if + * the object will be evicted on close + * + * \return \herr_t + * + * \details The library's metadata cache is fairly conservative about holding on + * to HDF5 object metadata (object headers, chunk index structures, + * etc.), which can cause the cache size to grow, resulting in memory + * pressure on an application or system. When enabled, the "evict on + * close" property will cause all metadata for an object to be + * immediately evicted from the cache as long as it is not referenced + * by any other open object. + * + * See H5Pset_evict_on_close() for additional notes on behavior. + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close); +/** + * \ingroup FAPL + * + * \brief Retrieves a data offset from the file access property list + * + * \fapl_id + * \param[out] offset Offset in bytes within the HDF5 file + * + * \return \herr_t + * + * \details H5Pget_family_offset() retrieves the value of offset from the + * file access property list \p fapl_id so that the user + * application can retrieve a file handle for low-level access to + * a particular member of a family of files. The file handle is + * retrieved with a separate call to H5Fget_vfd_handle() (or, + * in special circumstances, to H5FDget_vfd_handle(), see \ref VFL). + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); +/** + * \ingroup FAPL + * + * \brief Returns the file close degree + * + * \fapl_id + * \param[out] degree Pointer to a location to which to return the file + * close degree property, the value of \p degree + * + * \return \herr_t + * + * \details H5Pget_fclose_degree() returns the current setting of the file + * close degree property \p degree in the file access property + * list \p fapl_id. The value of \p degree determines how + * aggressively H5Fclose() deals with objects within a file that + * remain open when H5Fclose() is called to close that file. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *degree); +/** + * \ingroup FAPL + * + * \brief Retrieves a copy of the file image designated as the initial content + * and structure of a file + * + * \fapl_id + * \param[in,out] buf_ptr_ptr On input, \c NULL or a pointer to a + * pointer to a buffer that contains the + * file image.\n On successful return, if \p buf_ptr_ptr is not + * \c NULL, \Code{*buf_ptr_ptr} will contain a pointer to a copy + * of the initial image provided in the last call to + * H5Pset_file_image() for the supplied \p fapl_id. If no initial + * image has been set, \Code{*buf_ptr_ptr} will be \c NULL. + * \param[in,out] buf_len_ptr On input, \c NULL or a pointer to a buffer + * specifying the required size of the buffer to hold the file + * image.\n On successful return, if \p buf_len_ptr was not + * passed in as \c NULL, \p buf_len_ptr will return the required + * size in bytes of the buffer to hold the initial file image in + * the supplied file access property list, \p fapl_id. If no + * initial image is set, the value of \Code{*buf_len_ptr} will be + * set to 0 (zero) + * \return \herr_t + * + * \details H5Pget_file_image() allows an application to retrieve a copy of the + * file image designated for a VFD to use as the initial contents of a file. + * + * If file image callbacks are defined, H5Pget_file_image() will use + * them when allocating and loading the buffer to return to the + * application (see H5Pset_file_image_callbacks()). If file image + * callbacks are not defined, the function will use \c malloc and \c + * memcpy. When \c malloc and \c memcpy are used, it is the caller’s + * responsibility to discard the returned buffer with a call to \c + * free. + * + * It is the responsibility of the calling application to free the + * buffer whose address is returned in \p buf_ptr_ptr. This can be + * accomplished with \c free if file image callbacks have not been set + * (see H5Pset_file_image_callbacks()) or with the appropriate method + * if file image callbacks have been set. + * + * \see H5LTopen_file_image(), H5Fget_file_image(), H5Pset_file_image(), + * H5Pset_file_image_callbacks(), H5Pget_file_image_callbacks(), + * \ref H5FD_file_image_callbacks_t, \ref H5FD_file_image_op_t, + * + * HDF5 File Image Operations. + * + * + * \since 1.8.9 + * + */ +H5_DLL herr_t H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr); +/** + * \ingroup FAPL + * + * \brief Retrieves callback routines for working with file images + * + * \fapl_id + * \param[in,out] callbacks_ptr Pointer to the instance of the + * #H5FD_file_image_callbacks_t struct in which the callback + * routines are to be returned\n + * Struct fields must be initialized to NULL before the call + * is made.\n + * Struct field contents upon return will match those passed in + * in the last H5Pset_file_image_callbacks() call for the file + * access property list \p fapl_id. + * \return \herr_t + * + * \details H5Pget_file_image_callbacks() retrieves the callback routines set for + * working with file images opened with the file access property list + * \p fapl_id. + * + * The callbacks must have been previously set with + * H5Pset_file_image_callbacks() in the file access property list. + * + * Upon the successful return of H5Pset_file_image_callbacks(), the + * fields in the instance of the #H5FD_file_image_callbacks_t struct + * pointed to by \p callbacks_ptr will contain the same values as were + * passed in the most recent H5Pset_file_image_callbacks() call for the + * file access property list \p fapl_id. + * + * \see H5LTopen_file_image(), H5Fget_file_image(), H5Pset_file_image(), + * H5Pset_file_image_callbacks(), H5Pget_file_image_callbacks(), + * \ref H5FD_file_image_callbacks_t, \ref H5FD_file_image_op_t, + * + * HDF5 File Image Operations. + * + * \since 1.8.9 + * + */ +H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); +/** + * \ingroup FAPL + * + * \brief Retrieves the file locking property values + * + * \fapl_id + * \param[out] use_file_locking File locking flag + * \param[out] ignore_when_disabled Ignore when disabled flag + * \return \herr_t + * + * \details H5Pget_file_locking() retrieves the file locking property values for + * the file access property list specified by \p fapl_id. + * + * \since 1.10.7 + * + */ +H5_DLL herr_t H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled); +/** + * \ingroup FAPL + * + * \brief Returns garbage collecting references setting + * + * \fapl_id + * \param[out] gc_ref Flag returning the state of reference garbage + * collection. A returned value of 1 indicates that + * garbage collection is on while 0 indicates that + * garbage collection is off. + * + * \return \herr_t + * + * \details H5Pget_gc_references() returns the current setting for the + * garbage collection references property from the specified + * file access property list. The garbage collection references + * property is set by H5Pset_gc_references(). + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref /*out*/); +/** + * \ingroup FAPL + * + * \brief Retrieves library version bounds settings that indirectly control + * the format versions used when creating objects + * + * \fapl_id{plist_id} + * \param[out] low The earliest version of the library that will be used + * for writing objects + * \param[out] high The latest version of the library that will be used for + * writing objects + * + * \return \herr_t + * + * \details H5Pget_libver_bounds() retrieves the lower and upper bounds on + * the HDF5 library release versions that indirectly determine the + * object format versions used when creating objects in the file. + * + * This property is retrieved from the file access property list + * specified by the parameter \p fapl_id. + * + * The value returned in the parameters \p low and \p high is one + * of the enumerated values in the #H5F_libver_t struct, which is + * defined in H5Fpublic.h. + * + * \version 1.10.2 Add #H5F_LIBVER_V18 to the enumerated defines in + * #H5F_libver_t + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low, H5F_libver_t *high); +/** + * \ingroup FAPL + * + * \brief Get the current initial metadata cache configuration from the + * provided file access property list + * + * \fapl_id{plist_id} + * \param[in,out] config_ptr Pointer to the instance of #H5AC_cache_config_t + * in which the current metadata cache configuration is to be + * reported + * \return \herr_t + * + * \note The \c in direction applies only to the \ref H5AC_cache_config_t.version + * field. All other fields are \c out parameters. + * + * \details The fields of the #H5AC_cache_config_t structure are shown + * below: + * \snippet H5ACpublic.h H5AC_cache_config_t_snip + * \click4more + * + * H5Pget_mdc_config() gets the initial metadata cache configuration + * contained in a file access property list and loads it into the + * instance of #H5AC_cache_config_t pointed to by the \p config_ptr + * parameter. This configuration is used when the file is opened. + * + * Note that the version field of \Code{*config_ptr} must be + * initialized; this allows the library to support earlier versions of + * the #H5AC_cache_config_t structure. + * + * See the overview of the metadata cache in the special topics section + * of the user guide for details on the configuration data returned. If + * you haven't read and understood that documentation, the results of + * this call will not make much sense. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); /* out */ +/** + * \ingroup FAPL + * + * \brief Retrieves the metadata cache image configuration values for a file + * access property list + * + * \fapl_id{plist_id} + * \param[out] config_ptr Pointer to metadata cache image configuration values + * \return \herr_t + * + * \details H5Pget_mdc_image_config() retrieves the metadata cache image values + * into \p config_ptr for the file access property list specified in \p + * plist_id. + * + * #H5AC_cache_image_config_t is defined as follows: + * \snippet H5ACpublic.h H5AC_cache_image_config_t_snip + * \click4more + * + * \since 1.10.1 + */ +H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); +/** + * \ingroup FAPL + * + * \brief Gets metadata cache logging options + * + * \fapl_id{plist_id} + * \param[out] is_enabled Flag whether logging is enabled + * \param[out] location Location of log in UTF-8/ASCII (file path/name) (On + * Windows, this must be ASCII) + * \param[out] location_size Size in bytes of the location string + * \param[out] start_on_access Whether the logging begins as soon as the file is + * opened or created + * \return \herr_t + * + * \details The metadata cache is a central part of the HDF5 library through + * which all file metadata reads and writes take place. File metadata + * is normally invisible to the user and is used by the library for + * purposes such as locating and indexing data. File metadata should + * not be confused with user metadata, which consists of attributes + * created by users and attached to HDF5 objects such as datasets via + * \ref H5A API calls. + * + * Due to the complexity of the cache, a trace/logging feature has been + * created that can be used by HDF5 developers for debugging and + * performance analysis. The functions that control this functionality + * will normally be of use to a very limited number of developers + * outside of The HDF Group. The functions have been documented to help + * users create logs that can be sent with bug reports. + * + * Control of the log functionality is straightforward. Logging is + * enabled via the H5Pset_mdc_log_options() function, which will modify + * the file access property list used to open or create a file. This + * function has a flag that determines whether logging begins at file + * open or starts in a paused state. Log messages can then be + * controlled via the H5Fstart_mdc_logging() / H5Fstop_mdc_logging() + * functions. H5Pget_mdc_log_options() can be used to examine a file + * access property list, and H5Fget_mdc_logging_status() will return + * the current state of the logging flags. + * + * The log format is described in the + * Metadata Cache Logging document. + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, + size_t *location_size, hbool_t *start_on_access); +/** + * \ingroup FAPL + * + * \brief Returns the current metadata block size setting + * + * \fapl_id{fapl_id} + * \param[out] size Minimum size, in bytes, of metadata block allocations + * + * \return \herr_t + * + * \details Returns the current minimum size, in bytes, of new + * metadata block allocations. This setting is retrieved from the + * file access property list \p fapl_id. + * + * This value is set by H5Pset_meta_block_size() and is + * retrieved from the file access property list \p fapl_id. + * + * \since 1.4.0 + */ +H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size); +/** + * \ingroup FAPL + * + * \brief Retrieves the number of read attempts from a file access + * property list + * + * \fapl_id{plist_id} + * \param[out] attempts The number of read attempts + * + * \return \herr_t + * + * \details H5Pget_metadata_read_attempts() retrieves the number of read + * attempts that is set in the file access property list \p plist_id. + * + * For a default file access property list, the value retrieved + * will depend on whether the user sets the number of attempts via + * H5Pset_metadata_read_attempts(): + * + *
    + * + *
  • If the number of attempts is set to N, the value + * returned will be N. + *
  • If the number of attempts is not set, the value returned + * will be the default for non-SWMR access (1). SWMR is short + * for single-writer/multiple-reader. + *
+ * + * For the file access property list of a specified HDF5 file, + * the value retrieved will depend on how the file is opened + * and whether the user sets the number of read attempts via + * H5Pset_metadata_read_attempts(): + * + *
    + *
  • For a file opened with SWMR access: + * + *
      + *
    • If the number of attempts is set to N, the value + * returned will be N. + *
    • If the number of attempts is not set, the value + * returned will be the default for SWMR access (100). + *
    + *
  • For a file opened without SWMR access, the value + * retrieved will always be the default for non-SWMR access + * (1). The value set via H5Pset_metadata_read_attempts() does + * not have any effect on non-SWMR access. + *
+ * + * \par Failure Modes + * \parblock + * + * When the input property list is not a file access property list. + * + * When the library is unable to retrieve the number of read attempts from + * the file access property list. + * + * \endparblock + * + * \par Examples + * \parblock + * + * The first example illustrates the two cases for retrieving the number + * of read attempts from a default file access property list. + * + * \include H5Pget_metadata_read_attempts.1.c + * + * 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. + * + * \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. + * + * \include H5Pget_metadata_read_attempts.3.c + * + * \endparblock + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts); +/** + * \ingroup FAPL + * + * \brief Retrieves type of data property for MULTI driver + * + * \param[in] fapl_id File access property list or data transfer property + * list identifier + * \param[out] type Type of data + * + * \return \herr_t + * + * \details H5Pget_multi_type() retrieves the type of data setting from + * the file access or data transfer property list \p fapl_id. + * This enables a user application to specify the type of data + * the application wishes to access so that the application can + * retrieve a file handle for low-level access to the particular + * member of a set of MULTI files in which that type of data is + * stored. The file handle is retrieved with a separate call to + * H5Fget_vfd_handle() (or, in special circumstances, to + * H5FDget_vfd_handle(); see the Virtual File Layer documentation + * for more information. + * + * The type of data returned in \p type will be one of those + * listed in the discussion of the \p type parameter in the the + * description of the function H5Pset_multi_type(). + * + * Use of this function is only appropriate for an HDF5 file + * written as a set of files with the MULTI file driver. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); +/** + * \ingroup FAPL + * + * \brief Retrieves the object flush property values from the file access property list + * + * \fapl_id{plist_id} + * \param[in] func The user-defined callback function + * \param[in] udata The user-defined input data for the callback function + * + * \return \herr_t + * + * \details H5Pget_object_flush_cb() gets the user-defined callback + * function that is set in the file access property list + * \p fapl_id and stored in the parameter \p func. The callback is + * invoked whenever an object flush occurs in the file. This + * routine also obtains the user-defined input data that is + * passed along to the callback function in the parameter + * \p udata. + * + * \par Example + * \parblock + * The example below illustrates the usage of this routine to obtain the + * object flush property values. + * + * \include H5Pget_object_flush_cb.c + * \endparblock + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata); +/** + * \ingroup FAPL + * + * \brief Retrieves the maximum size for the page buffer and the minimum + percentage for metadata and raw data pages + * + * \fapl_id{plist_id} + * \param[out] buf_size Maximum size, in bytes, of the page buffer + * \param[out] min_meta_perc Minimum metadata percentage to keep in the + * page buffer before allowing pages containing metadata to + * be evicted + * + * \param[out] min_raw_perc Minimum raw data percentage to keep in the + * page buffer before allowing pages containing raw data to + * be evicted + * + * \return \herr_t + * + * \details H5Pget_page_buffer_size() retrieves \p buf_size, the maximum + * size in bytes of the page buffer, \p min_meta_perc, the + * minimum metadata percentage, and \p min_raw_perc, the + * minimum raw data percentage. + * + * \since 1.10.1 + */ +H5_DLL herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_perc, + unsigned *min_raw_perc); +/** + * \ingroup FAPL + * + * \brief Returns maximum data sieve buffer size + * + * \fapl_id{fapl_id} + * \param[in] size Maximum size, in bytes, of data sieve buffer + * + * \return \herr_t + * + * \details H5Pget_sieve_buf_size() retrieves, size, the current maximum + * size of the data sieve buffer. + * + * This value is set by H5Pset_sieve_buf_size() and is retrieved + * from the file access property list fapl_id. + * + * \version 1.6.0 The \p size parameter has changed from type \c hsize_t + * to \c size_t + * \since 1.4.0 + */ +H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, size_t *size /*out*/); +/** + * \ingroup FAPL + * + * \brief Retrieves the current small data block size setting + * + * \fapl_id{fapl_id} + * \param[out] size Maximum size, in bytes, of the small data block + * + * \result \herr_t + * + * \details H5Pget_small_data_block_size() retrieves the current setting + * for the size of the small data block. + * + * If the returned value is zero (0), the small data block + * mechanism has been disabled for the file. + * + * \since 1.4.4 + */ +H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size /*out*/); +/** + * \ingroup FAPL + * + * \brief Returns the identifier of the current VOL connector + * + * \fapl_id{plist_id} + * \param[out] vol_id Current VOL connector identifier + * + * \return \herr_t + * + * \details H5Pget_vol_id() returns the VOL connector identifier \p vol_id for + * the file access property list \p plist_id. This identifier should + * be closed with H5VLclose(). + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); +/** + * \ingroup FAPL + * + * \brief Returns a copy of the VOL information for a connector + * + * \fapl_id{plist_id} + * \param[out] vol_info The VOL information for a connector + * + * \return \herr_t + * + * \details H5Pget_vol_info() returns a copy of the VOL information \p vol_info + * for a connector specified by the file access property list + * \p plist_id. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); +/** + * \ingroup FAPL + * + * \brief Sets alignment properties of a file access property list + * + * \fapl_id + * \param[in] threshold Threshold value. Note that setting the threshold + * value to 0 (zero) has the effect of a special case, + * forcing everything to be aligned + * \param[in] alignment Alignment value + * + * \return \herr_t + * + * \details H5Pset_alignment() sets the alignment properties of a + * file access property list so that any file object greater + * than or equal in size to \p threshold bytes will be aligned + * on an address which is a multiple of \p alignment. The + * addresses are relative to the end of the user block; the + * alignment is calculated by subtracting the user block size + * from the absolute file address and then adjusting the address + * to be a multiple of \p alignment. + * + * Default values for \p threshold and \p alignment are one, + * implying no alignment. Generally the default values will + * result in the best performance for single-process access to + * the file. For MPI IO and other parallel systems, choose an + * alignment which is a multiple of the disk block size. + * + * If the file space handling strategy is set to + * #H5F_FSPACE_STRATEGY_PAGE, then the alignment set via this + * routine is ignored. The file space handling strategy is set + * by H5Pset_file_space_strategy(). + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment); +/** + * \ingroup FAPL + * + * \brief Sets the raw data chunk cache parameters + * + * \fapl_id{plist_id} + * \param[in] mdc_nelmts No longer used; any value passed is ignored + * \param[in] rdcc_nslots The number of chunk slots in the raw data chunk + * cache for this dataset. Increasing this value + * reduces the number of cache collisions, but + * slightly increases the memory used. Due to the + * hashing strategy, this value should ideally be a + * prime number. As a rule of thumb, this value + * should be at least 10 times the number of chunks + * that can fit in \p rdcc_nbytes bytes. For + * maximum performance, this value should be set + * approximately 100 times that number of chunks. + * The default value is 521. + * \param[in] rdcc_nbytes Total size of the raw data chunk cache in bytes. + * The default size is 1 MB per dataset. + * \param[in] rdcc_w0 The chunk preemption policy for all datasets. + * This must be between 0 and 1 inclusive and + * indicates the weighting according to which chunks + * which have been fully read or written are + * penalized when determining which chunks to flush + * from cache. A value of 0 means fully read or + * written chunks are treated no differently than + * other chunks (the preemption is strictly LRU) + * while a value of 1 means fully read or written + * chunks are always preempted before other chunks. + * If your application only reads or writes data once, + * this can be safely set to 1. Otherwise, this should + * be set lower depending on how often you re-read or + * re-write the same data. The default value is 0.75. + * If the value passed is #H5D_CHUNK_CACHE_W0_DEFAULT, + * then the property will not be set on the dataset + * access property list, and the parameter will come + * from the file access property list. + * + * \return \herr_t + * + * \details H5Pset_cache() sets the number of elements, the total number of + * bytes, and the preemption policy value for all datasets in a file + * on the file’s file access property list. + * + * The raw data chunk cache inserts chunks into the cache by first + * computing a hash value using the address of a chunk and then by + * using that hash value as the chunk’s index into the table of + * cached chunks. In other words, the size of this hash table and the + * number of possible hash values is determined by the \p rdcc_nslots + * parameter. If a different chunk in the cache has the same hash value, + * a collision will occur, which will reduce efficiency. If inserting + * the chunk into the cache would cause the cache to be too big, then + * the cache will be pruned according to the \p rdcc_w0 parameter. + * + * The \p mdc_nelmts parameter is no longer used; any value passed + * in that parameter will be ignored. + * + * \b Motivation: Setting raw data chunk cache parameters + * can be done with H5Pset_cache(), H5Pset_chunk_cache(), + * or a combination of both. H5Pset_cache() is used to + * adjust the chunk cache parameters for all datasets via + * a global setting for the file, and H5Pset_chunk_cache() + * is used to adjust the chunk cache parameters for + * individual datasets. When both are used, parameters + * set with H5Pset_chunk_cache() will override any parameters + * set with H5Pset_cache(). + * + * \note Optimum chunk cache parameters may vary widely depending + * on different data layout and access patterns. For datasets + * with low performance requirements for example, changing + * the cache settings can save memory. + * + * \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 + * 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(). + * \version 1.6.0 The \p rdcc_nbytes and \p rdcc_nelmts parameters + * changed from type int to size_t. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes, + double rdcc_w0); +/** + * \ingroup FAPL + * + * \brief Sets write tracking information for core driver, #H5FD_CORE + * + * \fapl_id{fapl_id} + * \param[in] is_enabled Boolean value specifying whether feature is + enabled + * \param[in] page_size Positive integer specifying size, in bytes, of + * write aggregation pages Value of 1 (one) enables + * tracking with no paging. + * + * \return \herr_t + * + * \details When a file is created or opened for writing using the core + * virtual file driver (VFD) with the backing store option + * turned on, the core driver can be configured to track + * changes to the file and write out only the modified bytes. + * + * This write tracking feature is enabled and disabled with \p + * is_enabled. The default setting is that write tracking is + * disabled, or off. + * + * To avoid a large number of small writes, changes can + * be aggregated into pages of a user-specified size, \p + * page_size. + * + * Setting \p page_size to 1 enables tracking with no page + * aggregation. + * + * The backing store option is set via the function + * H5Pset_fapl_core. + * + * \attention + * \parblock + * This function is only for use with the core VFD and must + * be used after the call to H5Pset_fapl_core(). It is an error + * to use this function with any other VFD. + * + * It is an error to use this function when the backing store + * flag has not been set using H5Pset_fapl_core(). + * + * This function only applies to the backing store write + * operation which typically occurs when the file is flushed + * or closed. This function has no relationship to the + * increment parameter passed to H5Pset_fapl_core(). + * + * For optimum performance, the \p page_size parameter should be + * a power of two. + * + * It is an error to set the page size to 0. + * \endparblock + * + * \version 1.8.14 C function modified in this release to return error + * if \p page_size is set to 0 (zero). + * \since 1.8.13 + * + */ +H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); +/** + * \ingroup FAPL + * + * \brief Sets a file driver + * + * \plist_id + * \param[in] driver_id The new driver identifier + * \param[in] driver_info Optional struct containing driver properties + * + * \return \herr_t + * + * \details H5Pset_driver() sets the file driver, driver_id, for a file + * access or data transfer property list, \p plist_id, and + * supplies an optional struct containing the driver-specific + * properties, \p 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 identifier but still + * use the property list. + * + * \version 1.8.2 Function publicized in this release; previous releases + * described this function only in the virtual file driver + * documentation. + * + */ +H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); +/** + * \ingroup FAPL + * + * \brief Sets the number of files that can be held open in an external + * link open file cache + * + * \par Motivation + * \parblock + * 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 + * certain heavy-use situations and when low-level file opens or closes + * are expensive. + * + * H5Pset_elink_file_cache_size() sets the number of files + * that will be held open in an external link open file + * cache. H5Pget_elink_file_cache_size() retrieves the size of an existing + * cache; and H5Fclear_elink_file_cache() clears an existing cache without + * closing it. + * \endparblock + * + * \fapl_id{plist_id} + * \param[in] efc_size External link open file cache size in number of files + * Default setting is 0 (zero). + * + * \return \herr_t + * + * \details H5Pset_elink_file_cache_size() specifies the number of files + * that will be held open in an external link open file cache. + * + * The default external link open file cache size is 0 (zero), + * meaning that files accessed via an external link are not + * held open. Setting the cache size to a positive integer + * turns on the cache; setting the size back to zero turns it + * off. + * + * With this property set, files are placed in the external + * link open file cache cache when they are opened via an + * external link. Files are then held open until either + * they are evicted from the cache or the parent file is + * closed. This property setting can improve performance when + * external links are repeatedly accessed. + * + * When the cache is full, files will be evicted using a least + * recently used (LRU) scheme; the file which has gone the + * longest time without being accessed through the parent file + * will be evicted and closed if nothing else is holding that + * file open. + * + * Files opened through external links inherit the parent + * file’s file access property list by default, and therefore + * inherit the parent file’s external link open file cache + * setting. + * + * When child files contain external links of their own, the + * caches can form a graph of cached external files. Closing + * the last external reference to such a graph will recursively + * close all files in the graph, even if cycles are present. + * \par Example + * \parblock + * The following code sets up an external link open file cache that will + * hold open up to 8 files reached through external links: + * + * \code + * status = H5Pset_elink_file_cache_size(fapl_id, 8); + * \endcode + * \endparblock + * + * \since 1.8.7 + */ +H5_DLL herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size); +/** + * \ingroup FAPL + * + * \brief Controls the library's behavior of evicting metadata associated with + * a closed object + * + * \fapl_id + * \param[in] evict_on_close Whether the HDF5 object should be evicted on close + * + * \return \herr_t + * + * \details The library's metadata cache is fairly conservative about holding + * on to HDF5 object metadata(object headers, chunk index structures, + * etc.), which can cause the cache size to grow, resulting in memory + * pressure on an application or system. When enabled, the "evict on + * close" property will cause all metadata for an object to be evicted + * from the cache as long as metadata is not referenced by any other + * open object. + * + * This function only applies to file access property lists. + * + * The default library behavior is to not evict on object or file + * close. + * + * When applied to a file access property list, any subsequently opened + * object will inherit the "evict on close" property and will have + * its metadata evicted when the object is closed. + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close); +/** + * \ingroup FAPL + * + * \brief Sets offset property for low-level access to a file in a family of + * files + * + * \fapl_id + * \param[in] offset Offset in bytes within the HDF5 file + * + * \return \herr_t + * + * \details H5Pset_family_offset() sets the offset property in the file access + * property list \p fapl_id so that the user application can + * retrieve a file handle for low-level access to a particular member + * of a family of files. The file handle is retrieved with a separate + * call to H5Fget_vfd_handle() (or, in special circumstances, to + * H5FDget_vfd_handle(); see \ref VFL). + * + * The value of \p offset is an offset in bytes from the beginning of + * the HDF5 file, identifying a user-determined location within the + * HDF5 file. + * The file handle the user application is seeking is for the specific + * member-file in the associated family of files to which this offset + * is mapped. + * + * Use of this function is only appropriate for an HDF5 file written as + * a family of files with the \c FAMILY file driver. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); +/** + * \ingroup FAPL + * + * \brief Sets the file close degree + * + * \fapl_id + * \param[in] degree Pointer to a location containing the file close + * degree property, the value of \p degree + * + * \return \herr_t + * + * \details H5Pset_fclose_degree() sets the file close degree property + * \p degree in the file access property list \p fapl_id. + * + * The value of \p degree determines how aggressively + * H5Fclose() deals with objects within a file that remain open + * when H5Fclose() is called to close that file. \p degree can + * have any one of four valid values: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Degree nameH5Fclose behavior with no open object in fileH5Fclose behavior with open object(s) in file
#H5F_CLOSE_WEAKActual file is closed.Access to file identifier is terminated; actual file + * close is delayed until all objects in file are closed + *
#H5F_CLOSE_SEMIActual file is closed.Function returns FAILURE
#H5F_CLOSE_STRONGActual file is closed.All open objects remaining in the file are closed then + * file is closed
#H5F_CLOSE_DEFAULTThe VFL driver chooses the behavior. Currently, all VFL + * drivers set this value to #H5F_CLOSE_WEAK, except for the + * MPI-I/O driver, which sets it to #H5F_CLOSE_SEMI.
+ * \warning If a file is opened multiple times without being closed, each + * open operation must use the same file close degree setting. + * For example, if a file is already open with #H5F_CLOSE_WEAK, + * an H5Fopen() call with #H5F_CLOSE_STRONG will fail. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); +/** + * \ingroup FAPL + * + * \brief Sets an initial file image in a memory buffer + * + * \fapl_id + * \param[in] buf_ptr Pointer to the initial file image, or + * NULL if no initial file image is desired + * \param[in] buf_len Size of the supplied buffer, or + * 0 (zero) if no initial image is desired + * + * \return \herr_t + * + * \details H5Pset_file_image() allows an application to provide a file image + * to be used as the initial contents of a file. + * Calling H5Pset_file_image()makes a copy of the buffer specified in + * \p buf_ptr of size \p buf_len. + * + * \par Motivation: + * H5Pset_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. + * + * \par Recommended Reading: + * This function is part of the file image + * operations feature set. It is highly recommended to study the guide + * [HDF5 File Image Operations] + * (https://portal.hdfgroup.org/display/HDF5/HDF5+File+Image+Operations + * ) before using this feature set. See the “See Also” section below + * for links to other elements of HDF5 file image operations. + * + * \see + * \li H5LTopen_file_image() + * \li H5Fget_file_image() + * \li H5Pget_file_image() + * \li H5Pset_file_image_callbacks() + * \li H5Pget_file_image_callbacks() + * + * \li [HDF5 File Image Operations] + * (https://portal.hdfgroup.org/display/HDF5/HDF5+File+Image+Operations) + * in [Advanced Topics in HDF5] + * (https://portal.hdfgroup.org/display/HDF5/Advanced+Topics+in+HDF5) + * + * \li Within H5Pset_file_image_callbacks(): + * \li Callback #H5FD_file_image_callbacks_t + * \li Callback #H5FD_file_image_op_t + * + * \version 1.8.13 Fortran subroutine added in this release. + * \since 1.8.9 + * + */ +H5_DLL herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len); +/** + * \ingroup FAPL + * + * \brief Sets the callbacks for working with file images + * + * \note **Motivation:** H5Pset_file_image_callbacks() 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.\n + * **Recommended Reading:** This function is part of the file + * image operations feature set. It is highly recommended to study + * the guide [HDF5 File Image Operations] + * (https://portal.hdfgroup.org/display/HDF5/HDF5+File+Image+Operations + * ) before using this feature set. See the “See Also” section below + * for links to other elements of HDF5 file image operations. + * + * \fapl_id + * \param[in,out] callbacks_ptr Pointer to the instance of the + * #H5FD_file_image_callbacks_t structure + * + * \return \herr_t \n + * **Failure Modes**: Due to interactions between this function and + * H5Pset_file_image() and H5Pget_file_image(), + * H5Pset_file_image_callbacks() will fail if a file image has + * already been set in the target file access property list, \p fapl_id. + * + * \details H5Pset_file_image_callbacks() sets callback functions for working + * with file images in memory. + * + * H5Pset_file_image_callbacks() allows an application to control the + * management of file image buffers through user defined callbacks. + * These callbacks can be used in the management of file image buffers + * in property lists and with certain file drivers. + * + * H5Pset_file_image_callbacks() must be used before any file image has + * been set in the file access property list. Once a file image has + * been set, the function will fail. + * + * The callback routines set up by H5Pset_file_image_callbacks() are + * invoked when a new file image buffer is allocated, when an existing + * file image buffer is copied or resized, or when a file image buffer + * is released from use. + * + * Some file drivers allow the use of user-defined callback functions + * for allocating, freeing, and copying the driver’s internal buffer, + * potentially allowing optimizations such as avoiding large \c malloc + * and \c memcpy operations, or to perform detailed logging. + * + * From the perspective of the HDF5 library, the operations of the + * \ref H5FD_file_image_callbacks_t.image_malloc "image_malloc", + * \ref H5FD_file_image_callbacks_t.image_memcpy "image_memcpy", + * \ref H5FD_file_image_callbacks_t.image_realloc "image_realloc", and + * \ref H5FD_file_image_callbacks_t.image_free "image_free" callbacks + * must be identical to those of the + * corresponding C standard library calls (\c malloc, \c memcpy, + * \c realloc, and \c free). While the operations must be identical, + * the file image callbacks have more parameters. The return values + * of \ref H5FD_file_image_callbacks_t.image_malloc "image_malloc" and + * \ref H5FD_file_image_callbacks_t.image_realloc "image_realloc" are identical to + * the return values of \c malloc and \c realloc. The return values of + * \ref H5FD_file_image_callbacks_t.image_malloc "image_malloc" and + * \ref H5FD_file_image_callbacks_t.image_free "image_free" differ from the return + * values of \c memcpy and \c free in that the return values of + * \ref H5FD_file_image_callbacks_t.image_memcpy "image_memcpy" and + * \ref H5FD_file_image_callbacks_t.image_free "image_free" can also indicate failure. + * + * The callbacks and their parameters, along with a struct and + * an \c ENUM required for their use, are described below. + * + * Callback struct and \c ENUM: + * + * The callback functions set up by H5Pset_file_image_callbacks() use + * a struct and an \c ENUM that are defined as follows + * + * The struct #H5FD_file_image_callbacks_t serves as a container + * for the callback functions and a pointer to user-supplied data. + * The struct is defined as follows: + * \snippet H5FDpublic.h H5FD_file_image_callbacks_t_snip + * + * Elements of the #H5FD_file_image_op_t are used by the + * callbacks to invoke certain operations on file images. The ENUM is + * defined as follows: + * \snippet H5FDpublic.h H5FD_file_image_op_t_snip + * + * The elements of the #H5FD_file_image_op_t are used in the following + * callbacks: + * + * - The \ref H5FD_file_image_callbacks_t.image_malloc "image_malloc" callback + * contains a pointer to a function that must appear to HDF5 to have + * functionality identical to that of the standard C library \c malloc() call. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h image_malloc_snip + * \n + * - The \ref H5FD_file_image_callbacks_t.image_memcpy "image_memcpy" + * callback contains a pointer to a function + * that must appear to HDF5 to have functionality identical to that + * of the standard C library \c memcopy() call, except that it returns + * a \p NULL on failure. (The \c memcpy C Library routine is defined + * to return the \p dest parameter in all cases.) + * + * - Setting \ref H5FD_file_image_callbacks_t.image_memcpy "image_memcpy" + * to \c NULL indicates that HDF5 should invoke + * the standard C library \c memcpy() routine when copying buffers. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h image_memcpy_snip + * \n + * - The \ref H5FD_file_image_callbacks_t.image_realloc "image_realloc" callback + * contains a pointer to a function that must appear to HDF5 to have + * functionality identical to that of the standard C library \c realloc() call. + * + * - Setting \ref H5FD_file_image_callbacks_t.image_realloc "image_realloc" + * to \p NULL indicates that HDF5 should + * invoke the standard C library \c realloc() routine when resizing + * file image buffers. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h image_realloc_snip + * \n + * - The \ref H5FD_file_image_callbacks_t.image_free "image_free" callback contains + * a pointer to a function that must appear to HDF5 to have functionality + * identical to that of the standard C library \c free() call, except + * that it will return \c 0 (\c SUCCEED) on success and \c -1 (\c FAIL) on failure. + * + * - Setting \ref H5FD_file_image_callbacks_t.image_free "image_free" + * to \c NULL indicates that HDF5 should invoke + * the standard C library \c free() routine when releasing file image + * buffers. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h image_free_snip + * \n + * - The \ref H5FD_file_image_callbacks_t.udata_copy "udata_copy" + * callback contains a pointer to a function + * that, from the perspective of HDF5, allocates a buffer of suitable + * size, copies the contents of the supplied \p udata into the new + * buffer, and returns the address of the new buffer. The function + * returns NULL on failure. This function is necessary if a non-NULL + * \p udata parameter is supplied, so that property lists containing + * the image callbacks can be copied. If the \p udata parameter below + * is \c NULL, then this parameter should be \c NULL as well. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h udata_copy_snip + * \n + * - The \ref H5FD_file_image_callbacks_t.udata_free "udata_free" + * callback contains a pointer to a function + * that, from the perspective of HDF5, frees a user data block. This + * function is necessary if a non-NULL udata parameter is supplied so + * that property lists containing image callbacks can be discarded + * without a memory leak. If the udata parameter below is \c NULL, + * this parameter should be \c NULL as well. + * + * - Signature in #H5FD_file_image_callbacks_t: + * \snippet H5FDpublic.h udata_free_snip + * + * - \p **udata**, the final field in the #H5FD_file_image_callbacks_t + * struct, provides a pointer to user-defined data. This pointer will + * be passed to the + * \ref H5FD_file_image_callbacks_t.image_malloc "image_malloc", + * \ref H5FD_file_image_callbacks_t.image_memcpy "image_memcpy", + * \ref H5FD_file_image_callbacks_t.image_realloc "image_realloc", and + * \ref H5FD_file_image_callbacks_t.image_free "image_free" callbacks. + * Define udata as \c NULL if no user-defined data is provided. + * + * \since 1.8.9 + * + */ +H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); +/** + * \ingroup FAPL + * + * \brief Sets the file locking property values + * + * \fapl_id + * \param[in] use_file_locking Toggle to specify file locking (or not) + * \param[in] ignore_when_disabled Toggle to ignore when disabled (or not) + * + * \return \herr_t + * + * \details H5Pset_file_locking() overrides the default file locking flag + * setting that was set when the library was configured. + * + * This setting can be overridden by the \c HDF5_USE_FILE_LOCKING + * environment variable. + * + * File locking is used when creating/opening a file to prevent + * problematic file accesses. + * + * \since 1.10.7 + * + */ +H5_DLL herr_t H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled); +/** + * \ingroup FAPL + * + * \brief Sets garbage collecting references flag + * + * \fapl_id + * \param[in] gc_ref Flag setting reference garbage collection to on (1) or off (0) + * + * \return \herr_t + * + * \details H5Pset_gc_references() sets the flag for garbage collecting + * references for the file. + * + * Dataset region references and other reference types use space in an + * HDF5 file's global heap. If garbage collection is on and the user + * passes in an uninitialized value in a reference structure, the heap + * might get corrupted. When garbage collection is off, however, and + * the user re-uses 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. + * + * The default value for garbage collecting references is off. + * + */ +H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); +/** + * \ingroup FAPL + * + * \brief Controls the range of library release versions used when creating + * objects in a file + * + * \fapl_id{plist_id} + * \param[in] low The earliest version of the library that will be used + * for writing objects + * \param[in] high The latest version of the library that will be used for + * writing objects + * + * \return \herr_t + * + * \details H5Pset_libver_bounds() controls the range of library release + * versions that will be used when creating objects in a file. + * The object format versions are determined indirectly from the + * library release versions specified in the call. + * + * This property is set in the file access property list + * specified by the parameter \p fapl_id. + * + * The parameter \p low sets the earliest possible format + * versions that the library will use when creating objects in + * the file. Note that earliest possible is different from + * earliest, as some features introduced in library versions + * later than 1.0.0 resulted in updates to object formats. + * The parameter \p high sets the latest format versions that + * the library will be allowed to use when creating objects in + * the file. + * + * The parameters \p low and \p high must be one of the + * enumerated values in the #H5F_libver_t struct, which is + * defined in H5Fpublic.h. + * + * The macro #H5F_LIBVER_LATEST is aliased to the highest + * enumerated value in #H5F_libver_t, indicating that this is + * currently the latest format available. + * + * The library supports the following five pairs of + * (\p low, \p high) combinations as derived from the values + * in #H5F_libver_t: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Value of \p low and \p highResult
\p low=#H5F_LIBVER_EARLIEST
+ * \p high=#H5F_LIBVER_V18
+ * \li The library will create objects with the earliest + * possible format versions. + * \li The library will allow objects to be created with the + * latest format versions available to library release 1.8.x. + * \li API calls that create objects or features that are + * available to versions of the library greater than 1.8.x + * release will fail. + *
\p low=#H5F_LIBVER_EARLIEST
+ * \p high=#H5F_LIBVER_V110
+ * \li The library will create objects with the earliest possible + * format versions. + * \li The library will allow objects to be created with the latest + * format versions available to library release 1.10.x. + * Since 1.10.x is also #H5F_LIBVER_LATEST, there is no upper + * limit on the format versions to use. For example, if a newer + * format version is required to support a feature e.g. virtual + * dataset, this setting will allow the object to be created. + * \li This is the library default setting and provides the greatest + * format compatibility. + *
\p low=#H5F_LIBVER_V18
+ * \p high=#H5F_LIBVER_V18
+ * \li The library will create objects with the latest format + * versions available to library release 1.8.x. + * \li API calls that create objects or features that are available + * to versions of the library greater than 1.8.x release will + * fail. + * \li Earlier versions of the library may not be able to access + * objects created with this setting.
\p low=#H5F_LIBVER_V18
+ * \p high=#H5F_LIBVER_V110
+ * \li The library will create objects with the latest format + * versions available to library release 1.8.x. + * \li The library will allow objects to be created with the latest + * format versions available to library release 1.10.x. + * Since 1.10.x is also #H5F_LIBVER_LATEST, there is no upper + * limit on the format versions to use. For example, if a + * newer format version is required to support a feature e.g. + * virtual dataset, this setting will allow the object to be + * created. + * \li Earlier versions of the library may not be able to access + * objects created with this setting.
\p low=#H5F_LIBVER_V110
+ * \p high=#H5F_LIBVER_V110 + *
+ * \li The library will create objects with the latest format + * versions available to library release 1.10.x. + * \li The library will allow objects to be created with the latest + * format versions available to library release 1.10.x. + * Since 1.10.x is also #H5F_LIBVER_LATEST, there is no upper + * limit on the format versions to use. For example, if a + * newer format version is required to support a feature e.g. + * virtual dataset, this setting will allow the object to be + * created. + * \li This setting allows users to take advantage of the latest + * features and performance enhancements in the library. + * However, objects written with this setting may be + * accessible to a smaller range of library versions than + * would be the case if low is set to #H5F_LIBVER_EARLIEST. + * \li Earlier versions of the library may not be able to access + * objects created with this + * setting. + *
+ * + * \version 1.10.2 #H5F_LIBVER_V18 added to the enumerated defines in + * #H5F_libver_t. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high); +/** + * \ingroup FAPL + * + * \brief Set the initial metadata cache configuration in the indicated File + * Access Property List to the supplied value + * + * \fapl_id{plist_id} + * \param[in] config_ptr Pointer to the instance of \p H5AC_cache_config_t + * containing the desired configuration + * \return \herr_t + * + * \details The fields of the #H5AC_cache_config_t structure are shown + * below: + * \snippet H5ACpublic.h H5AC_cache_config_t_snip + * \click4more + * + * \details H5Pset_mdc_config() attempts to set the initial metadata cache + * configuration to the supplied value. It will fail if an invalid + * configuration is detected. This configuration is used when the file + * is opened. + * + * See the overview of the metadata cache in the special topics section + * of the user manual for details on what is being configured. If you + * have not read and understood that documentation, you really should + * not be using this API call. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); +/** + * \ingroup FAPL + * + * \brief Sets metadata cache logging options + * + * \fapl_id{plist_id} + * \param[in] is_enabled Whether logging is enabled + * \param[in] location Location of log in UTF-8/ASCII (file path/name) + * (On Windows, this must be ASCII) + * \param[in] start_on_access Whether the logging will begin as soon as the + * file is opened or created + * + * \return \herr_t + * + * \details The metadata cache is a central part of the HDF5 library through + * which all file metadata reads and writes take place. File metadata + * is normally invisible to the user and is used by the library for + * purposes such as locating and indexing data. File metadata should + * not be confused with user metadata, which consists of attributes + * created by users and attached to HDF5 objects such as datasets via + * H5A API calls. + * + * Due to the complexity of the cache, a trace/logging feature has + * been created that can be used by HDF5 developers for debugging and + * performance analysis. The functions that control this functionality + * will normally be of use to a very limited number of developers + * outside of The HDF Group. The functions have been documented to + * help users create logs that can be sent with bug reports. + * + * Control of the log functionality is straightforward. Logging is + * enabled via the H5Pset_mdc_log_options() function, + * which will modify the file access property list used to open or + * create a file. This function has a flag that determines whether + * logging begins at file open or starts in a paused state. Log + * messages can then be controlled via the H5Fstart_mdc_logging() + * and H5Fstop_mdc_logging() function. + * + * H5Pget_mdc_log_options() can be used to examine a file access + * property list, and H5Fget_mdc_logging_status() will return the + * current state of the logging flags. + * + * The log format is described in [Metadata Cache Logging] + * (https://portal.hdfgroup.org/display/HDF5/Fine-tuning+the+Metadata+Cache). + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, + hbool_t start_on_access); +/** + * \ingroup FAPL + * + * \brief Sets the minimum metadata block size + * + * \fapl_id{fapl_id} + * \param[in] size Minimum size, in bytes, of metadata block allocations + * + * \return \herr_t + * + * \details H5Pset_meta_block_size() sets the minimum size, in bytes, of + * metadata block allocations when #H5FD_FEAT_AGGREGATE_METADATA is set by a VFL + * driver. + + * Each raw metadata block is initially allocated to be of the given size. + * Specific metadata objects (e.g., object headers, local heaps, B-trees) are then + * sub-allocated from this block. + * + * The default setting is 2048 bytes, meaning that the library will + * attempt to aggregate metadata in at least 2K blocks in the file. + * Setting the value to zero (\Code{0}) with this function will turn + * off metadata aggregation, even if the VFL driver attempts to use the + * metadata aggregation strategy. + * + * Metadata aggregation reduces the number of small data objects in the file that + * would otherwise be required for metadata. The aggregated block of metadata is + * usually written in a single write action and always in a contiguous block, + * potentially significantly improving library and application performance. + * + * \since 1.4.0 + */ +H5_DLL herr_t H5Pset_meta_block_size(hid_t fapl_id, hsize_t size); +/** + * \ingroup FAPL + * + * \brief Sets the number of read attempts in a file access property list + * + * \fapl_id{plist_id} + * \param[in] attempts The number of read attempts. Must be a value greater than \Code{0} + * + * \return \herr_t + * + * \return Failure Modes: + * - When the user sets the number of read attempts to \Code{0}. + * - When the input property list is not a file access property list. + * - When the library is unable to set the number of read attempts in the file access property list. + * + * \details H5Pset_metadata_read_attempts() sets the number of reads that the + * library will try when reading checksummed metadata in an HDF5 file opened + * with SWMR access. When reading such metadata, the library will compare the + * checksum computed for the metadata just read with the checksum stored within + * the piece of checksum. When performing SWMR operations on a file, the + * checksum check might fail when the library reads data on a system that is not + * atomic. To remedy such situations, the library will repeatedly read the piece + * of metadata until the check passes or finally fails the read when the allowed + * number of attempts is reached. + * + * The number of read attempts used by the library will depend on how the file is + * opened and whether the user sets the number of read attempts via this routine: + + * - For a file opened with SWMR access: + * - If the user sets the number of attempts to \Code{N}, the library will use \Code{N}. + * - If the user does not set the number of attempts, the library will use the + * default for SWMR access (\Code{100}). + * - For a file opened with non-SWMR access, the library will always use the default + * for non-SWMR access (\Code{1}). The value set via this routine does not have any effect + * during non-SWMR access. + * + * \b Example: The first example illustrates the case in setting the number of read attempts for a file + * opened with SWMR access. + * + * \snippet H5Pset_metadata_read_attempts.c SWMR Access + * + * \b Example: The second example illustrates the case in setting the number of + * read attempts for a file opened with non-SWMR access. The value + * set in the file access property list does not have any effect. + * + * \snippet H5Pset_metadata_read_attempts.c non-SWMR Access + * + * \note \b Motivation: On a system that is not atomic, the library might + * possibly read inconsistent metadata with checksum when performing + * single-writer/multiple-reader (SWMR) operations for an HDF5 file. Upon + * encountering such situations, the library will try reading the metadata + * again to obtain consistent data. This routine provides the means to set + * the number of read attempts other than the library default. + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts); +/** + * \ingroup FAPL + * + * \brief Specifies type of data to be accessed via the \Code{MULTI} driver, + * enabling more direct access + * + * \fapl_id{fapl_id} + * \param[in] type Type of data to be accessed + * + * \return \herr_t + * + * \details H5Pset_multi_type() sets the \Emph{type of data} property in the file + * access property list \p fapl_id. This setting enables a user + * application to specify the type of data the application wishes to + * access so that the application can retrieve a file handle for + * low-level access to the particular member of a set of \Code{MULTI} + * files in which that type of data is stored. The file handle is + * retrieved with a separate call to H5Fget_vfd_handle() (or, in special + * circumstances, to H5FDget_vfd_handle(); see \ref VFL. + * + * The type of data specified in \p type may be one of the following: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5FD_MEM_SUPER Super block data
#H5FD_MEM_BTREE B-tree data
#H5FD_MEM_DRAW Dataset raw data
#H5FD_MEM_GHEAP Global heap data
#H5FD_MEM_LHEAP Local Heap data
#H5FD_MEM_OHDR Object header data
+ * + * This function is for use only when accessing an HDF5 file written as a set of + * files with the \Code{MULTI} file driver. + * + * \since 1.6.0 + */ +H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); +/** + * \ingroup FAPL + * + * \brief Sets a callback function to invoke when an object flush occurs in the file + * + * \fapl_id{plist_id} + * \op{func} + * \op_data_in{udata} + * + * \return \herr_t + * + * \details H5Pset_object_flush_cb() sets the callback function to invoke in the + * file access property list \p plist_id whenever an object flush occurs in + * the file. Library objects are group, dataset, and committed + * datatype. + * + * The callback function \p func must conform to the prototype defined below: + * \code + * typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *user_data) + * \endcode + * + * The parameters of the callback function, per the above prototypes, are defined as follows: + * - \Code{object_id} is the identifier of the object which has just been flushed. + * - \Code{user_data} is the user-defined input data for the callback function. + * + * \b Example: The example below illustrates the usage of this routine to set + * the callback function to invoke when an object flush occurs. + * + * \include H5Pset_object_flush_cb.c + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata); +/** + * \ingroup FAPL + * + * \brief Sets the maximum size of the data sieve buffer + * + * \fapl_id{fapl_id} + * \param[in] size Maximum size, in bytes, of data sieve buffer + * + * \return \herr_t + * + * \details H5Pset_sieve_buf_size() sets \p size, the maximum size in bytes of the + * data sieve buffer, which is used by file drivers that 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 enough to hold several pieces of + * the dataset being read in for hyperslab selections boosts + * performance by quite a bit. + * + * The default value is set to 64KB, indicating that file I/O for raw + * data reads and writes will occur in at least 64KB blocks. Setting + * the value to zero (\Code{0}) with this API function will turn off + * the data sieving, even if the VFL driver attempts to use that + * strategy. + * + * Internally, the library checks the storage sizes of the datasets in + * the file. It picks the smaller one between the size from the file + * access property and the size of the dataset to allocate the sieve + * buffer for the dataset in order to save memory usage. + * + * \version 1.6.0 The \p size parameter has changed from type \Code{hsize_t} to \Code{size_t}. + * + * \since 1.4.0 + */ +H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, size_t size); +/** + * \ingroup FAPL + * + * \brief Sets the size of a contiguous block reserved for small data + * + * \fapl_id{fapl_id} + * \param[in] size Maximum size, in bytes, of the small data block. + The default size is \Code{2048}. + * + * \return \herr_t + * + * \details H5Pset_small_data_block_size() reserves blocks of \p size bytes for the + * contiguous storage of the raw data portion of \Emph{small} datasets. The + * HDF5 library then writes the raw data from small datasets to this + * reserved space, thus reducing unnecessary discontinuities within + * blocks of meta data and improving I/O performance. + * + * A small data block is actually allocated the first time a qualifying + * small dataset is written to the file. Space for the raw data portion + * of this small dataset is suballocated within the small data block. + * The raw data from each subsequent small dataset is also written to + * the small data block until it is filled; additional small data + * blocks are allocated as required. + * + * The HDF5 library employs an algorithm that determines whether I/O + * performance is likely to benefit from the use of this mechanism with + * each dataset as storage space is allocated in the file. A larger + * \p size will result in this mechanism being employed with larger + * datasets. + * + * The small data block size is set as an allocation property in the + * file access property list identified by \p fapl_id. + * + * Setting \p size to zero (\Code{0}) disables the small data block mechanism. + * + * \since 1.4.4 + */ +H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); +/** + * \ingroup FAPL + * + * \brief Set the file VOL connector for a file access property list + * + * \fapl_id{plist_id} + * \param[in] new_vol_id VOL connector identifier + * \param[in] new_vol_info Optional VOL information + * + * \return \herr_t + * + * \details H5Pset_vol() sets the VOL connector \p new_vol_id for a file access + * property list \p plist_id using the (optional) VOL information in + * \p new_vol_info. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); + +#ifdef H5_HAVE_PARALLEL +/** + * \ingroup GACPL + * + * \brief Sets metadata I/O mode for read operations to collective or independent (default) + * + * \gacpl_id + * \param[in] is_collective Boolean value indicating whether metadata reads are collective + * (\Code{1}) or independent (\Code{0}). + * Default mode: Independent (\Code{0}) + * + * \return \herr_t + * + * \details H5Pset_all_coll_metadata_ops() sets the metadata I/O mode for read + * operations in the access property list \p plist_id. + * + * When engaging in parallel I/O, all metadata write operations must be + * collective. If \p is_collective is \Code{1}, this property specifies + * that the HDF5 library will perform all metadata read operations + * collectively; if \p is_collective is \Code{0}, such operations may + * be performed independently. + * + * Users must be aware that several HDF5 operations can potentially + * issue metadata reads. These include opening a dataset, datatype, or + * group; reading an attribute; or issuing a \Emph{get info} call such + * as getting information for a group with H5Fget_info(). Collective + * I/O requirements must be kept in mind when issuing such calls in the + * context of parallel I/O. + * + * If this property is collective on a file access property list that + * is used in creating or opening a file, then the HDF5 library will + * assume that all metadata read operations issued on that file + * identifier will be issued collectively from all ranks irrespective + * of the individual setting of a particular operation. If this + * assumption is not adhered to, corruption will be introduced in the + * metadata cache and HDF5’s behavior will be undefined. + * + * Alternatively, a user may wish to avoid setting this property + * globally on the file access property list, and individually set it + * on particular object access property lists (dataset, group, link, + * datatype, attribute access property lists) for certain operations. + * This will indicate that only the operations issued with such an + * access property list will be called collectively and other + * operations may potentially be called independently. There are, + * however, several HDF5 operations that can issue metadata reads but + * have no property list in their function signatures to allow passing + * the collective requirement property. For those operations, the only + * option is to set the global collective requirement property on the + * file access property list; otherwise the metadata reads that can be + * triggered from those operations will be done independently by each + * process. + * + * Functions that do not accommodate an access property list but that + * might issue metadata reads are listed in \ref maybe_metadata_reads. + * + * \attention As noted above, corruption will be introduced into the metadata + * cache and HDF5 library behavior will be undefined when both of the following + * conditions exist: + * - A file is created or opened with a file access property list in which the + * collective metadata I/O property is set to \Code{1}. + * - Any function is called that triggers an independent metadata read while the + * file remains open with that file access property list. + * + * \attention An approach that avoids this corruption risk is described above. + * + * \sa_metadata_ops + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective); +/** + * \ingroup GACPL + * + * \brief Retrieves metadata read mode setting + * + * \gacpl_id + * \param[out] is_collective Pointer to a buffer containing the Boolean value indicating whether metadata + * reads are collective (\Code{>0}) or independent (\Code{0}). + * Default mode: Independent (\Code{0}) + * + * \return \herr_t + * + * \details H5Pget_all_coll_metadata_ops() retrieves the collective metadata read setting from the access + * property list \p plist_id into \p is_collective. + * + * \sa_metadata_ops + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); +/** + * \ingroup FAPL + * + * \brief Sets metadata write mode to collective or independent (default) + * + * \fapl_id{plist_id} + * \param[out] is_collective Boolean value indicating whether metadata + * writes are collective (\Code{>0}) or independent (\Code{0}). + * \Emph{Default mode:} Independent (\Code{0}) + * \return \herr_t + * + * \details H5Pset_coll_metadata_write() tells the HDF5 library whether to + * perform metadata writes collectively (1) or independently (0). + * + * If collective access is selected, then on a flush of the metadata + * cache, all processes will divide the metadata cache entries to be + * flushed evenly among themselves and issue a single MPI-IO collective + * write operation. This is the preferred method when the size of the + * metadata created by the application is large. + * + * If independent access is selected, the library uses the default + * method for doing metadata I/O either from process zero or + * independently from each process. + * + * \sa_metadata_ops + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pset_coll_metadata_write(hid_t plist_id, hbool_t is_collective); +/** + * \ingroup FAPL + * + * \brief Retrieves metadata write mode setting + * + * \fapl_id{plist_id} + * \param[out] is_collective Pointer to a boolean value indicating whether + * metadata writes are collective (\Code{>0}) or independent (\Code{0}). + * \Emph{Default mode:} Independent (\Code{0}) + * \return \herr_t + * + * \details H5Pget_coll_metadata_write() retrieves the collective metadata write + * setting from the file access property into \p is_collective. + * + * \sa_metadata_ops + * + * \since 1.10.0 + */ +H5_DLL herr_t H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective); + +/** + * \todo Add missing documentation + */ +H5_DLL herr_t H5Pget_mpi_params(hid_t fapl_id, MPI_Comm *comm, MPI_Info *info); + +/** + * \todo Add missing documentation + */ +H5_DLL herr_t H5Pset_mpi_params(hid_t fapl_id, MPI_Comm comm, MPI_Info info); +#endif /* H5_HAVE_PARALLEL */ +/** + * \ingroup FAPL + * + * \brief Sets the metadata cache image option for a file access property list + * + * \fapl_id{plist_id} + * \param[out] config_ptr Pointer to metadata cache image configuration values + * \return \herr_t + * + * \details H5Pset_mdc_image_config() sets the metadata cache image option with + * configuration values specified by \p config_ptr for the file access + * property list specified in \p plist_id. + * + * #H5AC_cache_image_config_t is defined as follows: + * \snippet H5ACpublic.h H5AC_cache_image_config_t_snip + * \click4more + * + * \par Limitations: While it is an obvious error to request a cache image when + * opening the file read only, it is not in general possible to test for + * this error in the H5Pset_mdc_image_config() call. Rather than fail the + * subsequent file open, the library silently ignores the file image + * request in this case.\n It is also an error to request a cache image on + * a file that does not support superblock extension messages (i.e. a + * superblock version less than 2). As above, it is not always possible to + * detect this error in the H5Pset_mdc_image_config() call, and thus the + * request for a cache image will fail silently in this case as well.\n + * Creation of cache images is currently disabled in parallel -- as above, + * any request for a cache image in this context will fail silently.\n + * Files with cache images may be read in parallel applications, but note + * that the load of the cache image is a collective operation triggered by + * the first operation that accesses metadata after file open (or, if + * persistent free space managers are enabled, on the first allocation or + * deallocation of file space, or read of file space manager status, + * whichever comes first). Thus the parallel process may deadlock if any + * process does not participate in this access.\n + * In long sequences of file closes and opens, infrequently accessed + * metadata can accumulate in the cache image to the point where the cost + * of storing and restoring this metadata exceeds the benefit of retaining + * frequently used metadata in the cache image. When implemented, the + * #H5AC_cache_image_config_t::entry_ageout should address this problem. In + * the interim, not requesting a cache image every n file close/open cycles + * may be an acceptable work around. The choice of \c n will be driven by + * application behavior, but \Code{n = 10} seems a good starting point. + * + * \since 1.10.1 + */ +H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); +/** + * \ingroup FAPL + * + * \brief Sets the maximum size for the page buffer and the minimum percentage + * for metadata and raw data pages + * + * \fapl_id{plist_id} + * \param[in] buf_size Maximum size, in bytes, of the page buffer + * \param[in] min_meta_per Minimum metadata percentage to keep in the page buffer + * before allowing pages containing metadata to be evicted (Default is 0) + * \param[in] min_raw_per Minimum raw data percentage to keep in the page buffer + * before allowing pages containing raw data to be evicted (Default is 0) + * \return \herr_t + * + * \details H5Pset_page_buffer_size() sets buf_size, the maximum size in bytes + * of the page buffer. The default value is zero, meaning that page + * buffering is disabled. When a non-zero page buffer size is set, the + * library will enable page buffering if that size is larger or equal + * than a single page size if a paged file space strategy is enabled + * using the functions H5Pset_file_space_strategy() and + * H5Pset_file_space_page_size(). + * + * The page buffer layer captures all I/O requests before they are + * issued to the VFD and "caches" them in fixed sized pages. Once the + * total number of pages exceeds the page buffer size, the library + * evicts pages from the page buffer by writing them to the VFD. At + * file close, the page buffer is flushed writing all the pages to the + * file. + * + * If a non-zero page buffer size is set, and the file space strategy + * is not set to paged or the page size for the file space strategy is + * larger than the page buffer size, the subsequent call to H5Fcreate() + * or H5Fopen() using the \p plist_id will fail. + * + * The function also allows setting the minimum percentage of pages for + * metadata and raw data to prevent a certain type of data to evict hot + * data of the other type. + * + * \since 1.10.1 + * + */ +H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, + unsigned min_raw_per); + +/* Dataset creation property list (DCPL) routines */ +/** + * \ingroup DCPL + * + * \brief Determines whether fill value is defined + * + * \dcpl_id{plist} + * \param[out] status Status of fill value in property list + * + * \return \herr_t + * + * \details H5Pfill_value_defined() determines whether a fill value is + * defined in the dataset creation property list \p plist. Valid + * values returned in status are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5D_FILL_VALUE_UNDEFINEDFill value is undefined.
#H5D_FILL_VALUE_DEFAULTFill value is the library default.
#H5D_FILL_VALUE_USER_DEFINEDFill value is defined by the application.
+ * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); +/** + * \ingroup DCPL + * + * \brief Retrieves the timing for storage space allocation + * + * \dcpl_id{plist_id} + * \param[out] alloc_time The timing setting for allocating dataset + * storage space + * + * \return \herr_t + * + * \details H5Pget_alloc_time() retrieves the timing for allocating storage + * space for a dataset's raw data. This property is set in the + * dataset creation property list \p plist_id. The timing setting + * is returned in \p alloc_time as one of the following values: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5D_ALLOC_TIME_DEFAULT
 
Uses the default allocation time, based on the dataset + * storage method.
See the \p alloc_time description in + * H5Pset_alloc_time() for default allocation times for + * various storage methods.
#H5D_ALLOC_TIME_EARLYAll space is allocated when the dataset is created.
#H5D_ALLOC_TIME_INCRSpace is allocated incrementally as data is written + * to the dataset.
#H5D_ALLOC_TIME_LATEAll space is allocated when data is first written to + * the dataset.
+ * + * \note H5Pget_alloc_time() is designed to work in concert with the + * dataset fill value and fill value write time properties, set + * with the functions H5Pget_fill_value() and H5Pget_fill_time(). + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time /*out*/); +/** + * \ingroup DCPL + * + * \brief Retrieves the size of chunks for the raw data of a chunked + * layout dataset + * + * \dcpl_id{plist_id} + * \param[in] max_ndims Size of the \p dims array + * \param[out] dim Array to store the chunk dimensions + * + * \return Returns chunk dimensionality if successful; + * otherwise returns a negative value. + * + * \details H5Pget_chunk() retrieves the size of chunks for the raw data + * of a chunked layout dataset. This function is only valid for + * dataset creation property lists. At most, \p max_ndims elements + * of \p dim will be initialized. + * + * \since 1.0.0 + * + */ +H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[] /*out*/); +/** + * + * \ingroup DCPL + * + * \brief Retrieves the edge chunk option setting from a dataset creation + * property list + * + * \dcpl_id{plist_id} + * \param[out] opts Edge chunk option flag. Valid values are described in + * H5Pset_chunk_opts(). The option status can be + * retrieved using the bitwise AND operator ( & ). For + * example, the expression + * (opts&#H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS) will + * evaluate to #H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS if + * that option has been enabled. Otherwise, it will + * evaluate to 0 (zero). + * + * \return \herr_t + * + * \details H5Pget_chunk_opts() retrieves the edge chunk option setting + * stored in the dataset creation property list \p plist_id. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *opts); +/** + * \ingroup DCPL + * + * \brief Retrieves the setting for whether or not to create minimized + * dataset object headers + * + * \dcpl_id + * \param[out] minimize Flag indicating whether the library will or will + * not create minimized dataset object headers + * + * \return \herr_t + * + * \details H5Pget_dset_no_attrs_hint() retrieves the + * no dataset attributes hint setting for the dataset + * creation property list \p dcpl_id. This setting is used to + * inform the library to create minimized dataset object headers + * when TRUE. The setting value is returned in the boolean pointer + * \p minimize. + * + * \since 1.10.5 + * + */ +H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); +/** + * \ingroup DCPL + * + * \brief Returns information about an external file + * + * \dcpl_id{plist_id} + * \param[in] idx External file index + * \param[in] name_size Maximum length of \p name array + * \param[out] name Name of the external file + * \param[out] offset Pointer to a location to return an offset value + * \param[out] size Pointer to a location to return the size of the + * external file data + * + * \return \herr_t + * + * \details H5Pget_external() returns information about an external file. + * The external file is specified by its index, \p idx, which + * is a number from zero to N-1, where N is the value returned + * by H5Pget_external_count(). At most \p name_size characters + * are copied into the \p name array. If the external file name + * is longer than \p name_size with the null terminator, the + * return value is not null terminated (similar to strncpy()). + * + * If \p name_size is zero or \p name is the null pointer, the + * external file name is not returned. If \p offset or \p size + * are null pointers then the corresponding information is not + * returned. + * + * \version 1.6.4 \p idx parameter type changed to unsigned. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name /*out*/, + off_t *offset /*out*/, hsize_t *size /*out*/); +/** + * \ingroup DCPL + * + * \brief Returns the number of external files for a dataset + * + * \dcpl_id{plist_id} + * + * \return Returns the number of external files if successful; otherwise + * returns a negative value. + * + * \details H5Pget_external_count() returns the number of external files + * for the specified dataset. + * + * \since 1.0.0 + * + */ +H5_DLL int H5Pget_external_count(hid_t plist_id); +/** + * \ingroup DCPL + * + * \brief Retrieves the time when fill values are written to a dataset + * + * \dcpl_id{plist_id} + * \param[out] fill_time Setting for the timing of writing fill values to + * the dataset + * + * \return \herr_t + * + * \details H5Pget_fill_time() examines the dataset creation property list + * \p plist_id to determine when fill values are to be written to + * a dataset. Valid values returned in \p fill_time are as + * follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5D_FILL_TIME_IFSETFill values are written to the dataset when storage + * space is allocated only if there is a user-defined fill + * value, i.e., one set with H5Pset_fill_value(). (Default) + *
#H5D_FILL_TIME_ALLOCFill values are written to the dataset when storage + * space is allocated.
#H5D_FILL_TIME_NEVERFill values are never written to the dataset.
+ * + * \note H5Pget_fill_time() is designed to work in coordination with the + * dataset fill value and dataset storage allocation time properties, + * retrieved with the functions H5Pget_fill_value() and + * H5Pget_alloc_time(). + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time /*out*/); +/** + * \ingroup DCPL + * + * \brief Retrieves a dataset fill value + * + * \dcpl_id{plist_id} + * \param[in] type_id Datatype identifier for the value passed via + * \p value + * \param[out] value Pointer to buffer to contain the returned + * fill value + * + * \return \herr_t + * + * \details H5Pget_fill_value() returns the dataset fill value defined in + * the dataset creation property list \p plist_id. The fill value + * is returned through the \p value pointer and will be converted + * to the datatype specified by \p type_id. This datatype may + * differ from the fill value datatype in the property list, but + * the HDF5 library must be able to convert between the two + * datatypes. + * + * If the fill value is undefined, i.e., set to NULL in the + * property list, H5Pget_fill_value() will return an error. + * H5Pfill_value_defined() should be used to check for this + * condition before H5Pget_fill_value() is called. + * + * Memory must be allocated by the calling application. + * + * \note H5Pget_fill_value() is designed to coordinate with the dataset + * storage allocation time and fill value write time properties, + * which can be retrieved with the functions H5Pget_alloc_time() + * and H5Pget_fill_time(), respectively. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value /*out*/); +/** + * \ingroup DCPL + * + * \brief Returns the layout of the raw data for a dataset + * + * \dcpl_id{plist_id} + * + * \return Returns the layout type (a non-negative value) of a dataset + * creation property list if successful. Valid return values are: + * - #H5D_COMPACT: Raw data is stored in the object header in the + * file. + * - #H5D_CONTIGUOUS: Raw data is stored separately from the object + * header in one contiguous chunk in the file. + * - #H5D_CHUNKED: Raw data is stored separately from the object + * header in chunks in separate locations in the + * file. + * - #H5D_VIRTUAL: Raw data is drawn from multiple datasets in + * different files. + * \return + * Otherwise, returns a negative value indicating failure. + * + * \details H5Pget_layout() returns the layout of the raw data for a + * dataset. This function is only valid for dataset creation + * property lists. + * + * Note that a compact storage layout may affect writing data to + * the dataset with parallel applications. See the H5Dwrite() + * documentation for details. + * + * \version 1.10.0 #H5D_VIRTUAL added in this release. + * + * \since 1.0.0 + * + */ +H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); +/** + * \ingroup DCPL + * + * \brief Gets the number of mappings for the virtual dataset + * + * \dcpl_id + * \param[out] count The number of mappings + * + * \return \herr_t + * + * \details H5Pget_virtual_count() gets the number of mappings for a + * virtual dataset that has the creation property list specified + * by \p dcpl_id. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pget_virtual_count(hid_t dcpl_id, size_t *count /*out*/); +/** + * \ingroup DCPL + * + * \brief Gets the name of a source dataset used in the mapping + * + * \dcpl_id + * \param[in] index Mapping index. The value of \p index is 0 (zero) or + * greater and less than \p count + * (0 ≤ \p index < \p count), where \p count is the + * number of mappings returned by H5Pget_virtual_count(). + * \param[out] name A buffer containing the name of the source dataset + * \param[in] size The size, in bytes, of the name buffer. Must be the + * size of the dataset name in bytes plus 1 for a NULL + * terminator + * + * \return Returns the length of the dataset name if successful; + * otherwise returns a negative value. + * + * \details H5Pget_virtual_dsetname() takes the dataset creation property + * list for the virtual dataset, \p dcpl_id, the mapping index, + * \p index, the size of the dataset name for a source dataset, + * \p size, and retrieves the name of the source dataset used in + * the mapping. + * + * Up to \p size characters of the dataset name are returned in + * \p name; additional characters, if any, are not returned to + * the user application. + * + * If the length of the dataset name, which determines the + * required value of \p size, is unknown, a preliminary call + * to H5Pget_virtual_dsetname() with the last two parameters + * set to NULL and zero respectively can be made. The return + * value of this call will be the size in bytes of the dataset + * name. That value, plus 1 for a NULL terminator, must then be + * assigned to \p size for a second H5Pget_virtual_dsetname() + * call, which will retrieve the actual dataset name. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL ssize_t H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name /*out*/, size_t size); +/** + * \ingroup DCPL + * + * \brief Gets the filename of a source dataset used in the mapping + * + * \dcpl_id + * \param[in] index Mapping index. The value of \p index is 0 (zero) or + * greater and less than \p count + * (0 ≤ \p index < \p count), where \p count is the + * number of mappings returned by H5Pget_virtual_count(). + * \param[out] name A buffer containing the name of the file containing + * the source dataset + * \param[in] size The size, in bytes, of the name buffer. Must be the + * size of the filename in bytes plus 1 for a NULL + * terminator + * + * \return Returns the length of the filename if successful; otherwise + * returns a negative value. + * + * \details H5Pget_virtual_filename() takes the dataset creation property + * list for the virtual dataset, \p dcpl_id, the mapping index, + * \p index, the size of the filename for a source dataset, + * \p size, and retrieves the name of the file for a source dataset + * used in the mapping. + * + * Up to \p size characters of the filename are returned in + * \p name; additional characters, if any, are not returned to + * the user application. + * + * If the length of the filename, which determines the required + * value of \p size, is unknown, a preliminary call to + * H5Pget_virtual_filename() with the last two parameters set + * to NULL and zero respectively can be made. The return value + * of this call will be the size in bytes of the filename. That + * value, plus 1 for a NULL terminator, must then be assigned to + * \p size for a second H5Pget_virtual_filename() call, which + * will retrieve the actual filename. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL ssize_t H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name /*out*/, size_t size); +/** + * \ingroup DCPL + * + * \brief Gets a dataspace identifier for the selection within the source + * dataset used in the mapping + * + * \dcpl_id + * \param[in] index Mapping index. The value of \p index is 0 (zero) or + * greater and less than \p count + * (0 ≤ \p index < \p count), where \p count is the number + * of mappings returned by H5Pget_virtual_count(). + * + * \return \hid_t{valid dataspace identifier} + * + * \details H5Pget_virtual_srcspace() takes the dataset creation property + * list for the virtual dataset, \p dcpl_id, and the mapping + * index, \p index, and returns a dataspace identifier for the + * selection within the source dataset used in the mapping. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL hid_t H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index); +/** + * \ingroup DCPL + * + * \brief Gets a dataspace identifier for the selection within the virtual + * dataset used in the mapping + * + * \dcpl_id + * \param[in] index Mapping index. The value of \p index is 0 (zero) or + * greater and less than \p count + * (0 ≤ \p index < \p count), where \p count is the number + * of mappings returned by H5Pget_virtual_count() + * + * \return \hid_t{valid dataspace identifier} + * + * \details H5Pget_virtual_vspace() takes the dataset creation property + * list for the virtual dataset, \p dcpl_id, and the mapping + * index, \p index, and returns a dataspace identifier for the + * selection within the virtual dataset used in the mapping. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL hid_t H5Pget_virtual_vspace(hid_t dcpl_id, size_t index); +/** + * \ingroup DCPL + * + * \brief Sets the timing for storage space allocation + * + * \dcpl_id{plist_id} + * \param[in] alloc_time When to allocate dataset storage space + * + * \return \herr_t + * + * \details H5Pset_alloc_time() sets up the timing for the allocation of + * storage space for a dataset's raw data. This property is set + * in the dataset creation property list \p plist_id. Timing is + * specified in \p alloc_time with one of the following values: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5D_ALLOC_TIME_DEFAULTAllocate dataset storage space at the default time
+ * (Defaults differ by storage method.)
#H5D_ALLOC_TIME_EARLYAllocate all space when the dataset is created
+ * (Default for compact datasets.)
#H5D_ALLOC_TIME_INCRAllocate space incrementally, as data is written to + * the dataset
(Default for chunked storage datasets.) + * + * \li Chunked datasets: Storage space allocation for each + * chunk is deferred until data is written to the chunk. + * \li Contiguous datasets: Incremental storage space + * allocation for contiguous data is treated as late + * allocation. + * \li Compact datasets: Incremental allocation is not + * allowed with compact datasets; H5Pset_alloc_time() + * will return an error.
#H5D_ALLOC_TIME_LATEAllocate all space when data is first written to the + * dataset
+ * (Default for contiguous datasets.)
+ * + * \note H5Pset_alloc_time() is designed to work in concert with the + * dataset fill value and fill value write time properties, set + * with the functions H5Pset_fill_value() and H5Pset_fill_time(). + * + * \note See H5Dcreate() for further cross-references. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time); +/** + * \ingroup DCPL + * + * \brief Sets the size of the chunks used to store a chunked layout + * dataset + * + * \dcpl_id{plist_id} + * \param[in] ndims The number of dimensions of each chunk + * \param[in] dim An array defining the size, in dataset elements, of + * each chunk + * + * \return \herr_t + * \details H5Pset_chunk() sets the size of the chunks used to store a + * chunked layout dataset. This function is only valid for dataset + * creation property lists. + * + * The \p ndims parameter currently must be the same size as the + * rank of the dataset. + * + * The values of the \p dim array define the size of the chunks + * to store the dataset's raw data. The unit of measure for \p dim + * values is dataset elements. + * + * As a side-effect of this function, the layout of the dataset is + * changed to #H5D_CHUNKED, if it is not already so set. + * + * \note Chunk size cannot exceed the size of a fixed-size dataset. For + * example, a dataset consisting of a 5x4 fixed-size array cannot be + * defined with 10x10 chunks. Chunk maximums: + * - The maximum number of elements in a chunk is 232-1 which + * is equal to 4,294,967,295. If the number of elements in a chunk is + * set via H5Pset_chunk() to a value greater than 232-1, + * then H5Pset_chunk() will fail. + * - The maximum size for any chunk is 4GB. If a chunk that is larger + * than 4GB attempts to be written with H5Dwrite(), then H5Dwrite() + * will fail. + * + * \see H5Pset_layout(), H5Dwrite() + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]); +/** + * \ingroup DCPL + * + * \brief Sets the edge chunk option in a dataset creation property list + * + * \dcpl_id{plist_id} + * \param[in] opts Edge chunk option flag. Valid values are: + * \li #H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS + * When enabled, filters are not applied to partial + * edge chunks. When disabled, partial edge chunks are + * filtered. Enabling this option will improve + * performance when appending to the dataset and, when + * compression filters are used, prevent reallocation + * of these chunks. Datasets created with this option + * enabled will be inaccessible with HDF5 library + * versions before Release 1.10. Default: \e Disabled + * \li 0 (zero) Disables option; partial edge chunks + * will be compressed. + * + * \return \herr_t + * + * \details H5Pset_chunk_opts() sets the edge chunk option in the + * dataset creation property list \p dcpl_id. + * + * The available option is detailed in the parameters section. + * Only chunks that are not completely filled by the dataset’s + * dataspace are affected by this option. Such chunks are + * referred to as partial edge chunks. + * + * \b Motivation: H5Pset_chunk_opts() is used to specify storage + * options for chunks on the edge of a dataset’s dataspace. This + * capability allows the user to tune performance in cases where + * the dataset size may not be a multiple of the chunk size and + * the handling of partial edge chunks can impact performance. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned opts); +/** + * \ingroup DCPL + * + * \brief Sets the flag to create minimized dataset object headers + * + * \dcpl_id + * \param[in] minimize Flag for indicating whether or not a dataset's + * object header will be minimized + * + * \return \herr_t + * + * \details H5Pset_dset_no_attrs_hint() sets the no dataset attributes + * hint setting for the dataset creation property list \p dcpl_id. + * Datasets created with the dataset creation property list + * \p dcpl_id will have their object headers minimized if the + * boolean flag \p minimize is set to TRUE. By setting \p minimize + * to TRUE, the library expects that no attributes will be added + * to the dataset. Attributes can be added, but they are appended + * with a continuation message, which can reduce performance. + * + * This setting interacts with H5Fset_dset_no_attrs_hint(): if + * either is set to TRUE, then the created dataset's object header + * will be minimized. + * + * \since 1.10.5 + * + */ +H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); +/** + * \ingroup DCPL + * + * \brief Adds an external file to the list of external files + * + * \dcpl_id{plist_id} + * \param[in] name Name of an external file + * \param[in] offset Offset, in bytes, from the beginning of the file to + * the location in the file where the data starts + * \param[in] size Number of bytes reserved in the file for the data + * + * \return \herr_t + * + * \details The first call to H5Pset_external() sets the external + * storage property in the property list, thus designating that + * the dataset will be stored in one or more non-HDF5 file(s) + * external to the HDF5 file. This call also adds the file + * \p name as the first file in the list of external files. + * Subsequent calls to the function add the named file as the + * next file in the list. + * + * If a dataset is split across multiple files, then the files + * should be defined in order. The total size of the dataset is + * the sum of the \p size arguments for all the external files. + * If the total size is larger than the size of a dataset then + * the dataset can be extended (provided the data space also + * allows the extending). + * + * The \p size argument specifies the number of bytes reserved + * for data in the external file. If \p size is set to + * #H5F_UNLIMITED, the external file can be of unlimited size + * and no more files can be added to the external files list. + * If \p size is set to 0 (zero), no external file will actually + * be created. + * + * All of the external files for a given dataset must be specified + * with H5Pset_external() before H5Dcreate() is called to create + * the dataset. If one these files does not exist on the system + * when H5Dwrite() is called to write data to it, the library + * will create the file. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size); +/** + * \ingroup DCPL + * + * \brief Sets the time when fill values are written to a dataset + * + * \dcpl_id{plist_id} + * \param[in] fill_time When to write fill values to a dataset + * + * \return \herr_t + * + * \details H5Pset_fill_time() sets up the timing for writing fill values + * to a dataset. This property is set in the dataset creation + * property list \p plist_id. Timing is specified in \p fill_time + * with one of the following values: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5D_FILL_TIME_IFSETWrite fill values to the dataset when storage space is + * allocated only if there is a user-defined fill value, + * i.e.,one set with H5Pset_fill_value(). (Default)
#H5D_FILL_TIME_ALLOCWrite fill values to the dataset when storage space is + * allocated.
#H5D_FILL_TIME_NEVERNever write fill values to the dataset.
+ * + * \note H5Pset_fill_time() is designed for coordination with the dataset + * fill value and dataset storage allocation time properties, set + * with the functions H5Pset_fill_value() and H5Pset_alloc_time(). + * See H5Dcreate() for further cross-references. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); +/** + * \ingroup DCPL + * + * \brief Sets the fill value for a dataset + * + * \dcpl_id{plist_id} + * \param[in] type_id Datatype of \p value + * \param[in] value Pointer to buffer containing value to use as + * fill value + * + * \return \herr_t + * + * \details H5Pset_fill_value() sets the fill value for a dataset in the + * dataset creation property list. \p value is interpreted as + * being of datatype \p type_id. This datatype may differ from + * that of the dataset, but the HDF5 library must be able to + * convert \p value to the dataset datatype when the dataset is + * created. + * + * The default fill value is 0 (zero), which is interpreted + * according to the actual dataset datatype. + * + * Setting \p value to NULL indicates that the fill value is to + * be undefined. + * + * \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. This function allows the user application + * to set that fill value; the functions H5Dfill() and + * H5Pset_fill_time(), respectively, provide the ability to apply the + * fill value on demand or to set up its automatic application. + * + * \note A fill value should be defined so that it is appropriate for the + * application. While the HDF5 default fill value is 0 (zero), it is + * often appropriate to use another value. It might be useful, for + * example, to use a value that is known to be impossible for the + * application to legitimately generate. + * + * \note H5Pset_fill_value() is designed to work in concert with + * H5Pset_alloc_time() and H5Pset_fill_time(). H5Pset_alloc_time() + * and H5Pset_fill_time() govern the timing of dataset storage + * allocation and fill value write operations and can be important in + * tuning application performance. + * + * \note See H5Dcreate() for further cross-references. + * + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value); +/** + * \ingroup DCPL + * + * \brief Sets up use of the shuffle filter + * + * \dcpl_id{plist_id} + * + * \return \herr_t + * + * \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. + * All the bytes from one consistent byte position of each data + * element are placed together in one block; all bytes from a + * second consistent byte position of each data element are placed + * together a second block; etc. For example, given three data + * elements of a 4-byte datatype stored as 012301230123, shuffling + * will re-order data as 000111222333. This can be a valuable step + * in an effective compression algorithm because the bytes in each + * byte position are often closely related to each other and + * putting them together can increase the compression ratio. + * + * As implied above, the primary value of the shuffle filter lies + * in its coordinated use with a compression filter; it does not + * provide data compression when used alone. When the shuffle + * filter is applied to a dataset immediately prior to the use of + * a compression filter, the compression ratio achieved is often + * superior to that achieved by the use of a compression filter + * without the shuffle filter. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); +/** + * \ingroup DCPL + * + * \brief Sets the type of storage used to store the raw data for a dataset + * + * \dcpl_id{plist_id} + * \param[in] layout Type of storage layout for raw data + * + * \return \herr_t + * \details H5Pset_layout() sets the type of storage used to store the raw + * data for a dataset. This function is only valid for dataset + * creation property lists. + * + * Valid values for \p layout are: + * - #H5D_COMPACT: Store raw data in the dataset object header + * in file. This should only be used for datasets + * with small amounts of raw data. The raw data + * size limit is 64K (65520 bytes). Attempting + * to create a dataset with raw data larger than + * this limit will cause the H5Dcreate() call to + * fail. + * - #H5D_CONTIGUOUS: Store raw data separately from the object + * header in one large chunk in the file. + * - #H5D_CHUNKED: Store raw data separately from the object header + * as chunks of data in separate locations in + * the file. + * - #H5D_VIRTUAL: Draw raw data from multiple datasets in + * different files. + * + * Note that a compact storage layout may affect writing data to + * the dataset with parallel applications. See the note in + * H5Dwrite() documentation for details. + * \version 1.10.0 #H5D_VIRTUAL added in this release. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); +/** + * \ingroup DCPL + * + * \brief Sets up the use of the N-Bit filter + * + * \dcpl_id{plist_id} + * + * \return \herr_t + * + * \details H5Pset_nbit() sets the N-Bit filter, #H5Z_FILTER_NBIT, in the + * dataset creation property list \p plist_id. + * + * The HDF5 user can create an N-Bit datatype with the following + * code: + *
+ *          hid_t nbit_datatype = H5Tcopy(H5T_STD_I32LE);
+ *          H5Tset_precision(nbit_datatype, 16);
+ *          H5Tset_offset(nbit_datatype, 4);
+ *          
+ * + * In memory, one value of the N-Bit datatype in the above example + * will be stored on a little-endian machine as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
byte 3byte 2byte 1byte 0
????????????SPPPPPPPPPPPPPPP????
+ * Note: S - sign bit, P - significant bit, ? - padding bit; For + * signed integer, the sign bit is included in the precision. + * + * When data of the above datatype is stored on disk using the + * N-bit filter, all padding bits are chopped off and only + * significant bits are stored. The values on disk will be + * something like: + * + * + * + * + * + * + * + * + * + * + * + * + *
1st value2nd value...
SPPPPPPPPPPPPPPPSPPPPPPPPPPPPPPP...
+ * The N-Bit filter is used effectively for compressing data of + * an N-Bit datatype as well as a compound and an array + * datatype with N-Bit fields. However, the datatype classes of + * the N-Bit datatype or the N-Bit field of the compound + * datatype or the array datatype are limited to integer or + * floating-point. + * + * The N-Bit filter supports complex situations where a compound + * datatype contains member(s) of a compound datatype or an array + * datatype that has a compound datatype as the base type. + * However, it does not support the situation where an array + * datatype has a variable-length or variable-length string as + * its base datatype. The filter does support the situation where + * a variable-length or variable-length string is a member of a + * compound datatype. + * + * The N-Bit filter allows all other HDF5 datatypes (such as + * time, string, bitfield, opaque, reference, enum, and variable + * length) to pass through as a no-op. + * + * Like other I/O filters supported by the HDF5 library, + * application using the N-Bit filter must store data with + * chunked storage. + * + * By nature, the N-Bit filter should not be used together with + * other I/O filters. + * + * \version 1.8.8 Fortran subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_nbit(hid_t plist_id); +/** + * \ingroup DCPL + * + * \brief Sets up the use of the scale-offset filter + * + * \dcpl_id{plist_id} + * \param[in] scale_type Flag indicating compression method + * \param[in] scale_factor Parameter related to scale. Must be + * non-negative + * + * \return \herr_t + * + * \details H5Pset_scaleoffset() sets the scale-offset filter, + * #H5Z_FILTER_SCALEOFFSET, for a dataset. + * + * 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 (MinBits) before storing it. The + * current scale-offset filter supports integer and floating-point + * datatypes. + * + * For an integer datatype, the parameter \p scale_type should be set + * to #H5Z_SO_INT (2). The parameter \p scale_factor denotes MinBits. + * If the user sets it to H5Z_SO_INT_MINBITS_DEFAULT (0), the filter + * will calculate MinBits. If \p scale_factor is set to a positive + * integer, the filter does not do any calculation and just uses the + * number as MinBits. However, if the user gives a MinBits that is less + * than what would be generated by the filter, the compression will be + * lossy. Also, the MinBits supplied by the user cannot exceed the + * number of bits to store one value of the dataset datatype. + * + * For a floating-point datatype, the filter adopts the GRiB data + * packing mechanism, which offers two alternate methods: E-scaling and + * D-scaling. Both methods are lossy compression. If the parameter + * \p scale_type is set to #H5Z_SO_FLOAT_DSCALE (0), the filter will + * use the D-scaling method; if it is set to #H5Z_SO_FLOAT_ESCALE (1), + * the filter will use the E-scaling method. Since only the D-scaling + * method is implemented, \p scale_type should be set to + * #H5Z_SO_FLOAT_DSCALE or 0. + * + * When the D-scaling method is used, the original data is "D" scaled + * — multiplied by 10 to the power of \p scale_factor, and the + * "significant" part of the value is moved to the left of the decimal + * point. Care should be taken in setting the decimal \p scale_factor + * so that the integer part will have enough precision to contain the + * appropriate information of the data value. For example, if + * \p scale_factor is set to 2, the number 104.561 will be 10456.1 + * after "D" scaling. The last digit 1 is not "significant" and is + * thrown off in the process of rounding. The user should make sure that + * after "D" scaling and rounding, the data values are within the range + * that can be represented by the integer (same size as the + * floating-point type). + * + * Valid values for scale_type are as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5Z_SO_FLOAT_DSCALE (0)Floating-point type, using variable MinBits method
#H5Z_SO_FLOAT_ESCALE (1)Floating-point type, using fixed MinBits method
#H5Z_SO_INT (2)Integer type
+ * + * The meaning of \p scale_factor varies according to the value + * assigned to \p scale_type: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
\p scale_type value\p scale_factor description
#H5Z_SO_FLOAT_DSCALEDenotes the decimal scale factor for D-scaling and can be + * positive, negative or zero. This is the current + * implementation of the library.
#H5Z_SO_FLOAT_ESCALEDenotes MinBits for E-scaling and must be a positive integer. + * This is not currently implemented by the library.
#H5Z_SO_INTDenotes MinBits and it should be a positive integer or + * #H5Z_SO_INT_MINBITS_DEFAULT (0). If it is less than 0, the + * library will reset it to 0 since it is not implemented. + *
+ * Like other I/O filters supported by the HDF5 library, an + * application using the scale-offset filter must store data with + * chunked storage. + * + * \version 1.8.8 Fortran90 subroutine introduced in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor); +/** + * \ingroup DCPL + * + * \brief Sets up use of the SZIP compression filter + * + * \dcpl_id{plist_id} + * \param[in] options_mask A bit-mask conveying the desired SZIP options; + * Valid values are #H5_SZIP_EC_OPTION_MASK and + * #H5_SZIP_NN_OPTION_MASK. + * \param[in] pixels_per_block The number of pixels or data elements in each + * data block + * + * \return \herr_t + * + * \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. + * + * Before proceeding, all users should review the “Limitations” + * section below. + * + * Users familiar with SZIP outside the HDF5 context may benefit + * from reviewing the Note “For Users Familiar with SZIP in Other + * Contexts” below. + * + * In the text below, the term pixel refers to an HDF5 data element. + * This terminology derives from SZIP compression's use with image + * data, where pixel referred to an image pixel. + * + * The SZIP \p bits_per_pixel value (see Note, below) is automatically + * set, based on the HDF5 datatype. SZIP can be used with atomic + * datatypes that may have size of 8, 16, 32, or 64 bits. + * Specifically, a dataset with a datatype that is 8-, 16-, 32-, or + * 64-bit signed or unsigned integer; char; or 32- or 64-bit float + * can be compressed with SZIP. See Note, below, for further + * discussion of the the SZIP \p bits_per_pixel setting. + * + * SZIP options are passed in an options mask, \p options_mask, + * as follows. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
OptionDescription (Mutually exclusive; select one.)
#H5_SZIP_EC_OPTION_MASKSelects entropy coding method
#H5_SZIP_NN_OPTION_MASKSelects nearest neighbor coding method
+ * + * The following guidelines can be used in determining which + * option to select: + * + * - The entropy coding method, the EC option specified by + * #H5_SZIP_EC_OPTION_MASK, is best suited for data that has been + * processed. The EC method works best for small numbers. + * - The nearest neighbor coding method, the NN option specified + * by #H5_SZIP_NN_OPTION_MASK, preprocesses the data then the + * applies EC method as above. + * + * Other factors may affect results, but the above criteria + * provides a good starting point for optimizing data compression. + * + * SZIP compresses data block by block, with a user-tunable block + * size. This block size is passed in the parameter + * \p pixels_per_block and must be even and not greater than 32, + * with typical values being 8, 10, 16, or 32. This parameter + * affects compression ratio; the more pixel values vary, the + * smaller this number should be to achieve better performance. + * + * In HDF5, compression can be applied only to chunked datasets. + * If \p pixels_per_block is bigger than the total number of + * elements in a dataset chunk, H5Pset_szip() will succeed but + * the subsequent call to H5Dcreate() will fail; the conflict + * can be detected only when the property list is used. + * + * To achieve optimal performance for SZIP compression, it is + * recommended that a chunk's fastest-changing dimension be equal + * to N times \p pixels_per_block where N is the maximum number of + * blocks per scan line allowed by the SZIP library. In the + * current version of SZIP, N is set to 128. + * + * SZIP compression is an optional HDF5 filter. + * + * \b Limitations: + * + * - SZIP compression cannot be applied to compound, array, + * variable-length, enumeration, or any other user-defined + * datatypes. If an SZIP filter is set in a dataset creation + * property list used to create a dataset containing a + * non-allowed datatype, the call to H5Dcreate() will fail; the + * conflict can be detected only when the property list is used. + * - Users should be aware that there are factors that affect one’s + * rights and ability to use SZIP compression by reviewing the + * SZIP copyright notice. + * + * \note \b For \b Users \b Familiar \b with \b SZIP \b in \b Other \b Contexts: + * + * \note The following notes are of interest primarily to those who have + * used SZIP compression outside of the HDF5 context. + * In non-HDF5 applications, SZIP typically requires that the user + * application supply additional parameters: + * - \p pixels_in_object, the number of pixels in the object to + * be compressed + * - \p bits_per_pixel, the number of bits per pixel + * - \p pixels_per_scanline, the number of pixels per scan line + * + * \note These values need not be independently supplied in the HDF5 + * environment as they are derived from the datatype and dataspace, + * which are already known. In particular, HDF5 sets + * \p pixels_in_object to the number of elements in a chunk and + * \p bits_per_pixel to the size of the element or pixel datatype. + * + * \note The following algorithm is used to set \p pixels_per_scanline: + * - If the size of a chunk's fastest-changing dimension, size, + * is greater than 4K, set \p pixels_per_scanline to 128 times + * \p pixels_per_block. + * - If size is less than 4K but greater than \p pixels_per_block, + * set \p pixels_per_scanline to the minimum of size and 128 + * times \p pixels_per_block. + * - If size is less than \p pixels_per_block but greater than the + * number elements in the chunk, set \p pixels_per_scanline to + * the minimum of the number elements in the chunk and 128 times + * \p pixels_per_block. + * + * \note The HDF5 datatype may have precision that is less than the full + * size of the data element, e.g., an 11-bit integer can be defined + * using H5Tset_precision(). To a certain extent, SZIP can take + * advantage of the precision of the datatype to improve compression: + * - If the HDF5 datatype size is 24-bit or less and the offset of + * the bits in the HDF5 datatype is zero (see H5Tset_offset() or + * H5Tget_offset()), the data is the in lowest N bits of the data + * element. In this case, the SZIP \p bits_per_pixel is set to the + * precision of the HDF5 datatype. + * - If the offset is not zero, the SZIP \p bits_per_pixel will be + * set to the number of bits in the full size of the data element. + * - If the HDF5 datatype precision is 25-bit to 32-bit, the SZIP + * \p bits_per_pixel will be set to 32. + * - If the HDF5 datatype precision is 33-bit to 64-bit, the SZIP + * \p bits_per_pixel will be set to 64. + * + * \note HDF5 always modifies the options mask provided by the user to set up + * usage of RAW_OPTION_MASK, ALLOW_K13_OPTION_MASK, and one of + * LSB_OPTION_MASK or MSB_OPTION_MASK, depending on endianness of the + * datatype. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); + +/** + * \ingroup DCPL + * + * \brief Sets the mapping between virtual and source datasets + * + * \dcpl_id + * \param[in] vspace_id The dataspace identifier with the selection within the + * virtual dataset applied, possibly an unlimited selection + * \param[in] src_file_name The name of the HDF5 file where the source dataset is + * located or a \Code{"."} (period) for a source dataset in the same + * file. The file might not exist yet. The name can be specified using + * a C-style \c printf statement as described below. + * \param[in] src_dset_name The path to the HDF5 dataset in the file specified by + * \p src_file_name. The dataset might not exist yet. The dataset name + * can be specified using a C-style \c printf statement as described below. + * \param[in] src_space_id The source dataset’s dataspace identifier with a + * selection applied, possibly an unlimited selection + * \return \herr_t + * + * \details H5Pset_virtual() maps elements of the virtual dataset (VDS) + * described by the virtual dataspace identifier \p vspace_id to the + * elements of the source dataset described by the source dataset + * dataspace identifier \p src_space_id. The source dataset is + * identified by the name of the file where it is located, + * \p src_file_name, and the name of the dataset, \p src_dset_name. + * + * \par C-style \c printf Formatting Statements: + * C-style \c printf formatting allows a pattern to be specified in the name + * of a source file or dataset. Strings for the file and dataset names are + * treated as literals except for the following substitutions: + * + * + * + * + * + * + * + * + * + *
\Code{"%%"}Replaced with a single \Code{"%"} (percent) character.
"%b"Where "" is the virtual dataset dimension axis (0-based) + * and \Code{"b"} indicates that the block count of the selection in that + * dimension should be used. The full expression (for example, \Code{"%0b"}) + * is replaced with a single numeric value when the mapping is evaluated at + * VDS access time. Example code for many source and virtual dataset mappings + * is available in the "Examples of Source to Virtual Dataset Mapping" + * chapter in the + * + * RFC: HDF5 Virtual Dataset. + *
+ * If the printf form is used for the source file or dataset names, the + * selection in the source dataset’s dataspace must be fixed-size. + * + * \par Source File Resolutions: + * When a source dataset residing in a different file is accessed, the + * library will search for the source file \p src_file_name as described + * below: + * \li If \p src_file_name is a \Code{"."} (period) then it refers to the + * file containing the virtual dataset. + * \li If \p src_file_name is a relative pathname, the following steps are + * performed: + * - The library will get the prefix(es) set in the environment + * variable \c HDF5_VDS_PREFIX and will try to prepend each prefix + * to \p src_file_name to form a new \p src_file_name. If the new + * \p src_file_name does not exist or if \c HDF5_VDS_PREFIX is not + * set, the library will get the prefix set via H5Pset_virtual_prefix() + * and prepend it to \p src_file_name to form a new \p src_file_name. + * If the new \p src_file_name does not exist or no prefix is being + * set by H5Pset_virtual_prefix() then the path of the file containing + * the virtual dataset is obtained. This path can be the absolute path + * or the current working directory plus the relative path of that + * file when it is created/opened. The library will prepend this path + * to \p src_file_name to form a new \p src_file_name. + * - If the new \p src_file_name does not exist, then the library will + * look for \p src_file_name and will return failure/success accordingly. + * \li If \p src_file_name is an absolute pathname, the library will first + * try to find \p src_file_name. If \p src_file_name does not exist, + * \p src_file_name is stripped of directory paths to form a new + * \p src_file_name. The search for the new \p src_file_name then follows + * the same steps as described above for a relative pathname. See + * examples below illustrating how \p src_file_name is stripped to form + * a new \p src_file_name. + * \par + * Note that \p src_file_name is considered to be an absolute pathname when + * the following condition is true: + * \li For Unix, the first character of \p src_file_name is a slash + * (\Code{/}).\n For example, consider a \p src_file_name of + * \Code{/tmp/A.h5}. If that source file does not exist, the new + * \p src_file_name after stripping will be \Code{A.h5}. + * \li For Windows, there are 6 cases: + * 1. \p src_file_name is an absolute drive with absolute pathname.\n + * For example, consider a \p src_file_name of \Code{/tmp/A.h5}. + * If that source file does not exist, the new \p src_file_name + * after stripping will be \Code{A.h5}. + * 2. \p src_file_name is an absolute pathname without specifying + * drive name.\n For example, consider a \p src_file_name of + * \Code{/tmp/A.h5}. If that source file does not exist, the new + * \p src_file_name after stripping will be \Code{A.h5}. + * 3. \p src_file_name is an absolute drive with relative pathname.\n + * For example, consider a \p src_file_name of \Code{/tmp/A.h5}. + * If that source file does not exist, the new \p src_file_name + * after stripping will be \Code{tmp/A.h5}. + * 4. \p src_file_name is in UNC (Uniform Naming Convention) format + * with server name, share name, and pathname.\n + * For example, consider a \p src_file_name of \Code{/tmp/A.h5}. + * If that source file does not exist, the new \p src_file_name + * after stripping will be \Code{A.h5}. + * 5. \p src_file_name is in Long UNC (Uniform Naming Convention) + * format with server name, share name, and pathname.\n + * For example, consider a \p src_file_name of \Code{/tmp/A.h5}. + * If that source file does not exist, the new \p src_file_name + * after stripping will be \Code{A.h5}. + * 6. \p src_file_name is in Long UNC (Uniform Naming Convention) + * format with an absolute drive and an absolute pathname.\n + * For example, consider a \p src_file_name of \Code{/tmp/A.h5}. + * If that source file does not exist, the new \p src_file_name + * after stripping will be \Code{A.h5} + * + * \see + * Virtual Dataset Overview + * + * \see_virtual + * + * \version 1.10.2 A change was made to the method of searching for VDS source files. + * \since 1.10.0 + * + */ +H5_DLL 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); + +/* Dataset access property list (DAPL) routines */ +/** + * \ingroup DAPL + * + * \brief Retrieves the values of the append property that is set up in + * the dataset access property list + * + * \dapl_id + * \param[in] dims The number of elements for \p boundary + * \param[in] boundary The dimension sizes used to determine the boundary + * \param[in] func The user-defined callback function + * \param[in] udata The user-defined input data + * + * \return \herr_t + * + * \details H5Pget_append_flush() obtains the following information + * from the dataset access property list, \p dapl_id. + * + * \p boundary consists of the sizes set up in the access + * property list that are used to determine when a dataset + * dimension size hits the boundary. Only at most \p dims + * boundary sizes are retrieved, and \p dims will not exceed + * the corresponding value that is set in the property list. + * + * \p func is the user-defined callback function to invoke when + * a dataset’s appended dimension size reaches a boundary and + * \p udata is the user-defined input data for the callback + * function. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pget_append_flush(hid_t dapl_id, unsigned dims, hsize_t boundary[], H5D_append_cb_t *func, + void **udata); +/** + * \ingroup DAPL + * + * \brief Retrieves the raw data chunk cache parameters + * + * \dapl_id + * \param[out] rdcc_nslots Number of chunk slots in the raw data chunk + * cache hash table + * \param[out] rdcc_nbytes Total size of the raw data chunk cache, in + * bytes + * \param[out] rdcc_w0 Preemption policy + * + * \return \herr_t + * + * \details H5Pget_chunk_cache() retrieves the number of chunk slots in + * the raw data chunk cache hash table, the maximum possible + * number of bytes in the raw data chunk cache, and the + * preemption policy value. + * + * These values are retrieved from a dataset access property + * list. If the values have not been set on the property list, + * then values returned will be the corresponding values from + * a default file access property list. + * + * Any (or all) pointer arguments may be null pointers, in which + * case the corresponding data is not returned. + * + * \since 1.8.3 + * + */ +H5_DLL herr_t H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots /*out*/, size_t *rdcc_nbytes /*out*/, + double *rdcc_w0 /*out*/); +/** + * \ingroup DAPL + * + * \brief Retrieves the prefix for external raw data storage files as set + * in the dataset access property list + * + * \dapl_id + * \param[in,out] prefix Dataset external storage prefix in UTF-8 or + * ASCII (\em Path and \em filename must be ASCII + * on Windows systems.) + * \param[in] size Size of prefix buffer in bytes + * + * \return Returns the size of \p prefix and the prefix string will be + * stored in \p prefix if successful. + * Otherwise returns a negative value and the contents of \p prefix + * will be undefined. + * + * \details H5Pget_efile_prefix() retrieves the file system path prefix + * for locating external files associated with a dataset that + * uses external storage. This will be the value set with + * H5Pset_efile_prefix() or the HDF5 library’s default. + * + * The value of \p size is the size in bytes of the prefix, + * including the NULL terminator. If the size is unknown, a + * preliminary H5Pget_elink_prefix() call with the pointer + * \p prefix set to NULL will return the size of the prefix + * without the NULL terminator. + * + * The \p prefix buffer must be allocated by the caller. In a + * call that retrieves the actual prefix, that buffer must be + * of the size specified in \p size. + * + * \note See H5Pset_efile_prefix() for a more complete description of + * file location behavior and for notes on the use of the + * HDF5_EXTFILE_PREFIX environment variable. + * + * \since 1.10.0, 1.8.17 + * + */ +H5_DLL ssize_t H5Pget_efile_prefix(hid_t dapl_id, char *prefix /*out*/, size_t size); +/** + * \ingroup DAPL + * + * \brief Retrieves prefix applied to VDS source file paths + * + * \dapl_id + * \param[out] prefix Prefix applied to VDS source file paths + * \param[in] size Size of prefix, including null terminator + * + * \return If successful, returns a non-negative value specifying the size + * in bytes of the prefix without the NULL terminator; otherwise + * returns a negative value. + * + * \details H5Pget_virtual_prefix() retrieves the prefix applied to the + * path of any VDS source files traversed. + * + * When an VDS source file is traversed, the prefix is retrieved + * from the dataset access property list \p dapl_id, returned + * in the user-allocated buffer pointed to by \p prefix, and + * prepended to the filename stored in the VDS virtual file, set + * with H5Pset_virtual(). + * + * The size in bytes of the prefix, including the NULL terminator, + * is specified in \p size. If \p size is unknown, a preliminary + * H5Pget_virtual_prefix() call with the pointer \p prefix set to + * NULL will return the size of the prefix without the NULL + * terminator. + * + * \see_virtual + * + * \since 1.10.2 + * + */ +H5_DLL ssize_t H5Pget_virtual_prefix(hid_t dapl_id, char *prefix /*out*/, size_t size); +/** + * \ingroup DAPL + * + * \brief Returns the maximum number of missing source files and/or datasets + * with the printf-style names when getting the extent for an unlimited + * virtual dataset + * + * \dapl_id + * \param[out] gap_size Maximum number of the files and/or datasets + * allowed to be missing for determining the extent + * of an unlimited virtual dataset with printf-style + * mappings. (\em Default: 0) + * + * \return \herr_t + * + * \details H5Pget_virtual_printf_gap() returns the maximum number of + * missing printf-style files and/or datasets for determining the + * extent of an unlimited virtual dataaset, \p gap_size, using + * the access property list for the virtual dataset, \p dapl_id. + * + * The default library value for \p gap_size is 0 (zero). + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pget_virtual_printf_gap(hid_t dapl_id, hsize_t *gap_size); +/** + * \ingroup DAPL + * + * \brief Retrieves the view of a virtual dataset accessed with + * \p dapl_id + * + * \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 + * + * \details H5Pget_virtual_view() takes the virtual dataset access property + * list, \p dapl_id, and retrieves the flag, \p view, set by the + * H5Pset_virtual_view() call. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pget_virtual_view(hid_t dapl_id, H5D_vds_view_t *view); +/** + * \ingroup DAPL + * + * \brief Sets two actions to perform when the size of a dataset’s + * dimension being appended reaches a specified boundary + * + * \dapl_id + * \param[in] ndims The number of elements for boundary + * \param[in] boundary The dimension sizes used to determine the boundary + * \param[in] func The user-defined callback function + * \param[in] udata The user-defined input data + * + * \return \herr_t + * + * \details H5Pset_append_flush() sets the following two actions to + * perform for a dataset associated with the dataset access + * property list \p dapl_id: + * + * \li Call the callback function \p func set in the property + * list + * \li Flush the dataset associated with the dataset access + * property list + * + * When a user is appending data to a dataset via H5DOappend() + * and the dataset’s newly extended dimension size hits a + * specified boundary, the library will perform the first action + * listed above. Upon return from the callback function, the + * library will then perform the second action listed above and + * return to the user. If no boundary is hit or set, the two + * actions above are not invoked. + * + * The specified boundary is indicated by the parameter + * \p boundary. It is a 1-dimensional array with \p ndims + * elements, which should be the same as the rank of the + * dataset’s dataspace. While appending to a dataset along a + * particular dimension index via H5Dappend(), the library + * determines a boundary is reached when the resulting dimension + * size is divisible by \p boundary[index]. A zero value for + * \p boundary[index] indicates no boundary is set for that + * dimension index. + * + * The setting of this property will apply only for a chunked + * dataset with an extendible dataspace. A dataspace is extendible + * when it is defined with either one of the following: + * + * \li A dataspace with fixed current and maximum dimension sizes + * \li A dataspace with at least one unlimited dimension for its + * maximum dimension size + * + * When creating or opening a chunked dataset, the library will + * check whether the boundary as specified in the access property + * list is set up properly. The library will fail the dataset + * create or open if the following conditions are true: + * + * \li \p ndims, the number of elements for boundary, is not the + * same as the rank of the dataset’s dataspace. + * \li A non-zero boundary value is specified for a non-extendible + * dimension. + * + * The callback function \p func must conform to the following + * prototype: + * \snippet H5Dpublic.h H5D_append_cb_t_snip + * + * The parameters of the callback function, per the above + * prototype, are defined as follows: + * + * \li \p dataset_id is the dataset identifier. + * \li \p cur_dims is the dataset’s current dimension sizes when + * a boundary is hit. + * \li \p user_data is the user-defined input data. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pset_append_flush(hid_t dapl_id, unsigned ndims, const hsize_t boundary[], + H5D_append_cb_t func, void *udata); +/** + * \ingroup DAPL + * + * \brief Sets the raw data chunk cache parameters + * + * \dapl_id + * \param[in] rdcc_nslots The number of chunk slots in the raw data chunk + * cache for this dataset. Increasing this value + * reduces the number of cache collisions, but + * slightly increases the memory used. Due to the + * hashing strategy, this value should ideally be a + * prime number. As a rule of thumb, this value + * should be at least 10 times the number of chunks + * that can fit in \p rdcc_nbytes bytes. For maximum + * performance, this value should be set + * approximately 100 times that number of chunks. + * The default value is 521. If the value passed is + * #H5D_CHUNK_CACHE_NSLOTS_DEFAULT, then the + * property will not be set on \p dapl_id and the + * parameter will come from the file access + * property list used to open the file. + * \param[in] rdcc_nbytes The total size of the raw data chunk cache for + * this dataset. In most cases increasing this + * number will improve performance, as long as + * you have enough free memory. + * The default size is 1 MB. If the value passed is + * #H5D_CHUNK_CACHE_NBYTES_DEFAULT, then the + * property will not be set on \p dapl_id and the + * parameter will come from the file access + * property list. + * \param[in] rdcc_w0 The chunk preemption policy for this dataset. + * This must be between 0 and 1 inclusive and + * indicates the weighting according to which chunks + * which have been fully read or written are + * penalized when determining which chunks to flush + * from cache. A value of 0 means fully read or + * written chunks are treated no differently than + * other chunks (the preemption is strictly LRU) + * while a value of 1 means fully read or written + * chunks are always preempted before other chunks. + * If your application only reads or writes data + * once, this can be safely set to 1. Otherwise, + * this should be set lower, depending on how often + * you re-read or re-write the same data. + * The default value is 0.75. If the value passed is + * #H5D_CHUNK_CACHE_W0_DEFAULT, then the property + * will not be set on \p dapl_id and the parameter + * will come from the file access property list. + * + * \return \herr_t + * + * \details H5Pset_chunk_cache() sets the number of elements, the total + * number of bytes, and the preemption policy value in the raw + * data chunk cache on a dataset access property list. After + * calling this function, the values set in the property list + * will override the values in the file's file access property + * list. + * + * The raw data chunk cache inserts chunks into the cache + * by first computing a hash value using the address of a chunk, + * then using that hash value as the chunk's index into the table + * of cached chunks. The size of this hash table, i.e., and the + * number of possible hash values, is determined by the + * \p rdcc_nslots parameter. If a different chunk in the cache + * has the same hash value, this causes a collision, which + * reduces efficiency. If inserting the chunk into cache would + * cause the cache to be too big, then the cache is pruned + * according to the \p rdcc_w0 parameter. + * + * \b Motivation: H5Pset_chunk_cache() is used to adjust the chunk + * cache parameters on a per-dataset basis, as opposed to a global + * setting for the file using H5Pset_cache(). The optimum chunk + * cache parameters may vary widely with different data layout and + * access patterns, so for optimal performance they must be set + * individually for each dataset. It may also be beneficial to + * reduce the size of the chunk cache for datasets whose + * performance is not important in order to save memory space. + * + * \b Example \b Usage: The following code sets the chunk cache to + * use a hash table with 12421 elements and a maximum size of + * 16 MB, while using the preemption policy specified for the + * entire file: + * \Code{ + * H5Pset_chunk_cache(dapl_id, 12421, 16*1024*1024, + * H5D_CHUNK_CACHE_W0_DEFAULT);} + * + * \b Usage \b Notes: The chunk cache size is a property for + * accessing a dataset and is not stored with a dataset or a + * file. To guarantee the same chunk cache settings each time + * the dataset is opened, call H5Dopen() with a dataset access + * property list where the chunk cache size is set by calling + * H5Pset_chunk_cache() for that property list. The property + * list can be used for multiple accesses in the same + * application. + * + * For files where the same chunk cache size will be + * appropriate for all or most datasets, H5Pset_cache() can + * be called with a file access property list to set the + * chunk cache size for accessing all datasets in the file. + * + * Both methods can be used in combination, in which case + * the chunk cache size set by H5Pset_cache() will apply + * except for specific datasets where H5Dopen() is called + * with dataset property list with the chunk cache size + * set by H5Pset_chunk_cache(). + * + * In the absence of any cache settings, H5Dopen() will + * by default create a 1 MB chunk cache for the opened + * dataset. If this size happens to be appropriate, no + * call will be needed to either function to set the + * chunk cache size. + * + * It is also possible that a change in access pattern + * for later access to a dataset will change the + * appropriate chunk cache size. + * + * \since 1.8.3 + * + */ +H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0); +/** + * \ingroup DAPL + * + * \brief Sets the external dataset storage file prefix in the dataset + * access property list + * + * \dapl_id + * \param[in] prefix Dataset external storage prefix in UTF-8 or ASCII + * (Path and filename must be ASCII on Windows systems.) + * + * \return \herr_t + * + * \details H5Pset_efile_prefix() sets the prefix used to locate raw data + * files for a dataset that uses external storage. This prefix + * can provide either an absolute path or a relative path to the + * external files. + * + * H5Pset_efile_prefix() is used in conjunction with + * H5Pset_external() to control the behavior of the HDF5 library + * when searching for the raw data files associated with a dataset + * that uses external storage: + * + * \li The default behavior of the library is to search for the + * dataset’s external storage raw data files in the same + * directory as the HDF5 file which contains the dataset. + * \li If the prefix is set to an absolute path, the target + * directory will be searched for the dataset’s external + * storage raw data files. + * \li If the prefix is set to a relative path, the target + * directory, relative to the current working directory, will + * be searched for the dataset’s external storage raw data + * files. + * \li If the prefix is set to a relative path that begins with + * the special token ${ORIGIN}, that directory, relative to + * the HDF5 file containing the dataset, will be searched for + * the dataset’s external storage raw data files. + * + * The HDF5_EXTFILE_PREFIX environment variable can be used to + * override the above behavior (the environment variable + * supersedes the API call). Setting the variable to a path + * string and calling H5Dcreate() or H5Dopen() is the equivalent + * of calling H5Pset_efile_prefix() and calling the same create + * or open function. The environment variable is checked at the + * time of the create or open action and copied so it can be + * safely changed after the H5Dcreate() or H5Dopen() call. + * + * Calling H5Pset_efile_prefix() with \p prefix set to NULL or + * the empty string returns the search path to the default. The + * result would be the same as if H5Pset_efile_prefix() had never + * been called. + * + * \note If the external file prefix is not an absolute path and the HDF5 + * file is moved, the external storage files will also need to be + * moved so they can be accessed at the new location. + * + * \note As stated above, the use of the HDF5_EXTFILE_PREFIX environment + * variable overrides any property list setting. + * H5Pset_efile_prefix() and H5Pget_efile_prefix(), being property + * functions, set and retrieve only the property list setting; they + * are unaware of the environment variable. + * + * \note On Windows, the prefix must be an ASCII string since the Windows + * standard C library’s I/O functions cannot handle UTF-8 file names. + * + * \since 1.10.0, 1.8.17 + * + */ +H5_DLL herr_t H5Pset_efile_prefix(hid_t dapl_id, const char *prefix); +/** + * \ingroup DAPL + * + * \brief Sets prefix to be applied to VDS source file paths + * + * \dapl_id + * \param[in] prefix Prefix to be applied to VDS source file paths + * + * \return \herr_t + * + * \details H5Pset_virtual_prefix() sets the prefix to be applied to the + * path of any VDS source files traversed. The prefix is prepended + * to the filename stored in the VDS virtual file, set with + * H5Pset_virtual(). + * + * The prefix is specified in the user-allocated buffer \p prefix + * and set in the dataset access property list \p dapl_id. The + * buffer should not be freed until the property list has been + * closed. + * + * \see_virtual + * + * \since 1.10.2 + * + */ +H5_DLL herr_t H5Pset_virtual_prefix(hid_t dapl_id, const char *prefix); +/** + * \ingroup DAPL + * + * \brief Sets the maximum number of missing source files and/or datasets + * with the printf-style names when getting the extent of an + * unlimited virtual dataset + * + * \dapl_id + * \param[in] gap_size Maximum number of files and/or datasets allowed to + * be missing for determining the extent of an + * unlimited virtual dataset with printf-style + * mappings (Default value: 0) + * + * \return \herr_t + * + * \details H5Pset_virtual_printf_gap() sets the access property list for + * the virtual dataset, \p dapl_id, to instruct the library to + * stop looking for the mapped data stored in the files and/or + * datasets with the printf-style names after not finding + * \p gap_size files and/or datasets. The found source files and + * datasets will determine the extent of the unlimited virtual + * dataset with the printf-style mappings. + * + * Consider the following examples where the regularly spaced + * blocks of a virtual dataset are mapped to datasets with the + * names d-1, d-2, d-3, ..., d-N, ... : + * + * \li If the dataset d-2 is missing and \p gap_size is set to 0, + * then the virtual dataset will contain only data found + * in d-1. + * \li If d-2 and d-3 are missing and \p gap_size is set to 2, + * then the virtual dataset will contain the data from + * d-1, d-3, ..., d-N, ... . The blocks that are mapped to + * d-2 and d-3 will be filled according to the virtual + * dataset’s fill value setting. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pset_virtual_printf_gap(hid_t dapl_id, hsize_t gap_size); +/** + * \ingroup DAPL + * + * \brief Sets the view of the virtual dataset (VDS) to include or exclude + * missing mapped elements + * + * \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 + * + * \return \herr_t + * + * \details H5Pset_virtual_view() takes the access property list for the + * virtual dataset, \p dapl_id, and the flag, \p view, and sets + * the VDS view according to the flag value. + * + * If \p view is set to #H5D_VDS_FIRST_MISSING, the view includes + * all data before the first missing mapped data. This setting + * provides a view containing only the continuous data starting + * with the dataset’s first data element. Any break in + * continuity terminates the view. + * + * If \p view is set to #H5D_VDS_LAST_AVAILABLE, the view + * includes all available mapped data. + * + * Missing mapped data is filled with the fill value set in the + * VDS creation property list. + * + * \see_virtual + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pset_virtual_view(hid_t dapl_id, H5D_vds_view_t view); -/* File creation property list (FCPL) routines */ -H5_DLL herr_t H5Pset_userblock(hid_t plist_id, hsize_t size); -H5_DLL herr_t H5Pget_userblock(hid_t plist_id, hsize_t *size); -H5_DLL herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, - size_t sizeof_size); -H5_DLL herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr/*out*/, - size_t *sizeof_size/*out*/); -H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk); -H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik/*out*/, unsigned *lk/*out*/); -H5_DLL herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik); -H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik/*out*/); -H5_DLL herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes); -H5_DLL herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes); -H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size); -H5_DLL herr_t H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags, unsigned *min_mesg_size); -H5_DLL herr_t H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree); -H5_DLL herr_t H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list, unsigned *min_btree); -H5_DLL herr_t H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, hbool_t persist, hsize_t threshold); -H5_DLL herr_t H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy, hbool_t *persist, hsize_t *threshold); -H5_DLL herr_t H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size); -H5_DLL herr_t H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size); +/* Dataset xfer property list (DXPL) routines */ +/** + * + * \ingroup DXPL + * + * \brief Gets B-tree split ratios for a dataset transfer property list + * + * \dxpl_id{plist_id} + * \param[out] left The B-tree split ratio for left-most nodes + * \param[out] middle The B-tree split ratio for right-most nodes and lone nodes + * \param[out] right The B-tree split ratio for all other nodes + * \return \herr_t + * + * \details H5Pget_btree_ratios() returns the B-tree split ratios for a dataset + * transfer property list. + * + * The B-tree split ratios are returned through the non-NULL arguments + * \p left, \p middle, and \p right, as set by the H5Pset_btree_ratios() + * function. + * + */ +H5_DLL herr_t H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, + double *right /*out*/); +/** + * + * \ingroup DXPL + * + * \brief Reads buffer settings + * + * \param[in] plist_id Identifier for the dataset transfer property list + * \param[out] tconv Address of the pointer to application-allocated type + * conversion buffer + * \param[out] bkg Address of the pointer to application-allocated + * background buffer + * + * \return Returns buffer size, in bytes, if successful; otherwise 0 on failure. + * + * \details H5Pget_buffer() reads values previously set with H5Pset_buffer(). + * + * \version 1.6.0 The return type changed from \p hsize_t to \p size_t. + * \version 1.4.0 The return type changed to \p hsize_t. + * + */ +H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*out*/); +/** + * + * \ingroup DXPL + * + * \brief Retrieves a data transform expression + * + * \param[in] plist_id Identifier of the property list or class + * \param[out] expression Pointer to memory where the transform expression will + * be copied + * \param[in] size Number of bytes of the transform expression to copy + * to + * + * \return Success: the size of the transform expression. Failure: a negative + * value. + * + * \details H5Pget_data_transform() retrieves the data transform expression + * previously set in the dataset transfer property list \p plist_id + * by H5Pset_data_transform(). + * + * H5Pget_data_transform() can be used to both retrieve the transform + * expression and query its size. + * + * If \p expression is non-NULL, up to \p size bytes of the data + * transform expression are written to the buffer. If \p expression + * is NULL, \p size is ignored, and the function does not write + * anything to the buffer. The function always returns the size of + * the data transform expression. + * + * If 0 is returned for the size of the expression, no data transform + * expression exists for the property list. + * + * 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 + * + */ +H5_DLL ssize_t H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size); +/** + * + * \ingroup DXPL + * + * \brief Determines whether error-detection is enabled for dataset reads + * + * \param[in] plist_id Dataset transfer property list identifier + * + * \return Returns \p H5Z_ENABLE_EDC or \p H5Z_DISABLE_EDC if successful; + * otherwise returns a negative value. + * + * \details H5Pget_edc_check() queries the dataset transfer property + * list \p plist to determine whether error detection is enabled for + * data read operations. + * + * \since 1.6.0 + * + */ +H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); +/** + * + * \ingroup DXPL + * + * \brief Retrieves number of I/O vectors to be read/written in hyperslab I/O + * + * \param[in] fapl_id Dataset transfer property list identifier + * \param[out] size Number of I/O vectors to accumulate in memory for I/O operations + * + * \return \herr_t + * + * \details H5Pget_hyper_vector_size() retrieves the number of I/O vectors to be accumulated in + * memory before being issued to the lower levels of the HDF5 library for reading or + * writing the actual data. + * + * The number of I/O vectors set in the dataset transfer property list \p fapl_id is + * returned in \p size. Unless the default value is in use, \p size was + * previously set with a call to H5Pset_hyper_vector_size(). + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size /*out*/); +/** + * + * \ingroup DXPL + * + * \brief Checks status of the dataset transfer property list (\b DEPRECATED) + * + * \deprecated{H5Pget_preserve() is deprecated as it is no longer useful; + * compound datatype field preservation is now core functionality + * in the HDF5 library.} + * + * \param[in] plist_id Identifier for the dataset transfer property list + * + * \return Returns 1 or 0 if successful; otherwise returns a negative value. + * + * \details H5Pget_preserve() checks the status of the dataset transfer + * property list. + * + * \version 1.6.0 The flag parameter was changed from INTEGER to LOGICAL to + * better match the C API. (Fortran 90) + * + */ +H5_DLL int H5Pget_preserve(hid_t plist_id); +/** + * + * \ingroup DXPL + * + * \brief Gets user-defined datatype conversion callback function + * + * \param[in] dxpl_id Dataset transfer property list identifier + * \param[out] op User-defined type conversion callback function + * \param[out] operate_data User-defined input data for the callback function + * + * \return \herr_t + * + * \details H5Pget_type_conv_cb() gets the user-defined datatype conversion + * callback function \p op in the dataset transfer property list + * \p dxpl_id. + * + * The parameter \p operate_data is a pointer to user-defined input + * data for the callback function. + * + * The callback function \p op defines the actions an application is + * to take when there is an exception during datatype conversion. + * + * Please refer to the function H5Pset_type_conv_cb() for more details. + * + */ +H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, void **operate_data); +/** + * + * \ingroup DXPL + * + * \brief Gets the memory manager for variable-length datatype allocation in H5Dread() and H5Dvlen_reclaim() + * + * \param[in] plist_id Identifier for the dataset transfer property list + * \param[out] alloc_func User's allocate routine, or NULL for system malloc + * \param[out] alloc_info Extra parameter for user’s allocation routine. + * Contents are ignored if preceding + * parameter is NULL \param[out] free_func User's free routine, or NULL for + * system free \param[out] free_info + * Extra parameter for user’s free routine. Contents are ignored if preceding + * parameter is NULL + * + * \return \herr_t + * + * \details H5Pget_vlen_mem_manager() is the companion function to + * H5Pset_vlen_mem_manager(), returning the parameters set by + * that function. + * + */ +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); +/** + * + * \ingroup DXPL + * + * \brief Sets B-tree split ratios for a dataset transfer property list + * + * \param[in] plist_id The dataset transfer property list identifier + * \param[in] left The B-tree split ratio for left-most nodes + * \param[in] middle The B-tree split ratio for all other nodes + * \param[in] right The B-tree split ratio for right-most nodes and lone + * nodes + * + * \return \herr_t + * + * \details H5Pset_btree_ratios() sets the B-tree split ratios for a dataset + * transfer property list. The split ratios determine what percent of + * children go in the first node when a node splits. + * + * The ratio \p left is used when the splitting node is the left-most + * node at its level in the tree; + * the ratio \p right is used when the splitting node is the right-most + * node at its level; and + * the ratio \p middle is used for all other cases. + * + * A node that is the only node at its level in the tree uses the + * ratio \p right when it splits. + * + * All ratios are real numbers between 0 and 1, inclusive. + * + */ +H5_DLL herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right); -/* File access property list (FAPL) routines */ -H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, - hsize_t alignment); -H5_DLL herr_t H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/, - hsize_t *alignment/*out*/); -H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, - const void *driver_info); -H5_DLL hid_t H5Pget_driver(hid_t plist_id); -H5_DLL const void *H5Pget_driver_info(hid_t plist_id); -H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); -H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); -H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); -H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); -H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, - size_t rdcc_nslots, size_t rdcc_nbytes, - double rdcc_w0); -H5_DLL herr_t H5Pget_cache(hid_t plist_id, - int *mdc_nelmts, /* out */ - size_t *rdcc_nslots/*out*/, - size_t *rdcc_nbytes/*out*/, double *rdcc_w0); -H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, - H5AC_cache_config_t * config_ptr); -H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, - H5AC_cache_config_t * config_ptr); /* out */ -H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); -H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref/*out*/); -H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); -H5_DLL herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *degree); -H5_DLL herr_t H5Pset_meta_block_size(hid_t fapl_id, hsize_t size); -H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_sieve_buf_size(hid_t fapl_id, size_t size); -H5_DLL herr_t H5Pget_sieve_buf_size(hid_t fapl_id, size_t *size/*out*/); -H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size); -H5_DLL herr_t H5Pget_small_data_block_size(hid_t fapl_id, hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, - H5F_libver_t high); -H5_DLL herr_t H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low, - H5F_libver_t *high); -H5_DLL herr_t H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size); -H5_DLL herr_t H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size); -H5_DLL herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len); -H5_DLL herr_t H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr); -H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, - H5FD_file_image_callbacks_t *callbacks_ptr); -H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, - H5FD_file_image_callbacks_t *callbacks_ptr); -H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); -H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); -H5_DLL herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts); -H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts); -H5_DLL herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata); -H5_DLL herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata); -H5_DLL herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access); -H5_DLL herr_t H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size, hbool_t *start_on_access); -H5_DLL herr_t H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close); -H5_DLL herr_t H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close); -H5_DLL herr_t H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled); -H5_DLL herr_t H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled); -#ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective); -H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); -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); -#endif /* H5_HAVE_PARALLEL */ -H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); -H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); -H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); -H5_DLL herr_t H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_per, unsigned *min_raw_per); +/** + * + * \ingroup DXPL + * + * \brief Sets type conversion and background buffers + * + * \dxpl_id{plist_id} + * \param[in] size Size, in bytes, of the type conversion and background buffers + * \param[in] tconv Pointer to application-allocated type conversion buffer + * \param[in] bkg Pointer to application-allocated background buffer + * \return \herr_t + * + * \details Given a dataset transfer property list, H5Pset_buffer() sets the + * maximum size for the type conversion buffer and background buffer + * and optionally supplies pointers to application-allocated + * buffers. If the buffer size is smaller than the entire amount of + * data being transferred between the application and the file, and a + * type conversion buffer or background buffer is required, then strip + * mining will be used. + * + * Note that there are minimum size requirements for the buffer. Strip + * mining can only break the data up along the first dimension, so the + * buffer must be large enough to accommodate a complete slice that + * encompasses all of the remaining dimensions. For example, when strip + * mining a \Code{100x200x300} hyperslab of a simple data space, the + * buffer must be large enough to hold \Code{1x200x300} data + * elements. When strip mining a \Code{100x200x300x150} hyperslab of a + * simple data space, the buffer must be large enough to hold + * \Code{1x200x300x150} data elements. + * + * If \p tconv and/or \p bkg are null pointers, then buffers will be + * allocated and freed during the data transfer. + * + * The default value for the maximum buffer is 1 MiB. + * + * \version 1.6.0 The \p size parameter has changed from type hsize_t to \c size_t. + * \version 1.4.0 The \p size parameter has changed to type hsize_t. + * + */ +H5_DLL herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg); + +/** + * \ingroup DXPL + * + * \brief Sets a data transform expression + * + * \dxpl_id{plist_id} + * \param[in] expression Pointer to the null-terminated data transform + * expression + * \return \herr_t + * + * \details H5Pset_data_transform() sets the data transform to be used for + * reading and writing data. This function operates on the dataset + * transfer property list \p plist_id. + * + * The \p expression parameter is a string containing an algebraic + * expression, such as \Code{(5/9.0)*(x-32)} or \Code{x*(x-5)}. When a + * dataset is read or written with this property list, the transform + * expression is applied with the \c x being replaced by the values in + * the dataset. When reading data, the values in the file are not + * changed and the transformed data is returned to the user. + * + * Data transforms can only be applied to integer or + * floating-point datasets. Order of operations is obeyed and + * the only supported operations are +, -, *, and /. Parentheses + * can be nested arbitrarily and can be used to change precedence. + * When writing data back to the dataset, the transformed data is + * written to the file and there is no way to recover the original + * values to which the transform was applied. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char *expression); + +/** + * \ingroup DXPL + * + * \brief Sets the dataset transfer property list to enable or disable error + * detection when reading data + * + * \dxpl_id{plist_id} + * \param[in] check Specifies whether error checking is enabled or disabled + * for dataset read operations + * \return \herr_t + * + * \details H5Pset_edc_check() sets the dataset transfer property list \p plist + * to enable or disable error detection when reading data. + * + * Whether error detection is enabled or disabled is specified in the + * \p check parameter. Valid values are #H5Z_ENABLE_EDC (default) and + * #H5Z_DISABLE_EDC. + * + * \note The initial error detection implementation, Fletcher32 checksum, + * supports error detection for chunked datasets only. + * + * \attention The Fletcher32 EDC checksum filter, set with H5Pset_fletcher32(), + * was added in HDF5 Release 1.6.0. In the original implementation, + * however, the checksum value was calculated incorrectly on + * little-endian systems. The error was fixed in HDF5 Release 1.6.3.\n + * As a result of this fix, an HDF5 library of Release 1.6.0 through + * Release 1.6.2 cannot read a dataset created or written with + * Release 1.6.3 or later if the dataset was created with the + * checksum filter and the filter is enabled in the reading + * library. (Libraries of Release 1.6.3 and later understand the + * earlier error and compensate appropriately.)\n + * \Bold{Work-around:} An HDF5 library of Release 1.6.2 or earlier + * will be able to read a dataset created or written with the + * checksum filter by an HDF5 library of Release 1.6.3 or later if + * the checksum filter is disabled for the read operation. This can + * be accomplished via an H5Pset_edc_check() call with the value + * #H5Z_DISABLE_EDC in the second parameter. This has the obvious + * drawback that the application will be unable to verify the + * checksum, but the data does remain accessible. + * + * \version 1.6.3 Error in checksum calculation on little-endian systems + * corrected in this release. + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); + +/** + * \ingroup DXPL + * + * \brief Sets user-defined filter callback function + * + * \dxpl_id{plist_id} + * \param[in] func User-defined filter callback function + * \param[in] op_data User-defined input data for the callback function + * \return \herr_t + * + * \details H5Pset_filter_callback() sets the user-defined filter callback + * function \p func in the dataset transfer property list \p plist_id. + * + * The parameter \p op_data is a pointer to user-defined input data for + * the callback function and will be passed through to the callback + * function. + * + * The callback function \p func defines the actions an application is + * to take when a filter fails. The function prototype is as follows: + * \snippet H5Zpublic.h H5Z_filter_func_t_snip + * where \c filter indicates which filter has failed, \c buf and \c buf_size + * are used to pass in the failed data, and op_data is the required + * input data for this callback function. + * + * Valid callback function return values are #H5Z_CB_FAIL and #H5Z_CB_CONT. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data); + +/** + * \ingroup DXPL + * + * \brief Sets number of I/O vectors to be read/written in hyperslab I/O + * + * \dxpl_id{plist_id} + * \param[in] size Number of I/O vectors to accumulate in memory for I/O + * operations\n + * Must be greater than 1 (one)\n + * Default value: 1024 + * \return \herr_t + * + * \details H5Pset_hyper_vector_size() sets the number of I/O vectors to be + * accumulated in memory before being issued to the lower levels of + * the HDF5 library for reading or writing the actual data. + * + * The I/O vectors are hyperslab offset and length pairs and are + * generated during hyperslab I/O. + * + * The number of I/O vectors is passed in \p size to be set in the + * dataset transfer property list \p plist_id. \p size must be + * greater than 1 (one). + * + * H5Pset_hyper_vector_size() is an I/O optimization function; + * increasing vector_size should provide better performance, but the + * library will use more memory during hyperslab I/O. The default value + * of \p size is 1024. + * + * \since 1.6.0 + * + */ +H5_DLL herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t size); + +/** + * \ingroup DXPL + * + * \brief Sets the dataset transfer property list \p status + * + * \dxpl_id{plist_id} + * \param[in] status Status toggle of the dataset transfer property list + * \return \herr_t + * + * \deprecated This function is deprecated as it no longer has any effect; + * compound datatype field preservation is now core functionality in + * the HDF5 library. + * + * \details H5Pset_preserve() sets the dataset transfer property list status to + * \c 1 or \c 0. + * + * When reading or writing compound datatypes and the destination is + * partially initialized and the read/write is intended to initialize + * the other members, one must set this property to \c 1. Otherwise the + * 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? + * + */ +H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); -/* Dataset creation property list (DCPL) routines */ -H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); -H5_DLL H5D_layout_t H5Pget_layout(hid_t plist_id); -H5_DLL herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]); -H5_DLL int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/); -H5_DLL 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); -H5_DLL herr_t H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/); -H5_DLL hid_t H5Pget_virtual_vspace(hid_t dcpl_id, size_t index); -H5_DLL hid_t H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index); -H5_DLL ssize_t H5Pget_virtual_filename(hid_t dcpl_id, size_t index, - char *name/*out*/, size_t size); -H5_DLL ssize_t H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, - char *name/*out*/, size_t size); -H5_DLL herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, - hsize_t size); -H5_DLL herr_t H5Pset_chunk_opts(hid_t plist_id, unsigned opts); -H5_DLL herr_t H5Pget_chunk_opts(hid_t plist_id, unsigned *opts); -H5_DLL int H5Pget_external_count(hid_t plist_id); -H5_DLL herr_t H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, - char *name/*out*/, off_t *offset/*out*/, - hsize_t *size/*out*/); -H5_DLL herr_t H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block); -H5_DLL herr_t H5Pset_shuffle(hid_t plist_id); -H5_DLL herr_t H5Pset_nbit(hid_t plist_id); -H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_factor); -H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, - const void *value); -H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, - void *value/*out*/); -H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); -H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t - alloc_time); -H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t - *alloc_time/*out*/); -H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); -H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t - *fill_time/*out*/); -H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); -H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); +/** + * \ingroup DXPL + * + * \brief Sets user-defined datatype conversion callback function + * + * \dxpl_id + * \param[in] op User-defined type conversion callback function + * \param[in] operate_data User-defined input data for the callback function + * \return \herr_t + * + * \details H5Pset_type_conv_cb() sets the user-defined datatype conversion + * callback function \p op in the dataset transfer property list \p + * dxpl_id + * + * The parameter operate_data is a pointer to user-defined input data + * for the callback function and will be passed through to the callback + * function. + * + * The callback function \p op defines the actions an application is to + * take when there is an exception during datatype conversion. The + * function prototype is as follows: + * \snippet H5Tpublic.h H5T_conv_except_func_t_snip + * + * \todo Add version information. + * + */ +H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void *operate_data); -/* Dataset access property list (DAPL) routines */ -H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, - size_t rdcc_nbytes, double rdcc_w0); -H5_DLL herr_t H5Pget_chunk_cache(hid_t dapl_id, - size_t *rdcc_nslots/*out*/, - size_t *rdcc_nbytes/*out*/, - double *rdcc_w0/*out*/); -H5_DLL herr_t H5Pset_virtual_view(hid_t plist_id, H5D_vds_view_t view); -H5_DLL herr_t H5Pget_virtual_view(hid_t plist_id, H5D_vds_view_t *view); -H5_DLL herr_t H5Pset_virtual_printf_gap(hid_t plist_id, hsize_t gap_size); -H5_DLL herr_t H5Pget_virtual_printf_gap(hid_t plist_id, hsize_t *gap_size); -H5_DLL herr_t H5Pset_virtual_prefix(hid_t dapl_id, const char* prefix); -H5_DLL ssize_t H5Pget_virtual_prefix(hid_t dapl_id, char* prefix /*out*/, size_t size); -H5_DLL herr_t H5Pset_append_flush(hid_t plist_id, unsigned ndims, - const hsize_t boundary[], H5D_append_cb_t func, void *udata); -H5_DLL herr_t H5Pget_append_flush(hid_t plist_id, unsigned dims, - hsize_t boundary[], H5D_append_cb_t *func, void **udata); -H5_DLL herr_t H5Pset_efile_prefix(hid_t dapl_id, const char* prefix); -H5_DLL ssize_t H5Pget_efile_prefix(hid_t dapl_id, char* prefix /*out*/, size_t size); +/** + * \ingroup DXPL + * + * \brief Sets the memory manager for variable-length datatype allocation in + * H5Dread() and H5Dvlen_reclaim() + * + * \dxpl_id{plist_id} + * \param[in] alloc_func User's allocate routine, or \c NULL for system \c malloc + * \param[in] alloc_info Extra parameter for user's allocation routine. + * Contents are ignored if preceding parameter is \c NULL. + * \param[in] free_func User's free routine, or \c NULL for system \c free + * \param[in] free_info Extra parameter for user's free routine. Contents are + * ignored if preceding parameter is \c NULL + * \return \herr_t + * + * \details H5Pset_vlen_mem_manager() sets the memory manager for + * variable-length datatype allocation in H5Dread() and free in + * H5Dvlen_reclaim(). + * + * The \p alloc_func and \p free_func parameters identify the memory + * management routines to be used. If the user has defined custom + * memory management routines, \p alloc_func and/or free_func should be + * set to make those routine calls (i.e., the name of the routine is + * used as the value of the parameter); if the user prefers to use the + * system's \c malloc and/or \c free, the \p alloc_func and \p + * free_func parameters, respectively, should be set to \c NULL + * + * The prototypes for these user-defined functions are as follows: + * \snippet H5MMpublic.h H5MM_allocate_t_snip + * + * \snippet H5MMpublic.h H5MM_free_t_snip + * + * The \p alloc_info and \p free_info parameters can be used to pass + * along any required information to the user's memory management + * routines. + * + * In summary, if the user has defined custom memory management + * routines, the name(s) of the routines are passed in the \p + * alloc_func and \p free_func parameters and the custom routines' + * parameters are passed in the \p alloc_info and \p free_info + * parameters. If the user wishes to use the system \c malloc and \c + * free functions, the \p alloc_func and/or \p free_func parameters are + * set to \c NULL and the \p alloc_info and \p free_info parameters are + * ignored. + * + * \todo Add version information. + */ +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); -/* Dataset xfer property list (DXPL) routines */ -H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char* expression); -H5_DLL ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t size); -H5_DLL herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, - void *bkg); -H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, - void **bkg/*out*/); -H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); -H5_DLL int H5Pget_preserve(hid_t plist_id); -H5_DLL herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check); -H5_DLL H5Z_EDC_t H5Pget_edc_check(hid_t plist_id); -H5_DLL herr_t H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, - void* op_data); -H5_DLL herr_t H5Pset_btree_ratios(hid_t plist_id, double left, double middle, - double right); -H5_DLL herr_t H5Pget_btree_ratios(hid_t plist_id, double *left/*out*/, - double *middle/*out*/, - double *right/*out*/); -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); -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); -H5_DLL herr_t H5Pset_hyper_vector_size(hid_t fapl_id, size_t size); -H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size/*out*/); -H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void* operate_data); -H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, void** operate_data); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); +/** + * \ingroup DXPL + * + * \brief Retrieves the type of chunk optimization that HDF5 actually performed + * on the last parallel I/O call (not necessarily the type requested) + * + * \dxpl_id{plist_id} + * \param[out] actual_chunk_opt_mode The type of chunk optimization performed by HDF5 + * \return \herr_t + * + * \par Motivation: + * A user can request collective I/O via a data transfer property list + * (DXPL) that has been suitably modified with H5Pset_dxpl_mpio(). + * However, HDF5 will sometimes ignore this request and perform independent + * I/O instead. This property allows the user to see what kind of I/O HDF5 + * actually performed. Used in conjunction with H5Pget_mpio_actual_io_mode(), + * this property allows the user to determine exactly what HDF5 did when + * attempting collective I/O. + * + * \details H5Pget_mpio_actual_chunk_opt_mode() retrieves the type of chunk + * optimization performed when collective I/O was requested. This + * property is set before I/O takes place, and will be set even if I/O + * fails. + * + * Valid values returned in \p actual_chunk_opt_mode: + * \snippet this H5D_mpio_actual_chunk_opt_mode_t_snip + * \click4more + * + * \since 1.8.8 + * + */ +H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, + H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); +/** + * \ingroup DXPL + * + * \brief Retrieves the type of I/O that HDF5 actually performed on the last + * parallel I/O call (not necessarily the type requested) + * + * \dxpl_id{plist_id} + * \param[out] actual_io_mode The type of I/O performed by this process + * \return \herr_t + * + * \par Motivation: + * A user can request collective I/O via a data transfer property list + * (DXPL) that has been suitably modified with H5Pset_dxpl_mpio(). + * However, HDF5 will sometimes ignore this request and perform independent + * I/O instead. This property allows the user to see what kind of I/O HDF5 + * actually performed. Used in conjunction with H5Pget_mpio_actual_chunk_opt_mode(), + * this property allows the user to determine exactly HDF5 did when + * attempting collective I/O. + * + * \details H5Pget_mpio_actual_io_mode() retrieves the type of I/O performed on + * the selection of the current process. This property is set after all + * I/O is completed; if I/O fails, it will not be set. + * + * Valid values returned in \p actual_io_mode: + * \snippet this H5D_mpio_actual_io_mode_t_snip + * \click4more + * + * \attention All processes do not need to have the same value. For example, if + * I/O is being performed using the multi chunk optimization scheme, + * one process's selection may include only chunks accessed + * collectively, while another may include chunks accessed + * independently. In this case, the first process will report + * #H5D_MPIO_CHUNK_COLLECTIVE while the second will report + * #H5D_MPIO_CHUNK_INDEPENDENT. + * + * \see H5Pget_mpio_no_collective_cause(), H5Pget_mpio_actual_chunk_opt_mode() + * + * \since 1.8.8 + * + */ H5_DLL herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); -H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); +/** + * \ingroup DXPL + * + * \brief Retrieves local and global causes that broke collective I/O on the last + * parallel I/O call + * + * \dxpl_id{plist_id} + * \param[out] local_no_collective_cause An enumerated set value indicating the + * causes that prevented collective I/O in the local process + * \param[out] global_no_collective_cause An enumerated set value indicating + * the causes across all processes that prevented collective I/O + * \return \herr_t + * + * \par Motivation: + * A user can request collective I/O via a data transfer property list (DXPL) + * that has been suitably modified with H5P_SET_DXPL_MPIO. However, there are + * conditions that can cause HDF5 to forgo collective I/O and perform + * independent I/O. Such causes can be different across the processes of a + * parallel application. This function allows the user to determine what + * caused the HDF5 library to skip collective I/O locally, that is in the + * local process, and globally, across all processes. + * + * \details H5Pget_mpio_no_collective_cause() serves two purposes. It can be + * used to determine whether collective I/O was used for the last + * preceding parallel I/O call. If collective I/O was not used, the + * function retrieves the local and global causes that broke collective + * I/O on that parallel I/O call. The properties retrieved by this + * function are set before I/O takes place and are retained even when + * I/O fails. + * + * Valid values returned in \p local_no_collective_cause and \p + * global_no_collective_cause are as follows or, if there are multiple + * causes, a bitwise OR of the relevant causes; the numbers in the + * center column are the bitmask values: + * \snippet this H5D_mpio_no_collective_cause_t_snip + * \click4more + * + * \attention Each process determines whether it can perform collective I/O and + * broadcasts the result. Those results are combined to make a + * collective decision; collective I/O will be performed only if all + * processes can perform collective I/O.\n + * If collective I/O was not used, the causes that prevented it are + * reported by individual process by means of an enumerated set. The + * causes may differ among processes, so H5Pget_mpio_no_collective_cause() + * returns two property values. The first value is the one produced + * by the local process to report local causes. This local information + * is encoded in an enumeration, the \ref H5D_mpio_no_collective_cause_t + * described above, with all individual causes combined into a single + * enumeration value by means of a bitwise OR operation. The second + * value reports global causes; this global value is the result of a + * bitwise-OR operation across the values returned by all the processes. + * + * \since 1.8.10 + * + */ +H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, + uint32_t *global_no_collective_cause); #endif /* H5_HAVE_PARALLEL */ /* Link creation property list (LCPL) routines */ -H5_DLL herr_t H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd); +/** + * \ingroup ALCAPL + * + * \brief Determines whether property is set to enable creating missing + * intermediate groups + * + * \lcpl_id{plist_id} + * \param[out] crt_intmd Flag specifying whether to create intermediate + * groups upon creation of an object + * + * \return \herr_t + * + * \details H5Pget_create_intermediate_group() determines whether the link + * creation property list \p plist_id is set to allow functions + * that create objects in groups different from the current + * working group to create intermediate groups that may be + * missing in the path of a new or moved object. + * + * Functions that create objects in or move objects to a group + * other than the current working group make use of this + * property. H5Gcreate_anon() and H5Lmove() are examples of such + * functions. + * + * If \p crt_intmd is positive, missing intermediate groups will + * be created; if \p crt_intmd is non-positive, missing intermediate + * groups will not be created. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_intmd /*out*/); +/** + * \ingroup ALCAPL + * + * \brief Specifies in property list whether to create missing + * intermediate groups + * + * \lcpl_id{plist_id} + * \param[in] crt_intmd Flag specifying whether to create intermediate + * groups upon the creation of an object + * + * \return \herr_t + * + * \details H5Pset_create_intermediate_group() + * + * \since + * + */ +H5_DLL herr_t H5Pset_create_intermediate_group(hid_t plist_id, unsigned crt_intmd); /* Group creation property list (GCPL) routines */ -H5_DLL herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint); + +/** + * \ingroup GCPL + * + * \brief Returns the estimated link count and average link name length in a group + * + * \gcpl_id{plist_id} + * \param[out] est_num_entries The estimated number of links in the group + * referenced by \p plist_id + * \param[out] est_name_len The estimated average length of line names in the group + * referenced by \p plist_id + * \return \herr_t + * + * \details H5Pget_est_link_info() retrieves two settings from the group creation + * property list \p plist_id: the estimated number of links that are + * expected to be inserted into a group created with the property list + * and the estimated average length of those link names. + * + * The estimated number of links is returned in \p est_num_entries. The + * limit for \p est_num_entries is 64 K. + * + * The estimated average length of the anticipated link names is returned + * in \p est_name_len. The limit for \p est_name_len is 64 K. + * + * See \ref_group_impls for a discussion of the available types of HDF5 + * group structures. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* out */, + unsigned *est_name_len /* out */); +/** + * \ingroup GCPL + * + * \brief Queries whether link creation order is tracked and/or indexed in + * a group + * + * \param[in] plist_id Group or file creation property list + * identifier + * \param[out] crt_order_flags Creation order flag(s) + * + * \return \herr_t + * + * \details H5Pget_link_creation_order() queries the group or file creation + * property list, \p plist_id, and returns a flag indicating whether + * link creation order is tracked and/or indexed in a group. + * + * See H5Pset_link_creation_order() for a list of valid creation + * order flags, as passed in \p crt_order_flags, and their + * meanings. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /* out */); +/** + * \ingroup GCPL + * + * \brief Queries the settings for conversion between compact and dense + * groups + * + * \gcpl_id{plist_id} + * \param[out] max_compact Maximum number of links for compact storage + * \param[out] min_dense Minimum number of links for dense storage + * + * \return \herr_t + * + * \details H5Pget_link_phase_change() queries the maximum number of + * entries for a compact group and the minimum number of links + * to require before converting a group to a dense form. + * + * In the compact format, links are stored as messages in the + * group’s header. In the dense format, links are stored in a + * fractal heap and indexed with a version 2 B-tree. + * + * \p max_compact is the maximum number of links to store as + * header messages in the group header before converting the + * group to the dense format. Groups that are in the compact + * format and exceed this number of links are automatically + * converted to the dense format. + * + * \p min_dense is the minimum number of links to store in the + * dense format. Groups which are in dense format and in which + * the number of links falls below this number are automatically + * converted back to the compact format. + * + * In the compact format, links are stored as messages in the + * group’s header. In the dense format, links are stored in a + * fractal heap and indexed with a version 2 B-tree. + * + * See H5Pset_link_phase_change() for a discussion of + * traditional, compact, and dense group storage. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, + unsigned *min_dense /*out*/); +/** + * \ingroup GCPL + * + * \brief Retrieves the anticipated size of the local heap for original-style + * groups + * + * \gcpl_id{plist_id} + * \param[out] size_hint Anticipated size of local heap + * \return \herr_t + * + * \details H5Pget_local_heap_size_hint() queries the group creation property + * list, \p plist_id, for the anticipated size of the local heap, \p + * size_hint, for original-style groups, i.e., for groups of the style + * used prior to HDF5 Release 1.8.0. See H5Pset_local_heap_size_hint() + * for further discussion. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/); -H5_DLL herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); -H5_DLL herr_t H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/); +/** + * \ingroup GCPL + * + * \brief Sets estimated number of links and length of link names in a group + * + * \gcpl_id{plist_id} + * \param[in] est_num_entries Estimated number of links to be inserted into group + * \param[in] est_name_len Estimated average length of link names + * \return \herr_t + * + * \details H5Pset_est_link_info() inserts two settings into the group creation + * property list plist_id: the estimated number of links that are + * expected to be inserted into a group created with the property list + * and the estimated average length of those link names. + * + * The estimated number of links is passed in \p est_num_entries. The + * limit for \p est_num_entries is 64 K. + * + * The estimated average length of the anticipated link names is passed + * in \p est_name_len. The limit for \p est_name_len is 64 K. + * + * The values for these two settings are multiplied to compute the + * initial local heap size (for old-style groups, if the local heap + * size hint is not set) or the initial object header size for + * (new-style compact groups; see \ref_group_impls). Accurately setting + * these parameters will help reduce wasted file space. + * + * If a group is expected to have many links and to be stored in dense + * format, set \p est_num_entries to 0 (zero) for maximum + * efficiency. This will prevent the group from being created in the + * compact format. + * + * See \ref_group_impls for a discussion of the available types of HDF5 + * group structures. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len); -H5_DLL herr_t H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /* out */, unsigned *est_name_len /* out */); +/** + * \ingroup GCPL + * + * \brief Sets creation order tracking and indexing for links in a group + * + * \param[in] plist_id Group or file creation property list + * identifier + * \param[out] crt_order_flags Creation order flag(s) + * + * \return \herr_t + * + * \details H5Pset_link_creation_order() sets flags for tracking and + * indexing links on creation order in groups created with the + * group (or file) creation property list \p plist_id. + * + * \p crt_order_flags contains flags with the following meanings: + * + * + * + * + * + * + * + * + * + * + *
#H5P_CRT_ORDER_TRACKEDLink creation order is tracked but not necessarily + * indexed
#H5P_CRT_ORDER_INDEXEDLink creation order is indexed (requires + * #H5P_CRT_ORDER_TRACKED)
+ * + * The default behavior is that links are tracked and indexed by + * name, and link creation order is neither tracked nor indexed. + * The name is always the primary index for links in a group. + * + * H5Pset_link_creation_order() can be used to set link creation + * order tracking, or to set link creation order tracking and + * indexing. + * + * If (#H5P_CRT_ORDER_TRACKED | #H5P_CRT_ORDER_INDEXED) is + * specified for \p crt_order_flags, then links will be tracked + * and indexed by creation order. The creation order is added as + * a secondary index and enables faster queries and iterations + * by creation order. + * + * If just #H5P_CRT_ORDER_TRACKED is specified for + * \p crt_order_flags, then links will be tracked by creation + * order, but not indexed by creation order. Queries and iterations + * by creation order will work but will be much slower for large + * groups than if #H5P_CRT_ORDER_INDEXED had been included. + * + * \note If a creation order index is to be built, it must be specified in + * the group creation property list. HDF5 currently provides no + * mechanism to turn on link creation order tracking at group + * creation time and to build the index later. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags); -H5_DLL herr_t H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /* out */); +/** + * \ingroup GCPL + * + * \brief Sets the parameters for conversion between compact and dense + * groups + * + * \gcpl_id{plist_id} + * \param[in] max_compact Maximum number of links for compact storage + * (\a Default: 8) + * \param[in] min_dense Minimum number of links for dense storage + * (\a Default: 6) + * + * \return \herr_t + * + * \details H5Pset_link_phase_change() sets the maximum number of entries + * for a compact group and the minimum number of links to allow + * before converting a dense group back to the compact format. + * + * \p max_compact is the maximum number of links to store as + * header messages in the group header before converting the + * group to the dense format. Groups that are in compact format + * and which exceed this number of links are automatically + * converted to dense format. + * + * \p min_dense is the minimum number of links to store in the + * dense format. Groups which are in dense format and in which + * the number of links falls below this threshold are + * automatically converted to compact format. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); +/** + * \ingroup GCPL + * + * \brief Specifies the anticipated maximum size of a local heap + * + * \gcpl_id{plist_id} + * \param[in] size_hint Anticipated maximum size in bytes of local heap + * \return \herr_t + * + * \details H5Pset_local_heap_size_hint() is used with original-style HDF5 + * groups (see “Motivation” below) to specify the anticipated maximum + * local heap size, size_hint, for groups created with the group + * creation property list \p plist_id. The HDF5 library then uses \p + * size_hint to allocate contiguous local heap space in the file for + * each group created with \p plist_id. + * + * For groups with many members or very few members, an appropriate + * initial value of \p size_hint would be the anticipated number of + * group members times the average length of group member names, plus a + * small margin: + * \code + * size_hint = max_number_of_group_members * + * (average_length_of_group_member_link_names + 2) + * \endcode + * If it is known that there will be groups with zero members, the use + * of a group creation property list with \p size_hint set to to 1 (one) + * will guarantee the smallest possible local heap for each of those groups. + * + * Setting \p size_hint to zero (0) causes the library to make a + * reasonable estimate for the default local heap size. + * + * \par Motivation: + * In situations where backward-compatibility is required, specifically, when + * libraries prior to HDF5 Release 1.8.0 may be used to read the file, groups + * must be created and maintained in the original style. This is HDF5’s default + * behavior. If backward compatibility with pre-1.8.0 libraries is not a concern, + * greater efficiencies can be obtained with the new-format compact and indexed + * groups. See Group + * implementations in HDF5 in the \ref H5G API introduction (at the bottom).\n + * H5Pset_local_heap_size_hint() is useful for tuning file size when files + * contain original-style groups with either zero members or very large + * numbers of members.\n + * The original style of HDF5 groups, the only style available prior to HDF5 + * Release 1.8.0, was well-suited for moderate-sized groups but was not optimized + * for either very small or very large groups. This original style remains the + * default, but two new group implementations were introduced in HDF5 Release 1.8.0: + * compact groups to accommodate zero to small numbers of members and indexed groups + * for thousands or tens of thousands of members ... or millions, if that's what + * your application requires.\n + * The local heap size hint, \p size_hint, is a performance tuning parameter for + * original-style groups. As indicated above, an HDF5 group may have zero, a handful, + * or tens of thousands of members. Since the original style of HDF5 groups stores the + * metadata for all of these group members in a uniform format in a local heap, the size + * of that metadata (and hence, the size of the local heap) can vary wildly from group + * to group. To intelligently allocate space and to avoid unnecessary fragmentation of + * the local heap, it can be valuable to provide the library with a hint as to the local + * heap’s likely eventual size. This can be particularly valuable when it is known that + * a group will eventually have a great many members. It can also be useful in conserving + * space in a file when it is known that certain groups will never have any members. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint); + +/* Map access property list (MAPL) routines */ +#ifdef H5_HAVE_MAP_API +/** + * \ingroup MAPL + * + * \brief Set map iteration hints + * + * \mapl_id + * \param[in] key_prefetch_size Number of keys to prefetch at a time during + * iteration + * \param[in] key_alloc_size The initial size of the buffer allocated to hold + * prefetched keys + * \return \herr_t + * + * \details H5Pset_map_iterate_hints() adjusts the behavior of H5Miterate() when + * prefetching keys for iteration. The \p key_prefetch_size parameter + * specifies the number of keys to prefetch at a time during + * iteration. The \p key_alloc_size parameter specifies the initial + * size of the buffer allocated to hold these prefetched keys. If this + * buffer is too small it will be reallocated to a larger size, though + * this may result in an additional I/O. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pset_map_iterate_hints(hid_t mapl_id, size_t key_prefetch_size, size_t key_alloc_size); +/** + * \ingroup MAPL + * + * \brief Set map iteration hints + * + * \mapl_id + * \param[out] key_prefetch_size Pointer to number of keys to prefetch at a time + * during iteration + * \param[out] key_alloc_size Pointer to the initial size of the buffer allocated + * to hold prefetched keys + * \return \herr_t + * + * \details H5Pget_map_iterate() returns the map iterate hints, \p key_prefetch_size + * and \p key_alloc_size, as set by H5Pset_map_iterate_hints(). + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size /*out*/, + size_t *key_alloc_size /*out*/); +#endif /* H5_HAVE_MAP_API */ /* String creation property list (STRCPL) routines */ -H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); +/** + * \ingroup ALCAPL + * + * \brief Retrieves the character encoding used to create a link or + * attribute name + * + * \param[in] plist_id Link creation or attribute creation property list + * identifier + * \param[out] encoding String encoding character set + * + * \return \herr_t + * + * \details H5Pget_char_encoding() retrieves the character encoding used + * to encode link or attribute names that are created with the + * property list \p plist_id. + * + * Valid values for \p encoding are defined in H5Tpublic.h and + * include the following: + * + * \csets + * + * \note H5Pget_char_encoding() retrieves the character set used for an + * HDF5 link or attribute name while H5Tget_cset() retrieves the + * character set used in a character or string datatype. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/); +/** + * \ingroup ALCAPL + * + * \brief Sets the character encoding used to encode link and attribute + * names + * + * \param[in] plist_id Link creation or attribute creation property list + * identifier + * \param[in] encoding String encoding character set + * + * \return \herr_t + * + * \details H5Pset_char_encoding() sets the character encoding used for + * the names of links (which provide the names by which objects + * are referenced) or attributes created with the property list + * \p plist_id. + * + * Valid values for encoding include the following: + * \csets + * \details For example, if the character set for the property list + * \p plist_id is set to #H5T_CSET_UTF8, link names pointing to + * objects created with the link creation property list + * \p plist_id will be encoded using the UTF-8 character set. + * Similarly, names of attributes created with the attribute + * creation property list \p plist_id will be encoded as UTF-8. + * + * ASCII and UTF-8 Unicode are the only currently supported + * character encodings. Extended ASCII encodings (for example, + * ISO 8859) are not supported. This encoding policy is not + * enforced by the HDF5 library. Using encodings other than + * ASCII and UTF-8 can lead to compatibility and usability + * problems. + * + * \note H5Pset_char_encoding() sets the character set used for an + * HDF5 link or attribute name while H5Tset_cset() sets the + * character set used in a character or string datatype. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); /* Link access property list (LAPL) routines */ -H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); +/** + * \ingroup LAPL + * + * \brief Retrieves the external link traversal file access flag from the + * specified link access property list + * + * \lapl_id + * \param[out] flags File access flag for link traversal + * + * \return \herr_t + * + * \details H5Pget_elink_acc_flags() retrieves the file access flag used + * to open an external link target file from the specified link + * access property list. + * + * Valid values for \p flags include: + * \li #H5F_ACC_RDWR - Files opened through external links will + * be opened with write access + * \li #H5F_ACC_RDONLY - Files opened through external links will + * be opened with read-only access + * \li #H5F_ACC_DEFAULT - Files opened through external links will + * be opened with the same access flag as + * the parent file + * + * The value returned, if it is not #H5F_ACC_DEFAULT, will + * override the default access flag, which is the access flag + * used to open the parent file. + * + * Example Usage: + * The following code retrieves the external link access flag + * settings on the link access property list \p lapl_id into a + * local variable: + *
+ *         unsigned acc_flags;
+ *         status = H5Pget_elink_acc_flags(lapl_id, &acc_flags);
+ *       
+ * + * \since 1.8.3 + * + */ +H5_DLL herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags); +/** + * \ingroup LAPL + * + * \brief Retrieves the external link traversal callback function from the + * specified link access property list + * + * \lapl_id + * \param[out] func User-defined external link traversal callback + * function + * \param[out] op_data User-defined input data for the callback function + * + * \return \herr_t + * + * \details H5Pget_elink_cb() retrieves the user-defined external link + * traversal callback function defined in the specified link + * access property list. + * + * The callback function may adjust the file access property + * list and file access flag to use when opening a file through + * an external link. The callback will be executed by the HDF5 + * library immediately before opening the target file. + * + * Failure Modes: H5Pget_elink_cb() will fail if the link + * access property list identifier, \p lapl_id, is invalid. + * + * An invalid function pointer or data pointer, \p func or + * \p op_data respectively, may cause a segmentation fault or an + * invalid memory access. + * + * Example Usage: The following code retrieves the external + * link callback settings on the link access property list + * \p lapl_id into local variables: + *
+ *       H5L_elink_traverse_t elink_callback_func;
+ *       void *elink_callback_udata;
+ *       status = H5Pget_elink_cb (lapl_id, &elink_callback_func,
+ *                                 &elink_callback_udata);
+ *       
+ * + * \since 1.8.3 + * + */ +H5_DLL herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data); +/** + * \ingroup LAPL + * + * \brief Retrieves the file access property list identifier associated + * with the link access property list + * + * \lapl_id + * + * \return \hid_t{file access property list} + * + * \details H5Pget_elink_fapl() retrieves the file access property list + * identifier that is set for the link access property list + * identifier, \p lapl_id. The library uses this file access + * property list identifier to open the target file for the + * external link access. When no such identifier is set, this + * routine returns #H5P_DEFAULT. + * + * \see H5Pset_elink_fapl() and H5Lcreate_external(). + * + * \since 1.8.0 + * + */ +H5_DLL hid_t H5Pget_elink_fapl(hid_t lapl_id); +/** + * \ingroup LAPL + * + * \brief Retrieves prefix applied to external link paths + * + * \lapl_id{plist_id} + * \param[out] prefix Prefix applied to external link paths + * \param[in] size Size of prefix, including null terminator + * + * \return If successful, returns a non-negative value specifying the size + * in bytes of the prefix without the NULL terminator; otherwise + * returns a negative value. + * + * \details H5Pget_elink_prefix() retrieves the prefix applied to the + * path of any external links traversed. + * + * When an external link is traversed, the prefix is retrieved + * from the link access property list \p plist_id, returned in + * the user-allocated buffer pointed to by \p prefix, and + * prepended to the filename stored in the external link. + * + * The size in bytes of the prefix, including the NULL terminator, + * is specified in \p size. If size is unknown, a preliminary + * H5Pget_elink_prefix() call with the pointer \p prefix set to + * NULL will return the size of the prefix without the NULL + * terminator. + * + * \since 1.8.0 + * + */ +H5_DLL ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size); +/** + * \ingroup LAPL + * + * \brief Retrieves the maximum number of link traversals + * + * \lapl_id{plist_id} + * \param[out] nlinks Maximum number of links to traverse + * + * \return \herr_t + * + * \details H5Pget_nlinks() retrieves the maximum number of soft or + * user-defined link traversals allowed, \p nlinks, before the + * library assumes it has found a cycle and aborts the traversal. + * This value is retrieved from the link access property list + * \p plist_id. + * + * The limit on the number of soft or user-defined link traversals + * is designed to terminate link traversal if one or more links + * form a cycle. User control is provided because some files may + * have legitimate paths formed of large numbers of soft or + * user-defined links. This property can be used to allow + * traversal of as many links as desired. + * + * \since 1.8.0 + * + */ H5_DLL herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks); -H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix); -H5_DLL ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size); -H5_DLL hid_t H5Pget_elink_fapl(hid_t lapl_id); -H5_DLL herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id); +/** + * \ingroup LAPL + * + * \brief Sets the external link traversal file access flag in a link + * access property list + * + * \lapl_id + * \param[in] flags The access flag for external link traversal + * + * \return \herr_t + * + * \details H5Pset_elink_acc_flags() specifies the file access flag to use + * to open the target file of an external link. This allows + * read-only access of files reached through an external link in + * a file opened with write access, or vice-versa. + * + * Valid values for \p flags include: + * \li #H5F_ACC_RDWR - Causes files opened through external links + * to be opened with write access + * \li #H5F_ACC_RDONLY - Causes files opened through external + * links to be opened with read-only access + * \li #H5F_ACC_DEFAULT - Removes any external link file access + * flag setting from \p lapl_id, causing the file access flag + * setting to be taken from the parent file + * + * The library will normally use the file access flag used to + * open the parent file as the file access flag for the target + * file. This function provides a way to override that behavior. + * The external link traversal callback function set by + * H5Pset_elink_cb() can override the setting from + * H5Pset_elink_acc_flags(). + * + * Motivation: H5Pset_elink_acc_flags() is used to adjust the + * file access flag used to open files reached through external links. + * This may be useful to, for example, prevent modifying files + * accessed through an external link. Otherwise, the target file is + * opened with whatever flag was used to open the parent. + * + * Example Usage: The following code sets the link access + * property list \p lapl_id to open external link target files with + * read-only access: + *
+ *         status = H5Pset_elink_acc_flags(lapl_id, H5F_ACC_RDONLY);
+ *        
+ * + * \since 1.8.3 + * + */ H5_DLL herr_t H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags); -H5_DLL herr_t H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags); +/** + * \ingroup LAPL + * + * \brief Sets the external link traversal callback function in a link + * access property list + * + * \lapl_id + * \param[in] func User-defined external link traversal callback + * function + * \param[in] op_data User-defined input data for the callback function + * + * \return \herr_t + * + * \details H5Pset_elink_cb() sets a user-defined external link traversal + * callback function in the link access property list \p lapl_id. + * The callback function \p func must conform to the prototype + * specified in #H5L_elink_traverse_t. + * + * The callback function may adjust the file access property + * list and file access flags to use when opening a file through + * an external link. The callback will be executed by the HDF5 + * library immediately before opening the target file. + * + * The callback will be made after the file access property list + * set by H5Pset_elink_fapl() and the file access flag set by + * H5Pset_elink_acc_flags() are applied, so changes made by this + * callback function will take precedence. + * + * \attention A file close degree property setting (H5Pset_fclose_degree()) + * in this callback function or an associated property list will + * be ignored. A file opened by means of traversing an external + * link is always opened with the weak file close degree + * property setting, #H5F_CLOSE_WEAK. + * + * Motivation: H5Pset_elink_cb() is used to specify a + * callback function that is executed by the HDF5 library when + * traversing an external link. This provides a mechanism to set + * specific access permissions, modify the file access property + * list, modify the parent or target file, or take any other + * user-defined action. This callback function is used in + * situations where the HDF5 library's default behavior is not + * suitable. + * + * Failure Modes: H5Pset_elink_cb() will fail if the link + * access property list identifier, \p lapl_id, is invalid or if + * the function pointer, \p func, is NULL. + * + * An invalid function pointer, \p func, will cause a segmentation + * fault or other failure when an attempt is subsequently made to + * traverse an external link. + * + * Example Usage: + * This example defines a callback function that prints the name + * of the target file every time an external link is followed, and + * sets this callback function on \p lapl_id. + *
+ *          herr_t elink_callback(const char *parent_file_name, const char
+ *                 *parent_group_name, const char *child_file_name, const char
+ *                 *child_object_name, unsigned *acc_flags, hid_t fapl_id, void *op_data) {
+ *              puts(child_file_name);
+ *              return 0;
+ *          }
+ *          int main(void) {
+ *              hid_t lapl_id = H5Pcreate(H5P_LINK_ACCESS);
+ *              H5Pset_elink_cb(lapl_id, elink_callback, NULL);
+ *                ...
+ *          }
+ *          
+ * + * + * \since 1.8.3 + * + */ H5_DLL herr_t H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data); -H5_DLL herr_t H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data); +/** + * \ingroup LAPL + * + * \brief Sets a file access property list for use in accessing a file + * pointed to by an external link + * + * \lapl_id + * \fapl_id + * + * \return \herr_t + * + * \details H5Pset_elink_fapl() sets the file access property list, + * \p fapl_id, to be used when accessing the target file of an + * external link associated with \p lapl_id. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id); +/** + * \ingroup LAPL + * + * \brief Sets prefix to be applied to external link paths + * + * \lapl_id{plist_id} + * \param[in] prefix Prefix to be applied to external link paths + * + * \return \herr_t + * + * \details H5Pset_elink_prefix() sets the prefix to be applied to the + * path of any external links traversed. The prefix is prepended + * to the filename stored in the external link. + * + * The prefix is specified in the user-allocated buffer \p prefix + * and set in the link access property list \p plist_id. The buffer + * should not be freed until the property list has been closed. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix); +/** + * \ingroup LAPL + * + * \brief Sets maximum number of soft or user-defined link traversals + * + * \lapl_id{plist_id} + * \param[in] nlinks Maximum number of links to traverse + * + * \return \herr_t + * + * \details H5Pset_nlinks() sets the maximum number of soft or user-defined + * link traversals allowed, \p nlinks, before the library assumes + * it has found a cycle and aborts the traversal. This value is + * set in the link access property list \p plist_id. + * + * The limit on the number of soft or user-defined link traversals + * is designed to terminate link traversal if one or more links + * form a cycle. User control is provided because some files may + * have legitimate paths formed of large numbers of soft or + * user-defined links. This property can be used to allow + * traversal of as many links as desired. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); /* Object copy property list (OCPYPL) routines */ -H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned crt_intmd); -H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *crt_intmd /*out*/); +/** + * \ingroup OCPPL + * + * \brief Adds a path to the list of paths that will be searched in the + * destination file for a matching committed datatype + * + * \param[in] plist_id Object copy property list identifier + * \param[in] path The path to be added + * + * \return \herr_t + * + * \details H5Padd_merge_committed_dtype_path() adds a path, \p path, + * which points to a committed datatype, to the current list of + * suggested paths stored in the object copy property list + * \p plist_id. The search as described in the next paragraph is + * effective only if the #H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG is + * enabled in the object copy property list via + * H5Pset_copy_object(). + * + * When copying a committed datatype, a dataset with a committed + * datatype, or an object with an attribute of a committed + * datatype, the default behavior of H5Ocopy() is to search for + * a matching committed datatype: + *
    + *
  1. First search the list of suggested paths in the object + * copy property list.
  2. + *
  3. Then, if no match has been found, search all the committed + * datatypes in the destination file. + *
+ * The default Step 2 in this search process can be changed by + * setting a callback function (see H5Pset_mcdt_search_cb()). + * + * Two datatypes are determined equal if their descriptions are + * identical, in a manner similar to H5Tequal(). If either + * committed datatype has one or more attributes, then all + * attributes must be present in both committed datatypes and they + * must be identical. Two attributes are considered identical if + * their datatype description, dataspace, and raw data values are + * the same. However, if an attribute uses a committed datatype, + * that committed datatype’s attributes will not be compared. + * + * If a match is found, H5Ocopy() will perform the following in + * the destination file: + * \li For a committed datatype, the library will create a hard + * link to the found datatype. + * \li For a dataset that uses a committed datatype, the library + * will modify the copied dataset to use the found committed + * datatype as its datatype. + * \li For an object with an attribute of a committed datatype, + * the library will modify the copied object’s attribute to + * use the found committed datatype as its datatype. + * + * If no match is found, H5Ocopy() will perform the following in + * the destination file: + * \li For a committed datatype, the library will copy it as it + * would any other object, creating a named committed + * datatype at the destination. That is, the library will + * create a committed datatype that is accessible in the + * file by a unique path. + * \li For a dataset that uses a committed datatype, the + * library will copy the datatype as an anonymous + * committed datatype and use that as the dataset’s + * datatype. + * \li For an object with an attribute of a committed datatype, + * the library will copy the datatype as an anonymous + * committed datatype and use that as the attribute’s + * datatype. + * + * \b Motivation: H5Padd_merge_committed_dtype_path() provides a + * means to override the default behavior of H5Ocopy() when + * #H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG is set in an object + * copy property list. + * H5Padd_merge_committed_dtype_path() is the mechanism for + * suggesting search paths where H5Ocopy() will look for a + * matching committed datatype. This can be substantially + * faster than the default approach of searching the entire + * destination file for a match. + * + * \b Example \b Usage: This example adds two paths to the object + * copy property list. H5Ocopy() will search the two suggested + * paths for a match before searching all the committed datatypes + * in the destination file. + * + *
+ *     int main(void) {
+ *     hid_t ocpypl_id = H5Pcreate(H5P_OBJECT_COPY);
+ *
+ *        H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG);
+ *        H5Padd_merge_committed_dtype_path(ocpypl_id, "/group/committed_dtypeA");
+ *        H5Padd_merge_committed_dtype_path(ocpypl_id, "/group2/committed_dset");
+ *        H5Ocopy(...ocpypl_id...);
+ *        ...
+ *        ...
+ *     }
+ *     
+ * + * \note H5Padd_merge_committed_dtype_path() will fail if the object + * copy property list is invalid. + * It will also fail if there is insufficient memory when + * duplicating \p path. + * + * \see + * \li H5Ocopy() + * \li #H5O_mcdt_search_cb_t + * \li H5Padd_merge_committed_dtype_path() + * \li H5Pfree_merge_committed_dtype_paths() + * \li H5Pget_mcdt_search_cb() + * \li H5Pset_copy_object() + * \li H5Pset_mcdt_search_cb() + * \li \ref_h5ocopy + * + * \since 1.8.9 + * + */ H5_DLL herr_t H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path); +/** + * \ingroup OCPPL + * + * \brief Clears the list of paths stored in the object copy property list + * + * \param[in] plist_id Object copy property list identifier + * + * \return \herr_t + * + * \details H5Pfree_merge_committed_dtype_paths() clears the suggested + * paths stored in the object copy property list \p plist_id. + * These are the suggested paths previously set with + * H5Padd_merge_committed_dtype_path(). + * + * \b Example \b Usage: This example adds a suggested path to the + * object copy property list, does the copy, clears the list, and + * then adds a new suggested path to the list for another copy. + * + *
+ *       int main(void) {
+ *           hid_t ocpypl_id = H5Pcreate(H5P_OBJECT_COPY);
+ *
+ *           H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG);
+ *           H5Padd_merge_committed_dtype_path(ocpypl_id, "/group/committed_dtypeA");
+ *           H5Ocopy(...ocpypl_id...);
+ *           ...
+ *           ...
+ *           H5Pfree_merge_committed_dtype_paths(ocpypl_id);
+ *           H5Padd_merge_committed_dtype_path(ocpypl_id, "/group2/committed_dtypeB");
+ *           H5Ocopy(...ocpypl_id...);
+ *           ...
+ *           ...
+ *       }
+ *       
+ * + * \note H5Pfree_merge_committed_dtype_paths() will fail if the + * object copy property list is invalid. + * + * \see + * \li H5Ocopy() + * \li #H5O_mcdt_search_cb_t + * \li H5Padd_merge_committed_dtype_path() + * \li H5Pfree_merge_committed_dtype_paths() + * \li H5Pget_mcdt_search_cb() + * \li H5Pset_copy_object() + * \li H5Pset_mcdt_search_cb() + * + * \since 1.8.9 + * + */ H5_DLL herr_t H5Pfree_merge_committed_dtype_paths(hid_t plist_id); -H5_DLL herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, void *op_data); +/** + * \ingroup OCPPL + * + * \brief Retrieves the properties to be used when an object is copied + * + * \param[in] plist_id Object copy property list identifier + * \param[out] copy_options Copy option(s) set in the object copy property + * list + * + * \return \herr_t + * + * \details H5Pget_copy_object() retrieves the properties currently + * specified in the object copy property list \p plist_id, which + * will be invoked when a new copy is made of an existing object. + * + * \p copy_options is a bit map indicating the flags, or + * properties, governing object copying that are set in the + * property list \p plist_id. + * + * The available flags are described in H5Pset_copy_object(). + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *copy_options /*out*/); +/** + * \ingroup OCPPL + * + * \brief Retrieves the callback function from the specified object copy + * property list + * + * \param[in] plist_id Object copy property list identifier + * \param[out] func User-defined callback function + * \param[out] op_data User-defined data for the callback + * function + * + * \return \herr_t + * + * \details H5Pget_mcdt_search_cb() retrieves the user-defined callback + * function and the user data that are set via + * H5Pset_mcdt_search_cb() in the object copy property list + * \p plist_id. + * + * The callback function will be returned in the parameter \p func + * and the user data will be returned in the parameter \p op_data. + * + * \note H5Pget_mcdt_search_cb() will fail if the object copy property + * list is invalid. + * + * \see + * \li H5Ocopy() + * \li #H5O_mcdt_search_cb_t + * \li H5Padd_merge_committed_dtype_path() + * \li H5Pfree_merge_committed_dtype_paths() + * \li H5Pget_mcdt_search_cb() + * \li H5Pset_copy_object() + * \li H5Pset_mcdt_search_cb() + * \li \ref_h5ocopy + * + * \since 1.8.9 + * + */ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, void **op_data); +/** + * \ingroup OCPPL + * + * \brief Sets properties to be used when an object is copied + * + * \param[in] plist_id Object copy property list identifier + * \param[out] copy_options Copy option(s) to be set + * + * \return \herr_t + * + * \details H5Pset_copy_object() sets properties in the object copy + * property list \p plist_id. When an existing object is copied, + * that property list will determine how the new copy is created. + * + * The following flags are available for use in an object copy + * property list: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5O_COPY_SHALLOW_HIERARCHY_FLAGCopy only immediate members of a group
+ * Default behavior, without flag: Recursively + * copy all objects in and below the group.
#H5O_COPY_EXPAND_SOFT_LINK_FLAGExpand soft links into new objects
+ * Default behavior, without flag: Copy soft + * links as they are.
#H5O_COPY_EXPAND_EXT_LINK_FLAGExpand external link into new objects
+ * Default behavior, without flag: Copy external + * links as they are.
#H5O_COPY_EXPAND_REFERENCE_FLAGCopy objects that are pointed to by references and + * update reference values in destination file
+ * Default behavior, without flag: Set reference + * values in destination file to zero (0)
#H5O_COPY_WITHOUT_ATTR_FLAGCopy object without copying attributes
+ * Default behavior, without flag: Copy object + * with all its attributes
#H5O_COPY_MERGE_COMMITTED_DTYPE_FLAGUse a matching committed datatype in the destination + * file when copying a committed datatype, a dataset with + * a committed datatype, or an object with an attribute + * of committed datatype
+ * Default behavior without flag: + * + * \li A committed datatype in the source will be copied to + * the destination as a committed datatype. + * \li If a dataset in the source uses a committed + * datatype or an object in the source has an attribute + * of a committed datatype, that committed datatype will + * be written to the destination as an anonymous + * committed datatype. + * If copied in a single H5Ocopy() operation, objects + * that share a committed datatype in the source will + * share an anonymous committed dataype in the + * destination copy. Subsequent H5Ocopy() operations, + * however, will be unaware of prior anonymous committed + * dataypes and will create new ones. + * + * See the “See Also” section immediately below for + * functions related to the use of this flag.
+ * + * \see + * Functions and a callback function used to tune committed datatype + * copying behavior: + * \li #H5O_mcdt_search_cb_t + * \li H5Padd_merge_committed_dtype_path() + * \li H5Pfree_merge_committed_dtype_paths() + * \li H5Pget_mcdt_search_cb() + * \li H5Pset_copy_object() + * \li H5Pset_mcdt_search_cb() + * \li \ref_h5ocopy + * + * \version 1.8.9 #H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG added in this release. + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned copy_options); +/** + * \ingroup OCPPL + * + * \brief Sets the callback function that H5Ocopy() will invoke before + * searching the entire destination file for a matching committed + * datatype + * + * \param[in] plist_id Object copy property list identifier + * \param[in] func User-defined callback function + * \param[in] op_data User-defined input data for the callback function + * + * \return \herr_t + * + * \details H5Pset_mcdt_search_cb() allows an application to set a + * callback function, \p func, that will be invoked before + * searching the destination file for a matching committed + * datatype. The default, global search process is described in + * H5Padd_merge_committed_dtype_path(). + * + * The callback function must conform to the #H5O_mcdt_search_cb_t + * prototype and will return an instruction for one of the + * following actions: + * + * \li Continue the search for a matching committed datatype in + * the destination file. + * \li Discontinue the search for a matching committed datatype. + * H5Ocopy() will then apply the default behavior of creating + * an anonymous committed datatype. + * \li Abort the copy operation and exit H5Ocopy(). + * + * \b Motivation: H5Pset_mcdt_search_cb() provides the means to + * define a callback function. An application can then use that + * callback to take an additional action before the default search + * of all committed datatypes in the destination file or to take an + * action that replaces the default search. This mechanism is + * intended to improve performance when the global search might + * take a long time. + * + * \b Example \b Usage: This example defines a callback function in + * the object copy property list. + * + *
+ * static H5O_mcdt_search_ret_t
+ * mcdt_search_cb(void *_udata)
+ * {
+ *     H5O_mcdt_search_ret_t action = *((H5O_mcdt_search_ret_t *)_udata);
+ *
+ *      return(action);
+ *  }
+ *
+ *  int main(void) {
+ *      hid_t ocpypl_id = H5Pcreate(H5P_OBJECT_COPY);
+ *
+ *      H5Pset_copy_object(ocpypl_id, H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG);
+ *      H5Padd_merge_committed_dtype_path(ocpypl_id, "/group/committed_dtypeA");
+ *
+ *      action = H5O_MCDT_SEARCH_STOP;
+ *      H5Pset_mcdt_search_cb(ocpypl_id, mcdt_search_cb, &action);
+ *      H5Ocopy(...ocpypl_id...);
+ *      ...
+ *      ...
+ * }
+ * 
+ * + * \note H5Pset_mcdt_search_cb() will fail if the + * object copy property list is invalid. + * + * \warning If the callback function return value causes H5Ocopy() to + * abort, the destination file may be left in an inconsistent or + * corrupted state. + * + * \see + * \li H5Ocopy() + * \li #H5O_mcdt_search_cb_t + * \li H5Padd_merge_committed_dtype_path() + * \li H5Pfree_merge_committed_dtype_paths() + * \li H5Pget_mcdt_search_cb() + * \li H5Pset_copy_object() + * \li H5Pset_mcdt_search_cb() + * \li \ref_h5ocopy + * + * \since 1.8.9 + * + */ +H5_DLL herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, void *op_data); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -517,37 +9262,477 @@ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, /* Macros */ /* We renamed the "root" of the property list class hierarchy */ -#define H5P_NO_CLASS H5P_ROOT - +#define H5P_NO_CLASS H5P_ROOT /* Typedefs */ - +/** + * \ingroup GPLOA + * + * \brief Registers a permanent property with a property list class + * + * \plistcls_id{cls_id} + * \param[in] name Name of property to register + * \param[in] size Size of property in bytes + * \param[in] def_value Default value for property in newly created + * property lists + * \param[in] prp_create Callback routine called when a property list is + * being created and the property value will be + * initialized + * \param[in] prp_set Callback routine called before a new value is + * copied into the property's value + * \param[in] prp_get Callback routine called when a property value is + * retrieved from the property + * \param[in] prp_del Callback routine called when a property is deleted + * from a property list + * \param[in] prp_copy Callback routine called when a property is copied + * from a property list + * \param[in] prp_close Callback routine called when a property list is + * being closed and the property value will be + * disposed of + * + * \return \herr_t + * + * \deprecated As of HDF5-1.8 this function was deprecated in favor of + * H5Pregister2() or the macro H5Pregister(). + * + * \details H5Pregister1() registers a new property with a property list + * class. The property will exist in all property list objects + * of that class after this routine is finished. The name of + * the property must not already exist. The default property + * value must be provided and all new property lists created + * with this property will have the property value set to the + * default provided. Any of the callback routines may be set + * to NULL if they are not needed. + * + * Zero-sized properties are allowed and do not store any data in + * the property list. These may be used as flags to indicate the + * presence or absence of a particular piece of information. The + * default pointer for a zero-sized property may be set to NULL. + * The property \p prp_create and \p prp_close callbacks are called for + * zero-sized properties, but the \p prp_set and \p prp_get callbacks + * are never called. + * + * The \p prp_create routine is called when a new property list with + * this property is being created. The #H5P_prp_create_func_t + * callback function is defined as #H5P_prp_cb1_t. + * + * The \p prp_create routine may modify the value to be set and those + * changes will be stored as the initial value of the property. + * If the \p prp_create routine returns a negative value, the new + * property value is not copied into the property and the + * \p prp_create routine returns an error value. + * + * The \p prp_set routine is called before a new value is copied into + * the property. The #H5P_prp_set_func_t callback function is defined + * as #H5P_prp_cb2_t. + * + * The \p prp_set routine may modify the value pointer to be set and + * those changes will be used when setting the property's value. + * If the \p prp_set routine returns a negative value, the new property + * value is not copied into the property and the \p prp_set routine + * returns an error value. The \p prp_set routine will not be called + * for the initial value; only the \p prp_create routine will be + * called. + * + * \b Note: The \p prp_set callback function may be useful to range + * check the value being set for the property or may perform some + * transformation or translation of the value set. The \p prp_get + * callback would then reverse the transformation or translation. + * A single \p prp_get or \p prp_set callback could handle multiple + * properties by performing different actions based on the property + * name or other properties in the property list. + * + * The \p prp_get routine is called when a value is retrieved from a + * property value. The #H5P_prp_get_func_t callback function is + * defined as #H5P_prp_cb2_t. + * + * The \p prp_get routine may modify the value to be returned from the + * query and those changes will be returned to the calling routine. + * If the \p prp_set routine returns a negative value, the query + * routine returns an error value. + * + * The \p prp_del routine is called when a property is being + * deleted from a property list. The #H5P_prp_delete_func_t + * callback function is defined as #H5P_prp_cb2_t. + * + * The \p prp_del routine may modify the value passed in, but the + * value is not used by the library when the \p prp_del routine + * returns. If the \p prp_del routine returns a negative value, + * the property list deletion routine returns an error value but + * the property is still deleted. + * + * The \p prp_copy routine is called when a new property list with + * this property is being created through a \p prp_copy operation. + * The #H5P_prp_copy_func_t callback function is defined as + * #H5P_prp_cb1_t. + * + * The \p prp_copy routine may modify the value to be set and those + * changes will be stored as the new value of the property. If + * the \p prp_copy routine returns a negative value, the new + * property value is not copied into the property and the \p prp_copy + * routine returns an error value. + * + * The \p prp_close routine is called when a property list with this + * property is being closed. The #H5P_prp_close_func_t callback + * function is defined as #H5P_prp_cb1_t. + * + * The \p prp_close routine may modify the value passed in, but the + * value is not used by the library when the \p prp_close routine + * returns. If the \p prp_close routine returns a negative value, the + * property list close routine returns an error value but the property + * list is still closed. + * + * The #H5P_prp_cb1_t is as follows: + * \snippet this H5P_prp_cb1_t_snip + * + * The #H5P_prp_cb2_t is as follows: + * \snippet this H5P_prp_cb2_t_snip + * + * + * \cpp_c_api_note + * + */ /* Function prototypes */ -H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, - void *def_value, H5P_prp_create_func_t prp_create, - H5P_prp_set_func_t prp_set, 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); -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); -H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]); -H5_DLL herr_t H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, - unsigned int *flags/*out*/, size_t *cd_nelmts/*out*/, - unsigned cd_values[]/*out*/, size_t namelen, char name[]/*out*/); -H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot/*out*/, - unsigned *freelist/*out*/, unsigned *stab/*out*/, - unsigned *shhdr/*out*/); +H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, void *def_value, + H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, + 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 + * + * \brief Registers a temporary property with a property list + * + * \plist_id + * \param[in] name Name of property to create + * \param[in] size Size of property in bytes + * \param[in] value Initial value for the property + * \param[in] prp_set Callback routine called before a new value is copied + * into the property's value + * \param[in] prp_get Callback routine called when a property value is + * retrieved from the property + * \param[in] prp_delete Callback routine called when a property is deleted + * from a property list + * \param[in] prp_copy Callback routine called when a property is copied + * from an existing property list + * \param[in] prp_close Callback routine called when a property list is + * being closed and the property value will be disposed + * of + * + * \return \herr_t + * + * \deprecated As of HDF5-1.8 this function was deprecated in favor of + * H5Pinsert2() or the macro H5Pinsert(). + * + * \details H5Pinsert1() creates a new property in a property + * list. The property will exist only in this property list and + * copies made from it. + * + * The initial property value must be provided in \p value and + * the property value will be set accordingly. + * + * The name of the property must not already exist in this list, + * or this routine will fail. + * + * The \p prp_set and \p prp_get callback routines may be set to NULL + * if they are not needed. + * + * Zero-sized properties are allowed and do not store any data + * in the property list. The default value of a zero-size + * property may be set to NULL. They may be used to indicate the + * presence or absence of a particular piece of information. + * + * The \p prp_set routine is called before a new value is copied + * into the property. The #H5P_prp_set_func_t callback function + * is defined as #H5P_prp_cb2_t. + * The \p prp_set routine may modify the value pointer to be set and + * those changes will be used when setting the property's value. + * If the \p prp_set routine returns a negative value, the new property + * value is not copied into the property and the \p set routine + * returns an error value. The \p prp_set routine will be called for + * the initial value. + * + * \b Note: The \p prp_set callback function may be useful to range + * check the value being set for the property or may perform some + * transformation or translation of the value set. The \p prp_get + * callback would then reverse the transformation or translation. + * A single \p prp_get or \p prp_set callback could handle multiple + * properties by performing different actions based on the + * property name or other properties in the property list. + * + * The \p prp_get routine is called when a value is retrieved from + * a property value. The #H5P_prp_get_func_t callback function + * is defined as #H5P_prp_cb2_t. + * + * The \p prp_get routine may modify the value to be returned from + * the query and those changes will be preserved. If the \p prp_get + * routine returns a negative value, the query routine returns + * an error value. + * + * The \p prp_delete routine is called when a property is being + * deleted from a property list. The #H5P_prp_delete_func_t + * callback function is defined as #H5P_prp_cb2_t. + * + * The \p prp_copy routine is called when a new property list with + * this property is being created through a \p prp_copy operation. + * The #H5P_prp_copy_func_t callback function is defined as + * #H5P_prp_cb1_t. + * + * The \p prp_copy routine may modify the value to be set and those + * changes will be stored as the new value of the property. If the + * \p prp_copy routine returns a negative value, the new property value + * is not copied into the property and the prp_copy routine returns an + * error value. + * + * The \p prp_close routine is called when a property list with this + * property is being closed. + * The #H5P_prp_close_func_t callback function is defined as + * #H5P_prp_cb1_t. + * + * The \p prp_close routine may modify the value passed in, the + * value is not used by the library when the close routine + * returns. If the \p prp_close routine returns a negative value, + * the property list \p prp_close routine returns an error value + * but the property list is still closed. + * + * \b Note: There is no \p prp_create callback routine for temporary + * property list objects; the initial value is assumed to + * have any necessary setup already performed on it. + * + * The #H5P_prp_cb1_t is as follows: + * \snippet this H5P_prp_cb1_t_snip + * + * 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 + * + * \brief Encodes the property values in a property list into a binary + * buffer + * + * \plist_id + * \param[out] buf Buffer into which the property list will be encoded. + * If the provided buffer is NULL, the size of the + * buffer required is returned through \p nalloc; the + * function does nothing more. + * \param[out] nalloc The size of the required buffer + * + * \return \herr_t + * + * \deprecated As of HDF5-1.12 this function has been deprecated in favor of + * H5Pencode2() or the macro H5Pencode(). + * + * \details H5Pencode1() encodes the property list \p plist_id into the + * binary buffer \p buf. + * + * If the required buffer size is unknown, \p buf can be passed + * in as NULL and the function will set the required buffer size + * in \p nalloc. The buffer can then be created and the property + * list encoded with a subsequent H5Pencode1() call. + * + * If the buffer passed in is not big enough to hold the encoded + * properties, the H5Pencode1() call can be expected to fail with + * a segmentation fault. + * + * Properties that do not have encode callbacks will be skipped. + * There is currently no mechanism to register an encode callback for + * a user-defined property, so user-defined properties cannot currently + * be encoded. + * + * Some properties cannot be encoded, particularly properties that are + * reliant on local context. + * + * \since 1.10.0 + * + */ +H5_DLL herr_t H5Pencode1(hid_t plist_id, void *buf, size_t *nalloc); +/** + * \ingroup DCPL + * + * \brief Returns information about a filter in a pipeline (DEPRECATED) + * + * + * + * \plist_id{plist_id} + * \param[in] filter Sequence number within the filter pipeline of + * the filter for which information is sought + * \param[out] flags Bit vector specifying certain general properties + * of the filter + * \param[in,out] cd_nelmts Number of elements in \p cd_values + * \param[out] cd_values Auxiliary data for the filter + * \param[in] namelen Anticipated number of characters in \p name + * \param[out] name Name of the filter + * + * \return Returns the filter identifier if successful; Otherwise returns + * a negative value. See: #H5Z_filter_t + * + * \deprecated When was this function deprecated? + * + * \details H5Pget_filter1() returns information about a filter, specified + * by its filter number, in a filter pipeline, specified by the + * property list with which it is associated. + * + * \p plist_id must be a dataset or group creation property list. + * + * \p filter is a value between zero and N-1, as described in + * H5Pget_nfilters(). The function will return a negative value + * if the filter number is out of range. + * + * The structure of the \p flags argument is discussed in + * H5Pset_filter(). + * + * On input, \p cd_nelmts indicates the number of entries in the + * \p cd_values array, as allocated by the caller; on return, + * \p cd_nelmts contains the number of values defined by the filter. + * + * If \p name is a pointer to an array of at least \p namelen + * bytes, the filter name will be copied into that array. The name + * will be null terminated if \p namelen is large enough. The + * filter name returned will be the name appearing in the file, the + * name registered for the filter, or an empty string. + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \version 1.8.0 N-bit and scale-offset filters added. + * \version 1.8.0 Function H5Pget_filter() renamed to H5Pget_filter1() and + * deprecated in this release. + * \version 1.6.4 \p filter parameter type changed to unsigned. + * + */ +H5_DLL H5Z_filter_t H5Pget_filter1(hid_t plist_id, unsigned filter, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[]); +/** + * \ingroup DCPL + * + * \brief Returns information about the specified filter + * + * \plist_id{plist_id} + * \param[in] id Filter identifier + * \param[out] flags Bit vector specifying certain general properties + * of the filter + * \param[in,out] cd_nelmts Number of elements in \p cd_values + * \param[out] cd_values Auxiliary data for the filter + * \param[in] namelen Anticipated number of characters in \p name + * \param[out] name Name of the filter + * + * + * \return Returns a non-negative value if successful; Otherwise returns + * a negative value. + * + * \deprecated As of HDF5-1.8 this function was deprecated in favor of + * H5Pget_filter_by_id2() or the macro H5Pget_filter_by_id(). + * + * \details H5Pget_filter_by_id1() returns information about a filter, specified + * in \p id, a filter identifier. + * + * \p plist_id must be a dataset or group creation property list and + * \p id must be in the associated filter pipeline. + * + * The \p id and \p flags parameters are used in the same + * manner as described in the discussion of H5Pset_filter(). + * + * Aside from the fact that they are used for output, the parameters + * \p cd_nelmts and \p cd_values[] are used in the same manner as + * described in the discussion of H5Pset_filter(). + * On input, the \p cd_nelmts parameter indicates the number of entries + * in the \p cd_values[] array allocated by the calling program; + * on exit it contains the number of values defined by the filter. + * + * On input, the \p namelen parameter indicates the number of + * characters allocated for the filter name by the calling program + * in the array \p name[]. On exit \p name[] contains the name of the + * filter with one character of the name in each element of the array. + * + * If the filter specified in \p id is not set for the property + * list, an error will be returned and this function will fail. + * + * + * \version 1.8.5 Function extended to work with group creation property + * lists. + * \version 1.8.0 Function H5Pget_filter_by_id() renamed to + * H5Pget_filter_by_id1() and deprecated in this release. + * \version 1.6.0 Function introduced in this release. + */ +H5_DLL herr_t H5Pget_filter_by_id1(hid_t plist_id, H5Z_filter_t id, unsigned int *flags /*out*/, + size_t *cd_nelmts /*out*/, unsigned cd_values[] /*out*/, size_t namelen, + char name[] /*out*/); +/** + * \ingroup FCPL + * + * \brief Retrieves the version information of various objects + * for a file creation property list(deprecated) + * + * \plist_id + * \param[out] boot Pointer to location to return super block version number + * \param[out] freelist Pointer to location to return global freelist version number + * \param[out] stab Pointer to location to return symbol table version number + * \param[out] shhdr Pointer to location to return shared object header version + * number + * + * \return \herr_t + * + * \deprecated Deprecated in favor of the function H5Fget_info() + * + * \details H5Pget_version() retrieves the version information of various objects + * for a file creation property list. Any pointer parameters which are + * passed as NULL are not queried. + * + * \version 1.6.4 \p boot, \p freelist, \p stab, \p shhdr parameter types + * changed to unsigned. + * + */ +H5_DLL herr_t H5Pget_version(hid_t plist_id, unsigned *boot /*out*/, unsigned *freelist /*out*/, + unsigned *stab /*out*/, unsigned *shhdr /*out*/); +/** + * \ingroup FCPL + * + * \brief Sets the file space handling strategy and the free-space section + * size threshold. + * + * \fcpl_id{plist_id} + * \param[in] strategy The file space handling strategy to be used. See: + * #H5F_fspace_strategy_t + * \param[in] threshold The smallest free-space section size that the free + * space manager will track + * + * \return \herr_t + * + * \deprecated When was this function deprecated? + * + * \details Maps to the function H5Pset_file_space_strategy(). + * + */ H5_DLL herr_t H5Pset_file_space(hid_t plist_id, H5F_file_space_type_t strategy, hsize_t threshold); +/** + * \ingroup FCPL + * + * \brief Retrieves the file space handling strategy, and threshold value for + * a file creation property list + * + * \fcpl_id{plist_id} + * \param[out] strategy Pointer to the file space handling strategy + * \param[out] threshold Pointer to the free-space section size threshold value + * + * \return \herr_t + * + * \deprecated When was this function deprecated? + * + * \details Maps to the function H5Pget_file_space_strategy() + * + * + */ H5_DLL herr_t H5Pget_file_space(hid_t plist_id, H5F_file_space_type_t *strategy, hsize_t *threshold); #endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif -#endif /* _H5Ppublic_H */ - +#endif /* H5Ppublic_H */ diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 63718621758..7e5ea461b1f 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,18 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ /* Local Macros */ @@ -45,22 +43,19 @@ /* ======== String creation properties ======== */ /* Definitions for character set encoding property */ -#define H5P_STRCRT_CHAR_ENCODING_SIZE sizeof(H5T_cset_t) -#define H5P_STRCRT_CHAR_ENCODING_DEF H5F_DEFAULT_CSET -#define H5P_STRCRT_CHAR_ENCODING_ENC H5P__strcrt_char_encoding_enc -#define H5P_STRCRT_CHAR_ENCODING_DEC H5P__strcrt_char_encoding_dec - +#define H5P_STRCRT_CHAR_ENCODING_SIZE sizeof(H5T_cset_t) +#define H5P_STRCRT_CHAR_ENCODING_DEF H5F_DEFAULT_CSET +#define H5P_STRCRT_CHAR_ENCODING_ENC H5P__strcrt_char_encoding_enc +#define H5P_STRCRT_CHAR_ENCODING_DEC H5P__strcrt_char_encoding_dec /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -72,45 +67,41 @@ static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass); static herr_t 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); - /*********************/ /* Package Variables */ /*********************/ /* String creation property list class library initialization object */ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ - "string create", /* Class name for debugging */ - H5P_TYPE_STRING_CREATE, /* Class type */ - - &H5P_CLS_ROOT_g, /* Parent class */ - &H5P_CLS_STRING_CREATE_g, /* Pointer to class */ - &H5P_CLS_STRING_CREATE_ID_g, /* Pointer to class ID */ - NULL, /* Pointer to default property list ID */ - H5P__strcrt_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + "string create", /* Class name for debugging */ + H5P_TYPE_STRING_CREATE, /* Class type */ + + &H5P_CLS_ROOT_g, /* Parent class */ + &H5P_CLS_STRING_CREATE_g, /* Pointer to class */ + &H5P_CLS_STRING_CREATE_ID_g, /* Pointer to class ID */ + NULL, /* Pointer to default property list ID */ + H5P__strcrt_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Property value defaults */ -static const H5T_cset_t H5P_def_char_encoding_g = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ +static const H5T_cset_t H5P_def_char_encoding_g = + H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ - - /*------------------------------------------------------------------------- * Function: H5P__strcrt_reg_prop * @@ -125,21 +116,20 @@ static const H5T_cset_t H5P_def_char_encoding_g = H5P_STRCRT_CHAR_ENCODING_DEF; static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register character encoding */ - if(H5P__register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, &H5P_def_char_encoding_g, - NULL, NULL, NULL, H5P_STRCRT_CHAR_ENCODING_ENC, H5P_STRCRT_CHAR_ENCODING_DEC, - NULL, NULL, NULL, NULL) < 0) + if (H5P__register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, + &H5P_def_char_encoding_g, NULL, NULL, NULL, H5P_STRCRT_CHAR_ENCODING_ENC, + H5P_STRCRT_CHAR_ENCODING_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__strcrt_reg_prop() */ - /*------------------------------------------------------------------------- * Function: H5Pset_char_encoding * @@ -154,8 +144,8 @@ H5P__strcrt_reg_prop(H5P_genclass_t *pclass) herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTc", plist_id, encoding); @@ -165,18 +155,17 @@ H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "character encoding is not valid") /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set the character encoding */ - if(H5P_set(plist, H5P_STRCRT_CHAR_ENCODING_NAME, &encoding) < 0) + if (H5P_set(plist, H5P_STRCRT_CHAR_ENCODING_NAME, &encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") done: FUNC_LEAVE_API(ret_value) } /* end H5P_set_char_encoding() */ - /*------------------------------------------------------------------------- * Function: H5Pget_char_encoding * @@ -191,26 +180,25 @@ H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding) herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, encoding); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) + if (NULL == (plist = H5P_object_verify(plist_id, H5P_STRING_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(encoding) - if(H5P_get(plist, H5P_STRCRT_CHAR_ENCODING_NAME, encoding) < 0) + if (encoding) + if (H5P_get(plist, H5P_STRCRT_CHAR_ENCODING_NAME, encoding) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get character encoding flag") done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_char_encoding() */ - /*------------------------------------------------------------------------- * Function: H5P__strcrt_char_encoding_enc * @@ -230,7 +218,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 @@ -238,7 +226,7 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) HDassert(encoding); HDassert(size); - if(NULL != *pp) + if (NULL != *pp) /* Encode character set encoding */ *(*pp)++ = (uint8_t)*encoding; @@ -248,7 +236,6 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__strcrt_char_encoding_enc() */ - /*------------------------------------------------------------------------- * Function: H5P__strcrt_char_encoding_dec * @@ -267,8 +254,8 @@ 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 */ - const uint8_t **pp = (const uint8_t **)_pp; + H5T_cset_t * encoding = (H5T_cset_t *)_value; /* Character set encoding */ + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -278,8 +265,7 @@ H5P__strcrt_char_encoding_dec(const void **_pp, void *_value) HDassert(encoding); /* Decode character set encoding */ - *encoding = (H5T_cset_t)*(*pp)++; + *encoding = (H5T_cset_t) * (*pp)++; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__strcrt_char_encoding_dec() */ - diff --git a/src/H5Ptest.c b/src/H5Ptest.c index 6bec415ee76..f22c30e8b34 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,22 +17,20 @@ * Purpose: Generic Property Testing Functions */ -#include "H5Pmodule.h" /* This source code file is part of the H5P module */ -#define H5P_TESTING /*suppress warning about H5P testing funcs*/ - +#include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5P_TESTING /*suppress warning about H5P testing funcs*/ /* Private header files */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5Dprivate.h" /* Dataset */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5Dprivate.h" /* Dataset */ /* Local variables */ /* Local typedefs */ - /*-------------------------------------------------------------------------- NAME H5P__get_class_path_test @@ -58,24 +56,23 @@ char * H5P__get_class_path_test(hid_t pclass_id) { - H5P_genclass_t *pclass; /* Property class to query */ - char *ret_value = NULL; /* Return value */ + H5P_genclass_t *pclass; /* Property class to query */ + char * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments. */ - if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) + if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class path */ - if(NULL == (ret_value = H5P__get_class_path(pclass))) + if (NULL == (ret_value = H5P__get_class_path(pclass))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query full path of class") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__get_class_path_test() */ +} /* H5P__get_class_path_test() */ - /*-------------------------------------------------------------------------- NAME H5P__open_class_path_test @@ -99,13 +96,13 @@ H5P__get_class_path_test(hid_t pclass_id) hid_t H5P__open_class_path_test(const char *path) { - H5P_genclass_t *pclass = NULL; /* Property class to query */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genclass_t *pclass = NULL; /* Property class to query */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments. */ - if (NULL == path || *path=='\0') + if (NULL == path || *path == '\0') HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid class path"); /* Open the property list class */ @@ -121,5 +118,4 @@ H5P__open_class_path_test(const char *path) H5P__close_class(pclass); FUNC_LEAVE_NOAPI(ret_value) -} /* H5P__open_class_path_test() */ - +} /* H5P__open_class_path_test() */ diff --git a/src/H5R.c b/src/H5R.c index 1c89b22f32e..e08e451e83e 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -6,354 +6,909 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: Reference routines. + */ + /****************/ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ - +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - -/*-------------------------------------------------------------------------- - NAME - H5Rcreate - PURPOSE - Creates a particular kind of reference for the user - USAGE - herr_t H5Rcreate(ref, loc_id, name, ref_type, space_id) - void *ref; OUT: Reference created - hid_t loc_id; IN: Location ID used to locate object pointed to - const char *name; IN: Name of object at location LOC_ID of object - pointed to - H5R_type_t ref_type; IN: Type of reference to create - hid_t space_id; IN: Dataspace ID with selection, used for Dataset - Region references. - - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Creates a particular type of reference specified with REF_TYPE, in the - space pointed to by REF. The LOC_ID and NAME are used to locate the object - pointed to and the SPACE_ID is used to choose the region pointed to (for - Dataset Region references). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5Rcreate_object + * + * Purpose: Creates an object reference. The LOC_ID and NAME are used + * to locate the object pointed to. + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ herr_t -H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) +H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5G_loc_t loc; /* File location */ - H5S_t *space = NULL; /* Pointer to dataspace containing region */ - herr_t ret_value; /* Return value */ + 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_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}; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id); + H5TRACE4("e", "i*si*Rr", loc_id, name, oapl_id, ref_ptr); /* Check args */ - if (ref == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if (ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION) - HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported") - if (space_id == (-1) && ref_type == H5R_DATASET_REGION) + if (oapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get object access property list */ + if (H5P_DEFAULT == oapl_id) + oapl_id = H5P_LINK_ACCESS_DEFAULT; + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object type */ + if ((obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Retrieve VOL file object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = oapl_id; + loc_params.obj_type = obj_type; + + /* Get the object token */ + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") + + /* Create the reference (do not pass filename, since file_id is attached) */ + HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); + if (H5R__create_object((const H5O_token_t *)&obj_token, cont_info.token_size, (H5R_ref_priv_t *)ref_ptr) < + 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") + + /* Attach loc_id to reference and hold reference to it */ + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") + +done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + FUNC_LEAVE_API(ret_value) +} /* end H5Rcreate_object() */ + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_region + * + * Purpose: Creates a region reference. The LOC_ID and NAME are used to + * locate the object pointed to and the SPACE_ID is used to + * choose the region pointed to. + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ +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 */ + 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_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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*sii*Rr", loc_id, name, space_id, oapl_id, ref_ptr); + + /* Check args */ + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if ((space_id == H5I_INVALID_HID) || (space_id == H5S_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if (space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + if (oapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get object access property list */ + if (H5P_DEFAULT == oapl_id) + oapl_id = H5P_LINK_ACCESS_DEFAULT; + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object type */ + if ((obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Retrieve VOL file object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = oapl_id; + loc_params.obj_type = obj_type; + + /* Get the object token */ + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") + + /* Create the reference (do not pass filename, since file_id is attached) */ + HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); + if (H5R__create_region((const H5O_token_t *)&obj_token, cont_info.token_size, space, + (H5R_ref_priv_t *)ref_ptr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") + + /* Attach loc_id to reference and hold reference to it */ + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") + +done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + FUNC_LEAVE_API(ret_value) +} /* end H5Rcreate_region() */ + +/*------------------------------------------------------------------------- + * Function: H5Rcreate_attr + * + * Purpose: Creates an attribute reference. The LOC_ID, NAME and + * ATTR_NAME are used to locate the attribute pointed to. + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ +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 */ + 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_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}; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "i*s*si*Rr", loc_id, name, attr_name, oapl_id, ref_ptr); + + /* Check args */ + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name given") + if (oapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get object access property list */ + if (H5P_DEFAULT == oapl_id) + oapl_id = H5P_LINK_ACCESS_DEFAULT; + else if (TRUE != H5P_isa_class(oapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "oapl_id is not a link access property list ID") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object type */ + if ((obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, obj_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Retrieve VOL file object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = oapl_id; + loc_params.obj_type = obj_type; + + /* Get the object token */ + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") + + /* Create the reference (do not pass filename, since file_id is attached) */ + HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); + if (H5R__create_attr((const H5O_token_t *)&obj_token, cont_info.token_size, attr_name, + (H5R_ref_priv_t *)ref_ptr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create attribute reference") + + /* Attach loc_id to reference and hold reference to it */ + if (H5R__set_loc_id((H5R_ref_priv_t *)ref_ptr, file_id, TRUE, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") + +done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + FUNC_LEAVE_API(ret_value) +} /* end H5Rcreate_attr() */ + +/*------------------------------------------------------------------------- + * Function: H5Rdestroy + * + * Purpose: Destroy reference and free resources allocated during + * H5Rcreate. + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rdestroy(H5R_ref_t *ref_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "*Rr", ref_ptr); + + /* Check args */ + if (NULL == ref_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid reference pointer") + + /* Destroy reference */ + if (H5R__destroy((H5R_ref_priv_t *)ref_ptr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "unable to destroy reference") + + /* Memset back to 0 for safety */ + HDmemset(ref_ptr, 0, H5R_REF_BUF_SIZE); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rdestroy() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_type + * + * Purpose: Given a reference to some object, return the type of that + * reference. + * + * Return: Reference type / H5R_BADTYPE on failure + * + *------------------------------------------------------------------------- + */ +H5R_type_t +H5Rget_type(const H5R_ref_t *ref_ptr) +{ + H5R_type_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5R_BADTYPE) + H5TRACE1("Rt", "*Rr", ref_ptr); + + /* Check args */ + if (NULL == ref_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5R_BADTYPE, "invalid reference pointer") + + /* Get reference type */ + ret_value = H5R__get_type((const H5R_ref_priv_t *)ref_ptr); + if ((ret_value <= H5R_BADTYPE) || (ret_value >= H5R_MAXTYPE)) + HGOTO_ERROR(H5E_REFERENCE, H5E_BADVALUE, H5R_BADTYPE, "invalid reference type") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rget_type() */ + +/*------------------------------------------------------------------------- + * Function: H5Requal + * + * Purpose: Compare two references + * + * Return: TRUE if equal, FALSE if unequal, FAIL if error + * + *------------------------------------------------------------------------- + */ +htri_t +H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("t", "*Rr*Rr", ref1_ptr, ref2_ptr); + + /* Check args */ + if (!ref1_ptr || !ref2_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + + /* Compare references */ + if ((ret_value = H5R__equal((const H5R_ref_priv_t *)ref2_ptr, (const H5R_ref_priv_t *)ref2_ptr)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare references") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Requal() */ + +/*------------------------------------------------------------------------- + * Function: H5Rcopy + * + * Purpose: Copy a reference + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "*Rr*Rr", src_ref_ptr, dst_ref_ptr); - /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Check args */ + if (NULL == src_ref_ptr || NULL == dst_ref_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid reference pointer") - /* Create reference */ - if((ret_value = H5R__create(ref, &loc, name, ref_type, space)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") + /* Copy reference */ + if (H5R__copy((const H5R_ref_priv_t *)src_ref_ptr, (H5R_ref_priv_t *)dst_ref_ptr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "cannot copy reference") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rcreate() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Rdereference2 - PURPOSE - Opens the HDF5 object referenced. - USAGE - hid_t H5Rdereference2(ref) - hid_t id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - hid_t oapl_id; IN: Property list of the object being referenced. - H5R_type_t ref_type; IN: Type of reference to create - void *ref; IN: Reference to open. - - RETURNS - Valid ID on success, H5I_INVALID_HID on failure - DESCRIPTION - Given a reference to some object, open that object and return an ID for - that object. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG - Raymond Lu - 13 July 2011 - I added the OAPL_ID parameter for the object being referenced. It only - supports dataset access property list currently. ---------------------------------------------------------------------------*/ +} /* end H5Rcopy() */ + +/*------------------------------------------------------------------------- + * Function: H5Ropen_object + * + * Purpose: Given a reference to some object, open that object and + * return an ID for that object. + * + * Return: Valid ID on success / H5I_INVALID_HID on failure + * + *------------------------------------------------------------------------- + */ hid_t -H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref) +H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t loc_id; /* Reference location 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 */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref); + H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, oapl_id); /* Check args */ - if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") + if (rapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if (_ref == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + + /* Retrieve loc_id from reference */ + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Attempt to re-open file and pass rapl_id as a fapl_id */ + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") + } + + /* Get object token */ + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") + if (H5CX_set_apl(&oapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = H5I_get_type(loc_id); - /* Create reference */ - if((ret_value = H5R__dereference(file, oapl_id, ref_type, _ref)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object") + /* Open object by token */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") + + /* Register object */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rdereference2() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Rget_region - PURPOSE - Retrieves a dataspace with the region pointed to selected. - USAGE - hid_t H5Rget_region(id, ref_type, ref) - hid_t id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - H5R_type_t ref_type; IN: Type of reference to get region of - void *ref; IN: Reference to open. - - RETURNS - Valid ID on success, H5I_INVALID_HID on failure - DESCRIPTION - Given a reference to some object, creates a copy of the dataset pointed - to's dataspace and defines a selection in the copy which is the region - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +} /* end H5Ropen_object() */ + +/*------------------------------------------------------------------------- + * Function: H5Ropen_region + * + * Purpose: Given a reference to some object, creates a copy of the dataset + * pointed to's dataspace and defines a selection in the copy + * which is the region pointed to. + * + * Return: Valid ID on success / H5I_INVALID_HID on failure + * + *------------------------------------------------------------------------- + */ hid_t -H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) +H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { - H5G_loc_t loc; /* Object's group location */ - H5S_t *space = NULL; /* Dataspace object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t loc_id; /* Reference location 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 */ + hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE3("i", "iRt*x", id, ref_type, ref); + H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, oapl_id); /* Check args */ - if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if (ref_type != H5R_DATASET_REGION) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if (ref == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if ((H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION1) && + (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_DATASET_REGION2)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") + if (rapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + if (oapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + + /* Retrieve loc_id from reference */ + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Attempt to re-open file and pass rapl_id as a fapl_id */ + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") + } + + /* Get object token */ + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Open object by token */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") + + /* Register object */ + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + + /* Get VOL object object */ + if (NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get dataspace from object */ + if (H5VL_dataset_get(opened_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &space_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace from dataset") + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Get the dataspace with the correct region selected */ - if(NULL == (space = H5R__get_region(loc.oloc->file, ref))) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve dataspace") + if (H5R__get_region((const H5R_ref_priv_t *)ref_ptr, space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get selection on dataspace") - /* Atomize */ - if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") + /* Simply return space_id */ + ret_value = space_id; done: + if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") + if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ + if ((space_id != H5I_INVALID_HID) && (H5I_dec_ref(space_id) < 0)) + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace") + FUNC_LEAVE_API(ret_value) -} /* end H5Rget_region() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Rget_obj_type2 - PURPOSE - Retrieves the type of object that an object reference points to - USAGE - herr_t H5Rget_obj_type2(id, ref_type, ref, obj_type) - hid_t id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - H5R_type_t ref_type; IN: Type of reference to query - void *ref; IN: Reference to query. - H5O_type_t *obj_type; OUT: Type of object reference points to - - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Given a reference to some object, this function retrieves the type of - object pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +} /* end H5Ropen_region() */ + +/*------------------------------------------------------------------------- + * Function: H5Ropen_attr + * + * Purpose: Given a reference to some attribute, open that attribute and + * return an ID for that attribute. + * + * Return: Valid ID on success / H5I_INVALID_HID on failure + * + *------------------------------------------------------------------------- + */ +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_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 */ + hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ + void * opened_attr = NULL; /* Opened attribute */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "*Rrii", ref_ptr, rapl_id, aapl_id); + + /* Check args */ + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") + if (rapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + if (aapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + + /* Retrieve loc_id from reference */ + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Attempt to re-open file and pass rapl_id as a fapl_id */ + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "cannot re-open referenced file") + } + + /* Get object token */ + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get object token") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Open object by token */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") + + /* Register object */ + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, vol_obj->connector, FALSE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = opened_type; + + /* Get VOL object object */ + if (NULL == (opened_obj = H5VL_vol_object(opened_obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Open the attribute */ + if (NULL == (opened_attr = H5VL_attr_open(opened_obj, &loc_params, + H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr), aapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", + H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)) + + /* Register the attribute and get an ID for it */ + if ((ret_value = H5VL_register(H5I_ATTR, opened_attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + +done: + if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") + if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ + if (opened_attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + + FUNC_LEAVE_API(ret_value) +} /* end H5Ropen_attr() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_obj_type3 + * + * Purpose: Given a reference to some object, this function returns the + * type of object pointed to. + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ herr_t -H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, - H5O_type_t *obj_type) +H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) { - H5G_loc_t loc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t loc_id; /* Reference location 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 */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); + H5TRACE3("e", "*Rri*Ot", ref_ptr, rapl_id, obj_type); /* Check args */ - if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if (ref == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - - /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + if (rapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Retrieve loc_id from reference */ + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Attempt to re-open file and pass rapl_id as a fapl_id */ + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, FAIL, "cannot re-open referenced file") + } + + /* Get object token */ + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object token") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Retrieve object's type */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_obj_type2() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Rget_name - PURPOSE - Determines a name for the object referenced - USAGE - ssize_t H5Rget_name(loc_id, ref_type, ref, name, size) - hid_t loc_id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - H5R_type_t ref_type; IN: Type of reference - void *ref; IN: Reference to query. - char *name; OUT: Buffer to place name of object referenced. If NULL - then this call will return the size in bytes of name. - size_t size; IN: Size of name buffer (user needs to include NULL terminator - when passing in the size) - - RETURNS - Non-negative length of the path on success, -1 on failure - DESCRIPTION - Given a reference to some object, determine a path to the object - referenced in the file. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This may not be the only path to that object. - EXAMPLES - REVISION LOG - M. Scot Breitenfeld - 22 January 2014 - Changed the behavior for the returned value of the function when name is NULL. - If name is NULL then size is ignored and the function returns the size - of the name buffer (not including the NULL terminator), it still returns - negative on failure. ---------------------------------------------------------------------------*/ +} /* end H5Rget_obj_type3() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_file_name + * + * Purpose: Given a reference to some object, determine a file name of the + * object located into. + * + * Return: Non-negative length of the path on success / -1 on failure + * + *------------------------------------------------------------------------- + */ ssize_t -H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, - size_t size) +H5Rget_file_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) { - H5G_loc_t loc; /* Group location */ - H5F_t *file; /* File object */ - ssize_t ret_value; /* Return value */ + hid_t loc_id; /* Reference location ID */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) - H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); + H5TRACE3("Zs", "*Rr*sz", ref_ptr, buf, size); /* Check args */ - if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") - if (_ref == NULL) + if (ref_ptr == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - - /* Get the file pointer from the entry */ - file = loc.oloc->file; + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") /* Get name */ - if((ret_value = H5R__get_name(file, id, ref_type, _ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine object path") + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Un-opened external references do not have loc_id set but hold a + * copy of the filename */ + if ((ret_value = H5R__get_file_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to retrieve file name") + } + else { + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ + + /* Retrieve VOL file object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5I_FILE, + size, buf, &ret_value) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get file name") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rget_file_name() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_obj_name + * + * Purpose: Given a reference to some object, determine a path to the + * object referenced in the file. + * + * Return: Non-negative length of the path on success / -1 on failure + * + *------------------------------------------------------------------------- + */ +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_loc_params_t loc_params; /* Location parameters */ + H5O_token_t obj_token = {0}; /* Object token */ + ssize_t ret_value = 0; /* Return value */ + + FUNC_ENTER_API((-1)) + H5TRACE4("Zs", "*Rri*sz", ref_ptr, rapl_id, buf, size); + + /* Check args */ + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) <= H5R_BADTYPE || + H5R__get_type((const H5R_ref_priv_t *)ref_ptr) >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") + if (rapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a property list") + + /* Retrieve loc_id from reference */ + if (H5I_INVALID_HID == (loc_id = H5R__get_loc_id((const H5R_ref_priv_t *)ref_ptr))) { + /* Attempt to re-open file and pass rapl_id as a fapl_id */ + if ((loc_id = H5R__reopen_file((H5R_ref_priv_t *)ref_ptr, rapl_id)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, (-1), "cannot re-open referenced file") + } + + /* Get object token */ + if (H5R__get_obj_token((const H5R_ref_priv_t *)ref_ptr, &obj_token, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to get object token") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Retrieve object's name */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, buf, size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_name() */ +} /* end H5Rget_obj_name() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_attr_name + * + * Purpose: Given a reference to some attribute, determine its name. + * + * Return: Non-negative length of the path on success / -1 on failure + * + *------------------------------------------------------------------------- + */ +ssize_t +H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *buf, size_t size) +{ + ssize_t ret_value; /* Return value */ + FUNC_ENTER_API((-1)) + H5TRACE3("Zs", "*Rr*sz", ref_ptr, buf, size); + + /* Check args */ + if (ref_ptr == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") + if (H5R__get_type((const H5R_ref_priv_t *)ref_ptr) != H5R_ATTR) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") + + /* Get attribute name */ + if ((ret_value = H5R__get_attr_name((const H5R_ref_priv_t *)ref_ptr, buf, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine attribute name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rget_attr_name() */ diff --git a/src/H5RS.c b/src/H5RS.c index ae500c5deaf..141ea2e4958 100644 --- a/src/H5RS.c +++ b/src/H5RS.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,32 +18,61 @@ * */ +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5RSprivate.h" /* Reference-counted strings */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5RSprivate.h" /* Reference-counted strings */ +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ /* Private typedefs & structs */ struct H5RS_str_t { - 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 */ + 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 */ }; +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + /* Declare a free list to manage the H5RS_str_t struct */ H5FL_DEFINE_STATIC(H5RS_str_t); /* Declare the PQ free list for the wrapped strings */ H5FL_BLK_DEFINE(str_buf); - /*-------------------------------------------------------------------------- NAME - H5RS_xstrdup + H5RS__xstrdup PURPOSE Duplicate the string being reference counted USAGE - char *H5RS_xstrdup(s) + char *H5RS__xstrdup(s) const char *s; IN: String to duplicate RETURNS @@ -57,13 +86,13 @@ H5FL_BLK_DEFINE(str_buf); REVISION LOG --------------------------------------------------------------------------*/ static char * -H5RS_xstrdup(const char *s) +H5RS__xstrdup(const char *s) { - char *ret_value; /* Return value */ + char *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - if(s) { + if (s) { size_t len = HDstrlen(s) + 1; ret_value = (char *)H5FL_BLK_MALLOC(str_buf, len); @@ -74,9 +103,8 @@ H5RS_xstrdup(const char *s) ret_value = NULL; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5RS_xstrdup() */ +} /* end H5RS__xstrdup() */ - /*-------------------------------------------------------------------------- NAME H5RS_create @@ -99,24 +127,23 @@ H5RS_xstrdup(const char *s) H5RS_str_t * H5RS_create(const char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->s = H5RS_xstrdup(s); + ret_value->s = H5RS__xstrdup(s); ret_value->wrapped = 0; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_create() */ - /*-------------------------------------------------------------------------- NAME H5RS_wrap @@ -139,24 +166,23 @@ H5RS_create(const char *s) H5RS_str_t * H5RS_wrap(const char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) - HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") + 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; + ret_value->s = (char *)s; ret_value->wrapped = 1; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_wrap() */ - /*-------------------------------------------------------------------------- NAME H5RS_own @@ -181,24 +207,23 @@ H5RS_wrap(const char *s) H5RS_str_t * H5RS_own(char *s) { - H5RS_str_t *ret_value; /* Return value */ + H5RS_str_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->s = s; + ret_value->s = s; ret_value->wrapped = 0; - ret_value->n = 1; + ret_value->n = 1; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_own() */ - /*-------------------------------------------------------------------------- NAME H5RS_decr @@ -228,8 +253,8 @@ H5RS_decr(H5RS_str_t *rs) HDassert(rs->n > 0); /* Decrement reference count for string */ - if((--rs->n) == 0) { - if(!rs->wrapped) + if ((--rs->n) == 0) { + if (!rs->wrapped) rs->s = (char *)H5FL_BLK_FREE(str_buf, rs->s); rs = H5FL_FREE(H5RS_str_t, rs); } /* end if */ @@ -237,7 +262,6 @@ H5RS_decr(H5RS_str_t *rs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5RS_decr() */ - /*-------------------------------------------------------------------------- NAME H5RS_incr @@ -269,8 +293,8 @@ H5RS_incr(H5RS_str_t *rs) * string, duplicate the string now, so that the wrapped string can go out * scope appropriately. */ - if(rs->wrapped) { - rs->s = H5RS_xstrdup(rs->s); + if (rs->wrapped) { + rs->s = H5RS__xstrdup(rs->s); rs->wrapped = 0; } /* end if */ @@ -280,7 +304,6 @@ H5RS_incr(H5RS_str_t *rs) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5RS_incr() */ - /*-------------------------------------------------------------------------- NAME H5RS_dup @@ -306,14 +329,13 @@ H5RS_dup(H5RS_str_t *ret_value) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check for valid reference counted string */ - if(ret_value != NULL) + if (ret_value != NULL) /* Increment reference count for string */ ret_value->n++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_dup() */ - /*-------------------------------------------------------------------------- NAME H5RS_dup_str @@ -335,8 +357,8 @@ H5RS_dup(H5RS_str_t *ret_value) H5RS_str_t * H5RS_dup_str(const char *s) { - char *new_str; /* Duplicate of string */ - size_t path_len; /* Length of the path */ + char * new_str; /* Duplicate of string */ + size_t path_len; /* Length of the path */ H5RS_str_t *ret_value; FUNC_ENTER_NOAPI(NULL) @@ -348,7 +370,7 @@ H5RS_dup_str(const char *s) path_len = HDstrlen(s); /* Allocate space for the string */ - if(NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) + if (NULL == (new_str = (char *)H5FL_BLK_MALLOC(str_buf, path_len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy name for full path */ @@ -361,7 +383,6 @@ H5RS_dup_str(const char *s) FUNC_LEAVE_NOAPI(ret_value) } /* end H5RS_dup_str() */ - /*-------------------------------------------------------------------------- NAME H5RS_cmp @@ -398,7 +419,6 @@ H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2) FUNC_LEAVE_NOAPI(HDstrcmp(rs1->s, rs2->s)) } /* end H5RS_cmp() */ - /*-------------------------------------------------------------------------- NAME H5RS_len @@ -429,7 +449,6 @@ H5RS_len(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(rs->s)) } /* end H5RS_len() */ - /*-------------------------------------------------------------------------- NAME H5RS_get_str @@ -463,7 +482,6 @@ H5RS_get_str(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI(rs->s) } /* end H5RS_get_str() */ - /*-------------------------------------------------------------------------- NAME H5RS_get_count @@ -494,4 +512,3 @@ H5RS_get_count(const H5RS_str_t *rs) FUNC_LEAVE_NOAPI(rs->n) } /* end H5RS_get_count() */ - diff --git a/src/H5RSprivate.h b/src/H5RSprivate.h index 1d26a18e8fc..32e1dc66c23 100644 --- a/src/H5RSprivate.h +++ b/src/H5RSprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains private information about the H5RS module */ -#ifndef _H5RSprivate_H -#define _H5RSprivate_H +#ifndef H5RSprivate_H +#define H5RSprivate_H /**************************************/ /* Public headers needed by this file */ @@ -46,14 +46,13 @@ typedef struct H5RS_str_t H5RS_str_t; H5_DLL H5RS_str_t *H5RS_create(const char *s); H5_DLL H5RS_str_t *H5RS_wrap(const char *s); H5_DLL H5RS_str_t *H5RS_own(char *s); -H5_DLL herr_t H5RS_decr(H5RS_str_t *rs); -H5_DLL herr_t H5RS_incr(H5RS_str_t *rs); +H5_DLL herr_t H5RS_decr(H5RS_str_t *rs); +H5_DLL herr_t H5RS_incr(H5RS_str_t *rs); 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 unsigned H5RS_get_count(const H5RS_str_t *rs); - -#endif /* _H5RSprivate_H */ +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 unsigned H5RS_get_count(const H5RS_str_t *rs); +#endif /* H5RSprivate_H */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index fb62430f1f4..f78460d54f0 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,74 +27,212 @@ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ - +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ /* Public headers needed by this file */ -#include "H5Ppublic.h" /* Property lists */ +#include "H5Ppublic.h" /* Property lists */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - +static herr_t H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, + H5S_t *space, unsigned char *buf, size_t *nalloc); +static herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, + const unsigned char *buf, H5O_token_t *obj_token); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/*------------------------------------------------------------------------- + * Function: H5R__decode_token_compat + * + * Purpose: Decode an object token. (native only) + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type, + 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_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(vol_obj, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Retrieve VOL object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") + + if (ref_type == H5R_OBJECT1) { + size_t buf_size = H5R_OBJ_REF_BUF_SIZE; + + /* Get object address */ + if (H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token") + } /* end if */ + else { + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; + H5F_t *f = NULL; + + /* Retrieve file from VOL object */ + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Get object address */ + if (H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") + } /* end else */ + +done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_token_compat() */ + +/*------------------------------------------------------------------------- + * Function: H5R__encode_token_region_compat + * + * Purpose: Encode dataset selection and insert data into heap + * (native only). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space, + unsigned char *buf, size_t *nalloc) +{ + size_t buf_size; + unsigned char *data = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(f); + HDassert(obj_token); + HDassert(token_size); + HDassert(space); + HDassert(nalloc); + + /* Get required buffer size */ + if (H5R__encode_heap(f, NULL, &buf_size, NULL, (size_t)0) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + if (buf && *nalloc >= buf_size) { + ssize_t data_size; + uint8_t *p; + + /* Pass the correct encoding version for the selection depending on the + * file libver bounds, this is later retrieved in H5S hyper encode */ + H5CX_set_libver_bounds(f); + + /* Zero the heap ID out, may leak heap space if user is re-using + * reference and doesn't have garbage collection turned on + */ + HDmemset(buf, 0, buf_size); + + /* Get the amount of space required to serialize the selection */ + if ((data_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, + "Invalid amount of space for serializing selection") + + /* Increase buffer size to allow for the dataset token */ + data_size += (hssize_t)token_size; + + /* Allocate the space to store the serialized information */ + H5_CHECK_OVERFLOW(data_size, hssize_t, size_t); + if (NULL == (data = (uint8_t *)H5MM_malloc((size_t)data_size))) + HGOTO_ERROR(H5E_REFERENCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Serialize information for dataset OID into heap buffer */ + p = (uint8_t *)data; + H5MM_memcpy(p, obj_token, token_size); + p += token_size; + + /* Serialize the selection into heap buffer */ + if (H5S_SELECT_SERIALIZE(space, &p) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") + + /* Write to heap */ + if (H5R__encode_heap(f, buf, nalloc, data, (size_t)data_size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + *nalloc = buf_size; + +done: + H5MM_free(data); + FUNC_LEAVE_NOAPI(ret_value) +} /* H5R__encode_token_region_compat() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - /*------------------------------------------------------------------------- * Function: H5Rget_obj_type1 * - * Purpose: Retrieves the type of the object that an object points to. - * - * Parameters: - * id IN: Dataset reference object is in or location ID of - * object that the dataset is located within - * ref_type IN: Type of reference to query - * ref IN: Reference to query + * Purpose: Retrieves the type of the object that a reference points to. * - * Return: Success: An object type (as defined in H5Gpublic.h) + * Return: Success: Object type (as defined in H5Gpublic.h) * Failure: H5G_UNKNOWN * *------------------------------------------------------------------------- @@ -102,77 +240,499 @@ H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object location */ - H5O_type_t obj_type; /* Object type */ - H5G_obj_t ret_value; /* Return value */ + 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 */ + H5O_type_t obj_type; /* Object type */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE3("Go", "iRt*x", id, ref_type, ref); /* Check args */ - if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") - if (ref == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") + + /* Get object token */ + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5G_UNKNOWN, "unable to get object token") - /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, &obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Retrieve object's type */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "can't retrieve object type") /* Set return value */ ret_value = H5G_map_obj_type(obj_type); done: FUNC_LEAVE_API(ret_value) -} /* end H5Rget_obj_type1() */ +} /* end H5Rget_obj_type1() */ - /*------------------------------------------------------------------------- * Function: H5Rdereference1 * - * Purpose: Opens the HDF5 object referenced. + * Purpose: Given a reference to some object, open that object and return + * an ID for that object. + * + * Return: Success: Valid ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "iRt*x", obj_id, ref_type, ref); + + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(obj_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object token */ + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Dereference */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") + + /* Register object */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rdereference1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/*------------------------------------------------------------------------- + * Function: H5Rcreate + * + * Purpose: Creates a particular type of reference specified with REF_TYPE, + * in the space pointed to by REF. The LOC_ID and NAME are used to + * locate the object pointed to and the SPACE_ID is used to choose + * the region pointed to (for Dataset Region references). + * + * Return: Non-negative on success / negative on failure + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id); + + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(vol_obj, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = vol_obj_type; + + /* Get the object token */ + if (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token") + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Retrieve VOL object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info") + + /* Create reference */ + if (ref_type == H5R_OBJECT1) { + size_t buf_size = H5R_OBJ_REF_BUF_SIZE; + + if ((ret_value = H5R__encode_token_obj_compat((const H5O_token_t *)&obj_token, cont_info.token_size, + buf, &buf_size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode object reference") + } /* end if */ + else { + H5F_t *f = NULL; + H5S_t *space = NULL; /* Pointer to dataspace containing region */ + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; + + /* Retrieve space */ + if (space_id == H5I_INVALID_HID) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") + if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Retrieve file from VOL object */ + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Encode dataset region */ + if ((ret_value = H5R__encode_token_region_compat(f, (const H5O_token_t *)&obj_token, + cont_info.token_size, space, buf, &buf_size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode region reference") + } /* end else */ + +done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + FUNC_LEAVE_API(ret_value) +} /* end H5Rcreate() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_obj_type2 + * + * Purpose: Given a reference to some object, this function returns the + * type of object pointed to. + * + * Return: Non-negative on success / negative on failure * - * Parameters: - * id IN: Dataset reference object is in or location ID of - * object that the dataset is located within - * ref_type IN: Type of reference to create - * ref IN: Reference to open + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); + + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object token */ + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Retrieve object's type */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve object type") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rget_obj_type2() */ + +/*------------------------------------------------------------------------- + * Function: H5Rdereference2 * - * Return: Success: Valid HDF5 ID + * Purpose: Given a reference to some object, open that object and return + * an ID for that object. + * + * Return: Success: Valid ID * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) +H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref); + H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, ref); /* Check args */ - if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (oapl_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - if (_ref == NULL) + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(obj_id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get object token */ + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Open object by token */ + if (NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token") + + /* Register object */ + if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rdereference2() */ + +/*------------------------------------------------------------------------- + * Function: H5Rget_region + * + * Purpose: Given a reference to some object, creates a copy of the dataset + * pointed to's dataspace and defines a selection in the copy + * which is the region pointed to. + * + * Return: Success: Valid ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + 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 */ + size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ + 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 */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "iRt*x", id, ref_type, ref); + + /* Check args */ + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + if (ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") - /* Create reference */ - if((ret_value = H5R__dereference(file, H5P_DATASET_ACCESS_DEFAULT, ref_type, _ref)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, "unable dereference object") +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(vol_obj, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, + "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get the file for the object */ + if ((file_id = H5F_get_file_id(vol_obj, vol_obj_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object") + + /* Retrieve VOL object */ + if (NULL == (vol_obj_file = H5VL_vol_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get container info */ + if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, &cont_info) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get container info") + + /* Retrieve file from VOL object */ + if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object") + + /* Get the dataspace with the correct region selected */ + if (H5R__decode_token_region_compat(f, buf, &buf_size, NULL, cont_info.token_size, &space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") + + /* Atomize */ + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: + if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") FUNC_LEAVE_API(ret_value) -} /* end H5Rdereference1() */ +} /* end H5Rget_region1() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +/*------------------------------------------------------------------------- + * Function: H5Rget_name + * + * Purpose: Given a reference to some object, determine a path to the + * object referenced in the file. + * + * Return: Success: Non-negative length of the path + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ + ssize_t ret_value = -1; /* Return value */ + + FUNC_ENTER_API((-1)) + H5TRACE5("Zs", "iRt*x*sz", id, ref_type, ref, name, size); + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") + if (ref_type != H5R_OBJECT1 && ref_type != H5R_DATASET_REGION1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(id)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Get object token */ + if (H5R__decode_token_compat(vol_obj, vol_obj_type, ref_type, buf, &obj_token) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, (-1), "unable to get object token") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_TOKEN; + loc_params.loc_data.loc_by_token.token = &obj_token; + loc_params.obj_type = vol_obj_type; + + /* Retrieve object's name */ + if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, name, size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve object name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Rget_name() */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 40567169ce1..cb56a847674 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,31 +15,111 @@ /* Module Setup */ /****************/ -#include "H5Rmodule.h" /* This source code file is part of the H5R module */ - +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ /****************/ +#define H5R_MAX_STRING_LEN (1 << 16) /* Max encoded string length */ + +/* Encode macro */ +#define H5R_ENCODE(func, val, buf, buf_size, actual, m) \ + do { \ + size_t __nalloc = buf_size; \ + if (func(val, buf, &__nalloc) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ + if (buf && buf_size >= __nalloc) { \ + buf += __nalloc; \ + buf_size -= __nalloc; \ + } \ + actual += __nalloc; \ + } while (0) + +#define H5R_ENCODE_VAR(func, var, size, buf, buf_size, actual, m) \ + do { \ + size_t __nalloc = buf_size; \ + if (func(var, size, buf, &__nalloc) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, m) \ + if (buf && buf_size >= __nalloc) { \ + p += __nalloc; \ + buf_size -= __nalloc; \ + } \ + actual += __nalloc; \ + } while (0) + +/* Decode macro */ +#define H5R_DECODE(func, val, buf, buf_size, actual, m) \ + do { \ + size_t __nbytes = buf_size; \ + if (func(buf, &__nbytes, val) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ + buf += __nbytes; \ + buf_size -= __nbytes; \ + actual += __nbytes; \ + } while (0) + +#define H5R_DECODE_VAR(func, var, size, buf, buf_size, actual, m) \ + do { \ + size_t __nbytes = buf_size; \ + if (func(buf, &__nbytes, var, size) < 0) \ + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, m) \ + p += __nbytes; \ + buf_size -= __nbytes; \ + actual += __nbytes; \ + } while (0) + +/* Debug */ +#ifdef H5R_DEBUG +#define H5R_LOG_DEBUG(...) \ + do { \ + HDfprintf(stdout, " # %s(): ", __func__); \ + HDfprintf(stdout, __VA_ARGS__); \ + HDfprintf(stdout, "\n"); \ + HDfflush(stdout); \ + } while (0) +static const char * +H5R__print_token(const H5O_token_t token) +{ + static char string[64]; + + /* Print the raw token. */ + HDsnprintf(string, 64, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + (unsigned char)token.__data[15], (unsigned char)token.__data[14], + (unsigned char)token.__data[13], (unsigned char)token.__data[12], + (unsigned char)token.__data[11], (unsigned char)token.__data[10], + (unsigned char)token.__data[9], (unsigned char)token.__data[8], (unsigned char)token.__data[7], + (unsigned char)token.__data[6], (unsigned char)token.__data[5], (unsigned char)token.__data[4], + (unsigned char)token.__data[3], (unsigned char)token.__data[2], (unsigned char)token.__data[1], + (unsigned char)token.__data[0]); + + return string; +} +#else +#define H5R_LOG_DEBUG(...) \ + do { \ + } while (0) +#endif + /******************/ /* Local Typedefs */ /******************/ @@ -48,6 +128,15 @@ /* Local Prototypes */ /********************/ +static herr_t H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, + size_t *nalloc); +static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + uint8_t *token_size); +static herr_t H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc); +static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr); +static herr_t H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc); +static herr_t H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr); + /*********************/ /* Package Variables */ /*********************/ @@ -63,22 +152,9 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Reference ID class - * - * NOTE: H5I_REFERENCE is not used by the library and has been deprecated - * with a tentative removal version of 1.12.0. (DER, July 2017) - */ -static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ - H5I_REFERENCE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - NULL /* Callback routine for closing objects of this class */ -}}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5R_top_package_initialize_s = FALSE; - /*-------------------------------------------------------------------------- NAME H5R__init_package -- Initialize interface-specific information @@ -94,21 +170,16 @@ DESCRIPTION herr_t H5R__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Initialize the atom group for the file IDs */ - if (H5I_register_type(H5I_REFERENCE_CLS) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") + FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Mark "top" of interface as initialized, too */ + /* Mark "top" of interface as initialized */ H5R_top_package_initialize_s = TRUE; -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__init_package() */ + /* Sanity check, if assert fails, H5R_REF_BUF_SIZE must be increased */ + HDcompile_assert(sizeof(H5R_ref_priv_t) <= H5R_REF_BUF_SIZE); + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5R__init_package() */ /*-------------------------------------------------------------------------- NAME @@ -131,25 +202,18 @@ H5R__init_package(void) int H5R_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5R_top_package_initialize_s) { - if (H5I_nmembers(H5I_REFERENCE) > 0) { - (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); - n++; - } - - /* Mark closed */ + /* Mark closed if initialized */ + if (H5R_top_package_initialize_s) if (0 == n) H5R_top_package_initialize_s = FALSE; - } FUNC_LEAVE_NOAPI(n) } /* end H5R_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5R_term_package @@ -173,18 +237,14 @@ H5R_top_term_package(void) int H5R_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR if (H5_PKG_INIT_VAR) { /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_REFERENCE)); HDassert(FALSE == H5R_top_package_initialize_s); - /* Destroy the reference id group */ - n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); - /* Mark closed */ if (0 == n) H5_PKG_INIT_VAR = FALSE; @@ -193,588 +253,1352 @@ H5R_term_package(void) FUNC_LEAVE_NOAPI(n) } /* end H5R_term_package() */ +/*------------------------------------------------------------------------- + * Function: H5R__create_object + * + * Purpose: Creates an object reference + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref) +{ + size_t encode_size; + herr_t ret_value = SUCCEED; /* Return value */ -/*-------------------------------------------------------------------------- - NAME - H5R__create - PURPOSE - Creates a particular kind of reference for the user - USAGE - herr_t H5R__create(ref, loc, name, ref_type, space) - void *ref; OUT: Reference created - H5G_loc_t *loc; IN: File location used to locate object pointed to - const char *name; IN: Name of object at location LOC_ID of object - pointed to - H5R_type_t ref_type; IN: Type of reference to create - H5S_t *space; IN: Dataspace ID with selection, used for Dataset - Region references. + FUNC_ENTER_PACKAGE - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Creates a particular type of reference specified with REF_TYPE, in the - space pointed to by REF. The LOC_ID and NAME are used to locate the object - pointed to and the SPACE_ID is used to choose the region pointed to (for - Dataset Region references). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ + HDassert(ref); + + /* Create new reference */ + ref->info.obj.filename = NULL; + ref->loc_id = H5I_INVALID_HID; + ref->type = (uint8_t)H5R_OBJECT2; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") + + /* Cache encoding size (assume no external reference) */ + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") + ref->encode_size = (uint32_t)encode_size; + + H5R_LOG_DEBUG("Created object reference, %d, filename=%s, obj_addr=%s, encode size=%u", + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->encode_size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__create_object() */ + +/*------------------------------------------------------------------------- + * Function: H5R__create_region + * + * Purpose: Creates a region reference + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t -H5R__create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, - H5S_t *space) +H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, H5R_ref_priv_t *ref) { - H5G_loc_t obj_loc; /* Group hier. location of object */ - H5G_name_t path; /* Object group hier. path */ - H5O_loc_t oloc; /* Object object location */ - hbool_t obj_found = FALSE; /* Object location found */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t encode_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - HDassert(_ref); - HDassert(loc); - HDassert(name); - HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); + HDassert(space); + HDassert(ref); - /* Set up object location to fill in */ - obj_loc.oloc = &oloc; - obj_loc.path = &path; - H5G_loc_reset(&obj_loc); + /* Create new reference */ + ref->info.obj.filename = NULL; + if (NULL == (ref->info.reg.space = H5S_copy(space, FALSE, TRUE))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") - /* Set the FAPL for the API context */ - H5CX_set_libver_bounds(loc->oloc->file); + ref->loc_id = H5I_INVALID_HID; + ref->type = (uint8_t)H5R_DATASET_REGION2; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") - /* Find the object */ - if(H5G_loc_find(loc, name, &obj_loc) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found") - obj_found = TRUE; + /* Cache encoding size (assume no external reference) */ + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") + ref->encode_size = (uint32_t)encode_size; - switch (ref_type) { - case H5R_OBJECT: - { - hobj_ref_t *ref = (hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */ + H5R_LOG_DEBUG("Created region reference, %d, filename=%s, obj_addr=%s, encode size=%u", + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->encode_size); + +done: + if (ret_value < 0) + if (ref->info.reg.space) { + H5S_close(ref->info.reg.space); + ref->info.reg.space = NULL; + } /* end if */ - *ref = obj_loc.oloc->addr; + FUNC_LEAVE_NOAPI(ret_value) +} /* H5R__create_region */ + +/*------------------------------------------------------------------------- + * Function: H5R__create_attr + * + * Purpose: Creates an attribute reference + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, H5R_ref_priv_t *ref) +{ + size_t encode_size; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + HDassert(attr_name); + HDassert(ref); + + /* Make sure that attribute name is not longer than supported encode size */ + if (HDstrlen(attr_name) > H5R_MAX_STRING_LEN) + HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", + (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN) + + /* Create new reference */ + ref->info.obj.filename = NULL; + if (NULL == (ref->info.attr.name = HDstrdup(attr_name))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") + + ref->loc_id = H5I_INVALID_HID; + ref->type = (uint8_t)H5R_ATTR; + if (H5R__set_obj_token(ref, obj_token, token_size) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token") + + /* Cache encoding size (assume no external reference) */ + if (H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to determine encoding size") + ref->encode_size = (uint32_t)encode_size; + + H5R_LOG_DEBUG("Created attribute reference, %d, filename=%s, obj_addr=%s, attr name=%s, encode size=%u", + (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->info.attr.name, ref->encode_size); + +done: + if (ret_value < 0) { + H5MM_xfree(ref->info.attr.name); + ref->info.attr.name = NULL; + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5R__create_attr */ + +/*------------------------------------------------------------------------- + * Function: H5R__destroy + * + * Purpose: Destroy a reference + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__destroy(H5R_ref_priv_t *ref) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + HDassert(ref != NULL); + + H5R_LOG_DEBUG("Destroying reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), ref->encode_size); + + H5MM_xfree(ref->info.obj.filename); + ref->info.obj.filename = NULL; + + switch (ref->type) { + case H5R_OBJECT2: + break; + + case H5R_DATASET_REGION2: + if (H5S_close(ref->info.reg.space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") + ref->info.reg.space = NULL; break; - } - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - hdset_reg_ref_t *ref = (hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ - hssize_t buf_size; /* Size of buffer needed to serialize selection */ - uint8_t *p; /* Pointer to OID to store */ - uint8_t *buf; /* Buffer to store serialized selection in */ - unsigned heapid_found; /* Flag for non-zero heap ID found */ - unsigned u; /* local index */ - - /* Set up information for dataset region */ - - /* Return any previous heap block to the free list if we are - * garbage collecting - */ - if (H5F_GC_REF(loc->oloc->file)) { - /* Check for an existing heap ID in the reference */ - for (u = 0, heapid_found = 0, p = (uint8_t *)ref; u < H5R_DSET_REG_REF_BUF_SIZE; u++) - if (p[u] != 0) { - heapid_found = 1; - break; - } - - if (heapid_found != 0) { - /* Return heap block to free list */ - } - } - - /* Zero the heap ID out, may leak heap space if user is re-using - * reference and doesn't have garbage collection turned on - */ - HDmemset(ref, 0, H5R_DSET_REG_REF_BUF_SIZE); - - /* Get the amount of space required to serialize the selection */ - if ((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") - - /* Increase buffer size to allow for the dataset OID */ - buf_size += (hssize_t)sizeof(haddr_t); - - /* Allocate the space to store the serialized information */ - H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); - if (NULL == (buf = (uint8_t *)H5MM_malloc((size_t)buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Serialize information for dataset OID into heap buffer */ - p = (uint8_t *)buf; - H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr); - - /* Serialize the selection into heap buffer */ - if (H5S_SELECT_SERIALIZE(space, &p) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") - - /* Save the serialized buffer for later */ - H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); - if(H5HG_insert(loc->oloc->file, (size_t)buf_size, buf, &hobjid) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection") - - /* Serialize the heap ID and index for storage in the file */ - p = (uint8_t *)ref; - H5F_addr_encode(loc->oloc->file, &p, hobjid.addr); - UINT32ENCODE(p, hobjid.idx); - - /* Free the buffer we serialized data in */ - H5MM_xfree(buf); + case H5R_ATTR: + H5MM_xfree(ref->info.attr.name); + ref->info.attr.name = NULL; break; - } /* end case H5R_DATASET_REGION */ + case H5R_OBJECT1: + case H5R_DATASET_REGION1: + break; case H5R_BADTYPE: case H5R_MAXTYPE: + HDassert("invalid reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)") + default: HDassert("unknown reference type" && 0); HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") } /* end switch */ + /* Decrement refcount of attached loc_id */ + if (ref->type && (ref->loc_id != H5I_INVALID_HID)) { + if (ref->app_ref) { + if (H5I_dec_app_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + else { + if (H5I_dec_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + } + done: - if (obj_found) - H5G_loc_free(&obj_loc); + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__destroy() */ + +/*------------------------------------------------------------------------- + * Function: H5R__set_loc_id + * + * Purpose: Attach location ID to reference and increment location refcount. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref) +{ + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_PACKAGE + + HDassert(ref != NULL); + HDassert(id != H5I_INVALID_HID); + + /* If a location ID was previously assigned, decrement refcount and + * assign new one */ + if ((ref->loc_id != H5I_INVALID_HID)) { + if (ref->app_ref) { + if (H5I_dec_app_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + else { + if (H5I_dec_ref(ref->loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "decrementing location ID failed") + } + } + ref->loc_id = id; + + /* Prevent location ID from being freed until reference is destroyed, + * set app_ref if necessary as references are exposed to users and are + * expected to be destroyed, this allows the loc_id to be cleanly released + * on shutdown if users fail to call H5Rdestroy(). */ + if (inc_ref && H5I_inc_ref(ref->loc_id, app_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINC, FAIL, "incrementing location ID failed") + ref->app_ref = app_ref; + +done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__create() */ +} /* end H5R__set_loc_id() */ +/*------------------------------------------------------------------------- + * Function: H5R__get_loc_id + * + * Purpose: Retrieve location ID attached to existing reference. + * + * Return: Valid ID on success / H5I_INVALID_HID on failure + * + *------------------------------------------------------------------------- + */ +hid_t +H5R__get_loc_id(const H5R_ref_priv_t *ref) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ -/*-------------------------------------------------------------------------- - NAME - H5R__dereference - PURPOSE - Opens the HDF5 object referenced. - USAGE - hid_t H5R__dereference(ref, oapl_id, ref_type, ref) - H5F_t *file; IN: File the object being dereferenced is within - hid_t oapl_id; IN: Object access property list ID - H5R_type_t ref_type; IN: Type of reference - void *ref; IN: Reference to open. + FUNC_ENTER_PACKAGE_NOERR - RETURNS - Valid ID on success, Negative on failure - DESCRIPTION - Given a reference to some object, open that object and return an ID for - that object. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Currently only set up to work with references to datasets - EXAMPLES - REVISION LOG - Raymond Lu - 13 July 2011 - I added the OAPL_ID parameter for the object being referenced. It only - supports dataset access property list currently. - - M. Scot Breitenfeld - 3 March 2015 - Added a check for undefined reference pointer. ---------------------------------------------------------------------------*/ + HDassert(ref != NULL); + + ret_value = ref->loc_id; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__get_loc_id() */ + +/*------------------------------------------------------------------------- + * Function: H5R__reopen_file + * + * Purpose: Re-open referenced file using file access property list. + * + * Return: Valid ID on success / H5I_INVALID_HID on failure + * + *------------------------------------------------------------------------- + */ hid_t -H5R__dereference(H5F_t *file, hid_t oapl_id, H5R_type_t ref_type, - const void *_ref) +H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) { - H5O_loc_t oloc; /* Object location */ - H5G_name_t path; /* Path of object */ - H5G_loc_t loc; /* Group location */ - unsigned rc; /* Reference count of object */ - H5O_type_t obj_type; /* Type of object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ + hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_PACKAGE - HDassert(_ref); - HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); - HDassert(file); + /* TODO add search path */ - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = file; + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - switch (ref_type) { - case H5R_OBJECT: - { - oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ - if (!H5F_addr_defined(oloc.addr) || oloc.addr == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "Undefined reference pointer") - break; - } + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf; /* Buffer to store serialized selection in */ - const uint8_t *p; /* Pointer to OID to store */ + /* Stash a copy of the "top-level" connector property, before any pass-through + * connectors modify or unwrap it. + */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, + "can't set VOL connector info in API context") + + /* Open the file */ + /* (Must open file read-write to allow for object modifications) */ + if (NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") + + /* Get an ID for the file */ + if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + + /* Get the file object */ + if (NULL == (vol_obj = H5VL_vol_object(ret_value))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") + + /* Make the 'post open' callback */ + supported = FALSE; + if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation") + if (supported) + if (H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, + "unable to make file 'post open' callback") + + /* Attach loc_id to reference */ + if (H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "unable to attach location id to reference") - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__reopen_file() */ - if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "Undefined reference pointer") +/*------------------------------------------------------------------------- + * Function: H5R__get_type + * + * Purpose: Given a reference to some object, return the type of that + * reference. + * + * Return: Type of the reference + * + *------------------------------------------------------------------------- + */ +H5R_type_t +H5R__get_type(const H5R_ref_priv_t *ref) +{ + H5R_type_t ret_value = H5R_BADTYPE; - /* Get the dataset region from the heap (allocate inside routine) */ - if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL))) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, H5I_INVALID_HID, "Unable to read dataset region information") + FUNC_ENTER_PACKAGE_NOERR - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + HDassert(ref != NULL); + ret_value = (H5R_type_t)ref->type; - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); - break; - } /* end case H5R_DATASET_REGION */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__get_type() */ + +/*------------------------------------------------------------------------- + * Function: H5R__equal + * + * Purpose: Compare two references + * + * Return: TRUE if equal, FALSE if unequal, FAIL if error + * + *------------------------------------------------------------------------- + */ +htri_t +H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2) +{ + htri_t ret_value = TRUE; + + FUNC_ENTER_PACKAGE + HDassert(ref1 != NULL); + HDassert(ref2 != NULL); + + /* Compare reference types */ + if (ref1->type != ref2->type) + HGOTO_DONE(FALSE); + + /* Compare object addresses */ + if (ref1->token_size != ref2->token_size) + HGOTO_DONE(FALSE); + if (0 != HDmemcmp(&ref1->info.obj.token, &ref2->info.obj.token, ref1->token_size)) + HGOTO_DONE(FALSE); + + /* Compare filenames */ + if ((ref1->info.obj.filename && (NULL == ref2->info.obj.filename)) || + ((NULL == ref1->info.obj.filename) && ref2->info.obj.filename)) + HGOTO_DONE(FALSE); + if (ref1->info.obj.filename && ref1->info.obj.filename && + (0 != HDstrcmp(ref1->info.obj.filename, ref2->info.obj.filename))) + HGOTO_DONE(FALSE); + + switch (ref1->type) { + case H5R_OBJECT2: + break; + case H5R_DATASET_REGION2: + if ((ret_value = H5S_extent_equal(ref1->info.reg.space, ref2->info.reg.space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare dataspace extents") + break; + case H5R_ATTR: + HDassert(ref1->info.attr.name && ref2->info.attr.name); + if (0 != HDstrcmp(ref1->info.attr.name, ref2->info.attr.name)) + HGOTO_DONE(FALSE); + break; + case H5R_OBJECT1: + case H5R_DATASET_REGION1: case H5R_BADTYPE: case H5R_MAXTYPE: + HDassert("invalid reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)") default: HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5I_INVALID_HID, "internal error (unknown reference type)") + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") } /* end switch */ - /* Get the # of links for object, and its type - * (To check to make certain that this object hasn't been deleted - * since the reference was created) - */ - if(H5O_get_rc_and_type(&oloc, &rc, &obj_type) < 0 || 0 == rc) - HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, H5I_INVALID_HID, "dereferencing deleted object") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__equal() */ - /* Construct a group location for opening the object */ - H5G_name_reset(&path); - loc.oloc = &oloc; - loc.path = &path; +/*------------------------------------------------------------------------- + * Function: H5R__copy + * + * Purpose: Copy a reference + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref) +{ + herr_t ret_value = SUCCEED; - /* Open the object */ - switch (obj_type) { - case H5O_TYPE_GROUP: - { - H5G_t *group; /* Pointer to group to open */ + FUNC_ENTER_PACKAGE - if(NULL == (group = H5G_open(&loc))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5I_INVALID_HID, "not found") + HDassert((src_ref != NULL) && (dst_ref != NULL)); - /* Create an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, group, TRUE)) < 0) { - H5G_close(group); - HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register group") - } /* end if */ + H5MM_memcpy(&dst_ref->info.obj.token, &src_ref->info.obj.token, sizeof(H5O_token_t)); + dst_ref->encode_size = src_ref->encode_size; + dst_ref->type = src_ref->type; + dst_ref->token_size = src_ref->token_size; + switch (src_ref->type) { + case H5R_OBJECT2: break; - } - - case H5O_TYPE_NAMED_DATATYPE: - { - H5T_t *type; /* Pointer to datatype to open */ - - if(NULL == (type = H5T_open(&loc))) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, H5I_INVALID_HID, "not found") + case H5R_DATASET_REGION2: + if (NULL == (dst_ref->info.reg.space = H5S_copy(src_ref->info.reg.space, FALSE, TRUE))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") + break; + case H5R_ATTR: + if (NULL == (dst_ref->info.attr.name = HDstrdup(src_ref->info.attr.name))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name") + break; + case H5R_OBJECT1: + case H5R_DATASET_REGION1: + HDassert("invalid reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)") + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ - /* Create an atom for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) { - H5T_close(type); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register datatype") - } /* end if */ + /* We only need to keep a copy of the filename if we don't have the loc_id */ + if (src_ref->loc_id == H5I_INVALID_HID) { + HDassert(src_ref->info.obj.filename); - break; - } + if (NULL == (dst_ref->info.obj.filename = HDstrdup(src_ref->info.obj.filename))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy filename") + dst_ref->loc_id = H5I_INVALID_HID; + } + else { + dst_ref->info.obj.filename = NULL; + + /* Set location ID and hold reference to it */ + dst_ref->loc_id = src_ref->loc_id; + if (H5I_inc_ref(dst_ref->loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINC, FAIL, "incrementing location ID failed") + dst_ref->app_ref = TRUE; + } - case H5O_TYPE_DATASET: - { - H5D_t *dset; /* Pointer to dataset to open */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__copy() */ - /* Open the dataset */ - if(NULL == (dset = H5D_open(&loc, oapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, H5I_INVALID_HID, "not found") +/*------------------------------------------------------------------------- + * Function: H5R__get_obj_token + * + * Purpose: Given a reference to some object, get the encoded token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size) +{ + herr_t ret_value = SUCCEED; /* Return value */ - /* Create an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) { - H5D_close(dset); - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset") - } /* end if */ + FUNC_ENTER_PACKAGE - break; - } + HDassert(ref != NULL); + HDassert(ref->token_size <= H5O_MAX_TOKEN_SIZE); - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, H5I_INVALID_HID, "can't identify type of object referenced") - } /* end switch */ + if (obj_token) { + if (0 == ref->token_size) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "NULL token size") + H5MM_memcpy(obj_token, &ref->info.obj.token, sizeof(H5O_token_t)); + } + if (token_size) + *token_size = ref->token_size; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__dereference() */ +} /* end H5R__get_obj_token() */ +/*------------------------------------------------------------------------- + * Function: H5R__set_obj_token + * + * Purpose: Given a reference to some object, set the encoded token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size) +{ + herr_t ret_value = SUCCEED; /* Return value */ -/*-------------------------------------------------------------------------- - NAME - H5R__get_region - PURPOSE - Retrieves a dataspace with the region pointed to selected. - USAGE - H5S_t *H5R__get_region(file, ref) - H5F_t *file; IN: File the object being dereferenced is within - void *ref; IN: Reference to open. + FUNC_ENTER_PACKAGE_NOERR - RETURNS - Pointer to the dataspace on success, NULL on failure - DESCRIPTION - Given a reference to some object, creates a copy of the dataset pointed - to's dataspace and defines a selection in the copy which is the region - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5S_t * -H5R__get_region(H5F_t *file, const void *_ref) + HDassert(ref != NULL); + HDassert(obj_token); + HDassert(token_size); + HDassert(token_size <= H5O_MAX_TOKEN_SIZE); + + H5MM_memcpy(&ref->info.obj.token, obj_token, token_size); + HDassert(token_size <= 255); + ref->token_size = (uint8_t)token_size; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__set_obj_token() */ + +/*------------------------------------------------------------------------- + * Function: H5R__get_region + * + * Purpose: Given a reference to some object, creates a copy of the + * dataset pointed to's dataspace and defines a selection in + * the copy which is the region pointed to. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space) { - H5O_loc_t oloc; /* Object location */ - const uint8_t *p; /* Pointer to OID to store */ - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf = NULL; /* Buffer to store serialized selection in */ - H5S_t *ds = NULL; /* Temporary pointer to dataspace */ - H5S_t *ret_value = NULL; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - HDassert(_ref); - HDassert(file); + HDassert(ref != NULL); + HDassert(ref->type == H5R_DATASET_REGION2); + HDassert(space); - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = file; + /* Copy reference selection to destination */ + if (H5S_select_copy(space, ref->info.reg.space, FALSE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy selection") - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); - - /* Get the dataset region from the heap (allocate inside routine) */ - if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL))) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__get_region() */ - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); +/*------------------------------------------------------------------------- + * Function: H5R__get_file_name + * + * Purpose: Given a reference to some object, determine a file name of + * the object located into. + * + * Return: Non-negative length of the path on success / -1 on failure + * + *------------------------------------------------------------------------- + */ +ssize_t +H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size) +{ + size_t copy_len; + ssize_t ret_value = -1; /* Return value */ - /* Open and copy the dataset's dataspace */ - if(NULL == (ds = H5S_read(&oloc))) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found") + FUNC_ENTER_PACKAGE - /* Unserialize the selection */ - if(H5S_SELECT_DESERIALIZE(&ds, &p) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection") + /* Check args */ + HDassert(ref != NULL); - ret_value = ds; + /* Return if that reference has no filename set */ + if (!ref->info.obj.filename) + HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, (-1), "no filename available for that reference") -done: - /* Free the buffer allocated in H5HG_read() */ - if(buf) - H5MM_xfree(buf); + /* Get the file name length */ + copy_len = HDstrlen(ref->info.obj.filename); + HDassert(copy_len <= H5R_MAX_STRING_LEN); - if(ret_value == NULL) { - if(ds && H5S_close(ds) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") + /* Copy the file name */ + if (buf) { + copy_len = MIN(copy_len, size - 1); + H5MM_memcpy(buf, ref->info.obj.filename, copy_len); + buf[copy_len] = '\0'; } + ret_value = (ssize_t)(copy_len + 1); +done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__get_region() */ +} /* end H5R__get_file_name() */ + +/*------------------------------------------------------------------------- + * Function: H5R__get_attr_name + * + * Purpose: Given a reference to some attribute, determine its name. + * + * Return: Non-negative length of the path on success / -1 on failure + * + *------------------------------------------------------------------------- + */ +ssize_t +H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size) +{ + ssize_t ret_value = -1; /* Return value */ + size_t attr_name_len; /* Length of the attribute name */ + FUNC_ENTER_PACKAGE_NOERR -/*-------------------------------------------------------------------------- - NAME - H5R__get_obj_type - PURPOSE - Retrieves the type of object that an object reference points to - USAGE - H5O_type_t H5R__get_obj_type(file, ref_type, ref) - H5F_t *file; IN: File the object being dereferenced is within - H5R_type_t ref_type; IN: Type of reference to query - void *ref; IN: Reference to query. - H5O_type_t *obj_type; OUT: The type of the object, set on success + /* Check args */ + HDassert(ref != NULL); + HDassert(ref->type == H5R_ATTR); + + /* Get the attribute name length */ + attr_name_len = HDstrlen(ref->info.attr.name); + HDassert(attr_name_len <= H5R_MAX_STRING_LEN); + + /* Get the attribute name */ + if (buf) { + size_t copy_len = MIN(attr_name_len, size - 1); + H5MM_memcpy(buf, ref->info.attr.name, copy_len); + buf[copy_len] = '\0'; + } - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Given a reference to some object, this function returns the type of object - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ + ret_value = (ssize_t)(attr_name_len + 1); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__get_attr_name() */ + +/*------------------------------------------------------------------------- + * Function: H5R__encode + * + * Purpose: Private function for H5Rencode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t -H5R__get_obj_type(H5F_t *file, H5R_type_t ref_type, const void *_ref, - H5O_type_t *obj_type) +H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, + unsigned flags) { - H5O_loc_t oloc; /* Object location */ - unsigned rc; /* Reference count of object */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *p = (uint8_t *)buf; + size_t buf_size = 0, encode_size = 0; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE - HDassert(file); - HDassert(_ref); + HDassert(ref); + HDassert(nalloc); + + /** + * Encoding format: + * | Reference type (8 bits) | Flags (8 bits) | Token (token size) + * | | + * | |----> H5R_IS_EXTERNAL: File info + * | + * |----> H5R_DATASET_REGION2: Serialized selection + * | + * |----> H5R_ATTR: Attribute name len + name + * + */ - /* Initialize the symbol table entry */ - H5O_loc_reset(&oloc); - oloc.file = file; + /* Don't encode if buffer size isn't big enough or buffer is empty */ + if (buf && *nalloc >= H5R_ENCODE_HEADER_SIZE) { + /* Encode the type of the reference */ + *p++ = (uint8_t)ref->type; + + /* Encode the flags */ + *p++ = (uint8_t)flags; + + buf_size = *nalloc - H5R_ENCODE_HEADER_SIZE; + } /* end if */ + encode_size += H5R_ENCODE_HEADER_SIZE; + + /* Encode object token */ + H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->info.obj.token, ref->token_size, p, buf_size, encode_size, + "Cannot encode object address"); + + /** + * TODO Encode VOL info + * When we have a better way of storing blobs, we should add + * support for referencing files in external VOLs. + * There are currently multiple limitations: + * - avoid duplicating VOL info on each reference + * - must query terminal VOL connector to avoid passthrough confusion + */ + if (flags & H5R_IS_EXTERNAL) + /* Encode file name */ + H5R_ENCODE(H5R__encode_string, filename, p, buf_size, encode_size, "Cannot encode filename"); - switch (ref_type) { - case H5R_OBJECT: - { - /* Get the object oid */ - oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ + switch (ref->type) { + case H5R_OBJECT2: break; - } - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - const uint8_t *p; /* Pointer to reference to decode */ - uint8_t *buf; /* Buffer to store serialized selection in */ + case H5R_DATASET_REGION2: + /* Encode dataspace */ + H5R_ENCODE(H5R__encode_region, ref->info.reg.space, p, buf_size, encode_size, + "Cannot encode region"); + break; - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); + case H5R_ATTR: + /* Encode attribute name */ + H5R_ENCODE(H5R__encode_string, ref->info.attr.name, p, buf_size, encode_size, + "Cannot encode attribute name"); + break; - /* Get the dataset region from the heap (allocate inside routine) */ - if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL))) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + case H5R_OBJECT1: + case H5R_DATASET_REGION1: + case H5R_BADTYPE: + case H5R_MAXTYPE: + HDassert("invalid reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)") - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); + H5R_LOG_DEBUG("Encoded reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), encode_size); - break; - } + *nalloc = encode_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode() */ +/*------------------------------------------------------------------------- + * Function: H5R__decode + * + * Purpose: Private function for H5Rdecode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref) +{ + const uint8_t *p = (const uint8_t *)buf; + size_t buf_size = 0, decode_size = 0; + uint8_t flags; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(buf); + HDassert(nbytes); + HDassert(ref); + + /* Don't decode if buffer size isn't big enough */ + buf_size = *nbytes; + if (buf_size < H5R_ENCODE_HEADER_SIZE) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + /* Set new reference */ + ref->type = (int8_t)*p++; + if (ref->type <= H5R_BADTYPE || ref->type >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") + + /* Set flags */ + flags = *p++; + + buf_size -= H5R_ENCODE_HEADER_SIZE; + decode_size += H5R_ENCODE_HEADER_SIZE; + + /* Decode object token */ + H5R_DECODE_VAR(H5R__decode_obj_token, &ref->info.obj.token, &ref->token_size, p, buf_size, decode_size, + "Cannot decode object address"); + + /* We do not need to store the filename if the reference is internal */ + if (flags & H5R_IS_EXTERNAL) { + /* Decode file name */ + H5R_DECODE(H5R__decode_string, &ref->info.obj.filename, p, buf_size, decode_size, + "Cannot decode filename"); + } + else + ref->info.obj.filename = NULL; + + switch (ref->type) { + case H5R_OBJECT2: + break; + case H5R_DATASET_REGION2: + /* Decode dataspace */ + H5R_DECODE(H5R__decode_region, &ref->info.reg.space, p, buf_size, decode_size, + "Cannot decode region"); + break; + case H5R_ATTR: + /* Decode attribute name */ + H5R_DECODE(H5R__decode_string, &ref->info.attr.name, p, buf_size, decode_size, + "Cannot decode attribute name"); + break; + case H5R_OBJECT1: + case H5R_DATASET_REGION1: case H5R_BADTYPE: case H5R_MAXTYPE: + HDassert("invalid reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)") default: HDassert("unknown reference type" && 0); HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") } /* end switch */ - /* Get the # of links for object, and its type */ - /* (To check to make certain that this object hasn't been deleted since the reference was created) */ - if(H5O_get_rc_and_type(&oloc, &rc, obj_type) < 0 || 0 == rc) - HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") + /* Set loc ID to invalid */ + ref->loc_id = H5I_INVALID_HID; + + /* Set encoding size */ + ref->encode_size = (uint32_t)decode_size; + + H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u", ref->info.obj.filename, + H5R__print_token(ref->info.obj.token), ref->encode_size); + + /* Set output info */ + *nbytes = decode_size; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__get_obj_type() */ +} /* end H5R__decode() */ +/*------------------------------------------------------------------------- + * Function: H5R__encode_obj_token + * + * Purpose: Encode an object address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc) +{ + herr_t ret_value = SUCCEED; -/*-------------------------------------------------------------------------- - NAME - H5R__get_name - PURPOSE - Internal routine to determine a name for the object referenced - USAGE - ssize_t H5R__get_name(f, ref_type, ref, name, size) - H5F_t *f; IN: Pointer to the file that the reference is pointing - into - hid_t lapl_id; IN: LAPL to use for operation - hid_t id; IN: Location ID given for reference - H5R_type_t ref_type; IN: Type of reference - void *_ref; IN: Reference to query. - char *name; OUT: Buffer to place name of object referenced - size_t size; IN: Size of name buffer + FUNC_ENTER_STATIC_NOERR - RETURNS - Non-negative length of the path on success, -1 on failure - DESCRIPTION - Given a reference to some object, determine a path to the object - referenced in the file. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This may not be the only path to that object. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -ssize_t -H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, - char *name, size_t size) + HDassert(nalloc); + + /* Don't encode if buffer size isn't big enough or buffer is empty */ + if (buf && *nalloc >= token_size) { + uint8_t *p = (uint8_t *)buf; + + /* Encode token size */ + *p++ = (uint8_t)(token_size & 0xff); + + /* Encode token */ + H5MM_memcpy(p, obj_token, token_size); + } + *nalloc = token_size + H5_SIZEOF_UINT8_T; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode_obj_token() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_obj_token + * + * Purpose: Decode an object address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, uint8_t *token_size) { - hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ - H5O_loc_t oloc; /* Object location describing object for reference */ - ssize_t ret_value = -1; /* Return value */ + const uint8_t *p = (const uint8_t *)buf; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(buf); + HDassert(nbytes); + HDassert(obj_token); + HDassert(token_size); + + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < H5_SIZEOF_UINT8_T) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + /* Get token size */ + *token_size = *p++; + if (*token_size > sizeof(H5O_token_t)) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Invalid token size (%u)", *token_size) + + /* Make sure that token is initialized */ + HDmemset(obj_token, 0, sizeof(H5O_token_t)); + + /* Decode token */ + H5MM_memcpy(obj_token, p, *token_size); + + *nbytes = (size_t)(*token_size + H5_SIZEOF_UINT8_T); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_obj_token() */ + +/*------------------------------------------------------------------------- + * Function: H5R__encode_region + * + * Purpose: Encode a selection. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) +{ + uint8_t *p = NULL; /* Pointer to data to store */ + hssize_t buf_size = 0; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(space); + HDassert(nalloc); + + /* Get the amount of space required to serialize the selection */ + if ((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, + "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)) { + int rank; + p = (uint8_t *)buf; + + /* Encode the size for safety check */ + UINT32ENCODE(p, (uint32_t)buf_size); + + /* Encode the extent rank */ + if ((rank = H5S_get_simple_extent_ndims(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get extent rank for selection") + UINT32ENCODE(p, (uint32_t)rank); + + /* Serialize the selection */ + 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; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode_region() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_region + * + * Purpose: Decode a selection. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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; + size_t buf_size = 0; + unsigned rank; + H5S_t * space; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(buf); + HDassert(nbytes); + HDassert(space_ptr); + + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < (2 * H5_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; + + /* Decode the extent rank */ + UINT32DECODE(p, rank); + buf_size += H5_SIZEOF_UINT32_T; + + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < buf_size) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + /* Deserialize the selection (dataspaces need the extent rank information) */ + if (NULL == (space = H5S_create(H5S_SIMPLE))) + 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) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") + + *nbytes = buf_size; + *space_ptr = space; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_region() */ + +/*------------------------------------------------------------------------- + * Function: H5R__encode_string + * + * Purpose: Encode a string. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc) +{ + size_t string_len, buf_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(string); + HDassert(nalloc); + + /* Get the amount of space required to serialize the string */ + string_len = HDstrlen(string); + if (string_len > H5R_MAX_STRING_LEN) + HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "string too long") + + /* Compute buffer size, allow for the attribute name length and object address */ + buf_size = string_len + sizeof(uint16_t); + + if (buf && *nalloc >= buf_size) { + uint8_t *p = (uint8_t *)buf; + /* Serialize information for string length into the buffer */ + UINT16ENCODE(p, string_len); + /* Copy the string into the buffer */ + H5MM_memcpy(p, string, string_len); + } + *nalloc = buf_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode_string() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_string + * + * Purpose: Decode a string. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +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; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(buf); + HDassert(nbytes); + HDassert(string_ptr); + + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < sizeof(uint16_t)) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + /* Get the string length */ + UINT16DECODE(p, string_len); + HDassert(string_len <= H5R_MAX_STRING_LEN); + + /* Allocate the string */ + if (NULL == (string = (char *)H5MM_malloc(string_len + 1))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, FAIL, "Cannot allocate string") + + /* Copy the string */ + H5MM_memcpy(string, p, string_len); + string[string_len] = '\0'; + + *string_ptr = string; + *nbytes = sizeof(uint16_t) + string_len; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_string() */ + +/*------------------------------------------------------------------------- + * Function: H5R__encode_heap + * + * Purpose: Encode data and insert into heap (native only). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, size_t data_size) +{ + size_t buf_size; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE - /* Check args */ HDassert(f); - HDassert(_ref); + HDassert(nalloc); - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = f; + buf_size = H5HG_HEAP_ID_SIZE(f); + if (buf && *nalloc >= buf_size) { + H5HG_t hobjid; + uint8_t *p = (uint8_t *)buf; - /* Get address for reference */ - switch (ref_type) { - case H5R_OBJECT: - { - oloc.addr = *(const hobj_ref_t *)_ref; - break; - } + /* Write the reference information to disk (allocates space also) */ + if (H5HG_insert(f, data_size, data, &hobjid) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to write reference information") + + /* Encode the heap information */ + H5F_addr_encode(f, &p, hobjid.addr); + UINT32ENCODE(p, hobjid.idx); + } /* end if */ + *nalloc = buf_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode_heap() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_heap + * + * Purpose: Decode data inserted into heap (native only). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, + size_t *data_size) +{ + const uint8_t *p = (const uint8_t *)buf; + H5HG_t hobjid; + size_t buf_size; + herr_t ret_value = SUCCEED; - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf; /* Buffer to store serialized selection in */ - const uint8_t *p; /* Pointer to OID to store */ + FUNC_ENTER_PACKAGE - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); + HDassert(f); + HDassert(buf); + HDassert(nbytes); + HDassert(data_ptr); + + buf_size = H5HG_HEAP_ID_SIZE(f); + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < buf_size) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + /* Get the heap information */ + H5F_addr_decode(f, &p, &(hobjid.addr)); + if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") + UINT32DECODE(p, hobjid.idx); - /* Get the dataset region from the heap (allocate inside routine) */ - if ((buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, (-1), "Unable to read dataset region information") + /* Read the information from disk */ + if (NULL == (*data_ptr = (unsigned char *)H5HG_read(f, &hobjid, (void *)*data_ptr, data_size))) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read reference data") - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + *nbytes = buf_size; - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_heap() */ - break; - } +/*------------------------------------------------------------------------- + * Function: H5R__encode_token_obj_compat + * + * Purpose: Encode an object token. (native only) + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, + size_t *nalloc) +{ + herr_t ret_value = SUCCEED; - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, (-1), "internal error (unknown reference type)") - } /* end switch */ + FUNC_ENTER_PACKAGE_NOERR - /* Retrieve file ID for name search */ - if ((file_id = H5F_get_id(f, FALSE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get file ID") + HDassert(obj_token); + HDassert(token_size); + HDassert(nalloc); - /* Get name, length, etc. */ - if ((ret_value = H5G_get_name_by_addr(file_id, &oloc, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't determine name") + /* Don't encode if buffer size isn't big enough or buffer is empty */ + if (buf && *nalloc >= token_size) + H5MM_memcpy(buf, obj_token, token_size); -done: - /* Close file ID used for search */ - if (file_id > 0 && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, (-1), "can't decrement ref count of temp ID") + *nalloc = token_size; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__encode_token_obj_compat() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_token_obj_compat + * + * Purpose: Decode an object token. (native only) + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + HDassert(buf); + HDassert(nbytes); + HDassert(obj_token); + HDassert(token_size); + + /* Don't decode if buffer size isn't big enough */ + if (*nbytes < token_size) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") + + H5MM_memcpy(obj_token, buf, token_size); + *nbytes = token_size; + +done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__get_name() */ +} /* H5R__decode_token_obj_compat() */ + +/*------------------------------------------------------------------------- + * Function: H5R__decode_token_region_compat + * + * Purpose: Decode dataset selection from data inserted into heap + * (native only). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size, H5S_t **space_ptr) +{ + unsigned char *data = NULL; + H5O_token_t token = {0}; + size_t data_size; + const uint8_t *p; + H5S_t * space = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + HDassert(f); + HDassert(buf); + HDassert(nbytes); + HDassert(token_size); + + /* Read from heap */ + if (H5R__decode_heap(f, buf, nbytes, &data, &data_size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get object address */ + p = (const uint8_t *)data; + H5MM_memcpy(&token, p, token_size); + p += token_size; + + if (space_ptr) { + H5O_loc_t oloc; /* Object location */ + + /* Initialize the object location */ + H5O_loc_reset(&oloc); + oloc.file = f; + + if (H5VL_native_token_to_addr(f, H5I_FILE, token, &oloc.addr) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + /* Open and copy the dataset's dataspace */ + if (NULL == (space = H5S_read(&oloc))) + HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "not found") + + /* Unserialize the selection */ + if (H5S_SELECT_DESERIALIZE(&space, &p) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") + + *space_ptr = space; + } + if (obj_token) + H5MM_memcpy(obj_token, &token, sizeof(H5O_token_t)); + +done: + H5MM_free(data); + + if (ret_value < 0) { + if (space && H5S_close(space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__decode_token_region_compat() */ diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h index 678a668035a..2a34d56d7b1 100644 --- a/src/H5Rmodule.h +++ b/src/H5Rmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,16 +14,22 @@ * H5R package. Including this header means that the source file * is part of the H5R package. */ -#ifndef _H5Rmodule_H -#define _H5Rmodule_H +#ifndef H5Rmodule_H +#define H5Rmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5R_MODULE -#define H5_MY_PKG H5R -#define H5_MY_PKG_ERR H5E_REFERENCE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5R +#define H5_MY_PKG_ERR H5E_REFERENCE +#define H5_MY_PKG_INIT YES -#endif /* _H5Rmodule_H */ +/** + * \defgroup H5R H5R + * \brief Reference Interface + * \details The HDF5 Reference Interface, H5R, provides a mechanism for managing + * HDF5 referenced objects. + */ +#endif /* H5Rmodule_H */ diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index fbbff500031..ee5fb710d37 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,46 +19,113 @@ #error "Do not include this file outside the H5R package!" #endif -#ifndef _H5Rpkg_H -#define _H5Rpkg_H +#ifndef H5Rpkg_H +#define H5Rpkg_H /* Get package's private header */ #include "H5Rprivate.h" /* Other private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ - +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ /**************************/ /* Package Private Macros */ /**************************/ +/* Encode flags */ +#define H5R_IS_EXTERNAL 0x1 /* Set when encoding reference to external file */ + +/* Macros for convenience */ +#define H5R_REF_FILENAME(x) ((x)->info.obj.filename) +#define H5R_REF_ATTRNAME(x) ((x)->info.attr.name) + +/* Header size */ +#define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T) /****************************/ /* Package Private Typedefs */ /****************************/ +/* Object reference */ +typedef struct H5R_ref_priv_obj_t { + H5O_token_t token; /* Object token */ + 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 */ +} 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 */ +} H5R_ref_priv_attr_t; + +/* Generic reference type (keep it cache aligned) */ +typedef struct H5R_ref_priv_t { + union { + H5R_ref_priv_obj_t obj; /* Object reference */ + H5R_ref_priv_reg_t reg; /* Region reference */ + H5R_ref_priv_attr_t attr; /* Attribute Reference */ + } info; + hid_t loc_id; /* Cached location identifier */ + uint32_t encode_size; /* Cached encoding size */ + int8_t type; /* Reference type */ + uint8_t token_size; /* Cached token size */ + hbool_t app_ref; /* App ref on loc_id */ +} H5R_ref_priv_t; /*****************************/ /* Package Private Variables */ /*****************************/ - /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5R__create(void *ref, H5G_loc_t *loc, const char *name, - H5R_type_t ref_type, H5S_t *space); -H5_DLL hid_t H5R__dereference(H5F_t *file, hid_t dapl_id, H5R_type_t ref_type, - const void *_ref); -H5_DLL H5S_t *H5R__get_region(H5F_t *file, const void *_ref); -H5_DLL herr_t H5R__get_obj_type(H5F_t *file, H5R_type_t ref_type, - const void *_ref, H5O_type_t *obj_type); -H5_DLL ssize_t H5R__get_name(H5F_t *file, hid_t id, H5R_type_t ref_type, - const void *_ref, char *name, size_t size); - -#endif /* _H5Rpkg_H */ +H5_DLL herr_t H5R__create_object(const H5O_token_t *obj_token, size_t token_size, H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_region(const H5O_token_t *obj_token, size_t token_size, H5S_t *space, + H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__create_attr(const H5O_token_t *obj_token, size_t token_size, const char *attr_name, + H5R_ref_priv_t *ref); +H5_DLL herr_t H5R__destroy(H5R_ref_priv_t *ref); + +H5_DLL herr_t H5R__set_loc_id(H5R_ref_priv_t *ref, hid_t id, hbool_t inc_ref, hbool_t app_ref); +H5_DLL hid_t H5R__get_loc_id(const H5R_ref_priv_t *ref); +H5_DLL hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id); + +H5_DLL H5R_type_t H5R__get_type(const H5R_ref_priv_t *ref); +H5_DLL htri_t H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2); +H5_DLL herr_t H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref); + +H5_DLL herr_t H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token, size_t *token_size); +H5_DLL herr_t H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token, size_t token_size); +H5_DLL herr_t H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space); + +H5_DLL ssize_t H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size); +H5_DLL ssize_t H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size); + +H5_DLL herr_t H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, size_t *nalloc, + unsigned flags); +H5_DLL herr_t H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref); + +/* Native HDF5 specific routines */ +H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned char *data, + size_t data_size); +H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, + size_t *data_size); + +H5_DLL herr_t H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size, + unsigned char *buf, size_t *nalloc); +H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, + size_t token_size); + +H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, + H5O_token_t *obj_token, size_t token_size, H5S_t **space_ptr); +#endif /* H5Rpkg_H */ diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 8c0ba8f45f6..6d6fcd5f994 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,37 +14,29 @@ /* * This file contains private information about the H5R module */ -#ifndef _H5Rprivate_H -#define _H5Rprivate_H +#ifndef H5Rprivate_H +#define H5Rprivate_H #include "H5Rpublic.h" /* Private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ - /**************************/ /* Library Private Macros */ /**************************/ +#define H5R_ENCODE_VERSION 0x1 /* Version for encoding references */ /****************************/ /* Library Private Typedefs */ /****************************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /******************************/ /* Library Private Prototypes */ /******************************/ - -#endif /* _H5Rprivate_H */ - +#endif /* H5Rprivate_H */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index 598bafd18a8..e26a72c3ee3 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains public declarations for the H5R module. */ -#ifndef _H5Rpublic_H -#define _H5Rpublic_H +#ifndef H5Rpublic_H +#define H5Rpublic_H /* Public headers needed by this file */ #include "H5public.h" @@ -26,42 +26,80 @@ /* Public Macros */ /*****************/ -/* Note! Be careful with the sizes of the references because they should really - * depend on the run-time values in the file. Unfortunately, the arrays need - * to be defined at compile-time, so we have to go with the worst case sizes - * for them. -QAK - */ -#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) +/* Deprecated reference buffer sizes that are kept for backward compatibility */ +#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) +#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) -/* 4 is used instead of sizeof(int) to permit portability between the Crays - * and other machines (the heap ID is always encoded as an int32 anyway). +/* 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. */ -#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) +#define H5R_REF_BUF_SIZE (64) /*******************/ /* Public Typedefs */ /*******************/ -/* Reference types */ -typedef enum H5R_type_t { - H5R_BADTYPE = (-1), /* Invalid Reference Type */ - H5R_OBJECT, /* Object reference */ - H5R_DATASET_REGION, /* Dataset Region Reference */ - H5R_MAXTYPE /* Highest type (Invalid as true type) */ +//! +/** + * Reference types allowed. + * + * \internal DO NOT CHANGE THE ORDER or VALUES as reference type values are + * encoded into the datatype message header. + */ +typedef enum { + H5R_BADTYPE = (-1), /**< Invalid reference type */ + H5R_OBJECT1 = 0, /**< Backward compatibility (object) */ + H5R_DATASET_REGION1 = 1, /**< Backward compatibility (region) */ + H5R_OBJECT2 = 2, /**< Object reference */ + H5R_DATASET_REGION2 = 3, /**< Region reference */ + H5R_ATTR = 4, /**< Attribute Reference */ + H5R_MAXTYPE = 5 /**< Highest type (invalid) */ } H5R_type_t; +//! + +/* Deprecated types are kept for backward compatibility with previous versions */ -/* Object reference structure for user's code - * This needs to be large enough to store largest haddr_t on a worst case - * machine (8 bytes currently). +//! +/** + * \deprecated Deprecated object reference type that is used with deprecated + * reference APIs. + * + * \note This type can only be used with the "native" HDF5 VOL connector. */ 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 + * machine (8 bytes currently) plus an int. + * + * \deprecated Dataset region reference type that is used with deprecated + * reference APIs. + * + * \note This type can only be used with the "native" HDF5 VOL connector. + */ +typedef struct { + uint8_t __data[H5R_DSET_REG_REF_BUF_SIZE]; +} hdset_reg_ref_t; +//! -/* Dataset Region reference structure for user's code - * (Buffer to store heap ID and index) - * This needs to be large enough to store largest haddr_t in a worst case - * machine (8 bytes currently) plus an int +//! +/** + * Opaque reference type. The same reference type is used for object, + * dataset region and attribute references. This is the type that + * should always be used with the current reference API. */ -typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE]; +typedef struct { + union { + uint8_t __data[H5R_REF_BUF_SIZE]; /**< opaque data */ + int64_t align; /**< ensures alignment */ + } u; +} H5R_ref_t; +//! /********************/ /* Public Variables */ @@ -75,30 +113,775 @@ typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE]; extern "C" { #endif -H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, - H5R_type_t ref_type, hid_t space_id); -H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref); -H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref); -H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *_ref, - H5O_type_t *obj_type); -H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, - char *name /*out*/, size_t size); +/* Constructors */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Creates an object reference + * + * \fgdta_loc_id + * \param[in] name Name of object + * \oapl_id + * \param[out] ref_ptr Pointer to reference + * + * \return \herr_t + * + * \details H5Rcreate_object() creates a reference pointing to the + * object named \p name located at \p loc_id. The parameters \p + * loc_id and \p name are used to locate the object. + * + * The parameter \p oapl_id is an object access property list + * identifier for the referenced object. The access property list + * must be of the same type as the object being referenced, that is + * a group, dataset or committed datatype property list. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + * H5Rdestroy() should be used to release the resource from the + * reference. + * + */ +H5_DLL herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Creates a region reference + * + * \fgdta_loc_id + * \param[in] name Name of object + * \space_id + * \oapl_id + * \param[out] ref_ptr Pointer to reference + * + * \return \herr_t + * + * \details H5Rcreate_region() creates the reference, \p ref_ptr, + * pointing to the region represented by \p space_id within the + * object named name located at \p loc_id. + * + * The parameters \p loc_id and \p name are used to locate the + * object. The parameter \p space_id identifies the dataset region + * that a dataset region reference points to. + * + * The parameter \p oapl_id is an object access property list + * identifier for the referenced object. The access property list + * must be of the same type as the object being referenced, that is + * a dataset property list in this case. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + * H5Rdestroy() should be used to release the resource from the + * reference. + * + */ +H5_DLL herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, + H5R_ref_t *ref_ptr); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Creates an attribute reference + * + * \fgdta_loc_id + * \param[in] name Name of object + * \param[in] attr_name Name of attribute + * \oapl_id + * \param[out] ref_ptr Pointer to reference + * + * \return \herr_t + * + * \details H5Rcreate_attr() creates the reference, \p ref_ptr, pointing + * to the attribute named \p attr_name and attached to the object + * named \p name located at \p loc_id. + * + * The parameters \p loc_id and \p name locate the object. The + * parameter \p attr_name specifies the attribute within the object. + * + * The parameter \p oapl_id is an object access property list + * identifier for the object that the referenced attribute is + * attached to. The access property list must be of the same type + * as that object, that is a group, dataset or committed datatype + * property list. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + * H5Rdestroy() should be used to release the resource from the + * reference. + * + */ +H5_DLL herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, + H5R_ref_t *ref_ptr); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Closes a reference + * + * \param[in] ref_ptr Pointer to reference + * + * \return \herr_t + * + * \details Given a reference, \p ref_ptr, to an object, region or attribute + * attached to an object, H5Rdestroy() releases allocated resources + * from a previous create call. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + */ +H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr); + +/* Info */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the type of a reference + * + * \param[in] ref_ptr Pointer to reference + * + * \return Returns a valid reference type if successful; otherwise returns #H5R_BADTYPE . + * + * \details Given a reference, \p ref_ptr, H5Rget_type() returns the + * type of the reference. + * + * Valid returned reference types are: + * \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 + * returned through that function. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + */ +H5_DLL H5R_type_t H5Rget_type(const H5R_ref_t *ref_ptr); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Determines whether two references are equal + * + * \param[in] ref1_ptr Pointer to reference to compare + * \param[in] ref2_ptr Pointer to reference to compare + * + * \return Returns a positive value if the references are equal. Returns + * 0 if the references are not equal. Returns a negative value when the + * function fails. + * + * \details H5Requal() determines whether two references point to the + * same object, region or attribute. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + */ +H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Copies an existing reference + * + * \param[in] src_ref_ptr Pointer to reference to copy + * \param[out] dst_ref_ptr Pointer to output reference + * + * \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 + * pointer to the destination reference. + * + */ +H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); + +/* Dereference */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Opens the HDF5 object referenced + * + * \param[in] ref_ptr Pointer to reference to open + * \rapl_id + * \oapl_id + * + * \return \hid_t{object} + * + * \details Given a reference, \p ref_ptr, to an object, a region in + * an object, or an attribute attached to an object, H5Ropen_object() + * opens that object and returns an identifier. + * + * The parameter \p oapl_id is an object access property list + * identifier for the referenced object. The access property list + * must be of the same type as the object being referenced, that is + * a group or dataset property list. + * + * \ref H5R_ref_t is defined in H5Rpublic.h as: + * \snippet this H5R_ref_t_snip + * + * 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 datasets. + * + */ +H5_DLL hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Sets up a dataspace and selection as specified by a region reference. + * + * \param[in] ref_ptr Pointer to reference to open + * \rapl_id + * \oapl_id + * + * \return \hid_t{dataspace} + * + * \details H5Ropen_region() creates a copy of the dataspace of the + * dataset pointed to by a region reference, \p ref_ptr, and defines + * a selection matching the selection pointed to by \p ref_ptr within + * the dataspace copy. + * + * The parameter \p rapl id is a reference access property list + * identifier for the reference. The access property list can + * be used to access external files that the reference points to + * (through a file access property list). + * + * The parameter \p oapl id is an object access property list + * identifier for the referenced object. The access property list + * must be of the same type as the object being referenced, that is + * a dataset property list in that case. + * + * Use H5Sclose() to release the dataspace identifier returned by + * this function when the identifier is no longer needed. + * + */ +H5_DLL hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Opens the HDF5 attribute referenced + * + * \param[in] ref_ptr Pointer to reference to open + * \rapl_id + * \aapl_id + * + * \return \hid_t{attribute} + * + * \details Given a reference, \p ref_ptr, to an attribute attached to + * an object, H5Ropen_attr() opens the attribute attached to that + * object and returns an identifier. + * + * The parameter \p rapl id is a reference access property list + * identifier for the reference. The access property list can + * be used to access external files that the reference points to + * (through a file access property list). + * + * The parameter \p aapl_id is an attribute access property list + * identifier for the referenced attribute. + * + * The attribute opened with this function should be closed with + * H5Aclose() when it is no longer needed. + * + */ +H5_DLL hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id); + +/* Get type */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the type of object that an object reference points to + * + * \param[in] ref_ptr Pointer to reference to query + * \rapl_id + * \param[out] obj_type Type of referenced object + * + * \return \herr_t + * + * \details Given a reference, \p ref_ptr, H5Rget_obj_type3() retrieves + * the type of the referenced object in \p obj_type. + * + * The parameter \p rapl id is a reference access property list + * identifier for the reference. The access property list can + * be used to access external files that the reference points to + * (through a file access property list). + * + * Upon success, the function returns in \p obj_type the type of + * the object that the reference points to. Valid values for this + * referenced object type are as followed (defined in H5Opublic.h): + * \snippet H5Opublic.h H5O_type_t_snip + * + */ +H5_DLL herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type); + +/* Get name */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the file name for a referenced object + * + * \param[in] ref_ptr Pointer to reference to query + * \param[in,out] name Buffer to place the file name of the reference + * \param[in] size Size of the \p name buffer + * + * \return Returns the length of the name if successful, otherwise, a negative value. + * + * \details H5Rget_file_name() retrieves the file name for the object, + * region or attribute reference pointed to by \p ref_ptr. + * + * Up to \p size characters of the 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 size, is unknown, a preliminary + * H5Rget_file_name() call can be made. The return value of this + * call will be the size of the file name. That value can then be + * passed in for size in the second call to H5Rget_file_name(), + * which will retrieve the actual name. + * + */ +H5_DLL ssize_t H5Rget_file_name(const H5R_ref_t *ref_ptr, char *name, size_t size); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the object name for a referenced object + * + * \param[in] ref_ptr Pointer to reference to query + * \rapl_id + * \param[in,out] name Buffer to place the file name of the reference + * \param[in] size Size of the \p name buffer + * + * \return Returns the length of the name if successful, returning + * 0 (zero) if no name is associated with the identifier. Otherwise + * returns a negative value. + * + * \details H5Rget_obj_name() retrieves the object name for the object, + * region or attribute reference pointed to by \p ref_ptr. + * + * The parameter \p rapl_id is a reference access property list + * identifier for the reference. The access property list can + * be used to access external files that the reference points to + * (through a file access property list). + * + * Up to size characters of the 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 call to H5Rget_obj_name() call + * can be made. The return value of this call will be the size of the + * object name. That value can then be passed in for \p size in the + * second call to H5Rget_obj_name(), which will retrieve the actual + * name. If there is no name associated with the object identifier + * or if the name is NULL, H5Rget_obj_name() returns the size of + * the name buffer (the size does not include the \c \0 terminator). + * + * If \p ref_ptr is an object reference, \p name will be returned with + * a name for the referenced object. If \p ref_ptr is a dataset region + * reference, \p name will contain a name for the object containing + * the referenced region. If \p ref_ptr is an attribute reference, \p + * name will contain a name for the object the attribute is attached + * to. Note that an object in an HDF5 file may have multiple paths + * if there are multiple links pointing to it. This function may + * return any one of these paths. + * + */ +H5_DLL ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *name, size_t size); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the attribute name for a referenced object + * + * \param[in] ref_ptr Pointer to reference to query + * \param[in,out] name Buffer to place the attribute name of the reference + * \param[in] size Size of the \p name buffer + * + * \return Returns the length of the name if successful, otherwise, a negative value. + * + * \details H5Rget_attr_name() retrieves the attribute name for the + * attribute reference pointed to by \p ref_ptr. + * + * Up to size characters of the 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 + * H5Rget_attr_name() call can be made. The return value of this + * call will be the size of the attribute name. That value can then + * be passed in for size in the second call to H5Rget_attr_name(), + * which will retrieve the actual name. + * + */ +H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *name, size_t size); /* Symbols defined for compatibility with previous versions of the HDF5 API. * - * Use of these symbols is deprecated. + * Use of these symbols is or will be deprecated. */ -#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* Macros */ + +/* Versions for compatibility */ +#define H5R_OBJECT H5R_OBJECT1 +#define H5R_DATASET_REGION H5R_DATASET_REGION1 /* Function prototypes */ -H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *_ref); +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the type of object that an object reference points to + * + * \param[in] id The dataset containing the reference object or the group + * containing that dataset + * \param[in] ref_type Type of reference to query + * \param[in] ref Reference to query + * + * \return Returns a valid object type if successful; otherwise returns a + * negative value (#H5G_UNKNOWN). + * + * \deprecated This function has been renamed from H5Rget_obj_type() and is + * deprecated in favor of the macro H5Rget_obj_type() or the + * function H5Rget_obj_type2(). + * + * \details Given an object reference, \p ref, H5Rget_obj_type1() returns the + * type of the referenced object. + * + * 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 a defined region within a dataset. + * + * The \Emph{referenced object} is the object the reference points + * to. The \Emph{referenced object type}, or the type of the referenced + * object, is the type of the object that the reference points to. + * + * The location identifier, \p id, is the identifier for either the + * dataset containing the object reference or the group containing that + * dataset. + * + * Valid reference types, to pass in as \p ref_type, include the + * following: + * \snippet this H5R_type_t_snip + * + * If the application does not already know the object reference type, + * that can be determined with three preliminary calls: + * + * \li Call H5Dget_type() on the dataset containing the reference to + * get a datatype identifier for the dataset’s datatype. + * \li Using that datatype identifier, H5Tget_class() returns a datatype + * class.\n If the datatype class is #H5T_REFERENCE, H5Tequal() can + * then be used to determine whether the reference’s datatype is + * #H5T_STD_REF_OBJ or #H5T_STD_REF_DSETREG: + * - If the datatype is #H5T_STD_REF_OBJ, the reference object type + * is #H5R_OBJECT. + * - If the datatype is #H5T_STD_REF_DSETREG, the reference object + * type is #H5R_DATASET_REGION. + * + * When the function completes successfully, it returns one of the + * following valid object type values (defined in H5Gpublic.h): + * \snippet H5Gpublic.h H5G_obj_t_snip + * + * \version 1.8.0 Function H5Rget_obj_type() renamed to H5Rget_obj_type1() and + * deprecated in this release. + * \since 1.6.0 + * + */ +H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Opens the HDF5 object referenced + * + * \obj_id + * \param[in] ref_type The reference type of \p ref + * \param[in] ref Reference to open + * + * \return Returns identifier of referenced object if successful; otherwise + * returns a negative value. + * + * \deprecated This function has been renamed from H5Rdereference() and is + * deprecated in favor of the macro H5Rdereference() or the function + * H5Rdereference2(). + * + * \details Given a reference, \p ref, to an object or a region in an object, + * H5Rdereference1() opens that object and returns an identifier. + * + * The parameter \p obj_id must be a valid identifier for an object in + * the HDF5 file containing the referenced object, including the file + * identifier. + * + * The parameter \p ref_type specifies the reference type of the + * reference \p ref. \p ref_type may contain either of the following + * values: + * - #H5R_OBJECT + * - #H5R_DATASET_REGION + * + * 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 + * datasets. + * + * \version 1.10.0 Function H5Rdereference() renamed to H5Rdereference1() and + * deprecated in this release. + * \since 1.8.0 + * + */ H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref); #endif /* H5_NO_DEPRECATED_SYMBOLS */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Creates a reference + * + * \param[out] ref Reference created by the function call + * \param[in] loc_id Location identifier used to locate the object being pointed to + * \param[in] name Name of object at location \p loc_id + * \param[in] ref_type Type of reference + * \param[in] space_id Dataspace identifier with selection. Used only for + * dataset region references; pass as -1 if reference is + * an object reference, i.e., of type #H5R_OBJECT + * + * \return \herr_t + * + * \details H5Rcreate() creates the reference, \p ref, of the type specified in + * \p ref_type, pointing to the object \p name located at \p loc_id. + * + * The HDF5 library maps the void type specified above for \p ref to + * the type specified in \p ref_type, which will be one of the following: + * \snippet this H5R_type_t_snip + * + * The parameters \p loc_id and \p name are used to locate the object. + * + * The parameter \p space_id identifies the dataset region that a + * dataset region reference points to. This parameter is used only with + * dataset region references and should be set to -1 if the reference + * is an object reference, #H5R_OBJECT. + * + * \since 1.8.0 + */ +H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves the type of object that an object reference points to + * + * \param[in] id The dataset containing the reference object or the group + * containing that dataset + * \param[in] ref_type Type of reference to query + * \param[in] ref Reference to query + * \param[out] obj_type Type of referenced object + * + * \return \herr_t + * + * \details Given an object reference, \p ref, H5Rget_obj_type2() returns the + * type of the referenced object in \p obj_type. + * + * 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 a defined region within a dataset. + * + * The \Emph{referenced object} is the object the reference points + * to. The \Emph{referenced object type}, or the type of the referenced + * object, is the type of the object that the reference points to. + * + * The location identifier, \p id, is the identifier for either the + * dataset containing the object reference or the group containing that + * dataset. + * + * Valid reference types, to pass in as \p ref_type, include the + * following: + * \snippet this H5R_type_t_snip + * + * If the application does not already know the object reference type, + * that can be determined with three preliminary calls: + * + * \li Call H5Dget_type() on the dataset containing the reference to + * get a datatype identifier for the dataset’s datatype. + * \li Using that datatype identifier, H5Tget_class() returns a datatype + * class.\n If the datatype class is #H5T_REFERENCE, H5Tequal() can + * then be used to determine whether the reference’s datatype is + * #H5T_STD_REF_OBJ or #H5T_STD_REF_DSETREG: + * - If the datatype is #H5T_STD_REF_OBJ, the reference object type + * is #H5R_OBJECT. + * - If the datatype is #H5T_STD_REF_DSETREG, the reference object + * type is #H5R_DATASET_REGION. + * + * When the function completes successfully, it returns one of the + * following valid object type values (defined in H5Opublic.h): + * \snippet H5Opublic.h H5O_type_t_snip + * + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Opens the HDF5 object referenced + * + * \obj_id + * \oapl_id + * \param[in] ref_type The reference type of \p ref + * \param[in] ref Reference to open + * + * \return Returns identifier of referenced object if successful; otherwise + * returns a negative value. + * + * \details Given a reference, \p ref, to an object or a region in an object, + * H5Rdereference2() opens that object and returns an identifier. + * + * The parameter \p obj_id must be a valid identifier for the HDF5 file + * containing the referenced object or for any object in that HDF5 + * file. + * + * The parameter \p oapl_id is an object access property list + * identifier for the referenced object. The access property list must + * be of the same type as the object being referenced, that is a group, + * dataset, or datatype property list. + * + * The parameter \p ref_type specifies the reference type of the + * reference \p ref. \p ref_type may contain either of the following + * values: + * - #H5R_OBJECT + * - #H5R_DATASET_REGION + * + * 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 + * datasets. + * + * \since 1.10.0 + * + */ +H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Sets up a dataspace and selection as specified by a region reference + * + * \param[in] dataset File identifier or identifier for any object in the file + * containing the referenced region + * \param[in] ref_type Reference type of \p ref, which must be #H5R_DATASET_REGION + * \param[in] ref Region reference to open + * + * \return Returns a valid dataspace identifier if successful; otherwise returns + * a negative value. + * + * \details H5Rget_region() creates a copy of the dataspace of the dataset + * pointed to by a region reference, \p ref, and defines a selection + * matching the selection pointed to by ref within the dataspace copy. + * + * \p dataset is used to identify the file containing the referenced + * region; it can be a file identifier or an identifier for any object + * in the file. + * + * The parameter \p ref_type specifies the reference type of \p ref and + * must contain the value #H5R_DATASET_REGION. + * + * Use H5Sclose() to release the dataspace identifier returned by this + * function when the identifier is no longer needed. + * + */ +H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5R + * + * \brief Retrieves a name for a referenced object + * + * \param[in] loc_id Identifier for the file containing the reference or for + * any object in that file + * \param[in] ref_type Type of reference + * \param[in] ref An object or dataset region reference + * \param[out] name A buffer to place the name of the referenced object or + * dataset region. If \c NULL, then this call will return the + * size in bytes of the name. + * \param[in] size The size of the \p name buffer. When the size is passed in, + * the \c NULL terminator needs to be included. + * + * \return Returns the length of the name if successful, returning 0 (zero) if + * no name is associated with the identifier. Otherwise returns a + * negative value. + * + * \details H5Rget_name() retrieves a name for the object identified by \p ref.\n + * \p loc_id is used to identify the file containing the reference. It + * can be the file identifier for the file containing the reference or + * an identifier for any object in that file. + * + * \ref H5R_type_t is the reference type of \p ref. Valid values + * include the following: + * \snippet this H5R_type_t_snip + * + * \p ref is the reference for which the target object’s name is + * sought. + * + * If \p ref is an object reference, \p name will be returned with a + * name for the referenced object. If \p ref is a dataset region + * reference, \p name will contain a name for the object containing the + * referenced region. + * + * Up to \p size characters of the 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 H5Rget_name() call can be made. The + * return value of this call will be the size of the object name. That + * value can then be assigned to \p size for a second H5Rget_name() + * call, which will retrieve the actual name. + * + * If there is no name associated with the object identifier or if the + * \p name is \c NULL, H5Rget_name() returns the size of the \p name + * buffer (the size does not include the \p NULL terminator). + * + * Note that an object in an HDF5 file may have multiple paths if there + * are multiple links pointing to it. This function may return any one + * of these paths. + * + * \since 1.8.0 + */ +H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, char *name, size_t size); + #ifdef __cplusplus } #endif -#endif /* _H5Rpublic_H */ - +#endif /* H5Rpublic_H */ diff --git a/src/H5S.c b/src/H5S.c index dff8e6037cf..d45a6f135ed 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,47 +15,41 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ /* Version of dataspace encoding */ -#define H5S_ENCODE_VERSION 0 - +#define H5S_ENCODE_VERSION 0 /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ static htri_t H5S__is_simple(const H5S_t *sdim); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -65,9 +59,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Format version bounds for dataspace */ const unsigned H5O_sdspace_ver_bounds[] = { - H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ - H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */ + H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V110 */ + H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /* Declare a free list to manage the H5S_extent_t struct */ @@ -79,25 +74,29 @@ H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); - /*******************/ /* Local Variables */ /*******************/ /* Dataspace ID class */ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ - H5I_DATASPACE, /* ID class value */ - 0, /* Class flags */ - 2, /* # of reserved IDs for class */ - (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ + H5I_DATASPACE, /* ID class value */ + 0, /* Class flags */ + 2, /* # of reserved IDs for class */ + (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ }}; +/* Dataspace selection iterator ID class */ +static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ + H5I_SPACE_SEL_ITER, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */ +}}; /* Flag indicating "top" of interface has been initialized */ static hbool_t H5S_top_package_initialize_s = FALSE; - - /*-------------------------------------------------------------------------- NAME H5S__init_package -- Initialize interface-specific information @@ -111,14 +110,19 @@ DESCRIPTION herr_t H5S__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Initialize the atom group for the dataspace IDs */ - if(H5I_register_type(H5I_DATASPACE_CLS) < 0) + 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 */ + 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") + /* Mark "top" of interface as initialized, too */ H5S_top_package_initialize_s = TRUE; @@ -126,7 +130,6 @@ H5S__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__init_package() */ - /*-------------------------------------------------------------------------- NAME H5S_top_term_package @@ -148,25 +151,29 @@ H5S__init_package(void) int H5S_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5S_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASPACE) > 0) { + if (H5S_top_package_initialize_s) { + if (H5I_nmembers(H5I_DATASPACE) > 0) { (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ + + if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { + (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ /* Mark "top" of interface as closed */ - if(0 == n) + if (0 == n) H5S_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5S_top_term_package() */ - /*-------------------------------------------------------------------------- NAME H5S_term_package @@ -190,28 +197,30 @@ H5S_top_term_package(void) int H5S_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_DATASPACE)); + HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); HDassert(FALSE == H5S_top_package_initialize_s); /* Destroy the dataspace object id group */ n += (H5I_dec_type_ref(H5I_DATASPACE) > 0); + /* Destroy the dataspace selection iterator object id group */ + n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); + /* Mark interface as closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5S_term_package() */ - - /*-------------------------------------------------------------------------- NAME H5S_get_validiated_dataspace @@ -234,26 +243,26 @@ H5S_term_package(void) herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(space); /* Check for invalid ID */ - if(space_id < 0) + if (space_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid space_id (ID cannot be a negative number)") /* No special dataspace struct for H5S_ALL */ - if(H5S_ALL == space_id) + if (H5S_ALL == space_id) *space = NULL; else { /* Get the dataspace pointer */ - if(NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (*space = (const H5S_t *)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 */ - if(H5S_SELECT_VALID(*space) != TRUE) + if (H5S_SELECT_VALID(*space) != TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") } @@ -261,7 +270,6 @@ H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_validated_dataspace() */ - /*-------------------------------------------------------------------------- NAME H5S_create @@ -283,25 +291,25 @@ H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) H5S_t * H5S_create(H5S_class_t type) { - H5S_t *new_ds = NULL; /* New dataspace created */ + H5S_t *new_ds = NULL; /* New dataspace created */ H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Create a new dataspace */ - if(NULL == (new_ds = H5FL_CALLOC(H5S_t))) + if (NULL == (new_ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize default dataspace state */ new_ds->extent.type = type; - if(type == H5S_NULL) + if (type == H5S_NULL) new_ds->extent.version = H5O_SDSPACE_VERSION_2; else new_ds->extent.version = H5O_SDSPACE_VERSION_1; new_ds->extent.rank = 0; new_ds->extent.size = new_ds->extent.max = NULL; - switch(type) { + switch (type) { case H5S_SCALAR: new_ds->extent.nelem = 1; break; @@ -318,28 +326,27 @@ H5S_create(H5S_class_t type) } /* end switch */ /* Start with "all" selection */ - if(H5S_select_all(new_ds, FALSE) < 0) + if (H5S_select_all(new_ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Reset common selection info pointer */ new_ds->select.sel_info.hslab = NULL; /* Reset "shared" info on extent */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, &(new_ds->extent.sh_loc)) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, &(new_ds->extent.sh_loc)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, NULL, "unable to reset shared component info") /* Set return value */ ret_value = new_ds; done: - if(ret_value == NULL) - if(new_ds && H5S_close(new_ds) < 0) + if (ret_value == NULL) + if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ - /*-------------------------------------------------------------------------- NAME H5Screate @@ -361,32 +368,31 @@ H5S_create(H5S_class_t type) hid_t H5Screate(H5S_class_t type) { - H5S_t *new_ds = NULL; /* New dataspace structure */ - hid_t ret_value; /* Return value */ + H5S_t *new_ds = NULL; /* New dataspace structure */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "Sc", type); /* Check args */ - if(type <= H5S_NO_CLASS || type > H5S_NULL) /* don't allow complex dataspace yet */ + if (type <= H5S_NO_CLASS || type > H5S_NULL) /* don't allow complex dataspace yet */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type") - if(NULL == (new_ds = H5S_create(type))) + if (NULL == (new_ds = H5S_create(type))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create dataspace") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_ds, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_ds, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if(ret_value < 0) - if(new_ds && H5S_close(new_ds) < 0) + if (ret_value < 0) + if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ - /*------------------------------------------------------------------------- * Function: H5S__extent_release * @@ -407,20 +413,19 @@ H5S__extent_release(H5S_extent_t *extent) HDassert(extent); /* Release extent */ - if(extent->type == H5S_SIMPLE) { - if(extent->size) + if (extent->type == H5S_SIMPLE) { + if (extent->size) extent->size = H5FL_ARR_FREE(hsize_t, extent->size); - if(extent->max) + if (extent->max) extent->max = H5FL_ARR_FREE(hsize_t, extent->max); } /* end if */ - extent->rank = 0; + extent->rank = 0; extent->nelem = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__extent_release() */ - /*------------------------------------------------------------------------- * Function: H5S_close * @@ -436,18 +441,18 @@ H5S__extent_release(H5S_extent_t *extent) herr_t H5S_close(H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(ds); /* Release selection (this should come before the extent release) */ - if(H5S_SELECT_RELEASE(ds) < 0) + if (H5S_SELECT_RELEASE(ds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection") /* Release extent */ - if(H5S__extent_release(&ds->extent) < 0) + if (H5S__extent_release(&ds->extent) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") done: @@ -461,7 +466,6 @@ H5S_close(H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_close() */ - /*------------------------------------------------------------------------- * Function: H5Sclose * @@ -477,24 +481,23 @@ H5S_close(H5S_t *ds) herr_t H5Sclose(hid_t space_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", space_id); /* Check args */ - if(NULL == H5I_object_verify(space_id, H5I_DATASPACE)) + if (NULL == H5I_object_verify(space_id, H5I_DATASPACE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(space_id) < 0) + if (H5I_dec_app_ref(space_id) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) } /* end H5Sclose() */ - /*------------------------------------------------------------------------- * Function: H5Scopy * @@ -512,34 +515,33 @@ H5Sclose(hid_t space_id) hid_t H5Scopy(hid_t space_id) { - H5S_t *src = NULL; - H5S_t *dst = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", space_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Copy */ - if(NULL == (dst = H5S_copy(src, FALSE, TRUE))) + if (NULL == (dst = H5S_copy(src, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy dataspace") /* Atomize */ - if((ret_value = H5I_register (H5I_DATASPACE, dst, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, dst, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0) - if(dst && H5S_close(dst) < 0) + if (ret_value < 0) + if (dst && H5S_close(dst) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ - /*------------------------------------------------------------------------- * Function: H5Sextent_copy * @@ -553,30 +555,29 @@ H5Scopy(hid_t space_id) *------------------------------------------------------------------------- */ herr_t -H5Sextent_copy(hid_t dst_id,hid_t src_id) +H5Sextent_copy(hid_t dst_id, hid_t src_id) { - H5S_t *src; - H5S_t *dst; - herr_t ret_value = SUCCEED; + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) + if (NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ - if(H5S_extent_copy(dst, src) < 0) + if (H5S_extent_copy(dst, src) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_copy * @@ -592,7 +593,7 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) herr_t H5S_extent_copy(H5S_t *dst, const H5S_t *src) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -600,20 +601,19 @@ H5S_extent_copy(H5S_t *dst, const H5S_t *src) HDassert(src); /* Copy extent */ - if(H5S__extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0) + if (H5S__extent_copy_real(&(dst->extent), &(src->extent), TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent") /* If the selection is 'all', update the number of elements selected in the * destination space */ - if(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(dst)) - if(H5S_select_all(dst, FALSE) < 0) + if (H5S_SEL_ALL == H5S_GET_SELECT_TYPE(dst)) + if (H5S_select_all(dst, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_copy() */ - /*------------------------------------------------------------------------- * Function: H5S__extent_copy_real * @@ -630,38 +630,38 @@ herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) { unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Release destination extent before we copy over it */ - if(H5S__extent_release(dst) < 0) + if (H5S__extent_release(dst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") /* Copy the regular fields */ - dst->type = src->type; + dst->type = src->type; dst->version = src->version; - dst->nelem = src->nelem; - dst->rank = src->rank; + dst->nelem = src->nelem; + dst->rank = src->rank; switch (src->type) { case H5S_NULL: case H5S_SCALAR: dst->size = NULL; - dst->max = NULL; + dst->max = NULL; break; case H5S_SIMPLE: - if(src->size) { + if (src->size) { dst->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)src->rank); - for(u = 0; u < src->rank; u++) + for (u = 0; u < src->rank; u++) dst->size[u] = src->size[u]; } /* end if */ else dst->size = NULL; - if(copy_max && src->max) { + if (copy_max && src->max) { dst->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)src->rank); - for(u = 0; u < src->rank; u++) + for (u = 0; u < src->rank; u++) dst->max[u] = src->max[u]; } /* end if */ else @@ -675,14 +675,13 @@ H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_m } /* end switch */ /* Copy the shared object info */ - if(H5O_set_shared(&(dst->sh_loc), &(src->sh_loc)) < 0) + if (H5O_set_shared(&(dst->sh_loc), &(src->sh_loc)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy shared information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__extent_copy_real() */ - /*------------------------------------------------------------------------- * Function: H5S_copy * @@ -705,34 +704,33 @@ H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_m H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) { - H5S_t *dst = NULL; - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *dst = NULL; + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - if(NULL == (dst = H5FL_CALLOC(H5S_t))) + if (NULL == (dst = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the source dataspace's extent */ - if(H5S__extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0) + if (H5S__extent_copy_real(&(dst->extent), &(src->extent), copy_max) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent") /* Copy the source dataspace's selection */ - if(H5S_select_copy(dst, src, share_selection) < 0) + if (H5S_select_copy(dst, src, share_selection) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select") /* Set the return value */ ret_value = dst; done: - if(NULL == ret_value) - if(dst) + if (NULL == ret_value) + if (dst) dst = H5FL_FREE(H5S_t, dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_npoints * @@ -754,7 +752,7 @@ H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value = -1; /* Return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) @@ -768,7 +766,6 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_npoints() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_npoints * @@ -785,14 +782,14 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) hssize_t H5Sget_simple_extent_npoints(hid_t space_id) { - H5S_t *ds; - hssize_t ret_value; + H5S_t * ds; + hssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", space_id); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = (hssize_t)H5S_GET_EXTENT_NPOINTS(ds); @@ -801,7 +798,6 @@ H5Sget_simple_extent_npoints(hid_t space_id) FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_npoints() */ - /*------------------------------------------------------------------------- * Function: H5S_get_npoints_max * @@ -823,15 +819,15 @@ H5Sget_simple_extent_npoints(hid_t space_id) hsize_t H5S_get_npoints_max(const H5S_t *ds) { - unsigned u; - hsize_t ret_value = 0; /* Return value */ + unsigned u; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* check args */ HDassert(ds); - switch(H5S_GET_EXTENT_TYPE(ds)) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: ret_value = 0; break; @@ -841,9 +837,9 @@ H5S_get_npoints_max(const H5S_t *ds) break; case H5S_SIMPLE: - if(ds->extent.max) { - for(ret_value = 1, u = 0; u < ds->extent.rank; u++) { - if(H5S_UNLIMITED == ds->extent.max[u]) { + if (ds->extent.max) { + for (ret_value = 1, u = 0; u < ds->extent.rank; u++) { + if (H5S_UNLIMITED == ds->extent.max[u]) { ret_value = HSIZET_MAX; break; } @@ -852,7 +848,7 @@ H5S_get_npoints_max(const H5S_t *ds) } } else - for(ret_value = 1, u = 0; u < ds->extent.rank; u++) + for (ret_value = 1, u = 0; u < ds->extent.rank; u++) ret_value *= ds->extent.size[u]; break; @@ -866,7 +862,6 @@ H5S_get_npoints_max(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_npoints_max() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_ndims * @@ -883,14 +878,14 @@ H5S_get_npoints_max(const H5S_t *ds) int H5Sget_simple_extent_ndims(hid_t space_id) { - H5S_t *ds; - int ret_value = -1; + H5S_t *ds; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", space_id); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = (int)H5S_GET_EXTENT_NDIMS(ds); @@ -899,7 +894,6 @@ H5Sget_simple_extent_ndims(hid_t space_id) FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_ndims() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_ndims * @@ -922,14 +916,14 @@ H5Sget_simple_extent_ndims(hid_t space_id) int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(ds); - switch(H5S_GET_EXTENT_TYPE(ds)) { + switch (H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -946,7 +940,6 @@ H5S_get_simple_extent_ndims(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_ndims() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_dims * @@ -964,16 +957,16 @@ H5S_get_simple_extent_ndims(const H5S_t *ds) *------------------------------------------------------------------------- */ int -H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) +H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[] /*out*/, hsize_t maxdims[] /*out*/) { - H5S_t *ds; - int ret_value = -1; + H5S_t *ds; + int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Is", "ixx", space_id, dims, maxdims); /* Check args */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); @@ -982,7 +975,6 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_get_dims * @@ -1000,15 +992,15 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) { - int i; /* Local index variable */ - int ret_value = -1; /* Return value */ + int i; /* Local index variable */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* check args */ HDassert(ext); - switch(ext->type) { + switch (ext->type) { case H5S_NULL: case H5S_SCALAR: ret_value = 0; @@ -1016,16 +1008,16 @@ H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) case H5S_SIMPLE: ret_value = (int)ext->rank; - for(i = 0; i < ret_value; i++) { - if(dims) + for (i = 0; i < ret_value; i++) { + if (dims) dims[i] = ext->size[i]; - if(max_dims) { - if(ext->max) + if (max_dims) { + if (ext->max) max_dims[i] = ext->max[i]; else max_dims[i] = ext->size[i]; } /* end if */ - } /* end for */ + } /* end for */ break; case H5S_NO_CLASS: @@ -1038,7 +1030,6 @@ H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_get_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_dims * @@ -1056,7 +1047,7 @@ H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1064,14 +1055,13 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) HDassert(ds); /* Get dims for extent */ - if((ret_value = H5S_extent_get_dims(&ds->extent, dims, max_dims)) < 0) + if ((ret_value = H5S_extent_get_dims(&ds->extent, dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_dims() */ - /*------------------------------------------------------------------------- * Function: H5S_write * @@ -1088,7 +1078,7 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) herr_t H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1098,14 +1088,13 @@ H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds) HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0); /* Write the current dataspace extent to the dataspace message */ - if(H5O_msg_write_oh(f, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0) + if (H5O_msg_write_oh(f, oh, H5O_SDSPACE_ID, 0, update_flags, &(ds->extent)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple dataspace message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_write() */ - /*------------------------------------------------------------------------- * Function: H5S_append * @@ -1121,7 +1110,7 @@ H5S_write(H5F_t *f, H5O_t *oh, unsigned update_flags, H5S_t *ds) herr_t H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1131,14 +1120,13 @@ H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds) HDassert(H5S_GET_EXTENT_TYPE(ds) >= 0); /* Add the dataspace message to the object header */ - if(H5O_msg_append_oh(f, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0) + if (H5O_msg_append_oh(f, oh, H5O_SDSPACE_ID, 0, 0, &(ds->extent)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't add simple dataspace message") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_append() */ - /*------------------------------------------------------------------------- * Function: H5S_read * @@ -1156,36 +1144,35 @@ H5S_append(H5F_t *f, H5O_t *oh, H5S_t *ds) H5S_t * H5S_read(const H5O_loc_t *loc) { - H5S_t *ds = NULL; /* Dataspace to return */ - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *ds = NULL; /* Dataspace to return */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* check args */ HDassert(loc); - if(NULL == (ds = H5FL_CALLOC(H5S_t))) + if (NULL == (ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if(NULL == H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent))) + if (NULL == H5O_msg_read(loc, H5O_SDSPACE_ID, &(ds->extent))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header") /* Default to entire dataspace being selected */ - if(H5S_select_all(ds, FALSE) < 0) + if (H5S_select_all(ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Set the value for successful return */ ret_value = ds; done: - if(ret_value == NULL) - if(ds != NULL) + if (ret_value == NULL) + if (ds != NULL) ds = H5FL_FREE(H5S_t, ds); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_read() */ - /*-------------------------------------------------------------------------- NAME H5S__is_simple @@ -1203,7 +1190,7 @@ H5S_read(const H5O_loc_t *loc) static htri_t H5S__is_simple(const H5S_t *sdim) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1211,13 +1198,12 @@ H5S__is_simple(const H5S_t *sdim) HDassert(sdim); /* H5S_NULL shouldn't be simple dataspace */ - ret_value = (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || - H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; + ret_value = + (H5S_GET_EXTENT_TYPE(sdim) == H5S_SIMPLE || H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__is_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sis_simple @@ -1235,14 +1221,14 @@ H5S__is_simple(const H5S_t *sdim) htri_t H5Sis_simple(hid_t space_id) { - H5S_t *space; /* Dataspace to check */ - htri_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to check */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", space_id); /* Check args and all the boring stuff. */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") ret_value = H5S__is_simple(space); @@ -1251,7 +1237,6 @@ H5Sis_simple(hid_t space_id) FUNC_LEAVE_API(ret_value) } /* end H5Sis_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sset_extent_simple @@ -1279,44 +1264,44 @@ H5Sis_simple(hid_t space_id) --------------------------------------------------------------------------*/ herr_t -H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], - const hsize_t max[/*rank*/]) +H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { - H5S_t *space; /* Dataspace to modify */ - int u; /* Local counting variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + int u; /* Local counting variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iIs*[a1]h*[a1]h", space_id, rank, dims, max); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") - if(rank > 0 && dims == NULL) + if (rank > 0 && dims == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified") - if(rank < 0 || rank > H5S_MAX_RANK) + if (rank < 0 || rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank") - if(dims) - for(u = 0; u < rank; u++) - if(H5S_UNLIMITED == dims[u]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED") - if(max != NULL) { - if(dims == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified") - for(u = 0; u < rank; u++) - if(max[u] != H5S_UNLIMITED && max[u] < dims[u]) + if (dims) + for (u = 0; u < rank; u++) + if (H5S_UNLIMITED == dims[u]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "current dimension must have a specific size, not H5S_UNLIMITED") + if (max != NULL) { + if (dims == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "maximum dimension specified, but no current dimensions specified") + for (u = 0; u < rank; u++) + if (max[u] != H5S_UNLIMITED && max[u] < dims[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size") } /* Do it */ - if(H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0) + if (H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_simple() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent_simple * @@ -1330,29 +1315,27 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], *------------------------------------------------------------------------- */ herr_t -H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, - const hsize_t *max) +H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(rank <= H5S_MAX_RANK); - HDassert(0 == rank || dims); /* shift out of the previous state to a "simple" dataspace. */ - if(H5S__extent_release(&space->extent) < 0) + if (H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "failed to release previous dataspace extent") - if(rank == 0) { /* scalar variable */ - space->extent.type = H5S_SCALAR; + if (rank == 0) { /* scalar variable */ + space->extent.type = H5S_SCALAR; space->extent.nelem = 1; - space->extent.rank = 0; /* set to scalar rank */ - } /* end if */ + space->extent.rank = 0; /* set to scalar rank */ + } /* end if */ else { - hsize_t nelem; /* Number of elements in extent */ + hsize_t nelem; /* Number of elements in extent */ space->extent.type = H5S_SIMPLE; @@ -1361,7 +1344,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, space->extent.size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); /* Copy the dimensions & compute the number of elements in the extent */ - for(u = 0, nelem = 1; u < space->extent.rank; u++) { + for (u = 0, nelem = 1; dims && (u < space->extent.rank); u++) { space->extent.size[u] = dims[u]; nelem *= dims[u]; } /* end for */ @@ -1370,10 +1353,10 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, /* Copy the maximum dimensions if specified. Otherwise, the maximal dimensions are the * same as the dimension */ space->extent.max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); - if(max != NULL) + if (max != NULL) H5MM_memcpy(space->extent.max, max, sizeof(hsize_t) * rank); else - for(u = 0; u < space->extent.rank; u++) + for (u = 0; dims && (u < space->extent.rank); u++) space->extent.max[u] = dims[u]; } /* end else */ @@ -1384,15 +1367,14 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, space->select.offset_changed = FALSE; /* If the selection is 'all', update the number of elements selected */ - if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL) - if(H5S_select_all(space, FALSE) < 0) + if (H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL) + if (H5S_select_all(space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_simple() */ - /*------------------------------------------------------------------------- * Function: H5Screate_simple * @@ -1417,50 +1399,50 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, hid_t H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { - H5S_t *space = NULL; - int i; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *space = NULL; + int i; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims); /* Check arguments */ - if(rank < 0) + if (rank < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality cannot be negative") - if(rank > H5S_MAX_RANK) + if (rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality is too large") /* We allow users to use this function to create scalar or null dataspace. * Check DIMS isn't set when the RANK is 0. */ - if(!dims && rank != 0) + if (!dims && rank != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dataspace information") /* Check whether the current dimensions are valid */ - for(i = 0; i < rank; i++) { - if(H5S_UNLIMITED == dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "current dimension must have a specific size, not H5S_UNLIMITED") - if(maxdims && H5S_UNLIMITED != maxdims[i] && maxdims[i]extent))) + if (NULL == (ds = H5FL_CALLOC(H5S_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for dataspace conversion path table") + if (NULL == H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object") - if(H5S__extent_release(extent) < 0) + if (H5S__extent_release(extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, NULL, "can't release previous dataspace") extent = H5FL_FREE(H5S_extent_t, extent); /* Initialize to "all" selection. Deserialization relies on valid existing selection. */ - if(H5S_select_all(ds, FALSE) < 0) + 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. */ *p = pp; - if(H5S_SELECT_DESERIALIZE(&ds, p) < 0) + if (H5S_SELECT_DESERIALIZE(&ds, p) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection") /* Set return value */ @@ -1726,13 +1706,12 @@ H5S_decode(const unsigned char **p) done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_decode() */ - /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_type * @@ -1754,7 +1733,7 @@ H5S_decode(const unsigned char **p) H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { - H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ + H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5S_NO_CLASS) @@ -1766,7 +1745,6 @@ H5S_get_simple_extent_type(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_type() */ - /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_type * @@ -1784,14 +1762,14 @@ H5S_get_simple_extent_type(const H5S_t *space) H5S_class_t H5Sget_simple_extent_type(hid_t sid) { - H5S_t *space; - H5S_class_t ret_value; /* Return value */ + H5S_t * space; + H5S_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5S_NO_CLASS) H5TRACE1("Sc", "i", sid); /* Check arguments */ - if(NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace") ret_value = H5S_GET_EXTENT_TYPE(space); @@ -1800,7 +1778,6 @@ H5Sget_simple_extent_type(hid_t sid) FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_type() */ - /*-------------------------------------------------------------------------- NAME H5Sset_extent_none @@ -1818,18 +1795,18 @@ H5Sget_simple_extent_type(hid_t sid) herr_t H5Sset_extent_none(hid_t space_id) { - H5S_t *space; /* Dataspace to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", space_id); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") /* Clear the previous extent from the dataspace */ - if(H5S__extent_release(&space->extent) < 0) + if (H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace") space->extent.type = H5S_NULL; @@ -1838,7 +1815,6 @@ H5Sset_extent_none(hid_t space_id) FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_none() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent * @@ -1855,7 +1831,7 @@ htri_t H5S_set_extent(H5S_t *space, const hsize_t *size) { unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1864,27 +1840,27 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) HDassert(size); /* Verify that the dimensions being changed are allowed to change */ - for(u = 0; u < space->extent.rank; u++) - if(space->extent.size[u] != size[u]) { + for (u = 0; u < space->extent.rank; u++) + if (space->extent.size[u] != size[u]) { /* Check for invalid dimension size modification */ - if(space->extent.max && H5S_UNLIMITED != space->extent.max[u] && - space->extent.max[u] < size[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "dimension cannot exceed the existing maximal size (new: %llu max: %llu)", (unsigned long long)size[u], (unsigned long long)space->extent.max[u]) + if (space->extent.max && H5S_UNLIMITED != space->extent.max[u] && space->extent.max[u] < size[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "dimension cannot exceed the existing maximal size (new: %llu max: %llu)", + (unsigned long long)size[u], (unsigned long long)space->extent.max[u]) /* Indicate that dimension size can be modified */ ret_value = TRUE; } /* end if */ /* Update dimension size(s) */ - if(ret_value) - if(H5S_set_extent_real(space, size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "failed to change dimension size(s)") + if (ret_value) + if (H5S_set_extent_real(space, size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "failed to change dimension size(s)") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent() */ - /*------------------------------------------------------------------------- * Function: H5S_has_extent * @@ -1903,13 +1879,13 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) H5_ATTR_PURE hbool_t H5S_has_extent(const H5S_t *ds) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(ds); - if(0 == ds->extent.rank && 0 == ds->extent.nelem && H5S_NULL != ds->extent.type) + if (0 == ds->extent.rank && 0 == ds->extent.nelem && H5S_NULL != ds->extent.type) ret_value = FALSE; else ret_value = TRUE; @@ -1917,7 +1893,6 @@ H5S_has_extent(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_has_extent() */ - /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * @@ -1934,9 +1909,9 @@ H5S_has_extent(const H5S_t *ds) herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size) { - hsize_t nelem; /* Number of elements in extent */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t nelem; /* Number of elements in extent */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1945,26 +1920,25 @@ H5S_set_extent_real(H5S_t *space, const hsize_t *size) HDassert(size); /* Change the dataspace size & re-compute the number of elements in the extent */ - for(u = 0, nelem = 1; u < space->extent.rank; u++ ) { + for (u = 0, nelem = 1; u < space->extent.rank; u++) { space->extent.size[u] = size[u]; nelem *= size[u]; } /* end for */ space->extent.nelem = nelem; /* If the selection is 'all', update the number of elements selected */ - if(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)) - if(H5S_select_all(space, FALSE) < 0) + if (H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)) + if (H5S_select_all(space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Mark the dataspace as no longer shared if it was before */ - if(H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0) + if (H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_real() */ - /*------------------------------------------------------------------------- * Function: H5Sextent_equal * @@ -1982,27 +1956,26 @@ H5S_set_extent_real(H5S_t *space, const hsize_t *size) htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id) { - const H5S_t *ds1; /* Dataspaces to compare */ - const H5S_t *ds2; - htri_t ret_value; + const H5S_t *ds1; /* Dataspaces to compare */ + const H5S_t *ds2; + htri_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); /* check args */ - if(NULL == (ds1 = (const H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)) || - NULL == (ds2 = (const H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (ds1 = (const H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)) || + NULL == (ds2 = (const H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Check dataspaces for extent's equality */ - if((ret_value = H5S_extent_equal(ds1, ds2)) < 0) + if ((ret_value = H5S_extent_equal(ds1, ds2)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "dataspace comparison failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_equal() */ - /*-------------------------------------------------------------------------- NAME H5S_extent_equal @@ -2019,8 +1992,8 @@ H5Sextent_equal(hid_t space1_id, hid_t space2_id) H5_ATTR_PURE htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) { - unsigned u; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + unsigned u; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2029,41 +2002,39 @@ H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) HDassert(ds2); /* Make certain the dataspaces are the same type */ - if(ds1->extent.type != ds2->extent.type) + if (ds1->extent.type != ds2->extent.type) HGOTO_DONE(FALSE) /* Make certain the dataspaces are the same rank */ - if(ds1->extent.rank != ds2->extent.rank) + if (ds1->extent.rank != ds2->extent.rank) HGOTO_DONE(FALSE) /* Make certain the dataspaces' current dimensions are the same size */ - if(ds1->extent.rank > 0) { + if (ds1->extent.rank > 0) { HDassert(ds1->extent.size); HDassert(ds2->extent.size); - for(u = 0; u < ds1->extent.rank; u++) - if(ds1->extent.size[u] != ds2->extent.size[u]) + for (u = 0; u < ds1->extent.rank; u++) + if (ds1->extent.size[u] != ds2->extent.size[u]) HGOTO_DONE(FALSE) } /* end if */ /* Make certain the dataspaces' maximum dimensions are the same size */ - if(ds1->extent.rank > 0) { + if (ds1->extent.rank > 0) { /* Check for no maximum dimensions on dataspaces */ - if(ds1->extent.max != NULL && ds2->extent.max != NULL) { - for(u = 0; u < ds1->extent.rank; u++) - if(ds1->extent.max[u] != ds2->extent.max[u]) + if (ds1->extent.max != NULL && ds2->extent.max != NULL) { + for (u = 0; u < ds1->extent.rank; u++) + if (ds1->extent.max[u] != ds2->extent.max[u]) HGOTO_DONE(FALSE) } /* end if */ - else - if((ds1->extent.max == NULL && ds2->extent.max != NULL) || - (ds1->extent.max != NULL && ds2->extent.max == NULL)) - HGOTO_DONE(FALSE) + else if ((ds1->extent.max == NULL && ds2->extent.max != NULL) || + (ds1->extent.max != NULL && ds2->extent.max == NULL)) + HGOTO_DONE(FALSE) } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_equal() */ - /*------------------------------------------------------------------------- * Function: H5S_extent_nelem * @@ -2089,7 +2060,6 @@ H5S_extent_nelem(const H5S_extent_t *ext) FUNC_LEAVE_NOAPI(ext->nelem) } /* end H5S_extent_nelem() */ - /*------------------------------------------------------------------------- * Function: H5S_set_version * @@ -2104,8 +2074,8 @@ H5S_extent_nelem(const H5S_extent_t *ext) herr_t H5S_set_version(H5F_t *f, H5S_t *ds) { - unsigned version; /* Message version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned version; /* Message version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2117,7 +2087,7 @@ H5S_set_version(H5F_t *f, H5S_t *ds) version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]); /* Version bounds check */ - if(version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) + if (version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds") /* Set the message version */ @@ -2126,4 +2096,3 @@ H5S_set_version(H5F_t *f, H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_version() */ - diff --git a/src/H5SL.c b/src/H5SL.c index ff8edb8ed44..9d3f5b390eb 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -57,521 +57,516 @@ * */ -#include "H5SLmodule.h" /* This source code file is part of the H5SL module */ - +#include "H5SLmodule.h" /* This source code file is part of the H5SL module */ /* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SLprivate.h" /* Skip list routines */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SLprivate.h" /* Skip list routines */ /* Local Macros */ /* 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 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 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 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) +#define H5SL_LOCATE_SCALAR_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) /* Define a code template for comparing string keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) ? \ - (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) < 0) : \ - ((PNODE)->hashval < HASHVAL)) +#define H5SL_LOCATE_STRING_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + (((PNODE)->hashval == HASHVAL) ? (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) < 0) \ + : ((PNODE)->hashval < HASHVAL)) /* Define a code template for comparing H5_obj_t keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_OBJ_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) \ - ? (((TYPE *)((PNODE)->key))->addr < ((TYPE *)PKEY)->addr) \ - : (((TYPE *)((PNODE)->key))->fileno < ((TYPE *)PKEY)->fileno)) +#define H5SL_LOCATE_OBJ_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) \ + ? (((TYPE *)((PNODE)->key))->addr < ((TYPE *)PKEY)->addr) \ + : (((TYPE *)((PNODE)->key))->fileno < ((TYPE *)PKEY)->fileno)) /* Define a code template for comparing generic keys for the "CMP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_GENERIC_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) < 0) - +#define H5SL_LOCATE_GENERIC_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) < 0) /* Define a code template for comparing scalar keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SCALAR_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (*(TYPE *)((PNODE)->key) == *(TYPE *)PKEY) +#define H5SL_LOCATE_SCALAR_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) == *(TYPE *)PKEY) /* Define a code template for comparing string keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) && (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) == 0)) +#define H5SL_LOCATE_STRING_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + (((PNODE)->hashval == HASHVAL) && (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) == 0)) /* Define a code template for comparing H5_obj_t keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_OBJ_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) && (((TYPE *)((PNODE)->key))->addr == ((TYPE *)PKEY)->addr)) +#define H5SL_LOCATE_OBJ_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((((TYPE *)((PNODE)->key))->fileno == ((TYPE *)PKEY)->fileno) && \ + (((TYPE *)((PNODE)->key))->addr == ((TYPE *)PKEY)->addr)) /* Define a code template for comparing generic keys for the "EQ" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_GENERIC_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ - ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) == 0) +#define H5SL_LOCATE_GENERIC_EQ(SLIST, TYPE, PNODE, PKEY, HASHVAL) \ + ((SLIST)->cmp((TYPE *)((PNODE)->key), (TYPE *)PKEY) == 0) - -/* Define a code template for initializing the hash value for scalar keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for scalar keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_HASHINIT(KEY, HASHVAL) -/* Define a code template for initializing the hash value for string keys for the "HASHINIT" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_STRING_HASHINIT(KEY, HASHVAL) \ - HASHVAL = H5_hash_string((const char *)KEY); +/* Define a code template for initializing the hash value for string keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ +#define H5SL_LOCATE_STRING_HASHINIT(KEY, HASHVAL) HASHVAL = H5_hash_string((const char *)KEY); -/* Define a code template for initializing the hash value for H5_obj_t keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for H5_obj_t keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_OBJ_HASHINIT(KEY, HASHVAL) -/* Define a code template for initializing the hash value for generic keys for the "HASHINIT" in the H5SL_LOCATE macro */ +/* Define a code template for initializing the hash value for generic keys for the "HASHINIT" in the + * H5SL_LOCATE macro */ #define H5SL_LOCATE_GENERIC_HASHINIT(KEY, HASHVAL) - /* Macro used to find node for operation, if all keys are valid */ -#define H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - int _i; /* Local index variable */ \ - unsigned _count; /* Num nodes searched at this height */ \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - _count = 0; \ - while(_count < 3 && X->forward[_i] && \ - 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 */ \ -} +#define H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + int _i; /* Local index variable */ \ + unsigned _count; /* Num nodes searched at this height */ \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ + { \ + _count = 0; \ + while (_count < 3 && X->forward[_i] && \ + 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 */ \ -} +#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) \ -} - +#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) \ + } /* Macro used to grow a node by 1. Does not update pointers. LVL is the current * level of X. Does not update LVL but does update X->lvl. */ -#define H5SL_GROW(X, LVL, ERR) \ -{ \ - /* Check if we need to increase allocation of forward pointers */ \ - if(LVL + 1 >= 1u << X->log_nalloc) { \ - H5SL_node_t **_tmp; \ - HDassert(LVL + 1 == 1u << X->log_nalloc); \ - /* Double the amount of allocated space */ \ - X->log_nalloc++; \ - \ - /* Check if we need to create a new factory */ \ - if(X->log_nalloc >= H5SL_fac_nused_g) { \ - HDassert(X->log_nalloc == H5SL_fac_nused_g); \ - \ - /* Check if we need to allocate space for the factory pointer*/ \ - if(H5SL_fac_nused_g >= H5SL_fac_nalloc_g) { \ - HDassert(H5SL_fac_nused_g == H5SL_fac_nalloc_g); \ - /* Double the size of the array of factory pointers */ \ - H5SL_fac_nalloc_g *= 2; \ - 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]))) \ - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ - 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++; \ -} - +#define H5SL_GROW(X, LVL, ERR) \ + { \ + /* Check if we need to increase allocation of forward pointers */ \ + if (LVL + 1 >= 1u << X->log_nalloc) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL + 1 == 1u << X->log_nalloc); \ + /* Double the amount of allocated space */ \ + X->log_nalloc++; \ + \ + /* Check if we need to create a new factory */ \ + if (X->log_nalloc >= H5SL_fac_nused_g) { \ + HDassert(X->log_nalloc == H5SL_fac_nused_g); \ + \ + /* Check if we need to allocate space for the factory pointer*/ \ + if (H5SL_fac_nused_g >= H5SL_fac_nalloc_g) { \ + HDassert(H5SL_fac_nused_g == H5SL_fac_nalloc_g); \ + /* Double the size of the array of factory pointers */ \ + H5SL_fac_nalloc_g *= 2; \ + 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]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ + 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++; \ + } /* Macro used to shrink a node by 1. Does not update pointers. LVL is the * current level of X. Does not update LVL but does update X->level. */ -#define H5SL_SHRINK(X, LVL) \ -{ \ - /* Check if we can reduce the allocation of forward pointers */ \ - if(LVL <= 1u << (X->log_nalloc - 1)) { \ - H5SL_node_t **_tmp; \ - HDassert(LVL == 1u << (X->log_nalloc - 1)); \ - X->log_nalloc--; \ - \ - /* Allocate space for new forward pointers */ \ - if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ - HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ - 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--; \ -} - +#define H5SL_SHRINK(X, LVL) \ + { \ + /* Check if we can reduce the allocation of forward pointers */ \ + if (LVL <= 1u << (X->log_nalloc - 1)) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL == 1u << (X->log_nalloc - 1)); \ + X->log_nalloc--; \ + \ + /* Allocate space for new forward pointers */ \ + if (NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ + 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--; \ + } /* Macro used to grow the level of a node by 1, with appropriate changes to the * head node if necessary. PREV is the previous node of the height that X is to * grow to. */ -#define H5SL_PROMOTE(SLIST, X, PREV, ERR) \ -{ \ - size_t _lvl = X->level; \ - \ - H5SL_GROW(X, _lvl, ERR); \ - \ - if(_lvl == (size_t) SLIST->curr_level) { \ - HDassert(PREV == SLIST->header); \ - /* Grow the head */ \ - H5SL_GROW(PREV, _lvl, ERR) \ - SLIST->curr_level++; \ - X->forward[_lvl+1] = NULL; \ - } else { \ - HDassert(_lvl < (size_t) SLIST->curr_level); \ - X->forward[_lvl+1] = PREV->forward[_lvl+1]; \ - } /* end else */ \ - PREV->forward[_lvl+1] = X; \ -} - +#define H5SL_PROMOTE(SLIST, X, PREV, ERR) \ + { \ + size_t _lvl = X->level; \ + \ + H5SL_GROW(X, _lvl, ERR); \ + \ + if (_lvl == (size_t)SLIST->curr_level) { \ + HDassert(PREV == SLIST->header); \ + /* Grow the head */ \ + H5SL_GROW(PREV, _lvl, ERR) \ + SLIST->curr_level++; \ + X->forward[_lvl + 1] = NULL; \ + } \ + else { \ + HDassert(_lvl < (size_t)SLIST->curr_level); \ + X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ + } /* end else */ \ + PREV->forward[_lvl + 1] = X; \ + } /* Macro used to reduce the level of a node by 1. Does not update the head node * "current level". PREV is the previous node of the currrent height of X. */ -#define H5SL_DEMOTE(X, PREV) \ -{ \ - size_t _lvl = X->level; \ - \ - HDassert(PREV->forward[_lvl] == X); \ - PREV->forward[_lvl] = X->forward[_lvl]; \ - H5SL_SHRINK(X, _lvl); \ -} - +#define H5SL_DEMOTE(X, PREV) \ + { \ + size_t _lvl = X->level; \ + \ + HDassert(PREV->forward[_lvl] == X); \ + PREV->forward[_lvl] = X->forward[_lvl]; \ + H5SL_SHRINK(X, _lvl); \ + } /* Macro used to insert node. Does not actually insert the node. After running * this macro, X will contain the node before where the new node should be * inserted (at level 0). */ -#define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ -{ \ - H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ - H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ - int _count; /* Number of nodes in the current gap */ \ - int _i; \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - /* Search for the node to drop into, also count the number of nodes */ \ - /* of height _i in this gap */ \ - _drop = NULL; \ - for(_count = 0; ; _count++) { \ - /* Terminate if this is the last node in the gap */ \ - if(X->forward[_i] == _next) { \ - if(!_drop) \ - _drop = X; \ - break; \ - } /* end if */ \ - \ - /* Check if this node is the start of the next gap */ \ - if(!_drop && !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ - _drop = X; \ - \ - /* No need to check the last node in the gap if there are 3, as */ \ - /* there cannot be a fourth */ \ - if(_count == 2) { \ - if(!_drop) \ - _drop = X->forward[_i]; \ - _count = 3; \ - break; \ - } \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ - \ - /* Promote the middle node if necessary */ \ - if(_count == 3) { \ - HDassert(X == _last->forward[_i]->forward[_i]); \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ - } \ - \ - /* 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") \ -} - +#define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + { \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i; \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ + { \ + /* Search for the node to drop into, also count the number of nodes */ \ + /* of height _i in this gap */ \ + _drop = NULL; \ + for (_count = 0;; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if (X->forward[_i] == _next) { \ + if (!_drop) \ + _drop = X; \ + break; \ + } /* end if */ \ + \ + /* Check if this node is the start of the next gap */ \ + if (!_drop && !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ + _drop = X; \ + \ + /* No need to check the last node in the gap if there are 3, as */ \ + /* there cannot be a fourth */ \ + if (_count == 2) { \ + if (!_drop) \ + _drop = X->forward[_i]; \ + _count = 3; \ + break; \ + } \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + \ + /* Promote the middle node if necessary */ \ + if (_count == 3) { \ + HDassert(X == _last->forward[_i]->forward[_i]); \ + H5SL_PROMOTE(SLIST, X, _last, NULL) \ + } \ + \ + /* 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") \ + } /* 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; \ - \ - if(_i < 0) \ - HGOTO_DONE(NULL); \ - \ - H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ - \ - /* Find the gap to drop in to at the highest level */ \ - while(X && (!X->key || H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(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 */ \ - \ - /* 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; \ - } /* end if */ \ - } /* end if */ \ - else \ - _ldrop = X; \ - } /* end else */ \ - \ - /* No need to check the last node in the gap if there are */ \ - /* 3, as there cannot be a fourth */ \ - if(_count == 2) { \ - if(!_drop) \ - _drop = X->forward[_i]; \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(_count >= 1 && _count <= 3); \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(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]; \ - \ - /* 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); \ - \ - H5SL_SHRINK(_head, (size_t) (_i+1)) \ - SLIST->curr_level--; \ - } /* end else */ \ - } else { \ - /* We are not in the first gap, count the number of */ \ - /* nodes of height _i in the previous gap. Note we */ \ - /* "look ahead" in this loop so X has the value of the */ \ - /* last node in the previous gap. */ \ - X = _llast->forward[_i]; \ - for(_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ - X = X->forward[_i]; \ - HDassert(X->forward[_i] == _last); \ - \ - /* Demote the separator node */ \ - H5SL_DEMOTE(_last, _llast) \ - \ - /* If there are 2 or more nodes, promote the last */ \ - if(_count >= 2) \ - H5SL_PROMOTE(SLIST, X, _llast, 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 */ \ - \ - /* Prepare to drop down */ \ - _llast = _ldrop; \ - _last = _drop; \ - _next = _drop->forward[_i]; \ - } /* end for */ \ - \ - /* Check if we've found the node */ \ - if(_next && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(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); \ - \ - /* 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 */ \ -} - +#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; \ + \ + if (_i < 0) \ + HGOTO_DONE(NULL); \ + \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) \ + \ + /* Find the gap to drop in to at the highest level */ \ + while (X && (!X->key || H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(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 */ \ + \ + /* 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; \ + } /* end if */ \ + } /* end if */ \ + else \ + _ldrop = X; \ + } /* end else */ \ + \ + /* No need to check the last node in the gap if there are */ \ + /* 3, as there cannot be a fourth */ \ + if (_count == 2) { \ + if (!_drop) \ + _drop = X->forward[_i]; \ + break; \ + } /* end if */ \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(_count >= 1 && _count <= 3); \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(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]; \ + \ + /* 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); \ + \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ + } /* end else */ \ + } \ + else { \ + /* We are not in the first gap, count the number of */ \ + /* nodes of height _i in the previous gap. Note we */ \ + /* "look ahead" in this loop so X has the value of the */ \ + /* last node in the previous gap. */ \ + X = _llast->forward[_i]; \ + for (_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ + X = X->forward[_i]; \ + HDassert(X->forward[_i] == _last); \ + \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_last, _llast) \ + \ + /* If there are 2 or more nodes, promote the last */ \ + if (_count >= 2) \ + H5SL_PROMOTE(SLIST, X, _llast, 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 */ \ + \ + /* Prepare to drop down */ \ + _llast = _ldrop; \ + _last = _drop; \ + _next = _drop->forward[_i]; \ + } /* end for */ \ + \ + /* Check if we've found the node */ \ + if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(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); \ + \ + /* 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 */ \ + } /* Macro used to search for node */ -#define H5SL_SEARCH(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(SEARCH, CMP, SLIST, X, TYPE, KEY, HASHVAL) +#define H5SL_SEARCH(CMP, SLIST, X, TYPE, KEY, HASHVAL) H5SL_LOCATE(SEARCH, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Macro used to find a node */ -#define H5SL_FIND(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(FIND, CMP, SLIST, X, TYPE, KEY, HASHVAL) - +#define H5SL_FIND(CMP, SLIST, X, TYPE, KEY, HASHVAL) H5SL_LOCATE(FIND, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Private typedefs & structs */ /* Skip list node data structure */ struct H5SL_node_t { - const void *key; /* Pointer to node's key */ - void *item; /* Pointer to node's item */ - size_t level; /* The level of this node */ - size_t log_nalloc; /* log2(Number of slots allocated in forward) */ - uint32_t hashval; /* Hash value for key (only for strings, currently) */ - 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 */ + 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 */ }; /* Main skip list data structure */ struct H5SL_t { /* Static values for each list */ - H5SL_type_t type; /* Type of skip list */ - H5SL_cmp_t cmp; /* Comparison callback, if type is H5SL_TYPE_GENERIC */ + H5SL_type_t type; /* Type of skip list */ + H5SL_cmp_t cmp; /* Comparison callback, if type is H5SL_TYPE_GENERIC */ /* Dynamic values for each list */ - int curr_level; /* Current top level used in list */ - 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 */ + int curr_level; /* Current top level used in list */ + 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 */ -static H5SL_node_t * H5SL_new_node(void *item, const void *key, uint32_t hashval); -static H5SL_node_t *H5SL_insert_common(H5SL_t *slist, void *item, const void *key); -static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); -static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); +static H5SL_node_t *H5SL__new_node(void *item, const void *key, uint32_t hashval); +static H5SL_node_t *H5SL__insert_common(H5SL_t *slist, void *item, const void *key); +static herr_t H5SL__release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); +static herr_t H5SL__close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; @@ -584,10 +579,9 @@ H5FL_DEFINE_STATIC(H5SL_node_t); /* Global variables */ static H5FL_fac_head_t **H5SL_fac_g; -static size_t H5SL_fac_nused_g; -static size_t H5SL_fac_nalloc_g; +static size_t H5SL_fac_nused_g; +static size_t H5SL_fac_nalloc_g; - /*-------------------------------------------------------------------------- NAME H5SL__init_package @@ -622,7 +616,6 @@ H5SL__init_package(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL__init_package() */ - /*-------------------------------------------------------------------------- NAME H5SL_term_package @@ -633,7 +626,7 @@ H5SL__init_package(void) RETURNS Success: Positive if any action might have caused a change in some other interface; zero otherwise. - Failure: Negative + Failure: Negative DESCRIPTION Release any resources allocated. GLOBAL VARIABLES @@ -642,19 +635,20 @@ H5SL__init_package(void) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -int H5SL_term_package(void) +int +H5SL_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Terminate all the factories */ - if(H5SL_fac_nused_g > 0) { - size_t i; - herr_t H5_ATTR_NDEBUG_UNUSED ret; + if (H5SL_fac_nused_g > 0) { + size_t i; + herr_t H5_ATTR_NDEBUG_UNUSED ret; - for(i = 0; i < H5SL_fac_nused_g; i++) { + for (i = 0; i < H5SL_fac_nused_g; i++) { ret = H5FL_fac_term(H5SL_fac_g[i]); HDassert(ret >= 0); } /* end if */ @@ -664,29 +658,28 @@ int H5SL_term_package(void) } /* end if */ /* Free the list of factories */ - if(H5SL_fac_g) { - H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); + if (H5SL_fac_g) { + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); H5SL_fac_nalloc_g = 0; n++; } /* end if */ /* Mark the interface as uninitialized */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5SL_term_package() */ - /*-------------------------------------------------------------------------- NAME - H5SL_new_node + H5SL__new_node PURPOSE Create a new skip list node of level 0 USAGE - H5SL_node_t *H5SL_new_node(item,key,hasval) + H5SL_node_t *H5SL__new_node(item,key,hasval) void *item; IN: Pointer to item info for node void *key; IN: Pointer to key info for node uint32_t hashval; IN: Hash value for node @@ -703,23 +696,23 @@ int H5SL_term_package(void) REVISION LOG --------------------------------------------------------------------------*/ static H5SL_node_t * -H5SL_new_node(void *item, const void *key, uint32_t hashval) +H5SL__new_node(void *item, const void *key, uint32_t hashval) { - H5SL_node_t *ret_value = NULL; /* New skip list node */ + H5SL_node_t *ret_value = NULL; /* New skip list node */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Allocate the node */ - if(NULL == (ret_value = (H5SL_node_t *)H5FL_MALLOC(H5SL_node_t))) + if (NULL == (ret_value = (H5SL_node_t *)H5FL_MALLOC(H5SL_node_t))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") /* Initialize node */ - ret_value->key = key; - ret_value->item = item; - ret_value->level = 0; + ret_value->key = key; + 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]))) { + 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 */ @@ -727,16 +720,15 @@ H5SL_new_node(void *item, const void *key, uint32_t hashval) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_new_node() */ +} /* end H5SL__new_node() */ - /*-------------------------------------------------------------------------- NAME - H5SL_insert_common + H5SL__insert_common PURPOSE Common code for inserting an object into a skip list USAGE - H5SL_node_t *H5SL_insert_common(slist,item,key) + H5SL_node_t *H5SL__insert_common(slist,item,key) H5SL_t *slist; IN/OUT: Pointer to skip list void *item; IN: Item to insert void *key; IN: Key for item to insert @@ -752,14 +744,14 @@ H5SL_new_node(void *item, const void *key, uint32_t hashval) REVISION LOG --------------------------------------------------------------------------*/ static H5SL_node_t * -H5SL_insert_common(H5SL_t *slist, void *item, const void *key) +H5SL__insert_common(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - H5SL_node_t *prev; /* Node before the new node */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + H5SL_node_t *prev; /* Node before the new node */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(slist); @@ -773,8 +765,8 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - prev=slist->header; - switch(slist->type) { + prev = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_INSERT(SCALAR, slist, prev, const int, key, -) break; @@ -815,21 +807,20 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) HDassert(0 && "Unknown skiplist type!"); } /* end switch */ - /* 'key' must not have been found in existing list, if we get here */ - if(slist->curr_level < 0) + if (slist->curr_level < 0) slist->curr_level = 0; /* Create new node of level 0 */ - if(NULL == (x = H5SL_new_node(item, key, hashval))) - HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") + if (NULL == (x = H5SL__new_node(item, key, hashval))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "can't create new skip list node") /* Update the links */ - x->backward = prev; - x->forward[0] = prev->forward[0]; + x->backward = prev; + x->forward[0] = prev->forward[0]; prev->forward[0] = x; - if(x->forward[0]) + if (x->forward[0]) x->forward[0]->backward = x; else { HDassert(slist->last == prev); @@ -840,20 +831,19 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) slist->nobjs++; /* Set return value */ - ret_value=x; + ret_value = x; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_insert_common() */ +} /* end H5SL__insert_common() */ - /*-------------------------------------------------------------------------- NAME - H5SL_release_common + H5SL__release_common PURPOSE Release all nodes from a skip list, optionally calling a 'free' operator USAGE - herr_t H5SL_release_common(slist,op,opdata) + herr_t H5SL__release_common(slist,op,opdata) H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback @@ -872,12 +862,12 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) +H5SL__release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ - herr_t ret_value = SUCCEED; + H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(slist); @@ -887,46 +877,46 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Free skip list nodes */ node = slist->header->forward[0]; - while(node) { + while (node) { next_node = node->forward[0]; /* Call callback, if one is given */ - if(op) + if (op) /* Casting away const OK -QAK */ (void)(op)(node->item, (void *)node->key, op_data); 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; + node = H5FL_FREE(H5SL_node_t, node); + node = next_node; } /* end while */ /* Reset the header pointers */ - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); - if(NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + slist->header->forward = + (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + if (NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, FAIL, "memory allocation failed") slist->header->forward[0] = NULL; slist->header->log_nalloc = 0; - slist->header->level = 0; + slist->header->level = 0; /* Reset the last pointer */ slist->last = slist->header; /* Reset the dynamic internal fields */ slist->curr_level = -1; - slist->nobjs = 0; + slist->nobjs = 0; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_release_common() */ +} /* end H5SL__release_common() */ - /*-------------------------------------------------------------------------- NAME - H5SL_close_common + H5SL__close_common PURPOSE Close a skip list, deallocating it and potentially freeing all its nodes. USAGE - herr_t H5SL_close_common(slist,op,opdata) + herr_t H5SL__close_common(slist,op,opdata) H5SL_t *slist; IN/OUT: Pointer to skip list to close H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback @@ -944,11 +934,11 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) +H5SL__close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(slist); @@ -957,11 +947,12 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Free skip list nodes */ - if(H5SL_release_common(slist, op, op_data) < 0) + if (H5SL__release_common(slist, op, op_data) < 0) HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") /* Release header node */ - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + slist->header->forward = + (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); slist->header = H5FL_FREE(H5SL_node_t, slist->header); /* Free skip list object */ @@ -969,9 +960,8 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_close_common() */ +} /* end H5SL__close_common() */ - /*-------------------------------------------------------------------------- NAME H5SL_create @@ -992,9 +982,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_node_t *header; /* Pointer to skip list header node */ - H5SL_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_NOAPI(NULL) @@ -1002,7 +992,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) HDassert(type >= H5SL_TYPE_INT && type <= H5SL_TYPE_GENERIC); /* Allocate skip list structure */ - if(NULL == (new_slist = H5FL_MALLOC(H5SL_t))) + if (NULL == (new_slist = H5FL_MALLOC(H5SL_t))) HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the static internal fields */ @@ -1011,13 +1001,13 @@ 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->curr_level = -1; + new_slist->nobjs = 0; new_slist->safe_iterating = FALSE; /* Allocate the header node */ - if(NULL == (header = H5SL_new_node(NULL, NULL, (uint32_t)ULONG_MAX))) - HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") + if (NULL == (header = H5SL__new_node(NULL, NULL, (uint32_t)ULONG_MAX))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "can't create new skip list node") /* Initialize header node's forward pointer */ header->forward[0] = NULL; @@ -1027,22 +1017,21 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) /* Attach the header */ new_slist->header = header; - new_slist->last = header; + new_slist->last = header; /* Set the return value */ ret_value = new_slist; done: /* Error cleanup */ - if(ret_value == NULL) { - if(new_slist != NULL) + 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() */ - /*-------------------------------------------------------------------------- NAME H5SL_count @@ -1078,7 +1067,6 @@ H5SL_count(H5SL_t *slist) FUNC_LEAVE_NOAPI(slist->nobjs) } /* end H5SL_count() */ - /*-------------------------------------------------------------------------- NAME H5SL_insert @@ -1103,7 +1091,7 @@ H5SL_count(H5SL_t *slist) herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1118,14 +1106,13 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) /* (Pre-condition) */ /* Insert item into skip list */ - if(H5SL_insert_common(slist,item,key)==NULL) - HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,FAIL,"can't create new skip list node") + if (NULL == H5SL__insert_common(slist, item, key)) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, FAIL, "can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_insert() */ - /*-------------------------------------------------------------------------- NAME H5SL_add @@ -1153,7 +1140,7 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) H5SL_node_t * H5SL_add(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1168,14 +1155,13 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) /* (Pre-condition) */ /* Insert item into skip list */ - if((ret_value=H5SL_insert_common(slist,item,key))==NULL) - HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,NULL,"can't create new skip list node") + if (NULL == (ret_value = H5SL__insert_common(slist, item, key))) + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't create new skip list node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_add() */ - /*-------------------------------------------------------------------------- NAME H5SL_remove @@ -1198,9 +1184,9 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) void * 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 */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1217,7 +1203,7 @@ H5SL_remove(H5SL_t *slist, const void *key) * level that is before the location to remove */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_REMOVE(SCALAR, slist, x, const int, key, -) break; @@ -1262,7 +1248,6 @@ H5SL_remove(H5SL_t *slist, const void *key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_remove() */ - /*-------------------------------------------------------------------------- NAME H5SL_remove_first @@ -1284,12 +1269,12 @@ H5SL_remove(H5SL_t *slist, const void *key) void * H5SL_remove_first(H5SL_t *slist) { - void *ret_value = NULL; /* Return value */ - H5SL_node_t *head = slist->header; /* Skip list header */ - H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ - H5SL_node_t *next; /* Next node to search for */ - size_t level; /* Skip list level */ - size_t i; /* Index */ + void * ret_value = NULL; /* Return value */ + H5SL_node_t *head = slist->header; /* Skip list header */ + H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ + H5SL_node_t *next; /* Next node to search for */ + size_t level; /* Skip list level */ + size_t i; /* Index */ FUNC_ENTER_NOAPI_NOINIT @@ -1309,7 +1294,7 @@ H5SL_remove_first(H5SL_t *slist) /* Remove item from skip list */ /* Check for empty list */ - if(slist->last != slist->header) { + if (slist->last != slist->header) { /* Assign return value */ ret_value = tmp->item; @@ -1318,58 +1303,59 @@ H5SL_remove_first(H5SL_t *slist) /* Remove the first node */ head->forward[0] = tmp->forward[0]; - if(slist->last == tmp) + if (slist->last == tmp) slist->last = head; else tmp->forward[0]->backward = head; slist->nobjs--; /* Free memory */ tmp->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], tmp->forward); - tmp = H5FL_FREE(H5SL_node_t, tmp); + tmp = H5FL_FREE(H5SL_node_t, tmp); /* Reshape the skip list as necessary to maintain 1-2-3 condition */ - for(i=0; i < level; i++) { - next = head->forward[i+1]; + for (i = 0; i < level; i++) { + next = head->forward[i + 1]; HDassert(next); /* Check if head->forward[i] == head->forward[i+1] (illegal) */ - if(head->forward[i] == next) { - tmp = next; - next = next->forward[i+1]; + if (head->forward[i] == next) { + tmp = next; + next = next->forward[i + 1]; - HDassert(tmp->level == i+1); + HDassert(tmp->level == i + 1); /* Demote head->forward[i] */ H5SL_DEMOTE(tmp, head) /* Check if we need to promote the following node to maintain * 1-2-3 condition */ - if(tmp->forward[i]->forward[i] != next) { + if (tmp->forward[i]->forward[i] != next) { HDassert(tmp->forward[i]->forward[i]->forward[i] == next || - tmp->forward[i]->forward[i]->forward[i]->forward[i] == next); + tmp->forward[i]->forward[i]->forward[i]->forward[i] == next); tmp = tmp->forward[i]; H5SL_PROMOTE(slist, tmp, head, NULL); /* In this case, since there is a node of height = i+1 here * now (tmp), we know the skip list must be valid and can * break */ break; - } else if(!head->forward[i+1]) { + } + else if (!head->forward[i + 1]) { /* We just shrunk the largest node, shrink the header */ HDassert(i == level - 1); H5SL_SHRINK(head, level) slist->curr_level--; } /* end else */ - } else + } + else break; } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_remove_first() */ - /*-------------------------------------------------------------------------- NAME H5SL_search @@ -1392,9 +1378,9 @@ H5SL_remove_first(H5SL_t *slist) void * 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; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1410,8 +1396,8 @@ H5SL_search(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1453,13 +1439,12 @@ H5SL_search(H5SL_t *slist, const void *key) } /* end switch */ /* 'key' must not have been found in list, if we get here */ - ret_value=NULL; + ret_value = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_search() */ - /*-------------------------------------------------------------------------- NAME H5SL_less @@ -1485,9 +1470,9 @@ H5SL_search(H5SL_t *slist, const void *key) void * 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 */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1506,8 +1491,8 @@ H5SL_less(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1550,25 +1535,24 @@ H5SL_less(H5SL_t *slist, const void *key) /* 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' */ - if(x==NULL) { + if (x == NULL) { /* Check for walking off the list */ - if(slist->last!=slist->header) - ret_value=slist->last->item; + if (slist->last != slist->header) + ret_value = slist->last->item; else - ret_value=NULL; + ret_value = NULL; } /* end if */ else { - if(x->backward!=slist->header) - ret_value=x->backward->item; + if (x->backward != slist->header) + ret_value = x->backward->item; else - ret_value=NULL; + ret_value = NULL; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_less() */ - /*-------------------------------------------------------------------------- NAME H5SL_greater @@ -1594,9 +1578,9 @@ H5SL_less(H5SL_t *slist, const void *key) void * 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 */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1616,7 +1600,7 @@ H5SL_greater(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; @@ -1659,7 +1643,7 @@ H5SL_greater(H5SL_t *slist, const void *key) /* 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) */ - if(x) + if (x) ret_value = x->item; else ret_value = NULL; @@ -1668,7 +1652,6 @@ H5SL_greater(H5SL_t *slist, const void *key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_greater() */ - /*-------------------------------------------------------------------------- NAME H5SL_find @@ -1693,9 +1676,9 @@ H5SL_greater(H5SL_t *slist, const void *key) H5SL_node_t * H5SL_find(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1711,8 +1694,8 @@ H5SL_find(H5SL_t *slist, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; - switch(slist->type) { + x = slist->header; + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1754,13 +1737,12 @@ H5SL_find(H5SL_t *slist, const void *key) } /* end switch */ /* 'key' must not have been found in list, if we get here */ - ret_value=NULL; + ret_value = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_find() */ - /*-------------------------------------------------------------------------- NAME H5SL_below @@ -1786,9 +1768,9 @@ H5SL_find(H5SL_t *slist, const void *key) H5SL_node_t * H5SL_below(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1805,7 +1787,7 @@ H5SL_below(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1848,15 +1830,15 @@ H5SL_below(H5SL_t *slist, const void *key) /* 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' */ - if(NULL == x) { + if (NULL == x) { /* Check for walking off the list */ - if(slist->last != slist->header) + if (slist->last != slist->header) ret_value = slist->last; else ret_value = NULL; } /* end if */ else { - if(x->backward != slist->header) + if (x->backward != slist->header) ret_value = x->backward; else ret_value = NULL; @@ -1866,7 +1848,6 @@ H5SL_below(H5SL_t *slist, const void *key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_below() */ - /*-------------------------------------------------------------------------- NAME H5SL_above @@ -1892,9 +1873,9 @@ H5SL_below(H5SL_t *slist, const void *key) H5SL_node_t * H5SL_above(H5SL_t *slist, const void *key) { - H5SL_node_t *x; /* Current node to examine */ - uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value = NULL; /* Return value */ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1911,7 +1892,7 @@ H5SL_above(H5SL_t *slist, const void *key) * level that is before the location to insert */ x = slist->header; - switch(slist->type) { + switch (slist->type) { case H5SL_TYPE_INT: H5SL_FIND(SCALAR, slist, x, const int, key, -) break; @@ -1954,7 +1935,7 @@ H5SL_above(H5SL_t *slist, const void *key) /* 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) */ - if(x) + if (x) ret_value = x; else ret_value = NULL; @@ -1963,7 +1944,6 @@ H5SL_above(H5SL_t *slist, const void *key) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_above() */ - /*-------------------------------------------------------------------------- NAME H5SL_first @@ -2000,7 +1980,6 @@ H5SL_first(H5SL_t *slist) FUNC_LEAVE_NOAPI(slist->header->forward[0]) } /* end H5SL_first() */ - /*-------------------------------------------------------------------------- NAME H5SL_next @@ -2037,7 +2016,6 @@ H5SL_next(H5SL_node_t *slist_node) FUNC_LEAVE_NOAPI(slist_node->forward[0]) } /* end H5SL_next() */ - /*-------------------------------------------------------------------------- NAME H5SL_prev @@ -2072,10 +2050,9 @@ H5SL_prev(H5SL_node_t *slist_node) /* (Pre-condition) */ /* Walk backward, detecting the header node (which has it's key set to NULL) */ - FUNC_LEAVE_NOAPI(slist_node->backward->key==NULL ? NULL : slist_node->backward) + FUNC_LEAVE_NOAPI(slist_node->backward->key == NULL ? NULL : slist_node->backward) } /* end H5SL_prev() */ - /*-------------------------------------------------------------------------- NAME H5SL_last @@ -2110,10 +2087,9 @@ H5SL_last(H5SL_t *slist) /* (Pre-condition) */ /* Find last node, avoiding the header node */ - FUNC_LEAVE_NOAPI(slist->last==slist->header ? NULL : slist->last) + FUNC_LEAVE_NOAPI(slist->last == slist->header ? NULL : slist->last) } /* end H5SL_last() */ - /*-------------------------------------------------------------------------- NAME H5SL_item @@ -2149,7 +2125,6 @@ H5SL_item(H5SL_node_t *slist_node) FUNC_LEAVE_NOAPI(slist_node->item) } /* end H5SL_item() */ - /*-------------------------------------------------------------------------- NAME H5SL_iterate @@ -2186,9 +2161,9 @@ H5SL_item(H5SL_node_t *slist_node) herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - H5SL_node_t *node; /* Pointer to current skip list node */ - H5SL_node_t *next; /* Pointer to next skip list node */ - herr_t ret_value = 0; /* Return value */ + H5SL_node_t *node; /* Pointer to current skip list node */ + H5SL_node_t *next; /* Pointer to next skip list node */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2200,14 +2175,14 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Free skip list nodes */ node = slist->header->forward[0]; - while(node != NULL) { + while (node != NULL) { /* 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) + if (!node->removed) + if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) break; /* Advance to next node */ @@ -2217,7 +2192,6 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_iterate() */ - /*-------------------------------------------------------------------------- NAME H5SL_release @@ -2241,7 +2215,9 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) herr_t H5SL_release(H5SL_t *slist) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(slist); @@ -2253,12 +2229,13 @@ H5SL_release(H5SL_t *slist) /* (Pre-condition) */ /* Free skip list nodes */ - H5SL_release_common(slist,NULL,NULL); /* always succeeds */ + if (H5SL__release_common(slist, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") +done: FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_release() */ - /*-------------------------------------------------------------------------- NAME H5SL_free @@ -2290,7 +2267,9 @@ H5SL_release(H5SL_t *slist) herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(slist); @@ -2302,12 +2281,13 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Free skip list nodes */ - H5SL_release_common(slist,op,op_data); /* always succeeds */ + if (H5SL__release_common(slist, op, op_data) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_free() */ - /*-------------------------------------------------------------------------- NAME H5SL_try_free_safe @@ -2339,8 +2319,8 @@ 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; + htri_t op_ret; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -2361,16 +2341,16 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* 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) { + while (node) { /* Check if the node was already removed */ - if(!node->removed) { + if (!node->removed) { /* Call callback */ /* Casting away const OK -NAF */ - if((op_ret = (op)(node->item , (void *)node->key, op_data)) < 0) + 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) + if (op_ret) /* Mark the node as removed */ node->removed = TRUE; } /* end if */ @@ -2383,17 +2363,17 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) slist->safe_iterating = FALSE; /* Iterate over nodes, freeing ones marked as removed */ - node = slist->header->forward[0]; + node = slist->header->forward[0]; last_node = slist->header; - while(node) { + while (node) { /* Save next node */ next_node = node->forward[0]; /* Check if the node was marked as removed */ - if(node->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); + node = H5FL_FREE(H5SL_node_t, node); slist->nobjs--; } /* end if */ else { @@ -2403,18 +2383,19 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* 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]))) + 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; + node->level = 0; } /* end if */ /* Update pointers */ last_node->forward[0] = node; - node->backward = last_node; - last_node = node; + node->backward = last_node; + last_node = node; } /* end else */ /* Advance node */ @@ -2423,23 +2404,24 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) /* Final pointer update */ last_node->forward[0] = NULL; - slist->last = last_node; + slist->last = last_node; /* Demote skip list to level 0 */ - if(slist->curr_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]))) + 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; + slist->header->level = 0; } /* end if */ /* Check if there are any nodes left */ - if(slist->nobjs > 0) { + if (slist->nobjs > 0) { int i; HDassert(slist->header->forward[0]); @@ -2448,31 +2430,31 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) slist->curr_level = 0; /* Rebuild the forward arrays */ - for(i = 0; slist->curr_level >= i; i++) { + 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) { + 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) + 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]) + 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 */ + } /* end for */ + } /* end if */ else { HDassert(!slist->header->forward[0]); HDassert(slist->last == slist->header); @@ -2486,7 +2468,6 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_try_free_safe() */ - /*-------------------------------------------------------------------------- NAME H5SL_destroy @@ -2516,9 +2497,9 @@ H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(slist); @@ -2527,12 +2508,13 @@ H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Close skip list */ - (void)H5SL_close_common(slist,op,op_data); /* always succeeds */ + if (H5SL__close_common(slist, op, op_data) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_destroy() */ - /*-------------------------------------------------------------------------- NAME H5SL_close @@ -2555,7 +2537,9 @@ H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data) herr_t H5SL_close(H5SL_t *slist) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT /* Check args */ HDassert(slist); @@ -2564,8 +2548,9 @@ H5SL_close(H5SL_t *slist) /* (Pre-condition) */ /* Close skip list */ - (void)H5SL_close_common(slist,NULL,NULL); /* always succeeds */ + if (H5SL__close_common(slist, NULL, NULL) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_close() */ - diff --git a/src/H5SLmodule.h b/src/H5SLmodule.h index 335e35bdb9a..2614f92eb11 100644 --- a/src/H5SLmodule.h +++ b/src/H5SLmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5SL package. Including this header means that the source file * is part of the H5SL package. */ -#ifndef _H5SLmodule_H -#define _H5SLmodule_H +#ifndef H5SLmodule_H +#define H5SLmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5SL_MODULE -#define H5_MY_PKG H5SL -#define H5_MY_PKG_ERR H5E_SLIST -#define H5_MY_PKG_INIT YES - -#endif /* _H5SLmodule_H */ +#define H5_MY_PKG H5SL +#define H5_MY_PKG_ERR H5E_SLIST +#define H5_MY_PKG_INIT YES +#endif /* H5SLmodule_H */ diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index 1393a25e23b..c9e11471cd2 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains private information about the H5SL module */ -#ifndef _H5SLprivate_H -#define _H5SLprivate_H +#ifndef H5SLprivate_H +#define H5SLprivate_H /**************************************/ /* Public headers needed by this file */ @@ -34,7 +34,7 @@ /************/ /* Typedefs for skip list struct (defined in H5SL.c) */ -typedef struct H5SL_t H5SL_t; +typedef struct H5SL_t H5SL_t; typedef struct H5SL_node_t H5SL_node_t; /* Typedef for kinds of skip lists supported */ @@ -58,25 +58,23 @@ typedef enum { 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 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*/); +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 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); @@ -84,15 +82,13 @@ 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 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); - -#endif /* _H5SLprivate_H */ +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); +#endif /* H5SLprivate_H */ diff --git a/src/H5SM.c b/src/H5SM.c index 5864a6f80f7..fa446cf94f9 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,67 +15,62 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ /* 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) */ + size_t buf_size; /* Size of the encoded message (out) */ + void * encoding_buf; /* The encoded message (out) */ } H5SM_read_udata_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header); -static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, - hbool_t delete_heap); +static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header); +static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, hbool_t delete_heap); static haddr_t H5SM__create_list(H5F_t *f, H5SM_index_header_t *header); -static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, - size_t *empty_pos, size_t *list_pos); -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); -static herr_t H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header); -static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed); -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); -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); -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); -static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata); -static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, - H5O_t * open_oh, size_t *encoding_size /*out*/, void ** encoded_mesg /*out*/); - +static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *empty_pos, + size_t *list_pos); +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); +static herr_t 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); +static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed); +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); +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); +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); +static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata); +static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh, + size_t *encoding_size /*out*/, void **encoded_mesg /*out*/); /*********************/ /* Package Variables */ @@ -89,18 +84,14 @@ H5FL_ARR_DEFINE(H5SM_index_header_t, H5O_SHMESG_MAX_NINDEXES); H5FL_DEFINE(H5SM_list_t); H5FL_ARR_DEFINE(H5SM_sohm_t, H5O_SHMESG_MAX_LIST_SIZE); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM_init * @@ -118,18 +109,18 @@ H5FL_ARR_DEFINE(H5SM_sohm_t, H5O_SHMESG_MAX_LIST_SIZE); *------------------------------------------------------------------------- */ herr_t -H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) +H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) { - H5O_shmesg_table_t sohm_table; /* SOHM message for superblock extension */ - H5SM_master_table_t *table = NULL; /* SOHM master table for file */ - H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ - 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 */ + H5O_shmesg_table_t sohm_table; /* SOHM message for superblock extension */ + H5SM_master_table_t *table = NULL; /* SOHM master table for file */ + H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ + 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 type_flags_used; /* Message type flags used, for sanity checking */ - unsigned x; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned type_flags_used; /* Message type flags used, for sanity checking */ + unsigned x; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -141,30 +132,31 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Initialize master table */ - if(NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) + if (NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "memory allocation failed for SOHM table") table->num_indexes = H5F_SOHM_NINDEXES(f); - table->table_size = H5SM_TABLE_SIZE(f); + table->table_size = H5SM_TABLE_SIZE(f); /* Get information from fcpl */ - if(H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, &index_type_flags) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, &index_type_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM type flags") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &list_max) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &list_max) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM list maximum") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &btree_min) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &btree_min) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM btree minimum") - if(H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, &minsizes) < 0) + if (H5P_get(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, &minsizes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get SOHM message min sizes") /* Verify that values are valid */ - if(table->num_indexes > H5O_SHMESG_MAX_NINDEXES) + if (table->num_indexes > H5O_SHMESG_MAX_NINDEXES) HGOTO_ERROR(H5E_SOHM, H5E_BADRANGE, FAIL, "number of indexes in property list is too large") /* Check that type flags weren't duplicated anywhere */ type_flags_used = 0; - for(x = 0; x < table->num_indexes; ++x) { - if(index_type_flags[x] & type_flags_used) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "the same shared message type flag is assigned to more than one index") + for (x = 0; x < table->num_indexes; ++x) { + if (index_type_flags[x] & type_flags_used) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "the same shared message type flag is assigned to more than one index") type_flags_used |= index_type_flags[x]; } /* end for */ @@ -182,23 +174,24 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) HDassert(table->num_indexes > 0 && table->num_indexes <= H5O_SHMESG_MAX_NINDEXES); /* Allocate the SOHM indexes as an array. */ - if(NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM indexes") + if (NULL == (table->indexes = + (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM indexes") /* Initialize all of the indexes, but don't allocate space for them to * hold messages until we actually need to write to them. */ - for(x = 0; x < table->num_indexes; x++) { - table->indexes[x].btree_min = btree_min; - table->indexes[x].list_max = list_max; - table->indexes[x].mesg_types = index_type_flags[x]; + for (x = 0; x < table->num_indexes; x++) { + table->indexes[x].btree_min = btree_min; + table->indexes[x].list_max = list_max; + table->indexes[x].mesg_types = index_type_flags[x]; table->indexes[x].min_mesg_size = minsizes[x]; - table->indexes[x].index_addr = HADDR_UNDEF; - table->indexes[x].heap_addr = HADDR_UNDEF; - table->indexes[x].num_messages = 0; + table->indexes[x].index_addr = HADDR_UNDEF; + table->indexes[x].heap_addr = HADDR_UNDEF; + table->indexes[x].num_messages = 0; /* Indexes start as lists unless the list-to-btree threshold is zero */ - if(table->indexes[x].list_max > 0) + if (table->indexes[x].list_max > 0) table->indexes[x].index_type = H5SM_LIST; else table->indexes[x].index_type = H5SM_BTREE; @@ -208,11 +201,11 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) } /* end for */ /* Allocate space for the table on disk */ - if(HADDR_UNDEF == (table_addr = H5MF_alloc(f, H5FD_MEM_SOHM_TABLE, (hsize_t)table->table_size))) + if (HADDR_UNDEF == (table_addr = H5MF_alloc(f, H5FD_MEM_SOHM_TABLE, (hsize_t)table->table_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "file allocation failed for SOHM table") /* Cache the new table */ - if(H5AC_insert_entry(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINS, FAIL, "can't add SOHM table to cache") /* Record the address of the master table in the file */ @@ -221,35 +214,35 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) /* Check for sharing attributes in this file, which means that creation * indices must be tracked on object header message in the file. */ - if(type_flags_used & H5O_SHMESG_ATTR_FLAG) + if (type_flags_used & H5O_SHMESG_ATTR_FLAG) H5F_SET_STORE_MSG_CRT_IDX(f, TRUE); /* Set the ring type to superblock extension */ H5AC_set_ring(H5AC_RING_SBE, NULL); /* Write shared message information to the superblock extension */ - sohm_table.addr = H5F_SOHM_ADDR(f); - sohm_table.version = H5F_SOHM_VERS(f); + sohm_table.addr = H5F_SOHM_ADDR(f); + sohm_table.version = H5F_SOHM_VERS(f); sohm_table.nindexes = H5F_SOHM_NINDEXES(f); - if(H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &sohm_table) < 0) + if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &sohm_table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to update SOHM header message") done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - if(ret_value < 0) { - if(table_addr != HADDR_UNDEF) + if (ret_value < 0) { + if (table_addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_TABLE, table_addr, (hsize_t)table->table_size); - if(table != NULL) + if (table != NULL) table = H5FL_FREE(H5SM_master_table_t, table); } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_init() */ - /*------------------------------------------------------------------------- * Function: H5SM__type_to_flag * @@ -265,15 +258,15 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc) static herr_t H5SM__type_to_flag(unsigned type_id, unsigned *type_flag) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Translate the H5O type_id into an H5SM type flag */ - switch(type_id) { + switch (type_id) { case H5O_FILL_ID: type_id = H5O_FILL_NEW_ID; - /* Fall through... */ + /* FALLTHROUGH */ H5_ATTR_FALLTHROUGH case H5O_SDSPACE_ID: @@ -292,9 +285,8 @@ H5SM__type_to_flag(unsigned type_id, unsigned *type_flag) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__type_to_flag() */ - /*------------------------------------------------------------------------- - * Function: H5SM_get_index + * Function: H5SM__get_index * * Purpose: Get the index number for a given message type. * @@ -310,23 +302,23 @@ H5SM__type_to_flag(unsigned type_id, unsigned *type_flag) *------------------------------------------------------------------------- */ ssize_t -H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id) +H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id) { - size_t x; + size_t x; unsigned type_flag; - ssize_t ret_value = FAIL; + ssize_t ret_value = FAIL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Translate the H5O type_id into an H5SM type flag */ - if(H5SM__type_to_flag(type_id, &type_flag) < 0) + if (H5SM__type_to_flag(type_id, &type_flag) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't map message type to flag") /* Search the indexes until we find one that matches this flag or we've * searched them all. */ - for(x = 0; x < table->num_indexes; ++x) - if(table->indexes[x].mesg_types & type_flag) + for (x = 0; x < table->num_indexes; ++x) + if (table->indexes[x].mesg_types & type_flag) HGOTO_DONE((ssize_t)x) /* At this point, ret_value is either the location of the correct @@ -334,9 +326,8 @@ H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id) */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_get_index() */ +} /* end H5SM__get_index() */ - /*------------------------------------------------------------------------- * Function: H5SM_type_shared * @@ -352,25 +343,26 @@ H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id) htri_t H5SM_type_shared(H5F_t *f, unsigned type_id) { - H5SM_master_table_t *table = NULL; /* Shared object master table */ - unsigned type_flag; /* Flag corresponding to message type */ - size_t u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + H5SM_master_table_t *table = NULL; /* Shared object master table */ + unsigned type_flag; /* Flag corresponding to message type */ + size_t u; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(H5AC__SOHM_TAG) /* Translate the H5O type_id into an H5SM type flag */ - if(H5SM__type_to_flag(type_id, &type_flag) < 0) + if (H5SM__type_to_flag(type_id, &type_flag) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't map message type to flag") /* Look up the master SOHM table */ - if(H5F_addr_defined(H5F_SOHM_ADDR(f))) { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + if (H5F_addr_defined(H5F_SOHM_ADDR(f))) { + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ /* Set up user data for callback */ cache_udata.f = f; - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") } /* end if */ else @@ -380,19 +372,18 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) /* Search the indexes until we find one that matches this flag or we've * searched them all. */ - for(u = 0; u < table->num_indexes; u++) - if(table->indexes[u].mesg_types & type_flag) + for (u = 0; u < table->num_indexes; u++) + if (table->indexes[u].mesg_types & type_flag) HGOTO_DONE(TRUE) done: /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_type_shared() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_fheap_addr * @@ -409,10 +400,10 @@ 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_table_cache_ud_t cache_udata; /* User-data for callback */ - ssize_t index_num; /* Which index */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -424,11 +415,12 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Look up index for message type */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM__get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to find correct SOHM index") /* Retrieve heap address for index */ @@ -436,13 +428,12 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) done: /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_fheap_addr() */ - /*------------------------------------------------------------------------- * Function: H5SM__create_index * @@ -458,10 +449,10 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) 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 */ - herr_t ret_value = SUCCEED; + 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 */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -471,11 +462,11 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) HDassert(header->btree_min <= header->list_max + 1); /* In most cases, the index starts as a list */ - if(header->list_max > 0) { - haddr_t list_addr = HADDR_UNDEF; /* Address of SOHM list */ + if (header->list_max > 0) { + haddr_t list_addr = HADDR_UNDEF; /* Address of SOHM list */ /* Create the list index */ - if(HADDR_UNDEF == (list_addr = H5SM__create_list(f, header))) + if (HADDR_UNDEF == (list_addr = H5SM__create_list(f, header))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "list creation failed for SOHM index") /* Set the index type & address */ @@ -484,20 +475,20 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) } /* end if */ /* index is a B-tree */ else { - H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - haddr_t tree_addr = HADDR_UNDEF; /* Address of SOHM B-tree */ + H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ + haddr_t tree_addr = HADDR_UNDEF; /* Address of SOHM B-tree */ /* Create the v2 B-tree index */ - bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.cls = H5SM_INDEX; + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) + if (NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2, &tree_addr) < 0) + if (H5B2_get_addr(bt2, &tree_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for SOHM index") /* Set the index type & address */ @@ -507,42 +498,41 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) /* Create a heap to hold the shared messages that the list or B-tree will index */ HDmemset(&fheap_cparam, 0, sizeof(fheap_cparam)); - fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; + fheap_cparam.managed.width = H5O_FHEAP_MAN_WIDTH; fheap_cparam.managed.start_block_size = H5O_FHEAP_MAN_START_BLOCK_SIZE; - fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; - fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; - fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; - fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; - fheap_cparam.id_len = 0; - fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; - if(NULL == (fheap = H5HF_create(f, &fheap_cparam))) + fheap_cparam.managed.max_direct_size = H5O_FHEAP_MAN_MAX_DIRECT_SIZE; + fheap_cparam.managed.max_index = H5O_FHEAP_MAN_MAX_INDEX; + fheap_cparam.managed.start_root_rows = H5O_FHEAP_MAN_START_ROOT_ROWS; + fheap_cparam.checksum_dblocks = H5O_FHEAP_CHECKSUM_DBLOCKS; + fheap_cparam.id_len = 0; + fheap_cparam.max_man_size = H5O_FHEAP_MAX_MAN_SIZE; + if (NULL == (fheap = H5HF_create(f, &fheap_cparam))) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create fractal heap") - if(H5HF_get_heap_addr(fheap, &(header->heap_addr)) < 0) + if (H5HF_get_heap_addr(fheap, &(header->heap_addr)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap address") #ifndef NDEBUG -{ - size_t fheap_id_len; /* Size of a fractal heap ID */ + { + size_t fheap_id_len; /* Size of a fractal heap ID */ - /* Sanity check ID length */ - if(H5HF_get_id_len(fheap, &fheap_id_len) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") - HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); -} + /* Sanity check ID length */ + if (H5HF_get_id_len(fheap, &fheap_id_len) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length") + HDassert(fheap_id_len == H5O_FHEAP_ID_LEN); + } #endif /* NDEBUG */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__create_index */ - /*------------------------------------------------------------------------- * Function: H5SM__delete_index * @@ -565,57 +555,56 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) static herr_t H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, hbool_t delete_heap) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Determine whether index is a list or a B-tree. */ - if(header->index_type == H5SM_LIST) { - unsigned index_status = 0; /* Index list's status in the metadata cache */ + if (header->index_type == H5SM_LIST) { + unsigned index_status = 0; /* Index list's status in the metadata cache */ /* Check the index list's status in the metadata cache */ - if(H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) + if (H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block") /* If the index list is in the cache, expunge it now */ - if(index_status & H5AC_ES__IN_CACHE) { + if (index_status & H5AC_ES__IN_CACHE) { /* Sanity checks on index list */ HDassert(!(index_status & H5AC_ES__IS_PINNED)); HDassert(!(index_status & H5AC_ES__IS_PROTECTED)); /* Evict the index list from the metadata cache */ - if(H5AC_expunge_entry(f, H5AC_SOHM_LIST, header->index_addr, H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_expunge_entry(f, H5AC_SOHM_LIST, header->index_addr, H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to remove list index from cache") } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(header->index_type == H5SM_BTREE); /* Delete the B-tree. */ - if(H5B2_delete(f, header->index_addr, f, NULL, NULL) < 0) + if (H5B2_delete(f, header->index_addr, f, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") /* Revert to list unless B-trees can have zero records */ - if(header->btree_min > 0) + if (header->btree_min > 0) header->index_type = H5SM_LIST; } /* end else */ /* Free the index's heap if requested. */ - if(delete_heap == TRUE) { - if(H5HF_delete(f, header->heap_addr) < 0) + if (delete_heap == TRUE) { + if (H5HF_delete(f, header->heap_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") header->heap_addr = HADDR_UNDEF; } /* end if */ /* Reset index info */ - header->index_addr = HADDR_UNDEF; + header->index_addr = HADDR_UNDEF; header->num_messages = 0; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__delete_index */ - /*------------------------------------------------------------------------- * Function: H5SM__create_list * @@ -634,13 +623,13 @@ H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, hbool_t delete_heap) static haddr_t H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) { - H5SM_list_t *list = NULL; /* List of messages */ - hsize_t x; /* Counter variable */ - size_t num_entries; /* Number of messages to create in list */ - haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + H5SM_list_t *list = NULL; /* List of messages */ + hsize_t x; /* Counter variable */ + size_t num_entries; /* Number of messages to create in list */ + haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC HDassert(f); HDassert(header); @@ -648,44 +637,43 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) num_entries = header->list_max; /* Allocate list in memory */ - if(NULL == (list = H5FL_CALLOC(H5SM_list_t))) + if (NULL == (list = H5FL_CALLOC(H5SM_list_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") - if(NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_CALLOC(H5SM_sohm_t, num_entries))) + if (NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_CALLOC(H5SM_sohm_t, num_entries))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") /* Initialize messages in list */ - for(x = 0; x < num_entries; x++) + for (x = 0; x < num_entries; x++) list->messages[x].location = H5SM_NO_LOC; /* Point list at header passed in */ list->header = header; /* Allocate space for the list on disk */ - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_SOHM_INDEX, (hsize_t)header->list_size))) + if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_SOHM_INDEX, (hsize_t)header->list_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list") /* Put the list into the cache */ - if(H5AC_insert_entry(f, H5AC_SOHM_LIST, addr, list, H5AC__NO_FLAGS_SET) < 0) + if (H5AC_insert_entry(f, H5AC_SOHM_LIST, addr, list, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINS, HADDR_UNDEF, "can't add SOHM list to cache") /* Set return value */ ret_value = addr; done: - if(ret_value == HADDR_UNDEF) { - if(list != NULL) { - if(list->messages != NULL) + if (ret_value == HADDR_UNDEF) { + if (list != NULL) { + if (list->messages != NULL) list->messages = H5FL_ARR_FREE(H5SM_sohm_t, list->messages); list = H5FL_FREE(H5SM_list_t, list); } /* end if */ - if(addr != HADDR_UNDEF) + if (addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_INDEX, addr, (hsize_t)header->list_size); } /* end if */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__create_list */ - /*------------------------------------------------------------------------- * Function: H5SM__convert_list_to_btree * @@ -708,18 +696,18 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) *------------------------------------------------------------------------- */ 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__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_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 */ - 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; - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -730,76 +718,117 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, list = *_list; /* Create the new v2 B-tree for tracking the messages */ - bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.cls = H5SM_INDEX; + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; - if(NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) + if (NULL == (bt2 = H5B2_create(f, &bt2_cparam, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTCREATE, FAIL, "B-tree creation failed for SOHM index") /* Retrieve the v2 B-tree's address in the file */ - if(H5B2_get_addr(bt2, &tree_addr) < 0) + if (H5B2_get_addr(bt2, &tree_addr) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't get v2 B-tree address for SOHM index") /* Set up key values that all messages will use. Since these messages * are in the heap, they have a heap ID and no encoding or type_id. */ - key.file = f; - key.fheap = fheap; + key.file = f; + key.fheap = fheap; key.encoding_size = 0; - key.encoding = NULL; + key.encoding = NULL; /* Insert each record into the new B-tree */ - for(x = 0; x < header->list_max; x++) { - if(list->messages[x].location != H5SM_NO_LOC) { + for (x = 0; x < header->list_max; x++) { + if (list->messages[x].location != H5SM_NO_LOC) { /* Copy message into key */ key.message = list->messages[x]; /* Get the encoded message */ - if(H5SM__read_mesg(f, &(key.message), fheap, open_oh, &key.encoding_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &(key.message), fheap, open_oh, &key.encoding_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "Couldn't read SOHM message in list") key.encoding = encoding_buf; /* Insert the message into the B-tree */ - if(H5B2_insert(bt2, &key) < 0) + if (H5B2_insert(bt2, &key) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "couldn't add SOHM to B-tree") /* Free buffer from H5SM__read_mesg */ - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); } /* end if */ - } /* end for */ + } /* end for */ /* Unprotect list in cache and release heap */ - if(H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list") *_list = list = NULL; /* Delete the old list index (but not its heap, which the new index is * still using!) */ - num_messages = header->num_messages; /* preserve this across the index deletion */ - if(H5SM__delete_index(f, header, FALSE) < 0) + num_messages = header->num_messages; /* preserve this across the index deletion */ + if (H5SM__delete_index(f, header, FALSE) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't free list index") /* Set/restore header info */ - header->index_addr = tree_addr; - header->index_type = H5SM_BTREE; + header->index_addr = tree_addr; + header->index_type = H5SM_BTREE; header->num_messages = num_messages; done: /* Release resources */ - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5SM__convert_list_to_btree() */ - +/*------------------------------------------------------------------------- + * Function: H5SM__bt2_convert_to_list_op + * + * Purpose: An H5B2_remove_t callback function to convert a SOHM + * B-tree index to a list. + * + * Inserts this record into the list passed through op_data. + * + * Return: Non-negative on success + * Negative on failure + * + * Programmer: James Laird + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5SM__bt2_convert_to_list_op(const void *record, void *op_data) +{ + const H5SM_sohm_t *message = (const H5SM_sohm_t *)record; + const H5SM_list_t *list = (const H5SM_list_t *)op_data; + size_t mesg_idx; /* Index of message to modify */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(record); + HDassert(op_data); + + /* Get the message index, and increment the # of messages in list */ + mesg_idx = list->header->num_messages++; + HDassert(list->header->num_messages <= list->header->list_max); + + /* Insert this message at the end of the list */ + HDassert(list->messages[mesg_idx].location == H5SM_NO_LOC); + HDassert(message->location != H5SM_NO_LOC); + H5MM_memcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t)); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM__bt2_convert_to_list_op() */ + /*------------------------------------------------------------------------- * Function: H5SM__convert_btree_to_list * @@ -815,14 +844,14 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, *------------------------------------------------------------------------- */ static herr_t -H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header) +H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) { - 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; + 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; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Remember the address of the old B-tree, but change the header over to be * a list.. @@ -830,37 +859,37 @@ H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header) btree_addr = header->index_addr; header->num_messages = 0; - header->index_type = H5SM_LIST; + header->index_type = H5SM_LIST; /* Create a new list index */ - if(HADDR_UNDEF == (header->index_addr = H5SM__create_list(f, header))) + if (HADDR_UNDEF == (header->index_addr = H5SM__create_list(f, header))) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create shared message list") /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* Protect the SOHM list */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM list index") /* Delete the B-tree and have messages copy themselves to the * list as they're deleted */ - if(H5B2_delete(f, btree_addr, f, H5SM_bt2_convert_to_list_op, list) < 0) + if (H5B2_delete(f, btree_addr, f, H5SM__bt2_convert_to_list_op, list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete B-tree") done: /* Release the SOHM list from the cache */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to unprotect SOHM index") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__convert_btree_to_list() */ - /*------------------------------------------------------------------------- - * Function: H5SM_can_share_common + * Function: H5SM__can_share_common * * Purpose: "trivial" checks for determining if a message can be shared. * @@ -878,21 +907,21 @@ H5SM__convert_btree_to_list(H5F_t * f, H5SM_index_header_t * header) *------------------------------------------------------------------------- */ static htri_t -H5SM_can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) +H5SM__can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check whether this message ought to be shared or not */ /* If sharing is disabled in this file, don't share the message */ - if(!H5F_addr_defined(H5F_SOHM_ADDR(f))) + if (!H5F_addr_defined(H5F_SOHM_ADDR(f))) HGOTO_DONE(FALSE) /* Type-specific check */ - if((ret_value = H5O_msg_can_share(type_id, mesg)) < 0) + if ((ret_value = H5O_msg_can_share(type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "can_share callback returned error") - if(ret_value == FALSE) + if (ret_value == FALSE) HGOTO_DONE(FALSE) /* At this point, the message passes the "trivial" checks and is worth @@ -901,9 +930,8 @@ H5SM_can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_can_share_common() */ +} /* end H5SM__can_share_common() */ - /*------------------------------------------------------------------------- * Function: H5SM_can_share * @@ -922,64 +950,65 @@ H5SM_can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) *------------------------------------------------------------------------- */ htri_t -H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, - ssize_t *sohm_index_num, unsigned type_id, const void *mesg) +H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, unsigned type_id, + const void *mesg) { - size_t mesg_size; + size_t mesg_size; H5SM_master_table_t *my_table = NULL; - ssize_t index_num; - htri_t tri_ret; - htri_t ret_value = TRUE; + ssize_t index_num; + htri_t tri_ret; + htri_t ret_value = TRUE; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) /* "trivial" sharing checks */ - if((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) + if ((tri_ret = H5SM__can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* Look up the master SOHM table */ /* (use incoming master SOHM table if possible) */ - if(table) + if (table) my_table = table; else { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ /* Set up user data for callback */ cache_udata.f = f; - if(NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") } /* end if */ /* Find the right index for this message type. If there is no such index * then this type of message isn't shareable */ - if((index_num = H5SM_get_index(my_table, type_id)) < 0) { + if ((index_num = H5SM__get_index(my_table, type_id)) < 0) { H5E_clear_stack(NULL); /*ignore error*/ HGOTO_DONE(FALSE) } /* end if */ /* If the message isn't big enough, don't bother sharing it */ - if(0 == (mesg_size = H5O_msg_raw_size(f, type_id, TRUE, mesg))) + if (0 == (mesg_size = H5O_msg_raw_size(f, type_id, TRUE, mesg))) HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, FAIL, "unable to get OH message size") - if(mesg_size < my_table->indexes[index_num].min_mesg_size) + if (mesg_size < my_table->indexes[index_num].min_mesg_size) HGOTO_DONE(FALSE) /* At this point, the message will be shared, set the index number if requested. */ - if(sohm_index_num) + if (sohm_index_num) *sohm_index_num = index_num; done: /* Release the master SOHM table, if we protected it */ - if(my_table && my_table != table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) + if (my_table && my_table != table && + H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_can_share() */ - /*------------------------------------------------------------------------- * Function: H5SM_try_share * @@ -1041,18 +1070,18 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, *------------------------------------------------------------------------- */ htri_t -H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, - unsigned type_id, void *mesg, unsigned *mesg_flags) +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_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned cache_flags = H5AC__NO_FLAGS_SET; - ssize_t index_num; - htri_t tri_ret; + 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; + htri_t tri_ret; #ifndef NDEBUG - unsigned deferred_type = -1u; + unsigned deferred_type = -1u; #endif - htri_t ret_value = TRUE; + htri_t ret_value = TRUE; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1060,41 +1089,42 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, * be the same as the one we get here. In debug mode, we make sure this * holds true; otherwise we can leave now if it wasn't shared in the DEFER * pass. */ - if(defer_flags & H5SM_WAS_DEFERRED) + if (defer_flags & H5SM_WAS_DEFERRED) #ifndef NDEBUG deferred_type = ((H5O_shared_t *)mesg)->type; -#else /* NDEBUG */ - if((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE) - && (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM)) +#else /* NDEBUG */ + if ((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE) && + (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM)) HGOTO_DONE(FALSE); #endif /* NDEBUG */ /* "trivial" sharing checks */ - if(mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) + if (mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) HGOTO_DONE(FALSE) - if((tri_ret = H5SM_can_share_common(f, type_id, mesg)) < 0) + if ((tri_ret = H5SM__can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* "complex" sharing checks */ - if((tri_ret = H5SM_can_share(f, table, &index_num, type_id, mesg)) < 0) + if ((tri_ret = H5SM_can_share(f, table, &index_num, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'complex' sharing checks returned error") - if(tri_ret == FALSE) + if (tri_ret == FALSE) HGOTO_DONE(FALSE) /* At this point, the message will be shared. */ /* If the index hasn't been allocated yet, create it */ - if(table->indexes[index_num].index_addr == HADDR_UNDEF) { - if(H5SM__create_index(f, &(table->indexes[index_num])) < 0) + if (table->indexes[index_num].index_addr == HADDR_UNDEF) { + if (H5SM__create_index(f, &(table->indexes[index_num])) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to create SOHM index") cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -1102,41 +1132,39 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, /* Write the message as a shared message. This may or may not cause the * message to become shared (if it is unique, it will not be shared). */ - if(H5SM__write_mesg(f, open_oh, &(table->indexes[index_num]), - (defer_flags & H5SM_DEFER) != 0, type_id, mesg, &cache_flags) < 0) + if (H5SM__write_mesg(f, open_oh, &(table->indexes[index_num]), (defer_flags & H5SM_DEFER) != 0, type_id, + mesg, &cache_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "can't write shared message") /* Set flags if this message was "written" without error and wasn't a * 'defer' attempt; it is now either fully shared or "shareable". */ - if(mesg_flags) { - if(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE) + if (mesg_flags) { + if (((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE) *mesg_flags |= H5O_MSG_FLAG_SHAREABLE; else { HDassert(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); *mesg_flags |= H5O_MSG_FLAG_SHARED; } /* end else */ - } /* end if */ + } /* end if */ done: - HDassert((ret_value != TRUE) - || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE - || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); + HDassert((ret_value != TRUE) || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE || + ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); #ifndef NDEBUG /* If we previously deferred this operation, make sure the saved message * type is the same as the one we get here. */ - if(defer_flags & H5SM_WAS_DEFERRED) + if (defer_flags & H5SM_WAS_DEFERRED) HDassert(deferred_type == ((H5O_shared_t *)mesg)->type); #endif /* NDEBUG */ /* Release the master SOHM table */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_try_share() */ - /*------------------------------------------------------------------------- * Function: H5SM__incr_ref * @@ -1157,9 +1185,9 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) { - 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; + 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; FUNC_ENTER_STATIC @@ -1170,14 +1198,15 @@ H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) /* If the message was previously shared in an object header, share * it in the heap now. */ - if(message->location == H5SM_IN_OH) { + if (message->location == H5SM_IN_OH) { HDassert(op_data->key && op_data->key->fheap); /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(op_data->key->fheap, op_data->key->encoding_size, op_data->key->encoding, &message->u.heap_loc.fheap_id) < 0) + if (H5HF_insert(op_data->key->fheap, op_data->key->encoding_size, op_data->key->encoding, + &message->u.heap_loc.fheap_id) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") - message->location = H5SM_IN_HEAP; + message->location = H5SM_IN_HEAP; message->u.heap_loc.ref_count = 2; } /* end if */ else { @@ -1190,14 +1219,13 @@ H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) *changed = TRUE; /* Check for retrieving the heap ID */ - if(op_data) - op_data->fheap_id = message->u.heap_loc.fheap_id; + if (op_data) + op_data->fheap_id = message->u.heap_loc.fheap_id; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__incr_ref() */ - /*------------------------------------------------------------------------- * Function: H5SM__write_mesg * @@ -1231,22 +1259,22 @@ H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) *------------------------------------------------------------------------- */ 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__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_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 */ - size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ - size_t empty_pos = UFAIL; /* Empty entry in list */ - herr_t ret_value = SUCCEED; + 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 */ + size_t buf_size; /* Size of the 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; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(header); @@ -1254,63 +1282,65 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(cache_flags_ptr); /* Encode the message to be written */ - if((buf_size = H5O_msg_raw_size(f, type_id, TRUE, mesg)) == 0) + if ((buf_size = H5O_msg_raw_size(f, type_id, TRUE, mesg)) == 0) HGOTO_ERROR(H5E_SOHM, H5E_BADSIZE, FAIL, "can't find message size") - if(NULL == (encoding_buf = H5MM_malloc(buf_size))) + if (NULL == (encoding_buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding") - if(H5O_msg_encode(f, type_id, TRUE, (unsigned char *)encoding_buf, mesg) < 0) + if (H5O_msg_encode(f, type_id, TRUE, (unsigned char *)encoding_buf, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, FAIL, "can't encode message to be shared") /* Open the fractal heap for this index */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up a key for the message to be written */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; - key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; + key.encoding_size = buf_size; + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); key.message.location = H5SM_NO_LOC; /* Assume the message is already in the index and try to increment its * reference count. If this fails, the message isn't in the index after * all and we'll need to add it. */ - if(header->index_type == H5SM_LIST) { - size_t list_pos; /* Position in a list index */ + if (header->index_type == H5SM_LIST) { + size_t list_pos; /* Position in a list index */ /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* The index is a list; get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* See if the message is already in the index and get its location. * Also record the first empty list position we find in case we need it * later. */ - if(H5SM__find_in_list(list, &key, &empty_pos, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, &empty_pos, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") - if(defer) { - if(list_pos != UFAIL) + if (defer) { + if (list_pos != SIZE_MAX) found = TRUE; } /* end if */ else { - if(list_pos != UFAIL) { + if (list_pos != SIZE_MAX) { /* If the message was previously shared in an object header, share * it in the heap now. */ - if(list->messages[list_pos].location == H5SM_IN_OH) { + if (list->messages[list_pos].location == H5SM_IN_OH) { /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") + if (H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, + "unable to insert message into fractal heap") - list->messages[list_pos].location = H5SM_IN_HEAP; - list->messages[list_pos].u.heap_loc.fheap_id = shared.u.heap_id; + list->messages[list_pos].location = H5SM_IN_HEAP; + list->messages[list_pos].u.heap_loc.fheap_id = shared.u.heap_id; list->messages[list_pos].u.heap_loc.ref_count = 2; } /* end if */ else { @@ -1321,27 +1351,27 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, /* Set up the shared location to point to the shared location */ shared.u.heap_id = list->messages[list_pos].u.heap_loc.fheap_id; - found = TRUE; + found = TRUE; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Index is a B-tree */ else { HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") - if(defer) { - htri_t bt2_find; /* Result from searching in the v2 B-tree */ + if (defer) { + htri_t bt2_find; /* Result from searching in the v2 B-tree */ /* If this returns 0, it means that the message wasn't found. */ /* If it return 1, set the heap_id in the shared struct. It will * return a heap ID, since a message with a reference count greater * than 1 is always shared in the heap. */ - if((bt2_find = H5B2_find(bt2, &key, NULL, NULL)) < 0) + if ((bt2_find = H5B2_find(bt2, &key, NULL, NULL)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "can't search for message in index") found = (hbool_t)bt2_find; } /* end if */ @@ -1356,16 +1386,16 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * return a heap ID, since a message with a reference count greater * than 1 is always shared in the heap. */ - if(H5B2_modify(bt2, &key, H5SM__incr_ref, &op_data) >= 0) { + if (H5B2_modify(bt2, &key, H5SM__incr_ref, &op_data) >= 0) { shared.u.heap_id = op_data.fheap_id; - found = TRUE; + found = TRUE; } /* end if */ else H5E_clear_stack(NULL); /*ignore error*/ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ - if(found) { + if (found) { /* If the message was found, it's shared in the heap (now). Set up a * shared message so we can mark it as shared. */ @@ -1378,17 +1408,17 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * checkers like valgrind from whining when the partially initialized * shared message is serialized. -QAK */ - if(defer) + if (defer) HDmemset(&shared.u, 0, sizeof(shared.u)); #endif /* H5_USING_MEMCHECKER */ - } /* end if */ + } /* end if */ else { - htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ + htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ /* Add the message to the index */ /* Check if the message can be shared in another object's header */ - if((share_in_ohdr = H5O_msg_can_share_in_ohdr(type_id)) < 0) + if ((share_in_ohdr = H5O_msg_can_share_in_ohdr(type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'share in ohdr' check returned error") /* If this message can be shared in an object header location, it is @@ -1408,59 +1438,59 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, * no object header location available, insert it in the * heap. */ - if(share_in_ohdr && open_oh) { + if (share_in_ohdr && open_oh) { /* Set up shared component info */ shared.type = H5O_SHARE_TYPE_HERE; /* Retrieve any creation index from the native message */ - if(H5O_msg_get_crt_index(type_id, mesg, &shared.u.loc.index) < 0) + if (H5O_msg_get_crt_index(type_id, mesg, &shared.u.loc.index) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to retrieve creation index") - if(defer) + if (defer) shared.u.loc.oh_addr = HADDR_UNDEF; else { shared.u.loc.oh_addr = H5O_OH_GET_ADDR(open_oh); /* Copy shared component info into key for inserting into index */ - key.message.location = H5SM_IN_OH; + key.message.location = H5SM_IN_OH; key.message.u.mesg_loc = shared.u.loc; } /* end else */ - } /* end if */ + } /* end if */ else { /* Set up shared component info */ /* (heap ID set below, if not deferred) */ shared.type = H5O_SHARE_TYPE_SOHM; - if(!defer) { + if (!defer) { /* Put the message in the heap and record its new heap ID */ - if(H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) + if (H5HF_insert(fheap, key.encoding_size, key.encoding, &shared.u.heap_id) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap") - key.message.location = H5SM_IN_HEAP; - key.message.u.heap_loc.fheap_id = shared.u.heap_id; + key.message.location = H5SM_IN_HEAP; + key.message.u.heap_loc.fheap_id = shared.u.heap_id; key.message.u.heap_loc.ref_count = 1; } /* end if */ - } /* end else */ + } /* end else */ - if(!defer) { + if (!defer) { /* Set common information */ key.message.msg_type_id = type_id; /* Check whether the list has grown enough that it needs to become a B-tree */ - if(header->index_type == H5SM_LIST && header->num_messages >= header->list_max) - if(H5SM__convert_list_to_btree(f, header, &list, fheap, open_oh) < 0) + if (header->index_type == H5SM_LIST && header->num_messages >= header->list_max) + if (H5SM__convert_list_to_btree(f, header, &list, fheap, open_oh) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to convert list to B-tree") /* Insert the new message into the SOHM index */ - if(header->index_type == H5SM_LIST) { + if (header->index_type == H5SM_LIST) { /* Index is a list. Find an empty spot if we haven't already */ - if(empty_pos == UFAIL) { + if (empty_pos == SIZE_MAX) { size_t pos; - if(H5SM__find_in_list(list, NULL, &empty_pos, &pos) < 0) + if (H5SM__find_in_list(list, NULL, &empty_pos, &pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to search for message in list") - if(pos == UFAIL || empty_pos == UFAIL) + if (pos == SIZE_MAX || empty_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "unable to find empty entry in list") } /* Insert message into list */ @@ -1473,46 +1503,47 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree, if it isn't already */ - if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") + if (NULL == bt2) { + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for SOHM index") } /* end if */ - if(H5B2_insert(bt2, &key) < 0) + if (H5B2_insert(bt2, &key) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "couldn't add SOHM to B-tree") } /* end else */ ++(header->num_messages); (*cache_flags_ptr) |= H5AC__DIRTIED_FLAG; } /* end if */ - } /* end else */ + } /* end else */ /* Set the file pointer & message type for the shared component */ - shared.file = f; + shared.file = f; shared.msg_type_id = type_id; /* Update the original message's shared component */ - if(H5O_msg_set_share(type_id, &shared, mesg) < 0) + if (H5O_msg_set_share(type_id, &shared, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, FAIL, "unable to set sharing information") done: /* Release the fractal heap & v2 B-tree if we opened them */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") /* If we got a list out of the cache, release it (it is always dirty after writing a message) */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__write_mesg() */ - /*------------------------------------------------------------------------- * Function: H5SM_delete * @@ -1534,14 +1565,14 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, 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 */ + 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; - unsigned type_id; /* Message type ID to operate on */ + size_t mesg_size = 0; + void * mesg_buf = NULL; + void * native_mesg = NULL; + unsigned type_id; /* Message type ID to operate on */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1557,22 +1588,24 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index and try to delete from it */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM__get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") /* If mesg_buf is not NULL, the message's reference count has reached * zero and any file space it uses needs to be freed. mesg_buf holds the * serialized form of the message. */ - if(H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, &mesg_buf) < 0) + 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") /* Release the master SOHM table */ - if(H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") table = NULL; @@ -1580,31 +1613,31 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * reference other shared messages that also need to be deleted, so the * master table needs to be unprotected when we do this. */ - if(mesg_buf) { - if(NULL == (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) + if (mesg_buf) { + if (NULL == + (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) HGOTO_ERROR(H5E_SOHM, H5E_CANTDECODE, FAIL, "can't decode shared message.") - if(H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) + if (H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFREE, FAIL, "can't delete shared message.") } /* end if */ done: /* Release the master SOHM table (should only happen on error) */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") /* Release any native message we decoded */ - if(native_mesg) + if (native_mesg) H5O_msg_free(type_id, native_mesg); /* Free encoding buf */ - if(mesg_buf) + if (mesg_buf) mesg_buf = H5MM_xfree(mesg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_delete() */ - /*------------------------------------------------------------------------- * Function: H5SM__find_in_list * @@ -1617,9 +1650,14 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * * If EMPTY_POS is NULL, don't store anything in it. * - * Return: Message's position in the list on success - * UFAIL if message couldn't be found - * empty_pos set to position of empty message or UFAIL. + * Return: Success: SUCCEED + * pos = position (if found) + * pos = SIZE_MAX (if not found) + * empty_pos = indeterminate (if found) + * empty_pos = 1st empty position (if not found) + * + * Failure: FAIL + * pos & empty_pos indeterminate * * Programmer: James Laird * Tuesday, May 2, 2006 @@ -1630,7 +1668,7 @@ static herr_t H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *empty_pos, size_t *pos) { size_t x; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1639,68 +1677,40 @@ H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t * HDassert(key || empty_pos); /* Initialize empty_pos to an invalid value */ - if(empty_pos) - *empty_pos = UFAIL; + if (empty_pos) + *empty_pos = SIZE_MAX; /* Find the first (only) message equal to the key passed in. * Also record the first empty position we find. */ - for(x = 0; x < list->header->list_max; x++) { - if(list->messages[x].location != H5SM_NO_LOC) { + for (x = 0; x < list->header->list_max; x++) { + if (list->messages[x].location != H5SM_NO_LOC) { int cmp; - if(H5SM__message_compare(key, &(list->messages[x]), &cmp) < 0) + if (H5SM__message_compare(key, &(list->messages[x]), &cmp) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCOMPARE, FAIL, "can't compare message records") - if(0 == cmp) { + if (0 == cmp) { *pos = x; HGOTO_DONE(SUCCEED) } } - else if(empty_pos && list->messages[x].location == H5SM_NO_LOC) { + else if (empty_pos && list->messages[x].location == H5SM_NO_LOC) { /* Note position */ *empty_pos = x; /* Found earlier position possible, don't check any more */ empty_pos = NULL; - } /* end if */ - } /* end for */ + } + } /* If we reached this point, we didn't find the message */ - *pos = UFAIL; + *pos = SIZE_MAX; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__find_in_list */ - -/*------------------------------------------------------------------------- - * Function: H5SM_get_hash_fh_cb - * - * Purpose: Callback for fractal heap operator, to make copy of link when - * when lookup up a link by index - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Nov 7 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata) -{ - H5SM_fh_ud_gh_t *udata = (H5SM_fh_ud_gh_t *)_udata; /* User data for fractal heap 'op' callback */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Compute hash value on raw message */ - udata->hash = H5_checksum_lookup3(obj, obj_len, udata->type_id); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_get_hash_fh_cb() */ - - /*------------------------------------------------------------------------- * Function: H5SM__decr_ref * @@ -1723,7 +1733,7 @@ H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata) static herr_t H5SM__decr_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; FUNC_ENTER_STATIC_NOERR @@ -1735,18 +1745,17 @@ H5SM__decr_ref(void *record, void *op_data, hbool_t *changed) * Messages stored in object headers always have refcounts of 1, * so the calling function should know to just delete such a message */ - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { --message->u.heap_loc.ref_count; *changed = TRUE; } /* end if */ - if(op_data) - *(H5SM_sohm_t *)op_data = *message; + if (op_data) + *(H5SM_sohm_t *)op_data = *message; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__decr_ref() */ - /*------------------------------------------------------------------------- * Function: H5SM__delete_from_index * @@ -1765,22 +1774,21 @@ 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) +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 */ - size_t buf_size; /* Size of the encoded message (out) */ - void *encoding_buf = NULL; /* The encoded message (out) */ - unsigned type_id; /* Message type to operate on */ + 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 */ + size_t buf_size; /* Size of 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; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -1793,55 +1801,56 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, type_id = mesg->msg_type_id; /* Open the heap for this type of message. */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get the message size and encoded message for the message to be deleted, * either from its OH or from the heap. */ - if(mesg->type == H5O_SHARE_TYPE_HERE) { - key.message.location = H5SM_IN_OH; + if (mesg->type == H5O_SHARE_TYPE_HERE) { + key.message.location = H5SM_IN_OH; key.message.msg_type_id = type_id; - key.message.u.mesg_loc = mesg->u.loc; + key.message.u.mesg_loc = mesg->u.loc; } /* end if */ else { - key.message.location = H5SM_IN_HEAP; - key.message.msg_type_id = type_id; + key.message.location = H5SM_IN_HEAP; + key.message.msg_type_id = type_id; key.message.u.heap_loc.ref_count = 0; /* Refcount isn't relevant here */ - key.message.u.heap_loc.fheap_id = mesg->u.heap_id; + key.message.u.heap_loc.fheap_id = mesg->u.heap_id; } /* end else */ /* Get the encoded message */ - if(H5SM__read_mesg(f, &key.message, fheap, open_oh, &buf_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &key.message, fheap, open_oh, &buf_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up key for message to be deleted. */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); /* Try to find the message in the index */ - if(header->index_type == H5SM_LIST) { - H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - size_t list_pos; /* Position of the message in the list */ + if (header->index_type == H5SM_LIST) { + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ + size_t list_pos; /* Position of the message in the list */ /* Set up user data for metadata cache callback */ - cache_udata.f = f; + cache_udata.f = f; cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Find the message in the list */ - if(H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if(list_pos == UFAIL) + if (list_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") - if(list->messages[list_pos].location == H5SM_IN_HEAP) + if (list->messages[list_pos].location == H5SM_IN_HEAP) --(list->messages[list_pos].u.heap_loc.ref_count); /* Point to the message */ @@ -1852,13 +1861,13 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* If this returns failure, it means that the message wasn't found. * If it succeeds, a copy of the modified message will be returned. */ - if(H5B2_modify(bt2, &key, H5SM__decr_ref, &message) < 0) + if (H5B2_modify(bt2, &key, H5SM__decr_ref, &message) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Point to the message */ @@ -1868,7 +1877,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, /* If the ref count is zero or this message was in an OH (which always * has a ref count of 1) delete the message from the index */ - if(message_ptr->location == H5SM_IN_OH || message_ptr->u.heap_loc.ref_count == 0) { + if (message_ptr->location == H5SM_IN_OH || message_ptr->u.heap_loc.ref_count == 0) { /* Save the location */ H5SM_storage_loc_t old_loc = message_ptr->location; @@ -1877,78 +1886,77 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, *cache_flags |= H5AC__DIRTIED_FLAG; /* Remove the message from the index */ - if(header->index_type == H5SM_LIST) + if (header->index_type == H5SM_LIST) message_ptr->location = H5SM_NO_LOC; else { /* Open the index v2 B-tree, if it isn't already */ - if(NULL == bt2) { - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == bt2) { + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") } /* end if */ - if(H5B2_remove(bt2, &key, NULL, NULL) < 0) + if (H5B2_remove(bt2, &key, NULL, NULL) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to delete message from index") } /* end else */ /* Remove the message from the heap if it was stored in the heap*/ - if(old_loc == H5SM_IN_HEAP) - if(H5HF_remove(fheap, &(message_ptr->u.heap_loc.fheap_id)) < 0) + if (old_loc == H5SM_IN_HEAP) + if (H5HF_remove(fheap, &(message_ptr->u.heap_loc.fheap_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "unable to remove message from heap") - /* Return the message's encoding so anything it references can be freed */ *encoded_mesg = encoding_buf; - *mesg_size = buf_size; + *mesg_size = buf_size; /* If there are no messages left in the index, delete it */ - if(header->num_messages == 0) { + if (header->num_messages == 0) { /* Unprotect cache and release heap */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list") list = NULL; HDassert(fheap); - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") fheap = NULL; /* Delete the index and its heap */ - if(H5SM__delete_index(f, header, TRUE) < 0) + if (H5SM__delete_index(f, header, TRUE) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't delete empty index") - } /* end if */ - else if(header->index_type == H5SM_BTREE && header->num_messages < header->btree_min) { + } /* end if */ + else if (header->index_type == H5SM_BTREE && header->num_messages < header->btree_min) { /* Otherwise, if we've just passed the btree-to-list cutoff, convert * this B-tree into a list */ - if(H5SM__convert_btree_to_list(f, header) < 0) + if (H5SM__convert_btree_to_list(f, header) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to convert btree to list") } /* end if */ - } /* end if */ + } /* end if */ done: /* Release the SOHM list */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") /* Release the fractal heap & v2 B-tree if we opened them */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") /* Free the message encoding, if we're not returning it in encoded_mesg * or if there's been an error. */ - if(encoding_buf && (NULL == *encoded_mesg || ret_value < 0)) { + if (encoding_buf && (NULL == *encoded_mesg || ret_value < 0)) { encoding_buf = H5MM_xfree(encoding_buf); - *mesg_size = 0; + *mesg_size = 0; } - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__delete_from_index() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_info * @@ -1964,13 +1972,13 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, 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) */ - 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 */ - unsigned tmp_sohm_nindexes; /* Number of shared messages indexes in the table */ - htri_t status; /* Status for message existing */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned tmp_sohm_nindexes; /* Number of shared messages indexes in the table */ + htri_t status; /* Status for message existing */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -1980,18 +1988,18 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) HDassert(fc_plist); /* Check for the extension having a 'shared message info' message */ - if((status = H5O_msg_exists(ext_loc, H5O_SHMESG_ID)) < 0) + if ((status = H5O_msg_exists(ext_loc, H5O_SHMESG_ID)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to read object header") - if(status) { - H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */ - unsigned sohm_l2b; /* SOHM list-to-btree cutoff */ - unsigned sohm_b2l; /* SOHM btree-to-list cutoff */ - unsigned u; /* Local index variable */ + if (status) { + H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ + unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */ + unsigned sohm_l2b; /* SOHM list-to-btree cutoff */ + unsigned sohm_b2l; /* SOHM btree-to-list cutoff */ + unsigned u; /* Local index variable */ /* Retrieve the 'shared message info' structure */ - if(NULL == H5O_msg_read(ext_loc, H5O_SHMESG_ID, &sohm_table)) + if (NULL == H5O_msg_read(ext_loc, H5O_SHMESG_ID, &sohm_table)) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "shared message info message not present") /* Portably initialize the arrays */ @@ -2012,7 +2020,8 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Read the rest of the SOHM table information from the cache */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Get index conversion limits */ @@ -2020,10 +2029,10 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) sohm_b2l = (unsigned)table->indexes[0].btree_min; /* Iterate through all indices */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Pack information about the individual SOHM index */ index_flags[u] = table->indexes[u].mesg_types; - minsizes[u] = (unsigned)table->indexes[u].min_mesg_size; + minsizes[u] = (unsigned)table->indexes[u].min_mesg_size; /* Sanity check */ HDassert(sohm_l2b == table->indexes[u].list_max); @@ -2032,21 +2041,21 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) /* Check for sharing attributes in this file, which means that creation * indices must be tracked on object header message in the file. */ - if(index_flags[u] & H5O_SHMESG_ATTR_FLAG) + if (index_flags[u] & H5O_SHMESG_ATTR_FLAG) H5F_SET_STORE_MSG_CRT_IDX(f, TRUE); } /* end for */ /* Set values in the property list */ tmp_sohm_nindexes = H5F_SOHM_NINDEXES(f); - if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set number of SOHM indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set type flags for indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set type flags for indexes") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list") - if(H5P_set(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list") } /* end if */ else { @@ -2057,23 +2066,22 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) /* Shared object header messages are disabled */ tmp_sohm_nindexes = H5F_SOHM_NINDEXES(f); - if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) + if (H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &tmp_sohm_nindexes) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTSET, FAIL, "can't set number of SOHM indexes") } /* end else */ done: /* Reset the ring in the API context */ - if(orig_ring != H5AC_RING_INV) + if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); /* Release the master SOHM table if we took it out of the cache */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_info() */ - /*------------------------------------------------------------------------- * Function: H5SM_reconstitute * @@ -2088,8 +2096,7 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) *------------------------------------------------------------------------- */ herr_t -H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, - H5O_fheap_id_t heap_id) +H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, H5O_fheap_id_t heap_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2097,17 +2104,16 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, HDassert(sh_mesg); /* Set flag for shared message */ - sh_mesg->type = H5O_SHARE_TYPE_SOHM; - sh_mesg->file = f; + sh_mesg->type = H5O_SHARE_TYPE_SOHM; + sh_mesg->file = f; sh_mesg->msg_type_id = msg_type_id; - sh_mesg->u.heap_id = heap_id; + sh_mesg->u.heap_id = heap_id; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM_reconstitute() */ - /*------------------------------------------------------------------------- - * Function: H5SM_get_refcount_bt2_cb + * Function: H5SM__get_refcount_bt2_cb * * Purpose: v2 B-tree 'find' callback to retrieve the record for a message * @@ -2119,12 +2125,12 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, *------------------------------------------------------------------------- */ static herr_t -H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) +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 */ + 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 */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* * Check arguments. @@ -2136,9 +2142,8 @@ H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) *op_data = *record; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_get_refcount_bt2_cb() */ +} /* end H5SM__get_refcount_bt2_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM_get_refcount * @@ -2152,21 +2157,20 @@ 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) +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 */ - 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_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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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_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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(H5AC__SOHM_TAG) @@ -2179,70 +2183,72 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index and find the message in it */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM__get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") header = &(table->indexes[index_num]); /* Open the heap for this message type */ - if(NULL == (fheap = H5HF_open(f, header->heap_addr))) + if (NULL == (fheap = H5HF_open(f, header->heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up a SOHM message to correspond to the shared message passed in */ - key.message.location = H5SM_IN_HEAP; - key.message.u.heap_loc.fheap_id = sh_mesg->u.heap_id; + key.message.location = H5SM_IN_HEAP; + key.message.u.heap_loc.fheap_id = sh_mesg->u.heap_id; key.message.u.heap_loc.ref_count = 0; /* Ref count isn't needed to find message */ /* Get the encoded message */ - if(H5SM__read_mesg(f, &key.message, fheap, NULL, &buf_size, &encoding_buf) < 0) + if (H5SM__read_mesg(f, &key.message, fheap, NULL, &buf_size, &encoding_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Set up key for message to locate */ - key.file = f; - key.fheap = fheap; - key.encoding = encoding_buf; + key.file = f; + key.fheap = fheap; + key.encoding = encoding_buf; key.encoding_size = buf_size; - key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); + key.message.hash = H5_checksum_lookup3(encoding_buf, buf_size, type_id); /* Try to find the message in the index */ - if(header->index_type == H5SM_LIST) { - H5SM_list_cache_ud_t lst_cache_udata; /* User-data for metadata cache callback */ - size_t list_pos; /* Position of the message in the list */ + if (header->index_type == H5SM_LIST) { + H5SM_list_cache_ud_t lst_cache_udata; /* User-data for metadata cache callback */ + size_t list_pos; /* Position of the message in the list */ /* Set up user data for metadata cache callback */ - lst_cache_udata.f = f; + lst_cache_udata.f = f; lst_cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, + &lst_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Find the message in the list */ - if(H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) + if (H5SM__find_in_list(list, &key, NULL, &list_pos) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to search for message in list") - if(list_pos == UFAIL) + if (list_pos == SIZE_MAX) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Copy the message */ message = list->messages[list_pos]; } /* end if */ else { - htri_t msg_exists; /* Whether the message exists in the v2 B-tree */ + htri_t msg_exists; /* Whether the message exists in the v2 B-tree */ /* Index is a B-tree */ HDassert(header->index_type == H5SM_BTREE); /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, header->index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") /* Look up the message in the v2 B-tree */ - if((msg_exists = H5B2_find(bt2, &key, H5SM_get_refcount_bt2_cb, &message)) < 0) + if ((msg_exists = H5B2_find(bt2, &key, H5SM__get_refcount_bt2_cb, &message)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "error finding message in index") - if(!msg_exists) + if (!msg_exists) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") } /* end else */ @@ -2252,21 +2258,20 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, done: /* Release resources */ - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(encoding_buf) + if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_refcount() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_iter_op * @@ -2286,11 +2291,11 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, *------------------------------------------------------------------------- */ static herr_t -H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5SM_read_udata_t *udata = (H5SM_read_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; + H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; + herr_t ret_value = H5_ITER_CONT; FUNC_ENTER_STATIC @@ -2303,10 +2308,10 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(NULL == udata->encoding_buf); /* Check the creation index for this message */ - if(sequence == udata->idx) { + if (sequence == udata->idx) { /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->file, oh, mesg) < 0) + if (mesg->dirty) + if (H5O_msg_flush(udata->file, oh, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") /* Get the message's encoded size */ @@ -2314,7 +2319,7 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(udata->buf_size); /* Allocate buffer to return the message in */ - if(NULL == (udata->encoding_buf = H5MM_malloc(udata->buf_size))) + if (NULL == (udata->encoding_buf = H5MM_malloc(udata->buf_size))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed") /* Copy the encoded message into the buffer to return */ @@ -2328,7 +2333,6 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_iter_op() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_mesg_fh_cb * @@ -2346,13 +2350,13 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, static herr_t H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata) { - H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; - herr_t ret_value = SUCCEED; + H5SM_read_udata_t *udata = (H5SM_read_udata_t *)_udata; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC /* Allocate a buffer to hold the message */ - if(NULL == (udata->encoding_buf = H5MM_malloc(obj_len))) + if (NULL == (udata->encoding_buf = H5MM_malloc(obj_len))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the message from the heap */ @@ -2363,7 +2367,6 @@ H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_mesg_fh_cb() */ - /*------------------------------------------------------------------------- * Function: H5SM__read_mesg * @@ -2378,94 +2381,93 @@ H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, - H5O_t *open_oh, size_t *encoding_size /*out*/, void ** encoded_mesg /*out*/) +H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh, + size_t *encoding_size /*out*/, void **encoded_mesg /*out*/) { - 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 */ - herr_t ret_value = SUCCEED; + 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 */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC HDassert(f); HDassert(mesg); HDassert(fheap); /* Set up user data for message iteration */ - udata.file = f; - udata.idx = mesg->u.mesg_loc.index; + udata.file = f; + udata.idx = mesg->u.mesg_loc.index; udata.encoding_buf = NULL; - udata.idx = 0; + udata.idx = 0; /* Get the message size and encoded message for the message to be deleted, * either from its OH or from the heap. */ - if(mesg->location == H5SM_IN_OH) { + if (mesg->location == H5SM_IN_OH) { /* Read message from object header */ - const H5O_msg_class_t *type = NULL; /* Actual H5O class type for the ID */ - H5O_mesg_operator_t op; /* Wrapper for operator */ + const H5O_msg_class_t *type = NULL; /* Actual H5O class type for the ID */ + H5O_mesg_operator_t op; /* Wrapper for operator */ - type = H5O_msg_class_g[mesg->msg_type_id]; /* map the type ID to the actual type object */ + type = H5O_msg_class_g[mesg->msg_type_id]; /* map the type ID to the actual type object */ HDassert(type); /* Reset object location for operation */ - if(H5O_loc_reset(&oloc) < 0) + if (H5O_loc_reset(&oloc) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRESET, FAIL, "unable to initialize location") - if(NULL == open_oh || mesg->u.mesg_loc.oh_addr != H5O_OH_GET_ADDR(open_oh)) { + if (NULL == open_oh || mesg->u.mesg_loc.oh_addr != H5O_OH_GET_ADDR(open_oh)) { /* Open the object in the file */ oloc.file = f; oloc.addr = mesg->u.mesg_loc.oh_addr; - if(H5O_open(&oloc) < 0) + if (H5O_open(&oloc) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "unable to open object header") /* Load the object header from the cache */ - if(NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, FALSE))) + if (NULL == (oh = H5O_protect(&oloc, H5AC__READ_ONLY_FLAG, FALSE))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load object header") } /* end if */ else oh = open_oh; /* Use the "real" iterate routine so it doesn't try to protect the OH */ - op.op_type = H5O_MESG_OP_LIB; + op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5SM__read_iter_op; - if((ret_value = H5O__msg_iterate_real(f, oh, type, &op, &udata)) < 0) + if ((ret_value = H5O__msg_iterate_real(f, oh, type, &op, &udata)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADITER, FAIL, "unable to iterate over object header messages") } /* end if */ else { HDassert(mesg->location == H5SM_IN_HEAP); /* Copy the message from the heap */ - if(H5HF_op(fheap, &(mesg->u.heap_loc.fheap_id), H5SM__read_mesg_fh_cb, &udata) < 0) + if (H5HF_op(fheap, &(mesg->u.heap_loc.fheap_id), H5SM__read_mesg_fh_cb, &udata) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, FAIL, "can't read message from fractal heap.") } /* end else */ HDassert(udata.encoding_buf); HDassert(udata.buf_size); /* Record the returned values */ - *encoded_mesg = udata.encoding_buf; + *encoded_mesg = udata.encoding_buf; *encoding_size = udata.buf_size; done: /* Close the object header if we opened one and had an error */ - if(oh && oh != open_oh) { - if(oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) + if (oh && oh != open_oh) { + if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - if(H5O_close(&oloc, NULL) < 0) + if (H5O_close(&oloc, NULL) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close object header") } /* end if */ /* Release the encoding buffer on error */ - if(ret_value < 0 && udata.encoding_buf) + if (ret_value < 0 && udata.encoding_buf) udata.encoding_buf = H5MM_xfree(udata.encoding_buf); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_mesg */ - /*------------------------------------------------------------------------- - * Function: H5SM_table_free + * Function: H5SM__table_free * * Purpose: Frees memory used by the SOHM table. * @@ -2477,9 +2479,9 @@ H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, *------------------------------------------------------------------------- */ herr_t -H5SM_table_free(H5SM_master_table_t *table) +H5SM__table_free(H5SM_master_table_t *table) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(table); @@ -2490,11 +2492,10 @@ H5SM_table_free(H5SM_master_table_t *table) table = H5FL_FREE(H5SM_master_table_t, table); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_table_free() */ +} /* end H5SM__table_free() */ - /*------------------------------------------------------------------------- - * Function: H5SM_list_free + * Function: H5SM__list_free * * Purpose: Frees all memory used by the list. * @@ -2506,9 +2507,9 @@ H5SM_table_free(H5SM_master_table_t *table) *------------------------------------------------------------------------- */ herr_t -H5SM_list_free(H5SM_list_t *list) +H5SM__list_free(H5SM_list_t *list) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(list); HDassert(list->messages); @@ -2518,15 +2519,14 @@ H5SM_list_free(H5SM_list_t *list) list = H5FL_FREE(H5SM_list_t, list); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_list_free() */ +} /* end H5SM__list_free() */ - /*------------------------------------------------------------------------- * Function: H5SM_table_debug * * Purpose: Print debugging information for the master table. * - * If table_vers and num_indexes are not UFAIL, they are used + * If table_vers and num_indexes are not UINT_MAX, they are used * instead of the values in the superblock. * * Return: Non-negative on success/Negative on failure @@ -2537,13 +2537,13 @@ H5SM_list_free(H5SM_list_t *list) *------------------------------------------------------------------------- */ 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_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_table_cache_ud_t cache_udata; /* User-data for callback */ - unsigned x; /* Counter variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2553,63 +2553,64 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); - /* If table_vers and num_indexes are UFAIL, replace them with values from + /* If table_vers and num_indexes are UINT_MAX, replace them with values from * userblock */ - if(table_vers == UFAIL) + if (table_vers == UINT_MAX) table_vers = H5F_SOHM_VERS(f); - else if(table_vers != H5F_SOHM_VERS(f)) + else if (table_vers != H5F_SOHM_VERS(f)) HDfprintf(stream, "*** SOHM TABLE VERSION DOESN'T MATCH VERSION IN SUPERBLOCK!\n"); - if(num_indexes == UFAIL) + if (num_indexes == UINT_MAX) num_indexes = H5F_SOHM_NINDEXES(f); - else if(num_indexes != H5F_SOHM_NINDEXES(f)) + else if (num_indexes != H5F_SOHM_NINDEXES(f)) HDfprintf(stream, "*** NUMBER OF SOHM INDEXES DOESN'T MATCH VALUE IN SUPERBLOCK!\n"); /* Check arguments. Version must be 0, the only version implemented so far */ - if(table_vers > HDF5_SHAREDHEADER_VERSION) + if (table_vers > HDF5_SHAREDHEADER_VERSION) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "unknown shared message table version") - if(num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES") + if (num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES") /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") HDfprintf(stream, "%*sShared Message Master Table...\n", indent, ""); - for(x = 0; x < num_indexes; ++x) { + for (x = 0; x < num_indexes; ++x) { HDfprintf(stream, "%*sIndex %d...\n", indent, "", x); - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "SOHM Index Type:", - (table->indexes[x].index_type == H5SM_LIST ? "List" : - (table->indexes[x].index_type == H5SM_BTREE ? "B-Tree" : "Unknown"))); - - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Address of index:", table->indexes[x].index_addr); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Address of index's heap:", table->indexes[x].heap_addr); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "SOHM Index Type:", + (table->indexes[x].index_type == H5SM_LIST + ? "List" + : (table->indexes[x].index_type == H5SM_BTREE ? "B-Tree" : "Unknown"))); + + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", fwidth, + "Address of index:", table->indexes[x].index_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", fwidth, + "Address of index's heap:", table->indexes[x].heap_addr); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent + 3, "", fwidth, - "Message type flags:", table->indexes[x].mesg_types); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Minimum size of messages:", table->indexes[x].min_mesg_size); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Number of messages:", table->indexes[x].num_messages); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Maximum list size:", table->indexes[x].list_max); - HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, - "Minimum B-tree size:", table->indexes[x].btree_min); + "Message type flags:", table->indexes[x].mesg_types); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", fwidth, + "Minimum size of messages:", table->indexes[x].min_mesg_size); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", fwidth, + "Number of messages:", table->indexes[x].num_messages); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", fwidth, + "Maximum list size:", table->indexes[x].list_max); + HDfprintf(stream, "%*s%-*s %zu\n", indent + 3, "", fwidth, + "Minimum B-tree size:", table->indexes[x].btree_min); } /* end for */ done: - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_table_debug() */ - /*------------------------------------------------------------------------- * Function: H5SM_list_debug * @@ -2625,17 +2626,16 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, *------------------------------------------------------------------------- */ herr_t -H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, - int fwidth, haddr_t table_addr) +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_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 */ - unsigned index_num; /* Index of list, within master table */ - unsigned x; /* Counter variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned index_num; /* Index of list, within master table */ + unsigned x; /* Counter variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2649,75 +2649,74 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Determine which index the list is part of */ index_num = table->num_indexes; - for(x = 0; x < table->num_indexes; x++) { - if(H5F_addr_eq(table->indexes[x].index_addr, list_addr)) { + for (x = 0; x < table->num_indexes; x++) { + if (H5F_addr_eq(table->indexes[x].index_addr, list_addr)) { index_num = x; break; } /* end if */ - } /* end for */ - if(x == table->num_indexes) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "list address doesn't match address for any indices in table") + } /* end for */ + if (x == table->num_indexes) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "list address doesn't match address for any indices in table") /* Set up user data for metadata cache callback */ - lst_cache_udata.f = f; + lst_cache_udata.f = f; lst_cache_udata.header = &(table->indexes[index_num]); /* Get the list from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, + H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") /* Open the heap, if one exists */ - if(H5F_addr_defined(table->indexes[index_num].heap_addr)) - if(NULL == (fh = H5HF_open(f, table->indexes[index_num].heap_addr))) + if (H5F_addr_defined(table->indexes[index_num].heap_addr)) + if (NULL == (fh = H5HF_open(f, table->indexes[index_num].heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open SOHM heap") HDfprintf(stream, "%*sShared Message List Index...\n", indent, ""); - for(x = 0; x < table->indexes[index_num].num_messages; ++x) { + for (x = 0; x < table->indexes[index_num].num_messages; ++x) { HDfprintf(stream, "%*sShared Object Header Message %d...\n", indent, "", x); HDfprintf(stream, "%*s%-*s %08lu\n", indent + 3, "", fwidth, - "Hash value:", (unsigned long)list->messages[x].hash); - if(list->messages[x].location == H5SM_IN_HEAP) { + "Hash value:", (unsigned long)list->messages[x].hash); + if (list->messages[x].location == H5SM_IN_HEAP) { HDassert(fh); - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "in heap"); - HDfprintf(stream, "%*s%-*s 0x%Zx\n", indent + 3, "", fwidth, - "Heap ID:", list->messages[x].u.heap_loc.fheap_id); - HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Reference count:", list->messages[x].u.heap_loc.ref_count); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "in heap"); + HDfprintf(stream, "%*s%-*s 0x%" PRIx64 "\n", indent + 3, "", fwidth, + "Heap ID:", list->messages[x].u.heap_loc.fheap_id.val); + HDfprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent + 3, "", fwidth, + "Reference count:", list->messages[x].u.heap_loc.ref_count); } /* end if */ - else if(list->messages[x].location == H5SM_IN_OH) { - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "in object header"); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth, - "Object header address:", list->messages[x].u.mesg_loc.oh_addr); - HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Message creation index:", list->messages[x].u.mesg_loc.oh_addr); + else if (list->messages[x].location == H5SM_IN_OH) { + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "in object header"); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", fwidth, + "Object header address:", list->messages[x].u.mesg_loc.oh_addr); + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", fwidth, + "Message creation index:", list->messages[x].u.mesg_loc.oh_addr); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, - "Message type ID:", list->messages[x].msg_type_id); + "Message type ID:", list->messages[x].msg_type_id); } /* end if */ else - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, - "Location:", "invalid"); + HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "invalid"); } /* end for */ done: - if(fh && H5HF_close(fh) < 0) + if (fh && H5HF_close(fh) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close SOHM heap") - if(list && H5AC_unprotect(f, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_list_debug() */ - /*------------------------------------------------------------------------- * Function: H5SM_ih_size * @@ -2737,12 +2736,12 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, 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_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 */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__SOHM_TAG, FAIL) @@ -2756,61 +2755,61 @@ H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Get SOHM header size */ *hdr_size = table->table_size; /* Loop over all the indices for shared messages */ - for(u = 0; u < table->num_indexes; u++) { + for (u = 0; u < table->num_indexes; u++) { /* Get index storage size (for either B-tree or list) */ - if(table->indexes[u].index_type == H5SM_BTREE) { - if(H5F_addr_defined(table->indexes[u].index_addr)) { + if (table->indexes[u].index_type == H5SM_BTREE) { + if (H5F_addr_defined(table->indexes[u].index_addr)) { /* Open the index v2 B-tree */ - if(NULL == (bt2 = H5B2_open(f, table->indexes[u].index_addr, f))) + if (NULL == (bt2 = H5B2_open(f, table->indexes[u].index_addr, f))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index") - if(H5B2_size(bt2, &(ih_info->index_size)) < 0) + if (H5B2_size(bt2, &(ih_info->index_size)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") /* Close the v2 B-tree */ - if(H5B2_close(bt2) < 0) + if (H5B2_close(bt2) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") bt2 = NULL; } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(table->indexes[u].index_type == H5SM_LIST); - ih_info->index_size += table->indexes[u].list_size; + ih_info->index_size += table->indexes[u].list_size; } /* end else */ /* Check for heap for this index */ - if(H5F_addr_defined(table->indexes[u].heap_addr)) { + if (H5F_addr_defined(table->indexes[u].heap_addr)) { /* Open the fractal heap for this index */ - if(NULL == (fheap = H5HF_open(f, table->indexes[u].heap_addr))) + if (NULL == (fheap = H5HF_open(f, table->indexes[u].heap_addr))) HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") /* Get heap storage size */ - if(H5HF_size(fheap, &(ih_info->heap_size)) < 0) + if (H5HF_size(fheap, &(ih_info->heap_size)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") /* Close the fractal heap */ - if(H5HF_close(fheap) < 0) + if (H5HF_close(fheap) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") fheap = NULL; } /* end if */ - } /* end for */ + } /* end for */ done: /* Release resources */ - if(fheap && H5HF_close(fheap) < 0) + if (fheap && H5HF_close(fheap) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") - if(bt2 && H5B2_close(bt2) < 0) + if (bt2 && H5B2_close(bt2) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_ih_size() */ - diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 7f6c804ad9e..2dca9fdefc8 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,60 +15,54 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* 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); - +static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); /*****************************/ /* Library Private Variables */ /*****************************/ /* v2 B-tree class for SOHM indexes*/ -const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ - H5B2_SOHM_INDEX_ID, /* Type of B-tree */ - "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ - sizeof(H5SM_sohm_t), /* Size of native record */ - H5SM__bt2_crt_context, /* Create client callback context */ - H5SM__bt2_dst_context, /* Destroy client callback context */ - H5SM__bt2_store, /* Record storage callback */ - H5SM__message_compare, /* Record comparison callback */ - H5SM__message_encode, /* Record encoding callback */ - H5SM__message_decode, /* Record decoding callback */ - H5SM__bt2_debug /* Record debugging callback */ +const H5B2_class_t H5SM_INDEX[1] = {{ + /* B-tree class information */ + H5B2_SOHM_INDEX_ID, /* Type of B-tree */ + "H5B2_SOHM_INDEX_ID", /* Name of B-tree class */ + sizeof(H5SM_sohm_t), /* Size of native record */ + H5SM__bt2_crt_context, /* Create client callback context */ + H5SM__bt2_dst_context, /* Destroy client callback context */ + H5SM__bt2_store, /* Record storage callback */ + H5SM__message_compare, /* Record comparison callback */ + H5SM__message_encode, /* Record encoding callback */ + H5SM__message_decode, /* Record decoding callback */ + H5SM__bt2_debug /* Record debugging callback */ }}; - /*******************/ /* Local Variables */ /*******************/ @@ -76,8 +70,6 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ /* Declare a free list to manage the H5SM_bt2_ctx_t struct */ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); - - /*------------------------------------------------------------------------- * Function: H5SM__bt2_crt_context * @@ -94,9 +86,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 */ - H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -104,7 +96,7 @@ H5SM__bt2_crt_context(void *_f) HDassert(f); /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + if (NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") /* Determine the size of addresses & lengths in the file */ @@ -117,7 +109,6 @@ H5SM__bt2_crt_context(void *_f) FUNC_LEAVE_NOAPI(ret_value) } /* H5SM__bt2_crt_context() */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_dst_context * @@ -134,7 +125,7 @@ H5SM__bt2_crt_context(void *_f) static herr_t H5SM__bt2_dst_context(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 */ FUNC_ENTER_STATIC_NOERR @@ -147,7 +138,6 @@ H5SM__bt2_dst_context(void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5SM__bt2_dst_context() */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_store * @@ -176,7 +166,6 @@ H5SM__bt2_store(void *native, const void *udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__bt2_store */ - /*------------------------------------------------------------------------- * Function: H5SM__bt2_debug * @@ -191,66 +180,22 @@ 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 H5_ATTR_UNUSED *_udata) +H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record; FUNC_ENTER_STATIC_NOERR - if(sohm->location == H5SM_IN_HEAP) - HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, - "Shared Message in heap:", - sohm->u.heap_loc.fheap_id, sohm->hash, sohm->u.heap_loc.ref_count); + if (sohm->location == H5SM_IN_HEAP) + HDfprintf(stream, "%*s%-*s {%" PRIu64 ", %" PRIo32 ", %" PRIxHSIZE "}\n", indent, "", fwidth, + "Shared Message in heap:", sohm->u.heap_loc.fheap_id.val, sohm->hash, + sohm->u.heap_loc.ref_count); else { HDassert(sohm->location == H5SM_IN_OH); - HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx, %Hx}\n", indent, "", fwidth, - "Shared Message in OH:", - sohm->u.mesg_loc.oh_addr, sohm->hash, sohm->msg_type_id, sohm->u.mesg_loc.index); + HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %" PRIo32 ", %x, %" PRIx32 "}\n", indent, "", fwidth, + "Shared Message in OH:", sohm->u.mesg_loc.oh_addr, sohm->hash, sohm->msg_type_id, + sohm->u.mesg_loc.index); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__bt2_debug */ - - -/*------------------------------------------------------------------------- - * Function: H5SM_bt2_convert_to_list_op - * - * Purpose: An H5B2_remove_t callback function to convert a SOHM - * B-tree index to a list. - * - * Inserts this record into the list passed through op_data. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_bt2_convert_to_list_op(const void * record, void *op_data) -{ - const H5SM_sohm_t *message = (const H5SM_sohm_t *)record; - const H5SM_list_t *list = (const H5SM_list_t *)op_data; - size_t mesg_idx; /* Index of message to modify */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity checks */ - HDassert(record); - HDassert(op_data); - - /* Get the message index, and increment the # of messages in list */ - mesg_idx = list->header->num_messages++; - HDassert(list->header->num_messages <= list->header->list_max); - - /* Insert this message at the end of the list */ - HDassert(list->messages[mesg_idx].location == H5SM_NO_LOC); - HDassert(message->location != H5SM_NO_LOC); - H5MM_memcpy(&(list->messages[mesg_idx]), message, sizeof(H5SM_sohm_t)); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_bt2_convert_to_list_op() */ - diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 7f243a6afe4..2ad467f1721 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,7 +15,7 @@ * * Created: H5SMcache.c * Nov 13 2006 - * James Laird + * James Laird * * Purpose: Implement shared message metadata cache methods. * @@ -26,31 +26,27 @@ /* Module Setup */ /****************/ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5SMpkg.h" /* Shared object header messages */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5SMpkg.h" /* Shared object header messages */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ @@ -58,74 +54,65 @@ /* 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_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_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5SM__cache_list_free_icr(void *thing); - /*********************/ /* Package Variables */ /*********************/ /* H5SM inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SOHM_TABLE[1] = {{ - H5AC_SOHM_TABLE_ID, /* Metadata client ID */ - "shared message table", /* Metadata client name (for debugging) */ - H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5SM__cache_table_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5SM__cache_table_verify_chksum, /* 'verify_chksum' callback */ - H5SM__cache_table_deserialize, /* 'deserialize' callback */ - H5SM__cache_table_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5SM__cache_table_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5SM__cache_table_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_SOHM_TABLE_ID, /* Metadata client ID */ + "shared message table", /* Metadata client name (for debugging) */ + H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5SM__cache_table_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5SM__cache_table_verify_chksum, /* 'verify_chksum' callback */ + H5SM__cache_table_deserialize, /* 'deserialize' callback */ + H5SM__cache_table_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5SM__cache_table_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5SM__cache_table_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; const H5AC_class_t H5AC_SOHM_LIST[1] = {{ - H5AC_SOHM_LIST_ID, /* Metadata client ID */ - "shared message list", /* Metadata client name (for debugging) */ - H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ - H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ - H5SM__cache_list_get_initial_load_size, /* 'get_initial_load_size' callback */ - NULL, /* 'get_final_load_size' callback */ - H5SM__cache_list_verify_chksum, /* 'verify_chksum' callback */ - H5SM__cache_list_deserialize, /* 'deserialize' callback */ - H5SM__cache_list_image_len, /* 'image_len' callback */ - NULL, /* 'pre_serialize' callback */ - H5SM__cache_list_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ - H5SM__cache_list_free_icr, /* 'free_icr' callback */ - NULL, /* 'fsf_size' callback */ + H5AC_SOHM_LIST_ID, /* Metadata client ID */ + "shared message list", /* Metadata client name (for debugging) */ + H5FD_MEM_SOHM_TABLE, /* File space memory type for client */ + H5AC__CLASS_NO_FLAGS_SET, /* Client class behavior flags */ + H5SM__cache_list_get_initial_load_size, /* 'get_initial_load_size' callback */ + NULL, /* 'get_final_load_size' callback */ + H5SM__cache_list_verify_chksum, /* 'verify_chksum' callback */ + H5SM__cache_list_deserialize, /* 'deserialize' callback */ + H5SM__cache_list_image_len, /* 'image_len' callback */ + NULL, /* 'pre_serialize' callback */ + H5SM__cache_list_serialize, /* 'serialize' callback */ + NULL, /* 'notify' callback */ + H5SM__cache_list_free_icr, /* 'free_icr' callback */ + NULL, /* 'fsf_size' callback */ }}; - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_get_initial_load_size() * @@ -143,7 +130,7 @@ const H5AC_class_t H5AC_SOHM_LIST[1] = {{ static herr_t H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) { - const H5SM_table_cache_ud_t *udata = (const H5SM_table_cache_ud_t *)_udata; /* User data for callback */ + const H5SM_table_cache_ud_t *udata = (const H5SM_table_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -158,7 +145,6 @@ H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_table_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_verify_chksum * @@ -175,10 +161,10 @@ H5SM__cache_table_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5SM__cache_table_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; /* Return value */ + 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; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -188,13 +174,12 @@ H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU /* Get stored and computed checksums */ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) + if (stored_chksum != computed_chksum) ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_table_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_deserialize * @@ -212,16 +197,16 @@ H5SM__cache_table_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNU *------------------------------------------------------------------------- */ static void * -H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, - void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +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 */ - 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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - size_t u; /* Counter variable for index headers */ - void *ret_value = NULL; /* Return value */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + size_t u; /* Counter variable for index headers */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -239,7 +224,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(H5F_SOHM_VERS(f) == HDF5_SHAREDHEADER_VERSION); /* Allocate space for the master table in memory */ - if(NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) + if (NULL == (table = H5FL_CALLOC(H5SM_master_table_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed") /* Read number of indexes and version from file superblock */ @@ -253,22 +238,23 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HDassert(table->table_size == len); /* Check magic number */ - if(HDmemcmp(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM table signature") image += H5_SIZEOF_MAGIC; /* Allocate space for the index headers in memory*/ - if(NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + if (NULL == (table->indexes = + (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed for SOHM indexes") /* Read in the index headers */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Verify correct version of index list */ - if(H5SM_LIST_VERSION != *image++) + if (H5SM_LIST_VERSION != *image++) HGOTO_ERROR(H5E_SOHM, H5E_VERSION, NULL, "bad shared message list version number") /* Type of the index (list or B-tree) */ - table->indexes[u].index_type= (H5SM_index_type_t)*image++; + table->indexes[u].index_type = (H5SM_index_type_t)*image++; /* Type of messages in the index */ UINT16DECODE(image, table->indexes[u].mesg_types); @@ -291,7 +277,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l /* Address of the index's heap */ H5F_addr_decode(f, &image, &(table->indexes[u].heap_addr)); - /* Compute the size of a list index for this SOHM index */ + /* Compute the size of a list index for this SOHM index */ table->indexes[u].list_size = H5SM_LIST_SIZE(f, table->indexes[u].list_max); } /* end for */ @@ -307,14 +293,13 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l ret_value = table; done: - if(!ret_value && table) - if(H5SM_table_free(table) < 0) + if (!ret_value && table) + if (H5SM__table_free(table) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_table_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_image_len * @@ -333,7 +318,8 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l static herr_t H5SM__cache_table_image_len(const void *_thing, size_t *image_len) { - const H5SM_master_table_t *table = (const H5SM_master_table_t *)_thing; /* Shared message table to query */ + const H5SM_master_table_t *table = + (const H5SM_master_table_t *)_thing; /* Shared message table to query */ FUNC_ENTER_STATIC_NOERR @@ -348,7 +334,6 @@ H5SM__cache_table_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_table_image_len() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_serialize * @@ -364,13 +349,12 @@ 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 H5_ATTR_NDEBUG_UNUSED len, - void *_thing) +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 */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - size_t u; /* Counter variable */ + uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + size_t u; /* Counter variable */ FUNC_ENTER_STATIC_NOERR @@ -392,7 +376,7 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ image += H5_SIZEOF_MAGIC; /* Encode each index header */ - for(u = 0; u < table->num_indexes; ++u) { + for (u = 0; u < table->num_indexes; ++u) { /* Version for this list */ *image++ = H5SM_LIST_VERSION; @@ -435,7 +419,6 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ /* no H5SM_cache_table_notify() function */ /*****************************************/ - /*------------------------------------------------------------------------- * Function: H5SM__cache_table_free_icr * @@ -456,8 +439,8 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ static herr_t H5SM__cache_table_free_icr(void *_thing) { - H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -467,14 +450,13 @@ H5SM__cache_table_free_icr(void *_thing) HDassert(table->cache_info.type == H5AC_SOHM_TABLE); /* Destroy Shared Object Header Message table */ - if(H5SM_table_free(table) < 0) + if (H5SM__table_free(table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message table") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_cache_table_free_icr() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_get_initial_load_size() * @@ -493,7 +475,7 @@ H5SM__cache_table_free_icr(void *_thing) static herr_t H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) { - const H5SM_list_cache_ud_t *udata = (const H5SM_list_cache_ud_t *)_udata; /* User data for callback */ + const H5SM_list_cache_ud_t *udata = (const H5SM_list_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -509,7 +491,6 @@ H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_list_get_initial_load_size() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_verify_chksum * @@ -526,12 +507,12 @@ 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 */ - 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 */ - uint32_t computed_chksum; /* Computed metadata checksum value */ - htri_t ret_value = TRUE; /* Return value */ + 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 */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -545,13 +526,12 @@ H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo /* Get stored and computed checksums */ H5F_get_checksums(image, chk_size, &stored_chksum, &computed_chksum); - if(stored_chksum != computed_chksum) - ret_value = FALSE; + if (stored_chksum != computed_chksum) + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_list_verify_chksum() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_deserialize * @@ -568,16 +548,16 @@ H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, vo *------------------------------------------------------------------------- */ 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__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_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 */ - uint32_t stored_chksum; /* Stored metadata checksum value */ - size_t u; /* Counter variable for messages in list */ - void *ret_value = NULL; /* Return value */ + 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 */ + uint32_t stored_chksum; /* Stored metadata checksum value */ + size_t u; /* Counter variable for messages in list */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -590,24 +570,24 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le HDassert(dirty); /* Allocate space for the SOHM list data structure */ - if(NULL == (list = H5FL_MALLOC(H5SM_list_t))) + if (NULL == (list = H5FL_MALLOC(H5SM_list_t))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&list->cache_info, 0, sizeof(H5AC_info_t)); /* Allocate list in memory as an array*/ - if(NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_MALLOC(H5SM_sohm_t, udata->header->list_max))) + if (NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_MALLOC(H5SM_sohm_t, udata->header->list_max))) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "file allocation failed for SOHM list") list->header = udata->header; /* Check magic number */ - if(HDmemcmp(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if (HDmemcmp(image, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM list signature") image += H5_SIZEOF_MAGIC; /* Read messages into the list array */ ctx.sizeof_addr = H5F_SIZEOF_ADDR(udata->f); - for(u = 0; u < udata->header->num_messages; u++) { - if(H5SM__message_decode(image, &(list->messages[u]), &ctx) < 0) + for (u = 0; u < udata->header->num_messages; u++) { + if (H5SM__message_decode(image, &(list->messages[u]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "can't decode shared message") image += H5SM_SOHM_ENTRY_SIZE(udata->f); @@ -622,15 +602,15 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le HDassert((size_t)(image - (const uint8_t *)_image) <= udata->header->list_size); /* Initialize the rest of the array */ - for(u = udata->header->num_messages; u < udata->header->list_max; u++) + for (u = udata->header->num_messages; u < udata->header->list_max; u++) list->messages[u].location = H5SM_NO_LOC; /* Set return value */ ret_value = list; done: - if(!ret_value && list) { - if(list->messages) + if (!ret_value && list) { + if (list->messages) list->messages = H5FL_ARR_FREE(H5SM_sohm_t, list->messages); list = H5FL_FREE(H5SM_list_t, list); } /* end if */ @@ -638,7 +618,6 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_list_deserialize() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_image_len * @@ -655,7 +634,7 @@ H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED le static herr_t H5SM__cache_list_image_len(const void *_thing, size_t *image_len) { - const H5SM_list_t *list = (const H5SM_list_t *)_thing; /* Shared message list to query */ + const H5SM_list_t *list = (const H5SM_list_t *)_thing; /* Shared message list to query */ FUNC_ENTER_STATIC_NOERR @@ -671,7 +650,6 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__cache_list_image_len() */ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_serialize * @@ -687,16 +665,15 @@ 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__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_bt2_ctx_t ctx; /* Message encoding context */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint32_t computed_chksum; /* Computed metadata checksum value */ + size_t mesgs_serialized; /* Number of messages serialized */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -715,16 +692,16 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_U /* serialize messages from the messages array */ mesgs_serialized = 0; - ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); - for(u = 0; ((u < list->header->list_max) && (mesgs_serialized < list->header->num_messages)); u++) { - if(list->messages[u].location != H5SM_NO_LOC) { - if(H5SM__message_encode(image, &(list->messages[u]), &ctx) < 0) + ctx.sizeof_addr = H5F_SIZEOF_ADDR(f); + for (u = 0; ((u < list->header->list_max) && (mesgs_serialized < list->header->num_messages)); u++) { + if (list->messages[u].location != H5SM_NO_LOC) { + if (H5SM__message_encode(image, &(list->messages[u]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to serialize shared message") image += H5SM_SOHM_ENTRY_SIZE(f); ++mesgs_serialized; } /* end if */ - } /* end for */ + } /* end for */ HDassert(mesgs_serialized == list->header->num_messages); @@ -746,7 +723,6 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_U /* no H5SM_cache_list_notify() function */ /****************************************/ - /*------------------------------------------------------------------------- * Function: H5SM__cache_list_free_icr * @@ -767,8 +743,8 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_U static herr_t H5SM__cache_list_free_icr(void *_thing) { - H5SM_list_t *list = (H5SM_list_t *)_thing; /* Shared message list to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_list_t *list = (H5SM_list_t *)_thing; /* Shared message list to release */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -778,10 +754,9 @@ H5SM__cache_list_free_icr(void *_thing) HDassert(list->cache_info.type == H5AC_SOHM_LIST); /* Destroy Shared Object Header Message list */ - if(H5SM_list_free(list) < 0) + if (H5SM__list_free(list) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_cache_list_free_icr() */ - diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index e085204218f..4499b0c3069 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,63 +15,54 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object Headers */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object Headers */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ -/* Udata struct for calls to H5SM_compare_cb and H5SM_compare_iter_op*/ +/* Udata struct for calls to H5SM__compare_cb and H5SM__compare_iter_op*/ typedef struct H5SM_compare_udata_t { const H5SM_mesg_key_t *key; /* Key; compare this against stored message */ - H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ - herr_t ret; /* Return value; set this to result of memcmp */ + H5O_msg_crt_idx_t idx; /* Index of the message in the OH, if applicable */ + herr_t ret; /* Return value; set this to result of memcmp */ } H5SM_compare_udata_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5SM_compare_cb(const void *obj, size_t obj_len, void *udata); -static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, - unsigned *oh_modified, void *udata); - +static herr_t H5SM__compare_cb(const void *obj, size_t obj_len, void *udata); +static herr_t H5SM__compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, unsigned *oh_modified, + void *udata); /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- - * Function: H5SM_compare_cb + * Function: H5SM__compare_cb * * Purpose: Callback for H5HF_op, used in H5SM__message_compare below. * Determines whether the search key passed in in _UDATA is @@ -87,27 +78,26 @@ static herr_t H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequenc *------------------------------------------------------------------------- */ static herr_t -H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) +H5SM__compare_cb(const void *obj, size_t obj_len, void *_udata) { H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* If the encoding sizes are different, it's not the same object */ - if(udata->key->encoding_size > obj_len) + if (udata->key->encoding_size > obj_len) udata->ret = 1; - else if(udata->key->encoding_size < obj_len) + else if (udata->key->encoding_size < obj_len) udata->ret = -1; else /* Sizes are the same. Return result of memcmp */ udata->ret = HDmemcmp(udata->key->encoding, obj, obj_len); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_compare_cb() */ +} /* end H5SM__compare_cb() */ - /*------------------------------------------------------------------------- - * Function: H5SM_compare_iter_op + * Function: H5SM__compare_iter_op * * Purpose: OH iteration callback to compare a key against a message in * an OH @@ -123,13 +113,13 @@ H5SM_compare_cb(const void *obj, size_t obj_len, void *_udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, - unsigned H5_ATTR_UNUSED *oh_modified, void *_udata/*in,out*/) +H5SM__compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, + unsigned H5_ATTR_UNUSED *oh_modified, void *_udata /*in,out*/) { - H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *) _udata; - herr_t ret_value = H5_ITER_CONT; + H5SM_compare_udata_t *udata = (H5SM_compare_udata_t *)_udata; + herr_t ret_value = H5_ITER_CONT; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* * Check arguments. @@ -139,21 +129,22 @@ H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, HDassert(udata && udata->key); /* Check the creation index for this message */ - if(sequence == udata->idx) { + if (sequence == udata->idx) { size_t aligned_encoded_size = H5O_ALIGN_OH(oh, udata->key->encoding_size); /* Sanity check the message's length */ HDassert(mesg->raw_size > 0); - if(aligned_encoded_size > mesg->raw_size) + if (aligned_encoded_size > mesg->raw_size) udata->ret = 1; - else if(aligned_encoded_size < mesg->raw_size) + else if (aligned_encoded_size < mesg->raw_size) udata->ret = -1; else { /* Check if the message is dirty & flush it to the object header if so */ - if(mesg->dirty) - if(H5O_msg_flush(udata->key->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message") + if (mesg->dirty) + if (H5O_msg_flush(udata->key->file, oh, mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, + "unable to encode object header message") HDassert(udata->key->encoding_size <= mesg->raw_size); udata->ret = HDmemcmp(udata->key->encoding, mesg->raw, udata->key->encoding_size); @@ -165,9 +156,8 @@ H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_compare_iter_op() */ +} /* end H5SM__compare_iter_op() */ - /*------------------------------------------------------------------------- * Function: H5SM__message_compare * @@ -187,9 +177,9 @@ H5SM_compare_iter_op(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, 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; - herr_t ret_value = SUCCEED; + const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)rec1; + const H5SM_sohm_t * mesg = (const H5SM_sohm_t *)rec2; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -199,25 +189,25 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) * Likewise, if the message has an OH location that is matched by the * message in the index, we've found the message. */ - if(mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { - if(key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { + if (mesg->location == H5SM_IN_HEAP && key->message.location == H5SM_IN_HEAP) { + if (key->message.u.heap_loc.fheap_id.val == mesg->u.heap_loc.fheap_id.val) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ - else if(mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { - if(key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && - key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && - key->message.msg_type_id == mesg->msg_type_id) { + else if (mesg->location == H5SM_IN_OH && key->message.location == H5SM_IN_OH) { + if (key->message.u.mesg_loc.oh_addr == mesg->u.mesg_loc.oh_addr && + key->message.u.mesg_loc.index == mesg->u.mesg_loc.index && + key->message.msg_type_id == mesg->msg_type_id) { *result = 0; HGOTO_DONE(SUCCEED); } } /* end if */ /* Compare hash values */ - if(key->message.hash > mesg->hash) + if (key->message.hash > mesg->hash) *result = 1; - else if(key->message.hash < mesg->hash) + else if (key->message.hash < mesg->hash) *result = -1; /* If the hash values match, make sure the messages are really the same */ else { @@ -235,21 +225,21 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) /* Compare the encoded message with either the message in the heap or * the message in an object header. */ - if(mesg->location == H5SM_IN_HEAP) { + if (mesg->location == H5SM_IN_HEAP) { /* Call heap op routine with comparison callback */ - if(H5HF_op(key->fheap, &(mesg->u.heap_loc.fheap_id), H5SM_compare_cb, &udata) < 0) + if (H5HF_op(key->fheap, &(mesg->u.heap_loc.fheap_id), H5SM__compare_cb, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") } /* end if */ else { - H5O_loc_t oloc; /* Object owning the message */ - H5O_mesg_operator_t op; /* Message operator */ + H5O_loc_t oloc; /* Object owning the message */ + H5O_mesg_operator_t op; /* Message operator */ /* Sanity checks */ HDassert(key->file); HDassert(mesg->location == H5SM_IN_OH); /* Reset the object location */ - if(H5O_loc_reset(&oloc) < 0) + if (H5O_loc_reset(&oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize target location") /* Set up object location */ @@ -260,9 +250,9 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) udata.idx = mesg->u.mesg_loc.index; /* Locate the right message and compare with it */ - op.op_type = H5O_MESG_OP_LIB; - op.u.lib_op = H5SM_compare_iter_op; - if(H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata) < 0) + op.op_type = H5O_MESG_OP_LIB; + op.u.lib_op = H5SM__compare_iter_op; + if (H5O_msg_iterate(&oloc, mesg->msg_type_id, &op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") } /* end else */ @@ -273,7 +263,6 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__message_compare */ - /*------------------------------------------------------------------------- * Function: H5SM__message_encode * @@ -290,7 +279,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 @@ -301,14 +290,14 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) *raw++ = (uint8_t)message->location; UINT32ENCODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32ENCODE(raw, message->u.heap_loc.ref_count); H5MM_memcpy(raw, message->u.heap_loc.fheap_id.id, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - *raw++ = 0; /* reserved (possible flags byte) */ + *raw++ = 0; /* reserved (possible flags byte) */ *raw++ = (uint8_t)message->msg_type_id; UINT16ENCODE(raw, message->u.mesg_loc.index); H5F_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); @@ -317,7 +306,6 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__message_encode */ - /*------------------------------------------------------------------------- * Function: H5SM__message_decode * @@ -334,22 +322,22 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) 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_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_sohm_t * message = (H5SM_sohm_t *)_nrecord; FUNC_ENTER_PACKAGE_NOERR message->location = (H5SM_storage_loc_t)*raw++; UINT32DECODE(raw, message->hash); - if(message->location == H5SM_IN_HEAP) { + if (message->location == H5SM_IN_HEAP) { UINT32DECODE(raw, message->u.heap_loc.ref_count); H5MM_memcpy(message->u.heap_loc.fheap_id.id, raw, (size_t)H5O_FHEAP_ID_LEN); } /* end if */ else { HDassert(message->location == H5SM_IN_OH); - raw++; /* reserved */ + raw++; /* reserved */ message->msg_type_id = *raw++; UINT16DECODE(raw, message->u.mesg_loc.index); H5F_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); @@ -357,4 +345,3 @@ H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SM__message_decode */ - diff --git a/src/H5SMmodule.h b/src/H5SMmodule.h index ccd7b9f7eaa..6d2abf17831 100644 --- a/src/H5SMmodule.h +++ b/src/H5SMmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,15 @@ * H5SM package. Including this header means that the source file * is part of the H5SM package. */ -#ifndef _H5SMmodule_H -#define _H5SMmodule_H +#ifndef H5SMmodule_H +#define H5SMmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5SM_MODULE -#define H5_MY_PKG H5SM -#define H5_MY_PKG_ERR H5E_SOHM -#define H5_MY_PKG_INIT NO - -#endif /* _H5SMmodule_H */ +#define H5_MY_PKG H5SM +#define H5_MY_PKG_ERR H5E_SOHM +#define H5_MY_PKG_INIT NO +#endif /* H5SMmodule_H */ diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 0a04e5d5675..ae9a5f630a1 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,17 +23,16 @@ #error "Do not include this file outside the H5SM package!" #endif -#ifndef _H5SMpkg_H -#define _H5SMpkg_H +#ifndef H5SMpkg_H +#define H5SMpkg_H /* Get package's private header */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata Cache */ -#include "H5B2private.h" /* B-trees */ -#include "H5HFprivate.h" /* Fractal heaps */ - +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5B2private.h" /* B-trees */ +#include "H5HFprivate.h" /* Fractal heaps */ /****************************/ /* Package Macros */ @@ -42,61 +41,59 @@ /* Size of checksum information (on disk) */ #define H5SM_SIZEOF_CHECKSUM 4 -#define H5SM_HEAP_LOC_SIZE ( \ - (unsigned)4 /* Reference count */ \ - + sizeof(H5O_fheap_id_t) /* size of heap ID on disk */ \ +#define H5SM_HEAP_LOC_SIZE \ + ((unsigned)4 /* Reference count */ \ + + sizeof(H5O_fheap_id_t) /* size of heap ID on disk */ \ ) -#define H5SM_OH_LOC_SIZE(f) ( \ - (unsigned)1 /* reserved (possible flags?) */ \ - + (unsigned)1 /* message type ID */ \ - + (unsigned)2 /* creation index of message in OH */ \ - + H5F_SIZEOF_ADDR(f) /* address of OH */ \ +#define H5SM_OH_LOC_SIZE(f) \ + ((unsigned)1 /* reserved (possible flags?) */ \ + + (unsigned)1 /* message type ID */ \ + + (unsigned)2 /* creation index of message in OH */ \ + + H5F_SIZEOF_ADDR(f) /* address of OH */ \ ) -#define H5SM_SOHM_ENTRY_SIZE(f) ( \ - (unsigned)1 /* Message location */ \ - + (unsigned)4 /* Hash value */ \ - + MAX(H5SM_HEAP_LOC_SIZE, H5SM_OH_LOC_SIZE(f)) /* Entry */ \ +#define H5SM_SOHM_ENTRY_SIZE(f) \ + ((unsigned)1 /* Message location */ \ + + (unsigned)4 /* Hash value */ \ + + MAX(H5SM_HEAP_LOC_SIZE, H5SM_OH_LOC_SIZE(f)) /* Entry */ \ ) -#define H5SM_INDEX_HEADER_SIZE(f) ( \ - (unsigned)1 /* Whether index is a list or B-tree */ \ - + (unsigned)1 /* Version of index format */ \ - + (unsigned)2 /* Type of messages stored in the index */ \ - + (unsigned)4 /* Minimum size of messages to share */ \ - + (unsigned)(3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \ - + H5F_SIZEOF_ADDR(f) /* Location of list or B-tree */ \ - + H5F_SIZEOF_ADDR(f) /* Address of heap */ \ +#define H5SM_INDEX_HEADER_SIZE(f) \ + ((unsigned)1 /* Whether index is a list or B-tree */ \ + + (unsigned)1 /* Version of index format */ \ + + (unsigned)2 /* Type of messages stored in the index */ \ + + (unsigned)4 /* Minimum size of messages to share */ \ + + (unsigned)(3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \ + + H5F_SIZEOF_ADDR(f) /* Location of list or B-tree */ \ + + H5F_SIZEOF_ADDR(f) /* Address of heap */ \ ) /* Format overhead for all SOHM tree metadata in the file */ -#define H5SM_METADATA_PREFIX_SIZE ( \ - H5_SIZEOF_MAGIC /* Signature */ \ - + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ - ) - -#define H5SM_TABLE_SIZE(f) ( \ - /* General metadata fields */ \ - H5SM_METADATA_PREFIX_SIZE \ - \ - /* Indices */ \ - + (H5F_SOHM_NINDEXES(f) * H5SM_INDEX_HEADER_SIZE(f)) \ - ) - -#define H5SM_LIST_SIZE(f, num_mesg) ( \ - /* General metadata fields */ \ - H5SM_METADATA_PREFIX_SIZE \ - \ - /* Message entries */ \ - + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg) \ +#define H5SM_METADATA_PREFIX_SIZE \ + (H5_SIZEOF_MAGIC /* Signature */ \ + + H5SM_SIZEOF_CHECKSUM /* Checksum */ \ ) -#define H5SM_B2_NODE_SIZE 512 +#define H5SM_TABLE_SIZE(f) \ + (/* General metadata fields */ \ + H5SM_METADATA_PREFIX_SIZE \ + \ + /* Indices */ \ + + (H5F_SOHM_NINDEXES(f) * H5SM_INDEX_HEADER_SIZE(f))) + +#define H5SM_LIST_SIZE(f, num_mesg) \ + (/* General metadata fields */ \ + H5SM_METADATA_PREFIX_SIZE \ + \ + /* Message entries */ \ + + (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg)) + +#define H5SM_B2_NODE_SIZE 512 #define H5SM_B2_SPLIT_PERCENT 100 #define H5SM_B2_MERGE_PERCENT 40 -#define H5SM_LIST_VERSION 0 /* Version of Shared Object Header Message List Indexes */ +#define H5SM_LIST_VERSION 0 /* Version of Shared Object Header Message List Indexes */ /****************************/ /* Package Typedefs */ @@ -132,49 +129,49 @@ /* Where a message is stored */ typedef enum { - H5SM_NO_LOC = -1, - H5SM_IN_HEAP = 0, /* Message is stored in the heap */ - H5SM_IN_OH /* Message is stored in an object header */ + H5SM_NO_LOC = -1, + H5SM_IN_HEAP = 0, /* Message is stored in the heap */ + H5SM_IN_OH /* Message is stored in an object header */ } H5SM_storage_loc_t; /* Typedef for a record's location if it's stored in the heap */ typedef struct { - hsize_t ref_count; /* Number of times this message is used in the file */ - H5O_fheap_id_t fheap_id; /* ID of the OHM in the fractal heap */ + hsize_t ref_count; /* Number of times this message is used in the file */ + H5O_fheap_id_t fheap_id; /* ID of the OHM in the fractal heap */ } H5SM_heap_loc_t; /* Typedef for a SOHM index node */ typedef struct { - H5SM_storage_loc_t location; /* Type of message location */ - uint32_t hash; /* Hash value for encoded OHM */ - unsigned msg_type_id; /* Message's type ID */ + H5SM_storage_loc_t location; /* Type of message location */ + uint32_t hash; /* Hash value for encoded OHM */ + unsigned msg_type_id; /* Message's type ID */ union { - H5O_mesg_loc_t mesg_loc; /* Location of message in object header */ - H5SM_heap_loc_t heap_loc; /* Heap ID for message in SOHM heap */ + H5O_mesg_loc_t mesg_loc; /* Location of message in object header */ + H5SM_heap_loc_t heap_loc; /* Heap ID for message in SOHM heap */ } u; } H5SM_sohm_t; /* Types of message indices */ typedef enum { H5SM_BADTYPE = -1, - H5SM_LIST, /* Index is an unsorted list */ - H5SM_BTREE /* Index is a sorted B-tree */ + H5SM_LIST, /* Index is an unsorted list */ + H5SM_BTREE /* Index is a sorted B-tree */ } H5SM_index_type_t; /* Typedef for a SOHM index header */ typedef struct { -/* Stored */ - unsigned mesg_types; /* Bit flag vector of message types */ - size_t min_mesg_size; /* number of messages being tracked */ - size_t list_max; /* >= this many messages, index with a B-tree */ - size_t btree_min; /* <= this many messages, index with a list again */ - size_t num_messages; /* number of messages being tracked */ - H5SM_index_type_t index_type; /* Is the index a list or a B-tree? */ - haddr_t index_addr; /* Address of the actual index (list or B-tree) */ - haddr_t heap_addr; /* Address of the fheap used to store shared messages */ - -/* Not stored */ - size_t list_size; /* Size of list index on disk */ + /* Stored */ + unsigned mesg_types; /* Bit flag vector of message types */ + size_t min_mesg_size; /* number of messages being tracked */ + size_t list_max; /* >= this many messages, index with a B-tree */ + size_t btree_min; /* <= this many messages, index with a list again */ + size_t num_messages; /* number of messages being tracked */ + H5SM_index_type_t index_type; /* Is the index a list or a B-tree? */ + haddr_t index_addr; /* Address of the actual index (list or B-tree) */ + haddr_t heap_addr; /* Address of the fheap used to store shared messages */ + + /* Not stored */ + size_t list_size; /* Size of list index on disk */ } H5SM_index_header_t; /* Typedef for a SOHM list */ @@ -182,8 +179,8 @@ typedef struct { /* Information for H5AC cache functions, _must_ be first field in structure */ 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_index_header_t *header; /* Pointer to the corresponding index header */ + H5SM_sohm_t * messages; /* Actual list, stored as an array */ } H5SM_list_t; /* Typedef for shared object header message master table */ @@ -191,20 +188,20 @@ struct H5SM_master_table_t { /* Information for H5AC cache functions, _must_ be first field in structure */ H5AC_info_t cache_info; - size_t table_size; /* Size of table on disk */ - unsigned num_indexes; /* Number of indexes */ - H5SM_index_header_t *indexes; /* Array of num_indexes indexes */ + size_t table_size; /* Size of table on disk */ + unsigned num_indexes; /* Number of indexes */ + H5SM_index_header_t *indexes; /* Array of num_indexes indexes */ }; /* 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 */ - 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 - * heap ID, the heap ID will be 0. */ + 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 + * heap ID, the heap ID will be 0. */ } H5SM_mesg_key_t; /* @@ -213,35 +210,34 @@ typedef struct { */ typedef struct { /* downward (internal) */ - unsigned type_id; /* Message type */ + unsigned type_id; /* Message type */ /* upward */ - uint32_t hash; /* Hash value */ + uint32_t hash; /* Hash value */ } H5SM_fh_ud_gh_t; /* Typedef to increment a reference count in the B-tree */ typedef struct { - H5SM_mesg_key_t *key; /* IN: key for message being incremented */ - H5O_fheap_id_t fheap_id; /* OUT: fheap ID of record */ + H5SM_mesg_key_t *key; /* IN: key for message being incremented */ + H5O_fheap_id_t fheap_id; /* OUT: fheap ID of record */ } H5SM_incr_ref_opdata; /* v2 B-tree client callback context */ typedef struct H5SM_bt2_ctx_t { - uint8_t sizeof_addr; /* Size of file addresses */ + uint8_t sizeof_addr; /* Size of file addresses */ } H5SM_bt2_ctx_t; /* Callback info for loading a shared message table index into the cache */ typedef struct H5SM_table_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_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; - /****************************/ /* Package Variables */ /****************************/ @@ -259,27 +255,20 @@ H5_DLLVAR const H5B2_class_t H5SM_INDEX[1]; /****************************/ /* General routines */ -H5_DLL ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id); +H5_DLL ssize_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id); /* Encode and decode routines, used for B-tree and cache encoding/decoding */ H5_DLL herr_t H5SM__message_compare(const void *rec1, const void *rec2, int *result); H5_DLL herr_t H5SM__message_encode(uint8_t *raw, const void *native, void *ctx); H5_DLL herr_t H5SM__message_decode(const uint8_t *raw, void *native, void *ctx); -/* H5B2_remove_t callback to add messages to a list index */ -H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data); - -/* Fractal heap 'op' callback to compute hash value for message "in place" */ -H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata); - /* Routines to release data structures */ -herr_t H5SM_table_free(H5SM_master_table_t *table); -herr_t H5SM_list_free(H5SM_list_t *list); +H5_DLL herr_t H5SM__table_free(H5SM_master_table_t *table); +H5_DLL herr_t H5SM__list_free(H5SM_list_t *list); /* Testing functions */ #ifdef H5SM_TESTING H5_DLL herr_t H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count); #endif /* H5SM_TESTING */ -#endif /* _H5SMpkg_H */ - +#endif /* H5SMpkg_H */ diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index 80d369235d4..efe9355516a 100644 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,11 +18,11 @@ * Purpose: This file contains private declarations for the H5SM * shared object header messages module. */ -#ifndef _H5SMprivate_H -#define _H5SMprivate_H +#ifndef H5SMprivate_H +#define H5SMprivate_H -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ /**************************/ /* Library Private Macros */ @@ -30,9 +30,9 @@ /* Flags for the "defer_flags" argument to H5SM_try_share */ -#define H5SM_DEFER 0x01u /* Don't actually write shared message to index, heap; just update shared info */ -#define H5SM_WAS_DEFERRED 0x02u /* Message was previously updated by a call to H5SM_try_share with H5SM_DEFER */ - +#define H5SM_DEFER 0x01u /* Don't actually write shared message to index, heap; just update shared info */ +#define H5SM_WAS_DEFERRED \ + 0x02u /* Message was previously updated by a call to H5SM_try_share with H5SM_DEFER */ /****************************/ /* Library Private Typedefs */ @@ -41,33 +41,29 @@ /* Forward references of package typedefs */ typedef struct H5SM_master_table_t H5SM_master_table_t; - /******************************/ /* Library Private Prototypes */ /******************************/ /* Generally useful shared message routines */ H5_DLL herr_t H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc); -H5_DLL htri_t H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, - ssize_t *sohm_index_num, unsigned type_id, const void *mesg); -H5_DLL htri_t H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, - unsigned type_id, void *mesg, unsigned *mesg_flags); +H5_DLL htri_t H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, unsigned type_id, + const void *mesg); +H5_DLL htri_t H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, void *mesg, + unsigned *mesg_flags); H5_DLL herr_t H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg); H5_DLL herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist); H5_DLL htri_t H5SM_type_shared(H5F_t *f, unsigned type_id); H5_DLL herr_t H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr); -H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, - unsigned msg_type_id, H5O_fheap_id_t heap_id); -H5_DLL herr_t H5SM_get_refcount(H5F_t *f, unsigned type_id, - const H5O_shared_t *sh_mesg, hsize_t *ref_count); +H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, + H5O_fheap_id_t heap_id); +H5_DLL herr_t H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize_t *ref_count); H5_DLL herr_t H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info); - /* Debugging routines */ -H5_DLL herr_t H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, - int indent, int fwidth, unsigned table_vers, unsigned num_indexes); -H5_DLL herr_t H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, - int indent, int fwidth, haddr_t table_addr); - -#endif /*_H5SMprivate_H*/ +H5_DLL herr_t H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwidth, + unsigned table_vers, unsigned num_indexes); +H5_DLL herr_t H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidth, + haddr_t table_addr); +#endif /*H5SMprivate_H*/ diff --git a/src/H5SMtest.c b/src/H5SMtest.c index 0a6149d1b87..d6f96be1cab 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,52 +15,43 @@ /* Module Setup */ /****************/ -#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ -#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ - +#include "H5SMmodule.h" /* This source code file is part of the H5SM module */ +#define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5SMpkg.h" /* Shared object header messages */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5SM__get_mesg_count_test * @@ -76,8 +67,8 @@ herr_t H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(H5AC__SOHM_TAG) @@ -86,20 +77,21 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) HDassert(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_table_cache_ud_t cache_udata; /* User-data for callback */ - ssize_t index_num; /* Table index for message type */ + if (H5F_addr_defined(H5F_SOHM_ADDR(f))) { + 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 */ /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") /* Find the correct index for this message type */ - if((index_num = H5SM_get_index(table, type_id)) < 0) + if ((index_num = H5SM__get_index(table, type_id)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") header = &(table->indexes[index_num]); @@ -112,9 +104,8 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) done: /* Release resources */ - if(table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) + if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__get_mesg_count_test() */ - diff --git a/src/H5ST.c b/src/H5ST.c deleted file mode 100644 index 2570f729dcc..00000000000 --- a/src/H5ST.c +++ /dev/null @@ -1,795 +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://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* TERNARY SEARCH TREE ALGS - This code is described in "Ternary Search Trees" by Jon -Bentley and Robert Sedgewick in the April, 1998, Dr. Dobb's Journal. -*/ - - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5STprivate.h" /* Ternary search trees */ - -#ifdef H5ST_DEBUG -static herr_t H5ST__dump_internal(H5ST_ptr_t p); -#endif /* H5ST_DEBUG */ - -/* Declare a free list to manage the H5ST_node_t struct */ -H5FL_DEFINE_STATIC(H5ST_node_t); - -/* Declare a free list to manage the H5ST_tree_t struct */ -H5FL_DEFINE_STATIC(H5ST_tree_t); - - -/*-------------------------------------------------------------------------- - NAME - H5ST_create - PURPOSE - Create a TST - USAGE - H5ST_ptr_t H5ST_create() - - RETURNS - Returns a pointer to the new TST tree on success, NULL on failure. - DESCRIPTION - Create a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_tree_t * -H5ST_create(void) -{ - H5ST_tree_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Allocate wrapper for TST */ - if(NULL == (ret_value = H5FL_MALLOC(H5ST_tree_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Set the internal fields */ - ret_value->root = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_create() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST__close_internal - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(p) - H5ST_ptr_t p; IN/OUT: Root of TST to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__close_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - /* Recursively free TST */ - if(p) { - H5ST__close_internal(p->lokid); - if(p->splitchar) - H5ST__close_internal(p->eqkid); - H5ST__close_internal(p->hikid); - p = H5FL_FREE(H5ST_node_t, p); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__close_internal() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_close - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(tree) - H5ST_tree_t *tree; IN/OUT: TST tree to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_close(H5ST_tree_t *tree) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if(NULL == tree) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid TST") - - /* Free the TST itself */ - if(H5ST__close_internal(tree->root) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTFREE, FAIL, "can't free TST") - - /* Free root node itself */ - tree = H5FL_FREE(H5ST_tree_t, tree); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_close() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_insert - PURPOSE - Insert a string/object pair into a TST - USAGE - herr_t H5ST_insert(tree,s,obj) - H5ST_tree_t *tree; IN/OUT: TST to insert string into - const char *s; IN: String to use as key for object - void *obj; IN: Pointer to object to insert - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Insert a key (string)/object pair into a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_insert(H5ST_tree_t *tree, const char *s, void *obj) -{ - int d; /* Comparison value */ - H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ - H5ST_ptr_t parent=NULL; /* Pointer to parent node */ - H5ST_ptr_t up=NULL; /* Pointer to up node */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Find the correct location to insert object */ - p = &tree->root; - while((pp = *p)) { - /* If this node matches the character in the key, then drop down to the lower tree */ - if(0 == (d = *s - pp->splitchar)) { - if(*s++ == 0) - HGOTO_ERROR(H5E_TST, H5E_EXISTS, FAIL, "key already in tree") - up=pp; - p = &(pp->eqkid); - } /* end if */ - else { - /* Walk through the current tree, searching for the matching character */ - parent = pp; - if(d < 0) - p = &(pp->lokid); - else - p = &(pp->hikid); - } /* end else */ - } /* end while */ - - /* Finish walking through the key string, adding nodes until the end */ - for (;;) { - if(NULL == (*p = H5FL_MALLOC(H5ST_node_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - pp = *p; - pp->splitchar = *s; - pp->up = up; - pp->parent = parent; - pp->lokid = pp->eqkid = pp->hikid = NULL; - - /* If this is the end of the key string, break out */ - if(*s++ == 0) { - pp->eqkid = (H5ST_ptr_t)obj; - break; - } /* end if */ - - /* Continue to next character */ - parent = NULL; - up = pp; - p = &(pp->eqkid); - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_insert() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_search - PURPOSE - Determine if a key is in the TST - USAGE - hbool_t H5ST_search(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: TRUE if key string in TST, FALSE if not - Failure: negative - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5ST_search(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t p; /* Temporary pointer to TST node */ - htri_t ret_value=FALSE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - p = tree->root; - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(TRUE); - p = p->eqkid; - } else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_search() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST__find_internal - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(p,s) - H5ST_ptr_t p; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__find_internal(H5ST_ptr_t p, const char *s) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(p); - p = p->eqkid; - } else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__find_internal() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_find - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_find(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if(NULL == (ret_value = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_find() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_locate - PURPOSE - Find an object in a TST - USAGE - void *H5ST_locate(tree,s) - H5ST_tree_t *tree; IN: TST to locate object within - const char *s; IN: String of key for object to locate - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Locate a node in a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_locate(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node located */ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if(NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_locate() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST__findfirst_internal - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST__findfirst_internal(p) - H5ST_ptr_t p; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__findfirst_internal(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while(p) { - /* Find least node in current tree */ - while(p->lokid) - p = p->lokid; - - /* Is least node '\0'? */ - if(p->splitchar == '\0') { - /* Return it */ - HGOTO_DONE(p); - } /* end if */ - else { - /* Go down to next level of tree */ - p = p->eqkid; - } /* end else */ - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__findfirst_internal() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_findfirst - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST_findfirst(tree) - H5ST_tree_t *tree; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findfirst(H5ST_tree_t *tree) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if(NULL == (ret_value = H5ST__findfirst_internal(tree->root))) - HGOTO_ERROR(H5E_TST,H5E_NOTFOUND,NULL,"no nodes in TST"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findfirst() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST__getnext - PURPOSE - Internal routine to find the next node in a given level of a TST - USAGE - H5ST_ptr_t H5ST__getnext(p) - H5ST_ptr_t *p; IN: Pointer to node to find next node from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in the current level of a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__getnext(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* If the node to continue from has higher-valued nodes attached */ - if(p->hikid) { - /* Go to first higher-valued node */ - p = p->hikid; - - /* Find least node from here */ - while(p->lokid) - p = p->lokid; - HGOTO_DONE(p); - } /* end if */ - else { - H5ST_ptr_t q; /* Temporary TST node pointer */ - - /* Go up one level in current tree */ - q = p->parent; - if(q == NULL) - HGOTO_DONE(NULL); - - /* While the previous node was the higher-valued node, keep backing up the tree */ - while(q->hikid == p) { - p = q; - q = p->parent; - if(NULL == q) - HGOTO_DONE(NULL); - } /* end while */ - HGOTO_DONE(q); - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__getnext() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_findnext - PURPOSE - Find the next node from a node in a TST - USAGE - H5ST_ptr_t H5ST_findnext(p) - H5ST_ptr_t p; IN: Current node to continue from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findnext(H5ST_ptr_t p) -{ - H5ST_ptr_t q; /* Temporary pointer to TST node */ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Find the next node at the current level, or go back up the tree */ - do { - q = H5ST__getnext(p); - if(q) { - HGOTO_DONE(H5ST__findfirst_internal(q->eqkid)); - } /* end if */ - else - p = p->up; - } while(p); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findnext() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST__delete_internal - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST__delete_internal(root,p) - H5ST_ptr_t *root; IN/OUT: Root of TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) -{ - H5ST_ptr_t q, /* Temporary pointer to TST node */ - newp; /* Pointer to node which will replace deleted node in tree */ - - FUNC_ENTER_STATIC_NOERR - - /* Find node to replace one being deleted */ - if(p->lokid) { - /* If the deleted node has lo & hi kids, attach them together */ - if(p->hikid) { - q = p->lokid; - while(q->hikid) - q = q->hikid; - q->hikid = p->hikid; - p->hikid->parent = q; - } /* end if */ - newp = p->lokid; - } /* end if */ - else if(p->hikid) { - newp = p->hikid; - } /* end if */ - else { - newp = NULL; - } /* end else */ - - /* Deleted node is in middle of tree */ - if(p->parent) { - /* Attach new node to correct side of parent */ - if(p == p->parent->lokid) - p->parent->lokid = newp; - else - p->parent->hikid = newp; - if(newp) - newp->parent = p->parent; - } /* end if */ - else { - if(newp) - newp->parent = p->parent; - if(p->up) { - p->up->eqkid = newp; - - /* If we deleted the last node in the TST, delete the upper node also */ - if(NULL == newp) - H5ST__delete_internal(root, p->up); - } /* end if */ - else /* Deleted last node at top level of tree */ - *root = newp; - } /* end else */ - - p = H5FL_FREE(H5ST_node_t, p); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__delete_internal() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_delete - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST_delete(tree,p) - H5ST_tree_t *tree; IN/OUT: TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_delete(H5ST_tree_t *tree, H5ST_ptr_t p) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if(H5ST__delete_internal(&tree->root, p) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, FAIL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_delete() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_remove - PURPOSE - Remove a node from a TST - USAGE - void *H5ST_remove(tree,s) - H5ST_tree_t *tree; IN/OUT: TST to remove node from - const char *s; IN: String of key for node to remove - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Remove a node from a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_remove(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node to remove */ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if(NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - - /* Remove the node from the TST */ - if(H5ST__delete_internal(&tree->root, node) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, NULL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_remove() */ - -#ifdef H5ST_DEBUG - -/*-------------------------------------------------------------------------- - NAME - H5ST__dump_internal - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(p) - H5ST_ptr_t p; IN: Root of TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__dump_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - if(p) { - HDprintf("p=%p\n", (void *)p); - HDprintf("\tp->up=%p\n", (void *)p->up); - HDprintf("\tp->parent=%p\n", (void *)p->parent); - HDprintf("\tp->lokid=%p\n", (void *)p->lokid); - HDprintf("\tp->hikid=%p\n", (void *)p->hikid); - HDprintf("\tp->eqkid=%p\n", (void *)p->eqkid); - HDprintf("\tp->splitchar=%c\n", p->splitchar); - - H5ST__dump_internal(p->lokid); - if(p->splitchar) - H5ST__dump_internal(p->eqkid); - else - HDprintf("%s\n", (char *)p->eqkid); - H5ST__dump_internal(p->hikid); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__dump_internal() */ - - -/*-------------------------------------------------------------------------- - NAME - H5ST_dump - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(tree) - H5ST_tree_t *tree; IN: TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_dump(H5ST_tree_t *tree) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Dump the tree */ - H5ST__dump_internal(tree->root); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST_dump() */ -#endif /* H5ST_DEBUG */ - diff --git a/src/H5STprivate.h b/src/H5STprivate.h deleted file mode 100644 index 07e9afea700..00000000000 --- a/src/H5STprivate.h +++ /dev/null @@ -1,64 +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://support.hdfgroup.org/ftp/HDF5/releases. * - * 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 H5ST module - */ -#ifndef _H5STprivate_H -#define _H5STprivate_H - -#ifdef LATER -#include "H5STpublic.h" -#endif /* LATER */ - -/* Private headers needed by this file */ -#include "H5private.h" - -/* Typedefs */ - -/* Internal nodes for TST */ -typedef struct H5ST_node *H5ST_ptr_t; -typedef struct H5ST_node { - char splitchar; /* Character represented at node */ - H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ - H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ - H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ - H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ - H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ -} H5ST_node_t; - -/* Wrapper about TST */ -typedef struct { - H5ST_ptr_t root; /* Pointer to actual TST */ -} H5ST_tree_t; - -/* Macro to access "data" pointer in H5ST_node_t's returned from functions */ -#define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) - -/* Private routines */ -H5_DLL H5ST_tree_t *H5ST_create(void); -H5_DLL herr_t H5ST_close(H5ST_tree_t *p); -H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); -H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); -H5_DLL void *H5ST_locate(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); -H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); -H5_DLL void *H5ST_remove(H5ST_tree_t *root, const char *s); -H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); -#ifdef H5ST_DEBUG -H5_DLL herr_t H5ST_dump(H5ST_tree_t *tree); -#endif /* H5ST_DEBUG */ - -#endif /* _H5STprivate_H */ - diff --git a/src/H5Sall.c b/src/H5Sall.c index f342279c1db..35ddf3d599a 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,72 +22,65 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Selection callbacks */ -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 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 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 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_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off); +static int H5S__all_unlim_dim(const H5S_t *space); +static htri_t H5S__all_is_contiguous(const H5S_t *space); +static htri_t H5S__all_is_single(const H5S_t *space); +static htri_t H5S__all_is_regular(const H5S_t *space); +static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__all_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static 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); /* Selection iteration callbacks */ -static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__all_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter); - +static htri_t H5S__all_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__all_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__all_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +static herr_t H5S__all_iter_release(H5S_sel_iter_t *sel_iter); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -119,7 +112,6 @@ const H5S_select_class_t H5S_sel_all[1] = {{ H5S__all_iter_init, }}; - /*******************/ /* Local Variables */ /*******************/ @@ -139,8 +131,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ H5S__all_iter_release, }}; - - /*------------------------------------------------------------------------- * Function: H5S__all_iter_init * @@ -172,7 +162,6 @@ H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_coords * @@ -189,7 +178,7 @@ H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -198,14 +187,13 @@ H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) HDassert(coords); /* Calculate the coordinates for the current iterator offset */ - if(H5VM_array_calc(iter->u.all.elmt_offset, iter->rank, iter->dims, coords) < 0) + if (H5VM_array_calc(iter->u.all.elmt_offset, iter->rank, iter->dims, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve coordinates") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_block * @@ -222,7 +210,7 @@ H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) static herr_t H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -231,7 +219,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) HDassert(start); HDassert(end); - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { /* Set the start of the 'all' block */ /* (Always '0' coordinates for now) */ start[u] = 0; @@ -244,7 +232,6 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__all_iter_nelmts * @@ -268,7 +255,6 @@ H5S__all_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__all_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_has_next_block @@ -297,7 +283,6 @@ H5S__all_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__all_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_next @@ -332,7 +317,6 @@ H5S__all_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_next_block @@ -361,7 +345,6 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__all_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_get_seq_list @@ -392,10 +375,10 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, - size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, size_t maxelem, size_t *nseq, + size_t *nelem, hsize_t *off, size_t *len) { - size_t elem_used; /* The number of elements used */ + size_t elem_used; /* The number of elements used */ FUNC_ENTER_STATIC_NOERR @@ -431,7 +414,6 @@ H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__all_iter_release @@ -450,7 +432,7 @@ H5S__all_iter_get_seq_list(H5S_sel_iter_t *iter, size_t H5_ATTR_UNUSED maxseq, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) +H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) { FUNC_ENTER_STATIC_NOERR @@ -460,7 +442,6 @@ H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__all_release @@ -492,7 +473,6 @@ H5S__all_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_release() */ - /*-------------------------------------------------------------------------- NAME H5S__all_copy @@ -527,7 +507,6 @@ H5S__all_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_valid @@ -558,7 +537,6 @@ H5S__all_is_valid(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__all_serial_size @@ -592,7 +570,6 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(16) } /* end H5S__all_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__all_serialize @@ -617,7 +594,7 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -629,8 +606,8 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ /* Update encoding pointer */ *p = pp; @@ -638,7 +615,6 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__all_deserialize @@ -665,9 +641,9 @@ static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p) { uint32_t version; /* Version number */ - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + 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 */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -680,8 +656,8 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -690,30 +666,29 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); - if(version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) + 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 */ *p += 8; /* Change to "all" selection */ - if(H5S_select_all(tmp_space, TRUE) < 0) + if (H5S_select_all(tmp_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__all_bounds @@ -742,8 +717,8 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - unsigned rank; /* Dataspace rank */ - unsigned i; /* index variable */ + unsigned rank; /* Dataspace rank */ + unsigned i; /* index variable */ FUNC_ENTER_STATIC_NOERR @@ -755,15 +730,14 @@ H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) rank = space->extent.rank; /* Just copy over the complete extent */ - for(i = 0; i < rank; i++) { + for (i = 0; i < rank; i++) { start[i] = 0; - end[i] = space->extent.size[i] - 1; + end[i] = space->extent.size[i] - 1; } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__all_offset @@ -798,7 +772,6 @@ H5S__all_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__all_unlim_dim @@ -828,7 +801,6 @@ H5S__all_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__all_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_contiguous @@ -857,7 +829,6 @@ H5S__all_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_single @@ -886,7 +857,6 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__all_is_regular @@ -917,7 +887,6 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__all_shape_same @@ -940,9 +909,9 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) { - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -959,8 +928,8 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) * In the following while loop, we test to see if space1 and space2 * have identical size in all dimensions they have in common. */ - while(space2_dim >= 0) { - if(space1->extent.size[space1_dim] != space2->extent.size[space2_dim]) + while (space2_dim >= 0) { + if (space1->extent.size[space1_dim] != space2->extent.size[space2_dim]) HGOTO_DONE(FALSE) space1_dim--; @@ -970,8 +939,8 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) /* Since we are selecting the entire space, we must also verify that space1 * has size 1 in all dimensions that it does not share with space2. */ - while(space1_dim >= 0) { - if(space1->extent.size[space1_dim] != 1) + while (space1_dim >= 0) { + if (space1->extent.size[space1_dim] != 1) HGOTO_DONE(FALSE) space1_dim--; @@ -981,7 +950,6 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__all_intersect_block @@ -1002,8 +970,8 @@ 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, const hsize_t H5_ATTR_UNUSED *end) +H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, + const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -1016,7 +984,6 @@ H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__all_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__all_adjust_u @@ -1047,7 +1014,6 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__all_adjust_s @@ -1078,7 +1044,6 @@ H5S__all_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *of FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_adjust_s() */ - /*------------------------------------------------------------------------- * Function: H5S__all_project_scalar * @@ -1107,7 +1072,6 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__all_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__all_project_simple * @@ -1122,10 +1086,10 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) *------------------------------------------------------------------------- */ static herr_t -H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, - H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset) +H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, H5S_t *new_space, + hsize_t H5_ATTR_UNUSED *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1135,14 +1099,13 @@ H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, HDassert(offset); /* Select the entire new space */ - if(H5S_select_all(new_space, TRUE) < 0) + if (H5S_select_all(new_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to set all selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_all @@ -1164,7 +1127,7 @@ H5S__all_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1172,8 +1135,8 @@ H5S_select_all(H5S_t *space, hbool_t rel_prev) HDassert(space); /* Remove current selection first */ - if(rel_prev) - if(H5S_SELECT_RELEASE(space) < 0) + if (rel_prev) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Set number of elements in selection */ @@ -1186,7 +1149,6 @@ H5S_select_all(H5S_t *space, hbool_t rel_prev) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_all() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_all @@ -1214,14 +1176,13 @@ H5Sselect_all(hid_t spaceid) H5TRACE1("e", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Call internal routine to do the work */ - if(H5S_select_all(space, TRUE) < 0) + if (H5S_select_all(space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_all() */ - diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c index 32f5295bc33..d20916b026b 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,7 +16,6 @@ * Created: H5Sdbg.c * Quincey Koziol * Jul 24 2007 - * * * Purpose: Dump debugging information about a dataspace * @@ -27,53 +26,43 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Spkg.h" /* Dataspaces */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5S_debug * @@ -89,34 +78,30 @@ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5S_t *mesg = (const H5S_t*)_mesg; + const H5S_t *mesg = (const H5S_t *)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR - switch(H5S_GET_EXTENT_TYPE(mesg)) { + switch (H5S_GET_EXTENT_TYPE(mesg)) { case H5S_NULL: - HDfprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, "Space class:"); break; case H5S_SCALAR: - HDfprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, "Space class:"); break; case H5S_SIMPLE: - HDfprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, - "Space class:"); + HDfprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, "Space class:"); H5O_debug_id(H5O_SDSPACE_ID, f, &(mesg->extent), stream, indent + 3, MAX(0, fwidth - 3)); break; case H5S_NO_CLASS: default: HDfprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, - "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); + "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); break; } /* end switch */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S_debug() */ - diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c new file mode 100644 index 00000000000..d050102e41b --- /dev/null +++ b/src/H5Sdeprec.c @@ -0,0 +1,110 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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: H5Sdeprec.c + * + * Purpose: Deprecated functions from the H5S interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Smodule.h" /* This source code file is part of the H5S module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/*------------------------------------------------------------------------- + * Function: H5Sencode1 + * + * Purpose: Given a dataspace ID, converts the object description + * (including selection) into binary in a buffer. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Raymond Lu + * July 14, 2004 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc) +{ + H5S_t *dspace; + hid_t temp_fapl_id = H5P_DEFAULT; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); + + /* Check argument and retrieve object */ + if (NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Verify access property list and set up collective metadata if appropriate */ + if (H5CX_set_apl(&temp_fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + + /* Use (earliest, latest) i.e. not latest format */ + if (H5S_encode(dspace, (unsigned char **)&buf, nalloc) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode dataspace") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Sencode1() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 42b9acd74fb..029adad4b21 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,21 +22,19 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ @@ -48,32 +46,31 @@ #define H5S_HYPER_COMPUTE_A_NOT_B 0x04 /* Macro to advance a span, possibly recycling it first */ -#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \ - do { \ - H5S_hyper_span_t *saved_next_span = (next_span); \ - \ - /* Check if the span should be recovered */ \ - if(recover) { \ - H5S__hyper_free_span(curr_span); \ - (recover) = FALSE; \ - } /* end if */ \ - \ - /* Set the current span to saved next span */ \ - (curr_span) = saved_next_span; \ - } while(0) +#define H5S_HYPER_ADVANCE_SPAN(recover, curr_span, next_span) \ + do { \ + H5S_hyper_span_t *saved_next_span = (next_span); \ + \ + /* Check if the span should be recovered */ \ + if (recover) { \ + H5S__hyper_free_span(curr_span); \ + (recover) = FALSE; \ + } /* end if */ \ + \ + /* Set the current span to saved next span */ \ + (curr_span) = saved_next_span; \ + } while (0) /* Macro to add "skipped" elements to projection during the execution of * H5S__hyper_project_intersect() */ -#define H5S_HYPER_PROJ_INT_ADD_SKIP(UDATA, ADD, ERR) \ - do { \ - /* If there are any elements to add, we must add them \ - * to the projection first before adding skip */ \ - if((UDATA)->nelem > 0) \ - if(H5S__hyper_proj_int_build_proj(UDATA) < 0) \ +#define H5S_HYPER_PROJ_INT_ADD_SKIP(UDATA, ADD, ERR) \ + do { \ + /* If there are any elements to add, we must add them \ + * to the projection first before adding skip */ \ + if ((UDATA)->nelem > 0) \ + if (H5S__hyper_proj_int_build_proj(UDATA) < 0) \ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, ERR, "can't add elements to projected selection") \ - (UDATA)->skip += (ADD); \ - } while(0) /* end H5S_HYPER_PROJ_INT_ADD_SKIP() */ - + (UDATA)->skip += (ADD); \ + } while (0) /* end H5S_HYPER_PROJ_INT_ADD_SKIP() */ /******************/ /* Local Typedefs */ @@ -86,17 +83,20 @@ typedef hsize_t hbounds_t; /* Struct for holding persistent information during iteration for * 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 */ + const H5S_hyper_span_t + * 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 */ - 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 */ - unsigned ds_rank; /* Rank of destination space */ - unsigned depth; /* Current depth of iterator in destination space */ - hsize_t skip; /* Number of elements to skip in projected space */ - hsize_t nelem; /* Number of elements to add to projected space (after skip) */ - uint64_t op_gen; /* Operation generation for counting elements */ - hbool_t share_selection; /* Whether span trees in dst_space can be shared with proj_space */ + H5S_hyper_span_info_t + * 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 */ + unsigned ds_rank; /* Rank of destination space */ + unsigned depth; /* Current depth of iterator in destination space */ + hsize_t skip; /* Number of elements to skip in projected space */ + hsize_t nelem; /* Number of elements to add to projected space (after skip) */ + uint64_t op_gen; /* Operation generation for counting elements */ + hbool_t share_selection; /* Whether span trees in dst_space can be shared with proj_space */ } H5S_hyper_project_intersect_ud_t; /* Assert that H5S_MAX_RANK is <= 32 so our trick with using a 32 bit bitmap @@ -106,116 +106,106 @@ typedef struct { #error H5S_MAX_RANK too large for ps_clean_bitmap field in H5S_hyper_project_intersect_ud_t struct #endif - /********************/ /* Local Prototypes */ /********************/ -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_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, unsigned op_info_i, - uint64_t op_gen); -static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, - unsigned rank); -static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2); -static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); -static void H5S__hyper_free_span(H5S_hyper_span_t *span); -static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, - hsize_t start[], hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, - hsize_t **buf); -static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, - hsize_t numblocks, hsize_t *buf); +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); +static H5S_hyper_span_info_t *H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank); +static hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, + const H5S_hyper_span_info_t *span_info2); +static void H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info); +static void H5S__hyper_free_span(H5S_hyper_span_t *span); +static herr_t H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], + hsize_t rank, hsize_t *startblock, hsize_t *numblocks, hsize_t **buf); +static herr_t H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, + hsize_t *buf); static H5S_hyper_span_t *H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords); -static herr_t H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, - unsigned ndims, hsize_t low, hsize_t high, H5S_hyper_span_info_t *down); -static herr_t H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, - H5S_hyper_span_info_t *b_spans, unsigned selector, - unsigned ndims, H5S_hyper_span_info_t **a_not_b, - H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a); -static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); -static hsize_t H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, - unsigned op_info_i, uint64_t op_gen); +static herr_t H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, hsize_t low, + hsize_t high, H5S_hyper_span_info_t *down); +static herr_t H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, + unsigned selector, unsigned ndims, H5S_hyper_span_info_t **a_not_b, + H5S_hyper_span_info_t **a_and_b, H5S_hyper_span_info_t **b_not_a); +static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); +static hsize_t H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, + uint64_t op_gen); static hsize_t H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans); -static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); -static H5S_hyper_span_info_t *H5S__hyper_make_spans(unsigned rank, - const hsize_t *start, const hsize_t *stride, - const hsize_t *count, const hsize_t *block); -static herr_t H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, - const H5S_hyper_dim_t *new_hyper_diminfo); -static herr_t H5S__hyper_generate_spans(H5S_t *space); -static hbool_t H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, - const H5S_hyper_span_info_t *spans2); -static herr_t H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, - H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2, - hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result); -static herr_t H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, - const hsize_t start[], const hsize_t stride[], const hsize_t count[], - const hsize_t block[]); -static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], - const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block, - 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 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, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); -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, - 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, hsize_t clip_size); -static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, - hsize_t num_slices, hbool_t incl_trail); +static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans); +static H5S_hyper_span_info_t *H5S__hyper_make_spans(unsigned rank, const hsize_t *start, + const hsize_t *stride, const hsize_t *count, + const hsize_t *block); +static herr_t H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, + const H5S_hyper_dim_t *new_hyper_diminfo); +static herr_t H5S__hyper_generate_spans(H5S_t *space); +static hbool_t H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, + const H5S_hyper_span_info_t *spans2); +static herr_t H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *space2_span_lst, + hbool_t can_own_span2, hbool_t *span2_owned, hbool_t *updated_spans, + H5S_t **result); +static herr_t H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]); +static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], const hsize_t *app_stride, + const hsize_t app_count[], const hsize_t *app_block, + 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 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, + size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); +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, + 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, + hsize_t clip_size); +static hsize_t H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, + hbool_t incl_trail); /* Selection callbacks */ -static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -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 herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +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 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 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_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset); +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 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); /* Selection iteration callbacks */ -static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter); -static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +static htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *sel_iter); +static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S__hyper_iter_release(H5S_sel_iter_t *sel_iter); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -249,9 +239,10 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{ /* Format version bounds for dataspace hyperslab selection */ const unsigned H5O_sds_hyper_ver_bounds[] = { - H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */ - H5S_HYPER_VERSION_2 /* H5F_LIBVER_LATEST */ + H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_HYPER_VERSION_2, /* H5F_LIBVER_V110 */ + H5S_HYPER_VERSION_3 /* H5F_LIBVER_LATEST */ }; /*******************/ @@ -274,16 +265,10 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ }}; /* Arrays for default stride, block, etc. */ -static const hsize_t H5S_hyper_zeros_g[H5S_MAX_RANK] = { - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0, - 0,0,0,0, 0,0,0,0}; -static const hsize_t H5S_hyper_ones_g[H5S_MAX_RANK] = { - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1}; +static const hsize_t H5S_hyper_zeros_g[H5S_MAX_RANK] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const hsize_t H5S_hyper_ones_g[H5S_MAX_RANK] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; /* Declare a free list to manage the H5S_hyper_sel_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_sel_t); @@ -301,7 +286,6 @@ H5FL_EXTERN(H5S_sel_iter_t); /* (Start with '1' to avoid clashing with '0' value in newly allocated structs) */ static uint64_t H5S_hyper_op_gen_g = 1; - /* Uncomment this to provide the debugging routines for printing selection info */ /* #define H5S_HYPER_DEBUG */ #ifdef H5S_HYPER_DEBUG @@ -310,10 +294,13 @@ 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); - 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); + 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); + 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); H5S__hyper_print_spans_helper(f, span->down->head, depth + 1); } /* end if */ span = span->next; @@ -327,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); + 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); H5S__hyper_print_spans_helper(f, span_lst->head, 0); } /* end if */ @@ -348,22 +336,22 @@ H5S__space_print_spans(FILE *f, const H5S_t *space) static herr_t H5S__hyper_print_diminfo_helper(FILE *f, const char *field, unsigned ndims, const H5S_hyper_dim_t *dinfo) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR - if(dinfo != NULL) { + if (dinfo != NULL) { HDfprintf(f, "%s: %s: start=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hd%s", dinfo[u].start, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: stride=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].stride, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: count=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].count, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: block=[", FUNC, field); - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) HDfprintf(f, "%Hu%s", dinfo[u].block, (u < (ndims - 1) ? ", " : "]\n")); } /* end if */ else @@ -377,13 +365,14 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) { FUNC_ENTER_STATIC_NOERR - H5S__hyper_print_diminfo_helper(f, "diminfo.opt", space->extent.rank, space->select.sel_info.hslab->diminfo.opt); - H5S__hyper_print_diminfo_helper(f, "diminfo.app", space->extent.rank, space->select.sel_info.hslab->diminfo.app); + H5S__hyper_print_diminfo_helper(f, "diminfo.opt", space->extent.rank, + space->select.sel_info.hslab->diminfo.opt); + H5S__hyper_print_diminfo_helper(f, "diminfo.app", space->extent.rank, + space->select.sel_info.hslab->diminfo.app); FUNC_LEAVE_NOAPI(SUCCEED) } - /*-------------------------------------------------------------------------- NAME H5S__hyper_print_spans_dfs @@ -402,53 +391,52 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, - unsigned depth, unsigned dims) +H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, unsigned depth, unsigned dims) { H5S_hyper_span_t *actual_tail = NULL; H5S_hyper_span_t *cur_elem; - unsigned num_elems = 0; - unsigned u, elem_idx; + unsigned num_elems = 0; + unsigned u, elem_idx; FUNC_ENTER_STATIC_NOERR /* get the actual tail from head */ cur_elem = span_lst->head; HDassert(cur_elem); /* at least 1 element */ - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; - cur_elem = cur_elem->next; + cur_elem = cur_elem->next; num_elems++; } /* end while */ - for(u = 0; u < depth; u++) + 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, (span_lst->tail == actual_tail)); + span_lst->count, num_elems, span_lst->head, span_lst->tail, actual_tail, + (span_lst->tail == actual_tail)); - for(u = 0; u < depth; u++) + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "low_bounds=["); - for(u = 0; u < dims - 1; u++) + 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]); - for(u = 0; u < depth; u++) + for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "high_bounds=["); - for(u = 0; u < dims - 1; u++) + 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]); cur_elem = span_lst->head; elem_idx = 0; - while(cur_elem) { - for(u = 0; u < depth; u++) + 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); - if(cur_elem->down) + 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); + if (cur_elem->down) H5S__hyper_print_spans_dfs(f, cur_elem->down, depth + 1, dims); cur_elem = cur_elem->next; } /* end while */ @@ -456,7 +444,6 @@ H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_print_spans_dfs() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_print_space_dfs @@ -477,51 +464,52 @@ static herr_t H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) { const H5S_hyper_sel_t *hslab = space->select.sel_info.hslab; - const unsigned dims = space->extent.rank; - unsigned u; + const unsigned dims = space->extent.rank; + unsigned u; FUNC_ENTER_STATIC_NOERR HDassert(hslab); HDfprintf(f, "=======================\n"); - HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, space->select.offset_changed); + HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, + space->select.offset_changed); HDfprintf(f, " offset=["); - for(u = 0; u < dims - 1; u++) + for (u = 0; u < dims - 1; u++) HDfprintf(f, "%lld,", space->select.offset[u]); HDfprintf(f, "%lld]\n", space->select.offset[dims - 1]); HDfprintf(f, " low_bounds=["); - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < dims - 1; u++) + 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]); } /* end if */ else { - for(u = 0; u < dims - 1; u++) + 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]); } /* 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++) + 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]); } /* end if */ else { - for(u = 0; u < dims - 1; u++) + 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]); } /* end else */ /* Print out diminfo, if it's valid */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) H5S__hyper_print_diminfo(f, space); /* Start print out the highest-order of dimension */ - if(hslab->span_lst) + if (hslab->span_lst) H5S__hyper_print_spans_dfs(f, hslab->span_lst, 0, dims); HDfprintf(f, "=======================\n\n"); @@ -529,7 +517,6 @@ H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) } /* end H5S__hyper_print_space_dfs() */ #endif /* H5S_HYPER_DEBUG */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_get_op_gen * @@ -553,7 +540,6 @@ H5S__hyper_get_op_gen(void) FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++); } /* end H5S__hyper_op_gen() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_init * @@ -574,13 +560,13 @@ H5S__hyper_get_op_gen(void) static herr_t H5S__hyper_iter_init(const 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 */ - unsigned slab_dim; /* Rank of the fastest changing dimension for calc. slab */ - unsigned rank; /* Dataspace's dimension rank */ - unsigned u; /* Index variable */ - int i; /* Index variable */ - herr_t ret_value = SUCCEED; /* return value */ + hsize_t *slab_size; /* Pointer to the dataspace dimensions to use for calc. slab */ + hsize_t acc; /* Accumulator for computing cumulative sizes */ + unsigned slab_dim; /* Rank of the fastest changing dimension for calc. slab */ + unsigned rank; /* Dataspace's dimension rank */ + unsigned u; /* Index variable */ + int i; /* Index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -598,15 +584,15 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * 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 */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ /* 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 */ - unsigned cont_dim = 0; /* # of contiguous dimensions */ + 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 */ + unsigned cont_dim = 0; /* # of contiguous dimensions */ /* Set the temporary pointer to the dimension information */ tdiminfo = space->select.sel_info.hslab->diminfo.opt; @@ -624,10 +610,10 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Don't flatten adjacent elements into contiguous block if the * element size is 0. This is for the H5S_select_shape_same() code. */ - if(iter->elmt_size > 0) { + if (iter->elmt_size > 0) { /* Check for any "contiguous" blocks that can be flattened */ - for(u = (rank - 1); u > 0; u--) { - if(tdiminfo[u].count == 1 && tdiminfo[u].block == mem_size[u]) { + for (u = (rank - 1); u > 0; u--) { + if (tdiminfo[u].count == 1 && tdiminfo[u].block == mem_size[u]) { cont_dim++; iter->u.hyp.flattened[u] = TRUE; } /* end if */ @@ -638,18 +624,18 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end if */ /* Check if the regular selection can be "flattened" */ - if(cont_dim > 0) { - hbool_t last_dim_flattened = TRUE; /* Flag to indicate that the last dimension was flattened */ - unsigned flat_rank = rank-cont_dim; /* Number of dimensions after flattening */ - unsigned curr_dim; /* Current dimension */ + if (cont_dim > 0) { + hbool_t last_dim_flattened = TRUE; /* Flag to indicate that the last dimension was flattened */ + unsigned flat_rank = rank - cont_dim; /* Number of dimensions after flattening */ + unsigned curr_dim; /* Current dimension */ /* Set the iterator's rank to the contiguous dimensions */ iter->u.hyp.iter_rank = flat_rank; /* "Flatten" dataspace extent and selection information */ curr_dim = flat_rank - 1; - for(i = (int)rank - 1, acc = 1; i >= 0; i--) { - if(tdiminfo[i].block == mem_size[i] && i > 0) { + for (i = (int)rank - 1, acc = 1; i >= 0; i--) { + if (tdiminfo[i].block == mem_size[i] && i > 0) { /* "Flatten" this dimension */ HDassert(tdiminfo[i].start == 0); acc *= mem_size[i]; @@ -658,19 +644,19 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) last_dim_flattened = TRUE; } /* end if */ else { - if(last_dim_flattened) { + if (last_dim_flattened) { /* First dimension after flattened dimensions */ iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start * acc; /* Special case for single block regular selections */ - if(tdiminfo[i].count == 1) + if (tdiminfo[i].count == 1) iter->u.hyp.diminfo[curr_dim].stride = 1; else iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride * acc; iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block * acc; - iter->u.hyp.size[curr_dim] = mem_size[i] * acc; - iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i] * (hssize_t)acc; + iter->u.hyp.size[curr_dim] = mem_size[i] * acc; + iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i] * (hssize_t)acc; /* Reset the "last dim flattened" flag to avoid flattened any further dimensions */ last_dim_flattened = FALSE; @@ -680,38 +666,40 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end if */ else { /* All other dimensions */ - iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start; + iter->u.hyp.diminfo[curr_dim].start = tdiminfo[i].start; iter->u.hyp.diminfo[curr_dim].stride = tdiminfo[i].stride; - iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; - iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block; - iter->u.hyp.size[curr_dim] = mem_size[i]; - iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i]; + iter->u.hyp.diminfo[curr_dim].count = tdiminfo[i].count; + iter->u.hyp.diminfo[curr_dim].block = tdiminfo[i].block; + iter->u.hyp.size[curr_dim] = mem_size[i]; + iter->u.hyp.sel_off[curr_dim] = iter->sel_off[i]; } /* end else */ /* Decrement "current" flattened dimension */ curr_dim--; } /* end if */ - } /* end for */ + } /* end for */ - /* Initialize "flattened" iterator offset to initial location and dataspace extent and selection information to correct values */ - for(u = 0; u < flat_rank; u++) + /* Initialize "flattened" iterator offset to initial location and dataspace extent and selection + * information to correct values */ + for (u = 0; u < flat_rank; u++) iter->u.hyp.off[u] = iter->u.hyp.diminfo[u].start; /* Set up information for computing slab sizes */ - slab_dim = iter->u.hyp.iter_rank - 1; + slab_dim = iter->u.hyp.iter_rank - 1; slab_size = iter->u.hyp.size; } /* end if */ else { /* Make local copy of the regular selection information */ - HDcompile_assert(sizeof(iter->u.hyp.diminfo) == sizeof(space->select.sel_info.hslab->diminfo.opt)); + HDcompile_assert(sizeof(iter->u.hyp.diminfo) == + sizeof(space->select.sel_info.hslab->diminfo.opt)); H5MM_memcpy(iter->u.hyp.diminfo, tdiminfo, sizeof(iter->u.hyp.diminfo)); /* Initialize position to initial location */ - for(u = 0; u < rank; u++) + for (u = 0; u < rank; u++) iter->u.hyp.off[u] = tdiminfo[u].start; /* Set up information for computing slab sizes */ - slab_dim = iter->rank - 1; + slab_dim = iter->rank - 1; slab_size = iter->dims; } /* end else */ @@ -720,9 +708,9 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Initialize irregular region information also (for release) */ iter->u.hyp.spans = NULL; - } /* end if */ - else { /* Initialize the information needed for non-regular hyperslab I/O */ - H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ + } /* end if */ + else { /* Initialize the information needed for non-regular hyperslab I/O */ + H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ /* If this iterator is created from an API call, by default we clone the * selection now, as the dataspace could be modified or go out of scope. @@ -733,10 +721,10 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) * close the dataspace that the iterator is operating on, or undefined * behavior will occur. */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { /* Copy the span tree */ - if(NULL == (iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst, space->extent.rank))) + if (NULL == (iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst, + space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy span tree") } /* end if */ else { @@ -748,7 +736,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) /* Initialize the starting span_info's and spans */ spans = iter->u.hyp.spans; - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Set the pointers to the initial span in each dimension */ HDassert(spans); HDassert(spans->head); @@ -764,7 +752,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end for */ /* Set up information for computing slab sizes */ - slab_dim = iter->rank - 1; + slab_dim = iter->rank - 1; slab_size = iter->dims; /* Flag the diminfo information as not valid in the iterator */ @@ -772,17 +760,18 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) } /* end else */ /* Compute the cumulative size of dataspace dimensions */ - for(i = (int)slab_dim, acc = iter->elmt_size; i >= 0; i--) { + for (i = (int)slab_dim, acc = iter->elmt_size; i >= 0; i--) { iter->u.hyp.slab[i] = acc; acc *= slab_size[i]; } /* end for */ /* Initialize more information for irregular hyperslab selections */ - if(!iter->u.hyp.diminfo_valid) { + if (!iter->u.hyp.diminfo_valid) { /* Set the offset of the first element iterated on, in each dimension */ - for(u = 0; u < rank; u++) + for (u = 0; u < rank; u++) /* Compute the sequential element offset */ - iter->u.hyp.loc_off[u] = ((hsize_t)((hssize_t)iter->u.hyp.off[u] + iter->sel_off[u])) * iter->u.hyp.slab[u]; + iter->u.hyp.loc_off[u] = + ((hsize_t)((hssize_t)iter->u.hyp.off[u] + iter->sel_off[u])) * iter->u.hyp.slab[u]; } /* end if */ /* Initialize type of selection iterator */ @@ -792,7 +781,6 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_coords * @@ -818,34 +806,35 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ - if(iter->u.hyp.diminfo_valid) { + if (iter->u.hyp.diminfo_valid) { /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { - int u, v; /* Dimension indices */ + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + int u, v; /* Dimension indices */ /* Set the starting rank of both the "natural" & "flattened" dimensions */ u = (int)iter->rank - 1; v = (int)iter->u.hyp.iter_rank - 1; /* Construct the "natural" dimensions from a set of flattened coordinates */ - while(u >= 0) { - if(iter->u.hyp.flattened[u]) { - int begin = u; /* The rank of the first flattened dimension */ + while (u >= 0) { + if (iter->u.hyp.flattened[u]) { + int begin = u; /* The rank of the first flattened dimension */ /* Walk up through as many flattened dimensions as possible */ do { u--; - } while(u >= 0 && iter->u.hyp.flattened[u]); + } while (u >= 0 && iter->u.hyp.flattened[u]); /* Compensate for possibly overshooting dim 0 */ - if(u < 0) + if (u < 0) u = 0; /* Sanity check */ HDassert(v >= 0); /* Compute the coords for the flattened dimensions */ - H5VM_array_calc(iter->u.hyp.off[v], (unsigned)((begin - u) + 1), &(iter->dims[u]), &(coords[u])); + H5VM_array_calc(iter->u.hyp.off[v], (unsigned)((begin - u) + 1), &(iter->dims[u]), + &(coords[u])); /* Continue to faster dimension in both indices */ u--; @@ -853,7 +842,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) } /* end if */ else { /* Walk up through as many non-flattened dimensions as possible */ - while(u >= 0 && !iter->u.hyp.flattened[u]) { + while (u >= 0 && !iter->u.hyp.flattened[u]) { /* Sanity check */ HDassert(v >= 0); @@ -864,8 +853,8 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) u--; v--; } /* end while */ - } /* end else */ - } /* end while */ + } /* end else */ + } /* end while */ HDassert(v < 0); } /* end if */ else @@ -877,7 +866,6 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_block * @@ -897,7 +885,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) static herr_t H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -909,25 +897,24 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) /* Copy the offset of the current point */ /* Check for a single "regular" hyperslab */ - if(iter->u.hyp.diminfo_valid) { + if (iter->u.hyp.diminfo_valid) { /* Copy the start and compute the end of the block */ - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.off[u]; - end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1; + end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1; } } /* end if */ else { /* Copy the start & end of the block */ - for(u = 0; u < iter->rank; u++) { + for (u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.span[u]->low; - end[u] = iter->u.hyp.span[u]->high; + end[u] = iter->u.hyp.span[u]->high; } } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_nelmts * @@ -951,7 +938,6 @@ H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__hyper_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_has_next_block @@ -973,7 +959,7 @@ static H5_ATTR_PURE htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) { unsigned u; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -981,25 +967,25 @@ H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) HDassert(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 */ + 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 */ /* Check if the offset of the iterator is at the last location in all dimensions */ tdiminfo = iter->u.hyp.diminfo; - toff = iter->u.hyp.off; - for(u = 0; u < iter->rank; u++) { + toff = iter->u.hyp.off; + for (u = 0; u < iter->rank; u++) { /* If there is only one block, continue */ - if(tdiminfo[u].count == 1) + if (tdiminfo[u].count == 1) continue; - if(toff[u] != (tdiminfo[u].start + ((tdiminfo[u].count - 1) * tdiminfo[u].stride))) + if (toff[u] != (tdiminfo[u].start + ((tdiminfo[u].count - 1) * tdiminfo[u].stride))) HGOTO_DONE(TRUE); } /* end for */ - } /* end if */ + } /* end if */ else { /* Check for any levels of the tree with more sequences in them */ - for(u = 0; u < iter->rank; u++) - if(iter->u.hyp.span[u]->next != NULL) + for (u = 0; u < iter->rank; u++) + if (iter->u.hyp.span[u]->next != NULL) HGOTO_DONE(TRUE); } /* end else */ @@ -1007,7 +993,6 @@ H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_has_next_block() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next * @@ -1025,22 +1010,22 @@ H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) static herr_t H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - unsigned ndims; /* Number of dimensions of dataset */ - int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned u; /* Counters */ + unsigned ndims; /* Number of dimensions of dataset */ + int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned u; /* Counters */ FUNC_ENTER_STATIC_NOERR /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t iter_offset[H5S_MAX_RANK]; - hsize_t iter_count[H5S_MAX_RANK]; - int temp_dim; /* Temporary rank holder */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t iter_offset[H5S_MAX_RANK]; + hsize_t iter_count[H5S_MAX_RANK]; + int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) /* Set the aliases for the dimension rank */ ndims = iter->u.hyp.iter_rank; else @@ -1054,25 +1039,25 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) tdiminfo = iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { iter_offset[u] = iter->u.hyp.off[u] - tdiminfo[u].start; - iter_count[u] = 0; + iter_count[u] = 0; } /* end if */ else { iter_offset[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; - iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; + iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Loop through, advancing the offset & counts, until all the nelements are accounted for */ - while(nelem > 0) { + while (nelem > 0) { /* Start with the fastest changing dimension */ temp_dim = fast_dim; - while(temp_dim >= 0) { - if(temp_dim == fast_dim) { - size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - hsize_t block_elem; /* Number of elements left in a block */ + while (temp_dim >= 0) { + if (temp_dim == fast_dim) { + size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ + hsize_t block_elem; /* Number of elements left in a block */ /* Compute the number of elements left in block */ block_elem = tdiminfo[temp_dim].block - iter_offset[temp_dim]; @@ -1090,59 +1075,61 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_offset[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_offset[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ iter_offset[temp_dim] = 0; iter_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_count[temp_dim] < tdiminfo[temp_dim].count) break; else iter_count[temp_dim] = 0; /* reset back to the beginning of the line */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ - } /* end while */ + } /* end while */ /* Translate current iter_offset and iter_count into iterator position */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = tdiminfo[u].start + (tdiminfo[u].stride * iter_count[u]) + iter_offset[u]; } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ - H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t *abs_arr; /* Absolute hyperslab span position */ - int curr_dim; /* Temporary rank holder */ + 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 */ + int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr = iter->u.hyp.off; - ispan = iter->u.hyp.span; + ispan = iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ - while(nelem > 0) { + while (nelem > 0) { /* Start at the fastest dim */ curr_dim = fast_dim; /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; /* Increment absolute position */ - if(curr_dim == fast_dim) { - size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ - hsize_t span_elem; /* Number of elements left in a span */ + if (curr_dim == fast_dim) { + size_t actual_elem; /* Actual # of elements advanced on each iteration through loop */ + hsize_t span_elem; /* Number of elements left in a span */ /* Compute the number of elements left in block */ span_elem = (curr_span->high - abs_arr[curr_dim]) + 1; @@ -1161,7 +1148,7 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) + if (abs_arr[curr_dim] <= curr_span->high) break; /* If we walked off that span, advance to the next span */ else { @@ -1169,7 +1156,7 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1179,15 +1166,16 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on + * and loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while(curr_dim < fast_dim) { + while (curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1208,13 +1196,12 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); } /* end if */ - } /* end while */ - } /* end else */ + } /* end while */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next_block * @@ -1232,22 +1219,22 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) static herr_t H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) { - unsigned ndims; /* Number of dimensions of dataset */ - int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned u; /* Counters */ + unsigned ndims; /* Number of dimensions of dataset */ + int fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned u; /* Counters */ FUNC_ENTER_STATIC_NOERR /* Check for the special case of just one H5Sselect_hyperslab call made */ /* (i.e. a regular hyperslab selection) */ - if(iter->u.hyp.diminfo_valid) { - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t iter_offset[H5S_MAX_RANK]; - hsize_t iter_count[H5S_MAX_RANK]; - int temp_dim; /* Temporary rank holder */ + if (iter->u.hyp.diminfo_valid) { + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t iter_offset[H5S_MAX_RANK]; + hsize_t iter_count[H5S_MAX_RANK]; + int temp_dim; /* Temporary rank holder */ /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) /* Set the aliases for the dimension rank */ ndims = iter->u.hyp.iter_rank; else @@ -1261,21 +1248,21 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) tdiminfo = iter->u.hyp.diminfo; /* Calculate the offset and block count for each dimension */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { iter_offset[u] = iter->u.hyp.off[u] - tdiminfo[u].start; - iter_count[u] = 0; + iter_count[u] = 0; } /* end if */ else { iter_offset[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; - iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; + iter_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Advance one block */ temp_dim = fast_dim; /* Start with the fastest changing dimension */ - while(temp_dim >= 0) { - if(temp_dim == fast_dim) + while (temp_dim >= 0) { + if (temp_dim == fast_dim) /* Move iterator over current block */ iter_offset[temp_dim] += tdiminfo[temp_dim].block; else @@ -1283,53 +1270,54 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) iter_offset[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_offset[temp_dim] < tdiminfo[temp_dim].block) + if (iter_offset[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ iter_offset[temp_dim] = 0; iter_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(iter_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (iter_count[temp_dim] < tdiminfo[temp_dim].count) break; else iter_count[temp_dim] = 0; /* reset back to the beginning of the line */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ /* Translate current iter_offset and iter_count into iterator position */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = tdiminfo[u].start + (tdiminfo[u].stride * iter_count[u]) + iter_offset[u]; } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ - H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t *abs_arr; /* Absolute hyperslab span position */ - int curr_dim; /* Temporary rank holder */ + 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 */ + int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (int)ndims - 1; /* Get the pointers to the current span info and span nodes */ abs_arr = iter->u.hyp.off; - ispan = iter->u.hyp.span; + ispan = iter->u.hyp.span; /* Loop through, advancing the span information, until all the nelements are accounted for */ curr_dim = fast_dim; /* Start at the fastest dim */ /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; /* Increment absolute position */ - if(curr_dim == fast_dim) + if (curr_dim == fast_dim) /* Move the iterator over rest of element in span */ abs_arr[curr_dim] = curr_span->high + 1; else @@ -1337,7 +1325,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) + if (abs_arr[curr_dim] <= curr_span->high) break; /* If we walked off that span, advance to the next span */ else { @@ -1345,7 +1333,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1355,15 +1343,16 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on and + * loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while(curr_dim < fast_dim) { + while (curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1384,12 +1373,11 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); } /* end if */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_gen @@ -1420,28 +1408,28 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ 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_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 **ispan; /* Iterator's hyperslab span nodes */ - 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 */ - 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 */ - size_t io_elmts_left; /* Number of elements left to process */ - size_t io_used; /* Number of elements processed */ - size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */ - size_t elem_size; /* Size of each element iterating over */ - unsigned ndims; /* Number of dimensions of dataset */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - int curr_dim; /* Current dimension being operated on */ - unsigned u; /* Index variable */ + 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 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 */ + 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 */ + size_t io_elmts_left; /* Number of elements left to process */ + size_t io_used; /* Number of elements processed */ + size_t curr_seq = 0; /* Number of sequence/offsets stored in the arrays */ + size_t elem_size; /* Size of each element iterating over */ + unsigned ndims; /* Number of dimensions of dataset */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + int curr_dim; /* Current dimension being operated on */ + unsigned u; /* Index variable */ FUNC_ENTER_STATIC_NOERR @@ -1455,16 +1443,16 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max HDassert(len); /* Set the rank of the fastest changing dimension */ - ndims = iter->rank; + ndims = iter->rank; fast_dim = (ndims - 1); /* Get the pointers to the current span info and span nodes */ curr_span = iter->u.hyp.span[fast_dim]; - abs_arr = iter->u.hyp.off; - loc_arr = iter->u.hyp.loc_off; - slab = iter->u.hyp.slab; - sel_off = iter->sel_off; - ispan = iter->u.hyp.span; + abs_arr = iter->u.hyp.off; + loc_arr = iter->u.hyp.loc_off; + slab = iter->u.hyp.slab; + sel_off = iter->sel_off; + ispan = iter->u.hyp.span; elem_size = iter->elmt_size; /* Set the amount of elements to perform I/O on, etc. */ @@ -1472,18 +1460,18 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max io_elmts_left = io_left = MIN(maxelem, (size_t)iter->elmt_left); /* Set the offset of the first element iterated on */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; /* Take care of any partial spans leftover from previous I/Os */ - if(abs_arr[fast_dim] != curr_span->low) { + if (abs_arr[fast_dim] != curr_span->low) { /* Finish the span in the fastest changing dimension */ /* Compute the number of elements to attempt in this span */ H5_CHECKED_ASSIGN(span_elmts, size_t, ((curr_span->high - abs_arr[fast_dim]) + 1), hsize_t); /* Check number of elements against upper bounds allowed */ - if(span_elmts > io_elmts_left) + if (span_elmts > io_elmts_left) span_elmts = io_elmts_left; /* Set the span_size, in bytes */ @@ -1503,26 +1491,27 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max io_elmts_left -= span_elmts; /* Check if we are done */ - if(io_elmts_left > 0) { + if (io_elmts_left > 0) { /* Move to next span in fastest changing dimension */ curr_span = curr_span->next; - if(NULL != curr_span) { + if (NULL != curr_span) { /* Move location offset of destination */ loc_off += (curr_span->low - abs_arr[fast_dim]) * elem_size; /* Move iterator for fastest changing dimension */ abs_arr[fast_dim] = curr_span->low; - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; ispan[fast_dim] = curr_span; } /* end if */ - } /* end if */ + } /* end if */ else { /* Advance the hyperslab iterator */ abs_arr[fast_dim] += span_elmts; /* Check if we are still within the span */ - if(abs_arr[fast_dim] <= curr_span->high) { + if (abs_arr[fast_dim] <= curr_span->high) { /* Sanity check */ HDassert(ispan[fast_dim] == curr_span); @@ -1535,28 +1524,29 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(NULL != curr_span) { + if (NULL != curr_span) { /* Reset absolute position */ abs_arr[fast_dim] = curr_span->low; /* Update location offset */ - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; /* Reset the span in the current dimension */ ispan[fast_dim] = curr_span; } /* end if */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Adjust iterator pointers */ - if(NULL == curr_span) { -/* Same as code in main loop */ + if (NULL == curr_span) { + /* Same as code in main loop */ /* Start at the next fastest dim */ curr_dim = (int)(fast_dim - 1); /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; @@ -1564,7 +1554,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) { + if (abs_arr[curr_dim] <= curr_span->high) { /* Update location offset */ loc_arr[curr_dim] += slab[curr_dim]; @@ -1576,7 +1566,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(NULL != curr_span) { + if (NULL != curr_span) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1584,20 +1574,22 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update byte location */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on + * and loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we have more spans in the tree */ - if(curr_dim >= 0) { + if (curr_dim >= 0) { /* Walk back down the iterator positions, resetting them */ - while((unsigned)curr_dim < fast_dim) { + while ((unsigned)curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1615,25 +1607,26 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update the location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; } /* end while */ /* Verify that the curr_span points to the fastest dim */ HDassert(curr_span == ispan[fast_dim]); /* Reset the buffer offset */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; } /* end else */ else /* We had better be done with I/O or bad things are going to happen... */ HDassert(io_elmts_left == 0); } /* end if */ - } /* end if */ + } /* end if */ /* Perform the I/O on the elements, based on the position of the iterator */ - while(io_elmts_left > 0 && curr_seq < maxseq) { - H5S_hyper_span_t *prev_span; /* Previous hyperslab span node */ + while (io_elmts_left > 0 && curr_seq < maxseq) { + H5S_hyper_span_t *prev_span; /* Previous hyperslab span node */ /* Sanity check */ HDassert(curr_span); @@ -1642,8 +1635,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max prev_span = curr_span; /* Loop over all the spans in the fastest changing dimension */ - while(curr_span != NULL) { - hsize_t nelmts; /* # of elements covered by current span */ + while (curr_span != NULL) { + hsize_t nelmts; /* # of elements covered by current span */ /* Move location offset of current span */ loc_off += (curr_span->low - prev_span->low) * elem_size; @@ -1653,17 +1646,17 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max H5_CHECKED_ASSIGN(span_elmts, size_t, nelmts, hsize_t); /* Check number of elements against upper bounds allowed */ - if(span_elmts >= io_elmts_left) { + if (span_elmts >= io_elmts_left) { /* Trim the number of elements to output */ - span_elmts = io_elmts_left; - span_size = span_elmts * elem_size; + span_elmts = io_elmts_left; + span_size = span_elmts * elem_size; io_elmts_left = 0; -/* COMMON */ + /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ - if(curr_seq > 0 && last_span_end == loc_off) + if (curr_seq > 0 && last_span_end == loc_off) len[curr_seq - 1] += span_size; else { off[curr_seq] = loc_off; @@ -1672,7 +1665,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ -/* end COMMON */ + /* end COMMON */ /* Break out now, we are finished with I/O */ break; @@ -1682,11 +1675,11 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max span_size = span_elmts * elem_size; io_elmts_left -= span_elmts; -/* COMMON */ + /* COMMON */ /* Store the I/O information for the span */ /* Check if this is appending onto previous sequence */ - if(curr_seq > 0 && last_span_end == loc_off) + if (curr_seq > 0 && last_span_end == loc_off) len[curr_seq - 1] += span_size; else { off[curr_seq] = loc_off; @@ -1695,10 +1688,10 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the number of sequences in arrays */ curr_seq++; } /* end else */ -/* end COMMON */ + /* end COMMON */ /* If the sequence & offset arrays are full, do what? */ - if(curr_seq >= maxseq) + if (curr_seq >= maxseq) /* Break out now, we are finished with sequences */ break; } /* end else */ @@ -1706,13 +1699,13 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Set the location of the last span's end */ last_span_end = loc_off + span_size; - /* Move to next span in fastest changing dimension */ + /* Move to next span in fastest changing dimension */ prev_span = curr_span; - curr_span = curr_span->next; + curr_span = curr_span->next; } /* end while */ /* Check if we are done */ - if(io_elmts_left == 0 || curr_seq >= maxseq) { + if (io_elmts_left == 0 || curr_seq >= maxseq) { /* Sanity checks */ HDassert(curr_span); @@ -1720,12 +1713,14 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[fast_dim] = curr_span->low + span_elmts; /* Check if we are still within the span */ - if(abs_arr[fast_dim] <= curr_span->high) { + if (abs_arr[fast_dim] <= curr_span->high) { /* Reset the span for the fast dimension */ ispan[fast_dim] = curr_span; /* Update location offset */ - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + (hssize_t)span_elmts + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + (hssize_t)span_elmts + sel_off[fast_dim])) * + slab[fast_dim]; break; } /* end if */ @@ -1735,16 +1730,17 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset absolute position */ abs_arr[fast_dim] = curr_span->low; - loc_arr[fast_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; + loc_arr[fast_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[fast_dim])) * slab[fast_dim]; ispan[fast_dim] = curr_span; break; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Adjust iterator pointers */ @@ -1752,7 +1748,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_dim = (int)(fast_dim - 1); /* Work back up through the dimensions */ - while(curr_dim >= 0) { + while (curr_dim >= 0) { /* Reset the current span */ curr_span = ispan[curr_dim]; @@ -1760,7 +1756,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim]++; /* Check if we are still within the span */ - if(abs_arr[curr_dim] <= curr_span->high) { + if (abs_arr[curr_dim] <= curr_span->high) { /* Update location offset */ loc_arr[curr_dim] += slab[curr_dim]; @@ -1772,7 +1768,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max curr_span = curr_span->next; /* Check if we have a valid span in this dimension still */ - if(curr_span != NULL) { + if (curr_span != NULL) { /* Reset the span in the current dimension */ ispan[curr_dim] = curr_span; @@ -1780,25 +1776,27 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; break; } /* end if */ else - /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ + /* If we finished the span list in this dimension, decrement the dimension worked on and + * loop again */ curr_dim--; } /* end else */ - } /* end while */ + } /* end while */ /* Check if we are finished with the spans in the tree */ - if(curr_dim < 0) { + if (curr_dim < 0) { /* We had better be done with I/O or bad things are going to happen... */ HDassert(io_elmts_left == 0); break; } /* end if */ else { /* Walk back down the iterator positions, resetting them */ - while((unsigned)curr_dim < fast_dim) { + while ((unsigned)curr_dim < fast_dim) { HDassert(curr_span); HDassert(curr_span->down); HDassert(curr_span->down->head); @@ -1816,7 +1814,8 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max abs_arr[curr_dim] = curr_span->low; /* Update location offset */ - loc_arr[curr_dim] = ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; + loc_arr[curr_dim] = + ((hsize_t)((hssize_t)curr_span->low + sel_off[curr_dim])) * slab[curr_dim]; } /* end while */ /* Verify that the curr_span points to the fastest dim */ @@ -1824,7 +1823,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max } /* end else */ /* Reset the buffer offset */ - for(u = 0, loc_off = 0; u < ndims; u++) + for (u = 0, loc_off = 0; u < ndims; u++) loc_off += loc_arr[u]; } /* end while */ @@ -1841,7 +1840,6 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_gen() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_opt @@ -1872,39 +1870,37 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max REVISION LOG --------------------------------------------------------------------------*/ 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) +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 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 */ - hsize_t wrap[H5S_MAX_RANK]; /* Bytes to wrap around at the end of a row */ - hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ - const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */ - fast_dim_stride, - fast_dim_block, - fast_dim_offset; - size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */ - size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */ - size_t tot_blk_count; /* Total number of blocks left to output */ - size_t act_blk_count; /* Actual number of blocks to output */ - size_t total_rows; /* Total number of entire rows to output */ - size_t curr_rows; /* Current number of entire rows to output */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Number of dimensions of dataset */ - int temp_dim; /* Temporary rank holder */ - hsize_t loc; /* Coordinate offset */ - size_t curr_seq = 0; /* Current sequence being operated on */ - size_t actual_elem; /* The actual number of elements to count */ - size_t actual_bytes;/* The actual number of bytes to copy */ - size_t io_left; /* The number of elements left in I/O operation */ - size_t start_io_left; /* The initial number of elements left in I/O operation */ - size_t elem_size; /* Size of each element iterating over */ - unsigned u; /* Local index variable */ + 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 */ + hsize_t wrap[H5S_MAX_RANK]; /* Bytes to wrap around at the end of a row */ + hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ + const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ + hsize_t fast_dim_start, /* Local copies of fastest changing dimension info */ + fast_dim_stride, fast_dim_block, fast_dim_offset; + size_t fast_dim_buf_off; /* Local copy of amount to move fastest dimension buffer offset */ + size_t fast_dim_count; /* Number of blocks left in fastest changing dimension */ + size_t tot_blk_count; /* Total number of blocks left to output */ + size_t act_blk_count; /* Actual number of blocks to output */ + size_t total_rows; /* Total number of entire rows to output */ + size_t curr_rows; /* Current number of entire rows to output */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Number of dimensions of dataset */ + int temp_dim; /* Temporary rank holder */ + hsize_t loc; /* Coordinate offset */ + size_t curr_seq = 0; /* Current sequence being operated on */ + size_t actual_elem; /* The actual number of elements to count */ + size_t actual_bytes; /* The actual number of bytes to copy */ + size_t io_left; /* The number of elements left in I/O operation */ + size_t start_io_left; /* The initial number of elements left in I/O operation */ + size_t elem_size; /* Size of each element iterating over */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1921,7 +1917,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -1943,9 +1939,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max } /* end else */ /* Set up some local variables */ - fast_dim = ndims - 1; + fast_dim = ndims - 1; elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Calculate the number of elements to sequence through */ H5_CHECK_OVERFLOW(iter->elmt_left, hsize_t, size_t); @@ -1953,7 +1949,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Sanity check that there aren't any "remainder" sequences in process */ HDassert(!((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || - ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1))); + ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1))); /* We've cleared the "remainder" of the previous fastest dimension * sequence before calling this routine, so we must be at the beginning of @@ -1968,12 +1964,12 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Copy the location of the point to get */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]); /* Compute the current "counts" for this location */ - for(u = 0; u < ndims; u++) { - if(tdiminfo[u].count == 1) { + for (u = 0; u < ndims; u++) { + if (tdiminfo[u].count == 1) { tmp_count[u] = 0; tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start; } /* end if */ @@ -1981,10 +1977,10 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) / tdiminfo[u].stride; tmp_block[u] = (iter->u.hyp.off[u] - tdiminfo[u].start) % tdiminfo[u].stride; } /* end else */ - } /* end for */ + } /* end for */ /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += offset[u] * slab[u]; /* Set the number of elements to write each time */ @@ -1994,9 +1990,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max actual_bytes = actual_elem * elem_size; /* Set local copies of information for the fastest changing dimension */ - fast_dim_start = tdiminfo[fast_dim].start; + fast_dim_start = tdiminfo[fast_dim].start; fast_dim_stride = tdiminfo[fast_dim].stride; - fast_dim_block = tdiminfo[fast_dim].block; + fast_dim_block = tdiminfo[fast_dim].block; H5_CHECKED_ASSIGN(fast_dim_buf_off, size_t, slab[fast_dim] * fast_dim_stride, hsize_t); fast_dim_offset = (hsize_t)((hssize_t)fast_dim_start + sel_off[fast_dim]); @@ -2008,15 +2004,15 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tot_blk_count = MIN(tot_blk_count, (maxseq - curr_seq)); /* Compute the amount to wrap at the end of each row */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) wrap[u] = (mem_size[u] - (tdiminfo[u].stride * tdiminfo[u].count)) * slab[u]; /* Compute the amount to skip between blocks */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) skip[u] = (tdiminfo[u].stride - tdiminfo[u].block) * slab[u]; /* Check if there is a partial row left (with full blocks) */ - if(tmp_count[fast_dim] > 0) { + if (tmp_count[fast_dim] > 0) { /* Get number of blocks in fastest dimension */ H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count - tmp_count[fast_dim], hsize_t); @@ -2027,7 +2023,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max act_blk_count = fast_dim_count; /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { /* Store the sequence information */ off[curr_seq] = loc; len[curr_seq] = actual_bytes; @@ -2052,23 +2048,24 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[fast_dim] += act_blk_count; /* Check if we finished the entire row of blocks */ - if(tmp_count[fast_dim] >= tdiminfo[fast_dim].count) { + if (tmp_count[fast_dim] >= tdiminfo[fast_dim].count) { /* Increment offset in destination buffer */ loc += wrap[fast_dim]; /* Increment information to reflect block just processed */ - offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */ + offset[fast_dim] = fast_dim_offset; /* reset the offset in the fastest dimension */ tmp_count[fast_dim] = 0; /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ @@ -2077,8 +2074,9 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_block[temp_dim] = 0; tmp_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_count[temp_dim] < tdiminfo[temp_dim].count) break; else { offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]); @@ -2086,17 +2084,17 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */ tmp_block[temp_dim] = 0; } /* end else */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ else { /* Update the offset in the fastest dimension */ offset[fast_dim] += (fast_dim_stride * act_blk_count); } /* end else */ - } /* end if */ + } /* end if */ /* Compute the number of entire rows to read in */ H5_CHECK_OVERFLOW(tot_blk_count / tdiminfo[fast_dim].count, hsize_t, size_t); @@ -2106,28 +2104,28 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max H5_CHECKED_ASSIGN(fast_dim_count, size_t, tdiminfo[fast_dim].count, hsize_t); /* Read in data until an entire sequence can't be written out any longer */ - while(curr_rows > 0) { - -#define DUFF_GUTS \ -/* Store the sequence information */ \ -off[curr_seq] = loc; \ -len[curr_seq] = actual_bytes; \ - \ -/* Increment sequence count */ \ -curr_seq++; \ - \ -/* Increment information to reflect block just processed */ \ -loc += fast_dim_buf_off; + while (curr_rows > 0) { + +#define DUFF_GUTS \ + /* Store the sequence information */ \ + off[curr_seq] = loc; \ + len[curr_seq] = actual_bytes; \ + \ + /* Increment sequence count */ \ + curr_seq++; \ + \ + /* Increment information to reflect block just processed */ \ + loc += fast_dim_buf_off; #ifdef NO_DUFFS_DEVICE /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { DUFF_GUTS /* Decrement number of blocks */ fast_dim_count--; } /* end while */ -#else /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ { size_t duffs_index; /* Counting index for Duff's device */ @@ -2137,34 +2135,40 @@ loc += fast_dim_buf_off; HDassert(0 && "This Should never be executed!"); break; case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: + do { DUFF_GUTS + /* FALLTHROUGH */ H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); + case 7: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); } /* end switch */ } -#endif /* NO_DUFFS_DEVICE */ +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS /* Increment offset in destination buffer */ @@ -2172,13 +2176,13 @@ loc += fast_dim_buf_off; /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { /* Move to the next block in the current dimension */ @@ -2187,8 +2191,9 @@ loc += fast_dim_buf_off; tmp_block[temp_dim] = 0; tmp_count[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_count[temp_dim] < tdiminfo[temp_dim].count) + /* If this block is still in the range of blocks to output for the dimension, break out of + * loop */ + if (tmp_count[temp_dim] < tdiminfo[temp_dim].count) break; else { offset[temp_dim] = (hsize_t)((hssize_t)tdiminfo[temp_dim].start + sel_off[temp_dim]); @@ -2196,7 +2201,7 @@ loc += fast_dim_buf_off; tmp_count[temp_dim] = 0; /* reset back to the beginning of the line */ tmp_block[temp_dim] = 0; } /* end else */ - } /* end else */ + } /* end else */ /* Decrement dimension count */ temp_dim--; @@ -2217,12 +2222,12 @@ loc += fast_dim_buf_off; tot_blk_count -= (size_t)(total_rows * tdiminfo[fast_dim].count); /* Read in partial row of blocks */ - if(io_left > 0 && curr_seq < maxseq) { + if (io_left > 0 && curr_seq < maxseq) { /* Get remaining number of blocks left to output */ fast_dim_count = tot_blk_count; /* Loop over all the blocks in the fastest changing dimension */ - while(fast_dim_count > 0) { + while (fast_dim_count > 0) { /* Store the sequence information */ off[curr_seq] = loc; len[curr_seq] = actual_bytes; @@ -2241,11 +2246,11 @@ loc += fast_dim_buf_off; io_left -= actual_elem * tot_blk_count; /* Increment information to reflect block just processed */ - offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */ + offset[fast_dim] += (fast_dim_stride * tot_blk_count); /* move the offset in the fastest dimension */ /* Handle any leftover, partial blocks in this row */ - if(io_left > 0 && curr_seq < maxseq) { - actual_elem = io_left; + if (io_left > 0 && curr_seq < maxseq) { + actual_elem = io_left; actual_bytes = actual_elem * elem_size; /* Store the sequence information */ @@ -2270,7 +2275,7 @@ loc += fast_dim_buf_off; /* Update the iterator with the location we stopped */ /* (Subtract out the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]); /* Decrement the number of elements left in selection */ @@ -2285,7 +2290,6 @@ loc += fast_dim_buf_off; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_opt() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_single @@ -2317,25 +2321,25 @@ loc += fast_dim_buf_off; REVISION LOG --------------------------------------------------------------------------*/ 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) +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) { - 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 */ - 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 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 */ - size_t elem_size; /* Size of each element iterating over */ - size_t io_left; /* The number of elements left in I/O operation */ - size_t actual_elem; /* The actual number of elements to count */ - unsigned ndims; /* Number of dimensions of dataset */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned skip_dim; /* Rank of the dimension to skip along */ - unsigned u; /* Local index variable */ + 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 */ + 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 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 */ + size_t elem_size; /* Size of each element iterating over */ + size_t io_left; /* The number of elements left in I/O operation */ + size_t actual_elem; /* The actual number of elements to count */ + unsigned ndims; /* Number of dimensions of dataset */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned skip_dim; /* Rank of the dimension to skip along */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2352,7 +2356,7 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -2374,22 +2378,22 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t } /* end else */ /* Set up some local variables */ - fast_dim = ndims - 1; + fast_dim = ndims - 1; elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Copy the base location of the block */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) base_offset[u] = (hsize_t)((hssize_t)tdiminfo[u].start + sel_off[u]); /* Copy the location of the point to get */ /* (Add in the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = (hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u]); /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += offset[u] * slab[u]; /* Set local copies of information for the fastest changing dimension */ @@ -2410,14 +2414,14 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t H5_CHECKED_ASSIGN(actual_elem, size_t, fast_dim_block, hsize_t); /* Check for blocks to operate on */ - if(tot_blk_count > 0) { - size_t actual_bytes; /* The actual number of bytes to copy */ + if (tot_blk_count > 0) { + size_t actual_bytes; /* The actual number of bytes to copy */ /* Set the number of actual bytes */ actual_bytes = actual_elem * elem_size; /* Check for 1-dim selection */ - if(0 == fast_dim) { + if (0 == fast_dim) { /* Sanity checks */ HDassert(1 == tot_blk_count); HDassert(io_left == actual_elem); @@ -2427,24 +2431,24 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t *len++ = actual_bytes; } /* end if */ else { - hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */ - size_t blk_count; /* Total number of blocks left to output */ - int i; /* Local index variable */ + hsize_t skip_slab; /* Temporary copy of slab[fast_dim - 1] */ + size_t blk_count; /* Total number of blocks left to output */ + int i; /* Local index variable */ /* Find first dimension w/block >1 */ skip_dim = fast_dim; - for(i = (int)(fast_dim - 1); i >= 0; i--) - if(tdiminfo[i].block > 1) { + for (i = (int)(fast_dim - 1); i >= 0; i--) + if (tdiminfo[i].block > 1) { skip_dim = (unsigned)i; break; } /* end if */ skip_slab = slab[skip_dim]; /* Check for being able to use fast algorithm for 1-D */ - if(0 == skip_dim) { + if (0 == skip_dim) { /* Create sequences until an entire row can't be used */ blk_count = tot_blk_count; - while(blk_count > 0) { + while (blk_count > 0) { /* Store the sequence information */ *off++ = loc; *len++ = actual_bytes; @@ -2460,21 +2464,21 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t offset[skip_dim] += tot_blk_count; } /* end if */ else { - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ - hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ - int temp_dim; /* Temporary rank holder */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ + hsize_t skip[H5S_MAX_RANK]; /* Bytes to skip between blocks */ + int temp_dim; /* Temporary rank holder */ /* Set the starting block location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) tmp_block[u] = iter->u.hyp.off[u] - tdiminfo[u].start; /* Compute the amount to skip between sequences */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) skip[u] = (mem_size[u] - tdiminfo[u].block) * slab[u]; /* Create sequences until an entire row can't be used */ blk_count = tot_blk_count; - while(blk_count > 0) { + while (blk_count > 0) { /* Store the sequence information */ *off++ = loc; *len++ = actual_bytes; @@ -2486,13 +2490,14 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t loc += skip_slab; /* Increment the offset and count for the other dimensions */ - while(temp_dim >= 0) { + while (temp_dim >= 0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; - /* If this block is still in the range of blocks to output for the dimension, break out of loop */ - if(tmp_block[temp_dim] < tdiminfo[temp_dim].block) + /* If this block is still in the range of blocks to output for the dimension, break + * out of loop */ + if (tmp_block[temp_dim] < tdiminfo[temp_dim].block) break; else { offset[temp_dim] = base_offset[temp_dim]; @@ -2507,8 +2512,8 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t /* Decrement block count */ blk_count--; } /* end while */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Update the iterator, if there were any blocks used */ @@ -2516,10 +2521,10 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t iter->elmt_left -= tot_blk_count * actual_elem; /* Check if there are elements left in iterator */ - if(iter->elmt_left > 0) { + if (iter->elmt_left > 0) { /* Update the iterator with the location we stopped */ /* (Subtract out the selection offset) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) iter->u.hyp.off[u] = (hsize_t)((hssize_t)offset[u] - sel_off[u]); } /* end if */ @@ -2531,8 +2536,8 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t } /* end if */ /* Check for partial block, with room for another sequence */ - if(io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) { - size_t elmt_remainder; /* Elements remaining */ + if (io_left > (tot_blk_count * actual_elem) && tot_blk_count < maxseq) { + size_t elmt_remainder; /* Elements remaining */ /* Compute elements left */ elmt_remainder = io_left - (tot_blk_count * actual_elem); @@ -2563,7 +2568,6 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_single() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list @@ -2595,10 +2599,10 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_iter_get_seq_list(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_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, + hsize_t *off, size_t *len) { - herr_t ret_value = FAIL; /* return value */ + herr_t ret_value = FAIL; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -2613,19 +2617,19 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, HDassert(len); /* 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 */ - 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 */ - unsigned u; /* Local index variable */ + 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 */ + 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 */ + unsigned u; /* Local index variable */ /* Set a local copy of the diminfo pointer */ tdiminfo = iter->u.hyp.diminfo; /* Check if this is a "flattened" regular hyperslab selection */ - if(iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { + if (iter->u.hyp.iter_rank != 0 && iter->u.hyp.iter_rank < iter->rank) { /* Set the aliases for a few important dimension ranks */ ndims = iter->u.hyp.iter_rank; @@ -2642,20 +2646,27 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, fast_dim = ndims - 1; /* Check if we stopped in the middle of a sequence of elements */ - if((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || - ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) { - hsize_t *slab; /* Hyperslab size */ - hsize_t loc; /* Coordinate offset */ - size_t leftover; /* The number of elements left over from the last sequence */ - size_t actual_elem; /* The actual number of elements to count */ - size_t elem_size; /* Size of each element iterating over */ + if ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride != 0 || + ((iter->u.hyp.off[fast_dim] != tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count == 1)) { + hsize_t *slab; /* Hyperslab size */ + hsize_t loc; /* Coordinate offset */ + size_t leftover; /* The number of elements left over from the last sequence */ + size_t actual_elem; /* The actual number of elements to count */ + size_t elem_size; /* Size of each element iterating over */ /* Calculate the number of elements left in the sequence */ - if(tdiminfo[fast_dim].count == 1) { - H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), hsize_t); + if (tdiminfo[fast_dim].count == 1) { + H5_CHECKED_ASSIGN(leftover, size_t, + tdiminfo[fast_dim].block - + (iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start), + hsize_t); } /* end if */ else { - H5_CHECKED_ASSIGN(leftover, size_t, tdiminfo[fast_dim].block - ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), hsize_t); + H5_CHECKED_ASSIGN( + leftover, size_t, + tdiminfo[fast_dim].block - + ((iter->u.hyp.off[fast_dim] - tdiminfo[fast_dim].start) % tdiminfo[fast_dim].stride), + hsize_t); } /* end else */ /* Make certain that we don't write too many */ @@ -2663,10 +2674,10 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, /* Set up some local variables */ elem_size = iter->elmt_size; - slab = iter->u.hyp.slab; + slab = iter->u.hyp.slab; /* Compute the initial buffer offset */ - for(u = 0, loc = 0; u < ndims; u++) + for (u = 0, loc = 0; u < ndims; u++) loc += ((hsize_t)((hssize_t)iter->u.hyp.off[u] + sel_off[u])) * slab[u]; /* Add a new sequence */ @@ -2688,29 +2699,29 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, maxseq--; /* Set the number of sequences generated and elements used */ - *nseq = 1; + *nseq = 1; *nelem = actual_elem; /* Check for using up all the sequences/elements */ - if(0 == iter->elmt_left || 0 == maxelem || 0 == maxseq) - return(SUCCEED); + if (0 == iter->elmt_left || 0 == maxelem || 0 == maxseq) + return (SUCCEED); } /* end if */ else { /* Reset the number of sequences generated and elements used */ - *nseq = 0; + *nseq = 0; *nelem = 0; } /* end else */ /* Check for a single block selected */ single_block = TRUE; - for(u = 0; u < ndims; u++) - if(1 != tdiminfo[u].count) { + for (u = 0; u < ndims; u++) + if (1 != tdiminfo[u].count) { single_block = FALSE; break; } /* end if */ /* Check for single block selection */ - if(single_block) + if (single_block) /* Use single-block optimized call to generate sequence list */ ret_value = H5S__hyper_iter_get_seq_list_single(iter, maxseq, maxelem, nseq, nelem, off, len); else @@ -2724,7 +2735,6 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_release @@ -2751,13 +2761,12 @@ H5S__hyper_iter_release(H5S_sel_iter_t *iter) HDassert(iter); /* Free the copy of the hyperslab selection span tree */ - if(iter->u.hyp.spans != NULL) + if (iter->u.hyp.spans != NULL) H5S__hyper_free_span_info(iter->u.hyp.spans); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span @@ -2780,32 +2789,30 @@ H5S__hyper_iter_release(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ 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) +H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next) { - H5S_hyper_span_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate a new span node */ - if(NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t))) + if (NULL == (ret_value = H5FL_MALLOC(H5S_hyper_span_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Copy the span's basic information */ - ret_value->low = low; + ret_value->low = low; ret_value->high = high; ret_value->down = down; ret_value->next = next; /* Increment the reference count of the 'down span' if there is one */ - if(ret_value->down) + if (ret_value->down) ret_value->down->count++; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span_info @@ -2828,7 +2835,7 @@ H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, static H5S_hyper_span_info_t * H5S__hyper_new_span_info(unsigned rank) { - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2837,18 +2844,17 @@ H5S__hyper_new_span_info(unsigned rank) HDassert(rank <= H5S_MAX_RANK); /* Allocate a new span info node */ - if(NULL == (ret_value = (H5S_hyper_span_info_t *)H5FL_ARR_CALLOC(hbounds_t, rank * 2))) + if (NULL == (ret_value = (H5S_hyper_span_info_t *)H5FL_ARR_CALLOC(hbounds_t, rank * 2))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info") /* Set low & high bound pointers into the 'bounds' array */ - ret_value->low_bounds = ret_value->bounds; + ret_value->low_bounds = ret_value->bounds; ret_value->high_bounds = &ret_value->bounds[rank]; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span_info() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span_helper @@ -2870,14 +2876,13 @@ H5S__hyper_new_span_info(unsigned rank) REVISION LOG --------------------------------------------------------------------------*/ 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_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_info_t *new_down; /* New down span tree */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -2885,7 +2890,7 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(spans); /* Check if the span tree was already copied */ - if(spans->op_info[op_info_i].op_gen == op_gen) { + if (spans->op_info[op_info_i].op_gen == op_gen) { /* Just return the value of the already copied span tree */ ret_value = spans->op_info[op_info_i].u.copied; @@ -2894,7 +2899,7 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, } /* end if */ else { /* Allocate a new span_info node */ - if(NULL == (ret_value = H5S__hyper_new_span_info(rank))) + if (NULL == (ret_value = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span info") /* Set the non-zero span_info information */ @@ -2909,22 +2914,22 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, spans->op_info[op_info_i].u.copied = ret_value; /* Copy over the nodes in the span list */ - span = spans->head; + span = spans->head; prev_span = NULL; - while(span != NULL) { + while (span != NULL) { /* Allocate a new node */ - if(NULL == (new_span = H5S__hyper_new_span(span->low, span->high, NULL, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(span->low, span->high, NULL, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Append to list of spans */ - if(NULL == prev_span) + if (NULL == prev_span) ret_value->head = new_span; else prev_span->next = new_span; /* Recurse to copy the 'down' spans, if there are any */ - if(span->down != NULL) { - if(NULL == (new_down = H5S__hyper_copy_span_helper(span->down, rank - 1, op_info_i, op_gen))) + if (span->down != NULL) { + if (NULL == (new_down = H5S__hyper_copy_span_helper(span->down, rank - 1, op_info_i, op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab spans") new_span->down = new_down; } /* end if */ @@ -2944,7 +2949,6 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span @@ -2968,8 +2972,8 @@ H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, static H5S_hyper_span_info_t * H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank) { - uint64_t op_gen; /* Operation generation value */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + uint64_t op_gen; /* Operation generation value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2982,14 +2986,13 @@ H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank) /* Copy the hyperslab span tree */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - if(NULL == (ret_value = H5S__hyper_copy_span_helper(spans, rank, 0, op_gen))) + if (NULL == (ret_value = H5S__hyper_copy_span_helper(spans, rank, 0, op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_cmp_spans @@ -3012,23 +3015,23 @@ H5S__hyper_copy_span(H5S_hyper_span_info_t *spans, unsigned rank) static H5_ATTR_PURE hbool_t H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check for redundant comparison (or both spans being NULL) */ - if(span_info1 != span_info2) { + if (span_info1 != span_info2) { /* Check for one span being NULL */ - if(span_info1 == NULL || span_info2 == NULL) + if (span_info1 == NULL || span_info2 == NULL) HGOTO_DONE(FALSE) else { /* Compare low & high bounds for this span list */ /* (Could compare lower dimensions also, but not certain if * that's worth it. - QAK, 2019/01/23) */ - if(span_info1->low_bounds[0] != span_info2->low_bounds[0]) + if (span_info1->low_bounds[0] != span_info2->low_bounds[0]) HGOTO_DONE(FALSE) - else if(span_info1->high_bounds[0] != span_info2->high_bounds[0]) + else if (span_info1->high_bounds[0] != span_info2->high_bounds[0]) HGOTO_DONE(FALSE) else { const H5S_hyper_span_t *span1; @@ -3043,40 +3046,40 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp HDassert(span2); /* infinite loop which must be broken out of */ - while(1) { + while (1) { /* Check for both spans being NULL */ - if(span1 == NULL && span2 == NULL) + if (span1 == NULL && span2 == NULL) HGOTO_DONE(TRUE) else { /* Check for one span being NULL */ - if(span1 == NULL || span2 == NULL) + if (span1 == NULL || span2 == NULL) HGOTO_DONE(FALSE) else { /* Check if the actual low & high span information is the same */ - if(span1->low != span2->low || span1->high != span2->high) + if (span1->low != span2->low || span1->high != span2->high) HGOTO_DONE(FALSE) else { - if(span1->down != NULL || span2->down != NULL) { - if(!H5S__hyper_cmp_spans(span1->down, span2->down)) + if (span1->down != NULL || span2->down != NULL) { + if (!H5S__hyper_cmp_spans(span1->down, span2->down)) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end if */ + } /* end if */ else { /* Keep going... */ } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ /* Advance to the next nodes in the span list */ span1 = span1->next; span2 = span2->next; } /* end while */ - } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end else */ + } /* end if */ /* Fall through, with default return value of 'TRUE' if spans were already visited */ @@ -3084,7 +3087,6 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_cmp_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span_info @@ -3116,13 +3118,13 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) span_info->count--; /* Free the span tree if the reference count drops to zero */ - if(span_info->count == 0) { - H5S_hyper_span_t *span; /* Pointer to spans to iterate over */ + if (span_info->count == 0) { + H5S_hyper_span_t *span; /* Pointer to spans to iterate over */ /* Work through the list of spans pointed to by this 'info' node */ span = span_info->head; - while(span != NULL) { - H5S_hyper_span_t *next_span; /* Pointer to next span to iterate over */ + while (span != NULL) { + H5S_hyper_span_t *next_span; /* Pointer to next span to iterate over */ /* Keep a pointer to the next span */ next_span = span->next; @@ -3141,7 +3143,6 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span_info() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span @@ -3170,7 +3171,7 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) HDassert(span); /* Decrement the reference count of the 'down spans', freeing them if appropriate */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_free_span_info(span->down); /* Free this span */ @@ -3179,7 +3180,6 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_copy @@ -3208,9 +3208,9 @@ 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 */ - const H5S_hyper_sel_t *src_hslab; /* Pointer to source hyperslab info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC @@ -3219,7 +3219,7 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(dst); /* Allocate space for the hyperslab selection information */ - if(NULL == (dst->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (dst->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set temporary pointers */ @@ -3228,33 +3228,33 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) /* Copy the hyperslab information */ dst_hslab->diminfo_valid = src_hslab->diminfo_valid; - if(src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) H5MM_memcpy(&dst_hslab->diminfo, &src_hslab->diminfo, sizeof(H5S_hyper_diminfo_t)); /* Check if there is hyperslab span information to copy */ /* (Regular hyperslab information is copied with the selection structure) */ - if(src->select.sel_info.hslab->span_lst != NULL) { - if(share_selection) { + if (src->select.sel_info.hslab->span_lst != NULL) { + if (share_selection) { /* Share the source's span tree by incrementing the reference count on it */ dst->select.sel_info.hslab->span_lst = src->select.sel_info.hslab->span_lst; dst->select.sel_info.hslab->span_lst->count++; } /* end if */ else /* Copy the hyperslab span information */ - dst->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank); + dst->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank); } /* end if */ else dst->select.sel_info.hslab->span_lst = NULL; /* Copy the unlimited dimension info */ - dst_hslab->unlim_dim = src_hslab->unlim_dim; + dst_hslab->unlim_dim = src_hslab->unlim_dim; dst_hslab->num_elem_non_unlim = src_hslab->num_elem_non_unlim; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_valid @@ -3278,34 +3278,34 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) static htri_t H5S__hyper_is_valid(const H5S_t *space) { - const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - unsigned u; /* Counter */ - htri_t ret_value = TRUE; /* return value */ + const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ + unsigned u; /* Counter */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* Check for unlimited selection */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) HGOTO_DONE(FALSE) /* Check which set of low & high bounds we should be using */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; high_bounds = space->select.sel_info.hslab->diminfo.high_bounds; } /* end if */ else { - low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; + low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; } /* end else */ /* Check each dimension */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Bounds check the selected point + offset against the extent */ - if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) HGOTO_DONE(FALSE) - if((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u]) + if ((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u]) HGOTO_DONE(FALSE) } /* end for */ @@ -3313,7 +3313,6 @@ H5S__hyper_is_valid(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks_helper @@ -3334,10 +3333,9 @@ H5S__hyper_is_valid(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, uint64_t op_gen) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3345,31 +3343,31 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, HDassert(spans); /* Check if the span tree was already counted */ - if(spans->op_info[op_info_i].op_gen == op_gen) + if (spans->op_info[op_info_i].op_gen == op_gen) /* Just return the # of blocks in the already counted span tree */ ret_value = spans->op_info[op_info_i].u.nblocks; - else { /* Count the number of elements in the span tree */ - H5S_hyper_span_t *span; /* Hyperslab span */ + else { /* Count the number of elements in the span tree */ + H5S_hyper_span_t *span; /* Hyperslab span */ span = spans->head; - if(span->down) { - while(span) { + if (span->down) { + while (span) { /* If there are down spans, add the total down span blocks */ ret_value += H5S__hyper_span_nblocks_helper(span->down, op_info_i, op_gen); /* Advance to next span */ span = span->next; } /* end while */ - } /* end if */ + } /* end if */ else { - while(span) { + while (span) { /* If there are no down spans, just count the block in this span */ ret_value++; /* Advance to next span */ span = span->next; } /* end while */ - } /* end else */ + } /* end else */ /* Set the operation generation for this span tree, to avoid re-computing */ spans->op_info[op_info_i].op_gen = op_gen; @@ -3381,7 +3379,6 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks @@ -3402,13 +3399,13 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Count the number of elements in the span tree */ - if(spans != NULL) { - uint64_t op_gen; /* Operation generation value */ + if (spans != NULL) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -3422,7 +3419,6 @@ H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_nblocks @@ -3444,7 +3440,7 @@ H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) static hsize_t H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -3453,13 +3449,13 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned u; /* Local index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned u; /* Local index variable */ /* Check each dimension */ - for(ret_value = 1, u = 0; u < space->extent.rank; u++) - ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count : - space->select.sel_info.hslab->diminfo.opt[u].count); + for (ret_value = 1, u = 0; u < space->extent.rank; u++) + ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count + : space->select.sel_info.hslab->diminfo.opt[u].count); } /* end if */ else ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); @@ -3467,7 +3463,6 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_nblocks @@ -3488,19 +3483,20 @@ 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 */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(space->select.sel_info.hslab->unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get number of blocks for unlimited selection") + if (space->select.sel_info.hslab->unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot get number of blocks for unlimited selection") ret_value = (hssize_t)H5S__get_select_hyper_nblocks(space, TRUE); @@ -3508,7 +3504,6 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_nblocks() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_enc_size_real @@ -3530,19 +3525,20 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) static uint8_t H5S__hyper_get_enc_size_real(hsize_t max_size) { - uint8_t ret_value; + uint8_t ret_value = H5S_SELECT_INFO_ENC_SIZE_2; FUNC_ENTER_STATIC_NOERR - if(max_size > H5S_UINT32_MAX) + if (max_size > H5S_UINT32_MAX) ret_value = H5S_SELECT_INFO_ENC_SIZE_8; - else + else if (max_size > H5S_UINT16_MAX) ret_value = H5S_SELECT_INFO_ENC_SIZE_4; + else + ret_value = H5S_SELECT_INFO_ENC_SIZE_2; FUNC_LEAVE_NOAPI(ret_value) } /* H5S__hyper_get_enc_size_real() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_version_enc_size @@ -3563,6 +3559,15 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) (1) the file format setting in fapl (2) whether the number of blocks or selection high bounds exceeds H5S_UINT32_MAX or not + Determine the encoded size based on version: + For version 3, the encoded size is determined according to: + (a) regular hyperslab + (1) The maximum needed to store start/stride/count/block + (2) Special handling for count/block: need to provide room for H5S_UNLIMITED + (b) irregular hyperslab + The maximum size needed to store: + (1) the number of blocks + (2) the selection high bounds GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -3571,69 +3576,74 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) static herr_t H5S__hyper_get_version_enc_size(const 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 */ - hbool_t count_up_version = FALSE; /* Whether number of blocks exceed (2^32 - 1) */ - hbool_t bound_up_version = FALSE; /* Whether high bounds exceed (2^32 - 1) */ - H5F_libver_t low_bound; /* The 'low' bound of library format versions */ - H5F_libver_t high_bound; /* The 'high' bound of library format versions */ - unsigned u; /* Local index veriable */ - uint32_t tmp_version; /* Temporay version */ - herr_t ret_value = SUCCEED; /* return value */ + hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ + hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ + hbool_t count_up_version = FALSE; /* Whether number of blocks exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + 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 */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get bounding box for the selection */ HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ /* Get bounding box for the selection */ - if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */ - if(block_count > H5S_UINT32_MAX) + if (block_count > H5S_UINT32_MAX) count_up_version = TRUE; else { - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > H5S_UINT32_MAX) + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > H5S_UINT32_MAX) { bound_up_version = TRUE; - } + break; + } /* end if */ + } /* end else */ /* Get the file's low_bound and high_bound */ - if(H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + if (H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") - /* Use version 2 for unlimited selection */ - if(space->select.sel_info.hslab->unlim_dim >= 0) - tmp_version = H5S_HYPER_VERSION_2; - else if(H5S__hyper_is_regular(space)) { + /* Determine regular hyperslab */ + is_regular = H5S__hyper_is_regular(space); - /* If exceed (2^32 -1) */ - if(count_up_version || bound_up_version) - tmp_version = H5S_HYPER_VERSION_2; + if (low_bound >= H5F_LIBVER_V112 || space->select.sel_info.hslab->unlim_dim >= 0) + tmp_version = MAX(H5S_HYPER_VERSION_2, H5O_sds_hyper_ver_bounds[low_bound]); + else { + if (count_up_version || bound_up_version) + tmp_version = is_regular ? H5S_HYPER_VERSION_2 : H5S_HYPER_VERSION_3; else - /* block_count < 4: version 1 */ - /* block_count >= 4: determined by low bound */ - tmp_version = (block_count < 4) ? H5S_HYPER_VERSION_1 : H5O_sds_hyper_ver_bounds[low_bound]; - - } else { - /* Fail for irregular hyperslab if exceeds 32 bits */ - if(count_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32") - else if(bound_up_version) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32") - tmp_version = H5S_HYPER_VERSION_1; - } + tmp_version = + (is_regular && block_count >= 4) ? H5O_sds_hyper_ver_bounds[low_bound] : H5S_HYPER_VERSION_1; + } /* end else */ /* Version bounds check */ - if(tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds") + if (tmp_version > H5O_sds_hyper_ver_bounds[high_bound]) { + /* Fail for irregular hyperslab if exceeds 32 bits */ + if (count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The number of blocks in hyperslab selection exceeds 2^32") + else if (bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The end of bounding box in hyperslab selection exceeds 2^32") + else + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "Dataspace hyperslab selection version out of bounds") + } /* end if */ + /* Set the message version */ *version = tmp_version; /* Determine the encoded size based on version */ - switch(tmp_version) { + switch (tmp_version) { case H5S_HYPER_VERSION_1: *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; break; @@ -3642,6 +3652,52 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ *enc_size = H5S_SELECT_INFO_ENC_SIZE_8; break; + case H5S_HYPER_VERSION_3: + if (is_regular) { + uint8_t enc1, enc2; + hsize_t max1 = 0; + hsize_t max2 = 0; + + /* Find max for count[] and block[] */ + for (u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo.opt[u].count != H5S_UNLIMITED && + space->select.sel_info.hslab->diminfo.opt[u].count > max1) + max1 = space->select.sel_info.hslab->diminfo.opt[u].count; + if (space->select.sel_info.hslab->diminfo.opt[u].block != H5S_UNLIMITED && + space->select.sel_info.hslab->diminfo.opt[u].block > max1) + max1 = space->select.sel_info.hslab->diminfo.opt[u].block; + } /* end for */ + + /* +1 to provide room for H5S_UNLIMITED */ + enc1 = H5S__hyper_get_enc_size_real(++max1); + + /* Find max for start[] and stride[] */ + for (u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo.opt[u].start > max2) + max2 = space->select.sel_info.hslab->diminfo.opt[u].start; + if (space->select.sel_info.hslab->diminfo.opt[u].stride > max2) + max2 = space->select.sel_info.hslab->diminfo.opt[u].stride; + } /* end for */ + + /* Determine the encoding size */ + enc2 = H5S__hyper_get_enc_size_real(max2); + + *enc_size = (uint8_t)MAX(enc1, enc2); + } /* end if */ + else { + hsize_t max_size = block_count; + HDassert(space->select.sel_info.hslab->unlim_dim < 0); + + /* Find max for block_count and bounds_end[] */ + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > max_size) + max_size = bounds_end[u]; + + /* Determine the encoding size */ + *enc_size = H5S__hyper_get_enc_size_real(max_size); + } /* end else */ + break; + default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown hyperslab selection version") break; @@ -3651,7 +3707,6 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ FUNC_LEAVE_NOAPI(ret_value) } /* H5S__hyper_get_version_enc_size() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serial_size @@ -3674,24 +3729,48 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ static hssize_t H5S__hyper_serial_size(const H5S_t *space) { - hsize_t block_count = 0; /* block counter for regular hyperslabs */ - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of hyperslab selection info */ - hssize_t ret_value = -1; /* return value */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of hyperslab selection info */ + hssize_t ret_value = -1; /* return value */ FUNC_ENTER_STATIC HDassert(space); /* Determine the number of blocks */ - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ - if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + if (H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") - if(version == H5S_HYPER_VERSION_2) { + if (version == H5S_HYPER_VERSION_3) { + /* Version 3: regular */ + /* Size required is always: + * + + + + * + + + * (4 (start/stride/count/block) * * ) = + * 14 + (4 * enc_size * rank) bytes + */ + if (H5S__hyper_is_regular(space)) + ret_value = (hssize_t)14 + ((hssize_t)4 * (hssize_t)enc_size * (hssize_t)space->extent.rank); + else { + /* Version 3: irregular */ + /* Size required is always: + * + + + + * + + + * < # of blocks (depend on enc_size) > + + * (2 (starting/ending offset) * * * <# of blocks) = + * = 14 bytes + enc_size (block_count) + (2 * enc_size * rank * block_count) bytes + */ + ret_value = 14 + enc_size; + H5_CHECK_OVERFLOW(((unsigned)2 * enc_size * space->extent.rank * block_count), hsize_t, hssize_t); + ret_value += (hssize_t)((unsigned)2 * enc_size * space->extent.rank * block_count); + } /* end else */ + } /* end if */ + else if (version == H5S_HYPER_VERSION_2) { /* Version 2 */ /* Size required is always: * + + + @@ -3721,7 +3800,6 @@ H5S__hyper_serial_size(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize_helper @@ -3746,11 +3824,11 @@ H5S__hyper_serial_size(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, - hsize_t *start, hsize_t *end, hsize_t rank, uint8_t enc_size, uint8_t **p) +H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, hsize_t *start, hsize_t *end, hsize_t rank, + 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 */ + H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + uint8_t * pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -3763,31 +3841,47 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, /* Walk through the list of spans, recursing or outputting them */ curr = spans->head; - while(curr != NULL) { + while (curr != NULL) { /* Recurse if this node has down spans */ - if(curr->down != NULL) { + if (curr->down != NULL) { /* Add the starting and ending points for this span to the list */ start[rank] = curr->low; - end[rank] = curr->high; + end[rank] = curr->high; /* Recurse down to the next dimension */ H5S__hyper_serialize_helper(curr->down, start, end, rank + 1, enc_size, &pp); } /* end if */ else { - hsize_t u; /* Index variable */ + hsize_t u; /* Index variable */ /* Encode all the previous dimensions starting & ending points */ - switch(enc_size) { + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + /* Encode previous starting points */ + for (u = 0; u < rank; u++) + UINT16ENCODE(pp, (uint16_t)start[u]); + + /* Encode starting point for this span */ + UINT16ENCODE(pp, (uint16_t)curr->low); + + /* Encode previous ending points */ + for (u = 0; u < rank; u++) + UINT16ENCODE(pp, (uint16_t)end[u]); + + /* Encode starting point for this span */ + UINT16ENCODE(pp, (uint16_t)curr->high); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: /* Encode previous starting points */ - for(u=0; ulow); - /* Encode previous ending points */ - for(u=0; ulow); /* Encode previous ending points */ - for(u=0; unext; @@ -3826,7 +3920,6 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_serialize_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize @@ -3851,24 +3944,24 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, static herr_t H5S__hyper_serialize(const 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 */ - uint32_t len = 0; /* number of bytes used */ - uint32_t version; /* Version number */ - uint8_t flags = 0; /* Flags for message */ - hsize_t block_count = 0; /* block counter for regular hyperslabs */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Rank of the dataspace */ - unsigned u; /* Local counting variable */ - hbool_t complete = FALSE; /* Whether we are done with the iteration */ - hbool_t is_regular; /* Whether selection is regular */ - uint8_t enc_size; /* Encoded size */ - herr_t ret_value = SUCCEED; /* return value */ + 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 */ + uint32_t len = 0; /* number of bytes used */ + uint32_t version; /* Version number */ + uint8_t flags = 0; /* Flags for message */ + hsize_t block_count = 0; /* block counter for regular hyperslabs */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + unsigned u; /* Local counting variable */ + hbool_t complete = FALSE; /* Whether we are done with the iteration */ + hbool_t is_regular; /* Whether selection is regular */ + uint8_t enc_size; /* Encoded size */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -3879,66 +3972,105 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Set some convienence values */ - ndims = space->extent.rank; + ndims = space->extent.rank; diminfo = space->select.sel_info.hslab->diminfo.opt; /* Calculate the # of blocks */ - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + if (space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ - if(H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) + if (H5S__hyper_get_version_enc_size(space, block_count, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version & enc_size") - is_regular = H5S__hyper_is_regular(space); - if(is_regular && version == H5S_HYPER_VERSION_2) + is_regular = H5S__hyper_is_regular(space); + if (is_regular && (version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3)) flags |= H5S_HYPER_REGULAR; /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, version); /* Store the version number */ + UINT32ENCODE(pp, version); /* Store the version number */ - if(version == H5S_HYPER_VERSION_2) + if (version >= 3) { *(pp)++ = flags; /* Store the flags */ - else - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* keep the pointer to the length location for later */ - pp += 4; /* skip over space for length */ + *(pp)++ = enc_size; /* Store size of offset info */ + } /* end if */ + else { + if (version == 2) + *(pp)++ = flags; /* Store the flags */ + else + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* keep the pointer to the length location for later */ + pp += 4; /* skip over space for length */ - len += 4; /* ndims */ + len += 4; /* ndims */ + } /* end else */ /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)ndims); - if(is_regular) { - if(version == H5S_HYPER_VERSION_2) { + if (is_regular) { + if (version >= H5S_HYPER_VERSION_2) { HDassert(H5S_UNLIMITED == HSIZE_UNDEF); /* Iterate over dimensions */ /* Encode start/stride/block/count */ - switch(enc_size) { + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_HYPER_VERSION_3); + for (u = 0; u < space->extent.rank; u++) { + UINT16ENCODE(pp, diminfo[u].start); + UINT16ENCODE(pp, diminfo[u].stride); + if (diminfo[u].count == H5S_UNLIMITED) + UINT16ENCODE(pp, H5S_UINT16_MAX) + else + UINT16ENCODE(pp, diminfo[u].count) + if (diminfo[u].block == H5S_UNLIMITED) + UINT16ENCODE(pp, H5S_UINT16_MAX) + else + UINT16ENCODE(pp, diminfo[u].block) + } /* end for */ + break; + + case H5S_SELECT_INFO_ENC_SIZE_4: + HDassert(version == H5S_HYPER_VERSION_3); + for (u = 0; u < space->extent.rank; u++) { + UINT32ENCODE(pp, diminfo[u].start); + UINT32ENCODE(pp, diminfo[u].stride); + if (diminfo[u].count == H5S_UNLIMITED) + UINT32ENCODE(pp, H5S_UINT32_MAX) + else + UINT32ENCODE(pp, diminfo[u].count) + if (diminfo[u].block == H5S_UNLIMITED) + UINT32ENCODE(pp, H5S_UINT32_MAX) + else + UINT32ENCODE(pp, diminfo[u].block) + } /* end for */ + break; + case H5S_SELECT_INFO_ENC_SIZE_8: - HDassert(version == H5S_HYPER_VERSION_2); - for(u = 0; u < space->extent.rank; u++) { + HDassert(version == H5S_HYPER_VERSION_2 || version == H5S_HYPER_VERSION_3); + for (u = 0; u < space->extent.rank; u++) { UINT64ENCODE(pp, diminfo[u].start); UINT64ENCODE(pp, diminfo[u].stride); - if(diminfo[u].count == H5S_UNLIMITED) + if (diminfo[u].count == H5S_UNLIMITED) UINT64ENCODE(pp, H5S_UINT64_MAX) else UINT64ENCODE(pp, diminfo[u].count) - if(diminfo[u].block == H5S_UNLIMITED) + if (diminfo[u].block == H5S_UNLIMITED) UINT64ENCODE(pp, H5S_UINT64_MAX) else UINT64ENCODE(pp, diminfo[u].block) } /* end for */ - if(version == H5S_HYPER_VERSION_2) + if (version == H5S_HYPER_VERSION_2) len += (4 * space->extent.rank * 8); break; default: - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unknown offset info size for hyperslab") break; } /* end switch */ - } /* end if */ + } /* end if */ else { HDassert(version == H5S_HYPER_VERSION_1); @@ -3953,52 +4085,52 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) /* Now serialize the information for the regular hyperslab */ /* Build the tables of count sizes as well as the initial offset */ - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { tmp_count[u] = diminfo[u].count; - offset[u] = diminfo[u].start; + offset[u] = diminfo[u].start; } /* end for */ /* Go iterate over the hyperslabs */ - while(complete == FALSE) { + while (complete == FALSE) { /* Iterate over the blocks in the fastest dimension */ - while(tmp_count[fast_dim] > 0) { + while (tmp_count[fast_dim] > 0) { /* Add 8 bytes times the rank for each hyperslab selected */ len += 8 * ndims; /* Encode hyperslab starting location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) UINT32ENCODE(pp, (uint32_t)offset[u]); /* Encode hyperslab ending location */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) UINT32ENCODE(pp, (uint32_t)(offset[u] + (diminfo[u].block - 1))); /* Move the offset to the next sequence to start */ - offset[fast_dim]+=diminfo[fast_dim].stride; + offset[fast_dim] += diminfo[fast_dim].stride; /* Decrement the block count */ tmp_count[fast_dim]--; } /* end while */ /* Work on other dimensions if necessary */ - if(fast_dim > 0) { - int temp_dim; /* Temporary rank holder */ + if (fast_dim > 0) { + int temp_dim; /* Temporary rank holder */ /* Reset the block counts */ tmp_count[fast_dim] = diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim = (int)fast_dim - 1; - while(temp_dim >= 0 && complete == FALSE) { + while (temp_dim >= 0 && complete == FALSE) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ - if(tmp_count[temp_dim] > 0) + if (tmp_count[temp_dim] > 0) break; /* Check for getting out of iterator */ - if(temp_dim == 0) + if (temp_dim == 0) complete = TRUE; /* Reset the block count in this dimension */ @@ -4007,31 +4139,42 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ else - break; /* Break out now, for 1-D selections */ + break; /* Break out now, for 1-D selections */ /* Re-compute offset array */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); } /* end while */ - } /* end else */ - } /* end if */ - else { /* irregular */ + } /* end else */ + } /* end if */ + else { /* irregular */ /* Encode number of hyperslabs */ - switch(enc_size) { + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_HYPER_VERSION_3); + H5_CHECK_OVERFLOW(block_count, hsize_t, uint16_t); + UINT16ENCODE(pp, (uint16_t)block_count); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: - HDassert(version == H5S_HYPER_VERSION_1); + HDassert(version == H5S_HYPER_VERSION_1 || version == H5S_HYPER_VERSION_3); H5_CHECK_OVERFLOW(block_count, hsize_t, uint32_t); UINT32ENCODE(pp, (uint32_t)block_count); break; + case H5S_SELECT_INFO_ENC_SIZE_8: + HDassert(version == H5S_HYPER_VERSION_3); + UINT64ENCODE(pp, block_count); + break; + default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") break; } /* end switch */ - if(version == H5S_HYPER_VERSION_1) { + if (version == H5S_HYPER_VERSION_1) { len += 4; /* block_count */ /* Add 8 bytes times the rank for each hyperslab selected */ @@ -4039,11 +4182,13 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) len += (uint32_t)(8 * ndims * block_count); } /* end if */ - H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, &pp); + H5S__hyper_serialize_helper(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, enc_size, + &pp); } /* end else */ /* Encode length */ - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + if (version <= H5S_HYPER_VERSION_2) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; @@ -4052,7 +4197,6 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_deserialize @@ -4078,18 +4222,18 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) { - 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]; /* 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 */ FUNC_ENTER_STATIC @@ -4103,8 +4247,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -4113,81 +4257,102 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - if(version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) + if (version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for hyperslab selection") - if(version >= (uint32_t)H5S_HYPER_VERSION_2) { + if (version >= (uint32_t)H5S_HYPER_VERSION_2) { /* Decode flags */ flags = *(pp)++; - /* Skip over the remainder of the header */ - pp += 4; - enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + if (version >= (uint32_t)H5S_HYPER_VERSION_3) + /* decode size of offset info */ + enc_size = *(pp)++; + else { + /* Skip over the remainder of the header */ + pp += 4; + enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + } /* end else */ - /* Check for unknown flags */ - if(flags & ~H5S_SELECT_FLAG_BITS) + /* Check for unknown flags */ + if (flags & ~H5S_SELECT_FLAG_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection") } else { /* Skip over the remainder of the header */ pp += 8; enc_size = H5S_SELECT_INFO_ENC_SIZE_4; - } /* end else */ + } /* end else */ - /* Check encoded */ - if(enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + /* Check encoded */ + if (enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ - UINT32DECODE(pp,rank); + UINT32DECODE(pp, rank); - if(!*space) { + if (!*space) { /* Patch the rank of the allocated dataspace */ HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + if (H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ 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") + if (rank != tmp_space->extent.rank) + 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 */ - hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ + if (flags & H5S_HYPER_REGULAR) { + hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */ + hsize_t count[H5S_MAX_RANK]; /* Hyperslab count information */ /* Sanity checks */ HDassert(H5S_UNLIMITED == HSIZE_UNDEF); HDassert(version >= H5S_HYPER_VERSION_2); - /* Decode start/stride/block/count */ - switch(enc_size) { + /* Decode start/stride/block/count */ + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + for (u = 0; u < tmp_space->extent.rank; u++) { + UINT16DECODE(pp, start[u]); + UINT16DECODE(pp, stride[u]); + + UINT16DECODE(pp, count[u]); + if ((uint16_t)count[u] == H5S_UINT16_MAX) + count[u] = H5S_UNLIMITED; + + UINT16DECODE(pp, block[u]); + if ((uint16_t)block[u] == H5S_UINT16_MAX) + block[u] = H5S_UNLIMITED; + } /* end for */ + break; + case H5S_SELECT_INFO_ENC_SIZE_4: - for(u = 0; u < tmp_space->extent.rank; u++) { + for (u = 0; u < tmp_space->extent.rank; u++) { UINT32DECODE(pp, start[u]); UINT32DECODE(pp, stride[u]); UINT32DECODE(pp, count[u]); - if((uint32_t)count[u] == H5S_UINT32_MAX) + if ((uint32_t)count[u] == H5S_UINT32_MAX) count[u] = H5S_UNLIMITED; UINT32DECODE(pp, block[u]); - if((uint32_t)block[u] == H5S_UINT32_MAX) + if ((uint32_t)block[u] == H5S_UINT32_MAX) block[u] = H5S_UNLIMITED; } /* end for */ break; case H5S_SELECT_INFO_ENC_SIZE_8: - for(u = 0; u < tmp_space->extent.rank; u++) { + for (u = 0; u < tmp_space->extent.rank; u++) { UINT64DECODE(pp, start[u]); UINT64DECODE(pp, stride[u]); UINT64DECODE(pp, count[u]); - if((uint64_t)count[u] == H5S_UINT64_MAX) + if ((uint64_t)count[u] == H5S_UINT64_MAX) count[u] = H5S_UNLIMITED; UINT64DECODE(pp, block[u]); - if((uint64_t)block[u] == H5S_UINT64_MAX) + if ((uint64_t)block[u] == H5S_UINT64_MAX) block[u] = H5S_UNLIMITED; } /* end for */ break; @@ -4198,21 +4363,25 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) } /* end switch */ /* Select the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) + if ((ret_value = H5S_select_hyperslab(tmp_space, H5S_SELECT_SET, start, stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end if */ else { - 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 */ - size_t num_elem; /* Number of elements in selection */ - unsigned v; /* Local counting variable */ + 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 */ + size_t num_elem; /* Number of elements in selection */ + unsigned v; /* Local counting variable */ /* Decode the number of blocks */ - switch(enc_size) { + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + UINT16DECODE(pp, num_elem); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: UINT32DECODE(pp, num_elem); break; @@ -4230,55 +4399,63 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) stride = count = H5S_hyper_ones_g; /* Retrieve the coordinates from the buffer */ - for(u = 0; u < num_elem; u++) { + for (u = 0; u < num_elem; u++) { /* Decode the starting and ending points */ - switch(enc_size) { + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + for (tstart = start, v = 0; v < rank; v++, tstart++) + UINT16DECODE(pp, *tstart); + for (tend = end, v = 0; v < rank; v++, tend++) + UINT16DECODE(pp, *tend); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: - for(tstart = start,v = 0; v < rank; v++, tstart++) + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT32DECODE(pp, *tstart); - for(tend = end, v = 0; v < rank; v++, tend++) + for (tend = end, v = 0; v < rank; v++, tend++) UINT32DECODE(pp, *tend); break; case H5S_SELECT_INFO_ENC_SIZE_8: - for(tstart = start, v = 0; v < rank; v++, tstart++) + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT64DECODE(pp, *tstart); - for(tend = end, v = 0; v < rank; v++, tend++) + for (tend = end, v = 0; v < rank; v++, tend++) UINT64DECODE(pp, *tend); break; default: - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown offset info size for hyperslab") + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unknown offset info size for hyperslab") break; } /* end switch */ /* Change the ending points into blocks */ - for(tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++) + for (tblock = block, tstart = start, tend = end, v = 0; v < rank; v++, tstart++, tend++, tblock++) *tblock = (*tend - *tstart) + 1; /* Select or add the hyperslab to the current selection */ - if((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, stride, count, block)) < 0) + if ((ret_value = H5S_select_hyperslab(tmp_space, (u == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, + stride, count, block)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't change selection") } /* end for */ - } /* end else */ + } /* end else */ /* Update decoding pointer */ *p = pp; /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_span_blocklist @@ -4313,12 +4490,11 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], - hsize_t end[], hsize_t rank, hsize_t *startblock, hsize_t *numblocks, - hsize_t **buf) +H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], hsize_t end[], hsize_t rank, + hsize_t *startblock, hsize_t *numblocks, hsize_t **buf) { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - herr_t ret_value = SUCCEED; /* return value */ + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -4333,20 +4509,20 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], /* Walk through the list of spans, recursing or outputting them */ curr = spans->head; - while(curr != NULL && *numblocks > 0) { + while (curr != NULL && *numblocks > 0) { /* Recurse if this node has down spans */ - if(curr->down != NULL) { + if (curr->down != NULL) { /* Add the starting and ending points for this span to the list */ start[rank] = curr->low; - end[rank] = curr->high; + end[rank] = curr->high; /* Recurse down to the next dimension */ - if(H5S__hyper_span_blocklist(curr->down, start, end, (rank + 1), startblock, numblocks, buf) < 0) + if (H5S__hyper_span_blocklist(curr->down, start, end, (rank + 1), startblock, numblocks, buf) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release hyperslab spans") } /* end if */ else { /* Skip this block if we haven't skipped all the startblocks yet */ - if(*startblock > 0) { + if (*startblock > 0) { /* Decrement the starting block */ (*startblock)--; } /* end if */ @@ -4373,7 +4549,7 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], /* Decrement the number of blocks processed */ (*numblocks)--; } /* end else */ - } /* end else */ + } /* end else */ /* Advance to next node */ curr = curr->next; @@ -4383,7 +4559,6 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_blocklist @@ -4415,8 +4590,7 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, - hsize_t numblocks, hsize_t *buf) +H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks, hsize_t *buf) { herr_t ret_value = SUCCEED; /* Return value */ @@ -4429,26 +4603,26 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * to be impossible. */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) H5S__hyper_rebuild(space); /* Check for a "regular" hyperslab selection */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - 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 end[H5S_MAX_RANK]; /* End of elements in dataspace */ - unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ - unsigned ndims; /* Rank of the dataspace */ - hbool_t done; /* Whether we are done with the iteration */ - unsigned u; /* Counter */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + 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 end[H5S_MAX_RANK]; /* End of elements in dataspace */ + unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ + unsigned ndims; /* Rank of the dataspace */ + hbool_t done; /* Whether we are done with the iteration */ + unsigned u; /* Counter */ /* Set some convienence values */ - ndims = space->extent.rank; + ndims = space->extent.rank; fast_dim = ndims - 1; /* Check which set of dimension information to use */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) /* * There is an unlimited dimension so we must use diminfo.opt as * it has been "clipped" to the current extent. @@ -4463,21 +4637,21 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, diminfo = space->select.sel_info.hslab->diminfo.app; /* Build the tables of count sizes as well as the initial offset */ - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { tmp_count[u] = diminfo[u].count; - offset[u] = diminfo[u].start; - end[u] = diminfo[u].start + (diminfo[u].block - 1); + offset[u] = diminfo[u].start; + end[u] = diminfo[u].start + (diminfo[u].block - 1); } /* end for */ /* We're not done with the iteration */ done = FALSE; /* Go iterate over the hyperslabs */ - while(!done && numblocks > 0) { + while (!done && numblocks > 0) { /* Skip over initial blocks */ - if(startblock > 0) { + if (startblock > 0) { /* Skip all blocks in row */ - if(startblock >= tmp_count[fast_dim]) { + if (startblock >= tmp_count[fast_dim]) { startblock -= tmp_count[fast_dim]; tmp_count[fast_dim] = 0; } /* end if */ @@ -4492,10 +4666,10 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, /* Done with starting blocks */ startblock = 0; } /* end else */ - } /* end if */ + } /* end if */ /* Iterate over the blocks in the fastest dimension */ - while(tmp_count[fast_dim] > 0 && numblocks > 0) { + while (tmp_count[fast_dim] > 0 && numblocks > 0) { /* Sanity check */ HDassert(startblock == 0); @@ -4519,53 +4693,53 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, } /* end while */ /* Work on other dimensions if necessary */ - if(fast_dim > 0 && numblocks > 0) { - int temp_dim; /* Temporary rank holder */ + if (fast_dim > 0 && numblocks > 0) { + int temp_dim; /* Temporary rank holder */ /* Reset the block counts */ tmp_count[fast_dim] = diminfo[fast_dim].count; /* Bubble up the decrement to the slower changing dimensions */ temp_dim = (int)(fast_dim - 1); - while(temp_dim >= 0 && !done) { + while (temp_dim >= 0 && !done) { /* Decrement the block count */ tmp_count[temp_dim]--; /* Check if we have more blocks left */ - if(tmp_count[temp_dim] > 0) + if (tmp_count[temp_dim] > 0) break; /* Reset the block count in this dimension */ tmp_count[temp_dim] = diminfo[temp_dim].count; /* Check for getting out of iterator */ - if(temp_dim == 0) + if (temp_dim == 0) done = TRUE; /* Wrapped a dimension, go up to next dimension */ temp_dim--; } /* end while */ - } /* end if */ + } /* end if */ /* Re-compute offset & end arrays */ - if(!done) - for(u = 0; u < ndims; u++) { + if (!done) + for (u = 0; u < ndims; u++) { offset[u] = diminfo[u].start + diminfo[u].stride * (diminfo[u].count - tmp_count[u]); - end[u] = offset[u] + (diminfo[u].block - 1); + end[u] = offset[u] + (diminfo[u].block - 1); } /* end for */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { - hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ - hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ + hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ + hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ - ret_value = H5S__hyper_span_blocklist(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, &startblock, &numblocks, &buf); + ret_value = H5S__hyper_span_blocklist(space->select.sel_info.hslab->span_lst, start, end, (hsize_t)0, + &startblock, &numblocks, &buf); } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_blocklist @@ -4597,36 +4771,35 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, - hsize_t numblocks, hsize_t buf[/*numblocks*/]) +H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, + hsize_t buf[/*numblocks*/]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ihh*[a2]h", spaceid, startblock, numblocks, buf); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space)!=H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot get blocklist for unlimited selection") /* Go get the correct number of blocks */ - if(numblocks > 0) + if (numblocks > 0) ret_value = H5S__get_select_hyper_blocklist(space, startblock, numblocks, buf); else - ret_value = SUCCEED; /* Successfully got 0 blocks... */ + ret_value = SUCCEED; /* Successfully got 0 blocks... */ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_blocklist() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_bounds @@ -4656,8 +4829,8 @@ H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ - herr_t ret_value = SUCCEED; /* Return value */ + const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4667,36 +4840,36 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(end); /* Check which set of low & high bounds we should be using */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + low_bounds = space->select.sel_info.hslab->diminfo.low_bounds; high_bounds = space->select.sel_info.hslab->diminfo.high_bounds; } /* end if */ else { - low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; + low_bounds = space->select.sel_info.hslab->span_lst->low_bounds; high_bounds = space->select.sel_info.hslab->span_lst->high_bounds; } /* end else */ /* Check for offset set */ - if(space->select.offset_changed) { - unsigned u; /* Local index variable */ + if (space->select.offset_changed) { + unsigned u; /* Local index variable */ /* Loop over dimensions */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check */ HDassert(low_bounds[u] <= high_bounds[u]); /* Check for offset moving selection negative */ - if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Set the low & high bounds in this dimension */ start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]); - if((int)u == space->select.sel_info.hslab->unlim_dim) + if ((int)u == space->select.sel_info.hslab->unlim_dim) end[u] = H5S_UNLIMITED; else end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]); } /* end for */ - } /* end if */ + } /* end if */ else { /* Offset vector is still zeros, just copy low & high bounds */ H5MM_memcpy(start, low_bounds, sizeof(hsize_t) * space->extent.rank); @@ -4707,7 +4880,6 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_offset @@ -4731,38 +4903,40 @@ 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) { - const hssize_t *sel_offset; /* Pointer to the selection's offset */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + const hssize_t *sel_offset; /* Pointer to the selection's offset */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - HDassert(space && space->extent.rank>0); + HDassert(space && space->extent.rank > 0); HDassert(offset); /* Start at linear offset 0 */ *offset = 0; /* Set up pointers to arrays of values */ - rank = space->extent.rank; + rank = space->extent.rank; sel_offset = space->select.offset; - dim_size = space->extent.size; + dim_size = space->extent.size; /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Local alias for diminfo */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* Local alias for diminfo */ /* Loop through starting coordinates, calculating the linear offset */ accum = 1; - for(i = (int)(rank - 1); i >= 0; i--) { - hssize_t hyp_offset = (hssize_t)diminfo[i].start + sel_offset[i]; /* Hyperslab's offset in this dimension */ + for (i = (int)(rank - 1); i >= 0; i--) { + hssize_t hyp_offset = + (hssize_t)diminfo[i].start + sel_offset[i]; /* Hyperslab's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) + if (hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the hyperslab's offset in this dimension to the total linear offset */ @@ -4771,14 +4945,14 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) /* Increase the accumulator */ accum *= dim_size[i]; } /* end for */ - } /* end if */ + } /* end if */ else { - const H5S_hyper_span_t *span; /* Hyperslab span node */ - hsize_t dim_accum[H5S_MAX_RANK]; /* Accumulators, for each dimension */ + const H5S_hyper_span_t *span; /* Hyperslab span node */ + hsize_t dim_accum[H5S_MAX_RANK]; /* Accumulators, for each dimension */ /* Calculate the accumulator for each dimension */ accum = 1; - for(i = (int)(rank - 1); i >= 0; i--) { + for (i = (int)(rank - 1); i >= 0; i--) { /* Set the accumulator for this dimension */ dim_accum[i] = accum; @@ -4791,18 +4965,19 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) /* Work down the spans, computing the linear offset */ i = 0; - while(span) { - hssize_t hyp_offset = (hssize_t)span->low + sel_offset[i]; /* Hyperslab's offset in this dimension */ + while (span) { + hssize_t hyp_offset = + (hssize_t)span->low + sel_offset[i]; /* Hyperslab's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) + if (hyp_offset < 0 || (hsize_t)hyp_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the hyperslab's offset in this dimension to the total linear offset */ *offset += (hsize_t)(hyp_offset * (hssize_t)dim_accum[i]); /* Advance to first span in "down" dimension */ - if(span->down) { + if (span->down) { HDassert(span->down->head); span = span->down->head; } /* end if */ @@ -4810,13 +4985,12 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset) span = NULL; i++; } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_unlim_dim @@ -4843,7 +5017,6 @@ H5S__hyper_unlim_dim(const H5S_t *space) FUNC_LEAVE_NOAPI(space->select.sel_info.hslab->unlim_dim); } /* end H5S__hyper_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_num_elem_non_unlim @@ -4876,7 +5049,7 @@ H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) HDassert(num_elem_non_unlim); /* Get number of elements in the non-unlimited dimensions */ - if(space->select.sel_info.hslab->unlim_dim >= 0) + if (space->select.sel_info.hslab->unlim_dim >= 0) *num_elem_non_unlim = space->select.sel_info.hslab->num_elem_non_unlim; else HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "selection has no unlimited dimension") @@ -4885,7 +5058,6 @@ H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_num_elem_non_unlim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_contiguous @@ -4907,10 +5079,10 @@ H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) static H5_ATTR_PURE htri_t H5S__hyper_is_contiguous(const H5S_t *space) { - hbool_t small_contiguous, /* Flag for small contiguous block */ - large_contiguous; /* Flag for large contiguous block */ - unsigned u; /* index variable */ - htri_t ret_value = FALSE; /* Return value */ + hbool_t small_contiguous, /* Flag for small contiguous block */ + large_contiguous; /* Flag for large contiguous block */ + unsigned u; /* index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -4918,8 +5090,9 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->diminfo.opt; /* local alias for diminfo */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* local alias for diminfo */ /* * For a regular hyperslab to be contiguous, it must have only one @@ -4935,43 +5108,43 @@ H5S__hyper_is_contiguous(const H5S_t *space) */ /* Initialize flags */ - large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ - small_contiguous = FALSE; /* assume false initially */ + 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 */ - for(u = 0; u < space->extent.rank; u++) { - if(diminfo[u].count > 1) { + for (u = 0; u < space->extent.rank; u++) { + if (diminfo[u].count > 1) { large_contiguous = FALSE; break; } /* end if */ - if(u > 0 && diminfo[u].block != space->extent.size[u]) { + if (u > 0 && diminfo[u].block != space->extent.size[u]) { large_contiguous = FALSE; break; } /* end if */ - } /* end for */ + } /* end for */ /* If we didn't find a large contiguous block, check for a small one */ - if(!large_contiguous) { + if (!large_contiguous) { small_contiguous = TRUE; - for(u = 0; u < space->extent.rank; u++) { - if(diminfo[u].count > 1) { + for (u = 0; u < space->extent.rank; u++) { + if (diminfo[u].count > 1) { small_contiguous = FALSE; break; } /* end if */ - if(u < (space->extent.rank - 1) && diminfo[u].block != 1) { + if (u < (space->extent.rank - 1) && diminfo[u].block != 1) { small_contiguous = FALSE; break; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ /* Indicate true if it's either a large or small contiguous block */ - if(large_contiguous || small_contiguous) + if (large_contiguous || small_contiguous) ret_value = TRUE; } /* end if */ else { - H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ - H5S_hyper_span_t *span; /* Hyperslab span node */ + H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ + H5S_hyper_span_t * span; /* Hyperslab span node */ /* * For a hyperslab to be contiguous, it must have only one block and @@ -4981,36 +5154,37 @@ H5S__hyper_is_contiguous(const H5S_t *space) * block size must be 1 in all but the fastest changing dimension. */ /* Initialize flags */ - large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ - small_contiguous = FALSE; /* assume false initially */ + large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ + small_contiguous = FALSE; /* assume false initially */ /* Get information for slowest changing information */ spans = space->select.sel_info.hslab->span_lst; - span = spans->head; + span = spans->head; /* If there are multiple spans in the slowest changing dimension, the selection isn't contiguous */ - if(span->next != NULL) + if (span->next != NULL) large_contiguous = FALSE; else { /* Now check the rest of the dimensions */ - if(span->down != NULL) { - u = 1; /* Current dimension working on */ + if (span->down != NULL) { + u = 1; /* Current dimension working on */ /* Get the span information for the next fastest dimension */ spans = span->down; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { + while (spans != NULL) { span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) { + if (span->next != NULL) { large_contiguous = FALSE; break; } /* end if */ else { - /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ - if(((span->high - span->low) + 1) != space->extent.size[u]) { + /* If this span doesn't cover the entire dimension, then this selection isn't + * contiguous */ + if (((span->high - span->low) + 1) != space->extent.size[u]) { large_contiguous = FALSE; break; } /* end if */ @@ -5021,34 +5195,35 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Increment dimension */ u++; } /* end else */ - } /* end else */ - } /* end while */ - } /* end if */ - } /* end else */ + } /* end else */ + } /* end while */ + } /* end if */ + } /* end else */ /* If we didn't find a large contiguous block, check for a small one */ - if(!large_contiguous) { + if (!large_contiguous) { small_contiguous = TRUE; /* Get information for slowest changing information */ spans = space->select.sel_info.hslab->span_lst; - span = spans->head; + span = spans->head; /* Current dimension working on */ u = 0; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { + while (spans != NULL) { span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) { + if (span->next != NULL) { small_contiguous = FALSE; break; } /* end if */ else { - /* If this span doesn't cover the entire dimension, then this selection isn't contiguous */ - if(u < (space->extent.rank - 1) && ((span->high-span->low) + 1) != 1) { + /* If this span doesn't cover the entire dimension, then this selection isn't contiguous + */ + if (u < (space->extent.rank - 1) && ((span->high - span->low) + 1) != 1) { small_contiguous = FALSE; break; } /* end if */ @@ -5059,19 +5234,18 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* Increment dimension */ u++; } /* end else */ - } /* end else */ - } /* end while */ - } /* end if */ + } /* end else */ + } /* end while */ + } /* end if */ /* Indicate true if it's either a large or small contiguous block */ - if(large_contiguous || small_contiguous) + if (large_contiguous || small_contiguous) ret_value = TRUE; } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_single @@ -5093,7 +5267,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) static H5_ATTR_PURE htri_t H5S__hyper_is_single(const H5S_t *space) { - htri_t ret_value = TRUE; /* return value */ + htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -5103,8 +5277,8 @@ H5S__hyper_is_single(const H5S_t *space) /* (No need to rebuild the dimension info yet, since the span-tree * algorithm is fast -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned u; /* index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned u; /* index variable */ /* * For a regular hyperslab to be single, it must have only one @@ -5112,12 +5286,12 @@ H5S__hyper_is_single(const H5S_t *space) */ /* Check for a single block */ - for(u = 0; u < space->extent.rank; u++) - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + for (u = 0; u < space->extent.rank; u++) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) HGOTO_DONE(FALSE) } /* end if */ else { - H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ + H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ /* * For a region to be single, it must have only one block @@ -5126,25 +5300,24 @@ H5S__hyper_is_single(const H5S_t *space) spans = space->select.sel_info.hslab->span_lst; /* Cycle down the spans until we run out of down spans or find a non-contiguous span */ - while(spans != NULL) { - H5S_hyper_span_t *span; /* Hyperslab span node */ + while (spans != NULL) { + H5S_hyper_span_t *span; /* Hyperslab span node */ span = spans->head; /* Check that this is the only span and it spans the entire dimension */ - if(span->next != NULL) + if (span->next != NULL) HGOTO_DONE(FALSE) else /* Walk down to the next span */ spans = span->down; } /* end while */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_is_regular @@ -5167,7 +5340,7 @@ H5S__hyper_is_single(const H5S_t *space) static htri_t H5S__hyper_is_regular(const H5S_t *space) { - htri_t ret_value = FAIL; /* return value */ + htri_t ret_value = FAIL; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -5177,11 +5350,11 @@ H5S__hyper_is_regular(const H5S_t *space) /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * 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 */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ /* Only simple check for regular hyperslabs for now... */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) ret_value = TRUE; else ret_value = FALSE; @@ -5189,7 +5362,6 @@ H5S__hyper_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_shape_same_helper @@ -5217,12 +5389,12 @@ H5S__hyper_is_regular(const H5S_t *space) --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2, hssize_t offset[], - hbool_t rest_zeros[]) + const H5S_hyper_span_info_t *span_info2, hssize_t offset[], + hbool_t rest_zeros[]) { - hbool_t ret_value = TRUE; /* Return value */ + hbool_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(span_info1); @@ -5234,9 +5406,9 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, /* (Could compare lower dimensions also, but not certain if * that's worth it. - QAK, 2019/01/23) */ - if((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0]) + if ((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0]) HGOTO_DONE(FALSE) - else if((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0]) + else if ((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0]) HGOTO_DONE(FALSE) else { const H5S_hyper_span_t *span1; @@ -5251,37 +5423,39 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, HDassert(span2); /* infinite loop which must be broken out of */ - while(1) { + while (1) { /* Check for both spans being NULL */ - if(span1 == NULL && span2 == NULL) + if (span1 == NULL && span2 == NULL) HGOTO_DONE(TRUE) /* Check for one span being NULL */ - if(span1 == NULL || span2 == NULL) + if (span1 == NULL || span2 == NULL) HGOTO_DONE(FALSE) /* Check if the actual low & high span information is the same */ - if((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high) + if ((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || + (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high) HGOTO_DONE(FALSE) /* Check for down tree for this span */ - if(span1->down != NULL || span2->down != NULL) { + if (span1->down != NULL || span2->down != NULL) { /* If the rest of the span trees have a zero offset, use the faster comparison routine */ - if(rest_zeros[0]) { - if(!H5S__hyper_cmp_spans(span1->down, span2->down)) + if (rest_zeros[0]) { + if (!H5S__hyper_cmp_spans(span1->down, span2->down)) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end if */ + } /* end if */ else { - if(!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], &rest_zeros[1])) + if (!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], + &rest_zeros[1])) HGOTO_DONE(FALSE) else { /* Keep going... */ } /* end else */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ else { /* Keep going... */ } /* end else */ @@ -5290,7 +5464,7 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, span1 = span1->next; span2 = span2->next; } /* end while */ - } /* end else */ + } /* end else */ /* Fall through, with default return value of 'TRUE' if spans were already visited */ @@ -5298,7 +5472,6 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_shape_same_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_shape_same @@ -5320,16 +5493,16 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, REVISION LOG --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t -H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2, unsigned ndims) +H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2, + unsigned ndims) { - const H5S_hyper_span_t *span1; /* Pointer to spans in first span tree */ - const H5S_hyper_span_t *span2; /* Pointer to spans in second span tree */ - hssize_t offset[H5S_MAX_RANK]; /* Offset vector for selections */ - hbool_t rest_zeros[H5S_MAX_RANK]; /* Vector of flags to indicate when remaining offset is all zero */ - hbool_t zero_offset; /* Whether the two selections have a non-zero offset */ - unsigned u; /* Local index variable */ - hbool_t ret_value = TRUE; /* Return value */ + const H5S_hyper_span_t *span1; /* Pointer to spans in first span tree */ + const H5S_hyper_span_t *span2; /* Pointer to spans in second span tree */ + hssize_t offset[H5S_MAX_RANK]; /* Offset vector for selections */ + hbool_t rest_zeros[H5S_MAX_RANK]; /* Vector of flags to indicate when remaining offset is all zero */ + hbool_t zero_offset; /* Whether the two selections have a non-zero offset */ + unsigned u; /* Local index variable */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5343,16 +5516,16 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, HDmemset(rest_zeros, 0, sizeof(rest_zeros)); /* Check for an offset between the two selections */ - span1 = span_info1->head; - span2 = span_info2->head; + span1 = span_info1->head; + span2 = span_info2->head; zero_offset = TRUE; - for(u = 0; u < ndims; u++) { + for (u = 0; u < ndims; u++) { /* Check for offset in this dimension */ - if(span1->low != span2->low) { + if (span1->low != span2->low) { offset[u] = (hssize_t)span2->low - (hssize_t)span1->low; /* Indicate that the offset vector is not all zeros */ - if(zero_offset) + if (zero_offset) zero_offset = FALSE; } /* end if */ @@ -5361,19 +5534,19 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, HDassert((span1->down && span2->down) || (NULL == span1->down && NULL == span2->down)); /* Advance to next dimension */ - if(span1->down) { + if (span1->down) { span1 = span1->down->head; span2 = span2->down->head; } /* end if */ - } /* end for */ + } /* end for */ /* Check if there's a "tail" of all zeros in a non-zero offset vector */ - if(!zero_offset) { - int i; /* Local index variable */ + if (!zero_offset) { + int i; /* Local index variable */ /* Find first non-zero offset, from the fastest dimension up */ - for(i = (int)(ndims - 1); i >= 0; i--) - if(offset[i]) { + for (i = (int)(ndims - 1); i >= 0; i--) + if (offset[i]) { rest_zeros[i] = TRUE; break; } /* end if */ @@ -5387,7 +5560,7 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, * comparison routine. Otherwise, use a generalized version of that * routine. */ - if(zero_offset) + if (zero_offset) ret_value = H5S__hyper_cmp_spans(span_info1, span_info2); else ret_value = H5S__hyper_spans_shape_same_helper(span_info1, span_info2, offset, rest_zeros); @@ -5395,7 +5568,6 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_shape_same @@ -5423,9 +5595,9 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) { - unsigned space1_rank; /* Number of dimensions of first dataspace */ - unsigned space2_rank; /* Number of dimensions of second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + unsigned space1_rank; /* Number of dimensions of first dataspace */ + unsigned space2_rank; /* Number of dimensions of second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -5443,16 +5615,16 @@ 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 */ - if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */ + if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space1); /* Casting away const OK -QAK */ + if (space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */ /* If both are regular hyperslabs, compare their diminfo values */ - if(space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES - && space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ + if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES && + space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ /* Initialize dimensions */ space1_dim = (int)space1_rank - 1; @@ -5461,63 +5633,65 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) /* Check that the shapes are the same in the common dimensions, and that * block == 1 in all dimensions that appear only in space1. */ - while(space2_dim >= 0) { - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride) + while (space2_dim >= 0) { + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride) HGOTO_DONE(FALSE) - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].count != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].count) + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].count != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].count) HGOTO_DONE(FALSE) - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != - space2->select.sel_info.hslab->diminfo.opt[space2_dim].block) + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != + space2->select.sel_info.hslab->diminfo.opt[space2_dim].block) HGOTO_DONE(FALSE) space1_dim--; space2_dim--; } /* end while */ - while(space1_dim >= 0) { - if(space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1) + while (space1_dim >= 0) { + if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1) HGOTO_DONE(FALSE) space1_dim--; } /* end while */ - } /* end if */ + } /* end if */ /* If both aren't regular, use fast irregular comparison */ else { - H5S_hyper_span_info_t *spans1; /* Hyperslab spans for first dataspace */ + H5S_hyper_span_info_t *spans1; /* Hyperslab spans for first dataspace */ /* 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 */ - 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 */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection") + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans((H5S_t *)space1) < 0) /* Casting away const OK -QAK */ + 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 */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for hyperslab selection") /* If rank of space A is different (guaranteed greater) than * rank of space B, walk down the span tree, verifying * that the block size is 1 on the way down. */ - if(space1_rank > space2_rank) { - unsigned diff_rank = space1_rank - space2_rank; /* Difference in ranks */ + if (space1_rank > space2_rank) { + unsigned diff_rank = space1_rank - space2_rank; /* Difference in ranks */ /* Walk down the dimensions */ spans1 = space1->select.sel_info.hslab->span_lst; - while(diff_rank > 0) { - H5S_hyper_span_t *span; /* Span for this dimension */ + while (diff_rank > 0) { + H5S_hyper_span_t *span; /* Span for this dimension */ /* Get pointer to first span in tree */ span = spans1->head; /* Check for more spans in this dimension */ - if(span->next) + if (span->next) HGOTO_DONE(FALSE) /* Check for span size > 1 element */ - if(span->low != span->high) + if (span->low != span->high) HGOTO_DONE(FALSE) /* Walk down to the next dimension */ @@ -5541,7 +5715,6 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_release @@ -5571,8 +5744,8 @@ H5S__hyper_release(H5S_t *space) space->select.num_elem = 0; /* Release irregular hyperslab information */ - if(space->select.sel_info.hslab) { - if(space->select.sel_info.hslab->span_lst != NULL) + if (space->select.sel_info.hslab) { + if (space->select.sel_info.hslab->span_lst != NULL) H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Release space for the hyperslab selection information */ @@ -5582,7 +5755,6 @@ H5S__hyper_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_release() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_coord_to_span @@ -5604,9 +5776,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_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 * 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 */ FUNC_ENTER_STATIC @@ -5614,9 +5786,9 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) HDassert(coords); /* Search for location to insert new element in tree */ - if(rank > 1) { + if (rank > 1) { /* Allocate a span info node for coordinates below this one */ - if(NULL == (down = H5S__hyper_new_span_info(rank - 1))) + if (NULL == (down = H5S__hyper_new_span_info(rank - 1))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set the low & high bounds for this span info node */ @@ -5624,28 +5796,27 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) H5MM_memcpy(down->high_bounds, &coords[1], (rank - 1) * sizeof(hsize_t)); /* Build span tree for coordinates below this one */ - if(NULL == (down->head = H5S__hyper_coord_to_span(rank - 1, &coords[1]))) + if (NULL == (down->head = H5S__hyper_coord_to_span(rank - 1, &coords[1]))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") - /* Update the tail pointer of the down dimension, and it's a single span element */ - down->tail = down->head; + /* Update the tail pointer of the down dimension, and it's a single span element */ + down->tail = down->head; } /* end if */ /* Build span for this coordinate */ - if(NULL == (new_span = H5S__hyper_new_span(coords[0], coords[0], down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(coords[0], coords[0], down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set return value */ ret_value = new_span; done: - if(ret_value == NULL && down != NULL) + if (ret_value == NULL && down != NULL) H5S__hyper_free_span_info(down); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_coord_to_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_add_span_element_helper @@ -5668,11 +5839,11 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, - unsigned rank, const hsize_t *coords, int *first_dim_modified) +H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, unsigned rank, const hsize_t *coords, + int *first_dim_modified) { - H5S_hyper_span_t *tail_span; /* Pointer to the tail span of one dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *tail_span; /* Pointer to the tail span of one dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -5687,24 +5858,24 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Determine if tail span includes a portion of the coordinate */ /* (Should never happen with the lowest level in the span tree) */ - if(coords[0] >= tail_span->low && coords[0] <= tail_span->high) { - H5S_hyper_span_t *prev_down_tail_span; /* Pointer to previous down spans' tail pointer */ - hsize_t prev_down_tail_span_high; /* Value of previous down spans' tail's high value */ + if (coords[0] >= tail_span->low && coords[0] <= tail_span->high) { + H5S_hyper_span_t *prev_down_tail_span; /* Pointer to previous down spans' tail pointer */ + hsize_t prev_down_tail_span_high; /* Value of previous down spans' tail's high value */ /* Retain into about down spans' tail */ - prev_down_tail_span = tail_span->down->tail; + prev_down_tail_span = tail_span->down->tail; prev_down_tail_span_high = tail_span->down->tail->high; /* Drop down a dimension */ HDassert(rank > 1); - if(H5S__hyper_add_span_element_helper(tail_span->down, rank - 1, &coords[1], first_dim_modified) < 0) + if (H5S__hyper_add_span_element_helper(tail_span->down, rank - 1, &coords[1], first_dim_modified) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree") /* Check & update high bounds for lower dimensions */ - if(*first_dim_modified >= 0) { - unsigned first_dim; /* First dimension modified, relative to this span tree */ - hbool_t first_dim_set = FALSE; /* Whether first dimension modified is set */ - unsigned u; /* Local index variable */ + if (*first_dim_modified >= 0) { + unsigned first_dim; /* First dimension modified, relative to this span tree */ + hbool_t first_dim_set = FALSE; /* Whether first dimension modified is set */ + unsigned u; /* Local index variable */ /* Adjust first dimension modified to be relative to this span tree */ first_dim = (unsigned)(*first_dim_modified + 1); @@ -5713,33 +5884,33 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, *first_dim_modified = -1; /* Iterate through coordinates */ - for(u = first_dim; u < rank; u++) { + for (u = first_dim; u < rank; u++) { /* Check if coordinate is outside the bounds for this span tree */ - if(coords[u] > span_tree->high_bounds[u]) { + if (coords[u] > span_tree->high_bounds[u]) { /* Update high bounds for this tree */ span_tree->high_bounds[u] = coords[u]; /* Need to signal to higher dimensions if high bounds changed */ - if(!first_dim_set) { + if (!first_dim_set) { *first_dim_modified = (int)u; - first_dim_set = TRUE; + first_dim_set = TRUE; } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ /* Check if previous tail span in down spans is different than current * tail span, or if its high value changed, in which case we should * check if the updated node can share down spans with other nodes. */ - if(tail_span->down->tail != prev_down_tail_span || - prev_down_tail_span_high != tail_span->down->tail->high) { + if (tail_span->down->tail != prev_down_tail_span || + prev_down_tail_span_high != tail_span->down->tail->high) { H5S_hyper_span_t *stop_span; /* Pointer to span to stop at */ - H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */ - uint64_t op_gen; /* Operation generation value */ + H5S_hyper_span_t *tmp_span; /* Temporary pointer to a span */ + uint64_t op_gen; /* Operation generation value */ /* Determine which span to stop at */ - if(tail_span->down->tail != prev_down_tail_span) { + if (tail_span->down->tail != prev_down_tail_span) { /* Sanity check */ HDassert(prev_down_tail_span->next == tail_span->down->tail); @@ -5765,23 +5936,23 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, * information. */ tmp_span = tail_span->down->head; - while(tmp_span != stop_span) { - hbool_t attempt_merge_spans = FALSE; /* Whether to merge spans */ + while (tmp_span != stop_span) { + hbool_t attempt_merge_spans = FALSE; /* Whether to merge spans */ /* Different tests for when to run the 'merge' algorithm, * depending whether there's "down trees" or not. */ - if(NULL == tmp_span->down) { + if (NULL == tmp_span->down) { /* Spin through spans until we find the one before the 'stop' span */ - if(tmp_span->next == stop_span) + if (tmp_span->next == stop_span) attempt_merge_spans = TRUE; } /* end if */ else { /* Check if we've compared the 'stop' span's "down tree" to * this span's "down tree" already. */ - if(tmp_span->down->op_info[0].op_gen != op_gen) { - if(H5S__hyper_cmp_spans(tmp_span->down, stop_span->down)) + if (tmp_span->down->op_info[0].op_gen != op_gen) { + if (H5S__hyper_cmp_spans(tmp_span->down, stop_span->down)) attempt_merge_spans = TRUE; /* Remember that we visited this span's "down tree" already */ @@ -5790,16 +5961,16 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, */ tmp_span->down->op_info[0].op_gen = op_gen; } /* end if */ - } /* end else */ + } /* end else */ /* Check for merging into previous span */ - if(attempt_merge_spans) { - if(tmp_span->high + 1 == stop_span->low) { + if (attempt_merge_spans) { + if (tmp_span->high + 1 == stop_span->low) { /* Increase size of previous span */ tmp_span->high++; /* Update pointers appropriately */ - if(stop_span == prev_down_tail_span) { + if (stop_span == prev_down_tail_span) { /* Sanity check */ HDassert(stop_span->next == tail_span->down->tail); @@ -5809,7 +5980,7 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Sanity check */ HDassert(tmp_span->next == tail_span->down->tail); - tmp_span->next = NULL; + tmp_span->next = NULL; tail_span->down->tail = tmp_span; } /* end else */ @@ -5818,7 +5989,7 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, } /* end if */ /* Span is disjoint, but has the same "down tree" selection */ /* (If it has a "down tree") */ - else if(stop_span->down) { + else if (stop_span->down) { /* Release "down tree" information */ H5S__hyper_free_span_info(stop_span->down); @@ -5836,23 +6007,24 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, /* Advance to next span to check */ tmp_span = tmp_span->next; } /* end while */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Check if we made it all the way to the bottom span list in the tree * and the new coordinate adjoins the current tail span. */ - if(rank == 1 && (tail_span->high + 1) == coords[0]) + if (rank == 1 && (tail_span->high + 1) == coords[0]) /* Append element to current tail span */ tail_span->high++; else { - H5S_hyper_span_t *new_span; /* New span created for element */ + H5S_hyper_span_t *new_span; /* New span created for element */ /* Make span tree for current coordinate(s) */ - if(NULL == (new_span = H5S__hyper_coord_to_span(rank, coords))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate") + if (NULL == (new_span = H5S__hyper_coord_to_span(rank, coords))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate hyperslab spans for coordinate") /* Add new span to span tree list */ tail_span->next = new_span; @@ -5864,8 +6036,8 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, span_tree->high_bounds[0] = coords[0]; /* Update high bounds for dimensions below this one */ - for(u = 1; u < rank; u++) - if(coords[u] > span_tree->high_bounds[u]) + for (u = 1; u < rank; u++) + if (coords[u] > span_tree->high_bounds[u]) span_tree->high_bounds[u] = coords[u]; /* Need to signal to higher dimensions that high bounds changed */ @@ -5876,7 +6048,6 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_span_element_helper() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_add_span_element @@ -5918,8 +6089,8 @@ H5S__hyper_add_span_element_helper(H5S_hyper_span_info_t *span_tree, herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) { - H5S_hyper_span_info_t *head = NULL; /* Pointer to new head of span tree */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_info_t *head = NULL; /* Pointer to new head of span tree */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -5929,9 +6100,9 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) HDassert(space->extent.rank == rank); /* Check if this is the first element in the selection */ - if(NULL == space->select.sel_info.hslab) { + if (NULL == space->select.sel_info.hslab) { /* Allocate a span info node */ - if(NULL == (head = H5S__hyper_new_span_info(rank))) + if (NULL == (head = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info") /* Set the low & high bounds for this span info node */ @@ -5942,14 +6113,14 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) head->count = 1; /* Build span tree for this coordinate */ - if(NULL == (head->head = H5S__hyper_coord_to_span(rank, coords))) + if (NULL == (head->head = H5S__hyper_coord_to_span(rank, coords))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab spans for coordinate") /* Update the tail pointer of this newly created span in dimension "rank" */ head->tail = head->head; /* Allocate selection info */ - if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab selection") /* Set the selection to the new span tree */ @@ -5968,10 +6139,11 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) space->select.num_elem = 1; } /* end if */ else { - int first_dim_modified = -1; /* Index of first dimension modified */ + int first_dim_modified = -1; /* Index of first dimension modified */ /* Add the element to the current set of spans */ - if(H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords, &first_dim_modified) < 0) + if (H5S__hyper_add_span_element_helper(space->select.sel_info.hslab->span_lst, rank, coords, + &first_dim_modified) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert coordinate into span tree") /* Increment # of elements in selection */ @@ -5979,14 +6151,13 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) } /* end else */ done: - if(ret_value < 0) - if(head) + if (ret_value < 0) + if (head) H5S__hyper_free_span_info(head); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_add_span_element() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block_helper @@ -6010,11 +6181,10 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords) REVISION LOG --------------------------------------------------------------------------*/ static hbool_t -H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, - unsigned rank, const hsize_t *start, const hsize_t *end, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hsize_t *start, + const hsize_t *end, unsigned op_info_i, uint64_t op_gen) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6024,47 +6194,48 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, HDassert(end); /* Check if we've already visited this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *curr; /* Pointer to current span in 1st span tree */ + unsigned u; /* Local index variable */ /* Verify that there is a possibility of an overlap by checking the block * against the low & high bounds for the span tree. */ - for(u = 0; u < rank; u++) - if(start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u]) + for (u = 0; u < rank; u++) + if (start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u]) HGOTO_DONE(FALSE) /* Get the span list for spans in this tree */ curr = spans->head; /* Iterate over the spans in the tree */ - while(curr != NULL) { + while (curr != NULL) { /* Check for span entirely before block */ - if(curr->high < *start) + if (curr->high < *start) /* Advance to next span in this dimension */ curr = curr->next; /* If this span is past the end of the block, then we're done in this dimension */ - else if(curr->low > *end) + else if (curr->low > *end) HGOTO_DONE(FALSE) /* block & span overlap */ else { /* If this is the bottom dimension, then the span tree overlaps the block */ - if(curr->down == NULL) + if (curr->down == NULL) HGOTO_DONE(TRUE) /* Recursively check spans in next dimension down */ else { /* If there is an intersection in the "down" dimensions, * the span trees overlap. */ - if(H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_info_i, op_gen)) + if (H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_info_i, + op_gen)) HGOTO_DONE(TRUE) /* No intersection in down dimensions, advance to next span */ curr = curr->next; } /* end else */ - } /* end else */ - } /* end while */ + } /* end else */ + } /* end while */ /* Set the tree's operation generation */ spans->op_info[op_info_i].op_gen = op_gen; @@ -6076,7 +6247,6 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block @@ -6101,7 +6271,7 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -6114,43 +6284,43 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* Attempt to rebuild diminfo if it is invalid and has not been confirmed * 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 */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) + H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */ /* Check for regular hyperslab intersection */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - hbool_t single_block; /* Whether the regular selection is a single block */ - unsigned u; /* Local index variable */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + hbool_t single_block; /* Whether the regular selection is a single block */ + unsigned u; /* Local index variable */ /* Check for a single block */ /* For a regular hyperslab to be single, it must have only one block * (i.e. count == 1 in all dimensions). */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + for (u = 0; u < space->extent.rank; u++) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) single_block = FALSE; /* Single blocks have already been "compared" above, in the low / high * bound checking, so just return TRUE if we've reached here - they * would have been rejected earlier, if they didn't intersect. */ - if(single_block) + if (single_block) HGOTO_DONE(TRUE) else { /* Loop over the dimensions, checking for an intersection */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* If the block's start is <= the hyperslab start, they intersect */ /* (So, if the start is > the hyperslab start, check more conditions) */ - if(start[u] > space->select.sel_info.hslab->diminfo.opt[u].start) { - hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ - hsize_t nstride; /* Number of strides into the selection */ + if (start[u] > space->select.sel_info.hslab->diminfo.opt[u].start) { + hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ + hsize_t nstride; /* Number of strides into the selection */ /* Adjust start coord for selection's 'start' offset */ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; @@ -6166,8 +6336,8 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* If the adjusted start doesn't fall within the first hyperslab * span, check for the block overlapping with the next one. */ - if(adj_start >= space->select.sel_info.hslab->diminfo.opt[u].block) { - hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ + if (adj_start >= space->select.sel_info.hslab->diminfo.opt[u].block) { + hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ /* Adjust end coord for selection's 'start' offset */ adj_end = end[u] - space->select.sel_info.hslab->diminfo.opt[u].start; @@ -6180,20 +6350,20 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* If block doesn't extend over beginning of next span, * it doesn't intersect. */ - if(adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride) + if (adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride) HGOTO_DONE(FALSE) } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* If we've looped through all dimensions and none of them didn't * overlap, then all of them do, so we report TRUE. */ HGOTO_DONE(TRUE) } /* end else */ - } /* end if */ + } /* end if */ else { - uint64_t op_gen; /* Operation generation value */ + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -6201,14 +6371,14 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize /* Perform the span-by-span intersection check */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, start, end, 0, op_gen); + ret_value = H5S__hyper_intersect_block_helper(space->select.sel_info.hslab->span_lst, + space->extent.rank, start, end, 0, op_gen); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u_helper @@ -6231,8 +6401,8 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, - const hsize_t *offset, unsigned op_info_i, uint64_t op_gen) +H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hsize_t *offset, + unsigned op_info_i, uint64_t op_gen) { FUNC_ENTER_STATIC_NOERR @@ -6241,12 +6411,12 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(offset); /* Check if we've already set this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *span; /* Pointer to current span in span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *span; /* Pointer to current span in span tree */ + unsigned u; /* Local index variable */ /* Adjust the span tree's low & high bounds */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert(spans->low_bounds[u] >= offset[u]); spans->low_bounds[u] -= offset[u]; spans->high_bounds[u] -= offset[u]; @@ -6254,14 +6424,14 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, /* Iterate over the spans in tree */ span = spans->head; - while(span != NULL) { + while (span != NULL) { /* Adjust span offset */ HDassert(span->low >= *offset); span->low -= *offset; span->high -= *offset; /* Recursively adjust spans in next dimension down */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_adjust_u_helper(span->down, rank - 1, offset + 1, op_info_i, op_gen); /* Advance to next span in this dimension */ @@ -6275,7 +6445,6 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_u_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u @@ -6297,8 +6466,8 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -6307,18 +6476,18 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Subtract the offset from the "regular" coordinates, if they exist */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { HDassert(space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]); space->select.sel_info.hslab->diminfo.opt[u].start -= offset[u]; @@ -6327,11 +6496,11 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) space->select.sel_info.hslab->diminfo.low_bounds[u] -= offset[u]; space->select.sel_info.hslab->diminfo.high_bounds[u] -= offset[u]; } /* end for */ - } /* end if */ + } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab->span_lst) { - uint64_t op_gen; /* Operation generation value */ + if (space->select.sel_info.hslab->span_lst) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -6339,14 +6508,14 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) /* Perform adjustment */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen); + H5S__hyper_adjust_u_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, + op_gen); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_adjust_u() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_scalar * @@ -6363,7 +6532,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) { - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ FUNC_ENTER_STATIC_NOERR @@ -6373,12 +6542,13 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ - unsigned u; /* Counter */ + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + const H5S_hyper_dim_t *diminfo = + space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ + unsigned u; /* Counter */ /* Build the table of the initial offset */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check diminfo */ HDassert(1 == diminfo[u].count); HDassert(1 == diminfo[u].block); @@ -6389,15 +6559,15 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) /* Keep the offset for later */ block[u] = diminfo[u].start; } /* end for */ - } /* end if */ + } /* end if */ else { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - unsigned curr_dim; /* Current dimension being operated on */ + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + unsigned curr_dim; /* Current dimension being operated on */ /* Advance down selected spans */ - curr = space->select.sel_info.hslab->span_lst->head; + curr = space->select.sel_info.hslab->span_lst->head; curr_dim = 0; - while(1) { + while (1) { /* Sanity checks */ HDassert(NULL == curr->next); HDassert(curr->low == curr->high); @@ -6407,14 +6577,14 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) block[curr_dim] = curr->low; /* Advance down to next dimension */ - if(curr->down) { + if (curr->down) { curr = curr->down->head; curr_dim++; } /* end if */ else break; } /* end while */ - } /* end else */ + } /* end else */ /* Calculate offset of selection in projected buffer */ *offset = H5VM_array_offset(space->extent.rank, space->extent.size, block); @@ -6422,7 +6592,6 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_lower * @@ -6439,8 +6608,8 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) static herr_t H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) { - H5S_hyper_span_info_t *down; /* Pointer to list of spans */ - unsigned curr_dim; /* Current dimension being operated on */ + H5S_hyper_span_info_t *down; /* Pointer to list of spans */ + unsigned curr_dim; /* Current dimension being operated on */ FUNC_ENTER_STATIC_NOERR @@ -6450,9 +6619,9 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) HDassert(new_space->extent.rank < base_space->extent.rank); /* Walk down the span tree until we reach the selection to project */ - down = base_space->select.sel_info.hslab->span_lst; + down = base_space->select.sel_info.hslab->span_lst; curr_dim = 0; - while(down && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { + while (down && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { /* Sanity check */ HDassert(NULL == down->head->next); @@ -6469,7 +6638,6 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_simple_lower() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_higher * @@ -6486,11 +6654,11 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) static herr_t H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) { - H5S_hyper_span_t *prev_span = NULL; /* Pointer to previous list of spans */ - unsigned delta_rank; /* Difference in dataspace ranks */ - unsigned curr_dim; /* Current dimension being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *prev_span = NULL; /* Pointer to previous list of spans */ + unsigned delta_rank; /* Difference in dataspace ranks */ + unsigned curr_dim; /* Current dimension being operated on */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6501,48 +6669,50 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) /* Create nodes until reaching the correct # of dimensions */ new_space->select.sel_info.hslab->span_lst = NULL; - curr_dim = 0; - 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 */ + curr_dim = 0; + 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 */ /* Allocate a new span_info node */ - if(NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { - if(prev_span) + if (NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { + if (prev_span) H5S__hyper_free_span(prev_span); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span info") } /* end if */ /* Check for linking into higher span */ - if(prev_span) + if (prev_span) prev_span->down = new_span_info; /* Allocate a new node */ - if(NULL == (new_span = H5S__hyper_new_span((hsize_t)0, (hsize_t)0, NULL, NULL))) { + if (NULL == (new_span = H5S__hyper_new_span((hsize_t)0, (hsize_t)0, NULL, NULL))) { HDassert(new_span_info); - if(!prev_span) + if (!prev_span) (void)H5FL_ARR_FREE(hbounds_t, new_span_info); HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") } /* end if */ /* Set the span_info information */ new_span_info->count = 1; - new_span_info->head = new_span; - new_span_info->tail = new_span; + new_span_info->head = new_span; + new_span_info->tail = new_span; /* Set the bounding box */ - for(u = 0; u < delta_rank; u++) { - new_span_info->low_bounds[u] = 0; + for (u = 0; u < delta_rank; u++) { + new_span_info->low_bounds[u] = 0; new_span_info->high_bounds[u] = 0; } /* end for */ - for(; u < new_space->extent.rank; u++) { - new_span_info->low_bounds[u] = base_space->select.sel_info.hslab->span_lst->low_bounds[u - delta_rank]; - new_span_info->high_bounds[u] = base_space->select.sel_info.hslab->span_lst->high_bounds[u - delta_rank]; + for (; u < new_space->extent.rank; u++) { + new_span_info->low_bounds[u] = + base_space->select.sel_info.hslab->span_lst->low_bounds[u - delta_rank]; + new_span_info->high_bounds[u] = + base_space->select.sel_info.hslab->span_lst->high_bounds[u - delta_rank]; } /* end for */ /* Attach to new space, if top span info */ - if(NULL == new_space->select.sel_info.hslab->span_lst) + if (NULL == new_space->select.sel_info.hslab->span_lst) new_space->select.sel_info.hslab->span_lst = new_span_info; /* Remember previous span info */ @@ -6559,17 +6729,17 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) prev_span->down->count++; done: - if(ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { - if(new_space->select.sel_info.hslab->span_lst->head) + if (ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { + if (new_space->select.sel_info.hslab->span_lst->head) H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head); - new_space->select.sel_info.hslab->span_lst = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); + new_space->select.sel_info.hslab->span_lst = + (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple_higher() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple * @@ -6584,10 +6754,9 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) *------------------------------------------------------------------------- */ static herr_t -H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, - hsize_t *offset) +H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -6597,11 +6766,11 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, HDassert(offset); /* We are setting a new selection, remove any current selection in new dataspace */ - if(H5S_SELECT_RELEASE(new_space) < 0) + if (H5S_SELECT_RELEASE(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate space for the hyperslab selection information */ - if(NULL == (new_space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (new_space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set unlim_dim */ @@ -6609,25 +6778,26 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, /* Check for a "regular" hyperslab selection */ /* (No need to rebuild the dimension info yet -QAK) */ - if(base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - unsigned base_space_dim; /* Current dimension in the base dataspace */ - unsigned new_space_dim; /* Current dimension in the new dataspace */ - unsigned u; /* Local index variable */ + if (base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + unsigned base_space_dim; /* Current dimension in the base dataspace */ + unsigned new_space_dim; /* Current dimension in the new dataspace */ + unsigned u; /* Local index variable */ /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->diminfo.opt; /* Alias for dataspace's diminfo information */ - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + if (new_space->extent.rank < base_space->extent.rank) { + const H5S_hyper_dim_t *opt_diminfo = base_space->select.sel_info.hslab->diminfo + .opt; /* Alias for dataspace's diminfo information */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ /* Compute the offset for the down-projection */ HDmemset(block, 0, sizeof(block)); - for(u = 0; u < (base_space->extent.rank - new_space->extent.rank); u++) + for (u = 0; u < (base_space->extent.rank - new_space->extent.rank); u++) block[u] = opt_diminfo[u].start; *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); /* Set the correct dimensions for the base & new spaces */ base_space_dim = base_space->extent.rank - new_space->extent.rank; - new_space_dim = 0; + new_space_dim = 0; } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -6636,16 +6806,17 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = 0; /* Set the diminfo information for the higher dimensions */ - for(new_space_dim = 0; new_space_dim < (new_space->extent.rank - base_space->extent.rank); new_space_dim++) { - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = 0; + for (new_space_dim = 0; new_space_dim < (new_space->extent.rank - base_space->extent.rank); + new_space_dim++) { + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = 0; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride = 1; - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = 1; - new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = 1; + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = 1; + new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = 0; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = 0; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = 1; - new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = 1; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = 1; + new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = 1; } /* end for */ /* Start at beginning of base space's dimension info */ @@ -6653,24 +6824,24 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end else */ /* Copy the diminfo */ - while(base_space_dim < base_space->extent.rank) { + while (base_space_dim < base_space->extent.rank) { new_space->select.sel_info.hslab->diminfo.app[new_space_dim].start = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].start; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].start; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].stride = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].stride; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].stride; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].count = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].count; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].count; new_space->select.sel_info.hslab->diminfo.app[new_space_dim].block = - base_space->select.sel_info.hslab->diminfo.app[base_space_dim].block; + base_space->select.sel_info.hslab->diminfo.app[base_space_dim].block; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].start = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].start; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].start; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].stride = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].stride; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].stride; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].count = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].count; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].count; new_space->select.sel_info.hslab->diminfo.opt[new_space_dim].block = - base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].block; + base_space->select.sel_info.hslab->diminfo.opt[base_space_dim].block; /* Advance to next dimensions */ base_space_dim++; @@ -6678,9 +6849,14 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end for */ /* Update the bounding box */ - for(u = 0; u < new_space->extent.rank; u++) { - new_space->select.sel_info.hslab->diminfo.low_bounds[u] = new_space->select.sel_info.hslab->diminfo.opt[u].start; - new_space->select.sel_info.hslab->diminfo.high_bounds[u] = new_space->select.sel_info.hslab->diminfo.low_bounds[u] + new_space->select.sel_info.hslab->diminfo.opt[u].stride * (new_space->select.sel_info.hslab->diminfo.opt[u].count - 1) + (new_space->select.sel_info.hslab->diminfo.opt[u].block - 1); + for (u = 0; u < new_space->extent.rank; u++) { + new_space->select.sel_info.hslab->diminfo.low_bounds[u] = + new_space->select.sel_info.hslab->diminfo.opt[u].start; + new_space->select.sel_info.hslab->diminfo.high_bounds[u] = + new_space->select.sel_info.hslab->diminfo.low_bounds[u] + + new_space->select.sel_info.hslab->diminfo.opt[u].stride * + (new_space->select.sel_info.hslab->diminfo.opt[u].count - 1) + + (new_space->select.sel_info.hslab->diminfo.opt[u].block - 1); } /* end for */ /* Indicate that the dimension information is valid */ @@ -6691,18 +6867,18 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, } /* end if */ else { /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ - unsigned curr_dim; /* Current dimension being operated on */ + if (new_space->extent.rank < base_space->extent.rank) { + const H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + unsigned curr_dim; /* Current dimension being operated on */ /* Clear the block buffer */ HDmemset(block, 0, sizeof(block)); /* Advance down selected spans */ - curr = base_space->select.sel_info.hslab->span_lst->head; + curr = base_space->select.sel_info.hslab->span_lst->head; curr_dim = 0; - while(curr && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { + while (curr && curr_dim < (base_space->extent.rank - new_space->extent.rank)) { /* Save the location of the selection in current dimension */ block[curr_dim] = curr->low; @@ -6715,8 +6891,9 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); /* Project the base space's selection down in less dimensions */ - if(H5S__hyper_project_simple_lower(base_space, new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't project hyperslab selection into less dimensions") + if (H5S__hyper_project_simple_lower(base_space, new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't project hyperslab selection into less dimensions") } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -6725,8 +6902,9 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, *offset = 0; /* Project the base space's selection down in more dimensions */ - if(H5S__hyper_project_simple_higher(base_space, new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't project hyperslab selection into less dimensions") + if (H5S__hyper_project_simple_higher(base_space, new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't project hyperslab selection into less dimensions") } /* end else */ /* Copy the status of the dimension information */ @@ -6743,7 +6921,6 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s_helper @@ -6766,8 +6943,8 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, - const hssize_t *offset, unsigned op_info_i, uint64_t op_gen) +H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, const hssize_t *offset, + unsigned op_info_i, uint64_t op_gen) { FUNC_ENTER_STATIC_NOERR @@ -6776,27 +6953,27 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, HDassert(offset); /* Check if we've already set this span tree */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_hyper_span_t *span; /* Pointer to current span in span tree */ - unsigned u; /* Local index variable */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_hyper_span_t *span; /* Pointer to current span in span tree */ + unsigned u; /* Local index variable */ /* Adjust the span tree's low & high bounds */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert((hssize_t)spans->low_bounds[u] >= offset[u]); - spans->low_bounds[u] = (hsize_t)((hssize_t)spans->low_bounds[u] - offset[u]); + spans->low_bounds[u] = (hsize_t)((hssize_t)spans->low_bounds[u] - offset[u]); spans->high_bounds[u] = (hsize_t)((hssize_t)spans->high_bounds[u] - offset[u]); } /* end for */ /* Iterate over the spans in tree */ span = spans->head; - while(span != NULL) { + while (span != NULL) { /* Adjust span offset */ HDassert((hssize_t)span->low >= *offset); - span->low = (hsize_t)((hssize_t)span->low - *offset); + span->low = (hsize_t)((hssize_t)span->low - *offset); span->high = (hsize_t)((hssize_t)span->high - *offset); /* Recursively adjust spans in next dimension down */ - if(span->down != NULL) + if (span->down != NULL) H5S__hyper_adjust_s_helper(span->down, rank - 1, offset + 1, op_info_i, op_gen); /* Advance to next span in this dimension */ @@ -6810,7 +6987,6 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_s_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s @@ -6832,42 +7008,44 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, static herr_t H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + unsigned u; /* Local index variable */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(space); HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* end if */ /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Subtract the offset from the "regular" coordinates, if they exist */ /* (No need to rebuild the dimension info yet -QAK) */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { HDassert((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start >= offset[u]); - space->select.sel_info.hslab->diminfo.opt[u].start = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start - offset[u]); + space->select.sel_info.hslab->diminfo.opt[u].start = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.opt[u].start - offset[u]); /* Adjust the low & high bounds */ HDassert((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] >= offset[u]); - space->select.sel_info.hslab->diminfo.low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] - offset[u]); - space->select.sel_info.hslab->diminfo.high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.high_bounds[u] - offset[u]); + space->select.sel_info.hslab->diminfo.low_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.low_bounds[u] - offset[u]); + space->select.sel_info.hslab->diminfo.high_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.hslab->diminfo.high_bounds[u] - offset[u]); } /* end for */ - } /* end if */ + } /* end if */ /* Subtract the offset from the span tree coordinates, if they exist */ - if(space->select.sel_info.hslab->span_lst) { - uint64_t op_gen; /* Operation generation value */ + if (space->select.sel_info.hslab->span_lst) { + uint64_t op_gen; /* Operation generation value */ /* Acquire an operation generation value for this operation */ op_gen = H5S__hyper_get_op_gen(); @@ -6875,15 +7053,14 @@ H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) /* Perform the adjustment */ /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ - H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen); + H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, + op_gen); } /* end if */ } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_adjust_s() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_normalize_offset @@ -6908,7 +7085,7 @@ H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6917,17 +7094,17 @@ H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) HDassert(old_offset); /* Check for hyperslab selection & offset changed */ - if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS && space->select.offset_changed) { - unsigned u; /* Local index variable */ + if (H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS && space->select.offset_changed) { + unsigned u; /* Local index variable */ /* Copy & invert the selection offset */ - for(u = 0; u < space->extent.rank; u++) { - old_offset[u] = space->select.offset[u]; + for (u = 0; u < space->extent.rank; u++) { + old_offset[u] = space->select.offset[u]; space->select.offset[u] = -space->select.offset[u]; } /* end for */ /* Call the 'adjust' routine */ - if(H5S__hyper_adjust_s(space, space->select.offset) < 0) + if (H5S__hyper_adjust_s(space, space->select.offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") /* Zero out the selection offset */ @@ -6941,7 +7118,6 @@ H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_normalize_offset() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_denormalize_offset @@ -6966,7 +7142,7 @@ H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset) herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -6975,7 +7151,7 @@ H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Call the 'adjust' routine */ - if(H5S__hyper_adjust_s(space, old_offset) < 0) + if (H5S__hyper_adjust_s(space, old_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") /* Copy the selection offset over */ @@ -6985,7 +7161,6 @@ H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_denormalize_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_append_span @@ -7008,11 +7183,11 @@ H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, - hsize_t low, hsize_t high, H5S_hyper_span_info_t *down) +H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, hsize_t low, hsize_t high, + H5S_hyper_span_info_t *down) { - H5S_hyper_span_t *new_span = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_span_t *new_span = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7020,40 +7195,40 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, HDassert(span_tree); /* Check for adding first node to merged spans */ - if(*span_tree == NULL) { + if (*span_tree == NULL) { /* Allocate new span node to append to list */ - if(NULL == (new_span = H5S__hyper_new_span(low, high, down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(low, high, down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Make new span the first node in span list */ /* Allocate a new span_info node */ - if(NULL == (*span_tree = H5S__hyper_new_span_info(ndims))) + if (NULL == (*span_tree = H5S__hyper_new_span_info(ndims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Set the span tree's basic information */ (*span_tree)->count = 1; - (*span_tree)->head = new_span; - (*span_tree)->tail = new_span; + (*span_tree)->head = new_span; + (*span_tree)->tail = new_span; /* Set low & high bounds for new span tree */ - (*span_tree)->low_bounds[0] = low; + (*span_tree)->low_bounds[0] = low; (*span_tree)->high_bounds[0] = high; - if(down) { + if (down) { /* Sanity check */ HDassert(ndims > 1); H5MM_memcpy(&((*span_tree)->low_bounds[1]), down->low_bounds, sizeof(hsize_t) * (ndims - 1)); H5MM_memcpy(&((*span_tree)->high_bounds[1]), down->high_bounds, sizeof(hsize_t) * (ndims - 1)); } /* end if */ - } /* end if */ + } /* end if */ /* Merge or append to existing merged spans list */ else { - htri_t down_cmp = (-1); /* Comparison value for down spans */ + htri_t down_cmp = (-1); /* Comparison value for down spans */ /* Check if span can just extend the previous merged span */ - if((((*span_tree)->tail->high + 1) == low) && - (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) { + if ((((*span_tree)->tail->high + 1) == low) && + (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) { /* Extend previous merged span to include new high bound */ (*span_tree)->tail->high = high; @@ -7062,17 +7237,17 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, (*span_tree)->high_bounds[0] = high; } /* end if */ else { - H5S_hyper_span_info_t *new_down; /* Down pointer for new span node */ + H5S_hyper_span_info_t *new_down; /* Down pointer for new span node */ /* Sanity check */ /* (If down_cmp was set to TRUE above, we won't be in this branch) */ HDassert(down_cmp != TRUE); /* Check if there is actually a down span */ - if(down) { + if (down) { /* Check if the down spans for the new span node are the same as the previous span node */ /* (Uses the 'down span comparison' from earlier, if already computed) */ - if(down_cmp < 0 && (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) + if (down_cmp < 0 && (down_cmp = H5S__hyper_cmp_spans(down, (*span_tree)->tail->down))) /* Share the previous span's down span tree */ new_down = (*span_tree)->tail->down; else @@ -7082,48 +7257,47 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, new_down = NULL; /* Allocate new span node to append to list */ - if(NULL == (new_span = H5S__hyper_new_span(low, high, new_down, NULL))) + if (NULL == (new_span = H5S__hyper_new_span(low, high, new_down, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Update the high bounds for current dimension */ (*span_tree)->high_bounds[0] = high; /* Update low & high bounds in lower dimensions, if there are any */ - if(down) { + if (down) { /* Sanity checks */ HDassert(ndims > 1); HDassert(down_cmp >= 0); /* Check if we are sharing down spans with a previous node */ /* (Only need to check for bounds changing if down spans aren't shared) */ - if(down_cmp == FALSE) { - unsigned u; /* Local index variable */ + if (down_cmp == FALSE) { + unsigned u; /* Local index variable */ /* Loop over lower dimensions, checking & updating low & high bounds */ - for(u = 0; u < (ndims - 1); u++) { - if(down->low_bounds[u] < (*span_tree)->low_bounds[u + 1]) + for (u = 0; u < (ndims - 1); u++) { + if (down->low_bounds[u] < (*span_tree)->low_bounds[u + 1]) (*span_tree)->low_bounds[u + 1] = down->low_bounds[u]; - if(down->high_bounds[u] > (*span_tree)->high_bounds[u + 1]) + if (down->high_bounds[u] > (*span_tree)->high_bounds[u + 1]) (*span_tree)->high_bounds[u + 1] = down->high_bounds[u]; } /* end for */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Append to end of merged spans list */ (*span_tree)->tail->next = new_span; - (*span_tree)->tail = new_span; + (*span_tree)->tail = new_span; } /* end else */ - } /* end else */ + } /* end else */ done: - if(ret_value < 0) - if(new_span) + if (ret_value < 0) + if (new_span) H5S__hyper_free_span(new_span); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_append_span() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_clip_spans @@ -7165,15 +7339,14 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, - unsigned selector, unsigned ndims, - H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b, - H5S_hyper_span_info_t **b_not_a) +H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, unsigned selector, + unsigned ndims, H5S_hyper_span_info_t **a_not_b, H5S_hyper_span_info_t **a_and_b, + H5S_hyper_span_info_t **b_not_a) { - hbool_t need_a_not_b; /* Whether to generate a_not_b list */ - hbool_t need_a_and_b; /* Whether to generate a_and_b list */ - hbool_t need_b_not_a; /* Whether to generate b_not_a list */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t need_a_not_b; /* Whether to generate a_not_b list */ + hbool_t need_a_and_b; /* Whether to generate a_and_b list */ + hbool_t need_b_not_a; /* Whether to generate b_not_a list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7190,28 +7363,28 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s need_b_not_a = ((selector & H5S_HYPER_COMPUTE_B_NOT_A) != 0); /* Check if both span trees are not defined */ - if(a_spans == NULL && b_spans == NULL) { + if (a_spans == NULL && b_spans == NULL) { *a_not_b = NULL; *a_and_b = NULL; *b_not_a = NULL; } /* end if */ /* If span 'a' is not defined, but 'b' is, copy 'b' and set the other return span trees to empty */ - else if(a_spans == NULL) { + else if (a_spans == NULL) { *a_not_b = NULL; *a_and_b = NULL; - if(need_b_not_a) { - if(NULL == (*b_not_a = H5S__hyper_copy_span(b_spans, ndims))) + if (need_b_not_a) { + if (NULL == (*b_not_a = H5S__hyper_copy_span(b_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else *b_not_a = NULL; } /* end if */ /* If span 'b' is not defined, but 'a' is, copy 'a' and set the other return span trees to empty */ - else if(b_spans == NULL) { + else if (b_spans == NULL) { *a_and_b = NULL; *b_not_a = NULL; - if(need_a_not_b) { - if(NULL == (*a_not_b = H5S__hyper_copy_span(a_spans, ndims))) + if (need_a_not_b) { + if (NULL == (*a_not_b = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else @@ -7220,20 +7393,20 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* If span 'a' and 'b' are both defined, calculate the proper span trees */ else { /* Check if both span trees completely overlap */ - if(H5S__hyper_cmp_spans(a_spans, b_spans)) { + if (H5S__hyper_cmp_spans(a_spans, b_spans)) { *a_not_b = NULL; *b_not_a = NULL; - if(need_a_and_b) { - if(NULL == (*a_and_b = H5S__hyper_copy_span(a_spans, ndims))) + if (need_a_and_b) { + if (NULL == (*a_and_b = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL, "can't copy hyperslab span tree") } /* end if */ else *a_and_b = NULL; } /* end if */ else { - H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */ - H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */ - hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ + H5S_hyper_span_t *span_a; /* Pointer to a node in span tree 'a' */ + H5S_hyper_span_t *span_b; /* Pointer to a node in span tree 'b' */ + hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ /* Get the pointers to the new and old span lists */ span_a = a_spans->head; @@ -7243,22 +7416,26 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s recover_a = recover_b = FALSE; /* Work through the list of spans in the new list */ - while(span_a != NULL && span_b != NULL) { - H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans for overlapping nodes */ - H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */ - H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */ - H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */ + while (span_a != NULL && span_b != NULL) { + H5S_hyper_span_info_t *down_a_not_b; /* Temporary pointer to a_not_b span tree of down spans + for overlapping nodes */ + H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans + for overlapping nodes */ + H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans + for overlapping nodes */ + H5S_hyper_span_t *tmp_span; /* Temporary pointer to new span */ /* Check if span 'a' is completely before span 'b' */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - if(span_a->high < span_b->low) { + if (span_a->high < span_b->low) { /* Copy span 'a' and add to a_not_b list */ /* Merge/add span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'a', leave span 'b' */ @@ -7269,27 +7446,32 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && (span_a->high >= span_b->low && span_a->high <= span_b->high)) { + else if (span_a->low < span_b->low && + (span_a->high >= span_b->low && span_a->high <= span_b->high)) { /* Split span 'a' into two parts at the low bound of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Check for overlaps between upper part of span 'a' and lower part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7301,52 +7483,60 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * has been updated in the following clip function (via * all_clips_bounds), there's no need updating the bound box * after each append call in the following codes */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_a->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_a->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_a->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'b' at upper span of span 'a' */ /* Check if there is actually an upper part of span 'b' to split off */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Allocate new span node for upper part of span 'b' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, + span_b->down, span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7362,33 +7552,37 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && span_a->high > span_b->high) { + else if (span_a->low < span_b->low && span_a->high > span_b->high) { /* Split off lower part of span 'a' at lower span of span 'b' */ /* Merge/add lower part of span 'a' with/to a_not_b list */ - if(need_a_not_b) - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (need_a_not_b) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Check for overlaps between middle part of span 'a' and span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7396,50 +7590,58 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_b->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_b->low, span_b->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_b->low, span_b->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' the new span 'a' */ @@ -7453,15 +7655,17 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low >= span_b->low && span_a->high <= span_b->high) { + else if (span_a->low >= span_b->low && span_a->high <= span_b->high) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Check if there is actually a lower part of span 'b' to split off */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* Keep going, nothing to split off */ @@ -7470,16 +7674,19 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Check for overlaps between span 'a' and midle of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7487,52 +7694,60 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_a->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_a->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_a->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Check if there is actually an upper part of span 'b' to split off */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Split off upper part of span 'b' at upper span of span 'a' */ /* Allocate new span node for upper part of spans 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, + span_b->down, span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* And advance span 'a' */ @@ -7547,21 +7762,24 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if((span_a->low >= span_b->low && span_a->low <= span_b->high) && span_a->high > span_b->high) { + else if ((span_a->low >= span_b->low && span_a->low <= span_b->high) && + span_a->high > span_b->high) { /* Check if there is actually a lower part of span 'b' to split off */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Split off lower part of span 'b' at lower span of span 'a' */ /* Merge/add lower part of span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* Keep going, nothing to split off */ @@ -7570,16 +7788,19 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Check for overlaps between lower part of span 'a' and upper part of span 'b' */ /* Make certain both spans either have a down span or both don't have one */ - HDassert((span_a->down != NULL && span_b->down != NULL) || (span_a->down == NULL && span_b->down == NULL)); + HDassert((span_a->down != NULL && span_b->down != NULL) || + (span_a->down == NULL && span_b->down == NULL)); /* If there are no down spans, just add the overlapping area to the a_and_b list */ - if(span_a->down == NULL) { + if (span_a->down == NULL) { /* Merge/add overlapped part with/to a_and_b list */ - if(need_a_and_b) - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (need_a_and_b) + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ - /* If there are down spans, check for the overlap in them and add to each appropriate list */ + /* If there are down spans, check for the overlap in them and add to each appropriate list + */ else { /* NULL out the temporary pointers to clipped areas in down spans */ down_a_not_b = NULL; @@ -7587,50 +7808,58 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s down_b_not_a = NULL; /* Check for overlaps in the 'down spans' of span 'a' & 'b' */ - if(H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) + if (H5S__hyper_clip_spans(span_a->down, span_b->down, selector, ndims - 1, + &down_a_not_b, &down_a_and_b, &down_b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") /* Check for additions to the a_not_b list */ - if(down_a_not_b) { + if (down_a_not_b) { HDassert(need_a_not_b == TRUE); /* Merge/add overlapped part with/to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->high, down_a_not_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_b->high, + down_a_not_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_not_b); } /* end if */ /* Check for additions to the a_and_b list */ - if(down_a_and_b) { + if (down_a_and_b) { HDassert(need_a_and_b == TRUE); /* Merge/add overlapped part with/to a_and_b list */ - if(H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, down_a_and_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(a_and_b, ndims, span_a->low, span_b->high, + down_a_and_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_a_and_b); } /* end if */ /* Check for additions to the b_not_a list */ - if(down_b_not_a) { + if (down_b_not_a) { HDassert(need_b_not_a == TRUE); /* Merge/add overlapped part with/to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_b->high, down_b_not_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(b_not_a, ndims, span_a->low, span_b->high, + down_b_not_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") /* Release the down span tree generated */ H5S__hyper_free_span_info(down_b_not_a); } /* end if */ - } /* end else */ + } /* end else */ /* Split off upper part of span 'a' at upper span of span 'b' */ /* Allocate new span node for upper part of span 'a' */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab span") /* Make upper part of span 'a' into new span 'a' */ @@ -7648,19 +7877,20 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s /* Copy span 'b' and add to b_not_a list */ /* Merge/add span 'b' with/to b_not_a list */ - if(need_b_not_a) - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (need_b_not_a) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance span 'b', leave span 'a' */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end while */ + } /* end while */ /* Clean up 'a' spans which haven't been covered yet */ - if(span_a != NULL && span_b == NULL) { + if (span_a != NULL && span_b == NULL) { /* Check if need to merge/add 'a' spans with/to a_not_b list */ - if(need_a_not_b) { + if (need_a_not_b) { /* (This loop, and the similar one below for 'b' spans, * could be replaced with an optimized routine that quickly * appended the remaining spans to the 'not' list, but @@ -7668,25 +7898,26 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * important use case, it's been left generic, and similar * to other code above. -QAK, 2019/02/01) */ - while(span_a != NULL) { + while (span_a != NULL) { /* Copy span 'a' and add to a_not_b list */ - if(H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(a_not_b, ndims, span_a->low, span_a->high, span_a->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'a' span */ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); } /* end while */ - } /* end if */ + } /* end if */ else { /* Free the span, if it's generated */ - if(recover_a) + if (recover_a) H5S__hyper_free_span(span_a); } /* end else */ - } /* end if */ + } /* end if */ /* Clean up 'b' spans which haven't been covered yet */ - else if(span_a == NULL && span_b != NULL) { + else if (span_a == NULL && span_b != NULL) { /* Check if need to merge/add 'b' spans with/to b_not_a list */ - if(need_b_not_a) { + if (need_b_not_a) { /* (This loop, and the similar one above for 'a' spans, * could be replaced with an optimized routine that quickly * appended the remaining spans to the 'not' list, but @@ -7694,32 +7925,32 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s * important use case, it's been left generic, and similar * to other code above. -QAK, 2019/02/01) */ - while(span_b != NULL) { + while (span_b != NULL) { /* Copy span 'b' and add to b_not_a list */ - if(H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(b_not_a, ndims, span_b->low, span_b->high, span_b->down) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") /* Advance to the next 'b' span */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end while */ - } /* end if */ + } /* end if */ else { /* Free the span, if it's generated */ - if(recover_b) + if (recover_b) H5S__hyper_free_span(span_b); } /* end else */ - } /* end if */ + } /* end if */ else /* Sanity check */ HDassert(span_a == NULL && span_b == NULL); } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_clip_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans_helper @@ -7744,11 +7975,10 @@ H5S__hyper_clip_spans(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * -H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, - unsigned ndims) +H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_spans, unsigned ndims) { H5S_hyper_span_info_t *merged_spans = NULL; /* Pointer to the merged span tree */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -7756,19 +7986,19 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf HDassert((a_spans != NULL && b_spans != NULL) || (a_spans == NULL && b_spans == NULL)); /* Check if the span trees for the 'a' span and the 'b' span are the same */ - if(H5S__hyper_cmp_spans(a_spans, b_spans)) { - if(a_spans == NULL) + if (H5S__hyper_cmp_spans(a_spans, b_spans)) { + if (a_spans == NULL) merged_spans = NULL; else { /* Copy one of the span trees to return */ - if(NULL == (merged_spans = H5S__hyper_copy_span(a_spans, ndims))) + if (NULL == (merged_spans = H5S__hyper_copy_span(a_spans, ndims))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "can't copy hyperslab span tree") } /* end else */ - } /* end if */ + } /* end if */ else { - H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */ - H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ - hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ + H5S_hyper_span_t *span_a; /* Pointer to current span 'a' working on */ + H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */ + hbool_t recover_a, recover_b; /* Flags to indicate when to recover temporary spans */ /* Get the pointers to the 'a' and 'b' span lists */ span_a = a_spans->head; @@ -7778,17 +8008,17 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf recover_a = recover_b = FALSE; /* 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 */ + 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 */ /* Check if the 'a' span is completely before 'b' span */ /* AAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - if(span_a->high < span_b->low) { + if (span_a->high < span_b->low) { /* Merge/add span 'a' with/to the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7799,23 +8029,27 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* AAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && (span_a->high >= span_b->low && span_a->high <= span_b->high)) { + else if (span_a->low < span_b->low && + (span_a->high >= span_b->low && span_a->high <= span_b->high)) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of span 'a' with/to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Merge/add lower part of span 'a' with/to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Get merged span tree for overlapped section */ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -7823,11 +8057,12 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf } /* end else */ /* Check if there is an upper part of span 'b' */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Copy upper part of span 'b' as new span 'b' */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, + span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7842,29 +8077,32 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps the lower & upper bound */ /* of span 'b' */ /* AAAAAAAAAAAAAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low < span_b->low && span_a->high > span_b->high) { + else if (span_a->low < span_b->low && span_a->high > span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of lower & middle parts of span 'a' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Merge/add lower part of span 'a' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->low - 1, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Get merged span tree for overlapped section */ tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -7874,7 +8112,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* Copy upper part of span 'a' as new span 'a' (remember to free) */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ @@ -7888,18 +8127,20 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* AAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if(span_a->low >= span_b->low && span_a->high <= span_b->high) { + else if (span_a->low >= span_b->low && span_a->high <= span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of lower & middle parts of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->high, + span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Check if there is a lower part of span 'b' */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { @@ -7910,7 +8151,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -7918,11 +8160,12 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf } /* end else */ /* Check if there is an upper part of span 'b' */ - if(span_a->high < span_b->high) { + if (span_a->high < span_b->high) { /* Copy upper part of span 'b' as new span 'b' (remember to free) */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, span_b->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_a->high + 1, span_b->high, span_b->down, + span_b->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Advance span 'a' */ @@ -7937,24 +8180,27 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end if */ + } /* end if */ /* Check if span 'a' overlaps only the upper bound */ /* of span 'b' */ /* AAAAAAAAAA */ /* <-----------------------------------> */ /* BBBBBBBBBB */ - else if((span_a->low >= span_b->low && span_a->low <= span_b->high) && span_a->high > span_b->high) { + else if ((span_a->low >= span_b->low && span_a->low <= span_b->high) && + span_a->high > span_b->high) { /* Check if span 'a' and span 'b' down spans are equal */ - if(H5S__hyper_cmp_spans(span_a->down, span_b->down)) { + if (H5S__hyper_cmp_spans(span_a->down, span_b->down)) { /* Merge/add copy of span 'b' to merged spans if so */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { /* Check if there is a lower part of span 'b' */ - if(span_a->low > span_b->low) { + if (span_a->low > span_b->low) { /* Merge/add lower part of span 'b' to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_a->low - 1, + span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") } /* end if */ else { @@ -7965,7 +8211,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf tmp_spans = H5S__hyper_merge_spans_helper(span_a->down, span_b->down, ndims - 1); /* Merge/add overlapped section to merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, tmp_spans) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_b->high, tmp_spans) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Release merged span tree for overlapped section */ @@ -7975,7 +8222,8 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* Copy upper part of span 'a' as new span 'a' */ /* Allocate new span node to append to list */ - if(NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, span_a->next))) + if (NULL == (tmp_span = H5S__hyper_new_span(span_b->high + 1, span_a->high, span_a->down, + span_a->next))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set new span 'a' to tmp_span */ @@ -7991,51 +8239,50 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* BBBBBBBBBB */ else { /* Merge/add span 'b' with the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance span 'b' */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end else */ - } /* end while */ + } /* end while */ /* Clean up 'a' spans which haven't been added to the list of merged spans */ - if(span_a != NULL && span_b == NULL) { - while(span_a != NULL) { + if (span_a != NULL && span_b == NULL) { + while (span_a != NULL) { /* Merge/add all 'a' spans into the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_a->low, span_a->high, span_a->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'a' span, until all processed */ H5S_HYPER_ADVANCE_SPAN(recover_a, span_a, span_a->next); } /* end while */ - } /* end if */ + } /* end if */ /* Clean up 'b' spans which haven't been added to the list of merged spans */ - if(span_a == NULL && span_b != NULL) { - while(span_b != NULL) { + if (span_a == NULL && span_b != NULL) { + while (span_b != NULL) { /* Merge/add all 'b' spans into the merged spans */ - if(H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) + if (H5S__hyper_append_span(&merged_spans, ndims, span_b->low, span_b->high, span_b->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, NULL, "can't allocate hyperslab span") /* Advance to next 'b' span, until all processed */ H5S_HYPER_ADVANCE_SPAN(recover_b, span_b, span_b->next); } /* end while */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ /* Set return value */ ret_value = merged_spans; done: - if(ret_value == NULL) - if(merged_spans) + if (ret_value == NULL) + if (merged_spans) H5S__hyper_free_span_info(merged_spans); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans @@ -8059,7 +8306,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf static herr_t H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8068,7 +8315,7 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) HDassert(new_spans); /* If this is the first span tree in the hyperslab selection, just use it */ - if(space->select.sel_info.hslab->span_lst == NULL) { + if (space->select.sel_info.hslab->span_lst == NULL) { space->select.sel_info.hslab->span_lst = new_spans; space->select.sel_info.hslab->span_lst->count++; } /* end if */ @@ -8076,7 +8323,8 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) H5S_hyper_span_info_t *merged_spans; /* Get the merged spans */ - if(NULL == (merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, new_spans, space->extent.rank))) + if (NULL == (merged_spans = H5S__hyper_merge_spans_helper(space->select.sel_info.hslab->span_lst, + new_spans, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTMERGE, FAIL, "can't merge hyperslab spans") /* Free the previous spans */ @@ -8090,7 +8338,6 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem_helper @@ -8111,10 +8358,9 @@ H5S__hyper_merge_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, - uint64_t op_gen) +H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, uint64_t op_gen) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8122,25 +8368,25 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, HDassert(spans); /* Check if the span tree was already counted */ - if(spans->op_info[op_info_i].op_gen == op_gen) + if (spans->op_info[op_info_i].op_gen == op_gen) /* Just return the # of elements in the already counted span tree */ ret_value = spans->op_info[op_info_i].u.nelmts; - else { /* Count the number of elements in the span tree */ - const H5S_hyper_span_t *span; /* Hyperslab span */ + else { /* Count the number of elements in the span tree */ + const H5S_hyper_span_t *span; /* Hyperslab span */ span = spans->head; - if(NULL == span->down) { - while(span != NULL) { + if (NULL == span->down) { + while (span != NULL) { /* Compute # of elements covered */ ret_value += (span->high - span->low) + 1; /* Advance to next span */ span = span->next; } /* end while */ - } /* end if */ + } /* end if */ else { - while(span != NULL) { - hsize_t nelmts; /* # of elements covered by current span */ + while (span != NULL) { + hsize_t nelmts; /* # of elements covered by current span */ /* Compute # of elements covered */ nelmts = (span->high - span->low) + 1; @@ -8151,7 +8397,7 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, /* Advance to next span */ span = span->next; } /* end while */ - } /* end else */ + } /* end else */ /* Set the operation generation for this span tree, to avoid re-computing */ spans->op_info[op_info_i].op_gen = op_gen; @@ -8163,7 +8409,6 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_nelem_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem @@ -8184,8 +8429,8 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, static hsize_t H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) { - uint64_t op_gen; /* Operation generation value */ - hsize_t ret_value = 0; /* Return value */ + uint64_t op_gen; /* Operation generation value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8203,7 +8448,6 @@ H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_nelem() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_add_disjoint_spans @@ -8230,7 +8474,7 @@ H5S__hyper_spans_nelem(H5S_hyper_span_info_t *spans) static herr_t H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8242,7 +8486,7 @@ H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) space->select.num_elem += H5S__hyper_spans_nelem(new_spans); /* Add the new spans to the existing selection in the dataspace */ - if(H5S__hyper_merge_spans(space, new_spans) < 0) + if (H5S__hyper_merge_spans(space, new_spans) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't merge hyperslabs") /* Free the memory space for new spans */ @@ -8252,7 +8496,6 @@ H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_disjoint_spans */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_make_spans @@ -8279,14 +8522,14 @@ H5S__hyper_add_disjoint_spans(H5S_t *space, H5S_hyper_span_info_t *new_spans) REVISION LOG --------------------------------------------------------------------------*/ static H5S_hyper_span_info_t * -H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride, - const hsize_t *count, const hsize_t *block) +H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride, const hsize_t *count, + 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 */ - int i; /* Counters */ - H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ + 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 */ + int i; /* Counters */ + H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -8298,32 +8541,32 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride HDassert(block); /* Start creating spans in fastest changing dimension */ - for(i = (int)(rank - 1); i >= 0; i--) { - hsize_t curr_low, curr_high; /* Current low & high values */ - hsize_t dim_stride; /* Current dim's stride */ - unsigned u; /* Local index variable */ + for (i = (int)(rank - 1); i >= 0; i--) { + hsize_t curr_low, curr_high; /* Current low & high values */ + hsize_t dim_stride; /* Current dim's stride */ + unsigned u; /* Local index variable */ /* Sanity check */ - if(0 == count[i]) + if (0 == count[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, NULL, "count == 0 is invalid") /* Start a new list in this dimension */ - head = NULL; + head = NULL; last_span = NULL; /* Generate all the span segments for this dimension */ - curr_low = start[i]; - curr_high = start[i] + (block[i] - 1); + curr_low = start[i]; + curr_high = start[i] + (block[i] - 1); dim_stride = stride[i]; - for(u = 0; u < count[i]; u++, curr_low += dim_stride, curr_high += dim_stride) { - H5S_hyper_span_t *span; /* New hyperslab span */ + for (u = 0; u < count[i]; u++, curr_low += dim_stride, curr_high += dim_stride) { + H5S_hyper_span_t *span; /* New hyperslab span */ /* Allocate a span node */ - if(NULL == (span = H5FL_MALLOC(H5S_hyper_span_t))) + if (NULL == (span = H5FL_MALLOC(H5S_hyper_span_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Set the span's basic information */ - span->low = curr_low; + span->low = curr_low; span->high = curr_high; span->next = NULL; @@ -8332,7 +8575,7 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride span->down = down; /* Append to the list of spans in this dimension */ - if(head == NULL) + if (head == NULL) head = span; else last_span->next = span; @@ -8342,11 +8585,11 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride } /* end for */ /* Increment ref. count of shared span */ - if(down != NULL) + if (down != NULL) down->count = (unsigned)count[i]; /* Allocate a span info node */ - if(NULL == (down = H5S__hyper_new_span_info(rank))) + if (NULL == (down = H5S__hyper_new_span_info(rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate hyperslab span") /* Keep the pointer to the next dimension down's completed list */ @@ -8356,19 +8599,21 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride down->tail = last_span; /* Set the low & high bounds for this dimension */ - down->low_bounds[0] = down->head->low; + down->low_bounds[0] = down->head->low; down->high_bounds[0] = down->tail->high; /* Copy bounds from lower dimensions */ /* (head & tail pointers share lower dimensions, so using either is OK) */ - if(head->down) { - H5MM_memcpy(&down->low_bounds[1], &head->down->low_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); - H5MM_memcpy(&down->high_bounds[1], &head->down->high_bounds[0], sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); + if (head->down) { + H5MM_memcpy(&down->low_bounds[1], &head->down->low_bounds[0], + sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); + H5MM_memcpy(&down->high_bounds[1], &head->down->high_bounds[0], + sizeof(hsize_t) * ((rank - 1) - (unsigned)i)); } /* end if */ - } /* end for */ + } /* end for */ /* Indicate that there is a pointer to this tree */ - if(down) + if (down) down->count = 1; /* Success! Return the head of the list in the slowest changing dimension */ @@ -8376,32 +8621,31 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride done: /* cleanup if error (ret_value will be NULL) */ - if(!ret_value) { - if(head || down) { - if(head && down) - if(down->head != head) + if (!ret_value) { + if (head || down) { + if (head && down) + if (down->head != head) down = NULL; do { - if(down) { + if (down) { head = down->head; down = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, down); } /* end if */ down = head->down; - while(head) { + while (head) { last_span = head->next; - head = H5FL_FREE(H5S_hyper_span_t, head); - head = last_span; + head = H5FL_FREE(H5S_hyper_span_t, head); + head = last_span; } /* end while */ - } while(down); + } while (down); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_make_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_update_diminfo @@ -8431,10 +8675,9 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, - const H5S_hyper_dim_t *new_hyper_diminfo) +H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, const H5S_hyper_dim_t *new_hyper_diminfo) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8444,182 +8687,180 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, /* Check for conditions that prevent us from using the fast algorithm here */ /* (and instead require H5S__hyper_rebuild) */ - if(!((op == H5S_SELECT_OR) || (op == H5S_SELECT_XOR)) - || space->select.sel_info.hslab->diminfo_valid != H5S_DIMINFO_VALID_YES - || !space->select.sel_info.hslab->span_lst->head) + if (!((op == H5S_SELECT_OR) || (op == H5S_SELECT_XOR)) || + space->select.sel_info.hslab->diminfo_valid != H5S_DIMINFO_VALID_YES || + !space->select.sel_info.hslab->span_lst->head) space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; else { - H5S_hyper_dim_t tmp_diminfo[H5S_MAX_RANK]; /* Temporary dimension info */ - hbool_t found_nonidentical_dim = FALSE; - unsigned curr_dim; + H5S_hyper_dim_t tmp_diminfo[H5S_MAX_RANK]; /* Temporary dimension info */ + hbool_t found_nonidentical_dim = FALSE; + unsigned curr_dim; /* Copy current diminfo.opt values */ H5MM_memcpy(tmp_diminfo, space->select.sel_info.hslab->diminfo.opt, sizeof(tmp_diminfo)); /* Loop over dimensions */ - for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { + for (curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { /* Check for this being identical */ - if((tmp_diminfo[curr_dim].start != new_hyper_diminfo[curr_dim].start) - || (tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) - || (tmp_diminfo[curr_dim].count != new_hyper_diminfo[curr_dim].count) - || (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block)) { - hsize_t high_start, high_count, high_block; /* The start, count & block values for the higher block */ + if ((tmp_diminfo[curr_dim].start != new_hyper_diminfo[curr_dim].start) || + (tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) || + (tmp_diminfo[curr_dim].count != new_hyper_diminfo[curr_dim].count) || + (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block)) { + hsize_t high_start, high_count, + high_block; /* The start, count & block values for the higher block */ /* Dimension is not identical */ /* Check if we already found a nonidentical dim - only one is * allowed */ - if(found_nonidentical_dim) { + if (found_nonidentical_dim) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check that strides are the same, or count is 1 for one of the * slabs */ - if((tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) - && (tmp_diminfo[curr_dim].count > 1) - && (new_hyper_diminfo[curr_dim].count > 1)) { + if ((tmp_diminfo[curr_dim].stride != new_hyper_diminfo[curr_dim].stride) && + (tmp_diminfo[curr_dim].count > 1) && (new_hyper_diminfo[curr_dim].count > 1)) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Patch tmp_diminfo.stride if its count is 1 */ - if((tmp_diminfo[curr_dim].count == 1) - && (new_hyper_diminfo[curr_dim].count > 1)) + if ((tmp_diminfo[curr_dim].count == 1) && (new_hyper_diminfo[curr_dim].count > 1)) tmp_diminfo[curr_dim].stride = new_hyper_diminfo[curr_dim].stride; /* Determine lowest start, and set tmp_diminfo.start, count and * block to use the lowest, and high_start, high_count and * high_block to use the highest */ - if(tmp_diminfo[curr_dim].start < new_hyper_diminfo[curr_dim].start) { + if (tmp_diminfo[curr_dim].start < new_hyper_diminfo[curr_dim].start) { high_start = new_hyper_diminfo[curr_dim].start; high_count = new_hyper_diminfo[curr_dim].count; high_block = new_hyper_diminfo[curr_dim].block; } /* end if */ else { - high_start = tmp_diminfo[curr_dim].start; + high_start = tmp_diminfo[curr_dim].start; tmp_diminfo[curr_dim].start = new_hyper_diminfo[curr_dim].start; - high_count = tmp_diminfo[curr_dim].count; + high_count = tmp_diminfo[curr_dim].count; tmp_diminfo[curr_dim].count = new_hyper_diminfo[curr_dim].count; - high_block = tmp_diminfo[curr_dim].block; + high_block = tmp_diminfo[curr_dim].block; tmp_diminfo[curr_dim].block = new_hyper_diminfo[curr_dim].block; } /* end else */ /* If count is 1 for both slabs, take different actions */ - if((tmp_diminfo[curr_dim].count == 1) && (high_count == 1)) { + if ((tmp_diminfo[curr_dim].count == 1) && (high_count == 1)) { /* Check for overlap */ - if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) - > high_start) { + if ((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) > high_start) { /* Check operation type */ - if(op == H5S_SELECT_OR) + if (op == H5S_SELECT_OR) /* Merge blocks */ - tmp_diminfo[curr_dim].block = ((high_start + high_block) - >= (tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)) + tmp_diminfo[curr_dim].block = + ((high_start + high_block) >= + (tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block)) ? (high_start + high_block - tmp_diminfo[curr_dim].start) : tmp_diminfo[curr_dim].block; else { /* Block values must be the same */ - if(tmp_diminfo[curr_dim].block != high_block) { + if (tmp_diminfo[curr_dim].block != high_block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* XOR - overlap creates 2 blocks */ tmp_diminfo[curr_dim].stride = high_block; - tmp_diminfo[curr_dim].count = 2; - tmp_diminfo[curr_dim].block = high_start - tmp_diminfo[curr_dim].start; + tmp_diminfo[curr_dim].count = 2; + tmp_diminfo[curr_dim].block = high_start - tmp_diminfo[curr_dim].start; } /* end else */ - } /* end if */ - else if((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) - == high_start) + } /* end if */ + else if ((tmp_diminfo[curr_dim].start + tmp_diminfo[curr_dim].block) == high_start) /* Blocks border, merge them */ tmp_diminfo[curr_dim].block += high_block; else { /* Distinct blocks */ /* Block values must be the same */ - if(tmp_diminfo[curr_dim].block != high_block) { + if (tmp_diminfo[curr_dim].block != high_block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Create strided selection */ tmp_diminfo[curr_dim].stride = high_start - tmp_diminfo[curr_dim].start; - tmp_diminfo[curr_dim].count = 2; + tmp_diminfo[curr_dim].count = 2; } /* end else */ - } /* end if */ + } /* 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 != new_hyper_diminfo[curr_dim].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)) { + if ((tmp_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride) != + (new_hyper_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check operation type */ - if(op == H5S_SELECT_OR) { + if (op == H5S_SELECT_OR) { /* Make sure the slabs border or overlap */ - if(high_start > (tmp_diminfo[curr_dim].start - + (tmp_diminfo[curr_dim].count - * tmp_diminfo[curr_dim].stride))) { + 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 */ - } /* end if */ + } /* end if */ else /* 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 */ + 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 */ /* Set count for combined selection */ - tmp_diminfo[curr_dim].count = ((high_start - - tmp_diminfo[curr_dim].start) - / tmp_diminfo[curr_dim].stride) + high_count; + tmp_diminfo[curr_dim].count = + ((high_start - tmp_diminfo[curr_dim].start) / tmp_diminfo[curr_dim].stride) + + high_count; } /* end else */ /* Indicate that we found a nonidentical dim */ found_nonidentical_dim = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* Check if we succeeded, if so, set the new diminfo values */ - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) - for(curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) + for (curr_dim = 0; curr_dim < space->extent.rank; curr_dim++) { hsize_t tmp_high_bound; /* Set the new diminfo values */ - space->select.sel_info.hslab->diminfo.app[curr_dim].start = space->select.sel_info.hslab->diminfo.opt[curr_dim].start = tmp_diminfo[curr_dim].start; + space->select.sel_info.hslab->diminfo.app[curr_dim].start = + space->select.sel_info.hslab->diminfo.opt[curr_dim].start = tmp_diminfo[curr_dim].start; HDassert(tmp_diminfo[curr_dim].stride > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].stride = space->select.sel_info.hslab->diminfo.opt[curr_dim].stride = tmp_diminfo[curr_dim].stride; + space->select.sel_info.hslab->diminfo.app[curr_dim].stride = + space->select.sel_info.hslab->diminfo.opt[curr_dim].stride = tmp_diminfo[curr_dim].stride; HDassert(tmp_diminfo[curr_dim].count > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].count = space->select.sel_info.hslab->diminfo.opt[curr_dim].count = tmp_diminfo[curr_dim].count; + space->select.sel_info.hslab->diminfo.app[curr_dim].count = + space->select.sel_info.hslab->diminfo.opt[curr_dim].count = tmp_diminfo[curr_dim].count; HDassert(tmp_diminfo[curr_dim].block > 0); - space->select.sel_info.hslab->diminfo.app[curr_dim].block = space->select.sel_info.hslab->diminfo.opt[curr_dim].block = tmp_diminfo[curr_dim].block; + space->select.sel_info.hslab->diminfo.app[curr_dim].block = + space->select.sel_info.hslab->diminfo.opt[curr_dim].block = tmp_diminfo[curr_dim].block; /* Check for updating the low & high bounds */ - if(tmp_diminfo[curr_dim].start < space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) + if (tmp_diminfo[curr_dim].start < space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) space->select.sel_info.hslab->diminfo.low_bounds[curr_dim] = tmp_diminfo[curr_dim].start; - tmp_high_bound = tmp_diminfo[curr_dim].start + - (tmp_diminfo[curr_dim].block - 1) + - (tmp_diminfo[curr_dim].stride * (tmp_diminfo[curr_dim].count - 1)); - if(tmp_high_bound > space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) + tmp_high_bound = tmp_diminfo[curr_dim].start + (tmp_diminfo[curr_dim].block - 1) + + (tmp_diminfo[curr_dim].stride * (tmp_diminfo[curr_dim].count - 1)); + if (tmp_high_bound > space->select.sel_info.hslab->diminfo.low_bounds[curr_dim]) space->select.sel_info.hslab->diminfo.high_bounds[curr_dim] = tmp_high_bound; } /* end for */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_update_diminfo() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild_helper @@ -8646,14 +8887,14 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, static hbool_t H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t span_slab_info[]) { - const H5S_hyper_span_t *span; /* Hyperslab span */ - const H5S_hyper_span_t *prev_span; /* Previous span in list */ - hsize_t start; /* Starting element for this dimension */ - hsize_t stride; /* Stride for this dimension */ - hsize_t block; /* Block size for this dimension */ - hsize_t prev_low; /* Low bound for previous span */ - size_t spancount; /* Number of spans encountered in this dimension */ - hbool_t ret_value = TRUE; /* Return value */ + const H5S_hyper_span_t *span; /* Hyperslab span */ + const H5S_hyper_span_t *prev_span; /* Previous span in list */ + hsize_t start; /* Starting element for this dimension */ + hsize_t stride; /* Stride for this dimension */ + hsize_t block; /* Block size for this dimension */ + hsize_t prev_low; /* Low bound for previous span */ + size_t spancount; /* Number of spans encountered in this dimension */ + hbool_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8661,15 +8902,15 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp HDassert(spans); /* Initialization */ - span = spans->head; - stride = 1; - prev_low = 0; + span = spans->head; + stride = 1; + prev_low = 0; spancount = 0; /* Get "canonical" down span information */ - if(span->down) + if (span->down) /* Go to the next down span and check whether the selection can be rebuilt */ - if(!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1])) + if (!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1])) HGOTO_DONE(FALSE) /* Assign the initial starting point & block size for this dimension */ @@ -8678,31 +8919,31 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp /* Loop the spans */ prev_span = NULL; - while(span) { - if(spancount > 0) { - hsize_t curr_stride; /* Current stride from previous span */ - hsize_t curr_block; /* Block size of current span */ + while (span) { + if (spancount > 0) { + hsize_t curr_stride; /* Current stride from previous span */ + hsize_t curr_block; /* Block size of current span */ /* Sanity check */ HDassert(prev_span); /* Check that down spans match current slab info */ /* (Can skip check if previous span's down pointer is same as current one) */ - if(span->down && prev_span->down != span->down) - if(!H5S__hyper_cmp_spans(span->down, prev_span->down)) + if (span->down && prev_span->down != span->down) + if (!H5S__hyper_cmp_spans(span->down, prev_span->down)) HGOTO_DONE(FALSE) /* Obtain values for stride and block */ curr_stride = span->low - prev_low; - curr_block = (span->high - span->low) + 1; + curr_block = (span->high - span->low) + 1; /* Compare stride and block for this span. To compare stride, * three spans are needed. Account for the first two spans. */ - if(curr_block != block) + if (curr_block != block) HGOTO_DONE(FALSE) - if(spancount > 1) { - if(stride != curr_stride) + if (spancount > 1) { + if (stride != curr_stride) HGOTO_DONE(FALSE) } /* end if */ else @@ -8714,7 +8955,7 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp /* Advance to next span */ prev_span = span; - span = span->next; + span = span->next; spancount++; } /* end while */ @@ -8728,7 +8969,6 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_rebuild_helper() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild @@ -8763,14 +9003,17 @@ H5S__hyper_rebuild(H5S_t *space) /* Check whether the slab can be rebuilt */ /* (Only regular selection can be rebuilt. If yes, fill in correct values) */ - if(FALSE == H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst, rebuilt_slab_info)) + if (FALSE == H5S__hyper_rebuild_helper(space->select.sel_info.hslab->span_lst, rebuilt_slab_info)) space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_IMPOSSIBLE; else { /* Set the dimension info & bounds for the dataspace, from the rebuilt info */ H5MM_memcpy(space->select.sel_info.hslab->diminfo.app, rebuilt_slab_info, sizeof(rebuilt_slab_info)); H5MM_memcpy(space->select.sel_info.hslab->diminfo.opt, rebuilt_slab_info, sizeof(rebuilt_slab_info)); - H5MM_memcpy(space->select.sel_info.hslab->diminfo.low_bounds, space->select.sel_info.hslab->span_lst->low_bounds, sizeof(hsize_t) * space->extent.rank); - H5MM_memcpy(space->select.sel_info.hslab->diminfo.high_bounds, space->select.sel_info.hslab->span_lst->high_bounds, sizeof(hsize_t) * space->extent.rank); + H5MM_memcpy(space->select.sel_info.hslab->diminfo.low_bounds, + space->select.sel_info.hslab->span_lst->low_bounds, sizeof(hsize_t) * space->extent.rank); + H5MM_memcpy(space->select.sel_info.hslab->diminfo.high_bounds, + space->select.sel_info.hslab->span_lst->high_bounds, + sizeof(hsize_t) * space->extent.rank); space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES; } /* end else */ @@ -8778,7 +9021,6 @@ H5S__hyper_rebuild(H5S_t *space) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_rebuild() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_generate_spans @@ -8800,12 +9042,12 @@ H5S__hyper_rebuild(H5S_t *space) static herr_t H5S__hyper_generate_spans(H5S_t *space) { - hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ - hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ + hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8813,31 +9055,30 @@ H5S__hyper_generate_spans(H5S_t *space) HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Get the diminfo */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Check for unlimited dimension and return error */ /* These should be able to be converted to assertions once everything * that calls this function checks for unlimited selections first * (especially the new hyperslab API) -NAF */ - if(space->select.sel_info.hslab->diminfo.opt[u].count == H5S_UNLIMITED) + if (space->select.sel_info.hslab->diminfo.opt[u].count == H5S_UNLIMITED) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited count") - if(space->select.sel_info.hslab->diminfo.opt[u].block == H5S_UNLIMITED) + if (space->select.sel_info.hslab->diminfo.opt[u].block == H5S_UNLIMITED) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "can't generate spans with unlimited block") - tmp_start[u] = space->select.sel_info.hslab->diminfo.opt[u].start; + tmp_start[u] = space->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Build the hyperslab information also */ - if(H5S__generate_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_generate_spans() */ - /*-------------------------------------------------------------------------- NAME H5S__check_spans_overlap @@ -8857,10 +9098,9 @@ H5S__hyper_generate_spans(H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t -H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, - const H5S_hyper_span_info_t *spans2) +H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, const H5S_hyper_span_info_t *spans2) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -8869,23 +9109,23 @@ H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, HDassert(spans2); /* Use low & high bounds to try to avoid spinning through the span lists */ - if(H5S_RANGE_OVERLAP(spans1->low_bounds[0], spans1->high_bounds[0], - spans2->low_bounds[0], spans2->high_bounds[0])) { - H5S_hyper_span_t *span1, *span2; /* Hyperslab spans */ + if (H5S_RANGE_OVERLAP(spans1->low_bounds[0], spans1->high_bounds[0], spans2->low_bounds[0], + spans2->high_bounds[0])) { + H5S_hyper_span_t *span1, *span2; /* Hyperslab spans */ /* Walk over spans, comparing them for overlap */ span1 = spans1->head; span2 = spans2->head; - while(span1 && span2) { + while (span1 && span2) { /* Check current two spans for overlap */ - if(H5S_RANGE_OVERLAP(span1->low, span1->high, span2->low, span2->high)) { + if (H5S_RANGE_OVERLAP(span1->low, span1->high, span2->low, span2->high)) { /* Check for spans in lowest dimension already */ - if(span1->down) { + if (span1->down) { /* Sanity check */ HDassert(span2->down); /* Check lower dimensions for overlap */ - if(H5S__check_spans_overlap(span1->down, span2->down)) + if (H5S__check_spans_overlap(span1->down, span2->down)) HGOTO_DONE(TRUE); } /* end if */ else @@ -8893,32 +9133,31 @@ H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, } /* end if */ /* Advance one of the spans */ - if(span1->high <= span2->high) { + if (span1->high <= span2->high) { /* Advance span1, unless it would be off the list and span2 has more nodes */ - if(NULL == span1->next && NULL != span2->next) + if (NULL == span1->next && NULL != span2->next) span2 = span2->next; else span1 = span1->next; } /* end if */ else { /* Advance span2, unless it would be off the list and span1 has more nodes */ - if(NULL == span2->next && NULL != span1->next) + if (NULL == span2->next && NULL != span1->next) span1 = span1->next; else span2 = span2->next; } /* end else */ - } /* end while */ + } /* end while */ /* Make certain we've exhausted our comparisons */ HDassert((NULL == span1 && (NULL != span2 && NULL == span2->next)) || - ((NULL != span1 && NULL == span1->next) && NULL == span2)); + ((NULL != span1 && NULL == span1->next) && NULL == span2)); } /* end of */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__check_spans_overlap() */ - /*-------------------------------------------------------------------------- NAME H5S__fill_in_new_space @@ -8949,16 +9188,17 @@ H5S__check_spans_overlap(const H5S_hyper_span_info_t *spans1, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, - H5S_hyper_span_info_t *space2_span_lst, hbool_t can_own_span2, - hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result) +H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, H5S_hyper_span_info_t *space2_span_lst, + hbool_t can_own_span2, hbool_t *span2_owned, hbool_t *updated_spans, H5S_t **result) { - H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ - H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */ - H5S_hyper_span_info_t *b_not_a = NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ - hbool_t overlapped = FALSE; /* Whether selections overlap */ + H5S_hyper_span_info_t *a_not_b = + NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ + H5S_hyper_span_info_t *a_and_b = NULL; /* Span tree for hyperslab spans in both old and new span trees */ + H5S_hyper_span_info_t *b_not_a = + NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ + hbool_t overlapped = FALSE; /* Whether selections overlap */ hbool_t is_result_new = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -8971,39 +9211,40 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, HDassert(span2_owned); /* Reset flags to return */ - *span2_owned = FALSE; + *span2_owned = FALSE; *updated_spans = FALSE; /* The result shares the same info from space1 */ - if(*result == NULL) { - if(NULL == ((*result) = H5S_copy(space1, TRUE, TRUE))) + if (*result == NULL) { + if (NULL == ((*result) = H5S_copy(space1, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") space1->select.sel_info.hslab->span_lst->count--; (*result)->select.sel_info.hslab->span_lst = NULL; - is_result_new = TRUE; + is_result_new = TRUE; } /* end if */ /* Check both spaces to see if they overlap */ overlapped = H5S__check_spans_overlap(space1->select.sel_info.hslab->span_lst, space2_span_lst); - if(!overlapped) { - switch(op) { + if (!overlapped) { + switch (op) { case H5S_SELECT_OR: case H5S_SELECT_XOR: /* Add the new disjoint spans to the space */ /* Copy of space1's spans to *result, and another copy of space2's spans */ - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); - if(!can_own_span2) { + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (!can_own_span2) { b_not_a = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); - if(H5S__hyper_add_disjoint_spans(*result, b_not_a) < 0) + if (H5S__hyper_add_disjoint_spans(*result, b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") /* The new_spans are now owned by 'space', so they should not be released */ b_not_a = NULL; } /* end if */ else { - if(H5S__hyper_add_disjoint_spans(*result, space2_span_lst) < 0) + if (H5S__hyper_add_disjoint_spans(*result, space2_span_lst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") *span2_owned = TRUE; } /* end else */ @@ -9014,21 +9255,22 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, case H5S_SELECT_AND: /* Convert *result to "none" selection */ - if(H5S_select_none(*result) < 0) + if (H5S_select_none(*result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); case H5S_SELECT_NOTB: /* Copy space1's spans to *result */ - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); /* Indicate that the spans changed */ *updated_spans = TRUE; break; case H5S_SELECT_NOTA: - if(!is_result_new) { + if (!is_result_new) { HDassert(space1 == *result); /* Free the current selection */ @@ -9037,11 +9279,12 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end if */ /* Copy space2's spans to *result */ - if(!can_own_span2) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); + if (!can_own_span2) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space2_span_lst, space1->extent.rank); else { (*result)->select.sel_info.hslab->span_lst = space2_span_lst; - *span2_owned = TRUE; + *span2_owned = TRUE; } /* end else */ /* Reset the number of items in selection */ @@ -9059,12 +9302,12 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ + } /* end if */ else { - unsigned selector = 0; /* Select which clipping spans to generate */ + unsigned selector = 0; /* Select which clipping spans to generate */ /* Generate mask for clip operation depending on the op */ - switch(op) { + switch (op) { case H5S_SELECT_OR: /* a + b_not_a */ selector = H5S_HYPER_COMPUTE_B_NOT_A; break; @@ -9095,21 +9338,21 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end switch */ /* Generate lists of spans which overlap and don't overlap */ - if(H5S__hyper_clip_spans(space1->select.sel_info.hslab->span_lst, - space2_span_lst, selector, space1->extent.rank, - &a_not_b, &a_and_b, &b_not_a) < 0) + if (H5S__hyper_clip_spans(space1->select.sel_info.hslab->span_lst, space2_span_lst, selector, + space1->extent.rank, &a_not_b, &a_and_b, &b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information") - switch(op) { + switch (op) { case H5S_SELECT_OR: - if(is_result_new) - (*result)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); + if (is_result_new) + (*result)->select.sel_info.hslab->span_lst = + H5S__hyper_copy_span(space1->select.sel_info.hslab->span_lst, space1->extent.rank); break; case H5S_SELECT_AND: case H5S_SELECT_XOR: case H5S_SELECT_NOTB: case H5S_SELECT_NOTA: - if(!is_result_new) { + if (!is_result_new) { HDassert(space1 == *result); /* Free the current selection */ @@ -9132,7 +9375,7 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, } /* end switch */ /* Check if there are any non-overlapped selections */ - if(a_not_b) { + if (a_not_b) { /* Other than OR, the span_lst is set to NULL. And in OR, * a_not_b is not needed */ @@ -9152,7 +9395,7 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, a_not_b = NULL; } /* end if */ - if(a_and_b) { + if (a_and_b) { /** * 1. Other than OR, the span_lst is set to NULL. And in OR, * a_and_b is not needed @@ -9175,9 +9418,9 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, a_and_b = NULL; } /* end if */ - if(b_not_a) { + if (b_not_a) { /* Merge the b_not_a spans into the result dataspace */ - if(H5S__hyper_merge_spans(*result, b_not_a) < 0) + if (H5S__hyper_merge_spans(*result, b_not_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslabs") /* Update the number of elements in current selection */ @@ -9186,10 +9429,10 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, /* Indicate that the spans were updated */ *updated_spans = TRUE; } /* end if */ - } /* end else for the case the new span overlaps with the old (i.e. space) */ + } /* end else for the case the new span overlaps with the old (i.e. space) */ /* Check if the spans weren't updated, and reset selection if so */ - if(!*updated_spans) { + if (!*updated_spans) { /* If updated_spans remains FALSE as in this branch, it means the * result has been cleared in XOR / AND / NOTB / NOTA cases, and the * result is a copy of the dataspace in the OR case. @@ -9198,26 +9441,25 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, * span trees (i.e. a_not_b, a_and_b, and b_not_a), the * updated_spans must be TRUE. */ - if(H5S_SELECT_OR != op) { + if (H5S_SELECT_OR != op) { /* Convert *result to "none" selection */ - if(H5S_select_none(*result) < 0) + if (H5S_select_none(*result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ - } /* end if */ + } /* end if */ done: /* Free resources */ - if(a_not_b) + if (a_not_b) H5S__hyper_free_span_info(a_not_b); - if(a_and_b) + if (a_and_b) H5S__hyper_free_span_info(a_and_b); - if(b_not_a) + if (b_not_a) H5S__hyper_free_span_info(b_not_a); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_new_space() */ - /*------------------------------------------------------------------------- * Function: H5S__generate_hyperlab * @@ -9231,11 +9473,11 @@ H5S__fill_in_new_space(H5S_t *space1, H5S_seloper_t op, *------------------------------------------------------------------------- */ static herr_t -H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { H5S_hyper_span_info_t *new_spans = NULL; /* Span tree for new hyperslab */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9248,13 +9490,13 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HDassert(block); /* Generate span tree for new hyperslab information */ - if(NULL == (new_spans = H5S__hyper_make_spans(space->extent.rank, start, stride, count, block))) + if (NULL == (new_spans = H5S__hyper_make_spans(space->extent.rank, start, stride, count, block))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information") /* Generate list of blocks to add/remove based on selection operation */ - if(op == H5S_SELECT_SET) { + if (op == H5S_SELECT_SET) { /* Free current selection */ - if(NULL != space->select.sel_info.hslab->span_lst) + if (NULL != space->select.sel_info.hslab->span_lst) H5S__hyper_free_span_info(space->select.sel_info.hslab->span_lst); /* Set the hyperslab selection to the new span tree */ @@ -9268,46 +9510,45 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end if */ else { hbool_t new_spans_owned = FALSE; - hbool_t updated_spans = FALSE; + hbool_t updated_spans = FALSE; /* Generate new spans for space */ - if(H5S__fill_in_new_space(space, op, new_spans, TRUE, &new_spans_owned, &updated_spans, &space) < 0) + if (H5S__fill_in_new_space(space, op, new_spans, TRUE, &new_spans_owned, &updated_spans, &space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't generate the specified hyperslab") /* Check if the spans were updated by H5S__fill_in_new_space */ - if(updated_spans) { + if (updated_spans) { H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ /* Sanity check */ HDassert(space->select.sel_info.hslab->span_lst->head); /* Build diminfo struct */ - for(u = 0; u extent.rank; u++) { - new_hyper_diminfo[u].start = start[u]; + for (u = 0; u < space->extent.rank; u++) { + new_hyper_diminfo[u].start = start[u]; new_hyper_diminfo[u].stride = stride[u]; - new_hyper_diminfo[u].count = count[u]; - new_hyper_diminfo[u].block = block[u]; + new_hyper_diminfo[u].count = count[u]; + new_hyper_diminfo[u].block = block[u]; } /* end for */ /* Update space's dim info */ - if(H5S__hyper_update_diminfo(space, op, new_hyper_diminfo) < 0) + if (H5S__hyper_update_diminfo(space, op, new_hyper_diminfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") } /* end if */ /* Indicate that the new_spans are owned, there's no need to free */ - if(new_spans_owned) + if (new_spans_owned) new_spans = NULL; } /* end else */ done: - if(new_spans) + if (new_spans) H5S__hyper_free_span_info(new_spans); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__generate_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__set_regular_hyperslab * @@ -9321,12 +9562,12 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], *------------------------------------------------------------------------- */ herr_t -H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], - const hsize_t *app_stride, const hsize_t app_count[], const hsize_t *app_block, - const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block) +H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], const hsize_t *app_stride, + const hsize_t app_count[], const hsize_t *app_block, const hsize_t *opt_stride, + const hsize_t opt_count[], const hsize_t *opt_block) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -9341,27 +9582,27 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], HDassert(opt_block); /* If we are setting a new selection, remove current selection first */ - if(H5S_SELECT_RELEASE(space) < 0) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate space for the hyperslab selection information */ - if(NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) + if (NULL == (space->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set the diminfo */ - space->select.num_elem = 1; + space->select.num_elem = 1; space->select.sel_info.hslab->unlim_dim = -1; - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Set application and optimized hyperslab info */ - space->select.sel_info.hslab->diminfo.app[u].start = start[u]; + space->select.sel_info.hslab->diminfo.app[u].start = start[u]; space->select.sel_info.hslab->diminfo.app[u].stride = app_stride[u]; - space->select.sel_info.hslab->diminfo.app[u].count = app_count[u]; - space->select.sel_info.hslab->diminfo.app[u].block = app_block[u]; + space->select.sel_info.hslab->diminfo.app[u].count = app_count[u]; + space->select.sel_info.hslab->diminfo.app[u].block = app_block[u]; - space->select.sel_info.hslab->diminfo.opt[u].start = start[u]; + space->select.sel_info.hslab->diminfo.opt[u].start = start[u]; space->select.sel_info.hslab->diminfo.opt[u].stride = opt_stride[u]; - space->select.sel_info.hslab->diminfo.opt[u].count = opt_count[u]; - space->select.sel_info.hslab->diminfo.opt[u].block = opt_block[u]; + space->select.sel_info.hslab->diminfo.opt[u].count = opt_count[u]; + space->select.sel_info.hslab->diminfo.opt[u].block = opt_block[u]; /* Update # of elements selected */ space->select.num_elem *= (opt_count[u] * opt_block[u]); @@ -9370,20 +9611,21 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], space->select.sel_info.hslab->diminfo.low_bounds[u] = start[u]; /* Check for unlimited dimension & set high bound */ - if((app_count[u] == H5S_UNLIMITED) || (app_block[u] == H5S_UNLIMITED)) { - space->select.sel_info.hslab->unlim_dim = (int)u; + if ((app_count[u] == H5S_UNLIMITED) || (app_block[u] == H5S_UNLIMITED)) { + space->select.sel_info.hslab->unlim_dim = (int)u; space->select.sel_info.hslab->diminfo.high_bounds[u] = H5S_UNLIMITED; } /* end if */ else - space->select.sel_info.hslab->diminfo.high_bounds[u] = start[u] + opt_stride[u] * (opt_count[u] - 1) + (opt_block[u] - 1); + space->select.sel_info.hslab->diminfo.high_bounds[u] = + start[u] + opt_stride[u] * (opt_count[u] - 1) + (opt_block[u] - 1); } /* end for */ /* Handle unlimited selections */ - if(space->select.sel_info.hslab->unlim_dim >= 0) { + if (space->select.sel_info.hslab->unlim_dim >= 0) { /* Calculate num_elem_non_unlim */ space->select.sel_info.hslab->num_elem_non_unlim = (hsize_t)1; - for(u = 0; u < space->extent.rank; u++) - if((int)u != space->select.sel_info.hslab->unlim_dim) + for (u = 0; u < space->extent.rank; u++) + if ((int)u != space->select.sel_info.hslab->unlim_dim) space->select.sel_info.hslab->num_elem_non_unlim *= (opt_count[u] * opt_block[u]); /* Update num_elem */ @@ -9403,7 +9645,6 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__set_regular_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__hyper_regular_and_single_block * @@ -9421,16 +9662,15 @@ H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], *------------------------------------------------------------------------- */ static herr_t -H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], - const hsize_t block[]) +H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], const hsize_t block[]) { - hsize_t select_end, block_end; /* End of block & selection */ - hbool_t single_block; /* Whether the selection is a single block */ - hbool_t overlap; /* Whether block & selection overlap */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t select_end, block_end; /* End of block & selection */ + hbool_t single_block; /* Whether the selection is a single block */ + hbool_t overlap; /* Whether block & selection overlap */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -9439,26 +9679,27 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], /* Check for single block selection in dataspace */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(1 != space->select.sel_info.hslab->diminfo.opt[u].count) { + for (u = 0; u < space->extent.rank; u++) + if (1 != space->select.sel_info.hslab->diminfo.opt[u].count) { single_block = FALSE; break; } /* end if */ /* Perform different optimizations, based on type of regular selection */ - if(single_block) { - hsize_t new_start[H5S_MAX_RANK]; /* New starting coordinate */ - hsize_t new_block[H5S_MAX_RANK]; /* New block size */ + if (single_block) { + hsize_t new_start[H5S_MAX_RANK]; /* New starting coordinate */ + hsize_t new_block[H5S_MAX_RANK]; /* New block size */ /* Check for overlap and compute new start offset & block sizes */ overlap = TRUE; - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Compute the end of the selection & block in this dimension */ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u]; - block_end = (start[u] + block[u]) - 1; + block_end = (start[u] + block[u]) - 1; /* Check for overlap */ - if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) { + if (!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], + block_end)) { overlap = FALSE; break; } /* end if */ @@ -9469,125 +9710,122 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], } /* end for */ /* Check for overlap of selection & block */ - if(overlap) { + if (overlap) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, new_start, H5S_hyper_ones_g, H5S_hyper_ones_g, new_block, - H5S_hyper_ones_g, H5S_hyper_ones_g, new_block) < 0) + if (H5S__set_regular_hyperslab(space, new_start, H5S_hyper_ones_g, H5S_hyper_ones_g, new_block, + H5S_hyper_ones_g, H5S_hyper_ones_g, new_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") } /* end if */ 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") + if (H5S_select_none(space) < 0) + 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 */ hsize_t new_count[H5S_MAX_RANK]; /* New count for hyperslab selection */ - hsize_t stride[H5S_MAX_RANK]; /* Stride for hyperslab selection */ + hsize_t stride[H5S_MAX_RANK]; /* Stride for hyperslab selection */ hsize_t new_block[H5S_MAX_RANK]; /* New block for hyperslab selection */ - hbool_t partial_first_span; /* Whether first span in intersection is partial */ - hbool_t partial_last_span; /* Whether last span in intersection is partial */ + hbool_t partial_first_span; /* Whether first span in intersection is partial */ + hbool_t partial_last_span; /* Whether last span in intersection is partial */ /* Iterate over selection, checking for overlap and computing first / last * span that intersects with the block. */ - overlap = TRUE; + overlap = TRUE; partial_first_span = FALSE; - partial_last_span = FALSE; - for(u = 0; u < space->extent.rank; u++) { - hsize_t first_span_start, first_span_end; /* Start / end of first span */ + partial_last_span = FALSE; + for (u = 0; u < space->extent.rank; u++) { + hsize_t first_span_start, first_span_end; /* Start / end of first span */ hsize_t last_span_start, last_span_end; /* Start / end of last span */ - hsize_t nstride; /* Number of strides into the selection */ + hsize_t nstride; /* Number of strides into the selection */ /* Compute the end of the selection & block in this dimension */ select_end = space->select.sel_info.hslab->diminfo.high_bounds[u]; - block_end = (start[u] + block[u]) - 1; + block_end = (start[u] + block[u]) - 1; /* Check for overlap */ - if(!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], block_end)) { + if (!H5S_RANGE_OVERLAP(space->select.sel_info.hslab->diminfo.opt[u].start, select_end, start[u], + block_end)) { overlap = FALSE; break; } /* end if */ /* Find first span that is before or overlaps with start of block */ - if(space->select.sel_info.hslab->diminfo.opt[u].start >= start[u]) { + if (space->select.sel_info.hslab->diminfo.opt[u].start >= start[u]) { /* Calculate start & end of first span */ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start; - first_span_end = (first_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + first_span_end = (first_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if first span overlaps _end_ of block */ - if(block_end >= first_span_start && block_end <= first_span_end) + if (block_end >= first_span_start && block_end <= first_span_end) partial_first_span = TRUE; } /* end if */ else { - hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ + hsize_t adj_start; /* Start coord, adjusted for hyperslab selection parameters */ /* Adjust start coord for selection's 'start' offset */ adj_start = start[u] - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_start / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; /* Calculate start & end of first span */ first_span_start = space->select.sel_info.hslab->diminfo.opt[u].start + - (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); - first_span_end = (first_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); + first_span_end = (first_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if first span overlaps start of block */ - if(first_span_start < start[u] && first_span_end >= start[u]) + if (first_span_start < start[u] && first_span_end >= start[u]) partial_first_span = TRUE; /* Advance first span to start higher than block's start, * if it's not partial. */ - if(first_span_end < start[u]) { + if (first_span_end < start[u]) { first_span_start += space->select.sel_info.hslab->diminfo.opt[u].stride; first_span_end += space->select.sel_info.hslab->diminfo.opt[u].stride; } /* end if */ - } /* end else */ + } /* end else */ /* Find last span that is before or overlaps with end of block */ - if(select_end < block_end) { + if (select_end < block_end) { /* Calculate start & end of last span */ - last_span_start = (select_end - - space->select.sel_info.hslab->diminfo.opt[u].block) + 1; - last_span_end = select_end; + last_span_start = (select_end - space->select.sel_info.hslab->diminfo.opt[u].block) + 1; + last_span_end = select_end; /* Check if last span overlaps _start_ of block */ - if(start[u] >= last_span_start && start[u] <= last_span_end) + if (start[u] >= last_span_start && start[u] <= last_span_end) partial_last_span = TRUE; } /* end if */ else { - hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ + hsize_t adj_end; /* End coord, adjusted for hyperslab selection parameters */ /* Adjust end coord for selection's 'start' offset */ adj_end = block_end - space->select.sel_info.hslab->diminfo.opt[u].start; /* Compute # of strides into the selection */ - if(space->select.sel_info.hslab->diminfo.opt[u].count > 1) + if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) nstride = adj_end / space->select.sel_info.hslab->diminfo.opt[u].stride; else nstride = 0; /* Calculate start & end of last span */ last_span_start = space->select.sel_info.hslab->diminfo.opt[u].start + - (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); - last_span_end = (last_span_start + - space->select.sel_info.hslab->diminfo.opt[u].block) - 1; + (nstride * space->select.sel_info.hslab->diminfo.opt[u].stride); + last_span_end = (last_span_start + space->select.sel_info.hslab->diminfo.opt[u].block) - 1; /* Check if last span overlaps end of block */ - if(block_end >= last_span_start && block_end <= last_span_end) + if (block_end >= last_span_start && block_end <= last_span_end) partial_last_span = TRUE; } /* end else */ /* Check if no spans are inside block */ /* (Can happen when block falls in "gap" between spans) */ - if(last_span_end < start[u]) { + if (last_span_end < start[u]) { overlap = FALSE; break; } /* end if */ @@ -9597,9 +9835,10 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], /* Compute new start / count / block values */ new_start[u] = first_span_start; - if(last_span_start != first_span_start) + if (last_span_start != first_span_start) new_count[u] = ((last_span_start - first_span_start) / - space->select.sel_info.hslab->diminfo.opt[u].stride) + 1; + space->select.sel_info.hslab->diminfo.opt[u].stride) + + 1; else new_count[u] = 1; new_block[u] = space->select.sel_info.hslab->diminfo.opt[u].block; @@ -9609,35 +9848,35 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], } /* end for */ /* Check for overlap of selection & block */ - if(overlap) { + if (overlap) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, new_start, stride, new_count, new_block, - stride, new_count, new_block) < 0) + if (H5S__set_regular_hyperslab(space, new_start, stride, new_count, new_block, stride, new_count, + new_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") /* If there's a partial first or last span, have to 'AND' against selection */ - if(partial_first_span || partial_last_span) { + if (partial_first_span || partial_last_span) { /* Generate span tree for regular selection */ - if(H5S__hyper_generate_spans(space) < 0) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* 'AND' against block */ - if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end if */ - } /* end if */ + } /* end if */ else { /* Selection & block don't overlap, set to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_regular_and_single_block() */ - /*------------------------------------------------------------------------- * Function: H5S_select_hyperslab * @@ -9651,18 +9890,18 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], *------------------------------------------------------------------------- */ herr_t -H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block) +H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, + const hsize_t count[], const hsize_t *block) { - hsize_t int_stride[H5S_MAX_RANK]; /* Internal storage for stride information */ - hsize_t int_count[H5S_MAX_RANK]; /* Internal storage for count information */ - hsize_t int_block[H5S_MAX_RANK]; /* Internal storage for block information */ - const hsize_t *opt_stride; /* Optimized stride information */ - const hsize_t *opt_count; /* Optimized count information */ - const hsize_t *opt_block; /* Optimized block information */ - int unlim_dim = -1; /* Unlimited dimension in selection, of -1 if none */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t int_stride[H5S_MAX_RANK]; /* Internal storage for stride information */ + hsize_t int_count[H5S_MAX_RANK]; /* Internal storage for count information */ + hsize_t int_block[H5S_MAX_RANK]; /* Internal storage for block information */ + const hsize_t *opt_stride; /* Optimized stride information */ + const hsize_t *opt_count; /* Optimized count information */ + const hsize_t *opt_block; /* Optimized block information */ + int unlim_dim = -1; /* Unlimited dimension in selection, of -1 if none */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -9673,34 +9912,34 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HDassert(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID); /* Point to the correct stride values */ - if(stride == NULL) + if (stride == NULL) stride = H5S_hyper_ones_g; /* Point to the correct block values */ - if(block == NULL) + if (block == NULL) block = H5S_hyper_ones_g; /* Check new selection */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ - if(count[u] > 1 && stride[u] < block[u]) + if (count[u] > 1 && stride[u] < block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap") /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) { - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + if (count[u] == 0 || block[u] == 0) { + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays same */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ case H5S_SELECT_NOOP: case H5S_SELECT_APPEND: @@ -9709,73 +9948,75 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ + } /* end if */ /* Check for unlimited dimension */ - if((count[u] == H5S_UNLIMITED) || (block[u] == H5S_UNLIMITED)) { - if(unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot have more than one unlimited dimension in selection") + if ((count[u] == H5S_UNLIMITED) || (block[u] == H5S_UNLIMITED)) { + if (unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot have more than one unlimited dimension in selection") else { - if(count[u] == block[u]) /* Both are H5S_UNLIMITED */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "count and block cannot both be unlimited") + if (count[u] == block[u]) /* Both are H5S_UNLIMITED */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "count and block cannot both be unlimited") unlim_dim = (int)u; } /* end else */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ - if(stride == H5S_hyper_ones_g && block == H5S_hyper_ones_g) { + if (stride == H5S_hyper_ones_g && block == H5S_hyper_ones_g) { /* Point to existing arrays */ opt_stride = H5S_hyper_ones_g; - opt_count = H5S_hyper_ones_g; - opt_block = count; + opt_count = H5S_hyper_ones_g; + opt_block = count; } /* end if */ else { /* Point to local arrays */ opt_stride = int_stride; - opt_count = int_count; - opt_block = int_block; - for(u = 0; u < space->extent.rank; u++) { + opt_count = int_count; + opt_block = int_block; + for (u = 0; u < space->extent.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ - if((stride[u] == block[u]) && (count[u] != H5S_UNLIMITED)) { - int_count[u] = 1; + if ((stride[u] == block[u]) && (count[u] != H5S_UNLIMITED)) { + int_count[u] = 1; int_stride[u] = 1; - if(block[u] == 1) + if (block[u] == 1) int_block[u] = count[u]; else int_block[u] = block[u] * count[u]; } /* end if */ else { - if(count[u] == 1) + if (count[u] == 1) int_stride[u] = 1; else { HDassert((stride[u] > block[u]) || - ((stride[u] == block[u]) && (count[u] == H5S_UNLIMITED))); + ((stride[u] == block[u]) && (count[u] == H5S_UNLIMITED))); int_stride[u] = stride[u]; } /* end else */ int_count[u] = count[u]; int_block[u] = block[u]; } /* end else */ - } /* end for */ - } /* end else */ + } /* end for */ + } /* end else */ /* Check for operating on unlimited selection */ - if((H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS) - && (space->select.sel_info.hslab->unlim_dim >= 0) - && (op != H5S_SELECT_SET)) { + if ((H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS) && + (space->select.sel_info.hslab->unlim_dim >= 0) && (op != H5S_SELECT_SET)) { /* Check for invalid operation */ - if(unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection") - if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTA))) + if (unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot modify unlimited selection with another unlimited selection") + if (!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTA))) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation on unlimited selection") HDassert(space->select.sel_info.hslab->diminfo_valid); /* Clip unlimited selection to include new selection */ - if(H5S_hyper_clip_unlim(space, - start[space->select.sel_info.hslab->unlim_dim] - + ((opt_count[space->select.sel_info.hslab->unlim_dim] - (hsize_t)1) - * opt_stride[space->select.sel_info.hslab->unlim_dim]) - + opt_block[space->select.sel_info.hslab->unlim_dim]) < 0) + if (H5S_hyper_clip_unlim(space, + start[space->select.sel_info.hslab->unlim_dim] + + ((opt_count[space->select.sel_info.hslab->unlim_dim] - (hsize_t)1) * + opt_stride[space->select.sel_info.hslab->unlim_dim]) + + opt_block[space->select.sel_info.hslab->unlim_dim]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") /* If an empty space was returned it must be "none" */ @@ -9783,22 +10024,22 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end if */ /* Fixup operation for non-hyperslab selections */ - switch(H5S_GET_SELECT_TYPE(space)) { - case H5S_SEL_NONE: /* No elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ + switch (H5S_GET_SELECT_TYPE(space)) { + case H5S_SEL_NONE: /* No elements selected in dataspace */ + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ /* Change "none" selection to hyperslab selection */ break; - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ op = H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "none" */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays "none" */ case H5S_SELECT_NOOP: case H5S_SELECT_APPEND: @@ -9809,43 +10050,44 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], } /* end switch */ break; - case H5S_SEL_ALL: /* All elements selected in dataspace */ - switch(op) { - case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SEL_ALL: /* All elements selected in dataspace */ + switch (op) { + case H5S_SELECT_SET: /* Select "set" operation */ /* Change "all" selection to hyperslab selection */ break; - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - HGOTO_DONE(SUCCEED); /* Selection stays "all" */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays "all" */ - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ op = H5S_SELECT_SET; /* Maps to "set" operation when applied to "none" selection */ break; - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ { - const hsize_t *tmp_start; /* Temporary start information */ - const hsize_t *tmp_stride; /* Temporary stride information */ - const hsize_t *tmp_count; /* Temporary count information */ - const hsize_t *tmp_block; /* Temporary block information */ + const hsize_t *tmp_start; /* Temporary start information */ + const hsize_t *tmp_stride; /* Temporary stride information */ + const hsize_t *tmp_count; /* Temporary count information */ + const hsize_t *tmp_block; /* Temporary block information */ /* Set up temporary information for the dimensions */ - tmp_start = H5S_hyper_zeros_g; + tmp_start = H5S_hyper_zeros_g; tmp_stride = tmp_count = H5S_hyper_ones_g; - tmp_block = space->extent.size; + tmp_block = space->extent.size; /* Convert to hyperslab selection */ - if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, + tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") } /* end case */ break; - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); @@ -9862,10 +10104,10 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], /* Hyperslab operation on hyperslab selection, OK */ break; - case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ - if(op == H5S_SELECT_SET) /* Allow only "set" operation to proceed */ + case H5S_SEL_POINTS: /* Can't combine hyperslab operations and point selections currently */ + if (op == H5S_SELECT_SET) /* Allow only "set" operation to proceed */ break; - /* Else fall through to error */ + /* FALLTHROUGH (to error) */ H5_ATTR_FALLTHROUGH case H5S_SEL_ERROR: @@ -9874,54 +10116,58 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - if(op == H5S_SELECT_SET) { + if (op == H5S_SELECT_SET) { /* Set selection to regular hyperslab */ - if(H5S__set_regular_hyperslab(space, start, stride, count, block, opt_stride, opt_count, opt_block) < 0) + if (H5S__set_regular_hyperslab(space, start, stride, count, block, opt_stride, opt_count, opt_block) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular hyperslab selection") } /* end if */ - else if(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA) { - hbool_t single_block; /* Whether the selection is a single block */ + else if (op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA) { + hbool_t single_block; /* Whether the selection is a single block */ /* Sanity check */ HDassert(H5S_GET_SELECT_TYPE(space) == H5S_SEL_HYPERSLABS); /* Handle unlimited selections */ - if(unlim_dim >= 0) { + if (unlim_dim >= 0) { hsize_t bounds_start[H5S_MAX_RANK]; hsize_t bounds_end[H5S_MAX_RANK]; hsize_t tmp_count = opt_count[unlim_dim]; hsize_t tmp_block = opt_block[unlim_dim]; /* Check for invalid operation */ - if(space->select.sel_info.hslab->unlim_dim >= 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "cannot modify unlimited selection with another unlimited selection") - if(!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTB))) - HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported operation with unlimited selection") + if (space->select.sel_info.hslab->unlim_dim >= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "cannot modify unlimited selection with another unlimited selection") + if (!((op == H5S_SELECT_AND) || (op == H5S_SELECT_NOTB))) + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "unsupported operation with unlimited selection") /* Get bounds of existing selection */ - if(H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__hyper_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Patch count and block to remove unlimited and include the * existing selection. */ - H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, bounds_end[unlim_dim] + (hsize_t)1); + H5S__hyper_get_clip_diminfo(start[unlim_dim], opt_stride[unlim_dim], &tmp_count, &tmp_block, + bounds_end[unlim_dim] + (hsize_t)1); HDassert((tmp_count == 1) || (opt_count != H5S_hyper_ones_g)); HDassert((tmp_block == 1) || (opt_block != H5S_hyper_ones_g)); - if(opt_count != H5S_hyper_ones_g) { + if (opt_count != H5S_hyper_ones_g) { HDassert(opt_count == int_count); int_count[unlim_dim] = tmp_count; } /* end if */ - if(opt_block != H5S_hyper_ones_g) { + if (opt_block != H5S_hyper_ones_g) { HDassert(opt_block == int_block); int_block[unlim_dim] = tmp_block; } /* end if */ - } /* end if */ + } /* end if */ /* Check for a single block selected */ single_block = TRUE; - for(u = 0; u < space->extent.rank; u++) - if(1 != opt_count[u]) { + for (u = 0; u < space->extent.rank; u++) + if (1 != opt_count[u]) { single_block = FALSE; break; } /* end if */ @@ -9929,25 +10175,26 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], /* Check for single block "AND" operation on a regular hyperslab, which * is used for constructing chunk maps and can be optimized for. */ - if(H5S_SELECT_AND == op && single_block && - space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - if(H5S__hyper_regular_and_single_block(space, start, opt_block) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTOPERATE, FAIL, "can't 'AND' single block against regular hyperslab") + if (H5S_SELECT_AND == op && single_block && + space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + if (H5S__hyper_regular_and_single_block(space, start, opt_block) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTOPERATE, FAIL, + "can't 'AND' single block against regular hyperslab") } /* end if */ else { /* Check if there's no hyperslab span information currently */ - if(NULL == space->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space) < 0) + if (NULL == space->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* Set selection type */ space->select.type = H5S_sel_hyper; /* Add in the new hyperslab information */ - if(H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0) + if (H5S__generate_hyperslab(space, op, start, opt_stride, opt_count, opt_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end else */ - } /* end if */ + } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") @@ -9955,7 +10202,6 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_hyperslab @@ -9983,8 +10229,8 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { H5S_t *space; /* Dataspace to modify selection of */ herr_t ret_value = SUCCEED; /* Return value */ @@ -9993,33 +10239,32 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], H5TRACE6("e", "iSs*h*h*h*h", space_id, op, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) + if (H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space") - if(H5S_NULL == H5S_GET_EXTENT_TYPE(space)) + if (H5S_NULL == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space") - if(start == NULL || count == NULL) + if (start == NULL || count == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified") - if(!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) + if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") - if(stride != NULL) { - unsigned u; /* Local index variable */ + if (stride != NULL) { + unsigned u; /* Local index variable */ /* Check for 0-sized strides */ - for(u = 0; u < space->extent.rank; u++) - if(stride[u] == 0) + for (u = 0; u < space->extent.rank; u++) + if (stride[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value") } /* end if */ - if(H5S_select_hyperslab(space, op, start, stride, count, block) < 0) + if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5S_combine_hyperslab @@ -10051,12 +10296,11 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block, - H5S_t **new_space) +H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], const hsize_t *stride, + const hsize_t count[], const hsize_t *block, H5S_t **new_space) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -10069,39 +10313,39 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], HDassert(*new_space == NULL); /* Point to the correct stride values */ - if(stride == NULL) + if (stride == NULL) stride = H5S_hyper_ones_g; /* Point to the correct block values */ - if(block == NULL) + if (block == NULL) block = H5S_hyper_ones_g; /* Check new selection. */ - for(u = 0; u < old_space->extent.rank; u++) { + for (u = 0; u < old_space->extent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ - if(count[u] > 1 && stride[u] < block[u]) + if (count[u] > 1 && stride[u] < block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap") /* Detect zero-sized hyperslabs in new selection */ - if(count[u] == 0 || block[u] == 0) { - switch(op) { - case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ - case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + if (count[u] == 0 || block[u] == 0) { + switch (op) { + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ /* Convert to "none" selection */ /* Copy the first dataspace without sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") HGOTO_DONE(SUCCEED); - case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ - case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ - case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ /* Copy the first dataspace with sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, FALSE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") - HGOTO_DONE(SUCCEED); /* Selection stays same */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ case H5S_SELECT_NOOP: case H5S_SELECT_SET: @@ -10111,92 +10355,95 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") } /* end switch */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ - if(H5S_GET_SELECT_TYPE(old_space) == H5S_SEL_HYPERSLABS) { - hsize_t *old_low_bounds; /* Pointer to old space's low & high bounds */ + if (H5S_GET_SELECT_TYPE(old_space) == H5S_SEL_HYPERSLABS) { + hsize_t *old_low_bounds; /* Pointer to old space's low & high bounds */ hsize_t *old_high_bounds; - hsize_t new_low_bounds[H5S_MAX_RANK]; /* New space's low & high bounds */ - hsize_t new_high_bounds[H5S_MAX_RANK]; - hbool_t overlapped = FALSE; + hsize_t new_low_bounds[H5S_MAX_RANK]; /* New space's low & high bounds */ + hsize_t new_high_bounds[H5S_MAX_RANK]; + hbool_t overlapped = FALSE; /* Set up old space's low & high bounds */ - if(old_space->select.sel_info.hslab->span_lst) { - old_low_bounds = old_space->select.sel_info.hslab->span_lst->low_bounds; + if (old_space->select.sel_info.hslab->span_lst) { + old_low_bounds = old_space->select.sel_info.hslab->span_lst->low_bounds; old_high_bounds = old_space->select.sel_info.hslab->span_lst->high_bounds; } /* end if */ else { - old_low_bounds = old_space->select.sel_info.hslab->diminfo.low_bounds; + old_low_bounds = old_space->select.sel_info.hslab->diminfo.low_bounds; old_high_bounds = old_space->select.sel_info.hslab->diminfo.high_bounds; } /* end else */ /* Generate bounding box for hyperslab parameters */ - for(u = 0; u < old_space->extent.rank; u++) { - new_low_bounds[u] = start[u]; + for (u = 0; u < old_space->extent.rank; u++) { + new_low_bounds[u] = start[u]; new_high_bounds[u] = start[u] + stride[u] * (count[u] - 1) + (block[u] - 1); } /* end for */ /* Check bound box of both spaces to see if they overlap */ - if(H5S_RANGE_OVERLAP(old_low_bounds[0], old_high_bounds[0], - new_low_bounds[0], new_high_bounds[0])) + if (H5S_RANGE_OVERLAP(old_low_bounds[0], old_high_bounds[0], new_low_bounds[0], new_high_bounds[0])) overlapped = TRUE; /* Non-overlapping situations can be handled in special ways */ - if(!overlapped) { + if (!overlapped) { H5S_hyper_span_info_t *new_spans = NULL; - H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; + H5S_hyper_dim_t new_hyper_diminfo[H5S_MAX_RANK]; - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") - if(NULL != (*new_space)->select.sel_info.hslab->span_lst) { + if (NULL != (*new_space)->select.sel_info.hslab->span_lst) { old_space->select.sel_info.hslab->span_lst->count--; (*new_space)->select.sel_info.hslab->span_lst = NULL; } /* end if */ /* Generate hyperslab info for new space */ - switch(op) { + switch (op) { case H5S_SELECT_OR: case H5S_SELECT_XOR: /* Add the new space to the space */ - if(NULL == (new_spans = H5S__hyper_make_spans(old_space->extent.rank, start, stride, count, block))) + if (NULL == (new_spans = H5S__hyper_make_spans(old_space->extent.rank, start, stride, + count, block))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information") - if(NULL != old_space->select.sel_info.hslab->span_lst) - (*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank); - if(H5S__hyper_add_disjoint_spans(*new_space, new_spans) < 0) + if (NULL != old_space->select.sel_info.hslab->span_lst) + (*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span( + old_space->select.sel_info.hslab->span_lst, old_space->extent.rank); + if (H5S__hyper_add_disjoint_spans(*new_space, new_spans) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't append hyperslabs") /* Build diminfo struct */ - for(u = 0; u < (*new_space)->extent.rank; u++) { - new_hyper_diminfo[u].start = start[u]; + for (u = 0; u < (*new_space)->extent.rank; u++) { + new_hyper_diminfo[u].start = start[u]; new_hyper_diminfo[u].stride = stride[u]; - new_hyper_diminfo[u].count = count[u]; - new_hyper_diminfo[u].block = block[u]; + new_hyper_diminfo[u].count = count[u]; + new_hyper_diminfo[u].block = block[u]; } /* end for */ /* Update space's dim info */ - if(H5S__hyper_update_diminfo(*new_space, op, new_hyper_diminfo) < 0) + if (H5S__hyper_update_diminfo(*new_space, op, new_hyper_diminfo) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") break; case H5S_SELECT_AND: - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") break; case H5S_SELECT_NOTB: - if(NULL != old_space->select.sel_info.hslab->span_lst) { - if(NULL == ((*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span(old_space->select.sel_info.hslab->span_lst, old_space->extent.rank))) + if (NULL != old_space->select.sel_info.hslab->span_lst) { + if (NULL == ((*new_space)->select.sel_info.hslab->span_lst = H5S__hyper_copy_span( + old_space->select.sel_info.hslab->span_lst, old_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy dataspace") } /* end if */ else { - if(H5S_select_none((*new_space)) < 0) + if (H5S_select_none((*new_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end else */ break; case H5S_SELECT_NOTA: - if(H5S__set_regular_hyperslab(*new_space, start, stride, count, block, stride, count, block) < 0) + if (H5S__set_regular_hyperslab(*new_space, start, stride, count, block, stride, count, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't set regular selection") break; @@ -10211,21 +10458,20 @@ H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], HGOTO_DONE(SUCCEED); } /* end if(!overlapped) */ - } /* end if the selection of old space is H5S_SEL_HYPERSLABS */ + } /* end if the selection of old space is H5S_SEL_HYPERSLABS */ /* Copy the first dataspace with sharing the list of spans */ - if(NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) + if (NULL == ((*new_space) = H5S_copy(old_space, TRUE, TRUE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") /* Note: a little overhead in calling the function as some conditions are checked again */ - if(H5S_select_hyperslab(*new_space, op, start, stride, count, block) < 0) + if (H5S_select_hyperslab(*new_space, op, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_combine_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__fill_in_select * @@ -10244,7 +10490,7 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu { hbool_t span2_owned; hbool_t updated_spans; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -10259,15 +10505,16 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu HDassert(space2->select.sel_info.hslab->span_lst); /* Note: the offset of space2 is not considered here for bounding box */ - if(H5S__fill_in_new_space(space1, op, space2->select.sel_info.hslab->span_lst, FALSE, &span2_owned, &updated_spans, result) < 0) + if (H5S__fill_in_new_space(space1, op, space2->select.sel_info.hslab->span_lst, FALSE, &span2_owned, + &updated_spans, result) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't create the specified selection") /* Update diminfo if space2's diminfo was valid, otherwise just mark it as * invalid if the spans were updated */ HDassert(result); - if(updated_spans) { - if(space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - if(H5S__hyper_update_diminfo(*result, op, space2->select.sel_info.hslab->diminfo.opt) < 0) + if (updated_spans) { + if (space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + if (H5S__hyper_update_diminfo(*result, op, space2->select.sel_info.hslab->diminfo.opt) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't update hyperslab info") } /* end if */ else @@ -10278,7 +10525,6 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_select() */ - /*-------------------------------------------------------------------------- NAME H5Scombine_hyperslab @@ -10309,40 +10555,39 @@ H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **resu REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], - const hsize_t stride[], const hsize_t count[], const hsize_t block[]) +H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], + const hsize_t count[], const hsize_t block[]) { - H5S_t *space; /* Dataspace to modify selection of */ - H5S_t *new_space = NULL; /* New dataspace created */ - hid_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to modify selection of */ + H5S_t *new_space = NULL; /* New dataspace created */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "iSs*h*h*h*h", space_id, op, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(start == NULL || count == NULL) + if (start == NULL || count == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "hyperslab not specified") - if(!(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_SET && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation") /* Generate new space, with combination of selections */ - if(H5S_combine_hyperslab(space, op, start, stride, count, block, &new_space) < 0) + if (H5S_combine_hyperslab(space, op, start, stride, count, block, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to set hyperslab selection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0 && new_space) + if (ret_value < 0 && new_space) H5S_close(new_space); FUNC_LEAVE_API(ret_value) } /* end H5Scombine_hyperslab() */ - /*------------------------------------------------------------------------- * Function: H5S__combine_select * @@ -10358,8 +10603,8 @@ H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], static H5S_t * H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) { - H5S_t *new_space = NULL; /* New dataspace generated */ - H5S_t *ret_value = NULL; /* Return value */ + H5S_t *new_space = NULL; /* New dataspace generated */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -10369,31 +10614,31 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA); /* Check if space1 selections has span trees */ - if(NULL == space1->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space1) < 0) + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, NULL, "dataspace does not have span tree") - if(NULL == space2->select.sel_info.hslab->span_lst) { - hsize_t tmp_start[H5S_MAX_RANK]; - hsize_t tmp_stride[H5S_MAX_RANK]; - hsize_t tmp_count[H5S_MAX_RANK]; - hsize_t tmp_block[H5S_MAX_RANK]; + if (NULL == space2->select.sel_info.hslab->span_lst) { + hsize_t tmp_start[H5S_MAX_RANK]; + hsize_t tmp_stride[H5S_MAX_RANK]; + hsize_t tmp_count[H5S_MAX_RANK]; + hsize_t tmp_block[H5S_MAX_RANK]; unsigned u; - for(u = 0; u < space2->extent.rank; u++) { - tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; + for (u = 0; u < space2->extent.rank; u++) { + tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Combine hyperslab selection with regular selection directly */ - if(H5S_combine_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block, &new_space) < 0) + if (H5S_combine_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to set hyperslab selection") } /* end if */ - else{ + else { /* Combine new_space (a copy of space 1) & space2, with the result in new_space */ - if(H5S__fill_in_select(space1, op, space2, &new_space) < 0) + if (H5S__fill_in_select(space1, op, space2, &new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information") } /* end else */ @@ -10404,13 +10649,12 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) ret_value = new_space; done: - if(ret_value == NULL && new_space) + if (ret_value == NULL && new_space) H5S_close(new_space); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__combine_select() */ - /*-------------------------------------------------------------------------- NAME H5Scombine_select @@ -10436,27 +10680,27 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) { - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - H5S_t *new_space = NULL; /* New Dataspace */ - hid_t ret_value; /* Return value */ + H5S_t *space1; /* First Dataspace */ + H5S_t *space2; /* Second Dataspace */ + H5S_t *new_space = NULL; /* New Dataspace */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iSsi", space1_id, op, space2_id); /* Check args */ - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") - if(!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, H5I_INVALID_HID, "invalid selection operation") /* Check that both dataspaces have the same rank */ - if(space1->extent.rank != space2->extent.rank) + if (space1->extent.rank != space2->extent.rank) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces not same rank") - /* Note: currently, the offset of each dataspace is ignored */ + /* Note: currently, the offset of each dataspace is ignored */ #if 0 /* Check that both dataspaces have the same offset */ /* Same note as in H5Smodify_select */ @@ -10467,25 +10711,25 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) #endif /* Check that both dataspaces have hyperslab selections */ - if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || + H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dataspaces don't have hyperslab selections") /* Go combine the dataspaces */ - if(NULL == (new_space = H5S__combine_select(space1, op, space2))) + if (NULL == (new_space = H5S__combine_select(space1, op, space2))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to create hyperslab selection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, new_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if(ret_value < 0 && new_space) + if (ret_value < 0 && new_space) H5S_close(new_space); FUNC_LEAVE_API(ret_value) } /* end H5Scombine_select() */ - /*------------------------------------------------------------------------- * Function: H5S__modify_select * @@ -10501,7 +10745,7 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -10511,41 +10755,40 @@ H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) HDassert(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA); /* Check that the space selections both have span trees */ - if(NULL == space1->select.sel_info.hslab->span_lst) - if(H5S__hyper_generate_spans(space1) < 0) + if (NULL == space1->select.sel_info.hslab->span_lst) + if (H5S__hyper_generate_spans(space1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree") /* Set unlim_dim */ space1->select.sel_info.hslab->unlim_dim = -1; - if(NULL == space2->select.sel_info.hslab->span_lst) { - hsize_t tmp_start[H5S_MAX_RANK]; - hsize_t tmp_stride[H5S_MAX_RANK]; - hsize_t tmp_count[H5S_MAX_RANK]; - hsize_t tmp_block[H5S_MAX_RANK]; + if (NULL == space2->select.sel_info.hslab->span_lst) { + hsize_t tmp_start[H5S_MAX_RANK]; + hsize_t tmp_stride[H5S_MAX_RANK]; + hsize_t tmp_count[H5S_MAX_RANK]; + hsize_t tmp_block[H5S_MAX_RANK]; unsigned u; - for(u = 0; u < space2->extent.rank; u++) { - tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; + for (u = 0; u < space2->extent.rank; u++) { + tmp_start[u] = space2->select.sel_info.hslab->diminfo.opt[u].start; tmp_stride[u] = space2->select.sel_info.hslab->diminfo.opt[u].stride; - tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; - tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; + tmp_count[u] = space2->select.sel_info.hslab->diminfo.opt[u].count; + tmp_block[u] = space2->select.sel_info.hslab->diminfo.opt[u].block; } /* end for */ /* Call H5S_select_hyperslab directly */ - if(H5S_select_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space1, op, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection") } /* end if */ 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") + if (H5S__fill_in_select(space1, op, space2, &space1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__modify_select() */ - /*-------------------------------------------------------------------------- NAME H5Smodify_select @@ -10571,43 +10814,43 @@ H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) { - H5S_t *space1; /* First Dataspace */ - H5S_t *space2; /* Second Dataspace */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space1; /* First Dataspace */ + H5S_t *space2; /* Second Dataspace */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iSsi", space1_id, op, space2_id); /* Check args */ - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) + if (!(op >= H5S_SELECT_OR && op <= H5S_SELECT_NOTA)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation") /* Check that both dataspaces have the same rank */ - if(space1->extent.rank != space2->extent.rank) + if (space1->extent.rank != space2->extent.rank) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces not same rank") - /* Check that both dataspaces have the same offset */ - /** Note that this is a tricky part of this function. It's - * possible that two dataspaces have different "offset". If the - * space2 has smaller offset value than that of space1 in a - * dimension, then the span elements of this dimension in - * space2 could have negative "low" and "high" values relative - * to the offset in space1. In other words, if the bounds of - * span elements in space2 are adjusted relative to the offset - * in space1, then every span element's bound is computed as - * "origin_bound+offset2-offset1". Therefore, if offset2 (the - * offset of space2) is smaller, then - * "origin_bound+offset2-offset1" could be negative which is - * not allowed by the bound type declaration as hsize_t! - * As a result, if the op is an OR selection, then the final - * result may contain span elements that have negative bound! - * So right now, the difference in the offset is totally - * ignored!! - */ + /* Check that both dataspaces have the same offset */ + /** Note that this is a tricky part of this function. It's + * possible that two dataspaces have different "offset". If the + * space2 has smaller offset value than that of space1 in a + * dimension, then the span elements of this dimension in + * space2 could have negative "low" and "high" values relative + * to the offset in space1. In other words, if the bounds of + * span elements in space2 are adjusted relative to the offset + * in space1, then every span element's bound is computed as + * "origin_bound+offset2-offset1". Therefore, if offset2 (the + * offset of space2) is smaller, then + * "origin_bound+offset2-offset1" could be negative which is + * not allowed by the bound type declaration as hsize_t! + * As a result, if the op is an OR selection, then the final + * result may contain span elements that have negative bound! + * So right now, the difference in the offset is totally + * ignored!! + */ #if 0 for(u=0; uextent.rank; u++) { if(space1->select.offset[u] != space2->select.offset[u]) @@ -10616,18 +10859,18 @@ H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) #endif /* Check that both dataspaces have hyperslab selections */ - if(H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space1) != H5S_SEL_HYPERSLABS || + H5S_GET_SELECT_TYPE(space2) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections") /* Go refine the first selection */ - if(H5S__modify_select(space1, op, space2) < 0) + if (H5S__modify_select(space1, op, space2) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Smodify_select() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_build_proj @@ -10650,9 +10893,10 @@ H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { - H5S_hyper_span_info_t *copied_span_info = NULL; /* Temporary span info pointer */ - herr_t ret_value = SUCCEED; /* Return value */ +H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) +{ + H5S_hyper_span_info_t *copied_span_info = NULL; /* Temporary span info pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -10661,35 +10905,37 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* * Skip over skipped elements */ - if(udata->skip > 0) { + if (udata->skip > 0) { /* Work upwards, finishing each span tree before moving up */ HDassert(udata->ds_span[udata->depth]); do { /* Check for lowest dimension */ - if(udata->ds_span[udata->depth]->down) { - if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { + if (udata->ds_span[udata->depth]->down) { + if (udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { /* If we will run out of elements to skip in this span, * advance to the first not fully skipped span and break * out of this loop (start moving downwards) */ - if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + if (udata->skip < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + udata->ds_low[udata->depth] += + udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->skip %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; break; } /* end if */ /* Skip over this entire span */ - udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); /* If we will run out of elements to skip in this span, * skip the remainder of the skipped elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { udata->ds_low[udata->depth] += udata->skip; udata->skip = 0; break; @@ -10701,15 +10947,15 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; - if(udata->ds_span[udata->depth]) + if (udata->ds_span[udata->depth]) udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - else if(udata->depth > 0) { + else if (udata->depth > 0) { /* If present, append this span tree to the higher dimension's, * and release ownership of it */ - if(udata->ps_span_info[udata->depth]) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], - udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], - udata->ds_low[udata->depth - 1], + if (udata->ps_span_info[udata->depth]) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth - 1], udata->ds_rank - udata->depth + 1, + udata->ds_low[udata->depth - 1], udata->ds_low[udata->depth - 1], udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); @@ -10722,44 +10968,47 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_low[udata->depth]++; } /* end if */ else - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection") - } while((udata->skip > 0) - || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "insufficient elements in destination selection") + } while ((udata->skip > 0) || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); /* Work downwards until skip is 0 */ HDassert(udata->ds_span[udata->depth]); - while(udata->skip > 0) { + while (udata->skip > 0) { HDassert(udata->ds_span[udata->depth]->down); udata->depth++; udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head; - udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - if(udata->ds_span[udata->depth]->down) { + udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; + if (udata->ds_span[udata->depth]->down) { do { /* If we will run out of elements to skip in this span, * advance to the first not fully skipped span and * continue down */ - if(udata->skip < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - udata->ds_low[udata->depth] += udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + if (udata->skip < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + udata->ds_low[udata->depth] += + udata->skip / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->skip %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; break; } /* end if */ /* Skip over this entire span */ - udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->skip -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->skip > 0); + } while (udata->skip > 0); } /* end if */ else { do { /* If we will run out of elements to skip in this span, * skip the remainder of the skipped elements */ - if(udata->skip < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->skip < + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { udata->ds_low[udata->depth] += udata->skip; udata->skip = 0; break; @@ -10772,10 +11021,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->skip > 0); + } while (udata->skip > 0); } /* end else */ - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ /* * Add requested number of elements to projected space @@ -10785,77 +11034,92 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { HDassert(udata->ds_span[udata->depth]); do { /* Check for lowest dimension */ - if(udata->ds_span[udata->depth]->down) { - if(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { + if (udata->ds_span[udata->depth]->down) { + if (udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high) { /* If we will run out of elements to add in this span, add * any complete spans, advance to the first not fully added * span, and break out of this loop (start moving downwards) */ - if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (udata->nelem < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { + if (udata->share_selection) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, udata->ds_span[udata->depth]->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, + udata->ds_rank - udata->depth, 1, udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, copied_span_info) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + udata->ds_low[udata->depth] += + udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; } /* end if */ break; } /* end if */ /* Append span tree for entire span */ - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - udata->ds_span[udata->depth]->down) < 0) + if (udata->share_selection) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, + udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, + udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - copied_span_info) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); } /* end if */ - } /* end if */ + } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); /* If we will run out of elements to add in this span, add the * remainder of the elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) + if (udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->ds_low[udata->depth] += udata->nelem; udata->nelem = 0; @@ -10863,24 +11127,24 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { } /* end if */ /* Append span tree for entire span */ - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, NULL) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1; } /* end else */ /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; - if(udata->ds_span[udata->depth]) + if (udata->ds_span[udata->depth]) udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - else if(udata->depth > 0) { + else if (udata->depth > 0) { /* Append this span tree to the higher dimension's, and release * ownership of it */ HDassert(udata->ps_span_info[udata->depth]); - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], - udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], - udata->ds_low[udata->depth - 1], - udata->ps_span_info[udata->depth]) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth - 1], + udata->ds_rank - udata->depth + 1, udata->ds_low[udata->depth - 1], + udata->ds_low[udata->depth - 1], + udata->ps_span_info[udata->depth]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[udata->depth]); udata->ps_span_info[udata->depth] = NULL; @@ -10893,87 +11157,102 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { else { /* We have finished the entire destination span tree. If there are * still elements to add, issue an error. */ - if(udata->nelem > 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "insufficient elements in destination selection") + if (udata->nelem > 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "insufficient elements in destination selection") break; } /* end else */ - } while((udata->nelem > 0) - || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); + } while ((udata->nelem > 0) || (udata->ds_low[udata->depth] > udata->ds_span[udata->depth]->high)); /* Work downwards until nelem is 0 */ HDassert(udata->ds_span[udata->depth] || (udata->nelem == 0)); - while(udata->nelem > 0) { + while (udata->nelem > 0) { HDassert(udata->ds_span[udata->depth]->down); udata->depth++; udata->ds_span[udata->depth] = udata->ds_span[udata->depth - 1]->down->head; - udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - if(udata->ds_span[udata->depth]->down) { + udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; + if (udata->ds_span[udata->depth]->down) { do { /* If we will run out of elements to add in this span, add * any complete spans, advance to the first not fully added * span and continue down */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (udata->nelem < + H5S__hyper_spans_nelem_helper(udata->ds_span[udata->depth]->down, 0, udata->op_gen) * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (udata->nelem >= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) { + if (udata->share_selection) { + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, udata->ds_span[udata->depth]->down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, + udata->ds_rank - udata->depth, 1, udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_low[udata->depth] + (udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - 1, + if (H5S__hyper_append_span( + &udata->ps_span_info[udata->depth], udata->ds_rank - udata->depth, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + + (udata->nelem / + udata->ds_span[udata->depth]->down->op_info[0].u.nelmts) - + 1, copied_span_info) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, + "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->ds_low[udata->depth] += udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; + udata->ds_low[udata->depth] += + udata->nelem / udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; udata->nelem %= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts; } /* end if */ break; } /* end if */ /* Append span tree for entire span */ - if(udata->share_selection) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - udata->ds_span[udata->depth]->down) < 0) + if (udata->share_selection) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, + udata->ds_span[udata->depth]->down) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") } /* end if */ else { /* If we're not sharing the destination space's * spans, we must copy it first (then release it * afterwards) */ - if(NULL == (copied_span_info = H5S__hyper_copy_span_helper(udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, udata->op_gen))) + if (NULL == (copied_span_info = H5S__hyper_copy_span_helper( + udata->ds_span[udata->depth]->down, udata->ds_rank - udata->depth, 1, + udata->op_gen))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination spans") - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], - udata->ds_rank - udata->depth, udata->ds_low[udata->depth], - udata->ds_span[udata->depth]->high, - copied_span_info) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], + udata->ds_rank - udata->depth, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, copied_span_info) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; } /* end else */ - udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts - * (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); + udata->nelem -= udata->ds_span[udata->depth]->down->op_info[0].u.nelmts * + (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1); /* Advance to next span */ udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->nelem > 0); + } while (udata->nelem > 0); } /* end if */ else { HDassert(udata->ds_rank - udata->depth == 1); @@ -10981,9 +11260,10 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { /* If we will run out of elements to add in this span, add * the remainder of the elements and break out */ HDassert(udata->ds_low[udata->depth] <= udata->ds_span[udata->depth]->high); - if(udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) + if (udata->nelem < (udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1)) { + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, + udata->ds_low[udata->depth], + udata->ds_low[udata->depth] + udata->nelem - 1, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->ds_low[udata->depth] += udata->nelem; udata->nelem = 0; @@ -10991,8 +11271,8 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { } /* end if */ /* Append span tree for entire span */ - if(H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, - udata->ds_low[udata->depth], udata->ds_span[udata->depth]->high, NULL) < 0) + if (H5S__hyper_append_span(&udata->ps_span_info[udata->depth], 1, udata->ds_low[udata->depth], + udata->ds_span[udata->depth]->high, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") udata->nelem -= udata->ds_span[udata->depth]->high - udata->ds_low[udata->depth] + 1; @@ -11000,9 +11280,9 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { udata->ds_span[udata->depth] = udata->ds_span[udata->depth]->next; HDassert(udata->ds_span[udata->depth]); udata->ds_low[udata->depth] = udata->ds_span[udata->depth]->low; - } while(udata->nelem > 0); + } while (udata->nelem > 0); } /* end else */ - } /* end while */ + } /* end while */ HDassert(udata->skip == 0); HDassert(udata->nelem == 0); @@ -11012,7 +11292,7 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { done: /* Cleanup on failure */ - if(copied_span_info) { + if (copied_span_info) { HDassert(ret_value < 0); H5S__hyper_free_span_info(copied_span_info); copied_span_info = NULL; @@ -11021,7 +11301,6 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_build_proj() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_iterate @@ -11031,8 +11310,8 @@ H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata) { herr_t H5S__hyper_proj_int_iterate(ss_span_info,sis_span_info,count,depth,udata) const H5S_hyper_span_info_t *ss_span_info; IN: Span tree for source selection const H5S_hyper_span_info_t *sis_span_info; IN: Span tree for source intersect selection - hsize_t count; IN: Number of times to compute the intersection of ss_span_info and sis_span_info - unsigned depth; IN: Depth of iteration (in terms of rank) + hsize_t count; IN: Number of times to compute the intersection of ss_span_info and +sis_span_info unsigned depth; IN: Depth of iteration (in terms of rank) H5S_hyper_project_intersect_ud_t *udata; IN/OUT: Persistent shared data for iteration RETURNS Non-negative on success/Negative on failure. @@ -11052,75 +11331,78 @@ 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, - 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_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 */ - hsize_t ss_low; /* Current low bounds of source span */ - hsize_t sis_low; /* Current low bounds of source intersect span */ - hsize_t high; /* High bounds of current intersection */ - hsize_t low; /* Low bounds of current intersection */ - hsize_t old_skip; /* Value of udata->skip before main loop */ - hsize_t old_nelem; /* Value of udata->nelem before main loop */ - hbool_t check_intersect; /* Whether to check for intersecting elements */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hsize_t ss_low; /* Current low bounds of source span */ + hsize_t sis_low; /* Current low bounds of source intersect span */ + hsize_t high; /* High bounds of current intersection */ + hsize_t low; /* Low bounds of current intersection */ + hsize_t old_skip; /* Value of udata->skip before main loop */ + hsize_t old_nelem; /* Value of udata->nelem before main loop */ + hbool_t check_intersect; /* Whether to check for intersecting elements */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check for non-overlapping bounds */ check_intersect = TRUE; - for(u = 0; u < (udata->ss_rank - depth); u++) - if(!H5S_RANGE_OVERLAP(ss_span_info->low_bounds[u], - ss_span_info->high_bounds[u], - sis_span_info->low_bounds[u], - sis_span_info->high_bounds[u])) { + for (u = 0; u < (udata->ss_rank - depth); u++) + if (!H5S_RANGE_OVERLAP(ss_span_info->low_bounds[u], ss_span_info->high_bounds[u], + sis_span_info->low_bounds[u], sis_span_info->high_bounds[u])) { check_intersect = FALSE; break; } /* end if */ /* Only enter main loop if there's something to do */ - if(check_intersect) { + if (check_intersect) { /* Set ps_clean_bitmap */ udata->ps_clean_bitmap |= (((uint32_t)1) << depth); /* Save old skip and nelem */ - old_skip = udata->skip; + old_skip = udata->skip; old_nelem = udata->nelem; /* Intersect spaces once per count */ - for(u = 0; u < count; u++) { - ss_span = ss_span_info->head; + for (u = 0; u < count; u++) { + ss_span = ss_span_info->head; sis_span = sis_span_info->head; HDassert(ss_span && sis_span); - ss_low = ss_span->low; + ss_low = ss_span->low; sis_low = sis_span->low; /* Main loop */ do { /* Check if spans overlap */ - if(H5S_RANGE_OVERLAP(ss_low, ss_span->high, - sis_low, sis_span->high)) { + if (H5S_RANGE_OVERLAP(ss_low, ss_span->high, sis_low, sis_span->high)) { high = MIN(ss_span->high, sis_span->high); - if(ss_span->down) { + if (ss_span->down) { /* Add skipped elements if there's a pre-gap */ - if(ss_low < sis_low) { + if (ss_low < sis_low) { low = sis_low; - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (sis_low - ss_low), FAIL); + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (sis_low - ss_low), + FAIL); } /* end if */ else low = ss_low; /* Recurse into next dimension down */ - if(H5S__hyper_proj_int_iterate(ss_span->down, sis_span->down, high - low + 1, depth + 1, udata) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't iterate over source selections") + if (H5S__hyper_proj_int_iterate(ss_span->down, sis_span->down, high - low + 1, + depth + 1, udata) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, + "can't iterate over source selections") } /* end if */ else { HDassert(depth == udata->ss_rank - 1); /* Add skipped elements if there's a pre-gap */ - if(ss_low < sis_low) { + if (ss_low < sis_low) { low = sis_low; H5S_HYPER_PROJ_INT_ADD_SKIP(udata, sis_low - ss_low, FAIL); } /* end if */ @@ -11132,87 +11414,99 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, } /* end else */ /* Advance spans */ - if(ss_span->high == sis_span->high) { + if (ss_span->high == sis_span->high) { /* Advance both spans */ ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end if */ - else if(ss_span->high == high) { + else if (ss_span->high == high) { /* Advance source span */ HDassert(ss_span->high < sis_span->high); sis_low = high + 1; ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; } /* end if */ else { /* Advance source intersect span */ HDassert(ss_span->high > sis_span->high); - ss_low = high + 1; + ss_low = high + 1; sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end else */ - } /* end if */ + } /* end if */ else { /* Advance spans */ - if(ss_span->high < sis_low) { + if (ss_span->high < sis_low) { /* Add skipped elements */ - if(ss_span->down) - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL); + if (ss_span->down) + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_low + 1), + FAIL); else H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL); /* Advance source span */ ss_span = ss_span->next; - if(ss_span) + if (ss_span) ss_low = ss_span->low; } /* end if */ else { /* Advance source intersect span */ HDassert(ss_low > sis_span->high); sis_span = sis_span->next; - if(sis_span) + if (sis_span) sis_low = sis_span->low; } /* end else */ - } /* end else */ - } while(ss_span && sis_span); + } /* end else */ + } while (ss_span && sis_span); - if(ss_span && !((depth == 0) && (u == count - 1))) { + if (ss_span && !((depth == 0) && (u == count - 1))) { /* Count remaining elements in ss_span_info */ - if(ss_span->down) { - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_low + 1), FAIL); + if (ss_span->down) { + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_low + 1), + FAIL); ss_span = ss_span->next; - while(ss_span) { - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * (ss_span->high - ss_span->low + 1), FAIL); + while (ss_span) { + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper(ss_span->down, 0, udata->op_gen) * + (ss_span->high - ss_span->low + 1), + FAIL); ss_span = ss_span->next; } /* end while */ - } /* end if */ + } /* end if */ else { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_low + 1, FAIL); ss_span = ss_span->next; - while(ss_span) { + while (ss_span) { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, ss_span->high - ss_span->low + 1, FAIL); ss_span = ss_span->next; } /* end while */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Check if the projected space was not changed since we started the * first iteration of the loop, if so we do not need to continue * looping and can just copy the result */ - if(udata->ps_clean_bitmap & (((uint32_t)1) << depth)) { + if (udata->ps_clean_bitmap & (((uint32_t)1) << depth)) { HDassert(u == 0); - if(udata->skip == old_skip) { + if (udata->skip == old_skip) { /* First case: algorithm added only elements */ HDassert(udata->nelem >= old_nelem); udata->nelem += (count - 1) * (udata->nelem - old_nelem); } /* end if */ - else if(udata->nelem == 0) { + else if (udata->nelem == 0) { /* Second case: algorithm added only skip. In this case, * nelem must be 0 since otherwise adding skip would have * triggered a change in the projected space */ @@ -11231,48 +11525,49 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, HDassert(udata->skip > old_skip); HDassert(old_nelem == 0); - skip_add = udata->skip - old_skip; + skip_add = udata->skip - old_skip; nelem_add = udata->nelem - old_nelem; - for(u = 1; u < count; u++) { + for (u = 1; u < count; u++) { H5S_HYPER_PROJ_INT_ADD_SKIP(udata, skip_add, FAIL); udata->nelem += nelem_add; } /* end for */ - } /* end else */ + } /* end else */ /* End loop since we already took care of it */ break; } /* end if */ - } /* end for */ - } /* end if */ - else if(depth > 0) + } /* end for */ + } /* end if */ + else if (depth > 0) /* Just count skipped elements */ - H5S_HYPER_PROJ_INT_ADD_SKIP(udata, H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, 0, udata->op_gen) * count, FAIL); /* Casting away const OK -NAF */ + H5S_HYPER_PROJ_INT_ADD_SKIP( + udata, + H5S__hyper_spans_nelem_helper((H5S_hyper_span_info_t *)ss_span_info, 0, udata->op_gen) * count, + FAIL); /* Casting away const OK -NAF */ /* Clean up if we are done */ - if(depth == 0) { + if (depth == 0) { /* Add remaining elements */ - if(udata->nelem > 0) - if(H5S__hyper_proj_int_build_proj(udata) < 0) + if (udata->nelem > 0) + if (H5S__hyper_proj_int_build_proj(udata) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't add elements to projected selection") /* Append remaining span trees */ - for(u = udata->ds_rank - 1; u > 0; u--) - if(udata->ps_span_info[u]) { - if(H5S__hyper_append_span(&udata->ps_span_info[u - 1], - udata->ds_rank - u + 1, udata->ds_low[u - 1], - udata->ds_low[u - 1], - udata->ps_span_info[u]) < 0) + for (u = udata->ds_rank - 1; u > 0; u--) + if (udata->ps_span_info[u]) { + if (H5S__hyper_append_span(&udata->ps_span_info[u - 1], udata->ds_rank - u + 1, + udata->ds_low[u - 1], udata->ds_low[u - 1], + udata->ps_span_info[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTAPPEND, FAIL, "can't allocate hyperslab span") H5S__hyper_free_span_info(udata->ps_span_info[u]); udata->ps_span_info[u] = NULL; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_iterate() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_project_intersection @@ -11282,38 +11577,29 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, within the selection of dst_space USAGE herr_t H5S__hyper_project_intersection(src_space,dst_space,src_intersect_space,proj_space,share_selection) - H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with src_intersect_space - H5S_t *dst_space; IN: Selection that is mapped to src_space, and which contains the result - H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the result - H5S_t *proj_space; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation - hbool_t share_selection; IN: Whether we are allowed to share structures inside dst_space with proj_space - RETURNS - Non-negative on success/Negative on failure. - DESCRIPTION - Projects the intersection of of the selections of src_space and - src_intersect_space within the selection of src_space as a selection - within the selection of dst_space. The result is placed in the selection - of proj_space. Note src_space, dst_space, and src_intersect_space do not - need to use hyperslab selections, but they cannot use point selections. - The result is always a hyperslab or none selection. Note also that - proj_space can share some span trees with dst_space, so proj_space - must not be subsequently modified if dst_space must be preserved. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG + H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with +src_intersect_space H5S_t *dst_space; IN: Selection that is mapped to src_space, and which contains the +result H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space +to obtain the result H5S_t *proj_space; OUT: Will contain the result (intersection of src_intersect_space +and src_space projected from src_space to dst_space) after the operation hbool_t share_selection; IN: Whether +we are allowed to share structures inside dst_space with proj_space RETURNS Non-negative on success/Negative +on failure. DESCRIPTION Projects the intersection of of the selections of src_space and src_intersect_space +within the selection of src_space as a selection within the selection of dst_space. The result is placed in +the selection of proj_space. Note src_space, dst_space, and src_intersect_space do not need to use hyperslab +selections, but they cannot use point selections. The result is always a hyperslab or none selection. Note +also that proj_space can share some span trees with dst_space, so proj_space must not be subsequently modified +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) + const 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; - herr_t ret_value = SUCCEED; /* Return value */ + 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; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -11332,11 +11618,12 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_HYPERSLABS); /* Set up ss_span_info */ - if(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_HYPERSLABS) { + 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 */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source hyperslab selection") + 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 */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for source hyperslab selection") /* Simply point to existing span tree */ ss_span_info = src_space->select.sel_info.hslab->span_lst; @@ -11345,18 +11632,20 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create temporary span tree from all selection */ HDassert(H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_ALL); - if(NULL == (ss_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(src_space), - H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, src_space->extent.size))) + if (NULL == (ss_span_info_buf = + H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(src_space), H5S_hyper_zeros_g, + H5S_hyper_zeros_g, H5S_hyper_ones_g, src_space->extent.size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL source space") ss_span_info = ss_span_info_buf; } /* end else */ /* Set up ds_span_info */ - if(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_HYPERSLABS) { + 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 */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for dsetination hyperslab selection") + 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 */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for dsetination hyperslab selection") /* Simply point to existing span tree */ ds_span_info = dst_space->select.sel_info.hslab->span_lst; @@ -11365,40 +11654,43 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create temporary span tree from all selection */ HDassert(H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_ALL); - if(NULL == (ds_span_info_buf = H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(dst_space), - H5S_hyper_zeros_g, H5S_hyper_zeros_g, H5S_hyper_ones_g, dst_space->extent.size))) + if (NULL == (ds_span_info_buf = + H5S__hyper_make_spans(H5S_GET_EXTENT_NDIMS(dst_space), H5S_hyper_zeros_g, + H5S_hyper_zeros_g, H5S_hyper_ones_g, dst_space->extent.size))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't create span tree for ALL destination space") ds_span_info = ds_span_info_buf; } /* end else */ /* 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 */ - HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source intersect hyperslab selection") + 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 */ + HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, + "can't construct span tree for source intersect hyperslab selection") /* Initialize udata */ /* We will use op_info[0] for nelem and op_info[1] for copied spans */ HDmemset(&udata, 0, sizeof(udata)); - udata.ds_span[0] = ds_span_info->head; - udata.ds_low[0] = udata.ds_span[0]->low; - udata.ss_rank = H5S_GET_EXTENT_NDIMS(src_space); - udata.ds_rank = H5S_GET_EXTENT_NDIMS(dst_space); - udata.op_gen = H5S__hyper_get_op_gen(); + udata.ds_span[0] = ds_span_info->head; + udata.ds_low[0] = udata.ds_span[0]->low; + udata.ss_rank = H5S_GET_EXTENT_NDIMS(src_space); + udata.ds_rank = H5S_GET_EXTENT_NDIMS(dst_space); + udata.op_gen = H5S__hyper_get_op_gen(); udata.share_selection = share_selection; /* Iterate over selections and build projected span tree */ - if(H5S__hyper_proj_int_iterate(ss_span_info, src_intersect_space->select.sel_info.hslab->span_lst, 1, 0, &udata) < 0) + if (H5S__hyper_proj_int_iterate(ss_span_info, src_intersect_space->select.sel_info.hslab->span_lst, 1, 0, + &udata) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "selection iteration failed") /* Remove current selection from proj_space */ - if(H5S_SELECT_RELEASE(proj_space) < 0) + if (H5S_SELECT_RELEASE(proj_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Check for elements in projected space */ - if(udata.ps_span_info[0]) { + if (udata.ps_span_info[0]) { /* Allocate space for the hyperslab selection information (note this sets * diminfo_valid to FALSE, diminfo arrays to 0, and span list to NULL) */ - if(NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t))) + if (NULL == (proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info") /* Set selection type */ @@ -11409,7 +11701,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Set span tree */ proj_space->select.sel_info.hslab->span_lst = udata.ps_span_info[0]; - udata.ps_span_info[0] = NULL; + udata.ps_span_info[0] = NULL; /* Set the number of elements in current selection */ proj_space->select.num_elem = H5S__hyper_spans_nelem(proj_space->select.sel_info.hslab->span_lst); @@ -11421,48 +11713,47 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, } /* end if */ 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") + if (H5S_select_none(proj_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") done: /* Free ss_span_info_buf */ - if(ss_span_info_buf) { + if (ss_span_info_buf) { H5S__hyper_free_span_info(ss_span_info_buf); ss_span_info_buf = NULL; } /* end if */ /* Free ds_span_info_buf */ - if(ds_span_info_buf) { + if (ds_span_info_buf) { H5S__hyper_free_span_info(ds_span_info_buf); ds_span_info_buf = NULL; } /* end if */ /* Cleanup on error */ - if(ret_value < 0) { + if (ret_value < 0) { unsigned u; /* Free span trees */ - for(u = 0; u < udata.ds_rank; u++) - if(udata.ps_span_info[u]) { + for (u = 0; u < udata.ds_rank; u++) + if (udata.ps_span_info[u]) { H5S__hyper_free_span_info(udata.ps_span_info[u]); udata.ps_span_info[u] = NULL; } /* end if */ - } /* end if */ + } /* end if */ #ifndef NDEBUG /* Verify there are no more span trees */ { unsigned u; - for(u = 0; u < H5S_MAX_RANK; u++) + for (u = 0; u < H5S_MAX_RANK; u++) HDassert(!udata.ps_span_info[u]); - } /* end block */ + } /* end block */ #endif /* NDEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_diminfo @@ -11488,20 +11779,19 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, REVISION LOG --------------------------------------------------------------------------*/ static void -H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, - hsize_t *block, hsize_t clip_size) +H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, hsize_t *block, hsize_t clip_size) { FUNC_ENTER_STATIC_NOERR /* Check for selection outside clip size */ - if(start >= clip_size) { - if(*block == H5S_UNLIMITED) + if (start >= clip_size) { + if (*block == H5S_UNLIMITED) *block = 0; else *count = 0; } /* end if */ /* Check for single block in unlimited dimension */ - else if((*block == H5S_UNLIMITED) || (*block == stride)) { + else if ((*block == H5S_UNLIMITED) || (*block == stride)) { /* Calculate actual block size for this clip size */ *block = clip_size - start; *count = (hsize_t)1; @@ -11517,7 +11807,6 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_get_clip_diminfo() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_clip_unlim @@ -11542,11 +11831,11 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) { - H5S_hyper_sel_t *hslab = NULL; /* Convenience pointer to hyperslab info */ - hsize_t orig_count; /* Original count in unlimited dimension */ - int orig_unlim_dim; /* Original unliminted dimension */ - H5S_hyper_dim_t *diminfo = NULL; /* Convenience pointer to diminfo.opt in unlimited dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_hyper_sel_t *hslab = NULL; /* Convenience pointer to hyperslab info */ + hsize_t orig_count; /* Original count in unlimited dimension */ + int orig_unlim_dim; /* Original unliminted dimension */ + H5S_hyper_dim_t *diminfo = NULL; /* Convenience pointer to diminfo.opt in unlimited dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -11573,17 +11862,17 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) space->select.sel_info.hslab->unlim_dim = -1; /* Check for nothing returned */ - if((diminfo->block == 0) || (diminfo->count == 0)) { + if ((diminfo->block == 0) || (diminfo->count == 0)) { /* Convert to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") /* Reset the convenience pointers */ - hslab = NULL; + hslab = NULL; diminfo = NULL; } /* end if */ /* Check for single block in unlimited dimension */ - else if(orig_count == (hsize_t)1) { + else if (orig_count == (hsize_t)1) { /* Calculate number of elements */ space->select.num_elem = diminfo->block * hslab->num_elem_non_unlim; @@ -11597,10 +11886,10 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) /* Check if last block is partial. If superset is set, just keep the * last block complete to speed computation. */ HDassert(clip_size > diminfo->start); - if(((diminfo->stride * (diminfo->count - (hsize_t)1)) + diminfo->block) - > (clip_size - diminfo->start)) { - hsize_t start[H5S_MAX_RANK]; - hsize_t block[H5S_MAX_RANK]; + if (((diminfo->stride * (diminfo->count - (hsize_t)1)) + diminfo->block) > + (clip_size - diminfo->start)) { + hsize_t start[H5S_MAX_RANK]; + hsize_t block[H5S_MAX_RANK]; unsigned u; /* Last block is partial, need to construct compound selection */ @@ -11609,22 +11898,23 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) /* Set block to clip_size in unlimited dimension, H5S_MAX_SIZE in * others so only unlimited dimension is clipped */ - for(u = 0; u < space->extent.rank; u++) - if((int)u == orig_unlim_dim) + for (u = 0; u < space->extent.rank; u++) + if ((int)u == orig_unlim_dim) block[u] = clip_size; else block[u] = H5S_MAX_SIZE; /* Generate span tree in selection */ - if(!hslab->span_lst) - if(H5S__hyper_generate_spans(space) < 0) + if (!hslab->span_lst) + if (H5S__hyper_generate_spans(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to generate span tree") /* Indicate that the regular dimensions are no longer valid */ hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; /* "And" selection with calculated block to perform clip operation */ - if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0) + if (H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, + block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs") } /* end if */ else @@ -11633,17 +11923,16 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) } /* end else */ /* Update the upper bound, if the diminfo is valid */ - if(hslab && (H5S_DIMINFO_VALID_YES == hslab->diminfo_valid)) + if (hslab && (H5S_DIMINFO_VALID_YES == hslab->diminfo_valid)) hslab->diminfo.high_bounds[orig_unlim_dim] = - hslab->diminfo.opt[orig_unlim_dim].start + - hslab->diminfo.opt[orig_unlim_dim].stride * (hslab->diminfo.opt[orig_unlim_dim].count - 1) + - (hslab->diminfo.opt[orig_unlim_dim].block - 1); + hslab->diminfo.opt[orig_unlim_dim].start + + hslab->diminfo.opt[orig_unlim_dim].stride * (hslab->diminfo.opt[orig_unlim_dim].count - 1) + + (hslab->diminfo.opt[orig_unlim_dim].block - 1); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_clip_unlim() */ - /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_extent_real @@ -11672,13 +11961,12 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) REVISION LOG --------------------------------------------------------------------------*/ static hsize_t -H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, - hbool_t incl_trail) +H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, hbool_t incl_trail) { const H5S_hyper_dim_t *diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension */ - hsize_t count; - hsize_t rem_slices; - hsize_t ret_value = 0; /* Return value */ + hsize_t count; + hsize_t rem_slices; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -11689,10 +11977,9 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, diminfo = &clip_space->select.sel_info.hslab->diminfo.opt[clip_space->select.sel_info.hslab->unlim_dim]; - if(num_slices == 0) + if (num_slices == 0) ret_value = incl_trail ? diminfo->start : 0; - else if((diminfo->block == H5S_UNLIMITED) - || (diminfo->block == diminfo->stride)) + else if ((diminfo->block == H5S_UNLIMITED) || (diminfo->block == diminfo->stride)) /* Unlimited block, just set the extent large enough for the block size * to match num_slices */ ret_value = diminfo->start + num_slices; @@ -11707,25 +11994,23 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, /* Calculate slices remaining */ rem_slices = num_slices - (count * diminfo->block); - if(rem_slices > 0) + if (rem_slices > 0) /* Must end extent in middle of partial block (or beginning of empty * block if include_trailing_space and rem_slices == 0) */ ret_value = diminfo->start + (count * diminfo->stride) + rem_slices; else { - if(incl_trail) + if (incl_trail) /* End extent just before first missing block */ ret_value = diminfo->start + (count * diminfo->stride); else /* End extent at end of last block */ - ret_value = diminfo->start + ((count - (hsize_t)1) - * diminfo->stride) + diminfo->block; + ret_value = diminfo->start + ((count - (hsize_t)1) * diminfo->stride) + diminfo->block; } /* end else */ - } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_get_clip_extent_real() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent @@ -11735,30 +12020,20 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, USAGE hsize_t H5S__hyper_get_clip_extent(clip_space,match_space,incl_trail) const H5S_t *clip_space, IN: Space that clip size will be calculated based on - const H5S_t *match_space, IN: Space containing the same number of elements as clip_space should after clipping - hbool_t incl_trail; IN: Whether to include trailing unselected space - RETURNS - Calculated clip extent (never fails) - DESCRIPTION - Calculates and returns the extent that clip_space should be clipped to - (via H5S_hyper_clip_unlim) in order for it to contain the same number - of elements as match_space. If the clipped selection would end - immediately before a section of unselected space (i.e. at the end of a - block), then if incl_trail is TRUE, the returned clip extent is - selected to include that trailing "blank" space, otherwise it is - selected to end at the end before the blank space. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Note this assumes the offset has been normalized. - EXAMPLES - REVISION LOG + const H5S_t *match_space, IN: Space containing the same number of elements as clip_space should after +clipping hbool_t incl_trail; IN: Whether to include trailing unselected space RETURNS Calculated clip +extent (never fails) DESCRIPTION Calculates and returns the extent that clip_space should be clipped to (via +H5S_hyper_clip_unlim) in order for it to contain the same number of elements as match_space. If the clipped +selection would end immediately before a section of unselected space (i.e. at the end of a block), then if +incl_trail is TRUE, the returned clip extent is selected to include that trailing "blank" space, otherwise it +is selected to end at the end before the blank space. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Note this +assumes the offset has been normalized. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, - hbool_t incl_trail) +H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbool_t incl_trail) { - hsize_t num_slices; /* Number of slices in unlimited dimension */ - hsize_t ret_value = 0; /* Return value */ + hsize_t num_slices; /* Number of slices in unlimited dimension */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -11768,17 +12043,15 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, HDassert(clip_space->select.sel_info.hslab->unlim_dim >= 0); /* Check for "none" match space */ - if(match_space->select.type->type == H5S_SEL_NONE) + if (match_space->select.type->type == H5S_SEL_NONE) num_slices = (hsize_t)0; else { HDassert(match_space->select.type->type == H5S_SEL_HYPERSLABS); HDassert(match_space->select.sel_info.hslab); /* Calculate number of slices */ - num_slices = match_space->select.num_elem - / clip_space->select.sel_info.hslab->num_elem_non_unlim; - HDassert((match_space->select.num_elem - % clip_space->select.sel_info.hslab->num_elem_non_unlim) == 0); + num_slices = match_space->select.num_elem / clip_space->select.sel_info.hslab->num_elem_non_unlim; + HDassert((match_space->select.num_elem % clip_space->select.sel_info.hslab->num_elem_non_unlim) == 0); } /* end else */ /* Call "real" get_clip_extent function */ @@ -11788,7 +12061,6 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent_match @@ -11799,35 +12071,27 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, USAGE hsize_t H5S__hyper_get_clip_extent_match(clip_space,match_space,match_clip_size,incl_trail) const H5S_t *clip_space, IN: Space that clip size will be calculated based on - const H5S_t *match_space, IN: Space that, after being clipped to match_clip_size, contains the same number of elements as clip_space should after clipping - hsize_t match_clip_size, IN: Extent match_space would be clipped to to match the number of elements in clip_space - hbool_t incl_trail; IN: Whether to include trailing unselected space - RETURNS - Calculated clip extent (never fails) - DESCRIPTION - Calculates and returns the extent that clip_space should be clipped to - (via H5S_hyper_clip_unlim) in order for it to contain the same number - of elements as match_space would have after being clipped to - match_clip_size. If the clipped selection would end immediately - before a section of unselected space (i.e. at the end of a block), - then if incl_trail is TRUE, the returned clip extent is selected to - include that trailing "blank" space, otherwise it is selected to end - at the end before the blank space. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Note this assumes the offset has been normalized. - EXAMPLES - REVISION LOG + const H5S_t *match_space, IN: Space that, after being clipped to match_clip_size, contains the same +number of elements as clip_space should after clipping hsize_t match_clip_size, IN: Extent match_space would +be clipped to to match the number of elements in clip_space hbool_t incl_trail; IN: Whether to include +trailing unselected space RETURNS Calculated clip extent (never fails) DESCRIPTION Calculates and returns the +extent that clip_space should be clipped to (via H5S_hyper_clip_unlim) in order for it to contain the same +number of elements as match_space would have after being clipped to match_clip_size. If the clipped selection +would end immediately before a section of unselected space (i.e. at the end of a block), then if incl_trail is +TRUE, the returned clip extent is selected to include that trailing "blank" space, otherwise it is selected to +end at the end before the blank space. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Note this assumes the +offset has been normalized. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ 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) +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) { - const H5S_hyper_dim_t *match_diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension in match_space */ - hsize_t count; /* Temporary count */ - hsize_t block; /* Temporary block */ - hsize_t num_slices; /* Number of slices in unlimited dimension */ - hsize_t ret_value = 0; /* Return value */ + const H5S_hyper_dim_t + *match_diminfo; /* Convenience pointer to opt_unlim_diminfo in unlimited dimension in match_space */ + hsize_t count; /* Temporary count */ + hsize_t block; /* Temporary block */ + hsize_t num_slices; /* Number of slices in unlimited dimension */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -11838,10 +12102,11 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, HDassert(match_space->select.sel_info.hslab); HDassert(clip_space->select.sel_info.hslab->unlim_dim >= 0); HDassert(match_space->select.sel_info.hslab->unlim_dim >= 0); - HDassert(clip_space->select.sel_info.hslab->num_elem_non_unlim - == match_space->select.sel_info.hslab->num_elem_non_unlim); + HDassert(clip_space->select.sel_info.hslab->num_elem_non_unlim == + match_space->select.sel_info.hslab->num_elem_non_unlim); - match_diminfo = &match_space->select.sel_info.hslab->diminfo.opt[match_space->select.sel_info.hslab->unlim_dim]; + match_diminfo = + &match_space->select.sel_info.hslab->diminfo.opt[match_space->select.sel_info.hslab->unlim_dim]; /* Get initial count and block */ count = match_diminfo->count; @@ -11850,10 +12115,10 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, /* Calculate number of slices */ /* Check for nothing returned */ - if((block == 0) || (count == 0)) + if ((block == 0) || (count == 0)) num_slices = (hsize_t)0; /* Check for single block in unlimited dimension */ - else if(count == (hsize_t)1) + else if (count == (hsize_t)1) num_slices = block; else { /* Calculate initial num_slices */ @@ -11861,15 +12126,15 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, /* Check for partial last block */ HDassert(match_clip_size >= match_diminfo->start); - if(((match_diminfo->stride * (count - (hsize_t)1)) + block) - > (match_clip_size - match_diminfo->start)) { + if (((match_diminfo->stride * (count - (hsize_t)1)) + block) > + (match_clip_size - match_diminfo->start)) { /* Subtract slices missing from last block */ - HDassert((((match_diminfo->stride * (count - (hsize_t)1)) + block) - - (match_clip_size - match_diminfo->start)) < num_slices); - num_slices -= ((match_diminfo->stride * (count - (hsize_t)1)) - + block) - (match_clip_size - match_diminfo->start); + HDassert((((match_diminfo->stride * (count - (hsize_t)1)) + block) - + (match_clip_size - match_diminfo->start)) < num_slices); + num_slices -= ((match_diminfo->stride * (count - (hsize_t)1)) + block) - + (match_clip_size - match_diminfo->start); } /* end if */ - } /* end else */ + } /* end else */ /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); @@ -11878,7 +12143,6 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent_match() */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_unlim_block @@ -11904,14 +12168,14 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, 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 */ - 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_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ + 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 */ FUNC_ENTER_NOAPI(NULL) @@ -11925,10 +12189,9 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) /* Set start to select block_indexth block in unlimited dimension and set * count to 1 in that dimension to only select that block. Copy all other * diminfo parameters. */ - for(u = 0; u < space->extent.rank; u++) { - if((int)u == hslab->unlim_dim){ - start[u] = hslab->diminfo.opt[u].start + (block_index - * hslab->diminfo.opt[u].stride); + for (u = 0; u < space->extent.rank; u++) { + if ((int)u == hslab->unlim_dim) { + start[u] = hslab->diminfo.opt[u].start + (block_index * hslab->diminfo.opt[u].stride); count[u] = (hsize_t)1; } /* end if */ else { @@ -11936,17 +12199,17 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) count[u] = hslab->diminfo.opt[u].count; } /* end else */ stride[u] = hslab->diminfo.opt[u].stride; - block[u] = hslab->diminfo.opt[u].block; + block[u] = hslab->diminfo.opt[u].block; } /* end for */ /* Create output space, copy extent */ - if(NULL == (space_out = H5S_create(H5S_SIMPLE))) + if (NULL == (space_out = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "unable to create output dataspace") - if(H5S__extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0) + if (H5S__extent_copy_real(&space_out->extent, &space->extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "unable to copy destination space extent") /* Select block as defined by start/stride/count/block computed above */ - if(H5S_select_hyperslab(space_out, H5S_SELECT_SET, start, stride, count, block) < 0) + if (H5S_select_hyperslab(space_out, H5S_SELECT_SET, start, stride, count, block) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "can't select hyperslab") /* Set return value */ @@ -11954,14 +12217,13 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) done: /* Free space on error */ - if(!ret_value) - if(space_out && H5S_close(space_out) < 0) + if (!ret_value) + if (space_out && H5S_close(space_out) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_unlim_block */ - /*-------------------------------------------------------------------------- NAME H5S_hyper_get_first_inc_block @@ -11987,12 +12249,11 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) REVISION LOG --------------------------------------------------------------------------*/ hsize_t -H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, - hbool_t *partial) +H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *partial) { - H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ - H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ - hsize_t ret_value = 0; + H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ + H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ + hsize_t ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -12006,30 +12267,28 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, diminfo = &hslab->diminfo.opt[hslab->unlim_dim]; /* Check for selection outside of clip_size */ - if(diminfo->start >= clip_size) { + if (diminfo->start >= clip_size) { ret_value = 0; - if(partial) + if (partial) partial = FALSE; } /* end if */ else { /* Calculate index of first incomplete block */ - ret_value = (clip_size - diminfo->start + diminfo->stride - - diminfo->block) / diminfo->stride; + ret_value = (clip_size - diminfo->start + diminfo->stride - diminfo->block) / diminfo->stride; - if(partial) { + if (partial) { /* Check for partial block */ - if((diminfo->stride * ret_value) < (clip_size - diminfo->start)) + if ((diminfo->stride * ret_value) < (clip_size - diminfo->start)) *partial = TRUE; else *partial = FALSE; } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_first_inc_block */ - /*-------------------------------------------------------------------------- NAME H5Sis_regular_hyperslab @@ -12053,16 +12312,16 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, htri_t H5Sis_regular_hyperslab(hid_t spaceid) { - H5S_t *space; /* Dataspace to query */ - htri_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") ret_value = H5S__hyper_is_regular(space); @@ -12071,7 +12330,6 @@ H5Sis_regular_hyperslab(hid_t spaceid) FUNC_LEAVE_API(ret_value) } /* end H5Sis_regular_hyperslab() */ - /*-------------------------------------------------------------------------- NAME H5Sget_regular_hyperslab @@ -12099,39 +12357,37 @@ H5Sis_regular_hyperslab(hid_t spaceid) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], - hsize_t count[], hsize_t block[]) +H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[]) { - H5S_t *space; /* Dataspace to query */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t * space; /* Dataspace to query */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*h*h*h*h", spaceid, start, stride, count, block); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_HYPERSLABS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection") - if(TRUE != H5S__hyper_is_regular(space)) + if (TRUE != H5S__hyper_is_regular(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a regular hyperslab selection") /* Retrieve hyperslab parameters */ - if(start) - for(u = 0; u < space->extent.rank; u++) + if (start) + for (u = 0; u < space->extent.rank; u++) start[u] = space->select.sel_info.hslab->diminfo.app[u].start; - if(stride) - for(u = 0; u < space->extent.rank; u++) + if (stride) + for (u = 0; u < space->extent.rank; u++) stride[u] = space->select.sel_info.hslab->diminfo.app[u].stride; - if(count) - for(u = 0; u < space->extent.rank; u++) + if (count) + for (u = 0; u < space->extent.rank; u++) count[u] = space->select.sel_info.hslab->diminfo.app[u].count; - if(block) - for(u = 0; u < space->extent.rank; u++) + if (block) + for (u = 0; u < space->extent.rank; u++) block[u] = space->select.sel_info.hslab->diminfo.app[u].block; done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_regular_hyperslab() */ - diff --git a/src/H5Smodule.h b/src/H5Smodule.h index 67ac785b9cd..bb33eb855a7 100644 --- a/src/H5Smodule.h +++ b/src/H5Smodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,42 @@ * H5S package. Including this header means that the source file * is part of the H5S package. */ -#ifndef _H5Smodule_H -#define _H5Smodule_H +#ifndef H5Smodule_H +#define H5Smodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5S_MODULE -#define H5_MY_PKG H5S -#define H5_MY_PKG_ERR H5E_DATASPACE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5S +#define H5_MY_PKG_ERR H5E_DATASPACE +#define H5_MY_PKG_INIT YES -#endif /* _H5Smodule_H */ +/**\defgroup H5S H5S + * \brief Dataspace Interface + * + * \details The Dataspace Interface provides functions for creating and + * working with dataspaces. + * + * A dataspace has two roles: + * + * \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. + * + * 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). + * + * A dataspace can consist of: + * \li no elements (NULL) + * \li a single element (scalar), or + * \li a simple array. + * + */ +#endif /* H5Smodule_H */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 147fd25da85..7b85209c650 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,26 +22,25 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ #ifdef H5_HAVE_PARALLEL /****************/ /* Local Macros */ /****************/ -#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 +#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 /*******************/ /* Local Variables */ @@ -53,56 +52,49 @@ /* Node in linked list of MPI data types created during traversal of irregular hyperslab selection */ typedef struct H5S_mpio_mpitype_node_t { - MPI_Datatype type; /* MPI Datatype */ - struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ + MPI_Datatype type; /* MPI Datatype */ + struct H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ } H5S_mpio_mpitype_node_t; /* List to track MPI data types generated during traversal of irregular hyperslab selection */ typedef struct H5S_mpio_mpitype_list_t { - H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */ - H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */ + H5S_mpio_mpitype_node_t *head; /* Pointer to head of list */ + H5S_mpio_mpitype_node_t *tail; /* Pointer to tail of list */ } H5S_mpio_mpitype_list_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5S__mpio_all_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_none_type(MPI_Datatype *new_type, int *count, - hbool_t *is_derived_type); -static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, - MPI_Aint *disp, MPI_Datatype *new_type); -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, 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_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__mpio_all_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_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *disp, + MPI_Datatype *new_type); +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, + 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_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); -static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, - size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, - H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen); - +static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t elmt_size, + const MPI_Datatype *elmt_type, MPI_Datatype *span_type, + H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */ H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t); - /*------------------------------------------------------------------------- * Function: H5S__mpio_all_type * @@ -120,14 +112,14 @@ H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t); *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, - MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - hsize_t total_bytes; - hssize_t snelmts; /* Total number of elmts (signed) */ - hsize_t nelmts; /* Total number of elmts */ - hsize_t bigio_count; /* Transition point to create derived type */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t total_bytes; + hssize_t snelmts; /* Total number of elmts (signed) */ + hsize_t nelmts; /* Total number of elmts */ + hsize_t bigio_count; /* Transition point to create derived type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -135,15 +127,15 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, HDassert(space); /* Just treat the entire extent as a block of bytes */ - if((snelmts = (hssize_t)H5S_GET_EXTENT_NPOINTS(space)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") + if ((snelmts = (hssize_t)H5S_GET_EXTENT_NPOINTS(space)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); total_bytes = (hsize_t)elmt_size * nelmts; bigio_count = H5_mpi_get_bigio_count(); /* Verify that the size can be expressed as a 32 bit integer */ - if(bigio_count >= total_bytes) { + if (bigio_count >= total_bytes) { /* fill in the return values */ *new_type = MPI_BYTE; H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t); @@ -151,9 +143,10 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, } else { /* Create a LARGE derived datatype for this transfer */ - if(H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large datatype from the all selection") - *count = 1; + if (H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large datatype from the all selection") + *count = 1; *is_derived_type = TRUE; } @@ -161,7 +154,6 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_all_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_none_type * @@ -184,14 +176,13 @@ H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type FUNC_ENTER_STATIC_NOERR /* fill in the return values */ - *new_type = MPI_BYTE; - *count = 0; + *new_type = MPI_BYTE; + *count = 0; *is_derived_type = FALSE; FUNC_LEAVE_NOAPI(SUCCEED) } /* H5S__mpio_none_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_create_point_datatype * @@ -206,52 +197,53 @@ H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, - MPI_Aint *disp, MPI_Datatype *new_type) +H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint *disp, MPI_Datatype *new_type) { - 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; - MPI_Datatype *inner_types = NULL; + 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; + MPI_Datatype *inner_types = NULL; #if MPI_VERSION < 3 - int *blocks = NULL; /* Array of block sizes for MPI hindexed create call */ - hsize_t u; /* Local index variable */ + 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 */ - int mpi_code; /* MPI error code */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t bigio_count; /* Transition point to create derived type */ + int mpi_code; /* MPI error code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Create an MPI datatype for an element */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) elmt_type_created = TRUE; bigio_count = H5_mpi_get_bigio_count(); /* Check whether standard or BIGIO processing will be employeed */ - if(bigio_count >= num_points) { + if (bigio_count >= num_points) { #if MPI_VERSION >= 3 /* Create an MPI datatype for the whole point selection */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed_block((int)num_points, 1, disp, elmt_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_indexed_block failed", mpi_code) #else /* Allocate block sizes for MPI datatype call */ - if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points))) + if (NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - for(u = 0; u < num_points; u++) + for (u = 0; u < num_points; u++) blocks[u] = 1; /* Create an MPI datatype for the whole point selection */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)num_points, blocks, disp, elmt_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif /* Commit MPI datatype for later use */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } else { @@ -259,9 +251,9 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, * We'll create an hindexed_block type for every 2G point count and then combine * those and any remaining points into a single large datatype. */ - int total_types, i; - int remaining_points; - int num_big_types; + int total_types, i; + int remaining_points; + int num_big_types; hsize_t leftover; /* Calculate how many Big MPI datatypes are needed to represent the buffer */ @@ -273,82 +265,85 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, total_types = (int)(remaining_points) ? (num_big_types + 1) : num_big_types; /* Allocate array if MPI derived types needed */ - if(NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types)))) + if (NULL == (inner_types = (MPI_Datatype *)H5MM_malloc((sizeof(MPI_Datatype) * (size_t)total_types)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - if(NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types))) + if (NULL == (inner_blocks = (int *)H5MM_malloc(sizeof(int) * (size_t)total_types))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - if(NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types))) + if (NULL == (inner_disps = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * (size_t)total_types))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") #if MPI_VERSION < 3 /* Allocate block sizes for MPI datatype call */ - if(NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count))) + if (NULL == (blocks = (int *)H5MM_malloc(sizeof(int) * bigio_count))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") - for(u = 0; u < bigio_count; u++) + for (u = 0; u < bigio_count; u++) blocks[u] = 1; #endif - for(i = 0; i < num_big_types; i++) { + for (i = 0; i < num_big_types; i++) { #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, - 1, &disp[(hsize_t)i*bigio_count], elmt_type, &inner_types[i]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, 1, + &disp[(hsize_t)i * bigio_count], + elmt_type, &inner_types[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count, - blocks, &disp[i*bigio_count], elmt_type, &inner_types[i]))) + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)bigio_count, blocks, &disp[i * bigio_count], + elmt_type, &inner_types[i]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif inner_blocks[i] = 1; inner_disps[i] = 0; } /* end for*/ - if(remaining_points) { + if (remaining_points) { #if MPI_VERSION >= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points, - 1, &disp[(hsize_t)num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block( + remaining_points, 1, &disp[(hsize_t)num_big_types * bigio_count], + elmt_type, &inner_types[num_big_types]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, - blocks, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, blocks, + &disp[num_big_types * bigio_count], + elmt_type, &inner_types[num_big_types]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) #endif inner_blocks[num_big_types] = 1; - inner_disps[num_big_types] = 0; + inner_disps[num_big_types] = 0; } - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types, - inner_blocks, inner_disps, inner_types, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types, inner_blocks, inner_disps, + inner_types, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code); - for(i = 0; i < total_types; i++) + for (i = 0; i < total_types; i++) MPI_Type_free(&inner_types[i]); /* Commit MPI datatype for later use */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } /* end else */ done: - if(elmt_type_created) + if (elmt_type_created) MPI_Type_free(&elmt_type); #if MPI_VERSION < 3 - if(blocks) + if (blocks) H5MM_free(blocks); #endif - if(inner_types) + if (inner_types) H5MM_free(inner_types); - if(inner_blocks) + if (inner_blocks) H5MM_free(inner_blocks); - if(inner_disps) + if (inner_disps) H5MM_free(inner_disps); FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_create_point_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_point_type * @@ -370,16 +365,15 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, *------------------------------------------------------------------------- */ 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) +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*/ - 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 */ - hsize_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hsize_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -387,25 +381,25 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ HDassert(space); /* Get the total number of points selected */ - if((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") num_points = (hsize_t)snum_points; /* Allocate array for element displacements */ - 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") + 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 array for element permutation - returned to caller */ - if(do_permute) - if(NULL == (*permute = (hsize_t *)H5MM_malloc(sizeof(hsize_t) * num_points))) + if (do_permute) + if (NULL == (*permute = (hsize_t *)H5MM_malloc(sizeof(hsize_t) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate permutation array") /* Iterate through list of elements */ curr = space->select.sel_info.pnt_lst->head; - for(u = 0 ; u < num_points ; u++) { + for (u = 0; u < num_points; u++) { /* Calculate the displacement of the current point */ hsize_t disp_tmp = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt); - if(disp_tmp > LONG_MAX) /* Maximum value of type long */ + if (disp_tmp > LONG_MAX) /* Maximum value of type long */ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "disp overflow") disp[u] = (MPI_Aint)disp_tmp; disp[u] *= (MPI_Aint)elmt_size; @@ -425,22 +419,22 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ * point 4: map[3] = 2, move the 2nd position since point 1 has a higher disp, * but points 2 and 3 have lower displacements. */ - if(do_permute) { - if(u > 0 && disp[u] < disp[u - 1]) { + if (do_permute) { + if (u > 0 && disp[u] < disp[u - 1]) { hsize_t s = 0, l = u, m = u / 2; *is_permuted = TRUE; do { - if(disp[u] > disp[m]) + if (disp[u] > disp[m]) s = m + 1; - else if(disp[u] < disp[m]) + else if (disp[u] < disp[m]) l = m; else break; m = s + ((l - s) / 2); - } while(s < l); + } while (s < l); - if(m < u) { + if (m < u) { MPI_Aint temp; temp = disp[u]; @@ -455,27 +449,27 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ /* this is a memory space, and no permutation is necessary to create the derived datatype */ else { - ; /* do nothing */ - } /* end else */ + ; /* do nothing */ + } /* end else */ /* get the next point */ curr = curr->next; } /* end for */ /* Create the MPI datatype for the set of element displacements */ - if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) + if (H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection") /* Set values about MPI datatype created */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: - if(NULL != disp) + if (NULL != disp) H5MM_free(disp); /* Release the permutation buffer, if it wasn't used */ - if(!(*is_permuted) && (*permute)) { + if (!(*is_permuted) && (*permute)) { H5MM_free(*permute); *permute = NULL; } /* end if */ @@ -483,7 +477,6 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_point_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_permute_type * @@ -508,17 +501,17 @@ 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(const 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; /* 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 */ FUNC_ENTER_STATIC @@ -526,39 +519,40 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, HDassert(space); /* Get the total number of points selected */ - if((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((snum_points = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") num_points = (hsize_t)snum_points; /* Allocate array to store point displacements */ - if(NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) + 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") /* 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 */ + sel_iter_init = TRUE; /* Selection iteration info has been initialized */ /* Set the number of elements to iterate over */ H5_CHECKED_ASSIGN(max_elem, size_t, num_points, hsize_t); /* 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 */ + 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 */ /* 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, len) < 0) + 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") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - hsize_t curr_off; /* Current offset within sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + hsize_t curr_off; /* Current offset within sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ /* Get the current offset */ curr_off = off[curr_seq]; @@ -567,19 +561,19 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, curr_len = len[curr_seq]; /* Loop, while bytes left in sequence */ - while(curr_len > 0) { + while (curr_len > 0) { /* Set the displacement of the current point */ - if(curr_off > LONG_MAX) + if (curr_off > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "curr_off overflow") disp[u] = (MPI_Aint)curr_off; /* This is a memory displacement, so for each point selected, * apply the map that was generated by the file selection */ - if((*permute)[u] != num_points) { + if ((*permute)[u] != num_points) { MPI_Aint temp = disp[u]; HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u], - (u - (*permute)[u]) * sizeof(MPI_Aint)); + (u - (*permute)[u]) * sizeof(MPI_Aint)); disp[(*permute)[u]] = temp; } /* end if */ @@ -592,30 +586,30 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, /* Decrement number of bytes left in sequence */ curr_len -= elmt_size; } /* end while */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ max_elem -= nelem; } /* end while */ /* Create the MPI datatype for the set of element displacements */ - if(H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) + if (H5S__mpio_create_point_datatype(elmt_size, num_points, disp, new_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create an MPI Datatype from point selection") /* Set values about MPI datatype created */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: /* Release selection iterator */ - if(sel_iter_init) - if(H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter_init) + if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") /* Free memory */ - if(disp) + if (disp) H5MM_free(disp); - if(*permute) { + if (*permute) { H5MM_free(*permute); *permute = NULL; } /* end if */ @@ -623,7 +617,6 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, FUNC_LEAVE_NOAPI(ret_value) } /* H5S__mpio_permute_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_reg_hyper_type * @@ -641,32 +634,32 @@ 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, hbool_t *is_derived_type) +H5S__mpio_reg_hyper_type(const 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; /* Selection iteration info */ + hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ - struct dim { /* less hassle than malloc/free & ilk */ + struct dim { /* less hassle than malloc/free & ilk */ hssize_t start; - hsize_t strid; - hsize_t block; - hsize_t xtent; - hsize_t count; + hsize_t strid; + hsize_t block; + hsize_t xtent; + hsize_t count; } d[H5S_MAX_RANK]; - hsize_t bigio_count; /* Transition point to create derived type */ - hsize_t offset[H5S_MAX_RANK]; - hsize_t max_xtent[H5S_MAX_RANK]; - H5S_hyper_dim_t *diminfo; /* [rank] */ - unsigned rank; - MPI_Datatype inner_type, outer_type; - MPI_Aint extent_len, start_disp, new_extent; - MPI_Aint lb; /* Needed as an argument for MPI_Type_get_extent */ - unsigned u; /* Local index variable */ - int i; /* Local index variable */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; + hsize_t bigio_count; /* Transition point to create derived type */ + hsize_t offset[H5S_MAX_RANK]; + hsize_t max_xtent[H5S_MAX_RANK]; + H5S_hyper_dim_t *diminfo; /* [rank] */ + unsigned rank; + MPI_Datatype inner_type, outer_type; + MPI_Aint extent_len, start_disp, new_extent; + MPI_Aint lb; /* Needed as an argument for MPI_Type_get_extent */ + unsigned u; /* Local index variable */ + int i; /* Local index variable */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -676,9 +669,9 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, bigio_count = H5_mpi_get_bigio_count(); /* 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 */ + sel_iter_init = TRUE; /* Selection iteration info has been initialized */ /* Abbreviate args */ diminfo = sel_iter.u.hyp.diminfo; @@ -687,14 +680,14 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, /* 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; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: Flattened selection\n",FUNC); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: Flattened selection\n", FUNC); #endif - for(u = 0; u < rank; ++u) { + 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].strid = diminfo[u].stride; @@ -703,14 +696,16 @@ if(H5DEBUG(S)) d[u].xtent = sel_iter.u.hyp.size[u]; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", - FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); - if(u == 0) - HDfprintf(H5DEBUG(S), " rank=%u\n", rank); - else - HDfprintf(H5DEBUG(S), "\n"); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), + "%s: start=%" PRIdHSIZE " stride=%" PRIuHSIZE " count=%" PRIuHSIZE + " block=%" PRIuHSIZE " xtent=%" PRIuHSIZE, + FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); + if (u == 0) + HDfprintf(H5DEBUG(S), " rank=%u\n", rank); + else + HDfprintf(H5DEBUG(S), "\n"); + } #endif /* Sanity check */ @@ -718,15 +713,15 @@ if(H5DEBUG(S)) { HDassert(d[u].count > 0); HDassert(d[u].xtent > 0); } /* end for */ - } /* end if */ + } /* end if */ else { /* Non-flattened selection */ rank = space->extent.rank; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S),"%s: Non-flattened selection\n",FUNC); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: Non-flattened selection\n", FUNC); #endif - for(u = 0; u < rank; ++u) { + for (u = 0; u < rank; ++u) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) d[u].start = (hssize_t)diminfo[u].start + space->select.offset[u]; d[u].strid = diminfo[u].stride; @@ -735,14 +730,16 @@ if(H5DEBUG(S)) d[u].xtent = space->extent.size[u]; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: start=%Hd stride=%Hu count=%Hu block=%Hu xtent=%Hu", - FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); - if(u == 0) - HDfprintf(H5DEBUG(S), " rank=%u\n", rank); - else - HDfprintf(H5DEBUG(S), "\n"); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), + "%s: start=%" PRIdHSIZE " stride=%" PRIuHSIZE " count=%" PRIuHSIZE + " block=%" PRIuHSIZE " xtent=%" PRIuHSIZE, + FUNC, d[u].start, d[u].strid, d[u].count, d[u].block, d[u].xtent); + if (u == 0) + HDfprintf(H5DEBUG(S), " rank=%u\n", rank); + else + HDfprintf(H5DEBUG(S), "\n"); + } #endif /* Sanity check */ @@ -750,26 +747,28 @@ if(H5DEBUG(S)) { HDassert(d[u].count > 0); HDassert(d[u].xtent > 0); } /* end for */ - } /* end else */ + } /* end else */ -/********************************************************************** - Compute array "offset[rank]" which gives the offsets for a multi- - dimensional array with dimensions "d[i].xtent" (i=0,1,...,rank-1). -**********************************************************************/ - offset[rank - 1] = 1; + /********************************************************************** + Compute array "offset[rank]" which gives the offsets for a multi- + dimensional array with dimensions "d[i].xtent" (i=0,1,...,rank-1). + **********************************************************************/ + offset[rank - 1] = 1; max_xtent[rank - 1] = d[rank - 1].xtent; #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - i = ((int)rank) - 1; - HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); -} + if (H5DEBUG(S)) { + i = ((int)rank) - 1; + HDfprintf(H5DEBUG(S), " offset[%2d]=%" PRIuHSIZE "; max_xtent[%2d]=%" PRIuHSIZE "\n", i, offset[i], i, + max_xtent[i]); + } #endif - for(i = ((int)rank) - 2; i >= 0; --i) { - offset[i] = offset[i + 1] * d[i + 1].xtent; + for (i = ((int)rank) - 2; i >= 0; --i) { + offset[i] = offset[i + 1] * d[i + 1].xtent; max_xtent[i] = max_xtent[i + 1] * d[i].xtent; #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), " offset[%2d]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), " offset[%2d]=%" PRIuHSIZE "; max_xtent[%2d]=%" PRIuHSIZE "\n", i, + offset[i], i, max_xtent[i]); #endif } /* end for */ @@ -780,14 +779,14 @@ if(H5DEBUG(S)) */ /******************************************************* -* Construct contig type for inner contig dims: -*******************************************************/ + * Construct contig type for inner contig dims: + *******************************************************/ #ifdef H5S_DEBUG -if(H5DEBUG(S)) { - HDfprintf(H5DEBUG(S), "%s: Making contig type %Zu MPI_BYTEs\n", FUNC, elmt_size); - for(i = ((int)rank) - 1; i >= 0; --i) - HDfprintf(H5DEBUG(S), "d[%d].xtent=%Hu \n", i, d[i].xtent); -} + if (H5DEBUG(S)) { + HDfprintf(H5DEBUG(S), "%s: Making contig type %zu MPI_BYTEs\n", FUNC, elmt_size); + for (i = ((int)rank) - 1; i >= 0; --i) + HDfprintf(H5DEBUG(S), "d[%d].xtent=%" PRIuHSIZE "\n", i, d[i].xtent); + } #endif /* LARGE_DATATYPE:: @@ -796,49 +795,51 @@ if(H5DEBUG(S)) { * Otherwise create a compound datatype by iterating as many times as needed * for the innertype to be created. */ - if(bigio_count >= elmt_size) { + if (bigio_count >= elmt_size) { /* Use a single MPI datatype that has a 32 bit size */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } 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") - -/******************************************************* -* Construct the type by walking the hyperslab dims -* from the inside out: -*******************************************************/ - for(i = ((int)rank) - 1; i >= 0; --i) { + 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") + + /******************************************************* + * Construct the type by walking the hyperslab dims + * from the inside out: + *******************************************************/ + for (i = ((int)rank) - 1; i >= 0; --i) { #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: Dimension i=%d \n" - "start=%Hd count=%Hu block=%Hu stride=%Hu, xtent=%Hu max_xtent=%d\n", - FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), + "%s: Dimension i=%d \n" + "start=%" PRIdHSIZE " count=%" PRIuHSIZE " block=%" PRIuHSIZE " stride=%" PRIuHSIZE + ", xtent=%" PRIuHSIZE " max_xtent=%" PRIuHSIZE "\n", + FUNC, i, d[i].start, d[i].count, d[i].block, d[i].strid, d[i].xtent, max_xtent[i]); #endif #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC,i); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "%s: i=%d Making vector-type \n", FUNC, i); #endif - /**************************************** - * Build vector type of the selection. - ****************************************/ - if(bigio_count >= d[i].count && - bigio_count >= d[i].block && bigio_count >= d[i].strid) { + /**************************************** + * Build vector type of the selection. + ****************************************/ + if (bigio_count >= d[i].count && bigio_count >= d[i].block && bigio_count >= d[i].strid) { /* All the parameters fit into 32 bit integers so create the vector type normally */ - mpi_code = MPI_Type_vector((int)(d[i].count), /* count */ - (int)(d[i].block), /* blocklength */ - (int)(d[i].strid), /* stride */ - inner_type, /* old type */ - &outer_type); /* new type */ + mpi_code = MPI_Type_vector((int)(d[i].count), /* count */ + (int)(d[i].block), /* blocklength */ + (int)(d[i].strid), /* stride */ + inner_type, /* old type */ + &outer_type); /* new type */ MPI_Type_free(&inner_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code) - } - else { + } + else { /* Things get a bit more complicated and require LARGE_DATATYPE processing * There are two MPI datatypes that need to be created: * 1) an internal contiguous block; and @@ -850,19 +851,20 @@ if(H5DEBUG(S)) * (2GB-1)number_of_blocks * the_datatype_extent. */ - MPI_Aint stride_in_bytes, inner_extent; + MPI_Aint stride_in_bytes, inner_extent; MPI_Datatype block_type; /* Create a contiguous datatype inner_type x number of BLOCKS. * Again we need to check that the number of BLOCKS can fit into * a 32 bit integer */ - if(bigio_count < d[i].block) { - if(H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large block datatype in hyper selection") + if (bigio_count < d[i].block) { + if (H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large block datatype in hyper selection") } - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) /* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default, * so we're using the MPI-2 version even though we don't need the lb @@ -877,18 +879,18 @@ if(H5DEBUG(S)) /* If the element count is larger than what a 32 bit integer can hold, * we call the large type creation function to handle that */ - if(bigio_count < d[i].count) { - if(H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large outer datatype in hyper selection") + if (bigio_count < d[i].count) { + if (H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large outer datatype in hyper selection") } /* otherwise a regular create_hvector will do */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */ - 1, /* blocklength */ - stride_in_bytes, /* stride in bytes*/ - block_type, /* old type */ - &outer_type))) /* new type */ - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */ + 1, /* blocklength */ + stride_in_bytes, /* stride in bytes*/ + block_type, /* old type */ + &outer_type))) /* new type */ + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) MPI_Type_free(&block_type); MPI_Type_free(&inner_type); @@ -900,14 +902,14 @@ if(H5DEBUG(S)) /* Calculate start and extent values of this dimension */ /* Check if value overflow to cast to type MPI_Aint */ - if(d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX) + if (d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow") - start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size; + start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size; - if(max_xtent[i] > LONG_MAX) + if (max_xtent[i] > LONG_MAX) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "max_xtent overflow") new_extent = (MPI_Aint)elmt_size * (MPI_Aint)max_xtent[i]; - if(MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_get_extent failed", mpi_code) /************************************************* @@ -915,52 +917,52 @@ if(H5DEBUG(S)) * so that it still starts at 0, but its extent * is the full extent in this dimension. *************************************************/ - if(start_disp > 0 || extent_len < new_extent) { + if (start_disp > 0 || extent_len < new_extent) { MPI_Datatype interm_type; - int block_len = 1; + int block_len = 1; HDassert(0 == lb); mpi_code = MPI_Type_create_hindexed(1, &block_len, &start_disp, outer_type, &interm_type); MPI_Type_free(&outer_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) mpi_code = MPI_Type_create_resized(interm_type, lb, new_extent, &inner_type); MPI_Type_free(&interm_type); - if(mpi_code != MPI_SUCCESS) + if (mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't resize MPI vector type", mpi_code) } /* end if */ else inner_type = outer_type; } /* end for */ -/****************************************** -* End of loop, walking through dimensions. -*******************************************/ + /****************************************** + * End of loop, walking through dimensions. + *******************************************/ /* At this point inner_type is actually the outermost type, even for 0-trip loop */ *new_type = inner_type; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* fill in the remaining return values */ - *count = 1; /* only have to move one of these suckers! */ + *count = 1; /* only have to move one of these suckers! */ *is_derived_type = TRUE; done: /* Release selection iterator */ - if(sel_iter_init) - if(H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter_init) + if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") #ifdef H5S_DEBUG -if(H5DEBUG(S)) - HDfprintf(H5DEBUG(S), "Leave %s, count=%ld is_derived_type=%t\n", FUNC, *count, *is_derived_type); + if (H5DEBUG(S)) + HDfprintf(H5DEBUG(S), "Leave %s, count=%d is_derived_type=%s\n", FUNC, *count, + (*is_derived_type) ? "TRUE" : "FALSE"); #endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__mpio_reg_hyper_type() */ - /*------------------------------------------------------------------------- * Function: H5S__mpio_span_hyper_type * @@ -979,18 +981,18 @@ if(H5DEBUG(S)) *------------------------------------------------------------------------- */ 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) +H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */ - MPI_Datatype elmt_type; /* MPI datatype for an element */ - hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */ - MPI_Datatype span_type; /* MPI datatype for overall span tree */ - hsize_t bigio_count; /* Transition point to create derived type */ - hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */ - uint64_t op_gen; /* Operation generation value */ - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_mpio_mpitype_list_t type_list; /* List to track MPI data types created */ + MPI_Datatype elmt_type; /* MPI datatype for an element */ + hbool_t elmt_type_is_derived = FALSE; /* Whether the element type has been created */ + MPI_Datatype span_type; /* MPI datatype for overall span tree */ + hsize_t bigio_count; /* Transition point to create derived type */ + hsize_t down[H5S_MAX_RANK]; /* 'down' sizes for each dimension */ + uint64_t op_gen; /* Operation generation value */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1002,18 +1004,17 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, bigio_count = H5_mpi_get_bigio_count(); /* Create the base type for an element */ - if(bigio_count >= elmt_size) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) + if (bigio_count >= elmt_size) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } - else - if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") + else if (H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large element datatype in span_hyper selection") elmt_type_is_derived = TRUE; /* Compute 'down' sizes for each dimension */ - if(H5VM_array_down(space->extent.rank, space->extent.size, down) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes") + H5VM_array_down(space->extent.rank, space->extent.size, down); /* Acquire an operation generation value for creating MPI datatypes */ op_gen = H5S__hyper_get_op_gen(); @@ -1022,31 +1023,31 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, /* Always use op_info[0] since we own this op_info, so there can be no * simultaneous operations */ type_list.head = type_list.tail = NULL; - if(H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, &type_list, 0, op_gen) < 0) + if (H5S__obtain_datatype(space->select.sel_info.hslab->span_lst, down, elmt_size, &elmt_type, &span_type, + &type_list, 0, op_gen) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") - if(MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_dup(span_type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) /* Release MPI data types generated during span tree traversal */ - if(H5S__release_datatype(&type_list) < 0) + if (H5S__release_datatype(&type_list) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "couldn't release MPI derived data type") /* fill in the remaining return values */ - *count = 1; + *count = 1; *is_derived_type = TRUE; done: /* Release resources */ - if(elmt_type_is_derived) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&elmt_type))) + if (elmt_type_is_derived) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&elmt_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__mpio_span_hyper_type() */ - /*------------------------------------------------------------------------- * Function: H5S__release_datatype * @@ -1061,8 +1062,8 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) { - H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_mpio_mpitype_node_t *curr; /* Pointer to head of list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1071,12 +1072,12 @@ H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) /* Iterate over the list, freeing the MPI data types */ curr = type_list->head; - while(curr) { - H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ - int mpi_code; /* MPI return status code */ + while (curr) { + H5S_mpio_mpitype_node_t *next; /* Pointer to next node in list */ + int mpi_code; /* MPI return status code */ /* Release the MPI data type for this span tree */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&curr->type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) /* Get pointer to next node in list */ @@ -1090,10 +1091,9 @@ H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) } /* end while */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__release_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S__obtain_datatype * @@ -1108,21 +1108,21 @@ H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list) *------------------------------------------------------------------------- */ static herr_t -H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, - size_t elmt_size, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, - H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen) +H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t elmt_size, + const MPI_Datatype *elmt_type, MPI_Datatype *span_type, + H5S_mpio_mpitype_list_t *type_list, unsigned op_info_i, uint64_t op_gen) { - H5S_hyper_span_t *span; /* Hyperslab span to iterate with */ - 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; - hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ - 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 */ + H5S_hyper_span_t *span; /* Hyperslab span to iterate with */ + 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; + hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ + 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 */ FUNC_ENTER_STATIC @@ -1132,39 +1132,41 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, bigio_count = H5_mpi_get_bigio_count(); /* Check if we've visited this span tree before */ - if(spans->op_info[op_info_i].op_gen != op_gen) { - H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */ + if (spans->op_info[op_info_i].op_gen != op_gen) { + H5S_mpio_mpitype_node_t *type_node; /* Pointer to new node in MPI data type list */ /* Allocate the initial displacement & block length buffers */ alloc_count = H5S_MPIO_INITIAL_ALLOC_COUNT; - if(NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint)))) + if (NULL == (disp = (MPI_Aint *)H5MM_malloc(alloc_count * sizeof(MPI_Aint)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") - if(NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int)))) + if (NULL == (blocklen = (int *)H5MM_malloc(alloc_count * sizeof(int)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") /* 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 */ + if (NULL == span->down) { + hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */ outercount = 0; - while(span) { - hsize_t nelmts; /* # of elements covered by current span */ + while (span) { + hsize_t nelmts; /* # of elements covered by current span */ /* 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 */ + if (outercount >= alloc_count) { + MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ + int * tmp_blocklen; /* Temporary pointer to new block length buffer */ /* Double the allocation count */ alloc_count *= 2; /* Re-allocate the buffers */ - if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + if (NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of displacements") disp = tmp_disp; - if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") + if (NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of block lengths") blocklen = tmp_blocklen; } /* end if */ @@ -1172,11 +1174,11 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, nelmts = (span->high - span->low) + 1; /* Store displacement & block length */ - disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; + disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; H5_CHECK_OVERFLOW(nelmts, hsize_t, int) - blocklen[outercount] = (int)nelmts; + blocklen[outercount] = (int)nelmts; - if(bigio_count < (hsize_t)blocklen[outercount]) + if (bigio_count < (hsize_t)blocklen[outercount]) large_block = TRUE; /* at least one block type is large, so set this flag to true */ span = span->next; @@ -1184,49 +1186,53 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, } /* end while */ /* Everything fits into integers, so cast them and use hindexed */ - if(bigio_count >= outercount && large_block == FALSE) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, &spans->op_info[op_info_i].u.down_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - } /* end if */ - else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */ - for(u = 0 ; u < outercount; u++) { + if (bigio_count >= outercount && large_block == FALSE) { + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, + &spans->op_info[op_info_i].u.down_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + } /* end if */ + else { /* LARGE_DATATYPE:: Something doesn't fit into a 32 bit integer */ + for (u = 0; u < outercount; u++) { MPI_Datatype temp_type = MPI_DATATYPE_NULL; /* create the block type from elmt_type while checking the 32 bit int limit */ - if((hsize_t)(blocklen[u]) > bigio_count) { - if(H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") + if ((hsize_t)(blocklen[u]) > bigio_count) { + if (H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large element datatype in span_hyper selection") } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_contiguous((int)blocklen[u], *elmt_type, &temp_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) /* Combine the current datatype that is created with this current block type */ - if(0 == u) /* first iteration, there is no combined datatype yet */ + if (0 == u) /* first iteration, there is no combined datatype yet */ spans->op_info[op_info_i].u.down_type = temp_type; else { - int bl[2] = {1, 1}; - MPI_Aint ds[2] = {disp[u - 1], disp[u]}; + int bl[2] = {1, 1}; + MPI_Aint ds[2] = {disp[u - 1], disp[u]}; MPI_Datatype dt[2] = {spans->op_info[op_info_i].u.down_type, temp_type}; - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, /* count */ - bl, /* blocklength */ - ds, /* stride in bytes*/ - dt, /* old type */ - &spans->op_info[op_info_i].u.down_type))) /* new type */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct( + 2, /* count */ + bl, /* blocklength */ + ds, /* stride in bytes*/ + dt, /* old type */ + &spans->op_info[op_info_i].u.down_type))) /* new type */ HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) /* Release previous temporary datatype */ - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&temp_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) } /* end else */ - } /* end for */ - } /* end else (LARGE_DATATYPE::) */ - } /* end if */ + } /* end for */ + } /* end else (LARGE_DATATYPE::) */ + } /* end if */ else { - MPI_Aint stride; /* Distance between inner MPI datatypes */ + MPI_Aint stride; /* Distance between inner MPI datatypes */ - if(NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype)))) + if (NULL == (inner_type = (MPI_Datatype *)H5MM_malloc(alloc_count * sizeof(MPI_Datatype)))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes") /* Calculate the total bytes of the lower dimension */ @@ -1234,39 +1240,44 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* Loop over span nodes */ outercount = 0; - while(span) { - MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */ - hsize_t nelmts; /* # of elements covered by current span */ + while (span) { + MPI_Datatype down_type; /* Temporary MPI datatype for a span tree node's children */ + hsize_t nelmts; /* # of elements covered by current span */ /* 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_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */ + 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_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */ /* Double the allocation count */ alloc_count *= 2; /* Re-allocate the buffers */ - if(NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + if (NULL == (tmp_disp = (MPI_Aint *)H5MM_realloc(disp, alloc_count * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of displacements") disp = tmp_disp; - if(NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of block lengths") + if (NULL == (tmp_blocklen = (int *)H5MM_realloc(blocklen, alloc_count * sizeof(int)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of block lengths") blocklen = tmp_blocklen; - if(NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc(inner_type, alloc_count * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes") + if (NULL == (tmp_inner_type = (MPI_Datatype *)H5MM_realloc( + inner_type, alloc_count * sizeof(MPI_Datatype)))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, + "can't allocate array of inner MPI datatypes") inner_type = tmp_inner_type; } /* end if */ /* Displacement should be in byte and should have dimension information */ /* First using MPI Type vector to build derived data type for this span only */ /* Need to calculate the disp in byte for this dimension. */ - disp[outercount] = (MPI_Aint)span->low * stride; - blocklen[outercount] = 1; + disp[outercount] = (MPI_Aint)span->low * stride; + blocklen[outercount] = 1; /* Generate MPI datatype for next dimension down */ - if(H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, op_info_i, op_gen) < 0) + if (H5S__obtain_datatype(span->down, down + 1, elmt_size, elmt_type, &down_type, type_list, + op_info_i, op_gen) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") /* Compute the number of elements to attempt in this span */ @@ -1274,27 +1285,29 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, /* Build the MPI datatype for this node */ H5_CHECK_OVERFLOW(nelmts, hsize_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, &inner_type[outercount]))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, + &inner_type[outercount]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) span = span->next; outercount++; - } /* end while */ + } /* end while */ /* Building the whole vector datatype */ H5_CHECK_OVERFLOW(outercount, size_t, int) - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, &spans->op_info[op_info_i].u.down_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, + &spans->op_info[op_info_i].u.down_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) /* Release inner node types */ - for(u = 0; u < outercount; u++) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) + for (u = 0; u < outercount; u++) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) inner_types_freed = TRUE; } /* end else */ /* Allocate space for the MPI data type list node */ - if(NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t))) + if (NULL == (type_node = H5FL_MALLOC(H5S_mpio_mpitype_node_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate MPI data type list node") /* Set up MPI type node */ @@ -1302,11 +1315,11 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, type_node->next = NULL; /* Add MPI type node to list */ - if(type_list->head == NULL) + if (type_list->head == NULL) type_list->head = type_list->tail = type_node; else { type_list->tail->next = type_node; - type_list->tail = type_node; + type_list->tail = type_node; } /* end else */ /* Remember that we've visited this span tree */ @@ -1318,22 +1331,21 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, done: /* General cleanup */ - if(inner_type != NULL) { - if(!inner_types_freed) - for(u = 0; u < outercount; u++) - if(MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) + if (inner_type != NULL) { + if (!inner_types_freed) + for (u = 0; u < outercount; u++) + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&inner_type[u]))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) H5MM_free(inner_type); } /* end if */ - if(blocklen != NULL) + if (blocklen != NULL) H5MM_free(blocklen); - if(disp != NULL) + if (disp != NULL) H5MM_free(disp); - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__obtain_datatype() */ - /*------------------------------------------------------------------------- * Function: H5S_mpio_space_type * @@ -1352,11 +1364,10 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, *------------------------------------------------------------------------- */ herr_t -H5S_mpio_space_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) +H5S_mpio_space_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) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1365,7 +1376,7 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert(elmt_size); /* Create MPI type based on the kind of selection */ - switch(H5S_GET_EXTENT_TYPE(space)) { + switch (H5S_GET_EXTENT_TYPE(space)) { case H5S_NULL: case H5S_SCALAR: case H5S_SIMPLE: @@ -1373,11 +1384,12 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type * out-of-order point selection, then permute this selection which * should be a memory selection to match the file space permutation. */ - if(TRUE == *is_permuted) { - switch(H5S_GET_SELECT_TYPE(space)) { + if (TRUE == *is_permuted) { + switch (H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: - if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'none' selection to MPI type") + if (H5S__mpio_none_type(new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'none' selection to MPI type") break; case H5S_SEL_ALL: @@ -1386,8 +1398,10 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type /* Sanity check */ HDassert(!do_permute); - if(H5S__mpio_permute_type(space, elmt_size, permute_map, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'all' selection to MPI type") + if (H5S__mpio_permute_type(space, elmt_size, permute_map, new_type, count, + is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'all' selection to MPI type") break; case H5S_SEL_ERROR: @@ -1396,33 +1410,40 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert("unknown selection type" && 0); break; } /* end switch */ - } /* end if */ + } /* end if */ /* the file space is not permuted, so do a regular selection */ else { - switch(H5S_GET_SELECT_TYPE(space)) { + switch (H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: - if(H5S__mpio_none_type(new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'none' selection to MPI type") + if (H5S__mpio_none_type(new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'none' selection to MPI type") break; case H5S_SEL_ALL: - if(H5S__mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert 'all' selection to MPI type") + if (H5S__mpio_all_type(space, elmt_size, new_type, count, is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'all' selection to MPI type") break; case H5S_SEL_POINTS: - if(H5S__mpio_point_type(space, elmt_size, new_type, count, is_derived_type, do_permute, permute_map, is_permuted) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't convert 'point' selection to MPI type") + if (H5S__mpio_point_type(space, elmt_size, new_type, count, is_derived_type, + do_permute, permute_map, is_permuted) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert 'point' selection to MPI type") break; case H5S_SEL_HYPERSLABS: - if((H5S_SELECT_IS_REGULAR(space) == TRUE)) { - if(H5S__mpio_reg_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert regular 'hyperslab' selection to MPI type") + if ((H5S_SELECT_IS_REGULAR(space) == TRUE)) { + if (H5S__mpio_reg_hyper_type(space, elmt_size, new_type, count, is_derived_type) < + 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert regular 'hyperslab' selection to MPI type") } /* end if */ - else - if(H5S__mpio_span_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert irregular 'hyperslab' selection to MPI type") + else if (H5S__mpio_span_hyper_type(space, elmt_size, new_type, count, + is_derived_type) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't convert irregular 'hyperslab' selection to MPI type") break; case H5S_SEL_ERROR: @@ -1431,7 +1452,7 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDassert("unknown selection type" && 0); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case H5S_NO_CLASS: @@ -1444,5 +1465,4 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_mpio_space_type() */ -#endif /* H5_HAVE_PARALLEL */ - +#endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 67c07d0c684..82e513e14eb 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,72 +22,65 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ /* Selection callbacks */ -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 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 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 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_serialize(const H5S_t *space, uint8_t **p); +static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); +static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); +static int H5S__none_unlim_dim(const H5S_t *space); +static htri_t H5S__none_is_contiguous(const H5S_t *space); +static htri_t H5S__none_is_single(const H5S_t *space); +static htri_t H5S__none_is_regular(const H5S_t *space); +static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); +static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static 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); /* Selection iteration callbacks */ -static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__none_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__none_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); -static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); - +static htri_t H5S__none_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__none_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__none_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__none_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +static herr_t H5S__none_iter_release(H5S_sel_iter_t *sel_iter); /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -119,7 +112,6 @@ const H5S_select_class_t H5S_sel_none[1] = {{ H5S__none_iter_init, }}; - /*******************/ /* Local Variables */ /*******************/ @@ -139,8 +131,6 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ H5S__none_iter_release, }}; - - /*------------------------------------------------------------------------- * Function: H5S__none_iter_init * @@ -168,7 +158,6 @@ H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_coords * @@ -194,7 +183,6 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_coords() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_block * @@ -209,7 +197,8 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -221,7 +210,6 @@ H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_ FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__none_iter_nelmts * @@ -245,7 +233,6 @@ H5S__none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(0) } /* end H5S__none_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_has_next_block @@ -274,7 +261,6 @@ H5S__none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next @@ -305,7 +291,6 @@ H5S__none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED n FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_next_block @@ -334,7 +319,6 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_get_seq_list @@ -365,9 +349,9 @@ H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, - size_t H5_ATTR_UNUSED maxseq, size_t H5_ATTR_UNUSED maxelem, size_t *nseq, - size_t *nelem, hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) +H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED maxseq, + size_t H5_ATTR_UNUSED maxelem, size_t *nseq, size_t *nelem, + hsize_t H5_ATTR_UNUSED *off, size_t H5_ATTR_UNUSED *len) { FUNC_ENTER_STATIC_NOERR @@ -389,7 +373,6 @@ H5S__none_iter_get_seq_list(H5S_sel_iter_t H5_ATTR_UNUSED *iter, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__none_iter_release @@ -418,7 +401,6 @@ H5S__none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_release @@ -447,7 +429,6 @@ H5S__none_release(H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_release() */ - /*-------------------------------------------------------------------------- NAME H5S__none_copy @@ -482,7 +463,6 @@ H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_valid @@ -513,7 +493,6 @@ H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serial_size @@ -547,7 +526,6 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(16) } /* end H5S__none_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__none_serialize @@ -572,7 +550,7 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p) { - uint8_t *pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -584,8 +562,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ /* Update encoding pointer */ *p = pp; @@ -593,7 +571,6 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_deserialize @@ -619,10 +596,10 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p) { - 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 */ FUNC_ENTER_STATIC @@ -634,8 +611,8 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -644,30 +621,29 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); - if(version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) + 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 */ *p += 8; /* Change to "none" selection */ - if(H5S_select_none(tmp_space) < 0) + if (H5S_select_none(tmp_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__none_bounds @@ -694,7 +670,8 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, + hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -705,7 +682,6 @@ H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *star FUNC_LEAVE_NOAPI(FAIL) } /* end H5S_none_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__none_offset @@ -737,7 +713,6 @@ H5S__none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offs FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__none_unlim_dim @@ -765,7 +740,6 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__none_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_contiguous @@ -794,7 +768,6 @@ H5S__none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_single @@ -823,7 +796,6 @@ H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__none_is_regular @@ -854,7 +826,6 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__none_shape_same @@ -875,8 +846,7 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, - const H5S_t H5_ATTR_UNUSED *space2) +H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNUSED *space2) { FUNC_ENTER_STATIC_NOERR @@ -887,7 +857,6 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, FUNC_LEAVE_NOAPI(TRUE) } /* end H5S__none_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__none_intersect_block @@ -908,8 +877,8 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, - const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) +H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, + const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -922,7 +891,6 @@ H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, FUNC_LEAVE_NOAPI(FALSE) } /* end H5S__none_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_u @@ -953,7 +921,6 @@ H5S__none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *of FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__none_adjust_s @@ -984,7 +951,6 @@ H5S__none_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *o FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__none_adjust_s() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_scalar * @@ -1009,7 +975,6 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(FAIL) } /* end H5S__none_project_scalar() */ - /*------------------------------------------------------------------------- * Function: H5S__none_project_simple * @@ -1024,10 +989,10 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS *------------------------------------------------------------------------- */ static herr_t -H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, - H5S_t *new_space, hsize_t H5_ATTR_UNUSED *offset) +H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, H5S_t *new_space, + hsize_t H5_ATTR_UNUSED *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1037,14 +1002,13 @@ H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, HDassert(offset); /* Select the entire new space */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to set none selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_none @@ -1065,7 +1029,7 @@ H5S__none_project_simple(const H5S_t H5_ATTR_UNUSED *base_space, herr_t H5S_select_none(H5S_t *space) { - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1073,7 +1037,7 @@ H5S_select_none(H5S_t *space) HDassert(space); /* Remove current selection first */ - if(H5S_SELECT_RELEASE(space) < 0) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab") /* Set number of elements in selection */ @@ -1086,7 +1050,6 @@ H5S_select_none(H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_none() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_none @@ -1107,21 +1070,20 @@ H5S_select_none(H5S_t *space) herr_t H5Sselect_none(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_none() */ - diff --git a/src/H5Spkg.h b/src/H5Spkg.h index aa4b9a25bd8..496cab65777 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -6,81 +6,84 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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 - * Thursday, September 28, 2000 + * Programmer: Quincey Koziol + * Thursday, September 28, 2000 * - * Purpose: This file contains declarations which are visible only within - * the H5S package. Source files outside the H5S package should - * include H5Sprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5S package. Source files outside the H5S package should + * include H5Sprivate.h instead. */ #if !(defined H5S_FRIEND || defined H5S_MODULE) #error "Do not include this file outside the H5S package!" #endif -#ifndef _H5Spkg_H -#define _H5Spkg_H +#ifndef H5Spkg_H +#define H5Spkg_H /* Get package's private header */ #include "H5Sprivate.h" /* Other private headers needed by this file */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Oprivate.h" /* Object headers */ /* Flags to indicate special dataspace features are active */ -#define H5S_VALID_MAX 0x01 -#define H5S_VALID_PERM 0x02 +#define H5S_VALID_MAX 0x01 +#define H5S_VALID_PERM 0x02 /* Flags for serialization of selections */ -#define H5S_HYPER_REGULAR 0x01 -#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) +#define H5S_HYPER_REGULAR 0x01 +#define H5S_SELECT_FLAG_BITS (H5S_HYPER_REGULAR) /* Versions for H5S_SEL_HYPER selection info */ -#define H5S_HYPER_VERSION_1 1 -#define H5S_HYPER_VERSION_2 2 -#define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_2 +#define H5S_HYPER_VERSION_1 1 +#define H5S_HYPER_VERSION_2 2 +#define H5S_HYPER_VERSION_3 3 +#define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_3 /* Versions for H5S_SEL_POINTS selection info */ -#define H5S_POINT_VERSION_1 1 -#define H5S_POINT_VERSION_LATEST H5S_POINT_VERSION_1 +#define H5S_POINT_VERSION_1 1 +#define H5S_POINT_VERSION_2 2 +#define H5S_POINT_VERSION_LATEST H5S_POINT_VERSION_2 /* Versions for H5S_SEL_NONE selection info */ -#define H5S_NONE_VERSION_1 1 -#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 +#define H5S_NONE_VERSION_1 1 +#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 /* Versions for H5S_SEL_ALL selection info */ -#define H5S_ALL_VERSION_1 1 -#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 +#define H5S_ALL_VERSION_1 1 +#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 /* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */ -#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */ -#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */ -#define H5S_SELECT_INFO_ENC_SIZE_BITS ( H5S_SELECT_INFO_ENC_SIZE_4 | \ - H5S_SELECT_INFO_ENC_SIZE_8 ) +#define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_4 0x04 /* 4 bytes: 32 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_8 0x08 /* 8 bytes: 64 bits */ +#define H5S_SELECT_INFO_ENC_SIZE_BITS \ + (H5S_SELECT_INFO_ENC_SIZE_2 | H5S_SELECT_INFO_ENC_SIZE_4 | H5S_SELECT_INFO_ENC_SIZE_8) -#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */ -#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */ +#define H5S_UINT16_MAX 0x0000FFFF /* 2^16 - 1 = 65,535 */ +#define H5S_UINT32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4,294,967,295 */ +#define H5S_UINT64_MAX ((hsize_t)(-1L)) /* 2^64 - 1 = 18,446,744,073,709,551,615 */ /* Length of stack-allocated sequences for "project intersect" routines */ #define H5S_PROJECT_INTERSECT_NSEQS 256 /* Internal flags for initializing selection iterators */ -#define H5S_SEL_ITER_API_CALL 0x1000 /* Selection iterator created from API call */ - +#define H5S_SEL_ITER_API_CALL 0x1000 /* Selection iterator created from API call */ /* Initial version of the dataspace information */ -#define H5O_SDSPACE_VERSION_1 1 +#define H5O_SDSPACE_VERSION_1 1 /* This version adds support for "null" dataspaces, encodes the type of the * dataspace in the message and eliminated the rest of the "reserved" * bytes. */ -#define H5O_SDSPACE_VERSION_2 2 +#define H5O_SDSPACE_VERSION_2 2 /* The latest version of the format. Look through the 'encode' * and 'size' callbacks for places to change when updating this. */ @@ -88,7 +91,7 @@ /* Maximum dimension size (highest value that is not a special value e.g. * H5S_UNLIMITED) */ -#define H5S_MAX_SIZE ((hsize_t)(hssize_t)(-2)) +#define H5S_MAX_SIZE ((hsize_t)(hssize_t)(-2)) /* Macro for checking if two ranges overlap one another */ /* @@ -97,23 +100,22 @@ * high bound of the other. */ /* (Assumes that low & high bounds are _inclusive_) */ -#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) (!((L1) > (H2) || (L2) > (H1))) - +#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) (!((L1) > (H2) || (L2) > (H1))) /* * Dataspace extent information */ /* Extent container */ struct H5S_extent_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5S_class_t type; /* Type of extent */ - unsigned version; /* Version of object header message to encode this object with */ - hsize_t nelem; /* Number of elements in extent */ + H5S_class_t type; /* Type of extent */ + unsigned version; /* Version of object header message to encode this object with */ + hsize_t nelem; /* Number of elements in extent */ - unsigned rank; /* Number of dimensions */ - hsize_t *size; /* Current size of the dimensions */ - hsize_t *max; /* Maximum size of the dimensions */ + unsigned rank; /* Number of dimensions */ + hsize_t *size; /* Current size of the dimensions */ + hsize_t *max; /* Maximum size of the dimensions */ }; /* @@ -122,48 +124,53 @@ struct H5S_extent_t { /* Node in point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_node_t { - struct H5S_pnt_node_t *next; /* Pointer to next point in list */ - hsize_t pnt[]; /* Selected point */ - /* (NOTE: This uses the C99 "flexible array member" feature) */ + struct H5S_pnt_node_t *next; /* Pointer to next point in list */ + hsize_t pnt[]; /* Selected point */ + /* (NOTE: This uses the C99 "flexible array member" feature) */ }; /* Information about point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_list_t { /* The following two fields defines the bounding box of the whole set of points, relative to the offset */ - hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ - hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ + hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ + hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ - H5S_pnt_node_t *head; /* Pointer to head of point list */ - H5S_pnt_node_t *tail; /* Pointer to tail of point list */ + H5S_pnt_node_t *head; /* Pointer to head of point list */ + H5S_pnt_node_t *tail; /* Pointer to tail of point list */ + + hsize_t last_idx; /* Index of the point after the last returned from H5S__get_select_elem_pointlist() */ + H5S_pnt_node_t *last_idx_pnt; /* Point after the last returned from H5S__get_select_elem_pointlist(). + * If we ever add a way to remove points or add points in the middle of + * the pointlist we will need to invalidate these fields. */ }; /* Information about hyperslab spans */ /* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */ 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 */ + 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 */ }; /* "Operation info" struct. Used to hold temporary information during copies, * 'adjust', 'nelem', and 'rebuild' operations, and higher level algorithms that * generate this information. */ typedef struct H5S_hyper_op_info_t { - uint64_t op_gen; /* Generation of the scratch info */ + uint64_t op_gen; /* Generation of the scratch info */ union { struct H5S_hyper_span_info_t *copied; /* Pointer to already copied span tree */ - hsize_t nelmts; /* # of elements */ - hsize_t nblocks; /* # of blocks */ + hsize_t nelmts; /* # of elements */ + hsize_t nblocks; /* # of blocks */ #ifdef H5_HAVE_PARALLEL MPI_Datatype down_type; /* MPI datatype for span tree */ -#endif /* H5_HAVE_PARALLEL */ - }u; +#endif /* H5_HAVE_PARALLEL */ + } u; } H5S_hyper_op_info_t; /* Information about a list of hyperslab spans in one dimension (typedef'd in H5Sprivate.h) */ struct H5S_hyper_span_info_t { - unsigned count; /* Ref. count of number of spans which share this span */ + unsigned count; /* Ref. count of number of spans which share this span */ /* The following two fields define the bounding box of this set of spans * and all lower dimensions, relative to the offset. @@ -176,25 +183,26 @@ struct H5S_hyper_span_info_t { * arrays correspond to the bounds in "this" dimension, even if * it's not the highest level in the span tree. */ - hsize_t *low_bounds; /* The smallest element selected in each dimension */ - hsize_t *high_bounds; /* The largest element selected in each dimension */ + hsize_t *low_bounds; /* The smallest element selected in each dimension */ + hsize_t *high_bounds; /* The largest element selected in each dimension */ /* "Operation info" fields */ /* (Used during copies, 'adjust', 'nelem', and 'rebuild' operations) */ /* Currently the maximum number of simultaneous operations is 2 */ H5S_hyper_op_info_t op_info[2]; - struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */ - struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */ - hsize_t bounds[]; /* Array for storing low & high bounds */ - /* (NOTE: This uses the C99 "flexible array member" feature) */ + struct H5S_hyper_span_t *head; /* Pointer to the first span of list of spans in the current dimension */ + struct H5S_hyper_span_t *tail; /* Pointer to the last span of list of spans in the current dimension */ + hsize_t bounds[]; /* Array for storing low & high bounds */ + /* (NOTE: This uses the C99 "flexible array member" feature) */ }; /* Enum for diminfo_valid field in H5S_hyper_sel_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_YES /* 2: diminfo is valid */ + 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_YES /* 2: diminfo is valid */ } H5S_diminfo_valid_t; /* Information about 'diminfo' form of hyperslab selection */ @@ -207,23 +215,23 @@ typedef struct { * used to set the hyperslab to the application when it queries the * hyperslab selection information. */ - H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */ - H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */ + H5S_hyper_dim_t app[H5S_MAX_RANK]; /* Application-set per-dim selection info */ + H5S_hyper_dim_t opt[H5S_MAX_RANK]; /* Optimized per-dim selection info */ /* The following two fields defines the bounding box of the diminfo selection */ /* (relative to the offset) */ - hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ - hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ + hsize_t low_bounds[H5S_MAX_RANK]; /* The smallest element selected in each dimension */ + hsize_t high_bounds[H5S_MAX_RANK]; /* The largest element selected in each dimension */ } H5S_hyper_diminfo_t; /* Information about hyperslab selection */ typedef struct { - H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */ + H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */ - H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */ - int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */ - hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */ - H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */ + H5S_hyper_diminfo_t diminfo; /* Dimension info form of hyperslab selection */ + int unlim_dim; /* Dimension where selection is unlimited, or -1 if none */ + hsize_t num_elem_non_unlim; /* # of elements in a "slice" excluding the unlimited dimension */ + H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information of all dimensions */ } H5S_hyper_sel_t; /* Selection information methods */ @@ -246,8 +254,7 @@ typedef herr_t (*H5S_sel_offset_func_t)(const H5S_t *space, hsize_t *offset); /* Method to get unlimited dimension of selection (or -1 for none) */ typedef int (*H5S_sel_unlim_dim_func_t)(const H5S_t *space); /* Method to get the number of elements in a slice through the unlimited dimension */ -typedef herr_t (*H5S_sel_num_elem_non_unlim_func_t)(const H5S_t *space, - hsize_t *num_elem_non_unlim); +typedef herr_t (*H5S_sel_num_elem_non_unlim_func_t)(const H5S_t *space, hsize_t *num_elem_non_unlim); /* Method to determine if current selection is contiguous */ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space); /* Method to determine if current selection is a single block */ @@ -257,7 +264,8 @@ typedef htri_t (*H5S_sel_is_regular_func_t)(const 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); /* 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)(const 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) */ @@ -271,50 +279,58 @@ typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *s /* Selection class information */ typedef struct { - H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods */ - H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ - 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 */ - 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 sequence suitable for storing on disk) */ - 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 */ - 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 */ + H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ + 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 */ + 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 + sequence suitable for storing on disk) */ + 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 */ + 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 */ H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ - H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ - H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ - 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) */ - 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 */ + H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ + H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ + 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) */ + 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 */ } H5S_select_class_t; /* Selection information object */ typedef struct { - const H5S_select_class_t *type; /* Pointer to selection's class info */ + const H5S_select_class_t *type; /* Pointer to selection's class info */ - hbool_t offset_changed; /* Indicate that the offset for the selection has been changed */ - hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ + hbool_t offset_changed; /* Indicate that the offset for the selection has been changed */ + hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ - hsize_t num_elem; /* Number of elements in selection */ + 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_hyper_sel_t *hslab; /* Info about hyperslab selection */ + 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; /* Main dataspace structure (typedef'd in H5Sprivate.h) */ struct H5S_t { - H5S_extent_t extent; /* Dataspace extent (must stay first) */ - H5S_select_t select; /* Dataspace selection */ + H5S_extent_t extent; /* Dataspace extent (must stay first) */ + H5S_select_t select; /* Dataspace selection */ }; /* Selection iteration methods */ @@ -331,25 +347,31 @@ typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); /* Method to move selection iterator to the next block in the selection */ typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); /* Method to retrieve a list of offset/length sequences for selection iterator */ -typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter, - size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, - size_t *len); +typedef herr_t (*H5S_sel_iter_get_seq_list_func_t)(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, + size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); /* Method to release iterator for current selection */ typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); /* Selection iteration class */ typedef struct H5S_sel_iter_class_t { - H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ + H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ /* Methods on selections */ - H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ - H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ - H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ - H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ - H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ - 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 */ - H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ + H5S_sel_iter_coords_func_t + iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ + H5S_sel_iter_block_func_t + iter_block; /* Method to retrieve the current block of iterator for current selection */ + H5S_sel_iter_nelmts_func_t + iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ + H5S_sel_iter_has_next_block_func_t + iter_has_next_block; /* Method to query if there is another block left in the selection */ + H5S_sel_iter_next_func_t + iter_next; /* Method to move selection iterator to the next element in the selection */ + 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 */ + H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ } H5S_sel_iter_class_t; /* @@ -377,25 +399,22 @@ H5_DLLVAR const unsigned H5O_sdspace_ver_bounds[H5F_LIBVER_NBOUNDS]; /* Extent functions */ H5_DLL herr_t H5S__extent_release(H5S_extent_t *extent); -H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, - hbool_t copy_max); +H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max); /* Operations on hyperslab selections */ 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 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); /* Testing functions */ #ifdef H5S_TESTING -H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id, - H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2); -H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id, - H5S_diminfo_valid_t *status); +H5_DLL herr_t H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, + H5S_diminfo_valid_t *status2); +H5_DLL herr_t H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status); H5_DLL htri_t H5S__internal_consistency_test(hid_t space_id); #endif /* H5S_TESTING */ -#endif /*_H5Spkg_H*/ - +#endif /*H5Spkg_H*/ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index ea5e1346003..929499f0a78 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,26 +22,24 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspace functions */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ @@ -50,55 +48,50 @@ /* (Makes it easier to understand the alloc / free calls) */ typedef hsize_t hcoords_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord); -static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src, - unsigned rank); -static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst); +static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); +static H5S_pnt_list_t *H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank); +static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst); /* Selection callbacks */ -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 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 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 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_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); +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 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 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_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); /* Selection iteration callbacks */ -static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); +static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__point_iter_nelmts(const H5S_sel_iter_t *iter); -static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); -static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter); -static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +static herr_t H5S__point_iter_next_block(H5S_sel_iter_t *sel_iter); +static herr_t H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); static herr_t H5S__point_iter_release(H5S_sel_iter_t *sel_iter); - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -130,6 +123,14 @@ const H5S_select_class_t H5S_sel_point[1] = {{ H5S__point_iter_init, }}; +/* Format version bounds for dataspace hyperslab selection */ +const unsigned H5O_sds_point_ver_bounds[] = { + H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */ + H5S_POINT_VERSION_1, /* H5F_LIBVER_V110 */ + H5S_POINT_VERSION_2 /* H5F_LIBVER_LATEST */ +}; + /*******************/ /* Local Variables */ /*******************/ @@ -155,7 +156,6 @@ H5FL_BARR_DEFINE_STATIC(H5S_pnt_node_t, hcoords_t, H5S_MAX_RANK); /* Declare a free list to manage the H5S_pnt_list_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_list_t); - /*------------------------------------------------------------------------- * Function: H5S__point_iter_init * @@ -171,7 +171,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -188,10 +188,10 @@ H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) * close the dataspace that the iterator is operating on, or undefined * behavior will occur. */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) { /* Copy the point list */ - if(NULL == (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank))) + if (NULL == + (iter->u.pnt.pnt_lst = H5S__copy_pnt_list(space->select.sel_info.pnt_lst, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list") } /* end if */ else @@ -208,7 +208,6 @@ H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_init() */ - /*------------------------------------------------------------------------- * Function: H5S__point_iter_coords * @@ -237,9 +236,8 @@ H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_coords() */ - /*------------------------------------------------------------------------- - * Function: H5S_point_iter_block + * Function: H5S__point_iter_block * * Purpose: Retrieve the current block of iterator for current * selection @@ -268,7 +266,6 @@ H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_block() */ - /*------------------------------------------------------------------------- * Function: H5S__point_iter_nelmts * @@ -292,7 +289,6 @@ H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__point_iter_nelmts() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_has_next_block @@ -313,7 +309,7 @@ H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -321,14 +317,13 @@ H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter) HDassert(iter); /* Check if there is another point in the list */ - if(iter->u.pnt.curr->next == NULL) + if (iter->u.pnt.curr->next == NULL) HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_has_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_next @@ -357,7 +352,7 @@ H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) HDassert(nelem > 0); /* Increment the iterator */ - while(nelem > 0) { + while (nelem > 0) { iter->u.pnt.curr = iter->u.pnt.curr->next; nelem--; } /* end while */ @@ -365,7 +360,6 @@ H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_next_block @@ -397,7 +391,6 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_get_seq_list @@ -428,18 +421,18 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, - size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) +H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, + hsize_t *off, size_t *len) { - size_t io_left; /* The number of bytes left in the selection */ - size_t start_io_left; /* The initial number of bytes left in the selection */ - H5S_pnt_node_t *node; /* Point node */ - unsigned ndims; /* Dimensionality of dataspace*/ - hsize_t acc; /* Coordinate accumulator */ - hsize_t loc; /* Coordinate offset */ - size_t curr_seq; /* Current sequence being operated on */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* return value */ + size_t io_left; /* The number of bytes left in the selection */ + size_t start_io_left; /* The initial number of bytes left in the selection */ + H5S_pnt_node_t *node; /* Point node */ + unsigned ndims; /* Dimensionality of dataspace*/ + hsize_t acc; /* Coordinate accumulator */ + hsize_t loc; /* Coordinate offset */ + size_t curr_seq; /* Current sequence being operated on */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC_NOERR @@ -461,24 +454,24 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem /* Walk through the points in the selection, starting at the current */ /* location in the iterator */ - node = iter->u.pnt.curr; + node = iter->u.pnt.curr; curr_seq = 0; - while(NULL != node) { + while (NULL != node) { /* Compute the offset of each selected point in the buffer */ - for(i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) { + for (i = (int)(ndims - 1), acc = iter->elmt_size, loc = 0; i >= 0; i--) { loc += (hsize_t)((hssize_t)node->pnt[i] + iter->sel_off[i]) * acc; acc *= iter->dims[i]; } /* end for */ /* Check if this is a later point in the selection */ - if(curr_seq > 0) { + if (curr_seq > 0) { /* If a sorted sequence is requested, make certain we don't go backwards in the offset */ - if((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1]) + if ((iter->flags & H5S_SEL_ITER_GET_SEQ_LIST_SORTED) && loc < off[curr_seq - 1]) break; /* Check if this point extends the previous sequence */ /* (Unlikely, but possible) */ - if(loc == (off[curr_seq - 1] + len[curr_seq - 1])) { + if (loc == (off[curr_seq - 1] + len[curr_seq - 1])) { /* Extend the previous sequence */ len[curr_seq - 1] += iter->elmt_size; } /* end if */ @@ -490,7 +483,7 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem /* Increment sequence count */ curr_seq++; } /* end else */ - } /* end if */ + } /* end if */ else { /* Add a new sequence */ off[curr_seq] = loc; @@ -508,16 +501,16 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem iter->elmt_left--; /* Check if we're finished with all sequences */ - if(curr_seq == maxseq) + if (curr_seq == maxseq) break; /* Check if we're finished with all the elements available */ - if(io_left == 0) + if (io_left == 0) break; /* Advance to the next point */ node = node->next; - } /* end while */ + } /* end while */ /* Set the number of sequences generated */ *nseq = curr_seq; @@ -528,7 +521,6 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S__point_iter_release @@ -547,7 +539,7 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_iter_release(H5S_sel_iter_t * iter) +H5S__point_iter_release(H5S_sel_iter_t *iter) { FUNC_ENTER_STATIC_NOERR @@ -555,14 +547,12 @@ H5S__point_iter_release(H5S_sel_iter_t * iter) HDassert(iter); /* If this iterator copied the point list, we must free it */ - if((iter->flags & H5S_SEL_ITER_API_CALL) && - !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) + if ((iter->flags & H5S_SEL_ITER_API_CALL) && !(iter->flags & H5S_SEL_ITER_SHARE_WITH_DATASPACE)) H5S__free_pnt_list(iter->u.pnt.pnt_lst); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S__point_add @@ -586,8 +576,8 @@ static herr_t H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { H5S_pnt_node_t *top = NULL, *curr = NULL, *new_node = NULL; /* Point selection nodes */ - unsigned u; /* Counter */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Counter */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -597,11 +587,11 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c HDassert(coord); HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND); - for(u = 0; u < num_elem; u++) { - unsigned dim; /* Counter for dimensions */ + for (u = 0; u < num_elem; u++) { + unsigned dim; /* Counter for dimensions */ /* Allocate space for the new node */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") /* Initialize fields in node */ @@ -611,7 +601,7 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c H5MM_memcpy(new_node->pnt, coord + (u * space->extent.rank), (space->extent.rank * sizeof(hsize_t))); /* Link into list */ - if(top == NULL) + if (top == NULL) top = new_node; else curr->next = new_node; @@ -623,31 +613,33 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c * So the following bound box update procedure works correctly * for the SET operation) */ - for(dim = 0; dim < space->extent.rank; dim++) { - space->select.sel_info.pnt_lst->low_bounds[dim] = MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]); - space->select.sel_info.pnt_lst->high_bounds[dim] = MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]); + for (dim = 0; dim < space->extent.rank; dim++) { + space->select.sel_info.pnt_lst->low_bounds[dim] = + MIN(space->select.sel_info.pnt_lst->low_bounds[dim], curr->pnt[dim]); + space->select.sel_info.pnt_lst->high_bounds[dim] = + MAX(space->select.sel_info.pnt_lst->high_bounds[dim], curr->pnt[dim]); } /* end for */ - } /* end for */ + } /* end for */ new_node = NULL; /* Insert the list of points selected in the proper place */ - if(op == H5S_SELECT_SET || op == H5S_SELECT_PREPEND) { + if (op == H5S_SELECT_SET || op == H5S_SELECT_PREPEND) { /* Append current list, if there is one */ - if(NULL != space->select.sel_info.pnt_lst->head) + if (NULL != space->select.sel_info.pnt_lst->head) curr->next = space->select.sel_info.pnt_lst->head; /* Put new list in point selection */ space->select.sel_info.pnt_lst->head = top; /* Change the tail pointer if tail has not been set */ - if(NULL == space->select.sel_info.pnt_lst->tail) + if (NULL == space->select.sel_info.pnt_lst->tail) space->select.sel_info.pnt_lst->tail = curr; - } /* end if */ - else { /* op==H5S_SELECT_APPEND */ - H5S_pnt_node_t *tmp_node; /* Temporary point selection node */ + } /* end if */ + else { /* op==H5S_SELECT_APPEND */ + H5S_pnt_node_t *tmp_node; /* Temporary point selection node */ tmp_node = space->select.sel_info.pnt_lst->head; - if(tmp_node != NULL) { + if (tmp_node != NULL) { HDassert(space->select.sel_info.pnt_lst->tail); space->select.sel_info.pnt_lst->tail->next = top; } /* end if */ @@ -657,29 +649,28 @@ H5S__point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *c } /* end else */ /* Set the number of elements in the new selection */ - if(op == H5S_SELECT_SET) + if (op == H5S_SELECT_SET) space->select.num_elem = num_elem; else space->select.num_elem += num_elem; done: - if(ret_value < 0) { + if (ret_value < 0) { /* Release possibly partially initialized new node */ - if(new_node) + if (new_node) new_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, new_node); /* Release possible linked list of nodes */ - while(top) { + while (top) { curr = top->next; - top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top); - top = curr; + top = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, top); + top = curr; } /* end while */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_add() */ - /*-------------------------------------------------------------------------- NAME H5S__point_release @@ -717,7 +708,6 @@ H5S__point_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_release() */ - /*-------------------------------------------------------------------------- NAME H5S_select_elements @@ -746,10 +736,9 @@ H5S__point_release(H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord) +H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -760,24 +749,25 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, HDassert(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND); /* If we are setting a new selection, remove current selection first */ - if(op == H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) - if(H5S_SELECT_RELEASE(space) < 0) + if (op == H5S_SELECT_SET || H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_SELECT_RELEASE(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release point selection") /* Allocate space for the point selection information if necessary */ - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) { + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS || space->select.sel_info.pnt_lst == NULL) { hsize_t tmp = HSIZET_MAX; - if(NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))) + if (NULL == (space->select.sel_info.pnt_lst = H5FL_CALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information") /* Set the bound box to the default value */ - H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), space->extent.rank); + H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), + space->extent.rank); HDmemset(space->select.sel_info.pnt_lst->high_bounds, 0, sizeof(hsize_t) * space->extent.rank); } /* Add points to selection */ - if(H5S__point_add(space, op, num_elem, coord) < 0) + if (H5S__point_add(space, op, num_elem, coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert elements") /* Set selection type */ @@ -787,7 +777,6 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_elements() */ - /*-------------------------------------------------------------------------- NAME H5S__copy_pnt_list @@ -810,9 +799,9 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, static H5S_pnt_list_t * H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) { - H5S_pnt_list_t *dst = NULL; /* New point list */ - H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */ - H5S_pnt_list_t *ret_value = NULL; /* Return value */ + H5S_pnt_list_t *dst = NULL; /* New point list */ + H5S_pnt_node_t *curr, *new_tail; /* Point information nodes */ + H5S_pnt_list_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -821,16 +810,16 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) HDassert(rank > 0); /* Allocate room for the head of the point list */ - if(NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t))) + if (NULL == (dst = H5FL_MALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point list node") - curr = src->head; + curr = src->head; new_tail = NULL; - while(curr) { - H5S_pnt_node_t *new_node; /* New point information node */ + while (curr) { + H5S_pnt_node_t *new_node; /* New point information node */ /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate point node") new_node->next = NULL; @@ -838,11 +827,11 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) H5MM_memcpy(new_node->pnt, curr->pnt, (rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == new_tail) + if (NULL == new_tail) new_tail = dst->head = new_node; else { new_tail->next = new_node; - new_tail = new_node; + new_tail = new_node; } /* end else */ curr = curr->next; @@ -853,17 +842,20 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) H5MM_memcpy(dst->high_bounds, src->high_bounds, (rank * sizeof(hsize_t))); H5MM_memcpy(dst->low_bounds, src->low_bounds, (rank * sizeof(hsize_t))); + /* Clear cached iteration point */ + dst->last_idx = 0; + dst->last_idx_pnt = NULL; + /* Set return value */ ret_value = dst; done: - if(NULL == ret_value && dst) + if (NULL == ret_value && dst) H5S__free_pnt_list(dst); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__copy_pnt_list() */ - /*-------------------------------------------------------------------------- NAME H5S__free_pnt_list @@ -884,7 +876,7 @@ H5S__copy_pnt_list(const H5S_pnt_list_t *src, unsigned rank) static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) { - H5S_pnt_node_t *curr; /* Point information nodes */ + H5S_pnt_node_t *curr; /* Point information nodes */ FUNC_ENTER_STATIC_NOERR @@ -893,10 +885,10 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) /* Traverse the list, freeing all memory */ curr = pnt_lst->head; - while(curr) { + while (curr) { H5S_pnt_node_t *tmp_node = curr; - curr = curr->next; + curr = curr->next; tmp_node = (H5S_pnt_node_t *)H5FL_ARR_FREE(hcoords_t, tmp_node); } /* end while */ @@ -905,7 +897,6 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) FUNC_LEAVE_NOAPI_VOID } /* end H5S__free_pnt_list() */ - /*-------------------------------------------------------------------------- NAME H5S__point_copy @@ -929,7 +920,7 @@ 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 H5_ATTR_UNUSED share_selection) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -938,14 +929,14 @@ H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selec HDassert(dst); /* Allocate room for the head of the point list */ - if(NULL == (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank))) + if (NULL == + (dst->select.sel_info.pnt_lst = H5S__copy_pnt_list(src->select.sel_info.pnt_lst, src->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy point list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_copy() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_valid @@ -969,19 +960,20 @@ H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selec static htri_t H5S__point_is_valid(const H5S_t *space) { - unsigned u; /* Counter */ - htri_t ret_value = TRUE; /* Return value */ + unsigned u; /* Counter */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* Check each dimension */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Bounds check the selected point + offset against the extent */ - if((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u]) + if ((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > + space->extent.size[u]) HGOTO_DONE(FALSE) - if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) HGOTO_DONE(FALSE) } /* end for */ @@ -989,7 +981,6 @@ H5S__point_is_valid(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_valid() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_npoints @@ -1010,16 +1001,16 @@ 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 */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection") ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); @@ -1028,12 +1019,11 @@ H5Sget_select_elem_npoints(hid_t spaceid) FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_npoints() */ - /*-------------------------------------------------------------------------- NAME H5S__point_get_version_enc_size PURPOSE - Determine the version and the size (4 bytes) to encode point selection info + Determine the version and the size (2, 4 or 8 bytes) to encode point selection info USAGE hssize_t H5S__point_get_version_enc_size(space, version, enc_size) const H5S_t *space: IN: Dataspace ID of selection to query @@ -1042,8 +1032,16 @@ H5Sget_select_elem_npoints(hid_t spaceid) RETURNS The version and the size to encode point selection info DESCRIPTION - Determine the version and the encoded size to use for encoding points selection info. - Detect whether the number of points or the high bound exceeds 2^32 -1. + Determine the version to use for encoding points selection info based + on the following: + (1) the low/high bounds setting in fapl + (2) whether the number of points or selection high bounds exceeds H5S_UINT32_MAX or not + + Determine the encoded size based on version: + --For version 2, the encoded size of point selection info is determined + by the maximum size for: + (a) storing the number of points + (b) storing the selection high bounds GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS @@ -1053,39 +1051,93 @@ H5Sget_select_elem_npoints(hid_t spaceid) static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size) { - hbool_t exceed = FALSE; - hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ - hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ - unsigned u; /* Local index veriable */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t count_up_version = FALSE; /* Whether number of points exceed H5S_UINT32_MAX */ + hbool_t bound_up_version = FALSE; /* Whether high bounds exceed H5S_UINT32_MAX */ + H5F_libver_t low_bound; /* The 'low' bound of library format versions */ + H5F_libver_t high_bound; /* The 'high' bound of library format versions */ + uint32_t tmp_version; /* Local temporary version */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get bounding box for the selection */ HDmemset(bounds_end, 0, sizeof(bounds_end)); - if(H5S__point_bounds(space, bounds_start, bounds_end) < 0) + if (H5S__point_bounds(space, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Determine whether number of points or high bounds exceeds (2^32 - 1) */ - for(u = 0; u < space->extent.rank; u++) - if(bounds_end[u] > H5S_UINT32_MAX) { - exceed = TRUE; + if (space->select.num_elem > H5S_UINT32_MAX) + count_up_version = TRUE; + else + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > H5S_UINT32_MAX) { + bound_up_version = TRUE; + break; + } /* end if */ + + /* If exceed (2^32 -1) */ + if (count_up_version || bound_up_version) + tmp_version = H5S_POINT_VERSION_2; + else + tmp_version = H5S_POINT_VERSION_1; + + /* Get the file's low/high bounds */ + if (H5CX_get_libver_bounds(&low_bound, &high_bound) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get low/high bounds from API context") + + /* Upgrade to the version indicated by the file's low bound if higher */ + tmp_version = MAX(tmp_version, H5O_sds_point_ver_bounds[low_bound]); + + /* Version bounds check */ + if (tmp_version > H5O_sds_point_ver_bounds[high_bound]) { + if (count_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The number of points in point selection exceeds 2^32") + else if (bound_up_version) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "The end of bounding box in point selection exceeds 2^32") + else + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace point selection version out of bounds") + } /* end if */ + + /* Set the version to return */ + *version = tmp_version; + + /* Get the encoded size use based on version */ + switch (tmp_version) { + case H5S_POINT_VERSION_1: + *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; break; - } - if(space->select.num_elem > H5S_UINT32_MAX) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of points in point selection exceeds 2^32") - else if(exceed) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32") + case H5S_POINT_VERSION_2: + /* Find max for num_elem and bounds_end[] */ + max_size = space->select.num_elem; + for (u = 0; u < space->extent.rank; u++) + if (bounds_end[u] > max_size) + max_size = bounds_end[u]; + + /* Determine the encoding size */ + if (max_size > H5S_UINT32_MAX) + *enc_size = H5S_SELECT_INFO_ENC_SIZE_8; + else if (max_size > H5S_UINT16_MAX) + *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + else + *enc_size = H5S_SELECT_INFO_ENC_SIZE_2; + break; - *version = H5S_POINT_VERSION_1; - *enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__point_get_version_enc_size() */ - /*-------------------------------------------------------------------------- NAME H5S__point_serial_size @@ -1108,45 +1160,42 @@ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t * static hssize_t H5S__point_serial_size(const H5S_t *space) { - H5S_pnt_node_t *curr; /* Point information nodes */ - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of point selection info */ - hssize_t ret_value = -1; /* Return value */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC HDassert(space); /* Determine the version and encoded size for point selection */ - if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + if (H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") - HDassert(version == H5S_POINT_VERSION_1); - HDassert(enc_size == H5S_SELECT_INFO_ENC_SIZE_4); - /* Basic number of bytes required to serialize point selection: */ - /* - * + + + - * + - */ - ret_value = 20; + if (version >= H5S_POINT_VERSION_2) + /* + * + + + * + rank (4 bytes)> + */ + ret_value = 13; + else + /* + * + + + + * + + */ + ret_value = 20; /* */ ret_value += enc_size; /* Count points in selection */ - curr = space->select.sel_info.pnt_lst->head; - while(curr != NULL) { - /* Add bytes times the rank for each element selected */ - ret_value += enc_size * space->extent.rank; - curr = curr->next; - } /* end while */ + ret_value += (hssize_t)(enc_size * space->extent.rank * space->select.num_elem); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S__point_serialize @@ -1171,14 +1220,14 @@ H5S__point_serial_size(const H5S_t *space) static herr_t H5S__point_serialize(const 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 */ - uint32_t len=0; /* number of bytes used */ - unsigned u; /* local counting variable */ - uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of point selection info */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + uint32_t len = 0; /* number of bytes used */ + unsigned u; /* local counting variable */ + uint32_t version; /* Version number */ + uint8_t enc_size; /* Encoded size of point selection info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1189,52 +1238,96 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Determine the version and encoded size for point selection info */ - if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) + if (H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") - HDassert(enc_size == H5S_SELECT_INFO_ENC_SIZE_4); - HDassert(version == H5S_POINT_VERSION_1); - /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - - UINT32ENCODE(pp, version); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ - lenp = pp; /* Keep the pointer to the length location for later */ - pp += 4; /* Skip over space for length */ - len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ + UINT32ENCODE(pp, version); /* Store the version number */ + if (version >= 2) { + *(pp)++ = enc_size; /* Store size of point info */ + } + else { + HDassert(version == H5S_POINT_VERSION_1); + UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ + lenp = pp; /* Keep the pointer to the length location for later */ + pp += 4; /* Skip over space for length */ + len += 8; /* Add in advance # of bytes for num of dimensions and num elements */ + } /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)space->extent.rank); + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + HDassert(version == H5S_POINT_VERSION_2); + + /* Encode number of elements */ + UINT16ENCODE(pp, (uint16_t)space->select.num_elem); + + /* Encode each point in selection */ + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { + /* Encode each point */ + for (u = 0; u < space->extent.rank; u++) + UINT16ENCODE(pp, (uint16_t)curr->pnt[u]); + curr = curr->next; + } /* end while */ + break; - /* Encode number of elements */ - UINT32ENCODE(pp, (uint32_t)space->select.num_elem); + case H5S_SELECT_INFO_ENC_SIZE_4: + HDassert(version == H5S_POINT_VERSION_1 || version == H5S_POINT_VERSION_2); - /* Encode each point in selection */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { - /* Add 4 bytes times the rank for each element selected */ - len += 4 * space->extent.rank; + /* Encode number of elements */ + UINT32ENCODE(pp, (uint32_t)space->select.num_elem); - /* Encode each point */ - for(u=0; uextent.rank; u++) - UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); + /* Encode each point in selection */ + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { + /* Encode each point */ + for (u = 0; u < space->extent.rank; u++) + UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); + curr = curr->next; + } /* end while */ - curr=curr->next; - } /* end while */ + /* Add 4 bytes times the rank for each element selected */ + if (version == H5S_POINT_VERSION_1) + len += (uint32_t)space->select.num_elem * 4 * space->extent.rank; + break; - UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ + case H5S_SELECT_INFO_ENC_SIZE_8: + HDassert(version == H5S_POINT_VERSION_2); + + /* Encode number of elements */ + UINT64ENCODE(pp, space->select.num_elem); + + /* Encode each point in selection */ + curr = space->select.sel_info.pnt_lst->head; + while (curr != NULL) { + /* Encode each point */ + for (u = 0; u < space->extent.rank; u++) + UINT64ENCODE(pp, curr->pnt[u]); + curr = curr->next; + } /* end while */ + break; + + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + + } /* end switch */ + + if (version == H5S_POINT_VERSION_1) + UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */ /* Update encoding pointer */ *p = pp; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__point_serialize() */ +} /* H5S__point_serialize() */ - /*-------------------------------------------------------------------------- NAME H5S__point_deserialize @@ -1260,16 +1353,17 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p) { - 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 */ - 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 */ FUNC_ENTER_STATIC @@ -1283,8 +1377,8 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) is moved from H5S_select_deserialize() in H5Sselect.c to here. This is needed for decoding virtual layout in H5O__layout_decode() */ /* Allocate space if not provided */ - if(!*space) { - if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + if (!*space) { + if (NULL == (tmp_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") } /* end if */ else @@ -1293,63 +1387,101 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); - if(version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) + if (version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for point selection") - /* Skip over the remainder of the header */ - pp += 8; + if (version >= (uint32_t)H5S_POINT_VERSION_2) + /* Decode size of point info */ + enc_size = *(pp)++; + else { + /* Skip over the remainder of the header */ + pp += 8; + enc_size = H5S_SELECT_INFO_ENC_SIZE_4; + } + + /* Check encoded size */ + if (enc_size & ~H5S_SELECT_INFO_ENC_SIZE_BITS) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ - UINT32DECODE(pp,rank); + UINT32DECODE(pp, rank); - if(!*space) { + if (!*space) { /* Patch the rank of the allocated dataspace */ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); - if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) + if (H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ 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") - - /* Deserialize points to select */ - UINT32DECODE(pp, num_elem); /* decode the number of points */ + if (rank != tmp_space->extent.rank) + 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: + UINT16DECODE(pp, num_elem); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: + UINT32DECODE(pp, num_elem); + break; + case H5S_SELECT_INFO_ENC_SIZE_8: + UINT64DECODE(pp, num_elem); + break; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ /* Allocate space for the coordinates */ - if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) + 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") /* Retrieve the coordinates from the buffer */ - for(tcoord = coord, i = 0; i < num_elem; i++) - for(j = 0; j < (unsigned)rank; j++, tcoord++) - UINT32DECODE(pp, *tcoord); + for (tcoord = coord, i = 0; i < num_elem; i++) + for (j = 0; j < (unsigned)rank; j++, tcoord++) + switch (enc_size) { + 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; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } /* end switch */ /* Select points */ - if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) + if (H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Update decoding pointer */ *p = pp; /* Return space to the caller if allocated */ - if(!*space) + if (!*space) *space = tmp_space; done: /* Free temporary space if not passed to caller (only happens on error) */ - if(!*space && tmp_space) - if(H5S_close(tmp_space) < 0) + if (!*space && tmp_space) + if (H5S_close(tmp_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") /* Free the coordinate array if necessary */ - if(coord != NULL) + if (coord != NULL) H5MM_xfree(coord); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5S__get_select_elem_pointlist @@ -1382,8 +1514,9 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) static herr_t H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ + const hsize_t endpoint = startpoint + numpoints; /* Index of last point in iteration */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ FUNC_ENTER_STATIC_NOERR @@ -1393,27 +1526,36 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t n /* Get the dataspace extent rank */ rank = space->extent.rank; - /* Get the head of the point list */ - node = space->select.sel_info.pnt_lst->head; + /* Check for cached point at the correct index */ + if (space->select.sel_info.pnt_lst->last_idx_pnt && + startpoint == space->select.sel_info.pnt_lst->last_idx) + node = space->select.sel_info.pnt_lst->last_idx_pnt; + else { + /* Get the head of the point list */ + node = space->select.sel_info.pnt_lst->head; - /* Iterate to the first point to return */ - while(node != NULL && startpoint > 0) { - startpoint--; - node = node->next; - } /* end while */ + /* Iterate to the first point to return */ + while (node != NULL && startpoint > 0) { + startpoint--; + node = node->next; + } /* end while */ + } /* end else */ /* Iterate through the node, copying each point's information */ - while(node != NULL && numpoints > 0) { + while (node != NULL && numpoints > 0) { H5MM_memcpy(buf, node->pnt, sizeof(hsize_t) * rank); buf += rank; numpoints--; node = node->next; - } /* end while */ + } /* end while */ + + /* Cached next point in iteration */ + space->select.sel_info.pnt_lst->last_idx = endpoint; + space->select.sel_info.pnt_lst->last_idx_pnt = node; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__get_select_elem_pointlist() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_pointlist @@ -1444,21 +1586,20 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t n REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, - hsize_t numpoints, hsize_t buf[/*numpoints*/]) +H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t buf[/*numpoints*/]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ihh*[a2]h", spaceid, startpoint, numpoints, buf); /* Check args */ - if(NULL == buf) + if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) + if (H5S_GET_SELECT_TYPE(space) != H5S_SEL_POINTS) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection") ret_value = H5S__get_select_elem_pointlist(space, startpoint, numpoints, buf); @@ -1467,7 +1608,6 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_pointlist() */ - /*-------------------------------------------------------------------------- NAME H5S__point_bounds @@ -1497,8 +1637,8 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1508,24 +1648,26 @@ H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(end); /* Loop over dimensions */ - for(u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) { /* Sanity check */ - HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= space->select.sel_info.pnt_lst->high_bounds[u]); + HDassert(space->select.sel_info.pnt_lst->low_bounds[u] <= + space->select.sel_info.pnt_lst->high_bounds[u]); /* Check for offset moving selection negative */ - if(((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) + if (((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Set the low & high bounds in this dimension */ - start[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]); - end[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]); + start[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]); + end[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] + space->select.offset[u]); } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S__point_offset @@ -1549,12 +1691,12 @@ 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 hssize_t *sel_offset; /* Pointer to the selection's offset */ - 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 */ + 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 */ + hsize_t accum; /* Accumulator for dimension sizes */ + int i; /* index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1565,17 +1707,17 @@ H5S__point_offset(const H5S_t *space, hsize_t *offset) *offset = 0; /* Set up pointers to arrays of values */ - pnt = space->select.sel_info.pnt_lst->head->pnt; + pnt = space->select.sel_info.pnt_lst->head->pnt; sel_offset = space->select.offset; - dim_size = space->extent.size; + dim_size = space->extent.size; /* Loop through coordinates, calculating the linear offset */ accum = 1; - for(i = (int)space->extent.rank - 1; i >= 0; i--) { + for (i = (int)space->extent.rank - 1; i >= 0; i--) { hssize_t pnt_offset = (hssize_t)pnt[i] + sel_offset[i]; /* Point's offset in this dimension */ /* Check for offset moving selection out of the dataspace */ - if(pnt_offset < 0 || (hsize_t)pnt_offset >= dim_size[i]) + if (pnt_offset < 0 || (hsize_t)pnt_offset >= dim_size[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds") /* Add the point's offset in this dimension to the total linear offset */ @@ -1589,7 +1731,6 @@ H5S__point_offset(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_offset() */ - /*-------------------------------------------------------------------------- NAME H5S__point_unlim_dim @@ -1618,7 +1759,6 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__point_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_contiguous @@ -1643,22 +1783,22 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) static htri_t H5S__point_is_contiguous(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely contiguous */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; - else /* More than one point might be contiguous, but it's complex to check and we don't need it right now */ + else /* More than one point might be contiguous, but it's complex to check and we don't need it right now + */ ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_single @@ -1680,14 +1820,14 @@ H5S__point_is_contiguous(const H5S_t *space) static htri_t H5S__point_is_single(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely 'single' :-) */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; else ret_value = FALSE; @@ -1695,7 +1835,6 @@ H5S__point_is_single(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S__point_is_regular @@ -1720,7 +1859,7 @@ H5S__point_is_single(const H5S_t *space) static htri_t H5S__point_is_regular(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1728,7 +1867,7 @@ H5S__point_is_regular(const H5S_t *space) HDassert(space); /* Only simple check for regular points for now... */ - if(space->select.num_elem == 1) + if (space->select.num_elem == 1) ret_value = TRUE; else ret_value = FALSE; @@ -1736,7 +1875,6 @@ H5S__point_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S__point_shape_same @@ -1759,13 +1897,13 @@ H5S__point_is_regular(const H5S_t *space) static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) { - H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */ - hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */ - unsigned space1_rank; /* Number of dimensions of first dataspace */ - unsigned space2_rank; /* Number of dimensions of second dataspace */ - int space1_dim; /* Current dimension in first dataspace */ - int space2_dim; /* Current dimension in second dataspace */ - htri_t ret_value = TRUE; /* Return value */ + H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */ + hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */ + unsigned space1_rank; /* Number of dimensions of first dataspace */ + unsigned space2_rank; /* Number of dimensions of second dataspace */ + int space1_dim; /* Current dimension in first dataspace */ + int space2_dim; /* Current dimension in second dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1790,7 +1928,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) */ pnt1 = space1->select.sel_info.pnt_lst->head; pnt2 = space2->select.sel_info.pnt_lst->head; - while(space2_dim >= 0) { + while (space2_dim >= 0) { /* Set the relative locations of the selections */ offset[space1_dim] = (hssize_t)pnt2->pnt[space2_dim] - (hssize_t)pnt1->pnt[space1_dim]; @@ -1799,7 +1937,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space1: */ - while(space1_dim >= 0) { + while (space1_dim >= 0) { /* Set the absolute offset of the remaining dimensions */ offset[space1_dim] = (hssize_t)pnt1->pnt[space1_dim]; @@ -1811,14 +1949,14 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) pnt2 = pnt2->next; /* Loop over remaining points */ - while(pnt1 && pnt2) { + while (pnt1 && pnt2) { /* Initialize dimensions */ space1_dim = (int)space1_rank - 1; space2_dim = (int)space2_rank - 1; /* Compare locations in common dimensions, including relative offset */ - while(space2_dim >= 0) { - if((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim]) + while (space2_dim >= 0) { + if ((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim]) HGOTO_DONE(FALSE) space1_dim--; @@ -1826,15 +1964,14 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space1: */ - while(space1_dim >= 0) { + while (space1_dim >= 0) { /* Compare the absolute offset in the remaining dimensions */ - if((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim]) + if ((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim]) HGOTO_DONE(FALSE) space1_dim--; } /* end while */ - /* Advance to next point */ pnt1 = pnt1->next; pnt2 = pnt2->next; @@ -1844,7 +1981,6 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S__point_intersect_block @@ -1865,11 +2001,10 @@ 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(const 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 */ + H5S_pnt_node_t *pnt; /* Point information node */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1881,16 +2016,16 @@ H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, /* Loop over points */ pnt = space->select.sel_info.pnt_lst->head; - while(pnt) { - unsigned u; /* Local index variable */ + while (pnt) { + unsigned u; /* Local index variable */ /* Verify that the point is within the block */ - for(u = 0; u < space->extent.rank; u++) - if(pnt->pnt[u] < start[u] || pnt->pnt[u] > end[u]) + for (u = 0; u < space->extent.rank; u++) + if (pnt->pnt[u] < start[u] || pnt->pnt[u] > end[u]) break; /* Check if point was within block for all dimensions */ - if(u == space->extent.rank) + if (u == space->extent.rank) HGOTO_DONE(TRUE) /* Advance to next point */ @@ -1901,7 +2036,6 @@ H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S__point_adjust_u @@ -1923,10 +2057,10 @@ H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1934,20 +2068,20 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Iterate through the nodes, checking the bounds on each element */ node = space->select.sel_info.pnt_lst->head; rank = space->extent.rank; - while(node) { + while (node) { /* Adjust each coordinate for point node */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Check for offset moving selection negative */ HDassert(node->pnt[u] >= offset[u]); @@ -1960,16 +2094,15 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) } /* end while */ /* update the bound box of the selection */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { space->select.sel_info.pnt_lst->low_bounds[u] -= offset[u]; space->select.sel_info.pnt_lst->high_bounds[u] -= offset[u]; } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S__point_adjust_s @@ -1991,10 +2124,10 @@ 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) { - hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ - H5S_pnt_node_t *node; /* Point node */ - unsigned rank; /* Dataspace rank */ - unsigned u; /* Local index variable */ + hbool_t non_zero_offset = FALSE; /* Whether any offset is non-zero */ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ + unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -2002,20 +2135,20 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) HDassert(offset); /* Check for an all-zero offset vector */ - for(u = 0; u < space->extent.rank; u++) - if(0 != offset[u]) { + for (u = 0; u < space->extent.rank; u++) + if (0 != offset[u]) { non_zero_offset = TRUE; break; } /* end if */ /* Only perform operation if the offset is non-zero */ - if(non_zero_offset) { + if (non_zero_offset) { /* Iterate through the nodes, checking the bounds on each element */ node = space->select.sel_info.pnt_lst->head; rank = space->extent.rank; - while(node) { + while (node) { /* Adjust each coordinate for point node */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { /* Check for offset moving selection negative */ HDassert((hssize_t)node->pnt[u] >= offset[u]); @@ -2028,18 +2161,18 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) } /* end while */ /* update the bound box of the selection */ - for(u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) { HDassert((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] >= offset[u]); - space->select.sel_info.pnt_lst->low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] - offset[u]); - space->select.sel_info.pnt_lst->high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] - offset[u]); + space->select.sel_info.pnt_lst->low_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] - offset[u]); + space->select.sel_info.pnt_lst->high_bounds[u] = + (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] - offset[u]); } /* end for */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_adjust_s() */ - - /*------------------------------------------------------------------------- * Function: H5S__point_project_scalar * @@ -2056,8 +2189,8 @@ 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) { - const H5S_pnt_node_t *node; /* Point node */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5S_pnt_node_t *node; /* Point node */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2069,8 +2202,9 @@ H5S__point_project_scalar(const H5S_t *space, hsize_t *offset) node = space->select.sel_info.pnt_lst->head; /* Check for more than one point selected */ - if(node->next) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "point selection of one element has more than one node!") + if (node->next) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "point selection of one element has more than one node!") /* Calculate offset of selection in projected buffer */ *offset = H5VM_array_offset(space->extent.rank, space->extent.size, node->pnt); @@ -2079,9 +2213,8 @@ H5S__point_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_scalar() */ - /*------------------------------------------------------------------------- - * Function: H5S_point_project_simple + * Function: H5S__point_project_simple * * Purpose: Projects a point selection onto/into a simple dataspace * of a different rank @@ -2096,12 +2229,12 @@ H5S__point_project_scalar(const H5S_t *space, hsize_t *offset) 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 */ - unsigned rank_diff; /* Difference in ranks between spaces */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned rank_diff; /* Difference in ranks between spaces */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2111,16 +2244,16 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of HDassert(offset); /* We are setting a new selection, remove any current selection in new dataspace */ - if(H5S_SELECT_RELEASE(new_space) < 0) + if (H5S_SELECT_RELEASE(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection") /* Allocate room for the head of the point list */ - if(NULL == (new_space->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) + if (NULL == (new_space->select.sel_info.pnt_lst = H5FL_MALLOC(H5S_pnt_list_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point list node") /* Check if the new space's rank is < or > base space's rank */ - if(new_space->extent.rank < base_space->extent.rank) { - hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ + if (new_space->extent.rank < base_space->extent.rank) { + hsize_t block[H5S_MAX_RANK]; /* Block selected in base dataspace */ /* Compute the difference in ranks */ rank_diff = base_space->extent.rank - new_space->extent.rank; @@ -2133,21 +2266,22 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of /* Iterate through base space's point nodes, copying the point information */ base_node = base_space->select.sel_info.pnt_lst->head; prev_node = NULL; - while(base_node) { + while (base_node) { /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") new_node->next = NULL; /* Copy over the point's coordinates */ - H5MM_memcpy(new_node->pnt, &base_node->pnt[rank_diff], (new_space->extent.rank * sizeof(hsize_t))); + H5MM_memcpy(new_node->pnt, &base_node->pnt[rank_diff], + (new_space->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == prev_node) + if (NULL == prev_node) prev_node = new_space->select.sel_info.pnt_lst->head = new_node; else { prev_node->next = new_node; - prev_node = new_node; + prev_node = new_node; } /* end else */ /* Advance to next node */ @@ -2155,11 +2289,13 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of } /* end while */ /* Update the bounding box */ - for(u = 0; u < new_space->extent.rank; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff]; - new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff]; + for (u = 0; u < new_space->extent.rank; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = + base_space->select.sel_info.pnt_lst->low_bounds[u + rank_diff]; + new_space->select.sel_info.pnt_lst->high_bounds[u] = + base_space->select.sel_info.pnt_lst->high_bounds[u + rank_diff]; } /* end for */ - } /* end if */ + } /* end if */ else { HDassert(new_space->extent.rank > base_space->extent.rank); @@ -2172,22 +2308,23 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of /* Iterate through base space's point nodes, copying the point information */ base_node = base_space->select.sel_info.pnt_lst->head; prev_node = NULL; - while(base_node) { + while (base_node) { /* Create new point */ - if(NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) + if (NULL == (new_node = (H5S_pnt_node_t *)H5FL_ARR_MALLOC(hcoords_t, new_space->extent.rank))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate point node") new_node->next = NULL; /* 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))); + H5MM_memcpy(&new_node->pnt[rank_diff], base_node->pnt, + (new_space->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ - if(NULL == prev_node) + if (NULL == prev_node) prev_node = new_space->select.sel_info.pnt_lst->head = new_node; else { prev_node->next = new_node; - prev_node = new_node; + prev_node = new_node; } /* end else */ /* Advance to next node */ @@ -2195,15 +2332,21 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of } /* end while */ /* Update the bounding box */ - for(u = 0; u < rank_diff; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = 0; + for (u = 0; u < rank_diff; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = 0; new_space->select.sel_info.pnt_lst->high_bounds[u] = 0; } /* end for */ - for(; u < new_space->extent.rank; u++) { - new_space->select.sel_info.pnt_lst->low_bounds[u] = base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff]; - new_space->select.sel_info.pnt_lst->high_bounds[u] = base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff]; + for (; u < new_space->extent.rank; u++) { + new_space->select.sel_info.pnt_lst->low_bounds[u] = + base_space->select.sel_info.pnt_lst->low_bounds[u - rank_diff]; + new_space->select.sel_info.pnt_lst->high_bounds[u] = + base_space->select.sel_info.pnt_lst->high_bounds[u - rank_diff]; } /* end for */ - } /* end else */ + } /* end else */ + + /* Clear cached iteration point */ + new_space->select.sel_info.pnt_lst->last_idx = 0; + new_space->select.sel_info.pnt_lst->last_idx_pnt = NULL; /* Number of elements selected will be the same */ new_space->select.num_elem = base_space->select.num_elem; @@ -2215,7 +2358,6 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_elements @@ -2247,32 +2389,30 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, - const hsize_t *coord) +H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iSsz*h", spaceid, op, num_elem, coord); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) + if (H5S_SCALAR == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_SCALAR space") - if(H5S_NULL == H5S_GET_EXTENT_TYPE(space)) + if (H5S_NULL == H5S_GET_EXTENT_TYPE(space)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "point doesn't support H5S_NULL space") - if(coord == NULL || num_elem == 0) + if (coord == NULL || num_elem == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified") - if(!(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND)) + if (!(op == H5S_SELECT_SET || op == H5S_SELECT_APPEND || op == H5S_SELECT_PREPEND)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "unsupported operation attempted") /* Call the real element selection routine */ - if((ret_value = H5S_select_elements(space, op, num_elem, coord)) < 0) + if ((ret_value = H5S_select_elements(space, op, num_elem, coord)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't select elements") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_elements() */ - diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 2a9c75830b5..76ed23792c0 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,56 +14,27 @@ /* * This file contains private information about the H5S module */ -#ifndef _H5Sprivate_H -#define _H5Sprivate_H +#ifndef H5Sprivate_H +#define H5Sprivate_H /* Include package's public header */ #include "H5Spublic.h" /* Public headers needed by this file */ -#include "H5Dpublic.h" /* Datasets */ +#include "H5Dpublic.h" /* Datasets */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* Files */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ - -/* 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. - */ -#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. - */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ /* Forward references of package typedefs */ -typedef struct H5S_extent_t H5S_extent_t; -typedef struct H5S_pnt_node_t H5S_pnt_node_t; -typedef struct H5S_pnt_list_t H5S_pnt_list_t; -typedef struct H5S_hyper_span_t H5S_hyper_span_t; +typedef struct H5S_extent_t H5S_extent_t; +typedef struct H5S_pnt_node_t H5S_pnt_node_t; +typedef struct H5S_pnt_list_t H5S_pnt_list_t; +typedef struct H5S_hyper_span_t H5S_hyper_span_t; typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t; /* Information about one dimension in a hyperslab selection */ @@ -76,39 +47,39 @@ typedef struct H5S_hyper_dim_t { /* Point selection iteration container */ typedef struct { - H5S_pnt_list_t *pnt_lst; /* Pointer to point list */ - H5S_pnt_node_t *curr; /* Pointer to next node to output */ + H5S_pnt_list_t *pnt_lst; /* Pointer to point list */ + H5S_pnt_node_t *curr; /* Pointer to next node to output */ } H5S_point_iter_t; /* Hyperslab selection iteration container */ typedef struct { /* Common fields for all hyperslab selections */ - hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ - hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */ - unsigned iter_rank; /* Rank of iterator information */ - /* (This should always be the same as the dataspace - * rank, except for regular hyperslab selections in - * which there are contiguous regions in the lower - * dimensions that have been "flattened") - */ - hbool_t diminfo_valid; /* Whether the dimension information is valid */ + hsize_t off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ + hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */ + unsigned iter_rank; /* Rank of iterator information */ + /* (This should always be the same as the dataspace + * rank, except for regular hyperslab selections in + * which there are contiguous regions in the lower + * dimensions that have been "flattened") + */ + hbool_t diminfo_valid; /* Whether the dimension information is valid */ /* "Flattened" regular hyperslab selection fields */ H5S_hyper_dim_t diminfo[H5S_MAX_RANK]; /* "Flattened" regular selection information */ - hsize_t size[H5S_MAX_RANK]; /* "Flattened" dataspace extent information */ - hssize_t sel_off[H5S_MAX_RANK]; /* "Flattened" selection offset information */ - hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */ + hsize_t size[H5S_MAX_RANK]; /* "Flattened" dataspace extent information */ + hssize_t sel_off[H5S_MAX_RANK]; /* "Flattened" selection offset information */ + hbool_t flattened[H5S_MAX_RANK]; /* Whether this dimension has been flattened */ /* 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 */ typedef struct { - hsize_t elmt_offset; /* Next element to output */ - hsize_t byte_offset; /* Next byte to output */ + hsize_t elmt_offset; /* Next element to output */ + hsize_t byte_offset; /* Next byte to output */ } H5S_all_iter_t; /* Forward declaration of selection iteration class */ @@ -120,105 +91,107 @@ typedef struct H5S_sel_iter_t { const struct H5S_sel_iter_class_t *type; /* Selection iteration class info */ /* Information common to all iterators */ - unsigned rank; /* Rank of dataspace the selection iterator is operating on */ - hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */ + unsigned rank; /* Rank of dataspace the selection iterator is operating on */ + hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataspace the selection is operating on */ hssize_t sel_off[H5S_MAX_RANK]; /* Selection offset in dataspace */ - hsize_t elmt_left; /* Number of elements left to iterate over */ - size_t elmt_size; /* Size of elements to iterate over */ - unsigned flags; /* Flags controlling iterator behavior */ + hsize_t elmt_left; /* Number of elements left to iterate over */ + size_t elmt_size; /* Size of elements to iterate over */ + unsigned flags; /* Flags controlling iterator behavior */ /* Information specific to each type of iterator */ union { - H5S_point_iter_t pnt; /* Point selection iteration information */ - H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ - H5S_all_iter_t all; /* "All" selection iteration information */ + H5S_point_iter_t pnt; /* Point selection iteration information */ + H5S_hyper_iter_t hyp; /* New Hyperslab selection iteration information */ + H5S_all_iter_t all; /* "All" selection iteration information */ } u; } H5S_sel_iter_t; /* Selection iteration operator for internal library callbacks */ -typedef herr_t (*H5S_sel_iter_lib_op_t)(void *elem, const H5T_t *type, - unsigned ndim, const hsize_t *point, void *op_data); +typedef herr_t (*H5S_sel_iter_lib_op_t)(void *elem, const H5T_t *type, unsigned ndim, const hsize_t *point, + void *op_data); /* Describe kind of callback to make */ typedef enum H5S_sel_iter_op_type_t { - H5S_SEL_ITER_OP_APP, /* Application callback */ - H5S_SEL_ITER_OP_LIB /* Library internal callback */ + H5S_SEL_ITER_OP_APP, /* Application callback */ + H5S_SEL_ITER_OP_LIB /* Library internal callback */ } H5S_sel_iter_op_type_t; typedef struct H5S_sel_iter_app_op_t { - H5D_operator_t op; /* Callback */ - hid_t type_id; /* Type ID to be passed to callback */ + H5D_operator_t op; /* Callback */ + hid_t type_id; /* Type ID to be passed to callback */ } H5S_sel_iter_app_op_t; typedef struct H5S_sel_iter_op_t { H5S_sel_iter_op_type_t op_type; union { - H5S_sel_iter_app_op_t app_op; /* Application callback */ - H5S_sel_iter_lib_op_t lib_op; /* Library internal callback */ + H5S_sel_iter_app_op_t app_op; /* Application callback */ + H5S_sel_iter_lib_op_t lib_op; /* Library internal callback */ } u; } H5S_sel_iter_op_t; /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5S_MODULE -#define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) -#define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) -#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) -#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) -#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) -#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) -#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) -#define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF)) -#define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.type->bounds)(S,START,END)) -#define H5S_SELECT_OFFSET(S, OFFSET) ((*(S)->select.type->offset)(S, OFFSET)) -#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) -#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) -#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) -#define H5S_SELECT_ADJUST_U(S,O) ((*(S)->select.type->adjust_u)(S, O)) -#define H5S_SELECT_ADJUST_S(S,O) ((*(S)->select.type->adjust_s)(S, O)) -#define H5S_SELECT_PROJECT_SCALAR(S,O) ((*(S)->select.type->project_scalar)(S, O)) -#define H5S_SELECT_PROJECT_SIMPLE(S,NS, O) ((*(S)->select.type->project_simple)(S, NS, O)) -#define H5S_SELECT_ITER_COORDS(ITER,COORDS) ((*(ITER)->type->iter_coords)(ITER,COORDS)) -#define H5S_SELECT_ITER_BLOCK(ITER,START,END) ((*(ITER)->type->iter_block)(ITER,START,END)) -#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) +#define H5S_GET_EXTENT_TYPE(S) ((S)->extent.type) +#define H5S_GET_EXTENT_NDIMS(S) ((S)->extent.rank) +#define H5S_GET_EXTENT_NPOINTS(S) ((S)->extent.nelem) +#define H5S_GET_SELECT_NPOINTS(S) ((S)->select.num_elem) +#define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) +#define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) +#define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) +#define H5S_SELECT_SERIALIZE(S, BUF) ((*(S)->select.type->serialize)(S, BUF)) +#define H5S_SELECT_BOUNDS(S, START, END) ((*(S)->select.type->bounds)(S, START, END)) +#define H5S_SELECT_OFFSET(S, OFFSET) ((*(S)->select.type->offset)(S, OFFSET)) +#define H5S_SELECT_IS_CONTIGUOUS(S) ((*(S)->select.type->is_contiguous)(S)) +#define H5S_SELECT_IS_SINGLE(S) ((*(S)->select.type->is_single)(S)) +#define H5S_SELECT_IS_REGULAR(S) ((*(S)->select.type->is_regular)(S)) +#define H5S_SELECT_ADJUST_U(S, O) ((*(S)->select.type->adjust_u)(S, O)) +#define H5S_SELECT_ADJUST_S(S, O) ((*(S)->select.type->adjust_s)(S, O)) +#define H5S_SELECT_PROJECT_SCALAR(S, O) ((*(S)->select.type->project_scalar)(S, O)) +#define H5S_SELECT_PROJECT_SIMPLE(S, NS, O) ((*(S)->select.type->project_simple)(S, NS, O)) +#define H5S_SELECT_ITER_COORDS(ITER, COORDS) ((*(ITER)->type->iter_coords)(ITER, COORDS)) +#define H5S_SELECT_ITER_BLOCK(ITER, START, END) ((*(ITER)->type->iter_block)(ITER, START, END)) +#define H5S_SELECT_ITER_NELMTS(ITER) ((*(ITER)->type->iter_nelmts)(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_has_next_block)(ITER)) -#define H5S_SELECT_ITER_NEXT(ITER,NELEM)((*(ITER)->type->iter_next)(ITER,NELEM)) +#define H5S_SELECT_ITER_NEXT(ITER, NELEM) ((*(ITER)->type->iter_next)(ITER, NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) ((*(ITER)->type->iter_next_block)(ITER)) -#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(ITER)->type->iter_get_seq_list)(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) -#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) +#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN) \ + ((*(ITER)->type->iter_get_seq_list)(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN)) +#define H5S_SELECT_ITER_RELEASE(ITER) ((*(ITER)->type->iter_release)(ITER)) #else /* H5S_MODULE */ -#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) -#define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) -#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) -#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) -#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) -#define H5S_SELECT_VALID(S) (H5S_select_valid(S)) -#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) -#define H5S_SELECT_SERIALIZE(S,BUF) (H5S_select_serialize(S,BUF)) -#define H5S_SELECT_BOUNDS(S,START,END) (H5S_get_select_bounds(S,START,END)) -#define H5S_SELECT_OFFSET(S, OFFSET) (H5S_get_select_offset(S, OFFSET)) -#define H5S_SELECT_IS_CONTIGUOUS(S) (H5S_select_is_contiguous(S)) -#define H5S_SELECT_IS_SINGLE(S) (H5S_select_is_single(S)) -#define H5S_SELECT_IS_REGULAR(S) (H5S_select_is_regular(S)) -#define H5S_SELECT_ADJUST_U(S,O) (H5S_select_adjust_u(S, O)) -#define H5S_SELECT_ADJUST_S(S,O) (H5S_select_adjust_s(S, O)) -#define H5S_SELECT_PROJECT_SCALAR(S,O) (H5S_select_project_scalar(S, O)) -#define H5S_SELECT_PROJECT_SIMPLE(S,NS,O) (H5S_select_project_simple(S, NS, O)) -#define H5S_SELECT_ITER_COORDS(ITER,COORDS) (H5S_select_iter_coords(ITER,COORDS)) -#define H5S_SELECT_ITER_BLOCK(ITER,START,END) (H5S_select_iter_block(ITER,START,END)) -#define H5S_SELECT_ITER_NELMTS(ITER) (H5S_select_iter_nelmts(ITER)) +#define H5S_GET_EXTENT_TYPE(S) (H5S_get_simple_extent_type(S)) +#define H5S_GET_EXTENT_NDIMS(S) (H5S_get_simple_extent_ndims(S)) +#define H5S_GET_EXTENT_NPOINTS(S) (H5S_get_simple_extent_npoints(S)) +#define H5S_GET_SELECT_NPOINTS(S) (H5S_get_select_npoints(S)) +#define H5S_GET_SELECT_TYPE(S) (H5S_get_select_type(S)) +#define H5S_SELECT_VALID(S) (H5S_select_valid(S)) +#define H5S_SELECT_SERIAL_SIZE(S) (H5S_select_serial_size(S)) +#define H5S_SELECT_SERIALIZE(S, BUF) (H5S_select_serialize(S, BUF)) +#define H5S_SELECT_BOUNDS(S, START, END) (H5S_get_select_bounds(S, START, END)) +#define H5S_SELECT_OFFSET(S, OFFSET) (H5S_get_select_offset(S, OFFSET)) +#define H5S_SELECT_IS_CONTIGUOUS(S) (H5S_select_is_contiguous(S)) +#define H5S_SELECT_IS_SINGLE(S) (H5S_select_is_single(S)) +#define H5S_SELECT_IS_REGULAR(S) (H5S_select_is_regular(S)) +#define H5S_SELECT_ADJUST_U(S, O) (H5S_select_adjust_u(S, O)) +#define H5S_SELECT_ADJUST_S(S, O) (H5S_select_adjust_s(S, O)) +#define H5S_SELECT_PROJECT_SCALAR(S, O) (H5S_select_project_scalar(S, O)) +#define H5S_SELECT_PROJECT_SIMPLE(S, NS, O) (H5S_select_project_simple(S, NS, O)) +#define H5S_SELECT_ITER_COORDS(ITER, COORDS) (H5S_select_iter_coords(ITER, COORDS)) +#define H5S_SELECT_ITER_BLOCK(ITER, START, END) (H5S_select_iter_block(ITER, START, END)) +#define H5S_SELECT_ITER_NELMTS(ITER) (H5S_select_iter_nelmts(ITER)) #define H5S_SELECT_ITER_HAS_NEXT_BLOCK(ITER) (H5S_select_iter_has_next_block(ITER)) -#define H5S_SELECT_ITER_NEXT(ITER,NELEM)(H5S_select_iter_next(ITER,NELEM)) +#define H5S_SELECT_ITER_NEXT(ITER, NELEM) (H5S_select_iter_next(ITER, NELEM)) #define H5S_SELECT_ITER_NEXT_BLOCK(ITER) (H5S_select_iter_next_block(ITER)) -#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_iter_get_seq_list(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) -#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) +#define H5S_SELECT_ITER_GET_SEQ_LIST(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN) \ + (H5S_select_iter_get_seq_list(ITER, MAXSEQ, MAXBYTES, NSEQ, NBYTES, OFF, LEN)) +#define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) #endif /* H5S_MODULE */ /* Handle these callbacks in a special way, since they have prologs that need to be executed */ -#define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) -#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_COPY(DST, SRC, SHARE) (H5S_select_copy(DST, SRC, SHARE)) +#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)) /* Forward declaration of structs used below */ struct H5O_t; @@ -228,74 +201,67 @@ 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 herr_t H5S_close(H5S_t *ds); +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); -H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); -H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); -H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); -H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[]/*out*/, - hsize_t max_dims[]/*out*/); +H5_DLL hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds); +H5_DLL hsize_t H5S_get_npoints_max(const H5S_t *ds); +H5_DLL hbool_t H5S_has_extent(const H5S_t *ds); +H5_DLL int H5S_get_simple_extent_ndims(const H5S_t *ds); +H5_DLL int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[] /*out*/, hsize_t max_dims[] /*out*/); H5_DLL herr_t H5S_write(H5F_t *f, struct H5O_t *oh, unsigned update_flags, H5S_t *ds); H5_DLL herr_t H5S_append(H5F_t *f, struct H5O_t *oh, H5S_t *ds); H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc); 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 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 H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], - const hsize_t maxdims[/*rank*/]); +H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const 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); H5_DLL H5S_t *H5S_decode(const unsigned char **p); -H5_DLL herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, - int fwidth); +H5_DLL herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); /* Operations on dataspace extents */ H5_DLL hsize_t H5S_extent_nelem(const H5S_extent_t *ext); -H5_DLL int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]); -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); +H5_DLL int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]); +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); 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, 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); /* Operations on all selections */ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); @@ -304,49 +270,40 @@ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); H5_DLL herr_t H5S_select_none(H5S_t *space); /* Operations on point selections */ -H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, - size_t num_elem, const hsize_t *coord); +H5_DLL herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); /* Operations on hyperslab selections */ -H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], - const hsize_t *stride, const hsize_t count[], const hsize_t *block); -H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, - const hsize_t start[], const hsize_t *stride, const hsize_t count[], - const hsize_t *block, H5S_t **new_space); -H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, - const hsize_t *coords); -H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); -H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); -H5_DLL herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size); -H5_DLL hsize_t H5S_hyper_get_clip_extent(const H5S_t *clip_space, - const H5S_t *match_space, 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 hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space, - hsize_t clip_size, hbool_t *partial); +H5_DLL herr_t H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], + const hsize_t *stride, const hsize_t count[], const hsize_t *block); +H5_DLL herr_t H5S_combine_hyperslab(H5S_t *old_space, H5S_seloper_t op, const hsize_t start[], + const hsize_t *stride, const hsize_t count[], const hsize_t *block, + H5S_t **new_space); +H5_DLL herr_t H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords); +H5_DLL htri_t H5S_hyper_normalize_offset(H5S_t *space, hssize_t *old_offset); +H5_DLL herr_t H5S_hyper_denormalize_offset(H5S_t *space, const hssize_t *old_offset); +H5_DLL herr_t H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size); +H5_DLL hsize_t H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, + 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 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_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); +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_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); -H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, - size_t maxbytes, size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); +H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); +H5_DLL herr_t H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); 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, - /* out: */ MPI_Datatype *new_type, - int *count, - hbool_t *is_derived_type, - hbool_t do_permute, - hsize_t **permute_map, - hbool_t * is_permuted); + /* 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 */ -#endif /* _H5Sprivate_H */ - +#endif /* H5Sprivate_H */ diff --git a/src/H5Spublic.h b/src/H5Spublic.h index b47cc45f3f0..331e5ee8070 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,139 +14,1379 @@ /* * This file contains public declarations for the H5S module. */ -#ifndef _H5Spublic_H -#define _H5Spublic_H +#ifndef H5Spublic_H +#define H5Spublic_H /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" /* Define atomic datatypes */ -#define H5S_ALL (hid_t)0 -#define H5S_UNLIMITED HSIZE_UNDEF +#define H5S_ALL (hid_t)0 +#define H5S_UNLIMITED HSIZE_UNDEF /* Define user-level maximum number of dimensions */ -#define H5S_MAX_RANK 32 +#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. \ + */ +#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. \ + */ /* Different 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, /*scalar variable */ + H5S_SIMPLE = 1, /*simple dataspace */ + H5S_NULL = 2 /*null dataspace */ } H5S_class_t; /* 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 - * (add new selection to existing selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A or B: CCCCCCCCCCCCCCCC - */ - H5S_SELECT_AND, /* Binary "and" operation for hyperslabs - * (only leave overlapped regions in selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A and B: CCCC - */ - H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs - * (only leave non-overlapped regions in selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A xor B: CCCCCC CCCCCC - */ - H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs - * (only leave non-overlapped regions in original selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * A not B: CCCCCC - */ - H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs - * (only leave non-overlapped regions in new selection) - * Original region: AAAAAAAAAA - * New region: BBBBBBBBBB - * B not A: CCCCCC - */ - 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_NOOP = -1, /* error */ + H5S_SELECT_SET = 0, /* Select "set" operation */ + H5S_SELECT_OR, /* Binary "or" operation for hyperslabs + * (add new selection to existing selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A or B: CCCCCCCCCCCCCCCC + */ + H5S_SELECT_AND, /* Binary "and" operation for hyperslabs + * (only leave overlapped regions in selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A and B: CCCC + */ + H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs + * (only leave non-overlapped regions in selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A xor B: CCCCCC CCCCCC + */ + H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs + * (only leave non-overlapped regions in original selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * A not B: CCCCCC + */ + H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs + * (only leave non-overlapped regions in new selection) + * Original region: AAAAAAAAAA + * New region: BBBBBBBBBB + * B not A: CCCCCC + */ + 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 */ 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, /* 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_type; #ifdef __cplusplus extern "C" { #endif -/* Operations on dataspaces */ -H5_DLL hid_t H5Screate(H5S_class_t type); -H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[], - const hsize_t maxdims[]); -H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, - const hsize_t dims[], const hsize_t max[]); -H5_DLL hid_t H5Scopy(hid_t space_id); +/* Operations on dataspaces, dataspace selections and selection iterators */ + +/** + * \ingroup H5S + * + * \brief Releases and terminates access to a dataspace + * + * \space_id + * + * \return \herr_t + * + * \details H5Sclose() releases a dataspace. Further access through the + * dataspace identifier is illegal. Failure to release a dataspace with this + * call will result in resource leaks. + * + * \version 1.4.0 Fortran subroutine introduced in this release. + * \since 1.0.0 + * + */ H5_DLL herr_t H5Sclose(hid_t space_id); -H5_DLL herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc); +/** + * \ingroup H5S + * + * \brief Performs an operation on a hyperslab and an existing selection and + * returns the resulting selection + * + * \space_id + * \param[in] op Operation to perform on the current selection + * \param[in] start Offset of the start of of the hyperslab + * \param[in] stride Hyperslab stride + * \param[in] count Number of blocks included in the hyperslab + * \param[in] block Size of a block in the hyperslab + * + * \return \hid_tv{dataspace} + * + * \details H5Scombine_hyperslab() combines a hyperslab selection specified + * by \p start, \p stride, \p count and \p block with the current + * selection for the dataspace \p space_id, creating a new dataspace + * to return the generated selection. If the current selection is + * not a hyperslab, it is freed and the hyperslab parameters passed + * in are combined with the #H5S_SEL_ALL hyperslab (ie. a selection + * composing the entire current extent). If either \p stride or + * \p block is NULL, then it will be set to \p 1. + * + * \since 1.10.6 + * + */ +H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]); +/** + * \ingroup H5S + * + * \brief Combine two hyperslab selections with an operation, returning a + * dataspace with the resulting selection + * + * \space_id{space1_id} + * \param[in] op Selection operator + * \space_id{space2_id} + * + * \return \hid_t{dataspace} + * + * \details H5Scombine_select() combines two hyperslab selections + * \p space1_id and \p space2_id with an operation, returning a + * new dataspace with the resulting selection. The dataspace extent + * from \p space1_id is copied for the dataspace extent of the + * newly created dataspace. + * + * \since 1.10.6 + * + */ +H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); +/** + * \ingroup H5S + * + * \brief Creates an exact copy of a dataspace + * + * \space_id + * + * \return \hid_tv{dataspace} + * + * \details H5Scopy() creates a new dataspace which is an exact copy of the + * dataspace identified by \p space_id. The dataspace identifier + * returned from this function should be released with H5Sclose() + * or resource leaks will occur. + * + * \version 1.4.0 Fortran subroutine introduced. + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Scopy(hid_t space_id); +/** + * \ingroup H5S + * + * \brief Creates a new dataspace of a specified type + * + * \param[in] type Type of dataspace to be created + * + * \return \hid_t{dataspace} + * + * \details H5Screate() creates a new dataspace of a particular type. Currently + * supported types are #H5S_SCALAR, #H5S_SIMPLE, and #H5S_NULL. + * + * Further dataspace types may be added later. + * + * A scalar dataspace, #H5S_SCALAR, has a single element, though that + * element may be of a complex datatype, such as a compound or array + * datatype. By convention, the rank of a scalar dataspace is always \p 0 + * (zero); think of it geometrically as a single, dimensionless point, + * though that point can be complex. + * + * A simple dataspace, #H5S_SIMPLE, consists of a regular array of elements. + * + * A null dataspace, #H5S_NULL, has no data elements. + * + * The dataspace identifier returned by this function can be released with + * H5Sclose() so that resource leaks will not occur. + * + * \version 1.4.0 Fortran subroutine introduced. + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Screate(H5S_class_t type); +/** + * \ingroup H5S + * \brief Creates a new simple dataspace and opens it for access + * + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims Array specifying the size of each dimension + * \param[in] maxdims Array specifying the maximum size of each dimension + * + * \return \hid_t{dataspace} + * + * \details H5Screate_simple() creates a new simple dataspace and opens it + * for access, returning a dataspace identifier. + * + * \p rank is the number of dimensions used in the dataspace. + * + * \p dims is a one-dimensional array of size rank specifying the + * size of each dimension of the dataset. \p maxdims is an array of + * the same size specifying the upper limit on the size of each + * dimension. + * + * Any element of \p dims can be \p 0 (zero). Note that no data can + * be written to a dataset if the size of any dimension of its current + * dataspace is \p 0. This is sometimes a useful initial state for + * a dataset. + * + * \p maxdims may be the null pointer, in which case the upper limit + * is the same as \p dims. Otherwise, no element of \p maxdims + * should be smaller than the corresponding element of \p dims. + * + * If an element of \p maxdims is #H5S_UNLIMITED, the maximum size of + * the corresponding dimension is unlimited. + * + * Any dataset with an unlimited dimension must also be chunked; see + * H5Pset_chunk(). Similarly, a dataset must be chunked if \p dims + * does not equal \p maxdims. + * + * The dataspace identifier returned from this function must be + * released with H5Sclose() or resource leaks will occur. + * + * \note Once a dataspace has been created, specific regions or elements in + * the dataspace can be selected and selections can be removed, as well. + * For example, H5Sselect_hyperslab() selects a region in a dataspace and + * H5Sselect_elements() selects array elements in a dataspace. These + * functions are used for subsetting. H5Sselect_none() removes all + * selections from a dataspace and is used in Parallel HDF5 when a process + * does not have or need to write data. + * + * \version 1.4.0 Fortran subroutine introduced. + * + * \since 1.0.0 + * + */ +H5_DLL hid_t H5Screate_simple(int rank, const hsize_t dims[], const hsize_t maxdims[]); +/** + * \ingroup H5S + * + * \brief Decodes a binary object description of data space and returns a + * new object handle + * + * \param[in] buf Buffer for the data space object to be decoded + * + * \return \hid_t{dataspace} + * + * \details Given an object description of a dataspace in binary in a + * buffer, H5Sdecode() reconstructs the HDF5 data type object and + * returns a new object handle for it. The binary description of the + * object is encoded by H5Sencode(). The user is responsible for + * passing in the right buffer. The types of dataspace addressed + * in this function are null, scalar, and simple space. For a + * simple dataspace, the selection information (for example, + * hyperslab selection) is also encoded and decoded. A complex + * dataspace has not been implemented in the library. + * + * \since 1.8.0 + * + */ H5_DLL hid_t H5Sdecode(const void *buf); -H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); +/** + * \ingroup H5S + * + * \brief Encodes a data space object description into a binary buffer + * + * \space_id{obj_id} + * \param[in,out] buf Buffer for the object to be encoded into; + * If the provided buffer is NULL, only the size + * of buffer needed is returned through \p nalloc. + * \param[in,out] nalloc The size of the allocated buffer + * \fapl_id{fapl} + * + * \return \herr_t + * + * \details Given the data space identifier \p obj_id, H5Sencode2() converts + * a data space description into binary form in a buffer. Using this + * binary form in the buffer, a data space object can be + * reconstructed with H5Sdecode() to return a new object handle + * (#hid_t) for this data space. + * + * A preliminary H5Sencode2() call can be made to determine the + * size of the buffer needed. This value is returned in \p nalloc. + * That value can then be assigned to \p nalloc for a second + * H5Sencode2() call, which will retrieve the actual encoded object. + * + * If the library determines that \p nalloc is not big enough for the + * object, it simply returns the size of the buffer needed through + * \p nalloc without encoding the provided buffer. + * + * The file access property list \p fapl_id is used to control the + * encoding via the \a libver_bounds property (see + * H5Pset_libver_bounds()). If the \a libver_bounds property is missing, + * H5Sencode2() proceeds as if the \a libver_bounds property were set to + * (#H5F_LIBVER_EARLIEST, #H5F_LIBVER_LATEST). (Functionally, + * H5Sencode1() is identical to H5Sencode2() with \a libver_bounds set to + * (#H5F_LIBVER_EARLIEST, #H5F_LIBVER_LATEST).) + * + * The types of data space that are addressed in this function are + * null, scalar, and simple space. For a simple data space, the + * information on the selection, for example, hyperslab selection, + * is also encoded and decoded. A complex data space has not been + * implemented in the library. + * + * \note Motivation: This function was introduced in HDF5-1.12 as part of the + * H5Sencode() format change to enable 64-bit selection encodings and + * a dataspace selection that is tied to a file. See the \ref_news_112 + * as well as the \ref_sencode_fmt_change. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl); +/** + * \ingroup H5S + * + * \brief Copies the extent of a dataspace + * + * \space_id{dst_id} + * \space_id{src_id} + * + * \return \herr_t + * + * \details H5Sextent_copy() copies the extent from \p src_id to \p dst_id. + * This action may change the type of the dataspace. + * + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Sextent_copy(hid_t dst_id, hid_t src_id); +/** + * \ingroup H5S + * + * \brief Determines whether two dataspace extents are equal + * + * \space_id{space1_id} + * \space_id{space2_id} + * + * \return \htri_t + * + * \details H5Sextent_equal() determines whether the dataspace extents of + * two dataspaces, \p space1_id and \p space2_id, are equal. + * + * \since 1.8.0 + * + */ +H5_DLL htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id); +/** + * \ingroup H5S + * + * \brief Retrieves a regular hyperslab selection + * + * \space_id{spaceid} + * \param[out] start Offset of the start of the regular hyperslab + * \param[out] stride Stride of the regular hyperslab + * \param[out] count Number of blocks in the regular hyperslab + * \param[out] block Size of a block in the regular hyperslab + * + * \return \herr_t + * + * \details H5Sget_regular_hyperslab() takes the dataspace identifier, + * \p spaceid, and retrieves the values of \p start, \p stride, + * \p count, and \p block for the regular hyperslab selection. + * + * A regular hyperslab selection is a hyperslab selection + * described by setting the \p offset, \p stride, \p count, and + * \p block parameters to the H5Sselect_hyperslab() call. If + * several calls to H5Sselect_hyperslab() are needed, the + * hyperslab selection is irregular. + * + * See H5Sselect_hyperslab() for descriptions of \p offset, + * \p stride, \p count, and \p block. + * + * \note If a hyperslab selection is originally regular, then becomes + * irregular through selection operations, and then becomes regular + * again, the final regular selection may be equivalent but not + * identical to the original regular selection. + * + * \since 1.10.0 + * + */ +H5_DLL htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], hsize_t count[], + hsize_t block[]); +/** + * \ingroup H5S + * + * \brief Gets the bounding box containing the current selection + * + * \space_id{spaceid} + * \param[out] start Starting coordinates of the bounding box + * \param[out] end Ending coordinates of the bounding box, i.e., the + * coordinates of the diagonally opposite corner + * + * \return \herr_t + * + * \details H5Sget_select_bounds() retrieves the coordinates of the bounding + * box containing the current selection and places them into + * user-supplied buffers. + * + * The \p start and \p end buffers must be large enough to hold + * the dataspace rank number of coordinates. + * + * The bounding box exactly contains the selection. I.e., if a + * 2-dimensional element selection is currently defined as containing + * the points (4,5), (6,8), and (10,7), then the bounding box + * will be (4, 5), (10, 8). + * + * The bounding box calculation includes the current offset of the + * selection within the dataspace extent. + * + * Calling this function on a \a none selection will fail. + * + * \version 1.6.0 The \p start and \p end parameters have changed from type + * \p hsize_t * to \p hssize_t *. + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]); +/** + * \ingroup H5S + * + * \brief Gets the number of element points in the current selection + * + * \space_id{spaceid} + * + * \return Returns the number of element points in the current dataspace + * selection if successful. Otherwise returns a negative value. + * + * \details H5Sget_select_elem_npoints() returns the number of element + * points in the current dataspace selection, so that the element + * points can be retrieved with H5Sget_select_elem_pointlist(). + * (This is similar to the way that H5Sget_select_hyper_nblocks() + * and H5Sget_select_hyper_blocklist() work with hyperslab + * selections.) + * + * Coincidentally, H5Sget_select_npoints() and + * H5Sget_select_elem_npoints() will always return the same value + * when an element selection is queried, but + * H5Sget_select_elem_npoints() does not work with other selection + * types. + * + * \since 1.2.0 + * + */ +H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Gets the list of element points currently selected + * + * \space_id{spaceid} + * \param[in] startpoint Element point to start with + * \param[in] numpoints Number of element points to get + * \param[out] buf List of element points selected + * + * \details H5Sget_select_elem_pointlist() returns the list of element + * points in the current dataspace selection \p space_id. Starting + * with the \p startpoint in the list of points, \p numpoints + * points are put into the user's buffer. If the user's buffer + * fills up before \p numpoints points are inserted, the buffer + * will contain only as many points as fit. + * + * The element point coordinates have the same dimensionality + * (rank) as the dataspace they are located within. The list of + * element points is formatted as follows:\n + * \, followed by\n + * the next coordinate,\n + * etc.\n + * until all of the selected element points have been listed. + * + * The points are returned in the order they will be iterated + * through when the selection is read/written from/to disk. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, + hsize_t buf[/*numpoints*/]); +/** + * \ingroup H5S + * + * \brief Gets the list of hyperslab blocks currently selected + * + * \space_id{spaceid} + * \param[in] startblock Hyperslab block to start with + * \param[in] numblocks Number of hyperslab blocks to get + * \param[out] buf List of hyperslab blocks selected + * + * \return \herr_t + * + * \details H5Sget_select_hyper_blocklist() returns a list of the hyperslab + * blocks currently selected. Starting with the \p startblock-th block + * in the list of blocks, \p numblocks blocks are put into the + * user's buffer. If the user's buffer fills up before \p numblocks + * blocks are inserted, the buffer will contain only as many blocks + * as fit. + * + * The block coordinates have the same dimensionality (rank) as the + * dataspace they are located within. The list of blocks is + * formatted as follows:\n + * \<"start" coordinate\>, immediately followed by\n + * \<"opposite" corner coordinate\>, followed by\n + * the next "start" and "opposite" coordinates,\n + * etc. until all of the selected blocks have been listed.\n + * No guarantee of any order of the blocks is implied. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, + hsize_t buf[/*numblocks*/]); +/** + * \ingroup H5S + * + * \brief Get number of hyperslab blocks + * + * \space_id{spaceid} + * + * \return Returns the number of hyperslab blocks in the current dataspace + * selection if successful. Otherwise returns a negative value. + * + * \details H5Sget_select_hyper_nblocks() returns the number of hyperslab + * blocks in the current dataspace selection. + * + * \since 1.2.0 + * + */ +H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Determines the number of elements in a dataspace selection + * + * \space_id{spaceid} + * + * \return Returns the number of elements in the selection if successful; + * otherwise returns a negative value. + * + * \details H5Sget_select_npoints() determines the number of elements in + * the current selection of a dataspace. It works with any + * selection type, and is the correct way to retrieve the number + * of elements in a selection. + * + * \version 1.4.0 Fortran subroutine introduced in this release. + * \since 1.0.0 + * + */ +H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Determines the type of the dataspace selection + * + * \space_id{spaceid} + * + * \return Returns the dataspace selection type, a value of the enumerated + * datatype #H5S_sel_type, if successful. + * + * \details H5Sget_select_type() retrieves the type of dataspace selection + * currently defined for the dataspace \p space_id. Valid values + * for the dataspace selection type are: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5S_SEL_NONENo selection is defined
#H5S_SEL_POINTSA sequence of points is selected
#H5S_SEL_HYPERSLABSA hyperslab or compound hyperslab is selected
#H5S_SEL_ALLThe entire dataset is selected
+ * + * Otherwise returns a negative value. + * + * \since 1.6.0 + * + */ +H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Retrieves dataspace dimension size and maximum size + * + * \space_id + * \param[out] dims Pointer to array to store the size of each dimension + * \param[out] maxdims Pointer to array to store the maximum size of each + * dimension + * + * \return Returns the number of dimensions in the dataspace if successful; + * otherwise returns a negative value. + * + * \details H5Sget_simple_extent_dims() returns the size and maximum sizes + * of each dimension of a dataspace \p space_id through the \p dims + * and \p maxdims parameters. + * + * Either or both of \p dims and \p maxdims may be NULL. + * + * If a value in the returned array \p maxdims is #H5S_UNLIMITED (-1), + * the maximum size of that dimension is unlimited. + * + * \version 1.4.0 Fortran subroutine introduced. + * \since 1.0.0 + * + */ +H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]); +/** + * \ingroup H5S + * + * \brief Determines the dimensionality of a dataspace + * + * \space_id + * + * \return Returns the number of dimensions in the dataspace if successful; + * otherwise returns a negative value. + * + * \details H5Sget_simple_extent_ndims() determines the dimensionality (or + * rank) of a dataspace. + * + * \version 1.4.0 Fortran subroutine introduced. + * \since 1.0.0 + * + */ H5_DLL int H5Sget_simple_extent_ndims(hid_t space_id); -H5_DLL int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], - hsize_t maxdims[]); -H5_DLL htri_t H5Sis_simple(hid_t space_id); +/** + * \ingroup H5S + * + * \brief Determines the number of elements in a dataspace + * + * \space_id + * + * \return Returns the number of elements in the dataspace if successful; + * otherwise returns a negative value. + * + * \details H5Sget_simple_extent_npoints() determines the number of elements + * in a dataspace \p space_id. For example, a simple 3-dimensional + * dataspace with dimensions 2, 3, and 4 would have 24 elements. + * + * \version 1.4.0 Fortran subroutine introduced. + * \since 1.0.0 + * + */ +H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); +/** + * \ingroup H5S + * + * \brief Determines the current class of a dataspace + * + * \space_id + * + * \return Returns a dataspace class name if successful; + * otherwise #H5S_NO_CLASS (-1). + * + * \details H5Sget_simple_extent_type() determines the current class of a + * dataspace \p space_id. + * + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.0.0 + * + */ H5_DLL H5S_class_t H5Sget_simple_extent_type(hid_t space_id); -H5_DLL herr_t H5Sset_extent_none(hid_t space_id); -H5_DLL herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id); -H5_DLL htri_t H5Sextent_equal(hid_t sid1, hid_t sid2); - -/* Operations on dataspace selections */ -H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid); -H5_DLL hssize_t H5Sget_select_npoints(hid_t spaceid); -H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); -H5_DLL htri_t H5Sselect_valid(hid_t spaceid); -H5_DLL herr_t H5Sselect_adjust(hid_t spaceid, const hssize_t *offset); -H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], - hsize_t end[]); -H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id); -H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, - const hsize_t *end); +/** + * \ingroup H5S + * + * \brief Determines if a hyperslab selection is regular + * + * \space_id{spaceid} + * + * \return \htri_t + * + * \details H5Sis_regular_hyperslab() takes the dataspace identifier, + * \p spaceid, and queries the type of the hyperslab selection. + * + * A regular hyperslab selection is a hyperslab selection described + * by setting the offset, stride, count, and block parameters for + * a single H5Sselect_hyperslab() call. If several calls to + * H5Sselect_hyperslab() are needed, then the hyperslab selection + * is irregular. + * + * \since 1.10.0 + * + */ +H5_DLL htri_t H5Sis_regular_hyperslab(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Determines whether a dataspace is a simple dataspace + * + * \space_id + * + * \return \htri_t + * + * \details H5Sis_simple() determines whether or not a dataspace is a simple + * dataspace. + * + * \note Currently, all dataspace objects are simple dataspaces; complex + * dataspace support will be added in the future. + * + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.0.0 + * + */ +H5_DLL htri_t H5Sis_simple(hid_t space_id); +/** + * \ingroup H5S + * + * \brief Refines a hyperslab selection with an operation, using a second + * hyperslab to modify it + * + * \space_id{space1_id} + * \param[in] op Selection operator + * \space_id{space2_id} + * + * \return \herr_t + * + * \details H5Smodify_select() refines an existing hyperslab selection + * \p space1_id with an operation \p op, using a second hyperslab + * \p space2_id. The first selection is modified to contain the + * result of \p space1_id operated on by \p space2_id. + * + * \since 1.10.6 + * + */ +H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); +/** + * \ingroup H5S + * + * \brief Sets the offset of a simple dataspace + * + * \space_id + * \param[in] offset The offset at which to position the selection + * + * \return \herr_t + * + * \details H5Soffset_simple() sets the offset of a simple dataspace + * \p space_id. The offset array must be the same number of + * elements as the number of dimensions for the dataspace. If the + * \p offset array is set to NULL, the offset for the dataspace is + * reset to 0. + * + * This function allows the same shaped selection to be moved to + * different locations within a dataspace without requiring it to + * be redefined. + * + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.0.0 + * + */ H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); +/** + * \ingroup H5S + * + * \brief Closes a dataspace selection iterator + * + * \space_id{sel_iter_id} + * + * \return \herr_t + * + * \details H5Ssel_iter_close() closes a dataspace selection iterator + * specified by \p sel_iter_id, releasing its state. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Ssel_iter_close(hid_t sel_iter_id); +/**\ingroup H5S + * + * \brief Creates a dataspace selection iterator for a dataspace's selection + * + * \space_id{spaceid} + * \param[in] elmt_size Size of element in the selection + * \param[in] flags Selection iterator flag + * + * \return \hid_t{valid dataspace selection iterator} + * + * \details H5Ssel_iter_create() creates a selection iterator and initializes + * it to start at the first element selected in the dataspace. + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5Ssel_iter_create(hid_t spaceid, size_t elmt_size, unsigned flags); +/** + * \ingroup H5S + * + * \brief Retrieves a list of offset / length sequences for the elements in + * an iterator + * + * \space_id{sel_iter_id} + * \param[in] maxseq Maximum number of sequences to retrieve + * \param[in] maxbytes Maximum number of bytes to retrieve in sequences + * \param[out] nseq Number of sequences retrieved + * \param[out] nbytes Number of bytes retrieved, in all sequences + * \param[out] off Array of sequence offsets + * \param[out] len Array of sequence lengths + * + * \return \herr_t + * + * \details H5Ssel_iter_get_seq_list() retrieves a list of offset / length + * pairs (a list of "sequences") matching the selected elements for + * an iterator \p sel_iter_id, according to the iteration order for + * the iterator. The lengths returned are in bytes, not elements. + * + * Note that the iteration order for "all" and "hyperslab" + * selections is row-major (i.e. "C-ordered"), but the iteration + * order for "point" selections is "in order selected", unless the + * #H5S_SEL_ITER_GET_SEQ_LIST_SORTED flag is passed to + * H5Ssel_iter_create() for a point selection. + * + * \p maxseq and \p maxbytes specify the most sequences or bytes + * possible to place into the \p off and \p len arrays. \p nseq and + * \p nbytes return the actual number of sequences and bytes put + * into the arrays. + * + * Each call to H5Ssel_iter_get_seq_list() will retrieve the next + * set of sequences for the selection being iterated over. + * + * The total number of bytes possible to retrieve from a selection + * iterator is the \p elmt_size passed to H5Ssel_iter_create() + * multiplied by the number of elements selected in the dataspace + * the iterator was created from (which can be retrieved with + * H5Sget_select_npoints(). When there are no further sequences of + * elements to retrieve, calls to this routine will set \p nseq + * and \p nbytes to zero. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes, size_t *nseq, + size_t *nbytes, hsize_t *off, size_t *len); +/** + * \ingroup H5S + * + * \brief Resets a dataspace selection iterator back to an initial state + * + * \param[in] sel_iter_id Identifier of the dataspace selection iterator + * to reset + * \param[in] space_id Identifier of the dataspace with selection to + * iterate over + * + * \return \herr_t + * + * \details H5Ssel_iter_reset() resets a dataspace selection iterator back to + * an initial state so that the iterator may be used for iteration + * once again. + * + * \since 1.12.1 + * + */ +H5_DLL herr_t H5Ssel_iter_reset(hid_t sel_iter_id, hid_t space_id); +/** + * \ingroup H5S + * + * \brief Adjusts a selection by subtracting an offset + * + * \space_id{spaceid} + * \param[in] offset Offset to subtract + * + * \return \herr_t + * + * \details H5Sselect_adjust() shifts a dataspace selection by a specified + * logical offset within the dataspace extent. + * + * \note This can be useful for VOL developers to implement chunked datasets. + * + * \since 1.10.6 + */ +H5_DLL herr_t H5Sselect_adjust(hid_t spaceid, const hssize_t *offset); +/** + * \ingroup H5S + * + * \brief Selects an entire dataspace + * + * \space_id{spaceid} + * + * \return \herr_t + * + * \details H5Sselect_all() selects the entire extent of the dataspace + * \p dspace_id. + * + * More specifically, H5Sselect_all() sets the selection type to + * #H5S_SEL_ALL, which specifies the entire dataspace anywhere it + * is applied. + * + * \since 1.0.0 + * + */ H5_DLL herr_t H5Sselect_all(hid_t spaceid); +/** + * \ingroup H5S + * + * \brief Copies a selection from one dataspace to another + * + * \space_id{dst_id} + * \space_id{src_id} + * + * \return \herr_t + * + * \details H5Sselect_copy() copies all selection information (including + * offset) from the source dataspace \p src_id to the destination + * dataspace \p dst_id. + * + * \since 1.10.6 + * + */ +H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); +/** + * \ingroup H5S + * + * \brief Selects array elements to be included in the selection for a + * dataspace + * + * \space_id + * \param[in] op Operator specifying how the new selection is to be + * combined with the existing selection for the dataspace + * \param[in] num_elem Number of elements to be selected + * \param[in] coord A pointer to a buffer containing a serialized copy of + * a 2-dimensional array of zero-based values specifying + * the coordinates of the elements in the point selection + * + * \return \herr_t + * + * \details H5Sselect_elements() selects array elements to be included in + * the selection for the \p space_id dataspace. This is referred + * to as a point selection. + * + * The number of elements selected is set in the \p num_elements + * parameter. + * + * The \p coord parameter is a pointer to a buffer containing a + * serialized 2-dimensional array of size \p num_elements by the + * rank of the dataspace. The array lists dataset elements in the + * point selection; that is, it’s a list of of zero-based values + * specifying the coordinates in the dataset of the selected + * elements. The order of the element coordinates in the \p coord + * array specifies the order in which the array elements are + * iterated through when I/O is performed. Duplicate coordinate + * locations are not checked for. See below for examples of the + * mapping between the serialized contents of the buffer and the + * point selection array that it represents. + * + * The selection operator \p op determines how the new selection + * is to be combined with the previously existing selection for + * the dataspace. The following operators are supported: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5S_SELECT_SETReplaces the existing selection with the parameters from + * this call. Overlapping blocks are not supported with this + * operator. Adds the new selection to the existing selection. + *
#H5S_SELECT_APPENDAdds the new selection following the last element of the + * existing selection.
#H5S_SELECT_PREPENDAdds the new selection preceding the first element of the + * existing selection.
+ * + * Mapping the serialized \p coord buffer to a 2-dimensional + * point selection array: + * To illustrate the construction of the contents of the \p coord + * buffer, consider two simple examples: a selection of 5 points in + * a 1-dimensional array and a selection of 3 points in a + * 4-dimensional array. + * + * In the 1D case, we will be selecting five points and a 1D + * dataspace has rank 1, so the selection will be described in a + * 5-by-1 array. To select the 1st, 14th, 17th, 23rd, 8th elements + * of the dataset, the selection array would be as follows + * (remembering that point coordinates are zero-based): + * \n 0 + * \n 13 + * \n 16 + * \n 22 + * \n 7 + * + * This point selection array will be serialized in the \p coord + * buffer as: + * \n 0 13 16 22 7 + * + * In the 4D case, we will be selecting three points and a 4D + * dataspace has rank 4, so the selection will be described in a + * 3-by-4 array. To select the points (1,1,1,1), (14,6,12,18), and + * (8,22,30,22), the point selection array would be as follows: + * \n 0 0 0 0 + * \n 13 5 11 17 + * \n 7 21 29 21 + * + * This point selection array will be serialized in the \p coord + * buffer as: + * \n 0 0 0 0 13 5 11 17 7 21 29 21 + * + * \version 1.6.4 C coord parameter type changed to \p const hsize_t. + * \version 1.6.4 Fortran \p coord parameter type changed to \p INTEGER(HSIZE_T). + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, size_t num_elem, const hsize_t *coord); +/** + * \ingroup H5S + * + * \brief Selects a hyperslab region to add to the current selected region + * + * \space_id + * \param[in] op Operation to perform on current selection + * \param[in] start Offset of start of hyperslab + * \param[in] stride Hyperslab stride + * \param[in] count Number of blocks included in hyperslab + * \param[in] block Size of block in hyperslab + * + * \return \herr_t + * + * \details H5Sselect_hyperslab() selects a hyperslab region to add to the + * current selected region for the dataspace specified by + * \p space_id. + * + * The \p start, \p stride, \p count, and \p block arrays must be the + * same size as the rank of the dataspace. For example, if the + * dataspace is 4-dimensional, each of these parameters must be a + * 1-dimensional array of size 4. + * + * The selection operator \p op determines how the new selection + * is to be combined with the already existing selection for the + * dataspace. The following operators are supported: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#H5S_SELECT_SETReplaces the existing selection with the + * parameters from this call. Overlapping blocks + * are not supported with this operator.
#H5S_SELECT_ORAdds the new selection to the existing selection. + * (Binary OR)
#H5S_SELECT_ANDRetains only the overlapping portions of the + * new selection and the existing selection. + * (Binary AND)
#H5S_SELECT_XORRetains only the elements that are members of + * the new selection or the existing selection, + * excluding elements that are members of both + * selections. (Binary exclusive-OR, XOR) + *
#H5S_SELECT_NOTBRetains only elements of the existing selection + * that are not in the new selection.
#H5S_SELECT_NOTARetains only elements of the new selection that + * are not in the existing selection.
+ * + * The \p start array specifies the offset of the starting element + * of the specified hyperslab. + * + * The \p stride array chooses array locations from the dataspace with + * each value in the \p stride array determining how many elements to + * move in each dimension. Setting a value in the \p stride array to + * \p 1 moves to each element in that dimension of the dataspace; + * setting a value of \p 2 in allocation in the \p stride array moves + * to every other element in that dimension of the dataspace. In + * other words, the \p stride determines the number of elements to + * move from the \p start location in each dimension. Stride values + * of \p 0 are not allowed. If the \p stride parameter is NULL, a + * contiguous hyperslab is selected (as if each value in the \p stride + * array were set to \p 1). + * + * The \p count array determines how many blocks to select from the + * dataspace, in each dimension. + * + * The \p block array determines the size of the element block + * selected from the dataspace. If the \p block parameter is set to + * NULL, the block size defaults to a single element in each dimension + * (as if each value in the \p block array were set to \p 1). + * + * For example, consider a 2-dimensional dataspace with hyperslab + * selection settings as follows: the \p start offset is specified as + * [1,1], \p stride is [4,4], \p count is [3,7], and \p block is [2,2]. + * In C, these settings will specify a hyperslab consisting of 21 + * 2x2 blocks of array elements starting with location (1,1) with the + * selected blocks at locations (1,1), (5,1), (9,1), (1,5), (5,5), etc.; + * in Fortran, they will specify a hyperslab consisting of 21 2x2 + * blocks of array elements starting with location (2,2) with the + * selected blocks at locations (2,2), (6,2), (10,2), (2,6), (6,6), etc. + * + * Regions selected with this function call default to C order + * iteration when I/O is performed. + * + * \version 1.4.0 Fortran subroutine introduced in this release. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], + const hsize_t stride[], const hsize_t count[], const hsize_t block[]); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Checks if current selection intersects with a block + * + * \space_id + * \param[in] start Starting coordinate of block + * \param[in] end Opposite ("ending") coordinate of block + * + * \return \htri_t + * + * \details H5Sselect_intersect_block() checks to see if the current + * selection \p space_id in the dataspace intersects with the block + * specified by \p start and \p end. + * + * \note Assumes that \p start & \p end block bounds are inclusive, so + * \p start == \p end value is OK. + * + * \since 1.10.6 + * + */ +H5_DLL htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Resets the selection region to include no elements + * + * \space_id{spaceid} + * + * \return \herr_t + * + * \details H5Sselect_none() resets the selection region for the dataspace + * \p space_id to include no elements. + * + * \since 1.0.0 + * + */ H5_DLL herr_t H5Sselect_none(hid_t spaceid); -H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, - size_t num_elem, const hsize_t *coord); -H5_DLL hssize_t H5Sget_select_elem_npoints(hid_t spaceid); -H5_DLL herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, - hsize_t numpoints, hsize_t buf[/*numpoints*/]); -H5_DLL herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, - const hsize_t start[], const hsize_t _stride[], const hsize_t count[], - const hsize_t _block[]); -H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, - const hsize_t start[], const hsize_t _stride[], const hsize_t count[], - const hsize_t _block[]); -H5_DLL herr_t H5Smodify_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); -H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id); -H5_DLL htri_t H5Sis_regular_hyperslab(hid_t spaceid); -H5_DLL htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], - hsize_t stride[], hsize_t count[], hsize_t block[]); -H5_DLL hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid); -H5_DLL herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, - hsize_t numblocks, hsize_t buf[/*numblocks*/]); -H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, - hid_t dst_space_id, hid_t src_intersect_space_id); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Projects the intersection of two source selections to a + * destination selection + * + * \space_id{src_space_id} + * \space_id{dst_space_id} + * \space_id{src_intersect_space_id} + * + * \return Returns a dataspace with a selection equal to the intersection of + * \p src_intersect_space_id and \p src_space_id projected from + * \p src_space to \p dst_space on success, negative on failure. + * + * \details H5Sselect_project_intersection() computes the intersection + * between two dataspace selections and projects that intersection + * into a third selection.This can be useful for VOL developers to + * implement chunked or virtual datasets. + * + * \since 1.10.6 + * + */ +H5_DLL hid_t H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, + hid_t src_intersect_space_id); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Checks if two selections are the same shape + * + * \space_id{space1_id} + * \space_id{space2_id} + * + * \return \htri_t + * + * \details H5Sselect_shape_same() checks to see if the current selection + * in the dataspaces are the same dimensionality and shape. + * + * This is primarily used for reading the entire selection in + * one swoop. + * + * \since 1.10.6 + * + */ +H5_DLL htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Verifies that the selection is within the extent of the dataspace + * + * \space_id{spaceid} + * + * \return \htri_t + * + * \details H5Sselect_valid() verifies that the selection for the dataspace + * \p space_id is within the extent of the dataspace if the current + * offset for the dataspace is used. + * + * \version 1.4.0 Fortran subroutine introduced in this release. + * \since 1.0.0 + * + */ +H5_DLL htri_t H5Sselect_valid(hid_t spaceid); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Resets the extent of a dataspace back to "none" + * + * \space_id + * + * \return \herr_t + * + * \details H5Sset_extent_none() resets the type of a dataspace to + * #H5S_NULL with no extent information stored for the dataspace. + * + * \version 1.10.7, 1.12.1 The function behavior changed. The previous + * behavior was to set the class to #H5S_NO_CLASS. + * \version 1.4.0 Fortran subroutine was introduced. + * \since 1.0.0 + * + */ +H5_DLL herr_t H5Sset_extent_none(hid_t space_id); +/*--------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Sets or resets the size of an existing dataspace + * + * \space_id + * \param[in] rank Rank, or dimensionality, of the dataspace + * \param[in] dims Array containing current size of dataspace + * \param[in] max Array containing maximum size of dataspace + * + * \return \herr_t + * + * \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 + * the dataspace. + * + * 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 + * + */ +H5_DLL herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[], const hsize_t max[]); + +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +/* Function prototypes */ +/* --------------------------------------------------------------------------*/ +/**\ingroup H5S + * + * \brief Encodes a data space object description into a binary buffer + * + * \space_id{obj_id} + * \param[in,out] buf Buffer for the object to be encoded into; + * If the provided buffer is NULL, only the size of + * buffer needed is returned through \p nalloc. + * \param[in,out] nalloc The size of the allocated buffer + * + * \return \herr_t + * + * \deprecated Deprecated in favor of H5Sencode2() + * + * \details Given the data space identifier \p obj_id, H5Sencode1() converts + * a data space description into binary form in a buffer. Using + * this binary form in the buffer, a data space object can be + * reconstructed using H5Sdecode() to return a new object handle + * (\p hid_t) for this data space. + * + * A preliminary H5Sencode1() call can be made to find out the size + * of the buffer needed. This value is returned as \p nalloc. That + * value can then be assigned to \p nalloc for a second H5Sencode1() + * call, which will retrieve the actual encoded object. + * + * If the library finds out \p nalloc is not big enough for the + * object, it simply returns the size of the buffer needed through + * \p nalloc without encoding the provided buffer. + * + * The types of data space addressed in this function are null, + * scalar, and simple space. For a simple data space, the information + * on the selection, for example, hyperslab selection, is also + * encoded and decoded. A complex data space has not been + * implemented in the library. + * + * \version 1.12.0 The function H5Sencode() was renamed H5Sencode1() and + * deprecated. + * \since 1.8.0 + * + */ +H5_DLL herr_t H5Sencode1(hid_t obj_id, void *buf, size_t *nalloc); + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef __cplusplus } #endif -#endif /* _H5Spublic_H */ - +#endif /* H5Spublic_H */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index d1e004e785e..86e9043b8f1 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,52 +21,45 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Spkg.h" /* Dataspaces */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ /****************/ /* All the valid public flags to H5Ssel_iter_create() */ -#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | \ - H5S_SEL_ITER_SHARE_WITH_DATASPACE) - +#define H5S_SEL_ITER_ALL_PUBLIC_FLAGS (H5S_SEL_ITER_GET_SEQ_LIST_SORTED | H5S_SEL_ITER_SHARE_WITH_DATASPACE) /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ #ifdef LATER -static herr_t H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); -static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter); +static herr_t H5S__select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +static htri_t H5S__select_iter_has_next_block(const H5S_sel_iter_t *iter); +static herr_t H5S__select_iter_next_block(H5S_sel_iter_t *iter); #endif /* LATER */ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ @@ -80,13 +73,10 @@ H5FL_SEQ_EXTERN(size_t); /* Declare extern free list to manage sequences of hsize_t */ H5FL_SEQ_EXTERN(hsize_t); - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5S_select_offset @@ -125,7 +115,6 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S_select_offset() */ - /*-------------------------------------------------------------------------- NAME H5Soffset_simple @@ -138,37 +127,36 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function creates an offset for the selection within an extent, allowing + This function creates an offset for the selection within an extent, allowing the same shaped selection to be moved to different locations within a dataspace without requiring it to be re-defined. --------------------------------------------------------------------------*/ herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset) { - H5S_t *space; /* Dataspace to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Hs", space_id, offset); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") - if(space->extent.rank == 0 || (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR - || H5S_GET_EXTENT_TYPE(space) == H5S_NULL)) + if (space->extent.rank == 0 || + (H5S_GET_EXTENT_TYPE(space) == H5S_SCALAR || H5S_GET_EXTENT_TYPE(space) == H5S_NULL)) HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") - if(offset == NULL) + if (offset == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified") /* Set the selection offset */ - if(H5S_select_offset(space, offset) < 0) + if (H5S_select_offset(space, offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset") done: FUNC_LEAVE_API(ret_value) } /* end H5Soffset_simple() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_copy @@ -193,28 +181,27 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id) { - H5S_t *src; - H5S_t *dst; - herr_t ret_value = SUCCEED; + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); /* Check args */ - if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) + if (NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) + if (NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Copy */ - if(H5S_select_copy(dst, src, FALSE) < 0) + if (H5S_select_copy(dst, src, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_copy() */ - /*-------------------------------------------------------------------------- NAME H5S_select_copy @@ -243,7 +230,7 @@ H5Sselect_copy(hid_t dst_id, hid_t src_id) herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -252,21 +239,20 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(src); /* Release the current selection */ - if(H5S_SELECT_RELEASE(dst) < 0) + if (H5S_SELECT_RELEASE(dst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") /* Copy regular fields */ dst->select = src->select; /* Perform correct type of copy based on the type of selection */ - if((ret_value = (*src->select.type->copy)(dst, src, share_selection)) < 0) + if ((ret_value = (*src->select.type->copy)(dst, src, share_selection)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_copy() */ - /*------------------------------------------------------------------------- * Function: H5S_select_release * @@ -286,21 +272,20 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) herr_t H5S_select_release(H5S_t *ds) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(ds); /* Call the selection type's release function */ - if((ds->select.type) && ((ret_value = (*ds->select.type->release)(ds)) < 0)) + if ((ds->select.type) && ((ret_value = (*ds->select.type->release)(ds)) < 0)) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_release() */ - /*------------------------------------------------------------------------- * Function: H5S_select_serial_size * @@ -321,7 +306,7 @@ H5S_select_release(H5S_t *ds) hssize_t H5S_select_serial_size(const H5S_t *space) { - hssize_t ret_value = -1; /* Return value */ + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -333,7 +318,6 @@ H5S_select_serial_size(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_serial_size() */ - /*-------------------------------------------------------------------------- NAME H5S_select_serialize @@ -361,7 +345,7 @@ H5S_select_serial_size(const H5S_t *space) herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -374,7 +358,6 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_serialize() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_npoints @@ -395,14 +378,14 @@ 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 */ - hssize_t ret_value; /* return value */ + H5S_t * space; /* Dataspace to modify selection of */ + hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = (hssize_t)H5S_GET_SELECT_NPOINTS(space); @@ -411,7 +394,6 @@ H5Sget_select_npoints(hid_t spaceid) FUNC_LEAVE_API(ret_value) } /* H5Sget_select_npoints() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_npoints @@ -443,7 +425,6 @@ H5S_get_select_npoints(const H5S_t *space) FUNC_LEAVE_NOAPI(space->select.num_elem) } /* end H5S_get_select_npoints() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_valid @@ -467,14 +448,14 @@ H5S_get_select_npoints(const H5S_t *space) htri_t H5Sselect_valid(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ - htri_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + htri_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", spaceid); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = H5S_SELECT_VALID(space); @@ -483,7 +464,6 @@ H5Sselect_valid(hid_t spaceid) FUNC_LEAVE_API(ret_value) } /* end H5Sselect_valid() */ - /*-------------------------------------------------------------------------- NAME H5S_select_valid @@ -510,7 +490,7 @@ H5Sselect_valid(hid_t spaceid) htri_t H5S_select_valid(const H5S_t *space) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -521,7 +501,6 @@ H5S_select_valid(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_valid() */ - /*-------------------------------------------------------------------------- NAME H5S_select_deserialize @@ -551,8 +530,8 @@ H5S_select_valid(const H5S_t *space) herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p) { - 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -564,20 +543,20 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) UINT32DECODE(*p, sel_type); /* Make routine for selection type */ - switch(sel_type) { - case H5S_SEL_POINTS: /* Sequence of points selected */ + switch (sel_type) { + case H5S_SEL_POINTS: /* Sequence of points selected */ ret_value = (*H5S_sel_point->deserialize)(space, p); break; - case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ + case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ ret_value = (*H5S_sel_hyper->deserialize)(space, p); break; - case H5S_SEL_ALL: /* Entire extent selected */ + case H5S_SEL_ALL: /* Entire extent selected */ ret_value = (*H5S_sel_all->deserialize)(space, p); break; - case H5S_SEL_NONE: /* Nothing selected */ + case H5S_SEL_NONE: /* Nothing selected */ ret_value = (*H5S_sel_none->deserialize)(space, p); break; @@ -585,14 +564,13 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) break; } - if(ret_value < 0) + if (ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_deserialize() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_bounds @@ -626,16 +604,16 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) { - H5S_t *space; /* Dataspace to modify selection of */ - herr_t ret_value; /* return value */ + H5S_t *space; /* Dataspace to modify selection of */ + herr_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", spaceid, start, end); /* Check args */ - if(start == NULL || end == NULL) + if (start == NULL || end == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer") - if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") ret_value = H5S_SELECT_BOUNDS(space, start, end); @@ -644,7 +622,6 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_bounds @@ -675,7 +652,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -689,7 +666,6 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_bounds() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_offset @@ -716,7 +692,7 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -729,7 +705,6 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_offset() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_unlim_dim @@ -755,7 +730,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) int H5S_get_select_unlim_dim(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -767,7 +742,6 @@ H5S_get_select_unlim_dim(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_num_elem_non_unlim @@ -789,8 +763,7 @@ H5S_get_select_unlim_dim(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_get_select_num_elem_non_unlim(const H5S_t *space, - hsize_t *num_elem_non_unlim) +H5S_get_select_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim) { herr_t ret_value = SUCCEED; /* return value */ @@ -801,18 +774,18 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space, HDassert(num_elem_non_unlim); /* Check for selection callback */ - if(!space->select.type->num_elem_non_unlim) + if (!space->select.type->num_elem_non_unlim) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "selection type has no num_elem_non_unlim callback") /* Make selection callback */ - if((*space->select.type->num_elem_non_unlim)(space, num_elem_non_unlim) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements in non-unlimited dimension") + if ((*space->select.type->num_elem_non_unlim)(space, num_elem_non_unlim) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, + "can't get number of elements in non-unlimited dimension") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_unlim_dim() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_contiguous @@ -837,7 +810,7 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space, htri_t H5S_select_is_contiguous(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -849,7 +822,6 @@ H5S_select_is_contiguous(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_contiguous() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_single @@ -874,7 +846,7 @@ H5S_select_is_contiguous(const H5S_t *space) htri_t H5S_select_is_single(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -886,7 +858,6 @@ H5S_select_is_single(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_single() */ - /*-------------------------------------------------------------------------- NAME H5S_select_is_regular @@ -911,7 +882,7 @@ H5S_select_is_single(const H5S_t *space) htri_t H5S_select_is_regular(const H5S_t *space) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -923,7 +894,6 @@ H5S_select_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_is_regular() */ - /*-------------------------------------------------------------------------- NAME H5S_select_adjust_u @@ -948,7 +918,7 @@ H5S_select_is_regular(const H5S_t *space) herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -962,7 +932,6 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_adjust_u() */ - /*-------------------------------------------------------------------------- NAME H5S_select_adjust_s @@ -987,7 +956,7 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1001,7 +970,6 @@ H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_adjust_s() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_adjust @@ -1023,35 +991,34 @@ 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; - hsize_t low_bounds[H5S_MAX_RANK]; - hsize_t high_bounds[H5S_MAX_RANK]; + H5S_t * space; + hsize_t low_bounds[H5S_MAX_RANK]; + hsize_t high_bounds[H5S_MAX_RANK]; unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Hs", space_id, offset); - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == offset) + if (NULL == offset) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "NULL offset pointer") /* Check bounds */ - if(H5S_SELECT_BOUNDS(space, low_bounds, high_bounds) < 0) + if (H5S_SELECT_BOUNDS(space, low_bounds, high_bounds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") - for(u = 0; u < space->extent.rank; u++) - if(offset[u] > (hssize_t)low_bounds[u]) + for (u = 0; u < space->extent.rank; u++) + if (offset[u] > (hssize_t)low_bounds[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjustment would move selection below zero offset") - if(H5S_select_adjust_s(space, offset) < 0) + if (H5S_select_adjust_s(space, offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't adjust selection") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_adjust() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_scalar @@ -1077,7 +1044,7 @@ H5Sselect_adjust(hid_t space_id, const hssize_t *offset) herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1090,7 +1057,6 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_scalar() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_simple @@ -1117,7 +1083,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1131,7 +1097,6 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_simple() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_init @@ -1151,10 +1116,9 @@ 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, const H5S_t *space, size_t elmt_size, unsigned flags) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1168,7 +1132,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, sel_iter->rank = space->extent.rank; /* If dims > 0, copy the dataspace dimensions & selection offset */ - if(sel_iter->rank > 0) { + if (sel_iter->rank > 0) { H5MM_memcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank); H5MM_memcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank); } @@ -1189,7 +1153,6 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_init() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_coords @@ -1215,7 +1178,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1230,14 +1193,14 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) } /* end H5S_select_iter_coords() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME - H5S_select_iter_block + H5S__select_iter_block PURPOSE Get the block of the current iterator position USAGE - herr_t H5S_select_iter_block(sel_iter,start,end) + herr_t H5S__select_iter_block(sel_iter,start,end) const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query hsize_t *start; OUT: Array to place iterator start block coordinates hsize_t *end; OUT: Array to place iterator end block coordinates @@ -1255,11 +1218,11 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) +H5S__select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); @@ -1270,10 +1233,9 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) ret_value = (*iter->type->iter_block)(iter, start, end); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_iter_block() */ +} /* end H5S__select_iter_block() */ #endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_nelmts @@ -1297,7 +1259,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) { - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1311,14 +1273,14 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) } /* end H5S_select_iter_nelmts() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME - H5S_select_iter_has_next_block + H5S__select_iter_has_next_block PURPOSE Check if there is another block available in the selection iterator USAGE - htri_t H5S_select_iter_has_next_block(sel_iter) + htri_t H5S__select_iter_has_next_block(sel_iter) const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query RETURNS Non-negative on success, negative on failure. @@ -1334,11 +1296,11 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) +H5S__select_iter_has_next_block(const H5S_sel_iter_t *iter) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); @@ -1347,10 +1309,9 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) ret_value = (*iter->type->iter_has_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_iter_has_next_block() */ +} /* end H5S__select_iter_has_next_block() */ #endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_next @@ -1376,32 +1337,32 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) herr_t H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); - HDassert(nelem>0); + HDassert(nelem > 0); /* Call iter_next routine for selection type */ ret_value = (*iter->type->iter_next)(iter, nelem); /* Decrement the number of elements left in selection */ - iter->elmt_left-=nelem; + iter->elmt_left -= nelem; FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_next() */ #ifdef LATER - + /*-------------------------------------------------------------------------- NAME - H5S_select_iter_next_block + H5S__select_iter_next_block PURPOSE Advance selection iterator to next block USAGE - herr_t H5S_select_iter_next_block(iter) + herr_t H5S__select_iter_next_block(iter) H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change RETURNS Non-negative on success, negative on failure. @@ -1419,11 +1380,11 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_select_iter_next_block(H5S_sel_iter_t *iter) +H5S__select_iter_next_block(H5S_sel_iter_t *iter) { - herr_t ret_value; /* return value */ + herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); @@ -1432,10 +1393,9 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) ret_value = (*iter->type->iter_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_iter_next_block() */ +} /* end H5S__select_iter_next_block() */ #endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5S_select_iter_get_seq_list * @@ -1454,10 +1414,10 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) *------------------------------------------------------------------------- */ herr_t -H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts, - size_t *nseq, size_t *nelmts, hsize_t *off, size_t *len) +H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmts, size_t *nseq, + size_t *nelmts, hsize_t *off, size_t *len) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1465,14 +1425,13 @@ H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmt HDassert(iter); /* Call the selection type's get_seq_list function */ - if((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0) + if ((ret_value = (*iter->type->iter_get_seq_list)(iter, maxseq, maxelmts, nseq, nelmts, off, len)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_get_seq_list() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_release @@ -1496,7 +1455,7 @@ H5S_select_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelmt herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1509,7 +1468,6 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_release() */ - /*-------------------------------------------------------------------------- NAME H5S_select_iterate @@ -1539,20 +1497,20 @@ 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, const 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 */ - 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 */ - size_t elmt_size; /* Datatype size */ - unsigned ndims; /* Number of dimensions in dataspace */ - herr_t user_ret = 0; /* User's return value */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + 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 */ + size_t elmt_size; /* Datatype size */ + unsigned ndims; /* Number of dimensions in dataspace */ + herr_t user_ret = 0; /* User's return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1563,29 +1521,29 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, HDassert(op); /* Get the datatype size */ - if(0 == (elmt_size = H5T_get_size(type))) + if (0 == (elmt_size = H5T_get_size(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator */ - if(H5S_select_iter_init(iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Get the rank of the dataspace */ ndims = space->extent.rank; - if(ndims > 0) { - /* Copy the size of the space */ - HDassert(space->extent.size); - H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t)); + if (ndims > 0) { + /* Copy the size of the space */ + HDassert(space->extent.size); + H5MM_memcpy(space_size, space->extent.size, ndims * sizeof(hsize_t)); } /* end if */ space_size[ndims] = elmt_size; @@ -1593,25 +1551,26 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t); /* Allocate the offset & length arrays */ - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array") /* Loop, while elements left in selection */ - while(max_elem > 0 && user_ret == 0) { - 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 */ + while (max_elem > 0 && user_ret == 0) { + 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(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Loop, while sequences left to process */ - for(curr_seq = 0; curr_seq < nseq && user_ret == 0; curr_seq++) { - hsize_t curr_off; /* Current offset within sequence */ - size_t curr_len; /* Length of bytes left to process in sequence */ + for (curr_seq = 0; curr_seq < nseq && user_ret == 0; curr_seq++) { + hsize_t curr_off; /* Current offset within sequence */ + size_t curr_len; /* Length of bytes left to process in sequence */ /* Get the current offset */ curr_off = off[curr_seq]; @@ -1620,14 +1579,14 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, curr_len = len[curr_seq]; /* Loop, while bytes left in sequence */ - while(curr_len > 0 && user_ret == 0) { - hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */ - hsize_t tmp_off; /* Temporary offset within sequence */ - uint8_t *loc; /* Current element location in buffer */ - int i; /* Local Index variable */ + while (curr_len > 0 && user_ret == 0) { + hsize_t coords[H5S_MAX_RANK]; /* Coordinates of element in dataspace */ + hsize_t tmp_off; /* Temporary offset within sequence */ + uint8_t *loc; /* Current element location in buffer */ + int i; /* Local Index variable */ /* Compute the coordinate from the offset */ - for(i = (int)ndims, tmp_off = curr_off; i >= 0; i--) { + for (i = (int)ndims, tmp_off = curr_off; i >= 0; i--) { coords[i] = tmp_off % space_size[i]; tmp_off /= space_size[i]; } /* end for */ @@ -1636,23 +1595,23 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, loc = (unsigned char *)buf + curr_off; /* Check which type of callback to make */ - switch(op->op_type) { + switch (op->op_type) { case H5S_SEL_ITER_OP_APP: /* Make the application callback */ user_ret = (op->u.app_op.op)(loc, op->u.app_op.type_id, ndims, coords, op_data); - break; + break; case H5S_SEL_ITER_OP_LIB: /* Call the library's callback */ user_ret = (op->u.lib_op)(loc, type, ndims, coords, op_data); - break; + break; default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unsupported op type") } /* end switch */ /* Check for error return from iterator */ - if(user_ret < 0) + if (user_ret < 0) HERROR(H5E_DATASPACE, H5E_CANTNEXT, "iteration operator failed"); /* Increment offset in dataspace */ @@ -1661,7 +1620,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, /* Decrement number of bytes left in sequence */ curr_len -= elmt_size; } /* end while */ - } /* end for */ + } /* end for */ /* Decrement number of elements left to process */ max_elem -= nelem; @@ -1672,21 +1631,20 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iterate() */ - /*-------------------------------------------------------------------------- NAME H5Sget_select_type @@ -1699,20 +1657,20 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION - This function retrieves the type of selection currently defined for + This function retrieves the type of selection currently defined for a dataspace. --------------------------------------------------------------------------*/ H5S_sel_type H5Sget_select_type(hid_t space_id) { - H5S_t *space; /* dataspace to modify */ - H5S_sel_type ret_value; /* Return value */ + H5S_t * space; /* dataspace to modify */ + H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_API(H5S_SEL_ERROR) H5TRACE1("St", "i", space_id); /* Check args */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a dataspace") /* Set return value */ @@ -1722,7 +1680,6 @@ H5Sget_select_type(hid_t space_id) FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_type() */ - /*-------------------------------------------------------------------------- NAME H5S_get_select_type @@ -1735,7 +1692,7 @@ H5Sget_select_type(hid_t space_id) Non-negative on success/Negative on failure. Return value is from the set of values in the H5S_sel_type enumerated type. DESCRIPTION - This function retrieves the type of selection currently defined for + This function retrieves the type of selection currently defined for a dataspace. COMMENTS This routine participates in the "Inlining C function pointers" @@ -1745,7 +1702,7 @@ H5Sget_select_type(hid_t space_id) H5_ATTR_PURE H5S_sel_type H5S_get_select_type(const H5S_t *space) { - H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ + H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1758,7 +1715,6 @@ H5S_get_select_type(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_select_type() */ - /*-------------------------------------------------------------------------- NAME H5S_select_shape_same @@ -1785,11 +1741,11 @@ H5S_get_select_type(const H5S_t *space) htri_t H5S_select_shape_same(const H5S_t *space1, const 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 */ - hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ - hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ - htri_t ret_value = TRUE; /* Return value */ + H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ + H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ + hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ + hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1798,20 +1754,20 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) HDassert(space2); /* Check for different number of elements selected */ - if(H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) + if (H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) HGOTO_DONE(FALSE) /* 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 */ - 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 */ - int space_b_dim; /* Current dimension in dataspace B */ - H5S_sel_type sel_a_type; /* Selection type for dataspace A */ - H5S_sel_type sel_b_type; /* Selection type for dataspace B */ + 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 */ + 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 */ + int space_b_dim; /* Current dimension in dataspace B */ + H5S_sel_type sel_a_type; /* Selection type for dataspace A */ + H5S_sel_type sel_b_type; /* Selection type for dataspace B */ /* Need to be able to handle spaces of different rank: * @@ -1827,7 +1783,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) * * Set all this up here. */ - if(space1->extent.rank >= space2->extent.rank) { + if (space1->extent.rank >= space2->extent.rank) { space_a = space1; space_b = space2; } /* end if */ @@ -1845,29 +1801,30 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) sel_b_type = H5S_GET_SELECT_TYPE(space_b); /* If selections aren't "none", compare their bounds */ - if(sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) { - hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */ - hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */ - hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */ - hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */ + if (sel_a_type != H5S_SEL_NONE && sel_b_type != H5S_SEL_NONE) { + hsize_t low_a[H5S_MAX_RANK]; /* Low bound of selection in dataspace a */ + hsize_t low_b[H5S_MAX_RANK]; /* Low bound of selection in dataspace b */ + hsize_t high_a[H5S_MAX_RANK]; /* High bound of selection in dataspace a */ + hsize_t high_b[H5S_MAX_RANK]; /* High bound of selection in dataspace b */ /* Get low & high bounds for both dataspaces */ - if(H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for first dataspace") - if(H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for second dataspace") + if (H5S_SELECT_BOUNDS(space_a, low_a, high_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get selection bounds for first dataspace") + if (H5S_SELECT_BOUNDS(space_b, low_b, high_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get selection bounds for second dataspace") /* Check that the range between the low & high bounds are the same */ space_a_dim = (int)space_a_rank - 1; space_b_dim = (int)space_b_rank - 1; - while(space_b_dim >= 0) { + while (space_b_dim >= 0) { /* Sanity check */ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]); HDassert(low_a[space_b_dim] <= high_a[space_b_dim]); /* Verify that the ranges are the same */ - if((high_a[space_a_dim] - low_a[space_a_dim]) - != (high_b[space_b_dim] - low_b[space_b_dim])) + if ((high_a[space_a_dim] - low_a[space_a_dim]) != (high_b[space_b_dim] - low_b[space_b_dim])) HGOTO_DONE(FALSE) /* Go to next dimension */ @@ -1876,45 +1833,45 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* Check that the rest of the ranges in space a are "flat" */ - while(space_a_dim >= 0) { + while (space_a_dim >= 0) { /* Sanity check */ HDassert(low_a[space_a_dim] <= high_a[space_a_dim]); /* This range should be flat to be the same in a lower dimension */ - if(low_a[space_a_dim] != high_a[space_a_dim]) + if (low_a[space_a_dim] != high_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; } /* end while */ /* Check for a single block in each selection */ - if(H5S_SELECT_IS_SINGLE(space_a) && H5S_SELECT_IS_SINGLE(space_b)) { + if (H5S_SELECT_IS_SINGLE(space_a) && H5S_SELECT_IS_SINGLE(space_b)) { /* If both selections are a single block and their bounds are * the same, then the selections are the same, even if the * selection types are different. */ HGOTO_DONE(TRUE) } /* end if */ - } /* end if */ + } /* end if */ /* If the dataspaces have the same selection type, use the selection's * shape_same operator. */ - if(sel_a_type == sel_b_type) + if (sel_a_type == sel_b_type) ret_value = (*space_a->select.type->shape_same)(space_a, space_b); /* Otherwise, iterate through all the blocks in the selection */ else { - hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ - hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ - hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ - hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ - hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */ - hbool_t first_block = TRUE; /* Flag to indicate the first block */ + hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ + hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ + hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ + hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ + hssize_t offset[H5S_MAX_RANK]; /* Offset of selection b blocks relative to selection a blocks */ + hbool_t first_block = TRUE; /* Flag to indicate the first block */ /* Allocate the selection iterators */ - if(NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - if(NULL == (iter_b = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter_b = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator for each dataspace selection @@ -1922,21 +1879,21 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) * that the selection iterator shouldn't be "flattened", since we * aren't actually going to be doing I/O with the iterators. */ - if(H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0) + if (H5S_select_iter_init(iter_a, space_a, (size_t)0, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a") iter_a_init = TRUE; - if(H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0) + if (H5S_select_iter_init(iter_b, space_b, (size_t)0, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b") iter_b_init = TRUE; /* Iterate over all the blocks in each selection */ - while(1) { - htri_t status_a, status_b; /* Status from next block checks */ + while (1) { + htri_t status_a, status_b; /* Status from next block checks */ /* Get the current block for each selection iterator */ - if(H5S_SELECT_ITER_BLOCK(iter_a, start_a, end_a) < 0) + if (H5S_SELECT_ITER_BLOCK(iter_a, start_a, end_a) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block a") - if(H5S_SELECT_ITER_BLOCK(iter_b, start_b, end_b) < 0) + if (H5S_SELECT_ITER_BLOCK(iter_b, start_b, end_b) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block b") space_a_dim = (int)space_a_rank - 1; @@ -1945,13 +1902,13 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* The first block only compares the sizes and sets the * relative offsets for later blocks */ - if(first_block) { + if (first_block) { /* If the block sizes in the common dimensions from * each selection don't match, get out */ - while(space_b_dim >= 0) { - if((end_a[space_a_dim] - start_a[space_a_dim]) != - (end_b[space_b_dim] - start_b[space_b_dim])) + while (space_b_dim >= 0) { + if ((end_a[space_a_dim] - start_a[space_a_dim]) != + (end_b[space_b_dim] - start_b[space_b_dim])) HGOTO_DONE(FALSE) /* Set the relative locations of the selections */ @@ -1964,8 +1921,8 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* Similarly, if the block size in any dimension that appears only * in space_a is not equal to 1, get out. */ - while(space_a_dim >= 0) { - if(start_a[space_a_dim] != end_a[space_a_dim]) + while (space_a_dim >= 0) { + if (start_a[space_a_dim] != end_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; @@ -1977,14 +1934,15 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* Check over the blocks for each selection */ else { /* For dimensions that space_a and space_b have in common: */ - while(space_b_dim >= 0) { + while (space_b_dim >= 0) { /* Check if the blocks are in the same relative location */ - if((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim]) + if ((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != + start_b[space_b_dim]) HGOTO_DONE(FALSE) /* If the block sizes from each selection doesn't match, get out */ - if((end_a[space_a_dim] - start_a[space_a_dim]) != - (end_b[space_b_dim] - start_b[space_b_dim])) + if ((end_a[space_a_dim] - start_a[space_a_dim]) != + (end_b[space_b_dim] - start_b[space_b_dim])) HGOTO_DONE(FALSE) space_a_dim--; @@ -1992,53 +1950,54 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ /* For dimensions that appear only in space_a: */ - while(space_a_dim >= 0) { + while (space_a_dim >= 0) { /* If the block size isn't 1, get out */ - if(start_a[space_a_dim] != end_a[space_a_dim]) + if (start_a[space_a_dim] != end_a[space_a_dim]) HGOTO_DONE(FALSE) space_a_dim--; } /* end while */ - } /* end else */ + } /* end else */ /* Check if we are able to advance to the next selection block */ - if((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_a)) < 0) + if ((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_a)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block a") - if((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_b)) < 0) + if ((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_b)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block b") /* Did we run out of blocks at the same time? */ - if((status_a == FALSE) && (status_b == FALSE)) + if ((status_a == FALSE) && (status_b == FALSE)) break; - else if(status_a != status_b) + else if (status_a != status_b) HGOTO_DONE(FALSE) else { /* Advance to next block in selection iterators */ - if(H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block a") + if (H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "unable to advance to next iterator block a") - if(H5S_SELECT_ITER_NEXT_BLOCK(iter_b) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block b") + if (H5S_SELECT_ITER_NEXT_BLOCK(iter_b) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "unable to advance to next iterator block b") } /* end else */ - } /* end while */ - } /* end else */ - } /* end if */ + } /* end while */ + } /* end else */ + } /* end if */ done: - if(iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) + if (iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a") - if(iter_a) + if (iter_a) iter_a = H5FL_FREE(H5S_sel_iter_t, iter_a); - if(iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0) + if (iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b") - if(iter_b) + if (iter_b) iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_shape_same @@ -2062,25 +2021,24 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id) { - H5S_t *space1, *space2; /* Dataspaces to compare */ - htri_t ret_value; /* Return value */ + H5S_t *space1, *space2; /* Dataspaces to compare */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); - if(NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) + if (NULL == (space1 = (H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) + if (NULL == (space2 = (H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if((ret_value = H5S_select_shape_same(space1, space2)) < 0) + if ((ret_value = H5S_select_shape_same(space1, space2)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selections") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_shape_same() */ - /*-------------------------------------------------------------------------- NAME H5S_select_intersect_block @@ -2105,10 +2063,9 @@ 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(const H5S_t *space, const hsize_t *start, const hsize_t *end) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2118,31 +2075,30 @@ H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, HDassert(end); /* If selections aren't "none", compare their bounds */ - if(H5S_SEL_NONE != H5S_GET_SELECT_TYPE(space)) { - hsize_t low[H5S_MAX_RANK]; /* Low bound of selection in dataspace */ - hsize_t high[H5S_MAX_RANK]; /* High bound of selection in dataspace */ - unsigned u; /* Local index variable */ + if (H5S_SEL_NONE != H5S_GET_SELECT_TYPE(space)) { + hsize_t low[H5S_MAX_RANK]; /* Low bound of selection in dataspace */ + hsize_t high[H5S_MAX_RANK]; /* High bound of selection in dataspace */ + unsigned u; /* Local index variable */ /* Get low & high bounds for dataspace selection */ - if(H5S_SELECT_BOUNDS(space, low, high) < 0) + if (H5S_SELECT_BOUNDS(space, low, high) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds for dataspace") /* Loop over selection bounds and block, checking for overlap */ - for(u = 0; u < space->extent.rank; u++) + for (u = 0; u < space->extent.rank; u++) /* If selection bounds & block don't overlap, can leave now */ - if(!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) + if (!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) HGOTO_DONE(FALSE) } /* end if */ /* Call selection type's intersect routine */ - if((ret_value = (*space->select.type->intersect_block)(space, start, end)) < 0) + if ((ret_value = (*space->select.type->intersect_block)(space, start, end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't intersect block with selection") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_intersect_block @@ -2168,35 +2124,35 @@ H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end) { - H5S_t *space; /* Dataspace to query */ - unsigned u; /* Local index value */ - htri_t ret_value = FAIL; /* Return value */ + H5S_t * space; /* Dataspace to query */ + unsigned u; /* Local index value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*h*h", space_id, start, end); /* Check arguments */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == start) + if (NULL == start) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block start array pointer is NULL") - if(NULL == end) + if (NULL == end) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "block end array pointer is NULL") /* Range check start & end values */ - for(u = 0; u < space->extent.rank; u++) - if(start[u] > end[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "block start[%u] (%llu) > end[%u] (%llu)", u, (unsigned long long)start[u], u, (unsigned long long)end[u]) + for (u = 0; u < space->extent.rank; u++) + if (start[u] > end[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "block start[%u] (%llu) > end[%u] (%llu)", u, + (unsigned long long)start[u], u, (unsigned long long)end[u]) /* Call internal routine to do comparison */ - if((ret_value = H5S_select_intersect_block(space, start, end)) < 0) + if ((ret_value = H5S_select_intersect_block(space, start, end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't compare selection and block") done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_intersect_block() */ - /*-------------------------------------------------------------------------- NAME H5S_select_construct_projection @@ -2227,15 +2183,15 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e adj_buf_ptr) 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 + 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. + 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. + address of the section of buf + that is described by *new_space_ptr + in *adj_buf_ptr. RETURNS Non-negative on success/Negative on failure. @@ -2258,45 +2214,46 @@ 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(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_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 */ - unsigned base_space_rank; /* # of dimensions of base dataspace */ - hsize_t projected_space_element_offset = 0; /* Offset of selected element in projected buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned base_space_rank; /* # of dimensions of base dataspace */ + hsize_t projected_space_element_offset = 0; /* Offset of selected element in projected buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(base_space != NULL); - HDassert((H5S_GET_EXTENT_TYPE(base_space) == H5S_SCALAR) || (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE)); + HDassert((H5S_GET_EXTENT_TYPE(base_space) == H5S_SCALAR) || + (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE)); 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 ); + HDassert(element_size > 0); /* Get the extent info for the base dataspace */ - if((sbase_space_rank = H5S_get_simple_extent_dims(base_space, base_space_dims, base_space_maxdims)) < 0) + if ((sbase_space_rank = H5S_get_simple_extent_dims(base_space, base_space_dims, base_space_maxdims)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality of base space") base_space_rank = (unsigned)sbase_space_rank; HDassert(base_space_rank != new_space_rank); /* Check if projected space is scalar */ - if(new_space_rank == 0) { - hssize_t npoints; /* Number of points selected */ + if (new_space_rank == 0) { + hssize_t npoints; /* Number of points selected */ /* Retreve the number of elements selected */ - if((npoints = (hssize_t)H5S_GET_SELECT_NPOINTS(base_space)) < 0) + 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); /* Create new scalar dataspace */ - if(NULL == (new_space = H5S_create(H5S_SCALAR))) + if (NULL == (new_space = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create scalar dataspace") /* No need to register the dataspace(i.e. get an ID) as @@ -2312,7 +2269,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * same shape as the file dataspace, and that data * space is scalar. */ - if(1 == npoints) { + if (1 == npoints) { /* Assuming that the selection in the base dataspace is not * empty, we must compute the offset of the selected item in * the buffer associated with the base dataspace. @@ -2323,20 +2280,20 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * selection, may be either point, hyperspace, or all. * */ - if(H5S_SELECT_PROJECT_SCALAR(base_space, &projected_space_element_offset) < 0) + if (H5S_SELECT_PROJECT_SCALAR(base_space, &projected_space_element_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project scalar selection") } /* end if */ else { HDassert(0 == npoints); - if(H5S_select_none(new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't delete default selection") - } /* end else */ - } /* end if */ - else { /* projected space must be simple */ - hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */ - hsize_t new_space_maxdims[H5S_MAX_RANK];/* Maximum dimensions for new dataspace */ - unsigned rank_diff; /* Difference in ranks */ + if (H5S_select_none(new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't delete default selection") + } /* end else */ + } /* end if */ + else { /* projected space must be simple */ + hsize_t new_space_dims[H5S_MAX_RANK]; /* Current dimensions for new dataspace */ + hsize_t new_space_maxdims[H5S_MAX_RANK]; /* Maximum dimensions for new dataspace */ + unsigned rank_diff; /* Difference in ranks */ /* Set up the dimensions of the new, projected dataspace. * @@ -2366,8 +2323,8 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * only in the higher rank dataspace (i.e. those with * more slowly changing indicies). */ - if(new_space_rank > base_space_rank) { - hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ + if (new_space_rank > base_space_rank) { + hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ /* we must copy the dimensions of the base space into * the fastest changing dimensions of the new space, @@ -2376,22 +2333,26 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, rank_diff = new_space_rank - base_space_rank; H5VM_array_fill(new_space_dims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff); H5VM_array_fill(new_space_maxdims, &tmp_dim_size, sizeof(tmp_dim_size), rank_diff); - H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, sizeof(new_space_dims[0]) * base_space_rank); - H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, sizeof(new_space_maxdims[0]) * base_space_rank); - } /* end if */ + H5MM_memcpy(&new_space_dims[rank_diff], base_space_dims, + sizeof(new_space_dims[0]) * base_space_rank); + H5MM_memcpy(&new_space_maxdims[rank_diff], base_space_maxdims, + sizeof(new_space_maxdims[0]) * base_space_rank); + } /* end if */ else { /* new_space_rank < base_space_rank */ /* we must copy the fastest changing dimension of the * base space into the dimensions of the new space. */ rank_diff = base_space_rank - new_space_rank; - H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], sizeof(new_space_dims[0]) * new_space_rank); - H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], sizeof(new_space_maxdims[0]) * new_space_rank); + H5MM_memcpy(new_space_dims, &base_space_dims[rank_diff], + sizeof(new_space_dims[0]) * new_space_rank); + H5MM_memcpy(new_space_maxdims, &base_space_maxdims[rank_diff], + sizeof(new_space_maxdims[0]) * new_space_rank); } /* end else */ /* now have the new space rank and dimensions set up -- * so we can create the new simple dataspace. */ - if(NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims))) + if (NULL == (new_space = H5S_create_simple(new_space_rank, new_space_dims, new_space_maxdims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* No need to register the dataspace(i.e. get an ID) as @@ -2402,7 +2363,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * dataspace. We must now project the selection in the base * dataspace into the projected dataspace. */ - if(H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0) + if (H5S_SELECT_PROJECT_SIMPLE(base_space, new_space, &projected_space_element_offset) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to project simple selection") /* If we get this far, we have created the new dataspace, and projected @@ -2413,18 +2374,20 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * project the offset into the new dataspace and set the * offset_changed flag. */ - if(H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) { - if(new_space_rank > base_space_rank) { + if (H5S_GET_EXTENT_TYPE(base_space) == H5S_SIMPLE && base_space->select.offset_changed) { + if (new_space_rank > base_space_rank) { HDmemset(new_space->select.offset, 0, sizeof(new_space->select.offset[0]) * rank_diff); - H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, sizeof(new_space->select.offset[0]) * base_space_rank); + H5MM_memcpy(&new_space->select.offset[rank_diff], base_space->select.offset, + sizeof(new_space->select.offset[0]) * base_space_rank); } /* end if */ else - H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], sizeof(new_space->select.offset[0]) * new_space_rank); + H5MM_memcpy(new_space->select.offset, &base_space->select.offset[rank_diff], + sizeof(new_space->select.offset[0]) * new_space_rank); /* Propagate the offset changed flag into the new dataspace. */ new_space->select.offset_changed = TRUE; } /* end if */ - } /* end else */ + } /* end else */ /* If we have done the projection correctly, the following assertion * should hold. @@ -2435,8 +2398,8 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, *new_space_ptr = new_space; /* now adjust the buffer if required */ - if(buf != NULL) { - if(new_space_rank < base_space_rank) { + if (buf != 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 @@ -2448,7 +2411,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * 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))); + ((size_t)(projected_space_element_offset * element_size))); } /* end if */ else /* No adjustment necessary */ @@ -2457,14 +2420,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, done: /* Cleanup on error */ - if(ret_value < 0) - if(new_space && H5S_close(new_space) < 0) + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_construct_projection() */ - /*-------------------------------------------------------------------------- NAME H5S_select_fill @@ -2492,13 +2454,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, herr_t H5S_select_fill(const void *fill, size_t fill_size, const 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 */ - 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 */ + 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 */ + 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 */ FUNC_ENTER_NOAPI(FAIL) @@ -2509,40 +2471,41 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b HDassert(_buf); /* Allocate the selection iterator */ - if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Initialize iterator */ - if(H5S_select_iter_init(iter, space, fill_size, 0) < 0) + if (H5S_select_iter_init(iter, space, fill_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = TRUE; /* Selection iteration info has been initialized */ + iter_init = TRUE; /* Selection iteration info has been initialized */ /* Get the number of elements in selection */ - if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected") /* Compute the number of bytes to process */ H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t); /* Allocate the offset & length arrays */ - if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array") - if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) + if (NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array") /* 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 nelem; /* Number of elements used in sequences */ + while (max_elem > 0) { + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequnce being worked on */ + size_t nelem; /* Number of elements used in sequences */ /* Get the sequences of bytes */ - if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) + if (H5S_SELECT_ITER_GET_SEQ_LIST(iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + len) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") /* Loop over sequences */ - for(curr_seq = 0; curr_seq < nseq; curr_seq++) { - uint8_t *buf; /* Current location in buffer */ + for (curr_seq = 0; curr_seq < nseq; curr_seq++) { + uint8_t *buf; /* Current location in buffer */ /* Get offset in memory buffer */ buf = (uint8_t *)_buf + off[curr_seq]; @@ -2558,21 +2521,20 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b done: /* Release resources, if allocated */ - if(len) + if (len) len = H5FL_SEQ_FREE(size_t, len); - if(off) + if (off) off = H5FL_SEQ_FREE(hsize_t, off); /* Release selection iterator */ - if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - if(iter) + if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_fill() */ - /*-------------------------------------------------------------------------- NAME H5S_select_project_intersection @@ -2584,11 +2546,12 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b USAGE herr_t H5S_select_project_intersection(src_space,dst_space,src_intersect_space,proj_space,share_selection) - H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with src_intersect_space - H5S_t *dst_space; IN: Selection that is mapped to src_space - H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the result - H5S_t **new_space_ptr; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation - hbool_t share_selection; IN: Whether we are allowed to share structures inside dst_space with proj_space + H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with +src_intersect_space H5S_t *dst_space; IN: Selection that is mapped to src_space H5S_t +*src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the +result H5S_t **new_space_ptr; OUT: Will contain the result (intersection of src_intersect_space and src_space +projected from src_space to dst_space) after the operation hbool_t share_selection; IN: Whether we are allowed +to share structures inside dst_space with proj_space RETURNS Non-negative on success/Negative on failure. @@ -2606,16 +2569,16 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b --------------------------------------------------------------------------*/ 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) + const 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_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 */ - hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2627,31 +2590,30 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space)); HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); - if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) + if (NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) + if (NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") /* Create new space, using dst extent. Start with "all" selection. */ - if(NULL == (new_space = H5S_create(H5S_SIMPLE))) + if (NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") - if(H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) + if (H5S__extent_copy_real(&new_space->extent, &dst_space->extent, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy destination space extent") /* If the intersecting space is "all", the intersection must be equal to the * source space and the projection must be equal to the destination space */ - if(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_ALL) { + if (H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_ALL) { /* Copy the destination selection. */ - if(H5S_select_copy(new_space, dst_space, FALSE) < 0) + if (H5S_select_copy(new_space, dst_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection") } /* end if */ /* If any of the selections contain no elements, the projection must be * "none" */ - else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0) - || (H5S_GET_SELECT_NPOINTS(src_space) == 0) - || (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) { + else if ((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0) || (H5S_GET_SELECT_NPOINTS(src_space) == 0) || + (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) { /* Change to "none" selection */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ else { @@ -2667,28 +2629,28 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Check for scalar dst_space. In this case we simply check if the * (single) point selected in src_space intersects src_intersect_space, * if so select all in new_space, otherwise select none. */ - if(H5S_GET_EXTENT_TYPE(dst_space) == H5S_SCALAR) { + if (H5S_GET_EXTENT_TYPE(dst_space) == H5S_SCALAR) { hsize_t coords_start[H5S_MAX_RANK]; hsize_t coords_end[H5S_MAX_RANK]; - htri_t intersect; + htri_t intersect; /* Get source space bounds. Should be a single point. */ - if(H5S_SELECT_BOUNDS(src_space, coords_start, coords_end) < 0) + if (H5S_SELECT_BOUNDS(src_space, coords_start, coords_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source space bounds") - HDassert(0 == HDmemcmp(coords_start, coords_end, H5S_GET_EXTENT_NDIMS(src_space) * sizeof(coords_start[0]))); + HDassert(0 == HDmemcmp(coords_start, coords_end, + H5S_GET_EXTENT_NDIMS(src_space) * sizeof(coords_start[0]))); /* Check for intersection */ - if((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords_start, coords_end)) < 0) + if ((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords_start, coords_end)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't check for intersection") /* Select all or none as appropriate */ - if(intersect) { - if(H5S_select_all(new_space, TRUE) < 0) + if (intersect) { + if (H5S_select_all(new_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't select all") } /* end if */ - else - if(H5S_select_none(new_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + else if (H5S_select_none(new_space) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ else { /* If the source intersect space is a point selection, convert it to a @@ -2697,20 +2659,26 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Maybe we should just leave it as a point selection for the point by * point algorithm? The search through the selection in * H5S_SELECT_INTERSECT_BLOCK will likely be O(N) either way. -NAF */ - if(H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_POINTS) { + if (H5S_GET_SELECT_TYPE(src_intersect_space) == H5S_SEL_POINTS) { H5S_pnt_node_t *curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; /* Create dataspace and copy extent */ - if(NULL == (tmp_src_intersect_space = H5S_create(H5S_SIMPLE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create temporary source intersect dataspace") - if(H5S__extent_copy_real(&tmp_src_intersect_space->extent, &src_intersect_space->extent, FALSE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy source intersect space extent") + if (NULL == (tmp_src_intersect_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, + "unable to create temporary source intersect dataspace") + if (H5S__extent_copy_real(&tmp_src_intersect_space->extent, &src_intersect_space->extent, + FALSE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, + "unable to copy source intersect space extent") /* Iterate over points */ - for(curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; curr_pnt; curr_pnt = curr_pnt->next) + for (curr_pnt = src_intersect_space->select.sel_info.pnt_lst->head; curr_pnt; + curr_pnt = curr_pnt->next) /* Add point to hyperslab selection */ - if(H5S_hyper_add_span_element(tmp_src_intersect_space, src_intersect_space->extent.rank, curr_pnt->pnt) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't add point to temporary dataspace selection") + if (H5S_hyper_add_span_element(tmp_src_intersect_space, src_intersect_space->extent.rank, + curr_pnt->pnt) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't add point to temporary dataspace selection") /* Redirect local src_intersect_space pointer (will not affect * calling function) */ @@ -2722,21 +2690,23 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* If either the source space or the destination space is a point * selection, iterate element by element */ - if((H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_POINTS) - || (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_POINTS)) { + if ((H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_POINTS) || + (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_POINTS)) { hsize_t coords[H5S_MAX_RANK]; - htri_t intersect; + htri_t intersect; /* Start with "none" selection */ - if(H5S_select_none(new_space) < 0) + if (H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Initialize iterators */ - if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator") + if (H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't initialize source space selection iterator") ss_iter_init = TRUE; - if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator") + if (H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't initialize destination space selection iterator") ds_iter_init = TRUE; /* Iterate over points */ @@ -2745,32 +2715,37 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(ss_iter->elmt_left > 0); /* Get SS coords */ - if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates") + if (H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get source selection coordinates") /* Check for intersection */ - if((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords, coords)) < 0) + if ((intersect = H5S_SELECT_INTERSECT_BLOCK(src_intersect_space, coords, coords)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "can't check for intersection") /* Add point if it intersects */ - if(intersect) { + if (intersect) { /* Get DS coords */ - if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates") + if (H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, + "can't get destination selection coordinates") /* Add point to new_space */ - if(H5S_select_elements(new_space, H5S_SELECT_APPEND, 1, coords) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't add point to new selection") + if (H5S_select_elements(new_space, H5S_SELECT_APPEND, 1, coords) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, + "can't add point to new selection") } /* end if */ /* Advance iterators */ - if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator") + if (H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "can't advacne source selection iterator") ss_iter->elmt_left--; - if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator") + if (H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, + "can't advacne destination selection iterator") ds_iter->elmt_left--; - } while(ss_iter->elmt_left > 0); + } while (ss_iter->elmt_left > 0); HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0); } /* end if */ else { @@ -2780,27 +2755,29 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Source and destination selections are all or hyperslab, * intersecting selection is hyperslab. Call the hyperslab routine * to project to another hyperslab selection. */ - if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space, share_selection) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't project hyperslab onto destination selection") + if (H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space, + share_selection) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, + "can't project hyperslab onto destination selection") } /* end else */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* load the address of the new space into *new_space_ptr */ *new_space_ptr = new_space; done: /* Cleanup on error */ - if(ret_value < 0) - if(new_space && H5S_close(new_space) < 0) + if (ret_value < 0) + if (new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") /* General cleanup */ - if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) + if (tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") - if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) + if (ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") - if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) + if (ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); @@ -2809,7 +2786,6 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5Sselect_project_intersection @@ -2821,9 +2797,10 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, USAGE hid_t H5Sselect_project_intersection(src_space_id,dst_space_d,src_intersect_space_id) - hid_t src_space_id; IN: Selection that is mapped to dst_space_id, and intersected with src_intersect_space_id - hid_t dst_space_id; IN: Selection that is mapped to src_space_id - hid_t src_intersect_space_id; IN: Selection whose intersection with src_space_id is projected to dst_space_id to obtain the result + hid_t src_space_id; IN: Selection that is mapped to dst_space_id, and intersected with +src_intersect_space_id hid_t dst_space_id; IN: Selection that is mapped to src_space_id hid_t +src_intersect_space_id; IN: Selection whose intersection with src_space_id is projected to dst_space_id to +obtain the result RETURNS A dataspace with a selection equal to the intersection of @@ -2842,51 +2819,50 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, REVISION LOG --------------------------------------------------------------------------*/ hid_t -H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, - hid_t src_intersect_space_id) +H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, hid_t src_intersect_space_id) { H5S_t *src_space, *dst_space, *src_intersect_space; /* Input dataspaces */ - H5S_t *proj_space = NULL; /* Output dataspace */ - hid_t ret_value; /* Return value */ + H5S_t *proj_space = NULL; /* Output dataspace */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "iii", src_space_id, dst_space_id, src_intersect_space_id); /* Check args */ - if(NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) + if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") - if(NULL == (src_intersect_space = (H5S_t *)H5I_object_verify(src_intersect_space_id, H5I_DATASPACE))) + if (NULL == (src_intersect_space = (H5S_t *)H5I_object_verify(src_intersect_space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") /* Check numbers of points selected matches in source and destination */ - if(H5S_GET_SELECT_NPOINTS(src_space) != H5S_GET_SELECT_NPOINTS(dst_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "number of points selected in source space does not match that in destination space") + if (H5S_GET_SELECT_NPOINTS(src_space) != H5S_GET_SELECT_NPOINTS(dst_space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "number of points selected in source space does not match that in destination space") /* Check numbers of dimensions matches in source and source intersect spaces */ - if(H5S_GET_EXTENT_NDIMS(src_space) != H5S_GET_EXTENT_NDIMS(src_intersect_space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "rank of source space does not match rank of source intersect space") + if (H5S_GET_EXTENT_NDIMS(src_space) != H5S_GET_EXTENT_NDIMS(src_intersect_space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "rank of source space does not match rank of source intersect space") /* Perform operation */ - if(H5S_select_project_intersection(src_space, dst_space, - src_intersect_space, &proj_space, FALSE) < 0) + if (H5S_select_project_intersection(src_space, dst_space, src_intersect_space, &proj_space, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project dataspace intersection") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, proj_space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, proj_space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if(ret_value < 0) - if(proj_space && H5S_close(proj_space) < 0) + if (ret_value < 0) + if (proj_space && H5S_close(proj_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Sselect_project_intersection() */ - /*-------------------------------------------------------------------------- NAME H5S_select_subtract @@ -2915,7 +2891,7 @@ H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2925,40 +2901,40 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) /* If either space is using the none selection, then we do not need to do * anything */ - if((space->select.type->type != H5S_SEL_NONE) - && (subtract_space->select.type->type != H5S_SEL_NONE)) { + if ((space->select.type->type != H5S_SEL_NONE) && (subtract_space->select.type->type != H5S_SEL_NONE)) { /* If subtract_space is using the all selection, set space to none */ - if(subtract_space->select.type->type == H5S_SEL_ALL) { + if (subtract_space->select.type->type == H5S_SEL_ALL) { /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if (H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ /* If either selection is a point selection, fail currently */ - else if((subtract_space->select.type->type == H5S_SEL_POINTS) || - (space->select.type->type == H5S_SEL_POINTS)) { + else if ((subtract_space->select.type->type == H5S_SEL_POINTS) || + (space->select.type->type == H5S_SEL_POINTS)) { HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") } /* end if */ else { /* Check for all selection in space, convert to hyperslab */ - if(space->select.type->type == H5S_SEL_ALL) { + if (space->select.type->type == H5S_SEL_ALL) { /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ - hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ - hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ - hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ - hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ - unsigned u; /* Local index variable */ + hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ + hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ + unsigned u; /* Local index variable */ /* Fill in temporary information for the dimensions */ - for(u = 0; u < space->extent.rank; u++) { - tmp_start[u] = 0; + for (u = 0; u < space->extent.rank; u++) { + tmp_start[u] = 0; tmp_stride[u] = 1; - tmp_count[u] = 1; - tmp_block[u] = space->extent.size[u]; + tmp_count[u] = 1; + tmp_block[u] = space->extent.size[u]; } /* end for */ /* Convert to hyperslab selection */ - if(H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < 0) + if (H5S_select_hyperslab(space, H5S_SELECT_SET, tmp_start, tmp_stride, tmp_count, tmp_block) < + 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end if */ @@ -2966,16 +2942,203 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) HDassert(subtract_space->select.type->type == H5S_SEL_HYPERSLABS); /* Both spaces are now hyperslabs, perform the operation */ - if(H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0) + if (H5S__modify_select(space, H5S_SELECT_NOTB, subtract_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't subtract hyperslab") } /* end else */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_subtract() */ - +/*-------------------------------------------------------------------------- + NAME + H5Ssel_iter_create + PURPOSE + Create a dataspace selection iterator for a dataspace's selection + USAGE + hid_t H5Ssel_iter_create(space) + hid_t space; IN: ID of the dataspace with selection to iterate over + RETURNS + Valid dataspace selection iterator ID on success, H5I_INVALID_HID on failure + DESCRIPTION + Creates a selection iterator and initializes it to start at the first + element selected in the dataspace. + PROGRAMMER + Quincey Koziol - February 11, 2019 + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +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_sel_iter_t *sel_iter; /* Selection iterator created */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE3("i", "izIu", space_id, elmt_size, flags); + + /* Check args */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") + if (elmt_size == 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "element size must be greater than 0") + if (flags != (flags & H5S_SEL_ITER_ALL_PUBLIC_FLAGS)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, H5I_INVALID_HID, "invalid selection iterator flag") + + /* Allocate the iterator */ + if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate selection iterator") + + /* Add flag to indicate that this iterator is from an API call */ + flags |= H5S_SEL_ITER_API_CALL; + + /* Initialize the selection iterator */ + if (H5S_select_iter_init(sel_iter, space, elmt_size, flags) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to initialize selection iterator") + + /* Atomize */ + if ((ret_value = H5I_register(H5I_SPACE_SEL_ITER, sel_iter, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, + "unable to register dataspace selection iterator atom") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ssel_iter_create() */ + +/*-------------------------------------------------------------------------- + NAME + H5Ssel_iter_get_seq_list + PURPOSE + Retrieve a list of offset / length sequences for the elements in an iterator + USAGE + herr_t H5Ssel_iter_get_seq_list(sel_iter_id, maxseq, maxbytes, nseq, nbytes, off, len) + hid_t sel_iter_id; IN: ID of the dataspace selection iterator to retrieve sequence from + size_t maxseq; IN: Max. # of sequences to retrieve + size_t maxbytes; IN: Max. # of bytes to retrieve in sequences + size_t *nseq; OUT: # of sequences retrieved + size_t *nbytes; OUT: # of bytes retrieved, in all sequences + hsize_t *off; OUT: Array of sequence offsets + size_t *len; OUT: Array of sequence lengths + RETURNS + Non-negative on success / Negative on failure + DESCRIPTION + Retrieve a list of offset / length pairs (a list of "sequences") matching + the selected elements for an iterator, according to the iteration order for + the iterator. The lengths returned are in _bytes_, not elements. + + Note that the iteration order for "all" and "hyperslab" selections is + row-major (i.e. "C-ordered"), but the iteration order for "point" + selections is "in order selected", unless the H5S_SEL_ITER_GET_SEQ_LIST_SORTED + flag is passed to H5Sset_iter_create for a point selection. + + MAXSEQ and MAXBYTES specify the most sequences or bytes possible to + place into the OFF and LEN arrays. *NSEQ and *NBYTES return the actual + number of sequences and bytes put into the arrays. + + Each call to H5Ssel_iter_get_seq_list() will retrieve the next set + of sequences for the selection being iterated over. + + The total number of bytes possible to retrieve from a selection iterator + is the 'elmt_size' passed to H5Ssel_iter_create multiplied by the number + of elements selected in the dataspace the iterator was created from + (which can be retrieved with H5Sget_select_npoints). When there are no + further sequences of elements to retrieve, calls to this routine will + set *NSEQ and *NBYTES to zero. + PROGRAMMER + Quincey Koziol - February 11, 2019 + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Ssel_iter_get_seq_list(hid_t sel_iter_id, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes, + hsize_t *off, size_t *len) +{ + H5S_sel_iter_t *sel_iter; /* Dataspace selection iterator to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "izz*z*z*h*z", sel_iter_id, maxseq, maxbytes, nseq, nbytes, off, len); + + /* Check args */ + if (NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator") + if (NULL == nseq) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nseq' pointer is NULL") + if (NULL == nbytes) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "'nbytes' pointer is NULL") + if (NULL == off) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "offset array pointer is NULL") + if (NULL == len) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "length array pointer is NULL") + + /* Get the sequences of bytes */ + if (maxseq > 0 && maxbytes > 0 && sel_iter->elmt_left > 0) { + if (H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, maxseq, maxbytes, nseq, nbytes, off, len) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed") + } /* end if */ + else + *nseq = *nbytes = 0; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ssel_iter_get_seq_list() */ + +/*-------------------------------------------------------------------------- + NAME + H5Ssel_iter_reset + PURPOSE + Resets a dataspace selection iterator back to an initial state. + USAGE + herr_t H5Ssel_iter_reset(sel_iter_id) + hid_t sel_iter_id; IN: ID of the dataspace selection iterator to + reset + hid_t space_id; IN: ID of the dataspace with selection to + iterate over + RETURNS + Non-negative on success / Negative on failure + DESCRIPTION + Resets a dataspace selection iterator back to an initial state so that + the iterator may be used for iteration once again. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Ssel_iter_reset(hid_t sel_iter_id, hid_t space_id) +{ + H5S_sel_iter_t *sel_iter; + H5S_t * space; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", sel_iter_id, space_id); + + /* Check args */ + if (NULL == (sel_iter = (H5S_sel_iter_t *)H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator") + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Call selection type-specific release routine */ + if (H5S_SELECT_ITER_RELEASE(sel_iter) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, + "problem releasing a selection iterator's type-specific info") + + /* Simply re-initialize iterator */ + if (H5S_select_iter_init(sel_iter, space, sel_iter->elmt_size, sel_iter->flags) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to re-initialize selection iterator") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ssel_iter_reset() */ + /*------------------------------------------------------------------------- * Function: H5S_sel_iter_close * @@ -2991,7 +3154,7 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2999,8 +3162,9 @@ H5S_sel_iter_close(H5S_sel_iter_t *sel_iter) HDassert(sel_iter); /* Call selection type-specific release routine */ - if(H5S_SELECT_ITER_RELEASE(sel_iter) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "problem releasing a selection iterator's type-specific info") + if (H5S_SELECT_ITER_RELEASE(sel_iter) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, + "problem releasing a selection iterator's type-specific info") /* Release the structure */ sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); @@ -3009,3 +3173,41 @@ H5S_sel_iter_close(H5S_sel_iter_t *sel_iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_sel_iter_close() */ +/*-------------------------------------------------------------------------- + NAME + H5Ssel_iter_close + PURPOSE + Close a dataspace selection iterator + USAGE + herr_t H5Ssel_iter_close(sel_iter_id) + hid_t sel_iter_id; IN: ID of the dataspace selection iterator to close + RETURNS + Non-negative on success / Negative on failure + DESCRIPTION + Close a dataspace selection iterator, releasing its state. + PROGRAMMER + Quincey Koziol - February 11, 2019 + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Ssel_iter_close(hid_t sel_iter_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", sel_iter_id); + + /* Check args */ + if (NULL == H5I_object_verify(sel_iter_id, H5I_SPACE_SEL_ITER)) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "not a dataspace selection iterator") + + /* When the reference count reaches zero the resources are freed */ + if (H5I_dec_app_ref(sel_iter_id) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing dataspace selection iterator ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ssel_iter_close() */ diff --git a/src/H5Stest.c b/src/H5Stest.c index 1bc5b9fa7bf..a85154922e4 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,49 +21,41 @@ /* Module Setup */ /****************/ -#include "H5Smodule.h" /* This source code file is part of the H5S module */ -#define H5S_TESTING /*suppress warning about H5S testing funcs*/ - +#include "H5Smodule.h" /* This source code file is part of the H5S module */ +#define H5S_TESTING /*suppress warning about H5S testing funcs*/ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*********************/ /* Package Variables */ /*********************/ - /*******************/ /* Local Variables */ /*******************/ - - /*-------------------------------------------------------------------------- NAME H5S__get_rebuild_status_test @@ -89,8 +81,7 @@ REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, - H5S_diminfo_valid_t *status2) +H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, H5S_diminfo_valid_t *status2) { H5S_t *space; /* Pointer to 1st dataspace */ herr_t ret_value = SUCCEED; /* Return value */ @@ -100,14 +91,14 @@ H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, HDassert(status1); HDassert(status2); - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") *status1 = space->select.sel_info.hslab->diminfo_valid; /* Fully rebuild diminfo, if necessary */ - if(*status1 == H5S_DIMINFO_VALID_NO) + if (*status1 == H5S_DIMINFO_VALID_NO) H5S__hyper_rebuild(space); *status2 = space->select.sel_info.hslab->diminfo_valid; @@ -116,7 +107,6 @@ H5S__get_rebuild_status_test(hid_t space_id, H5S_diminfo_valid_t *status1, FUNC_LEAVE_NOAPI(ret_value) } /* H5S__get_rebuild_status_test() */ - /*-------------------------------------------------------------------------- NAME H5S__get_diminfo_status_test @@ -147,8 +137,8 @@ H5S__get_diminfo_status_test(hid_t space_id, H5S_diminfo_valid_t *status) HDassert(status); - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") *status = space->select.sel_info.hslab->diminfo_valid; @@ -181,24 +171,25 @@ H5S__check_spans_tail_ptr(const H5S_hyper_span_info_t *span_lst) { H5S_hyper_span_t *cur_elem; H5S_hyper_span_t *actual_tail = NULL; - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(span_lst); cur_elem = span_lst->head; - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; /* check the next dimension of lower order */ - 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") + 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") cur_elem = cur_elem->next; } /* end while */ - if(actual_tail != span_lst->tail) + if (actual_tail != span_lst->tail) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") done: @@ -228,25 +219,24 @@ H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst) { H5S_pnt_node_t *cur_elem; H5S_pnt_node_t *actual_tail = NULL; - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC HDassert(pnt_lst); cur_elem = pnt_lst->head; - while(cur_elem) { + while (cur_elem) { actual_tail = cur_elem; - cur_elem = cur_elem->next; + cur_elem = cur_elem->next; } /* end while */ - if(actual_tail != pnt_lst->tail) + if (actual_tail != pnt_lst->tail) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__check_points_tail_ptr */ - /*-------------------------------------------------------------------------- NAME H5S__check_internal_consistency @@ -269,60 +259,70 @@ H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst) static herr_t H5S__check_internal_consistency(const H5S_t *space) { - hsize_t low_bounds[H5S_MAX_RANK]; - hsize_t high_bounds[H5S_MAX_RANK]; + hsize_t low_bounds[H5S_MAX_RANK]; + hsize_t high_bounds[H5S_MAX_RANK]; unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(space); - if(space->select.type->type == H5S_SEL_NONE) + if (space->select.type->type == H5S_SEL_NONE) HGOTO_DONE(ret_value); /* Initialize the inputs */ - for(u = 0; u < space->extent.rank; u++) { - low_bounds[u] = HSIZET_MAX; + for (u = 0; u < space->extent.rank; u++) { + low_bounds[u] = HSIZET_MAX; high_bounds[u] = 0; } /* end for */ /* Check the bound box */ - if(H5S_get_select_bounds(space, low_bounds, high_bounds) < 0) + if (H5S_get_select_bounds(space, low_bounds, high_bounds) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the bound box could not be retrieved") - if(space->select.type->type == H5S_SEL_HYPERSLABS) { + if (space->select.type->type == H5S_SEL_HYPERSLABS) { H5S_hyper_sel_t *hslab = space->select.sel_info.hslab; - if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { - for(u = 0; u < space->extent.rank; u++) { - if((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != low_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent") - if((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != high_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent") + if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { + for (u = 0; u < space->extent.rank; u++) { + if ((hsize_t)((hssize_t)hslab->diminfo.low_bounds[u] + space->select.offset[u]) != + low_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the lower bound box of the selection is inconsistent") + if ((hsize_t)((hssize_t)hslab->diminfo.high_bounds[u] + space->select.offset[u]) != + high_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the higher bound box of the selection is inconsistent") } /* end for */ - } /* end if */ + } /* end if */ else { - for(u = 0; u < space->extent.rank; u++) { - if((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != low_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the lower bound box of the selection is inconsistent") - if((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != high_bounds[u]) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the higher bound box of the selection is inconsistent") + for (u = 0; u < space->extent.rank; u++) { + if ((hsize_t)((hssize_t)hslab->span_lst->low_bounds[u] + space->select.offset[u]) != + low_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the lower bound box of the selection is inconsistent") + if ((hsize_t)((hssize_t)hslab->span_lst->high_bounds[u] + space->select.offset[u]) != + high_bounds[u]) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the higher bound box of the selection is inconsistent") } /* end for */ - } /* end else */ + } /* end else */ /* check the tail pointer */ - 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") + 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") } /* end if */ - else if(space->select.type->type == H5S_SEL_POINTS) { + else if (space->select.type->type == H5S_SEL_POINTS) { H5S_pnt_list_t *pnt_lst = space->select.sel_info.pnt_lst; - 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") + 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") } /* end else-if */ done: @@ -351,20 +351,20 @@ H5S__check_internal_consistency(const H5S_t *space) htri_t H5S__internal_consistency_test(hid_t space_id) { - H5S_t *space; /* Pointer to 1st dataspace */ - htri_t ret_value = TRUE; /* Return value */ + H5S_t *space; /* Pointer to 1st dataspace */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE - /* Get dataspace structures */ - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + /* Get dataspace structures */ + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Check if the dataspace selections are the same shape */ - if(FAIL == H5S__check_internal_consistency(space)) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "The dataspace has inconsistent internal state") + if (FAIL == H5S__check_internal_consistency(space)) + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "The dataspace has inconsistent internal state") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__internal_consistency_test() */ - diff --git a/src/H5T.c b/src/H5T.c index 776a84ec900..c3ca03b48af 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,32 +22,31 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ -#define H5T_ENCODE_VERSION 0 +#define H5T_ENCODE_VERSION 0 /* * Type initialization macros @@ -59,225 +58,277 @@ */ /* Define the code template for bitfields for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_BITFIELD_CORE { \ - dt->shared->type = H5T_BITFIELD; \ -} +#define H5T_INIT_TYPE_BITFIELD_CORE \ + { \ + dt->shared->type = H5T_BITFIELD; \ + } -#define H5T_INIT_TYPE_BITFIELD_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - H5T_INIT_TYPE_BITFIELD_CORE; \ -} +#define H5T_INIT_TYPE_BITFIELD_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + H5T_INIT_TYPE_BITFIELD_CORE; \ + } -#define H5T_INIT_TYPE_BITFIELDLE_CORE { \ - H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_BITFIELDLE_CORE \ + { \ + H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_BITFIELDBE_CORE { \ - H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_BITFIELDBE_CORE \ + { \ + H5T_INIT_TYPE_BITFIELD_COMMON(H5T_ORDER_BE) \ + } /* Define the code template for times for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_TIME_CORE { \ - dt->shared->type = H5T_TIME; \ -} +#define H5T_INIT_TYPE_TIME_CORE \ + { \ + dt->shared->type = H5T_TIME; \ + } /* Define the code template for types which reset the offset for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_OFFSET_CORE { \ - dt->shared->u.atomic.offset = 0; \ -} +#define H5T_INIT_TYPE_OFFSET_CORE \ + { \ + dt->shared->u.atomic.offset = 0; \ + } /* Define common code for all numeric types (floating-point & int, signed & unsigned) */ -#define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) { \ - dt->shared->u.atomic.order = ENDIANNESS; \ - dt->shared->u.atomic.offset = 0; \ - dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ - dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + { \ + dt->shared->u.atomic.order = ENDIANNESS; \ + dt->shared->u.atomic.offset = 0; \ + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ + } /* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.f.sign = 31; \ - dt->shared->u.atomic.u.f.epos = 23; \ - dt->shared->u.atomic.u.f.esize = 8; \ - dt->shared->u.atomic.u.f.ebias = 0x7f; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 23; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x7f; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + } -#define H5T_INIT_TYPE_FLOATLE_CORE { \ - H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_FLOATLE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_FLOATBE_CORE { \ - H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_FLOATBE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for standard doubles for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.f.sign = 63; \ - dt->shared->u.atomic.u.f.epos = 52; \ - dt->shared->u.atomic.u.f.esize = 11; \ - dt->shared->u.atomic.u.f.ebias = 0x03ff; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 52; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ -} +#define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x03ff; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + } -#define H5T_INIT_TYPE_DOUBLELE_CORE { \ - H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_DOUBLELE_CORE \ + { \ + H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_DOUBLEBE_CORE { \ - H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_DOUBLEBE_CORE \ + { \ + H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for VAX float for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_FLOATVAX_CORE { \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ - dt->shared->u.atomic.u.f.sign = 31; \ - dt->shared->u.atomic.u.f.epos = 23; \ - dt->shared->u.atomic.u.f.esize = 8; \ - dt->shared->u.atomic.u.f.ebias = 0x81; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 23; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ - dt->shared->version = H5O_DTYPE_VERSION_3; \ -} +#define H5T_INIT_TYPE_FLOATVAX_CORE \ + { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x81; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->version = H5O_DTYPE_VERSION_3; \ + } /* Define the code templates for VAX double for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_DOUBLEVAX_CORE { \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ - dt->shared->u.atomic.u.f.sign = 63; \ - dt->shared->u.atomic.u.f.epos = 52; \ - dt->shared->u.atomic.u.f.esize = 11; \ - dt->shared->u.atomic.u.f.ebias = 0x0401; \ - dt->shared->u.atomic.u.f.mpos = 0; \ - dt->shared->u.atomic.u.f.msize = 52; \ - dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ - dt->shared->version = H5O_DTYPE_VERSION_3; \ -} +#define H5T_INIT_TYPE_DOUBLEVAX_CORE \ + { \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x0401; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->version = H5O_DTYPE_VERSION_3; \ + } /* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ -} +#define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ + } -#define H5T_INIT_TYPE_SINTLE_CORE { \ - H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_SINTLE_CORE \ + { \ + H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_SINTBE_CORE { \ - H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_SINTBE_CORE \ + { \ + H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \ + } /* Define the code templates for standard unsigned integers for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) { \ - H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ -} +#define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ + } -#define H5T_INIT_TYPE_UINTLE_CORE { \ - H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \ -} +#define H5T_INIT_TYPE_UINTLE_CORE \ + { \ + H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \ + } -#define H5T_INIT_TYPE_UINTBE_CORE { \ - H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \ -} +#define H5T_INIT_TYPE_UINTBE_CORE \ + { \ + H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \ + } /* Define a macro for common code for all newly allocate datatypes */ -#define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) { \ - dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; \ - dt->shared->type = TYPE; \ -} +#define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) \ + { \ + dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; \ + dt->shared->type = TYPE; \ + } /* Define the code templates for opaque for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_OPAQ_CORE { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ - dt->shared->u.opaque.tag = H5MM_xstrdup(""); \ -} +#define H5T_INIT_TYPE_OPAQ_CORE \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ + dt->shared->u.opaque.tag = H5MM_xstrdup(""); \ + } /* Define the code templates for strings for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_STRING_COMMON { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ - dt->shared->u.atomic.u.s.cset = H5F_DEFAULT_CSET; \ -} +#define H5T_INIT_TYPE_STRING_COMMON \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ + dt->shared->u.atomic.u.s.cset = H5F_DEFAULT_CSET; \ + } -#define H5T_INIT_TYPE_CSTRING_CORE { \ - H5T_INIT_TYPE_STRING_COMMON \ - dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ -} +#define H5T_INIT_TYPE_CSTRING_CORE \ + { \ + H5T_INIT_TYPE_STRING_COMMON \ + dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ + } -#define H5T_INIT_TYPE_FORSTRING_CORE { \ - H5T_INIT_TYPE_STRING_COMMON \ - dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ -} +#define H5T_INIT_TYPE_FORSTRING_CORE \ + { \ + H5T_INIT_TYPE_STRING_COMMON \ + dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ + } /* Define the code templates for references for the "GUTS" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_REF_COMMON { \ - H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ - H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ -} +#define H5T_INIT_TYPE_REF_COMMON \ + { \ + H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ + H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ + dt->shared->force_conv = TRUE; \ + dt->shared->u.atomic.u.r.file = NULL; \ + dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \ + dt->shared->u.atomic.u.r.cls = NULL; \ + } -#define H5T_INIT_TYPE_OBJREF_CORE { \ - H5T_INIT_TYPE_REF_COMMON \ - dt->shared->force_conv = TRUE; \ - dt->shared->u.atomic.u.r.rtype = H5R_OBJECT; \ - dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; \ -} +#define H5T_INIT_TYPE_OBJREF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_OBJECT1; \ + dt->shared->u.atomic.u.r.opaque = FALSE; \ + dt->shared->u.atomic.u.r.version = 0; \ + } -#define H5T_INIT_TYPE_REGREF_CORE { \ - H5T_INIT_TYPE_REF_COMMON \ - dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION; \ -} +#define H5T_INIT_TYPE_REGREF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION1; \ + dt->shared->u.atomic.u.r.opaque = FALSE; \ + dt->shared->u.atomic.u.r.version = 0; \ + } + +/* rtype value is only used as a placeholder to differentiate the type from + * other types, any opaque (i.e. "new") reference type could be used. + */ +#define H5T_INIT_TYPE_REF_CORE \ + { \ + H5T_INIT_TYPE_REF_COMMON \ + dt->shared->u.atomic.u.r.rtype = H5R_OBJECT2; \ + dt->shared->u.atomic.u.r.opaque = TRUE; \ + dt->shared->u.atomic.u.r.version = H5R_ENCODE_VERSION; \ + dt->shared->version = H5O_DTYPE_VERSION_4; \ + } /* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_SET_SIZE(SIZE) { \ - dt->shared->size = SIZE; \ - dt->shared->u.atomic.prec = 8 * SIZE; \ -} +#define H5T_INIT_TYPE_SET_SIZE(SIZE) \ + { \ + dt->shared->size = SIZE; \ + dt->shared->u.atomic.prec = 8 * SIZE; \ + } -#define H5T_INIT_TYPE_NOSET_SIZE(SIZE) { \ -} +#define H5T_INIT_TYPE_NOSET_SIZE(SIZE) \ + { \ + } /* Define the code templates for the "CRT_TMPL" in the H5T_INIT_TYPE macro */ -#define H5T_INIT_TYPE_COPY_CREATE(BASE) { \ - /* Base off of existing datatype */ \ - if(NULL == (dt = H5T_copy(BASE, H5T_COPY_TRANSIENT))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \ -} - -#define H5T_INIT_TYPE_ALLOC_CREATE(BASE) { \ - /* Allocate new datatype info */ \ - if(NULL == (dt = H5T__alloc())) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") \ -} - +#define H5T_INIT_TYPE_COPY_CREATE(BASE) \ + { \ + /* Base off of existing datatype */ \ + if (NULL == (dt = H5T_copy(BASE, H5T_COPY_TRANSIENT))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \ + } -#define H5T_INIT_TYPE(GUTS,GLOBAL,CRT_TMPL,BASE,SIZE_TMPL,SIZE) { \ - /* Get new datatype struct */ \ - H5_GLUE3(H5T_INIT_TYPE_,CRT_TMPL,_CREATE)(BASE) \ - \ - /* Adjust information for all types */ \ - dt->shared->state = H5T_STATE_IMMUTABLE; \ - H5_GLUE3(H5T_INIT_TYPE_,SIZE_TMPL,_SIZE)(SIZE) \ - \ - /* Adjust information for this type */ \ - H5_GLUE3(H5T_INIT_TYPE_, GUTS, _CORE) \ - \ - /* Atomize result */ \ - if((GLOBAL = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \ -} +#define H5T_INIT_TYPE_ALLOC_CREATE(BASE) \ + { \ + /* Allocate new datatype info */ \ + if (NULL == (dt = H5T__alloc())) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") \ + } +#define H5T_INIT_TYPE(GUTS, GLOBAL, CRT_TMPL, BASE, SIZE_TMPL, SIZE) \ + { \ + /* Get new datatype struct */ \ + H5_GLUE3(H5T_INIT_TYPE_, CRT_TMPL, _CREATE) \ + (BASE) \ + \ + /* Adjust information for all types */ \ + dt->shared->state = H5T_STATE_IMMUTABLE; \ + H5_GLUE3(H5T_INIT_TYPE_, SIZE_TMPL, _SIZE) \ + (SIZE) \ + \ + /* Adjust information for this type */ \ + H5_GLUE3(H5T_INIT_TYPE_, GUTS, _CORE) \ + \ + /* Atomize result */ \ + if ((GLOBAL = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \ + } /******************/ /* Local Typedefs */ @@ -286,24 +337,24 @@ /* Typedef for recursive const-correct datatype copying routines */ typedef H5T_t *(*H5T_copy_func_t)(H5T_t *old_dt); - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_lib_conv_t func); +static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, + H5T_lib_conv_t func); static herr_t H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv); static herr_t H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func); static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst); static herr_t H5T__set_size(H5T_t *dt, size_t size); 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_reg_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 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); - +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 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); /*****************************/ /* Library Private Variables */ @@ -312,7 +363,6 @@ static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, /* The native endianness of the platform */ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; - /*********************/ /* Package Variables */ /*********************/ @@ -327,82 +377,83 @@ hbool_t H5_PKG_INIT_VAR = FALSE; * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_package(). */ -hid_t H5T_IEEE_F32BE_g = FAIL; -hid_t H5T_IEEE_F32LE_g = FAIL; -hid_t H5T_IEEE_F64BE_g = FAIL; -hid_t H5T_IEEE_F64LE_g = FAIL; - -hid_t H5T_VAX_F32_g = FAIL; -hid_t H5T_VAX_F64_g = FAIL; - -hid_t H5T_STD_I8BE_g = FAIL; -hid_t H5T_STD_I8LE_g = FAIL; -hid_t H5T_STD_I16BE_g = FAIL; -hid_t H5T_STD_I16LE_g = FAIL; -hid_t H5T_STD_I32BE_g = FAIL; -hid_t H5T_STD_I32LE_g = FAIL; -hid_t H5T_STD_I64BE_g = FAIL; -hid_t H5T_STD_I64LE_g = FAIL; -hid_t H5T_STD_U8BE_g = FAIL; -hid_t H5T_STD_U8LE_g = FAIL; -hid_t H5T_STD_U16BE_g = FAIL; -hid_t H5T_STD_U16LE_g = FAIL; -hid_t H5T_STD_U32BE_g = FAIL; -hid_t H5T_STD_U32LE_g = FAIL; -hid_t H5T_STD_U64BE_g = FAIL; -hid_t H5T_STD_U64LE_g = FAIL; -hid_t H5T_STD_B8BE_g = FAIL; -hid_t H5T_STD_B8LE_g = FAIL; -hid_t H5T_STD_B16BE_g = FAIL; -hid_t H5T_STD_B16LE_g = FAIL; -hid_t H5T_STD_B32BE_g = FAIL; -hid_t H5T_STD_B32LE_g = FAIL; -hid_t H5T_STD_B64BE_g = FAIL; -hid_t H5T_STD_B64LE_g = FAIL; -hid_t H5T_STD_REF_OBJ_g = FAIL; -hid_t H5T_STD_REF_DSETREG_g = FAIL; - -hid_t H5T_UNIX_D32BE_g = FAIL; -hid_t H5T_UNIX_D32LE_g = FAIL; -hid_t H5T_UNIX_D64BE_g = FAIL; -hid_t H5T_UNIX_D64LE_g = FAIL; - -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_LDOUBLE_g = FAIL; +hid_t H5T_IEEE_F32BE_g = FAIL; +hid_t H5T_IEEE_F32LE_g = FAIL; +hid_t H5T_IEEE_F64BE_g = FAIL; +hid_t H5T_IEEE_F64LE_g = FAIL; + +hid_t H5T_VAX_F32_g = FAIL; +hid_t H5T_VAX_F64_g = FAIL; + +hid_t H5T_STD_I8BE_g = FAIL; +hid_t H5T_STD_I8LE_g = FAIL; +hid_t H5T_STD_I16BE_g = FAIL; +hid_t H5T_STD_I16LE_g = FAIL; +hid_t H5T_STD_I32BE_g = FAIL; +hid_t H5T_STD_I32LE_g = FAIL; +hid_t H5T_STD_I64BE_g = FAIL; +hid_t H5T_STD_I64LE_g = FAIL; +hid_t H5T_STD_U8BE_g = FAIL; +hid_t H5T_STD_U8LE_g = FAIL; +hid_t H5T_STD_U16BE_g = FAIL; +hid_t H5T_STD_U16LE_g = FAIL; +hid_t H5T_STD_U32BE_g = FAIL; +hid_t H5T_STD_U32LE_g = FAIL; +hid_t H5T_STD_U64BE_g = FAIL; +hid_t H5T_STD_U64LE_g = FAIL; +hid_t H5T_STD_B8BE_g = FAIL; +hid_t H5T_STD_B8LE_g = FAIL; +hid_t H5T_STD_B16BE_g = FAIL; +hid_t H5T_STD_B16LE_g = FAIL; +hid_t H5T_STD_B32BE_g = FAIL; +hid_t H5T_STD_B32LE_g = FAIL; +hid_t H5T_STD_B64BE_g = FAIL; +hid_t H5T_STD_B64LE_g = FAIL; +hid_t H5T_STD_REF_OBJ_g = FAIL; +hid_t H5T_STD_REF_DSETREG_g = FAIL; +hid_t H5T_STD_REF_g = FAIL; + +hid_t H5T_UNIX_D32BE_g = FAIL; +hid_t H5T_UNIX_D32LE_g = FAIL; +hid_t H5T_UNIX_D64BE_g = FAIL; +hid_t H5T_UNIX_D64LE_g = FAIL; + +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_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_INT8_g = FAIL; -hid_t H5T_NATIVE_UINT8_g = FAIL; -hid_t H5T_NATIVE_INT_LEAST8_g = FAIL; -hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL; -hid_t H5T_NATIVE_INT_FAST8_g = FAIL; -hid_t H5T_NATIVE_UINT_FAST8_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; +hid_t H5T_NATIVE_INT_LEAST8_g = FAIL; +hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL; +hid_t H5T_NATIVE_INT_FAST8_g = FAIL; +hid_t H5T_NATIVE_UINT_FAST8_g = FAIL; hid_t H5T_NATIVE_INT16_g = FAIL; hid_t H5T_NATIVE_UINT16_g = FAIL; @@ -431,45 +482,46 @@ 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_LDOUBLE_COMP_ALIGN_g = 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; +#if H5_SIZEOF_LONG_DOUBLE != 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; -size_t H5T_HOBJREF_COMP_ALIGN_g = 0; -size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0; +size_t H5T_POINTER_COMP_ALIGN_g = 0; +size_t H5T_HVL_COMP_ALIGN_g = 0; +size_t H5T_HOBJREF_COMP_ALIGN_g = 0; +size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0; +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_LDOUBLE_ALIGN_g = 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; +#if H5_SIZEOF_LONG_DOUBLE != 0 +size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; #endif /* @@ -477,40 +529,40 @@ size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; * H5Tinit.c if the types are provided by the system. Otherwise we set their * values to 0 here (no alignment calculated). */ -size_t H5T_NATIVE_INT8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT8_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0; - -size_t H5T_NATIVE_INT16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT16_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0; - -size_t H5T_NATIVE_INT32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT32_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0; - -size_t H5T_NATIVE_INT64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT64_ALIGN_g = 0; -size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0; -size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; +size_t H5T_NATIVE_INT8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT8_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0; + +size_t H5T_NATIVE_INT16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT16_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0; + +size_t H5T_NATIVE_INT32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT32_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0; + +size_t H5T_NATIVE_INT64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT64_ALIGN_g = 0; +size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0; +size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ -float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; -float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; -double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f; -double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f; +float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f; +float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f; +double H5T_NATIVE_DOUBLE_POS_INF_g = 0.0; +double H5T_NATIVE_DOUBLE_NEG_INF_g = 0.0; /* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); @@ -518,9 +570,10 @@ H5FL_DEFINE(H5T_shared_t); /* Format version bounds for datatype */ const unsigned H5O_dtype_ver_bounds[] = { - H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ - H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_DTYPE_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V18 */ + H5O_DTYPE_VERSION_3, /* H5F_LIBVER_V110 */ + H5O_DTYPE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*******************/ @@ -532,12 +585,12 @@ const unsigned H5O_dtype_ver_bounds[] = { * which is used as the key by which the `entries' array is sorted. */ static struct { - int npaths; /*number of paths defined */ - size_t apaths; /*number of paths allocated */ - 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 */ + int npaths; /*number of paths defined */ + size_t apaths; /*number of paths allocated */ + 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_g; /* Declare the free list for H5T_path_t's */ @@ -545,18 +598,15 @@ H5FL_DEFINE_STATIC(H5T_path_t); /* Datatype ID class */ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ - H5I_DATATYPE, /* ID class value */ - 0, /* Class flags */ - 8, /* # of reserved IDs for class */ - (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ + H5I_DATATYPE, /* ID class value */ + 0, /* Class flags */ + 8, /* # of reserved IDs for class */ + (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ }}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5T_top_package_initialize_s = FALSE; - - /*------------------------------------------------------------------------- * Function: H5T_init * @@ -573,7 +623,7 @@ static hbool_t H5T_top_package_initialize_s = FALSE; herr_t H5T_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* FUNC_ENTER() does all the work */ @@ -582,7 +632,6 @@ H5T_init(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_init() */ - /*------------------------------------------------------------------------- * Function: H5T__init_inf * @@ -600,22 +649,22 @@ H5T_init(void) static herr_t H5T__init_inf(void) { - H5T_t *dst_p; /* Datatype type operate on */ - H5T_atomic_t *dst; /* Datatype's atomic info */ - 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 */ + H5T_t * dst_p; /* Datatype type operate on */ + H5T_atomic_t *dst; /* Datatype's atomic info */ + 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 */ FUNC_ENTER_STATIC /* Get the float datatype */ - if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) + if (NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ - if(H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) + if (H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") /* +Inf */ @@ -627,12 +676,12 @@ H5T__init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* -Inf */ d = (uint8_t *)&H5T_NATIVE_FLOAT_NEG_INF_g; @@ -641,22 +690,22 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* Get the double datatype */ - if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) + if (NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ - if(H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) + if (H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") /* +Inf */ @@ -666,14 +715,14 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* -Inf */ d = (uint8_t *)&H5T_NATIVE_DOUBLE_NEG_INF_g; @@ -682,20 +731,19 @@ H5T__init_inf(void) H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE); /* Swap the bytes if the machine architecture is big-endian */ - if(H5T_ORDER_BE == H5T_native_order_g) { + if (H5T_ORDER_BE == H5T_native_order_g) { half_size = dst_p->shared->size / 2; - for(u = 0; u < half_size; u++) { - uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; d[dst_p->shared->size - (u + 1)] = d[u]; - d[u] = tmp; + d[u] = tmp; } /* end for */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_inf() */ - /*-------------------------------------------------------------------------- NAME H5T__init_package -- Initialize interface-specific information @@ -710,48 +758,51 @@ 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 */ + 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 object reference objects */ - hsize_t dim[1]={1}; /* Dimension info for array datatype */ - herr_t status; - hbool_t copied_dtype = TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * std_u8le = NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ + H5T_t * std_u8be = NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ + H5T_t * std_u16le = NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ + H5T_t * std_u16be = NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ + H5T_t * std_u32le = NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ + H5T_t * std_u32be = NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ + H5T_t * std_u64le = NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ + H5T_t * std_u64be = NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ + H5T_t * dt = NULL; + H5T_t * fixedpt = NULL; /* Datatype structure for native int */ + H5T_t * floatpt = NULL; /* Datatype structure for native float */ + H5T_t * string = NULL; /* Datatype structure for C string */ + H5T_t * bitfield = NULL; /* Datatype structure for bitfield */ + H5T_t * compound = NULL; /* Datatype structure for compound objects */ + H5T_t * enum_type = NULL; /* Datatype structure for enum objects */ + H5T_t * vlen = NULL; /* Datatype structure for vlen objects */ + H5T_t * array = NULL; /* Datatype structure for array objects */ + H5T_t * objref = NULL; /* Datatype structure for deprecated reference objects */ + H5T_t * regref = NULL; /* Datatype structure for deprecated region references */ + H5T_t * ref = NULL; /* Datatype structure for opaque references */ + hsize_t dim[1] = {1}; /* Dimension info for array datatype */ + herr_t status; + hbool_t copied_dtype = + TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Initialize the atom group for the file IDs */ - if(H5I_register_type(H5I_DATATYPE_CLS) < 0) + if (H5I_register_type(H5I_DATATYPE_CLS) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Make certain there aren't too many classes of datatypes defined */ @@ -762,36 +813,36 @@ H5T__init_package(void) * Initialize pre-defined native datatypes from code generated during * the library configuration by H5detect. */ - if(H5T__init_native() < 0) + if (H5T__init_native() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Get the atomic datatype structures needed by the initialization code below */ - if(NULL == (native_schar = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) + if (NULL == (native_schar = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_uchar = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR_g))) + if (NULL == (native_uchar = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_short = (H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) + if (NULL == (native_short = (H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ushort = (H5T_t *)H5I_object(H5T_NATIVE_USHORT_g))) + if (NULL == (native_ushort = (H5T_t *)H5I_object(H5T_NATIVE_USHORT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_int = (H5T_t *)H5I_object(H5T_NATIVE_INT_g))) + if (NULL == (native_int = (H5T_t *)H5I_object(H5T_NATIVE_INT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_uint = (H5T_t *)H5I_object(H5T_NATIVE_UINT_g))) + if (NULL == (native_uint = (H5T_t *)H5I_object(H5T_NATIVE_UINT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_long = (H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) + if (NULL == (native_long = (H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ulong = (H5T_t *)H5I_object(H5T_NATIVE_ULONG_g))) + if (NULL == (native_ulong = (H5T_t *)H5I_object(H5T_NATIVE_ULONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_llong = (H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) + if (NULL == (native_llong = (H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_ullong = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG_g))) + if (NULL == (native_ullong = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_float = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) + if (NULL == (native_float = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(NULL == (native_double = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) + 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))) +#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 @@ -801,31 +852,31 @@ H5T__init_package(void) */ /* 1-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B8_g,COPY,native_uint,SET,1) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B8_g, COPY, native_uint, SET, 1) /* 2-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B16_g,COPY,native_uint,SET,2) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B16_g, COPY, native_uint, SET, 2) /* 4-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B32_g,COPY,native_uint,SET,4) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B32_g, COPY, native_uint, SET, 4) /* 8-byte bit field */ - H5T_INIT_TYPE(BITFIELD,H5T_NATIVE_B64_g,COPY,native_uint,SET,8) + H5T_INIT_TYPE(BITFIELD, H5T_NATIVE_B64_g, COPY, native_uint, SET, 8) /* haddr_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HADDR_g,COPY,native_uint,SET,sizeof(haddr_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HADDR_g, COPY, native_uint, SET, sizeof(haddr_t)) /* hsize_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSIZE_g,COPY,native_uint,SET,sizeof(hsize_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HSIZE_g, COPY, native_uint, SET, sizeof(hsize_t)) /* hssize_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HSSIZE_g,COPY,native_int,SET,sizeof(hssize_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HSSIZE_g, COPY, native_int, SET, sizeof(hssize_t)) /* herr_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HERR_g,COPY,native_int,SET,sizeof(herr_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HERR_g, COPY, native_int, SET, sizeof(herr_t)) /* hbool_t */ - H5T_INIT_TYPE(OFFSET,H5T_NATIVE_HBOOL_g,COPY,native_uint,SET,sizeof(hbool_t)) + H5T_INIT_TYPE(OFFSET, H5T_NATIVE_HBOOL_g, COPY, native_uint, SET, sizeof(hbool_t)) /*------------------------------------------------------------ * IEEE Types @@ -833,16 +884,16 @@ H5T__init_package(void) */ /* IEEE 4-byte little-endian float */ - H5T_INIT_TYPE(FLOATLE,H5T_IEEE_F32LE_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATLE, H5T_IEEE_F32LE_g, COPY, native_double, SET, 4) /* IEEE 4-byte big-endian float */ - H5T_INIT_TYPE(FLOATBE,H5T_IEEE_F32BE_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATBE, H5T_IEEE_F32BE_g, COPY, native_double, SET, 4) /* IEEE 8-byte little-endian float */ - H5T_INIT_TYPE(DOUBLELE,H5T_IEEE_F64LE_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLELE, H5T_IEEE_F64LE_g, COPY, native_double, SET, 8) /* IEEE 8-byte big-endian float */ - H5T_INIT_TYPE(DOUBLEBE,H5T_IEEE_F64BE_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLEBE, H5T_IEEE_F64BE_g, COPY, native_double, SET, 8) /*------------------------------------------------------------ * VAX Types @@ -850,10 +901,10 @@ H5T__init_package(void) */ /* VAX 4-byte float */ - H5T_INIT_TYPE(FLOATVAX,H5T_VAX_F32_g,COPY,native_double,SET,4) + H5T_INIT_TYPE(FLOATVAX, H5T_VAX_F32_g, COPY, native_double, SET, 4) /* VAX 8-byte double */ - H5T_INIT_TYPE(DOUBLEVAX,H5T_VAX_F64_g,COPY,native_double,SET,8) + H5T_INIT_TYPE(DOUBLEVAX, H5T_VAX_F64_g, COPY, native_double, SET, 8) /*------------------------------------------------------------ * C99 types @@ -861,60 +912,60 @@ H5T__init_package(void) */ /* 1-byte little-endian (endianness is irrelevant) signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I8LE_g,COPY,native_int,SET,1) + H5T_INIT_TYPE(SINTLE, H5T_STD_I8LE_g, COPY, native_int, SET, 1) /* 1-byte big-endian (endianness is irrelevant) signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I8BE_g,COPY,native_int,SET,1) + H5T_INIT_TYPE(SINTBE, H5T_STD_I8BE_g, COPY, native_int, SET, 1) /* 2-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I16LE_g,COPY,native_int,SET,2) + H5T_INIT_TYPE(SINTLE, H5T_STD_I16LE_g, COPY, native_int, SET, 2) /* 2-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I16BE_g,COPY,native_int,SET,2) + H5T_INIT_TYPE(SINTBE, H5T_STD_I16BE_g, COPY, native_int, SET, 2) /* 4-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I32LE_g,COPY,native_int,SET,4) + H5T_INIT_TYPE(SINTLE, H5T_STD_I32LE_g, COPY, native_int, SET, 4) /* 4-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I32BE_g,COPY,native_int,SET,4) + H5T_INIT_TYPE(SINTBE, H5T_STD_I32BE_g, COPY, native_int, SET, 4) /* 8-byte little-endian signed integer */ - H5T_INIT_TYPE(SINTLE,H5T_STD_I64LE_g,COPY,native_int,SET,8) + H5T_INIT_TYPE(SINTLE, H5T_STD_I64LE_g, COPY, native_int, SET, 8) /* 8-byte big-endian signed integer */ - H5T_INIT_TYPE(SINTBE,H5T_STD_I64BE_g,COPY,native_int,SET,8) + H5T_INIT_TYPE(SINTBE, H5T_STD_I64BE_g, COPY, native_int, SET, 8) /* 1-byte little-endian (endianness is irrelevant) unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U8LE_g,COPY,native_uint,SET,1) - std_u8le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U8LE_g, COPY, native_uint, SET, 1) + std_u8le = dt; /* Keep type for later */ /* 1-byte big-endian (endianness is irrelevant) unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U8BE_g,COPY,native_uint,SET,1) - std_u8be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U8BE_g, COPY, native_uint, SET, 1) + std_u8be = dt; /* Keep type for later */ /* 2-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U16LE_g,COPY,native_uint,SET,2) - std_u16le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U16LE_g, COPY, native_uint, SET, 2) + std_u16le = dt; /* Keep type for later */ /* 2-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U16BE_g,COPY,native_uint,SET,2) - std_u16be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U16BE_g, COPY, native_uint, SET, 2) + std_u16be = dt; /* Keep type for later */ /* 4-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U32LE_g,COPY,native_uint,SET,4) - std_u32le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U32LE_g, COPY, native_uint, SET, 4) + std_u32le = dt; /* Keep type for later */ /* 4-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U32BE_g,COPY,native_uint,SET,4) - std_u32be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U32BE_g, COPY, native_uint, SET, 4) + std_u32be = dt; /* Keep type for later */ /* 8-byte little-endian unsigned integer */ - H5T_INIT_TYPE(UINTLE,H5T_STD_U64LE_g,COPY,native_uint,SET,8) - std_u64le=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTLE, H5T_STD_U64LE_g, COPY, native_uint, SET, 8) + std_u64le = dt; /* Keep type for later */ /* 8-byte big-endian unsigned integer */ - H5T_INIT_TYPE(UINTBE,H5T_STD_U64BE_g,COPY,native_uint,SET,8) - std_u64be=dt; /* Keep type for later */ + H5T_INIT_TYPE(UINTBE, H5T_STD_U64BE_g, COPY, native_uint, SET, 8) + std_u64be = dt; /* Keep type for later */ /*------------------------------------------------------------ * Native, Little- & Big-endian bitfields @@ -923,7 +974,7 @@ H5T__init_package(void) /* little-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELDLE, H5T_STD_B8LE_g, COPY, std_u8le, NOSET, -) - bitfield=dt; /* Keep type for later */ + bitfield = dt; /* Keep type for later */ /* big-endian (order is irrelevant) 8-bit bitfield */ H5T_INIT_TYPE(BITFIELDBE, H5T_STD_B8BE_g, COPY, std_u8be, NOSET, -) @@ -963,7 +1014,6 @@ H5T__init_package(void) /* Big-endian 64-bit UNIX time_t */ H5T_INIT_TYPE(TIME, H5T_UNIX_D64BE_g, COPY, std_u64be, NOSET, -) - /* Indicate that the types that are created from here down are allocated * H5FL_ALLOC(), not copied with H5T_copy() */ @@ -979,7 +1029,7 @@ H5T__init_package(void) /* One-byte character string */ H5T_INIT_TYPE(CSTRING, H5T_C_S1_g, ALLOC, -, SET, 1) - string = dt; /* Keep type for later */ + string = dt; /* Keep type for later */ /*------------------------------------------------------------ * The `Fortran' architecture @@ -994,12 +1044,23 @@ H5T__init_package(void) *------------------------------------------------------------ */ - /* Object reference (i.e. object header address in file) */ - H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, SET, H5R_OBJ_REF_BUF_SIZE) - objref = dt; /* Keep type for later */ + /* Deprecated object reference type */ + H5T_INIT_TYPE(OBJREF, H5T_STD_REF_OBJ_g, ALLOC, -, NOSET, -) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") + objref = dt; /* Keep type for later */ + + /* Deprecated region reference type */ + H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, NOSET, -) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") + regref = dt; /* Keep type for later */ - /* Dataset Region reference (i.e. selection inside a dataset) */ - H5T_INIT_TYPE(REGREF, H5T_STD_REF_DSETREG_g, ALLOC, -, SET, H5R_DSET_REG_REF_BUF_SIZE) + /* Opaque reference type */ + H5T_INIT_TYPE(REF, H5T_STD_REF_g, ALLOC, -, NOSET, -) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") + ref = dt; /* Keep type for later */ /* * Register conversion functions beginning with the most general and @@ -1034,7 +1095,11 @@ H5T__init_package(void) status |= H5T__register_int(H5T_PERS_SOFT, "enum_f", enum_type, floatpt, H5T__conv_enum_numeric); status |= H5T__register_int(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T__conv_vlen); status |= H5T__register_int(H5T_PERS_SOFT, "array", array, array, H5T__conv_array); - status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_order_opt); + status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_noop); + status |= H5T__register_int(H5T_PERS_SOFT, "regref", regref, regref, H5T__conv_noop); + status |= H5T__register_int(H5T_PERS_SOFT, "ref", ref, ref, H5T__conv_ref); + status |= H5T__register_int(H5T_PERS_SOFT, "objref_ref", objref, ref, H5T__conv_ref); + status |= H5T__register_int(H5T_PERS_SOFT, "regref_ref", regref, ref, H5T__conv_ref); /* * Native conversions should be listed last since we can use hardware to @@ -1045,80 +1110,123 @@ H5T__init_package(void) */ /* floating point */ - status |= 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); + status |= + 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 |= H5T__register_int(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble); - status |= 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); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ldbl", native_double, native_ldouble, H5T__conv_double_ldouble); + status |= + 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 |= H5T__register_int(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ullong", native_llong, native_ullong, H5T__conv_llong_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_llong", native_ullong, native_llong, H5T__conv_ullong_llong); status |= H5T__register_int(H5T_PERS_HARD, "llong_long", native_llong, native_long, H5T__conv_llong_long); - status |= H5T__register_int(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short); - status |= H5T__register_int(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, H5T__conv_ullong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ulong", native_llong, native_ulong, H5T__conv_llong_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_long", native_ullong, native_long, H5T__conv_ullong_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_ulong", native_ullong, native_ulong, H5T__conv_ullong_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_short", native_llong, native_short, H5T__conv_llong_short); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ushort", native_llong, native_ushort, H5T__conv_llong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_short", native_ullong, native_short, H5T__conv_ullong_short); + status |= H5T__register_int(H5T_PERS_HARD, "ullong_ushort", native_ullong, native_ushort, + H5T__conv_ullong_ushort); status |= H5T__register_int(H5T_PERS_HARD, "llong_int", native_llong, native_int, H5T__conv_llong_int); status |= H5T__register_int(H5T_PERS_HARD, "llong_uint", native_llong, native_uint, H5T__conv_llong_uint); status |= H5T__register_int(H5T_PERS_HARD, "ullong_int", native_ullong, native_int, H5T__conv_ullong_int); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint); - status |= H5T__register_int(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_uint", native_ullong, native_uint, H5T__conv_ullong_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_schar", native_llong, native_schar, H5T__conv_llong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_uchar", native_llong, native_uchar, H5T__conv_llong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_schar", native_ullong, native_schar, H5T__conv_ullong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_uchar", native_ullong, native_uchar, H5T__conv_ullong_uchar); /* From long */ status |= H5T__register_int(H5T_PERS_HARD, "long_llong", native_long, native_llong, H5T__conv_long_llong); - status |= H5T__register_int(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ullong", native_long, native_ullong, H5T__conv_long_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_llong", native_ulong, native_llong, H5T__conv_ulong_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ullong", native_ulong, native_ullong, H5T__conv_ulong_ullong); status |= H5T__register_int(H5T_PERS_HARD, "long_ulong", native_long, native_ulong, H5T__conv_long_ulong); status |= H5T__register_int(H5T_PERS_HARD, "ulong_long", native_ulong, native_long, H5T__conv_ulong_long); status |= H5T__register_int(H5T_PERS_HARD, "long_short", native_long, native_short, H5T__conv_long_short); - status |= H5T__register_int(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ushort", native_long, native_ushort, H5T__conv_long_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_short", native_ulong, native_short, H5T__conv_ulong_short); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ushort", native_ulong, native_ushort, H5T__conv_ulong_ushort); status |= H5T__register_int(H5T_PERS_HARD, "long_int", native_long, native_int, H5T__conv_long_int); status |= H5T__register_int(H5T_PERS_HARD, "long_uint", native_long, native_uint, H5T__conv_long_uint); status |= H5T__register_int(H5T_PERS_HARD, "ulong_int", native_ulong, native_int, H5T__conv_ulong_int); status |= H5T__register_int(H5T_PERS_HARD, "ulong_uint", native_ulong, native_uint, H5T__conv_ulong_uint); status |= H5T__register_int(H5T_PERS_HARD, "long_schar", native_long, native_schar, H5T__conv_long_schar); status |= H5T__register_int(H5T_PERS_HARD, "long_uchar", native_long, native_uchar, H5T__conv_long_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_schar", native_ulong, native_schar, H5T__conv_ulong_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_uchar", native_ulong, native_uchar, H5T__conv_ulong_uchar); /* From short */ - status |= H5T__register_int(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong); - status |= H5T__register_int(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, H5T__conv_ushort_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_llong", native_short, native_llong, H5T__conv_short_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ullong", native_short, native_ullong, H5T__conv_short_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_llong", native_ushort, native_llong, H5T__conv_ushort_llong); + status |= H5T__register_int(H5T_PERS_HARD, "ushort_ullong", native_ushort, native_ullong, + H5T__conv_ushort_ullong); status |= H5T__register_int(H5T_PERS_HARD, "short_long", native_short, native_long, H5T__conv_short_long); - status |= H5T__register_int(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ulong", native_short, native_ulong, H5T__conv_short_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_long", native_ushort, native_long, H5T__conv_ushort_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_ulong", native_ushort, native_ulong, H5T__conv_ushort_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ushort", native_short, native_ushort, H5T__conv_short_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_short", native_ushort, native_short, H5T__conv_ushort_short); status |= H5T__register_int(H5T_PERS_HARD, "short_int", native_short, native_int, H5T__conv_short_int); status |= H5T__register_int(H5T_PERS_HARD, "short_uint", native_short, native_uint, H5T__conv_short_uint); status |= H5T__register_int(H5T_PERS_HARD, "ushort_int", native_ushort, native_int, H5T__conv_ushort_int); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint); - status |= H5T__register_int(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar); - status |= H5T__register_int(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_uint", native_ushort, native_uint, H5T__conv_ushort_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "short_schar", native_short, native_schar, H5T__conv_short_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "short_uchar", native_short, native_uchar, H5T__conv_short_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_schar", native_ushort, native_schar, H5T__conv_ushort_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_uchar", native_ushort, native_uchar, H5T__conv_ushort_uchar); /* From int */ status |= H5T__register_int(H5T_PERS_HARD, "int_llong", native_int, native_llong, H5T__conv_int_llong); status |= H5T__register_int(H5T_PERS_HARD, "int_ullong", native_int, native_ullong, H5T__conv_int_ullong); status |= H5T__register_int(H5T_PERS_HARD, "uint_llong", native_uint, native_llong, H5T__conv_uint_llong); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ullong", native_uint, native_ullong, H5T__conv_uint_ullong); status |= H5T__register_int(H5T_PERS_HARD, "int_long", native_int, native_long, H5T__conv_int_long); status |= H5T__register_int(H5T_PERS_HARD, "int_ulong", native_int, native_ulong, H5T__conv_int_ulong); status |= H5T__register_int(H5T_PERS_HARD, "uint_long", native_uint, native_long, H5T__conv_uint_long); @@ -1126,7 +1234,8 @@ H5T__init_package(void) status |= H5T__register_int(H5T_PERS_HARD, "int_short", native_int, native_short, H5T__conv_int_short); status |= H5T__register_int(H5T_PERS_HARD, "int_ushort", native_int, native_ushort, H5T__conv_int_ushort); status |= H5T__register_int(H5T_PERS_HARD, "uint_short", native_uint, native_short, H5T__conv_uint_short); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ushort", native_uint, native_ushort, H5T__conv_uint_ushort); status |= H5T__register_int(H5T_PERS_HARD, "int_uint", native_int, native_uint, H5T__conv_int_uint); status |= H5T__register_int(H5T_PERS_HARD, "uint_int", native_uint, native_int, H5T__conv_uint_int); status |= H5T__register_int(H5T_PERS_HARD, "int_schar", native_int, native_schar, H5T__conv_int_schar); @@ -1135,44 +1244,68 @@ H5T__init_package(void) status |= H5T__register_int(H5T_PERS_HARD, "uint_uchar", native_uint, native_uchar, H5T__conv_uint_uchar); /* From char */ - status |= H5T__register_int(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_llong", native_schar, native_llong, H5T__conv_schar_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ullong", native_schar, native_ullong, H5T__conv_schar_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_llong", native_uchar, native_llong, H5T__conv_uchar_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ullong", native_uchar, native_ullong, H5T__conv_uchar_ullong); status |= H5T__register_int(H5T_PERS_HARD, "schar_long", native_schar, native_long, H5T__conv_schar_long); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ulong", native_schar, native_ulong, H5T__conv_schar_ulong); status |= H5T__register_int(H5T_PERS_HARD, "uchar_long", native_uchar, native_long, H5T__conv_uchar_long); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ulong", native_uchar, native_ulong, H5T__conv_uchar_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_short", native_schar, native_short, H5T__conv_schar_short); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ushort", native_schar, native_ushort, H5T__conv_schar_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_short", native_uchar, native_short, H5T__conv_uchar_short); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ushort", native_uchar, native_ushort, H5T__conv_uchar_ushort); status |= H5T__register_int(H5T_PERS_HARD, "schar_int", native_schar, native_int, H5T__conv_schar_int); status |= H5T__register_int(H5T_PERS_HARD, "schar_uint", native_schar, native_uint, H5T__conv_schar_uint); status |= H5T__register_int(H5T_PERS_HARD, "uchar_int", native_uchar, native_int, H5T__conv_uchar_int); status |= H5T__register_int(H5T_PERS_HARD, "uchar_uint", native_uchar, native_uint, H5T__conv_uchar_uint); - status |= H5T__register_int(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_uchar", native_schar, native_uchar, H5T__conv_schar_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_schar", native_uchar, native_schar, H5T__conv_uchar_schar); /* From char to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float); - status |= H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double); - status |= H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_flt", native_schar, native_float, H5T__conv_schar_float); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double); + status |= + H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble); /* From unsigned char to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double); - status |= H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_flt", native_uchar, native_float, H5T__conv_uchar_float); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double); + status |= + H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble); /* From short to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float); - status |= H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double); - status |= H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "short_flt", native_short, native_float, H5T__conv_short_float); + status |= + H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double); + status |= + H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble); /* From unsigned short to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double); - status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, H5T__conv_ushort_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_flt", native_ushort, native_float, H5T__conv_ushort_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double); + status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, + H5T__conv_ushort_ldouble); /* From int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "int_flt", native_int, native_float, H5T__conv_int_float); @@ -1182,51 +1315,74 @@ H5T__init_package(void) /* From unsigned int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "uint_flt", native_uint, native_float, H5T__conv_uint_float); status |= H5T__register_int(H5T_PERS_HARD, "uint_dbl", native_uint, native_double, H5T__conv_uint_double); - status |= H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble); /* From long to floats */ status |= H5T__register_int(H5T_PERS_HARD, "long_flt", native_long, native_float, H5T__conv_long_float); status |= H5T__register_int(H5T_PERS_HARD, "long_dbl", native_long, native_double, H5T__conv_long_double); - status |= H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble); /* From unsigned long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double); - status |= H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_flt", native_ulong, native_float, H5T__conv_ulong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble); /* From long long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float); - status |= H5T__register_int(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T__conv_llong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T__conv_llong_double); #ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE - status |= H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble); #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ /* From unsigned long long to floats */ - status |= H5T__register_int(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float); - status |= H5T__register_int(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T__conv_ullong_float); + status |= + H5T__register_int(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T__conv_ullong_double); #ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE - status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T__conv_ullong_ldouble); + status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, + H5T__conv_ullong_ldouble); #endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */ /* From floats to char */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_schar", native_float, native_schar, H5T__conv_float_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar); /* From floats to unsigned char */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_uchar", native_float, native_uchar, H5T__conv_float_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar); /* From floats to short */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_short", native_float, native_short, H5T__conv_float_short); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short); /* From floats to unsigned short */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, H5T__conv_ldouble_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ushort", native_float, native_ushort, H5T__conv_float_ushort); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort); + status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, + H5T__conv_ldouble_ushort); /* From floats to int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_int", native_float, native_int, H5T__conv_float_int); @@ -1236,30 +1392,41 @@ H5T__init_package(void) /* From floats to unsigned int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_uint", native_float, native_uint, H5T__conv_float_uint); status |= H5T__register_int(H5T_PERS_HARD, "dbl_uint", native_double, native_uint, H5T__conv_double_uint); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint); /* From floats to long */ status |= H5T__register_int(H5T_PERS_HARD, "flt_long", native_float, native_long, H5T__conv_float_long); status |= H5T__register_int(H5T_PERS_HARD, "dbl_long", native_double, native_long, H5T__conv_double_long); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long); /* From floats to unsigned long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong); - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ulong", native_float, native_ulong, H5T__conv_float_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong); /* From floats to long long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T__conv_float_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T__conv_double_llong); #ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong); + status |= + H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */ /* From floats to unsigned long long */ - status |= H5T__register_int(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong); - status |= H5T__register_int(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_ullong", native_float, native_ullong, H5T__conv_float_ullong); + status |= + H5T__register_int(H5T_PERS_HARD, "dbl_ullong", native_double, native_ullong, H5T__conv_double_ullong); #if H5T_CONV_INTERNAL_LDOUBLE_ULLONG - status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong); + status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, + H5T__conv_ldouble_ullong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_ULLONG */ /* @@ -1272,7 +1439,7 @@ H5T__init_package(void) /* Initialize the +/- Infinity values for floating-point types */ status |= H5T__init_inf(); - if(status < 0) + if (status < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") /* Register datatype creation property class properties here. See similar @@ -1280,13 +1447,13 @@ H5T__init_package(void) */ /* Only register the default property list if it hasn't been created yet */ - if(H5P_LST_DATATYPE_CREATE_ID_g == (-1)) { + if (H5P_LST_DATATYPE_CREATE_ID_g == (-1)) { /* ========== Datatype Creation Property Class Initialization ============*/ HDassert(H5P_CLS_DATATYPE_CREATE_g != NULL); /* Register the default datatype creation property list */ - if((H5P_LST_DATATYPE_CREATE_ID_g = H5P_create_id(H5P_CLS_DATATYPE_CREATE_g, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") + if ((H5P_LST_DATATYPE_CREATE_ID_g = H5P_create_id(H5P_CLS_DATATYPE_CREATE_g, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* Mark "top" of interface as initialized, too */ @@ -1294,32 +1461,33 @@ H5T__init_package(void) done: /* General cleanup */ - if(compound != NULL) + if (compound != NULL) (void)H5T_close_real(compound); - if(enum_type != NULL) + if (enum_type != NULL) (void)H5T_close_real(enum_type); - if(vlen != NULL) + if (vlen != NULL) (void)H5T_close_real(vlen); - if(array != NULL) + if (array != NULL) (void)H5T_close_real(array); /* Error cleanup */ - if(ret_value < 0) { - if(dt) { + if (ret_value < 0) { + if (dt) { /* Check if we should call H5T_close_real or H5FL_FREE */ - if(copied_dtype) + if (copied_dtype) (void)H5T_close_real(dt); else { + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); - dt = H5FL_FREE(H5T_t, dt); + dt = H5FL_FREE(H5T_t, dt); } /* end else */ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_package() */ - /*------------------------------------------------------------------------- * Function: H5T__unlock_cb * @@ -1337,14 +1505,14 @@ H5T__init_package(void) 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; + H5T_t *dt = (H5T_t *)_dt; + int * n = (int *)_udata; FUNC_ENTER_STATIC_NOERR HDassert(dt && dt->shared); - if(H5T_STATE_IMMUTABLE==dt->shared->state) { + if (H5T_STATE_IMMUTABLE == dt->shared->state) { dt->shared->state = H5T_STATE_RDONLY; (*n)++; } /* end if */ @@ -1352,7 +1520,6 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__unlock_cb() */ - /*------------------------------------------------------------------------- * Function: H5T_top_term_package * @@ -1370,66 +1537,70 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) int H5T_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5T_top_package_initialize_s) { + if (H5T_top_package_initialize_s) { /* Unregister all conversion functions */ - if(H5T_g.path) { + if (H5T_g.path) { int i, nprint = 0; - for(i = 0; i < H5T_g.npaths; i++) { + for (i = 0; i < H5T_g.npaths; i++) { H5T_path_t *path; path = H5T_g.path[i]; HDassert(path); - if(path->conv.u.app_func) { - H5T__print_stats(path, &nprint/*in,out*/); + if (path->conv.u.app_func) { + H5T__print_stats(path, &nprint /*in,out*/); path->cdata.command = H5T_CONV_FREE; - if(path->conv.is_app) { - if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ else { - if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); } /* end if */ #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end else */ - } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ - if(path->src) + if (path->src) (void)H5T_close_real(path->src); - if(path->dst) + if (path->dst) (void)H5T_close_real(path->dst); - path = H5FL_FREE(H5T_path_t, path); + path = H5FL_FREE(H5T_path_t, path); H5T_g.path[i] = NULL; } /* end for */ /* Clear conversion tables */ - H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); + H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); H5T_g.npaths = 0; H5T_g.apaths = 0; - H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); - H5T_g.nsoft = 0; - H5T_g.asoft = 0; + H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); + H5T_g.nsoft = 0; + H5T_g.asoft = 0; n++; } /* end if */ @@ -1440,120 +1611,120 @@ H5T_top_term_package(void) H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); /* Release all datatype IDs */ - if(H5I_nmembers(H5I_DATATYPE) > 0) { + if (H5I_nmembers(H5I_DATATYPE) > 0) { (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Reset all the datatype IDs */ - if(H5T_IEEE_F32BE_g > 0) { - H5T_IEEE_F32BE_g = FAIL; - H5T_IEEE_F32LE_g = FAIL; - H5T_IEEE_F64BE_g = FAIL; - H5T_IEEE_F64LE_g = FAIL; - - H5T_STD_I8BE_g = FAIL; - H5T_STD_I8LE_g = FAIL; - H5T_STD_I16BE_g = FAIL; - H5T_STD_I16LE_g = FAIL; - H5T_STD_I32BE_g = FAIL; - H5T_STD_I32LE_g = FAIL; - H5T_STD_I64BE_g = FAIL; - H5T_STD_I64LE_g = FAIL; - H5T_STD_U8BE_g = FAIL; - H5T_STD_U8LE_g = FAIL; - H5T_STD_U16BE_g = FAIL; - H5T_STD_U16LE_g = FAIL; - H5T_STD_U32BE_g = FAIL; - H5T_STD_U32LE_g = FAIL; - H5T_STD_U64BE_g = FAIL; - H5T_STD_U64LE_g = FAIL; - H5T_STD_B8BE_g = FAIL; - H5T_STD_B8LE_g = FAIL; - H5T_STD_B16BE_g = FAIL; - H5T_STD_B16LE_g = FAIL; - H5T_STD_B32BE_g = FAIL; - H5T_STD_B32LE_g = FAIL; - H5T_STD_B64BE_g = FAIL; - H5T_STD_B64LE_g = FAIL; - H5T_STD_REF_OBJ_g = FAIL; - H5T_STD_REF_DSETREG_g = FAIL; - - H5T_UNIX_D32BE_g = FAIL; - H5T_UNIX_D32LE_g = FAIL; - H5T_UNIX_D64BE_g = FAIL; - H5T_UNIX_D64LE_g = FAIL; - - H5T_C_S1_g = FAIL; - - H5T_FORTRAN_S1_g = FAIL; - - H5T_NATIVE_SCHAR_g = FAIL; - H5T_NATIVE_UCHAR_g = FAIL; - H5T_NATIVE_SHORT_g = FAIL; - H5T_NATIVE_USHORT_g = FAIL; - H5T_NATIVE_INT_g = FAIL; - H5T_NATIVE_UINT_g = FAIL; - H5T_NATIVE_LONG_g = FAIL; - H5T_NATIVE_ULONG_g = FAIL; - H5T_NATIVE_LLONG_g = FAIL; - H5T_NATIVE_ULLONG_g = FAIL; - H5T_NATIVE_FLOAT_g = FAIL; - H5T_NATIVE_DOUBLE_g = FAIL; -#if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_NATIVE_LDOUBLE_g = FAIL; + if (H5T_IEEE_F32BE_g > 0) { + H5T_IEEE_F32BE_g = FAIL; + H5T_IEEE_F32LE_g = FAIL; + H5T_IEEE_F64BE_g = FAIL; + H5T_IEEE_F64LE_g = FAIL; + + H5T_STD_I8BE_g = FAIL; + H5T_STD_I8LE_g = FAIL; + H5T_STD_I16BE_g = FAIL; + H5T_STD_I16LE_g = FAIL; + H5T_STD_I32BE_g = FAIL; + H5T_STD_I32LE_g = FAIL; + H5T_STD_I64BE_g = FAIL; + H5T_STD_I64LE_g = FAIL; + H5T_STD_U8BE_g = FAIL; + H5T_STD_U8LE_g = FAIL; + H5T_STD_U16BE_g = FAIL; + H5T_STD_U16LE_g = FAIL; + H5T_STD_U32BE_g = FAIL; + H5T_STD_U32LE_g = FAIL; + H5T_STD_U64BE_g = FAIL; + H5T_STD_U64LE_g = FAIL; + H5T_STD_B8BE_g = FAIL; + H5T_STD_B8LE_g = FAIL; + H5T_STD_B16BE_g = FAIL; + H5T_STD_B16LE_g = FAIL; + H5T_STD_B32BE_g = FAIL; + H5T_STD_B32LE_g = FAIL; + H5T_STD_B64BE_g = FAIL; + H5T_STD_B64LE_g = FAIL; + H5T_STD_REF_OBJ_g = FAIL; + H5T_STD_REF_DSETREG_g = FAIL; + H5T_STD_REF_g = FAIL; + + H5T_UNIX_D32BE_g = FAIL; + H5T_UNIX_D32LE_g = FAIL; + H5T_UNIX_D64BE_g = FAIL; + H5T_UNIX_D64LE_g = FAIL; + + H5T_C_S1_g = FAIL; + + H5T_FORTRAN_S1_g = FAIL; + + H5T_NATIVE_SCHAR_g = FAIL; + H5T_NATIVE_UCHAR_g = FAIL; + H5T_NATIVE_SHORT_g = FAIL; + H5T_NATIVE_USHORT_g = FAIL; + H5T_NATIVE_INT_g = FAIL; + H5T_NATIVE_UINT_g = FAIL; + H5T_NATIVE_LONG_g = FAIL; + H5T_NATIVE_ULONG_g = FAIL; + H5T_NATIVE_LLONG_g = FAIL; + H5T_NATIVE_ULLONG_g = FAIL; + H5T_NATIVE_FLOAT_g = FAIL; + H5T_NATIVE_DOUBLE_g = FAIL; +#if H5_SIZEOF_LONG_DOUBLE != 0 + H5T_NATIVE_LDOUBLE_g = FAIL; #endif - H5T_NATIVE_B8_g = FAIL; - H5T_NATIVE_B16_g = FAIL; - H5T_NATIVE_B32_g = FAIL; - H5T_NATIVE_B64_g = FAIL; - H5T_NATIVE_OPAQUE_g = FAIL; - H5T_NATIVE_HADDR_g = FAIL; - H5T_NATIVE_HSIZE_g = FAIL; - H5T_NATIVE_HSSIZE_g = FAIL; - H5T_NATIVE_HERR_g = FAIL; - H5T_NATIVE_HBOOL_g = FAIL; - - H5T_NATIVE_INT8_g = FAIL; - H5T_NATIVE_UINT8_g = FAIL; - H5T_NATIVE_INT_LEAST8_g = FAIL; - H5T_NATIVE_UINT_LEAST8_g = FAIL; - H5T_NATIVE_INT_FAST8_g = FAIL; - H5T_NATIVE_UINT_FAST8_g = FAIL; - - H5T_NATIVE_INT16_g = FAIL; - H5T_NATIVE_UINT16_g = FAIL; - H5T_NATIVE_INT_LEAST16_g = FAIL; - H5T_NATIVE_UINT_LEAST16_g = FAIL; - H5T_NATIVE_INT_FAST16_g = FAIL; - H5T_NATIVE_UINT_FAST16_g = FAIL; - - H5T_NATIVE_INT32_g = FAIL; - H5T_NATIVE_UINT32_g = FAIL; - H5T_NATIVE_INT_LEAST32_g = FAIL; - H5T_NATIVE_UINT_LEAST32_g = FAIL; - H5T_NATIVE_INT_FAST32_g = FAIL; - H5T_NATIVE_UINT_FAST32_g = FAIL; - - H5T_NATIVE_INT64_g = FAIL; - H5T_NATIVE_UINT64_g = FAIL; - H5T_NATIVE_INT_LEAST64_g = FAIL; - H5T_NATIVE_UINT_LEAST64_g = FAIL; - H5T_NATIVE_INT_FAST64_g = FAIL; - H5T_NATIVE_UINT_FAST64_g = FAIL; + H5T_NATIVE_B8_g = FAIL; + H5T_NATIVE_B16_g = FAIL; + H5T_NATIVE_B32_g = FAIL; + H5T_NATIVE_B64_g = FAIL; + H5T_NATIVE_OPAQUE_g = FAIL; + H5T_NATIVE_HADDR_g = FAIL; + H5T_NATIVE_HSIZE_g = FAIL; + H5T_NATIVE_HSSIZE_g = FAIL; + H5T_NATIVE_HERR_g = FAIL; + H5T_NATIVE_HBOOL_g = FAIL; + + H5T_NATIVE_INT8_g = FAIL; + H5T_NATIVE_UINT8_g = FAIL; + H5T_NATIVE_INT_LEAST8_g = FAIL; + H5T_NATIVE_UINT_LEAST8_g = FAIL; + H5T_NATIVE_INT_FAST8_g = FAIL; + H5T_NATIVE_UINT_FAST8_g = FAIL; + + H5T_NATIVE_INT16_g = FAIL; + H5T_NATIVE_UINT16_g = FAIL; + H5T_NATIVE_INT_LEAST16_g = FAIL; + H5T_NATIVE_UINT_LEAST16_g = FAIL; + H5T_NATIVE_INT_FAST16_g = FAIL; + H5T_NATIVE_UINT_FAST16_g = FAIL; + + H5T_NATIVE_INT32_g = FAIL; + H5T_NATIVE_UINT32_g = FAIL; + H5T_NATIVE_INT_LEAST32_g = FAIL; + H5T_NATIVE_UINT_LEAST32_g = FAIL; + H5T_NATIVE_INT_FAST32_g = FAIL; + H5T_NATIVE_UINT_FAST32_g = FAIL; + + H5T_NATIVE_INT64_g = FAIL; + H5T_NATIVE_UINT64_g = FAIL; + H5T_NATIVE_INT_LEAST64_g = FAIL; + H5T_NATIVE_UINT_LEAST64_g = FAIL; + H5T_NATIVE_INT_FAST64_g = FAIL; + H5T_NATIVE_UINT_FAST64_g = FAIL; n++; } /* end if */ - /* Mark "top" of interface as closed */ - if(0 == n) + /* Mark "top" of interface as closed */ + if (0 == n) H5T_top_package_initialize_s = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5T_top_term_package() */ - /*------------------------------------------------------------------------- * Function: H5T_term_package * @@ -1575,11 +1746,11 @@ H5T_top_term_package(void) int H5T_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { /* Sanity check */ HDassert(0 == H5I_nmembers(H5I_DATATYPE)); HDassert(FALSE == H5T_top_package_initialize_s); @@ -1588,13 +1759,54 @@ H5T_term_package(void) n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); /* Mark interface as closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5T_term_package() */ +/*------------------------------------------------------------------------- + * Function: H5T__close_cb + * + * Purpose: Called when the ref count reaches zero on the datatype's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__close_cb(H5T_t *dt) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(dt); + HDassert(dt->shared); + + /* If this datatype is VOL-managed (i.e.: has a VOL object), + * close it through the VOL connector. + */ + if (NULL != dt->vol_obj) { + /* Close the connector-managed datatype data */ + if (H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") + + /* Free the VOL object */ + if (H5VL_free_object(dt->vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + dt->vol_obj = NULL; + } /* end if */ + + /* Close the datatype */ + if (H5T_close(dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__close_cb() */ /*------------------------------------------------------------------------- * Function: H5Tcreate @@ -1618,29 +1830,28 @@ H5T_term_package(void) hid_t H5Tcreate(H5T_class_t type, size_t size) { - H5T_t *dt = NULL; /* New datatype constructed */ - hid_t ret_value; /* Return value */ + H5T_t *dt = NULL; /* New datatype constructed */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "Ttz", type, size); /* check args. We support string (fixed-size or variable-length) now. */ - if(size <= 0 && size != H5T_VARIABLE) + if (size <= 0 && size != H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive") /* create the type */ - if(NULL == (dt = H5T__create(type, size))) + if (NULL == (dt = H5T__create(type, size))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type") /* Get an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcreate() */ - /*------------------------------------------------------------------------- * Function: H5Tcopy * @@ -1662,33 +1873,41 @@ H5Tcreate(H5T_class_t type, size_t size) hid_t H5Tcopy(hid_t obj_id) { - H5T_t *dt = NULL; /* Pointer to the datatype to copy */ - H5T_t *new_dt = NULL; /* Pointer to the new datatype */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *dt = NULL; /* Pointer to the datatype to copy */ + H5T_t *new_dt = NULL; /* Pointer to the new datatype */ + hid_t dset_tid = H5I_INVALID_HID; /* Datatype ID from dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); - switch(H5I_get_type(obj_id)) { + switch (H5I_get_type(obj_id)) { case H5I_DATATYPE: /* The argument is a datatype handle */ - if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) + if (NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "obj_id is not a datatype ID") break; - case H5I_DATASET: - { - H5D_t *dset; /* Dataset structure */ + case H5I_DATASET: { + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ /* The argument is a dataset handle */ - if(NULL == (dset = (H5D_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataset") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a dataset ID") - /* Get the datatype from the dataset */ - if(NULL == (dt = H5D_typeof(dset))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to get the dataset datatype") - } - break; + /* Get the datatype from the dataset + * NOTE: This will have to be closed after we're done with it. + */ + if (H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &dset_tid) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, + "unable to get datatype from the dataset") + + /* Unwrap the type ID */ + if (NULL == (dt = (H5T_t *)H5I_object(dset_tid))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, + "received invalid datatype from the dataset") + } break; case H5I_UNINIT: case H5I_BADID: @@ -1696,36 +1915,43 @@ H5Tcopy(hid_t obj_id) case H5I_GROUP: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: + case H5I_MAP: 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_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype or dataset") } /* end switch */ /* Copy datatype */ - if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) + if (NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy"); /* Get an ID for the copied datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype atom") done: + + /* If we got a type ID from a passed-in dataset, we need to close that */ + if (dset_tid != H5I_INVALID_HID) + if (H5I_dec_app_ref(dset_tid) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADATOM, FAIL, "problem freeing temporary dataset type ID") + /* Close the new datatype on errors */ - if(H5I_INVALID_HID == ret_value) - if(new_dt && H5T_close_real(new_dt) < 0) + if (H5I_INVALID_HID == ret_value) + if (new_dt && H5T_close_real(new_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release datatype info") FUNC_LEAVE_API(ret_value) } /* end H5Tcopy() */ - /*------------------------------------------------------------------------- * Function: H5Tclose * @@ -1740,27 +1966,26 @@ H5Tcopy(hid_t obj_id) herr_t H5Tclose(hid_t type_id) { - H5T_t *dt; /* Pointer to datatype to close */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Pointer to datatype to close */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_IMMUTABLE == dt->shared->state) + if (H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(type_id) < 0) + if (H5I_dec_app_ref(type_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) } /* end H5Tclose() */ - /*------------------------------------------------------------------------- * Function: H5Tequal * @@ -1778,17 +2003,17 @@ H5Tclose(hid_t type_id) htri_t H5Tequal(hid_t type1_id, hid_t type2_id) { - const H5T_t *dt1; /* Pointer to first datatype */ - const H5T_t *dt2; /* Pointer to second datatype */ - htri_t ret_value; /* Return value */ + const H5T_t *dt1; /* Pointer to first datatype */ + const H5T_t *dt2; /* Pointer to second datatype */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", type1_id, type2_id); /* check args */ - if(NULL == (dt1 = (H5T_t *)H5I_object_verify(type1_id, H5I_DATATYPE))) + if (NULL == (dt1 = (H5T_t *)H5I_object_verify(type1_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(NULL == (dt2 = (H5T_t *)H5I_object_verify(type2_id, H5I_DATATYPE))) + if (NULL == (dt2 = (H5T_t *)H5I_object_verify(type2_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") ret_value = (0 == H5T_cmp(dt1, dt2, FALSE)) ? TRUE : FALSE; @@ -1797,7 +2022,6 @@ H5Tequal(hid_t type1_id, hid_t type2_id) FUNC_LEAVE_API(ret_value) } /* end H5Tequal() */ - /*------------------------------------------------------------------------- * Function: H5Tlock * @@ -1819,26 +2043,25 @@ H5Tequal(hid_t type1_id, hid_t type2_id) herr_t H5Tlock(hid_t type_id) { - H5T_t *dt; /* Datatype to operate on */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + if (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named datatype") - if(H5T_lock(dt, TRUE) < 0) + if (H5T_lock(dt, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tlock() */ - /*------------------------------------------------------------------------- * Function: H5Tget_class * @@ -1856,14 +2079,14 @@ H5Tlock(hid_t type_id) H5T_class_t H5Tget_class(hid_t type_id) { - H5T_t *dt; /* Pointer to datatype */ - H5T_class_t ret_value; /* Return value */ + H5T_t * dt; /* Pointer to datatype */ + H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) H5TRACE1("Tt", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype") /* Set return value */ @@ -1873,7 +2096,6 @@ H5Tget_class(hid_t type_id) FUNC_LEAVE_API(ret_value) } /* end H5Tget_class() */ - /*------------------------------------------------------------------------- * Function: H5T_get_class * @@ -1891,27 +2113,26 @@ H5Tget_class(hid_t type_id) H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal) { - H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ + H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5T_NO_CLASS) HDassert(dt); /* Externally, a VL string is a string; internally, a VL string is a VL. */ - if(internal) { - ret_value=dt->shared->type; + if (internal) { + ret_value = dt->shared->type; } else { - if(H5T_IS_VL_STRING(dt->shared)) - ret_value=H5T_STRING; + if (H5T_IS_VL_STRING(dt->shared)) + ret_value = H5T_STRING; else - ret_value=dt->shared->type; + ret_value = dt->shared->type; } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_get_class() */ - +} /* end H5T_get_class() */ /*------------------------------------------------------------------------- * Function: H5Tdetect_class @@ -1928,27 +2149,26 @@ H5T_get_class(const H5T_t *dt, htri_t internal) htri_t H5Tdetect_class(hid_t type, H5T_class_t cls) { - H5T_t *dt; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "iTt", type, cls); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype") - if(!(cls > H5T_NO_CLASS && cls < H5T_NCLASSES)) + if (!(cls > H5T_NO_CLASS && cls < H5T_NCLASSES)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a datatype class") /* Set return value */ - if((ret_value = H5T_detect_class(dt, cls, TRUE)) < 0) + if ((ret_value = H5T_detect_class(dt, cls, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_NO_CLASS, "can't get datatype class") done: FUNC_LEAVE_API(ret_value) } /* end H5Tdetect_class() */ - /*------------------------------------------------------------------------- * Function: H5T_detect_class * @@ -1965,8 +2185,8 @@ H5Tdetect_class(hid_t type, H5T_class_t cls) htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) { - unsigned i; - htri_t ret_value = FALSE; /* Return value */ + unsigned i; + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1978,26 +2198,27 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) * string belongs to the H5T_VLEN class, which would otherwise return * true. -QAK) */ - if(from_api && H5T_IS_VL_STRING(dt->shared)) + if (from_api && H5T_IS_VL_STRING(dt->shared)) HGOTO_DONE(H5T_STRING == cls); /* Check if this type is the correct type */ - if(dt->shared->type == cls) + if (dt->shared->type == cls) HGOTO_DONE(TRUE); /* check for types that might have the correct type as a component */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - htri_t nested_ret; /* Return value from nested call */ + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + htri_t nested_ret; /* Return value from nested call */ /* Check if this field's type is the correct type */ - if(dt->shared->u.compnd.memb[i].type->shared->type == cls) + if (dt->shared->u.compnd.memb[i].type->shared->type == cls) HGOTO_DONE(TRUE); /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) - if((nested_ret = H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api)) != FALSE) + if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) + if ((nested_ret = H5T_detect_class(dt->shared->u.compnd.memb[i].type, cls, from_api)) != + FALSE) HGOTO_DONE(nested_ret); } /* end for */ break; @@ -2024,7 +2245,6 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_detect_class() */ - /*------------------------------------------------------------------------- * Function: H5Tis_variable_str * @@ -2040,25 +2260,24 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) htri_t H5Tis_variable_str(hid_t dtype_id) { - H5T_t *dt; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", dtype_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ - if((ret_value = H5T_is_variable_str(dt)) < 0) + if ((ret_value = H5T_is_variable_str(dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "can't determine if datatype is VL-string") done: FUNC_LEAVE_API(ret_value) } /* end H5Tis_variable_str() */ - /*------------------------------------------------------------------------- * Function: H5T_is_variable_str * @@ -2079,7 +2298,6 @@ H5T_is_variable_str(const H5T_t *dt) FUNC_LEAVE_NOAPI(H5T_IS_VL_STRING(dt->shared)) } /* end H5T_is_variable_str() */ - /*------------------------------------------------------------------------- * Function: H5Tget_size * @@ -2099,14 +2317,14 @@ H5T_is_variable_str(const H5T_t *dt) size_t H5Tget_size(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* size */ @@ -2116,7 +2334,6 @@ H5Tget_size(hid_t type_id) FUNC_LEAVE_API(ret_value) } /* end H5Tget_size() */ - /*------------------------------------------------------------------------- * Function: H5Tset_size * @@ -2144,35 +2361,34 @@ H5Tget_size(hid_t type_id) herr_t H5Tset_size(hid_t type_id, size_t size) { - H5T_t *dt; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, size); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") - if(size <= 0 && size != H5T_VARIABLE) + if (size <= 0 && size != H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive") - if(size == H5T_VARIABLE && !H5T_IS_STRING(dt->shared)) + if (size == H5T_VARIABLE && !H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length") - if(H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - if(H5T_REFERENCE == dt->shared->type) + if (H5T_REFERENCE == dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype") /* Modify the datatype */ - if(H5T__set_size(dt, size) < 0) + if (H5T__set_size(dt, size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_size() */ - /*------------------------------------------------------------------------- * Function: H5Tget_super * @@ -2190,29 +2406,29 @@ H5Tset_size(hid_t type_id, size_t size) hid_t H5Tget_super(hid_t type) { - H5T_t *dt; /* Datatype to query */ - H5T_t *super = NULL; /* Supertype */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *dt; /* Datatype to query */ + H5T_t *super = NULL; /* Supertype */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", type); - if(NULL == (dt = (H5T_t *)H5I_object_verify(type,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype") - if(NULL == (super = H5T_get_super(dt))) + if (NULL == (super = H5T_get_super(dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "not a datatype") - if((ret_value = H5I_register(H5I_DATATYPE, super, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, super, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register parent datatype") done: - if(H5I_INVALID_HID == ret_value) - if(super && H5T_close_real(super) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release super datatype info") + if (H5I_INVALID_HID == ret_value) + if (super && H5T_close_real(super) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to release super datatype info") FUNC_LEAVE_API(ret_value) } /* end H5Tget_super() */ - /*------------------------------------------------------------------------- * Function: H5T_get_super * @@ -2237,16 +2453,15 @@ H5T_get_super(const H5T_t *dt) HDassert(dt); - if(!dt->shared->parent) + if (!dt->shared->parent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); - if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) + if (NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_super() */ - /*------------------------------------------------------------------------- * Function: H5T__register_int * @@ -2259,11 +2474,10 @@ H5T_get_super(const H5T_t *dt) *------------------------------------------------------------------------- */ static herr_t -H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_lib_conv_t func) +H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_lib_conv_t func) { - H5T_conv_func_t conv_func; /* Conversion function wrapper */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_conv_func_t conv_func; /* Conversion function wrapper */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2275,18 +2489,18 @@ H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, HDassert(func); /* Set up conversion function wrapper */ - conv_func.is_app = FALSE; + conv_func.is_app = FALSE; conv_func.u.lib_func = func; /* Register conversion */ - if(H5T__register(pers, name, src, dst, &conv_func) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register internal datatype conversion routine") + if (H5T__register(pers, name, src, dst, &conv_func) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to register internal datatype conversion routine") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__register_int() */ - /*------------------------------------------------------------------------- * Function: H5T__register * @@ -2306,16 +2520,15 @@ H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, *------------------------------------------------------------------------- */ static herr_t -H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_conv_func_t *conv) +H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv) { - hid_t tmp_sid = -1, tmp_did = -1; /*temporary data type IDs */ - H5T_path_t *old_path = NULL; /*existing conversion path */ - H5T_path_t *new_path = NULL; /*new conversion path */ - H5T_cdata_t cdata; /*temporary conversion data */ - int nprint=0; /*number of paths shut down */ - int i; /*counter */ - herr_t ret_value = SUCCEED; /*return value */ + hid_t tmp_sid = -1, tmp_did = -1; /*temporary data type IDs */ + H5T_path_t *old_path = NULL; /*existing conversion path */ + H5T_path_t *new_path = NULL; /*new conversion path */ + H5T_cdata_t cdata; /*temporary conversion data */ + int nprint = 0; /*number of paths shut down */ + int i; /*counter */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_STATIC @@ -2323,14 +2536,14 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, HDassert(src); HDassert(dst); HDassert(conv); - HDassert(H5T_PERS_HARD==pers || H5T_PERS_SOFT==pers); + HDassert(H5T_PERS_HARD == pers || H5T_PERS_SOFT == pers); HDassert(name && *name); - if(H5T_PERS_HARD == pers) { + if (H5T_PERS_HARD == pers) { /* Only bother to register the path if it's not a no-op path (for this machine) */ - if(H5T_cmp(src, dst, FALSE)) { + if (H5T_cmp(src, dst, FALSE)) { /* Locate or create a new conversion path */ - if(NULL == (new_path = H5T__path_find_real(src, dst, name, conv))) + if (NULL == (new_path = H5T__path_find_real(src, dst, name, conv))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path") /* Notify all other functions to recalculate private data since some @@ -2339,27 +2552,27 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, * functions for the members, so adding a new function should cause * the list to be recalculated to use the new function. */ - for(i = 0; i < H5T_g.npaths; i++) - if(new_path != H5T_g.path[i]) + for (i = 0; i < H5T_g.npaths; i++) + if (new_path != H5T_g.path[i]) H5T_g.path[i]->cdata.recalc = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Add function to end of soft list */ - if((size_t)H5T_g.nsoft >= H5T_g.asoft) { - size_t na = MAX(32, 2 * H5T_g.asoft); + if ((size_t)H5T_g.nsoft >= H5T_g.asoft) { + size_t na = MAX(32, 2 * H5T_g.asoft); H5T_soft_t *x; - if(NULL == (x = (H5T_soft_t *)H5MM_realloc(H5T_g.soft, na * sizeof(H5T_soft_t)))) + if (NULL == (x = (H5T_soft_t *)H5MM_realloc(H5T_g.soft, na * sizeof(H5T_soft_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") H5T_g.asoft = na; - H5T_g.soft = x; + H5T_g.soft = x; } /* end if */ HDstrncpy(H5T_g.soft[H5T_g.nsoft].name, name, (size_t)H5T_NAMELEN); H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN - 1] = '\0'; - H5T_g.soft[H5T_g.nsoft].src = src->shared->type; - H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; - H5T_g.soft[H5T_g.nsoft].conv = *conv; + H5T_g.soft[H5T_g.nsoft].src = src->shared->type; + H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; + H5T_g.soft[H5T_g.nsoft].conv = *conv; H5T_g.nsoft++; /* @@ -2367,77 +2580,81 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, * conversion function applies should be replaced by a new path that * uses this function. */ - for(i = 1; i < H5T_g.npaths; i++) { + for (i = 1; i < H5T_g.npaths; i++) { old_path = H5T_g.path[i]; HDassert(old_path); /* Does the new soft conversion function apply to this path? */ - if(old_path->is_hard || - old_path->src->shared->type != src->shared->type || - old_path->dst->shared->type != dst->shared->type) + if (old_path->is_hard || old_path->src->shared->type != src->shared->type || + old_path->dst->shared->type != dst->shared->type) continue; - if((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 || - (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query") + if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 || + (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, + "unable to register data types for conv query") HDmemset(&cdata, 0, sizeof cdata); cdata.command = H5T_CONV_INIT; - if(conv->is_app) { - if((conv->u.app_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (conv->is_app) { + if ((conv->u.app_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL, + H5CX_get_dxpl()) < 0) { H5I_dec_ref(tmp_sid); H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; H5E_clear_stack(NULL); continue; } /* end if */ + } /* end if */ + else if ((conv->u.lib_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, + NULL) < 0) { + H5I_dec_ref(tmp_sid); + H5I_dec_ref(tmp_did); + tmp_sid = tmp_did = -1; + H5E_clear_stack(NULL); + continue; } /* end if */ - else - if((conv->u.lib_func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { - H5I_dec_ref(tmp_sid); - H5I_dec_ref(tmp_did); - tmp_sid = tmp_did = -1; - H5E_clear_stack(NULL); - continue; - } /* end if */ /* Create a new conversion path */ - if(NULL == (new_path = H5FL_CALLOC(H5T_path_t))) + if (NULL == (new_path = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN); new_path->name[H5T_NAMELEN - 1] = '\0'; - if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || - NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) + if (NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || + NULL == (new_path->dst = H5T_copy(old_path->dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types") - new_path->conv = *conv; + new_path->conv = *conv; new_path->is_hard = FALSE; - new_path->cdata = cdata; + new_path->cdata = cdata; /* Replace previous path */ H5T_g.path[i] = new_path; - new_path = NULL; /*so we don't free it on error*/ + new_path = NULL; /*so we don't free it on error*/ /* Free old path */ H5T__print_stats(old_path, &nprint); old_path->cdata.command = H5T_CONV_FREE; - if(old_path->conv.is_app) { - if((old_path->conv.u.app_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (old_path->conv.is_app) { + if ((old_path->conv.u.app_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx " - "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.app_func), old_path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx " + "failed to free private data for %s (ignored)\n", + (unsigned long)(old_path->conv.u.app_func), old_path->name); #endif } /* end if */ - } /* end if */ - else - if((old_path->conv.u.lib_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + else if ((old_path->conv.u.lib_func)(tmp_sid, tmp_did, &(old_path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx " - "failed to free private data for %s (ignored)\n", - (unsigned long)(old_path->conv.u.lib_func), old_path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx " + "failed to free private data for %s (ignored)\n", + (unsigned long)(old_path->conv.u.lib_func), old_path->name); #endif - } /* end if */ + } /* end if */ (void)H5T_close_real(old_path->src); (void)H5T_close_real(old_path->dst); old_path = H5FL_FREE(H5T_path_t, old_path); @@ -2450,27 +2667,26 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, /* We don't care about any failures during the freeing process */ H5E_clear_stack(NULL); } /* end for */ - } /* end else */ + } /* end else */ done: - if(ret_value < 0) { - if(new_path) { - if(new_path->src) - (void)H5T_close_real(new_path->src); - if(new_path->dst) - (void)H5T_close_real(new_path->dst); - new_path = H5FL_FREE(H5T_path_t, new_path); + if (ret_value < 0) { + if (new_path) { + if (new_path->src) + (void)H5T_close_real(new_path->src); + if (new_path->dst) + (void)H5T_close_real(new_path->dst); + new_path = H5FL_FREE(H5T_path_t, new_path); } /* end if */ - if(tmp_sid >= 0) - H5I_dec_ref(tmp_sid); - if(tmp_did >= 0) - H5I_dec_ref(tmp_did); + if (tmp_sid >= 0) + H5I_dec_ref(tmp_sid); + if (tmp_did >= 0) + H5I_dec_ref(tmp_did); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__register() */ - /*------------------------------------------------------------------------- * Function: H5Tregister * @@ -2491,42 +2707,40 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, *------------------------------------------------------------------------- */ herr_t -H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, - H5T_conv_t func) +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_conv_func_t conv_func; /* Conversion function wrapper */ - herr_t ret_value = SUCCEED; /*return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "Te*siix", pers, name, src_id, dst_id, func); /* Check args */ - if(H5T_PERS_HARD != pers && H5T_PERS_SOFT != pers) + if (H5T_PERS_HARD != pers && H5T_PERS_SOFT != pers) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid function persistence") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conversion must have a name for debugging") - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id,H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(NULL == (dst = (H5T_t *)H5I_object_verify(dst_id,H5I_DATATYPE))) + if (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(!func) + if (!func) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function specified") /* Set up conversion function wrapper */ - conv_func.is_app = TRUE; + conv_func.is_app = TRUE; conv_func.u.app_func = func; /* Go register the function */ - if(H5T__register(pers, name, src, dst, &conv_func) < 0) + if (H5T__register(pers, name, src, dst, &conv_func) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register conversion function") done: FUNC_LEAVE_API(ret_value) } /* end H5Tregister() */ - /*------------------------------------------------------------------------- * Function: H5T__unregister * @@ -2543,47 +2757,44 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, *------------------------------------------------------------------------- */ static herr_t -H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, - H5T_conv_t func) +H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func) { - H5T_path_t *path = NULL; /*conversion path */ - H5T_soft_t *soft = NULL; /*soft conversion information */ - int nprint = 0; /*number of paths shut down */ - int i; /*counter */ + H5T_path_t *path = NULL; /*conversion path */ + H5T_soft_t *soft = NULL; /*soft conversion information */ + int nprint = 0; /*number of paths shut down */ + int i; /*counter */ FUNC_ENTER_STATIC_NOERR /* Remove matching entries from the soft list */ - if(H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) { - for(i = H5T_g.nsoft - 1; i >= 0; --i) { + if (H5T_PERS_DONTCARE == pers || H5T_PERS_SOFT == pers) { + for (i = H5T_g.nsoft - 1; i >= 0; --i) { soft = H5T_g.soft + i; HDassert(soft); - if(name && *name && HDstrcmp(name, soft->name)) + if (name && *name && HDstrcmp(name, soft->name) != 0) continue; - if(src && src->shared->type != soft->src) + if (src && src->shared->type != soft->src) continue; - if(dst && dst->shared->type != soft->dst) + if (dst && dst->shared->type != soft->dst) continue; - if(func && func != soft->conv.u.app_func) + if (func && func != soft->conv.u.app_func) continue; - HDmemmove(H5T_g.soft + i, H5T_g.soft + i + 1, (size_t)(H5T_g.nsoft - (i + 1)) * sizeof(H5T_soft_t)); + HDmemmove(H5T_g.soft + i, H5T_g.soft + i + 1, + (size_t)(H5T_g.nsoft - (i + 1)) * sizeof(H5T_soft_t)); --H5T_g.nsoft; } /* end for */ - } /* end if */ + } /* end if */ /* Remove matching conversion paths, except no-op path */ - for(i = H5T_g.npaths - 1; i > 0; --i) { + for (i = H5T_g.npaths - 1; i > 0; --i) { path = H5T_g.path[i]; HDassert(path); /* Not a match */ - if(((H5T_PERS_SOFT == pers && path->is_hard) || - (H5T_PERS_HARD == pers && !path->is_hard)) || - (name && *name && HDstrcmp(name, path->name)) || - (src && H5T_cmp(src, path->src, FALSE)) || - (dst && H5T_cmp(dst, path->dst, FALSE)) || - (func && func != path->conv.u.app_func)) { + if (((H5T_PERS_SOFT == pers && path->is_hard) || (H5T_PERS_HARD == pers && !path->is_hard)) || + (name && *name && HDstrcmp(name, path->name) != 0) || (src && H5T_cmp(src, path->src, FALSE)) || + (dst && H5T_cmp(dst, path->dst, FALSE)) || (func && func != path->conv.u.app_func)) { /* * Notify all other functions to recalculate private data since some * functions might cache a list of conversion functions. For @@ -2595,42 +2806,45 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, } /* end if */ else { /* Remove from table */ - HDmemmove(H5T_g.path + i, H5T_g.path + i + 1, (size_t)(H5T_g.npaths - (i + 1)) * sizeof(H5T_path_t*)); + HDmemmove(H5T_g.path + i, H5T_g.path + i + 1, + (size_t)(H5T_g.npaths - (i + 1)) * sizeof(H5T_path_t *)); --H5T_g.npaths; /* Shut down path */ H5T__print_stats(path, &nprint); path->cdata.command = H5T_CONV_FREE; - if(path->conv.is_app) { - if((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed " - "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx failed " + "to free private data for %s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); #endif } /* end if */ - } /* end if */ - else - if((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + else if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed " - "to free private data for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), + "H5T: conversion function 0x%08lx failed " + "to free private data for %s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); #endif - } /* end if */ + } /* end if */ (void)H5T_close_real(path->src); (void)H5T_close_real(path->dst); path = H5FL_FREE(H5T_path_t, path); H5E_clear_stack(NULL); /*ignore all shutdown errors*/ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__unregister() */ - /*------------------------------------------------------------------------- * Function: H5Tunregister * @@ -2648,29 +2862,27 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, *------------------------------------------------------------------------- */ herr_t -H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, - H5T_conv_t func) +H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { - H5T_t *src = NULL, *dst = NULL; /* Datatype descriptors */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *src = NULL, *dst = NULL; /* Datatype descriptors */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "Te*siix", pers, name, src_id, dst_id, func); /* Check arguments */ - if(src_id > 0 && (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)))) + if (src_id > 0 && (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type") - if(dst_id > 0 && (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE)))) + if (dst_id > 0 && (NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type") - if(H5T__unregister(pers, name, src, dst, func) < 0) + if (H5T__unregister(pers, name, src, dst, func) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Tunregister() */ - /*------------------------------------------------------------------------- * Function: H5Tfind * @@ -2692,25 +2904,25 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { - H5T_t *src, *dst; - H5T_path_t *path; - H5T_conv_t ret_value; /* Return value */ + H5T_t * src, *dst; + H5T_path_t *path; + H5T_conv_t ret_value; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("x", "ii**x", src_id, dst_id, pcdata); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if(!pcdata) + if (!pcdata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no address to receive cdata pointer") /* Find it */ - if(NULL == (path = H5T_path_find(src, dst))) + if (NULL == (path = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "conversion function not found") - if(pcdata) + if (pcdata) *pcdata = &(path->cdata); /* Set return value */ @@ -2720,7 +2932,6 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) FUNC_LEAVE_API(ret_value) } /* end H5Tfind() */ - /*------------------------------------------------------------------------- * Function: H5Tcompiler_conv * @@ -2741,26 +2952,25 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id) { - H5T_t *src, *dst; - htri_t ret_value; /* Return value */ + H5T_t *src, *dst; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", src_id, dst_id); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* Find it */ - if((ret_value = H5T__compiler_conv(src, dst)) < 0) + if ((ret_value = H5T__compiler_conv(src, dst)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcompiler_conv() */ - /*------------------------------------------------------------------------- * Function: H5Tconvert * @@ -2785,40 +2995,85 @@ H5Tcompiler_conv(hid_t src_id, hid_t dst_id) *------------------------------------------------------------------------- */ herr_t -H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, - void *background, hid_t dxpl_id) +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 */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_path_t *tpath; /* type conversion info */ + H5T_t * src, *dst; /* unatomized types */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiz*x*xi", src_id, dst_id, nelmts, buf, background, dxpl_id); /* Check args */ - if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || - NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5P_DEFAULT == dxpl_id) + 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, "not dataset transfer property list") + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset transfer property list") /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); /* Find the conversion function */ - if(NULL == (tpath = H5T_path_find(src, dst))) + if (NULL == (tpath = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types") - if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background) < 0) + if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, buf, background) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Tconvert() */ +/*------------------------------------------------------------------------- + * Function: H5Treclaim + * + * Purpose: Frees the buffers allocated for storing variable-length data + * in memory. Only frees the VL data in the selection defined in the + * dataspace. The dataset transfer property list is required to find the + * correct allocation/free methods for the VL data in the buffer. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * Thursday, June 10, 1999 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Treclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf) +{ + H5S_t *space; /* Dataspace for iteration */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iii*x", type_id, space_id, dxpl_id, buf); + + /* Check args */ + if (H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") + if (!(H5S_has_extent(space))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") + + /* 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, "not xfer parms") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Call internal routine */ + ret_value = H5T_reclaim(type_id, space, buf); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Treclaim() */ /*------------------------------------------------------------------------- * Function: H5Tencode @@ -2838,27 +3093,26 @@ H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc) { - H5T_t *dtype; - herr_t ret_value = SUCCEED; + H5T_t *dtype; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*x*z", obj_id, buf, nalloc); /* Check argument and retrieve object */ - if(NULL == (dtype = (H5T_t *)H5I_object_verify(obj_id, H5I_DATATYPE))) + if (NULL == (dtype = (H5T_t *)H5I_object_verify(obj_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(nalloc == NULL) + if (nalloc == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer size") /* Go encode the datatype */ - if(H5T_encode(dtype, (unsigned char *)buf, nalloc) < 0) + if (H5T_encode(dtype, (unsigned char *)buf, nalloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tencode() */ - /*------------------------------------------------------------------------- * Function: H5Tdecode * @@ -2877,14 +3131,14 @@ H5Tencode(hid_t obj_id, void *buf, size_t *nalloc) hid_t H5Tdecode(const void *buf) { - H5T_t *dt; - hid_t ret_value; /* Return value */ + H5T_t *dt; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "*x", buf); /* Check args */ - if(buf == NULL) + if (buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer") /* Create datatype by decoding buffer @@ -2893,11 +3147,11 @@ H5Tdecode(const void *buf) * Really fixing this will require an H5Tdecode2() call that * takes a size parameter. */ - if(NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) + if (NULL == (dt = H5T_decode(SIZE_MAX, (const unsigned char *)buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type") done: @@ -2909,7 +3163,6 @@ H5Tdecode(const void *buf) *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * Function: H5T_encode * @@ -2928,22 +3181,22 @@ H5Tdecode(const void *buf) herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc) { - size_t buf_size; /* Encoded size of datatype */ - H5F_t *f = NULL; /* Fake file structure*/ - herr_t ret_value = SUCCEED; + size_t buf_size; /* Encoded size of datatype */ + H5F_t *f = NULL; /* Fake file structure*/ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT /* Allocate "fake" file structure */ - if(NULL == (f = H5F_fake_alloc((uint8_t)0))) + if (NULL == (f = H5F_fake_alloc((uint8_t)0))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate fake file struct") /* Find out the size of buffer needed */ - if((buf_size = H5O_msg_raw_size(f, H5O_DTYPE_ID, TRUE, obj)) == 0) + if ((buf_size = H5O_msg_raw_size(f, H5O_DTYPE_ID, TRUE, obj)) == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "can't find datatype size") /* Don't encode if buffer size isn't big enough or buffer is empty */ - if(!buf || *nalloc < (buf_size + 1 + 1)) + if (!buf || *nalloc < (buf_size + 1 + 1)) *nalloc = buf_size + 1 + 1; else { /* Encode the type of the information */ @@ -2953,19 +3206,18 @@ H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc) *buf++ = H5T_ENCODE_VERSION; /* Encode into user's buffer */ - if(H5O_msg_encode(f, H5O_DTYPE_ID, TRUE, buf, obj) < 0) + if (H5O_msg_encode(f, H5O_DTYPE_ID, TRUE, buf, obj) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode object") } /* end else */ done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_encode() */ - /*------------------------------------------------------------------------- * Function: H5T_decode * @@ -2984,40 +3236,41 @@ H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc) H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf) { - H5F_t *f = NULL; /* Fake file structure*/ - H5T_t *ret_value = NULL; /* Return value */ + H5F_t *f = NULL; /* Fake file structure*/ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Allocate "fake" file structure */ - if(NULL == (f = H5F_fake_alloc((uint8_t)0))) + if (NULL == (f = H5F_fake_alloc((uint8_t)0))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "can't allocate fake file struct") /* Decode the type of the information */ - if(*buf++ != H5O_DTYPE_ID) + if (*buf++ != H5O_DTYPE_ID) HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "not an encoded datatype") /* Decode the version of the datatype information */ - if(*buf++ != H5T_ENCODE_VERSION) + if (*buf++ != H5T_ENCODE_VERSION) HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype") /* Decode the serialized datatype message */ - if(NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, NULL, H5O_DTYPE_ID, buf_size, buf))) + if (NULL == (ret_value = (H5T_t *)H5O_msg_decode(f, NULL, H5O_DTYPE_ID, buf_size, buf))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object") /* Mark datatype as being in memory now */ - if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + /* No VOL object */ + ret_value->vol_obj = NULL; done: /* Release fake file structure */ - if(f && H5F_fake_free(f) < 0) + if (f && H5F_fake_free(f) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release fake file struct") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_decode() */ - /*------------------------------------------------------------------------- * Function: H5T__create * @@ -3037,84 +3290,80 @@ H5T_decode(size_t buf_size, const unsigned char *buf) H5T_t * H5T__create(H5T_class_t type, size_t size) { - H5T_t *dt = NULL; - H5T_t *ret_value = NULL; + H5T_t *dt = NULL; + H5T_t *ret_value = NULL; FUNC_ENTER_PACKAGE - switch(type) { + switch (type) { case H5T_INTEGER: case H5T_FLOAT: case H5T_TIME: - case H5T_STRING: - { - H5T_t *origin_dt = NULL; + case H5T_STRING: { + H5T_t *origin_dt = NULL; - if(NULL == (origin_dt = (H5T_t *)H5I_object(H5T_C_S1))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "can't get structure for string type") + if (NULL == (origin_dt = (H5T_t *)H5I_object(H5T_C_S1))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "can't get structure for string type") - /* Copy the default string datatype */ - if(NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + /* Copy the default string datatype */ + if (NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - /* Modify the datatype */ - if(H5T__set_size(dt, size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set size for string type") - } - break; + /* Modify the datatype */ + if (H5T__set_size(dt, size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to set size for string type") + } break; case H5T_BITFIELD: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "type class is not appropriate - use H5Tcopy()") case H5T_OPAQUE: case H5T_COMPOUND: - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->type = type; - if(type == H5T_COMPOUND) { - dt->shared->u.compnd.packed=FALSE; /* Start out unpacked */ - dt->shared->u.compnd.memb_size=0; + if (type == H5T_COMPOUND) { + dt->shared->u.compnd.packed = FALSE; /* Start out unpacked */ + dt->shared->u.compnd.memb_size = 0; } /* end if */ - else if(type == H5T_OPAQUE) + else if (type == H5T_OPAQUE) /* Initialize the tag in case it's not set later. A null tag will * cause problems for later operations. */ dt->shared->u.opaque.tag = H5MM_strdup(""); break; - case H5T_ENUM: - { - hid_t subtype; - H5T_t *sub_t_obj; - - if(sizeof(char) == size) - subtype = H5T_NATIVE_SCHAR_g; - else if(sizeof(short) == size) - subtype = H5T_NATIVE_SHORT_g; - else if(sizeof(int) == size) - subtype = H5T_NATIVE_INT_g; - else if(sizeof(long) == size) - subtype = H5T_NATIVE_LONG_g; + case H5T_ENUM: { + hid_t subtype; + H5T_t *sub_t_obj; + + if (sizeof(char) == size) + subtype = H5T_NATIVE_SCHAR_g; + else if (sizeof(short) == size) + subtype = H5T_NATIVE_SHORT_g; + else if (sizeof(int) == size) + subtype = H5T_NATIVE_INT_g; + else if (sizeof(long) == size) + subtype = H5T_NATIVE_LONG_g; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(sizeof(long long) == size) - subtype = H5T_NATIVE_LLONG_g; + else if (sizeof(long long) == size) + subtype = H5T_NATIVE_LLONG_g; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ - else - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type") - if(NULL == (dt = H5T__alloc())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - dt->shared->type = type; - if(NULL == (sub_t_obj = (H5T_t *)H5I_object(subtype))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get datatype object") - if(NULL == (dt->shared->parent = H5T_copy(sub_t_obj, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") - } - break; + else + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type") + if (NULL == (dt = H5T__alloc())) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + dt->shared->type = type; + if (NULL == (sub_t_obj = (H5T_t *)H5I_object(subtype))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get datatype object") + if (NULL == (dt->shared->parent = H5T_copy(sub_t_obj, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") + } break; - case H5T_VLEN: /* Variable length datatype */ + case H5T_VLEN: /* Variable length datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()") - case H5T_ARRAY: /* Array datatype */ + case H5T_ARRAY: /* Array datatype */ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create2()") case H5T_NO_CLASS: @@ -3125,24 +3374,28 @@ H5T__create(H5T_class_t type, size_t size) } /* end switch */ /* Set the size except VL string */ - if(H5T_STRING != type || H5T_VARIABLE != size) + if (H5T_STRING != type || H5T_VARIABLE != size) dt->shared->size = size; + /* No VOL object */ + dt->vol_obj = NULL; + /* Set return value */ ret_value = dt; done: - if(NULL == ret_value) { - if(dt) { + if (NULL == ret_value) { + if (dt) { + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); - dt = H5FL_FREE(H5T_t, dt); + dt = H5FL_FREE(H5T_t, dt); } } FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__create() */ - /*------------------------------------------------------------------------- * Function: H5T__initiate_copy * @@ -3155,43 +3408,52 @@ H5T__create(H5T_class_t type, size_t size) * Note: Common code for both H5T_copy and H5T_copy_reopen, as part of * the const-correct datatype copying routines. * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ static H5T_t * H5T__initiate_copy(const H5T_t *old_dt) { - H5T_t *new_dt = NULL; /* Copy of datatype */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *new_dt = NULL; /* Copy of datatype */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Allocate space */ - if(NULL == (new_dt = H5FL_MALLOC(H5T_t))) + if (NULL == (new_dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_t memory allocation failed") - if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) + if (NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "H5T_shared_t memory allocation failed") /* Copy shared information */ *(new_dt->shared) = *(old_dt->shared); + /* Increment ref count on owned VOL object */ + if (new_dt->shared->owned_vol_obj) + (void)H5VL_object_inc_rc(new_dt->shared->owned_vol_obj); + + /* Reset vol_obj field */ + new_dt->vol_obj = NULL; + /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { - if(new_dt->shared) + if (ret_value == NULL) + if (new_dt) { + if (new_dt->shared) { + if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); + } /* end if */ new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__initiate_copy() */ - /*------------------------------------------------------------------------- * Function: H5T__copy_transient * @@ -3200,27 +3462,26 @@ H5T__initiate_copy(const H5T_t *old_dt) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ static H5T_t * H5T__copy_transient(H5T_t *old_dt) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Copy datatype, with correct method */ - if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_TRANSIENT))) + if (NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'transient' copy of datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__copy_transient() */ - /*------------------------------------------------------------------------- * Function: H5T__copy_all * @@ -3229,27 +3490,26 @@ H5T__copy_transient(H5T_t *old_dt) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ static H5T_t * H5T__copy_all(H5T_t *old_dt) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Copy datatype, with correct method */ - if(NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_ALL))) + if (NULL == (ret_value = H5T_copy(old_dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't make 'all' copy of datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__copy_transient() */ - /*------------------------------------------------------------------------- * Function: H5T__complete_copy * @@ -3261,132 +3521,143 @@ H5T__copy_all(H5T_t *old_dt) * * Note: Common code for both H5T_copy and H5T_copy_reopen. * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ 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__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 */ - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_STATIC /* Update fields in the new struct, if we aren't sharing an already opened * committed datatype */ - if(!reopened_fo) { + if (!reopened_fo) { /* Copy parent information */ - if(old_dt->shared->parent) - if(NULL == (new_dt->shared->parent = (*copyfn)(old_dt->shared->parent))) + if (old_dt->shared->parent) + if (NULL == (new_dt->shared->parent = (*copyfn)(old_dt->shared->parent))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype's parent type") - switch(new_dt->shared->type) { - case H5T_COMPOUND: - { - ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ + switch (new_dt->shared->type) { + case H5T_COMPOUND: { + ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ - /* - * Copy all member fields to new type, then overwrite the - * name and type fields of each new member with copied values. - * That is, H5T_copy() is a deep copy. - */ - /* Only malloc if space has been allocated for members - NAF */ - if(new_dt->shared->u.compnd.nalloc > 0) { - if(NULL == (new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") - - H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, + /* + * Copy all member fields to new type, then overwrite the + * name and type fields of each new member with copied values. + * That is, H5T_copy() is a deep copy. + */ + /* Only malloc if space has been allocated for members - NAF */ + if (new_dt->shared->u.compnd.nalloc > 0) { + if (NULL == (new_dt->shared->u.compnd.memb = + H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + H5MM_memcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); - } /* end if */ + } /* end if */ - for(i = 0; i < new_dt->shared->u.compnd.nmembs; i++) { - unsigned j; - int old_match; - - if(NULL == (s = H5MM_xstrdup(new_dt->shared->u.compnd.memb[i].name))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for compound field's name") - new_dt->shared->u.compnd.memb[i].name = s; - if(NULL == (tmp = (*copyfn)(old_dt->shared->u.compnd.memb[i].type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy compound field's datatype") - new_dt->shared->u.compnd.memb[i].type = tmp; - HDassert(tmp != NULL); - - /* Range check against compound member's offset */ - if((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") - - /* Apply the accumulated size change to the offset of the field */ - new_dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; - - if(old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { - for(old_match = -1, j = 0; j < old_dt->shared->u.compnd.nmembs; j++) { - if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name, old_dt->shared->u.compnd.memb[j].name)) { - old_match = (int) j; - break; - } /* end if */ - } /* end for */ - - /* check if we couldn't find a match */ - if(old_match < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "fields in datatype corrupted") - } /* end if */ - else - old_match = (int) i; + for (i = 0; i < new_dt->shared->u.compnd.nmembs; i++) { + unsigned j; + int old_match; + + if (NULL == (s = H5MM_xstrdup(new_dt->shared->u.compnd.memb[i].name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, + "can't copy string for compound field's name") + new_dt->shared->u.compnd.memb[i].name = s; + if (NULL == (tmp = (*copyfn)(old_dt->shared->u.compnd.memb[i].type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy compound field's datatype") + new_dt->shared->u.compnd.memb[i].type = tmp; + HDassert(tmp != NULL); + + /* Range check against compound member's offset */ + if ((accum_change < 0) && + ((ssize_t)new_dt->shared->u.compnd.memb[i].offset < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") - /* If the field changed size, add that change to the accumulated size change */ - if(new_dt->shared->u.compnd.memb[i].type->shared->size != old_dt->shared->u.compnd.memb[old_match].type->shared->size) { - /* Adjust the size of the member */ - new_dt->shared->u.compnd.memb[i].size = (old_dt->shared->u.compnd.memb[old_match].size*tmp->shared->size)/old_dt->shared->u.compnd.memb[old_match].type->shared->size; + /* Apply the accumulated size change to the offset of the field */ + new_dt->shared->u.compnd.memb[i].offset += (size_t)accum_change; - accum_change += (ssize_t) (new_dt->shared->u.compnd.memb[i].type->shared->size - old_dt->shared->u.compnd.memb[old_match].type->shared->size); - } /* end if */ - } /* end for */ + if (old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { + for (old_match = -1, j = 0; j < old_dt->shared->u.compnd.nmembs; j++) { + if (!HDstrcmp(new_dt->shared->u.compnd.memb[i].name, + old_dt->shared->u.compnd.memb[j].name)) { + old_match = (int)j; + break; + } /* end if */ + } /* end for */ - /* Range check against datatype size */ - if((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + /* check if we couldn't find a match */ + if (old_match < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "fields in datatype corrupted") + } /* end if */ + else + old_match = (int)i; + + /* If the field changed size, add that change to the accumulated size change */ + if (new_dt->shared->u.compnd.memb[i].type->shared->size != + old_dt->shared->u.compnd.memb[old_match].type->shared->size) { + /* Adjust the size of the member */ + new_dt->shared->u.compnd.memb[i].size = + (old_dt->shared->u.compnd.memb[old_match].size * tmp->shared->size) / + old_dt->shared->u.compnd.memb[old_match].type->shared->size; + + accum_change += + (ssize_t)(new_dt->shared->u.compnd.memb[i].type->shared->size - + old_dt->shared->u.compnd.memb[old_match].type->shared->size); + } /* end if */ + } /* end for */ - /* Apply the accumulated size change to the size of the compound struct */ - new_dt->shared->size += (size_t) accum_change; - } - break; + /* Range check against datatype size */ + if ((accum_change < 0) && ((ssize_t)new_dt->shared->size < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + + /* Apply the accumulated size change to the size of the compound struct */ + new_dt->shared->size += (size_t)accum_change; + } break; case H5T_ENUM: /* - * Copy all member fields to new type, then overwrite the name fields - * of each new member with copied values. That is, H5T_copy() is a - * deep copy. - */ - if(NULL == (new_dt->shared->u.enumer.name = H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*)))) + * Copy all member fields to new type, then overwrite the name fields + * of each new member with copied values. That is, H5T_copy() is a + * deep copy. + */ + if (NULL == (new_dt->shared->u.enumer.name = + H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char *)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam name array memory allocation failed") - if(NULL == (new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "enam value array memory allocation failed") + if (NULL == (new_dt->shared->u.enumer.value = + H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "enam value array memory allocation failed") H5MM_memcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, - new_dt->shared->u.enumer.nmembs * new_dt->shared->size); - for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { - if(NULL == (s = H5MM_xstrdup(old_dt->shared->u.enumer.name[i]))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy string for enum value's name") + new_dt->shared->u.enumer.nmembs * new_dt->shared->size); + for (i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { + if (NULL == (s = H5MM_xstrdup(old_dt->shared->u.enumer.name[i]))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, + "can't copy string for enum value's name") new_dt->shared->u.enumer.name[i] = s; } /* end for */ break; case H5T_VLEN: case H5T_REFERENCE: - if(set_memory_type) + if (set_memory_type) /* H5T_copy converts any type into a memory type */ - if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; case H5T_OPAQUE: /* - * Copy the tag name. - */ + * Copy the tag name. + */ new_dt->shared->u.opaque.tag = H5MM_xstrdup(new_dt->shared->u.opaque.tag); break; @@ -3405,29 +3676,29 @@ H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo default: break; } /* end switch */ - } /* end if */ + } /* end if */ /* Set the cached location & name path if the original type was a named * type and the new type is also named. */ - if(H5O_loc_reset(&new_dt->oloc) < 0) + if (H5O_loc_reset(&new_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_reset(&new_dt->path) < 0) + if (H5G_name_reset(&new_dt->path) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") - if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { - if(H5O_loc_copy_deep(&(new_dt->oloc), &(old_dt->oloc)) < 0) + if (new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { + if (H5O_loc_copy_deep(&(new_dt->oloc), &(old_dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy object location") - if(H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0) + if (H5G_name_copy(&(new_dt->path), &(old_dt->path), H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy path") } /* end if */ /* Copy shared location information if the new type is named or if it is * shared in the heap. */ - if((old_dt->sh_loc.type == H5O_SHARE_TYPE_SOHM || old_dt->sh_loc.type == H5O_SHARE_TYPE_HERE) || - new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { - if(H5O_set_shared(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0) + if ((old_dt->sh_loc.type == H5O_SHARE_TYPE_SOHM || old_dt->sh_loc.type == H5O_SHARE_TYPE_HERE) || + new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { + if (H5O_set_shared(&(new_dt->sh_loc), &(old_dt->sh_loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy shared information") } /* end if */ else @@ -3438,7 +3709,6 @@ H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__complete_copy() */ - /*------------------------------------------------------------------------- * Function: H5T_copy * @@ -3456,9 +3726,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_copy_func_t copyfn; /* Pointer to correct copy routine */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * new_dt = NULL; /* New datatype */ + H5T_copy_func_t copyfn; /* Pointer to correct copy routine */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3466,7 +3736,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) HDassert(old_dt); /* Allocate and copy core datatype information */ - if(NULL == (new_dt = H5T__initiate_copy(old_dt))) + if (NULL == (new_dt = H5T__initiate_copy(old_dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info") /* Check what sort of copy we are making */ @@ -3476,7 +3746,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return an unlocked transient type. */ new_dt->shared->state = H5T_STATE_TRANSIENT; - copyfn = H5T__copy_transient; + copyfn = H5T__copy_transient; break; case H5T_COPY_ALL: @@ -3484,9 +3754,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return a transient type (locked or unlocked) or an unopened named * type. Immutable transient types are degraded to read-only. */ - if(H5T_STATE_OPEN==old_dt->shared->state) + if (H5T_STATE_OPEN == old_dt->shared->state) new_dt->shared->state = H5T_STATE_NAMED; - else if(H5T_STATE_IMMUTABLE==old_dt->shared->state) + else if (H5T_STATE_IMMUTABLE == old_dt->shared->state) new_dt->shared->state = H5T_STATE_RDONLY; copyfn = H5T__copy_all; break; @@ -3496,24 +3766,25 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) } /* end switch */ /* Finish making the copy of the datatype */ - if(H5T__complete_copy(new_dt, old_dt, NULL, (method == H5T_COPY_TRANSIENT), copyfn) < 0) + if (H5T__complete_copy(new_dt, old_dt, NULL, (method == H5T_COPY_TRANSIENT), copyfn) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization") /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { + if (ret_value == NULL) + if (new_dt) { HDassert(new_dt->shared); + if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); - new_dt = H5FL_FREE(H5T_t, new_dt); + new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_copy() */ - /*------------------------------------------------------------------------- * Function: H5T_copy_reopen * @@ -3523,17 +3794,17 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return: Success: Pointer to a new copy of the OLD_DT argument. * Failure: NULL * - * Programmer: David Young - * January 18, 2020 + * Programmer: David Young + * January 18, 2020 * *------------------------------------------------------------------------- */ H5T_t * H5T_copy_reopen(H5T_t *old_dt) { - 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 * new_dt = NULL; /* New datatype */ + H5T_shared_t *reopened_fo = NULL; /* Pointer to reopened existing named datatype */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3541,29 +3812,31 @@ H5T_copy_reopen(H5T_t *old_dt) HDassert(old_dt); /* Allocate and copy core datatype information */ - if(NULL == (new_dt = H5T__initiate_copy(old_dt))) + if (NULL == (new_dt = H5T__initiate_copy(old_dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy core datatype info") /* * Return a transient type (locked or unlocked) or an opened named * type. Immutable transient types are degraded to read-only. */ - if(old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + if (old_dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Check if the object is already open */ - if(NULL == (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) { + if (NULL == + (reopened_fo = (H5T_shared_t *)H5FO_opened(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open named datatype again */ - if(H5O_open(&old_dt->oloc) < 0) + if (H5O_open(&old_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type") /* Insert opened named datatype into opened object list for the file */ - if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") + if (H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, + "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") new_dt->shared->fo_count = 1; @@ -3572,20 +3845,22 @@ H5T_copy_reopen(H5T_t *old_dt) /* The object is already open. Free the H5T_shared_t struct * we had been using and use the one that already exists. * Not terribly efficient. */ + if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); new_dt->shared = reopened_fo; reopened_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&old_dt->oloc) < 0) + if (H5O_open(&old_dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ @@ -3594,28 +3869,29 @@ H5T_copy_reopen(H5T_t *old_dt) } /* end if */ else /* Downgrade immutable datatypes to read-only */ - if(H5T_STATE_IMMUTABLE == old_dt->shared->state) - new_dt->shared->state = H5T_STATE_RDONLY; + if (H5T_STATE_IMMUTABLE == old_dt->shared->state) + 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) + if (H5T__complete_copy(new_dt, old_dt, reopened_fo, TRUE, H5T_copy_reopen) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't complete datatype initialization") /* Set return value */ ret_value = new_dt; done: - if(ret_value == NULL) - if(new_dt) { + if (ret_value == NULL) + if (new_dt) { HDassert(new_dt->shared); + if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); - new_dt = H5FL_FREE(H5T_t, new_dt); + new_dt = H5FL_FREE(H5T_t, new_dt); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_copy_reopen() */ - /*------------------------------------------------------------------------- * Function: H5T_lock * @@ -3635,18 +3911,18 @@ H5T_copy_reopen(H5T_t *old_dt) herr_t H5T_lock(H5T_t *dt, hbool_t immutable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert (dt); + HDassert(dt); switch (dt->shared->state) { case H5T_STATE_TRANSIENT: dt->shared->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY; break; case H5T_STATE_RDONLY: - if(immutable) + if (immutable) dt->shared->state = H5T_STATE_IMMUTABLE; break; case H5T_STATE_IMMUTABLE: @@ -3662,7 +3938,6 @@ H5T_lock(H5T_t *dt, hbool_t immutable) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__alloc * @@ -3678,38 +3953,42 @@ H5T_lock(H5T_t *dt, hbool_t immutable) H5T_t * H5T__alloc(void) { - H5T_t *dt = NULL; /* Pointer to datatype allocated */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* Pointer to datatype allocated */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Allocate & initialize datatype wrapper info */ - if(NULL == (dt = H5FL_CALLOC(H5T_t))) + if (NULL == (dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5O_loc_reset(&(dt->oloc)); H5G_name_reset(&(dt->path)); H5O_msg_reset_share(H5O_DTYPE_ID, dt); /* Allocate & initialize shared datatype structure */ - if(NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) + if (NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->version = H5O_DTYPE_VERSION_1; + /* No VOL object initially */ + dt->vol_obj = NULL; + /* Assign return value */ ret_value = dt; done: - if(ret_value == NULL) - if(dt) { - if(dt->shared) + if (ret_value == NULL) + if (dt) { + if (dt->shared) { + 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 */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__alloc() */ - /*------------------------------------------------------------------------- * Function: H5T__free * @@ -3727,8 +4006,8 @@ H5T__alloc(void) herr_t H5T__free(H5T_t *dt) { - unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3738,25 +4017,25 @@ H5T__free(H5T_t *dt) H5G_name_free(&(dt->path)); /* Don't free locked datatypes */ - if(H5T_STATE_IMMUTABLE == dt->shared->state) + if (H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype") /* Close the datatype */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { dt->shared->u.compnd.memb[i].name = (char *)H5MM_xfree(dt->shared->u.compnd.memb[i].name); (void)H5T_close_real(dt->shared->u.compnd.memb[i].type); } - dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb); + dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_xfree(dt->shared->u.compnd.memb); dt->shared->u.compnd.nmembs = 0; break; case H5T_ENUM: - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) dt->shared->u.enumer.name[i] = (char *)H5MM_xfree(dt->shared->u.enumer.name[i]); - dt->shared->u.enumer.name = (char **)H5MM_xfree(dt->shared->u.enumer.name); - dt->shared->u.enumer.value = (uint8_t *)H5MM_xfree(dt->shared->u.enumer.value); + dt->shared->u.enumer.name = (char **)H5MM_xfree(dt->shared->u.enumer.name); + dt->shared->u.enumer.value = (uint8_t *)H5MM_xfree(dt->shared->u.enumer.value); dt->shared->u.enumer.nmembs = 0; break; @@ -3781,21 +4060,26 @@ H5T__free(H5T_t *dt) /* Close the parent */ HDassert(dt->shared->parent != dt); - if(dt->shared->parent && H5T_close_real(dt->shared->parent) < 0) + if (dt->shared->parent && H5T_close_real(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type") dt->shared->parent = NULL; + /* Close the owned VOL object */ + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") + dt->shared->owned_vol_obj = NULL; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__free() */ - /*------------------------------------------------------------------------- * Function: H5T_close_real * * Purpose: Frees a datatype and all associated memory. * - * Note: Does _not_ deal with open named datatypes, etc. + * Note: Does _not_ deal with open named datatypes, etc. so this + * should never see a type managed by a VOL connector. * * Return: Non-negative on success/Negative on failure * @@ -3807,7 +4091,7 @@ H5T__free(H5T_t *dt) herr_t H5T_close_real(H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3815,10 +4099,11 @@ H5T_close_real(H5T_t *dt) HDassert(dt && dt->shared); /* Clean up resources, depending on shared state */ - if(dt->shared->state != H5T_STATE_OPEN) { - if(H5T__free(dt) < 0) + if (dt->shared->state != H5T_STATE_OPEN) { + if (H5T__free(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); + HDassert(!dt->shared->owned_vol_obj); dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); } /* end if */ else @@ -3832,36 +4117,6 @@ H5T_close_real(H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_close_real() */ - -/*------------------------------------------------------------------------- - * Function: H5T__close_cb - * - * Purpose: Callback routine for closing a datatype ID. Closes the datatype - * object that was attached to the ID. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5T__close_cb(H5T_t *dt) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* check args */ - HDassert(dt && dt->shared); - - /* Call actual datatype close routine */ - if(H5T_close(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "can't close datatype"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__close_cb() */ - - /*------------------------------------------------------------------------- * Function: H5T_close * @@ -3878,7 +4133,7 @@ H5T__close_cb(H5T_t *dt) herr_t H5T_close(H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3887,7 +4142,7 @@ H5T_close(H5T_t *dt) HDassert(dt->shared); /* Named datatype cleanups */ - if(dt->shared->state == H5T_STATE_OPEN) { + if (dt->shared->state == H5T_STATE_OPEN) { /* Decrement refcount count on open named datatype */ dt->shared->fo_count--; @@ -3901,24 +4156,25 @@ H5T_close(H5T_t *dt) */ /* Decrement the ref. count for this object in the top file */ - if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object") /* Close things down if this is the last reference to the open named datatype */ - if(0 == dt->shared->fo_count) { - hbool_t corked; /* Whether the named datatype is corked or not */ + if (0 == dt->shared->fo_count) { + hbool_t corked; /* Whether the named datatype is corked or not */ /* Uncork cache entries with object address tag for named datatype */ - if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0) + if (H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0) + if (corked) + if (H5AC_cork(dt->oloc.file, dt->oloc.addr, H5AC__UNCORK, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* Remove the datatype from the list of opened objects in the file */ - if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects") - if(H5O_close(&dt->oloc, NULL) < 0) + if (H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, + "can't remove datatype from list of open objects") + if (H5O_close(&dt->oloc, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header") /* Mark named datatype closed now */ @@ -3926,27 +4182,26 @@ H5T_close(H5T_t *dt) } /* end if */ else { /* Check reference count for this object in the top file */ - if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { /* Close object location for named datatype */ - if(H5O_close(&dt->oloc, NULL) < 0) + if (H5O_close(&dt->oloc, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close") } /* end if */ 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") + if (H5O_loc_free(&(dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ - } /* end if */ + } /* end if */ /* Clean up resources */ - if(H5T_close_real(dt) < 0) + if (H5T_close_real(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_close() */ - /*------------------------------------------------------------------------- * Function: H5T__set_size * @@ -3976,45 +4231,45 @@ H5T_close(H5T_t *dt) static herr_t H5T__set_size(H5T_t *dt, size_t size) { - size_t prec, offset; - herr_t ret_value = SUCCEED; /* Return value */ + size_t prec, offset; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(dt); - HDassert(size!=0); - HDassert(H5T_REFERENCE!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(dt->shared); + HDassert(size != 0); + HDassert(H5T_REFERENCE != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); - if(dt->shared->parent) { - if(H5T__set_size(dt->shared->parent, size) < 0) + if (dt->shared->parent) { + if (H5T__set_size(dt->shared->parent, size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } else { if (H5T_IS_ATOMIC(dt->shared)) { offset = dt->shared->u.atomic.offset; - prec = dt->shared->u.atomic.prec; + prec = dt->shared->u.atomic.prec; /* Decrement the offset and precision if necessary */ - if (prec > 8*size) + if (prec > 8 * size) offset = 0; - else - if (offset+prec > 8*size) - offset = 8 * size - prec; - if (prec > 8*size) + else if (offset + prec > 8 * size) + offset = 8 * size - prec; + if (prec > 8 * size) prec = 8 * size; } else prec = offset = 0; - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: @@ -4024,28 +4279,29 @@ H5T__set_size(H5T_t *dt, size_t size) case H5T_COMPOUND: /* If decreasing size, check the last member isn't being cut. */ - if(size < dt->shared->size) { - int num_membs = 0; - unsigned i, max_index = 0; - size_t memb_offset, max_offset = 0; - size_t max_size; + if (size < dt->shared->size) { + int num_membs = 0; + unsigned i, max_index = 0; + size_t memb_offset, max_offset = 0; + size_t max_size; - if((num_membs = H5T_get_nmembers(dt)) < 0) + if ((num_membs = H5T_get_nmembers(dt)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); - if(num_membs) { - for(i = 0; i < (unsigned)num_membs; i++) { + if (num_membs) { + for (i = 0; i < (unsigned)num_membs; i++) { memb_offset = H5T_get_member_offset(dt, i); - if(memb_offset > max_offset) { + if (memb_offset > max_offset) { max_offset = memb_offset; - max_index = i; + max_index = i; } /* end if */ - } /* end for */ + } /* end for */ max_size = H5T__get_member_size(dt, max_index); - if(size < (max_offset + max_size)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); + if (size < (max_offset + max_size)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "size shrinking will cut off last member "); } /* end if */ /* Compound must not have been packed previously */ @@ -4058,15 +4314,15 @@ 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_cset_t tmp_cset; /* Temp. cset info */ - H5T_str_t tmp_strpad; /* Temp. strpad info */ + if (size == H5T_VARIABLE) { + H5T_t * base = NULL; /* base data type */ + H5T_cset_t tmp_cset; /* Temp. cset info */ + H5T_str_t tmp_strpad; /* Temp. strpad info */ /* Get a copy of unsigned char type as the base/parent type */ - if(NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) + if (NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); - dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); + dt->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* change this datatype into a VL string */ dt->shared->type = H5T_VLEN; @@ -4079,7 +4335,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Before we mess with the info in the union, extract the * values we need */ - tmp_cset = dt->shared->u.atomic.u.s.cset; + tmp_cset = dt->shared->u.atomic.u.s.cset; tmp_strpad = dt->shared->u.atomic.u.s.pad; /* This is a string, not a sequence */ @@ -4090,11 +4346,11 @@ H5T__set_size(H5T_t *dt, size_t size) dt->shared->u.vlen.pad = tmp_strpad; /* Set up VL information */ - if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); } /* end if */ else { - prec = 8 * size; + prec = 8 * size; offset = 0; } /* end else */ break; @@ -4104,10 +4360,11 @@ H5T__set_size(H5T_t *dt, size_t size) * The sign, mantissa, and exponent fields should be adjusted * first when decreasing the size of a floating point type. */ - if(dt->shared->u.atomic.u.f.sign >= prec+offset || - dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || - dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); + if (dt->shared->u.atomic.u.f.sign >= prec + offset || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec + offset || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec + offset) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "adjust sign, mantissa, and exponent fields first"); } break; @@ -4129,16 +4386,16 @@ H5T__set_size(H5T_t *dt, size_t size) } /* end switch */ /* Commit (if we didn't convert this type to a VL string) */ - if(dt->shared->type != H5T_VLEN) { + if (dt->shared->type != H5T_VLEN) { dt->shared->size = size; if (H5T_IS_ATOMIC(dt->shared)) { dt->shared->u.atomic.offset = offset; - dt->shared->u.atomic.prec = prec; + dt->shared->u.atomic.prec = prec; } } /* end if */ /* Check if the new compound type is packed */ - if(dt->shared->type == H5T_COMPOUND) + if (dt->shared->type == H5T_COMPOUND) H5T__update_packed(dt); } /* end else */ @@ -4146,7 +4403,6 @@ H5T__set_size(H5T_t *dt, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__set_size() */ - /*------------------------------------------------------------------------- * Function: H5T_get_size * @@ -4170,10 +4426,36 @@ H5T_get_size(const H5T_t *dt) /* check args */ HDassert(dt); + HDassert(dt->shared); FUNC_LEAVE_NOAPI(dt->shared->size) } /* end H5T_get_size() */ +/*------------------------------------------------------------------------- + * Function: H5T_get_force_conv + * + * Purpose: Determines if the type has forced conversion. This will be + * true if and only if the type keeps a pointer to a file VOL + * object internally. + * + * Return: TRUE/FALSE (never fails) + * + * Programmer: Neil Fortner + * Thursday, January 21, 2021 + *------------------------------------------------------------------------- + */ +hbool_t +H5T_get_force_conv(const H5T_t *dt) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* check args */ + HDassert(dt); + HDassert(dt->shared); + + FUNC_LEAVE_NOAPI(dt->shared->force_conv) +} /* end H5T_get_force_conv() */ /*------------------------------------------------------------------------- * Function: H5T_cmp @@ -4194,12 +4476,12 @@ H5T_get_size(const H5T_t *dt) int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) { - unsigned *idx1 = NULL, *idx2 = NULL; - size_t base_size; - hbool_t swapped; - unsigned u; - int tmp; - int ret_value = 0; + unsigned *idx1 = NULL, *idx2 = NULL; + size_t base_size; + hbool_t swapped; + unsigned u; + int tmp; + int ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -4208,106 +4490,115 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) HDassert(dt2); /* the easy case */ - if(dt1 == dt2) + if (dt1 == dt2) HGOTO_DONE(0); + HDassert(dt1->shared); + HDassert(dt2->shared); + /* compare */ - if(dt1->shared->type < dt2->shared->type) + if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1); - if(dt1->shared->type > dt2->shared->type) + if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1); - if(dt1->shared->size < dt2->shared->size) + if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1); - if(dt1->shared->size > dt2->shared->size) + if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1); - if(dt1->shared->parent && !dt2->shared->parent) + if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1); - if(!dt1->shared->parent && dt2->shared->parent) + if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1); - if(dt1->shared->parent) { + if (dt1->shared->parent) { tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); - if(tmp < 0) + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); } /* end if */ - switch(dt1->shared->type) { + switch (dt1->shared->type) { case H5T_COMPOUND: /* * Compound data types... */ - if(dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) HGOTO_DONE(1); /* Build an index for each type so the names are sorted */ - if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || - NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) + if (NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || + NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for(u = 0; u < dt1->shared->u.compnd.nmembs; u++) + for (u = 0; u < dt1->shared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; - if(dt1->shared->u.enumer.nmembs > 1) { + if (dt1->shared->u.enumer.nmembs > 1) { int i; - for(i = (int) dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt1->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped=FALSE; j < i; j++) - if(HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name, - dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name, + dt1->shared->u.compnd.memb[idx1[j + 1]].name) > 0) { unsigned tmp_idx = idx1[j]; - idx1[j] = idx1[j + 1]; - idx1[j + 1] = tmp_idx; - swapped = TRUE; + idx1[j] = idx1[j + 1]; + idx1[j + 1] = tmp_idx; + swapped = TRUE; } } - for(i = (int) dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt2->shared->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; jshared->u.compnd.memb[idx2[j]].name, - dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name, + dt2->shared->u.compnd.memb[idx2[j + 1]].name) > 0) { unsigned tmp_idx = idx2[j]; - idx2[j] = idx2[j + 1]; - idx2[j + 1] = tmp_idx; - swapped = TRUE; + idx2[j] = idx2[j + 1]; + idx2[j + 1] = tmp_idx; + swapped = TRUE; } } } /* end if */ #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for(u=0; ushared->u.compnd.nmembs-1; u++) { + for (u = 0; u < dt1->shared->u.compnd.nmembs - 1; u++) { HDassert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, - dt1->shared->u.compnd.memb[idx1[u + 1]].name)); + dt1->shared->u.compnd.memb[idx1[u + 1]].name)); HDassert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, - dt2->shared->u.compnd.memb[idx2[u + 1]].name)); + dt2->shared->u.compnd.memb[idx2[u + 1]].name)); } #endif /* Compare the members */ - for(u=0; ushared->u.compnd.nmembs; u++) { + for (u = 0; u < dt1->shared->u.compnd.nmembs; u++) { tmp = HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, - dt2->shared->u.compnd.memb[idx2[u]].name); - if(tmp < 0) + dt2->shared->u.compnd.memb[idx2[u]].name); + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); - if(dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) + HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) + HGOTO_DONE(1); - if(dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1); - if(dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) + HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) + HGOTO_DONE(1); tmp = H5T_cmp(dt1->shared->u.compnd.memb[idx1[u]].type, - dt2->shared->u.compnd.memb[idx2[u]].type, superset); - if(tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) HGOTO_DONE(1); + dt2->shared->u.compnd.memb[idx2[u]].type, superset); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); } break; @@ -4319,75 +4610,75 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* If we are doing a "superset" comparison, dt2 is allowed to have * more members than dt1 */ - if(superset) { - if(dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) + if (superset) { + if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end if */ else { - if(dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) HGOTO_DONE(-1); - if(dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); } /* end else */ /* Build an index for each type so the names are sorted */ - if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || - NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) + if (NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || + NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for(u=0; ushared->u.enumer.nmembs; u++) + for (u = 0; u < dt1->shared->u.enumer.nmembs; u++) idx1[u] = u; - if(dt1->shared->u.enumer.nmembs > 1) { + if (dt1->shared->u.enumer.nmembs > 1) { int i; - for (i = (int) dt1->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt1->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; j < i; j++) - if(HDstrcmp(dt1->shared->u.enumer.name[idx1[j]], - dt1->shared->u.enumer.name[idx1[j+1]]) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt1->shared->u.enumer.name[idx1[j]], + dt1->shared->u.enumer.name[idx1[j + 1]]) > 0) { unsigned tmp_idx = idx1[j]; - idx1[j] = idx1[j+1]; - idx1[j+1] = tmp_idx; - swapped = TRUE; + idx1[j] = idx1[j + 1]; + idx1[j + 1] = tmp_idx; + swapped = TRUE; } } } - for(u=0; ushared->u.enumer.nmembs; u++) + for (u = 0; u < dt2->shared->u.enumer.nmembs; u++) idx2[u] = u; - if(dt2->shared->u.enumer.nmembs > 1) { + if (dt2->shared->u.enumer.nmembs > 1) { int i; - for(i = (int) dt2->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { + for (i = (int)dt2->shared->u.enumer.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) { int j; - for(j = 0, swapped = FALSE; j < i; j++) - if(HDstrcmp(dt2->shared->u.enumer.name[idx2[j]], - dt2->shared->u.enumer.name[idx2[j+1]]) > 0) { + for (j = 0, swapped = FALSE; j < i; j++) + if (HDstrcmp(dt2->shared->u.enumer.name[idx2[j]], + dt2->shared->u.enumer.name[idx2[j + 1]]) > 0) { unsigned tmp_idx = idx2[j]; - idx2[j] = idx2[j+1]; - idx2[j+1] = tmp_idx; - swapped = TRUE; + idx2[j] = idx2[j + 1]; + idx2[j + 1] = tmp_idx; + swapped = TRUE; } } } #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for(u=0; ushared->u.enumer.nmembs-1; u++) { - HDassert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt1->shared->u.enumer.name[idx1[u+1]])); - HDassert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], - dt2->shared->u.enumer.name[idx2[u+1]])); + for (u = 0; u < dt1->shared->u.enumer.nmembs - 1; u++) { + HDassert( + HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt1->shared->u.enumer.name[idx1[u + 1]])); + HDassert( + HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], dt2->shared->u.enumer.name[idx2[u + 1]])); } #endif /* Compare the members */ base_size = dt1->shared->parent->shared->size; - for(u=0; ushared->u.enumer.nmembs; u++) { + for (u = 0; u < dt1->shared->u.enumer.nmembs; u++) { unsigned idx = 0; - if(superset) { - unsigned lt = 0, rt; /* Final, left & right key indices */ - int cmp = 1; /* Key comparison value */ + if (superset) { + unsigned lt = 0, rt; /* Final, left & right key indices */ + int cmp = 1; /* Key comparison value */ /* If a superset is allowed, dt2 may have more members * than dt1, so binary search for matching member name in @@ -4395,99 +4686,100 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) */ rt = dt2->shared->u.enumer.nmembs; - while(lt < rt && cmp) { + while (lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ - if((cmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt2->shared->u.enumer.name[idx2[idx]] ) ) < 0) + if ((cmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], + dt2->shared->u.enumer.name[idx2[idx]])) < 0) rt = idx; else - lt = idx+1; + lt = idx + 1; } /* Leave, if we couldn't find match */ - if(cmp) + if (cmp) HGOTO_DONE(-1); } /* end if */ else { /* Check for exact member name match when not doing * "superset" comparison */ - tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], - dt2->shared->u.enumer.name[idx2[u]]); - if (tmp<0) HGOTO_DONE(-1); - if (tmp>0) HGOTO_DONE(1); + tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], dt2->shared->u.enumer.name[idx2[u]]); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); /* Set index value appropriately */ idx = u; } /* end else */ tmp = HDmemcmp((uint8_t *)dt1->shared->u.enumer.value + idx1[u] * base_size, - (uint8_t *)dt2->shared->u.enumer.value + idx2[idx] * base_size, - base_size); - if(tmp<0) HGOTO_DONE(-1); - if(tmp>0) HGOTO_DONE(1); + (uint8_t *)dt2->shared->u.enumer.value + idx2[idx] * base_size, base_size); + if (tmp < 0) + HGOTO_DONE(-1); + if (tmp > 0) + HGOTO_DONE(1); } break; case H5T_VLEN: - HDassert(dt1->shared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>=H5T_LOC_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>=H5T_LOC_BADLOC && dt2->shared->u.vlen.locshared->u.vlen.type > H5T_VLEN_BADTYPE && + dt1->shared->u.vlen.type < H5T_VLEN_MAXTYPE); + HDassert(dt2->shared->u.vlen.type > H5T_VLEN_BADTYPE && + dt2->shared->u.vlen.type < H5T_VLEN_MAXTYPE); + HDassert(dt1->shared->u.vlen.loc >= H5T_LOC_BADLOC && dt1->shared->u.vlen.loc < H5T_LOC_MAXLOC); + HDassert(dt2->shared->u.vlen.loc >= H5T_LOC_BADLOC && dt2->shared->u.vlen.loc < H5T_LOC_MAXLOC); /* Arbitrarily sort sequence VL datatypes before string VL datatypes */ - if(dt1->shared->u.vlen.type==H5T_VLEN_SEQUENCE && - dt2->shared->u.vlen.type==H5T_VLEN_STRING) { + if (dt1->shared->u.vlen.type == H5T_VLEN_SEQUENCE && + dt2->shared->u.vlen.type == H5T_VLEN_STRING) { HGOTO_DONE(-1); } - else if(dt1->shared->u.vlen.type==H5T_VLEN_STRING && - dt2->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { + else if (dt1->shared->u.vlen.type == H5T_VLEN_STRING && + dt2->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { HGOTO_DONE(1); } /* Arbitrarily sort VL datatypes in memory before disk */ - if(dt1->shared->u.vlen.loc==H5T_LOC_MEMORY && - dt2->shared->u.vlen.loc==H5T_LOC_DISK) { + if (dt1->shared->u.vlen.loc == H5T_LOC_MEMORY && dt2->shared->u.vlen.loc == H5T_LOC_DISK) { HGOTO_DONE(-1); } - else if(dt1->shared->u.vlen.loc==H5T_LOC_DISK && - dt2->shared->u.vlen.loc==H5T_LOC_MEMORY) { + else if (dt1->shared->u.vlen.loc == H5T_LOC_DISK && dt2->shared->u.vlen.loc == H5T_LOC_MEMORY) { HGOTO_DONE(1); } - else if(dt1->shared->u.vlen.loc==H5T_LOC_BADLOC && - dt2->shared->u.vlen.loc!=H5T_LOC_BADLOC) { + else if (dt1->shared->u.vlen.loc == H5T_LOC_BADLOC && dt2->shared->u.vlen.loc != H5T_LOC_BADLOC) { HGOTO_DONE(1); } /* Don't allow VL types in different files to compare as equal */ - if(dt1->shared->u.vlen.f < dt2->shared->u.vlen.f) + if (dt1->shared->u.vlen.file < dt2->shared->u.vlen.file) HGOTO_DONE(-1); - if(dt1->shared->u.vlen.f > dt2->shared->u.vlen.f) + if (dt1->shared->u.vlen.file > dt2->shared->u.vlen.file) HGOTO_DONE(1); break; case H5T_OPAQUE: - if(dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) - HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag,dt2->shared->u.opaque.tag)); + if (dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) + HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag, dt2->shared->u.opaque.tag)); break; case H5T_ARRAY: - if(dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) + if (dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) HGOTO_DONE(-1); - if(dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) + if (dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) HGOTO_DONE(1); - for(u=0; ushared->u.array.ndims; u++) { - if(dt1->shared->u.array.dim[u] < dt2->shared->u.array.dim[u]) + for (u = 0; u < dt1->shared->u.array.ndims; u++) { + if (dt1->shared->u.array.dim[u] < dt2->shared->u.array.dim[u]) HGOTO_DONE(-1); - if(dt1->shared->u.array.dim[u] > dt2->shared->u.array.dim[u]) + if (dt1->shared->u.array.dim[u] > dt2->shared->u.array.dim[u]) HGOTO_DONE(1); } tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent, superset); - if(tmp < 0) + if (tmp < 0) HGOTO_DONE(-1); - if(tmp > 0) + if (tmp > 0) HGOTO_DONE(1); break; @@ -4503,79 +4795,95 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* * Atomic datatypes... */ - if(dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) HGOTO_DONE(1); + if (dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) HGOTO_DONE(1); + if (dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) HGOTO_DONE(1); + if (dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) + HGOTO_DONE(1); switch (dt1->shared->type) { case H5T_INTEGER: - if(dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(1); break; case H5T_FLOAT: - if(dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) + HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(1); break; - case H5T_TIME: /* order and precision are checked above */ + case H5T_TIME: /* order and precision are checked above */ /*void */ break; case H5T_STRING: - if(dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(1); - if(dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(1); break; @@ -4585,32 +4893,18 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) break; case H5T_REFERENCE: - if(dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) + HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) + HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.r.file < dt2->shared->u.atomic.u.r.file) + HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.r.file > dt2->shared->u.atomic.u.r.file) HGOTO_DONE(1); - - switch(dt1->shared->u.atomic.u.r.rtype) { - case H5R_OBJECT: - if(dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc) - HGOTO_DONE(-1); - if(dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) - HGOTO_DONE(1); - break; - - case H5R_DATASET_REGION: - /* Does this need more to distinguish it? -QAK 11/30/98 */ - /*void */ - break; - - case H5R_BADTYPE: - case H5R_MAXTYPE: - HDassert("invalid type" && 0); - break; - default: - HDassert("not implemented yet" && 0); - break; - } break; case H5T_NO_CLASS: @@ -4624,19 +4918,18 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) HDassert("not implemented yet" && 0); break; } - break; + break; } /* end switch */ done: - if(NULL != idx1) + if (NULL != idx1) H5MM_xfree(idx1); - if(NULL != idx2) + if (NULL != idx2) H5MM_xfree(idx2); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_cmp() */ - /*------------------------------------------------------------------------- * Function: H5T_path_find * @@ -4660,8 +4953,8 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) 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_conv_func_t conv_func; /* Conversion function wrapper */ + H5T_path_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -4672,18 +4965,17 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst) HDassert(dst->shared); /* Set up conversion function wrapper */ - conv_func.is_app = FALSE; + conv_func.is_app = FALSE; conv_func.u.lib_func = NULL; /* Call the internal routine, with additional parameters */ - if(NULL == (ret_value = H5T__path_find_real(src, dst, NULL, &conv_func))) + if (NULL == (ret_value = H5T__path_find_real(src, dst, NULL, &conv_func))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't find datatype conversion path") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_path_find() */ - /*------------------------------------------------------------------------- * Function: H5T__path_find_real * @@ -4711,19 +5003,18 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst) *------------------------------------------------------------------------- */ static H5T_path_t * -H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, - H5T_conv_func_t *conv) +H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv) { - int lt, rt; /* left and right edges */ - int md; /* middle */ - int cmp; /* comparison result */ - int old_npaths; /* Previous number of paths in table */ - H5T_path_t *table = NULL; /* path existing in the table */ - H5T_path_t *path = NULL; /* new path */ - hid_t src_id = -1, dst_id = -1; /* src and dst type identifiers */ - int i; /* counter */ - int nprint = 0; /* lines of output printed */ - H5T_path_t *ret_value = NULL; /* Return value */ + int lt, rt; /* left and right edges */ + int md; /* middle */ + int cmp; /* comparison result */ + int old_npaths; /* Previous number of paths in table */ + H5T_path_t *table = NULL; /* path existing in the table */ + H5T_path_t *path = NULL; /* new path */ + hid_t src_id = -1, dst_id = -1; /* src and dst type identifiers */ + int i; /* counter */ + int nprint = 0; /* lines of output printed */ + H5T_path_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -4736,25 +5027,27 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, /* * Make sure the first entry in the table is the no-op conversion path. */ - if(0 == H5T_g.npaths) { - if(NULL == (H5T_g.path = (H5T_path_t **)H5MM_malloc(128 * sizeof(H5T_path_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path table") + if (0 == H5T_g.npaths) { + if (NULL == (H5T_g.path = (H5T_path_t **)H5MM_malloc(128 * sizeof(H5T_path_t *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for type conversion path table") H5T_g.apaths = 128; - if(NULL == (H5T_g.path[0] = H5FL_CALLOC(H5T_path_t))) + if (NULL == (H5T_g.path[0] = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for no-op conversion path") HDsnprintf(H5T_g.path[0]->name, sizeof(H5T_g.path[0]->name), "no-op"); - H5T_g.path[0]->conv.is_app = FALSE; + H5T_g.path[0]->conv.is_app = FALSE; H5T_g.path[0]->conv.u.lib_func = H5T__conv_noop; - H5T_g.path[0]->cdata.command = H5T_CONV_INIT; - if(H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + H5T_g.path[0]->cdata.command = H5T_CONV_INIT; + if (H5T__conv_noop((hid_t)FAIL, (hid_t)FAIL, &(H5T_g.path[0]->cdata), (size_t)0, (size_t)0, (size_t)0, + NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) + if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), "H5T: unable to initialize no-op conversion function (ignored)\n"); #endif H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ + } /* end if */ H5T_g.path[0]->is_noop = TRUE; - H5T_g.npaths = 1; + H5T_g.npaths = 1; } /* end if */ /* Find the conversion path. If source and destination types are equal @@ -4765,30 +5058,31 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * Only allow the no-op conversion to occur if no "force conversion" flags * are set */ - if(src->shared->force_conv == FALSE && dst->shared->force_conv == FALSE && 0 == H5T_cmp(src, dst, TRUE)) { + if (src->shared->force_conv == FALSE && dst->shared->force_conv == FALSE && + 0 == H5T_cmp(src, dst, TRUE)) { table = H5T_g.path[0]; - cmp = 0; - md = 0; + cmp = 0; + md = 0; } /* end if */ else { lt = md = 1; - rt = H5T_g.npaths; - cmp = -1; + rt = H5T_g.npaths; + cmp = -1; - while(cmp && lt < rt) { + while (cmp && lt < rt) { md = (lt + rt) / 2; HDassert(H5T_g.path[md]); cmp = H5T_cmp(src, H5T_g.path[md]->src, FALSE); - if(0 == cmp) + if (0 == cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else table = H5T_g.path[md]; } /* end while */ - } /* end else */ + } /* end else */ /* Keep a record of the number of paths in the table, in case one of the * initialization calls below (hard or soft) causes more entries to be @@ -4801,18 +5095,19 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * specifying a new hard conversion and the path is a soft conversion, then * create a new path and add the new function to the path. */ - if(!table || (table && conv->is_app && conv->u.app_func) || (table && !table->is_hard && !conv->is_app && conv->u.lib_func)) { - if(NULL == (path = H5FL_CALLOC(H5T_path_t))) + if (!table || (table && conv->is_app && conv->u.app_func) || + (table && !table->is_hard && !conv->is_app && conv->u.lib_func)) { + if (NULL == (path = H5FL_CALLOC(H5T_path_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path") - if(name && *name) { + if (name && *name) { HDstrncpy(path->name, name, (size_t)H5T_NAMELEN); path->name[H5T_NAMELEN - 1] = '\0'; } /* end if */ else HDsnprintf(path->name, sizeof(path->name), "NONAME"); - if(NULL == (path->src = H5T_copy(src, H5T_COPY_ALL))) + if (NULL == (path->src = H5T_copy(src, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy datatype for conversion path") - if(NULL == (path->dst = H5T_copy(dst, H5T_COPY_ALL))) + if (NULL == (path->dst = H5T_copy(dst, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy datatype for conversion path") } /* end if */ else @@ -4823,28 +5118,32 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * the existing path is a soft function, then add the new conversion to the path * and initialize its conversion data. */ - if(conv->u.app_func && (!table || (table && conv->is_app) || (table && !table->is_hard && !conv->is_app))) { + if (conv->u.app_func && + (!table || (table && conv->is_app) || (table && !table->is_hard && !conv->is_app))) { HDassert(path != table); HDassert(NULL == path->conv.u.app_func); - if(path->src && (src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source conversion type for query") - if(path->dst && (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination conversion type for query") + if (path->src && (src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register source conversion type for query") + if (path->dst && (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register destination conversion type for query") path->cdata.command = H5T_CONV_INIT; - if(conv->is_app) { - if((conv->u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) + if (conv->is_app) { + if ((conv->u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, + NULL, H5CX_get_dxpl()) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") } /* end if */ - else - if((conv->u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") - if(src_id >= 0) + else if ((conv->u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") + if (src_id >= 0) H5I_dec_ref(src_id); - if(dst_id >= 0) + if (dst_id >= 0) H5I_dec_ref(dst_id); src_id = dst_id = -1; - path->conv = *conv; - path->is_hard = TRUE; + path->conv = *conv; + path->is_hard = TRUE; } /* end if */ /* @@ -4854,143 +5153,149 @@ H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, * for the no-op conversion path. */ HDassert(path->conv.u.app_func || (src && dst)); - for(i = H5T_g.nsoft - 1; i >= 0 && !path->conv.u.app_func; --i) { + for (i = H5T_g.nsoft - 1; i >= 0 && !path->conv.u.app_func; --i) { hbool_t path_init_error = FALSE; - if(src->shared->type != H5T_g.soft[i].src || dst->shared->type != H5T_g.soft[i].dst) + if (src->shared->type != H5T_g.soft[i].src || dst->shared->type != H5T_g.soft[i].dst) continue; - if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register src conversion type for query") - if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register dst conversion type for query") + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(path->src, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register src conversion type for query") + if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, + "unable to register dst conversion type for query") path->cdata.command = H5T_CONV_INIT; - if(H5T_g.soft[i].conv.is_app) { - if((H5T_g.soft[i].conv.u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (H5T_g.soft[i].conv.is_app) { + if ((H5T_g.soft[i].conv.u.app_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); H5E_clear_stack(NULL); /*ignore the error*/ path_init_error = TRUE; } /* end if */ + } /* end if */ + else if ((H5T_g.soft[i].conv.u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { + HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); + H5E_clear_stack(NULL); /*ignore the error*/ + path_init_error = TRUE; } /* end if */ - else - if((H5T_g.soft[i].conv.u.lib_func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { - HDmemset(&(path->cdata), 0, sizeof(H5T_cdata_t)); - H5E_clear_stack(NULL); /*ignore the error*/ - path_init_error = TRUE; - } /* end if */ /* Finish operation, if no error */ - if(!path_init_error) { + if (!path_init_error) { HDstrncpy(path->name, H5T_g.soft[i].name, (size_t)H5T_NAMELEN); path->name[H5T_NAMELEN - 1] = '\0'; - path->conv = H5T_g.soft[i].conv; - path->is_hard = FALSE; + path->conv = H5T_g.soft[i].conv; + path->is_hard = FALSE; } /* end else */ H5I_dec_ref(src_id); H5I_dec_ref(dst_id); src_id = dst_id = -1; } /* end for */ - if(!path->conv.u.app_func) + if (!path->conv.u.app_func) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path") /* Check if paths were inserted into the table through a recursive call * and re-compute the correct location for this path if so. - QAK, 1/26/02 */ - if(old_npaths != H5T_g.npaths) { + if (old_npaths != H5T_g.npaths) { lt = md = 1; - rt = H5T_g.npaths; - cmp = -1; + rt = H5T_g.npaths; + cmp = -1; - while(cmp && lt < rt) { + while (cmp && lt < rt) { md = (lt + rt) / 2; HDassert(H5T_g.path[md]); cmp = H5T_cmp(src, H5T_g.path[md]->src, FALSE); - if(0 == cmp) + if (0 == cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst, FALSE); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else table = H5T_g.path[md]; } /* end while */ - } /* end if */ + } /* end if */ /* Replace an existing table entry or add a new entry */ - if(table && path != table) { + if (table && path != table) { HDassert(table == H5T_g.path[md]); - H5T__print_stats(table, &nprint/*in,out*/); + H5T__print_stats(table, &nprint /*in,out*/); table->cdata.command = H5T_CONV_FREE; - if(table->conv.is_app) { - if((table->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + if (table->conv.is_app) { + if ((table->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) + if (H5DEBUG(T)) HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); + (unsigned long)(path->conv.u.app_func), path->name); #endif H5E_clear_stack(NULL); /*ignore the failure*/ - } /* end if */ - } /* end if */ - else - if((table->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL) < 0) { + } /* end if */ + } /* end if */ + else if ((table->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(table->cdata), (size_t)0, (size_t)0, + (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if(H5DEBUG(T)) - HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); + if (H5DEBUG(T)) + HDfprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free failed for %s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); #endif - H5E_clear_stack(NULL); /*ignore the failure*/ - } /* end if */ - if(table->src) + H5E_clear_stack(NULL); /*ignore the failure*/ + } /* end if */ + if (table->src) (void)H5T_close_real(table->src); - if(table->dst) + if (table->dst) (void)H5T_close_real(table->dst); - table = H5FL_FREE(H5T_path_t, table); - table = path; + table = H5FL_FREE(H5T_path_t, table); + table = path; H5T_g.path[md] = path; } /* end if */ - else if(path != table) { + else if (path != table) { HDassert(cmp); - if((size_t)H5T_g.npaths >= H5T_g.apaths) { - size_t na = MAX(128, 2 * H5T_g.apaths); + if ((size_t)H5T_g.npaths >= H5T_g.apaths) { + size_t na = MAX(128, 2 * H5T_g.apaths); H5T_path_t **x; - if(NULL == (x = (H5T_path_t **)H5MM_realloc(H5T_g.path, na * sizeof(H5T_path_t*)))) + if (NULL == (x = (H5T_path_t **)H5MM_realloc(H5T_g.path, na * sizeof(H5T_path_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5T_g.apaths = na; - H5T_g.path = x; + H5T_g.path = x; } /* end if */ - if(cmp > 0) + if (cmp > 0) md++; - HDmemmove(H5T_g.path + md + 1, H5T_g.path + md, (size_t) (H5T_g.npaths - md) * sizeof(H5T_path_t*)); + HDmemmove(H5T_g.path + md + 1, H5T_g.path + md, (size_t)(H5T_g.npaths - md) * sizeof(H5T_path_t *)); H5T_g.npaths++; H5T_g.path[md] = path; - table = path; + table = path; } /* end else-if */ /* Set the flag to indicate both source and destination types are compound types - * for the optimization of data reading (in H5Dio.c). */ - if(H5T_COMPOUND == H5T_get_class(src, TRUE) && H5T_COMPOUND == H5T_get_class(dst, TRUE)) + * for the optimization of data reading (in H5Dio.c). + * Make sure that path->are_compounds is only TRUE for compound types. + */ + path->are_compounds = FALSE; + if (H5T_COMPOUND == H5T_get_class(src, TRUE) && H5T_COMPOUND == H5T_get_class(dst, TRUE)) path->are_compounds = TRUE; /* Set return value */ ret_value = path; done: - if(!ret_value && path && path != table) { - if(path->src) + if (!ret_value && path && path != table) { + if (path->src) (void)H5T_close_real(path->src); - if(path->dst) + if (path->dst) (void)H5T_close_real(path->dst); path = H5FL_FREE(H5T_path_t, path); } /* end if */ - if(src_id >= 0) + if (src_id >= 0) H5I_dec_ref(src_id); - if(dst_id >= 0) + if (dst_id >= 0) H5I_dec_ref(dst_id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__path_find_real() */ - /*------------------------------------------------------------------------- * Function: H5T_path_noop * @@ -5012,10 +5317,9 @@ H5T_path_noop(const H5T_path_t *p) HDassert(p); - FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst, FALSE))) + FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0 == H5T_cmp(p->src, p->dst, FALSE))) } /* end H5T_path_noop() */ - /*------------------------------------------------------------------------- * Function: H5T_path_compound_subset * @@ -5048,13 +5352,12 @@ H5T_path_compound_subset(const H5T_path_t *p) HDassert(p); - if(p->are_compounds) + if (p->are_compounds) ret_value = H5T__conv_struct_subset(&(p->cdata)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_path_compound_subset */ - /*------------------------------------------------------------------------- * Function: H5T_path_bkg * @@ -5076,7 +5379,6 @@ H5T_path_bkg(const H5T_path_t *p) FUNC_LEAVE_NOAPI(p->cdata.need_bkg) } /* end H5T_path_bkg() */ - /*------------------------------------------------------------------------- * Function: H5T__compiler_conv * @@ -5095,13 +5397,13 @@ H5T_path_bkg(const H5T_path_t *p) static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst) { - H5T_path_t *path; - htri_t ret_value = FAIL; /* Return value */ + H5T_path_t *path; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC /* Find it */ - if(NULL == (path = H5T_path_find(src, dst))) + if (NULL == (path = H5T_path_find(src, dst))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "conversion function not found") ret_value = (htri_t)path->is_hard; @@ -5110,7 +5412,6 @@ H5T__compiler_conv(H5T_t *src, H5T_t *dst) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__compiler_conv() */ - /*------------------------------------------------------------------------- * Function: H5T_convert * @@ -5127,18 +5428,18 @@ H5T__compiler_conv(H5T_t *src, H5T_t *dst) *------------------------------------------------------------------------- */ herr_t -H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, - size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) +H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg) { #ifdef H5T_DEBUG - H5_timer_t timer; /* Timer for conversion */ + H5_timer_t timer; /* Timer for conversion */ #endif - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5T_DEBUG - if(H5DEBUG(T)) { + if (H5DEBUG(T)) { /* Initialize and start timer */ H5_timer_init(&timer); H5_timer_start(&timer); @@ -5147,15 +5448,16 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, /* Call the appropriate conversion callback */ tpath->cdata.command = H5T_CONV_CONV; - if(tpath->conv.is_app) { - if((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg, H5CX_get_dxpl()) < 0) + if (tpath->conv.is_app) { + if ((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, + bkg, H5CX_get_dxpl()) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ - else - if((tpath->conv.u.lib_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") + else if ((tpath->conv.u.lib_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, + bkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") #ifdef H5T_DEBUG - if(H5DEBUG(T)) { + if (H5DEBUG(T)) { /* Stop timer */ H5_timer_stop(&timer); @@ -5172,7 +5474,6 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_convert() */ - /*------------------------------------------------------------------------- * Function: H5T_oloc * @@ -5195,7 +5496,7 @@ H5T_oloc(H5T_t *dt) HDassert(dt); - switch(dt->shared->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: @@ -5213,7 +5514,6 @@ H5T_oloc(H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_oloc() */ - /*------------------------------------------------------------------------- * Function: H5T_nameof * @@ -5236,7 +5536,7 @@ H5T_nameof(const H5T_t *dt) HDassert(dt); - switch(dt->shared->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: @@ -5253,7 +5553,6 @@ H5T_nameof(const H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_nameof() */ - /*------------------------------------------------------------------------- * Function: H5T_is_immutable * @@ -5276,14 +5575,13 @@ H5T_is_immutable(const H5T_t *dt) HDassert(dt); - if(dt->shared->state == H5T_STATE_IMMUTABLE) + if (dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_is_named * @@ -5302,7 +5600,10 @@ H5T_is_named(const H5T_t *dt) HDassert(dt); - ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); + if (dt->vol_obj) + ret_value = TRUE; + else + ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); done: FUNC_LEAVE_NOAPI(ret_value) @@ -5328,29 +5629,42 @@ H5T_is_named(const H5T_t *dt) herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); HDassert(f); - if(H5T_is_named(dt) && (dt->sh_loc.file != f)) { - HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); + if (H5T_is_named(dt) && (dt->sh_loc.file != f)) { + HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); H5O_msg_reset_share(H5O_DTYPE_ID, dt); - if(H5O_loc_free(&dt->oloc) < 0) + if (H5O_loc_free(&dt->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_free(&dt->path) < 0) + if (H5G_name_free(&dt->path) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") + /* If the datatype is committed through the VOL, close it */ + if (NULL != dt->vol_obj) { + H5VL_object_t *vol_obj = dt->vol_obj; + + /* Close the datatype through the VOL*/ + if (H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") + + /* Free the datatype and set the VOL object pointer to NULL */ + if (H5VL_free_object(vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + dt->vol_obj = NULL; + } /* end if */ + dt->shared->state = H5T_STATE_TRANSIENT; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_convert_committed_datatype() */ - +} /* end H5T_convert_committed_datatype() */ /*-------------------------------------------------------------------------- * Function: H5T_get_ref_type @@ -5373,13 +5687,12 @@ H5T_get_ref_type(const H5T_t *dt) HDassert(dt); - if(dt->shared->type==H5T_REFERENCE) - ret_value=dt->shared->u.atomic.u.r.rtype; + if (dt->shared->type == H5T_REFERENCE) + ret_value = dt->shared->u.atomic.u.r.rtype; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_get_ref_type() */ - +} /* end H5T_get_ref_type() */ /*------------------------------------------------------------------------- * Function: H5T_is_sensible @@ -5398,27 +5711,27 @@ H5T_get_ref_type(const H5T_t *dt) htri_t H5T_is_sensible(const H5T_t *dt) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: /* Only allow compound datatypes with at least one member to be stored on disk */ - if(dt->shared->u.compnd.nmembs > 0) - ret_value=TRUE; + if (dt->shared->u.compnd.nmembs > 0) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; break; case H5T_ENUM: /* Only allow enum datatypes with at least one member to be stored on disk */ - if(dt->shared->u.enumer.nmembs > 0) - ret_value=TRUE; + if (dt->shared->u.enumer.nmembs > 0) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; break; case H5T_NO_CLASS: @@ -5434,7 +5747,7 @@ H5T_is_sensible(const H5T_t *dt) case H5T_NCLASSES: default: /* Assume all other datatype are sensible to store on disk */ - ret_value=TRUE; + ret_value = TRUE; break; } /* end switch */ @@ -5442,7 +5755,6 @@ H5T_is_sensible(const H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } - /*-------------------------------------------------------------------------- NAME H5T_set_loc @@ -5452,7 +5764,7 @@ H5T_is_sensible(const H5T_t *dt) htri_t H5T_set_loc(dt,f,loc) H5T_t *dt; IN/OUT: Pointer to the datatype to mark H5F_t *f; IN: Pointer to the file the datatype is in - H5T_vlen_type_t loc IN: location of type + H5T_loc_t loc IN: location of type RETURNS One of two values on success: @@ -5465,129 +5777,128 @@ H5T_is_sensible(const H5T_t *dt) -------------------------------------------------------------------------- */ htri_t -H5T_set_loc(H5T_t *dt, H5F_t *file, H5T_loc_t loc) +H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) { - htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */ - htri_t ret_value = 0; /* Indicate that success, but no location change */ - unsigned i; /* Local index variable */ - size_t old_size; /* Previous size of a field */ + htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */ + htri_t ret_value = 0; /* Indicate that success, but no location change */ + unsigned i; /* Local index variable */ + size_t old_size; /* Previous size of a field */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - HDassert(loc>=H5T_LOC_BADLOC && loc= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Datatypes can't change in size if the force_conv flag is not set */ - if(dt->shared->force_conv) { + if (dt->shared->force_conv) { /* Check the datatype of this element */ - switch(dt->shared->type) { - case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ + switch (dt->shared->type) { + case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + if (dt->shared->parent->shared->force_conv && + H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { /* Keep the old base element size for later */ - old_size=dt->shared->parent->shared->size; + old_size = dt->shared->parent->shared->size; /* Mark the VL, compound or array type */ - if((changed=H5T_set_loc(dt->shared->parent, file, loc))<0) + if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") - if(changed>0) - ret_value=changed; + if (changed > 0) + ret_value = changed; /* Check if the field changed size */ - if(old_size != dt->shared->parent->shared->size) { + if (old_size != dt->shared->parent->shared->size) { /* Adjust the size of the array */ - dt->shared->size = dt->shared->u.array.nelem*dt->shared->parent->shared->size; + dt->shared->size = dt->shared->u.array.nelem * dt->shared->parent->shared->size; } /* end if */ - } /* end if */ + } /* end if */ break; - case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ - { - ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ + case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ + { + ssize_t accum_change = 0; /* Amount of change in the offset of the fields */ - /* Sort the fields based on offsets */ - H5T__sort_value(dt, NULL); + /* Sort the fields based on offsets */ + H5T__sort_value(dt, NULL); - for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - H5T_t *memb_type; /* Member's datatype pointer */ + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + H5T_t *memb_type; /* Member's datatype pointer */ - /* Range check against compound member's offset */ - if ((accum_change < 0) && ((ssize_t) dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + /* Range check against compound member's offset */ + if ((accum_change < 0) && ((ssize_t)dt->shared->u.compnd.memb[i].offset < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); - /* Apply the accumulated size change to the offset of the field */ - dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; + /* Apply the accumulated size change to the offset of the field */ + dt->shared->u.compnd.memb[i].offset += (size_t)accum_change; - /* Set the member type pointer (for convenience) */ - memb_type = dt->shared->u.compnd.memb[i].type; + /* Set the member type pointer (for convenience) */ + memb_type = dt->shared->u.compnd.memb[i].type; - /* Recurse if it's VL, compound, enum or array */ - /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { - /* Keep the old field size for later */ - old_size = memb_type->shared->size; + /* Recurse if it's VL, compound, enum or array */ + /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) + */ + if (memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { + /* Keep the old field size for later */ + old_size = memb_type->shared->size; - /* Mark the VL, compound, enum or array type */ - if((changed = H5T_set_loc(memb_type, file, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) - ret_value = changed; + /* Mark the VL, compound, enum or array type */ + if ((changed = H5T_set_loc(memb_type, file, loc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + if (changed > 0) + ret_value = changed; - /* Check if the field changed size */ - if(old_size != memb_type->shared->size) { + /* Check if the field changed size */ + if (old_size != memb_type->shared->size) { - /* Fail if the old_size is zero */ - if (0 == old_size) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); + /* Fail if the old_size is zero */ + if (0 == old_size) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, + "old_size of zero would cause division by zero"); - /* Adjust the size of the member */ - dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; + /* Adjust the size of the member */ + dt->shared->u.compnd.memb[i].size = + (dt->shared->u.compnd.memb[i].size * memb_type->shared->size) / old_size; - /* Add that change to the accumulated size change */ - accum_change += (ssize_t) (memb_type->shared->size - old_size); - } /* end if */ + /* Add that change to the accumulated size change */ + accum_change += (ssize_t)(memb_type->shared->size - old_size); } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ - /* Range check against datatype size */ - if ((accum_change < 0) && ((ssize_t) dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + /* Range check against datatype size */ + if ((accum_change < 0) && ((ssize_t)dt->shared->size < accum_change)) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); - /* Apply the accumulated size change to the datatype */ - dt->shared->size += (size_t) accum_change; - } - break; + /* Apply the accumulated size change to the datatype */ + dt->shared->size += (size_t)accum_change; + } break; - case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ - /* Recurse if it's VL, compound, enum or array */ + case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL + sequence */ + /* Recurse if it's VL, compound, enum or array (ignore references here so that we can encode + * them as part of the same blob)*/ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - if((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) + if (dt->shared->parent->shared->force_conv && + H5T_IS_COMPLEX(dt->shared->parent->shared->type) && + (dt->shared->parent->shared->type != H5T_REFERENCE)) { + if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) + if (changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ - if((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) + if ((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - if(changed > 0) + if (changed > 0) ret_value = changed; break; case H5T_REFERENCE: - /* Only need to change location of object references */ - if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) { - /* Mark this reference */ - if(loc != dt->shared->u.atomic.u.r.loc) { - /* Set the location */ - dt->shared->u.atomic.u.r.loc = loc; - - /* Indicate that the location changed */ - ret_value = TRUE; - } /* end if */ - } /* end if */ + /* Reference types go through type conversion */ + if ((ret_value = H5T__ref_set_loc(dt, file, loc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "Unable to set reference location"); break; case H5T_NO_CLASS: @@ -5602,19 +5913,18 @@ H5T_set_loc(H5T_t *dt, H5F_t *file, H5T_loc_t loc) default: break; } /* end switch */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_set_loc() */ - +} /* end H5T_set_loc() */ /*------------------------------------------------------------------------- * Function: H5T_is_relocatable * * Purpose: Check if a datatype will change between disk and memory. * - * Notes: Currently, only variable-length and object references change + * Notes: Currently, only variable-length and references change * between disk & memory (see cases where things are changed in * the H5T_set_loc() code above). * @@ -5640,18 +5950,17 @@ H5T_is_relocatable(const H5T_t *dt) HDassert(dt); /* VL and reference datatypes are relocatable */ - if(H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) + if (H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) ret_value = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_relocatable() */ - /*------------------------------------------------------------------------- - * Function: H5T_detect_reg_ref + * Function: H5T__detect_vlen_ref * - * Purpose: Check whether a datatype contains (or is) a region reference + * Purpose: Check whether a datatype contains (or is) a vlen reference * datatype. * * Return: TRUE (1) or FALSE (0) on success @@ -5663,34 +5972,35 @@ H5T_is_relocatable(const H5T_t *dt) *------------------------------------------------------------------------- */ static hbool_t -H5T__detect_reg_ref(const H5T_t *dt) +H5T__detect_vlen_ref(const H5T_t *dt) { - unsigned u; /* Local index variable */ - hbool_t ret_value = FALSE; /* Return value */ + unsigned u; /* Local index variable */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(dt); - /* Check if this datatype is a region reference */ - if(H5T_REFERENCE == dt->shared->type && H5R_DATASET_REGION == dt->shared->u.atomic.u.r.rtype) + /* Check if this datatype is a vlen reference */ + /* TODO currently H5T_STD_REF is always considered as a vlen type */ + if (H5T_REFERENCE == dt->shared->type && !dt->shared->u.atomic.u.r.opaque) HGOTO_DONE(TRUE); /* Check for types that might have the correct type as a component */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: /* Iterate over all the compound datatype's fields */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) /* Recurse on field's datatype */ - if(H5T__detect_reg_ref(dt->shared->u.compnd.memb[u].type)) + if (H5T__detect_vlen_ref(dt->shared->u.compnd.memb[u].type)) HGOTO_DONE(TRUE); break; case H5T_ARRAY: case H5T_VLEN: case H5T_ENUM: - HGOTO_DONE(H5T__detect_reg_ref(dt->shared->parent)); + HGOTO_DONE(H5T__detect_vlen_ref(dt->shared->parent)); break; case H5T_NO_CLASS: @@ -5708,8 +6018,7 @@ H5T__detect_reg_ref(const H5T_t *dt) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__detect_reg_ref() */ - +} /* end H5T__detect_vlen_ref() */ /*------------------------------------------------------------------------- * Function: H5T_is_vl_storage @@ -5741,10 +6050,10 @@ H5T_is_vl_storage(const H5T_t *dt) HDassert(dt); /* VL and region reference datatypes are stored in variable-length form */ - if(H5T_detect_class(dt, H5T_VLEN, FALSE)) + if (H5T_detect_class(dt, H5T_VLEN, FALSE)) ret_value = TRUE; - else if(H5T_detect_class(dt, H5T_REFERENCE, FALSE)) - ret_value = H5T__detect_reg_ref(dt); + else if (H5T_detect_class(dt, H5T_REFERENCE, FALSE)) + ret_value = H5T__detect_vlen_ref(dt); else ret_value = FALSE; @@ -5752,9 +6061,8 @@ H5T_is_vl_storage(const H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_vl_storage() */ - /*------------------------------------------------------------------------- - * Function: H5T_upgrade_version_cb + * Function: H5T__upgrade_version_cb * * Purpose: H5T__visit callback to Upgrade the version of a datatype * (if there's any benefit to doing so) @@ -5780,17 +6088,17 @@ H5T__upgrade_version_cb(H5T_t *dt, void *op_value) HDassert(op_value); /* Special behavior for each type of datatype */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: case H5T_ARRAY: case H5T_ENUM: /* These types benefit from "upgrading" their version */ - if(*(unsigned *)op_value > dt->shared->version) + if (*(unsigned *)op_value > dt->shared->version) dt->shared->version = *(unsigned *)op_value; break; case H5T_VLEN: - if(dt->shared->parent->shared->version > dt->shared->version) + if (dt->shared->parent->shared->version > dt->shared->version) dt->shared->version = dt->shared->parent->shared->version; break; @@ -5810,7 +6118,6 @@ H5T__upgrade_version_cb(H5T_t *dt, void *op_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__upgrade_version_cb() */ - /*------------------------------------------------------------------------- * Function: H5T__upgrade_version * @@ -5828,7 +6135,7 @@ H5T__upgrade_version_cb(H5T_t *dt, void *op_value) herr_t H5T__upgrade_version(H5T_t *dt, unsigned new_version) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5836,14 +6143,14 @@ H5T__upgrade_version(H5T_t *dt, unsigned new_version) HDassert(dt); /* Iterate over entire datatype, upgrading the version of components, if it's useful */ - if(H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPLEX_LAST), H5T__upgrade_version_cb, &new_version) < 0) + if (H5T__visit(dt, (H5T_VISIT_SIMPLE | H5T_VISIT_COMPLEX_LAST), H5T__upgrade_version_cb, &new_version) < + 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "iteration to upgrade datatype encoding version failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__upgrade_version() */ - /*------------------------------------------------------------------------- * Function: H5T_set_version * @@ -5860,8 +6167,8 @@ H5T__upgrade_version(H5T_t *dt, unsigned new_version) herr_t H5T_set_version(H5F_t *f, H5T_t *dt) { - unsigned vers; /* The version */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned vers; /* The version */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -5870,21 +6177,20 @@ H5T_set_version(H5F_t *f, H5T_t *dt) HDassert(dt); vers = H5O_dtype_ver_bounds[H5F_LOW_BOUND(f)]; - if(vers > dt->shared->version) { + if (vers > dt->shared->version) { /* Upgrade the format version for the datatype */ - if(H5T__upgrade_version(dt, vers) < 0) + if (H5T__upgrade_version(dt, vers) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade datatype encoding") } /* Version bounds check */ - if(dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) + if (dt->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(f)]) HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "Datatype version out of bounds") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_set_version() */ - /*------------------------------------------------------------------------- * Function: H5T_patch_file * @@ -5911,8 +6217,8 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) HDassert(dt); HDassert(f); - if(H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) { - dt->oloc.file = f; + if (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) { + dt->oloc.file = f; dt->sh_loc.file = f; } /* end if */ @@ -5920,7 +6226,6 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_patch_file() */ - /*------------------------------------------------------------------------- * Function: H5T_patch_vlen_file * @@ -5934,7 +6239,7 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5T_patch_vlen_file(H5T_t *dt, H5F_t *file) +H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -5943,9 +6248,46 @@ H5T_patch_vlen_file(H5T_t *dt, H5F_t *file) HDassert(dt->shared); HDassert(file); - if((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.f != file) - dt->shared->u.vlen.f = file; + if ((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file != file) + dt->shared->u.vlen.file = file; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_patch_vlen_file() */ +/*------------------------------------------------------------------------- + * Function: H5T_own_vol_obj + * + * Purpose: Transfers ownership of the supplied VOL object to the + * datatype, the VOL object will be freed when the datatype + * is closed. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(dt); + HDassert(dt->shared); + HDassert(vol_obj); + + /* Currently no support for owning multiple VOL objects, free the previous + * owned object. Currently this is only used for holding open VOL objects + * used in the "loc" for vlens and references, so if this is being + * overwritten we don't need the old one anyways. */ + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") + + /* Take ownership */ + dt->shared->owned_vol_obj = vol_obj; + (void)H5VL_object_inc_rc(vol_obj); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_own_vol_obj() */ diff --git a/src/H5TS.c b/src/H5TS.c index ee3b2191dee..321a83d4af1 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -6,39 +6,48 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* private headers */ -#include "H5private.h" /*library */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /*memory management functions */ +/* + * Purpose: This file contains the framework for ensuring that the global + * library lock is held when an API routine is called. This + * framework works in concert with the FUNC_ENTER_API / FUNC_LEAVE_API + * macros defined in H5private.h. + * + * Note: Because this threadsafety framework operates outside the library, + * it does not use the error stack. + */ + +/****************/ +/* Module Setup */ +/****************/ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ #ifdef H5_HAVE_THREADSAFE -/* Module specific data structures */ +/****************/ +/* Local Macros */ +/****************/ -/* cancelability structure */ +/******************/ +/* Local Typedefs */ +/******************/ + +/* Cancelability structure */ typedef struct H5TS_cancel_struct { - int previous_state; + int previous_state; unsigned int cancel_count; } H5TS_cancel_t; -/* Global variable definitions */ -#ifdef H5_HAVE_WIN_THREADS -H5TS_once_t H5TS_first_init_g; -#else /* H5_HAVE_WIN_THREADS */ -H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; -#endif /* H5_HAVE_WIN_THREADS */ -H5TS_key_t H5TS_errstk_key_g; -H5TS_key_t H5TS_funcstk_key_g; -H5TS_key_t H5TS_apictx_key_g; -H5TS_key_t H5TS_cancel_key_g; - #ifndef H5_HAVE_WIN_THREADS - /* An H5TS_tid_t is a record of a thread identifier that is * available for reuse. */ @@ -47,12 +56,59 @@ typedef struct _tid H5TS_tid_t; struct _tid { H5TS_tid_t *next; - uint64_t id; + uint64_t id; }; +#endif + +/********************/ +/* Local Prototypes */ +/********************/ +static void H5TS__key_destructor(void *key_val); +#ifndef H5_HAVE_WIN_THREADS +static void H5TS_tid_destructor(void *_v); +static void H5TS_tid_init(void); +#endif + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/* Global variable definitions */ +#ifdef H5_HAVE_WIN_THREADS +H5TS_once_t H5TS_first_init_g; +#else +H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; +#endif + +/* Thread-local keys, used by other interfaces */ + +/* Error stack */ +H5TS_key_t H5TS_errstk_key_g; + +/* Function stack */ +#ifdef H5_HAVE_CODESTACK +H5TS_key_t H5TS_funcstk_key_g; +#endif + +/* API context */ +H5TS_key_t H5TS_apictx_key_g; + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Thread-local keys, used in this module */ +static H5TS_key_t H5TS_cancel_key_s; /* Thread cancellation state */ + +#ifndef H5_HAVE_WIN_THREADS /* Pointer to first free thread ID record or NULL. */ static H5TS_tid_t *H5TS_tid_next_free = NULL; -static uint64_t H5TS_tid_next_id = 0; +static uint64_t H5TS_tid_next_id = 0; /* Mutual exclusion for access to H5TS_tid_next_free and H5TS_tid_next_id. */ static pthread_mutex_t H5TS_tid_mtx; @@ -60,51 +116,39 @@ static pthread_mutex_t H5TS_tid_mtx; /* Key for thread-local storage of the thread ID. */ static H5TS_key_t H5TS_tid_key; -#endif /* H5_HAVE_WIN_THREADS */ +#endif - /*-------------------------------------------------------------------------- - * NAME - * H5TS_key_destructor + * Function: H5TS__key_destructor * - * USAGE - * H5TS_key_destructor() + * Returns: void * - * RETURNS - * - * DESCRIPTION + * Description: * Frees the memory for a key. Called by each thread as it exits. * Currently all the thread-specific information for all keys are simple * structures allocated with malloc, so we can free them all uniformly. * - * PROGRAMMER: Quincey Koziol - * February 7, 2003 - * + * Programmer: Quincey Koziol + * February 7, 2003 *-------------------------------------------------------------------------- */ static void -H5TS_key_destructor(void *key_val) +H5TS__key_destructor(void *key_val) { /* Use HDfree here instead of H5MM_xfree(), to avoid calling the H5CS routines */ - if(key_val != NULL) + if (key_val != NULL) HDfree(key_val); -} +} /* end H5TS__key_destructor() */ - #ifndef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- - * NAME - * H5TS_tid_destructor + * Function: H5TS_tid_destructor * - * USAGE - * H5TS_tid_destructor() - * - * RETURNS + * Returns: void * - * DESCRIPTION + * Description: * When a thread shuts down, put its ID record on the free list. - * *-------------------------------------------------------------------------- */ static void @@ -117,23 +161,18 @@ H5TS_tid_destructor(void *_v) /* TBD use an atomic CAS */ pthread_mutex_lock(&H5TS_tid_mtx); - tid->next = H5TS_tid_next_free; + tid->next = H5TS_tid_next_free; H5TS_tid_next_free = tid; pthread_mutex_unlock(&H5TS_tid_mtx); } /*-------------------------------------------------------------------------- - * NAME - * H5TS_tid_init - * - * USAGE - * H5TS_tid_init() + * Function: H5TS_tid_init * - * RETURNS - * - * DESCRIPTION - * Initialize for integer thread identifiers. + * Returns: void * + * Description: + * Initialization for integer thread identifiers. *-------------------------------------------------------------------------- */ static void @@ -143,17 +182,154 @@ H5TS_tid_init(void) pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); } +#endif + +#ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- - * NAME - * H5TS_thread_id + * Function: H5TS_win32_process_enter * - * USAGE - * uint64_t id = H5TS_thread_id() + * Returns: TRUE on success, FALSE on failure * - * RETURNS - * Return an integer identifier, ID, for the current thread. + * Description: + * Per-process setup on Windows when using Win32 threads. * - * DESCRIPTION + *-------------------------------------------------------------------------- + */ +H5_DLL BOOL CALLBACK +H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) +{ + BOOL ret_value = TRUE; + + /* initialize global API mutex lock */ + InitializeCriticalSection(&H5_g.init_lock.CriticalSection); + + /* Set up thread local storage */ + if (TLS_OUT_OF_INDEXES == (H5TS_errstk_key_g = TlsAlloc())) + ret_value = FALSE; + +#ifdef H5_HAVE_CODESTACK + if (TLS_OUT_OF_INDEXES == (H5TS_funcstk_key_g = TlsAlloc())) + ret_value = FALSE; +#endif + + if (TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) + ret_value = FALSE; + + return ret_value; +} /* H5TS_win32_process_enter() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_win32_thread_enter + * + * Returns: SUCCEED/FAIL + * + * Description: + * Per-thread setup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_win32_thread_enter(void) +{ + herr_t ret_value = SUCCEED; + + /* Currently a placeholder function. TLS setup is performed + * elsewhere in the library. + * + * WARNING: Do NOT use C standard library functions here. + * CRT functions are not allowed in DllMain, which is where this code + * is used. + */ + + return ret_value; +} /* H5TS_win32_thread_enter() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_win32_process_exit + * + * Returns: void + * + * Description: + * Per-process cleanup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +void +H5TS_win32_process_exit(void) +{ + + /* Windows uses a different thread local storage mechanism which does + * not support auto-freeing like pthreads' keys. + * + * This function is currently registered via atexit() and is called + * AFTER H5_term_library(). + */ + + /* Clean up critical section resources (can't fail) */ + DeleteCriticalSection(&H5_g.init_lock.CriticalSection); + + /* Clean up per-process thread local storage */ + TlsFree(H5TS_errstk_key_g); +#ifdef H5_HAVE_CODESTACK + TlsFree(H5TS_funcstk_key_g); +#endif + TlsFree(H5TS_apictx_key_g); + + return; +} /* end H5TS_win32_process_exit() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_win32_thread_exit + * + * Returns: SUCCEED/FAIL + * + * Description: + * Per-thread cleanup on Windows when using Win32 threads. + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_win32_thread_exit(void) +{ + LPVOID lpvData; + herr_t ret_value = SUCCEED; + + /* Windows uses a different thread local storage mechanism which does + * not support auto-freeing like pthreads' keys. + * + * WARNING: Do NOT use C standard library functions here. + * CRT functions are not allowed in DllMain, which is where this code + * is used. + */ + + /* Clean up per-thread thread local storage */ + lpvData = TlsGetValue(H5TS_errstk_key_g); + if (lpvData) + LocalFree((HLOCAL)lpvData); + +#ifdef H5_HAVE_CODESTACK + lpvData = TlsGetValue(H5TS_funcstk_key_g); + if (lpvData) + LocalFree((HLOCAL)lpvData); +#endif + + lpvData = TlsGetValue(H5TS_apictx_key_g); + if (lpvData) + LocalFree((HLOCAL)lpvData); + + return ret_value; +} /* end H5TS_win32_thread_exit() */ + +#endif /* H5_HAVE_WIN_THREADS */ + +#ifndef H5_HAVE_WIN_THREADS + +/*-------------------------------------------------------------------------- + * Function: H5TS_thread_id + * + * Returns: An integer identifier for the current thread + * + * Description: * The ID satisfies the following properties: * * 1 1 <= ID <= UINT64_MAX @@ -171,7 +347,7 @@ uint64_t H5TS_thread_id(void) { H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key); - H5TS_tid_t proto_tid; + H5TS_tid_t proto_tid; /* An ID is already assigned. */ if (tid != NULL) @@ -188,16 +364,15 @@ H5TS_thread_id(void) if ((tid = H5TS_tid_next_free) != NULL) H5TS_tid_next_free = tid->next; else if (H5TS_tid_next_id != UINT64_MAX) { - tid = &proto_tid; + tid = &proto_tid; tid->id = ++H5TS_tid_next_id; } pthread_mutex_unlock(&H5TS_tid_mtx); /* If a prototype ID record was established, copy it to the heap. */ - if (tid == &proto_tid) { + if (tid == &proto_tid) if ((tid = HDmalloc(sizeof(*tid))) != NULL) *tid = proto_tid; - } if (tid == NULL) return 0; @@ -215,20 +390,16 @@ H5TS_thread_id(void) } /*-------------------------------------------------------------------------- - * NAME - * H5TS_pthread_first_thread_init - * - * USAGE - * H5TS_pthread_first_thread_init() + * Function: H5TS_pthread_first_thread_init * - * RETURNS + * Returns: void * - * DESCRIPTION + * Description: * Initialization of global API lock, keys for per-thread error stacks and * cancallability information. Called by the first thread that enters the * library. * - * PROGRAMMER: Chee Wai LEE + * Programmer: Chee Wai LEE * May 2, 2000 * *-------------------------------------------------------------------------- @@ -236,54 +407,57 @@ H5TS_thread_id(void) void H5TS_pthread_first_thread_init(void) { - H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ - H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ + H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ + H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ #ifdef H5_HAVE_WIN32_API -# ifdef PTW32_STATIC_LIB +#ifdef PTW32_STATIC_LIB pthread_win32_process_attach_np(); -# endif +#endif #endif /* initialize global API mutex lock */ +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS + H5TS_rw_lock_init(&H5_g.init_rw_lock, H5TS_RW_LOCK_POLICY_FAVOR_WRITERS); +#else pthread_mutex_init(&H5_g.init_lock.atomic_lock, NULL); pthread_cond_init(&H5_g.init_lock.cond_var, NULL); H5_g.init_lock.lock_count = 0; +#endif /* Initialize integer thread identifiers. */ H5TS_tid_init(); /* initialize key for thread-specific error stacks */ - pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor); + pthread_key_create(&H5TS_errstk_key_g, H5TS__key_destructor); +#ifdef H5_HAVE_CODESTACK /* initialize key for thread-specific function stacks */ - pthread_key_create(&H5TS_funcstk_key_g, H5TS_key_destructor); + pthread_key_create(&H5TS_funcstk_key_g, H5TS__key_destructor); +#endif /* initialize key for thread-specific API contexts */ - pthread_key_create(&H5TS_apictx_key_g, H5TS_key_destructor); + pthread_key_create(&H5TS_apictx_key_g, H5TS__key_destructor); /* initialize key for thread cancellability mechanism */ - pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); -} + pthread_key_create(&H5TS_cancel_key_s, H5TS__key_destructor); + +} /* end H5TS_pthread_first_thread_init() */ + #endif /* H5_HAVE_WIN_THREADS */ - /*-------------------------------------------------------------------------- - * NAME - * H5TS_mutex_lock + * Function: H5TS_mutex_lock * - * USAGE - * H5TS_mutex_lock(&mutex_var) * - * RETURNS - * 0 on success and non-zero on error. + * Returns: SUCCEED/FAIL * - * DESCRIPTION + * Description: * Recursive lock semantics for HDF5 (locking) - * Multiple acquisition of a lock by a thread is permitted with a * corresponding unlock operation required. * - * PROGRAMMER: Chee Wai LEE + * Programmer: Chee Wai LEE * May 2, 2000 * *-------------------------------------------------------------------------- @@ -291,49 +465,48 @@ H5TS_pthread_first_thread_init(void) herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS - EnterCriticalSection( &mutex->CriticalSection); - return 0; -#else /* H5_HAVE_WIN_THREADS */ - herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); - - if (ret_value) - return ret_value; + herr_t ret_value = SUCCEED; - if(mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) { +#ifdef H5_HAVE_WIN_THREADS + EnterCriticalSection(&mutex->CriticalSection); +#else + /* Acquire the library lock */ + if (pthread_mutex_lock(&mutex->atomic_lock) != 0) + return FAIL; + + /* Check if this thread already owns the lock */ + if (mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) /* already owned by self - increment count */ mutex->lock_count++; - } else { - /* if owned by other thread, wait for condition signal */ - while(mutex->lock_count) + else { + /* Wait until the lock is released by current owner thread */ + while (mutex->lock_count) pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); /* After we've received the signal, take ownership of the mutex */ mutex->owner_thread = pthread_self(); - mutex->lock_count = 1; - } + mutex->lock_count = 1; + } /* end else */ - return pthread_mutex_unlock(&mutex->atomic_lock); -#endif /* H5_HAVE_WIN_THREADS */ -} + /* Release the library lock */ + if (pthread_mutex_unlock(&mutex->atomic_lock) != 0) + ret_value = FAIL; +#endif + + return ret_value; +} /* end H5TS_mutex_lock() */ - /*-------------------------------------------------------------------------- - * NAME - * H5TS_mutex_unlock - * - * USAGE - * H5TS_mutex_unlock(&mutex_var) + * Function: H5TS_mutex_unlock * - * RETURNS - * 0 on success and non-zero on error. + * Returns: SUCCEED/FAIL * - * DESCRIPTION + * Description: * Recursive lock semantics for HDF5 (unlocking) - * Multiple acquisition of a lock by a thread is permitted with a * corresponding unlock operation required. * - * PROGRAMMER: Chee Wai LEE + * Programmer: Chee Wai LEE * May 2, 2000 * *-------------------------------------------------------------------------- @@ -341,53 +514,47 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS + herr_t ret_value = SUCCEED; + +#ifdef H5_HAVE_WIN_THREADS /* Releases ownership of the specified critical section object. */ LeaveCriticalSection(&mutex->CriticalSection); - return 0; -#else /* H5_HAVE_WIN_THREADS */ - herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); - - if(ret_value) - return ret_value; +#else + /* Decrement the lock count for this thread */ + if (pthread_mutex_lock(&mutex->atomic_lock) != 0) + return FAIL; mutex->lock_count--; + if (pthread_mutex_unlock(&mutex->atomic_lock) != 0) + ret_value = FAIL; - ret_value = pthread_mutex_unlock(&mutex->atomic_lock); - - if(mutex->lock_count == 0) { - int err; - - err = pthread_cond_signal(&mutex->cond_var); - if(err != 0) - ret_value = err; - } /* end if */ + /* If the lock count drops to zero, signal the condition variable, to + * wake another thread. + */ + if (mutex->lock_count == 0) + if (pthread_cond_signal(&mutex->cond_var) != 0) + ret_value = FAIL; +#endif /* H5_HAVE_WIN_THREADS */ return ret_value; -#endif /* H5_HAVE_WIN_THREADS */ } /* H5TS_mutex_unlock */ - /*-------------------------------------------------------------------------- - * NAME - * H5TS_cancel_count_inc + * Function: H5TS_cancel_count_inc * - * USAGE - * H5TS_cancel_count_inc() - * - * RETURNS - * 0 on success non-zero error code on error. + * Returns: SUCCEED/FAIL * - * DESCRIPTION - * Creates a cancelation counter for a thread if it is the first time + * Description: + * 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 * to PTHREAD_CANCEL_DISABLE as thread is entering the library and store - * the previous cancelability type into cancelation counter. + * the previous cancelability type into cancellation counter. + * * Increase the counter value by 1. * - * PROGRAMMER: Chee Wai LEE + * Programmer: Chee Wai LEE * May 2, 2000 * *-------------------------------------------------------------------------- @@ -395,15 +562,15 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) herr_t H5TS_cancel_count_inc(void) { -#ifdef H5_HAVE_WIN_THREADS - /* unsupported; just return 0 */ - return SUCCEED; -#else /* H5_HAVE_WIN_THREADS */ - H5TS_cancel_t *cancel_counter; herr_t ret_value = SUCCEED; - cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); +#ifndef H5_HAVE_WIN_THREADS + H5TS_cancel_t *cancel_counter; + /* Acquire the thread's cancellation counter */ + cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_s); + + /* Check if it's created yet */ if (!cancel_counter) { /* * First time thread calls library - create new counter and associate @@ -412,46 +579,47 @@ H5TS_cancel_count_inc(void) * Don't use H5MM calls here since the destructor has to use HDfree in * order to avoid codestack calls. */ - cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); - - if (!cancel_counter) { + cancel_counter = HDcalloc(1, sizeof(*cancel_counter)); + if (NULL == cancel_counter) { HERROR(H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); return FAIL; } - ret_value = pthread_setspecific(H5TS_cancel_key_g, (void *)cancel_counter); + /* Set the thread's cancellation counter with the new object */ + if (pthread_setspecific(H5TS_cancel_key_s, (void *)cancel_counter) != 0) { + HDfree(cancel_counter); + return FAIL; + } } + /* Check if thread entering library */ if (cancel_counter->cancel_count == 0) - /* thread entering library */ - ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, - &cancel_counter->previous_state); + /* Set cancellation state to 'disable', and remember previous state */ + if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_counter->previous_state) != 0) + ret_value = FAIL; + /* Increment # of times the library API was re-entered, to avoid resetting + * previous cancellation state until the final API routine is returning. + */ ++cancel_counter->cancel_count; +#endif /* H5_HAVE_WIN_THREADS */ return ret_value; -#endif /* H5_HAVE_WIN_THREADS */ -} +} /* end H5TS_cancel_count_inc() */ - /*-------------------------------------------------------------------------- - * NAME - * H5TS_cancel_count_dec - * - * USAGE - * H5TS_cancel_count_dec() + * Function: H5TS_cancel_count_dec * - * RETURNS - * 0 on success and a non-zero error code on error. + * Returns: SUCCEED/FAIL * - * DESCRIPTION + * Description: * If counter value is one, then set cancelability type of the thread - * to the previous cancelability type stored in the cancelation counter. + * to the previous cancelability type stored in the cancellation counter. * (the thread is leaving the library). * * Decrement the counter value by 1. * - * PROGRAMMER: Chee Wai LEE + * Programmer: Chee Wai LEE * May 2, 2000 * *-------------------------------------------------------------------------- @@ -459,180 +627,814 @@ H5TS_cancel_count_inc(void) herr_t H5TS_cancel_count_dec(void) { -#ifdef H5_HAVE_WIN_THREADS - /* unsupported; will just return 0 */ - return SUCCEED; -#else /* H5_HAVE_WIN_THREADS */ - register H5TS_cancel_t *cancel_counter; herr_t ret_value = SUCCEED; - cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); +#ifndef H5_HAVE_WIN_THREADS + H5TS_cancel_t *cancel_counter; + + /* Acquire the thread's cancellation counter */ + cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_s); + /* Check for leaving last API routine */ if (cancel_counter->cancel_count == 1) - ret_value = pthread_setcancelstate(cancel_counter->previous_state, NULL); + /* Reset to previous thread cancellation state, if last API */ + if (pthread_setcancelstate(cancel_counter->previous_state, NULL) != 0) + ret_value = FAIL; + /* Decrement cancellation counter */ --cancel_counter->cancel_count; +#endif /* H5_HAVE_WIN_THREADS */ return ret_value; -#endif /* H5_HAVE_WIN_THREADS */ -} +} /* end H5TS_cancel_count_dec() */ + +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS - -#ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- - * NAME - * H5TS_win32_process_enter + * Function: H5TS_alloc_rec_entry_count * - * RETURNS - * SUCCEED/FAIL + * Returns: + * Pointer to allocated and initialized instance of + * H5TS_rec_entry_count, or NULL on failure. * - * DESCRIPTION - * Per-process setup on Windows when using Win32 threads. + * Description: + * Allocate and initalize an instance of H5TS_rec_entry_count. + * + * Programmer: John Mainzer + * August 28, 2020 * *-------------------------------------------------------------------------- */ -H5_DLL BOOL CALLBACK -H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) +H5TS_rec_entry_count * +H5TS_alloc_rec_entry_count(hbool_t write_lock) { - BOOL ret_value = TRUE; + H5TS_rec_entry_count *ret_value = NULL; - /* Initialize the critical section (can't fail) */ - InitializeCriticalSection(&H5_g.init_lock.CriticalSection); + ret_value = HDmalloc(sizeof(*ret_value)); - /* Set up thread local storage */ - if(TLS_OUT_OF_INDEXES == (H5TS_errstk_key_g = TlsAlloc())) - ret_value = FALSE; + if (ret_value) { -#ifdef H5_HAVE_CODESTACK - if(TLS_OUT_OF_INDEXES == (H5TS_funcstk_key_g = TlsAlloc())) - ret_value = FALSE; -#endif /* H5_HAVE_CODESTACK */ + ret_value->magic = H5TS_RW_ENTRY_COUNT_MAGIC; + ret_value->write_lock = write_lock; + ret_value->rec_lock_count = 1; + } - if(TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) - ret_value = FALSE; + return ret_value; + +} /* end H5TS_alloc_rec_entry_count() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_free_rec_entry_count + * + * Returns: void + * + * Description: + * Frees the supplied instance of H5TS_rec_entry_count. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +void +H5TS_free_rec_entry_count(void *target) +{ + H5TS_rec_entry_count *count; + + count = (H5TS_rec_entry_count *)target; + + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + + count->magic = 0; + + HDfree(count); + + return; + +} /* end H5TS_free_rec_entry_count() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_rw_lock_init + * + * Returns: SUCCEED/FAIL + * + * Description: + * Initialize the supplied instance of H5TS_rw_lock_t. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_rw_lock_init(H5TS_rw_lock_t *rw_lock, int policy) +{ + herr_t ret_value = SUCCEED; + + /* Sanity checks -- until other policies are implemented, + * policy must equal H5TS_RW_LOCK_POLICY_FAVOR_WRITERS. + */ + if ((rw_lock == NULL) || (policy != H5TS_RW_LOCK_POLICY_FAVOR_WRITERS)) { + + ret_value = FAIL; + } + + /* NOTE: Win32 thread init functions tend to have a return type of void while + * Pthreads return an int. We've gone with the lowest common denominator + * here, but we're going to have to better abstract this in the future. + */ + + /* Initialize the mutex */ + if (ret_value == SUCCEED) + if (H5TS_mutex_init(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + + /* Initialize the waiting readers cv */ + if (ret_value == SUCCEED) + if (H5TS_cond_init(&(rw_lock->readers_cv)) != 0) + ret_value = FAIL; + + /* Initialize the waiting writers cv */ + if (ret_value == SUCCEED) + if (H5TS_cond_init(&(rw_lock->writers_cv)) != 0) + ret_value = FAIL; + + /* Initialize the counts key */ + if (ret_value == SUCCEED) + if (pthread_key_create(&(rw_lock->rec_entry_count_key), H5TS_free_rec_entry_count) != 0) + ret_value = FAIL; + + if (ret_value == SUCCEED) { + + /* Initialize scalar fields */ + + rw_lock->magic = H5TS_RW_LOCK_MAGIC; + rw_lock->policy = policy; + rw_lock->waiting_readers_count = 0; + rw_lock->waiting_writers_count = 0; + rw_lock->active_readers = 0; + rw_lock->active_writers = 0; + rw_lock->stats.read_locks_granted = 0; + rw_lock->stats.read_locks_released = 0; + rw_lock->stats.real_read_locks_granted = 0; + rw_lock->stats.real_read_locks_released = 0; + rw_lock->stats.max_read_locks = 0; + rw_lock->stats.max_read_lock_recursion_depth = 0; + rw_lock->stats.read_locks_delayed = 0; + rw_lock->stats.max_read_locks_pending = 0; + rw_lock->stats.write_locks_granted = 0; + rw_lock->stats.write_locks_released = 0; + rw_lock->stats.real_write_locks_granted = 0; + rw_lock->stats.real_write_locks_released = 0; + rw_lock->stats.max_write_locks = 0; + rw_lock->stats.max_write_lock_recursion_depth = 0; + rw_lock->stats.write_locks_delayed = 0; + rw_lock->stats.max_write_locks_pending = 0; + } return ret_value; -} /* H5TS_win32_process_enter() */ -#endif /* H5_HAVE_WIN_THREADS */ - -#ifdef H5_HAVE_WIN_THREADS +} /* end H5TS_rw_lock_init() */ + /*-------------------------------------------------------------------------- - * NAME - * H5TS_win32_thread_enter + * Function: H5TS_rw_lock_destroy * - * RETURNS - * SUCCEED/FAIL + * Returns: SUCCEED/FAIL * - * DESCRIPTION - * Per-thread setup on Windows when using Win32 threads. + * Description: + * Take down an instance of H5TS_rw_lock_t. All mutex, condition + * variables, and keys are destroyed, and magic is set to an invalid + * value. However, the instance of H5TS_rw_lock_t is not + * freed. + * + * Programmer: John Mainzer + * August 28, 2020 * *-------------------------------------------------------------------------- */ herr_t -H5TS_win32_thread_enter(void) +H5TS_rw_lock_destroy(H5TS_rw_lock_t *rw_lock) { herr_t ret_value = SUCCEED; - /* Currently a placeholder function. TLS setup is performed - * elsewhere in the library. - * - * WARNING: Do NOT use C standard library functions here. - * CRT functions are not allowed in DllMain, which is where this code - * is used. + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC)) { + + ret_value = FAIL; + } + else { + + /* We are commited 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. + */ + rw_lock->magic = 0; + + if (H5TS_mutex_destroy(&(rw_lock->mutex)) < 0) + ret_value = FAIL; + + if (H5TS_cond_destroy(&(rw_lock->readers_cv)) < 0) + ret_value = FAIL; + + if (H5TS_cond_destroy(&(rw_lock->writers_cv)) < 0) + ret_value = FAIL; + + if (pthread_key_delete(rw_lock->rec_entry_count_key) < 0) + ret_value = FAIL; + } + + return ret_value; + +} /* end H5TS_rw_lock_destroy() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_rw_rdlock + * + * Returns: SUCCEED/FAIL + * + * Description: + * Attempt to obtain a read lock on the associated recursive read / write + * lock. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_rw_rdlock(H5TS_rw_lock_t *rw_lock) +{ + hbool_t have_mutex = FALSE; + int result; + H5TS_rec_entry_count *count; + herr_t ret_value = SUCCEED; + + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC)) { + + ret_value = FAIL; + } + + /* Obtain the mutex */ + if (ret_value == SUCCEED) { + if (H5TS_mutex_lock_simple(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + else + have_mutex = TRUE; + } + + /* If there is no specific data for this thread, this is an + * initial read lock request. */ + if (ret_value == SUCCEED) { + + count = (H5TS_rec_entry_count *)H5TS_get_thread_local_value(rw_lock->rec_entry_count_key); + + if (count) { /* This is a recursive lock */ + + if ((count->write_lock) || (rw_lock->active_readers == 0) || (rw_lock->active_writers != 0)) { + + ret_value = FAIL; + } + else { + + count->rec_lock_count++; + + H5TS_update_stats_rd_lock(rw_lock, count); + } + } + else { /* This is an initial read lock request */ + + switch (rw_lock->policy) { + + case H5TS_RW_LOCK_POLICY_FAVOR_WRITERS: + if ((rw_lock->active_writers != 0) || (rw_lock->waiting_writers_count != 0)) { + + int delayed = rw_lock->waiting_readers_count + 1; + + H5TS_update_stats_rd_lock_delay(rw_lock, delayed); + } + + while ((rw_lock->active_writers != 0) || (rw_lock->waiting_writers_count != 0)) { + + rw_lock->waiting_readers_count++; + + result = H5TS_cond_wait(&(rw_lock->readers_cv), &(rw_lock->mutex)); + + rw_lock->waiting_readers_count--; + + if (result != 0) { + + ret_value = FAIL; + break; + } + } + break; + + default: + ret_value = FAIL; + break; + } + + if ((ret_value == SUCCEED) && (NULL == (count = H5TS_alloc_rec_entry_count(FALSE)))) { + + ret_value = FAIL; + } + + if ((ret_value == SUCCEED) && + (H5TS_set_thread_local_value(rw_lock->rec_entry_count_key, (void *)count) != 0)) { + + ret_value = FAIL; + } + + if (ret_value == SUCCEED) { + + rw_lock->active_readers++; + + HDassert(count->rec_lock_count == 1); + + H5TS_update_stats_rd_lock(rw_lock, count); + } + } + } + + if (have_mutex) { + + H5TS_mutex_unlock_simple(&(rw_lock->mutex)); + } return ret_value; -} /* H5TS_win32_thread_enter() */ -#endif /* H5_HAVE_WIN_THREADS */ - -#ifdef H5_HAVE_WIN_THREADS +} /* end H5TS_rw_rdlock() */ + /*-------------------------------------------------------------------------- - * NAME - * H5TS_win32_process_exit + * Function: H5TS_rw_wrlock * - * RETURNS - * SUCCEED/FAIL + * Returns: SUCCEED/FAIL * - * DESCRIPTION - * Per-process cleanup on Windows when using Win32 threads. + * Description: + * Attempt to obtain a write lock on the associated recursive read / write + * lock. + * + * Programmer: John Mainzer + * August 28, 2020 * *-------------------------------------------------------------------------- */ -void -H5TS_win32_process_exit(void) +herr_t +H5TS_rw_wrlock(H5TS_rw_lock_t *rw_lock) { + hbool_t have_mutex = FALSE; + int result; + H5TS_rec_entry_count *count; + herr_t ret_value = SUCCEED; - /* Windows uses a different thread local storage mechanism which does - * not support auto-freeing like pthreads' keys. - * - * This function is currently registered via atexit() and is called - * AFTER H5_term_library(). + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC)) { + + ret_value = FAIL; + } + + /* Obtain the mutex */ + if (ret_value == SUCCEED) { + if (H5TS_mutex_lock_simple(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + else + have_mutex = TRUE; + } + + /* If there is no specific data for this thread, this is an + * initial write lock request. */ + if (ret_value == SUCCEED) { - /* Clean up critical section resources (can't fail) */ - DeleteCriticalSection(&H5_g.init_lock.CriticalSection); + count = (H5TS_rec_entry_count *)H5TS_get_thread_local_value(rw_lock->rec_entry_count_key); - /* Clean up per-process thread local storage */ - TlsFree(H5TS_errstk_key_g); -#ifdef H5_HAVE_CODESTACK - TlsFree(H5TS_funcstk_key_g); -#endif /* H5_HAVE_CODESTACK */ - TlsFree(H5TS_apictx_key_g); + if (count) { /* this is a recursive lock */ - return; -} /* H5TS_win32_process_exit() */ -#endif /* H5_HAVE_WIN_THREADS */ + if ((!(count->write_lock)) || (rw_lock->active_readers != 0) || (rw_lock->active_writers != 1)) { + + ret_value = FAIL; + } + else { + + count->rec_lock_count++; + + H5TS_update_stats_wr_lock(rw_lock, count); + } + } + else { /* This is an initial write lock request */ + + switch (rw_lock->policy) { + + case H5TS_RW_LOCK_POLICY_FAVOR_WRITERS: + if ((rw_lock->active_readers > 0) || (rw_lock->active_writers > 0)) { + + int delayed = rw_lock->waiting_writers_count + 1; + + H5TS_update_stats_wr_lock_delay(rw_lock, delayed); + } + + while ((rw_lock->active_readers > 0) || (rw_lock->active_writers > 0)) { + + rw_lock->waiting_writers_count++; + + result = H5TS_cond_wait(&(rw_lock->writers_cv), &(rw_lock->mutex)); + + rw_lock->waiting_writers_count--; + + if (result != 0) { + + ret_value = FAIL; + break; + } + } + break; + + default: + ret_value = FAIL; + break; + } + + if ((ret_value == SUCCEED) && (NULL == (count = H5TS_alloc_rec_entry_count(TRUE)))) { + + ret_value = FAIL; + } + + if ((ret_value == SUCCEED) && + (H5TS_set_thread_local_value(rw_lock->rec_entry_count_key, (void *)count) != 0)) { + + ret_value = FAIL; + } + + if (ret_value == SUCCEED) { + + rw_lock->active_writers++; + + HDassert(count->rec_lock_count == 1); + + H5TS_update_stats_wr_lock(rw_lock, count); + } + } + } + + if (have_mutex) { + + H5TS_mutex_unlock_simple(&(rw_lock->mutex)); + } + + return ret_value; + +} /* end H5TS_rw_wrlock() */ - -#ifdef H5_HAVE_WIN_THREADS /*-------------------------------------------------------------------------- - * NAME - * H5TS_win32_thread_exit + * Function: H5TS_rw_unlock * - * RETURNS - * SUCCEED/FAIL + * Returns: SUCCEED/FAIL * - * DESCRIPTION - * Per-thread cleanup on Windows when using Win32 threads. + * Description: + * Attempt to unlock either a read or a write lock on the supplied + * recursive read / write lock. + * + * Programmer: John Mainzer + * August 28, 2020 * *-------------------------------------------------------------------------- */ herr_t -H5TS_win32_thread_exit(void) +H5TS_rw_unlock(H5TS_rw_lock_t *rw_lock) { - LPVOID lpvData; - herr_t ret_value = SUCCEED; + hbool_t have_mutex = FALSE; + hbool_t discard_rec_count = FALSE; + H5TS_rec_entry_count *count; + herr_t ret_value = SUCCEED; - /* Windows uses a different thread local storage mechanism which does - * not support auto-freeing like pthreads' keys. - * - * WARNING: Do NOT use C standard library functions here. - * CRT functions are not allowed in DllMain, which is where this code - * is used. + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC)) { + + ret_value = FAIL; + } + + /* Obtain the mutex */ + if (ret_value == SUCCEED) { + if (H5TS_mutex_lock_simple(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + else + have_mutex = TRUE; + } + + /* If there is no specific data for this thread, no lock was held, + * and thus the unlock call must fail. */ + if (ret_value == SUCCEED) { - /* Clean up per-thread thread local storage */ - lpvData = TlsGetValue(H5TS_errstk_key_g); - if(lpvData) - LocalFree((HLOCAL)lpvData); + count = (H5TS_rec_entry_count *)H5TS_get_thread_local_value(rw_lock->rec_entry_count_key); -#ifdef H5_HAVE_CODESTACK - lpvData = TlsGetValue(H5TS_funcstk_key_g); - if(lpvData) - LocalFree((HLOCAL)lpvData); -#endif /* H5_HAVE_CODESTACK */ + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + HDassert(count->rec_lock_count > 0); - lpvData = TlsGetValue(H5TS_apictx_key_g); - if(lpvData) - LocalFree((HLOCAL)lpvData); + if (NULL == count) { + + ret_value = FAIL; + } + else if (count->magic != H5TS_RW_ENTRY_COUNT_MAGIC) { + + ret_value = FAIL; + } + else if (count->rec_lock_count <= 0) { /* Corrupt count? */ + + ret_value = FAIL; + } + else if (count->write_lock) { /* Drop a write lock */ + + HDassert((rw_lock->active_readers == 0) && (rw_lock->active_writers == 1)); + + if ((rw_lock->active_readers != 0) || (rw_lock->active_writers != 1)) { + + ret_value = FAIL; + } + else { + + count->rec_lock_count--; + + HDassert(count->rec_lock_count >= 0); + + if (count->rec_lock_count == 0) { + + /* Make note that we must discard the + * recursive entry counter so it will not + * confuse us on the next lock request. + */ + discard_rec_count = TRUE; + + /* Drop the write lock -- will signal later if needed */ + rw_lock->active_writers--; + + HDassert(rw_lock->active_writers == 0); + } + } + + H5TS_update_stats_wr_unlock(rw_lock, count); + } + else { /* drop a read lock */ + + HDassert((rw_lock->active_readers > 0) && (rw_lock->active_writers == 0)); + + if ((rw_lock->active_readers <= 0) || (rw_lock->active_writers != 0)) { + + ret_value = FAIL; + } + else { + + count->rec_lock_count--; + + HDassert(count->rec_lock_count >= 0); + + if (count->rec_lock_count == 0) { + + /* Make note that we must discard the + * recursive entry counter so it will not + * confuse us on the next lock request. + */ + discard_rec_count = TRUE; + + /* Drop the read lock -- will signal later if needed */ + rw_lock->active_readers--; + } + } + + H5TS_update_stats_rd_unlock(rw_lock, count); + } + + if ((ret_value == SUCCEED) && (rw_lock->active_readers == 0) && (rw_lock->active_writers == 0)) { + + /* No locks held -- signal condition variables if required */ + + switch (rw_lock->policy) { + + case H5TS_RW_LOCK_POLICY_FAVOR_WRITERS: +#ifdef H5_HAVE_WIN_THREADS + if (rw_lock->waiting_writers_count > 0) + H5TS_cond_signal(&(rw_lock->writers_cv)); + else if (rw_lock->waiting_readers_count > 0) + H5TS_cond_broadcast(&(rw_lock->readers_cv)); +#else + if (rw_lock->waiting_writers_count > 0) { + + if (H5TS_cond_signal(&(rw_lock->writers_cv)) != 0) + ret_value = FAIL; + } + else if (rw_lock->waiting_readers_count > 0) { + + if (H5TS_cond_broadcast(&(rw_lock->readers_cv)) != 0) + ret_value = FAIL; + } +#endif + break; + default: + ret_value = FAIL; + break; + } + } + } + + /* If we are really dropping the lock, must set the value of + * rec_entry_count_key for this thread to NULL, so that + * when this thread next requests a lock, it will appear + * as an initial lock, not a recursive lock. + */ + if (discard_rec_count) { + + HDassert(count); + + if (H5TS_set_thread_local_value(rw_lock->rec_entry_count_key, (void *)NULL) != 0) { + + ret_value = FAIL; + } + + H5TS_free_rec_entry_count((void *)count); + count = NULL; + } + + if (have_mutex) { + + H5TS_mutex_unlock_simple(&(rw_lock->mutex)); + } return ret_value; -} /* H5TS_win32_thread_exit() */ -#endif /* H5_HAVE_WIN_THREADS */ - +} /* end H5TS_rw_unlock() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_rw_lock_get_stats + * + * Returns: SUCCEED/FAIL + * + * Description: + * Obtain a copy of the current statistics on the supplied + * recursive read / write lock. Note that to obtain a consistent + * set of statistics, the function must obtain the lock mutex. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_rw_lock_get_stats(H5TS_rw_lock_t *rw_lock, H5TS_rw_lock_stats_t *stats) +{ + hbool_t have_mutex = FALSE; + herr_t ret_value = SUCCEED; + + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC) || (stats == NULL)) { + + ret_value = FAIL; + } + + /* Obtain the mutex */ + if (ret_value == SUCCEED) { + if (H5TS_mutex_lock_simple(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + else + have_mutex = TRUE; + } + + if (ret_value == SUCCEED) { + + *stats = rw_lock->stats; + } + + if (have_mutex) { + + H5TS_mutex_unlock_simple(&(rw_lock->mutex)); + } + + return ret_value; + +} /* end H5TS_rw_lock_get_stats() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_rw_lock_reset_stats + * + * Returns: SUCCEED/FAIL + * + * Description: + * Reset the statistics for the supplied recursive read / write lock. + * Note that to reset the statistics consistently, the function must + * obtain the lock mutex. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_rw_lock_reset_stats(H5TS_rw_lock_t *rw_lock) +{ + hbool_t have_mutex = FALSE; + /* NOTE: Update this initializer if you modify H5TS_rw_lock_stats_t */ + static const H5TS_rw_lock_stats_t reset_stats = {/* read_locks_granted = */ 0, + /* read_locks_released = */ 0, + /* real_read_locks_granted = */ 0, + /* real_read_locks_released = */ 0, + /* max_read_locks = */ 0, + /* max_read_lock_recursion_depth = */ 0, + /* read_locks_delayed = */ 0, + /* max_read_locks_pending = */ 0, + /* write_locks_granted = */ 0, + /* write_locks_released = */ 0, + /* real_write_locks_granted = */ 0, + /* real_write_locks_released = */ 0, + /* max_write_locks = */ 0, + /* max_write_lock_recursion_depth = */ 0, + /* write_locks_delayed = */ 0, + /* max_write_locks_pending = */ 0}; + herr_t ret_value = SUCCEED; + + if ((rw_lock == NULL) || (rw_lock->magic != H5TS_RW_LOCK_MAGIC)) { + + ret_value = FAIL; + } + + /* Obtain the mutex */ + if (ret_value == SUCCEED) { + if (H5TS_mutex_lock_simple(&(rw_lock->mutex)) != 0) + ret_value = FAIL; + else + have_mutex = TRUE; + } + + if (ret_value == SUCCEED) { + + rw_lock->stats = reset_stats; + } + + if (have_mutex) { + + H5TS_mutex_unlock_simple(&(rw_lock->mutex)); + } + + return ret_value; + +} /* end H5TS_rw_lock_reset_stats() */ + +/*-------------------------------------------------------------------------- + * Function: H5TS_rw_lock_print_stats + * + * Returns: SUCCEED/FAIL + * + * Description: + * Print the supplied pthresds recursive R/W lock statistics to + * standard out. + * + * UPDATE THIS FUNCTION IF YOU MODIFY H5TS_rw_lock_stats_t. + * + * Programmer: John Mainzer + * August 28, 2020 + * + *-------------------------------------------------------------------------- + */ +herr_t +H5TS_rw_lock_print_stats(const char *header_str, H5TS_rw_lock_stats_t *stats) +{ + herr_t ret_value = SUCCEED; + + if ((header_str == NULL) || (stats == NULL)) { + + ret_value = FAIL; + } + else { + + HDfprintf(stdout, "\n\n%s\n\n", header_str); + HDfprintf(stdout, " read_locks_granted = %" PRId64 "\n", stats->read_locks_granted); + HDfprintf(stdout, " read_locks_released = %" PRId64 "\n", stats->read_locks_released); + HDfprintf(stdout, " real_read_locks_granted = %" PRId64 "\n", stats->real_read_locks_granted); + HDfprintf(stdout, " real_read_locks_released = %" PRId64 "\n", + stats->real_read_locks_released); + HDfprintf(stdout, " max_read_locks = %" PRId64 "\n", stats->max_read_locks); + HDfprintf(stdout, " max_read_lock_recursion_depth = %" PRId64 "\n", + stats->max_read_lock_recursion_depth); + HDfprintf(stdout, " read_locks_delayed = %" PRId64 "\n", stats->read_locks_delayed); + HDfprintf(stdout, " max_read_locks_pending = %" PRId64 "\n", stats->max_read_locks_pending); + HDfprintf(stdout, " write_locks_granted = %" PRId64 "\n", stats->write_locks_granted); + HDfprintf(stdout, " write_locks_released = %" PRId64 "\n", stats->write_locks_released); + HDfprintf(stdout, " real_write_locks_granted = %" PRId64 "\n", + stats->real_write_locks_granted); + HDfprintf(stdout, " real_write_locks_released = %" PRId64 "\n", + stats->real_write_locks_released); + HDfprintf(stdout, " max_write_locks = %" PRId64 "\n", stats->max_write_locks); + HDfprintf(stdout, " max_write_lock_recursion_depth = %" PRId64 "\n", + stats->max_write_lock_recursion_depth); + HDfprintf(stdout, " write_locks_delayed = %" PRId64 "\n", stats->write_locks_delayed); + HDfprintf(stdout, " max_write_locks_pending = %" PRId64 "\n\n", + stats->max_write_locks_pending); + } + + return ret_value; + +} /* end H5TS_rw_lock_print_stats() */ + +#endif /* H5_USE_RECURSIVE_WRITER_LOCKS */ + /*-------------------------------------------------------------------------- * NAME * H5TS_create_thread @@ -653,8 +1455,7 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) { H5TS_thread_t ret_value; -#ifdef H5_HAVE_WIN_THREADS - +#ifdef H5_HAVE_WIN_THREADS /* When calling C runtime functions, you should use _beginthread or * _beginthreadex instead of CreateThread. Threads created with * CreateThread risk being killed in low-memory situations. Since we @@ -669,13 +1470,11 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) #else /* H5_HAVE_WIN_THREADS */ - pthread_create(&ret_value, attr, (void * (*)(void *))func, udata); + pthread_create(&ret_value, attr, (void *(*)(void *))func, udata); #endif /* H5_HAVE_WIN_THREADS */ return ret_value; +} /* end H5TS_create_thread() */ -} /* H5TS_create_thread */ - -#endif /* H5_HAVE_THREADSAFE */ - +#endif /* H5_HAVE_THREADSAFE */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index effda557ef4..e324b381db2 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -6,18 +6,16 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: H5TSprivate.h - * May 2 2000 - * Chee Wai LEE + * Created: H5TSprivate.h * - * Purpose: Private non-prototype header. + * Purpose: Thread-safety abstractions used by the library * *------------------------------------------------------------------------- */ @@ -25,113 +23,569 @@ #define H5TSprivate_H_ #ifdef H5_HAVE_THREADSAFE + /* Public headers needed by this file */ #ifdef LATER -#include "H5TSpublic.h" /*Public API prototypes */ -#endif /* LATER */ +#include "H5TSpublic.h" /* Public API prototypes */ +#endif /* LATER */ -#ifdef H5_HAVE_WIN_THREADS +/**************************/ +/* Library Private Macros */ +/**************************/ -/* Library level data structures */ +/* Defines */ -/* Mutexes, Threads, and Attributes */ -typedef struct H5TS_mutex_struct { - CRITICAL_SECTION CriticalSection; -} H5TS_mutex_t; -typedef CRITICAL_SECTION H5TS_mutex_simple_t; -typedef HANDLE H5TS_thread_t; -typedef HANDLE H5TS_attr_t; -typedef DWORD H5TS_key_t; -typedef INIT_ONCE H5TS_once_t; +#ifdef H5_HAVE_WIN_THREADS -/* Defines */ -/* not used on windows side, but need to be defined to something */ -#define H5TS_SCOPE_SYSTEM 0 +/* Scope Definitions (Pthreads only) */ +#define H5TS_SCOPE_SYSTEM 0 #define H5TS_SCOPE_PROCESS 0 -#define H5TS_CALL_CONV WINAPI -/* Functions */ -#define H5TS_get_thread_local_value(key) TlsGetValue( key ) -#define H5TS_set_thread_local_value(key, value) TlsSetValue( key, value ) -#define H5TS_attr_init(attr_ptr) 0 -#define H5TS_attr_setscope(attr_ptr, scope) 0 -#define H5TS_attr_destroy(attr_ptr) 0 -#define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) -#define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) -#define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) -#define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) +/* Calling convention (Windows only) */ +#define H5TS_CALL_CONV WINAPI -/* Functions called from DllMain */ -H5_DLL BOOL CALLBACK H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); -H5_DLL void H5TS_win32_process_exit(void); -H5_DLL herr_t H5TS_win32_thread_enter(void); -H5_DLL herr_t H5TS_win32_thread_exit(void); +/* Portability function aliases */ +#define H5TS_get_thread_local_value(key) TlsGetValue(key) +#define H5TS_set_thread_local_value(key, value) TlsSetValue(key, value) +#define H5TS_attr_init(attr) 0 +#define H5TS_attr_setscope(attr, scope) 0 +#define H5TS_attr_destroy(attr) 0 +#define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) +#define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) +#define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) +#define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) +/* No Pthreads equivalent - we use a custom H5TS call with that thread library */ #define H5TS_thread_id() ((uint64_t)GetCurrentThreadId()) -#else /* H5_HAVE_WIN_THREADS */ +#else + +/* Scope Definitions (Pthreads only) */ +#define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM +#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS + +/* Calling convention (Windows only) */ +#define H5TS_CALL_CONV /* N/A */ + +/* Portability function aliases */ +#define H5TS_get_thread_local_value(key) pthread_getspecific(key) +#define H5TS_set_thread_local_value(key, value) pthread_setspecific(key, value) +#define H5TS_attr_init(attr) pthread_attr_init((attr)) +#define H5TS_attr_setscope(attr, scope) pthread_attr_setscope(attr, scope) +#define H5TS_attr_destroy(attr) pthread_attr_destroy(attr) +#define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) +#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) +#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) +#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) + +/* No Win32 thread equivalent - only needed for RW locks which are not supported + * under Windows threads. + */ +#define H5TS_mutex_destroy(mutex) pthread_mutex_destroy(mutex) +#define H5TS_cond_init(cond) pthread_cond_init(cond, NULL) +#define H5TS_cond_destroy(cond) pthread_cond_destroy(cond) +#define H5TS_cond_wait(cond, mutex) pthread_cond_wait(cond, mutex) +#define H5TS_cond_signal(cond) pthread_cond_signal(cond) +#define H5TS_cond_broadcast(cond) pthread_cond_broadcast(cond) + +#endif /* H5_HAVE_WIN_THREADS */ + +/****************************************************************************** + * Macros to maintain statistics on the Pthreads recursive R/W lock. + ******************************************************************************/ + +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS + +/* Magic values for struct sanity checking */ -/* Library level data structures */ +/* RW lock */ +#define H5TS_RW_LOCK_MAGIC 0XABCD + +/* RW lock entry counts */ +#define H5TS_RW_ENTRY_COUNT_MAGIC 0XABBA + +/* Flag for favoring writers */ +/* THIS SHOULD BE AN ENUM */ +#define H5TS_RW_LOCK_POLICY_FAVOR_WRITERS 0 + +#endif /* H5_USE_RECURSIVE_WRITER_LOCKS */ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ /* Mutexes, Threads, and Attributes */ + +#ifdef H5_HAVE_WIN_THREADS + +typedef struct H5TS_mutex_struct { + CRITICAL_SECTION CriticalSection; +} H5TS_mutex_t; + +#else + typedef struct H5TS_mutex_struct { - pthread_t owner_thread; /* current lock owner */ - pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ - pthread_cond_t cond_var; /* condition variable */ - unsigned int lock_count; + pthread_t owner_thread; /* current lock owner */ + pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ + pthread_cond_t cond_var; /* condition variable */ + unsigned int lock_count; } H5TS_mutex_t; -typedef pthread_t H5TS_thread_t; -typedef pthread_attr_t H5TS_attr_t; + +#endif /* H5_HAVE_WIN_THREADS */ + +/* Portability wrappers */ + +#ifdef H5_HAVE_WIN_THREADS + +typedef HANDLE H5TS_thread_t; +typedef HANDLE H5TS_attr_t; +typedef CRITICAL_SECTION H5TS_mutex_simple_t; +typedef DWORD H5TS_key_t; +typedef INIT_ONCE H5TS_once_t; +typedef CONDITION_VARIABLE H5TS_cond_t; + +#else + +typedef pthread_t H5TS_thread_t; +typedef pthread_attr_t H5TS_attr_t; typedef pthread_mutex_t H5TS_mutex_simple_t; -typedef pthread_key_t H5TS_key_t; -typedef pthread_once_t H5TS_once_t; - -/* Scope Definitions */ -#define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM -#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS -#define H5TS_CALL_CONV /* unused - Windows only */ - -/* Functions */ -#define H5TS_get_thread_local_value(key) pthread_getspecific( key ) -#define H5TS_set_thread_local_value(key, value) pthread_setspecific( key, value ) -#define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) -#define H5TS_attr_setscope(attr_ptr, scope) pthread_attr_setscope(attr_ptr, scope) -#define H5TS_attr_destroy(attr_ptr) pthread_attr_destroy(attr_ptr) -#define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) -#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) -#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) -#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) -H5_DLL uint64_t H5TS_thread_id(void); +typedef pthread_key_t H5TS_key_t; +typedef pthread_once_t H5TS_once_t; +typedef pthread_cond_t H5TS_cond_t; #endif /* H5_HAVE_WIN_THREADS */ -/* External global variables */ +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS + +/****************************************************************************** + * + * Structure H5TS_rw_lock_stats_t + * + * Catchall structure for statistics on the recursive p-threads based + * recursive R/W lock (see declaration of H5TS_rw_lock_t below). + * + * Since the mutex must be held when reading a consistent set of statistics + * from the recursibe R/W lock, it simplifies matters to bundle them into + * a single structure. This structure exists for that purpose. + * + * If you modify this structure, be sure to make equivalent changes to + * the reset_stats initializer in H5TS_rw_lock_reset_stats(). + * + * Individual fields are discussed below. + * + * JRM -- 8/28/20 + * + * Read lock stats: + * + * read_locks_granted: 64 bit integer used to count the total number of read + * locks granted. Note that this includes recursive lock + * requests. + * + * read_locks_released: 64 bit integer used to count the total number of read + * locks released. Note that this includes recursive lock + * release requests. + * + * real_read_locks_granted: 64 bit integer used to count the total number of + * read locks granted, less any recursive lock requests. + * + * real_read_locks_released: 64 bit integer used to count the total number of + * read locks released, less any recursive lock releases. + * + * max_read_locks; 64 bit integer used to track the maximum number of read + * locks active at any point in time. + * + * max_read_lock_recursion_depth; 64 bit integer used to track the maximum + * recursion depth observed for any read lock. + * + * read_locks_delayed: 64 bit integer used to track the number of read locks + * that were not granted immediately. + * + * max_read_locks_delayed; 64 bit integer used to track the maximum number of + * pending read locks at any point in time. + * + * + * Write lock stats: + * + * write_locks_granted: 64 bit integer used to count the total number of write + * locks granted. Note that this includes recursive lock + * requests. + * + * write_locks_released: 64 bit integer used to count the total number of write + * locks released. Note that this includes recursive lock + * release requests. + * + * real_write_locks_granted: 64 bit integer used to count the total number of + * write locks granted, less any recursive lock requests. + * + * real_write_locks_released: 64 bit integer used to count the total number of + * write locks released, less any recursive lock releases. + * + * max_write_locks; 64 bit integer used to track the maximum number of write + * locks active at any point in time. Must be either zero or one. + * + * max_write_lock_recursion_depth; 64 bit integer used to track the maximum + * recursion depth observed for any write lock. + * + * write_locks_delayed: 64 bit integer used to track the number of write locks + * that were not granted immediately. + * + * max_write_locks_delayed; 64 bit integer used to track the maximum number of + * pending write locks at any point in time. + * + ******************************************************************************/ + +typedef struct H5TS_rw_lock_stats_t { + + int64_t read_locks_granted; + int64_t read_locks_released; + int64_t real_read_locks_granted; + int64_t real_read_locks_released; + int64_t max_read_locks; + int64_t max_read_lock_recursion_depth; + int64_t read_locks_delayed; + int64_t max_read_locks_pending; + int64_t write_locks_granted; + int64_t write_locks_released; + int64_t real_write_locks_granted; + int64_t real_write_locks_released; + int64_t max_write_locks; + int64_t max_write_lock_recursion_depth; + int64_t write_locks_delayed; + int64_t max_write_locks_pending; + +} 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 + * 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. + * + * Note that we can't use the Pthreads or Win32 R/W locks, as while they + * permit recursive read locks, they disallow recursive write locks. + * + * This structure is a catchall for the fields needed to implement a + * recursive R/W lock that allows recursive write locks, and for the + * associate statistics collection fields. + * + * This recursive R/W lock implementation is an extension of the R/W lock + * implementation given in "UNIX network programming" Volume 2, Chapter 8 + * by w. Richard Stevens, 2nd edition. + * + * Individual fields are discussed below. + * + * JRM -- 8/28/20 + * + * magic: Unsigned 32 bit integer field used for sanity checking. This + * fields must always be set to H5TS_RW_LOCK_MAGIC. + * 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 + * used by the R/W lock. The supported policies are listed + * below: + * + * H5TS__RW_LOCK_POLICY__FAVOR_WRITERS: + * + * If selected, the R/W lock will grant access to a pending + * writer if there are both pending readers and writers. + * + * + * --- Define other policies here --- + * + * + * mutex: Mutex used to maintain mutual exclusion on the fields of + * of this structure. + * + * readers_cv: Condition variable used for waiting readers. + * + * writers_cv: Condition variable used for waiting writers. + * + * waiting_readers_count: 32 bit integer used to maintain a count of + * waiting readers. This value should always be non-negative. + * + * waiting_writers_count: 32 bit integer used to maintain a count of + * waiting writers. This value should always be non-negative. + * + * The following two fields could be combined into a single field, with + * the count of active readers being represented by a positive value, and + * the number of writers by a negative value. Two fields are used to + * facilitate sanity checking. + * + * active_readers: 32 bit integer used to maintain a count of + * readers that currently hold a read lock. This value + * must be zero if active_writers is positive. It should + * never be negative. + * + * active_writers: 32 bit integer used to maintain a count of + * writers that currently hold a write lock. This value + * must always be either 0 or 1, and must be zero if + * active_readers is positive. It should never be negative. + * + * rec_entry_count_key: Instance of thread-local key used to maintain + * a thread specific lock type and recursive entry count + * for all threads holding a lock. + * + * stats: Instance of H5TS_rw_lock_stats_t used to track + * statistics on the recursive R/W lock. See the declaration + * of the structure for discussion of its fields. + * + * Note that the stats are gathered into a structure because + * we must obtain the mutex when reading the statistics to + * avoid changes while the statistics are being read. Collecting + * them into a structure facilitates this. + * + ******************************************************************************/ + +typedef struct H5TS_rw_lock_t { + + uint32_t magic; + int32_t policy; + H5TS_mutex_simple_t mutex; + H5TS_cond_t readers_cv; + H5TS_cond_t writers_cv; + int32_t waiting_readers_count; + int32_t waiting_writers_count; + int32_t active_readers; + int32_t active_writers; + H5TS_key_t rec_entry_count_key; + int32_t writer_rec_entry_count; + struct H5TS_rw_lock_stats_t stats; + +} H5TS_rw_lock_t; + +/****************************************************************************** + * + * Structure H5TS_rec_entry_count + * + * Strucure 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. + * + * Individual fields are discussed below. + * + * JRM -- 8/28/20 + * + * magic: Unsigned 32 bit integer field used for sanity checking. This + * field must always be set to H5TS_RW_ENTRY_COUNT_MAGIC, and + * should be set to some invalid value just before the structure + * is freed. + * + * write_lock: Boolean field that is set to TRUE if the count is for a write + * lock, and to FALSE if it is for a read lock. + * + * rec_lock_count: Count of the number of recursive lock calls, less + * the number of recursive unlock calls. The lock in question + * is dropped when the count drops to zero. + * + ******************************************************************************/ + +typedef struct H5TS_rec_entry_count { + + uint32_t magic; + hbool_t write_lock; + int64_t rec_lock_count; + +} H5TS_rec_entry_count; + +#endif /* H5_USE_RECURSIVE_WRITER_LOCKS */ + +/*****************************/ +/* Library-private Variables */ +/*****************************/ + +/* Library-scope global variables */ + +/* Library initialization */ extern H5TS_once_t H5TS_first_init_g; + +/* Error stacks */ extern H5TS_key_t H5TS_errstk_key_g; + +/* Function stacks */ +#ifdef H5_HAVE_CODESTACK extern H5TS_key_t H5TS_funcstk_key_g; +#endif + +/* API contexts */ extern H5TS_key_t H5TS_apictx_key_g; -#if defined c_plusplus || defined __cplusplus -extern "C" +/***********************************/ +/* Private static inline functions */ +/***********************************/ + +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS + +static inline void +H5TS_update_stats_rd_lock(H5TS_rw_lock_t *rw_lock, H5TS_rec_entry_count *count) +{ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + HDassert(count->rec_lock_count >= 1); + HDassert(!count->write_lock); + + rw_lock->stats.read_locks_granted++; + + if (count->rec_lock_count == 1) { + + rw_lock->stats.real_read_locks_granted++; + + if (rw_lock->active_readers > rw_lock->stats.max_read_locks) + rw_lock->stats.max_read_locks = rw_lock->active_readers; + } + + if (count->rec_lock_count > rw_lock->stats.max_read_lock_recursion_depth) + rw_lock->stats.max_read_lock_recursion_depth = count->rec_lock_count; + +} /* end H5TS_update_stats_rd_lock() */ + +static inline void +H5TS_update_stats_rd_lock_delay(H5TS_rw_lock_t *rw_lock, int waiting_count) +{ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert((waiting_count) > 0); + + rw_lock->stats.read_locks_delayed++; + + if (rw_lock->stats.max_read_locks_pending < waiting_count) + rw_lock->stats.max_read_locks_pending = (waiting_count); + +} /* end H5TS_update_stats_rd_lock_delay() */ + +static inline void +H5TS_update_stats_rd_unlock(H5TS_rw_lock_t *rw_lock, H5TS_rec_entry_count *count) +{ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + HDassert(count->rec_lock_count >= 0); + HDassert(!count->write_lock); + + rw_lock->stats.read_locks_released++; + + if (count->rec_lock_count == 0) + rw_lock->stats.real_read_locks_released++; + +} /* end H5TS_update_stats_rd_unlock() */ + +static inline void +H5TS_update_stats_wr_lock(H5TS_rw_lock_t *rw_lock, H5TS_rec_entry_count *count) +{ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + HDassert(count->rec_lock_count >= 1); + HDassert(count->write_lock); + + rw_lock->stats.write_locks_granted++; + + if (count->rec_lock_count == 1) { + + rw_lock->stats.real_write_locks_granted++; + + if (rw_lock->active_writers > rw_lock->stats.max_write_locks) + rw_lock->stats.max_write_locks = rw_lock->active_writers; + } + + if (count->rec_lock_count > rw_lock->stats.max_write_lock_recursion_depth) + rw_lock->stats.max_write_lock_recursion_depth = count->rec_lock_count; + +} /* end H5TS_update_stats_wr_lock() */ + +static inline void +H5TS_update_stats_wr_lock_delay(H5TS_rw_lock_t *rw_lock, int waiting_count) { -#endif /* c_plusplus || __cplusplus */ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert(waiting_count > 0); -H5_DLL void H5TS_pthread_first_thread_init(void); + rw_lock->stats.write_locks_delayed++; + + if (rw_lock->stats.max_write_locks_pending < waiting_count) + rw_lock->stats.max_write_locks_pending = waiting_count; + +} /* end H5TS_update_stats_wr_lock_delay() */ + +static inline void +H5TS_update_stats_wr_unlock(H5TS_rw_lock_t *rw_lock, H5TS_rec_entry_count *count) +{ + HDassert(rw_lock); + HDassert(rw_lock->magic == H5TS_RW_LOCK_MAGIC); + HDassert(count); + HDassert(count->magic == H5TS_RW_ENTRY_COUNT_MAGIC); + HDassert(count->rec_lock_count >= 0); + HDassert(count->write_lock); + + rw_lock->stats.write_locks_released++; + + if (count->rec_lock_count == 0) + rw_lock->stats.real_write_locks_released++; + +} /* end H5TS_update_stats_wr_unlock() */ +#endif + +/***************************************/ +/* Library-private Function Prototypes */ +/***************************************/ + +/* Platform-specific functions */ +#ifdef H5_HAVE_WIN_THREADS + +/* Functions called from DllMain */ +H5_DLL BOOL CALLBACK H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); +H5_DLL void H5TS_win32_process_exit(void); +H5_DLL herr_t H5TS_win32_thread_enter(void); +H5_DLL herr_t H5TS_win32_thread_exit(void); + +#else + +H5_DLL uint64_t H5TS_thread_id(void); +H5_DLL void H5TS_pthread_first_thread_init(void); + +#endif /* H5_HAVE_WIN_THREADS */ + +/* Library-scope routines */ +/* (Only used within H5private.h macros) */ H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_cancel_count_inc(void); H5_DLL herr_t H5TS_cancel_count_dec(void); -H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t * attr, void *udata); -#if defined c_plusplus || defined __cplusplus -} -#endif /* c_plusplus || __cplusplus */ +/* Fully recursive R/W lock related function declarations */ +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS +H5_DLL H5TS_rec_entry_count *H5TS_alloc_rec_entry_count(hbool_t write_lock); +H5_DLL void H5TS_free_rec_entry_count(void *target); +H5_DLL herr_t H5TS_rw_lock_init(H5TS_rw_lock_t *rw_lock, int policy); +H5_DLL herr_t H5TS_rw_lock_destroy(H5TS_rw_lock_t *rw_lock); +H5_DLL herr_t H5TS_rw_rdlock(H5TS_rw_lock_t *rw_lock); +H5_DLL herr_t H5TS_rw_wrlock(H5TS_rw_lock_t *rw_lock); +H5_DLL herr_t H5TS_rw_unlock(H5TS_rw_lock_t *rw_lock); +H5_DLL herr_t H5TS_rw_lock_get_stats(H5TS_rw_lock_t *rw_lock, H5TS_rw_lock_stats_t *stats); +H5_DLL herr_t H5TS_rw_lock_reset_stats(H5TS_rw_lock_t *rw_lock); +H5_DLL herr_t H5TS_rw_lock_print_stats(const char *header_str, H5TS_rw_lock_stats_t *stats); +#endif + +/* Testing routines */ +H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata); #else /* H5_HAVE_THREADSAFE */ +/* Non-threadsafe code needs this */ #define H5TS_thread_id() ((uint64_t)0) #endif /* H5_HAVE_THREADSAFE */ -#endif /* H5TSprivate_H_ */ - +#endif /* H5TSprivate_H_ */ diff --git a/src/H5Tarray.c b/src/H5Tarray.c index 60b3d437c1c..e2f3f01bce2 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,59 +20,48 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tarray_create2 * @@ -95,42 +84,41 @@ 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 */ - unsigned u; /* local index variable */ - hid_t ret_value; /* return value */ + H5T_t * base; /* base datatype */ + H5T_t * dt = NULL; /* new array datatype */ + unsigned u; /* local index variable */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iIu*h", base_id, ndims, dim); /* Check args */ - if(ndims < 1 || ndims > H5S_MAX_RANK) + if (ndims < 1 || ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dimensionality") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no dimensions specified") - for(u = 0; u < ndims; u++) - if(!(dim[u] > 0)) + for (u = 0; u < ndims; u++) + if (!(dim[u] > 0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "zero-sized dimension specified") - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an valid base datatype") /* Create the array datatype */ - if(NULL == (dt = H5T__array_create(base, ndims, dim))) + if (NULL == (dt = H5T__array_create(base, ndims, dim))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to create datatype") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close_real(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") FUNC_LEAVE_API(ret_value) -} /* end H5Tarray_create2() */ +} /* end H5Tarray_create2() */ - /*------------------------------------------------------------------------- * Function: H5T__array_create * @@ -151,8 +139,8 @@ H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]) 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 */ + unsigned u; /* Local index variable */ + H5T_t * ret_value = NULL; /* New array data type */ FUNC_ENTER_PACKAGE @@ -161,19 +149,19 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) HDassert(dim); /* Build new type */ - if(NULL == (ret_value = H5T__alloc())) + if (NULL == (ret_value = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") ret_value->shared->type = H5T_ARRAY; /* Copy the base type of the array */ - if(NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + if (NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") /* Set the array parameters */ ret_value->shared->u.array.ndims = ndims; /* Copy the array dimensions & compute the # of elements in the array */ - for(u = 0, ret_value->shared->u.array.nelem = 1; u < ndims; u++) { + for (u = 0, ret_value->shared->u.array.nelem = 1; u < ndims; u++) { H5_CHECKED_ASSIGN(ret_value->shared->u.array.dim[u], size_t, dim[u], hsize_t); ret_value->shared->u.array.nelem *= (size_t)dim[u]; } /* end for */ @@ -182,7 +170,7 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) ret_value->shared->size = ret_value->shared->parent->shared->size * ret_value->shared->u.array.nelem; /* Set the "force conversion" flag if the base datatype indicates */ - if(base->shared->force_conv == TRUE) + if (base->shared->force_conv == TRUE) ret_value->shared->force_conv = TRUE; /* Array datatypes need a later version of the datatype object header message */ @@ -190,9 +178,8 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__array_create */ +} /* end H5T__array_create */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_ndims * @@ -209,16 +196,16 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) int H5Tget_array_ndims(hid_t type_id) { - H5T_t *dt; /* pointer to array datatype */ - int ret_value; /* return value */ + H5T_t *dt; /* pointer to array datatype */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the number of dimensions */ @@ -226,9 +213,8 @@ H5Tget_array_ndims(hid_t type_id) done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_ndims */ +} /* end H5Tget_array_ndims */ - /*------------------------------------------------------------------------- * Function: H5T__get_array_ndims * @@ -253,9 +239,8 @@ H5T__get_array_ndims(const H5T_t *dt) /* Retrieve the number of dimensions */ FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) -} /* end H5T__get_array_ndims */ +} /* end H5T__get_array_ndims */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_dims2 * @@ -272,26 +257,25 @@ H5T__get_array_ndims(const H5T_t *dt) int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]) { - H5T_t *dt; /* pointer to array data type */ - int ret_value; /* return value */ + H5T_t *dt; /* pointer to array data type */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE2("Is", "i*h", type_id, dims); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the sizes of the dimensions */ - if((ret_value = H5T__get_array_dims(dt, dims)) < 0) + if ((ret_value = H5T__get_array_dims(dt, dims)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_dims2() */ +} /* end H5Tget_array_dims2() */ - /*------------------------------------------------------------------------- * Function: H5T__get_array_dims * @@ -309,7 +293,7 @@ H5Tget_array_dims2(hid_t type_id, hsize_t dims[]) int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_PACKAGE_NOERR @@ -317,16 +301,16 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) HDassert(dt->shared->type == H5T_ARRAY); /* Retrieve the sizes of the dimensions */ - if(dims) - for(u = 0; u < dt->shared->u.array.ndims; u++) + if (dims) + for (u = 0; u < dt->shared->u.array.ndims; u++) dims[u] = dt->shared->u.array.dim[u]; /* Pass along the array rank as the return value */ FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) -} /* end H5T__get_array_dims */ +} /* end H5T__get_array_dims */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Tarray_create1 * @@ -348,44 +332,43 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) */ hid_t H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], - const int H5_ATTR_UNUSED perm[/* ndims */]) + const int H5_ATTR_UNUSED perm[/* ndims */]) { - H5T_t *base; /* base datatype */ - H5T_t *dt = NULL; /* new array datatype */ - unsigned u; /* local index variable */ - hid_t ret_value; /* return value */ + H5T_t * base; /* base datatype */ + H5T_t * dt = NULL; /* new array datatype */ + unsigned u; /* local index variable */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "iIs*h*Is", base_id, ndims, dim, perm); /* Check args */ - if(ndims < 1 || ndims > H5S_MAX_RANK) + if (ndims < 1 || ndims > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dimensionality") - if(!dim) + if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no dimensions specified") - for(u = 0; u < (unsigned)ndims; u++) - if(!(dim[u] > 0)) + for (u = 0; u < (unsigned)ndims; u++) + if (!(dim[u] > 0)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "zero-sized dimension specified") - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an valid base datatype") /* Create the array datatype */ - if(NULL == (dt = H5T__array_create(base, (unsigned)ndims, dim))) + if (NULL == (dt = H5T__array_create(base, (unsigned)ndims, dim))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to create datatype") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") done: - if(ret_value < 0) - if(dt && H5T_close_real(dt) < 0) + if (ret_value < 0) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") FUNC_LEAVE_API(ret_value) -} /* end H5Tarray_create1() */ +} /* end H5Tarray_create1() */ - /*------------------------------------------------------------------------- * Function: H5Tget_array_dims1 * @@ -402,24 +385,23 @@ H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int H5_ATTR_UNUSED perm[]) { - H5T_t *dt; /* Array datatype to query */ - int ret_value; /* return value */ + H5T_t *dt; /* Array datatype to query */ + int ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Is", "i*h*Is", type_id, dims, perm); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") - if(dt->shared->type != H5T_ARRAY) + if (dt->shared->type != H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype") /* Retrieve the sizes of the dimensions */ - if((ret_value = H5T__get_array_dims(dt, dims)) < 0) + if ((ret_value = H5T__get_array_dims(dt, dims)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get dimension sizes") done: FUNC_LEAVE_API(ret_value) -} /* end H5Tget_array_dims1() */ +} /* end H5Tget_array_dims1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Tbit.c b/src/H5Tbit.c index c6c1777dfd4..9f0c061b37d 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,17 +16,14 @@ * the bytes are in little-endian order. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /*data-type functions */ +#include "H5WBprivate.h" /* Wrapped Buffers */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /*data-type functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ - - - /*------------------------------------------------------------------------- * Function: H5T__bit_copy * @@ -37,12 +34,11 @@ *------------------------------------------------------------------------- */ void -H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, - size_t src_offset, size_t size) +H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size) { - size_t shift; - size_t mask_lo, mask_hi; - size_t s_idx, d_idx; + size_t shift; + size_t mask_lo, mask_hi; + size_t s_idx, d_idx; FUNC_ENTER_PACKAGE_NOERR @@ -71,9 +67,9 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, */ while (src_offset && size > 0) { size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; + size_t mask = ((size_t)1 << nbits) - 1; - dst[d_idx] &= (uint8_t)~(mask << dst_offset); + dst[d_idx] &= (uint8_t) ~(mask << dst_offset); dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); src_offset += nbits; @@ -111,7 +107,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, * bits). SHIFT is three since the source must be shifted right three bits * to line up with the destination. */ - shift = dst_offset; + shift = dst_offset; mask_lo = ((size_t)1 << (8 - shift)) - 1; mask_hi = (~mask_lo) & 0xff; @@ -128,8 +124,8 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, /* Finish up */ while (size > 0) { - size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; + size_t nbits = (size_t)MIN3(size, 8 - dst_offset, 8 - src_offset); + size_t mask = ((size_t)1 << nbits) - 1; dst[d_idx] &= (uint8_t)(~(mask << dst_offset)); dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); @@ -152,7 +148,6 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_copy() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_shift * @@ -173,9 +168,9 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) { - uint8_t tmp_buf[512]; /* Temporary buffer */ - H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t tmp_buf[512]; /* Temporary buffer */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -189,7 +184,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) if (abs_shift_dist >= size) H5T__bit_set(buf, offset, size, 0); else { - size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ + size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ uint8_t *shift_buf; /* Pointer to shift buffer */ /* Wrap the local buffer for serialized header info */ @@ -217,7 +212,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) H5T__bit_set(buf, offset + size - abs_shift_dist, abs_shift_dist, 0); } } /* end else */ - } /* end if */ + } /* end if */ done: /* Release resources */ @@ -227,41 +222,37 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_shift() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_get_d * * Purpose: Return a small bit sequence as a number. Bit vector starts * at OFFSET and is SIZE bits long. * - * Return: Success: The bit sequence interpretted as an unsigned - * integer. - * - * Failure: 0 + * Return: The bit sequence interpretted as an unsigned integer * *------------------------------------------------------------------------- */ uint64_t H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) { - uint64_t val = 0; - size_t i, hs; - uint64_t ret_value = 0; /* Return value */ + uint64_t val = 0; + size_t i, hs; + uint64_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR HDassert(8 * sizeof(val) >= size); - H5T__bit_copy((uint8_t*)&val, (size_t)0, buf, offset, size); - switch(H5T_native_order_g) { + H5T__bit_copy((uint8_t *)&val, (size_t)0, buf, offset, size); + switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { - uint8_t tmp = ((uint8_t*)&val)[i]; - ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val) - (i + 1)]; - ((uint8_t*)&val)[sizeof(val) - (i + 1)] = tmp; + uint8_t tmp = ((uint8_t *)&val)[i]; + ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; + ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; } break; @@ -270,8 +261,8 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) case H5T_ORDER_NONE: case H5T_ORDER_MIXED: default: - /* Unknown endianness. Bail out. */ - HGOTO_DONE(UFAIL) + /* This function can't return errors */ + HDassert(0 && "unknown byte order"); } /* Set return value */ @@ -281,7 +272,6 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_get_d() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_set_d * @@ -294,20 +284,20 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) { - size_t i, hs; + size_t i, hs; FUNC_ENTER_PACKAGE_NOERR HDassert(8 * sizeof(val) >= size); - switch(H5T_native_order_g) { + switch (H5T_native_order_g) { case H5T_ORDER_LE: break; case H5T_ORDER_BE: for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { - uint8_t tmp = ((uint8_t *)&val)[i]; - ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; + uint8_t tmp = ((uint8_t *)&val)[i]; + ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; } break; @@ -320,12 +310,11 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) HDabort(); } - H5T__bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size); + H5T__bit_copy(buf, offset, (uint8_t *)&val, (size_t)0, size); FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_set_d() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_set * @@ -339,7 +328,7 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) { - int idx; + int idx; FUNC_ENTER_PACKAGE_NOERR @@ -349,8 +338,8 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) /* The first partial byte */ if (size && offset % 8) { - size_t nbits = MIN(size, 8 - offset); - unsigned mask = ((unsigned)1 << nbits) - 1; + size_t nbits = MIN(size, 8 - offset); + unsigned mask = ((unsigned)1 << nbits) - 1; if (value) buf[idx] = (uint8_t)(buf[idx] | (mask << offset)); @@ -378,7 +367,6 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_set() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_find * @@ -397,13 +385,12 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) *------------------------------------------------------------------------- */ ssize_t -H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, - hbool_t value) +H5T__bit_find(const uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value) { - ssize_t base = (ssize_t)offset; - ssize_t idx, i; - size_t iu; - ssize_t ret_value = (-1); /* Return value */ + ssize_t base = (ssize_t)offset; + ssize_t idx, i; + size_t iu; + ssize_t ret_value = (-1); /* Return value */ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -486,7 +473,6 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_find() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_inc * @@ -500,9 +486,9 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - unsigned carry = 1; - unsigned acc, mask; + size_t idx = start / 8; + unsigned carry = 1; + unsigned acc, mask; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -513,7 +499,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) /* The first partial byte */ if (start) { - if(size + start < 8) + if (size + start < 8) mask = ((unsigned)1 << size) - 1; else mask = ((unsigned)1 << (8 - start)) - 1; @@ -531,7 +517,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) while (carry && size >= 8) { acc = buf[idx]; acc++; - carry = acc & 0x100; + carry = acc & 0x100; buf[idx] = (uint8_t)(acc & 0xff); idx++; size -= 8; @@ -540,7 +526,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) /* The last bits */ if (carry && size > 0) { mask = ((unsigned)1 << size) - 1; - acc = buf[idx] & mask; + acc = buf[idx] & mask; acc++; carry = acc & ((unsigned)1 << size); buf[idx] &= (uint8_t)(~mask); @@ -550,7 +536,6 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE) } /* end H5T__bit_inc() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_dec * @@ -565,10 +550,10 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - size_t pos = start % 8; - uint8_t tmp; - unsigned borrow = 0; + size_t idx = start / 8; + size_t pos = start % 8; + uint8_t tmp; + unsigned borrow = 0; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -617,18 +602,17 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) * 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. */ - tmp = buf[idx]; + tmp = buf[idx]; buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); if ((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { buf[idx] = (uint8_t)(buf[idx] + (1 << (pos + size))); - borrow = 1; + borrow = 1; } } FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE) } /* end H5T__bit_dec() */ - /*------------------------------------------------------------------------- * Function: H5T__bit_neg * @@ -642,9 +626,9 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) void H5T__bit_neg(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - size_t pos = start % 8; - uint8_t tmp[1]; + size_t idx = start / 8; + size_t pos = start % 8; + uint8_t tmp[1]; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -656,30 +640,29 @@ H5T__bit_neg(uint8_t *buf, size_t start, size_t size) tmp[0] = (uint8_t)~buf[idx]; /* Simply copy the negated bit field back to the original byte */ - if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ - H5T__bit_copy(&(buf[idx]), pos, tmp, pos, (8-pos)); + if ((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ + H5T__bit_copy(&(buf[idx]), pos, tmp, pos, (8 - pos)); idx++; size -= (8 - pos); /* The middle bytes */ - while(size >= 8) { - buf[idx] = (uint8_t)~(buf[idx]); + while (size >= 8) { + buf[idx] = (uint8_t) ~(buf[idx]); idx++; size -= 8; } /* The last partial byte */ - if(size > 0) { + if (size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ tmp[0] = (uint8_t)~buf[idx]; H5T__bit_copy(&(buf[idx]), (size_t)0, tmp, (size_t)0, size); } } - else { + else { /* bit sequence ends in the same byte as starts */ H5T__bit_copy(&(buf[idx]), pos, tmp, pos, size); } FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_neg() */ - diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 18ec4f0d088..4ee070e427a 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,68 +20,64 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory Management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory Management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id); -static hid_t H5T__get_create_plist(const H5T_t *type); static H5T_t *H5T__open_oid(const H5G_loc_t *loc); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); - /*------------------------------------------------------------------------- * Function: H5Tcommit2 * @@ -96,56 +92,71 @@ static H5T_t *H5T__open_oid(const H5G_loc_t *loc); *------------------------------------------------------------------------- */ 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) +H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ - if(H5P_DEFAULT == lcpl_id) + if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") /* Get correct property list */ if (H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") + else if (TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") /* Set the LCPL for the API context */ H5CX_set_lcpl(lcpl_id); /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object from the loc_id */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + if (NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Set up VOL object */ + if (NULL == (new_obj = H5VL_create_object(data, vol_obj->connector))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype") + + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ + dt->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ - /*------------------------------------------------------------------------- * Function: H5T__commit_named * @@ -160,13 +171,12 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, *------------------------------------------------------------------------- */ herr_t -H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, - hid_t lcpl_id, hid_t tcpl_id) +H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ - H5T_state_t old_state; /* The state of the datatype before H5T__commit. */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5T_obj_create_t tcrt_info; /* Information for named datatype creation */ + H5T_state_t old_state; /* The state of the datatype before H5T__commit. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -181,16 +191,16 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, old_state = dt->shared->state; /* Set up named datatype creation info */ - tcrt_info.dt = dt; + tcrt_info.dt = dt; tcrt_info.tcpl_id = tcpl_id; /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_NAMED_DATATYPE; ocrt_info.crt_info = &tcrt_info; - ocrt_info.new_obj = NULL; + ocrt_info.new_obj = NULL; /* Create the new named datatype and link it to its parent group */ - if(H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) + if (H5L_link_object(loc, name, &ocrt_info, lcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype") HDassert(ocrt_info.new_obj); @@ -198,34 +208,34 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, /* If the datatype was committed but something failed after that, we need * to return it to the state it was in before it was committed. */ - if(ret_value < 0 && (NULL != ocrt_info.new_obj)) { - if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { + if (ret_value < 0 && (NULL != ocrt_info.new_obj)) { + if (dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Remove the datatype from the list of opened objects in the file */ - if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") - if(H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") + if (H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, + "can't remove dataset from list of open objects") /* Close the datatype object */ - if(H5O_close(&(dt->oloc), NULL) < 0) + if (H5O_close(&(dt->oloc), NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") /* Remove the datatype's object header from the file */ - if(H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") /* Mark datatype as being back in memory */ - if(H5T_set_loc(dt, dt->sh_loc.file, H5T_LOC_MEMORY)) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory") - dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; + dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; dt->shared->state = old_state; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__commit_named() */ - /*------------------------------------------------------------------------- * Function: H5Tcommit_anon * @@ -248,39 +258,56 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Group location for location */ - H5T_t *type = NULL; /* Datatype created */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_is_named(type)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ - if(H5P_DEFAULT == tcpl_id) + if (H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; - else - if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") + else if (TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") - /* Commit the type */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* Commit the datatype */ + if (NULL == (dt = H5VL_datatype_commit(vol_obj, &loc_params, NULL, type_id, H5P_LINK_CREATE_DEFAULT, + tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Setup VOL object */ + if (NULL == (new_obj = H5VL_create_object(dt, vol_obj->connector))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype") + + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ + type->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit_anon() */ - /*------------------------------------------------------------------------- * Function: H5T__commit_anon * @@ -293,13 +320,13 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id) { - H5O_loc_t *oloc; /* Object location for datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_loc_t *oloc; /* Object location for datatype */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(file); @@ -307,24 +334,23 @@ H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id) HDassert(tcpl_id != H5P_DEFAULT); /* Commit the type */ - if(H5T__commit(file, type, tcpl_id) < 0) + if (H5T__commit(file, type, tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Release the datatype's object header */ /* Get the new committed datatype's object location */ - if(NULL == (oloc = H5T_oloc(type))) + if (NULL == (oloc = H5T_oloc(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") /* Decrement refcount on committed datatype's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + if (H5O_dec_rc_by_loc(oloc) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5T__commit_anon() */ - /*------------------------------------------------------------------------- * Function: H5T__commit * @@ -341,11 +367,11 @@ H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id) herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) { - H5O_loc_t temp_oloc; /* Temporary object header location */ - H5G_name_t temp_path; /* Temporary path */ - hbool_t loc_init = FALSE; /* Have temp_oloc and temp_path been initialized? */ - size_t dtype_size; /* Size of the datatype message */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_loc_t temp_oloc; /* Temporary object header location */ + H5G_name_t temp_path; /* Temporary path */ + hbool_t loc_init = FALSE; /* Have temp_oloc and temp_path been initialized? */ + size_t dtype_size; /* Size of the datatype message */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -354,7 +380,7 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) HDassert(tcpl_id != H5P_DEFAULT); /* Check if we are allowed to write to this file */ - if(0 == (H5F_INTENT(file) & H5F_ACC_RDWR)) + if (0 == (H5F_INTENT(file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "no write intent on file") /* @@ -362,30 +388,30 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ - if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) + if (H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == type->shared->state) + if (H5T_STATE_IMMUTABLE == type->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(type) <= 0) + if (H5T_is_sensible(type) <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible") /* Mark datatype as being on disk now. This step changes the size of * datatype as stored on disk. */ - if(H5T_set_loc(type, file, H5T_LOC_DISK) < 0) + if (H5T_set_loc(type, H5F_VOL_OBJ(file), H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk") /* Reset datatype location and path */ - if(H5O_loc_reset(&temp_oloc) < 0) + if (H5O_loc_reset(&temp_oloc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize location") - if(H5G_name_reset(&temp_path) < 0) + if (H5G_name_reset(&temp_path) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "unable to initialize path") loc_init = TRUE; /* Set the version for datatype */ - if(H5T_set_version(file, type) < 0) + if (H5T_set_version(file, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set version of datatype") /* Calculate message size information, for creating object header */ @@ -396,56 +422,58 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) * Create the object header and open it for write access. Insert the data * type message and then give the object header a name. */ - if(H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0) + if (H5O_create(file, dtype_size, (size_t)1, tcpl_id, &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") - if(H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, type) < 0) + if (H5O_msg_create(&temp_oloc, H5O_DTYPE_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") /* Copy the new object header's location into the datatype, taking ownership of it */ - if(H5O_loc_copy_shallow(&(type->oloc), &temp_oloc) < 0) + if (H5O_loc_copy_shallow(&(type->oloc), &temp_oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") - if(H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(type->path), &temp_path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy datatype location") loc_init = FALSE; /* Set the shared info fields */ H5T_update_shared(type); - type->shared->state = H5T_STATE_OPEN; + type->shared->state = H5T_STATE_OPEN; type->shared->fo_count = 1; /* Add datatype to the list of open objects in the file */ - if(H5FO_top_incr(type->sh_loc.file, type->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(type->sh_loc.file, type->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't incr object ref. count") - if(H5FO_insert(type->sh_loc.file, type->sh_loc.u.loc.oh_addr, type->shared, TRUE) < 0) + if (H5FO_insert(type->sh_loc.file, type->sh_loc.u.loc.oh_addr, type->shared, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert datatype into list of open objects") /* Mark datatype as being on memory again. Since this datatype may still be * used in memory after committed to disk, change its size back as in memory. */ - if(H5T_set_loc(type, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(type, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype in memory") done: - if(ret_value < 0) { - if(loc_init) { + if (ret_value < 0) { + if (loc_init) { H5O_loc_free(&temp_oloc); H5G_name_free(&temp_path); } /* end if */ - if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { - if(H5O_dec_rc_by_loc(&(type->oloc)) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - if(H5O_close(&(type->oloc), NULL) < 0) + if ((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && + (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { + if (H5O_dec_rc_by_loc(&(type->oloc)) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, + "unable to decrement refcount on newly created object") + if (H5O_close(&(type->oloc), NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") - if(H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0) + if (H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5T__commit() */ - /*------------------------------------------------------------------------- * Function: H5Tcommitted * @@ -461,48 +489,23 @@ H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id) htri_t H5Tcommitted(hid_t type_id) { - H5T_t *type; /* Datatype to query */ - htri_t ret_value; /* Return value */ + H5T_t *type; /* Datatype to query */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", type_id); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ - ret_value = H5T_committed(type); + ret_value = H5T_is_named(type); done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommitted() */ - -/*------------------------------------------------------------------------- - * Function: H5T_committed - * - * Purpose: Determines if a datatype is committed or not. - * - * Return: Success: TRUE if committed, FALSE otherwise. - * - * Programmer: Quincey Koziol - * Wednesday, September 24, 2003 - * - *------------------------------------------------------------------------- - */ -htri_t -H5T_committed(const H5T_t *type) -{ - /* Use no-init for efficiency */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(type); - - FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state) -} /* end H5T_committed() */ - - /*------------------------------------------------------------------------- * Function: H5T_link * @@ -520,7 +523,7 @@ H5T_committed(const H5T_t *type) int H5T_link(const H5T_t *type, int adjust) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -528,14 +531,13 @@ H5T_link(const H5T_t *type, int adjust) HDassert(type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED); /* Adjust the link count on the named datatype */ - if((ret_value = H5O_link(&type->oloc, adjust)) < 0) + if ((ret_value = H5O_link(&type->oloc, adjust)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_LINKCOUNT, (-1), "unable to adjust named datatype link count") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_link() */ - /*------------------------------------------------------------------------- * Function: H5Topen2 * @@ -554,43 +556,50 @@ H5T_link(const H5T_t *type, int adjust) hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, tapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name) + if (!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") - if(!*name) + if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0) + if (H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) + if (NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ - if(H5I_INVALID_HID == ret_value) - if(type && H5T_close(type) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen2() */ - /*------------------------------------------------------------------------- * Function: H5Tget_create_plist * @@ -613,32 +622,48 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) hid_t H5Tget_create_plist(hid_t dtype_id) { - H5T_t *type; /* Datatype object for ID */ - herr_t status; /* Generic status value */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *type = NULL; /* Datatype object for ID */ + htri_t is_named = FAIL; /* Is the datatype named? */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dtype_id); /* Check arguments */ - if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype") /* Check if the datatype is committed */ - if((status = H5T_committed(type)) < 0) + if (FAIL == (is_named = H5T_is_named(type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't check whether datatype is committed") - /* Retrieve further information, if the datatype is committed */ - if(status > 0) - /* Retrieve datatype creation properties */ - if((ret_value = H5T__get_create_plist(type)) < 0) + /* If the datatype is not committed/named, just copy the default + * creation property list and return that. + */ + if (FALSE == is_named) { + H5P_genplist_t *tcpl_plist = NULL; + + /* Copy the default datatype creation property list */ + if (NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") + if ((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, + "unable to copy the creation property list") + } /* end if */ + /* If the datatype is committed, retrieve further information */ + else { + H5VL_object_t *vol_obj = type->vol_obj; + + /* Get the property list through the VOL */ + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") + } /* end else */ done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5Tflush * @@ -654,31 +679,32 @@ H5Tget_create_plist(hid_t dtype_id) herr_t H5Tflush(hid_t type_id) { - H5T_t *dt; /* Datatype for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!H5T_is_named(dt)) + if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(type_id) < 0) + if (H5CX_set_loc(type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Flush metadata for named datatype */ - if(H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype and object flush callback") + if (dt->vol_obj) + if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") done: FUNC_LEAVE_API(ret_value) } /* H5Tflush */ - /*------------------------------------------------------------------------- * Function: H5Trefresh * @@ -694,31 +720,32 @@ H5Tflush(hid_t type_id) herr_t H5Trefresh(hid_t type_id) { - H5T_t *dt; /* Datatype for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(!H5T_is_named(dt)) + if (!H5T_is_named(dt)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(type_id) < 0) + if (H5CX_set_loc(type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Refresh the datatype's metadata */ - if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + if (dt->vol_obj) + if (H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") done: FUNC_LEAVE_API(ret_value) } /* H5Trefresh */ - /*------------------------------------------------------------------------- * Function: H5T__get_create_plist * @@ -738,46 +765,45 @@ H5Trefresh(hid_t type_id) * *------------------------------------------------------------------------- */ -static hid_t +hid_t H5T__get_create_plist(const H5T_t *type) { - H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ - H5P_genplist_t *new_plist; /* New datatype creation property list */ - hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ + H5P_genplist_t *new_plist; /* New datatype creation property list */ + hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(type); /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") - if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + if (NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") + if ((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") /* Get property list object for new TCPL */ - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list") /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&type->oloc, new_plist) < 0) + if (H5O_get_create_plist(&type->oloc, new_plist) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") /* Set the return value */ ret_value = new_tcpl_id; done: - if(ret_value < 0) - if(new_tcpl_id > 0) - if(H5I_dec_app_ref(new_tcpl_id) < 0) + if (ret_value < 0) + if (new_tcpl_id > 0) + if (H5I_dec_app_ref(new_tcpl_id) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, H5I_INVALID_HID, "unable to close temporary object") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_create_plist() */ - /*------------------------------------------------------------------------- * Function: H5T__open_name * @@ -794,13 +820,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 */ - 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 * 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 */ FUNC_ENTER_PACKAGE @@ -817,33 +843,32 @@ H5T__open_name(const H5G_loc_t *loc, const char *name) * Find the named datatype object header and read the datatype message * from it. */ - if(H5G_loc_find(loc, name, &type_loc/*out*/) < 0) + if (H5G_loc_find(loc, name, &type_loc /*out*/) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") obj_found = TRUE; /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type) < 0) + if (H5O_obj_type(&oloc, &obj_type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type") - if(obj_type != H5O_TYPE_NAMED_DATATYPE) + if (obj_type != H5O_TYPE_NAMED_DATATYPE) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype") /* Open it */ - if(NULL == (dt = H5T_open(&type_loc))) + if (NULL == (dt = H5T_open(&type_loc))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") ret_value = dt; done: /* Error cleanup */ - if(NULL == ret_value) - if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) - if(H5G_loc_free(&type_loc) < 0) + if (NULL == ret_value) + if (obj_found && H5F_addr_defined(type_loc.oloc->addr)) + if (H5G_loc_free(&type_loc) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__open_name() */ - /*------------------------------------------------------------------------- * Function: H5T_open * @@ -861,57 +886,58 @@ H5T__open_name(const H5G_loc_t *loc, const char *name) 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_shared_t *shared_fo = NULL; + H5T_t * dt = NULL; + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(loc); /* Check if datatype was already open */ - if(NULL == (shared_fo = (H5T_shared_t *)H5FO_opened(loc->oloc->file, loc->oloc->addr))) { + if (NULL == (shared_fo = (H5T_shared_t *)H5FO_opened(loc->oloc->file, loc->oloc->addr))) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the datatype object */ - if(NULL == (dt = H5T__open_oid(loc))) + if (NULL == (dt = H5T__open_oid(loc))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") /* Add the datatype to the list of opened objects in the file */ - if(H5FO_insert(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr, dt->shared, FALSE) < 0) + if (H5FO_insert(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr, dt->shared, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") dt->shared->fo_count = 1; } /* end if */ else { - if(NULL == (dt = H5FL_MALLOC(H5T_t))) + if (NULL == (dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + dt->vol_obj = NULL; #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear object location */ - if(H5O_loc_reset(&(dt->oloc)) < 0) + if (H5O_loc_reset(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset location") /* Clear path name */ - if(H5G_name_reset(&(dt->path)) < 0) + if (H5G_name_reset(&(dt->path)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reset path") #endif /* H5_USING_MEMCHECKER */ /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) + if (H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy path") /* Set the shared component info */ @@ -921,31 +947,34 @@ H5T_open(const H5G_loc_t *loc) dt->shared = shared_fo; /* Mark any datatypes as being in memory now */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Increment ref. count on shared info */ shared_fo->fo_count++; /* Check if the object has been opened through the top file yet */ - if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { + if (H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) { /* Open the object through this top file */ - if(H5O_open(&(dt->oloc)) < 0) + if (H5O_open(&(dt->oloc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header") } /* end if */ /* Increment object count for the object in the top file */ - if(H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) + if (H5FO_top_incr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") } /* end else */ ret_value = dt; done: - if(ret_value == NULL) { - if(dt) { - if(shared_fo == NULL) /* Need to free shared fo */ + if (ret_value == NULL) { + if (dt) { + if (shared_fo == NULL) { /* Need to free shared fo */ + if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); + } /* end if */ H5O_loc_free(&(dt->oloc)); H5G_name_free(&(dt->path)); @@ -953,14 +982,13 @@ H5T_open(const H5G_loc_t *loc) dt = H5FL_FREE(H5T_t, dt); } /* end if */ - if(shared_fo) + if (shared_fo) shared_fo->fo_count--; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_open() */ - /*------------------------------------------------------------------------- * Function: H5T__open_oid * @@ -978,30 +1006,30 @@ H5T_open(const H5G_loc_t *loc) static H5T_t * H5T__open_oid(const H5G_loc_t *loc) { - H5T_t *dt = NULL; /* Datatype from the file */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* Datatype from the file */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(loc->oloc->addr) HDassert(loc); /* Open named datatype object in file */ - if(H5O_open(loc->oloc) < 0) + if (H5O_open(loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") /* Deserialize the datatype message into a datatype in memory */ - if(NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL))) + if (NULL == (dt = (H5T_t *)H5O_msg_read(loc->oloc, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header") /* Mark the type as named and open */ dt->shared->state = H5T_STATE_OPEN; /* Shallow copy (take ownership) of the object location object */ - if(H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) + if (H5O_loc_copy_shallow(&dt->oloc, loc->oloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy object location") /* Shallow copy (take ownership) of the group hier. path */ - if(H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) + if (H5G_name_copy(&(dt->path), loc->path, H5_COPY_SHALLOW) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy path") /* Set the shared component info */ @@ -1011,14 +1039,13 @@ H5T__open_oid(const H5G_loc_t *loc) ret_value = dt; done: - if(ret_value == NULL) - if(dt == NULL) + if (ret_value == NULL) + if (dt == NULL) H5O_close(loc->oloc, NULL); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5T__open_oid() */ - /*------------------------------------------------------------------------- * Function: H5T_update_shared * @@ -1044,3 +1071,201 @@ H5T_update_shared(H5T_t *dt) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5T_update_shared() */ +/*------------------------------------------------------------------------- + * Function: H5T_construct_datatype + * + * Purpose: Create a Library datatype with a connector specific datatype object + * + * Return: Success: A type structure + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +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; + + FUNC_ENTER_NOAPI(NULL) + + /* get required buf size for encoding the datatype */ + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &nalloc, NULL, 0) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") + + /* allocate buffer to store binary description of the datatype */ + if (NULL == (buf = (void *)H5MM_calloc((size_t)nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + + /* get binary description of the datatype */ + if (H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &nalloc, buf, (size_t)nalloc) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") + + if (NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype") + + dt->vol_obj = vol_obj; + + ret_value = dt; + +done: + if (buf) + buf = H5MM_xfree(buf); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_construct_datatype() */ + +/*------------------------------------------------------------------------- + * Function: H5T_get_named_type + * + * Purpose: Returns the VOL object for the named datatype if it exists + * + * Return: Success: Pointer to the VOL object for the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5T_get_named_type(const H5T_t *dt) +{ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (NULL != dt->vol_obj) + ret_value = dt->vol_obj; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_named_type() */ + +/*------------------------------------------------------------------------- + * Function: H5T_get_actual_type + * + * Purpose: Returns underlying native datatype created by native connector + * if datatype is committed, otherwise return the datatype + * object associate with the ID. + * + * Return: Success: Pointer to the VOL-managed data for this datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T_get_actual_type(H5T_t *dt) +{ + H5T_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check if the datatype is committed */ + if (NULL == dt->vol_obj) + ret_value = dt; + else + ret_value = (H5T_t *)H5VL_object_data(dt->vol_obj); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_actual_type() */ + +/*------------------------------------------------------------------------- + * Function: H5T_save_refresh_state + * + * Purpose: Save state for datatype reconstuction after a refresh. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) +{ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(cached_H5O_shared); + + if (NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not a datatype ID") + vol_dt = (H5T_t *)(dt->vol_obj->data); + if (NULL == vol_dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") + + /* Increase the count on the file object */ + vol_dt->shared->fo_count += 1; + + /* Increment object count for the object in the top file */ + if (H5FO_top_incr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't increment object count") + + /* Cache the H5O_shared_t data */ + H5MM_memcpy(cached_H5O_shared, &(vol_dt->sh_loc), sizeof(H5O_shared_t)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_save_refresh_state() */ + +/*------------------------------------------------------------------------- + * Function: H5T_restore_refresh_state + * + * Purpose: Restore state for datatype reconstuction after a refresh. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_restore_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) +{ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(cached_H5O_shared); + + if (NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid not a datatype ID") + vol_dt = (H5T_t *)(dt->vol_obj->data); + if (NULL == vol_dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") + + /* Restore the H5O_shared_t data */ + H5MM_memcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t)); + + /* Decrement the ref. count for this object in the top file */ + if (H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "can't decrement object count") + + /* Decrease the count on the file object */ + vol_dt->shared->fo_count -= 1; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_restore_refresh_state() */ + +/*------------------------------------------------------------------------- + * Function: H5T_already_vol_managed + * + * Purpose: Check if the committed datatype is already VOL managed + * + * Return: TRUE / FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +H5T_already_vol_managed(const H5T_t *dt) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(dt); + + FUNC_LEAVE_NOAPI(dt->vol_obj != NULL) +} /* end H5T_already_vol_managed() */ diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index 5d2d87226fe..e6a0e4efda4 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,34 +20,30 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /*generic functions */ -#include "H5CXprivate.h" /*API Contexts */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /*generic functions */ +#include "H5CXprivate.h" /*API Contexts */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Tpkg.h" /*data-type functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ @@ -55,28 +51,22 @@ static herr_t H5T__pack(const H5T_t *dt); static htri_t H5T__is_packed(const H5T_t *dt); static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tget_member_offset * @@ -98,17 +88,17 @@ static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno); size_t H5Tget_member_offset(hid_t type_id, unsigned membno) { - H5T_t *dt; /* Datatype to query */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE2("z", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") + if (membno >= dt->shared->u.compnd.nmembs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") /* Value */ ret_value = H5T_GET_MEMBER_OFFSET(dt->shared, membno); @@ -117,7 +107,6 @@ H5Tget_member_offset(hid_t type_id, unsigned membno) FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_offset() */ - /*------------------------------------------------------------------------- * Function: H5T_get_member_offset * @@ -148,7 +137,6 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno) FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].offset) } /* end H5T_get_member_offset() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_class * @@ -166,16 +154,16 @@ 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_class_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype to query */ + H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) H5TRACE2("Tt", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number") /* Get the type's class. We have to use this function to get type class @@ -187,7 +175,6 @@ H5Tget_member_class(hid_t type_id, unsigned membno) FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_class() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_type * @@ -209,36 +196,35 @@ H5Tget_member_class(hid_t type_id, unsigned membno) hid_t H5Tget_member_type(hid_t type_id, unsigned membno) { - H5T_t *dt; /* Datatype to query */ - H5T_t *memb_dt = NULL; /* Member datatype */ - hid_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + H5T_t *memb_dt = NULL; /* Member datatype */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iIu", type_id, membno); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a compound datatype") - if(membno >= dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid member number") /* Retrieve the datatype for the member */ - if(NULL == (memb_dt = H5T__reopen_member_type(dt, membno))) + if (NULL == (memb_dt = H5T__reopen_member_type(dt, membno))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to retrieve member type") /* Get an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable register datatype atom") done: - if(ret_value < 0) - if(memb_dt && H5T_close(memb_dt) < 0) + if (ret_value < 0) + if (memb_dt && H5T_close(memb_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype") FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T_get_member_type * @@ -258,7 +244,7 @@ H5Tget_member_type(hid_t type_id, unsigned membno) H5T_t * H5T_get_member_type(const H5T_t *dt, unsigned membno) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -267,14 +253,13 @@ H5T_get_member_type(const H5T_t *dt, unsigned membno) HDassert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype */ - if(NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT))) + if (NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T__reopen_member_type * @@ -295,7 +280,7 @@ H5T_get_member_type(const H5T_t *dt, unsigned membno) static H5T_t * H5T__reopen_member_type(const H5T_t *dt, unsigned membno) { - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -304,14 +289,13 @@ H5T__reopen_member_type(const H5T_t *dt, unsigned membno) HDassert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype, possibly re-opening it */ - if(NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type))) + if (NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__reopen_member_type() */ - /*------------------------------------------------------------------------- * Function: H5T__get_member_size * @@ -336,7 +320,6 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno) FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].type->shared->size) } /* end H5T__get_member_size() */ - /*------------------------------------------------------------------------- * Function: H5Tinsert * @@ -362,34 +345,34 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno) herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) { - H5T_t *parent; /* The compound parent datatype */ - H5T_t *member; /* The member datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *parent; /* The compound parent datatype */ + H5T_t *member; /* The member datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szi", parent_id, name, offset, member_id); /* Check args */ - if(parent_id == member_id) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") - if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_COMPOUND != parent->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") - if(H5T_STATE_TRANSIENT != parent->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") - if(NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (parent_id == member_id) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") + if (NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || + H5T_COMPOUND != parent->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") + if (H5T_STATE_TRANSIENT != parent->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") + if (NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Insert */ - if(H5T__insert(parent, name, offset, member) < 0) + if (H5T__insert(parent, name, offset, member) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member") done: FUNC_LEAVE_API(ret_value) } /* end H5Tinsert() */ - /*------------------------------------------------------------------------- * Function: H5Tpack * @@ -406,25 +389,25 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) herr_t H5Tpack(hid_t type_id) { - H5T_t *dt; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || + H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") /* Pack */ - if(H5T__pack(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") + if (H5T__pack(dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tpack() */ - /*------------------------------------------------------------------------- * Function: H5T__insert * @@ -443,10 +426,10 @@ H5Tpack(hid_t type_id) herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) { - unsigned idx; /* Index of member to insert */ - size_t total_size; - unsigned i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned idx; /* Index of member to insert */ + size_t total_size; + unsigned i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -457,45 +440,44 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) HDassert(name && *name); /* Does NAME already exist in PARENT? */ - for(i = 0; i < parent->shared->u.compnd.nmembs; i++) - if(!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") + for (i = 0; i < parent->shared->u.compnd.nmembs; i++) + if (!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") /* Does the new member overlap any existing member ? */ total_size = member->shared->size; - for(i = 0; i < parent->shared->u.compnd.nmembs; i++) - if((offset <= parent->shared->u.compnd.memb[i].offset && - (offset + total_size) > parent->shared->u.compnd.memb[i].offset) || - (parent->shared->u.compnd.memb[i].offset <= offset && - (parent->shared->u.compnd.memb[i].offset + - parent->shared->u.compnd.memb[i].size) > offset)) + for (i = 0; i < parent->shared->u.compnd.nmembs; i++) + if ((offset <= parent->shared->u.compnd.memb[i].offset && + (offset + total_size) > parent->shared->u.compnd.memb[i].offset) || + (parent->shared->u.compnd.memb[i].offset <= offset && + (parent->shared->u.compnd.memb[i].offset + parent->shared->u.compnd.memb[i].size) > offset)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member") /* Does the new member overlap the end of the compound type? */ - if((offset + total_size) > parent->shared->size) + if ((offset + total_size) > parent->shared->size) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type") /* Increase member array if necessary */ - if(parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { - unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2); + if (parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { + unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2); H5T_cmemb_t *x = (H5T_cmemb_t *)H5MM_realloc(parent->shared->u.compnd.memb, na * sizeof(H5T_cmemb_t)); - if(!x) + if (!x) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") parent->shared->u.compnd.nalloc = na; - parent->shared->u.compnd.memb = x; + parent->shared->u.compnd.memb = x; } /* end if */ /* Add member to end of member array */ - idx = parent->shared->u.compnd.nmembs; - parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); + idx = parent->shared->u.compnd.nmembs; + parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); parent->shared->u.compnd.memb[idx].offset = offset; - parent->shared->u.compnd.memb[idx].size = total_size; - parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL); + parent->shared->u.compnd.memb[idx].size = total_size; + parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL); parent->shared->u.compnd.sorted = H5T_SORT_NONE; parent->shared->u.compnd.nmembs++; - parent->shared->u.compnd.memb_size+=total_size; + parent->shared->u.compnd.memb_size += total_size; /* It should not be possible to get this far if the type is already packed * - the new member would overlap something */ @@ -505,23 +487,22 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) H5T__update_packed(parent); /* Set the "force conversion" flag if the field's datatype indicates */ - if(member->shared->force_conv == TRUE) + if (member->shared->force_conv == TRUE) parent->shared->force_conv = TRUE; /* Check for member having a later version than the parent */ - if(parent->shared->version < member->shared->version) + if (parent->shared->version < member->shared->version) /* Upgrade parent datatype (and all other members also) */ /* (can't use a partial datatype and later versions of the format are * more efficient, so might as well upgrade all members also... -QAK) */ - if(H5T__upgrade_version(parent, member->shared->version) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version") + if (H5T__upgrade_version(parent, member->shared->version) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__insert() */ - /*------------------------------------------------------------------------- * Function: H5T__pack * @@ -538,48 +519,49 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) static herr_t H5T__pack(const H5T_t *dt) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(dt); - if(H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { + if (H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { /* If datatype has been packed, skip packing it and indicate success */ - if(TRUE == H5T__is_packed(dt)) + if (TRUE == H5T__is_packed(dt)) HGOTO_DONE(SUCCEED) /* Check for packing unmodifiable datatype */ - if(H5T_STATE_TRANSIENT != dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") - if(dt->shared->parent) { - if(H5T__pack(dt->shared->parent) < 0) + if (dt->shared->parent) { + if (H5T__pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ - if(dt->shared->type == H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type != H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; } /* end if */ - else if(dt->shared->type == H5T_COMPOUND) { - size_t offset; /* Offset of member */ - unsigned i; /* Local index variable */ + else if (dt->shared->type == H5T_COMPOUND) { + size_t offset; /* Offset of member */ + unsigned i; /* Local index variable */ /* Recursively pack the members */ - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - if(H5T__pack(dt->shared->u.compnd.memb[i].type) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { + if (H5T__pack(dt->shared->u.compnd.memb[i].type) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to pack part of a compound datatype") /* Update the member size */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].type)->shared->size; } /* end for */ /* Remove padding between members */ - if(H5T__sort_value(dt, NULL) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") - for(i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) { + if (H5T__sort_value(dt, NULL) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") + for (i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) { dt->shared->u.compnd.memb[i].offset = offset; offset += dt->shared->u.compnd.memb[i].size; } @@ -590,13 +572,12 @@ H5T__pack(const H5T_t *dt) /* Mark the type as packed now */ dt->shared->u.compnd.packed = TRUE; } /* end if */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__pack() */ - /*------------------------------------------------------------------------- * Function: H5T__is_packed * @@ -613,24 +594,23 @@ H5T__pack(const H5T_t *dt) static htri_t H5T__is_packed(const H5T_t *dt) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(dt); /* Go up the chain as far as possible */ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; /* If this is a compound datatype, check if it is packed */ - if(dt->shared->type == H5T_COMPOUND) + if (dt->shared->type == H5T_COMPOUND) ret_value = (htri_t)(dt->shared->u.compnd.packed); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__is_packed() */ - /*------------------------------------------------------------------------- * Function: H5T__update_packed * @@ -649,7 +629,7 @@ H5T__is_packed(const H5T_t *dt) void H5T__update_packed(const H5T_t *dt) { - unsigned i; /* Index */ + unsigned i; /* Index */ FUNC_ENTER_PACKAGE_NOERR @@ -657,20 +637,19 @@ H5T__update_packed(const H5T_t *dt) HDassert(dt->shared->type == H5T_COMPOUND); /* First check if all space is used in the "top level" type */ - if(dt->shared->size == dt->shared->u.compnd.memb_size) { + if (dt->shared->size == dt->shared->u.compnd.memb_size) { /* Set the packed flag to TRUE */ dt->shared->u.compnd.packed = TRUE; /* Now check if all members are packed */ - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) - if(!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) { + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) + if (!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) { dt->shared->u.compnd.packed = FALSE; break; } /* end if */ - } /* end if */ + } /* end if */ else dt->shared->u.compnd.packed = FALSE; FUNC_LEAVE_NOAPI_VOID } /* end H5T__update_packed() */ - diff --git a/src/H5Tconv.c b/src/H5Tconv.c index f495829d1df..0c986331c2c 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,23 +19,20 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ @@ -120,19 +117,19 @@ * The macros take a subset of these arguments in the order listed here: * * CDATA: A pointer to the H5T_cdata_t structure that was passed to the - * conversion function. + * conversion function. * * STYPE: The hid_t value for the source datatype. * * DTYPE: The hid_t value for the destination datatype. * - * BUF: A pointer to the conversion buffer. + * BUF: A pointer to the conversion buffer. * - * NELMTS: The number of values to be converted. + * NELMTS: The number of values to be converted. * - * ST: The C name for source datatype (e.g., int) + * ST: The C name for source datatype (e.g., int) * - * DT: The C name for the destination datatype (e.g., signed char) + * DT: The C name for the destination datatype (e.g., signed char) * * D_MIN: The minimum possible destination value. For unsigned * destination types this should be zero. For signed @@ -170,12 +167,14 @@ * destination. * */ -#define H5T_CONV_xX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_xX_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} +#define H5T_CONV_xX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_xX_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } /* Added a condition branch(else if (*(S) == (DT)(D_MAX))) which seems redundant. * It handles a special situation when the source is "float" and assigned the value @@ -184,415 +183,455 @@ * equal. In this case, do not return exception but make sure the maximum is assigned * to the destination. SLU - 2005/06/29 */ -#define H5T_CONV_Xx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MIN); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Xx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - *(D) = (DT)(D_MAX); \ - } else if (*(S) < (ST)(D_MIN)) { \ - *(D) = (DT)(D_MIN); \ - } else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Ux_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Ux_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) > (ST)(D_MAX)) { \ - *(D) = (DT)(D_MAX); \ - } else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_sU_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_sU_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) \ - *(D) = 0; \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} +#define H5T_CONV_Xx_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MIN); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Xx_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + *(D) = (DT)(D_MIN); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Ux_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Ux_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + *(D) = (DT)(D_MAX); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_sS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_sU_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_sU_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_sU(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_sU, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } /* Define to 1 if overflow is possible during conversion, 0 otherwise * Because destination is at least as wide as the source, this should only * occur between types of equal size */ -#define H5T_CONV_uS_UCHAR_SHORT 0 -#define H5T_CONV_uS_UCHAR_INT 0 -#define H5T_CONV_uS_UCHAR_LONG 0 -#define H5T_CONV_uS_UCHAR_LLONG 0 +#define H5T_CONV_uS_UCHAR_SHORT 0 +#define H5T_CONV_uS_UCHAR_INT 0 +#define H5T_CONV_uS_UCHAR_LONG 0 +#define H5T_CONV_uS_UCHAR_LLONG 0 #if H5_SIZEOF_SHORT == H5_SIZEOF_INT - #define H5T_CONV_uS_USHORT_INT 1 +#define H5T_CONV_uS_USHORT_INT 1 #else - #define H5T_CONV_uS_USHORT_INT 0 +#define H5T_CONV_uS_USHORT_INT 0 #endif -#define H5T_CONV_uS_USHORT_LONG 0 -#define H5T_CONV_uS_USHORT_LLONG 0 +#define H5T_CONV_uS_USHORT_LONG 0 +#define H5T_CONV_uS_USHORT_LLONG 0 #if H5_SIZEOF_INT == H5_SIZEOF_LONG - #define H5T_CONV_uS_UINT_LONG 1 +#define H5T_CONV_uS_UINT_LONG 1 #else - #define H5T_CONV_uS_UINT_LONG 0 +#define H5T_CONV_uS_UINT_LONG 0 #endif -#define H5T_CONV_uS_UINT_LLONG 0 +#define H5T_CONV_uS_UINT_LLONG 0 #if H5_SIZEOF_LONG == H5_SIZEOF_LONG_LONG - #define H5T_CONV_uS_ULONG_LLONG 1 +#define H5T_CONV_uS_ULONG_LLONG 1 #else - #define H5T_CONV_uS_ULONG_LLONG 0 +#define H5T_CONV_uS_ULONG_LLONG 0 #endif /* Note. If an argument is stringified or concatenated, the prescan does not * occur. To expand the macro, then stringify or concatenate its expansion, * one macro must call another macro that does the stringification or * concatenation. */ -#define H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE) \ - H5_GLUE4(H5T_CONV_uS_, STYPE, _, DTYPE) +#define H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE) H5_GLUE4(H5T_CONV_uS_, STYPE, _, DTYPE) /* Called if overflow is possible */ -#define H5T_CONV_uS_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ - if (*(S) > (DT)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI,\ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler */ \ - *(D) = (DT)(D_MAX); \ - else if (except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, \ - "can't handle conversion exception") \ - /* if (except_ret==H5T_CONV_HANDLED): Fall through, user handled it */\ - } else \ +#define H5T_CONV_uS_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ + if (*(S) > (DT)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler */ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if (except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ *(D) = (DT)(*(S)); /* Called if no overflow is possible */ -#define H5T_CONV_uS_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \ - *(D) = (DT)(*(S)); +#define H5T_CONV_uS_CORE_0(S, D, ST, DT, D_MIN, D_MAX) *(D) = (DT)(*(S)); -#define H5T_CONV_uS_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ - H5_GLUE(H5T_CONV_uS_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) +#define H5T_CONV_uS_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ + H5_GLUE(H5T_CONV_uS_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) -#define H5T_CONV_uS_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \ - H5T_CONV_uS_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \ - S, D, ST, DT, D_MIN, D_MAX) \ -} +#define H5T_CONV_uS_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV_uS_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), S, D, ST, DT, D_MIN, D_MAX) \ + } /* Called if overflow is possible */ -#define H5T_CONV_uS_NOEX_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ - if (*(S) > (DT)(D_MAX)) \ - *(D) = (D_MAX); \ - else \ +#define H5T_CONV_uS_NOEX_CORE_1(S, D, ST, DT, D_MIN, D_MAX) \ + if (*(S) > (DT)(D_MAX)) \ + *(D) = (D_MAX); \ + else \ *(D) = (DT)(*(S)); /* Called if no overflow is possible */ -#define H5T_CONV_uS_NOEX_CORE_0(S, D, ST, DT, D_MIN, D_MAX) \ - *(D) = (DT)(*(S)); - -#define H5T_CONV_uS_NOEX_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ - H5_GLUE(H5T_CONV_uS_NOEX_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) - -#define H5T_CONV_uS_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) { \ - H5T_CONV_uS_NOEX_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), \ - S, D, ST, DT, D_MIN, D_MAX) \ -} - -#define H5T_CONV_uS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) { \ - HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ - H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) < 0) \ - *(D) = 0; \ - else if (sizeof(ST)>sizeof(DT) && *(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_su_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) < 0) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = 0; \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_su_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) < 0) \ - *(D) = 0; \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_us_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if (*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_us_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - /* Assumes memory format of unsigned & signed integers is same */ \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)==sizeof(DT)); \ - H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)<=sizeof(DT)); \ - H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} +#define H5T_CONV_uS_NOEX_CORE_0(S, D, ST, DT, D_MIN, D_MAX) *(D) = (DT)(*(S)); + +#define H5T_CONV_uS_NOEX_CORE_I(over, S, D, ST, DT, D_MIN, D_MAX) \ + H5_GLUE(H5T_CONV_uS_NOEX_CORE_, over)(S, D, ST, DT, D_MIN, D_MAX) + +#define H5T_CONV_uS_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV_uS_NOEX_CORE_I(H5T_CONV_uS_EVAL_TYPES(STYPE, DTYPE), S, D, ST, DT, D_MIN, D_MAX) \ + } + +#define H5T_CONV_uS(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_uS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_uU(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Ss(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Xx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Su_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (sizeof(ST) > sizeof(DT) && *(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Su_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) < 0) \ + *(D) = 0; \ + else if (sizeof(ST) > sizeof(DT) && *(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Su(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Us(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_Uu(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ux, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_su_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) < 0) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = 0; \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_su_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) < 0) \ + *(D) = 0; \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_su(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) == sizeof(DT)); \ + H5T_CONV(H5T_CONV_su, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_us_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_us_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + /* Assumes memory format of unsigned & signed integers is same */ \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_us(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) == sizeof(DT)); \ + H5T_CONV(H5T_CONV_us, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_CONV_fF(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } /* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN * when an overflow occurs, use the 'float' infinity values. */ -#define H5T_CONV_Ff_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Ff_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ - else if (*(S) < (ST)(D_MIN)) \ - *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - HDcompile_assert(sizeof(ST)>=sizeof(DT)); \ - H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ -} - -#define H5T_HI_LO_BIT_SET(TYP, V, LO, HI) { \ - unsigned count; \ - unsigned char p; \ - unsigned u; \ - \ - count = 0; \ - for(u = 0; u < sizeof(TYP); u++) { \ - count = (((unsigned)sizeof(TYP) - 1) - u) * 8; \ - p = (unsigned char)((V) >> count); \ - if(p > 0) { \ - if(p & 0x80) \ - count += 7; \ - else if(p & 0x40) \ - count += 6; \ - else if(p & 0x20) \ - count += 5; \ - else if(p & 0x10) \ - count += 4; \ - else if(p & 0x08) \ - count += 3; \ - else if(p & 0x04) \ - count += 2; \ - else if(p & 0x02) \ - count += 1; \ - break; \ - } /* end if */ \ - } /* end for */ \ - \ - HI = count; \ - \ - count = 0; \ - for(u = 0; u < sizeof(TYP); u++) { \ - p = (unsigned char)((V) >> (u * 8)); \ - if(p > 0) { \ - count = u * 8; \ - \ - if(p & 0x01) \ - ; \ - else if(p & 0x02) \ - count += 1; \ - else if(p & 0x04) \ - count += 2; \ - else if(p & 0x08) \ - count += 3; \ - else if(p & 0x10) \ - count += 4; \ - else if(p & 0x20) \ - count += 5; \ - else if(p & 0x40) \ - count += 6; \ - else if(p & 0x80) \ - count += 7; \ - break; \ - } /* end if */ \ - } /* end for */ \ - \ - LO = count; \ -} - -#define H5T_CONV_xF_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if (sprec > dprec) { \ - unsigned low_bit_pos, high_bit_pos; \ - \ - /* Detect high & low bits set in source */ \ - H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ - \ - /* Check for more bits of precision in src than available in dst */ \ - if((high_bit_pos - low_bit_pos) >= dprec) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(*(S)); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } \ - else \ - *(D) = (DT)(*(S)); \ - } \ - else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_xF_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_xF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ -} +#define H5T_CONV_Ff_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Ff_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (H5T_NATIVE_FLOAT_POS_INF_g); \ + else if (*(S) < (ST)(D_MIN)) \ + *(D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Ff(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + HDcompile_assert(sizeof(ST) >= sizeof(DT)); \ + H5T_CONV(H5T_CONV_Ff, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } + +#define H5T_HI_LO_BIT_SET(TYP, V, LO, HI) \ + { \ + unsigned count; \ + unsigned char p; \ + unsigned u; \ + \ + count = 0; \ + for (u = 0; u < sizeof(TYP); u++) { \ + count = (((unsigned)sizeof(TYP) - 1) - u) * 8; \ + p = (unsigned char)((V) >> count); \ + if (p > 0) { \ + if (p & 0x80) \ + count += 7; \ + else if (p & 0x40) \ + count += 6; \ + else if (p & 0x20) \ + count += 5; \ + else if (p & 0x10) \ + count += 4; \ + else if (p & 0x08) \ + count += 3; \ + else if (p & 0x04) \ + count += 2; \ + else if (p & 0x02) \ + count += 1; \ + break; \ + } /* end if */ \ + } /* end for */ \ + \ + HI = count; \ + \ + count = 0; \ + for (u = 0; u < sizeof(TYP); u++) { \ + p = (unsigned char)((V) >> (u * 8)); \ + if (p > 0) { \ + count = u * 8; \ + \ + if (p & 0x01) \ + ; \ + else if (p & 0x02) \ + count += 1; \ + else if (p & 0x04) \ + count += 2; \ + else if (p & 0x08) \ + count += 3; \ + else if (p & 0x10) \ + count += 4; \ + else if (p & 0x20) \ + count += 5; \ + else if (p & 0x40) \ + count += 6; \ + else if (p & 0x80) \ + count += 7; \ + break; \ + } /* end if */ \ + } /* end for */ \ + \ + LO = count; \ + } + +#define H5T_CONV_xF_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (sprec > dprec) { \ + unsigned low_bit_pos, high_bit_pos; \ + \ + /* Detect high & low bits set in source */ \ + H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ + \ + /* Check for more bits of precision in src than available in dst */ \ + if ((high_bit_pos - low_bit_pos) >= dprec) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(*(S)); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_xF_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_xF(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV(H5T_CONV_xF, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } /* Quincey added the condition branch (else if (*(S) != (ST)((DT)(*(S))))). * It handles a special situation when the source is "float" and assigned the value @@ -602,358 +641,396 @@ * (ST)(D_MAX))) is for some compilers like Sun, HP, IBM, and SGI where under * the same situation the "int" doesn't overflow. SLU - 2005/9/12 */ -#define H5T_CONV_Fx_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MAX); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) < (ST)(D_MIN)) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(D_MIN); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } else if (*(S) != (ST)((DT)(*(S)))) { \ - H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, \ - src_id, dst_id, S, D, cb_struct.user_data); \ - if(except_ret == H5T_CONV_UNHANDLED) \ - /* Let compiler convert if case is ignored by user handler*/ \ - *(D) = (DT)(*(S)); \ - else if(except_ret == H5T_CONV_ABORT) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ - /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ - } \ - else \ - *(D) = (DT)(*(S)); \ -} -#define H5T_CONV_Fx_NOEX_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - if(*(S) > (ST)(D_MAX)) \ - *(D) = (DT)(D_MAX); \ - else if(*(S) < (ST)(D_MIN)) \ - *(D) = (DT)(D_MIN); \ - else \ - *(D) = (DT)(*(S)); \ -} - -#define H5T_CONV_Fx(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \ - H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ -} +#define H5T_CONV_Fx_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MAX); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(D_MIN); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) != (ST)((DT)(*(S)))) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(*(S)); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Fx_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = (DT)(D_MAX); \ + else if (*(S) < (ST)(D_MIN)) \ + *(D) = (DT)(D_MIN); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Fx(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + { \ + H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } /* Since all "no exception" cores do the same thing (assign the value in the * source location to the destination location, using casting), use one "core" * to do them all. */ #ifndef H5_WANT_DCONV_EXCEPTION -#define H5T_CONV_NO_EXCEPT_CORE(STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) { \ - *(D) = (DT)(*(S)); \ -} +#define H5T_CONV_NO_EXCEPT_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + *(D) = (DT)(*(S)); \ + } #endif /* H5_WANT_DCONV_EXCEPTION */ - /* The main part of every integer hardware conversion macro */ -#define H5T_CONV(GUTS,STYPE,DTYPE,ST,DT,D_MIN,D_MAX,PREC) \ -{ \ - herr_t ret_value=SUCCEED; /* Return value */ \ - \ - FUNC_ENTER_PACKAGE \ - \ -{ \ - size_t elmtno; /*element number */ \ - H5T_CONV_DECL_PREC(PREC) /*declare precision variables, or not */ \ - uint8_t *src_buf; /*'raw' source buffer */ \ - uint8_t *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? */ \ - ssize_t s_stride, d_stride; /*src and dst strides */ \ - size_t safe; /*how many elements are safe to process in each pass */ \ - H5T_conv_cb_t cb_struct; /*conversion callback structure */ \ - \ - switch (cdata->command) { \ - case H5T_CONV_INIT: \ - /* Sanity check and initialize statistics */ \ - cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ - "unable to dereference datatype object ID") \ - if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ - "disagreement about datatype size") \ - CI_ALLOC_PRIV \ - break; \ - \ - case H5T_CONV_FREE: \ - /* Print and free statistics */ \ - CI_PRINT_STATS(STYPE,DTYPE); \ - CI_FREE_PRIV \ - break; \ - \ - case H5T_CONV_CONV: \ - /* Initialize source & destination strides */ \ - if (buf_stride) { \ - HDassert(buf_stride >= sizeof(ST)); \ - HDassert(buf_stride >= sizeof(DT)); \ - s_stride = d_stride = (ssize_t)buf_stride; \ - } else { \ - s_stride = sizeof(ST); \ - d_stride = sizeof(DT); \ - } \ - \ - /* Is alignment required for source or dest? */ \ - s_mv = H5T_NATIVE_##STYPE##_ALIGN_g>1 && \ - ((size_t)buf%H5T_NATIVE_##STYPE##_ALIGN_g || \ - /* Cray */ ((size_t)((ST*)buf)!=(size_t)buf) || \ - (size_t)s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \ - d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g>1 && \ - ((size_t)buf%H5T_NATIVE_##DTYPE##_ALIGN_g || \ - /* Cray */ ((size_t)((DT*)buf)!=(size_t)buf) || \ - (size_t)d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \ - CI_INC_SRC(s_mv) \ - CI_INC_DST(d_mv) \ - \ - /* Get conversion exception callback property */ \ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") \ - \ - /* Get source and destination datatypes */ \ - if(NULL == (st = (H5T_t *)H5I_object(src_id)) || NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference datatype object ID") \ - \ - H5T_CONV_SET_PREC(PREC) /*init precision variables, or not */ \ - \ - /* The outer loop of the type conversion macro, controlling which */ \ - /* direction the buffer is walked */ \ - while (nelmts>0) { \ - /* Check if we need to go backwards through the buffer */ \ - if(d_stride>s_stride) { \ - /* Compute the number of "safe" destination elements at */ \ - /* the end of the buffer (Those which don't overlap with */ \ - /* any source elements at the beginning of the buffer) */ \ - safe = nelmts - (((nelmts * (size_t)s_stride) + (size_t)(d_stride - 1)) / (size_t)d_stride); \ - \ - /* If we're down to the last few elements, just wrap up */ \ - /* with a "real" reverse copy */ \ - if(safe<2) { \ - src = (ST *)(src_buf = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride); \ - dst = (DT *)(dst_buf = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride); \ - s_stride = -s_stride; \ - d_stride = -d_stride; \ - \ - safe=nelmts; \ - } /* end if */ \ - else { \ - src = (ST *)(src_buf = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride); \ - dst = (DT *)(dst_buf = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride); \ - } /* end else */ \ - } /* end if */ \ - else { \ - /* Single forward pass over all data */ \ - src = (ST *)(src_buf = (uint8_t*)buf); \ - dst = (DT *)(dst_buf = (uint8_t*)buf); \ - safe=nelmts; \ - } /* end else */ \ - \ - /* Perform loop over elements to convert */ \ - if (s_mv && d_mv) { \ - /* Alignment is required for both source and dest */ \ - s = &src_aligned; \ - H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,s,d,ST,DT,D_MIN,D_MAX) \ - } else if(s_mv) { \ - /* Alignment is required only for source */ \ - s = &src_aligned; \ - H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,s,dst,ST,DT,D_MIN,D_MAX) \ - } else if(d_mv) { \ - /* Alignment is required only for destination */ \ - H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,STYPE,DTYPE,src,d,ST,DT,D_MIN,D_MAX) \ - } else { \ - /* Alignment is not required for both source and destination */ \ - H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,STYPE,DTYPE,src,dst,ST,DT,D_MIN,D_MAX) \ - } \ - \ - /* Decrement number of elements left to convert */ \ - nelmts-=safe; \ - } /* end while */ \ - break; \ - \ - default: \ - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \ - "unknown conversion command"); \ - } \ -} \ - \ -done: \ - FUNC_LEAVE_NOAPI(ret_value) \ -} +#define H5T_CONV(GUTS, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, PREC) \ + { \ + herr_t ret_value = SUCCEED; /* Return value */ \ + \ + FUNC_ENTER_PACKAGE \ + \ + { \ + 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 */ \ + ST src_aligned; /*source aligned type */ \ + DT dst_aligned; /*destination aligned type */ \ + hbool_t s_mv, d_mv; /*move data to align it? */ \ + ssize_t s_stride, d_stride; /*src and dst strides */ \ + size_t safe; /*how many elements are safe to process in each pass */ \ + H5T_conv_cb_t cb_struct; /*conversion callback structure */ \ + \ + switch (cdata->command) { \ + case H5T_CONV_INIT: \ + /* Sanity check and initialize statistics */ \ + cdata->need_bkg = H5T_BKG_NO; \ + if (NULL == (st = (H5T_t *)H5I_object(src_id)) || \ + NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ + "unable to dereference datatype object ID") \ + if (st->shared->size != sizeof(ST) || dt->shared->size != sizeof(DT)) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "disagreement about datatype size") \ + CI_ALLOC_PRIV \ + break; \ + \ + case H5T_CONV_FREE: \ + /* Print and free statistics */ \ + CI_PRINT_STATS(STYPE, DTYPE); \ + CI_FREE_PRIV \ + break; \ + \ + case H5T_CONV_CONV: \ + /* Initialize source & destination strides */ \ + if (buf_stride) { \ + HDassert(buf_stride >= sizeof(ST)); \ + HDassert(buf_stride >= sizeof(DT)); \ + s_stride = d_stride = (ssize_t)buf_stride; \ + } \ + else { \ + s_stride = sizeof(ST); \ + d_stride = sizeof(DT); \ + } \ + \ + /* Is alignment required for source or dest? */ \ + s_mv = H5T_NATIVE_##STYPE##_ALIGN_g > 1 && \ + ((size_t)buf % H5T_NATIVE_##STYPE##_ALIGN_g || \ + /* Cray */ ((size_t)((ST *)buf) != (size_t)buf) || \ + (size_t)s_stride % H5T_NATIVE_##STYPE##_ALIGN_g); \ + d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g > 1 && \ + ((size_t)buf % H5T_NATIVE_##DTYPE##_ALIGN_g || \ + /* Cray */ ((size_t)((DT *)buf) != (size_t)buf) || \ + (size_t)d_stride % H5T_NATIVE_##DTYPE##_ALIGN_g); \ + CI_INC_SRC(s_mv) \ + CI_INC_DST(d_mv) \ + \ + /* Get conversion exception callback property */ \ + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, \ + "unable to get conversion exception callback") \ + \ + /* Get source and destination datatypes */ \ + if (NULL == (st = (H5T_t *)H5I_object(src_id)) || \ + NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ + "unable to dereference datatype object ID") \ + \ + H5T_CONV_SET_PREC(PREC) /*init precision variables, or not */ \ + \ + /* The outer loop of the type conversion macro, controlling which */ \ + /* direction the buffer is walked */ \ + while (nelmts > 0) { \ + /* Check if we need to go backwards through the buffer */ \ + if (d_stride > s_stride) { \ + /* Compute the number of "safe" destination elements at */ \ + /* the end of the buffer (Those which don't overlap with */ \ + /* any source elements at the beginning of the buffer) */ \ + safe = nelmts - (((nelmts * (size_t)s_stride) + (size_t)(d_stride - 1)) / \ + (size_t)d_stride); \ + \ + /* If we're down to the last few elements, just wrap up */ \ + /* with a "real" reverse copy */ \ + if (safe < 2) { \ + src = (ST *)(src_buf = (void *)((uint8_t *)buf + \ + (nelmts - 1) * (size_t)s_stride)); \ + dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + \ + (nelmts - 1) * (size_t)d_stride)); \ + s_stride = -s_stride; \ + d_stride = -d_stride; \ + \ + safe = nelmts; \ + } /* end if */ \ + else { \ + src = (ST *)(src_buf = (void *)((uint8_t *)buf + \ + (nelmts - safe) * (size_t)s_stride)); \ + dst = (DT *)(dst_buf = (void *)((uint8_t *)buf + \ + (nelmts - safe) * (size_t)d_stride)); \ + } /* end else */ \ + } /* end if */ \ + else { \ + /* Single forward pass over all data */ \ + src = (ST *)(src_buf = buf); \ + dst = (DT *)(dst_buf = buf); \ + safe = nelmts; \ + } /* end else */ \ + \ + /* Perform loop over elements to convert */ \ + if (s_mv && d_mv) { \ + /* Alignment is required for both source and dest */ \ + s = &src_aligned; \ + H5T_CONV_LOOP_OUTER(PRE_SALIGN, PRE_DALIGN, POST_SALIGN, POST_DALIGN, GUTS, \ + STYPE, DTYPE, s, d, ST, DT, D_MIN, D_MAX) \ + } \ + else if (s_mv) { \ + /* Alignment is required only for source */ \ + s = &src_aligned; \ + H5T_CONV_LOOP_OUTER(PRE_SALIGN, PRE_DNOALIGN, POST_SALIGN, POST_DNOALIGN, GUTS, \ + STYPE, DTYPE, s, dst, ST, DT, D_MIN, D_MAX) \ + } \ + else if (d_mv) { \ + /* Alignment is required only for destination */ \ + H5T_CONV_LOOP_OUTER(PRE_SNOALIGN, PRE_DALIGN, POST_SNOALIGN, POST_DALIGN, GUTS, \ + STYPE, DTYPE, src, d, ST, DT, D_MIN, D_MAX) \ + } \ + else { \ + /* Alignment is not required for both source and destination */ \ + H5T_CONV_LOOP_OUTER(PRE_SNOALIGN, PRE_DNOALIGN, POST_SNOALIGN, POST_DNOALIGN, \ + GUTS, STYPE, DTYPE, src, dst, ST, DT, D_MIN, D_MAX) \ + } \ + \ + /* Decrement number of elements left to convert */ \ + nelmts -= safe; \ + } /* end while */ \ + break; \ + \ + default: \ + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command"); \ + } \ + } \ + \ +done: \ + FUNC_LEAVE_NOAPI(ret_value) \ + } /* Declare the source & destination precision variables */ #define H5T_CONV_DECL_PREC(PREC) H5_GLUE(H5T_CONV_DECL_PREC_, PREC) -#define H5T_CONV_DECL_PREC_Y \ - size_t sprec; /*source precision */ \ - size_t dprec; /*destination precision */ \ - H5T_class_t tclass; /*datatype's class */ +#define H5T_CONV_DECL_PREC_Y \ + size_t sprec; /*source precision */ \ + size_t dprec; /*destination precision */ \ + H5T_class_t tclass; /*datatype's class */ -#define H5T_CONV_DECL_PREC_N /*no precision variables */ +#define H5T_CONV_DECL_PREC_N /*no precision variables */ /* Initialize the source & destination precision variables */ #define H5T_CONV_SET_PREC(PREC) H5_GLUE(H5T_CONV_SET_PREC_, PREC) -#define H5T_CONV_SET_PREC_Y \ - /* Get source & destination precisions into a variable */ \ - tclass = st->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - sprec = st->shared->u.atomic.prec; \ - else \ - sprec = 1 + st->shared->u.atomic.u.f.msize; \ - tclass = dt->shared->type; \ - HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ - if(tclass == H5T_INTEGER) \ - dprec = dt->shared->u.atomic.prec; \ - else \ - dprec = 1 + dt->shared->u.atomic.u.f.msize; - -#define H5T_CONV_SET_PREC_N /*don't init precision variables */ +#define H5T_CONV_SET_PREC_Y \ + /* Get source & destination precisions into a variable */ \ + tclass = st->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if (tclass == H5T_INTEGER) \ + sprec = st->shared->u.atomic.prec; \ + else \ + sprec = 1 + st->shared->u.atomic.u.f.msize; \ + tclass = dt->shared->type; \ + HDassert(tclass == H5T_INTEGER || tclass == H5T_FLOAT); \ + if (tclass == H5T_INTEGER) \ + dprec = dt->shared->u.atomic.prec; \ + else \ + dprec = 1 + dt->shared->u.atomic.u.f.msize; + +#define H5T_CONV_SET_PREC_N /*don't init precision variables */ /* 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)); \ -} +#define H5T_CONV_LOOP_PRE_SALIGN(ST) \ + { \ + H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ + } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_SNOALIGN(ST) { \ -} +#define H5T_CONV_LOOP_PRE_SNOALIGN(ST) \ + { \ + } /* Macro defining action on destination data which needs to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_DALIGN(DT) { \ - d = &dst_aligned; \ -} +#define H5T_CONV_LOOP_PRE_DALIGN(DT) \ + { \ + d = &dst_aligned; \ + } /* Macro defining action on destination data which doesn't need to be aligned (before main action) */ -#define H5T_CONV_LOOP_PRE_DNOALIGN(DT) { \ -} +#define H5T_CONV_LOOP_PRE_DNOALIGN(DT) \ + { \ + } /* Macro defining action on source data which needs to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_SALIGN(ST) { \ -} +#define H5T_CONV_LOOP_POST_SALIGN(ST) \ + { \ + } /* Macro defining action on source data which doesn't need to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_SNOALIGN(ST) { \ -} +#define H5T_CONV_LOOP_POST_SNOALIGN(ST) \ + { \ + } /* 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)); \ -} +#define H5T_CONV_LOOP_POST_DALIGN(DT) \ + { \ + H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ + } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ -#define H5T_CONV_LOOP_POST_DNOALIGN(DT) { \ -} +#define H5T_CONV_LOOP_POST_DNOALIGN(DT) \ + { \ + } /* The outer wrapper for the type conversion loop, to check for an exception handling routine */ -#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - if(cb_struct.func) { \ - H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - } \ - else { \ - H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ +#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, GUTS, \ + STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + if (cb_struct.func) { \ + H5T_CONV_LOOP(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, GUTS, STYPE, \ + DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + } \ + else { \ + H5T_CONV_LOOP(PRE_SALIGN_GUTS, PRE_DALIGN_GUTS, POST_SALIGN_GUTS, POST_DALIGN_GUTS, \ + H5_GLUE(GUTS, _NOEX), STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ } /* The inner loop of the type conversion macro, actually converting the elements */ -#define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,STYPE,DTYPE,S,D,ST,DT,D_MIN,D_MAX) \ - for (elmtno=0; elmtnopriv)->s_aligned) { \ - HDfprintf(H5DEBUG(T), \ - " %Hu src elements aligned on %lu-byte boundaries\n", \ - ((H5T_conv_hw_t *)cdata->priv)->s_aligned, \ - (unsigned long)H5T_NATIVE_##STYPE##_ALIGN_g); \ - } \ - if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \ - HDfprintf(H5DEBUG(T), \ - " %Hu dst elements aligned on %lu-byte boundaries\n", \ - ((H5T_conv_hw_t *)cdata->priv)->d_aligned, \ - (unsigned long)H5T_NATIVE_##DTYPE##_ALIGN_g); \ - } \ -} +#define CI_PRINT_STATS(STYPE, DTYPE) \ + { \ + if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->s_aligned) { \ + HDfprintf(H5DEBUG(T), " %zu src elements aligned on %zu-byte boundaries\n", \ + ((H5T_conv_hw_t *)cdata->priv)->s_aligned, H5T_NATIVE_##STYPE##_ALIGN_g); \ + } \ + if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \ + HDfprintf(H5DEBUG(T), " %zu dst elements aligned on %zu-byte boundaries\n", \ + ((H5T_conv_hw_t *)cdata->priv)->d_aligned, H5T_NATIVE_##DTYPE##_ALIGN_g); \ + } \ + } /* Allocate private alignment structure for atomic types */ -# define CI_ALLOC_PRIV \ - if (NULL==(cdata->priv=H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \ - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \ - "memory allocation failed"); \ +#define CI_ALLOC_PRIV \ + if (NULL == (cdata->priv = H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \ + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); \ } /* Free private alignment structure for atomic types */ -# define CI_FREE_PRIV \ - if(cdata->priv!=NULL) \ +#define CI_FREE_PRIV \ + if (cdata->priv != NULL) \ cdata->priv = H5MM_xfree(cdata->priv); /* Increment source alignment counter */ -# define CI_INC_SRC(s) if (s) ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts; +#define CI_INC_SRC(s) \ + if (s) \ + ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts; /* Increment destination alignment counter */ -# define CI_INC_DST(d) if (d) ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts; -#else /* H5T_DEBUG */ -# define CI_PRINT_STATS(STYPE,DTYPE) /*void*/ -# define CI_ALLOC_PRIV cdata->priv=NULL; -# define CI_FREE_PRIV /* void */ -# define CI_INC_SRC(s) /* void */ -# define CI_INC_DST(d) /* void */ -#endif /* H5T_DEBUG */ +#define CI_INC_DST(d) \ + if (d) \ + ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts; +#else /* H5T_DEBUG */ +#define CI_PRINT_STATS(STYPE, DTYPE) /*void*/ +#define CI_ALLOC_PRIV cdata->priv = NULL; +#define CI_FREE_PRIV /* void */ +#define CI_INC_SRC(s) /* void */ +#define CI_INC_DST(d) /* void */ +#endif /* H5T_DEBUG */ /* Swap two elements (I & J) of an array using a temporary variable */ -#define H5_SWAP_BYTES(ARRAY,I,J) {uint8_t _tmp; _tmp=ARRAY[I]; ARRAY[I]=ARRAY[J]; ARRAY[J]=_tmp;} +#define H5_SWAP_BYTES(ARRAY, I, J) \ + { \ + uint8_t _tmp; \ + _tmp = ARRAY[I]; \ + ARRAY[I] = ARRAY[J]; \ + ARRAY[J] = _tmp; \ + } /* Minimum size of variable-length conversion buffer */ -#define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 +#define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 /******************/ /* Local Typedefs */ @@ -961,54 +1038,49 @@ 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 */ - H5T_subset_info_t subset_info; /*info related to compound subsets */ - unsigned src_nmembs; /*needed by free function */ + 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; /* Conversion data for H5T__conv_enum() */ 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 base; /*lowest `in' value */ + unsigned length; /*num elements in arrays */ + int * src2dst; /*map from src to dst index */ } H5T_enum_struct_t; /* Conversion data for the hardware conversion functions */ typedef struct H5T_conv_hw_t { - size_t s_aligned; /*number source elements aligned */ - size_t d_aligned; /*number destination elements aligned*/ + size_t s_aligned; /*number source elements aligned */ + size_t d_aligned; /*number destination elements aligned*/ } H5T_conv_hw_t; /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order); - +static herr_t H5T__reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order); /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -1019,6 +1091,8 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq); /* Declare a free list to manage pieces of array data */ H5FL_BLK_DEFINE_STATIC(array_seq); +/* Declare a free list to manage pieces of reference data */ +H5FL_BLK_DEFINE_STATIC(ref_seq); /*------------------------------------------------------------------------- * Function: H5T__conv_noop @@ -1035,15 +1109,14 @@ H5FL_BLK_DEFINE_STATIC(array_seq); */ herr_t H5T__conv_noop(hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, H5T_cdata_t *cdata, - size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, - size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *buf, - void H5_ATTR_UNUSED *background) + size_t H5_ATTR_UNUSED nelmts, size_t H5_ATTR_UNUSED buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void H5_ATTR_UNUSED *buf, void H5_ATTR_UNUSED *background) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: cdata->need_bkg = H5T_BKG_NO; break; @@ -1063,7 +1136,6 @@ H5T__conv_noop(hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, H5T_cda FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_noop() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_order_opt * @@ -1081,39 +1153,37 @@ H5T__conv_noop(hid_t H5_ATTR_UNUSED src_id, hid_t H5_ATTR_UNUSED dst_id, H5T_cda *------------------------------------------------------------------------- */ herr_t -H5T__conv_order_opt(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) +H5T__conv_order_opt(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; - H5T_t *dst = NULL; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *buf = (uint8_t *)_buf; + H5T_t * src = NULL; + H5T_t * dst = NULL; + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(src->shared->size != dst->shared->size || - 0 != src->shared->u.atomic.offset || - 0 != dst->shared->u.atomic.offset) + if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if((src->shared->type == H5T_REFERENCE && dst->shared->type != H5T_REFERENCE) || - (dst->shared->type == H5T_REFERENCE && src->shared->type != H5T_REFERENCE)) + if ((src->shared->type == H5T_REFERENCE && dst->shared->type != H5T_REFERENCE) || + (dst->shared->type == H5T_REFERENCE && src->shared->type != H5T_REFERENCE)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if(src->shared->type != H5T_REFERENCE && - !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || - (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) + if (src->shared->type != H5T_REFERENCE && !((H5T_ORDER_BE == src->shared->u.atomic.order && + H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && + H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - if(src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && - src->shared->size != 8 && src->shared->size != 16) + if (src->shared->size != 1 && src->shared->size != 2 && src->shared->size != 4 && + src->shared->size != 8 && src->shared->size != 16) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - switch(src->shared->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: case H5T_REFERENCE: @@ -1121,14 +1191,14 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; case H5T_FLOAT: - if(src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || - src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || - src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || - src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || - src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || - src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || - src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || - src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") break; @@ -1149,13 +1219,13 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Check for "no op" reference conversion */ - if(src->shared->type == H5T_REFERENCE) { + if (src->shared->type == H5T_REFERENCE) { /* Sanity check */ - if(dst->shared->type != H5T_REFERENCE) + if (dst->shared->type != H5T_REFERENCE) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") /* Check if we are on a little-endian machine (the order that @@ -1167,186 +1237,186 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * "native" hobj_ref_t datatype and I think that would break a * lot of existing programs. -QAK */ - if(H5T_native_order_g == H5T_ORDER_LE) + if (H5T_native_order_g == H5T_ORDER_LE) break; } /* end if */ buf_stride = buf_stride ? buf_stride : src->shared->size; - switch(src->shared->size) { + switch (src->shared->size) { case 1: /*no-op*/ break; case 2: - for(/*void*/; nelmts >= 20; nelmts -= 20) { - H5_SWAP_BYTES(buf, 0, 1); /* 0 */ + for (/*void*/; nelmts >= 20; nelmts -= 20) { + H5_SWAP_BYTES(buf, 0, 1); /* 0 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 1 */ + H5_SWAP_BYTES(buf, 0, 1); /* 1 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 2 */ + H5_SWAP_BYTES(buf, 0, 1); /* 2 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 3 */ + H5_SWAP_BYTES(buf, 0, 1); /* 3 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 4 */ + H5_SWAP_BYTES(buf, 0, 1); /* 4 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 5 */ + H5_SWAP_BYTES(buf, 0, 1); /* 5 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 6 */ + H5_SWAP_BYTES(buf, 0, 1); /* 6 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 7 */ + H5_SWAP_BYTES(buf, 0, 1); /* 7 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 8 */ + H5_SWAP_BYTES(buf, 0, 1); /* 8 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 9 */ + H5_SWAP_BYTES(buf, 0, 1); /* 9 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 10 */ + H5_SWAP_BYTES(buf, 0, 1); /* 10 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 11 */ + H5_SWAP_BYTES(buf, 0, 1); /* 11 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 12 */ + H5_SWAP_BYTES(buf, 0, 1); /* 12 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 13 */ + H5_SWAP_BYTES(buf, 0, 1); /* 13 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 14 */ + H5_SWAP_BYTES(buf, 0, 1); /* 14 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 15 */ + H5_SWAP_BYTES(buf, 0, 1); /* 15 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 16 */ + H5_SWAP_BYTES(buf, 0, 1); /* 16 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 17 */ + H5_SWAP_BYTES(buf, 0, 1); /* 17 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 18 */ + H5_SWAP_BYTES(buf, 0, 1); /* 18 */ buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 1); /* 19 */ + H5_SWAP_BYTES(buf, 0, 1); /* 19 */ buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) + for (i = 0; i < nelmts; i++, buf += buf_stride) H5_SWAP_BYTES(buf, 0, 1); break; case 4: - for(/*void*/; nelmts >= 20; nelmts -= 20) { - H5_SWAP_BYTES(buf, 0, 3); /* 0 */ - H5_SWAP_BYTES(buf, 1, 2); + for (/*void*/; nelmts >= 20; nelmts -= 20) { + H5_SWAP_BYTES(buf, 0, 3); /* 0 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 1 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 1 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 2 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 2 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 3 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 3 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 4 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 4 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 5 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 5 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 6 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 6 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 7 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 7 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 8 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 8 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 9 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 9 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 10 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 10 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 11 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 11 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 12 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 12 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 13 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 13 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 14 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 14 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 15 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 15 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 16 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 16 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 17 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 17 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 18 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 18 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 3); /* 19 */ - H5_SWAP_BYTES(buf, 1, 2); + H5_SWAP_BYTES(buf, 0, 3); /* 19 */ + H5_SWAP_BYTES(buf, 1, 2); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 3); H5_SWAP_BYTES(buf, 1, 2); } /* end for */ break; case 8: - for(/*void*/; nelmts >= 10; nelmts -= 10) { - H5_SWAP_BYTES(buf, 0, 7); /* 0 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + for (/*void*/; nelmts >= 10; nelmts -= 10) { + H5_SWAP_BYTES(buf, 0, 7); /* 0 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 1 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 1 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 2 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 2 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 3 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 3 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 4 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 4 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 5 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 5 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 6 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 6 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 7 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 7 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 8 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 8 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 7); /* 9 */ - H5_SWAP_BYTES(buf, 1, 6); - H5_SWAP_BYTES(buf, 2, 5); - H5_SWAP_BYTES(buf, 3, 4); + H5_SWAP_BYTES(buf, 0, 7); /* 9 */ + H5_SWAP_BYTES(buf, 1, 6); + H5_SWAP_BYTES(buf, 2, 5); + H5_SWAP_BYTES(buf, 3, 4); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 7); H5_SWAP_BYTES(buf, 1, 6); H5_SWAP_BYTES(buf, 2, 5); @@ -1355,107 +1425,107 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; case 16: - for(/*void*/; nelmts >= 10; nelmts -= 10) { - H5_SWAP_BYTES(buf, 0, 15); /* 0 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + for (/*void*/; nelmts >= 10; nelmts -= 10) { + H5_SWAP_BYTES(buf, 0, 15); /* 0 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 1 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 1 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 2 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 2 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 3 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 3 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 4 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 4 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 5 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 5 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 6 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 6 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 7 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 7 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 8 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 8 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; - H5_SWAP_BYTES(buf, 0, 15); /* 9 */ - H5_SWAP_BYTES(buf, 1, 14); - H5_SWAP_BYTES(buf, 2, 13); - H5_SWAP_BYTES(buf, 3, 12); - H5_SWAP_BYTES(buf, 4, 11); - H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 0, 15); /* 9 */ + H5_SWAP_BYTES(buf, 1, 14); + H5_SWAP_BYTES(buf, 2, 13); + H5_SWAP_BYTES(buf, 3, 12); + H5_SWAP_BYTES(buf, 4, 11); + H5_SWAP_BYTES(buf, 5, 10); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); buf += buf_stride; } /* end for */ - for(i = 0; i < nelmts; i++, buf += buf_stride) { + for (i = 0; i < nelmts; i++, buf += buf_stride) { H5_SWAP_BYTES(buf, 0, 15); H5_SWAP_BYTES(buf, 1, 14); H5_SWAP_BYTES(buf, 2, 13); H5_SWAP_BYTES(buf, 3, 12); H5_SWAP_BYTES(buf, 4, 11); H5_SWAP_BYTES(buf, 5, 10); - H5_SWAP_BYTES(buf, 6, 9); - H5_SWAP_BYTES(buf, 7, 8); + H5_SWAP_BYTES(buf, 6, 9); + H5_SWAP_BYTES(buf, 7, 8); } /* end for */ break; @@ -1476,7 +1546,6 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_order_opt() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_order * @@ -1493,47 +1562,45 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_order(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) +H5T__conv_order(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; - H5T_t *dst = NULL; - size_t i; - size_t j, md; - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *buf = (uint8_t *)_buf; + H5T_t * src = NULL; + H5T_t * dst = NULL; + size_t i; + size_t j, md; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || - 0 != dst->shared->u.atomic.offset || - !((H5T_ORDER_BE == src->shared->u.atomic.order && - H5T_ORDER_LE == dst->shared->u.atomic.order) || - (H5T_ORDER_LE == src->shared->u.atomic.order && - H5T_ORDER_BE == dst->shared->u.atomic.order))) + if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset || + !((H5T_ORDER_BE == src->shared->u.atomic.order && + H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && + H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") - switch(src->shared->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: - if(src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || - src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || - src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || - src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || - src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || - src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || - src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || - src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported") } /* end if */ break; @@ -1556,13 +1623,13 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") buf_stride = buf_stride ? buf_stride : src->shared->size; - md = src->shared->size / 2; - for(i = 0; i < nelmts; i++, buf += buf_stride) - for(j = 0; j < md; j++) + md = src->shared->size / 2; + for (i = 0; i < nelmts; i++, buf += buf_stride) + for (j = 0; j < md; j++) H5_SWAP_BYTES(buf, j, src->shared->size - (j + 1)); break; @@ -1578,7 +1645,6 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_order() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_b_b * @@ -1592,39 +1658,35 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ 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) +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 */ - 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 dbuf[256]; /*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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ORDER_LE != src->shared->u.atomic.order && - H5T_ORDER_BE != src->shared->u.atomic.order) + if (H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst->shared->u.atomic.order && - H5T_ORDER_BE != dst->shared->u.atomic.order) + if (H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") cdata->need_bkg = H5T_BKG_NO; break; @@ -1634,7 +1696,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -1642,28 +1704,30 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if(src->shared->size == dst->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src->shared->size == dst->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if(src->shared->size >= dst->shared->size) { - double olap_d = HDceil((double)(dst->shared->size) / - (double)(src->shared->size - dst->shared->size)); + olap = nelmts; + } + else if (src->shared->size >= dst->shared->size) { + double olap_d = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src->shared->size) / - (double)(dst->shared->size - src->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; + } + else { + double olap_d = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ @@ -1673,13 +1737,13 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; } /* end if */ @@ -1689,12 +1753,12 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end else */ #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if(d == dbuf) + if (d == dbuf) HDassert((dp >= sp && dp < sp + src->shared->size) || - (sp >= dp && sp < dp + dst->shared->size)); + (sp >= dp && sp < dp + dst->shared->size)); else - HDassert((dp < sp && dp + dst->shared->size<=sp) || - (sp < dp && sp + src->shared->size<=dp)); + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); #endif /* @@ -1702,14 +1766,14 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if(H5T_ORDER_BE == src->shared->u.atomic.order) { + if (H5T_ORDER_BE == src->shared->u.atomic.order) { half_size = src->shared->size / 2; - for(i = 0; i < half_size; i++) { - uint8_t tmp = s[src->shared->size - (i + 1)]; + for (i = 0; i < half_size; i++) { + uint8_t tmp = s[src->shared->size - (i + 1)]; s[src->shared->size - (i + 1)] = s[i]; - s[i] = tmp; + s[i] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* Initiate these variables */ except_ret = H5T_CONV_UNHANDLED; @@ -1720,34 +1784,36 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * than the destination then invoke the overflow function or copy * as many bits as possible. Zero extra bits in the destination. */ - if(src->shared->u.atomic.prec > dst->shared->u.atomic.prec) { + if (src->shared->u.atomic.prec > dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); } /* end if */ - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy(d, dst->shared->u.atomic.offset, - s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); - } else if(except_ret == H5T_CONV_ABORT) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it*/ reverse = FALSE; - } else { - H5T__bit_copy(d, dst->shared->u.atomic.offset, - s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set(d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); } /* * Fill the destination padding areas. */ - switch(dst->shared->u.atomic.lsb_pad) { + switch (dst->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, FALSE); break; @@ -1763,7 +1829,7 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding") } /* end switch */ msb_pad_offset = dst->shared->u.atomic.offset + dst->shared->u.atomic.prec; - switch(dst->shared->u.atomic.msb_pad) { + switch (dst->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: H5T__bit_set(d, msb_pad_offset, 8 * dst->shared->size - msb_pad_offset, FALSE); break; @@ -1783,30 +1849,36 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Put the destination in the correct byte order. See note at * beginning of loop. */ - if(H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { + if (H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { half_size = dst->shared->size / 2; - for(i = 0; i < half_size; i++) { - uint8_t tmp = d[dst->shared->size - (i + 1)]; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst->shared->size - (i + 1)]; d[dst->shared->size - (i + 1)] = d[i]; - d[i] = tmp; + d[i] = tmp; } /* end for */ - } /* end if */ + } /* end if */ /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d == dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); - if(buf_stride) { - sp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - dp += direction * (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - } /* end if */ + if (buf_stride) { + sp += direction * + (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * + (ssize_t)buf_stride; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + } /* end if */ else { - sp += direction * (ssize_t)src->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - dp += direction * (ssize_t)dst->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ - } /* end else */ - } /* end for */ + sp += direction * + (ssize_t) + src->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + dp += direction * + (ssize_t) + dst->shared->size; /* Note that cast is checked with H5_CHECK_OVERFLOW, above */ + } /* end else */ + } /* end for */ break; @@ -1815,14 +1887,13 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_b_b() */ - /*------------------------------------------------------------------------- - * Function: H5T_conv_struct_free + * Function: H5T__conv_struct_free * * Purpose: Free the private data structure used by the compound * conversion functions. @@ -1835,18 +1906,17 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ static H5T_conv_struct_t * -H5T_conv_struct_free(H5T_conv_struct_t *priv) +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; - unsigned i; + int * src2dst = priv->src2dst; + hid_t * src_memb_id = priv->src_memb_id, *dst_memb_id = priv->dst_memb_id; + unsigned i; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - for(i = 0; i < priv->src_nmembs; i++) - if(src2dst[i] >= 0) { - int status; + for (i = 0; i < priv->src_nmembs; i++) + if (src2dst[i] >= 0) { + int H5_ATTR_NDEBUG_UNUSED status; status = H5I_dec_ref(src_memb_id[i]); HDassert(status >= 0); @@ -1860,11 +1930,10 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) H5MM_xfree(priv->memb_path); FUNC_LEAVE_NOAPI((H5T_conv_struct_t *)H5MM_xfree(priv)) -} /* end H5T_conv_struct_free() */ - +} /* end H5T__conv_struct_free() */ /*------------------------------------------------------------------------- - * Function: H5T_conv_struct_init + * Function: H5T__conv_struct_init * * Purpose: Initialize the `priv' field of `cdata' with conversion * information that is relatively constant. If `priv' is @@ -1910,38 +1979,38 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) *------------------------------------------------------------------------- */ static herr_t -H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) +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; - unsigned src_nmembs, dst_nmembs; - unsigned i, j; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); + int * src2dst = NULL; + unsigned src_nmembs, dst_nmembs; + unsigned i, j; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC src_nmembs = src->shared->u.compnd.nmembs; dst_nmembs = dst->shared->u.compnd.nmembs; - if(!priv) { + if (!priv) { /* * Allocate private data structure and arrays. */ - if(NULL == (priv = (H5T_conv_struct_t *)(cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t)))) || - NULL == (priv->src2dst = (int *)H5MM_malloc(src_nmembs * sizeof(int))) || - NULL == (priv->src_memb_id = (hid_t *)H5MM_malloc(src_nmembs * sizeof(hid_t))) || - NULL == (priv->dst_memb_id = (hid_t *)H5MM_malloc(dst_nmembs * sizeof(hid_t)))) + if (NULL == (priv = (H5T_conv_struct_t *)(cdata->priv = H5MM_calloc(sizeof(H5T_conv_struct_t)))) || + NULL == (priv->src2dst = (int *)H5MM_malloc(src_nmembs * sizeof(int))) || + NULL == (priv->src_memb_id = (hid_t *)H5MM_malloc(src_nmembs * sizeof(hid_t))) || + NULL == (priv->dst_memb_id = (hid_t *)H5MM_malloc(dst_nmembs * sizeof(hid_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - src2dst = priv->src2dst; + src2dst = priv->src2dst; priv->src_nmembs = src_nmembs; /* The flag of special optimization to indicate if source members and destination * members are a subset of each other. Initialize it to FALSE */ - priv->subset_info.subset = H5T_SUBSET_FALSE; + priv->subset_info.subset = H5T_SUBSET_FALSE; priv->subset_info.copy_size = 0; /* - * Insure that members are sorted. + * Ensure that members are sorted. */ H5T__sort_value(src, NULL); H5T__sort_value(dst, NULL); @@ -1953,30 +2022,30 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * source and destination member datatype so we can look up the * member datatype conversion functions later. */ - for(i = 0; i < src_nmembs; i++) { + for (i = 0; i < src_nmembs; i++) { src2dst[i] = -1; - for(j = 0; j < dst_nmembs; j++) { - if(!HDstrcmp(src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { + for (j = 0; j < dst_nmembs; j++) { + if (!HDstrcmp(src->shared->u.compnd.memb[i].name, dst->shared->u.compnd.memb[j].name)) { H5_CHECKED_ASSIGN(src2dst[i], int, j, unsigned); break; } /* end if */ - } /* end for */ - if(src2dst[i] >= 0) { - hid_t tid; - H5T_t *type; + } /* end for */ + if (src2dst[i] >= 0) { + hid_t tid; + H5T_t *type; type = H5T_copy(src->shared->u.compnd.memb[i].type, H5T_COPY_ALL); - tid = H5I_register(H5I_DATATYPE, type, FALSE); + tid = H5I_register(H5I_DATATYPE, type, FALSE); HDassert(tid >= 0); priv->src_memb_id[i] = tid; type = H5T_copy(dst->shared->u.compnd.memb[src2dst[i]].type, H5T_COPY_ALL); - tid = H5I_register(H5I_DATATYPE, type, FALSE); + tid = H5I_register(H5I_DATATYPE, type, FALSE); HDassert(tid >= 0); priv->dst_memb_id[src2dst[i]] = tid; } /* end if */ - } /* end for */ - } /* end if */ + } /* end for */ + } /* end if */ else { /* Restore sorted conditions for the datatypes */ /* (Required for the src2dst array to be valid) */ @@ -1990,69 +2059,78 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ src2dst = priv->src2dst; H5MM_xfree(priv->memb_path); - if(NULL == (priv->memb_path = (H5T_path_t **)H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) + if (NULL == + (priv->memb_path = (H5T_path_t **)H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0; i < src_nmembs; i++) { - if(src2dst[i] >= 0) { - H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, dst->shared->u.compnd.memb[src2dst[i]].type); + for (i = 0; i < src_nmembs; i++) { + if (src2dst[i] >= 0) { + H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, + dst->shared->u.compnd.memb[src2dst[i]].type); - if(NULL == (priv->memb_path[i] = tpath)) { - cdata->priv = H5T_conv_struct_free(priv); + if (NULL == (priv->memb_path[i] = tpath)) { + cdata->priv = H5T__conv_struct_free(priv); HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member datatype") } /* end if */ - } /* end if */ - } /* end for */ + } /* end if */ + } /* end for */ /* The compound conversion functions need a background buffer */ cdata->need_bkg = H5T_BKG_YES; - if(src_nmembs < dst_nmembs) { + if (src_nmembs < dst_nmembs) { priv->subset_info.subset = H5T_SUBSET_SRC; - for(i = 0; i < src_nmembs; i++) { + for (i = 0; i < src_nmembs; i++) { /* If any of source members doesn't have counterpart in the same - * order or there's conversion between members, don't do the - * optimization. - */ - if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + * order or there's conversion between members, don't do the + * optimization. + */ + if (src2dst[i] != (int)i || + (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || + (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } /* end if */ - } /* end for */ + } /* end for */ /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of src. - */ - if(priv->subset_info.subset == H5T_SUBSET_SRC) - priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs - 1].offset - + src->shared->u.compnd.memb[src_nmembs - 1].size; - } else if(dst_nmembs < src_nmembs) { + * may be smaller than either src or dst if there is extra space at + * the end of src. + */ + if (priv->subset_info.subset == H5T_SUBSET_SRC) + priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs - 1].offset + + src->shared->u.compnd.memb[src_nmembs - 1].size; + } + else if (dst_nmembs < src_nmembs) { priv->subset_info.subset = H5T_SUBSET_DST; - for(i = 0; i < dst_nmembs; i++) { + for (i = 0; i < dst_nmembs; i++) { /* If any of source members doesn't have counterpart in the same order or - * there's conversion between members, don't do the optimization. */ - if(src2dst[i] != (int)i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + * there's conversion between members, don't do the optimization. */ + if (src2dst[i] != (int)i || + (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || + (priv->memb_path[i])->is_noop == FALSE) { priv->subset_info.subset = H5T_SUBSET_FALSE; break; } } /* end for */ /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of dst. - */ - if(priv->subset_info.subset == H5T_SUBSET_DST) - priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs-1].offset - + dst->shared->u.compnd.memb[dst_nmembs-1].size; - } else /* If the numbers of source and dest members are equal and no conversion is needed, - * the case should have been handled as noop earlier in H5Dio.c. */ - {;} + * may be smaller than either src or dst if there is extra space at + * the end of dst. + */ + if (priv->subset_info.subset == H5T_SUBSET_DST) + priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs - 1].offset + + dst->shared->u.compnd.memb[dst_nmembs - 1].size; + } + else /* If the numbers of source and dest members are equal and no conversion is needed, + * the case should have been handled as noop earlier in H5Dio.c. */ + { + ; + } cdata->recalc = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_conv_struct_init() */ - +} /* end H5T__conv_struct_init() */ /*------------------------------------------------------------------------- * Function: H5T__conv_struct_subset @@ -2081,7 +2159,7 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) H5T_subset_info_t * H5T__conv_struct_subset(const H5T_cdata_t *cdata) { - H5T_conv_struct_t *priv = NULL; + H5T_conv_struct_t *priv = NULL; FUNC_ENTER_PACKAGE_NOERR @@ -2090,10 +2168,9 @@ H5T__conv_struct_subset(const H5T_cdata_t *cdata) priv = (H5T_conv_struct_t *)(cdata->priv); - FUNC_LEAVE_NOAPI((H5T_subset_info_t *) &priv->subset_info) + FUNC_LEAVE_NOAPI((H5T_subset_info_t *)&priv->subset_info) } /* end H5T__conv_struct_subset() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_struct * @@ -2121,29 +2198,29 @@ H5T__conv_struct_subset(const H5T_cdata_t *cdata) *------------------------------------------------------------------------- */ 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) +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. */ - size_t offset; /*byte offset wrt struct */ - ssize_t src_delta; /*source stride */ - ssize_t bkg_delta; /*background stride */ - size_t elmtno; - unsigned u; /*counters */ - int i; /*counters */ - H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + size_t elmtno; + unsigned u; /*counters */ + int i; /*counters */ + H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2153,12 +2230,12 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_COMPOUND != src->shared->type) + if (H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_COMPOUND != dst->shared->type) + if (H5T_COMPOUND != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_conv_struct_init(src, dst, cdata) < 0) + if (H5T__conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") break; @@ -2166,19 +2243,19 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Free the private conversion data. */ - cdata->priv = H5T_conv_struct_free(priv); + cdata->priv = H5T__conv_struct_free(priv); break; case H5T_CONV_CONV: /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") HDassert(priv); HDassert(bkg && cdata->need_bkg); - if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) + if (cdata->recalc && H5T__conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") /* @@ -2191,15 +2268,15 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Direction of conversion and striding through background. */ - if(buf_stride) { + if (buf_stride) { H5_CHECKED_ASSIGN(src_delta, ssize_t, buf_stride, size_t); - if(!bkg_stride) { + if (!bkg_stride) { H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); } /* end if */ else H5_CHECKED_ASSIGN(bkg_delta, ssize_t, bkg_stride, size_t); } /* end if */ - else if(dst->shared->size <= src->shared->size) { + else if (dst->shared->size <= src->shared->size) { H5_CHECKED_ASSIGN(src_delta, ssize_t, src->shared->size, size_t); H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); } /* end else-if */ @@ -2213,7 +2290,7 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end else */ /* Conversion loop... */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * For each source member which will be present in the * destination, convert the member to the destination type unless @@ -2222,27 +2299,27 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * data point as small as possible with all the free space on the * right side. */ - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size <= src_memb->size) { - if(H5T_convert(priv->memb_path[u], priv->src_memb_id[u], - priv->dst_memb_id[src2dst[u]], - (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ - xbuf + src_memb->offset, xbkg + dst_memb->offset) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + if (dst_memb->size <= src_memb->size) { + if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], + priv->dst_memb_id[src2dst[u]], (size_t)1, (size_t)0, + (size_t)0, /*no striding (packed array)*/ + xbuf + src_memb->offset, xbkg + dst_memb->offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") HDmemmove(xbuf + offset, xbuf + src_memb->offset, dst_memb->size); offset += dst_memb->size; } /* end if */ else { - HDmemmove (xbuf+offset, xbuf+src_memb->offset, - src_memb->size); + HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); offset += src_memb->size; } /* end else */ - } /* end for */ + } /* end for */ /* * For each source member which will be present in the @@ -2252,19 +2329,20 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * background buffer. */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; - if(H5T_convert(priv->memb_path[i], - priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], - (size_t)1, (size_t)0, (size_t)0, /*no striding (packed array)*/ - xbuf + offset, xbkg + dst_memb->offset) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") + if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], + priv->dst_memb_id[src2dst[i]], (size_t)1, (size_t)0, + (size_t)0, /*no striding (packed array)*/ + xbuf + offset, xbkg + dst_memb->offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") } /* end if */ else offset -= dst_memb->size; @@ -2280,14 +2358,14 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end for */ /* If the bkg_delta was set to -(dst->shared->size), make it positive now */ - if(buf_stride == 0 && dst->shared->size > src->shared->size) + if (buf_stride == 0 && dst->shared->size > src->shared->size) H5_CHECKED_ASSIGN(bkg_delta, ssize_t, dst->shared->size, size_t); /* * Copy the background buffer back into the in-place conversion * buffer. */ - for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_delta; @@ -2303,7 +2381,6 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_struct() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_struct_opt * @@ -2348,30 +2425,30 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ 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) +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. */ - size_t offset; /*byte offset wrt struct */ - size_t elmtno; /*element counter */ - size_t copy_size; /*size of element for copying */ - H5T_conv_struct_t *priv = NULL; /*private data */ - hbool_t no_stride = FALSE; /*flag to indicate no stride */ - unsigned u; /*counters */ - int i; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + H5T_conv_struct_t *priv = NULL; /*private data */ + hbool_t no_stride = FALSE; /*flag to indicate no stride */ + unsigned u; /*counters */ + int i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -2379,17 +2456,17 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_COMPOUND != src->shared->type) + if (H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") - if(H5T_COMPOUND != dst->shared->type) + if (H5T_COMPOUND != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") /* Initialize data which is relatively constant */ - if(H5T_conv_struct_init(src, dst, cdata) < 0) + if (H5T__conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") - priv = (H5T_conv_struct_t *)(cdata->priv); + priv = (H5T_conv_struct_t *)(cdata->priv); src2dst = priv->src2dst; /* @@ -2402,48 +2479,49 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * of loops as in the actual conversion except it checks that there * is room for each conversion instead of actually doing anything. */ - if(dst->shared->size > src->shared->size) { - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + if (dst->shared->size > src->shared->size) { + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size > src_memb->size) + if (dst_memb->size > src_memb->size) offset += src_memb->size; } /* end for */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; - if(dst_memb->size > src->shared->size-offset) { - cdata->priv = H5T_conv_struct_free(priv); - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion is unsupported by this function") + if (dst_memb->size > src->shared->size - offset) { + cdata->priv = H5T__conv_struct_free(priv); + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "conversion is unsupported by this function") } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ + } /* end if */ + } /* end for */ + } /* end if */ break; case H5T_CONV_FREE: /* * Free the private conversion data. */ - cdata->priv = H5T_conv_struct_free((H5T_conv_struct_t *)(cdata->priv)); + cdata->priv = H5T__conv_struct_free((H5T_conv_struct_t *)(cdata->priv)); break; case H5T_CONV_CONV: /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Update cached data if necessary */ - if(cdata->recalc && H5T_conv_struct_init(src, dst, cdata) < 0) + if (cdata->recalc && H5T__conv_struct_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data") priv = (H5T_conv_struct_t *)(cdata->priv); HDassert(priv); @@ -2466,29 +2544,29 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * background data into the BKG buffer at multiples of BKG_STRIDE; * otherwise assume BKG buffer is the packed destination datatype. */ - if(!buf_stride || !bkg_stride) + if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size; - if(!buf_stride) { - no_stride = TRUE; + if (!buf_stride) { + no_stride = TRUE; buf_stride = src->shared->size; } /* end if */ - if(priv->subset_info.subset == H5T_SUBSET_SRC || priv->subset_info.subset == H5T_SUBSET_DST) { + if (priv->subset_info.subset == H5T_SUBSET_SRC || priv->subset_info.subset == H5T_SUBSET_DST) { /* If the optimization flag is set to indicate source members are a subset and * in the top of the destination, simply copy the source members to background buffer. */ - xbuf = buf; - xbkg = bkg; + xbuf = buf; + xbkg = bkg; copy_size = priv->subset_info.copy_size; - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, copy_size); /* Update pointers */ xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ + } /* end if */ else { /* * For each member where the destination is not larger than the @@ -2497,33 +2575,34 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * destination in the bkg buffer. Otherwise move the element as far * left as possible in the buffer. */ - for(u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { - if(src2dst[u] < 0) + for (u = 0, offset = 0; u < src->shared->u.compnd.nmembs; u++) { + if (src2dst[u] < 0) continue; /*subsetting*/ src_memb = src->shared->u.compnd.memb + u; dst_memb = dst->shared->u.compnd.memb + src2dst[u]; - if(dst_memb->size <= src_memb->size) { + if (dst_memb->size <= src_memb->size) { xbuf = buf + src_memb->offset; xbkg = bkg + dst_memb->offset; - if(H5T_convert(priv->memb_path[u], priv->src_memb_id[u], - priv->dst_memb_id[src2dst[u]], nelmts, - buf_stride, bkg_stride, xbuf, xbkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") - for(elmtno = 0; elmtno < nelmts; elmtno++) { + if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], + priv->dst_memb_id[src2dst[u]], nelmts, buf_stride, bkg_stride, xbuf, + xbkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ + } /* end if */ else { - for(xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); xbuf += buf_stride; } /* end for */ offset += src_memb->size; } /* end else */ - } /* end else */ + } /* end else */ /* * Work from right to left, converting those members that weren't @@ -2532,34 +2611,35 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * bkg buffer. */ H5_CHECK_OVERFLOW(src->shared->u.compnd.nmembs, size_t, int); - for(i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { - if(src2dst[i] < 0) + for (i = (int)src->shared->u.compnd.nmembs - 1; i >= 0; --i) { + if (src2dst[i] < 0) continue; src_memb = src->shared->u.compnd.memb + i; dst_memb = dst->shared->u.compnd.memb + src2dst[i]; - if(dst_memb->size > src_memb->size) { + if (dst_memb->size > src_memb->size) { offset -= src_memb->size; xbuf = buf + offset; xbkg = bkg + dst_memb->offset; - if(H5T_convert(priv->memb_path[i], priv->src_memb_id[i], - priv->dst_memb_id[src2dst[i]], nelmts, - buf_stride, bkg_stride, xbuf, xbkg) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") - for(elmtno = 0; elmtno < nelmts; elmtno++) { + if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], + priv->dst_memb_id[src2dst[i]], nelmts, buf_stride, bkg_stride, xbuf, + xbkg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound datatype member") + for (elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ - } /* end if */ - } /* end for */ - } /* end else */ + } /* end if */ + } /* end for */ + } /* end else */ - if(no_stride) + if (no_stride) buf_stride = dst->shared->size; /* Move background buffer into result buffer */ - for(xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { + for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { HDmemmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride; xbkg += bkg_stride; @@ -2575,15 +2655,14 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_struct_opt() */ - /*------------------------------------------------------------------------- - * Function: H5T_conv_enum_init + * Function: H5T__conv_enum_init * * Purpose: Initialize information for H5T__conv_enum(). * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Monday, January 4, 1999 @@ -2591,23 +2670,23 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ static herr_t -H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) +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 */ - unsigned length; /*nelmts in map array */ - unsigned i, j; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ + unsigned length; /*nelmts in map array */ + unsigned i, j; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC cdata->need_bkg = H5T_BKG_NO; - if(NULL == (priv = (H5T_enum_struct_t *)(cdata->priv = H5MM_calloc(sizeof(*priv))))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(0 == src->shared->u.enumer.nmembs) - HGOTO_DONE(SUCCEED); + if (NULL == (priv = (H5T_enum_struct_t *)(cdata->priv = H5MM_calloc(sizeof(*priv))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if (0 == src->shared->u.enumer.nmembs) + HGOTO_DONE(SUCCEED); /* * Check that the source symbol names are a subset of the destination @@ -2616,17 +2695,16 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ H5T__sort_name(src, NULL); H5T__sort_name(dst, NULL); - if(NULL == (priv->src2dst = (int *)H5MM_malloc(src->shared->u.enumer.nmembs * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0, j = 0; - i < src->shared->u.enumer.nmembs && j < dst->shared->u.enumer.nmembs; - i++, j++) { - while(j < dst->shared->u.enumer.nmembs && - HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) + if (NULL == (priv->src2dst = (int *)H5MM_malloc(src->shared->u.enumer.nmembs * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for (i = 0, j = 0; i < src->shared->u.enumer.nmembs && j < dst->shared->u.enumer.nmembs; i++, j++) { + while (j < dst->shared->u.enumer.nmembs && + HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j]) != 0) j++; - if(j >= dst->shared->u.enumer.nmembs) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type") - priv->src2dst[i] = (int)j; + if (j >= dst->shared->u.enumer.nmembs) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "source type is not a subset of destination type") + priv->src2dst[i] = (int)j; } /* end for */ /* @@ -2655,69 +2733,71 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * Because this is the optimized code, we won't fix it. It should still work in some * situations. SLU - 2011/5/24) */ - if(1 == src->shared->size || sizeof(short) == src->shared->size || sizeof(int) == src->shared->size) { - for(i = 0; i < src->shared->u.enumer.nmembs; i++) { - if(1 == src->shared->size) - n = *((signed char *)(src->shared->u.enumer.value + i)); - else if (sizeof(short) == src->shared->size) - n = *((short *)(src->shared->u.enumer.value + i * src->shared->size)); - else - n = *((int *)(src->shared->u.enumer.value + i * src->shared->size)); - if(0 == i) { - domain[0] = domain[1] = n; - } else { - domain[0] = MIN(domain[0], n); - domain[1] = MAX(domain[1], n); - } - } /* end for */ + if (1 == src->shared->size || sizeof(short) == src->shared->size || sizeof(int) == src->shared->size) { + for (i = 0; i < src->shared->u.enumer.nmembs; i++) { + if (1 == src->shared->size) + n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); + else if (sizeof(short) == src->shared->size) + n = *((short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + else + n = *((int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + if (0 == i) { + domain[0] = domain[1] = n; + } + else { + domain[0] = MIN(domain[0], n); + domain[1] = MAX(domain[1], n); + } + } /* end for */ 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)) { - priv->base = domain[0]; - priv->length = length; - if(NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - for(i = 0; i < length; i++) + length = (unsigned)(domain[1] - domain[0]) + 1; + if (src->shared->u.enumer.nmembs < 2 || + (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)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for (i = 0; i < length; i++) map[i] = -1; /*entry unused*/ - for(i = 0; i < src->shared->u.enumer.nmembs; i++) { - if(1 == src->shared->size) - n = *((signed char *)(src->shared->u.enumer.value + i)); - else if(sizeof(short) == src->shared->size) - n = *((short *)(src->shared->u.enumer.value + i * src->shared->size)); - else - n = *((int *)(src->shared->u.enumer.value + i * src->shared->size)); - n -= priv->base; - HDassert(n >= 0 && (unsigned)n < priv->length); - HDassert(map[n] < 0); - map[n] = priv->src2dst[i]; - } /* end for */ + for (i = 0; i < src->shared->u.enumer.nmembs; i++) { + if (1 == src->shared->size) + n = *((signed char *)((uint8_t *)src->shared->u.enumer.value + i)); + else if (sizeof(short) == src->shared->size) + n = *(( + short *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + else + n = *( + (int *)((void *)((uint8_t *)src->shared->u.enumer.value + (i * src->shared->size)))); + n -= priv->base; + HDassert(n >= 0 && (unsigned)n < priv->length); + HDassert(map[n] < 0); + map[n] = priv->src2dst[i]; + } /* end for */ - /* - * Replace original src2dst array with our new one. The original - * was indexed by source member number while the new one is - * indexed by source values. - */ - H5MM_xfree(priv->src2dst); - priv->src2dst = map; - HGOTO_DONE(SUCCEED); - } + /* + * Replace original src2dst array with our new one. The original + * was indexed by source member number while the new one is + * indexed by source values. + */ + H5MM_xfree(priv->src2dst); + priv->src2dst = map; + HGOTO_DONE(SUCCEED); + } } /* Sort source type by value and adjust src2dst[] appropriately */ H5T__sort_value(src, priv->src2dst); done: - if (ret_value<0 && priv) { - H5MM_xfree(priv->src2dst); - H5MM_xfree(priv); - cdata->priv = NULL; + if (ret_value < 0 && priv) { + H5MM_xfree(priv->src2dst); + H5MM_xfree(priv); + cdata->priv = NULL; } FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__conv_enum * @@ -2725,31 +2805,30 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * * Return: Success: Non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, January 4, 1999 *------------------------------------------------------------------------- */ 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) +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 */ - 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); - H5T_conv_cb_t cb_struct; /*conversion callback structure */ - H5T_conv_ret_t except_ret; /*return of callback function */ - size_t i; /*counters */ - herr_t ret_value = SUCCEED; /* Return value */ + 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); + H5T_conv_cb_t cb_struct; /*conversion callback structure */ + H5T_conv_ret_t except_ret; /*return of callback function */ + size_t i; /*counters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion @@ -2757,14 +2836,14 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_ENUM != dst->shared->type) + if (H5T_ENUM != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_conv_enum_init(src, dst, cdata) < 0) + if (H5T__conv_enum_init(src, dst, cdata) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data") break; @@ -2772,8 +2851,8 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, #ifdef H5T_DEBUG if (H5DEBUG(T)) { HDfprintf(H5DEBUG(T), " Using %s mapping function%s\n", - priv->length?"O(1)":"O(log N)", - priv->length?"":", where N is the number of enum members"); + priv->length ? "O(1)" : "O(log N)", + priv->length ? "" : ", where N is the number of enum members"); } #endif if (priv) { @@ -2784,115 +2863,122 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") - if(H5T_ENUM != dst->shared->type) + if (H5T_ENUM != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") /* priv->src2dst map was computed for certain sort keys. Make sure those same - * sort keys are used here during conversion. See H5T_conv_enum_init(). But + * sort keys are used here during conversion. See H5T__conv_enum_init(). But * we actually don't care about the source type's order when doing the O(1) * conversion algorithm, which is turned on by non-zero priv->length */ H5T__sort_name(dst, NULL); - if(!priv->length) + if (!priv->length) H5T__sort_value(src, NULL); /* * Direction of conversion. */ - if(buf_stride) { + if (buf_stride) { H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); src_delta = dst_delta = (ssize_t)buf_stride; s = d = buf; - } else if(dst->shared->size <= src->shared->size) { + } + else if (dst->shared->size <= src->shared->size) { H5_CHECKED_ASSIGN(src_delta, ssize_t, src->shared->size, size_t); H5_CHECKED_ASSIGN(dst_delta, ssize_t, dst->shared->size, size_t); s = d = buf; - } else { + } + else { H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); src_delta = -(ssize_t)src->shared->size; dst_delta = -(ssize_t)dst->shared->size; - s = buf + (nelmts - 1) * src->shared->size; - d = buf + (nelmts - 1) * dst->shared->size; + s = buf + (nelmts - 1) * src->shared->size; + d = buf + (nelmts - 1) * dst->shared->size; } /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") - for(i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { - if(priv->length) { + for (i = 0; i < nelmts; i++, s += src_delta, d += dst_delta) { + if (priv->length) { /* Use O(1) lookup */ /* (The casting won't work when the byte orders are different. i.g. if the source value * is big-endian 0x0000000f, the direct casting "n = *((int*)s);" will make it a big * number 0x0f000000 on little-endian machine. But we won't fix it because it's an - * optimization code. Please also see the comment in the H5T_conv_enum_init() function. + * optimization code. Please also see the comment in the H5T__conv_enum_init() function. * SLU - 2011/5/24) */ - if(1 == src->shared->size) - n = *((signed char*)s); - else if(sizeof(short) == src->shared->size) - n = *((short*)s); + if (1 == src->shared->size) + n = *((signed char *)s); + else if (sizeof(short) == src->shared->size) + n = *((short *)((void *)s)); else - n = *((int*)s); + n = *((int *)((void *)s)); n -= priv->base; - if(n < 0 || (unsigned)n >= priv->length || priv->src2dst[n] < 0) { + if (n < 0 || (unsigned)n >= priv->length || priv->src2dst[n] < 0) { /*overflow*/ except_ret = H5T_CONV_UNHANDLED; /*If user's exception handler is present, use it*/ - if(cb_struct.func) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - s, d, cb_struct.user_data); + if (cb_struct.func) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, s, d, + cb_struct.user_data); - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else H5MM_memcpy(d, - dst->shared->u.enumer.value + (unsigned)priv->src2dst[n] * dst->shared->size, - dst->shared->size); + (uint8_t *)dst->shared->u.enumer.value + + ((unsigned)priv->src2dst[n] * dst->shared->size), + dst->shared->size); } /* end if */ else { /* Use O(log N) lookup */ unsigned lt = 0; unsigned rt = src->shared->u.enumer.nmembs; unsigned md = 0; - int cmp; + int cmp; - while(lt < rt) { - md = (lt + rt) / 2; - cmp = HDmemcmp(s, src->shared->u.enumer.value + md * src->shared->size, + while (lt < rt) { + md = (lt + rt) / 2; + cmp = HDmemcmp(s, (uint8_t *)src->shared->u.enumer.value + (md * src->shared->size), src->shared->size); - if(cmp < 0) + if (cmp < 0) rt = md; - else if(cmp > 0) + else if (cmp > 0) lt = md + 1; else break; } /* end while */ - if(lt >= rt) { + if (lt >= rt) { except_ret = H5T_CONV_UNHANDLED; /*If user's exception handler is present, use it*/ - if(cb_struct.func) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src, d, cb_struct.user_data); + if (cb_struct.func) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src, d, + cb_struct.user_data); - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) HDmemset(d, 0xff, dst->shared->size); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } /* end if */ else { HDassert(priv->src2dst[md] >= 0); H5MM_memcpy(d, - dst->shared->u.enumer.value + (unsigned)priv->src2dst[md] * dst->shared->size, - dst->shared->size); + (uint8_t *)dst->shared->u.enumer.value + + ((unsigned)priv->src2dst[md] * dst->shared->size), + dst->shared->size); } /* end else */ - } /* end else */ + } /* end else */ } break; @@ -2906,7 +2992,6 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_enum() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_enum_numeric * @@ -2917,7 +3002,7 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * * Return: Success: Non-negative * - * Failure: negative + * Failure: negative * * Programmer: Raymond Lu * 12 October 2012 @@ -2925,28 +3010,28 @@ H5T__conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ herr_t H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t H5_ATTR_UNUSED buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, - void H5_ATTR_UNUSED *bkg) + 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 */ - 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 */ + 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 */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * Determine if this conversion function applies to the conversion * path SRC_ID->DST_ID. If not, return failure. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ENUM != src->shared->type) + if (H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "source type is not a H5T_ENUM datatype") - if(H5T_INTEGER != dst->shared->type && H5T_FLOAT != dst->shared->type) + if (H5T_INTEGER != dst->shared->type && H5T_FLOAT != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "destination is not an integer type") cdata->need_bkg = H5T_BKG_NO; @@ -2956,19 +3041,23 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne break; case H5T_CONV_CONV: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src_parent = src->shared->parent; - if(NULL == (tpath = H5T_path_find(src_parent, dst))) { - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") - } else if(!H5T_path_noop(tpath)) { - if((src_parent_id = H5I_register(H5I_DATATYPE, H5T_copy(src_parent, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (NULL == (tpath = H5T_path_find(src_parent, dst))) { + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatype") + } + else if (!H5T_path_noop(tpath)) { + if ((src_parent_id = H5I_register(H5I_DATATYPE, H5T_copy(src_parent, H5T_COPY_ALL), FALSE)) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") /* Convert the data */ - if(H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg) < 0) + if (H5T_convert(tpath, src_parent_id, dst_id, nelmts, buf_stride, bkg_stride, _buf, bkg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } break; @@ -2980,13 +3069,12 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne done: /* Release the temporary datatype IDs used */ - if(src_parent_id >= 0) + if (src_parent_id >= 0) H5I_dec_ref(src_parent_id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_enum_numeric() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_vlen * @@ -3012,37 +3100,36 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne *------------------------------------------------------------------------- */ herr_t -H5T__conv_vlen(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_vlen_alloc_info_t vl_alloc_info;/* VL allocation info */ - 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 */ - hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ - H5T_t *src = NULL; /*source datatype */ - H5T_t *dst = NULL; /*destination datatype */ - H5HG_t bg_hobjid, parent_hobjid; - 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 bg_seq_len = 0; - size_t src_base_size, dst_base_size;/*source & destination base size*/ - 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 */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ +H5T__conv_vlen(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_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ + 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 */ + 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 */ + size_t conv_buf_size = 0; /*size of conversion buffer in bytes */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: /* * First, determine if this conversion function applies to the @@ -3051,17 +3138,19 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_VLEN != src->shared->type) + if (H5T_VLEN != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") - if(H5T_VLEN != dst->shared->type) + if (H5T_VLEN != dst->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") - if(H5T_VLEN_STRING == src->shared->u.vlen.type && H5T_VLEN_STRING == dst->shared->u.vlen.type) { - if((H5T_CSET_ASCII == src->shared->u.vlen.cset && H5T_CSET_UTF8 == dst->shared->u.vlen.cset) - || (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF") - } + if (H5T_VLEN_STRING == src->shared->u.vlen.type && H5T_VLEN_STRING == dst->shared->u.vlen.type) { + if ((H5T_CSET_ASCII == src->shared->u.vlen.cset && + H5T_CSET_UTF8 == dst->shared->u.vlen.cset) || + (H5T_CSET_ASCII == dst->shared->u.vlen.cset && H5T_CSET_UTF8 == src->shared->u.vlen.cset)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "The library doesn't convert between strings of ASCII and UTF") + } /* end if */ /* Variable-length types don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; @@ -3076,11 +3165,11 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize source & destination strides */ - if(buf_stride) { + if (buf_stride) { HDassert(buf_stride >= src->shared->size); HDassert(buf_stride >= dst->shared->size); H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); @@ -3092,8 +3181,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s_stride = (ssize_t)src->shared->size; d_stride = (ssize_t)dst->shared->size; } /* end else */ - if(bkg) { - if(bkg_stride) + if (bkg) { + if (bkg_stride) b_stride = (ssize_t)bkg_stride; else b_stride = d_stride; @@ -3106,43 +3195,63 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_base_size = H5T_get_size(dst->shared->parent); /* Set up conversion path for base elements */ - if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes") - else if(!H5T_path_noop(tpath)) { - if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), FALSE)) < 0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatypes") + else if (!H5T_path_noop(tpath)) { + H5T_t *tsrc_cpy = NULL, *tdst_cpy = NULL; + + if (NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy src type for conversion") + /* References need to know about the src file */ + if (tsrc_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tsrc_cpy, src->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if (NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy dst type for conversion") + /* References need to know about the dst file */ + if (tdst_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tdst_cpy, dst->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if (((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) || + ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") } /* end else-if */ else noop_conv = TRUE; /* Check if we need a temporary buffer for this conversion */ - if((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, "internal error when detecting variable-length class") - if(tpath->cdata.need_bkg || parent_is_vlen) { + if ((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, + "internal error when detecting variable-length class") + if (tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ tmp_buf_size = MAX(src_base_size, dst_base_size); - if(NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq,tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") + if (NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for type conversion") } /* end if */ /* Get the allocation info */ - if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) + if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Set flags to indicate we are writing to or reading from the file */ - if(dst->shared->u.vlen.f != NULL) + if (dst->shared->u.vlen.file != NULL) write_to_file = TRUE; /* Set the flag for nested VL case */ - if(write_to_file && parent_is_vlen && bkg != NULL) + if (write_to_file && parent_is_vlen && bkg != NULL) nested = TRUE; /* The outer loop of the type conversion macro, controlling which */ /* direction the buffer is walked */ - while(nelmts > 0) { + while (nelmts > 0) { /* Check if we need to go backwards through the buffer */ - if(d_stride > s_stride) { + if (d_stride > s_stride) { /* Sanity check */ HDassert(s_stride > 0); HDassert(d_stride > 0); @@ -3151,14 +3260,15 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Compute the number of "safe" destination elements at */ /* the end of the buffer (Those which don't overlap with */ /* any source elements at the beginning of the buffer) */ - safe = nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); + safe = + nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); /* If we're down to the last few elements, just wrap up */ /* with a "real" reverse copy */ - if(safe < 2) { - s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; - d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; - b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; + if (safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; s_stride = -s_stride; d_stride = -d_stride; b_stride = -b_stride; @@ -3170,38 +3280,41 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; } /* end else */ - } /* end if */ + } /* end if */ else { /* Single forward pass over all data */ s = d = (uint8_t *)buf; - b = (uint8_t *)bkg; - safe = nelmts; + b = (uint8_t *)bkg; + safe = nelmts; } /* end else */ - for(elmtno = 0; elmtno < safe; elmtno++) { + for (elmtno = 0; elmtno < safe; elmtno++) { + hbool_t is_nil; /* Whether sequence is "nil" */ + /* Check for "nil" source sequence */ - if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f, s)) { + if ((*(src->shared->u.vlen.cls->isnull))(src->shared->u.vlen.file, s, &is_nil) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if VL data is 'nil'") + else if (is_nil) { /* Write "nil" sequence to destination location */ - if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f, d, b) < 0) + if ((*(dst->shared->u.vlen.cls->setnull))(dst->shared->u.vlen.file, d, b) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") - } /* end if */ + } /* end else-if */ else { - ssize_t sseq_len; /* (signed) The number of elements in the current sequence*/ - size_t seq_len; /* The number of elements in the current sequence*/ + size_t seq_len; /* The number of elements in the current sequence */ /* Get length of element sequences */ - if((sseq_len = (*(src->shared->u.vlen.getlen))(s)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length") - seq_len = (size_t)sseq_len; + if ((*(src->shared->u.vlen.cls->getlen))(src->shared->u.vlen.file, s, &seq_len) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") - /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ - if(write_to_file && noop_conv) { + /* If we are reading from memory and there is no conversion, just get the pointer to + * sequence */ + if (write_to_file && noop_conv) { /* Get direct pointer to sequence */ - if(NULL == (conv_buf = (*(src->shared->u.vlen.getptr))(s))) + if (NULL == (conv_buf = (*(src->shared->u.vlen.cls->getptr))(s))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer") } /* end if */ else { - size_t src_size, dst_size; /*source & destination total size in bytes*/ + size_t src_size, dst_size; /*source & destination total size in bytes*/ src_size = seq_len * src_base_size; dst_size = seq_len * dst_base_size; @@ -3209,89 +3322,106 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Check if conversion buffer is large enough, resize if * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. */ - if(!seq_len && !conv_buf) { - conv_buf_size = ((1 / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE; - if(NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") - } - else if(conv_buf_size < MAX(src_size, dst_size)) { + if (!seq_len && !conv_buf) { + conv_buf_size = H5T_VLEN_MIN_CONF_BUF_SIZE; + if (NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + } /* end if */ + else if (conv_buf_size < MAX(src_size, dst_size)) { /* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */ - conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE; - if(NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * + H5T_VLEN_MIN_CONF_BUF_SIZE; + if (NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(conv_buf, 0, conv_buf_size); - } /* end if */ + } /* end else-if */ /* Read in VL sequence */ - if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f, s, conv_buf, src_size) < 0) + if ((*(src->shared->u.vlen.cls->read))(src->shared->u.vlen.file, s, conv_buf, + src_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end else */ - if(!noop_conv) { + if (!noop_conv) { /* Check if temporary buffer is large enough, resize if necessary */ /* (Chain off the conversion buffer size) */ - if(tmp_buf && tmp_buf_size < conv_buf_size) { + if (tmp_buf && tmp_buf_size < conv_buf_size) { /* Set up initial background buffer */ tmp_buf_size = conv_buf_size; - if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(tmp_buf, 0, tmp_buf_size); } /* end if */ /* If we are writing and there is a nested VL type, read * the sequence into the background buffer */ - if(nested) { - const uint8_t *tmp = b; - - UINT32DECODE(tmp, bg_seq_len); - if(bg_seq_len > 0) { - if(tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { + if (nested) { + /* Sanity check */ + HDassert(write_to_file); + + /* Get length of background element sequence */ + if ((*(dst->shared->u.vlen.cls->getlen))(dst->shared->u.vlen.file, b, + &bg_seq_len) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") + + /* Read sequence if length > 0 */ + if (bg_seq_len > 0) { + if (tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size)); - if(NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == + (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") HDmemset(tmp_buf, 0, tmp_buf_size); } /* end if */ - H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(bg_hobjid.addr)); - UINT32DECODE(tmp, bg_hobjid.idx); - if(NULL == H5HG_read(dst->shared->u.vlen.f, &bg_hobjid, tmp_buf, NULL)) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer") + + /* Read in background VL sequence */ + if ((*(dst->shared->u.vlen.cls->read))(dst->shared->u.vlen.file, b, + tmp_buf, + bg_seq_len * dst_base_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end if */ /* If the sequence gets shorter, pad out the original sequence with zeros */ - if(bg_seq_len < seq_len) - HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, (seq_len - bg_seq_len) * dst_base_size); + if (bg_seq_len < seq_len) + HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, + (seq_len - bg_seq_len) * dst_base_size); } /* end if */ /* Convert VL sequence */ - if(H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, tmp_buf) < 0) + if (H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, + tmp_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ /* Write sequence to destination location */ - if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f, &vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0) + if ((*(dst->shared->u.vlen.cls->write))(dst->shared->u.vlen.file, &vl_alloc_info, d, + conv_buf, b, seq_len, dst_base_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") - if(!noop_conv) { - /* 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) { - size_t parent_seq_len; - const uint8_t *tmp; - size_t u; - - /* TMP_P is reset each time in the loop because DST_BASE_SIZE may include some data in addition to VL info. - SLU */ - for(u = seq_len; u < bg_seq_len; u++) { - tmp = (uint8_t *)tmp_buf + u * dst_base_size; - UINT32DECODE(tmp, parent_seq_len); - if(parent_seq_len > 0) { - H5F_addr_decode(dst->shared->u.vlen.f, &tmp, &(parent_hobjid.addr)); - UINT32DECODE(tmp, parent_hobjid.idx); - if(H5HG_remove(dst->shared->u.vlen.f, &parent_hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") - } /* end if */ + if (!noop_conv) { + /* 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; + + /* Sanity check */ + HDassert(write_to_file); + + tmp = (uint8_t *)tmp_buf + seq_len * dst_base_size; + for (u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) { + /* Delete sequence in destination location */ + if ((*(dst->shared->u.vlen.cls->del))(dst->shared->u.vlen.file, tmp) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, + "unable to remove heap object") } /* end for */ - } /* end if */ - } /* end if */ - } /* end else */ + } /* end if */ + } /* end if */ + } /* end else */ /* Advance pointers */ s += s_stride; @@ -3304,31 +3434,30 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end while */ /* Release the temporary datatype IDs used */ - if(tsrc_id >= 0) + if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); - if(tdst_id >= 0) + if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; - default: /* Some other command we don't know about yet.*/ + default: /* Some other command we don't know about yet.*/ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") - } /* end switch */ + } /* end switch */ done: /* If the conversion buffer doesn't need to be freed, reset its pointer */ - if(write_to_file && noop_conv) + if (write_to_file && noop_conv) conv_buf = NULL; /* Release the conversion buffer (always allocated, except on errors) */ - if(conv_buf) + if (conv_buf) conv_buf = H5FL_BLK_FREE(vlen_seq, conv_buf); /* Release the background buffer, if we have one */ - if(tmp_buf) + if (tmp_buf) tmp_buf = H5FL_BLK_FREE(vlen_seq, tmp_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_vlen() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_array * @@ -3343,20 +3472,20 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T__conv_array(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 H5_ATTR_UNUSED *_bkg) +H5T__conv_array(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 H5_ATTR_UNUSED *_bkg) { - 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 */ - 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 */ - herr_t ret_value=SUCCEED; /* Return value */ + 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 */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3369,17 +3498,19 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - HDassert(H5T_ARRAY==src->shared->type); - HDassert(H5T_ARRAY==dst->shared->type); + HDassert(H5T_ARRAY == src->shared->type); + HDassert(H5T_ARRAY == dst->shared->type); /* Check the number and sizes of the dimensions */ - if(src->shared->u.array.ndims != dst->shared->u.array.ndims) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions") - for(u = 0; u < src->shared->u.array.ndims; u++) - if(src->shared->u.array.dim[u] != dst->shared->u.array.dim[u]) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions") + if (src->shared->u.array.ndims != dst->shared->u.array.ndims) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "array datatypes do not have the same number of dimensions") + for (u = 0; u < src->shared->u.array.ndims; u++) + if (src->shared->u.array.dim[u] != dst->shared->u.array.dim[u]) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "array datatypes do not have the same sizes of dimensions") /* Array datatypes don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; @@ -3402,14 +3533,13 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * versa? Also, how many of the elements have the source and * destination areas overlapping? */ - if(src->shared->size >= dst->shared->size || buf_stride > 0) { - sp = dp = (uint8_t*)_buf; + if (src->shared->size >= dst->shared->size || buf_stride > 0) { + sp = dp = (uint8_t *)_buf; direction = 1; - } else { - sp = (uint8_t*)_buf + (nelmts - 1) * - (buf_stride ? buf_stride : src->shared->size); - dp = (uint8_t*)_buf + (nelmts - 1) * - (buf_stride ? buf_stride : dst->shared->size); + } + else { + sp = (uint8_t *)_buf + (nelmts - 1) * (buf_stride ? buf_stride : src->shared->size); + dp = (uint8_t *)_buf + (nelmts - 1) * (buf_stride ? buf_stride : dst->shared->size); direction = -1; } @@ -3423,31 +3553,38 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Set up conversion path for base elements */ - if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) { - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes") - } else if (!H5T_path_noop(tpath)) { - if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), FALSE)) < 0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) { + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatypes") + } + else if (!H5T_path_noop(tpath)) { + if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), + FALSE)) < 0 || + (tdst_id = + H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") } /* Check if we need a background buffer for this conversion */ - if(tpath->cdata.need_bkg) { - size_t bkg_buf_size; /*size of background buffer in bytes */ + if (tpath->cdata.need_bkg) { + size_t bkg_buf_size; /*size of background buffer in bytes */ /* Allocate background buffer */ bkg_buf_size = src->shared->u.array.nelem * MAX(src->shared->size, dst->shared->size); - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(array_seq, bkg_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(array_seq, bkg_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") } /* end if */ /* Perform the actual conversion */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* Copy the source array into the correct location for the destination */ HDmemmove(dp, sp, src->shared->size); /* Convert array */ - if(H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, (size_t)0, bkg_stride, dp, bkg_buf) < 0) + if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, (size_t)0, bkg_stride, + dp, bkg_buf) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Advance the source & destination pointers */ @@ -3456,24 +3593,229 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end for */ /* Release the temporary datatype IDs used */ - if(tsrc_id >= 0) + if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); - if(tdst_id >= 0) + if (tdst_id >= 0) H5I_dec_ref(tdst_id); break; - default: /* Some other command we don't know about yet.*/ + default: /* Some other command we don't know about yet.*/ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") } /* end switch */ done: /* Release the background buffer, if we have one */ - if(bkg_buf) + if (bkg_buf) bkg_buf = H5FL_BLK_FREE(array_seq, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_array() */ +/*------------------------------------------------------------------------- + * Function: H5T__conv_ref + * + * Purpose: Converts between reference datatypes in memory and on disk. + * This is a soft conversion function. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +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 */ + 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 */ + 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 */ + + FUNC_ENTER_PACKAGE + + switch (cdata->command) { + case H5T_CONV_INIT: + /* + * First, determine if this conversion function applies to the + * conversion path SRC_ID-->DST_ID. If not, return failure; + * otherwise initialize the `priv' field of `cdata' with + * information that remains (almost) constant for this + * conversion path. + */ + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_REFERENCE != src->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") + if (H5T_REFERENCE != dst->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_REFERENCE datatype") + /* Only allow for source reference that is not an opaque type, destination must be opaque */ + if (!dst->shared->u.atomic.u.r.opaque) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not an H5T_STD_REF datatype") + + /* Reference types don't need a background buffer */ + cdata->need_bkg = H5T_BKG_NO; + break; + + case H5T_CONV_FREE: + break; + + case H5T_CONV_CONV: { + /* + * Conversion. + */ + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + HDassert(src->shared->u.atomic.u.r.cls); + + /* Initialize source & destination strides */ + if (buf_stride) { + HDassert(buf_stride >= src->shared->size); + HDassert(buf_stride >= dst->shared->size); + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + s_stride = d_stride = (ssize_t)buf_stride; + } /* end if */ + else { + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + s_stride = (ssize_t)src->shared->size; + d_stride = (ssize_t)dst->shared->size; + } /* end else */ + if (bkg) { + if (bkg_stride) + b_stride = (ssize_t)bkg_stride; + else + b_stride = d_stride; + } /* end if */ + else + b_stride = 0; + + /* The outer loop of the type conversion macro, controlling which */ + /* direction the buffer is walked */ + while (nelmts > 0) { + /* Check if we need to go backwards through the buffer */ + if (d_stride > s_stride) { + /* Sanity check */ + HDassert(s_stride > 0); + HDassert(d_stride > 0); + HDassert(b_stride >= 0); + + /* Compute the number of "safe" destination elements at */ + /* the end of the buffer (Those which don't overlap with */ + /* any source elements at the beginning of the buffer) */ + safe = + nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); + + /* If we're down to the last few elements, just wrap up */ + /* with a "real" reverse copy */ + if (safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; + s_stride = -s_stride; + d_stride = -d_stride; + b_stride = -b_stride; + + safe = nelmts; + } /* end if */ + else { + s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; + } /* end else */ + } /* end if */ + else { + /* Single forward pass over all data */ + s = d = (uint8_t *)buf; + b = (uint8_t *)bkg; + safe = nelmts; + } /* end else */ + + for (elmtno = 0; elmtno < safe; elmtno++) { + size_t buf_size; + hbool_t dst_copy = FALSE; + hbool_t is_nil; /* Whether reference is "nil" */ + + /* Check for "nil" source reference */ + if ((*(src->shared->u.atomic.u.r.cls->isnull))(src->shared->u.atomic.u.r.file, s, + &is_nil) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if reference data is 'nil'") + + if (is_nil) { + /* Write "nil" reference to destination location */ + if ((*(dst->shared->u.atomic.u.r.cls->setnull))(dst->shared->u.atomic.u.r.file, d, + b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, + "can't set reference data to 'nil'") + } /* end else-if */ + else { + /* Get size of references */ + if (0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize( + src->shared->u.atomic.u.r.file, s, src->shared->size, + dst->shared->u.atomic.u.r.file, &dst_copy))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to obtain size of reference") + + /* Check if conversion buffer is large enough, resize if necessary. */ + if (conv_buf_size < buf_size) { + conv_buf_size = buf_size; + if (NULL == (conv_buf = H5FL_BLK_REALLOC(ref_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + HDmemset(conv_buf, 0, conv_buf_size); + } /* end if */ + + if (dst_copy && (src->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + H5MM_memcpy(conv_buf, s, buf_size); + else { + /* Read reference */ + if (src->shared->u.atomic.u.r.cls->read( + src->shared->u.atomic.u.r.file, s, src->shared->size, + dst->shared->u.atomic.u.r.file, conv_buf, buf_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read reference data") + } /* end else */ + + if (dst_copy && (dst->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + H5MM_memcpy(d, conv_buf, buf_size); + else { + /* Write reference to destination location */ + if (dst->shared->u.atomic.u.r.cls->write( + src->shared->u.atomic.u.r.file, conv_buf, buf_size, + src->shared->u.atomic.u.r.rtype, dst->shared->u.atomic.u.r.file, d, + dst->shared->size, b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write reference data") + } /* end else */ + } /* end else */ + + /* Advance pointers */ + s += s_stride; + d += d_stride; + b += b_stride; + } /* end for */ + + /* Decrement number of elements left to convert */ + nelmts -= safe; + } /* end while */ + } /* end case */ + break; + + default: /* Some other command we don't know about yet.*/ + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") + } /* end switch */ + +done: + /* Release the conversion buffer (always allocated, except on errors) */ + if (conv_buf) + conv_buf = H5FL_BLK_FREE(ref_seq, conv_buf); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__conv_ref() */ /*------------------------------------------------------------------------- * Function: H5T__conv_i_i @@ -3490,38 +3832,38 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ 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__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 */ - 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 dbuf[64]; /*temp destination buffer */ - size_t first; - ssize_t sfirst; /*a signed version of `first' */ - size_t i; /*Local index variables */ - 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 */ - herr_t ret_value=SUCCEED; /* Return value */ + 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 dbuf[64] = {0}; /*temp destination buffer */ + size_t first; + ssize_t sfirst; /*a signed version of `first' */ + size_t i; /*Local index variables */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) + if (H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) + if (H5T_ORDER_LE != dst->shared->u.atomic.order && H5T_ORDER_BE != dst->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst->shared->size > sizeof dbuf) + if (dst->shared->size > sizeof dbuf) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -3531,7 +3873,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -3539,23 +3881,25 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->shared->size==dst->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src->shared->size == dst->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src->shared->size>=dst->shared->size) { - double olap_d = HDceil((double)(dst->shared->size)/ - (double)(src->shared->size-dst->shared->size)); + olap = nelmts; + } + else if (src->shared->size >= dst->shared->size) { + double olap_d = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src->shared->size)/ - (double)(dst->shared->size-src->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts - 1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts - 1) * dst->shared->size; + } + else { + double olap_d = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } @@ -3569,32 +3913,36 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src->shared->size); /* The conversion loop */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; - } else { + } + else { s = sp; d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src->shared->size) || + (sp >= dp && sp < dp + dst->shared->size)); + } + else { + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); } #endif @@ -3603,12 +3951,12 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src->shared->u.atomic.order) { - half_size = src->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src->shared->size-(i+1)] = s[i]; - s[i] = tmp; + if (H5T_ORDER_BE == src->shared->u.atomic.order) { + half_size = src->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = s[src->shared->size - (i + 1)]; + s[src->shared->size - (i + 1)] = s[i]; + s[i] = tmp; } } @@ -3616,23 +3964,23 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * What is the bit number for the msb bit of S which is set? The * bit number is relative to the significant part of the number. */ - sfirst = H5T__bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, + sfirst = H5T__bit_find(s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, H5T_BIT_MSB, TRUE); - first = (size_t)sfirst; + first = (size_t)sfirst; /* Set these variables to default */ except_ret = H5T_CONV_UNHANDLED; reverse = TRUE; - if (sfirst<0) { + if (sfirst < 0) { /* * The source has no bits set and must therefore be zero. * Set the destination to zero. */ - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); - - } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); + } + else if (H5T_SGN_NONE == src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE == dst->shared->u.atomic.u.i.sign) { /* * Source and destination are both unsigned, but if the * source has more precision bits than the destination then @@ -3640,32 +3988,37 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * destination will be set to the maximum possible value. */ if (src->shared->u.atomic.prec <= dst->shared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else if (first>=dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else if (first >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - - } else if (H5T_SGN_2==src->shared->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (H5T_SGN_2 == src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE == dst->shared->u.atomic.u.i.sign) { /* * If the source is signed and the destination isn't then we * can have overflow if the source contains more bits than @@ -3673,79 +4026,95 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * possible value) or overflow if the source is negative * (destination is set to zero). */ - if (first+1 == src->shared->u.atomic.prec) { + if (first + 1 == src->shared->u.atomic.prec) { /*overflow - source is negative*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec-1); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec-1, - (dst->shared->u.atomic.prec-src->shared->u.atomic.prec)+1, FALSE); - } else if (first>=dst->shared->u.atomic.prec) { + } + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec - 1); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec - 1, + (dst->shared->u.atomic.prec - src->shared->u.atomic.prec) + 1, FALSE); + } + else if (first >= dst->shared->u.atomic.prec) { /*overflow - source is positive*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - - } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && - H5T_SGN_2==dst->shared->u.atomic.u.i.sign) { + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (H5T_SGN_NONE == src->shared->u.atomic.u.i.sign && + H5T_SGN_2 == dst->shared->u.atomic.u.i.sign) { /* * If the source is not signed but the destination is then * overflow can occur in which case the destination is set to * the largest possible value (all bits set except the msb). */ - if (first+1 >= dst->shared->u.atomic.prec) { + if (first + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + TRUE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); } - } else if (first+1 == src->shared->u.atomic.prec) { + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else if (first + 1 == src->shared->u.atomic.prec) { /* * Both the source and the destination are signed and the * source value is negative. We could experience overflow @@ -3753,91 +4122,112 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * destination is set to a negative number with the largest * possible magnitude. */ - ssize_t sfz = H5T__bit_find (s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec-1, H5T_BIT_MSB, FALSE); - size_t fz = (size_t)sfz; + ssize_t sfz = H5T__bit_find(s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec - 1, H5T_BIT_MSB, FALSE); + size_t fz = (size_t)sfz; - if (sfz>=0 && fz+1>=dst->shared->u.atomic.prec) { + if (sfz >= 0 && fz + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, FALSE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + FALSE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, TRUE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } - - } else { + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, TRUE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); + } + } + else { /* * Source and destination are both signed but the source * value is positive. We could have an overflow in which * case the destination is set to the largest possible * positive value. */ - if (first+1>=dst->shared->u.atomic.prec) { + if (first + 1 >= dst->shared->u.atomic.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, - cb_struct.user_data); + if (cb_struct.func) { /*If user's exception handler is present, use it*/ + H5T__reverse_order(src_rev, s, src->shared->size, + src->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); - H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), (size_t)1, FALSE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_set(d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec - 1, + TRUE); + H5T__bit_set(d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec - 1), + (size_t)1, FALSE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->shared->u.atomic.precshared->u.atomic.prec) { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - src->shared->u.atomic.prec); - H5T__bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, - dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); - } else { - H5T__bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, - dst->shared->u.atomic.prec); + } + else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T__bit_set(d, dst->shared->u.atomic.offset + src->shared->u.atomic.prec, + dst->shared->u.atomic.prec - src->shared->u.atomic.prec, FALSE); + } + else { + H5T__bit_copy(d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } } /* * Set padding areas in destination. */ - if (dst->shared->u.atomic.offset>0) { - HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); - H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad)); + if (dst->shared->u.atomic.offset > 0) { + HDassert(H5T_PAD_ZERO == dst->shared->u.atomic.lsb_pad || + H5T_PAD_ONE == dst->shared->u.atomic.lsb_pad); + H5T__bit_set(d, (size_t)0, dst->shared->u.atomic.offset, + (hbool_t)(H5T_PAD_ONE == dst->shared->u.atomic.lsb_pad)); } - if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) { - HDassert(H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); - H5T__bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec, - 8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec), - (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad)); + if (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec != 8 * dst->shared->size) { + HDassert(H5T_PAD_ZERO == dst->shared->u.atomic.msb_pad || + H5T_PAD_ONE == dst->shared->u.atomic.msb_pad); + H5T__bit_set(d, dst->shared->u.atomic.offset + dst->shared->u.atomic.prec, + 8 * dst->shared->size - + (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec), + (hbool_t)(H5T_PAD_ONE == dst->shared->u.atomic.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst->shared->u.atomic.order && reverse) { - half_size = dst->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst->shared->u.atomic.order && reverse) { + half_size = dst->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst->shared->size - (i + 1)]; + d[dst->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } } @@ -3845,7 +4235,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d==dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -3860,12 +4250,11 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_i_i() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_f_f * @@ -3881,57 +4270,58 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T__conv_f_f(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_f_f(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) { /* Traversal-related variables */ - 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 */ - int direction; /*forward or backward traversal */ - size_t elmtno; /*element number */ - size_t half_size; /*half the type size */ - 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 dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + 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 */ + int direction; /*forward or backward traversal */ + size_t elmtno; /*element number */ + size_t half_size; /*half the type size */ + 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 dbuf[64] = {0}; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - int64_t expo; /*exponent */ - hssize_t expo_max; /*maximum possible dst exponent */ - size_t msize = 0; /*useful size of mantissa in src*/ - size_t mpos; /*offset to useful mant is src */ - uint64_t sign; /*source sign bit value */ - size_t mrsh; /*amount to right shift mantissa*/ - hbool_t carry = FALSE; /*carry after rounding mantissa */ - size_t i; /*miscellaneous counters */ - size_t implied; /*destination implied bits */ - hbool_t denormalized = FALSE; /*is either source or destination denormalized?*/ - 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 */ - herr_t ret_value = SUCCEED; /*return value */ + int64_t expo; /*exponent */ + hssize_t expo_max; /*maximum possible dst exponent */ + size_t msize = 0; /*useful size of mantissa in src*/ + size_t mpos; /*offset to useful mant is src */ + uint64_t sign; /*source sign bit value */ + size_t mrsh; /*amount to right shift mantissa*/ + hbool_t carry = FALSE; /*carry after rounding mantissa */ + size_t i; /*miscellaneous counters */ + size_t implied; /*destination implied bits */ + hbool_t denormalized = FALSE; /*is either source or destination denormalized?*/ + 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 */ + herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + if (H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + if (H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize || 8 * sizeof(expo) - 1 < dst.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize || 8 * sizeof(expo) - 1 < dst.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -3941,10 +4331,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - src = src_p->shared->u.atomic; - dst = dst_p->shared->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; expo_max = ((hssize_t)1 << dst.u.f.esize) - 1; /* @@ -3952,25 +4343,25 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; + olap = nelmts; } - else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* @@ -3983,14 +4374,14 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst_p->shared->size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif @@ -4024,27 +4415,27 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } } - else if (H5T_ORDER_VAX==src.order) { + else if (H5T_ORDER_VAX == src.order) { tsize = src_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; - tmp2 = s[i+1]; + tmp2 = s[i + 1]; - s[i] = s[(tsize-2)-i]; - s[i+1] = s[(tsize-1)-i]; + s[i] = s[(tsize - 2) - i]; + s[i + 1] = s[(tsize - 1) - i]; - s[(tsize-2)-i] = tmp1; - s[(tsize-1)-i] = tmp2; + s[(tsize - 2) - i] = tmp1; + s[(tsize - 1) - i] = tmp2; } } @@ -4056,117 +4447,115 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Check for special cases: +0, -0, +Inf, -Inf, NaN */ - if (H5T__bit_find (s, src.u.f.mpos, src.u.f.msize, - H5T_BIT_LSB, TRUE)<0) { - if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, TRUE)<0) { + if (H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, TRUE) < 0) { /* +0 or -0 */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, FALSE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); goto padding; } - else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* +Inf or -Inf */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - if(sign) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + if (sign) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); else - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1. The Intel-Linux long double is *this case.*/ - if (H5T_NORM_NONE==dst.u.f.norm) - H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); + if (H5T_NORM_NONE == dst.u.f.norm) + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - 1, (size_t)1, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") goto padding; } } - else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, - H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T_NORM_NONE == src.u.f.norm && + H5T__bit_find(s, src.u.f.mpos, src.u.f.msize - 1, H5T_BIT_LSB, TRUE) < 0 && + H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ /* +Inf or -Inf */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - if(sign) - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); + if (sign) + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); else - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); - H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); + if (except_ret == H5T_CONV_UNHANDLED) { + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); /*If the destination no implied mantissa bit, we'll need to set *the 1st bit of mantissa to 1. The Intel-Linux long double is *this case.*/ - if (H5T_NORM_NONE==dst.u.f.norm) - H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); + if (H5T_NORM_NONE == dst.u.f.norm) + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - 1, (size_t)1, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; - /* Temporary solution to handle VAX special values. - * Note that even though we don't support VAX anymore, we - * still need to handle legacy VAX files so this code must - * remain in place. - */ + /* Temporary solution to handle VAX special values. + * Note that even though we don't support VAX anymore, we + * still need to handle legacy VAX files so this code must + * remain in place. + */ } - else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* NaN */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /* There are many NaN values, so we just set all bits of * the significand. */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); - H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_set(d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE); } - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -4179,58 +4568,60 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ expo = (int64_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); - if (expo==0) - denormalized=TRUE; + if (expo == 0) + denormalized = TRUE; /* * Set markers for the source mantissa, excluding the leading `1' * (might be implied). */ implied = 1; - mpos = src.u.f.mpos; - mrsh = 0; + mpos = src.u.f.mpos; + mrsh = 0; if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { if ((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) { msize = (size_t)bitno; } - else if (0==bitno) { + else if (0 == bitno) { msize = 1; H5T__bit_set(s, src.u.f.mpos, (size_t)1, FALSE); } } - else if (H5T_NORM_IMPLIED==src.u.f.norm) { + else if (H5T_NORM_IMPLIED == src.u.f.norm) { msize = src.u.f.msize; } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* * The sign for the destination is the same as the sign for the * source in all cases. */ - H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); + H5T__bit_copy(d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); /* * Calculate the true source exponent by adjusting according to * the source exponent bias. */ - if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - HDassert(bitno>=0); + if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { + HDassert(bitno >= 0); expo -= (int64_t)((src.u.f.ebias - 1) + (src.u.f.msize - (size_t)bitno)); } - else if (H5T_NORM_IMPLIED==src.u.f.norm) { + else if (H5T_NORM_IMPLIED == src.u.f.norm) { expo -= (int64_t)src.u.f.ebias; } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* * If the destination is not normalized then right shift the * mantissa by one. */ - if (H5T_NORM_NONE==dst.u.f.norm) + if (H5T_NORM_NONE == dst.u.f.norm) mrsh++; /* @@ -4246,7 +4637,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } - else if (expo<=0) { + else if (expo <= 0) { /* * The exponent is too small to fit in the exponent field, * but by shifting the mantissa to the right we can @@ -4254,10 +4645,10 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * longer normalized. */ mrsh += (size_t)(1 - expo); - expo = 0; - denormalized=TRUE; + expo = 0; + denormalized = TRUE; } - else if (expo>=expo_max) { + else if (expo >= expo_max) { /* * The exponent is too large to fit in the available region * or it results in the maximum possible value. Use positive @@ -4266,21 +4657,21 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * handler make sure the source buffer we hand it is in the * original byte order. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; } - else if(except_ret == H5T_CONV_ABORT) + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto next; } @@ -4293,20 +4684,22 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * overflow. That is, if `carry' is clear then the implied * mantissa bit is `1', else it is `10' binary. */ - if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) { + if (msize > 0 && mrsh <= dst.u.f.msize && mrsh + msize > dst.u.f.msize) { bitno = (ssize_t)(mrsh + msize - dst.u.f.msize); HDassert(bitno >= 0 && (size_t)bitno <= msize); /* If the 1st bit being cut off is set and source isn't denormalized.*/ - if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && !denormalized) { + if (H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && !denormalized) { /* Don't do rounding if exponent is 111...110 and mantissa is 111...11. * To do rounding and increment exponent in this case will create an infinity value.*/ - if((H5T__bit_find(s, mpos + (size_t)bitno, msize - (size_t)bitno, H5T_BIT_LSB, FALSE) >= 0 || expo < expo_max - 1)) { + if ((H5T__bit_find(s, mpos + (size_t)bitno, msize - (size_t)bitno, H5T_BIT_LSB, + FALSE) >= 0 || + expo < expo_max - 1)) { carry = H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); - if(carry) + if (carry) implied = 2; } } - else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) + else if (H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) /* For either source or destination, denormalized value doesn't increment carry.*/ H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); } @@ -4316,41 +4709,36 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Write the mantissa to the destination */ - if (mrsh>dst.u.f.msize+1) { + if (mrsh > dst.u.f.msize + 1) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } - else if (mrsh==dst.u.f.msize+1) { - H5T__bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE); + else if (mrsh == dst.u.f.msize + 1) { + H5T__bit_set(d, dst.u.f.mpos + 1, dst.u.f.msize - 1, FALSE); H5T__bit_set(d, dst.u.f.mpos, (size_t)1, TRUE); } - else if (mrsh==dst.u.f.msize) { + else if (mrsh == dst.u.f.msize) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); H5T__bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied); } else { - if (mrsh>0) { - H5T__bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh, - FALSE); - H5T__bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, (size_t)2, - (hsize_t)implied); + if (mrsh > 0) { + H5T__bit_set(d, dst.u.f.mpos + dst.u.f.msize - mrsh, mrsh, FALSE); + H5T__bit_set_d(d, dst.u.f.mpos + dst.u.f.msize - mrsh, (size_t)2, (hsize_t)implied); } - if (mrsh+msize>=dst.u.f.msize) { - H5T__bit_copy(d, dst.u.f.mpos, - s, (mpos+msize+mrsh-dst.u.f.msize), - dst.u.f.msize-mrsh); + if (mrsh + msize >= dst.u.f.msize) { + H5T__bit_copy(d, dst.u.f.mpos, s, (mpos + msize + mrsh - dst.u.f.msize), + dst.u.f.msize - mrsh); } else { - H5T__bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize), - s, mpos, msize); - H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize), - FALSE); + H5T__bit_copy(d, dst.u.f.mpos + dst.u.f.msize - (mrsh + msize), s, mpos, msize); + H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize - (mrsh + msize), FALSE); } } /* Write the exponent */ if (carry) { expo++; - if (expo>=expo_max) { + if (expo >= expo_max) { /* * The exponent is too large to fit in the available * region or it results in the maximum possible value. @@ -4359,20 +4747,22 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * calling the overflow handler make sure the source * buffer we hand it is in the original byte order. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); } - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto next; } @@ -4381,48 +4771,49 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /*reset CARRY*/ carry = FALSE; - H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t); + H5_CHECK_OVERFLOW(expo, hssize_t, hsize_t); H5T__bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo); - padding: +padding: /* * Set external padding areas */ - if (dst.offset>0) { - HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); - H5T__bit_set (d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + if (dst.offset > 0) { + HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->shared->size) { - HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); - H5T__bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec), - (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { + HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), + (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } - } else if (H5T_ORDER_VAX==dst.order && reverse) { + } + else if (H5T_ORDER_VAX == dst.order && reverse) { tsize = dst_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; - tmp2 = d[i+1]; + tmp2 = d[i + 1]; - d[i] = d[(tsize-2)-i]; - d[i+1] = d[(tsize-1)-i]; + d[i] = d[(tsize - 2) - i]; + d[i + 1] = d[(tsize - 1) - i]; - d[(tsize-2)-i] = tmp1; - d[(tsize-1)-i] = tmp2; + d[(tsize - 2) - i] = tmp1; + d[(tsize - 1) - i] = tmp2; } } @@ -4430,8 +4821,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - next: - if(d == dbuf) +next: + if (d == dbuf) H5MM_memcpy(dp, d, dst_p->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -4446,13 +4837,12 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_f_f() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_s_s * @@ -4466,40 +4856,45 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ 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__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 */ - 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. */ - herr_t ret_value=SUCCEED; /* Return value */ + 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. */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(8 * src->shared->size != src->shared->u.atomic.prec || 8 * dst->shared->size != dst->shared->u.atomic.prec) + if (8 * src->shared->size != src->shared->u.atomic.prec || + 8 * dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision") - if(0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) + if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset") - if(H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) + if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 != src->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad source character set") - if(H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) + if (H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 != dst->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad destination character set") - if((H5T_CSET_ASCII == src->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == dst->shared->u.atomic.u.s.cset) - || (H5T_CSET_ASCII == dst->shared->u.atomic.u.s.cset && H5T_CSET_UTF8 == src->shared->u.atomic.u.s.cset)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "The library doesn't convert between strings of ASCII and UTF") - if(src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NSTR || - dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NSTR) + if ((H5T_CSET_ASCII == src->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 == dst->shared->u.atomic.u.s.cset) || + (H5T_CSET_ASCII == dst->shared->u.atomic.u.s.cset && + H5T_CSET_UTF8 == src->shared->u.atomic.u.s.cset)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "The library doesn't convert between strings of ASCII and UTF") + if (src->shared->u.atomic.u.s.pad < 0 || src->shared->u.atomic.u.s.pad >= H5T_NSTR || + dst->shared->u.atomic.u.s.pad < 0 || dst->shared->u.atomic.u.s.pad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding") cdata->need_bkg = H5T_BKG_NO; break; @@ -4509,7 +4904,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -4517,26 +4912,28 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->shared->size==dst->shared->size || buf_stride) { + if (src->shared->size == dst->shared->size || buf_stride) { /* * When the source and destination are the same size we can do * all the conversions in place. */ - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - olap = 0; - } else if (src->shared->size>=dst->shared->size) { - double olapd = HDceil((double)(dst->shared->size)/ - (double)(src->shared->size-dst->shared->size)); + olap = 0; + } + else if (src->shared->size >= dst->shared->size) { + double olapd = + HDceil((double)(dst->shared->size) / (double)(src->shared->size - dst->shared->size)); olap = (size_t)olapd; - sp = dp = (uint8_t*)buf; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olapd = HDceil((double)(src->shared->size)/ - (double)(dst->shared->size-src->shared->size)); - olap = (size_t)olapd; - sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; + } + else { + double olapd = + HDceil((double)(src->shared->size) / (double)(dst->shared->size - src->shared->size)); + olap = (size_t)olapd; + sp = (uint8_t *)buf + (nelmts - 1) * src->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst->shared->size; direction = -1; } @@ -4550,49 +4947,52 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_delta = (ssize_t)direction * (ssize_t)(buf_stride ? buf_stride : dst->shared->size); /* Allocate the overlap buffer */ - if(NULL == (dbuf = (uint8_t *)H5MM_malloc(dst->shared->size))) + if (NULL == (dbuf = (uint8_t *)H5MM_calloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion") /* The conversion loop. */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; d = elmtno < olap ? dbuf : dp; - } else { + } + else { s = sp; d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (src->shared->size==dst->shared->size || buf_stride) { - HDassert(s==d); - } else if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (src->shared->size == dst->shared->size || buf_stride) { + HDassert(s == d); + } + else if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src->shared->size) || + (sp >= dp && sp < dp + dst->shared->size)); + } + else { + HDassert((dp < sp && dp + dst->shared->size <= sp) || + (sp < dp && sp + src->shared->size <= dp)); } #endif /* Copy characters from source to destination */ - switch(src->shared->u.atomic.u.s.pad) { + switch (src->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - for (nchars=0; - ncharsshared->size && ncharsshared->size && s[nchars]; + for (nchars = 0; + nchars < dst->shared->size && nchars < src->shared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } break; case H5T_STR_NULLPAD: - for (nchars=0; - ncharsshared->size && ncharsshared->size && s[nchars]; + for (nchars = 0; + nchars < dst->shared->size && nchars < src->shared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } @@ -4600,10 +5000,10 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_SPACEPAD: nchars = src->shared->size; - while (nchars>0 && ' '==s[nchars-1]) + while (nchars > 0 && ' ' == s[nchars - 1]) --nchars; nchars = MIN(dst->shared->size, nchars); - if(d != s) + if (d != s) H5MM_memcpy(d, s, nchars); break; @@ -4622,24 +5022,25 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_15: case H5T_STR_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "source string padding method not supported") } /* end switch */ /* Terminate or pad the destination */ - switch(dst->shared->u.atomic.u.s.pad) { + switch (dst->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = '\0'; d[dst->shared->size - 1] = '\0'; break; case H5T_STR_NULLPAD: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = '\0'; break; case H5T_STR_SPACEPAD: - while(nchars < dst->shared->size) + while (nchars < dst->shared->size) d[nchars++] = ' '; break; @@ -4658,14 +5059,15 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_RESERVED_15: case H5T_STR_ERROR: default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "destination string padding method not supported") } /* end switch */ /* * If we used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if(d == dbuf) + if (d == dbuf) H5MM_memcpy(dp, d, dst->shared->size); /* Advance source & destination pointers by delta amounts */ @@ -4684,7 +5086,6 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_s_s() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_uchar * @@ -4692,7 +5093,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -4700,14 +5101,12 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_uchar(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_schar_uchar(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_su(SCHAR, UCHAR, signed char, unsigned char, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_schar * @@ -4715,7 +5114,7 @@ H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -4723,14 +5122,12 @@ H5T__conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_schar(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_uchar_schar(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_us(UCHAR, SCHAR, unsigned char, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_short * @@ -4738,7 +5135,7 @@ H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4746,14 +5143,12 @@ H5T__conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_short(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_schar_short(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_sS(SCHAR, SHORT, signed char, short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ushort * @@ -4761,7 +5156,7 @@ H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4769,14 +5164,12 @@ H5T__conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ushort(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_schar_ushort(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_sU(SCHAR, USHORT, signed char, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_short * @@ -4784,7 +5177,7 @@ H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4792,14 +5185,12 @@ H5T__conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_short(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_uchar_short(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_uS(UCHAR, SHORT, unsigned char, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ushort * @@ -4807,7 +5198,7 @@ H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4815,14 +5206,12 @@ H5T__conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ushort(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_uchar_ushort(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_uU(UCHAR, USHORT, unsigned char, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_int * @@ -4830,7 +5219,7 @@ H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4838,14 +5227,12 @@ H5T__conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_int(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_schar_int(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_sS(SCHAR, INT, signed char, int, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_uint * @@ -4853,7 +5240,7 @@ H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4861,14 +5248,12 @@ H5T__conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_uint(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_schar_uint(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_sU(SCHAR, UINT, signed char, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_int * @@ -4876,7 +5261,7 @@ H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4884,14 +5269,12 @@ H5T__conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_int(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_uchar_int(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_uS(UCHAR, INT, unsigned char, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_uint * @@ -4899,7 +5282,7 @@ H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4907,14 +5290,12 @@ H5T__conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_uint(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_uchar_uint(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_uU(UCHAR, UINT, unsigned char, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_long * @@ -4922,7 +5303,7 @@ H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4930,14 +5311,12 @@ H5T__conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_long(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_schar_long(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_sS(SCHAR, LONG, signed char, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ulong * @@ -4945,7 +5324,7 @@ H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4953,14 +5332,12 @@ H5T__conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ulong(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_schar_ulong(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_sU(SCHAR, ULONG, signed char, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_long * @@ -4968,7 +5345,7 @@ H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4976,14 +5353,12 @@ H5T__conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_long(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_uchar_long(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_uS(UCHAR, LONG, unsigned char, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ulong * @@ -4991,7 +5366,7 @@ H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -4999,14 +5374,12 @@ H5T__conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ulong(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_uchar_ulong(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_uU(UCHAR, ULONG, unsigned char, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_llong * @@ -5014,7 +5387,7 @@ H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5022,14 +5395,12 @@ H5T__conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_llong(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_schar_llong(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_sS(SCHAR, LLONG, signed char, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ullong * @@ -5037,7 +5408,7 @@ H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5045,14 +5416,12 @@ H5T__conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_ullong(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_schar_ullong(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_sU(SCHAR, ULLONG, signed char, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_llong * @@ -5060,7 +5429,7 @@ H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5068,14 +5437,12 @@ H5T__conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_llong(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_uchar_llong(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_uS(UCHAR, LLONG, unsigned char, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ullong * @@ -5083,7 +5450,7 @@ H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5091,14 +5458,12 @@ H5T__conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_ullong(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_uchar_ullong(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_uU(UCHAR, ULLONG, unsigned char, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_schar * @@ -5106,7 +5471,7 @@ H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5114,14 +5479,12 @@ H5T__conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_schar(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_short_schar(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_Ss(SHORT, SCHAR, short, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_uchar * @@ -5129,7 +5492,7 @@ H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5137,14 +5500,12 @@ H5T__conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_uchar(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_short_uchar(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_Su(SHORT, UCHAR, short, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_schar * @@ -5152,7 +5513,7 @@ H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5160,14 +5521,12 @@ H5T__conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_schar(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_ushort_schar(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_Us(USHORT, SCHAR, unsigned short, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_uchar * @@ -5175,7 +5534,7 @@ H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5183,14 +5542,12 @@ H5T__conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_uchar(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_ushort_uchar(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_Uu(USHORT, UCHAR, unsigned short, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ushort * @@ -5198,7 +5555,7 @@ H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -5206,14 +5563,12 @@ H5T__conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ushort(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_short_ushort(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_su(SHORT, USHORT, short, unsigned short, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_short * @@ -5221,7 +5576,7 @@ H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -5229,14 +5584,12 @@ H5T__conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_short(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_ushort_short(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_us(USHORT, SHORT, unsigned short, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_int * @@ -5244,7 +5597,7 @@ H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5252,14 +5605,12 @@ H5T__conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_int(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_short_int(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_sS(SHORT, INT, short, int, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_uint * @@ -5267,7 +5618,7 @@ H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5275,14 +5626,12 @@ H5T__conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_uint(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_short_uint(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_sU(SHORT, UINT, short, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_int * @@ -5290,7 +5639,7 @@ H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5298,14 +5647,12 @@ H5T__conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_int(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_ushort_int(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_uS(USHORT, INT, unsigned short, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_uint * @@ -5313,7 +5660,7 @@ H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5321,14 +5668,12 @@ H5T__conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_uint(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_ushort_uint(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_uU(USHORT, UINT, unsigned short, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_long * @@ -5336,7 +5681,7 @@ H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5344,14 +5689,12 @@ H5T__conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_long(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_short_long(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_sS(SHORT, LONG, short, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ulong * @@ -5359,7 +5702,7 @@ H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5367,14 +5710,12 @@ H5T__conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ulong(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_short_ulong(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_sU(SHORT, ULONG, short, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_long * @@ -5382,7 +5723,7 @@ H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5390,14 +5731,12 @@ H5T__conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_long(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_ushort_long(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_uS(USHORT, LONG, unsigned short, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ulong * @@ -5405,7 +5744,7 @@ H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5413,14 +5752,12 @@ H5T__conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_ulong(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_ushort_ulong(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_uU(USHORT, ULONG, unsigned short, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_llong * @@ -5428,7 +5765,7 @@ H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5436,14 +5773,12 @@ H5T__conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_llong(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_short_llong(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_sS(SHORT, LLONG, short, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ullong * @@ -5451,7 +5786,7 @@ H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5459,14 +5794,12 @@ H5T__conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_ullong(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_short_ullong(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_sU(SHORT, ULLONG, short, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_llong * @@ -5474,7 +5807,7 @@ H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5482,14 +5815,12 @@ H5T__conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_llong(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_ushort_llong(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_uS(USHORT, LLONG, unsigned short, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ullong * @@ -5497,7 +5828,7 @@ H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5505,14 +5836,12 @@ H5T__conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_ullong(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_ushort_ullong(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_uU(USHORT, ULLONG, unsigned short, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_schar * @@ -5520,7 +5849,7 @@ H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5528,14 +5857,12 @@ H5T__conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_schar(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_int_schar(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_Ss(INT, SCHAR, int, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_uchar * @@ -5543,7 +5870,7 @@ H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5551,14 +5878,12 @@ H5T__conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_uchar(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_int_uchar(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_Su(INT, UCHAR, int, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_schar * @@ -5566,7 +5891,7 @@ H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5574,14 +5899,12 @@ H5T__conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_schar(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_uint_schar(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_Us(UINT, SCHAR, unsigned, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_uchar * @@ -5589,7 +5912,7 @@ H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5597,14 +5920,12 @@ H5T__conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_uchar(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_uint_uchar(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_Uu(UINT, UCHAR, unsigned, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_short * @@ -5612,7 +5933,7 @@ H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5620,14 +5941,12 @@ H5T__conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_short(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_int_short(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_Ss(INT, SHORT, int, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ushort * @@ -5635,7 +5954,7 @@ H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5643,14 +5962,12 @@ H5T__conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ushort(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_int_ushort(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_Su(INT, USHORT, int, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_short * @@ -5658,7 +5975,7 @@ H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5666,14 +5983,12 @@ H5T__conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_short(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_uint_short(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_Us(UINT, SHORT, unsigned, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ushort * @@ -5681,7 +5996,7 @@ H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5689,14 +6004,12 @@ H5T__conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ushort(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_uint_ushort(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_Uu(UINT, USHORT, unsigned, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_uint * @@ -5704,7 +6017,7 @@ H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -5712,14 +6025,12 @@ H5T__conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_uint(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_int_uint(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_su(INT, UINT, int, unsigned, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_int * @@ -5727,7 +6038,7 @@ H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -5735,14 +6046,12 @@ H5T__conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_int(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_uint_int(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_us(UINT, INT, unsigned, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_long * @@ -5750,7 +6059,7 @@ H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5758,14 +6067,12 @@ H5T__conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_long(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_int_long(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_sS(INT, LONG, int, long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ulong * @@ -5773,7 +6080,7 @@ H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5781,14 +6088,12 @@ H5T__conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ulong(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_int_ulong(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_sU(INT, LONG, int, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_long * @@ -5796,7 +6101,7 @@ H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5804,14 +6109,12 @@ H5T__conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_long(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_uint_long(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_uS(UINT, LONG, unsigned, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ulong * @@ -5819,7 +6122,7 @@ H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5827,14 +6130,12 @@ H5T__conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ulong(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_uint_ulong(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_uU(UINT, ULONG, unsigned, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_llong * @@ -5842,7 +6143,7 @@ H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5850,14 +6151,12 @@ H5T__conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_llong(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_int_llong(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_sS(INT, LLONG, int, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ullong * @@ -5865,7 +6164,7 @@ H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5873,14 +6172,12 @@ H5T__conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_ullong(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_int_ullong(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_sU(INT, ULLONG, int, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_llong * @@ -5888,7 +6185,7 @@ H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5896,14 +6193,12 @@ H5T__conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_llong(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_uint_llong(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_uS(UINT, LLONG, unsigned, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ullong * @@ -5911,7 +6206,7 @@ H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5919,14 +6214,12 @@ H5T__conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_ullong(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_uint_ullong(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_uU(UINT, ULLONG, unsigned, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_schar * @@ -5934,7 +6227,7 @@ H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5942,14 +6235,12 @@ H5T__conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_schar(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_long_schar(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_Ss(LONG, SCHAR, long, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_uchar * @@ -5957,7 +6248,7 @@ H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5965,14 +6256,12 @@ H5T__conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_uchar(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_long_uchar(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_Su(LONG, UCHAR, long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_schar * @@ -5980,7 +6269,7 @@ H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -5988,14 +6277,12 @@ H5T__conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_schar(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_ulong_schar(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_Us(ULONG, SCHAR, unsigned long, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_uchar * @@ -6003,7 +6290,7 @@ H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6011,14 +6298,12 @@ H5T__conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_uchar(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_ulong_uchar(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_Uu(ULONG, UCHAR, unsigned long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_short * @@ -6026,7 +6311,7 @@ H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6034,14 +6319,12 @@ H5T__conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_short(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_long_short(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_Ss(LONG, SHORT, long, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ushort * @@ -6049,7 +6332,7 @@ H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6057,14 +6340,12 @@ H5T__conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ushort(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_long_ushort(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_Su(LONG, USHORT, long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_short * @@ -6072,7 +6353,7 @@ H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6080,14 +6361,12 @@ H5T__conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_short(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_ulong_short(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_Us(ULONG, SHORT, unsigned long, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ushort * @@ -6095,7 +6374,7 @@ H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6103,14 +6382,12 @@ H5T__conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_ushort(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_ulong_ushort(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_Uu(ULONG, USHORT, unsigned long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_int * @@ -6118,7 +6395,7 @@ H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6126,14 +6403,12 @@ H5T__conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_int(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_long_int(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_Ss(LONG, INT, long, int, INT_MIN, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_uint * @@ -6141,7 +6416,7 @@ H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6149,14 +6424,12 @@ H5T__conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_uint(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_long_uint(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_Su(LONG, UINT, long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_int * @@ -6164,7 +6437,7 @@ H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6172,14 +6445,12 @@ H5T__conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_int(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_ulong_int(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_Us(ULONG, INT, unsigned long, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_uint * @@ -6187,7 +6458,7 @@ H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6195,14 +6466,12 @@ H5T__conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_uint(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_ulong_uint(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_Uu(ULONG, UINT, unsigned long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ulong * @@ -6210,7 +6479,7 @@ H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -6218,14 +6487,12 @@ H5T__conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ulong(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_long_ulong(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_su(LONG, ULONG, long, unsigned long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_long * @@ -6233,7 +6500,7 @@ H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -6241,14 +6508,12 @@ H5T__conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_long(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_ulong_long(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_us(ULONG, LONG, unsigned long, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_llong * @@ -6256,7 +6521,7 @@ H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6264,14 +6529,12 @@ H5T__conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_llong(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_long_llong(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_sS(LONG, LLONG, long, long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ullong * @@ -6279,7 +6542,7 @@ H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6287,14 +6550,12 @@ H5T__conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_ullong(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_long_ullong(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_sU(LONG, ULLONG, long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_llong * @@ -6302,7 +6563,7 @@ H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6310,14 +6571,12 @@ H5T__conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_llong(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_ulong_llong(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_uS(ULONG, LLONG, unsigned long, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ullong * @@ -6325,7 +6584,7 @@ H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6333,14 +6592,12 @@ H5T__conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_ullong(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_ulong_ullong(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_uU(ULONG, ULLONG, unsigned long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_schar * @@ -6348,7 +6605,7 @@ H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6356,14 +6613,12 @@ H5T__conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_schar(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_llong_schar(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_Ss(LLONG, SCHAR, long long, signed char, SCHAR_MIN, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_uchar * @@ -6371,7 +6626,7 @@ H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6379,14 +6634,12 @@ H5T__conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_uchar(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_llong_uchar(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_Su(LLONG, UCHAR, long long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_schar * @@ -6394,7 +6647,7 @@ H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6402,14 +6655,12 @@ H5T__conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_schar(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_ullong_schar(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_Us(ULLONG, SCHAR, unsigned long long, signed char, -, SCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_uchar * @@ -6417,7 +6668,7 @@ H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6425,14 +6676,12 @@ H5T__conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_uchar(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_ullong_uchar(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_Uu(ULLONG, UCHAR, unsigned long long, unsigned char, -, UCHAR_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_short * @@ -6440,7 +6689,7 @@ H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6448,14 +6697,12 @@ H5T__conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_short(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_llong_short(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_Ss(LLONG, SHORT, long long, short, SHRT_MIN, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ushort * @@ -6463,7 +6710,7 @@ H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6471,14 +6718,12 @@ H5T__conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ushort(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_llong_ushort(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_Su(LLONG, USHORT, long long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_short * @@ -6486,7 +6731,7 @@ H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6494,14 +6739,12 @@ H5T__conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_short(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_ullong_short(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_Us(ULLONG, SHORT, unsigned long long, short, -, SHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ushort * @@ -6509,7 +6752,7 @@ H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6517,14 +6760,12 @@ H5T__conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_ushort(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_ullong_ushort(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_Uu(ULLONG, USHORT, unsigned long long, unsigned short, -, USHRT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_int * @@ -6532,7 +6773,7 @@ H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6540,14 +6781,12 @@ H5T__conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_int(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_llong_int(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_Ss(LLONG, INT, long long, int, INT_MIN, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_uint * @@ -6555,7 +6794,7 @@ H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6563,14 +6802,12 @@ H5T__conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_uint(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_llong_uint(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_Su(LLONG, UINT, long long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_int * @@ -6578,7 +6815,7 @@ H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6586,14 +6823,12 @@ H5T__conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_int(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_ullong_int(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_Us(ULLONG, INT, unsigned long long, int, -, INT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_uint * @@ -6601,7 +6836,7 @@ H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6609,14 +6844,12 @@ H5T__conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_uint(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_ullong_uint(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_Uu(ULLONG, UINT, unsigned long long, unsigned, -, UINT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_long * @@ -6624,7 +6857,7 @@ H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6632,14 +6865,12 @@ H5T__conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_long(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_llong_long(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_Ss(LLONG, LONG, long long, long, LONG_MIN, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ulong * @@ -6647,7 +6878,7 @@ H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6655,14 +6886,12 @@ H5T__conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ulong(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_llong_ulong(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_Su(LLONG, ULONG, long long, unsigned long, -, ULONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_long * @@ -6670,7 +6899,7 @@ H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6678,14 +6907,12 @@ H5T__conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_long(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_ullong_long(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_Us(ULLONG, LONG, unsigned long long, long, -, LONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ulong * @@ -6693,7 +6920,7 @@ H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Friday, November 13, 1998 @@ -6701,14 +6928,12 @@ H5T__conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_ulong(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_ullong_ulong(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_Uu(ULLONG, ULONG, unsigned long long, unsigned long, -, ULONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ullong * @@ -6716,7 +6941,7 @@ H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -6724,14 +6949,12 @@ H5T__conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_ullong(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_llong_ullong(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_su(LLONG, ULLONG, long long, unsigned long long, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_llong * @@ -6739,7 +6962,7 @@ H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * * Return: Success: non-negative * - * Failure: negative + * Failure: negative * * Programmer: Robb Matzke * Monday, November 16, 1998 @@ -6747,14 +6970,12 @@ H5T__conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_llong(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_ullong_llong(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_us(ULLONG, LLONG, unsigned long long, long long, -, LLONG_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_double * @@ -6769,14 +6990,12 @@ H5T__conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_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_float_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(FLOAT, DOUBLE, float, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ldouble * @@ -6792,15 +7011,13 @@ H5T__conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #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_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 * @@ -6815,14 +7032,12 @@ H5T__conv_float_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_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_double_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(DOUBLE, FLOAT, double, float, -FLT_MAX, FLT_MAX); } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ldouble * @@ -6838,15 +7053,13 @@ H5T__conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #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_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 * @@ -6862,15 +7075,13 @@ H5T__conv_double_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #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_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 * @@ -6886,15 +7097,13 @@ H5T__conv_ldouble_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ #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_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 * @@ -6909,14 +7118,12 @@ H5T__conv_ldouble_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_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_schar_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_xF(SCHAR, FLOAT, signed char, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_double * @@ -6931,14 +7138,12 @@ H5T__conv_schar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_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_schar_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_xF(SCHAR, DOUBLE, signed char, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_schar_ldouble * @@ -6953,14 +7158,12 @@ H5T__conv_schar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_schar_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_schar_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_xF(SCHAR, LDOUBLE, signed char, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_float * @@ -6975,14 +7178,12 @@ H5T__conv_schar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_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_uchar_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_xF(UCHAR, FLOAT, unsigned char, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_double * @@ -6997,14 +7198,12 @@ H5T__conv_uchar_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_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_uchar_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_xF(UCHAR, DOUBLE, unsigned char, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uchar_ldouble * @@ -7019,14 +7218,12 @@ H5T__conv_uchar_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uchar_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_uchar_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_xF(UCHAR, LDOUBLE, unsigned char, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_float * @@ -7041,14 +7238,12 @@ H5T__conv_uchar_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_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_short_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_xF(SHORT, FLOAT, short, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_double * @@ -7063,14 +7258,12 @@ H5T__conv_short_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_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_short_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_xF(SHORT, DOUBLE, short, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_short_ldouble * @@ -7085,14 +7278,12 @@ H5T__conv_short_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_short_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_short_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_xF(SHORT, LDOUBLE, short, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_float * @@ -7107,14 +7298,12 @@ H5T__conv_short_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_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_ushort_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_xF(USHORT, FLOAT, unsigned short, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_double * @@ -7129,14 +7318,12 @@ H5T__conv_ushort_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_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_ushort_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_xF(USHORT, DOUBLE, unsigned short, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ushort_ldouble * @@ -7151,14 +7338,12 @@ H5T__conv_ushort_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ushort_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_ushort_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_xF(USHORT, LDOUBLE, unsigned short, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_float * @@ -7173,14 +7358,12 @@ H5T__conv_ushort_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_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_int_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_xF(INT, FLOAT, int, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_double * @@ -7195,14 +7378,12 @@ H5T__conv_int_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_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_int_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_xF(INT, DOUBLE, int, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_int_ldouble * @@ -7217,14 +7398,12 @@ H5T__conv_int_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_int_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_int_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_xF(INT, LDOUBLE, int, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_float * @@ -7239,14 +7418,12 @@ H5T__conv_int_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_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_uint_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_xF(UINT, FLOAT, unsigned int, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_double * @@ -7261,14 +7438,12 @@ H5T__conv_uint_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_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_uint_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_xF(UINT, DOUBLE, unsigned int, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_uint_ldouble * @@ -7283,14 +7458,12 @@ H5T__conv_uint_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_uint_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_uint_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_xF(UINT, LDOUBLE, unsigned int, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_float * @@ -7305,14 +7478,12 @@ H5T__conv_uint_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_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_long_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_xF(LONG, FLOAT, long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_double * @@ -7327,14 +7498,12 @@ H5T__conv_long_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_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_long_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_xF(LONG, DOUBLE, long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_long_ldouble * @@ -7349,14 +7518,12 @@ H5T__conv_long_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_long_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_long_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_xF(LONG, LDOUBLE, long, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_float * @@ -7371,14 +7538,12 @@ H5T__conv_long_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_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_ulong_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_xF(ULONG, FLOAT, unsigned long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_double * @@ -7393,14 +7558,12 @@ H5T__conv_ulong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_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_ulong_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_xF(ULONG, DOUBLE, unsigned long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ulong_ldouble * @@ -7415,14 +7578,12 @@ H5T__conv_ulong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ulong_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_ulong_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_xF(ULONG, LDOUBLE, unsigned long, long double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_float * @@ -7437,14 +7598,12 @@ H5T__conv_ulong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_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_llong_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_xF(LLONG, FLOAT, long long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_double * @@ -7459,14 +7618,12 @@ H5T__conv_llong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_llong_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_llong_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_xF(LLONG, DOUBLE, long long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_llong_ldouble * @@ -7480,17 +7637,15 @@ H5T__conv_llong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_LLONG_LDOUBLE +#ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE herr_t -H5T__conv_llong_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_llong_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_xF(LLONG, LDOUBLE, long long, long double, -, -); } #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_float * @@ -7505,14 +7660,12 @@ H5T__conv_llong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_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_ullong_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_xF(ULLONG, FLOAT, unsigned long long, float, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_double * @@ -7527,14 +7680,12 @@ H5T__conv_ullong_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_ullong_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_ullong_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_xF(ULLONG, DOUBLE, unsigned long long, double, -, -); } - /*------------------------------------------------------------------------- * Function: H5T__conv_ullong_ldouble * @@ -7548,17 +7699,15 @@ H5T__conv_ullong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_ULLONG_LDOUBLE +#ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE herr_t -H5T__conv_ullong_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_ullong_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_xF(ULLONG, LDOUBLE, unsigned long long, long double, -, -); } #endif /*H5T_CONV_INTERNAL_ULLONG_LDOUBLE*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_float_schar * @@ -7573,16 +7722,14 @@ H5T__conv_ullong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_schar (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_float_schar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, SCHAR, float, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_uchar * @@ -7597,16 +7744,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_uchar (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_float_uchar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, UCHAR, float, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_schar * @@ -7621,16 +7766,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_schar (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_double_schar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, SCHAR, double, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_uchar * @@ -7645,16 +7788,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_uchar (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_double_uchar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, UCHAR, double, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_schar * @@ -7669,16 +7810,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_schar (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_ldouble_schar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, SCHAR, long double, signed char, SCHAR_MIN, SCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_uchar * @@ -7693,16 +7832,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_uchar (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_ldouble_uchar(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, UCHAR, long double, unsigned char, 0, UCHAR_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_short * @@ -7717,16 +7854,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_short (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_float_short(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, SHORT, float, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ushort * @@ -7741,16 +7876,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ushort (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_float_ushort(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, USHORT, float, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_short * @@ -7765,16 +7898,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_short (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_double_short(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, SHORT, double, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ushort * @@ -7789,16 +7920,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ushort (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_double_ushort(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, USHORT, double, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_short * @@ -7813,16 +7942,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_short (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_ldouble_short(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, SHORT, long double, short, SHRT_MIN, SHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ushort * @@ -7837,16 +7964,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_ushort (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_ldouble_ushort(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, USHORT, long double, unsigned short, 0, USHRT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_int * @@ -7861,16 +7986,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_int (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_float_int(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, INT, float, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_uint * @@ -7885,16 +8008,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_uint (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_float_uint(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, UINT, float, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_int * @@ -7909,16 +8030,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_int (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_double_int(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, INT, double, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_uint * @@ -7933,16 +8052,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_uint (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_double_uint(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, UINT, double, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_int * @@ -7957,16 +8074,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_int (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_ldouble_int(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, INT, long double, int, INT_MIN, INT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_uint * @@ -7981,16 +8096,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_uint (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_ldouble_uint(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, UINT, long double, unsigned int, 0, UINT_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_long * @@ -8005,16 +8118,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_long (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_float_long(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, LONG, float, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ulong * @@ -8029,16 +8140,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ulong (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_float_ulong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, ULONG, float, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_long * @@ -8053,16 +8162,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_long (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_double_long(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, LONG, double, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ulong * @@ -8077,16 +8184,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ulong (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_double_ulong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, ULONG, double, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_long * @@ -8101,16 +8206,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_long (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_ldouble_long(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, LONG, long double, long, LONG_MIN, LONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ulong * @@ -8125,16 +8228,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_ldouble_ulong (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_ldouble_ulong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, ULONG, long double, unsigned long, 0, ULONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_llong * @@ -8149,16 +8250,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_llong (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_float_llong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, LLONG, float, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_float_ullong * @@ -8173,16 +8272,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_float_ullong (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_float_ullong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(FLOAT, ULLONG, float, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_llong * @@ -8197,16 +8294,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_llong (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_double_llong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, LLONG, double, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_double_ullong * @@ -8221,16 +8316,14 @@ H5_GCC_DIAG_ON(float-equal) *------------------------------------------------------------------------- */ herr_t -H5T__conv_double_ullong (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_double_ullong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(DOUBLE, ULLONG, double, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_llong * @@ -8244,19 +8337,17 @@ H5_GCC_DIAG_ON(float-equal) * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_LDOUBLE_LLONG +#ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG herr_t -H5T__conv_ldouble_llong (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_ldouble_llong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, LLONG, long double, long long, LLONG_MIN, LLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } #endif /*H5T_CONV_INTERNAL_LDOUBLE_LLONG*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_ullong * @@ -8272,17 +8363,15 @@ H5_GCC_DIAG_ON(float-equal) */ #if H5T_CONV_INTERNAL_LDOUBLE_ULLONG herr_t -H5T__conv_ldouble_ullong (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_ldouble_ullong(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) { -H5_GCC_DIAG_OFF(float-equal) + H5_GCC_DIAG_OFF("float-equal") H5T_CONV_Fx(LDOUBLE, ULLONG, long double, unsigned long long, 0, ULLONG_MAX); -H5_GCC_DIAG_ON(float-equal) + H5_GCC_DIAG_ON("float-equal") } #endif /*H5T_CONV_INTERNAL_LDOUBLE_ULLONG*/ - /*------------------------------------------------------------------------- * Function: H5T__conv_f_i * @@ -8295,62 +8384,55 @@ H5_GCC_DIAG_ON(float-equal) * Programmer: Raymond Lu * Wednesday, Jan 21, 2004 * - * Raymond Lu - * Wednesday, April 21, 2004 - * There is a new design for exception handling like overflow, - * which is passed in as a transfer property. - * - * Raymond Lu - * Monday, March 13, 2006 - * Added support for VAX floating-point types. *------------------------------------------------------------------------- */ herr_t -H5T__conv_f_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__conv_f_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) { /* Traversal-related variables */ - 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 */ - size_t elmtno; /*element number */ - 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 dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + 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 */ + size_t elmtno; /*element number */ + 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 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 */ - size_t buf_size; /*buffer size for temporary value */ - size_t i; /*miscellaneous counters */ - size_t first; /*first bit(MSB) in an integer */ - ssize_t sfirst; /*a signed version of `first' */ - H5T_conv_cb_t cb_struct={NULL, NULL}; /*conversion callback structure */ - hbool_t truncated; /*if fraction value is dropped */ - hbool_t reverse; /*if reverse order of destination at the end */ - H5T_conv_ret_t except_ret; /*return of callback function */ - herr_t ret_value=SUCCEED; /* Return value */ + hssize_t expo; /*source exponent */ + hssize_t sign; /*source sign bit 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 */ + ssize_t sfirst; /*a signed version of `first' */ + H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ + hbool_t truncated; /*if fraction value is dropped */ + hbool_t reverse; /*if reverse order of destination at the end */ + H5T_conv_ret_t except_ret; /*return of callback function */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) + if (H5T_ORDER_LE != src.order && H5T_ORDER_BE != src.order && H5T_ORDER_VAX != src.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -8360,7 +8442,8 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -8370,40 +8453,42 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if(src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + olap = nelmts; + } + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + } + else { + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (size_t) (HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1); - int_buf = (uint8_t*)H5MM_calloc(buf_size); + buf_size = (size_t)(HDpow(2.0, (double)src.u.f.esize) / 8 + 1); + int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for(elmtno = 0; elmtno < nelmts; elmtno++) { + for (elmtno = 0; elmtno < nelmts; elmtno++) { /* Set these variables to default */ except_ret = H5T_CONV_UNHANDLED; truncated = FALSE; @@ -8413,21 +8498,23 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If the source and destination buffers overlap then use a * temporary buffer for the destination. */ - if(direction > 0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); + } + else { + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif /* @@ -8435,152 +8522,172 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } - } else if (H5T_ORDER_VAX==src.order) { + } + else if (H5T_ORDER_VAX == src.order) { tsize = src_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = s[i]; - tmp2 = s[i+1]; + tmp2 = s[i + 1]; - s[i] = s[(tsize-2)-i]; - s[i+1] = s[(tsize-1)-i]; + s[i] = s[(tsize - 2) - i]; + s[i + 1] = s[(tsize - 1) - i]; - s[(tsize-2)-i] = tmp1; - s[(tsize-1)-i] = tmp2; + s[(tsize - 2) - i] = tmp1; + s[(tsize - 1) - i] = tmp2; } } /*zero-set all destination bits*/ - H5T__bit_set (d, dst.offset, dst.prec, FALSE); + H5T__bit_set(d, dst.offset, dst.prec, FALSE); /* * Find the sign bit value of the source. */ - sign = (hssize_t) H5T__bit_get_d(s, src.u.f.sign, (size_t)1); + sign = (hssize_t)H5T__bit_get_d(s, src.u.f.sign, (size_t)1); /* * Check for special cases: +0, -0, +Inf, -Inf, NaN */ - if (H5T__bit_find (s, src.u.f.mpos, src.u.f.msize, - H5T_BIT_LSB, TRUE)<0) { - if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, TRUE)<0) { + if (H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_LSB, TRUE) < 0) { + if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, TRUE) < 0) { /* +0 or -0 */ /* Set all bits to zero */ goto padding; - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* +Infinity or -Infinity */ - if(sign) { /* -Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (sign) { /* -Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.prec-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.prec - 1, (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { /* +Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else { /* +Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, + d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_NONE==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec-1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_NONE == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } goto padding; } - } else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, - H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T_NORM_NONE == src.u.f.norm && + H5T__bit_find(s, src.u.f.mpos, src.u.f.msize - 1, H5T_BIT_LSB, TRUE) < 0 && + H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ /* +Infinity or -Infinity */ - if(sign) { /* -Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (sign) { /* -Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.prec-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.prec - 1, (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else { /* +Infinity */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + } + else { /* +Infinity */ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PINF, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { - if (H5T_SGN_NONE==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if (H5T_SGN_2==dst.u.i.sign) - H5T__bit_set (d, dst.offset, dst.prec-1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { + if (H5T_SGN_NONE == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (H5T_SGN_2 == dst.u.i.sign) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } goto padding; - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, - H5T_BIT_LSB, FALSE)<0) { + } + else if (H5T__bit_find(s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE) < 0) { /* NaN */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_NAN, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /*Just set all bits to zero.*/ goto padding; - } else if(except_ret == H5T_CONV_HANDLED) { + } + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) + } + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -8591,18 +8698,21 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the source bit field where it's located. Not expecting * exponent to be greater than the maximal value of hssize_t. */ - expo = (hssize_t) H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); + expo = (hssize_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); /* * Calculate the true source exponent by adjusting according to * the source exponent bias. */ - if (0==expo || H5T_NORM_NONE==src.u.f.norm) { - expo -= (hssize_t) (src.u.f.ebias-1); - } else if (H5T_NORM_IMPLIED==src.u.f.norm) { - expo -= (hssize_t) src.u.f.ebias; - } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { + expo -= (hssize_t)(src.u.f.ebias - 1); + } + else if (H5T_NORM_IMPLIED == src.u.f.norm) { + expo -= (hssize_t)src.u.f.ebias; + } + else { + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* @@ -8621,7 +8731,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Restore the implicit bit for mantissa if it's implied. * Equivalent to mantissa |= (hsize_t)1<shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, - src_id, dst_id, src_rev, d, cb_struct.user_data); - if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, + d, cb_struct.user_data); + if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } } - } else { /*source is positive*/ - if (first>=dst.prec) { + } + else { /*source is positive*/ + if (first >= dst.prec) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set (d, dst.offset, dst.prec, TRUE); - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst.offset, dst.prec, TRUE); + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - } else if (first shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy (d, dst.offset, int_buf, (size_t)0, first+1); - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") } } - } else if (H5T_SGN_2==dst.u.i.sign) { /*Destination is signed*/ - if(sign) { /*source is negative*/ - if(first < dst.prec-1) { - if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (H5T_SGN_2 == dst.u.i.sign) { /*Destination is signed*/ + if (sign) { /*source is negative*/ + if (first < dst.prec - 1) { + if (truncated && + cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { /*If this case ignored by user handler*/ + if (except_ret == H5T_CONV_UNHANDLED) { /*If this case ignored by user handler*/ /*Convert to integer representation. Equivalent to ~(value - 1).*/ H5T__bit_dec(int_buf, (size_t)0, 8 * buf_size); H5T__bit_neg(int_buf, (size_t)0, 8 * buf_size); /*copy source value into destination*/ - H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, dst.prec-1); - H5T__bit_set(d, (dst.offset + dst.prec-1), (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, dst.prec - 1); + H5T__bit_set(d, (dst.offset + dst.prec - 1), (size_t)1, TRUE); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - } else { + } + else { /* if underflows and no callback, do nothing except turn on * the sign bit because 0x80...00 is the biggest negative value. */ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set(d, (dst.offset + dst.prec-1), (size_t)1, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, (dst.offset + dst.prec - 1), (size_t)1, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } } - } else { /*source is positive*/ - if (first >= dst.prec-1) { + } + else { /*source is positive*/ + if (first >= dst.prec - 1) { /*overflow*/ - if(cb_struct.func) { /*If user's exception handler is present, use it*/ + if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) - H5T__bit_set(d, dst.offset, dst.prec-1, TRUE); - else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) + H5T__bit_set(d, dst.offset, dst.prec - 1, TRUE); + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; } - } else if(first < dst.prec-1) { - if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ + } + else if (first < dst.prec - 1) { + if (truncated && + cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, - src_id, dst_id, src_rev, d, cb_struct.user_data); + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, + src_rev, d, cb_struct.user_data); } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy (d, dst.offset, int_buf, (size_t)0, first+1); - } else if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + } + else if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; @@ -8799,47 +8937,47 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } - padding: +padding: /* * Set padding areas in destination. */ - if (dst.offset>0) { - HDassert(H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); - H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + if (dst.offset > 0) { + HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->shared->size) { - HDassert(H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); - H5T__bit_set(d, dst.offset+dst.prec, - 8*dst_p->shared->size - (dst.offset+ dst.prec), - (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { + HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), + (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp1; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp1; } } - next: +next: /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) - H5MM_memcpy (dp, d, dst_p->shared->size); + if (d == dbuf) + H5MM_memcpy(dp, d, dst_p->shared->size); if (buf_stride) { - sp += direction * (ssize_t) buf_stride; - dp += direction * (ssize_t) buf_stride; - } else { - sp += direction * (ssize_t) src_p->shared->size; - dp += direction * (ssize_t) dst_p->shared->size; + sp += direction * (ssize_t)buf_stride; + dp += direction * (ssize_t)buf_stride; + } + else { + sp += direction * (ssize_t)src_p->shared->size; + dp += direction * (ssize_t)dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); @@ -8852,15 +8990,14 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(int_buf) + if (int_buf) H5MM_xfree(int_buf); - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_f_i() */ - /*------------------------------------------------------------------------- * Function: H5T__conv_i_f * @@ -8876,53 +9013,54 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T__conv_i_f(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_i_f(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) { /* Traversal-related variables */ - 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 */ - size_t elmtno; /*element number */ - 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 dbuf[64]; /*temp destination buffer */ - uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ + 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 */ + size_t elmtno; /*element number */ + 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 dbuf[64] = {0}; /*temp destination buffer */ + uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ - hsize_t expo; /*destination exponent */ - hsize_t expo_max; /*maximal possible exponent value */ - 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 */ - size_t buf_size; /*buffer size for temporary value */ - size_t i; /*miscellaneous counters */ - size_t first; /*first bit(MSB) in an integer */ - ssize_t sfirst; /*a signed version of `first' */ - 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 */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t expo; /*destination exponent */ + hsize_t expo_max; /*maximal possible exponent value */ + 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 */ + size_t buf_size; /*buffer size for temporary value */ + size_t i; /*miscellaneous counters */ + size_t first; /*first bit(MSB) in an integer */ + ssize_t sfirst; /*a signed version of `first' */ + 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 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - switch(cdata->command) { + switch (cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; - if(H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) + if (H5T_ORDER_LE != dst.order && H5T_ORDER_BE != dst.order && H5T_ORDER_VAX != dst.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") - if(dst_p->shared->size > sizeof(dbuf)) + if (dst_p->shared->size > sizeof(dbuf)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large") - if(8 * sizeof(expo) - 1 < src.u.f.esize) + if (8 * sizeof(expo) - 1 < src.u.f.esize) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large") cdata->need_bkg = H5T_BKG_NO; break; @@ -8932,7 +9070,8 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src_p = (H5T_t *)H5I_object(src_id)) || + NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -8942,137 +9081,138 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->shared->size==dst_p->shared->size || buf_stride) { - sp = dp = (uint8_t*)buf; + if (src_p->shared->size == dst_p->shared->size || buf_stride) { + sp = dp = (uint8_t *)buf; direction = 1; - olap = nelmts; - } else if (src_p->shared->size>=dst_p->shared->size) { - double olap_d = HDceil((double)(dst_p->shared->size)/ - (double)(src_p->shared->size-dst_p->shared->size)); - olap = (size_t)olap_d; - sp = dp = (uint8_t*)buf; + olap = nelmts; + } + else if (src_p->shared->size >= dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size) / + (double)(src_p->shared->size - dst_p->shared->size)); + olap = (size_t)olap_d; + sp = dp = (uint8_t *)buf; direction = 1; - } else { - double olap_d = HDceil((double)(src_p->shared->size)/ - (double)(dst_p->shared->size-src_p->shared->size)); - olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; - direction = -1; + } + else { + double olap_d = HDceil((double)(src_p->shared->size) / + (double)(dst_p->shared->size - src_p->shared->size)); + olap = (size_t)olap_d; + sp = (uint8_t *)buf + (nelmts - 1) * src_p->shared->size; + dp = (uint8_t *)buf + (nelmts - 1) * dst_p->shared->size; + direction = -1; } /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize)/8 + 1; - int_buf = (uint8_t*)H5MM_calloc(buf_size); + buf_size = (src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize) / 8 + 1; + int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ - if(H5CX_get_dt_conv_cb(&cb_struct) < 0) + if (H5CX_get_dt_conv_cb(&cb_struct) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get conversion exception callback") /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); + src_rev = (uint8_t *)H5MM_calloc(src_p->shared->size); /* The conversion loop */ - for (elmtno=0; elmtno0) { + if (direction > 0) { s = sp; - d = elmtno= nelmts ? dbuf : dp; + d = elmtno + olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (d==dbuf) { - HDassert((dp>=sp && dpshared->size) || - (sp>=dp && spshared->size)); - } else { - HDassert((dpshared->size<=sp) || - (spshared->size<=dp)); + if (d == dbuf) { + HDassert((dp >= sp && dp < sp + src_p->shared->size) || + (sp >= dp && sp < dp + dst_p->shared->size)); + } + else { + HDassert((dp < sp && dp + dst_p->shared->size <= sp) || + (sp < dp && sp + src_p->shared->size <= dp)); } #endif - /* - * Put the data in little endian order so our loops aren't so + /* Put the data in little endian order so our loops aren't so * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src.order) { - half_size = src_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - s[src_p->shared->size-(i+1)] = s[i]; - s[i] = tmp1; + if (H5T_ORDER_BE == src.order) { + half_size = src_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + tmp1 = s[src_p->shared->size - (i + 1)]; + s[src_p->shared->size - (i + 1)] = s[i]; + s[i] = tmp1; } } - /*zero-set all destination bits*/ - H5T__bit_set (d, dst.offset, dst.prec, FALSE); + /* Zero-set all destination bits*/ + H5T__bit_set(d, dst.offset, dst.prec, FALSE); /* Copy source into a temporary buffer */ H5T__bit_copy(int_buf, (size_t)0, s, src.offset, src.prec); - /* - * Find the sign bit value of the source. - */ - if(H5T_SGN_2 == src.u.i.sign) + /* Find the sign bit value of the source */ + if (H5T_SGN_2 == src.u.i.sign) sign = (size_t)H5T__bit_get_d(int_buf, src.prec - 1, (size_t)1); - /* - * What is the bit position(starting from 0 as first one) for the most significant - * bit(MSB) of S which is set? + /* What is the bit position(starting from 0 as first one) for the most significant + * bit(MSB) of S which is set? */ - if(H5T_SGN_2 == src.u.i.sign) { + if (H5T_SGN_2 == src.u.i.sign) { sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec - 1, H5T_BIT_MSB, TRUE); - if(sign && sfirst < 0) - /* The case 0x80...00, which is negative with maximal value */ + if (sign && sfirst < 0) + /* The case 0x80...00, which is negative with maximal value */ is_max_neg = 1; - } else if(H5T_SGN_NONE == src.u.i.sign) + } + else if (H5T_SGN_NONE == src.u.i.sign) sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec, H5T_BIT_MSB, TRUE); /* Handle special cases here. Integer is zero */ - if(!sign && sfirst < 0) + if (!sign && sfirst < 0) goto padding; - /* - * Convert source integer if it's negative - */ - if(H5T_SGN_2 == src.u.i.sign && sign) { - if(!is_max_neg) { + /* Convert source integer if it's negative */ + if (H5T_SGN_2 == src.u.i.sign && sign) { + if (!is_max_neg) { /* Equivalent to ~(i - 1) */ H5T__bit_dec(int_buf, (size_t)0, buf_size * 8); H5T__bit_neg(int_buf, (size_t)0, buf_size * 8); sfirst = H5T__bit_find(int_buf, (size_t)0, src.prec - 1, H5T_BIT_MSB, TRUE); - } else { - /* If it's maximal negative number 0x80...000, treat it as if it overflowed - * (create a carry) to help conversion. i.e. a character type number 0x80 - * is treated as 0x100. - */ - sfirst = (ssize_t)(src.prec - 1); + } + else { + /* If it's maximal negative number 0x80...000, treat it as if it overflowed + * (create a carry) to help conversion. i.e. a character type number 0x80 + * is treated as 0x100. + */ + sfirst = (ssize_t)(src.prec - 1); is_max_neg = 0; } - if(sfirst < 0) + if (sfirst < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "zero bit not found") /* Sign bit has been negated if bit vector isn't 0x80...00. Set all bits in front of * sign bit to 0 in the temporary buffer because they're all negated from the previous - * step. */ + * step. + */ H5T__bit_set(int_buf, src.prec, (buf_size * 8) - src.prec, 0); /* Set sign bit in destination */ @@ -9081,109 +9221,118 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, first = (size_t)sfirst; - /* - * Calculate the true destination exponent by adjusting according to + /* Calculate the true destination exponent by adjusting according to * the destination exponent bias. Implied and non-implied normalization * should be the same. */ - if (H5T_NORM_NONE==dst.u.f.norm || H5T_NORM_IMPLIED==dst.u.f.norm) { + if (H5T_NORM_NONE == dst.u.f.norm || H5T_NORM_IMPLIED == dst.u.f.norm) { expo = first + dst.u.f.ebias; - } else { - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") + } + else { + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "normalization method not implemented yet") } /* Handle mantissa part here */ - if (H5T_NORM_IMPLIED==dst.u.f.norm) { + if (H5T_NORM_IMPLIED == dst.u.f.norm) { /* Imply first bit */ H5T__bit_set(int_buf, first, (size_t)1, 0); - } else if (H5T_NORM_NONE==dst.u.f.norm) { - first++; - } + } + else if (H5T_NORM_NONE == dst.u.f.norm) { + first++; + } /* Roundup for mantissa */ - if(first > dst.u.f.msize) { - /* If the bit sequence is bigger than the mantissa part, there'll be some + if (first > dst.u.f.msize) { + /* If the bit sequence is bigger than the mantissa part, there'll be some * precision loss. Let user's handler deal with the case if it's present */ - if(cb_struct.func) { - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, - src_rev, d, cb_struct.user_data); + if (cb_struct.func) { + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, src_rev, d, + cb_struct.user_data); } - if(except_ret == H5T_CONV_HANDLED) { + if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto padding; - } else if(except_ret == H5T_CONV_ABORT) + } + else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - /* If user's exception handler does deal with it, we do it by dropping off the - * extra bits at the end and do rounding. If we have .50...0(decimal) after radix - * point, we do roundup when the least significant digit before radix is odd, we do - * rounddown if it's even. - */ + /* If user's exception handler does deal with it, we do it by dropping off the + * extra bits at the end and do rounding. If we have .50...0(decimal) after radix + * point, we do roundup when the least significant digit before radix is odd, we do + * rounddown if it's even. + */ /* Check 1st dropoff bit, see if it's set. */ - if(H5T__bit_get_d(int_buf, ((first - dst.u.f.msize) - 1), (size_t)1)) { + if (H5T__bit_get_d(int_buf, ((first - dst.u.f.msize) - 1), (size_t)1)) { /* Check all bits after 1st dropoff bit, see if any of them is set. */ - if(((first - dst.u.f.msize) - 1) > 0 && H5T__bit_get_d(int_buf, (size_t)0, ((first - dst.u.f.msize) - 1))) + if (((first - dst.u.f.msize) - 1) > 0 && + H5T__bit_get_d(int_buf, (size_t)0, ((first - dst.u.f.msize) - 1))) do_round = 1; - else { /* The .50...0 case */ + else { /* The .50...0 case */ /* Check if the least significant bit is odd. */ - if(H5T__bit_get_d(int_buf, (first - dst.u.f.msize), (size_t)1)) - do_round = 1; + if (H5T__bit_get_d(int_buf, (first - dst.u.f.msize), (size_t)1)) + do_round = 1; } - } + } /* Right shift to drop off extra bits */ H5T__bit_shift(int_buf, (ssize_t)(dst.u.f.msize - first), (size_t)0, buf_size * 8); - if(do_round) { + if (do_round) { H5T__bit_inc(int_buf, (size_t)0, buf_size * 8); do_round = 0; - /* If integer is like 0x0ff...fff and we need to round up the - * last f, we get 0x100...000. Treat this special case here. - */ - if(H5T__bit_get_d(int_buf, dst.u.f.msize, (size_t)1)) { - if (H5T_NORM_IMPLIED==dst.u.f.norm) { - /* The bit at this 1's position was impled already, so this - * number should be 0x200...000. We need to increment the - * exponent in this case. - */ - expo++; - } else if (H5T_NORM_NONE==dst.u.f.norm) { - /* Right shift 1 bit to let the carried 1 fit in the mantissa, - * and increment exponent by 1. - */ + /* If integer is like 0x0ff...fff and we need to round up the + * last f, we get 0x100...000. Treat this special case here. + */ + if (H5T__bit_get_d(int_buf, dst.u.f.msize, (size_t)1)) { + if (H5T_NORM_IMPLIED == dst.u.f.norm) { + /* The bit at this 1's position was impled already, so this + * number should be 0x200...000. We need to increment the + * exponent in this case. + */ + expo++; + } + else if (H5T_NORM_NONE == dst.u.f.norm) { + /* Right shift 1 bit to let the carried 1 fit in the mantissa, + * and increment exponent by 1. + */ H5T__bit_shift(int_buf, (ssize_t)-1, (size_t)0, buf_size * 8); - expo++; - } - } + expo++; + } + } } - } else { + } + else { /* The bit sequence can fit mantissa part. Left shift to fit in from high-order of - * bit position. */ + * bit position. */ H5T__bit_shift(int_buf, (ssize_t)(dst.u.f.msize - first), (size_t)0, dst.u.f.msize); } - /* Check if the exponent is too big */ - expo_max = (hsize_t) (HDpow((double)2.0f, (double)dst.u.f.esize) - 1); - - if(expo > expo_max) { /*overflows*/ - if(cb_struct.func) { /*user's exception handler. Reverse back source order*/ - H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ - except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, - src_rev, d, cb_struct.user_data); - - if(except_ret == H5T_CONV_ABORT) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") - else if(except_ret == H5T_CONV_HANDLED) { + expo_max = (hsize_t)(HDpow(2.0, (double)dst.u.f.esize) - 1); + + if (expo > expo_max) { /*overflows*/ + if (cb_struct.func) { /*user's exception handler. Reverse back source order*/ + H5T__reverse_order(src_rev, s, src_p->shared->size, + src_p->shared->u.atomic.order); /*reverse order first*/ + except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, + cb_struct.user_data); + + if (except_ret == H5T_CONV_ABORT) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, + "can't handle conversion exception") + else if (except_ret == H5T_CONV_HANDLED) { reverse = FALSE; goto padding; } - } else { + } + else { /*make destination infinity by setting exponent to maximal number and *mantissa to zero.*/ expo = expo_max; @@ -9191,26 +9340,26 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } } - if(except_ret == H5T_CONV_UNHANDLED) { + if (except_ret == H5T_CONV_UNHANDLED) { /* Set exponent in destination */ H5T__bit_set_d(d, dst.u.f.epos, dst.u.f.esize, expo); /* Copy mantissa into destination */ - H5T__bit_copy(d, dst.u.f.mpos, int_buf, (size_t)0, (buf_size * 8) > dst.u.f.msize ? dst.u.f.msize : buf_size * 8); + H5T__bit_copy(d, dst.u.f.mpos, int_buf, (size_t)0, + (buf_size * 8) > dst.u.f.msize ? dst.u.f.msize : buf_size * 8); } - padding: +padding: /* * Set padding areas in destination. */ - if(dst.offset > 0) { + if (dst.offset > 0) { HDassert(H5T_PAD_ZERO == dst.lsb_pad || H5T_PAD_ONE == dst.lsb_pad); - H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); + H5T__bit_set(d, (size_t)0, dst.offset, (hbool_t)(H5T_PAD_ONE == dst.lsb_pad)); } - if(dst.offset + dst.prec != 8 * dst_p->shared->size) { + if (dst.offset + dst.prec != 8 * dst_p->shared->size) { HDassert(H5T_PAD_ZERO == dst.msb_pad || H5T_PAD_ONE == dst.msb_pad); - H5T__bit_set(d, dst.offset + dst.prec, - 8 * dst_p->shared->size - (dst.offset + dst.prec), + H5T__bit_set(d, dst.offset + dst.prec, 8 * dst_p->shared->size - (dst.offset + dst.prec), (hbool_t)(H5T_PAD_ONE == dst.msb_pad)); } @@ -9218,26 +9367,27 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->shared->size/2; - for (i=0; ishared->size-(i+1)]; - d[dst_p->shared->size-(i+1)] = d[i]; - d[i] = tmp; + if (H5T_ORDER_BE == dst.order && reverse) { + half_size = dst_p->shared->size / 2; + for (i = 0; i < half_size; i++) { + uint8_t tmp = d[dst_p->shared->size - (i + 1)]; + d[dst_p->shared->size - (i + 1)] = d[i]; + d[i] = tmp; } - } else if (H5T_ORDER_VAX==dst.order && reverse) { + } + else if (H5T_ORDER_VAX == dst.order && reverse) { tsize = dst_p->shared->size; HDassert(0 == tsize % 2); for (i = 0; i < tsize; i += 4) { tmp1 = d[i]; - tmp2 = d[i+1]; + tmp2 = d[i + 1]; - d[i] = d[(tsize-2)-i]; - d[i+1] = d[(tsize-1)-i]; + d[i] = d[(tsize - 2) - i]; + d[i + 1] = d[(tsize - 1) - i]; - d[(tsize-2)-i] = tmp1; - d[(tsize-1)-i] = tmp2; + d[(tsize - 2) - i] = tmp1; + d[(tsize - 1) - i] = tmp2; } } @@ -9245,14 +9395,15 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) - H5MM_memcpy (dp, d, dst_p->shared->size); + if (d == dbuf) + H5MM_memcpy(dp, d, dst_p->shared->size); if (buf_stride) { - sp += direction * (ssize_t) buf_stride; - dp += direction * (ssize_t) buf_stride; - } else { - sp += direction * (ssize_t) src_p->shared->size; - dp += direction * (ssize_t) dst_p->shared->size; + sp += direction * (ssize_t)buf_stride; + dp += direction * (ssize_t)buf_stride; + } + else { + sp += direction * (ssize_t)src_p->shared->size; + dp += direction * (ssize_t)dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); @@ -9265,17 +9416,16 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end switch */ done: - if(int_buf) + if (int_buf) H5MM_xfree(int_buf); - if(src_rev) + if (src_rev) H5MM_free(src_rev); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__conv_i_f() */ - /*------------------------------------------------------------------------- - * Function: H5T_reverse_order + * Function: H5T__reverse_order * * Purpose: Internal assisting function to reverse the order of * a sequence of byte when it's big endian or VAX order. @@ -9291,28 +9441,110 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ static herr_t -H5T_reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) +H5T__reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) { - size_t i; + size_t i; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(s); HDassert(size); if (H5T_ORDER_VAX == order) { for (i = 0; i < size; i += 2) { - rev[i] = s[(size - 2) - i]; + rev[i] = s[(size - 2) - i]; rev[i + 1] = s[(size - 1) - i]; } - } else if (H5T_ORDER_BE == order) { - for (i=0; ishared->type == H5T_REFERENCE) { + if (H5T__ref_reclaim(elem, dt) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim ref elements") + } + else { + HDassert(op_data); + + /* Allow vlen reclaim to recurse into that routine */ + if (H5T__vlen_reclaim(elem, dt, (H5T_vlen_alloc_info_t *)op_data) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_reclaim_cb() */ diff --git a/src/H5Tcset.c b/src/H5Tcset.c index 5ac2a6261b3..dd145c97e88 100644 --- a/src/H5Tcset.c +++ b/src/H5Tcset.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,15 +16,13 @@ * the character set (cset) for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_cset * @@ -44,22 +42,23 @@ H5T_cset_t H5Tget_cset(hid_t type_id) { - H5T_t *dt; - H5T_cset_t ret_value; + H5T_t * dt; + H5T_cset_t ret_value; FUNC_ENTER_API(H5T_CSET_ERROR) H5TRACE1("Tc", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, "operation not defined for data type class") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, + "operation not defined for data type class") /* result */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.cset; else ret_value = dt->shared->u.vlen.cset; @@ -68,7 +67,6 @@ H5Tget_cset(hid_t type_id) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_cset * @@ -86,26 +84,26 @@ H5Tget_cset(hid_t type_id) herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) { - H5T_t *dt; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTc", type_id, cset); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (cset < H5T_CSET_ASCII || cset >= H5T_NCSET) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.cset = cset; else dt->shared->u.vlen.cset = cset; @@ -113,4 +111,3 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index 61881385afb..613aa603a8d 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,53 +26,43 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5T__print_stats * @@ -93,26 +83,31 @@ *------------------------------------------------------------------------- */ herr_t -H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*in,out*/) +H5T__print_stats(H5T_path_t H5_ATTR_UNUSED *path, int H5_ATTR_UNUSED *nprint /*in,out*/) { FUNC_ENTER_PACKAGE_NOERR #ifdef H5T_DEBUG - if(H5DEBUG(T) && path->stats.ncalls > 0) { - hsize_t nbytes; + if (H5DEBUG(T) && path->stats.ncalls > 0) { + hsize_t nbytes; char bandwidth[32]; - - if(nprint && 0 == (*nprint)++) { - HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "Conversion", "Elmts", "Calls", "User", - "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "----------", "-----", "-----", "----", - "------", "-------", "---------"); - } /* end if */ - - if(path->src && path->dst) + struct { + char *user; + char *system; + char *elapsed; + } timestrs = {H5_timer_get_time_string(path->stats.times.user), + H5_timer_get_time_string(path->stats.times.system), + H5_timer_get_time_string(path->stats.times.elapsed)}; + + if (nprint && 0 == (*nprint)++) { + HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "Conversion", "Elmts", "Calls", + "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", "----------", "-----", "-----", + "----", "------", "-------", "---------"); + } /* end if */ + + if (path->src && path->dst) nbytes = MAX(H5T_get_size(path->src), H5T_get_size(path->dst)); else if (path->src) nbytes = H5T_get_size(path->src); @@ -120,24 +115,20 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/* nbytes = H5T_get_size(path->dst); else nbytes = 0; - - nbytes *= path->stats.nelmts; + nbytes *= path->stats.nelmts; H5_bandwidth(bandwidth, (double)nbytes, path->stats.times.elapsed); - HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8T %8T %8T %10s\n", - path->name, - path->stats.nelmts, - path->stats.ncalls, - path->stats.times.user, - path->stats.times.system, - path->stats.times.elapsed, - bandwidth); - } /* end if */ + HDfprintf(H5DEBUG(T), " %-16s %10" PRIdHSIZE " %10u %8s %8s %8s %10s\n", path->name, + path->stats.nelmts, path->stats.ncalls, timestrs.user, timestrs.system, timestrs.elapsed, + bandwidth); + HDfree(timestrs.user); + HDfree(timestrs.system); + HDfree(timestrs.elapsed); + } #endif FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__print_stats() */ - /*------------------------------------------------------------------------- * Function: H5T_debug * @@ -150,10 +141,10 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/* herr_t H5T_debug(const H5T_t *dt, FILE *stream) { - const char *s1 = ""; - const char *s2 = ""; + const char *s1 = ""; + const char *s2 = ""; unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -199,7 +190,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; case H5T_VLEN: - if(H5T_IS_VL_STRING(dt->shared)) + if (H5T_IS_VL_STRING(dt->shared)) s1 = "str"; else s1 = "vlen"; @@ -211,7 +202,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) default: s1 = ""; break; - } /* end switch */ + } /* end switch */ switch (dt->shared->state) { case H5T_STATE_TRANSIENT: @@ -235,12 +226,12 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; default: HDassert(0 && "This Should never be executed!"); - } /* end switch */ + } /* end switch */ HDfprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size)); if (H5T_IS_ATOMIC(dt->shared)) { - uint64_t tmp; + uint64_t tmp; switch (dt->shared->u.atomic.order) { case H5T_ORDER_ERROR: @@ -272,9 +263,9 @@ H5T_debug(const H5T_t *dt, FILE *stream) HDfprintf(stream, ", %s", s1); if (dt->shared->u.atomic.offset) - HDfprintf(stream, ", offset=%lu", (unsigned long) (dt->shared->u.atomic.offset)); + HDfprintf(stream, ", offset=%lu", (unsigned long)(dt->shared->u.atomic.offset)); if (dt->shared->u.atomic.prec != 8 * dt->shared->size) - HDfprintf(stream, ", prec=%lu", (unsigned long) (dt->shared->u.atomic.prec)); + HDfprintf(stream, ", prec=%lu", (unsigned long)(dt->shared->u.atomic.prec)); switch (dt->shared->type) { case H5T_NO_CLASS: @@ -282,7 +273,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; case H5T_INTEGER: - switch(dt->shared->u.atomic.u.i.sign) { + switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "sign error"); break; @@ -301,12 +292,12 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } /* end switch */ - if(s1) + if (s1) HDfprintf(stream, ", %s", s1); break; case H5T_FLOAT: - switch(dt->shared->u.atomic.u.f.norm) { + switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_ERROR: HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "norm error"); break; @@ -328,20 +319,16 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } /* end switch */ - HDfprintf(stream, ", sign=%lu+1", - (unsigned long)(dt->shared->u.atomic.u.f.sign)); - HDfprintf(stream, ", mant=%lu+%lu (%s)", - (unsigned long)(dt->shared->u.atomic.u.f.mpos), - (unsigned long)(dt->shared->u.atomic.u.f.msize), s1); - HDfprintf(stream, ", exp=%lu+%lu", - (unsigned long)(dt->shared->u.atomic.u.f.epos), - (unsigned long)(dt->shared->u.atomic.u.f.esize)); + HDfprintf(stream, ", sign=%lu+1", (unsigned long)(dt->shared->u.atomic.u.f.sign)); + HDfprintf(stream, ", mant=%lu+%lu (%s)", (unsigned long)(dt->shared->u.atomic.u.f.mpos), + (unsigned long)(dt->shared->u.atomic.u.f.msize), s1); + HDfprintf(stream, ", exp=%lu+%lu", (unsigned long)(dt->shared->u.atomic.u.f.epos), + (unsigned long)(dt->shared->u.atomic.u.f.esize)); tmp = dt->shared->u.atomic.u.f.ebias >> 32; if (tmp) { size_t hi = (size_t)tmp; size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); - HDfprintf(stream, " bias=0x%08lx%08lx", - (unsigned long)hi, (unsigned long)lo); + HDfprintf(stream, " bias=0x%08lx%08lx", (unsigned long)hi, (unsigned long)lo); } else { size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); @@ -367,9 +354,8 @@ H5T_debug(const H5T_t *dt, FILE *stream) else if (H5T_COMPOUND == dt->shared->type) { /* Compound data type */ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - HDfprintf(stream, "\n\"%s\" @%lu", - dt->shared->u.compnd.memb[i].name, - (unsigned long)(dt->shared->u.compnd.memb[i].offset)); + HDfprintf(stream, "\n\"%s\" @%lu", dt->shared->u.compnd.memb[i].name, + (unsigned long)(dt->shared->u.compnd.memb[i].offset)); HDfprintf(stream, " "); H5T_debug(dt->shared->u.compnd.memb[i].type, stream); } /* end for */ @@ -406,18 +392,19 @@ H5T_debug(const H5T_t *dt, FILE *stream) } /* end else */ } else if (H5T_ENUM == dt->shared->type) { - size_t base_size; + size_t base_size; /* Enumeration data type */ HDfprintf(stream, " "); H5T_debug(dt->shared->parent, stream); base_size = dt->shared->parent->shared->size; for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - size_t k; + size_t k; HDfprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]); for (k = 0; k < base_size; k++) - HDfprintf(stream, "%02p", ((uint8_t *)dt->shared->u.enumer.value + (i * base_size) + k)); + HDfprintf(stream, "%02" PRIx8, + *((uint8_t *)dt->shared->u.enumer.value + (i * base_size) + k)); } /* end for */ HDfprintf(stream, "\n"); } @@ -433,4 +420,3 @@ H5T_debug(const H5T_t *dt, FILE *stream) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_debug() */ - diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 17e4a825a45..116d34cfce6 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -29,59 +29,57 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppublic.h" /* Property Lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5Tcommit1 * @@ -100,34 +98,52 @@ herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *dt; /* Datatype for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + 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 */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, type_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) + if (H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object from the loc_id */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Commit the datatype */ - if(H5T__commit_named(&loc, name, dt, H5P_LINK_CREATE_DEFAULT, H5P_DATATYPE_CREATE_DEFAULT) < 0) + if (NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, H5P_LINK_CREATE_DEFAULT, + H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Set up VOL object */ + if (NULL == (new_obj = H5VL_create_object(data, vol_obj->connector))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype") + + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ + dt->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit1() */ - /*------------------------------------------------------------------------- * Function: H5Topen1 * @@ -147,34 +163,40 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) hid_t H5Topen1(hid_t loc_id, const char *name) { - H5T_t *type = NULL; - H5G_loc_t loc; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + 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 */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) + if (NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ - if(H5I_INVALID_HID == ret_value) - if(type && H5T_close(type) < 0) + if (H5I_INVALID_HID == ret_value) + if (dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Tenum.c b/src/H5Tenum.c index e1d824610f2..2843ac579fd 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,23 +16,18 @@ * in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#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 herr_t H5T__enum_valueof(const H5T_t *dt, const char *name, - void *value/*out*/); - +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*/); - /*------------------------------------------------------------------------- * Function: H5Tenum_create * @@ -51,30 +46,30 @@ static herr_t H5T__enum_valueof(const H5T_t *dt, const char *name, hid_t H5Tenum_create(hid_t parent_id) { - H5T_t *parent = NULL; /*base integer data type */ - H5T_t *dt = NULL; /*new enumeration data type */ - hid_t ret_value; /*return value */ + H5T_t *parent = NULL; /*base integer data type */ + H5T_t *dt = NULL; /*new enumeration data type */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", parent_id); /* Check args */ - if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_INTEGER != parent->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an integer data type") + if (NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || + H5T_INTEGER != parent->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an integer data type") /* Build new type */ - if(NULL == (dt = H5T__enum_create(parent))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "cannot create enum type") + if (NULL == (dt = H5T__enum_create(parent))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "cannot create enum type") /* Atomize the type */ - if ((ret_value=H5I_register(H5I_DATATYPE, dt, TRUE))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type atom") + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type atom") done: FUNC_LEAVE_API(ret_value) } /* end H5Tenum_create() */ - /*------------------------------------------------------------------------- * Function: H5T__enum_create * @@ -94,16 +89,16 @@ H5Tenum_create(hid_t parent_id) H5T_t * H5T__enum_create(const H5T_t *parent) { - H5T_t *ret_value = NULL; /* New enumeration data type */ + H5T_t *ret_value = NULL; /* New enumeration data type */ FUNC_ENTER_PACKAGE HDassert(parent); /* Build new type */ - if(NULL == (ret_value = H5T__alloc())) + if (NULL == (ret_value = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - ret_value->shared->type = H5T_ENUM; + ret_value->shared->type = H5T_ENUM; ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL); HDassert(ret_value->shared->parent); ret_value->shared->size = ret_value->shared->parent->shared->size; @@ -112,7 +107,6 @@ H5T__enum_create(const H5T_t *parent) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tenum_insert * @@ -135,31 +129,30 @@ H5T__enum_create(const H5T_t *parent) herr_t H5Tenum_insert(hid_t type, const char *name, const void *value) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*x", type, name, value); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified") /* Do work */ - if(H5T__enum_insert(dt, name, value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") + if (H5T__enum_insert(dt, name, value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__enum_insert * @@ -180,8 +173,8 @@ H5Tenum_insert(hid_t type, const char *name, const void *value) herr_t H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) { - unsigned i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -190,32 +183,33 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) HDassert(value); /* The name and value had better not already exist */ - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) { - if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") - if(!HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, dt->shared->size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { + if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") + if (!HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, + dt->shared->size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") } /* Increase table sizes */ - if(dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { - char **names; - uint8_t *values; - unsigned n = MAX(32, 2*dt->shared->u.enumer.nalloc); - - if(NULL == (names = (char **)H5MM_realloc(dt->shared->u.enumer.name, n * sizeof(char *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->shared->u.enumer.name = names; - - if(NULL == (values = (uint8_t *)H5MM_realloc(dt->shared->u.enumer.value, n * dt->shared->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->shared->u.enumer.value = values; - dt->shared->u.enumer.nalloc = n; + if (dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { + char ** names; + uint8_t *values; + unsigned n = MAX(32, 2 * dt->shared->u.enumer.nalloc); + + if (NULL == (names = (char **)H5MM_realloc(dt->shared->u.enumer.name, n * sizeof(char *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + dt->shared->u.enumer.name = names; + + if (NULL == (values = (uint8_t *)H5MM_realloc(dt->shared->u.enumer.value, n * dt->shared->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + dt->shared->u.enumer.value = values; + dt->shared->u.enumer.nalloc = n; } /* Insert new member at end of member arrays */ - dt->shared->u.enumer.sorted = H5T_SORT_NONE; - i = dt->shared->u.enumer.nmembs++; + dt->shared->u.enumer.sorted = H5T_SORT_NONE; + i = dt->shared->u.enumer.nmembs++; dt->shared->u.enumer.name[i] = H5MM_xstrdup(name); H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (i * dt->shared->size), value, dt->shared->size); @@ -223,7 +217,6 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_member_value * @@ -240,30 +233,29 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) *------------------------------------------------------------------------- */ herr_t -H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) +H5Tget_member_value(hid_t type, unsigned membno, void *value /*out*/) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iIux", type, membno, value); - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") - if (membno>=dt->shared->u.enumer.nmembs) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") + if (membno >= dt->shared->u.enumer.nmembs) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") - if(H5T__get_member_value(dt, membno, value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") + if (H5T__get_member_value(dt, membno, value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__get_member_value * @@ -281,7 +273,7 @@ H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) *------------------------------------------------------------------------- */ herr_t -H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) +H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value /*out*/) { FUNC_ENTER_PACKAGE_NOERR @@ -293,8 +285,6 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) FUNC_LEAVE_NOAPI(SUCCEED) } - - /*------------------------------------------------------------------------- * Function: H5Tenum_nameof * @@ -316,32 +306,31 @@ H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size) +H5Tenum_nameof(hid_t type, const void *value, char *name /*out*/, size_t size) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*xxz", type, value, name, size); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") if (!name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied") - if (NULL==H5T__enum_nameof(dt, value, name, size)) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") + if (NULL == H5T__enum_nameof(dt, value, name, size)) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__enum_nameof * @@ -366,13 +355,13 @@ 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__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 */ - 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 */ + 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 */ FUNC_ENTER_STATIC @@ -381,61 +370,61 @@ H5T__enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t s HDassert(value); HDassert(name || 0 == size); - if(name && size > 0) + if (name && size > 0) *name = '\0'; /* Sanity check */ - if(dt->shared->u.enumer.nmembs == 0) + if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members") /* Do a binary search over the values to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ - if(NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type") - if(H5T__sort_value(copied_dt, NULL) < 0) + if (NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type") + if (H5T__sort_value(copied_dt, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOMPARE, NULL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; - while(lt < rt) { - md = (lt + rt) / 2; - cmp = HDmemcmp(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), copied_dt->shared->size); - if(cmp < 0) - rt = md; - else if(cmp > 0) - lt = md + 1; - else - break; + while (lt < rt) { + md = (lt + rt) / 2; + cmp = HDmemcmp(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), + copied_dt->shared->size); + if (cmp < 0) + rt = md; + else if (cmp > 0) + lt = md + 1; + else + break; } /* end while */ /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ - if(cmp != 0) + if (cmp != 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined") /* Save result name */ - if(!name) { - if(NULL == (name = (char *)H5MM_malloc(HDstrlen(copied_dt->shared->u.enumer.name[md]) + 1))) + if (!name) { + if (NULL == (name = (char *)H5MM_malloc(HDstrlen(copied_dt->shared->u.enumer.name[md]) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); alloc_name = TRUE; } /* end if */ HDstrncpy(name, copied_dt->shared->u.enumer.name[md], size); - if(HDstrlen(copied_dt->shared->u.enumer.name[md]) >= size) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") + if (HDstrlen(copied_dt->shared->u.enumer.name[md]) >= size) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") /* Set return value */ ret_value = name; done: - if(copied_dt) - if(H5T_close_real(copied_dt) < 0) + if (copied_dt) + if (H5T_close_real(copied_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close data type"); - if(!ret_value && alloc_name) + if (!ret_value && alloc_name) H5MM_free(name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__enum_nameof() */ - /*------------------------------------------------------------------------- * Function: H5Tenum_valueof * @@ -454,32 +443,31 @@ H5T__enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t s *------------------------------------------------------------------------- */ herr_t -H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) +H5Tenum_valueof(hid_t type, const char *name, void *value /*out*/) { - H5T_t *dt; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*sx", type, name, value); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if(H5T_ENUM != dt->shared->type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(!value) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") - - if(H5T__enum_valueof(dt, name, value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + if (H5T_ENUM != dt->shared->type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if (!value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer") + + if (H5T__enum_valueof(dt, name, value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed") done: FUNC_LEAVE_API(ret_value) } /* H5Tenum_valueof() */ - /*------------------------------------------------------------------------- * Function: H5T__enum_valueof * @@ -498,17 +486,17 @@ H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) *------------------------------------------------------------------------- */ static herr_t -H5T__enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) +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 */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned lt, md = 0, rt; /*indices for binary search */ + int cmp = (-1); /*comparison result */ + H5T_t * copied_dt = NULL; /*do sorting in copied datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ - HDassert(dt && H5T_ENUM==dt->shared->type); + HDassert(dt && H5T_ENUM == dt->shared->type); HDassert(name && *name); HDassert(value); @@ -518,36 +506,38 @@ H5T__enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/) /* Do a binary search over the names to find the correct one. Do sorting * and search on the copied datatype to protect the original order. */ - if (NULL==(copied_dt=H5T_copy(dt, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); - if(H5T__sort_name(copied_dt, NULL) < 0) + if (NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type"); + if (H5T__sort_name(copied_dt, NULL) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") lt = 0; rt = copied_dt->shared->u.enumer.nmembs; - while (ltshared->u.enumer.name[md]); - if (cmp<0) { - rt = md; - } else if (cmp>0) { - lt = md+1; - } else { - break; - } + while (lt < rt) { + md = (lt + rt) / 2; + cmp = HDstrcmp(name, copied_dt->shared->u.enumer.name[md]); + if (cmp < 0) { + rt = md; + } + else if (cmp > 0) { + lt = md + 1; + } + else { + break; + } } /* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */ - if (cmp!=0) + if (cmp != 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type") - H5MM_memcpy(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), copied_dt->shared->size); + H5MM_memcpy(value, (uint8_t *)copied_dt->shared->u.enumer.value + (md * copied_dt->shared->size), + copied_dt->shared->size); done: - if(copied_dt) - if(H5T_close_real(copied_dt) < 0) + if (copied_dt) + if (H5T_close_real(copied_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type") FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Tfields.c b/src/H5Tfields.c index 8f5e20219bc..baeae6d446a 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,16 +16,14 @@ * enumerated & compound datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_nmembers * @@ -46,24 +44,23 @@ int H5Tget_nmembers(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - int ret_value; /* Return value */ + H5T_t *dt; /* Datatype to query */ + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if((ret_value = H5T_get_nmembers(dt)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot return member number") + if ((ret_value = H5T_get_nmembers(dt)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot return member number") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5T_get_nmembers * @@ -85,24 +82,23 @@ H5Tget_nmembers(hid_t type_id) int H5T_get_nmembers(const H5T_t *dt) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(dt); - if(H5T_COMPOUND == dt->shared->type) - ret_value = (int)dt->shared->u.compnd.nmembs; - else if(H5T_ENUM == dt->shared->type) - ret_value = (int)dt->shared->u.enumer.nmembs; + if (H5T_COMPOUND == dt->shared->type) + ret_value = (int)dt->shared->u.compnd.nmembs; + else if (H5T_ENUM == dt->shared->type) + ret_value = (int)dt->shared->u.enumer.nmembs; else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5Tget_member_name * @@ -124,24 +120,23 @@ H5T_get_nmembers(const H5T_t *dt) char * H5Tget_member_name(hid_t type_id, unsigned membno) { - H5T_t *dt = NULL; - char *ret_value; + H5T_t *dt = NULL; + char * ret_value; FUNC_ENTER_API(NULL) H5TRACE2("*s", "iIu", type_id, membno); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - if(NULL == (ret_value = H5T__get_member_name(dt, membno))) + if (NULL == (ret_value = H5T__get_member_name(dt, membno))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get member name") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__get_member_name * @@ -163,7 +158,7 @@ H5Tget_member_name(hid_t type_id, unsigned membno) char * H5T__get_member_name(H5T_t const *dt, unsigned membno) { - char *ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -171,13 +166,13 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) switch (dt->shared->type) { case H5T_COMPOUND: - if (membno>=dt->shared->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.compnd.memb[membno].name); break; case H5T_ENUM: - if (membno>=dt->shared->u.enumer.nmembs) + if (membno >= dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; @@ -201,7 +196,6 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_member_index * @@ -221,28 +215,28 @@ 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; - int ret_value=FAIL; - unsigned i; + H5T_t * dt = NULL; + int ret_value = FAIL; + unsigned i; FUNC_ENTER_API(FAIL) H5TRACE2("Is", "i*s", type_id, name); /* Check arguments */ HDassert(name); - if(NULL == (dt = (H5T_t*)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i = 0; i < dt->shared->u.compnd.nmembs; i++) - if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) + if (!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) break; case H5T_ENUM: - for(i = 0; i < dt->shared->u.enumer.nmembs; i++) - if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) + for (i = 0; i < dt->shared->u.enumer.nmembs; i++) + if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) break; @@ -265,7 +259,6 @@ H5Tget_member_index(hid_t type_id, const char *name) FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_index() */ - /*------------------------------------------------------------------------- * Function: H5T__sort_value * @@ -285,12 +278,12 @@ H5Tget_member_index(hid_t type_id, const char *name) herr_t H5T__sort_value(const H5T_t *dt, int *map) { - unsigned nmembs; /* Number of members for datatype */ - size_t size; - hbool_t swapped; /* Whether we've swapped fields */ - uint8_t tbuf[32]; - unsigned i, j; /* Local index variables */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned nmembs; /* Number of members for datatype */ + size_t size; + hbool_t swapped; /* Whether we've swapped fields */ + uint8_t tbuf[32]; + unsigned i, j; /* Local index variables */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -299,76 +292,78 @@ H5T__sort_value(const H5T_t *dt, int *map) HDassert(H5T_COMPOUND == dt->shared->type || H5T_ENUM == dt->shared->type); /* Use a bubble sort because we can short circuit */ - if(H5T_COMPOUND == dt->shared->type) { - if(H5T_SORT_VALUE != dt->shared->u.compnd.sorted) { - dt->shared->u.compnd.sorted = H5T_SORT_VALUE; - nmembs = dt->shared->u.compnd.nmembs; - for(i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { - for(j = 0, swapped = FALSE; j < i; j++) { - if(dt->shared->u.compnd.memb[j].offset > dt->shared->u.compnd.memb[j + 1].offset) { - H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; - dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; - dt->shared->u.compnd.memb[j + 1] = tmp; - if(map) { - int x = map[j]; - - map[j] = map[j + 1]; - map[j + 1] = x; - } /* end if */ - swapped = TRUE; - } /* end if */ - } /* end for */ - } /* end for */ + if (H5T_COMPOUND == dt->shared->type) { + if (H5T_SORT_VALUE != dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.compnd.nmembs; + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (dt->shared->u.compnd.memb[j].offset > dt->shared->u.compnd.memb[j + 1].offset) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; + dt->shared->u.compnd.memb[j + 1] = tmp; + if (map) { + int x = map[j]; + + map[j] = map[j + 1]; + map[j + 1] = x; + } /* end if */ + swapped = TRUE; + } /* end if */ + } /* end for */ + } /* end for */ #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for(i = 0; i < (nmembs - 1); i++) - HDassert(dt->shared->u.compnd.memb[i].offset < dt->shared->u.compnd.memb[i + 1].offset); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < (nmembs - 1); i++) + HDassert(dt->shared->u.compnd.memb[i].offset < dt->shared->u.compnd.memb[i + 1].offset); #endif - } /* end if */ - } else if(H5T_ENUM == dt->shared->type) { - if(H5T_SORT_VALUE != dt->shared->u.enumer.sorted) { - dt->shared->u.enumer.sorted = H5T_SORT_VALUE; - nmembs = dt->shared->u.enumer.nmembs; - size = dt->shared->size; - HDassert(size <= sizeof(tbuf)); - for(i = (nmembs - 1), swapped = TRUE; i > 0 && swapped; --i) { - for(j = 0, swapped = FALSE; j < i; j++) { - if(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (j * size), (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size) > 0) { - /* Swap names */ - char *tmp = dt->shared->u.enumer.name[j]; - dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; - dt->shared->u.enumer.name[j + 1] = tmp; - - /* Swap values */ - H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), - (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); - - /* Swap map */ - if(map) { - int x = map[j]; - - map[j] = map[j + 1]; - map[j + 1] = x; - } /* end if */ - - swapped = TRUE; - } /* end if */ - } /* end for */ - } /* end for */ + } /* end if */ + } + else if (H5T_ENUM == dt->shared->type) { + if (H5T_SORT_VALUE != dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; + HDassert(size <= sizeof(tbuf)); + for (i = (nmembs - 1), swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size) > 0) { + /* Swap names */ + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; + dt->shared->u.enumer.name[j + 1] = tmp; + + /* Swap values */ + H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); + + /* Swap map */ + if (map) { + int x = map[j]; + + map[j] = map[j + 1]; + map[j + 1] = x; + } /* end if */ + + swapped = TRUE; + } /* end if */ + } /* end for */ + } /* end for */ #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for(i = 0; i < (nmembs - 1); i++) - HDassert(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * size), (uint8_t *)dt->shared->u.enumer.value + ((i + 1) * size), size) < 0); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < (nmembs - 1); i++) + HDassert(HDmemcmp((uint8_t *)dt->shared->u.enumer.value + (i * size), + (uint8_t *)dt->shared->u.enumer.value + ((i + 1) * size), size) < 0); #endif - } /* end if */ - } /* end else */ + } /* end if */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__sort_value() */ - /*------------------------------------------------------------------------- * Function: H5T__sort_name * @@ -388,86 +383,85 @@ H5T__sort_value(const H5T_t *dt, int *map) herr_t H5T__sort_name(const H5T_t *dt, int *map) { - unsigned i, j, nmembs; - size_t size; - hbool_t swapped; - uint8_t tbuf[32]; + unsigned i, j, nmembs; + size_t size; + hbool_t swapped; + uint8_t tbuf[32]; FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(dt); - HDassert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); + HDassert(H5T_COMPOUND == dt->shared->type || H5T_ENUM == dt->shared->type); /* Use a bubble sort because we can short circuit */ - if (H5T_COMPOUND==dt->shared->type) { - if (H5T_SORT_NAME!=dt->shared->u.compnd.sorted) { - dt->shared->u.compnd.sorted = H5T_SORT_NAME; - nmembs = dt->shared->u.compnd.nmembs; - for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { - for (j=0, swapped=FALSE; jshared->u.compnd.memb[j].name, - dt->shared->u.compnd.memb[j+1].name)>0) { - H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; - dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; - dt->shared->u.compnd.memb[j+1] = tmp; - swapped = TRUE; - if (map) { - int x = map[j]; - map[j] = map[j+1]; - map[j+1] = x; - } - } - } - } + if (H5T_COMPOUND == dt->shared->type) { + if (H5T_SORT_NAME != dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.compnd.nmembs; + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDstrcmp(dt->shared->u.compnd.memb[j].name, dt->shared->u.compnd.memb[j + 1].name) > + 0) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j + 1]; + dt->shared->u.compnd.memb[j + 1] = tmp; + swapped = TRUE; + if (map) { + int x = map[j]; + map[j] = map[j + 1]; + map[j + 1] = x; + } + } + } + } #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for (i=0; ishared->u.compnd.memb[i].name, - dt->shared->u.compnd.memb[i+1].name)<0); - } + /* I never trust a sort :-) -RPM */ + for (i = 0; i < nmembs - 1; i++) { + HDassert(HDstrcmp(dt->shared->u.compnd.memb[i].name, dt->shared->u.compnd.memb[i + 1].name) < + 0); + } #endif - } - } else if (H5T_ENUM==dt->shared->type) { - if (H5T_SORT_NAME!=dt->shared->u.enumer.sorted) { - dt->shared->u.enumer.sorted = H5T_SORT_NAME; - nmembs = dt->shared->u.enumer.nmembs; - size = dt->shared->size; - HDassert(size<=sizeof(tbuf)); - for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { - for (j=0, swapped=FALSE; jshared->u.enumer.name[j], - dt->shared->u.enumer.name[j+1])>0) { - /* Swap names */ - char *tmp = dt->shared->u.enumer.name[j]; - dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; - dt->shared->u.enumer.name[j+1] = tmp; - - /* Swap values */ - H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), - (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); - H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); - - /* Swap map */ - if (map) { - int x = map[j]; - map[j] = map[j+1]; - map[j+1] = x; - } - - swapped = TRUE; - } - } - } + } + } + else if (H5T_ENUM == dt->shared->type) { + if (H5T_SORT_NAME != dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; + HDassert(size <= sizeof(tbuf)); + for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) { + for (j = 0, swapped = FALSE; j < i; j++) { + if (HDstrcmp(dt->shared->u.enumer.name[j], dt->shared->u.enumer.name[j + 1]) > 0) { + /* Swap names */ + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j + 1]; + dt->shared->u.enumer.name[j + 1] = tmp; + + /* Swap values */ + H5MM_memcpy(tbuf, (uint8_t *)dt->shared->u.enumer.value + (j * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + (j * size), + (uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), size); + H5MM_memcpy((uint8_t *)dt->shared->u.enumer.value + ((j + 1) * size), tbuf, size); + + /* Swap map */ + if (map) { + int x = map[j]; + map[j] = map[j + 1]; + map[j + 1] = x; + } + + swapped = TRUE; + } + } + } #ifndef NDEBUG - /* I never trust a sort :-) -RPM */ - for (i=0; ishared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); + /* I never trust a sort :-) -RPM */ + for (i = 0; i < nmembs - 1; i++) + HDassert(HDstrcmp(dt->shared->u.enumer.name[i], dt->shared->u.enumer.name[i + 1]) < 0); #endif - } + } } FUNC_LEAVE_NOAPI(SUCCEED) } - diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index 5270a9a4896..9527a5ad206 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,15 +16,13 @@ * integer) datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - /*------------------------------------------------------------------------- * Function: H5Tget_sign * @@ -42,14 +40,14 @@ H5T_sign_t H5Tget_sign(hid_t type_id) { - H5T_t *dt = NULL; - H5T_sign_t ret_value; + H5T_t * dt = NULL; + H5T_sign_t ret_value; FUNC_ENTER_API(H5T_SGN_ERROR) H5TRACE1("Ts", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer datatype") ret_value = H5T_get_sign(dt); @@ -58,7 +56,6 @@ H5Tget_sign(hid_t type_id) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T_get_sign * @@ -77,19 +74,19 @@ H5Tget_sign(hid_t type_id) H5T_sign_t H5T_get_sign(H5T_t const *dt) { - H5T_sign_t ret_value = H5T_SGN_ERROR; /* Return value */ + H5T_sign_t ret_value = H5T_SGN_ERROR; /* Return value */ FUNC_ENTER_NOAPI(H5T_SGN_ERROR) HDassert(dt); /* Defer to parent */ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; /* Check args */ - if (H5T_INTEGER!=dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") + if (H5T_INTEGER != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") /* Sign */ ret_value = dt->shared->u.atomic.u.i.sign; @@ -98,8 +95,6 @@ H5T_get_sign(H5T_t const *dt) FUNC_LEAVE_NOAPI(ret_value) } - - /*------------------------------------------------------------------------- * Function: H5Tset_sign * @@ -115,24 +110,24 @@ H5T_get_sign(H5T_t const *dt) herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTs", type_id, sign); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (sign < H5T_SGN_NONE || sign >= H5T_NSGN) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if (H5T_INTEGER!=dt->shared->type) + if (H5T_INTEGER != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ @@ -141,4 +136,3 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c index 0d224db9b32..b3fa724e5f1 100644 --- a/src/H5Tfloat.c +++ b/src/H5Tfloat.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,16 +16,13 @@ * datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /*generic functions */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5Tpkg.h" /*data-type functions */ -#include "H5private.h" /*generic functions */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5Tpkg.h" /*data-type functions */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_fields * @@ -47,40 +44,39 @@ *------------------------------------------------------------------------- */ herr_t -H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/, -size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/) +H5Tget_fields(hid_t type_id, size_t *spos /*out*/, size_t *epos /*out*/, size_t *esize /*out*/, + size_t *mpos /*out*/, size_t *msize /*out*/) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "ixxxxx", type_id, spos, epos, esize, mpos, msize); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Get values */ - if(spos) + if (spos) *spos = dt->shared->u.atomic.u.f.sign; - if(epos) + if (epos) *epos = dt->shared->u.atomic.u.f.epos; - if(esize) + if (esize) *esize = dt->shared->u.atomic.u.f.esize; - if(mpos) + if (mpos) *mpos = dt->shared->u.atomic.u.f.mpos; - if(msize) + if (msize) *msize = dt->shared->u.atomic.u.f.msize; done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_fields() */ - /*------------------------------------------------------------------------- * Function: H5Tset_fields * @@ -100,43 +96,42 @@ size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/) *------------------------------------------------------------------------- */ herr_t -H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, - size_t mpos, size_t msize) +H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "izzzzz", type_id, spos, epos, esize, mpos, msize); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") - if(epos + esize > dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") - if(mpos + msize > dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") - if(spos >= dt->shared->u.atomic.prec) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (epos + esize > dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") + if (mpos + msize > dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") + if (spos >= dt->shared->u.atomic.prec) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") /* Check for overlap */ - if(spos >= epos && spos < epos + esize) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field") - if(spos >= mpos && spos < mpos + msize) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field") - if((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") + if (spos >= epos && spos < epos + esize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field") + if (spos >= mpos && spos < mpos + msize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field") + if ((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") /* Commit */ - dt->shared->u.atomic.u.f.sign = spos; - dt->shared->u.atomic.u.f.epos = epos; - dt->shared->u.atomic.u.f.mpos = mpos; + dt->shared->u.atomic.u.f.sign = spos; + dt->shared->u.atomic.u.f.epos = epos; + dt->shared->u.atomic.u.f.mpos = mpos; dt->shared->u.atomic.u.f.esize = esize; dt->shared->u.atomic.u.f.msize = msize; @@ -144,7 +139,6 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, FUNC_LEAVE_API(ret_value) } /* end H5Tset_fields() */ - /*------------------------------------------------------------------------- * Function: H5Tget_ebias * @@ -162,19 +156,19 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t H5Tget_ebias(hid_t type_id) { - H5T_t *dt; /* Datatype */ - size_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype */ + size_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, 0, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, 0, "operation not defined for datatype class") /* bias */ H5_CHECKED_ASSIGN(ret_value, size_t, dt->shared->u.atomic.u.f.ebias, uint64_t); @@ -183,7 +177,6 @@ H5Tget_ebias(hid_t type_id) FUNC_LEAVE_API(ret_value) } /* end H5Tget_ebias() */ - /*------------------------------------------------------------------------- * Function: H5Tset_ebias * @@ -199,21 +192,21 @@ H5Tget_ebias(hid_t type_id) herr_t H5Tset_ebias(hid_t type_id, size_t ebias) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, ebias); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.ebias = ebias; @@ -222,7 +215,6 @@ H5Tset_ebias(hid_t type_id, size_t ebias) FUNC_LEAVE_API(ret_value) } /* end H5Tset_ebias() */ - /*------------------------------------------------------------------------- * Function: H5Tget_norm * @@ -241,19 +233,19 @@ H5Tset_ebias(hid_t type_id, size_t ebias) H5T_norm_t H5Tget_norm(hid_t type_id) { - H5T_t *dt; /* Datatype */ - H5T_norm_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype */ + H5T_norm_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NORM_ERROR) H5TRACE1("Tn", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_NORM_ERROR, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_NORM_ERROR, "operation not defined for datatype class") /* norm */ ret_value = dt->shared->u.atomic.u.f.norm; @@ -262,7 +254,6 @@ H5Tget_norm(hid_t type_id) FUNC_LEAVE_API(ret_value) } /* end H5Tget_norm() */ - /*------------------------------------------------------------------------- * Function: H5Tset_norm * @@ -279,23 +270,23 @@ H5Tget_norm(hid_t type_id) herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTn", type_id, norm); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - if(norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.norm = norm; @@ -304,7 +295,6 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm) FUNC_LEAVE_API(ret_value) } /* end H5Tset_norm() */ - /*------------------------------------------------------------------------- * Function: H5Tget_inpad * @@ -325,19 +315,19 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm) H5T_pad_t H5Tget_inpad(hid_t type_id) { - H5T_t *dt; /* Datatype */ - H5T_pad_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype */ + H5T_pad_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_PAD_ERROR) H5TRACE1("Tp", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_PAD_ERROR, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_PAD_ERROR, "operation not defined for datatype class") /* pad */ ret_value = dt->shared->u.atomic.u.f.pad; @@ -346,7 +336,6 @@ H5Tget_inpad(hid_t type_id) FUNC_LEAVE_API(ret_value) } /* end H5Tget_inpad() */ - /*------------------------------------------------------------------------- * Function: H5Tset_inpad * @@ -365,23 +354,23 @@ H5Tget_inpad(hid_t type_id) herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad) { - H5T_t *dt; /* Datatype */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Datatype */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTp", type_id, pad); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_TRANSIENT != dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") - if(pad < H5T_PAD_ZERO || pad >= H5T_NPAD) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") - while(dt->shared->parent) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (pad < H5T_PAD_ZERO || pad >= H5T_NPAD) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") + while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if(H5T_FLOAT != dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") + if (H5T_FLOAT != dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class") /* Commit */ dt->shared->u.atomic.u.f.pad = pad; @@ -389,4 +378,3 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad) done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_inpad() */ - diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index f8f57ac81cf..c489edc56c3 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,87 @@ * H5T package. Including this header means that the source file * is part of the H5T package. */ -#ifndef _H5Tmodule_H -#define _H5Tmodule_H +#ifndef H5Tmodule_H +#define H5Tmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5T_MODULE -#define H5_MY_PKG H5T -#define H5_MY_PKG_ERR H5E_DATATYPE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5T +#define H5_MY_PKG_ERR H5E_DATATYPE +#define H5_MY_PKG_INIT YES -#endif /* _H5Tmodule_H */ +/** + * \defgroup H5T H5T + * \brief Datatype Interface + * \todo Describe concisely what the functions in this module are about. + * + * \defgroup ARRAY Array Datatypes + * \ingroup H5T + * \defgroup ATOM Atomic Datatypes + * \ingroup H5T + * \defgroup COMPOUND Compound Datatypes + * \ingroup H5T + * \defgroup CONV Conversion Function + * \ingroup H5T + * \defgroup ENUM Enumeration Datatypes + * \ingroup H5T + * \defgroup OPAQUE Opaque Datatypes + * \ingroup H5T + * \defgroup VLEN Variable-length Sequence Datatypes + * \ingroup H5T + * + * \defgroup PDT Predefined Datatypes + * \ingroup H5T + * \details What is a predefined HDF5 datatype? + * \todo Fill in the blanks! + * + * \defgroup PDTCPU By CPU + * \ingroup PDT + * \details CPU-specific datatypes + * \defgroup PDTALPHA DEC Alpha + * \ingroup PDTCPU + * \defgroup PDTX86 AMD & INTEL + * \ingroup PDTCPU + * \defgroup PDTMIPS SGI MIPS + * \ingroup PDTCPU + * + * \defgroup PDTIEEE IEEE + * \ingroup PDT + * \details The IEEE floating point types in big- and little-endian byte orders. + * + * \defgroup PDTSTD Standard Datatypes + * \ingroup PDT + * \details These are "standard" types. For instance, signed (2's complement) + * and unsigned integers of various sizes in big- and little-endian + * byte orders. + * + * \defgroup PDTUNIX UNIX-specific Datatypes + * \ingroup PDT + * \details Types which are particular to Unix. + * \todo Fill in the blanks! + * + * \defgroup PDTNAT Native Datatypes + * \ingroup PDT + * \details These are the datatypes detected during library \Emph{compilation} + * by \c H5detect(). Their names differ from other HDF5 datatype names + * as follows: + * \li Instead of a class name, precision and byte order as the last + * component, they have a C-like type name. + * \li If the type begins with \c U then it is the unsigned version of + * the integer type; other integer types are signed. + * \li The datatype \c LLONG corresponds C's \Code{long long} and + * \c LDOUBLE is \Code{long double}. These types might be the same + * as \c LONG and \c DOUBLE, respectively. + * \defgroup PDTC9x C9x Integer Datatypes + * \ingroup PDTNAT + * \details C9x integer types + * \todo Fill in the blanks! + * + * \defgroup PDTS Strings + * \ingroup PDT + * + */ +#endif /* H5Tmodule_H */ diff --git a/src/H5Tnative.c b/src/H5Tnative.c index c4a57751e9c..2688b235034 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,32 +16,28 @@ * a "native" datatype for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ -static H5T_t *H5T__get_native_type(H5T_t *dt, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static H5T_t *H5T__get_native_integer(size_t prec, H5T_sign_t sign, - H5T_direction_t direction, size_t *struct_align, size_t *offset, - size_t *comp_size); -static H5T_t *H5T__get_native_float(size_t size, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static H5T_t* H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size); -static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, - size_t nelems, size_t align, size_t *struct_align); - - - +static H5T_t *H5T__get_native_type(H5T_t *dt, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size); +static H5T_t *H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, + size_t *struct_align, size_t *offset, size_t *comp_size); +static H5T_t *H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size); +static H5T_t *H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size); +static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, + size_t align, size_t *struct_align); + /*------------------------------------------------------------------------- * Function: H5Tget_native_type * @@ -75,39 +71,37 @@ static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_siz hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction) { - H5T_t *dt; /* Datatype to create native datatype from */ - H5T_t *new_dt = NULL; /* Datatype for native datatype created */ - size_t comp_size = 0; /* Compound datatype's size */ - hid_t ret_value; /* Return value */ + H5T_t *dt; /* Datatype to create native datatype from */ + H5T_t *new_dt = NULL; /* Datatype for native datatype created */ + size_t comp_size = 0; /* Compound datatype's size */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "iTd", type_id, direction); /* Check arguments */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a data type") - if(direction != H5T_DIR_DEFAULT && direction != H5T_DIR_ASCEND - && direction != H5T_DIR_DESCEND) + if (direction != H5T_DIR_DEFAULT && direction != H5T_DIR_ASCEND && direction != H5T_DIR_DESCEND) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not valid direction value") /* Get the native type */ - if(NULL == (new_dt = H5T__get_native_type(dt, direction, NULL, NULL, &comp_size))) + if (NULL == (new_dt = H5T__get_native_type(dt, direction, NULL, NULL, &comp_size))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "cannot retrieve native type") /* Get an ID for the new type */ - if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register data type") done: /* Error cleanup */ - if(ret_value < 0) - if(new_dt && H5T_close_real(new_dt) < 0) + if (ret_value < 0) + if (new_dt && H5T_close_real(new_dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Tget_native_type() */ - /*------------------------------------------------------------------------- * Function: H5T__get_native_type * @@ -123,72 +117,74 @@ H5Tget_native_type(hid_t type_id, H5T_direction_t direction) *------------------------------------------------------------------------- */ static H5T_t * -H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align, - size_t *offset, size_t *comp_size) +H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *dt; /* Datatype to make native */ - H5T_t *super_type; /* Super type of VL, array and enum datatypes */ - H5T_t *nat_super_type; /* Native form of VL, array & enum super datatype */ - H5T_t *new_type = NULL; /* New native datatype */ - H5T_t *memb_type = NULL; /* Datatype of member */ - H5T_t **memb_list = NULL; /* List of compound member IDs */ - size_t *memb_offset = NULL; /* List of member offsets in compound type, including member size and alignment */ - char **comp_mname = NULL; /* List of member names in compound type */ - char *memb_name = NULL; /* Enum's member name */ - void *memb_value = NULL; /* Enum's member value */ - void *tmp_memb_value = NULL; /* Enum's member value */ - hsize_t *dims = NULL; /* Dimension sizes for array */ - H5T_class_t h5_class; /* Class of datatype to make native */ - size_t size; /* Size of datatype to make native */ - size_t prec; /* Precision of datatype to make native */ - int snmemb; /* Number of members in compound & enum types */ - unsigned nmemb = 0; /* Number of members in compound & enum types */ - unsigned u; /* Local index variable */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t * super_type; /* Super type of VL, array and enum datatypes */ + H5T_t * nat_super_type; /* Native form of VL, array & enum super datatype */ + H5T_t * new_type = NULL; /* New native datatype */ + H5T_t * memb_type = NULL; /* Datatype of member */ + H5T_t **memb_list = NULL; /* List of compound member IDs */ + size_t *memb_offset = + NULL; /* List of member offsets in compound type, including member size and alignment */ + char ** comp_mname = NULL; /* List of member names in compound type */ + char * memb_name = NULL; /* Enum's member name */ + void * memb_value = NULL; /* Enum's member value */ + void * tmp_memb_value = NULL; /* Enum's member value */ + hsize_t * dims = NULL; /* Dimension sizes for array */ + H5T_class_t h5_class; /* Class of datatype to make native */ + size_t size; /* Size of datatype to make native */ + size_t prec; /* Precision of datatype to make native */ + int snmemb; /* Number of members in compound & enum types */ + unsigned nmemb = 0; /* Number of members in compound & enum types */ + unsigned u; /* Local index variable */ + H5T_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(dtype); - if(H5T_NO_CLASS == (h5_class = H5T_get_class(dtype, FALSE))) + if (H5T_NO_CLASS == (h5_class = H5T_get_class(dtype, FALSE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid class") - if(0 == (size = H5T_get_size(dtype))) + if (0 == (size = H5T_get_size(dtype))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid size") - switch(h5_class) { - case H5T_INTEGER: - { - H5T_sign_t sign; /* Signedness of integer type */ + switch (h5_class) { + case H5T_INTEGER: { + H5T_sign_t sign; /* Signedness of integer type */ - if(H5T_SGN_ERROR == (sign = H5T_get_sign(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") + if (H5T_SGN_ERROR == (sign = H5T_get_sign(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") - prec = dtype->shared->u.atomic.prec; + prec = dtype->shared->u.atomic.prec; - if(NULL == (ret_value = H5T__get_native_integer(prec, sign, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") - } /* end case */ - break; + if (NULL == + (ret_value = H5T__get_native_integer(prec, sign, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") + } /* end case */ + break; case H5T_FLOAT: - if(NULL == (ret_value = H5T__get_native_float(size, direction, struct_align, offset, comp_size))) + if (NULL == (ret_value = H5T__get_native_float(size, direction, struct_align, offset, comp_size))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") break; case H5T_STRING: - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") - if(H5T_IS_VL_STRING(dtype->shared)) { + if (H5T_IS_VL_STRING(dtype->shared)) { /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char *), (size_t)1, H5T_POINTER_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } /* end if */ else { /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") } /* end else */ break; @@ -198,285 +194,300 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali case H5T_TIME: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "time type is not supported yet") - case H5T_BITFIELD: - { - prec = dtype->shared->u.atomic.prec; + case H5T_BITFIELD: { + prec = dtype->shared->u.atomic.prec; - if(NULL == (ret_value = H5T__get_native_bitfield(prec, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer for bitfield type") - } /* end case */ - break; + if (NULL == + (ret_value = H5T__get_native_bitfield(prec, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer for bitfield type") + } /* end case */ + break; case H5T_OPAQUE: - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* Update size, offset and compound alignment for parent. */ - if(H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, struct_align) < 0) + if (H5T__cmp_offset(comp_size, offset, sizeof(char), size, H5T_NATIVE_SCHAR_COMP_ALIGN_g, + struct_align) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") break; - case H5T_REFERENCE: - { - size_t align; - size_t ref_size; - int not_equal; + case H5T_REFERENCE: { + H5T_t *dt; /* Datatype to make native */ + size_t align; + size_t ref_size; - if(NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy reference type") + if (NULL == (ret_value = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy reference type") - /* Decide if the data type is object or dataset region reference. */ - if(NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_OBJ_g))) + /* Decide if the data type is object reference. */ + if (NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_OBJ_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") + + /* Update size, offset and compound alignment for parent. */ + if (0 == H5T_cmp(ret_value, dt, FALSE)) { + align = H5T_HOBJREF_COMP_ALIGN_g; + ref_size = sizeof(hobj_ref_t); + } /* end if */ + else { + /* Decide if the data type is dataset region reference. */ + if (NULL == (dt = (H5T_t *)H5I_object(H5T_STD_REF_DSETREG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - not_equal = H5T_cmp(ret_value, dt, FALSE); - /* Update size, offset and compound alignment for parent. */ - if(!not_equal) { - align = H5T_HOBJREF_COMP_ALIGN_g; - ref_size = sizeof(hobj_ref_t); + if (0 == H5T_cmp(ret_value, dt, FALSE)) { + align = H5T_HDSETREGREF_COMP_ALIGN_g; + ref_size = sizeof(hdset_reg_ref_t); } /* end if */ else { - align = H5T_HDSETREGREF_COMP_ALIGN_g; - ref_size = sizeof(hdset_reg_ref_t); + /* Only pointers to underlying opaque reference types */ + align = H5T_REF_COMP_ALIGN_g; + ref_size = sizeof(H5R_ref_t); } /* end else */ + } /* end else */ - if(H5T__cmp_offset(comp_size, offset, ref_size, (size_t)1, align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - } /* end case */ - break; + if (H5T__cmp_offset(comp_size, offset, ref_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + } /* end case */ + break; + + case H5T_COMPOUND: { + size_t children_size = 0; /* Total size of compound members */ + size_t children_st_align = + 0; /* The max alignment among compound members. This'll be the compound alignment */ + + if ((snmemb = H5T_get_nmembers(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") + H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); + + if (NULL == (memb_list = (H5T_t **)H5MM_calloc(nmemb * sizeof(H5T_t *)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (memb_offset = (size_t *)H5MM_calloc(nmemb * sizeof(size_t)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (comp_mname = (char **)H5MM_calloc(nmemb * sizeof(char *)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + + /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and + * alignment for compound type. */ + for (u = 0; u < nmemb; u++) { + if (NULL == (memb_type = H5T_get_member_type(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") + + if (NULL == (comp_mname[u] = H5T__get_member_name(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") + + if (NULL == (memb_list[u] = H5T__get_native_type(memb_type, direction, &children_st_align, + &(memb_offset[u]), &children_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed") + + if (H5T_close_real(memb_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + } /* end for */ + + /* The alignment for whole compound type */ + if (children_st_align && children_size % children_st_align) + children_size += children_st_align - (children_size % children_st_align); + + /* Construct new compound type based on native type */ + if (NULL == (new_type = H5T__create(H5T_COMPOUND, children_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type") + + /* Insert members for the new compound type */ + for (u = 0; u < nmemb; u++) + if (H5T__insert(new_type, comp_mname[u], memb_offset[u], memb_list[u]) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype") + + /* Update size, offset and compound alignment for parent in the case of + * nested compound type. The alignment for a compound type as one field in + * a compound type is the biggest compound alignment among all its members. + * e.g. in the structure + * typedef struct s1 { + * char c; + * int i; + * s2 st; + * unsigned long long l; + * } s1; + * typedef struct s2 { + * short c2; + * long l2; + * long long ll2; + * } s2; + * The alignment for ST in S1 is the biggest structure alignment of all the + * members of S2, which is probably the LL2 of 'long long'. -SLU 2010/4/28 + */ + if (H5T__cmp_offset(comp_size, offset, children_size, (size_t)1, children_st_align, + struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - case H5T_COMPOUND: - { - size_t children_size = 0;/* Total size of compound members */ - size_t children_st_align = 0; /* The max alignment among compound members. This'll be the compound alignment */ - - if((snmemb = H5T_get_nmembers(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "compound data type doesn't have any member") - H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); - - if(NULL == (memb_list = (H5T_t **)H5MM_calloc(nmemb * sizeof(H5T_t *)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (memb_offset = (size_t *)H5MM_calloc(nmemb * sizeof(size_t)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (comp_mname = (char **)H5MM_calloc(nmemb * sizeof(char *)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - - /* Construct child compound type and retrieve a list of their IDs, offsets, total size, and alignment for compound type. */ - for(u = 0; u < nmemb; u++) { - if(NULL == (memb_type = H5T_get_member_type(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") - - if(NULL == (comp_mname[u] = H5T__get_member_name(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member type retrieval failed") - - if(NULL == (memb_list[u] = H5T__get_native_type(memb_type, direction, &children_st_align, &(memb_offset[u]), &children_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "member identifier retrieval failed") - - if(H5T_close_real(memb_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - } /* end for */ - - /* The alignment for whole compound type */ - if(children_st_align && children_size % children_st_align) - children_size += children_st_align - (children_size % children_st_align); - - /* Construct new compound type based on native type */ - if(NULL == (new_type = H5T__create(H5T_COMPOUND, children_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot create a compound type") - - /* Insert members for the new compound type */ - for(u = 0; u < nmemb; u++) - if(H5T__insert(new_type, comp_mname[u], memb_offset[u], memb_list[u]) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member to compound datatype") - - /* Update size, offset and compound alignment for parent in the case of - * nested compound type. The alignment for a compound type as one field in - * a compound type is the biggest compound alignment among all its members. - * e.g. in the structure - * typedef struct s1 { - * char c; - * int i; - * s2 st; - * unsigned long long l; - * } s1; - * typedef struct s2 { - * short c2; - * long l2; - * long long ll2; - * } s2; - * The alignment for ST in S1 is the biggest structure alignment of all the - * members of S2, which is probably the LL2 of 'long long'. -SLU 2010/4/28 - */ - if(H5T__cmp_offset(comp_size, offset, children_size, (size_t)1, children_st_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + /* Close member data type */ + for (u = 0; u < nmemb; u++) { + if (H5T_close_real(memb_list[u]) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - /* Close member data type */ - for(u = 0; u < nmemb; u++) { - if(H5T_close_real(memb_list[u]) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Free member names in list */ + comp_mname[u] = (char *)H5MM_xfree(comp_mname[u]); + } /* end for */ + + /* Free lists for members */ + memb_list = (H5T_t **)H5MM_xfree(memb_list); + memb_offset = (size_t *)H5MM_xfree(memb_offset); + comp_mname = (char **)H5MM_xfree(comp_mname); + + ret_value = new_type; + } /* end case */ + break; + + case H5T_ENUM: { + H5T_path_t *tpath; /* Type conversion info */ + hid_t super_type_id, nat_super_type_id; + + /* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. + */ + + /* Retrieve base type for enumerated type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumerate type") + if (NULL == (nat_super_type = + H5T__get_native_type(super_type, direction, struct_align, offset, comp_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed") + + if ((super_type_id = H5I_register(H5I_DATATYPE, super_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") + if ((nat_super_type_id = H5I_register(H5I_DATATYPE, nat_super_type, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") + + /* Allocate room for the enum values */ + if (NULL == (tmp_memb_value = H5MM_calloc(H5T_get_size(super_type)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (NULL == (memb_value = H5MM_calloc(H5T_get_size(nat_super_type)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + + /* Construct new enum type based on native type */ + if (NULL == (new_type = H5T__enum_create(nat_super_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type") + + /* Find the conversion function */ + if (NULL == (tpath = H5T_path_find(super_type, nat_super_type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, + "unable to convert between src and dst data types") + + /* Retrieve member info and insert members into new enum type */ + if ((snmemb = H5T_get_nmembers(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member") + H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); + for (u = 0; u < nmemb; u++) { + if (NULL == (memb_name = H5T__get_member_name(dtype, u))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name") + if (H5T__get_member_value(dtype, u, tmp_memb_value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") + H5MM_memcpy(memb_value, tmp_memb_value, H5T_get_size(super_type)); + + if (H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, + memb_value, NULL) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") + + if (H5T__enum_insert(new_type, memb_name, memb_value) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member") + memb_name = (char *)H5MM_xfree(memb_name); + } + memb_value = H5MM_xfree(memb_value); + tmp_memb_value = H5MM_xfree(tmp_memb_value); + + /* Close base type */ + if (H5I_dec_app_ref(nat_super_type_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Close super type */ + if (H5I_dec_app_ref(super_type_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + + ret_value = new_type; + } /* end case */ + break; + + case H5T_ARRAY: { + int sarray_rank; /* Array's rank */ + unsigned array_rank; /* Array's rank */ + hsize_t nelems = 1; + size_t super_offset = 0; + size_t super_size = 0; + size_t super_align = 0; + + /* Retrieve dimension information for array data type */ + if ((sarray_rank = H5T__get_array_ndims(dtype)) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank") + H5_CHECKED_ASSIGN(array_rank, unsigned, sarray_rank, int); + if (NULL == (dims = (hsize_t *)H5MM_malloc(array_rank * sizeof(hsize_t)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") + if (H5T__get_array_dims(dtype, dims) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size") + + /* Retrieve base type for array type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for array type") + if (NULL == (nat_super_type = H5T__get_native_type(super_type, direction, &super_align, + &super_offset, &super_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") + + /* Close super type */ + if (H5T_close_real(super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") + + /* Create a new array type based on native type */ + if (NULL == (new_type = H5T__array_create(nat_super_type, array_rank, dims))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type") + + /* Close base type */ + if (H5T_close_real(nat_super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") + + for (u = 0; u < array_rank; u++) + nelems *= dims[u]; + H5_CHECK_OVERFLOW(nelems, hsize_t, size_t); + if (H5T__cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - /* Free member names in list */ - comp_mname[u] = (char *)H5MM_xfree(comp_mname[u]); - } /* end for */ + dims = (hsize_t *)H5MM_xfree(dims); - /* Free lists for members */ - memb_list = (H5T_t **)H5MM_xfree(memb_list); - memb_offset = (size_t *)H5MM_xfree(memb_offset); - comp_mname = (char **)H5MM_xfree(comp_mname); + ret_value = new_type; + } /* end case */ + break; - ret_value = new_type; - } /* end case */ - break; + case H5T_VLEN: { + size_t vl_align = 0; + size_t vl_size = 0; + size_t super_size = 0; - case H5T_ENUM: - { - H5T_path_t *tpath; /* Type conversion info */ - hid_t super_type_id, nat_super_type_id; - - /* Don't need to do anything special for alignment, offset since the ENUM type usually is integer. */ - - /* Retrieve base type for enumerated type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get base type for enumerate type") - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, struct_align, offset, comp_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "base native type retrieval failed") - - if((super_type_id = H5I_register(H5I_DATATYPE, super_type, FALSE)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") - if((nat_super_type_id = H5I_register(H5I_DATATYPE, nat_super_type, FALSE)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot register datatype") - - /* Allocate room for the enum values */ - if(NULL == (tmp_memb_value = H5MM_calloc(H5T_get_size(super_type)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(NULL == (memb_value = H5MM_calloc(H5T_get_size(nat_super_type)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - - /* Construct new enum type based on native type */ - if(NULL == (new_type = H5T__enum_create(nat_super_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create enum type") - - /* Find the conversion function */ - if(NULL == (tpath = H5T_path_find(super_type, nat_super_type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to convert between src and dst data types") - - /* Retrieve member info and insert members into new enum type */ - if((snmemb = H5T_get_nmembers(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "enumerate data type doesn't have any member") - H5_CHECKED_ASSIGN(nmemb, unsigned, snmemb, int); - for(u = 0; u < nmemb; u++) { - if(NULL == (memb_name = H5T__get_member_name(dtype, u))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member name") - if(H5T__get_member_value(dtype, u, tmp_memb_value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") - H5MM_memcpy(memb_value, tmp_memb_value, H5T_get_size(super_type)); - - if(H5T_convert(tpath, super_type_id, nat_super_type_id, (size_t)1, (size_t)0, (size_t)0, memb_value, NULL) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get member value") - - if(H5T__enum_insert(new_type, memb_name, memb_value) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot insert member") - memb_name = (char *)H5MM_xfree(memb_name); - } - memb_value = H5MM_xfree(memb_value); - tmp_memb_value = H5MM_xfree(tmp_memb_value); - - /* Close base type */ - if(H5I_dec_app_ref(nat_super_type_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") - /* Close super type */ - if(H5I_dec_app_ref(super_type_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + /* Retrieve base type for array type */ + if (NULL == (super_type = H5T_get_super(dtype))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for VL type") + /* Don't need alignment, offset information if this VL isn't a field of compound type. If it + * is, go to a few steps below to compute the information directly. */ + if (NULL == + (nat_super_type = H5T__get_native_type(super_type, direction, NULL, NULL, &super_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - ret_value = new_type; - } /* end case */ - break; + /* Close super type */ + if (H5T_close_real(super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - case H5T_ARRAY: - { - int sarray_rank; /* Array's rank */ - unsigned array_rank; /* Array's rank */ - hsize_t nelems = 1; - size_t super_offset = 0; - size_t super_size = 0; - size_t super_align = 0; - - /* Retrieve dimension information for array data type */ - if((sarray_rank = H5T__get_array_ndims(dtype)) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension rank") - H5_CHECKED_ASSIGN(array_rank, unsigned, sarray_rank, int); - if(NULL == (dims = (hsize_t*)H5MM_malloc(array_rank * sizeof(hsize_t)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot allocate memory") - if(H5T__get_array_dims(dtype, dims) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot get dimension size") - - /* Retrieve base type for array type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for array type") - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, &super_align, - &super_offset, &super_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - - /* Close super type */ - if(H5T_close_real(super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Create a new array type based on native type */ - if(NULL == (new_type = H5T__array_create(nat_super_type, array_rank, dims))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create array type") - - /* Close base type */ - if(H5T_close_real(nat_super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - for(u = 0; u < array_rank; u++) - nelems *= dims[u]; - H5_CHECK_OVERFLOW(nelems, hsize_t, size_t); - if(H5T__cmp_offset(comp_size, offset, super_size, (size_t)nelems, super_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + /* Create a new array type based on native type */ + if (NULL == (new_type = H5T__vlen_create(nat_super_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type") - dims = (hsize_t *)H5MM_xfree(dims); + /* Close base type */ + if (H5T_close_real(nat_super_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - ret_value = new_type; - } /* end case */ - break; + /* Update size, offset and compound alignment for parent compound type directly. */ + vl_align = H5T_HVL_COMP_ALIGN_g; + vl_size = sizeof(hvl_t); - case H5T_VLEN: - { - size_t vl_align = 0; - size_t vl_size = 0; - size_t super_size = 0; - - /* Retrieve base type for array type */ - if(NULL == (super_type = H5T_get_super(dtype))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to get parent type for VL type") - /* Don't need alignment, offset information if this VL isn't a field of compound type. If it - * is, go to a few steps below to compute the information directly. */ - if(NULL == (nat_super_type = H5T__get_native_type(super_type, direction, NULL, NULL, &super_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "parent native type retrieval failed") - - /* Close super type */ - if(H5T_close_real(super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Create a new array type based on native type */ - if(NULL == (new_type = H5T__vlen_create(nat_super_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unable to create VL type") - - /* Close base type */ - if(H5T_close_real(nat_super_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CLOSEERROR, NULL, "cannot close datatype") - - /* Update size, offset and compound alignment for parent compound type directly. */ - vl_align = H5T_HVL_COMP_ALIGN_g; - vl_size = sizeof(hvl_t); - - if(H5T__cmp_offset(comp_size, offset, vl_size, (size_t)1, vl_align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, vl_size, (size_t)1, vl_align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") - ret_value = new_type; - } /* end case */ - break; + ret_value = new_type; + } /* end case */ + break; case H5T_NO_CLASS: case H5T_NCLASSES: @@ -486,30 +497,30 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali done: /* Error cleanup */ - if(NULL == ret_value) { - if(new_type) - if(H5T_close_real(new_type) < 0) + if (NULL == ret_value) { + if (new_type) + if (H5T_close_real(new_type) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") /* Free lists for members */ - if(memb_list) { - for(u = 0; u < nmemb; u++) - if(memb_list[u] && H5T_close_real(memb_list[u]) < 0) + if (memb_list) { + for (u = 0; u < nmemb; u++) + if (memb_list[u] && H5T_close_real(memb_list[u]) < 0) HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") memb_list = (H5T_t **)H5MM_xfree(memb_list); } /* end if */ memb_offset = (size_t *)H5MM_xfree(memb_offset); - if(comp_mname) { - for(u = 0; u < nmemb; u++) - if(comp_mname[u]) + if (comp_mname) { + for (u = 0; u < nmemb; u++) + if (comp_mname[u]) H5MM_xfree(comp_mname[u]); comp_mname = (char **)H5MM_xfree(comp_mname); } /* end if */ - memb_name = (char *)H5MM_xfree(memb_name); - memb_value = H5MM_xfree(memb_value); + memb_name = (char *)H5MM_xfree(memb_name); + memb_value = H5MM_xfree(memb_value); tmp_memb_value = H5MM_xfree(tmp_memb_value); - dims = (hsize_t *)H5MM_xfree(dims); + dims = (hsize_t *)H5MM_xfree(dims); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -521,8 +532,8 @@ H5T__get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_ali * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_integer * @@ -538,68 +549,78 @@ H5_GCC_DIAG_OFF(duplicated-branches) *------------------------------------------------------------------------- */ static H5T_t * -H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size) +H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, size_t *struct_align, + size_t *offset, size_t *comp_size) { - H5T_t *dt; /* Appropriate native datatype to copy */ - hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ - size_t align = 0; /* Alignment necessary for native datatype */ - size_t native_size = 0; /* Datatype size of the native type */ - enum match_type { /* The different kinds of integers we can match */ - H5T_NATIVE_INT_MATCH_CHAR, - H5T_NATIVE_INT_MATCH_SHORT, - H5T_NATIVE_INT_MATCH_INT, - H5T_NATIVE_INT_MATCH_LONG, - H5T_NATIVE_INT_MATCH_LLONG, - H5T_NATIVE_INT_MATCH_UNKNOWN - } match = H5T_NATIVE_INT_MATCH_UNKNOWN; - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + enum match_type { /* The different kinds of integers we can match */ + H5T_NATIVE_INT_MATCH_CHAR, + H5T_NATIVE_INT_MATCH_SHORT, + H5T_NATIVE_INT_MATCH_INT, + H5T_NATIVE_INT_MATCH_LONG, + H5T_NATIVE_INT_MATCH_LLONG, + H5T_NATIVE_INT_MATCH_UNKNOWN + } match = H5T_NATIVE_INT_MATCH_UNKNOWN; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { - match = H5T_NATIVE_INT_MATCH_CHAR; + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { + match = H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { - match = H5T_NATIVE_INT_MATCH_SHORT; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { + match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { - match = H5T_NATIVE_INT_MATCH_INT; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { + match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { - match = H5T_NATIVE_INT_MATCH_LONG; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { + match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) { - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LLONG_g))) { + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); - } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); } - } else if(direction == H5T_DIR_DESCEND) { - if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { - match = H5T_NATIVE_INT_MATCH_LLONG; + } + else if (direction == H5T_DIR_DESCEND) { + if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_LONG_g))) { + match = H5T_NATIVE_INT_MATCH_LLONG; native_size = sizeof(long long); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { - match = H5T_NATIVE_INT_MATCH_LONG; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_INT_g))) { + match = H5T_NATIVE_INT_MATCH_LONG; native_size = sizeof(long); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { - match = H5T_NATIVE_INT_MATCH_INT; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SHORT_g))) { + match = H5T_NATIVE_INT_MATCH_INT; native_size = sizeof(int); - } else if(prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { - match = H5T_NATIVE_INT_MATCH_SHORT; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_SCHAR_g))) { + match = H5T_NATIVE_INT_MATCH_SHORT; native_size = sizeof(short); - } else { - match = H5T_NATIVE_INT_MATCH_CHAR; + } + else { + match = H5T_NATIVE_INT_MATCH_CHAR; native_size = sizeof(char); } } /* Set the appropriate native datatype information */ - switch(match) { + switch (match) { case H5T_NATIVE_INT_MATCH_CHAR: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_SCHAR; else tid = H5T_NATIVE_UCHAR; @@ -608,7 +629,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_SHORT: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_SHORT; else tid = H5T_NATIVE_USHORT; @@ -616,7 +637,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_INT: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_INT; else tid = H5T_NATIVE_UINT; @@ -625,7 +646,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_LONG: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_LONG; else tid = H5T_NATIVE_ULONG; @@ -634,7 +655,7 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, break; case H5T_NATIVE_INT_MATCH_LLONG: - if(sign == H5T_SGN_2) + if (sign == H5T_SGN_2) tid = H5T_NATIVE_LLONG; else tid = H5T_NATIVE_ULLONG; @@ -649,20 +670,20 @@ H5T__get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, /* Create new native type */ HDassert(tid >= 0); - if(NULL == (dt = (H5T_t *)H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") + if (NULL == (dt = (H5T_t *)H5I_object(tid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if(NULL == (ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") + if (NULL == (ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_integer() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") /* Disable warning for intentional identical branches here -QAK */ /* @@ -670,8 +691,8 @@ H5_GCC_DIAG_ON(duplicated-branches) * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_float * @@ -686,93 +707,94 @@ H5_GCC_DIAG_OFF(duplicated-branches) * *------------------------------------------------------------------------- */ -static H5T_t* -H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, - size_t *offset, size_t *comp_size) +static H5T_t * +H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *dt=NULL; /* Appropriate native datatype to copy */ - hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ - size_t align=0; /* Alignment necessary for native datatype */ - size_t native_size=0; /* Datatype size of the native type */ - enum match_type { /* The different kinds of floating point types we can match */ - H5T_NATIVE_FLOAT_MATCH_FLOAT, - H5T_NATIVE_FLOAT_MATCH_DOUBLE, -#if H5_SIZEOF_LONG_DOUBLE !=0 - H5T_NATIVE_FLOAT_MATCH_LDOUBLE, + H5T_t *dt = NULL; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + enum match_type { /* The different kinds of floating point types we can match */ + H5T_NATIVE_FLOAT_MATCH_FLOAT, + H5T_NATIVE_FLOAT_MATCH_DOUBLE, +#if H5_SIZEOF_LONG_DOUBLE != 0 + H5T_NATIVE_FLOAT_MATCH_LDOUBLE, #endif - H5T_NATIVE_FLOAT_MATCH_UNKNOWN - } match=H5T_NATIVE_FLOAT_MATCH_UNKNOWN; - H5T_t *ret_value = NULL; /* Return value */ + H5T_NATIVE_FLOAT_MATCH_UNKNOWN + } match = H5T_NATIVE_FLOAT_MATCH_UNKNOWN; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - HDassert(size>0); + HDassert(size > 0); - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(size<=sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (size <= sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); } - else if(size<=sizeof(double)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + else if (size <= sizeof(double)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(size<=sizeof(long double)) { - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (size <= sizeof(long double)) { + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); } #endif - else { /* If not match, return the biggest datatype */ -#if H5_SIZEOF_LONG_DOUBLE !=0 - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); + else { /* If not match, return the biggest datatype */ +#if H5_SIZEOF_LONG_DOUBLE != 0 + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); #else - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); #endif - } - } else { -#if H5_SIZEOF_LONG_DOUBLE !=0 - if(size>sizeof(double)) { - match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE; - native_size = sizeof(long double); } - else if(size>sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + } + else { +#if H5_SIZEOF_LONG_DOUBLE != 0 + if (size > sizeof(double)) { + match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; + native_size = sizeof(long double); + } + else if (size > sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } else { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); - } + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); + } #else - if(size>sizeof(float)) { - match=H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); + if (size > sizeof(float)) { + match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; + native_size = sizeof(double); } else { - match=H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); - } + match = H5T_NATIVE_FLOAT_MATCH_FLOAT; + native_size = sizeof(float); + } #endif } /* Set the appropriate native floating point information */ - switch(match) { + switch (match) { case H5T_NATIVE_FLOAT_MATCH_FLOAT: - tid = H5T_NATIVE_FLOAT; + tid = H5T_NATIVE_FLOAT; align = H5T_NATIVE_FLOAT_COMP_ALIGN_g; break; case H5T_NATIVE_FLOAT_MATCH_DOUBLE: - tid = H5T_NATIVE_DOUBLE; + tid = H5T_NATIVE_DOUBLE; align = H5T_NATIVE_DOUBLE_COMP_ALIGN_g; break; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 case H5T_NATIVE_FLOAT_MATCH_LDOUBLE: - tid = H5T_NATIVE_LDOUBLE; + tid = H5T_NATIVE_LDOUBLE; align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; break; #endif @@ -782,20 +804,20 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali } /* end switch */ /* Create new native type */ - HDassert(tid>=0); - if(NULL==(dt=(H5T_t *)H5I_object(tid))) + HDassert(tid >= 0); + if (NULL == (dt = (H5T_t *)H5I_object(tid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) + if ((ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT)) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") /* compute offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_float() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") /* Disable warning for intentional identical branches here -QAK */ /* @@ -803,8 +825,8 @@ H5_GCC_DIAG_ON(duplicated-branches) * the code below, but early (4.4.7, at least) gcc only allows * diagnostic pragmas to be toggled outside of functions. */ -H5_GCC_DIAG_OFF(duplicated-branches) - +H5_GCC_DIAG_OFF("duplicated-branches") + /*------------------------------------------------------------------------- * Function: H5T__get_native_bitfield * @@ -820,116 +842,122 @@ H5_GCC_DIAG_OFF(duplicated-branches) * *------------------------------------------------------------------------- */ -static H5T_t* -H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, - size_t *struct_align, size_t *offset, size_t *comp_size) +static H5T_t * +H5T__get_native_bitfield(size_t prec, H5T_direction_t direction, size_t *struct_align, size_t *offset, + size_t *comp_size) { - H5T_t *dt; /* Appropriate native datatype to copy */ - hid_t tid=(-1); /* Datatype ID of appropriate native datatype */ - size_t align=0; /* Alignment necessary for native datatype */ - size_t native_size=0; /* Datatype size of the native type */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt; /* Appropriate native datatype to copy */ + hid_t tid = (-1); /* Datatype ID of appropriate native datatype */ + size_t align = 0; /* Alignment necessary for native datatype */ + size_t native_size = 0; /* Datatype size of the native type */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { - tid = H5T_NATIVE_B8; + if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { + tid = H5T_NATIVE_B8; native_size = 1; - align = H5T_NATIVE_UINT8_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { - tid = H5T_NATIVE_B16; + align = H5T_NATIVE_UINT8_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { + tid = H5T_NATIVE_B16; native_size = 2; - align = H5T_NATIVE_UINT16_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { - tid = H5T_NATIVE_B32; + align = H5T_NATIVE_UINT16_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { + tid = H5T_NATIVE_B32; native_size = 4; - align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec<=H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B64_g))) { - tid = H5T_NATIVE_B64; + align = H5T_NATIVE_UINT32_ALIGN_g; + } + else if (prec <= H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B64_g))) { + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; - } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ - tid = H5T_NATIVE_B64; + align = H5T_NATIVE_UINT64_ALIGN_g; + } + else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; + align = H5T_NATIVE_UINT64_ALIGN_g; } - } else if(direction == H5T_DIR_DESCEND) { - if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { - tid = H5T_NATIVE_B64; + } + else if (direction == H5T_DIR_DESCEND) { + if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B32_g))) { + tid = H5T_NATIVE_B64; native_size = 8; - align = H5T_NATIVE_UINT64_ALIGN_g; - } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { - tid = H5T_NATIVE_B32; + align = H5T_NATIVE_UINT64_ALIGN_g; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B16_g))) { + tid = H5T_NATIVE_B32; native_size = 4; - align = H5T_NATIVE_UINT32_ALIGN_g; - } else if(prec>H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { - tid = H5T_NATIVE_B16; + align = H5T_NATIVE_UINT32_ALIGN_g; + } + else if (prec > H5T_get_precision((H5T_t *)H5I_object(H5T_NATIVE_B8_g))) { + tid = H5T_NATIVE_B16; native_size = 2; - align = H5T_NATIVE_UINT16_ALIGN_g; - } else { - tid = H5T_NATIVE_B8; + align = H5T_NATIVE_UINT16_ALIGN_g; + } + else { + tid = H5T_NATIVE_B8; native_size = 1; - align = H5T_NATIVE_UINT8_ALIGN_g; + align = H5T_NATIVE_UINT8_ALIGN_g; } } /* Create new native type */ - HDassert(tid>=0); - if(NULL==(dt=(H5T_t *)H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") + HDassert(tid >= 0); + if (NULL == (dt = (H5T_t *)H5I_object(tid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") + if ((ret_value = H5T_copy(dt, H5T_COPY_TRANSIENT)) == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ - if(H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") + if (H5T__cmp_offset(comp_size, offset, native_size, (size_t)1, align, struct_align) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_native_bitfield() */ -H5_GCC_DIAG_ON(duplicated-branches) +H5_GCC_DIAG_ON("duplicated-branches") - /*------------------------------------------------------------------------- - * Function: H5T__cmp_offset + * Function: H5T__cmp_offset * - * Purpose: This function is only for convenience. It computes the + * Purpose: This function is only for convenience. It computes the * compound type size, offset of the member being considered * and the alignment for the whole compound type. * - * Return: Success: Non-negative value. + * Return: Success: Non-negative value. * - * Failure: Negative value. + * Failure: Negative value. * - * Programmer: Raymond Lu - * December 10, 2002 + * Programmer: Raymond Lu + * December 10, 2002 * *------------------------------------------------------------------------- */ static herr_t -H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, - size_t nelems, size_t align, size_t *struct_align) +H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_size, size_t nelems, size_t align, + size_t *struct_align) { FUNC_ENTER_STATIC_NOERR - if(offset && comp_size) { - if(align > 1 && *comp_size % align) { + if (offset && comp_size) { + if (align > 1 && *comp_size % align) { /* Add alignment value */ - *offset = *comp_size + (align - *comp_size % align); + *offset = *comp_size + (align - *comp_size % align); *comp_size += (align - *comp_size % align); } /* end if */ else *offset = *comp_size; /* compute size of compound type member. */ - *comp_size += nelems* elem_size; + *comp_size += nelems * elem_size; } /* end if */ - if(struct_align && *struct_align < align) + if (struct_align && *struct_align < align) *struct_align = align; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__cmp_offset() */ - diff --git a/src/H5Toffset.c b/src/H5Toffset.c index 38c7e53b8e9..b206dca2a06 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,19 +16,16 @@ * the datatype offset for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T__set_offset(const H5T_t *dt, size_t offset); - - /*------------------------------------------------------------------------- * Function: H5Tget_offset * @@ -61,25 +58,24 @@ static herr_t H5T__set_offset(const H5T_t *dt, size_t offset); int H5Tget_offset(hid_t type_id) { - H5T_t *dt; - int ret_value; + H5T_t *dt; + int ret_value; FUNC_ENTER_API(-1) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") /* Get offset */ - if((ret_value = H5T_get_offset(dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "cant't get offset for specified datatype") + if ((ret_value = H5T_get_offset(dt)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "cant't get offset for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_offset() */ - /*------------------------------------------------------------------------- * Function: H5T_get_offset * @@ -112,15 +108,15 @@ H5Tget_offset(hid_t type_id) int H5T_get_offset(const H5T_t *dt) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) /* Defer to parent*/ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; - if(!H5T_IS_ATOMIC(dt->shared)) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") + if (!H5T_IS_ATOMIC(dt->shared)) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ ret_value = (int)dt->shared->u.atomic.offset; @@ -129,7 +125,6 @@ H5T_get_offset(const H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_offset() */ - /*------------------------------------------------------------------------- * Function: H5Tset_offset * @@ -168,33 +163,33 @@ H5T_get_offset(const H5T_t *dt) herr_t H5Tset_offset(hid_t type_id, size_t offset) { - H5T_t *dt; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, offset); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") + if (H5T_STATE_TRANSIENT != dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (H5T_STRING == dt->shared->type && offset != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - if (H5T_COMPOUND==dt->shared->type || H5T_REFERENCE==dt->shared->type || H5T_OPAQUE==dt->shared->type) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") + if (H5T_COMPOUND == dt->shared->type || H5T_REFERENCE == dt->shared->type || + H5T_OPAQUE == dt->shared->type) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") /* Do the real work */ - if (H5T__set_offset(dt, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") + if (H5T__set_offset(dt, offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__set_offset * @@ -233,29 +228,30 @@ H5Tset_offset(hid_t type_id, size_t offset) static herr_t H5T__set_offset(const H5T_t *dt, size_t offset) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(dt); - HDassert(H5T_STRING!=dt->shared->type || 0==offset); - HDassert(H5T_REFERENCE!=dt->shared->type); - HDassert(H5T_OPAQUE!=dt->shared->type); - HDassert(H5T_COMPOUND!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(H5T_STRING != dt->shared->type || 0 == offset); + HDassert(H5T_REFERENCE != dt->shared->type); + HDassert(H5T_OPAQUE != dt->shared->type); + HDassert(H5T_COMPOUND != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { - if (H5T__set_offset(dt->shared->parent, offset)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") + if (H5T__set_offset(dt->shared->parent, offset) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; - } else { - if (offset+dt->shared->u.atomic.prec > 8*dt->shared->size) + } + else { + if (offset + dt->shared->u.atomic.prec > 8 * dt->shared->size) dt->shared->size = (offset + dt->shared->u.atomic.prec + 7) / 8; dt->shared->u.atomic.offset = offset; } @@ -263,4 +259,3 @@ H5T__set_offset(const H5T_t *dt, size_t offset) done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Toh.c b/src/H5Toh.c index 2dfa3fb42d2..de011e40908 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,69 +15,61 @@ /* Module Setup */ /****************/ -#define H5O_FRIEND /*suppress error about including H5Opkg */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ -static htri_t H5O__dtype_isa(const H5O_t *loc); -static hid_t H5O__dtype_open(const H5G_loc_t *obj_loc, hbool_t app_ref); -static void *H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static htri_t H5O__dtype_isa(const H5O_t *loc); +static void * H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void * H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dtype_get_oloc(hid_t obj_id); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* This message derives from H5O object class */ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ - H5O_TYPE_NAMED_DATATYPE, /* object type */ - "named datatype", /* object name, for debugging */ - NULL, /* get 'copy file' user data */ - NULL, /* free 'copy file' user data */ - H5O__dtype_isa, /* "isa" */ - H5O__dtype_open, /* open an object of this class */ - H5O__dtype_create, /* create an object of this class */ - H5O__dtype_get_oloc, /* get an object header location for an object */ - NULL, /* get the index & heap info for an object */ - NULL /* flush an opened object of this class */ + H5O_TYPE_NAMED_DATATYPE, /* object type */ + "named datatype", /* object name, for debugging */ + NULL, /* get 'copy file' user data */ + NULL, /* free 'copy file' user data */ + H5O__dtype_isa, /* "isa" */ + H5O__dtype_open, /* open an object of this class */ + H5O__dtype_create, /* create an object of this class */ + H5O__dtype_get_oloc, /* get an object header location for an object */ + NULL, /* get the index & heap info for an object */ + NULL /* flush an opened object of this class */ }}; - /*------------------------------------------------------------------------- * Function: H5O__dtype_isa * @@ -98,20 +90,19 @@ const H5O_obj_class_t H5O_OBJ_DATATYPE[1] = {{ static htri_t H5O__dtype_isa(const H5O_t *oh) { - htri_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC HDassert(oh); - if((ret_value = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header") + if ((ret_value = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_isa() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_open * @@ -125,33 +116,32 @@ H5O__dtype_isa(const H5O_t *oh) * *------------------------------------------------------------------------- */ -static hid_t -H5O__dtype_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5T_t *type = NULL; /* Datatype opened */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *type = NULL; /* Datatype opened */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_DATATYPE; + /* Open the datatype */ - if(NULL == (type = H5T_open(obj_loc))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype") + if (NULL == (type = H5T_open(obj_loc))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open datatype") - /* Register an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + ret_value = (void *)type; done: - if(ret_value < 0) - if(type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype") + if (NULL == ret_value) + if (type && H5T_close(type) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_open() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_create * @@ -168,8 +158,8 @@ H5O__dtype_open(const H5G_loc_t *obj_loc, hbool_t app_ref) static void * H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { - H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */ - void *ret_value = NULL; /* Return value */ + H5T_obj_create_t *crt_info = (H5T_obj_create_t *)_crt_info; /* Named datatype creation parameters */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -179,13 +169,13 @@ H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(obj_loc); /* Commit the type to the file */ - if(H5T__commit(f, crt_info->dt, crt_info->tcpl_id) < 0) + if (H5T__commit(f, crt_info->dt, crt_info->tcpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") /* Set up the new named datatype's location */ - if(NULL == (obj_loc->oloc = H5T_oloc(crt_info->dt))) + if (NULL == (obj_loc->oloc = H5T_oloc(crt_info->dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get object location of named datatype") - if(NULL == (obj_loc->path = H5T_nameof(crt_info->dt))) + if (NULL == (obj_loc->path = H5T_nameof(crt_info->dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get path of named datatype") /* Set the return value */ @@ -195,7 +185,6 @@ H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_create() */ - /*------------------------------------------------------------------------- * Function: H5O__dtype_get_oloc * @@ -212,20 +201,23 @@ H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) static H5O_loc_t * H5O__dtype_get_oloc(hid_t obj_id) { - H5T_t *type = NULL; /* Datatype opened */ - H5O_loc_t *ret_value = NULL; /* Return value */ + H5T_t * type = NULL; /* Datatype opened */ + H5T_t * dt = NULL; + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the datatype */ - if(NULL == (type = (H5T_t *)H5I_object(obj_id))) + if (NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") + /* If this is a named datatype, get the VOL driver pointer to the datatype */ + type = (H5T_t *)H5T_get_actual_type(dt); + /* Get the datatype's object header location */ - if(NULL == (ret_value = H5T_oloc(type))) + if (NULL == (ret_value = H5T_oloc(type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from object") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_get_oloc() */ - diff --git a/src/H5Topaque.c b/src/H5Topaque.c index f7ce97751ff..f097fca881a 100644 --- a/src/H5Topaque.c +++ b/src/H5Topaque.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,17 +16,14 @@ * datatypes in the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tset_tag * @@ -42,20 +39,20 @@ herr_t H5Tset_tag(hid_t type_id, const char *tag) { - H5T_t *dt=NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", type_id, tag); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ - if (H5T_OPAQUE!=dt->shared->type) + if (H5T_OPAQUE != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type") if (!tag) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag") @@ -70,7 +67,6 @@ H5Tset_tag(hid_t type_id, const char *tag) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tget_tag * @@ -87,14 +83,14 @@ H5Tset_tag(hid_t type_id, const char *tag) char * H5Tget_tag(hid_t type_id) { - H5T_t *dt=NULL; - char *ret_value; + H5T_t *dt = NULL; + char * ret_value; FUNC_ENTER_API(NULL) H5TRACE1("*s", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -102,10 +98,9 @@ H5Tget_tag(hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class") /* result */ - if (NULL==(ret_value=H5MM_strdup(dt->shared->u.opaque.tag))) + if (NULL == (ret_value = H5MM_strdup(dt->shared->u.opaque.tag))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Torder.c b/src/H5Torder.c index e229c55cef7..e0b48b3ad8d 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,60 +20,49 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ static herr_t H5T__set_order(H5T_t *dtype, H5T_order_t order); - /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5Tget_order * @@ -92,25 +81,24 @@ static herr_t H5T__set_order(H5T_t *dtype, H5T_order_t order); H5T_order_t H5Tget_order(hid_t type_id) { - H5T_t *dt; /* Datatype to query */ - H5T_order_t ret_value; /* Return value */ + H5T_t * dt; /* Datatype to query */ + H5T_order_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_ORDER_ERROR) H5TRACE1("To", "i", type_id); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_ORDER_ERROR, "not a datatype") /* Get order */ - if(H5T_ORDER_ERROR == (ret_value = H5T_get_order(dt))) + if (H5T_ORDER_ERROR == (ret_value = H5T_get_order(dt))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "can't get order for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_order() */ - /*------------------------------------------------------------------------- * Function: H5T_get_order * @@ -127,55 +115,55 @@ H5Tget_order(hid_t type_id) H5T_order_t H5T_get_order(const H5T_t *dtype) { - H5T_order_t ret_value = H5T_ORDER_NONE; /* Return value */ + H5T_order_t ret_value = H5T_ORDER_NONE; /* Return value */ FUNC_ENTER_NOAPI(H5T_ORDER_ERROR) /* Defer to parent */ - while(dtype->shared->parent) + while (dtype->shared->parent) dtype = dtype->shared->parent; /* Set order for atomic type. */ - if(H5T_IS_ATOMIC(dtype->shared)) + if (H5T_IS_ATOMIC(dtype->shared)) ret_value = dtype->shared->u.atomic.order; else { /* Check for compound datatype */ - if(H5T_COMPOUND == dtype->shared->type) { + if (H5T_COMPOUND == dtype->shared->type) { H5T_order_t memb_order = H5T_ORDER_NONE; - int nmemb; /* Number of members in compound & enum types */ - int i; /* Local index variable */ + int nmemb; /* Number of members in compound & enum types */ + int i; /* Local index variable */ /* Retrieve the number of members */ - if((nmemb = H5T_get_nmembers(dtype)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "can't get number of members from compound data type") + if ((nmemb = H5T_get_nmembers(dtype)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, + "can't get number of members from compound data type") /* Get order for each compound member type. */ - for(i = 0; i < nmemb; i++) { + for (i = 0; i < nmemb; i++) { /* Get order for member */ - if((memb_order = H5T_get_order(dtype->shared->u.compnd.memb[i].type)) == H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_ORDER_ERROR, "can't get order for compound member") + if ((memb_order = H5T_get_order(dtype->shared->u.compnd.memb[i].type)) == H5T_ORDER_ERROR) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5T_ORDER_ERROR, + "can't get order for compound member") /* Ignore the H5T_ORDER_NONE, write down the first non H5T_ORDER_NONE order. */ - if(memb_order != H5T_ORDER_NONE && ret_value == H5T_ORDER_NONE) + if (memb_order != H5T_ORDER_NONE && ret_value == H5T_ORDER_NONE) ret_value = memb_order; /* If the orders are mixed, stop the loop and report it. * (H5T_ORDER_NONE is ignored) */ - if(memb_order != H5T_ORDER_NONE && ret_value != H5T_ORDER_NONE - && memb_order != ret_value) { + if (memb_order != H5T_ORDER_NONE && ret_value != H5T_ORDER_NONE && memb_order != ret_value) { ret_value = H5T_ORDER_MIXED; break; } /* end if */ - } /* end for */ - } /* end if */ - } /* end else */ + } /* end for */ + } /* end if */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_order() */ - /*------------------------------------------------------------------------- * Function: H5Tset_order * @@ -199,29 +187,30 @@ H5T_get_order(const H5T_t *dtype) herr_t H5Tset_order(hid_t type_id, H5T_order_t order) { - H5T_t *dt = NULL; /* Datatype to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt = NULL; /* Datatype to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTo", type_id, order); /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") - if(order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) + if (order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order") - if(H5T_STATE_TRANSIENT != dt->shared->state) + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is read-only") /* Call internal routine to set the order */ - if(H5T__set_order(dt, order) < 0) + if (H5T__set_order(dt, order) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "can't set order") done: FUNC_LEAVE_API(ret_value) } /* end H5Tset_order() */ - /*------------------------------------------------------------------------- * Function: H5T__set_order * @@ -237,47 +226,47 @@ H5Tset_order(hid_t type_id, H5T_order_t order) static herr_t H5T__set_order(H5T_t *dtype, H5T_order_t order) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(H5T_ENUM == dtype->shared->type && dtype->shared->u.enumer.nmembs > 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after enum members are defined") + if (H5T_ENUM == dtype->shared->type && dtype->shared->u.enumer.nmembs > 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after enum members are defined") /* For derived data type, defer to parent */ - while(dtype->shared->parent) + while (dtype->shared->parent) dtype = dtype->shared->parent; /* Check for setting order on inappropriate datatype */ - if(order == H5T_ORDER_NONE && !(H5T_REFERENCE == dtype->shared->type || - H5T_OPAQUE == dtype->shared->type || H5T_IS_FIXED_STRING(dtype->shared))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order for type") + if (order == H5T_ORDER_NONE && !(H5T_REFERENCE == dtype->shared->type || + H5T_OPAQUE == dtype->shared->type || H5T_IS_FIXED_STRING(dtype->shared))) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order for type") /* For atomic data type */ - if(H5T_IS_ATOMIC(dtype->shared)) + if (H5T_IS_ATOMIC(dtype->shared)) dtype->shared->u.atomic.order = order; else { /* Check for compound datatype */ - if(H5T_COMPOUND == dtype->shared->type) { - int nmemb; /* Number of members in type */ - int i; /* Local index variable */ + if (H5T_COMPOUND == dtype->shared->type) { + int nmemb; /* Number of members in type */ + int i; /* Local index variable */ /* Retrieve the number of fields in the compound datatype */ - if((nmemb = H5T_get_nmembers(dtype)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get number of members from compound data type") + if ((nmemb = H5T_get_nmembers(dtype)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, + "can't get number of members from compound data type") /* Check for uninitialized compound datatype */ - if(nmemb == 0) + if (nmemb == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, FAIL, "no member is in the compound data type") /* Loop through all fields of compound type, setting the order */ - for(i = 0; i < nmemb; i++) - if(H5T__set_order(dtype->shared->u.compnd.memb[i].type, order) < 0) + for (i = 0; i < nmemb; i++) + if (H5T__set_order(dtype->shared->u.compnd.memb[i].type, order) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set order for compound member") } /* end if */ - } /* end else */ + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__set_order() */ - diff --git a/src/H5Tpad.c b/src/H5Tpad.c index 450c567545f..db1a2cb9a2c 100644 --- a/src/H5Tpad.c +++ b/src/H5Tpad.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,16 +16,13 @@ * the datatype padding for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_pad * @@ -41,16 +38,16 @@ *------------------------------------------------------------------------- */ herr_t -H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) +H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out*/, H5T_pad_t *msb /*out*/) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", type_id, lsb, msb); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -67,7 +64,6 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_pad * @@ -83,20 +79,20 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iTpTp", type_id, lsb, msb); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (lsb < H5T_PAD_ZERO || lsb >= H5T_NPAD || msb < H5T_PAD_ZERO || msb >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") while (dt->shared->parent) dt = dt->shared->parent; /*defer to parent*/ @@ -110,4 +106,3 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 9bd02eafd7a..51ecacae481 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,52 +23,54 @@ #error "Do not include this file outside the H5T package!" #endif -#ifndef _H5Tpkg_H -#define _H5Tpkg_H +#ifndef H5Tpkg_H +#define H5Tpkg_H /* * Define this to enable debugging. */ #ifdef NDEBUG -# undef H5T_DEBUG +#undef H5T_DEBUG #endif /* Get package's private header */ #include "H5Tprivate.h" /* Other private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Other public headers needed by this file */ -#include "H5Spublic.h" /* Dataspace functions */ +#include "H5Spublic.h" /* Dataspace functions */ /* Length of debugging name buffer */ -#define H5T_NAMELEN 32 +#define H5T_NAMELEN 32 /* Macro to ease detecting "complex" datatypes (i.e. those with base types or fields) */ -#define H5T_IS_COMPLEX(t) ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY) +#define H5T_IS_COMPLEX(t) \ + ((t) == H5T_COMPOUND || (t) == H5T_ENUM || (t) == H5T_VLEN || (t) == H5T_ARRAY || (t) == H5T_REFERENCE) /* Macro to ease detecting fixed "string" datatypes */ #define H5T_IS_FIXED_STRING(dt) (H5T_STRING == (dt)->type) /* Macro to ease detecting variable-length "string" datatypes */ -#define H5T_IS_VL_STRING(dt) (H5T_VLEN == (dt)->type && H5T_VLEN_STRING == (dt)->u.vlen.type) +#define H5T_IS_VL_STRING(dt) (H5T_VLEN == (dt)->type && H5T_VLEN_STRING == (dt)->u.vlen.type) /* Macro to ease detecting fixed or variable-length "string" datatypes */ -#define H5T_IS_STRING(dt) (H5T_IS_FIXED_STRING(dt) || H5T_IS_VL_STRING(dt)) +#define H5T_IS_STRING(dt) (H5T_IS_FIXED_STRING(dt) || H5T_IS_VL_STRING(dt)) /* Macro to ease detecting atomic datatypes */ -#define H5T_IS_ATOMIC(dt) (!(H5T_IS_COMPLEX((dt)->type) || (dt)->type == H5T_OPAQUE)) +#define H5T_IS_ATOMIC(dt) (!(H5T_IS_COMPLEX((dt)->type) || (dt)->type == H5T_OPAQUE)) /* Macro to ease retrieving class of shared datatype */ /* (Externally, a VL string is a string; internally, a VL string is a VL. Lie * to the user if they have a VL string and tell them it's in the string * class) */ -#define H5T_GET_CLASS(shared, internal) ((internal) ? (shared)->type : (H5T_IS_VL_STRING(shared) ? H5T_STRING : (shared)->type)) - +#define H5T_GET_CLASS(shared, internal) \ + ((internal) ? (shared)->type : (H5T_IS_VL_STRING(shared) ? H5T_STRING : (shared)->type)) /* * Datatype encoding versions @@ -79,13 +81,13 @@ * vlen sequences of objects which aren't arrays, etc.) or VAX byte-ordered * objects. */ -#define H5O_DTYPE_VERSION_1 1 +#define H5O_DTYPE_VERSION_1 1 /* This is the version to create all datatypes which contain H5T_ARRAY * class objects (array definitely, potentially compound & vlen sequences also), * but not VAX byte-ordered objects. */ -#define H5O_DTYPE_VERSION_2 2 +#define H5O_DTYPE_VERSION_2 2 /* This is the version to create all datatypes which contain VAX byte-ordered * objects (floating-point types, currently). @@ -93,26 +95,31 @@ /* This version also packs compound & enum field names without padding */ /* This version also encodes the member offset of compound fields more efficiently */ /* This version also encodes array types more efficiently */ -#define H5O_DTYPE_VERSION_3 3 +#define H5O_DTYPE_VERSION_3 3 + +/* This is the version that adds support for new reference types and prevents + * older versions of the library to attempt reading unknown types. + */ +#define H5O_DTYPE_VERSION_4 4 /* The latest version of the format. Look through the 'encode helper' routine * and 'size' callback for places to change when updating this. */ -#define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_3 - +#define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_4 /* Flags for visiting datatype */ -#define H5T_VISIT_COMPLEX_FIRST 0x01 /* Visit complex datatype before visiting member/parent datatypes */ -#define H5T_VISIT_COMPLEX_LAST 0x02 /* Visit complex datatype after visiting member/parent datatypes */ - /* (setting both flags will mean visiting complex type twice) */ -#define H5T_VISIT_SIMPLE 0x04 /* Visit simple datatypes (at all) */ - /* (setting H5T_VISIT_SIMPLE and _not_ setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will mean visiting _only_ "simple" "leafs" in the "tree" */ - /* (_not_ setting H5T_VISIT_SIMPLE and setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will mean visiting all nodes _except_ "simple" "leafs" in the "tree" */ - +#define H5T_VISIT_COMPLEX_FIRST 0x01 /* Visit complex datatype before visiting member/parent datatypes */ +#define H5T_VISIT_COMPLEX_LAST 0x02 /* Visit complex datatype after visiting member/parent datatypes */ + /* (setting both flags will mean visiting complex type twice) */ +#define H5T_VISIT_SIMPLE 0x04 /* Visit simple datatypes (at all) */ +/* (setting H5T_VISIT_SIMPLE and _not_ setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will + * mean visiting _only_ "simple" "leafs" in the "tree" */ +/* (_not_ setting H5T_VISIT_SIMPLE and setting either H5T_VISIT_COMPLEX_FIRST or H5T_VISIT_COMPLEX_LAST will + * mean visiting all nodes _except_ "simple" "leafs" in the "tree" */ /* Define an internal macro for converting long long to long double. Mac OS 10.4 gives some * incorrect conversions. */ #if (H5_WANT_DATA_ACCURACY && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 +#define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 #endif /* Define an internal macro for converting unsigned long long to long double. SGI compilers give @@ -121,229 +128,261 @@ * compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly. * Mac OS 10.4 gives some incorrect result. */ #if (H5_WANT_DATA_ACCURACY && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 +#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 #endif /* Define an internal macro for converting long double to long long. SGI compilers give some incorrect * conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates floating exception. * The hard conversion on Windows .NET 2003 has a bug and gives wrong exception value. */ -#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \ - (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 +#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || (!H5_WANT_DATA_ACCURACY) +#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 #endif /* Define an internal macro for converting long double to unsigned long long. SGI compilers give some * incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates * floating exception. */ -#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \ - (!H5_WANT_DATA_ACCURACY) -#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 +#if (H5_WANT_DATA_ACCURACY && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || (!H5_WANT_DATA_ACCURACY) +#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 #else -#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 0 +#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 0 #endif /* Statistics about a conversion function */ struct H5T_stats_t { - unsigned ncalls; /*num calls to conversion function */ - hsize_t nelmts; /*total data points converted */ - H5_timevals_t times; /*total time for conversion */ + unsigned ncalls; /*num calls to conversion function */ + hsize_t nelmts; /*total data points converted */ + H5_timevals_t times; /*total time for conversion */ }; /* Library internal datatype conversion functions are... */ -typedef herr_t (*H5T_lib_conv_t) (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); +typedef herr_t (*H5T_lib_conv_t)(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); /* Conversion callbacks (library internal ones don't need DXPL) */ typedef struct H5T_conv_func_t { - hbool_t is_app; /* Whether conversion function is registered from application */ + hbool_t is_app; /* Whether conversion function is registered from application */ union { - H5T_conv_t app_func; /* Application data conversion function */ - H5T_lib_conv_t lib_func; /* Library internal data conversion function */ + H5T_conv_t app_func; /* Application data conversion function */ + H5T_lib_conv_t lib_func; /* Library internal data conversion function */ } u; } H5T_conv_func_t; /* The datatype conversion database */ struct H5T_path_t { - char name[H5T_NAMELEN]; /*name for debugging only */ - H5T_t *src; /*source datatype */ - H5T_t *dst; /*destination datatype */ - H5T_conv_func_t conv; /* Conversion function */ - hbool_t is_hard; /*is it a hard function? */ - hbool_t is_noop; /*is it the noop conversion? */ - hbool_t are_compounds; /*are source and dest both compounds?*/ - H5T_stats_t stats; /*statistics for the conversion */ - H5T_cdata_t cdata; /*data for this function */ + char name[H5T_NAMELEN]; /*name for debugging only */ + H5T_t * src; /*source datatype */ + H5T_t * dst; /*destination datatype */ + H5T_conv_func_t conv; /* Conversion function */ + hbool_t is_hard; /*is it a hard function? */ + hbool_t is_noop; /*is it the noop conversion? */ + hbool_t are_compounds; /*are source and dest both compounds?*/ + H5T_stats_t stats; /*statistics for the conversion */ + H5T_cdata_t cdata; /*data for this function */ }; +/* Reference function pointers */ +typedef herr_t (*H5T_ref_isnullfunc_t)(const H5VL_object_t *file, const void *src_buf, hbool_t *isnull); +typedef herr_t (*H5T_ref_setnullfunc_t)(H5VL_object_t *file, void *dst_buf, void *bg_buf); +typedef size_t (*H5T_ref_getsizefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +typedef herr_t (*H5T_ref_readfunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +typedef herr_t (*H5T_ref_writefunc_t)(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf); + +typedef struct H5T_ref_class_t { + H5T_ref_isnullfunc_t isnull; /* check if reference value is NIL */ + H5T_ref_setnullfunc_t setnull; /* set a reference value to NIL */ + H5T_ref_getsizefunc_t getsize; /* get reference size (bytes) */ + H5T_ref_readfunc_t read; /* read reference into buffer */ + H5T_ref_writefunc_t write; /* write reference from buffer */ +} H5T_ref_class_t; + typedef struct H5T_atomic_t { - H5T_order_t order; /* byte order */ - size_t prec; /* precision in bits */ - size_t offset; /* bit position of lsb of value */ - H5T_pad_t lsb_pad; /* type of lsb padding */ - H5T_pad_t msb_pad; /* type of msb padding */ + H5T_order_t order; /* byte order */ + size_t prec; /* precision in bits */ + size_t offset; /* bit position of lsb of value */ + H5T_pad_t lsb_pad; /* type of lsb padding */ + H5T_pad_t msb_pad; /* type of msb padding */ union { struct { - H5T_sign_t sign; /* type of integer sign */ - } i; /* integer; integer types */ + H5T_sign_t sign; /* type of integer sign */ + } i; /* integer; integer types */ struct { - size_t sign; /* bit position of sign bit */ - size_t epos; /* position of lsb of exponent */ - size_t esize; /* size of exponent in bits */ - uint64_t ebias; /* exponent bias */ - size_t mpos; /* position of lsb of mantissa */ - size_t msize; /* size of mantissa */ - H5T_norm_t norm; /* normalization */ - H5T_pad_t pad; /* type of padding for internal bits */ - } f; /* floating-point types */ + size_t sign; /* bit position of sign bit */ + size_t epos; /* position of lsb of exponent */ + size_t esize; /* size of exponent in bits */ + uint64_t ebias; /* exponent bias */ + size_t mpos; /* position of lsb of mantissa */ + size_t msize; /* size of mantissa */ + H5T_norm_t norm; /* normalization */ + H5T_pad_t pad; /* type of padding for internal bits */ + } f; /* floating-point types */ struct { - H5T_cset_t cset; /* character set */ - H5T_str_t pad; /* space or null padding of extra bytes */ - } s; /* string types */ + H5T_cset_t cset; /* character set */ + H5T_str_t pad; /* space or null padding of extra bytes */ + } s; /* string types */ struct { - H5R_type_t rtype; /* type of reference stored */ - H5T_loc_t loc; /* location of data in buffer */ - } r; /* reference types */ + H5R_type_t rtype; /* type of reference stored */ + unsigned version; /* version of encoded reference */ + hbool_t opaque; /* opaque reference type */ + H5T_loc_t loc; /* location of data in buffer */ + H5VL_object_t * file; /* file VOL pointer (if data is on disk) */ + const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */ + } r; /* reference types */ } u; } H5T_atomic_t; /* How members are sorted for compound or enum datatypes */ typedef enum H5T_sort_t { - H5T_SORT_NONE = 0, /*not sorted */ - H5T_SORT_NAME = 1, /*sorted by member name */ - H5T_SORT_VALUE = 2 /*sorted by memb offset or enum value*/ + H5T_SORT_NONE = 0, /*not sorted */ + H5T_SORT_NAME = 1, /*sorted by member name */ + H5T_SORT_VALUE = 2 /*sorted by memb offset or enum value*/ } H5T_sort_t; /* A compound datatype member */ typedef struct H5T_cmemb_t { - char *name; /*name of this member */ - size_t offset; /*offset from beginning of struct */ - size_t size; /*size of this member */ - struct H5T_t *type; /*type of this member */ + char * name; /*name of this member */ + size_t offset; /*offset from beginning of struct */ + size_t size; /*size of this member */ + struct H5T_t *type; /*type of this member */ } H5T_cmemb_t; /* A compound datatype */ typedef struct H5T_compnd_t { - unsigned nalloc; /*num entries allocated in MEMB array*/ - unsigned nmembs; /*number of members defined in struct*/ - H5T_sort_t sorted; /*how are members sorted? */ - hbool_t packed; /*are members packed together? */ - H5T_cmemb_t *memb; /*array of struct members */ - size_t memb_size; /*total of all member sizes */ + unsigned nalloc; /*num entries allocated in MEMB array*/ + unsigned nmembs; /*number of members defined in struct*/ + H5T_sort_t sorted; /*how are members sorted? */ + hbool_t packed; /*are members packed together? */ + H5T_cmemb_t *memb; /*array of struct members */ + size_t memb_size; /*total of all member sizes */ } H5T_compnd_t; /* An enumeration datatype */ typedef struct H5T_enum_t { - unsigned nalloc; /*num entries allocated */ - unsigned nmembs; /*number of members defined in enum */ - H5T_sort_t sorted; /*how are members sorted? */ - uint8_t *value; /*array of values */ - char **name; /*array of symbol names */ + unsigned nalloc; /*num entries allocated */ + unsigned nmembs; /*number of members defined in enum */ + H5T_sort_t sorted; /*how are members sorted? */ + void * value; /*array of values */ + char ** name; /*array of symbol names */ } H5T_enum_t; -/* VL function pointers */ -typedef ssize_t (*H5T_vlen_getlenfunc_t)(const void *vl_addr); -typedef void * (*H5T_vlen_getptrfunc_t)(void *vl_addr); -typedef htri_t (*H5T_vlen_isnullfunc_t)(const H5F_t *f, void *vl_addr); -typedef herr_t (*H5T_vlen_readfunc_t)(H5F_t *f, void *_vl, void *buf, size_t len); -typedef herr_t (*H5T_vlen_writefunc_t)(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size); -typedef herr_t (*H5T_vlen_setnullfunc_t)(H5F_t *f, void *_vl, void *_bg); - /* VL types */ typedef enum { - H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ + H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ H5T_VLEN_SEQUENCE = 0, /* VL sequence */ H5T_VLEN_STRING, /* VL string */ H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ } H5T_vlen_type_t; +/* VL function pointers */ +typedef herr_t (*H5T_vlen_getlen_func_t)(H5VL_object_t *file, const void *vl_addr, size_t *len); +typedef void *(*H5T_vlen_getptr_func_t)(void *vl_addr); +typedef herr_t (*H5T_vlen_isnull_func_t)(const H5VL_object_t *file, void *vl_addr, hbool_t *isnull); +typedef herr_t (*H5T_vlen_setnull_func_t)(H5VL_object_t *file, void *_vl, void *_bg); +typedef herr_t (*H5T_vlen_read_func_t)(H5VL_object_t *file, void *_vl, void *buf, size_t len); +typedef herr_t (*H5T_vlen_write_func_t)(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size); +typedef herr_t (*H5T_vlen_delete_func_t)(H5VL_object_t *file, const void *_vl); + +/* VL datatype callbacks */ +typedef struct H5T_vlen_class_t { + H5T_vlen_getlen_func_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ + H5T_vlen_getptr_func_t getptr; /* Function to get VL sequence pointer */ + H5T_vlen_isnull_func_t isnull; /* Function to check if VL value is NIL */ + H5T_vlen_setnull_func_t setnull; /* Function to set a VL value to NIL */ + H5T_vlen_read_func_t read; /* Function to read VL sequence into buffer */ + H5T_vlen_write_func_t write; /* Function to write VL sequence from buffer */ + H5T_vlen_delete_func_t del; /* Function to delete VL sequence */ +} H5T_vlen_class_t; + /* A VL datatype */ typedef struct H5T_vlen_t { - H5T_vlen_type_t type; /* Type of VL data in buffer */ - H5T_loc_t loc; /* Location of VL data in buffer */ - H5T_cset_t cset; /* For VL string: character set */ - H5T_str_t pad; /* For VL string: space or null padding of - * extra bytes */ - H5F_t *f; /* File ID (if VL data is on disk) */ - H5T_vlen_getptrfunc_t getptr; /* Function to get VL sequence pointer */ - H5T_vlen_getlenfunc_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ - H5T_vlen_isnullfunc_t isnull; /* Function to check if VL value is NIL */ - H5T_vlen_readfunc_t read; /* Function to read VL sequence into buffer */ - H5T_vlen_writefunc_t write; /* Function to write VL sequence from buffer */ - H5T_vlen_setnullfunc_t setnull; /* Function to set a VL value to NIL */ + H5T_vlen_type_t type; /* Type of VL data in buffer */ + H5T_loc_t loc; /* Location of VL data in buffer */ + H5T_cset_t cset; /* For VL string: character set */ + H5T_str_t pad; /* For VL string: space or null padding of + * extra bytes */ + H5VL_object_t * file; /* File object (if VL data is on disk) */ + const H5T_vlen_class_t *cls; /* Pointer to VL class callbacks */ } H5T_vlen_t; /* An opaque datatype */ typedef struct H5T_opaque_t { - char *tag; /*short type description string */ + char *tag; /*short type description string */ } H5T_opaque_t; /* An array datatype */ typedef struct H5T_array_t { - size_t nelem; /* total number of elements in array */ - unsigned ndims; /* member dimensionality */ - size_t dim[H5S_MAX_RANK]; /* size in each dimension */ + size_t nelem; /* total number of elements in array */ + unsigned ndims; /* member dimensionality */ + size_t dim[H5S_MAX_RANK]; /* size in each dimension */ } H5T_array_t; typedef enum H5T_state_t { - H5T_STATE_TRANSIENT, /*type is a modifiable, closable transient */ - H5T_STATE_RDONLY, /*transient, not modifiable, closable */ - H5T_STATE_IMMUTABLE, /*transient, not modifiable, not closable */ - H5T_STATE_NAMED, /*named constant, not open */ - H5T_STATE_OPEN /*named constant, open object header */ + H5T_STATE_TRANSIENT, /*type is a modifiable, closable transient */ + H5T_STATE_RDONLY, /*transient, not modifiable, closable */ + H5T_STATE_IMMUTABLE, /*transient, not modifiable, not closable */ + H5T_STATE_NAMED, /*named constant, not open */ + H5T_STATE_OPEN /*named constant, open object header */ } H5T_state_t; - /* This struct is shared between all occurrences of an open named type */ +/* This struct is shared between all occurrences of an open named type */ typedef struct H5T_shared_t { - hsize_t fo_count; /* number of references to this file object */ - H5T_state_t state; /*current state of the type */ - H5T_class_t type; /*which class of type is this? */ - size_t size; /*total size of an instance of this type */ - unsigned version; /* Version of object header message to encode this object with */ - hbool_t force_conv;/* Set if this type always needs to be converted and H5T__conv_noop cannot be called */ - struct H5T_t *parent;/*parent type for derived datatypes */ + hsize_t fo_count; /* number of references to this file object */ + H5T_state_t state; /*current state of the type */ + H5T_class_t type; /*which class of type is this? */ + size_t size; /*total size of an instance of this type */ + unsigned version; /* Version of object header message to encode this object with */ + hbool_t + force_conv; /* Set if this type always needs to be converted and H5T__conv_noop cannot be called */ + struct H5T_t * parent; /*parent type for derived datatypes */ + H5VL_object_t *owned_vol_obj; /* Vol object owned by this type (free on close) */ union { - H5T_atomic_t atomic; /* an atomic datatype */ - H5T_compnd_t compnd; /* a compound datatype (struct) */ - H5T_enum_t enumer; /* an enumeration type (enum) */ - H5T_vlen_t vlen; /* a variable-length datatype */ - H5T_opaque_t opaque; /* an opaque datatype */ - H5T_array_t array; /* an array datatype */ + H5T_atomic_t atomic; /* an atomic datatype */ + H5T_compnd_t compnd; /* a compound datatype (struct) */ + H5T_enum_t enumer; /* an enumeration type (enum) */ + H5T_vlen_t vlen; /* a variable-length datatype */ + H5T_opaque_t opaque; /* an opaque datatype */ + H5T_array_t array; /* an array datatype */ } u; } H5T_shared_t; struct H5T_t { - H5O_shared_t sh_loc; /* Shared message info (must be first) */ + H5O_shared_t sh_loc; /* Shared message info (must be first) */ - H5T_shared_t *shared; /* all other information */ - H5O_loc_t oloc; /* Object location, if the type is a named type */ - H5G_name_t path; /* group hier. path if the type is a named type */ + H5T_shared_t * shared; /* all other information */ + H5O_loc_t oloc; /* Object location, if the type is a named type */ + H5G_name_t path; /* group hier. path if the type is a named type */ + H5VL_object_t *vol_obj; /* pointer to VOL object when working with committed datatypes */ }; /* The master list of soft conversion functions */ typedef struct H5T_soft_t { - char name[H5T_NAMELEN]; /*name for debugging only */ - H5T_class_t src; /*source datatype class */ - H5T_class_t dst; /*destination datatype class */ - H5T_conv_func_t conv; /*the conversion function */ + char name[H5T_NAMELEN]; /*name for debugging only */ + H5T_class_t src; /*source datatype class */ + H5T_class_t dst; /*destination datatype class */ + H5T_conv_func_t conv; /*the conversion function */ } H5T_soft_t; /* Bit search direction */ typedef enum H5T_sdir_t { - H5T_BIT_LSB, /*search lsb toward msb */ - H5T_BIT_MSB /*search msb toward lsb */ + H5T_BIT_LSB, /*search lsb toward msb */ + H5T_BIT_MSB /*search msb toward lsb */ } H5T_sdir_t; /* Typedef for named datatype creation operation */ typedef struct { - H5T_t *dt; /* Datatype to commit */ - hid_t tcpl_id; /* Named datatype creation property list */ + H5T_t *dt; /* Datatype to commit */ + hid_t tcpl_id; /* Named datatype creation property list */ } H5T_obj_create_t; /* Typedef for datatype iteration operations */ -typedef herr_t (*H5T_operator_t)(H5T_t *dt, void *op_data/*in,out*/); +typedef herr_t (*H5T_operator_t)(H5T_t *dt, void *op_data /*in,out*/); /* Array of versions for Datatype */ H5_DLLVAR const unsigned H5O_dtype_ver_bounds[H5F_LIBVER_NBOUNDS]; @@ -355,21 +394,22 @@ H5_DLLVAR const unsigned H5O_dtype_ver_bounds[H5F_LIBVER_NBOUNDS]; * not calculated. These alignment info is only for H5Tget_native_type. * These values are used for structure alignment. */ -H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 -H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SHORT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; +#if H5_SIZEOF_LONG_DOUBLE != 0 +H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; #endif H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HVL_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HOBJREF_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HDSETREGREF_COMP_ALIGN_g; +H5_DLLVAR size_t H5T_REF_COMP_ALIGN_g; /* * Alignment information for native types. A value of N indicates that the @@ -377,58 +417,58 @@ H5_DLLVAR size_t H5T_HDSETREGREF_COMP_ALIGN_g; * N=1 no alignment is required; N=0 implies that alignment constraints were * not calculated. */ -H5_DLLVAR size_t H5T_NATIVE_SCHAR_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UCHAR_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_SHORT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_USHORT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 -H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SCHAR_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UCHAR_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_SHORT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_USHORT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; +#if H5_SIZEOF_LONG_DOUBLE != 0 +H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; #endif /* C9x alignment constraints */ -H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST8_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST8_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST16_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST16_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST32_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST32_ALIGN_g; - -H5_DLLVAR size_t H5T_NATIVE_INT64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_LEAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_INT_FAST64_ALIGN_g; -H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST8_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST8_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST16_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST16_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST32_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST32_ALIGN_g; + +H5_DLLVAR size_t H5T_NATIVE_INT64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_LEAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_INT_FAST64_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ -H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; -H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; +H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; +H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_NEG_INF_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR double H5T_NATIVE_LDOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_LDOUBLE_NEG_INF_g; #endif @@ -442,715 +482,400 @@ H5_DLL herr_t H5T__init_native(void); H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size); H5_DLL H5T_t *H5T__alloc(void); H5_DLL herr_t H5T__free(H5T_t *dt); -H5_DLL herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, - void *op_value); +H5_DLL herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value); H5_DLL herr_t H5T__upgrade_version(H5T_t *dt, unsigned new_version); /* Committed / named datatype routines */ +H5_DLL herr_t H5T__commit_anon(H5F_t *file, H5T_t *type, hid_t tcpl_id); H5_DLL herr_t H5T__commit(H5F_t *file, H5T_t *type, hid_t tcpl_id); -H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, - H5T_t *dt, hid_t lcpl_id, hid_t tcpl_id); +H5_DLL herr_t H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_id, + hid_t tcpl_id); H5_DLL H5T_t *H5T__open_name(const H5G_loc_t *loc, const char *name); +H5_DLL hid_t H5T__get_create_plist(const H5T_t *type); /* Conversion functions */ -H5_DLL herr_t H5T__conv_noop(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); - -H5_DLL herr_t H5T__conv_order(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); -H5_DLL herr_t H5T__conv_order_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); -H5_DLL 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); -H5_DLL 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); -H5_DLL 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 bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T__conv_enum_numeric(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); -H5_DLL herr_t H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_noop(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); + +H5_DLL herr_t H5T__conv_order(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); +H5_DLL herr_t H5T__conv_order_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); +H5_DLL 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); +H5_DLL 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); +H5_DLL 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 bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_enum_numeric(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); +H5_DLL herr_t H5T__conv_vlen(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); +H5_DLL herr_t H5T__conv_array(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); +H5_DLL 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); -H5_DLL herr_t H5T__conv_array(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); -H5_DLL 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, +H5_DLL 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 bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_f_f(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); -H5_DLL herr_t H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_f_i(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); -H5_DLL herr_t H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, +H5_DLL herr_t H5T__conv_i_f(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); -H5_DLL 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, +H5_DLL 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 bkg_stride, void *_buf, void *bkg); -H5_DLL 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, +H5_DLL 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 bkg_stride, void *_buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_uchar(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); -H5_DLL herr_t H5T__conv_uchar_schar(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); -H5_DLL herr_t H5T__conv_schar_short(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); -H5_DLL herr_t H5T__conv_schar_ushort(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); -H5_DLL herr_t H5T__conv_uchar_short(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); -H5_DLL herr_t H5T__conv_uchar_ushort(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); -H5_DLL herr_t H5T__conv_schar_int(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); -H5_DLL herr_t H5T__conv_schar_uint(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); -H5_DLL herr_t H5T__conv_uchar_int(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); -H5_DLL herr_t H5T__conv_uchar_uint(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); -H5_DLL herr_t H5T__conv_schar_long(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); -H5_DLL herr_t H5T__conv_schar_ulong(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); -H5_DLL herr_t H5T__conv_uchar_long(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); -H5_DLL herr_t H5T__conv_uchar_ulong(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); -H5_DLL herr_t H5T__conv_schar_llong(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); -H5_DLL herr_t H5T__conv_schar_ullong(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); -H5_DLL herr_t H5T__conv_uchar_llong(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); -H5_DLL herr_t H5T__conv_uchar_ullong(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); - -H5_DLL herr_t H5T__conv_short_schar(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); -H5_DLL herr_t H5T__conv_short_uchar(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); -H5_DLL herr_t H5T__conv_ushort_schar(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); -H5_DLL herr_t H5T__conv_ushort_uchar(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); -H5_DLL herr_t H5T__conv_short_ushort(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); -H5_DLL herr_t H5T__conv_ushort_short(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); -H5_DLL herr_t H5T__conv_short_int(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); -H5_DLL herr_t H5T__conv_short_uint(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); -H5_DLL herr_t H5T__conv_ushort_int(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); -H5_DLL herr_t H5T__conv_ushort_uint(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); -H5_DLL herr_t H5T__conv_short_long(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); -H5_DLL herr_t H5T__conv_short_ulong(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); -H5_DLL herr_t H5T__conv_ushort_long(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); -H5_DLL herr_t H5T__conv_ushort_ulong(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); -H5_DLL herr_t H5T__conv_short_llong(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); -H5_DLL herr_t H5T__conv_short_ullong(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); -H5_DLL herr_t H5T__conv_ushort_llong(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); -H5_DLL herr_t H5T__conv_ushort_ullong(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); - -H5_DLL herr_t H5T__conv_int_schar(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); -H5_DLL herr_t H5T__conv_int_uchar(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); -H5_DLL herr_t H5T__conv_uint_schar(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); -H5_DLL herr_t H5T__conv_uint_uchar(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); -H5_DLL herr_t H5T__conv_int_short(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); -H5_DLL herr_t H5T__conv_int_ushort(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); -H5_DLL herr_t H5T__conv_uint_short(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); -H5_DLL herr_t H5T__conv_uint_ushort(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); -H5_DLL herr_t H5T__conv_int_uint(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); -H5_DLL herr_t H5T__conv_uint_int(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); -H5_DLL herr_t H5T__conv_int_long(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); -H5_DLL herr_t H5T__conv_int_ulong(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); -H5_DLL herr_t H5T__conv_uint_long(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); -H5_DLL herr_t H5T__conv_uint_ulong(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); -H5_DLL herr_t H5T__conv_int_llong(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); -H5_DLL herr_t H5T__conv_int_ullong(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); -H5_DLL herr_t H5T__conv_uint_llong(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); -H5_DLL herr_t H5T__conv_uint_ullong(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); - -H5_DLL herr_t H5T__conv_long_schar(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); -H5_DLL herr_t H5T__conv_long_uchar(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); -H5_DLL herr_t H5T__conv_ulong_schar(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); -H5_DLL herr_t H5T__conv_ulong_uchar(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); -H5_DLL herr_t H5T__conv_long_short(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); -H5_DLL herr_t H5T__conv_long_ushort(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); -H5_DLL herr_t H5T__conv_ulong_short(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); -H5_DLL herr_t H5T__conv_ulong_ushort(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); -H5_DLL herr_t H5T__conv_long_int(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); -H5_DLL herr_t H5T__conv_long_uint(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); -H5_DLL herr_t H5T__conv_ulong_int(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); -H5_DLL herr_t H5T__conv_ulong_uint(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); -H5_DLL herr_t H5T__conv_long_ulong(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); -H5_DLL herr_t H5T__conv_ulong_long(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); -H5_DLL herr_t H5T__conv_long_llong(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); -H5_DLL herr_t H5T__conv_long_ullong(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); -H5_DLL herr_t H5T__conv_ulong_llong(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); -H5_DLL herr_t H5T__conv_ulong_ullong(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); - -H5_DLL herr_t H5T__conv_llong_schar(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); -H5_DLL herr_t H5T__conv_llong_uchar(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); -H5_DLL herr_t H5T__conv_ullong_schar(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); -H5_DLL herr_t H5T__conv_ullong_uchar(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); -H5_DLL herr_t H5T__conv_llong_short(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); -H5_DLL herr_t H5T__conv_llong_ushort(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); -H5_DLL herr_t H5T__conv_ullong_short(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); -H5_DLL herr_t H5T__conv_ullong_ushort(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); -H5_DLL herr_t H5T__conv_llong_int(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); -H5_DLL herr_t H5T__conv_llong_uint(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); -H5_DLL herr_t H5T__conv_ullong_int(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); -H5_DLL herr_t H5T__conv_ullong_uint(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); -H5_DLL herr_t H5T__conv_llong_long(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); -H5_DLL herr_t H5T__conv_llong_ulong(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); -H5_DLL herr_t H5T__conv_ullong_long(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); -H5_DLL herr_t H5T__conv_ullong_ulong(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); -H5_DLL herr_t H5T__conv_llong_ullong(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); -H5_DLL herr_t H5T__conv_ullong_llong(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); -H5_DLL herr_t H5T__conv_float_double(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); -H5_DLL 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 bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_double_float(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); -H5_DLL 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 bkg_stride, - void *buf, void *bkg); -H5_DLL 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 bkg_stride, - void *buf, void *bkg); -H5_DLL 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 bkg_stride, - void *buf, void *bkg); -H5_DLL herr_t H5T__conv_schar_float(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); -H5_DLL herr_t H5T__conv_schar_double(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); -H5_DLL herr_t H5T__conv_schar_ldouble(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); -H5_DLL herr_t H5T__conv_uchar_float(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); -H5_DLL herr_t H5T__conv_uchar_double(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); -H5_DLL herr_t H5T__conv_uchar_ldouble(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); -H5_DLL herr_t H5T__conv_short_float(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); -H5_DLL herr_t H5T__conv_short_double(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); -H5_DLL herr_t H5T__conv_short_ldouble(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); -H5_DLL herr_t H5T__conv_ushort_float(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); -H5_DLL herr_t H5T__conv_ushort_double(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); -H5_DLL herr_t H5T__conv_ushort_ldouble(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); -H5_DLL herr_t H5T__conv_int_float(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); -H5_DLL herr_t H5T__conv_int_double(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); -H5_DLL herr_t H5T__conv_int_ldouble(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); -H5_DLL herr_t H5T__conv_uint_float(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); -H5_DLL herr_t H5T__conv_uint_double(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); -H5_DLL herr_t H5T__conv_uint_ldouble(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); -H5_DLL herr_t H5T__conv_long_float(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); -H5_DLL herr_t H5T__conv_long_double(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); -H5_DLL herr_t H5T__conv_long_ldouble(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); -H5_DLL herr_t H5T__conv_ulong_float(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); -H5_DLL herr_t H5T__conv_ulong_double(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); -H5_DLL herr_t H5T__conv_ulong_ldouble(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); -H5_DLL herr_t H5T__conv_llong_float(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); -H5_DLL herr_t H5T__conv_llong_double(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); -H5_DLL herr_t H5T__conv_llong_ldouble(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); -H5_DLL herr_t H5T__conv_ullong_float(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); -H5_DLL herr_t H5T__conv_ullong_double(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); -H5_DLL herr_t H5T__conv_ullong_ldouble(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); -H5_DLL herr_t H5T__conv_float_schar(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); -H5_DLL herr_t H5T__conv_float_uchar(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); -H5_DLL herr_t H5T__conv_float_short(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); -H5_DLL herr_t H5T__conv_float_ushort(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); -H5_DLL herr_t H5T__conv_float_int(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); -H5_DLL herr_t H5T__conv_float_uint(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); -H5_DLL herr_t H5T__conv_float_long(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); -H5_DLL herr_t H5T__conv_float_ulong(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); -H5_DLL herr_t H5T__conv_float_llong(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); -H5_DLL herr_t H5T__conv_float_ullong(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); -H5_DLL herr_t H5T__conv_double_schar(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); -H5_DLL herr_t H5T__conv_double_uchar(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); -H5_DLL herr_t H5T__conv_double_short(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); -H5_DLL herr_t H5T__conv_double_ushort(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); -H5_DLL herr_t H5T__conv_double_int(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); -H5_DLL herr_t H5T__conv_double_uint(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); -H5_DLL herr_t H5T__conv_double_long(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); -H5_DLL herr_t H5T__conv_double_ulong(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); -H5_DLL herr_t H5T__conv_double_llong(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); -H5_DLL herr_t H5T__conv_double_ullong(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); -H5_DLL herr_t H5T__conv_ldouble_schar(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); -H5_DLL herr_t H5T__conv_ldouble_uchar(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); -H5_DLL herr_t H5T__conv_ldouble_short(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); -H5_DLL herr_t H5T__conv_ldouble_ushort(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); -H5_DLL herr_t H5T__conv_ldouble_int(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); -H5_DLL herr_t H5T__conv_ldouble_uint(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); -H5_DLL herr_t H5T__conv_ldouble_long(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); -H5_DLL herr_t H5T__conv_ldouble_ulong(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); -H5_DLL herr_t H5T__conv_ldouble_llong(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); -H5_DLL herr_t H5T__conv_ldouble_ullong(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); +H5_DLL herr_t H5T__conv_schar_uchar(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); +H5_DLL herr_t H5T__conv_uchar_schar(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); +H5_DLL herr_t H5T__conv_schar_short(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); +H5_DLL herr_t H5T__conv_schar_ushort(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); +H5_DLL herr_t H5T__conv_uchar_short(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); +H5_DLL herr_t H5T__conv_uchar_ushort(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); +H5_DLL herr_t H5T__conv_schar_int(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); +H5_DLL herr_t H5T__conv_schar_uint(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); +H5_DLL herr_t H5T__conv_uchar_int(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); +H5_DLL herr_t H5T__conv_uchar_uint(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); +H5_DLL herr_t H5T__conv_schar_long(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); +H5_DLL herr_t H5T__conv_schar_ulong(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); +H5_DLL herr_t H5T__conv_uchar_long(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); +H5_DLL herr_t H5T__conv_uchar_ulong(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); +H5_DLL herr_t H5T__conv_schar_llong(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); +H5_DLL herr_t H5T__conv_schar_ullong(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); +H5_DLL herr_t H5T__conv_uchar_llong(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); +H5_DLL herr_t H5T__conv_uchar_ullong(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); + +H5_DLL herr_t H5T__conv_short_schar(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); +H5_DLL herr_t H5T__conv_short_uchar(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); +H5_DLL herr_t H5T__conv_ushort_schar(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); +H5_DLL herr_t H5T__conv_ushort_uchar(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); +H5_DLL herr_t H5T__conv_short_ushort(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); +H5_DLL herr_t H5T__conv_ushort_short(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); +H5_DLL herr_t H5T__conv_short_int(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); +H5_DLL herr_t H5T__conv_short_uint(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); +H5_DLL herr_t H5T__conv_ushort_int(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); +H5_DLL herr_t H5T__conv_ushort_uint(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); +H5_DLL herr_t H5T__conv_short_long(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); +H5_DLL herr_t H5T__conv_short_ulong(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); +H5_DLL herr_t H5T__conv_ushort_long(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); +H5_DLL herr_t H5T__conv_ushort_ulong(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); +H5_DLL herr_t H5T__conv_short_llong(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); +H5_DLL herr_t H5T__conv_short_ullong(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); +H5_DLL herr_t H5T__conv_ushort_llong(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); +H5_DLL herr_t H5T__conv_ushort_ullong(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); + +H5_DLL herr_t H5T__conv_int_schar(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); +H5_DLL herr_t H5T__conv_int_uchar(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); +H5_DLL herr_t H5T__conv_uint_schar(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); +H5_DLL herr_t H5T__conv_uint_uchar(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); +H5_DLL herr_t H5T__conv_int_short(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); +H5_DLL herr_t H5T__conv_int_ushort(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); +H5_DLL herr_t H5T__conv_uint_short(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); +H5_DLL herr_t H5T__conv_uint_ushort(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); +H5_DLL herr_t H5T__conv_int_uint(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); +H5_DLL herr_t H5T__conv_uint_int(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); +H5_DLL herr_t H5T__conv_int_long(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); +H5_DLL herr_t H5T__conv_int_ulong(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); +H5_DLL herr_t H5T__conv_uint_long(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); +H5_DLL herr_t H5T__conv_uint_ulong(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); +H5_DLL herr_t H5T__conv_int_llong(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); +H5_DLL herr_t H5T__conv_int_ullong(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); +H5_DLL herr_t H5T__conv_uint_llong(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); +H5_DLL herr_t H5T__conv_uint_ullong(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); + +H5_DLL herr_t H5T__conv_long_schar(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); +H5_DLL herr_t H5T__conv_long_uchar(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); +H5_DLL herr_t H5T__conv_ulong_schar(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); +H5_DLL herr_t H5T__conv_ulong_uchar(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); +H5_DLL herr_t H5T__conv_long_short(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); +H5_DLL herr_t H5T__conv_long_ushort(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); +H5_DLL herr_t H5T__conv_ulong_short(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); +H5_DLL herr_t H5T__conv_ulong_ushort(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); +H5_DLL herr_t H5T__conv_long_int(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); +H5_DLL herr_t H5T__conv_long_uint(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); +H5_DLL herr_t H5T__conv_ulong_int(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); +H5_DLL herr_t H5T__conv_ulong_uint(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); +H5_DLL herr_t H5T__conv_long_ulong(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); +H5_DLL herr_t H5T__conv_ulong_long(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); +H5_DLL herr_t H5T__conv_long_llong(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); +H5_DLL herr_t H5T__conv_long_ullong(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); +H5_DLL herr_t H5T__conv_ulong_llong(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); +H5_DLL herr_t H5T__conv_ulong_ullong(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); + +H5_DLL herr_t H5T__conv_llong_schar(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); +H5_DLL herr_t H5T__conv_llong_uchar(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); +H5_DLL herr_t H5T__conv_ullong_schar(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); +H5_DLL herr_t H5T__conv_ullong_uchar(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); +H5_DLL herr_t H5T__conv_llong_short(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); +H5_DLL herr_t H5T__conv_llong_ushort(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); +H5_DLL herr_t H5T__conv_ullong_short(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); +H5_DLL herr_t H5T__conv_ullong_ushort(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); +H5_DLL herr_t H5T__conv_llong_int(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); +H5_DLL herr_t H5T__conv_llong_uint(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); +H5_DLL herr_t H5T__conv_ullong_int(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); +H5_DLL herr_t H5T__conv_ullong_uint(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); +H5_DLL herr_t H5T__conv_llong_long(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); +H5_DLL herr_t H5T__conv_llong_ulong(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); +H5_DLL herr_t H5T__conv_ullong_long(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); +H5_DLL herr_t H5T__conv_ullong_ulong(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); +H5_DLL herr_t H5T__conv_llong_ullong(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); +H5_DLL herr_t H5T__conv_ullong_llong(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); +H5_DLL herr_t H5T__conv_float_double(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); +H5_DLL 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 bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double_float(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); +H5_DLL 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 bkg_stride, void *buf, void *bkg); +H5_DLL 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 bkg_stride, void *buf, void *bkg); +H5_DLL 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 bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_schar_float(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); +H5_DLL herr_t H5T__conv_schar_double(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); +H5_DLL herr_t H5T__conv_schar_ldouble(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); +H5_DLL herr_t H5T__conv_uchar_float(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); +H5_DLL herr_t H5T__conv_uchar_double(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); +H5_DLL herr_t H5T__conv_uchar_ldouble(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); +H5_DLL herr_t H5T__conv_short_float(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); +H5_DLL herr_t H5T__conv_short_double(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); +H5_DLL herr_t H5T__conv_short_ldouble(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); +H5_DLL herr_t H5T__conv_ushort_float(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); +H5_DLL herr_t H5T__conv_ushort_double(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); +H5_DLL herr_t H5T__conv_ushort_ldouble(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); +H5_DLL herr_t H5T__conv_int_float(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); +H5_DLL herr_t H5T__conv_int_double(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); +H5_DLL herr_t H5T__conv_int_ldouble(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); +H5_DLL herr_t H5T__conv_uint_float(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); +H5_DLL herr_t H5T__conv_uint_double(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); +H5_DLL herr_t H5T__conv_uint_ldouble(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); +H5_DLL herr_t H5T__conv_long_float(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); +H5_DLL herr_t H5T__conv_long_double(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); +H5_DLL herr_t H5T__conv_long_ldouble(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); +H5_DLL herr_t H5T__conv_ulong_float(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); +H5_DLL herr_t H5T__conv_ulong_double(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); +H5_DLL herr_t H5T__conv_ulong_ldouble(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); +H5_DLL herr_t H5T__conv_llong_float(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); +H5_DLL herr_t H5T__conv_llong_double(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); +H5_DLL herr_t H5T__conv_llong_ldouble(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); +H5_DLL herr_t H5T__conv_ullong_float(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); +H5_DLL herr_t H5T__conv_ullong_double(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); +H5_DLL herr_t H5T__conv_ullong_ldouble(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); +H5_DLL herr_t H5T__conv_float_schar(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); +H5_DLL herr_t H5T__conv_float_uchar(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); +H5_DLL herr_t H5T__conv_float_short(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); +H5_DLL herr_t H5T__conv_float_ushort(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); +H5_DLL herr_t H5T__conv_float_int(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); +H5_DLL herr_t H5T__conv_float_uint(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); +H5_DLL herr_t H5T__conv_float_long(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); +H5_DLL herr_t H5T__conv_float_ulong(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); +H5_DLL herr_t H5T__conv_float_llong(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); +H5_DLL herr_t H5T__conv_float_ullong(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); +H5_DLL herr_t H5T__conv_double_schar(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); +H5_DLL herr_t H5T__conv_double_uchar(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); +H5_DLL herr_t H5T__conv_double_short(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); +H5_DLL herr_t H5T__conv_double_ushort(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); +H5_DLL herr_t H5T__conv_double_int(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); +H5_DLL herr_t H5T__conv_double_uint(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); +H5_DLL herr_t H5T__conv_double_long(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); +H5_DLL herr_t H5T__conv_double_ulong(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); +H5_DLL herr_t H5T__conv_double_llong(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); +H5_DLL herr_t H5T__conv_double_ullong(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); +H5_DLL herr_t H5T__conv_ldouble_schar(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); +H5_DLL herr_t H5T__conv_ldouble_uchar(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); +H5_DLL herr_t H5T__conv_ldouble_short(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); +H5_DLL herr_t H5T__conv_ldouble_ushort(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); +H5_DLL herr_t H5T__conv_ldouble_int(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); +H5_DLL herr_t H5T__conv_ldouble_uint(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); +H5_DLL herr_t H5T__conv_ldouble_long(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); +H5_DLL herr_t H5T__conv_ldouble_ulong(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); +H5_DLL herr_t H5T__conv_ldouble_llong(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); +H5_DLL herr_t H5T__conv_ldouble_ullong(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); /* Bit twiddling functions */ -H5_DLL void H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, - size_t src_offset, size_t size); -H5_DLL herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); -H5_DLL void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, - hbool_t value); +H5_DLL void H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, + size_t size); +H5_DLL herr_t H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size); +H5_DLL void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value); H5_DLL uint64_t H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size); -H5_DLL void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, - uint64_t val); -H5_DLL ssize_t H5T__bit_find(uint8_t *buf, size_t offset, size_t size, - H5T_sdir_t direction, hbool_t value); -H5_DLL hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size); -H5_DLL hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size); -H5_DLL void H5T__bit_neg(uint8_t *buf, size_t start, size_t size); +H5_DLL void H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val); +H5_DLL ssize_t H5T__bit_find(const uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, + hbool_t value); +H5_DLL hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size); +H5_DLL hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size); +H5_DLL void H5T__bit_neg(uint8_t *buf, size_t start, size_t size); /* VL functions */ -H5_DLL H5T_t * H5T__vlen_create(const H5T_t *base); -H5_DLL htri_t H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc); +H5_DLL H5T_t *H5T__vlen_create(const H5T_t *base); +H5_DLL herr_t H5T__vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info); +H5_DLL htri_t H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); /* Array functions */ H5_DLL H5T_t *H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]); H5_DLL int H5T__get_array_ndims(const H5T_t *dt); H5_DLL int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]); +/* Reference functions */ +H5_DLL herr_t H5T__ref_reclaim(void *elem, const H5T_t *dt); +H5_DLL htri_t H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); + /* Compound functions */ -H5_DLL herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, - const H5T_t *member); +H5_DLL herr_t H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member); H5_DLL size_t H5T__get_member_size(const H5T_t *dt, unsigned membno); -H5_DLL void H5T__update_packed(const H5T_t *dt); +H5_DLL void H5T__update_packed(const H5T_t *dt); H5_DLL H5T_subset_info_t *H5T__conv_struct_subset(const H5T_cdata_t *cdata); /* Enumerated type functions */ @@ -1159,12 +884,11 @@ H5_DLL herr_t H5T__enum_insert(const H5T_t *dt, const char *name, const void *va H5_DLL herr_t H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value); /* Field functions (for both compound & enumerated types) */ -H5_DLL char *H5T__get_member_name(H5T_t const *dt, unsigned membno); +H5_DLL char * H5T__get_member_name(H5T_t const *dt, unsigned membno); H5_DLL herr_t H5T__sort_value(const H5T_t *dt, int *map); H5_DLL herr_t H5T__sort_name(const H5T_t *dt, int *map); /* Debugging functions */ -H5_DLL herr_t H5T__print_stats(H5T_path_t *path, int *nprint/*in,out*/); - -#endif /* _H5Tpkg_H */ +H5_DLL herr_t H5T__print_stats(H5T_path_t *path, int *nprint /*in,out*/); +#endif /* H5Tpkg_H */ diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index 635fb631d4e..1dc0073fcc4 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,19 +16,16 @@ * the datatype precision for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ /* Static local functions */ static herr_t H5T__set_precision(const H5T_t *dt, size_t prec); - - /*------------------------------------------------------------------------- * Function: H5Tget_precision * @@ -50,25 +47,24 @@ static herr_t H5T__set_precision(const H5T_t *dt, size_t prec); size_t H5Tget_precision(hid_t type_id) { - H5T_t *dt; - size_t ret_value; + H5T_t *dt; + size_t ret_value; FUNC_ENTER_API(0) H5TRACE1("z", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Get precision */ - if((ret_value = H5T_get_precision(dt)) == 0) + if ((ret_value = H5T_get_precision(dt)) == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, 0, "cant't get precision for specified datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tget_precision() */ - /*------------------------------------------------------------------------- * Function: H5T_get_precision * @@ -89,14 +85,14 @@ H5Tget_precision(hid_t type_id) size_t H5T_get_precision(const H5T_t *dt) { - size_t ret_value = 0; /* Return value */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) /* Defer to parent*/ - while(dt->shared->parent) + while (dt->shared->parent) dt = dt->shared->parent; - if(!H5T_IS_ATOMIC(dt->shared)) + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified datatype") /* Precision */ @@ -106,7 +102,6 @@ H5T_get_precision(const H5T_t *dt) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_precision() */ - /*------------------------------------------------------------------------- * Function: H5Tset_precision * @@ -135,35 +130,36 @@ H5T_get_precision(const H5T_t *dt) herr_t H5Tset_precision(hid_t type_id, size_t prec) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, prec); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is committed") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") - if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) + if (H5T_ENUM == dt->shared->type && dt->shared->u.enumer.nmembs > 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after members are defined") - if (H5T_STRING==dt->shared->type) + if (H5T_STRING == dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "precision for this type is read-only") - if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) + if (H5T_COMPOUND == dt->shared->type || H5T_OPAQUE == dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified datatype") /* Do the work */ - if (H5T__set_precision(dt, prec)<0) + if (H5T__set_precision(dt, prec) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision") done: FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5T__set_precision * @@ -192,39 +188,40 @@ H5Tset_precision(hid_t type_id, size_t prec) static herr_t H5T__set_precision(const H5T_t *dt, size_t prec) { - size_t offset, size; - herr_t ret_value=SUCCEED; /* Return value */ + size_t offset, size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(dt); - HDassert(prec>0); - HDassert(H5T_OPAQUE!=dt->shared->type); - HDassert(H5T_COMPOUND!=dt->shared->type); - HDassert(H5T_STRING!=dt->shared->type); - HDassert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + HDassert(prec > 0); + HDassert(H5T_OPAQUE != dt->shared->type); + HDassert(H5T_COMPOUND != dt->shared->type); + HDassert(H5T_STRING != dt->shared->type); + HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs)); if (dt->shared->parent) { - if (H5T__set_precision(dt->shared->parent, prec)<0) + if (H5T__set_precision(dt->shared->parent, prec) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision for base type") /* Adjust size of datatype appropriately */ - if(dt->shared->type==H5T_ARRAY) + if (dt->shared->type == H5T_ARRAY) dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; - else if(dt->shared->type!=H5T_VLEN) + else if (dt->shared->type != H5T_VLEN) dt->shared->size = dt->shared->parent->shared->size; - } else { + } + else { if (H5T_IS_ATOMIC(dt->shared)) { /* Adjust the offset and size */ offset = dt->shared->u.atomic.offset; - size = dt->shared->size; - if (prec > 8*size) + size = dt->shared->size; + if (prec > 8 * size) offset = 0; - else if (offset+prec > 8 * size) + else if (offset + prec > 8 * size) offset = 8 * size - prec; - if (prec > 8*size) - size = (prec+7) / 8; + if (prec > 8 * size) + size = (prec + 7) / 8; /* Check that things are still kosher */ switch (dt->shared->type) { @@ -240,10 +237,11 @@ H5T__set_precision(const H5T_t *dt, size_t prec) * first when decreasing the precision of a floating point * type. */ - if (dt->shared->u.atomic.u.f.sign >= prec+offset || - dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || - dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") + if (dt->shared->u.atomic.u.f.sign >= prec + offset || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec + offset || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec + offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "adjust sign, mantissa, and exponent fields first") break; case H5T_NO_CLASS: @@ -257,12 +255,12 @@ H5T__set_precision(const H5T_t *dt, size_t prec) case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") - } /* end switch */ + } /* end switch */ /* Commit */ - dt->shared->size = size; + dt->shared->size = size; dt->shared->u.atomic.offset = offset; - dt->shared->u.atomic.prec = prec; + dt->shared->u.atomic.prec = prec; } /* end if */ else HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified datatype") @@ -271,4 +269,3 @@ H5T__set_precision(const H5T_t *dt, size_t prec) done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 4682d79b2f3..9ee0d0462a1 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,8 +14,8 @@ /* * This file contains private information about the H5T module */ -#ifndef _H5Tprivate_H -#define _H5Tprivate_H +#ifndef H5Tprivate_H +#define H5Tprivate_H /* Early typedefs to avoid circular dependencies */ typedef struct H5T_t H5T_t; @@ -24,59 +24,62 @@ typedef struct H5T_t H5T_t; #include "H5Tpublic.h" /* Other public headers needed by this file */ -#include "H5MMpublic.h" /* Memory management */ +#include "H5MMpublic.h" /* Memory management */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Rprivate.h" /* References */ +#include "H5private.h" /* Generic Functions */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Rprivate.h" /* References */ +#include "H5VLprivate.h" /* VOL Drivers */ /* Macro for size of temporary buffers to contain a single element */ -#define H5T_ELEM_BUF_SIZE 256 +#define H5T_ELEM_BUF_SIZE 256 /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5T_MODULE -#define H5T_GET_SIZE(T) ((T)->shared->size) -#define H5T_GET_SHARED(T) ((T)->shared) -#define H5T_GET_MEMBER_OFFSET(T, I) ((T)->u.compnd.memb[I].offset) -#define H5T_GET_MEMBER_SIZE(T, I) ((T)->u.compnd.memb[I].shared->size) +#define H5T_GET_SIZE(T) ((T)->shared->size) +#define H5T_GET_SHARED(T) ((T)->shared) +#define H5T_GET_MEMBER_OFFSET(T, I) ((T)->u.compnd.memb[I].offset) +#define H5T_GET_MEMBER_SIZE(T, I) ((T)->u.compnd.memb[I].shared->size) +#define H5T_GET_FORCE_CONV(T) ((T)->shared->force_conv) #else /* H5T_MODULE */ -#define H5T_GET_SIZE(T) (H5T_get_size(T)) -#define H5T_GET_SHARED(T) (H5T_get_shared(T)) -#define H5T_GET_MEMBER_OFFSET(T, I) (H5T_get_member_offset((T), (I))) -#define H5T_GET_MEMBER_SIZE(T, I) (H5T_get_member_size((T), (I))) +#define H5T_GET_SIZE(T) (H5T_get_size(T)) +#define H5T_GET_SHARED(T) (H5T_get_shared(T)) +#define H5T_GET_MEMBER_OFFSET(T, I) (H5T_get_member_offset((T), (I))) +#define H5T_GET_MEMBER_SIZE(T, I) (H5T_get_member_size((T), (I))) +#define H5T_GET_FORCE_CONV(T) (H5T_get_force_conv(T)) #endif /* H5T_MODULE */ /* Forward references of package typedefs (declared in H5Tpkg.h) */ typedef struct H5T_stats_t H5T_stats_t; -typedef struct H5T_path_t H5T_path_t; +typedef struct H5T_path_t H5T_path_t; + +/* Forward reference of H5S_t */ +struct H5S_t; /* How to copy a datatype */ -typedef enum H5T_copy_t { - H5T_COPY_TRANSIENT, - H5T_COPY_ALL -} H5T_copy_t; +typedef enum H5T_copy_t { H5T_COPY_TRANSIENT, H5T_COPY_ALL } H5T_copy_t; /* Location of datatype information */ typedef enum { - H5T_LOC_BADLOC = 0, /* invalid datatype location */ - H5T_LOC_MEMORY, /* data stored in memory */ - H5T_LOC_DISK, /* data stored on disk */ - H5T_LOC_MAXLOC /* highest value (Invalid as true value) */ + H5T_LOC_BADLOC = 0, /* invalid datatype location */ + H5T_LOC_MEMORY, /* data stored in memory */ + H5T_LOC_DISK, /* data stored on disk */ + H5T_LOC_MAXLOC /* highest value (Invalid as true value) */ } H5T_loc_t; /* VL allocation information */ typedef struct { H5MM_allocate_t alloc_func; /* Allocation function */ - void *alloc_info; /* Allocation information */ - H5MM_free_t free_func; /* Free function */ - void *free_info; /* Free information */ + void * alloc_info; /* Allocation information */ + H5MM_free_t free_func; /* Free function */ + void * free_info; /* Free information */ } H5T_vlen_alloc_info_t; /* Structure for conversion callback property */ typedef struct H5T_conv_cb_t { - H5T_conv_except_func_t func; - void* user_data; + H5T_conv_except_func_t func; + void * user_data; } H5T_conv_cb_t; /* Values for the optimization of compound data reading and writing. They indicate @@ -84,20 +87,20 @@ typedef struct H5T_conv_cb_t { * there is no conversion needed. */ typedef enum { - H5T_SUBSET_BADVALUE = -1, /* Invalid value */ - H5T_SUBSET_FALSE = 0, /* Source and destination aren't subset of each other */ - H5T_SUBSET_SRC, /* Source is the subset of dest and no conversion is needed */ - H5T_SUBSET_DST, /* Dest is the subset of source and no conversion is needed */ - H5T_SUBSET_CAP /* Must be the last value */ + H5T_SUBSET_BADVALUE = -1, /* Invalid value */ + H5T_SUBSET_FALSE = 0, /* Source and destination aren't subset of each other */ + H5T_SUBSET_SRC, /* Source is the subset of dest and no conversion is needed */ + H5T_SUBSET_DST, /* Dest is the subset of source and no conversion is needed */ + H5T_SUBSET_CAP /* Must be the last value */ } H5T_subset_t; typedef struct H5T_subset_info_t { - H5T_subset_t subset; /* See above */ - size_t copy_size; /* Size in bytes, to copy for each element */ + H5T_subset_t subset; /* See above */ + size_t copy_size; /* Size in bytes, to copy for each element */ } H5T_subset_info_t; /* Forward declarations for prototype arguments */ -struct H5O_t; +struct H5O_shared_t; /* The native endianness of the platform */ H5_DLLVAR H5T_order_t H5T_native_order_g; @@ -109,44 +112,52 @@ H5_DLL H5T_t *H5T_copy_reopen(H5T_t *old_dt); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL herr_t H5T_close_real(H5T_t *dt); -H5_DLL H5T_t *H5T_get_super(const H5T_t *dt); +H5_DLL H5T_t * H5T_get_super(const H5T_t *dt); H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal); -H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api); -H5_DLL size_t H5T_get_size(const H5T_t *dt); -H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset); -H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); -H5_DLL H5T_t *H5T_decode(size_t buf_size, const unsigned char *buf); -H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream); +H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api); +H5_DLL size_t H5T_get_size(const H5T_t *dt); +H5_DLL hbool_t H5T_get_force_conv(const H5T_t *dt); +H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset); +H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); +H5_DLL H5T_t * H5T_decode(size_t buf_size, const unsigned char *buf); +H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE *stream); H5_DLL struct H5O_loc_t *H5T_oloc(H5T_t *dt); H5_DLL H5G_name_t *H5T_nameof(const H5T_t *dt); -H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); -H5_DLL htri_t H5T_is_named(const H5T_t *dt); -H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); -H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt); +H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); +H5_DLL htri_t H5T_is_named(const H5T_t *dt); +H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); +H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt); H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst); -H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); -H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); +H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p); +H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p); H5_DLL H5T_subset_info_t *H5T_path_compound_subset(const H5T_path_t *p); -H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, - size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); -H5_DLL herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_op_data); +H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, + size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T_reclaim(hid_t type_id, struct H5S_t *space, void *buf); +H5_DLL herr_t H5T_reclaim_cb(void *elem, const H5T_t *dt, unsigned ndim, const hsize_t *point, void *op_data); H5_DLL herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt); -H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc); +H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc); H5_DLL htri_t H5T_is_sensible(const H5T_t *dt); -H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt); -H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); -H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); -H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5F_t *f); -H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); -H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt); +H5_DLL uint32_t H5T_hash(H5F_t *file, const H5T_t *dt); +H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); +H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); +H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file); +H5_DLL herr_t H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj); +H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); +H5_DLL H5T_t *H5T_construct_datatype(H5VL_object_t *dt_obj); +H5_DLL H5VL_object_t *H5T_get_named_type(const H5T_t *dt); +H5_DLL H5T_t * H5T_get_actual_type(H5T_t *dt); +H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL hbool_t H5T_already_vol_managed(const H5T_t *dt); +H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); /* Operations on named datatypes */ H5_DLL H5T_t *H5T_open(const H5G_loc_t *loc); -H5_DLL htri_t H5T_committed(const H5T_t *type); -H5_DLL int H5T_link(const H5T_t *type, int adjust); +H5_DLL int H5T_link(const H5T_t *type, int adjust); H5_DLL herr_t H5T_update_shared(H5T_t *type); /* Field functions (for both compound & enumerated types) */ @@ -156,11 +167,10 @@ H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno); /* Atomic functions */ H5_DLL H5T_order_t H5T_get_order(const H5T_t *dt); -H5_DLL size_t H5T_get_precision(const H5T_t *dt); -H5_DLL int H5T_get_offset(const H5T_t *dt); +H5_DLL size_t H5T_get_precision(const H5T_t *dt); +H5_DLL int H5T_get_offset(const H5T_t *dt); /* Fixed-point functions */ H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt); -#endif /* _H5Tprivate_H */ - +#endif /* H5Tprivate_H */ diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index fc3e4ee3408..b7085060fe9 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,221 +14,310 @@ /* * This file contains public declarations for the H5T module. */ -#ifndef _H5Tpublic_H -#define _H5Tpublic_H +#ifndef H5Tpublic_H +#define H5Tpublic_H /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" -#define HOFFSET(S,M) (offsetof(S,M)) +#define HOFFSET(S, M) (offsetof(S, M)) -/* These are the various classes of datatypes */ -/* If this goes over 16 types (0-15), the file format will need to change) */ +/** + * These are the various classes of datatypes + * internal If this goes over 16 types (0-15), the file format will need to + * change. + */ +//! typedef enum H5T_class_t { - H5T_NO_CLASS = -1, /*error */ - H5T_INTEGER = 0, /*integer types */ - H5T_FLOAT = 1, /*floating-point types */ - H5T_TIME = 2, /*date and time types */ - H5T_STRING = 3, /*character string types */ - H5T_BITFIELD = 4, /*bit field types */ - H5T_OPAQUE = 5, /*opaque types */ - H5T_COMPOUND = 6, /*compound types */ - H5T_REFERENCE = 7, /*reference types */ - H5T_ENUM = 8, /*enumeration types */ - H5T_VLEN = 9, /*Variable-Length types */ - H5T_ARRAY = 10, /*Array types */ - - H5T_NCLASSES /*this must be last */ + H5T_NO_CLASS = -1, /**< error */ + H5T_INTEGER = 0, /**< integer types */ + H5T_FLOAT = 1, /**< floating-point types */ + H5T_TIME = 2, /**< date and time types */ + H5T_STRING = 3, /**< character string types */ + H5T_BITFIELD = 4, /**< bit field types */ + H5T_OPAQUE = 5, /**< opaque types */ + H5T_COMPOUND = 6, /**< compound types */ + H5T_REFERENCE = 7, /**< reference types */ + H5T_ENUM = 8, /**< enumeration types */ + H5T_VLEN = 9, /**< variable-Length types */ + H5T_ARRAY = 10, /**< array types */ + + H5T_NCLASSES /**< sentinel: this must be last */ } H5T_class_t; +//! -/* Byte orders */ +/** + * Byte orders + */ +//! typedef enum H5T_order_t { - H5T_ORDER_ERROR = -1, /*error */ - H5T_ORDER_LE = 0, /*little endian */ - H5T_ORDER_BE = 1, /*bit endian */ - H5T_ORDER_VAX = 2, /*VAX mixed endian */ - H5T_ORDER_MIXED = 3, /*Compound type with mixed member orders */ - H5T_ORDER_NONE = 4 /*no particular order (strings, bits,..) */ + H5T_ORDER_ERROR = -1, /**< error */ + H5T_ORDER_LE = 0, /**< little endian */ + H5T_ORDER_BE = 1, /**< bit endian */ + H5T_ORDER_VAX = 2, /**< VAX mixed endian */ + H5T_ORDER_MIXED = 3, /**< Compound type with mixed member orders */ + H5T_ORDER_NONE = 4 /**< no particular order (strings, bits,..) */ /*H5T_ORDER_NONE must be last */ } H5T_order_t; +//! -/* Types of integer sign schemes */ +/** + * Types of integer sign schemes + */ +//! typedef enum H5T_sign_t { - H5T_SGN_ERROR = -1, /*error */ - H5T_SGN_NONE = 0, /*this is an unsigned type */ - H5T_SGN_2 = 1, /*two's complement */ + H5T_SGN_ERROR = -1, /**< error */ + H5T_SGN_NONE = 0, /**< this is an unsigned type */ + H5T_SGN_2 = 1, /**< two's complement */ - H5T_NSGN = 2 /*this must be last! */ + H5T_NSGN = 2 /** sentinel: this must be last! */ } H5T_sign_t; +//! -/* Floating-point normalization schemes */ +/** + * Floating-point normalization schemes + */ +//! typedef enum H5T_norm_t { - H5T_NORM_ERROR = -1, /*error */ - H5T_NORM_IMPLIED = 0, /*msb of mantissa isn't stored, always 1 */ - H5T_NORM_MSBSET = 1, /*msb of mantissa is always 1 */ - H5T_NORM_NONE = 2 /*not normalized */ + H5T_NORM_ERROR = -1, /**< error */ + H5T_NORM_IMPLIED = 0, /**< msb of mantissa isn't stored, always 1 */ + H5T_NORM_MSBSET = 1, /**< msb of mantissa is always 1 */ + H5T_NORM_NONE = 2 /**< not normalized */ /*H5T_NORM_NONE must be last */ } H5T_norm_t; +//! -/* - * Character set to use for text strings. Do not change these values since - * they appear in HDF5 files! +/** + * Character set to use for text strings. + * \internal Do not change these values since they appear in HDF5 files! */ typedef enum H5T_cset_t { - H5T_CSET_ERROR = -1, /*error */ - H5T_CSET_ASCII = 0, /*US ASCII */ - H5T_CSET_UTF8 = 1, /*UTF-8 Unicode encoding */ - H5T_CSET_RESERVED_2 = 2, /*reserved for later use */ - H5T_CSET_RESERVED_3 = 3, /*reserved for later use */ - H5T_CSET_RESERVED_4 = 4, /*reserved for later use */ - H5T_CSET_RESERVED_5 = 5, /*reserved for later use */ - H5T_CSET_RESERVED_6 = 6, /*reserved for later use */ - H5T_CSET_RESERVED_7 = 7, /*reserved for later use */ - H5T_CSET_RESERVED_8 = 8, /*reserved for later use */ - H5T_CSET_RESERVED_9 = 9, /*reserved for later use */ - H5T_CSET_RESERVED_10 = 10, /*reserved for later use */ - H5T_CSET_RESERVED_11 = 11, /*reserved for later use */ - H5T_CSET_RESERVED_12 = 12, /*reserved for later use */ - H5T_CSET_RESERVED_13 = 13, /*reserved for later use */ - H5T_CSET_RESERVED_14 = 14, /*reserved for later use */ - H5T_CSET_RESERVED_15 = 15 /*reserved for later use */ + H5T_CSET_ERROR = -1, /**< error */ + H5T_CSET_ASCII = 0, /**< US ASCII */ + H5T_CSET_UTF8 = 1, /**< UTF-8 Unicode encoding */ + H5T_CSET_RESERVED_2 = 2, /**< reserved for later use */ + H5T_CSET_RESERVED_3 = 3, /**< reserved for later use */ + H5T_CSET_RESERVED_4 = 4, /**< reserved for later use */ + H5T_CSET_RESERVED_5 = 5, /**< reserved for later use */ + H5T_CSET_RESERVED_6 = 6, /**< reserved for later use */ + H5T_CSET_RESERVED_7 = 7, /**< reserved for later use */ + H5T_CSET_RESERVED_8 = 8, /**< reserved for later use */ + H5T_CSET_RESERVED_9 = 9, /**< reserved for later use */ + H5T_CSET_RESERVED_10 = 10, /**< reserved for later use */ + H5T_CSET_RESERVED_11 = 11, /**< reserved for later use */ + H5T_CSET_RESERVED_12 = 12, /**< reserved for later use */ + H5T_CSET_RESERVED_13 = 13, /**< reserved for later use */ + H5T_CSET_RESERVED_14 = 14, /**< reserved for later use */ + H5T_CSET_RESERVED_15 = 15 /**< reserved for later use */ } H5T_cset_t; -#define H5T_NCSET H5T_CSET_RESERVED_2 /*Number of character sets actually defined */ +#define H5T_NCSET H5T_CSET_RESERVED_2 /*Number of character sets actually defined */ -/* - * Type of padding to use in character strings. Do not change these values - * since they appear in HDF5 files! +/** + * Type of padding to use in character strings. + * \internal Do not change these values since they appear in HDF5 files! */ typedef enum H5T_str_t { - H5T_STR_ERROR = -1, /*error */ - H5T_STR_NULLTERM = 0, /*null terminate like in C */ - H5T_STR_NULLPAD = 1, /*pad with nulls */ - H5T_STR_SPACEPAD = 2, /*pad with spaces like in Fortran */ - H5T_STR_RESERVED_3 = 3, /*reserved for later use */ - H5T_STR_RESERVED_4 = 4, /*reserved for later use */ - H5T_STR_RESERVED_5 = 5, /*reserved for later use */ - H5T_STR_RESERVED_6 = 6, /*reserved for later use */ - H5T_STR_RESERVED_7 = 7, /*reserved for later use */ - H5T_STR_RESERVED_8 = 8, /*reserved for later use */ - H5T_STR_RESERVED_9 = 9, /*reserved for later use */ - H5T_STR_RESERVED_10 = 10, /*reserved for later use */ - H5T_STR_RESERVED_11 = 11, /*reserved for later use */ - H5T_STR_RESERVED_12 = 12, /*reserved for later use */ - H5T_STR_RESERVED_13 = 13, /*reserved for later use */ - H5T_STR_RESERVED_14 = 14, /*reserved for later use */ - H5T_STR_RESERVED_15 = 15 /*reserved for later use */ + H5T_STR_ERROR = -1, /**< error */ + H5T_STR_NULLTERM = 0, /**< null terminate like in C */ + H5T_STR_NULLPAD = 1, /**< pad with nulls */ + H5T_STR_SPACEPAD = 2, /**< pad with spaces like in Fortran */ + H5T_STR_RESERVED_3 = 3, /**< reserved for later use */ + H5T_STR_RESERVED_4 = 4, /**< reserved for later use */ + H5T_STR_RESERVED_5 = 5, /**< reserved for later use */ + H5T_STR_RESERVED_6 = 6, /**< reserved for later use */ + H5T_STR_RESERVED_7 = 7, /**< reserved for later use */ + H5T_STR_RESERVED_8 = 8, /**< reserved for later use */ + H5T_STR_RESERVED_9 = 9, /**< reserved for later use */ + H5T_STR_RESERVED_10 = 10, /**< reserved for later use */ + H5T_STR_RESERVED_11 = 11, /**< reserved for later use */ + H5T_STR_RESERVED_12 = 12, /**< reserved for later use */ + H5T_STR_RESERVED_13 = 13, /**< reserved for later use */ + H5T_STR_RESERVED_14 = 14, /**< reserved for later use */ + H5T_STR_RESERVED_15 = 15 /**< reserved for later use */ } H5T_str_t; -#define H5T_NSTR H5T_STR_RESERVED_3 /*num H5T_str_t types actually defined */ +#define H5T_NSTR H5T_STR_RESERVED_3 /*num H5T_str_t types actually defined */ -/* Type of padding to use in other atomic types */ +/** + * Type of padding to use in other atomic types + */ +//! typedef enum H5T_pad_t { - H5T_PAD_ERROR = -1, /*error */ - H5T_PAD_ZERO = 0, /*always set to zero */ - H5T_PAD_ONE = 1, /*always set to one */ - H5T_PAD_BACKGROUND = 2, /*set to background value */ + H5T_PAD_ERROR = -1, /**< error */ + H5T_PAD_ZERO = 0, /**< always set to zero */ + H5T_PAD_ONE = 1, /**< always set to one */ + H5T_PAD_BACKGROUND = 2, /**< set to background value */ - H5T_NPAD = 3 /*THIS MUST BE LAST */ + H5T_NPAD = 3 /**< sentinal: THIS MUST BE LAST */ } H5T_pad_t; +//! -/* Commands sent to conversion functions */ +/** + * Commands sent to conversion functions + */ typedef enum H5T_cmd_t { - H5T_CONV_INIT = 0, /*query and/or initialize private data */ - H5T_CONV_CONV = 1, /*convert data from source to dest datatype */ - H5T_CONV_FREE = 2 /*function is being removed from path */ + H5T_CONV_INIT = 0, /**< query and/or initialize private data */ + H5T_CONV_CONV = 1, /**< convert data from source to dest datatype */ + H5T_CONV_FREE = 2 /**< function is being removed from path */ } H5T_cmd_t; -/* How is the `bkg' buffer used by the conversion function? */ +/** + * How is the `bkg' buffer used by the conversion function? + */ typedef enum H5T_bkg_t { - H5T_BKG_NO = 0, /*background buffer is not needed, send NULL */ - H5T_BKG_TEMP = 1, /*bkg buffer used as temp storage only */ - H5T_BKG_YES = 2 /*init bkg buf with data before conversion */ + H5T_BKG_NO = 0, /**< background buffer is not needed, send NULL */ + H5T_BKG_TEMP = 1, /**< bkg buffer used as temp storage only */ + H5T_BKG_YES = 2 /**< init bkg buf with data before conversion */ } H5T_bkg_t; -/* Type conversion client data */ +/** + * Type conversion client data + */ +//! typedef struct H5T_cdata_t { - H5T_cmd_t command;/*what should the conversion function do? */ - H5T_bkg_t need_bkg;/*is the background buffer needed? */ - hbool_t recalc; /*recalculate private data */ - void *priv; /*private data */ + H5T_cmd_t command; /**< what should the conversion function do? */ + H5T_bkg_t need_bkg; /**< is the background buffer needed? */ + hbool_t recalc; /**< recalculate private data */ + void * priv; /**< private data */ } H5T_cdata_t; +//! -/* Conversion function persistence */ +/** + * Conversion function persistence + */ typedef enum H5T_pers_t { - H5T_PERS_DONTCARE = -1, /*wild card */ - H5T_PERS_HARD = 0, /*hard conversion function */ - H5T_PERS_SOFT = 1 /*soft conversion function */ + H5T_PERS_DONTCARE = -1, /**< wild card */ + H5T_PERS_HARD = 0, /**< hard conversion function */ + H5T_PERS_SOFT = 1 /**< soft conversion function */ } H5T_pers_t; -/* The order to retrieve atomic native datatype */ +/** + * The order to retrieve atomic native datatype + */ +//! typedef enum H5T_direction_t { - H5T_DIR_DEFAULT = 0, /*default direction is inscendent */ - H5T_DIR_ASCEND = 1, /*in inscendent order */ - H5T_DIR_DESCEND = 2 /*in descendent order */ + H5T_DIR_DEFAULT = 0, /**< default direction is inscendent */ + H5T_DIR_ASCEND = 1, /**< in inscendent order */ + H5T_DIR_DESCEND = 2 /**< in descendent order */ } H5T_direction_t; +//! -/* The exception type passed into the conversion callback function */ +/** + * The exception type passed into the conversion callback function + */ typedef enum H5T_conv_except_t { - H5T_CONV_EXCEPT_RANGE_HI = 0, /*source value is greater than destination's range */ - H5T_CONV_EXCEPT_RANGE_LOW = 1, /*source value is less than destination's range */ - H5T_CONV_EXCEPT_PRECISION = 2, /*source value loses precision in destination */ - H5T_CONV_EXCEPT_TRUNCATE = 3, /*source value is truncated in destination */ - H5T_CONV_EXCEPT_PINF = 4, /*source value is positive infinity(floating number) */ - H5T_CONV_EXCEPT_NINF = 5, /*source value is negative infinity(floating number) */ - H5T_CONV_EXCEPT_NAN = 6 /*source value is NaN(floating number) */ + H5T_CONV_EXCEPT_RANGE_HI = 0, + /**< Source value is greater than destination's range */ + H5T_CONV_EXCEPT_RANGE_LOW = 1, + /**< Source value is less than destination's range */ + H5T_CONV_EXCEPT_PRECISION = 2, + /**< Source value loses precision in destination */ + H5T_CONV_EXCEPT_TRUNCATE = 3, + /**< Source value is truncated in destination */ + H5T_CONV_EXCEPT_PINF = 4, + /**< Source value is positive infinity */ + H5T_CONV_EXCEPT_NINF = 5, + /**< Source value is negative infinity */ + H5T_CONV_EXCEPT_NAN = 6 + /**< Source value is \c NaN (not a number, including \c QNaN and \c SNaN) */ } H5T_conv_except_t; -/* The return value from conversion callback function H5T_conv_except_func_t */ +/** + * The return value from conversion callback function H5T_conv_except_func_t() + */ typedef enum H5T_conv_ret_t { - H5T_CONV_ABORT = -1, /*abort conversion */ - H5T_CONV_UNHANDLED = 0, /*callback function failed to handle the exception */ - H5T_CONV_HANDLED = 1 /*callback function handled the exception successfully */ + H5T_CONV_ABORT = -1, /**< abort conversion */ + H5T_CONV_UNHANDLED = 0, /**< callback function failed to handle the exception */ + H5T_CONV_HANDLED = 1 /**< callback function handled the exception successfully */ } H5T_conv_ret_t; -/* Variable Length Datatype struct in memory */ -/* (This is only used for VL sequences, not VL strings, which are stored in char *'s) */ +/** + * Variable Length Datatype struct in memory (This is only used for VL + * sequences, not VL strings, which are stored in char *'s) + */ typedef struct { - size_t len; /* Length of VL data (in base type units) */ - void *p; /* Pointer to VL data */ + size_t len; /**< Length of VL data (in base type units) */ + void * p; /**< Pointer to VL data */ } hvl_t; /* Variable Length String information */ -#define H5T_VARIABLE ((size_t)(-1)) /* Indicate that a string is variable length (null-terminated in C, instead of fixed length) */ +/** + * Indicate that a string is variable length (null-terminated in C, instead of + * fixed length) + */ +#define H5T_VARIABLE ((size_t)(-1)) /* Opaque information */ -#define H5T_OPAQUE_TAG_MAX 256 /* Maximum length of an opaque tag */ - /* This could be raised without too much difficulty */ +/** + * Maximum length of an opaque tag + * \internal This could be raised without too much difficulty + */ +#define H5T_OPAQUE_TAG_MAX 256 #ifdef __cplusplus extern "C" { #endif -/* All datatype conversion functions are... */ -typedef herr_t (*H5T_conv_t) (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, hid_t dset_xfer_plist); +/** + * All datatype conversion functions are... + */ +//! +typedef herr_t (*H5T_conv_t)(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, hid_t dset_xfer_plist); +//! -/* Exception handler. If an exception like overflow happenes during conversion, - * this function is called if it's registered through H5Pset_type_conv_cb. +//! +/** + * \brief Exception handler. + * + * \param[in] except_type The kind of exception that occurred + * \param[in] src_id Source datatype identifier + * \param[in] dst_id Destination datatype identifier + * \param[in] src_buf Source data buffer + * \param[in,out] dst_buf Destination data buffer + * \param[in,out] user_data Callback context + * \returns Valid callback function return values are #H5T_CONV_ABORT, + * #H5T_CONV_UNHANDLED and #H5T_CONV_HANDLED. + * + * \details If an exception like overflow happenes during conversion, this + * function is called if it's registered through H5Pset_type_conv_cb(). + * */ -typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, - hid_t src_id, hid_t dst_id, void *src_buf, void *dst_buf, void *user_data); +typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, hid_t src_id, hid_t dst_id, + void *src_buf, void *dst_buf, void *user_data); +//! /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN -#ifndef _H5private_H -#define H5OPEN H5open(), -#else /* _H5private_H */ +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ #define H5OPEN -#endif /* _H5private_H */ +#endif /* H5private_H */ /* * The IEEE floating point types in various byte orders. */ -#define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) -#define H5T_IEEE_F32LE (H5OPEN H5T_IEEE_F32LE_g) -#define H5T_IEEE_F64BE (H5OPEN H5T_IEEE_F64BE_g) -#define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) +/** + * \ingroup PDTIEEE + * 32-bit big-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) +/** + * \ingroup PDTIEEE + * 32-bit little-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F32LE (H5OPEN H5T_IEEE_F32LE_g) +/** + * \ingroup PDTIEEE + * 64-bit big-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F64BE (H5OPEN H5T_IEEE_F64BE_g) +/** + * \ingroup PDTIEEE + * 64-bit little-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) H5_DLLVAR hid_t H5T_IEEE_F32BE_g; H5_DLLVAR hid_t H5T_IEEE_F32LE_g; H5_DLLVAR hid_t H5T_IEEE_F64BE_g; @@ -238,32 +327,141 @@ H5_DLLVAR hid_t H5T_IEEE_F64LE_g; * These are "standard" types. For instance, signed (2's complement) and * unsigned integers of various sizes and byte orders. */ -#define H5T_STD_I8BE (H5OPEN H5T_STD_I8BE_g) -#define H5T_STD_I8LE (H5OPEN H5T_STD_I8LE_g) -#define H5T_STD_I16BE (H5OPEN H5T_STD_I16BE_g) -#define H5T_STD_I16LE (H5OPEN H5T_STD_I16LE_g) -#define H5T_STD_I32BE (H5OPEN H5T_STD_I32BE_g) -#define H5T_STD_I32LE (H5OPEN H5T_STD_I32LE_g) -#define H5T_STD_I64BE (H5OPEN H5T_STD_I64BE_g) -#define H5T_STD_I64LE (H5OPEN H5T_STD_I64LE_g) -#define H5T_STD_U8BE (H5OPEN H5T_STD_U8BE_g) -#define H5T_STD_U8LE (H5OPEN H5T_STD_U8LE_g) -#define H5T_STD_U16BE (H5OPEN H5T_STD_U16BE_g) -#define H5T_STD_U16LE (H5OPEN H5T_STD_U16LE_g) -#define H5T_STD_U32BE (H5OPEN H5T_STD_U32BE_g) -#define H5T_STD_U32LE (H5OPEN H5T_STD_U32LE_g) -#define H5T_STD_U64BE (H5OPEN H5T_STD_U64BE_g) -#define H5T_STD_U64LE (H5OPEN H5T_STD_U64LE_g) -#define H5T_STD_B8BE (H5OPEN H5T_STD_B8BE_g) -#define H5T_STD_B8LE (H5OPEN H5T_STD_B8LE_g) -#define H5T_STD_B16BE (H5OPEN H5T_STD_B16BE_g) -#define H5T_STD_B16LE (H5OPEN H5T_STD_B16LE_g) -#define H5T_STD_B32BE (H5OPEN H5T_STD_B32BE_g) -#define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g) -#define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g) -#define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g) -#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g) -#define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g) +/** + * \ingroup PDTSTD + * 8-bit big-endian signed integers + */ +#define H5T_STD_I8BE (H5OPEN H5T_STD_I8BE_g) +/** + * \ingroup PDTSTD + * 8-bit little-endian signed integers + */ +#define H5T_STD_I8LE (H5OPEN H5T_STD_I8LE_g) +/** + * \ingroup PDTSTD + * 16-bit big-endian signed integers + */ +#define H5T_STD_I16BE (H5OPEN H5T_STD_I16BE_g) +/** + * \ingroup PDTSTD + * 16-bit little-endian signed integers + */ +#define H5T_STD_I16LE (H5OPEN H5T_STD_I16LE_g) +/** + * \ingroup PDTSTD + * 32-bit big-endian signed integers + */ +#define H5T_STD_I32BE (H5OPEN H5T_STD_I32BE_g) +/** + * \ingroup PDTSTD + * 32-bit little-endian signed integers + */ +#define H5T_STD_I32LE (H5OPEN H5T_STD_I32LE_g) +/** + * \ingroup PDTSTD + * 64-bit big-endian signed integers + */ +#define H5T_STD_I64BE (H5OPEN H5T_STD_I64BE_g) +/** + * \ingroup PDTSTD + * 64-bit little-endian signed integers + */ +#define H5T_STD_I64LE (H5OPEN H5T_STD_I64LE_g) +/** + * \ingroup PDTSTD + * 8-bit big-endian unsigned integers + */ +#define H5T_STD_U8BE (H5OPEN H5T_STD_U8BE_g) +/** + * \ingroup PDTSTD + * 8-bit little-endian unsigned integers + */ +#define H5T_STD_U8LE (H5OPEN H5T_STD_U8LE_g) +/** + * \ingroup PDTSTD + * 16-bit big-endian unsigned integers + */ +#define H5T_STD_U16BE (H5OPEN H5T_STD_U16BE_g) +/** + * \ingroup PDTSTD + * 16-bit little-endian unsigned integers + */ +#define H5T_STD_U16LE (H5OPEN H5T_STD_U16LE_g) +/** + * \ingroup PDTSTD + * 32-bit big-endian unsigned integers + */ +#define H5T_STD_U32BE (H5OPEN H5T_STD_U32BE_g) +/** + * \ingroup PDTSTD + * 32-bit little-endian unsigned integers + */ +#define H5T_STD_U32LE (H5OPEN H5T_STD_U32LE_g) +/** + * \ingroup PDTSTD + * 64-bit big-endian unsigned integers + */ +#define H5T_STD_U64BE (H5OPEN H5T_STD_U64BE_g) +/** + * \ingroup PDTSTD + * 64-bit little-endian unsigned integers + */ +#define H5T_STD_U64LE (H5OPEN H5T_STD_U64LE_g) +/** + * \ingroup PDTSTD + * 8-bit big-endian bitfield + */ +#define H5T_STD_B8BE (H5OPEN H5T_STD_B8BE_g) +/** + * \ingroup PDTSTD + * 8-bit little-endian bitfield + */ +#define H5T_STD_B8LE (H5OPEN H5T_STD_B8LE_g) +/** + * \ingroup PDTSTD + * 16-bit big-endian bitfield + */ +#define H5T_STD_B16BE (H5OPEN H5T_STD_B16BE_g) +/** + * \ingroup PDTSTD + * 16-bit little-endian bitfield + */ +#define H5T_STD_B16LE (H5OPEN H5T_STD_B16LE_g) +/** + * \ingroup PDTSTD + * 32-bit big-endian bitfield + */ +#define H5T_STD_B32BE (H5OPEN H5T_STD_B32BE_g) +/** + * \ingroup PDTSTD + * 32-bit little-endian bitfield + */ +#define H5T_STD_B32LE (H5OPEN H5T_STD_B32LE_g) +/** + * \ingroup PDTSTD + * 64-bit big-endian bitfield + */ +#define H5T_STD_B64BE (H5OPEN H5T_STD_B64BE_g) +/** + * \ingroup PDTSTD + * 64-bit little-endian bitfield + */ +#define H5T_STD_B64LE (H5OPEN H5T_STD_B64LE_g) +/** + * \ingroup PDTSTD + * Object reference + */ +#define H5T_STD_REF_OBJ (H5OPEN H5T_STD_REF_OBJ_g) +/** + * \ingroup PDTSTD + * Dataset region reference + */ +#define H5T_STD_REF_DSETREG (H5OPEN H5T_STD_REF_DSETREG_g) +/** + * \ingroup PDTSTD + * Generic reference + */ +#define H5T_STD_REF (H5OPEN H5T_STD_REF_g) H5_DLLVAR hid_t H5T_STD_I8BE_g; H5_DLLVAR hid_t H5T_STD_I8LE_g; H5_DLLVAR hid_t H5T_STD_I16BE_g; @@ -290,14 +488,27 @@ H5_DLLVAR hid_t H5T_STD_B64BE_g; H5_DLLVAR hid_t H5T_STD_B64LE_g; H5_DLLVAR hid_t H5T_STD_REF_OBJ_g; H5_DLLVAR hid_t H5T_STD_REF_DSETREG_g; +H5_DLLVAR hid_t H5T_STD_REF_g; /* * Types which are particular to Unix. */ -#define H5T_UNIX_D32BE (H5OPEN H5T_UNIX_D32BE_g) -#define H5T_UNIX_D32LE (H5OPEN H5T_UNIX_D32LE_g) -#define H5T_UNIX_D64BE (H5OPEN H5T_UNIX_D64BE_g) -#define H5T_UNIX_D64LE (H5OPEN H5T_UNIX_D64LE_g) +/** + * \ingroup PDTUNIX + */ +#define H5T_UNIX_D32BE (H5OPEN H5T_UNIX_D32BE_g) +/** + * \ingroup PDTUNIX + */ +#define H5T_UNIX_D32LE (H5OPEN H5T_UNIX_D32LE_g) +/** + * \ingroup PDTUNIX + */ +#define H5T_UNIX_D64BE (H5OPEN H5T_UNIX_D64BE_g) +/** + * \ingroup PDTUNIX + */ +#define H5T_UNIX_D64LE (H5OPEN H5T_UNIX_D64LE_g) H5_DLLVAR hid_t H5T_UNIX_D32BE_g; H5_DLLVAR hid_t H5T_UNIX_D32LE_g; H5_DLLVAR hid_t H5T_UNIX_D64BE_g; @@ -307,77 +518,261 @@ H5_DLLVAR hid_t H5T_UNIX_D64LE_g; * Types particular to the C language. String types use `bytes' instead * of `bits' as their size. */ -#define H5T_C_S1 (H5OPEN H5T_C_S1_g) +/** + * \ingroup PDTS + * String datatype in C (size defined in bytes rather than in bits) + */ +#define H5T_C_S1 (H5OPEN H5T_C_S1_g) H5_DLLVAR hid_t H5T_C_S1_g; /* * Types particular to Fortran. */ -#define H5T_FORTRAN_S1 (H5OPEN H5T_FORTRAN_S1_g) +/** + * \ingroup PDTS + * String datatype in Fortran (as defined for the HDF5 C library) + */ +#define H5T_FORTRAN_S1 (H5OPEN H5T_FORTRAN_S1_g) H5_DLLVAR hid_t H5T_FORTRAN_S1_g; /* * These types are for Intel CPU's. They are little endian with IEEE * floating point. */ -#define H5T_INTEL_I8 H5T_STD_I8LE -#define H5T_INTEL_I16 H5T_STD_I16LE -#define H5T_INTEL_I32 H5T_STD_I32LE -#define H5T_INTEL_I64 H5T_STD_I64LE -#define H5T_INTEL_U8 H5T_STD_U8LE -#define H5T_INTEL_U16 H5T_STD_U16LE -#define H5T_INTEL_U32 H5T_STD_U32LE -#define H5T_INTEL_U64 H5T_STD_U64LE -#define H5T_INTEL_B8 H5T_STD_B8LE -#define H5T_INTEL_B16 H5T_STD_B16LE -#define H5T_INTEL_B32 H5T_STD_B32LE -#define H5T_INTEL_B64 H5T_STD_B64LE -#define H5T_INTEL_F32 H5T_IEEE_F32LE -#define H5T_INTEL_F64 H5T_IEEE_F64LE +/** + * \ingroup PDTX86 + * 8-bit little-endian signed (2's complement) integers for Intel CPUs + */ +#define H5T_INTEL_I8 H5T_STD_I8LE +/** + * \ingroup PDTX86 + * 16-bit little-endian signed (2's complement) integers for Intel CPUs + */ +#define H5T_INTEL_I16 H5T_STD_I16LE +/** + * \ingroup PDTX86 + * 32-bit little-endian signed (2's complement) integers for Intel CPUs + */ +#define H5T_INTEL_I32 H5T_STD_I32LE +/** + * \ingroup PDTX86 + * 64-bit little-endian signed (2's complement) integers for Intel CPUs + */ +#define H5T_INTEL_I64 H5T_STD_I64LE +/** + * \ingroup PDTX86 + * 8-bit little-endian unsigned integers for Intel CPUs + */ +#define H5T_INTEL_U8 H5T_STD_U8LE +/** + * \ingroup PDTX86 + * 16-bit little-endian unsigned integers for Intel CPUs + */ +#define H5T_INTEL_U16 H5T_STD_U16LE +/** + * \ingroup PDTX86 + * 32-bit little-endian unsigned integers for Intel CPUs + */ +#define H5T_INTEL_U32 H5T_STD_U32LE +/** + * \ingroup PDTX86 + * 64-bit little-endian unsigned integers for Intel CPUs + */ +#define H5T_INTEL_U64 H5T_STD_U64LE +/** + * \ingroup PDTX86 + * 8-bit little-endian bitfield for Intel CPUs + */ +#define H5T_INTEL_B8 H5T_STD_B8LE +/** + * \ingroup PDTX86 + * 16-bit little-endian bitfield for Intel CPUs + */ +#define H5T_INTEL_B16 H5T_STD_B16LE +/** + * \ingroup PDTX86 + * 32-bit little-endian bitfield for Intel CPUs + */ +#define H5T_INTEL_B32 H5T_STD_B32LE +/** + * \ingroup PDTX86 + * 64-bit little-endian bitfield for Intel CPUs + */ +#define H5T_INTEL_B64 H5T_STD_B64LE +/** + * \ingroup PDTX86 + * 32-bit little-endian IEEE floating-point numbers for Intel CPUs + */ +#define H5T_INTEL_F32 H5T_IEEE_F32LE +/** + * \ingroup PDTX86 + * 64-bit little-endian IEEE floating-point numbers for Intel CPUs + */ +#define H5T_INTEL_F64 H5T_IEEE_F64LE /* * These types are for DEC Alpha CPU's. They are little endian with IEEE * floating point. */ -#define H5T_ALPHA_I8 H5T_STD_I8LE -#define H5T_ALPHA_I16 H5T_STD_I16LE -#define H5T_ALPHA_I32 H5T_STD_I32LE -#define H5T_ALPHA_I64 H5T_STD_I64LE -#define H5T_ALPHA_U8 H5T_STD_U8LE -#define H5T_ALPHA_U16 H5T_STD_U16LE -#define H5T_ALPHA_U32 H5T_STD_U32LE -#define H5T_ALPHA_U64 H5T_STD_U64LE -#define H5T_ALPHA_B8 H5T_STD_B8LE -#define H5T_ALPHA_B16 H5T_STD_B16LE -#define H5T_ALPHA_B32 H5T_STD_B32LE -#define H5T_ALPHA_B64 H5T_STD_B64LE -#define H5T_ALPHA_F32 H5T_IEEE_F32LE -#define H5T_ALPHA_F64 H5T_IEEE_F64LE +/** + * \ingroup PDTALPHA + * 8-bit little-endian signed (2's complement) integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_I8 H5T_STD_I8LE +/** + * \ingroup PDTALPHA + * 16-bit little-endian signed (2's complement) integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_I16 H5T_STD_I16LE +/** + * \ingroup PDTALPHA + * 32-bit little-endian signed (2's complement) integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_I32 H5T_STD_I32LE +/** + * \ingroup PDTALPHA + * 64-bit little-endian signed (2's complement) integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_I64 H5T_STD_I64LE +/** + * \ingroup PDTALPHA + * 8-bit little-endian unsigned integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_U8 H5T_STD_U8LE +/** + * \ingroup PDTALPHA + * 16-bit little-endian unsigned integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_U16 H5T_STD_U16LE +/** + * \ingroup PDTALPHA + * 32-bit little-endian unsigned integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_U32 H5T_STD_U32LE +/** + * \ingroup PDTALPHA + * 64-bit little-endian unsigned integers for DEC Alpha CPUs + */ +#define H5T_ALPHA_U64 H5T_STD_U64LE +/** + * \ingroup PDTALPHA + * 8-bit little-endian bitfield for DEC Alpha CPUs + */ +#define H5T_ALPHA_B8 H5T_STD_B8LE +/** + * \ingroup PDTALPHA + * 16-bit little-endian bitfield for DEC Alpha CPUs + */ +#define H5T_ALPHA_B16 H5T_STD_B16LE +/** + * \ingroup PDTALPHA + * 32-bit little-endian bitfield for DEC Alpha CPUs + */ +#define H5T_ALPHA_B32 H5T_STD_B32LE +/** + * \ingroup PDTALPHA + * 64-bit little-endian bitfield for DEC Alpha CPUs + */ +#define H5T_ALPHA_B64 H5T_STD_B64LE +/** + * \ingroup PDTALPHA + * 32-bit little-endian IEEE floating-point numbers for DEC Alpha CPUs + */ +#define H5T_ALPHA_F32 H5T_IEEE_F32LE +/** + * \ingroup PDTALPHA + * 64-bit little-endian IEEE floating-point numbers for DEC Alpha CPUs + */ +#define H5T_ALPHA_F64 H5T_IEEE_F64LE /* * These types are for MIPS cpu's commonly used in SGI systems. They are big * endian with IEEE floating point. */ -#define H5T_MIPS_I8 H5T_STD_I8BE -#define H5T_MIPS_I16 H5T_STD_I16BE -#define H5T_MIPS_I32 H5T_STD_I32BE -#define H5T_MIPS_I64 H5T_STD_I64BE -#define H5T_MIPS_U8 H5T_STD_U8BE -#define H5T_MIPS_U16 H5T_STD_U16BE -#define H5T_MIPS_U32 H5T_STD_U32BE -#define H5T_MIPS_U64 H5T_STD_U64BE -#define H5T_MIPS_B8 H5T_STD_B8BE -#define H5T_MIPS_B16 H5T_STD_B16BE -#define H5T_MIPS_B32 H5T_STD_B32BE -#define H5T_MIPS_B64 H5T_STD_B64BE -#define H5T_MIPS_F32 H5T_IEEE_F32BE -#define H5T_MIPS_F64 H5T_IEEE_F64BE +/** + * \ingroup PDTMIPS + * 8-bit big-endian signed (2's complement) integers for SGI MIPS CPUs + */ +#define H5T_MIPS_I8 H5T_STD_I8BE +/** + * \ingroup PDTMIPS + * 16-bit big-endian signed (2's complement) integers for SGI MIPS CPUs + */ +#define H5T_MIPS_I16 H5T_STD_I16BE +/** + * \ingroup PDTMIPS + * 32-bit big-endian signed (2's complement) integers for SGI MIPS CPUs + */ +#define H5T_MIPS_I32 H5T_STD_I32BE +/** + * \ingroup PDTMIPS + * 64-bit big-endian signed (2's complement) integers for SGI MIPS CPUs + */ +#define H5T_MIPS_I64 H5T_STD_I64BE +/** + * \ingroup PDTMIPS + * 8-bit big-endian unsigned integers for SGI MIPS CPUs + */ +#define H5T_MIPS_U8 H5T_STD_U8BE +/** + * \ingroup PDTMIPS + * 16-bit big-endian unsigned integers for SGI MIPS CPUs + */ +#define H5T_MIPS_U16 H5T_STD_U16BE +/** + * \ingroup PDTMIPS + * 32-bit big-endian unsigned integers for SGI MIPS CPUs + */ +#define H5T_MIPS_U32 H5T_STD_U32BE +/** + * \ingroup PDTMIPS + * 64-bit big-endian unsigned integers for SGI MIPS CPUs + */ +#define H5T_MIPS_U64 H5T_STD_U64BE +/** + * \ingroup PDTMIPS + * 8-bit big-endian bitfield for SGI MIPS CPUs + */ +#define H5T_MIPS_B8 H5T_STD_B8BE +/** + * \ingroup PDTMIPS + * 16-bit big-endian bitfield for SGI MIPS CPUs + */ +#define H5T_MIPS_B16 H5T_STD_B16BE +/** + * \ingroup PDTMIPS + * 32-bit big-endian bitfield for SGI MIPS CPUs + */ +#define H5T_MIPS_B32 H5T_STD_B32BE +/** + * \ingroup PDTMIPS + * 64-bit big-endian bitfield for SGI MIPS CPUs + */ +#define H5T_MIPS_B64 H5T_STD_B64BE +/** + * \ingroup PDTMIPS + * 32-bit big-endian IEEE floating-point numbers for MIPS CPUs + */ +#define H5T_MIPS_F32 H5T_IEEE_F32BE +/** + * \ingroup PDTMIPS + * 64-bit big-endian IEEE floating-point numbers for MIPS CPUs + */ +#define H5T_MIPS_F64 H5T_IEEE_F64BE /* * The VAX floating point types (i.e. in VAX byte order) */ -#define H5T_VAX_F32 (H5OPEN H5T_VAX_F32_g) -#define H5T_VAX_F64 (H5OPEN H5T_VAX_F64_g) +/** + * \ingroup PDTALPHA + * 32-bit VAX byte order floating-point numbers for OpenVMS on DEC Alpha CPUs + */ +#define H5T_VAX_F32 (H5OPEN H5T_VAX_F32_g) +/** + * \ingroup PDTALPHA + * 64-bit VAX byte order floating-point numbers for OpenVMS on DEC Alpha CPUs + */ +#define H5T_VAX_F64 (H5OPEN H5T_VAX_F64_g) H5_DLLVAR hid_t H5T_VAX_F32_g; H5_DLLVAR hid_t H5T_VAX_F64_g; @@ -390,32 +785,128 @@ H5_DLLVAR hid_t H5T_VAX_F64_g; * to C's `long long' and LDOUBLE is `long double' (these types might be the * same as `LONG' and `DOUBLE' respectively). */ -#define H5T_NATIVE_CHAR (CHAR_MIN?H5T_NATIVE_SCHAR:H5T_NATIVE_UCHAR) -#define H5T_NATIVE_SCHAR (H5OPEN H5T_NATIVE_SCHAR_g) -#define H5T_NATIVE_UCHAR (H5OPEN H5T_NATIVE_UCHAR_g) -#define H5T_NATIVE_SHORT (H5OPEN H5T_NATIVE_SHORT_g) -#define H5T_NATIVE_USHORT (H5OPEN H5T_NATIVE_USHORT_g) -#define H5T_NATIVE_INT (H5OPEN H5T_NATIVE_INT_g) -#define H5T_NATIVE_UINT (H5OPEN H5T_NATIVE_UINT_g) -#define H5T_NATIVE_LONG (H5OPEN H5T_NATIVE_LONG_g) -#define H5T_NATIVE_ULONG (H5OPEN H5T_NATIVE_ULONG_g) -#define H5T_NATIVE_LLONG (H5OPEN H5T_NATIVE_LLONG_g) -#define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) -#define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) -#define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) -#if H5_SIZEOF_LONG_DOUBLE !=0 -#define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) +/** + * \ingroup PDTNAT + * C-style \c char + */ +#define H5T_NATIVE_CHAR (CHAR_MIN ? H5T_NATIVE_SCHAR : H5T_NATIVE_UCHAR) +/** + * \ingroup PDTNAT + * C-style \Code{signed char} + */ +#define H5T_NATIVE_SCHAR (H5OPEN H5T_NATIVE_SCHAR_g) +/** + * \ingroup PDTNAT + * C-style \Code{unsigned char} + */ +#define H5T_NATIVE_UCHAR (H5OPEN H5T_NATIVE_UCHAR_g) +/** + * \ingroup PDTNAT + * C-style \Code{short} + */ +#define H5T_NATIVE_SHORT (H5OPEN H5T_NATIVE_SHORT_g) +/** + * \ingroup PDTNAT + * C-style \Code{unsigned short} + */ +#define H5T_NATIVE_USHORT (H5OPEN H5T_NATIVE_USHORT_g) +/** + * \ingroup PDTNAT + * C-style \Code{int} + */ +#define H5T_NATIVE_INT (H5OPEN H5T_NATIVE_INT_g) +/** + * \ingroup PDTNAT + * C-style \Code{unsigned int} + */ +#define H5T_NATIVE_UINT (H5OPEN H5T_NATIVE_UINT_g) +/** + * \ingroup PDTNAT + * C-style \Code{long} + */ +#define H5T_NATIVE_LONG (H5OPEN H5T_NATIVE_LONG_g) +/** + * \ingroup PDTNAT + * C-style \Code{unsigned long} + */ +#define H5T_NATIVE_ULONG (H5OPEN H5T_NATIVE_ULONG_g) +/** + * \ingroup PDTNAT + * C-style \Code{long long} + */ +#define H5T_NATIVE_LLONG (H5OPEN H5T_NATIVE_LLONG_g) +/** + * \ingroup PDTNAT + * C-style \Code{unsigned long long} + */ +#define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) +/** + * \ingroup PDTNAT + * C-style \Code{float} + */ +#define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) +/** + * \ingroup PDTNAT + * C-style \Code{double} + */ +#define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) +#if H5_SIZEOF_LONG_DOUBLE != 0 +/** + * \ingroup PDTNAT + * C-style \Code{long double} + */ +#define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) #endif -#define H5T_NATIVE_B8 (H5OPEN H5T_NATIVE_B8_g) -#define H5T_NATIVE_B16 (H5OPEN H5T_NATIVE_B16_g) -#define H5T_NATIVE_B32 (H5OPEN H5T_NATIVE_B32_g) -#define H5T_NATIVE_B64 (H5OPEN H5T_NATIVE_B64_g) -#define H5T_NATIVE_OPAQUE (H5OPEN H5T_NATIVE_OPAQUE_g) -#define H5T_NATIVE_HADDR (H5OPEN H5T_NATIVE_HADDR_g) -#define H5T_NATIVE_HSIZE (H5OPEN H5T_NATIVE_HSIZE_g) -#define H5T_NATIVE_HSSIZE (H5OPEN H5T_NATIVE_HSSIZE_g) -#define H5T_NATIVE_HERR (H5OPEN H5T_NATIVE_HERR_g) -#define H5T_NATIVE_HBOOL (H5OPEN H5T_NATIVE_HBOOL_g) +/** + * \ingroup PDTNAT + * HDF5 8-bit bitfield based on native types + */ +#define H5T_NATIVE_B8 (H5OPEN H5T_NATIVE_B8_g) +/** + * \ingroup PDTNAT + * HDF5 16-bit bitfield based on native types + */ +#define H5T_NATIVE_B16 (H5OPEN H5T_NATIVE_B16_g) +/** + * \ingroup PDTNAT + * HDF5 32-bit bitfield based on native types + */ +#define H5T_NATIVE_B32 (H5OPEN H5T_NATIVE_B32_g) +/** + * \ingroup PDTNAT + * HDF5 64-bit bitfield based on native types + */ +#define H5T_NATIVE_B64 (H5OPEN H5T_NATIVE_B64_g) +/** + * \ingroup PDTNAT + * HDF5 opaque unit based on native types + */ +#define H5T_NATIVE_OPAQUE (H5OPEN H5T_NATIVE_OPAQUE_g) +/** + * \ingroup PDTNAT + * HDF5 address type based on native types + */ +#define H5T_NATIVE_HADDR (H5OPEN H5T_NATIVE_HADDR_g) +/** + * \ingroup PDTNAT + * HDF5 size type based on native types + */ +#define H5T_NATIVE_HSIZE (H5OPEN H5T_NATIVE_HSIZE_g) +/** + * \ingroup PDTNAT + * HDF5 signed size type based on native types + */ +#define H5T_NATIVE_HSSIZE (H5OPEN H5T_NATIVE_HSSIZE_g) +/** + * \ingroup PDTNAT + * HDF5 error code type based on native types + */ +#define H5T_NATIVE_HERR (H5OPEN H5T_NATIVE_HERR_g) +/** + * \ingroup PDTNAT + * HDF5 Boolean type based on native types + */ +#define H5T_NATIVE_HBOOL (H5OPEN H5T_NATIVE_HBOOL_g) H5_DLLVAR hid_t H5T_NATIVE_SCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_UCHAR_g; H5_DLLVAR hid_t H5T_NATIVE_SHORT_g; @@ -428,7 +919,7 @@ H5_DLLVAR hid_t H5T_NATIVE_LLONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULLONG_g; H5_DLLVAR hid_t H5T_NATIVE_FLOAT_g; H5_DLLVAR hid_t H5T_NATIVE_DOUBLE_g; -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR hid_t H5T_NATIVE_LDOUBLE_g; #endif H5_DLLVAR hid_t H5T_NATIVE_B8_g; @@ -443,12 +934,30 @@ H5_DLLVAR hid_t H5T_NATIVE_HERR_g; H5_DLLVAR hid_t H5T_NATIVE_HBOOL_g; /* C9x integer types */ -#define H5T_NATIVE_INT8 (H5OPEN H5T_NATIVE_INT8_g) -#define H5T_NATIVE_UINT8 (H5OPEN H5T_NATIVE_UINT8_g) -#define H5T_NATIVE_INT_LEAST8 (H5OPEN H5T_NATIVE_INT_LEAST8_g) -#define H5T_NATIVE_UINT_LEAST8 (H5OPEN H5T_NATIVE_UINT_LEAST8_g) -#define H5T_NATIVE_INT_FAST8 (H5OPEN H5T_NATIVE_INT_FAST8_g) -#define H5T_NATIVE_UINT_FAST8 (H5OPEN H5T_NATIVE_UINT_FAST8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT8 (H5OPEN H5T_NATIVE_INT8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT8 (H5OPEN H5T_NATIVE_UINT8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_LEAST8 (H5OPEN H5T_NATIVE_INT_LEAST8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_LEAST8 (H5OPEN H5T_NATIVE_UINT_LEAST8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_FAST8 (H5OPEN H5T_NATIVE_INT_FAST8_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_FAST8 (H5OPEN H5T_NATIVE_UINT_FAST8_g) H5_DLLVAR hid_t H5T_NATIVE_INT8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST8_g; @@ -456,12 +965,30 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST8_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST8_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST8_g; -#define H5T_NATIVE_INT16 (H5OPEN H5T_NATIVE_INT16_g) -#define H5T_NATIVE_UINT16 (H5OPEN H5T_NATIVE_UINT16_g) -#define H5T_NATIVE_INT_LEAST16 (H5OPEN H5T_NATIVE_INT_LEAST16_g) -#define H5T_NATIVE_UINT_LEAST16 (H5OPEN H5T_NATIVE_UINT_LEAST16_g) -#define H5T_NATIVE_INT_FAST16 (H5OPEN H5T_NATIVE_INT_FAST16_g) -#define H5T_NATIVE_UINT_FAST16 (H5OPEN H5T_NATIVE_UINT_FAST16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT16 (H5OPEN H5T_NATIVE_INT16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT16 (H5OPEN H5T_NATIVE_UINT16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_LEAST16 (H5OPEN H5T_NATIVE_INT_LEAST16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_LEAST16 (H5OPEN H5T_NATIVE_UINT_LEAST16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_FAST16 (H5OPEN H5T_NATIVE_INT_FAST16_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_FAST16 (H5OPEN H5T_NATIVE_UINT_FAST16_g) H5_DLLVAR hid_t H5T_NATIVE_INT16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST16_g; @@ -469,12 +996,30 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST16_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST16_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST16_g; -#define H5T_NATIVE_INT32 (H5OPEN H5T_NATIVE_INT32_g) -#define H5T_NATIVE_UINT32 (H5OPEN H5T_NATIVE_UINT32_g) -#define H5T_NATIVE_INT_LEAST32 (H5OPEN H5T_NATIVE_INT_LEAST32_g) -#define H5T_NATIVE_UINT_LEAST32 (H5OPEN H5T_NATIVE_UINT_LEAST32_g) -#define H5T_NATIVE_INT_FAST32 (H5OPEN H5T_NATIVE_INT_FAST32_g) -#define H5T_NATIVE_UINT_FAST32 (H5OPEN H5T_NATIVE_UINT_FAST32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT32 (H5OPEN H5T_NATIVE_INT32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT32 (H5OPEN H5T_NATIVE_UINT32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_LEAST32 (H5OPEN H5T_NATIVE_INT_LEAST32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_LEAST32 (H5OPEN H5T_NATIVE_UINT_LEAST32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_FAST32 (H5OPEN H5T_NATIVE_INT_FAST32_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_FAST32 (H5OPEN H5T_NATIVE_UINT_FAST32_g) H5_DLLVAR hid_t H5T_NATIVE_INT32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST32_g; @@ -482,12 +1027,30 @@ H5_DLLVAR hid_t H5T_NATIVE_UINT_LEAST32_g; H5_DLLVAR hid_t H5T_NATIVE_INT_FAST32_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST32_g; -#define H5T_NATIVE_INT64 (H5OPEN H5T_NATIVE_INT64_g) -#define H5T_NATIVE_UINT64 (H5OPEN H5T_NATIVE_UINT64_g) -#define H5T_NATIVE_INT_LEAST64 (H5OPEN H5T_NATIVE_INT_LEAST64_g) -#define H5T_NATIVE_UINT_LEAST64 (H5OPEN H5T_NATIVE_UINT_LEAST64_g) -#define H5T_NATIVE_INT_FAST64 (H5OPEN H5T_NATIVE_INT_FAST64_g) -#define H5T_NATIVE_UINT_FAST64 (H5OPEN H5T_NATIVE_UINT_FAST64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT64 (H5OPEN H5T_NATIVE_INT64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT64 (H5OPEN H5T_NATIVE_UINT64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_LEAST64 (H5OPEN H5T_NATIVE_INT_LEAST64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_LEAST64 (H5OPEN H5T_NATIVE_UINT_LEAST64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_INT_FAST64 (H5OPEN H5T_NATIVE_INT_FAST64_g) +/** + * \ingroup PDTC9x + */ +#define H5T_NATIVE_UINT_FAST64 (H5OPEN H5T_NATIVE_UINT_FAST64_g) H5_DLLVAR hid_t H5T_NATIVE_INT64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT64_g; H5_DLLVAR hid_t H5T_NATIVE_INT_LEAST64_g; @@ -496,120 +1059,1967 @@ H5_DLLVAR hid_t H5T_NATIVE_INT_FAST64_g; H5_DLLVAR hid_t H5T_NATIVE_UINT_FAST64_g; /* Operations defined on all datatypes */ +/** + * \ingroup H5T + * + * \brief Creates a new datatype. + * + * \param[in] type Class of datatype to create + * \param[in] size Size, in bytes, of the datatype being created + * + * \return \hid_t{datatype} + * + * \details H5Tcreate() creates a new datatype of the specified class with the + * specified number of bytes. This function is used only with the + * following datatype classes: + * - #H5T_COMPOUND + * - #H5T_OPAQUE + * - #H5T_ENUM + * - #H5T_STRING + * + * Other datatypes, including integer and floating-point datatypes, + * are typically created by using H5Tcopy() to copy and modify a + * predefined datatype. + * + * When creating a variable-length string datatype, \p size must + * be #H5T_VARIABLE; see \ref_vlen_strings. + * + * When creating a fixed-length string datatype, \p size will + * be the length of the string in bytes. The length of the + * string in characters will depend on i the encoding used; see + * H5Pset_char_encoding(). + * + * ENUMs created with this function have a signed native integer + * base datatype. Use H5Tenum_create() if a different integer base + * datatype is required. + * + * The datatype identifier returned from this function should be + * released with H5Tclose or resource leaks will result. + * + * \see H5Tclose() + * + * \since 1.2.0 + * + */ H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size); +/** + * \ingroup H5T + * + * \brief Copies an existing datatype. + * + * \type_id + * + * \return \hid_t{datatype} + * + * \details H5Tcopy() makes a copy of an existing datatype. The returned type + * is always transient and unlocked. + * + * The \p type_id argument can be either a datatype identifier, + * a predefined datatype (defined in H5Tpublic.h), or a dataset + * identifier. If \p type_id is a dataset identifier, this function + * returns a transient, modifiable datatype which is a copy of the + * dataset's datatype. + * + * The returned datatype identifier should be released with H5Tclose() + * to prevent resource leak. + * + */ H5_DLL hid_t H5Tcopy(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Releases a datatype + * + * \type_id + * + * \return \herr_t + * + * \details H5Tclose() releases the datatype \p dtype_id. Further access + * through this datatype identifier is illegal. Failure to release + * a datatype with this call will result in resource leaks. + * + */ H5_DLL herr_t H5Tclose(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Determines whether two datatype identifiers refer to the same datatype + * + * \type_id{type1_id} + * \type_id{type2_id} + * + * \return \htri_t + * + * \details H5Tequal() determines whether two datatype identifiers refer to + * the same datatype. + * + * \since 1.6 or earlier + * + */ H5_DLL htri_t H5Tequal(hid_t type1_id, hid_t type2_id); +/** + * \ingroup H5T + * + * \brief Locks a datatype + * + * \type_id + * + * \return \herr_t + * + * \details H5Tlock() locks the datatype specified by the dtype_id identifier, + * making it read-only and non-destructible. This is normally done by + * the library for predefined datatypes so the application does not + * inadvertently change or delete a predefined type. Once a datatype + * is locked it can never be unlocked. + * + */ H5_DLL herr_t H5Tlock(hid_t type_id); -H5_DLL 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); +/** + * \ingroup H5T + * + * \brief Commits a transient datatype, linking it into the file and creating + * a new committed datatype + * + * \fg_loc_id + * \param[in] name Name given to committed datatype + * \type_id Identifier of datatype to be committed and, upon function’s + * return, identifier for the committed datatype + * \lcpl_id + * \tcpl_id + * \tapl_id + * + * \return \herr_t + * + * \details H5Tcommit2() saves a transient datatype as an immutable committed + * datatype in a file. The datatype specified by \p dtype_id is + * committed to the file with the name name at the location specified + * by \p loc_id and with the datatype creation and access property + * lists \p tcpl_id and \p tapl_id, respectively. + * + * \p loc_id may be a file identifier, or a group identifier within + * that file. \p name may be either an absolute path in the file or + * a relative path from \p loc_id naming the newly-commited datatype. + * + * The link creation property list, \p lcpl_id, governs creation of + * the link(s) by which the new committed datatype is accessed and + * the creation of any intermediate groups that may be missing. + * + * Once commited, this datatype may be used to define the datatype + * of any other dataset or attribute in the file. + * + * This function will not accept a datatype that cannot actually hold + * information. This currently includes compound datatypes with no + * fields and enumerated datatypes with no members. + * + * Committed datatypes are sometimes referred to as named datatypes. + * + * \version 1.8.7 Function modified in this release to reject datatypes that + * will not accomodate actual data, such as a compound datatype + * with no fields or an enumerated datatype with no members. + * + * \since 1.8.0 + * + */ +H5_DLL 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); +/** + * -------------------------------------------------------------------------- + * \ingroup H5T + * + * \brief Opens a committed (named) datatype + * + * \fgdta_loc_id + * \param[in] name Name of the datatype to open + * \tapl_id + * + * \return \hid_t{datatype} + * + * \details H5Topen2() opens a committed datatype at the location specified + * by \p loc_id and returns an identifier for the datatype. \p + * loc_id is either a file or group identifier. The identifier should + * eventually be closed by calling H5Tclose() to release resources. + * + * The committed datatype is opened with the datatype access property + * list tapl_id. + * + * \since 1.8.0 + * + */ H5_DLL hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id); +/** + * \ingroup H5T + * + * \brief Commits a transient datatype to a file, creating a new named + * datatype, but does not link it into the file structure + * + * \fg_loc_id + * \type_id + * \tcpl_id + * \tapl_id + * + * \return \herr_t + * + * \details H5Tcommit_anon() commits a transient datatype (not immutable) + * to a file, turning it into a named datatype with the specified + * creation and property lists. With default property lists, + * #H5P_DEFAULT, H5Tcommit_anon() provides similar functionality to + * that of H5Tcommit(), with the differences described below. + * + * #H5P_DEFAULT can be passed in for the datatype creation property + * list identifier, \p tcpl_id. The datatype access property list + * identifier, \p tapl_id, is provided for future functionality and + * is not used at this time. This parameter should always be passed + * as the value #H5P_DEFAULT. + * + * Note that H5Tcommit_anon() does not link this newly-committed + * datatype into the file. After the H5Tcommit_anon() call, the + * datatype identifier \p type_id must be linked into the HDF5 file + * structure with H5Olink() or it will be deleted from the file when + * the file is closed. + * + * The differences between this function and H5Tcommit() are as follows: + * \li H5Tcommit_anon() explicitly includes property lists, + * which provides for greater control of the creation process + * and of the properties of the new named datatype. H5Tcommit() + * always uses default properties. + * \li H5Tcommit_anon() neither provides the new named datatype’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. + * + * This function will not accept a datatype that cannot actually + * hold data. This currently includes compound datatypes with no + * fields and enumerated datatypes with no members. + * + * \version 1.8.7 Function modified in this release to reject datatypes that + * will not accomodate actual data, such as a compound datatype + * with no fields or an enumerated datatype with no members. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id); +/** + * \ingroup H5T + * + * \brief Returns a copy of a datatype's creation property list + * + * \type_id + * + * \return \hid_t{datatype creation property list} + * + * \details H5Tget_create_plist() returns a property list identifier + * for the datatype creation property list associated with the datatype + * specified by \p type_id. + * + * The creation property list identifier should be released with + * H5Pclose() to prevent memory leaks. + * + * \since 1.8.0 + * + */ H5_DLL hid_t H5Tget_create_plist(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Determines whether a datatype is a committed type or a transient type + * + * \type_id + * + * \return \htri_t + * + * \details H5Tcommitted() queries a type to determine whether the type + * specified by the \p dtype_id identifier is a committed (formerly + * known as a \Emph{named}) type or a transient type. If this function returns + * a positive value, then the type is committed (that is, it has been + * committed, perhaps by some other application). Datasets which + * return committed datatypes with H5Dget_type() are able to share + * the datatype with other datasets in the same file. + * + * \version 1.8.0 Fortran API was added + * + * \since 1.6 or earlier + * + */ H5_DLL htri_t H5Tcommitted(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Encodes a datatype object description into a binary buffer + * + * \param[in] obj_id Identifier of the object to be encoded + * \param[in,out] buf Buffer for the object to be encoded into. + * \param[in,out] nalloc IN: The size of the allocated buffer + * OUT: The size of the buffer needed + * + * \return \herr_t + * + * \details H5Tencode() Given datatype identifier, H5Tencode() converts a + * datatype description into binary form in a buffer. Using this + * binary form in the buffer, a datatype object can be reconstructed + * using H5Tdecode() to return a new object handle (\ref hid_t) for + * this datatype. + * + * If the provided buffer is NULL, only the size of buffer needed is + * returned through \p nalloc. + * + * A preliminary H5Tencode() call can be made to find out the size + * of the buffer needed. This value is returned as \p nalloc. That + * value can then be assigned to \p nalloc for a second H5Tencode() + * call, which will retrieve the actual encoded object. + * + * If the library finds that \p nalloc is not big enough for the + * object, it simply returns the size of the buffer needed through + * \p nalloc without encoding the provided buffer. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); -H5_DLL hid_t H5Tdecode(const void *buf); -H5_DLL herr_t H5Tflush(hid_t type_id); -H5_DLL herr_t H5Trefresh(hid_t type_id); - -/* Operations defined on compound datatypes */ -H5_DLL herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, - hid_t member_id); -H5_DLL herr_t H5Tpack(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Decodes a binary object description of datatype and return a new + * object handle + * + * \param[in] buf Buffer for the datatype object to be decoded + * + * \return \hid_t{datatype} + * + * \details H5Tdecode() Given an object description of datatype in binary in a + * buffer, H5Tdecode() reconstructs the HDF5 datatype object and + * returns a new object handle for it. The binary description of + * the object is encoded by H5Tencode(). User is responsible for + * passing in the right buffer. + * + * The datatype identifier returned by this function can be released + * with H5Tclose() when the identifier is no longer needed so that + * resource leaks will not develop. + * + */ +H5_DLL hid_t H5Tdecode(const void *buf); +/** + * \ingroup H5T + * + * \brief Flushes all buffers associated with a committed datatype to disk + * + * \type_id + * + * \return \herr_t + * + * \details H5Tflush() causes all buffers associated with a committed datatype + * \p type_id to be immediately flushed to disk without removing the + * data from the cache. + * + * HDF5 does not possess full control over buffering. H5Tflush() + * 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. + * + * \return \herr_t + * + * \since 1.10.0 C function introduced with this release. + * + * \see H5Dflush() + * H5Drefresh() + * H5Tflush() + * H5Grefresh() + * H5Oflush() + * H5Orefresh() + * H5Tflush() + * H5Trefresh() + * H5Fstart_swmr_write() + * H5Pget_append_flush() + * H5Pget_object_flush_cb() + * H5Pset_append_flush() + * H5Pset_object_flush_cb() + * + */ +H5_DLL herr_t H5Tflush(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Refreshes all buffers associated with a committed datatype + * + * \type_id + * + * \return \herr_t + * + * \details H5Trefresh() causes all buffers associated with a committed + * datatype to be cleared and immediately re-loaded with updated + * contents from disk. + * + * This function essentially closes the datatype, evicts all + * metadata associated with it from the cache, and then re-opens the + * datatype. The reopened datatype is automatically re-registered + * with the same identifier. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Trefresh(hid_t type_id); + +/* Operations defined on compound datatypes */ +/** + * \ingroup COMPOUND + * + * \brief Adds a new member to a compound datatype. + * + * \type_id{parent_id} + * \param[in] name Name of the field to insert + * \param[in] offset Offset in memory structure of the field to insert + * \param[in] member_id Datatype identifier of the field to insert + * + * \return \herr_t + * + * \details H5Tinsert() adds another member to the compound datatype, specified + * \p type_id. + * + * The new member has a \p name which must be unique within the + * compound datatype. The \p offset argument defines the start of the + * member in an instance of the compound datatype, and \p member_id + * is the datatype identifier of the new member. + * + * \note Members of a compound datatype do not have to be atomic + * datatypes; a compound datatype can have a member which is a + * compound datatype. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id); +/** + * \ingroup COMPOUND + * + * \brief Recursively removes padding from within a compound datatype + * + * \type_id + * + * \return \herr_t + * + * \details H5Tpack() recursively removes padding from within a compound + * datatype to make it more efficient (space-wise) to store that data. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tpack(hid_t type_id); /* Operations defined on enumeration datatypes */ +/** + * \ingroup ENUM + * + * \brief Creates a new enumeration datatype + * + * \param[in] base_id Datatype identifier for the base datatype. Must be an + * integer datatype + * + * \return \hid_t{enumeration datatype} + * + * \details H5Tenum_create() creates a new enumeration datatype based on the + * specified base datatype, dtype_id, which must be an integer datatype. + * + * If a particular architecture datatype is required, a little endian + * or big endian datatype for example, use a native datatype as the + * base datatype and use H5Tconvert() on values as they are read + * from or written to a dataset. + * + * \since 1.2.0 + * + */ H5_DLL hid_t H5Tenum_create(hid_t base_id); +/** + * \ingroup ENUM + * + * \brief Inserts a new enumeration datatype member + * + * \type_id{type} + * \param[in] name Name of the new member + * \param[in] value Pointer to the value of the new member + * + * \return \herr_t + * + * \details H5Tenum_insert() inserts a new enumeration datatype member into an + * enumeration datatype. + * + * \p type_id is the datatype identifier for the enumeration datatype, + * \p name is the name of the new member, and \p value points to the + * value of the new member. + * + * \p name and \p value must both be unique within \p dtype_id. + * + * \p value points to data which must be of the integer base datatype + * used when the enumeration datatype was created. If a particular + * architecture datatype is required, a little endian or big endian + * datatype for example, use a native datatype as the base datatype + * and use H5Tconvert() on values as they are read from or written + * to a dataset. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tenum_insert(hid_t type, const char *name, const void *value); -H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, - size_t size); -H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, - void *value/*out*/); +/** + * \ingroup ENUM + * + * \brief Returns the symbol name corresponding to a specified member of an + * enumeration datatype + * + * \type_id{type} + * \param[in] value Value of the enumeration datatype + * \param[out] name Buffer for output of the symbol name + * \param[in] size Anticipated size of the symbol name, in bytes + * + * \return Returns a non-negative value if successful. Otherwise returns a + * negative value + * + * \details H5Tenum_nameof() finds the symbol name that corresponds to the + * specified \p value of the enumeration datatype \p type. + * + * At most \p size characters of the symbol \p name are copied into + * the \p name buffer. If the entire symbol name and null terminator + * do not fit in the name buffer, then as many characters as possible + * are copied (not null terminated) and the function fails. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tenum_nameof(hid_t type, const void *value, char *name /*out*/, size_t size); +/** + * \ingroup ENUM + * + * \brief Returns the value corresponding to a specified member of an + * enumeration datatype + * + * \type_id{type} + * \param[in] name Symbol name of the enumeration datatype + * \param[out] value Buffer for the value of the enumeration datatype + * + * \return \herr_t + * + * \details H5Tenum_valueof() finds the value that corresponds to the + * specified name of the enumeration datatype \p dtype_id. + * + * Values returned in \p value will be of the enumerated type’s + * base type, that is, the datatype used by H5Tenum_create() when + * the enumerated type was created. + * + * The \p value buffer must be at least large enough to hold a value + * of that base type. If the size is unknown, you can determine it + * with H5Tget_size(). + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tenum_valueof(hid_t type, const char *name, void *value /*out*/); /* Operations defined on variable-length datatypes */ +/** + * \ingroup VLEN + * + * \brief Creates a new variable-length array datatype + * + * \type_id{base_id}, the element type of the datatype to create + * + * \return \hid_t{variable-length datatype} + * + * \details H5Tvlen_create() creates a new one-dimensional array datatype of + * variable-length (VL) with the base datatype \p base_id. + * + * This one-dimensional array often represents a data sequence of the + * base datatype, such as characters for character sequences or vertex + * coordinates for polygon lists. The base type specified for the VL + * datatype can be any HDF5 datatype, including another VL datatype, a + * compound datatype, or an atomic datatype. + * + * When necessary, use H5Tget_super() to determine the base type of + * the VL datatype. + * + * The datatype identifier returned from this function should be + * released with H5Tclose() or resource leaks will result. Under + * certain circumstances, H5Dvlen_reclaim() must also be used. + * + * \attention H5Tvlen_create() cannot be used to create a variable-length + * string datatype. H5Tvlen_create() called with a string or + * character base type creates a variable-length sequence of strings + * (a variable-length, 1-dimensional array), with each element of + * the array being of the string or character base type.\n + * To create a variable-length string datatype, see \ref_vlen_strings. + * + */ H5_DLL hid_t H5Tvlen_create(hid_t base_id); /* Operations defined on array datatypes */ -H5_DLL hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, - const hsize_t dim[/* ndims */]); +/** + * \ingroup ARRAY + * + * \brief Creates an array datatype object + * + * \param[in] base_id Datatype identifier for the array base datatype + * \param[in] ndims Rank of the array + * \param[in] dim Size of each array dimension + * + * \return \hid_t{array datatype} + * + * \details H5Tarray_create2() creates a new array datatype object.\n\n + * \p base_id is the datatype of every element of the array, i.e., + * of the number at each position in the array. + * + * \p ndims is the number of dimensions and the size of each dimension + * is specified in the array \p dim. The value of \p rank is + * currently limited to #H5S_MAX_RANK and must be greater than 0 + * (zero). All dimension sizes specified in \p dim must be greater + * than 0 (zero). + * + * \since 1.8.0 + * + */ +H5_DLL hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]); +/** + * \ingroup ARRAY + * + * \brief Returns the rank of an array datatype + * + * \type_id + * + * \return Returns the rank of the array if successful; otherwise returns a + * negative value. + * + * \details H5Tget_array_ndims() returns the rank, i.e., the number of + * dimensions, of an array datatype object. + * + * \since 1.2.0 + * + */ H5_DLL int H5Tget_array_ndims(hid_t type_id); +/** + * \ingroup ARRAY + * + * \brief Retrieves sizes of array dimensions + * + * \type_id + * \param[out] dims Sizes of array dimensions + * + * \return Returns the non-negative number of dimensions of the array type + * if successful; otherwise returns a negative value. + * + * \details H5Tget_array_dims2() returns the sizes of the dimensions of the + * specified array datatype object in the array \p dims. + * + * \since 1.2.0 + * + */ H5_DLL int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]); /* Operations defined on opaque datatypes */ +/** + * \ingroup OPAQUE + * + * \brief Tags an opaque datatype + * + * \type_id{type} of an opaque datatype + * \param[in] tag Descriptive ASCII string with which the opaque datatype is + * to be tagged + * + * \return \herr_t + * + * \details H5Tset_tag() tags an opaque datatype \p type with a descriptive + * ASCII identifier, \p tag. + * + * \p tag is intended to provide a concise description; the maximum + * size is hard-coded in the HDF5 library as 256 bytes + * (#H5T_OPAQUE_TAG_MAX). + * + * \version 1.6.5 The #H5T_OPAQUE_TAG_MAX macro constant, specifying the + * maximum size of an opaque datatype tag, was added in + * H5Tpublic.h. + * + */ H5_DLL herr_t H5Tset_tag(hid_t type, const char *tag); +/** + * \ingroup OPAQUE + * + * \brief Gets the tag associated with an opaque datatype + * + * \type_id{type} of an opaque datatype + * + * \return Returns a pointer to an allocated string if successful; otherwise + * returns NULL. + * + * \details H5Tget_tag() returns the tag associated with the opaque datatype + * \p type. + * + * \attention The tag is returned via a pointer to an allocated string, which + * the caller must free. + * + */ H5_DLL char *H5Tget_tag(hid_t type); /* Querying property values */ +/** + * \ingroup H5T + * + * \brief Returns the base datatype from which a datatype is derived + * + * \type_id{type} + * + * \return \hid_t{datatype} + * + * \details H5Tget_super() returns the base datatype from which the datatype + * \p type_id is derived. In the case of an enumeration type, the + * return value is an integer type. + * + * The datatype identifier returned by this function must be released + * with H5Tclose() when the identifier is no longer needed so that + * resource leaks will not develop. + * + */ H5_DLL hid_t H5Tget_super(hid_t type); +/** + * \ingroup H5T + * + * \brief Returns a datatype class + * + * \type_id + * + * \return Returns the datatype class if successful; otherwise #H5T_NO_CLASS. + * + * \details H5Tget_class() returns the class of the datatype \p type_id. + * Valid class identifiers, as defined in H5Tpublic.h, are: + * \snippet this H5T_class_t_snip + * + * \note The library returns #H5T_STRING for both fixed-length and + * variable-length strings. + * + * \note Unsupported datatype: The time datatype class, #H5T_TIME, + * is not supported. If #H5T_TIME is used, the resulting data will + * be readable and modifiable only on the originating computing + * platform; it will not be portable to other platforms. + * + */ H5_DLL H5T_class_t H5Tget_class(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Determines whether a datatype contains any datatypes of the given + * datatype class + * + * \type_id + * \param[in] cls Datatype class + * + * \return \htri_t + * + * \details H5Tdetect_class() determines whether the datatype specified in + * \p type_id contains any datatypes of the datatype class specified + * in \p dtype_class. + * + * This function is useful primarily in recursively examining all the + * fields and/or base types of compound, array, and variable-length + * datatypes. + * + * Valid class identifiers, as defined in H5Tpublic.h, are: + * \snippet this H5T_class_t_snip + * + * \since 1.6.0 + * + */ H5_DLL htri_t H5Tdetect_class(hid_t type_id, H5T_class_t cls); +/** + * \ingroup H5T + * + * \brief Returns the size of a datatype + * + * \type_id + * + * \return Returns the size of the datatype in bytes if successful; otherwise, + * returns 0. + * + * \details H5Tget_size() returns the size of a datatype in bytes. + * \li For atomic datatypes, array datatypes, compound datatypes, and + * other datatypes of a constant size, the returned value is the + * size of the actual datatype in bytes. + * \li For variable-length string datatypes the returned value is + * the size of the pointer to the actual string, or \c sizeof(\c + * char \c *). This function does not return the size of actual + * variable-length string data. + * \li For variable-length sequence datatypes (see H5Tvlen_create()), + * the returned value is the size of the \p hvl_t struct, or \c + * sizeof(\p hvl_t). The \p hvl_t struct contains a pointer to the + * actual data and a size value. This function does not return the + * size of actual variable-length sequence data. + * + * \see H5Tset_size() + * + * \since 1.2.0 + */ H5_DLL size_t H5Tget_size(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Returns the byte order of an atomic datatype + * + * \type_id + * + * \return Returns a byte order constant if successful; otherwise returns + * #H5T_ORDER_ERROR (-1) + * + * \details H5Tget_order() returns the byte order of an atomic datatype. + * Possible return values are: + * \snippet this H5T_order_t_snip + * Members of a compound datatype need not have the same byte + * order. If members of a compound datatype have more than one of + * little endian, big endian, or VAX byte order, H5Tget_order() will + * return #H5T_ORDER_MIXED for the compound datatype. A byte order of + * #H5T_ORDER_NONE will, however, be ignored; for example, if one or + * more members of a compound datatype have byte order #H5T_ORDER_NONE + * but all other members have byte order #H5T_ORDER_LE, H5Tget_order() + * will return #H5T_ORDER_LE for the compound datatype. + * + * \since 1.2.0 + * + */ H5_DLL H5T_order_t H5Tget_order(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Returns the precision of an atomic datatype + * + * \type_id + * + * \return Returns the number of significant bits if successful; otherwise 0 + * + * \details H5Tget_precision() returns the precision of an atomic datatype + * (for example, integer or float) or a datatype whose base (parent) + * type is an atomic type (for example, array, enum and variable + * length). The precision is the number of significant bits which, + * unless padding is present, is 8 times larger than the value + * returned by H5Tget_size(). + * + * \since 1.2.0 + * + */ H5_DLL size_t H5Tget_precision(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Retrieves the bit offset of the first significant bit + * + * \type_id + * + * \return Returns an offset value if successful; otherwise returns a + * negative value. + * + * \details H5Tget_offset() retrieves the bit offset of the first significant + * bit. The significant bits of an atomic datum can be offset from the + * beginning of the memory for that datum by an amount of padding. The + * 'offset' property specifies the number of bits of padding that + * appear to the "right of" the value. That is, if we have a 32-bit + * datum with 16-bits of precision having the value 0x1122 then it + * will be laid out in memory as (from small byte address toward + * larger byte addresses): + * \code{.unparsed} + * 0: [ pad] [0x11] [0x22] [ pad] + * 1: [ pad] [0x22] [0x11] [ pad] + * 2: [0x11] [ pad] [ pad] [0x22] + * 3: [0x22] [ pad] [ pad] [0x11] + * \endcode + * + * \since 1.2.0 + * + */ H5_DLL int H5Tget_offset(hid_t type_id); -H5_DLL herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, - H5T_pad_t *msb/*out*/); +/** + * \ingroup ATOM + * + * \brief Retrieves the padding type of the least and most-significant bit padding + * + * \type_id + * \param[out] lsb Buffer for the least-significant bit padding type + * \param[out] msb Buffer for the most-significant bit padding type + * + * \return \herr_t + * + * \details H5Tget_pad() retrieves the padding type of the least and + * most-significant bit padding. Valid padding types are: + * \snippet this H5T_pad_t_snip + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out*/, H5T_pad_t *msb /*out*/); +/** + * \ingroup ATOM + * + * \brief Retrieves the sign type for an integer type + * + * \type_id + * + * \return Returns a valid sign type if successful; otherwise #H5T_SGN_ERROR (-1) + * + * \details H5Tget_sign() retrieves the sign type for an integer type. + * Valid types are: + * \snippet this H5T_sign_t_snip + * + * \since 1.2.0 + * + */ H5_DLL H5T_sign_t H5Tget_sign(hid_t type_id); -H5_DLL herr_t H5Tget_fields(hid_t type_id, size_t *spos/*out*/, - size_t *epos/*out*/, size_t *esize/*out*/, - size_t *mpos/*out*/, size_t *msize/*out*/); +/** + * \ingroup ATOM + * + * \brief Retrieves floating point datatype bit field information + * + * \type_id + * \param[out] spos Pointer to location to return floating-point sign bit + * \param[out] epos Pointer to location to return exponent bit-position + * \param[out] esize Pointer to location to return size of exponent in bits + * \param[out] mpos Pointer to location to return mantissa bit-position + * \param[out] msize Pointer to location to return size of mantissa in bits + * + * \return \herr_t + * + * \details H5Tget_fields() retrieves information about the locations of + * the various bit fields of a floating point datatype. The field + * positions are bit positions in the significant region of the + * datatype. Bits are numbered with the least significant bit number + * zero. Any (or even all) of the arguments can be null pointers. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tget_fields(hid_t type_id, size_t *spos /*out*/, size_t *epos /*out*/, size_t *esize /*out*/, + size_t *mpos /*out*/, size_t *msize /*out*/); +/** + * \ingroup ATOM + * + * \brief Retrieves the exponent bias of a floating-point type + * + * \type_id + * + * \return Returns the bias if successful and 0, otherwise. + * + * \details H5Tget_ebias() retrieves the exponent bias of a floating-point type. + * + * \since 1.2.0 + * + */ H5_DLL size_t H5Tget_ebias(hid_t type_id); +/** + * -------------------------------------------------------------------------- + * \ingroup ATOM + * + * \brief Retrieves mantissa normalization of a floating-point datatype + * + * \type_id + * + * \return Returns a valid normalization type if successful; otherwise + * returns #H5T_NORM_ERROR (-1) + * + * \details H5Tget_norm() retrieves the mantissa normalization of a + * floating-point datatype. Valid normalization types are: + * \snippet this H5T_norm_t_snip + * + * \since 1.2.0 + * + */ H5_DLL H5T_norm_t H5Tget_norm(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Retrieves the internal padding type for unused bits in floating-point + * datatypes + * + * \type_id + * + * \return Returns a valid padding type if successful; otherwise returns + * #H5T_PAD_ERROR (-1). + * + * \details H5Tget_inpad() retrieves the internal padding type for unused + * bits in floating-point datatypes. Valid padding types are: + * \snippet this H5T_pad_t_snip + * + * \since 1.2.0 + * + */ H5_DLL H5T_pad_t H5Tget_inpad(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Retrieves the type of padding used for a string datatype + * + * \type_id + * + * \return Returns a valid string of the padding if successful; otherwise + * returns #H5T_STR_ERROR (-1) + * + * \details H5Tget_strpad() retrieves the type of padding used for a string + * datatype. + * + * The string padding type is set with H5Tset_strpad(). Possible + * values returned are: + * \str_pad_type + * + * \since 1.2.0 + * + */ H5_DLL H5T_str_t H5Tget_strpad(hid_t type_id); +/** + * \ingroup COMPOUND ENUM + * + * \brief Retrieves the number of elements in a compound or enumeration datatype + * + * \type_id + * + * \return Returns the number of elements if successful; otherwise returns a + * negative value. + * + * \details H5Tget_nmembers() retrieves the number of fields in a compound + * datatype or the number of members of an enumeration datatype. + * + * \since 1.2.0 + * + */ H5_DLL int H5Tget_nmembers(hid_t type_id); +/** + * \ingroup COMPOUND ENUM + * + * \brief Retrieves the name of a compound or enumeration datatype member + * + * \type_id + * \param[in] membno Zero-based index of the field or element + * + * \return Returns a valid pointer to a string allocated with malloc() if + * successful; otherwise returns NULL. + * + * \details H5Tget_member_name() retrieves the name of a field of a compound + * datatype or an element of an enumeration datatype. + * + * The index of the target field or element is specified in \p + * member_no. Compound datatype fields and enumeration datatype + * elements are stored in no particular order with index values of + * 0 through N-1, where N is the value returned by H5Tget_nmembers(). + * + * The HDF5 library allocates a buffer to receive the name of + * the field. The caller must subsequently free the buffer with + * H5free_memory(). + * + * \since 1.2.0 + * + */ H5_DLL char *H5Tget_member_name(hid_t type_id, unsigned membno); +/** + * \ingroup COMPOUND ENUM + * + * \brief Retrieves the index of a compound or enumeration datatype member + * + * \type_id + * \param[in] name Name of the field or member + * + * \return \herr_t + * + * \details H5Tget_member_index() retrieves the index of a field of a compound + * datatype or an element of an enumeration datatype. + * + * The name of the target field or element is specified by \p name. + * + * Fields are stored in no particular order with index values of 0 + * through N-1, where N is the value returned by H5Tget_nmembers() . + * + * \since 1.2.0 + * + */ H5_DLL int H5Tget_member_index(hid_t type_id, const char *name); +/** + * \ingroup COMPOUND + * + * \brief Retrieves the offset of a field of a compound datatype + * + * \type_id + * \param[in] membno Zero-based index of the field or element + * + * \return Returns the byte offset of the field if successful; otherwise + * returns 0 (zero). + * + * \details H5Tget_member_offset() retrieves the byte offset of the beginning + * of a field within a compound datatype with respect to the beginning + * of the compound datatype datum. + * + * Note that zero is a valid offset and that this function will fail + * only if a call to H5Tget_member_class() fails with the same arguments. + * + * \version 1.6.4 \p member_no parameter type changed to unsigned. + * + * \since 1.2.0 + * + */ H5_DLL size_t H5Tget_member_offset(hid_t type_id, unsigned membno); +/** + * \ingroup COMPOUND + * + * \brief Returns datatype class of compound datatype member + * + * \type_id + * \param[in] membno Zero-based index of the field or element + * + * \return Returns the datatype class, a non-negative value, if successful; + * otherwise returns a negative value. + * + * \details Given a compound datatype, \p dtype_id, H5Tget_member_class() + * returns the datatype class of the member specified by \p member_no. + * + * Valid class identifiers, as defined in H5Tpublic.h, are: + * \snippet this H5T_class_t_snip + * + * \since 1.2.0 + * + */ H5_DLL H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno); +/** + * \ingroup COMPOUND + * + * \brief Returns the datatype of the specified member + * + * \type_id + * \param[in] membno Zero-based index of the field or element + * + * \return Returns the identifier of a copy of the datatype of the field if + * successful; otherwise returns a negative value. + * + * \details H5Tget_member_type() returns the datatype of the specified member. + * The caller should invoke H5Tclose() to release resources associated + * with the type. + * + * \version 1.6.4 \p membno parameter type changed to unsigned. + * + * \since 1.2.0 + * + */ H5_DLL hid_t H5Tget_member_type(hid_t type_id, unsigned membno); -H5_DLL herr_t H5Tget_member_value(hid_t type_id, unsigned membno, void *value/*out*/); +/** + * \ingroup ENUM + * + * \brief Returns the value of an enumeration datatype member + * + * \type_id + * \param[in] membno Number of the enumeration datatype member + * \param[out] value Buffer for the value of the enumeration datatype member + * + * \return \herr_t + * + * \details H5Tget_member_value() returns the value of the enumeration datatype + * member \p member_no. + * + * The member value is returned in a user-supplied buffer pointed to + * by \p value. Values returned in \p value will be of the enumerated + * type’s base type, that is, the datatype used by H5Tenum_create() + * when the enumerated type was created. + * + * The value buffer must be at least large enough to hold a value + * of that base type. If the size is unknown, you can determine it + * with H5Tget_size(). + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tget_member_value(hid_t type_id, unsigned membno, void *value /*out*/); +/** + * \ingroup ATOM + * + * \brief Retrieves the character set type of a string datatype + * + * \type_id + * + * \return Returns a valid character set type if successful; otherwise + * #H5T_CSET_ERROR (-1). + * + * \details H5Tget_cset() retrieves the character set type of a string datatype. + * Valid character set types are: + * \csets + * + * \since 1.2.0 + * + */ H5_DLL H5T_cset_t H5Tget_cset(hid_t type_id); +/** + * \ingroup ATOM + * + * \brief Determines whether datatype is a variable-length string + * + * \type_id + * + * \return Returns: + * \li a positive value if the specified datatype is a variable-length + * string + * \li 0 if the specified datatype is not a variable-length string + * \li a negative value when the function fails + * + * \details H5Tis_variable_str() determines whether the datatype identified + * by \p dtype_id is a variable-length string. + * + * This function can be used to distinguish between fixed and + * variable-length string datatypes. + * + * \since 1.6.0 + * + */ H5_DLL htri_t H5Tis_variable_str(hid_t type_id); +/** + * \ingroup H5T + * + * \brief Returns the native datatype identifier of a specified datatype + * + * \type_id + * \param[in] direction Direction of search + * + * \return \hid_t{native datatype} + * + * \details H5Tget_native_type() returns the equivalent native datatype + * identifier for the datatype specified by \p type_id. + * + * H5Tget_native_type() is designed primarily to facilitate use of + * the H5Dread() function, for which users otherwise must undertake a + * multi-step process to determine the native datatype of a dataset + * prior to reading it into memory. This function can be used for + * the following purposes: + * + * \li To determine the native datatype of an atomic datatype + * \li To determine the base datatype of an array, enumerated, or + * variable-length datatype + * \li To determine the native atomic datatypes of the individual + * components of a compound datatype + * + * For example, if \p type_id is a compound datatype, the returned + * datatype identifier will be for a similar compound datatype with + * each element converted to the corresponding native datatype; + * nested compound datatypes will be unwound. If \p type_id is an + * array, the returned datatype identifier will be for the native + * datatype of a single array element. + * + * H5Tget_native_type() selects the first matching native datatype + * from the following list: + * + * \li #H5T_NATIVE_CHAR + * \li #H5T_NATIVE_SHORT + * \li #H5T_NATIVE_INT + * \li #H5T_NATIVE_LONG + * \li #H5T_NATIVE_LLONG + * + * \li #H5T_NATIVE_UCHAR + * \li #H5T_NATIVE_USHORT + * \li #H5T_NATIVE_UINT + * \li #H5T_NATIVE_ULONG + * \li #H5T_NATIVE_ULLONG + * + * \li #H5T_NATIVE_FLOAT + * \li #H5T_NATIVE_DOUBLE + * \li #H5T_NATIVE_LDOUBLE + * + * \li #H5T_NATIVE_B8 + * \li #H5T_NATIVE_B16 + * \li #H5T_NATIVE_B32 + * \li #H5T_NATIVE_B64 + * + * The direction parameter indicates the order in which the library + * searches for a native datatype match. Valid values for direction + * are as follows: + * \snippet this H5T_direction_t_snip + * + * H5Tget_native_type() is designed primarily for use with integer, + * floating point, and bitfield datatypes. String, time, opaque, and + * reference datatypes are returned as a copy of dtype_id. See above + * for compound, array, enumerated, and variable-length datatypes. + * + * The identifier returned by H5Tget_native_type() should eventually + * be closed by calling H5Tclose() to release resources. + * + * \note Please note that a datatype is actually an object + * identifier or handle returned from opening the datatype. It + * is not persistent and its value can be different from one HDF5 + * session to the next. + * + * \note H5Tequal() can be used to compare datatypes. + * + * \note 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. + * + * \since 1.6.0 + * + */ H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); /* Setting property values */ +/** + * \ingroup H5T + * + * \brief Sets size for a datatype. + * + * \type_id + * \param[in] size New datatype size is bytes or #H5T_VARIABLE + * + * \return \herr_t + * + * \details H5Tset_size() sets the total size, \p size, in bytes, for a + * datatype. + * + * \p size must have a positive value, unless it is passed in as + * #H5T_VARIABLE and the datatype is a string datatype. + * + * \li Numeric datatypes: If the datatype is atomic and the size + * is decreased so that significant bits of the datatype extend + * beyond the edge of the new size, then the offset property of the + * datatype is decreased toward zero. If the offset becomes zero + * and the significant bits of the datatype still hang over the edge + * of the new size, then the number of significant bits is decreased. + * + * \li String or character datatypes: The size set for a string + * datatype should include space for the null-terminator character, + * otherwise it will not be stored on (or retrieved from) + * disk. Adjusting the size of a string automatically sets the + * precision to \p 8*size. + * + * \li Variable-length string datatypes: If \p dtype_id is a + * variable-length string, size must normally be set to #H5T_VARIABLE. + * See \ref_vlen_strings. + * + * \li Compound datatypes: This function may be used to increase or + * decrease the size of a compound datatype, but the function will + * fail if the new size is too small to accommodate all member fields. + * + * \li Ineligible datatypes: This function cannot be used with + * enumerated datatypes (#H5T_ENUM), array datatypes (#H5T_ARRAY), + * variable-length array datatypes (#H5T_VLEN), or reference datatypes + * (#H5T_REFERENCE). + * + * \see H5Tget_size() + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_size(hid_t type_id, size_t size); +/** + * \ingroup ATOM + * + * \brief Sets the byte order of a datatype + * + * \type_id + * \param[in] order Byte order constant + * + * \return \herr_t + * + * \details H5Tset_order() sets the byte order of a datatype.\n + * Byte order can currently be set to any of the following: + * \snippet this H5T_order_t_snip + * #H5T_ORDER_MIXED (3) is a valid value for order only when + * returned by the function H5Tget_order(); it cannot be set with + * H5Tset_order(). + * + * #H5T_ORDER_NONE (4) is a valid value for order, but it has no + * effect. It is valid only for fixed-length strings and object and + * region references and specifies “no particular order.” + * + * The byte order of a derived datatype is initially the same as + * that of the parent type, but can be changed with H5Tset_order(). + * + * This function cannot be used with a datatype after it has been + * committed. + * + * \note Special considerations: + * \li ENUM datatypes: Byte order must be set before any member on + * an ENUM is defined. + * \li Compound datatypes: Byte order is set individually on each member + * of a compound datatype; members of a compound datatype need not + * have the same byte order. + * \li Opaque datatypes: Byte order can be set but has no effect. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_order(hid_t type_id, H5T_order_t order); +/** + * \ingroup ATOM + * + * \brief Sets the precision of an atomic datatype + * + * \type_id + * \param[in] prec Number of bits of precision for datatype + * + * \return \herr_t + * + * \details H5Tset_precision() sets the precision of an atomic datatype. The + * precision is the number of significant bits which, unless + * padding is present, is 8 times larger than the value returned + * by H5Tget_size(). + * + * If the precision is increased then the offset is decreased and + * then the size is increased to insure that significant bits do not + * "hang over" the edge of the datatype. + * + * Changing the precision of an #H5T_STRING automatically changes + * the size as well. The precision must be a multiple of 8. + * + * When decreasing the precision of a floating point type, set the + * locations and sizes of the sign, mantissa, and exponent fields + * first. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_precision(hid_t type_id, size_t prec); +/** + * \ingroup ATOM + * + * \brief Sets the bit offset of the first significant bit + * + * \type_id + * \param[in] offset Offset of first significant bit + * + * \return \herr_t + * + * \details H5Tset_offset() sets the bit offset of the first significant + * bit. The significant bits of an atomic datum can be offset from + * the beginning of the memory for that datum by an amount of + * padding. The offset property specifies the number of bits of + * padding that appear “to the right of” the value. That is, + * if we have a 32-bit datum with 16-bits of precision having the + * value 0x1122, then it will be laid out in memory as (from small + * byte address toward larger byte addresses): + * \code{.unparsed} + * 0: [ pad] [0x11] [0x22] [ pad] + * 1: [ pad] [0x22] [0x11] [ pad] + * 2: [0x11] [ pad] [ pad] [0x22] + * 3: [0x22] [ pad] [ pad] [0x11] + * \endcode + * 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 offset of an #H5T_STRING cannot be set to anything but zero. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_offset(hid_t type_id, size_t offset); +/** + * \ingroup ATOM + * + * \brief Sets the least and most-significant bits padding types + * + * \type_id + * \param[in] lsb Padding type for least-significant bits + * \param[in] msb Padding type for most-significant bits + * + * \return \herr_t + * + * \details H5Tset_pad() sets the least and most-significant bits padding types. + * Available values are: + * \padding_type + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb); +/** + * \ingroup ATOM + * + * \brief Sets the sign property for an integer type + * + * \type_id + * \param[in] sign Sign type + * + * \return \herr_t + * + * \details H5Tset_sign() sets the sign property for an integer type: + * \sign_prop + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign); -H5_DLL herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, - size_t esize, size_t mpos, size_t msize); +/** + * \ingroup ATOM + * + * \brief Sets locations and sizes of floating point bit fields + * + * \type_id + * \param[in] spos Sign position, i.e., the bit offset of the floating-point + * sign bit + * \param[in] epos Exponent bit position + * \param[in] esize Size of exponent in bits + * \param[in] mpos Mantissa bit position + * \param[in] msize Size of mantissa in bits + * + * \return \herr_t + * + * \details H5Tset_fields() sets the locations and sizes of the various + * floating-point bit fields. The field positions are bit positions + * in the significant region of the datatype. Bits are numbered with + * the least significant bit number zero. + * + * Fields are not allowed to extend beyond the number of bits of + * precision, nor are they allowed to overlap with one another. + * + * \since 1.2.0 + * + */ +H5_DLL herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, size_t mpos, size_t msize); +/** + * \ingroup ATOM + * + * \brief Sets the exponent bias of a floating-point type + * + * \type_id + * \param[in] ebias Exponent bias value + * + * \return \herr_t + * + * \details H5Tset_ebias() sets the exponent bias of a floating-point type. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_ebias(hid_t type_id, size_t ebias); +/** + * \ingroup ATOM + * + * \brief Sets the mantissa normalization of a floating-point datatype + * + * \type_id + * \param[in] norm Mantissa normalization type + * + * \return \herr_t + * + * \details H5Tset_norm() sets the mantissa normalization of a floating-point + * datatype. Valid normalization types are: + * \snippet this H5T_norm_t_snip + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm); +/** + * \ingroup ATOM + * + * \brief Fills unused internal floating-point bits + * + * \type_id + * \param[in] pad Padding type + * + * \return \herr_t + * + * \details H5Tset_inpad() If any internal bits of a floating point-type are + * unused (that is, those significant bits which are not part of the + * sign, exponent, or mantissa), then H5Tset_inpad() will be filled + * according to the value of the padding value property inpad. Valid + * padding types are: + * \snippet this H5T_pad_t_snip + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad); +/** + * \ingroup ATOM + * + * \brief Sets character set to be used in a string or character datatype + * + * \type_id + * \param[in] cset Character set type + * + * \return \herr_t + * + * \details H5Tset_cset() sets the character set to be used in a dataset with + * a string or character datatype. + * + * Valid values for cset include the following: + * \csets + * For example, if the character set for the datatype \p type_id is set + * to #H5T_CSET_UTF8, string or character data of datatype dtype_id + * will be encoded using the UTF-8 Unicode character set. + * + * ASCII and UTF-8 Unicode are the only currently supported character + * encodings. Extended ASCII encodings (for example, ISO 8859) are + * not supported. This encoding policy is not enforced by the HDF5 + * library. Using encodings other than ASCII and UTF-8 can lead to + * compatibility and usability problems. + * + * Note that H5Tset_cset() sets the character set for a character or + * string datatype while H5Pset_char_encoding() sets the character + * set used for an HDF5 link or attribute name. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset); +/** + * \ingroup ATOM + * + * \brief Defines the type of padding used for character strings + * + * \type_id + * \param[in] strpad String padding type + * + * \return \herr_t + * + * \details H5Tset_strpad() defines the type of padding used for a string + * datatype. + * + * The method used to store character strings differs with the + * programming language. C usually null terminates strings while + * Fortran left-justifies and space-pads strings. + * + * Valid values of \p strpad are as follows: + * \str_pad_type + * When converting from a longer string to a shorter string, the + * behavior is as follows. If the shorter string is #H5T_STR_NULLPAD + * or #H5T_STR_SPACEPAD, then the string is simply truncated. If + * the short string is #H5T_STR_NULLTERM, it is truncated and a null + * terminator is appended. + * + * When converting from a shorter string to a longer string, the + * longer string is padded on the end by appending nulls or spaces. + * + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad); /* Type conversion database */ -H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, - hid_t dst_id, H5T_conv_t func); -H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, - hid_t dst_id, H5T_conv_t func); +/** + * \ingroup CONV + * + * \brief Registers a datatype conversion function + * + * \param[in] pers Conversion function type + * \param[in] name Name displayed in diagnostic output + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[in] func Function to convert between source and destination datatypes + * + * \return \herr_t + * + * \details H5Tregister() registers a hard or soft conversion function for a + * datatype conversion path. The parameter \p pers indicates whether a + * conversion function is hard (#H5T_PERS_HARD) or soft + * (#H5T_PERS_SOFT). User-defined functions employing compiler casting + * are designated as \Emph{hard}; other user-defined conversion + * functions registered with the HDF5 library (with H5Tregister() ) + * are designated as \Emph{soft}. The HDF5 library also has its own + * hard and soft conversion functions. + * + * A conversion path can have only one hard function. When type is + * #H5T_PERS_HARD, \p func replaces any previous hard function. + * + * When type is #H5T_PERS_SOFT, H5Tregister() adds the function to the + * end of the master soft list and replaces the soft function in all + * applicable existing conversion paths. Soft functions are used when + * determining which conversion function is appropriate for this path. + * + * The \p name is used only for debugging and should be a short + * identifier for the function. + * + * The path is specified by the source and destination datatypes \p + * src_id and \p dst_id. For soft conversion functions, only the class + * of these types is important. + * + * The type of the conversion function pointer is declared as: + * \snippet this H5T_conv_t_snip + * + * The \ref H5T_cdata_t \c struct is declared as: + * \snippet this H5T_cdata_t_snip + * + * \since 1.6.3 The following change occurred in the \ref H5T_conv_t function: + * the \c nelmts parameter type changed to size_t. + * + */ +H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); +/** + * \ingroup CONV + * + * \brief Removes a conversion function + * + * \param[in] pers Conversion function type + * \param[in] name Name displayed in diagnostic output + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[in] func Function to convert between source and destination datatypes + * + * \return \herr_t + * + * \details H5Tunregister() removes a conversion function matching criteria + * such as soft or hard conversion, source and destination types, and + * the conversion function. + * + * If a user is trying to remove a conversion function he registered, + * all parameters can be used. If he is trying to remove a library’s + * default conversion function, there is no guarantee the \p name and + * \p func parameters will match the user’s chosen values. Passing in + * some values may cause this function to fail. A good practice is to + * pass in NULL as their values. + * + * All parameters are optional. The missing parameters will be used to + * generalize the search criteria. + * + * The conversion function pointer type declaration is described in + * H5Tregister(). + * + * \version 1.6.3 The following change occurred in the \ref H5T_conv_t function: + * the \c nelmts parameter type changed to size_t. + * + */ +H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); +/** + * \ingroup CONV + * + * \brief Finds a conversion function + * + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[out] pcdata Pointer to type conversion data + * + * \return Returns a pointer to a suitable conversion function if successful. + * Otherwise returns NULL. + * + * \details H5Tfind() finds a conversion function that can handle a conversion + * from type \p src_id to type \p dst_id. The \p pcdata argument is a + * pointer to a pointer to type conversion data which was created and + * initialized by the soft type conversion function of this path when + * the conversion function was installed on the path. + * + */ H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); +/** + * \ingroup CONV + * + * \brief Check whether the library’s default conversion is hard conversion + * + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * + * \return \htri_t + * + * \details H5Tcompiler_conv() determines whether the library’s conversion + * function from type \p src_id to type \p dst_id is a compiler (hard) + * conversion or not. A compiler conversion uses compiler’s casting; a + * library (soft) conversion uses the library’s own conversion + * function. + * + * \since 1.8.0 + * + */ H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id); -H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, - void *buf, void *background, hid_t plist_id); +/** + * -------------------------------------------------------------------------- + * \ingroup CONV + * + * \brief Converts data from one specified datatype to another + * + * \type_id{src_id} of source datatype + * \type_id{dst_id} of destination datatype + * \param[in] nelmts Size of array \p buf + * \param[in,out] buf Array containing pre- and post-conversion values + * \param[in] background Optional background buffer + * \dxpl_id{plist_id} + * + * \return \herr_t + * + * \details H5Tconvert() converts \p nelmts elements from a source datatype, + * specified by \p src_id, to a destination datatype, \p dst_id. The + * source elements are packed in \p buf and on return the destination + * elements will be packed in \p buf. That is, the conversion is + * performed in place. + * + * The optional background buffer is for use with compound datatypes. + * It is an array of \p nelmts values for the destination datatype + * which can then be merged with the converted values to recreate the + * compound datatype. For instance, background might be an array of + * structs with the \c a and \c b fields already initialized and the + * conversion of buf supplies the \c c and \c d field values. + * + * The parameter \p plist_id contains the dataset transfer property list + * identifier which is passed to the conversion functions. As of + * Release 1.2, this parameter is only used to pass along the + * variable-length datatype custom allocation information. + * + * \note H5Tconvert() will not resize the buffer \p buf; it must be large + * enough to hold the larger of the input and output data. + * + * \version 1.6.3 \p nelmts parameter type changed to size_t. + * \version 1.4.0 \p nelmts parameter type changed to hsize_t. + * + */ +H5_DLL herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, + hid_t plist_id); +/** + * \ingroup VLEN + * + * \brief Reclaims the variable length (VL) datatype memory buffers + * + * \type_id + * \space_id + * \dxpl_id{plist_id} used to create the buffer + * \param[in] buf Pointer to the buffer to be reclaimed + * + * \return \herr_t + * + * \details H5Treclaim() reclaims memory buffers created to store VL datatypes. + * It only frees the variable length data in the selection defined in + * the dataspace specified by \p space_id. The dataset transfer + * property list \p plist_id is required to find the correct + * allocation and/or free methods for the variable-length data in the + * buffer. + * + * \since 1.12.0 + * + */ +H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf); /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. */ + #ifndef H5_NO_DEPRECATED_SYMBOLS /* Macros */ - /* Typedefs */ - /* Function prototypes */ +/** + * \ingroup H5T + * + * \brief Commits a transient datatype to a file, creating a new named datatype + * + * \fg_loc_id + * \param[in] name Name given to committed datatype + * \param[in] type_id Identifier of datatype to be committed + * + * \return \herr_t + * + * \deprecated This function has been renamed from H5Tcommit() and is + * deprecated in favor of the macro #H5Tcommit or the function + * H5Tcommit2(). + * + * \details H5Tcommit1() commits the transient datatype (not immutable) to + * a file, turning it into a named datatype. + * + * The datatype \p dtype_id is committed as a named datatype at the + * location \p loc_id, which is either a file or group identifier, + * with the name \p name. + * + * \p name can be a relative path based at \p loc_id or an absolute + * path from the root of the file. Use of this function requires + * that any intermediate groups specified in the path already exist. + * + * As is the case for any object in a group, the length of the name + * of a named datatype is not limited. + * + * See H5Tcommit_anon() for a discussion of the differences between + * H5Tcommit() and H5Tcommit_anon(). + * + * This function will not accept a datatype that cannot actually + * hold data. This currently includes compound datatypes with no + * fields and enumerated datatypes with no members. + * + * \version 1.8.7 Function modified in this release to reject datatypes that + * will not accommodate actual data, such as a compound datatype with + * no fields or an enumerated datatype with no members. + * \version 1.8.0 C function H5Tcommit() renamed to H5Tcommit1() and deprecated + * in this release. + * \since 1.2.0 + * + */ H5_DLL herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id); +/** + * \ingroup H5T + * + * \brief Opens a named datatype + * + * \fg_loc_id + * \param[in] name A datatype name, defined within the specified file or group + * + * \return \herr_t + * + * \deprecated This function has been renamed from H5Topen() and is + * deprecated in favor of the macro #H5Topen or the function + * H5Topen2(). + * + * \details H5Topen1() opens a named datatype at the location specified by + * \p loc_id and returns an identifier for the datatype. \p loc_id + * can be either a file or group identifier. The identifier should + * eventually be closed by calling H5Tclose() to release resources. + * + * \version 1.8.0 Function H5Topen() renamed to H5Topen1() and deprecated in + * this release. + * + * \since 1.2.0 + * + */ H5_DLL hid_t H5Topen1(hid_t loc_id, const char *name); -H5_DLL hid_t H5Tarray_create1(hid_t base_id, int ndims, - const hsize_t dim[/* ndims */], - const int perm[/* ndims */]); +/** + * \ingroup ARRAY + * + * \brief Creates an array datatype object + * + * \param[in] base_id Datatype identifier for the array base datatype + * \param[in] ndims Rank of the array + * \param[in] dim Size of each array dimension + * \param[in] perm Dimension permutation (Currently not implemented.) + * + * \return \hid_t{array datatype} + * + * \deprecated This function has been renamed from H5Tarray_create() and is + * deprecated in favor of the macro #H5Tarray_create or the function + * H5Tarray_create2(). + * + * \details H5Tarray_create1() creates a new array datatype object.\n\n + * \p base_id is the datatype of every element of the array, i.e., + * of the number at each position in the array. + * + * \p rank is the number of dimensions and the size of each dimension + * is specified in the array dims. The value of rank is currently + * limited to #H5S_MAX_RANK and must be greater than 0 (zero). All + * dimension sizes specified in dims must be greater than 0 (zero). + * + * The array \p perm is designed to contain the dimension permutation, + * i.e. C versus FORTRAN array order. (The parameter perm is + * currently unused and is not yet implemented.) + * + * \version 1.8.0 Function H5Tarray_create() renamed to H5Tarray_create1() + * and deprecated in this release. + * \since 1.4.0 + * + */ +H5_DLL hid_t H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], + const int perm[/* ndims */]); +/** + * \ingroup ARRAY + * + * \brief Retrieves sizes of array dimensions + * + * \type_id + * \param[out] dims Sizes of array dimensions + * \param[out] perm Dimension permutations (This parameter is not used.) + * + * \return Returns the non-negative number of dimensions of the array type + * if successful; otherwise, returns a negative value. + * + * \deprecated This function has been renamed from H5Tget_array_dims() and is + * deprecated in favor of the macro #H5Tget_array_dims or the + * function H5Tget_array_dims2(). + * + * \details H5Tget_array_dims1() returns the sizes of the dimensions and + * the dimension permutations of the specified array datatype object. + * + * The sizes of the dimensions are returned in the array \p dims. + * + * \version 1.8.0 Function H5Tarray_create() renamed to H5Tarray_create1() + * and deprecated in this release. + * \since 1.2.0 + * + */ H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -617,5 +3027,4 @@ H5_DLL int H5Tget_array_dims1(hid_t type_id, hsize_t dims[], int perm[]); #ifdef __cplusplus } #endif -#endif /* _H5Tpublic_H */ - +#endif /* H5Tpublic_H */ diff --git a/src/H5Tref.c b/src/H5Tref.c new file mode 100644 index 00000000000..1114c25ad39 --- /dev/null +++ b/src/H5Tref.c @@ -0,0 +1,1283 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Module Info: This module contains the functionality for reference + * datatypes in the H5T interface. + */ + +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5R_FRIEND /*suppress error about including H5Rpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Fpkg.h" /* File */ +#include "H5Rpkg.h" /* References */ +#include "H5Tpkg.h" /* Datatypes */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +#define H5T_REF_MEM_SIZE (H5R_REF_BUF_SIZE) +#define H5T_REF_OBJ_MEM_SIZE (H5R_OBJ_REF_BUF_SIZE) +#define H5T_REF_DSETREG_MEM_SIZE (H5R_DSET_REG_REF_BUF_SIZE) + +#define H5T_REF_OBJ_DISK_SIZE(f) (H5F_SIZEOF_ADDR(f)) +#define H5T_REF_DSETREG_DISK_SIZE(f) (H5HG_HEAP_ID_SIZE(f)) + +/* Debug */ +// #define H5T_REF_DEBUG +#ifdef H5T_REF_DEBUG +#define H5T_REF_LOG_DEBUG(...) \ + do { \ + HDfprintf(stdout, " # %s(): ", __func__); \ + HDfprintf(stdout, __VA_ARGS__); \ + HDfprintf(stdout, "\n"); \ + HDfflush(stdout); \ + } while (0) +#else +#define H5T_REF_LOG_DEBUG(...) \ + do { \ + } while (0) +#endif + +/******************/ +/* Local Typedefs */ +/******************/ + +/* For region compatibility support */ +struct H5Tref_dsetreg { + H5O_token_t token; /* Object token */ + H5S_t * space; /* Dataspace */ +}; + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5T__ref_mem_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); +static herr_t H5T__ref_mem_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); +static size_t H5T__ref_mem_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_mem_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, + void *bg_buf); + +static herr_t H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); +static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); +static size_t H5T__ref_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_disk_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf); + +/* For compatibility */ +static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); +static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); + +static herr_t H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, + hbool_t *isnull); +static size_t H5T__ref_dsetreg_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, hbool_t *dst_copy); +static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Class for reference in memory */ +static const H5T_ref_class_t H5T_ref_mem_g = { + H5T__ref_mem_isnull, /* 'isnull' */ + H5T__ref_mem_setnull, /* 'setnull' */ + H5T__ref_mem_getsize, /* 'getsize' */ + H5T__ref_mem_read, /* 'read' */ + H5T__ref_mem_write /* 'write' */ +}; + +static const H5T_ref_class_t H5T_ref_disk_g = { + H5T__ref_disk_isnull, /* 'isnull' */ + H5T__ref_disk_setnull, /* 'setnull' */ + H5T__ref_disk_getsize, /* 'getsize' */ + H5T__ref_disk_read, /* 'read' */ + H5T__ref_disk_write /* 'write' */ +}; + +static const H5T_ref_class_t H5T_ref_obj_disk_g = { + H5T__ref_obj_disk_isnull, /* 'isnull' */ + NULL, /* 'setnull' */ + H5T__ref_obj_disk_getsize, /* 'getsize' */ + H5T__ref_obj_disk_read, /* 'read' */ + NULL /* 'write' */ +}; + +static const H5T_ref_class_t H5T_ref_dsetreg_disk_g = { + H5T__ref_dsetreg_disk_isnull, /* 'isnull' */ + NULL, /* 'setnull' */ + H5T__ref_dsetreg_disk_getsize, /* 'getsize' */ + H5T__ref_dsetreg_disk_read, /* 'read' */ + NULL /* 'write' */ +}; + +/*------------------------------------------------------------------------- + * Function: H5T__ref_set_loc + * + * Purpose: Sets the location of a reference datatype to be either on disk + * or in memory + * + * Return: + * One of two values on success: + * TRUE - If the location of any reference types changed + * FALSE - If the location of any reference types is the same + * Negative value is returned on failure + * + *------------------------------------------------------------------------- + */ +htri_t +H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) +{ + htri_t ret_value = FALSE; /* Indicate success, but no location change */ + + FUNC_ENTER_PACKAGE + H5T_REF_LOG_DEBUG("loc=%d", (int)loc); + + HDassert(dt); + /* f is NULL when loc == H5T_LOC_MEMORY */ + HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); + + /* Only change the location if it's different */ + if (loc == dt->shared->u.atomic.u.r.loc && file == dt->shared->u.atomic.u.r.file) + HGOTO_DONE(FALSE) + + switch (loc) { + case H5T_LOC_MEMORY: /* Memory based reference datatype */ + + /* NB. We allow for the file to be non-NULL when doing + * memory-to-memory conversion */ + + /* Mark this type as being stored in memory */ + dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; + + /* Release owned file */ + if (dt->shared->owned_vol_obj) { + if (H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") + dt->shared->owned_vol_obj = NULL; + } /* end if */ + + /* Reset file ID (since this reference is in memory) */ + dt->shared->u.atomic.u.r.file = file; /* file is NULL */ + + if (dt->shared->u.atomic.u.r.opaque) { + /* Size in memory, disk size is different */ + dt->shared->size = H5T_REF_MEM_SIZE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Set up the function pointers to access the reference in memory */ + dt->shared->u.atomic.u.r.cls = &H5T_ref_mem_g; + } /* end if */ + else if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { + /* Size in memory, disk size is different */ + dt->shared->size = H5T_REF_OBJ_MEM_SIZE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Unused for now */ + dt->shared->u.atomic.u.r.cls = NULL; + } /* end else-if */ + else if (dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { + /* Size in memory, disk size is different */ + dt->shared->size = H5T_REF_DSETREG_MEM_SIZE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Unused for now */ + dt->shared->u.atomic.u.r.cls = NULL; + } /* end else-if */ + else + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid location") + break; + + case H5T_LOC_DISK: /* Disk based reference datatype */ + HDassert(file); + + /* Mark this type as being stored on disk */ + dt->shared->u.atomic.u.r.loc = H5T_LOC_DISK; + + /* Set file pointer (since this reference is on disk) */ + dt->shared->u.atomic.u.r.file = file; + + /* dt now owns a reference to file */ + if (H5T_own_vol_obj(dt, file) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") + + if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { + H5F_t *f; + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, + "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (f = (H5F_t *)H5VL_object_data(file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Size on disk, memory size is different */ + dt->shared->size = H5T_REF_OBJ_DISK_SIZE(f); + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Set up the function pointers to access the reference in memory */ + dt->shared->u.atomic.u.r.cls = &H5T_ref_obj_disk_g; + } /* end if */ + else if (dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION1) { + H5F_t *f; + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, + "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (f = (H5F_t *)H5VL_object_data(file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Size on disk, memory size is different */ + dt->shared->size = H5T_REF_DSETREG_DISK_SIZE(f); + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Set up the function pointers to access the reference in memory */ + dt->shared->u.atomic.u.r.cls = &H5T_ref_dsetreg_disk_g; + } /* end else-if */ + else { + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + size_t ref_encode_size; + H5R_ref_priv_t fixed_ref; + + /* Get container info */ + if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") + + /* Retrieve min encode size (when references have no vlen part) */ + HDmemset(&fixed_ref, 0, sizeof(fixed_ref)); + fixed_ref.type = (int8_t)H5R_OBJECT2; + fixed_ref.token_size = (uint8_t)cont_info.token_size; + if (H5R__encode(NULL, &fixed_ref, NULL, &ref_encode_size, 0) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get encode size") + + /* Size on disk, memory size is different */ + dt->shared->size = MAX(H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size, + ref_encode_size); + dt->shared->u.atomic.prec = 8 * dt->shared->size; + + /* Set up the function pointers to access the information on + * disk. Region and attribute references are stored identically + * on disk, so use the same functions. + */ + dt->shared->u.atomic.u.r.cls = &H5T_ref_disk_g; + } + break; + + case H5T_LOC_BADLOC: + /* Allow undefined location. In H5Odtype.c, H5O_dtype_decode sets undefined + * location for reference type and leaves it for the caller to decide. + */ + dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; + + /* Reset file pointer */ + dt->shared->u.atomic.u.r.file = NULL; + + /* Reset the function pointers */ + dt->shared->u.atomic.u.r.cls = NULL; + + break; + + case H5T_LOC_MAXLOC: /* MAXLOC is invalid */ + default: + HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid reference datatype location") + } /* end switch */ + + /* Indicate that the location changed */ + ret_value = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_set_loc() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_mem_isnull + * + * Purpose: Check if it's a NULL / uninitialized reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, hbool_t *isnull) +{ + const unsigned char zeros[H5T_REF_MEM_SIZE] = {0}; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC_NOERR + H5T_REF_LOG_DEBUG(""); + + /* Check parameters */ + HDassert(src_buf); + HDassert(isnull); + + *isnull = (0 == HDmemcmp(src_buf, zeros, H5T_REF_MEM_SIZE)) ? TRUE : FALSE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_mem_isnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_mem_setnull + * + * Purpose: Set a reference as NULL / uninitialized. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, H5_ATTR_UNUSED void *bg_buf) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC_NOERR + H5T_REF_LOG_DEBUG(""); + + HDmemset(dst_buf, 0, H5T_REF_MEM_SIZE); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_mem_setnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_mem_getsize + * + * Purpose: Retrieves the size of a memory based reference. + * + * Return: Non-negative on success/zero on failure + * + *------------------------------------------------------------------------- + */ +static size_t +H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, hbool_t *dst_copy) +{ + H5VL_object_t * vol_obj = NULL; /* VOL object for src ref's location */ + const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; + char * file_name_buf_dyn = + NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ + unsigned flags = 0; /* References flags */ + size_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Sanity check */ + HDassert(src_buf); + HDassert(src_size == H5T_REF_MEM_SIZE); + + if (NULL != dst_file) { + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + + /* Retrieve VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") + + /* Set external flag if referenced file is not destination file */ + if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal") + flags |= !files_equal ? H5R_IS_EXTERNAL : 0; + } + + /* Force re-calculating encoding size if any flags are set */ + if (flags || !src_ref->encode_size) { + char file_name_buf_static[256]; /* File name */ + ssize_t file_name_len; /* Size of file name buffer */ + + /* Pass the correct encoding version for the selection depending on the + * file libver bounds, this is later retrieved in H5S hyper encode */ + if (src_ref->type == (int8_t)H5R_DATASET_REGION2) { + hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(dst_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") + + /* Set the file's libver bounds if using the native VOL connector */ + if (is_native) { + H5F_t *dst_f; /* Native file struct */ + + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") + H5CX_set_libver_bounds(dst_f); + } /* end if */ + else + H5CX_set_libver_bounds(NULL); + } /* end if */ + + /* Get file name */ + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { + if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + } /* end if */ + + /* Determine encoding size */ + if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, NULL, + &ret_value, flags) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, 0, "unable to determine encoding size") + } /* end if */ + else { + /* Can do a direct copy and skip blob decoding */ + if (src_ref->type == (int8_t)H5R_OBJECT2) + *dst_copy = TRUE; + + /* Get cached encoding size */ + ret_value = src_ref->encode_size; + } /* end else */ + +done: + H5MM_xfree(file_name_buf_dyn); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_mem_getsize() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_mem_read + * + * Purpose: "Reads" the memory based reference into a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t H5_ATTR_UNUSED src_size, + H5VL_object_t *dst_file, void *dst_buf, size_t dst_size) +{ + H5VL_object_t * vol_obj; /* VOL object for src ref's location */ + const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + char file_name_buf_static[256] = {'\0'}; /* File name */ + char * file_name_buf_dyn = + NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ + ssize_t file_name_len; /* Size of file name buffer */ + unsigned flags = 0; /* References flags */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Sanity check */ + HDassert(src_buf); + HDassert(src_size == H5T_REF_MEM_SIZE); + HDassert(dst_buf); + HDassert(dst_size); + + /* Memory-to-memory conversion to support vlen conversion */ + if (NULL == dst_file) { + H5MM_memcpy(dst_buf, src_buf, dst_size); + HGOTO_DONE(ret_value); + } + + /* Retrieve VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") + + /* Set external flag if referenced file is not destination file */ + if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "can't check if files are equal") + flags |= !files_equal ? H5R_IS_EXTERNAL : 0; + + /* Pass the correct encoding version for the selection depending on the + * file libver bounds, this is later retrieved in H5S hyper encode */ + if (src_ref->type == (int8_t)H5R_DATASET_REGION2) { + hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(dst_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") + + /* Set the file's libver bounds if using the native VOL connector */ + if (is_native) { + H5F_t *dst_f; + + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") + H5CX_set_libver_bounds(dst_f); + } /* end if */ + else + H5CX_set_libver_bounds(NULL); + } /* end if */ + + /* Get file name (if external reference) */ + if (flags) { + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { + if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") + if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, + (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + } /* end if */ + } /* end if */ + + /* Encode reference */ + if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, + (unsigned char *)dst_buf, &dst_size, flags) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot encode reference") + +done: + H5MM_xfree(file_name_buf_dyn); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_mem_read() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_mem_write + * + * Purpose: "Writes" the memory reference from a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size, + void H5_ATTR_UNUSED *bg_buf) +{ + H5F_t * src_f = NULL; + hid_t file_id = H5I_INVALID_HID; + H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf; + H5R_ref_priv_t tmp_ref; /* Temporary reference to decode into */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Sanity check */ + HDassert(src_buf); + HDassert(src_size); + HDassert(dst_buf); + HDassert(dst_size == H5T_REF_MEM_SIZE); + HDcompile_assert(sizeof(*dst_ref) == sizeof(tmp_ref)); + + /* Memory-to-memory conversion to support vlen conversion */ + if (NULL == src_file) { + H5MM_memcpy(dst_buf, src_buf, src_size); + HGOTO_DONE(ret_value); + } + +#ifndef NDEBUG + if ((src_type == H5R_OBJECT1) || (src_type == H5R_DATASET_REGION1)) { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Make sure reference buffer is correctly initialized */ + HDmemset(&tmp_ref, 0, sizeof(tmp_ref)); + + switch (src_type) { + case H5R_OBJECT1: { + size_t token_size = H5F_SIZEOF_ADDR(src_f); + + if (H5R__create_object((const H5O_token_t *)src_buf, token_size, &tmp_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference") + } break; + + case H5R_DATASET_REGION1: { + const struct H5Tref_dsetreg *src_reg = (const struct H5Tref_dsetreg *)src_buf; + size_t token_size = H5F_SIZEOF_ADDR(src_f); + + if (H5R__create_region(&src_reg->token, token_size, src_reg->space, &tmp_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference") + + /* create_region creates its internal copy of the space */ + if (H5S_close(src_reg->space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace") + } break; + + case H5R_DATASET_REGION2: + /* Pass the correct encoding version for the selection depending on the + * file libver bounds, this is later retrieved in H5S hyper decode */ + H5CX_set_libver_bounds(src_f); + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case H5R_OBJECT2: + case H5R_ATTR: + /* Decode reference */ + if (H5R__decode((const unsigned char *)src_buf, &src_size, &tmp_ref) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Cannot decode reference") + break; + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + + /* If no filename set, this is not an external reference */ + if (NULL == H5R_REF_FILENAME(&tmp_ref)) { + /* TODO temporary hack to retrieve file object */ + if ((file_id = H5F_get_file_id(src_file, H5I_FILE, FALSE)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Attach loc ID to reference and hold reference to it, this is a + * user exposed reference so set app_ref to TRUE. */ + if (H5R__set_loc_id(&tmp_ref, file_id, TRUE, TRUE) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to attach location id to reference") + } /* end if */ + + /* Set output info */ + HDmemcpy(dst_ref, &tmp_ref, sizeof(tmp_ref)); + +done: + if ((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0)) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_mem_write() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_disk_isnull + * + * Purpose: Check if it's a NULL / uninitialized reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +{ + const uint8_t *p = (const uint8_t *)src_buf; + H5R_type_t ref_type; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Check parameters */ + HDassert(src_file); + HDassert(src_buf); + HDassert(isnull); + + /* Try to check encoded reference type */ + ref_type = (H5R_type_t)*p++; + if (ref_type) { + /* This is a valid reference */ + *isnull = FALSE; + } + else { + /* Skip the size / header */ + p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T; + + /* Check if blob ID is "nil" */ + if (H5VL_blob_specific(src_file, (void *)p, H5VL_BLOB_ISNULL, isnull) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_disk_isnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_disk_setnull + * + * Purpose: Set a reference as NULL / uninitialized. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) +{ + uint8_t *q = (uint8_t *)dst_buf; + uint8_t *p_bg = (uint8_t *)bg_buf; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(dst_file); + HDassert(dst_buf); + + /* TODO Should get rid of bg stuff */ + if (p_bg) { + /* Skip the size / header */ + p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + + /* Remove blob for old data */ + if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") + } /* end if */ + + /* Copy header manually so that it does not get encoded into the blob */ + HDmemset(q, 0, H5R_ENCODE_HEADER_SIZE); + q += H5R_ENCODE_HEADER_SIZE; + + /* Set the size */ + UINT32ENCODE(q, 0); + + /* Set blob ID to "nil" */ + if (H5VL_blob_specific(dst_file, q, H5VL_BLOB_SETNULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_disk_setnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_disk_getsize + * + * Purpose: Retrieves the length of a disk based reference. + * + * Return: Non-negative value (cannot fail) + * + *------------------------------------------------------------------------- + */ +static size_t +H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file, hbool_t *dst_copy) +{ + const uint8_t *p = (const uint8_t *)src_buf; + unsigned flags; + H5R_type_t ref_type; + size_t ret_value = 0; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_buf); + + /* Set reference type */ + ref_type = (H5R_type_t)*p++; + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid reference type") + + /* Set flags */ + flags = (unsigned)*p++; + + if (!(flags & H5R_IS_EXTERNAL) && (ref_type == H5R_OBJECT2)) { + /* Can do a direct copy and skip blob decoding */ + *dst_copy = TRUE; + + ret_value = src_size; + } /* end if */ + else { + /* Retrieve encoded data size */ + UINT32DECODE(p, ret_value); + + /* Add size of the header */ + ret_value += H5R_ENCODE_HEADER_SIZE; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_disk_getsize() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_disk_read + * + * Purpose: Reads the disk based reference into a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_NDEBUG_UNUSED src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size) +{ + const uint8_t *p = (const uint8_t *)src_buf; + uint8_t * q = (uint8_t *)dst_buf; + size_t blob_size = dst_size; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_file); + HDassert(src_buf); + HDassert(dst_buf); + HDassert(dst_size); + + /* Copy header manually */ + H5MM_memcpy(q, p, H5R_ENCODE_HEADER_SIZE); + p += H5R_ENCODE_HEADER_SIZE; + q += H5R_ENCODE_HEADER_SIZE; + blob_size -= H5R_ENCODE_HEADER_SIZE; + + /* Skip the size */ + p += H5_SIZEOF_UINT32_T; + HDassert(src_size > (H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T)); + + /* Retrieve blob */ + if (H5VL_blob_get(src_file, p, q, blob_size, NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_disk_read() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_disk_write + * + * Purpose: Writes the disk based reference from a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, + H5R_type_t H5_ATTR_UNUSED src_type, H5VL_object_t *dst_file, void *dst_buf, + size_t dst_size, void *bg_buf) +{ + const uint8_t *p = (const uint8_t *)src_buf; + uint8_t * q = (uint8_t *)dst_buf; + size_t buf_size_left = dst_size; + uint8_t * p_bg = (uint8_t *)bg_buf; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_buf); + HDassert(src_size); + HDassert(dst_file); + HDassert(dst_buf); + + /* TODO Should get rid of bg stuff */ + if (p_bg) { + size_t p_buf_size_left = dst_size; + + /* Skip the size / header */ + p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + HDassert(p_buf_size_left > (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE)); + p_buf_size_left -= (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + + /* Remove blob for old data */ + if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") + } /* end if */ + + /* Copy header manually so that it does not get encoded into the blob */ + H5MM_memcpy(q, p, H5R_ENCODE_HEADER_SIZE); + p += H5R_ENCODE_HEADER_SIZE; + q += H5R_ENCODE_HEADER_SIZE; + src_size -= H5R_ENCODE_HEADER_SIZE; + buf_size_left -= H5_SIZEOF_UINT32_T; + + /* Set the size */ + UINT32ENCODE(q, src_size); + HDassert(buf_size_left > H5_SIZEOF_UINT32_T); + buf_size_left -= H5_SIZEOF_UINT32_T; + + /* Store blob */ + if (H5VL_blob_put(dst_file, p, src_size, q, NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_disk_write() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_obj_disk_isnull + * + * Purpose: Check if it's a NULL / uninitialized reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +{ + H5F_t * src_f; + const uint8_t *p = (const uint8_t *)src_buf; + haddr_t addr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Check parameters */ + HDassert(src_file); + HDassert(src_buf); + HDassert(isnull); + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Get the object address */ + H5F_addr_decode(src_f, &p, &addr); + + /* Check if heap address is 'nil' */ + *isnull = (addr == 0) ? TRUE : FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_obj_disk_isnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_obj_disk_getsize + * + * Purpose: Retrieves the length of a disk based reference. + * + * Return: Non-negative value (cannot fail) + * + *------------------------------------------------------------------------- + */ +static size_t +H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, + hbool_t H5_ATTR_UNUSED *dst_copy) +{ + H5F_t *src_f; + size_t ret_value = 0; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_file); + HDassert(src_buf); + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") + + HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); + + ret_value = H5T_REF_OBJ_DISK_SIZE(src_f); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_obj_disk_getsize() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_obj_disk_read + * + * Purpose: Reads the disk based reference into a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) +{ + H5F_t *src_f; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_file); + HDassert(src_buf); + HDassert(dst_buf); + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); + HDassert(dst_size == H5F_SIZEOF_ADDR(src_f)); + + /* Get object address */ + if (H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size, (H5O_token_t *)dst_buf, + H5F_SIZEOF_ADDR(src_f)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_obj_disk_read() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_dsetreg_disk_isnull + * + * Purpose: Check if it's a NULL / uninitialized reference. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +{ + H5F_t * src_f; + const uint8_t *p = (const uint8_t *)src_buf; + haddr_t addr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + /* Check parameters */ + HDassert(src_file); + HDassert(src_buf); + HDassert(isnull); + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + /* Get the heap address */ + H5F_addr_decode(src_f, &p, &addr); + + /* Check if heap address is 'nil' */ + *isnull = (addr == 0) ? TRUE : FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_dsetreg_disk_isnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_dsetreg_disk_getsize + * + * Purpose: Retrieves the length of a disk based reference. + * + * Return: Non-negative value (cannot fail) + * + *------------------------------------------------------------------------- + */ +static size_t +H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void H5_ATTR_UNUSED *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, + hbool_t H5_ATTR_UNUSED *dst_copy) +{ + size_t ret_value = sizeof(struct H5Tref_dsetreg); + +#ifndef NDEBUG + FUNC_ENTER_STATIC +#else + FUNC_ENTER_STATIC_NOERR +#endif + H5T_REF_LOG_DEBUG(""); + + HDassert(src_buf); + +#ifndef NDEBUG + { + H5F_t * src_f; + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") + + HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); + } +#endif /* NDEBUG */ + +#ifndef NDEBUG +done: +#endif + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_dsetreg_disk_getsize() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_dsetreg_disk_read + * + * Purpose: Reads the disk based reference into a buffer + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, + size_t H5_ATTR_UNUSED dst_size) +{ + H5F_t * src_f; + struct H5Tref_dsetreg *dst_reg = (struct H5Tref_dsetreg *)dst_buf; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + H5T_REF_LOG_DEBUG(""); + + HDassert(src_file); + HDassert(src_buf); + HDassert(dst_buf); + HDassert(dst_size == sizeof(struct H5Tref_dsetreg)); + +#ifndef NDEBUG + { + hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ + + /* Check if using native VOL connector */ + if (H5VL_object_is_native(src_file, &is_native) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") + + /* Must use native VOL connector for this operation */ + HDassert(is_native); + } +#endif /* NDEBUG */ + + /* Retrieve file from VOL object */ + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") + + HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); + + /* Retrieve object address and space */ + if (H5R__decode_token_region_compat(src_f, (const unsigned char *)src_buf, &src_size, &dst_reg->token, + H5F_SIZEOF_ADDR(src_f), &dst_reg->space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_dsetreg_disk_read() */ + +/*------------------------------------------------------------------------- + * Function: H5T__ref_reclaim + * + * Purpose: Internal routine to free reference datatypes + * + * Return: Non-negative on success / Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__ref_reclaim(void *elem, const H5T_t *dt) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + H5T_REF_LOG_DEBUG(""); + + /* Sanity checks */ + HDassert(elem); + HDassert(dt && (dt->shared->type == H5T_REFERENCE)); + + if (dt->shared->u.atomic.u.r.opaque && H5R__destroy((H5R_ref_priv_t *)elem) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "cannot free reference") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__ref_reclaim() */ diff --git a/src/H5Tstrpad.c b/src/H5Tstrpad.c index 35de30b2d43..5937f74a53a 100644 --- a/src/H5Tstrpad.c +++ b/src/H5Tstrpad.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,16 +16,13 @@ * the datatype string padding for the H5T interface. */ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Tpkg.h" /* Datatypes */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Tpkg.h" /* Datatypes */ - - - /*------------------------------------------------------------------------- * Function: H5Tget_strpad * @@ -46,22 +43,22 @@ H5T_str_t H5Tget_strpad(hid_t type_id) { - H5T_t *dt = NULL; - H5T_str_t ret_value; + H5T_t * dt = NULL; + H5T_str_t ret_value; FUNC_ENTER_API(H5T_STR_ERROR) H5TRACE1("Tz", "i", type_id); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a datatype") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_STR_ERROR, "operation not defined for datatype class") /* result */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) ret_value = dt->shared->u.atomic.u.s.pad; else ret_value = dt->shared->u.vlen.pad; @@ -70,7 +67,6 @@ H5Tget_strpad(hid_t type_id) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Tset_strpad * @@ -99,26 +95,26 @@ H5Tget_strpad(hid_t type_id) herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) { - H5T_t *dt = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t *dt = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iTz", type_id, strpad); /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->shared->state) + if (H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (strpad < H5T_STR_NULLTERM || strpad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type") while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) - dt = dt->shared->parent; /*defer to parent*/ + dt = dt->shared->parent; /*defer to parent*/ if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt->shared)) + if (H5T_IS_FIXED_STRING(dt->shared)) dt->shared->u.atomic.u.s.pad = strpad; else dt->shared->u.vlen.pad = strpad; @@ -126,4 +122,3 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad) done: FUNC_LEAVE_API(ret_value) } - diff --git a/src/H5Tvisit.c b/src/H5Tvisit.c index 00c7d8fd0ed..7974d49890a 100644 --- a/src/H5Tvisit.c +++ b/src/H5Tvisit.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -33,53 +33,43 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ - +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Tpkg.h" /* Datatypes */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5T__visit * @@ -96,8 +86,8 @@ herr_t H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) { - hbool_t is_complex; /* Flag indicating current datatype is "complex" */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t is_complex; /* Flag indicating current datatype is "complex" */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -106,31 +96,30 @@ H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) HDassert(op); /* Check for complex datatype */ - is_complex = H5T_IS_COMPLEX(dt->shared->type); + is_complex = H5T_IS_COMPLEX(dt->shared->type); /* If the callback is to be made on the datatype first, do that */ - if(is_complex && (visit_flags & H5T_VISIT_COMPLEX_FIRST)) - if(op(dt, op_value) < 0) + if (is_complex && (visit_flags & H5T_VISIT_COMPLEX_FIRST)) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") /* Make callback for each member/child, if requested */ - switch(dt->shared->type) { - case H5T_COMPOUND: - { - unsigned u; /* Local index variable */ - - /* Visit each member of the compound datatype */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) - if(H5T__visit(dt->shared->u.compnd.memb[u].type, visit_flags, op, op_value) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit member datatype") - } /* end case */ - break; + switch (dt->shared->type) { + case H5T_COMPOUND: { + unsigned u; /* Local index variable */ + + /* Visit each member of the compound datatype */ + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) + if (H5T__visit(dt->shared->u.compnd.memb[u].type, visit_flags, op, op_value) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit member datatype") + } /* end case */ + break; case H5T_ARRAY: case H5T_VLEN: case H5T_ENUM: /* Visit parent type */ - if(H5T__visit(dt->shared->parent, visit_flags, op, op_value) < 0) + if (H5T__visit(dt->shared->parent, visit_flags, op, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "can't visit parent datatype") break; @@ -149,18 +138,17 @@ H5T__visit(H5T_t *dt, unsigned visit_flags, H5T_operator_t op, void *op_value) case H5T_REFERENCE: default: /* Visit "simple" datatypes here */ - if(visit_flags & H5T_VISIT_SIMPLE) - if(op(dt, op_value) < 0) + if (visit_flags & H5T_VISIT_SIMPLE) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") break; } /* end switch */ /* If the callback is to be made on the datatype last, do that */ - if(is_complex && (visit_flags & H5T_VISIT_COMPLEX_LAST)) - if(op(dt, op_value) < 0) + if (is_complex && (visit_flags & H5T_VISIT_COMPLEX_LAST)) + if (op(dt, op_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADITER, FAIL, "operator callback failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__visit() */ - diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index b1cb33695b7..0d412ba9c3a 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,85 +20,113 @@ /* Module Setup */ /****************/ -#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#include "H5Tmodule.h" /* This source code file is part of the H5T module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ /* Memory-based VL sequence callbacks */ -static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info); -static ssize_t H5T_vlen_seq_mem_getlen(const void *_vl); -static void * H5T_vlen_seq_mem_getptr(void *_vl); -static htri_t H5T_vlen_seq_mem_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_seq_mem_read(H5F_t *f, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_seq_mem_write(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_seq_mem_setnull(H5F_t *f, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_seq_getlen(H5VL_object_t *file, const void *_vl, size_t *len); +static void * H5T__vlen_mem_seq_getptr(void *_vl); +static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t *file, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_seq_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Memory-based VL string callbacks */ -static ssize_t H5T_vlen_str_mem_getlen(const void *_vl); -static void * H5T_vlen_str_mem_getptr(void *_vl); -static htri_t H5T_vlen_str_mem_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_str_mem_read(H5F_t *f, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_str_mem_write(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_str_mem_setnull(H5F_t *f, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t *file, const void *_vl, size_t *len); +static void * H5T__vlen_mem_str_getptr(void *_vl); +static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t *file, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_str_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Disk-based VL sequence (and string) callbacks */ -static ssize_t H5T_vlen_disk_getlen(const void *_vl); -static void * H5T_vlen_disk_getptr(void *_vl); -static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_disk_read(H5F_t *f, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_disk_write(H5F_t *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_disk_setnull(H5F_t *f, void *_vl, void *_bg); +static herr_t H5T__vlen_disk_getlen(H5VL_object_t *file, const void *_vl, size_t *len); +static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *_bg); +static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, + void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl); /*********************/ /* Public Variables */ /*********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ +/* Class for VL sequences in memory */ +static const H5T_vlen_class_t H5T_vlen_mem_seq_g = { + H5T__vlen_mem_seq_getlen, /* 'getlen' */ + H5T__vlen_mem_seq_getptr, /* 'getptr' */ + H5T__vlen_mem_seq_isnull, /* 'isnull' */ + H5T__vlen_mem_seq_setnull, /* 'setnull' */ + H5T__vlen_mem_seq_read, /* 'read' */ + H5T__vlen_mem_seq_write, /* 'write' */ + NULL /* 'delete' */ +}; + +/* Class for VL strings in memory */ +static const H5T_vlen_class_t H5T_vlen_mem_str_g = { + H5T__vlen_mem_str_getlen, /* 'getlen' */ + H5T__vlen_mem_str_getptr, /* 'getptr' */ + H5T__vlen_mem_str_isnull, /* 'isnull' */ + H5T__vlen_mem_str_setnull, /* 'setnull' */ + H5T__vlen_mem_str_read, /* 'read' */ + H5T__vlen_mem_str_write, /* 'write' */ + NULL /* 'delete' */ +}; + +/* Class for both VL strings and sequences in file */ +static const H5T_vlen_class_t H5T_vlen_disk_g = { + H5T__vlen_disk_getlen, /* 'getlen' */ + NULL, /* 'getptr' */ + H5T__vlen_disk_isnull, /* 'isnull' */ + H5T__vlen_disk_setnull, /* 'setnull' */ + H5T__vlen_disk_read, /* 'read' */ + H5T__vlen_disk_write, /* 'write' */ + H5T__vlen_disk_delete /* 'delete' */ +}; - /*------------------------------------------------------------------------- * Function: H5Tvlen_create * @@ -117,30 +145,29 @@ static herr_t H5T_vlen_disk_setnull(H5F_t *f, void *_vl, void *_bg); hid_t H5Tvlen_create(hid_t base_id) { - H5T_t *base = NULL; /*base datatype */ - H5T_t *dt = NULL; /*new datatype */ - hid_t ret_value; /*return value */ + H5T_t *base = NULL; /*base datatype */ + H5T_t *dt = NULL; /*new datatype */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", base_id); /* Check args */ - if(NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") /* Create up VL datatype */ - if((dt = H5T__vlen_create(base)) == NULL) + if ((dt = H5T__vlen_create(base)) == NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tvlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_create * @@ -159,8 +186,8 @@ H5Tvlen_create(hid_t base_id) H5T_t * H5T__vlen_create(const H5T_t *base) { - H5T_t *dt = NULL; /* New VL datatype */ - H5T_t *ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; /* New VL datatype */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -168,7 +195,7 @@ H5T__vlen_create(const H5T_t *base) HDassert(base); /* Build new type */ - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "memory allocation failed") dt->shared->type = H5T_VLEN; @@ -177,7 +204,7 @@ H5T__vlen_create(const H5T_t *base) * data, not point to the same VL sequences) */ dt->shared->force_conv = TRUE; - if(NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + if (NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy base datatype") /* Inherit encoding version from base type */ @@ -187,21 +214,20 @@ H5T__vlen_create(const H5T_t *base) dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE; /* Set up VL information */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set return value */ ret_value = dt; done: - if(!ret_value) - if(dt && H5T_close_real(dt) < 0) + if (!ret_value) + if (dt && H5T_close_real(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_set_loc * @@ -219,9 +245,10 @@ H5T__vlen_create(const H5T_t *base) *------------------------------------------------------------------------- */ htri_t -H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) +H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) { - htri_t ret_value = FALSE; /* Indicate success, but no location change */ + H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; + htri_t ret_value = FALSE; /* Indicate success, but no location change */ FUNC_ENTER_PACKAGE @@ -230,75 +257,80 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if(loc != dt->shared->u.vlen.loc || f != dt->shared->u.vlen.f) { - switch(loc) { - case H5T_LOC_MEMORY: /* Memory based VL datatype */ - HDassert(NULL == f); + if (loc != dt->shared->u.vlen.loc || file != dt->shared->u.vlen.file) { + switch (loc) { + case H5T_LOC_MEMORY: /* Memory based VL datatype */ + HDassert(NULL == file); /* Mark this type as being stored in memory */ dt->shared->u.vlen.loc = H5T_LOC_MEMORY; - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { /* Size in memory, disk size is different */ dt->shared->size = sizeof(hvl_t); /* Set up the function pointers to access the VL sequence in memory */ - dt->shared->u.vlen.getlen = H5T_vlen_seq_mem_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_seq_mem_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_seq_mem_isnull; - dt->shared->u.vlen.read = H5T_vlen_seq_mem_read; - dt->shared->u.vlen.write = H5T_vlen_seq_mem_write; - dt->shared->u.vlen.setnull = H5T_vlen_seq_mem_setnull; + dt->shared->u.vlen.cls = &H5T_vlen_mem_seq_g; } /* end if */ - else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Size in memory, disk size is different */ dt->shared->size = sizeof(char *); /* Set up the function pointers to access the VL string in memory */ - dt->shared->u.vlen.getlen = H5T_vlen_str_mem_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_str_mem_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_str_mem_isnull; - dt->shared->u.vlen.read = H5T_vlen_str_mem_read; - dt->shared->u.vlen.write = H5T_vlen_str_mem_write; - dt->shared->u.vlen.setnull = H5T_vlen_str_mem_setnull; + dt->shared->u.vlen.cls = &H5T_vlen_mem_str_g; } /* end else-if */ else HDassert(0 && "Invalid VL type"); + /* Release owned file */ + if (dt->shared->owned_vol_obj) { + if (H5VL_free_object(dt->shared->owned_vol_obj) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") + dt->shared->owned_vol_obj = NULL; + } /* end if */ + /* Reset file pointer (since this VL is in memory) */ - dt->shared->u.vlen.f = NULL; + dt->shared->u.vlen.file = NULL; break; - case H5T_LOC_DISK: /* Disk based VL datatype */ - HDassert(f); + case H5T_LOC_DISK: /* Disk based VL datatype */ + HDassert(file); /* Mark this type as being stored on disk */ dt->shared->u.vlen.loc = H5T_LOC_DISK; - /* - * Size of element on disk is 4 bytes for the length, plus the size - * of an address in this file, plus 4 bytes for the size of a heap - * ID. Memory size is different - */ - dt->shared->size = 4 + (size_t)H5F_SIZEOF_ADDR(f) + 4; + /* Get container info */ + if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &cont_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") + + /* The datatype size is equal to 4 bytes for the sequence length + * plus the size of a blob id */ + dt->shared->size = 4 + cont_info.blob_id_size; /* Set up the function pointers to access the VL information on disk */ /* VL sequences and VL strings are stored identically on disk, so use the same functions */ - dt->shared->u.vlen.getlen = H5T_vlen_disk_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_disk_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_disk_isnull; - dt->shared->u.vlen.read = H5T_vlen_disk_read; - dt->shared->u.vlen.write = H5T_vlen_disk_write; - dt->shared->u.vlen.setnull = H5T_vlen_disk_setnull; + dt->shared->u.vlen.cls = &H5T_vlen_disk_g; /* Set file ID (since this VL is on disk) */ - dt->shared->u.vlen.f = f; + dt->shared->u.vlen.file = file; + + /* dt now owns a reference to file */ + if (H5T_own_vol_obj(dt, file) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") break; case H5T_LOC_BADLOC: /* Allow undefined location. In H5Odtype.c, H5O_dtype_decode sets undefined * location for VL type and leaves it for the caller to decide. */ + dt->shared->u.vlen.loc = H5T_LOC_BADLOC; + + /* Reset the function pointers to access the VL information */ + dt->shared->u.vlen.cls = NULL; + + /* Reset file pointer */ + dt->shared->u.vlen.file = NULL; break; case H5T_LOC_MAXLOC: @@ -315,9 +347,8 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_set_loc() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_getlen + * Function: H5T__vlen_mem_seq_getlen * * Purpose: Retrieves the length of a memory based VL element. * @@ -328,33 +359,34 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) * *------------------------------------------------------------------------- */ -static ssize_t -H5T_vlen_seq_mem_getlen(const void *_vl) +static herr_t +H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - /* Check parameters, return result */ -#ifdef H5_NO_ALIGNMENT_RESTRICTIONS - HDassert(vl); + /* Check parameter */ + HDassert(_vl); + HDassert(len); - FUNC_LEAVE_NOAPI((ssize_t)vl->len) +#ifdef H5_NO_ALIGNMENT_RESTRICTIONS + *len = vl->len; #else - HDassert(_vl); H5MM_memcpy(&vl, _vl, sizeof(hvl_t)); - FUNC_LEAVE_NOAPI((ssize_t)vl.len) + *len = vl.len; #endif -} /* end H5T_vlen_seq_mem_getlen() */ - + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T__vlen_mem_seq_getlen() */ + /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_getptr + * Function: H5T__vlen_mem_seq_getptr * * Purpose: Retrieves the pointer for a memory based VL element. * @@ -366,15 +398,15 @@ H5T_vlen_seq_mem_getlen(const void *_vl) *------------------------------------------------------------------------- */ static void * -H5T_vlen_seq_mem_getptr(void *_vl) +H5T__vlen_mem_seq_getptr(void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check parameters, return result */ #ifdef H5_NO_ALIGNMENT_RESTRICTIONS @@ -387,48 +419,79 @@ H5T_vlen_seq_mem_getptr(void *_vl) FUNC_LEAVE_NOAPI(vl.p) #endif -} /* end H5T_vlen_seq_mem_getptr() */ +} /* end H5T__vlen_mem_seq_getptr() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_isnull + * Function: H5T__vlen_mem_seq_isnull * * Purpose: Checks if a memory sequence is the "null" sequence * - * Return: TRUE/FALSE on success/Negative on failure + * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * *------------------------------------------------------------------------- */ -static htri_t -H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) +static herr_t +H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - /* check parameters, return result */ -#ifdef H5_NO_ALIGNMENT_RESTRICTIONS - HDassert(vl); + /* Check parameters */ + HDassert(_vl); - FUNC_LEAVE_NOAPI((vl->len==0 || vl->p==NULL) ? TRUE : FALSE) +#ifdef H5_NO_ALIGNMENT_RESTRICTIONS + *isnull = ((vl->len == 0 || vl->p == NULL) ? TRUE : FALSE); #else - HDassert(_vl); H5MM_memcpy(&vl, _vl, sizeof(hvl_t)); - FUNC_LEAVE_NOAPI((vl.len==0 || vl.p==NULL) ? TRUE : FALSE) + *isnull = ((vl.len == 0 || vl.p == NULL) ? TRUE : FALSE); #endif -} /* end H5T_vlen_seq_mem_isnull() */ - + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T__vlen_mem_seq_isnull() */ + +/*------------------------------------------------------------------------- + * Function: H5T__vlen_mem_seq_setnull + * + * Purpose: Sets a VL info object in memory to the "nil" value + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Saturday, November 8, 2003 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) +{ + hvl_t vl; /* Temporary hvl_t to use during operation */ + + FUNC_ENTER_STATIC_NOERR + + /* check parameters */ + HDassert(_vl); + + /* Set the "nil" hvl_t */ + vl.len = 0; + vl.p = NULL; + + /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ + H5MM_memcpy(_vl, &vl, sizeof(hvl_t)); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T__vlen_mem_seq_setnull() */ + /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_read + * Function: H5T__vlen_mem_seq_read * * Purpose: "Reads" the memory based VL sequence into a buffer * @@ -440,15 +503,15 @@ H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) +H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check parameters, copy data */ HDassert(buf); @@ -465,11 +528,10 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) #endif FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_seq_mem_read() */ +} /* end H5T__vlen_mem_seq_read() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_write + * Function: H5T__vlen_mem_seq_write * * Purpose: "Writes" the memory based VL sequence from a buffer * @@ -481,28 +543,30 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) +H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - hvl_t vl; /* Temporary hvl_t to use during operation */ - herr_t ret_value = SUCCEED; /* Return value */ + hvl_t vl; /* Temporary hvl_t to use during operation */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check parameters */ HDassert(_vl); HDassert(buf); - if(seq_len) { - size_t len = seq_len * base_size; /* Sequence size */ + if (seq_len) { + size_t len = seq_len * base_size; /* Sequence size */ /* Use the user's memory allocation routine is one is defined */ - if(vl_alloc_info->alloc_func != NULL) { - if(NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "application memory allocation routine failed for VL data") - } /* end if */ - else /* Default to system malloc */ - if(NULL == (vl.p = HDmalloc(len))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "application memory allocation routine failed for VL data") + } /* end if */ + else /* Default to system malloc */ + if (NULL == (vl.p = HDmalloc(len))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") /* Copy the data into the newly allocated buffer */ H5MM_memcpy(vl.p, buf, len); @@ -518,64 +582,65 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_seq_mem_write() */ +} /* end H5T__vlen_mem_seq_write() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_seq_mem_setnull + * Function: H5T__vlen_mem_str_getlen * - * Purpose: Sets a VL info object in memory to the "nil" value + * Purpose: Retrieves the length of a memory based VL string. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * Saturday, November 8, 2003 + * Wednesday, June 2, 1999 * *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, void *_vl, void H5_ATTR_UNUSED *_bg) +H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len) { - hvl_t vl; /* Temporary hvl_t to use during operation */ +#ifdef H5_NO_ALIGNMENT_RESTRICTIONS + const char *s = *(const char *const *)_vl; /* Pointer to the user's string information */ +#else + const char *s = NULL; /* Pointer to the user's string information */ +#endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check parameters */ HDassert(_vl); - /* Set the "nil" hvl_t */ - vl.len = 0; - vl.p = NULL; +#ifndef H5_NO_ALIGNMENT_RESTRICTIONS + H5MM_memcpy(&s, _vl, sizeof(char *)); +#endif - /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - H5MM_memcpy(_vl, &vl, sizeof(hvl_t)); + *len = HDstrlen(s); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_seq_mem_setnull() */ +} /* end H5T__vlen_mem_str_getlen() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_getlen + * Function: H5T__vlen_mem_str_getptr * - * Purpose: Retrieves the length of a memory based VL string. + * Purpose: Retrieves the pointer for a memory based VL string. * - * Return: Non-negative on success/Negative on failure + * Return: Non-NULL on success/NULL on failure * * Programmer: Quincey Koziol - * Wednesday, June 2, 1999 + * Saturday, June 12, 2004 * *------------------------------------------------------------------------- */ -static ssize_t -H5T_vlen_str_mem_getlen(const void *_vl) +static void * +H5T__vlen_mem_str_getptr(void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const char *s = *(const char * const *)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - const char *s; /* Pointer to the user's string information */ + char * s = NULL; /* Pointer to the user's string information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check parameters */ #ifdef H5_NO_ALIGNMENT_RESTRICTIONS @@ -585,78 +650,68 @@ H5T_vlen_str_mem_getlen(const void *_vl) H5MM_memcpy(&s, _vl, sizeof(char *)); #endif - FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(s)) -} /* end H5T_vlen_str_mem_getlen() */ + FUNC_LEAVE_NOAPI(s) +} /* end H5T__vlen_mem_str_getptr() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_getptr + * Function: H5T__vlen_mem_str_isnull * - * Purpose: Retrieves the pointer for a memory based VL string. + * Purpose: Checks if a memory string is a NULL pointer * - * Return: Non-NULL on success/NULL on failure + * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Saturday, June 12, 2004 + * Saturday, November 8, 2003 * *------------------------------------------------------------------------- */ -static void * -H5T_vlen_str_mem_getptr(void *_vl) +static herr_t +H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s = NULL; /* Pointer to the user's string information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - /* check parameters */ -#ifdef H5_NO_ALIGNMENT_RESTRICTIONS - HDassert(s); -#else - HDassert(_vl); +#ifndef H5_NO_ALIGNMENT_RESTRICTIONS H5MM_memcpy(&s, _vl, sizeof(char *)); #endif - FUNC_LEAVE_NOAPI(s) -} /* end H5T_vlen_str_mem_getptr() */ + *isnull = (s == NULL ? TRUE : FALSE); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T__vlen_mem_str_isnull() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_isnull + * Function: H5T__vlen_mem_str_setnull * - * Purpose: Checks if a memory string is a NULL pointer + * Purpose: Sets a VL info object in memory to the "null" value * - * Return: TRUE/FALSE on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * *------------------------------------------------------------------------- */ -static htri_t -H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) +static herr_t +H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) { -#ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ -#else - char *s; /* Pointer to the user's string information */ -#endif + char *t = NULL; /* Pointer to temporary buffer allocated */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR -#ifndef H5_NO_ALIGNMENT_RESTRICTIONS - H5MM_memcpy(&s, _vl, sizeof(char *)); -#endif + /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ + H5MM_memcpy(_vl, &t, sizeof(char *)); - FUNC_LEAVE_NOAPI(s==NULL ? TRUE : FALSE) -} /* end H5T_vlen_str_mem_isnull() */ + FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */ +} /* end H5T__vlen_mem_str_setnull() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_read + * Function: H5T__vlen_mem_str_read * * Purpose: "Reads" the memory based VL string into a buffer * @@ -668,17 +723,17 @@ H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) +H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s; /* Pointer to the user's string information */ #endif - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR - if(len > 0) { + if (len > 0) { /* check parameters */ HDassert(buf); #ifdef H5_NO_ALIGNMENT_RESTRICTIONS @@ -692,11 +747,10 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_str_mem_read() */ +} /* end H5T__vlen_mem_str_read() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_write + * Function: H5T__vlen_mem_str_write * * Purpose: "Writes" the memory based VL string from a buffer * @@ -708,27 +762,28 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, void *_vl, void *buf, size_t len) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_alloc_info, - void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, - size_t base_size) +H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - char *t; /* Pointer to temporary buffer allocated */ - size_t len; /* Maximum length of the string to copy */ - herr_t ret_value=SUCCEED; /* Return value */ + char * t; /* Pointer to temporary buffer allocated */ + size_t len; /* Maximum length of the string to copy */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check parameters */ HDassert(buf); /* Use the user's memory allocation routine if one is defined */ - if(vl_alloc_info->alloc_func != NULL) { - if(NULL == (t = (char *)(vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "application memory allocation routine failed for VL data") - } /* end if */ - else /* Default to system malloc */ - if(NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == + (t = (char *)(vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, + "application memory allocation routine failed for VL data") + } /* end if */ + else /* Default to system malloc */ + if (NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data") /* 'write' the string into the buffer, with memcpy() */ len = (seq_len * base_size); @@ -740,37 +795,10 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, const H5T_vlen_alloc_info_t *vl_ done: FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */ -} /* end H5T_vlen_str_mem_write() */ +} /* end H5T__vlen_mem_str_write() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_str_mem_setnull - * - * Purpose: Sets a VL info object in memory to the "null" value - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Saturday, November 8, 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, void *_vl, void H5_ATTR_UNUSED *_bg) -{ - char *t=NULL; /* Pointer to temporary buffer allocated */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - H5MM_memcpy(_vl,&t,sizeof(char *)); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_str_mem_setnull() */ - - -/*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_getlen + * Function: H5T__vlen_disk_getlen * * Purpose: Retrieves the length of a disk based VL element. * @@ -781,82 +809,102 @@ H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, void *_vl, void H5_ATTR_UNUSED * *------------------------------------------------------------------------- */ -static ssize_t -H5T_vlen_disk_getlen(const void *_vl) +static herr_t +H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *seq_len) { - const uint8_t *vl=(const uint8_t *)_vl; /* Pointer to the disk VL information */ - size_t seq_len = 0; /* Sequence length */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check parameters */ HDassert(vl); + HDassert(seq_len); - UINT32DECODE(vl, seq_len); + /* Get length of sequence (different from blob size) */ + UINT32DECODE(vl, *seq_len); - FUNC_LEAVE_NOAPI((ssize_t)seq_len) -} /* end H5T_vlen_disk_getlen() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T__vlen_disk_getlen() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_getptr + * Function: H5T__vlen_disk_isnull * - * Purpose: Retrieves the pointer to a disk based VL element. + * Purpose: Checks if a disk VL info object is the "nil" object * - * Return: Non-NULL on success/NULL on failure + * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Saturday, June 12, 2004 + * Saturday, November 8, 2003 * *------------------------------------------------------------------------- */ -static void * -H5T_vlen_disk_getptr(void H5_ATTR_UNUSED *vl) +static herr_t +H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC /* Check parameters */ + HDassert(file); HDassert(vl); + HDassert(isnull); - FUNC_LEAVE_NOAPI(NULL) -} /* end H5T_vlen_disk_getptr() */ + /* Skip the sequence's length */ + vl += 4; + + /* Check if blob ID is "nil" */ + if (H5VL_blob_specific(file, vl, H5VL_BLOB_ISNULL, isnull) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__vlen_disk_isnull() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_isnull + * Function: H5T__vlen_disk_setnull * - * Purpose: Checks if a disk VL info object is the "nil" object + * Purpose: Sets a VL info object on disk to the "nil" value * - * Return: TRUE/FALSE on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, November 8, 2003 * *------------------------------------------------------------------------- */ -static htri_t -H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) +static herr_t +H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) { - uint8_t *vl = (uint8_t *)_vl; /* Pointer to the disk VL information */ - haddr_t addr; /* Sequence's heap address */ + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC /* check parameters */ + HDassert(file); HDassert(vl); - /* Skip the sequence's length */ - vl += 4; + /* Free heap object for old data */ + if (bg != NULL) + /* Delete sequence in destination location */ + if (H5T__vlen_disk_delete(file, bg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") - /* Get the heap address */ - H5F_addr_decode(f, (const uint8_t **)&vl, &addr); + /* Set the length of the sequence */ + UINT32ENCODE(vl, 0); - FUNC_LEAVE_NOAPI(addr == 0 ? TRUE : FALSE) -} /* end H5T_vlen_disk_isnull() */ + /* Set blob ID to "nil" */ + if (H5VL_blob_specific(file, vl, H5VL_BLOB_SETNULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__vlen_disk_setnull() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_read + * Function: H5T__vlen_disk_read * * Purpose: Reads the disk based VL element into a buffer * @@ -868,39 +916,31 @@ H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_disk_read(H5F_t *f, void *_vl, void *buf, size_t H5_ATTR_UNUSED len) +H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) { - uint8_t *vl=(uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - H5HG_t hobjid; - herr_t ret_value=SUCCEED; /* Return value */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check parameters */ + HDassert(file); HDassert(vl); HDassert(buf); - HDassert(f); /* Skip the length of the sequence */ vl += 4; - /* Get the heap information */ - H5F_addr_decode(f, (const uint8_t **)&vl, &(hobjid.addr)); - UINT32DECODE(vl, hobjid.idx); - - /* Check if this sequence actually has any data */ - if(hobjid.addr > 0) - /* Read the VL information from disk */ - if(NULL == H5HG_read(f, &hobjid, buf, NULL)) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read VL information") + /* Retrieve blob */ + if (H5VL_blob_get(file, vl, buf, len, NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_read() */ +} /* end H5T__vlen_disk_read() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_write + * Function: H5T__vlen_disk_write * * Purpose: Writes the disk based VL element from a buffer * @@ -912,210 +952,172 @@ H5T_vlen_disk_read(H5F_t *f, void *_vl, void *buf, size_t H5_ATTR_UNUSED len) *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_disk_write(H5F_t *f, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, - void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) +H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { - uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ - uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ - H5HG_t hobjid; /* New VL sequence's heap ID */ - size_t len; /* Size of new sequence on disk (in bytes) */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + const uint8_t *bg = (const uint8_t *)_bg; /* Pointer to the old data hvl_t */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* check parameters */ HDassert(vl); HDassert(seq_len == 0 || buf); - HDassert(f); + HDassert(file); - /* Free heap object for old data. */ - if(bg!=NULL) { - H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ - - /* Skip the length of the sequence and heap object ID from background data. */ - bg += 4; - - /* Get heap information */ - H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); - UINT32DECODE(bg, bg_hobjid.idx); - - /* Free heap object for old data */ - if(bg_hobjid.addr > 0) - /* Free heap object */ - if(H5HG_remove(f, &bg_hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") - } /* end if */ + /* Free heap object for old data, if non-NULL */ + if (bg != NULL) + if (H5T__vlen_disk_delete(file, bg) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); - /* Write the VL information to disk (allocates space also) */ - len = (seq_len*base_size); - if(H5HG_insert(f, len, buf, &hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information") - - /* Encode the heap information */ - H5F_addr_encode(f, &vl, hobjid.addr); - UINT32ENCODE(vl, hobjid.idx); + /* Store blob */ + if (H5VL_blob_put(file, buf, (seq_len * base_size), vl, NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_write() */ +} /* end H5T__vlen_disk_write() */ - /*------------------------------------------------------------------------- - * Function: H5T_vlen_disk_setnull + * Function: H5T__vlen_disk_delete * - * Purpose: Sets a VL info object on disk to the "nil" value + * Purpose: Deletes a disk-based VL element * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Saturday, November 8, 2003 + * Friday, August 15, 2019 * *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_disk_setnull(H5F_t *f, void *_vl, void *_bg) +H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) { - uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ - uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ - uint32_t seq_len = 0; /* Sequence length */ - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check parameters */ - HDassert(f); - HDassert(vl); - - /* Free heap object for old data. */ - if(bg != NULL) { - H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ + HDassert(file); - /* Skip the length of the sequence and heap object ID from background data. */ - bg += 4; + /* Free heap object for old data */ + if (vl != NULL) { + size_t seq_len; /* VL sequence's length */ - /* Get heap information */ - H5F_addr_decode(f, (const uint8_t **)&bg, &(bg_hobjid.addr)); - UINT32DECODE(bg, bg_hobjid.idx); + /* Get length of sequence */ + UINT32DECODE(vl, seq_len); - /* Free heap object for old data */ - if(bg_hobjid.addr > 0) { - /* Free heap object */ - if(H5HG_remove(f, &bg_hobjid) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") - } /* end if */ + /* Delete object, if length > 0 */ + if (seq_len > 0) + if (H5VL_blob_specific(file, (void *)vl, H5VL_BLOB_DELETE) < 0) /* Casting away 'const' OK -QAK */ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ - /* Set the length of the sequence */ - UINT32ENCODE(vl, seq_len); - - /* Encode the "nil" heap pointer information */ - H5F_addr_encode(f, &vl, (haddr_t)0); - UINT32ENCODE(vl, 0); - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_setnull() */ - - -/*-------------------------------------------------------------------------- - NAME - H5T_vlen_reclaim_recurse - PURPOSE - Internal recursive routine to free VL datatypes - USAGE - herr_t H5T_vlen_reclaim_recurse(elem,dt) - void *elem; IN/OUT: Pointer to the dataset element - H5T_t *dt; IN: Datatype of dataset element - - RETURNS - SUCCEED/FAIL - DESCRIPTION - Frees any dynamic memory used by VL datatypes in the current dataset - element. Performs a recursive depth-first traversal of all compound - datatypes to free all VL datatype information allocated by any field. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info) +} /* end H5T__vlen_disk_delete() */ + +/*------------------------------------------------------------------------- + * Function: H5T__vlen_reclaim + * + * Purpose: Internal recursive routine to free VL datatypes + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * Friday, August 15, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5T__vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + H5MM_free_t free_func; /* Free function */ + void * free_info; /* Free info */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) + /* Sanity checks */ HDassert(elem); HDassert(dt); + HDassert(alloc_info); + + free_func = alloc_info->free_func; + free_info = alloc_info->free_info; /* Check the datatype of this element */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_ARRAY: /* Recurse on each element, if the array's base type is array, VL, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - for(u = 0; u < dt->shared->u.array.nelem; u++) { + for (u = 0; u < dt->shared->u.array.nelem; u++) { off = ((uint8_t *)elem) + u * (dt->shared->parent->shared->size); - if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free array element") } /* end for */ - } /* end if */ + } /* end if */ break; case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) { /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ off = ((uint8_t *)elem) + dt->shared->u.compnd.memb[u].offset; - if(H5T_vlen_reclaim_recurse(off, dt->shared->u.compnd.memb[u].type, free_func, free_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->u.compnd.memb[u].type, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free compound field") } /* end if */ - } /* end for */ + } /* end for */ break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { - hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ - if(vl->len!=0) { + if (vl->len != 0) { /* Recurse if it's VL, array, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ - while(vl->len > 0) { + while (vl->len > 0) { off = ((uint8_t *)vl->p) + (vl->len - 1) * dt->shared->parent->shared->size; - if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) + if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free VL element") vl->len--; } /* end while */ - } /* end if */ + } /* end if */ /* Free the VL sequence */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(vl->p, free_info); else HDfree(vl->p); } /* end if */ - } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + } + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(*(char **)elem, free_info); else HDfree(*(char **)elem); - } else { + } + else { HDassert(0 && "Invalid VL type"); } /* end else */ break; @@ -1127,11 +1129,11 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi case H5T_STRING: case H5T_BITFIELD: case H5T_OPAQUE: - case H5T_REFERENCE: case H5T_ENUM: break; /* Should never have these values */ + case H5T_REFERENCE: case H5T_NO_CLASS: case H5T_NCLASSES: default: @@ -1142,65 +1144,17 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_reclaim_recurse() */ - - -/*-------------------------------------------------------------------------- - NAME - H5T_vlen_reclaim - PURPOSE - Default method to reclaim any VL data for a buffer element - USAGE - herr_t H5T_vlen_reclaim(elem,type_id,ndim,point,op_data) - void *elem; IN/OUT: Pointer to the dataset element - hid_t type_id; IN: Datatype of dataset element - unsigned ndim; IN: Number of dimensions in dataspace - hsize_t *point; IN: Coordinate location of element in dataspace - void *op_data IN: Operator data - - RETURNS - SUCCEED/FAIL - DESCRIPTION - Frees any dynamic memory used by VL datatypes in the current dataset - element. Recursively descends compound datatypes to free all VL datatype - information allocated by any field. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, - const hsize_t H5_ATTR_UNUSED *point, void *op_data) -{ - H5T_vlen_alloc_info_t *vl_alloc_info = (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */ - H5T_t *dt; - herr_t ret_value = SUCCEED; /* Return value */ +} /* end H5T__vlen_reclaim() */ - FUNC_ENTER_NOAPI(FAIL) - - HDassert(elem); - HDassert(vl_alloc_info); - HDassert(H5I_DATATYPE == H5I_get_type(type_id)); - - /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */ - if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_reclaim() */ - - /*------------------------------------------------------------------------- * Function: H5T_vlen_reclaim_elmt * * Purpose: Alternative method to reclaim any VL data for a buffer element. * + * Use this function when the datatype is already available, but + * the allocation info is needed from the context before jumping + * into recursion. + * * Return: Non-negative on success/Negative on failure * * Programmer: Mike McGreevy @@ -1211,8 +1165,8 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt) { - H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ - herr_t ret_value = SUCCEED; /* return value */ + H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ + herr_t ret_value = SUCCEED; /* return value */ HDassert(dt); HDassert(elem); @@ -1220,14 +1174,13 @@ H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt) FUNC_ENTER_NOAPI(FAIL) /* Get VL allocation info */ - if(H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) + if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Recurse on buffer to free dynamic fields */ - if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info.free_func, vl_alloc_info.free_info) < 0) + if (H5T__vlen_reclaim(elem, dt, &vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5T_vlen_reclaim_elmt */ - +} /* H5T_vlen_reclaim_elmt() */ diff --git a/src/H5UC.c b/src/H5UC.c index dd615391af7..c1c8b5ba98a 100644 --- a/src/H5UC.c +++ b/src/H5UC.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,17 +21,15 @@ * */ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5UCprivate.h" /* Reference-counted buffers */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5UCprivate.h" /* Reference-counted buffers */ /* Private typedefs & structs */ /* Declare a free list to manage the H5UC_t struct */ H5FL_DEFINE_STATIC(H5UC_t); - /*-------------------------------------------------------------------------- NAME H5UC_create @@ -56,7 +54,7 @@ H5FL_DEFINE_STATIC(H5UC_t); H5UC_t * H5UC_create(void *o, H5UC_free_func_t free_func) { - H5UC_t *ret_value; /* Return value */ + H5UC_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -65,19 +63,18 @@ H5UC_create(void *o, H5UC_free_func_t free_func) HDassert(free_func); /* Allocate ref-counted string structure */ - if(NULL == (ret_value = H5FL_MALLOC(H5UC_t))) - HGOTO_ERROR(H5E_RS,H5E_NOSPACE,NULL,"memory allocation failed") + if (NULL == (ret_value = H5FL_MALLOC(H5UC_t))) + HGOTO_ERROR(H5E_RS, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the internal fields */ - ret_value->o = o; - ret_value->n = 1; + ret_value->o = o; + ret_value->n = 1; ret_value->free_func = free_func; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5UC_create() */ - /*-------------------------------------------------------------------------- NAME H5UC_decr @@ -100,7 +97,7 @@ H5UC_create(void *o, H5UC_free_func_t free_func) herr_t H5UC_decr(H5UC_t *rc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -114,8 +111,8 @@ H5UC_decr(H5UC_t *rc) rc->n--; /* Check if we should delete this object now */ - if(rc->n == 0) { - if((rc->free_func)(rc->o) < 0) { + if (rc->n == 0) { + if ((rc->free_func)(rc->o) < 0) { rc = H5FL_FREE(H5UC_t, rc); HGOTO_ERROR(H5E_RS, H5E_CANTFREE, FAIL, "memory release failed") } /* end if */ @@ -125,4 +122,3 @@ H5UC_decr(H5UC_t *rc) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5UC_decr() */ - diff --git a/src/H5UCprivate.h b/src/H5UCprivate.h index e4916df2b09..9f4f15a1e46 100644 --- a/src/H5UCprivate.h +++ b/src/H5UCprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,8 +17,8 @@ * conflicting requirement for the use of H5RC. */ -#ifndef _H5UCprivate_H -#define _H5UCprivate_H +#ifndef H5UCprivate_H +#define H5UCprivate_H /**************************************/ /* Public headers needed by this file */ @@ -41,24 +41,22 @@ typedef herr_t (*H5UC_free_func_t)(void *o); /* Typedef for reference counted objects */ typedef struct H5UC_t { - void *o; /* Object to be reference counted */ - size_t n; /* Reference count of number of pointers sharing object */ + void * o; /* Object to be reference counted */ + size_t n; /* Reference count of number of pointers sharing object */ H5UC_free_func_t free_func; /* Function to free object */ } H5UC_t; /**********/ /* Macros */ /**********/ -#define H5UC_INC(rc) ((rc)->n++) -#define H5UC_DEC(rc) (H5UC_decr(rc)) -#define H5UC_GET_OBJ(rc) ((rc)->o) +#define H5UC_INC(rc) ((rc)->n++) +#define H5UC_DEC(rc) (H5UC_decr(rc)) +#define H5UC_GET_OBJ(rc) ((rc)->o) /********************/ /* Private routines */ /********************/ H5_DLL H5UC_t *H5UC_create(void *s, H5UC_free_func_t free_func); -H5_DLL herr_t H5UC_decr(H5UC_t *rc); - -#endif /* _H5RSprivate_H */ - +H5_DLL herr_t H5UC_decr(H5UC_t *rc); +#endif /* H5UCprivate_H */ diff --git a/src/H5VL.c b/src/H5VL.c new file mode 100644 index 00000000000..f65d1490d35 --- /dev/null +++ b/src/H5VL.c @@ -0,0 +1,911 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/* VOL connectors */ +#include "H5VLnative.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5VLregister_connector + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * VIPL_ID is a VOL initialization property list which must be + * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT). + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "*xi", cls, vipl_id); + + /* Check VOL initialization property list */ + if (H5P_DEFAULT == vipl_id) + vipl_id = H5P_VOL_INITIALIZE_DEFAULT; + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + + /* Register connector */ + if ((ret_value = H5VL__register_connector_by_class(cls, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister_connector() */ + +/*------------------------------------------------------------------------- + * Function: H5VLregister_connector_by_name + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * VIPL_ID is a VOL initialization property list which must be + * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT). + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_connector_by_name(const char *name, hid_t vipl_id) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "*si", name, vipl_id); + + /* Check arguments */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null VOL connector name is disallowed") + if (0 == HDstrlen(name)) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "zero-length VOL connector name is disallowed") + + /* Check VOL initialization property list */ + if (H5P_DEFAULT == vipl_id) + vipl_id = H5P_VOL_INITIALIZE_DEFAULT; + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + + /* Register connector */ + if ((ret_value = H5VL__register_connector_by_name(name, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister_connector_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VLregister_connector_by_value + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * VIPL_ID is a VOL initialization property list which must be + * created with H5Pcreate(H5P_VOL_INITIALIZE) (or H5P_DEFAULT). + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "VCi", value, vipl_id); + + /* Check arguments */ + if (value < 0) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "negative VOL connector value is disallowed") + + /* Check VOL initialization property list */ + if (H5P_DEFAULT == vipl_id) + vipl_id = H5P_VOL_INITIALIZE_DEFAULT; + else if (TRUE != H5P_isa_class(vipl_id, H5P_VOL_INITIALIZE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list") + + /* Register connector */ + if ((ret_value = H5VL__register_connector_by_value(value, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister_connector_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VLis_connector_registered_by_name + * + * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector name. + * + * Return: >0 if a VOL connector with that name has been registered + * 0 if a VOL connector with that name has NOT been registered + * <0 on errors + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_connector_registered_by_name(const char *name) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "*s", name); + + /* Check if connector with this name is registered */ + if ((ret_value = H5VL__is_connector_registered_by_name(name)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_connector_registered_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VLis_connector_registered_by_value + * + * Purpose: Tests whether a VOL class has been registered or not + * according to a supplied connector value (ID). + * + * Return: >0 if a VOL connector with that value has been registered + * 0 if a VOL connector with that value hasn't been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value) +{ + htri_t ret_value = FALSE; + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "VC", connector_value); + + /* Check if connector with this value is registered */ + if ((ret_value = H5VL__is_connector_registered_by_value(connector_value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check for VOL") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_connector_registered_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VLget_connector_id + * + * Purpose: Retrieves the VOL connector ID for a given object ID. + * + * Return: A valid VOL connector ID. This ID will need to be closed + * using H5VLclose(). + * + * H5I_INVALID_HID on error. + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id(hid_t obj_id) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "i", obj_id); + + /* Get connector ID */ + if ((ret_value = H5VL__get_connector_id(obj_id, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VLget_connector_id_by_name + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector by that name has + * been registered. This ID will need to be closed using + * H5VLclose(). + * + * H5I_INVALID_HID on error or if a VOL connector of that + * name has not been registered. + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id_by_name(const char *name) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "*s", name); + + /* Get connector ID with this name */ + if ((ret_value = H5VL__get_connector_id_by_name(name, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_id_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VLget_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value has + * been registered. This ID will need to be closed using + * H5VLclose(). + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_connector_id_by_value(H5VL_class_value_t connector_value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", connector_value); + + /* Get connector ID with this value */ + if ((ret_value = H5VL__get_connector_id_by_value(connector_value, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_id_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_name + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector by that name has + * been registered. This ID is *not* owned by the caller and + * H5VLclose() should not be called. Intended for use by VOL + * connectors to find their own ID. + * + * H5I_INVALID_HID on error or if a VOL connector of that + * name has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLpeek_connector_id_by_name(const char *name) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "*s", name); + + /* Get connector ID with this name */ + if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLpeek_connector_id_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VLpeek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: A valid VOL connector ID if a connector with that value + * has been registered. This ID is *not* owned by the caller + * and H5VLclose() should not be called. Intended for use by + * VOL connectors to find their own ID. + * + * H5I_INVALID_HID on error or if a VOL connector with that + * value has not been registered. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLpeek_connector_id_by_value(H5VL_class_value_t value) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "VC", value); + + /* Get connector ID with this value */ + if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLpeek_connector_id_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VLget_connector_name + * + * Purpose: Returns the connector name for the VOL associated with the + * object or file ID. + * + * This works like other calls where the caller must provide a + * buffer of the appropriate size for the library to fill in. + * i.e., passing in a NULL pointer for NAME will return the + * required size of the buffer. + * + * Return: Success: The length of the connector name + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VLget_connector_name(hid_t obj_id, char *name /*out*/, size_t size) +{ + ssize_t ret_value = -1; + + FUNC_ENTER_API(FAIL) + H5TRACE3("Zs", "ixz", obj_id, name, size); + + /* Call internal routine */ + if ((ret_value = H5VL__get_connector_name(obj_id, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get connector name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_connector_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VLclose + * + * Purpose: Closes a VOL connector ID. This in no way affects + * file access property lists which have been defined to use + * this VOL connector or files which are already opened under with + * this connector. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLclose(hid_t vol_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", vol_id); + + /* Check args */ + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector") + + /* Decrement the ref count on the ID, possibly releasing the VOL connector */ + if (H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close VOL connector ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLclose() */ + +/*------------------------------------------------------------------------- + * Function: H5VLunregister_connector + * + * Purpose: Removes a VOL connector ID from the library. This in no way affects + * file access property lists which have been defined to use + * this VOL connector or files which are already opened under with + * this connector. + * + * The native VOL connector cannot be unregistered and attempts + * to do so are considered an error. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLunregister_connector(hid_t vol_id) +{ + hid_t native_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", vol_id); + + /* Check arguments */ + if (NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* For the time being, we disallow unregistering the native VOL connector */ + if (H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID") + if (vol_id == native_id) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed") + + /* The H5VL_class_t struct will be freed by this function */ + if (H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") + +done: + if (native_id != H5I_INVALID_HID) + if (H5I_dec_ref(native_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement count on native_id") + + FUNC_LEAVE_API(ret_value) +} /* end H5VLunregister_connector() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLcmp_connector_cls + * + * Purpose: Compares two connector classes (based on their value field) + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Return: Success: Non-negative, *cmp set to a value like strcmp + * + * Failure: Negative, *cmp unset + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2) +{ + H5VL_class_t *cls1, *cls2; /* connectors for IDs */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "*Isii", cmp, connector_id1, connector_id2); + + /* Check args and get class pointers */ + if (NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(connector_id1, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if (NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(connector_id2, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Compare the two VOL connector classes */ + if (H5VL_cmp_connector_cls(cmp, cls1, cls2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLcmp_connector_cls() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLwrap_register + * + * Purpose: Wrap an internal object with a "wrap context" and register an + * hid_t for the resulting object. + * + * Note: This routine is mainly targeted toward wrapping objects for + * iteration routine callbacks (i.e. the callbacks from H5Aiterate*, + * H5Literate* / H5Lvisit*, and H5Ovisit* ). + * + * type must be a VOL-managed object class (H5I_FILE, + * H5I_GROUP, H5I_DATATYPE, H5I_DATASET, H5I_MAP, or H5I_ATTR). + * + * Return: Success: Non-negative hid_t for the object. + * Failure: Negative (H5I_INVALID_HID) + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VLwrap_register(void *obj, H5I_type_t type) +{ + hid_t ret_value; /* Return value */ + + /* Use FUNC_ENTER_API_NOINIT here, so the API context doesn't get reset */ + FUNC_ENTER_API_NOINIT + H5TRACE2("i", "*xIt", obj, type); + + /* Check args */ + /* Use a switch here for (hopefully) better performance than a series of + * equality checks. We could also group these types together in H5I_type_t, + * make some assertions here to guarantee that, then just check the range. + */ + switch (type) { + case H5I_FILE: + case H5I_GROUP: + case H5I_DATATYPE: + case H5I_DATASET: + case H5I_MAP: + case H5I_ATTR: + /* VOL-managed objects, call is valid */ + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + 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_VOL, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") + } /* end switch */ + if (NULL == obj) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "obj is NULL") + + /* Wrap the object and register an ID for it */ + if ((ret_value = H5VL_wrap_register(type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to wrap object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLwrap_register() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLobject + * + * Purpose: Retrieve the object pointer associated with an hid_t for a + * VOL object. + * + * Note: This routine is mainly targeted toward unwrapping objects for + * testing. + * + * Return: Success: Object pointer + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLobject(hid_t id) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE1("*x", "i", id); + + /* Retrieve the object pointer for the ID */ + if (NULL == (ret_value = H5VL_object(id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to retrieve object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLobject() */ + +/*------------------------------------------------------------------------- + * Function: H5VLget_file_type + * + * Purpose: Returns a copy of dtype_id with its location set to be in + * the file, with updated size, etc. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id) +{ + H5T_t * dtype; /* unatomized type */ + H5T_t * file_type = NULL; /* copied file type */ + hid_t file_type_id = -1; /* copied file type id */ + H5VL_object_t *file_vol_obj = NULL; /* VOL object for file */ + hid_t ret_value = -1; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("i", "*xii", file_obj, connector_id, dtype_id); + + /* Check args */ + if (!file_obj) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "no file object supplied") + if (NULL == (dtype = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") + + /* Create VOL object for file if necessary (force_conv will be TRUE if and + * only if file needs to be passed to H5T_set_loc) */ + if (H5T_GET_FORCE_CONV(dtype) && + (NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id)))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") + + /* Copy the datatype */ + if (NULL == (file_type = H5T_copy(dtype, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy datatype") + + /* Register file type id */ + if ((file_type_id = H5I_register(H5I_DATATYPE, file_type, FALSE)) < 0) { + (void)H5T_close_real(file_type); + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "unable to register file datatype") + } /* end if */ + + /* Set the location of the datatype to be in the file */ + if (H5T_set_loc(file_type, file_vol_obj, H5T_LOC_DISK) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't set datatype location") + + /* Release our reference to file_type */ + if (file_vol_obj) { + if (H5VL_free_object(file_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to free VOL object") + file_vol_obj = NULL; + } /* end if */ + + /* Set return value */ + ret_value = file_type_id; + +done: + /* Cleanup on error */ + if (ret_value < 0) { + if (file_vol_obj && H5VL_free_object(file_vol_obj) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to free VOL object") + if (file_type_id >= 0 && H5I_dec_ref(file_type_id) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close file datatype") + } /* end if */ + + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_file_type() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLretrieve_lib_state + * + * Purpose: Retrieves a copy of the internal state of the HDF5 library, + * so that it can be restored later. + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Return: Success: Non-negative, *state set + * Failure: Negative, *state unset + * + * Programmer: Quincey Koziol + * Thursday, January 10, 2019 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLretrieve_lib_state(void **state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "**x", state); + + /* Check args */ + if (NULL == state) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer") + + /* Retrieve the library state */ + if (H5VL_retrieve_lib_state(state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve library state") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLretrieve_lib_state() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLrestore_lib_state + * + * Purpose: Restores the internal state of the HDF5 library. + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, January 10, 2019 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLrestore_lib_state(const void *state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "*x", state); + + /* Check args */ + if (NULL == state) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer") + + /* Restore the library state */ + if (H5VL_restore_lib_state(state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't restore library state") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLrestore_lib_state() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLreset_lib_state + * + * Purpose: Resets the internal state of the HDF5 library, undoing the + * affects of H5VLrestore_lib_state. + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Note: This routine must be called as a "pair" with + * H5VLrestore_lib_state. It can be called before / after / + * independently of H5VLfree_lib_state. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Saturday, February 23, 2019 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLreset_lib_state(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Must use this, to avoid modifying the API context stack in FUNC_ENTER */ + FUNC_ENTER_API_NOINIT + H5TRACE0("e", ""); + + /* Reset the library state */ + if (H5VL_reset_lib_state() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset library state") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLreset_lib_state() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLfree_lib_state + * + * Purpose: Free a retrieved library state. + * + * Note: This routine is _only_ for HDF5 VOL connector authors! It is + * _not_ part of the public API for HDF5 application developers. + * + * Note: This routine must be called as a "pair" with + * H5VLretrieve_lib_state. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, January 10, 2019 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfree_lib_state(void *state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "*x", state); + + /* Check args */ + if (NULL == state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid state pointer") + + /* Free the library state */ + if (H5VL_free_lib_state(state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free library state") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLfree_lib_state() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLquery_optional + * + * Purpose: Determine if a VOL connector supports a particular optional + * callback operation. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iVSIs*b", obj_id, subcls, opt_type, supported); + + /* Check args */ + if (NULL == supported) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid supported pointer") + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Query the connector */ + if (H5VL_introspect_opt_query(vol_obj, subcls, opt_type, supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to query VOL connector support") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLquery_optional() */ diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c new file mode 100644 index 00000000000..cde3f84de33 --- /dev/null +++ b/src/H5VLcallback.c @@ -0,0 +1,7669 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Structure used when trying to find a + * VOL connector to open a given file with. + */ +typedef struct H5VL_file_open_find_connector_t { + const char * filename; + const H5VL_class_t * cls; + H5VL_connector_prop_t *connector_prop; + hid_t fapl_id; +} H5VL_file_open_find_connector_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ +static void * H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +static void * H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req); +static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void * H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); +static herr_t H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); +static herr_t H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, + H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +static void * H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, + H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req); +static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_info, + void *op_data); +static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static void * H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +static void * H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static void * H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + const H5VL_class_t *cls, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +static herr_t H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, + int opt_type, hbool_t *supported); +static herr_t H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, H5ES_status_t *status); +static herr_t H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, void *ctx); +static herr_t H5VL__request_cancel(void *req, const H5VL_class_t *cls); +static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, + H5VL_request_specific_t specific_type, va_list arguments); +static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, + va_list arguments); +static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls); +static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, void *blob_id, + void *ctx); +static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, void *buf, size_t size, + void *ctx); +static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments); +static herr_t H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, + H5VL_blob_optional_t opt_type, va_list arguments); +static herr_t H5VL__token_cmp(void *obj, const H5VL_class_t *cls, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); +static herr_t H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const H5O_token_t *token, char **token_str); +static herr_t H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, + const char *token_str, H5O_token_t *token); +static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, + va_list arguments); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5VLinitialize + * + * Purpose: Calls the connector-specific callback to initialize the connector. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLinitialize(hid_t connector_id, hid_t vipl_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "ii", connector_id, vipl_id); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Invoke class' callback, if there is one */ + if (cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not initialize") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLinitialize() */ + +/*------------------------------------------------------------------------- + * Function: H5VLterminate + * + * Purpose: Calls the connector-specific callback to terminate the connector. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLterminate(hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "i", connector_id); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Invoke class' callback, if there is one */ + if (cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLterminate() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLget_cap_flags + * + * Purpose: Retrieves the capability flag for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*Iu", connector_id, cap_flags); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Retrieve capability flags */ + if (cap_flags) + *cap_flags = cls->cap_flags; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_cap_flags */ + +/*--------------------------------------------------------------------------- + * Function: H5VLget_value + * + * Purpose: Retrieves the 'value' for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_value(hid_t connector_id, H5VL_class_value_t *value) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*VC", connector_id, value); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Retrieve connector value */ + if (value) + *value = cls->value; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_value */ + +/*------------------------------------------------------------------------- + * Function: H5VL_copy_connector_info + * + * Purpose: Copy the VOL info for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info) +{ + void * new_connector_info = NULL; /* Copy of connector info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + + /* Check for actual source info */ + if (src_info) { + /* Allow the connector to copy or do it ourselves */ + if (connector->info_cls.copy) { + if (NULL == (new_connector_info = (connector->info_cls.copy)(src_info))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "connector info copy callback failed") + } /* end if */ + else if (connector->info_cls.size > 0) { + if (NULL == (new_connector_info = H5MM_malloc(connector->info_cls.size))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "connector info allocation failed") + H5MM_memcpy(new_connector_info, src_info, connector->info_cls.size); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy connector info") + } /* end if */ + + /* Set the connector info for the copy */ + *dst_info = new_connector_info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_copy_connector_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLcopy_connector_info + * + * Purpose: Copies a VOL connector's info object + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "i**x*x", connector_id, dst_vol_info, src_vol_info); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Copy the VOL connector's info object */ + if (H5VL_copy_connector_info(cls, dst_vol_info, src_vol_info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy VOL connector info object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLcopy_connector_info() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_cmp_connector_info + * + * Purpose: Compare VOL info for a connector. Sets *cmp_value to + * positive if INFO1 is greater than INFO2, negative if + * INFO2 is greater than INFO1 and zero if INFO1 and + * INFO2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, const void *info2) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + HDassert(cmp_value); + + /* Take care of cases where one or both pointers is NULL */ + if (info1 == NULL && info2 != NULL) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED); + } /* end if */ + if (info1 != NULL && info2 == NULL) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED); + } /* end if */ + if (info1 == NULL && info2 == NULL) { + *cmp_value = 0; + HGOTO_DONE(SUCCEED); + } /* end if */ + + /* Use the class's info comparison routine to compare the info objects, + * if there is a a callback, otherwise just compare the info objects as + * memory buffers + */ + if (connector->info_cls.cmp) { + if ((connector->info_cls.cmp)(cmp_value, info1, info2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector info") + } /* end if */ + else { + HDassert(connector->info_cls.size > 0); + *cmp_value = HDmemcmp(info1, info2, connector->info_cls.size); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_cmp_connector_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLcmp_connector_info + * + * Purpose: Compares two connector info objects + * + * Note: Both info objects must be from the same VOL connector class + * + * Return: Success: Non-negative, with *cmp set to positive if + * info1 is greater than info2, negative if info2 + * is greater than info1 and zero if info1 and info2 + * are equal. + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*Isi*x*x", cmp, connector_id, info1, info2); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Compare the two VOL connector info objects */ + if (cmp) + H5VL_cmp_connector_info(cls, cmp, info1, info2); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLcmp_connector_info() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_free_connector_info + * + * Purpose: Free VOL info for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_connector_info(hid_t connector_id, const void *info) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(connector_id > 0); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Only free info object, if it's non-NULL */ + if (info) { + /* Allow the connector to free info or do it ourselves */ + if (cls->info_cls.free) { + /* Cast through uintptr_t to de-const memory */ + if ((cls->info_cls.free)((void *)(uintptr_t)info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed") + } + else + H5MM_xfree_const(info); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_connector_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLfree_connector_info + * + * Purpose: Free VOL connector info object + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfree_connector_info(hid_t connector_id, void *info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*x", connector_id, info); + + /* Free the VOL connector info object */ + if (H5VL_free_connector_info(connector_id, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLfree_connector_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLconnector_info_to_str + * + * Purpose: Serialize a connector's info into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xi**s", info, connector_id, str); + + /* Only serialize info object, if it's non-NULL */ + if (info) { + H5VL_class_t *cls; /* VOL connector's class struct */ + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allow the connector to serialize info */ + if (cls->info_cls.to_str) { + if ((cls->info_cls.to_str)(info, str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize connector info") + } /* end if */ + else + *str = NULL; + } /* end if */ + else + *str = NULL; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLconnector_info_to_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLconnector_str_to_info + * + * Purpose: Deserialize a string into a connector's info + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*si**x", str, connector_id, info); + + /* Call internal routine */ + if (H5VL__connector_str_to_info(str, connector_id, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLconnector_str_to_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLget_object + * + * Purpose: Retrieves an underlying object. + * + * Return: Success: Non-NULL + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLget_object(void *obj, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("*x", "*xi", obj, connector_id); + + /* Check args */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Check for 'get_object' callback in connector */ + if (cls->wrap_cls.get_object) + ret_value = (cls->wrap_cls.get_object)(obj); + else + ret_value = obj; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_object */ + +/*------------------------------------------------------------------------- + * Function: H5VL_get_wrap_ctx + * + * Purpose: Retrieve the VOL object wrapping context for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + HDassert(obj); + HDassert(wrap_ctx); + + /* Allow the connector to copy or do it ourselves */ + if (connector->wrap_cls.get_wrap_ctx) { + /* Sanity check */ + HDassert(connector->wrap_cls.free_wrap_ctx); + + /* Invoke connector's callback */ + if ((connector->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed") + } /* end if */ + else + *wrap_ctx = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_wrap_ctx() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLget_wrap_ctx + * + * Purpose: Get a VOL connector's object wrapping context + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xi**x", obj, connector_id, wrap_ctx); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Get the VOL connector's object wrapper */ + if (H5VL_get_wrap_ctx(cls, obj, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to retrieve VOL connector object wrap context") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_wrap_ctx() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_wrap_object + * + * Purpose: Wrap an object with connector + * + * Return: Success: Non-NULL + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Sanity checks */ + HDassert(connector); + HDassert(obj); + + /* Only wrap object if there's a wrap context */ + if (wrap_ctx) { + /* Ask the connector to wrap the object */ + if (NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") + } /* end if */ + else + ret_value = obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_wrap_object() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLwrap_object + * + * Purpose: Asks a connector to wrap an underlying object. + * + * Return: Success: Non-NULL + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Wrap the object */ + if (NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLwrap_object */ + +/*------------------------------------------------------------------------- + * Function: H5VL_unwrap_object + * + * Purpose: Unwrap an object from connector + * + * Return: Success: Non-NULL + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_unwrap_object(const H5VL_class_t *connector, void *obj) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Sanity checks */ + HDassert(connector); + HDassert(obj); + + /* Only unwrap object if there's an unwrap callback */ + if (connector->wrap_cls.wrap_object) { + /* Ask the connector to unwrap the object */ + if (NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object") + } /* end if */ + else + ret_value = obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_unwrap_object() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLunwrap_object + * + * Purpose: Unwrap an object from connector + * + * Return: Success: Non-NULL + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLunwrap_object(void *obj, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("*x", "*xi", obj, connector_id); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Unwrap the object */ + if (NULL == (ret_value = H5VL_unwrap_object(cls, obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLunwrap_object */ + +/*------------------------------------------------------------------------- + * Function: H5VL_free_wrap_ctx + * + * Purpose: Free object wrapping context for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + + /* Only free wrap context, if it's non-NULL */ + if (wrap_ctx) { + /* Free the connector's object wrapping context */ + if ((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_wrap_ctx() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLfree_wrap_ctx + * + * Purpose: Release a VOL connector's object wrapping context + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", wrap_ctx, connector_id); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Release the VOL connector's object wrapper */ + if (H5VL_free_wrap_ctx(cls, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLfree_wrap_ctx() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr create' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, + type_id, space_id, acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_create + * + * Purpose: Creates an attribute + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_open + * + * Purpose: Opens an attribute through the VOL + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr open' method") + + /* Call the corresponding VOL open callback */ + if (NULL == (ret_value = (cls->attr_cls.open)(obj, loc_params, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_open + * + * Purpose: Opens an attribute through the VOL + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__attr_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_open + * + * Purpose: Opens an attribute + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, aapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_read + * + * Purpose: Reads data from attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr read' method") + + /* Call the corresponding VOL callback */ + if ((cls->attr_cls.read)(obj, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_read + * + * Purpose: Reads data from attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_read + * + * Purpose: Reads data from an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_write + * + * Purpose: Writes data to attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, hid_t dxpl_id, + void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr write' method") + + /* Call the corresponding VOL callback */ + if ((cls->attr_cls.write)(obj, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_write + * + * Purpose: Writes data to attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_write + * + * Purpose: Writes data to an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_get + * + * Purpose: Get specific information about the attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr get' method") + + /* Call the corresponding VOL callback */ + if ((cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_get + * + * Purpose: Get specific information about the attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_get + * + * Purpose: Gets information about the attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVai**xx", obj, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_specific + * + * Purpose: Specific operation on attributes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr specific' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_specific + * + * Purpose: Specific operation on attributes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_specific + * + * Purpose: Performs a connector-specific operation on an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVbi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__attr_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_optional(void *obj, const H5VL_class_t *cls, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr optional' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->attr_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, + arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_optional + * + * Purpose: Performs an optional connector-specific operation on an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVsi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__attr_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_close + * + * Purpose: Closes an attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr close' method") + + /* Call the corresponding VOL callback */ + if ((cls->attr_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_close + * + * Purpose: Closes an attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VLattr_close + * + * Purpose: Closes an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__attr_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: Pointer to new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset create' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: Pointer to new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, + void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == + (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, lcpl_id, + type_id, space_id, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_create + * + * Purpose: Creates a dataset + * + * Return: Success: Pointer to the new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE11("*x", "*x*xi*siiiiii**x", obj, loc_params, connector_id, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: Pointer to dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset open' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->dataset_cls.open)(obj, loc_params, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: Pointer to dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__dataset_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_open + * + * Purpose: Opens a dataset + * + * Return: Success: Pointer to the new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, dapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_read + * + * Purpose: Reads data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset read' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.read)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_read + * + * Purpose: Reads data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, + dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_read + * + * Purpose: Reads data from a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_read(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset write' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.write)(obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, + dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_write + * + * Purpose: Writes data to a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_write(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_write(obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_get + * + * Purpose: Get specific information about the dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset get' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_get + * + * Purpose: Get specific information about the dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_get + * + * Purpose: Gets information about a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVci**xx", obj, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_specific + * + * Purpose: Specific operation on datasets through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset specific' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_specific + * + * Purpose: Specific operation on datasets through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, + arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_specific + * + * Purpose: Performs a connector-specific operation on a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVdi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_optional + * + * Purpose: Performs an optional connector-specific operation on a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVti**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset close' method") + + /* Call the corresponding VOL callback */ + if ((cls->dataset_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(vol_obj->data); + HDassert(vol_obj->connector); + HDassert(vol_obj->connector->cls); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_close + * + * Purpose: Closes a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__dataset_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.commit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'datatype commit' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->datatype_cls.commit)(obj, loc_params, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_commit() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__datatype_commit(vol_obj->data, loc_params, vol_obj->connector->cls, name, + type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_commit() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_commit + * + * Purpose: Commits a datatype to the file + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_commit() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__datatype_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_open + * + * Purpose: Opens a named datatype + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, tapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype get' method") + + /* Call the corresponding VOL callback */ + if ((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_get + * + * Purpose: Gets information about the datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVei**xx", obj, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `datatype get' method") + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_specific + * + * Purpose: Specific operation on datatypes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype specific' method") + + /* Call the corresponding VOL callback */ + if ((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_specific + * + * Purpose: Specific operation on datatypes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, + arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_specific + * + * Purpose: Performs a connector-specific operation on a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVfi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->datatype_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_optional + * + * Purpose: Performs an optional connector-specific operation on a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVui**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype close' method") + + /* Call the corresponding VOL callback */ + if ((cls->datatype_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_close + * + * Purpose: Closes a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_create + * + * Purpose: Creates a file through the VOL + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file create' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_create + * + * Purpose: Creates a file through the VOL + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the connector's class */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_create + * + * Purpose: Creates a file + * + * Return: Success: Pointer to the new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t * cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("*x", "*sIuiii**x", name, flags, fcpl_id, fapl_id, dxpl_id, req); + + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_open + * + * Purpose: Opens a file through the VOL. + * + * Return: Success: Pointer to file. + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file open' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_open_find_connector_cb + * + * Purpose: Iteration callback for H5PL_iterate that tries to find the + * correct VOL connector to open a file with when + * H5VL_file_open fails for its given VOL connector. Iterates + * through all of the available VOL connector plugins until + * H5Fis_accessible returns true for the given filename and + * VOL connector. + * + * Return: H5_ITER_CONT if current plugin can't open the given file + * H5_ITER_STOP if current plugin can open given file + * H5_ITER_ERROR if an error occurs while trying to determine + * if current plugin can open given file. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_info, void *op_data) +{ + H5VL_file_open_find_connector_t *udata = (H5VL_file_open_find_connector_t *)op_data; + const H5VL_class_t * cls = (const H5VL_class_t *)plugin_info; + H5P_genplist_t * fapl_plist; + H5P_genplist_t * fapl_plist_copy; + herr_t status; + htri_t is_accessible = FALSE; + hid_t connector_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + herr_t ret_value = H5_ITER_CONT; + + FUNC_ENTER_STATIC + + HDassert(udata); + HDassert(udata->filename); + HDassert(udata->connector_prop); + HDassert(cls); + HDassert(plugin_type == H5PL_TYPE_VOL); + + /* Silence compiler */ + (void)plugin_type; + + udata->cls = cls; + + /* Attempt to register plugin as a VOL connector */ + if ((connector_id = H5VL__register_connector_by_class(cls, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5_ITER_ERROR, "unable to register VOL connector") + + /* Setup FAPL with registered VOL connector */ + if (NULL == (fapl_plist = (H5P_genplist_t *)H5I_object_verify(udata->fapl_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "not a property list") + if ((fapl_id = H5P_copy_plist(fapl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy fapl"); + if (NULL == (fapl_plist_copy = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "not a property list") + if (H5P_set_vol(fapl_plist_copy, connector_id, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5_ITER_ERROR, "can't set VOL connector on fapl") + + /* Check if file is accessible with given VOL connector */ + H5E_BEGIN_TRY + { + status = H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + fapl_id, udata->filename, &is_accessible); + } + H5E_END_TRY; + + /* If the file was accessible with the current VOL connector, return + * the FAPL with that VOL connector set on it. Errors are ignored here + * as some VOL connectors may not support H5Fis_accessible. + */ + if (status == SUCCEED && is_accessible > 0) { + /* Modify 'connector_prop' to point to the VOL connector that + * was actually used to open the file, rather than the original + * VOL connector that was requested. + */ + udata->connector_prop->connector_id = connector_id; + udata->connector_prop->connector_info = NULL; + + udata->fapl_id = fapl_id; + ret_value = H5_ITER_STOP; + } /* end if */ + +done: + if (ret_value != H5_ITER_STOP) { + if (fapl_id >= 0 && H5I_dec_app_ref(fapl_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close fapl") + if (connector_id >= 0 && H5I_dec_app_ref(connector_id) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close VOL connector ID") + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_open_find_connector_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_open + * + * Purpose: Opens a file through the VOL. + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to file. + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the connector's class */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) { + H5VL_file_open_find_connector_t find_connector_ud; + hbool_t find_connector; + hbool_t connector_available = FALSE; + + /* Opening the file failed - Determine whether we should search + * the plugin path to see if any other VOL connectors are available + * to attempt to open the file with. This only occurs if no particular + * VOL connector was specified (either via a FAPL or the + * HDF5_VOL_CONNECTOR environment variable). + */ + find_connector = !getenv("HDF5_VOL_CONNECTOR") && ((H5P_FILE_ACCESS_DEFAULT == fapl_id) || + connector_prop->connector_id == H5_DEFAULT_VOL); + + if (find_connector) { + herr_t iter_ret; + + find_connector_ud.connector_prop = connector_prop; + find_connector_ud.filename = name; + find_connector_ud.cls = NULL; + find_connector_ud.fapl_id = fapl_id; + + iter_ret = H5PL_iterate(H5PL_ITER_TYPE_VOL, H5VL__file_open_find_connector_cb, + (void *)&find_connector_ud); + if (iter_ret < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, NULL, + "failed to iterate over available VOL connector plugins") + else if (iter_ret) + connector_available = TRUE; + } /* end if */ + + /* If one of the available VOL connector plugins is + * able to open the file, clear the error stack from any + * previous file open failures and then open the file. + * Otherwise, if no VOL connectors are available, throw + * error from original file open failure. + */ + if (connector_available) { + H5E_clear_stack(NULL); + + if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, + find_connector_ud.fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "can't open file '%s' with VOL connector '%s'", + name, find_connector_ud.cls->name) + } + else + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_open + * + * Purpose: Opens a file + * + * Return: Success: Pointer to the file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t * cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("*x", "*sIuii**x", name, flags, fapl_id, dxpl_id, req); + + /* Get the VOL info from the fapl */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file get' method") + + /* Call the corresponding VOL callback */ + if ((cls->file_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_get + * + * Purpose: Gets information about the file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVgi**xx", obj, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_specific + * + * Purpose: Perform File specific operations through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file specific' method") + + /* Call the corresponding VOL callback */ + if ((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_specific + * + * Purpose: Perform file specific operations through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, ...) +{ + const H5VL_class_t *cls; /* VOL connector's class struct */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Start access to the varargs, so they are available in all situations below */ + HDva_start(arguments, req); + arg_started = TRUE; + + /* Special treatment of file access check & delete operations */ + /* (Retrieve the VOL connector from the FAPL, since the file isn't open) */ + if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { + H5P_genplist_t * plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + va_list tmp_args; /* argument list passed from the API call */ + hid_t fapl_id; /* File access property list for accessing the file */ + + /* Get the file access property list to access the file */ + HDva_copy(tmp_args, arguments); + fapl_id = HDva_arg(tmp_args, hid_t); + HDva_end(tmp_args); + + /* Get the VOL info from the FAPL */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + } /* end if */ + /* Set wrapper info in API context, for all other operations */ + else { + /* Sanity check */ + HDassert(vol_obj); + + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Set the VOL connector class pointer */ + cls = vol_obj->connector->cls; + } /* end else */ + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_specific + * + * Purpose: Performs a connector-specific operation on a file + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVhi**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_optional + * + * Purpose: Perform a connector specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_optional(void *obj, const H5VL_class_t *cls, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->file_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_optional + * + * Purpose: Perform a connector specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_optional + * + * Purpose: Performs an optional connector-specific operation on a file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVvi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__file_close + * + * Purpose: Closes a file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file close' method") + + /* Call the corresponding VOL callback */ + if ((cls->file_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_close + * + * Purpose: Closes a file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VLfile_close + * + * Purpose: Closes a file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__file_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_create + * + * Purpose: Creates a group through the VOL + * + * Return: Success: Pointer to new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group create' method") + + /* Call the corresponding VOL callback */ + if (NULL == + (ret_value = (cls->group_cls.create)(obj, loc_params, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_create + * + * Purpose: Creates a group through the VOL + * + * Return: Success: Pointer to new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, + lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_create + * + * Purpose: Creates a group + * + * Return: Success: Pointer to the new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("*x", "*x*xi*siiii**x", obj, loc_params, connector_id, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, + req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == + (ret_value = H5VL__group_create(obj, loc_params, cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: Pointer to group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group open' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->group_cls.open)(obj, loc_params, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: Pointer to group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__group_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, + gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_open + * + * Purpose: Opens a group + * + * Return: Success: Pointer to the group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, gapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__group_open(obj, loc_params, cls, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group get' method") + + /* Call the corresponding VOL callback */ + if ((cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_get + * + * Purpose: Gets information about the group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVii**xx", obj, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__group_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_specific + * + * Purpose: Specific operation on groups through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group specific' method") + + /* Call the corresponding VOL callback */ + if ((cls->group_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_specific + * + * Purpose: Specific operation on groups through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_specific + * + * Purpose: Performs a connector-specific operation on a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVji**xx", obj, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__group_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_optional(void *obj, const H5VL_class_t *cls, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group optional' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->group_cls.optional)(obj, opt_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, + arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_optional + * + * Purpose: Performs an optional connector-specific operation on a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVwi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__group_optional(obj, cls, opt_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__group_close + * + * Purpose: Closes a group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group close' method") + + /* Call the corresponding VOL callback */ + if ((cls->group_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_group_close + * + * Purpose: Closes a group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__group_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_close + * + * Purpose: Closes a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__group_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_create + * + * Purpose: Creates a link through the VOL + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link create' method") + + /* Call the corresponding VOL callback */ + if ((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_create + * + * Purpose: Creates a link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + ...) +{ + H5VL_object_t tmp_vol_obj; /* Temporary object */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Start the varargs, so they can be copied */ + HDva_start(arguments, req); + arg_started = TRUE; + + /* Special case for hard links */ + if (H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) { + va_list tmp_arguments; /* Copy of argument list passed in */ + + /* Get the VOL data pointer from the varargs */ + HDva_copy(tmp_arguments, arguments); + tmp_vol_obj.data = HDva_arg(tmp_arguments, void *); + HDva_end(tmp_arguments); + } /* end if */ + else + /* Use the VOL object passed in */ + tmp_vol_obj.data = vol_obj->data; + tmp_vol_obj.connector = vol_obj->connector; + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(&tmp_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, + dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_create + * + * Purpose: Creates a link + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("e", "Vk*x*xiiii**xx", create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, + req, arguments); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_copy + * + * Purpose: Copys a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link copy' method") + + /* Call the corresponding VOL callback */ + if ((cls->link_cls.copy)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_copy + * + * Purpose: Copys a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + vol_obj = (src_vol_obj->data ? src_vol_obj : dst_vol_obj); + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_copy(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, + vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_copy + * + * Purpose: Copies a link to a new location + * + * Note: The 'src_obj' and 'dst_obj' parameters are allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, + lapl_id, dxpl_id, req); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_move + * + * Purpose: Moves a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.move) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link move' method") + + /* Call the corresponding VOL callback */ + if ((cls->link_cls.move)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_move() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_move + * + * Purpose: Moves a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + vol_obj = (src_vol_obj->data ? src_vol_obj : dst_vol_obj); + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_move(src_vol_obj->data, loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, + vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_move() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_move + * + * Purpose: Moves a link to another location + * + * Note: The 'src_obj' and 'dst_obj' parameters are allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, + lapl_id, dxpl_id, req); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "unable to move object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_move() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_get + * + * Purpose: Get specific information about the link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link get' method") + + /* Call the corresponding VOL callback */ + if ((cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_get + * + * Purpose: Get specific information about the link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, + arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_get + * + * Purpose: Gets information about a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVli**xx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_specific + * + * Purpose: Specific operation on links through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link specific' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->link_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_specific + * + * Purpose: Specific operation on links through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_specific + * + * Purpose: Performs a connector-specific operation on a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVmi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__link_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__link_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_optional(void *obj, const H5VL_class_t *cls, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->link_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_link_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLlink_optional + * + * Purpose: Performs an optional connector-specific operation on a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVxi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__link_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, + H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'object open' method") + + /* Call the corresponding VOL callback */ + if (NULL == (ret_value = (cls->object_cls.open)(obj, params, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__object_open(vol_obj->data, params, vol_obj->connector->cls, opened_type, + dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VLobject_open + * + * Purpose: Opens an object + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("*x", "*x*xi*Iti**x", obj, params, connector_id, opened_type, dxpl_id, req); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (NULL == (ret_value = H5VL__object_open(obj, params, cls, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object_copy + * + * Purpose: Copies an object to another destination through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, const H5VL_class_t *cls, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object copy' method") + + /* Call the corresponding VOL callback */ + if ((cls->object_cls.copy)(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, + ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_copy + * + * Purpose: Copies an object to another destination through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Make sure that the VOL connectors are the same */ + if (src_obj->connector->cls->value != dst_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "objects are accessed through different VOL connectors and can't be copied") + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(src_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__object_copy(src_obj->data, src_loc_params, src_name, dst_obj->data, dst_loc_params, dst_name, + src_obj->connector->cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VLobject_copy + * + * Purpose: Copies an object to another location + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t connector_id, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE11("e", "*x*x*s*x*x*siiii**x", src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, + dst_name, connector_id, ocpypl_id, lcpl_id, dxpl_id, req); + + /* Check args and get class pointers */ + if (NULL == src_obj || NULL == dst_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, cls, + ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object get' method") + + /* Call the corresponding VOL callback */ + if ((cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, + arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLobject_get + * + * Purpose: Gets information about an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVni**xx", obj, loc_params, connector_id, get_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__object_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object_specific + * + * Purpose: Specific operation on objects through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object specific' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_specific + * + * Purpose: Specific operation on objects through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, + dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLobject_specific + * + * Purpose: Performs a connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVoi**xx", obj, loc_params, connector_id, specific_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `object specific' method") + + /* Bypass the H5VLint layer, calling the VOL callback directly */ + if ((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_optional(void *obj, const H5VL_class_t *cls, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->object_cls.optional)(obj, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if (H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLobject_optional + * + * Purpose: Performs an optional connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVyi**xx", obj, connector_id, opt_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__object_optional(obj, cls, opt_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__introspect_get_conn_cls + * + * Purpose: Calls the connector-specific callback to query the connector + * class. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__introspect_get_conn_cls(void *obj, const H5VL_class_t *cls, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + HDassert(lvl >= H5VL_GET_CONN_LVL_CURR && lvl <= H5VL_GET_CONN_LVL_TERM); + HDassert(conn_cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->introspect_cls.get_conn_cls) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'get_conn_cls' method") + + /* Call the corresponding VOL callback */ + if ((cls->introspect_cls.get_conn_cls)(obj, lvl, conn_cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__introspect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_introspect_get_conn_cls + * + * Purpose: Calls the connector-specific callback to query the connector + * class. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__introspect_get_conn_cls(vol_obj->data, vol_obj->connector->cls, lvl, conn_cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_introspect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VLintrospect_get_conn_cls + * + * Purpose: Calls the connector-specific callback to query the connector + * class. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiVL**x", obj, connector_id, lvl, conn_cls); + + /* Check args */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL obj pointer") + if (NULL == conn_cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL conn_cls pointer") + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__introspect_get_conn_cls(obj, cls, lvl, conn_cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLintrospect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__introspect_opt_query + * + * Purpose: Calls the connector-specific callback to query if an optional + * operation is supported. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__introspect_opt_query(void *obj, const H5VL_class_t *cls, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->introspect_cls.opt_query) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'opt_query' method") + + /* Call the corresponding VOL callback */ + if ((cls->introspect_cls.opt_query)(obj, subcls, opt_type, supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__introspect_opt_query() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_introspect_opt_query + * + * Purpose: Calls the connector-specific callback to query if an optional + * operation is supported. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__introspect_opt_query(vol_obj->data, vol_obj->connector->cls, subcls, opt_type, supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_introspect_opt_query() */ + +/*------------------------------------------------------------------------- + * Function: H5VLintrospect_opt_query + * + * Purpose: Calls the connector-specific callback to query if an optional + * operation is supported. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xiVSIs*b", obj, connector_id, subcls, opt_type, supported); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__introspect_opt_query(obj, cls, subcls, opt_type, supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLintrospect_opt_query() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_wait + * + * Purpose: Waits on an asychronous request through the VOL + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(req); + HDassert(cls); + HDassert(status); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.wait) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async wait' method") + + /* Call the corresponding VOL callback */ + if ((cls->request_cls.wait)(req, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_wait() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_wait + * + * Purpose: Waits on an asychronous request through the VOL + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5ES_status_t *status) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_wait(vol_obj->data, vol_obj->connector->cls, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_wait() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_wait + * + * Purpose: Waits on a request + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiUL*Es", req, connector_id, timeout, status); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_wait(req, cls, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_wait() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.notify) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async notify' method") + + /* Call the corresponding VOL callback */ + if ((cls->request_cls.notify)(req, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request notify failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_notify() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_notify(vol_obj->data, vol_obj->connector->cls, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "request notify failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_notify() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xix*x", req, connector_id, cb, ctx); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_notify(req, cls, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to register notify callback for request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_notify() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_cancel + * + * Purpose: Cancels an asynchronous request through the VOL + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_cancel(void *req, const H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.cancel) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async cancel' method") + + /* Call the corresponding VOL callback */ + if ((cls->request_cls.cancel)(req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_cancel() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_cancel + * + * Purpose: Cancels an asynchronous request through the VOL + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_cancel(const H5VL_object_t *vol_obj) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_cancel(vol_obj->data, vol_obj->connector->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_cancel() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_cancel + * + * Purpose: Cancels a request + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_cancel(void *req, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", req, connector_id); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_cancel(req, cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_cancel() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_specific + * + * Purpose: Specific operation on asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_specific(void *req, const H5VL_class_t *cls, H5VL_request_specific_t specific_type, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async specific' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->request_cls.specific)(req, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_specific + * + * Purpose: Specific operation on asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, specific_type); + arg_started = TRUE; + if ((ret_value = + H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_specific + * + * Purpose: Performs a connector-specific operation on an asynchronous request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiVrx", req, connector_id, specific_type, arguments); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__request_specific(req, cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_optional(void *req, const H5VL_class_t *cls, H5VL_request_optional_t opt_type, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async optional' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->request_cls.optional)(req, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, opt_type); + arg_started = TRUE; + if ((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_optional + * + * Purpose: Performs an optional connector-specific operation on an asynchronous request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiVzx", req, connector_id, opt_type, arguments); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__request_optional(req, cls, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, + "unable to execute asynchronous request optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__request_free + * + * Purpose: Frees an asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_free(void *req, const H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->request_cls.free) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async free' method") + + /* Call the corresponding VOL callback */ + if ((cls->request_cls.free)(req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_request_free + * + * Purpose: Frees an asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_free(const H5VL_object_t *vol_obj) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if (H5VL__request_free(vol_obj->data, vol_obj->connector->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_free + * + * Purpose: Frees a request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_free(void *req, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", req, connector_id); + + /* Get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if (H5VL__request_free(req, cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_put + * + * Purpose: Put a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, void *blob_id, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + HDassert(size == 0 || buf); + HDassert(blob_id); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->blob_cls.put) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob put' method") + + /* Call the corresponding VOL callback */ + if ((cls->blob_cls.put)(obj, buf, size, blob_id, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put callback failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_put() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_put + * + * Purpose: Put a blob through the VOL + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Wednesday, August 21, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, void *ctx) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(size == 0 || buf); + HDassert(blob_id); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if (H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_blob_put() */ + +/*------------------------------------------------------------------------- + * Function: H5VLblob_put + * + * Purpose: Put a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xi*xz*x*x", obj, connector_id, buf, size, blob_id, ctx); + + /* Get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding VOL callback */ + if (H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_put() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, void *buf, size_t size, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + HDassert(blob_id); + HDassert(buf); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->blob_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob get' method") + + /* Call the corresponding VOL callback */ + if ((cls->blob_cls.get)(obj, blob_id, buf, size, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get callback failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, void *ctx) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(blob_id); + HDassert(buf); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if (H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_blob_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VLblob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xi*x*xz*x", obj, connector_id, blob_id, buf, size, ctx); + + /* Get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding VOL callback */ + if (H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_specific + * + * Purpose: Specific operation on blobs through the VOL + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Saturday, August 17, 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + HDassert(blob_id); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->blob_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob specific' method") + + /* Call the corresponding VOL callback */ + if ((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_specific + * + * Purpose: Specific operation on blobs through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specific_t specific_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(blob_id); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, specific_type); + arg_started = TRUE; + if ((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, + arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_blob_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VLblob_specific + * + * Purpose: Specific operation on blobs through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xi*xVBx", obj, connector_id, blob_id, specific_type, arguments); + + /* Get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding VOL callback */ + if (H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_optional + * + * Purpose: Optional operation on blobs through the VOL + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, November 14, 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__blob_optional(void *obj, const H5VL_class_t *cls, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + HDassert(blob_id); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->blob_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob optional' method") + + /* Call the corresponding VOL callback */ + if ((cls->blob_cls.optional)(obj, blob_id, opt_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_optional + * + * Purpose: Optional operation on blobs through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(blob_id); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, opt_type); + arg_started = TRUE; + if ((ret_value = + H5VL__blob_optional(vol_obj->data, vol_obj->connector->cls, blob_id, opt_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_blob_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLblob_optional + * + * Purpose: Optional operation on blobs through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xi*xVAx", obj, connector_id, blob_id, opt_type, arguments); + + /* Get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding VOL callback */ + if (H5VL__blob_optional(obj, cls, blob_id, opt_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob optional operation failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__token_cmp + * + * Purpose: Compares two VOL connector object tokens. Sets *cmp_value + * to positive if token1 is greater than token2, negative if + * token2 is greater than token1 and zero if token1 and + * token2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_cmp(void *obj, const H5VL_class_t *cls, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(cmp_value); + + /* Take care of cases where one or both pointers is NULL */ + if (token1 == NULL && token2 != NULL) + *cmp_value = -1; + else if (token1 != NULL && token2 == NULL) + *cmp_value = 1; + else if (token1 == NULL && token2 == NULL) + *cmp_value = 0; + else { + /* Use the class's token comparison routine to compare the tokens, + * if there is a callback, otherwise just compare the tokens as + * memory buffers. + */ + if (cls->token_cls.cmp) { + if ((cls->token_cls.cmp)(obj, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare object tokens") + } /* end if */ + else + *cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t)); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_token_cmp + * + * Purpose: Compares two VOL connector object tokens. Sets *cmp_value + * to positive if token1 is greater than token2, negative if + * token2 is greater than token1 and zero if token1 and + * token2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(cmp_value); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "token compare failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_cmp() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_cmp + * + * Purpose: Compares two VOL connector object tokens + * + * Note: Both object tokens must be from the same VOL connector class + * + * Return: Success: Non-negative, with *cmp_value set to positive if + * token1 is greater than token2, negative if token2 + * is greater than token1 and zero if token1 and + * token2 are equal. + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xi*k*k*Is", obj, connector_id, token1, token2, cmp_value); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if (NULL == cmp_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer") + + /* Call the corresponding internal VOL routine */ + if (H5VL__token_cmp(obj, cls, token1, token2, cmp_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__token_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_to_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const H5O_token_t *token, + char **token_str) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(token); + HDassert(token_str); + + /* Use the class's token serialization routine on the token if there is a + * callback, otherwise just set the token_str to NULL. + */ + if (cls->token_cls.to_str) { + if ((cls->token_cls.to_str)(obj, obj_type, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize object token") + } /* end if */ + else + *token_str = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_to_str() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_token_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(token); + HDassert(token_str); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "token serialization failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_to_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_to_str + * + * Purpose: Serialize a connector's object token into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, + char **token_str) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xIti*k**s", obj, obj_type, connector_id, token, token_str); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if (NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if (NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") + + /* Call the corresponding internal VOL routine */ + if (H5VL__token_to_str(obj, obj_type, cls, token, token_str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token to string failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_to_str() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__token_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__token_from_str(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls, const char *token_str, + H5O_token_t *token) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(obj); + HDassert(cls); + HDassert(token_str); + HDassert(token); + + /* Use the class's token deserialization routine on the token if there is a + * callback, otherwise just set the token to H5_TOKEN_UNDEF. + */ + if (cls->token_cls.from_str) { + if ((cls->token_cls.from_str)(obj, obj_type, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token string") + } /* end if */ + else + *token = H5O_TOKEN_UNDEF; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__token_from_str() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_token_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + HDassert(token); + HDassert(token_str); + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if ((ret_value = + H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "token deserialization failed") + +done: + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_token_from_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLtoken_from_str + * + * Purpose: Deserialize a string into a connector object token + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, + H5O_token_t *token) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xIti*s*k", obj, obj_type, connector_id, token_str, token); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if (NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer") + if (NULL == token_str) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer") + + /* Call the corresponding internal VOL routine */ + if (H5VL__token_from_str(obj, obj_type, cls, token_str, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token from string failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLtoken_from_str() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__optional(void *obj, const H5VL_class_t *cls, int op_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'optional' method") + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->optional)(obj, op_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if (H5VL_set_vol_wrapper(vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if ((ret_value = + H5VL__optional(vol_obj->data, vol_obj->connector->cls, op_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute optional callback") + +done: + /* End access to the va_list, if we started it */ + if (arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, ret_value, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VLoptional + * + * Purpose: Performs an optional connector-specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiIsi**xx", obj, connector_id, op_type, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if ((ret_value = H5VL__optional(obj, cls, op_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, ret_value, "unable to execute optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLoptional() */ diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h new file mode 100644 index 00000000000..de3f6b3bfb8 --- /dev/null +++ b/src/H5VLconnector.h @@ -0,0 +1,546 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for authoring VOL connectors. + */ + +#ifndef H5VLconnector_H +#define H5VLconnector_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Apublic.h" /* Attributes */ +#include "H5ESpublic.h" /* Event Stack */ +#include "H5Fpublic.h" /* Files */ +#include "H5Ipublic.h" /* IDs */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Objects */ +#include "H5Rpublic.h" /* References */ +#include "H5VLpublic.h" /* Virtual Object Layer */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Capability flags for connector */ +#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ +#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ + +/* Container info version */ +#define H5VL_CONTAINER_INFO_VERSION 0x01 /* Container info struct version */ + +/* The maximum size allowed for blobs */ +#define H5VL_MAX_BLOB_ID_SIZE (16) /* Allow for 128-bits blob IDs */ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* types for attribute GET callback */ +typedef enum H5VL_attr_get_t { + H5VL_ATTR_GET_ACPL, /* creation property list */ + H5VL_ATTR_GET_INFO, /* info */ + H5VL_ATTR_GET_NAME, /* access property list */ + H5VL_ATTR_GET_SPACE, /* dataspace */ + H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */ + H5VL_ATTR_GET_TYPE /* datatype */ +} H5VL_attr_get_t; + +/* types for attribute SPECFIC callback */ +typedef enum H5VL_attr_specific_t { + H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ + H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ + H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ + H5VL_ATTR_RENAME /* H5Arename(_by_name) */ +} H5VL_attr_specific_t; + +/* Typedef for VOL connector attribute optional VOL operations */ +typedef int H5VL_attr_optional_t; + +/* types for dataset GET callback */ +typedef enum H5VL_dataset_get_t { + H5VL_DATASET_GET_DAPL, /* access property list */ + H5VL_DATASET_GET_DCPL, /* creation property list */ + H5VL_DATASET_GET_SPACE, /* dataspace */ + H5VL_DATASET_GET_SPACE_STATUS, /* space status */ + H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ + H5VL_DATASET_GET_TYPE /* datatype */ +} H5VL_dataset_get_t; + +/* types for dataset SPECFIC callback */ +typedef enum H5VL_dataset_specific_t { + H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */ + H5VL_DATASET_FLUSH, /* H5Dflush */ + H5VL_DATASET_REFRESH /* H5Drefresh */ +} H5VL_dataset_specific_t; + +/* Typedef for VOL connector dataset optional VOL operations */ +typedef int H5VL_dataset_optional_t; + +/* types for datatype GET callback */ +typedef enum H5VL_datatype_get_t { + H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ + H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ +} H5VL_datatype_get_t; + +/* types for datatype SPECFIC callback */ +typedef enum H5VL_datatype_specific_t { H5VL_DATATYPE_FLUSH, H5VL_DATATYPE_REFRESH } H5VL_datatype_specific_t; + +/* Typedef and values for native VOL connector named datatype optional VOL operations */ +typedef int H5VL_datatype_optional_t; +/* (No optional named datatype VOL operations currently) */ + +/* types for file GET callback */ +typedef enum H5VL_file_get_t { + H5VL_FILE_GET_CONT_INFO, /* file get container info */ + H5VL_FILE_GET_FAPL, /* file access property list */ + H5VL_FILE_GET_FCPL, /* file creation property list */ + H5VL_FILE_GET_FILENO, /* file number */ + H5VL_FILE_GET_INTENT, /* file intent */ + H5VL_FILE_GET_NAME, /* file name */ + H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ + H5VL_FILE_GET_OBJ_IDS /* object ids in file */ +} H5VL_file_get_t; + +/* types for file SPECIFIC callback */ +typedef enum H5VL_file_specific_t { + H5VL_FILE_FLUSH, /* Flush file */ + H5VL_FILE_REOPEN, /* Reopen the file */ + H5VL_FILE_MOUNT, /* Mount a file */ + H5VL_FILE_UNMOUNT, /* Unmount a file */ + H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ + H5VL_FILE_DELETE, /* Delete a file */ + H5VL_FILE_IS_EQUAL /* Check if two files are the same */ +} H5VL_file_specific_t; + +/* Typedef for VOL connector file optional VOL operations */ +typedef int H5VL_file_optional_t; + +/* types for group GET callback */ +typedef enum H5VL_group_get_t { + H5VL_GROUP_GET_GCPL, /* group creation property list */ + H5VL_GROUP_GET_INFO /* group info */ +} H5VL_group_get_t; + +/* types for group SPECFIC callback */ +typedef enum H5VL_group_specific_t { H5VL_GROUP_FLUSH, H5VL_GROUP_REFRESH } H5VL_group_specific_t; + +/* Typedef for VOL connector group optional VOL operations */ +typedef int H5VL_group_optional_t; + +/* link create types for VOL */ +typedef enum H5VL_link_create_type_t { + H5VL_LINK_CREATE_HARD, + H5VL_LINK_CREATE_SOFT, + H5VL_LINK_CREATE_UD +} H5VL_link_create_type_t; + +/* types for link GET callback */ +typedef enum H5VL_link_get_t { + H5VL_LINK_GET_INFO, /* link info */ + H5VL_LINK_GET_NAME, /* link name */ + H5VL_LINK_GET_VAL /* link value */ +} H5VL_link_get_t; + +/* types for link SPECIFIC callback */ +typedef enum H5VL_link_specific_t { + H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ + H5VL_LINK_EXISTS, /* link existence */ + H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ +} H5VL_link_specific_t; + +/* Typedef and values for native VOL connector link optional VOL operations */ +typedef int H5VL_link_optional_t; +/* (No optional link VOL operations currently) */ + +/* types for object GET callback */ +typedef enum H5VL_object_get_t { + H5VL_OBJECT_GET_FILE, /* object file */ + H5VL_OBJECT_GET_NAME, /* object name */ + H5VL_OBJECT_GET_TYPE, /* object type */ + H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ +} H5VL_object_get_t; + +/* types for object SPECIFIC callback */ +typedef enum H5VL_object_specific_t { + H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ + H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ + H5VL_OBJECT_LOOKUP, /* Lookup object */ + H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ + H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */ + H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */ +} H5VL_object_specific_t; + +/* Typedef for VOL connector object optional VOL operations */ +typedef int H5VL_object_optional_t; + +/* types for async request SPECIFIC callback */ +typedef enum H5VL_request_specific_t { + H5VL_REQUEST_WAITANY, /* Wait until any request completes */ + H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */ + H5VL_REQUEST_WAITALL /* Wait until all requests complete */ +} H5VL_request_specific_t; + +/* Typedef and values for native VOL connector request optional VOL operations */ +typedef int H5VL_request_optional_t; +/* (No optional request VOL operations currently) */ + +/* types for 'blob' SPECIFIC callback */ +typedef enum H5VL_blob_specific_t { + H5VL_BLOB_DELETE, /* Delete a blob (by ID) */ + H5VL_BLOB_GETSIZE, /* Get size of blob */ + H5VL_BLOB_ISNULL, /* Check if a blob ID is "null" */ + H5VL_BLOB_SETNULL /* Set a blob ID to the connector's "null" blob ID value */ +} H5VL_blob_specific_t; + +/* Typedef and values for native VOL connector blob optional VOL operations */ +typedef int H5VL_blob_optional_t; +/* (No optional blob VOL operations currently) */ + +/* Types for different ways that objects are located in an HDF5 container */ +typedef enum H5VL_loc_type_t { + H5VL_OBJECT_BY_SELF, + H5VL_OBJECT_BY_NAME, + H5VL_OBJECT_BY_IDX, + H5VL_OBJECT_BY_TOKEN +} H5VL_loc_type_t; + +typedef struct H5VL_loc_by_name { + const char *name; + hid_t lapl_id; +} H5VL_loc_by_name_t; + +typedef struct H5VL_loc_by_idx { + const char * name; + H5_index_t idx_type; + H5_iter_order_t order; + hsize_t n; + hid_t lapl_id; +} H5VL_loc_by_idx_t; + +typedef struct H5VL_loc_by_token { + H5O_token_t *token; +} H5VL_loc_by_token_t; + +/* Structure to hold parameters for object locations. + * Either: BY_SELF, BY_NAME, BY_IDX, BY_TOKEN + * + * Note: Leave loc_by_token as the first union member so we + * can perform the simplest initialization of the struct + * without raising warnings. + * + * Note: BY_SELF requires no union members. + */ +typedef struct H5VL_loc_params_t { + H5I_type_t obj_type; + H5VL_loc_type_t type; + union { + H5VL_loc_by_token_t loc_by_token; + H5VL_loc_by_name_t loc_by_name; + H5VL_loc_by_idx_t loc_by_idx; + } loc_data; +} H5VL_loc_params_t; + +/* Info for H5VL_FILE_GET_CONT_INFO */ +typedef struct H5VL_file_cont_info_t { + unsigned version; /* version information (keep first) */ + uint64_t feature_flags; /* Container feature flags */ + /* (none currently defined) */ + size_t token_size; /* Size of tokens */ + size_t blob_id_size; /* Size of blob IDs */ +} H5VL_file_cont_info_t; + +/* VOL connector info fields & callbacks */ +typedef struct H5VL_info_class_t { + size_t size; /* Size of the VOL info */ + void *(*copy)(const void *info); /* Callback to create a copy of the VOL info */ + herr_t (*cmp)(int *cmp_value, const void *info1, const void *info2); /* Callback to compare VOL info */ + herr_t (*free)(void *info); /* Callback to release a VOL info */ + herr_t (*to_str)(const void *info, char **str); /* Callback to serialize connector's info into a string */ + herr_t (*from_str)(const char *str, + void ** info); /* Callback to deserialize a string into connector's info */ +} H5VL_info_class_t; + +/* VOL object wrap / retrieval callbacks */ +/* (These only need to be implemented by "pass through" VOL connectors) */ +typedef struct H5VL_wrap_class_t { + void *(*get_object)(const void *obj); /* Callback to retrieve underlying object */ + herr_t (*get_wrap_ctx)( + const void *obj, + void ** wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */ + void *(*wrap_object)(void *obj, H5I_type_t obj_type, + void *wrap_ctx); /* Callback to wrap a library object */ + void *(*unwrap_object)(void *obj); /* Callback to unwrap a library object */ + herr_t (*free_wrap_ctx)( + void *wrap_ctx); /* Callback to release the object wrapping context for the connector */ +} H5VL_wrap_class_t; + +/* H5A routines */ +typedef struct H5VL_attr_class_t { + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, + hid_t dxpl_id, void **req); + herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); + herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *attr, hid_t dxpl_id, void **req); +} H5VL_attr_class_t; + +/* H5D routines */ +typedef struct H5VL_dataset_class_t { + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, + hid_t dxpl_id, void **req); + herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + void *buf, void **req); + herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, + const void *buf, void **req); + herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *dset, hid_t dxpl_id, void **req); +} H5VL_dataset_class_t; + +/* H5T routines*/ +typedef struct H5VL_datatype_class_t { + void *(*commit)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, + hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *dt, hid_t dxpl_id, void **req); +} H5VL_datatype_class_t; + +/* H5F routines */ +typedef struct H5VL_file_class_t { + void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req); + void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *file, hid_t dxpl_id, void **req); +} H5VL_file_class_t; + +/* H5G routines */ +typedef struct H5VL_group_class_t { + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, + hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*optional)(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); + herr_t (*close)(void *grp, hid_t dxpl_id, void **req); +} H5VL_group_class_t; + +/* H5L routines */ +typedef struct H5VL_link_class_t { + herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req); + herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); +} H5VL_link_class_t; + +/* H5O routines */ +typedef struct H5VL_object_class_t { + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, + void **req); + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, + hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); +} H5VL_object_class_t; + +/* Asynchronous request 'notify' callback */ +typedef herr_t (*H5VL_request_notify_t)(void *ctx, H5ES_status_t status); + +/* "Levels" for 'get connector class' introspection callback */ +typedef enum H5VL_get_conn_lvl_t { + H5VL_GET_CONN_LVL_CURR, /* Get "current" connector (for this object) */ + H5VL_GET_CONN_LVL_TERM /* Get "terminal" connector (for this object) */ + /* (Recursively called, for pass-through connectors) */ + /* (Connectors that "split" must choose which connector to return) */ +} H5VL_get_conn_lvl_t; + +/* Forward declaration of H5VL_class_t, defined later in this file */ +struct H5VL_class_t; + +/* Container/connector introspection routines */ +typedef struct H5VL_introspect_class_t { + herr_t (*get_conn_cls)(void *obj, H5VL_get_conn_lvl_t lvl, const struct H5VL_class_t **conn_cls); + herr_t (*opt_query)(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported); +} H5VL_introspect_class_t; + +/* Async request operation routines */ +typedef struct H5VL_request_class_t { + herr_t (*wait)(void *req, uint64_t timeout, H5ES_status_t *status); + herr_t (*notify)(void *req, H5VL_request_notify_t cb, void *ctx); + herr_t (*cancel)(void *req); + herr_t (*specific)(void *req, H5VL_request_specific_t specific_type, va_list arguments); + herr_t (*optional)(void *req, H5VL_request_optional_t opt_type, va_list arguments); + herr_t (*free)(void *req); +} H5VL_request_class_t; + +/* 'blob' routines */ +typedef struct H5VL_blob_class_t { + herr_t (*put)(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); + herr_t (*get)(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); + herr_t (*specific)(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); + herr_t (*optional)(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments); +} H5VL_blob_class_t; + +/* Object token routines */ +typedef struct H5VL_token_class_t { + herr_t (*cmp)(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value); + herr_t (*to_str)(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str); + herr_t (*from_str)(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token); +} H5VL_token_class_t; + +/** + * \ingroup H5VLDEV + * Class information for each VOL connector + */ +//! +typedef struct H5VL_class_t { + /* Overall connector fields & callbacks */ + unsigned version; /**< VOL connector class struct version # */ + H5VL_class_value_t value; /**< Value to identify connector */ + const char * name; /**< Connector name (MUST be unique!) */ + unsigned cap_flags; /**< Capability flags for connector */ + herr_t (*initialize)(hid_t vipl_id); /**< Connector initialization callback */ + herr_t (*terminate)(void); /**< Connector termination callback */ + + /* VOL framework */ + H5VL_info_class_t info_cls; /**< VOL info fields & callbacks */ + H5VL_wrap_class_t wrap_cls; /**< VOL object wrap / retrieval callbacks */ + + /* Data Model */ + H5VL_attr_class_t attr_cls; /**< Attribute (H5A*) class callbacks */ + H5VL_dataset_class_t dataset_cls; /**< Dataset (H5D*) class callbacks */ + H5VL_datatype_class_t datatype_cls; /**< Datatype (H5T*) class callbacks */ + H5VL_file_class_t file_cls; /**< File (H5F*) class callbacks */ + H5VL_group_class_t group_cls; /**< Group (H5G*) class callbacks */ + H5VL_link_class_t link_cls; /**< Link (H5L*) class callbacks */ + H5VL_object_class_t object_cls; /**< Object (H5O*) class callbacks */ + + /* Infrastructure / Services */ + H5VL_introspect_class_t introspect_cls; /**< Container/connector introspection class callbacks */ + H5VL_request_class_t request_cls; /**< Asynchronous request class callbacks */ + H5VL_blob_class_t blob_cls; /**< 'Blob' class callbacks */ + H5VL_token_class_t token_cls; /**< VOL connector object token class callbacks */ + + /* Catch-all */ + herr_t (*optional)(void *obj, int op_type, hid_t dxpl_id, void **req, + va_list arguments); /**< Optional callback */ +} H5VL_class_t; +//! + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper routines for VOL connector authors */ +/** + * \ingroup H5VLDEV + * \brief Registers a new VOL connector + * + * \param[in] cls A pointer to the plugin structure to register + * \vipl_id + * \return \hid_t{VOL connector} + * + * \details H5VLregister_connector() registers a new VOL connector as a member + * of the virtual object layer class. This VOL connector identifier is + * good until the library is closed or the connector is unregistered. + * + * \p vipl_id is either #H5P_DEFAULT or the identifier of a VOL + * initialization property list of class #H5P_VOL_INITIALIZE created + * with H5Pcreate(). When created, this property list contains no + * library properties. If a VOL connector author decides that + * initialization-specific data are needed, they can be added to the + * empty list and retrieved by the connector in the VOL connector's + * initialize callback. Use of the VOL initialization property list is + * uncommon, as most VOL-specific properties are added to the file + * access property list via the connector's API calls which set the + * VOL connector for the file open/create. For more information, see + * the \ref_vol_doc. + * + * H5VL_class_t is defined in H5VLconnector.h in the source code. It + * contains class information for each VOL connector: + * \snippet this H5VL_class_t_snip + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); +/** + * \ingroup H5VLDEV + */ +H5_DLL void *H5VLobject(hid_t obj_id); +/** + * \ingroup H5VLDEV + */ +H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); +/** + * \ingroup H5VLDEV + */ +H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); +/** + * \ingroup H5VLDEV + */ +H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); + +#ifdef __cplusplus +} +#endif + +#endif /* H5VLconnector_H */ diff --git a/src/H5VLconnector_passthru.h b/src/H5VLconnector_passthru.h new file mode 100644 index 00000000000..1b6715b0ba7 --- /dev/null +++ b/src/H5VLconnector_passthru.h @@ -0,0 +1,236 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for authoring VOL connectors + * which act as "passthrough" connectors that forward their API calls to + * an underlying connector. + * + * An example of this might be a logging connector, which creates log messages + * and then passes the call on to an underlying VOL connector. + * + * The functionality required to implement such a connector is specialized + * and non-trivial so it has been split into this header in an effort to keep + * the H5VLconnector.h header easier to understand. + */ + +#ifndef H5VLconnector_passthru_H +#define H5VLconnector_passthru_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ +#include "H5VLpublic.h" /* Virtual Object Layer */ + +/* Semi-public headers mainly for VOL connector authors */ +#include "H5VLconnector.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper routines for VOL connector authors */ +H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2); +H5_DLL hid_t H5VLwrap_register(void *obj, H5I_type_t type); +H5_DLL herr_t H5VLretrieve_lib_state(void **state); +H5_DLL herr_t H5VLrestore_lib_state(const void *state); +H5_DLL herr_t H5VLreset_lib_state(void); +H5_DLL herr_t H5VLfree_lib_state(void *state); + +/* Pass-through callbacks */ +H5_DLL void * H5VLget_object(void *obj, hid_t connector_id); +H5_DLL herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx); +H5_DLL void * H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx); +H5_DLL void * H5VLunwrap_object(void *obj, hid_t connector_id); +H5_DLL herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id); + +/* Public wrappers for generic callbacks */ +H5_DLL herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id); +H5_DLL herr_t H5VLterminate(hid_t connector_id); +H5_DLL herr_t H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags); +H5_DLL herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *conn_value); + +/* Public wrappers for info fields and callbacks */ +H5_DLL herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info); +H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2); +H5_DLL herr_t H5VLfree_connector_info(hid_t connector_id, void *vol_info); +H5_DLL herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str); +H5_DLL herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info); + +/* Public wrappers for attribute callbacks */ +H5_DLL void * H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, + hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for dataset callbacks */ +H5_DLL void * H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_dataset_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for named datatype callbacks */ +H5_DLL void * H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for file callbacks */ +H5_DLL void * H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for group callbacks */ +H5_DLL void * H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for link callbacks */ +H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); + +/* Public wrappers for object callbacks */ +H5_DLL void * H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, va_list arguments); + +/* Public wrappers for connector/container introspection callbacks */ +H5_DLL herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported); + +/* Public wrappers for asynchronous request callbacks */ +H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx); +H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id); +H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, + va_list arguments); +H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_request_optional_t opt_type, + va_list arguments); +H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id); + +/* Public wrappers for blob callbacks */ +H5_DLL herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, + void *ctx); +H5_DLL herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, size_t size, + void *ctx); +H5_DLL herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments); +H5_DLL herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments); + +/* Public wrappers for token callbacks */ +H5_DLL herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, + H5O_token_t *token); + +/* Public wrappers for generic 'optional' callback */ +H5_DLL herr_t H5VLoptional(void *obj, hid_t connector_id, int op_type, hid_t dxpl_id, void **req, + va_list arguments); + +#ifdef __cplusplus +} +#endif + +#endif /* H5VLconnector_passthru_H */ diff --git a/src/H5VLint.c b/src/H5VLint.c new file mode 100644 index 00000000000..774d160d5cd --- /dev/null +++ b/src/H5VLint.c @@ -0,0 +1,2480 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Mprivate.h" /* Maps */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/* VOL connectors */ +#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLpassthru.h" /* Pass-through VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Object wrapping context info */ +typedef struct H5VL_wrap_ctx_t { + unsigned rc; /* Ref. count for the # of times the context was set / reset */ + H5VL_t * connector; /* VOL connector for "outermost" class to start wrap */ + void * obj_wrap_ctx; /* "wrap context" for outermost connector */ +} H5VL_wrap_ctx_t; + +/* Information needed for iterating over the registered VOL connector hid_t IDs. + * The name or value of the new VOL connector that is being registered is + * stored in the name (or value) field and the found_id field is initialized to + * H5I_INVALID_HID (-1). If we find a VOL connector with the same name / value, + * we set the found_id field to the existing ID for return to the function. + */ +typedef struct { + /* IN */ + H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */ + union { + const char * name; /* The name of the VOL connector to check */ + H5VL_class_value_t value; /* The value of the VOL connector to check */ + } u; + + /* OUT */ + hid_t found_id; /* The connector ID, if we found a match */ +} H5VL_get_connector_ud_t; + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5VL__free_cls(H5VL_class_t *cls); +static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); +static herr_t H5VL__set_def_conn(void); +static void * H5VL__wrap_obj(void *obj, H5I_type_t obj_type); +static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, + hbool_t wrap_obj); +static int64_t H5VL__conn_inc_rc(H5VL_t *connector); +static int64_t H5VL__conn_dec_rc(H5VL_t *connector); +static void * H5VL__object(hid_t id, H5I_type_t obj_type); +static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* VOL ID class */ +static const H5I_class_t H5I_VOL_CLS[1] = {{ + H5I_VOL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5VL__free_cls /* Callback routine for closing objects of this class */ +}}; + +/* Declare a free list to manage the H5VL_class_t struct */ +H5FL_DEFINE_STATIC(H5VL_class_t); + +/* Declare a free list to manage the H5VL_t struct */ +H5FL_DEFINE(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_DEFINE(H5VL_object_t); + +/* Declare a free list to manage the H5VL_wrap_ctx_t struct */ +H5FL_DEFINE_STATIC(H5VL_wrap_ctx_t); + +/* Default VOL connector */ +static H5VL_connector_prop_t H5VL_def_conn_s = {-1, NULL}; + +/*------------------------------------------------------------------------- + * Function: H5VL_init_phase1 + * + * Purpose: Initialize the interface from some other package. This should + * be followed with a call to H5VL_init_phase2 after the H5P + * interface is completely set up, finish setting up the H5VL + * information. + * + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_init_phase1(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init_phase1() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_init_phase2 + * + * Purpose: Finish initializing the interface from some other package. + * + * Note: This is broken out as a separate routine to avoid a circular + * reference with the H5P package. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_init_phase2(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Initialize all packages for VOL-managed objects */ + if (H5T_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") + if (H5D_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") + if (H5F_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize file interface") + if (H5G_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize group interface") + if (H5A_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize attribute interface") + if (H5M_init() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface") + + /* Set up the default VOL connector in the default FAPL */ + if (H5VL__set_def_conn() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set default VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init_phase2() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__init_package + * + * Purpose: Initialize interface-specific information + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Initialize the atom group for the VL IDs */ + if (H5I_register_type(H5I_VOL_CLS) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__init_package() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_term_package + * + * Purpose: Terminate various H5VL objects + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +int +H5VL_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + if (H5VL_def_conn_s.connector_id > 0) { + /* Release the default VOL connector */ + (void)H5VL_conn_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector_id = -1; + H5VL_def_conn_s.connector_info = NULL; + n++; + } /* end if */ + else { + if (H5I_nmembers(H5I_VOL) > 0) { + /* Unregister all VOL connectors */ + (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); + n++; + } /* end if */ + else { + /* Destroy the VOL connector ID group */ + n += (H5I_dec_type_ref(H5I_VOL) > 0); + + /* Mark interface as closed */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } /* end else */ + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(n) +} /* end H5VL_term_package() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__free_cls + * + * Purpose: Frees a file VOL class struct and returns an indication of + * success. This function is used as the free callback for the + * virtual object layer object identifiers + * (c.f.: H5VL_init_interface). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__free_cls(H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(cls); + + /* Shut down the VOL connector */ + if (cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") + + /* Release the class */ + H5MM_xfree_const(cls->name); + H5FL_FREE(H5VL_class_t, cls); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__free_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_cb + * + * Purpose: Callback routine to search through registered VOLs + * + * Return: Success: H5_ITER_STOP if the class and op_data name + * members match. H5_ITER_CONT otherwise. + * Failure: Can't fail + * + * Programmer: Dana Robinson + * June 22, 2017 + * + *------------------------------------------------------------------------- + */ +static int +H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) +{ + H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */ + H5VL_class_t * cls = (H5VL_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + if (H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) { + if (0 == HDstrcmp(cls->name, op_data->u.name)) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end if */ + else { + HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind); + if (cls->value == op_data->u.value) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end else */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__set_def_conn + * + * Purpose: Parses a string that contains the default VOL connector for + * the library. + * + * Note: Usually from the environment variable "HDF5_VOL_CONNECTOR", + * but could be from elsewhere. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jordan Henderson + * November 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__set_def_conn(void) +{ + H5P_genplist_t *def_fapl; /* Default file access property list */ + H5P_genclass_t *def_fapclass; /* Default file access property class */ + const char * env_var; /* Environment variable for default VOL connector */ + char * buf = NULL; /* Buffer for tokenizing string */ + hid_t connector_id = -1; /* VOL conntector ID */ + void * vol_info = NULL; /* VOL connector info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(H5VL_def_conn_s.connector_id == (-1)); + HDassert(H5VL_def_conn_s.connector_info == NULL); + + /* Check for environment variable set */ + env_var = HDgetenv("HDF5_VOL_CONNECTOR"); + + /* Only parse the string if it's set */ + if (env_var && *env_var) { + char * lasts = NULL; /* Context pointer for strtok_r() call */ + const char *tok = NULL; /* Token from strtok_r call */ + htri_t connector_is_registered; /* Whether connector is already registered */ + + /* Duplicate the string to parse, as it is modified as we go */ + if (NULL == (buf = H5MM_strdup(env_var))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate memory for environment variable string") + + /* Get the first 'word' of the environment variable. + * If it's nothing (environment variable was whitespace) return error. + */ + if (NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "VOL connector environment variable set empty?") + + /* First, check to see if the connector is already registered */ + if ((connector_is_registered = H5VL__is_connector_registered_by_name(tok)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered") + else if (connector_is_registered) { + /* Retrieve the ID of the already-registered VOL connector */ + if ((connector_id = H5VL__get_connector_id_by_name(tok, FALSE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector ID") + } /* end else-if */ + else { + /* Check for VOL connectors that ship with the library */ + if (!HDstrcmp(tok, "native")) { + connector_id = H5VL_NATIVE; + if (H5I_inc_ref(connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") + } /* end if */ + else if (!HDstrcmp(tok, "pass_through")) { + connector_id = H5VL_PASSTHRU; + if (H5I_inc_ref(connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") + } /* end else-if */ + else { + /* Register the VOL connector */ + /* (NOTE: No provisions for vipl_id currently) */ + if ((connector_id = H5VL__register_connector_by_name(tok, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register connector") + } /* end else */ + } /* end else */ + + /* Was there any connector info specified in the environment variable? */ + if (NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if (H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") + + /* Set the default VOL connector */ + H5VL_def_conn_s.connector_id = connector_id; + H5VL_def_conn_s.connector_info = vol_info; + } /* end if */ + else { + /* Set the default VOL connector */ + H5VL_def_conn_s.connector_id = H5_DEFAULT_VOL; + H5VL_def_conn_s.connector_info = NULL; + + /* Increment the ref count on the default connector */ + if (H5I_inc_ref(H5VL_def_conn_s.connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount") + } /* end else */ + + /* Get default file access pclass */ + if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default file access property class ID") + + /* Change the default VOL for the default file access pclass */ + if (H5P_reset_vol_class(def_fapclass, &H5VL_def_conn_s) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, + "can't set default VOL connector for default file access property class") + + /* Get default file access plist */ + if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_VOL, H5E_BADATOM, FAIL, "can't find object for default fapl ID") + + /* Change the default VOL for the default FAPL */ + if (H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default FAPL") + +done: + /* Clean up on error */ + if (ret_value < 0) { + if (vol_info) + if (H5VL_free_connector_info(connector_id, vol_info) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info") + if (connector_id >= 0) + /* The H5VL_class_t struct will be freed by this function */ + if (H5I_dec_ref(connector_id) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") + } /* end if */ + + /* Clean up */ + H5MM_xfree(buf); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__set_def_conn() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__wrap_obj + * + * Purpose: Wraps a library object with possible VOL connector wrappers, to + * match the VOL connector stack for the file. + * + * Return: Success: Wrapped object pointer + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, October 7, 2018 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__wrap_obj(void *obj, H5I_type_t obj_type) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check arguments */ + HDassert(obj); + + /* Retrieve the VOL object wrapping context */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't get VOL object wrap context") + + /* If there is a VOL object wrapping context, wrap the object */ + if (vol_wrap_ctx) { + /* Wrap object, using the VOL callback */ + if (NULL == (ret_value = H5VL_wrap_object(vol_wrap_ctx->connector->cls, vol_wrap_ctx->obj_wrap_ctx, + obj, obj_type))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") + } /* end if */ + else + ret_value = obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__wrap_obj() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__new_vol_obj + * + * Purpose: Creates a new VOL object, to use when registering an ID. + * + * Return: Success: VOL object pointer + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, October 7, 2018 + * + *------------------------------------------------------------------------- + */ +static H5VL_object_t * +H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t wrap_obj) +{ + H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ + hbool_t conn_rc_incr = FALSE; /* Whether the VOL connector refcount has been incremented */ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check arguments */ + HDassert(object); + HDassert(vol_connector); + + /* Make sure type number is valid */ + if (type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && + type != H5I_GROUP && type != H5I_MAP) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid type number") + + /* Create the new VOL object */ + if (NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object") + new_vol_obj->connector = vol_connector; + if (wrap_obj) { + if (NULL == (new_vol_obj->data = H5VL__wrap_obj(object, type))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't wrap library object") + } /* end if */ + else + new_vol_obj->data = object; + new_vol_obj->rc = 1; + + /* Bump the reference count on the VOL connector */ + H5VL__conn_inc_rc(vol_connector); + conn_rc_incr = TRUE; + + /* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */ + if (H5I_DATATYPE == type) { + if (NULL == (ret_value = (H5VL_object_t *)H5T_construct_datatype(new_vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't construct datatype object") + } /* end if */ + else + ret_value = (H5VL_object_t *)new_vol_obj; + +done: + /* Cleanup on error */ + if (NULL == ret_value) { + if (conn_rc_incr && H5VL__conn_dec_rc(vol_connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__new_vol_obj() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_conn_copy + * + * Purpose: Copy VOL connector ID & info. + * + * Note: This is an "in-place" copy. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (connector_prop) { + /* Copy the connector ID & info, if there is one */ + if (connector_prop->connector_id > 0) { + /* Increment the reference count on connector ID and copy connector info */ + if (H5I_inc_ref(connector_prop->connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") + + /* Copy connector info, if it exists */ + if (connector_prop->connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + void * new_connector_info = NULL; /* Copy of connector info */ + + /* Retrieve the connector for the ID */ + if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop->connector_info) < + 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") + + /* Set the connector info to the copy */ + connector_prop->connector_info = new_connector_info; + } /* end if */ + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_conn_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_conn_free + * + * Purpose: Free VOL connector ID & info. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (connector_prop) { + /* Free the connector info (if it exists) and decrement the ID */ + if (connector_prop->connector_id > 0) { + if (connector_prop->connector_info) + /* Free the connector info */ + if (H5VL_free_connector_info(connector_prop->connector_id, connector_prop->connector_info) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + + /* Decrement reference count for connector ID */ + if (H5I_dec_ref(connector_prop->connector_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_conn_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_register + * + * Purpose: VOL-aware version of H5I_register. Constructs an H5VL_object_t + * from the passed-in object and registers that. Does the right + * thing with datatypes, which are complicated under the VOL. + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref) +{ + H5VL_object_t *vol_obj = NULL; /* VOL object wrapper for library object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check arguments */ + HDassert(object); + HDassert(vol_connector); + + /* Set up VOL object for the passed-in data */ + /* (Does not wrap object, since it's from a VOL callback) */ + if (NULL == (vol_obj = H5VL__new_vol_obj(type, object, vol_connector, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") + + /* Register VOL object as _object_ type, for future object API calls */ + if ((ret_value = H5I_register(type, vol_obj, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_register_using_existing_id + * + * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. + * This routine will check to ensure the supplied ID is not already + * in use, and ensure that it is a valid ID for the given type, + * but will NOT check to ensure the OBJECT is not already + * registered (thus, it is possible to register one object under + * multiple IDs). + * + * NOTE: Intended for use in refresh calls, where we have to close + * and re-open the underlying data, then hook the VOL object back + * up to the original ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, + hid_t existing_id) +{ + H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(object); + HDassert(vol_connector); + + /* Set up VOL object for the passed-in data */ + /* (Wraps object, since it's a library object) */ + if (NULL == (new_vol_obj = H5VL__new_vol_obj(type, object, vol_connector, TRUE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") + + /* Call the underlying H5I function to complete the registration */ + if (H5I_register_using_existing_id(type, new_vol_obj, app_ref, existing_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register object under existing ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register_using_existing_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_register_using_vol_id + * + * Purpose: Utility function to create a user ID for an object created + * or opened through the VOL. Uses the VOL connector's ID to + * get the connector information instead of it being passed in. + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref) +{ + H5VL_class_t *cls = NULL; /* VOL connector class */ + H5VL_t * connector = NULL; /* VOL connector struct */ + hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Get the VOL class object from the connector's ID */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID") + + /* Setup VOL info struct */ + if (NULL == (connector = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate VOL info struct") + connector->cls = cls; + connector->id = connector_id; + if (H5I_inc_ref(connector->id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + conn_id_incr = TRUE; + + /* Get an ID for the VOL object */ + if ((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + +done: + /* Clean up on error */ + if (ret_value < 0) { + /* Decrement VOL connector ID ref count on error */ + if (conn_id_incr && H5I_dec_ref(connector_id) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector") + + /* Free VOL connector struct */ + if (NULL != connector) + connector = H5FL_FREE(H5VL_t, connector); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register_using_vol_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_create_object + * + * Purpose: Similar to H5VL_register but does not create an ID. + * Creates a new VOL object for the provided generic object + * using the provided vol connector. Should only be used for + * internal objects returned from the connector such as + * requests. + * + * Return: Success: A valid VOL object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5VL_create_object(void *object, H5VL_t *vol_connector) +{ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ + HDassert(object); + HDassert(vol_connector); + + /* Set up VOL object for the passed-in data */ + /* (Does not wrap object, since it's from a VOL callback) */ + if (NULL == (ret_value = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object") + ret_value->connector = vol_connector; + ret_value->data = object; + ret_value->rc = 1; + + /* Bump the reference count on the VOL connector */ + H5VL__conn_inc_rc(vol_connector); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_create_object() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_create_object_using_vol_id + * + * Purpose: Similar to H5VL_register_using_vol_id but does not create + * an id. Intended for use by internal library routines, + * therefore it wraps the object. + * + * Return: Success: VOL object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) +{ + H5VL_class_t * cls = NULL; /* VOL connector class */ + H5VL_t * connector = NULL; /* VOL connector struct */ + hbool_t conn_id_incr = FALSE; /* Whether the VOL connector ID has been incremented */ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the VOL class object from the connector's ID */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Setup VOL info struct */ + if (NULL == (connector = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL info struct") + connector->cls = cls; + connector->id = connector_id; + if (H5I_inc_ref(connector->id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL connector") + conn_id_incr = TRUE; + + /* Set up VOL object for the passed-in data */ + /* (Wraps object, since it's a library object) */ + if (NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, TRUE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't create VOL object") + +done: + /* Clean up on error */ + if (!ret_value) { + /* Decrement VOL connector ID ref count on error */ + if (conn_id_incr && H5I_dec_ref(connector_id) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") + + /* Free VOL connector struct */ + if (NULL != connector) + connector = H5FL_FREE(H5VL_t, connector); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_create_object_using_vol_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__conn_inc_rc + * + * Purpose: Wrapper to increment the ref. count on a connector. + * + * Return: Current ref. count (can't fail) + * + * Programmer: Quincey Koziol + * February 23, 2019 + * + *------------------------------------------------------------------------- + */ +static int64_t +H5VL__conn_inc_rc(H5VL_t *connector) +{ + FUNC_ENTER_STATIC_NOERR + + /* Check arguments */ + HDassert(connector); + + /* Increment refcount for connector */ + connector->nrefs++; + + FUNC_LEAVE_NOAPI(connector->nrefs) +} /* end H5VL__conn_inc_rc() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__conn_dec_rc + * + * Purpose: Wrapper to decrement the ref. count on a connector. + * + * Return: Current ref. count (>=0) on success, <0 on failure + * + * Programmer: Quincey Koziol + * February 23, 2019 + * + *------------------------------------------------------------------------- + */ +static int64_t +H5VL__conn_dec_rc(H5VL_t *connector) +{ + int64_t ret_value = -1; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check arguments */ + HDassert(connector); + + /* Decrement refcount for connector */ + connector->nrefs--; + + /* Check for last reference */ + if (0 == connector->nrefs) { + if (H5I_dec_ref(connector->id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + H5FL_FREE(H5VL_t, connector); + + /* Set return value */ + ret_value = 0; + } /* end if */ + else + /* Set return value */ + ret_value = connector->nrefs; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__conn_dec_rc() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_inc_rc + * + * Purpose: Wrapper to increment the ref count on a VOL object. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +hsize_t +H5VL_object_inc_rc(H5VL_object_t *vol_obj) +{ + FUNC_ENTER_NOAPI_NOERR_NOFS + + /* Check arguments */ + HDassert(vol_obj); + + /* Increment refcount for object and return */ + FUNC_LEAVE_NOAPI(++vol_obj->rc) +} /* end H5VL_object_inc_rc() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_free_object + * + * Purpose: Wrapper to unregister an object ID with a VOL aux struct + * and decrement ref count on VOL connector ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_object(H5VL_object_t *vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(vol_obj); + + if (--vol_obj->rc == 0) { + /* Decrement refcount on connector */ + if (H5VL__conn_dec_rc(vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + + vol_obj = H5FL_FREE(H5VL_object_t, vol_obj); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_object() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_is_native + * + * Purpose: Query if an object is (if it's a file object) / is in (if its + * an object) a native connector's file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 14, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native) +{ + const H5VL_class_t *cls; /* VOL connector class structs for object */ + const H5VL_class_t *native_cls; /* Native VOL connector class structs */ + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(obj); + HDassert(is_native); + + /* Retrieve the terminal connector class for the object */ + cls = NULL; + if (H5VL_introspect_get_conn_cls(obj, H5VL_GET_CONN_LVL_TERM, &cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") + + /* Retrieve the native connector class */ + if (NULL == (native_cls = (H5VL_class_t *)H5I_object_verify(H5VL_NATIVE, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve native VOL connector class") + + /* Compare connector classes */ + if (H5VL_cmp_connector_cls(&cmp_value, cls, native_cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + + /* If classes compare equal, then the object is / is in a native connector's file */ + *is_native = (cmp_value == 0); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_is_native() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_file_is_same + * + * Purpose: Query if two files are the same. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * December 14, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, hbool_t *same_file) +{ + const H5VL_class_t *cls1; /* VOL connector class struct for first object */ + const H5VL_class_t *cls2; /* VOL connector class struct for second object */ + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(vol_obj1); + HDassert(vol_obj2); + HDassert(same_file); + + /* Retrieve the terminal connectors for each object */ + cls1 = NULL; + if (H5VL_introspect_get_conn_cls(vol_obj1, H5VL_GET_CONN_LVL_TERM, &cls1) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") + cls2 = NULL; + if (H5VL_introspect_get_conn_cls(vol_obj2, H5VL_GET_CONN_LVL_TERM, &cls2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") + + /* Compare connector classes */ + if (H5VL_cmp_connector_cls(&cmp_value, cls1, cls2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + + /* If the connector classes are different, the files are different */ + if (cmp_value) + *same_file = FALSE; + else { + void *obj2; /* Terminal object for second file */ + + /* Get unwrapped (terminal) object for vol_obj2 */ + if (NULL == (obj2 = H5VL_object_data(vol_obj2))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get unwrapped object") + + /* Make callback */ + if (H5VL_file_specific(vol_obj1, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, obj2, + same_file) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_is_same() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__register_connector + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is unregistered. + * + * Failure: H5I_INVALID_HID + * + * Programmer: Dana Robinson + * June 22, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) +{ + const H5VL_class_t *cls = (const H5VL_class_t *)_cls; + H5VL_class_t * saved = NULL; + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + HDassert(cls); + + /* Copy the class structure so the caller can reuse or free it */ + if (NULL == (saved = H5FL_MALLOC(H5VL_class_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, + "memory allocation failed for VOL connector class struct") + H5MM_memcpy(saved, cls, sizeof(H5VL_class_t)); + if (NULL == (saved->name = H5MM_strdup(cls->name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, + "memory allocation failed for VOL connector name") + + /* Initialize the VOL connector */ + if (cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to init VOL connector") + + /* Create the new class ID */ + if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") + +done: + if (ret_value < 0 && saved) { + if (saved->name) + H5MM_xfree_const(saved->name); + + H5FL_FREE(H5VL_class_t, saved); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__register_connector() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__register_connector_by_class + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + * Programmer: Dana Robinson + * June 22, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__register_connector_by_class(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (!cls) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "VOL connector class pointer cannot be NULL") + if (H5VL_VERSION != cls->version) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector has incompatible version") + if (!cls->name) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector class name cannot be the NULL pointer") + if (0 == HDstrlen(cls->name)) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector class name cannot be the empty string") + if (cls->info_cls.copy && !cls->info_cls.free) + HGOTO_ERROR( + H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector must provide free callback for VOL info objects when a copy callback is provided") + if (cls->wrap_cls.get_wrap_ctx && !cls->wrap_cls.free_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + "VOL connector must provide free callback for object wrapping contexts when a get " + "callback is provided") + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = cls->name; + op_data.found_id = H5I_INVALID_HID; + + /* Check if connector is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs") + + /* Increment the ref count on the existing VOL connector ID, if it's already registered */ + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") + ret_value = op_data.found_id; + } /* end if */ + else { + /* Create a new class ID */ + if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__register_connector_by_class() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__register_connector_by_name + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + * Programmer: Dana Robinson + * June 22, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; + op_data.found_id = H5I_INVALID_HID; + + /* Check if connector is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") + + /* If connector alread registered, increment ref count on ID and return ID */ + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") + ret_value = op_data.found_id; + } /* end if */ + else { + H5PL_key_t key; + const H5VL_class_t *cls; + + /* Try loading the connector */ + key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.u.name = name; + if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") + + /* Register the connector we loaded */ + if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__register_connector_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__register_connector_by_value + * + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. + * + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. + * + * Failure: H5I_INVALID_HID + * + * Programmer: Dana Robinson + * June 22, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Check if connector is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") + + /* If connector alread registered, increment ref count on ID and return ID */ + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, app_ref) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, + "unable to increment ref count on VOL connector") + ret_value = op_data.found_id; + } /* end if */ + else { + H5PL_key_t key; + const H5VL_class_t *cls; + + /* Try loading the connector */ + key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; + key.vol.u.value = value; + if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") + + /* Register the connector we loaded */ + if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__register_connector_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__is_connector_registered_by_name + * + * Purpose: Checks if a connector with a particular name is registered. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL__is_connector_registered_by_name(const char *name) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with name */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") + + /* Found a connector with that name */ + if (op_data.found_id != H5I_INVALID_HID) + ret_value = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__is_connector_registered_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__is_connector_registered_by_value + * + * Purpose: Checks if a connector with a particular value (ID) is + * registered. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL__is_connector_registered_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors") + + /* Found a connector with that name */ + if (op_data.found_id != H5I_INVALID_HID) + ret_value = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__is_connector_registered_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_id + * + * Purpose: Retrieves the VOL connector ID for a given object ID. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or not registered) + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id(hid_t obj_id, hbool_t is_api) +{ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get the underlying VOL object for the object ID */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Return the VOL object's VOL class ID */ + ret_value = vol_obj->connector->id; + if (H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_id_by_name + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or not registered) + * + * Programmer: Dana Robinson + * June 17, 2017 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id_by_name(const char *name, hbool_t is_api) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Find connector with name */ + if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") + + /* Found a connector with that name */ + if (H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Find connector with value */ + if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector") + + /* Found a connector with that value */ + if (H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_id_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_name + * + * Purpose: Retrieves the ID for a registered VOL connector. Does not + * increment the ref count + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__peek_connector_id_by_name(const char *name) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with name */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") + + /* Set return value */ + ret_value = op_data.found_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__peek_connector_id_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__peek_connector_id_by_value + * + * Purpose: Retrieves the ID for a registered VOL connector. Does not + * increment the ref count + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or + * not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__peek_connector_id_by_value(H5VL_class_value_t value) +{ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Set up op data for iteration */ + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find connector with value */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors") + + /* Set return value */ + ret_value = op_data.found_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__peek_connector_id_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__connector_str_to_info + * + * Purpose: Deserializes a string into a connector's info object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * March 2, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Only deserialize string, if it's non-NULL */ + if (str) { + H5VL_class_t *cls; /* VOL connector's class struct */ + + /* Check args and get class pointer */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allow the connector to deserialize info */ + if (cls->info_cls.from_str) { + if ((cls->info_cls.from_str)(str, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info") + } /* end if */ + else + *info = NULL; + } /* end if */ + else + *info = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__connector_str_to_info() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__get_connector_name + * + * Purpose: Private version of H5VLget_connector_name + * + * Return: Success: The length of the connector name + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size) +{ + H5VL_object_t * vol_obj; + const H5VL_class_t *cls; + size_t len; + ssize_t ret_value = -1; + + FUNC_ENTER_PACKAGE + + /* get the object pointer */ + if (NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid VOL identifier") + + cls = vol_obj->connector->cls; + + len = HDstrlen(cls->name); + if (name) { + HDstrncpy(name, cls->name, MIN(len + 1, size)); + if (len >= size) + name[size - 1] = '\0'; + } /* end if */ + + /* Set the return value for the API call */ + ret_value = (ssize_t)len; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_connector_name() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_vol_object + * + * Purpose: Utility function to return the object pointer associated with + * a hid_t. This routine is the same as H5I_object for all types + * except for named datatypes, where the vol_obj is returned that + * is attached to the H5T_t struct. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5VL_vol_object(hid_t id) +{ + void * obj = NULL; + H5I_type_t obj_type; + H5VL_object_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + obj_type = H5I_get_type(id); + if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || H5I_DATASET == obj_type || + H5I_DATATYPE == obj_type) { + /* Get the object */ + if (NULL == (obj = H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + /* If this is a datatype, get the VOL object attached to the H5T_t struct */ + if (H5I_DATATYPE == obj_type) + if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function") + + ret_value = (H5VL_object_t *)obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_vol_object() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_data + * + * Purpose: Correctly retrieve the 'data' field for a VOL object (H5VL_object), + * even for nested / stacked VOL connectors. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_data(const H5VL_object_t *vol_obj) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check for 'get_object' callback in connector */ + if (vol_obj->connector->cls->wrap_cls.get_object) + ret_value = (vol_obj->connector->cls->wrap_cls.get_object)(vol_obj->data); + else + ret_value = vol_obj->data; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_data() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_unwrap + * + * Purpose: Correctly unwrap the 'data' field for a VOL object (H5VL_object), + * even for nested / stacked VOL connectors. + * + * Return: Success: Object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_unwrap(const H5VL_object_t *vol_obj) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + if (NULL == (ret_value = H5VL_unwrap_object(vol_obj->connector->cls, vol_obj->data))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_unwrap() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__object + * + * Purpose: Internal function to return the VOL object pointer associated + * with an hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__object(hid_t id, H5I_type_t obj_type) +{ + H5VL_object_t *vol_obj = NULL; + void * ret_value = NULL; + + FUNC_ENTER_STATIC + + /* Get the underlying object */ + switch (obj_type) { + case H5I_GROUP: + case H5I_DATASET: + case H5I_FILE: + case H5I_ATTR: + case H5I_MAP: + /* get the object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + break; + + case H5I_DATATYPE: { + H5T_t *dt = NULL; + + /* get the object */ + if (NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + /* Get the actual datatype object that should be the vol_obj */ + if (NULL == (vol_obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + break; + } + + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + 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_ARGS, H5E_BADTYPE, NULL, "unknown data object type") + } /* end switch */ + + /* Set the return value */ + ret_value = H5VL_object_data(vol_obj); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object + * + * Purpose: Utility function to return the VOL object pointer associated with + * a hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object(hid_t id) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Get the underlying object */ + if (NULL == (ret_value = H5VL__object(id, H5I_get_type(id)))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't retrieve object for ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_object_verify + * + * Purpose: Utility function to return the VOL object pointer associated + * with an identifier. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_verify(hid_t id, H5I_type_t obj_type) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Check of ID of correct type */ + if (obj_type != H5I_get_type(id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + /* Get the underlying object */ + if (NULL == (ret_value = H5VL__object(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "can't retrieve object for ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_verify() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_cmp_connector_cls + * + * Purpose: Compare VOL class for a connector + * + * Note: Sets *cmp_value positive if VALUE1 is greater than VALUE2, + * negative if VALUE2 is greater than VALUE1, and zero if VALUE1 + * and VALUE2 are equal (like strcmp). + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cls1); + HDassert(cls2); + + /* If the pointers are the same the classes are the same */ + if (cls1 == cls2) { + *cmp_value = 0; + HGOTO_DONE(SUCCEED); + } /* end if */ + + /* Compare connector "values" */ + if (cls1->value < cls2->value) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if (cls1->value > cls2->value) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->value == cls2->value); + + /* Compare connector names */ + if (cls1->name == NULL && cls2->name != NULL) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if (cls1->name != NULL && cls2->name == NULL) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if (0 != (*cmp_value = HDstrcmp(cls1->name, cls2->name))) + HGOTO_DONE(SUCCEED) + + /* Compare connector VOL API versions */ + if (cls1->version < cls2->version) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if (cls1->version > cls2->version) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->version == cls2->version); + + /* Compare connector info */ + if (cls1->info_cls.size < cls2->info_cls.size) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if (cls1->info_cls.size > cls2->info_cls.size) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->info_cls.size == cls2->info_cls.size); + + /* Set comparison value to 'equal' */ + *cmp_value = 0; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_cmp_connector_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_retrieve_lib_state + * + * Purpose: Retrieve the state of the library. + * + * Note: Currently just retrieves the API context state, but could be + * expanded in the future. + * + * Return: Success: Non-negative, *state set + * Failure: Negative, *state unset + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_retrieve_lib_state(void **state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(state); + + /* Retrieve the API context state */ + if (H5CX_retrieve_state((H5CX_state_t **)state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get API context state") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_retrieve_lib_state() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_restore_lib_state + * + * Purpose: Restore the state of the library. + * + * Note: Currently just restores the API context state, but could be + * expanded in the future. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, January 10, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_restore_lib_state(const void *state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(state); + + /* Push a new API context on the stack */ + if (H5CX_push() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't push API context") + + /* Restore the API context state */ + if (H5CX_restore_state((const H5CX_state_t *)state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context state") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_restore_lib_state() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_reset_lib_state + * + * Purpose: Reset the state of the library, undoing affects of + * H5VL_restore_lib_state. + * + * Note: Currently just resets the API context state, but could be + * expanded in the future. + * + * Note: This routine must be called as a "pair" with + * H5VL_restore_lib_state. It can be called before / after / + * independently of H5VL_free_lib_state. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Saturday, February 23, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_reset_lib_state(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Pop the API context off the stack */ + if (H5CX_pop() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't pop API context") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_reset_lib_state() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_free_lib_state + * + * Purpose: Free a library state. + * + * Note: This routine must be called as a "pair" with + * H5VL_retrieve_lib_state. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Thursday, January 10, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_lib_state(void *state) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(state); + + /* Free the API context state */ + if (H5CX_free_state((H5CX_state_t *)state) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free API context state") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_lib_state() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__free_vol_wrapper + * + * Purpose: Free object wrapping context for VOL connector + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Wednesday, January 9, 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(vol_wrap_ctx); + HDassert(0 == vol_wrap_ctx->rc); + HDassert(vol_wrap_ctx->connector); + HDassert(vol_wrap_ctx->connector->cls); + + /* If there is a VOL connector object wrapping context, release it */ + if (vol_wrap_ctx->obj_wrap_ctx) + /* Release the VOL connector's object wrapping context */ + if ((*vol_wrap_ctx->connector->cls->wrap_cls.free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, + "unable to release connector's object wrapping context") + + /* Decrement refcount on connector */ + if (H5VL__conn_dec_rc(vol_wrap_ctx->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + + /* Release object wrapping context */ + H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__free_vol_wrapper() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_set_vol_wrapper + * + * Purpose: Set up object wrapping context for current VOL connector + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Retrieve the VOL object wrap context */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + + /* Check for existing wrapping context */ + if (NULL == vol_wrap_ctx) { + void *obj_wrap_ctx = NULL; /* VOL connector's wrapping context */ + + /* Sanity checks */ + HDassert(vol_obj->data); + HDassert(vol_obj->connector); + + /* Check if the connector can create a wrap context */ + if (vol_obj->connector->cls->wrap_cls.get_wrap_ctx) { + /* Sanity check */ + HDassert(vol_obj->connector->cls->wrap_cls.free_wrap_ctx); + + /* Get the wrap context from the connector */ + if ((vol_obj->connector->cls->wrap_cls.get_wrap_ctx)(vol_obj->data, &obj_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve VOL connector's object wrap context") + } /* end if */ + + /* Allocate VOL object wrapper context */ + if (NULL == (vol_wrap_ctx = H5FL_MALLOC(H5VL_wrap_ctx_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate VOL wrap context") + + /* Increment the outstanding objects that are using the connector */ + H5VL__conn_inc_rc(vol_obj->connector); + + /* Set up VOL object wrapper context */ + vol_wrap_ctx->rc = 1; + vol_wrap_ctx->connector = vol_obj->connector; + vol_wrap_ctx->obj_wrap_ctx = obj_wrap_ctx; + } /* end if */ + else + /* Incremeent ref count on existing wrapper context */ + vol_wrap_ctx->rc++; + + /* Save the wrapper context */ + if (H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + +done: + if (ret_value < 0 && vol_wrap_ctx) + /* Release object wrapping context */ + H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_set_vol_wrapper() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_inc_vol_wrapper + * + * Purpose: Increment refcount on object wrapping context + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Wednesday, January 9, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_inc_vol_wrapper(void *_vol_wrap_ctx) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check for valid, active VOL object wrap context */ + if (NULL == vol_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") + if (0 == vol_wrap_ctx->rc) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?") + + /* Increment ref count on wrapping context */ + vol_wrap_ctx->rc++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_inc_vol_wrapper() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_dec_vol_wrapper + * + * Purpose: Decrement refcount on object wrapping context, releasing it + * if the refcount drops to zero. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Wednesday, January 9, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dec_vol_wrapper(void *_vol_wrap_ctx) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = (H5VL_wrap_ctx_t *)_vol_wrap_ctx; /* VOL object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check for valid, active VOL object wrap context */ + if (NULL == vol_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") + if (0 == vol_wrap_ctx->rc) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "bad VOL object wrap context refcount?") + + /* Decrement ref count on wrapping context */ + vol_wrap_ctx->rc--; + + /* Release context if the ref count drops to zero */ + if (0 == vol_wrap_ctx->rc) + if (H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dec_vol_wrapper() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_reset_vol_wrapper + * + * Purpose: Reset object wrapping context for current VOL connector + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_reset_vol_wrapper(void) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Retrieve the VOL object wrap context */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + + /* Check for VOL object wrap context */ + if (NULL == vol_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") + + /* Decrement ref count on wrapping context */ + vol_wrap_ctx->rc--; + + /* Release context if the ref count drops to zero */ + if (0 == vol_wrap_ctx->rc) { + /* Release object wrapping context */ + if (H5VL__free_vol_wrapper(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL object wrapping context") + + /* Reset the wrapper context */ + if (H5CX_set_vol_wrap_ctx(NULL) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + } /* end if */ + else + /* Save the updated wrapper context */ + if (H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_reset_vol_wrapper() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_wrap_register + * + * Purpose: Wrap an object and register an ID for it + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void * new_obj; /* Newly wrapped object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Sanity check */ + HDassert(obj); + + /* Retrieve the VOL object wrapping context */ + if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context") + if (NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, + "VOL object wrap context or its connector is NULL???") + + /* If the datatype is already VOL-managed, the datatype's vol_obj + * field will get clobbered later, so disallow this. + */ + if (type == H5I_DATATYPE) + if (vol_wrap_ctx->connector->id == H5VL_NATIVE) + if (TRUE == H5T_already_vol_managed((const H5T_t *)obj)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype") + + /* Wrap the object with VOL connector info */ + if (NULL == (new_obj = H5VL__wrap_obj(obj, type))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object") + + /* Get an ID for the object */ + if ((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_wrap_register() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_check_plugin_load + * + * Purpose: Check if a VOL connector matches the search criteria, and + * can be loaded. + * + * Note: Matching the connector's name / value, but the connector + * having an incompatible version is not an error, but means + * that the connector isn't a "match". Setting the SUCCEED + * value to FALSE and not failing for that case allows the + * plugin framework to keep looking for other DLLs that match + * and have a compatible version. + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t *success) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cls); + HDassert(key); + HDassert(success); + + /* Which kind of key are we looking for? */ + if (key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { + /* Check if plugin name matches VOL connector class name */ + if (cls->name && !HDstrcmp(cls->name, key->vol.u.name)) + *success = TRUE; + } /* end if */ + else { + /* Sanity check */ + HDassert(key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE); + + /* Check if plugin value matches VOL connector class value */ + if (cls->value == key->vol.u.value) + *success = TRUE; + } /* end else */ + + /* Connector is a match, but might not be a compatible version */ + if (*success && cls->version != H5VL_VERSION) + *success = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_check_plugin_load() */ diff --git a/src/H5VLmodule.h b/src/H5VLmodule.h new file mode 100644 index 00000000000..78c59862235 --- /dev/null +++ b/src/H5VLmodule.h @@ -0,0 +1,45 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which define macros for the + * H5VL package. Including this header means that the source file + * is part of the H5VL package. + */ + +#ifndef H5VLmodule_H +#define H5VLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5VL_MODULE +#define H5_MY_PKG H5VL +#define H5_MY_PKG_ERR H5E_VOL +#define H5_MY_PKG_INIT YES + +/** + * \defgroup H5VL H5VL + * \brief Virtual Object Layer Interface + * \todo Describe concisely what the functions in this module are about. + * + * \defgroup H5VLDEF Definitions + * \ingroup H5VL + * \defgroup H5VLDEV VOL Developer + * \ingroup H5VL + * \defgroup H5VLNAT Native VOL + * \ingroup H5VL + * \defgroup H5VLPT Pass-through VOL + * \ingroup H5VL + */ + +#endif /* H5VLmodule_H */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c new file mode 100644 index 00000000000..48c5a803a12 --- /dev/null +++ b/src/H5VLnative.c @@ -0,0 +1,573 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The native VOL connector where access is to a single HDF5 file + * using HDF5 VFDs. + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5VL_FRIEND /* Suppress error about including H5VLpkg */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/* The VOL connector identification number */ +static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; + +/* Prototypes */ +static herr_t H5VL__native_term(void); + +/* Native VOL connector class struct */ +static const H5VL_class_t H5VL_native_cls_g = { + H5VL_VERSION, /* VOL class struct version */ + H5VL_NATIVE_VALUE, /* value */ + H5VL_NATIVE_NAME, /* name */ + 0, /* capability flags */ + NULL, /* initialize */ + H5VL__native_term, /* terminate */ + { + /* info_cls */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL /* str to info */ + }, + { + /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL /* free_wrap_ctx */ + }, + { + /* attribute_cls */ + H5VL__native_attr_create, /* create */ + H5VL__native_attr_open, /* open */ + H5VL__native_attr_read, /* read */ + H5VL__native_attr_write, /* write */ + H5VL__native_attr_get, /* get */ + H5VL__native_attr_specific, /* specific */ + H5VL__native_attr_optional, /* optional */ + H5VL__native_attr_close /* close */ + }, + { + /* dataset_cls */ + H5VL__native_dataset_create, /* create */ + H5VL__native_dataset_open, /* open */ + H5VL__native_dataset_read, /* read */ + H5VL__native_dataset_write, /* write */ + H5VL__native_dataset_get, /* get */ + H5VL__native_dataset_specific, /* specific */ + H5VL__native_dataset_optional, /* optional */ + H5VL__native_dataset_close /* close */ + }, + { + /* datatype_cls */ + H5VL__native_datatype_commit, /* commit */ + H5VL__native_datatype_open, /* open */ + H5VL__native_datatype_get, /* get */ + H5VL__native_datatype_specific, /* specific */ + NULL, /* optional */ + H5VL__native_datatype_close /* close */ + }, + { + /* file_cls */ + H5VL__native_file_create, /* create */ + H5VL__native_file_open, /* open */ + H5VL__native_file_get, /* get */ + H5VL__native_file_specific, /* specific */ + H5VL__native_file_optional, /* optional */ + H5VL__native_file_close /* close */ + }, + { + /* group_cls */ + H5VL__native_group_create, /* create */ + H5VL__native_group_open, /* open */ + H5VL__native_group_get, /* get */ + H5VL__native_group_specific, /* specific */ + H5VL__native_group_optional, /* optional */ + H5VL__native_group_close /* close */ + }, + { + /* link_cls */ + H5VL__native_link_create, /* create */ + H5VL__native_link_copy, /* copy */ + H5VL__native_link_move, /* move */ + H5VL__native_link_get, /* get */ + H5VL__native_link_specific, /* specific */ + NULL /* optional */ + }, + { + /* object_cls */ + H5VL__native_object_open, /* open */ + H5VL__native_object_copy, /* copy */ + H5VL__native_object_get, /* get */ + H5VL__native_object_specific, /* specific */ + H5VL__native_object_optional /* optional */ + }, + { + /* introspect_cls */ + H5VL__native_introspect_get_conn_cls, /* get_conn_cls */ + H5VL__native_introspect_opt_query, /* opt_query */ + }, + { + /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ + }, + { + /* blob_cls */ + H5VL__native_blob_put, /* put */ + H5VL__native_blob_get, /* get */ + H5VL__native_blob_specific, /* specific */ + NULL /* optional */ + }, + { + /* token_cls */ + H5VL__native_token_cmp, /* cmp */ + H5VL__native_token_to_str, /* to_str */ + H5VL__native_str_to_token /* from_str */ + }, + NULL /* optional */ +}; + +/*------------------------------------------------------------------------- + * Function: H5VL_native_register + * + * Purpose: Register the native VOL connector and retrieve an ID for it. + * + * Return: Success: The ID for the native connector + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_native_register(void) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Register the native VOL connector, if it isn't already */ + if (H5I_INVALID_HID == H5VL_NATIVE_ID_g) + if ((H5VL_NATIVE_ID_g = + H5VL__register_connector(&H5VL_native_cls_g, TRUE, H5P_VOL_INITIALIZE_DEFAULT)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector") + + /* Set return value */ + ret_value = H5VL_NATIVE_ID_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_register() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_term + * + * Purpose: Shut down the native VOL + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL__native_term(void) +{ + FUNC_ENTER_STATIC_NOERR + + /* Reset VOL ID */ + H5VL_NATIVE_ID_g = H5I_INVALID_HID; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__native_term() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_introspect_get_conn_cls + * + * Purpose: Query the connector class. + * + * Note: This routine is in this file so that it can return the address + * of the staticly declared class struct. + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_introspect_get_conn_cls(void H5_ATTR_UNUSED *obj, H5VL_get_conn_lvl_t H5_ATTR_UNUSED lvl, + const H5VL_class_t **conn_cls) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(conn_cls); + + /* Retrieve the native VOL connector class */ + *conn_cls = &H5VL_native_cls_g; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__native_introspect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_native_get_file_addr_len + * + * Purpose: Convenience function to get a file's address length from a + * location ID. Useful when you have to encode/decode addresses + * to/from tokens. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check arguments */ + HDassert(addr_len); + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if (NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve file address length */ + if (H5VL__native_get_file_addr_len(vol_obj, vol_obj_type, addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get file address length") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_get_file_addr_len() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_get_file_addr_len + * + * Purpose: Convenience function to get a file's address length from a + * VOL object. Useful when you have to encode/decode addresses + * to/from tokens. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len) +{ + H5F_t *file = NULL; /* File stuct pointer */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* check arguments */ + HDassert(obj); + HDassert(addr_len); + + /* Retrieve file from the VOL object */ + if (H5VL_native_get_file_struct(obj, obj_type, &file) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get file from VOL object") + + /* Get the length of an address in this file */ + *addr_len = H5F_SIZEOF_ADDR(file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_get_file_addr_len() */ + +/*------------------------------------------------------------------------- + * Function: H5VLnative_addr_to_token + * + * Purpose: Converts a native VOL haddr_t address to an abstract VOL token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ia*k", loc_id, addr, token); + + /* Check args */ + if (NULL == token) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "token pointer can't be NULL") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if (NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + +#ifndef NDEBUG + { + H5VL_object_t *vol_obj_container; + hbool_t is_native_vol_obj; + + /* Get the location object */ + if (NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL object is a native connector object */ + if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, + "can't determine if VOL object is native connector object") + + HDassert(is_native_vol_obj && "not a native VOL connector object"); + } +#endif + + /* Convert the haddr_t to an object token */ + if (H5VL_native_addr_to_token(vol_obj, vol_obj_type, addr, token) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "couldn't serialize haddr_t into object token") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLnative_addr_to_token() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_native_addr_to_token + * + * Purpose: Converts a native VOL haddr_t address to an abstract VOL token. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token) +{ + uint8_t *p; + size_t addr_len = 0; /* Size of haddr_t */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(obj); + HDassert(token); + + /* Get the length of an haddr_t in the file */ + if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") + + /* Ensure that token is initialized */ + HDmemset(token, 0, sizeof(H5O_token_t)); + + /* Encode token */ + p = (uint8_t *)token; + H5F_addr_encode_len(addr_len, &p, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_addr_to_token() */ + +/*------------------------------------------------------------------------- + * Function: H5VLnative_token_to_addr + * + * Purpose: Converts an abstract VOL token to a native VOL haddr_t address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr) +{ + H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ + void * vol_obj = NULL; /* VOL Object of loc_id */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ik*a", loc_id, token, addr); + + /* Check args */ + if (NULL == addr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr pointer can't be NULL") + + /* Get object type */ + if ((vol_obj_type = H5I_get_type(loc_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve underlying VOL object */ + if (NULL == (vol_obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get underlying VOL object") + +#ifndef NDEBUG + { + H5VL_object_t *vol_obj_container; + hbool_t is_native_vol_obj; + + /* Get the location object */ + if (NULL == (vol_obj_container = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Make sure that the VOL object is a native connector object */ + if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, + "can't determine if VOL object is native connector object") + + HDassert(is_native_vol_obj && "not a native VOL connector object"); + } +#endif + + /* Convert the object token to an haddr_t */ + if (H5VL_native_token_to_addr(vol_obj, vol_obj_type, token, addr) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "couldn't deserialize object token into haddr_t") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLnative_token_to_addr() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_native_token_to_addr + * + * Purpose: Converts an abstract VOL token to a native VOL haddr_t address. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr) +{ + const uint8_t *p; + size_t addr_len = 0; /* Size of haddr_t */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(obj); + HDassert(addr); + + /* Get the length of an haddr_t in the file */ + if (H5VL__native_get_file_addr_len(obj, obj_type, &addr_len) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "couldn't get length of haddr_t from VOL object") + + /* Decode token */ + p = (const uint8_t *)&token; + H5F_addr_decode_len(addr_len, &p, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_token_to_addr() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_get_file_struct + * + * Purpose: Utility routine to get file struct for an object + * + * Returns: SUCCEED/FAIL + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file) +{ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL); + + *file = NULL; + + switch (type) { + case H5I_FILE: + *file = (H5F_t *)obj; + break; + + case H5I_GROUP: + oloc = H5G_oloc((H5G_t *)obj); + break; + + case H5I_DATATYPE: + oloc = H5T_oloc((H5T_t *)obj); + break; + + case H5I_DATASET: + oloc = H5D_oloc((H5D_t *)obj); + break; + + case H5I_ATTR: + oloc = H5A_oloc((H5A_t *)obj); + break; + + case H5I_MAP: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + 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_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } /* end switch */ + + /* Set return value for objects (not files) */ + if (oloc) + *file = oloc->file; + + /* Couldn't find a file struct */ + if (!*file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL_native_get_file_struct */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h new file mode 100644 index 00000000000..cb7f0e03e40 --- /dev/null +++ b/src/H5VLnative.h @@ -0,0 +1,142 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the native VOL connector. + */ + +#ifndef H5VLnative_H +#define H5VLnative_H + +/* Public headers needed by this file */ +#include "H5VLpublic.h" /* Virtual Object Layer */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Identifier for the native VOL connector */ +#define H5VL_NATIVE (H5VL_native_register()) + +/* Characteristics of the native VOL connector */ +#define H5VL_NATIVE_NAME "native" +#define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ +#define H5VL_NATIVE_VERSION 0 + +/* Values for VOL connector attribute optional VOL operations */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Values for native VOL connector dataset optional VOL operations */ +#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ +#define H5VL_NATIVE_DATASET_GET_NUM_CHUNKS 3 /* H5Dget_num_chunks */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX 4 /* H5Dget_chunk_info */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD 5 /* H5Dget_chunk_info_by_coord */ +#define H5VL_NATIVE_DATASET_CHUNK_READ 6 /* H5Dchunk_read */ +#define H5VL_NATIVE_DATASET_CHUNK_WRITE 7 /* H5Dchunk_write */ +#define H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE 8 /* H5Dvlen_get_buf_size */ +#define H5VL_NATIVE_DATASET_GET_OFFSET 9 /* H5Dget_offset */ + +/* Values for native VOL connector file optional VOL operations */ +#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ +#define H5VL_NATIVE_FILE_GET_FILE_IMAGE 1 /* H5Fget_file_image */ +#define H5VL_NATIVE_FILE_GET_FREE_SECTIONS 2 /* H5Fget_free_sections */ +#define H5VL_NATIVE_FILE_GET_FREE_SPACE 3 /* H5Fget_freespace */ +#define H5VL_NATIVE_FILE_GET_INFO 4 /* H5Fget_info1/2 */ +#define H5VL_NATIVE_FILE_GET_MDC_CONF 5 /* H5Fget_mdc_config */ +#define H5VL_NATIVE_FILE_GET_MDC_HR 6 /* H5Fget_mdc_hit_rate */ +#define H5VL_NATIVE_FILE_GET_MDC_SIZE 7 /* H5Fget_mdc_size */ +#define H5VL_NATIVE_FILE_GET_SIZE 8 /* H5Fget_filesize */ +#define H5VL_NATIVE_FILE_GET_VFD_HANDLE 9 /* H5Fget_vfd_handle */ +#define H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE 10 /* H5Freset_mdc_hit_rate_stats */ +#define H5VL_NATIVE_FILE_SET_MDC_CONFIG 11 /* H5Fset_mdc_config */ +#define H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO 12 /* H5Fget_metadata_read_retry_info */ +#define H5VL_NATIVE_FILE_START_SWMR_WRITE 13 /* H5Fstart_swmr_write */ +#define H5VL_NATIVE_FILE_START_MDC_LOGGING 14 /* H5Fstart_mdc_logging */ +#define H5VL_NATIVE_FILE_STOP_MDC_LOGGING 15 /* H5Fstop_mdc_logging */ +#define H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS 16 /* H5Fget_mdc_logging_status */ +#define H5VL_NATIVE_FILE_FORMAT_CONVERT 17 /* H5Fformat_convert */ +#define H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS 18 /* H5Freset_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS 19 /* H5Fget_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO 20 /* H5Fget_mdc_image_info */ +#define H5VL_NATIVE_FILE_GET_EOA 21 /* H5Fget_eoa */ +#define H5VL_NATIVE_FILE_INCR_FILESIZE 22 /* H5Fincrement_filesize */ +#define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 23 /* H5Fset_latest_format/libver_bounds */ +#define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 24 /* H5Fget_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 25 /* H5Fset_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 26 /* H5Fget_mpi_atomicity */ +#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 27 /* H5Fset_mpi_atomicity */ +#define H5VL_NATIVE_FILE_POST_OPEN 28 /* Adjust file after open, with wrapping context */ + +/* Values for native VOL connector group optional VOL operations */ +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ +#define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Values for native VOL connector object optional VOL operations */ +#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 1 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ +#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 2 /* H5Odisable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 3 /* H5Oenable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 4 /* H5Oare_mdc_flushes_disabled */ +#define H5VL_NATIVE_OBJECT_GET_NATIVE_INFO 5 /* H5Oget_native_info(_by_idx, _by_name) */ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Token <--> address converters */ +/** + * \ingroup H5VLNAT + */ +H5_DLL herr_t H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token); +/** + * \ingroup H5VLNAT + */ +H5_DLL herr_t H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr); + +/* Not really public but must be included here */ +H5_DLL hid_t H5VL_native_register(void); + +#ifdef __cplusplus +} +#endif + +#endif /* H5VLnative_H */ diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c new file mode 100644 index 00000000000..ab97c40bb18 --- /dev/null +++ b/src/H5VLnative_attr.c @@ -0,0 +1,566 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Attribute callbacks for the native VOL connector + * + */ + +#define H5A_FRIEND /* Suppress error about including H5Apkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_create + * + * Purpose: Handles the attribute create callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5T_t * type, *dt; /* Datatype to use for attribute */ + H5S_t * space; /* Dataspace to use for attribute */ + H5A_t * attr = NULL; + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if (0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") + + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the connector's pointer to the datatype */ + type = H5T_get_actual_type(dt); + + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Acreate */ + /* Go do the real work for attaching the attribute to the dataset */ + if (NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Acreate_by_name */ + if (NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, + space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") + + ret_value = (void *)attr; + +done: + /* Release resources */ + if (loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_open + * + * Purpose: Handles the attribute open callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5A_t * attr = NULL; /* Attribute opened */ + void * ret_value; + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Aopen */ + /* Open the attribute */ + if (NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Aopen_by_name */ + /* Open the attribute on the object header */ + if (NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Aopen_by_idx */ + /* Open the attribute in the object header */ + if (NULL == (attr = H5A__open_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") + + ret_value = (void *)attr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_read + * + * Purpose: Handles the attribute read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if ((ret_value = H5A__read((H5A_t *)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_write + * + * Purpose: Handles the attribute write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if ((ret_value = H5A__write((H5A_t *)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_get + * + * Purpose: Handles the attribute get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + /* H5Aget_space */ + case H5VL_ATTR_GET_SPACE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if ((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } + + /* H5Aget_type */ + case H5VL_ATTR_GET_TYPE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if ((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } + + /* H5Aget_create_plist */ + case H5VL_ATTR_GET_ACPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if ((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + + break; + } + + /* H5Aget_name */ + case H5VL_ATTR_GET_NAME: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + size_t buf_size = HDva_arg(arguments, size_t); + char * buf = HDva_arg(arguments, char *); + ssize_t * ret_val = HDva_arg(arguments, ssize_t *); + H5A_t * attr = NULL; + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if (0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + } + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if (buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if ((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1] = '\0'; + } /* end if */ + + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5A_info_t * ainfo = HDva_arg(arguments, H5A_info_t *); + H5A_t * attr = NULL; + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if (H5VL_OBJECT_BY_NAME == loc_params->type) { + char * attr_name = HDva_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == + (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if (NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if (H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if (attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + case H5VL_ATTR_GET_STORAGE_SIZE: { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + H5A_t * attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_specific + * + * Purpose: Handles the attribute specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get location for passed-in object */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch (specific_type) { + case H5VL_ATTR_DELETE: { + char *attr_name = HDva_arg(arguments, char *); + + if (H5VL_OBJECT_BY_SELF == loc_params->type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if (H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end if */ + else if (H5VL_OBJECT_BY_NAME == loc_params->type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if (H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else if (H5VL_OBJECT_BY_IDX == loc_params->type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if (H5A__delete_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + + case H5VL_ATTR_EXISTS: { + const char *attr_name = HDva_arg(arguments, const char *); + htri_t * ret = HDva_arg(arguments, htri_t *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if ((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if ((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + case H5VL_ATTR_ITER: { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t * idx = HDva_arg(arguments, hsize_t *); + H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); + void * op_data = HDva_arg(arguments, void *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + /* Iterate over attributes */ + if ((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + /* Iterate over attributes by name */ + if ((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + /* H5Arename/rename_by_name */ + case H5VL_ATTR_RENAME: { + const char *old_name = HDva_arg(arguments, const char *); + const char *new_name = HDva_arg(arguments, const char *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if (H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if (H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_optional + * + * Purpose: Handles the attribute optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, H5VL_attr_optional_t opt_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, + va_list H5_ATTR_DEPRECATED_USED arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (opt_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_ATTR_ITERATE_OLD: { + hid_t loc_id = HDva_arg(arguments, hid_t); + unsigned * attr_num = HDva_arg(arguments, unsigned *); + H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); + void * op_data = HDva_arg(arguments, void *); + + /* Call the actual iteration routine */ + if ((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_close + * + * Purpose: Handles the attribute close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (attribute will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5A__close((H5A_t *)attr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_close() */ diff --git a/src/H5VLnative_blob.c b/src/H5VLnative_blob.c new file mode 100644 index 00000000000..170a5bc625d --- /dev/null +++ b/src/H5VLnative_blob.c @@ -0,0 +1,225 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Blob callbacks for the native VOL connector + */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5VLnative_private.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_blob_put + * + * Purpose: Handles the blob 'put' callback + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, August 15, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void H5_ATTR_UNUSED *ctx) +{ + H5F_t * f = (H5F_t *)obj; /* Retrieve file pointer */ + uint8_t *id = (uint8_t *)blob_id; /* Pointer to blob ID */ + H5HG_t hobjid; /* New VL sequence's heap ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check parameters */ + HDassert(f); + HDassert(size == 0 || buf); + HDassert(id); + + /* Write the VL information to disk (allocates space also) */ + if (H5HG_insert(f, size, buf, &hobjid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write blob information") + + /* Encode the heap information */ + H5F_addr_encode(f, &id, hobjid.addr); + UINT32ENCODE(id, hobjid.idx); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_blob_put() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_blob_get + * + * Purpose: Handles the blob 'get' callback + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, August 15, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void H5_ATTR_UNUSED *ctx) +{ + H5F_t * f = (H5F_t *)obj; /* Retrieve file pointer */ + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the disk blob ID */ + H5HG_t hobjid; /* Global heap ID for sequence */ + size_t hobj_size = 0; /* Global heap object size returned from H5HG_read() */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(id); + HDassert(buf); + + /* Get the heap information */ + H5F_addr_decode(f, &id, &hobjid.addr); + UINT32DECODE(id, hobjid.idx); + + /* Check if this sequence actually has any data */ + if (hobjid.addr > 0) + /* Read the VL information from disk */ + if (NULL == H5HG_read(f, &hobjid, buf, &hobj_size)) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read VL information") + + /* Verify the size is correct */ + if (hobj_size != size) + HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "Expected global heap object size does not match") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_blob_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_blob_specific + * + * Purpose: Handles the blob 'specific' callback + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Friday, August 15, 2019 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments) +{ + H5F_t *f = (H5F_t *)obj; /* Retrieve file pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(blob_id); + + switch (specific_type) { + case H5VL_BLOB_GETSIZE: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + size_t * size = HDva_arg(arguments, size_t *); + H5HG_t hobjid; /* blob's heap ID */ + + /* Get heap information */ + H5F_addr_decode(f, &id, &(hobjid.addr)); + UINT32DECODE(id, hobjid.idx); + + /* Get heap object's size */ + if (hobjid.addr > 0) { + if (H5HG_get_obj_size(f, &hobjid, size) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + } /* end if */ + else + *size = 0; /* Return '0' size for 'nil' blob ID */ + + break; + } + + case H5VL_BLOB_ISNULL: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + hbool_t * isnull = HDva_arg(arguments, hbool_t *); + haddr_t addr; /* Sequence's heap address */ + + /* Get the heap address */ + H5F_addr_decode(f, &id, &addr); + + /* Check if heap address is 'nil' */ + *isnull = (addr == 0 ? TRUE : FALSE); + + break; + } + + case H5VL_BLOB_SETNULL: { + uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */ + /* Encode the "nil" heap pointer information */ + H5F_addr_encode(f, &id, (haddr_t)0); + UINT32ENCODE(id, 0); + + break; + } + + case H5VL_BLOB_DELETE: { + const uint8_t *id = (const uint8_t *)blob_id; /* Pointer to the blob ID */ + H5HG_t hobjid; /* VL sequence's heap ID */ + + /* Get heap information */ + H5F_addr_decode(f, &id, &hobjid.addr); + UINT32DECODE(id, hobjid.idx); + + /* Free heap object */ + if (hobjid.addr > 0) + if (H5HG_remove(f, &hobjid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_blob_specific() */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c new file mode 100644 index 00000000000..f23267ee91b --- /dev/null +++ b/src/H5VLnative_dataset.c @@ -0,0 +1,620 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Dataset callbacks for the native VOL connector + * + */ + +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_create + * + * Purpose: Handles the dataset create callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t * dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void * ret_value; + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if (H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if (NULL == name) { + /* build and open the new dataset */ + if (NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end if */ + /* H5Dcreate2 */ + else { + /* Create the new dataset & get its ID */ + if (NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end else */ + + ret_value = (void *)dset; + +done: + if (NULL == name) { + /* Release the dataset's object header, if it was created */ + if (dset) { + H5O_loc_t *oloc; /* Object location for dataset */ + + /* Get the new dataset's object location */ + if (NULL == (oloc = H5D_oloc(dset))) + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if (H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_open + * + * Purpose: Handles the dataset open callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5D_t * dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the dataset */ + if (NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + + ret_value = (void *)dset; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_read + * + * Purpose: Handles the dataset read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, void *buf, void H5_ATTR_UNUSED **req) +{ + H5D_t * dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Read raw data */ + if (H5D__read(dset, mem_type_id, mem_space, file_space, buf /*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_write + * + * Purpose: Handles the dataset write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) +{ + H5D_t * dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + /* Write the data */ + if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_get + * + * Purpose: Handles the dataset get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + /* H5Dget_space */ + case H5VL_DATASET_GET_SPACE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if ((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + + break; + } + + /* H5Dget_space_status */ + case H5VL_DATASET_GET_SPACE_STATUS: { + H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); + + /* Read data space address and return */ + if (H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + + break; + } + + /* H5Dget_type */ + case H5VL_DATASET_GET_TYPE: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if ((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + + break; + } + + /* H5Dget_create_plist */ + case H5VL_DATASET_GET_DCPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if ((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + + break; + } + + /* H5Dget_access_plist */ + case H5VL_DATASET_GET_DAPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if ((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + + break; + } + + /* H5Dget_storage_size */ + case H5VL_DATASET_GET_STORAGE_SIZE: { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + + /* Set return value */ + if (H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_specific + * + * Purpose: Handles the dataset specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (specific_type) { + /* H5Dspecific_space */ + case H5VL_DATASET_SET_EXTENT: { /* H5Dset_extent (H5Dextend - deprecated) */ + const hsize_t *size = HDva_arg(arguments, const hsize_t *); + + if (H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } + + case H5VL_DATASET_FLUSH: { /* H5Dflush */ + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Flush the dataset */ + if (H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + + break; + } + + case H5VL_DATASET_REFRESH: { /* H5Drefresh */ + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Refresh the dataset */ + if ((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_optional + * + * Purpose: Handles the dataset optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_optional(void *obj, H5VL_dataset_optional_t optional_type, hid_t dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; /* Dataset */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + HDassert(dset); + + /* Set DXPL for operation */ + H5CX_set_dxpl(dxpl_id); + + switch (optional_type) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: { /* H5Dformat_convert */ + switch (dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if (dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if ((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, + "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if (dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if ((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, + "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: { /* H5Dget_chunk_index_type */ + H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: { /* H5Dget_chunk_storage_size */ + hsize_t *offset = HDva_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + + case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: { /* H5Dget_num_chunks */ + const H5S_t *space = NULL; + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t * nchunks = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + HDassert(dset->shared->space); + + /* When default dataspace is given, use the dataset's dataspace */ + if (space_id == H5S_ALL) + space = dset->shared->space; + else /* otherwise, use the given space ID */ + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_num_chunks(dset, space, nchunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: { /* H5Dget_chunk_info */ + const H5S_t *space = NULL; + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t chk_index = HDva_arg(arguments, hsize_t); + hsize_t * offset = HDva_arg(arguments, hsize_t *); + unsigned * filter_mask = HDva_arg(arguments, unsigned *); + haddr_t * addr = HDva_arg(arguments, haddr_t *); + hsize_t * size = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + HDassert(dset->shared->space); + + /* When default dataspace is given, use the dataset's dataspace */ + if (space_id == H5S_ALL) + space = dset->shared->space; + else /* otherwise, use the given space ID */ + if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace ID") + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_info(dset, space, chk_index, offset, filter_mask, addr, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: { /* H5Dget_chunk_info_by_coord */ + hsize_t * offset = HDva_arg(arguments, hsize_t *); + unsigned *filter_mask = HDva_arg(arguments, unsigned *); + haddr_t * addr = HDva_arg(arguments, haddr_t *); + hsize_t * size = HDva_arg(arguments, hsize_t *); + + HDassert(dset->shared); + + /* Make sure the dataset is chunked */ + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if (H5D__get_chunk_info_by_coord(dset, offset, filter_mask, addr, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by its logical coordinates") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_READ: { /* H5Dread_chunk */ + const hsize_t *offset = HDva_arg(arguments, hsize_t *); + uint32_t * filters = HDva_arg(arguments, uint32_t *); + void * buf = HDva_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + /* Check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_WRITE: { /* H5Dwrite_chunk */ + uint32_t filters = HDva_arg(arguments, uint32_t); + const hsize_t *offset = HDva_arg(arguments, const hsize_t *); + uint32_t data_size_32 = HDva_arg(arguments, uint32_t); + const void * buf = HDva_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + /* Check arguments */ + if (NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if (H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: { /* H5Dvlen_get_buf_size */ + hid_t type_id = HDva_arg(arguments, hid_t); + hid_t space_id = HDva_arg(arguments, hid_t); + hsize_t *size = HDva_arg(arguments, hsize_t *); + + if (H5D__vlen_get_buf_size(dset, type_id, space_id, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of vlen buf needed") + break; + } + + /* H5Dget_offset */ + case H5VL_NATIVE_DATASET_GET_OFFSET: { + haddr_t *ret = HDva_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if (!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_close + * + * Purpose: Handles the dataset close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (dataset will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5D_close((H5D_t *)dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_close() */ diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c new file mode 100644 index 00000000000..9551f50c236 --- /dev/null +++ b/src/H5VLnative_datatype.c @@ -0,0 +1,255 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Datatype callbacks for the native VOL connector + * + */ + +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_commit + * + * Purpose: Handles the datatype commit callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t * dt; /* Datatype for ID */ + H5T_t * type = NULL; /* copy of the original type which will be committed */ + void * ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + + /* Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") + if (H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if (H5T_is_sensible(dt) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") + + /* Copy the datatype - the copied one will be the type that is + * committed, and attached to original datatype above the VOL + * layer + */ + if (NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + + /* Commit the datatype */ + if (NULL != name) { + /* H5Tcommit */ + if (H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end if */ + else { + /* H5Tcommit_anon */ + if (H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end else */ + + ret_value = (void *)type; + +done: + if (NULL == ret_value && type) + H5T_close(type); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_commit() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_open + * + * Purpose: Handles the datatype open callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5T_t * type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the datatype */ + if (NULL == (type = H5T__open_name(&loc, name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + + ret_value = (void *)type; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_get + * + * Purpose: Handles the datatype get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + case H5VL_DATATYPE_GET_BINARY: { + ssize_t *nalloc = HDva_arg(arguments, ssize_t *); + void * buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + if (H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + + *nalloc = (ssize_t)size; + break; + } + + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if (H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_specific + * + * Purpose: Handles the datatype specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (specific_type) { + case H5VL_DATATYPE_FLUSH: { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* To flush metadata and invoke flush callback if there is */ + if (H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + + break; + } + + case H5VL_DATATYPE_REFRESH: { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh datatype object */ + if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_close + * + * Purpose: Handles the datatype close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (datatype will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5T_close((H5T_t *)dt) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_close() */ diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c new file mode 100644 index 00000000000..a2dd0582ea3 --- /dev/null +++ b/src/H5VLnative_file.c @@ -0,0 +1,842 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: File callbacks for the native VOL connector + * + */ + +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PBprivate.h" /* Page buffering */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_create + * + * Purpose: Handles the file create callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if (0 == (flags & (H5F_ACC_EXCL | H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /* default */ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + + /* Create the file */ + if (NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if (NULL == ret_value && new_file) + if (H5F__close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_open + * + * Purpose: Handles the file open callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Open the file */ + if (NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if (NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_get + * + * Purpose: Handles the file get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + /* "get container info" */ + case H5VL_FILE_GET_CONT_INFO: { + H5VL_file_cont_info_t *info = HDva_arg(arguments, H5VL_file_cont_info_t *); + + /* Retrieve the file's container info */ + if (H5F__get_cont_info((H5F_t *)obj, info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file container info") + + break; + } + + /* H5Fget_access_plist */ + case H5VL_FILE_GET_FAPL: { + H5P_genplist_t *new_plist; /* New property list */ + hid_t * plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + + /* Retrieve the file's access property list */ + if ((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file access property list") + + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } + + /* H5Fget_create_plist */ + case H5VL_FILE_GET_FCPL: { + H5P_genplist_t *plist; /* Property list */ + hid_t * plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Create the property list object to return */ + if ((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + + break; + } + + /* H5Fget_intent */ + case H5VL_FILE_GET_INTENT: { + unsigned *intent_flags = HDva_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if (H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } /* end if */ + else { + *intent_flags = H5F_ACC_RDONLY; + + /* Check for SWMR read access on the file */ + if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } /* end else */ + + break; + } + + /* H5Fget_fileno */ + case H5VL_FILE_GET_FILENO: { + unsigned long *fno = HDva_arg(arguments, unsigned long *); + unsigned long my_fileno = 0; + + f = (H5F_t *)obj; + H5F_GET_FILENO(f, my_fileno); + *fno = my_fileno; /* sigh */ + + break; + } + + /* H5Fget_name */ + case H5VL_FILE_GET_NAME: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + size_t size = HDva_arg(arguments, size_t); + char * name = HDva_arg(arguments, char *); + ssize_t * ret = HDva_arg(arguments, ssize_t *); + size_t len; + + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if (name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1, size)); + if (len >= size) + name[size - 1] = '\0'; + } /* end if */ + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + + /* H5Fget_obj_count */ + case H5VL_FILE_GET_OBJ_COUNT: { + unsigned types = HDva_arg(arguments, unsigned); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if (H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_obj_ids */ + case H5VL_FILE_GET_OBJ_IDS: { + unsigned types = HDva_arg(arguments, unsigned); + size_t max_objs = HDva_arg(arguments, size_t); + hid_t * oid_list = HDva_arg(arguments, hid_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if (H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_specific + * + * Purpose: Handles the file specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (specific_type) { + /* H5Fflush */ + case H5VL_FILE_FLUSH: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_t * f = NULL; /* File to flush */ + + /* Get the file for the object */ + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if (H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if (H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if (H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } /* end if */ + else { + /* Call the flush routine, for this file */ + if (H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, + "unable to flush file's cached information") + } /* end else */ + } /* end if */ + break; + } + + /* H5Freopen */ + case H5VL_FILE_REOPEN: { + void **ret = HDva_arg(arguments, void **); + H5F_t *new_file = NULL; + + /* Reopen the file through the VOL connector */ + if (NULL == (new_file = H5F__reopen((H5F_t *)obj))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + new_file->id_exists = TRUE; + + *ret = (void *)new_file; + break; + } + + /* H5Fmount */ + case H5VL_FILE_MOUNT: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5F_t * child = HDva_arg(arguments, H5F_t *); + hid_t fmpl_id = HDva_arg(arguments, hid_t); + H5G_loc_t loc; + + if (H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Do the mount */ + if (H5F__mount(&loc, name, child, fmpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + + /* H5Funmount */ + case H5VL_FILE_UNMOUNT: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5G_loc_t loc; + + if (H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unmount */ + if (H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } + + /* H5Fis_accessible */ + case H5VL_FILE_IS_ACCESSIBLE: { + hid_t fapl_id = HDva_arg(arguments, hid_t); + const char *name = HDva_arg(arguments, const char *); + htri_t * result = HDva_arg(arguments, htri_t *); + + /* Call private routine */ + if ((*result = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } + + /* H5Fdelete */ + case H5VL_FILE_DELETE: { + HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, + "H5Fdelete() is currently not supported in the native VOL connector") + break; + } + + /* Check if two files are the same */ + case H5VL_FILE_IS_EQUAL: { + H5F_t * file2 = (H5F_t *)HDva_arg(arguments, void *); + hbool_t *is_equal = HDva_arg(arguments, hbool_t *); + + if (!obj || !file2) + *is_equal = FALSE; + else + *is_equal = (((H5F_t *)obj)->shared == file2->shared); + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_optional + * + * Purpose: Handles the file optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + f = (H5F_t *)obj; + switch (optional_type) { + /* H5Fget_filesize */ + case H5VL_NATIVE_FILE_GET_SIZE: { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = HDva_arg(arguments, hsize_t *); + + /* Go get the actual file size */ + if (H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + base_addr = H5FD_get_base_addr(f->shared->lf); + + if (size) + *size = (hsize_t)(max_eof_eoa + + base_addr); /* Convert relative base address for file to absolute address */ + + break; + } + + /* H5Fget_file_image */ + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: { + void * buf_ptr = HDva_arg(arguments, void *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t buf_len = HDva_arg(arguments, size_t); + + /* Do the actual work */ + if ((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } + + /* H5Fget_freespace */ + case H5VL_NATIVE_FILE_GET_FREE_SPACE: { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = HDva_arg(arguments, hssize_t *); + + /* Go get the actual amount of free space in the file */ + if (H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } + + /* H5Fget_free_sections */ + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: { + H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); + ssize_t * ret = HDva_arg(arguments, ssize_t *); + H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ + size_t nsects = HDva_arg(arguments, size_t); + + /* Go get the free-space section information in the file */ + if ((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } + + /* H5Fget_info1/2 */ + case H5VL_NATIVE_FILE_GET_INFO: { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if (H5VL_native_get_file_struct(obj, type, &f) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + + /* Get the file info */ + if (H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + + break; + } + + /* H5Fget_mdc_config */ + case H5VL_NATIVE_FILE_GET_MDC_CONF: { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* Go get the resize configuration */ + if (H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } + + /* H5Fget_mdc_hit_rate */ + case H5VL_NATIVE_FILE_GET_MDC_HR: { + double *hit_rate_ptr = HDva_arg(arguments, double *); + + /* Go get the current hit rate */ + if (H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } + + /* H5Fget_mdc_size */ + case H5VL_NATIVE_FILE_GET_MDC_SIZE: { + size_t * max_size_ptr = HDva_arg(arguments, size_t *); + size_t * min_clean_size_ptr = HDva_arg(arguments, size_t *); + size_t * cur_size_ptr = HDva_arg(arguments, size_t *); + int * cur_num_entries_ptr = HDva_arg(arguments, int *); + uint32_t cur_num_entries; + + /* Go get the size data */ + if (H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, cur_size_ptr, + &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if (cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } + + /* H5Fget_vfd_handle */ + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: { + void **file_handle = HDva_arg(arguments, void **); + hid_t fapl_id = HDva_arg(arguments, hid_t); + + /* Retrieve the VFD handle for the file */ + if (H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } + + /* H5Fclear_elink_file_cache */ + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: { + /* Release the EFC */ + if (f->shared->efc) + if (H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } + + /* H5Freset_mdc_hit_rate_stats */ + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: { + /* Reset the hit rate statistic */ + if (H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } + + /* H5Fset_mdc_config */ + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* set the resize configuration */ + if (H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } + + /* H5Fget_metadata_read_retry_info */ + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: { + H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); + + if (H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + + break; + } + + /* H5Fstart_swmr_write */ + case H5VL_NATIVE_FILE_START_SWMR_WRITE: { + if (H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + + break; + } + + /* H5Fstart_mdc_logging */ + case H5VL_NATIVE_FILE_START_MDC_LOGGING: { + /* Call mdc logging function */ + if (H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") + + break; + } + + /* H5Fstop_mdc_logging */ + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: { + /* Call mdc logging function */ + if (H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") + + break; + } + + /* H5Fget_mdc_logging_status */ + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: { + hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + + /* Call mdc logging function */ + if (H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") + + break; + } + + /* H5Fformat_convert */ + case H5VL_NATIVE_FILE_FORMAT_CONVERT: { + /* Convert the format */ + if (H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + + break; + } + + /* H5Freset_page_buffering_stats */ + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: { + /* Sanity check */ + if (NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if (H5PB_reset_stats(f->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + + break; + } + + /* H5Fget_page_buffering_stats */ + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: { + unsigned *accesses = HDva_arg(arguments, unsigned *); + unsigned *hits = HDva_arg(arguments, unsigned *); + unsigned *misses = HDva_arg(arguments, unsigned *); + unsigned *evictions = HDva_arg(arguments, unsigned *); + unsigned *bypasses = HDva_arg(arguments, unsigned *); + + /* Sanity check */ + if (NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Get the statistics */ + if (H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + + break; + } + + /* H5Fget_mdc_image_info */ + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: { + haddr_t *image_addr = HDva_arg(arguments, haddr_t *); + hsize_t *image_len = HDva_arg(arguments, hsize_t *); + + /* Go get the address and size of the cache image */ + if (H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + + break; + } + + /* H5Fget_eoa */ + case H5VL_NATIVE_FILE_GET_EOA: { + haddr_t *eoa = HDva_arg(arguments, haddr_t *); + haddr_t rel_eoa; /* Relative address of EOA */ + + /* Sanity check */ + HDassert(eoa); + + /* This routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "must use a SWMR-compatible VFD for this public routine") + + /* The real work */ + if (HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + + /* Set return value */ + /* (Note compensating for base address subtraction in internal routine) */ + *eoa = rel_eoa + H5F_get_base_addr(f); + + break; + } + + /* H5Fincrement_filesize */ + case H5VL_NATIVE_FILE_INCR_FILESIZE: { + hsize_t increment = HDva_arg(arguments, hsize_t); + haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ + + /* This public routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if (!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "must use a SWMR-compatible VFD for this public routine") + + /* Get the maximum of EOA and EOF */ + if (H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + /* Set EOA to the maximum value + increment */ + if (H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + + break; + } + + /* H5Fset_latest_format, H5Fset_libver_bounds */ + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: { + H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + + /* Call internal set_libver_bounds function */ + if (H5F__set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + + break; + } + + /* H5Fget_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: { + hbool_t *minimize = HDva_arg(arguments, hbool_t *); + *minimize = H5F_GET_MIN_DSET_OHDR(f); + break; + } + + /* H5Fset_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: { + int minimize = HDva_arg(arguments, int); + if (H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, + "cannot set file's dataset object header minimization flag") + break; + } + +#ifdef H5_HAVE_PARALLEL + /* H5Fget_mpi_atomicity */ + case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: { + hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); + if (H5F_get_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); + break; + } + + /* H5Fset_mpi_atomicity */ + case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: { + hbool_t flag = (hbool_t)HDva_arg(arguments, int); + if (H5F_set_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); + break; + } +#endif /* H5_HAVE_PARALLEL */ + + /* Finalize H5Fopen */ + case H5VL_NATIVE_FILE_POST_OPEN: { + /* Call package routine */ + if (H5F__post_open((H5F_t *)obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't finish opening file") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_close + * + * Purpose: Handles the file close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (file will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* This routine should only be called when a file ID's ref count drops to zero */ + HDassert(H5F_ID_EXISTS(f)); + + /* Flush file if this is the last reference to this id and we have write + * intent, unless it will be flushed by the "shared" file being closed. + * This is only necessary to replicate previous behaviour, and could be + * disabled by an option/property to improve performance. + */ + if ((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* Get the file ID corresponding to the H5F_t struct */ + if (H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + + /* Get the number of references outstanding for this file ID */ + if ((nref = H5I_get_ref(file_id, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + if (nref == 1) + if (H5F__flush(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + } /* end if */ + + /* Close the file */ + if (H5F__close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_close() */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c new file mode 100644 index 00000000000..e3fa7025ff8 --- /dev/null +++ b/src/H5VLnative_group.c @@ -0,0 +1,342 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Group callbacks for the native VOL connector + * + */ + +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_create + * + * Purpose: Handles the group create callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, + hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to create group */ + H5G_t * grp = NULL; /* New group created */ + void * ret_value; + + FUNC_ENTER_PACKAGE + + /* Set up the location */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* if name is NULL then this is from H5Gcreate_anon */ + if (name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ + + /* Set up group creation info */ + gcrt_info.gcpl_id = gcpl_id; + gcrt_info.cache_type = H5G_NOTHING_CACHED; + HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + + /* Create the new group & get its ID */ + if (NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end if */ + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if (NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end else */ + + ret_value = (void *)grp; + +done: + if (name == NULL) { + /* Release the group's object header, if it was created */ + if (grp) { + H5O_loc_t *oloc; /* Object location for group */ + + /* Get the new group's object location */ + if (NULL == (oloc = H5G_oloc(grp))) + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if (H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, + "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_open + * + * Purpose: Handles the group open callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t * grp = NULL; /* New group opend */ + void * ret_value; + + FUNC_ENTER_PACKAGE + + /* Set up the location */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the group */ + if ((grp = H5G__open_name(&loc, name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") + + ret_value = (void *)grp; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_get + * + * Purpose: Handles the group get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + /* H5Gget_create_plist */ + case H5VL_GROUP_GET_GCPL: { + hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; + + if ((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } + + /* H5Gget_info */ + case H5VL_GROUP_GET_INFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5G_info_t * group_info = HDva_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if (H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if (H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if (H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_specific + * + * Purpose: Handles the group specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (specific_type) { + case H5VL_GROUP_FLUSH: { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Flush object's metadata to file */ + if (H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + + break; + } + + case H5VL_GROUP_REFRESH: { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh group object */ + if ((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_optional + * + * Purpose: Handles the group optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, H5VL_group_optional_t optional_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, + va_list H5_ATTR_DEPRECATED_USED arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* H5Giterate (deprecated) */ + case H5VL_NATIVE_GROUP_ITERATE_OLD: { + const H5VL_loc_params_t * loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hsize_t idx = HDva_arg(arguments, hsize_t); + hsize_t * last_obj = HDva_arg(arguments, hsize_t *); + const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); + void * op_data = HDva_arg(arguments, void *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual iteration routine */ + if ((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, + H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + + break; + } + + /* H5Gget_objinfo (deprecated) */ + case H5VL_NATIVE_GROUP_GET_OBJINFO: { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); + H5G_stat_t * statbuf = HDva_arg(arguments, H5G_stat_t *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if (H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual group objinfo routine */ + if (H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_close + * + * Purpose: Handles the group close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (group will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5G_close((H5G_t *)grp) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_close() */ diff --git a/src/H5VLnative_introspect.c b/src/H5VLnative_introspect.c new file mode 100644 index 00000000000..9d1244b41b9 --- /dev/null +++ b/src/H5VLnative_introspect.c @@ -0,0 +1,50 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Connector/container introspection callbacks for the native VOL connector + * + */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/* Note: H5VL__native_introspect_get_conn_cls is in src/H5VLnative.c so that + * it can return the address of the staticly declared class struct. + */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_introspect_opt_query + * + * Purpose: Query if an optional operation is supported by this connector + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_introspect_opt_query(void H5_ATTR_UNUSED *obj, H5VL_subclass_t H5_ATTR_UNUSED cls, + int H5_ATTR_UNUSED opt_type, hbool_t *supported) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(supported); + + /* The native VOL connector supports all optional operations */ + *supported = TRUE; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__native_introspect_opt_query() */ diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c new file mode 100644 index 00000000000..c17f5e62751 --- /dev/null +++ b/src/H5VLnative_link.c @@ -0,0 +1,407 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Link callbacks for the native VOL connector + * + */ + +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_create + * + * Purpose: Handles the link create callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (create_type) { + case H5VL_LINK_CREATE_HARD: { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void * cur_obj = HDva_arg(arguments, void *); + H5VL_loc_params_t *cur_params = HDva_arg(arguments, H5VL_loc_params_t *); + + if (NULL != cur_obj && H5G_loc_real(cur_obj, cur_params->obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if (H5VL_OBJECT_BY_NAME == cur_params->type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if (NULL == cur_obj) + cur_loc_p = link_loc_p; + else if (NULL == obj) + link_loc_p = cur_loc_p; + else if (cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "source and destination should be in the same file.") + + /* Create the link */ + if ((ret_value = + H5L__create_hard(cur_loc_p, cur_params->loc_data.loc_by_name.name, link_loc_p, + loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + } /* end if */ + else { /* H5Olink */ + /* Link to the object */ + if (H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else */ + break; + } + + case H5VL_LINK_CREATE_SOFT: { + char * target_name = HDva_arg(arguments, char *); + H5G_loc_t link_loc; /* Group location for new link */ + + if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Create the link */ + if ((ret_value = H5L__create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, + lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + case H5VL_LINK_CREATE_UD: { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type = (H5L_type_t)HDva_arg(arguments, int); + void * udata = HDva_arg(arguments, void *); + size_t udata_size = HDva_arg(arguments, size_t); + + if (H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Create link */ + if (H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, link_type, + lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_copy + * + * Purpose: Handles the link copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if (NULL == src_obj) + src_loc_p = dst_loc_p; + else if (NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Copy the link */ + if (H5L__move(src_loc_p, loc_params1->loc_data.loc_by_name.name, dst_loc_p, + loc_params2->loc_data.loc_by_name.name, TRUE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_move + * + * Purpose: Handles the link move callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if (NULL == src_obj) + src_loc_p = dst_loc_p; + else if (NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Move the link */ + if (H5L__move(src_loc_p, loc_params1->loc_data.loc_by_name.name, dst_loc_p, + loc_params2->loc_data.loc_by_name.name, FALSE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_move() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_get + * + * Purpose: Handles the link get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch (get_type) { + /* H5Lget_info/H5Lget_info_by_idx */ + case H5VL_LINK_GET_INFO: { + H5L_info2_t *linfo2 = HDva_arg(arguments, H5L_info2_t *); + + /* Get the link information */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if (H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + if (H5L__get_info_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo2) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + + /* H5Lget_name_by_idx */ + case H5VL_LINK_GET_NAME: { + char * name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Get the link name */ + if ((*ret = H5L__get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + + /* H5Lget_val/H5Lget_val_by_idx */ + case H5VL_LINK_GET_VAL: { + void * buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + /* Get the link information */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if (H5L__get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + + if (H5L__get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_specific + * + * Purpose: Handles the link specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (specific_type) { + case H5VL_LINK_EXISTS: { + htri_t * ret = HDva_arg(arguments, htri_t *); + H5G_loc_t loc; + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if ((*ret = H5L__exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + + case H5VL_LINK_ITER: { + H5G_loc_t loc; + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t * idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate2_t op = HDva_arg(arguments, H5L_iterate2_t); + void * op_data = HDva_arg(arguments, void *); + + /* Get the location */ + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + if (recursive) { + /* H5Lvisit */ + if ((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate */ + if ((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + if (recursive) { + /* H5Lvisit_by_name */ + if ((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate_by_name */ + if ((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, + idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + + break; + } + + case H5VL_LINK_DELETE: { + H5G_loc_t loc; + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if (H5L__delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + if (H5L__delete_by_idx( + &loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_specific() */ diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c new file mode 100644 index 00000000000..449f3896fb1 --- /dev/null +++ b/src/H5VLnative_object.c @@ -0,0 +1,576 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Object callbacks for the native VOL connector + * + */ + +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files (pkg needed for id_exists) */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_open + * + * Purpose: Handles the object open callback + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; + void * ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + switch (loc_params->type) { + case H5VL_OBJECT_BY_NAME: { + /* Open the object */ + if (NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + + case H5VL_OBJECT_BY_IDX: { + /* Open the object */ + if (NULL == (ret_value = H5O__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + + case H5VL_OBJECT_BY_TOKEN: { + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; + haddr_t addr; + + /* Decode token */ + if (H5VL_native_token_to_addr(loc.oloc->file, H5I_FILE, token, &addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, NULL, + "can't deserialize object token into address") + + /* Open the object */ + if (NULL == (ret_value = H5O__open_by_addr(&loc, addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } + + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_copy + * + * Purpose: Handles the object copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; + + FUNC_ENTER_PACKAGE + + /* get location for objects */ + if (H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if (H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Copy the object */ + if ((ret_value = H5O__copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_get + * + * Purpose: Handles the object get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch (get_type) { + + /* Object file */ + case H5VL_OBJECT_GET_FILE: { + void **ret = HDva_arg(arguments, void **); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + *ret = (void *)loc.oloc->file; + + /* TODO we currently need to set id_exists to TRUE because + * the upper layer will create an ID from the returned + * object. In theory this should not be needed and id_exists + * should be removed once the H5Fmount code gets fixed. */ + loc.oloc->file->id_exists = TRUE; + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_file parameters") + break; + } + + /* Object name */ + case H5VL_OBJECT_GET_NAME: { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char * name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* Retrieve object's name */ + if ((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve object name") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { + H5O_loc_t obj_oloc; /* Object location */ + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; + + /* Initialize the object location */ + H5O_loc_reset(&obj_oloc); + obj_oloc.file = loc.oloc->file; + + /* Decode token */ + if (H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + /* Retrieve object's name */ + if ((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine object name") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_name parameters") + break; + } + + /* Object type */ + case H5VL_OBJECT_GET_TYPE: { + H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); + + if (loc_params->type == H5VL_OBJECT_BY_TOKEN) { + H5O_loc_t obj_oloc; /* Object location */ + unsigned rc; /* Reference count of object */ + H5O_token_t token = *loc_params->loc_data.loc_by_token.token; + + /* Initialize the object location */ + H5O_loc_reset(&obj_oloc); + obj_oloc.file = loc.oloc->file; + + /* Decode token */ + if (H5VL_native_token_to_addr(obj_oloc.file, H5I_FILE, token, &obj_oloc.addr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, + "can't deserialize object token into address") + + /* Get the # of links for object, and its type */ + /* (To check to make certain that this object hasn't been deleted) */ + if (H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc) + HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters") + break; + } + + /* H5Oget_info(_name|_by_idx)3 */ + case H5VL_OBJECT_GET_INFO: { + H5O_info2_t *oinfo = HDva_arg(arguments, H5O_info2_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if (H5G_loc_info(&loc, ".", oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if (H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, oinfo, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + 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 */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if (H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if (H5O_get_info(obj_loc.oloc, oinfo, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_specific + * + * Purpose: Handles the object specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch (specific_type) { + /* H5Oincr_refcount / H5Odecr_refcount */ + case H5VL_OBJECT_CHANGE_REF_COUNT: { + int update_ref = HDva_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; + + if (H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + + break; + } + + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: { + htri_t *ret = HDva_arg(arguments, htri_t *); + + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if ((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", + loc_params->loc_data.loc_by_name.name) + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + /* Lookup object */ + case H5VL_OBJECT_LOOKUP: { + H5O_token_t *token = HDva_arg(arguments, H5O_token_t *); + + HDassert(token); + + if (loc_params->type == H5VL_OBJECT_BY_NAME) { + H5G_loc_t obj_loc; /* Group hier. location of object */ + H5G_name_t obj_path; /* Object group hier. path */ + H5O_loc_t obj_oloc; /* Object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object */ + if (H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + + /* Encode token */ + if (H5VL_native_addr_to_token(loc.oloc->file, H5I_FILE, obj_loc.oloc->addr, token) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, + "can't serialize address into object token") + + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + case H5VL_OBJECT_VISIT: { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + H5O_iterate2_t op = HDva_arg(arguments, H5O_iterate2_t); + void * op_data = HDva_arg(arguments, void *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if ((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if ((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, + op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + + case H5VL_OBJECT_FLUSH: { + hid_t oid = HDva_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if (H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + + case H5VL_OBJECT_REFRESH: { + hid_t oid = HDva_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if (H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_optional + * + * Purpose: Handles the object optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_optional(void *obj, H5VL_object_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if (H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch (optional_type) { + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5VL_NATIVE_OBJECT_GET_COMMENT: { + char * comment = HDva_arg(arguments, char *); + size_t bufsize = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if ((*ret = H5G_loc_get_comment(&loc, ".", comment /*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if ((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment /*out*/, + bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + /* H5Oset_comment */ + case H5VL_NATIVE_OBJECT_SET_COMMENT: { + const char *comment = HDva_arg(arguments, char *); + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if (H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if (H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + /* H5Odisable_mdc_flushes */ + case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: { + H5O_loc_t *oloc = loc.oloc; + + if (H5O_disable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache"); + + break; + } + + /* H5Oenable_mdc_flushes */ + case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: { + H5O_loc_t *oloc = loc.oloc; + + if (H5O_enable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache"); + + break; + } + + /* H5Oare_mdc_flushes_disabled */ + case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: { + H5O_loc_t *oloc = loc.oloc; + hbool_t * are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *); + + if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status"); + + break; + } + + /* H5Oget_native_info(_name|_by_idx) */ + case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: { + H5O_native_info_t *native_info = HDva_arg(arguments, H5O_native_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Use the original H5Oget_info code to get the data */ + + if (loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if (H5G_loc_native_info(&loc, ".", native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if (loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if (H5G_loc_native_info(&loc, loc_params->loc_data.loc_by_name.name, native_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if (loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + 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 */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if (H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if (H5O_get_native_info(obj_loc.oloc, native_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_optional() */ diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h new file mode 100644 index 00000000000..126441d00e5 --- /dev/null +++ b/src/H5VLnative_private.h @@ -0,0 +1,181 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The private header file for the native VOL connector. + */ + +#ifndef H5VLnative_private_H +#define H5VLnative_private_H + +/* Private headers needed by this file */ +#include "H5Fprivate.h" /* Files */ +#include "H5VLnative.h" /* Native VOL connector */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Attribute callbacks */ +H5_DLL void * H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +void * H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +H5_DLL void * H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* Datatype callbacks */ +H5_DLL void * H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* File callbacks */ +H5_DLL void * H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req); +H5_DLL void * H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +H5_DLL void * H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); + +/* Object callbacks */ +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + const char *src_name, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); + +/* Connector/container introspection functions */ +H5_DLL herr_t H5VL__native_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL__native_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, + hbool_t *supported); + +/* Blob callbacks */ +H5_DLL herr_t H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); +H5_DLL herr_t H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); +H5_DLL herr_t H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments); + +/* Token callbacks */ +H5_DLL herr_t H5VL__native_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +H5_DLL herr_t H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); + +/* Helper functions */ +H5_DLL herr_t H5VL_native_get_file_addr_len(hid_t loc_id, size_t *addr_len); +H5_DLL herr_t H5VL__native_get_file_addr_len(void *obj, H5I_type_t obj_type, size_t *addr_len); +H5_DLL herr_t H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_token_t *token); +H5_DLL herr_t H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr); +H5_DLL herr_t H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file); + +#ifdef __cplusplus +} +#endif + +#endif /* H5VLnative_private_H */ diff --git a/src/H5VLnative_token.c b/src/H5VLnative_token.c new file mode 100644 index 00000000000..65591c7e83e --- /dev/null +++ b/src/H5VLnative_token.c @@ -0,0 +1,145 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Object token callbacks for the native VOL connector + */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory handling */ +#include "H5VLnative_private.h" /* Native VOL connector */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_token_cmp + * + * Purpose: Compare two of the connector's object tokens, setting + * *cmp_value, following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: (can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_token_cmp(void H5_ATTR_UNUSED *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE_NOERR + + /* Check parameters */ + HDassert(token1); + HDassert(token2); + + *cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_token_cmp() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_token_to_str + * + * Purpose: Serialize an object token into a string + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str) +{ + haddr_t addr; + size_t addr_ndigits; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Check parameters */ + HDassert(obj); + HDassert(token); + + if (H5VL_native_token_to_addr(obj, obj_type, *token, &addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert object token to address") + + if (addr == 0) + addr_ndigits = 1; + else + addr_ndigits = (size_t)(HDfloor(HDlog10((double)addr)) + 1); + + if (NULL == (*token_str = H5MM_malloc(addr_ndigits + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate buffer for token string") + + HDsnprintf(*token_str, addr_ndigits + 1, H5_PRINTF_HADDR_FMT, addr); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_token_to_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_str_to_token + * + * Purpose: Deserialize a string into an object token + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__native_str_to_token(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token) +{ + haddr_t addr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Check parameters */ + HDassert(token_str); + + HDsscanf(token_str, H5_PRINTF_HADDR_FMT, &addr); + + if (H5VL_native_addr_to_token(obj, obj_type, addr, token) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't convert address to object token") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_str_to_token() */ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c new file mode 100644 index 00000000000..434fd437e5d --- /dev/null +++ b/src/H5VLpassthru.c @@ -0,0 +1,3182 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This is a "pass through" VOL connector, which forwards each + * VOL callback to an underlying connector. + * + * It is designed as an example VOL connector for developers to + * use when creating new connectors, especially connectors that + * are outside of the HDF5 library. As such, it should _NOT_ + * include _any_ private HDF5 header files. This connector should + * therefore only make public HDF5 API calls and use standard C / + * POSIX calls. + * + * Note that the HDF5 error stack must be preserved on code paths + * that could be invoked when the underlying VOL connector's + * callback can fail. + * + */ + +/* Header files needed */ +/* Do NOT include private HDF5 files here! */ +#include +#include +#include +#include +#include + +/* Public HDF5 file */ +#include "hdf5.h" + +/* This connector's header */ +#include "H5VLpassthru.h" + +/**********/ +/* Macros */ +/**********/ + +/* Whether to display log messge when callback is invoked */ +/* (Uncomment to enable) */ +/* #define ENABLE_PASSTHRU_LOGGING */ + +/* Hack for missing va_copy() in old Visual Studio editions + * (from H5win2_defs.h - used on VS2012 and earlier) + */ +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800) +#define va_copy(D, S) ((D) = (S)) +#endif + +/************/ +/* Typedefs */ +/************/ + +/* The pass through VOL info object */ +typedef struct H5VL_pass_through_t { + hid_t under_vol_id; /* ID for underlying VOL connector */ + void *under_object; /* Info object for underlying VOL connector */ +} H5VL_pass_through_t; + +/* The pass through VOL wrapper context */ +typedef struct H5VL_pass_through_wrap_ctx_t { + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_wrap_ctx; /* Object wrapping context for under VOL */ +} H5VL_pass_through_wrap_ctx_t; + +/********************* */ +/* Function prototypes */ +/********************* */ + +/* Helper routines */ +static herr_t H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, + H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, ...); +static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, + H5VL_request_specific_t specific_type, ...); +static herr_t H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, + ...); +static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id); +static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj); + +/* "Management" callbacks */ +static herr_t H5VL_pass_through_init(hid_t vipl_id); +static herr_t H5VL_pass_through_term(void); + +/* VOL info callbacks */ +static void * H5VL_pass_through_info_copy(const void *info); +static herr_t H5VL_pass_through_info_cmp(int *cmp_value, const void *info1, const void *info2); +static herr_t H5VL_pass_through_info_free(void *info); +static herr_t H5VL_pass_through_info_to_str(const void *info, char **str); +static herr_t H5VL_pass_through_str_to_info(const char *str, void **info); + +/* VOL object wrap / retrieval callbacks */ +static void * H5VL_pass_through_get_object(const void *obj); +static herr_t H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx); +static void * H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *wrap_ctx); +static void * H5VL_pass_through_unwrap_object(void *obj); +static herr_t H5VL_pass_through_free_wrap_ctx(void *obj); + +/* Attribute callbacks */ +static void * H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +static void * H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +static void * H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void * H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +static herr_t H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, + void **req); +static herr_t H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* Datatype callbacks */ +static void *H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* File callbacks */ +static void * H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req); +static void * H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +static void * H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +static void * H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); + +/* Object callbacks */ +static void * H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, void *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, + void **req, va_list arguments); + +/* Container/connector introspection callbacks */ +static herr_t H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, + hbool_t *supported); + +/* Async request callbacks */ +static herr_t H5VL_pass_through_request_wait(void *req, uint64_t timeout, H5ES_status_t *status); +static herr_t H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx); +static herr_t H5VL_pass_through_request_cancel(void *req); +static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_t specific_type, + va_list arguments); +static herr_t H5VL_pass_through_request_optional(void *req, H5VL_request_optional_t opt_type, + va_list arguments); +static herr_t H5VL_pass_through_request_free(void *req); + +/* Blob callbacks */ +static herr_t H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx); +static herr_t H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx); +static herr_t H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments); +static herr_t H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, + va_list arguments); + +/* Token callbacks */ +static herr_t H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, + int *cmp_value); +static herr_t H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +static herr_t H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); + +/* Generic optional callback */ +static herr_t H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, + va_list arguments); + +/*******************/ +/* Local variables */ +/*******************/ + +/* Pass through VOL connector class struct */ +static const H5VL_class_t H5VL_pass_through_g = { + H5VL_VERSION, /* VOL class struct version */ + (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ + H5VL_PASSTHRU_NAME, /* name */ + 0, /* capability flags */ + H5VL_pass_through_init, /* initialize */ + H5VL_pass_through_term, /* terminate */ + { + /* info_cls */ + sizeof(H5VL_pass_through_info_t), /* size */ + H5VL_pass_through_info_copy, /* copy */ + H5VL_pass_through_info_cmp, /* compare */ + H5VL_pass_through_info_free, /* free */ + H5VL_pass_through_info_to_str, /* to_str */ + H5VL_pass_through_str_to_info /* from_str */ + }, + { + /* wrap_cls */ + H5VL_pass_through_get_object, /* get_object */ + H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */ + H5VL_pass_through_wrap_object, /* wrap_object */ + H5VL_pass_through_unwrap_object, /* unwrap_object */ + H5VL_pass_through_free_wrap_ctx /* free_wrap_ctx */ + }, + { + /* attribute_cls */ + H5VL_pass_through_attr_create, /* create */ + H5VL_pass_through_attr_open, /* open */ + H5VL_pass_through_attr_read, /* read */ + H5VL_pass_through_attr_write, /* write */ + H5VL_pass_through_attr_get, /* get */ + H5VL_pass_through_attr_specific, /* specific */ + H5VL_pass_through_attr_optional, /* optional */ + H5VL_pass_through_attr_close /* close */ + }, + { + /* dataset_cls */ + H5VL_pass_through_dataset_create, /* create */ + H5VL_pass_through_dataset_open, /* open */ + H5VL_pass_through_dataset_read, /* read */ + H5VL_pass_through_dataset_write, /* write */ + H5VL_pass_through_dataset_get, /* get */ + H5VL_pass_through_dataset_specific, /* specific */ + H5VL_pass_through_dataset_optional, /* optional */ + H5VL_pass_through_dataset_close /* close */ + }, + { + /* datatype_cls */ + H5VL_pass_through_datatype_commit, /* commit */ + H5VL_pass_through_datatype_open, /* open */ + H5VL_pass_through_datatype_get, /* get_size */ + H5VL_pass_through_datatype_specific, /* specific */ + H5VL_pass_through_datatype_optional, /* optional */ + H5VL_pass_through_datatype_close /* close */ + }, + { + /* file_cls */ + H5VL_pass_through_file_create, /* create */ + H5VL_pass_through_file_open, /* open */ + H5VL_pass_through_file_get, /* get */ + H5VL_pass_through_file_specific, /* specific */ + H5VL_pass_through_file_optional, /* optional */ + H5VL_pass_through_file_close /* close */ + }, + { + /* group_cls */ + H5VL_pass_through_group_create, /* create */ + H5VL_pass_through_group_open, /* open */ + H5VL_pass_through_group_get, /* get */ + H5VL_pass_through_group_specific, /* specific */ + H5VL_pass_through_group_optional, /* optional */ + H5VL_pass_through_group_close /* close */ + }, + { + /* link_cls */ + H5VL_pass_through_link_create, /* create */ + H5VL_pass_through_link_copy, /* copy */ + H5VL_pass_through_link_move, /* move */ + H5VL_pass_through_link_get, /* get */ + H5VL_pass_through_link_specific, /* specific */ + H5VL_pass_through_link_optional /* optional */ + }, + { + /* object_cls */ + H5VL_pass_through_object_open, /* open */ + H5VL_pass_through_object_copy, /* copy */ + H5VL_pass_through_object_get, /* get */ + H5VL_pass_through_object_specific, /* specific */ + H5VL_pass_through_object_optional /* optional */ + }, + { + /* introspect_cls */ + H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */ + H5VL_pass_through_introspect_opt_query, /* opt_query */ + }, + { + /* request_cls */ + H5VL_pass_through_request_wait, /* wait */ + H5VL_pass_through_request_notify, /* notify */ + H5VL_pass_through_request_cancel, /* cancel */ + H5VL_pass_through_request_specific, /* specific */ + H5VL_pass_through_request_optional, /* optional */ + H5VL_pass_through_request_free /* free */ + }, + { + /* blob_cls */ + H5VL_pass_through_blob_put, /* put */ + H5VL_pass_through_blob_get, /* get */ + H5VL_pass_through_blob_specific, /* specific */ + H5VL_pass_through_blob_optional /* optional */ + }, + { + /* token_cls */ + H5VL_pass_through_token_cmp, /* cmp */ + H5VL_pass_through_token_to_str, /* to_str */ + H5VL_pass_through_token_from_str /* from_str */ + }, + H5VL_pass_through_optional /* optional */ +}; + +/* The connector identification number, initialized at runtime */ +static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; + +/*------------------------------------------------------------------------- + * Function: H5VL__pass_through_new_obj + * + * Purpose: Create a new pass through object for an underlying object + * + * Return: Success: Pointer to the new pass through object + * Failure: NULL + * + * Programmer: Quincey Koziol + * Monday, December 3, 2018 + * + *------------------------------------------------------------------------- + */ +static H5VL_pass_through_t * +H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) +{ + H5VL_pass_through_t *new_obj; + + new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); + new_obj->under_object = under_obj; + new_obj->under_vol_id = under_vol_id; + H5Iinc_ref(new_obj->under_vol_id); + + return new_obj; +} /* end H5VL__pass_through_new_obj() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__pass_through_free_obj + * + * Purpose: Release a pass through object + * + * Note: Take care to preserve the current HDF5 error stack + * when calling HDF5 API calls. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, December 3, 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_free_obj(H5VL_pass_through_t *obj) +{ + hid_t err_id; + + err_id = H5Eget_current_stack(); + + H5Idec_ref(obj->under_vol_id); + + H5Eset_current_stack(err_id); + + free(obj); + + return 0; +} /* end H5VL__pass_through_free_obj() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_register + * + * Purpose: Register the pass-through VOL connector and retrieve an ID + * for it. + * + * Return: Success: The ID for the pass-through VOL connector + * Failure: -1 + * + * Programmer: Quincey Koziol + * Wednesday, November 28, 2018 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_pass_through_register(void) +{ + /* Singleton register the pass-through VOL connector ID */ + if (H5VL_PASSTHRU_g < 0) + H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT); + + return H5VL_PASSTHRU_g; +} /* end H5VL_pass_through_register() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_init + * + * Purpose: Initialize this VOL connector, performing any necessary + * operations for the connector that will apply to all containers + * accessed with the connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_init(hid_t vipl_id) +{ +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INIT\n"); +#endif + + /* Shut compiler up about unused parameter */ + (void)vipl_id; + + return 0; +} /* end H5VL_pass_through_init() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_term + * + * Purpose: Terminate this VOL connector, performing any necessary + * operations for the connector that release connector-wide + * resources (usually created / initialized with the 'init' + * callback). + * + * Return: Success: 0 + * Failure: (Can't fail) + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_term(void) +{ +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TERM\n"); +#endif + + /* Reset VOL ID */ + H5VL_PASSTHRU_g = H5I_INVALID_HID; + + return 0; +} /* end H5VL_pass_through_term() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_copy + * + * Purpose: Duplicate the connector's info object. + * + * Returns: Success: New connector info object + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_info_copy(const void *_info) +{ + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + H5VL_pass_through_info_t * new_info; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Copy\n"); +#endif + + /* Allocate new VOL info struct for the pass through connector */ + new_info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); + + /* Increment reference count on underlying VOL ID, and copy the VOL info */ + new_info->under_vol_id = info->under_vol_id; + H5Iinc_ref(new_info->under_vol_id); + if (info->under_vol_info) + H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); + + return new_info; +} /* end H5VL_pass_through_info_copy() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_cmp + * + * Purpose: Compare two of the connector's info objects, setting *cmp_value, + * following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info2) +{ + const H5VL_pass_through_info_t *info1 = (const H5VL_pass_through_info_t *)_info1; + const H5VL_pass_through_info_t *info2 = (const H5VL_pass_through_info_t *)_info2; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Compare\n"); +#endif + + /* Sanity checks */ + assert(info1); + assert(info2); + + /* Initialize comparison value */ + *cmp_value = 0; + + /* Compare under VOL connector classes */ + H5VLcmp_connector_cls(cmp_value, info1->under_vol_id, info2->under_vol_id); + if (*cmp_value != 0) + return 0; + + /* Compare under VOL connector info objects */ + H5VLcmp_connector_info(cmp_value, info1->under_vol_id, info1->under_vol_info, info2->under_vol_info); + if (*cmp_value != 0) + return 0; + + return 0; +} /* end H5VL_pass_through_info_cmp() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_free + * + * Purpose: Release an info object for the connector. + * + * Note: Take care to preserve the current HDF5 error stack + * when calling HDF5 API calls. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_free(void *_info) +{ + H5VL_pass_through_info_t *info = (H5VL_pass_through_info_t *)_info; + hid_t err_id; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Free\n"); +#endif + + err_id = H5Eget_current_stack(); + + /* Release underlying VOL ID and info */ + if (info->under_vol_info) + H5VLfree_connector_info(info->under_vol_id, info->under_vol_info); + H5Idec_ref(info->under_vol_id); + + H5Eset_current_stack(err_id); + + /* Free pass through info object itself */ + free(info); + + return 0; +} /* end H5VL_pass_through_info_free() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_to_str + * + * Purpose: Serialize an info object for this connector into a string + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_to_str(const void *_info, char **str) +{ + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + H5VL_class_value_t under_value = (H5VL_class_value_t)-1; + char * under_vol_string = NULL; + size_t under_vol_str_len = 0; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO To String\n"); +#endif + + /* Get value and string for underlying VOL connector */ + H5VLget_value(info->under_vol_id, &under_value); + H5VLconnector_info_to_str(info->under_vol_info, info->under_vol_id, &under_vol_string); + + /* Determine length of underlying VOL info string */ + if (under_vol_string) + under_vol_str_len = strlen(under_vol_string); + + /* Allocate space for our info */ + *str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0); + assert(*str); + + /* Encode our info + * Normally we'd use snprintf() here for a little extra safety, but that + * call had problems on Windows until recently. So, to be as platform-independent + * as we can, we're using sprintf() instead. + */ + sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, + (under_vol_string ? under_vol_string : "")); + + return 0; +} /* end H5VL_pass_through_info_to_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_str_to_info + * + * Purpose: Deserialize a string into an info object for this connector. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_str_to_info(const char *str, void **_info) +{ + H5VL_pass_through_info_t *info; + unsigned under_vol_value; + const char * under_vol_info_start, *under_vol_info_end; + hid_t under_vol_id; + void * under_vol_info = NULL; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO String To Info\n"); +#endif + + /* Retrieve the underlying VOL connector value and info */ + sscanf(str, "under_vol=%u;", &under_vol_value); + under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT); + under_vol_info_start = strchr(str, '{'); + under_vol_info_end = strrchr(str, '}'); + assert(under_vol_info_end > under_vol_info_start); + if (under_vol_info_end != (under_vol_info_start + 1)) { + char *under_vol_info_str; + + under_vol_info_str = (char *)malloc((size_t)(under_vol_info_end - under_vol_info_start)); + memcpy(under_vol_info_str, under_vol_info_start + 1, + (size_t)((under_vol_info_end - under_vol_info_start) - 1)); + *(under_vol_info_str + (under_vol_info_end - under_vol_info_start)) = '\0'; + + H5VLconnector_str_to_info(under_vol_info_str, under_vol_id, &under_vol_info); + + free(under_vol_info_str); + } /* end else */ + + /* Allocate new pass-through VOL connector info and set its fields */ + info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); + info->under_vol_id = under_vol_id; + info->under_vol_info = under_vol_info; + + /* Set return value */ + *_info = info; + + return 0; +} /* end H5VL_pass_through_str_to_info() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_get_object + * + * Purpose: Retrieve the 'data' for a VOL object. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_get_object(const void *obj) +{ + const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL Get object\n"); +#endif + + return H5VLget_object(o->under_object, o->under_vol_id); +} /* end H5VL_pass_through_get_object() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_get_wrap_ctx + * + * Purpose: Retrieve a "wrapper context" for an object + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) +{ + const H5VL_pass_through_t * o = (const H5VL_pass_through_t *)obj; + H5VL_pass_through_wrap_ctx_t *new_wrap_ctx; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP CTX Get\n"); +#endif + + /* Allocate new VOL object wrapping context for the pass through connector */ + new_wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)calloc(1, sizeof(H5VL_pass_through_wrap_ctx_t)); + + /* Increment reference count on underlying VOL ID, and copy the VOL info */ + new_wrap_ctx->under_vol_id = o->under_vol_id; + H5Iinc_ref(new_wrap_ctx->under_vol_id); + H5VLget_wrap_ctx(o->under_object, o->under_vol_id, &new_wrap_ctx->under_wrap_ctx); + + /* Set wrap context to return */ + *wrap_ctx = new_wrap_ctx; + + return 0; +} /* end H5VL_pass_through_get_wrap_ctx() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_wrap_object + * + * Purpose: Use a "wrapper context" to wrap a data object + * + * Return: Success: Pointer to wrapped object + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx) +{ + H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; + H5VL_pass_through_t * new_obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP Object\n"); +#endif + + /* Wrap the object with the underlying VOL */ + under = H5VLwrap_object(obj, obj_type, wrap_ctx->under_vol_id, wrap_ctx->under_wrap_ctx); + if (under) + new_obj = H5VL_pass_through_new_obj(under, wrap_ctx->under_vol_id); + else + new_obj = NULL; + + return new_obj; +} /* end H5VL_pass_through_wrap_object() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_unwrap_object + * + * Purpose: Unwrap a wrapped object, discarding the wrapper, but returning + * underlying object. + * + * Return: Success: Pointer to unwrapped object + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_unwrap_object(void *obj) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL UNWRAP Object\n"); +#endif + + /* Unrap the object with the underlying VOL */ + under = H5VLunwrap_object(o->under_object, o->under_vol_id); + + if (under) + H5VL_pass_through_free_obj(o); + + return under; +} /* end H5VL_pass_through_unwrap_object() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_free_wrap_ctx + * + * Purpose: Release a "wrapper context" for an object + * + * Note: Take care to preserve the current HDF5 error stack + * when calling HDF5 API calls. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) +{ + H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; + hid_t err_id; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP CTX Free\n"); +#endif + + err_id = H5Eget_current_stack(); + + /* Release underlying VOL ID and wrap context */ + if (wrap_ctx->under_wrap_ctx) + H5VLfree_wrap_ctx(wrap_ctx->under_wrap_ctx, wrap_ctx->under_vol_id); + H5Idec_ref(wrap_ctx->under_vol_id); + + H5Eset_current_stack(err_id); + + /* Free pass through wrap context object itself */ + free(wrap_ctx); + + return 0; +} /* end H5VL_pass_through_free_wrap_ctx() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_create + * + * Purpose: Creates an attribute on an object. + * + * Return: Success: Pointer to attribute object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *attr; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Create\n"); +#endif + + under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, type_id, space_id, acpl_id, + aapl_id, dxpl_id, req); + if (under) { + attr = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + attr = NULL; + + return (void *)attr; +} /* end H5VL_pass_through_attr_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_open + * + * Purpose: Opens an attribute on an object. + * + * Return: Success: Pointer to attribute object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *attr; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Open\n"); +#endif + + under = H5VLattr_open(o->under_object, loc_params, o->under_vol_id, name, aapl_id, dxpl_id, req); + if (under) { + attr = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + attr = NULL; + + return (void *)attr; +} /* end H5VL_pass_through_attr_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_read + * + * Purpose: Reads data from attribute. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Read\n"); +#endif + + ret_value = H5VLattr_read(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_write + * + * Purpose: Writes data to attribute. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Write\n"); +#endif + + ret_value = H5VLattr_write(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_get + * + * Purpose: Gets information about an attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Get\n"); +#endif + + ret_value = H5VLattr_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_specific + * + * Purpose: Specific operation on attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Specific\n"); +#endif + + ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_optional + * + * Purpose: Perform a connector-specific operation on an attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Optional\n"); +#endif + + ret_value = H5VLattr_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_close + * + * Purpose: Closes an attribute. + * + * Return: Success: 0 + * Failure: -1, attr not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Close\n"); +#endif + + ret_value = H5VLattr_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying attribute was closed */ + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_attr_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_create + * + * Purpose: Creates a dataset in a container + * + * Return: Success: Pointer to a dataset object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dset; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Create\n"); +#endif + + under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, type_id, space_id, + dcpl_id, dapl_id, dxpl_id, req); + if (under) { + dset = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dset = NULL; + + return (void *)dset; +} /* end H5VL_pass_through_dataset_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_open + * + * Purpose: Opens a dataset in a container + * + * Return: Success: Pointer to a dataset object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dset; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Open\n"); +#endif + + under = H5VLdataset_open(o->under_object, loc_params, o->under_vol_id, name, dapl_id, dxpl_id, req); + if (under) { + dset = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dset = NULL; + + return (void *)dset; +} /* end H5VL_pass_through_dataset_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_read + * + * Purpose: Reads data elements from a dataset into a buffer. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, void *buf, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Read\n"); +#endif + + ret_value = H5VLdataset_read(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_read() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_write + * + * Purpose: Writes data elements from a buffer into a dataset. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t plist_id, const void *buf, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Write\n"); +#endif + + ret_value = H5VLdataset_write(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_write() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_get + * + * Purpose: Gets information about a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Get\n"); +#endif + + ret_value = H5VLdataset_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_specific + * + * Purpose: Specific operation on a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL H5Dspecific\n"); +#endif + + // Save copy of underlying VOL connector ID and prov helper, in case of + // refresh destroying the current object + under_vol_id = o->under_vol_id; + + ret_value = + H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_optional + * + * Purpose: Perform a connector-specific operation on a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Optional\n"); +#endif + + ret_value = H5VLdataset_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_close + * + * Purpose: Closes a dataset. + * + * Return: Success: 0 + * Failure: -1, dataset not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Close\n"); +#endif + + ret_value = H5VLdataset_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying dataset was closed */ + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_dataset_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_commit + * + * Purpose: Commits a datatype inside a container. + * + * Return: Success: Pointer to datatype object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_pass_through_t *dt; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Commit\n"); +#endif + + under = H5VLdatatype_commit(o->under_object, loc_params, o->under_vol_id, name, type_id, lcpl_id, tcpl_id, + tapl_id, dxpl_id, req); + if (under) { + dt = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dt = NULL; + + return (void *)dt; +} /* end H5VL_pass_through_datatype_commit() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_open + * + * Purpose: Opens a named datatype inside a container. + * + * Return: Success: Pointer to datatype object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dt; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Open\n"); +#endif + + under = H5VLdatatype_open(o->under_object, loc_params, o->under_vol_id, name, tapl_id, dxpl_id, req); + if (under) { + dt = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dt = NULL; + + return (void *)dt; +} /* end H5VL_pass_through_datatype_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_get + * + * Purpose: Get information about a datatype + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Get\n"); +#endif + + ret_value = H5VLdatatype_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_specific + * + * Purpose: Specific operations for datatypes + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Specific\n"); +#endif + + // Save copy of underlying VOL connector ID and prov helper, in case of + // refresh destroying the current object + under_vol_id = o->under_vol_id; + + ret_value = + H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_optional + * + * Purpose: Perform a connector-specific operation on a datatype + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Optional\n"); +#endif + + ret_value = H5VLdatatype_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_close + * + * Purpose: Closes a datatype. + * + * Return: Success: 0 + * Failure: -1, datatype not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Close\n"); +#endif + + assert(o->under_object); + + ret_value = H5VLdatatype_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying datatype was closed */ + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_datatype_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_create + * + * Purpose: Creates a container using this connector + * + * Return: Success: Pointer to a file object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_pass_through_info_t *info; + H5VL_pass_through_t * file; + hid_t under_fapl_id; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Create\n"); +#endif + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Open the file with the underlying VOL connector */ + under = H5VLfile_create(name, flags, fcpl_id, under_fapl_id, dxpl_id, req); + if (under) { + file = H5VL_pass_through_new_obj(under, info->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); + } /* end if */ + else + file = NULL; + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + + return (void *)file; +} /* end H5VL_pass_through_file_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_open + * + * Purpose: Opens a container created with this connector + * + * Return: Success: Pointer to a file object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_info_t *info; + H5VL_pass_through_t * file; + hid_t under_fapl_id; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Open\n"); +#endif + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Open the file with the underlying VOL connector */ + under = H5VLfile_open(name, flags, under_fapl_id, dxpl_id, req); + if (under) { + file = H5VL_pass_through_new_obj(under, info->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); + } /* end if */ + else + file = NULL; + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + + return (void *)file; +} /* end H5VL_pass_through_file_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_get + * + * Purpose: Get info about a file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Get\n"); +#endif + + ret_value = H5VLfile_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_specific_reissue + * + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * file specific callback to the underlying VOL connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; + herr_t ret_value; + + va_start(arguments, req); + ret_value = H5VLfile_specific(obj, connector_id, specific_type, dxpl_id, req, arguments); + va_end(arguments); + + return ret_value; +} /* end H5VL_pass_through_file_specific_reissue() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_specific + * + * Purpose: Specific operation on file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Specific\n"); +#endif + + /* Unpack arguments to get at the child file pointer when mounting a file */ + if (specific_type == H5VL_FILE_MOUNT) { + H5I_type_t loc_type; + const char * name; + H5VL_pass_through_t *child_file; + hid_t plist_id; + + /* Retrieve parameters for 'mount' operation, so we can unwrap the child file */ + loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ + name = va_arg(arguments, const char *); + child_file = (H5VL_pass_through_t *)va_arg(arguments, void *); + plist_id = va_arg(arguments, hid_t); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = o->under_vol_id; + + /* Re-issue 'file specific' call, using the unwrapped pieces */ + ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, + dxpl_id, req, (int)loc_type, name, + child_file->under_object, plist_id); + } /* end if */ + else if (specific_type == H5VL_FILE_IS_ACCESSIBLE || specific_type == H5VL_FILE_DELETE) { + H5VL_pass_through_info_t *info; + hid_t fapl_id, under_fapl_id; + const char * name; + htri_t * ret; + + /* Get the arguments for the 'is accessible' check */ + fapl_id = va_arg(arguments, hid_t); + name = va_arg(arguments, const char *); + ret = va_arg(arguments, htri_t *); + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return (-1); + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = info->under_vol_id; + + /* Re-issue 'file specific' call */ + ret_value = H5VL_pass_through_file_specific_reissue(NULL, info->under_vol_id, specific_type, dxpl_id, + req, under_fapl_id, name, ret); + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + } /* end else-if */ + else { + va_list my_arguments; + + /* Make a copy of the argument list for later, if reopening */ + if (specific_type == H5VL_FILE_REOPEN) + va_copy(my_arguments, arguments); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = o->under_vol_id; + + ret_value = + H5VLfile_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Wrap file struct pointer, if we reopened one */ + if (specific_type == H5VL_FILE_REOPEN) { + if (ret_value >= 0) { + void **ret = va_arg(my_arguments, void **); + + if (ret && *ret) + *ret = H5VL_pass_through_new_obj(*ret, o->under_vol_id); + } /* end if */ + + /* Finish use of copied vararg list */ + va_end(my_arguments); + } /* end if */ + } /* end else */ + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_optional + * + * Purpose: Perform a connector-specific operation on a file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL File Optional\n"); +#endif + + ret_value = H5VLfile_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_close + * + * Purpose: Closes a file. + * + * Return: Success: 0 + * Failure: -1, file not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Close\n"); +#endif + + ret_value = H5VLfile_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying file was closed */ + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_file_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_create + * + * Purpose: Creates a group inside a container + * + * Return: Success: Pointer to a group object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *group; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Create\n"); +#endif + + under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, lcpl_id, gcpl_id, gapl_id, + dxpl_id, req); + if (under) { + group = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + group = NULL; + + return (void *)group; +} /* end H5VL_pass_through_group_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_open + * + * Purpose: Opens a group inside a container + * + * Return: Success: Pointer to a group object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *group; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Open\n"); +#endif + + under = H5VLgroup_open(o->under_object, loc_params, o->under_vol_id, name, gapl_id, dxpl_id, req); + if (under) { + group = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + group = NULL; + + return (void *)group; +} /* end H5VL_pass_through_group_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_get + * + * Purpose: Get info about a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Get\n"); +#endif + + ret_value = H5VLgroup_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_specific + * + * Purpose: Specific operation on a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Specific\n"); +#endif + + // Save copy of underlying VOL connector ID and prov helper, in case of + // refresh destroying the current object + under_vol_id = o->under_vol_id; + + ret_value = H5VLgroup_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_optional + * + * Purpose: Perform a connector-specific operation on a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Optional\n"); +#endif + + ret_value = H5VLgroup_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_close + * + * Purpose: Closes a group. + * + * Return: Success: 0 + * Failure: -1, group not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)grp; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL H5Gclose\n"); +#endif + + ret_value = H5VLgroup_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying file was closed */ + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_group_close() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_create_reissue + * + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * link create callback to the underlying VOL connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_create_reissue(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; + herr_t ret_value; + + va_start(arguments, req); + ret_value = H5VLlink_create(create_type, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req, + arguments); + va_end(arguments); + + return ret_value; +} /* end H5VL_pass_through_link_create_reissue() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_create + * + * Purpose: Creates a hard / soft / UD / external link. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Create\n"); +#endif + + /* Try to retrieve the "under" VOL id */ + if (o) + under_vol_id = o->under_vol_id; + + /* Fix up the link target object for hard link creation */ + if (H5VL_LINK_CREATE_HARD == create_type) { + void * cur_obj; + H5VL_loc_params_t *cur_params; + + /* Retrieve the object & loc params for the link target */ + cur_obj = va_arg(arguments, void *); + cur_params = va_arg(arguments, H5VL_loc_params_t *); + + /* If it's a non-NULL pointer, find the 'under object' and re-set the property */ + if (cur_obj) { + /* Check if we still need the "under" VOL ID */ + if (under_vol_id < 0) + under_vol_id = ((H5VL_pass_through_t *)cur_obj)->under_vol_id; + + /* Set the object for the link target */ + cur_obj = ((H5VL_pass_through_t *)cur_obj)->under_object; + } /* end if */ + + /* Re-issue 'link create' call, using the unwrapped pieces */ + ret_value = H5VL_pass_through_link_create_reissue(create_type, (o ? o->under_object : NULL), + loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, + req, cur_obj, cur_params); + } /* end if */ + else + ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, + lcpl_id, lapl_id, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_create() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_copy + * + * Purpose: Renames an object within an HDF5 container and copies it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Copy\n"); +#endif + + /* Retrieve the "under" VOL id */ + if (o_src) + under_vol_id = o_src->under_vol_id; + else if (o_dst) + under_vol_id = o_dst->under_vol_id; + assert(under_vol_id > 0); + + ret_value = + H5VLlink_copy((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), + loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_move + * + * Purpose: Moves a link within an HDF5 file to a new group. The original + * name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Move\n"); +#endif + + /* Retrieve the "under" VOL id */ + if (o_src) + under_vol_id = o_src->under_vol_id; + else if (o_dst) + under_vol_id = o_dst->under_vol_id; + assert(under_vol_id > 0); + + ret_value = + H5VLlink_move((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), + loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_move() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_get + * + * Purpose: Get info about a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Get\n"); +#endif + + ret_value = H5VLlink_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_specific + * + * Purpose: Specific operation on a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Specific\n"); +#endif + + ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_optional + * + * Purpose: Perform a connector-specific operation on a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Optional\n"); +#endif + + ret_value = H5VLlink_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_open + * + * Purpose: Opens an object inside a container. + * + * Return: Success: Pointer to object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *new_obj; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void * under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Open\n"); +#endif + + under = H5VLobject_open(o->under_object, loc_params, o->under_vol_id, opened_type, dxpl_id, req); + if (under) { + new_obj = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + new_obj = NULL; + + return (void *)new_obj; +} /* end H5VL_pass_through_object_open() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_copy + * + * Purpose: Copies an object inside a container. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Copy\n"); +#endif + + ret_value = + H5VLobject_copy(o_src->under_object, src_loc_params, src_name, o_dst->under_object, dst_loc_params, + dst_name, o_src->under_vol_id, ocpypl_id, lcpl_id, dxpl_id, req); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o_src->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_get + * + * Purpose: Get info about an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Get\n"); +#endif + + ret_value = + H5VLobject_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_specific + * + * Purpose: Specific operation on an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Specific\n"); +#endif + + // Save copy of underlying VOL connector ID and prov helper, in case of + // refresh destroying the current object + under_vol_id = o->under_vol_id; + + ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, + arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_optional + * + * Purpose: Perform a connector-specific operation for an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Optional\n"); +#endif + + ret_value = H5VLobject_optional(o->under_object, o->under_vol_id, opt_type, dxpl_id, req, arguments); + + /* Check for async request */ + if (req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_introspect_get_conn_clss + * + * Purpose: Query the connector class. + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INTROSPECT GetConnCls\n"); +#endif + + /* Check for querying this connector's class */ + if (H5VL_GET_CONN_LVL_CURR == lvl) { + *conn_cls = &H5VL_pass_through_g; + ret_value = 0; + } /* end if */ + else + ret_value = H5VLintrospect_get_conn_cls(o->under_object, o->under_vol_id, lvl, conn_cls); + + return ret_value; +} /* end H5VL_pass_through_introspect_get_conn_cls() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_introspect_opt_query + * + * Purpose: Query if an optional operation is supported by this connector + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INTROSPECT OptQuery\n"); +#endif + + ret_value = H5VLintrospect_opt_query(o->under_object, o->under_vol_id, cls, opt_type, supported); + + return ret_value; +} /* end H5VL_pass_through_introspect_opt_query() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_wait + * + * Purpose: Wait (with a timeout) for an async operation to complete + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_wait(void *obj, uint64_t timeout, H5ES_status_t *status) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Wait\n"); +#endif + + ret_value = H5VLrequest_wait(o->under_object, o->under_vol_id, timeout, status); + + if (ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_wait() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Notify\n"); +#endif + + ret_value = H5VLrequest_notify(o->under_object, o->under_vol_id, cb, ctx); + + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_notify() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_cancel + * + * Purpose: Cancels an asynchronous operation + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_cancel(void *obj) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Cancel\n"); +#endif + + ret_value = H5VLrequest_cancel(o->under_object, o->under_vol_id); + + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_cancel() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_specific_reissue + * + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * request specific callback to the underlying VOL connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, + H5VL_request_specific_t specific_type, ...) +{ + va_list arguments; + herr_t ret_value; + + va_start(arguments, specific_type); + ret_value = H5VLrequest_specific(obj, connector_id, specific_type, arguments); + va_end(arguments); + + return ret_value; +} /* end H5VL_pass_through_request_specific_reissue() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_specific + * + * Purpose: Specific operation on a request + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_type, va_list arguments) +{ + herr_t ret_value = -1; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Specific\n"); +#endif + + if (H5VL_REQUEST_WAITANY == specific_type || H5VL_REQUEST_WAITSOME == specific_type || + H5VL_REQUEST_WAITALL == specific_type) { + va_list tmp_arguments; + size_t req_count; + + /* Sanity check */ + assert(obj == NULL); + + /* Get enough info to call the underlying connector */ + va_copy(tmp_arguments, arguments); + req_count = va_arg(tmp_arguments, size_t); + + /* Can only use a request to invoke the underlying VOL connector when there's >0 requests */ + if (req_count > 0) { + void ** req_array; + void ** under_req_array; + uint64_t timeout; + H5VL_pass_through_t *o; + size_t u; /* Local index variable */ + + /* Get the request array */ + req_array = va_arg(tmp_arguments, void **); + + /* Get a request to use for determining the underlying VOL connector */ + o = (H5VL_pass_through_t *)req_array[0]; + + /* Create array of underlying VOL requests */ + under_req_array = (void **)malloc(req_count * sizeof(void **)); + for (u = 0; u < req_count; u++) + under_req_array[u] = ((H5VL_pass_through_t *)req_array[u])->under_object; + + /* Remove the timeout value from the vararg list (it's used in all the calls below) */ + timeout = va_arg(tmp_arguments, uint64_t); + + /* Release requests that have completed */ + if (H5VL_REQUEST_WAITANY == specific_type) { + size_t * idx; /* Pointer to the index of completed request */ + H5ES_status_t *status; /* Pointer to the request's status */ + + /* Retrieve the remaining arguments */ + idx = va_arg(tmp_arguments, size_t *); + assert(*idx <= req_count); + status = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITANY 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, + specific_type, req_count, + under_req_array, timeout, idx, status); + + /* Release the completed request, if it completed */ + if (ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[*idx]; + H5VL_pass_through_free_obj(tmp_o); + } /* end if */ + } /* end if */ + else if (H5VL_REQUEST_WAITSOME == specific_type) { + size_t * outcount; /* # of completed requests */ + unsigned * array_of_indices; /* Array of indices for completed requests */ + H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ + + /* Retrieve the remaining arguments */ + outcount = va_arg(tmp_arguments, size_t *); + assert(*outcount <= req_count); + array_of_indices = va_arg(tmp_arguments, unsigned *); + array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITSOME 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue( + o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, + outcount, array_of_indices, array_of_statuses); + + /* If any requests completed, release them */ + if (ret_value >= 0 && *outcount > 0) { + unsigned *idx_array; /* Array of indices of completed requests */ + + /* Retrieve the array of completed request indices */ + idx_array = va_arg(tmp_arguments, unsigned *); + + /* Release the completed requests */ + for (u = 0; u < *outcount; u++) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[idx_array[u]]; + H5VL_pass_through_free_obj(tmp_o); + } /* end for */ + } /* end if */ + } /* end else-if */ + else { /* H5VL_REQUEST_WAITALL == specific_type */ + H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ + + /* Retrieve the remaining arguments */ + array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITALL 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue( + o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, + array_of_statuses); + + /* Release the completed requests */ + if (ret_value >= 0) { + for (u = 0; u < req_count; u++) { + if (array_of_statuses[u] != H5ES_STATUS_IN_PROGRESS) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[u]; + H5VL_pass_through_free_obj(tmp_o); + } /* end if */ + } /* end for */ + } /* end if */ + } /* end else */ + + /* Release array of requests for underlying connector */ + free(under_req_array); + } /* end if */ + + /* Finish use of copied vararg list */ + va_end(tmp_arguments); + } /* end if */ + else { + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + + ret_value = H5VLrequest_specific(o->under_object, o->under_vol_id, specific_type, arguments); + } /* end else */ + + return ret_value; +} /* end H5VL_pass_through_request_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_optional + * + * Purpose: Perform a connector-specific operation for a request + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_optional(void *obj, H5VL_request_optional_t opt_type, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Optional\n"); +#endif + + ret_value = H5VLrequest_optional(o->under_object, o->under_vol_id, opt_type, arguments); + + return ret_value; +} /* end H5VL_pass_through_request_optional() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_free + * + * Purpose: Releases a request, allowing the operation to complete without + * application tracking + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_free(void *obj) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Free\n"); +#endif + + ret_value = H5VLrequest_free(o->under_object, o->under_vol_id); + + if (ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_blob_put + * + * Purpose: Handles the blob 'put' callback + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL BLOB Put\n"); +#endif + + ret_value = H5VLblob_put(o->under_object, o->under_vol_id, buf, size, blob_id, ctx); + + return ret_value; +} /* end H5VL_pass_through_blob_put() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_blob_get + * + * Purpose: Handles the blob 'get' callback + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL BLOB Get\n"); +#endif + + ret_value = H5VLblob_get(o->under_object, o->under_vol_id, blob_id, buf, size, ctx); + + return ret_value; +} /* end H5VL_pass_through_blob_get() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_blob_specific + * + * Purpose: Handles the blob 'specific' callback + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL BLOB Specific\n"); +#endif + + ret_value = H5VLblob_specific(o->under_object, o->under_vol_id, blob_id, specific_type, arguments); + + return ret_value; +} /* end H5VL_pass_through_blob_specific() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_blob_optional + * + * Purpose: Handles the blob 'optional' callback + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL BLOB Optional\n"); +#endif + + ret_value = H5VLblob_optional(o->under_object, o->under_vol_id, blob_id, opt_type, arguments); + + return ret_value; +} /* end H5VL_pass_through_blob_optional() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_cmp + * + * Purpose: Compare two of the connector's object tokens, setting + * *cmp_value, following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN Compare\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token1); + assert(token2); + assert(cmp_value); + + ret_value = H5VLtoken_cmp(o->under_object, o->under_vol_id, token1, token2, cmp_value); + + return ret_value; +} /* end H5VL_pass_through_token_cmp() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_to_str + * + * Purpose: Serialize the connector's object token into a string. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN To string\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token); + assert(token_str); + + ret_value = H5VLtoken_to_str(o->under_object, obj_type, o->under_vol_id, token, token_str); + + return ret_value; +} /* end H5VL_pass_through_token_to_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_token_from_str + * + * Purpose: Deserialize the connector's object token from a string. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TOKEN From string\n"); +#endif + + /* Sanity checks */ + assert(obj); + assert(token); + assert(token_str); + + ret_value = H5VLtoken_from_str(o->under_object, obj_type, o->under_vol_id, token_str, token); + + return ret_value; +} /* end H5VL_pass_through_token_from_str() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_optional + * + * Purpose: Handles the generic 'optional' callback + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_pass_through_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL generic Optional\n"); +#endif + + ret_value = H5VLoptional(o->under_object, o->under_vol_id, op_type, dxpl_id, req, arguments); + + return ret_value; +} /* end H5VL_pass_through_optional() */ diff --git a/src/H5VLpassthru.h b/src/H5VLpassthru.h new file mode 100644 index 00000000000..79caca7fb5d --- /dev/null +++ b/src/H5VLpassthru.h @@ -0,0 +1,47 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the pass-through VOL connector. + */ + +#ifndef H5VLpassthru_H +#define H5VLpassthru_H + +/* Public headers needed by this file */ +#include "H5VLpublic.h" /* Virtual Object Layer */ + +/* Identifier for the pass-through VOL connector */ +#define H5VL_PASSTHRU (H5VL_pass_through_register()) + +/* Characteristics of the pass-through VOL connector */ +#define H5VL_PASSTHRU_NAME "pass_through" +#define H5VL_PASSTHRU_VALUE 505 /* VOL connector ID */ +#define H5VL_PASSTHRU_VERSION 0 + +/* Pass-through VOL connector info */ +typedef struct H5VL_pass_through_info_t { + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_vol_info; /* VOL info for under VOL */ +} H5VL_pass_through_info_t; + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5VL_pass_through_register(void); + +#ifdef __cplusplus +} +#endif + +#endif /* H5VLpassthru_H */ diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h new file mode 100644 index 00000000000..7b8a8779d6f --- /dev/null +++ b/src/H5VLpkg.h @@ -0,0 +1,60 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which are visible only within + * the H5VL package. Source files outside the H5VL package should + * include H5VLprivate.h instead. + */ + +#if !(defined H5VL_FRIEND || defined H5VL_MODULE) +#error "Do not include this file outside the H5VL package!" +#endif + +#ifndef H5VLpkg_H +#define H5VLpkg_H + +/* Get package's private header */ +#include "H5VLprivate.h" /* Generic Functions */ + +/* Other private headers needed by this file */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +H5_DLL hid_t H5VL__register_connector(const void *cls, hbool_t app_ref, hid_t vipl_id); +H5_DLL hid_t H5VL__register_connector_by_class(const H5VL_class_t *cls, hbool_t app_ref, hid_t vipl_id); +H5_DLL hid_t H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_id); +H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid_t vipl_id); +H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); +H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, hbool_t is_api); +H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, hbool_t is_api); +H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); +H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); +H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); +H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size); + +#endif /* H5VLpkg_H */ diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h new file mode 100644 index 00000000000..678a27fea1a --- /dev/null +++ b/src/H5VLprivate.h @@ -0,0 +1,274 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef H5VLprivate_H +#define H5VLprivate_H + +/* Include package's public header */ +#include "H5VLpublic.h" /* Generic Functions */ + +/* Private headers needed by this file */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* Internal struct to track VOL connector information for objects */ +typedef struct H5VL_t { + const H5VL_class_t *cls; /* Pointer to connector class struct */ + int64_t nrefs; /* Number of references by objects using this struct */ + hid_t id; /* Identifier for the VOL connector */ +} H5VL_t; + +/* Internal vol object structure returned to the API */ +typedef struct H5VL_object_t { + void * data; /* Pointer to connector-managed data for this object */ + H5VL_t *connector; /* Pointer to VOL connector struct */ + size_t rc; /* Reference count */ +} H5VL_object_t; + +/* Internal structure to hold the connector ID & info for FAPLs */ +typedef struct H5VL_connector_prop_t { + hid_t connector_id; /* VOL connector's ID */ + const void *connector_info; /* VOL connector info, for open callbacks */ +} H5VL_connector_prop_t; + +/* Which kind of VOL connector field to use for searching */ +typedef enum H5VL_get_connector_kind_t { + H5VL_GET_CONNECTOR_BY_NAME, /* Name field is set */ + H5VL_GET_CONNECTOR_BY_VALUE /* Value field is set */ +} H5VL_get_connector_kind_t; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +/* Utility functions */ +H5_DLL herr_t H5VL_init_phase1(void); +H5_DLL herr_t H5VL_init_phase2(void); +H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2); +H5_DLL herr_t H5VL_conn_copy(H5VL_connector_prop_t *value); +H5_DLL herr_t H5VL_conn_free(const H5VL_connector_prop_t *info); + +/* Functions that deal with VOL connectors */ +union H5PL_key_t; +H5_DLL herr_t H5VL_check_plugin_load(const H5VL_class_t *cls, const union H5PL_key_t *key, hbool_t *success); + +/* NOTE: The object and ID functions below deal in VOL objects (i.e.; + * H5VL_object_t). Similar non-VOL calls exist in H5Iprivate.h. Use + * the H5VL calls with objects that go through the VOL, such as + * datasets and groups, and the H5I calls with objects + * that do not, such as property lists and dataspaces. Datatypes + * are can be either named, where they will use the VOL, or not, + * and thus require special treatment. See the datatype docs for + * how to handle this. + */ + +/* Functions that manipulate VOL objects */ +H5_DLL void *H5VL_object(hid_t id); +H5_DLL void *H5VL_object_data(const H5VL_object_t *vol_obj); +H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj); +H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); +H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id); +H5_DLL H5VL_object_t *H5VL_create_object(void *object, H5VL_t *vol_connector); +H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id); +H5_DLL hsize_t H5VL_object_inc_rc(H5VL_object_t *obj); +H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); +H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native); +H5_DLL herr_t H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, + hbool_t *same_file); + +/* Functions that wrap / unwrap VOL objects */ +H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx); +H5_DLL void * H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type); +H5_DLL void * H5VL_unwrap_object(const H5VL_class_t *connector, void *obj); +H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx); +H5_DLL herr_t H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj); +H5_DLL herr_t H5VL_inc_vol_wrapper(void *vol_wrap_ctx); +H5_DLL herr_t H5VL_dec_vol_wrapper(void *vol_wrap_ctx); +H5_DLL herr_t H5VL_reset_vol_wrapper(void); + +/* Library state functions */ +H5_DLL herr_t H5VL_retrieve_lib_state(void **state); +H5_DLL herr_t H5VL_restore_lib_state(const void *state); +H5_DLL herr_t H5VL_reset_lib_state(void); +H5_DLL herr_t H5VL_free_lib_state(void *state); + +/* ID registration functions */ +H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref); +H5_DLL hid_t H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref); +H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref); +H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, + hbool_t app_ref, hid_t existing_id); + +/********************************** + * VOL connector callback wrappers + *********************************/ + +/* Connector "management" functions */ +H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info); +H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, + const void *info2); +H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, const void *info); + +/* Attribute functions */ +H5_DLL void * H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, + hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, + void **req); +H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, + ...); +H5_DLL herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); + +/* Dataset functions */ +H5_DLL void * H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, void *buf, void **req); +H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf, void **req); +H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_dataset_optional_t opt_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); + +/* Datatype functions */ +H5_DLL void * H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, + hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_datatype_optional_t opt_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); + +/* File functions */ +H5_DLL void * H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, + hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void * H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, + hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, + ...); +H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_file_optional_t opt_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); + +/* Group functions */ +H5_DLL void * H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, + void **req); +H5_DLL void * H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, + void **req, ...); +H5_DLL herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); + +/* Link functions */ +H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, + hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, + void **req, ...); + +/* Object functions */ +H5_DLL void * H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, const H5VL_object_t *dst_obj, + const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, + hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, H5VL_object_optional_t opt_type, + hid_t dxpl_id, void **req, ...); + +/* Connector/container introspection functions */ +H5_DLL herr_t H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t lvl, + const H5VL_class_t **conn_cls); +H5_DLL herr_t H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, int opt_type, + hbool_t *supported); + +/* Asynchronous functions */ +H5_DLL herr_t H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx); +H5_DLL herr_t H5VL_request_cancel(const H5VL_object_t *vol_obj); +H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...); +H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_request_optional_t opt_type, ...); +H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj); + +/* Blob functions */ +H5_DLL herr_t H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void *blob_id, + void *ctx); +H5_DLL herr_t H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size_t size, + void *ctx); +H5_DLL herr_t H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, + H5VL_blob_specific_t specific_type, ...); +H5_DLL herr_t H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_optional_t opt_type, + ...); + +/* Token functions */ +H5_DLL herr_t H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, + const H5O_token_t *token2, int *cmp_value); +H5_DLL herr_t H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token, + char **token_str); +H5_DLL herr_t H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str, + H5O_token_t *token); + +/* Generic functions */ +H5_DLL herr_t H5VL_optional(const H5VL_object_t *vol_obj, int op_type, hid_t dxpl_id, void **req, ...); + +#endif /* H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h new file mode 100644 index 00000000000..aec4851ecb6 --- /dev/null +++ b/src/H5VLpublic.h @@ -0,0 +1,347 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5VL (VOL) module. + */ + +#ifndef H5VLpublic_H +#define H5VLpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Ipublic.h" /* IDs */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/** + * \ingroup H5VLDEF + * \brief Version # of VOL class struct & callbacks + * + * \details Each VOL connector must set the 'version' field in the H5VL_class_t + * struct to the version of the H5VL_class_t struct that the connector + * implements. The HDF5 library will reject connectors with + * incompatible structs. + */ +#define H5VL_VERSION 0 + +/* VOL connector identifier values + * These are H5VL_class_value_t values, NOT hid_t values! + */ +/** + * \ingroup H5VLDEF + * Invalid ID for VOL connector ID + */ +#define H5_VOL_INVALID (-1) +/** + * \ingroup H5VLDEF + * Native HDF5 file format VOL connector + */ +#define H5_VOL_NATIVE 0 +/** + * \ingroup H5VLDEF + * VOL connector IDs below this value are reserved for library use + */ +#define H5_VOL_RESERVED 256 +/** + * \ingroup H5VLDEF + * Maximum VOL connector ID + */ +#define H5_VOL_MAX 65535 + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/** + * \ingroup H5VLDEF + * + * \brief VOL connector identifiers. + * + * \details Values 0 through 255 are for connectors defined by the HDF5 + * library. Values 256 through 511 are available for testing new + * connectors. Subsequent values should be obtained from the HDF5 + * development team at mailto:help@hdfgroup.org. + */ +//! +typedef int H5VL_class_value_t; +//! + +/** + * \ingroup H5VLDEF + * \details Enum type for each VOL subclass + * (Used for various queries, etc) + */ +typedef enum H5VL_subclass_t { + H5VL_SUBCLS_NONE, /**< Operations outside of a subclass */ + H5VL_SUBCLS_INFO, /**< 'Info' subclass */ + H5VL_SUBCLS_WRAP, /**< 'Wrap' subclass */ + H5VL_SUBCLS_ATTR, /**< 'Attribute' subclass */ + H5VL_SUBCLS_DATASET, /**< 'Dataset' subclass */ + H5VL_SUBCLS_DATATYPE, /**< 'Named datatype' subclass */ + H5VL_SUBCLS_FILE, /**< 'File' subclass */ + H5VL_SUBCLS_GROUP, /**< 'Group' subclass */ + H5VL_SUBCLS_LINK, /**< 'Link' subclass */ + H5VL_SUBCLS_OBJECT, /**< 'Object' subclass */ + H5VL_SUBCLS_REQUEST, /**< 'Request' subclass */ + H5VL_SUBCLS_BLOB, /**< 'Blob' subclass */ + H5VL_SUBCLS_TOKEN /**< 'Token' subclass */ +} H5VL_subclass_t; + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \ingroup H5VL + * \brief Registers a new VOL connector by name + * + * \param[in] connector_name Connector name + * \vipl_id + * \return \hid_t{VOL connector} + * + * \details H5VLregister_connector_by_name() registers a new VOL connector with + * the name \p connector_name as a member of the virtual object layer + * class. This VOL connector identifier is good until the library is + * closed or the connector is unregistered. + * + * \p vipl_id is either #H5P_DEFAULT or the identifier of a VOL + * initialization property list of class #H5P_VOL_INITIALIZE created + * with H5Pcreate(). When created, this property list contains no + * library properties. If a VOL connector author decides that + * initialization-specific data are needed, they can be added to the + * empty list and retrieved by the connector in the VOL connector's + * initialize callback. Use of the VOL initialization property list is + * uncommon, as most VOL-specific properties are added to the file + * access property list via the connector's API calls which set the + * VOL connector for the file open/create. For more information, see + * \ref_vol_doc. + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); +/** + * \ingroup H5VL + * \brief Registers a new VOL connector by value + * + * \param[in] connector_value Connector value + * \vipl_id + * \return \hid_t{VOL connector} + * + * \details H5VLregister_connector_by_value() registers a new VOL connector + * with value connector_value as a member of the virtual object layer + * class. This VOL connector identifier is good until the library is + * closed or the connector is unregistered. + * + * \p connector_value has a type of H5VL_class_value_t, which is + * defined in H5VLpublic.h as follows: + * \snippet this H5VL_class_value_t_snip + * + * Valid VOL connector identifiers can have values from 0 through 255 + * for connectors defined by the HDF5 library. Values 256 through 511 + * are available for testing new connectors. Subsequent values should + * be obtained by contacting the The HDF Help Desk. + * + * \p vipl_id is either #H5P_DEFAULT or the identifier of a VOL + * initialization property list of class #H5P_VOL_INITIALIZE created + * with H5Pcreate(). When created, this property list contains no + * library properties. If a VOL connector author decides that + * initialization-specific data are needed, they can be added to the + * empty list and retrieved by the connector in the VOL connector's + * initialize callback. Use of the VOL initialization property list is + * uncommon, as most VOL-specific properties are added to the file + * access property list via the connector's API calls which set the + * VOL connector for the file open/create. For more information, see + * the \ref_vol_doc. + * + * \since 1.12.0 + * + */ +H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); +/** + * \ingroup H5VL + * \brief Tests whether a VOL class has been registered under a certain name + * + * \param[in] name Alleged name of connector + * \return \htri_t + * + * \details H5VLis_connector_registered_by_name() tests whether a VOL class has + * been registered or not, according to the supplied connector name + * \p name. + * + * \since 1.12.0 + */ +H5_DLL htri_t H5VLis_connector_registered_by_name(const char *name); +/** + * \ingroup H5VL + * \brief Tests whether a VOL class has been registered for a given value + * + * \param[in] connector_value Connector value + * \return \htri_t + * + * \details H5VLis_connector_registered_by_value() tests whether a VOL class + * has been registered, according to the supplied connector value \p + * connector_value. + * + * \p connector_value has a type of H5VL_class_value_t, which is + * defined in H5VLpublic.h as follows: + * \snippet this H5VL_class_value_t_snip + * + * Valid VOL connector identifiers can have values from 0 through 255 + * for connectors defined by the HDF5 library. Values 256 through 511 + * are available for testing new connectors. Subsequent values should + * be obtained by contacting the The HDF Help Desk. + * + * \since 1.12.0 + */ +H5_DLL htri_t H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value); +/** + * \ingroup H5VL + * \brief Retrieves the VOL connector identifier for a given object identifier + * + * \obj_id + * \return \hid_t{VOL connector} + * + * \details H5VLget_connector_id() retrieves the registered VOL connector + * identifier for the specified object identifier \p obj_id. The VOL + * connector identifier must be closed with H5VLclose() when no longer + * in use. + * + * \since 1.12.0 + */ +H5_DLL hid_t H5VLget_connector_id(hid_t obj_id); +/** + * \ingroup H5VL + * \brief Retrieves the identifier for a registered VOL connector name + * + * \param[in] name Connector name + * \return \hid_t{VOL connector} + * + * \details H5VLget_connector_id_by_name() retrieves the identifier for a + * registered VOL connector with the name \p name. The identifier must + * be closed with H5VLclose() when no longer in use. + * + * \since 1.12.0 + */ +H5_DLL hid_t H5VLget_connector_id_by_name(const char *name); +/** + * \ingroup H5VL + * \brief Retrieves the identifier for a registered VOL connector value + * + * \param[in] connector_value Connector value + * \return \hid_t{VOL connector} + * + * \details H5VLget_connector_id_by_value() retrieves the identifier for a + * registered VOL connector with the value \p connector_value. The + * identifier will need to be closed by H5VLclose(). + * + * \p connector_value has a type of H5VL_class_value_t, which is + * defined in H5VLpublic.h as follows: + * \snippet this H5VL_class_value_t_snip + * + * Valid VOL connector identifiers can have values from 0 through 255 + * for connectors defined by the HDF5 library. Values 256 through 511 + * are available for testing new connectors. Subsequent values should + * be obtained by contacting the The HDF Help Desk. + * + * \since 1.12.0 + */ +H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); +/** + * \ingroup H5VL + * \brief Retrieves a connector name for a VOL + * + * \obj_id{id} or file identifier + * \param[out] name Connector name + * \param[in] size Maximum length of the name to retrieve + * \return Returns the length of the connector name on success, and a negative value on failure. + * + * \details H5VLget_connector_name() retrieves up to \p size elements of the + * VOL name \p name associated with the object or file identifier \p + * id. + * + * Passing in a NULL pointer for size will return the size of the + * connector name. This can be used to determine the size of the + * buffer to allocate for the name. + * + * \since 1.12.0 + */ +H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name /*out*/, size_t size); +/** + * \ingroup H5VL + * \brief Closes a VOL connector identifier + * + * \param[in] connector_id Connector identifier + * \return \herr_t + * + * \details H5VLclose() closes a VOL connector identifier. This does not affect + * the file access property lists which have been defined to use this + * VOL connector or files which are already opened under this + * connector. + * + * \since 1.12.0 + */ +H5_DLL herr_t H5VLclose(hid_t connector_id); +/** + * \ingroup H5VL + * \brief Removes a VOL connector identifier from the library + * + * \param[in] connector_id Connector identifier + * \return \herr_t + * + * \details H5VLunregister_connector() removes a VOL connector identifier from + * the library. This does not affect the file access property lists + * which have been defined to use the VOL connector or any files which + * are already opened with this connector. + * + * \attention H5VLunregister_connector() will fail if attempting to unregister + * the native VOL connector. + * + * \since 1.12.0 + */ +H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); +/** + * \ingroup H5VL + * \brief Determine if a VOL connector supports a particular + * optional callback operation. + * + * \obj_id + * \param[in] subcls VOL subclass + * \param[in] opt_type Option type + * \param[out] supported Flag + * \return \herr_t + * + * \since 1.12.0 + */ +H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported); + +#ifdef __cplusplus +} +#endif + +/* Semi-public headers mainly for VOL connector authors */ +#include "H5VLconnector.h" /* VOL connector author routines */ +#include "H5VLconnector_passthru.h" /* Pass-through VOL connector author routines */ +#include "H5VLnative.h" /* Native VOL connector macros, for VOL connector authors */ + +#endif /* H5VLpublic_H */ diff --git a/src/H5VM.c b/src/H5VM.c index 7be8eab0dec..4d65d7525a4 100644 --- a/src/H5VM.c +++ b/src/H5VM.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,196 +16,181 @@ * Friday, October 10, 1997 */ - #include "H5private.h" #include "H5Eprivate.h" -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" #include "H5VMprivate.h" /* Local typedefs */ typedef struct H5VM_memcpy_ud_t { - unsigned char *dst; /* Pointer to destination buffer */ - const unsigned char *src; /* Pointer to source buffer */ + unsigned char * dst; /* Pointer to destination buffer */ + const unsigned char *src; /* Pointer to source buffer */ } H5VM_memcpy_ud_t; /* Local macros */ #define H5VM_HYPER_NDIMS H5O_LAYOUT_NDIMS /* Local prototypes */ -static void -H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1); -static void -H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1, hsize_t *stride2); +static void H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, + const hsize_t *size, hsize_t *stride1); +static void H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, + const hsize_t *size, hsize_t *stride1, hsize_t *stride2); #ifdef LATER -static void -H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, - unsigned dst_n, const hsize_t *dst_size, const ssize_t *dst_stride, void *_dst, - unsigned src_n, const hsize_t *src_size, const ssize_t *src_stride, const void *_src); +static void H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, + const ssize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, + const ssize_t *src_stride, const void *_src); #endif /* LATER */ - /*------------------------------------------------------------------------- - * Function: H5VM__stride_optimize1 + * Function: H5VM__stride_optimize1 * - * Purpose: Given a stride vector which references elements of the - * specified size, optimize the dimensionality, the stride - * vector, and the element size to minimize the dimensionality - * and the number of memory accesses. + * Purpose: Given a stride vector which references elements of the + * specified size, optimize the dimensionality, the stride + * vector, and the element size to minimize the dimensionality + * and the number of memory accesses. * - * All arguments are passed by reference and their values may be - * modified by this function. + * All arguments are passed by reference and their values may be + * modified by this function. * - * Return: None + * Return: void * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ static void -H5VM__stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1) +H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1) { FUNC_ENTER_STATIC_NOERR - /* - * This has to be true because if we optimize the dimensionality down to + /* This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ HDassert(1 == H5VM_vector_reduce_product(0, NULL)); - /* - * Combine adjacent memory accesses - */ - while (*np && stride1[*np-1]>0 && - (hsize_t)(stride1[*np-1])==*elmt_size) { - *elmt_size *= size[*np-1]; + /* Combine adjacent memory accesses */ + while (*np && stride1[*np - 1] > 0 && (hsize_t)(stride1[*np - 1]) == *elmt_size) { + *elmt_size *= size[*np - 1]; if (--*np) - stride1[*np-1] += size[*np] * stride1[*np]; + stride1[*np - 1] += size[*np] * stride1[*np]; } FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- - * Function: H5VM__stride_optimize2 + * Function: H5VM__stride_optimize2 * - * Purpose: Given two stride vectors which reference elements of the - * specified size, optimize the dimensionality, the stride - * vectors, and the element size to minimize the dimensionality - * and the number of memory accesses. + * Purpose: Given two stride vectors which reference elements of the + * specified size, optimize the dimensionality, the stride + * vectors, and the element size to minimize the dimensionality + * and the number of memory accesses. * - * All arguments are passed by reference and their values may be - * modified by this function. + * All arguments are passed by reference and their values may be + * modified by this function. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ static void -H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, - const hsize_t *size, hsize_t *stride1, hsize_t *stride2) +H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, + hsize_t *stride1, hsize_t *stride2) { FUNC_ENTER_STATIC_NOERR - /* - * This has to be true because if we optimize the dimensionality down to + /* This has to be true because if we optimize the dimensionality down to * zero we still must make one reference. */ HDassert(1 == H5VM_vector_reduce_product(0, NULL)); - HDassert(*elmt_size>0); + HDassert(*elmt_size > 0); - /* - * Combine adjacent memory accesses - */ + /* Combine adjacent memory accesses */ /* Unroll loop for common cases */ - switch(*np) { + switch (*np) { case 1: /* For 0-D datasets (dunno if this ever gets used...) */ - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ break; case 2: /* For 1-D datasets */ - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ break; case 3: /* For 2-D datasets */ - if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { + if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; - --*np; /* *np decrements to a value of 2 now */ + --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ + } /* end if */ break; case 4: /* For 3-D datasets */ - if(stride1[3] == *elmt_size && stride2[3] == *elmt_size) { + if (stride1[3] == *elmt_size && stride2[3] == *elmt_size) { *elmt_size *= size[3]; - --*np; /* *np decrements to a value of 3 now */ + --*np; /* *np decrements to a value of 3 now */ stride1[2] += size[3] * stride1[3]; stride2[2] += size[3] * stride2[3]; - if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) { + if (stride1[2] == *elmt_size && stride2[2] == *elmt_size) { *elmt_size *= size[2]; - --*np; /* *np decrements to a value of 2 now */ + --*np; /* *np decrements to a value of 2 now */ stride1[1] += size[2] * stride1[2]; stride2[1] += size[2] * stride2[2]; - if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) { + if (stride1[1] == *elmt_size && stride2[1] == *elmt_size) { *elmt_size *= size[1]; - --*np; /* *np decrements to a value of 1 now */ + --*np; /* *np decrements to a value of 1 now */ stride1[0] += size[1] * stride1[1]; stride2[0] += size[1] * stride2[1]; - if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) { + if (stride1[0] == *elmt_size && stride2[0] == *elmt_size) { *elmt_size *= size[0]; - --*np; /* *np decrements to a value of 0 now */ - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ + --*np; /* *np decrements to a value of 0 now */ + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ break; default: - while (*np && - stride1[*np-1] == *elmt_size && - stride2[*np-1] == *elmt_size) { - *elmt_size *= size[*np-1]; + while (*np && stride1[*np - 1] == *elmt_size && stride2[*np - 1] == *elmt_size) { + *elmt_size *= size[*np - 1]; if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; - stride2[*np-1] += size[*np] * stride2[*np]; + stride1[*np - 1] += size[*np] * stride1[*np]; + stride2[*np - 1] += size[*np] * stride2[*np]; } } break; @@ -214,43 +199,38 @@ H5VM__stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/, FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- - * Function: H5VM_hyper_stride + * Function: H5VM_hyper_stride * - * Purpose: Given a description of a hyperslab, this function returns - * (through STRIDE[]) the byte strides appropriate for accessing - * all bytes of the hyperslab and the byte offset where the - * striding will begin. The SIZE can be passed to the various - * stride functions. + * Purpose: Given a description of a hyperslab, this function returns + * (through STRIDE[]) the byte strides appropriate for accessing + * all bytes of the hyperslab and the byte offset where the + * striding will begin. The SIZE can be passed to the various + * stride functions. * - * The dimensionality of the whole array, the hyperslab, and the - * returned stride array is N. The whole array dimensions are - * TOTAL_SIZE and the hyperslab is at offset OFFSET and has - * dimensions SIZE. + * The dimensionality of the whole array, the hyperslab, and the + * returned stride array is N. The whole array dimensions are + * TOTAL_SIZE and the hyperslab is at offset OFFSET and has + * dimensions SIZE. * - * The stride and starting point returned will cause the - * hyperslab elements to be referenced in C order. + * The stride and starting point returned will cause the + * hyperslab elements to be referenced in C order. * - * Return: Success: Byte offset from beginning of array to start - * of striding. + * Return: Byte offset from beginning of array to start of striding. * - * Failure: abort() -- should never fail - * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ hsize_t -H5VM_hyper_stride(unsigned n, const hsize_t *size, - const hsize_t *total_size, const hsize_t *offset, - hsize_t *stride/*out*/) +H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, const hsize_t *offset, + hsize_t *stride /*out*/) { - hsize_t skip; /*starting point byte offset */ - hsize_t acc; /*accumulator */ - int i; /*counter */ - hsize_t ret_value; /* Return value */ + hsize_t skip; /*starting point byte offset */ + hsize_t acc; /*accumulator */ + int i; /*counter */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -260,42 +240,42 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, HDassert(stride); /* init */ - HDassert(n>0); - stride[n-1] = 1; - skip = offset ? offset[n-1] : 0; + HDassert(n > 0); + stride[n - 1] = 1; + skip = offset ? offset[n - 1] : 0; - switch(n) { + switch (n) { case 2: /* 1-D dataset */ - HDassert(total_size[1]>=size[1]); - stride[0] = total_size[1]-size[1]; /*overflow checked*/ - acc = total_size[1]; + HDassert(total_size[1] >= size[1]); + stride[0] = total_size[1] - size[1]; /*overflow checked*/ + acc = total_size[1]; skip += acc * (offset ? offset[0] : 0); break; case 3: /* 2-D dataset */ - HDassert(total_size[2]>=size[2]); - stride[1] = total_size[2]-size[2]; /*overflow checked*/ - acc = total_size[2]; + HDassert(total_size[2] >= size[2]); + stride[1] = total_size[2] - size[2]; /*overflow checked*/ + acc = total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - HDassert(total_size[1]>=size[1]); + HDassert(total_size[1] >= size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); break; case 4: /* 3-D dataset */ - HDassert(total_size[3]>=size[3]); - stride[2] = total_size[3]-size[3]; /*overflow checked*/ - acc = total_size[3]; + HDassert(total_size[3] >= size[3]); + stride[2] = total_size[3] - size[3]; /*overflow checked*/ + acc = total_size[3]; skip += acc * (offset ? (hsize_t)offset[2] : 0); - HDassert(total_size[2]>=size[2]); + HDassert(total_size[2] >= size[2]); stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/ acc *= total_size[2]; skip += acc * (offset ? (hsize_t)offset[1] : 0); - HDassert(total_size[1]>=size[1]); + HDassert(total_size[1] >= size[1]); stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/ acc *= total_size[1]; skip += acc * (offset ? (hsize_t)offset[0] : 0); @@ -303,65 +283,63 @@ H5VM_hyper_stride(unsigned n, const hsize_t *size, default: /* others */ - for (i=(int)(n-2), acc=1; i>=0; --i) { - HDassert(total_size[i+1]>=size[i+1]); - stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/ - acc *= total_size[i+1]; + for (i = (int)(n - 2), acc = 1; i >= 0; --i) { + HDassert(total_size[i + 1] >= size[i + 1]); + stride[i] = acc * (total_size[i + 1] - size[i + 1]); /*overflow checked*/ + acc *= total_size[i + 1]; skip += acc * (offset ? (hsize_t)offset[i] : 0); } break; } /* end switch */ /* Set return value */ - ret_value=skip; + ret_value = skip; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5VM_hyper_eq + * Function: H5VM_hyper_eq * - * Purpose: Determines whether two hyperslabs are equal. This function - * assumes that both hyperslabs are relative to the same array, - * for if not, they could not possibly be equal. + * Purpose: Determines whether two hyperslabs are equal. This function + * assumes that both hyperslabs are relative to the same array, + * for if not, they could not possibly be equal. * - * Return: Success: TRUE if the hyperslabs are equal (that is, - * both refer to exactly the same elements of an - * array) + * Return: TRUE if the hyperslabs are equal (that is, + * both refer to exactly the same elements of an + * array) * - * FALSE otherwise. + * FALSE otherwise * - * Failure: TRUE the rank is zero or if both hyperslabs - * are of zero size. + * Never returns FAIL * - * Programmer: Robb Matzke - * Friday, October 17, 1997 + * Programmer: Robb Matzke + * Friday, October 17, 1997 * *------------------------------------------------------------------------- */ htri_t -H5VM_hyper_eq(unsigned n, - const hsize_t *offset1, const hsize_t *size1, - const hsize_t *offset2, const hsize_t *size2) +H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, + const hsize_t *size2) { - hsize_t nelmts1 = 1, nelmts2 = 1; - unsigned i; - htri_t ret_value=TRUE; /* Return value */ + hsize_t nelmts1 = 1, nelmts2 = 1; + unsigned i; + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (n == 0) HGOTO_DONE(TRUE) + if (n == 0) + HGOTO_DONE(TRUE) - for (i=0; i0); - dst_stride[n-1] = 1; - src_stride[n-1] = 1; - dst_start = dst_offset ? dst_offset[n-1] : 0; - src_start = src_offset ? src_offset[n-1] : 0; + HDassert(n > 0); + dst_stride[n - 1] = 1; + src_stride[n - 1] = 1; + dst_start = dst_offset ? dst_offset[n - 1] : 0; + src_start = src_offset ? src_offset[n - 1] : 0; /* Unroll loop for common cases */ - switch(n) { + switch (n) { case 2: - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/ src_stride[0] = src_size[1] - size[1]; /*overflow checked*/ - dst_acc = dst_size[1]; - src_acc = src_size[1]; + dst_acc = dst_size[1]; + src_acc = src_size[1]; dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0); src_start += src_acc * (src_offset ? src_offset[0] : 0); break; case 3: - HDassert(dst_size[2]>=size[2]); - HDassert(src_size[2]>=size[2]); + HDassert(dst_size[2] >= size[2]); + HDassert(src_size[2] >= size[2]); dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/ src_stride[1] = src_size[2] - size[2]; /*overflow checked*/ - dst_acc = dst_size[2]; - src_acc = src_size[2]; + dst_acc = dst_size[2]; + src_acc = src_size[2]; dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -557,17 +524,17 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, break; case 4: - HDassert(dst_size[3]>=size[3]); - HDassert(src_size[3]>=size[3]); + HDassert(dst_size[3] >= size[3]); + HDassert(src_size[3] >= size[3]); dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/ src_stride[2] = src_size[3] - size[3]; /*overflow checked*/ - dst_acc = dst_size[3]; - src_acc = src_size[3]; + dst_acc = dst_size[3]; + src_acc = src_size[3]; dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0); src_start += src_acc * (src_offset ? src_offset[2] : 0); - HDassert(dst_size[2]>=size[2]); - HDassert(src_size[2]>=size[2]); + HDassert(dst_size[2] >= size[2]); + HDassert(src_size[2] >= size[2]); dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/ src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/ dst_acc *= dst_size[2]; @@ -575,8 +542,8 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0); src_start += src_acc * (src_offset ? src_offset[1] : 0); - HDassert(dst_size[1]>=size[1]); - HDassert(src_size[1]>=size[1]); + HDassert(dst_size[1] >= size[1]); + HDassert(src_size[1] >= size[1]); dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/ src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/ dst_acc *= dst_size[1]; @@ -587,13 +554,13 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, default: /* others */ - for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { - HDassert(dst_size[ii+1]>=size[ii+1]); - HDassert(src_size[ii+1]>=size[ii+1]); - dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/ - src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/ - dst_acc *= dst_size[ii+1]; - src_acc *= src_size[ii+1]; + for (ii = (int)(n - 2), dst_acc = 1, src_acc = 1; ii >= 0; --ii) { + HDassert(dst_size[ii + 1] >= size[ii + 1]); + HDassert(src_size[ii + 1] >= size[ii + 1]); + dst_stride[ii] = dst_acc * (dst_size[ii + 1] - size[ii + 1]); /*overflow checked*/ + src_stride[ii] = src_acc * (src_size[ii + 1] - size[ii + 1]); /*overflow checked*/ + dst_acc *= dst_size[ii + 1]; + src_acc *= src_size[ii + 1]; dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0); src_start += src_acc * (src_offset ? src_offset[ii] : 0); } @@ -606,36 +573,35 @@ H5VM_hyper_copy(unsigned n, const hsize_t *_size, H5VM__stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride); /* Perform the copy in terms of stride */ - ret_value = H5VM_stride_copy(n, elmt_size, size, - dst_stride, dst+dst_start, src_stride, src+src_start); + ret_value = + H5VM_stride_copy(n, elmt_size, size, dst_stride, dst + dst_start, src_stride, src + src_start); FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_fill * - * Purpose: Fills all bytes of a hyperslab with the same value using - * memset(). + * Purpose: Fills all bytes of a hyperslab with the same value using + * memset(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ herr_t -H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *stride, void *_dst, unsigned fill_value) +H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, void *_dst, + unsigned fill_value) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*number of elements to fill */ - hsize_t i; /*counter */ - int j; /*counter */ - hbool_t carry; /*subtraction carray value */ + uint8_t *dst = (uint8_t *)_dst; /*cast for ptr arithmetic */ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*number of elements to fill */ + hsize_t i; /*counter */ + int j; /*counter */ + hbool_t carry; /*subtraction carray value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -643,13 +609,13 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, H5VM_vector_cpy(n, idx, size); nelmts = H5VM_vector_reduce_product(n, size); - for (i=0; i=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { dst += stride[j]; if (--idx[j]) @@ -664,54 +630,52 @@ H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_copy * - * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays - * DST and SRC while copying bytes from SRC to DST. This - * function minimizes the number of calls to memcpy() by - * combining various strides, but it will never touch memory - * outside the hyperslab defined by the strides. + * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays + * DST and SRC while copying bytes from SRC to DST. This + * function minimizes the number of calls to memcpy() by + * combining various strides, but it will never touch memory + * outside the hyperslab defined by the strides. * - * Note: If the src_stride is all zero and elmt_size is one, then it's - * probably more efficient to use H5VM_stride_fill() instead. + * Note: If the src_stride is all zero and elmt_size is one, then it's + * probably more efficient to use H5VM_stride_fill() instead. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ herr_t -H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *dst_stride, void *_dst, - const hsize_t *src_stride, const void *_src) +H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *dst_stride, void *_dst, + const hsize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ - const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*num elements to copy */ - hsize_t i; /*counter */ - int j; /*counters */ - hbool_t carry; /*carray for subtraction*/ + uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/ + const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*num elements to copy */ + hsize_t i; /*counter */ + int j; /*counters */ + hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDassert(elmt_size=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; @@ -723,62 +687,61 @@ H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size, } } } - } else { - H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ + } + else { + H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t); + H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } - /*------------------------------------------------------------------------- * Function: H5VM_stride_copy_s * - * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays - * DST and SRC while copying bytes from SRC to DST. This - * function minimizes the number of calls to memcpy() by - * combining various strides, but it will never touch memory - * outside the hyperslab defined by the strides. + * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays + * DST and SRC while copying bytes from SRC to DST. This + * function minimizes the number of calls to memcpy() by + * combining various strides, but it will never touch memory + * outside the hyperslab defined by the strides. * - * Note: If the src_stride is all zero and elmt_size is one, then it's - * probably more efficient to use H5VM_stride_fill() instead. + * Note: If the src_stride is all zero and elmt_size is one, then it's + * probably more efficient to use H5VM_stride_fill() instead. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ herr_t -H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hssize_t *dst_stride, void *_dst, - const hssize_t *src_stride, const void *_src) +H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst, + const hssize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/ - const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/ - hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ - hsize_t nelmts; /*num elements to copy */ - hsize_t i; /*counter */ - int j; /*counters */ - hbool_t carry; /*carray for subtraction*/ + uint8_t * dst = (uint8_t *)_dst; /*cast for ptr arithmetic*/ + const uint8_t *src = (const uint8_t *)_src; /*cast for ptr arithmetic*/ + hsize_t idx[H5VM_HYPER_NDIMS]; /*1-origin indices */ + hsize_t nelmts; /*num elements to copy */ + hsize_t i; /*counter */ + int j; /*counters */ + hbool_t carry; /*carray for subtraction*/ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDassert(elmt_size=0 && carry; --j) { + for (j = (int)(n - 1), carry = TRUE; j >= 0 && carry; --j) { src += src_stride[j]; dst += dst_stride[j]; @@ -790,114 +753,106 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, } } } - } else { - H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t); - H5MM_memcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ + } + else { + H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t); + H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ } FUNC_LEAVE_NOAPI(SUCCEED) } #ifdef LATER - + /*------------------------------------------------------------------------- - * Function: H5VM__stride_copy2 + * Function: H5VM__stride_copy2 * - * Purpose: Similar to H5VM_stride_copy() except the source and - * destination each have their own dimensionality and size and - * we copy exactly NELMTS elements each of size ELMT_SIZE. The - * size counters wrap if NELMTS is more than a size counter. + * Purpose: Similar to H5VM_stride_copy() except the source and + * destination each have their own dimensionality and size and + * we copy exactly NELMTS elements each of size ELMT_SIZE. The + * size counters wrap if NELMTS is more than a size counter. * - * Return: None + * Return: void * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 + * Programmer: Robb Matzke + * Saturday, October 11, 1997 * *------------------------------------------------------------------------- */ static void -H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, - - /* destination */ - unsigned dst_n, const hsize_t *dst_size, - const hsize_t *dst_stride, - void *_dst, - - /* source */ - unsigned src_n, const hsize_t *src_size, - const hsize_t *src_stride, - const void *_src) +H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, + const hsize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, + const hsize_t *src_stride, const void *_src) { - uint8_t *dst = (uint8_t *) _dst; - const uint8_t *src = (const uint8_t *) _src; - hsize_t dst_idx[H5VM_HYPER_NDIMS]; - hsize_t src_idx[H5VM_HYPER_NDIMS]; - hsize_t i; /* Local index variable */ - int j; /* Local index variable */ - hbool_t carry; + uint8_t * dst = (uint8_t *)_dst; + const uint8_t *src = (const uint8_t *)_src; + hsize_t dst_idx[H5VM_HYPER_NDIMS]; + hsize_t src_idx[H5VM_HYPER_NDIMS]; + hsize_t i; /* Local index variable */ + int j; /* Local index variable */ + hbool_t carry; FUNC_ENTER_STATIC_NOERR HDassert(elmt_size < SIZET_MAX); - HDassert(dst_n>0); - HDassert(src_n>0); + HDassert(dst_n > 0); + HDassert(src_n > 0); H5VM_vector_cpy(dst_n, dst_idx, dst_size); H5VM_vector_cpy(src_n, src_idx, src_size); - for (i=0; i=0 && carry; --j) { - dst += dst_stride[j]; - if (--dst_idx[j]) + /* Decrement indices and advance pointers */ + for (j = (int)(dst_n - 1), carry = TRUE; j >= 0 && carry; --j) { + dst += dst_stride[j]; + if (--dst_idx[j]) carry = FALSE; - else { + else { HDassert(dst_size); dst_idx[j] = dst_size[j]; } /* end else */ - } - for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) { - src += src_stride[j]; - if (--src_idx[j]) + } + for (j = (int)(src_n - 1), carry = TRUE; j >= 0 && carry; --j) { + src += src_stride[j]; + if (--src_idx[j]) carry = FALSE; - else { + else { HDassert(src_size); src_idx[j] = src_size[j]; } /* end else */ - } + } } FUNC_LEAVE_NOAPI_VOID } #endif /* LATER */ - /*------------------------------------------------------------------------- - * Function: H5VM_array_fill + * Function: H5VM_array_fill * - * Purpose: Fills all bytes of an array with the same value using - * memset(). Increases amount copied by power of two until the - * halfway point is crossed, then copies the rest in one swoop. + * Purpose: Fills all bytes of an array with the same value using + * memset(). Increases amount copied by power of two until the + * halfway point is crossed, then copies the rest in one swoop. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, June 18, 1998 + * Programmer: Quincey Koziol + * Thursday, June 18, 1998 * *------------------------------------------------------------------------- */ herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) { - size_t copy_size; /* size of the buffer to copy */ - size_t copy_items; /* number of items currently copying*/ - size_t items_left; /* number of items left to copy */ - uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */ + size_t copy_size; /* size of the buffer to copy */ + size_t copy_items; /* number of items currently copying*/ + size_t items_left; /* number of items left to copy */ + uint8_t *dst = (uint8_t *)_dst; /* alias for pointer arithmetic */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -906,51 +861,49 @@ H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count) HDassert(size < SIZET_MAX && size > 0); HDassert(count < SIZET_MAX && count > 0); - H5MM_memcpy(dst, src, size); /* copy first item */ + H5MM_memcpy(dst, src, size); /* copy first item */ /* Initialize counters, etc. while compensating for first element copied */ - copy_size = size; + copy_size = size; copy_items = 1; items_left = count - 1; dst += size; /* copy until we've copied at least half of the items */ - while (items_left >= copy_items) - { - H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */ - dst += copy_size; /* move the offset for the next chunk */ - items_left -= copy_items; /* decrement the number of items left */ - - copy_size *= 2; /* increase the size of the chunk to copy */ - copy_items *= 2; /* increase the count of items we are copying */ - } /* end while */ - if (items_left > 0) /* if there are any items left to copy */ + while (items_left >= copy_items) { + H5MM_memcpy(dst, _dst, copy_size); /* copy the current chunk */ + dst += copy_size; /* move the offset for the next chunk */ + items_left -= copy_items; /* decrement the number of items left */ + + copy_size *= 2; /* increase the size of the chunk to copy */ + copy_items *= 2; /* increase the count of items we are copying */ + } /* end while */ + if (items_left > 0) /* if there are any items left to copy */ H5MM_memcpy(dst, _dst, items_left * size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5VM_array_fill() */ +} /* H5VM_array_fill() */ - /*------------------------------------------------------------------------- - * Function: H5VM_array_down + * Function: H5VM_array_down * - * Purpose: Given a set of dimension sizes, calculate the size of each + * Purpose: Given a set of dimension sizes, calculate the size of each * "down" slice. This is the size of the dimensions for all the * dimensions below the current one, which is used for indexing * offsets in this dimension. * - * Return: Non-negative on success/Negative on failure + * Return: void * - * Programmer: Quincey Koziol - * Monday, April 28, 2003 + * Programmer: Quincey Koziol + * Monday, April 28, 2003 * *------------------------------------------------------------------------- */ -herr_t +void H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) { - hsize_t acc; /*accumulator */ - int i; /*counter */ + hsize_t acc; /* Accumulator */ + int i; /* Counter */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -958,40 +911,39 @@ H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down) HDassert(total_size); HDassert(down); - /* Build the sizes of each dimension in the array */ - /* (From fastest to slowest) */ - for(i=(int)(n-1),acc=1; i>=0; i--) { - down[i]=acc; + /* Build the sizes of each dimension in the array + * (From fastest to slowest) + */ + for (i = (int)(n - 1), acc = 1; i >= 0; i--) { + down[i] = acc; acc *= total_size[i]; - } /* end for */ + } - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI_VOID } /* end H5VM_array_down() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_offset_pre * - * Purpose: Given a coordinate description of a location in an array, this - * function returns the byte offset of the coordinate. + * Purpose: Given a coordinate description of a location in an array, this + * function returns the byte offset of the coordinate. * - * The dimensionality of the whole array, and the offset is N. + * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * - * Return: Success: Byte offset from beginning of array to element offset - * Failure: abort() -- should never fail + * Return: Byte offset from beginning of array to element offset * * Programmer: Quincey Koziol - * Tuesday, June 22, 1999 + * Tuesday, June 22, 1999 * *------------------------------------------------------------------------- */ hsize_t H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) { - unsigned u; /* Local index variable */ - hsize_t ret_value; /* Return value */ + unsigned u; /* Local index variable */ + hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1000,78 +952,72 @@ H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset) HDassert(offset); /* Compute offset in array */ - for(u = 0, ret_value = 0; u < n; u++) + for (u = 0, ret_value = 0; u < n; u++) ret_value += acc[u] * offset[u]; FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_offset_pre() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_offset * - * Purpose: Given a coordinate description of a location in an array, this - * function returns the byte offset of the coordinate. + * Purpose: Given a coordinate description of a location in an array, + * this function returns the byte offset of the coordinate. * - * The dimensionality of the whole array, and the offset is N. + * The dimensionality of the whole array, and the offset is N. * The whole array dimensions are TOTAL_SIZE and the coordinate * is at offset OFFSET. * - * Return: Success: Byte offset from beginning of array to element offset - * Failure: abort() -- should never fail + * Return: Byte offset from beginning of array to element offset * * Programmer: Quincey Koziol - * Tuesday, June 22, 1999 + * Tuesday, June 22, 1999 * *------------------------------------------------------------------------- */ hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset) { - hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */ - hsize_t ret_value; /* Return value */ + hsize_t acc_arr[H5VM_HYPER_NDIMS]; /* Accumulated size of down dimensions */ + hsize_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */ + FUNC_ENTER_NOAPI_NOERR HDassert(n <= H5VM_HYPER_NDIMS); HDassert(total_size); HDassert(offset); /* Build the sizes of each dimension in the array */ - if(H5VM_array_down(n,total_size,acc_arr)<0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes") + H5VM_array_down(n, total_size, acc_arr); /* Set return value */ - ret_value=H5VM_array_offset_pre(n,acc_arr,offset); + ret_value = H5VM_array_offset_pre(n, acc_arr, offset); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_offset() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_calc_pre * - * Purpose: Given a linear offset in an array, the dimensions of that + * Purpose: Given a linear offset in an array, the dimensions of that * array and the pre-computed 'down' (accumulator) sizes, this * function computes the coordinates of that offset in the array. * - * The dimensionality of the whole array, and the coordinates is N. + * The dimensionality of the whole array, and the coordinates is N. * The array dimensions are TOTAL_SIZE and the coordinates * are returned in COORD. The linear offset is in OFFSET. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 16, 2009 + * Programmer: Quincey Koziol + * Thursday, July 16, 2009 * *------------------------------------------------------------------------- */ herr_t -H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, - hsize_t *coords) +H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1080,7 +1026,7 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, HDassert(coords); /* Compute the coordinates from the offset */ - for(u = 0; u < n; u++) { + for (u = 0; u < n; u++) { coords[u] = offset / down[u]; offset %= down[u]; } /* end for */ @@ -1088,30 +1034,29 @@ H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VM_array_calc_pre() */ - /*------------------------------------------------------------------------- * Function: H5VM_array_calc * - * Purpose: Given a linear offset in an array and the dimensions of that + * Purpose: Given a linear offset in an array and the dimensions of that * array, this function computes the coordinates of that offset * in the array. * - * The dimensionality of the whole array, and the coordinates is N. + * The dimensionality of the whole array, and the coordinates is N. * The array dimensions are TOTAL_SIZE and the coordinates * are returned in COORD. The linear offset is in OFFSET. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Wednesday, April 16, 2003 + * Programmer: Quincey Koziol + * Wednesday, April 16, 2003 * *------------------------------------------------------------------------- */ herr_t H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords) { - hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */ - herr_t ret_value = SUCCEED; /* Return value */ + hsize_t idx[H5VM_HYPER_NDIMS]; /* Size of each dimension in bytes */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1121,22 +1066,20 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * HDassert(coords); /* Build the sizes of each dimension in the array */ - if(H5VM_array_down(n, total_size, idx) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes") + H5VM_array_down(n, total_size, idx); /* Compute the coordinates from the offset */ - if(H5VM_array_calc_pre(offset, n, idx, coords) < 0) + if (H5VM_array_calc_pre(offset, n, idx, coords) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute coordinates") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_array_calc() */ - /*------------------------------------------------------------------------- * Function: H5VM_chunk_index * - * Purpose: Given a coordinate offset (COORD), the size of each chunk + * Purpose: Given a coordinate offset (COORD), the size of each chunk * (CHUNK), the number of chunks in each dimension (NCHUNKS) * and the number of dimensions of all of these (NDIMS), calculate * a "chunk index" for the chunk that the coordinate offset is @@ -1166,19 +1109,18 @@ H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t * * The chunk index is placed in the CHUNK_IDX location for return * from this function * - * Return: Chunk index on success (can't fail) + * Return: Chunk index on success (can't fail) * - * Programmer: Quincey Koziol - * Monday, April 21, 2003 + * Programmer: Quincey Koziol + * Monday, April 21, 2003 * *------------------------------------------------------------------------- */ hsize_t -H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - const hsize_t *down_nchunks) +H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, const hsize_t *down_nchunks) { - hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */ - hsize_t chunk_idx; /* Chunk index computed */ + hsize_t scaled_coord[H5VM_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */ + hsize_t chunk_idx; /* Chunk index computed */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1194,24 +1136,22 @@ H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, FUNC_LEAVE_NOAPI(chunk_idx) } /* end H5VM_chunk_index() */ - /*------------------------------------------------------------------------- - * Function: H5VM_chunk_scaled + * Function: H5VM_chunk_scaled * - * Purpose: Compute the scaled coordinates for a chunk offset + * Purpose: Compute the scaled coordinates for a chunk offset * - * Return: + * Return: void * - * Programmer: Quincey Koziol - * Wednesday, November 19, 2014 + * Programmer: Quincey Koziol + * Wednesday, November 19, 2014 * *------------------------------------------------------------------------- */ void -H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - hsize_t *scaled) +H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, hsize_t *scaled) { - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1223,17 +1163,16 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, /* Compute the scaled coordinates for actual coordinates */ /* (Note that the 'scaled' array is an 'OUT' parameter) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) scaled[u] = coord[u] / chunk[u]; FUNC_LEAVE_NOAPI_VOID } /* end H5VM_chunk_scaled() */ - /*------------------------------------------------------------------------- * Function: H5VM_chunk_index_scaled * - * Purpose: Given a coordinate offset (COORD), the size of each chunk + * Purpose: Given a coordinate offset (COORD), the size of each chunk * (CHUNK), the number of chunks in each dimension (NCHUNKS) * and the number of dimensions of all of these (NDIMS), calculate * a "chunk index" for the chunk that the coordinate offset is @@ -1263,22 +1202,22 @@ H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, * The chunk index is placed in the CHUNK_IDX location for return * from this function * - * Note: This routine is identical to H5VM_chunk_index(), except for - * caching the scaled information. Make changes in both places. + * Note: This routine is identical to H5VM_chunk_index(), except for + * caching the scaled information. Make changes in both places. * - * Return: Chunk index on success (can't fail) + * Return: Chunk index on success (can't fail) * - * Programmer: Vailin Choi - * Monday, February 9, 2015 + * Programmer: Vailin Choi + * Monday, February 9, 2015 * *------------------------------------------------------------------------- */ hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, - const hsize_t *down_nchunks, hsize_t *scaled) + const hsize_t *down_nchunks, hsize_t *scaled) { - hsize_t chunk_idx; /* Computed chunk index */ - unsigned u; /* Local index variable */ + hsize_t chunk_idx; /* Computed chunk index */ + unsigned u; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1291,52 +1230,50 @@ H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *ch /* Compute the scaled coordinates for actual coordinates */ /* (Note that the 'scaled' array is an 'OUT' parameter) */ - for(u = 0; u < ndims; u++) + for (u = 0; u < ndims; u++) scaled[u] = coord[u] / chunk[u]; /* Compute the chunk index */ - chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks, scaled); /*lint !e772 scaled_coord will always be initialized */ + chunk_idx = H5VM_array_offset_pre(ndims, down_nchunks, + scaled); /*lint !e772 scaled_coord will always be initialized */ FUNC_LEAVE_NOAPI(chunk_idx) } /* end H5VM_chunk_index_scaled() */ - /*------------------------------------------------------------------------- * Function: H5VM_opvv * - * Purpose: Perform an operation on a source & destination sequences - * of offset/length pairs. Each set of sequnces has an array - * of lengths, an array of offsets, the maximum number of - * sequences and the current sequence to start at in the sequence. + * Purpose: Perform an operation on a source & destination sequences + * of offset/length pairs. Each set of sequnces has an array + * of lengths, an array of offsets, the maximum number of + * sequences and the current sequence to start at in the sequence. * * There may be different numbers of bytes in the source and * destination sequences, the operation stops when either the * source or destination sequence runs out of information. * - * Note: The algorithm in this routine is [basically] the same as for - * H5VM_memcpyvv(). Changes should be made to both! + * Note: The algorithm in this routine is [basically] the same as for + * H5VM_memcpyvv(). Changes should be made to both! * - * Return: Non-negative # of bytes operated on, on success/Negative on failure + * Return: Non-negative # of bytes operated on, on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, September 30, 2010 + * Programmer: Quincey Koziol + * Thursday, September 30, 2010 * *------------------------------------------------------------------------- */ ssize_t -H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], - hsize_t dst_off_arr[], - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], - hsize_t src_off_arr[], - H5VM_opvv_func_t op, void *op_data) +H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], + size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[], + H5VM_opvv_func_t op, void *op_data) { - hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ - hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ - size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ - hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */ - size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */ - size_t acc_len; /* Accumulated length of sequences */ - ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ + hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ + hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ + size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ + hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */ + size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */ + size_t acc_len; /* Accumulated length of sequences */ + ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_NOAPI(FAIL) @@ -1367,16 +1304,16 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], max_dst_off_ptr = dst_off_arr + dst_max_nseq; max_src_off_ptr = src_off_arr + src_max_nseq; -/* Work through the sequences */ -/* (Choose smallest sequence available initially) */ + /* Work through the sequences */ + /* (Choose smallest sequence available initially) */ /* Source sequence is less than destination sequence */ - if(tmp_src_len < tmp_dst_len) { + if (tmp_src_len < tmp_dst_len) { src_smaller: acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1388,7 +1325,7 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Advance source offset & check for being finished */ src_off_ptr++; - if(src_off_ptr >= max_src_off_ptr) { + if (src_off_ptr >= max_src_off_ptr) { /* Roll accumulated changes into appropriate counters */ *dst_off_ptr = tmp_dst_off; *dst_len_ptr = tmp_dst_len; @@ -1401,24 +1338,24 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - } while(tmp_src_len < tmp_dst_len); + } while (tmp_src_len < tmp_dst_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto equal; } /* end if */ /* Destination sequence is less than source sequence */ - else if(tmp_dst_len < tmp_src_len) { + else if (tmp_dst_len < tmp_src_len) { dst_smaller: acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1430,7 +1367,7 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Advance destination offset & check for being finished */ dst_off_ptr++; - if(dst_off_ptr >= max_dst_off_ptr) { + if (dst_off_ptr >= max_dst_off_ptr) { /* Roll accumulated changes into appropriate counters */ *src_off_ptr = tmp_src_off; *src_len_ptr = tmp_src_len; @@ -1443,13 +1380,13 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - } while(tmp_dst_len < tmp_src_len); + } while (tmp_dst_len < tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_src_len < tmp_dst_len) + if (tmp_src_len < tmp_dst_len) goto src_smaller; else goto equal; @@ -1460,7 +1397,7 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], acc_len = 0; do { /* Make operator callback */ - if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) + if ((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation") /* Accumulate number of bytes copied */ @@ -1469,7 +1406,7 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Advance source & destination offset & check for being finished */ src_off_ptr++; dst_off_ptr++; - if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) + if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) /* Done with sequences */ goto finished; tmp_src_off = *src_off_ptr; @@ -1482,13 +1419,13 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - } while(tmp_dst_len == tmp_src_len); + } while (tmp_dst_len == tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto src_smaller; @@ -1506,11 +1443,10 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_opvv() */ - /*------------------------------------------------------------------------- * Function: H5VM_memcpyvv * - * Purpose: Given source and destination buffers in memory (SRC & DST) + * Purpose: Given source and destination buffers in memory (SRC & DST) * copy sequences of from the source buffer into the destination * buffer. Each set of sequences has an array of lengths, an * array of offsets, the maximum number of sequences and the @@ -1520,31 +1456,30 @@ H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], * destination sequences, data copying stops when either the * source or destination buffer runs out of sequence information. * - * Note: The algorithm in this routine is [basically] the same as for - * H5VM_opvv(). Changes should be made to both! + * Note: The algorithm in this routine is [basically] the same as for + * H5VM_opvv(). Changes should be made to both! * - * Return: Non-negative # of bytes copied on success/Negative on failure + * Return: Non-negative # of bytes copied on success/Negative on failure * - * Programmer: Quincey Koziol - * Friday, May 2, 2003 + * Programmer: Quincey Koziol + * Friday, May 2, 2003 * *------------------------------------------------------------------------- */ ssize_t -H5VM_memcpyvv(void *_dst, - size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], - const void *_src, - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]) +H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], + hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, size_t *src_curr_seq, + size_t src_len_arr[], hsize_t src_off_arr[]) { - unsigned char *dst; /* Destination buffer pointer */ - const unsigned char *src; /* Source buffer pointer */ - hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ - hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ - size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ - size_t tmp_dst_len; /* Temporary dest. length value */ - size_t tmp_src_len; /* Temporary source length value */ - size_t acc_len; /* Accumulated length of sequences */ - ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ + unsigned char * dst; /* Destination buffer pointer */ + const unsigned char *src; /* Source buffer pointer */ + hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */ + hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */ + size_t * dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */ + size_t tmp_dst_len; /* Temporary dest. length value */ + size_t tmp_src_len; /* Temporary source length value */ + size_t acc_len; /* Accumulated length of sequences */ + ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1578,11 +1513,11 @@ H5VM_memcpyvv(void *_dst, dst = (unsigned char *)_dst + *dst_off_ptr; src = (const unsigned char *)_src + *src_off_ptr; -/* Work through the sequences */ -/* (Choose smallest sequence available initially) */ + /* Work through the sequences */ + /* (Choose smallest sequence available initially) */ /* Source sequence is less than destination sequence */ - if(tmp_src_len < tmp_dst_len) { + if (tmp_src_len < tmp_dst_len) { src_smaller: acc_len = 0; do { @@ -1597,7 +1532,7 @@ H5VM_memcpyvv(void *_dst, /* Advance source offset & check for being finished */ src_off_ptr++; - if(src_off_ptr >= max_src_off_ptr) { + if (src_off_ptr >= max_src_off_ptr) { /* Roll accumulated changes into appropriate counters */ *dst_off_ptr += acc_len; *dst_len_ptr = tmp_dst_len; @@ -1612,20 +1547,20 @@ H5VM_memcpyvv(void *_dst, /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - src = (const unsigned char *)_src + *src_off_ptr; - } while(tmp_src_len < tmp_dst_len); + src = (const unsigned char *)_src + *src_off_ptr; + } while (tmp_src_len < tmp_dst_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto equal; } /* end if */ /* Destination sequence is less than source sequence */ - else if(tmp_dst_len < tmp_src_len) { + else if (tmp_dst_len < tmp_src_len) { dst_smaller: acc_len = 0; do { @@ -1640,7 +1575,7 @@ H5VM_memcpyvv(void *_dst, /* Advance destination offset & check for being finished */ dst_off_ptr++; - if(dst_off_ptr >= max_dst_off_ptr) { + if (dst_off_ptr >= max_dst_off_ptr) { /* Roll accumulated changes into appropriate counters */ *src_off_ptr += acc_len; *src_len_ptr = tmp_src_len; @@ -1655,14 +1590,14 @@ H5VM_memcpyvv(void *_dst, /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - dst = (unsigned char *)_dst + *dst_off_ptr; - } while(tmp_dst_len < tmp_src_len); + dst = (unsigned char *)_dst + *dst_off_ptr; + } while (tmp_dst_len < tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_src_len < tmp_dst_len) + if (tmp_src_len < tmp_dst_len) goto src_smaller; else goto equal; @@ -1681,26 +1616,26 @@ H5VM_memcpyvv(void *_dst, /* Advance source & destination offset & check for being finished */ src_off_ptr++; dst_off_ptr++; - if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) + if (src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr) /* Done with sequences */ goto finished; /* Update source information */ src_len_ptr++; tmp_src_len = *src_len_ptr; - src = (const unsigned char *)_src + *src_off_ptr; + src = (const unsigned char *)_src + *src_off_ptr; /* Update destination information */ dst_len_ptr++; tmp_dst_len = *dst_len_ptr; - dst = (unsigned char *)_dst + *dst_off_ptr; - } while(tmp_dst_len == tmp_src_len); + dst = (unsigned char *)_dst + *dst_off_ptr; + } while (tmp_dst_len == tmp_src_len); /* Roll accumulated sequence lengths into return value */ ret_value += (ssize_t)acc_len; /* Transition to next state */ - if(tmp_dst_len < tmp_src_len) + if (tmp_dst_len < tmp_src_len) goto dst_smaller; else goto src_smaller; @@ -1716,4 +1651,3 @@ H5VM_memcpyvv(void *_dst, FUNC_LEAVE_NOAPI(ret_value) } /* end H5VM_memcpyvv() */ - diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 5c975f6bd28..0d3bd0fe795 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,124 +19,108 @@ #define H5VMprivate_H /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /* Vector-Vector sequence operation callback */ -typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, - size_t len, void *udata); +typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, size_t len, void *udata); /* Vector comparison functions like Fortran66 comparison operators */ -#define H5VM_vector_eq_s(N,V1,V2) (H5VM_vector_cmp_s(N, V1, V2) == 0) -#define H5VM_vector_lt_s(N,V1,V2) (H5VM_vector_cmp_s(N, V1, V2) < 0) -#define H5VM_vector_gt_s(N,V1,V2) (H5VM_vector_cmp_s(N, V1, V2) > 0) -#define H5VM_vector_le_s(N,V1,V2) (H5VM_vector_cmp_s(N, V1, V2) <= 0) -#define H5VM_vector_ge_s(N,V1,V2) (H5VM_vector_cmp_s(N, V1, V2) >= 0) -#define H5VM_vector_eq_u(N,V1,V2) (H5VM_vector_cmp_u(N, V1, V2) == 0) -#define H5VM_vector_lt_u(N,V1,V2) (H5VM_vector_cmp_u(N, V1, V2) < 0) -#define H5VM_vector_gt_u(N,V1,V2) (H5VM_vector_cmp_u(N, V1, V2) > 0) -#define H5VM_vector_le_u(N,V1,V2) (H5VM_vector_cmp_u(N, V1, V2) <= 0) -#define H5VM_vector_ge_u(N,V1,V2) (H5VM_vector_cmp_u(N, V1, V2) >= 0) +#define H5VM_vector_eq_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) == 0) +#define H5VM_vector_lt_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) < 0) +#define H5VM_vector_gt_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) > 0) +#define H5VM_vector_le_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) <= 0) +#define H5VM_vector_ge_s(N, V1, V2) (H5VM_vector_cmp_s(N, V1, V2) >= 0) +#define H5VM_vector_eq_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) == 0) +#define H5VM_vector_lt_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) < 0) +#define H5VM_vector_gt_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) > 0) +#define H5VM_vector_le_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) <= 0) +#define H5VM_vector_ge_u(N, V1, V2) (H5VM_vector_cmp_u(N, V1, V2) >= 0) /* Other functions */ -#define H5VM_vector_cpy(N,DST,SRC) { \ - HDassert(sizeof(*(DST))==sizeof(*(SRC))); \ - if (SRC) H5MM_memcpy (DST, SRC, (N)*sizeof(*(DST))); \ - else HDmemset (DST, 0, (N)*sizeof(*(DST))); \ -} +#define H5VM_vector_cpy(N, DST, SRC) \ + { \ + HDassert(sizeof(*(DST)) == sizeof(*(SRC))); \ + if (SRC) \ + H5MM_memcpy(DST, SRC, (N) * sizeof(*(DST))); \ + else \ + HDmemset(DST, 0, (N) * sizeof(*(DST))); \ + } -#define H5VM_vector_zero(N,DST) HDmemset(DST,0,(N)*sizeof(*(DST))) +#define H5VM_vector_zero(N, DST) HDmemset(DST, 0, (N) * sizeof(*(DST))) /* Given a coordinate offset array (COORDS) of type TYPE, move the unlimited * dimension (UNLIM_DIM) value to offset 0, sliding any intermediate values down * one position. */ -#define H5VM_swizzle_coords(TYPE,COORDS,UNLIM_DIM) { \ - /* COORDS must be an array of type TYPE */ \ - HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ - \ - /* Nothing to do when unlimited dimension is at position 0 */ \ - if(0 != (UNLIM_DIM)) { \ - TYPE _tmp = (COORDS)[UNLIM_DIM]; \ - \ - HDmemmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ - (COORDS)[0] = _tmp; \ - } /* end if */ \ -} +#define H5VM_swizzle_coords(TYPE, COORDS, UNLIM_DIM) \ + { \ + /* COORDS must be an array of type TYPE */ \ + HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ + \ + /* Nothing to do when unlimited dimension is at position 0 */ \ + if (0 != (UNLIM_DIM)) { \ + TYPE _tmp = (COORDS)[UNLIM_DIM]; \ + \ + HDmemmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ + (COORDS)[0] = _tmp; \ + } /* end if */ \ + } /* Given a coordinate offset array (COORDS) of type TYPE, move the value at * offset 0 to offset of the unlimied dimension (UNLIM_DIM), sliding any * intermediate values up one position. Undoes the "swizzle_coords" operation. */ -#define H5VM_unswizzle_coords(TYPE,COORDS,UNLIM_DIM) { \ - /* COORDS must be an array of type TYPE */ \ - HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ - \ - /* Nothing to do when unlimited dimension is at position 0 */ \ - if(0 != (UNLIM_DIM)) { \ - TYPE _tmp = (COORDS)[0]; \ - \ - HDmemmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ - (COORDS)[UNLIM_DIM] = _tmp; \ - } /* end if */ \ -} +#define H5VM_unswizzle_coords(TYPE, COORDS, UNLIM_DIM) \ + { \ + /* COORDS must be an array of type TYPE */ \ + HDassert(sizeof(COORDS[0]) == sizeof(TYPE)); \ + \ + /* Nothing to do when unlimited dimension is at position 0 */ \ + if (0 != (UNLIM_DIM)) { \ + TYPE _tmp = (COORDS)[0]; \ + \ + HDmemmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ + (COORDS)[UNLIM_DIM] = _tmp; \ + } /* end if */ \ + } /* A null pointer is equivalent to a zero vector */ -#define H5VM_ZERO NULL - -H5_DLL hsize_t H5VM_hyper_stride(unsigned n, const hsize_t *size, - const hsize_t *total_size, - const hsize_t *offset, - hsize_t *stride); -H5_DLL htri_t H5VM_hyper_eq(unsigned n, const hsize_t *offset1, - const hsize_t *size1, const hsize_t *offset2, - const hsize_t *size2); -H5_DLL herr_t H5VM_hyper_fill(unsigned n, const hsize_t *_size, - const hsize_t *total_size, - const hsize_t *offset, void *_dst, - unsigned fill_value); -H5_DLL herr_t H5VM_hyper_copy(unsigned n, const hsize_t *size, - const hsize_t *dst_total_size, - const hsize_t *dst_offset, void *_dst, - const hsize_t *src_total_size, - const hsize_t *src_offset, const void *_src); -H5_DLL herr_t H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, - const hsize_t *stride, void *_dst, - unsigned fill_value); -H5_DLL herr_t H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, - const hsize_t *dst_stride, void *_dst, - const hsize_t *src_stride, const void *_src); +#define H5VM_ZERO NULL + +H5_DLL hsize_t H5VM_hyper_stride(unsigned n, const hsize_t *size, const hsize_t *total_size, + const hsize_t *offset, hsize_t *stride); +H5_DLL htri_t H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hsize_t *offset2, + const hsize_t *size2); +H5_DLL herr_t H5VM_hyper_fill(unsigned n, const hsize_t *_size, const hsize_t *total_size, + const hsize_t *offset, void *_dst, unsigned fill_value); +H5_DLL herr_t H5VM_hyper_copy(unsigned n, const hsize_t *size, const hsize_t *dst_total_size, + const hsize_t *dst_offset, void *_dst, const hsize_t *src_total_size, + const hsize_t *src_offset, const void *_src); +H5_DLL herr_t H5VM_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size, const hsize_t *stride, + void *_dst, unsigned fill_value); +H5_DLL herr_t H5VM_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size, const hsize_t *dst_stride, + void *_dst, const hsize_t *src_stride, const void *_src); H5_DLL herr_t H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *_size, - const hssize_t *dst_stride, void *_dst, - const hssize_t *src_stride, const void *_src); -H5_DLL herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, - size_t count); -H5_DLL herr_t H5VM_array_down(unsigned n, const hsize_t *total_size, - hsize_t *down); -H5_DLL hsize_t H5VM_array_offset_pre(unsigned n, - const hsize_t *acc, const hsize_t *offset); -H5_DLL hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, - const hsize_t *offset); -H5_DLL herr_t H5VM_array_calc_pre(hsize_t offset, unsigned n, - const hsize_t *down, hsize_t *coords); -H5_DLL herr_t H5VM_array_calc(hsize_t offset, unsigned n, - const hsize_t *total_size, hsize_t *coords); -H5_DLL hsize_t H5VM_chunk_index(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, const hsize_t *down_nchunks); -H5_DLL void H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, hsize_t *scaled); -H5_DLL hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, - const uint32_t *chunk, const hsize_t *down_nchunks, hsize_t *scaled); + const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, + const void *_src); +H5_DLL herr_t H5VM_array_fill(void *_dst, const void *src, size_t size, size_t count); +H5_DLL void H5VM_array_down(unsigned n, const hsize_t *total_size, hsize_t *down); +H5_DLL hsize_t H5VM_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset); +H5_DLL hsize_t H5VM_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset); +H5_DLL herr_t H5VM_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down, hsize_t *coords); +H5_DLL herr_t H5VM_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords); +H5_DLL hsize_t H5VM_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, + const hsize_t *down_nchunks); +H5_DLL void H5VM_chunk_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, hsize_t *scaled); +H5_DLL hsize_t H5VM_chunk_index_scaled(unsigned ndims, const hsize_t *coord, const uint32_t *chunk, + const hsize_t *down_nchunks, hsize_t *scaled); H5_DLL ssize_t H5VM_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], - hsize_t dst_off_arr[], - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], - hsize_t src_off_arr[], - H5VM_opvv_func_t op, void *op_data); -H5_DLL ssize_t H5VM_memcpyvv(void *_dst, - size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[], - const void *_src, - size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]); - + hsize_t dst_off_arr[], size_t src_max_nseq, size_t *src_curr_seq, + size_t src_len_arr[], hsize_t src_off_arr[], H5VM_opvv_func_t op, void *op_data); +H5_DLL ssize_t H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], + hsize_t dst_off_arr[], const void *_src, size_t src_max_nseq, + size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]); /*------------------------------------------------------------------------- * Function: H5VM_vector_reduce_product @@ -159,16 +143,18 @@ H5_DLL ssize_t H5VM_memcpyvv(void *_dst, * *------------------------------------------------------------------------- */ -static H5_INLINE hsize_t H5_ATTR_UNUSED +static inline hsize_t H5_ATTR_UNUSED H5VM_vector_reduce_product(unsigned n, const hsize_t *v) { - hsize_t ret_value = 1; + hsize_t ret_value = 1; /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (n && !v) HGOTO_DONE(0) - while (n--) ret_value *= *v++; + if (n && !v) + HGOTO_DONE(0) + while (n--) + ret_value *= *v++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -193,10 +179,10 @@ H5VM_vector_reduce_product(unsigned n, const hsize_t *v) * *------------------------------------------------------------------------- */ -static H5_INLINE htri_t H5_ATTR_UNUSED +static inline htri_t H5_ATTR_UNUSED H5VM_vector_zerop_u(int n, const hsize_t *v) { - htri_t ret_value=TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -204,7 +190,7 @@ H5VM_vector_zerop_u(int n, const hsize_t *v) if (!v) HGOTO_DONE(TRUE) while (n--) - if (*v++) + if (*v++) HGOTO_DONE(FALSE) done: @@ -230,10 +216,10 @@ H5VM_vector_zerop_u(int n, const hsize_t *v) * *------------------------------------------------------------------------- */ -static H5_INLINE htri_t H5_ATTR_UNUSED +static inline htri_t H5_ATTR_UNUSED H5VM_vector_zerop_s(int n, const hssize_t *v) { - htri_t ret_value=TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -241,7 +227,7 @@ H5VM_vector_zerop_s(int n, const hssize_t *v) if (!v) HGOTO_DONE(TRUE) while (n--) - if (*v++) + if (*v++) HGOTO_DONE(FALSE) done: @@ -269,20 +255,25 @@ H5VM_vector_zerop_s(int n, const hssize_t *v) * *------------------------------------------------------------------------- */ -static H5_INLINE int H5_ATTR_UNUSED +static inline int H5_ATTR_UNUSED H5VM_vector_cmp_u(unsigned n, const hsize_t *v1, const hsize_t *v2) { - int ret_value=0; /* Return value */ + int ret_value = 0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (v1 == v2) HGOTO_DONE(0) - if (v1 == NULL) HGOTO_DONE(-1) - if (v2 == NULL) HGOTO_DONE(1) + if (v1 == v2) + HGOTO_DONE(0) + if (v1 == NULL) + HGOTO_DONE(-1) + if (v2 == NULL) + HGOTO_DONE(1) while (n--) { - if (*v1 < *v2) HGOTO_DONE(-1) - if (*v1 > *v2) HGOTO_DONE(1) + if (*v1 < *v2) + HGOTO_DONE(-1) + if (*v1 > *v2) + HGOTO_DONE(1) v1++; v2++; } @@ -291,9 +282,8 @@ H5VM_vector_cmp_u(unsigned n, const hsize_t *v1, const hsize_t *v2) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- - * Function: H5VM_vector_cmp_s + * Function: H5VM_vector_cmp_s * * Purpose: Compares two vectors of the same size and determines if V1 is * lexicographically less than, equal, or greater than V2. @@ -308,25 +298,30 @@ H5VM_vector_cmp_u(unsigned n, const hsize_t *v1, const hsize_t *v2) * * Failure: 0 if N is zero * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, April 8, 1998 * *------------------------------------------------------------------------- */ -static H5_INLINE int H5_ATTR_UNUSED +static inline int H5_ATTR_UNUSED H5VM_vector_cmp_s(unsigned n, const hssize_t *v1, const hssize_t *v2) { - int ret_value=0; /* Return value */ + int ret_value = 0; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if (v1 == v2) HGOTO_DONE(0) - if (v1 == NULL) HGOTO_DONE(-1) - if (v2 == NULL) HGOTO_DONE(1) + if (v1 == v2) + HGOTO_DONE(0) + if (v1 == NULL) + HGOTO_DONE(-1) + if (v2 == NULL) + HGOTO_DONE(1) while (n--) { - if (*v1 < *v2) HGOTO_DONE(-1) - if (*v1 > *v2) HGOTO_DONE(1) + if (*v1 < *v2) + HGOTO_DONE(-1) + if (*v1 > *v2) + HGOTO_DONE(1) v1++; v2++; } @@ -335,7 +330,6 @@ H5VM_vector_cmp_s(unsigned n, const hssize_t *v1, const hssize_t *v2) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5VM_vector_inc * @@ -352,34 +346,27 @@ H5VM_vector_cmp_s(unsigned n, const hssize_t *v1, const hssize_t *v2) * *------------------------------------------------------------------------- */ -static H5_INLINE void H5_ATTR_UNUSED +static inline void H5_ATTR_UNUSED H5VM_vector_inc(int n, hsize_t *v1, const hsize_t *v2) { - while (n--) *v1++ += *v2++; + while (n--) + *v1++ += *v2++; } /* Lookup table for general log2(n) routine */ -static const unsigned char LogTable256[] = -{ - 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 +static const unsigned char LogTable256[] = { + /* clang-clang-format off */ + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 + /* clang-clang-format on */ }; - /*------------------------------------------------------------------------- * Function: H5VM_log2_gen * @@ -403,36 +390,33 @@ static const unsigned char LogTable256[] = * *------------------------------------------------------------------------- */ -static H5_INLINE unsigned H5_ATTR_UNUSED +static inline unsigned H5_ATTR_UNUSED H5VM_log2_gen(uint64_t n) { - unsigned r; /* r will be log2(n) */ - register unsigned int t, tt, ttt; /* temporaries */ + unsigned r; /* r will be log2(n) */ + register unsigned int t, tt, ttt; /* temporaries */ - if((ttt = (unsigned)(n >> 32))) - if((tt = (unsigned)(n >> 48))) - r = (t = (unsigned)(n >> 56)) ? 56 + (unsigned)LogTable256[t] : 48 + (unsigned)LogTable256[tt & 0xFF]; + if ((ttt = (unsigned)(n >> 32))) + if ((tt = (unsigned)(n >> 48))) + r = (t = (unsigned)(n >> 56)) ? 56 + (unsigned)LogTable256[t] + : 48 + (unsigned)LogTable256[tt & 0xFF]; else - r = (t = (unsigned)(n >> 40)) ? 40 + (unsigned)LogTable256[t] : 32 + (unsigned)LogTable256[ttt & 0xFF]; + r = (t = (unsigned)(n >> 40)) ? 40 + (unsigned)LogTable256[t] + : 32 + (unsigned)LogTable256[ttt & 0xFF]; + else if ((tt = (unsigned)(n >> 16))) + r = (t = (unsigned)(n >> 24)) ? 24 + (unsigned)LogTable256[t] : 16 + (unsigned)LogTable256[tt & 0xFF]; else - if((tt = (unsigned)(n >> 16))) - r = (t = (unsigned)(n >> 24)) ? 24 + (unsigned)LogTable256[t] : 16 + (unsigned)LogTable256[tt & 0xFF]; - else - /* Added 'uint8_t' cast to pacify PGCC compiler */ - r = (t = (unsigned)(n >> 8)) ? 8 + (unsigned)LogTable256[t] : (unsigned)LogTable256[(uint8_t)n]; + /* Added 'uint8_t' cast to pacify PGCC compiler */ + r = (t = (unsigned)(n >> 8)) ? 8 + (unsigned)LogTable256[t] : (unsigned)LogTable256[(uint8_t)n]; - return(r); + return (r); } /* H5VM_log2_gen() */ - /* Lookup table for specialized log2(n) of power of two routine */ -static const unsigned MultiplyDeBruijnBitPosition[32] = -{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, - 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 -}; +static const unsigned MultiplyDeBruijnBitPosition[32] = {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, + 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, + 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; - /*------------------------------------------------------------------------- * Function: H5VM_log2_of2 * @@ -455,47 +439,45 @@ static const unsigned MultiplyDeBruijnBitPosition[32] = * *------------------------------------------------------------------------- */ -static H5_INLINE H5_ATTR_PURE unsigned +static inline H5_ATTR_PURE unsigned H5VM_log2_of2(uint32_t n) { #ifndef NDEBUG HDassert(POWER_OF_TWO(n)); #endif /* NDEBUG */ - return(MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]); + return (MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]); } /* H5VM_log2_of2() */ - /*------------------------------------------------------------------------- - * Function: H5VM_power2up + * Function: H5VM_power2up * - * Purpose: Round up a number to the next power of 2 + * Purpose: Round up a number to the next power of 2 * * Note: Although this routine is 'static' in this file, that's intended * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Return the number which is a power of 2 + * Return: Return the number which is a power of 2 * - * Programmer: Vailin Choi; Nov 2014 + * Programmer: Vailin Choi; Nov 2014 * *------------------------------------------------------------------------- */ -static H5_INLINE H5_ATTR_CONST hsize_t +static inline H5_ATTR_CONST hsize_t H5VM_power2up(hsize_t n) { - hsize_t ret_value = 1; /* Return value */ + hsize_t ret_value = 1; /* Return value */ /* Returns 0 when n exceeds 2^63 */ - if(n >= (hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) + if (n >= (hsize_t)1 << ((sizeof(hsize_t) * CHAR_BIT) - 1)) ret_value = 0; - while(ret_value && ret_value < n) + while (ret_value && ret_value < n) ret_value <<= 1; - return(ret_value); + return (ret_value); } /* H5VM_power2up */ - /*------------------------------------------------------------------------- * Function: H5VM_limit_enc_size * @@ -513,24 +495,23 @@ H5VM_power2up(hsize_t n) * *------------------------------------------------------------------------- */ -static H5_INLINE unsigned H5_ATTR_UNUSED +static inline unsigned H5_ATTR_UNUSED H5VM_limit_enc_size(uint64_t limit) { return (H5VM_log2_gen(limit) / 8) + 1; } /* end H5VM_limit_enc_size() */ -static const unsigned char H5VM_bit_set_g[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; +static const unsigned char H5VM_bit_set_g[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; static const unsigned char H5VM_bit_clear_g[8] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE}; - /*------------------------------------------------------------------------- * Function: H5VM_bit_get * * Purpose: Determine the value of the n'th bit in a buffer. * - * Note: No range checking on is performed! + * Note: No range checking on is performed! * - * Note #2: Bits are sequentially stored in the buffer, starting with bit + * Note #2: Bits are sequentially stored in the buffer, starting with bit * offset 0 in the first byte's high-bit position, proceeding down * to bit offset 7 in the first byte's low-bit position, then to * bit offset 8 in the second byte's high-bit position, etc. @@ -546,22 +527,21 @@ static const unsigned char H5VM_bit_clear_g[8] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, * *------------------------------------------------------------------------- */ -static H5_INLINE hbool_t H5_ATTR_UNUSED +static inline hbool_t H5_ATTR_UNUSED H5VM_bit_get(const unsigned char *buf, size_t offset) { /* Test the appropriate bit in the buffer */ return (hbool_t)((buf[offset / 8] & (H5VM_bit_set_g[offset % 8])) ? TRUE : FALSE); } /* end H5VM_bit_get() */ - /*------------------------------------------------------------------------- * Function: H5VM_bit_set * * Purpose: Set/reset the n'th bit in a buffer. * - * Note: No range checking on is performed! + * Note: No range checking on is performed! * - * Note #2: Bits are sequentially stored in the buffer, starting with bit + * Note #2: Bits are sequentially stored in the buffer, starting with bit * offset 0 in the first byte's high-bit position, proceeding down * to bit offset 7 in the first byte's low-bit position, then to * bit offset 8 in the second byte's high-bit position, etc. @@ -577,15 +557,14 @@ H5VM_bit_get(const unsigned char *buf, size_t offset) * *------------------------------------------------------------------------- */ -static H5_INLINE void H5_ATTR_UNUSED +static inline void H5_ATTR_UNUSED H5VM_bit_set(unsigned char *buf, size_t offset, hbool_t val) { /* Set/reset the appropriate bit in the buffer */ - if(val) + if (val) buf[offset / 8] |= H5VM_bit_set_g[offset % 8]; else buf[offset / 8] &= H5VM_bit_clear_g[offset % 8]; } /* end H5VM_bit_set() */ #endif /* H5VMprivate_H */ - diff --git a/src/H5WB.c b/src/H5WB.c index abeaf634457..df7627f711f 100644 --- a/src/H5WB.c +++ b/src/H5WB.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,54 +28,47 @@ /* Module Setup */ /****************/ - /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ /* Typedef for buffer wrapper */ struct H5WB_t { - void *wrapped_buf; /* Pointer to wrapped buffer */ - size_t wrapped_size; /* Size of wrapped buffer */ - void *actual_buf; /* Pointer to actual buffer */ - size_t actual_size; /* Size of actual buffer used */ - size_t alloc_size; /* Size of actual buffer allocated */ + void * wrapped_buf; /* Pointer to wrapped buffer */ + size_t wrapped_size; /* Size of wrapped buffer */ + void * actual_buf; /* Pointer to actual buffer */ + size_t actual_size; /* Size of actual buffer used */ + size_t alloc_size; /* Size of actual buffer allocated */ }; - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -86,8 +79,6 @@ H5FL_DEFINE_STATIC(H5WB_t); /* Declare a free list to manage the extra buffer information */ H5FL_BLK_DEFINE_STATIC(extra_buf); - - /*------------------------------------------------------------------------- * Function: H5WB_wrap * @@ -104,8 +95,8 @@ H5FL_BLK_DEFINE_STATIC(extra_buf); H5WB_t * H5WB_wrap(void *buf, size_t buf_size) { - H5WB_t *wb = NULL; /* Wrapped buffer info */ - H5WB_t *ret_value; /* Return value */ + H5WB_t *wb = NULL; /* Wrapped buffer info */ + H5WB_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -116,30 +107,29 @@ H5WB_wrap(void *buf, size_t buf_size) HDassert(buf_size); /* Create wrapped buffer info */ - if(NULL == (wb = H5FL_MALLOC(H5WB_t))) + if (NULL == (wb = H5FL_MALLOC(H5WB_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for wrapped buffer info") /* Wrap buffer given */ - wb->wrapped_buf = buf; + wb->wrapped_buf = buf; wb->wrapped_size = buf_size; /* No actual buffer yet */ - wb->actual_buf = NULL; + wb->actual_buf = NULL; wb->actual_size = 0; - wb->alloc_size = 0; + wb->alloc_size = 0; /* Set the return value */ ret_value = wb; done: /* Release resources on error */ - if(!ret_value && wb) + if (!ret_value && wb) wb = H5FL_FREE(H5WB_t, wb); FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_wrap() */ - /*------------------------------------------------------------------------- * Function: H5WB_actual * @@ -157,7 +147,7 @@ H5WB_wrap(void *buf, size_t buf_size) void * H5WB_actual(H5WB_t *wb, size_t need) { - void *ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -168,12 +158,12 @@ H5WB_actual(H5WB_t *wb, size_t need) HDassert(wb->wrapped_buf); /* Check for previously allocated buffer */ - if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { + if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { /* Sanity check */ HDassert(wb->actual_size > wb->wrapped_size); /* Check if we can re-use existing buffer */ - if(need <= wb->alloc_size) + if (need <= wb->alloc_size) HGOTO_DONE(wb->actual_buf) /* Can't re-use existing buffer, free it and proceed */ else @@ -181,9 +171,9 @@ H5WB_actual(H5WB_t *wb, size_t need) } /* end if */ /* Check if size needed can be fulfilled with wrapped buffer */ - if(need > wb->wrapped_size) { + if (need > wb->wrapped_size) { /* Need to allocate new buffer */ - if(NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need))) + if (NULL == (wb->actual_buf = H5FL_BLK_MALLOC(extra_buf, need))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed") /* Remember size of buffer allocated */ @@ -200,13 +190,12 @@ H5WB_actual(H5WB_t *wb, size_t need) done: /* Remember size of buffer used, if we were successful */ - if(ret_value) + if (ret_value) wb->actual_size = need; FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_actual() */ - /*------------------------------------------------------------------------- * Function: H5WB_actual_clear * @@ -224,7 +213,7 @@ H5WB_actual(H5WB_t *wb, size_t need) void * H5WB_actual_clear(H5WB_t *wb, size_t need) { - void *ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -235,7 +224,7 @@ H5WB_actual_clear(H5WB_t *wb, size_t need) HDassert(wb->wrapped_buf); /* Get a pointer to an actual buffer */ - if(NULL == (ret_value = H5WB_actual(wb, need))) + if (NULL == (ret_value = H5WB_actual(wb, need))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear the buffer */ @@ -245,7 +234,6 @@ H5WB_actual_clear(H5WB_t *wb, size_t need) FUNC_LEAVE_NOAPI(ret_value) } /* end H5WB_actual_clear() */ - /*------------------------------------------------------------------------- * Function: H5WB_unwrap * @@ -270,7 +258,7 @@ H5WB_unwrap(H5WB_t *wb) HDassert(wb->wrapped_buf); /* Release any extra buffers allocated */ - if(wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { + if (wb->actual_buf && wb->actual_buf != wb->wrapped_buf) { /* Sanity check */ HDassert(wb->actual_size > wb->wrapped_size); @@ -282,4 +270,3 @@ H5WB_unwrap(H5WB_t *wb) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5WB_unwrap() */ - diff --git a/src/H5WBprivate.h b/src/H5WBprivate.h index 3ec9261d344..109236560a7 100644 --- a/src/H5WBprivate.h +++ b/src/H5WBprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,8 +22,8 @@ *------------------------------------------------------------------------- */ -#ifndef _H5WBprivate_H -#define _H5WBprivate_H +#ifndef H5WBprivate_H +#define H5WBprivate_H /* Include package's public header */ /* #include "H5WBpublic.h" */ @@ -34,7 +34,6 @@ /* Library Private Macros */ /**************************/ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -42,21 +41,18 @@ /* Wrapped buffer info (forward decl - defined in H5WB.c) */ typedef struct H5WB_t H5WB_t; - /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ /* General routines for wrapped buffer operations */ H5_DLL H5WB_t *H5WB_wrap(void *buf, size_t buf_size); -H5_DLL void *H5WB_actual(H5WB_t *wb, size_t need); -H5_DLL void *H5WB_actual_clear(H5WB_t *wb, size_t need); -H5_DLL herr_t H5WB_unwrap(H5WB_t *wb); - -#endif /* _H5WBprivate_H */ +H5_DLL void * H5WB_actual(H5WB_t *wb, size_t need); +H5_DLL void * H5WB_actual_clear(H5WB_t *wb, size_t need); +H5_DLL herr_t H5WB_unwrap(H5WB_t *wb); +#endif /* H5WBprivate_H */ diff --git a/src/H5Z.c b/src/H5Z.c index 573a078bd9f..6b4402424d4 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -6,65 +6,65 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5PLprivate.h" /* Plugins */ -#include "H5Sprivate.h" /* Dataspace functions */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ + +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5Sprivate.h" /* Dataspace functions */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif /* Local typedefs */ #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { - hsize_t total; /* total number of bytes processed */ - hsize_t errors; /* bytes of total attributable to errors */ - H5_timevals_t times; /* execution time including errors */ - } stats[2]; /* 0 = output, 1 = input */ + hsize_t total; /* total number of bytes processed */ + hsize_t errors; /* bytes of total attributable to errors */ + H5_timevals_t times; /* execution time including errors */ + } stats[2]; /* 0 = output, 1 = input */ } H5Z_stats_t; #endif /* H5Z_DEBUG */ typedef struct H5Z_object_t { - H5Z_filter_t filter_id; /* ID of the filter we're looking for */ - htri_t found; /* Whether we find an object using the filter */ + H5Z_filter_t filter_id; /* ID of the filter we're looking for */ + htri_t found; /* Whether we find an object using the filter */ #ifdef H5_HAVE_PARALLEL - hbool_t sanity_checked; /* Whether the sanity check for collectively calling H5Zunregister has been done */ -#endif /* H5_HAVE_PARALLEL */ + hbool_t + sanity_checked; /* Whether the sanity check for collectively calling H5Zunregister has been done */ +#endif /* H5_HAVE_PARALLEL */ } H5Z_object_t; /* Enumerated type for dataset creation prelude callbacks */ typedef enum { - H5Z_PRELUDE_CAN_APPLY, /* Call "can apply" callback */ - H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ + H5Z_PRELUDE_CAN_APPLY, /* Call "can apply" callback */ + H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ } H5Z_prelude_type_t; /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local variables */ -static size_t H5Z_table_alloc_g = 0; -static size_t H5Z_table_used_g = 0; -static H5Z_class2_t *H5Z_table_g = NULL; +static size_t H5Z_table_alloc_g = 0; +static size_t H5Z_table_used_g = 0; +static H5Z_class2_t *H5Z_table_g = NULL; #ifdef H5Z_DEBUG -static H5Z_stats_t *H5Z_stat_table_g = NULL; +static H5Z_stats_t *H5Z_stat_table_g = NULL; #endif /* H5Z_DEBUG */ /* Local functions */ @@ -73,7 +73,6 @@ static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t obj_id, void *key) static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key); static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); - /*------------------------------------------------------------------------- * Function: H5Z__init_package * @@ -85,7 +84,7 @@ static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); herr_t H5Z__init_package(void) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -99,7 +98,7 @@ H5Z__init_package(void) if (H5Z_register(H5Z_SCALEOFFSET) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") - /* External filters */ + /* External filters */ #ifdef H5_HAVE_FILTER_DEFLATE if (H5Z_register(H5Z_DEFLATE) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") @@ -114,7 +113,6 @@ H5Z__init_package(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__init_package() */ - /*------------------------------------------------------------------------- * Function: H5Z_term_package * @@ -126,34 +124,37 @@ H5Z__init_package(void) int H5Z_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { + if (H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - char comment[16], bandwidth[32]; - int dir, nprint = 0; - size_t i; - - if(H5DEBUG(Z)) { - for(i = 0; i < H5Z_table_used_g; i++) { - for(dir = 0; dir<2; dir++) { - if(0 == H5Z_stat_table_g[i].stats[dir].total) - continue; - - if(0 == nprint++) { + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; + + if (H5DEBUG(Z)) { + for (i = 0; i < H5Z_table_used_g; i++) { + for (dir = 0; dir < 2; dir++) { + struct { + char *user; + char *system; + char *elapsed; + } timestrs = {H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.user), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.system), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.elapsed)}; + if (0 == H5Z_stat_table_g[i].stats[dir].total) + goto next; + + if (0 == nprint++) { /* Print column headers */ HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " - "accumulated over life of library:\n"); - HDfprintf(H5DEBUG(Z), - " %-16s %10s %10s %8s %8s %8s %10s\n", - "Filter", "Total", "Errors", "User", - "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(Z), - " %-16s %10s %10s %8s %8s %8s %10s\n", - "------", "-----", "------", "----", - "------", "-------", "---------"); + "accumulated over life of library:\n"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", + "Errors", "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", + "------", "----", "------", "-------", "---------"); } /* end if */ /* Truncate the comment to fit in the field */ @@ -161,30 +162,29 @@ H5Z_term_package(void) comment[sizeof(comment) - 1] = '\0'; /* - * Format bandwidth to have four significant digits and - * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or - * the word `Inf' if the elapsed time is zero. - */ - H5_bandwidth(bandwidth, - (double)(H5Z_stat_table_g[i].stats[dir].total), - H5Z_stat_table_g[i].stats[dir].times.elapsed); + * Format bandwidth to have four significant digits and + * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or + * the word `Inf' if the elapsed time is zero. + */ + H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), + H5Z_stat_table_g[i].stats[dir].times.elapsed); /* Print the statistics */ - HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8T %8T %8T %10s\n", - (dir ? "<" : ">"), comment, - H5Z_stat_table_g[i].stats[dir].total, - H5Z_stat_table_g[i].stats[dir].errors, - H5Z_stat_table_g[i].stats[dir].times.user, - H5Z_stat_table_g[i].stats[dir].times.system, - H5Z_stat_table_g[i].stats[dir].times.elapsed, - bandwidth); + HDfprintf(H5DEBUG(Z), " %s%-15s %10" PRIdHSIZE " %10" PRIdHSIZE " %8s %8s %8s %10s\n", + (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, + H5Z_stat_table_g[i].stats[dir].errors, timestrs.user, timestrs.system, + timestrs.elapsed, bandwidth); +next: + HDfree(timestrs.user); + HDfree(timestrs.system); + HDfree(timestrs.elapsed); } /* end for */ - } /* end for */ - } /* end if */ -#endif /* H5Z_DEBUG */ + } /* end for */ + } /* end if */ +#endif /* H5Z_DEBUG */ /* Free the table of filters */ - if(H5Z_table_g) { + if (H5Z_table_g) { H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG @@ -203,7 +203,6 @@ H5Z_term_package(void) FUNC_LEAVE_NOAPI(n) } /* end H5Z_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Zregister * @@ -215,17 +214,17 @@ H5Z_term_package(void) herr_t H5Zregister(const void *cls) { - const H5Z_class2_t *cls_real = (const H5Z_class2_t *) cls; /* "Real" class pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5Z_class2_t *cls_real = (const H5Z_class2_t *)cls; /* "Real" class pointer */ + herr_t ret_value = SUCCEED; /* Return value */ #ifndef H5_NO_DEPRECATED_SYMBOLS - H5Z_class2_t cls_new; /* Translated class struct */ + H5Z_class2_t cls_new; /* Translated class struct */ #endif FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", cls); /* Check args */ - if (cls_real==NULL) + if (cls_real == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class") /* Check H5Z_class_t version number; this is where a function to convert @@ -241,26 +240,26 @@ H5Zregister(const void *cls) if (cls_real->version != H5Z_CLASS_T_VERS) { #ifndef H5_NO_DEPRECATED_SYMBOLS /* Assume it is an old "H5Z_class1_t" instead */ - const H5Z_class1_t *cls_old = (const H5Z_class1_t *) cls; + const H5Z_class1_t *cls_old = (const H5Z_class1_t *)cls; /* Translate to new H5Z_class2_t */ - cls_new.version = H5Z_CLASS_T_VERS; - cls_new.id = cls_old->id; + cls_new.version = H5Z_CLASS_T_VERS; + cls_new.id = cls_old->id; cls_new.encoder_present = 1; cls_new.decoder_present = 1; - cls_new.name = cls_old->name; - cls_new.can_apply = cls_old->can_apply; - cls_new.set_local = cls_old->set_local; - cls_new.filter = cls_old->filter; + cls_new.name = cls_old->name; + cls_new.can_apply = cls_old->can_apply; + cls_new.set_local = cls_old->set_local; + cls_new.filter = cls_old->filter; /* Set cls_real to point to the translated structure */ cls_real = &cls_new; -#else /* H5_NO_DEPRECATED_SYMBOLS */ +#else /* H5_NO_DEPRECATED_SYMBOLS */ /* Deprecated symbols not allowed, throw an error */ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - } /* end if */ + } /* end if */ if (cls_real->id < 0 || cls_real->id > H5Z_FILTER_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") @@ -277,7 +276,6 @@ H5Zregister(const void *cls) FUNC_LEAVE_API(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_register * @@ -289,10 +287,10 @@ H5Zregister(const void *cls) *------------------------------------------------------------------------- */ herr_t -H5Z_register (const H5Z_class2_t *cls) +H5Z_register(const H5Z_class2_t *cls) { - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -307,7 +305,7 @@ H5Z_register (const H5Z_class2_t *cls) /* Filter not already registered */ if (i >= H5Z_table_used_g) { if (H5Z_table_used_g >= H5Z_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5Z_table_alloc_g); + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5Z_table_alloc_g); H5Z_class2_t *table = (H5Z_class2_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t)); @@ -325,22 +323,21 @@ H5Z_register (const H5Z_class2_t *cls) /* Initialize */ i = H5Z_table_used_g++; - H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + H5MM_memcpy(H5Z_table_g + i, cls, sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG - HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); + HDmemset(H5Z_stat_table_g + i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ - } /* end if */ + } /* end if */ /* Filter already registered */ else { /* Replace old contents */ - H5MM_memcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + H5MM_memcpy(H5Z_table_g + i, cls, sizeof(H5Z_class2_t)); } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Zunregister * @@ -353,7 +350,7 @@ H5Z_register (const H5Z_class2_t *cls) herr_t H5Zunregister(H5Z_filter_t id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Zf", id); @@ -365,14 +362,13 @@ H5Zunregister(H5Z_filter_t id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") /* Do it */ - if(H5Z__unregister(id) < 0) + if (H5Z__unregister(id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") done: FUNC_LEAVE_API(ret_value) } /* end H5Zunregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__unregister * @@ -386,9 +382,9 @@ H5Zunregister(H5Z_filter_t id) herr_t H5Z__unregister(H5Z_filter_t filter_id) { - size_t filter_index; /* Local index variable for filter */ - H5Z_object_t object; /* Object to pass to callbacks */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t filter_index; /* Local index variable for filter */ + H5Z_object_t object; /* Object to pass to callbacks */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -404,10 +400,10 @@ H5Z__unregister(H5Z_filter_t filter_id) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") /* Initialize the structure object for iteration */ - object.filter_id = filter_id; - object.found = FALSE; + object.filter_id = filter_id; + object.found = FALSE; #ifdef H5_HAVE_PARALLEL - object.sanity_checked = FALSE; + object.sanity_checked = FALSE; #endif /* H5_HAVE_PARALLEL */ /* Iterate through all opened datasets, returns a failure if any of them uses the filter */ @@ -415,14 +411,16 @@ H5Z__unregister(H5Z_filter_t filter_id) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") if (object.found) - HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a dataset is still using it") + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, + "can't unregister filter because a dataset is still using it") /* Iterate through all opened groups, returns a failure if any of them uses the filter */ if (H5I_iterate(H5I_GROUP, H5Z__check_unregister_group_cb, &object, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") if (object.found) - HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a group is still using it") + HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, + "can't unregister filter because a group is still using it") /* Iterate through all opened files and flush them */ if (H5I_iterate(H5I_FILE, H5Z__flush_file_cb, &object, FALSE) < 0) @@ -430,9 +428,11 @@ H5Z__unregister(H5Z_filter_t filter_id) /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index + 1], + sizeof(H5Z_class2_t) * ((H5Z_table_used_g - 1) - filter_index)); #ifdef H5Z_DEBUG - HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index+1], sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index + 1], + sizeof(H5Z_stats_t) * ((H5Z_table_used_g - 1) - filter_index)); #endif /* H5Z_DEBUG */ H5Z_table_used_g--; @@ -440,7 +440,6 @@ H5Z__unregister(H5Z_filter_t filter_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__unregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister * @@ -455,8 +454,8 @@ H5Z__unregister(H5Z_filter_t filter_id) static htri_t H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id) { - H5P_genplist_t *plist; /* Property list */ - htri_t ret_value = FALSE; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -472,7 +471,6 @@ H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister_group_cb * @@ -490,17 +488,17 @@ H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id) static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { - hid_t ocpl_id = -1; - H5Z_object_t *object = (H5Z_object_t *)key; - htri_t filter_in_pline = FALSE; - int ret_value = FALSE; /* Return value */ + hid_t ocpl_id = -1; + H5Z_object_t *object = (H5Z_object_t *)key; + htri_t filter_in_pline = FALSE; + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_ptr); /* Get the group creation property */ - if((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) + if ((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list") /* Check if the filter is in the group creation property list */ @@ -512,7 +510,7 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void */ if (filter_in_pline) { object->found = TRUE; - ret_value = TRUE; + ret_value = TRUE; } done: @@ -523,7 +521,6 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_group_cb() */ - /*------------------------------------------------------------------------- * Function: H5Z__check_unregister_dset_cb * @@ -541,10 +538,10 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { - hid_t ocpl_id = -1; - H5Z_object_t *object = (H5Z_object_t *)key; - htri_t filter_in_pline = FALSE; - int ret_value = FALSE; /* Return value */ + hid_t ocpl_id = -1; + H5Z_object_t *object = (H5Z_object_t *)key; + htri_t filter_in_pline = FALSE; + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -563,7 +560,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * */ if (filter_in_pline) { object->found = TRUE; - ret_value = TRUE; + ret_value = TRUE; } done: @@ -574,7 +571,6 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_dset_cb() */ - /*------------------------------------------------------------------------- * Function: H5Z__flush_file_cb * @@ -586,14 +582,13 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * *------------------------------------------------------------------------- */ static int -H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, - void *key H5_ATTR_PARALLEL_USED) +H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_PARALLEL_USED *key) { - H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ + H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ #ifdef H5_HAVE_PARALLEL - H5Z_object_t *object = (H5Z_object_t *)key; -#endif /* H5_HAVE_PARALLEL */ - int ret_value = FALSE; /* Return value */ + H5Z_object_t *object = (H5Z_object_t *)key; +#endif /* H5_HAVE_PARALLEL */ + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -602,30 +597,30 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, HDassert(key); /* Do a global flush if the file is opened for write */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { + if (H5F_ACC_RDWR & H5F_INTENT(f)) { /* When parallel HDF5 is defined, check for collective metadata reads on this * file and set the flag for metadata I/O in the API context. -QAK, 2018/02/14 */ #ifdef H5_HAVE_PARALLEL /* Check if MPIO driver is used */ - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ /* Sanity check for collectively calling H5Zunregister, if requested */ /* (Sanity check assumes that a barrier on one file's comm * is sufficient (i.e. that there aren't different comms for * different files). -QAK, 2018/02/14) */ - if(H5_coll_api_sanity_check_g && !object->sanity_checked) { - MPI_Comm mpi_comm; /* File's communicator */ + if (H5_coll_api_sanity_check_g && !object->sanity_checked) { + MPI_Comm mpi_comm; /* File's communicator */ /* Retrieve the file communicator */ - if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) + if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get MPI communicator") /* Issue the barrier */ - if(mpi_comm != MPI_COMM_NULL) + if (mpi_comm != MPI_COMM_NULL) MPI_Barrier(mpi_comm); /* Set the "sanity checked" flag */ @@ -634,13 +629,13 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, /* Check whether to use the collective metadata read DXPL */ coll_md_read = H5F_COLL_MD_READ(f); - if(H5P_USER_TRUE == coll_md_read) + if (H5P_USER_TRUE == coll_md_read) H5CX_set_coll_metadata_read(TRUE); } /* end if */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts((H5F_t *)obj_ptr) < 0) + if (H5F_flush_mounts((H5F_t *)obj_ptr) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") } /* end if */ @@ -648,7 +643,6 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__flush_file_cb() */ - /*------------------------------------------------------------------------- * Function: H5Zfilter_avail * @@ -660,7 +654,7 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, htri_t H5Zfilter_avail(H5Z_filter_t id) { - htri_t ret_value = FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Zf", id); @@ -676,7 +670,6 @@ H5Zfilter_avail(H5Z_filter_t id) FUNC_LEAVE_API(ret_value) } /* end H5Zfilter_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_avail * @@ -688,10 +681,10 @@ H5Zfilter_avail(H5Z_filter_t id) htri_t H5Z_filter_avail(H5Z_filter_t id) { - H5PL_key_t key; /* Key for finding a plugin */ - const H5Z_class2_t *filter_info; /* Filter information */ - size_t i; /* Local index variable */ - htri_t ret_value = FALSE; /* Return value */ + H5PL_key_t key; /* Key for finding a plugin */ + const H5Z_class2_t *filter_info; /* Filter information */ + size_t i; /* Local index variable */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -701,8 +694,8 @@ H5Z_filter_avail(H5Z_filter_t id) HGOTO_DONE(TRUE) key.id = (int)id; - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) { - if(H5Z_register(filter_info) < 0) + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { + if (H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") HGOTO_DONE(TRUE) } /* end if */ @@ -711,7 +704,6 @@ H5Z_filter_avail(H5Z_filter_t id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z__prelude_callback * @@ -726,12 +718,12 @@ H5Z_filter_avail(H5Z_filter_t id) *------------------------------------------------------------------------- */ static herr_t -H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, - hid_t space_id, H5Z_prelude_type_t prelude_type) +H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, hid_t space_id, + H5Z_prelude_type_t prelude_type) { - H5Z_class2_t *fclass; /* Individual filter information */ - size_t u; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + H5Z_class2_t *fclass; /* Individual filter information */ + size_t u; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -743,7 +735,7 @@ H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, if (NULL == (fclass = H5Z_find(pline->filter[u].id))) { /* Ignore errors from optional filters */ if (pline->filter[u].flags & H5Z_FLAG_OPTIONAL) - H5E_clear_stack (NULL); + H5E_clear_stack(NULL); else HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located") } /* end if */ @@ -753,8 +745,8 @@ H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, case H5Z_PRELUDE_CAN_APPLY: /* Check if filter is configured to be able to encode */ if (!fclass->encoder_present) - HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); - + HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, + "Filter present but encoding is disabled."); /* Check if there is a "can apply" callback */ if (fclass->can_apply) { @@ -785,15 +777,14 @@ H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, default: HDassert("invalid prelude type" && 0); } /* end switch */ - } /* end else */ - } /* end for */ + } /* end else */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__prelude_callback() */ - /*------------------------------------------------------------------------- * Function: H5Z__prepare_prelude_callback_dcpl * @@ -810,9 +801,9 @@ H5Z__prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, static herr_t H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type) { - hid_t space_id = -1; /* ID for dataspace describing chunk */ - H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t space_id = -1; /* ID for dataspace describing chunk */ + H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -821,7 +812,7 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ /* Check if the property list is non-default */ if (dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5P_genplist_t *dc_plist; /* Dataset creation property list object */ + H5P_genplist_t *dc_plist; /* Dataset creation property list object */ /* Get memory for the layout */ if (NULL == (dcpl_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) @@ -837,7 +828,7 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ /* Check if the dataset is chunked */ if (H5D_CHUNKED == dcpl_layout->type) { - H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ + H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ /* Get I/O pipeline information */ if (H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) @@ -845,14 +836,14 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ /* Check if the chunks have filters */ if (dcpl_pline.nused > 0) { - hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ - H5S_t *space; /* Dataspace describing chunk */ - size_t u; /* Local index variable */ + hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ + H5S_t * space; /* Dataspace describing chunk */ + size_t u; /* Local index variable */ /* Create a dataspace for a chunk & set the extent */ - for(u = 0; u < dcpl_layout->u.chunk.ndims; u++) + for (u = 0; u < dcpl_layout->u.chunk.ndims; u++) chunk_dims[u] = dcpl_layout->u.chunk.dim[u]; - if(NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL))) + if (NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Get ID for dataspace to pass to filter routines */ @@ -878,7 +869,6 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__prepare_prelude_callback_dcpl() */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply * @@ -897,7 +887,7 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -909,7 +899,6 @@ H5Z_can_apply(hid_t dcpl_id, hid_t type_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local * @@ -928,7 +917,7 @@ H5Z_can_apply(hid_t dcpl_id, hid_t type_id) herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -940,7 +929,6 @@ H5Z_set_local(hid_t dcpl_id, hid_t type_id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local() */ - /*------------------------------------------------------------------------- * Function: H5Z_can_apply_direct * @@ -955,7 +943,7 @@ H5Z_set_local(hid_t dcpl_id, hid_t type_id) herr_t H5Z_can_apply_direct(const H5O_pline_t *pline) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -969,7 +957,6 @@ H5Z_can_apply_direct(const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply_direct() */ - /*------------------------------------------------------------------------- * Function: H5Z_set_local_direct * @@ -988,7 +975,7 @@ H5Z_can_apply_direct(const H5O_pline_t *pline) herr_t H5Z_set_local_direct(const H5O_pline_t *pline) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1002,7 +989,6 @@ H5Z_set_local_direct(const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local_direct() */ - /*------------------------------------------------------------------------- * Function: H5Z_ignore_filters * @@ -1024,12 +1010,12 @@ H5Z_set_local_direct(const H5O_pline_t *pline) htri_t H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space) { - H5P_genplist_t *dc_plist; /* Dataset creation property list object */ - H5O_pline_t pline; /* Object's I/O pipeline information */ - H5S_class_t space_class; /* To check class of space */ - H5T_class_t type_class; /* To check if type is VL */ - bool bad_for_filters = FALSE;/* Suitable to have filters */ - htri_t ret_value = FALSE; /* TRUE for ignoring filters */ + H5P_genplist_t *dc_plist; /* Dataset creation property list object */ + H5O_pline_t pline; /* Object's I/O pipeline information */ + H5S_class_t space_class; /* To check class of space */ + H5T_class_t type_class; /* To check if type is VL */ + bool bad_for_filters = FALSE; /* Suitable to have filters */ + htri_t ret_value = FALSE; /* TRUE for ignoring filters */ FUNC_ENTER_NOAPI(FAIL) @@ -1042,20 +1028,18 @@ H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space) /* Get datatype and dataspace classes for quick access */ space_class = H5S_GET_EXTENT_TYPE(space); - type_class = H5T_get_class(type, FALSE); + type_class = H5T_get_class(type, FALSE); /* These conditions are not suitable for filters */ - bad_for_filters = (H5S_NULL == space_class || H5S_SCALAR == space_class - || H5T_VLEN == type_class - || (H5T_STRING == type_class && TRUE == H5T_is_variable_str(type))); + bad_for_filters = (H5S_NULL == space_class || H5S_SCALAR == space_class || H5T_VLEN == type_class || + (H5T_STRING == type_class && TRUE == H5T_is_variable_str(type))); /* When these conditions occur, if there are required filters in pline, then report a failure, otherwise, set flag that they can be ignored */ if (bad_for_filters) { size_t ii; if (pline.nused > 0) { - for (ii = 0; ii < pline.nused; ii++) - { + for (ii = 0; ii < pline.nused; ii++) { if (!(pline.filter[ii].flags & H5Z_FLAG_OPTIONAL)) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "not suitable for filters") } @@ -1069,7 +1053,6 @@ H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_ignore_filters() */ - /*------------------------------------------------------------------------- * Function: H5Z_modify * @@ -1080,11 +1063,11 @@ H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space) *------------------------------------------------------------------------- */ herr_t -H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; /* Index of filter in pipeline */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1103,7 +1086,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Change parameters for filter */ - pline->filter[idx].flags = flags; + pline->filter[idx].flags = flags; pline->filter[idx].cd_nelmts = cd_nelmts; /* Free any existing parameters */ @@ -1112,7 +1095,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Set parameters */ if (cd_nelmts > 0) { - size_t i; /* Local index variable */ + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ if (cd_nelmts > H5Z_COMMON_CD_VALUES) { @@ -1128,13 +1111,12 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else - pline->filter[idx].cd_values = NULL; + pline->filter[idx].cd_values = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_modify() */ - /*------------------------------------------------------------------------- * Function: H5Z_append * @@ -1145,11 +1127,11 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, *------------------------------------------------------------------------- */ herr_t -H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, - size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) +H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1163,7 +1145,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * decide to relax this restriction in the future. */ if (pline->nused >= H5Z_MAX_NFILTERS) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") /* Check for freshly allocated filter pipeline */ if (pline->version == 0) @@ -1172,7 +1154,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, /* Allocate additional space in the pipeline if it's full */ if (pline->nused >= pline->nalloc) { H5O_pline_t x; - size_t n; + size_t n; /* Each filter's data may be stored internally or may be * a separate block of memory. @@ -1183,7 +1165,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, */ for (n = 0; n < pline->nalloc; ++n) if (pline->filter[n].cd_values == pline->filter[n]._cd_values) - pline->filter[n].cd_values = (unsigned *)((void *) ~((size_t)NULL)); + pline->filter[n].cd_values = (unsigned *)((void *)~((size_t)NULL)); x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc); x.filter = (H5Z_filter_info_t *)H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0])); @@ -1194,7 +1176,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * internal data. */ for (n = 0; n < pline->nalloc; ++n) - if (x.filter[n].cd_values == (void *) ~((size_t) NULL)) + if (x.filter[n].cd_values == (void *)~((size_t)NULL)) x.filter[n].cd_values = x.filter[n]._cd_values; /* Point to newly allocated buffer */ @@ -1203,13 +1185,13 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, } /* end if */ /* Add the new filter to the pipeline */ - idx = pline->nused; - pline->filter[idx].id = filter; - pline->filter[idx].flags = flags; - pline->filter[idx].name = NULL; /*we'll pick it up later*/ + idx = pline->nused; + pline->filter[idx].id = filter; + pline->filter[idx].flags = flags; + pline->filter[idx].name = NULL; /*we'll pick it up later*/ pline->filter[idx].cd_nelmts = cd_nelmts; if (cd_nelmts > 0) { - size_t i; /* Local index variable */ + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ if (cd_nelmts > H5Z_COMMON_CD_VALUES) { @@ -1225,7 +1207,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else - pline->filter[idx].cd_values = NULL; + pline->filter[idx].cd_values = NULL; pline->nused++; @@ -1233,7 +1215,6 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_append() */ - /*------------------------------------------------------------------------- * Function: H5Z__find_idx * @@ -1247,20 +1228,19 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, static int H5Z__find_idx(H5Z_filter_t id) { - size_t i; /* Local index variable */ - int ret_value = FAIL; /* Return value */ + size_t i; /* Local index variable */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_STATIC_NOERR - for(i = 0; i < H5Z_table_used_g; i++) - if(H5Z_table_g[i].id == id) + for (i = 0; i < H5Z_table_used_g; i++) + if (H5Z_table_g[i].id == id) HGOTO_DONE((int)i) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__find_idx() */ - /*------------------------------------------------------------------------- * Function: H5Z_find * @@ -1274,8 +1254,8 @@ H5Z__find_idx(H5Z_filter_t id) H5Z_class2_t * H5Z_find(H5Z_filter_t id) { - int idx; /* Filter index in global table */ - H5Z_class2_t *ret_value = NULL; /* Return value */ + int idx; /* Filter index in global table */ + H5Z_class2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1290,7 +1270,6 @@ H5Z_find(H5Z_filter_t id) FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_find() */ - /*------------------------------------------------------------------------- * Function: H5Z_pipeline * @@ -1315,42 +1294,42 @@ H5Z_find(H5Z_filter_t id) *------------------------------------------------------------------------- */ herr_t -H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, - unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, - size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/) +H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*in,out*/, H5Z_EDC_t edc_read, + H5Z_cb_t cb_struct, size_t *nbytes /*in,out*/, size_t *buf_size /*in,out*/, + void **buf /*in,out*/) { - size_t idx; - size_t new_nbytes; - int fclass_idx; /* Index of filter class in global table */ - H5Z_class2_t *fclass = NULL; /* Filter class pointer */ + size_t idx; + size_t new_nbytes; + int fclass_idx; /* Index of filter class in global table */ + H5Z_class2_t *fclass = NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG - H5Z_stats_t *fstats = NULL; /* Filter stats pointer */ - H5_timer_t timer; /* Timer for filter operations */ - H5_timevals_t times; /* Elapsed time for each operation */ + H5Z_stats_t * fstats = NULL; /* Filter stats pointer */ + H5_timer_t timer; /* Timer for filter operations */ + H5_timevals_t times; /* Elapsed time for each operation */ #endif - unsigned failed = 0; - unsigned tmp_flags; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned failed = 0; + unsigned tmp_flags; + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK))); HDassert(filter_mask); - HDassert(nbytes && *nbytes>0); - HDassert(buf_size && *buf_size>0); + HDassert(nbytes && *nbytes > 0); + HDassert(buf_size && *buf_size > 0); HDassert(buf && *buf); HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS); #ifdef H5Z_DEBUG H5_timer_init(&timer); #endif - if(pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ - for(i = pline->nused; i > 0; --i) { + if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ + for (i = pline->nused; i > 0; --i) { idx = i - 1; - if(*filter_mask & ((unsigned)1 << idx)) { + if (*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue; /* filter excluded */ + continue; /* filter excluded */ } /* If the filter isn't registered and the application doesn't @@ -1358,19 +1337,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, * try to load it dynamically and register it. Otherwise, return failure */ if ((fclass_idx = H5Z__find_idx(pline->filter[idx].id)) < 0) { - H5PL_key_t key; - const H5Z_class2_t *filter_info; - hbool_t issue_error = FALSE; + H5PL_key_t key; + const H5Z_class2_t *filter_info; + hbool_t issue_error = FALSE; /* Try loading the filter */ key.id = (int)(pline->filter[idx].id); - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) { + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { /* Register the filter we loaded */ - if(H5Z_register(filter_info) < 0) + if (H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") - /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if((fclass_idx = H5Z__find_idx(pline->filter[idx].id)) < 0) + /* Search in the table of registered filters again to find the dynamic filter just loaded + * and registered */ + if ((fclass_idx = H5Z__find_idx(pline->filter[idx].id)) < 0) issue_error = TRUE; } else @@ -1381,9 +1361,11 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, /* Print out the filter name to give more info. But the name is optional for * the filter */ if (pline->filter[idx].name) - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name) + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", + pline->filter[idx].name) else - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered") + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, + "required filter (name unavailable) is not registered") } } /* end if */ @@ -1396,26 +1378,25 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, tmp_flags = flags | (pline->filter[idx].flags); tmp_flags |= (edc_read == H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; - new_nbytes = (fclass->filter)(tmp_flags, - pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, - *nbytes, buf_size, buf); + new_nbytes = (fclass->filter)(tmp_flags, pline->filter[idx].cd_nelmts, + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_stop(&timer); H5_timer_get_times(timer, ×); fstats->stats[1].times.elapsed += times.elapsed; - fstats->stats[1].times.system += times.system; - fstats->stats[1].times.user += times.user; + fstats->stats[1].times.system += times.system; + fstats->stats[1].times.user += times.user; fstats->stats[1].total += MAX(*nbytes, new_nbytes); - if(0 == new_nbytes) + if (0 == new_nbytes) fstats->stats[1].errors += *nbytes; #endif - if(0 == new_nbytes) { - if((cb_struct.func - && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) - || !cb_struct.func) + if (0 == new_nbytes) { + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, + cb_struct.op_data))) || + !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; @@ -1426,20 +1407,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, *nbytes = new_nbytes; } } - else if(pline) { /* Write */ - for(idx = 0; idx < pline->nused; idx++) { - if(*filter_mask & ((unsigned)1 << idx)) { + else if (pline) { /* Write */ + for (idx = 0; idx < pline->nused; idx++) { + if (*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue; /* filter excluded */ + continue; /* filter excluded */ } - if((fclass_idx = H5Z__find_idx(pline->filter[idx].id)) < 0) { + if ((fclass_idx = H5Z__find_idx(pline->filter[idx].id)) < 0) { /* Check if filter is optional -- If it isn't, then error */ - if((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) + if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") failed |= (unsigned)1 << idx; H5E_clear_stack(NULL); - continue; /* filter excluded */ - } /* end if */ + continue; /* filter excluded */ + } /* end if */ fclass = &H5Z_table_g[fclass_idx]; @@ -1448,26 +1429,26 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, H5_timer_start(&timer); #endif - new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), - pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, - *nbytes, buf_size, buf); + new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), pline->filter[idx].cd_nelmts, + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG H5_timer_stop(&timer); H5_timer_get_times(timer, ×); fstats->stats[0].times.elapsed += times.elapsed; - fstats->stats[0].times.system += times.system; - fstats->stats[0].times.user += times.user; + fstats->stats[0].times.system += times.system; + fstats->stats[0].times.user += times.user; fstats->stats[0].total += MAX(*nbytes, new_nbytes); - if(0 == new_nbytes) + if (0 == new_nbytes) fstats->stats[0].errors += *nbytes; #endif - if(0 == new_nbytes) { - if(0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { - if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) - || !cb_struct.func) + if (0 == new_nbytes) { + if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, + *nbytes, cb_struct.op_data))) || + !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; @@ -1486,7 +1467,6 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_filter_info * @@ -1499,8 +1479,8 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, H5Z_filter_info_t * H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - H5Z_filter_info_t *ret_value = NULL; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + H5Z_filter_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1523,7 +1503,6 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_info() */ - /*------------------------------------------------------------------------- * Function: H5Z_filter_in_pline * @@ -1538,8 +1517,8 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) htri_t H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - htri_t ret_value = TRUE; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1559,8 +1538,6 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_in_pline() */ - - /*------------------------------------------------------------------------- * Function: H5Z_all_filters_avail * @@ -1574,8 +1551,8 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) htri_t H5Z_all_filters_avail(const H5O_pline_t *pline) { - size_t i, j; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + size_t i, j; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1598,7 +1575,6 @@ H5Z_all_filters_avail(const H5O_pline_t *pline) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_all_filters_avail() */ - /*------------------------------------------------------------------------- * Function: H5Z_delete * @@ -1631,8 +1607,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) } /* Delete filter */ else { - size_t idx; /* Index of filter in pipeline */ - hbool_t found = FALSE; /* Indicate filter was found in pipeline */ + size_t idx; /* Index of filter in pipeline */ + hbool_t found = FALSE; /* Indicate filter was found in pipeline */ /* Locate the filter in the pipeline */ for (idx = 0; idx < pline->nused; idx++) @@ -1678,7 +1654,6 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_delete() */ - /*------------------------------------------------------------------------- * Function: H5Zget_filter_info * @@ -1705,7 +1680,6 @@ H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) FUNC_LEAVE_API(ret_value) } /* end H5Zget_filter_info() */ - /*------------------------------------------------------------------------- * Function: H5Z_get_filter_info * @@ -1741,4 +1715,3 @@ H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_get_filter_info() */ - diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index d46108fffe5..d29d8e565eb 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,42 +16,40 @@ * Friday, August 27, 1999 */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_DEFLATE #if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) -# define H5_ZLIB_HEADER "zlib.h" +#define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) -# include H5_ZLIB_HEADER /* "zlib.h" */ +#include H5_ZLIB_HEADER /* "zlib.h" */ #endif /* Local function prototypes */ -static size_t H5Z__filter_deflate (unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z__filter_deflate(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DEFLATE[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DEFLATE, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "deflate", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - H5Z__filter_deflate, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DEFLATE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "deflate", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z__filter_deflate, /* The actual filter function */ }}; -#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12) +#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12) - /*------------------------------------------------------------------------- * Function: H5Z__filter_deflate * @@ -67,13 +65,12 @@ const H5Z_class2_t H5Z_DEFLATE[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5Z__filter_deflate(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, - size_t *buf_size, void **buf) +H5Z__filter_deflate(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - void *outbuf = NULL; /* Pointer to new buffer */ - int status; /* Status from zlib operation */ - size_t ret_value = 0; /* Return value */ + void * outbuf = NULL; /* Pointer to new buffer */ + int status; /* Status from zlib operation */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC @@ -83,122 +80,122 @@ H5Z__filter_deflate(unsigned flags, size_t cd_nelmts, HDassert(*buf); /* Check arguments */ - if (cd_nelmts!=1 || cd_values[0]>9) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") + if (cd_nelmts != 1 || cd_values[0] > 9) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid deflate aggression level") if (flags & H5Z_FLAG_REVERSE) { - /* Input; uncompress */ - z_stream z_strm; /* zlib parameters */ - size_t nalloc = *buf_size; /* Number of bytes for output (compressed) buffer */ + /* Input; uncompress */ + z_stream z_strm; /* zlib parameters */ + size_t nalloc = *buf_size; /* Number of bytes for output (compressed) buffer */ /* Allocate space for the compressed buffer */ - if (NULL==(outbuf = H5MM_malloc(nalloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") + if (NULL == (outbuf = H5MM_malloc(nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") /* Set the uncompression parameters */ - HDmemset(&z_strm, 0, sizeof(z_strm)); - z_strm.next_in = (Bytef *)*buf; + HDmemset(&z_strm, 0, sizeof(z_strm)); + z_strm.next_in = (Bytef *)*buf; H5_CHECKED_ASSIGN(z_strm.avail_in, unsigned, nbytes, size_t); - z_strm.next_out = (Bytef *)outbuf; + z_strm.next_out = (Bytef *)outbuf; H5_CHECKED_ASSIGN(z_strm.avail_out, unsigned, nalloc, size_t); /* Initialize the uncompression routines */ - if (Z_OK!=inflateInit(&z_strm)) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed") + if (Z_OK != inflateInit(&z_strm)) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflateInit() failed") /* Loop to uncompress the buffer */ - do { + do { /* Uncompress some data */ - status = inflate(&z_strm, Z_SYNC_FLUSH); + status = inflate(&z_strm, Z_SYNC_FLUSH); /* Check if we are done uncompressing data */ - if (Z_STREAM_END==status) - break; /*done*/ + if (Z_STREAM_END == status) + break; /*done*/ /* Check for error */ - if (Z_OK!=status) { - (void)inflateEnd(&z_strm); - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed") - } + if (Z_OK != status) { + (void)inflateEnd(&z_strm); + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "inflate() failed") + } else { /* If we're not done and just ran out of buffer space, get more */ - if(0 == z_strm.avail_out) { - void *new_outbuf; /* Pointer to new output buffer */ + if (0 == z_strm.avail_out) { + void *new_outbuf; /* Pointer to new output buffer */ /* Allocate a buffer twice as big */ nalloc *= 2; - if(NULL == (new_outbuf = H5MM_realloc(outbuf, nalloc))) { + if (NULL == (new_outbuf = H5MM_realloc(outbuf, nalloc))) { (void)inflateEnd(&z_strm); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, + "memory allocation failed for deflate uncompression") } /* end if */ outbuf = new_outbuf; /* Update pointers to buffer for next set of uncompressed data */ - z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out; + z_strm.next_out = (unsigned char *)outbuf + z_strm.total_out; z_strm.avail_out = (uInt)(nalloc - z_strm.total_out); } /* end if */ - } /* end else */ - } while(status==Z_OK); + } /* end else */ + } while (status == Z_OK); /* Free the input buffer */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nalloc; - ret_value = z_strm.total_out; + *buf = outbuf; + outbuf = NULL; + *buf_size = nalloc; + ret_value = z_strm.total_out; /* Finish uncompressing the stream */ - (void)inflateEnd(&z_strm); + (void)inflateEnd(&z_strm); } /* end if */ else { - /* - * Output; compress but fail if the result would be larger than the - * input. The library doesn't provide in-place compression, so we - * must allocate a separate buffer for the result. - */ - const Bytef *z_src = (const Bytef*)(*buf); - Bytef *z_dst; /*destination buffer */ - uLongf z_dst_nbytes = (uLongf)H5Z_DEFLATE_SIZE_ADJUST(nbytes); - uLong z_src_nbytes = (uLong)nbytes; - int aggression; /* Compression aggression setting */ + /* + * Output; compress but fail if the result would be larger than the + * input. The library doesn't provide in-place compression, so we + * must allocate a separate buffer for the result. + */ + const Bytef *z_src = (const Bytef *)(*buf); + Bytef * z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)H5Z_DEFLATE_SIZE_ADJUST(nbytes); + uLong z_src_nbytes = (uLong)nbytes; + int aggression; /* Compression aggression setting */ /* Set the compression aggression level */ H5_CHECKED_ASSIGN(aggression, int, cd_values[0], unsigned); /* Allocate output (compressed) buffer */ - if(NULL == (outbuf = H5MM_malloc(z_dst_nbytes))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") + if (NULL == (outbuf = H5MM_malloc(z_dst_nbytes))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") z_dst = (Bytef *)outbuf; /* Perform compression from the source to the destination buffer */ - status = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); + status = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); /* Check for various zlib errors */ - if(Z_BUF_ERROR == status) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") - else if(Z_MEM_ERROR == status) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error") - else if(Z_OK != status) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "other deflate error") + if (Z_BUF_ERROR == status) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") + else if (Z_MEM_ERROR == status) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error") + else if (Z_OK != status) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "other deflate error") /* Successfully uncompressed the buffer */ else { /* Free the input buffer */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nbytes; - ret_value = z_dst_nbytes; - } /* end else */ - } /* end else */ + *buf = outbuf; + outbuf = NULL; + *buf_size = nbytes; + ret_value = z_dst_nbytes; + } /* end else */ + } /* end else */ done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_DEFLATE */ - diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 07e2f79afd5..4b0801c88f5 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,34 +16,32 @@ * Jan 3, 2003 */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Zpkg.h" /* Data filters */ /* Local function prototypes */ -static size_t H5Z__filter_fletcher32(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z__filter_fletcher32(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_FLETCHER32[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_FLETCHER32, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "fletcher32", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - H5Z__filter_fletcher32, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_FLETCHER32, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "fletcher32", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + H5Z__filter_fletcher32, /* The actual filter function */ }}; -#define FLETCHER_LEN 4 +#define FLETCHER_LEN 4 - /*------------------------------------------------------------------------- * Function: H5Z__filter_fletcher32 * @@ -58,32 +56,32 @@ const H5Z_class2_t H5Z_FLETCHER32[1] = {{ *------------------------------------------------------------------------- */ static size_t -H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned H5_ATTR_UNUSED cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, + const unsigned H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t *buf_size, void **buf) { - void *outbuf = NULL; /* Pointer to new buffer */ - unsigned char *src = (unsigned char*)(*buf); - uint32_t fletcher; /* Checksum value */ - uint32_t reversed_fletcher; /* Possible wrong checksum value */ - uint8_t c[4]; - uint8_t tmp; - size_t ret_value = 0; /* Return value */ + void * outbuf = NULL; /* Pointer to new buffer */ + unsigned char *src = (unsigned char *)(*buf); + uint32_t fletcher; /* Checksum value */ + uint32_t reversed_fletcher; /* Possible wrong checksum value */ + uint8_t c[4]; + uint8_t tmp; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC - HDassert(sizeof(uint32_t)>=4); + HDassert(sizeof(uint32_t) >= 4); if (flags & H5Z_FLAG_REVERSE) { /* Read */ /* Do checksum if it's enabled for read; otherwise skip it * to save performance. */ if (!(flags & H5Z_FLAG_SKIP_EDC)) { unsigned char *tmp_src; /* Pointer to checksum in buffer */ - size_t src_nbytes = nbytes; /* Original number of bytes */ - uint32_t stored_fletcher; /* Stored checksum value */ + size_t src_nbytes = nbytes; /* Original number of bytes */ + uint32_t stored_fletcher; /* Stored checksum value */ /* Get the stored checksum */ src_nbytes -= FLETCHER_LEN; - tmp_src=src+src_nbytes; + tmp_src = src + src_nbytes; UINT32DECODE(tmp_src, stored_fletcher); /* Compute checksum (can't fail) */ @@ -110,44 +108,45 @@ H5Z__filter_fletcher32(unsigned flags, size_t H5_ATTR_UNUSED cd_nelmts, const un H5MM_memcpy(&reversed_fletcher, c, (size_t)4); /* Verify computed checksum matches stored checksum */ - if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher) - HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum") + if (stored_fletcher != fletcher && stored_fletcher != reversed_fletcher) + HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum") } /* Set return values */ /* (Re-use the input buffer, just note that the size is smaller by the size of the checksum) */ - ret_value = nbytes-FLETCHER_LEN; - } else { /* Write */ - unsigned char *dst; /* Temporary pointer to destination buffer */ + ret_value = nbytes - FLETCHER_LEN; + } + else { /* Write */ + unsigned char *dst; /* Temporary pointer to destination buffer */ /* Compute checksum (can't fail) */ fletcher = H5_checksum_fletcher32(src, nbytes); - if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate Fletcher32 checksum destination buffer") + if (NULL == (outbuf = H5MM_malloc(nbytes + FLETCHER_LEN))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, + "unable to allocate Fletcher32 checksum destination buffer") - dst = (unsigned char *) outbuf; + dst = (unsigned char *)outbuf; /* Copy raw data */ - H5MM_memcpy((void*)dst, (void*)(*buf), nbytes); + H5MM_memcpy((void *)dst, (void *)(*buf), nbytes); /* Append checksum to raw data for storage */ dst += nbytes; UINT32ENCODE(dst, fletcher); /* Free input buffer */ - H5MM_xfree(*buf); + H5MM_xfree(*buf); /* Set return values */ *buf_size = nbytes + FLETCHER_LEN; - *buf = outbuf; - outbuf = NULL; - ret_value = *buf_size; + *buf = outbuf; + outbuf = NULL; + ret_value = *buf_size; } done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Zmodule.h b/src/H5Zmodule.h index e4fd90c90e4..76a23809294 100644 --- a/src/H5Zmodule.h +++ b/src/H5Zmodule.h @@ -5,7 +5,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,16 +18,80 @@ * H5Z package. Including this header means that the source file * is part of the H5Z package. */ -#ifndef _H5Zmodule_H -#define _H5Zmodule_H +#ifndef H5Zmodule_H +#define H5Zmodule_H /* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error * reporting macros. */ #define H5Z_MODULE -#define H5_MY_PKG H5Z -#define H5_MY_PKG_ERR H5E_PLINE -#define H5_MY_PKG_INIT YES +#define H5_MY_PKG H5Z +#define H5_MY_PKG_ERR H5E_PLINE +#define H5_MY_PKG_INIT YES -#endif /* _H5Zmodule_H */ +/** + * \defgroup H5Z H5Z + * + * + * \brief Filter and Compression Interface + * + * \details The functions in this module let you configure filters that process + * data during I/O operation. + * + * HDF5 supports a filter pipeline that provides the capability for + * standard and customized raw data processing during I/O operations. + * HDF5 is distributed with a small set of standard filters such as + * compression (gzip, SZIP, and a shuffling algorithm) and error + * checking (Fletcher32 checksum). For further flexibility, the + * library allows a user application to extend the pipeline through + * the creation and registration of customized filters. + * + * The flexibility of the filter pipeline implementation enables the + * definition of additional filters by a user application. A filter + * \li is associated with a dataset when the dataset is created, + * \li can be used only with chunked data (i.e., datasets stored in + * the #H5D_CHUNKED storage layout), and + * \li is applied independently to each chunk of the dataset. + * + * The HDF5 library does not support filters for contiguous datasets + * because of the difficulty of implementing random access for partial + * I/O. Compact dataset filters are not supported because it would not + * produce significant results. + * + * Filter identifiers for the filters distributed with the HDF5 + * Library are as follows: + * + * + * + * + * + * + * + *
#H5Z_FILTER_DEFLATEThe gzip compression, or + * deflation, filter
#H5Z_FILTER_SZIPThe SZIP compression + * filter
#H5Z_FILTER_NBITThe N-bit compression + * filter
#H5Z_FILTER_SCALEOFFSETThe scale-offset + * compression filter
#H5Z_FILTER_SHUFFLEThe shuffle algorithm + * filter
#H5Z_FILTER_FLETCHER32The Fletcher32 checksum, + * or error checking, filter
+ * Custom filters that have been registered with the library will have + * additional unique identifiers. + * + * See \ref_dld_filters for more information on how an HDF5 + * application can apply a filter that is not registered with the HDF5 + * library. + * + * \defgroup H5ZPRE Predefined Filters + * \ingroup H5Z + * \defgroup FLETCHER32 Checksum Filter + * \ingroup H5ZPRE + * \defgroup SCALEOFFSET Scale-Offset Filter + * \ingroup H5ZPRE + * \defgroup SHUFFLE Shuffle Filter + * \ingroup H5ZPRE + * \defgroup SZIP Szip Filter + * \ingroup H5ZPRE + * + */ +#endif /* H5Zmodule_H */ diff --git a/src/H5Znbit.c b/src/H5Znbit.c index d29343b1a76..795fdce307f 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -6,106 +6,107 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property lists */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Struct of parameters needed for compressing/decompressing * one nbit atomic datatype: integer or floating-point */ typedef struct { - unsigned size; /* size of datatype */ - unsigned order; /* datatype endianness order */ - unsigned precision; /* datatype precision */ - unsigned offset; /* datatype offset */ + unsigned size; /* size of datatype */ + unsigned order; /* datatype endianness order */ + unsigned precision; /* datatype precision */ + unsigned offset; /* datatype offset */ } parms_atomic; /* Local function prototypes */ static htri_t H5Z__can_apply_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); -static void H5Z__calc_parms_nooptype(size_t *cd_values_actual_nparms); -static void H5Z__calc_parms_atomic(size_t *cd_values_actual_nparms); +static void H5Z__calc_parms_nooptype(size_t *cd_values_actual_nparms); +static void H5Z__calc_parms_atomic(size_t *cd_values_actual_nparms); static herr_t H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms); static herr_t H5Z__calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms); -static herr_t H5Z__set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[]); -static herr_t H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); -static herr_t H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); -static herr_t H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress); - -static void H5Z__nbit_next_byte(size_t *j, size_t *buf_len); -static void H5Z__nbit_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, - size_t *buf_len, const parms_atomic *p, size_t datatype_len); -static void H5Z__nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, - unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p, size_t datatype_len); -static void H5Z__nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); -static void H5Z__nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p); -static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); +static herr_t H5Z__set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[]); +static herr_t H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); +static herr_t H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); +static herr_t H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress); + +static void H5Z__nbit_next_byte(size_t *j, size_t *buf_len); +static void H5Z__nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned end_i, const unsigned char *buffer, + size_t *j, size_t *buf_len, const parms_atomic *p, + size_t datatype_len); +static void H5Z__nbit_compress_one_byte(const unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p, size_t datatype_len); +static void H5Z__nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, + const unsigned char *buffer, size_t *j, size_t *buf_len, + unsigned size); +static void H5Z__nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const parms_atomic *p); +static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); static herr_t H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); + unsigned char *buffer, size_t *j, size_t *buf_len, + const unsigned parms[], unsigned *parms_index); static herr_t H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - const unsigned parms[]); -static void H5Z__nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); -static void H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); -static void H5Z__nbit_compress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index); -static void H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t *buffer_size, const unsigned parms[]); + const unsigned parms[]); +static void H5Z__nbit_compress_one_nooptype(const unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); +static void H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); +static void H5Z__nbit_compress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, const unsigned parms[], + unsigned *parms_index); +static void H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + size_t *buffer_size, const unsigned parms[]); /* This message derives from H5Z */ H5Z_class2_t H5Z_NBIT[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_NBIT, /* Filter id number */ - 1, /* Assume encoder present: check before registering */ - 1, /* decoder_present flag (set to true) */ - "nbit", /* Filter name for debugging */ - H5Z__can_apply_nbit, /* The "can apply" callback */ - H5Z__set_local_nbit, /* The "set local" callback */ - H5Z__filter_nbit, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_NBIT, /* Filter id number */ + 1, /* Assume encoder present: check before registering */ + 1, /* decoder_present flag (set to true) */ + "nbit", /* Filter name for debugging */ + H5Z__can_apply_nbit, /* The "can apply" callback */ + H5Z__set_local_nbit, /* The "set local" callback */ + H5Z__filter_nbit, /* The actual filter function */ }}; /* Local macros */ -#define H5Z_NBIT_ATOMIC 1 /* Atomic datatype class: integer/floating-point */ -#define H5Z_NBIT_ARRAY 2 /* Array datatype class */ -#define H5Z_NBIT_COMPOUND 3 /* Compound datatype class */ -#define H5Z_NBIT_NOOPTYPE 4 /* Other datatype class: nbit does no compression */ -#define H5Z_NBIT_MAX_NPARMS 4096 /* Max number of parameters for filter */ -#define H5Z_NBIT_ORDER_LE 0 /* Little endian for datatype byte order */ -#define H5Z_NBIT_ORDER_BE 1 /* Big endian for datatype byte order */ +#define H5Z_NBIT_ATOMIC 1 /* Atomic datatype class: integer/floating-point */ +#define H5Z_NBIT_ARRAY 2 /* Array datatype class */ +#define H5Z_NBIT_COMPOUND 3 /* Compound datatype class */ +#define H5Z_NBIT_NOOPTYPE 4 /* Other datatype class: nbit does no compression */ +#define H5Z_NBIT_MAX_NPARMS 4096 /* Max number of parameters for filter */ +#define H5Z_NBIT_ORDER_LE 0 /* Little endian for datatype byte order */ +#define H5Z_NBIT_ORDER_BE 1 /* Big endian for datatype byte order */ /* Local variables */ - /*------------------------------------------------------------------------- * Function: H5Z__can_apply_nbit * @@ -123,28 +124,27 @@ H5Z_class2_t H5Z_NBIT[1] = {{ static htri_t H5Z__can_apply_nbit(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ - if(H5T_get_class(type, TRUE) == H5T_NO_CLASS) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") + if (H5T_get_class(type, TRUE) == H5T_NO_CLASS) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if(H5T_get_size(type) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if (H5T_get_size(type) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__can_apply_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Z__calc_parms_nooptype * @@ -167,7 +167,6 @@ H5Z__calc_parms_nooptype(size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; } - /*------------------------------------------------------------------------- * Function: H5Z__calc_parms_atomic * @@ -199,7 +198,6 @@ H5Z__calc_parms_atomic(size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; } - /*------------------------------------------------------------------------- * Function: H5Z__calc_parms_array * @@ -218,9 +216,9 @@ H5Z__calc_parms_atomic(size_t *cd_values_actual_nparms) static herr_t H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) { - H5T_t *dtype_base = NULL; /* Array datatype's base datatype */ - H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t * dtype_base = NULL; /* Array datatype's base datatype */ + H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -231,27 +229,27 @@ H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; /* Get array datatype's base datatype */ - if(NULL == (dtype_base = H5T_get_super(type))) + if (NULL == (dtype_base = H5T_get_super(type))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype") /* Get base datatype's class */ - if((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) + if ((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype class") /* Calculate number of the rest parameters according to base datatype's class */ - switch(dtype_base_class) { + switch (dtype_base_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z__calc_parms_atomic(cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z__calc_parms_array(dtype_base, cd_values_actual_nparms) == FAIL) + if (H5Z__calc_parms_array(dtype_base, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__calc_parms_compound(dtype_base, cd_values_actual_nparms) == FAIL) + if (H5Z__calc_parms_compound(dtype_base, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -275,14 +273,13 @@ H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) } /* end switch */ done: - if(dtype_base) - if(H5T_close_real(dtype_base) < 0) + if (dtype_base) + if (H5T_close_real(dtype_base) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__calc_parms_array() */ - /*------------------------------------------------------------------------- * Function: H5Z__calc_parms_compound * @@ -301,10 +298,10 @@ H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) static herr_t H5Z__calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) { - int nmembers; /* Compound datatype's number of members */ - H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int nmembers; /* Compound datatype's number of members */ + H5T_t * dtype_member = NULL; /* Compound datatype's member datatype */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -315,41 +312,41 @@ H5Z__calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) *cd_values_actual_nparms += 1; /* Get number of members */ - if((nmembers = H5T_get_nmembers(type)) < 0) + if ((nmembers = H5T_get_nmembers(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members") /* Store number of members */ *cd_values_actual_nparms += 1; /* For each member, calculate parameters */ - for(u = 0; u < (unsigned)nmembers; u++) { + for (u = 0; u < (unsigned)nmembers; u++) { H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ /* Get member datatype */ - if(NULL == (dtype_member = H5T_get_member_type(type, u))) + if (NULL == (dtype_member = H5T_get_member_type(type, u))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype") /* Get member datatype's class */ - if((dtype_member_class = H5T_get_class(dtype_member, TRUE)) == H5T_NO_CLASS) + if ((dtype_member_class = H5T_get_class(dtype_member, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype class") /* Store member offset */ *cd_values_actual_nparms += 1; /* Calculate parameters according to member's datatype class */ - switch(dtype_member_class) { + switch (dtype_member_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z__calc_parms_atomic(cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z__calc_parms_array(dtype_member, cd_values_actual_nparms) == FAIL) + if (H5Z__calc_parms_array(dtype_member, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__calc_parms_compound(dtype_member, cd_values_actual_nparms) == FAIL) + if (H5Z__calc_parms_compound(dtype_member, cd_values_actual_nparms) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -373,20 +370,19 @@ H5Z__calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) } /* end switch */ /* Close member datatype */ - if(H5T_close_real(dtype_member) < 0) + if (H5T_close_real(dtype_member) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") dtype_member = NULL; } /* end for */ done: - if(dtype_member) - if(H5T_close_real(dtype_member) < 0) + if (dtype_member) + if (H5T_close_real(dtype_member) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_calc_params_compound */ - /*------------------------------------------------------------------------- * Function: H5Z__set_parms_nooptype * @@ -415,8 +411,8 @@ H5Z__set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned c cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); @@ -426,7 +422,6 @@ H5Z__set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned c FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_parms_nooptype() */ - /*------------------------------------------------------------------------- * Function: H5Z__set_parms_atomic * @@ -442,15 +437,15 @@ H5Z__set_parms_nooptype(const H5T_t *type, unsigned *cd_values_index, unsigned c *------------------------------------------------------------------------- */ static herr_t -H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - H5T_order_t dtype_order; /* Atomic datatype's endianness order */ - size_t dtype_size; /* Atomic datatype's size (in bytes) */ - size_t dtype_precision; /* Atomic datatype's precision (in bits) */ - int sdtype_offset; /* Atomic datatype's offset (in bits) */ - unsigned dtype_offset; /* Atomic datatype's offset (in bits) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_order_t dtype_order; /* Atomic datatype's endianness order */ + size_t dtype_size; /* Atomic datatype's size (in bytes) */ + size_t dtype_precision; /* Atomic datatype's precision (in bits) */ + int sdtype_offset; /* Atomic datatype's offset (in bits) */ + unsigned dtype_offset; /* Atomic datatype's offset (in bits) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -458,7 +453,7 @@ H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_ATOMIC; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) + if ((dtype_size = H5T_get_size(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ @@ -466,16 +461,16 @@ H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set "local" parameter for datatype endianness */ - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_LE; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[(*cd_values_index)++] = H5Z_NBIT_ORDER_BE; break; @@ -488,16 +483,16 @@ H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ /* Get datatype's precision */ - if((dtype_precision = H5T_get_precision(type)) == 0) + if ((dtype_precision = H5T_get_precision(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision") /* Get datatype's offset */ - if((sdtype_offset = H5T_get_offset(type)) < 0) + if ((sdtype_offset = H5T_get_offset(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype offset") dtype_offset = (unsigned)sdtype_offset; /* Check values of precision and offset */ - if(dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8) + if (dtype_precision > dtype_size * 8 || (dtype_precision + dtype_offset) > dtype_size * 8) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") /* Set "local" parameter for datatype precision */ @@ -511,14 +506,13 @@ H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, * compress at this point. If current datatype is not full-precision, * flag need_not_compress should be set to FALSE. */ - if(*need_not_compress) /* so far no need to compress */ - if(dtype_offset != 0 || dtype_precision != dtype_size * 8) - *need_not_compress = FALSE; + if (*need_not_compress) /* so far no need to compress */ + if (dtype_offset != 0 || dtype_precision != dtype_size * 8) + *need_not_compress = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_parms_atomic() */ - /*------------------------------------------------------------------------- * Function: H5Z__set_parms_array * @@ -534,14 +528,14 @@ H5Z__set_parms_atomic(const H5T_t *type, unsigned *cd_values_index, *------------------------------------------------------------------------- */ static herr_t -H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - H5T_t *dtype_base = NULL; /* Array datatype's base datatype */ - H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ - size_t dtype_size; /* Array datatype's size (in bytes) */ - htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ - herr_t ret_value=SUCCEED; /* Return value */ + H5T_t * dtype_base = NULL; /* Array datatype's base datatype */ + H5T_class_t dtype_base_class; /* Array datatype's base datatype's class */ + size_t dtype_size; /* Array datatype's size (in bytes) */ + htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -549,49 +543,50 @@ H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_ARRAY; /* Get array datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for array datatype's size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get array datatype's base datatype */ - if(NULL == (dtype_base = H5T_get_super(type))) + if (NULL == (dtype_base = H5T_get_super(type))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype") /* Get base datatype's class */ - if((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) + if ((dtype_base_class = H5T_get_class(dtype_base, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad base datatype class") /* Call appropriate function according to base datatype's class */ - switch(dtype_base_class) { + switch (dtype_base_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z__set_parms_atomic(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_atomic(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z__set_parms_array(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_array(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__set_parms_compound(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_compound(dtype_base, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_VLEN: /* Check if base datatype is a variable-length string */ - if((is_vlstring = H5T_is_variable_str(dtype_base)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot determine if datatype is a variable-length string") + if ((is_vlstring = H5T_is_variable_str(dtype_base)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, + "cannot determine if datatype is a variable-length string") /* base datatype of VL or VL-string is not supported */ - if(dtype_base_class == H5T_VLEN || is_vlstring) + if (dtype_base_class == H5T_VLEN || is_vlstring) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype not supported by nbit") - if(H5Z__set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) + if (H5Z__set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -601,7 +596,7 @@ H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, case H5T_OPAQUE: case H5T_REFERENCE: case H5T_ENUM: - if(H5Z__set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) + if (H5Z__set_parms_nooptype(dtype_base, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -614,14 +609,13 @@ H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ done: - if(dtype_base) - if(H5T_close_real(dtype_base) < 0) + if (dtype_base) + if (H5T_close_real(dtype_base) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_parms_array() */ - /*------------------------------------------------------------------------- * Function: H5Z__set_parms_compound * @@ -637,19 +631,19 @@ H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, *------------------------------------------------------------------------- */ static herr_t -H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, - unsigned cd_values[], hbool_t *need_not_compress) +H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, unsigned cd_values[], + hbool_t *need_not_compress) { - int snmembers; /* Compound datatype's number of members */ - unsigned nmembers; /* Compound datatype's number of members */ - H5T_t *dtype_member = NULL; /* Compound datatype's member datatype */ - H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ - size_t dtype_member_offset; /* Compound datatype's current member datatype's offset (in bytes) */ - size_t dtype_next_member_offset;/* Compound datatype's next member datatype's offset (in bytes) */ - size_t dtype_size; /* Compound datatype's size (in bytes) */ - htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + int snmembers; /* Compound datatype's number of members */ + unsigned nmembers; /* Compound datatype's number of members */ + H5T_t * dtype_member = NULL; /* Compound datatype's member datatype */ + H5T_class_t dtype_member_class; /* Compound datatype's member datatype's class */ + size_t dtype_member_offset; /* Compound datatype's current member datatype's offset (in bytes) */ + size_t dtype_next_member_offset; /* Compound datatype's next member datatype's offset (in bytes) */ + size_t dtype_size; /* Compound datatype's size (in bytes) */ + htri_t is_vlstring; /* flag indicating if datatype is variable-length string */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -657,15 +651,15 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = H5Z_NBIT_COMPOUND; /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((dtype_size = H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for compound datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_size; /* Get number of members */ - if((snmembers = H5T_get_nmembers(type)) < 0) + if ((snmembers = H5T_get_nmembers(type)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype number of members") nmembers = (unsigned)snmembers; @@ -673,44 +667,45 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, cd_values[(*cd_values_index)++] = nmembers; /* For each member, set parameters */ - for(u = 0; u < nmembers; u++) { + for (u = 0; u < nmembers; u++) { /* Get member datatype */ - if(NULL == (dtype_member = H5T_get_member_type(type, u))) + if (NULL == (dtype_member = H5T_get_member_type(type, u))) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype") /* Get member datatype's class */ - if((dtype_member_class = H5T_get_class(dtype_member, TRUE)) < 0) + if ((dtype_member_class = H5T_get_class(dtype_member, TRUE)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad member datatype class") /* Get member offset, success if H5T_get_class() success */ - dtype_member_offset = H5T_get_member_offset(type, u); + dtype_member_offset = H5T_get_member_offset(type, u); /* Set "local" parameter for member offset */ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned); cd_values[(*cd_values_index)++] = (unsigned)dtype_member_offset; /* Call appropriate function according to member's datatype class */ - switch(dtype_member_class) { + switch (dtype_member_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z__set_parms_atomic(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_atomic(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z__set_parms_array(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_array(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__set_parms_compound(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) + if (H5Z__set_parms_compound(dtype_member, cd_values_index, cd_values, need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_VLEN: /* Check if datatype is a variable-length string */ - if((is_vlstring = H5T_is_variable_str(dtype_member)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot determine if datatype is a variable-length string") + if ((is_vlstring = H5T_is_variable_str(dtype_member)) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, + "cannot determine if datatype is a variable-length string") /* Because for some no-op datatype (VL datatype and VL string datatype), its * size can not be retrieved correctly by using function call H5T_get_size, @@ -718,11 +713,11 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, * adjacent member offset is used (if alignment is present, the result can be * larger, but it does not affect the nbit filter's correctness). */ - if(dtype_member_class == H5T_VLEN || is_vlstring) { + if (dtype_member_class == H5T_VLEN || is_vlstring) { /* Set datatype class code */ cd_values[(*cd_values_index)++] = H5Z_NBIT_NOOPTYPE; - if(u != nmembers - 1) + if (u != nmembers - 1) dtype_next_member_offset = H5T_get_member_offset(type, u + 1); else /* current member is the last member */ dtype_next_member_offset = dtype_size; @@ -730,7 +725,8 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_member_offset, size_t, unsigned); H5_CHECK_OVERFLOW(dtype_next_member_offset, size_t, unsigned); - cd_values[(*cd_values_index)++] = (unsigned)dtype_next_member_offset - (unsigned)dtype_member_offset; + cd_values[(*cd_values_index)++] = + (unsigned)dtype_next_member_offset - (unsigned)dtype_member_offset; } break; @@ -741,7 +737,7 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, case H5T_REFERENCE: case H5T_ENUM: /* other datatype that nbit does no compression */ - if(H5Z__set_parms_nooptype(dtype_member, cd_values_index, cd_values) < 0) + if (H5Z__set_parms_nooptype(dtype_member, cd_values_index, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -754,20 +750,19 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, } /* end switch */ /* Close member datatype */ - if(H5T_close_real(dtype_member) < 0) + if (H5T_close_real(dtype_member) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") dtype_member = NULL; } /* end for */ done: - if(dtype_member) - if(H5T_close_real(dtype_member) < 0) + if (dtype_member) + if (H5T_close_real(dtype_member) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_params_compound */ - /*------------------------------------------------------------------------- * Function: H5Z__set_local_nbit * @@ -784,28 +779,28 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, static herr_t H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - unsigned cd_values_index; /* Index of array cd_values */ - size_t cd_values_actual_nparms; /* Number of parameters in array cd_values[] */ - size_t cd_nelmts = H5Z_NBIT_USER_NPARMS; /* Number of filter parameters */ - unsigned *cd_values = NULL; /* Filter parameters */ - hssize_t npoints; /* Number of points in the dataspace */ - H5T_class_t dtype_class; /* Datatype's class */ - hbool_t need_not_compress; /* Flag if TRUE indicating no need to do nbit compression */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + unsigned cd_values_index; /* Index of array cd_values */ + size_t cd_values_actual_nparms; /* Number of parameters in array cd_values[] */ + size_t cd_nelmts = H5Z_NBIT_USER_NPARMS; /* Number of filter parameters */ + unsigned * cd_values = NULL; /* Filter parameters */ + hssize_t npoints; /* Number of points in the dataspace */ + H5T_class_t dtype_class; /* Datatype's class */ + hbool_t need_not_compress; /* Flag if TRUE indicating no need to do nbit compression */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Calculate how many parameters will fill the cd_values array * First three parameters reserved for: @@ -814,19 +809,19 @@ H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) * 3. number of elements in the chunk */ cd_values_actual_nparms = 3; - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: case H5T_FLOAT: H5Z__calc_parms_atomic(&cd_values_actual_nparms); break; case H5T_ARRAY: - if(H5Z__calc_parms_array(type, &cd_values_actual_nparms) < 0) + if (H5Z__calc_parms_array(type, &cd_values_actual_nparms) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__calc_parms_compound(type, &cd_values_actual_nparms) < 0) + if (H5Z__calc_parms_compound(type, &cd_values_actual_nparms) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot compute parameters for datatype") break; @@ -849,27 +844,28 @@ H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Check if the number of parameters exceed what cd_values[] can store */ - if(cd_values_actual_nparms > H5Z_NBIT_MAX_NPARMS) + if (cd_values_actual_nparms > H5Z_NBIT_MAX_NPARMS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "datatype needs too many nbit parameters") /* Allocate memory space for cd_values[] */ - if(NULL == (cd_values = (unsigned *)H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) + if (NULL == (cd_values = (unsigned *)H5MM_malloc(cd_values_actual_nparms * sizeof(unsigned)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for cd_values[]") /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_NBIT, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get nbit parameters") + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_NBIT, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get nbit parameters") /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get total number of elements in the chunk */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") HDassert(npoints); @@ -884,20 +880,20 @@ H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) need_not_compress = TRUE; /* Call appropriate function according to the datatype class */ - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: case H5T_FLOAT: - if(H5Z__set_parms_atomic(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z__set_parms_atomic(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_ARRAY: - if(H5Z__set_parms_array(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z__set_parms_array(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; case H5T_COMPOUND: - if(H5Z__set_parms_compound(type, &cd_values_index, cd_values, &need_not_compress) < 0) + if (H5Z__set_parms_compound(type, &cd_values_index, cd_values, &need_not_compress) < 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "nbit cannot set parameters for datatype") break; @@ -928,17 +924,16 @@ H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[1] = (unsigned)need_not_compress; /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_NBIT, flags, cd_values_actual_nparms, cd_values) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local nbit parameters") + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_NBIT, flags, cd_values_actual_nparms, cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local nbit parameters") done: - if(cd_values) - H5MM_xfree(cd_values); + if (cd_values) + H5MM_xfree(cd_values); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_local_nbit() */ - /*------------------------------------------------------------------------- * Function: H5Z__filter_nbit * @@ -953,41 +948,41 @@ H5Z__set_local_nbit(hid_t dcpl_id, hid_t type_id, hid_t space_id) *------------------------------------------------------------------------- */ static size_t -H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - unsigned char *outbuf; /* pointer to new output buffer */ - size_t size_out = 0; /* size of output buffer */ - unsigned d_nelmts = 0; /* number of elements in the chunk */ - size_t ret_value = 0; /* return value */ + unsigned char *outbuf; /* pointer to new output buffer */ + size_t size_out = 0; /* size of output buffer */ + unsigned d_nelmts = 0; /* number of elements in the chunk */ + size_t ret_value = 0; /* return value */ FUNC_ENTER_STATIC /* check arguments * cd_values[0] stores actual number of parameters in cd_values[] */ - if(cd_nelmts != cd_values[0]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid nbit aggression level") + if (cd_nelmts != cd_values[0]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid nbit aggression level") /* check if need to do nbit compress or decompress * cd_values[1] stores the flag if true indicating no need to compress */ - if(cd_values[1]) + if (cd_values[1]) HGOTO_DONE(*buf_size) /* copy a filter parameter to d_nelmts */ d_nelmts = cd_values[2]; /* input; decompress */ - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { size_out = d_nelmts * cd_values[4]; /* cd_values[4] stores datatype size */ /* allocate memory space for decompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit decompression") /* decompress the buffer */ - if(H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) + if (H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, 0, "can't decompress buffer") } /* end if */ /* output; compress */ @@ -997,7 +992,7 @@ H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_out = nbytes; /* allocate memory space for compressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit compression") /* compress the buffer, size_out will be changed */ @@ -1008,7 +1003,7 @@ H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], H5MM_xfree(*buf); /* set return values */ - *buf = outbuf; + *buf = outbuf; *buf_size = size_out; ret_value = size_out; @@ -1027,104 +1022,110 @@ H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], static void H5Z__nbit_next_byte(size_t *j, size_t *buf_len) { - ++(*j); - *buf_len = 8 * sizeof(unsigned char); + ++(*j); + *buf_len = 8 * sizeof(unsigned char); } static void -H5Z__nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, - unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, - const parms_atomic *p, size_t datatype_len) +H5Z__nbit_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned end_i, const unsigned char *buffer, size_t *j, size_t *buf_len, + const parms_atomic *p, size_t datatype_len) { - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - size_t dat_offset; - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - dat_offset = 0; - - if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */ - if(k == begin_i) - dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; - else if(k == end_i) { - dat_len = 8 - p->offset % 8; - dat_offset = 8 - dat_len; - } - else - dat_len = 8; - } else { /* all significant bits in one unsigned char */ - dat_offset = p->offset % 8; - dat_len = p->precision; - } - - if(*buf_len > dat_len) { - data[data_offset + k] = (unsigned char)( - ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset); - *buf_len -= dat_len; - } else { - data[data_offset + k] = (unsigned char)( - ((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)) << dat_offset); - dat_len -= *buf_len; - H5Z__nbit_next_byte(j, buf_len); - if(dat_len == 0) - return; - - val = buffer[*j]; - data[data_offset + k] |= (unsigned char)( - ((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))) << dat_offset); - *buf_len -= dat_len; - } + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + size_t dat_offset; + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + dat_offset = 0; + + if (begin_i != end_i) { /* significant bits occupy >1 unsigned char */ + if (k == begin_i) + dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; + else if (k == end_i) { + dat_len = 8 - p->offset % 8; + dat_offset = 8 - dat_len; + } + else + dat_len = 8; + } + else { /* all significant bits in one unsigned char */ + dat_offset = p->offset % 8; + dat_len = p->precision; + } + + if (*buf_len > dat_len) { + data[data_offset + k] = (unsigned char)(((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))) + << dat_offset); + *buf_len -= dat_len; + } + else { + data[data_offset + k] = + (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)) << dat_offset); + dat_len -= *buf_len; + H5Z__nbit_next_byte(j, buf_len); + if (dat_len == 0) + return; + + val = buffer[*j]; + data[data_offset + k] |= (unsigned char)(((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))) + << dat_offset); + *buf_len -= dat_len; + } } static void -H5Z__nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size) +H5Z__nbit_decompress_one_nooptype(unsigned char *data, size_t data_offset, const unsigned char *buffer, + size_t *j, size_t *buf_len, unsigned size) { - unsigned i; /* index */ - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - for(i = 0; i < size; i++) { - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - dat_len = sizeof(unsigned char) * 8; - - data[data_offset + i] = (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len))); - dat_len -= *buf_len; - H5Z__nbit_next_byte(j, buf_len); - if(dat_len == 0) - continue; - - val = buffer[*j]; - data[data_offset + i] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)(~0) << dat_len))); - *buf_len -= dat_len; - } + unsigned i; /* index */ + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + for (i = 0; i < size; i++) { + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + dat_len = sizeof(unsigned char) * 8; + + data[data_offset + i] = + (unsigned char)(((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len))); + dat_len -= *buf_len; + H5Z__nbit_next_byte(j, buf_len); + if (dat_len == 0) + continue; + + val = buffer[*j]; + data[data_offset + i] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & + (unsigned)(~((unsigned)(~0) << dat_len))); + *buf_len -= dat_len; + } } static void -H5Z__nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p) +H5Z__nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p) { /* begin_i: the index of byte having first significant bit end_i: the index of byte having last significant bit */ - int k; + int k; unsigned begin_i, end_i; - size_t datatype_len; + size_t datatype_len; datatype_len = p->size * 8; - if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ + if (p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ /* calculate begin_i and end_i */ - if((p->precision + p->offset) % 8 != 0) - begin_i = (p->precision + p->offset) / 8; + if ((p->precision + p->offset) % 8 != 0) + begin_i = (p->precision + p->offset) / 8; else - begin_i = (p->precision + p->offset) / 8 - 1; + begin_i = (p->precision + p->offset) / 8 - 1; end_i = p->offset / 8; - for(k = (int)begin_i; k >= (int)end_i; k--) - H5Z__nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k >= (int)end_i; k--) + H5Z__nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, + p, datatype_len); } else { /* big endian */ /* Sanity check */ @@ -1132,165 +1133,160 @@ H5Z__nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, /* calculate begin_i and end_i */ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8; - if(p->offset % 8 != 0) - end_i = ((unsigned)datatype_len - p->offset) / 8; + if (p->offset % 8 != 0) + end_i = ((unsigned)datatype_len - p->offset) / 8; else - end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; + end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; - for(k = (int)begin_i; k <= (int)end_i; k++) - H5Z__nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k <= (int)end_i; k++) + H5Z__nbit_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, + p, datatype_len); } } static herr_t -H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, total_size, base_class, base_size, n, begin_index; - parms_atomic p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - total_size = parms[(*parms_index)++]; - base_class = parms[(*parms_index)++]; - - switch(base_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - - /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - - n = total_size / p.size; - for(i = 0; i < n; i++) - H5Z__nbit_decompress_one_atomic(data, data_offset + i * p.size, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - if(H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_COMPOUND: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - if(H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_NOOPTYPE: - (*parms_index)++; /* skip size of no-op type */ - H5Z__nbit_decompress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ + unsigned i, total_size, base_class, base_size, n, begin_index; + parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + total_size = parms[(*parms_index)++]; + base_class = parms[(*parms_index)++]; + + switch (base_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + + n = total_size / p.size; + for (i = 0; i < n; i++) + H5Z__nbit_decompress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + if (H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_COMPOUND: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + if (H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_NOOPTYPE: + (*parms_index)++; /* skip size of no-op type */ + H5Z__nbit_decompress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) } static herr_t -H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; - parms_atomic p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - size = parms[(*parms_index)++]; - nmembers = parms[(*parms_index)++]; - - for(i = 0; i < nmembers; i++) { - member_offset = parms[(*parms_index)++]; - member_class = parms[(*parms_index)++]; - - /* Check for overflow */ - member_size = parms[*parms_index]; - used_size += member_size; - if(used_size > size) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") - switch(member_class) { - case H5Z_NBIT_ATOMIC: - p.size = member_size; - /* Advance past member size */ - (*parms_index)++; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - - /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - - H5Z__nbit_decompress_one_atomic(data, data_offset + member_offset, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - if(H5Z__nbit_decompress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") - break; - - case H5Z_NBIT_COMPOUND: - if(H5Z__nbit_decompress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") - break; - - case H5Z_NBIT_NOOPTYPE: - /* Advance past member size */ - (*parms_index)++; - H5Z__nbit_decompress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, member_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ - } + unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; + parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + size = parms[(*parms_index)++]; + nmembers = parms[(*parms_index)++]; + + for (i = 0; i < nmembers; i++) { + member_offset = parms[(*parms_index)++]; + member_class = parms[(*parms_index)++]; + + /* Check for overflow */ + member_size = parms[*parms_index]; + used_size += member_size; + if (used_size > size) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") + switch (member_class) { + case H5Z_NBIT_ATOMIC: + p.size = member_size; + /* Advance past member size */ + (*parms_index)++; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + + H5Z__nbit_decompress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + if (H5Z__nbit_decompress_one_array(data, data_offset + member_offset, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") + break; + + case H5Z_NBIT_COMPOUND: + if (H5Z__nbit_decompress_one_compound(data, data_offset + member_offset, buffer, j, buf_len, + parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") + break; + + case H5Z_NBIT_NOOPTYPE: + /* Advance past member size */ + (*parms_index)++; + H5Z__nbit_decompress_one_nooptype(data, data_offset + member_offset, buffer, j, buf_len, + member_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) } static herr_t -H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - const unsigned parms[]) +H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ - unsigned i; - size_t j, size; - size_t buf_len; + unsigned i; + size_t j, size; + size_t buf_len; parms_atomic p; - unsigned parms_index; /* index in array parms used by compression/decompression functions */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned parms_index; /* index in array parms used by compression/decompression functions */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1298,46 +1294,48 @@ H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buff HDmemset(data, 0, d_nelmts * parms[4]); /* initialization before the loop */ - j = 0; + j = 0; buf_len = sizeof(unsigned char) * 8; - switch(parms[3]) { - case H5Z_NBIT_ATOMIC: - p.size = parms[4]; - p.order = parms[5]; + switch (parms[3]) { + case H5Z_NBIT_ATOMIC: + p.size = parms[4]; + p.order = parms[5]; p.precision = parms[6]; - p.offset = parms[7]; + p.offset = parms[7]; /* Check values of precision and offset */ - if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + if (p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") - for(i = 0; i < d_nelmts; i++) - H5Z__nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); + for (i = 0; i < d_nelmts; i++) + H5Z__nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); break; - case H5Z_NBIT_ARRAY: - size = parms[4]; - parms_index = 4; /* set the index before goto function call */ - for(i = 0; i < d_nelmts; i++) { - if(H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + case H5Z_NBIT_ARRAY: + size = parms[4]; + parms_index = 4; /* set the index before goto function call */ + for (i = 0; i < d_nelmts; i++) { + if (H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, + &parms_index) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") parms_index = 4; } break; - case H5Z_NBIT_COMPOUND: - size = parms[4]; - parms_index = 4; /* set the index before goto function call */ - for(i = 0; i < d_nelmts; i++) { - if(H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + case H5Z_NBIT_COMPOUND: + size = parms[4]; + parms_index = 4; /* set the index before goto function call */ + for (i = 0; i < d_nelmts; i++) { + if (H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, + &parms_index) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") parms_index = 4; } break; - default: - HDassert(0 && "This Should never be executed!"); + default: + HDassert(0 && "This Should never be executed!"); } /* end switch */ done: @@ -1345,91 +1343,95 @@ H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buff } static void -H5Z__nbit_compress_one_byte(unsigned char *data, size_t data_offset, unsigned k, - unsigned begin_i, unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, - const parms_atomic *p, size_t datatype_len) +H5Z__nbit_compress_one_byte(const unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + unsigned end_i, unsigned char *buffer, size_t *j, size_t *buf_len, + const parms_atomic *p, size_t datatype_len) { - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + k]; - if(begin_i != end_i) { /* significant bits occupy >1 unsigned char */ - if(k == begin_i) - dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; - else if(k == end_i) { - dat_len = 8 - p->offset % 8; - val = (unsigned char)(val >> (8 - dat_len)); - } - else - dat_len = 8; - } else { /* all significant bits in one unsigned char */ - val = (unsigned char)(val >> (p->offset % 8)); - dat_len = p->precision; - } - - if(*buf_len > dat_len) { - buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } else { - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z__nbit_next_byte(j, buf_len); - if(dat_len == 0) - return; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + k]; + if (begin_i != end_i) { /* significant bits occupy >1 unsigned char */ + if (k == begin_i) + dat_len = 8 - (datatype_len - p->precision - p->offset) % 8; + else if (k == end_i) { + dat_len = 8 - p->offset % 8; + val = (unsigned char)(val >> (8 - dat_len)); + } + else + dat_len = 8; + } + else { /* all significant bits in one unsigned char */ + val = (unsigned char)(val >> (p->offset % 8)); + dat_len = p->precision; + } + + if (*buf_len > dat_len) { + buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } + else { + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z__nbit_next_byte(j, buf_len); + if (dat_len == 0) + return; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } } static void -H5Z__nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size) +H5Z__nbit_compress_one_nooptype(const unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, size_t *buf_len, unsigned size) { - unsigned i; /* index */ - size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - for(i = 0; i < size; i++) { - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + i]; - dat_len = sizeof(unsigned char) * 8; - - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z__nbit_next_byte(j, buf_len); - if(dat_len == 0) - continue; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } + unsigned i; /* index */ + size_t dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + for (i = 0; i < size; i++) { + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + i]; + dat_len = sizeof(unsigned char) * 8; + + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z__nbit_next_byte(j, buf_len); + if (dat_len == 0) + continue; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } } static void -H5Z__nbit_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p) +H5Z__nbit_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const parms_atomic *p) { /* begin_i: the index of byte having first significant bit end_i: the index of byte having last significant bit */ - int k; + int k; unsigned begin_i, end_i; - size_t datatype_len; + size_t datatype_len; datatype_len = p->size * 8; - if(p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ + if (p->order == H5Z_NBIT_ORDER_LE) { /* little endian */ /* calculate begin_i and end_i */ - if((p->precision + p->offset) % 8 != 0) - begin_i = (p->precision + p->offset) / 8; + if ((p->precision + p->offset) % 8 != 0) + begin_i = (p->precision + p->offset) / 8; else - begin_i = (p->precision + p->offset) / 8 - 1; + begin_i = (p->precision + p->offset) / 8 - 1; end_i = p->offset / 8; - for(k = (int)begin_i; k >= (int)end_i; k--) - H5Z__nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k >= (int)end_i; k--) + H5Z__nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, p, + datatype_len); } else { /* big endian */ /* Sanity check */ @@ -1437,131 +1439,126 @@ H5Z__nbit_compress_one_atomic(unsigned char *data, size_t data_offset, /* calculate begin_i and end_i */ begin_i = ((unsigned)datatype_len - p->precision - p->offset) / 8; - if(p->offset % 8 != 0) - end_i = ((unsigned)datatype_len - p->offset) / 8; + if (p->offset % 8 != 0) + end_i = ((unsigned)datatype_len - p->offset) / 8; else - end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; + end_i = ((unsigned)datatype_len - p->offset) / 8 - 1; - for(k = (int)begin_i; k <= (int)end_i; k++) - H5Z__nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, - buffer, j, buf_len, p, datatype_len); + for (k = (int)begin_i; k <= (int)end_i; k++) + H5Z__nbit_compress_one_byte(data, data_offset, (unsigned)k, begin_i, end_i, buffer, j, buf_len, p, + datatype_len); } } static void -H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_compress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, total_size, base_class, base_size, n, begin_index; - parms_atomic p; - - total_size = parms[(*parms_index)++]; - base_class = parms[(*parms_index)++]; - - switch(base_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - n = total_size / p.size; - for(i = 0; i < n; i++) - H5Z__nbit_compress_one_atomic(data, data_offset + i * p.size, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - H5Z__nbit_compress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_COMPOUND: - base_size = parms[*parms_index]; /* read in advance */ - n = total_size / base_size; /* number of base_type elements inside the array datatype */ - begin_index = *parms_index; - for(i = 0; i < n; i++) { - H5Z__nbit_compress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); - *parms_index = begin_index; - } - break; - - case H5Z_NBIT_NOOPTYPE: - (*parms_index)++; /* skip size of no-op type */ - H5Z__nbit_compress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ + unsigned i, total_size, base_class, base_size, n, begin_index; + parms_atomic p; + + total_size = parms[(*parms_index)++]; + base_class = parms[(*parms_index)++]; + + switch (base_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + n = total_size / p.size; + for (i = 0; i < n; i++) + H5Z__nbit_compress_one_atomic(data, data_offset + i * p.size, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + H5Z__nbit_compress_one_array(data, data_offset + i * base_size, buffer, j, buf_len, parms, + parms_index); + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_COMPOUND: + base_size = parms[*parms_index]; /* read in advance */ + n = total_size / base_size; /* number of base_type elements inside the array datatype */ + begin_index = *parms_index; + for (i = 0; i < n; i++) { + H5Z__nbit_compress_one_compound(data, data_offset + i * base_size, buffer, j, buf_len, parms, + parms_index); + *parms_index = begin_index; + } + break; + + case H5Z_NBIT_NOOPTYPE: + (*parms_index)++; /* skip size of no-op type */ + H5Z__nbit_compress_one_nooptype(data, data_offset, buffer, j, buf_len, total_size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ } static void -H5Z__nbit_compress_one_compound(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], - unsigned *parms_index) +H5Z__nbit_compress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, + size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, size; - parms_atomic p; - - (*parms_index)++; /* skip size of compound datatype */ - nmembers = parms[(*parms_index)++]; - - for(i = 0; i < nmembers; i++) { - member_offset = parms[(*parms_index)++]; - member_class = parms[(*parms_index)++]; - - switch(member_class) { - case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; - p.order = parms[(*parms_index)++]; - p.precision = parms[(*parms_index)++]; - p.offset = parms[(*parms_index)++]; - H5Z__nbit_compress_one_atomic(data, data_offset + member_offset, - buffer, j, buf_len, &p); - break; - - case H5Z_NBIT_ARRAY: - H5Z__nbit_compress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index); - break; - - case H5Z_NBIT_COMPOUND: - H5Z__nbit_compress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index); - break; - - case H5Z_NBIT_NOOPTYPE: - size = parms[(*parms_index)++]; - H5Z__nbit_compress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, size); - break; - - default: - HDassert(0 && "This Should never be executed!"); - } /* end switch */ - } + unsigned i, nmembers, member_offset, member_class, size; + parms_atomic p; + + (*parms_index)++; /* skip size of compound datatype */ + nmembers = parms[(*parms_index)++]; + + for (i = 0; i < nmembers; i++) { + member_offset = parms[(*parms_index)++]; + member_class = parms[(*parms_index)++]; + + switch (member_class) { + case H5Z_NBIT_ATOMIC: + p.size = parms[(*parms_index)++]; + p.order = parms[(*parms_index)++]; + p.precision = parms[(*parms_index)++]; + p.offset = parms[(*parms_index)++]; + H5Z__nbit_compress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); + break; + + case H5Z_NBIT_ARRAY: + H5Z__nbit_compress_one_array(data, data_offset + member_offset, buffer, j, buf_len, parms, + parms_index); + break; + + case H5Z_NBIT_COMPOUND: + H5Z__nbit_compress_one_compound(data, data_offset + member_offset, buffer, j, buf_len, parms, + parms_index); + break; + + case H5Z_NBIT_NOOPTYPE: + size = parms[(*parms_index)++]; + H5Z__nbit_compress_one_nooptype(data, data_offset + member_offset, buffer, j, buf_len, size); + break; + + default: + HDassert(0 && "This Should never be executed!"); + } /* end switch */ + } } static void -H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t *buffer_size, const unsigned parms[]) +H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, size_t *buffer_size, + const unsigned parms[]) { /* i: index of data, new_size: index of buffer, buf_len: number of bits to be filled in current byte */ - unsigned i; - size_t size; - size_t new_size = 0; - size_t buf_len; + unsigned i; + size_t size; + size_t new_size = 0; + size_t buf_len; parms_atomic p; - unsigned parms_index; /* index in array parms used by compression/decompression functions */ + unsigned parms_index; /* index in array parms used by compression/decompression functions */ /* must initialize buffer to be zeros */ HDmemset(buffer, 0, *buffer_size); @@ -1569,31 +1566,33 @@ H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer /* initialization before the loop */ buf_len = sizeof(unsigned char) * 8; - switch(parms[3]) { - case H5Z_NBIT_ATOMIC: - p.size = parms[4]; - p.order = parms[5]; + switch (parms[3]) { + case H5Z_NBIT_ATOMIC: + p.size = parms[4]; + p.order = parms[5]; p.precision = parms[6]; - p.offset = parms[7]; + p.offset = parms[7]; - for(i = 0; i < d_nelmts; i++) + for (i = 0; i < d_nelmts; i++) H5Z__nbit_compress_one_atomic(data, i * p.size, buffer, &new_size, &buf_len, &p); break; - case H5Z_NBIT_ARRAY: - size = parms[4]; + case H5Z_NBIT_ARRAY: + size = parms[4]; parms_index = 4; - for(i = 0; i < d_nelmts; i++) { - H5Z__nbit_compress_one_array(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index); + for (i = 0; i < d_nelmts; i++) { + H5Z__nbit_compress_one_array(data, i * size, buffer, &new_size, &buf_len, parms, + &parms_index); parms_index = 4; } break; - case H5Z_NBIT_COMPOUND: - size = parms[4]; + case H5Z_NBIT_COMPOUND: + size = parms[4]; parms_index = 4; - for(i = 0; i < d_nelmts; i++) { - H5Z__nbit_compress_one_compound(data, i * size, buffer, &new_size, &buf_len, parms, &parms_index); + for (i = 0; i < d_nelmts; i++) { + H5Z__nbit_compress_one_compound(data, i * size, buffer, &new_size, &buf_len, parms, + &parms_index); parms_index = 4; } break; @@ -1606,4 +1605,3 @@ H5Z__nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer * the last byte, increment the value by 1. */ *buffer_size = new_size + 1; } - diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index 55fca27996a..726478a0880 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,11 +15,11 @@ #error "Do not include this file outside the H5Z package!" #endif -#ifndef _H5Zpkg_H -#define _H5Zpkg_H +#ifndef H5Zpkg_H +#define H5Zpkg_H /* Include private header file */ -#include "H5Zprivate.h" /* Filter functions */ +#include "H5Zprivate.h" /* Filter functions */ /********************/ /* Internal filters */ @@ -54,5 +54,4 @@ H5_DLLVAR H5Z_class2_t H5Z_SZIP[1]; /* Package internal routines */ H5_DLL herr_t H5Z__unregister(H5Z_filter_t filter_id); -#endif /* _H5Zpkg_H */ - +#endif /* H5Zpkg_H */ diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 24b06e393db..51690b424c7 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ * Thursday, April 16, 1998 */ -#ifndef _H5Zprivate_H -#define _H5Zprivate_H +#ifndef H5Zprivate_H +#define H5Zprivate_H /* Early typedefs to avoid circular dependencies */ typedef struct H5Z_filter_info_t H5Z_filter_info_t; @@ -25,10 +25,8 @@ typedef struct H5Z_filter_info_t H5Z_filter_info_t; #include "H5Zpublic.h" /* Private headers needed by this file */ -#include "H5Tprivate.h" /* Datatypes */ - -/* Forward declarations (for prototype) */ -struct H5S_t; +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Sprivate.h" /* Dataspace */ /**************************/ /* Library Private Macros */ @@ -38,17 +36,17 @@ struct H5S_t; /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ -#define H5_SZIP_LSB_OPTION_MASK 8 -#define H5_SZIP_MSB_OPTION_MASK 16 -#define H5_SZIP_RAW_OPTION_MASK 128 +#define H5_SZIP_LSB_OPTION_MASK 8 +#define H5_SZIP_MSB_OPTION_MASK 16 +#define H5_SZIP_RAW_OPTION_MASK 128 /* Common # of 'client data values' for filters */ /* (avoids dynamic memory allocation in most cases) */ -#define H5Z_COMMON_CD_VALUES 4 +#define H5Z_COMMON_CD_VALUES 4 /* Common size of filter name */ /* (avoids dynamic memory allocation in most cases) */ -#define H5Z_COMMON_NAME_LEN 12 +#define H5Z_COMMON_NAME_LEN 12 /****************************/ /* Library Private Typedefs */ @@ -56,20 +54,19 @@ struct H5S_t; /* Structure to store information about each filter's parameters */ struct H5Z_filter_info_t { - H5Z_filter_t id; /*filter identification number */ - unsigned flags; /*defn and invocation flags */ - char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ - char *name; /*optional filter name */ - size_t cd_nelmts; /*number of elements in cd_values[] */ - unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */ - unsigned *cd_values; /*client data values */ + H5Z_filter_t id; /*filter identification number */ + unsigned flags; /*defn and invocation flags */ + char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ + char * name; /*optional filter name */ + size_t cd_nelmts; /*number of elements in cd_values[] */ + unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */ + unsigned * cd_values; /*client data values */ }; /*****************************/ /* Library-private Variables */ /*****************************/ - /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -78,38 +75,35 @@ struct H5O_pline_t; /*forward decl*/ /* Internal API routines */ H5_DLL herr_t H5Z_init(void); H5_DLL herr_t H5Z_register(const H5Z_class2_t *cls); -H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); -H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, - unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); -H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, - unsigned flags, unsigned *filter_mask/*in,out*/, - H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, - size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, - void **buf/*in,out*/); +H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, + const unsigned int cd_values[]); +H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, + size_t cd_nelmts, const unsigned int cd_values[]); +H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, unsigned flags, unsigned *filter_mask /*in,out*/, + H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes /*in,out*/, + size_t *buf_size /*in,out*/, void **buf /*in,out*/); H5_DLL H5Z_class2_t *H5Z_find(H5Z_filter_t id); -H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); -H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); -H5_DLL herr_t H5Z_can_apply_direct(const struct H5O_pline_t *pline); -H5_DLL herr_t H5Z_set_local_direct(const struct H5O_pline_t *pline); -H5_DLL htri_t H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const struct H5S_t *space); -H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, - H5Z_filter_t filter); -H5_DLL htri_t H5Z_filter_in_pline(const struct H5O_pline_t *pline, H5Z_filter_t filter); -H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); -H5_DLL htri_t H5Z_filter_avail(H5Z_filter_t id); -H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); -H5_DLL herr_t H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); +H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); +H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); +H5_DLL herr_t H5Z_can_apply_direct(const struct H5O_pline_t *pline); +H5_DLL herr_t H5Z_set_local_direct(const struct H5O_pline_t *pline); +H5_DLL htri_t H5Z_ignore_filters(hid_t dcpl_id, const H5T_t *type, const H5S_t *space); +H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL htri_t H5Z_filter_in_pline(const struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); +H5_DLL htri_t H5Z_filter_avail(H5Z_filter_t id); +H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL herr_t H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); /* Data Transform Functions */ typedef struct H5Z_data_xform_t H5Z_data_xform_t; /* Defined in H5Ztrans.c */ H5_DLL H5Z_data_xform_t *H5Z_xform_create(const char *expr); -H5_DLL herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop); -H5_DLL herr_t H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop); -H5_DLL herr_t H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, - size_t array_size, const H5T_t *buf_type); -H5_DLL hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop); -H5_DLL const char *H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop); +H5_DLL herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop); +H5_DLL herr_t H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop); +H5_DLL herr_t H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size, + const H5T_t *buf_type); +H5_DLL hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop); +H5_DLL const char * H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop); #endif diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index b37dcf31265..90277cf9cea 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,210 +15,651 @@ * Thursday, April 16, 1998 */ -#ifndef _H5Zpublic_H -#define _H5Zpublic_H +#ifndef H5Zpublic_H +#define H5Zpublic_H /* Public headers needed by this file */ #include "H5public.h" -/* - * Filter identifiers. Values 0 through 255 are for filters defined by the - * HDF5 library. Values 256 through 511 are available for testing new - * filters. Subsequent values should be obtained from the HDF5 development - * team at help@hdfgroup.org. These values will never change because they - * appear in the HDF5 files. +/** + * \brief Filter identifiers + * + * \details Values 0 through 255 are for filters defined by the HDF5 library. + * Values 256 through 511 are available for testing new filters. + * Subsequent values should be obtained from the HDF5 development team + * at mailto:help@hdfgroup.org. These values will never change because + * they appear in the HDF5 files. */ typedef int H5Z_filter_t; /* Filter IDs */ -#define H5Z_FILTER_ERROR (-1) /*no filter */ -#define H5Z_FILTER_NONE 0 /*reserved indefinitely */ -#define H5Z_FILTER_DEFLATE 1 /*deflation like gzip */ -#define H5Z_FILTER_SHUFFLE 2 /*shuffle the data */ -#define H5Z_FILTER_FLETCHER32 3 /*fletcher32 checksum of EDC */ -#define H5Z_FILTER_SZIP 4 /*szip compression */ -#define H5Z_FILTER_NBIT 5 /*nbit compression */ -#define H5Z_FILTER_SCALEOFFSET 6 /*scale+offset compression */ -#define H5Z_FILTER_RESERVED 256 /*filter ids below this value are reserved for library use */ - -#define H5Z_FILTER_MAX 65535 /*maximum filter id */ +/** + * no filter + */ +#define H5Z_FILTER_ERROR (-1) +/** + * reserved indefinitely + */ +#define H5Z_FILTER_NONE 0 +/** + * deflation like gzip + */ +#define H5Z_FILTER_DEFLATE 1 +/** + * shuffle the data + */ +#define H5Z_FILTER_SHUFFLE 2 +/** + * fletcher32 checksum of EDC + */ +#define H5Z_FILTER_FLETCHER32 3 +/** + * szip compression + */ +#define H5Z_FILTER_SZIP 4 +/** + * nbit compression + */ +#define H5Z_FILTER_NBIT 5 +/** + * scale+offset compression + */ +#define H5Z_FILTER_SCALEOFFSET 6 +/** + * filter ids below this value are reserved for library use + */ +#define H5Z_FILTER_RESERVED 256 +/** + * maximum filter id + */ +#define H5Z_FILTER_MAX 65535 /* General macros */ -#define H5Z_FILTER_ALL 0 /* Symbol to remove all filters in H5Premove_filter */ -#define H5Z_MAX_NFILTERS 32 /* Maximum number of filters allowed in a pipeline */ - /* (should probably be allowed to be an - * unlimited amount, but currently each - * filter uses a bit in a 32-bit field, - * so the format would have to be - * changed to accommodate that) - */ +/** + * Symbol to remove all filters in H5Premove_filter() + */ +#define H5Z_FILTER_ALL 0 +/** + * Maximum number of filters allowed in a pipeline + * + * \internal (should probably be allowed to be an unlimited amount, but + * currently each filter uses a bit in a 32-bit field, so the format + * would have to be changed to accommodate that) + */ +#define H5Z_MAX_NFILTERS 32 /* Flags for filter definition (stored) */ -#define H5Z_FLAG_DEFMASK 0x00ff /*definition flag mask */ -#define H5Z_FLAG_MANDATORY 0x0000 /*filter is mandatory */ -#define H5Z_FLAG_OPTIONAL 0x0001 /*filter is optional */ +/** + * definition flag mask + */ +#define H5Z_FLAG_DEFMASK 0x00ff +/** + * filter is mandatory + */ +#define H5Z_FLAG_MANDATORY 0x0000 +/** + * filter is optional + */ +#define H5Z_FLAG_OPTIONAL 0x0001 /* Additional flags for filter invocation (not stored) */ -#define H5Z_FLAG_INVMASK 0xff00 /*invocation flag mask */ -#define H5Z_FLAG_REVERSE 0x0100 /*reverse direction; read */ -#define H5Z_FLAG_SKIP_EDC 0x0200 /*skip EDC filters for read */ +/** + * invocation flag mask + */ +#define H5Z_FLAG_INVMASK 0xff00 +/** + * reverse direction; read + */ +#define H5Z_FLAG_REVERSE 0x0100 +/** + * skip EDC filters for read + */ +#define H5Z_FLAG_SKIP_EDC 0x0200 /* Special parameters for szip compression */ /* [These are aliases for the similar definitions in szlib.h, which we can't * include directly due to the duplication of various symbols with the zlib.h * header file] */ -#define H5_SZIP_ALLOW_K13_OPTION_MASK 1 -#define H5_SZIP_CHIP_OPTION_MASK 2 -#define H5_SZIP_EC_OPTION_MASK 4 -#define H5_SZIP_NN_OPTION_MASK 32 -#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 +/** + * \ingroup SZIP */ +#define H5_SZIP_ALLOW_K13_OPTION_MASK 1 +/** + * \ingroup SZIP */ +#define H5_SZIP_CHIP_OPTION_MASK 2 +/** + * \ingroup SZIP */ +#define H5_SZIP_EC_OPTION_MASK 4 +/** + * \ingroup SZIP */ +#define H5_SZIP_NN_OPTION_MASK 32 +/** + * \ingroup SZIP */ +#define H5_SZIP_MAX_PIXELS_PER_BLOCK 32 /* Macros for the shuffle filter */ -#define H5Z_SHUFFLE_USER_NPARMS 0 /* Number of parameters that users can set */ -#define H5Z_SHUFFLE_TOTAL_NPARMS 1 /* Total number of parameters for filter */ +/** + * \ingroup SHUFFLE + * Number of parameters that users can set for the shuffle filter + */ +#define H5Z_SHUFFLE_USER_NPARMS 0 +/** + * \ingroup SHUFFLE + * Total number of parameters for the shuffle filter + */ +#define H5Z_SHUFFLE_TOTAL_NPARMS 1 /* Macros for the szip filter */ -#define H5Z_SZIP_USER_NPARMS 2 /* Number of parameters that users can set */ -#define H5Z_SZIP_TOTAL_NPARMS 4 /* Total number of parameters for filter */ -#define H5Z_SZIP_PARM_MASK 0 /* "User" parameter for option mask */ -#define H5Z_SZIP_PARM_PPB 1 /* "User" parameter for pixels-per-block */ -#define H5Z_SZIP_PARM_BPP 2 /* "Local" parameter for bits-per-pixel */ -#define H5Z_SZIP_PARM_PPS 3 /* "Local" parameter for pixels-per-scanline */ +/** + * \ingroup SZIP + * Number of parameters that users can set for SZIP + */ +#define H5Z_SZIP_USER_NPARMS 2 +/** + * \ingroup SZIP + * Total number of parameters for SZIP filter + */ +#define H5Z_SZIP_TOTAL_NPARMS 4 +/** + * \ingroup SZIP + * "User" parameter for option mask + */ +#define H5Z_SZIP_PARM_MASK 0 +/** + * \ingroup SZIP + * "User" parameter for pixels-per-block + */ +#define H5Z_SZIP_PARM_PPB 1 +/** + * \ingroup SZIP + * "Local" parameter for bits-per-pixel + */ +#define H5Z_SZIP_PARM_BPP 2 +/** + * \ingroup SZIP + * "Local" parameter for pixels-per-scanline + */ +#define H5Z_SZIP_PARM_PPS 3 /* Macros for the nbit filter */ -#define H5Z_NBIT_USER_NPARMS 0 /* Number of parameters that users can set */ +/** + * \ingroup NBIT + * Number of parameters that users can set for the N-bit filter + */ +#define H5Z_NBIT_USER_NPARMS 0 /* Number of parameters that users can set */ /* Macros for the scale offset filter */ -#define H5Z_SCALEOFFSET_USER_NPARMS 2 /* Number of parameters that users can set */ - +/** + * \ingroup SCALEOFFSET + * Number of parameters that users can set for the scale-offset filter + */ +#define H5Z_SCALEOFFSET_USER_NPARMS 2 /* Special parameters for ScaleOffset filter*/ +/** + * \ingroup SCALEOFFSET */ #define H5Z_SO_INT_MINBITS_DEFAULT 0 +/** + * \ingroup SCALEOFFSET */ typedef enum H5Z_SO_scale_type_t { H5Z_SO_FLOAT_DSCALE = 0, H5Z_SO_FLOAT_ESCALE = 1, H5Z_SO_INT = 2 } H5Z_SO_scale_type_t; -/* Current version of the H5Z_class_t struct */ +/** + * Current version of the H5Z_class_t struct + */ #define H5Z_CLASS_T_VERS (1) -/* Values to decide if EDC is enabled for reading data */ +/** + * \ingroup FLETCHER32 + * Values to decide if EDC is enabled for reading data + */ typedef enum H5Z_EDC_t { - H5Z_ERROR_EDC = -1, /* error value */ - H5Z_DISABLE_EDC = 0, - H5Z_ENABLE_EDC = 1, - H5Z_NO_EDC = 2 /* must be the last */ + H5Z_ERROR_EDC = -1, /**< error value */ + H5Z_DISABLE_EDC = 0, + H5Z_ENABLE_EDC = 1, + H5Z_NO_EDC = 2 /**< sentinel */ } H5Z_EDC_t; /* Bit flags for H5Zget_filter_info */ #define H5Z_FILTER_CONFIG_ENCODE_ENABLED (0x0001) #define H5Z_FILTER_CONFIG_DECODE_ENABLED (0x0002) -/* Return values for filter callback function */ +/** + * Return values for filter callback function + */ typedef enum H5Z_cb_return_t { - H5Z_CB_ERROR = -1, - H5Z_CB_FAIL = 0, /* I/O should fail if filter fails. */ - H5Z_CB_CONT = 1, /* I/O continues if filter fails. */ - H5Z_CB_NO = 2 + H5Z_CB_ERROR = -1, /**< error value */ + H5Z_CB_FAIL = 0, /**< I/O should fail if filter fails. */ + H5Z_CB_CONT = 1, /**< I/O continues if filter fails. */ + H5Z_CB_NO = 2 /**< sentinel */ } H5Z_cb_return_t; -/* Filter callback function definition */ -typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf, - size_t buf_size, void* op_data); +//! +/** + * Filter callback function definition + */ +typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void *buf, size_t buf_size, void *op_data); +//! -/* Structure for filter callback property */ +/** + * Structure for filter callback property + */ typedef struct H5Z_cb_t { - H5Z_filter_func_t func; - void *op_data; + H5Z_filter_func_t func; + void * op_data; } H5Z_cb_t; #ifdef __cplusplus extern "C" { #endif -/* - * Before a dataset gets created, the "can_apply" callbacks for any filters used - * in the dataset creation property list are called - * with the dataset's dataset creation property list, the dataset's datatype and - * a dataspace describing a chunk (for chunked dataset storage). +/** + * \brief This callback determines if a filter can be applied to the dataset + * with the characteristics provided + * + * \dcpl_id + * \type_id + * \space_id + * + * \return \htri_t * - * The "can_apply" callback must determine if the combination of the dataset - * creation property list setting, the datatype and the dataspace represent a - * valid combination to apply this filter to. For example, some cases of - * invalid combinations may involve the filter not operating correctly on - * certain datatypes (or certain datatype sizes), or certain sizes of the chunk - * dataspace. + * \details Before a dataset gets created, the \ref H5Z_can_apply_func_t + * callbacks for any filters used in the dataset creation property list + * are called with the dataset's dataset creation property list, the + * dataset's datatype and a dataspace describing a chunk (for chunked + * dataset storage). * - * The "can_apply" callback can be the NULL pointer, in which case, the library - * will assume that it can apply to any combination of dataset creation - * property list values, datatypes and dataspaces. + * The \ref H5Z_can_apply_func_t callback must determine if the + * combination of the dataset creation property list setting, the + * datatype and the dataspace represent a valid combination to apply + * this filter to. For example, some cases of invalid combinations may + * involve the filter not operating correctly on certain datatypes (or + * certain datatype sizes), or certain sizes of the chunk dataspace. * - * The "can_apply" callback returns positive a valid combination, zero for an - * invalid combination and negative for an error. + * The \ref H5Z_can_apply_func_t callback can be the NULL pointer, in + * which case, the library will assume that it can apply to any + * combination of dataset creation property list values, datatypes and + * dataspaces. + * + * The \ref H5Z_can_apply_func_t callback returns positive a valid + * combination, zero for an invalid combination and negative for an + * error. */ +//! typedef htri_t (*H5Z_can_apply_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); - -/* - * After the "can_apply" callbacks are checked for new datasets, the "set_local" - * callbacks for any filters used in the dataset creation property list are - * called. These callbacks receive the dataset's private copy of the dataset - * creation property list passed in to H5Dcreate (i.e. not the actual property - * list passed in to H5Dcreate) and the datatype ID passed in to H5Dcreate - * (which is not copied and should not be modified) and a dataspace describing - * the chunk (for chunked dataset storage) (which should also not be modified). +//! +/** + * \brief The filter operation callback function, defining a filter's operation + * on data + * + * \dcpl_id + * \type_id + * \space_id * - * The "set_local" callback must set any parameters that are specific to this - * dataset, based on the combination of the dataset creation property list - * values, the datatype and the dataspace. For example, some filters perform - * different actions based on different datatypes (or datatype sizes) or - * different number of dimensions or dataspace sizes. + * \return \herr_t * - * The "set_local" callback can be the NULL pointer, in which case, the library - * will assume that there are no dataset-specific settings for this filter. + * \details After the \ref H5Z_can_apply_func_t callbacks are checked for new + * datasets, the \ref H5Z_set_local_func_t callbacks for any filters + * used in the dataset creation property list are called. These + * callbacks receive the dataset's private copy of the dataset creation + * property list passed in to H5Dcreate() (i.e. not the actual property + * list passed in to H5Dcreate()) and the datatype ID passed in to + * H5Dcreate() (which is not copied and should not be modified) and a + * dataspace describing the chunk (for chunked dataset storage) (which + * should also not be modified). * - * The "set_local" callback must return non-negative on success and negative - * for an error. + * The \ref H5Z_set_local_func_t callback must set any parameters that + * are specific to this dataset, based on the combination of the + * dataset creation property list values, the datatype and the + * dataspace. For example, some filters perform different actions based + * on different datatypes (or datatype sizes) or different number of + * dimensions or dataspace sizes. + * + * The \ref H5Z_set_local_func_t callback can be the NULL pointer, in + * which case, the library will assume that there are no + * dataset-specific settings for this filter. + * + * The \ref H5Z_set_local_func_t callback must return non-negative on + * success and negative for an error. */ +//! typedef herr_t (*H5Z_set_local_func_t)(hid_t dcpl_id, hid_t type_id, hid_t space_id); +//! -/* - * A filter gets definition flags and invocation flags (defined above), the - * client data array and size defined when the filter was added to the - * pipeline, the size in bytes of the data on which to operate, and pointers - * to a buffer and its allocated size. +/** + * \brief The filter operation callback function, defining a filter's operation + * on data + * + * \param[in] flags Bit vector specifying certain general properties of the filter + * \param[in] cd_nelmts Number of elements in \p cd_values + * \param[in] cd_values Auxiliary data for the filter + * \param[in] nbytes The number of valid bytes in \p buf to be filtered + * \param[in,out] buf_size The size of \p buf + * \param[in,out] buf The filter buffer + * + * \return Returns the number of valid bytes of data contained in \p buf. In the + * case of failure, the return value is 0 (zero) and all pointer + * arguments are left unchanged. * - * The filter should store the result in the supplied buffer if possible, - * otherwise it can allocate a new buffer, freeing the original. The - * allocated size of the new buffer should be returned through the BUF_SIZE - * pointer and the new buffer through the BUF pointer. + * \details A filter gets definition flags and invocation flags (defined + * above), the client data array and size defined when the filter was + * added to the pipeline, the size in bytes of the data on which to + * operate, and pointers to a buffer and its allocated size. * - * The return value from the filter is the number of bytes in the output - * buffer. If an error occurs then the function should return zero and leave - * all pointer arguments unchanged. + * The filter should store the result in the supplied buffer if + * possible, otherwise it can allocate a new buffer, freeing the + * original. The allocated size of the new buffer should be returned + * through the \p buf_size pointer and the new buffer through the \p + * buf pointer. + * + * The return value from the filter is the number of bytes in the + * output buffer. If an error occurs then the function should return + * zero and leave all pointer arguments unchanged. */ -typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, - size_t *buf_size, void **buf); - -/* +//! +typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], + size_t nbytes, size_t *buf_size, void **buf); +//! +/** * The filter table maps filter identification numbers to structs that * contain a pointers to the filter function and timing statistics. */ +//! typedef struct H5Z_class2_t { - int version; /* Version number of the H5Z_class_t struct */ - H5Z_filter_t id; /* Filter ID number */ - unsigned encoder_present; /* Does this filter have an encoder? */ - unsigned decoder_present; /* Does this filter have a decoder? */ - const char *name; /* Comment for debugging */ - H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ - H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ - H5Z_func_t filter; /* The actual filter function */ + int version; /**< Version number of the H5Z_class_t struct */ + H5Z_filter_t id; /**< Filter ID number */ + unsigned encoder_present; /**< Does this filter have an encoder? */ + unsigned decoder_present; /**< Does this filter have a decoder? */ + const char * name; /**< Comment for debugging */ + H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ + H5Z_func_t filter; /**< The actual filter function */ } H5Z_class2_t; +//! +/** + * \ingroup H5Z + * + * \brief Registers a new filter with the HDF5 library + * + * \param[in] cls A pointer to a buffer for the struct containing the + * filter-definition + * + * \return \herr_t + * + * \details H5Zregister() registers a new filter with the HDF5 library. + * + * \details Making a new filter available to an application is a two-step + * process. The first step is to write the three filter callback + * functions described below: \c can_apply, \c set_local, and \c + * filter. This call to H5Zregister(), registering the filter with the + * library, is the second step. The can_apply and set_local fields can + * be set to NULL if they are not required for the filter being + * registered. + * + * H5Zregister() accepts a single parameter, a pointer to a buffer for + * the \p cls data structure. That data structure must conform to one + * of the following definitions: + * \snippet this H5Z_class1_t_snip + * or + * \snippet this H5Z_class2_t_snip + * + * \c version is a library-defined value reporting the version number + * of the #H5Z_class_t struct. This currently must be set to + * #H5Z_CLASS_T_VERS. + * + * \c id is the identifier for the new filter. This is a user-defined + * value between #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX. These + * values are defined in the HDF5 source file H5Zpublic.h, but the + * symbols #H5Z_FILTER_RESERVED and #H5Z_FILTER_MAX should always be + * used instead of the literal values. + * + * \c encoder_present is a library-defined value indicating whether + * the filter’s encoding capability is available to the application. + * + * \c decoder_present is a library-defined value indicating whether + * the filter’s encoding capability is available to the application. + * + * \c name is a descriptive comment used for debugging, may contain a + * descriptive name for the filter, and may be the null pointer. + * + * \c can_apply, described in detail below, is a user-defined callback + * function which determines whether the combination of the dataset + * creation property list values, the datatype, and the dataspace + * represent a valid combination to apply this filter to. + * + * \c set_local, described in detail below, is a user-defined callback + * function which sets any parameters that are specific to this + * dataset, based on the combination of the dataset creation property + * list values, the datatype, and the dataspace. + * + * \c filter, described in detail below, is a user-defined callback + * function which performs the action of the filter. + * + * The statistics associated with a filter are not reset by this + * function; they accumulate over the life of the library. + * + * #H5Z_class_t is a macro which maps to either H5Z_class1_t or + * H5Z_class2_t, depending on the needs of the application. To affect + * only this macro, H5Z_class_t_vers may be defined to either 1 or 2. + * Otherwise, it will behave in the same manner as other API + * compatibility macros. See API Compatibility Macros in HDF5 for more + * information. H5Z_class1_t matches the #H5Z_class_t structure that is + * used in the 1.6.x versions of the HDF5 library. + * + * H5Zregister() will automatically detect which structure type has + * been passed in, regardless of the mapping of the #H5Z_class_t macro. + * However, the application must make sure that the fields are filled + * in according to the correct structure definition if the macro is + * used to declare the structure. + * + * \Bold{The callback functions:}\n Before H5Zregister() can link a + * filter into an application, three callback functions must be + * defined as described in the HDF5 library header file H5Zpublic.h. + * + * When a filter is applied to the fractal heap for a group (e.g., + * when compressing group metadata) and if the can apply and set local + * callback functions have been defined for that filter, HDF5 passes + * the value -1 for all parameters for those callback functions. This + * is done to ensure that the filter will not be applied to groups if + * it relies on these parameters, as they are not applicable to group + * fractal heaps; to operate on group fractal heaps, a filter must be + * capable of operating on an opaque block of binary data. + * + * The \Emph{can apply} callback function must return a positive value + * for a valid combination, zero for an invalid combination, and a + * negative value for an error. + * \snippet this H5Z_can_apply_func_t_snip + * + * Before a dataset is created, the \Emph{can apply} callbacks for any + * filters used in the dataset creation property list are called with + * the dataset's dataset creation property list, \c dcpl_id, the + * dataset's datatype, \p type_id, and a dataspace describing a chunk, + * \p space_id, (for chunked dataset storage). + * + * This callback must determine whether the combination of the dataset + * creation property list settings, the datatype, and the dataspace + * represent a valid combination to which to apply this filter. For + * example, an invalid combination may involve the filter not + * operating correctly on certain datatypes, on certain datatype + * sizes, or on certain sizes of the chunk dataspace. If this filter + * is enabled through H5Pset_filter() as optional and the can apply + * function returns 0, the library will skip the filter in the filter + * pipeline. + * + * This callback can be the NULL pointer, in which case the library + * will assume that the filter can be applied to a dataset with any + * combination of dataset creation property list values, datatypes, + * and dataspaces. + * + * The \Emph{set local} callback function is defined as follows: + * \snippet this H5Z_set_local_func_t_snip + * + * After the can apply callbacks are checked for a new dataset, the + * \Emph{set local} callback functions for any filters used in the + * dataset creation property list are called. These callbacks receive + * \c dcpl_id, the dataset's private copy of the dataset creation + * property list passed in to H5Dcreate() (i.e. not the actual + * property list passed in to H5Dcreate()); \c type_id, the datatype + * identifier passed in to H5Dcreate(), which is not copied and should + * not be modified; and \c space_id, a dataspace describing the chunk + * (for chunked dataset storage), which should also not be modified. + * + * The set local callback must set any filter parameters that are + * specific to this dataset, based on the combination of the dataset + * creation property list values, the datatype, and the dataspace. For + * example, some filters perform different actions based on different + * datatypes, datatype sizes, numbers of dimensions, or dataspace + * sizes. + * + * The \Emph{set local} callback may be the NULL pointer, in which + * case, the library will assume that there are no dataset-specific + * settings for this filter. + * + * The \Emph{set local} callback function must return a non-negative + * value on success and a negative value for an error. + * + * The \Emph{filter operation} callback function, defining the + * filter's operation on the data, is defined as follows: + * \snippet this H5Z_func_t_snip + * + * The parameters \c flags, \c cd_nelmts, and \c cd_values are the + * same as for the function H5Pset_filter(). The one exception is that + * an additional flag, #H5Z_FLAG_REVERSE, is set when the filter is + * called as part of the input pipeline. + * + * The parameter \c buf points to the input buffer which has a size of + * \c buf_size bytes, \c nbytes of which are valid data. + * + * The filter should perform the transformation in place if possible. + * If the transformation cannot be done in place, then the filter + * should allocate a new buffer with malloc() and assign it to \c buf, + * assigning the allocated size of that buffer to \c buf_size. The old + * buffer should be freed by calling free(). + * + * If successful, the \Emph{filter operation} callback function + * returns the number of valid bytes of data contained in \c buf. In + * the case of failure, the return value is 0 (zero) and all pointer + * arguments are left unchanged. + * + * \version 1.8.6 Return type for the \Emph{can apply} callback function, + * \ref H5Z_can_apply_func_t, changed to \ref htri_t. + * \version 1.8.5 Semantics of the \Emph{can apply} and \Emph{set local} + * callback functions changed to accommodate the use of filters + * with group fractal heaps. + * \version 1.8.3 #H5Z_class_t renamed to H5Z_class2_t, H5Z_class1_t structure + * introduced for backwards compatibility with release 1.6.x, + * and #H5Z_class_t macro introduced in this release. Function + * modified to accept either structure type. + * \version 1.8.0 The fields \c version, \c encoder_present, and + * \c decoder_present were added to the #H5Z_class_t \c struct + * in this release. + * \version 1.6.0 This function was substantially revised in Release 1.6.0 with + * a new #H5Z_class_t struct and new set local and can apply + * callback functions. + * + */ H5_DLL herr_t H5Zregister(const void *cls); +/** + * \ingroup H5Z + * + * \brief Unregisters a filter. + * + * \param[in] id Identifier of the filter to be unregistered. + * \return \herr_t + * + * \details H5Zunregister() unregisters the filter specified in \p id. + * + * \details This function first iterates through all opened datasets and + * groups. If an open object that uses this filter is found, the + * function will fail with a message indicating that an object using + * the filter is still open. All open files are then flushed to make + * sure that all cached data that may use this filter are written out. + * + * If the application is a parallel program, all processes that + * participate in collective data write should call this function to + * ensure that all data is flushed. + * + * After a call to H5Zunregister(), the filter specified in filter + * will no longer be available to the application. + * + * \version 1.8.12 Function modified to check for open objects using the + * filter. + * \since 1.6.0 + */ H5_DLL herr_t H5Zunregister(H5Z_filter_t id); +/** + * \ingroup H5Z + * + * \brief Determines whether a filter is available + * + * \param[in] id Filter identifier + * \return \htri_t + * + * \details H5Zfilter_avail() determines whether the filter specified in \p id + * is available to the application. + * + * \since 1.6.0 + */ H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); +/** + * \ingroup H5Z + * + * \brief Retrieves information about a filter + * + * \param[in] filter Filter identifier + * \param[out] filter_config_flags A bit field encoding the returned filter + * information + * \return \herr_t + * + * \details H5Zget_filter_info() retrieves information about a filter. At + * present, this means that the function retrieves a filter's + * configuration flags, indicating whether the filter is configured to + * decode data, to encode data, neither, or both. + * + * If \p filter_config_flags is not set to NULL prior to the function + * call, the returned parameter contains a bit field specifying the + * available filter configuration. The configuration flag values can + * then be determined through a series of bitwise AND operations, as + * described below. + * + * Valid filter configuration flags include the following: + * + * + * + * + * + *
#H5Z_FILTER_CONFIG_ENCODE_ENABLEDEncoding is enabled for this filter
#H5Z_FILTER_CONFIG_DECODE_ENABLEDDecoding is enabled for this filter
+ * + * A bitwise AND of the returned \p filter_config_flags and a valid + * filter configuration flag will reveal whether the related + * configuration option is available. For example, if the value of + * \code + * H5Z_FILTER_CONFIG_ENCODE_ENABLED & filter_config_flags + * \endcode + * is true, i.e., greater than 0 (zero), the queried filter + * is configured to encode data; if the value is \c FALSE, i.e., equal to + * 0 (zero), the filter is not so configured. + * + * If a filter is not encode-enabled, the corresponding \c H5Pset_* + * function will return an error if the filter is added to a dataset + * creation property list (which is required if the filter is to be + * used to encode that dataset). For example, if the + * #H5Z_FILTER_CONFIG_ENCODE_ENABLED flag is not returned for the SZIP + * filter, #H5Z_FILTER_SZIP, a call to H5Pset_szip() will fail. + * + * If a filter is not decode-enabled, the application will not be able + * to read an existing file encoded with that filter. + * + * This function should be called, and the returned \p + * filter_config_flags analyzed, before calling any other function, + * such as H5Pset_szip() , that might require a particular filter + * configuration. + * + * \since 1.6.3 + */ H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); /* Symbols defined for compatibility with previous versions of the HDF5 API. @@ -227,17 +668,19 @@ H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_confi */ #ifndef H5_NO_DEPRECATED_SYMBOLS -/* +/** * The filter table maps filter identification numbers to structs that * contain a pointers to the filter function and timing statistics. */ +//! typedef struct H5Z_class1_t { - H5Z_filter_t id; /* Filter ID number */ - const char *name; /* Comment for debugging */ - H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ - H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ - H5Z_func_t filter; /* The actual filter function */ + H5Z_filter_t id; /**< Filter ID number */ + const char * name; /**< Comment for debugging */ + H5Z_can_apply_func_t can_apply; /**< The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /**< The "set local" callback for a filter */ + H5Z_func_t filter; /**< The actual filter function */ } H5Z_class1_t; +//! #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -245,4 +688,3 @@ typedef struct H5Z_class1_t { } #endif #endif - diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 83f170e96a8..97678b04d18 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -6,74 +6,88 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Struct of parameters needed for compressing/decompressing one atomic datatype */ typedef struct { - unsigned size; /* datatype size */ - uint32_t minbits; /* minimum bits to compress one value of such datatype */ - unsigned mem_order; /* current memory endianness order */ + unsigned size; /* datatype size */ + uint32_t minbits; /* minimum bits to compress one value of such datatype */ + unsigned mem_order; /* current memory endianness order */ } parms_atomic; -enum H5Z_scaleoffset_t {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, - t_schar, t_short, t_int, t_long, t_long_long, - t_float, t_double}; +enum H5Z_scaleoffset_t { + t_bad = 0, + t_uchar = 1, + t_ushort, + t_uint, + t_ulong, + t_ulong_long, + t_schar, + t_short, + t_int, + t_long, + t_long_long, + t_float, + t_double +}; /* Local function prototypes */ -static htri_t H5Z__can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static enum H5Z_scaleoffset_t H5Z__scaleoffset_get_type(unsigned dtype_class, - unsigned dtype_size, unsigned dtype_sign); -static herr_t H5Z__scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - H5T_t *type, enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], - int need_convert); -static herr_t H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); -static void H5Z__scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size); +static htri_t H5Z__can_apply_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); +static enum H5Z_scaleoffset_t H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, + unsigned dtype_sign); +static herr_t H5Z__scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, H5T_t *type, + enum H5Z_scaleoffset_t scale_type, unsigned cd_values[], + int need_convert); +static herr_t H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id); +static size_t H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], + size_t nbytes, size_t *buf_size, void **buf); +static void H5Z__scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size); static H5_ATTR_CONST unsigned H5Z__scaleoffset_log2(unsigned long long num); -static void H5Z__scaleoffset_precompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t *minbits, unsigned long long *minval); -static void H5Z__scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t minbits, unsigned long long minval); -static herr_t H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t *minbits, unsigned long long *minval, double D_val); -static herr_t H5Z__scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, - enum H5Z_scaleoffset_t type, unsigned filavail, const unsigned cd_values[], - uint32_t minbits, unsigned long long minval, double D_val); -static void H5Z__scaleoffset_next_byte(size_t *j, unsigned *buf_len); -static void H5Z__scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len); -static void H5Z__scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len); -static void H5Z__scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); -static void H5Z__scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p); -static void H5Z__scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p); -static void H5Z__scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, - size_t buffer_size, parms_atomic p); +static void H5Z__scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], uint32_t *minbits, + unsigned long long *minval); +static void H5Z__scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval); +static herr_t H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], + uint32_t *minbits, unsigned long long *minval, double D_val); +static herr_t H5Z__scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, + unsigned filavail, const unsigned cd_values[], + uint32_t minbits, unsigned long long minval, double D_val); +static void H5Z__scaleoffset_next_byte(size_t *j, unsigned *buf_len); +static void H5Z__scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, const unsigned char *buffer, size_t *j, + unsigned *buf_len, parms_atomic p, unsigned dtype_len); +static void H5Z__scaleoffset_compress_one_byte(const unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned char *buffer, size_t *j, + unsigned *buf_len, parms_atomic p, unsigned dtype_len); +static void H5Z__scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p); +static void H5Z__scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, + unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p); +static void H5Z__scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + parms_atomic p); +static void H5Z__scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, + size_t buffer_size, parms_atomic p); /* This message derives from H5Z */ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ @@ -88,583 +102,639 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ }}; /* Local macros */ -#define H5Z_SCALEOFFSET_TOTAL_NPARMS 20 /* Total number of parameters for filter */ -#define H5Z_SCALEOFFSET_PARM_SCALETYPE 0 /* "User" parameter for scale type */ -#define H5Z_SCALEOFFSET_PARM_SCALEFACTOR 1 /* "User" parameter for scale factor */ -#define H5Z_SCALEOFFSET_PARM_NELMTS 2 /* "Local" parameter for number of elements in the chunk */ -#define H5Z_SCALEOFFSET_PARM_CLASS 3 /* "Local" parameter for datatype class */ -#define H5Z_SCALEOFFSET_PARM_SIZE 4 /* "Local" parameter for datatype size */ -#define H5Z_SCALEOFFSET_PARM_SIGN 5 /* "Local" parameter for integer datatype sign */ -#define H5Z_SCALEOFFSET_PARM_ORDER 6 /* "Local" parameter for datatype byte order */ -#define H5Z_SCALEOFFSET_PARM_FILAVAIL 7 /* "Local" parameter for dataset fill value existence */ -#define H5Z_SCALEOFFSET_PARM_FILVAL 8 /* "Local" parameter for start location to store dataset fill value */ +#define H5Z_SCALEOFFSET_TOTAL_NPARMS 20 /* Total number of parameters for filter */ +#define H5Z_SCALEOFFSET_PARM_SCALETYPE 0 /* "User" parameter for scale type */ +#define H5Z_SCALEOFFSET_PARM_SCALEFACTOR 1 /* "User" parameter for scale factor */ +#define H5Z_SCALEOFFSET_PARM_NELMTS 2 /* "Local" parameter for number of elements in the chunk */ +#define H5Z_SCALEOFFSET_PARM_CLASS 3 /* "Local" parameter for datatype class */ +#define H5Z_SCALEOFFSET_PARM_SIZE 4 /* "Local" parameter for datatype size */ +#define H5Z_SCALEOFFSET_PARM_SIGN 5 /* "Local" parameter for integer datatype sign */ +#define H5Z_SCALEOFFSET_PARM_ORDER 6 /* "Local" parameter for datatype byte order */ +#define H5Z_SCALEOFFSET_PARM_FILAVAIL 7 /* "Local" parameter for dataset fill value existence */ +#define H5Z_SCALEOFFSET_PARM_FILVAL 8 /* "Local" parameter for start location to store dataset fill value */ -#define H5Z_SCALEOFFSET_CLS_INTEGER 0 /* Integer (datatype class) */ -#define H5Z_SCALEOFFSET_CLS_FLOAT 1 /* Floatig-point (datatype class) */ +#define H5Z_SCALEOFFSET_CLS_INTEGER 0 /* Integer (datatype class) */ +#define H5Z_SCALEOFFSET_CLS_FLOAT 1 /* Floatig-point (datatype class) */ -#define H5Z_SCALEOFFSET_SGN_NONE 0 /* Unsigned integer type */ -#define H5Z_SCALEOFFSET_SGN_2 1 /* Two's complement signed integer type */ +#define H5Z_SCALEOFFSET_SGN_NONE 0 /* Unsigned integer type */ +#define H5Z_SCALEOFFSET_SGN_2 1 /* Two's complement signed integer type */ -#define H5Z_SCALEOFFSET_ORDER_LE 0 /* Little endian (datatype byte order) */ -#define H5Z_SCALEOFFSET_ORDER_BE 1 /* Big endian (datatype byte order) */ +#define H5Z_SCALEOFFSET_ORDER_LE 0 /* Little endian (datatype byte order) */ +#define H5Z_SCALEOFFSET_ORDER_BE 1 /* Big endian (datatype byte order) */ -#define H5Z_SCALEOFFSET_FILL_UNDEFINED 0 /* Fill value is not defined */ -#define H5Z_SCALEOFFSET_FILL_DEFINED 1 /* Fill value is defined */ +#define H5Z_SCALEOFFSET_FILL_UNDEFINED 0 /* Fill value is not defined */ +#define H5Z_SCALEOFFSET_FILL_DEFINED 1 /* Fill value is defined */ /* Store fill value in cd_values[] */ -#define H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -{ \ - unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ - uint32_t _cd_value; /* Current cd_value */ \ - char *_fv_p; /* Pointer to current byte in fill_val */ \ - size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ - size_t _size_rem = sizeof(type); /* # of bytes left to copy to cd_values */ \ - \ - /* Store the fill value as the last entry in cd_values[] \ - * Store byte by byte from least significant byte to most significant byte \ - * Plenty of space left for the fill value (from index 8 to 19) \ - * H5O_pline_encode will byte-swap each individual cd value, but we still \ - * need to swap the cd values as a whole if we are on a BE machine. Note \ - * that we need to make sure to put the data only in the lowest 4 bytes of \ - * each, if sizeof(unsigned) > 4. \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) { \ - _fv_p = (char *)&(fill_val); \ - /* Copy 4 bytes at a time to each cd value */ \ - do { \ - if(_size_rem < 4) { \ - /* Amount left to copy is smaller than a cd_value, adjust copy \ - * size and initialize cd_value as it will not be fully \ - * overwritten */ \ - _copy_size = _size_rem; \ - _cd_value = (uint32_t)0; \ - } /* end if */ \ - \ - /* Copy the value */ \ - H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - \ - /* Next field */ \ - _i++; \ - _fv_p += _copy_size; \ - _size_rem -= _copy_size; \ - } while(_size_rem); \ - } /* end if */ \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - \ - /* Copy 4 bytes at a time to each cd value, but start at the end \ - * (highest address) of fill_val */ \ - _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ - while(_size_rem >= 4) { \ - /* Copy the value */ \ - H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - \ - /* Next field */ \ - _i++; \ - _size_rem -= 4; \ - if(_size_rem >= 4) \ - _fv_p -= 4; \ - else \ - _fv_p -= _size_rem; \ - } /* end while */ \ - \ - HDassert(_fv_p == (char *)&(fill_val)); \ - if(_size_rem) { \ - /* Amount left to copy is smaller than a cd_value, initialize \ - * _cd_value as it will not be fully overwritten and copy to the end \ - * of _cd value as it is BE. */ \ - _cd_value = (uint32_t)0; \ - H5MM_memcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \ - (cd_values)[_i] = (unsigned)_cd_value; \ - } /* end if */ \ - } /* end else */ \ -} +#define H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + { \ + unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ + uint32_t _cd_value; /* Current cd_value */ \ + char * _fv_p; /* Pointer to current byte in fill_val */ \ + size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ + size_t _size_rem = sizeof(type); /* # of bytes left to copy to cd_values */ \ + \ + /* Store the fill value as the last entry in cd_values[] \ + * Store byte by byte from least significant byte to most significant byte \ + * Plenty of space left for the fill value (from index 8 to 19) \ + * H5O_pline_encode will byte-swap each individual cd value, but we still \ + * need to swap the cd values as a whole if we are on a BE machine. Note \ + * that we need to make sure to put the data only in the lowest 4 bytes of \ + * each, if sizeof(unsigned) > 4. \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) { \ + _fv_p = (char *)&(fill_val); \ + /* Copy 4 bytes at a time to each cd value */ \ + do { \ + if (_size_rem < 4) { \ + /* Amount left to copy is smaller than a cd_value, adjust copy \ + * size and initialize cd_value as it will not be fully \ + * overwritten */ \ + _copy_size = _size_rem; \ + _cd_value = (uint32_t)0; \ + } /* end if */ \ + \ + /* Copy the value */ \ + H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + \ + /* Next field */ \ + _i++; \ + _fv_p += _copy_size; \ + _size_rem -= _copy_size; \ + } while (_size_rem); \ + } /* end if */ \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + /* Copy 4 bytes at a time to each cd value, but start at the end \ + * (highest address) of fill_val */ \ + _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ + while (_size_rem >= 4) { \ + /* Copy the value */ \ + H5MM_memcpy(&_cd_value, _fv_p, _copy_size); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + \ + /* Next field */ \ + _i++; \ + _size_rem -= 4; \ + if (_size_rem >= 4) \ + _fv_p -= 4; \ + else \ + _fv_p -= _size_rem; \ + } /* end while */ \ + \ + HDassert(_fv_p == (char *)&(fill_val)); \ + if (_size_rem) { \ + /* Amount left to copy is smaller than a cd_value, initialize \ + * _cd_value as it will not be fully overwritten and copy to the end \ + * of _cd value as it is BE. */ \ + _cd_value = (uint32_t)0; \ + H5MM_memcpy((char *)&_cd_value + 4 - _size_rem, _fv_p, _size_rem); \ + (cd_values)[_i] = (unsigned)_cd_value; \ + } /* end if */ \ + } /* end else */ \ + } /* Set the fill value parameter in cd_values[] for unsigned integer type */ -#define H5Z_scaleoffset_set_filval_1(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_1(type, dcpl_plist, dt, cd_values, need_convert) \ + do { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + } while (0) /* Set the fill value parameter in cd_values[] for signed integer type */ -#define H5Z_scaleoffset_set_filval_2(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(unsigned type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_2(type, dcpl_plist, dt, cd_values, need_convert) \ + do { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(unsigned type, cd_values, fill_val) \ + } while (0) /* Set the fill value parameter in cd_values[] for character integer type */ -#define H5Z_scaleoffset_set_filval_3(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - /* Store the fill value as the last entry in cd_values[] */ \ - (cd_values)[H5Z_SCALEOFFSET_PARM_FILVAL] = (unsigned)((unsigned char)fill_val); \ -} +#define H5Z_scaleoffset_set_filval_3(type, dcpl_plist, dt, cd_values, need_convert) \ + do { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + /* Store the fill value as the last entry in cd_values[] */ \ + (cd_values)[H5Z_SCALEOFFSET_PARM_FILVAL] = (unsigned)((unsigned char)fill_val); \ + } while (0) /* Set the fill value parameter in cd_values[] for floating-point type */ -#define H5Z_scaleoffset_set_filval_4(type, dcpl_plist, dt, cd_values, need_convert) \ -{ \ - type fill_val; \ - \ - /* Get dataset fill value */ \ - if(H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ - \ - if(need_convert) \ - H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ - \ - H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ -} +#define H5Z_scaleoffset_set_filval_4(type, dcpl_plist, dt, cd_values, need_convert) \ + do { \ + type fill_val; \ + \ + /* Get dataset fill value */ \ + if (H5P_get_fill_value(dcpl_plist, dt, &fill_val) < 0) \ + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get fill value") \ + \ + if (need_convert) \ + H5Z__scaleoffset_convert(&fill_val, 1, sizeof(type)); \ + \ + H5Z_scaleoffset_save_filval(type, cd_values, fill_val) \ + } while (0) /* Get the fill value for integer type */ -#define H5Z_scaleoffset_get_filval_1(type, cd_values, fill_val) \ -{ \ - unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ - uint32_t _cd_value; /* Current cd_value */ \ - char *_fv_p; /* Pointer to current byte in fill_val */ \ - size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ - size_t _size_rem = sizeof(type); /* # of bytes left to copy to filval */ \ - \ - /* Retrieve the fill value from the last entry in cd_values[] \ - * Store byte by byte from least significant byte to most significant byte \ - * Plenty of space left for the fill value (from index 8 to 19) \ - * H5O_pline_encode will byte-swap each individual cd value, but we still \ - * need to swap the cd values as a whole if we are on a BE machine. Note \ - * that we need to make sure to put the data only in the lowest 4 bytes of \ - * each, if sizeof(unsigned) > 4. \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) { \ - _fv_p = (char *)&(fill_val); \ - /* Copy 4 bytes at a time to each cd value */ \ - do { \ - if(_size_rem < 4) \ - /* Amount left to copy is smaller than a cd_value, adjust copy \ - * size and initialize cd_value as it will not be fully \ - * overwritten */ \ - _copy_size = _size_rem; \ - \ - /* Copy the value */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ - \ - /* Next field */ \ - _i++; \ - _fv_p += _copy_size; \ - _size_rem -= _copy_size; \ - } while(_size_rem); \ - } /* end if */ \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - \ - /* Copy 4 bytes at a time to each cd value, but start at the end \ - * (highest address) of fill_val */ \ - _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ - while(_size_rem >= 4) { \ - /* Copy the value */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ - \ - /* Next field */ \ - _i++; \ - _size_rem -= 4; \ - if(_size_rem >=4) \ - _fv_p -= 4; \ - else \ - _fv_p -= _size_rem; \ - } /* end while */ \ - \ - HDassert(_fv_p == (char *)&(fill_val)); \ - if(_size_rem) { \ - /* Amount left to copy is smaller than a cd_value, initialize \ - * _cd_value as it will not be fully overwritten and copy to the end \ - * of _cd value as it is BE. */ \ - _cd_value = (uint32_t)(cd_values)[_i]; \ - H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \ - } /* end if */ \ - } /* end else */ \ -} +#define H5Z_scaleoffset_get_filval_1(type, cd_values, fill_val) \ + { \ + unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ + uint32_t _cd_value; /* Current cd_value */ \ + char * _fv_p; /* Pointer to current byte in fill_val */ \ + size_t _copy_size = 4; /* # of bytes to copy this iteration */ \ + size_t _size_rem = sizeof(type); /* # of bytes left to copy to filval */ \ + \ + /* Retrieve the fill value from the last entry in cd_values[] \ + * Store byte by byte from least significant byte to most significant byte \ + * Plenty of space left for the fill value (from index 8 to 19) \ + * H5O_pline_encode will byte-swap each individual cd value, but we still \ + * need to swap the cd values as a whole if we are on a BE machine. Note \ + * that we need to make sure to put the data only in the lowest 4 bytes of \ + * each, if sizeof(unsigned) > 4. \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) { \ + _fv_p = (char *)&(fill_val); \ + /* Copy 4 bytes at a time to each cd value */ \ + do { \ + if (_size_rem < 4) \ + /* Amount left to copy is smaller than a cd_value, adjust copy \ + * size and initialize cd_value as it will not be fully \ + * overwritten */ \ + _copy_size = _size_rem; \ + \ + /* Copy the value */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ + \ + /* Next field */ \ + _i++; \ + _fv_p += _copy_size; \ + _size_rem -= _copy_size; \ + } while (_size_rem); \ + } /* end if */ \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + \ + /* Copy 4 bytes at a time to each cd value, but start at the end \ + * (highest address) of fill_val */ \ + _fv_p = ((char *)&(fill_val)) + sizeof(type) - MIN(4, _size_rem); \ + while (_size_rem >= 4) { \ + /* Copy the value */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, &_cd_value, _copy_size); \ + \ + /* Next field */ \ + _i++; \ + _size_rem -= 4; \ + if (_size_rem >= 4) \ + _fv_p -= 4; \ + else \ + _fv_p -= _size_rem; \ + } /* end while */ \ + \ + HDassert(_fv_p == (char *)&(fill_val)); \ + if (_size_rem) { \ + /* Amount left to copy is smaller than a cd_value, initialize \ + * _cd_value as it will not be fully overwritten and copy to the end \ + * of _cd value as it is BE. */ \ + _cd_value = (uint32_t)(cd_values)[_i]; \ + H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \ + } /* end if */ \ + } /* end else */ \ + } /* Get the fill value for floating-point type */ -#define H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) else HGOTO_ERROR( \ + H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Find maximum and minimum values of a buffer with fill value defined for integer type */ -#define H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min)\ -{ \ - i = 0; while(i < d_nelmts && buf[i]== filval) i++; \ - if(i < d_nelmts) min = max = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(buf[i] == filval) continue; /* ignore fill value */ \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + { \ + i = 0; \ + while (i < d_nelmts && buf[i] == filval) \ + i++; \ + if (i < d_nelmts) \ + min = max = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (buf[i] == filval) \ + continue; /* ignore fill value */ \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find maximum and minimum values of a buffer with fill value undefined */ -#define H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min)\ -{ \ - min = max = buf[0]; \ - for(i = 0; i < d_nelmts; i++) { \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + { \ + min = max = buf[0]; \ + for (i = 0; i < d_nelmts; i++) { \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find maximum and minimum values of a buffer with fill value defined for floating-point type */ -#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ -{ \ - i = 0; while(i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) i++; \ - if(i < d_nelmts) min = max = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \ - continue; /* ignore fill value */ \ - if(buf[i] > max) max = buf[i]; \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ + { \ + i = 0; \ + while (i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + i++; \ + if (i < d_nelmts) \ + min = max = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + continue; /* ignore fill value */ \ + if (buf[i] > max) \ + max = buf[i]; \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find minimum value of a buffer with fill value defined for integer type */ -#define H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ -{ \ - i = 0; while(i < d_nelmts && buf[i]== filval) i++; \ - if(i < d_nelmts) min = buf[i]; \ - for(; i < d_nelmts; i++) { \ - if(buf[i] == filval) continue; /* ignore fill value */ \ - if(buf[i] < min) min = buf[i]; \ - } \ -} +#define H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ + { \ + i = 0; \ + while (i < d_nelmts && buf[i] == filval) \ + i++; \ + if (i < d_nelmts) \ + min = buf[i]; \ + for (; i < d_nelmts; i++) { \ + if (buf[i] == filval) \ + continue; /* ignore fill value */ \ + if (buf[i] < min) \ + min = buf[i]; \ + } \ + } /* Find minimum value of a buffer with fill value undefined */ -#define H5Z_scaleoffset_min_2(i, d_nelmts, buf, min)\ -{ \ - min = buf[0]; \ - for(i = 0; i < d_nelmts; i++) \ - if(buf[i] < min) min = buf[i]; \ -} +#define H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ + { \ + min = buf[0]; \ + for (i = 0; i < d_nelmts; i++) \ + if (buf[i] < min) \ + min = buf[i]; \ + } /* Check and handle special situation for unsigned integer type */ -#define H5Z_scaleoffset_check_1(type, max, min, minbits) \ -{ \ - if(max - min > (type)(~(type)0 - 2)) \ - { *minbits = sizeof(type)*8; return; } \ -} +#define H5Z_scaleoffset_check_1(type, max, min, minbits) \ + { \ + if (max - min > (type)(~(type)0 - 2)) { \ + *minbits = sizeof(type) * 8; \ + return; \ + } \ + } /* Check and handle special situation for signed integer type */ -#define H5Z_scaleoffset_check_2(type, max, min, minbits) \ -{ \ - if((unsigned type)(max - min) > (unsigned type)(~(unsigned type)0 - 2)) \ - { *minbits = sizeof(type)*8; return; } \ -} +#define H5Z_scaleoffset_check_2(type, max, min, minbits) \ + { \ + if ((unsigned type)(max - min) > (unsigned type)(~(unsigned type)0 - 2)) { \ + *minbits = sizeof(type) * 8; \ + return; \ + } \ + } /* Check and handle special situation for floating-point type */ -#define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(int) * 8 - 1))) { \ - *minbits = sizeof(int) * 8; \ - goto done; \ - } \ - } else if(sizeof(type) == sizeof(long)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(long) * 8 - 1))) { \ - *minbits = sizeof(long) * 8; \ - goto done; \ - } \ - } else if(sizeof(type) == sizeof(long long)) { \ - if(round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) \ - > pow_fun(2.0f, (type)(sizeof(long long) * 8 - 1))) { \ - *minbits = sizeof(long long) * 8; \ - goto done; \ - } \ - } else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(int) * 8 - 1))) { \ + *minbits = sizeof(int) * 8; \ + goto done; \ + } \ + } \ + else if (sizeof(type) == sizeof(long)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(long) * 8 - 1))) { \ + *minbits = sizeof(long) * 8; \ + goto done; \ + } \ + } \ + else if (sizeof(type) == sizeof(long long)) { \ + if (round_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) > \ + pow_fun(2.0f, (type)(sizeof(long long) * 8 - 1))) { \ + *minbits = sizeof(long long) * 8; \ + goto done; \ + } \ + } \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Precompress for unsigned integer type */ -#define H5Z_scaleoffset_precompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, min = 0, max = 0, span, filval = 0; \ - unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = (type)(max - min + 1); \ - *minbits = H5Z__scaleoffset_log2((unsigned long long)(span+1)); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ - } else { /* fill value undefined */ \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) \ - span = (type)(max - min + 1); \ - *minbits = H5Z__scaleoffset_log2((unsigned long long)span); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type)*8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] - min); \ - } \ - *minval = min; \ -} +#define H5Z_scaleoffset_precompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + do { \ + type * buf = (type *)data, min = 0, max = 0, span, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, \ + filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ + { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ + *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_1( \ + i, d_nelmts, buf, filval, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ + } \ + else { /* fill value undefined */ \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ + *minbits = H5Z__scaleoffset_log2((unsigned long long)span); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_2( \ + i, d_nelmts, buf, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] - min); \ + } \ + *minval = min; \ + } while (0) /* Precompress for signed integer type */ -#define H5Z_scaleoffset_precompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, min = 0, max = 0, filval = 0; \ - unsigned type span; unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ - H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = (unsigned type)(max - min + 1); \ - *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min)); \ - } else { /* fill value undefined */ \ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT ) { /* minbits not set yet, calculate max, min, and minbits */\ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_2(type, max, min, minbits) \ - span = (unsigned type)(max - min + 1); \ - *minbits = H5Z__scaleoffset_log2((unsigned long long)span); \ - } else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] - min); \ - } \ - *minval = (unsigned long long)min; \ -} +#define H5Z_scaleoffset_precompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + do { \ + type * buf = (type *)data, min = 0, max = 0, filval = 0; \ + unsigned type span; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, \ + filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ + { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ + H5Z_scaleoffset_check_2(type, max, min, minbits) span = (unsigned type)(max - min + 1); \ + *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_1( \ + i, d_nelmts, buf, filval, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)( \ + (buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) : (buf[i] - min)); \ + } \ + else { /* fill value undefined */ \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_2(type, max, min, minbits) span = (unsigned type)(max - min + 1); \ + *minbits = H5Z__scaleoffset_log2((unsigned long long)span); \ + } \ + else /* minbits already set, only calculate min */ \ + H5Z_scaleoffset_min_2( \ + i, d_nelmts, buf, \ + min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] - min); \ + } \ + *minval = (unsigned long long)min; \ + } while (0) /* Modify values of data in precompression if fill value defined for floating-point type */ -#define H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, minbits, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(int *)((void *)&buf[i]) = (int)(((unsigned int)1 << *minbits) - 1); \ - else \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(long *)((void *)&buf[i]) = (long)(((unsigned long)1 << *minbits) - 1); \ - else \ - *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) { \ - if(abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ - *(long long *)((void *)&buf[i]) = (long long)(((unsigned long long)1 << *minbits) - 1); \ - else \ - *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - } \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, \ + minbits, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(int *)((void *)&buf[i]) = (int)(((unsigned int)1 << *minbits) - 1); \ + else \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(long *)((void *)&buf[i]) = (long)(((unsigned long)1 << *minbits) - 1); \ + else \ + *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) { \ + if (abs_fun(buf[i] - filval) < pow_fun(10.0f, (type)-D_val)) \ + *(long long *)((void *)&buf[i]) = (long long)(((unsigned long long)1 << *minbits) - 1); \ + else \ + *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + } \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in precompression if fill value undefined for floating-point type */ -#define H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + *(long *)((void *)&buf[i]) = \ + lround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + *(long long *)((void *)&buf[i]) = \ + llround_fun(buf[i] * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Save the minimum value for floating-point type */ -#define H5Z_scaleoffset_save_min(i, type, minval, min) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - /* Save min value to corresponding position \ - * byte-order will be swapped as appropriate, but be sure to \ - * account for offset in BE if sizes differ \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) \ - H5MM_memcpy(minval, &min, sizeof(type)); \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), \ - &min, sizeof(type)); \ - } /* end else */ \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_save_min(i, type, minval, min) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + /* Save min value to corresponding position \ + * byte-order will be swapped as appropriate, but be sure to \ + * account for offset in BE if sizes differ \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) \ + H5MM_memcpy(minval, &min, sizeof(type)); \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), &min, sizeof(type)); \ + } /* end else */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Precompress for floating-point type using variable-minimum-bits method */ -#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, d_nelmts, filavail, cd_values, \ - minbits, minval, D_val) \ -{ \ - type *buf = (type *)data, min = 0, max = 0, filval = 0; \ - unsigned long long span; \ - unsigned i; \ - \ - *minval = 0; \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ - span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \ - *minbits = H5Z__scaleoffset_log2(span + 1); \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, filval, minbits, min, D_val) \ - } else { /* fill value undefined */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ - span = (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - min * pow_fun(10.0f, (type)D_val)) + 1); \ - *minbits = H5Z__scaleoffset_log2(span); \ - if(*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, D_val) \ - } \ - H5Z_scaleoffset_save_min(i, type, minval, min) \ -} +#define H5Z_scaleoffset_precompress_3(type, pow_fun, abs_fun, round_fun, lround_fun, llround_fun, data, \ + d_nelmts, filavail, cd_values, minbits, minval, D_val) \ + do { \ + type * buf = (type *)data, min = 0, max = 0, filval = 0; \ + unsigned long long span; \ + unsigned i; \ + \ + *minval = 0; \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ + (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)) + \ + 1); \ + *minbits = H5Z__scaleoffset_log2(span + 1); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, \ + filval, minbits, min, D_val) \ + } \ + else { /* fill value undefined */ \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ + (unsigned long long)(llround_fun(max * pow_fun(10.0f, (type)D_val) - \ + min * pow_fun(10.0f, (type)D_val)) + \ + 1); \ + *minbits = H5Z__scaleoffset_log2(span); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, \ + D_val) \ + } \ + H5Z_scaleoffset_save_min(i, type, minval, min) \ + } while (0) /* Postdecompress for unsigned integer type */ -#define H5Z_scaleoffset_postdecompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, filval = 0; unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ - } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] + (type)(minval)); \ -} +#define H5Z_scaleoffset_postdecompress_1(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + do { \ + type * buf = (type *)data, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ + } \ + else /* fill value undefined */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] + (type)(minval)); \ + } while (0) /* Postdecompress for signed integer type */ -#define H5Z_scaleoffset_postdecompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval)\ -{ \ - type *buf = (type *)data, filval = 0; \ - unsigned i; \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval : (buf[i] + minval));\ - } else /* fill value undefined */ \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)(buf[i] + (type)(minval)); \ -} +#define H5Z_scaleoffset_postdecompress_2(type, data, d_nelmts, filavail, cd_values, minbits, minval) \ + do { \ + type * buf = (type *)data, filval = 0; \ + unsigned i; \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ + (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval \ + : (buf[i] + minval)); \ + } \ + else /* fill value undefined */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] + (type)(minval)); \ + } while (0) /* Retrive minimum value of floating-point type */ -#define H5Z_scaleoffset_get_min(type, minval, min) \ -{ \ - if(sizeof(type) <= sizeof(long long)) \ - /* retrieve min value from corresponding position \ - * byte-order has already been swapped as appropriate, but be sure to \ - * account for offset in BE if sizes differ \ - */ \ - if(H5T_native_order_g == H5T_ORDER_LE) \ - H5MM_memcpy(&min, &minval, sizeof(type)); \ - else { \ - HDassert(H5T_native_order_g == H5T_ORDER_BE); \ - H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) \ - - sizeof(type)), sizeof(type)); \ - } /* end else */ \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_get_min(type, minval, min) \ + { \ + if (sizeof(type) <= sizeof(long long)) \ + /* retrieve min value from corresponding position \ + * byte-order has already been swapped as appropriate, but be sure to \ + * account for offset in BE if sizes differ \ + */ \ + if (H5T_native_order_g == H5T_ORDER_LE) \ + H5MM_memcpy(&min, &minval, sizeof(type)); \ + else { \ + HDassert(H5T_native_order_g == H5T_ORDER_BE); \ + H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) - sizeof(type)), sizeof(type)); \ + } /* end else */ \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in postdecompression if fill value defined for floating-point type */ -#define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ -{ \ - if(sizeof(type) == sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(int *)((void *)&buf[i]) == (int)(((unsigned int)1 << minbits) - 1)) ? \ - filval : (type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type) == sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(long *)((void *)&buf[i]) == (long)(((unsigned long)1 << minbits) - 1)) ? \ - filval : (type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type) == sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = (type)((*(long long *)((void *)&buf[i]) == (long long)(((unsigned long long)1 << minbits) - 1)) ? \ - filval : (type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = \ + (type)((*(int *)((void *)&buf[i]) == (int)(((unsigned int)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = \ + (type)((*(long *)((void *)&buf[i]) == (long)(((unsigned long)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)( \ + (*(long long *)((void *)&buf[i]) == (long long)(((unsigned long long)1 << minbits) - 1)) \ + ? filval \ + : (type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Modify values of data in postdecompression if fill value undefined for floating-point type */ -#define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ -{ \ - if(sizeof(type)==sizeof(int)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type)==sizeof(long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else if(sizeof(type)==sizeof(long long)) \ - for(i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ - else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ -} +#define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ + { \ + if (sizeof(type) == sizeof(int)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else if (sizeof(type) == sizeof(long long)) \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0f, (type)D_val) + min); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + } /* Postdecompress for floating-point type using variable-minimum-bits method */ -#define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, \ - minbits, minval, D_val) \ -{ \ - type *buf = (type *)data, filval = 0, min = 0; \ - unsigned i; \ - \ - H5Z_scaleoffset_get_min(type, minval, min) \ - \ - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ - } else /* fill value undefined */ \ - H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ -} - +#define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, minbits, \ + minval, D_val) \ + do { \ + type * buf = (type *)data, filval = 0, min = 0; \ + unsigned i; \ + \ + H5Z_scaleoffset_get_min(type, minval, min) \ + \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) \ + { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ + H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ + } \ + else /* fill value undefined */ \ + H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ + } while (0) /*------------------------------------------------------------------------- * Function: H5Z__can_apply_scaleoffset @@ -683,41 +753,41 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ static htri_t H5Z__can_apply_scaleoffset(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - H5T_class_t dtype_class; /* Datatype's class */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + H5T_class_t dtype_class; /* Datatype's class */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's class, for checking the "datatype class" */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if(H5T_get_size(type) == 0) + if (H5T_get_size(type) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") - if(dtype_class == H5T_INTEGER || dtype_class == H5T_FLOAT) { + if (dtype_class == H5T_INTEGER || dtype_class == H5T_FLOAT) { /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ - if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) + if (dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FALSE, "bad datatype endianness order") - } else + } + else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FALSE, "datatype class not supported by scaleoffset") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__can_apply_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Z__scaleoffset_get_type * @@ -735,40 +805,52 @@ H5Z__can_apply_scaleoffset(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5 static enum H5Z_scaleoffset_t H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { - enum H5Z_scaleoffset_t type = t_bad; /* integer type */ - enum H5Z_scaleoffset_t ret_value = t_bad; /* Return value */ + enum H5Z_scaleoffset_t type = t_bad; /* integer type */ + enum H5Z_scaleoffset_t ret_value = t_bad; /* Return value */ FUNC_ENTER_STATIC - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { - if(dtype_sign==H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ - if (dtype_size == sizeof(unsigned char)) type = t_uchar; - else if(dtype_size == sizeof(unsigned short)) type = t_ushort; - else if(dtype_size == sizeof(unsigned int)) type = t_uint; - else if(dtype_size == sizeof(unsigned long)) type = t_ulong; + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) { + if (dtype_sign == H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ + if (dtype_size == sizeof(unsigned char)) + type = t_uchar; + else if (dtype_size == sizeof(unsigned short)) + type = t_ushort; + else if (dtype_size == sizeof(unsigned int)) + type = t_uint; + else if (dtype_size == sizeof(unsigned long)) + type = t_ulong; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(dtype_size == sizeof(unsigned long long)) type = t_ulong_long; + else if (dtype_size == sizeof(unsigned long long)) + type = t_ulong_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } - if(dtype_sign==H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ - if (dtype_size == sizeof(signed char)) type = t_schar; - else if(dtype_size == sizeof(short)) type = t_short; - else if(dtype_size == sizeof(int)) type = t_int; - else if(dtype_size == sizeof(long)) type = t_long; + if (dtype_sign == H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ + if (dtype_size == sizeof(signed char)) + type = t_schar; + else if (dtype_size == sizeof(short)) + type = t_short; + else if (dtype_size == sizeof(int)) + type = t_int; + else if (dtype_size == sizeof(long)) + type = t_long; #if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG - else if(dtype_size == sizeof(long long)) type = t_long_long; + else if (dtype_size == sizeof(long long)) + type = t_long_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } } - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { - if(dtype_size == sizeof(float)) type = t_float; - else if(dtype_size == sizeof(double)) type = t_double; + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) { + if (dtype_size == sizeof(float)) + type = t_float; + else if (dtype_size == sizeof(double)) + type = t_double; else HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } @@ -780,7 +862,6 @@ H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dt FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__scaleoffset_set_parms_fillval * @@ -795,44 +876,42 @@ H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dt *------------------------------------------------------------------------- */ static herr_t -H5Z__scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, - H5T_t *type, enum H5Z_scaleoffset_t scale_type, - unsigned cd_values[], int need_convert) +H5Z__scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, H5T_t *type, enum H5Z_scaleoffset_t scale_type, + unsigned cd_values[], int need_convert) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(scale_type == t_uchar) - H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ushort) - H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_uint) - H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ulong) - H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_ulong_long) - H5Z_scaleoffset_set_filval_1(unsigned long long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_schar) - H5Z_scaleoffset_set_filval_3(signed char, dcpl_plist, type, cd_values, need_convertd) - else if(scale_type == t_short) - H5Z_scaleoffset_set_filval_2(short, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_int) - H5Z_scaleoffset_set_filval_2(int, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_long) - H5Z_scaleoffset_set_filval_2(long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_long_long) - H5Z_scaleoffset_set_filval_2(long long, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_float) - H5Z_scaleoffset_set_filval_4(float, dcpl_plist, type, cd_values, need_convert) - else if(scale_type == t_double) - H5Z_scaleoffset_set_filval_4(double, dcpl_plist, type, cd_values, need_convert) + if (scale_type == t_uchar) + H5Z_scaleoffset_set_filval_3(unsigned char, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_ushort) + H5Z_scaleoffset_set_filval_1(unsigned short, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_uint) + H5Z_scaleoffset_set_filval_1(unsigned int, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_ulong) + H5Z_scaleoffset_set_filval_1(unsigned long, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_ulong_long) + H5Z_scaleoffset_set_filval_1(unsigned long long, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_schar) + H5Z_scaleoffset_set_filval_3(signed char, dcpl_plist, type, cd_values, need_convertd); + else if (scale_type == t_short) + H5Z_scaleoffset_set_filval_2(short, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_int) + H5Z_scaleoffset_set_filval_2(int, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_long) + H5Z_scaleoffset_set_filval_2(long, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_long_long) + H5Z_scaleoffset_set_filval_2(long long, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_float) + H5Z_scaleoffset_set_filval_4(float, dcpl_plist, type, cd_values, need_convert); + else if (scale_type == t_double) + H5Z_scaleoffset_set_filval_4(double, dcpl_plist, type, cd_values, need_convert); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__scaleoffset_set_parms_fillval() */ - /*------------------------------------------------------------------------- * Function: H5Z__set_local_scaleoffset * @@ -850,55 +929,56 @@ H5Z__scaleoffset_set_parms_fillval(H5P_genplist_t *dcpl_plist, static herr_t H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SCALEOFFSET_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SCALEOFFSET_TOTAL_NPARMS]; /* Filter parameters */ - hssize_t npoints; /* Number of points in the dataspace */ - H5T_class_t dtype_class; /* Datatype's class */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - size_t dtype_size; /* Datatype's size (in bytes) */ - H5T_sign_t dtype_sign; /* Datatype's sign */ - enum H5Z_scaleoffset_t scale_type; /* Specific datatype */ - H5D_fill_value_t status; /* Status of fill value in property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t * dcpl_plist; /* Property list pointer */ + H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SCALEOFFSET_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SCALEOFFSET_TOTAL_NPARMS]; /* Filter parameters */ + hssize_t npoints; /* Number of points in the dataspace */ + H5T_class_t dtype_class; /* Datatype's class */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + size_t dtype_size; /* Datatype's size (in bytes) */ + H5T_sign_t dtype_sign; /* Datatype's sign */ + enum H5Z_scaleoffset_t scale_type; /* Specific datatype */ + H5D_fill_value_t status; /* Status of fill value in property list */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize the parameters to a known state */ HDmemset(cd_values, 0, sizeof(cd_values)); /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, + NULL, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get scaleoffset parameters") /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get total number of elements in the chunk */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") /* Set "local" parameter for this dataset's number of elements */ H5_CHECKED_ASSIGN(cd_values[H5Z_SCALEOFFSET_PARM_NELMTS], unsigned, npoints, hssize_t); /* Get datatype's class */ - if((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) + if ((dtype_class = H5T_get_class(type, TRUE)) == H5T_NO_CLASS) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Set "local" parameter for datatype's class */ - switch(dtype_class) { + switch (dtype_class) { case H5T_INTEGER: cd_values[H5Z_SCALEOFFSET_PARM_CLASS] = H5Z_SCALEOFFSET_CLS_INTEGER; break; @@ -923,20 +1003,20 @@ H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Get datatype's size */ - if((dtype_size = H5T_get_size(type)) == 0) + if ((dtype_size = H5T_get_size(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Set "local" parameter for datatype size */ H5_CHECK_OVERFLOW(dtype_size, size_t, unsigned); cd_values[H5Z_SCALEOFFSET_PARM_SIZE] = (unsigned)dtype_size; - if(dtype_class == H5T_INTEGER) { + if (dtype_class == H5T_INTEGER) { /* Get datatype's sign */ - if((dtype_sign = H5T_get_sign(type)) == H5T_SGN_ERROR) + if ((dtype_sign = H5T_get_sign(type)) == H5T_SGN_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype sign") /* Set "local" parameter for integer datatype sign */ - switch(dtype_sign) { + switch (dtype_sign) { case H5T_SGN_NONE: cd_values[H5Z_SCALEOFFSET_PARM_SIGN] = H5Z_SCALEOFFSET_SGN_NONE; break; @@ -950,19 +1030,19 @@ H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad integer sign") } /* end switch */ - } /* end if */ + } /* end if */ /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set "local" parameter for datatype endianness */ - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[H5Z_SCALEOFFSET_PARM_ORDER] = H5Z_SCALEOFFSET_ORDER_LE; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[H5Z_SCALEOFFSET_PARM_ORDER] = H5Z_SCALEOFFSET_ORDER_BE; break; @@ -975,40 +1055,41 @@ H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Check whether fill value is defined for dataset */ - if(H5P_fill_value_defined(dcpl_plist, &status) < 0) + if (H5P_fill_value_defined(dcpl_plist, &status) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") /* Set local parameter for availability of fill value */ - if(status == H5D_FILL_VALUE_UNDEFINED) + if (status == H5D_FILL_VALUE_UNDEFINED) cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_UNDEFINED; else { - int need_convert = FALSE; /* Flag indicating conversion of byte order */ + int need_convert = FALSE; /* Flag indicating conversion of byte order */ cd_values[H5Z_SCALEOFFSET_PARM_FILAVAIL] = H5Z_SCALEOFFSET_FILL_DEFINED; /* Check if memory byte order matches dataset datatype byte order */ - if(H5T_native_order_g != dtype_order) + if (H5T_native_order_g != dtype_order) need_convert = TRUE; /* Before getting fill value, get its type */ - if((scale_type = H5Z__scaleoffset_get_type(cd_values[H5Z_SCALEOFFSET_PARM_CLASS], - cd_values[H5Z_SCALEOFFSET_PARM_SIZE], cd_values[H5Z_SCALEOFFSET_PARM_SIGN])) == 0) + if ((scale_type = H5Z__scaleoffset_get_type(cd_values[H5Z_SCALEOFFSET_PARM_CLASS], + cd_values[H5Z_SCALEOFFSET_PARM_SIZE], + cd_values[H5Z_SCALEOFFSET_PARM_SIGN])) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot use C integer datatype for cast") /* Get dataset fill value and store in cd_values[] */ - if(H5Z__scaleoffset_set_parms_fillval(dcpl_plist, type, scale_type, cd_values, need_convert) < 0) + if (H5Z__scaleoffset_set_parms_fillval(dcpl_plist, type, scale_type, cd_values, need_convert) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "unable to set fill value") } /* end else */ /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SCALEOFFSET, flags, (size_t)H5Z_SCALEOFFSET_TOTAL_NPARMS, cd_values) < 0) + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SCALEOFFSET, flags, (size_t)H5Z_SCALEOFFSET_TOTAL_NPARMS, + cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local scaleoffset parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_local_scaleoffset() */ - /*------------------------------------------------------------------------- * Function: H5Z__filter_scaleoffset * @@ -1024,42 +1105,42 @@ H5Z__set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) *------------------------------------------------------------------------- */ static size_t -H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - size_t ret_value = 0; /* return value */ - size_t size_out = 0; /* size of output buffer */ - unsigned d_nelmts = 0; /* number of data elements in the chunk */ - unsigned dtype_class; /* datatype class */ - unsigned dtype_sign; /* integer datatype sign */ - unsigned filavail; /* flag indicating if fill value is defined or not */ - H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE;/* scale type */ - int scale_factor = 0; /* scale factor */ - double D_val = 0.0f; /* decimal scale factor */ - uint32_t minbits = 0; /* minimum number of bits to store values */ - unsigned long long minval= 0; /* minimum value of input buffer */ - enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ - int need_convert = FALSE; /* flag indicating conversion of byte order */ - unsigned char *outbuf = NULL; /* pointer to new output buffer */ - unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ - unsigned i; /* index */ - parms_atomic p; /* parameters needed for compress/decompress functions */ + size_t ret_value = 0; /* return value */ + size_t size_out = 0; /* size of output buffer */ + unsigned d_nelmts = 0; /* number of data elements in the chunk */ + unsigned dtype_class; /* datatype class */ + unsigned dtype_sign; /* integer datatype sign */ + unsigned filavail; /* flag indicating if fill value is defined or not */ + H5Z_SO_scale_type_t scale_type = H5Z_SO_FLOAT_DSCALE; /* scale type */ + int scale_factor = 0; /* scale factor */ + double D_val = 0.0; /* decimal scale factor */ + uint32_t minbits = 0; /* minimum number of bits to store values */ + unsigned long long minval = 0; /* minimum value of input buffer */ + enum H5Z_scaleoffset_t type; /* memory type corresponding to dataset datatype */ + int need_convert = FALSE; /* flag indicating conversion of byte order */ + unsigned char * outbuf = NULL; /* pointer to new output buffer */ + unsigned buf_offset = 21; /* buffer offset because of parameters stored in file */ + unsigned i; /* index */ + parms_atomic p; /* parameters needed for compress/decompress functions */ FUNC_ENTER_STATIC /* check arguments */ - if(cd_nelmts != H5Z_SCALEOFFSET_TOTAL_NPARMS) + if (cd_nelmts != H5Z_SCALEOFFSET_TOTAL_NPARMS) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scaleoffset number of parameters") /* Check if memory byte order matches dataset datatype byte order */ - switch(H5T_native_order_g) { - case H5T_ORDER_LE: /* memory is little-endian byte order */ - if(cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_BE) + switch (H5T_native_order_g) { + case H5T_ORDER_LE: /* memory is little-endian byte order */ + if (cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_BE) need_convert = TRUE; break; - case H5T_ORDER_BE: /* memory is big-endian byte order */ - if(cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_LE) + case H5T_ORDER_BE: /* memory is big-endian byte order */ + if (cd_values[H5Z_SCALEOFFSET_PARM_ORDER] == H5Z_SCALEOFFSET_ORDER_LE) need_convert = TRUE; break; @@ -1087,33 +1168,35 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * scale factor is the fixed minimum number of bits * H5Z_SO_INT : integer type, scale_factor is minimum number of bits */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) { /* floating-point type */ - if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE) + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) { /* floating-point type */ + if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") } - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { /* integer type */ - if(scale_type!=H5Z_SO_INT) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) { /* integer type */ + if (scale_type != H5Z_SO_INT) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid scale type") /* if scale_factor is less than 0 for integer, library will reset it to 0 * in this case, library will calculate the minimum-bits */ - if(scale_factor < 0) scale_factor = 0; + if (scale_factor < 0) + scale_factor = 0; } /* fixed-minimum-bits method is not implemented and is forbidden */ - if(scale_type==H5Z_SO_FLOAT_ESCALE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "E-scaling method not supported") + if (scale_type == H5Z_SO_FLOAT_ESCALE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "E-scaling method not supported") - if(scale_type==H5Z_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ + if (scale_type == H5Z_SO_FLOAT_DSCALE) { /* floating-point type, variable-minimum-bits */ D_val = (double)scale_factor; - } else { /* integer type, or floating-point type with fixed-minimum-bits method */ - if(scale_factor > (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) + } + else { /* integer type, or floating-point type with fixed-minimum-bits method */ + if (scale_factor > (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "minimum number of bits exceeds maximum") /* no need to process data */ - if(scale_factor == (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) { + if (scale_factor == (int)(cd_values[H5Z_SCALEOFFSET_PARM_SIZE] * 8)) { ret_value = *buf_size; goto done; } @@ -1121,7 +1204,7 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu } /* prepare parameters to pass to compress/decompress functions */ - p.size = cd_values[H5Z_SCALEOFFSET_PARM_SIZE]; + p.size = cd_values[H5Z_SCALEOFFSET_PARM_SIZE]; p.mem_order = H5T_native_order_g; /* input; decompress */ @@ -1129,14 +1212,14 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu /* retrieve values of minbits and minval from input compressed buffer * retrieve them corresponding to how they are stored during compression */ - uint32_t minbits_mask = 0; - unsigned long long minval_mask = 0; - unsigned minval_size = 0; + uint32_t minbits_mask = 0; + unsigned long long minval_mask = 0; + unsigned minval_size = 0; minbits = 0; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { minbits_mask = ((unsigned char *)*buf)[i]; - minbits_mask <<= i*8; + minbits_mask <<= i * 8; minbits |= minbits_mask; } @@ -1144,12 +1227,12 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * unsigned long long (datatype of minval) may change from compression * to decompression, only smaller size is used */ - minval_size = sizeof(unsigned long long) <= ((unsigned char *)*buf)[4] ? - sizeof(unsigned long long) : ((unsigned char *)*buf)[4]; + minval_size = sizeof(unsigned long long) <= ((unsigned char *)*buf)[4] ? sizeof(unsigned long long) + : ((unsigned char *)*buf)[4]; minval = 0; - for(i = 0; i < minval_size; i++) { - minval_mask = ((unsigned char *)*buf)[5+i]; - minval_mask <<= i*8; + for (i = 0; i < minval_size; i++) { + minval_mask = ((unsigned char *)*buf)[5 + i]; + minval_mask <<= i * 8; minval |= minval_mask; } @@ -1160,52 +1243,53 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu size_out = d_nelmts * p.size; /* allocate memory space for decompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset decompression") + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, + "memory allocation failed for scaleoffset decompression") /* special case: minbits equal to full precision */ - if(minbits == p.size * 8) { - H5MM_memcpy(outbuf, (unsigned char*)(*buf)+buf_offset, size_out); + if (minbits == p.size * 8) { + H5MM_memcpy(outbuf, (unsigned char *)(*buf) + buf_offset, size_out); /* free the original buffer */ H5MM_xfree(*buf); /* convert to dataset datatype endianness order if needed */ - if(need_convert) + if (need_convert) H5Z__scaleoffset_convert(outbuf, d_nelmts, p.size); - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = size_out; goto done; } /* decompress the buffer if minbits not equal to zero */ - if(minbits != 0) - H5Z__scaleoffset_decompress(outbuf, d_nelmts, (unsigned char*)(*buf)+buf_offset, p); + if (minbits != 0) + H5Z__scaleoffset_decompress(outbuf, d_nelmts, (unsigned char *)(*buf) + buf_offset, p); else { /* fill value is not defined and all data elements have the same value */ - for(i = 0; i < size_out; i++) outbuf[i] = 0; + for (i = 0; i < size_out; i++) + outbuf[i] = 0; } /* before postprocess, get memory type */ - if((type = H5Z__scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) + if ((type = H5Z__scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast") /* postprocess after decompression */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z__scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, - cd_values, minbits, minval); - - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ - if(H5Z__scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, - cd_values, minbits, minval, D_val)==FAIL) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) + H5Z__scaleoffset_postdecompress_i(outbuf, d_nelmts, type, filavail, cd_values, minbits, minval); + + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) + if (scale_type == 0) { /* variable-minimum-bits method */ + if (H5Z__scaleoffset_postdecompress_fd(outbuf, d_nelmts, type, filavail, cd_values, minbits, + minval, D_val) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "post-decompression failed") } /* after postprocess, convert to dataset datatype endianness order if needed */ - if(need_convert) + if (need_convert) H5Z__scaleoffset_convert(outbuf, d_nelmts, p.size); } /* output; compress */ @@ -1213,22 +1297,21 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu HDassert(nbytes == d_nelmts * p.size); /* before preprocess, convert to memory endianness order if needed */ - if(need_convert) + if (need_convert) H5Z__scaleoffset_convert(*buf, d_nelmts, p.size); /* before preprocess, get memory type */ - if((type = H5Z__scaleoffset_get_type(dtype_class, p.size, dtype_sign))==0) + if ((type = H5Z__scaleoffset_get_type(dtype_class, p.size, dtype_sign)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot use C integer datatype for cast") /* preprocess before compression */ - if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) - H5Z__scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, - cd_values, &minbits, &minval); - - if(dtype_class==H5Z_SCALEOFFSET_CLS_FLOAT) - if(scale_type==0) { /* variable-minimum-bits method */ - if(H5Z__scaleoffset_precompress_fd(*buf, d_nelmts, type, filavail, - cd_values, &minbits, &minval, D_val)==FAIL) + if (dtype_class == H5Z_SCALEOFFSET_CLS_INTEGER) + H5Z__scaleoffset_precompress_i(*buf, d_nelmts, type, filavail, cd_values, &minbits, &minval); + + if (dtype_class == H5Z_SCALEOFFSET_CLS_FLOAT) + if (scale_type == 0) { /* variable-minimum-bits method */ + if (H5Z__scaleoffset_precompress_fd(*buf, d_nelmts, type, filavail, cd_values, &minbits, + &minval, D_val) == FAIL) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "pre-compression failed") } @@ -1238,10 +1321,10 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * minbits and minval are stored in the front of the compressed buffer */ p.minbits = minbits; - size_out = buf_offset + nbytes * p.minbits / (p.size * 8) + 1; /* may be 1 larger */ + size_out = buf_offset + nbytes * p.minbits / (p.size * 8) + 1; /* may be 1 larger */ /* allocate memory space for compressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(size_out))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for scaleoffset compression") /* store minbits and minval in the front of output compressed buffer @@ -1249,13 +1332,14 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * constant buffer size (21 bytes) is left for these two parameters * 4 bytes for minbits, 1 byte for size of minval, 16 bytes for minval */ - for(i = 0; i < 4; i++) - ((unsigned char *)outbuf)[i] = (unsigned char)((minbits & ((uint32_t)0xff << i*8)) >> i*8); + for (i = 0; i < 4; i++) + ((unsigned char *)outbuf)[i] = (unsigned char)((minbits & ((uint32_t)0xff << i * 8)) >> i * 8); ((unsigned char *)outbuf)[4] = sizeof(unsigned long long); - for(i = 0; i < sizeof(unsigned long long); i++) - ((unsigned char *)outbuf)[5+i] = (unsigned char)((minval & ((unsigned long long)0xff << i*8)) >> i*8); + for (i = 0; i < sizeof(unsigned long long); i++) + ((unsigned char *)outbuf)[5 + i] = + (unsigned char)((minval & ((unsigned long long)0xff << i * 8)) >> i * 8); /* Zero out remaining, unused bytes */ /* (Looks like an error in the original determination of how many @@ -1264,13 +1348,13 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu HDmemset(outbuf + 13, 0, (size_t)8); /* special case: minbits equal to full precision */ - if(minbits == p.size * 8) { + if (minbits == p.size * 8) { H5MM_memcpy(outbuf + buf_offset, *buf, nbytes); /* free the original buffer */ H5MM_xfree(*buf); - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = buf_offset + nbytes; goto done; @@ -1280,21 +1364,22 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * minbits equal to zero only when fill value is not defined and * all data elements have the same value */ - if(minbits != 0) - H5Z__scaleoffset_compress((unsigned char *)*buf, d_nelmts, outbuf + buf_offset, size_out - buf_offset, p); + if (minbits != 0) + H5Z__scaleoffset_compress((unsigned char *)*buf, d_nelmts, outbuf + buf_offset, + size_out - buf_offset, p); } /* free the input buffer */ H5MM_xfree(*buf); /* set return values */ - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = size_out; ret_value = size_out; done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } @@ -1307,26 +1392,25 @@ H5Z__filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_valu * atomic datatype is treated on byte basis */ - /* change byte order of input buffer either from little-endian to big-endian * or from big-endian to little-endian 2/21/2005 */ static void H5Z__scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size) { - if(dtype_size > 1) { - size_t i, j; - unsigned char *buffer, temp; - - buffer = (unsigned char *)buf; - for(i = 0; i < d_nelmts * dtype_size; i += dtype_size) - for(j = 0; j < dtype_size / 2; j++) { - /* swap pair of bytes */ - temp = buffer[i + j]; - buffer[i + j] = buffer[i + dtype_size - 1 - j]; - buffer[i + dtype_size - 1 - j] = temp; - } /* end for */ - } /* end if */ + if (dtype_size > 1) { + size_t i, j; + unsigned char *buffer, temp; + + buffer = (unsigned char *)buf; + for (i = 0; i < d_nelmts * dtype_size; i += dtype_size) + for (j = 0; j < dtype_size / 2; j++) { + /* swap pair of bytes */ + temp = buffer[i + j]; + buffer[i + j] = buffer[i + dtype_size - 1 - j]; + buffer[i + dtype_size - 1 - j] = temp; + } /* end for */ + } /* end if */ } /* end H5Z__scaleoffset_convert() */ /* return ceiling of floating-point log2 function @@ -1335,158 +1419,158 @@ H5Z__scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size) static unsigned H5Z__scaleoffset_log2(unsigned long long num) { - unsigned v = 0; - unsigned long long lower_bound = 1; /* is power of 2, largest value <= num */ - unsigned long long val = num; - - while(val >>= 1) { - v++; - lower_bound <<= 1; - } - - if(num == lower_bound) - return v; - else - return v + 1; + unsigned v = 0; + unsigned long long lower_bound = 1; /* is power of 2, largest value <= num */ + unsigned long long val = num; + + while (val >>= 1) { + v++; + lower_bound <<= 1; + } + + if (num == lower_bound) + return v; + else + return v + 1; } /* precompress for integer type */ static void -H5Z__scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval) +H5Z__scaleoffset_precompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, unsigned filavail, + const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval) { - if(type == t_uchar) - H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_schar) { - signed char *buf = (signed char *)data, min = 0, max = 0, filval = 0; + if (type == t_uchar) + H5Z_scaleoffset_precompress_1(unsigned char, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ushort) + H5Z_scaleoffset_precompress_1(unsigned short, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_uint) + H5Z_scaleoffset_precompress_1(unsigned int, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ulong) + H5Z_scaleoffset_precompress_1(unsigned long, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ulong_long) + H5Z_scaleoffset_precompress_1(unsigned long long, data, d_nelmts, filavail, cd_values, minbits, + minval); + else if (type == t_schar) { + signed char * buf = (signed char *)data, min = 0, max = 0, filval = 0; unsigned char span; - unsigned i; + unsigned i; - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval); - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { - *minbits = sizeof(signed char)*8; + if (*minbits == + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, + min) if ((unsigned char)(max - min) > + (unsigned char)(~(unsigned char)0 - 2)) + { + *minbits = sizeof(signed char) * 8; return; } - span = (unsigned char)(max - min + 1); - *minbits = H5Z__scaleoffset_log2((unsigned long long)(span+1)); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min) - if(*minbits != sizeof(signed char)*8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)((buf[i] == filval) ? (((unsigned char)1 << *minbits) - 1) : (buf[i] - min)); - } else { /* fill value undefined */ - if(*minbits == H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) - if((unsigned char)(max - min) > (unsigned char)(~(unsigned char)0 - 2)) { - *minbits = sizeof(signed char)*8; - *minval = (unsigned long long)min; + span = (unsigned char)(max - min + 1); + *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); + } + else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, + min) if (*minbits != + sizeof(signed char) * + 8) /* change values if minbits != full precision */ + for (i = 0; i < d_nelmts; i++) buf[i] = + (signed char)((buf[i] == filval) ? (((unsigned char)1 << *minbits) - 1) + : (buf[i] - min)); + } + else { /* fill value undefined */ + if (*minbits == + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, + min) if ((unsigned char)(max - min) > + (unsigned char)(~(unsigned char)0 - 2)) + { + *minbits = sizeof(signed char) * 8; + *minval = (unsigned long long)min; return; } - span = (unsigned char)(max - min + 1); + span = (unsigned char)(max - min + 1); *minbits = H5Z__scaleoffset_log2((unsigned long long)span); - } else /* minbits already set, only calculate min */ - H5Z_scaleoffset_min_2(i, d_nelmts, buf, min) - if(*minbits != sizeof(signed char) * 8) /* change values if minbits != full precision */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)(buf[i] - min); + } + else /* minbits already set, only calculate min */ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, + min) if (*minbits != + sizeof(signed char) * + 8) /* change values if minbits != full precision */ + for (i = 0; i < d_nelmts; i++) buf[i] = (signed char)(buf[i] - min); } *minval = (unsigned long long)min; } - else if(type == t_short) - H5Z_scaleoffset_precompress_2(short, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_int) - H5Z_scaleoffset_precompress_2(int, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_long) - H5Z_scaleoffset_precompress_2(long, data, d_nelmts, - filavail, cd_values, minbits, minval) - else if(type == t_long_long) - H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, - filavail, cd_values, minbits, minval) + else if (type == t_short) + H5Z_scaleoffset_precompress_2(short, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_int) + H5Z_scaleoffset_precompress_2(int, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_long) + H5Z_scaleoffset_precompress_2(long, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_long_long) + H5Z_scaleoffset_precompress_2(long long, data, d_nelmts, filavail, cd_values, minbits, minval); } /* postdecompress for integer type */ static void H5Z__scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t minbits, unsigned long long minval) + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval) { - long long sminval = *(long long*)&minval; /* for signed integer types */ - - if(type == t_uchar) - H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ushort) - H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_uint) - H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ulong) - H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_ulong_long) - H5Z_scaleoffset_postdecompress_1(unsigned long long, data, d_nelmts, filavail, - cd_values, minbits, minval) - else if(type == t_schar) { - signed char *buf = (signed char *)data, filval = 0; - unsigned i; - - if(filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval) - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval : (buf[i] + sminval)); - } else /* fill value undefined */ - for(i = 0; i < d_nelmts; i++) - buf[i] = (signed char)(buf[i] + sminval); - } - else if(type == t_short) - H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_int) - H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_long) - H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, - cd_values, minbits, sminval) - else if(type == t_long_long) - H5Z_scaleoffset_postdecompress_2(long long, data, d_nelmts, filavail, - cd_values, minbits, sminval) + long long sminval = *(long long *)&minval; /* for signed integer types */ + + if (type == t_uchar) + H5Z_scaleoffset_postdecompress_1(unsigned char, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ushort) + H5Z_scaleoffset_postdecompress_1(unsigned short, data, d_nelmts, filavail, cd_values, minbits, + minval); + else if (type == t_uint) + H5Z_scaleoffset_postdecompress_1(unsigned int, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ulong) + H5Z_scaleoffset_postdecompress_1(unsigned long, data, d_nelmts, filavail, cd_values, minbits, minval); + else if (type == t_ulong_long) + H5Z_scaleoffset_postdecompress_1(unsigned long long, data, d_nelmts, filavail, cd_values, minbits, + minval); + else if (type == t_schar) { + signed char *buf = (signed char *)data, filval = 0; + unsigned i; + + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ + H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval) for (i = 0; i < d_nelmts; + i++) buf[i] = + (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval : (buf[i] + sminval)); + } + else /* fill value undefined */ + for (i = 0; i < d_nelmts; i++) + buf[i] = (signed char)(buf[i] + sminval); + } + else if (type == t_short) + H5Z_scaleoffset_postdecompress_2(short, data, d_nelmts, filavail, cd_values, minbits, sminval); + else if (type == t_int) + H5Z_scaleoffset_postdecompress_2(int, data, d_nelmts, filavail, cd_values, minbits, sminval); + else if (type == t_long) + H5Z_scaleoffset_postdecompress_2(long, data, d_nelmts, filavail, cd_values, minbits, sminval); + else if (type == t_long_long) + H5Z_scaleoffset_postdecompress_2(long long, data, d_nelmts, filavail, cd_values, minbits, sminval); } /* precompress for floating-point type, variable-minimum-bits method success: non-negative, failure: negative 4/15/05 */ static herr_t -H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t *minbits, - unsigned long long *minval, double D_val) +H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, unsigned filavail, + const unsigned cd_values[], uint32_t *minbits, unsigned long long *minval, + double D_val) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - if(type == t_float) + if (type == t_float) H5Z_scaleoffset_precompress_3(float, HDpowf, HDfabsf, HDroundf, HDlroundf, HDllroundf, data, d_nelmts, - filavail, cd_values, minbits, minval, D_val) - else if(type == t_double) + filavail, cd_values, minbits, minval, D_val); + else if (type == t_double) H5Z_scaleoffset_precompress_3(double, HDpow, HDfabs, HDround, HDlround, HDllround, data, d_nelmts, - filavail, cd_values, minbits, minval, D_val) + filavail, cd_values, minbits, minval, D_val); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1496,196 +1580,199 @@ H5Z__scaleoffset_precompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoff success: non-negative, failure: negative 4/15/05 */ static herr_t H5Z__scaleoffset_postdecompress_fd(void *data, unsigned d_nelmts, enum H5Z_scaleoffset_t type, - unsigned filavail, const unsigned cd_values[], uint32_t minbits, - unsigned long long minval, double D_val) + unsigned filavail, const unsigned cd_values[], uint32_t minbits, + unsigned long long minval, double D_val) { - long long sminval = (long long)minval; /* for signed integer types */ - herr_t ret_value=SUCCEED; /* Return value */ + long long sminval = (long long)minval; /* for signed integer types */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC - if(type == t_float) - H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail, - cd_values, minbits, sminval, D_val) - else if(type == t_double) - H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail, - cd_values, minbits, sminval, D_val) + if (type == t_float) + H5Z_scaleoffset_postdecompress_3(float, HDpowf, data, d_nelmts, filavail, cd_values, minbits, sminval, + D_val); + else if (type == t_double) + H5Z_scaleoffset_postdecompress_3(double, HDpow, data, d_nelmts, filavail, cd_values, minbits, sminval, + D_val); done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } static void H5Z__scaleoffset_next_byte(size_t *j, unsigned *buf_len) { - ++(*j); - *buf_len = 8 * sizeof(unsigned char); + ++(*j); + *buf_len = 8 * sizeof(unsigned char); } static void -H5Z__scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len) +H5Z__scaleoffset_decompress_one_byte(unsigned char *data, size_t data_offset, unsigned k, unsigned begin_i, + const unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len) { - unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = buffer[*j]; - if(k == begin_i) - dat_len = 8 - (dtype_len - p.minbits) % 8; - else - dat_len = 8; - - if(*buf_len > dat_len) { - data[data_offset + k] = (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)~0 << dat_len))); - *buf_len -= dat_len; - } /* end if */ - else { - data[data_offset + k] = (unsigned char)((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)); - dat_len -= *buf_len; - H5Z__scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) - return; - - val = buffer[*j]; - data[data_offset + k] |= (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & ~((unsigned)(~0) << dat_len)); - *buf_len -= dat_len; - } /* end else */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = buffer[*j]; + if (k == begin_i) + dat_len = 8 - (dtype_len - p.minbits) % 8; + else + dat_len = 8; + + if (*buf_len > dat_len) { + data[data_offset + k] = + (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & (unsigned)(~((unsigned)~0 << dat_len))); + *buf_len -= dat_len; + } /* end if */ + else { + data[data_offset + k] = + (unsigned char)((val & ~((unsigned)(~0) << *buf_len)) << (dat_len - *buf_len)); + dat_len -= *buf_len; + H5Z__scaleoffset_next_byte(j, buf_len); + if (dat_len == 0) + return; + + val = buffer[*j]; + data[data_offset + k] |= + (unsigned char)((unsigned)(val >> (*buf_len - dat_len)) & ~((unsigned)(~0) << dat_len)); + *buf_len -= dat_len; + } /* end else */ } static void -H5Z__scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) +H5Z__scaleoffset_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, unsigned *buf_len, parms_atomic p) { - /* begin_i: the index of byte having first significant bit */ - unsigned begin_i; - unsigned dtype_len; - int k; + /* begin_i: the index of byte having first significant bit */ + unsigned begin_i; + unsigned dtype_len; + int k; - HDassert(p.minbits > 0); + HDassert(p.minbits > 0); - dtype_len = p.size * 8; + dtype_len = p.size * 8; - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ - begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; + if (p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ + begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - for(k = (int)begin_i; k >= 0; k--) - H5Z__scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } - else { /* big endian */ - HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); + for (k = (int)begin_i; k >= 0; k--) + H5Z__scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, + p, dtype_len); + } + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); - begin_i = (dtype_len - p.minbits) / 8; + begin_i = (dtype_len - p.minbits) / 8; - for(k = (int)begin_i; k <= (int)(p.size - 1); k++) - H5Z__scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } + for (k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z__scaleoffset_decompress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, + p, dtype_len); + } } static void -H5Z__scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, parms_atomic p) +H5Z__scaleoffset_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, parms_atomic p) { /* i: index of data, j: index of buffer, buf_len: number of bits to be filled in current byte */ - size_t i, j; + size_t i, j; unsigned buf_len; /* must initialize to zeros */ - for(i = 0; i < d_nelmts * p.size; i++) + for (i = 0; i < d_nelmts * p.size; i++) data[i] = 0; /* initialization before the loop */ - j = 0; + j = 0; buf_len = sizeof(unsigned char) * 8; /* decompress */ - for(i = 0; i < d_nelmts; i++) + for (i = 0; i < d_nelmts; i++) H5Z__scaleoffset_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); } static void -H5Z__scaleoffset_compress_one_byte(unsigned char *data, size_t data_offset, - unsigned k, unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, - parms_atomic p, unsigned dtype_len) +H5Z__scaleoffset_compress_one_byte(const unsigned char *data, size_t data_offset, unsigned k, + unsigned begin_i, unsigned char *buffer, size_t *j, unsigned *buf_len, + parms_atomic p, unsigned dtype_len) { - unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ - unsigned char val; /* value to be copied in each data byte */ - - /* initialize value and bits of unsigned char to be copied */ - val = data[data_offset + k]; - if(k == begin_i) - dat_len = 8 - (dtype_len - p.minbits) % 8; - else - dat_len = 8; - - if(*buf_len > dat_len) { - buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } else { - buffer[*j] |= (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); - dat_len -= *buf_len; - H5Z__scaleoffset_next_byte(j, buf_len); - if(dat_len == 0) - return; - - buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); - *buf_len -= dat_len; - } /* end else */ + unsigned dat_len; /* dat_len is the number of bits to be copied in each data byte */ + unsigned char val; /* value to be copied in each data byte */ + + /* initialize value and bits of unsigned char to be copied */ + val = data[data_offset + k]; + if (k == begin_i) + dat_len = 8 - (dtype_len - p.minbits) % 8; + else + dat_len = 8; + + if (*buf_len > dat_len) { + buffer[*j] |= (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } + else { + buffer[*j] |= + (unsigned char)((unsigned)(val >> (dat_len - *buf_len)) & ~((unsigned)(~0) << *buf_len)); + dat_len -= *buf_len; + H5Z__scaleoffset_next_byte(j, buf_len); + if (dat_len == 0) + return; + + buffer[*j] = (unsigned char)((val & ~((unsigned)(~0) << dat_len)) << (*buf_len - dat_len)); + *buf_len -= dat_len; + } /* end else */ } static void -H5Z__scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, - unsigned char *buffer, size_t *j, unsigned *buf_len, parms_atomic p) +H5Z__scaleoffset_compress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, + size_t *j, unsigned *buf_len, parms_atomic p) { - /* begin_i: the index of byte having first significant bit */ - unsigned begin_i; - unsigned dtype_len; - int k; - - HDassert(p.minbits > 0); - - dtype_len = p.size * 8; - - if(p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ - begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; - - for(k = (int)begin_i; k >= 0; k--) - H5Z__scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } - else { /* big endian */ - HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); - begin_i = (dtype_len - p.minbits) / 8; - - for(k = (int)begin_i; k <= (int)(p.size - 1); k++) - H5Z__scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, - buffer, j, buf_len, p, dtype_len); - } + /* begin_i: the index of byte having first significant bit */ + unsigned begin_i; + unsigned dtype_len; + int k; + + HDassert(p.minbits > 0); + + dtype_len = p.size * 8; + + if (p.mem_order == H5Z_SCALEOFFSET_ORDER_LE) { /* little endian */ + begin_i = p.size - 1 - (dtype_len - p.minbits) / 8; + + for (k = (int)begin_i; k >= 0; k--) + H5Z__scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, + dtype_len); + } + else { /* big endian */ + HDassert(p.mem_order == H5Z_SCALEOFFSET_ORDER_BE); + begin_i = (dtype_len - p.minbits) / 8; + + for (k = (int)begin_i; k <= (int)(p.size - 1); k++) + H5Z__scaleoffset_compress_one_byte(data, data_offset, (unsigned)k, begin_i, buffer, j, buf_len, p, + dtype_len); + } } static void -H5Z__scaleoffset_compress(unsigned char *data, unsigned d_nelmts, - unsigned char *buffer, size_t buffer_size, parms_atomic p) +H5Z__scaleoffset_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, size_t buffer_size, + parms_atomic p) { - /* i: index of data, j: index of buffer, - buf_len: number of bits to be filled in current byte */ - size_t i, j; - unsigned buf_len; - - /* must initialize buffer to be zeros */ - for(j = 0; j < buffer_size; j++) - buffer[j] = 0; - - /* initialization before the loop */ - j = 0; - buf_len = sizeof(unsigned char) * 8; - - /* compress */ - for(i = 0; i < d_nelmts; i++) - H5Z__scaleoffset_compress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); -} + /* i: index of data, j: index of buffer, + buf_len: number of bits to be filled in current byte */ + size_t i, j; + unsigned buf_len; + /* must initialize buffer to be zeros */ + for (j = 0; j < buffer_size; j++) + buffer[j] = 0; + + /* initialization before the loop */ + j = 0; + buf_len = sizeof(unsigned char) * 8; + + /* compress */ + for (i = 0; i < d_nelmts; i++) + H5Z__scaleoffset_compress_one_atomic(data, i * p.size, buffer, &j, &buf_len, p); +} diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 224c78e2ec6..bf272c40339 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -6,43 +6,41 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ /* Local function prototypes */ static herr_t H5Z__set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_SHUFFLE[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_SHUFFLE, /* Filter id number */ - 1, /* encoder_present flag (set to true) */ - 1, /* decoder_present flag (set to true) */ - "shuffle", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - H5Z__set_local_shuffle, /* The "set local" callback */ - H5Z__filter_shuffle, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_SHUFFLE, /* Filter id number */ + 1, /* encoder_present flag (set to true) */ + 1, /* decoder_present flag (set to true) */ + "shuffle", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + H5Z__set_local_shuffle, /* The "set local" callback */ + H5Z__filter_shuffle, /* The actual filter function */ }}; /* Local macros */ -#define H5Z_SHUFFLE_PARM_SIZE 0 /* "Local" parameter for shuffling size */ +#define H5Z_SHUFFLE_PARM_SIZE 0 /* "Local" parameter for shuffling size */ - /*------------------------------------------------------------------------- * Function: H5Z__set_local_shuffle * @@ -60,40 +58,41 @@ const H5Z_class2_t H5Z_SHUFFLE[1] = {{ static herr_t H5Z__set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SHUFFLE_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SHUFFLE_TOTAL_NPARMS]; /* Filter parameters */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SHUFFLE_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SHUFFLE_TOTAL_NPARMS]; /* Filter parameters */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (const H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (type = (const H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SHUFFLE, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SHUFFLE, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, + NULL) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") /* Set "local" parameter for this dataset */ - if((cd_values[H5Z_SHUFFLE_PARM_SIZE] = (unsigned)H5T_get_size(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + if ((cd_values[H5Z_SHUFFLE_PARM_SIZE] = (unsigned)H5T_get_size(type)) == 0) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, cd_values) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, + cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_local_shuffle() */ - /*------------------------------------------------------------------------- * Function: H5Z__filter_shuffle * @@ -113,170 +112,182 @@ H5Z__set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_ *------------------------------------------------------------------------- */ static size_t -H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - void *dest = NULL; /* Buffer to deposit [un]shuffled bytes into */ - unsigned char *_src=NULL; /* Alias for source buffer */ - unsigned char *_dest=NULL; /* Alias for destination buffer */ - unsigned bytesoftype; /* Number of bytes per element */ - size_t numofelements; /* Number of elements in buffer */ - size_t i; /* Local index variables */ + void * dest = NULL; /* Buffer to deposit [un]shuffled bytes into */ + unsigned char *_src = NULL; /* Alias for source buffer */ + unsigned char *_dest = NULL; /* Alias for destination buffer */ + unsigned bytesoftype; /* Number of bytes per element */ + size_t numofelements; /* Number of elements in buffer */ + size_t i; /* Local index variables */ #ifdef NO_DUFFS_DEVICE - size_t j; /* Local index variable */ -#endif /* NO_DUFFS_DEVICE */ - size_t leftover; /* Extra bytes at end of buffer */ - size_t ret_value = 0; /* Return value */ + size_t j; /* Local index variable */ +#endif /* NO_DUFFS_DEVICE */ + size_t leftover; /* Extra bytes at end of buffer */ + size_t ret_value = 0; /* Return value */ FUNC_ENTER_STATIC /* Check arguments */ - if (cd_nelmts!=H5Z_SHUFFLE_TOTAL_NPARMS || cd_values[H5Z_SHUFFLE_PARM_SIZE]==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid shuffle parameters") + if (cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS || cd_values[H5Z_SHUFFLE_PARM_SIZE] == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid shuffle parameters") /* Get the number of bytes per element from the parameter block */ - bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE]; + bytesoftype = cd_values[H5Z_SHUFFLE_PARM_SIZE]; /* Compute the number of elements in buffer */ - numofelements=nbytes/bytesoftype; + numofelements = nbytes / bytesoftype; /* Don't do anything for 1-byte elements, or "fractional" elements */ - if(bytesoftype > 1 && numofelements > 1) { + if (bytesoftype > 1 && numofelements > 1) { /* Compute the leftover bytes if there are any */ - leftover = nbytes%bytesoftype; + leftover = nbytes % bytesoftype; /* Allocate the destination buffer */ - if (NULL==(dest = H5MM_malloc(nbytes))) + if (NULL == (dest = H5MM_malloc(nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for shuffle buffer") - if(flags & H5Z_FLAG_REVERSE) { + if (flags & H5Z_FLAG_REVERSE) { /* Get the pointer to the source buffer */ - _src =(unsigned char *)(*buf); + _src = (unsigned char *)(*buf); /* Input; unshuffle */ - for(i=0; i 0) { + while (j > 0) { DUFF_GUTS; j--; } /* end for */ -#else /* NO_DUFFS_DEVICE */ - { - size_t duffs_index; /* Counting index for Duff's device */ - - duffs_index = (numofelements + 7) / 8; - switch (numofelements % 8) { - default: - HDassert(0 && "This Should never be executed!"); - break; - case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); - } /* end switch */ - } -#endif /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ + { + size_t duffs_index; /* Counting index for Duff's device */ + + duffs_index = (numofelements + 7) / 8; + switch (numofelements % 8) { + default: + HDassert(0 && "This Should never be executed!"); + break; + case 0: + do { + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 7: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); + } /* end switch */ + } +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ - if(leftover>0) { + if (leftover > 0) { /* Adjust back to end of shuffled bytes */ - _dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */ - H5MM_memcpy((void*)_dest, (void*)_src, leftover); + _dest -= (bytesoftype - 1); /*lint !e794 _dest is initialized */ + H5MM_memcpy((void *)_dest, (void *)_src, leftover); } } /* end if */ else { /* Get the pointer to the destination buffer */ - _dest =(unsigned char *)dest; + _dest = (unsigned char *)dest; /* Output; shuffle */ - for(i=0; i 0) { + while (j > 0) { DUFF_GUTS; j--; } /* end for */ -#else /* NO_DUFFS_DEVICE */ - { - size_t duffs_index; /* Counting index for Duff's device */ - - duffs_index = (numofelements + 7) / 8; - switch (numofelements % 8) { - default: - HDassert(0 && "This Should never be executed!"); - break; - case 0: - do - { - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 7: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 6: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 5: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 4: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 3: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 2: - DUFF_GUTS - H5_ATTR_FALLTHROUGH - case 1: - DUFF_GUTS - } while (--duffs_index > 0); - } /* end switch */ - } -#endif /* NO_DUFFS_DEVICE */ +#else /* NO_DUFFS_DEVICE */ + { + size_t duffs_index; /* Counting index for Duff's device */ + + duffs_index = (numofelements + 7) / 8; + switch (numofelements % 8) { + default: + HDassert(0 && "This Should never be executed!"); + break; + case 0: + do { + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 7: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 6: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 5: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 4: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 3: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 2: + DUFF_GUTS + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 1: + DUFF_GUTS + } while (--duffs_index > 0); + } /* end switch */ + } +#endif /* NO_DUFFS_DEVICE */ #undef DUFF_GUTS } /* end for */ /* Add leftover to the end of data */ - if(leftover>0) { + if (leftover > 0) { /* Adjust back to end of shuffled bytes */ - _src -= (bytesoftype - 1); /*lint !e794 _src is initialized */ - H5MM_memcpy((void*)_dest, (void*)_src, leftover); + _src -= (bytesoftype - 1); /*lint !e794 _src is initialized */ + H5MM_memcpy((void *)_dest, (void *)_src, leftover); } } /* end else */ @@ -284,8 +295,8 @@ H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[] H5MM_xfree(*buf); /* Set the buffer information to return */ - *buf = dest; - *buf_size=nbytes; + *buf = dest; + *buf_size = nbytes; } /* end else */ /* Set the return value */ @@ -294,4 +305,3 @@ H5Z__filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[] done: FUNC_LEAVE_NOAPI(ret_value) } - diff --git a/src/H5Zszip.c b/src/H5Zszip.c index c72c499a842..a5c8deccd37 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -6,51 +6,48 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Tprivate.h" /* Datatypes */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5Zpkg.h" /* Data filters */ #ifdef H5_HAVE_FILTER_SZIP #ifdef H5_HAVE_SZLIB_H -# include "szlib.h" +#include "szlib.h" #endif /* Local function prototypes */ static htri_t H5Z__can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); static herr_t H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id); -static size_t H5Z__filter_szip(unsigned flags, size_t cd_nelmts, - const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf); /* This message derives from H5Z */ H5Z_class2_t H5Z_SZIP[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_SZIP, /* Filter id number */ - 1, /* Assume encoder present: check before registering */ - 1, /* decoder_present flag (set to true) */ - "szip", /* Filter name for debugging */ - H5Z__can_apply_szip, /* The "can apply" callback */ - H5Z__set_local_szip, /* The "set local" callback */ - H5Z__filter_szip, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_SZIP, /* Filter id number */ + 1, /* Assume encoder present: check before registering */ + 1, /* decoder_present flag (set to true) */ + "szip", /* Filter name for debugging */ + H5Z__can_apply_szip, /* The "can apply" callback */ + H5Z__set_local_szip, /* The "set local" callback */ + H5Z__filter_szip, /* The actual filter function */ }}; - - /*------------------------------------------------------------------------- * Function: H5Z__can_apply_szip * @@ -75,39 +72,38 @@ H5Z_class2_t H5Z_SZIP[1] = {{ static htri_t H5Z__can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { - const H5T_t *type; /* Datatype */ - unsigned dtype_size; /* Datatype's size (in bits) */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - htri_t ret_value = TRUE; /* Return value */ + const H5T_t *type; /* Datatype */ + unsigned dtype_size; /* Datatype's size (in bits) */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's size, for checking the "bits-per-pixel" */ - if((dtype_size = (8 * H5T_get_size(type))) == 0) + if ((dtype_size = (8 * H5T_get_size(type))) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Range check datatype's size */ - if(dtype_size > 32 && dtype_size != 64) + if (dtype_size > 32 && dtype_size != 64) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ /* (Note: this may not handle non-atomic datatypes well) */ - if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) + if (dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__can_apply_szip() */ - /*------------------------------------------------------------------------- * Function: H5Z__set_local_szip * @@ -124,52 +120,52 @@ H5Z__can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_U static herr_t H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) { - H5P_genplist_t *dcpl_plist; /* Property list pointer */ - const H5T_t *type; /* Datatype */ - const H5S_t *ds; /* Dataspace */ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */ - unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ - hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ - int ndims; /* Number of (chunk) dimensions */ - H5T_order_t dtype_order; /* Datatype's endianness order */ - size_t dtype_size; /* Datatype's size (in bits) */ - size_t dtype_precision; /* Datatype's precision (in bits) */ - size_t dtype_offset; /* Datatype's offset (in bits) */ - hsize_t scanline; /* Size of dataspace's fastest changing dimension */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *dcpl_plist; /* Property list pointer */ + const H5T_t * type; /* Datatype */ + const H5S_t * ds; /* Dataspace */ + unsigned flags; /* Filter flags */ + size_t cd_nelmts = H5Z_SZIP_USER_NPARMS; /* Number of filter parameters */ + unsigned cd_values[H5Z_SZIP_TOTAL_NPARMS]; /* Filter parameters */ + hsize_t dims[H5O_LAYOUT_NDIMS]; /* Dataspace (i.e. chunk) dimensions */ + int ndims; /* Number of (chunk) dimensions */ + H5T_order_t dtype_order; /* Datatype's endianness order */ + size_t dtype_size; /* Datatype's size (in bits) */ + size_t dtype_precision; /* Datatype's precision (in bits) */ + size_t dtype_offset; /* Datatype's offset (in bits) */ + hsize_t scanline; /* Size of dataspace's fastest changing dimension */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Get the plist structure */ - if(NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) + if (NULL == (dcpl_plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get datatype */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ - if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) + if (H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Get datatype's size, for checking the "bits-per-pixel" */ - if((dtype_size = (8 * H5T_get_size(type))) == 0) + if ((dtype_size = (8 * H5T_get_size(type))) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); /* Get datatype's precision, in case is less than full bits */ - if((dtype_precision = H5T_get_precision(type)) == 0) + if ((dtype_precision = H5T_get_precision(type)) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision"); - if(dtype_precision < dtype_size) { + if (dtype_precision < dtype_size) { dtype_offset = H5T_get_offset(type); - if(dtype_offset != 0) + if (dtype_offset != 0) dtype_precision = dtype_size; } /* end if */ - if(dtype_precision > 24) { - if(dtype_precision <= 32) + if (dtype_precision > 24) { + if (dtype_precision <= 32) dtype_precision = 32; - else if(dtype_precision <= 64) + else if (dtype_precision <= 64) dtype_precision = 64; } /* end if */ @@ -177,11 +173,11 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SZIP_PARM_BPP] = dtype_precision; /* Get dataspace */ - if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Get dimensions for dataspace */ - if((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0) + if ((ndims = H5S_get_simple_extent_dims(ds, dims, NULL)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get dataspace dimensions") /* Set "local" parameter for this dataset's "pixels-per-scanline" */ @@ -194,19 +190,20 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) SZ_MAX_BLOCKS_PER_SCANLINE blocks per scanline */ /* Check the pixels per block against the 'scanline' size */ - if(scanline < cd_values[H5Z_SZIP_PARM_PPB]) { - hssize_t npoints; /* Number of points in the dataspace */ + if (scanline < cd_values[H5Z_SZIP_PARM_PPB]) { + hssize_t npoints; /* Number of points in the dataspace */ /* Get number of elements for the dataspace; use total number of elements in the chunk to define the new 'scanline' size */ - if((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) + if ((npoints = H5S_GET_EXTENT_NPOINTS(ds)) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "unable to get number of points in the dataspace") - if(npoints < cd_values[H5Z_SZIP_PARM_PPB]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels per block greater than total number of elements in the chunk") + if (npoints < cd_values[H5Z_SZIP_PARM_PPB]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "pixels per block greater than total number of elements in the chunk") scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), npoints); } else { - if(scanline <= SZ_MAX_PIXELS_PER_SCANLINE) + if (scanline <= SZ_MAX_PIXELS_PER_SCANLINE) scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), scanline); else scanline = cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE; @@ -216,18 +213,18 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) H5_CHECKED_ASSIGN(cd_values[H5Z_SZIP_PARM_PPS], unsigned, scanline, hsize_t); /* Get datatype's endianness order */ - if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) + if ((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set the correct endianness flag for szip */ /* (Note: this may not handle non-atomic datatypes well) */ - cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK|SZ_MSB_OPTION_MASK); - switch(dtype_order) { - case H5T_ORDER_LE: /* Little-endian byte order */ + cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK | SZ_MSB_OPTION_MASK); + switch (dtype_order) { + case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[H5Z_SZIP_PARM_MASK] |= SZ_LSB_OPTION_MASK; break; - case H5T_ORDER_BE: /* Big-endian byte order */ + case H5T_ORDER_BE: /* Big-endian byte order */ cd_values[H5Z_SZIP_PARM_MASK] |= SZ_MSB_OPTION_MASK; break; @@ -240,14 +237,13 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) } /* end switch */ /* Modify the filter's parameters for this dataset */ - if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0) + if (H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_local_szip() */ - /*------------------------------------------------------------------------- * Function: H5Z__filter_szip * @@ -263,29 +259,29 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) *------------------------------------------------------------------------- */ static size_t -H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], - size_t nbytes, size_t *buf_size, void **buf) +H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, + size_t *buf_size, void **buf) { - size_t ret_value = 0; /* Return value */ - size_t size_out = 0; /* Size of output buffer */ - unsigned char *outbuf = NULL; /* Pointer to new output buffer */ - unsigned char *newbuf = NULL; /* Pointer to input buffer */ - SZ_com_t sz_param; /* szip parameter block */ + size_t ret_value = 0; /* Return value */ + size_t size_out = 0; /* Size of output buffer */ + unsigned char *outbuf = NULL; /* Pointer to new output buffer */ + unsigned char *newbuf = NULL; /* Pointer to input buffer */ + SZ_com_t sz_param; /* szip parameter block */ FUNC_ENTER_STATIC /* Sanity check to make certain that we haven't drifted out of date with * the mask options from the szlib.h header */ - HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK); - HDassert(H5_SZIP_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK); - HDassert(H5_SZIP_EC_OPTION_MASK==SZ_EC_OPTION_MASK); - HDassert(H5_SZIP_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK); - HDassert(H5_SZIP_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK); - HDassert(H5_SZIP_NN_OPTION_MASK==SZ_NN_OPTION_MASK); - HDassert(H5_SZIP_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK); + HDassert(H5_SZIP_ALLOW_K13_OPTION_MASK == SZ_ALLOW_K13_OPTION_MASK); + HDassert(H5_SZIP_CHIP_OPTION_MASK == SZ_CHIP_OPTION_MASK); + HDassert(H5_SZIP_EC_OPTION_MASK == SZ_EC_OPTION_MASK); + HDassert(H5_SZIP_LSB_OPTION_MASK == SZ_LSB_OPTION_MASK); + HDassert(H5_SZIP_MSB_OPTION_MASK == SZ_MSB_OPTION_MASK); + HDassert(H5_SZIP_NN_OPTION_MASK == SZ_NN_OPTION_MASK); + HDassert(H5_SZIP_RAW_OPTION_MASK == SZ_RAW_OPTION_MASK); /* Check arguments */ - if (cd_nelmts!=4) + if (cd_nelmts != 4) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters") /* Copy the filter parameters into the szip parameter block */ @@ -296,66 +292,65 @@ H5Z__filter_szip(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Input; uncompress */ if (flags & H5Z_FLAG_REVERSE) { - uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */ - size_t nalloc; /* Number of bytes the compressed block will expand into */ + uint32_t stored_nalloc; /* Number of bytes the compressed block will expand into */ + size_t nalloc; /* Number of bytes the compressed block will expand into */ /* Get the size of the uncompressed buffer */ newbuf = (unsigned char *)(*buf); - UINT32DECODE(newbuf,stored_nalloc); + UINT32DECODE(newbuf, stored_nalloc); H5_CHECKED_ASSIGN(nalloc, size_t, stored_nalloc, uint32_t); /* Allocate space for the uncompressed buffer */ - if(NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc))) + if (NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression") /* Decompress the buffer */ - size_out=nalloc; - if(SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes-4, &sz_param) != SZ_OK) + size_out = nalloc; + if (SZ_BufftoBuffDecompress(outbuf, &size_out, newbuf, nbytes - 4, &sz_param) != SZ_OK) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "szip_filter: decompression failed") - HDassert(size_out==nalloc); + HDassert(size_out == nalloc); /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; + *buf = outbuf; + outbuf = NULL; *buf_size = nalloc; ret_value = size_out; } /* Output; compress */ else { - unsigned char *dst = NULL; /* Temporary pointer to new output buffer */ + unsigned char *dst = NULL; /* Temporary pointer to new output buffer */ /* Allocate space for the compressed buffer & header (assume data won't get bigger) */ - if(NULL == (dst=outbuf = (unsigned char *)H5MM_malloc(nbytes+4))) + if (NULL == (dst = outbuf = (unsigned char *)H5MM_malloc(nbytes + 4))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer") /* Encode the uncompressed length */ - H5_CHECK_OVERFLOW(nbytes,size_t,uint32_t); - UINT32ENCODE(dst,nbytes); + H5_CHECK_OVERFLOW(nbytes, size_t, uint32_t); + UINT32ENCODE(dst, nbytes); /* Compress the buffer */ size_out = nbytes; - if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) + if (SZ_OK != SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") - HDassert(size_out<=nbytes); + HDassert(size_out <= nbytes); /* Free the input buffer */ H5MM_xfree(*buf); /* Set return values */ - *buf = outbuf; - outbuf = NULL; - *buf_size = nbytes+4; - ret_value = size_out+4; + *buf = outbuf; + outbuf = NULL; + *buf_size = nbytes + 4; + ret_value = size_out + 4; } done: - if(outbuf) + if (outbuf) H5MM_xfree(outbuf); FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5_HAVE_FILTER_SZIP */ - diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 83e9c3867a2..7d55efd3d1c 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -6,27 +6,25 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VMprivate.h" /* H5VM_array_fill */ -#include "H5Zpkg.h" /* Data filters */ +#include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* H5VM_array_fill */ +#include "H5Zpkg.h" /* Data filters */ /* Token types */ typedef enum { H5Z_XFORM_ERROR, H5Z_XFORM_INTEGER, /* this represents an integer type in the data transform expression */ - H5Z_XFORM_FLOAT, /* this represents a floating point type in the data transform expression */ + H5Z_XFORM_FLOAT, /* this represents a floating point type in the data transform expression */ H5Z_XFORM_SYMBOL, H5Z_XFORM_PLUS, H5Z_XFORM_MINUS, @@ -37,31 +35,29 @@ typedef enum { H5Z_XFORM_END } H5Z_token_type; - typedef struct { - unsigned int num_ptrs; - void** ptr_dat_val; + unsigned int num_ptrs; + void ** ptr_dat_val; } H5Z_datval_ptrs; - /* Used to represent values in transform expression */ typedef union { - void *dat_val; - long int_val; - double float_val; + void * dat_val; + long int_val; + double float_val; } H5Z_num_val; typedef struct H5Z_node { - struct H5Z_node *lchild; - struct H5Z_node *rchild; - H5Z_token_type type; - H5Z_num_val value; + struct H5Z_node *lchild; + struct H5Z_node *rchild; + H5Z_token_type type; + H5Z_num_val value; } H5Z_node; struct H5Z_data_xform_t { - char* xform_exp; - H5Z_node* parse_root; - H5Z_datval_ptrs* dat_val_pointers; + char * xform_exp; + H5Z_node * parse_root; + H5Z_datval_ptrs *dat_val_pointers; }; typedef struct result { @@ -69,302 +65,305 @@ typedef struct result { H5Z_num_val value; } H5Z_result; - /* The token */ typedef struct { - const char *tok_expr; /* Holds the original expression */ + const char *tok_expr; /* Holds the original expression */ /* Current token values */ - H5Z_token_type tok_type; /* The type of the current token */ - const char *tok_begin; /* The beginning of the current token */ - const char *tok_end; /* The end of the current token */ + H5Z_token_type tok_type; /* The type of the current token */ + const char * tok_begin; /* The beginning of the current token */ + const char * tok_end; /* The end of the current token */ /* Previous token values */ - H5Z_token_type tok_last_type; /* The type of the last token */ - const char *tok_last_begin; /* The beginning of the last token */ - const char *tok_last_end; /* The end of the last token */ + H5Z_token_type tok_last_type; /* The type of the last token */ + const char * tok_last_begin; /* The beginning of the last token */ + const char * tok_last_end; /* The end of the last token */ } H5Z_token; /* Local function prototypes */ static H5Z_token *H5Z__get_token(H5Z_token *current); -static H5Z_node *H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers); -static H5Z_node *H5Z__new_node(H5Z_token_type type); -static void H5Z__do_op(H5Z_node* tree); -static hbool_t H5Z__op_is_numbs(H5Z_node* _tree); -static hbool_t H5Z__op_is_numbs2(H5Z_node* _tree); -static hid_t H5Z__xform_find_type(const H5T_t* type); -static herr_t H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result* res); -static void H5Z__xform_destroy_parse_tree(H5Z_node *tree); -static void* H5Z__xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers); -static void* H5Z__xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers); -static void H5Z__xform_reduce_tree(H5Z_node* tree); +static H5Z_node * H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers); +static H5Z_node * H5Z__new_node(H5Z_token_type type); +static void H5Z__do_op(H5Z_node *tree); +static hbool_t H5Z__op_is_numbs(H5Z_node *_tree); +static hbool_t H5Z__op_is_numbs2(H5Z_node *_tree); +static hid_t H5Z__xform_find_type(const H5T_t *type); +static herr_t H5Z__xform_eval_full(H5Z_node *tree, size_t array_size, hid_t array_type, H5Z_result *res); +static void H5Z__xform_destroy_parse_tree(H5Z_node *tree); +static void * H5Z__xform_parse(const char *expression, H5Z_datval_ptrs *dat_val_pointers); +static void * H5Z__xform_copy_tree(H5Z_node *tree, H5Z_datval_ptrs *dat_val_pointers, + H5Z_datval_ptrs *new_dat_val_pointers); +static void H5Z__xform_reduce_tree(H5Z_node *tree); /* PGCC (11.8-0) has trouble with the command *p++ = *p OP tree_val. It increments P first before * doing the operation. So I break down the command into two lines: * *p = *p OP tree_val; p++; * Actually, the behavior of *p++ = *p OP tree_val is undefined. (SLU - 2012/3/19) */ -#define H5Z_XFORM_DO_OP1(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - size_t u; \ - \ - if(((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type != H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* p; \ - double tree_val; \ - \ - tree_val = ((RESR).type==H5Z_XFORM_INTEGER ? (double)(RESR).value.int_val : (RESR).value.float_val); \ - p = (TYPE*)(RESL).value.dat_val; \ - \ - for(u = 0; u < (SIZE); u++) { \ - *p = (TYPE)((double)*p OP tree_val); \ - p++; \ - } \ - } \ - else if(((RESR).type == H5Z_XFORM_SYMBOL) && ((RESL).type != H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* p; \ - double tree_val; \ - \ - /* The case that the left operand is nothing, like -x or +x */ \ - if((RESL).type == H5Z_XFORM_ERROR) \ - tree_val = 0; \ - else \ - tree_val = ((RESL).type==H5Z_XFORM_INTEGER ? (double)(RESL).value.int_val : (RESL).value.float_val); \ - \ - p = (TYPE*)(RESR).value.dat_val; \ - for(u = 0; u < (SIZE); u++) { \ - *p = (TYPE)(tree_val OP (double)*p); \ - p++; \ - } \ - } \ - else if( ((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type == H5Z_XFORM_SYMBOL)) \ - { \ - TYPE* pl = (TYPE*)(RESL).value.dat_val; \ - TYPE* pr = (TYPE*)(RESR).value.dat_val; \ - \ - for(u = 0; u < (SIZE); u++) { \ - *pl = (TYPE)(*pl OP *pr); \ - pl++; pr++; \ - } \ - } \ - else \ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \ -} +#define H5Z_XFORM_DO_OP1(RESL, RESR, TYPE, OP, SIZE) \ + { \ + size_t u; \ + \ + if (((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type != H5Z_XFORM_SYMBOL)) { \ + TYPE * p; \ + double tree_val; \ + \ + tree_val = \ + ((RESR).type == H5Z_XFORM_INTEGER ? (double)(RESR).value.int_val : (RESR).value.float_val); \ + p = (TYPE *)(RESL).value.dat_val; \ + \ + for (u = 0; u < (SIZE); u++) { \ + *p = (TYPE)((double)*p OP tree_val); \ + p++; \ + } \ + } \ + else if (((RESR).type == H5Z_XFORM_SYMBOL) && ((RESL).type != H5Z_XFORM_SYMBOL)) { \ + TYPE * p; \ + double tree_val; \ + \ + /* The case that the left operand is nothing, like -x or +x */ \ + if ((RESL).type == H5Z_XFORM_ERROR) \ + tree_val = 0; \ + else \ + tree_val = ((RESL).type == H5Z_XFORM_INTEGER ? (double)(RESL).value.int_val \ + : (RESL).value.float_val); \ + \ + p = (TYPE *)(RESR).value.dat_val; \ + for (u = 0; u < (SIZE); u++) { \ + *p = (TYPE)(tree_val OP(double) * p); \ + p++; \ + } \ + } \ + else if (((RESL).type == H5Z_XFORM_SYMBOL) && ((RESR).type == H5Z_XFORM_SYMBOL)) { \ + TYPE *pl = (TYPE *)(RESL).value.dat_val; \ + TYPE *pr = (TYPE *)(RESR).value.dat_val; \ + \ + for (u = 0; u < (SIZE); u++) { \ + *pl = (TYPE)(*pl OP * pr); \ + pl++; \ + pr++; \ + } \ + } \ + else \ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \ + } #if H5_SIZEOF_LONG_DOUBLE != 0 #if CHAR_MIN >= 0 -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LDOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LDOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ + } #else /* CHAR_MIN >= 0 */ -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LDOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LDOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ + } #endif /* CHAR_MIN >= 0 */ #else #if CHAR_MIN >= 0 -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + } #else /* CHAR_MIN >= 0 */ -#define H5Z_XFORM_TYPE_OP(RESL,RESR,TYPE,OP,SIZE) \ -{ \ - if((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ -} +#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ + { \ + if ((TYPE) == H5T_NATIVE_CHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UCHAR) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_SHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_USHORT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_INT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_UINT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_LLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_ULLONG) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_FLOAT) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ + else if ((TYPE) == H5T_NATIVE_DOUBLE) \ + H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ + } #endif /* CHAR_MIN >= 0 */ #endif /*H5_SIZEOF_LONG_DOUBLE */ -#define H5Z_XFORM_DO_OP3(OP) \ -{ \ - if((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ - else if( ( (tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ - ( (tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val : (double)tree->lchild->value.int_val) OP \ - ((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val : (double)tree->rchild->value.int_val); \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP3(OP) \ + { \ + if ((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + else if (((tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ + ((tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = \ + ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val \ + : (double)tree->lchild->value.int_val) \ + OP((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val \ + : (double)tree->rchild->value.int_val); \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + } -#define H5Z_XFORM_DO_OP4(TYPE) \ -{ \ - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) \ - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") \ - else \ - { \ - ret_value->type = (TYPE); \ - if(tree->lchild) \ - ret_value->lchild = (H5Z_node*) H5Z__xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ - else \ - ret_value->lchild = NULL; \ - if(tree->rchild) \ - ret_value->rchild = (H5Z_node*) H5Z__xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ - else \ - ret_value->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP4(TYPE) \ + { \ + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) \ + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") \ + else { \ + ret_value->type = (TYPE); \ + if (tree->lchild) \ + ret_value->lchild = \ + (H5Z_node *)H5Z__xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->lchild = NULL; \ + if (tree->rchild) \ + ret_value->rchild = \ + (H5Z_node *)H5Z__xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->rchild = NULL; \ + } \ + } -#define H5Z_XFORM_DO_OP5(TYPE, SIZE) \ -{ \ - TYPE val = ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \ - H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \ -} +#define H5Z_XFORM_DO_OP5(TYPE, SIZE) \ + { \ + TYPE val = \ + ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \ + H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \ + } -/* The difference of this macro from H5Z_XFORM_DO_OP3 is that it handles the operations when the left operand is empty, like -x or +x. - * The reason that it's separated from H5Z_XFORM_DO_OP3 is because compilers don't accept operations like *x or /x. So in H5Z__do_op, - * these two macros are called in different ways. (SLU 2012/3/20) +/* The difference of this macro from H5Z_XFORM_DO_OP3 is that it handles the operations when the left operand + * is empty, like -x or +x. The reason that it's separated from H5Z_XFORM_DO_OP3 is because compilers don't + * accept operations like *x or /x. So in H5Z__do_op, these two macros are called in different ways. (SLU + * 2012/3/20) */ -#define H5Z_XFORM_DO_OP6(OP) \ -{ \ - if(!tree->lchild && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->rchild); \ - tree->rchild = NULL; \ - } \ - else if(!tree->lchild && (tree->rchild->type==H5Z_XFORM_FLOAT)) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = OP tree->rchild->value.float_val; \ - H5MM_xfree(tree->rchild); \ - tree->rchild = NULL; \ - } \ - else if((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type==H5Z_XFORM_INTEGER)) \ - { \ - tree->type = H5Z_XFORM_INTEGER; \ - tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ - else if( ( (tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ - ( (tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) \ - { \ - tree->type = H5Z_XFORM_FLOAT; \ - tree->value.float_val = ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val : (double)tree->lchild->value.int_val) OP \ - ((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val : (double)tree->rchild->value.int_val); \ - H5MM_xfree(tree->lchild); \ - H5MM_xfree(tree->rchild); \ - tree->lchild = NULL; \ - tree->rchild = NULL; \ - } \ -} +#define H5Z_XFORM_DO_OP6(OP) \ + { \ + if (!tree->lchild && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->rchild); \ + tree->rchild = NULL; \ + } \ + else if (!tree->lchild && (tree->rchild->type == H5Z_XFORM_FLOAT)) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = OP tree->rchild->value.float_val; \ + H5MM_xfree(tree->rchild); \ + tree->rchild = NULL; \ + } \ + else if ((tree->lchild->type == H5Z_XFORM_INTEGER) && (tree->rchild->type == H5Z_XFORM_INTEGER)) { \ + tree->type = H5Z_XFORM_INTEGER; \ + tree->value.int_val = tree->lchild->value.int_val OP tree->rchild->value.int_val; \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + else if (((tree->lchild->type == H5Z_XFORM_FLOAT) || (tree->lchild->type == H5Z_XFORM_INTEGER)) && \ + ((tree->rchild->type == H5Z_XFORM_FLOAT) || (tree->rchild->type == H5Z_XFORM_INTEGER))) { \ + tree->type = H5Z_XFORM_FLOAT; \ + tree->value.float_val = \ + ((tree->lchild->type == H5Z_XFORM_FLOAT) ? tree->lchild->value.float_val \ + : (double)tree->lchild->value.int_val) \ + OP((tree->rchild->type == H5Z_XFORM_FLOAT) ? tree->rchild->value.float_val \ + : (double)tree->rchild->value.int_val); \ + H5MM_xfree(tree->lchild); \ + H5MM_xfree(tree->rchild); \ + tree->lchild = NULL; \ + tree->rchild = NULL; \ + } \ + } /* * Programmer: Bill Wendling @@ -387,7 +386,6 @@ static void H5Z__xform_reduce_tree(H5Z_node* tree); * // FLOAT is a C double */ - /*------------------------------------------------------------------------- * Function: H5Z__unget_token * @@ -410,14 +408,13 @@ H5Z__unget_token(H5Z_token *current) /* check args */ HDassert(current); - current->tok_type = current->tok_last_type; + current->tok_type = current->tok_last_type; current->tok_begin = current->tok_last_begin; - current->tok_end = current->tok_last_end; + current->tok_end = current->tok_last_end; FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5Z__get_token * @@ -447,17 +444,17 @@ H5Z__get_token(H5Z_token *current) HDassert(current); /* Save the last position for possible ungets */ - current->tok_last_type = current->tok_type; + current->tok_last_type = current->tok_type; current->tok_last_begin = current->tok_begin; - current->tok_last_end = current->tok_end; + current->tok_last_end = current->tok_end; current->tok_begin = current->tok_end; while (current->tok_begin[0] != '\0') { if (HDisspace(current->tok_begin[0])) { /* ignore whitespace */ - } else if (HDisdigit(current->tok_begin[0]) || - current->tok_begin[0] == '.') { + } + else if (HDisdigit(current->tok_begin[0]) || current->tok_begin[0] == '.') { current->tok_end = current->tok_begin; /* @@ -480,9 +477,7 @@ H5Z__get_token(H5Z_token *current) * '.' digit-sequence * exponent := [Ee] [-+]? digit-sequence */ - if (current->tok_end[0] == '.' || - current->tok_end[0] == 'e' || - current->tok_end[0] == 'E') { + if (current->tok_end[0] == '.' || current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { current->tok_type = H5Z_XFORM_FLOAT; if (current->tok_end[0] == '.') @@ -490,17 +485,16 @@ H5Z__get_token(H5Z_token *current) ++current->tok_end; } while (HDisdigit(current->tok_end[0])); - if (current->tok_end[0] == 'e' || - current->tok_end[0] == 'E') { + if (current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { ++current->tok_end; - if (current->tok_end[0] == '-' || - current->tok_end[0] == '+') + if (current->tok_end[0] == '-' || current->tok_end[0] == '+') ++current->tok_end; if (!HDisdigit(current->tok_end[0])) { current->tok_type = H5Z_XFORM_ERROR; - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, + "Invalidly formatted floating point number") } while (HDisdigit(current->tok_end[0])) @@ -515,27 +509,42 @@ H5Z__get_token(H5Z_token *current) } break; - } else if (HDisalpha(current->tok_begin[0])) { + } + else if (HDisalpha(current->tok_begin[0])) { /* is symbol */ current->tok_type = H5Z_XFORM_SYMBOL; - current->tok_end = current->tok_begin; + current->tok_end = current->tok_begin; while (HDisalnum(current->tok_end[0])) ++current->tok_end; break; - } else { + } + else { /* should be +, -, *, /, (, or ) */ switch (current->tok_begin[0]) { - case '+': current->tok_type = H5Z_XFORM_PLUS; break; - case '-': current->tok_type = H5Z_XFORM_MINUS; break; - case '*': current->tok_type = H5Z_XFORM_MULT; break; - case '/': current->tok_type = H5Z_XFORM_DIVIDE; break; - case '(': current->tok_type = H5Z_XFORM_LPAREN; break; - case ')': current->tok_type = H5Z_XFORM_RPAREN; break; + case '+': + current->tok_type = H5Z_XFORM_PLUS; + break; + case '-': + current->tok_type = H5Z_XFORM_MINUS; + break; + case '*': + current->tok_type = H5Z_XFORM_MULT; + break; + case '/': + current->tok_type = H5Z_XFORM_DIVIDE; + break; + case '(': + current->tok_type = H5Z_XFORM_LPAREN; + break; + case ')': + current->tok_type = H5Z_XFORM_RPAREN; + break; default: current->tok_type = H5Z_XFORM_ERROR; - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Unknown H5Z_token in data transform expression ") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, + "Unknown H5Z_token in data transform expression ") } current->tok_end = current->tok_begin + 1; @@ -555,7 +564,6 @@ H5Z__get_token(H5Z_token *current) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__xform_destroy_parse_tree * Purpose: Recursively destroys the expression tree. @@ -570,7 +578,7 @@ H5Z__xform_destroy_parse_tree(H5Z_node *tree) { FUNC_ENTER_STATIC_NOERR - if(tree) { + if (tree) { H5Z__xform_destroy_parse_tree(tree->lchild); H5Z__xform_destroy_parse_tree(tree->rchild); H5MM_xfree(tree); @@ -580,7 +588,6 @@ H5Z__xform_destroy_parse_tree(H5Z_node *tree) FUNC_LEAVE_NOAPI_VOID } - /*------------------------------------------------------------------------- * Function: H5Z_parse * @@ -595,28 +602,27 @@ H5Z__xform_destroy_parse_tree(H5Z_node *tree) *------------------------------------------------------------------------- */ static void * -H5Z__xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) +H5Z__xform_parse(const char *expression, H5Z_datval_ptrs *dat_val_pointers) { H5Z_token tok; - void *ret_value = NULL; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(!expression) + if (!expression) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "No expression provided?") /* Set up the initial H5Z_token for parsing */ tok.tok_expr = tok.tok_begin = tok.tok_end = expression; - ret_value = (void*)H5Z__parse_expression(&tok, dat_val_pointers); + ret_value = (void *)H5Z__parse_expression(&tok, dat_val_pointers); - H5Z__xform_reduce_tree((H5Z_node*)ret_value); + H5Z__xform_reduce_tree((H5Z_node *)ret_value); done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__parse_expression * Purpose: Beginning of the recursive descent parser to parse the @@ -629,14 +635,14 @@ H5Z__xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) * * Programmer: Bill Wendling * 26. August 2003 -* + * *------------------------------------------------------------------------- */ static H5Z_node * -H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { H5Z_node *expr; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -647,7 +653,7 @@ H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) current = H5Z__get_token(current); - switch(current->tok_type) { + switch (current->tok_type) { case H5Z_XFORM_PLUS: new_node = H5Z__new_node(H5Z_XFORM_PLUS); @@ -710,7 +716,6 @@ H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__parse_term * Purpose: Parses a term in our expression language. A term is: @@ -726,10 +731,10 @@ H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) *------------------------------------------------------------------------- */ static H5Z_node * -H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { - H5Z_node *term = NULL; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *term = NULL; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -770,7 +775,7 @@ H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) new_node->lchild = term; new_node->rchild = H5Z__parse_factor(current, dat_val_pointers); - term = new_node; + term = new_node; if (!new_node->rchild) { H5Z__xform_destroy_parse_tree(new_node); @@ -797,15 +802,15 @@ H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) case H5Z_XFORM_ERROR: default: H5Z__xform_destroy_parse_tree(term); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "bad transform type passed to data transform expression") - } /* end switch */ - } /* end for */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "bad transform type passed to data transform expression") + } /* end switch */ + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__parse_factor * Purpose: Parses a factor in our expression language. A factor is: @@ -825,11 +830,11 @@ H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) *------------------------------------------------------------------------- */ static H5Z_node * -H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) +H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) { - H5Z_node *factor=NULL; - H5Z_node *new_node; - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *factor = NULL; + H5Z_node *new_node; + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -840,7 +845,7 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z__new_node(H5Z_XFORM_INTEGER); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") HDsscanf(current->tok_begin, "%ld", &factor->value.int_val); break; @@ -848,7 +853,7 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z__new_node(H5Z_XFORM_FLOAT); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") HDsscanf(current->tok_begin, "%lf", &factor->value.float_val); break; @@ -856,7 +861,7 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z__new_node(H5Z_XFORM_SYMBOL); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]); dat_val_pointers->num_ptrs++; @@ -866,7 +871,7 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) factor = H5Z__parse_expression(current, dat_val_pointers); if (!factor) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") current = H5Z__get_token(current); @@ -882,80 +887,80 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Syntax error: unexpected ')' ") case H5Z_XFORM_PLUS: - /* unary + */ - new_node = H5Z__parse_factor(current, dat_val_pointers); - - if (new_node) { - if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && - new_node->type != H5Z_XFORM_SYMBOL) { - H5Z__xform_destroy_parse_tree(new_node); - H5Z__xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + /* unary + */ + new_node = H5Z__parse_factor(current, dat_val_pointers); - factor = new_node; - new_node = H5Z__new_node(H5Z_XFORM_PLUS); + if (new_node) { + if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && + new_node->type != H5Z_XFORM_SYMBOL) { + H5Z__xform_destroy_parse_tree(new_node); + H5Z__xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } - if (!new_node) { - H5Z__xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + factor = new_node; + new_node = H5Z__new_node(H5Z_XFORM_PLUS); - new_node->rchild = factor; - factor = new_node; - } else { + if (!new_node) { H5Z__xform_destroy_parse_tree(factor); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") } - break; + + new_node->rchild = factor; + factor = new_node; + } + else { + H5Z__xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } + break; case H5Z_XFORM_MINUS: - /* unary - */ - new_node = H5Z__parse_factor(current, dat_val_pointers); - - if (new_node) { - if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && - new_node->type != H5Z_XFORM_SYMBOL) { - H5Z__xform_destroy_parse_tree(new_node); - H5Z__xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + /* unary - */ + new_node = H5Z__parse_factor(current, dat_val_pointers); - factor = new_node; - new_node = H5Z__new_node(H5Z_XFORM_MINUS); + if (new_node) { + if (new_node->type != H5Z_XFORM_INTEGER && new_node->type != H5Z_XFORM_FLOAT && + new_node->type != H5Z_XFORM_SYMBOL) { + H5Z__xform_destroy_parse_tree(new_node); + H5Z__xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } - if (!new_node) { - H5Z__xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") - } + factor = new_node; + new_node = H5Z__new_node(H5Z_XFORM_MINUS); - new_node->rchild = factor; - factor = new_node; - } else { + if (!new_node) { H5Z__xform_destroy_parse_tree(factor); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") } - break; + + new_node->rchild = factor; + factor = new_node; + } + else { + H5Z__xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression") + } + break; case H5Z_XFORM_END: - break; + break; case H5Z_XFORM_MULT: case H5Z_XFORM_DIVIDE: case H5Z_XFORM_ERROR: default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Invalid token while parsing data transform expression") - } /* Set return value */ - ret_value=factor; + ret_value = factor; done: FUNC_LEAVE_NOAPI(ret_value); } - /*------------------------------------------------------------------------- * Function: H5Z__new_node * @@ -972,12 +977,13 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) static H5Z_node * H5Z__new_node(H5Z_token_type type) { - H5Z_node *ret_value = NULL; /* Return value */ + H5Z_node *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC - if(NULL == (ret_value = (H5Z_node *)H5MM_calloc(sizeof(H5Z_node)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to allocate space for nodes in the parse tree") + if (NULL == (ret_value = (H5Z_node *)H5MM_calloc(sizeof(H5Z_node)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "Ran out of memory trying to allocate space for nodes in the parse tree") ret_value->type = type; @@ -985,26 +991,25 @@ H5Z__new_node(H5Z_token_type type) FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z_xform_eval - * Purpose: If the transform is trivial, this function applies it. - * Otherwise, it calls H5Z__xform_eval_full to do the full - * transform. + * Purpose: If the transform is trivial, this function applies it. + * Otherwise, it calls H5Z__xform_eval_full to do the full + * transform. * Return: SUCCEED if transform applied successfully, FAIL otherwise * Programmer: Leon Arber - * 5/1/04 + * 5/1/04 * *------------------------------------------------------------------------- */ herr_t -H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size, const H5T_t *buf_type) +H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size, const H5T_t *buf_type) { - H5Z_node *tree; - hid_t array_type; + H5Z_node * tree; + hid_t array_type; H5Z_result res; - size_t i; - herr_t ret_value = SUCCEED; /* Return value */ + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1013,97 +1018,99 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size tree = data_xform_prop->parse_root; /* Get the datatype ID for the buffer's type */ - if((array_type = H5Z__xform_find_type(buf_type)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Cannot perform data transform on this type.") + if ((array_type = H5Z__xform_find_type(buf_type)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Cannot perform data transform on this type.") /* After this point, we're assured that the type of the array is handled by the eval code, * so we no longer have to check for valid types */ /* If it's a trivial data transform, perform it */ - if(tree->type == H5Z_XFORM_INTEGER || tree->type == H5Z_XFORM_FLOAT) { - if(array_type == H5T_NATIVE_CHAR) + if (tree->type == H5Z_XFORM_INTEGER || tree->type == H5Z_XFORM_FLOAT) { + if (array_type == H5T_NATIVE_CHAR) H5Z_XFORM_DO_OP5(char, array_size) #if CHAR_MIN >= 0 - else if(array_type == H5T_NATIVE_SCHAR) + else if (array_type == H5T_NATIVE_SCHAR) H5Z_XFORM_DO_OP5(signed char, array_size) -#else /* CHAR_MIN >= 0 */ - else if(array_type == H5T_NATIVE_UCHAR) +#else /* CHAR_MIN >= 0 */ + else if (array_type == H5T_NATIVE_UCHAR) H5Z_XFORM_DO_OP5(unsigned char, array_size) #endif /* CHAR_MIN >= 0 */ - else if(array_type == H5T_NATIVE_SHORT) + else if (array_type == H5T_NATIVE_SHORT) H5Z_XFORM_DO_OP5(short, array_size) - else if(array_type == H5T_NATIVE_USHORT) + else if (array_type == H5T_NATIVE_USHORT) H5Z_XFORM_DO_OP5(unsigned short, array_size) - else if(array_type == H5T_NATIVE_INT) + else if (array_type == H5T_NATIVE_INT) H5Z_XFORM_DO_OP5(int, array_size) - else if(array_type == H5T_NATIVE_UINT) + else if (array_type == H5T_NATIVE_UINT) H5Z_XFORM_DO_OP5(unsigned int, array_size) - else if(array_type == H5T_NATIVE_LONG) + else if (array_type == H5T_NATIVE_LONG) H5Z_XFORM_DO_OP5(long, array_size) - else if(array_type == H5T_NATIVE_ULONG) + else if (array_type == H5T_NATIVE_ULONG) H5Z_XFORM_DO_OP5(unsigned long, array_size) - else if(array_type == H5T_NATIVE_LLONG) + else if (array_type == H5T_NATIVE_LLONG) H5Z_XFORM_DO_OP5(long long, array_size) - else if(array_type == H5T_NATIVE_ULLONG) + else if (array_type == H5T_NATIVE_ULLONG) H5Z_XFORM_DO_OP5(unsigned long long, array_size) - else if(array_type == H5T_NATIVE_FLOAT) + else if (array_type == H5T_NATIVE_FLOAT) H5Z_XFORM_DO_OP5(float, array_size) - else if(array_type == H5T_NATIVE_DOUBLE) + else if (array_type == H5T_NATIVE_DOUBLE) H5Z_XFORM_DO_OP5(double, array_size) -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(array_type == H5T_NATIVE_LDOUBLE) +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (array_type == H5T_NATIVE_LDOUBLE) H5Z_XFORM_DO_OP5(long double, array_size) #endif } /* end if */ /* Otherwise, do the full data transform */ else { - /* Optimization for linear transform: */ - if(data_xform_prop->dat_val_pointers->num_ptrs == 1) - data_xform_prop->dat_val_pointers->ptr_dat_val[0] = array; + /* Optimization for linear transform: */ + if (data_xform_prop->dat_val_pointers->num_ptrs == 1) + data_xform_prop->dat_val_pointers->ptr_dat_val[0] = array; - /* If it's a quadratic transform, we have no choice but to store multiple copies of the data */ - else { - for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) { - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size * H5T_get_size((H5T_t *)H5I_object(array_type))))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "Ran out of memory trying to allocate space for data in data transform") + /* If it's a quadratic transform, we have no choice but to store multiple copies of the data */ + else { + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) { + if (NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void *)H5MM_malloc( + array_size * H5T_get_size((H5T_t *)H5I_object(array_type))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "Ran out of memory trying to allocate space for data in data transform") - H5MM_memcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); - } /* end for */ - } /* end else */ + H5MM_memcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, + array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); + } /* end for */ + } /* end else */ - if(H5Z__xform_eval_full(tree, array_size, array_type, &res) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + if (H5Z__xform_eval_full(tree, array_size, array_type, &res) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - H5MM_memcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + H5MM_memcpy(array, res.value.dat_val, array_size * H5T_get_size((H5T_t *)H5I_object(array_type))); /* Free the temporary arrays we used */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - for(i=0; idat_val_pointers->num_ptrs; i++) + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end else */ done: - if(ret_value < 0) { - /* If we ran out of memory above copying the array for temp storage (which we easily can for - * polynomial transforms of high order) we free those arrays which we already allocated */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 1) - for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) - if(data_xform_prop->dat_val_pointers->ptr_dat_val[i]) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + if (ret_value < 0) { + /* If we ran out of memory above copying the array for temp storage (which we easily can for + * polynomial transforms of high order) we free those arrays which we already allocated */ + if (data_xform_prop->dat_val_pointers->num_ptrs > 1) + for (i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) + if (data_xform_prop->dat_val_pointers->ptr_dat_val[i]) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_xform_eval() */ - /*------------------------------------------------------------------------- * Function: H5Z__xform_eval_full * - * Purpose: Does a full evaluation of the parse tree contained in tree - * and applies this transform to array. + * Purpose: Does a full evaluation of the parse tree contained in tree + * and applies this transform to array. * * Notes: In the case of a polynomial data transform (ie, the left and right * subtree are both of type H5Z_XFORM_SYMBOL), the convention is @@ -1113,15 +1120,15 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size * Return: Nothing * * Programmer: Leon Arber - * 5/1/04 + * 5/1/04 * *------------------------------------------------------------------------- */ static herr_t -H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result *res) +H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array_type, H5Z_result *res) { H5Z_result resl, resr; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1132,47 +1139,47 @@ H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array HDmemset(&resr, 0, sizeof(H5Z_result)); if (tree->type == H5Z_XFORM_INTEGER) { - res->type = H5Z_XFORM_INTEGER; - res->value.int_val = tree->value.int_val; + res->type = H5Z_XFORM_INTEGER; + res->value.int_val = tree->value.int_val; } /* end if */ else if (tree->type == H5Z_XFORM_FLOAT) { - res->type = H5Z_XFORM_FLOAT; - res->value.float_val = tree->value.float_val; + res->type = H5Z_XFORM_FLOAT; + res->value.float_val = tree->value.float_val; } /* end if */ else if (tree->type == H5Z_XFORM_SYMBOL) { - res->type = H5Z_XFORM_SYMBOL; + res->type = H5Z_XFORM_SYMBOL; - /*since dat_val stores the address of the array which is really stored in the dat_val_pointers, - * here we make dat_val store a pointer to the array itself instead of the address of it so that the - * rest of the code below works normally. */ - res->value.dat_val = *((void**)(tree->value.dat_val)); + /*since dat_val stores the address of the array which is really stored in the dat_val_pointers, + * here we make dat_val store a pointer to the array itself instead of the address of it so that the + * rest of the code below works normally. */ + res->value.dat_val = *((void **)(tree->value.dat_val)); } /* end if */ else { - if(tree->lchild && H5Z__xform_eval_full(tree->lchild, array_size, array_type, &resl) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - if(H5Z__xform_eval_full(tree->rchild, array_size, array_type, &resr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") - - res->type = H5Z_XFORM_SYMBOL; - - /* For each type of operation: - * 1. See if "x" is on left hand side, right hand side, or if both sides are "x" - * 2. Figure out what type of data we're going to be manipulating - * 3. Do the operation on the data. */ - switch (tree->type) { - case H5Z_XFORM_PLUS: + if (tree->lchild && H5Z__xform_eval_full(tree->lchild, array_size, array_type, &resl) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + if (H5Z__xform_eval_full(tree->rchild, array_size, array_type, &resr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform") + + res->type = H5Z_XFORM_SYMBOL; + + /* For each type of operation: + * 1. See if "x" is on left hand side, right hand side, or if both sides are "x" + * 2. Figure out what type of data we're going to be manipulating + * 3. Do the operation on the data. */ + switch (tree->type) { + case H5Z_XFORM_PLUS: H5Z_XFORM_TYPE_OP(resl, resr, array_type, +, array_size) break; - case H5Z_XFORM_MINUS: + case H5Z_XFORM_MINUS: H5Z_XFORM_TYPE_OP(resl, resr, array_type, -, array_size) break; - case H5Z_XFORM_MULT: + case H5Z_XFORM_MULT: H5Z_XFORM_TYPE_OP(resl, resr, array_type, *, array_size) break; - case H5Z_XFORM_DIVIDE: + case H5Z_XFORM_DIVIDE: H5Z_XFORM_TYPE_OP(resl, resr, array_type, /, array_size) break; @@ -1183,26 +1190,25 @@ H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array case H5Z_XFORM_LPAREN: case H5Z_XFORM_RPAREN: case H5Z_XFORM_END: - default: + default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid expression tree") - } /* end switch */ - - /* The result stores a pointer to the new data */ - /* So, if the left hand side got its data modified, the result stores a pointers - * to the left hand side's data, ditto for rhs */ - if(resl.type == H5Z_XFORM_SYMBOL) - res->value.dat_val = resl.value.dat_val; - else if(resr.type == H5Z_XFORM_SYMBOL) - res->value.dat_val = resr.value.dat_val; - else - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error during transform evaluation") + } /* end switch */ + + /* The result stores a pointer to the new data */ + /* So, if the left hand side got its data modified, the result stores a pointers + * to the left hand side's data, ditto for rhs */ + if (resl.type == H5Z_XFORM_SYMBOL) + res->value.dat_val = resl.value.dat_val; + else if (resr.type == H5Z_XFORM_SYMBOL) + res->value.dat_val = resr.value.dat_val; + else + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error during transform evaluation") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__xform_eval_full() */ - /*------------------------------------------------------------------------- * Function: H5Z_find_type * @@ -1213,81 +1219,66 @@ H5Z__xform_eval_full(H5Z_node *tree, const size_t array_size, const hid_t array *------------------------------------------------------------------------- */ static hid_t -H5Z__xform_find_type(const H5T_t* type) +H5Z__xform_find_type(const H5T_t *type) { - H5T_t *tmp; /* Temporary datatype */ - hid_t ret_value = SUCCEED; /* Return value */ + H5T_t *tmp; /* Temporary datatype */ + hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(type); /* Check for SHORT type */ - if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SHORT) + if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_SHORT) /* Check for INT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) - && 0 == H5T_cmp(type, tmp, FALSE)) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_INT) /* Check for LONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LONG) /* Check for LONGLONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LLONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LLONG) /* Check for UCHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UCHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_UCHAR) /* Check for CHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_CHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_CHAR) /* Check for SCHAR type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SCHAR) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_SCHAR) /* Check for USHORT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_USHORT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_USHORT) /* Check for UINT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UINT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_UINT) /* Check for ULONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_ULONG) /* Check for ULONGLONG type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULLONG) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_ULLONG) /* Check for FLOAT type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_FLOAT) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_FLOAT) /* Check for DOUBLE type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_DOUBLE) -#if H5_SIZEOF_LONG_DOUBLE !=0 + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_DOUBLE) +#if H5_SIZEOF_LONG_DOUBLE != 0 /* Check for LONGDOUBLE type */ - else if((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) - && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LDOUBLE) + else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) + HGOTO_DONE(H5T_NATIVE_LDOUBLE) #endif else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__xform_find_type() */ - /*------------------------------------------------------------------------- * Function: H5Z__xform_copy_tree * @@ -1302,59 +1293,53 @@ H5Z__xform_find_type(const H5T_t* type) *------------------------------------------------------------------------- */ static void * -H5Z__xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers) +H5Z__xform_copy_tree(H5Z_node *tree, H5Z_datval_ptrs *dat_val_pointers, H5Z_datval_ptrs *new_dat_val_pointers) { - H5Z_node* ret_value=NULL; + H5Z_node *ret_value = NULL; FUNC_ENTER_STATIC HDassert(tree); - if(tree->type == H5Z_XFORM_INTEGER) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + if (tree->type == H5Z_XFORM_INTEGER) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_INTEGER; - ret_value ->value.int_val = tree->value.int_val; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_INTEGER; + ret_value->value.int_val = tree->value.int_val; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if (tree->type == H5Z_XFORM_FLOAT) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + else if (tree->type == H5Z_XFORM_FLOAT) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_FLOAT; - ret_value ->value.float_val = tree->value.float_val; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_FLOAT; + ret_value->value.float_val = tree->value.float_val; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if(tree->type == H5Z_XFORM_SYMBOL) - { - if ((ret_value = (H5Z_node*) H5MM_malloc(sizeof(H5Z_node))) == NULL) + else if (tree->type == H5Z_XFORM_SYMBOL) { + if ((ret_value = (H5Z_node *)H5MM_malloc(sizeof(H5Z_node))) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Ran out of memory trying to copy parse tree") - else - { - ret_value -> type = H5Z_XFORM_SYMBOL; - - ret_value -> value.dat_val = &(new_dat_val_pointers->ptr_dat_val[new_dat_val_pointers->num_ptrs]); - new_dat_val_pointers->num_ptrs++; - ret_value -> lchild = NULL; - ret_value -> rchild = NULL; - } + else { + ret_value->type = H5Z_XFORM_SYMBOL; + + ret_value->value.dat_val = &(new_dat_val_pointers->ptr_dat_val[new_dat_val_pointers->num_ptrs]); + new_dat_val_pointers->num_ptrs++; + ret_value->lchild = NULL; + ret_value->rchild = NULL; + } } - else if(tree->type == H5Z_XFORM_MULT) + else if (tree->type == H5Z_XFORM_MULT) H5Z_XFORM_DO_OP4(H5Z_XFORM_MULT) - else if(tree->type == H5Z_XFORM_PLUS) + else if (tree->type == H5Z_XFORM_PLUS) H5Z_XFORM_DO_OP4(H5Z_XFORM_PLUS) - else if(tree->type == H5Z_XFORM_MINUS) + else if (tree->type == H5Z_XFORM_MINUS) H5Z_XFORM_DO_OP4(H5Z_XFORM_MINUS) - else if(tree->type == H5Z_XFORM_DIVIDE) + else if (tree->type == H5Z_XFORM_DIVIDE) H5Z_XFORM_DO_OP4(H5Z_XFORM_DIVIDE) else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error in parse tree while trying to copy") @@ -1363,7 +1348,6 @@ H5Z__xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datv FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__op_is_numbs * @@ -1378,7 +1362,7 @@ H5Z__xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datv *------------------------------------------------------------------------- */ static hbool_t -H5Z__op_is_numbs(H5Z_node* _tree) +H5Z__op_is_numbs(H5Z_node *_tree) { hbool_t ret_value = FALSE; @@ -1386,13 +1370,13 @@ H5Z__op_is_numbs(H5Z_node* _tree) HDassert(_tree); - if(((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT)) && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) - ret_value = TRUE; + if (((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT)) && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) + ret_value = TRUE; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__op_is_numbs2 * @@ -1409,7 +1393,7 @@ H5Z__op_is_numbs(H5Z_node* _tree) *------------------------------------------------------------------------- */ static hbool_t -H5Z__op_is_numbs2(H5Z_node* _tree) +H5Z__op_is_numbs2(H5Z_node *_tree) { hbool_t ret_value = FALSE; @@ -1417,14 +1401,17 @@ H5Z__op_is_numbs2(H5Z_node* _tree) HDassert(_tree); - if((!_tree->lchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) || - ((_tree->lchild && ((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT))) && (_tree->rchild && ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))))) - ret_value = TRUE; + if ((!_tree->lchild && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))) || + ((_tree->lchild && + ((_tree->lchild->type == H5Z_XFORM_INTEGER) || (_tree->lchild->type == H5Z_XFORM_FLOAT))) && + (_tree->rchild && + ((_tree->rchild->type == H5Z_XFORM_INTEGER) || (_tree->rchild->type == H5Z_XFORM_FLOAT))))) + ret_value = TRUE; FUNC_LEAVE_NOAPI(ret_value) } - /*------------------------------------------------------------------------- * Function: H5Z__xform_reduce_tree * @@ -1439,48 +1426,44 @@ H5Z__op_is_numbs2(H5Z_node* _tree) *------------------------------------------------------------------------- */ static void -H5Z__xform_reduce_tree(H5Z_node* tree) +H5Z__xform_reduce_tree(H5Z_node *tree) { FUNC_ENTER_STATIC_NOERR - if(tree) { - if((tree->type == H5Z_XFORM_DIVIDE) || (tree->type == H5Z_XFORM_MULT)) - { - if(H5Z__op_is_numbs(tree)) + if (tree) { + if ((tree->type == H5Z_XFORM_DIVIDE) || (tree->type == H5Z_XFORM_MULT)) { + if (H5Z__op_is_numbs(tree)) H5Z__do_op(tree); - else - { + else { H5Z__xform_reduce_tree(tree->lchild); - if(H5Z__op_is_numbs(tree)) + if (H5Z__op_is_numbs(tree)) H5Z__do_op(tree); else { H5Z__xform_reduce_tree(tree->rchild); - if(H5Z__op_is_numbs(tree)) + if (H5Z__op_is_numbs(tree)) H5Z__do_op(tree); } } - } else if((tree->type == H5Z_XFORM_PLUS) || (tree->type == H5Z_XFORM_MINUS)) { - if(H5Z__op_is_numbs2(tree)) + } + else if ((tree->type == H5Z_XFORM_PLUS) || (tree->type == H5Z_XFORM_MINUS)) { + if (H5Z__op_is_numbs2(tree)) H5Z__do_op(tree); - else - { + else { H5Z__xform_reduce_tree(tree->lchild); - if(H5Z__op_is_numbs2(tree)) + if (H5Z__op_is_numbs2(tree)) H5Z__do_op(tree); else { H5Z__xform_reduce_tree(tree->rchild); - if(H5Z__op_is_numbs2(tree)) + if (H5Z__op_is_numbs2(tree)) H5Z__do_op(tree); } } } - } FUNC_LEAVE_NOAPI_VOID; } - /*------------------------------------------------------------------------- * Function: H5Z__do_op * @@ -1498,23 +1481,22 @@ H5Z__xform_reduce_tree(H5Z_node* tree) *------------------------------------------------------------------------- */ static void -H5Z__do_op(H5Z_node* tree) +H5Z__do_op(H5Z_node *tree) { FUNC_ENTER_STATIC_NOERR - if(tree->type == H5Z_XFORM_DIVIDE) - H5Z_XFORM_DO_OP3(/) - else if(tree->type == H5Z_XFORM_MULT) - H5Z_XFORM_DO_OP3(*) - else if(tree->type == H5Z_XFORM_PLUS) - H5Z_XFORM_DO_OP6(+) - else if(tree->type == H5Z_XFORM_MINUS) - H5Z_XFORM_DO_OP6(-) + if (tree->type == H5Z_XFORM_DIVIDE) + H5Z_XFORM_DO_OP3(/) + else if (tree->type == H5Z_XFORM_MULT) + H5Z_XFORM_DO_OP3(*) + else if (tree->type == H5Z_XFORM_PLUS) + H5Z_XFORM_DO_OP6(+) + else if (tree->type == H5Z_XFORM_MINUS) + H5Z_XFORM_DO_OP6(-) FUNC_LEAVE_NOAPI_VOID; } - /*------------------------------------------------------------------------- * Function: H5Z_xform_create * @@ -1534,74 +1516,89 @@ H5Z_data_xform_t * H5Z_xform_create(const char *expr) { H5Z_data_xform_t *data_xform_prop = NULL; - unsigned int i; - unsigned int count = 0; - H5Z_data_xform_t *ret_value = NULL; /* Return value */ + unsigned int i; + unsigned int count = 0; + H5Z_data_xform_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) HDassert(expr); /* Allocate space for the data transform information */ - if(NULL == (data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) + if (NULL == (data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform info") - if(NULL == (data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform array storage") + if (NULL == (data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for data transform array storage") /* copy the user's string into the property */ - if(NULL == (data_xform_prop->xform_exp = (char *)H5MM_xstrdup(expr))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform expression") + if (NULL == (data_xform_prop->xform_exp = (char *)H5MM_xstrdup(expr))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for data transform expression") - /* Find the number of times "x" is used in this equation, and allocate room for storing that many points */ - for(i = 0; i < HDstrlen(expr); i++) - if(HDisalpha(expr[i])) - count++; + /* Find the number of times "x" is used in this equation, and allocate room for storing that many points + * A more sophisticated check is needed to support scientific notation. + */ + for (i = 0; i < HDstrlen(expr); i++) { + if (HDisalpha(expr[i])) { + if ((i > 0) && (i < (HDstrlen(expr) - 1))) { + if (((expr[i] == 'E') || (expr[i] == 'e')) && + (HDisdigit(expr[i - 1]) || (expr[i - 1] == '.')) && + (HDisdigit(expr[i + 1]) || (expr[i + 1] == '-') || (expr[i + 1] == '+'))) + continue; + } + + count++; + } + } /* When there are no "x"'s in the equation (ie, simple transform case), * we don't need to allocate any space since no array will have to be * stored */ - if(count > 0) - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array") + if (count > 0) + if (NULL == + (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate memory for pointers in transform array") /* Initialize the num_ptrs field, which will be used to keep track of the number of copies * of the data we have for polynomial transforms */ data_xform_prop->dat_val_pointers->num_ptrs = 0; - /* we generate the parse tree right here and store a pointer to its root in the property. */ - if((data_xform_prop->parse_root = (H5Z_node *)H5Z__xform_parse(expr, data_xform_prop->dat_val_pointers))==NULL) + /* we generate the parse tree right here and store a pointer to its root in the property. */ + if ((data_xform_prop->parse_root = + (H5Z_node *)H5Z__xform_parse(expr, data_xform_prop->dat_val_pointers)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to generate parse tree from expression") /* Sanity check * count should be the same num_ptrs */ - if(count != data_xform_prop->dat_val_pointers->num_ptrs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "error copying the parse tree, did not find correct number of \"variables\"") + if (count != data_xform_prop->dat_val_pointers->num_ptrs) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, + "error copying the parse tree, did not find correct number of \"variables\"") /* Assign return value */ - ret_value=data_xform_prop; - + ret_value = data_xform_prop; done: /* Clean up on error */ - if(ret_value==NULL) { - if(data_xform_prop) { - if(data_xform_prop->parse_root) + if (ret_value == NULL) { + if (data_xform_prop) { + if (data_xform_prop->parse_root) H5Z__xform_destroy_parse_tree(data_xform_prop->parse_root); - if(data_xform_prop->xform_exp) + if (data_xform_prop->xform_exp) H5MM_xfree(data_xform_prop->xform_exp); - if(count > 0 && data_xform_prop->dat_val_pointers->ptr_dat_val) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); - if(data_xform_prop->dat_val_pointers) - H5MM_xfree(data_xform_prop->dat_val_pointers); + if (count > 0 && data_xform_prop->dat_val_pointers->ptr_dat_val) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); + if (data_xform_prop->dat_val_pointers) + H5MM_xfree(data_xform_prop->dat_val_pointers); H5MM_xfree(data_xform_prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_create() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_destroy * @@ -1622,19 +1619,19 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if(data_xform_prop) { - /* Destroy the parse tree */ + if (data_xform_prop) { + /* Destroy the parse tree */ H5Z__xform_destroy_parse_tree(data_xform_prop->parse_root); /* Free the expression */ H5MM_xfree(data_xform_prop->xform_exp); - /* Free the pointers to the temp. arrays, if there are any */ - if(data_xform_prop->dat_val_pointers->num_ptrs > 0) - H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); + /* Free the pointers to the temp. arrays, if there are any */ + if (data_xform_prop->dat_val_pointers->num_ptrs > 0) + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val); - /* Free the data storage struct */ - H5MM_xfree(data_xform_prop->dat_val_pointers); + /* Free the data storage struct */ + H5MM_xfree(data_xform_prop->dat_val_pointers); /* Free the node */ H5MM_xfree(data_xform_prop); @@ -1643,7 +1640,6 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5Z_xform_destroy() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_copy * @@ -1666,66 +1662,75 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) herr_t H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) { - unsigned int i; - unsigned int count = 0; - H5Z_data_xform_t *new_data_xform_prop=NULL; - herr_t ret_value=SUCCEED; + unsigned int i; + unsigned int count = 0; + H5Z_data_xform_t *new_data_xform_prop = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - if(*data_xform_prop) { + if (*data_xform_prop) { /* Allocate new node */ - if(NULL == (new_data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) + if (NULL == (new_data_xform_prop = (H5Z_data_xform_t *)H5MM_calloc(sizeof(H5Z_data_xform_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform info") /* Copy string */ - if(NULL == (new_data_xform_prop->xform_exp = (char *)H5MM_xstrdup((*data_xform_prop)->xform_exp))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform expression") - - if(NULL == (new_data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform array storage") - - /* Find the number of times "x" is used in this equation, and allocate room for storing that many points */ - for(i = 0; i < HDstrlen(new_data_xform_prop->xform_exp); i++) - if(HDisalpha(new_data_xform_prop->xform_exp[i])) - count++; - - if(count > 0) - if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array") - - /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */ - new_data_xform_prop->dat_val_pointers->num_ptrs = 0; + if (NULL == (new_data_xform_prop->xform_exp = (char *)H5MM_xstrdup((*data_xform_prop)->xform_exp))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for data transform expression") + + if (NULL == + (new_data_xform_prop->dat_val_pointers = (H5Z_datval_ptrs *)H5MM_malloc(sizeof(H5Z_datval_ptrs)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for data transform array storage") + + /* Find the number of times "x" is used in this equation, and allocate room for storing that many + * points */ + for (i = 0; i < HDstrlen(new_data_xform_prop->xform_exp); i++) + if (HDisalpha(new_data_xform_prop->xform_exp[i])) + count++; + + if (count > 0) + if (NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = + (void **)H5MM_calloc(count * sizeof(void *)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate memory for pointers in transform array") + + /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right + * amount */ + new_data_xform_prop->dat_val_pointers->num_ptrs = 0; /* Copy parse tree */ - if((new_data_xform_prop->parse_root = (H5Z_node*)H5Z__xform_copy_tree((*data_xform_prop)->parse_root, (*data_xform_prop)->dat_val_pointers, new_data_xform_prop->dat_val_pointers)) == NULL) + if ((new_data_xform_prop->parse_root = (H5Z_node *)H5Z__xform_copy_tree( + (*data_xform_prop)->parse_root, (*data_xform_prop)->dat_val_pointers, + new_data_xform_prop->dat_val_pointers)) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree") - /* Sanity check - * count should be the same num_ptrs */ - if(count != new_data_xform_prop->dat_val_pointers->num_ptrs) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "error copying the parse tree, did not find correct number of \"variables\"") + /* Sanity check + * count should be the same num_ptrs */ + if (count != new_data_xform_prop->dat_val_pointers->num_ptrs) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "error copying the parse tree, did not find correct number of \"variables\"") /* Copy new information on top of old information */ - *data_xform_prop=new_data_xform_prop; + *data_xform_prop = new_data_xform_prop; } /* end if */ done: /* Clean up on error */ - if(ret_value<0) { - if(new_data_xform_prop) { - if(new_data_xform_prop->parse_root) + if (ret_value < 0) { + if (new_data_xform_prop) { + if (new_data_xform_prop->parse_root) H5Z__xform_destroy_parse_tree(new_data_xform_prop->parse_root); - if(new_data_xform_prop->xform_exp) + if (new_data_xform_prop->xform_exp) H5MM_xfree(new_data_xform_prop->xform_exp); H5MM_xfree(new_data_xform_prop); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_copy() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_noop * @@ -1744,21 +1749,20 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) hbool_t H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop) { - hbool_t ret_value = FALSE; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR - ret_value=(data_xform_prop ? FALSE : TRUE); + ret_value = (data_xform_prop ? FALSE : TRUE); FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_xform_noop() */ - /*------------------------------------------------------------------------- * Function: H5Z_xform_extract_xform_str * * Purpose: Extracts the pointer to the data transform strings from the - * data transform property.` + * data transform property.` * Return: * Pointer to a copy of the string in the data_xform property. * @@ -1780,4 +1784,3 @@ H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop) FUNC_LEAVE_NOAPI(data_xform_prop->xform_exp) } /* H5Z_xform_extract_xform_str() */ - diff --git a/src/H5api_adpt.h b/src/H5api_adpt.h index 0ff0f7481f2..53080b775ad 100644 --- a/src/H5api_adpt.h +++ b/src/H5api_adpt.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -19,236 +19,235 @@ #ifndef H5API_ADPT_H #define H5API_ADPT_H - /* This will only be defined if HDF5 was built with CMake */ #ifdef H5_BUILT_AS_DYNAMIC_LIB #if defined(hdf5_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLL __declspec(dllexport) - #define H5_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLL __attribute__ ((visibility("default"))) - #define H5_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLL __declspec(dllexport) +#define H5_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLL __attribute__((visibility("default"))) +#define H5_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLL __declspec(dllimport) - #define H5_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLL __attribute__ ((visibility("default"))) - #define H5_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLL __declspec(dllimport) +#define H5_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLL __attribute__((visibility("default"))) +#define H5_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_DLL - #define H5_DLL - #define H5_DLLVAR extern +#define H5_DLL +#define H5_DLLVAR extern #endif /* _HDF5DLL_ */ #if defined(hdf5_test_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TEST_DLL __declspec(dllexport) - #define H5TEST_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TEST_DLL __attribute__ ((visibility("default"))) - #define H5TEST_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TEST_DLL __declspec(dllexport) +#define H5TEST_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TEST_DLL __attribute__((visibility("default"))) +#define H5TEST_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TEST_DLL __declspec(dllimport) - #define H5TEST_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TEST_DLL __attribute__ ((visibility("default"))) - #define H5TEST_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TEST_DLL __declspec(dllimport) +#define H5TEST_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TEST_DLL __attribute__((visibility("default"))) +#define H5TEST_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5TEST_DLL - #define H5TEST_DLL - #define H5TEST_DLLVAR extern +#define H5TEST_DLL +#define H5TEST_DLLVAR extern #endif /* H5TEST_DLL */ #if defined(hdf5_tools_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TOOLS_DLL __declspec(dllexport) - #define H5TOOLS_DLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TOOLS_DLL __attribute__ ((visibility("default"))) - #define H5TOOLS_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TOOLS_DLL __declspec(dllexport) +#define H5TOOLS_DLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TOOLS_DLL __attribute__((visibility("default"))) +#define H5TOOLS_DLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5TOOLS_DLL __declspec(dllimport) - #define H5TOOLS_DLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5TOOLS_DLL __attribute__ ((visibility("default"))) - #define H5TOOLS_DLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5TOOLS_DLL __declspec(dllimport) +#define H5TOOLS_DLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5TOOLS_DLL __attribute__((visibility("default"))) +#define H5TOOLS_DLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5TOOLS_DLL - #define H5TOOLS_DLL - #define H5TOOLS_DLLVAR extern +#define H5TOOLS_DLL +#define H5TOOLS_DLLVAR extern #endif /* H5TOOLS_DLL */ #if defined(hdf5_cpp_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLLCPP __declspec(dllexport) - #define H5_DLLCPPVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLLCPP __attribute__ ((visibility("default"))) - #define H5_DLLCPPVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLLCPP __declspec(dllexport) +#define H5_DLLCPPVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLLCPP __attribute__((visibility("default"))) +#define H5_DLLCPPVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_DLLCPP __declspec(dllimport) - #define H5_DLLCPPVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_DLLCPP __attribute__ ((visibility("default"))) - #define H5_DLLCPPVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_DLLCPP __declspec(dllimport) +#define H5_DLLCPPVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_DLLCPP __attribute__((visibility("default"))) +#define H5_DLLCPPVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_DLLCPP - #define H5_DLLCPP - #define H5_DLLCPPVAR extern +#define H5_DLLCPP +#define H5_DLLCPPVAR extern #endif /* H5_DLLCPP */ #if defined(hdf5_hl_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLDLL __declspec(dllexport) - #define H5_HLDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLDLL __attribute__ ((visibility("default"))) - #define H5_HLDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLDLL __declspec(dllexport) +#define H5_HLDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLDLL __attribute__((visibility("default"))) +#define H5_HLDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLDLL __declspec(dllimport) - #define H5_HLDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLDLL __attribute__ ((visibility("default"))) - #define H5_HLDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLDLL __declspec(dllimport) +#define H5_HLDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLDLL __attribute__((visibility("default"))) +#define H5_HLDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_HLDLL - #define H5_HLDLL - #define H5_HLDLLVAR extern +#define H5_HLDLL +#define H5_HLDLLVAR extern #endif /* H5_HLDLL */ #if defined(hdf5_hl_cpp_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLCPPDLL __declspec(dllexport) - #define H5_HLCPPDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLCPPDLL __attribute__ ((visibility("default"))) - #define H5_HLCPPDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLCPPDLL __declspec(dllexport) +#define H5_HLCPPDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLCPPDLL __attribute__((visibility("default"))) +#define H5_HLCPPDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_HLCPPDLL __declspec(dllimport) - #define H5_HLCPPDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_HLCPPDLL __attribute__ ((visibility("default"))) - #define H5_HLCPPDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_HLCPPDLL __declspec(dllimport) +#define H5_HLCPPDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_HLCPPDLL __attribute__((visibility("default"))) +#define H5_HLCPPDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_HLCPPDLL - #define H5_HLCPPDLL - #define H5_HLCPPDLLVAR extern +#define H5_HLCPPDLL +#define H5_HLCPPDLLVAR extern #endif /* H5_HLCPPDLL */ #if defined(hdf5_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCDLL __declspec(dllexport) - #define H5_FCDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCDLL __attribute__ ((visibility("default"))) - #define H5_FCDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCDLL __declspec(dllexport) +#define H5_FCDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCDLL __attribute__((visibility("default"))) +#define H5_FCDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCDLL __declspec(dllimport) - #define H5_FCDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCDLL __attribute__ ((visibility("default"))) - #define H5_FCDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCDLL __declspec(dllimport) +#define H5_FCDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCDLL __attribute__((visibility("default"))) +#define H5_FCDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_FCDLL - #define H5_FCDLL - #define H5_FCDLLVAR extern +#define H5_FCDLL +#define H5_FCDLLVAR extern #endif /* H5_FCDLL */ #if defined(hdf5_test_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCTESTDLL __declspec(dllexport) - #define H5_FCTESTDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCTESTDLL __attribute__ ((visibility("default"))) - #define H5_FCTESTDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCTESTDLL __declspec(dllexport) +#define H5_FCTESTDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCTESTDLL __attribute__((visibility("default"))) +#define H5_FCTESTDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define H5_FCTESTDLL __declspec(dllimport) - #define H5_FCTESTDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define H5_FCTESTDLL __attribute__ ((visibility("default"))) - #define H5_FCTESTDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define H5_FCTESTDLL __declspec(dllimport) +#define H5_FCTESTDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define H5_FCTESTDLL __attribute__((visibility("default"))) +#define H5_FCTESTDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef H5_FCTESTDLL - #define H5_FCTESTDLL - #define H5_FCTESTDLLVAR extern +#define H5_FCTESTDLL +#define H5_FCTESTDLLVAR extern #endif /* H5_FCTESTDLL */ #if defined(hdf5_hl_f90cstub_shared_EXPORTS) - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define HDF5_HL_F90CSTUBDLL __declspec(dllexport) - #define HDF5_HL_F90CSTUBDLLVAR extern __declspec(dllexport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define HDF5_HL_F90CSTUBDLL __attribute__ ((visibility("default"))) - #define HDF5_HL_F90CSTUBDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define HDF5_HL_F90CSTUBDLL __declspec(dllexport) +#define HDF5_HL_F90CSTUBDLLVAR extern __declspec(dllexport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define HDF5_HL_F90CSTUBDLL __attribute__((visibility("default"))) +#define HDF5_HL_F90CSTUBDLLVAR extern __attribute__((visibility("default"))) +#endif #else - #if defined (_MSC_VER) /* MSVC Compiler Case */ - #define HDF5_HL_F90CSTUBDLL __declspec(dllimport) - #define HDF5_HL_F90CSTUBDLLVAR __declspec(dllimport) - #elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ - #define HDF5_HL_F90CSTUBDLL __attribute__ ((visibility("default"))) - #define HDF5_HL_F90CSTUBDLLVAR extern __attribute__ ((visibility("default"))) - #endif +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define HDF5_HL_F90CSTUBDLL __declspec(dllimport) +#define HDF5_HL_F90CSTUBDLLVAR __declspec(dllimport) +#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define HDF5_HL_F90CSTUBDLL __attribute__((visibility("default"))) +#define HDF5_HL_F90CSTUBDLLVAR extern __attribute__((visibility("default"))) +#endif #endif #ifndef HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLLVAR extern +#define HDF5_HL_F90CSTUBDLL +#define HDF5_HL_F90CSTUBDLLVAR extern #endif /* HDF5_HL_F90CSTUBDLL */ #else - #define H5_DLL - #define H5_DLLVAR extern - #define H5TEST_DLL - #define H5TEST_DLLVAR extern - #define H5TOOLS_DLL - #define H5TOOLS_DLLVAR extern - #define H5_DLLCPP - #define H5_DLLCPPVAR extern - #define H5_HLDLL - #define H5_HLDLLVAR extern - #define H5_HLCPPDLL - #define H5_HLCPPDLLVAR extern - #define H5_FCDLL - #define H5_FCDLLVAR extern - #define H5_FCTESTDLL - #define H5_FCTESTDLLVAR extern - #define HDF5_HL_F90CSTUBDLL - #define HDF5_HL_F90CSTUBDLLVAR extern +#define H5_DLL +#define H5_DLLVAR extern +#define H5TEST_DLL +#define H5TEST_DLLVAR extern +#define H5TOOLS_DLL +#define H5TOOLS_DLLVAR extern +#define H5_DLLCPP +#define H5_DLLCPPVAR extern +#define H5_HLDLL +#define H5_HLDLLVAR extern +#define H5_HLCPPDLL +#define H5_HLCPPDLLVAR extern +#define H5_FCDLL +#define H5_FCDLLVAR extern +#define H5_FCTESTDLL +#define H5_FCTESTDLLVAR extern +#define HDF5_HL_F90CSTUBDLL +#define HDF5_HL_F90CSTUBDLLVAR extern #endif /* H5_BUILT_AS_DYNAMIC_LIB */ #endif /* H5API_ADPT_H */ diff --git a/src/H5checksum.c b/src/H5checksum.c index a9d2b4e2954..0cd7745a5e2 100644 --- a/src/H5checksum.c +++ b/src/H5checksum.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,13 +25,12 @@ /****************/ /* Module Setup */ /****************/ - +#include "H5module.h" /* This source code file is part of the H5 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ @@ -41,32 +40,26 @@ /* (same as the IEEE 802.3 (Ethernet) quotient) */ #define H5_CRC_QUOTIENT 0x04C11DB7 - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -77,8 +70,6 @@ static uint32_t H5_crc_table[256]; /* Flag: has the table been computed? */ static hbool_t H5_crc_table_computed = FALSE; - - /*------------------------------------------------------------------------- * Function: H5_checksum_fletcher32 * @@ -109,9 +100,9 @@ static hbool_t H5_crc_table_computed = FALSE; uint32_t H5_checksum_fletcher32(const void *_data, size_t _len) { - const uint8_t *data = (const uint8_t *)_data; /* Pointer to the data to be summed */ - size_t len = _len / 2; /* Length in 16-bit words */ - uint32_t sum1 = 0, sum2 = 0; + const uint8_t *data = (const uint8_t *)_data; /* Pointer to the data to be summed */ + size_t len = _len / 2; /* Length in 16-bit words */ + uint32_t sum1 = 0, sum2 = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -136,7 +127,7 @@ H5_checksum_fletcher32(const void *_data, size_t _len) } /* Check for odd # of bytes */ - if(_len % 2) { + if (_len % 2) { sum1 += (uint32_t)(((uint16_t)*data) << 8); sum2 += sum1; sum1 = (sum1 & 0xffff) + (sum1 >> 16); @@ -150,7 +141,6 @@ H5_checksum_fletcher32(const void *_data, size_t _len) FUNC_LEAVE_NOAPI((sum2 << 16) | sum1) } /* end H5_checksum_fletcher32() */ - /*------------------------------------------------------------------------- * Function: H5__checksum_crc_make_table * @@ -166,16 +156,16 @@ H5_checksum_fletcher32(const void *_data, size_t _len) static void H5__checksum_crc_make_table(void) { - uint32_t c; /* Checksum for each byte value */ - unsigned n, k; /* Local index variables */ + uint32_t c; /* Checksum for each byte value */ + unsigned n, k; /* Local index variables */ FUNC_ENTER_STATIC_NOERR /* Compute the checksum for each possible byte value */ - for(n = 0; n < 256; n++) { - c = (uint32_t) n; - for(k = 0; k < 8; k++) - if(c & 1) + for (n = 0; n < 256; n++) { + c = (uint32_t)n; + for (k = 0; k < 8; k++) + if (c & 1) c = H5_CRC_QUOTIENT ^ (c >> 1); else c = c >> 1; @@ -186,7 +176,6 @@ H5__checksum_crc_make_table(void) FUNC_LEAVE_NOAPI_VOID } /* end H5__checksum_crc_make_table() */ - /*------------------------------------------------------------------------- * Function: H5__checksum_crc_update * @@ -205,22 +194,21 @@ H5__checksum_crc_make_table(void) static uint32_t H5__checksum_crc_update(uint32_t crc, const uint8_t *buf, size_t len) { - size_t n; /* Local index variable */ + size_t n; /* Local index variable */ FUNC_ENTER_STATIC_NOERR /* Initialize the CRC table if necessary */ - if(!H5_crc_table_computed) + if (!H5_crc_table_computed) H5__checksum_crc_make_table(); /* Update the CRC with the results from this buffer */ - for(n = 0; n < len; n++) + for (n = 0; n < len; n++) crc = H5_crc_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); FUNC_LEAVE_NOAPI(crc) } /* end H5__checksum_crc_update() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_crc * @@ -247,7 +235,8 @@ H5_checksum_crc(const void *_data, size_t len) HDassert(_data); HDassert(len > 0); - FUNC_LEAVE_NOAPI(H5__checksum_crc_update((uint32_t)0xffffffffL, (const uint8_t *)_data, len) ^ 0xffffffffL) + FUNC_LEAVE_NOAPI(H5__checksum_crc_update((uint32_t)0xffffffffL, (const uint8_t *)_data, len) ^ + 0xffffffffL) } /* end H5_checksum_crc() */ /* @@ -294,16 +283,28 @@ on, and rotates are much kinder to the top and bottom bits, so I used rotates. ------------------------------------------------------------------------------- */ -#define H5_lookup3_rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k)))) -#define H5_lookup3_mix(a,b,c) \ -{ \ - a -= c; a ^= H5_lookup3_rot(c, 4); c += b; \ - b -= a; b ^= H5_lookup3_rot(a, 6); a += c; \ - c -= b; c ^= H5_lookup3_rot(b, 8); b += a; \ - a -= c; a ^= H5_lookup3_rot(c,16); c += b; \ - b -= a; b ^= H5_lookup3_rot(a,19); a += c; \ - c -= b; c ^= H5_lookup3_rot(b, 4); b += a; \ -} +#define H5_lookup3_rot(x, k) (((x) << (k)) ^ ((x) >> (32 - (k)))) +#define H5_lookup3_mix(a, b, c) \ + { \ + a -= c; \ + a ^= H5_lookup3_rot(c, 4); \ + c += b; \ + b -= a; \ + b ^= H5_lookup3_rot(a, 6); \ + a += c; \ + c -= b; \ + c ^= H5_lookup3_rot(b, 8); \ + b += a; \ + a -= c; \ + a ^= H5_lookup3_rot(c, 16); \ + c += b; \ + b -= a; \ + b ^= H5_lookup3_rot(a, 19); \ + a += c; \ + c -= b; \ + c ^= H5_lookup3_rot(b, 4); \ + b += a; \ + } /* ------------------------------------------------------------------------------- @@ -330,16 +331,23 @@ and these came close: 11 8 15 26 3 22 24 ------------------------------------------------------------------------------- */ -#define H5_lookup3_final(a,b,c) \ -{ \ - c ^= b; c -= H5_lookup3_rot(b,14); \ - a ^= c; a -= H5_lookup3_rot(c,11); \ - b ^= a; b -= H5_lookup3_rot(a,25); \ - c ^= b; c -= H5_lookup3_rot(b,16); \ - a ^= c; a -= H5_lookup3_rot(c,4); \ - b ^= a; b -= H5_lookup3_rot(a,14); \ - c ^= b; c -= H5_lookup3_rot(b,24); \ -} +#define H5_lookup3_final(a, b, c) \ + { \ + c ^= b; \ + c -= H5_lookup3_rot(b, 14); \ + a ^= c; \ + a -= H5_lookup3_rot(c, 11); \ + b ^= a; \ + b -= H5_lookup3_rot(a, 25); \ + c ^= b; \ + c -= H5_lookup3_rot(b, 16); \ + a ^= c; \ + a -= H5_lookup3_rot(c, 4); \ + b ^= a; \ + b -= H5_lookup3_rot(a, 14); \ + c ^= b; \ + c -= H5_lookup3_rot(b, 24); \ + } /* ------------------------------------------------------------------------------- @@ -372,7 +380,7 @@ uint32_t H5_checksum_lookup3(const void *key, size_t length, uint32_t initval) { const uint8_t *k = (const uint8_t *)key; - uint32_t a, b, c; /* internal state */ + uint32_t a, b, c = 0; /* internal state */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -384,53 +392,76 @@ H5_checksum_lookup3(const void *key, size_t length, uint32_t initval) a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - a += ((uint32_t)k[1])<<8; - a += ((uint32_t)k[2])<<16; - a += ((uint32_t)k[3])<<24; - b += k[4]; - b += ((uint32_t)k[5])<<8; - b += ((uint32_t)k[6])<<16; - b += ((uint32_t)k[7])<<24; - c += k[8]; - c += ((uint32_t)k[9])<<8; - c += ((uint32_t)k[10])<<16; - c += ((uint32_t)k[11])<<24; - H5_lookup3_mix(a, b, c); - length -= 12; - k += 12; + while (length > 12) { + a += k[0]; + a += ((uint32_t)k[1]) << 8; + a += ((uint32_t)k[2]) << 16; + a += ((uint32_t)k[3]) << 24; + b += k[4]; + b += ((uint32_t)k[5]) << 8; + b += ((uint32_t)k[6]) << 16; + b += ((uint32_t)k[7]) << 24; + c += k[8]; + c += ((uint32_t)k[9]) << 8; + c += ((uint32_t)k[10]) << 16; + c += ((uint32_t)k[11]) << 24; + H5_lookup3_mix(a, b, c); + length -= 12; + k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ + switch (length) /* all the case statements fall through */ { - case 12: c+=((uint32_t)k[11])<<24; - H5_ATTR_FALLTHROUGH - case 11: c+=((uint32_t)k[10])<<16; - H5_ATTR_FALLTHROUGH - case 10: c+=((uint32_t)k[9])<<8; - H5_ATTR_FALLTHROUGH - case 9 : c+=k[8]; - H5_ATTR_FALLTHROUGH - case 8 : b+=((uint32_t)k[7])<<24; - H5_ATTR_FALLTHROUGH - case 7 : b+=((uint32_t)k[6])<<16; - H5_ATTR_FALLTHROUGH - case 6 : b+=((uint32_t)k[5])<<8; - H5_ATTR_FALLTHROUGH - case 5 : b+=k[4]; - H5_ATTR_FALLTHROUGH - case 4 : a+=((uint32_t)k[3])<<24; - H5_ATTR_FALLTHROUGH - case 3 : a+=((uint32_t)k[2])<<16; - H5_ATTR_FALLTHROUGH - case 2 : a+=((uint32_t)k[1])<<8; - H5_ATTR_FALLTHROUGH - case 1 : a+=k[0]; - break; - case 0 : goto done; + case 12: + c += ((uint32_t)k[11]) << 24; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 11: + c += ((uint32_t)k[10]) << 16; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 10: + c += ((uint32_t)k[9]) << 8; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 9: + c += k[8]; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 8: + b += ((uint32_t)k[7]) << 24; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 7: + b += ((uint32_t)k[6]) << 16; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 6: + b += ((uint32_t)k[5]) << 8; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 5: + b += k[4]; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 4: + a += ((uint32_t)k[3]) << 24; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 3: + a += ((uint32_t)k[2]) << 16; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 2: + a += ((uint32_t)k[1]) << 8; + /* FALLTHROUGH */ + H5_ATTR_FALLTHROUGH + case 1: + a += k[0]; + break; + case 0: + goto done; default: HDassert(0 && "This Should never be executed!"); } @@ -441,7 +472,6 @@ H5_checksum_lookup3(const void *key, size_t length, uint32_t initval) FUNC_LEAVE_NOAPI(c) } /* end H5_checksum_lookup3() */ - /*------------------------------------------------------------------------- * Function: H5_checksum_metadata * @@ -470,7 +500,6 @@ H5_checksum_metadata(const void *data, size_t len, uint32_t initval) FUNC_LEAVE_NOAPI(H5_checksum_lookup3(data, len, initval)) } /* end H5_checksum_metadata() */ - /*------------------------------------------------------------------------- * Function: H5_hash_string * @@ -490,16 +519,15 @@ uint32_t H5_hash_string(const char *str) { uint32_t hash = 5381; - int c; + int c; FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(str); - while((c = *str++)) + while ((c = *str++)) hash = ((hash << 5) + hash) + (uint32_t)c; /* hash * 33 + c */ FUNC_LEAVE_NOAPI(hash) } /* end H5_hash_string() */ - diff --git a/src/H5config.h.in b/src/H5config.h.in index 24d802c03ec..d4ec65d4201 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -245,6 +245,9 @@ /* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT +/* Define if the map API (H5M) should be compiled */ +#undef HAVE_MAP_API + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -659,6 +662,9 @@ /* Define using v1.10 public API symbols by default */ #undef USE_110_API_DEFAULT +/* Define using v1.12 public API symbols by default */ +#undef USE_112_API_DEFAULT + /* Define using v1.6 public API symbols by default */ #undef USE_16_API_DEFAULT @@ -668,6 +674,9 @@ /* Define if the library will use file locking */ #undef USE_FILE_LOCKING +/* Define if the library will use recursive RW locks for thread safety */ +#undef USE_RECURSIVE_RW_LOCKS + /* Define if a memory checking tool will be used on the library, to cause library to be very picky about memory operations and also disable the internal free list manager code. */ diff --git a/src/H5dbg.c b/src/H5dbg.c index 819653d64ac..5af65257803 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,43 +25,37 @@ /****************/ /* Module Setup */ /****************/ +#include "H5module.h" /* This source code file is part of the H5 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_buffer_dump * @@ -75,10 +69,10 @@ *------------------------------------------------------------------------- */ herr_t -H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, - const uint8_t *marker, size_t buf_offset, size_t buf_size) +H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *marker, size_t buf_offset, + size_t buf_size) { - size_t u, v; /* Local index variable */ + size_t u, v; /* Local index variable */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -94,47 +88,46 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, /* * Print the buffer in a VMS-style octal dump. */ - HDfprintf(stream, "%*sData follows (`__' indicates free region)...\n", - indent, ""); - for(u = 0; u < buf_size; u += 16) { - uint8_t c; + HDfprintf(stream, "%*sData follows (`__' indicates free region)...\n", indent, ""); + for (u = 0; u < buf_size; u += 16) { + uint8_t c; - HDfprintf(stream, "%*s %8d: ", indent, "", u + buf_offset); + HDfprintf(stream, "%*s %8zu: ", indent, "", u + buf_offset); /* Print the hex values */ - for(v = 0; v < 16; v++) { - if(u + v < buf_size) { - if(marker[u + v]) + for (v = 0; v < 16; v++) { + if (u + v < buf_size) { + if (marker[u + v]) HDfprintf(stream, "__ "); else { c = buf[buf_offset + u + v]; HDfprintf(stream, "%02x ", c); } /* end else */ - } /* end if */ + } /* end if */ else HDfprintf(stream, " "); - if(7 == v) + if (7 == v) HDfputc(' ', stream); } /* end for */ HDfputc(' ', stream); /* Print the character values */ - for(v = 0; v < 16; v++) { - if(u + v < buf_size) { - if(marker[u + v]) + for (v = 0; v < 16; v++) { + if (u + v < buf_size) { + if (marker[u + v]) HDfputc(' ', stream); else { c = buf[buf_offset + u + v]; - if(HDisprint(c)) + if (HDisprint(c)) HDfputc(c, stream); else HDfputc('.', stream); } /* end else */ - } /* end if */ + } /* end if */ - if(7 == v) + if (7 == v) HDfputc(' ', stream); } /* end for */ @@ -143,4 +136,3 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5_buffer_dump() */ - diff --git a/src/H5detect.c b/src/H5detect.c index 85f1f90e986..e4fe4538a83 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,7 +21,7 @@ static const char *FileHeader = "\n\ * This file is part of HDF5. The full HDF5 copyright notice, including *\n\ * terms governing use, modification, and redistribution, is contained in *\n\ * the COPYING file, which can be found at the root of the source code *\n\ - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *\n\ + * distribution tree, or in https://www.hdfgroup.org/licenses. *\n\ * If you do not have access to either file, you may request a copy from *\n\ * help@hdfgroup.org. *\n\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; @@ -52,16 +52,16 @@ static const char *FileHeader = "\n\ /* Disable warning about cast increasing the alignment of the target type, * that's _exactly_ what this code is probing. -QAK */ -H5_GCC_DIAG_OFF(cast-align) +H5_GCC_DIAG_OFF("cast-align") #if defined(__has_attribute) -# if __has_attribute(no_sanitize_address) -# define HDF_NO_UBSAN __attribute__((no_sanitize_address)) -# else -# define HDF_NO_UBSAN -# endif +#if __has_attribute(no_sanitize_address) +#define HDF_NO_UBSAN __attribute__((no_sanitize_address)) #else -# define HDF_NO_UBSAN +#define HDF_NO_UBSAN +#endif +#else +#define HDF_NO_UBSAN #endif #define MAXDETECT 64 @@ -76,80 +76,79 @@ H5_GCC_DIAG_OFF(cast-align) /* supported. */ #if defined(H5_HAVE_SIGSETJMP) && defined(H5_HAVE_SIGLONGJMP) /* Always save blocked signals to be restored by siglongjmp. */ -#define H5JMP_BUF sigjmp_buf -#define H5SETJMP(buf) HDsigsetjmp(buf, 1) -#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val) -#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */ +#define H5JMP_BUF sigjmp_buf +#define H5SETJMP(buf) HDsigsetjmp(buf, 1) +#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val) +#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */ #elif defined(H5_HAVE_LONGJMP) -#define H5JMP_BUF jmp_buf -#define H5SETJMP(buf) HDsetjmp(buf) -#define H5LONGJMP(buf, val) HDlongjmp(buf, val) +#define H5JMP_BUF jmp_buf +#define H5SETJMP(buf) HDsetjmp(buf) +#define H5LONGJMP(buf, val) HDlongjmp(buf, val) #endif /* ALIGNMENT and signal-handling status codes */ -#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */ -#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */ - +#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */ +#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */ /* * This structure holds information about a type that * was detected. */ typedef struct detected_t { - const char *varname; - unsigned int size; /* total byte size */ - unsigned int precision; /* meaningful bits */ - unsigned int offset; /* bit offset to meaningful bits */ - int perm[32]; /* for detection of byte order */ - hbool_t is_vax; /* for vax (float & double) only */ - unsigned int sign; /* location of sign bit */ - unsigned int mpos, msize, imp; /* information about mantissa */ - unsigned int epos, esize; /* information about exponent */ - unsigned long bias; /* exponent bias for floating pt */ - unsigned int align; /* required byte alignment */ - unsigned int comp_align; /* alignment for structure */ + const char * varname; + unsigned int size; /* total byte size */ + unsigned int precision; /* meaningful bits */ + unsigned int offset; /* bit offset to meaningful bits */ + int perm[32]; /* for detection of byte order */ + hbool_t is_vax; /* for vax (float & double) only */ + unsigned int sign; /* location of sign bit */ + unsigned int mpos, msize, imp; /* information about mantissa */ + unsigned int epos, esize; /* information about exponent */ + unsigned long bias; /* exponent bias for floating pt */ + unsigned int align; /* required byte alignment */ + unsigned int comp_align; /* alignment for structure */ } detected_t; -/* This structure holds structure alignment for pointers, hvl_t, hobj_ref_t, - * hdset_reg_ref_t */ +/* This structure holds structure alignment for pointers, vlen and reference + * types. */ typedef struct malign_t { - const char *name; - unsigned int comp_align; /* alignment for structure */ + const char * name; + unsigned int comp_align; /* alignment for structure */ } malign_t; -FILE *rawoutstream = NULL; +FILE *rawoutstream = NULL; /* global variables types detection code */ -H5_GCC_DIAG_OFF(larger-than=) +H5_GCC_DIAG_OFF("larger-than=") static detected_t d_g[MAXDETECT]; -H5_GCC_DIAG_ON(larger-than=) -static malign_t m_g[MAXDETECT]; +H5_GCC_DIAG_ON("larger-than=") +static malign_t m_g[MAXDETECT]; static volatile int nd_g = 0, na_g = 0; -static void print_results(int nd, detected_t *d, int na, malign_t *m); -static void iprint(detected_t *); -static int byte_cmp(int, const void *, const void *, const unsigned char *); +static void print_results(int nd, detected_t *d, int na, malign_t *m); +static void iprint(detected_t *); +static int byte_cmp(int, const void *, const void *, const unsigned char *); static unsigned int bit_cmp(unsigned int, int *, void *, void *, const unsigned char *); -static void fix_order(int, int, int *, const char **); +static void fix_order(int, int, int *, const char **); static unsigned int imp_bit(unsigned int, int *, void *, void *, const unsigned char *); static unsigned int find_bias(unsigned int, unsigned int, int *, void *); -static void precision (detected_t*); -static void print_header(void); -static void detect_C89_integers(void); -static void detect_C89_floats(void); -static void detect_C99_integers(void); -static void detect_C99_floats(void); -static void detect_C99_integers8(void); -static void detect_C99_integers16(void); -static void detect_C99_integers32(void); -static void detect_C99_integers64(void); -static void detect_alignments(void); -static unsigned int align_g[] = {1, 2, 4, 8, 16}; -static int align_status_g = 0; /* ALIGNMENT Signal Status */ -static int sigbus_handler_called_g = 0; /* how many times called */ -static int sigsegv_handler_called_g = 0; /* how many times called */ -static int sigill_handler_called_g = 0; /* how many times called */ -static int signal_handler_tested_g = 0; /* how many times tested */ +static void precision(detected_t *); +static void print_header(void); +static void detect_C89_integers(void); +static void detect_C89_floats(void); +static void detect_C99_integers(void); +static void detect_C99_floats(void); +static void detect_C99_integers8(void); +static void detect_C99_integers16(void); +static void detect_C99_integers32(void); +static void detect_C99_integers64(void); +static void detect_alignments(void); +static unsigned int align_g[] = {1, 2, 4, 8, 16}; +static int align_status_g = 0; /* ALIGNMENT Signal Status */ +static int sigbus_handler_called_g = 0; /* how many times called */ +static int sigsegv_handler_called_g = 0; /* how many times called */ +static int sigill_handler_called_g = 0; /* how many times called */ +static int signal_handler_tested_g = 0; /* how many times tested */ #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) static int verify_signal_handlers(int signum, void (*handler)(int)); #endif @@ -157,8 +156,6 @@ static int verify_signal_handlers(int signum, void (*handler)(int)); static H5JMP_BUF jbuf_g; #endif - - /*------------------------------------------------------------------------- * Function: precision * @@ -168,50 +165,49 @@ static H5JMP_BUF jbuf_g; *------------------------------------------------------------------------- */ static void -precision (detected_t *d) +precision(detected_t *d) { unsigned int n; - if(0 == d->msize) { + if (0 == d->msize) { /* * An integer. The permutation can have negative values at the * beginning or end which represent padding of bytes. We must adjust * the precision and offset accordingly. */ - if(d->perm[0] < 0) { + if (d->perm[0] < 0) { /* * Lower addresses are padded. */ - for(n = 0; n < d->size && d->perm[n] < 0; n++) + for (n = 0; n < d->size && d->perm[n] < 0; n++) /*void*/; d->precision = 8 * (d->size - n); - d->offset = 0; + d->offset = 0; } - else if(d->perm[d->size - 1] < 0) { + else if (d->perm[d->size - 1] < 0) { /* * Higher addresses are padded. */ for (n = 0; n < d->size && d->perm[d->size - (n + 1)]; n++) /*void*/; d->precision = 8 * (d->size - n); - d->offset = 8 * n; + d->offset = 8 * n; } else { /* * No padding. */ d->precision = 8 * d->size; - d->offset = 0; + d->offset = 0; } } else { /* A floating point */ - d->offset = MIN3(d->mpos, d->epos, d->sign); + d->offset = MIN3(d->mpos, d->epos, d->sign); d->precision = d->msize + d->esize + 1; } } - /*------------------------------------------------------------------------- * Function: DETECT_I/DETECT_BYTE * @@ -226,47 +222,49 @@ precision (detected_t *d) * *------------------------------------------------------------------------- */ -#define DETECT_I_BYTE_CORE(TYPE,VAR,INFO,DETECT_TYPE) { \ - DETECT_TYPE _v; \ - int _i, _j; \ - unsigned char *_x; \ - \ - HDmemset(&INFO, 0, sizeof(INFO)); \ - INFO.varname = #VAR; \ - INFO.size = sizeof(TYPE); \ - \ - for(_i = sizeof(DETECT_TYPE), _v = 0; _i > 0; --_i) \ - _v = (DETECT_TYPE) ((DETECT_TYPE) (_v << 8) + (DETECT_TYPE) _i); \ - \ - for(_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(DETECT_TYPE); _i++) { \ - _j = (*_x++) - 1; \ - HDassert(_j < (signed)sizeof(DETECT_TYPE)); \ - INFO.perm[_i] = _j; \ - } /* end for */ \ - \ - INFO.sign = ('U' != *(#VAR)); \ - precision (&(INFO)); \ - ALIGNMENT(TYPE, INFO); \ - if(!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \ - !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \ - !HDstrcmp(INFO.varname, "LLONG")) { \ - COMP_ALIGNMENT(TYPE, INFO.comp_align); \ - } \ -} +#define DETECT_I_BYTE_CORE(TYPE, VAR, INFO, DETECT_TYPE) \ + { \ + DETECT_TYPE _v; \ + int _i, _j; \ + unsigned char *_x; \ + \ + HDmemset(&INFO, 0, sizeof(INFO)); \ + INFO.varname = #VAR; \ + INFO.size = sizeof(TYPE); \ + \ + for (_i = sizeof(DETECT_TYPE), _v = 0; _i > 0; --_i) \ + _v = (DETECT_TYPE)((DETECT_TYPE)(_v << 8) + (DETECT_TYPE)_i); \ + \ + for (_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(DETECT_TYPE); _i++) { \ + _j = (*_x++) - 1; \ + HDassert(_j < (signed)sizeof(DETECT_TYPE)); \ + INFO.perm[_i] = _j; \ + } /* end for */ \ + \ + INFO.sign = ('U' != *(#VAR)); \ + precision(&(INFO)); \ + ALIGNMENT(TYPE, INFO); \ + if (!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \ + !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \ + !HDstrcmp(INFO.varname, "LLONG")) { \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } \ + } -#define DETECT_BYTE(TYPE,VAR,INFO) { \ - HDcompile_assert(sizeof(TYPE) == 1); \ - \ - DETECT_I_BYTE_CORE(TYPE,VAR,INFO,int) \ -} +#define DETECT_BYTE(TYPE, VAR, INFO) \ + { \ + HDcompile_assert(sizeof(TYPE) == 1); \ + \ + DETECT_I_BYTE_CORE(TYPE, VAR, INFO, int) \ + } -#define DETECT_I(TYPE,VAR,INFO) { \ - HDcompile_assert(sizeof(TYPE) > 1); \ - \ - DETECT_I_BYTE_CORE(TYPE,VAR,INFO,TYPE) \ -} +#define DETECT_I(TYPE, VAR, INFO) \ + { \ + HDcompile_assert(sizeof(TYPE) > 1); \ + \ + DETECT_I_BYTE_CORE(TYPE, VAR, INFO, TYPE) \ + } - /*------------------------------------------------------------------------- * Function: DETECT_F * @@ -277,169 +275,176 @@ precision (detected_t *d) * initializes a detected_t structure with those properties. *------------------------------------------------------------------------- */ -#define DETECT_F(TYPE,VAR,INFO) { \ - TYPE _v1, _v2, _v3; \ - unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \ - unsigned char _pad_mask[sizeof(TYPE)]; \ - unsigned char _byte_mask; \ - int _i, _j, _last = (-1); \ - const char *_mesg; \ - \ - HDmemset(&INFO, 0, sizeof(INFO)); \ - INFO.varname = #VAR; \ - INFO.size = sizeof(TYPE); \ - \ - /* Initialize padding mask */ \ - HDmemset(_pad_mask, 0, sizeof(_pad_mask)); \ - \ - /* Padding bits. Set a variable to 4.0, then flip each bit and see if \ - * the modified variable is equal ("==") to the original. Build a \ - * padding bitmask to indicate which bits in the type are padding (i.e. \ - * have no effect on the value and should be ignored by subsequent \ - * steps). This is necessary because padding bits can change arbitrarily \ - * and interfere with detection of the various properties below unless we \ - * know to ignore them. */ \ - _v1 = (TYPE)4.0L; \ - HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ - for(_i = 0; _i < (int)sizeof(TYPE); _i++) \ - for(_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char) (_byte_mask << 1)) { \ - _buf1[_i] ^= _byte_mask; \ - HDmemcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \ - H5_GCC_DIAG_OFF(float-equal) \ - if(_v1 != _v2) \ - _pad_mask[_i] |= _byte_mask; \ - H5_GCC_DIAG_ON(float-equal) \ - _buf1[_i] ^= _byte_mask; \ - } /* end for */ \ - \ - /* Byte Order */ \ - for(_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \ - _v3 = _v1; \ - _v1 += _v2; \ - _v2 /= (TYPE)256.0L; \ - HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ - HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ - _j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \ - if(_j >= 0) { \ - INFO.perm[_i] = _j; \ - _last = _i; \ - } \ - } \ - fix_order(sizeof(TYPE), _last, INFO.perm, (const char**)&_mesg); \ - \ - if(!HDstrcmp(_mesg, "VAX")) \ - INFO.is_vax = TRUE; \ - \ - /* Implicit mantissa bit */ \ - _v1 = (TYPE)0.5L; \ - _v2 = (TYPE)1.0L; \ - INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - \ - /* Sign bit */ \ - _v1 = (TYPE)1.0L; \ - _v2 = (TYPE)-1.0L; \ - INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - \ - /* Mantissa */ \ - INFO.mpos = 0; \ - \ - _v1 = (TYPE)1.0L; \ - _v2 = (TYPE)1.5L; \ - INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ - INFO.msize += 1 + (unsigned int) (INFO.imp ? 0 : 1) - INFO.mpos; \ - \ - /* Exponent */ \ - INFO.epos = INFO.mpos + INFO.msize; \ - \ - INFO.esize = INFO.sign - INFO.epos; \ - \ - _v1 = (TYPE)1.0L; \ - INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.perm, &_v1); \ - precision (&(INFO)); \ - ALIGNMENT(TYPE, INFO); \ - if(!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ - !HDstrcmp(INFO.varname, "LDOUBLE")) { \ - COMP_ALIGNMENT(TYPE,INFO.comp_align); \ - } \ -} +#define DETECT_F(TYPE, VAR, INFO) \ + { \ + TYPE _v1, _v2, _v3; \ + unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \ + unsigned char _pad_mask[sizeof(TYPE)]; \ + unsigned char _byte_mask; \ + int _i, _j, _last = (-1); \ + const char * _mesg; \ + \ + HDmemset(&INFO, 0, sizeof(INFO)); \ + INFO.varname = #VAR; \ + INFO.size = sizeof(TYPE); \ + \ + /* Initialize padding mask */ \ + HDmemset(_pad_mask, 0, sizeof(_pad_mask)); \ + \ + /* Padding bits. Set a variable to 4.0, then flip each bit and see if \ + * the modified variable is equal ("==") to the original. Build a \ + * padding bitmask to indicate which bits in the type are padding (i.e. \ + * have no effect on the value and should be ignored by subsequent \ + * steps). This is necessary because padding bits can change arbitrarily \ + * and interfere with detection of the various properties below unless we \ + * know to ignore them. */ \ + _v1 = (TYPE)4.0L; \ + HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ + for (_i = 0; _i < (int)sizeof(TYPE); _i++) \ + for (_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char)(_byte_mask << 1)) { \ + _buf1[_i] ^= _byte_mask; \ + HDmemcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \ + H5_GCC_DIAG_OFF("float-equal") \ + if (_v1 != _v2) \ + _pad_mask[_i] |= _byte_mask; \ + H5_GCC_DIAG_ON("float-equal") \ + _buf1[_i] ^= _byte_mask; \ + } /* end for */ \ + \ + /* Byte Order */ \ + for (_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \ + _v3 = _v1; \ + _v1 += _v2; \ + _v2 /= (TYPE)256.0L; \ + HDmemcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \ + HDmemcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \ + _j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \ + if (_j >= 0) { \ + INFO.perm[_i] = _j; \ + _last = _i; \ + } \ + } \ + fix_order(sizeof(TYPE), _last, INFO.perm, (const char **)&_mesg); \ + \ + if (!HDstrcmp(_mesg, "VAX")) \ + INFO.is_vax = TRUE; \ + \ + /* Implicit mantissa bit */ \ + _v1 = (TYPE)0.5L; \ + _v2 = (TYPE)1.0L; \ + INFO.imp = imp_bit(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + \ + /* Sign bit */ \ + _v1 = (TYPE)1.0L; \ + _v2 = (TYPE)-1.0L; \ + INFO.sign = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + \ + /* Mantissa */ \ + INFO.mpos = 0; \ + \ + _v1 = (TYPE)1.0L; \ + _v2 = (TYPE)1.5L; \ + INFO.msize = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \ + INFO.msize += 1 + (unsigned int)(INFO.imp ? 0 : 1) - INFO.mpos; \ + \ + /* Exponent */ \ + INFO.epos = INFO.mpos + INFO.msize; \ + \ + INFO.esize = INFO.sign - INFO.epos; \ + \ + _v1 = (TYPE)1.0L; \ + INFO.bias = find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \ + precision(&(INFO)); \ + ALIGNMENT(TYPE, INFO); \ + if (!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ + !HDstrcmp(INFO.varname, "LDOUBLE")) { \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } \ + } - /*------------------------------------------------------------------------- * Function: DETECT_M * - * Purpose: This macro takes only miscellaneous structures or pointer - * (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It - * constructs the names and decides the alignment in structure. + * Purpose: This macro takes only miscellaneous structures or pointer. + * It constructs the names and decides the alignment in structure. * * Return: void *------------------------------------------------------------------------- */ -#define DETECT_M(TYPE,VAR,INFO) { \ - INFO.name = #VAR; \ - COMP_ALIGNMENT(TYPE, INFO.comp_align); \ -} +#define DETECT_M(TYPE, VAR, INFO) \ + { \ + INFO.name = #VAR; \ + COMP_ALIGNMENT(TYPE, INFO.comp_align); \ + } /* Detect alignment for C structure */ -#define COMP_ALIGNMENT(TYPE,COMP_ALIGN) { \ - struct { \ - char c; \ - TYPE x; \ - } s; \ - \ - COMP_ALIGN = (unsigned int)((char*)(&(s.x)) - (char*)(&s)); \ -} +#define COMP_ALIGNMENT(TYPE, COMP_ALIGN) \ + { \ + struct { \ + char c; \ + TYPE x; \ + } s; \ + \ + COMP_ALIGN = (unsigned int)((char *)(&(s.x)) - (char *)(&s)); \ + } #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) -#define ALIGNMENT(TYPE,INFO) { \ - char *volatile _buf = NULL; \ - TYPE _val = 1, _val2; \ - volatile size_t _ano = 0; \ - void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ - void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\ - void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \ - \ - _buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ - if(H5SETJMP(jbuf_g)) _ano++; \ - if(_ano < NELMTS(align_g)) { \ - *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\ - /* Cray Check: This section helps detect alignment on Cray's */ \ - /* vector machines (like the SV1) which mask off */ \ - /* pointer values when pointing to non-word aligned */ \ - /* locations with pointers that are supposed to be */ \ - /* word aligned. -QAK */ \ - HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ - /*How to handle VAX types?*/ \ - if(INFO.perm[0]) /* Big-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ - else /* Little-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); \ - H5_GCC_DIAG_OFF(float-equal) \ - if(_val!=_val2) \ - H5LONGJMP(jbuf_g, 1); \ - H5_GCC_DIAG_ON(float-equal) \ - /* End Cray Check */ \ - (INFO.align)=align_g[_ano]; \ - } else { \ - (INFO.align)=0; \ - fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ - } \ - HDfree(_buf); \ - HDsignal(SIGBUS, _handler); /*restore original handler*/ \ - HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ - HDsignal(SIGILL, _handler3); /*restore original handler*/ \ -} +#define ALIGNMENT(TYPE, INFO) \ + { \ + char *volatile _buf = NULL; \ + TYPE _val = 1, _val2; \ + volatile size_t _ano = 0; \ + void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ + void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler); \ + void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \ + \ + _buf = (char *)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ + if (H5SETJMP(jbuf_g)) \ + _ano++; \ + if (_ano < NELMTS(align_g)) { \ + *((TYPE *)(_buf + align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ + _val2 = *((TYPE *)(_buf + align_g[_ano])); /*possible SIGBUS or SEGSEGV*/ \ + /* Cray Check: This section helps detect alignment on Cray's */ \ + /* vector machines (like the SV1) which mask off */ \ + /* pointer values when pointing to non-word aligned */ \ + /* locations with pointers that are supposed to be */ \ + /* word aligned. -QAK */ \ + HDmemset(_buf, 0xff, sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ + /*How to handle VAX types?*/ \ + if (INFO.perm[0]) /* Big-Endian */ \ + HDmemcpy(_buf + align_g[_ano] + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \ + ((char *)&_val) + (INFO.size - ((INFO.offset + INFO.precision) / 8)), \ + (size_t)(INFO.precision / 8)); \ + else /* Little-Endian */ \ + HDmemcpy(_buf + align_g[_ano] + (INFO.offset / 8), ((char *)&_val) + (INFO.offset / 8), \ + (size_t)(INFO.precision / 8)); \ + _val2 = *((TYPE *)(_buf + align_g[_ano])); \ + H5_GCC_DIAG_OFF("float-equal") \ + if (_val != _val2) \ + H5LONGJMP(jbuf_g, 1); \ + H5_GCC_DIAG_ON("float-equal") \ + /* End Cray Check */ \ + (INFO.align) = align_g[_ano]; \ + } \ + else { \ + (INFO.align) = 0; \ + fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ + } \ + HDfree(_buf); \ + HDsignal(SIGBUS, _handler); /*restore original handler*/ \ + HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ + HDsignal(SIGILL, _handler3); /*restore original handler*/ \ + } #else -#define ALIGNMENT(TYPE,INFO) { \ - align_status_g |= STA_NoALIGNMENT; \ - (INFO.align)=0; \ -} +#define ALIGNMENT(TYPE, INFO) \ + { \ + align_status_g |= STA_NoALIGNMENT; \ + (INFO.align) = 0; \ + } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigsegv_handler * @@ -470,9 +475,8 @@ sigsegv_handler(int H5_ATTR_UNUSED signo) } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigbus_handler * @@ -503,9 +507,8 @@ sigbus_handler(int H5_ATTR_UNUSED signo) } #endif - #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) - + /*------------------------------------------------------------------------- * Function: sigill_handler * @@ -536,7 +539,6 @@ sigill_handler(int H5_ATTR_UNUSED signo) } #endif - /*------------------------------------------------------------------------- * Function: print_results * @@ -548,8 +550,8 @@ sigill_handler(int H5_ATTR_UNUSED signo) static void print_results(int nd, detected_t *d, int na, malign_t *misc_align) { - int byte_order=0; /*byte order of data types*/ - int i, j; + int byte_order = 0; /*byte order of data types*/ + int i, j; /* Include files */ fprintf(rawoutstream, "\ @@ -611,7 +613,6 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /*******************/\n\ \n"); - /* The interface initialization function */ fprintf(rawoutstream, "\n\ \n\ @@ -637,43 +638,43 @@ H5T__init_native(void)\n\ \n\ FUNC_ENTER_PACKAGE\n"); - for(i = 0; i < nd; i++) { + for (i = 0; i < nd; i++) { /* The native endianness of this machine */ /* The INFO.perm now contains `-1' for bytes that aren't used and * are always zero. This happens on the Cray for `short' where * sizeof(short) is 8, but only the low-order 4 bytes are ever used. */ - if(d[i].is_vax) /* the type is a VAX floating number */ - byte_order=-1; + if (d[i].is_vax) /* the type is a VAX floating number */ + byte_order = -1; else { - for(j=0; j<32; j++) { + for (j = 0; j < 32; j++) { /*Find the 1st containing valid data*/ - if(d[i].perm[j]>-1) { - byte_order=d[i].perm[j]; + if (d[i].perm[j] > -1) { + byte_order = d[i].perm[j]; break; } } } - /* Print a comment to describe this section of definitions. */ - fprintf(rawoutstream, "\n /*\n"); - iprint(d+i); - fprintf(rawoutstream, " */\n"); + /* Print a comment to describe this section of definitions. */ + fprintf(rawoutstream, "\n /*\n"); + iprint(d + i); + fprintf(rawoutstream, " */\n"); - /* The part common to fixed and floating types */ - fprintf(rawoutstream, "\ + /* The part common to fixed and floating types */ + fprintf(rawoutstream, "\ if(NULL == (dt = H5T__alloc()))\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\ dt->shared->state = H5T_STATE_IMMUTABLE;\n\ dt->shared->type = H5T_%s;\n\ dt->shared->size = %d;\n", - d[i].msize ? "FLOAT" : "INTEGER",/*class */ - d[i].size); /*size */ + d[i].msize ? "FLOAT" : "INTEGER", /*class */ + d[i].size); /*size */ - if(byte_order==-1) + if (byte_order == -1) fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_VAX;\n"); - else if(byte_order==0) + else if (byte_order == 0) fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_LE;\n"); else @@ -685,19 +686,19 @@ H5T__init_native(void)\n\ dt->shared->u.atomic.prec = %d;\n\ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", - d[i].offset, /*offset */ - d[i].precision); /*precision */ - /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ + d[i].offset, /*offset */ + d[i].precision); /*precision */ + /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ - if(0 == d[i].msize) { - /* The part unique to fixed point types */ - fprintf(rawoutstream, "\ + if (0 == d[i].msize) { + /* The part unique to fixed point types */ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n", - d[i].sign ? "2" : "NONE"); - } - else { - /* The part unique to floating point types */ - fprintf(rawoutstream, "\ + d[i].sign ? "2" : "NONE"); + } + else { + /* The part unique to floating point types */ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.f.sign = %d;\n\ dt->shared->u.atomic.u.f.epos = %d;\n\ dt->shared->u.atomic.u.f.esize = %d;\n\ @@ -706,49 +707,52 @@ H5T__init_native(void)\n\ dt->shared->u.atomic.u.f.msize = %d;\n\ dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", - d[i].sign, /*sign location */ - d[i].epos, /*exponent loc */ - d[i].esize, /*exponent size */ - (unsigned long)(d[i].bias), /*exponent bias */ - d[i].mpos, /*mantissa loc */ - d[i].msize, /*mantissa size */ - d[i].imp ? "IMPLIED" : "NONE"); /*normalization */ - } + d[i].sign, /*sign location */ + d[i].epos, /*exponent loc */ + d[i].esize, /*exponent size */ + (unsigned long)(d[i].bias), /*exponent bias */ + d[i].mpos, /*mantissa loc */ + d[i].msize, /*mantissa size */ + d[i].imp ? "IMPLIED" : "NONE"); /*normalization */ + } - /* Atomize the type */ - fprintf(rawoutstream, "\ + /* Atomize the type */ + fprintf(rawoutstream, "\ if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n", - d[i].varname); - fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", - d[i].varname, (unsigned long)(d[i].align)); + d[i].varname); + fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname, + (unsigned long)(d[i].align)); /* Variables for alignment of compound datatype */ - if(!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || - !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || + if (!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || + !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || !HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") || !HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) { - fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", - d[i].varname, (unsigned long)(d[i].comp_align)); + fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname, + (unsigned long)(d[i].comp_align)); } } /* Consider VAX a little-endian machine */ - if(byte_order==0 || byte_order==-1) { + if (byte_order == 0 || byte_order == -1) { fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ - H5T_native_order_g = H5T_ORDER_%s;\n", "LE"); + H5T_native_order_g = H5T_ORDER_%s;\n", + "LE"); } else { fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ - H5T_native_order_g = H5T_ORDER_%s;\n", "BE"); + H5T_native_order_g = H5T_ORDER_%s;\n", + "BE"); } - /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ - fprintf(rawoutstream, "\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n"); - for(j=0; jsize - 1) / 4; ; --pass) { + for (pass = (d->size - 1) / 4;; --pass) { unsigned int i, k; /* * Print the byte ordering above the bit fields. */ fprintf(rawoutstream, " * "); - for(i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { + for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { fprintf(rawoutstream, "%4d", d->perm[i]); - if(i > pass * 4) + if (i > pass * 4) HDfputs(" ", stdout); - if(!i) + if (!i) break; } @@ -848,24 +851,24 @@ iprint(detected_t *d) * Print the bit fields */ fprintf(rawoutstream, "\n * "); - for(i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, - 8 * d->size - 1); i >= pass * 4; --i) { + for (i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, 8 * d->size - 1); i >= pass * 4; + --i) { unsigned int j; - for(j = 8; j > 0; --j) { - if(k == d->sign && d->msize) { + for (j = 8; j > 0; --j) { + if (k == d->sign && d->msize) { HDfputc('S', rawoutstream); } - else if(k >= d->epos && k < d->epos + d->esize) { + else if (k >= d->epos && k < d->epos + d->esize) { HDfputc('E', rawoutstream); } - else if(k >= d->mpos && k < d->mpos + d->msize) { + else if (k >= d->mpos && k < d->mpos + d->msize) { HDfputc('M', rawoutstream); } - else if(d->msize) { + else if (d->msize) { HDfputc('?', rawoutstream); /*unknown floating point bit */ } - else if(d->sign) { + else if (d->sign) { HDfputc('I', rawoutstream); } else { @@ -873,39 +876,37 @@ iprint(detected_t *d) } --k; } - if(i > pass * 4) + if (i > pass * 4) HDfputc(' ', rawoutstream); - if(!i) + if (!i) break; } HDfputc('\n', rawoutstream); - if(!pass) + if (!pass) break; } /* * Is there an implicit bit in the mantissa. */ - if(d->msize) { + if (d->msize) { fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no"); } /* * Alignment */ - if(0 == d->align) { + if (0 == d->align) { fprintf(rawoutstream, " * Alignment: NOT CALCULATED\n"); } - else if(1 == d->align) { + else if (1 == d->align) { fprintf(rawoutstream, " * Alignment: none\n"); } else { - fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long) (d->align)); + fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long)(d->align)); } - } - /*------------------------------------------------------------------------- * Function: byte_cmp * @@ -921,18 +922,17 @@ iprint(detected_t *d) static int byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask) { - int i; - const unsigned char *a = (const unsigned char *) _a; - const unsigned char *b = (const unsigned char *) _b; + int i; + const unsigned char *a = (const unsigned char *)_a; + const unsigned char *b = (const unsigned char *)_b; - for(i = 0; i < n; i++) - if((a[i] & pad_mask[i]) != (b[i] & pad_mask[i])) + for (i = 0; i < n; i++) + if ((a[i] & pad_mask[i]) != (b[i] & pad_mask[i])) return i; return -1; } - /*------------------------------------------------------------------------- * Function: bit_cmp * @@ -947,22 +947,22 @@ byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask) *------------------------------------------------------------------------- */ static unsigned int -bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, - const unsigned char *pad_mask) +bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, const unsigned char *pad_mask) { - unsigned int i; - unsigned char *a = (unsigned char *) _a; - unsigned char *b = (unsigned char *) _b; - unsigned char aa, bb; - - for(i = 0; i < nbytes; i++) { - HDassert(perm[i] < (int) nbytes); - if((aa = (unsigned char) (a[perm[i]] & pad_mask[perm[i]])) - != (bb = (unsigned char) (b[perm[i]] & pad_mask[perm[i]]))) { + unsigned int i; + unsigned char *a = (unsigned char *)_a; + unsigned char *b = (unsigned char *)_b; + unsigned char aa, bb; + + for (i = 0; i < nbytes; i++) { + HDassert(perm[i] < (int)nbytes); + if ((aa = (unsigned char)(a[perm[i]] & pad_mask[perm[i]])) != + (bb = (unsigned char)(b[perm[i]] & pad_mask[perm[i]]))) { unsigned int j; - for(j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { - if((aa & 1) != (bb & 1)) return i * 8 + j; + for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { + if ((aa & 1) != (bb & 1)) + return i * 8 + j; } fprintf(stderr, "INTERNAL ERROR"); HDabort(); @@ -973,7 +973,6 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, return 0; } - /*------------------------------------------------------------------------- * Function: fix_order * @@ -991,32 +990,29 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, static void fix_order(int n, int last, int *perm, const char **mesg) { - int i; + int i; - if(last > 1) { + if (last > 1) { /* * We have at least three points to consider. */ - if(perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { + if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { /* * Little endian. */ - if(mesg) + if (mesg) *mesg = "Little-endian"; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) perm[i] = i; - } - else if(perm[last] > perm[last - 1] - && perm[last - 1] > perm[last - 2]) { + else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) { /* * Big endian. */ - if(mesg) + if (mesg) *mesg = "Big-endian"; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) perm[i] = (n - 1) - i; - } else { /* @@ -1026,22 +1022,20 @@ fix_order(int n, int last, int *perm, const char **mesg) * case - JKM & QAK) */ HDassert(0 == n % 2); - if(mesg) + if (mesg) *mesg = "VAX"; - for(i = 0; i < n; i += 2) { - perm[i] = (n - 2) - i; + for (i = 0; i < n; i += 2) { + perm[i] = (n - 2) - i; perm[i + 1] = (n - 1) - i; } } } else { - fprintf(stderr, - "Failed to detect byte order of %d-byte floating point.\n", n); + fprintf(stderr, "Failed to detect byte order of %d-byte floating point.\n", n); HDexit(1); } } - /*------------------------------------------------------------------------- * Function: imp_bit * @@ -1072,10 +1066,10 @@ fix_order(int n, int last, int *perm, const char **mesg) static unsigned int imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_mask) { - unsigned char *a = (unsigned char *) _a; - unsigned char *b = (unsigned char *) _b; - unsigned int changed, major, minor; - unsigned int msmb; /* most significant mantissa bit */ + unsigned char *a = (unsigned char *)_a; + unsigned char *b = (unsigned char *)_b; + unsigned int changed, major, minor; + unsigned int msmb; /* most significant mantissa bit */ /* * Look for the least significant bit that has changed between @@ -1088,14 +1082,13 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_ * be the most significant bit of the mantissa. If it is non-zero * then the format does not remove the leading `1' of the mantissa. */ - msmb = changed - 1; + msmb = changed - 1; major = msmb / 8; minor = msmb % 8; return (a[perm[major]] >> minor) & 0x01 ? 0 : 1; } - /*------------------------------------------------------------------------- * Function: find_bias * @@ -1109,14 +1102,14 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_ H5_ATTR_PURE static unsigned int find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) { - unsigned char *a = (unsigned char *) _a; - unsigned char mask; - unsigned int b, shift = 0, nbits, bias = 0; + unsigned char *a = (unsigned char *)_a; + unsigned char mask; + unsigned int b, shift = 0, nbits, bias = 0; - while(esize > 0) { + while (esize > 0) { nbits = MIN(esize, (8 - epos % 8)); - mask = (unsigned char) ((1 << nbits) - 1); - b = (unsigned int) (a[perm[epos / 8]] >> (epos % 8)) & mask; + mask = (unsigned char)((1 << nbits) - 1); + b = (unsigned int)(a[perm[epos / 8]] >> (epos % 8)) & mask; bias |= b << shift; shift += nbits; @@ -1126,7 +1119,6 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) return bias; } - /*------------------------------------------------------------------------- * Function: print_header * @@ -1139,22 +1131,20 @@ static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); - char real_name[30]; - char host_name[256]; - int i; - const char *s; + time_t now = HDtime(NULL); + struct tm * tm = HDlocaltime(&now); + char real_name[30]; + char host_name[256]; + int i; + const char *s; #ifdef H5_HAVE_GETPWUID struct passwd *pwd = NULL; #else - int pwd = 1; + int pwd = 1; #endif - static const char *month_name[] = - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - static const char *purpose = "\ + static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static const char *purpose = "\ This machine-generated source code contains\n\ information about the various integer and\n\ floating point numeric formats found on this\n\ @@ -1198,10 +1188,10 @@ bit.\n"; #ifdef H5_HAVE_GETPWUID { size_t n; - char *comma; - if((pwd = HDgetpwuid(HDgetuid()))) { - if((comma = HDstrchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); + char * comma; + if ((pwd = HDgetpwuid(HDgetuid()))) { + if ((comma = HDstrchr(pwd->pw_gecos, ','))) { + n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } @@ -1221,7 +1211,7 @@ bit.\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(host_name, sizeof(host_name)) < 0) { + if (HDgethostname(host_name, sizeof(host_name)) < 0) { host_name[0] = '\0'; } #else @@ -1232,27 +1222,28 @@ bit.\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", - month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if(pwd || real_name[0] || host_name[0]) { + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, + 1900 + tm->tm_year); + if (pwd || real_name[0] || host_name[0]) { fprintf(rawoutstream, " *\t\t\t"); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if(pwd) HDfputs(pwd->pw_name, rawoutstream); + if (pwd) + HDfputs(pwd->pw_name, rawoutstream); #endif - if(host_name[0]) + if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, ">"); HDfputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); - for(s = purpose; *s; s++) { + for (s = purpose; *s; s++) { HDfputc(*s, rawoutstream); - if('\n' == *s && s[1]) + if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -1261,13 +1252,11 @@ bit.\n"; fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n"); fprintf(rawoutstream, " *\n *"); - for(i = 0; i < 73; i++) + for (i = 0; i < 73; i++) HDfputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); - } - /*------------------------------------------------------------------------- * Function: detect_C89_integers * @@ -1279,17 +1268,24 @@ bit.\n"; static void HDF_NO_UBSAN detect_C89_integers(void) { - DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++; - DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++; - DETECT_I(short, SHORT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++; - DETECT_I(int, INT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++; - DETECT_I(long, LONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++; + DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); + nd_g++; + DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); + nd_g++; + DETECT_I(short, SHORT, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned short, USHORT, d_g[nd_g]); + nd_g++; + DETECT_I(int, INT, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned int, UINT, d_g[nd_g]); + nd_g++; + DETECT_I(long, LONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long, ULONG, d_g[nd_g]); + nd_g++; } - /*------------------------------------------------------------------------- * Function: detect_C89_floats * @@ -1301,11 +1297,12 @@ detect_C89_integers(void) static void HDF_NO_UBSAN detect_C89_floats(void) { - DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++; - DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++; + DETECT_F(float, FLOAT, d_g[nd_g]); + nd_g++; + DETECT_F(double, DOUBLE, d_g[nd_g]); + nd_g++; } - /*------------------------------------------------------------------------- * Function: detect_C99_integers8 * @@ -1317,51 +1314,62 @@ detect_C89_floats(void) static void HDF_NO_UBSAN detect_C99_integers8(void) { -#if H5_SIZEOF_INT8_T>0 - #if H5_SIZEOF_INT8_T==1 - DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_INT8_T > 0 +#if H5_SIZEOF_INT8_T == 1 + DETECT_BYTE(int8_t, INT8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int8_t, INT8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_UINT8_T > 0 +#if H5_SIZEOF_UINT8_T == 1 + DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint8_t, UINT8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_INT_LEAST8_T > 0 +#if H5_SIZEOF_INT_LEAST8_T == 1 + DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT8_T>0 - #if H5_SIZEOF_UINT8_T==1 - DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++; - #endif #endif -#if H5_SIZEOF_INT_LEAST8_T>0 - #if H5_SIZEOF_INT_LEAST8_T==1 - DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_UINT_LEAST8_T > 0 +#if H5_SIZEOF_UINT_LEAST8_T == 1 + DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); + nd_g++; +#endif +#endif +#if H5_SIZEOF_INT_FAST8_T > 0 +#if H5_SIZEOF_INT_FAST8_T == 1 + DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST8_T>0 - #if H5_SIZEOF_UINT_LEAST8_T==1 - DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; - #endif #endif -#if H5_SIZEOF_INT_FAST8_T>0 - #if H5_SIZEOF_INT_FAST8_T==1 - DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; - #endif +#if H5_SIZEOF_UINT_FAST8_T > 0 +#if H5_SIZEOF_UINT_FAST8_T == 1 + DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); + nd_g++; +#else + DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST8_T>0 - #if H5_SIZEOF_UINT_FAST8_T==1 - DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; - #else - DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; - #endif #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers16 * @@ -1373,27 +1381,32 @@ detect_C99_integers8(void) static void HDF_NO_UBSAN detect_C99_integers16(void) { -#if H5_SIZEOF_INT16_T>0 - DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT16_T > 0 + DETECT_I(int16_t, INT16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT16_T>0 - DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT16_T > 0 + DETECT_I(uint16_t, UINT16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST16_T>0 - DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST16_T > 0 + DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST16_T>0 - DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST16_T > 0 + DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST16_T>0 - DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST16_T > 0 + DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST16_T>0 - DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST16_T > 0 + DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers32 * @@ -1405,27 +1418,32 @@ detect_C99_integers16(void) static void HDF_NO_UBSAN detect_C99_integers32(void) { -#if H5_SIZEOF_INT32_T>0 - DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT32_T > 0 + DETECT_I(int32_t, INT32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT32_T>0 - DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT32_T > 0 + DETECT_I(uint32_t, UINT32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST32_T>0 - DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST32_T > 0 + DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST32_T>0 - DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST32_T > 0 + DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST32_T>0 - DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST32_T > 0 + DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST32_T>0 - DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST32_T > 0 + DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers64 * @@ -1438,40 +1456,49 @@ detect_C99_integers32(void) static void HDF_NO_UBSAN detect_C99_integers64(void) { -#if H5_SIZEOF_INT64_T>0 - DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT64_T > 0 + DETECT_I(int64_t, INT64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT64_T>0 - DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT64_T > 0 + DETECT_I(uint64_t, UINT64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_LEAST64_T>0 - DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_LEAST64_T > 0 + DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_LEAST64_T>0 - DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_LEAST64_T > 0 + DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_INT_FAST64_T>0 - DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_INT_FAST64_T > 0 + DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_UINT_FAST64_T>0 - DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_UINT_FAST64_T > 0 + DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); + nd_g++; #endif -#if H5_SIZEOF_LONG_LONG>0 - DETECT_I(long long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++; +#if H5_SIZEOF_LONG_LONG > 0 + DETECT_I(long long, LLONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); + nd_g++; #else /* * This architecture doesn't support an integer type larger than `long' * so we'll just make H5T_NATIVE_LLONG the same as H5T_NATIVE_LONG since * `long long' is probably equivalent to `long' here anyway. */ - DETECT_I(long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++; + DETECT_I(long, LLONG, d_g[nd_g]); + nd_g++; + DETECT_I(unsigned long, ULLONG, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_C99_integers * @@ -1491,7 +1518,6 @@ detect_C99_integers(void) detect_C99_integers64(); } - /*------------------------------------------------------------------------- * Function: detect_C99_floats * @@ -1510,13 +1536,14 @@ detect_C99_floats(void) * some systems and `long double' is probably the same as `double' here * anyway. */ - DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++; -#elif H5_SIZEOF_LONG_DOUBLE !=0 - DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++; + DETECT_F(double, LDOUBLE, d_g[nd_g]); + nd_g++; +#elif H5_SIZEOF_LONG_DOUBLE != 0 + DETECT_F(long double, LDOUBLE, d_g[nd_g]); + nd_g++; #endif } - /*------------------------------------------------------------------------- * Function: detect_alignments * @@ -1528,21 +1555,27 @@ detect_C99_floats(void) static void HDF_NO_UBSAN detect_alignments(void) { - /* Detect structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ - DETECT_M(void *, POINTER, m_g[na_g]); na_g++; - DETECT_M(hvl_t, HVL, m_g[na_g]); na_g++; - DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); na_g++; - DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); na_g++; + /* Detect structure alignment for pointers, vlen and reference types */ + DETECT_M(void *, POINTER, m_g[na_g]); + na_g++; + DETECT_M(hvl_t, HVL, m_g[na_g]); + na_g++; + DETECT_M(hobj_ref_t, HOBJREF, m_g[na_g]); + na_g++; + DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); + na_g++; + DETECT_M(H5R_ref_t, REF, m_g[na_g]); + na_g++; } - #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* Verify the signal handler for signal signum works correctly multiple times. * One possible cause of failure is that the signal handling is blocked or * changed to SIG_DFL after H5LONGJMP. * Return 0 for success, -1 for failure. */ -static int verify_signal_handlers(int signum, void (*handler)(int)) +static int +verify_signal_handlers(int signum, void (*handler)(int)) { #if defined(__has_feature) /* Clang */ #if __has_feature(address_sanitizer) || __has_feature(thread_sanitizer) @@ -1552,15 +1585,15 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) #elif defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) /* GCC */ return 0; #endif - void (*save_handler)(int) = HDsignal(signum, handler); + void (*save_handler)(int) = HDsignal(signum, handler); volatile int i, val; - int ntries = 5; - volatile int nfailures = 0; + int ntries = 5; + volatile int nfailures = 0; volatile int nsuccesses = 0; - for(i=0;i0 || nsuccesses != ntries) { - fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. " - "Found %d failures and %d successes\n", - signum, ntries, nfailures, nsuccesses); + if (nfailures > 0 || nsuccesses != ntries) { + fprintf(stderr, + "verify_signal_handlers for signal %d did %d tries. " + "Found %d failures and %d successes\n", + signum, ntries, nfailures, nsuccesses); return -1; } else { @@ -1593,7 +1627,6 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) } #endif - /*------------------------------------------------------------------------- * Function: main * @@ -1606,20 +1639,20 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) int HDF_NO_UBSAN main(int argc, char *argv[]) { - char *fname = NULL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawoutstream is changed only when succeeded */ + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded */ - if(argc > 1) + if (argc > 1) fname = argv[1]; /* First check if filename is string "NULL" */ - if(fname != NULL) { + if (fname != NULL) { /* binary output */ - if((f = HDfopen(fname, "w")) != NULL) + if ((f = HDfopen(fname, "w")) != NULL) rawoutstream = f; } - if(!rawoutstream) + if (!rawoutstream) rawoutstream = stdout; #if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS) @@ -1628,29 +1661,25 @@ main(int argc, char *argv[]) * Make sure unaligned access generates SIGBUS and doesn't print warning * messages so that we can detect alignment constraints on the DEC Alpha. */ - int nvpairs[2]; + int nvpairs[2]; nvpairs[0] = SSIN_UACPROC; nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; - if(setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { - fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", - HDstrerror(errno)); + if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0) < 0) { + fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", HDstrerror(errno)); } #endif #endif #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* verify the SIGBUS and SIGSEGV handlers work properly */ - if(verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigbus_handler", SIGBUS); + if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigbus_handler", SIGBUS); } - if(verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigsegv_handler", SIGSEGV); + if (verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigsegv_handler", SIGSEGV); } - if(verify_signal_handlers(SIGILL, sigill_handler) != 0) { - fprintf(stderr, "Signal handler %s for signal %d failed\n", - "sigill_handler", SIGILL); + if (verify_signal_handlers(SIGILL, sigill_handler) != 0) { + fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigill_handler", SIGILL); } #else align_status_g |= STA_NoHandlerVerify; @@ -1673,10 +1702,10 @@ main(int argc, char *argv[]) /* Detect structure alignment */ detect_alignments(); - print_results (nd_g, d_g, na_g, m_g); + print_results(nd_g, d_g, na_g, m_g); - if(rawoutstream && rawoutstream != stdout) { - if(HDfclose(rawoutstream)) + if (rawoutstream && rawoutstream != stdout) { + if (HDfclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; @@ -1685,4 +1714,4 @@ main(int argc, char *argv[]) return EXIT_SUCCESS; } -H5_GCC_DIAG_ON(cast-align) +H5_GCC_DIAG_ON("cast-align") diff --git a/src/H5err.txt b/src/H5err.txt index f3cca72f1bd..9bd6d0f9354 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -46,6 +46,7 @@ MAJOR, H5E_ARGS, Invalid arguments to routine MAJOR, H5E_RESOURCE, Resource unavailable MAJOR, H5E_INTERNAL, Internal error (too specific to document in detail) +MAJOR, H5E_LIB, General library infrastructure MAJOR, H5E_FILE, File accessibility MAJOR, H5E_IO, Low-level I/O MAJOR, H5E_FUNC, Function entry/exit @@ -66,6 +67,7 @@ MAJOR, H5E_PLINE, Data filters MAJOR, H5E_EFL, External file list MAJOR, H5E_REFERENCE, References MAJOR, H5E_VFL, Virtual File Layer +MAJOR, H5E_VOL, Virtual Object Layer MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API @@ -77,6 +79,7 @@ MAJOR, H5E_FARRAY, Fixed Array MAJOR, H5E_PLUGIN, Plugin for dynamically loaded library MAJOR, H5E_PAGEBUF, Page Buffering MAJOR, H5E_CONTEXT, API Context +MAJOR, H5E_MAP, Map MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) @@ -133,6 +136,7 @@ MINOR, FILEACC, H5E_NOTHDF5, Not an HDF5 file MINOR, FILEACC, H5E_BADFILE, Bad file ID accessed MINOR, FILEACC, H5E_TRUNCATED, File has been truncated MINOR, FILEACC, H5E_MOUNT, File mount error +MINOR, FILEACC, H5E_CANTDELETEFILE, Unable to delete file MINOR, FILEACC, H5E_CANTLOCKFILE, Unable to lock file MINOR, FILEACC, H5E_CANTUNLOCKFILE, Unable to unlock file @@ -183,7 +187,6 @@ MINOR, CACHE, H5E_CANTDEPEND, Unable to create a flush dependency MINOR, CACHE, H5E_CANTUNDEPEND, Unable to destroy a flush dependency MINOR, CACHE, H5E_CANTNOTIFY, Unable to notify object about action MINOR, CACHE, H5E_LOGGING, Failure in the cache logging framework -MINOR, CACHE, H5E_LOGFAIL, old H5E_LOGGING_g (maintained for binary compatibility) MINOR, CACHE, H5E_CANTCORK, Unable to cork an object MINOR, CACHE, H5E_CANTUNCORK, Unable to uncork an object diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index 72041ed204d..06f7ae34940 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,7 +21,7 @@ static const char *FileHeader = "\n\ * This file is part of HDF5. The full HDF5 copyright notice, including *\n\ * terms governing use, modification, and redistribution, is contained in *\n\ * the COPYING file, which can be found at the root of the source code *\n\ - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *\n\ + * distribution tree, or in https://www.hdfgroup.org/licenses. *\n\ * If you do not have access to either file, you may request a copy from *\n\ * help@hdfgroup.org. *\n\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; @@ -42,7 +42,6 @@ static const char *FileHeader = "\n\ FILE *rawoutstream = NULL; - /*------------------------------------------------------------------------- * Function: insert_libhdf5_settings * @@ -58,11 +57,11 @@ static void insert_libhdf5_settings(FILE *flibinfo) { #ifdef H5_HAVE_EMBEDDED_LIBINFO - FILE *fsettings; /* for files libhdf5.settings */ - int inchar; - int bol = 0; /* indicates the beginning of a new line */ + FILE *fsettings; /* for files libhdf5.settings */ + int inchar; + int bol = 0; /* indicates the beginning of a new line */ - if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { + if (NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } @@ -71,13 +70,13 @@ insert_libhdf5_settings(FILE *flibinfo) /* Do not use const else AIX strings does not show it. */ fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); bol++; - while(EOF != (inchar = HDgetc(fsettings))) { - if(bol) { + while (EOF != (inchar = HDgetc(fsettings))) { + if (bol) { /* Start a new line */ fprintf(flibinfo, "\t\""); bol = 0; } - if(inchar == '\n') { + if (inchar == '\n') { /* end of a line */ fprintf(flibinfo, "\\n\"\n"); bol++; @@ -86,9 +85,9 @@ insert_libhdf5_settings(FILE *flibinfo) HDputc(inchar, flibinfo); } - if(HDfeof(fsettings)) { + if (HDfeof(fsettings)) { /* wrap up */ - if(!bol) + if (!bol) /* EOF found without a new line */ fprintf(flibinfo, "\\n\"\n"); fprintf(flibinfo, ";\n\n"); @@ -97,7 +96,7 @@ insert_libhdf5_settings(FILE *flibinfo) fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } - if(0 != HDfclose(fsettings)) { + if (0 != HDfclose(fsettings)) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); } @@ -108,7 +107,6 @@ insert_libhdf5_settings(FILE *flibinfo) #endif } /* insert_libhdf5_settings() */ - /*------------------------------------------------------------------------- * Function: make_libinfo * @@ -126,7 +124,6 @@ make_libinfo(void) insert_libhdf5_settings(rawoutstream); } - /*------------------------------------------------------------------------- * Function: print_header * @@ -138,22 +135,20 @@ make_libinfo(void) static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); + time_t now = HDtime(NULL); + struct tm * tm = HDlocaltime(&now); char real_name[30]; char host_name[256]; - int i; - const char *s; + int i; + const char *s; #ifdef H5_HAVE_GETPWUID - struct passwd *pwd = NULL; + struct passwd *pwd = NULL; #else - int pwd = 1; + int pwd = 1; #endif - static const char *month_name[] = - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - static const char *purpose = "\ + static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static const char *purpose = "\ This machine-generated source code contains\n\ information about the library build configuration\n"; @@ -163,10 +158,10 @@ information about the library build configuration\n"; #ifdef H5_HAVE_GETPWUID { size_t n; - char *comma; + char * comma; - if((pwd = HDgetpwuid(HDgetuid()))) { - if((comma = HDstrchr(pwd->pw_gecos, ','))) { + if ((pwd = HDgetpwuid(HDgetuid()))) { + if ((comma = HDstrchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; @@ -187,7 +182,7 @@ information about the library build configuration\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if(HDgethostname(host_name, sizeof(host_name)) < 0) + if (HDgethostname(host_name, sizeof(host_name)) < 0) host_name[0] = '\0'; #else host_name[0] = '\0'; @@ -197,30 +192,30 @@ information about the library build configuration\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", - month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if(pwd || real_name[0] || host_name[0]) { + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, + 1900 + tm->tm_year); + if (pwd || real_name[0] || host_name[0]) { fprintf(rawoutstream, " *\t\t\t"); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if(pwd) + if (pwd) HDfputs(pwd->pw_name, rawoutstream); #endif - if(host_name[0]) + if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); - if(real_name[0]) + if (real_name[0]) fprintf(rawoutstream, ">"); HDfputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); - for(s = purpose; *s; s++) { + for (s = purpose; *s; s++) { HDfputc(*s, rawoutstream); - if('\n' == *s && s[1]) + if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -229,12 +224,11 @@ information about the library build configuration\n"; fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n"); fprintf(rawoutstream, " *\n *"); - for(i = 0; i < 73; i++) + for (i = 0; i < 73; i++) HDfputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); } - /*------------------------------------------------------------------------- * Function: print_footer * @@ -249,7 +243,6 @@ print_footer(void) /* nothing */ } - /*------------------------------------------------------------------------- * Function: main * @@ -261,21 +254,21 @@ print_footer(void) int main(int argc, char *argv[]) { - char *fname = NULL; - FILE *f; /* temporary holding place for the stream pointer - * so that rawoutstream is changed only when succeeded - */ + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded + */ - if(argc > 1) + if (argc > 1) fname = argv[1]; /* First check if filename is string "NULL" */ - if(fname != NULL) { + if (fname != NULL) { /* binary output */ - if((f = HDfopen(fname, "w")) != NULL) + if ((f = HDfopen(fname, "w")) != NULL) rawoutstream = f; } - if(!rawoutstream) + if (!rawoutstream) rawoutstream = stdout; print_header(); @@ -285,8 +278,8 @@ main(int argc, char *argv[]) print_footer(); - if(rawoutstream && rawoutstream != stdout) { - if(HDfclose(rawoutstream)) + if (rawoutstream && rawoutstream != stdout) { + if (HDfclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; @@ -294,4 +287,3 @@ main(int argc, char *argv[]) HDexit(EXIT_SUCCESS); } - diff --git a/src/H5module.h b/src/H5module.h new file mode 100644 index 00000000000..64081bf5509 --- /dev/null +++ b/src/H5module.h @@ -0,0 +1,34 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which define macros for the + * H5 package. Including this header means that the source file + * is part of the H5 package. + */ +#ifndef H5module_H +#define H5module_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5_MODULE +#define H5_MY_PKG H5 +#define H5_MY_PKG_ERR H5E_LIB +#define H5_MY_PKG_INIT YES + +/**\defgroup H5 H5 + * \brief General Library Functions + * \todo Describe concisely what the functions in this module are about. + */ + +#endif /* H5module_H */ diff --git a/src/H5mpi.c b/src/H5mpi.c index 9c72fb0955c..97497215c96 100644 --- a/src/H5mpi.c +++ b/src/H5mpi.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,27 +16,25 @@ * */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory Management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory Management */ #ifdef H5_HAVE_PARALLEL /****************/ /* Local Macros */ /****************/ -#define TWO_GIG_LIMIT (1 << 31) +#define TWO_GIG_LIMIT INT32_MAX #ifndef H5_MAX_MPI_COUNT -#define H5_MAX_MPI_COUNT (1 << 30) +#define H5_MAX_MPI_COUNT (1 << 30) #endif /*******************/ /* Local Variables */ /*******************/ -static hsize_t bigio_count = H5_MAX_MPI_COUNT; +static hsize_t bigio_count_g = H5_MAX_MPI_COUNT; - /*------------------------------------------------------------------------- * Function: H5_mpi_set_bigio_count * @@ -44,7 +42,7 @@ static hsize_t bigio_count = H5_MAX_MPI_COUNT; * when we utilize derived datatypes. This is of * particular interest for allowing nightly testing * - * Return: The current/previous value of bigio_count. + * Return: The current/previous value of bigio_count_g. * * Programmer: Richard Warren, March 10, 2017 * @@ -53,22 +51,21 @@ static hsize_t bigio_count = H5_MAX_MPI_COUNT; hsize_t H5_mpi_set_bigio_count(hsize_t new_count) { - hsize_t orig_count = bigio_count; + hsize_t orig_count = bigio_count_g; - if((new_count > 0) && (new_count < (hsize_t)TWO_GIG_LIMIT)) { - bigio_count = new_count; + if ((new_count > 0) && (new_count < (hsize_t)TWO_GIG_LIMIT)) { + bigio_count_g = new_count; } return orig_count; } /* end H5_mpi_set_bigio_count() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_get_bigio_count * * Purpose: Allow other HDF5 library functions to access - * the current value for bigio_count. + * the current value for bigio_count_g. * - * Return: The current/previous value of bigio_count. + * Return: The current/previous value of bigio_count_g. * * Programmer: Richard Warren, October 7, 2019 * @@ -77,10 +74,9 @@ H5_mpi_set_bigio_count(hsize_t new_count) hsize_t H5_mpi_get_bigio_count(void) { - return bigio_count; + return bigio_count_g; } - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_dup * @@ -98,9 +94,9 @@ H5_mpi_get_bigio_count(void) herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) { - herr_t ret_value = SUCCEED; - MPI_Comm comm_dup = MPI_COMM_NULL; - int mpi_code; + herr_t ret_value = SUCCEED; + MPI_Comm comm_dup = MPI_COMM_NULL; + int mpi_code; FUNC_ENTER_NOAPI(FAIL) @@ -124,7 +120,6 @@ H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) */ if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_errhandler(comm_dup, MPI_ERRORS_RETURN))) HMPI_GOTO_ERROR(FAIL, "MPI_Errhandler_set failed", mpi_code) - } /* Copy the new communicator to the return argument */ @@ -140,7 +135,6 @@ H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_comm_dup() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_info_dup * @@ -159,9 +153,9 @@ H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new) herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new) { - herr_t ret_value = SUCCEED; - MPI_Info info_dup = MPI_INFO_NULL; - int mpi_code; + herr_t ret_value = SUCCEED; + MPI_Info info_dup = MPI_INFO_NULL; + int mpi_code; FUNC_ENTER_NOAPI(FAIL) @@ -193,7 +187,6 @@ H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_info_dup() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_free * @@ -208,7 +201,7 @@ H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new) herr_t H5_mpi_comm_free(MPI_Comm *comm) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -217,7 +210,7 @@ H5_mpi_comm_free(MPI_Comm *comm) HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "comm pointer cannot be NULL") /* Free the communicator */ - if (MPI_COMM_NULL != *comm) + if (MPI_COMM_WORLD != *comm && MPI_COMM_NULL != *comm) MPI_Comm_free(comm); *comm = MPI_COMM_NULL; @@ -225,7 +218,7 @@ H5_mpi_comm_free(MPI_Comm *comm) done: FUNC_LEAVE_NOAPI(ret_value) } /* End H5_mpi_comm_free() */ - + /*------------------------------------------------------------------------- * Function: H5_mpi_info_free * @@ -240,7 +233,7 @@ H5_mpi_comm_free(MPI_Comm *comm) herr_t H5_mpi_info_free(MPI_Info *info) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -258,7 +251,6 @@ H5_mpi_info_free(MPI_Info *info) FUNC_LEAVE_NOAPI(ret_value) } /* End H5_mpi_info_free() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_comm_cmp * @@ -282,9 +274,9 @@ H5_mpi_info_free(MPI_Info *info) herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result) { - int mpi_code; - int mpi_result = MPI_IDENT; - herr_t ret_value = SUCCEED; + int mpi_code; + int mpi_result = MPI_IDENT; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -329,7 +321,6 @@ H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_comm_cmp() */ - /*------------------------------------------------------------------------- * Function: H5_mpi_info_cmp * @@ -349,11 +340,11 @@ H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result) herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) { - hbool_t same = FALSE; - char *key = NULL; - char *value1 = NULL; - char *value2 = NULL; - herr_t ret_value = SUCCEED; + hbool_t same = FALSE; + char * key = NULL; + char * value1 = NULL; + char * value2 = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -372,9 +363,9 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) same = FALSE; } else { - int mpi_code; - int nkeys_1; - int nkeys_2; + int mpi_code; + int nkeys_1; + int nkeys_2; /* Check if the number of keys is the same */ if (MPI_SUCCESS != (mpi_code = MPI_Info_get_nkeys(info1, &nkeys_1))) @@ -426,8 +417,8 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) } } /* end for */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ /* Set the output value * @@ -450,7 +441,6 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpi_info_cmp() */ - /*------------------------------------------------------------------------- * Function: H5_mpio_create_large_type * @@ -466,23 +456,23 @@ H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result) *------------------------------------------------------------------------- */ herr_t -H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, - MPI_Datatype old_type, MPI_Datatype *new_type) +H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, MPI_Datatype old_type, + MPI_Datatype *new_type) { - int num_big_types; /* num times the 2G datatype will be repeated */ - int remaining_bytes; /* the number of bytes left that can be held in an int value */ - hsize_t leftover; - int block_len[2]; - int mpi_code; /* MPI return code */ - MPI_Datatype inner_type, outer_type, leftover_type, type[2]; - MPI_Aint disp[2], old_extent; - herr_t ret_value = SUCCEED; /* Return value */ + int num_big_types; /* num times the 2G datatype will be repeated */ + int remaining_bytes; /* the number of bytes left that can be held in an int value */ + hsize_t leftover; + int block_len[2]; + int mpi_code; /* MPI return code */ + MPI_Datatype inner_type, outer_type, leftover_type, type[2]; + MPI_Aint disp[2], old_extent; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Calculate how many Big MPI datatypes are needed to represent the buffer */ - num_big_types = (int)(num_elements/bigio_count); - leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count; + num_big_types = (int)(num_elements / bigio_count_g); + leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count_g; H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t); /* Create a contiguous datatype of size equal to the largest @@ -491,37 +481,38 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, * use type_hvector to create the type with the displacement provided */ if (0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count, old_type, &inner_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count_g, old_type, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)bigio_count, 1, stride_bytes, old_type, &inner_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hvector((int)bigio_count_g, 1, stride_bytes, old_type, &inner_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) /* Create a contiguous datatype of the buffer (minus the remaining < 2GB part) * If a stride is present, use hvector type */ - if(0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type))) + if (0 == stride_bytes) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(num_big_types, inner_type, &outer_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hvector(num_big_types, 1, stride_bytes, inner_type, &outer_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) MPI_Type_free(&inner_type); /* If there is a remaining part create a contiguous/vector datatype and then * use a struct datatype to encapsulate everything. */ - if(remaining_bytes) { - if(stride_bytes == 0) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type))) + if (remaining_bytes) { + if (stride_bytes == 0) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(remaining_bytes, old_type, &leftover_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) } /* end if */ - else - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)(num_elements - (hsize_t)num_big_types * bigio_count), 1, stride_bytes, old_type, &leftover_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + else if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector( + (int)(num_elements - (hsize_t)num_big_types * bigio_count_g), 1, + stride_bytes, old_type, &leftover_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) /* As of version 4.0, OpenMPI now turns off MPI-1 API calls by default, * so we're using the MPI-2 version even though we don't need the lb @@ -533,14 +524,14 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, } /* Set up the arguments for MPI_Type_struct constructor */ - type[0] = outer_type; - type[1] = leftover_type; + type[0] = outer_type; + type[1] = leftover_type; block_len[0] = 1; block_len[1] = 1; - disp[0] = 0; - disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count; + disp[0] = 0; + disp[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count_g; - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(2, block_len, disp, type, new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) MPI_Type_free(&outer_type); @@ -551,13 +542,11 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, * the outer type created */ *new_type = outer_type; - if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5_mpio_create_large_type() */ - #endif /* H5_HAVE_PARALLEL */ - diff --git a/src/H5overflow.h b/src/H5overflow.h index ba693e21a85..833f5ca2f19 100644 --- a/src/H5overflow.h +++ b/src/H5overflow.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ /* Add new types to H5overflow.txt file */ -#ifndef _H5overflow_H -#define _H5overflow_H +#ifndef H5overflow_H +#define H5overflow_H /* Each type in this file is tested for assignment to the other types, diff --git a/src/H5overflow.txt b/src/H5overflow.txt index 9fb3b8921d3..3f91a750d38 100644 --- a/src/H5overflow.txt +++ b/src/H5overflow.txt @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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/H5private.h b/src/H5private.h index c16c461519c..56ded143dbb 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,41 +21,41 @@ * */ -#ifndef _H5private_H -#define _H5private_H +#ifndef H5private_H +#define H5private_H -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ /* include the pthread header */ #ifdef H5_HAVE_THREADSAFE - #ifdef H5_HAVE_WIN32_API - #ifndef H5_HAVE_WIN_THREADS - #ifdef H5_HAVE_PTHREAD_H - #include - #endif /* H5_HAVE_PTHREAD_H */ - #endif /* H5_HAVE_WIN_THREADS */ - #else /* H5_HAVE_WIN32_API */ - #ifdef H5_HAVE_PTHREAD_H - #include - #endif /* H5_HAVE_PTHREAD_H */ - #endif /* H5_HAVE_WIN32_API */ +#ifdef H5_HAVE_WIN32_API +#ifndef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_PTHREAD_H +#include +#endif /* H5_HAVE_PTHREAD_H */ +#endif /* H5_HAVE_WIN_THREADS */ +#else /* H5_HAVE_WIN32_API */ +#ifdef H5_HAVE_PTHREAD_H +#include +#endif /* H5_HAVE_PTHREAD_H */ +#endif /* H5_HAVE_WIN32_API */ #endif /* H5_HAVE_THREADSAFE */ /* * Include ANSI-C header files. */ #ifdef H5_STDC_HEADERS -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif /* @@ -63,12 +63,12 @@ * compliant. Otherwise all bets are off. */ #ifdef H5_HAVE_UNISTD_H -# include -# include +#include +#include #endif #ifdef _POSIX_VERSION -# include -# include +#include +#include #endif /* @@ -76,7 +76,7 @@ */ #ifndef __cplusplus #ifdef H5_HAVE_STDINT_H -# include +#include #endif #endif @@ -86,7 +86,7 @@ * for hdf5 to compile, although only a few fields are actually used. */ #ifdef H5_HAVE_SYS_STAT_H -# include +#include #endif /* @@ -100,26 +100,26 @@ * by `AC_CHECK_HEADERS(sys/time.h)' in configure.ac. */ #if defined(H5_TIME_WITH_SYS_TIME) -# include -# include +#include +#include #elif defined(H5_HAVE_SYS_TIME_H) -# include +#include #else -# include +#include #endif /* * Longjumps are used to detect alignment constrants */ #ifdef H5_HAVE_SETJMP_H -# include +#include #endif /* * flock() in sys/file.h is used for the implementation of file locking. */ #if defined(H5_HAVE_FLOCK) && defined(H5_HAVE_SYS_FILE_H) -# include +#include #endif /* @@ -127,7 +127,7 @@ * and debugging code if available. */ #ifdef H5_HAVE_SYS_RESOURCE_H -# include +#include #endif /* @@ -135,7 +135,7 @@ * reasonable output width. */ #ifdef H5_HAVE_SYS_IOCTL_H -# include +#include #endif /* @@ -144,13 +144,13 @@ * alignment constraints in H5detect.c:main(). */ #ifdef H5_HAVE_SYS_SYSINFO_H -# include +#include #endif #ifdef H5_HAVE_SYS_PROC_H -# include +#include #endif #ifdef H5_HAVE_IO_H -# include +#include #endif /* @@ -167,47 +167,33 @@ /* Define the default VFD for this platform. * Since the removal of the Windows VFD, this is sec2 for all platforms. */ -#define H5_DEFAULT_VFD H5FD_SEC2 +#define H5_DEFAULT_VFD H5FD_SEC2 + +/* Define the default VOL driver */ +#define H5_DEFAULT_VOL H5VL_NATIVE #ifdef H5_HAVE_WIN32_API /* The following two defines must be before any windows headers are included */ -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ -#define NOGDI /* Exclude Graphic Display Interface macros */ +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#define NOGDI /* Exclude Graphic Display Interface macros */ #ifdef H5_HAVE_WINSOCK2_H #include #endif #ifdef H5_HAVE_THREADSAFE -#include /* For _beginthread() */ +#include /* For _beginthread() */ #endif #include -#include /* For _getcwd() */ +#include /* For _getcwd() */ #endif /*H5_HAVE_WIN32_API*/ -/* Various ways that inline functions can be declared */ -#if defined(H5_HAVE___INLINE__) - /* GNU (alternative form) */ - #define H5_INLINE __inline__ -#elif defined(H5_HAVE___INLINE) - /* Visual Studio */ - #define H5_INLINE __inline -#elif defined(H5_HAVE_INLINE) - /* GNU, C++ - * Use "inline" as a last resort on the off-chance that there will - * be C++ problems. - */ - #define H5_INLINE inline -#else - #define H5_INLINE -#endif /* inline choices */ - #ifndef F_OK -# define F_OK 00 -# define W_OK 02 -# define R_OK 04 +#define F_OK 00 +#define W_OK 02 +#define R_OK 04 #endif /* @@ -227,12 +213,12 @@ * #define eventa(func_name) h5_mpe_ ## func_name ## _a * #define eventb(func_name) h5_mpe_ ## func_name ## _b */ -#define eventa(func_name) h5_mpe_eventa -#define eventb(func_name) h5_mpe_eventb -#define MPE_LOG_VARS \ - static int eventa(FUNC) = -1; \ - static int eventb(FUNC) = -1; \ - char p_event_start[128]; +#define eventa(func_name) h5_mpe_eventa +#define eventb(func_name) h5_mpe_eventb +#define MPE_LOG_VARS \ + static int eventa(FUNC) = -1; \ + static int eventb(FUNC) = -1; \ + char p_event_start[128]; /* Hardwire the color to "red", since that's what all the routines are using * now. In the future, if we want to change that color for a given routine, @@ -241,34 +227,33 @@ * color information down to the BEGIN_MPE_LOG macro (which should have a new * BEGIN_MPE_LOG_COLOR variant). -QAK */ -#define BEGIN_MPE_LOG \ - if (H5_MPEinit_g){ \ - sprintf(p_event_start, "start %s", FUNC); \ - if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ - const char* p_color = "red"; \ - eventa(FUNC)=MPE_Log_get_event_number(); \ - eventb(FUNC)=MPE_Log_get_event_number(); \ - MPE_Describe_state(eventa(FUNC), eventb(FUNC), FUNC, p_color); \ - } \ - MPE_Log_event(eventa(FUNC), 0, p_event_start); \ +#define BEGIN_MPE_LOG \ + if (H5_MPEinit_g) { \ + sprintf(p_event_start, "start %s", FUNC); \ + if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ + const char *p_color = "red"; \ + eventa(FUNC) = MPE_Log_get_event_number(); \ + eventb(FUNC) = MPE_Log_get_event_number(); \ + MPE_Describe_state(eventa(FUNC), eventb(FUNC), FUNC, p_color); \ + } \ + MPE_Log_event(eventa(FUNC), 0, p_event_start); \ } - /*------------------------------------------------------------------------ * Purpose: Finish the collection of MPE log information for a function. * It should be after the actual function's process. * * Programmer: Long Wang */ -#define FINISH_MPE_LOG \ - if (H5_MPEinit_g) { \ - MPE_Log_event(eventb(FUNC), 0, FUNC); \ +#define FINISH_MPE_LOG \ + if (H5_MPEinit_g) { \ + MPE_Log_event(eventb(FUNC), 0, FUNC); \ } -#else /* H5_HAVE_MPE */ -#define MPE_LOG_VARS /* void */ -#define BEGIN_MPE_LOG /* void */ -#define FINISH_MPE_LOG /* void */ +#else /* H5_HAVE_MPE */ +#define MPE_LOG_VARS /* void */ +#define BEGIN_MPE_LOG /* void */ +#define FINISH_MPE_LOG /* void */ #endif /* H5_HAVE_MPE */ @@ -286,7 +271,7 @@ * never be raised by the hdf5 library). */ #ifndef SIGBUS -# define SIGBUS SIGILL +#define SIGBUS SIGILL #endif /* @@ -296,85 +281,75 @@ * Note that Solaris Studio supports attribute, but does not support the * attributes we use. * + * When using H5_ATTR_FALLTHROUGH, you should also include a comment that + * says FALLTHROUGH to reduce warnings on compilers that don't use + * attributes but do respect fall-through comments. + * * H5_ATTR_CONST is redefined in tools/h5repack/dynlib_rpk.c to quiet * gcc warnings (it has to use the public API and can't include this * file). Be sure to update that file if the #ifdefs change here. */ -#ifdef __cplusplus -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_DEPRECATED_USED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_DEBUG_API_USED /*void*/ -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ -#else /* __cplusplus */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) -# define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z))) -# define H5_ATTR_UNUSED __attribute__((unused)) +#define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) +#define H5_ATTR_UNUSED __attribute__((unused)) #ifdef H5_HAVE_PARALLEL -# define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) -# define H5_ATTR_PARALLEL_USED /*void*/ +#define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) +#define H5_ATTR_PARALLEL_USED /*void*/ #else -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED __attribute__((unused)) +#define H5_ATTR_PARALLEL_UNUSED /*void*/ +#define H5_ATTR_PARALLEL_USED __attribute__((unused)) #endif #ifdef H5_NO_DEPRECATED_SYMBOLS -#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED -#else /* H5_NO_DEPRECATED_SYMBOLS */ -#define H5_ATTR_DEPRECATED_USED /*void*/ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED +#else /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ #ifdef H5_DEBUG_API -#define H5_ATTR_DEBUG_API_USED /*void*/ -#else /* H5_DEBUG_API */ -#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED +#define H5_ATTR_DEBUG_API_USED /*void*/ +#else /* H5_DEBUG_API */ +#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED #endif /* H5_DEBUG_API */ #ifndef NDEBUG -#define H5_ATTR_NDEBUG_UNUSED /*void*/ -#else /* NDEBUG */ -#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#else /* NDEBUG */ +#define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED #endif /* NDEBUG */ -# define H5_ATTR_NORETURN __attribute__((noreturn)) -# define H5_ATTR_CONST __attribute__((const)) -# define H5_ATTR_PURE __attribute__((pure)) +#define H5_ATTR_NORETURN __attribute__((noreturn)) +#define H5_ATTR_CONST __attribute__((const)) +#define H5_ATTR_PURE __attribute__((pure)) #if defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) -# define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); +#define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); #else -# define H5_ATTR_FALLTHROUGH /*void*/ +#define H5_ATTR_FALLTHROUGH /*void*/ #endif #else -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_DEBUG_API_USED /*void*/ -# define H5_ATTR_DEPRECATED_USED /*void*/ -# define H5_ATTR_PARALLEL_UNUSED /*void*/ -# define H5_ATTR_PARALLEL_USED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +#define H5_ATTR_FORMAT(X, Y, Z) /*void*/ +#define H5_ATTR_UNUSED /*void*/ +#define H5_ATTR_NDEBUG_UNUSED /*void*/ +#define H5_ATTR_DEBUG_API_USED /*void*/ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#define H5_ATTR_PARALLEL_UNUSED /*void*/ +#define H5_ATTR_PARALLEL_USED /*void*/ +#define H5_ATTR_NORETURN /*void*/ +#define H5_ATTR_CONST /*void*/ +#define H5_ATTR_PURE /*void*/ +#define H5_ATTR_FALLTHROUGH /*void*/ #endif -#endif /* __cplusplus */ /* * Networking headers used by the mirror VFD and related tests and utilities. */ #ifdef H5_HAVE_ARPA_INET_H -# include +#include #endif #ifdef H5_HAVE_NETDB_H -# include +#include #endif #ifdef H5_HAVE_NETINET_IN_H -# include +#include #endif #ifdef H5_HAVE_SYS_SOCKET_H -# include +#include #endif /* @@ -386,9 +361,8 @@ * function, remember to compare against zero and not one of these two * values. */ -#define SUCCEED 0 +#define SUCCEED 0 #define FAIL (-1) -#define UFAIL (unsigned)(-1) /* The HDF5 library uses the symbol `ERR` frequently. So do * header files for libraries such as curses(3), terminfo(3), etc. @@ -400,51 +374,51 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif /* minimum of two, three, or four values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#define MIN2(a,b) MIN(a,b) -#define MIN3(a,b,c) MIN(a,MIN(b,c)) -#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MIN2(a, b) MIN(a, b) +#define MIN3(a, b, c) MIN(a, MIN(b, c)) +#define MIN4(a, b, c, d) MIN(MIN(a, b), MIN(c, d)) /* maximum of two, three, or four values */ #undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define MAX2(a, b) MAX(a, b) +#define MAX3(a, b, c) MAX(a, MAX(b, c)) +#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d)) /* limit the middle value to be within a range (inclusive) */ -#define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) +#define RANGE(LO, X, HI) MAX(LO, MIN(X, HI)) /* absolute value */ #ifndef ABS -# define ABS(a) (((a)>=0) ? (a) : -(a)) +#define ABS(a) (((a) >= 0) ? (a) : -(a)) #endif /* sign of argument */ #ifndef SIGN -# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) +#define SIGN(a) ((a) > 0 ? 1 : (a) < 0 ? -1 : 0) #endif /* test for number that is a power of 2 */ /* (from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2) */ -# define POWER_OF_TWO(n) (!(n & (n - 1)) && n) +#define POWER_OF_TWO(n) (!(n & (n - 1)) && n) /* Raise an integer to a power of 2 */ -# define H5_EXP2(n) (1 << (n)) +#define H5_EXP2(n) (1 << (n)) /* * HDF Boolean type. */ #ifndef FALSE - #define FALSE false +#define FALSE false #endif #ifndef TRUE - #define TRUE true +#define TRUE true #endif /* @@ -454,65 +428,65 @@ * be exactly one byte wide because we use it for pointer calculations to * void* memory. */ -#if H5_SIZEOF_INT8_T==0 - typedef signed char int8_t; -# undef H5_SIZEOF_INT8_T -# define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR -#elif H5_SIZEOF_INT8_T==1 +#if H5_SIZEOF_INT8_T == 0 +typedef signed char int8_t; +#undef H5_SIZEOF_INT8_T +#define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR +#elif H5_SIZEOF_INT8_T == 1 #else -# error "the int8_t type must be 1 byte wide" +#error "the int8_t type must be 1 byte wide" #endif -#if H5_SIZEOF_UINT8_T==0 - typedef unsigned char uint8_t; -# undef H5_SIZEOF_UINT8_T -# define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR -#elif H5_SIZEOF_UINT8_T==1 +#if H5_SIZEOF_UINT8_T == 0 +typedef unsigned char uint8_t; +#undef H5_SIZEOF_UINT8_T +#define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR +#elif H5_SIZEOF_UINT8_T == 1 #else -# error "the uint8_t type must be 1 byte wide" +#error "the uint8_t type must be 1 byte wide" #endif -#if H5_SIZEOF_INT16_T>=2 -#elif H5_SIZEOF_SHORT>=2 - typedef short int16_t; -# undef H5_SIZEOF_INT16_T -# define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=2 - typedef int int16_t; -# undef H5_SIZEOF_INT16_T -# define H5_SIZEOF_INT16_T H5_SIZEOF_INT +#if H5_SIZEOF_INT16_T >= 2 +#elif H5_SIZEOF_SHORT >= 2 +typedef short int16_t; +#undef H5_SIZEOF_INT16_T +#define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 2 +typedef int int16_t; +#undef H5_SIZEOF_INT16_T +#define H5_SIZEOF_INT16_T H5_SIZEOF_INT #else -# error "nothing appropriate for int16_t" +#error "nothing appropriate for int16_t" #endif -#if H5_SIZEOF_UINT16_T>=2 -#elif H5_SIZEOF_SHORT>=2 - typedef unsigned short uint16_t; -# undef H5_SIZEOF_UINT16_T -# define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=2 - typedef unsigned uint16_t; -# undef H5_SIZEOF_UINT16_T -# define H5_SIZEOF_UINT16_T H5_SIZEOF_INT +#if H5_SIZEOF_UINT16_T >= 2 +#elif H5_SIZEOF_SHORT >= 2 +typedef unsigned short uint16_t; +#undef H5_SIZEOF_UINT16_T +#define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 2 +typedef unsigned uint16_t; +#undef H5_SIZEOF_UINT16_T +#define H5_SIZEOF_UINT16_T H5_SIZEOF_INT #else -# error "nothing appropriate for uint16_t" +#error "nothing appropriate for uint16_t" #endif -#if H5_SIZEOF_INT32_T>=4 -#elif H5_SIZEOF_SHORT>=4 - typedef short int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=4 - typedef int int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=4 - typedef long int32_t; -# undef H5_SIZEOF_INT32_T -# define H5_SIZEOF_INT32_T H5_SIZEOF_LONG +#if H5_SIZEOF_INT32_T >= 4 +#elif H5_SIZEOF_SHORT >= 4 +typedef short int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 4 +typedef int int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 4 +typedef long int32_t; +#undef H5_SIZEOF_INT32_T +#define H5_SIZEOF_INT32_T H5_SIZEOF_LONG #else -# error "nothing appropriate for int32_t" +#error "nothing appropriate for int32_t" #endif /* @@ -520,56 +494,55 @@ * most part. */ #ifndef LLONG_MAX -# define LLONG_MAX ((long long)(((unsigned long long)1 \ - <<(8*sizeof(long long)-1))-1)) -# define LLONG_MIN ((long long)(-LLONG_MAX)-1) +#define LLONG_MAX ((long long)(((unsigned long long)1 << (8 * sizeof(long long) - 1)) - 1)) +#define LLONG_MIN ((long long)(-LLONG_MAX) - 1) #endif #ifndef ULLONG_MAX -# define ULLONG_MAX ((unsigned long long)((long long)(-1))) +#define ULLONG_MAX ((unsigned long long)((long long)(-1))) #endif #ifndef SIZET_MAX -# define SIZET_MAX ((size_t)(ssize_t)(-1)) -# define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) +#define SIZET_MAX ((size_t)(ssize_t)(-1)) +#define SSIZET_MAX ((ssize_t)(((size_t)1 << (8 * sizeof(ssize_t) - 1)) - 1)) #endif /* * Maximum & minimum values for our typedefs. */ -#define HSIZET_MAX ((hsize_t)ULLONG_MAX) -#define HSSIZET_MAX ((hssize_t)LLONG_MAX) -#define HSSIZET_MIN (~(HSSIZET_MAX)) +#define HSIZET_MAX ((hsize_t)ULLONG_MAX) +#define HSSIZET_MAX ((hssize_t)LLONG_MAX) +#define HSSIZET_MIN (~(HSSIZET_MAX)) /* * Types and max sizes for POSIX I/O. * OS X (Darwin) is odd since the max I/O size does not match the types. */ #if defined(H5_HAVE_WIN32_API) -# define h5_posix_io_t unsigned int -# define h5_posix_io_ret_t int -# define H5_POSIX_MAX_IO_BYTES INT_MAX +#define h5_posix_io_t unsigned int +#define h5_posix_io_ret_t int +#define H5_POSIX_MAX_IO_BYTES INT_MAX #elif defined(H5_HAVE_DARWIN) -# define h5_posix_io_t size_t -# define h5_posix_io_ret_t ssize_t -# define H5_POSIX_MAX_IO_BYTES INT_MAX +#define h5_posix_io_t size_t +#define h5_posix_io_ret_t ssize_t +#define H5_POSIX_MAX_IO_BYTES INT_MAX #else -# define h5_posix_io_t size_t -# define h5_posix_io_ret_t ssize_t -# define H5_POSIX_MAX_IO_BYTES SSIZET_MAX +#define h5_posix_io_t size_t +#define h5_posix_io_ret_t ssize_t +#define H5_POSIX_MAX_IO_BYTES SSIZET_MAX #endif /* POSIX I/O mode used as the third parameter to open/_open * when creating a new file (O_CREAT is set). */ #if defined(H5_HAVE_WIN32_API) -# define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE) +#define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE) #else -# define H5_POSIX_CREATE_MODE_RW 0666 +#define H5_POSIX_CREATE_MODE_RW 0666 #endif /* Represents an empty asynchronous request handle. * Used in the VOL code. */ -#define H5_REQUEST_NULL NULL +#define H5_REQUEST_NULL NULL /* * Methods to compare the equality of floating-point values: @@ -583,13 +556,13 @@ * It's the developer's responsibility not to pass in the value 0, which * may cause the equation to fail. */ -#define H5_FLT_ABS_EQUAL(X,Y) (HDfabsf((X)-(Y)) < FLT_EPSILON) -#define H5_DBL_ABS_EQUAL(X,Y) (HDfabs ((X)-(Y)) < DBL_EPSILON) -#define H5_LDBL_ABS_EQUAL(X,Y) (HDfabsl((X)-(Y)) < LDBL_EPSILON) +#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON) +#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON) +#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON) -#define H5_FLT_REL_EQUAL(X,Y,M) (HDfabsf(((Y)-(X)) / (X)) < (M)) -#define H5_DBL_REL_EQUAL(X,Y,M) (HDfabs (((Y)-(X)) / (X)) < (M)) -#define H5_LDBL_REL_EQUAL(X,Y,M) (HDfabsl(((Y)-(X)) / (X)) < (M)) +#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M)) +#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M)) +#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M)) /* KiB, MiB, GiB, TiB, PiB, EiB - Used in profiling and timing code */ #define H5_KB (1024.0F) @@ -605,10 +578,10 @@ * with system-provided flock() calls since the values will come from the * header file. */ -#define LOCK_SH 0x01 -#define LOCK_EX 0x02 -#define LOCK_NB 0x04 -#define LOCK_UN 0x08 +#define LOCK_SH 0x01 +#define LOCK_EX 0x02 +#define LOCK_NB 0x04 +#define LOCK_UN 0x08 #endif /* H5_HAVE_FLOCK */ /* Typedefs and functions for timing certain parts of the library. */ @@ -617,47 +590,47 @@ * platform-independent timers. */ typedef struct { - double user; /* User time in seconds */ - double system; /* System time in seconds */ - double elapsed; /* Elapsed (wall clock) time in seconds */ + double user; /* User time in seconds */ + double system; /* System time in seconds */ + double elapsed; /* Elapsed (wall clock) time in seconds */ } H5_timevals_t; /* Timer structure for platform-independent timers */ typedef struct { - H5_timevals_t initial; /* Current interval start time */ - H5_timevals_t final_interval; /* Last interval elapsed time */ - H5_timevals_t total; /* Total elapsed time for all intervals */ - hbool_t is_running; /* Whether timer is running */ + H5_timevals_t initial; /* Current interval start time */ + H5_timevals_t final_interval; /* Last interval elapsed time */ + H5_timevals_t total; /* Total elapsed time for all intervals */ + hbool_t is_running; /* Whether timer is running */ } H5_timer_t; /* Returns library bandwidth as a pretty string */ -H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); +H5_DLL void H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds); /* Timer functionality */ -H5_DLL time_t H5_now(void); +H5_DLL time_t H5_now(void); H5_DLL uint64_t H5_now_usec(void); -H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/); -H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); -H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); -H5_DLL char *H5_timer_get_time_string(double seconds); +H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL char * H5_timer_get_time_string(double seconds); /* Depth of object copy */ typedef enum { - H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */ - H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */ + H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */ + H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */ } H5_copy_depth_t; /* Common object copying udata (right now only used for groups and datasets) */ typedef struct H5O_copy_file_ud_common_t { - struct H5O_pline_t *src_pline; /* Copy of filter pipeline for object */ + struct H5O_pline_t *src_pline; /* Copy of filter pipeline for object */ } H5O_copy_file_ud_common_t; /* Unique object "position" */ typedef struct { - unsigned long fileno; /* The unique identifier for the file of the object */ - haddr_t addr; /* The unique address of the object's header in that file */ + unsigned long fileno; /* The unique identifier for the file of the object */ + haddr_t addr; /* The unique address of the object's header in that file */ } H5_obj_t; /* @@ -667,213 +640,213 @@ typedef struct { /* Put all platform-specific definitions in the following file */ /* so that the following definitions are platform free. */ -#include "H5win32defs.h" /* For Windows-specific definitions */ +#include "H5win32defs.h" /* For Windows-specific definitions */ #ifndef HDabort - #define HDabort() abort() +#define HDabort() abort() #endif /* HDabort */ #ifndef HDabs - #define HDabs(X) abs(X) +#define HDabs(X) abs(X) #endif /* HDabs */ #ifndef HDaccept - #define HDaccept(A,B,C) accept((A),(B),(C)) /* mirror VFD */ -#endif /* HDaccept */ +#define HDaccept(A, B, C) accept((A), (B), (C)) /* mirror VFD */ +#endif /* HDaccept */ #ifndef HDaccess - #define HDaccess(F,M) access(F, M) +#define HDaccess(F, M) access(F, M) #endif /* HDaccess */ #ifndef HDacos - #define HDacos(X) acos(X) +#define HDacos(X) acos(X) #endif /* HDacos */ #ifndef HDalarm - #ifdef H5_HAVE_ALARM - #define HDalarm(N) alarm(N) - #else /* H5_HAVE_ALARM */ - #define HDalarm(N) (0) - #endif /* H5_HAVE_ALARM */ +#ifdef H5_HAVE_ALARM +#define HDalarm(N) alarm(N) +#else /* H5_HAVE_ALARM */ +#define HDalarm(N) (0) +#endif /* H5_HAVE_ALARM */ #endif /* HDalarm */ #ifndef HDasctime - #define HDasctime(T) asctime(T) +#define HDasctime(T) asctime(T) #endif /* HDasctime */ #ifndef HDasin - #define HDasin(X) asin(X) +#define HDasin(X) asin(X) #endif /* HDasin */ #ifndef HDasprintf - #define HDasprintf asprintf /*varargs*/ -#endif /* HDasprintf */ +#define HDasprintf asprintf /*varargs*/ +#endif /* HDasprintf */ #ifndef HDassert - #define HDassert(X) assert(X) +#define HDassert(X) assert(X) #endif /* HDassert */ #ifndef HDatan - #define HDatan(X) atan(X) +#define HDatan(X) atan(X) #endif /* HDatan */ #ifndef HDatan2 - #define HDatan2(X,Y) atan2(X,Y) +#define HDatan2(X, Y) atan2(X, Y) #endif /* HDatan2 */ #ifndef HDatexit - #define HDatexit(F) atexit(F) +#define HDatexit(F) atexit(F) #endif /* HDatexit */ #ifndef HDatof - #define HDatof(S) atof(S) +#define HDatof(S) atof(S) #endif /* HDatof */ #ifndef HDatoi - #define HDatoi(S) atoi(S) +#define HDatoi(S) atoi(S) #endif /* HDatoi */ #ifndef HDatol - #define HDatol(S) atol(S) +#define HDatol(S) atol(S) #endif /* HDatol */ #ifndef HDatoll - #define HDatoll(S) atoll(S) +#define HDatoll(S) atoll(S) #endif /* HDatol */ #ifndef HDbind - #define HDbind(A,B,C) bind((A),(B),(C)) /* mirror VFD */ -#endif /* HDbind */ +#define HDbind(A, B, C) bind((A), (B), (C)) /* mirror VFD */ +#endif /* HDbind */ #ifndef HDbsearch - #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) +#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) #endif /* HDbsearch */ #ifndef HDcalloc - #define HDcalloc(N,Z) calloc(N,Z) +#define HDcalloc(N, Z) calloc(N, Z) #endif /* HDcalloc */ #ifndef HDceil - #define HDceil(X) ceil(X) +#define HDceil(X) ceil(X) #endif /* HDceil */ #ifndef HDcfgetispeed - #define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetispeed(T) cfgetispeed(T) #endif /* HDcfgetispeed */ #ifndef HDcfgetospeed - #define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) #endif /* HDcfgetospeed */ #ifndef HDcfsetispeed - #define HDcfsetispeed(T,S) cfsetispeed(T,S) +#define HDcfsetispeed(T, S) cfsetispeed(T, S) #endif /* HDcfsetispeed */ #ifndef HDcfsetospeed - #define HDcfsetospeed(T,S) cfsetospeed(T,S) +#define HDcfsetospeed(T, S) cfsetospeed(T, S) #endif /* HDcfsetospeed */ #ifndef HDchdir - #define HDchdir(S) chdir(S) +#define HDchdir(S) chdir(S) #endif /* HDchdir */ #ifndef HDchmod - #define HDchmod(S,M) chmod(S,M) +#define HDchmod(S, M) chmod(S, M) #endif /* HDchmod */ #ifndef HDchown - #define HDchown(S,O,G) chown(S,O,G) +#define HDchown(S, O, G) chown(S, O, G) #endif /* HDchown */ #ifndef HDclearerr - #define HDclearerr(F) clearerr(F) +#define HDclearerr(F) clearerr(F) #endif /* HDclearerr */ #ifndef HDclock - #define HDclock() clock() +#define HDclock() clock() #endif /* HDclock */ #ifndef HDclock_gettime - #define HDclock_gettime(CID, TS) clock_gettime(CID, TS) +#define HDclock_gettime(CID, TS) clock_gettime(CID, TS) #endif /* HDclock_gettime */ #ifndef HDclose - #define HDclose(F) close(F) +#define HDclose(F) close(F) #endif /* HDclose */ #ifndef HDclosedir - #define HDclosedir(D) closedir(D) +#define HDclosedir(D) closedir(D) #endif /* HDclosedir */ #ifndef HDconnect - #define HDconnect(A,B,C) connect((A),(B),(C)) /* mirror VFD */ -#endif /* HDconnect */ +#define HDconnect(A, B, C) connect((A), (B), (C)) /* mirror VFD */ +#endif /* HDconnect */ #ifndef HDcos - #define HDcos(X) cos(X) +#define HDcos(X) cos(X) #endif /* HDcos */ #ifndef HDcosh - #define HDcosh(X) cosh(X) +#define HDcosh(X) cosh(X) #endif /* HDcosh */ #ifndef HDcreat - #define HDcreat(S,M) creat(S,M) +#define HDcreat(S, M) creat(S, M) #endif /* HDcreat */ #ifndef HDctermid - #define HDctermid(S) ctermid(S) +#define HDctermid(S) ctermid(S) #endif /* HDctermid */ #ifndef HDctime - #define HDctime(T) ctime(T) +#define HDctime(T) ctime(T) #endif /* HDctime */ #ifndef HDcuserid - #define HDcuserid(S) cuserid(S) +#define HDcuserid(S) cuserid(S) #endif /* HDcuserid */ #ifndef HDdifftime - #ifdef H5_HAVE_DIFFTIME - #define HDdifftime(X,Y) difftime(X,Y) - #else /* H5_HAVE_DIFFTIME */ - #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) - #endif /* H5_HAVE_DIFFTIME */ +#ifdef H5_HAVE_DIFFTIME +#define HDdifftime(X, Y) difftime(X, Y) +#else /* H5_HAVE_DIFFTIME */ +#define HDdifftime(X, Y) ((double)(X) - (double)(Y)) +#endif /* H5_HAVE_DIFFTIME */ #endif /* HDdifftime */ #ifndef HDdiv - #define HDdiv(X,Y) div(X,Y) +#define HDdiv(X, Y) div(X, Y) #endif /* HDdiv */ #ifndef HDdup - #define HDdup(F) dup(F) +#define HDdup(F) dup(F) #endif /* HDdup */ #ifndef HDdup2 - #define HDdup2(F,I) dup2(F,I) +#define HDdup2(F, I) dup2(F, I) #endif /* HDdup2 */ /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ #ifndef HDexecv - #define HDexecv(S,AV) execv(S,AV) +#define HDexecv(S, AV) execv(S, AV) #endif /* HDexecv */ #ifndef HDexecve - #define HDexecve(S,AV,E) execve(S,AV,E) +#define HDexecve(S, AV, E) execve(S, AV, E) #endif /* HDexecve */ #ifndef HDexecvp - #define HDexecvp(S,AV) execvp(S,AV) +#define HDexecvp(S, AV) execvp(S, AV) #endif /* HDexecvp */ #ifndef HDexit - #define HDexit(N) exit(N) +#define HDexit(N) exit(N) #endif /* HDexit */ #ifndef HD_exit - #define HD_exit(N) _exit(N) +#define HD_exit(N) _exit(N) #endif /* HD_exit */ #ifndef HDexp - #define HDexp(X) exp(X) +#define HDexp(X) exp(X) #endif /* HDexp */ #ifndef HDexp2 - #define HDexp2(X) exp2(X) +#define HDexp2(X) exp2(X) #endif /* HDexp2 */ #ifndef HDfabs - #define HDfabs(X) fabs(X) +#define HDfabs(X) fabs(X) #endif /* HDfabs */ /* use ABS() because fabsf() fabsl() are not common yet. */ #ifndef HDfabsf - #define HDfabsf(X) ABS(X) +#define HDfabsf(X) ABS(X) #endif /* HDfabsf */ #ifndef HDfabsl - #define HDfabsl(X) ABS(X) +#define HDfabsl(X) ABS(X) #endif /* HDfabsl */ #ifndef HDfclose - #define HDfclose(F) fclose(F) +#define HDfclose(F) fclose(F) #endif /* HDfclose */ #ifdef H5_HAVE_FCNTL - #ifndef HDfcntl - #define HDfcntl(F,C,...) fcntl(F,C,__VA_ARGS__) - #endif /* HDfcntl */ +#ifndef HDfcntl +#define HDfcntl(F, C, ...) fcntl(F, C, __VA_ARGS__) +#endif /* HDfcntl */ #endif /* H5_HAVE_FCNTL */ #ifndef HDfdopen - #define HDfdopen(N,S) fdopen(N,S) +#define HDfdopen(N, S) fdopen(N, S) #endif /* HDfdopen */ #ifndef HDfeof - #define HDfeof(F) feof(F) +#define HDfeof(F) feof(F) #endif /* HDfeof */ #ifndef HDferror - #define HDferror(F) ferror(F) +#define HDferror(F) ferror(F) #endif /* HDferror */ #ifndef HDfflush - #define HDfflush(F) fflush(F) +#define HDfflush(F) fflush(F) #endif /* HDfflush */ #ifndef HDfgetc - #define HDfgetc(F) fgetc(F) +#define HDfgetc(F) fgetc(F) #endif /* HDfgetc */ #ifndef HDfgetpos - #define HDfgetpos(F,P) fgetpos(F,P) +#define HDfgetpos(F, P) fgetpos(F, P) #endif /* HDfgetpos */ #ifndef HDfgets - #define HDfgets(S,N,F) fgets(S,N,F) +#define HDfgets(S, N, F) fgets(S, N, F) #endif /* HDfgets */ #ifndef HDfileno - #define HDfileno(F) fileno(F) +#define HDfileno(F) fileno(F) #endif /* HDfileno */ /* Since flock is so prevalent, always build these functions * when possible to avoid them becoming dead code. @@ -883,795 +856,792 @@ H5_DLL int Pflock(int fd, int operation); #endif /* H5_HAVE_FCNTL */ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDflock - /* NOTE: flock(2) is not present on all POSIX systems. - * If it is not present, we try a flock() equivalent based on - * fcntl(2), then fall back to a function that always succeeds - * if it is not present at all (Windows uses a separate Wflock() - * function). - */ - #if defined(H5_HAVE_FLOCK) - #define HDflock(F,L) flock(F,L) - #elif defined(H5_HAVE_FCNTL) - #define HDflock(F,L) Pflock(F,L) - #else - #define HDflock(F,L) Nflock(F,L) - #endif /* H5_HAVE_FLOCK */ +/* NOTE: flock(2) is not present on all POSIX systems. + * If it is not present, we try a flock() equivalent based on + * fcntl(2), then fall back to a function that always succeeds + * if it is not present at all (Windows uses a separate Wflock() + * function). + */ +#if defined(H5_HAVE_FLOCK) +#define HDflock(F, L) flock(F, L) +#elif defined(H5_HAVE_FCNTL) +#define HDflock(F, L) Pflock(F, L) +#else +#define HDflock(F, L) Nflock(F, L) +#endif /* H5_HAVE_FLOCK */ #endif /* HDflock */ #ifndef HDfloor - #define HDfloor(X) floor(X) +#define HDfloor(X) floor(X) #endif /* HDfloor */ #ifndef HDfmod - #define HDfmod(X,Y) fmod(X,Y) +#define HDfmod(X, Y) fmod(X, Y) #endif /* HDfmod */ #ifndef HDfopen - #define HDfopen(S,M) fopen(S,M) +#define HDfopen(S, M) fopen(S, M) #endif /* HDfopen */ #ifndef HDfork - #define HDfork() fork() +#define HDfork() fork() #endif /* HDfork */ +#ifndef HDfprintf +#define HDfprintf fprintf +#endif #ifndef HDfpathconf - #define HDfpathconf(F,N) fpathconf(F,N) +#define HDfpathconf(F, N) fpathconf(F, N) #endif /* HDfpathconf */ -H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDfputc - #define HDfputc(C,F) fputc(C,F) +#define HDfputc(C, F) fputc(C, F) #endif /* HDfputc */ #ifndef HDfputs - #define HDfputs(S,F) fputs(S,F) +#define HDfputs(S, F) fputs(S, F) #endif /* HDfputs */ #ifndef HDfread - #define HDfread(M,Z,N,F) fread(M,Z,N,F) +#define HDfread(M, Z, N, F) fread(M, Z, N, F) #endif /* HDfread */ #ifndef HDfree - #define HDfree(M) free(M) +#define HDfree(M) free(M) #endif /* HDfree */ #ifndef HDfreopen - #define HDfreopen(S,M,F) freopen(S,M,F) +#define HDfreopen(S, M, F) freopen(S, M, F) #endif /* HDfreopen */ #ifndef HDfrexp - #define HDfrexp(X,N) frexp(X,N) +#define HDfrexp(X, N) frexp(X, N) #endif /* HDfrexp */ /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifndef HDfrexpf - #ifdef H5_HAVE_FREXPF - #define HDfrexpf(X,N) frexpf(X,N) - #else /* H5_HAVE_FREXPF */ - #define HDfrexpf(X,N) frexp(X,N) - #endif /* H5_HAVE_FREXPF */ +#ifdef H5_HAVE_FREXPF +#define HDfrexpf(X, N) frexpf(X, N) +#else /* H5_HAVE_FREXPF */ +#define HDfrexpf(X, N) frexp(X, N) +#endif /* H5_HAVE_FREXPF */ #endif /* HDfrexpf */ #ifndef HDfrexpl - #ifdef H5_HAVE_FREXPL - #define HDfrexpl(X,N) frexpl(X,N) - #else /* H5_HAVE_FREXPL */ - #define HDfrexpl(X,N) frexp(X,N) - #endif /* H5_HAVE_FREXPL */ +#ifdef H5_HAVE_FREXPL +#define HDfrexpl(X, N) frexpl(X, N) +#else /* H5_HAVE_FREXPL */ +#define HDfrexpl(X, N) frexp(X, N) +#endif /* H5_HAVE_FREXPL */ #endif /* HDfrexpl */ /* fscanf() variable arguments */ #ifndef HDfseek - #define HDfseek(F,O,W) fseeko(F,O,W) +#define HDfseek(F, O, W) fseeko(F, O, W) #endif /* HDfseek */ #ifndef HDfsetpos - #define HDfsetpos(F,P) fsetpos(F,P) +#define HDfsetpos(F, P) fsetpos(F, P) #endif /* HDfsetpos */ #ifndef HDfstat - #define HDfstat(F,B) fstat(F,B) +#define HDfstat(F, B) fstat(F, B) #endif /* HDfstat */ #ifndef HDlstat - #define HDlstat(S,B) lstat(S,B) +#define HDlstat(S, B) lstat(S, B) #endif /* HDlstat */ #ifndef HDstat - #define HDstat(S,B) stat(S,B) +#define HDstat(S, B) stat(S, B) #endif /* HDstat */ #ifndef H5_HAVE_WIN32_API /* These definitions differ in Windows and are defined in * H5win32defs for that platform. */ -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; -#define HDoff_t off_t +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t #endif /* H5_HAVE_WIN32_API */ #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T #ifndef HDftell - #define HDftell(F) ftell(F) +#define HDftell(F) ftell(F) #endif /* HDftell */ #ifndef HDftruncate - #define HDftruncate(F,L) ftruncate(F,L) +#define HDftruncate(F, L) ftruncate(F, L) #endif /* HDftruncate */ #ifndef HDfwrite - #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) +#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) #endif /* HDfwrite */ #ifndef HDgetc - #define HDgetc(F) getc(F) +#define HDgetc(F) getc(F) #endif /* HDgetc */ #ifndef HDgetchar - #define HDgetchar() getchar() +#define HDgetchar() getchar() #endif /* HDgetchar */ #ifndef HDgetcwd - #define HDgetcwd(S,Z) getcwd(S,Z) +#define HDgetcwd(S, Z) getcwd(S, Z) #endif /* HDgetcwd */ #ifndef HDgetdcwd - #define HDgetdcwd(D,S,Z) getcwd(S,Z) +#define HDgetdcwd(D, S, Z) getcwd(S, Z) #endif /* HDgetdcwd */ #ifndef HDgetdrive - #define HDgetdrive() 0 +#define HDgetdrive() 0 #endif /* HDgetdrive */ #ifndef HDgetegid - #define HDgetegid() getegid() +#define HDgetegid() getegid() #endif /* HDgetegid() */ #ifndef HDgetenv - #define HDgetenv(S) getenv(S) +#define HDgetenv(S) getenv(S) #endif /* HDgetenv */ #ifndef HDgeteuid - #define HDgeteuid() geteuid() +#define HDgeteuid() geteuid() #endif /* HDgeteuid */ #ifndef HDgetgid - #define HDgetgid() getgid() +#define HDgetgid() getgid() #endif /* HDgetgid */ #ifndef HDgetgrgid - #define HDgetgrgid(G) getgrgid(G) +#define HDgetgrgid(G) getgrgid(G) #endif /* HDgetgrgid */ #ifndef HDgetgrnam - #define HDgetgrnam(S) getgrnam(S) +#define HDgetgrnam(S) getgrnam(S) #endif /* HDgetgrnam */ #ifndef HDgetgroups - #define HDgetgroups(Z,G) getgroups(Z,G) +#define HDgetgroups(Z, G) getgroups(Z, G) #endif /* HDgetgroups */ #ifndef HDgethostbyaddr - #define HDgethostbyaddr(A,B,C) gethostbyaddr((A),(B),(C)) /* mirror VFD */ -#endif /* HDgethostbyaddr */ +#define HDgethostbyaddr(A, B, C) gethostbyaddr((A), (B), (C)) /* mirror VFD */ +#endif /* HDgethostbyaddr */ #ifndef HDgethostname - #define HDgethostname(N,L) gethostname(N,L) +#define HDgethostname(N, L) gethostname(N, L) #endif /* HDgethostname */ #ifndef HDgetlogin - #define HDgetlogin() getlogin() +#define HDgetlogin() getlogin() #endif /* HDgetlogin */ #ifndef HDgetpgrp - #define HDgetpgrp() getpgrp() +#define HDgetpgrp() getpgrp() #endif /* HDgetpgrp */ #ifndef HDgetpid - #define HDgetpid() getpid() +#define HDgetpid() getpid() #endif /* HDgetpid */ #ifndef HDgetppid - #define HDgetppid() getppid() +#define HDgetppid() getppid() #endif /* HDgetppid */ #ifndef HDgetpwnam - #define HDgetpwnam(S) getpwnam(S) +#define HDgetpwnam(S) getpwnam(S) #endif /* HDgetpwnam */ #ifndef HDgetpwuid - #define HDgetpwuid(U) getpwuid(U) +#define HDgetpwuid(U) getpwuid(U) #endif /* HDgetpwuid */ #ifndef HDgetrusage - #define HDgetrusage(X,S) getrusage(X,S) +#define HDgetrusage(X, S) getrusage(X, S) #endif /* HDgetrusage */ /* Don't define HDgets - gets() was deprecated in C99 and removed in C11 */ #ifdef HDgets - #undef HDgets +#undef HDgets #endif /* HDgets */ #ifndef HDgettimeofday - #define HDgettimeofday(S,P) gettimeofday(S,P) +#define HDgettimeofday(S, P) gettimeofday(S, P) #endif /* HDgettimeofday */ #ifndef HDgetuid - #define HDgetuid() getuid() +#define HDgetuid() getuid() #endif /* HDgetuid */ #ifndef HDgmtime - #define HDgmtime(T) gmtime(T) +#define HDgmtime(T) gmtime(T) #endif /* HDgmtime */ #ifndef HDhtonl - #define HDhtonl(X) htonl((X)) /* mirror VFD */ -#endif /* HDhtonl */ +#define HDhtonl(X) htonl((X)) /* mirror VFD */ +#endif /* HDhtonl */ #ifndef HDhtons - #define HDhtons(X) htons((X)) /* mirror VFD */ -#endif /* HDhtons */ +#define HDhtons(X) htons((X)) /* mirror VFD */ +#endif /* HDhtons */ #ifndef HDinet_addr - #define HDinet_addr(C) inet_addr((C)) /* mirror VFD */ -#endif /* HDinet_addr */ +#define HDinet_addr(C) inet_addr((C)) /* mirror VFD */ +#endif /* HDinet_addr */ #ifndef HDinet_ntoa - #define HDinet_ntoa(C) inet_ntoa((C)) /* mirror VFD */ -#endif /* HDinet_ntoa */ +#define HDinet_ntoa(C) inet_ntoa((C)) /* mirror VFD */ +#endif /* HDinet_ntoa */ #ifndef HDisalnum - #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ -#endif /* HDisalnum */ +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#endif /* HDisalnum */ #ifndef HDisalpha - #define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ -#endif /* HDisalpha */ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#endif /* HDisalpha */ #ifndef HDisatty - #define HDisatty(F) isatty(F) +#define HDisatty(F) isatty(F) #endif /* HDisatty */ #ifndef HDiscntrl - #define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ -#endif /* HDiscntrl */ +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#endif /* HDiscntrl */ #ifndef HDisdigit - #define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ -#endif /* HDisdigit */ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#endif /* HDisdigit */ #ifndef HDisgraph - #define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ -#endif /* HDisgraph */ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#endif /* HDisgraph */ #ifndef HDislower - #define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ -#endif /* HDislower */ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#endif /* HDislower */ #ifndef HDisnan - #define HDisnan(X) isnan(X) +#define HDisnan(X) isnan(X) #endif /* HDisnan */ #ifndef HDisprint - #define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ -#endif /* HDisprint */ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#endif /* HDisprint */ #ifndef HDispunct - #define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ -#endif /* HDispunct */ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#endif /* HDispunct */ #ifndef HDisspace - #define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ -#endif /* HDisspace */ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#endif /* HDisspace */ #ifndef HDisupper - #define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ -#endif /* HDisupper */ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#endif /* HDisupper */ #ifndef HDisxdigit - #define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ -#endif /* HDisxdigit */ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#endif /* HDisxdigit */ #ifndef HDkill - #define HDkill(P,S) kill(P,S) +#define HDkill(P, S) kill(P, S) #endif /* HDkill */ #ifndef HDlabs - #define HDlabs(X) labs(X) +#define HDlabs(X) labs(X) #endif /* HDlabs */ #ifndef HDldexp - #define HDldexp(X,N) ldexp(X,N) +#define HDldexp(X, N) ldexp(X, N) #endif /* HDldexp */ #ifndef HDldiv - #define HDldiv(X,Y) ldiv(X,Y) +#define HDldiv(X, Y) ldiv(X, Y) #endif /* HDldiv */ #ifndef HDlink - #define HDlink(OLD,NEW) link(OLD,NEW) +#define HDlink(OLD, NEW) link(OLD, NEW) #endif /* HDlink */ #ifndef HDlisten - #define HDlisten(A,B) listen((A),(B)) /* mirror VFD */ -#endif /* HDlisten */ +#define HDlisten(A, B) listen((A), (B)) /* mirror VFD */ +#endif /* HDlisten */ #ifndef HDllround - #define HDllround(V) llround(V) +#define HDllround(V) llround(V) #endif /* HDround */ #ifndef HDllroundf - #define HDllroundf(V) llroundf(V) +#define HDllroundf(V) llroundf(V) #endif /* HDllroundf */ #ifndef HDllroundl - #define HDllroundl(V) llroundl(V) +#define HDllroundl(V) llroundl(V) #endif /* HDllroundl */ #ifndef HDlocaleconv - #define HDlocaleconv() localeconv() +#define HDlocaleconv() localeconv() #endif /* HDlocaleconv */ #ifndef HDlocaltime - #define HDlocaltime(T) localtime(T) +#define HDlocaltime(T) localtime(T) #endif /* HDlocaltime */ #ifndef HDlog - #define HDlog(X) log(X) +#define HDlog(X) log(X) #endif /* HDlog */ #ifndef HDlog10 - #define HDlog10(X) log10(X) +#define HDlog10(X) log10(X) #endif /* HDlog10 */ #ifndef HDlongjmp - #define HDlongjmp(J,N) longjmp(J,N) +#define HDlongjmp(J, N) longjmp(J, N) #endif /* HDlongjmp */ #ifndef HDlround - #define HDlround(V) lround(V) +#define HDlround(V) lround(V) #endif /* HDround */ #ifndef HDlroundf - #define HDlroundf(V) lroundf(V) +#define HDlroundf(V) lroundf(V) #endif /* HDlroundf */ #ifndef HDlroundl - #define HDlroundl(V) lroundl(V) +#define HDlroundl(V) lroundl(V) #endif /* HDroundl */ #ifndef HDlseek - #define HDlseek(F,O,W) lseek(F,O,W) +#define HDlseek(F, O, W) lseek(F, O, W) #endif /* HDlseek */ #ifndef HDmalloc - #define HDmalloc(Z) malloc(Z) +#define HDmalloc(Z) malloc(Z) #endif /* HDmalloc */ #ifndef HDposix_memalign - #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) +#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) #endif /* HDposix_memalign */ #ifndef HDmblen - #define HDmblen(S,N) mblen(S,N) +#define HDmblen(S, N) mblen(S, N) #endif /* HDmblen */ #ifndef HDmbstowcs - #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) +#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) #endif /* HDmbstowcs */ #ifndef HDmbtowc - #define HDmbtowc(P,S,Z) mbtowc(P,S,Z) +#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) #endif /* HDmbtowc */ #ifndef HDmemchr - #define HDmemchr(S,C,Z) memchr(S,C,Z) +#define HDmemchr(S, C, Z) memchr(S, C, Z) #endif /* HDmemchr */ #ifndef HDmemcmp - #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) #endif /* HDmemcmp */ #ifndef HDmemcpy - #define HDmemcpy(X,Y,Z) memcpy(X,Y,Z) +#define HDmemcpy(X, Y, Z) memcpy(X, Y, Z) #endif /* HDmemcpy */ #ifndef HDmemmove - #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) #endif /* HDmemmove */ #ifndef HDmemset - #define HDmemset(X,C,Z) memset(X,C,Z) +#define HDmemset(X, C, Z) memset(X, C, Z) #endif /* HDmemset */ #ifndef HDmkdir - #define HDmkdir(S,M) mkdir(S,M) +#define HDmkdir(S, M) mkdir(S, M) #endif /* HDmkdir */ #ifndef HDmkfifo - #define HDmkfifo(S,M) mkfifo(S,M) +#define HDmkfifo(S, M) mkfifo(S, M) #endif /* HDmkfifo */ #ifndef HDmktime - #define HDmktime(T) mktime(T) +#define HDmktime(T) mktime(T) #endif /* HDmktime */ #ifndef HDmodf - #define HDmodf(X,Y) modf(X,Y) +#define HDmodf(X, Y) modf(X, Y) #endif /* HDmodf */ #ifndef HDnanosleep - #define HDnanosleep(N, O) nanosleep(N, O) +#define HDnanosleep(N, O) nanosleep(N, O) #endif /* HDnanosleep */ #ifndef HDntohl - #define HDntohl(A) ntohl((A)) /* mirror VFD */ -#endif /* HDntohl */ +#define HDntohl(A) ntohl((A)) /* mirror VFD */ +#endif /* HDntohl */ #ifndef HDntohs - #define HDntohs(A) ntohs((A)) /* mirror VFD */ -#endif /* HDntohs */ +#define HDntohs(A) ntohs((A)) /* mirror VFD */ +#endif /* HDntohs */ #ifndef HDopen - #define HDopen(F,...) open(F,__VA_ARGS__) +#define HDopen(F, ...) open(F, __VA_ARGS__) #endif /* HDopen */ #ifndef HDopendir - #define HDopendir(S) opendir(S) +#define HDopendir(S) opendir(S) #endif /* HDopendir */ #ifndef HDpathconf - #define HDpathconf(S,N) pathconf(S,N) +#define HDpathconf(S, N) pathconf(S, N) #endif /* HDpathconf */ #ifndef HDpause - #define HDpause() pause() +#define HDpause() pause() #endif /* HDpause */ #ifndef HDperror - #define HDperror(S) perror(S) +#define HDperror(S) perror(S) #endif /* HDperror */ #ifndef HDpipe - #define HDpipe(F) pipe(F) +#define HDpipe(F) pipe(F) #endif /* HDpipe */ #ifndef HDpow - #define HDpow(X,Y) pow(X,Y) +#define HDpow(X, Y) pow(X, Y) #endif /* HDpow */ #ifndef HDpowf - #define HDpowf(X,Y) powf(X,Y) +#define HDpowf(X, Y) powf(X, Y) #endif /* HDpowf */ #ifndef HDpread - #define HDpread(F,B,C,O) pread(F,B,C,O) +#define HDpread(F, B, C, O) pread(F, B, C, O) #endif /* HDpread */ #ifndef HDprintf - #define HDprintf(...) HDfprintf(stdout, __VA_ARGS__) +#define HDprintf printf #endif /* HDprintf */ #ifndef HDputc - #define HDputc(C,F) putc(C,F) +#define HDputc(C, F) putc(C, F) #endif /* HDputc*/ #ifndef HDputchar - #define HDputchar(C) putchar(C) +#define HDputchar(C) putchar(C) #endif /* HDputchar */ #ifndef HDputs - #define HDputs(S) puts(S) +#define HDputs(S) puts(S) #endif /* HDputs */ #ifndef HDpwrite - #define HDpwrite(F,B,C,O) pwrite(F,B,C,O) +#define HDpwrite(F, B, C, O) pwrite(F, B, C, O) #endif /* HDpwrite */ #ifndef HDqsort - #define HDqsort(M,N,Z,F) qsort(M,N,Z,F) +#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) #endif /* HDqsort*/ #ifndef HDraise - #define HDraise(N) raise(N) +#define HDraise(N) raise(N) #endif /* HDraise */ #ifdef H5_HAVE_RAND_R - #ifndef HDrandom - #define HDrandom() HDrand() - #endif /* HDrandom */ - H5_DLL int HDrand(void); - #ifndef HDsrandom - #define HDsrandom(S) HDsrand(S) - #endif /* HDsrandom */ - H5_DLL void HDsrand(unsigned int seed); +#ifndef HDrandom +#define HDrandom() HDrand() +#endif /* HDrandom */ +H5_DLL int HDrand(void); +#ifndef HDsrandom +#define HDsrandom(S) HDsrand(S) +#endif /* HDsrandom */ +H5_DLL void HDsrand(unsigned int seed); #elif defined(H5_HAVE_RANDOM) - #ifndef HDrand - #define HDrand() random() - #endif /* HDrand */ - #ifndef HDrandom - #define HDrandom() random() - #endif /* HDrandom */ - #ifndef HDsrand - #define HDsrand(S) srandom(S) - #endif /* HDsrand */ - #ifndef HDsrandom - #define HDsrandom(S) srandom(S) - #endif /* HDsrandom */ -#else /* H5_HAVE_RANDOM */ - #ifndef HDrand - #define HDrand() rand() - #endif /* HDrand */ - #ifndef HDrandom - #define HDrandom() rand() - #endif /* HDrandom */ - #ifndef HDsrand - #define HDsrand(S) srand(S) - #endif /* HDsrand */ - #ifndef HDsrandom - #define HDsrandom(S) srand(S) - #endif /* HDsrandom */ +#ifndef HDrand +#define HDrand() random() +#endif /* HDrand */ +#ifndef HDrandom +#define HDrandom() random() +#endif /* HDrandom */ +#ifndef HDsrand +#define HDsrand(S) srandom(S) +#endif /* HDsrand */ +#ifndef HDsrandom +#define HDsrandom(S) srandom(S) +#endif /* HDsrandom */ +#else /* H5_HAVE_RANDOM */ +#ifndef HDrand +#define HDrand() rand() +#endif /* HDrand */ +#ifndef HDrandom +#define HDrandom() rand() +#endif /* HDrandom */ +#ifndef HDsrand +#define HDsrand(S) srand(S) +#endif /* HDsrand */ +#ifndef HDsrandom +#define HDsrandom(S) srand(S) +#endif /* HDsrandom */ #endif /* H5_HAVE_RANDOM */ #ifndef HDread - #define HDread(F,M,Z) read(F,M,Z) +#define HDread(F, M, Z) read(F, M, Z) #endif /* HDread */ #ifndef HDreaddir - #define HDreaddir(D) readdir(D) +#define HDreaddir(D) readdir(D) #endif /* HDreaddir */ #ifndef HDrealloc - #define HDrealloc(M,Z) realloc(M,Z) +#define HDrealloc(M, Z) realloc(M, Z) #endif /* HDrealloc */ #ifndef HDrealpath - #define HDrealpath(F1,F2) realpath(F1,F2) +#define HDrealpath(F1, F2) realpath(F1, F2) #endif /* HDrealloc */ #ifndef HDremove - #define HDremove(S) remove(S) +#define HDremove(S) remove(S) #endif /* HDremove */ #ifndef HDrename - #define HDrename(OLD,NEW) rename(OLD,NEW) +#define HDrename(OLD, NEW) rename(OLD, NEW) #endif /* HDrename */ #ifndef HDrewind - #define HDrewind(F) rewind(F) +#define HDrewind(F) rewind(F) #endif /* HDrewind */ #ifndef HDrewinddir - #define HDrewinddir(D) rewinddir(D) +#define HDrewinddir(D) rewinddir(D) #endif /* HDrewinddir */ #ifndef HDround - #define HDround(V) round(V) +#define HDround(V) round(V) #endif /* HDround */ #ifndef HDroundf - #define HDroundf(V) roundf(V) +#define HDroundf(V) roundf(V) #endif /* HDroundf */ #ifndef HDroundl - #define HDroundl(V) roundl(V) +#define HDroundl(V) roundl(V) #endif /* HDroundl */ #ifndef HDrmdir - #define HDrmdir(S) rmdir(S) +#define HDrmdir(S) rmdir(S) #endif /* HDrmdir */ /* scanf() variable arguments */ #ifndef HDselect - #define HDselect(N,RD,WR,ER,T) select(N,RD,WR,ER,T) +#define HDselect(N, RD, WR, ER, T) select(N, RD, WR, ER, T) #endif /* HDsetbuf */ #ifndef HDsetbuf - #define HDsetbuf(F,S) setbuf(F,S) +#define HDsetbuf(F, S) setbuf(F, S) #endif /* HDsetbuf */ #ifndef HDsetenv - #define HDsetenv(N,V,O) setenv(N,V,O) +#define HDsetenv(N, V, O) setenv(N, V, O) #endif /* HDsetenv */ #ifndef HDsetgid - #define HDsetgid(G) setgid(G) +#define HDsetgid(G) setgid(G) #endif /* HDsetgid */ #ifndef HDsetjmp - #define HDsetjmp(J) setjmp(J) +#define HDsetjmp(J) setjmp(J) #endif /* HDsetjmp */ #ifndef HDsetlocale - #define HDsetlocale(N,S) setlocale(N,S) +#define HDsetlocale(N, S) setlocale(N, S) #endif /* HDsetlocale */ #ifndef HDsetpgid - #define HDsetpgid(P,PG) setpgid(P,PG) +#define HDsetpgid(P, PG) setpgid(P, PG) #endif /* HDsetpgid */ #ifndef HDsetsid - #define HDsetsid() setsid() +#define HDsetsid() setsid() #endif /* HDsetsid */ #ifndef HDsetsockopt - #define HDsetsockopt(A,B,C,D,E) setsockopt((A),(B),(C),(D),(E)) /* mirror VFD */ -#endif /* HDsetsockopt */ +#define HDsetsockopt(A, B, C, D, E) setsockopt((A), (B), (C), (D), (E)) /* mirror VFD */ +#endif /* HDsetsockopt */ #ifndef HDsetuid - #define HDsetuid(U) setuid(U) +#define HDsetuid(U) setuid(U) #endif /* HDsetuid */ #ifndef HDsetvbuf - #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #endif /* HDsetvbuf */ #ifndef HDshutdown - #define HDshutdown(A, B) shutdown((A),(B)) /* mirror VFD */ -#endif /* HDshutdown */ +#define HDshutdown(A, B) shutdown((A), (B)) /* mirror VFD */ +#endif /* HDshutdown */ #ifndef HDsigaction - #define HDsigaction(S,A,O) sigaction((S),(A),(O)) +#define HDsigaction(S, A, O) sigaction((S), (A), (O)) #endif /* HDsigaction */ #ifndef HDsigaddset - #define HDsigaddset(S,N) sigaddset(S,N) +#define HDsigaddset(S, N) sigaddset(S, N) #endif /* HDsigaddset */ #ifndef HDsigdelset - #define HDsigdelset(S,N) sigdelset(S,N) +#define HDsigdelset(S, N) sigdelset(S, N) #endif /* HDsigdelset */ #ifndef HDsigemptyset - #define HDsigemptyset(S) sigemptyset(S) +#define HDsigemptyset(S) sigemptyset(S) #endif /* HDsigemptyset */ #ifndef HDsigfillset - #define HDsigfillset(S) sigfillset(S) +#define HDsigfillset(S) sigfillset(S) #endif /* HDsigfillset */ #ifndef HDsigismember - #define HDsigismember(S,N) sigismember(S,N) +#define HDsigismember(S, N) sigismember(S, N) #endif /* HDsigismember */ #ifndef HDsiglongjmp - #define HDsiglongjmp(J,N) siglongjmp(J,N) +#define HDsiglongjmp(J, N) siglongjmp(J, N) #endif /* HDsiglongjmp */ #ifndef HDsignal - #define HDsignal(N,F) signal(N,F) +#define HDsignal(N, F) signal(N, F) #endif /* HDsignal */ #ifndef HDsigpending - #define HDsigpending(S) sigpending(S) +#define HDsigpending(S) sigpending(S) #endif /* HDsigpending */ #ifndef HDsigprocmask - #define HDsigprocmask(H,S,O) sigprocmask(H,S,O) +#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) #endif /* HDsigprocmask */ #ifndef HDsigsetjmp - #define HDsigsetjmp(J,N) sigsetjmp(J,N) +#define HDsigsetjmp(J, N) sigsetjmp(J, N) #endif /* HDsigsetjmp */ #ifndef HDsigsuspend - #define HDsigsuspend(S) sigsuspend(S) +#define HDsigsuspend(S) sigsuspend(S) #endif /* HDsigsuspend */ #ifndef HDsin - #define HDsin(X) sin(X) +#define HDsin(X) sin(X) #endif /* HDsin */ #ifndef HDsinh - #define HDsinh(X) sinh(X) +#define HDsinh(X) sinh(X) #endif /* HDsinh */ #ifndef HDsleep - #define HDsleep(N) sleep(N) +#define HDsleep(N) sleep(N) #endif /* HDsleep */ #ifndef HDsnprintf - #define HDsnprintf snprintf /*varargs*/ -#endif /* HDsnprintf */ +#define HDsnprintf snprintf /*varargs*/ +#endif /* HDsnprintf */ #ifndef HDsocket - #define HDsocket(A,B,C) socket((A),(B),(C)) /* mirror VFD */ -#endif /* HDsocket */ +#define HDsocket(A, B, C) socket((A), (B), (C)) /* mirror VFD */ +#endif /* HDsocket */ #ifndef HDsprintf - #define HDsprintf sprintf /*varargs*/ -#endif /* HDsprintf */ +#define HDsprintf sprintf /*varargs*/ +#endif /* HDsprintf */ #ifndef HDsqrt - #define HDsqrt(X) sqrt(X) +#define HDsqrt(X) sqrt(X) #endif /* HDsqrt */ #ifndef HDsscanf - #define HDsscanf(S,FMT,...) sscanf(S,FMT,__VA_ARGS__) +#define HDsscanf(S, FMT, ...) sscanf(S, FMT, __VA_ARGS__) #endif /* HDsscanf */ #ifndef HDstrcat - #define HDstrcat(X,Y) strcat(X,Y) +#define HDstrcat(X, Y) strcat(X, Y) #endif /* HDstrcat */ #ifndef HDstrchr - #define HDstrchr(S,C) strchr(S,C) +#define HDstrchr(S, C) strchr(S, C) #endif /* HDstrchr */ #ifndef HDstrcmp - #define HDstrcmp(X,Y) strcmp(X,Y) +#define HDstrcmp(X, Y) strcmp(X, Y) #endif /* HDstrcmp */ #ifndef HDstrcasecmp - #define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif /* HDstrcasecmp */ #ifndef HDstrcoll - #define HDstrcoll(X,Y) strcoll(X,Y) +#define HDstrcoll(X, Y) strcoll(X, Y) #endif /* HDstrcoll */ #ifndef HDstrcpy - #define HDstrcpy(X,Y) strcpy(X,Y) +#define HDstrcpy(X, Y) strcpy(X, Y) #endif /* HDstrcpy */ #ifndef HDstrcspn - #define HDstrcspn(X,Y) strcspn(X,Y) +#define HDstrcspn(X, Y) strcspn(X, Y) #endif /* HDstrcspn */ +#ifndef HDstrdup +#define HDstrdup(S) strdup(S) +#endif /* HDstrdup */ #ifndef HDstrerror - #define HDstrerror(N) strerror(N) +#define HDstrerror(N) strerror(N) #endif /* HDstrerror */ #ifndef HDstrftime - #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) +#define HDstrftime(S, Z, F, T) strftime(S, Z, F, T) #endif /* HDstrftime */ #ifndef HDstrlen - #define HDstrlen(S) strlen(S) +#define HDstrlen(S) strlen(S) #endif /* HDstrlen */ #ifndef HDstrncat - #define HDstrncat(X,Y,Z) strncat(X,Y,Z) +#define HDstrncat(X, Y, Z) strncat(X, Y, Z) #endif /* HDstrncat */ #ifndef HDstrncmp - #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) +#define HDstrncmp(X, Y, Z) strncmp(X, Y, Z) #endif /* HDstrncmp */ #ifndef HDstrncpy - #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) +#define HDstrncpy(X, Y, Z) strncpy(X, Y, Z) #endif /* HDstrncpy */ #ifndef HDstrpbrk - #define HDstrpbrk(X,Y) strpbrk(X,Y) +#define HDstrpbrk(X, Y) strpbrk(X, Y) #endif /* HDstrpbrk */ #ifndef HDstrrchr - #define HDstrrchr(S,C) strrchr(S,C) +#define HDstrrchr(S, C) strrchr(S, C) #endif /* HDstrrchr */ #ifndef HDstrspn - #define HDstrspn(X,Y) strspn(X,Y) +#define HDstrspn(X, Y) strspn(X, Y) #endif /* HDstrspn */ #ifndef HDstrstr - #define HDstrstr(X,Y) strstr(X,Y) +#define HDstrstr(X, Y) strstr(X, Y) #endif /* HDstrstr */ #ifndef HDstrtod - #define HDstrtod(S,R) strtod(S,R) +#define HDstrtod(S, R) strtod(S, R) #endif /* HDstrtod */ #ifndef HDstrtok - #define HDstrtok(X,Y) strtok(X,Y) +#define HDstrtok(X, Y) strtok(X, Y) #endif /* HDstrtok */ #ifndef HDstrtok_r - #define HDstrtok_r(X,Y,Z) strtok_r(X,Y,Z) +#define HDstrtok_r(X, Y, Z) strtok_r(X, Y, Z) #endif /* HDstrtok */ #ifndef HDstrtol - #define HDstrtol(S,R,N) strtol(S,R,N) +#define HDstrtol(S, R, N) strtol(S, R, N) #endif /* HDstrtol */ #ifndef HDstrtoll - #ifdef H5_HAVE_STRTOLL - #define HDstrtoll(S,R,N) strtoll(S,R,N) - #else - H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); - #endif /* H5_HAVE_STRTOLL */ +#ifdef H5_HAVE_STRTOLL +#define HDstrtoll(S, R, N) strtoll(S, R, N) +#else +H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); +#endif /* H5_HAVE_STRTOLL */ #endif /* HDstrtoll */ #ifndef HDstrtoul - #define HDstrtoul(S,R,N) strtoul(S,R,N) +#define HDstrtoul(S, R, N) strtoul(S, R, N) #endif /* HDstrtoul */ #ifndef HDstrtoull - #define HDstrtoull(S,R,N) strtoull(S,R,N) +#define HDstrtoull(S, R, N) strtoull(S, R, N) #endif /* HDstrtoul */ #ifndef HDstrtoumax - #define HDstrtoumax(S,R,N) strtoumax(S,R,N) +#define HDstrtoumax(S, R, N) strtoumax(S, R, N) #endif /* HDstrtoumax */ #ifndef HDstrxfrm - #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) +#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) #endif /* HDstrxfrm */ #ifdef H5_HAVE_SYMLINK - #ifndef HDsymlink - #define HDsymlink(F1,F2) symlink(F1,F2) - #endif /* HDsymlink */ +#ifndef HDsymlink +#define HDsymlink(F1, F2) symlink(F1, F2) +#endif /* HDsymlink */ #endif /* H5_HAVE_SYMLINK */ #ifndef HDsysconf - #define HDsysconf(N) sysconf(N) +#define HDsysconf(N) sysconf(N) #endif /* HDsysconf */ #ifndef HDsystem - #define HDsystem(S) system(S) +#define HDsystem(S) system(S) #endif /* HDsystem */ #ifndef HDtan - #define HDtan(X) tan(X) +#define HDtan(X) tan(X) #endif /* HDtan */ #ifndef HDtanh - #define HDtanh(X) tanh(X) +#define HDtanh(X) tanh(X) #endif /* HDtanh */ #ifndef HDtcdrain - #define HDtcdrain(F) tcdrain(F) +#define HDtcdrain(F) tcdrain(F) #endif /* HDtcdrain */ #ifndef HDtcflow - #define HDtcflow(F,A) tcflow(F,A) +#define HDtcflow(F, A) tcflow(F, A) #endif /* HDtcflow */ #ifndef HDtcflush - #define HDtcflush(F,N) tcflush(F,N) +#define HDtcflush(F, N) tcflush(F, N) #endif /* HDtcflush */ #ifndef HDtcgetattr - #define HDtcgetattr(F,T) tcgetattr(F,T) +#define HDtcgetattr(F, T) tcgetattr(F, T) #endif /* HDtcgetattr */ #ifndef HDtcgetpgrp - #define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcgetpgrp(F) tcgetpgrp(F) #endif /* HDtcgetpgrp */ #ifndef HDtcsendbreak - #define HDtcsendbreak(F,N) tcsendbreak(F,N) +#define HDtcsendbreak(F, N) tcsendbreak(F, N) #endif /* HDtcsendbreak */ #ifndef HDtcsetattr - #define HDtcsetattr(F,O,T) tcsetattr(F,O,T) +#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) #endif /* HDtcsetattr */ #ifndef HDtcsetpgrp - #define HDtcsetpgrp(F,N) tcsetpgrp(F,N) +#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) #endif /* HDtcsetpgrp */ #ifndef HDtime - #define HDtime(T) time(T) +#define HDtime(T) time(T) #endif /* HDtime */ #ifndef HDtimes - #define HDtimes(T) times(T) +#define HDtimes(T) times(T) #endif /* HDtimes*/ #ifndef HDtmpfile - #define HDtmpfile() tmpfile() +#define HDtmpfile() tmpfile() #endif /* HDtmpfile */ #ifndef HDtmpnam - #define HDtmpnam(S) tmpnam(S) +#define HDtmpnam(S) tmpnam(S) #endif /* HDtmpnam */ #ifndef HDtolower - #define HDtolower(C) tolower(C) +#define HDtolower(C) tolower(C) #endif /* HDtolower */ #ifndef HDtoupper - #define HDtoupper(C) toupper(C) +#define HDtoupper(C) toupper(C) #endif /* HDtoupper */ #ifndef HDttyname - #define HDttyname(F) ttyname(F) +#define HDttyname(F) ttyname(F) #endif /* HDttyname */ #ifndef HDtzset - #define HDtzset() tzset() +#define HDtzset() tzset() #endif /* HDtzset */ #ifndef HDumask - #define HDumask(N) umask(N) +#define HDumask(N) umask(N) #endif /* HDumask */ #ifndef HDuname - #define HDuname(S) uname(S) +#define HDuname(S) uname(S) #endif /* HDuname */ #ifndef HDungetc - #define HDungetc(C,F) ungetc(C,F) +#define HDungetc(C, F) ungetc(C, F) #endif /* HDungetc */ #ifndef HDunlink - #define HDunlink(S) unlink(S) +#define HDunlink(S) unlink(S) #endif /* HDunlink */ #ifndef HDutime - #define HDutime(S,T) utime(S,T) +#define HDutime(S, T) utime(S, T) #endif /* HDutime */ +#ifndef HDvasprintf +#ifdef H5_HAVE_VASPRINTF +#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) +#else +H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); +#endif /* H5_HAVE_VASPRINTF */ +#endif /* HDvasprintf */ #ifndef HDva_arg - #define HDva_arg(A,T) va_arg(A,T) +#define HDva_arg(A, T) va_arg(A, T) #endif /* HDva_arg */ #ifndef HDva_copy -#define HDva_copy(D,S) va_copy(D,S) +#define HDva_copy(D, S) va_copy(D, S) #endif /* HDva_copy */ #ifndef HDva_end - #define HDva_end(A) va_end(A) +#define HDva_end(A) va_end(A) #endif /* HDva_end */ #ifndef HDva_start - #define HDva_start(A,P) va_start(A,P) +#define HDva_start(A, P) va_start(A, P) #endif /* HDva_start */ -#ifndef HDvasprintf - #define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) -#endif /* HDvasprintf */ #ifndef HDvfprintf - #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) +#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) #endif /* HDvfprintf */ #ifndef HDvprintf - #define HDvprintf(FMT,A) vprintf(FMT,A) +#define HDvprintf(FMT, A) vprintf(FMT, A) #endif /* HDvprintf */ #ifndef HDvsprintf - #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) +#define HDvsprintf(S, FMT, A) vsprintf(S, FMT, A) #endif /* HDvsprintf */ #ifndef HDvsnprintf - #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) +#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif /* HDvsnprintf */ #ifndef HDwait - #define HDwait(W) wait(W) +#define HDwait(W) wait(W) #endif /* HDwait */ #ifndef HDwaitpid - #define HDwaitpid(P,W,O) waitpid(P,W,O) +#define HDwaitpid(P, W, O) waitpid(P, W, O) #endif /* HDwaitpid */ #ifndef HDwcstombs - #define HDwcstombs(S,P,Z) wcstombs(S,P,Z) +#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) #endif /* HDwcstombs */ #ifndef HDwctomb - #define HDwctomb(S,C) wctomb(S,C) +#define HDwctomb(S, C) wctomb(S, C) #endif /* HDwctomb */ #ifndef HDwrite - #define HDwrite(F,M,Z) write(F,M,Z) +#define HDwrite(F, M, Z) write(F, M, Z) #endif /* HDwrite */ -/* - * And now for a couple non-Posix functions... Watch out for systems that - * define these in terms of macros. - */ -#if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); -#endif - -#ifndef HDstrdup - #define HDstrdup(S) strdup(S) -#endif /* HDstrdup */ - /* Macro for "stringizing" an integer in the C preprocessor (use H5_TOSTRING) */ /* (use H5_TOSTRING, H5_STRINGIZE is just part of the implementation) */ #define H5_STRINGIZE(x) #x -#define H5_TOSTRING(x) H5_STRINGIZE(x) +#define H5_TOSTRING(x) H5_STRINGIZE(x) /* Macro for "glueing" together items, for re-scanning macros */ -#define H5_GLUE(x,y) x##y -#define H5_GLUE3(x,y,z) x##y##z -#define H5_GLUE4(w,x,y,z) w##x##y##z +#define H5_GLUE(x, y) x##y +#define H5_GLUE3(x, y, z) x##y##z +#define H5_GLUE4(w, x, y, z) w##x##y##z /* * A macro for detecting over/under-flow when casting between types */ #ifndef NDEBUG -#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ -{ \ - casttype _tmp_overflow = (casttype)(var); \ - HDassert((var) == (vartype)_tmp_overflow); \ -} +#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ + { \ + casttype _tmp_overflow = (casttype)(var); \ + HDassert((var) == (vartype)_tmp_overflow); \ + } #else /* NDEBUG */ #define H5_CHECK_OVERFLOW(var, vartype, casttype) #endif /* NDEBUG */ @@ -1680,49 +1650,46 @@ extern char *strdup(const char *s); * A macro for detecting over/under-flow when assigning between types */ #ifndef NDEBUG -#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); - -#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); - -#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_dst >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ -{ \ - srctype _tmp_src = (srctype)(src); \ - dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ - (dst) = _tmp_dst; \ -} - -#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); +#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); + +#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); + +#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_dst >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ + { \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + HDassert(_tmp_src >= 0); \ + HDassert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ + } + +#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) (dst) = (dsttype)(src); /* Include the generated overflow header file */ #include "H5overflow.h" @@ -1739,50 +1706,49 @@ extern char *strdup(const char *s); * The preprocessor does not expand macros in w##x##y##z, so * that will always generate the expected name. */ -#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - ASSIGN_##srctype##_TO_##dsttype(dst,dsttype,src,srctype)\ +#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ + ASSIGN_##srctype##_TO_##dsttype(dst, dsttype, src, srctype) #else /* NDEBUG */ -#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - (dst) = (dsttype)(src); +#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) (dst) = (dsttype)(src); #endif /* NDEBUG */ #if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ -#define H5_DIR_SLASH_SEPC '/' -#define H5_DIR_SEPC '\\' -#define H5_DIR_SEPS "\\" -#define H5_CHECK_DELIMITER(SS) ((SS == H5_DIR_SEPC) || (SS == H5_DIR_SLASH_SEPC)) -#define H5_CHECK_ABSOLUTE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) -#define H5_CHECK_ABS_DRIVE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':')) -#define H5_CHECK_ABS_PATH(NAME) (H5_CHECK_DELIMITER(NAME[0])) - -#define H5_GET_LAST_DELIMITER(NAME, ptr) { \ - char *slash, *backslash; \ - \ - slash = HDstrrchr(NAME, H5_DIR_SLASH_SEPC); \ - backslash = HDstrrchr(NAME, H5_DIR_SEPC); \ - if(backslash > slash) \ - (ptr = backslash); \ - else \ - (ptr = slash); \ -} +#define H5_DIR_SLASH_SEPC '/' +#define H5_DIR_SEPC '\\' +#define H5_DIR_SEPS "\\" +#define H5_CHECK_DELIMITER(SS) ((SS == H5_DIR_SEPC) || (SS == H5_DIR_SLASH_SEPC)) +#define H5_CHECK_ABSOLUTE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) +#define H5_CHECK_ABS_DRIVE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':')) +#define H5_CHECK_ABS_PATH(NAME) (H5_CHECK_DELIMITER(NAME[0])) + +#define H5_GET_LAST_DELIMITER(NAME, ptr) \ + { \ + char *slash, *backslash; \ + \ + slash = HDstrrchr(NAME, H5_DIR_SLASH_SEPC); \ + backslash = HDstrrchr(NAME, H5_DIR_SEPC); \ + if (backslash > slash) \ + (ptr = backslash); \ + else \ + (ptr = slash); \ + } #else /* H5_HAVE_WINDOW_PATH */ -#define H5_DIR_SEPC '/' -#define H5_DIR_SEPS "/" -#define H5_CHECK_DELIMITER(SS) (SS == H5_DIR_SEPC) -#define H5_CHECK_ABSOLUTE(NAME) (H5_CHECK_DELIMITER(*NAME)) -#define H5_CHECK_ABS_DRIVE(NAME) (0) -#define H5_CHECK_ABS_PATH(NAME) (0) -#define H5_GET_LAST_DELIMITER(NAME, ptr) ptr = HDstrrchr(NAME, H5_DIR_SEPC); +#define H5_DIR_SEPC '/' +#define H5_DIR_SEPS "/" +#define H5_CHECK_DELIMITER(SS) (SS == H5_DIR_SEPC) +#define H5_CHECK_ABSOLUTE(NAME) (H5_CHECK_DELIMITER(*NAME)) +#define H5_CHECK_ABS_DRIVE(NAME) (0) +#define H5_CHECK_ABS_PATH(NAME) (0) +#define H5_GET_LAST_DELIMITER(NAME, ptr) ptr = HDstrrchr(NAME, H5_DIR_SEPC); #endif /* H5_HAVE_WINDOW_PATH */ -#define H5_COLON_SEPC ':' - +#define H5_COLON_SEPC ':' /* Use FUNC to safely handle variations of C99 __func__ keyword handling */ #ifdef H5_HAVE_C99_FUNC @@ -1804,39 +1770,41 @@ extern char *strdup(const char *s); * information about the package in H5_init_library(). */ typedef enum { - H5_PKG_A, /* Attributes */ - H5_PKG_AC, /* Metadata cache */ - H5_PKG_B, /* B-trees */ - H5_PKG_D, /* Datasets */ - H5_PKG_E, /* Error handling */ - H5_PKG_F, /* Files */ - H5_PKG_G, /* Groups */ - H5_PKG_HG, /* Global heaps */ - H5_PKG_HL, /* Local heaps */ - H5_PKG_I, /* IDs */ - H5_PKG_MF, /* File memory management */ - H5_PKG_MM, /* Core memory management */ - H5_PKG_O, /* Object headers */ - H5_PKG_P, /* Property lists */ - H5_PKG_S, /* Dataspaces */ - H5_PKG_T, /* Datatypes */ - H5_PKG_V, /* Vector functions */ - H5_PKG_Z, /* Raw data filters */ - H5_NPKGS /* Must be last */ + H5_PKG_A, /* Attributes */ + H5_PKG_AC, /* Metadata cache */ + H5_PKG_B, /* B-trees */ + H5_PKG_D, /* Datasets */ + H5_PKG_E, /* Error handling */ + H5_PKG_F, /* Files */ + H5_PKG_G, /* Groups */ + H5_PKG_HG, /* Global heaps */ + H5_PKG_HL, /* Local heaps */ + H5_PKG_I, /* IDs */ + H5_PKG_M, /* Maps */ + H5_PKG_MF, /* File memory management */ + H5_PKG_MM, /* Core memory management */ + H5_PKG_O, /* Object headers */ + H5_PKG_P, /* Property lists */ + H5_PKG_S, /* Dataspaces */ + H5_PKG_T, /* Datatypes */ + H5_PKG_V, /* Vector functions */ + H5_PKG_VL, /* VOL functions */ + H5_PKG_Z, /* Raw data filters */ + H5_NPKGS /* Must be last */ } H5_pkg_t; typedef struct H5_debug_open_stream_t { - FILE *stream; /* Open output stream */ - struct H5_debug_open_stream_t *next; /* Next open output stream */ + FILE * stream; /* Open output stream */ + struct H5_debug_open_stream_t *next; /* Next open output stream */ } H5_debug_open_stream_t; typedef struct H5_debug_t { - FILE *trace; /*API trace output stream */ - hbool_t ttop; /*Show only top-level calls? */ - hbool_t ttimes; /*Show trace event times? */ + FILE * trace; /*API trace output stream */ + hbool_t ttop; /*Show only top-level calls? */ + hbool_t ttimes; /*Show trace event times? */ struct { - const char *name; /*package name */ - FILE *stream; /*output stream or NULL */ + const char *name; /*package name */ + FILE * stream; /*output stream or NULL */ } pkg[H5_NPKGS]; H5_debug_open_stream_t *open_stream; /* Stack of open output streams */ } H5_debug_t; @@ -1845,8 +1813,8 @@ typedef struct H5_debug_t { extern hbool_t H5_coll_api_sanity_check_g; #endif /* H5_HAVE_PARALLEL */ -extern H5_debug_t H5_debug_g; -#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) +extern H5_debug_t H5_debug_g; +#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) /* Do not use const else AIX strings does not show it. */ extern char H5libhdf5_settings[]; /* embedded library information */ @@ -1865,80 +1833,79 @@ extern char H5libhdf5_settings[]; /* embedded library information */ */ #ifdef H5_DEBUG_API -#define H5TRACE_DECL \ - const char *RTYPE = NULL; \ - double CALLTIME; - -#define H5TRACE0(R,T) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T) -#define H5TRACE1(R,T,A0) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0) -#define H5TRACE2(R,T,A0,A1) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1) -#define H5TRACE3(R,T,A0,A1,A2) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2) -#define H5TRACE4(R,T,A0,A1,A2,A3) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3) -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4) -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5) -#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6) -#define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7) -#define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8) -#define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9) -#define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9,#A10,A10) -#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) \ - RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3,#A4,A4,#A5,A5,#A6,A6,#A7,A7, \ - #A8,A8,#A9,A9,#A10,A10,#A11,A11) - -#define H5TRACE_RETURN(V) \ - if (RTYPE) { \ - H5_trace(&CALLTIME, FUNC, RTYPE, NULL, V); \ - RTYPE = NULL; \ - } +#define H5TRACE_DECL \ + const char *RTYPE = NULL; \ + double CALLTIME; + +#define H5TRACE0(R, T) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T) +#define H5TRACE1(R, T, A0) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0) +#define H5TRACE2(R, T, A0, A1) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1) +#define H5TRACE3(R, T, A0, A1, A2) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2) +#define H5TRACE4(R, T, A0, A1, A2, A3) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3) +#define H5TRACE5(R, T, A0, A1, A2, A3, A4) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4) +#define H5TRACE6(R, T, A0, A1, A2, A3, A4, A5) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5) +#define H5TRACE7(R, T, A0, A1, A2, A3, A4, A5, A6) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6) +#define H5TRACE8(R, T, A0, A1, A2, A3, A4, A5, A6, A7) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, A7) +#define H5TRACE9(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8) +#define H5TRACE10(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9) +#define H5TRACE11(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9, #A10, A10) +#define H5TRACE12(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \ + RTYPE = R; \ + CALLTIME = H5_trace(NULL, FUNC, T, #A0, A0, #A1, A1, #A2, A2, #A3, A3, #A4, A4, #A5, A5, #A6, A6, #A7, \ + A7, #A8, A8, #A9, A9, #A10, A10, #A11, A11) + +#define H5TRACE_RETURN(V) \ + if (RTYPE) { \ + H5_trace(&CALLTIME, FUNC, RTYPE, NULL, V); \ + RTYPE = NULL; \ + } #else -#define H5TRACE_DECL /*void*/ -#define H5TRACE0(R,T) /*void*/ -#define H5TRACE1(R,T,A0) /*void*/ -#define H5TRACE2(R,T,A0,A1) /*void*/ -#define H5TRACE3(R,T,A0,A1,A2) /*void*/ -#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ -#define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) /*void*/ -#define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) /*void*/ -#define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) /*void*/ -#define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) /*void*/ -#define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/ -#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) /*void*/ -#define H5TRACE_RETURN(V) /*void*/ -#endif /* H5_DEBUG_API */ +#define H5TRACE_DECL /*void*/ +#define H5TRACE0(R, T) /*void*/ +#define H5TRACE1(R, T, A0) /*void*/ +#define H5TRACE2(R, T, A0, A1) /*void*/ +#define H5TRACE3(R, T, A0, A1, A2) /*void*/ +#define H5TRACE4(R, T, A0, A1, A2, A3) /*void*/ +#define H5TRACE5(R, T, A0, A1, A2, A3, A4) /*void*/ +#define H5TRACE6(R, T, A0, A1, A2, A3, A4, A5) /*void*/ +#define H5TRACE7(R, T, A0, A1, A2, A3, A4, A5, A6) /*void*/ +#define H5TRACE8(R, T, A0, A1, A2, A3, A4, A5, A6, A7) /*void*/ +#define H5TRACE9(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8) /*void*/ +#define H5TRACE10(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) /*void*/ +#define H5TRACE11(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) /*void*/ +#define H5TRACE12(R, T, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) /*void*/ +#define H5TRACE_RETURN(V) /*void*/ +#endif /* H5_DEBUG_API */ H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...); - /*------------------------------------------------------------------------- * Purpose: Register function entry for library initialization and code * profiling. @@ -1968,36 +1935,38 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ * - Underscore at position 4 if position 3 is uppercase or a digit. * Handles H5XY_. */ -#define H5_IS_API(S) (\ - '_'!=((const char *)S)[2] /* underscore at position 2 */ \ - && '_'!=((const char *)S)[3] /* underscore at position 3 */ \ - && !( /* NOT */ \ - ((const char *)S)[4] /* pos 4 exists */ \ - && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ - && '_'==((const char *)S)[4] /* pos 4 underscore */ \ - )\ -) +#define H5_IS_API(S) \ + ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ + && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ + && !( /* NOT */ \ + ((const char *)S)[4] /* pos 4 exists */ \ + && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ + && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ + )) /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ -#define H5_IS_PUB(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ - (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) +#define H5_IS_PUB(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ + (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) /* `S' is the name of a function which is being tested to check if it's */ /* a private library function */ -#define H5_IS_PRIV(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) +#define H5_IS_PRIV(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) /* `S' is the name of a function which is being tested to check if it's */ /* a package private function */ -#define H5_IS_PKG(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) +#define H5_IS_PKG(S) \ + (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ + ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ + ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) /* global library version information string */ -extern char H5_lib_vers_info_g[]; +extern char H5_lib_vers_info_g[]; #include "H5TSprivate.h" @@ -2006,9 +1975,13 @@ extern char H5_lib_vers_info_g[]; /* replacement structure for original global variable */ typedef struct H5_api_struct { - H5TS_mutex_t init_lock; /* API entrance mutex */ - hbool_t H5_libinit_g; /* Has the library been initialized? */ - hbool_t H5_libterm_g; /* Is the library being shutdown? */ +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS + H5TS_rw_lock_t init_rw_lock; /* API entrance RW lock */ +#else + H5TS_mutex_t init_lock; /* API entrance mutex */ +#endif + hbool_t H5_libinit_g; /* Has the library been initialized? */ + hbool_t H5_libterm_g; /* Is the library being shutdown? */ } H5_api_t; /* Macros for accessing the global variables */ @@ -2023,17 +1996,17 @@ typedef struct H5_api_struct { #endif /* Macros for threadsafe HDF-5 Phase I locks */ -#define H5_API_LOCK \ - H5TS_mutex_lock(&H5_g.init_lock); -#define H5_API_UNLOCK \ - H5TS_mutex_unlock(&H5_g.init_lock); +#ifdef H5_USE_RECURSIVE_WRITER_LOCKS +#define H5_API_LOCK H5TS_rw_wrlock(&H5_g.init_rw_lock); +#define H5_API_UNLOCK H5TS_rw_unlock(&H5_g.init_rw_lock); +#else +#define H5_API_LOCK H5TS_mutex_lock(&H5_g.init_lock); +#define H5_API_UNLOCK H5TS_mutex_unlock(&H5_g.init_lock); +#endif /* Macros for thread cancellation-safe mechanism */ -#define H5_API_UNSET_CANCEL \ - H5TS_cancel_count_inc(); - -#define H5_API_SET_CANCEL \ - H5TS_cancel_count_dec(); +#define H5_API_UNSET_CANCEL H5TS_cancel_count_inc(); +#define H5_API_SET_CANCEL H5TS_cancel_count_dec(); extern H5_api_t H5_g; @@ -2051,8 +2024,8 @@ extern H5_api_t H5_g; #define H5_API_SET_CANCEL /* extern global variables */ -extern hbool_t H5_libinit_g; /* Has the library been initialized? */ -extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ +extern hbool_t H5_libinit_g; /* Has the library been initialized? */ +extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ /* Macros for accessing the global variables */ #define H5_INIT_GLOBAL (H5_libinit_g) @@ -2065,41 +2038,41 @@ extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ /* Include required function stack header */ #include "H5CSprivate.h" -#define H5_PUSH_FUNC H5CS_push(FUNC); -#define H5_POP_FUNC H5CS_pop(); -#else /* H5_HAVE_CODESTACK */ -#define H5_PUSH_FUNC /* void */ -#define H5_POP_FUNC /* void */ -#endif /* H5_HAVE_CODESTACK */ +#define H5_PUSH_FUNC H5CS_push(FUNC); +#define H5_POP_FUNC H5CS_pop(); +#else /* H5_HAVE_CODESTACK */ +#define H5_PUSH_FUNC /* void */ +#define H5_POP_FUNC /* void */ +#endif /* H5_HAVE_CODESTACK */ #ifdef H5_HAVE_MPE -extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ +extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif /* Macros for referencing package initialization symbols */ -#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) -#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) +#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) +#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) /* Macros for defining package initialization routines */ #ifdef H5_MY_PKG -#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) -#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) -#define H5_PACKAGE_YES_INIT(err) \ - /* Initialize this interface or bust */ \ - if(!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ - H5_PKG_INIT_VAR = TRUE; \ - if(H5_PKG_INIT_FUNC() < 0) { \ - H5_PKG_INIT_VAR = FALSE; \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ - } \ +#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) +#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) +#define H5_PACKAGE_YES_INIT(err) \ + /* Initialize this interface or bust */ \ + if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ + H5_PKG_INIT_VAR = TRUE; \ + if (H5_PKG_INIT_FUNC() < 0) { \ + H5_PKG_INIT_VAR = FALSE; \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ + } \ } -#define H5_PACKAGE_NO_INIT(err) \ - /* Initialize this interface or bust */ \ - if(!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ +#define H5_PACKAGE_NO_INIT(err) \ + /* Initialize this interface or bust */ \ + if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ H5_PKG_INIT_VAR = TRUE; -#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) +#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) #else /* H5_MY_PKG */ -#define H5_PKG_INIT_VAR (TRUE) +#define H5_PKG_INIT_VAR (TRUE) #define H5_PACKAGE_INIT(pkg_init, err) #endif /* H5_MY_PKG */ @@ -2109,101 +2082,108 @@ H5_DLL herr_t H5CX_push(void); H5_DLL herr_t H5CX_pop(void); #ifndef NDEBUG -#define FUNC_ENTER_CHECK_NAME(asrt) \ - { \ - static hbool_t func_check = FALSE; \ - \ - if(!func_check) { \ - /* Check function naming status */ \ - HDassert(asrt && "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in H5private.h (this is usually due to an incorrect number of underscores)"); \ - \ - /* Don't check again */ \ - func_check = TRUE; \ - } /* end if */ \ - } /* end scope */ -#else /* NDEBUG */ +#define FUNC_ENTER_CHECK_NAME(asrt) \ + { \ + static hbool_t func_check = FALSE; \ + \ + if (!func_check) { \ + /* Check function naming status */ \ + HDassert(asrt && \ + "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in " \ + "H5private.h (this is usually due to an incorrect number of underscores)"); \ + \ + /* Don't check again */ \ + func_check = TRUE; \ + } /* end if */ \ + } /* end scope */ +#else /* NDEBUG */ #define FUNC_ENTER_CHECK_NAME(asrt) #endif /* NDEBUG */ - -#define FUNC_ENTER_COMMON(asrt) \ - hbool_t err_occurred = FALSE; \ - \ +#define FUNC_ENTER_COMMON(asrt) \ + hbool_t err_occurred = FALSE; \ + \ FUNC_ENTER_CHECK_NAME(asrt); -#define FUNC_ENTER_COMMON_NOERR(asrt) \ - FUNC_ENTER_CHECK_NAME(asrt); +#define FUNC_ENTER_COMMON_NOERR(asrt) FUNC_ENTER_CHECK_NAME(asrt); /* Threadsafety initialization code for API routines */ -#define FUNC_ENTER_API_THREADSAFE \ - /* Initialize the thread-safe code */ \ - H5_FIRST_THREAD_INIT \ - \ - /* Grab the mutex for the library */ \ - H5_API_UNSET_CANCEL \ - H5_API_LOCK +#define FUNC_ENTER_API_THREADSAFE \ + /* Initialize the thread-safe code */ \ + H5_FIRST_THREAD_INIT \ + \ + /* Grab the mutex for the library */ \ + H5_API_UNSET_CANCEL \ + H5_API_LOCK /* Local variables for API routines */ -#define FUNC_ENTER_API_VARS \ - MPE_LOG_VARS \ +#define FUNC_ENTER_API_VARS \ + MPE_LOG_VARS \ H5TRACE_DECL -#define FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ +#define FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; -#define FUNC_ENTER_API_INIT(err) \ - /* Initialize the library */ \ - if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ - } /* end if */ \ - \ - /* Initialize the package, if appropriate */ \ +#define FUNC_ENTER_API_INIT(err) \ + /* Initialize the library */ \ + if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + if (H5_init_library() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ + } /* end if */ \ + \ + /* Initialize the package, if appropriate */ \ H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) -#define FUNC_ENTER_API_PUSH(err) \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Push the API context */ \ - if(H5CX_push() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ - \ +#define FUNC_ENTER_API_PUSH(err) \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ + \ BEGIN_MPE_LOG /* Use this macro for all "normal" API functions */ -#define FUNC_ENTER_API(err) {{ \ - FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - FUNC_ENTER_API_PUSH(err); \ - /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ - { +#define FUNC_ENTER_API(err) \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_PUSH(err); \ + /* Clear thread error stack entering public functions */ \ + H5E_clear_stack(NULL); \ + { /* * Use this macro for API functions that shouldn't clear the error stack * like H5Eprint and H5Ewalk. */ -#define FUNC_ENTER_API_NOCLEAR(err) {{ \ - FUNC_ENTER_API_COMMON \ - FUNC_ENTER_API_INIT(err); \ - FUNC_ENTER_API_PUSH(err); \ - { +#define FUNC_ENTER_API_NOCLEAR(err) \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + FUNC_ENTER_API_INIT(err); \ + FUNC_ENTER_API_PUSH(err); \ + { /* * Use this macro for API functions that shouldn't perform _any_ initialization * of the library or an interface, just perform tracing, etc. Examples - * are: H5allocate_memory, H5is_library_threadsafe, etc. + * are: H5allocate_memory, H5is_library_threadsafe, public VOL callback + * wrappers (e.g. H5VLfile_create, H5VLdataset_read, etc.), etc. * */ -#define FUNC_ENTER_API_NOINIT {{{ \ - FUNC_ENTER_API_COMMON \ - H5_PUSH_FUNC \ - BEGIN_MPE_LOG \ - { +#define FUNC_ENTER_API_NOINIT \ + { \ + { \ + { \ + FUNC_ENTER_API_COMMON \ + H5_PUSH_FUNC \ + BEGIN_MPE_LOG \ + { /* * Use this macro for API functions that shouldn't perform _any_ initialization @@ -2212,12 +2192,16 @@ H5_DLL herr_t H5CX_pop(void); * are: H5close, H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{{{ \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ - FUNC_ENTER_API_THREADSAFE; \ - BEGIN_MPE_LOG \ - { +#define FUNC_ENTER_API_NOINIT_NOERR_NOFS \ + { \ + { \ + { \ + { \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ + FUNC_ENTER_API_THREADSAFE; \ + BEGIN_MPE_LOG \ + { /* * Use this macro for API functions that should only perform initialization @@ -2225,31 +2209,38 @@ H5_DLL herr_t H5CX_pop(void); * function name, start MPE logging, etc) examples are: H5open. * */ -#define FUNC_ENTER_API_NOPUSH(err) {{{{{ \ - FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_API_INIT(err); \ - { +#define FUNC_ENTER_API_NOPUSH(err) \ + { \ + { \ + { \ + { \ + { \ + FUNC_ENTER_COMMON(H5_IS_API(FUNC)); \ + FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_API_INIT(err); \ + { /* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(err) \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - \ - /* Push the name of this function on the function stack */ \ +#define FUNC_ENTER_NOAPI_INIT(err) \ + /* Initialize the package, if appropriate */ \ + H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ + \ + /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC /* Use this macro for all "normal" non-API functions */ -#define FUNC_ENTER_NOAPI(err) { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI(err) \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + FUNC_ENTER_NOAPI_INIT(err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ -#define FUNC_ENTER_NOAPI_NOERR { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - FUNC_ENTER_NOAPI_INIT(-) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + FUNC_ENTER_NOAPI_INIT(-) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2259,10 +2250,11 @@ H5_DLL herr_t H5CX_pop(void); * - functions which are called during library shutdown, since we don't * want to re-initialize the library. */ -#define FUNC_ENTER_NOAPI_NOINIT { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOINIT \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2273,10 +2265,11 @@ H5_DLL herr_t H5CX_pop(void); * want to re-initialize the library. * - functions that propagate, but don't issue errors */ -#define FUNC_ENTER_NOAPI_NOINIT_NOERR { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOINIT_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2284,12 +2277,13 @@ H5_DLL herr_t H5CX_pop(void); * (so far, just the H5CS routines themselves) * */ -#define FUNC_ENTER_NOAPI_NOFS { \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOFS \ + { \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + \ + /* Initialize the package, if appropriate */ \ + H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* * Use this macro for non-API functions which fall into these categories: @@ -2300,79 +2294,88 @@ H5_DLL herr_t H5CX_pop(void); * also don't use the 'FUNC' variable (i.e. don't push errors on the error stack) * */ -#define FUNC_ENTER_NOAPI_NOERR_NOFS { \ - FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_NOERR_NOFS \ + { \ + FUNC_ENTER_COMMON_NOERR(!H5_IS_API(FUNC)); \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following two macros as replacements for the FUNC_ENTER_NOAPI * and FUNC_ENTER_NOAPI_NOINIT macros when the function needs to set * up a metadata tag. */ -#define FUNC_ENTER_NOAPI_TAG(tag, err) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { - -#define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_NOAPI_TAG(tag, err) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + FUNC_ENTER_NOAPI_INIT(err) \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + +#define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(!H5_IS_API(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all "normal" package-level functions */ -#define FUNC_ENTER_PACKAGE { \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE \ + { \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for package-level functions which propgate errors, but don't issue them */ -#define FUNC_ENTER_PACKAGE_NOERR { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following macro as replacement for the FUNC_ENTER_PACKAGE * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_PACKAGE_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_PACKAGE_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for all "normal" staticly-scoped functions */ -#define FUNC_ENTER_STATIC { \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC \ + { \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ -#define FUNC_ENTER_STATIC_NOERR { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC_NOERR \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ /* And that shouldn't push their name on the function stack */ -#define FUNC_ENTER_STATIC_NOERR_NOFS { \ - FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { +#define FUNC_ENTER_STATIC_NOERR_NOFS \ + { \ + FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(FUNC)); \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /* Use the following macro as replacement for the FUNC_ENTER_STATIC * macro when the function needs to set up a metadata tag. */ -#define FUNC_ENTER_STATIC_TAG(tag) { \ - haddr_t prev_tag = HADDR_UNDEF; \ - \ - FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ - H5AC_tag(tag, &prev_tag); \ - H5_PUSH_FUNC \ - if(H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { - +#define FUNC_ENTER_STATIC_TAG(tag) \ + { \ + haddr_t prev_tag = HADDR_UNDEF; \ + \ + FUNC_ENTER_COMMON(H5_IS_PKG(FUNC)); \ + H5AC_tag(tag, &prev_tag); \ + H5_PUSH_FUNC \ + if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { /*------------------------------------------------------------------------- * Purpose: Register function exit for code profiling. This should be @@ -2383,130 +2386,139 @@ H5_DLL herr_t H5CX_pop(void); *------------------------------------------------------------------------- */ /* Threadsafety termination code for API routines */ -#define FUNC_LEAVE_API_THREADSAFE \ - H5_API_UNLOCK \ +#define FUNC_LEAVE_API_THREADSAFE \ + H5_API_UNLOCK \ H5_API_SET_CANCEL -#define FUNC_LEAVE_API_COMMON(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - FINISH_MPE_LOG \ +#define FUNC_LEAVE_API_COMMON(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + FINISH_MPE_LOG \ H5TRACE_RETURN(ret_value); -#define FUNC_LEAVE_API(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - (void)H5CX_pop(); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + (void)H5CX_pop(); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOINIT macro */ -#define FUNC_LEAVE_API_NOINIT(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOINIT(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOINIT_NOERR_NOFS macro */ -#define FUNC_LEAVE_API_NOFS(ret_value) \ - FUNC_LEAVE_API_COMMON(ret_value); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}}} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOFS(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOPUSH macro */ -#define FUNC_LEAVE_API_NOPUSH(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ - FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ -}}}}} /*end scope from beginning of FUNC_ENTER*/ - -#define FUNC_LEAVE_NOAPI(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5_POP_FUNC \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ - -#define FUNC_LEAVE_NOAPI_VOID \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5_POP_FUNC \ - return; \ -} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_API_NOPUSH(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ + +#define FUNC_LEAVE_NOAPI(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ + +#define FUNC_LEAVE_NOAPI_VOID \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5_POP_FUNC \ + return; \ + } /*end scope from beginning of FUNC_ENTER*/ /* * Use this macro for non-API functions which fall into these categories: * - functions which didn't push their name on the function stack * (so far, just the H5CS routines themselves) */ -#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ +#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ /* Use this macro when exiting a function that set up a metadata tag */ -#define FUNC_LEAVE_NOAPI_TAG(ret_value) \ - ; \ - } /*end scope from end of FUNC_ENTER*/ \ - H5AC_tag(prev_tag, NULL); \ - H5_POP_FUNC \ - return(ret_value); \ -} /*end scope from beginning of FUNC_ENTER*/ - +#define FUNC_LEAVE_NOAPI_TAG(ret_value) \ + ; \ + } /*end scope from end of FUNC_ENTER*/ \ + H5AC_tag(prev_tag, NULL); \ + H5_POP_FUNC \ + return (ret_value); \ + } /*end scope from beginning of FUNC_ENTER*/ /****************************************/ /* Revisions to FUNC_ENTER/LEAVE Macros */ /****************************************/ /* Macros to check if a package is initialized */ -#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); +#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); #define H5_CHECK_PACKAGE_INIT_REG_NO(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_YES(asrt) #define H5_CHECK_PACKAGE_INIT_INIT_NO(asrt) -#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) +#define H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) /* Macros to initialize package, if a package initialization routine is defined */ -#define H5_PKG_YES_INIT(pkg) \ - if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ - H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ - if(H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ - H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ -#define H5_PKG_NO_INIT(pkg) \ - if(!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ +#define H5_PKG_YES_INIT(pkg) \ + if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) { \ + H5_PACKAGE_INIT_VAR(pkg) = TRUE; \ + if (H5_PACKAGE_INIT_FUNC(pkg)() < 0) { \ + H5_PACKAGE_INIT_VAR(pkg) = FALSE; \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ + } /* end if */ +#define H5_PKG_NO_INIT(pkg) \ + if (!H5_PACKAGE_INIT_VAR(pkg) && !H5_TERM_GLOBAL) \ H5_PACKAGE_INIT_VAR(pkg) = TRUE; -#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) +#define H5_PKG_INIT(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) /* Macros to declare package initialization function, if a package initialization routine is defined */ #ifdef H5_PKG_SINGLE_SOURCE #define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else /* H5_PKG_SINGLE_SOURCE */ +#else /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); #endif /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_NO_FUNC(pkg) /* Declare package initialization symbols (if in a package) */ #ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else /* H5_PKG_SINGLE_SOURCE */ -#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); +#else /* H5_PKG_SINGLE_SOURCE */ +#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); +#endif /* H5_PKG_SINGLE_SOURCE */ #define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) #ifdef H5_MY_PKG H5_PKG_DECLARE_VAR(H5_MY_PKG) @@ -2514,84 +2526,86 @@ H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) #endif /* H5_MY_PKG */ /* API re-entrance variable */ -extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ +extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */ /* Macros for entering different scopes of routines */ -#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* This interface should be initialized already */ \ - /* (except for package initialization routines :-) */ \ - H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ +#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PKG(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* This interface should be initialized already */ \ + /* (except for package initialization routines :-) */ \ + H5_CHECK_PACKAGE_INIT(pkg, pkg_init, init) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ { -#define H5_PRIVATE_ENTER(pkg, pkg_init) \ - FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ - \ - /* The library should be initialized already */ \ - HDassert(H5_INIT_GLOBAL); \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - {{ - -#define H5_PUBLIC_ENTER(pkg, pkg_init) \ - FUNC_ENTER_API_VARS \ - FUNC_ENTER_API_THREADSAFE; \ - FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ - \ - /* Clear thread error stack when entering public functions */ \ - H5E_clear_stack(NULL); \ - \ - /* Initialize the library or bust */ \ - if(!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ - H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) { \ - /* (Can't use H5E_THROW here) */ \ - H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ - ret_value = fail_value; \ - goto func_init_failed; \ - } /* end if */ \ - } /* end if */ \ - \ - /* Initialize this interface if desired */ \ - H5_PKG_INIT(pkg_init, pkg) \ - \ - /* Check for re-entering API routine */ \ - HDassert(!H5_api_entered_g); \ - H5_api_entered_g = TRUE; \ - \ - /* Start logging MPI's MPE information */ \ - BEGIN_MPE_LOG \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC \ - \ - /* Enter scope for this type of function */ \ - {{{ +#define H5_PRIVATE_ENTER(pkg, pkg_init) \ + FUNC_ENTER_CHECK_NAME(H5_IS_PRIV(FUNC)) \ + \ + /* The library should be initialized already */ \ + HDassert(H5_INIT_GLOBAL); \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ + { \ + { + +#define H5_PUBLIC_ENTER(pkg, pkg_init) \ + FUNC_ENTER_API_VARS \ + FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_CHECK_NAME(H5_IS_PUB(FUNC)) \ + \ + /* Clear thread error stack when entering public functions */ \ + H5E_clear_stack(NULL); \ + \ + /* Initialize the library or bust */ \ + if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ + if (H5_init_library() < 0) { \ + /* (Can't use H5E_THROW here) */ \ + H5E_PRINTF(H5E_CANTINIT, "interface initialization failed"); \ + ret_value = fail_value; \ + goto func_init_failed; \ + } /* end if */ \ + } /* end if */ \ + \ + /* Initialize this interface if desired */ \ + H5_PKG_INIT(pkg_init, pkg) \ + \ + /* Check for re-entering API routine */ \ + HDassert(!H5_api_entered_g); \ + H5_api_entered_g = TRUE; \ + \ + /* Start logging MPI's MPE information */ \ + BEGIN_MPE_LOG \ + \ + /* Push the name of this function on the function stack */ \ + H5_PUSH_FUNC \ + \ + /* Enter scope for this type of function */ \ + { \ + { \ + { /* Macros for substituting the package name */ #define FUNC_ENT_STATIC(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) -#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) -#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) +#define FUNC_ENT_PKGINIT(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, INIT) +#define FUNC_ENT_PKG(pkg, pkg_init) H5_PACKAGE_ENTER(pkg, pkg_init, REG) #define FUNC_ENT_PRIV(pkg, pkg_init) H5_PRIVATE_ENTER(pkg, pkg_init) -#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) +#define FUNC_ENT_PUB(pkg, pkg_init) H5_PUBLIC_ENTER(pkg, pkg_init) /* Macros for substituting a function prefix */ -#define FUNC_PREFIX_STATIC static +#define FUNC_PREFIX_STATIC static #define FUNC_PREFIX_PKGINIT #define FUNC_PREFIX_PKG #define FUNC_PREFIX_PRIV @@ -2599,134 +2613,134 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through /* Macros for declaring error variables */ /* Function can detect errors and has a specific error return value */ -#define FUNC_ERR_VAR_ERR(ret_typ, err) \ - hbool_t past_catch = FALSE; \ +#define FUNC_ERR_VAR_ERR(ret_typ, err) \ + hbool_t past_catch = FALSE; \ ret_typ fail_value = err; /* Function can detect errors but cannot return an error value (Cleanup only) */ -#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) \ - hbool_t past_catch = FALSE; +#define FUNC_ERR_VAR_ERRCATCH(ret_typ, err) hbool_t past_catch = FALSE; /* Function has no need to detect or clean up from errors */ #define FUNC_ERR_VAR_NOERR(ret_typ, err) /* Use this macro when entering all functions */ -#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ -H5_GLUE(FUNC_PREFIX_, scope) \ -ret_typ \ -func \ -/* Open function */ \ -{ \ - ret_typ ret_value = ret_init; \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) \ - H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) +#define BEGIN_FUNC(scope, use_err, ret_typ, ret_init, err, func) \ + H5_GLUE(FUNC_PREFIX_, scope) \ + ret_typ func \ + /* Open function */ \ + { \ + ret_typ ret_value = ret_init; \ + H5_GLUE(FUNC_ERR_VAR_, use_err)(ret_typ, err) H5_GLUE(FUNC_ENT_, scope)(H5_MY_PKG, H5_MY_PKG_INIT) /* Use this macro when entering functions that have no return value */ -#define BEGIN_FUNC_VOID(scope, use_err, func) \ -H5_GLUE(FUNC_PREFIX_, scope) \ -void \ -func \ -/* Open function */ \ -{ \ - H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) \ - H5_GLUE(FUNC_ENT_, scope) +#define BEGIN_FUNC_VOID(scope, use_err, func) \ + H5_GLUE(FUNC_PREFIX_, scope) \ + void func \ + /* Open function */ \ + { \ + H5_GLUE(FUNC_ERR_VAR_, use_err)(void, -, -) H5_GLUE(FUNC_ENT_, scope) /* Macros for label when a function initialization can fail */ -#define H5_PRIV_YES_FUNC_INIT_FAILED func_init_failed: +#define H5_PRIV_YES_FUNC_INIT_FAILED \ +func_init_failed: #define H5_PRIV_NO_FUNC_INIT_FAILED #define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) /* Macros for leaving different scopes of routines */ -#define FUNC_LEAVE_PKGINIT \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKGINIT \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_STATIC \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_STATIC \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PKG \ - /* Leave scope for this type of function */ \ - } \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PKG \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PRIV \ - /* Leave scope for this type of function */ \ - }} \ - \ - /* Label for errors during FUNC_ENTER */ \ - H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ - \ - /* Pop the name of this function off the function stack */ \ +#define FUNC_LEAVE_PRIV \ + /* Leave scope for this type of function */ \ + } \ + } \ + \ + /* Label for errors during FUNC_ENTER */ \ + H5_PRIV_FUNC_INIT_FAILED(H5_MY_PKG_INIT) \ + \ + /* Pop the name of this function off the function stack */ \ H5_POP_FUNC -#define FUNC_LEAVE_PUB \ - /* Leave scope for this type of function */ \ - }}} \ - \ - /* Label for errors during FUNC_ENTER */ \ -func_init_failed: \ - \ - /* Dump error stack if an error occurred during API routine */ \ - if(ret_value == fail_value) \ - (void)H5E_dump_api_stack(TRUE); \ - \ - /* Finish the API tracing info */ \ - H5TRACE_RETURN(ret_value); \ - \ - /* Pop the name of this function off the function stack */ \ - H5_POP_FUNC \ - \ - /* Finish the MPE tracing info */ \ - FINISH_MPE_LOG \ - \ - /* Check for leaving API routine */ \ - HDassert(H5_api_entered_g); \ - H5_api_entered_g = FALSE; \ - \ - /* Release thread-safety semaphore */ \ +#define FUNC_LEAVE_PUB \ + /* Leave scope for this type of function */ \ + } \ + } \ + } \ + \ + /* Label for errors during FUNC_ENTER */ \ +func_init_failed: \ + \ + /* Dump error stack if an error occurred during API routine */ \ + if (ret_value == fail_value) \ + (void)H5E_dump_api_stack(TRUE); \ + \ + /* Finish the API tracing info */ \ + H5TRACE_RETURN(ret_value); \ + \ + /* Pop the name of this function off the function stack */ \ + H5_POP_FUNC \ + \ + /* Finish the MPE tracing info */ \ + FINISH_MPE_LOG \ + \ + /* Check for leaving API routine */ \ + HDassert(H5_api_entered_g); \ + H5_api_entered_g = FALSE; \ + \ + /* Release thread-safety semaphore */ \ FUNC_LEAVE_API_THREADSAFE /* Use this macro when leaving all functions */ -#define END_FUNC(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return(ret_value); \ - \ - /* Close Function */ \ -} +#define END_FUNC(scope) \ + /* Scope-specific function conclusion */ \ + H5_GLUE(FUNC_LEAVE_, scope) \ + \ + /* Leave routine */ \ + return (ret_value); \ + \ + /* Close Function */ \ + } /* Use this macro when leaving void functions */ -#define END_FUNC_VOID(scope) \ - /* Scope-specific function conclusion */ \ - H5_GLUE(FUNC_LEAVE_, scope) \ - \ - /* Leave routine */ \ - return; \ - \ - /* Close Function */ \ -} +#define END_FUNC_VOID(scope) \ + /* Scope-specific function conclusion */ \ + H5_GLUE(FUNC_LEAVE_, scope) \ + \ + /* Leave routine */ \ + return; \ + \ + /* Close Function */ \ + } /* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ -#define H5_BEGIN_TAG(tag) { \ - haddr_t prv_tag = HADDR_UNDEF; \ - H5AC_tag(tag, &prv_tag); \ +#define H5_BEGIN_TAG(tag) \ + { \ + haddr_t prv_tag = HADDR_UNDEF; \ + H5AC_tag(tag, &prv_tag); -#define H5_END_TAG \ - H5AC_tag(prv_tag, NULL); \ -} +#define H5_END_TAG \ + H5AC_tag(prv_tag, NULL); \ + } /* Compile-time "assert" macro */ -#define HDcompile_assert(e) ((void)sizeof(char[ !!(e) ? 1 : -1])) +#define HDcompile_assert(e) ((void)sizeof(char[!!(e) ? 1 : -1])) /* Variants that are correct, but generate compile-time warnings in some circumstances: #define HDcompile_assert(e) do { enum { compile_assert__ = 1 / (e) }; } while(0) #define HDcompile_assert(e) do { typedef struct { unsigned int b: (e); } x; } while(0) @@ -2734,7 +2748,7 @@ func_init_failed: \ /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); -H5_DLL void H5_term_library(void); +H5_DLL void H5_term_library(void); /* Functions to terminate interfaces */ H5_DLL int H5A_term_package(void); @@ -2752,6 +2766,8 @@ H5_DLL int H5G_term_package(void); H5_DLL int H5G_top_term_package(void); H5_DLL int H5I_term_package(void); H5_DLL int H5L_term_package(void); +H5_DLL int H5M_term_package(void); +H5_DLL int H5M_top_term_package(void); H5_DLL int H5P_term_package(void); H5_DLL int H5PL_term_package(void); H5_DLL int H5R_term_package(void); @@ -2761,6 +2777,7 @@ H5_DLL int H5S_top_term_package(void); H5_DLL int H5SL_term_package(void); H5_DLL int H5T_term_package(void); H5_DLL int H5T_top_term_package(void); +H5_DLL int H5VL_term_package(void); H5_DLL int H5Z_term_package(void); /* Checksum functions */ @@ -2772,30 +2789,29 @@ H5_DLL uint32_t H5_hash_string(const char *str); /* Time related routines */ H5_DLL time_t H5_make_time(struct tm *tm); -H5_DLL void H5_nanosleep(uint64_t nanosec); +H5_DLL void H5_nanosleep(uint64_t nanosec); H5_DLL double H5_get_time(void); /* Functions for building paths, etc. */ -H5_DLL herr_t H5_build_extpath(const char *name, char **extpath /*out*/); -H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/); +H5_DLL herr_t H5_build_extpath(const char *name, char **extpath /*out*/); +H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/); #ifdef H5_HAVE_PARALLEL /* Generic MPI functions */ -H5_DLL hsize_t H5_mpi_set_bigio_count(hsize_t new_count); -H5_DLL hsize_t H5_mpi_get_bigio_count(void); -H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new); -H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new); -H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm); -H5_DLL herr_t H5_mpi_info_free(MPI_Info *info); -H5_DLL herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result); -H5_DLL herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result); -H5_DLL herr_t H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, - MPI_Datatype old_type, MPI_Datatype *new_type); +H5_DLL hsize_t H5_mpi_set_bigio_count(hsize_t new_count); +H5_DLL hsize_t H5_mpi_get_bigio_count(void); +H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new); +H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new); +H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm); +H5_DLL herr_t H5_mpi_info_free(MPI_Info *info); +H5_DLL herr_t H5_mpi_comm_cmp(MPI_Comm comm1, MPI_Comm comm2, int *result); +H5_DLL herr_t H5_mpi_info_cmp(MPI_Info info1, MPI_Info info2, int *result); +H5_DLL herr_t H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes, MPI_Datatype old_type, + MPI_Datatype *new_type); #endif /* H5_HAVE_PARALLEL */ /* Functions for debugging */ -H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, - const uint8_t *marker, size_t buf_offset, size_t buf_size); - -#endif /* _H5private_H */ +H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *marker, + size_t buf_offset, size_t buf_size); +#endif /* H5private_H */ diff --git a/src/H5public.h b/src/H5public.h index 62f1047fe00..44072ba7fec 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -14,59 +14,58 @@ /* * This file contains public declarations for the HDF5 module. */ -#ifndef _H5public_H -#define _H5public_H +#ifndef H5public_H +#define H5public_H /* Include files for public use... */ /* * Since H5pubconf.h is a generated header file, it is messy to try - * to put a #ifndef _H5pubconf_H ... #endif guard in it. + * to put a #ifndef H5pubconf_H ... #endif guard in it. * HDF5 has set an internal rule that it is being included here. * Source files should NOT include H5pubconf.h directly but include - * it via H5public.h. The #ifndef _H5public_H guard above would + * it via H5public.h. The #ifndef H5public_H guard above would * prevent repeated include. */ -#include "H5pubconf.h" /* From configure */ +#include "H5pubconf.h" /* From configure */ /* API Version macro wrapper definitions */ #include "H5version.h" #ifdef H5_HAVE_FEATURES_H -#include /* For setting POSIX, BSD, etc. compatibility */ +#include /* For setting POSIX, BSD, etc. compatibility */ #endif #ifdef H5_HAVE_SYS_TYPES_H #include #endif #ifdef H5_STDC_HEADERS -# include /* For H5T_NATIVE_CHAR defn in H5Tpublic.h */ -# include /* For variadic functions in H5VLpublic.h */ +#include /* For H5T_NATIVE_CHAR defn in H5Tpublic.h */ +#include /* For variadic functions in H5VLpublic.h */ #endif #ifndef __cplusplus -# ifdef H5_HAVE_STDINT_H -# include /* For C9x types */ -# endif +#ifdef H5_HAVE_STDINT_H +#include /* For C9x types */ +#endif #else -# ifdef H5_HAVE_STDINT_H_CXX -# include /* For C9x types (when included from C++) */ -# endif +#ifdef H5_HAVE_STDINT_H_CXX +#include /* For C9x types (when included from C++) */ +#endif #endif #ifdef H5_HAVE_INTTYPES_H -# include /* C99/POSIX.1 header for uint64_t, PRIu64 */ +#include /* C99/POSIX.1 header for uint64_t, PRIu64 */ #endif #ifdef H5_HAVE_STDDEF_H -# include +#include #endif #ifdef H5_HAVE_PARALLEL /* Don't link against MPI C++ bindings */ -# define MPICH_SKIP_MPICXX 1 -# define OMPI_SKIP_MPICXX 1 -# include -#ifndef MPI_FILE_NULL /* MPIO may be defined in mpi.h already */ -# include +#define MPICH_SKIP_MPICXX 1 +#define OMPI_SKIP_MPICXX 1 +#include +#ifndef MPI_FILE_NULL /* MPIO may be defined in mpi.h already */ +#include #endif #endif - /* Include the Windows API adapter header early */ #include "H5api_adpt.h" @@ -81,289 +80,798 @@ extern "C" { */ /* These pragmas are only implemented usefully in gcc 4.6+ */ #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 - #define H5_GCC_DIAG_STR(s) #s - #define H5_GCC_DIAG_JOINSTR(x,y) H5_GCC_DIAG_STR(x ## y) - #define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma (#x) - #define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x) +#define H5_GCC_DIAG_JOINSTR(x, y) x y +#define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma(#x) +#define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x) - #define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR(-W,x)) - #define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop) +#define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR("-W", x)) +#define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop) #else - #define H5_GCC_DIAG_OFF(x) - #define H5_GCC_DIAG_ON(x) +#define H5_GCC_DIAG_OFF(x) +#define H5_GCC_DIAG_ON(x) #endif /* Version numbers */ -#define H5_VERS_MAJOR 1 /* For major interface/format changes */ -#define H5_VERS_MINOR 10 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 7 /* For tweaks, bug-fixes, or development */ -#define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ - /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.10.7" /* Full version string */ +/** + * For major interface/format changes + */ +#define H5_VERS_MAJOR 1 +/** + * For minor interface/format changes + */ +#define H5_VERS_MINOR 12 +/** + * For tweaks, bug-fixes, or development + */ +#define H5_VERS_RELEASE 1 +/** + * For pre-releases like \c snap0. Empty string for official releases. + */ +#define H5_VERS_SUBRELEASE "" +/** + * Full version string + */ +#define H5_VERS_INFO "HDF5 library version: 1.12.1" -#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ - H5_VERS_RELEASE) +#define H5check() H5check_version(H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE) /* macros for comparing the version */ -#define H5_VERSION_GE(Maj,Min,Rel) \ - (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE>=Rel)) || \ - ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \ - (H5_VERS_MAJOR>Maj)) +/** + * \brief Determines whether the version of the library being used is greater + * than or equal to the specified version + * + * \param[in] Maj Major version number - A non-negative integer value + * \param[in] Min Minor version number - A non-negative integer value + * \param[in] Rel Release version number - A non-negative integer value + * \returns A value of 1 is returned if the library version is greater than + * or equal to the version number specified.\n + * A value of 0 is returned if the library version is less than the + * version number specified.\n + * A library version is greater than the specified version number if + * its major version is larger than the specified major version + * number. If the major version numbers are the same, it is greater + * than the specified version number if its minor version is larger + * than the specified minor version number. If the minor version + * numbers are the same, then a library version would be greater than + * the specified version number if its release number is larger than + * the specified release number. + * + * \details The #H5_VERSION_GE and #H5_VERSION_LE macros are used at compile + * time to conditionally include or exclude code based on the version + * of the HDF5 library against which an application will be linked. + * + * The #H5_VERSION_GE macro compares the version of the HDF5 library + * being used against the version number specified in the parameters. + * + * For more information about release versioning, see \ref_h5lib_relver. + * + * \since 1.8.7 + * + */ +#define H5_VERSION_GE(Maj, Min, Rel) \ + (((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR == Min) && (H5_VERS_RELEASE >= Rel)) || \ + ((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR > Min)) || (H5_VERS_MAJOR > Maj)) -#define H5_VERSION_LE(Maj,Min,Rel) \ - (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE<=Rel)) || \ - ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR 0) { - * printf("data type is committed\n"); - * } else if (!retval) { - * printf("data type is not committed\n"); - * } else { - * printf("error determining whether data type is committed\n"); - * } + * for truth from a #htri_t function is: + * \code + * if ((retval = H5Tcommitted(type)) > 0) { + * printf("data type is committed\n"); + * } else if (!retval) { + * printf("data type is not committed\n"); + * } else { + * printf("error determining whether data type is committed\n"); + * } + * \endcode */ #ifdef H5_HAVE_STDBOOL_H - #include +#include #else /* H5_HAVE_STDBOOL_H */ - #ifndef __cplusplus - #if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0) - #define bool _Bool - #else - #define bool unsigned int - #endif - #define true 1 - #define false 0 - #endif /* __cplusplus */ +#ifndef __cplusplus +#if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0) +#define bool _Bool +#else +#define bool unsigned int +#endif +#define true 1 +#define false 0 +#endif /* __cplusplus */ #endif /* H5_HAVE_STDBOOL_H */ typedef bool hbool_t; -typedef int htri_t; +typedef int htri_t; /* Define the ssize_t type if it not is defined */ -#if H5_SIZEOF_SSIZE_T==0 +#if H5_SIZEOF_SSIZE_T == 0 /* Undefine this size, we will re-define it in one of the sections below */ #undef H5_SIZEOF_SSIZE_T -#if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT +#if H5_SIZEOF_SIZE_T == H5_SIZEOF_INT typedef int ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT -#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT +#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG typedef long ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG -#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG +#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG_LONG typedef long long ssize_t; -# define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG #else /* Can't find matching type for ssize_t */ -# error "nothing appropriate for ssize_t" +#error "nothing appropriate for ssize_t" #endif #endif -/* - * The sizes of file objects have their own types defined here, use a 64-bit - * type. +/* int64_t type is used for creation order field for links. It may be + * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_LONG_LONG >= 8 -H5_GCC_DIAG_OFF(long-long) -typedef unsigned long long hsize_t; -typedef signed long long hssize_t; -H5_GCC_DIAG_ON(long-long) -# define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG -# define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG +#if H5_SIZEOF_INT64_T >= 8 +#elif H5_SIZEOF_INT >= 8 +typedef int int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 8 +typedef long int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG +#elif H5_SIZEOF_LONG_LONG >= 8 +typedef long long int64_t; +#undef H5_SIZEOF_INT64_T +#define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG #else -# error "nothing appropriate for hsize_t" +#error "nothing appropriate for int64_t" #endif -#define HSIZE_UNDEF ((hsize_t)(hssize_t)(-1)) -/* - * File addresses have their own types. +/* uint64_t type is used for fields for H5O_info_t. It may be + * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_INT >= 8 - typedef unsigned haddr_t; -# define HADDR_UNDEF ((haddr_t)(-1)) -# define H5_SIZEOF_HADDR_T H5_SIZEOF_INT -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_UNSIGNED -# endif /* H5_HAVE_PARALLEL */ +#if H5_SIZEOF_UINT64_T >= 8 +#ifndef UINT64_MAX +#define UINT64_MAX ((uint64_t)-1) +#endif +#elif H5_SIZEOF_INT >= 8 +typedef unsigned uint64_t; +#define UINT64_MAX UINT_MAX +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_INT #elif H5_SIZEOF_LONG >= 8 - typedef unsigned long haddr_t; -# define HADDR_UNDEF ((haddr_t)(long)(-1)) -# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG -# endif /* H5_HAVE_PARALLEL */ +typedef unsigned long uint64_t; +#define UINT64_MAX ULONG_MAX +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG #elif H5_SIZEOF_LONG_LONG >= 8 - typedef unsigned long long haddr_t; -# define HADDR_UNDEF ((haddr_t)(long long)(-1)) -# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG -# ifdef H5_HAVE_PARALLEL -# define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT -# endif /* H5_HAVE_PARALLEL */ -#else -# error "nothing appropriate for haddr_t" -#endif -#if H5_SIZEOF_HADDR_T == H5_SIZEOF_INT -# define H5_PRINTF_HADDR_FMT "%u" -#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG -# define H5_PRINTF_HADDR_FMT "%lu" -#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG_LONG -# define H5_PRINTF_HADDR_FMT "%" H5_PRINTF_LL_WIDTH "u" +typedef unsigned long long uint64_t; +#define UINT64_MAX ULLONG_MAX +#undef H5_SIZEOF_UINT64_T +#define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG #else -# error "nothing appropriate for H5_PRINTF_HADDR_FMT" +#error "nothing appropriate for uint64_t" #endif -#define HADDR_MAX (HADDR_UNDEF-1) -/* uint32_t type is used for creation order field for messages. It may be - * defined in Posix.1g, otherwise it is defined here. +/* + * The sizes of file objects have their own types defined here, use a minimum + * 64-bit type. */ -#if H5_SIZEOF_UINT32_T>=4 -#elif H5_SIZEOF_SHORT>=4 - typedef short uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT -#elif H5_SIZEOF_INT>=4 - typedef unsigned int uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=4 - typedef unsigned long uint32_t; -# undef H5_SIZEOF_UINT32_T -# define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG +#if H5_SIZEOF_LONG_LONG >= 8 +H5_GCC_DIAG_OFF("long-long") +typedef unsigned long long hsize_t; +typedef signed long long hssize_t; +H5_GCC_DIAG_ON("long-long") +#define PRIdHSIZE H5_PRINTF_LL_WIDTH "d" +#define PRIiHSIZE H5_PRINTF_LL_WIDTH "i" +#define PRIoHSIZE H5_PRINTF_LL_WIDTH "o" +#define PRIuHSIZE H5_PRINTF_LL_WIDTH "u" +#define PRIxHSIZE H5_PRINTF_LL_WIDTH "x" +#define PRIXHSIZE H5_PRINTF_LL_WIDTH "X" +#define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG +#define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG +#define HSIZE_UNDEF ULLONG_MAX #else -# error "nothing appropriate for uint32_t" +#error "nothing appropriate for hsize_t" #endif -/* int64_t type is used for creation order field for links. It may be - * defined in Posix.1g, otherwise it is defined here. +/* + * File addresses have their own types. */ -#if H5_SIZEOF_INT64_T>=8 -#elif H5_SIZEOF_INT>=8 - typedef int int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=8 - typedef long int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG>=8 - typedef long long int64_t; -# undef H5_SIZEOF_INT64_T -# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG +#if H5_SIZEOF_INT >= 8 +typedef unsigned haddr_t; +#define HADDR_UNDEF UINT_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_INT +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_UNSIGNED +#endif /* H5_HAVE_PARALLEL */ +#define PRIdHADDR "d" +#define PRIoHADDR "o" +#define PRIuHADDR "u" +#define PRIxHADDR "x" +#define PRIXHADDR "X" +#elif H5_SIZEOF_LONG >= 8 +typedef unsigned long haddr_t; +#define HADDR_UNDEF ULONG_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG +#endif /* H5_HAVE_PARALLEL */ +#define PRIdHADDR "ld" +#define PRIoHADDR "lo" +#define PRIuHADDR "lu" +#define PRIxHADDR "lx" +#define PRIXHADDR "lX" +#elif H5_SIZEOF_LONG_LONG >= 8 +typedef unsigned long long haddr_t; +#define HADDR_UNDEF ULLONG_MAX +#define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG +#ifdef H5_HAVE_PARALLEL +#define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT +#endif /* H5_HAVE_PARALLEL */ +#define PRIdHADDR H5_PRINTF_LL_WIDTH "d" +#define PRIoHADDR H5_PRINTF_LL_WIDTH "o" +#define PRIuHADDR H5_PRINTF_LL_WIDTH "u" +#define PRIxHADDR H5_PRINTF_LL_WIDTH "x" +#define PRIXHADDR H5_PRINTF_LL_WIDTH "X" #else -# error "nothing appropriate for int64_t" +#error "nothing appropriate for haddr_t" #endif +#define H5_PRINTF_HADDR_FMT "%" PRIuHADDR +#define HADDR_MAX (HADDR_UNDEF - 1) -/* uint64_t type is used for fields for H5O_info_t. It may be +/* uint32_t type is used for creation order field for messages. It may be * defined in Posix.1g, otherwise it is defined here. */ -#if H5_SIZEOF_UINT64_T>=8 -#elif H5_SIZEOF_INT>=8 - typedef unsigned uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_INT -#elif H5_SIZEOF_LONG>=8 - typedef unsigned long uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG -#elif H5_SIZEOF_LONG_LONG>=8 - typedef unsigned long long uint64_t; -# undef H5_SIZEOF_UINT64_T -# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG +#if H5_SIZEOF_UINT32_T >= 4 +#elif H5_SIZEOF_SHORT >= 4 +typedef short uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT +#elif H5_SIZEOF_INT >= 4 +typedef unsigned int uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_INT +#elif H5_SIZEOF_LONG >= 4 +typedef unsigned long uint32_t; +#undef H5_SIZEOF_UINT32_T +#define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG #else -# error "nothing appropriate for uint64_t" +#error "nothing appropriate for uint32_t" #endif -/* Common iteration orders */ +//! +/** + * Common iteration orders + */ typedef enum { - H5_ITER_UNKNOWN = -1, /* Unknown order */ - H5_ITER_INC, /* Increasing order */ - H5_ITER_DEC, /* Decreasing order */ - H5_ITER_NATIVE, /* No particular order, whatever is fastest */ - H5_ITER_N /* Number of iteration orders */ + H5_ITER_UNKNOWN = -1, /**< Unknown order */ + H5_ITER_INC, /**< Increasing order */ + H5_ITER_DEC, /**< Decreasing order */ + H5_ITER_NATIVE, /**< No particular order, whatever is fastest */ + H5_ITER_N /**< Number of iteration orders */ } H5_iter_order_t; +//! /* Iteration callback values */ /* (Actually, any positive value will cause the iterator to stop and pass back * that positive value to the function that called the iterator) */ -#define H5_ITER_ERROR (-1) -#define H5_ITER_CONT (0) -#define H5_ITER_STOP (1) +#define H5_ITER_ERROR (-1) +#define H5_ITER_CONT (0) +#define H5_ITER_STOP (1) -/* +//! +/** * The types of indices on links in groups/attributes on objects. * Primarily used for " by index" routines and for iterating over * links in groups/attributes on objects. */ typedef enum H5_index_t { - H5_INDEX_UNKNOWN = -1, /* Unknown index type */ - H5_INDEX_NAME, /* Index on names */ - H5_INDEX_CRT_ORDER, /* Index on creation order */ - H5_INDEX_N /* Number of indices defined */ + H5_INDEX_UNKNOWN = -1, /**< Unknown index type */ + H5_INDEX_NAME, /**< Index on names */ + H5_INDEX_CRT_ORDER, /**< Index on creation order */ + H5_INDEX_N /**< Number of indices defined */ } H5_index_t; +//! -/* +/** * Storage info struct used by H5O_info_t and H5F_info_t */ +//! typedef struct H5_ih_info_t { - hsize_t index_size; /* btree and/or list */ - hsize_t heap_size; + hsize_t index_size; /**< btree and/or list */ + hsize_t heap_size; } H5_ih_info_t; +//! -/* +/** + * The maximum size allowed for tokens + * \details Tokens are unique and permanent identifiers that are + * used to reference HDF5 objects in a container. This allows + * for 128-bit tokens + */ +#define H5O_MAX_TOKEN_SIZE (16) + +//! +/** + * Type for object tokens + * + * \internal (Hoisted here, since it's used by both the + * H5Lpublic.h and H5Opublic.h headers) + */ +typedef struct H5O_token_t { + uint8_t __data[H5O_MAX_TOKEN_SIZE]; +} H5O_token_t; +//! + +/** * Allocation statistics info struct */ typedef struct H5_alloc_stats_t { - unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ - size_t curr_alloc_bytes; /* Current # of bytes allocated */ - size_t peak_alloc_bytes; /* Peak # of bytes allocated */ - size_t max_block_size; /* Largest block allocated */ - size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ - size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ - size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ + unsigned long long total_alloc_bytes; /**< Running count of total # of bytes allocated */ + size_t curr_alloc_bytes; /**< Current # of bytes allocated */ + size_t peak_alloc_bytes; /**< Peak # of bytes allocated */ + size_t max_block_size; /**< Largest block allocated */ + size_t total_alloc_blocks_count; /**< Running count of total # of blocks allocated */ + size_t curr_alloc_blocks_count; /**< Current # of blocks allocated */ + size_t peak_alloc_blocks_count; /**< Peak # of blocks allocated */ } H5_alloc_stats_t; /* Functions in H5.c */ +/** + * \ingroup H5 + * \brief Initializes the HDF5 library + * \return \herr_t + * + * \details H5open() initializes the HDF5 library. + * + * \details When the HDF5 library is used in a C application, the library is + * automatically initialized when the first HDf5 function call is + * issued. If one finds that an HDF5 library function is failing + * inexplicably, H5open() can be called first. It is safe to call + * H5open() before an application issues any other function calls to + * the HDF5 library as there are no damaging side effects in calling + * it more than once. + */ H5_DLL herr_t H5open(void); +/** + * \ingroup H5 + * \brief Flushes all data to disk, closes all open objects, and releases memory + * \return \herr_t + * + * \details H5close() flushes all data to disk, closes all open HDF5 objects, + * and cleans up all memory used by the HDF5 library. This function is + * generally called when the application calls exit(), but may be + * called earlier in the event of an emergency shutdown or out of a + * desire to free all resources used by the HDF5 library. + */ H5_DLL herr_t H5close(void); +/** + * \ingroup H5 + * \brief Instructs library not to install atexit() cleanup routine + * \return \herr_t + * + * \details H5dont_atexit() indicates to the library that an atexit() cleanup + * routine should not be installed. The major purpose for using this + * function is in situations where the library is dynamically linked + * into an application and is un-linked from the application before + * exit() gets called. In those situations, a routine installed with + * atexit() would jump to a routine which was no longer in memory, + * causing errors. + * + * \attention In order to be effective, this routine \Emph{must} be called + * before any other HDF5 function calls, and must be called each + * time the library is loaded/linked into the application (the first + * time and after it's been un-loaded). + */ H5_DLL herr_t H5dont_atexit(void); +/** + * \ingroup H5 + * \brief Garbage collects on all free-lists of all types + * \return \herr_t + * + * \details H5garbage_collect() walks through all garbage collection routines + * of the library, freeing any unused memory. + * + * It is not required that H5garbage_collect() be called at any + * particular time; it is only necessary in certain situations where + * the application has performed actions that cause the library to + * allocate many objects. The application should call + * H5garbage_collect() if it eventually releases those objects and + * wants to reduce the memory used by the library from the peak usage + * required. + * + * \note The library automatically garbage collects all the free lists when the + * application ends. + */ H5_DLL herr_t H5garbage_collect(void); -H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, - int blk_list_lim); -H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, - size_t *blk_size, size_t *fac_size); +/** + * \ingroup H5 + * \brief Sets free-list size limits + * + * \param[in] reg_global_lim The cumulative limit, in bytes, on memory used for + * all regular free lists (Default: 1MB) + * \param[in] reg_list_lim The limit, in bytes, on memory used for each regular + * free list (Default: 64KB) + * \param[in] arr_global_lim The cumulative limit, in bytes, on memory used for + * all array free lists (Default: 4MB) + * \param[in] arr_list_lim The limit, in bytes, on memory used for each array + * free list (Default: 256KB) + * \param[in] blk_global_lim The cumulative limit, in bytes, on memory used for + * all block free lists and, separately, for all + * factory free lists (Default: 16MB) + * \param[in] blk_list_lim The limit, in bytes, on memory used for each block + * or factory free list (Default: 1MB) + * \return \herr_t + * + * \details H5set_free_list_limits() sets size limits on all types of free + * lists. The HDF5 library uses free lists internally to manage + * memory. The types of free lists used are as follows: + * \li Regular free lists manage memory for single internal data + * structures. + * \li Array free lists manage memory for arrays of internal + * data structures. + * \li Block free lists manage memory for arbitrarily-sized blocks + * of bytes. + * \li Factory free lists manage memory for fixed-size blocks of + * bytes. + * + * The parameters specify global and per-list limits; for example, \p + * reg_global_limit and \p reg_list_limit limit the accumulated size + * of all regular free lists and the size of each individual regular + * free list, respectively. Therefore, if an application sets a 1Mb + * limit on each of the global lists, up to 4Mb of total storage might + * be allocated, 1Mb for each of the regular, array, block, and + * factory type lists. + * + * The settings specified for block free lists are duplicated for + * factory free lists. Therefore, increasing the global limit on block + * free lists by x bytes will increase the potential free list memory + * usage by 2x bytes. + * + * Using a value of -1 for a limit means that no limit is set for the + * specified type of free list. + * + * \version 1.8.3 Function changed in this release to set factory free list + * memory limits. + * + * \since 1.6.0 + */ +H5_DLL herr_t H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, + int arr_list_lim, int blk_global_lim, int blk_list_lim); +/** + * \ingroup H5 + * \brief Gets the current size of the free lists used to manage memory + * + * \param[out] reg_size The current size of all "regular" free list memory used + * \param[out] arr_size The current size of all "array" free list memory used + * \param[out] blk_size The current size of all "block" free list memory used + * \param[out] fac_size The current size of all "factory" free list memory used + * \return \herr_t + * + * \details H5get_free_list_sizes() obtains 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. + * + * \since 1.12.1 + */ +H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size); +/** + * \ingroup H5 + * \brief Gets the memory allocation statistics for the library + * + * \param[out] stats Memory allocation statistics + * \return \herr_t + * + * \details H5get_alloc_stats() gets the memory allocation statistics for the + * library, if the \c --enable-memory-alloc-sanity-check option was + * given when building the library. Applications can check whether + * this option was enabled detecting if the + * \c 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 do not include allocations from chunked dataset + * I/O filters or non-native VOL connectors. + * + * \since 1.12.1 + */ H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats); -H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, - unsigned *relnum); -H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, - unsigned relnum); +/** + * \ingroup H5 + * \brief Returns the HDF library release number + * + * \param[out] majnum The major version number of the library + * \param[out] minnum The minor version number of the library + * \param[out] relnum The release version number of the library + * \return \herr_t + * + * \details H5get_libversion() retrieves the major, minor, and release numbers + * of the version of the HDF5 library which is linked to the + * application. + * + */ +H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); +/** + * \ingroup H5 + * \brief Verifies that HDF5 library versions are consistent + * + * \param[in] majnum HDF5 library major version number + * \param[in] minnum HDF5 library minor version number + * \param[in] relnum HDF5 library release number + * \return \herr_t + * + * \details H5check_version() verifies that the version of the HDF5 library + * with which an application was compiled, as indicated by the passed + * parameters, matches the version of the HDF5 library against which + * the application is currently linked. + * + * \p majnum is the major version number of the HDF library with which + * the application was compiled, \p minnum is the minor version + * number, and \p relnum is the release number. Consider the following + * example: + * + * An official HDF5 release is labelled as follows: + * HDF5 Release \Code{\.\.\}\n + * For example, in HDF5 Release 1.8.5: + * \li 1 is the major version number, \p majnum. + * \li 8 is the minor version number, \p minnum. + * \li 5 is the release number, \p relnum. + * + * As stated above, H5check_version() first verifies that the version + * of the HDF5 library with which an application was compiled matches + * the version of the HDF5 library against which the application is + * currently linked. If this check fails, H5check_version() causes the + * application to abort (by means of a standard C abort() call) and + * prints information that is usually useful for debugging. This + * precaution is is taken to avoid the risks of data corruption or + * segmentation faults. + * + * The most common cause of this failure is that an application was + * compiled with one version of HDF5 and is dynamically linked with a + * different version different version. + * + * If the above test passes, H5check_version() proceeds to verify the + * consistency of additional library version information. This is + * designed to catch source code inconsistencies that do not normally + * cause failures; if this check reveals an inconsistency, an + * informational warning is printed but the application is allowed to + * run. + * + */ +H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); +/** + * \ingroup H5 + * \brief Determines whether the HDF5 library was built with the thread-safety + * feature enabled + * + * \param[out] is_ts Boolean value indicating whether the library was built + * with thread-safety enabled + * \return \herr_t + * + * \details The HDF5 library, although not internally multi-threaded, can be + * built with a thread-safety feature enabled that protects internal + * data structures with a mutex. In certain circumstances, it may be + * useful to determine, at run-time, whether the linked HDF5 library + * was built with the thread-safety feature enabled. + */ H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); +/** + * \ingroup H5 + * \brief Frees memory allocated by the HDF5 library + * + * \param[in] mem Buffer to be freed. Can be NULL + * \return \herr_t + * + * \details H5free_memory() frees memory that has been allocated by the caller + * with H5allocate_memory() or by the HDF5 library on behalf of the + * caller. + * + * H5Tget_member_name() provides an example of memory allocation on + * behalf of the caller: The function returns a buffer containing the + * name of a compound datatype member. It is the caller’s + * responsibility to eventually free that buffer with H5free_memory(). + * + * \attention It is especially important to use this function to free memory + * allocated by the library on Windows. The C standard library is + * implemented in dynamic link libraries (DLLs) known as the C + * run-time (CRT). Each version of Visual Studio comes with two CRT + * DLLs (debug and release) and allocating and freeing across DLL + * boundaries can cause resource leaks and subtle bugs due to heap + * corruption.\n + * Only use this function to free memory allocated by the HDF5 + * Library. It will generally not be safe to use this function to + * free memory allocated by any other means.\n + * Even when using this function, it is still best to ensure that + * all components of a C application are built with the same version + * of Visual Studio and build (debug or release) and thus linked + * against the same CRT. + * + * \see H5allocate_memory(), H5resize_memory() + * + * \since 1.8.13 + * + */ H5_DLL herr_t H5free_memory(void *mem); +/** + * \ingroup H5 + * \brief Frees memory allocated by the HDF5 library + * + * \param[in] size The size in bytes of the buffer to be allocated + * \param[in] clear Flag whether the new buffer is to be initialized with 0 + * + * \return On success, returns pointer to newly allocated buffer or returns + * NULL if size is 0 (zero).\n + * Returns NULL on failure. + * + * \details H5allocate_memory() allocates a memory buffer of size bytes that + * will later be freed internally by the HDF5 library. + * + * The boolean \p clear parameter specifies whether the buffer should + * be initialized. If clear is \c TRUE, all bits in the buffer are to be + * set to 0 (zero); if clear is \c FALSE, the buffer will not be + * initialized. + * + * This function is intended to have the semantics of malloc() and + * calloc(). However, unlike malloc() and calloc() which allow for a + * "special" pointer to be returned instead of NULL, this function + * always returns NULL on failure or when size is set to 0 (zero). + * + * \note At this time, the only intended use for this function is to allocate + * memory that will be returned to the library as a data buffer from a + * third-party filter. + * + * \attention To avoid heap corruption, allocated memory should be freed using + * the same library that initially allocated it. In most cases, the + * HDF5 API uses resources that are allocated and freed either + * entirely by the user or entirely by the library, so this is not a + * problem. In rare cases, however, HDF5 API calls will free memory + * that the user allocated. This function allows the user to safely + * allocate this memory.\n + * It is particularly important to use this function to allocate + * memory in Microsoft Windows environments. In Windows, the C + * standard library is implemented in dynamic link libraries (DLLs) + * known as the C run-time (CRT). Each version of Visual Studio + * comes with multiple versions of the CRT DLLs (debug, release, et + * cetera) and allocating and freeing memory across DLL boundaries + * can cause resource leaks and subtle bugs due to heap corruption.\n + * Even when using this function, it is best where possible to + * ensure that all components of a C application are built with the + * same version of Visual Studio and configuration (Debug or + * Release), and thus linked against the same CRT.\n + * Use this function only to allocate memory inside third-party HDF5 + * filters. It will generally not be safe to use this function to + * allocate memory for any other purpose. + * + * \see H5free_memory(), H5resize_memory() + * + * \since 1.8.15 + * + */ H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); +/** + * \ingroup H5 + * \brief Resizes and, if required, re-allocates memory that will later be + * freed internally by the HDF5 library + * + * \param[in] mem Pointer to a buffer to be resized. May be NULL + * \param[in] size New size of the buffer, in bytes + + * + * \return On success, returns pointer to resized or reallocated buffer + * or returns NULL if size is 0 (zero).\n + * Returns NULL on failure. + * + * \details H5resize_memory() takes a pointer to an existing buffer and resizes + * the buffer to match the value in \p size. If necessary, the buffer + * is reallocated. If \p size is 0, the buffer is released. + * + * The input buffer must either be NULL or have been allocated by + * H5allocate_memory() since the input buffer may be freed by the + * library. + * + * For certain behaviors, the pointer \p mem may be passed in as NULL. + * + * This function is intended to have the semantics of realloc(): + * + * + * + * + * + * + * + * + * + * + *
\Code{H5resize_memory(buffer, size)}Resizes buffer. Returns pointer to resized buffer.
\Code{H5resize_memory(NULL, size)}Allocates memory using HDF5 Library allocator. + * Returns pointer to new buffer
\Code{H5resize_memory(buffer, 0)}Frees memory using HDF5 Library allocator. + * Returns NULL.
\Code{H5resize_memory(NULL, 0)}Returns NULL (undefined in C standard).
+ * + * Unlike realloc(), which allows for a "special pointer to be + * returned instead of NULL, this function always returns NULL on + * failure or when size is 0 (zero). + * + * \note At this time, the only intended use for this function is to resize or + * reallocate memory that will be returned to the library (and eventually + * to the user) as a data buffer from a third-party HDF5 filter. + * + * \attention To avoid heap corruption, allocated memory should be freed using + * the same library that initially allocated it. In most cases, the + * HDF5 API uses resources that are allocated and freed either + * entirely by the user or entirely by the library, so this is not a + * problem. In rare cases, however, HDF5 API calls will free memory + * that the user allocated. This function allows the user to safely + * allocate this memory.\n + * It is particularly important to use this function to resize + * memory on Microsoft Windows systems. In Windows, the C standard + * library is implemented in dynamic link libraries (DLLs) known as + * the C run-time (CRT). Each version of Visual Studio comes with + * multiple versions of the CRT DLLs (debug, release, et cetera) and + * allocating and freeing memory across DLL boundaries can cause + * resource leaks and subtle bugs due to heap corruption.\n + * Even when using this function, it is still best to ensure that + * all components of a C application are built with the same version + * of Visual Studio and the same configuration (Debug or Release), + * and thus linked against the same CRT.\n + * Only use this function to resize memory inside third-party HDF5 + * filters. It will generally not be safe to use this function to + * resize memory for any other purpose. + * + * \see H5allocate_memory(), H5free_memory() + * + * \since 1.8.15 + * + */ H5_DLL void *H5resize_memory(void *mem, size_t size); #ifdef __cplusplus } #endif -#endif /* _H5public_H */ - - +#endif /* H5public_H */ diff --git a/src/H5system.c b/src/H5system.c index e2747f4d80f..144e0bc6a7f 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,47 +25,40 @@ /****************/ /* Module Setup */ /****************/ - +#include "H5module.h" /* This source code file is part of the H5 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ @@ -73,381 +66,36 @@ /* Track whether tzset routine was called */ static hbool_t H5_ntzset = FALSE; - -/*------------------------------------------------------------------------- - * Function: HDfprintf - * - * Purpose: Prints the optional arguments under the control of the format - * string FMT to the stream STREAM. This function takes the - * same format as fprintf(3c) with a few added features: - * - * The conversion modifier `H' refers to the size of an - * `hsize_t' or `hssize_t' type. For instance, "0x%018Hx" - * prints an `hsize_t' value as a hex number right justified and - * zero filled in an 18-character field. - * - * The conversion 'a' refers to an haddr_t type. - * - * The conversion 't' refers to an htri_t type. - * - * Return: Success: Number of characters printed - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Thursday, April 9, 1998 - * - *------------------------------------------------------------------------- +#ifndef H5_HAVE_VASPRINTF +/* HDvasprintf provides vasprintf-like function on targets where it is + * unavailable. */ -/* Disable warning for "format not a string literal" here -QAK */ -/* - * This pragma only needs to surround the fprintf() calls with - * format_templ in the code below, but early (4.4.7, at least) gcc only - * allows diagnostic pragmas to be toggled outside of functions. - */ -H5_GCC_DIAG_OFF(format-nonliteral) int -HDfprintf(FILE *stream, const char *fmt, ...) +HDvasprintf(char **bufp, const char *fmt, va_list _ap) { - int n=0, nout = 0; - int fwidth, prec; - int zerofill; - int leftjust; - int plussign; - int ldspace; - int prefix; - char modifier[8]; - int conv; - char *rest, format_templ[128]; - int len; - const char *s; - va_list ap; - - HDassert(stream); - HDassert(fmt); - - HDva_start (ap, fmt); - while (*fmt) { - fwidth = prec = 0; - zerofill = 0; - leftjust = 0; - plussign = 0; - prefix = 0; - ldspace = 0; - modifier[0] = '\0'; - - if ('%'==fmt[0] && '%'==fmt[1]) { - HDputc ('%', stream); - fmt += 2; - nout++; - } else if ('%'==fmt[0]) { - s = fmt + 1; - - /* Flags */ - while(HDstrchr("-+ #", *s)) { - switch(*s) { - case '-': - leftjust = 1; - break; - - case '+': - plussign = 1; - break; - - case ' ': - ldspace = 1; - break; - - case '#': - prefix = 1; - break; - - default: - HDassert(0 && "Unknown format flag"); - } /* end switch */ /*lint !e744 Switch statement doesn't _need_ default */ - s++; - } /* end while */ - - /* Field width */ - if(HDisdigit(*s)) { - zerofill = ('0' == *s); - fwidth = (int)HDstrtol (s, &rest, 10); - s = rest; - } /* end if */ - else if ('*'==*s) { - fwidth = HDva_arg(ap, int); - if(fwidth < 0) { - leftjust = 1; - fwidth = -fwidth; - } - s++; - } - - /* Precision */ - if('.'==*s) { - s++; - if(HDisdigit(*s)) { - prec = (int)HDstrtol(s, &rest, 10); - s = rest; - } else if('*'==*s) { - prec = HDva_arg(ap, int); - s++; - } - if(prec < 1) - prec = 1; - } - - /* Extra type modifiers */ - if(HDstrchr("zZHhlqLI", *s)) { - switch(*s) { - /*lint --e{506} Don't issue warnings about constant value booleans */ - /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ - case 'H': - if(sizeof(hsize_t) < sizeof(long)) - modifier[0] = '\0'; - else if(sizeof(hsize_t) == sizeof(long)) { - HDstrncpy(modifier, "l", sizeof(modifier)); - modifier[sizeof(modifier) - 1] = '\0'; - } /* end if */ - else { - HDstrncpy(modifier, H5_PRINTF_LL_WIDTH, sizeof(modifier)); - modifier[sizeof(modifier) - 1] = '\0'; - } /* end else */ - break; - - case 'Z': - case 'z': - if(sizeof(size_t) < sizeof(long)) - modifier[0] = '\0'; - else if(sizeof(size_t) == sizeof(long)) { - HDstrncpy(modifier, "l", sizeof(modifier)); - modifier[sizeof(modifier) - 1] = '\0'; - } /* end if */ - else { - HDstrncpy(modifier, H5_PRINTF_LL_WIDTH, sizeof(modifier)); - modifier[sizeof(modifier) - 1] = '\0'; - } /* end else */ - break; - - default: - /* Handle 'I64' modifier for Microsoft's "__int64" type */ - if(*s=='I' && *(s+1)=='6' && *(s+2)=='4') { - modifier[0] = *s; - modifier[1] = *(s+1); - modifier[2] = *(s+2); - modifier[3] = '\0'; - s += 2; /* Increment over 'I6', the '4' is taken care of below */ - } /* end if */ - else { - /* Handle 'll' for long long types */ - if(*s=='l' && *(s+1)=='l') { - modifier[0] = *s; - modifier[1] = *s; - modifier[2] = '\0'; - s++; /* Increment over first 'l', second is taken care of below */ - } /* end if */ - else { - modifier[0] = *s; - modifier[1] = '\0'; - } /* end else */ - } /* end else */ - break; - } - s++; - } - - /* Conversion */ - conv = *s++; - - /* Create the format template */ - len = 0; - len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), "%%%s%s%s%s%s", (leftjust ? "-" : ""), - (plussign ? "+" : ""), (ldspace ? " " : ""), - (prefix ? "#" : ""), (zerofill ? "0" : "")); - if(fwidth > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - if(prec > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), ".%d", prec); - if(*modifier) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%s", modifier); - HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%c", conv); - - /* Conversion */ - switch (conv) { - case 'd': - case 'i': - if(!HDstrcmp(modifier, "h")) { - short x = (short)HDva_arg(ap, int); - n = fprintf(stream, format_templ, x); - } else if(!*modifier) { - int x = HDva_arg(ap, int); - n = fprintf(stream, format_templ, x); - } else if(!HDstrcmp(modifier, "l")) { - long x = HDva_arg(ap, long); - n = fprintf(stream, format_templ, x); - } else { - int64_t x = HDva_arg(ap, int64_t); - n = fprintf(stream, format_templ, x); - } - break; - - case 'o': - case 'u': - case 'x': - case 'X': - if(!HDstrcmp(modifier, "h")) { - unsigned short x = (unsigned short)HDva_arg(ap, unsigned int); - n = fprintf(stream, format_templ, x); - } else if(!*modifier) { - unsigned int x = HDva_arg(ap, unsigned int); - n = fprintf(stream, format_templ, x); - } else if(!HDstrcmp(modifier, "l")) { - unsigned long x = HDva_arg(ap, unsigned long); - n = fprintf(stream, format_templ, x); - } else { - uint64_t x = HDva_arg(ap, uint64_t); - n = fprintf(stream, format_templ, x); - } - break; - - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - if(!HDstrcmp(modifier, "h")) { - float x = (float)HDva_arg(ap, double); - n = fprintf(stream, format_templ, (double)x); - } else if(!*modifier || !HDstrcmp(modifier, "l")) { - double x = HDva_arg(ap, double); - n = fprintf(stream, format_templ, x); - } else { - /* - * Some compilers complain when `long double' and - * `double' are the same thing. - */ -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - long double x = HDva_arg(ap, long double); - n = fprintf(stream, format_templ, x); -#else - double x = HDva_arg(ap, double); - n = fprintf(stream, format_templ, x); -#endif - } - break; - - case 'a': - { - haddr_t x = HDva_arg(ap, haddr_t); - - if(H5F_addr_defined(x)) { - len = 0; - len += HDsnprintf(format_templ, (sizeof(format_templ) - (size_t)(len + 1)), "%%%s%s%s%s%s", - (leftjust ? "-" : ""), (plussign ? "+" : ""), - (ldspace ? " " : ""), (prefix ? "#" : ""), - (zerofill ? "0" : "")); - if(fwidth > 0) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - - /*lint --e{506} Don't issue warnings about constant value booleans */ - /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ - if(sizeof(x) == H5_SIZEOF_INT) { - HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - else if(sizeof(x) == H5_SIZEOF_LONG) { - HDstrncat(format_templ, "lu", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - else if(sizeof(x) == H5_SIZEOF_LONG_LONG) { - HDstrncat(format_templ, H5_PRINTF_LL_WIDTH, (sizeof(format_templ) - (size_t)(len + 1))); - len += (int)sizeof(H5_PRINTF_LL_WIDTH); - HDstrncat(format_templ, "u", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } - n = fprintf(stream, format_templ, x); - } else { - len = 0; - HDstrncpy(format_templ, "%", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - if(leftjust) { - HDstrncat(format_templ, "-", (sizeof(format_templ) - (size_t)(len + 1))); - len++; - } /* end if */ - if(fwidth) - len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); - HDstrncat(format_templ, "s", (sizeof(format_templ) - (size_t)(len + 1))); - n = fprintf(stream, format_templ, "UNDEF"); - } - } - break; - - case 'c': - { - char x = (char)HDva_arg(ap, int); - n = fprintf(stream, format_templ, x); - } - break; - - case 's': - case 'p': - { - char *x = HDva_arg(ap, char*); - n = fprintf(stream, format_templ, x); - } - break; - - case 'n': - format_templ[HDstrlen(format_templ) - 1] = 'u'; - n = fprintf(stream, format_templ, nout); - break; - - case 't': - { - htri_t tri_var = HDva_arg(ap, htri_t); - - if(tri_var > 0) - n = fprintf(stream, "TRUE"); - else if(!tri_var) - n = fprintf(stream, "FALSE"); - else - n = fprintf(stream, "FAIL(%d)", (int)tri_var); - } - break; - - case 'T': /* Elapsed time, in seconds */ - { - double seconds = HDva_arg(ap, double); - char *time_string = H5_timer_get_time_string(seconds); - - if(time_string) { - n = fprintf(stream, format_templ, time_string); - HDfree(time_string); - } /* end if */ - else - n = fprintf(stream, format_templ, "(error)"); - } - break; - - default: - HDfputs(format_templ, stream); - n = (int)HDstrlen(format_templ); - break; - } - nout += n; - fmt = s; - } else { - HDputc(*fmt, stream); - fmt++; - nout++; + char * buf; /* buffer to receive formatted string */ + size_t bufsz; /* size of buffer to allocate */ + + for (bufsz = 32; (buf = HDmalloc(bufsz)) != NULL;) { + int ret; + va_list ap; + + HDva_copy(ap, _ap); + ret = HDvsnprintf(buf, bufsz, fmt, ap); + va_end(ap); + if (ret >= 0 && (size_t)ret < bufsz) { + *bufp = buf; + return ret; } + HDfree(buf); + if (ret < 0) + return ret; + bufsz = (size_t)ret + 1; } - HDva_end(ap); - return nout; -} /* end HDfprintf() */ -H5_GCC_DIAG_ON(format-nonliteral) + return -1; +} +#endif /* H5_HAVE_VASPRINTF */ - /*------------------------------------------------------------------------- * Function: HDstrtoll * @@ -494,61 +142,61 @@ H5_GCC_DIAG_ON(format-nonliteral) int64_t HDstrtoll(const char *s, const char **rest, int base) { - int64_t sign=1, acc=0; - hbool_t overflow = FALSE; + int64_t sign = 1, acc = 0; + hbool_t overflow = FALSE; errno = 0; - if (!s || (base && (base<2 || base>36))) { + if (!s || (base && (base < 2 || base > 36))) { if (rest) *rest = s; return 0; } /* Skip white space */ - while (HDisspace (*s)) s++; + while (HDisspace(*s)) + s++; /* Optional minus or plus sign */ - if ('+'==*s) { + if ('+' == *s) { s++; } - else if ('-'==*s) { + else if ('-' == *s) { sign = -1; s++; } /* Zero base prefix */ - if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { + if (0 == base && '0' == *s && ('x' == s[1] || 'X' == s[1])) { base = 16; s += 2; } - else if (0==base && '0'==*s) { + else if (0 == base && '0' == *s) { base = 8; s++; } - else if (0==base) { + else if (0 == base) { base = 10; } /* Digits */ - while ((base<=10 && *s>='0' && *s<'0'+base) || - (base>10 && ((*s>='0' && *s<='9') || - (*s>='a' && *s<'a'+base-10) || - (*s>='A' && *s<'A'+base-10)))) { + while ((base <= 10 && *s >= '0' && *s < '0' + base) || + (base > 10 && ((*s >= '0' && *s <= '9') || (*s >= 'a' && *s < 'a' + base - 10) || + (*s >= 'A' && *s < 'A' + base - 10)))) { if (!overflow) { int64_t digit = 0; - if (*s>='0' && *s<='9') + if (*s >= '0' && *s <= '9') digit = *s - '0'; - else if (*s>='a' && *s<='z') - digit = (*s-'a')+10; + else if (*s >= 'a' && *s <= 'z') + digit = (*s - 'a') + 10; else - digit = (*s-'A')+10; + digit = (*s - 'A') + 10; - if (acc*base+digit < acc) { + if (acc * base + digit < acc) { overflow = TRUE; } else { - acc = acc*base + digit; + acc = acc * base + digit; } } s++; @@ -556,11 +204,11 @@ HDstrtoll(const char *s, const char **rest, int base) /* Overflow */ if (overflow) { - if (sign>0) { - acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; + if (sign > 0) { + acc = ((uint64_t)1 << (8 * sizeof(int64_t) - 1)) - 1; } else { - acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); + acc = (int64_t)((uint64_t)1 << (8 * sizeof(int64_t) - 1)); } errno = ERANGE; } @@ -572,7 +220,7 @@ HDstrtoll(const char *s, const char **rest, int base) return acc; } /* end HDstrtoll() */ #endif - + /*------------------------------------------------------------------------- * Function: HDrand/HDsrand * @@ -596,19 +244,19 @@ HDstrtoll(const char *s, const char **rest, int base) static unsigned int g_seed = 42; -int HDrand(void) +int +HDrand(void) { return rand_r(&g_seed); } -void HDsrand(unsigned int seed) +void +HDsrand(unsigned int seed) { g_seed = seed; } #endif /* H5_HAVE_RAND_R */ - - /*------------------------------------------------------------------------- * Function: Pflock * @@ -625,26 +273,27 @@ void HDsrand(unsigned int seed) */ #ifdef H5_HAVE_FCNTL int -Pflock(int fd, int operation) { +Pflock(int fd, int operation) +{ - struct flock flk; + struct flock flk; /* Set the lock type */ - if(operation & LOCK_UN) + if (operation & LOCK_UN) flk.l_type = F_UNLCK; - else if(operation & LOCK_SH) + else if (operation & LOCK_SH) flk.l_type = F_RDLCK; else flk.l_type = F_WRLCK; /* Set the other flock struct values */ flk.l_whence = SEEK_SET; - flk.l_start = 0; - flk.l_len = 0; /* to EOF */ - flk.l_pid = 0; /* not used with set */ + flk.l_start = 0; + flk.l_len = 0; /* to EOF */ + flk.l_pid = 0; /* not used with set */ /* Lock or unlock */ - if(HDfcntl(fd, F_SETLK, &flk) < 0) + if (HDfcntl(fd, F_SETLK, &flk) < 0) return -1; return 0; @@ -652,7 +301,6 @@ Pflock(int fd, int operation) { } /* end Pflock() */ #endif /* H5_HAVE_FCNTL */ - /*------------------------------------------------------------------------- * Function: Nflock * @@ -664,12 +312,12 @@ Pflock(int fd, int operation) { *------------------------------------------------------------------------- */ int H5_ATTR_CONST -Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { +Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) +{ /* just succeed */ return 0; } /* end Nflock() */ - /*------------------------------------------------------------------------- * Function: H5_make_time * @@ -692,15 +340,15 @@ Nflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { time_t H5_make_time(struct tm *tm) { - time_t the_time; /* The converted time */ -#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ + time_t the_time; /* The converted time */ +#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global * variable declared in time.h. That variable was deprecated and in * VS 2015 is removed, with _get_timezone replacing it. */ long timezone = 0; -#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */ - time_t ret_value; /* Return value */ +#endif /* defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) */ + time_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -708,21 +356,21 @@ H5_make_time(struct tm *tm) HDassert(tm); /* Initialize timezone information */ - if(!H5_ntzset) { + if (!H5_ntzset) { HDtzset(); H5_ntzset = TRUE; } /* end if */ /* Perform base conversion */ - if((time_t)-1 == (the_time = HDmktime(tm))) + if ((time_t)-1 == (the_time = HDmktime(tm))) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCONVERT, FAIL, "badly formatted modification time message") - /* Adjust for timezones */ + /* Adjust for timezones */ #if defined(H5_HAVE_TM_GMTOFF) /* BSD-like systems */ the_time += tm->tm_gmtoff; #elif defined(H5_HAVE_TIMEZONE) -#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ +#if defined(H5_HAVE_VISUAL_STUDIO) && (_MSC_VER >= 1900) /* VS 2015 */ /* In gcc and in Visual Studio prior to VS 2015 'timezone' is a global * variable declared in time.h. That variable was deprecated and in * VS 2015 is removed, with _get_timezone replacing it. @@ -754,7 +402,6 @@ H5_make_time(struct tm *tm) /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */ #define _W32_FT_OFFSET (116444736000000000ULL) - /*------------------------------------------------------------------------- * Function: Wgettimeofday * @@ -779,34 +426,33 @@ H5_make_time(struct tm *tm) int Wgettimeofday(struct timeval *tv, struct timezone *tz) { - union { - unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME ft; - } _now; + union { + unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } _now; static int tzsetflag; - if(tv) { - GetSystemTimeAsFileTime (&_now.ft); - tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); - tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); + if (tv) { + GetSystemTimeAsFileTime(&_now.ft); + tv->tv_usec = (long)((_now.ns100 / 10ULL) % 1000000ULL); + tv->tv_sec = (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); } - if(tz) { - if(!tzsetflag) { + if (tz) { + if (!tzsetflag) { _tzset(); tzsetflag = 1; } tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; + tz->tz_dsttime = _daylight; } - /* Always return 0 as per Open Group Base Specifications Issue 6. - Do not set errno on error. */ - return 0; + /* Always return 0 as per Open Group Base Specifications Issue 6. + Do not set errno on error. */ + return 0; } /* end Wgettimeofday() */ - /*------------------------------------------------------------------------- * Function: Wsetenv * @@ -825,14 +471,14 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) int Wsetenv(const char *name, const char *value, int overwrite) { - size_t bufsize; + size_t bufsize; errno_t err; /* If we're not overwriting, check if the environment variable exists. * If it does (i.e.: the required buffer size to store the variable's * value is non-zero), then return an error code. */ - if(!overwrite) { + if (!overwrite) { err = getenv_s(&bufsize, NULL, 0, name); if (err || bufsize) return (int)err; @@ -845,7 +491,6 @@ Wsetenv(const char *name, const char *value, int overwrite) #pragma comment(lib, "advapi32.lib") #endif - /*------------------------------------------------------------------------- * Function: H5_get_win32_times * @@ -864,25 +509,25 @@ Wsetenv(const char *name, const char *value, int overwrite) int H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) { - static HANDLE process_handle; - ULARGE_INTEGER kernel_start; - ULARGE_INTEGER user_start; - FILETIME KernelTime; - FILETIME UserTime; - FILETIME CreationTime; - FILETIME ExitTime; - LARGE_INTEGER counts_start; + static HANDLE process_handle; + ULARGE_INTEGER kernel_start; + ULARGE_INTEGER user_start; + FILETIME KernelTime; + FILETIME UserTime; + FILETIME CreationTime; + FILETIME ExitTime; + LARGE_INTEGER counts_start; static LARGE_INTEGER counts_freq; - static hbool_t is_initialized = FALSE; - BOOL err; + static hbool_t is_initialized = FALSE; + BOOL err; HDassert(tvs); - if(!is_initialized) { + if (!is_initialized) { /* NOTE: This is just a pseudo handle and does not need to be closed. */ process_handle = GetCurrentProcess(); - err = QueryPerformanceFrequency(&counts_freq); - if(0 == err) + err = QueryPerformanceFrequency(&counts_freq); + if (0 == err) return -1; is_initialized = TRUE; } /* end if */ @@ -891,28 +536,27 @@ H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) * System and user times * *************************/ - err = GetProcessTimes(process_handle, &CreationTime, &ExitTime, &KernelTime, - &UserTime); - if(0 == err) + err = GetProcessTimes(process_handle, &CreationTime, &ExitTime, &KernelTime, &UserTime); + if (0 == err) return -1; /* The 1.0E7 factor seems strange but it's due to the clock * ticking in 100 ns increments. */ kernel_start.HighPart = KernelTime.dwHighDateTime; - kernel_start.LowPart = KernelTime.dwLowDateTime; - tvs->system = (double)(kernel_start.QuadPart / 1.0E7F); + kernel_start.LowPart = KernelTime.dwLowDateTime; + tvs->system = (double)(kernel_start.QuadPart / 1.0E7F); user_start.HighPart = UserTime.dwHighDateTime; - user_start.LowPart = UserTime.dwLowDateTime; - tvs->user = (double)(user_start.QuadPart / 1.0E7F); + user_start.LowPart = UserTime.dwLowDateTime; + tvs->user = (double)(user_start.QuadPart / 1.0E7F); /**************** * Elapsed time * ****************/ err = QueryPerformanceCounter(&counts_start); - if(0 == err) + if (0 == err) return -1; tvs->elapsed = (double)(counts_start.QuadPart) / (double)counts_freq.QuadPart; @@ -924,45 +568,19 @@ H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) #define WloginBuffer_count 256 static char Wlogin_buffer[WloginBuffer_count]; - -char* +char * Wgetlogin(void) { #ifdef H5_HAVE_WINSOCK2_H - long bufferCount = WloginBuffer_count; - if (GetUserName(Wlogin_buffer, &bufferCount) == 0) + DWORD bufferCount = WloginBuffer_count; + if (GetUserName(Wlogin_buffer, &bufferCount) != 0) return (Wlogin_buffer); else #endif /* H5_HAVE_WINSOCK2_H */ return NULL; } -int c99_snprintf(char* str, size_t size, const char* format, ...) -{ - int count; - va_list ap; - - HDva_start(ap, format); - count = c99_vsnprintf(str, size, format, ap); - HDva_end(ap); - - return count; -} - -int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) -{ - int count = -1; - - if (size != 0) - count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); - if (count == -1) - count = _vscprintf(format, ap); - - return count; -} - - /*------------------------------------------------------------------------- * Function: Wflock * @@ -974,151 +592,85 @@ int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) *------------------------------------------------------------------------- */ int -Wflock(int H5_ATTR_UNUSED fd, int H5_ATTR_UNUSED operation) { - -/* This is a no-op while we implement a Win32 VFD */ -#if 0 -int -Wflock(int fd, int operation) { +Wflock(int fd, int operation) +{ - HANDLE hFile; - DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; - DWORD dwReserved = 0; - /* MAXDWORD for entire file */ - DWORD nNumberOfBytesToLockLow = MAXDWORD; - DWORD nNumberOfBytesToLockHigh = MAXDWORD; - /* Must initialize OVERLAPPED struct */ - OVERLAPPED overlapped = {0}; + HANDLE hFile; + DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; + DWORD dwReserved = 0; + /* MAXDWORD locks the entire file */ + DWORD nNumberOfBytesToLockLow = MAXDWORD; + DWORD nNumberOfBytesToLockHigh = MAXDWORD; + /* Must initialize OVERLAPPED struct */ + OVERLAPPED overlapped = {0}; /* Get Windows HANDLE */ - hFile = _get_osfhandle(fd); + if (INVALID_HANDLE_VALUE == (hFile = (HANDLE)_get_osfhandle(fd))) + return -1; /* Convert to Windows flags */ - if(operation & LOCK_EX) + if (operation & LOCK_EX) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; /* Lock or unlock */ - if(operation & LOCK_UN) - if(0 == UnlockFileEx(hFile, dwReserved, nNumberOfBytesToLockLow, - nNumberOfBytesToLockHigh, &overlapped)) - return -1; - else - if(0 == LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, - nNumberOfBytesToLockHigh, &overlapped)) + if (operation & LOCK_UN) { + if (0 == + UnlockFileEx(hFile, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, &overlapped)) { + /* Attempting to unlock an already unlocked file will fail and this can happen + * in H5Fstart_swmr_write(). For now, just ignore the "error" (error code: 0x9e / 158). + */ + if (GetLastError() != 158) + return -1; + } + } + else { + if (0 == LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, + &overlapped)) return -1; -#endif /* 0 */ - return 0; -} /* end Wflock() */ - + } - /*-------------------------------------------------------------------------- - * Function: Wnanosleep - * - * Purpose: Sleep for a given # of nanoseconds (Windows version) - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * Fall 2016 - *-------------------------------------------------------------------------- - */ -int -Wnanosleep(const struct timespec *req, struct timespec *rem) -{ - /* XXX: Currently just a placeholder */ return 0; +} /* end Wflock() */ -} /* end Wnanosleep() */ - - /*------------------------------------------------------------------------- - * Function: Wllround, Wllroundf, Wlround, Wlroundf, Wround, Wroundf + * Function: H5_get_utf16_str * - * Purpose: Wrapper function for round functions for use with VS2012 - * and earlier. + * Purpose: Gets a UTF-16 string from an UTF-8 (or ASCII) string. * - * Return: The rounded value that was passed in. + * Return: Success: A pointer to a UTF-16 string + * This must be freed by the caller using H5MM_xfree() + * Failure: NULL * * Programmer: Dana Robinson - * December 2016 + * Spring 2019 * *------------------------------------------------------------------------- */ -long long -Wllround(double arg) -{ - return (long long)(arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5)); -} - -long long -Wllroundf(float arg) -{ - return (long long)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F)); -} - -long -Wlround(double arg) -{ - return (long)(arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5)); -} - -long -Wlroundf(float arg) -{ - return (long)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F)); -} - -double -Wround(double arg) -{ - return arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5); -} - -float -Wroundf(float arg) -{ - return (float)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F)); -} - -/*------------------------------------------------------------------------- -* Function: H5_get_utf16_str -* -* Purpose: Gets a UTF-16 string from an UTF-8 (or ASCII) string. -* -* Return: Success: A pointer to a UTF-16 string -* This must be freed by the caller using H5MM_xfree() -* Failure: NULL -* -* Programmer: Dana Robinson -* Spring 2019 -* -*------------------------------------------------------------------------- -*/ -const wchar_t * +wchar_t * H5_get_utf16_str(const char *s) { - int nwchars = -1; /* Length of the UTF-16 buffer */ - wchar_t *ret_s = NULL; /* UTF-16 version of the string */ + int nwchars = -1; /* Length of the UTF-16 buffer */ + wchar_t *ret_s = NULL; /* UTF-16 version of the string */ /* Get the number of UTF-16 characters needed */ - if(0 == (nwchars = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0))) + if (0 == (nwchars = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0))) goto error; /* Allocate a buffer for the UTF-16 string */ - if(NULL == (ret_s = (wchar_t *)H5MM_calloc(sizeof(wchar_t) * (size_t)nwchars))) + if (NULL == (ret_s = (wchar_t *)H5MM_calloc(sizeof(wchar_t) * (size_t)nwchars))) goto error; /* Convert the input UTF-8 string to UTF-16 */ - if(0 == MultiByteToWideChar(CP_UTF8, 0, s, -1, ret_s, nwchars)) + if (0 == MultiByteToWideChar(CP_UTF8, 0, s, -1, ret_s, nwchars)) goto error; return ret_s; error: - if(ret_s) + if (ret_s) H5MM_xfree((void *)ret_s); return NULL; -} /* end H5_get_utf16_str() */ +} /* end H5_get_utf16_str() */ /*------------------------------------------------------------------------- * Function: Wopen_utf8 @@ -1138,22 +690,22 @@ H5_get_utf16_str(const char *s) int Wopen_utf8(const char *path, int oflag, ...) { - int fd = -1; /* POSIX file descriptor to be returned */ - wchar_t *wpath = NULL; /* UTF-16 version of the path */ - int pmode = 0; /* mode (optionally set via variable args) */ + int fd = -1; /* POSIX file descriptor to be returned */ + wchar_t *wpath = NULL; /* UTF-16 version of the path */ + int pmode = 0; /* mode (optionally set via variable args) */ /* Convert the input UTF-8 path to UTF-16 */ - if(NULL == (wpath = H5_get_utf16_str(path))) + if (NULL == (wpath = H5_get_utf16_str(path))) goto done; /* _O_BINARY must be set in Windows to avoid CR-LF <-> LF EOL - * transformations when performing I/O. Note that this will - * produce Unix-style text files, though. - */ + * transformations when performing I/O. Note that this will + * produce Unix-style text files, though. + */ oflag |= _O_BINARY; /* Get the mode, if O_CREAT was specified */ - if(oflag & O_CREAT) { + if (oflag & O_CREAT) { va_list vl; HDva_start(vl, oflag); @@ -1165,11 +717,11 @@ Wopen_utf8(const char *path, int oflag, ...) fd = _wopen(wpath, oflag, pmode); done: - if(wpath) + if (wpath) H5MM_xfree((void *)wpath); return fd; -} /* end Wopen_utf8() */ +} /* end Wopen_utf8() */ /*------------------------------------------------------------------------- * Function: Wremove_utf8 @@ -1189,26 +741,25 @@ Wopen_utf8(const char *path, int oflag, ...) int Wremove_utf8(const char *path) { - wchar_t *wpath = NULL; /* UTF-16 version of the path */ - int ret; + wchar_t *wpath = NULL; /* UTF-16 version of the path */ + int ret = -1; /* Convert the input UTF-8 path to UTF-16 */ - if(NULL == (wpath = H5_get_utf16_str(path))) + if (NULL == (wpath = H5_get_utf16_str(path))) goto done; /* Open the file */ ret = _wremove(wpath); done: - if(wpath) + if (wpath) H5MM_xfree((void *)wpath); return ret; -} /* end Wremove_utf8() */ +} /* end Wremove_utf8() */ #endif /* H5_HAVE_WIN32_API */ - /*------------------------------------------------------------------------- * Function: H5_build_extpath * @@ -1225,15 +776,15 @@ Wremove_utf8(const char *path) * *------------------------------------------------------------------------- */ -#define MAX_PATH_LEN 1024 +#define MAX_PATH_LEN 1024 herr_t H5_build_extpath(const char *name, char **extpath /*out*/) { - char *full_path = NULL; /* Pointer to the full path, as built or passed in */ - char *cwdpath = NULL; /* Pointer to the current working directory path */ - char *new_name = NULL; /* Pointer to the name of the file */ - herr_t ret_value = SUCCEED; /* Return value */ + char * full_path = NULL; /* Pointer to the full path, as built or passed in */ + char * cwdpath = NULL; /* Pointer to the current working directory path */ + char * new_name = NULL; /* Pointer to the name of the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1248,19 +799,19 @@ H5_build_extpath(const char *name, char **extpath /*out*/) * Unix: name[0] is a "/" * Windows: name[0-2] is ":\" or ":/" */ - if(H5_CHECK_ABSOLUTE(name)) { - if(NULL == (full_path = (char *)H5MM_strdup(name))) + if (H5_CHECK_ABSOLUTE(name)) { + if (NULL == (full_path = (char *)H5MM_strdup(name))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end if */ + } /* end if */ else { /* relative pathname */ - char *retcwd; + char * retcwd; size_t name_len; - int drive; + int drive; - if(NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) + if (NULL == (cwdpath = (char *)H5MM_malloc(MAX_PATH_LEN))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") name_len = HDstrlen(name) + 1; - if(NULL == (new_name = (char *)H5MM_malloc(name_len))) + if (NULL == (new_name = (char *)H5MM_malloc(name_len))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") /* @@ -1268,17 +819,17 @@ H5_build_extpath(const char *name, char **extpath /*out*/) * Get current working directory on the drive specified in NAME * Unix: does not apply */ - if(H5_CHECK_ABS_DRIVE(name)) { - drive = HDtoupper(name[0]) - 'A' + 1; + if (H5_CHECK_ABS_DRIVE(name)) { + drive = HDtoupper(name[0]) - 'A' + 1; retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); HDstrncpy(new_name, &name[2], name_len); } /* end if */ - /* - * Windows: name[0] is a '/' or '\' - * Get current drive - * Unix: does not apply - */ - else if(H5_CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { + /* + * Windows: name[0] is a '/' or '\' + * Get current drive + * Unix: does not apply + */ + else if (H5_CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { HDsnprintf(cwdpath, MAX_PATH_LEN, "%c:%c", (drive + 'A' - 1), name[0]); retcwd = cwdpath; HDstrncpy(new_name, &name[1], name_len); @@ -1289,7 +840,7 @@ H5_build_extpath(const char *name, char **extpath /*out*/) HDstrncpy(new_name, name, name_len); } /* end if */ - if(retcwd != NULL) { + if (retcwd != NULL) { size_t cwdlen; size_t path_len; @@ -1298,37 +849,36 @@ H5_build_extpath(const char *name, char **extpath /*out*/) HDassert(cwdlen); HDassert(new_name); path_len = cwdlen + HDstrlen(new_name) + 2; - if(NULL == (full_path = (char *)H5MM_malloc(path_len))) + if (NULL == (full_path = (char *)H5MM_malloc(path_len))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(full_path, cwdpath, cwdlen + 1); - if(!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1])) + if (!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1])) HDstrncat(full_path, H5_DIR_SEPS, HDstrlen(H5_DIR_SEPS)); HDstrncat(full_path, new_name, HDstrlen(new_name)); } /* end if */ - } /* end else */ + } /* end else */ /* strip out the last component (the file name itself) from the path */ - if(full_path) { + if (full_path) { char *ptr = NULL; H5_GET_LAST_DELIMITER(full_path, ptr) HDassert(ptr); - *++ptr = '\0'; + *++ptr = '\0'; *extpath = full_path; } /* end if */ done: /* Release resources */ - if(cwdpath) + if (cwdpath) H5MM_xfree(cwdpath); - if(new_name) + if (new_name) H5MM_xfree(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5_build_extpath() */ - /*-------------------------------------------------------------------------- * Function: H5_combine_path * @@ -1343,35 +893,35 @@ H5_build_extpath(const char *name, char **extpath /*out*/) *-------------------------------------------------------------------------- */ herr_t -H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) +H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/) { - size_t path1_len; /* length of path1 */ - size_t path2_len; /* length of path2 */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t path1_len = 0; /* length of path1 */ + size_t path2_len; /* length of path2 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(path2); - if(path1) + if (path1) path1_len = HDstrlen(path1); path2_len = HDstrlen(path2); - if(path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { + if (path1 == NULL || *path1 == '\0' || H5_CHECK_ABSOLUTE(path2)) { /* If path1 is empty or path2 is absolute, simply use path2 */ - if(NULL == (*full_name = (char *)H5MM_strdup(path2))) + if (NULL == (*full_name = (char *)H5MM_strdup(path2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ - else if(H5_CHECK_ABS_PATH(path2)) { + else if (H5_CHECK_ABS_PATH(path2)) { /* On windows path2 is a path absolute name */ if (H5_CHECK_ABSOLUTE(path1) || H5_CHECK_ABS_DRIVE(path1)) { /* path1 is absolute or drive absolute and path2 is path absolute. * Use the drive letter of path1 + path2 */ - if(NULL == (*full_name = (char *)H5MM_malloc(path2_len + 3))) + if (NULL == (*full_name = (char *)H5MM_malloc(path2_len + 3))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate path2 buffer") HDsnprintf(*full_name, (path2_len + 3), "%c:%s", path1[0], path2); } /* end if */ @@ -1380,7 +930,7 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) * path1 does not have a drive letter (i.e. is "a\b" or "\a\b"). * Use path2. */ - if(NULL == (*full_name = (char *)H5MM_strdup(path2))) + if (NULL == (*full_name = (char *)H5MM_strdup(path2))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end else */ @@ -1391,11 +941,14 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) * Allocate a buffer to hold path1 + path2 + possibly the delimiter * + terminating null byte */ - if(NULL == (*full_name = (char *)H5MM_malloc(path1_len + path2_len + 2 + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + if (NULL == + (*full_name = (char *)H5MM_malloc(path1_len + path2_len + 2 + + 2))) /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate filename buffer") /* Compose the full file name */ - HDsnprintf(*full_name, (path1_len + path2_len + 2 + 2), "%s%s%s", path1, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ + HDsnprintf(*full_name, (path1_len + path2_len + 2 + 2), "%s%s%s", + path1, /* Extra "+2" to quiet GCC warning - 2019/07/05, QAK */ (H5_CHECK_DELIMITER(path1[path1_len - 1]) ? "" : H5_DIR_SEPS), path2); } /* end else */ @@ -1403,12 +956,14 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_combine_path() */ - /*-------------------------------------------------------------------------- * Function: H5_nanosleep * * Purpose: Sleep for a given # of nanoseconds * + * Note that commodity hardware is probably going to have a + * resolution of milliseconds, not nanoseconds. + * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol @@ -1418,24 +973,34 @@ H5_combine_path(const char* path1, const char* path2, char **full_name /*out*/) void H5_nanosleep(uint64_t nanosec) { - struct timespec sleeptime; /* Struct to hold time to sleep */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Set up time to sleep */ - sleeptime.tv_sec = 0; - sleeptime.tv_nsec = (long)nanosec; +#ifdef H5_HAVE_WIN32_API + + /* On Windows, Sleep() is in milliseconds. Passing 0 to Sleep() + * causes the thread to relinquish the rest of its time slice. + */ + Sleep(nanosec / (1000 * 1000)); + +#else + { + struct timespec sleeptime; /* Struct to hold time to sleep */ + + /* Set up time to sleep */ + sleeptime.tv_sec = 0; + sleeptime.tv_nsec = (long)nanosec; - HDnanosleep(&sleeptime, NULL); + HDnanosleep(&sleeptime, NULL); + } +#endif FUNC_LEAVE_NOAPI_VOID } /* end H5_nanosleep() */ #ifdef H5_HAVE_WIN32_API -#define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 +#define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 - /*------------------------------------------------------------------------- * Function: H5_expand_windows_env_vars() * @@ -1449,9 +1014,9 @@ H5_nanosleep(uint64_t nanosec) herr_t H5_expand_windows_env_vars(char **env_var) { - long n_chars = 0; - char *temp_buf = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + long n_chars = 0; + char * temp_buf = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1460,7 +1025,8 @@ H5_expand_windows_env_vars(char **env_var) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path") /* Expand the environment variable string */ - if ((n_chars = ExpandEnvironmentStringsA(*env_var, temp_buf, H5_WIN32_ENV_VAR_BUFFER_SIZE)) > H5_WIN32_ENV_VAR_BUFFER_SIZE) + if ((n_chars = ExpandEnvironmentStringsA(*env_var, temp_buf, H5_WIN32_ENV_VAR_BUFFER_SIZE)) > + H5_WIN32_ENV_VAR_BUFFER_SIZE) HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long") if (0 == n_chars) @@ -1476,4 +1042,3 @@ H5_expand_windows_env_vars(char **env_var) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_expand_windows_env_vars() */ #endif /* H5_HAVE_WIN32_API */ - diff --git a/src/H5timer.c b/src/H5timer.c index 61d6f0f61dd..b2cc5f09ae4 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,13 +24,12 @@ /****************/ /* Module Setup */ /****************/ - +#include "H5module.h" /* This source code file is part of the H5 module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ - +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ @@ -43,42 +42,34 @@ #define H5TIMER_TIME_STRING_LEN 1536 /* Conversion factors */ -#define H5_SEC_PER_DAY (double)(24.0F * 60.0F * 60.0F) -#define H5_SEC_PER_HOUR (double)(60.0F * 60.0F) -#define H5_SEC_PER_MIN (double)(60.0F) - +#define H5_SEC_PER_DAY (24.0 * 60.0 * 60.0) +#define H5_SEC_PER_HOUR (60.0 * 60.0) +#define H5_SEC_PER_MIN (60.0) /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_bandwidth * @@ -105,45 +96,50 @@ *------------------------------------------------------------------------- */ void -H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) +H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds) { - double bw; + double bw; - if(nseconds <= (double)0.0F) + if (nseconds <= 0.0) HDstrcpy(buf, " NaN"); else { bw = nbytes / nseconds; - if(H5_DBL_ABS_EQUAL(bw, (double)0.0F)) + if (H5_DBL_ABS_EQUAL(bw, 0.0)) HDstrcpy(buf, "0.000 B/s"); - else if(bw < (double)1.0F) + else if (bw < 1.0) HDsprintf(buf, "%10.4e", bw); - else if(bw < (double)H5_KB) { + else if (bw < (double)H5_KB) { HDsprintf(buf, "%05.4f", bw); HDstrcpy(buf + 5, " B/s"); - } else if(bw < (double)H5_MB) { + } + else if (bw < (double)H5_MB) { HDsprintf(buf, "%05.4f", bw / (double)H5_KB); HDstrcpy(buf + 5, " kB/s"); - } else if(bw < (double)H5_GB) { + } + else if (bw < (double)H5_GB) { HDsprintf(buf, "%05.4f", bw / (double)H5_MB); HDstrcpy(buf + 5, " MB/s"); - } else if(bw < (double)H5_TB) { + } + else if (bw < (double)H5_TB) { HDsprintf(buf, "%05.4f", bw / (double)H5_GB); HDstrcpy(buf + 5, " GB/s"); - } else if(bw < (double)H5_PB) { + } + else if (bw < (double)H5_PB) { HDsprintf(buf, "%05.4f", bw / (double)H5_TB); HDstrcpy(buf + 5, " TB/s"); - } else if(bw < (double)H5_EB) { + } + else if (bw < (double)H5_EB) { HDsprintf(buf, "%05.4f", bw / (double)H5_PB); HDstrcpy(buf + 5, " PB/s"); - } else { + } + else { HDsprintf(buf, "%10.4e", bw); - if(HDstrlen(buf) > 10) + if (HDstrlen(buf) > 10) HDsprintf(buf, "%10.3e", bw); } /* end else-if */ - } /* end else */ + } /* end else */ } /* end H5_bandwidth() */ - /*------------------------------------------------------------------------- * Function: H5_now * @@ -159,7 +155,7 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) time_t H5_now(void) { - time_t now; /* Current time */ + time_t now; /* Current time */ #ifdef H5_HAVE_GETTIMEOFDAY { @@ -168,14 +164,13 @@ H5_now(void) HDgettimeofday(&now_tv, NULL); now = now_tv.tv_sec; } -#else /* H5_HAVE_GETTIMEOFDAY */ +#else /* H5_HAVE_GETTIMEOFDAY */ now = HDtime(NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ - return(now); + return (now); } /* end H5_now() */ - /*------------------------------------------------------------------------- * Function: H5_now_usec * @@ -191,7 +186,7 @@ H5_now(void) uint64_t H5_now_usec(void) { - uint64_t now; /* Current time, in microseconds */ + uint64_t now; /* Current time, in microseconds */ #if defined(H5_HAVE_CLOCK_GETTIME) { @@ -207,14 +202,13 @@ H5_now_usec(void) HDgettimeofday(&now_tv, NULL); now = (uint64_t)(now_tv.tv_sec * (1000 * 1000)) + (uint64_t)now_tv.tv_usec; } -#else /* H5_HAVE_GETTIMEOFDAY */ - now = (uint64_t)(HDtime(NULL) * (1000 * 1000)); +#else /* H5_HAVE_GETTIMEOFDAY */ + now = (uint64_t)(HDtime(NULL) * (1000 * 1000)); #endif /* H5_HAVE_GETTIMEOFDAY */ - return(now); + return (now); } /* end H5_now_usec() */ - /*-------------------------------------------------------------------------- * Function: H5_get_time * @@ -230,7 +224,7 @@ H5_now_usec(void) double H5_get_time(void) { - double ret_value = (double)0.0f; + double ret_value = 0.0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -239,14 +233,14 @@ H5_get_time(void) struct timespec ts; HDclock_gettime(CLOCK_MONOTONIC, &ts); - ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / (double)1000000000.0f); + ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / 1000000000.0); } #elif defined(H5_HAVE_GETTIMEOFDAY) { struct timeval now_tv; HDgettimeofday(&now_tv, NULL); - ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / (double)1000000.0f); + ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / 1000000.0); } #else ret_value = (double)HDtime(NULL); @@ -255,8 +249,6 @@ H5_get_time(void) FUNC_LEAVE_NOAPI(ret_value) } /* end H5_get_time() */ - - /*------------------------------------------------------------------------- * Function: H5__timer_get_timevals * @@ -279,10 +271,10 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) /* Windows call handles both system/user and elapsed times */ #ifdef H5_HAVE_WIN32_API - if(H5_get_win32_times(times) < 0) { - times->elapsed = -1.0; - times->system = -1.0; - times->user = -1.0; + if (H5_get_win32_times(times) < 0) { + times->elapsed = -1.0; + times->system = -1.0; + times->user = -1.0; return -1; } /* end if */ @@ -292,14 +284,14 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) * System and user times * *************************/ #if defined(H5_HAVE_GETRUSAGE) -{ - struct rusage res; + { + struct rusage res; - if(HDgetrusage(RUSAGE_SELF, &res) < 0) - return -1; - times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / (double)1.0E6F); - times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / (double)1.0E6F); -} + if (HDgetrusage(RUSAGE_SELF, &res) < 0) + return -1; + times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / 1.0E6); + times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / 1.0E6); + } #else /* No suitable way to get system/user times */ /* This is not an error condition, they just won't be available */ @@ -318,7 +310,6 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) return 0; } /* end H5__timer_get_timevals() */ - /*------------------------------------------------------------------------- * Function: H5_timer_init * @@ -384,7 +375,6 @@ H5_timer_init(H5_timer_t *timer /*in,out*/) return 0; } /* end H5_timer_init() */ - /*------------------------------------------------------------------------- * Function: H5_timer_start * @@ -407,7 +397,7 @@ H5_timer_start(H5_timer_t *timer /*in,out*/) /* Start the timer * This sets the "initial" times to the system-defined start times. */ - if(H5__timer_get_timevals(&(timer->initial)) < 0) + if (H5__timer_get_timevals(&(timer->initial)) < 0) return -1; timer->is_running = TRUE; @@ -415,7 +405,6 @@ H5_timer_start(H5_timer_t *timer /*in,out*/) return 0; } /* end H5_timer_start() */ - /*------------------------------------------------------------------------- * Function: H5_timer_stop * @@ -436,27 +425,26 @@ H5_timer_stop(H5_timer_t *timer /*in,out*/) HDassert(timer); /* Stop the timer */ - if(H5__timer_get_timevals(&(timer->final_interval)) < 0) + if (H5__timer_get_timevals(&(timer->final_interval)) < 0) return -1; /* The "final" times are stored as intervals (final - initial) * for more useful reporting to the user. */ timer->final_interval.elapsed = timer->final_interval.elapsed - timer->initial.elapsed; - timer->final_interval.system = timer->final_interval.system - timer->initial.system; - timer->final_interval.user = timer->final_interval.user - timer->initial.user; + timer->final_interval.system = timer->final_interval.system - timer->initial.system; + timer->final_interval.user = timer->final_interval.user - timer->initial.user; /* Add the intervals to the elapsed time */ timer->total.elapsed += timer->final_interval.elapsed; - timer->total.system += timer->final_interval.system; - timer->total.user += timer->final_interval.user; + timer->total.system += timer->final_interval.system; + timer->total.user += timer->final_interval.user; timer->is_running = FALSE; return 0; } /* end H5_timer_stop() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_times * @@ -487,18 +475,18 @@ H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) /* Sanity check */ HDassert(times); - if(timer.is_running) { - H5_timevals_t now; + if (timer.is_running) { + H5_timevals_t now; /* Get the current times and report the current intervals without * stopping the timer. */ - if(H5__timer_get_timevals(&now) < 0) + if (H5__timer_get_timevals(&now) < 0) return -1; times->elapsed = now.elapsed - timer.initial.elapsed; - times->system = now.system - timer.initial.system; - times->user = now.user - timer.initial.user; + times->system = now.system - timer.initial.system; + times->user = now.user - timer.initial.user; } /* end if */ else { times->elapsed = timer.final_interval.elapsed; @@ -509,7 +497,6 @@ H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) return 0; } /* end H5_timer_get_times() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_total_times * @@ -543,18 +530,18 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) /* Sanity check */ HDassert(times); - if(timer.is_running) { - H5_timevals_t now; + if (timer.is_running) { + H5_timevals_t now; /* Get the current times and report the current totals without * stopping the timer. */ - if(H5__timer_get_timevals(&now) < 0) + if (H5__timer_get_timevals(&now) < 0) return -1; times->elapsed = timer.total.elapsed + (now.elapsed - timer.initial.elapsed); - times->system = timer.total.system + (now.system - timer.initial.system); - times->user = timer.total.user + (now.user - timer.initial.user); + times->system = timer.total.system + (now.system - timer.initial.system); + times->user = timer.total.user + (now.user - timer.initial.user); } /* end if */ else { times->elapsed = timer.total.elapsed; @@ -565,7 +552,6 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) return 0; } /* end H5_timer_get_total_times() */ - /*------------------------------------------------------------------------- * Function: H5_timer_get_time_string * @@ -594,16 +580,16 @@ H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) char * H5_timer_get_time_string(double seconds) { - char *s; /* output string */ + char *s; /* output string */ /* Used when the time is greater than 59 seconds */ - double days; - double hours; - double minutes; - double remainder_sec; + double days = 0.0; + double hours = 0.0; + double minutes = 0.0; + double remainder_sec = 0.0; /* Extract larger time units from count of seconds */ - if(seconds > (double)60.0F) { + if (seconds > 60.0) { /* Set initial # of seconds */ remainder_sec = seconds; @@ -623,7 +609,7 @@ H5_timer_get_time_string(double seconds) } /* end if */ /* Allocate */ - if(NULL == (s = (char *)HDcalloc(H5TIMER_TIME_STRING_LEN, sizeof(char)))) + if (NULL == (s = (char *)HDcalloc(H5TIMER_TIME_STRING_LEN, sizeof(char)))) return NULL; /* Do we need a format string? Some people might like a certain @@ -631,26 +617,26 @@ H5_timer_get_time_string(double seconds) * time unit. Perhaps this could be passed as an integer. * (name? round_up_size? ?) */ - if(seconds < (double)0.0F) + if (seconds < 0.0) HDsprintf(s, "N/A"); - else if(H5_DBL_ABS_EQUAL((double)0.0F, seconds)) + else if (H5_DBL_ABS_EQUAL(0.0, seconds)) HDsprintf(s, "0.0 s"); - else if(seconds < (double)1.0E-6F) + else if (seconds < 1.0E-6) /* t < 1 us, Print time in ns */ - HDsprintf(s, "%.f ns", seconds * (double)1.0E9F); - else if(seconds < (double)1.0E-3F) + HDsprintf(s, "%.f ns", seconds * 1.0E9); + else if (seconds < 1.0E-3) /* t < 1 ms, Print time in us */ - HDsprintf(s, "%.1f us", seconds * (double)1.0E6F); - else if(seconds < (double)1.0F) + HDsprintf(s, "%.1f us", seconds * 1.0E6); + else if (seconds < 1.0) /* t < 1 s, Print time in ms */ - HDsprintf(s, "%.1f ms", seconds * (double)1.0E3F); - else if(seconds < H5_SEC_PER_MIN) + HDsprintf(s, "%.1f ms", seconds * 1.0E3); + else if (seconds < H5_SEC_PER_MIN) /* t < 1 m, Print time in s */ HDsprintf(s, "%.2f s", seconds); - else if(seconds < H5_SEC_PER_HOUR) + else if (seconds < H5_SEC_PER_HOUR) /* t < 1 h, Print time in m and s */ HDsprintf(s, "%.f m %.f s", minutes, remainder_sec); - else if(seconds < H5_SEC_PER_DAY) + else if (seconds < H5_SEC_PER_DAY) /* t < 1 d, Print time in h, m and s */ HDsprintf(s, "%.f h %.f m %.f s", hours, minutes, remainder_sec); else @@ -659,4 +645,3 @@ H5_timer_get_time_string(double seconds) return s; } /* end H5_timer_get_time_string() */ - diff --git a/src/H5trace.c b/src/H5trace.c index 89685ad5a72..71675aa18a7 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,60 +25,54 @@ /****************/ /* Module Setup */ /****************/ -#define H5I_FRIEND /*suppress error about including H5Ipkg */ +#include "H5module.h" /* This source code file is part of the H5 module */ +#define H5I_FRIEND /*suppress error about including H5Ipkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Rprivate.h" /* References */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #ifdef H5_HAVE_PARALLEL /* datatypes of predefined drivers needed by H5_trace() */ #include "H5FDmpio.h" #endif /* H5_HAVE_PARALLEL */ - /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5_trace * @@ -117,52 +111,52 @@ double H5_trace(const double *returning, const char *func, const char *type, ...) { - va_list ap; - char buf[64], *rest; - const char *argname; - int argno = 0, ptr, asize_idx; - hssize_t asize[16]; - hssize_t i; - void *vp = NULL; - FILE *out = H5_debug_g.trace; - static hbool_t is_first_invocation = TRUE; - H5_timer_t function_timer; - H5_timevals_t function_times; - static H5_timer_t running_timer; - H5_timevals_t running_times; - static int current_depth = 0; - static int last_call_depth = 0; + va_list ap; + char buf[64], *rest; + const char * argname; + int argno = 0, ptr, asize_idx; + hssize_t asize[16]; + hssize_t i; + void * vp = NULL; + FILE * out = H5_debug_g.trace; + static hbool_t is_first_invocation = TRUE; + H5_timer_t function_timer = {{0}, {0}, {0}, FALSE}; + H5_timevals_t function_times; + static H5_timer_t running_timer; + H5_timevals_t running_times; + static int current_depth = 0; + static int last_call_depth = 0; /* FUNC_ENTER() should not be called */ - if(!out) - return 0.0F; /*tracing is off*/ + if (!out) + return 0.0F; /*tracing is off*/ HDva_start(ap, type); - if(H5_debug_g.ttop) { - if(returning) { - if(current_depth > 1) { + if (H5_debug_g.ttop) { + if (returning) { + if (current_depth > 1) { --current_depth; return 0.0F; } /* end if */ - } /* end if */ + } /* end if */ else { - if(current_depth > 0) { + if (current_depth > 0) { /*do not update last_call_depth*/ current_depth++; return 0.0F; } /* end if */ - } /* end else */ - } /* end if */ + } /* end else */ + } /* end if */ /* Get time for event if the trace times flag is set */ - if(is_first_invocation && H5_debug_g.ttimes) { + if (is_first_invocation && H5_debug_g.ttimes) { /* start the library-wide timer */ is_first_invocation = FALSE; H5_timer_init(&running_timer); H5_timer_start(&running_timer); } /* end if */ - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { /* start the timer for this function */ H5_timer_init(&function_timer); H5_timer_start(&function_timer); @@ -174,12 +168,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * function return and no other calls have been made to H5_trace() * since the one for the function call, then we're continuing * the same line. */ - if(returning) { + if (returning) { HDassert(current_depth > 0); --current_depth; - if(current_depth < last_call_depth) { + if (current_depth < last_call_depth) { /* We are at the beginning of a line */ - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { char tmp[320]; H5_timer_get_times(function_timer, &function_times); @@ -187,47 +181,48 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDsprintf(tmp, "%.6f", (function_times.elapsed - running_times.elapsed)); HDfprintf(out, " %*s ", (int)HDstrlen(tmp), ""); } /* end if */ - for(i = 0; i < current_depth; i++) + for (i = 0; i < current_depth; i++) HDfputc('+', out); - HDfprintf(out, "%*s%s = ", 2*current_depth, "", func); + HDfprintf(out, "%*s%s = ", 2 * current_depth, "", func); } /* end if */ else { /* Continue current line with return value */ HDfprintf(out, " = "); } /* end else */ - } /* end if */ + } /* end if */ else { - if(current_depth>last_call_depth) + if (current_depth > last_call_depth) HDfputs(" = \n", out); - if(H5_debug_g.ttimes) { + if (H5_debug_g.ttimes) { H5_timer_get_times(function_timer, &function_times); H5_timer_get_times(running_timer, &running_times); HDfprintf(out, "@%.6f ", (function_times.elapsed - running_times.elapsed)); } /* end if */ - for(i = 0; i < current_depth; i++) + for (i = 0; i < current_depth; i++) HDfputc('+', out); - HDfprintf(out, "%*s%s(", 2*current_depth, "", func); + HDfprintf(out, "%*s%s(", 2 * current_depth, "", func); } /* end else */ /* Clear array sizes */ - for(i = 0; i < (hssize_t)NELMTS(asize); i++) + for (i = 0; i < (hssize_t)NELMTS(asize); i++) asize[i] = -1; /* Parse the argument types */ - for(argno = 0; *type; argno++, type += (HDisupper(*type) ? 2 : 1)) { + for (argno = 0; *type; argno++, type += (HDisupper(*type) ? 2 : 1)) { /* Count levels of indirection */ - for(ptr = 0; '*' == *type; type++) + for (ptr = 0; '*' == *type; type++) ptr++; - if('[' == *type) { - if('a' == type[1]) { + if ('[' == *type) { + if ('a' == type[1]) { asize_idx = (int)HDstrtol(type + 2, &rest, 10); - HDassert(0 <= asize_idx && asize_idx < (int) NELMTS(asize)); - HDassert(']'==*rest); + HDassert(0 <= asize_idx && asize_idx < (int)NELMTS(asize)); + HDassert(']' == *rest); type = rest + 1; - } else { + } + else { rest = (char *)HDstrchr(type, ']'); HDassert(rest); - type = rest + 1; + type = rest + 1; asize_idx = -1; } } /* end if */ @@ -240,26 +235,26 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * following `='. This is used for return values. */ argname = HDva_arg(ap, char *); - if(argname) { - unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname) - 3); + if (argname) { + unsigned n = (unsigned)MAX(0, (int)HDstrlen(argname) - 3); - if(!HDstrcmp(argname + n, "_id")) { + if (!HDstrcmp(argname + n, "_id")) { HDstrncpy(buf, argname, (size_t)MIN((int)sizeof(buf) - 1, n)); buf[MIN((int)sizeof(buf) - 1, n)] = '\0'; - argname = buf; + argname = buf; } /* end if */ - HDfprintf(out, "%s%s=", argno?", ":"", argname); + HDfprintf(out, "%s%s=", argno ? ", " : "", argname); } /* end if */ else argname = ""; /* The value */ - if(ptr) + if (ptr) vp = HDva_arg(ap, void *); - switch(type[0]) { + switch (type[0]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -267,23 +262,23 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { haddr_t addr = HDva_arg(ap, haddr_t); - HDfprintf(out, "%a", addr); + HDfprintf(out, "%" PRIuHADDR, addr); } /* end else */ break; case 'b': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); - } /* end if */ + } /* end if */ else { /* Can't pass hbool_t to HDva_arg() */ hbool_t bool_var = (hbool_t)HDva_arg(ap, int); - if(TRUE == bool_var) + if (TRUE == bool_var) HDfprintf(out, "TRUE"); - else if(!bool_var) + else if (!bool_var) HDfprintf(out, "FALSE"); else HDfprintf(out, "TRUE(%u)", (unsigned)bool_var); @@ -291,8 +286,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -305,10 +300,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'D': - switch(type[1]) { + switch (type[1]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -316,7 +311,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)HDva_arg(ap, int); - switch(alloc_time) { + switch (alloc_time) { case H5D_ALLOC_TIME_ERROR: HDfprintf(out, "H5D_ALLOC_TIME_ERROR"); break; @@ -341,691 +336,731 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)alloc_time); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)HDva_arg(ap, int); - switch(opt) { + switch (opt) { case H5FD_MPIO_COLLECTIVE_IO: - HDfprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE_IO"); break; case H5FD_MPIO_INDIVIDUAL_IO: - HDfprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); + HDfprintf(out, "H5FD_MPIO_INDIVIDUAL_IO"); break; default: - HDfprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'f': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_time_t fill_time = (H5D_fill_time_t)HDva_arg(ap, int); - switch(fill_time) { + switch (fill_time) { case H5D_FILL_TIME_ERROR: - HDfprintf(out, "H5D_FILL_TIME_ERROR"); + HDfprintf(out, "H5D_FILL_TIME_ERROR"); break; case H5D_FILL_TIME_ALLOC: - HDfprintf(out, "H5D_FILL_TIME_ALLOC"); + HDfprintf(out, "H5D_FILL_TIME_ALLOC"); break; case H5D_FILL_TIME_NEVER: - HDfprintf(out, "H5D_FILL_TIME_NEVER"); + HDfprintf(out, "H5D_FILL_TIME_NEVER"); break; case H5D_FILL_TIME_IFSET: - HDfprintf(out, "H5D_FILL_TIME_IFSET"); + HDfprintf(out, "H5D_FILL_TIME_IFSET"); break; default: - HDfprintf(out, "%ld", (long)fill_time); + HDfprintf(out, "%ld", (long)fill_time); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'F': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_fill_value_t fill_value = (H5D_fill_value_t)HDva_arg(ap, int); - switch(fill_value) { + switch (fill_value) { case H5D_FILL_VALUE_ERROR: - HDfprintf(out, "H5D_FILL_VALUE_ERROR"); + HDfprintf(out, "H5D_FILL_VALUE_ERROR"); break; case H5D_FILL_VALUE_UNDEFINED: - HDfprintf(out, "H5D_FILL_VALUE_UNDEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_UNDEFINED"); break; case H5D_FILL_VALUE_DEFAULT: - HDfprintf(out, "H5D_FILL_VALUE_DEFAULT"); + HDfprintf(out, "H5D_FILL_VALUE_DEFAULT"); break; case H5D_FILL_VALUE_USER_DEFINED: - HDfprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); + HDfprintf(out, "H5D_FILL_VALUE_USER_DEFINED"); break; default: - HDfprintf(out, "%ld", (long)fill_value); + HDfprintf(out, "%ld", (long)fill_value); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'h': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)HDva_arg(ap, int); - switch(opt) { + switch (opt) { case H5FD_MPIO_CHUNK_DEFAULT: - HDfprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); + HDfprintf(out, "H5FD_MPIO_CHUNK_DEFAULT"); break; case H5FD_MPIO_CHUNK_ONE_IO: - HDfprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_ONE_IO"); break; case H5FD_MPIO_CHUNK_MULTI_IO: - HDfprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); + HDfprintf(out, "H5FD_MPIO_CHUNK_MULTI_IO"); break; default: - HDfprintf(out, "%ld", (long)opt); + HDfprintf(out, "%ld", (long)opt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'i': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); + H5D_mpio_actual_io_mode_t actual_io_mode = + (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); - switch(actual_io_mode) { + switch (actual_io_mode) { case H5D_MPIO_NO_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_NO_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_NO_COLLECTIVE"); break; case H5D_MPIO_CHUNK_INDEPENDENT: - HDfprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); + HDfprintf(out, "H5D_MPIO_CHUNK_INDEPENDENT"); break; case H5D_MPIO_CHUNK_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CHUNK_COLLECTIVE"); break; case H5D_MPIO_CHUNK_MIXED: - HDfprintf(out, "H5D_MPIO_CHUNK_MIXED"); + HDfprintf(out, "H5D_MPIO_CHUNK_MIXED"); break; case H5D_MPIO_CONTIGUOUS_COLLECTIVE: - HDfprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); + HDfprintf(out, "H5D_MPIO_CONTIGUOUS_COLLECTIVE"); break; default: - HDfprintf(out, "%ld", (long)actual_io_mode); + HDfprintf(out, "%ld", (long)actual_io_mode); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'k': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_chunk_index_t idx = (H5D_chunk_index_t)HDva_arg(ap, int); - switch(idx) { + switch (idx) { case H5D_CHUNK_IDX_BTREE: - HDfprintf(out, "H5D_CHUNK_IDX_BTREE"); + HDfprintf(out, "H5D_CHUNK_IDX_BTREE"); break; case H5D_CHUNK_IDX_NONE: - HDfprintf(out, "H5D_CHUNK_IDX_NONE"); + HDfprintf(out, "H5D_CHUNK_IDX_NONE"); break; case H5D_CHUNK_IDX_FARRAY: - HDfprintf(out, "H5D_CHUNK_IDX_FARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_FARRAY"); break; case H5D_CHUNK_IDX_EARRAY: - HDfprintf(out, "H5D_CHUNK_IDX_EARRAY"); + HDfprintf(out, "H5D_CHUNK_IDX_EARRAY"); break; case H5D_CHUNK_IDX_BT2: - HDfprintf(out, "H5D_CHUNK_IDX_BT2"); + HDfprintf(out, "H5D_CHUNK_IDX_BT2"); break; case H5D_CHUNK_IDX_SINGLE: - HDfprintf(out, "H5D_CHUNK_IDX_SINGLE"); + HDfprintf(out, "H5D_CHUNK_IDX_SINGLE"); break; case H5D_CHUNK_IDX_NTYPES: - HDfprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); + HDfprintf(out, "ERROR: H5D_CHUNK_IDX_NTYPES (invalid value)"); break; default: - HDfprintf(out, "UNKNOWN VALUE: %ld", (long)idx); + HDfprintf(out, "UNKNOWN VALUE: %ld", (long)idx); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'l': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_layout_t layout = (H5D_layout_t)HDva_arg(ap, int); - switch(layout) { + switch (layout) { case H5D_LAYOUT_ERROR: - HDfprintf(out, "H5D_LAYOUT_ERROR"); + HDfprintf(out, "H5D_LAYOUT_ERROR"); break; case H5D_COMPACT: - HDfprintf(out, "H5D_COMPACT"); + HDfprintf(out, "H5D_COMPACT"); break; case H5D_CONTIGUOUS: - HDfprintf(out, "H5D_CONTIGUOUS"); + HDfprintf(out, "H5D_CONTIGUOUS"); break; case H5D_CHUNKED: - HDfprintf(out, "H5D_CHUNKED"); + HDfprintf(out, "H5D_CHUNKED"); break; case H5D_VIRTUAL: - HDfprintf(out, "H5D_VIRTUAL"); + HDfprintf(out, "H5D_VIRTUAL"); break; case H5D_NLAYOUTS: - HDfprintf(out, "H5D_NLAYOUTS"); + HDfprintf(out, "H5D_NLAYOUTS"); break; default: - HDfprintf(out, "%ld", (long)layout); + HDfprintf(out, "%ld", (long)layout); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'n': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); + H5D_mpio_no_collective_cause_t nocol_cause_mode = + (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); hbool_t flag_already_displayed = FALSE; /* Check for all bit-flags which might be set */ - if(nocol_cause_mode & H5D_MPIO_COLLECTIVE) { - HDfprintf(out, "H5D_MPIO_COLLECTIVE"); + if (nocol_cause_mode & H5D_MPIO_COLLECTIVE) { + HDfprintf(out, "H5D_MPIO_COLLECTIVE"); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_SET_INDEPENDENT) { - HDfprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_SET_INDEPENDENT) { + HDfprintf(out, "%sH5D_MPIO_SET_INDEPENDENT", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_DATATYPE_CONVERSION) { - HDfprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_DATATYPE_CONVERSION) { + HDfprintf(out, "%sH5D_MPIO_DATATYPE_CONVERSION", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_DATA_TRANSFORMS) { - HDfprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_DATA_TRANSFORMS) { + HDfprintf(out, "%sH5D_MPIO_DATA_TRANSFORMS", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED) { - HDfprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED) { + HDfprintf(out, "%sH5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES) { - HDfprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES) { + HDfprintf(out, "%sH5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ - if(nocol_cause_mode & H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET) { - HDfprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", flag_already_displayed ? " | " : ""); + if (nocol_cause_mode & H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET) { + HDfprintf(out, "%sH5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET", + flag_already_displayed ? " | " : ""); flag_already_displayed = TRUE; } /* end if */ /* Display '' if there's no flags set */ - if(!flag_already_displayed) - HDfprintf(out, ""); + if (!flag_already_displayed) + HDfprintf(out, ""); } /* end else */ break; case 'o': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); + H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = + (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); - switch(chunk_opt_mode) { + switch (chunk_opt_mode) { case H5D_MPIO_NO_CHUNK_OPTIMIZATION: - HDfprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); + HDfprintf(out, "H5D_MPIO_NO_CHUNK_OPTIMIZATION"); break; case H5D_MPIO_LINK_CHUNK: - HDfprintf(out, "H5D_MPIO_LINK_CHUNK"); + HDfprintf(out, "H5D_MPIO_LINK_CHUNK"); break; case H5D_MPIO_MULTI_CHUNK: - HDfprintf(out, "H5D_MPIO_MULTI_CHUNK"); + HDfprintf(out, "H5D_MPIO_MULTI_CHUNK"); break; default: - HDfprintf(out, "%ld", (long)chunk_opt_mode); + HDfprintf(out, "%ld", (long)chunk_opt_mode); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_space_status_t space_status = (H5D_space_status_t)HDva_arg(ap, int); - switch(space_status) { + switch (space_status) { case H5D_SPACE_STATUS_NOT_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_NOT_ALLOCATED"); break; case H5D_SPACE_STATUS_PART_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_PART_ALLOCATED"); break; case H5D_SPACE_STATUS_ALLOCATED: - HDfprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); + HDfprintf(out, "H5D_SPACE_STATUS_ALLOCATED"); break; case H5D_SPACE_STATUS_ERROR: - HDfprintf(out, "H5D_SPACE_STATUS_ERROR"); + HDfprintf(out, "H5D_SPACE_STATUS_ERROR"); break; default: - HDfprintf(out, "%ld", (long)space_status); + HDfprintf(out, "%ld", (long)space_status); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)HDva_arg(ap, int); - switch(transfer) { + switch (transfer) { case H5FD_MPIO_INDEPENDENT: - HDfprintf(out, "H5FD_MPIO_INDEPENDENT"); + HDfprintf(out, "H5FD_MPIO_INDEPENDENT"); break; case H5FD_MPIO_COLLECTIVE: - HDfprintf(out, "H5FD_MPIO_COLLECTIVE"); + HDfprintf(out, "H5FD_MPIO_COLLECTIVE"); break; default: - HDfprintf(out, "%ld", (long)transfer); + HDfprintf(out, "%ld", (long)transfer); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'v': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5D_vds_view_t view = (H5D_vds_view_t)HDva_arg(ap, int); - switch(view) { + switch (view) { case H5D_VDS_ERROR: - HDfprintf(out, "H5D_VDS_ERROR"); + HDfprintf(out, "H5D_VDS_ERROR"); break; case H5D_VDS_FIRST_MISSING: - HDfprintf(out, "H5D_VDS_FIRST_MISSING"); + HDfprintf(out, "H5D_VDS_FIRST_MISSING"); break; case H5D_VDS_LAST_AVAILABLE: - HDfprintf(out, "H5D_VDS_LAST_AVAILABLE"); + HDfprintf(out, "H5D_VDS_LAST_AVAILABLE"); break; default: - HDfprintf(out, "%ld", (long)view); + HDfprintf(out, "%ld", (long)view); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: - HDfprintf(out, "BADTYPE(D%c)", type[1]); + HDfprintf(out, "BADTYPE(D%c)", type[1]); goto error; } /* end switch */ break; case 'e': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { herr_t status = HDva_arg(ap, herr_t); - if(status >= 0) - HDfprintf(out, "SUCCEED"); + if (status >= 0) + HDfprintf(out, "SUCCEED"); else - HDfprintf(out, "FAIL"); + HDfprintf(out, "FAIL"); } /* end else */ break; case 'E': - switch(type[1]) { + switch (type[1]) { case 'd': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_direction_t direction = (H5E_direction_t)HDva_arg(ap, int); - switch(direction) { + switch (direction) { case H5E_WALK_UPWARD: - HDfprintf(out, "H5E_WALK_UPWARD"); + HDfprintf(out, "H5E_WALK_UPWARD"); break; case H5E_WALK_DOWNWARD: - HDfprintf(out, "H5E_WALK_DOWNWARD"); + HDfprintf(out, "H5E_WALK_DOWNWARD"); break; default: - HDfprintf(out, "%ld", (long)direction); + HDfprintf(out, "%ld", (long)direction); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'e': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); - HDfprintf(out, "0x%p", error); + HDfprintf(out, "0x%p", (void *)error); } /* end else */ break; + case 's': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5ES_status_t status = (H5ES_status_t)HDva_arg(ap, int); + + switch (status) { + case H5ES_STATUS_IN_PROGRESS: + HDfprintf(out, "H5ES_STATUS_IN_PROGRESS"); + break; + case H5ES_STATUS_SUCCEED: + HDfprintf(out, "H5ES_STATUS_SUCCEED"); + break; + case H5ES_STATUS_FAIL: + HDfprintf(out, "H5ES_STATUS_FAIL"); + break; + case H5ES_STATUS_CANCELED: + HDfprintf(out, "H5ES_STATUS_CANCELED"); + break; + + default: + HDfprintf(out, "%ld", (long)status); + break; + } /* end switch */ + } /* end else */ + break; + case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5E_type_t etype = (H5E_type_t)HDva_arg(ap, int); - switch(etype) { + switch (etype) { case H5E_MAJOR: - HDfprintf(out, "H5E_MAJOR"); + HDfprintf(out, "H5E_MAJOR"); break; case H5E_MINOR: - HDfprintf(out, "H5E_MINOR"); + HDfprintf(out, "H5E_MINOR"); break; default: - HDfprintf(out, "%ld", (long)etype); + HDfprintf(out, "%ld", (long)etype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: - HDfprintf(out, "BADTYPE(E%c)", type[1]); + HDfprintf(out, "BADTYPE(E%c)", type[1]); goto error; } /* end switch */ break; case 'F': - switch(type[1]) { + switch (type[1]) { case 'd': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_close_degree_t degree = (H5F_close_degree_t)HDva_arg(ap, int); - switch(degree) { + switch (degree) { case H5F_CLOSE_DEFAULT: - HDfprintf(out, "H5F_CLOSE_DEFAULT"); + HDfprintf(out, "H5F_CLOSE_DEFAULT"); break; case H5F_CLOSE_WEAK: - HDfprintf(out, "H5F_CLOSE_WEAK"); + HDfprintf(out, "H5F_CLOSE_WEAK"); break; case H5F_CLOSE_SEMI: - HDfprintf(out, "H5F_CLOSE_SEMI"); + HDfprintf(out, "H5F_CLOSE_SEMI"); break; case H5F_CLOSE_STRONG: - HDfprintf(out, "H5F_CLOSE_STRONG"); + HDfprintf(out, "H5F_CLOSE_STRONG"); break; default: - HDfprintf(out, "%ld", (long)degree); + HDfprintf(out, "%ld", (long)degree); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'f': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)HDva_arg(ap, int); - switch(fs_strategy) { + switch (fs_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: - HDfprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_FSM_AGGR"); break; case H5F_FSPACE_STRATEGY_PAGE: - HDfprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_PAGE"); break; case H5F_FSPACE_STRATEGY_AGGR: - HDfprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_AGGR"); break; case H5F_FSPACE_STRATEGY_NONE: - HDfprintf(out, "H5F_FSPACE_STRATEGY_NONE"); + HDfprintf(out, "H5F_FSPACE_STRATEGY_NONE"); break; case H5F_FSPACE_STRATEGY_NTYPES: default: - HDfprintf(out, "%ld", (long)fs_strategy); + HDfprintf(out, "%ld", (long)fs_strategy); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'm': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_mem_t mem_type = (H5F_mem_t)HDva_arg(ap, int); - switch(mem_type) { + switch (mem_type) { case H5FD_MEM_NOLIST: - HDfprintf(out, "H5FD_MEM_NOLIST"); + HDfprintf(out, "H5FD_MEM_NOLIST"); break; case H5FD_MEM_DEFAULT: - HDfprintf(out, "H5FD_MEM_DEFAULT"); + HDfprintf(out, "H5FD_MEM_DEFAULT"); break; case H5FD_MEM_SUPER: - HDfprintf(out, "H5FD_MEM_SUPER"); + HDfprintf(out, "H5FD_MEM_SUPER"); break; case H5FD_MEM_BTREE: - HDfprintf(out, "H5FD_MEM_BTREE"); + HDfprintf(out, "H5FD_MEM_BTREE"); break; case H5FD_MEM_DRAW: - HDfprintf(out, "H5FD_MEM_DRAW"); + HDfprintf(out, "H5FD_MEM_DRAW"); break; case H5FD_MEM_GHEAP: - HDfprintf(out, "H5FD_MEM_GHEAP"); + HDfprintf(out, "H5FD_MEM_GHEAP"); break; case H5FD_MEM_LHEAP: - HDfprintf(out, "H5FD_MEM_LHEAP"); + HDfprintf(out, "H5FD_MEM_LHEAP"); break; case H5FD_MEM_OHDR: - HDfprintf(out, "H5FD_MEM_OHDR"); + HDfprintf(out, "H5FD_MEM_OHDR"); break; case H5FD_MEM_NTYPES: default: - HDfprintf(out, "%ld", (long)mem_type); + HDfprintf(out, "%ld", (long)mem_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_scope_t scope = (H5F_scope_t)HDva_arg(ap, int); - switch(scope) { + switch (scope) { case H5F_SCOPE_LOCAL: - HDfprintf(out, "H5F_SCOPE_LOCAL"); + HDfprintf(out, "H5F_SCOPE_LOCAL"); break; case H5F_SCOPE_GLOBAL: - HDfprintf(out, "H5F_SCOPE_GLOBAL"); + HDfprintf(out, "H5F_SCOPE_GLOBAL"); break; default: - HDfprintf(out, "%ld", (long)scope); + HDfprintf(out, "%ld", (long)scope); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ break; case 'v': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); else - HDfprintf(out, "NULL"); + HDfprintf(out, "NULL"); } /* end if */ else { H5F_libver_t libver_vers = (H5F_libver_t)HDva_arg(ap, int); - switch(libver_vers) { + switch (libver_vers) { case H5F_LIBVER_EARLIEST: HDfprintf(out, "H5F_LIBVER_EARLIEST"); break; @@ -1035,7 +1070,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case H5F_LIBVER_V110: - HDcompile_assert(H5F_LIBVER_LATEST == H5F_LIBVER_V110); + HDfprintf(out, "H5F_LIBVER_V110"); + break; + + case H5F_LIBVER_V112: + HDcompile_assert(H5F_LIBVER_LATEST == H5F_LIBVER_V112); HDfprintf(out, "H5F_LIBVER_LATEST"); break; @@ -1045,7 +1084,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)libver_vers); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1055,11 +1094,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'G': - switch(type[1]) { + switch (type[1]) { #ifndef H5_NO_DEPRECATED_SYMBOLS case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1067,7 +1106,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5G_obj_t obj_type = (H5G_obj_t)HDva_arg(ap, int); - switch(obj_type) { + switch (obj_type) { case H5G_UNKNOWN: HDfprintf(out, "H5G_UNKNOWN"); break; @@ -1102,20 +1141,20 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)obj_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); + H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t *); - HDfprintf(out, "0x%p", statbuf); + HDfprintf(out, "0x%p", (void *)statbuf); } break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1127,59 +1166,59 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'h': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) { - if(H5S_UNLIMITED == p[i]) + for (i = 0; i < asize[asize_idx]; i++) { + if (H5S_UNLIMITED == p[i]) HDfprintf(out, "%sH5S_UNLIMITED", (i ? ", " : "")); else - HDfprintf(out, "%s%Hu", (i ? ", " : ""), p[i]); + HDfprintf(out, "%s%" PRIuHSIZE, (i ? ", " : ""), p[i]); } /* end for */ HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ else { hsize_t hsize = HDva_arg(ap, hsize_t); - if(H5S_UNLIMITED == hsize) + if (H5S_UNLIMITED == hsize) HDfprintf(out, "H5S_UNLIMITED"); else { - HDfprintf(out, "%Hu", hsize); + HDfprintf(out, "%" PRIuHSIZE, hsize); asize[argno] = (hssize_t)hsize; } /* end else */ - } /* end else */ + } /* end else */ break; case 'H': - switch(type[1]) { + switch (type[1]) { case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%Hd", (i ? ", " : ""), p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%" PRIdHSIZE, (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ else { hssize_t hssize = HDva_arg(ap, hssize_t); - HDfprintf(out, "%Hd", hssize); + HDfprintf(out, "%" PRIdHSIZE, hssize); asize[argno] = (hssize_t)hssize; } /* end else */ break; @@ -1191,8 +1230,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1200,12 +1239,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { hid_t obj = HDva_arg(ap, hid_t); - if(H5P_DEFAULT == obj) + if (H5P_DEFAULT == obj) HDfprintf(out, "H5P_DEFAULT"); - else if(obj < 0) + else if (obj < 0) HDfprintf(out, "FAIL"); else { - switch(H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ + switch (H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ case H5I_UNINIT: HDfprintf(out, "%ld (uninit - error)", (long)obj); break; @@ -1223,93 +1262,93 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case H5I_DATATYPE: - if(obj == H5T_NATIVE_SCHAR_g) + if (obj == H5T_NATIVE_SCHAR_g) HDfprintf(out, "H5T_NATIVE_SCHAR"); - else if(obj == H5T_NATIVE_UCHAR_g) + else if (obj == H5T_NATIVE_UCHAR_g) HDfprintf(out, "H5T_NATIVE_UCHAR"); - else if(obj == H5T_NATIVE_SHORT_g) + else if (obj == H5T_NATIVE_SHORT_g) HDfprintf(out, "H5T_NATIVE_SHORT"); - else if(obj == H5T_NATIVE_USHORT_g) + else if (obj == H5T_NATIVE_USHORT_g) HDfprintf(out, "H5T_NATIVE_USHORT"); - else if(obj == H5T_NATIVE_INT_g) + else if (obj == H5T_NATIVE_INT_g) HDfprintf(out, "H5T_NATIVE_INT"); - else if(obj == H5T_NATIVE_UINT_g) + else if (obj == H5T_NATIVE_UINT_g) HDfprintf(out, "H5T_NATIVE_UINT"); - else if(obj == H5T_NATIVE_LONG_g) + else if (obj == H5T_NATIVE_LONG_g) HDfprintf(out, "H5T_NATIVE_LONG"); - else if(obj == H5T_NATIVE_ULONG_g) + else if (obj == H5T_NATIVE_ULONG_g) HDfprintf(out, "H5T_NATIVE_ULONG"); - else if(obj == H5T_NATIVE_LLONG_g) + else if (obj == H5T_NATIVE_LLONG_g) HDfprintf(out, "H5T_NATIVE_LLONG"); - else if(obj == H5T_NATIVE_ULLONG_g) + else if (obj == H5T_NATIVE_ULLONG_g) HDfprintf(out, "H5T_NATIVE_ULLONG"); - else if(obj == H5T_NATIVE_FLOAT_g) + else if (obj == H5T_NATIVE_FLOAT_g) HDfprintf(out, "H5T_NATIVE_FLOAT"); - else if(obj == H5T_NATIVE_DOUBLE_g) + else if (obj == H5T_NATIVE_DOUBLE_g) HDfprintf(out, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if(obj == H5T_NATIVE_LDOUBLE_g) +#if H5_SIZEOF_LONG_DOUBLE != 0 + else if (obj == H5T_NATIVE_LDOUBLE_g) HDfprintf(out, "H5T_NATIVE_LDOUBLE"); #endif - else if(obj == H5T_IEEE_F32BE_g) + else if (obj == H5T_IEEE_F32BE_g) HDfprintf(out, "H5T_IEEE_F32BE"); - else if(obj == H5T_IEEE_F32LE_g) + else if (obj == H5T_IEEE_F32LE_g) HDfprintf(out, "H5T_IEEE_F32LE"); - else if(obj == H5T_IEEE_F64BE_g) + else if (obj == H5T_IEEE_F64BE_g) HDfprintf(out, "H5T_IEEE_F64BE"); - else if(obj == H5T_IEEE_F64LE_g) + else if (obj == H5T_IEEE_F64LE_g) HDfprintf(out, "H5T_IEEE_F64LE"); - else if(obj == H5T_STD_I8BE_g) + else if (obj == H5T_STD_I8BE_g) HDfprintf(out, "H5T_STD_I8BE"); - else if(obj == H5T_STD_I8LE_g) + else if (obj == H5T_STD_I8LE_g) HDfprintf(out, "H5T_STD_I8LE"); - else if(obj == H5T_STD_I16BE_g) + else if (obj == H5T_STD_I16BE_g) HDfprintf(out, "H5T_STD_I16BE"); - else if(obj == H5T_STD_I16LE_g) + else if (obj == H5T_STD_I16LE_g) HDfprintf(out, "H5T_STD_I16LE"); - else if(obj == H5T_STD_I32BE_g) + else if (obj == H5T_STD_I32BE_g) HDfprintf(out, "H5T_STD_I32BE"); - else if(obj == H5T_STD_I32LE_g) + else if (obj == H5T_STD_I32LE_g) HDfprintf(out, "H5T_STD_I32LE"); - else if(obj == H5T_STD_I64BE_g) + else if (obj == H5T_STD_I64BE_g) HDfprintf(out, "H5T_STD_I64BE"); - else if(obj == H5T_STD_I64LE_g) + else if (obj == H5T_STD_I64LE_g) HDfprintf(out, "H5T_STD_I64LE"); - else if(obj == H5T_STD_U8BE_g) + else if (obj == H5T_STD_U8BE_g) HDfprintf(out, "H5T_STD_U8BE"); - else if(obj == H5T_STD_U8LE_g) + else if (obj == H5T_STD_U8LE_g) HDfprintf(out, "H5T_STD_U8LE"); - else if(obj == H5T_STD_U16BE_g) + else if (obj == H5T_STD_U16BE_g) HDfprintf(out, "H5T_STD_U16BE"); - else if(obj == H5T_STD_U16LE_g) + else if (obj == H5T_STD_U16LE_g) HDfprintf(out, "H5T_STD_U16LE"); - else if(obj == H5T_STD_U32BE_g) + else if (obj == H5T_STD_U32BE_g) HDfprintf(out, "H5T_STD_U32BE"); - else if(obj == H5T_STD_U32LE_g) + else if (obj == H5T_STD_U32LE_g) HDfprintf(out, "H5T_STD_U32LE"); - else if(obj == H5T_STD_U64BE_g) + else if (obj == H5T_STD_U64BE_g) HDfprintf(out, "H5T_STD_U64BE"); - else if(obj == H5T_STD_U64LE_g) + else if (obj == H5T_STD_U64LE_g) HDfprintf(out, "H5T_STD_U64LE"); - else if(obj == H5T_STD_B8BE_g) + else if (obj == H5T_STD_B8BE_g) HDfprintf(out, "H5T_STD_B8BE"); - else if(obj == H5T_STD_B8LE_g) + else if (obj == H5T_STD_B8LE_g) HDfprintf(out, "H5T_STD_B8LE"); - else if(obj == H5T_STD_B16BE_g) + else if (obj == H5T_STD_B16BE_g) HDfprintf(out, "H5T_STD_B16BE"); - else if(obj == H5T_STD_B16LE_g) + else if (obj == H5T_STD_B16LE_g) HDfprintf(out, "H5T_STD_B16LE"); - else if(obj == H5T_STD_B32BE_g) + else if (obj == H5T_STD_B32BE_g) HDfprintf(out, "H5T_STD_B32BE"); - else if(obj == H5T_STD_B32LE_g) + else if (obj == H5T_STD_B32LE_g) HDfprintf(out, "H5T_STD_B32LE"); - else if(obj == H5T_STD_B64BE_g) + else if (obj == H5T_STD_B64BE_g) HDfprintf(out, "H5T_STD_B64BE"); - else if(obj == H5T_STD_B64LE_g) + else if (obj == H5T_STD_B64LE_g) HDfprintf(out, "H5T_STD_B64LE"); - else if(obj == H5T_C_S1_g) + else if (obj == H5T_C_S1_g) HDfprintf(out, "H5T_C_S1"); - else if(obj == H5T_FORTRAN_S1_g) + else if (obj == H5T_FORTRAN_S1_g) HDfprintf(out, "H5T_FORTRAN_S1"); else HDfprintf(out, "%ld (dtype)", (long)obj); @@ -1322,8 +1361,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) { H5S_t *space; - if(NULL != (space = (H5S_t *)H5I_object(obj))) - if(H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)) + if (NULL != (space = (H5S_t *)H5I_object(obj))) + if (H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)) asize[argno] = H5S_GET_EXTENT_NDIMS(space); } break; @@ -1336,14 +1375,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (attr)", (long)obj); break; - case H5I_REFERENCE: - HDfprintf(out, "%ld (reference)", (long)obj); + case H5I_MAP: + HDfprintf(out, "%ld (map)", (long)obj); break; case H5I_VFL: HDfprintf(out, "%ld (file driver)", (long)obj); break; + case H5I_VOL: + HDfprintf(out, "%ld (VOL plugin)", (long)obj); + break; + case H5I_GENPROP_CLS: HDfprintf(out, "%ld (genprop class)", (long)obj); break; @@ -1364,6 +1407,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (err stack)", (long)obj); break; + case H5I_SPACE_SEL_ITER: + HDfprintf(out, "%ld (dataspace selection iterator)", (long)obj); + break; + case H5I_NTYPES: HDfprintf(out, "%ld (ntypes - error)", (long)obj); break; @@ -1372,15 +1419,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (unknown class)", (long)obj); break; } /* end switch */ - } /* end else */ - } /* end else */ + } /* end else */ + } /* end else */ break; case 'I': switch (type[1]) { case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1388,7 +1435,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5_index_t idx_type = (H5_index_t)HDva_arg(ap, int); - switch(idx_type) { + switch (idx_type) { case H5_INDEX_UNKNOWN: HDfprintf(out, "H5_INDEX_UNKNOWN"); break; @@ -1409,12 +1456,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)idx_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1422,7 +1469,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5_iter_order_t order = (H5_iter_order_t)HDva_arg(ap, int); - switch(order) { + switch (order) { case H5_ITER_UNKNOWN: HDfprintf(out, "H5_ITER_UNKNOWN"); break; @@ -1447,22 +1494,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)order); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - int *p = (int*)vp; + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + int *p = (int *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) + for (i = 0; i < asize[asize_idx]; i++) HDfprintf(out, "%s%d", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -1475,8 +1522,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1517,14 +1564,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_ATTR"); break; - case H5I_REFERENCE: - HDfprintf(out, "H5I_REFERENCE"); + case H5I_MAP: + HDfprintf(out, "H5I_MAP"); break; case H5I_VFL: HDfprintf(out, "H5I_VFL"); break; + case H5I_VOL: + HDfprintf(out, "H5I_VOL"); + break; + case H5I_GENPROP_CLS: HDfprintf(out, "H5I_GENPROP_CLS"); break; @@ -1545,6 +1596,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_ERROR_STACK"); break; + case H5I_SPACE_SEL_ITER: + HDfprintf(out, "H5I_SPACE_SEL_ITER"); + break; + case H5I_NTYPES: HDfprintf(out, "H5I_NTYPES"); break; @@ -1553,22 +1608,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)id_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'u': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - unsigned *p = (unsigned*)vp; + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + unsigned *p = (unsigned *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%u", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%u", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -1586,11 +1641,27 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ break; + case 'k': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5O_token_t token = HDva_arg(ap, H5O_token_t); + int j; + + for (j = 0; j < H5O_MAX_TOKEN_SIZE; j++) + HDfprintf(out, "%02x", token.__data[j]); + } /* end else */ + break; + case 'L': - switch(type[1]) { + switch (type[1]) { case 'l': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1598,7 +1669,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5L_type_t link_type = (H5L_type_t)HDva_arg(ap, int); - switch(link_type) { + switch (link_type) { case H5L_TYPE_ERROR: HDfprintf(out, "H5L_TYPE_ERROR"); break; @@ -1623,7 +1694,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)link_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1633,10 +1704,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'M': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1647,12 +1718,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)comm); } /* end else */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ break; case 'i': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1663,12 +1734,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)info); } /* end else */ -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1676,7 +1747,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5FD_mem_t mt = (H5FD_mem_t)HDva_arg(ap, int); - switch(mt) { + switch (mt) { case H5FD_MEM_NOLIST: HDfprintf(out, "H5FD_MEM_NOLIST"); break; @@ -1717,7 +1788,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)mt); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1726,8 +1797,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1740,10 +1811,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'O': - switch(type[1]) { + switch (type[1]) { case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1751,7 +1822,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5O_type_t objtype = (H5O_type_t)HDva_arg(ap, int); - switch(objtype) { + switch (objtype) { case H5O_TYPE_UNKNOWN: HDfprintf(out, "H5O_TYPE_UNKNOWN"); break; @@ -1768,6 +1839,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5O_TYPE_NAMED_DATATYPE"); break; + case H5O_TYPE_MAP: + HDfprintf(out, "H5O_TYPE_MAP"); + break; + case H5O_TYPE_NTYPES: HDfprintf(out, "H5O_TYPE_NTYPES"); break; @@ -1776,7 +1851,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "BADTYPE(%ld)", (long)objtype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1786,21 +1861,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'p': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - hid_t pclass_id = HDva_arg(ap, hid_t); - char *class_name = NULL; + hid_t pclass_id = HDva_arg(ap, hid_t); + char * class_name = NULL; H5P_genclass_t *pclass; /* Get the class name and print it */ /* (This may generate recursive call to the library... -QAK) */ - if(NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) && - NULL != (class_name = H5P_get_class_name(pclass))) { + if (NULL != (pclass = (H5P_genclass_t *)H5I_object(pclass_id)) && + NULL != (class_name = H5P_get_class_name(pclass))) { HDfprintf(out, "%s", class_name); H5MM_xfree(class_name); } /* end if */ @@ -1809,25 +1884,54 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ break; - case 'r': - if(ptr) { - if(vp) - HDfprintf(out, "0x%p", vp); - else - HDfprintf(out, "NULL"); - } /* end if */ - else { - hobj_ref_t ref = HDva_arg(ap, hobj_ref_t); + case 'R': + switch (type[1]) { - HDfprintf(out, "Reference Object=%a", ref); - } /* end else */ - break; + case 'o': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + hobj_ref_t ref = HDva_arg(ap, hobj_ref_t); + + HDfprintf(out, "Reference Object=%" PRIuHADDR, ref); + } /* end else */ + break; + + case 'd': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + /* Note! region references are array types */ + HDfprintf(out, "Reference Region"); + goto error; + } /* end else */ + break; + + case 'r': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + /* Note! reference types are opaque types */ + HDfprintf(out, "Reference Opaque"); + goto error; + } /* end else */ + break; - case 'R': - switch(type[1]) { case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1835,17 +1939,29 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5R_type_t reftype = (H5R_type_t)HDva_arg(ap, int); - switch(reftype) { + switch (reftype) { case H5R_BADTYPE: HDfprintf(out, "H5R_BADTYPE"); break; - case H5R_OBJECT: - HDfprintf(out, "H5R_OBJECT"); + case H5R_OBJECT1: + HDfprintf(out, "H5R_OBJECT1"); + break; + + case H5R_DATASET_REGION1: + HDfprintf(out, "H5R_DATASET_REGION1"); + break; + + case H5R_OBJECT2: + HDfprintf(out, "H5R_OBJECT2"); + break; + + case H5R_DATASET_REGION2: + HDfprintf(out, "H5R_DATASET_REGION2"); break; - case H5R_DATASET_REGION: - HDfprintf(out, "H5R_DATASET_REGION"); + case H5R_ATTR: + HDfprintf(out, "H5R_ATTR"); break; case H5R_MAXTYPE: @@ -1856,7 +1972,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "BADTYPE(%ld)", (long)reftype); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -1866,10 +1982,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'S': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1877,7 +1993,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_class_t cls = (H5S_class_t)HDva_arg(ap, int); - switch(cls) { + switch (cls) { case H5S_NO_CLASS: HDfprintf(out, "H5S_NO_CLASS"); break; @@ -1898,12 +2014,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)cls); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1911,7 +2027,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_seloper_t so = (H5S_seloper_t)HDva_arg(ap, int); - switch(so) { + switch (so) { case H5S_SELECT_NOOP: HDfprintf(out, "H5S_NOOP"); break; @@ -1956,12 +2072,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)so); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -1969,7 +2085,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5S_sel_type st = (H5S_sel_type)HDva_arg(ap, int); - switch(st) { + switch (st) { case H5S_SEL_ERROR: HDfprintf(out, "H5S_SEL_ERROR"); break; @@ -1998,7 +2114,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)st); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -2008,8 +2124,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2022,10 +2138,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'T': - switch(type[1]) { + switch (type[1]) { case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2033,7 +2149,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_cset_t cset = (H5T_cset_t)HDva_arg(ap, int); - switch(cset) { + switch (cset) { case H5T_CSET_ERROR: HDfprintf(out, "H5T_CSET_ERROR"); break; @@ -2067,12 +2183,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)cset); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'd': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2080,7 +2196,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_direction_t direct = (H5T_direction_t)HDva_arg(ap, int); - switch(direct) { + switch (direct) { case H5T_DIR_DEFAULT: HDfprintf(out, "H5T_DIR_DEFAULT"); break; @@ -2097,12 +2213,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)direct); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'e': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2110,7 +2226,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_pers_t pers = (H5T_pers_t)HDva_arg(ap, int); - switch(pers) { + switch (pers) { case H5T_PERS_DONTCARE: HDfprintf(out, "H5T_PERS_DONTCARE"); break; @@ -2127,12 +2243,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)pers); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'n': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2140,7 +2256,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_norm_t norm = (H5T_norm_t)HDva_arg(ap, int); - switch(norm) { + switch (norm) { case H5T_NORM_ERROR: HDfprintf(out, "H5T_NORM_ERROR"); break; @@ -2161,12 +2277,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)norm); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'o': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2174,7 +2290,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_order_t order = (H5T_order_t)HDva_arg(ap, int); - switch(order) { + switch (order) { case H5T_ORDER_ERROR: HDfprintf(out, "H5T_ORDER_ERROR"); break; @@ -2203,12 +2319,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)order); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'p': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2216,7 +2332,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_pad_t pad = (H5T_pad_t)HDva_arg(ap, int); - switch(pad) { + switch (pad) { case H5T_PAD_ERROR: HDfprintf(out, "H5T_PAD_ERROR"); break; @@ -2241,12 +2357,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)pad); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 's': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2254,7 +2370,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_sign_t sign = (H5T_sign_t)HDva_arg(ap, int); - switch(sign) { + switch (sign) { case H5T_SGN_ERROR: HDfprintf(out, "H5T_SGN_ERROR"); break; @@ -2275,12 +2391,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)sign); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2288,7 +2404,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_class_t type_class = (H5T_class_t)HDva_arg(ap, int); - switch(type_class) { + switch (type_class) { case H5T_NO_CLASS: HDfprintf(out, "H5T_NO_CLASS"); break; @@ -2345,12 +2461,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)type_class); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'z': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2358,7 +2474,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5T_str_t str = (H5T_str_t)HDva_arg(ap, int); - switch(str) { + switch (str) { case H5T_STR_ERROR: HDfprintf(out, "H5T_STR_ERROR"); break; @@ -2388,14 +2504,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDfprintf(out, "H5T_STR_RESERVED(%ld)",(long)str); + HDfprintf(out, "H5T_STR_RESERVED(%ld)", (long)str); break; default: HDfprintf(out, "%ld", (long)str); break; } /* end switch */ - } /* end else */ + } /* end else */ break; default: @@ -2405,18 +2521,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 't': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - htri_t tri_var = HDva_arg (ap, htri_t); + htri_t tri_var = HDva_arg(ap, htri_t); - if(tri_var>0) + if (tri_var > 0) HDfprintf(out, "TRUE"); - else if(!tri_var) + else if (!tri_var) HDfprintf(out, "FALSE"); else HDfprintf(out, "FAIL(%d)", (int)tri_var); @@ -2424,20 +2540,20 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'U': - switch(type[1]) { + switch (type[1]) { case 'l': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%lu", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%lu", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -2450,18 +2566,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'L': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%llu", i?", ":"", p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%llu", i ? ", " : "", p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ @@ -2479,78 +2595,1005 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ break; - case 'x': - if(ptr) { - if(vp) { - HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - void **p = (void**)vp; - - HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) { - if(p[i]) - HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); - else - HDfprintf(out, "%sNULL", (i ? ", " : "")); - } /* end for */ - HDfprintf(out, "}"); - } /* end if */ - } /* end if */ - else - HDfprintf(out, "NULL"); - } /* end if */ - else { - vp = HDva_arg (ap, void *); - - if(vp) - HDfprintf(out, "0x%p", vp); - else - HDfprintf(out, "NULL"); - } /* end else */ - break; - - case 'z': - if(ptr) { - if(vp) { - HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { - size_t *p = (size_t *)vp; - - HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%Zu", (i ? ", " : ""), p[i]); - HDfprintf(out, "}"); - } /* end if */ - } /* end if */ - else - HDfprintf(out, "NULL"); - } /* end if */ - else { - size_t size = HDva_arg(ap, size_t); - - HDfprintf(out, "%Zu", size); - asize[argno] = (hssize_t)size; - } /* end else */ - break; - - case 'Z': + case 'V': switch (type[1]) { case 'a': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)HDva_arg(ap, int); + H5VL_attr_get_t get = (H5VL_attr_get_t)HDva_arg(ap, int); - switch(scale_type) { - case H5Z_SO_FLOAT_DSCALE: - HDfprintf(out, "H5Z_SO_FLOAT_DSCALE"); + switch (get) { + case H5VL_ATTR_GET_SPACE: + HDfprintf(out, "H5VL_ATTR_GET_SPACE"); break; - - case H5Z_SO_FLOAT_ESCALE: + case H5VL_ATTR_GET_TYPE: + HDfprintf(out, "H5VL_ATTR_GET_TYPE"); + break; + case H5VL_ATTR_GET_ACPL: + HDfprintf(out, "H5VL_ATTR_GET_ACPL"); + break; + case H5VL_ATTR_GET_NAME: + HDfprintf(out, "H5VL_ATTR_GET_NAME"); + break; + case H5VL_ATTR_GET_STORAGE_SIZE: + HDfprintf(out, "H5VL_ATTR_GET_STORAGE_SIZE"); + break; + case H5VL_ATTR_GET_INFO: + HDfprintf(out, "H5VL_ATTR_GET_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'A': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_blob_optional_t optional = (H5VL_blob_optional_t)HDva_arg(ap, int); + + switch (optional) { + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'b': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_specific_t specific = (H5VL_attr_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_ATTR_DELETE: + HDfprintf(out, "H5VL_ATTR_DELETE"); + break; + case H5VL_ATTR_EXISTS: + HDfprintf(out, "H5VL_ATTR_EXISTS"); + break; + case H5VL_ATTR_ITER: + HDfprintf(out, "H5VL_ATTR_ITER"); + break; + case H5VL_ATTR_RENAME: + HDfprintf(out, "H5VL_ATTR_RENAME"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'B': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_blob_specific_t specific = (H5VL_blob_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_BLOB_DELETE: + HDfprintf(out, "H5VL_BLOB_DELETE"); + break; + case H5VL_BLOB_GETSIZE: + HDfprintf(out, "H5VL_BLOB_GETSIZE"); + break; + case H5VL_BLOB_ISNULL: + HDfprintf(out, "H5VL_BLOB_ISNULL"); + break; + case H5VL_BLOB_SETNULL: + HDfprintf(out, "H5VL_BLOB_SETNULL"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'C': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_class_value_t class_val = + (H5VL_class_value_t)HDva_arg(ap, H5VL_class_value_t); + + if (H5_VOL_NATIVE == class_val) + HDfprintf(out, "H5_VOL_NATIVE"); + else + HDfprintf(out, "%ld", (long)class_val); + } /* end else */ + break; + + case 'c': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_get_t get = (H5VL_dataset_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_DATASET_GET_SPACE: + HDfprintf(out, "H5VL_DATASET_GET_SPACE"); + break; + case H5VL_DATASET_GET_SPACE_STATUS: + HDfprintf(out, "H5VL_DATASET_GET_SPACE_STATUS"); + break; + case H5VL_DATASET_GET_TYPE: + HDfprintf(out, "H5VL_DATASET_GET_TYPE"); + break; + case H5VL_DATASET_GET_DCPL: + HDfprintf(out, "H5VL_DATASET_GET_DCPL"); + break; + case H5VL_DATASET_GET_DAPL: + HDfprintf(out, "H5VL_DATASET_GET_DAPL"); + break; + case H5VL_DATASET_GET_STORAGE_SIZE: + HDfprintf(out, "H5VL_DATASET_GET_STORAGE_SIZE"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'd': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_DATASET_SET_EXTENT: + HDfprintf(out, "H5VL_DATASET_SET_EXTENT"); + break; + case H5VL_DATASET_FLUSH: + HDfprintf(out, "H5VL_DATASET_FLUSH"); + break; + case H5VL_DATASET_REFRESH: + HDfprintf(out, "H5VL_DATASET_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'e': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_get_t get = (H5VL_datatype_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_DATATYPE_GET_BINARY: + HDfprintf(out, "H5VL_DATATYPE_GET_BINARY"); + break; + case H5VL_DATATYPE_GET_TCPL: + HDfprintf(out, "H5VL_DATATYPE_GET_TCPL"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'f': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_DATATYPE_FLUSH: + HDfprintf(out, "H5VL_DATATYPE_FLUSH"); + break; + case H5VL_DATATYPE_REFRESH: + HDfprintf(out, "H5VL_DATATYPE_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'g': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_get_t get = (H5VL_file_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_FILE_GET_CONT_INFO: + HDfprintf(out, "H5VL_FILE_GET_CONT_INFO"); + break; + case H5VL_FILE_GET_FAPL: + HDfprintf(out, "H5VL_FILE_GET_FAPL"); + break; + case H5VL_FILE_GET_FCPL: + HDfprintf(out, "H5VL_FILE_GET_FCPL"); + break; + case H5VL_FILE_GET_FILENO: + HDfprintf(out, "H5VL_FILE_GET_FILENO"); + break; + case H5VL_FILE_GET_INTENT: + HDfprintf(out, "H5VL_FILE_GET_INTENT"); + break; + case H5VL_FILE_GET_NAME: + HDfprintf(out, "H5VL_FILE_GET_NAME"); + break; + case H5VL_FILE_GET_OBJ_COUNT: + HDfprintf(out, "H5VL_FILE_GET_OBJ_COUNT"); + break; + case H5VL_FILE_GET_OBJ_IDS: + HDfprintf(out, "H5VL_FILE_GET_OBJ_IDS"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'h': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_specific_t specific = (H5VL_file_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_FILE_FLUSH: + HDfprintf(out, "H5VL_FILE_FLUSH"); + break; + case H5VL_FILE_REOPEN: + HDfprintf(out, "H5VL_FILE_REOPEN"); + break; + case H5VL_FILE_MOUNT: + HDfprintf(out, "H5VL_FILE_MOUNT"); + break; + case H5VL_FILE_UNMOUNT: + HDfprintf(out, "H5VL_FILE_UNMOUNT"); + break; + case H5VL_FILE_IS_ACCESSIBLE: + HDfprintf(out, "H5VL_FILE_IS_ACCESSIBLE"); + break; + case H5VL_FILE_DELETE: + HDfprintf(out, "H5VL_FILE_DELETE"); + break; + case H5VL_FILE_IS_EQUAL: + HDfprintf(out, "H5VL_FILE_IS_EQUAL"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'i': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_get_t get = (H5VL_group_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_GROUP_GET_GCPL: + HDfprintf(out, "H5VL_GROUP_GET_GCPL"); + break; + case H5VL_GROUP_GET_INFO: + HDfprintf(out, "H5VL_GROUP_GET_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'j': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_specific_t specific = (H5VL_group_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_GROUP_FLUSH: + HDfprintf(out, "H5VL_GROUP_FLUSH"); + break; + case H5VL_GROUP_REFRESH: + HDfprintf(out, "H5VL_GROUP_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'k': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_create_type_t create = (H5VL_link_create_type_t)HDva_arg(ap, int); + + switch (create) { + case H5VL_LINK_CREATE_HARD: + HDfprintf(out, "H5VL_LINK_CREATE_HARD"); + break; + case H5VL_LINK_CREATE_SOFT: + HDfprintf(out, "H5VL_LINK_CREATE_SOFT"); + break; + case H5VL_LINK_CREATE_UD: + HDfprintf(out, "H5VL_LINK_CREATE_UD"); + break; + default: + HDfprintf(out, "%ld", (long)create); + break; + } /* end switch */ + } /* end else */ + break; + + case 'l': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_get_t get = (H5VL_link_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_LINK_GET_INFO: + HDfprintf(out, "H5VL_LINK_GET_INFO"); + break; + case H5VL_LINK_GET_NAME: + HDfprintf(out, "H5VL_LINK_GET_NAME"); + break; + case H5VL_LINK_GET_VAL: + HDfprintf(out, "H5VL_LINK_GET_VAL"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'L': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_get_conn_lvl_t get = (H5VL_get_conn_lvl_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_GET_CONN_LVL_CURR: + HDfprintf(out, "H5VL_GET_CONN_LVL_CURR"); + break; + case H5VL_GET_CONN_LVL_TERM: + HDfprintf(out, "H5VL_GET_CONN_LVL_TERM"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'm': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_specific_t specific = (H5VL_link_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_LINK_DELETE: + HDfprintf(out, "H5VL_LINK_DELETE"); + break; + case H5VL_LINK_EXISTS: + HDfprintf(out, "H5VL_LINK_EXISTS"); + break; + case H5VL_LINK_ITER: + HDfprintf(out, "H5VL_LINK_ITER"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'n': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_get_t get = (H5VL_object_get_t)HDva_arg(ap, int); + + switch (get) { + case H5VL_OBJECT_GET_FILE: + HDfprintf(out, "H5VL_OBJECT_GET_FILE"); + break; + case H5VL_OBJECT_GET_NAME: + HDfprintf(out, "H5VL_OBJECT_GET_NAME"); + break; + case H5VL_OBJECT_GET_TYPE: + HDfprintf(out, "H5VL_OBJECT_GET_TYPE"); + break; + case H5VL_OBJECT_GET_INFO: + HDfprintf(out, "H5VL_OBJECT_GET_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + + case 'o': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_specific_t specific = (H5VL_object_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_OBJECT_CHANGE_REF_COUNT: + HDfprintf(out, "H5VL_OBJECT_CHANGE_REF_COUNT"); + break; + case H5VL_OBJECT_EXISTS: + HDfprintf(out, "H5VL_OBJECT_EXISTS"); + break; + case H5VL_OBJECT_LOOKUP: + HDfprintf(out, "H5VL_OBJECT_LOOKUP"); + break; + case H5VL_OBJECT_VISIT: + HDfprintf(out, "H5VL_OBJECT_VISIT"); + break; + case H5VL_OBJECT_FLUSH: + HDfprintf(out, "H5VL_OBJECT_FLUSH"); + break; + case H5VL_OBJECT_REFRESH: + HDfprintf(out, "H5VL_OBJECT_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 'r': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_request_specific_t specific = (H5VL_request_specific_t)HDva_arg(ap, int); + + switch (specific) { + case H5VL_REQUEST_WAITANY: + HDfprintf(out, "H5VL_REQUEST_WAITANY"); + break; + case H5VL_REQUEST_WAITSOME: + HDfprintf(out, "H5VL_REQUEST_WAITSOME"); + break; + case H5VL_REQUEST_WAITALL: + HDfprintf(out, "H5VL_REQUEST_WAITALL"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + + case 's': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_optional_t optional = (H5VL_attr_optional_t)HDva_arg(ap, int); + + switch (optional) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_ATTR_ITERATE_OLD: + HDfprintf(out, "H5VL_NATIVE_ATTR_ITERATE_OLD"); + break; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'S': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_subclass_t subclass = (H5VL_subclass_t)HDva_arg(ap, int); + + switch (subclass) { + case H5VL_SUBCLS_NONE: + HDfprintf(out, "H5VL_SUBCLS_NONE"); + break; + case H5VL_SUBCLS_INFO: + HDfprintf(out, "H5VL_SUBCLS_INFO"); + break; + case H5VL_SUBCLS_WRAP: + HDfprintf(out, "H5VL_SUBCLS_WRAP"); + break; + case H5VL_SUBCLS_ATTR: + HDfprintf(out, "H5VL_SUBCLS_ATTR"); + break; + case H5VL_SUBCLS_DATASET: + HDfprintf(out, "H5VL_SUBCLS_DATASET"); + break; + case H5VL_SUBCLS_DATATYPE: + HDfprintf(out, "H5VL_SUBCLS_DATATYPE"); + break; + case H5VL_SUBCLS_FILE: + HDfprintf(out, "H5VL_SUBCLS_FILE"); + break; + case H5VL_SUBCLS_GROUP: + HDfprintf(out, "H5VL_SUBCLS_GROUP"); + break; + case H5VL_SUBCLS_LINK: + HDfprintf(out, "H5VL_SUBCLS_LINK"); + break; + case H5VL_SUBCLS_OBJECT: + HDfprintf(out, "H5VL_SUBCLS_OBJECT"); + break; + case H5VL_SUBCLS_REQUEST: + HDfprintf(out, "H5VL_SUBCLS_REQUEST"); + break; + case H5VL_SUBCLS_BLOB: + HDfprintf(out, "H5VL_SUBCLS_BLOB"); + break; + case H5VL_SUBCLS_TOKEN: + HDfprintf(out, "H5VL_SUBCLS_TOKEN"); + break; + default: + HDfprintf(out, "%ld", (long)subclass); + break; + } /* end switch */ + } /* end else */ + break; + + case 't': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_optional_t optional = (H5VL_dataset_optional_t)HDva_arg(ap, int); + + switch (optional) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: + HDfprintf(out, "H5VL_NATIVE_DATASET_FORMAT_CONVERT"); + break; + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE"); + break; + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE"); + break; + case H5VL_NATIVE_DATASET_GET_NUM_CHUNKS: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_NUM_CHUNKS"); + break; + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_IDX"); + break; + case H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD"); + break; + case H5VL_NATIVE_DATASET_CHUNK_READ: + HDfprintf(out, "H5VL_NATIVE_DATASET_CHUNK_READ"); + break; + case H5VL_NATIVE_DATASET_CHUNK_WRITE: + HDfprintf(out, "H5VL_NATIVE_DATASET_CHUNK_WRITE"); + break; + case H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_VLEN_BUF_SIZE"); + break; + case H5VL_NATIVE_DATASET_GET_OFFSET: + HDfprintf(out, "H5VL_NATIVE_DATASET_GET_OFFSET"); + break; + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'u': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_optional_t optional = (H5VL_datatype_optional_t)HDva_arg(ap, int); + + switch (optional) { + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'v': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_optional_t optional = (H5VL_file_optional_t)HDva_arg(ap, int); + + switch (optional) { + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: + HDfprintf(out, "H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE"); + break; + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_FILE_IMAGE"); + break; + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_FREE_SECTIONS"); + break; + case H5VL_NATIVE_FILE_GET_FREE_SPACE: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_FREE_SPACE"); + break; + case H5VL_NATIVE_FILE_GET_INFO: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_INFO"); + break; + case H5VL_NATIVE_FILE_GET_MDC_CONF: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MDC_CONF"); + break; + case H5VL_NATIVE_FILE_GET_MDC_HR: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MDC_HR"); + break; + case H5VL_NATIVE_FILE_GET_MDC_SIZE: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MDC_SIZE"); + break; + case H5VL_NATIVE_FILE_GET_SIZE: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_SIZE"); + break; + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_VFD_HANDLE"); + break; + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: + HDfprintf(out, "H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE"); + break; + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: + HDfprintf(out, "H5VL_NATIVE_FILE_SET_MDC_CONFIG"); + break; + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO"); + break; + case H5VL_NATIVE_FILE_START_SWMR_WRITE: + HDfprintf(out, "H5VL_NATIVE_FILE_START_SWMR_WRITE"); + break; + case H5VL_NATIVE_FILE_START_MDC_LOGGING: + HDfprintf(out, "H5VL_NATIVE_FILE_START_MDC_LOGGING"); + break; + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: + HDfprintf(out, "H5VL_NATIVE_FILE_STOP_MDC_LOGGING"); + break; + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS"); + break; + case H5VL_NATIVE_FILE_FORMAT_CONVERT: + HDfprintf(out, "H5VL_NATIVE_FILE_FORMAT_CONVERT"); + break; + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: + HDfprintf(out, "H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS"); + break; + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS"); + break; + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO"); + break; + case H5VL_NATIVE_FILE_GET_EOA: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_EOA"); + break; + case H5VL_NATIVE_FILE_INCR_FILESIZE: + HDfprintf(out, "H5VL_NATIVE_FILE_INCR_FILESIZE"); + break; + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: + HDfprintf(out, "H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS"); + break; + case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG"); + break; + case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: + HDfprintf(out, "H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG"); + break; + case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: + HDfprintf(out, "H5VL_NATIVE_FILE_GET_MPI_ATOMICITY"); + break; + case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: + HDfprintf(out, "H5VL_NATIVE_FILE_SET_MPI_ATOMICITY"); + break; + case H5VL_NATIVE_FILE_POST_OPEN: + HDfprintf(out, "H5VL_NATIVE_FILE_POST_OPEN"); + break; + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'w': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_optional_t optional = (H5VL_group_optional_t)HDva_arg(ap, int); + + switch (optional) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_GROUP_ITERATE_OLD: + HDfprintf(out, "H5VL_NATIVE_GROUP_ITERATE_OLD"); + break; + case H5VL_NATIVE_GROUP_GET_OBJINFO: + HDfprintf(out, "H5VL_NATIVE_GROUP_GET_OBJINFO"); + break; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'x': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_optional_t optional = (H5VL_link_optional_t)HDva_arg(ap, int); + + switch (optional) { + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'y': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_optional_t optional = (H5VL_object_optional_t)HDva_arg(ap, int); + + switch (optional) { + case H5VL_NATIVE_OBJECT_GET_COMMENT: + HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_COMMENT"); + break; + case H5VL_NATIVE_OBJECT_SET_COMMENT: + HDfprintf(out, "H5VL_NATIVE_OBJECT_SET_COMMENT"); + break; + case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: + HDfprintf(out, "H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES"); + break; + case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: + HDfprintf(out, "H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES"); + break; + case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: + HDfprintf(out, "H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED"); + break; + case H5VL_NATIVE_OBJECT_GET_NATIVE_INFO: + HDfprintf(out, "H5VL_NATIVE_OBJECT_GET_NATIVE_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + case 'z': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_request_optional_t optional = (H5VL_request_optional_t)HDva_arg(ap, int); + + switch (optional) { + default: + HDfprintf(out, "%ld", (long)optional); + break; + } /* end switch */ + } /* end else */ + break; + + default: + HDfprintf(out, "BADTYPE(Z%c)", type[1]); + goto error; + } /* end switch */ + break; + + case 'x': + if (ptr) { + if (vp) { + HDfprintf(out, "0x%p", vp); + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + void **p = (void **)vp; + + HDfprintf(out, " {"); + for (i = 0; i < asize[asize_idx]; i++) { + if (p[i]) + HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); + else + HDfprintf(out, "%sNULL", (i ? ", " : "")); + } /* end for */ + HDfprintf(out, "}"); + } /* end if */ + } /* end if */ + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + vp = HDva_arg(ap, void *); + + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end else */ + break; + + case 'z': + if (ptr) { + if (vp) { + HDfprintf(out, "0x%p", vp); + if (asize_idx >= 0 && asize[asize_idx] >= 0) { + size_t *p = (size_t *)vp; + + HDfprintf(out, " {"); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%zu", (i ? ", " : ""), p[i]); + HDfprintf(out, "}"); + } /* end if */ + } /* end if */ + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + size_t size = HDva_arg(ap, size_t); + + HDfprintf(out, "%zu", size); + asize[argno] = (hssize_t)size; + } /* end else */ + break; + + case 'Z': + switch (type[1]) { + case 'a': + if (ptr) { + if (vp) + HDfprintf(out, "0x%p", vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)HDva_arg(ap, int); + + switch (scale_type) { + case H5Z_SO_FLOAT_DSCALE: + HDfprintf(out, "H5Z_SO_FLOAT_DSCALE"); + break; + + case H5Z_SO_FLOAT_ESCALE: HDfprintf(out, "H5Z_SO_FLOAT_ESCALE"); break; @@ -2562,26 +3605,26 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld", (long)scale_type); break; } /* end switch */ - } /* end else */ + } /* end else */ break; case 'c': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); + H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t *); - HDfprintf(out, "0x%p", filter); + HDfprintf(out, "0x%p", (void *)filter); } /* end else */ break; case 'e': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2589,7 +3632,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5Z_EDC_t edc = (H5Z_EDC_t)HDva_arg(ap, int); - if(H5Z_DISABLE_EDC == edc) + if (H5Z_DISABLE_EDC == edc) HDfprintf(out, "H5Z_DISABLE_EDC"); else if (H5Z_ENABLE_EDC == edc) HDfprintf(out, "H5Z_ENABLE_EDC"); @@ -2599,8 +3642,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 'f': - if(ptr) { - if(vp) + if (ptr) { + if (vp) HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); @@ -2608,7 +3651,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { H5Z_filter_t id = HDva_arg(ap, H5Z_filter_t); - if(H5Z_FILTER_DEFLATE == id) + if (H5Z_FILTER_DEFLATE == id) HDfprintf(out, "H5Z_FILTER_DEFLATE"); else HDfprintf(out, "%ld", (long)id); @@ -2616,25 +3659,25 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; case 's': - if(ptr) { - if(vp) { + if (ptr) { + if (vp) { HDfprintf(out, "0x%p", vp); - if(asize_idx >= 0 && asize[asize_idx] >= 0) { + if (asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; HDfprintf(out, " {"); - for(i = 0; i < asize[asize_idx]; i++) - HDfprintf(out, "%s%Zd", (i ? ", " : ""), p[i]); + for (i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%zd", (i ? ", " : ""), p[i]); HDfprintf(out, "}"); } /* end if */ - } /* end if */ + } /* end if */ else HDfprintf(out, "NULL"); } /* end if */ else { ssize_t ssize = HDva_arg(ap, ssize_t); - HDfprintf(out, "%Zd", ssize); + HDfprintf(out, "%zd", ssize); asize[argno] = (hssize_t)ssize; } /* end else */ break; @@ -2646,25 +3689,25 @@ H5_trace(const double *returning, const char *func, const char *type, ...) break; default: - if(HDisupper(type[0])) + if (HDisupper(type[0])) HDfprintf(out, "BADTYPE(%c%c)", type[0], type[1]); else HDfprintf(out, "BADTYPE(%c)", type[0]); goto error; } /* end switch */ - } /* end for */ + } /* end for */ /* Display event time for return */ - if(returning && H5_debug_g.ttimes) { + if (returning && H5_debug_g.ttimes) { H5_timer_get_times(function_timer, &function_times); H5_timer_get_times(running_timer, &running_times); HDfprintf(out, " @%.6f [dt=%.6f]", (function_times.elapsed - running_times.elapsed), - (function_times.elapsed - *returning)); + (function_times.elapsed - *returning)); } /* end if */ error: HDva_end(ap); - if(returning) + if (returning) HDfprintf(out, ";\n"); else { last_call_depth = current_depth++; @@ -2672,9 +3715,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ HDfflush(out); - if(H5_debug_g.ttimes) + if (H5_debug_g.ttimes) return function_times.elapsed; else - return 0.0F; + return 0.0; } /* end H5_trace() */ - diff --git a/src/H5vers.txt b/src/H5vers.txt index 1834f6582f7..ef7250fcf8a 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -5,7 +5,7 @@ # 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://support.hdfgroup.org/ftp/HDF5/releases. +# 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. # @@ -56,12 +56,34 @@ FUNCTION: H5Ewalk; H5E_walk, H5E_error; v10, v18 FUNCTION: H5Fget_info; H5F_info; v18, v110 FUNCTION: H5Gcreate; ; v10, v18 FUNCTION: H5Gopen; ; v10, v18 +FUNCTION: H5Lget_info; H5L_info; v18, v112 +FUNCTION: H5Lget_info_by_idx; H5L_info; v18, v112 +FUNCTION: H5Literate; H5L_iterate; v18, v112 +FUNCTION: H5Literate_by_name; H5L_iterate; v18, v112 +FUNCTION: H5Lvisit; H5L_iterate; v18, v112 +FUNCTION: H5Lvisit_by_name; H5L_iterate; v18, v112 +# Note: v111 is allowed in make_vers because H5O functions were prematurely +# versioned in HDF5 1.10. Because users were affected by this, the +# versioning was rescinded but the H5O version 2 functions were kept +# to be called directly. Now that the version macros are added in 1.12, +# along with a 3rd version of the H5O functions, the H5O function +# version for default api=v110 should be version 1 to work correctly +# with 1.10 applications that were using unversioned H5O functions, +# and the H5O function version should be version 3 for default api=v112 +# (the default api version for 1.12). +FUNCTION: H5Oget_info; ; v18, v111, v112 +FUNCTION: H5Oget_info_by_name; ; v18, v111, v112 +FUNCTION: H5Oget_info_by_idx; ; v18, v111, v112 +FUNCTION: H5Ovisit; ; v18, v111, v112 +FUNCTION: H5Ovisit_by_name; ; v18, v111, v112 +FUNCTION: H5Pencode; ; v110, v112 FUNCTION: H5Pget_filter; ; v10, v18 FUNCTION: H5Pget_filter_by_id; ; v16, v18 FUNCTION: H5Pinsert; ; v14, v18 FUNCTION: H5Pregister; ; v14, v18 FUNCTION: H5Rdereference; ; v10, v110 FUNCTION: H5Rget_obj_type; ; v16, v18 +FUNCTION: H5Sencode; ; v18, v112 FUNCTION: H5Tarray_create; ; v14, v18 FUNCTION: H5Tcommit; ; v10, v18 FUNCTION: H5Tget_array_dims; ; v14, v18 @@ -71,5 +93,7 @@ FUNCTION: H5Topen; ; v10, v18 # (although not required, it's easier to compare this file with the headers # generated if the list below is in alphanumeric sort order - QAK) TYPEDEF: H5E_auto; v10, v18 +TYPEDEF: H5O_info; v18, v112 +TYPEDEF: H5O_iterate; v18, v112 TYPEDEF: H5Z_class; v16, v18 diff --git a/src/H5version.h b/src/H5version.h index 7326a534ee4..89ee7f6fc44 100644 --- a/src/H5version.h +++ b/src/H5version.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,8 +15,8 @@ /* Add new versioned symbols to H5vers.txt file */ -#ifndef _H5version_H -#define _H5version_H +#ifndef H5version_H +#define H5version_H /* If a particular default "global" version of the library's interfaces is @@ -32,12 +32,16 @@ #define H5_USE_18_API 1 #endif /* H5_USE_18_API_DEFAULT && !H5_USE_18_API */ +#if defined(H5_USE_110_API_DEFAULT) && !defined(H5_USE_110_API) + #define H5_USE_110_API 1 +#endif /* H5_USE_110_API_DEFAULT && !H5_USE_110_API */ + /* Issue error if contradicting macros have been defined. */ /* (Can't use an older (deprecated) API version if deprecated symbols have been disabled) */ -#if (defined(H5_USE_16_API) || defined(H5_USE_18_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) +#if (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) #error "Can't choose old API versions when deprecated APIs are disabled" -#endif /* (defined(H5_USE_16_API) || defined(H5_USE_18_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) */ +#endif /* (defined(H5_USE_16_API) || defined(H5_USE_18_API) || defined(H5_USE_110_API)) && defined(H5_NO_DEPRECATED_SYMBOLS) */ /* If a particular "global" version of the library's interfaces is chosen, @@ -213,6 +217,50 @@ #define H5Gopen_vers 2 #endif /* !defined(H5Gopen_vers) */ +#if !defined(H5Lget_info_vers) + #define H5Lget_info_vers 1 +#endif /* !defined(H5Lget_info_vers) */ + +#if !defined(H5Lget_info_by_idx_vers) + #define H5Lget_info_by_idx_vers 1 +#endif /* !defined(H5Lget_info_by_idx_vers) */ + +#if !defined(H5Literate_vers) + #define H5Literate_vers 1 +#endif /* !defined(H5Literate_vers) */ + +#if !defined(H5Literate_by_name_vers) + #define H5Literate_by_name_vers 1 +#endif /* !defined(H5Literate_by_name_vers) */ + +#if !defined(H5Lvisit_vers) + #define H5Lvisit_vers 1 +#endif /* !defined(H5Lvisit_vers) */ + +#if !defined(H5Lvisit_by_name_vers) + #define H5Lvisit_by_name_vers 1 +#endif /* !defined(H5Lvisit_by_name_vers) */ + +#if !defined(H5Oget_info_vers) + #define H5Oget_info_vers 1 +#endif /* !defined(H5Oget_info_vers) */ + +#if !defined(H5Oget_info_by_idx_vers) + #define H5Oget_info_by_idx_vers 1 +#endif /* !defined(H5Oget_info_by_idx_vers) */ + +#if !defined(H5Oget_info_by_name_vers) + #define H5Oget_info_by_name_vers 1 +#endif /* !defined(H5Oget_info_by_name_vers) */ + +#if !defined(H5Ovisit_vers) + #define H5Ovisit_vers 1 +#endif /* !defined(H5Ovisit_vers) */ + +#if !defined(H5Ovisit_by_name_vers) + #define H5Ovisit_by_name_vers 1 +#endif /* !defined(H5Ovisit_by_name_vers) */ + #if !defined(H5Pget_filter_vers) #define H5Pget_filter_vers 2 #endif /* !defined(H5Pget_filter_vers) */ @@ -237,6 +285,10 @@ #define H5Rget_obj_type_vers 2 #endif /* !defined(H5Rget_obj_type_vers) */ +#if !defined(H5Sencode_vers) + #define H5Sencode_vers 1 +#endif /* !defined(H5Sencode_vers) */ + #if !defined(H5Tarray_create_vers) #define H5Tarray_create_vers 2 #endif /* !defined(H5Tarray_create_vers) */ @@ -261,12 +313,192 @@ #define H5E_auto_t_vers 2 #endif /* !defined(H5E_auto_t_vers) */ +#if !defined(H5O_info_t_vers) + #define H5O_info_t_vers 1 +#endif /* !defined(H5O_info_t_vers) */ + +#if !defined(H5O_iterate_t_vers) + #define H5O_iterate_t_vers 1 +#endif /* !defined(H5O_iterate_t_vers) */ + #if !defined(H5Z_class_t_vers) #define H5Z_class_t_vers 2 #endif /* !defined(H5Z_class_t_vers) */ #endif /* H5_USE_18_API */ +#ifdef H5_USE_110_API + +/*************/ +/* Functions */ +/*************/ + +#if !defined(H5Acreate_vers) + #define H5Acreate_vers 2 +#endif /* !defined(H5Acreate_vers) */ + +#if !defined(H5Aiterate_vers) + #define H5Aiterate_vers 2 +#endif /* !defined(H5Aiterate_vers) */ + +#if !defined(H5Dcreate_vers) + #define H5Dcreate_vers 2 +#endif /* !defined(H5Dcreate_vers) */ + +#if !defined(H5Dopen_vers) + #define H5Dopen_vers 2 +#endif /* !defined(H5Dopen_vers) */ + +#if !defined(H5Eclear_vers) + #define H5Eclear_vers 2 +#endif /* !defined(H5Eclear_vers) */ + +#if !defined(H5Eget_auto_vers) + #define H5Eget_auto_vers 2 +#endif /* !defined(H5Eget_auto_vers) */ + +#if !defined(H5Eprint_vers) + #define H5Eprint_vers 2 +#endif /* !defined(H5Eprint_vers) */ + +#if !defined(H5Epush_vers) + #define H5Epush_vers 2 +#endif /* !defined(H5Epush_vers) */ + +#if !defined(H5Eset_auto_vers) + #define H5Eset_auto_vers 2 +#endif /* !defined(H5Eset_auto_vers) */ + +#if !defined(H5Ewalk_vers) + #define H5Ewalk_vers 2 +#endif /* !defined(H5Ewalk_vers) */ + +#if !defined(H5Fget_info_vers) + #define H5Fget_info_vers 2 +#endif /* !defined(H5Fget_info_vers) */ + +#if !defined(H5Gcreate_vers) + #define H5Gcreate_vers 2 +#endif /* !defined(H5Gcreate_vers) */ + +#if !defined(H5Gopen_vers) + #define H5Gopen_vers 2 +#endif /* !defined(H5Gopen_vers) */ + +#if !defined(H5Lget_info_vers) + #define H5Lget_info_vers 1 +#endif /* !defined(H5Lget_info_vers) */ + +#if !defined(H5Lget_info_by_idx_vers) + #define H5Lget_info_by_idx_vers 1 +#endif /* !defined(H5Lget_info_by_idx_vers) */ + +#if !defined(H5Literate_vers) + #define H5Literate_vers 1 +#endif /* !defined(H5Literate_vers) */ + +#if !defined(H5Literate_by_name_vers) + #define H5Literate_by_name_vers 1 +#endif /* !defined(H5Literate_by_name_vers) */ + +#if !defined(H5Lvisit_vers) + #define H5Lvisit_vers 1 +#endif /* !defined(H5Lvisit_vers) */ + +#if !defined(H5Lvisit_by_name_vers) + #define H5Lvisit_by_name_vers 1 +#endif /* !defined(H5Lvisit_by_name_vers) */ + +#if !defined(H5Oget_info_vers) + #define H5Oget_info_vers 1 +#endif /* !defined(H5Oget_info_vers) */ + +#if !defined(H5Oget_info_by_idx_vers) + #define H5Oget_info_by_idx_vers 1 +#endif /* !defined(H5Oget_info_by_idx_vers) */ + +#if !defined(H5Oget_info_by_name_vers) + #define H5Oget_info_by_name_vers 1 +#endif /* !defined(H5Oget_info_by_name_vers) */ + +#if !defined(H5Ovisit_vers) + #define H5Ovisit_vers 1 +#endif /* !defined(H5Ovisit_vers) */ + +#if !defined(H5Ovisit_by_name_vers) + #define H5Ovisit_by_name_vers 1 +#endif /* !defined(H5Ovisit_by_name_vers) */ + +#if !defined(H5Pencode_vers) + #define H5Pencode_vers 1 +#endif /* !defined(H5Pencode_vers) */ + +#if !defined(H5Pget_filter_vers) + #define H5Pget_filter_vers 2 +#endif /* !defined(H5Pget_filter_vers) */ + +#if !defined(H5Pget_filter_by_id_vers) + #define H5Pget_filter_by_id_vers 2 +#endif /* !defined(H5Pget_filter_by_id_vers) */ + +#if !defined(H5Pinsert_vers) + #define H5Pinsert_vers 2 +#endif /* !defined(H5Pinsert_vers) */ + +#if !defined(H5Pregister_vers) + #define H5Pregister_vers 2 +#endif /* !defined(H5Pregister_vers) */ + +#if !defined(H5Rdereference_vers) + #define H5Rdereference_vers 2 +#endif /* !defined(H5Rdereference_vers) */ + +#if !defined(H5Rget_obj_type_vers) + #define H5Rget_obj_type_vers 2 +#endif /* !defined(H5Rget_obj_type_vers) */ + +#if !defined(H5Sencode_vers) + #define H5Sencode_vers 1 +#endif /* !defined(H5Sencode_vers) */ + +#if !defined(H5Tarray_create_vers) + #define H5Tarray_create_vers 2 +#endif /* !defined(H5Tarray_create_vers) */ + +#if !defined(H5Tcommit_vers) + #define H5Tcommit_vers 2 +#endif /* !defined(H5Tcommit_vers) */ + +#if !defined(H5Tget_array_dims_vers) + #define H5Tget_array_dims_vers 2 +#endif /* !defined(H5Tget_array_dims_vers) */ + +#if !defined(H5Topen_vers) + #define H5Topen_vers 2 +#endif /* !defined(H5Topen_vers) */ + +/************/ +/* Typedefs */ +/************/ + +#if !defined(H5E_auto_t_vers) + #define H5E_auto_t_vers 2 +#endif /* !defined(H5E_auto_t_vers) */ + +#if !defined(H5O_info_t_vers) + #define H5O_info_t_vers 1 +#endif /* !defined(H5O_info_t_vers) */ + +#if !defined(H5O_iterate_t_vers) + #define H5O_iterate_t_vers 1 +#endif /* !defined(H5O_iterate_t_vers) */ + +#if !defined(H5Z_class_t_vers) + #define H5Z_class_t_vers 2 +#endif /* !defined(H5Z_class_t_vers) */ + +#endif /* H5_USE_110_API */ + /* Choose the correct version of each API symbol, defaulting to the latest * version of each. The "best" name for API parameters/data structures @@ -429,6 +661,160 @@ #error "H5Gopen_vers set to invalid value" #endif /* H5Gopen_vers */ +#if !defined(H5Lget_info_vers) || H5Lget_info_vers == 2 + #ifndef H5Lget_info_vers + #define H5Lget_info_vers 2 + #endif /* H5Lget_info_vers */ + #define H5Lget_info H5Lget_info2 + #define H5L_info_t H5L_info2_t +#elif H5Lget_info_vers == 1 + #define H5Lget_info H5Lget_info1 + #define H5L_info_t H5L_info1_t +#else /* H5Lget_info_vers */ + #error "H5Lget_info_vers set to invalid value" +#endif /* H5Lget_info_vers */ + +#if !defined(H5Lget_info_by_idx_vers) || H5Lget_info_by_idx_vers == 2 + #ifndef H5Lget_info_by_idx_vers + #define H5Lget_info_by_idx_vers 2 + #endif /* H5Lget_info_by_idx_vers */ + #define H5Lget_info_by_idx H5Lget_info_by_idx2 + #define H5L_info_t H5L_info2_t +#elif H5Lget_info_by_idx_vers == 1 + #define H5Lget_info_by_idx H5Lget_info_by_idx1 + #define H5L_info_t H5L_info1_t +#else /* H5Lget_info_by_idx_vers */ + #error "H5Lget_info_by_idx_vers set to invalid value" +#endif /* H5Lget_info_by_idx_vers */ + +#if !defined(H5Literate_vers) || H5Literate_vers == 2 + #ifndef H5Literate_vers + #define H5Literate_vers 2 + #endif /* H5Literate_vers */ + #define H5Literate H5Literate2 + #define H5L_iterate_t H5L_iterate2_t +#elif H5Literate_vers == 1 + #define H5Literate H5Literate1 + #define H5L_iterate_t H5L_iterate1_t +#else /* H5Literate_vers */ + #error "H5Literate_vers set to invalid value" +#endif /* H5Literate_vers */ + +#if !defined(H5Literate_by_name_vers) || H5Literate_by_name_vers == 2 + #ifndef H5Literate_by_name_vers + #define H5Literate_by_name_vers 2 + #endif /* H5Literate_by_name_vers */ + #define H5Literate_by_name H5Literate_by_name2 + #define H5L_iterate_t H5L_iterate2_t +#elif H5Literate_by_name_vers == 1 + #define H5Literate_by_name H5Literate_by_name1 + #define H5L_iterate_t H5L_iterate1_t +#else /* H5Literate_by_name_vers */ + #error "H5Literate_by_name_vers set to invalid value" +#endif /* H5Literate_by_name_vers */ + +#if !defined(H5Lvisit_vers) || H5Lvisit_vers == 2 + #ifndef H5Lvisit_vers + #define H5Lvisit_vers 2 + #endif /* H5Lvisit_vers */ + #define H5Lvisit H5Lvisit2 + #define H5L_iterate_t H5L_iterate2_t +#elif H5Lvisit_vers == 1 + #define H5Lvisit H5Lvisit1 + #define H5L_iterate_t H5L_iterate1_t +#else /* H5Lvisit_vers */ + #error "H5Lvisit_vers set to invalid value" +#endif /* H5Lvisit_vers */ + +#if !defined(H5Lvisit_by_name_vers) || H5Lvisit_by_name_vers == 2 + #ifndef H5Lvisit_by_name_vers + #define H5Lvisit_by_name_vers 2 + #endif /* H5Lvisit_by_name_vers */ + #define H5Lvisit_by_name H5Lvisit_by_name2 + #define H5L_iterate_t H5L_iterate2_t +#elif H5Lvisit_by_name_vers == 1 + #define H5Lvisit_by_name H5Lvisit_by_name1 + #define H5L_iterate_t H5L_iterate1_t +#else /* H5Lvisit_by_name_vers */ + #error "H5Lvisit_by_name_vers set to invalid value" +#endif /* H5Lvisit_by_name_vers */ + +#if !defined(H5Oget_info_vers) || H5Oget_info_vers == 3 + #ifndef H5Oget_info_vers + #define H5Oget_info_vers 3 + #endif /* H5Oget_info_vers */ + #define H5Oget_info H5Oget_info3 +#elif H5Oget_info_vers == 2 + #define H5Oget_info H5Oget_info2 +#elif H5Oget_info_vers == 1 + #define H5Oget_info H5Oget_info1 +#else /* H5Oget_info_vers */ + #error "H5Oget_info_vers set to invalid value" +#endif /* H5Oget_info_vers */ + +#if !defined(H5Oget_info_by_idx_vers) || H5Oget_info_by_idx_vers == 3 + #ifndef H5Oget_info_by_idx_vers + #define H5Oget_info_by_idx_vers 3 + #endif /* H5Oget_info_by_idx_vers */ + #define H5Oget_info_by_idx H5Oget_info_by_idx3 +#elif H5Oget_info_by_idx_vers == 2 + #define H5Oget_info_by_idx H5Oget_info_by_idx2 +#elif H5Oget_info_by_idx_vers == 1 + #define H5Oget_info_by_idx H5Oget_info_by_idx1 +#else /* H5Oget_info_by_idx_vers */ + #error "H5Oget_info_by_idx_vers set to invalid value" +#endif /* H5Oget_info_by_idx_vers */ + +#if !defined(H5Oget_info_by_name_vers) || H5Oget_info_by_name_vers == 3 + #ifndef H5Oget_info_by_name_vers + #define H5Oget_info_by_name_vers 3 + #endif /* H5Oget_info_by_name_vers */ + #define H5Oget_info_by_name H5Oget_info_by_name3 +#elif H5Oget_info_by_name_vers == 2 + #define H5Oget_info_by_name H5Oget_info_by_name2 +#elif H5Oget_info_by_name_vers == 1 + #define H5Oget_info_by_name H5Oget_info_by_name1 +#else /* H5Oget_info_by_name_vers */ + #error "H5Oget_info_by_name_vers set to invalid value" +#endif /* H5Oget_info_by_name_vers */ + +#if !defined(H5Ovisit_vers) || H5Ovisit_vers == 3 + #ifndef H5Ovisit_vers + #define H5Ovisit_vers 3 + #endif /* H5Ovisit_vers */ + #define H5Ovisit H5Ovisit3 +#elif H5Ovisit_vers == 2 + #define H5Ovisit H5Ovisit2 +#elif H5Ovisit_vers == 1 + #define H5Ovisit H5Ovisit1 +#else /* H5Ovisit_vers */ + #error "H5Ovisit_vers set to invalid value" +#endif /* H5Ovisit_vers */ + +#if !defined(H5Ovisit_by_name_vers) || H5Ovisit_by_name_vers == 3 + #ifndef H5Ovisit_by_name_vers + #define H5Ovisit_by_name_vers 3 + #endif /* H5Ovisit_by_name_vers */ + #define H5Ovisit_by_name H5Ovisit_by_name3 +#elif H5Ovisit_by_name_vers == 2 + #define H5Ovisit_by_name H5Ovisit_by_name2 +#elif H5Ovisit_by_name_vers == 1 + #define H5Ovisit_by_name H5Ovisit_by_name1 +#else /* H5Ovisit_by_name_vers */ + #error "H5Ovisit_by_name_vers set to invalid value" +#endif /* H5Ovisit_by_name_vers */ + +#if !defined(H5Pencode_vers) || H5Pencode_vers == 2 + #ifndef H5Pencode_vers + #define H5Pencode_vers 2 + #endif /* H5Pencode_vers */ + #define H5Pencode H5Pencode2 +#elif H5Pencode_vers == 1 + #define H5Pencode H5Pencode1 +#else /* H5Pencode_vers */ + #error "H5Pencode_vers set to invalid value" +#endif /* H5Pencode_vers */ + #if !defined(H5Pget_filter_vers) || H5Pget_filter_vers == 2 #ifndef H5Pget_filter_vers #define H5Pget_filter_vers 2 @@ -495,6 +881,17 @@ #error "H5Rget_obj_type_vers set to invalid value" #endif /* H5Rget_obj_type_vers */ +#if !defined(H5Sencode_vers) || H5Sencode_vers == 2 + #ifndef H5Sencode_vers + #define H5Sencode_vers 2 + #endif /* H5Sencode_vers */ + #define H5Sencode H5Sencode2 +#elif H5Sencode_vers == 1 + #define H5Sencode H5Sencode1 +#else /* H5Sencode_vers */ + #error "H5Sencode_vers set to invalid value" +#endif /* H5Sencode_vers */ + #if !defined(H5Tarray_create_vers) || H5Tarray_create_vers == 2 #ifndef H5Tarray_create_vers #define H5Tarray_create_vers 2 @@ -555,6 +952,30 @@ #endif /* H5E_auto_t_vers */ +#if !defined(H5O_info_t_vers) || H5O_info_t_vers == 2 + #ifndef H5O_info_t_vers + #define H5O_info_t_vers 2 + #endif /* H5O_info_t_vers */ + #define H5O_info_t H5O_info2_t +#elif H5O_info_t_vers == 1 + #define H5O_info_t H5O_info1_t +#else /* H5O_info_t_vers */ + #error "H5O_info_t_vers set to invalid value" +#endif /* H5O_info_t_vers */ + + +#if !defined(H5O_iterate_t_vers) || H5O_iterate_t_vers == 2 + #ifndef H5O_iterate_t_vers + #define H5O_iterate_t_vers 2 + #endif /* H5O_iterate_t_vers */ + #define H5O_iterate_t H5O_iterate2_t +#elif H5O_iterate_t_vers == 1 + #define H5O_iterate_t H5O_iterate1_t +#else /* H5O_iterate_t_vers */ + #error "H5O_iterate_t_vers set to invalid value" +#endif /* H5O_iterate_t_vers */ + + #if !defined(H5Z_class_t_vers) || H5Z_class_t_vers == 2 #ifndef H5Z_class_t_vers #define H5Z_class_t_vers 2 diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 71162eb4f25..88911b07b5a 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -6,203 +6,109 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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: Scott Wegner - * June 3, 2008 - * - * Purpose: This file is used to map HDF macros to Windows functions. This +/* Purpose: This file is used to map HDF macros to Windows functions. This * should get included H5private mappings, so as to override them. * Any macro not mapped here, however, will receive a similar mapping * inside H5private.h * */ -#ifndef H5_HAVE_INTTYPES_H -/* The following definitions should be suitable for 64-bit Windows, which is - * LLP64, and for 32-bit Windows, which is ILP32. Those are the only - * platforms where is likely to be missing. VS2015 and later - * *may* provide these definitions. - */ -#ifdef _WIN64 -# define PRIdPTR "lld" -# define PRIoPTR "llo" -# define PRIuPTR "llu" -# define PRIxPTR "llx" -#else /* _WIN64 */ -# define PRIdPTR "ld" -# define PRIoPTR "lo" -# define PRIuPTR "lu" -# define PRIxPTR "lx" -#endif /* _WIN64 */ - -# define PRId8 "d" -# define PRIo8 "o" -# define PRIu8 "u" -# define PRIx8 "x" -# define PRId16 "d" -# define PRIo16 "o" -# define PRIu16 "u" -# define PRIx16 "x" -# define PRId32 "d" -# define PRIo32 "o" -# define PRIu32 "u" -# define PRIx32 "x" -# define PRId64 "lld" -# define PRIo64 "llo" -# define PRIu64 "llu" -# define PRIx64 "llx" -# define PRIdMAX "lld" -# define PRIoMAX "llo" -# define PRIuMAX "llu" -# define PRIxMAX "llx" -#endif -/* - * _MSC_VER = 1900 VS2015 - * _MSC_VER = 1800 VS2013 - * _MSC_VER = 1700 VS2012 +/* _MSC_VER = 192x VS2019 + * _MSC_VER = 191x VS2017 + * _MSC_VER = 1900 VS2015 + * _MSC_VER = 1800 VS2013 + * _MSC_VER = 1700 VS2012 */ #ifdef H5_HAVE_WIN32_API -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; - -#define HDaccess(F,M) _access(F,M) -#define HDchdir(S) _chdir(S) -#define HDclose(F) _close(F) -#define HDcreat(S,M) Wopen_utf8(S,O_CREAT|O_TRUNC|O_RDWR,M) -#define HDdup(F) _dup(F) -#define HDfdopen(N,S) _fdopen(N,S) -#define HDfileno(F) _fileno(F) -#define HDfstat(F,B) _fstati64(F,B) -#define HDisatty(F) _isatty(F) - -#define HDgetcwd(S,Z) _getcwd(S,Z) -#define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) -#define HDgetdrive() _getdrive() -#define HDlseek(F,O,W) _lseeki64(F,O,W) -#define HDlstat(S,B) _lstati64(S,B) -#define HDmkdir(S,M) _mkdir(S) -#define HDnanosleep(N, O) Wnanosleep(N, O) -#define HDoff_t __int64 +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; + +#define HDaccess(F, M) _access(F, M) +#define HDchdir(S) _chdir(S) +#define HDclose(F) _close(F) +#define HDcreat(S, M) Wopen_utf8(S, O_CREAT | O_TRUNC | O_RDWR, M) +#define HDdup(F) _dup(F) +#define HDfdopen(N, S) _fdopen(N, S) +#define HDfileno(F) _fileno(F) +#define HDfstat(F, B) _fstati64(F, B) +#define HDisatty(F) _isatty(F) + +#define HDgetcwd(S, Z) _getcwd(S, Z) +#define HDgetdcwd(D, S, Z) _getdcwd(D, S, Z) +#define HDgetdrive() _getdrive() +#define HDlseek(F, O, W) _lseeki64(F, O, W) +#define HDlstat(S, B) _lstati64(S, B) +#define HDmkdir(S, M) _mkdir(S) +#define HDnanosleep(N, O) Wnanosleep(N, O) +#define HDoff_t __int64 /* Note that the variadic HDopen macro is using a VC++ extension * where the comma is dropped if nothing is passed to the ellipsis. */ #ifndef H5_HAVE_MINGW -#define HDopen(S,F,...) Wopen_utf8(S,F,__VA_ARGS__) +#define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__) #else -#define HDopen(S,F,...) Wopen_utf8(S,F,##__VA_ARGS__) +#define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__) #endif -#define HDread(F,M,Z) _read(F,M,Z) -#define HDremove(S) Wremove_utf8(S) -#define HDrmdir(S) _rmdir(S) -#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) -#define HDsleep(S) Sleep(S*1000) -#define HDstat(S,B) _stati64(S,B) -#define HDstrcasecmp(A,B) _stricmp(A,B) -#define HDstrdup(S) _strdup(S) -#define HDstrtok_r(X,Y,Z) strtok_s(X,Y,Z) -#define HDtzset() _tzset() -#define HDunlink(S) _unlink(S) -#define HDwrite(F,M,Z) _write(F,M,Z) +#define HDread(F, M, Z) _read(F, M, Z) +#define HDremove(S) Wremove_utf8(S) +#define HDrmdir(S) _rmdir(S) +#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) +#define HDsleep(S) Sleep(S * 1000) +#define HDstat(S, B) _stati64(S, B) +#define HDstrcasecmp(A, B) _stricmp(A, B) +#define HDstrdup(S) _strdup(S) +#define HDstrtok_r(X, Y, Z) strtok_s(X, Y, Z) +#define HDtzset() _tzset() +#define HDunlink(S) _unlink(S) +#define HDwrite(F, M, Z) _write(F, M, Z) #ifdef H5_HAVE_VISUAL_STUDIO -#if (_MSC_VER < 1800) - #ifndef H5_HAVE_STRTOLL - #define HDstrtoll(S,R,N) _strtoi64(S,R,N) - #endif /* H5_HAVE_STRTOLL */ - #ifndef H5_HAVE_STRTOULL - #define HDstrtoull(S,R,N) _strtoui64(S,R,N) - #endif /* H5_HAVE_STRTOULL */ - /* va_copy() does not exist on pre-2013 Visual Studio. Since va_lists are - * just pointers into the stack in those CRTs, the usual work-around - * is to just define the operation as a pointer copy. - */ - #define HDva_copy(D,S) ((D) = (S)) -#endif /* MSC_VER < 1800 */ - /* - * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO + * The (void*) cast just avoids a compiler warning in MSVC */ -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDmemset(X, C, Z) memset((void *)(X), C, Z) struct timezone { int tz_minuteswest; int tz_dsttime; }; -/* time.h before VS2015 does not include timespec */ -#if (_MSC_VER < 1900) -struct timespec -{ - time_t tv_sec; /* Seconds - >= 0 */ - long tv_nsec; /* Nanoseconds - [0, 999999999] */ -}; -#endif /* MSC_VER < 1900 */ - -#if (_MSC_VER <= 1700) -/* The isnan function needs underscore in VS2012 and earlier */ -#define HDisnan(X) _isnan(X) -/* The round functions do not exist in VS2012 and earlier */ -#define HDllround(V) Wllround(V) -#define HDllroundf(V) Wllroundf(V) -#define HDlround(V) Wlround(V) -#define HDlroundf(V) Wlroundf(V) -#define HDround(V) Wround(V) -#define HDroundf(V) Wroundf(V) -#endif /* MSC_VER < 1700 */ - #endif /* H5_HAVE_VISUAL_STUDIO */ - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); - H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); - H5_DLL int Wflock(int fd, int operation); - H5_DLL char* Wgetlogin(void); - H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); - H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); - H5_DLL int Wnanosleep(const struct timespec *req, struct timespec *rem); - H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); - H5_DLL const wchar_t *H5_get_utf16_str(const char *s); - H5_DLL int Wopen_utf8(const char *path, int oflag, ...); - H5_DLL int Wremove_utf8(const char *path); - - /* Round functions only needed for VS2012 and earlier. - * They are always built to ensure they don't go stale and - * can be deleted (along with their #defines, above) when we - * drop VS2012 support. - */ - H5_DLL long long Wllround(double arg); - H5_DLL long long Wllroundf(float arg); - H5_DLL long Wlround(double arg); - H5_DLL long Wlroundf(float arg); - H5_DLL double Wround(double arg); - H5_DLL float Wroundf(float arg); +H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); +H5_DLL int Wflock(int fd, int operation); +H5_DLL char * Wgetlogin(void); +H5_DLL herr_t H5_expand_windows_env_vars(char **env_var); +H5_DLL wchar_t *H5_get_utf16_str(const char *s); +H5_DLL int Wopen_utf8(const char *path, int oflag, ...); +H5_DLL int Wremove_utf8(const char *path); +H5_DLL int H5_get_win32_times(H5_timevals_t *tvs); #ifdef __cplusplus } #endif /* __cplusplus */ -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) -#define HDsetenv(N,V,O) Wsetenv(N,V,O) -#define HDflock(F,L) Wflock(F,L) -#define HDgetlogin() Wgetlogin() -#define HDsnprintf c99_snprintf /*varargs*/ -#define HDvsnprintf c99_vsnprintf /*varargs*/ +#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) +#define HDsetenv(N, V, O) Wsetenv(N, V, O) +#define HDflock(F, L) Wflock(F, L) +#define HDgetlogin() Wgetlogin() /* Non-POSIX functions */ #ifndef H5_HAVE_MINGW -#define HDftruncate(F,L) _chsize_s(F,L) -#define HDfseek(F,O,W) _fseeki64(F,O,W) +#define HDftruncate(F, L) _chsize_s(F, L) +#define HDfseek(F, O, W) _fseeki64(F, O, W) #endif /* H5_HAVE_MINGW */ #endif /* H5_HAVE_WIN32_API */ - diff --git a/src/hdf5.h b/src/hdf5.h index b717c6d9b1f..c13e472fe7f 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -6,7 +6,7 @@ * 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://support.hdfgroup.org/ftp/HDF5/releases. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,43 +16,49 @@ * a particular header file and include that here, don't fill this file with * lots of gunk... */ -#ifndef _HDF5_H -#define _HDF5_H +#ifndef HDF5_H +#define HDF5_H #include "H5public.h" -#include "H5Apublic.h" /* Attributes */ -#include "H5ACpublic.h" /* Metadata cache */ -#include "H5Dpublic.h" /* Datasets */ -#include "H5Epublic.h" /* Errors */ -#include "H5Fpublic.h" /* Files */ -#include "H5FDpublic.h" /* File drivers */ -#include "H5Gpublic.h" /* Groups */ -#include "H5Ipublic.h" /* ID management */ -#include "H5Lpublic.h" /* Links */ -#include "H5MMpublic.h" /* Memory management */ -#include "H5Opublic.h" /* Object headers */ -#include "H5Ppublic.h" /* Property lists */ -#include "H5PLpublic.h" /* Plugins */ -#include "H5Rpublic.h" /* References */ -#include "H5Spublic.h" /* Dataspaces */ -#include "H5Tpublic.h" /* Datatypes */ -#include "H5Zpublic.h" /* Data filters */ +#include "H5Apublic.h" /* Attributes */ +#include "H5ACpublic.h" /* Metadata cache */ +#include "H5Dpublic.h" /* Datasets */ +#include "H5Epublic.h" /* Errors */ +#include "H5Fpublic.h" /* Files */ +#include "H5FDpublic.h" /* File drivers */ +#include "H5Gpublic.h" /* Groups */ +#include "H5Ipublic.h" /* ID management */ +#include "H5Lpublic.h" /* Links */ +#include "H5Mpublic.h" /* Maps */ +#include "H5MMpublic.h" /* Memory management */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Ppublic.h" /* Property lists */ +#include "H5PLpublic.h" /* Plugins */ +#include "H5Rpublic.h" /* References */ +#include "H5Spublic.h" /* Dataspaces */ +#include "H5Tpublic.h" /* Datatypes */ +#include "H5VLpublic.h" /* Virtual Object Layer */ +#include "H5Zpublic.h" /* Data filters */ /* Predefined file drivers */ -#include "H5FDcore.h" /* Files stored entirely in memory */ -#include "H5FDdirect.h" /* Linux direct I/O */ -#include "H5FDfamily.h" /* File families */ -#include "H5FDhdfs.h" /* Hadoop HDFS */ -#include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ -#include "H5FDmirror.h" /* Mirror VFD and IPC definitions */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FDros3.h" /* R/O S3 "file" I/O */ -#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ -#include "H5FDsplitter.h" /* Twin-channel (R/W & R/O) I/O passthrough */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDcore.h" /* Files stored entirely in memory */ +#include "H5FDdirect.h" /* Linux direct I/O */ +#include "H5FDfamily.h" /* File families */ +#include "H5FDhdfs.h" /* Hadoop HDFS */ +#include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ +#include "H5FDmirror.h" /* Mirror VFD and IPC definitions */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FDros3.h" /* R/O S3 "file" I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ +#include "H5FDsplitter.h" /* Twin-channel (R/W & R/O) I/O passthrough */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Win32 I/O */ +#include "H5FDwindows.h" /* Win32 I/O */ #endif +/* Virtual object layer (VOL) connectors */ +#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLpassthru.h" /* Pass-through VOL connector */ + #endif diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 128e1078390..a4d4af661af 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -39,7 +39,7 @@ Languages: H5_CPPFLAGS: @H5_CPPFLAGS@ AM_CPPFLAGS: @AM_CPPFLAGS@ C Flags: @CFLAGS@ - H5 C Flags: @H5_CFLAGS@ @H5_ECFLAGS@ + H5 C Flags: @H5_CFLAGS@ AM C Flags: @AM_CFLAGS@ Shared C Library: @enable_shared@ Static C Library: @enable_static@ @@ -56,7 +56,7 @@ Languages: C++: @HDF_CXX@ @BUILD_CXX_CONDITIONAL_TRUE@ C++ Compiler: @CXX_VERSION@ @BUILD_CXX_CONDITIONAL_TRUE@ C++ Flags: @CXXFLAGS@ -@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @H5_CXXFLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ AM C++ Flags: @AM_CXXFLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ Shared C++ Library: @enable_shared@ @BUILD_CXX_CONDITIONAL_TRUE@ Static C++ Library: @enable_static@ @@ -73,11 +73,12 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ High-level library: @HDF5_HL@ Build HDF5 Tests: @HDF5_TESTS@ Build HDF5 Tools: @HDF5_TOOLS@ - Threadsafety: @THREADSAFE@ + Threadsafety: @THREADSAFE@ (recursive RW locks: @RECURSIVE_RW_LOCKS@) Default API mapping: @DEFAULT_API_VERSION@ With deprecated public symbols: @DEPRECATED_SYMBOLS@ I/O filters (external): @EXTERNAL_FILTERS@ MPE: @MPE@ + Map (H5M) API: @MAP_API@ Direct VFD: @DIRECT_VFD@ Mirror VFD: @MIRROR_VFD@ (Read-Only) S3 VFD: @ROS3_VFD@ diff --git a/src/uthash.h b/src/uthash.h new file mode 100644 index 00000000000..8bdca557f7f --- /dev/null +++ b/src/uthash.h @@ -0,0 +1,1184 @@ +/* +Copyright (c) 2003-2018, Troy D. Hanson http://troydhanson.github.com/uthash/ +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef UTHASH_H +#define UTHASH_H + +#define UTHASH_VERSION 2.1.0 + +#include /* memcmp, memset, strlen */ +#include /* ptrdiff_t */ +#include /* exit */ + +/* These macros use decltype or the earlier __typeof GNU extension. + As decltype is only available in newer compilers (VS2010 or gcc 4.3+ + when compiling c++ source) this code uses whatever method is needed + or, for VS2008 where neither is available, uses casting workarounds. */ +#if !defined(DECLTYPE) && !defined(NO_DECLTYPE) +#if defined(_MSC_VER) /* MS compiler */ +#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ +#define DECLTYPE(x) (decltype(x)) +#else /* VS2008 or older (or VS2010 in C mode) */ +#define NO_DECLTYPE +#endif +#elif defined(__BORLANDC__) || defined(__ICCARM__) || defined(__LCC__) || defined(__WATCOMC__) +#define NO_DECLTYPE +#else /* GNU, Sun and other compilers */ +#define DECLTYPE(x) (__typeof(x)) +#endif +#endif + +#ifdef NO_DECLTYPE +#define DECLTYPE(x) +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + char **_da_dst = (char **)(&(dst)); \ + *_da_dst = (char *)(src); \ + } while (0) +#else +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + (dst) = DECLTYPE(dst)(src); \ + } while (0) +#endif + +/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ +#if defined(_WIN32) +#if defined(_MSC_VER) && _MSC_VER >= 1600 +#include +#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) +#include +#else +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#endif +#elif defined(__GNUC__) && !defined(__VXWORKS__) +#include +#else +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#endif + +#ifndef uthash_malloc +#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ +#endif +#ifndef uthash_free +#define uthash_free(ptr, sz) free(ptr) /* free fcn */ +#endif +#ifndef uthash_bzero +#define uthash_bzero(a, n) memset(a, '\0', n) +#endif +#ifndef uthash_strlen +#define uthash_strlen(s) strlen(s) +#endif + +#ifdef uthash_memcmp +/* This warning will not catch programs that define uthash_memcmp AFTER including uthash.h. */ +#warning "uthash_memcmp is deprecated; please use HASH_KEYCMP instead" +#else +#define uthash_memcmp(a, b, n) memcmp(a, b, n) +#endif + +#ifndef HASH_KEYCMP +#define HASH_KEYCMP(a, b, n) uthash_memcmp(a, b, n) +#endif + +#ifndef uthash_noexpand_fyi +#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ +#endif +#ifndef uthash_expand_fyi +#define uthash_expand_fyi(tbl) /* can be defined to log expands */ +#endif + +#ifndef HASH_NONFATAL_OOM +#define HASH_NONFATAL_OOM 0 +#endif + +#if HASH_NONFATAL_OOM +/* malloc failures can be recovered from */ + +#ifndef uthash_nonfatal_oom +#define uthash_nonfatal_oom(obj) \ + do { \ + } while (0) /* non-fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) \ + do { \ + (oomed) = 1; \ + } while (0) +#define IF_HASH_NONFATAL_OOM(x) x + +#else +/* malloc failures result in lost memory, hash tables are unusable */ + +#ifndef uthash_fatal +#define uthash_fatal(msg) exit(-1) /* fatal OOM error */ +#endif + +#define HASH_RECORD_OOM(oomed) uthash_fatal("out of memory") +#define IF_HASH_NONFATAL_OOM(x) + +#endif + +/* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS 32U /* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS_LOG2 5U /* lg2 of initial number of buckets */ +#define HASH_BKT_CAPACITY_THRESH 10U /* expand when bucket count reaches */ + +/* calculate the element whose hash handle address is hhp */ +#define ELMT_FROM_HH(tbl, hhp) ((void *)(((char *)(hhp)) - ((tbl)->hho))) +/* calculate the hash handle from element address elp */ +#define HH_FROM_ELMT(tbl, elp) ((UT_hash_handle *)(void *)(((char *)(elp)) + ((tbl)->hho))) + +#define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ + do { \ + struct UT_hash_handle *_hd_hh_item = (itemptrhh); \ + unsigned _hd_bkt; \ + HASH_TO_BKT(_hd_hh_item->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + (head)->hh.tbl->buckets[_hd_bkt].count++; \ + _hd_hh_item->hh_next = NULL; \ + _hd_hh_item->hh_prev = NULL; \ + } while (0) + +#define HASH_VALUE(keyptr, keylen, hashv) \ + do { \ + HASH_FCN(keyptr, keylen, hashv); \ + } while (0) + +#define HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, hashval, out) \ + do { \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_bkt; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _hf_bkt); \ + if (HASH_BLOOM_TEST((head)->hh.tbl, hashval) != 0) { \ + HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[_hf_bkt], keyptr, keylen, \ + hashval, out); \ + } \ + } \ + } while (0) + +#define HASH_FIND(hh, head, keyptr, keylen, out) \ + do { \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ + } while (0) + +#ifdef HASH_BLOOM +#define HASH_BLOOM_BITLEN (1UL << HASH_BLOOM) +#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN / 8UL) + (((HASH_BLOOM_BITLEN % 8UL) != 0UL) ? 1UL : 0UL) +#define HASH_BLOOM_MAKE(tbl, oomed) \ + do { \ + (tbl)->bloom_nbits = HASH_BLOOM; \ + (tbl)->bloom_bv = (uint8_t *)uthash_malloc(HASH_BLOOM_BYTELEN); \ + if (!(tbl)->bloom_bv) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ + } \ + } while (0) + +#define HASH_BLOOM_FREE(tbl) \ + do { \ + uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ + } while (0) + +#define HASH_BLOOM_BITSET(bv, idx) (bv[(idx) / 8U] |= (1U << ((idx) % 8U))) +#define HASH_BLOOM_BITTEST(bv, idx) (bv[(idx) / 8U] & (1U << ((idx) % 8U))) + +#define HASH_BLOOM_ADD(tbl, hashv) \ + HASH_BLOOM_BITSET((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + +#define HASH_BLOOM_TEST(tbl, hashv) \ + HASH_BLOOM_BITTEST((tbl)->bloom_bv, ((hashv) & (uint32_t)((1UL << (tbl)->bloom_nbits) - 1U))) + +#else +#define HASH_BLOOM_MAKE(tbl, oomed) +#define HASH_BLOOM_FREE(tbl) +#define HASH_BLOOM_ADD(tbl, hashv) +#define HASH_BLOOM_TEST(tbl, hashv) (1) +#define HASH_BLOOM_BYTELEN 0U +#endif + +#define HASH_MAKE_TABLE(hh, head, oomed) \ + do { \ + (head)->hh.tbl = (UT_hash_table *)uthash_malloc(sizeof(UT_hash_table)); \ + if (!(head)->hh.tbl) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \ + (head)->hh.tbl->buckets = \ + (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + if (!(head)->hh.tbl->buckets) { \ + HASH_RECORD_OOM(oomed); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + } \ + else { \ + uthash_bzero((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl, oomed); \ + IF_HASH_NONFATAL_OOM(if (oomed) { \ + uthash_free((head)->hh.tbl->buckets, \ + HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + }) \ + } \ + } \ + } while (0) + +#define HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, replaced, cmpfcn) \ + do { \ + (replaced) = NULL; \ + HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ + if (replaced) { \ + HASH_DELETE(hh, head, replaced); \ + } \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn); \ + } while (0) + +#define HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add, replaced) \ + do { \ + (replaced) = NULL; \ + HASH_FIND_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, replaced); \ + if (replaced) { \ + HASH_DELETE(hh, head, replaced); \ + } \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add); \ + } while (0) + +#define HASH_REPLACE(hh, head, fieldname, keylen_in, add, replaced) \ + do { \ + unsigned _hr_hashv; \ + HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ + HASH_REPLACE_BYHASHVALUE(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced); \ + } while (0) + +#define HASH_REPLACE_INORDER(hh, head, fieldname, keylen_in, add, replaced, cmpfcn) \ + do { \ + unsigned _hr_hashv; \ + HASH_VALUE(&((add)->fieldname), keylen_in, _hr_hashv); \ + HASH_REPLACE_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, _hr_hashv, add, replaced, cmpfcn); \ + } while (0) + +#define HASH_APPEND_LIST(hh, head, add) \ + do { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ + (head)->hh.tbl->tail->next = (add); \ + (head)->hh.tbl->tail = &((add)->hh); \ + } while (0) + +#define HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn) \ + do { \ + do { \ + if (cmpfcn(DECLTYPE(head)(_hs_iter), add) > 0) { \ + break; \ + } \ + } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ + } while (0) + +#ifdef NO_DECLTYPE +#undef HASH_AKBI_INNER_LOOP +#define HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn) \ + do { \ + char *_hs_saved_head = (char *)(head); \ + do { \ + DECLTYPE_ASSIGN(head, _hs_iter); \ + if (cmpfcn(head, add) > 0) { \ + DECLTYPE_ASSIGN(head, _hs_saved_head); \ + break; \ + } \ + DECLTYPE_ASSIGN(head, _hs_saved_head); \ + } while ((_hs_iter = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->next)); \ + } while (0) +#endif + +#if HASH_NONFATAL_OOM + +#define HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, oomed) \ + do { \ + if (!(oomed)) { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + if (oomed) { \ + HASH_ROLLBACK_BKT(hh, head, &(add)->hh); \ + HASH_DELETE_HH(hh, head, &(add)->hh); \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ + else { \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } \ + } \ + else { \ + (add)->hh.tbl = NULL; \ + uthash_nonfatal_oom(add); \ + } \ + } while (0) + +#else + +#define HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, oomed) \ + do { \ + unsigned _ha_bkt; \ + (head)->hh.tbl->num_items++; \ + HASH_TO_BKT(hashval, (head)->hh.tbl->num_buckets, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], hh, &(add)->hh, oomed); \ + HASH_BLOOM_ADD((head)->hh.tbl, hashval); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + } while (0) + +#endif + +#define HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, hashval, add, cmpfcn) \ + do { \ + IF_HASH_NONFATAL_OOM(int _ha_oomed = 0;) \ + (add)->hh.hashv = (hashval); \ + (add)->hh.key = (char *)(keyptr); \ + (add)->hh.keylen = (unsigned)(keylen_in); \ + if (!(head)) { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM(if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( \ + }) \ + } \ + else { \ + void *_hs_iter = (head); \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_AKBI_INNER_LOOP(hh, head, add, cmpfcn); \ + if (_hs_iter) { \ + (add)->hh.next = _hs_iter; \ + if (((add)->hh.prev = HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev)) { \ + HH_FROM_ELMT((head)->hh.tbl, (add)->hh.prev)->next = (add); \ + } \ + else { \ + (head) = (add); \ + } \ + HH_FROM_ELMT((head)->hh.tbl, _hs_iter)->prev = (add); \ + } \ + else { \ + HASH_APPEND_LIST(hh, head, add); \ + } \ + } \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ + HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE_INORDER"); \ + } while (0) + +#define HASH_ADD_KEYPTR_INORDER(hh, head, keyptr, keylen_in, add, cmpfcn) \ + do { \ + unsigned _hs_hashv; \ + HASH_VALUE(keyptr, keylen_in, _hs_hashv); \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, keyptr, keylen_in, _hs_hashv, add, cmpfcn); \ + } while (0) + +#define HASH_ADD_BYHASHVALUE_INORDER(hh, head, fieldname, keylen_in, hashval, add, cmpfcn) \ + HASH_ADD_KEYPTR_BYHASHVALUE_INORDER(hh, head, &((add)->fieldname), keylen_in, hashval, add, cmpfcn) + +#define HASH_ADD_INORDER(hh, head, fieldname, keylen_in, add, cmpfcn) \ + HASH_ADD_KEYPTR_INORDER(hh, head, &((add)->fieldname), keylen_in, add, cmpfcn) + +#define HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, hashval, add) \ + do { \ + IF_HASH_NONFATAL_OOM(int _ha_oomed = 0;) \ + (add)->hh.hashv = (hashval); \ + (add)->hh.key = (char *)(keyptr); \ + (add)->hh.keylen = (unsigned)(keylen_in); \ + if (!(head)) { \ + (add)->hh.next = NULL; \ + (add)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh, add, _ha_oomed); \ + IF_HASH_NONFATAL_OOM(if (!_ha_oomed) { ) \ + (head) = (add); \ + IF_HASH_NONFATAL_OOM( \ + }) \ + } \ + else { \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_APPEND_LIST(hh, head, add); \ + } \ + HASH_ADD_TO_TABLE(hh, head, keyptr, keylen_in, hashval, add, _ha_oomed); \ + HASH_FSCK(hh, head, "HASH_ADD_KEYPTR_BYHASHVALUE"); \ + } while (0) + +#define HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add) \ + do { \ + unsigned _ha_hashv; \ + HASH_VALUE(keyptr, keylen_in, _ha_hashv); \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, keyptr, keylen_in, _ha_hashv, add); \ + } while (0) + +#define HASH_ADD_BYHASHVALUE(hh, head, fieldname, keylen_in, hashval, add) \ + HASH_ADD_KEYPTR_BYHASHVALUE(hh, head, &((add)->fieldname), keylen_in, hashval, add) + +#define HASH_ADD(hh, head, fieldname, keylen_in, add) \ + HASH_ADD_KEYPTR(hh, head, &((add)->fieldname), keylen_in, add) + +#define HASH_TO_BKT(hashv, num_bkts, bkt) \ + do { \ + bkt = ((hashv) & ((num_bkts)-1U)); \ + } while (0) + +/* delete "delptr" from the hash table. + * "the usual" patch-up process for the app-order doubly-linked-list. + * The use of _hd_hh_del below deserves special explanation. + * These used to be expressed using (delptr) but that led to a bug + * if someone used the same symbol for the head and deletee, like + * HASH_DELETE(hh,users,users); + * We want that to work, but by changing the head (users) below + * we were forfeiting our ability to further refer to the deletee (users) + * in the patch-up process. Solution: use scratch space to + * copy the deletee pointer, then the latter references are via that + * scratch pointer rather than through the repointed (users) symbol. + */ +#define HASH_DELETE(hh, head, delptr) HASH_DELETE_HH(hh, head, &(delptr)->hh) + +#define HASH_DELETE_HH(hh, head, delptrhh) \ + do { \ + struct UT_hash_handle *_hd_hh_del = (delptrhh); \ + if ((_hd_hh_del->prev == NULL) && (_hd_hh_del->next == NULL)) { \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head) = NULL; \ + } \ + else { \ + unsigned _hd_bkt; \ + if (_hd_hh_del == (head)->hh.tbl->tail) { \ + (head)->hh.tbl->tail = HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev); \ + } \ + if (_hd_hh_del->prev != NULL) { \ + HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->prev)->next = _hd_hh_del->next; \ + } \ + else { \ + DECLTYPE_ASSIGN(head, _hd_hh_del->next); \ + } \ + if (_hd_hh_del->next != NULL) { \ + HH_FROM_ELMT((head)->hh.tbl, _hd_hh_del->next)->prev = _hd_hh_del->prev; \ + } \ + HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + HASH_DEL_IN_BKT((head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ + (head)->hh.tbl->num_items--; \ + } \ + HASH_FSCK(hh, head, "HASH_DELETE_HH"); \ + } while (0) + +/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ +#define HASH_FIND_STR(head, findstr, out) \ + do { \ + unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(findstr); \ + HASH_FIND(hh, head, findstr, _uthash_hfstr_keylen, out); \ + } while (0) +#define HASH_ADD_STR(head, strfield, add) \ + do { \ + unsigned _uthash_hastr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_ADD(hh, head, strfield[0], _uthash_hastr_keylen, add); \ + } while (0) +#define HASH_REPLACE_STR(head, strfield, add, replaced) \ + do { \ + unsigned _uthash_hrstr_keylen = (unsigned)uthash_strlen((add)->strfield); \ + HASH_REPLACE(hh, head, strfield[0], _uthash_hrstr_keylen, add, replaced); \ + } while (0) +#define HASH_FIND_INT(head, findint, out) HASH_FIND(hh, head, findint, sizeof(int), out) +#define HASH_ADD_INT(head, intfield, add) HASH_ADD(hh, head, intfield, sizeof(int), add) +#define HASH_REPLACE_INT(head, intfield, add, replaced) \ + HASH_REPLACE(hh, head, intfield, sizeof(int), add, replaced) +#define HASH_FIND_PTR(head, findptr, out) HASH_FIND(hh, head, findptr, sizeof(void *), out) +#define HASH_ADD_PTR(head, ptrfield, add) HASH_ADD(hh, head, ptrfield, sizeof(void *), add) +#define HASH_REPLACE_PTR(head, ptrfield, add, replaced) \ + HASH_REPLACE(hh, head, ptrfield, sizeof(void *), add, replaced) +#define HASH_DEL(head, delptr) HASH_DELETE(hh, head, delptr) + +/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. + * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. + */ +#ifdef HASH_DEBUG +#include /* fprintf, stderr */ +#define HASH_OOPS(...) \ + do { \ + fprintf(stderr, __VA_ARGS__); \ + exit(-1); \ + } while (0) +#define HASH_FSCK(hh, head, where) \ + do { \ + struct UT_hash_handle *_thh; \ + if (head) { \ + unsigned _bkt_i; \ + unsigned _count = 0; \ + char * _prev; \ + for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; ++_bkt_i) { \ + unsigned _bkt_count = 0; \ + _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ + _prev = NULL; \ + while (_thh) { \ + if (_prev != (char *)(_thh->hh_prev)) { \ + HASH_OOPS("%s: invalid hh_prev %p, actual %p\n", (where), (void *)_thh->hh_prev, \ + (void *)_prev); \ + } \ + _bkt_count++; \ + _prev = (char *)(_thh); \ + _thh = _thh->hh_next; \ + } \ + _count += _bkt_count; \ + if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ + HASH_OOPS("%s: invalid bucket count %u, actual %u\n", (where), \ + (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ + } \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("%s: invalid hh item count %u, actual %u\n", (where), (head)->hh.tbl->num_items, \ + _count); \ + } \ + _count = 0; \ + _prev = NULL; \ + _thh = &(head)->hh; \ + while (_thh) { \ + _count++; \ + if (_prev != (char *)_thh->prev) { \ + HASH_OOPS("%s: invalid prev %p, actual %p\n", (where), (void *)_thh->prev, \ + (void *)_prev); \ + } \ + _prev = (char *)ELMT_FROM_HH((head)->hh.tbl, _thh); \ + _thh = (_thh->next ? HH_FROM_ELMT((head)->hh.tbl, _thh->next) : NULL); \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("%s: invalid app item count %u, actual %u\n", (where), (head)->hh.tbl->num_items, \ + _count); \ + } \ + } \ + } while (0) +#else +#define HASH_FSCK(hh, head, where) +#endif + +/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to + * the descriptor to which this macro is defined for tuning the hash function. + * The app can #include to get the prototype for write(2). */ +#ifdef HASH_EMIT_KEYS +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) \ + do { \ + unsigned _klen = fieldlen; \ + write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ + write(HASH_EMIT_KEYS, keyptr, (unsigned long)fieldlen); \ + } while (0) +#else +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) +#endif + +/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ +#ifdef HASH_FUNCTION +#define HASH_FCN HASH_FUNCTION +#else +#define HASH_FCN HASH_JEN +#endif + +/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ +#define HASH_BER(key, keylen, hashv) \ + do { \ + unsigned _hb_keylen = (unsigned)keylen; \ + const unsigned char *_hb_key = (const unsigned char *)(key); \ + (hashv) = 0; \ + while (_hb_keylen-- != 0U) { \ + (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; \ + } \ + } while (0) + +/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at + * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ +#define HASH_SAX(key, keylen, hashv) \ + do { \ + unsigned _sx_i; \ + const unsigned char *_hs_key = (const unsigned char *)(key); \ + hashv = 0; \ + for (_sx_i = 0; _sx_i < keylen; _sx_i++) { \ + hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ + } \ + } while (0) +/* FNV-1a variation */ +#define HASH_FNV(key, keylen, hashv) \ + do { \ + unsigned _fn_i; \ + const unsigned char *_hf_key = (const unsigned char *)(key); \ + (hashv) = 2166136261U; \ + for (_fn_i = 0; _fn_i < keylen; _fn_i++) { \ + hashv = hashv ^ _hf_key[_fn_i]; \ + hashv = hashv * 16777619U; \ + } \ + } while (0) + +#define HASH_OAT(key, keylen, hashv) \ + do { \ + unsigned _ho_i; \ + const unsigned char *_ho_key = (const unsigned char *)(key); \ + hashv = 0; \ + for (_ho_i = 0; _ho_i < keylen; _ho_i++) { \ + hashv += _ho_key[_ho_i]; \ + hashv += (hashv << 10); \ + hashv ^= (hashv >> 6); \ + } \ + hashv += (hashv << 3); \ + hashv ^= (hashv >> 11); \ + hashv += (hashv << 15); \ + } while (0) + +#define HASH_JEN_MIX(a, b, c) \ + do { \ + a -= b; \ + a -= c; \ + a ^= (c >> 13); \ + b -= c; \ + b -= a; \ + b ^= (a << 8); \ + c -= a; \ + c -= b; \ + c ^= (b >> 13); \ + a -= b; \ + a -= c; \ + a ^= (c >> 12); \ + b -= c; \ + b -= a; \ + b ^= (a << 16); \ + c -= a; \ + c -= b; \ + c ^= (b >> 5); \ + a -= b; \ + a -= c; \ + a ^= (c >> 3); \ + b -= c; \ + b -= a; \ + b ^= (a << 10); \ + c -= a; \ + c -= b; \ + c ^= (b >> 15); \ + } while (0) + +#define HASH_JEN(key, keylen, hashv) \ + do { \ + unsigned _hj_i, _hj_j, _hj_k; \ + unsigned const char *_hj_key = (unsigned const char *)(key); \ + hashv = 0xfeedbeefu; \ + _hj_i = _hj_j = 0x9e3779b9u; \ + _hj_k = (unsigned)(keylen); \ + while (_hj_k >= 12U) { \ + _hj_i += (_hj_key[0] + ((unsigned)_hj_key[1] << 8) + ((unsigned)_hj_key[2] << 16) + \ + ((unsigned)_hj_key[3] << 24)); \ + _hj_j += (_hj_key[4] + ((unsigned)_hj_key[5] << 8) + ((unsigned)_hj_key[6] << 16) + \ + ((unsigned)_hj_key[7] << 24)); \ + hashv += (_hj_key[8] + ((unsigned)_hj_key[9] << 8) + ((unsigned)_hj_key[10] << 16) + \ + ((unsigned)_hj_key[11] << 24)); \ + \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + \ + _hj_key += 12; \ + _hj_k -= 12U; \ + } \ + hashv += (unsigned)(keylen); \ + switch (_hj_k) { \ + case 11: \ + hashv += ((unsigned)_hj_key[10] << 24); /* FALLTHROUGH */ \ + case 10: \ + hashv += ((unsigned)_hj_key[9] << 16); /* FALLTHROUGH */ \ + case 9: \ + hashv += ((unsigned)_hj_key[8] << 8); /* FALLTHROUGH */ \ + case 8: \ + _hj_j += ((unsigned)_hj_key[7] << 24); /* FALLTHROUGH */ \ + case 7: \ + _hj_j += ((unsigned)_hj_key[6] << 16); /* FALLTHROUGH */ \ + case 6: \ + _hj_j += ((unsigned)_hj_key[5] << 8); /* FALLTHROUGH */ \ + case 5: \ + _hj_j += _hj_key[4]; /* FALLTHROUGH */ \ + case 4: \ + _hj_i += ((unsigned)_hj_key[3] << 24); /* FALLTHROUGH */ \ + case 3: \ + _hj_i += ((unsigned)_hj_key[2] << 16); /* FALLTHROUGH */ \ + case 2: \ + _hj_i += ((unsigned)_hj_key[1] << 8); /* FALLTHROUGH */ \ + case 1: \ + _hj_i += _hj_key[0]; \ + } \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + } while (0) + +/* The Paul Hsieh hash function */ +#undef get16bits +#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || \ + defined(__BORLANDC__) || defined(__TURBOC__) +#define get16bits(d) (*((const uint16_t *)(d))) +#endif + +#if !defined(get16bits) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) + (uint32_t)(((const uint8_t *)(d))[0])) +#endif +#define HASH_SFH(key, keylen, hashv) \ + do { \ + unsigned const char *_sfh_key = (unsigned const char *)(key); \ + uint32_t _sfh_tmp, _sfh_len = (uint32_t)keylen; \ + \ + unsigned _sfh_rem = _sfh_len & 3U; \ + _sfh_len >>= 2; \ + hashv = 0xcafebabeu; \ + \ + /* Main loop */ \ + for (; _sfh_len > 0U; _sfh_len--) { \ + hashv += get16bits(_sfh_key); \ + _sfh_tmp = ((uint32_t)(get16bits(_sfh_key + 2)) << 11) ^ hashv; \ + hashv = (hashv << 16) ^ _sfh_tmp; \ + _sfh_key += 2U * sizeof(uint16_t); \ + hashv += hashv >> 11; \ + } \ + \ + /* Handle end cases */ \ + switch (_sfh_rem) { \ + case 3: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 16; \ + hashv ^= (uint32_t)(_sfh_key[sizeof(uint16_t)]) << 18; \ + hashv += hashv >> 11; \ + break; \ + case 2: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 11; \ + hashv += hashv >> 17; \ + break; \ + case 1: \ + hashv += *_sfh_key; \ + hashv ^= hashv << 10; \ + hashv += hashv >> 1; \ + } \ + \ + /* Force "avalanching" of final 127 bits */ \ + hashv ^= hashv << 3; \ + hashv += hashv >> 5; \ + hashv ^= hashv << 4; \ + hashv += hashv >> 17; \ + hashv ^= hashv << 25; \ + hashv += hashv >> 6; \ + } while (0) + +/* iterate over items in a known bucket to find desired item */ +#define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, hashval, out) \ + do { \ + if ((head).hh_head != NULL) { \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (head).hh_head)); \ + } \ + else { \ + (out) = NULL; \ + } \ + while ((out) != NULL) { \ + if ((out)->hh.hashv == (hashval) && (out)->hh.keylen == (keylen_in)) { \ + if (HASH_KEYCMP((out)->hh.key, keyptr, keylen_in) == 0) { \ + break; \ + } \ + } \ + if ((out)->hh.hh_next != NULL) { \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, (out)->hh.hh_next)); \ + } \ + else { \ + (out) = NULL; \ + } \ + } \ + } while (0) + +/* add an item to a bucket */ +#define HASH_ADD_TO_BKT(head, hh, addhh, oomed) \ + do { \ + UT_hash_bucket *_ha_head = &(head); \ + _ha_head->count++; \ + (addhh)->hh_next = _ha_head->hh_head; \ + (addhh)->hh_prev = NULL; \ + if (_ha_head->hh_head != NULL) { \ + _ha_head->hh_head->hh_prev = (addhh); \ + } \ + _ha_head->hh_head = (addhh); \ + if ((_ha_head->count >= ((_ha_head->expand_mult + 1U) * HASH_BKT_CAPACITY_THRESH)) && \ + !(addhh)->tbl->noexpand) { \ + HASH_EXPAND_BUCKETS(addhh, (addhh)->tbl, oomed); \ + IF_HASH_NONFATAL_OOM(if (oomed) { HASH_DEL_IN_BKT(head, addhh); }) \ + } \ + } while (0) + +/* remove an item from a given bucket */ +#define HASH_DEL_IN_BKT(head, delhh) \ + do { \ + UT_hash_bucket *_hd_head = &(head); \ + _hd_head->count--; \ + if (_hd_head->hh_head == (delhh)) { \ + _hd_head->hh_head = (delhh)->hh_next; \ + } \ + if ((delhh)->hh_prev) { \ + (delhh)->hh_prev->hh_next = (delhh)->hh_next; \ + } \ + if ((delhh)->hh_next) { \ + (delhh)->hh_next->hh_prev = (delhh)->hh_prev; \ + } \ + } while (0) + +/* Bucket expansion has the effect of doubling the number of buckets + * and redistributing the items into the new buckets. Ideally the + * items will distribute more or less evenly into the new buckets + * (the extent to which this is true is a measure of the quality of + * the hash function as it applies to the key domain). + * + * With the items distributed into more buckets, the chain length + * (item count) in each bucket is reduced. Thus by expanding buckets + * the hash keeps a bound on the chain length. This bounded chain + * length is the essence of how a hash provides constant time lookup. + * + * The calculation of tbl->ideal_chain_maxlen below deserves some + * explanation. First, keep in mind that we're calculating the ideal + * maximum chain length based on the *new* (doubled) bucket count. + * In fractions this is just n/b (n=number of items,b=new num buckets). + * Since the ideal chain length is an integer, we want to calculate + * ceil(n/b). We don't depend on floating point arithmetic in this + * hash, so to calculate ceil(n/b) with integers we could write + * + * ceil(n/b) = (n/b) + ((n%b)?1:0) + * + * and in fact a previous version of this hash did just that. + * But now we have improved things a bit by recognizing that b is + * always a power of two. We keep its base 2 log handy (call it lb), + * so now we can write this with a bit shift and logical AND: + * + * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) + * + */ +#define HASH_EXPAND_BUCKETS(hh, tbl, oomed) \ + do { \ + unsigned _he_bkt; \ + unsigned _he_bkt_i; \ + struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ + UT_hash_bucket * _he_new_buckets, *_he_newbkt; \ + _he_new_buckets = \ + (UT_hash_bucket *)uthash_malloc(2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + if (!_he_new_buckets) { \ + HASH_RECORD_OOM(oomed); \ + } \ + else { \ + uthash_bzero(_he_new_buckets, 2UL * (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->ideal_chain_maxlen = \ + ((tbl)->num_items >> ((tbl)->log2_num_buckets + 1U)) + \ + ((((tbl)->num_items & (((tbl)->num_buckets * 2U) - 1U)) != 0U) ? 1U : 0U); \ + (tbl)->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < (tbl)->num_buckets; _he_bkt_i++) { \ + _he_thh = (tbl)->buckets[_he_bkt_i].hh_head; \ + while (_he_thh != NULL) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, (tbl)->num_buckets * 2U, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > (tbl)->ideal_chain_maxlen) { \ + (tbl)->nonideal_items++; \ + if (_he_newbkt->count > _he_newbkt->expand_mult * (tbl)->ideal_chain_maxlen) { \ + _he_newbkt->expand_mult++; \ + } \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head != NULL) { \ + _he_newbkt->hh_head->hh_prev = _he_thh; \ + } \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ + } \ + } \ + uthash_free((tbl)->buckets, (tbl)->num_buckets * sizeof(struct UT_hash_bucket)); \ + (tbl)->num_buckets *= 2U; \ + (tbl)->log2_num_buckets++; \ + (tbl)->buckets = _he_new_buckets; \ + (tbl)->ineff_expands = \ + ((tbl)->nonideal_items > ((tbl)->num_items >> 1)) ? ((tbl)->ineff_expands + 1U) : 0U; \ + if ((tbl)->ineff_expands > 1U) { \ + (tbl)->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ + } \ + } while (0) + +/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ +/* Note that HASH_SORT assumes the hash handle name to be hh. + * HASH_SRT was added to allow the hash handle name to be passed in. */ +#define HASH_SORT(head, cmpfcn) HASH_SRT(hh, head, cmpfcn) +#define HASH_SRT(hh, head, cmpfcn) \ + do { \ + unsigned _hs_i; \ + unsigned _hs_looping, _hs_nmerges, _hs_insize, _hs_psize, _hs_qsize; \ + struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ + if (head != NULL) { \ + _hs_insize = 1; \ + _hs_looping = 1; \ + _hs_list = &((head)->hh); \ + while (_hs_looping != 0U) { \ + _hs_p = _hs_list; \ + _hs_list = NULL; \ + _hs_tail = NULL; \ + _hs_nmerges = 0; \ + while (_hs_p != NULL) { \ + _hs_nmerges++; \ + _hs_q = _hs_p; \ + _hs_psize = 0; \ + for (_hs_i = 0; _hs_i < _hs_insize; ++_hs_i) { \ + _hs_psize++; \ + _hs_q = ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + if (_hs_q == NULL) { \ + break; \ + } \ + } \ + _hs_qsize = _hs_insize; \ + while ((_hs_psize != 0U) || ((_hs_qsize != 0U) && (_hs_q != NULL))) { \ + if (_hs_psize == 0U) { \ + _hs_e = _hs_q; \ + _hs_q = \ + ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + _hs_qsize--; \ + } \ + else if ((_hs_qsize == 0U) || (_hs_q == NULL)) { \ + _hs_e = _hs_p; \ + if (_hs_p != NULL) { \ + _hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) \ + : NULL); \ + } \ + _hs_psize--; \ + } \ + else if ((cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \ + DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) <= 0) { \ + _hs_e = _hs_p; \ + if (_hs_p != NULL) { \ + _hs_p = ((_hs_p->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_p->next) \ + : NULL); \ + } \ + _hs_psize--; \ + } \ + else { \ + _hs_e = _hs_q; \ + _hs_q = \ + ((_hs_q->next != NULL) ? HH_FROM_ELMT((head)->hh.tbl, _hs_q->next) : NULL); \ + _hs_qsize--; \ + } \ + if (_hs_tail != NULL) { \ + _hs_tail->next = ((_hs_e != NULL) ? ELMT_FROM_HH((head)->hh.tbl, _hs_e) : NULL); \ + } \ + else { \ + _hs_list = _hs_e; \ + } \ + if (_hs_e != NULL) { \ + _hs_e->prev = \ + ((_hs_tail != NULL) ? ELMT_FROM_HH((head)->hh.tbl, _hs_tail) : NULL); \ + } \ + _hs_tail = _hs_e; \ + } \ + _hs_p = _hs_q; \ + } \ + if (_hs_tail != NULL) { \ + _hs_tail->next = NULL; \ + } \ + if (_hs_nmerges <= 1U) { \ + _hs_looping = 0; \ + (head)->hh.tbl->tail = _hs_tail; \ + DECLTYPE_ASSIGN(head, ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ + } \ + _hs_insize *= 2U; \ + } \ + HASH_FSCK(hh, head, "HASH_SRT"); \ + } \ + } while (0) + +/* This function selects items from one hash into another hash. + * The end result is that the selected items have dual presence + * in both hashes. There is no copy of the items made; rather + * they are added into the new hash through a secondary hash + * hash handle that must be present in the structure. */ +#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ + do { \ + unsigned _src_bkt, _dst_bkt; \ + void * _last_elt = NULL, *_elt; \ + UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh = NULL; \ + ptrdiff_t _dst_hho = ((char *)(&(dst)->hh_dst) - (char *)(dst)); \ + if ((src) != NULL) { \ + for (_src_bkt = 0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ + for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; _src_hh != NULL; \ + _src_hh = _src_hh->hh_next) { \ + _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ + if (cond(_elt)) { \ + IF_HASH_NONFATAL_OOM(int _hs_oomed = 0;) \ + _dst_hh = (UT_hash_handle *)(void *)(((char *)_elt) + _dst_hho); \ + _dst_hh->key = _src_hh->key; \ + _dst_hh->keylen = _src_hh->keylen; \ + _dst_hh->hashv = _src_hh->hashv; \ + _dst_hh->prev = _last_elt; \ + _dst_hh->next = NULL; \ + if (_last_elt_hh != NULL) { \ + _last_elt_hh->next = _elt; \ + } \ + if ((dst) == NULL) { \ + DECLTYPE_ASSIGN(dst, _elt); \ + HASH_MAKE_TABLE(hh_dst, dst, _hs_oomed); \ + IF_HASH_NONFATAL_OOM(if (_hs_oomed) { \ + uthash_nonfatal_oom(_elt); \ + (dst) = NULL; \ + continue; \ + }) \ + } \ + else { \ + _dst_hh->tbl = (dst)->hh_dst.tbl; \ + } \ + HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], hh_dst, _dst_hh, _hs_oomed); \ + (dst)->hh_dst.tbl->num_items++; \ + IF_HASH_NONFATAL_OOM(if (_hs_oomed) { \ + HASH_ROLLBACK_BKT(hh_dst, dst, _dst_hh); \ + HASH_DELETE_HH(hh_dst, dst, _dst_hh); \ + _dst_hh->tbl = NULL; \ + uthash_nonfatal_oom(_elt); \ + continue; \ + }) \ + HASH_BLOOM_ADD(_dst_hh->tbl, _dst_hh->hashv); \ + _last_elt = _elt; \ + _last_elt_hh = _dst_hh; \ + } \ + } \ + } \ + } \ + HASH_FSCK(hh_dst, dst, "HASH_SELECT"); \ + } while (0) + +#define HASH_CLEAR(hh, head) \ + do { \ + if ((head) != NULL) { \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl->buckets, \ + (head)->hh.tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ + (head) = NULL; \ + } \ + } while (0) + +#define HASH_OVERHEAD(hh, head) \ + (((head) != NULL) ? ((size_t)(((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ + ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ + sizeof(UT_hash_table) + (HASH_BLOOM_BYTELEN))) \ + : 0U) + +#ifdef NO_DECLTYPE +#define HASH_ITER(hh, head, el, tmp) \ + for (((el) = (head)), ((*(char **)(&(tmp))) = (char *)((head != NULL) ? (head)->hh.next : NULL)); \ + (el) != NULL; \ + ((el) = (tmp)), ((*(char **)(&(tmp))) = (char *)((tmp != NULL) ? (tmp)->hh.next : NULL))) +#else +#define HASH_ITER(hh, head, el, tmp) \ + for (((el) = (head)), ((tmp) = DECLTYPE(el)((head != NULL) ? (head)->hh.next : NULL)); (el) != NULL; \ + ((el) = (tmp)), ((tmp) = DECLTYPE(el)((tmp != NULL) ? (tmp)->hh.next : NULL))) +#endif + +/* obtain a count of items in the hash */ +#define HASH_COUNT(head) HASH_CNT(hh, head) +#define HASH_CNT(hh, head) ((head != NULL) ? ((head)->hh.tbl->num_items) : 0U) + +typedef struct UT_hash_bucket { + struct UT_hash_handle *hh_head; + unsigned count; + + /* expand_mult is normally set to 0. In this situation, the max chain length + * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If + * the bucket's chain exceeds this length, bucket expansion is triggered). + * However, setting expand_mult to a non-zero value delays bucket expansion + * (that would be triggered by additions to this particular bucket) + * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. + * (The multiplier is simply expand_mult+1). The whole idea of this + * multiplier is to reduce bucket expansions, since they are expensive, in + * situations where we know that a particular bucket tends to be overused. + * It is better to let its chain length grow to a longer yet-still-bounded + * value, than to do an O(n) bucket expansion too often. + */ + unsigned expand_mult; + +} UT_hash_bucket; + +/* random signature used only to find hash tables in external analysis */ +#define HASH_SIGNATURE 0xa0111fe1u +#define HASH_BLOOM_SIGNATURE 0xb12220f2u + +typedef struct UT_hash_table { + UT_hash_bucket * buckets; + unsigned num_buckets, log2_num_buckets; + unsigned num_items; + struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ + ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ + + /* in an ideal situation (all buckets used equally), no bucket would have + * more than ceil(#items/#buckets) items. that's the ideal chain length. */ + unsigned ideal_chain_maxlen; + + /* nonideal_items is the number of items in the hash whose chain position + * exceeds the ideal chain maxlen. these items pay the penalty for an uneven + * hash distribution; reaching them in a chain traversal takes >ideal steps */ + unsigned nonideal_items; + + /* ineffective expands occur when a bucket doubling was performed, but + * afterward, more than half the items in the hash had nonideal chain + * positions. If this happens on two consecutive expansions we inhibit any + * further expansion, as it's not helping; this happens when the hash + * function isn't a good fit for the key domain. When expansion is inhibited + * the hash will still work, albeit no longer in constant time. */ + unsigned ineff_expands, noexpand; + + uint32_t signature; /* used only to find hash tables in external analysis */ +#ifdef HASH_BLOOM + uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ + uint8_t *bloom_bv; + uint8_t bloom_nbits; +#endif + +} UT_hash_table; + +typedef struct UT_hash_handle { + struct UT_hash_table * tbl; + void * prev; /* prev element in app order */ + void * next; /* next element in app order */ + struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ + struct UT_hash_handle *hh_next; /* next hh in bucket order */ + void * key; /* ptr to enclosing struct's key */ + unsigned keylen; /* enclosing struct's key len */ + unsigned hashv; /* result of hash-fcn(key) */ +} UT_hash_handle; + +#endif /* UTHASH_H */